2 * Unit tests for window message handling
4 * Copyright 1999 Ove Kaaven
5 * Copyright 2003 Dimitrie O. Paun
6 * Copyright 2004, 2005 Dmitry Timoshkov
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
27 #define _WIN32_WINNT 0x0501 /* For WM_CHANGEUISTATE,QS_RAWINPUT */
35 #include "wine/test.h"
37 #define MDI_FIRST_CHILD_ID 2004
39 /* undocumented SWP flags - from SDK 3.1 */
40 #define SWP_NOCLIENTSIZE 0x0800
41 #define SWP_NOCLIENTMOVE 0x1000
42 #define SWP_STATECHANGED 0x8000
44 #define SW_NORMALNA 0xCC /* undoc. flag in MinMaximize */
47 #define WM_KEYF1 0x004d
51 #define WM_SYSTIMER 0x0118
54 #define WND_PARENT_ID 1
55 #define WND_POPUP_ID 2
56 #define WND_CHILD_ID 3
58 #ifndef WM_LBTRACKPOINT
59 #define WM_LBTRACKPOINT 0x0131
62 /* encoded DRAWITEMSTRUCT into an LPARAM */
69 UINT type : 4; /* ODT_* flags */
70 UINT ctl_id : 4; /* Control ID */
71 UINT item_id : 4; /* Menu item ID */
72 UINT action : 4; /* ODA_* flags */
73 UINT state : 16; /* ODS_* flags */
79 static BOOL test_DestroyWindow_flag;
80 static HWINEVENTHOOK hEvent_hook;
82 static void dump_winpos_flags(UINT flags);
84 static const WCHAR testWindowClassW[] =
85 { 'T','e','s','t','W','i','n','d','o','w','C','l','a','s','s','W',0 };
88 FIXME: add tests for these
89 Window Edge Styles (Win31/Win95/98 look), in order of precedence:
90 WS_EX_DLGMODALFRAME: double border, WS_CAPTION allowed
91 WS_THICKFRAME: thick border
92 WS_DLGFRAME: double border, WS_CAPTION not allowed (but possibly shown anyway)
93 WS_BORDER (default for overlapped windows): single black border
94 none (default for child (and popup?) windows): no border
111 UINT message; /* the WM_* code */
112 msg_flags_t flags; /* message props */
113 WPARAM wParam; /* expected value of wParam */
114 LPARAM lParam; /* expected value of lParam */
117 /* Empty message sequence */
118 static const struct message WmEmptySeq[] =
122 /* CreateWindow (for overlapped window, not initially visible) (16/32) */
123 static const struct message WmCreateOverlappedSeq[] = {
124 { HCBT_CREATEWND, hook },
125 { WM_GETMINMAXINFO, sent },
126 { WM_NCCREATE, sent },
127 { WM_NCCALCSIZE, sent|wparam, 0 },
128 { 0x0093, sent|defwinproc|optional },
129 { 0x0094, sent|defwinproc|optional },
130 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
132 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
135 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
136 * for a not visible overlapped window.
138 static const struct message WmSWP_ShowOverlappedSeq[] = {
139 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
140 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
141 { WM_NCPAINT, sent|wparam|optional, 1 },
142 { WM_GETTEXT, sent|defwinproc|optional },
143 { WM_ERASEBKGND, sent|optional },
144 { HCBT_ACTIVATE, hook },
145 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
146 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
147 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* Win9x: SWP_NOSENDCHANGING */
148 { WM_ACTIVATEAPP, sent|wparam, 1 },
149 { WM_NCACTIVATE, sent|wparam, 1 },
150 { WM_GETTEXT, sent|defwinproc|optional },
151 { WM_ACTIVATE, sent|wparam, 1 },
152 { HCBT_SETFOCUS, hook },
153 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
154 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
155 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
156 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
157 { WM_NCPAINT, sent|wparam|optional, 1 },
158 { WM_GETTEXT, sent|defwinproc|optional },
159 { WM_ERASEBKGND, sent|optional },
160 /* Win9x adds SWP_NOZORDER below */
161 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
162 { WM_NCCALCSIZE, sent|wparam|optional, 1 },
163 { WM_NCPAINT, sent|wparam|optional, 1 },
164 { WM_ERASEBKGND, sent|optional },
165 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
168 /* SetWindowPos(SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE)
169 * for a visible overlapped window.
171 static const struct message WmSWP_HideOverlappedSeq[] = {
172 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE },
173 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
174 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
178 /* SetWindowPos(SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOMOVE)
179 * for a visible overlapped window.
181 static const struct message WmSWP_ResizeSeq[] = {
182 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE },
183 { WM_GETMINMAXINFO, sent|defwinproc },
184 { WM_NCCALCSIZE, sent|wparam, TRUE },
185 { WM_NCPAINT, sent|optional },
186 { WM_GETTEXT, sent|defwinproc|optional },
187 { WM_ERASEBKGND, sent|optional },
188 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOCLIENTMOVE },
189 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
190 { WM_NCCALCSIZE, sent|wparam|optional, TRUE },
191 { WM_NCPAINT, sent|optional },
192 { WM_GETTEXT, sent|defwinproc|optional },
193 { WM_ERASEBKGND, sent|optional },
194 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
195 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* XP sends a duplicate */
199 /* SetWindowPos(SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOMOVE)
200 * for a visible popup window.
202 static const struct message WmSWP_ResizePopupSeq[] = {
203 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE },
204 { WM_GETMINMAXINFO, sent|defwinproc|optional }, /* Win9x */
205 { WM_NCCALCSIZE, sent|wparam, TRUE },
206 { WM_NCPAINT, sent|optional },
207 { WM_GETTEXT, sent|defwinproc|optional },
208 { WM_ERASEBKGND, sent|optional },
209 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOCLIENTMOVE },
210 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
211 { WM_NCCALCSIZE, sent|wparam|optional, TRUE },
212 { WM_NCPAINT, sent|optional },
213 { WM_GETTEXT, sent|defwinproc|optional },
214 { WM_ERASEBKGND, sent|optional },
215 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
219 /* SetWindowPos(SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOSIZE)
220 * for a visible overlapped window.
222 static const struct message WmSWP_MoveSeq[] = {
223 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_NOSIZE },
224 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOCLIENTSIZE },
225 { WM_MOVE, sent|defwinproc|wparam, 0 },
226 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
229 /* Resize with SetWindowPos(SWP_NOZORDER)
230 * for a visible overlapped window
231 * SWP_NOZORDER is stripped by the logging code
233 static const struct message WmSWP_ResizeNoZOrder[] = {
234 { WM_WINDOWPOSCHANGING, sent|wparam, 0/*SWP_NOZORDER*/ },
235 { WM_GETMINMAXINFO, sent|defwinproc },
236 { WM_NCCALCSIZE, sent|wparam, 1 },
237 { WM_NCPAINT, sent },
238 { WM_GETTEXT, sent|defwinproc|optional },
239 { WM_ERASEBKGND, sent|optional }, /* FIXME: remove optional once Wine is fixed */
240 { WM_WINDOWPOSCHANGED, sent|wparam, /*SWP_NOZORDER|*/SWP_NOMOVE|SWP_NOCLIENTMOVE },
241 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
242 { WM_NCCALCSIZE, sent|wparam|optional, 1 }, /* Win9x doesn't send it */
243 { WM_NCPAINT, sent|optional }, /* Win9x doesn't send it */
244 { WM_GETTEXT, sent|defwinproc|optional }, /* Win9x doesn't send it */
245 { WM_ERASEBKGND, sent|optional }, /* Win9x doesn't send it */
246 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
247 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
251 /* Switch visible mdi children */
252 static const struct message WmSwitchChild[] = {
253 /* Switch MDI child */
254 { WM_MDIACTIVATE, sent },/* in the MDI client */
255 { WM_WINDOWPOSCHANGING, sent|wparam,SWP_NOSIZE|SWP_NOMOVE },/* in the 1st MDI child */
256 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
257 { WM_CHILDACTIVATE, sent },/* in the 1st MDI child */
258 /* Deactivate 2nd MDI child */
259 { WM_NCACTIVATE, sent|wparam|defwinproc, 0 }, /* in the 2nd MDI child */
260 { WM_MDIACTIVATE, sent|defwinproc }, /* in the 2nd MDI child */
261 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
262 /* Preparing for maximize and maximaze the 1st MDI child */
263 { WM_GETMINMAXINFO, sent|defwinproc }, /* in the 1st MDI child */
264 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_STATECHANGED }, /* in the 1st MDI child */
265 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 }, /* in the 1st MDI child */
266 { WM_CHILDACTIVATE, sent|defwinproc }, /* in the 1st MDI child */
267 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_STATECHANGED }, /* in the 1st MDI child */
268 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED }, /* in the 1st MDI child */
269 /* Lock redraw 2nd MDI child */
270 { WM_SETREDRAW, sent|wparam|defwinproc, 0 }, /* in the 2nd MDI child */
271 { HCBT_MINMAX, hook|lparam, 0, SW_NORMALNA },
272 /* Restore 2nd MDI child */
273 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_STATECHANGED },/* in the 2nd MDI child */
274 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 },/* in the 2nd MDI child */
275 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 }, /* in the 2nd MDI child */
276 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_STATECHANGED }, /* in the 2nd MDI child */
277 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED }, /* in the 2nd MDI child */
278 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* in the 2nd MDI child */
279 /* Redraw 2nd MDI child */
280 { WM_SETREDRAW, sent|wparam|defwinproc, 1 },/* in the 2nd MDI child */
281 /* Redraw MDI frame */
282 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE },/* in MDI frame */
283 { WM_NCCALCSIZE, sent|wparam, 1 },/* in MDI frame */
284 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE}, /* in MDI frame */
285 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* in MDI frame */
286 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* in the 1st MDI child */
287 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE }, /* in the 1st MDI child */
288 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 }, /* in the 1st MDI child */
289 { HCBT_SETFOCUS, hook },
290 { WM_KILLFOCUS, sent|defwinproc }, /* in the 2nd MDI child */
291 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 0 },/* in the 1st MDI child */
292 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
293 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
294 { WM_SETFOCUS, sent },/* in the MDI client */
295 { HCBT_SETFOCUS, hook },
296 { WM_KILLFOCUS, sent },/* in the MDI client */
297 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
298 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 }, /* in the 1st MDI child */
299 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
300 { WM_SETFOCUS, sent|defwinproc }, /* in the 1st MDI child */
301 { WM_MDIACTIVATE, sent|defwinproc },/* in the 1st MDI child */
302 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE }, /* in the 1st MDI child */
306 /* Switch visible not maximized mdi children */
307 static const struct message WmSwitchNotMaximizedChild[] = {
308 /* Switch not maximized MDI child */
309 { WM_MDIACTIVATE, sent },/* in the MDI client */
310 { WM_WINDOWPOSCHANGING, sent|wparam,SWP_NOSIZE|SWP_NOMOVE },/* in the 2nd MDI child */
311 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
312 { WM_CHILDACTIVATE, sent },/* in the 2nd MDI child */
313 /* Deactivate 1st MDI child */
314 { WM_NCACTIVATE, sent|wparam|defwinproc, 0 }, /* in the 1st MDI child */
315 { WM_MDIACTIVATE, sent|defwinproc }, /* in the 1st MDI child */
316 /* Activate 2nd MDI child */
317 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE}, /* in the 2nd MDI child */
318 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 }, /* in the 2nd MDI child */
319 { HCBT_SETFOCUS, hook }, /* in the 1st MDI child */
320 { WM_KILLFOCUS, sent|defwinproc }, /* in the 1st MDI child */
321 { WM_IME_SETCONTEXT, sent|defwinproc|optional }, /* in the 1st MDI child */
322 { WM_IME_SETCONTEXT, sent|optional }, /* in the MDI client */
323 { WM_SETFOCUS, sent, 0 }, /* in the MDI client */
324 { HCBT_SETFOCUS, hook },
325 { WM_KILLFOCUS, sent }, /* in the MDI client */
326 { WM_IME_SETCONTEXT, sent|optional }, /* in the MDI client */
327 { WM_IME_SETCONTEXT, sent|defwinproc|optional }, /* in the 1st MDI child */
328 { WM_SETFOCUS, sent|defwinproc }, /* in the 2nd MDI child */
329 { WM_MDIACTIVATE, sent|defwinproc }, /* in the 2nd MDI child */
330 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE}, /* in the 2nd MDI child */
335 /* SetWindowPos(SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|
336 SWP_NOZORDER|SWP_FRAMECHANGED)
337 * for a visible overlapped window with WS_CLIPCHILDREN style set.
339 static const struct message WmSWP_FrameChanged_clip[] = {
340 { WM_WINDOWPOSCHANGING, sent|wparam|parent, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED },
341 { WM_NCCALCSIZE, sent|wparam|parent, 1 },
342 { WM_NCPAINT, sent|parent }, /* wparam != 1 */
343 { WM_GETTEXT, sent|parent|defwinproc|optional },
344 { WM_ERASEBKGND, sent|parent|optional }, /* FIXME: remove optional once Wine is fixed */
345 { WM_NCPAINT, sent }, /* wparam != 1 */
346 { WM_ERASEBKGND, sent },
347 { WM_WINDOWPOSCHANGED, sent|wparam|parent, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
348 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
352 /* SetWindowPos(SWP_NOSIZE|SWP_NOMOVE|SWP_DEFERERASE|SWP_NOACTIVATE|
353 SWP_NOZORDER|SWP_FRAMECHANGED)
354 * for a visible overlapped window.
356 static const struct message WmSWP_FrameChangedDeferErase[] = {
357 { WM_WINDOWPOSCHANGING, sent|wparam|parent, SWP_NOSIZE|SWP_NOMOVE|SWP_DEFERERASE|SWP_NOACTIVATE|SWP_FRAMECHANGED },
358 { WM_NCCALCSIZE, sent|wparam|parent, 1 },
359 { WM_WINDOWPOSCHANGED, sent|wparam|parent, SWP_NOSIZE|SWP_NOMOVE|SWP_DEFERERASE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
360 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
361 { WM_PAINT, sent|parent },
362 { WM_NCPAINT, sent|beginpaint|parent }, /* wparam != 1 */
363 { WM_GETTEXT, sent|beginpaint|parent|defwinproc|optional },
365 { WM_NCPAINT, sent|beginpaint }, /* wparam != 1 */
366 { WM_ERASEBKGND, sent|beginpaint },
370 /* SetWindowPos(SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|
371 SWP_NOZORDER|SWP_FRAMECHANGED)
372 * for a visible overlapped window without WS_CLIPCHILDREN style set.
374 static const struct message WmSWP_FrameChanged_noclip[] = {
375 { WM_WINDOWPOSCHANGING, sent|wparam|parent, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED },
376 { WM_NCCALCSIZE, sent|wparam|parent, 1 },
377 { WM_NCPAINT, sent|parent }, /* wparam != 1 */
378 { WM_GETTEXT, sent|parent|defwinproc|optional },
379 { WM_ERASEBKGND, sent|parent|optional }, /* FIXME: remove optional once Wine is fixed */
380 { WM_WINDOWPOSCHANGED, sent|wparam|parent, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
381 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
383 { WM_NCPAINT, sent|beginpaint }, /* wparam != 1 */
384 { WM_ERASEBKGND, sent|beginpaint },
388 /* ShowWindow(SW_SHOW) for a not visible overlapped window */
389 static const struct message WmShowOverlappedSeq[] = {
390 { WM_SHOWWINDOW, sent|wparam, 1 },
391 { WM_NCPAINT, sent|wparam|optional, 1 },
392 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
393 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
394 { WM_NCPAINT, sent|wparam|optional, 1 },
395 { WM_GETTEXT, sent|defwinproc|optional },
396 { WM_ERASEBKGND, sent|optional },
397 { HCBT_ACTIVATE, hook },
398 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
399 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
400 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE },
401 { WM_NCPAINT, sent|wparam|optional, 1 },
402 { WM_ACTIVATEAPP, sent|wparam, 1 },
403 { WM_NCACTIVATE, sent|wparam, 1 },
404 { WM_GETTEXT, sent|defwinproc|optional },
405 { WM_ACTIVATE, sent|wparam, 1 },
406 { HCBT_SETFOCUS, hook },
407 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
408 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
409 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
410 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
411 { WM_NCPAINT, sent|wparam|optional, 1 },
412 { WM_GETTEXT, sent|defwinproc|optional },
413 { WM_ERASEBKGND, sent|optional },
414 /* Win9x adds SWP_NOZORDER below */
415 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
416 { WM_NCCALCSIZE, sent|optional },
417 { WM_NCPAINT, sent|optional },
418 { WM_ERASEBKGND, sent|optional },
419 #if 0 /* CreateWindow/ShowWindow(SW_SHOW) also generates WM_SIZE/WM_MOVE
420 * messages. Does that mean that CreateWindow doesn't set initial
421 * window dimensions for overlapped windows?
428 /* ShowWindow(SW_SHOWMAXIMIZED) for a not visible overlapped window */
429 static const struct message WmShowMaxOverlappedSeq[] = {
430 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
431 { WM_GETMINMAXINFO, sent },
432 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_STATECHANGED },
433 { WM_GETMINMAXINFO, sent|defwinproc },
434 { WM_NCCALCSIZE, sent|wparam, TRUE },
435 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
436 { HCBT_ACTIVATE, hook },
437 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
438 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
439 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE },
440 { WM_ACTIVATEAPP, sent|wparam, 1 },
441 { WM_NCACTIVATE, sent|wparam, 1 },
442 { WM_GETTEXT, sent|defwinproc|optional },
443 { WM_ACTIVATE, sent|wparam, 1 },
444 { HCBT_SETFOCUS, hook },
445 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
446 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
447 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
448 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
449 { WM_NCPAINT, sent|wparam|optional, 1 },
450 { WM_GETTEXT, sent|defwinproc|optional },
451 { WM_ERASEBKGND, sent|optional },
452 /* Win9x adds SWP_NOZORDER below */
453 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_STATECHANGED },
454 { WM_MOVE, sent|defwinproc },
455 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
456 { WM_NCCALCSIZE, sent|optional },
457 { WM_NCPAINT, sent|optional },
458 { WM_ERASEBKGND, sent|optional },
459 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
460 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
463 /* ShowWindow(SW_SHOWMINIMIZED) for a not visible overlapped window */
464 static const struct message WmShowMinOverlappedSeq[] = {
465 { HCBT_MINMAX, hook|lparam, 0, SW_MINIMIZE },
466 { HCBT_SETFOCUS, hook },
467 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
468 { WM_KILLFOCUS, sent },
469 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
470 { WM_IME_NOTIFY, sent|wparam|optional|defwinproc, 1 },
471 { WM_GETTEXT, sent|optional },
472 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOCOPYBITS|SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_STATECHANGED },
473 { WM_GETMINMAXINFO, sent|defwinproc },
474 { WM_NCCALCSIZE, sent|wparam, TRUE },
475 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
476 { WM_NCPAINT, sent },
477 { WM_GETTEXT, sent|defwinproc|optional },
478 { WM_WINDOWPOSCHANGED, sent },
479 { WM_MOVE, sent|defwinproc },
480 { WM_SIZE, sent|defwinproc|wparam, SIZE_MINIMIZED },
481 { WM_NCCALCSIZE, sent|optional },
482 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
483 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
484 { EVENT_SYSTEM_MINIMIZESTART, winevent_hook|wparam|lparam, 0, 0 },
485 { WM_NCACTIVATE, sent|wparam, 0 },
486 { WM_GETTEXT, sent|defwinproc|optional },
487 { WM_ACTIVATE, sent },
488 { WM_ACTIVATEAPP, sent|wparam, 0 },
491 /* ShowWindow(SW_HIDE) for a visible overlapped window */
492 static const struct message WmHideOverlappedSeq[] = {
493 { WM_SHOWWINDOW, sent|wparam, 0 },
494 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE },
495 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
496 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
497 { WM_SIZE, sent|optional }, /* XP doesn't send it */
498 { WM_MOVE, sent|optional }, /* XP doesn't send it */
499 { WM_NCACTIVATE, sent|wparam, 0 },
500 { WM_ACTIVATE, sent|wparam, 0 },
501 { WM_ACTIVATEAPP, sent|wparam, 0 },
502 { WM_KILLFOCUS, sent|wparam, 0 },
503 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
504 { WM_IME_NOTIFY, sent|wparam|optional|defwinproc, 1 },
507 /* DestroyWindow for a visible overlapped window */
508 static const struct message WmDestroyOverlappedSeq[] = {
509 { HCBT_DESTROYWND, hook },
510 { 0x0090, sent|optional },
511 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
512 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
513 { 0x0090, sent|optional },
514 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
515 { WM_NCACTIVATE, sent|wparam, 0 },
516 { WM_ACTIVATE, sent|wparam, 0 },
517 { WM_ACTIVATEAPP, sent|wparam, 0 },
518 { WM_KILLFOCUS, sent|wparam, 0 },
519 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
520 { WM_IME_NOTIFY, sent|wparam|optional|defwinproc, 1 },
521 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
522 { WM_DESTROY, sent },
523 { WM_NCDESTROY, sent },
526 /* CreateWindow(WS_MAXIMIZE|WS_VISIBLE) for popup window */
527 static const struct message WmCreateMaxPopupSeq[] = {
528 { HCBT_CREATEWND, hook },
529 { WM_NCCREATE, sent },
530 { WM_NCCALCSIZE, sent|wparam, 0 },
532 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
533 { WM_SIZE, sent|wparam, SIZE_RESTORED },
535 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
536 { WM_GETMINMAXINFO, sent },
537 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_STATECHANGED },
538 { WM_NCCALCSIZE, sent|wparam, TRUE },
539 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOREDRAW|SWP_STATECHANGED },
540 { WM_MOVE, sent|defwinproc },
541 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
542 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
543 { WM_SHOWWINDOW, sent|wparam, 1 },
544 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
545 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
546 { HCBT_ACTIVATE, hook },
547 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
548 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
549 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE },
550 { WM_ACTIVATEAPP, sent|wparam, 1 },
551 { WM_NCACTIVATE, sent|wparam, 1 },
552 { WM_ACTIVATE, sent|wparam, 1 },
553 { HCBT_SETFOCUS, hook },
554 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
555 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
556 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
557 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
558 { WM_SYNCPAINT, sent|wparam|optional, 4 },
559 { WM_NCPAINT, sent|wparam|optional, 1 },
560 { WM_ERASEBKGND, sent|optional },
561 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOCLIENTMOVE|SWP_NOCLIENTSIZE|SWP_SHOWWINDOW|SWP_NOMOVE|SWP_NOSIZE },
564 /* CreateWindow(WS_MAXIMIZE) for popup window, not initially visible */
565 static const struct message WmCreateInvisibleMaxPopupSeq[] = {
566 { HCBT_CREATEWND, hook },
567 { WM_NCCREATE, sent },
568 { WM_NCCALCSIZE, sent|wparam, 0 },
570 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
571 { WM_SIZE, sent|wparam, SIZE_RESTORED },
573 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
574 { WM_GETMINMAXINFO, sent },
575 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_STATECHANGED },
576 { WM_NCCALCSIZE, sent|wparam, TRUE },
577 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOREDRAW|SWP_STATECHANGED },
578 { WM_MOVE, sent|defwinproc },
579 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
580 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
583 /* ShowWindow(SW_SHOWMAXIMIZED) for a resized not visible popup window */
584 static const struct message WmShowMaxPopupResizedSeq[] = {
585 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
586 { WM_GETMINMAXINFO, sent },
587 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED },
588 { WM_NCCALCSIZE, sent|wparam, TRUE },
589 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
590 { HCBT_ACTIVATE, hook },
591 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
592 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
593 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE },
594 { WM_ACTIVATEAPP, sent|wparam, 1 },
595 { WM_NCACTIVATE, sent|wparam, 1 },
596 { WM_ACTIVATE, sent|wparam, 1 },
597 { HCBT_SETFOCUS, hook },
598 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
599 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
600 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
601 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
602 { WM_NCPAINT, sent|wparam|optional, 1 },
603 { WM_ERASEBKGND, sent|optional },
604 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOCLIENTMOVE|SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOMOVE },
605 /* WinNT4.0 sends WM_MOVE */
606 { WM_MOVE, sent|defwinproc|optional },
607 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
608 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
611 /* ShowWindow(SW_SHOWMAXIMIZED) for a not visible popup window */
612 static const struct message WmShowMaxPopupSeq[] = {
613 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
614 { WM_GETMINMAXINFO, sent },
615 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED },
616 { WM_NCCALCSIZE, sent|wparam, TRUE },
617 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
618 { HCBT_ACTIVATE, hook },
619 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
620 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
621 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE },
622 { WM_ACTIVATEAPP, sent|wparam, 1 },
623 { WM_NCACTIVATE, sent|wparam, 1 },
624 { WM_ACTIVATE, sent|wparam, 1 },
625 { HCBT_SETFOCUS, hook },
626 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
627 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
628 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
629 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
630 { WM_SYNCPAINT, sent|wparam|optional, 4 },
631 { WM_NCPAINT, sent|wparam|optional, 1 },
632 { WM_ERASEBKGND, sent|optional },
633 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOMOVE|SWP_NOSIZE },
634 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
637 /* CreateWindow(WS_VISIBLE) for popup window */
638 static const struct message WmCreatePopupSeq[] = {
639 { HCBT_CREATEWND, hook },
640 { WM_NCCREATE, sent },
641 { WM_NCCALCSIZE, sent|wparam, 0 },
643 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
644 { WM_SIZE, sent|wparam, SIZE_RESTORED },
646 { WM_SHOWWINDOW, sent|wparam, 1 },
647 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
648 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
649 { HCBT_ACTIVATE, hook },
650 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
651 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
652 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE },
653 { WM_NCPAINT, sent|wparam|optional, 1 },
654 { WM_ERASEBKGND, sent|optional },
655 { WM_ACTIVATEAPP, sent|wparam, 1 },
656 { WM_NCACTIVATE, sent|wparam, 1 },
657 { WM_ACTIVATE, sent|wparam, 1 },
658 { HCBT_SETFOCUS, hook },
659 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
660 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
661 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
662 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
663 { WM_SYNCPAINT, sent|wparam|optional, 4 },
664 { WM_NCPAINT, sent|wparam|optional, 1 },
665 { WM_ERASEBKGND, sent|optional },
666 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOCLIENTMOVE|SWP_NOCLIENTSIZE|SWP_SHOWWINDOW|SWP_NOMOVE|SWP_NOSIZE },
669 /* ShowWindow(SW_SHOWMAXIMIZED) for a visible popup window */
670 static const struct message WmShowVisMaxPopupSeq[] = {
671 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
672 { WM_GETMINMAXINFO, sent },
673 { WM_GETTEXT, sent|optional },
674 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_STATECHANGED },
675 { WM_NCCALCSIZE, sent|wparam, TRUE },
676 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
677 { WM_NCPAINT, sent|wparam|optional, 1 },
678 { WM_ERASEBKGND, sent|optional },
679 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_STATECHANGED },
680 { WM_MOVE, sent|defwinproc },
681 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
682 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
685 /* CreateWindow (for a child popup window, not initially visible) */
686 static const struct message WmCreateChildPopupSeq[] = {
687 { HCBT_CREATEWND, hook },
688 { WM_NCCREATE, sent },
689 { WM_NCCALCSIZE, sent|wparam, 0 },
691 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
692 { WM_SIZE, sent|wparam, SIZE_RESTORED },
696 /* CreateWindow (for a popup window, not initially visible,
697 * which sets WS_VISIBLE in WM_CREATE handler)
699 static const struct message WmCreateInvisiblePopupSeq[] = {
700 { HCBT_CREATEWND, hook },
701 { WM_NCCREATE, sent },
702 { WM_NCCALCSIZE, sent|wparam, 0 },
704 { WM_STYLECHANGING, sent },
705 { WM_STYLECHANGED, sent },
706 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
707 { WM_SIZE, sent|wparam, SIZE_RESTORED },
711 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER)
712 * for a popup window with WS_VISIBLE style set
714 static const struct message WmShowVisiblePopupSeq_2[] = {
715 { WM_WINDOWPOSCHANGING, sent|wparam, 0 },
718 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
719 * for a popup window with WS_VISIBLE style set
721 static const struct message WmShowVisiblePopupSeq_3[] = {
722 { WM_WINDOWPOSCHANGING, sent|wparam, 0 },
723 { HCBT_ACTIVATE, hook },
724 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
725 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
726 { WM_WINDOWPOSCHANGING, sent|wparam, 0 },
727 { WM_NCACTIVATE, sent|wparam, 1 },
728 { WM_ACTIVATE, sent|wparam, 1 },
729 { HCBT_SETFOCUS, hook },
730 { WM_KILLFOCUS, sent|parent },
731 { WM_IME_SETCONTEXT, sent|parent|wparam|optional, 0 },
732 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
733 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
734 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
735 { WM_SETFOCUS, sent|defwinproc },
738 /* CreateWindow (for child window, not initially visible) */
739 static const struct message WmCreateChildSeq[] = {
740 { HCBT_CREATEWND, hook },
741 { WM_NCCREATE, sent },
742 /* child is inserted into parent's child list after WM_NCCREATE returns */
743 { WM_NCCALCSIZE, sent|wparam, 0 },
745 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
746 { WM_SIZE, sent|wparam, SIZE_RESTORED },
748 { WM_PARENTNOTIFY, sent|parent|wparam, WM_CREATE },
751 /* CreateWindow (for maximized child window, not initially visible) */
752 static const struct message WmCreateMaximizedChildSeq[] = {
753 { HCBT_CREATEWND, hook },
754 { WM_NCCREATE, sent },
755 { WM_NCCALCSIZE, sent|wparam, 0 },
757 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
758 { WM_SIZE, sent|wparam, SIZE_RESTORED },
760 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
761 { WM_GETMINMAXINFO, sent },
762 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_STATECHANGED },
763 { WM_NCCALCSIZE, sent|wparam, 1 },
764 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTMOVE|SWP_STATECHANGED },
765 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
766 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
767 { WM_PARENTNOTIFY, sent|parent|wparam, WM_CREATE },
770 /* CreateWindow (for a child window, initially visible) */
771 static const struct message WmCreateVisibleChildSeq[] = {
772 { HCBT_CREATEWND, hook },
773 { WM_NCCREATE, sent },
774 /* child is inserted into parent's child list after WM_NCCREATE returns */
775 { WM_NCCALCSIZE, sent|wparam, 0 },
776 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
778 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
779 { WM_SIZE, sent|wparam, SIZE_RESTORED },
781 { WM_PARENTNOTIFY, sent|parent|wparam, WM_CREATE },
782 { WM_SHOWWINDOW, sent|wparam, 1 },
783 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
784 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
785 { WM_ERASEBKGND, sent|parent|optional },
786 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
787 { WM_NCCALCSIZE, sent|wparam|optional, 1 }, /* WinXP */
788 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
791 /* ShowWindow(SW_SHOW) for a not visible child window */
792 static const struct message WmShowChildSeq[] = {
793 { WM_SHOWWINDOW, sent|wparam, 1 },
794 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
795 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
796 { WM_ERASEBKGND, sent|parent|optional },
797 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
800 /* ShowWindow(SW_HIDE) for a visible child window */
801 static const struct message WmHideChildSeq[] = {
802 { WM_SHOWWINDOW, sent|wparam, 0 },
803 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
804 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
805 { WM_ERASEBKGND, sent|parent|optional },
806 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
809 /* ShowWindow(SW_HIDE) for a visible child window checking all parent events*/
810 static const struct message WmHideChildSeq2[] = {
811 { WM_SHOWWINDOW, sent|wparam, 0 },
812 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
813 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
814 { WM_ERASEBKGND, sent|parent },
815 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
818 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
819 * for a not visible child window
821 static const struct message WmShowChildSeq_2[] = {
822 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
823 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
824 { WM_CHILDACTIVATE, sent },
825 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
828 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE)
829 * for a not visible child window
831 static const struct message WmShowChildSeq_3[] = {
832 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
833 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
834 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
837 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
838 * for a visible child window with a caption
840 static const struct message WmShowChildSeq_4[] = {
841 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
842 { WM_CHILDACTIVATE, sent },
845 /* ShowWindow(SW_MINIMIZE) for child with invisible parent */
846 static const struct message WmShowChildInvisibleParentSeq_1[] = {
847 { HCBT_MINMAX, hook|lparam, 0, SW_MINIMIZE },
848 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOCOPYBITS|SWP_STATECHANGED },
849 { WM_NCCALCSIZE, sent|wparam, 1 },
850 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
851 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOREDRAW|SWP_NOCOPYBITS|SWP_STATECHANGED },
852 { WM_MOVE, sent|defwinproc },
853 { WM_SIZE, sent|defwinproc|wparam, SIZE_MINIMIZED },
854 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
855 { EVENT_SYSTEM_MINIMIZESTART, winevent_hook|wparam|lparam, 0, 0 },
856 /* FIXME: Wine creates an icon/title window while Windows doesn't */
857 { WM_PARENTNOTIFY, sent|parent|wparam|optional, WM_CREATE },
858 { WM_GETTEXT, sent|optional },
861 /* repeated ShowWindow(SW_MINIMIZE) for child with invisible parent */
862 static const struct message WmShowChildInvisibleParentSeq_1r[] = {
863 { HCBT_MINMAX, hook|lparam, 0, SW_MINIMIZE },
866 /* ShowWindow(SW_MAXIMIZE) for child with invisible parent */
867 static const struct message WmShowChildInvisibleParentSeq_2[] = {
868 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
869 { WM_GETMINMAXINFO, sent },
870 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_STATECHANGED },
871 { WM_NCCALCSIZE, sent|wparam, 1 },
872 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
873 { WM_CHILDACTIVATE, sent },
874 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTMOVE|SWP_STATECHANGED },
875 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
876 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
879 /* repeated ShowWindow(SW_MAXIMIZE) for child with invisible parent */
880 static const struct message WmShowChildInvisibleParentSeq_2r[] = {
881 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
884 /* ShowWindow(SW_SHOWMINIMIZED) for child with invisible parent */
885 static const struct message WmShowChildInvisibleParentSeq_3[] = {
886 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMINIMIZED },
887 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
888 { WM_NCCALCSIZE, sent|wparam, 1 },
889 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
890 { WM_CHILDACTIVATE, sent },
891 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOREDRAW|SWP_NOCOPYBITS|SWP_STATECHANGED },
892 { WM_MOVE, sent|defwinproc },
893 { WM_SIZE, sent|defwinproc|wparam, SIZE_MINIMIZED },
894 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
895 { EVENT_SYSTEM_MINIMIZESTART, winevent_hook|wparam|lparam, 0, 0 },
896 /* FIXME: Wine creates an icon/title window while Windows doesn't */
897 { WM_PARENTNOTIFY, sent|parent|wparam|optional, WM_CREATE },
898 { WM_GETTEXT, sent|optional },
901 /* repeated ShowWindow(SW_SHOWMINIMIZED) for child with invisible parent */
902 static const struct message WmShowChildInvisibleParentSeq_3r[] = {
903 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMINIMIZED },
906 /* ShowWindow(SW_SHOWMINNOACTIVE) for child with invisible parent */
907 static const struct message WmShowChildInvisibleParentSeq_4[] = {
908 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMINNOACTIVE },
909 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOCOPYBITS|SWP_STATECHANGED },
910 { WM_NCCALCSIZE, sent|wparam, 1 },
911 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
912 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOREDRAW|SWP_NOCOPYBITS|SWP_STATECHANGED },
913 { WM_MOVE, sent|defwinproc },
914 { WM_SIZE, sent|defwinproc|wparam, SIZE_MINIMIZED },
915 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
916 { EVENT_SYSTEM_MINIMIZESTART, winevent_hook|wparam|lparam, 0, 0 },
917 /* FIXME: Wine creates an icon/title window while Windows doesn't */
918 { WM_PARENTNOTIFY, sent|parent|wparam|optional, WM_CREATE },
919 { WM_GETTEXT, sent|optional },
922 /* repeated ShowWindow(SW_SHOWMINNOACTIVE) for child with invisible parent */
923 static const struct message WmShowChildInvisibleParentSeq_4r[] = {
924 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMINNOACTIVE },
927 /* ShowWindow(SW_SHOW) for child with invisible parent */
928 static const struct message WmShowChildInvisibleParentSeq_5[] = {
929 { WM_SHOWWINDOW, sent|wparam, 1 },
932 /* ShowWindow(SW_HIDE) for child with invisible parent */
933 static const struct message WmHideChildInvisibleParentSeq[] = {
934 { WM_SHOWWINDOW, sent|wparam, 0 },
937 /* SetWindowPos(SWP_SHOWWINDOW) for child with invisible parent */
938 static const struct message WmShowChildInvisibleParentSeq_6[] = {
939 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
940 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
941 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
944 /* SetWindowPos(SWP_HIDEWINDOW) for child with invisible parent */
945 static const struct message WmHideChildInvisibleParentSeq_2[] = {
946 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
947 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
948 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
951 /* DestroyWindow for a visible child window */
952 static const struct message WmDestroyChildSeq[] = {
953 { HCBT_DESTROYWND, hook },
954 { 0x0090, sent|optional },
955 { WM_PARENTNOTIFY, sent|parent|wparam, WM_DESTROY },
956 { WM_SHOWWINDOW, sent|wparam, 0 },
957 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
958 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
959 { WM_ERASEBKGND, sent|parent|optional },
960 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
961 { HCBT_SETFOCUS, hook }, /* set focus to a parent */
962 { WM_KILLFOCUS, sent },
963 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
964 { WM_IME_SETCONTEXT, sent|wparam|parent|optional, 1 },
965 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
966 { WM_SETFOCUS, sent|parent },
967 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
968 { WM_DESTROY, sent },
969 { WM_DESTROY, sent|optional }, /* some other (IME?) window */
970 { WM_NCDESTROY, sent|optional }, /* some other (IME?) window */
971 { WM_NCDESTROY, sent },
974 /* DestroyWindow for a visible child window with invisible parent */
975 static const struct message WmDestroyInvisibleChildSeq[] = {
976 { HCBT_DESTROYWND, hook },
977 { 0x0090, sent|optional },
978 { WM_PARENTNOTIFY, sent|parent|wparam, WM_DESTROY },
979 { WM_SHOWWINDOW, sent|wparam, 0 },
980 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
981 { WM_DESTROY, sent },
982 { WM_NCDESTROY, sent },
985 /* Moving the mouse in nonclient area */
986 static const struct message WmMouseMoveInNonClientAreaSeq[] = { /* FIXME: add */
987 { WM_NCHITTEST, sent },
988 { WM_SETCURSOR, sent },
989 { WM_NCMOUSEMOVE, posted },
992 /* Moving the mouse in client area */
993 static const struct message WmMouseMoveInClientAreaSeq[] = { /* FIXME: add */
994 { WM_NCHITTEST, sent },
995 { WM_SETCURSOR, sent },
996 { WM_MOUSEMOVE, posted },
999 /* Moving by dragging the title bar (after WM_NCHITTEST and WM_SETCURSOR) (outline move) */
1000 static const struct message WmDragTitleBarSeq[] = { /* FIXME: add */
1001 { WM_NCLBUTTONDOWN, sent|wparam, HTCAPTION },
1002 { WM_SYSCOMMAND, sent|defwinproc|wparam, SC_MOVE+2 },
1003 { WM_GETMINMAXINFO, sent|defwinproc },
1004 { WM_ENTERSIZEMOVE, sent|defwinproc },
1005 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, 0 },
1006 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, 0 },
1007 { WM_MOVE, sent|defwinproc },
1008 { WM_EXITSIZEMOVE, sent|defwinproc },
1011 /* Sizing by dragging the thick borders (after WM_NCHITTEST and WM_SETCURSOR) (outline move) */
1012 static const struct message WmDragThickBordersBarSeq[] = { /* FIXME: add */
1013 { WM_NCLBUTTONDOWN, sent|wparam, 0xd },
1014 { WM_SYSCOMMAND, sent|defwinproc|wparam, 0xf004 },
1015 { WM_GETMINMAXINFO, sent|defwinproc },
1016 { WM_ENTERSIZEMOVE, sent|defwinproc },
1017 { WM_SIZING, sent|defwinproc|wparam, 4}, /* one for each mouse movement */
1018 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, 0 },
1019 { WM_GETMINMAXINFO, sent|defwinproc },
1020 { WM_NCCALCSIZE, sent|defwinproc|wparam, 1 },
1021 { WM_NCPAINT, sent|defwinproc|wparam, 1 },
1022 { WM_GETTEXT, sent|defwinproc },
1023 { WM_ERASEBKGND, sent|defwinproc },
1024 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, 0 },
1025 { WM_MOVE, sent|defwinproc },
1026 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
1027 { WM_EXITSIZEMOVE, sent|defwinproc },
1030 /* Resizing child window with MoveWindow (32) */
1031 static const struct message WmResizingChildWithMoveWindowSeq[] = {
1032 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE },
1033 { WM_NCCALCSIZE, sent|wparam, 1 },
1034 { WM_ERASEBKGND, sent|parent|optional },
1035 { WM_ERASEBKGND, sent|optional },
1036 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE },
1037 { WM_MOVE, sent|defwinproc },
1038 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
1039 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1042 /* Clicking on inactive button */
1043 static const struct message WmClickInactiveButtonSeq[] = { /* FIXME: add */
1044 { WM_NCHITTEST, sent },
1045 { WM_PARENTNOTIFY, sent|parent|wparam, WM_LBUTTONDOWN },
1046 { WM_MOUSEACTIVATE, sent },
1047 { WM_MOUSEACTIVATE, sent|parent|defwinproc },
1048 { WM_SETCURSOR, sent },
1049 { WM_SETCURSOR, sent|parent|defwinproc },
1050 { WM_LBUTTONDOWN, posted },
1051 { WM_KILLFOCUS, posted|parent },
1052 { WM_SETFOCUS, posted },
1053 { WM_CTLCOLORBTN, posted|parent },
1054 { BM_SETSTATE, posted },
1055 { WM_CTLCOLORBTN, posted|parent },
1056 { WM_LBUTTONUP, posted },
1057 { BM_SETSTATE, posted },
1058 { WM_CTLCOLORBTN, posted|parent },
1059 { WM_COMMAND, posted|parent },
1062 /* Reparenting a button (16/32) */
1063 /* The last child (button) reparented gets topmost for its new parent. */
1064 static const struct message WmReparentButtonSeq[] = { /* FIXME: add */
1065 { WM_SHOWWINDOW, sent|wparam, 0 },
1066 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE },
1067 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
1068 { WM_ERASEBKGND, sent|parent },
1069 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE },
1070 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE },
1071 { WM_CHILDACTIVATE, sent },
1072 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOSIZE|SWP_NOREDRAW },
1073 { WM_MOVE, sent|defwinproc },
1074 { WM_SHOWWINDOW, sent|wparam, 1 },
1077 /* Creation of a custom dialog (32) */
1078 static const struct message WmCreateCustomDialogSeq[] = {
1079 { HCBT_CREATEWND, hook },
1080 { WM_GETMINMAXINFO, sent },
1081 { WM_NCCREATE, sent },
1082 { WM_NCCALCSIZE, sent|wparam, 0 },
1083 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
1084 { WM_CREATE, sent },
1085 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1086 { WM_SHOWWINDOW, sent|wparam, 1 },
1087 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
1088 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1089 { HCBT_ACTIVATE, hook },
1090 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
1093 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
1095 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE },
1097 { WM_NCACTIVATE, sent|wparam, 1 },
1098 { WM_GETTEXT, sent|optional|defwinproc },
1099 { WM_GETTEXT, sent|optional|defwinproc },
1100 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
1101 { WM_ACTIVATE, sent|wparam, 1 },
1102 { WM_KILLFOCUS, sent|parent },
1103 { WM_IME_SETCONTEXT, sent|parent|wparam|optional, 0 },
1104 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
1105 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
1106 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1107 { WM_SETFOCUS, sent },
1108 { WM_GETDLGCODE, sent|defwinproc|wparam, 0 },
1109 { WM_NCPAINT, sent|wparam, 1 },
1110 { WM_GETTEXT, sent|optional|defwinproc },
1111 { WM_GETTEXT, sent|optional|defwinproc },
1112 { WM_ERASEBKGND, sent },
1113 { WM_CTLCOLORDLG, sent|defwinproc },
1114 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1115 { WM_GETTEXT, sent|optional },
1116 { WM_GETTEXT, sent|optional },
1117 { WM_NCCALCSIZE, sent|optional },
1118 { WM_NCPAINT, sent|optional },
1119 { WM_GETTEXT, sent|optional|defwinproc },
1120 { WM_GETTEXT, sent|optional|defwinproc },
1121 { WM_ERASEBKGND, sent|optional },
1122 { WM_CTLCOLORDLG, sent|optional|defwinproc },
1123 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1124 { WM_SIZE, sent|wparam, SIZE_RESTORED },
1128 /* Calling EndDialog for a custom dialog (32) */
1129 static const struct message WmEndCustomDialogSeq[] = {
1130 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1131 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
1132 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1133 { WM_GETTEXT, sent|optional },
1134 { HCBT_ACTIVATE, hook },
1135 { WM_NCACTIVATE, sent|wparam, 0 },
1136 { WM_GETTEXT, sent|optional|defwinproc },
1137 { WM_GETTEXT, sent|optional|defwinproc },
1138 { WM_ACTIVATE, sent|wparam, 0 },
1139 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
1140 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1141 { HCBT_SETFOCUS, hook },
1142 { WM_KILLFOCUS, sent },
1143 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
1144 { WM_IME_SETCONTEXT, sent|parent|wparam|defwinproc|optional, 1 },
1145 { WM_IME_NOTIFY, sent|wparam|optional, 1 },
1146 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1147 { WM_SETFOCUS, sent|parent|defwinproc },
1150 /* ShowWindow(SW_SHOW) for a custom dialog (initially invisible) */
1151 static const struct message WmShowCustomDialogSeq[] = {
1152 { WM_SHOWWINDOW, sent|wparam, 1 },
1153 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
1154 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1155 { HCBT_ACTIVATE, hook },
1156 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
1158 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
1160 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE },
1161 { WM_ACTIVATEAPP, sent|wparam|optional, 1 },
1162 { WM_NCACTIVATE, sent|wparam, 1 },
1163 { WM_ACTIVATE, sent|wparam, 1 },
1165 { WM_KILLFOCUS, sent|parent },
1166 { WM_IME_SETCONTEXT, sent|parent|wparam|optional, 0 },
1167 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
1168 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
1169 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1170 { WM_SETFOCUS, sent },
1171 { WM_GETDLGCODE, sent|defwinproc|wparam, 0 },
1172 { WM_NCPAINT, sent|wparam, 1 },
1173 { WM_ERASEBKGND, sent },
1174 { WM_CTLCOLORDLG, sent|defwinproc },
1175 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1178 /* Creation and destruction of a modal dialog (32) */
1179 static const struct message WmModalDialogSeq[] = {
1180 { WM_CANCELMODE, sent|parent },
1181 { HCBT_SETFOCUS, hook },
1182 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1183 { WM_KILLFOCUS, sent|parent },
1184 { WM_IME_SETCONTEXT, sent|parent|wparam|optional, 0 },
1185 { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, 0, 0 },
1186 { WM_ENABLE, sent|parent|wparam, 0 },
1187 { HCBT_CREATEWND, hook },
1188 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
1189 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1190 { WM_SETFONT, sent },
1191 { WM_INITDIALOG, sent },
1192 { WM_CHANGEUISTATE, sent|optional },
1193 { WM_UPDATEUISTATE, sent|optional },
1194 { WM_SHOWWINDOW, sent },
1195 { HCBT_ACTIVATE, hook },
1196 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
1197 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
1198 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE },
1199 { WM_NCACTIVATE, sent|wparam, 1 },
1200 { WM_GETTEXT, sent|optional },
1201 { WM_ACTIVATE, sent|wparam, 1 },
1202 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
1203 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1204 { WM_NCPAINT, sent },
1205 { WM_GETTEXT, sent|optional },
1206 { WM_ERASEBKGND, sent },
1207 { WM_CTLCOLORDLG, sent },
1208 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1209 { WM_GETTEXT, sent|optional },
1210 { WM_NCCALCSIZE, sent|optional },
1211 { WM_NCPAINT, sent|optional },
1212 { WM_GETTEXT, sent|optional },
1213 { WM_ERASEBKGND, sent|optional },
1214 { WM_CTLCOLORDLG, sent|optional },
1215 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1216 { WM_PAINT, sent|optional },
1217 { WM_CTLCOLORBTN, sent },
1218 { WM_ENTERIDLE, sent|parent|optional },
1219 { WM_ENTERIDLE, sent|parent|optional },
1220 { WM_ENTERIDLE, sent|parent|optional },
1221 { WM_ENTERIDLE, sent|parent|optional },
1222 { WM_ENTERIDLE, sent|parent|optional },
1223 { WM_ENTERIDLE, sent|parent|optional },
1224 { WM_ENTERIDLE, sent|parent|optional },
1225 { WM_ENTERIDLE, sent|parent|optional },
1226 { WM_ENTERIDLE, sent|parent|optional },
1227 { WM_ENTERIDLE, sent|parent|optional },
1228 { WM_ENTERIDLE, sent|parent|optional },
1229 { WM_ENTERIDLE, sent|parent|optional },
1230 { WM_ENTERIDLE, sent|parent|optional },
1231 { WM_ENTERIDLE, sent|parent|optional },
1232 { WM_ENTERIDLE, sent|parent|optional },
1233 { WM_ENTERIDLE, sent|parent|optional },
1234 { WM_ENTERIDLE, sent|parent|optional },
1235 { WM_ENTERIDLE, sent|parent|optional },
1236 { WM_ENTERIDLE, sent|parent|optional },
1237 { WM_ENTERIDLE, sent|parent|optional },
1239 { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, 0, 0 },
1240 { WM_ENABLE, sent|parent|wparam, 1 },
1241 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
1242 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
1243 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1244 { WM_GETTEXT, sent|optional },
1245 { HCBT_ACTIVATE, hook },
1246 { WM_NCACTIVATE, sent|wparam, 0 },
1247 { WM_GETTEXT, sent|optional },
1248 { WM_ACTIVATE, sent|wparam, 0 },
1249 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
1250 { WM_WINDOWPOSCHANGING, sent|optional },
1251 { HCBT_SETFOCUS, hook },
1252 { WM_IME_SETCONTEXT, sent|parent|wparam|defwinproc|optional, 1 },
1253 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1254 { WM_SETFOCUS, sent|parent|defwinproc },
1255 { EVENT_SYSTEM_DIALOGEND, winevent_hook|wparam|lparam, 0, 0 },
1256 { HCBT_DESTROYWND, hook },
1257 { 0x0090, sent|optional },
1258 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
1259 { WM_DESTROY, sent },
1260 { WM_NCDESTROY, sent },
1263 /* Creation of a modal dialog that is resized inside WM_INITDIALOG (32) */
1264 static const struct message WmCreateModalDialogResizeSeq[] = { /* FIXME: add */
1265 /* (inside dialog proc, handling WM_INITDIALOG) */
1266 { WM_WINDOWPOSCHANGING, sent|wparam, 0 },
1267 { WM_NCCALCSIZE, sent },
1268 { WM_NCACTIVATE, sent|parent|wparam, 0 },
1269 { WM_GETTEXT, sent|defwinproc },
1270 { WM_ACTIVATE, sent|parent|wparam, 0 },
1271 { WM_WINDOWPOSCHANGING, sent|wparam, 0 },
1272 { WM_WINDOWPOSCHANGING, sent|parent },
1273 { WM_NCACTIVATE, sent|wparam, 1 },
1274 { WM_ACTIVATE, sent|wparam, 1 },
1275 { WM_WINDOWPOSCHANGED, sent|wparam, 0 },
1276 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
1277 /* (setting focus) */
1278 { WM_SHOWWINDOW, sent|wparam, 1 },
1279 { WM_WINDOWPOSCHANGING, sent|wparam, 0 },
1280 { WM_NCPAINT, sent },
1281 { WM_GETTEXT, sent|defwinproc },
1282 { WM_ERASEBKGND, sent },
1283 { WM_CTLCOLORDLG, sent|defwinproc },
1284 { WM_WINDOWPOSCHANGED, sent|wparam, 0 },
1286 /* (bunch of WM_CTLCOLOR* for each control) */
1287 { WM_PAINT, sent|parent },
1288 { WM_ENTERIDLE, sent|parent|wparam, 0 },
1289 { WM_SETCURSOR, sent|parent },
1292 /* SetMenu for NonVisible windows with size change*/
1293 static const struct message WmSetMenuNonVisibleSizeChangeSeq[] = {
1294 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1295 { WM_NCCALCSIZE, sent|wparam, 1 },
1296 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
1297 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW },
1298 { WM_MOVE, sent|defwinproc },
1299 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
1300 { WM_NCCALCSIZE,sent|wparam|optional, 1 }, /* XP */
1301 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1302 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* XP sends a duplicate */
1303 { WM_GETTEXT, sent|optional },
1304 { WM_NCCALCSIZE, sent|wparam|optional, 1 },
1307 /* SetMenu for NonVisible windows with no size change */
1308 static const struct message WmSetMenuNonVisibleNoSizeChangeSeq[] = {
1309 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1310 { WM_NCCALCSIZE, sent|wparam, 1 },
1311 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1312 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1315 /* SetMenu for Visible windows with size change */
1316 static const struct message WmSetMenuVisibleSizeChangeSeq[] = {
1317 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1318 { WM_NCCALCSIZE, sent|wparam, 1 },
1319 { 0x0093, sent|defwinproc|optional },
1320 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
1321 { WM_NCPAINT, sent }, /* wparam != 1 */
1322 { 0x0093, sent|defwinproc|optional },
1323 { 0x0093, sent|defwinproc|optional },
1324 { 0x0091, sent|defwinproc|optional },
1325 { 0x0092, sent|defwinproc|optional },
1326 { WM_GETTEXT, sent|defwinproc|optional },
1327 { WM_ERASEBKGND, sent|optional },
1328 { WM_ACTIVATE, sent|optional },
1329 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1330 { WM_MOVE, sent|defwinproc },
1331 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
1332 { 0x0093, sent|optional },
1333 { WM_NCCALCSIZE, sent|wparam|optional, 1 },
1334 { 0x0093, sent|defwinproc|optional },
1335 { WM_NCPAINT, sent|optional }, /* wparam != 1 */
1336 { 0x0093, sent|defwinproc|optional },
1337 { 0x0093, sent|defwinproc|optional },
1338 { 0x0091, sent|defwinproc|optional },
1339 { 0x0092, sent|defwinproc|optional },
1340 { WM_ERASEBKGND, sent|optional },
1341 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1342 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* XP sends a duplicate */
1345 /* SetMenu for Visible windows with no size change */
1346 static const struct message WmSetMenuVisibleNoSizeChangeSeq[] = {
1347 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1348 { WM_NCCALCSIZE, sent|wparam, 1 },
1349 { WM_NCPAINT, sent }, /* wparam != 1 */
1350 { WM_GETTEXT, sent|defwinproc|optional },
1351 { WM_ERASEBKGND, sent|optional },
1352 { WM_ACTIVATE, sent|optional },
1353 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1354 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1357 /* DrawMenuBar for a visible window */
1358 static const struct message WmDrawMenuBarSeq[] =
1360 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1361 { WM_NCCALCSIZE, sent|wparam, 1 },
1362 { 0x0093, sent|defwinproc|optional },
1363 { WM_NCPAINT, sent }, /* wparam != 1 */
1364 { 0x0093, sent|defwinproc|optional },
1365 { 0x0093, sent|defwinproc|optional },
1366 { 0x0091, sent|defwinproc|optional },
1367 { 0x0092, sent|defwinproc|optional },
1368 { WM_GETTEXT, sent|defwinproc|optional },
1369 { WM_ERASEBKGND, sent|optional },
1370 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1371 { 0x0093, sent|optional },
1372 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1376 static const struct message WmSetRedrawFalseSeq[] =
1378 { WM_SETREDRAW, sent|wparam, 0 },
1382 static const struct message WmSetRedrawTrueSeq[] =
1384 { WM_SETREDRAW, sent|wparam, 1 },
1388 static const struct message WmEnableWindowSeq_1[] =
1390 { WM_CANCELMODE, sent|wparam|lparam, 0, 0 },
1391 { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, 0, 0 },
1392 { WM_ENABLE, sent|wparam|lparam, FALSE, 0 },
1396 static const struct message WmEnableWindowSeq_2[] =
1398 { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, 0, 0 },
1399 { WM_ENABLE, sent|wparam|lparam, TRUE, 0 },
1403 static const struct message WmGetScrollRangeSeq[] =
1405 { SBM_GETRANGE, sent },
1408 static const struct message WmGetScrollInfoSeq[] =
1410 { SBM_GETSCROLLINFO, sent },
1413 static const struct message WmSetScrollRangeSeq[] =
1415 /* MSDN claims that Windows sends SBM_SETRANGE message, but win2k SP4
1416 sends SBM_SETSCROLLINFO.
1418 { SBM_SETSCROLLINFO, sent },
1421 /* SetScrollRange for a window without a non-client area */
1422 static const struct message WmSetScrollRangeHSeq_empty[] =
1424 { EVENT_OBJECT_VALUECHANGE, winevent_hook|wparam|lparam, OBJID_HSCROLL, 0 },
1427 static const struct message WmSetScrollRangeVSeq_empty[] =
1429 { EVENT_OBJECT_VALUECHANGE, winevent_hook|wparam|lparam, OBJID_VSCROLL, 0 },
1432 static const struct message WmSetScrollRangeHVSeq[] =
1434 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE },
1435 { WM_NCCALCSIZE, sent|wparam, 1 },
1436 { WM_GETTEXT, sent|defwinproc|optional },
1437 { WM_ERASEBKGND, sent|optional },
1438 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1439 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1440 { EVENT_OBJECT_VALUECHANGE, winevent_hook|lparam|optional, 0/*OBJID_HSCROLL or OBJID_VSCROLL*/, 0 },
1443 /* SetScrollRange for a window with a non-client area */
1444 static const struct message WmSetScrollRangeHV_NC_Seq[] =
1446 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE },
1447 { WM_NCCALCSIZE, sent|wparam, 1 },
1448 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
1449 { WM_NCPAINT, sent|optional },
1450 { WM_STYLECHANGING, sent|defwinproc|optional },
1451 { WM_STYLECHANGED, sent|defwinproc|optional },
1452 { WM_STYLECHANGING, sent|defwinproc|optional },
1453 { WM_STYLECHANGED, sent|defwinproc|optional },
1454 { WM_STYLECHANGING, sent|defwinproc|optional },
1455 { WM_STYLECHANGED, sent|defwinproc|optional },
1456 { WM_STYLECHANGING, sent|defwinproc|optional },
1457 { WM_STYLECHANGED, sent|defwinproc|optional },
1458 { WM_GETTEXT, sent|defwinproc|optional },
1459 { WM_GETTEXT, sent|defwinproc|optional },
1460 { WM_ERASEBKGND, sent|optional },
1461 { WM_CTLCOLORDLG, sent|defwinproc|optional }, /* sent to a parent of the dialog */
1462 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE|SWP_NOCLIENTMOVE },
1463 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
1464 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1465 { EVENT_OBJECT_VALUECHANGE, winevent_hook|lparam|optional, 0/*OBJID_HSCROLL or OBJID_VSCROLL*/, 0 },
1466 { WM_GETTEXT, sent|optional },
1467 { WM_GETTEXT, sent|optional },
1468 { WM_GETTEXT, sent|optional },
1469 { WM_GETTEXT, sent|optional },
1472 /* test if we receive the right sequence of messages */
1473 /* after calling ShowWindow( SW_SHOWNA) */
1474 static const struct message WmSHOWNAChildInvisParInvis[] = {
1475 { WM_SHOWWINDOW, sent|wparam, 1 },
1478 static const struct message WmSHOWNAChildVisParInvis[] = {
1479 { WM_SHOWWINDOW, sent|wparam, 1 },
1482 static const struct message WmSHOWNAChildVisParVis[] = {
1483 { WM_SHOWWINDOW, sent|wparam, 1 },
1484 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
1487 static const struct message WmSHOWNAChildInvisParVis[] = {
1488 { WM_SHOWWINDOW, sent|wparam, 1 },
1489 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1490 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1491 { WM_ERASEBKGND, sent|optional },
1492 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOACTIVATE|SWP_NOCLIENTMOVE },
1495 static const struct message WmSHOWNATopVisible[] = {
1496 { WM_SHOWWINDOW, sent|wparam, 1 },
1497 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
1500 static const struct message WmSHOWNATopInvisible[] = {
1501 { WM_SHOWWINDOW, sent|wparam, 1 },
1502 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1503 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1504 { WM_NCPAINT, sent|wparam, 1 },
1505 { WM_GETTEXT, sent|defwinproc|optional },
1506 { WM_ERASEBKGND, sent|optional },
1507 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1508 { WM_NCCALCSIZE, sent|wparam|optional, 1 },
1509 { WM_NCPAINT, sent|wparam|optional, 1 },
1510 { WM_ERASEBKGND, sent|optional },
1511 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1512 { WM_SIZE, sent|wparam, SIZE_RESTORED },
1517 static int after_end_dialog, test_def_id;
1518 static int sequence_cnt, sequence_size;
1519 static struct message* sequence;
1520 static int log_all_parent_messages;
1522 /* user32 functions */
1523 static HWND (WINAPI *pGetAncestor)(HWND,UINT);
1524 static void (WINAPI *pNotifyWinEvent)(DWORD, HWND, LONG, LONG);
1525 static HWINEVENTHOOK (WINAPI *pSetWinEventHook)(DWORD, DWORD, HMODULE, WINEVENTPROC, DWORD, DWORD, DWORD);
1526 static BOOL (WINAPI *pTrackMouseEvent)(TRACKMOUSEEVENT*);
1527 static BOOL (WINAPI *pUnhookWinEvent)(HWINEVENTHOOK);
1528 /* kernel32 functions */
1529 static BOOL (WINAPI *pGetCPInfoExA)(UINT, DWORD, LPCPINFOEXA);
1531 static void init_procs(void)
1533 HMODULE user32 = GetModuleHandleA("user32.dll");
1534 HMODULE kernel32 = GetModuleHandleA("kernel32.dll");
1536 #define GET_PROC(dll, func) \
1537 p ## func = (void*)GetProcAddress(dll, #func); \
1539 trace("GetProcAddress(%s) failed\n", #func); \
1542 GET_PROC(user32, GetAncestor)
1543 GET_PROC(user32, NotifyWinEvent)
1544 GET_PROC(user32, SetWinEventHook)
1545 GET_PROC(user32, TrackMouseEvent)
1546 GET_PROC(user32, UnhookWinEvent)
1548 GET_PROC(kernel32, GetCPInfoExA)
1553 static void add_message(const struct message *msg)
1558 sequence = HeapAlloc( GetProcessHeap(), 0, sequence_size * sizeof (struct message) );
1560 if (sequence_cnt == sequence_size)
1563 sequence = HeapReAlloc( GetProcessHeap(), 0, sequence, sequence_size * sizeof (struct message) );
1567 sequence[sequence_cnt].message = msg->message;
1568 sequence[sequence_cnt].flags = msg->flags;
1569 sequence[sequence_cnt].wParam = msg->wParam;
1570 sequence[sequence_cnt].lParam = msg->lParam;
1575 /* try to make sure pending X events have been processed before continuing */
1576 static void flush_events(void)
1580 int min_timeout = 50;
1581 DWORD time = GetTickCount() + diff;
1585 if (MsgWaitForMultipleObjects( 0, NULL, FALSE, min_timeout, QS_ALLINPUT ) == WAIT_TIMEOUT) break;
1586 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
1587 diff = time - GetTickCount();
1592 static void flush_sequence(void)
1594 HeapFree(GetProcessHeap(), 0, sequence);
1596 sequence_cnt = sequence_size = 0;
1599 #define ok_sequence( exp, contx, todo) \
1600 ok_sequence_( (exp), (contx), (todo), __FILE__, __LINE__)
1603 static void ok_sequence_(const struct message *expected, const char *context, int todo,
1604 const char *file, int line)
1606 static const struct message end_of_sequence = { 0, 0, 0, 0 };
1607 const struct message *actual;
1610 add_message(&end_of_sequence);
1614 while (expected->message && actual->message)
1616 trace_( file, line)("expected %04x - actual %04x\n", expected->message, actual->message);
1618 if (expected->message == actual->message)
1620 if (expected->flags & wparam)
1622 if (expected->wParam != actual->wParam && todo)
1626 ok_( file, line) (FALSE,
1627 "%s: in msg 0x%04x expecting wParam 0x%lx got 0x%lx\n",
1628 context, expected->message, expected->wParam, actual->wParam);
1632 ok_( file, line) (expected->wParam == actual->wParam,
1633 "%s: in msg 0x%04x expecting wParam 0x%lx got 0x%lx\n",
1634 context, expected->message, expected->wParam, actual->wParam);
1636 if (expected->flags & lparam)
1638 if (expected->lParam != actual->lParam && todo)
1642 ok_( file, line) (FALSE,
1643 "%s: in msg 0x%04x expecting lParam 0x%lx got 0x%lx\n",
1644 context, expected->message, expected->lParam, actual->lParam);
1648 ok_( file, line) (expected->lParam == actual->lParam,
1649 "%s: in msg 0x%04x expecting lParam 0x%lx got 0x%lx\n",
1650 context, expected->message, expected->lParam, actual->lParam);
1652 if ((expected->flags & defwinproc) != (actual->flags & defwinproc) && todo)
1656 ok_( file, line) (FALSE,
1657 "%s: the msg 0x%04x should %shave been sent by DefWindowProc\n",
1658 context, expected->message, (expected->flags & defwinproc) ? "" : "NOT ");
1662 ok_( file, line) ((expected->flags & defwinproc) == (actual->flags & defwinproc),
1663 "%s: the msg 0x%04x should %shave been sent by DefWindowProc\n",
1664 context, expected->message, (expected->flags & defwinproc) ? "" : "NOT ");
1665 ok_( file, line) ((expected->flags & beginpaint) == (actual->flags & beginpaint),
1666 "%s: the msg 0x%04x should %shave been sent by BeginPaint\n",
1667 context, expected->message, (expected->flags & beginpaint) ? "" : "NOT ");
1668 ok_( file, line) ((expected->flags & (sent|posted)) == (actual->flags & (sent|posted)),
1669 "%s: the msg 0x%04x should have been %s\n",
1670 context, expected->message, (expected->flags & posted) ? "posted" : "sent");
1671 ok_( file, line) ((expected->flags & parent) == (actual->flags & parent),
1672 "%s: the msg 0x%04x was expected in %s\n",
1673 context, expected->message, (expected->flags & parent) ? "parent" : "child");
1674 ok_( file, line) ((expected->flags & hook) == (actual->flags & hook),
1675 "%s: the msg 0x%04x should have been sent by a hook\n",
1676 context, expected->message);
1677 ok_( file, line) ((expected->flags & winevent_hook) == (actual->flags & winevent_hook),
1678 "%s: the msg 0x%04x should have been sent by a winevent hook\n",
1679 context, expected->message);
1683 /* silently drop winevent messages if there is no support for them */
1684 else if ((expected->flags & optional) || ((expected->flags & winevent_hook) && !hEvent_hook))
1690 ok_( file, line) (FALSE, "%s: the msg 0x%04x was expected, but got msg 0x%04x instead\n",
1691 context, expected->message, actual->message);
1698 ok_( file, line) (FALSE, "%s: the msg 0x%04x was expected, but got msg 0x%04x instead\n",
1699 context, expected->message, actual->message);
1705 /* skip all optional trailing messages */
1706 while (expected->message && ((expected->flags & optional) ||
1707 ((expected->flags & winevent_hook) && !hEvent_hook)))
1713 if (expected->message || actual->message) {
1715 ok_( file, line) (FALSE, "%s: the msg sequence is not complete: expected %04x - actual %04x\n",
1716 context, expected->message, actual->message);
1722 if (expected->message || actual->message)
1723 ok_( file, line) (FALSE, "%s: the msg sequence is not complete: expected %04x - actual %04x\n",
1724 context, expected->message, actual->message);
1726 if( todo && !failcount) /* succeeded yet marked todo */
1728 ok_( file, line)( TRUE, "%s: marked \"todo_wine\" but succeeds\n", context);
1734 /******************************** MDI test **********************************/
1736 /* CreateWindow for MDI frame window, initially visible */
1737 static const struct message WmCreateMDIframeSeq[] = {
1738 { HCBT_CREATEWND, hook },
1739 { WM_GETMINMAXINFO, sent },
1740 { WM_NCCREATE, sent },
1741 { WM_NCCALCSIZE, sent|wparam, 0 },
1742 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
1743 { WM_CREATE, sent },
1744 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1745 { WM_SHOWWINDOW, sent|wparam, 1 },
1746 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
1747 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1748 { HCBT_ACTIVATE, hook },
1749 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
1750 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
1751 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* XP */
1752 { WM_ACTIVATEAPP, sent|wparam|optional, 1 }, /* Win9x doesn't send it */
1753 { WM_NCACTIVATE, sent|wparam, 1 },
1754 { WM_GETTEXT, sent|defwinproc|optional },
1755 { WM_ACTIVATE, sent|wparam, 1 },
1756 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* Win9x */
1757 { HCBT_SETFOCUS, hook },
1758 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
1759 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
1760 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1761 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
1762 /* Win9x adds SWP_NOZORDER below */
1763 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1764 { WM_NCCALCSIZE, sent|wparam|optional, 1 }, /* XP */
1765 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1766 { WM_SIZE, sent|wparam, SIZE_RESTORED },
1770 /* DestroyWindow for MDI frame window, initially visible */
1771 static const struct message WmDestroyMDIframeSeq[] = {
1772 { HCBT_DESTROYWND, hook },
1773 { 0x0090, sent|optional },
1774 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1775 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
1776 { WM_NCACTIVATE, sent|wparam|optional, 0 }, /* Win9x */
1777 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1778 { WM_NCACTIVATE, sent|wparam|optional, 0 }, /* XP */
1779 { WM_ACTIVATE, sent|wparam|optional, 0 }, /* Win9x */
1780 { WM_ACTIVATEAPP, sent|wparam|optional, 0 }, /* Win9x */
1781 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
1782 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
1783 { WM_DESTROY, sent },
1784 { WM_NCDESTROY, sent },
1787 /* CreateWindow for MDI client window, initially visible */
1788 static const struct message WmCreateMDIclientSeq[] = {
1789 { HCBT_CREATEWND, hook },
1790 { WM_NCCREATE, sent },
1791 { WM_NCCALCSIZE, sent|wparam, 0 },
1792 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam|optional, 0, 0 },
1793 { WM_CREATE, sent },
1794 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam|optional, 0, 0 },
1795 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1796 { WM_SIZE, sent|wparam, SIZE_RESTORED },
1798 { WM_PARENTNOTIFY, sent|wparam, WM_CREATE }, /* in MDI frame */
1799 { WM_SHOWWINDOW, sent|wparam, 1 },
1800 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1801 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1802 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1805 /* ShowWindow(SW_SHOW) for MDI client window */
1806 static const struct message WmShowMDIclientSeq[] = {
1807 { WM_SHOWWINDOW, sent|wparam, 1 },
1808 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1809 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1810 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1813 /* ShowWindow(SW_HIDE) for MDI client window */
1814 static const struct message WmHideMDIclientSeq[] = {
1815 { WM_SHOWWINDOW, sent|wparam, 0 },
1816 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1817 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam|optional, 0, 0 }, /* win2000 */
1818 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* XP */
1819 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1822 /* DestroyWindow for MDI client window, initially visible */
1823 static const struct message WmDestroyMDIclientSeq[] = {
1824 { HCBT_DESTROYWND, hook },
1825 { 0x0090, sent|optional },
1826 { WM_PARENTNOTIFY, sent|wparam, WM_DESTROY }, /* in MDI frame */
1827 { WM_SHOWWINDOW, sent|wparam, 0 },
1828 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1829 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
1830 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1831 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
1832 { WM_DESTROY, sent },
1833 { WM_NCDESTROY, sent },
1836 /* CreateWindow for MDI child window, initially visible */
1837 static const struct message WmCreateMDIchildVisibleSeq[] = {
1838 { HCBT_CREATEWND, hook },
1839 { WM_NCCREATE, sent },
1840 { WM_NCCALCSIZE, sent|wparam, 0 },
1841 { WM_CREATE, sent },
1842 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1843 { WM_SIZE, sent|wparam, SIZE_RESTORED },
1845 /* Win2k sends wparam set to
1846 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
1847 * while Win9x doesn't bother to set child window id according to
1848 * CLIENTCREATESTRUCT.idFirstChild
1850 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
1851 { WM_SHOWWINDOW, sent|wparam, 1 },
1852 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1853 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1854 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1855 { WM_MDIREFRESHMENU, sent/*|wparam|lparam, 0, 0*/ },
1856 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
1857 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
1858 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1860 /* Win9x: message sequence terminates here. */
1862 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
1863 { HCBT_SETFOCUS, hook }, /* in MDI client */
1864 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
1865 { WM_IME_NOTIFY, sent|wparam|optional, 2 }, /* in MDI client */
1866 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1867 { WM_SETFOCUS, sent }, /* in MDI client */
1868 { HCBT_SETFOCUS, hook },
1869 { WM_KILLFOCUS, sent }, /* in MDI client */
1870 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
1871 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
1872 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1873 { WM_SETFOCUS, sent|defwinproc },
1874 { WM_MDIACTIVATE, sent|defwinproc },
1877 /* CreateWindow for MDI child window with invisible parent */
1878 static const struct message WmCreateMDIchildInvisibleParentSeq[] = {
1879 { HCBT_CREATEWND, hook },
1880 { WM_GETMINMAXINFO, sent },
1881 { WM_NCCREATE, sent },
1882 { WM_NCCALCSIZE, sent|wparam, 0 },
1883 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam|optional, 0, 0 },
1884 { WM_CREATE, sent },
1885 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1886 { WM_SIZE, sent|wparam, SIZE_RESTORED },
1888 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
1889 { WM_SHOWWINDOW, sent|wparam, 1 },
1890 { WM_MDIREFRESHMENU, sent }, /* in MDI client */
1891 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
1892 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
1893 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1895 /* Win9x: message sequence terminates here. */
1897 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
1898 { HCBT_SETFOCUS, hook }, /* in MDI client */
1899 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
1900 { WM_IME_NOTIFY, sent|wparam|optional, 2 }, /* in MDI client */
1901 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1902 { WM_SETFOCUS, sent }, /* in MDI client */
1903 { HCBT_SETFOCUS, hook },
1904 { WM_KILLFOCUS, sent }, /* in MDI client */
1905 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
1906 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
1907 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1908 { WM_SETFOCUS, sent|defwinproc },
1909 { WM_MDIACTIVATE, sent|defwinproc },
1912 /* DestroyWindow for MDI child window, initially visible */
1913 static const struct message WmDestroyMDIchildVisibleSeq[] = {
1914 { HCBT_DESTROYWND, hook },
1915 /* Win2k sends wparam set to
1916 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
1917 * while Win9x doesn't bother to set child window id according to
1918 * CLIENTCREATESTRUCT.idFirstChild
1920 { 0x0090, sent|optional },
1921 { WM_PARENTNOTIFY, sent /*|wparam, WM_DESTROY*/ }, /* in MDI client */
1922 { WM_SHOWWINDOW, sent|wparam, 0 },
1923 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1924 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
1925 { WM_ERASEBKGND, sent|parent|optional },
1926 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1928 /* { WM_DESTROY, sent }
1929 * Win9x: message sequence terminates here.
1932 { HCBT_SETFOCUS, hook }, /* set focus to MDI client */
1933 { WM_KILLFOCUS, sent },
1934 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
1935 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
1936 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1937 { WM_SETFOCUS, sent }, /* in MDI client */
1939 { HCBT_SETFOCUS, hook }, /* MDI client sets focus back to MDI child */
1940 { WM_KILLFOCUS, sent }, /* in MDI client */
1941 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
1942 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
1943 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1944 { WM_SETFOCUS, sent }, /* in MDI client */
1946 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
1948 { HCBT_SETFOCUS, hook }, /* set focus to MDI client */
1949 { WM_KILLFOCUS, sent },
1950 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
1951 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
1952 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1953 { WM_SETFOCUS, sent }, /* in MDI client */
1955 { HCBT_SETFOCUS, hook }, /* MDI client sets focus back to MDI child */
1956 { WM_KILLFOCUS, sent }, /* in MDI client */
1957 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
1958 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
1959 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1960 { WM_SETFOCUS, sent }, /* in MDI client */
1962 { WM_DESTROY, sent },
1964 { HCBT_SETFOCUS, hook }, /* set focus to MDI client */
1965 { WM_KILLFOCUS, sent },
1966 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
1967 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
1968 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1969 { WM_SETFOCUS, sent }, /* in MDI client */
1971 { HCBT_SETFOCUS, hook }, /* MDI client sets focus back to MDI child */
1972 { WM_KILLFOCUS, sent }, /* in MDI client */
1973 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
1974 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
1975 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1976 { WM_SETFOCUS, sent }, /* in MDI client */
1978 { WM_NCDESTROY, sent },
1981 /* CreateWindow for MDI child window, initially invisible */
1982 static const struct message WmCreateMDIchildInvisibleSeq[] = {
1983 { HCBT_CREATEWND, hook },
1984 { WM_NCCREATE, sent },
1985 { WM_NCCALCSIZE, sent|wparam, 0 },
1986 { WM_CREATE, sent },
1987 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1988 { WM_SIZE, sent|wparam, SIZE_RESTORED },
1990 /* Win2k sends wparam set to
1991 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
1992 * while Win9x doesn't bother to set child window id according to
1993 * CLIENTCREATESTRUCT.idFirstChild
1995 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
1998 /* DestroyWindow for MDI child window, initially invisible */
1999 static const struct message WmDestroyMDIchildInvisibleSeq[] = {
2000 { HCBT_DESTROYWND, hook },
2001 /* Win2k sends wparam set to
2002 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
2003 * while Win9x doesn't bother to set child window id according to
2004 * CLIENTCREATESTRUCT.idFirstChild
2006 { 0x0090, sent|optional },
2007 { WM_PARENTNOTIFY, sent /*|wparam, WM_DESTROY*/ }, /* in MDI client */
2008 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
2009 { WM_DESTROY, sent },
2010 { WM_NCDESTROY, sent },
2011 /* FIXME: Wine destroys an icon/title window while Windows doesn't */
2012 { WM_PARENTNOTIFY, sent|wparam|optional, WM_DESTROY }, /* MDI client */
2015 /* CreateWindow for the 1st MDI child window, initially visible and maximized */
2016 static const struct message WmCreateMDIchildVisibleMaxSeq1[] = {
2017 { HCBT_CREATEWND, hook },
2018 { WM_NCCREATE, sent },
2019 { WM_NCCALCSIZE, sent|wparam, 0 },
2020 { WM_CREATE, sent },
2021 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
2022 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2024 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
2025 { WM_GETMINMAXINFO, sent },
2026 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_STATECHANGED },
2027 { WM_NCCALCSIZE, sent|wparam, 1 },
2028 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_STATECHANGED },
2029 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2031 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2032 { WM_NCCALCSIZE, sent|wparam, 1 },
2033 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2034 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2035 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2036 /* Win2k sends wparam set to
2037 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2038 * while Win9x doesn't bother to set child window id according to
2039 * CLIENTCREATESTRUCT.idFirstChild
2041 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
2042 { WM_SHOWWINDOW, sent|wparam, 1 },
2043 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2044 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2045 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2046 { WM_MDIREFRESHMENU, sent/*|wparam|lparam, 0, 0*/ },
2047 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
2048 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2049 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2051 /* Win9x: message sequence terminates here. */
2053 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
2054 { HCBT_SETFOCUS, hook }, /* in MDI client */
2055 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2056 { WM_IME_NOTIFY, sent|wparam|optional, 2 }, /* in MDI client */
2057 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2058 { WM_SETFOCUS, sent }, /* in MDI client */
2059 { HCBT_SETFOCUS, hook },
2060 { WM_KILLFOCUS, sent }, /* in MDI client */
2061 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
2062 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
2063 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2064 { WM_SETFOCUS, sent|defwinproc },
2065 { WM_MDIACTIVATE, sent|defwinproc },
2067 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2068 { WM_NCCALCSIZE, sent|wparam, 1 },
2069 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2070 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2073 /* CreateWindow for the 2nd MDI child window, initially visible and maximized */
2074 static const struct message WmCreateMDIchildVisibleMaxSeq2[] = {
2075 /* restore the 1st MDI child */
2076 { WM_SETREDRAW, sent|wparam, 0 },
2077 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWNORMAL },
2078 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_STATECHANGED },
2079 { WM_NCCALCSIZE, sent|wparam, 1 },
2080 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2081 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_STATECHANGED },
2082 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2084 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2085 { WM_NCCALCSIZE, sent|wparam, 1 },
2086 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2087 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2088 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2089 { WM_SETREDRAW, sent|wparam, 1 }, /* in the 1st MDI child */
2090 /* create the 2nd MDI child */
2091 { HCBT_CREATEWND, hook },
2092 { WM_NCCREATE, sent },
2093 { WM_NCCALCSIZE, sent|wparam, 0 },
2094 { WM_CREATE, sent },
2095 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
2096 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2098 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
2099 { WM_GETMINMAXINFO, sent },
2100 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_STATECHANGED },
2101 { WM_NCCALCSIZE, sent|wparam, 1 },
2102 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2103 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_STATECHANGED },
2104 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2106 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2107 { WM_NCCALCSIZE, sent|wparam, 1 },
2108 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2109 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2110 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2111 /* Win2k sends wparam set to
2112 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2113 * while Win9x doesn't bother to set child window id according to
2114 * CLIENTCREATESTRUCT.idFirstChild
2116 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
2117 { WM_SHOWWINDOW, sent|wparam, 1 },
2118 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2119 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2120 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2121 { WM_MDIREFRESHMENU, sent/*|wparam|lparam, 0, 0*/ },
2122 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
2123 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2125 { WM_NCACTIVATE, sent|wparam|defwinproc, 0 }, /* in the 1st MDI child */
2126 { WM_MDIACTIVATE, sent|defwinproc }, /* in the 1st MDI child */
2128 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2130 /* Win9x: message sequence terminates here. */
2132 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
2133 { HCBT_SETFOCUS, hook },
2134 { WM_KILLFOCUS, sent|defwinproc }, /* in the 1st MDI child */
2135 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 0 }, /* in the 1st MDI child */
2136 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2137 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2138 { WM_SETFOCUS, sent }, /* in MDI client */
2139 { HCBT_SETFOCUS, hook },
2140 { WM_KILLFOCUS, sent }, /* in MDI client */
2141 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
2142 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
2143 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2144 { WM_SETFOCUS, sent|defwinproc },
2146 { WM_MDIACTIVATE, sent|defwinproc },
2148 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2149 { WM_NCCALCSIZE, sent|wparam, 1 },
2150 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2151 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2154 /* WM_MDICREATE MDI child window, initially visible and maximized */
2155 static const struct message WmCreateMDIchildVisibleMaxSeq3[] = {
2156 { WM_MDICREATE, sent },
2157 { HCBT_CREATEWND, hook },
2158 { WM_NCCREATE, sent },
2159 { WM_NCCALCSIZE, sent|wparam, 0 },
2160 { WM_CREATE, sent },
2161 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
2162 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2164 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
2165 { WM_GETMINMAXINFO, sent },
2166 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_STATECHANGED },
2167 { WM_NCCALCSIZE, sent|wparam, 1 },
2168 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_STATECHANGED },
2169 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2172 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2173 { WM_NCCALCSIZE, sent|wparam, 1 },
2174 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2175 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2176 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2178 /* Win2k sends wparam set to
2179 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2180 * while Win9x doesn't bother to set child window id according to
2181 * CLIENTCREATESTRUCT.idFirstChild
2183 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
2184 { WM_SHOWWINDOW, sent|wparam, 1 },
2185 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2187 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2189 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2190 { WM_MDIREFRESHMENU, sent/*|wparam|lparam, 0, 0*/ },
2191 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
2193 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2194 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2196 /* Win9x: message sequence terminates here. */
2198 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
2199 { WM_SETFOCUS, sent|optional }, /* in MDI client */
2200 { HCBT_SETFOCUS, hook }, /* in MDI client */
2201 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2202 { WM_IME_NOTIFY, sent|wparam|optional, 2 },
2203 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
2204 { WM_SETFOCUS, sent|optional }, /* in MDI client */
2205 { HCBT_SETFOCUS, hook|optional },
2206 { WM_KILLFOCUS, sent }, /* in MDI client */
2207 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
2208 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
2209 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2210 { WM_SETFOCUS, sent|defwinproc },
2212 { WM_MDIACTIVATE, sent|defwinproc },
2215 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2216 { WM_NCCALCSIZE, sent|wparam, 1 },
2217 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2218 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
2221 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2222 { WM_NCCALCSIZE, sent|wparam, 1 },
2223 { 0x0093, sent|defwinproc|optional },
2224 { 0x0093, sent|defwinproc|optional },
2225 { 0x0093, sent|defwinproc|optional },
2226 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2227 { WM_MOVE, sent|defwinproc },
2228 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2231 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE },
2232 { WM_NCCALCSIZE, sent|wparam, 1 },
2233 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOCLIENTMOVE },
2234 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2237 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE },
2238 { WM_NCCALCSIZE, sent|wparam, 1 },
2239 { 0x0093, sent|optional },
2240 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOCLIENTMOVE },
2241 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2243 { 0x0093, sent|optional },
2244 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2245 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI client */
2246 { WM_NCCALCSIZE, sent|wparam|optional, 1 }, /* XP sends it to MDI frame */
2247 { 0x0093, sent|defwinproc|optional },
2248 { 0x0093, sent|defwinproc|optional },
2249 { 0x0093, sent|defwinproc|optional },
2250 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2251 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* XP sends a duplicate */
2255 /* CreateWindow for the 1st MDI child window, initially invisible and maximized */
2256 static const struct message WmCreateMDIchildInvisibleMaxSeq4[] = {
2257 { HCBT_CREATEWND, hook },
2258 { WM_GETMINMAXINFO, sent },
2259 { WM_NCCREATE, sent },
2260 { WM_NCCALCSIZE, sent|wparam, 0 },
2261 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
2262 { WM_CREATE, sent },
2263 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
2264 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2266 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
2267 { WM_GETMINMAXINFO, sent },
2268 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_STATECHANGED },
2269 { WM_GETMINMAXINFO, sent|defwinproc },
2270 { WM_NCCALCSIZE, sent|wparam, 1 },
2271 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_STATECHANGED },
2272 { WM_MOVE, sent|defwinproc },
2273 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2275 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2276 { WM_NCCALCSIZE, sent|wparam, 1 },
2277 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2278 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2279 { WM_NCCALCSIZE, sent|wparam|optional, 1 }, /* MDI child */
2280 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2281 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2282 /* Win2k sends wparam set to
2283 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2284 * while Win9x doesn't bother to set child window id according to
2285 * CLIENTCREATESTRUCT.idFirstChild
2287 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
2290 /* WM_SYSCOMMAND/SC_CLOSE for the 2nd MDI child window, initially visible and maximized */
2291 static const struct message WmDestroyMDIchildVisibleMaxSeq2[] = {
2292 { WM_SYSCOMMAND, sent|wparam, SC_CLOSE },
2293 { HCBT_SYSCOMMAND, hook },
2294 { WM_CLOSE, sent|defwinproc },
2295 { WM_MDIDESTROY, sent }, /* in MDI client */
2297 /* bring the 1st MDI child to top */
2298 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOSIZE|SWP_NOMOVE }, /* in the 1st MDI child */
2299 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE }, /* in the 2nd MDI child */
2301 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2303 { WM_CHILDACTIVATE, sent|defwinproc|wparam|lparam, 0, 0 }, /* in the 1st MDI child */
2304 { WM_NCACTIVATE, sent|wparam|defwinproc, 0 }, /* in the 1st MDI child */
2305 { WM_MDIACTIVATE, sent|defwinproc }, /* in the 1st MDI child */
2307 /* maximize the 1st MDI child */
2308 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
2309 { WM_GETMINMAXINFO, sent|defwinproc },
2310 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_STATECHANGED },
2311 { WM_NCCALCSIZE, sent|defwinproc|wparam, 1 },
2312 { WM_CHILDACTIVATE, sent|defwinproc|wparam|lparam, 0, 0 },
2313 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_STATECHANGED },
2314 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2316 /* restore the 2nd MDI child */
2317 { WM_SETREDRAW, sent|defwinproc|wparam, 0 },
2318 { HCBT_MINMAX, hook|lparam, 0, SW_NORMALNA },
2319 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_SHOWWINDOW|SWP_STATECHANGED },
2320 { WM_NCCALCSIZE, sent|defwinproc|wparam, 1 },
2322 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2324 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_STATECHANGED },
2325 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2327 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2329 { WM_SETREDRAW, sent|defwinproc|wparam, 1 },
2331 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2332 { WM_NCCALCSIZE, sent|wparam, 1 },
2333 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2334 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2335 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2337 /* bring the 1st MDI child to top */
2338 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2339 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
2340 { HCBT_SETFOCUS, hook },
2341 { WM_KILLFOCUS, sent|defwinproc },
2342 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 0 },
2343 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2344 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2345 { WM_SETFOCUS, sent }, /* in MDI client */
2346 { HCBT_SETFOCUS, hook },
2347 { WM_KILLFOCUS, sent }, /* in MDI client */
2348 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
2349 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
2350 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2351 { WM_SETFOCUS, sent|defwinproc },
2352 { WM_MDIACTIVATE, sent|defwinproc },
2353 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2355 /* apparently ShowWindow(SW_SHOW) on an MDI client */
2356 { WM_SHOWWINDOW, sent|wparam, 1 },
2357 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2358 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2359 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2360 { WM_MDIREFRESHMENU, sent },
2362 { HCBT_DESTROYWND, hook },
2363 /* Win2k sends wparam set to
2364 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
2365 * while Win9x doesn't bother to set child window id according to
2366 * CLIENTCREATESTRUCT.idFirstChild
2368 { 0x0090, sent|defwinproc|optional },
2369 { WM_PARENTNOTIFY, sent /*|wparam, WM_DESTROY*/ }, /* in MDI client */
2370 { WM_SHOWWINDOW, sent|defwinproc|wparam, 0 },
2371 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2372 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
2373 { WM_ERASEBKGND, sent|parent|optional },
2374 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2376 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
2377 { WM_DESTROY, sent|defwinproc },
2378 { WM_NCDESTROY, sent|defwinproc },
2381 /* WM_MDIDESTROY for the single MDI child window, initially visible and maximized */
2382 static const struct message WmDestroyMDIchildVisibleMaxSeq1[] = {
2383 { WM_MDIDESTROY, sent }, /* in MDI client */
2384 { WM_SHOWWINDOW, sent|wparam, 0 },
2385 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2386 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
2387 { WM_ERASEBKGND, sent|parent|optional },
2388 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2390 { HCBT_SETFOCUS, hook },
2391 { WM_KILLFOCUS, sent },
2392 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
2393 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2394 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2395 { WM_SETFOCUS, sent }, /* in MDI client */
2396 { HCBT_SETFOCUS, hook },
2397 { WM_KILLFOCUS, sent }, /* in MDI client */
2398 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
2399 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
2400 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2401 { WM_SETFOCUS, sent },
2404 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2405 { WM_NCCALCSIZE, sent|wparam, 1 },
2406 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2407 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2410 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2411 { WM_NCCALCSIZE, sent|wparam, 1 },
2412 { 0x0093, sent|defwinproc|optional },
2413 { 0x0093, sent|defwinproc|optional },
2414 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2415 { WM_MOVE, sent|defwinproc },
2416 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2419 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE },
2420 { WM_NCCALCSIZE, sent|wparam, 1 },
2421 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOCLIENTMOVE },
2422 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2425 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE },
2426 { WM_NCCALCSIZE, sent|wparam, 1 },
2427 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTMOVE },
2428 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2431 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2432 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 },
2433 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2434 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2437 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2438 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 },
2439 { 0x0093, sent|defwinproc|optional },
2440 { 0x0093, sent|defwinproc|optional },
2441 { 0x0093, sent|defwinproc|optional },
2442 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2443 { WM_MOVE, sent|defwinproc },
2444 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2447 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE },
2448 { WM_NCCALCSIZE, sent|wparam, 1 },
2449 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOCLIENTMOVE },
2450 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2453 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE },
2454 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 },
2455 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTMOVE },
2456 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2457 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2458 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI client */
2460 { 0x0093, sent|defwinproc|optional },
2461 { WM_NCCALCSIZE, sent|wparam|defwinproc|optional, 1 }, /* XP sends it to MDI frame */
2462 { 0x0093, sent|defwinproc|optional },
2463 { 0x0093, sent|defwinproc|optional },
2464 { 0x0093, sent|defwinproc|optional },
2465 { 0x0093, sent|optional },
2467 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2468 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2469 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI client */
2470 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2471 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* XP sends a duplicate */
2474 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2475 { WM_NCCALCSIZE, sent|wparam, 1 },
2476 { 0x0093, sent|defwinproc|optional },
2477 { 0x0093, sent|defwinproc|optional },
2478 { 0x0093, sent|defwinproc|optional },
2479 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2480 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2481 { 0x0093, sent|optional },
2483 { WM_NCACTIVATE, sent|wparam, 0 },
2484 { WM_MDIACTIVATE, sent },
2486 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWNORMAL },
2487 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_SHOWWINDOW|SWP_STATECHANGED },
2488 { WM_NCCALCSIZE, sent|wparam, 1 },
2490 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2492 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2493 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_SHOWWINDOW|SWP_NOMOVE|SWP_NOCLIENTMOVE|SWP_STATECHANGED },
2494 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2497 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2498 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 },
2499 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2500 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2503 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2504 { WM_NCCALCSIZE, sent|wparam, 1 },
2505 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2506 { WM_MOVE, sent|defwinproc },
2507 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2510 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE },
2511 { WM_NCCALCSIZE, sent|wparam, 1 },
2512 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOCLIENTMOVE },
2513 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2514 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2515 { WM_NCCALCSIZE, sent|wparam|optional, 1 }, /* XP */
2516 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI client */
2517 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2518 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* XP sends a duplicate */
2520 { HCBT_SETFOCUS, hook },
2521 { WM_KILLFOCUS, sent },
2522 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
2523 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2524 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2525 { WM_SETFOCUS, sent }, /* in MDI client */
2527 { WM_MDIREFRESHMENU, sent }, /* in MDI client */
2529 { HCBT_DESTROYWND, hook },
2530 /* Win2k sends wparam set to
2531 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
2532 * while Win9x doesn't bother to set child window id according to
2533 * CLIENTCREATESTRUCT.idFirstChild
2535 { 0x0090, sent|optional },
2536 { WM_PARENTNOTIFY, sent /*|wparam, WM_DESTROY*/ }, /* in MDI client */
2538 { WM_SHOWWINDOW, sent|wparam, 0 },
2539 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2540 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
2541 { WM_ERASEBKGND, sent|parent|optional },
2542 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2544 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
2545 { WM_DESTROY, sent },
2546 { WM_NCDESTROY, sent },
2549 /* ShowWindow(SW_MAXIMIZE) for a not visible MDI child window */
2550 static const struct message WmMaximizeMDIchildInvisibleSeq[] = {
2551 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
2552 { WM_GETMINMAXINFO, sent },
2553 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_STATECHANGED },
2554 { WM_NCCALCSIZE, sent|wparam, 1 },
2555 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2556 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2558 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2559 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
2560 { HCBT_SETFOCUS, hook },
2561 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2562 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2563 { WM_SETFOCUS, sent }, /* in MDI client */
2564 { HCBT_SETFOCUS, hook },
2565 { WM_KILLFOCUS, sent }, /* in MDI client */
2566 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
2567 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
2568 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2569 { WM_SETFOCUS, sent|defwinproc },
2570 { WM_MDIACTIVATE, sent|defwinproc },
2571 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_STATECHANGED },
2572 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2574 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2575 { WM_NCCALCSIZE, sent|wparam, 1 },
2576 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2577 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2578 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2581 /* ShowWindow(SW_MAXIMIZE) for a not visible maximized MDI child window */
2582 static const struct message WmMaximizeMDIchildInvisibleSeq2[] = {
2583 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
2584 { WM_GETMINMAXINFO, sent },
2585 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED },
2586 { WM_GETMINMAXINFO, sent|defwinproc },
2587 { WM_NCCALCSIZE, sent|wparam, 1 },
2588 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2589 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2591 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2592 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
2593 { HCBT_SETFOCUS, hook },
2594 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2595 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2596 { WM_SETFOCUS, sent }, /* in MDI client */
2597 { HCBT_SETFOCUS, hook },
2598 { WM_KILLFOCUS, sent }, /* in MDI client */
2599 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
2600 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
2601 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2602 { WM_SETFOCUS, sent|defwinproc },
2603 { WM_MDIACTIVATE, sent|defwinproc },
2604 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2605 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2608 /* WM_MDIMAXIMIZE for an MDI child window with invisible parent */
2609 static const struct message WmMaximizeMDIchildInvisibleParentSeq[] = {
2610 { WM_MDIMAXIMIZE, sent }, /* in MDI client */
2611 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
2612 { WM_GETMINMAXINFO, sent },
2613 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_STATECHANGED },
2614 { WM_GETMINMAXINFO, sent|defwinproc },
2615 { WM_NCCALCSIZE, sent|wparam, 1 },
2616 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam|optional, 0, 0 }, /* XP doesn't send it */
2617 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2618 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOREDRAW|SWP_STATECHANGED },
2619 { WM_MOVE, sent|defwinproc },
2620 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2622 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2623 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 },
2624 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2625 { WM_NCCALCSIZE, sent|wparam|defwinproc|optional, 1 },
2626 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI child XP */
2627 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI client XP */
2629 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2630 { WM_NCCALCSIZE, sent|wparam, 1 },
2631 { 0x0093, sent|defwinproc|optional },
2632 { 0x0094, sent|defwinproc|optional },
2633 { 0x0094, sent|defwinproc|optional },
2634 { 0x0094, sent|defwinproc|optional },
2635 { 0x0094, sent|defwinproc|optional },
2636 { 0x0093, sent|defwinproc|optional },
2637 { 0x0093, sent|defwinproc|optional },
2638 { 0x0091, sent|defwinproc|optional },
2639 { 0x0092, sent|defwinproc|optional },
2640 { 0x0092, sent|defwinproc|optional },
2641 { 0x0092, sent|defwinproc|optional },
2642 { 0x0092, sent|defwinproc|optional },
2643 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2644 { WM_MOVE, sent|defwinproc },
2645 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2646 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI frame win2000 */
2648 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE },
2649 { WM_NCCALCSIZE, sent|wparam, 1 },
2650 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTMOVE },
2651 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2653 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE },
2654 { WM_GETMINMAXINFO, sent|defwinproc },
2655 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 },
2656 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTMOVE },
2657 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2658 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI child win2000 */
2659 { WM_NCCALCSIZE, sent|wparam|defwinproc|optional, 1 },
2660 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI child XP */
2661 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI child XP */
2662 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI client XP */
2664 { 0x0093, sent|optional },
2665 { WM_NCCALCSIZE, sent|wparam|optional, 1 },
2666 { 0x0093, sent|defwinproc|optional },
2667 { 0x0093, sent|defwinproc|optional },
2668 { 0x0093, sent|defwinproc|optional },
2669 { 0x0091, sent|defwinproc|optional },
2670 { 0x0092, sent|defwinproc|optional },
2671 { 0x0092, sent|defwinproc|optional },
2672 { 0x0092, sent|defwinproc|optional },
2673 { 0x0092, sent|defwinproc|optional },
2674 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI frame XP */
2675 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI frame XP */
2676 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI child XP */
2679 /* ShowWindow(SW_MAXIMIZE) for a visible MDI child window */
2680 static const struct message WmMaximizeMDIchildVisibleSeq[] = {
2681 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
2682 { WM_GETMINMAXINFO, sent },
2683 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_STATECHANGED },
2684 { WM_NCCALCSIZE, sent|wparam, 1 },
2685 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2686 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_STATECHANGED },
2687 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2689 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2690 { WM_NCCALCSIZE, sent|wparam, 1 },
2691 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2692 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2693 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2696 /* ShowWindow(SW_RESTORE) for a visible maximized MDI child window */
2697 static const struct message WmRestoreMDIchildVisibleSeq[] = {
2698 { HCBT_MINMAX, hook|lparam, 0, SW_RESTORE },
2699 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_STATECHANGED },
2700 { WM_NCCALCSIZE, sent|wparam, 1 },
2701 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2702 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_STATECHANGED },
2703 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2705 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2706 { WM_NCCALCSIZE, sent|wparam, 1 },
2707 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2708 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2709 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2712 /* ShowWindow(SW_RESTORE) for a visible minimized MDI child window */
2713 static const struct message WmRestoreMDIchildVisibleSeq_2[] = {
2714 { HCBT_MINMAX, hook|lparam, 0, SW_RESTORE },
2715 { WM_QUERYOPEN, sent|wparam|lparam, 0, 0 },
2716 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
2717 { WM_NCCALCSIZE, sent|wparam, 1 },
2718 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2719 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_NOCLIENTSIZE|SWP_STATECHANGED },
2720 { WM_MOVE, sent|defwinproc },
2721 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2722 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2723 { EVENT_SYSTEM_MINIMIZEEND, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2724 { HCBT_SETFOCUS, hook },
2725 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
2726 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
2727 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2728 { WM_SETFOCUS, sent },
2731 /* ShowWindow(SW_MINIMIZE) for a visible restored MDI child window */
2732 static const struct message WmMinimizeMDIchildVisibleSeq[] = {
2733 { HCBT_MINMAX, hook|lparam, 0, SW_MINIMIZE },
2734 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOCOPYBITS|SWP_STATECHANGED },
2735 { WM_NCCALCSIZE, sent|wparam, 1 },
2736 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOCOPYBITS|SWP_NOCLIENTSIZE|SWP_STATECHANGED },
2737 { WM_MOVE, sent|defwinproc },
2738 { WM_SIZE, sent|defwinproc|wparam, SIZE_MINIMIZED },
2739 { WM_CHILDACTIVATE, sent|wparam|lparam|defwinproc, 0, 0 },
2740 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2741 { EVENT_SYSTEM_MINIMIZESTART, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2742 /* FIXME: Wine creates an icon/title window while Windows doesn't */
2743 { WM_PARENTNOTIFY, sent|parent|wparam|optional, WM_CREATE }, /* MDI client */
2746 /* ShowWindow(SW_RESTORE) for a not visible MDI child window */
2747 static const struct message WmRestoreMDIchildInisibleSeq[] = {
2748 { HCBT_MINMAX, hook|lparam, 0, SW_RESTORE },
2749 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_STATECHANGED },
2750 { WM_NCCALCSIZE, sent|wparam, 1 },
2751 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2752 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2753 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_STATECHANGED },
2754 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2756 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2757 { WM_NCCALCSIZE, sent|wparam, 1 },
2758 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2759 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2760 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2764 static HWND mdi_client;
2765 static WNDPROC old_mdi_client_proc;
2767 static LRESULT WINAPI mdi_client_hook_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
2771 /* do not log painting messages */
2772 if (message != WM_PAINT &&
2773 message != WM_NCPAINT &&
2774 message != WM_SYNCPAINT &&
2775 message != WM_ERASEBKGND &&
2776 message != WM_NCHITTEST &&
2777 message != WM_GETTEXT &&
2778 message != WM_MDIGETACTIVE &&
2779 message != WM_GETICON &&
2780 message != WM_DEVICECHANGE)
2782 trace("mdi client: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
2786 case WM_WINDOWPOSCHANGING:
2787 case WM_WINDOWPOSCHANGED:
2789 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
2791 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
2792 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x ",
2793 winpos->hwnd, winpos->hwndInsertAfter,
2794 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
2795 dump_winpos_flags(winpos->flags);
2797 /* Log only documented flags, win2k uses 0x1000 and 0x2000
2798 * in the high word for internal purposes
2800 wParam = winpos->flags & 0xffff;
2801 /* We are not interested in the flags that don't match under XP and Win9x */
2802 wParam &= ~(SWP_NOZORDER);
2807 msg.message = message;
2808 msg.flags = sent|wparam|lparam;
2809 msg.wParam = wParam;
2810 msg.lParam = lParam;
2814 return CallWindowProcA(old_mdi_client_proc, hwnd, message, wParam, lParam);
2817 static LRESULT WINAPI mdi_child_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
2819 static long defwndproc_counter = 0;
2823 /* do not log painting messages */
2824 if (message != WM_PAINT &&
2825 message != WM_NCPAINT &&
2826 message != WM_SYNCPAINT &&
2827 message != WM_ERASEBKGND &&
2828 message != WM_NCHITTEST &&
2829 message != WM_GETTEXT &&
2830 message != WM_GETICON &&
2831 message != WM_DEVICECHANGE)
2833 trace("mdi child: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
2837 case WM_WINDOWPOSCHANGING:
2838 case WM_WINDOWPOSCHANGED:
2840 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
2842 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
2843 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x ",
2844 winpos->hwnd, winpos->hwndInsertAfter,
2845 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
2846 dump_winpos_flags(winpos->flags);
2848 /* Log only documented flags, win2k uses 0x1000 and 0x2000
2849 * in the high word for internal purposes
2851 wParam = winpos->flags & 0xffff;
2852 /* We are not interested in the flags that don't match under XP and Win9x */
2853 wParam &= ~(SWP_NOZORDER);
2857 case WM_MDIACTIVATE:
2859 HWND active, client = GetParent(hwnd);
2861 active = (HWND)SendMessageA(client, WM_MDIGETACTIVE, 0, 0);
2863 if (hwnd == (HWND)lParam) /* if we are being activated */
2864 ok (active == (HWND)lParam, "new active %p != active %p\n", (HWND)lParam, active);
2866 ok (active == (HWND)wParam, "old active %p != active %p\n", (HWND)wParam, active);
2871 msg.message = message;
2872 msg.flags = sent|wparam|lparam;
2873 if (defwndproc_counter) msg.flags |= defwinproc;
2874 msg.wParam = wParam;
2875 msg.lParam = lParam;
2879 defwndproc_counter++;
2880 ret = DefMDIChildProcA(hwnd, message, wParam, lParam);
2881 defwndproc_counter--;
2886 static LRESULT WINAPI mdi_frame_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
2888 static long defwndproc_counter = 0;
2892 /* do not log painting messages */
2893 if (message != WM_PAINT &&
2894 message != WM_NCPAINT &&
2895 message != WM_SYNCPAINT &&
2896 message != WM_ERASEBKGND &&
2897 message != WM_NCHITTEST &&
2898 message != WM_GETTEXT &&
2899 message != WM_GETICON &&
2900 message != WM_DEVICECHANGE)
2902 trace("mdi frame: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
2906 case WM_WINDOWPOSCHANGING:
2907 case WM_WINDOWPOSCHANGED:
2909 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
2911 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
2912 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x ",
2913 winpos->hwnd, winpos->hwndInsertAfter,
2914 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
2915 dump_winpos_flags(winpos->flags);
2917 /* Log only documented flags, win2k uses 0x1000 and 0x2000
2918 * in the high word for internal purposes
2920 wParam = winpos->flags & 0xffff;
2921 /* We are not interested in the flags that don't match under XP and Win9x */
2922 wParam &= ~(SWP_NOZORDER);
2927 msg.message = message;
2928 msg.flags = sent|wparam|lparam;
2929 if (defwndproc_counter) msg.flags |= defwinproc;
2930 msg.wParam = wParam;
2931 msg.lParam = lParam;
2935 defwndproc_counter++;
2936 ret = DefFrameProcA(hwnd, mdi_client, message, wParam, lParam);
2937 defwndproc_counter--;
2942 static BOOL mdi_RegisterWindowClasses(void)
2947 cls.lpfnWndProc = mdi_frame_wnd_proc;
2950 cls.hInstance = GetModuleHandleA(0);
2952 cls.hCursor = LoadCursorA(0, (LPSTR)IDC_ARROW);
2953 cls.hbrBackground = GetStockObject(WHITE_BRUSH);
2954 cls.lpszMenuName = NULL;
2955 cls.lpszClassName = "MDI_frame_class";
2956 if (!RegisterClassA(&cls)) return FALSE;
2958 cls.lpfnWndProc = mdi_child_wnd_proc;
2959 cls.lpszClassName = "MDI_child_class";
2960 if (!RegisterClassA(&cls)) return FALSE;
2962 if (!GetClassInfoA(0, "MDIClient", &cls)) assert(0);
2963 old_mdi_client_proc = cls.lpfnWndProc;
2964 cls.hInstance = GetModuleHandleA(0);
2965 cls.lpfnWndProc = mdi_client_hook_proc;
2966 cls.lpszClassName = "MDI_client_class";
2967 if (!RegisterClassA(&cls)) assert(0);
2972 static void test_mdi_messages(void)
2974 MDICREATESTRUCTA mdi_cs;
2975 CLIENTCREATESTRUCT client_cs;
2976 HWND mdi_frame, mdi_child, mdi_child2, active_child;
2978 HMENU hMenu = CreateMenu();
2980 assert(mdi_RegisterWindowClasses());
2984 trace("creating MDI frame window\n");
2985 mdi_frame = CreateWindowExA(0, "MDI_frame_class", "MDI frame window",
2986 WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX |
2987 WS_MAXIMIZEBOX | WS_VISIBLE,
2988 100, 100, CW_USEDEFAULT, CW_USEDEFAULT,
2989 GetDesktopWindow(), hMenu,
2990 GetModuleHandleA(0), NULL);
2992 ok_sequence(WmCreateMDIframeSeq, "Create MDI frame window", FALSE);
2994 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2995 ok(GetFocus() == mdi_frame, "wrong focus window %p\n", GetFocus());
2997 trace("creating MDI client window\n");
2998 client_cs.hWindowMenu = 0;
2999 client_cs.idFirstChild = MDI_FIRST_CHILD_ID;
3000 mdi_client = CreateWindowExA(0, "MDI_client_class",
3002 WS_CHILD | WS_VISIBLE | MDIS_ALLCHILDSTYLES,
3004 mdi_frame, 0, GetModuleHandleA(0), &client_cs);
3006 ok_sequence(WmCreateMDIclientSeq, "Create visible MDI client window", FALSE);
3008 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3009 ok(GetFocus() == mdi_frame, "input focus should be on MDI frame not on %p\n", GetFocus());
3011 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3012 ok(!active_child, "wrong active MDI child %p\n", active_child);
3013 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
3018 trace("creating invisible MDI child window\n");
3019 mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
3021 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
3022 mdi_client, 0, GetModuleHandleA(0), NULL);
3026 ShowWindow(mdi_child, SW_SHOWNORMAL);
3027 ok_sequence(WmShowChildSeq, "ShowWindow(SW_SHOWNORMAL) MDI child window", FALSE);
3029 ok(GetWindowLongA(mdi_child, GWL_STYLE) & WS_VISIBLE, "MDI child should be visible\n");
3030 ok(IsWindowVisible(mdi_child), "MDI child should be visible\n");
3032 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3033 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3035 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3036 ok(!active_child, "wrong active MDI child %p\n", active_child);
3037 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
3039 ShowWindow(mdi_child, SW_HIDE);
3040 ok_sequence(WmHideChildSeq, "ShowWindow(SW_HIDE) MDI child window", FALSE);
3043 ShowWindow(mdi_child, SW_SHOW);
3044 ok_sequence(WmShowChildSeq, "ShowWindow(SW_SHOW) MDI child window", FALSE);
3046 ok(GetWindowLongA(mdi_child, GWL_STYLE) & WS_VISIBLE, "MDI child should be visible\n");
3047 ok(IsWindowVisible(mdi_child), "MDI child should be visible\n");
3049 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3050 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3052 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3053 ok(!active_child, "wrong active MDI child %p\n", active_child);
3054 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
3056 DestroyWindow(mdi_child);
3059 trace("creating visible MDI child window\n");
3060 mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
3061 WS_CHILD | WS_VISIBLE,
3062 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
3063 mdi_client, 0, GetModuleHandleA(0), NULL);
3065 ok_sequence(WmCreateMDIchildVisibleSeq, "Create visible MDI child window", FALSE);
3067 ok(GetWindowLongA(mdi_child, GWL_STYLE) & WS_VISIBLE, "MDI child should be visible\n");
3068 ok(IsWindowVisible(mdi_child), "MDI child should be visible\n");
3070 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3071 ok(GetFocus() == mdi_child, "wrong focus window %p\n", GetFocus());
3073 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3074 ok(active_child == mdi_child, "wrong active MDI child %p\n", active_child);
3075 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
3078 DestroyWindow(mdi_child);
3079 ok_sequence(WmDestroyMDIchildVisibleSeq, "Destroy visible MDI child window", TRUE);
3081 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3082 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3084 /* Win2k: MDI client still returns a just destroyed child as active
3085 * Win9x: MDI client returns 0
3087 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3088 ok(active_child == mdi_child || /* win2k */
3089 !active_child, /* win9x */
3090 "wrong active MDI child %p\n", active_child);
3091 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
3095 trace("creating invisible MDI child window\n");
3096 mdi_child2 = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
3098 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
3099 mdi_client, 0, GetModuleHandleA(0), NULL);
3101 ok_sequence(WmCreateMDIchildInvisibleSeq, "Create invisible MDI child window", FALSE);
3103 ok(!(GetWindowLongA(mdi_child2, GWL_STYLE) & WS_VISIBLE), "MDI child should not be visible\n");
3104 ok(!IsWindowVisible(mdi_child2), "MDI child should not be visible\n");
3106 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3107 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3109 /* Win2k: MDI client still returns a just destroyed child as active
3110 * Win9x: MDI client returns mdi_child2
3112 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3113 ok(active_child == mdi_child || /* win2k */
3114 active_child == mdi_child2, /* win9x */
3115 "wrong active MDI child %p\n", active_child);
3116 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
3119 ShowWindow(mdi_child2, SW_MAXIMIZE);
3120 ok_sequence(WmMaximizeMDIchildInvisibleSeq, "ShowWindow(SW_MAXIMIZE):invisible MDI child", FALSE);
3122 ok(GetWindowLongA(mdi_child2, GWL_STYLE) & WS_VISIBLE, "MDI child should be visible\n");
3123 ok(IsWindowVisible(mdi_child2), "MDI child should be visible\n");
3125 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3126 ok(active_child == mdi_child2, "wrong active MDI child %p\n", active_child);
3127 ok(zoomed, "wrong zoomed state %d\n", zoomed);
3130 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3131 ok(GetFocus() == mdi_child2 || /* win2k */
3132 GetFocus() == 0, /* win9x */
3133 "wrong focus window %p\n", GetFocus());
3138 ShowWindow(mdi_child2, SW_HIDE);
3139 ok_sequence(WmHideChildSeq, "ShowWindow(SW_HIDE):MDI child", FALSE);
3141 ShowWindow(mdi_child2, SW_RESTORE);
3142 ok_sequence(WmRestoreMDIchildInisibleSeq, "ShowWindow(SW_RESTORE):invisible MDI child", FALSE);
3145 ok(GetWindowLongA(mdi_child2, GWL_STYLE) & WS_VISIBLE, "MDI child should be visible\n");
3146 ok(IsWindowVisible(mdi_child2), "MDI child should be visible\n");
3148 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3149 ok(active_child == mdi_child2, "wrong active MDI child %p\n", active_child);
3150 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
3156 ShowWindow(mdi_child2, SW_HIDE);
3157 ok_sequence(WmHideChildSeq, "ShowWindow(SW_HIDE):MDI child", FALSE);
3159 ShowWindow(mdi_child2, SW_SHOW);
3160 ok_sequence(WmShowChildSeq, "ShowWindow(SW_SHOW):MDI child", FALSE);
3162 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3163 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3165 ShowWindow(mdi_child2, SW_MAXIMIZE);
3166 ok_sequence(WmMaximizeMDIchildVisibleSeq, "ShowWindow(SW_MAXIMIZE):MDI child", FALSE);
3168 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3169 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3171 ShowWindow(mdi_child2, SW_RESTORE);
3172 ok_sequence(WmRestoreMDIchildVisibleSeq, "ShowWindow(SW_RESTORE):maximized MDI child", FALSE);
3174 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3175 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3177 ShowWindow(mdi_child2, SW_MINIMIZE);
3178 ok_sequence(WmMinimizeMDIchildVisibleSeq, "ShowWindow(SW_MINIMIZE):MDI child", TRUE);
3180 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3181 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3183 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3184 ok(active_child == mdi_child2, "wrong active MDI child %p\n", active_child);
3185 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
3188 ShowWindow(mdi_child2, SW_RESTORE);
3189 ok_sequence(WmRestoreMDIchildVisibleSeq_2, "ShowWindow(SW_RESTORE):minimized MDI child", TRUE);
3191 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3192 ok(GetFocus() == mdi_child2, "wrong focus window %p\n", GetFocus());
3194 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3195 ok(active_child == mdi_child2, "wrong active MDI child %p\n", active_child);
3196 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
3202 ShowWindow(mdi_child2, SW_HIDE);
3203 ok_sequence(WmHideChildSeq, "ShowWindow(SW_HIDE):MDI child", FALSE);
3205 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3206 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3208 DestroyWindow(mdi_child2);
3209 ok_sequence(WmDestroyMDIchildInvisibleSeq, "Destroy invisible MDI child window", FALSE);
3211 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3212 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3214 /* test for maximized MDI children */
3215 trace("creating maximized visible MDI child window 1\n");
3216 mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
3217 WS_CHILD | WS_VISIBLE | WS_MAXIMIZEBOX | WS_MAXIMIZE,
3218 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
3219 mdi_client, 0, GetModuleHandleA(0), NULL);
3221 ok_sequence(WmCreateMDIchildVisibleMaxSeq1, "Create maximized visible 1st MDI child window", TRUE);
3222 ok(IsZoomed(mdi_child), "1st MDI child should be maximized\n");
3224 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3225 ok(GetFocus() == mdi_child || /* win2k */
3226 GetFocus() == 0, /* win9x */
3227 "wrong focus window %p\n", GetFocus());
3229 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3230 ok(active_child == mdi_child, "wrong active MDI child %p\n", active_child);
3231 ok(zoomed, "wrong zoomed state %d\n", zoomed);
3234 trace("creating maximized visible MDI child window 2\n");
3235 mdi_child2 = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
3236 WS_CHILD | WS_VISIBLE | WS_MAXIMIZEBOX | WS_MAXIMIZE,
3237 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
3238 mdi_client, 0, GetModuleHandleA(0), NULL);
3240 ok_sequence(WmCreateMDIchildVisibleMaxSeq2, "Create maximized visible 2nd MDI child 2 window", TRUE);
3241 ok(IsZoomed(mdi_child2), "2nd MDI child should be maximized\n");
3242 ok(!IsZoomed(mdi_child), "1st MDI child should NOT be maximized\n");
3244 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3245 ok(GetFocus() == mdi_child2, "wrong focus window %p\n", GetFocus());
3247 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3248 ok(active_child == mdi_child2, "wrong active MDI child %p\n", active_child);
3249 ok(zoomed, "wrong zoomed state %d\n", zoomed);
3252 trace("destroying maximized visible MDI child window 2\n");
3253 DestroyWindow(mdi_child2);
3254 ok_sequence(WmDestroyMDIchildVisibleSeq, "Destroy visible MDI child window", TRUE);
3256 ok(!IsZoomed(mdi_child), "1st MDI child should NOT be maximized\n");
3258 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3259 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3261 /* Win2k: MDI client still returns a just destroyed child as active
3262 * Win9x: MDI client returns 0
3264 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3265 ok(active_child == mdi_child2 || /* win2k */
3266 !active_child, /* win9x */
3267 "wrong active MDI child %p\n", active_child);
3270 ShowWindow(mdi_child, SW_MAXIMIZE);
3271 ok(IsZoomed(mdi_child), "1st MDI child should be maximized\n");
3274 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3275 ok(GetFocus() == mdi_child, "wrong focus window %p\n", GetFocus());
3277 trace("re-creating maximized visible MDI child window 2\n");
3278 mdi_child2 = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
3279 WS_CHILD | WS_VISIBLE | WS_MAXIMIZEBOX | WS_MAXIMIZE,
3280 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
3281 mdi_client, 0, GetModuleHandleA(0), NULL);
3283 ok_sequence(WmCreateMDIchildVisibleMaxSeq2, "Create maximized visible 2nd MDI child 2 window", TRUE);
3284 ok(IsZoomed(mdi_child2), "2nd MDI child should be maximized\n");
3285 ok(!IsZoomed(mdi_child), "1st MDI child should NOT be maximized\n");
3287 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3288 ok(GetFocus() == mdi_child2, "wrong focus window %p\n", GetFocus());
3290 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3291 ok(active_child == mdi_child2, "wrong active MDI child %p\n", active_child);
3292 ok(zoomed, "wrong zoomed state %d\n", zoomed);
3295 SendMessageA(mdi_child2, WM_SYSCOMMAND, SC_CLOSE, 0);
3296 ok_sequence(WmDestroyMDIchildVisibleMaxSeq2, "WM_SYSCOMMAND/SC_CLOSE on a visible maximized MDI child window", TRUE);
3297 ok(!IsWindow(mdi_child2), "MDI child 2 should be destroyed\n");
3299 ok(IsZoomed(mdi_child), "1st MDI child should be maximized\n");
3300 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3301 ok(GetFocus() == mdi_child, "wrong focus window %p\n", GetFocus());
3303 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3304 ok(active_child == mdi_child, "wrong active MDI child %p\n", active_child);
3305 ok(zoomed, "wrong zoomed state %d\n", zoomed);
3308 DestroyWindow(mdi_child);
3309 ok_sequence(WmDestroyMDIchildVisibleSeq, "Destroy visible MDI child window", TRUE);
3311 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3312 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3314 /* Win2k: MDI client still returns a just destroyed child as active
3315 * Win9x: MDI client returns 0
3317 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3318 ok(active_child == mdi_child || /* win2k */
3319 !active_child, /* win9x */
3320 "wrong active MDI child %p\n", active_child);
3323 trace("creating maximized invisible MDI child window\n");
3324 mdi_child2 = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
3325 WS_CHILD | WS_MAXIMIZE | WS_CAPTION | WS_THICKFRAME,
3326 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
3327 mdi_client, 0, GetModuleHandleA(0), NULL);
3329 ok_sequence(WmCreateMDIchildInvisibleMaxSeq4, "Create maximized invisible MDI child window", TRUE);
3330 ok(IsZoomed(mdi_child2), "MDI child should be maximized\n");
3331 ok(!(GetWindowLongA(mdi_child2, GWL_STYLE) & WS_VISIBLE), "MDI child should be not visible\n");
3332 ok(!IsWindowVisible(mdi_child2), "MDI child should be not visible\n");
3334 /* Win2k: MDI client still returns a just destroyed child as active
3335 * Win9x: MDI client returns 0
3337 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3338 ok(active_child == mdi_child || /* win2k */
3339 !active_child, /* win9x */
3340 "wrong active MDI child %p\n", active_child);
3343 trace("call ShowWindow(mdi_child, SW_MAXIMIZE)\n");
3344 ShowWindow(mdi_child2, SW_MAXIMIZE);
3345 ok_sequence(WmMaximizeMDIchildInvisibleSeq2, "ShowWindow(SW_MAXIMIZE):invisible maximized MDI child", FALSE);
3346 ok(IsZoomed(mdi_child2), "MDI child should be maximized\n");
3347 ok(GetWindowLongA(mdi_child2, GWL_STYLE) & WS_VISIBLE, "MDI child should be visible\n");
3348 ok(IsWindowVisible(mdi_child2), "MDI child should be visible\n");
3350 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3351 ok(active_child == mdi_child2, "wrong active MDI child %p\n", active_child);
3352 ok(zoomed, "wrong zoomed state %d\n", zoomed);
3355 SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child2, 0);
3358 /* end of test for maximized MDI children */
3361 trace("creating maximized visible MDI child window 1(Switch test)\n");
3362 mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
3363 WS_CHILD | WS_VISIBLE | WS_MAXIMIZEBOX | WS_MAXIMIZE,
3364 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
3365 mdi_client, 0, GetModuleHandleA(0), NULL);
3367 ok_sequence(WmCreateMDIchildVisibleMaxSeq1, "Create maximized visible 1st MDI child window(Switch test)", TRUE);
3368 ok(IsZoomed(mdi_child), "1st MDI child should be maximized(Switch test)\n");
3370 ok(GetActiveWindow() == mdi_frame, "wrong active window %p(Switch test)\n", GetActiveWindow());
3371 ok(GetFocus() == mdi_child || /* win2k */
3372 GetFocus() == 0, /* win9x */
3373 "wrong focus window %p(Switch test)\n", GetFocus());
3375 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3376 ok(active_child == mdi_child, "wrong active MDI child %p(Switch test)\n", active_child);
3377 ok(zoomed, "wrong zoomed state %d(Switch test)\n", zoomed);
3380 trace("creating maximized visible MDI child window 2(Switch test)\n");
3381 mdi_child2 = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
3382 WS_CHILD | WS_VISIBLE | WS_MAXIMIZEBOX | WS_MAXIMIZE,
3383 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
3384 mdi_client, 0, GetModuleHandleA(0), NULL);
3386 ok_sequence(WmCreateMDIchildVisibleMaxSeq2, "Create maximized visible 2nd MDI child window (Switch test)", TRUE);
3388 ok(IsZoomed(mdi_child2), "2nd MDI child should be maximized(Switch test)\n");
3389 ok(!IsZoomed(mdi_child), "1st MDI child should NOT be maximized(Switch test)\n");
3391 ok(GetActiveWindow() == mdi_frame, "wrong active window %p(Switch test)\n", GetActiveWindow());
3392 ok(GetFocus() == mdi_child2, "wrong focus window %p(Switch test)\n", GetFocus());
3394 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3395 ok(active_child == mdi_child2, "wrong active MDI child %p(Switch test)\n", active_child);
3396 ok(zoomed, "wrong zoomed state %d(Switch test)\n", zoomed);
3399 trace("Switch child window.\n");
3400 SendMessageA(mdi_client, WM_MDIACTIVATE, (WPARAM)mdi_child, 0);
3401 ok_sequence(WmSwitchChild, "Child did not switch correctly", TRUE);
3402 trace("end of test for switch maximized MDI children\n");
3405 /* Prepare for switching test of not maximized MDI children */
3406 ShowWindow( mdi_child, SW_NORMAL );
3407 ok(!IsZoomed(mdi_child), "wrong zoomed state for %p(Switch test)\n", mdi_child);
3408 ok(!IsZoomed(mdi_child2), "wrong zoomed state for %p(Switch test)\n", mdi_child2);
3409 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, 0);
3410 ok(active_child == mdi_child, "wrong active MDI child %p(Switch test)\n", active_child);
3413 SendMessageA(mdi_client, WM_MDIACTIVATE, (WPARAM)mdi_child2, 0);
3414 ok_sequence(WmSwitchNotMaximizedChild, "Not maximized child did not switch correctly", FALSE);
3415 trace("end of test for switch not maximized MDI children\n");
3418 SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child, 0);
3421 SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child2, 0);
3426 /* end of tests for switch maximized/not maximized MDI children */
3428 mdi_cs.szClass = "MDI_child_Class";
3429 mdi_cs.szTitle = "MDI child";
3430 mdi_cs.hOwner = GetModuleHandleA(0);
3433 mdi_cs.cx = CW_USEDEFAULT;
3434 mdi_cs.cy = CW_USEDEFAULT;
3435 mdi_cs.style = WS_CHILD | WS_SYSMENU | WS_VISIBLE | WS_MAXIMIZEBOX | WS_MAXIMIZE;
3437 mdi_child = (HWND)SendMessageA(mdi_client, WM_MDICREATE, 0, (LPARAM)&mdi_cs);
3438 ok(mdi_child != 0, "MDI child creation failed\n");
3439 ok_sequence(WmCreateMDIchildVisibleMaxSeq3, "WM_MDICREATE for maximized visible MDI child window", TRUE);
3441 ok(GetMenuItemID(hMenu, GetMenuItemCount(hMenu) - 1) == SC_CLOSE, "SC_CLOSE menu item not found\n");
3443 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3444 ok(active_child == mdi_child, "wrong active MDI child %p\n", active_child);
3446 ok(IsZoomed(mdi_child), "MDI child should be maximized\n");
3447 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3448 ok(GetFocus() == mdi_child, "wrong focus window %p\n", GetFocus());
3450 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3451 ok(active_child == mdi_child, "wrong active MDI child %p\n", active_child);
3452 ok(zoomed, "wrong zoomed state %d\n", zoomed);
3455 SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child, 0);
3456 ok_sequence(WmDestroyMDIchildVisibleMaxSeq1, "Destroy visible maximized MDI child window", TRUE);
3458 ok(!IsWindow(mdi_child), "MDI child should be destroyed\n");
3459 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3460 ok(!active_child, "wrong active MDI child %p\n", active_child);
3465 DestroyWindow(mdi_client);
3466 ok_sequence(WmDestroyMDIclientSeq, "Destroy MDI client window", FALSE);
3468 /* test maximization of MDI child with invisible parent */
3469 client_cs.hWindowMenu = 0;
3470 mdi_client = CreateWindow("MDI_client_class",
3472 WS_CHILD | WS_CLIPCHILDREN | WS_VSCROLL | WS_HSCROLL | WS_VISIBLE,
3474 mdi_frame, 0, GetModuleHandleA(0), &client_cs);
3475 ok_sequence(WmCreateMDIclientSeq, "Create MDI client window", FALSE);
3477 ShowWindow(mdi_client, SW_HIDE);
3478 ok_sequence(WmHideMDIclientSeq, "Hide MDI client window", FALSE);
3480 mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
3481 WS_CHILD | WS_CLIPCHILDREN | WS_VSCROLL | WS_HSCROLL,
3483 mdi_client, 0, GetModuleHandleA(0), NULL);
3484 ok_sequence(WmCreateMDIchildInvisibleParentSeq, "Create MDI child window with invisible parent", FALSE);
3486 SendMessage(mdi_client, WM_MDIMAXIMIZE, (WPARAM) mdi_child, 0);
3487 ok_sequence(WmMaximizeMDIchildInvisibleParentSeq, "Maximize MDI child window with invisible parent", TRUE);
3488 zoomed = IsZoomed(mdi_child);
3489 ok(zoomed, "wrong zoomed state %d\n", zoomed);
3491 ShowWindow(mdi_client, SW_SHOW);
3492 ok_sequence(WmShowMDIclientSeq, "Show MDI client window", FALSE);
3494 DestroyWindow(mdi_child);
3495 ok_sequence(WmDestroyMDIchildVisibleSeq, "Destroy visible maximized MDI child window", TRUE);
3497 /* end of test for maximization of MDI child with invisible parent */
3499 DestroyWindow(mdi_client);
3500 ok_sequence(WmDestroyMDIclientSeq, "Destroy MDI client window", FALSE);
3502 DestroyWindow(mdi_frame);
3503 ok_sequence(WmDestroyMDIframeSeq, "Destroy MDI frame window", FALSE);
3505 /************************* End of MDI test **********************************/
3507 static void test_WM_SETREDRAW(HWND hwnd)
3509 DWORD style = GetWindowLongA(hwnd, GWL_STYLE);
3513 SendMessageA(hwnd, WM_SETREDRAW, FALSE, 0);
3514 ok_sequence(WmSetRedrawFalseSeq, "SetRedraw:FALSE", FALSE);
3516 ok(!(GetWindowLongA(hwnd, GWL_STYLE) & WS_VISIBLE), "WS_VISIBLE should NOT be set\n");
3517 ok(!IsWindowVisible(hwnd), "IsWindowVisible() should return FALSE\n");
3520 SendMessageA(hwnd, WM_SETREDRAW, TRUE, 0);
3521 ok_sequence(WmSetRedrawTrueSeq, "SetRedraw:TRUE", FALSE);
3523 ok(GetWindowLongA(hwnd, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
3524 ok(IsWindowVisible(hwnd), "IsWindowVisible() should return TRUE\n");
3526 /* restore original WS_VISIBLE state */
3527 SetWindowLongA(hwnd, GWL_STYLE, style);
3532 static INT_PTR CALLBACK TestModalDlgProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
3536 trace("dialog: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
3538 /* explicitly ignore WM_GETICON message */
3539 if (message == WM_GETICON) return 0;
3546 case WM_DEVICECHANGE:
3551 case WM_WINDOWPOSCHANGING:
3552 case WM_WINDOWPOSCHANGED:
3554 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
3556 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
3557 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x ",
3558 winpos->hwnd, winpos->hwndInsertAfter,
3559 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
3560 dump_winpos_flags(winpos->flags);
3562 /* Log only documented flags, win2k uses 0x1000 and 0x2000
3563 * in the high word for internal purposes
3565 wParam = winpos->flags & 0xffff;
3566 /* We are not interested in the flags that don't match under XP and Win9x */
3567 wParam &= ~(SWP_NOZORDER);
3572 msg.message = message;
3573 msg.flags = sent|wparam|lparam;
3574 msg.wParam = wParam;
3575 msg.lParam = lParam;
3578 if (message == WM_INITDIALOG) SetTimer( hwnd, 1, 100, NULL );
3579 if (message == WM_TIMER) EndDialog( hwnd, 0 );
3583 static void test_hv_scroll_1(HWND hwnd, INT ctl, DWORD clear, DWORD set, INT min, INT max)
3585 DWORD style, exstyle;
3589 exstyle = GetWindowLongA(hwnd, GWL_EXSTYLE);
3590 style = GetWindowLongA(hwnd, GWL_STYLE);
3591 /* do not be confused by WS_DLGFRAME set */
3592 if ((style & WS_CAPTION) == WS_CAPTION) style &= ~WS_CAPTION;
3594 if (clear) ok(style & clear, "style %08x should be set\n", clear);
3595 if (set) ok(!(style & set), "style %08x should not be set\n", set);
3597 ret = SetScrollRange(hwnd, ctl, min, max, FALSE);
3598 ok( ret, "SetScrollRange(%d) error %d\n", ctl, GetLastError());
3599 if ((style & (WS_DLGFRAME | WS_BORDER | WS_THICKFRAME)) || (exstyle & WS_EX_DLGMODALFRAME))
3600 ok_sequence(WmSetScrollRangeHV_NC_Seq, "SetScrollRange(SB_HORZ/SB_VERT) NC", FALSE);
3602 ok_sequence(WmSetScrollRangeHVSeq, "SetScrollRange(SB_HORZ/SB_VERT)", FALSE);
3604 style = GetWindowLongA(hwnd, GWL_STYLE);
3605 if (set) ok(style & set, "style %08x should be set\n", set);
3606 if (clear) ok(!(style & clear), "style %08x should not be set\n", clear);
3608 /* a subsequent call should do nothing */
3609 ret = SetScrollRange(hwnd, ctl, min, max, FALSE);
3610 ok( ret, "SetScrollRange(%d) error %d\n", ctl, GetLastError());
3611 ok_sequence(WmEmptySeq, "SetScrollRange(SB_HORZ/SB_VERT) empty sequence", FALSE);
3615 trace("Ignore GetScrollRange error below if you are on Win9x\n");
3616 ret = GetScrollRange(hwnd, ctl, &xmin, &xmax);
3617 ok( ret, "GetScrollRange(%d) error %d\n", ctl, GetLastError());
3618 ok_sequence(WmEmptySeq, "GetScrollRange(SB_HORZ/SB_VERT) empty sequence", FALSE);
3619 ok(xmin == min, "unexpected min scroll value %d\n", xmin);
3620 ok(xmax == max, "unexpected max scroll value %d\n", xmax);
3623 static void test_hv_scroll_2(HWND hwnd, INT ctl, DWORD clear, DWORD set, INT min, INT max)
3625 DWORD style, exstyle;
3629 exstyle = GetWindowLongA(hwnd, GWL_EXSTYLE);
3630 style = GetWindowLongA(hwnd, GWL_STYLE);
3631 /* do not be confused by WS_DLGFRAME set */
3632 if ((style & WS_CAPTION) == WS_CAPTION) style &= ~WS_CAPTION;
3634 if (clear) ok(style & clear, "style %08x should be set\n", clear);
3635 if (set) ok(!(style & set), "style %08x should not be set\n", set);
3637 si.cbSize = sizeof(si);
3638 si.fMask = SIF_RANGE;
3641 SetScrollInfo(hwnd, ctl, &si, TRUE);
3642 if ((style & (WS_DLGFRAME | WS_BORDER | WS_THICKFRAME)) || (exstyle & WS_EX_DLGMODALFRAME))
3643 ok_sequence(WmSetScrollRangeHV_NC_Seq, "SetScrollInfo(SB_HORZ/SB_VERT) NC", FALSE);
3645 ok_sequence(WmSetScrollRangeHVSeq, "SetScrollInfo(SB_HORZ/SB_VERT)", FALSE);
3647 style = GetWindowLongA(hwnd, GWL_STYLE);
3648 if (set) ok(style & set, "style %08x should be set\n", set);
3649 if (clear) ok(!(style & clear), "style %08x should not be set\n", clear);
3651 /* a subsequent call should do nothing */
3652 SetScrollInfo(hwnd, ctl, &si, TRUE);
3653 if (style & WS_HSCROLL)
3654 ok_sequence(WmSetScrollRangeHSeq_empty, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE);
3655 else if (style & WS_VSCROLL)
3656 ok_sequence(WmSetScrollRangeVSeq_empty, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE);
3658 ok_sequence(WmEmptySeq, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE);
3660 si.fMask = SIF_PAGE;
3662 SetScrollInfo(hwnd, ctl, &si, FALSE);
3663 ok_sequence(WmEmptySeq, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE);
3667 SetScrollInfo(hwnd, ctl, &si, FALSE);
3668 ok_sequence(WmEmptySeq, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE);
3670 si.fMask = SIF_RANGE;
3671 si.nMin = 0xdeadbeef;
3672 si.nMax = 0xdeadbeef;
3673 ret = GetScrollInfo(hwnd, ctl, &si);
3674 ok( ret, "GetScrollInfo error %d\n", GetLastError());
3675 ok_sequence(WmEmptySeq, "GetScrollRange(SB_HORZ/SB_VERT) empty sequence", FALSE);
3676 ok(si.nMin == min, "unexpected min scroll value %d\n", si.nMin);
3677 ok(si.nMax == max, "unexpected max scroll value %d\n", si.nMax);
3680 /* Win9x sends WM_USER+xxx while and NT versions send SBM_xxx messages */
3681 static void test_scroll_messages(HWND hwnd)
3689 ret = GetScrollRange(hwnd, SB_CTL, &min, &max);
3690 ok( ret, "GetScrollRange error %d\n", GetLastError());
3691 if (sequence->message != WmGetScrollRangeSeq[0].message)
3692 trace("GetScrollRange(SB_CTL) generated unknown message %04x\n", sequence->message);
3693 /* values of min and max are undefined */
3696 ret = SetScrollRange(hwnd, SB_CTL, 10, 150, FALSE);
3697 ok( ret, "SetScrollRange error %d\n", GetLastError());
3698 if (sequence->message != WmSetScrollRangeSeq[0].message)
3699 trace("SetScrollRange(SB_CTL) generated unknown message %04x\n", sequence->message);
3704 ret = GetScrollRange(hwnd, SB_CTL, &min, &max);
3705 ok( ret, "GetScrollRange error %d\n", GetLastError());
3706 if (sequence->message != WmGetScrollRangeSeq[0].message)
3707 trace("GetScrollRange(SB_CTL) generated unknown message %04x\n", sequence->message);
3708 /* values of min and max are undefined */
3711 si.cbSize = sizeof(si);
3712 si.fMask = SIF_RANGE;
3715 SetScrollInfo(hwnd, SB_CTL, &si, FALSE);
3716 if (sequence->message != WmSetScrollRangeSeq[0].message)
3717 trace("SetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence->message);
3720 si.fMask = SIF_PAGE;
3722 SetScrollInfo(hwnd, SB_CTL, &si, FALSE);
3723 if (sequence->message != WmSetScrollRangeSeq[0].message)
3724 trace("SetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence->message);
3729 SetScrollInfo(hwnd, SB_CTL, &si, FALSE);
3730 if (sequence->message != WmSetScrollRangeSeq[0].message)
3731 trace("SetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence->message);
3734 si.fMask = SIF_RANGE;
3735 si.nMin = 0xdeadbeef;
3736 si.nMax = 0xdeadbeef;
3737 ret = GetScrollInfo(hwnd, SB_CTL, &si);
3738 ok( ret, "GetScrollInfo error %d\n", GetLastError());
3739 if (sequence->message != WmGetScrollInfoSeq[0].message)
3740 trace("GetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence->message);
3741 /* values of min and max are undefined */
3744 /* set WS_HSCROLL */
3745 test_hv_scroll_1(hwnd, SB_HORZ, 0, WS_HSCROLL, 10, 150);
3746 /* clear WS_HSCROLL */
3747 test_hv_scroll_1(hwnd, SB_HORZ, WS_HSCROLL, 0, 0, 0);
3749 /* set WS_HSCROLL */
3750 test_hv_scroll_2(hwnd, SB_HORZ, 0, WS_HSCROLL, 10, 150);
3751 /* clear WS_HSCROLL */
3752 test_hv_scroll_2(hwnd, SB_HORZ, WS_HSCROLL, 0, 0, 0);
3754 /* set WS_VSCROLL */
3755 test_hv_scroll_1(hwnd, SB_VERT, 0, WS_VSCROLL, 10, 150);
3756 /* clear WS_VSCROLL */
3757 test_hv_scroll_1(hwnd, SB_VERT, WS_VSCROLL, 0, 0, 0);
3759 /* set WS_VSCROLL */
3760 test_hv_scroll_2(hwnd, SB_VERT, 0, WS_VSCROLL, 10, 150);
3761 /* clear WS_VSCROLL */
3762 test_hv_scroll_2(hwnd, SB_VERT, WS_VSCROLL, 0, 0, 0);
3765 static void test_showwindow(void)
3770 hwnd = CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW,
3771 100, 100, 200, 200, 0, 0, 0, NULL);
3772 ok (hwnd != 0, "Failed to create overlapped window\n");
3773 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
3774 0, 0, 10, 10, hwnd, 0, 0, NULL);
3775 ok (hchild != 0, "Failed to create child\n");
3778 /* ShowWindow( SW_SHOWNA) for invisible top level window */
3779 trace("calling ShowWindow( SW_SHOWNA) for invisible top level window\n");
3780 ok( ShowWindow(hwnd, SW_SHOWNA) == FALSE, "ShowWindow: window was visible\n" );
3781 ok_sequence(WmSHOWNATopInvisible, "ShowWindow(SW_SHOWNA) on invisible top level window", TRUE);
3784 /* ShowWindow( SW_SHOWNA) for now visible top level window */
3785 trace("calling ShowWindow( SW_SHOWNA) for now visible top level window\n");
3786 ok( ShowWindow(hwnd, SW_SHOWNA) != FALSE, "ShowWindow: window was invisible\n" );
3787 ok_sequence(WmSHOWNATopVisible, "ShowWindow(SW_SHOWNA) on visible top level window", FALSE);
3789 /* back to invisible */
3790 ShowWindow(hchild, SW_HIDE);
3791 ShowWindow(hwnd, SW_HIDE);
3793 /* ShowWindow(SW_SHOWNA) with child and parent invisible */
3794 trace("calling ShowWindow( SW_SHOWNA) for invisible child with invisible parent\n");
3795 ok( ShowWindow(hchild, SW_SHOWNA) == FALSE, "ShowWindow: window was visible\n" );
3796 ok_sequence(WmSHOWNAChildInvisParInvis, "ShowWindow(SW_SHOWNA) invisible child and parent", FALSE);
3798 /* ShowWindow(SW_SHOWNA) with child visible and parent invisible */
3799 ok( ShowWindow(hchild, SW_SHOW) != FALSE, "ShowWindow: window was invisible\n" );
3801 trace("calling ShowWindow( SW_SHOWNA) for the visible child and invisible parent\n");
3802 ok( ShowWindow(hchild, SW_SHOWNA) != FALSE, "ShowWindow: window was invisible\n" );
3803 ok_sequence(WmSHOWNAChildVisParInvis, "ShowWindow(SW_SHOWNA) visible child and invisible parent", FALSE);
3805 /* ShowWindow(SW_SHOWNA) with child visible and parent visible */
3806 ShowWindow( hwnd, SW_SHOW);
3808 trace("calling ShowWindow( SW_SHOWNA) for the visible child and parent\n");
3809 ok( ShowWindow(hchild, SW_SHOWNA) != FALSE, "ShowWindow: window was invisible\n" );
3810 ok_sequence(WmSHOWNAChildVisParVis, "ShowWindow(SW_SHOWNA) for the visible child and parent", FALSE);
3813 /* ShowWindow(SW_SHOWNA) with child invisible and parent visible */
3814 ShowWindow( hchild, SW_HIDE);
3816 trace("calling ShowWindow( SW_SHOWNA) for the invisible child and visible parent\n");
3817 ok( ShowWindow(hchild, SW_SHOWNA) == FALSE, "ShowWindow: window was visible\n" );
3818 ok_sequence(WmSHOWNAChildInvisParVis, "ShowWindow(SW_SHOWNA) for the invisible child and visible parent", FALSE);
3822 ok(GetCapture() == hchild, "wrong capture window %p\n", GetCapture());
3823 DestroyWindow(hchild);
3824 ok(!GetCapture(), "wrong capture window %p\n", GetCapture());
3826 DestroyWindow(hwnd);
3831 * 1. Create invisible maximized popup window.
3832 * 2. Move and resize it.
3833 * 3. Show it maximized.
3835 trace("calling CreateWindowExA( WS_MAXIMIZE ) for invisible maximized popup window\n");
3836 hwnd = CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP | WS_MAXIMIZE,
3837 100, 100, 200, 200, 0, 0, 0, NULL);
3838 ok (hwnd != 0, "Failed to create popup window\n");
3839 ok(IsZoomed(hwnd), "window should be maximized\n");
3840 ok_sequence(WmCreateInvisibleMaxPopupSeq, "CreateWindow(WS_MAXIMIZED):popup", FALSE);
3843 GetWindowRect(hwnd, &rc);
3844 ok( rc.right-rc.left == GetSystemMetrics(SM_CXSCREEN) &&
3845 rc.bottom-rc.top == GetSystemMetrics(SM_CYSCREEN),
3846 "Invalid maximized size before ShowWindow (%d,%d)-(%d,%d)\n",
3847 rc.left, rc.top, rc.right, rc.bottom);
3848 /* Reset window's size & position */
3849 SetWindowPos(hwnd, 0, 10, 10, 200, 200, SWP_NOZORDER | SWP_NOACTIVATE);
3850 ok(IsZoomed(hwnd), "window should be maximized\n");
3853 trace("calling ShowWindow( SW_SHOWMAXIMIZE ) for invisible maximized popup window\n");
3854 ShowWindow(hwnd, SW_SHOWMAXIMIZED);
3855 ok(IsZoomed(hwnd), "window should be maximized\n");
3856 ok_sequence(WmShowMaxPopupResizedSeq, "ShowWindow(SW_SHOWMAXIMIZED):invisible maximized and resized popup", FALSE);
3859 GetWindowRect(hwnd, &rc);
3860 ok( rc.right-rc.left == GetSystemMetrics(SM_CXSCREEN) &&
3861 rc.bottom-rc.top == GetSystemMetrics(SM_CYSCREEN),
3862 "Invalid maximized size after ShowWindow (%d,%d)-(%d,%d)\n",
3863 rc.left, rc.top, rc.right, rc.bottom);
3864 DestroyWindow(hwnd);
3868 * 1. Create invisible maximized popup window.
3869 * 2. Show it maximized.
3871 trace("calling CreateWindowExA( WS_MAXIMIZE ) for invisible maximized popup window\n");
3872 hwnd = CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP | WS_MAXIMIZE,
3873 100, 100, 200, 200, 0, 0, 0, NULL);
3874 ok (hwnd != 0, "Failed to create popup window\n");
3875 ok(IsZoomed(hwnd), "window should be maximized\n");
3876 ok_sequence(WmCreateInvisibleMaxPopupSeq, "CreateWindow(WS_MAXIMIZED):popup", FALSE);
3879 trace("calling ShowWindow( SW_SHOWMAXIMIZE ) for invisible maximized popup window\n");
3880 ShowWindow(hwnd, SW_SHOWMAXIMIZED);
3881 ok(IsZoomed(hwnd), "window should be maximized\n");
3882 ok_sequence(WmShowMaxPopupSeq, "ShowWindow(SW_SHOWMAXIMIZED):invisible maximized popup", FALSE);
3884 DestroyWindow(hwnd);
3888 * 1. Create visible maximized popup window.
3890 trace("calling CreateWindowExA( WS_MAXIMIZE ) for maximized popup window\n");
3891 hwnd = CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP | WS_MAXIMIZE | WS_VISIBLE,
3892 100, 100, 200, 200, 0, 0, 0, NULL);
3893 ok (hwnd != 0, "Failed to create popup window\n");
3894 ok(IsZoomed(hwnd), "window should be maximized\n");
3895 ok_sequence(WmCreateMaxPopupSeq, "CreateWindow(WS_MAXIMIZED):popup", FALSE);
3897 DestroyWindow(hwnd);
3901 * 1. Create visible popup window.
3904 trace("calling CreateWindowExA( WS_VISIBLE ) for popup window\n");
3905 hwnd = CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP | WS_VISIBLE,
3906 100, 100, 200, 200, 0, 0, 0, NULL);
3907 ok (hwnd != 0, "Failed to create popup window\n");
3908 ok(!IsZoomed(hwnd), "window should NOT be maximized\n");
3909 ok_sequence(WmCreatePopupSeq, "CreateWindow(WS_VISIBLE):popup", FALSE);
3912 trace("calling ShowWindow( SW_SHOWMAXIMIZE ) for visible popup window\n");
3913 ShowWindow(hwnd, SW_SHOWMAXIMIZED);
3914 ok(IsZoomed(hwnd), "window should be maximized\n");
3915 ok_sequence(WmShowVisMaxPopupSeq, "ShowWindow(SW_SHOWMAXIMIZED):popup", FALSE);
3917 DestroyWindow(hwnd);
3921 static void test_sys_menu(void)
3927 hwnd = CreateWindowExA(0, "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW,
3928 100, 100, 200, 200, 0, 0, 0, NULL);
3929 ok (hwnd != 0, "Failed to create overlapped window\n");
3933 /* test existing window without CS_NOCLOSE style */
3934 hmenu = GetSystemMenu(hwnd, FALSE);
3935 ok(hmenu != 0, "GetSystemMenu error %d\n", GetLastError());
3937 state = GetMenuState(hmenu, SC_CLOSE, MF_BYCOMMAND);
3938 ok(state != 0xffffffff, "wrong SC_CLOSE state %x\n", state);
3939 ok(!(state & (MF_DISABLED | MF_GRAYED)), "wrong SC_CLOSE state %x\n", state);
3941 EnableMenuItem(hmenu, SC_CLOSE, MF_BYCOMMAND | MF_GRAYED);
3942 ok_sequence(WmEmptySeq, "WmEnableMenuItem", FALSE);
3944 state = GetMenuState(hmenu, SC_CLOSE, MF_BYCOMMAND);
3945 ok(state != 0xffffffff, "wrong SC_CLOSE state %x\n", state);
3946 ok((state & (MF_DISABLED | MF_GRAYED)) == MF_GRAYED, "wrong SC_CLOSE state %x\n", state);
3948 EnableMenuItem(hmenu, SC_CLOSE, 0);
3949 ok_sequence(WmEmptySeq, "WmEnableMenuItem", FALSE);
3951 state = GetMenuState(hmenu, SC_CLOSE, MF_BYCOMMAND);
3952 ok(state != 0xffffffff, "wrong SC_CLOSE state %x\n", state);
3953 ok(!(state & (MF_DISABLED | MF_GRAYED)), "wrong SC_CLOSE state %x\n", state);
3955 /* test whether removing WS_SYSMENU destroys a system menu */
3956 SetWindowLongW(hwnd, GWL_STYLE, WS_POPUP);
3957 SetWindowPos(hwnd, 0, 0, 0, 0, 0, SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_FRAMECHANGED);
3959 hmenu = GetSystemMenu(hwnd, FALSE);
3960 ok(hmenu != 0, "GetSystemMenu error %d\n", GetLastError());
3962 DestroyWindow(hwnd);
3964 /* test new window with CS_NOCLOSE style */
3965 hwnd = CreateWindowExA(0, "NoCloseWindowClass", NULL, WS_OVERLAPPEDWINDOW,
3966 100, 100, 200, 200, 0, 0, 0, NULL);
3967 ok (hwnd != 0, "Failed to create overlapped window\n");
3969 hmenu = GetSystemMenu(hwnd, FALSE);
3970 ok(hmenu != 0, "GetSystemMenu error %d\n", GetLastError());
3972 state = GetMenuState(hmenu, SC_CLOSE, MF_BYCOMMAND);
3973 ok(state == 0xffffffff, "wrong SC_CLOSE state %x\n", state);
3975 DestroyWindow(hwnd);
3977 /* test new window without WS_SYSMENU style */
3978 hwnd = CreateWindowExA(0, "NoCloseWindowClass", NULL, WS_OVERLAPPEDWINDOW & ~WS_SYSMENU,
3979 100, 100, 200, 200, 0, 0, 0, NULL);
3980 ok(hwnd != 0, "Failed to create overlapped window\n");
3982 hmenu = GetSystemMenu(hwnd, FALSE);
3983 ok(!hmenu, "GetSystemMenu error %d\n", GetLastError());
3985 DestroyWindow(hwnd);
3988 /* For shown WS_OVERLAPPEDWINDOW */
3989 static const struct message WmSetIcon_1[] = {
3990 { WM_SETICON, sent },
3991 { 0x00AE, sent|defwinproc|optional }, /* XP */
3992 { WM_GETTEXT, sent|defwinproc|optional },
3993 { WM_GETTEXT, sent|defwinproc|optional }, /* XP sends a duplicate */
3997 /* For WS_POPUP and hidden WS_OVERLAPPEDWINDOW */
3998 static const struct message WmSetIcon_2[] = {
3999 { WM_SETICON, sent },
4003 /* Sending undocumented 0x3B message with wparam = 0x8000000b */
4004 static const struct message WmInitEndSession[] = {
4006 { WM_QUERYENDSESSION, sent|defwinproc|wparam|lparam, 0, ENDSESSION_LOGOFF },
4010 /* Sending undocumented 0x3B message with wparam = 0x0000000b */
4011 static const struct message WmInitEndSession_2[] = {
4013 { WM_QUERYENDSESSION, sent|defwinproc|wparam|lparam, 0, 0 },
4017 /* Sending undocumented 0x3B message with wparam = 0x80000008 */
4018 static const struct message WmInitEndSession_3[] = {
4020 { WM_ENDSESSION, sent|defwinproc|wparam|lparam, 0, ENDSESSION_LOGOFF },
4024 /* Sending undocumented 0x3B message with wparam = 0x00000008 */
4025 static const struct message WmInitEndSession_4[] = {
4027 { WM_ENDSESSION, sent|defwinproc|wparam|lparam, 0, 0 },
4031 /* Sending undocumented 0x3B message with wparam = 0x80000001 */
4032 static const struct message WmInitEndSession_5[] = {
4034 { WM_ENDSESSION, sent|defwinproc|wparam|lparam, 1, ENDSESSION_LOGOFF },
4038 static void test_MsgWaitForMultipleObjects(HWND hwnd)
4043 ret = MsgWaitForMultipleObjects(0, NULL, FALSE, 0, QS_POSTMESSAGE);
4044 ok(ret == WAIT_TIMEOUT, "MsgWaitForMultipleObjects returned %x\n", ret);
4046 PostMessageA(hwnd, WM_USER, 0, 0);
4048 ret = MsgWaitForMultipleObjects(0, NULL, FALSE, 0, QS_POSTMESSAGE);
4049 ok(ret == WAIT_OBJECT_0, "MsgWaitForMultipleObjects returned %x\n", ret);
4051 ok(PeekMessageW( &msg, 0, 0, 0, PM_REMOVE ), "PeekMessage should succeed\n");
4052 ok(msg.message == WM_USER, "got %04x instead of WM_USER\n", msg.message);
4054 ret = MsgWaitForMultipleObjects(0, NULL, FALSE, 0, QS_POSTMESSAGE);
4055 ok(ret == WAIT_TIMEOUT, "MsgWaitForMultipleObjects returned %x\n", ret);
4057 PostMessageA(hwnd, WM_USER, 0, 0);
4059 ret = MsgWaitForMultipleObjects(0, NULL, FALSE, 0, QS_POSTMESSAGE);
4060 ok(ret == WAIT_OBJECT_0, "MsgWaitForMultipleObjects returned %x\n", ret);
4062 ok(PeekMessageW( &msg, 0, 0, 0, PM_NOREMOVE ), "PeekMessage should succeed\n");
4063 ok(msg.message == WM_USER, "got %04x instead of WM_USER\n", msg.message);
4065 /* shows QS_POSTMESSAGE flag is cleared in the PeekMessage call */
4066 ret = MsgWaitForMultipleObjects(0, NULL, FALSE, 0, QS_POSTMESSAGE);
4067 ok(ret == WAIT_TIMEOUT, "MsgWaitForMultipleObjects returned %x\n", ret);
4069 PostMessageA(hwnd, WM_USER, 0, 0);
4071 /* new incoming message causes it to become signaled again */
4072 ret = MsgWaitForMultipleObjects(0, NULL, FALSE, 0, QS_POSTMESSAGE);
4073 ok(ret == WAIT_OBJECT_0, "MsgWaitForMultipleObjects returned %x\n", ret);
4075 ok(PeekMessageW( &msg, 0, 0, 0, PM_REMOVE ), "PeekMessage should succeed\n");
4076 ok(msg.message == WM_USER, "got %04x instead of WM_USER\n", msg.message);
4077 ok(PeekMessageW( &msg, 0, 0, 0, PM_REMOVE ), "PeekMessage should succeed\n");
4078 ok(msg.message == WM_USER, "got %04x instead of WM_USER\n", msg.message);
4081 /* test if we receive the right sequence of messages */
4082 static void test_messages(void)
4084 HWND hwnd, hparent, hchild;
4085 HWND hchild2, hbutton;
4092 hwnd = CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW,
4093 100, 100, 200, 200, 0, 0, 0, NULL);
4094 ok (hwnd != 0, "Failed to create overlapped window\n");
4095 ok_sequence(WmCreateOverlappedSeq, "CreateWindow:overlapped", FALSE);
4097 /* test ShowWindow(SW_HIDE) on a newly created invisible window */
4098 ok( ShowWindow(hwnd, SW_HIDE) == FALSE, "ShowWindow: window was visible\n" );
4099 ok_sequence(WmEmptySeq, "ShowWindow(SW_HIDE):overlapped, invisible", FALSE);
4101 /* test WM_SETREDRAW on a not visible top level window */
4102 test_WM_SETREDRAW(hwnd);
4104 SetWindowPos(hwnd, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE);
4105 ok_sequence(WmSWP_ShowOverlappedSeq, "SetWindowPos:SWP_SHOWWINDOW:overlapped", FALSE);
4106 ok(IsWindowVisible(hwnd), "window should be visible at this point\n");
4108 ok(GetActiveWindow() == hwnd, "window should be active\n");
4109 ok(GetFocus() == hwnd, "window should have input focus\n");
4110 ShowWindow(hwnd, SW_HIDE);
4111 ok_sequence(WmHideOverlappedSeq, "ShowWindow(SW_HIDE):overlapped", TRUE);
4113 ShowWindow(hwnd, SW_SHOW);
4114 ok_sequence(WmShowOverlappedSeq, "ShowWindow(SW_SHOW):overlapped", TRUE);
4116 ShowWindow(hwnd, SW_HIDE);
4117 ok_sequence(WmHideOverlappedSeq, "ShowWindow(SW_HIDE):overlapped", FALSE);
4119 ShowWindow(hwnd, SW_SHOWMAXIMIZED);
4120 ok_sequence(WmShowMaxOverlappedSeq, "ShowWindow(SW_SHOWMAXIMIZED):overlapped", TRUE);
4122 ShowWindow(hwnd, SW_RESTORE);
4123 /* FIXME: add ok_sequence() here */
4126 ShowWindow(hwnd, SW_MINIMIZE);
4127 ok_sequence(WmShowMinOverlappedSeq, "ShowWindow(SW_SHOWMINIMIZED):overlapped", TRUE);
4130 ShowWindow(hwnd, SW_RESTORE);
4131 /* FIXME: add ok_sequence() here */
4134 ShowWindow(hwnd, SW_SHOW);
4135 ok_sequence(WmEmptySeq, "ShowWindow(SW_SHOW):overlapped already visible", FALSE);
4137 ok(GetActiveWindow() == hwnd, "window should be active\n");
4138 ok(GetFocus() == hwnd, "window should have input focus\n");
4139 SetWindowPos(hwnd, 0,0,0,0,0, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE);
4140 ok_sequence(WmSWP_HideOverlappedSeq, "SetWindowPos:SWP_HIDEWINDOW:overlapped", FALSE);
4141 ok(!IsWindowVisible(hwnd), "window should not be visible at this point\n");
4142 ok(GetActiveWindow() == hwnd, "window should still be active\n");
4144 /* test WM_SETREDRAW on a visible top level window */
4145 ShowWindow(hwnd, SW_SHOW);
4146 test_WM_SETREDRAW(hwnd);
4148 trace("testing scroll APIs on a visible top level window %p\n", hwnd);
4149 test_scroll_messages(hwnd);
4151 /* test resizing and moving */
4152 SetWindowPos( hwnd, 0, 0, 0, 300, 300, SWP_NOMOVE|SWP_NOACTIVATE );
4153 ok_sequence(WmSWP_ResizeSeq, "SetWindowPos:Resize", FALSE );
4156 SetWindowPos( hwnd, 0, 200, 200, 0, 0, SWP_NOSIZE|SWP_NOACTIVATE );
4157 ok_sequence(WmSWP_MoveSeq, "SetWindowPos:Move", FALSE );
4160 SetWindowPos( hwnd, 0, 200, 200, 250, 250, SWP_NOZORDER );
4161 ok_sequence(WmSWP_ResizeNoZOrder, "SetWindowPos:WmSWP_ResizeNoZOrder", FALSE );
4165 /* popups don't get WM_GETMINMAXINFO */
4166 SetWindowLongW( hwnd, GWL_STYLE, WS_VISIBLE|WS_POPUP );
4167 SetWindowPos( hwnd, 0, 0, 0, 0, 0, SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_FRAMECHANGED);
4169 SetWindowPos( hwnd, 0, 0, 0, 200, 200, SWP_NOMOVE|SWP_NOACTIVATE );
4170 ok_sequence(WmSWP_ResizePopupSeq, "SetWindowPos:ResizePopup", FALSE );
4172 DestroyWindow(hwnd);
4173 ok_sequence(WmDestroyOverlappedSeq, "DestroyWindow:overlapped", FALSE);
4175 hparent = CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
4176 100, 100, 200, 200, 0, 0, 0, NULL);
4177 ok (hparent != 0, "Failed to create parent window\n");
4180 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD | WS_MAXIMIZE,
4181 0, 0, 10, 10, hparent, 0, 0, NULL);
4182 ok (hchild != 0, "Failed to create child window\n");
4183 ok_sequence(WmCreateMaximizedChildSeq, "CreateWindow:maximized child", FALSE);
4184 DestroyWindow(hchild);
4187 /* visible child window with a caption */
4188 hchild = CreateWindowExA(0, "TestWindowClass", "Test child",
4189 WS_CHILD | WS_VISIBLE | WS_CAPTION,
4190 0, 0, 10, 10, hparent, 0, 0, NULL);
4191 ok (hchild != 0, "Failed to create child window\n");
4192 ok_sequence(WmCreateVisibleChildSeq, "CreateWindow:visible child", FALSE);
4194 trace("testing scroll APIs on a visible child window %p\n", hchild);
4195 test_scroll_messages(hchild);
4197 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE);
4198 ok_sequence(WmShowChildSeq_4, "SetWindowPos(SWP_SHOWWINDOW):child with a caption", FALSE);
4200 DestroyWindow(hchild);
4203 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
4204 0, 0, 10, 10, hparent, 0, 0, NULL);
4205 ok (hchild != 0, "Failed to create child window\n");
4206 ok_sequence(WmCreateChildSeq, "CreateWindow:child", FALSE);
4208 hchild2 = CreateWindowExA(0, "SimpleWindowClass", "Test child2", WS_CHILD,
4209 100, 100, 50, 50, hparent, 0, 0, NULL);
4210 ok (hchild2 != 0, "Failed to create child2 window\n");
4213 hbutton = CreateWindowExA(0, "TestWindowClass", "Test button", WS_CHILD,
4214 0, 100, 50, 50, hchild, 0, 0, NULL);
4215 ok (hbutton != 0, "Failed to create button window\n");
4217 /* test WM_SETREDRAW on a not visible child window */
4218 test_WM_SETREDRAW(hchild);
4220 ShowWindow(hchild, SW_SHOW);
4221 ok_sequence(WmShowChildSeq, "ShowWindow(SW_SHOW):child", FALSE);
4223 /* check parent messages too */
4224 log_all_parent_messages++;
4225 ShowWindow(hchild, SW_HIDE);
4226 ok_sequence(WmHideChildSeq2, "ShowWindow(SW_HIDE):child", FALSE);
4227 log_all_parent_messages--;
4229 ShowWindow(hchild, SW_SHOW);
4230 ok_sequence(WmShowChildSeq, "ShowWindow(SW_SHOW):child", FALSE);
4232 ShowWindow(hchild, SW_HIDE);
4233 ok_sequence(WmHideChildSeq, "ShowWindow(SW_HIDE):child", FALSE);
4235 ShowWindow(hchild, SW_SHOW);
4236 ok_sequence(WmShowChildSeq, "ShowWindow(SW_SHOW):child", FALSE);
4238 /* test WM_SETREDRAW on a visible child window */
4239 test_WM_SETREDRAW(hchild);
4241 log_all_parent_messages++;
4242 MoveWindow(hchild, 10, 10, 20, 20, TRUE);
4243 ok_sequence(WmResizingChildWithMoveWindowSeq, "MoveWindow:child", FALSE);
4244 log_all_parent_messages--;
4246 ShowWindow(hchild, SW_HIDE);
4248 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE);
4249 ok_sequence(WmShowChildSeq_2, "SetWindowPos:show_child_2", FALSE);
4251 ShowWindow(hchild, SW_HIDE);
4253 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE);
4254 ok_sequence(WmShowChildSeq_3, "SetWindowPos:show_child_3", FALSE);
4256 /* DestroyWindow sequence below expects that a child has focus */
4260 DestroyWindow(hchild);
4261 ok_sequence(WmDestroyChildSeq, "DestroyWindow:child", FALSE);
4262 DestroyWindow(hchild2);
4263 DestroyWindow(hbutton);
4266 hchild = CreateWindowExA(0, "TestWindowClass", "Test Child Popup", WS_CHILD | WS_POPUP,
4267 0, 0, 100, 100, hparent, 0, 0, NULL);
4268 ok (hchild != 0, "Failed to create child popup window\n");
4269 ok_sequence(WmCreateChildPopupSeq, "CreateWindow:child_popup", FALSE);
4270 DestroyWindow(hchild);
4272 /* test what happens to a window which sets WS_VISIBLE in WM_CREATE */
4274 hchild = CreateWindowExA(0, "TestPopupClass", "Test Popup", WS_POPUP,
4275 0, 0, 100, 100, hparent, 0, 0, NULL);
4276 ok (hchild != 0, "Failed to create popup window\n");
4277 ok_sequence(WmCreateInvisiblePopupSeq, "CreateWindow:invisible_popup", FALSE);
4278 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
4279 ok(IsWindowVisible(hchild), "IsWindowVisible() should return TRUE\n");
4281 ShowWindow(hchild, SW_SHOW);
4282 ok_sequence(WmEmptySeq, "ShowWindow:show_visible_popup", FALSE);
4284 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER);
4285 ok_sequence(WmShowVisiblePopupSeq_2, "SetWindowPos:show_visible_popup_2", FALSE);
4287 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE);
4288 ok_sequence(WmShowVisiblePopupSeq_3, "SetWindowPos:show_visible_popup_3", TRUE);
4289 DestroyWindow(hchild);
4291 /* this time add WS_VISIBLE for CreateWindowEx, but this fact actually
4292 * changes nothing in message sequences.
4295 hchild = CreateWindowExA(0, "TestPopupClass", "Test Popup", WS_POPUP | WS_VISIBLE,
4296 0, 0, 100, 100, hparent, 0, 0, NULL);
4297 ok (hchild != 0, "Failed to create popup window\n");
4298 ok_sequence(WmCreateInvisiblePopupSeq, "CreateWindow:invisible_popup", FALSE);
4299 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
4300 ok(IsWindowVisible(hchild), "IsWindowVisible() should return TRUE\n");
4302 ShowWindow(hchild, SW_SHOW);
4303 ok_sequence(WmEmptySeq, "ShowWindow:show_visible_popup", FALSE);
4305 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER);
4306 ok_sequence(WmShowVisiblePopupSeq_2, "SetWindowPos:show_visible_popup_2", FALSE);
4307 DestroyWindow(hchild);
4310 hwnd = CreateWindowExA(WS_EX_DLGMODALFRAME, "TestDialogClass", NULL, WS_VISIBLE|WS_CAPTION|WS_SYSMENU|WS_DLGFRAME,
4311 0, 0, 100, 100, hparent, 0, 0, NULL);
4312 ok(hwnd != 0, "Failed to create custom dialog window\n");
4313 ok_sequence(WmCreateCustomDialogSeq, "CreateCustomDialog", TRUE);
4316 trace("testing scroll APIs on a visible dialog %p\n", hwnd);
4317 test_scroll_messages(hwnd);
4323 SendMessage(hwnd, WM_NULL, 0, 0);
4326 after_end_dialog = 1;
4327 EndDialog( hwnd, 0 );
4328 ok_sequence(WmEndCustomDialogSeq, "EndCustomDialog", FALSE);
4330 DestroyWindow(hwnd);
4331 after_end_dialog = 0;
4334 hwnd = CreateWindowExA(0, "TestDialogClass", NULL, WS_POPUP,
4335 0, 0, 100, 100, 0, 0, GetModuleHandleA(0), NULL);
4336 ok(hwnd != 0, "Failed to create custom dialog window\n");
4338 trace("call ShowWindow(%p, SW_SHOW)\n", hwnd);
4339 ShowWindow(hwnd, SW_SHOW);
4340 ok_sequence(WmShowCustomDialogSeq, "ShowCustomDialog", TRUE);
4341 DestroyWindow(hwnd);
4344 DialogBoxA( 0, "TEST_DIALOG", hparent, TestModalDlgProcA );
4345 ok_sequence(WmModalDialogSeq, "ModalDialog", TRUE);
4347 DestroyWindow(hparent);
4350 /* Message sequence for SetMenu */
4351 ok(!DrawMenuBar(hwnd), "DrawMenuBar should return FALSE for a window without a menu\n");
4352 ok_sequence(WmEmptySeq, "DrawMenuBar for a window without a menu", FALSE);
4354 hmenu = CreateMenu();
4355 ok (hmenu != 0, "Failed to create menu\n");
4356 ok (InsertMenuA(hmenu, -1, MF_BYPOSITION, 0x1000, "foo"), "InsertMenu failed\n");
4357 hwnd = CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW,
4358 100, 100, 200, 200, 0, hmenu, 0, NULL);
4359 ok_sequence(WmCreateOverlappedSeq, "CreateWindow:overlapped", FALSE);
4360 ok (SetMenu(hwnd, 0), "SetMenu\n");
4361 ok_sequence(WmSetMenuNonVisibleSizeChangeSeq, "SetMenu:NonVisibleSizeChange", FALSE);
4362 ok (SetMenu(hwnd, 0), "SetMenu\n");
4363 ok_sequence(WmSetMenuNonVisibleNoSizeChangeSeq, "SetMenu:NonVisibleNoSizeChange", FALSE);
4364 ShowWindow(hwnd, SW_SHOW);
4365 UpdateWindow( hwnd );
4368 ok (SetMenu(hwnd, 0), "SetMenu\n");
4369 ok_sequence(WmSetMenuVisibleNoSizeChangeSeq, "SetMenu:VisibleNoSizeChange", FALSE);
4370 ok (SetMenu(hwnd, hmenu), "SetMenu\n");
4371 ok_sequence(WmSetMenuVisibleSizeChangeSeq, "SetMenu:VisibleSizeChange", FALSE);
4373 UpdateWindow( hwnd );
4376 ok(DrawMenuBar(hwnd), "DrawMenuBar\n");
4378 ok_sequence(WmDrawMenuBarSeq, "DrawMenuBar", FALSE);
4380 DestroyWindow(hwnd);
4383 /* Message sequence for EnableWindow */
4384 hparent = CreateWindowExA(0, "TestWindowClass", "Test parent", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
4385 100, 100, 200, 200, 0, 0, 0, NULL);
4386 ok (hparent != 0, "Failed to create parent window\n");
4387 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD | WS_VISIBLE,
4388 0, 0, 10, 10, hparent, 0, 0, NULL);
4389 ok (hchild != 0, "Failed to create child window\n");
4395 EnableWindow(hparent, FALSE);
4396 ok_sequence(WmEnableWindowSeq_1, "EnableWindow(FALSE)", FALSE);
4398 EnableWindow(hparent, TRUE);
4399 ok_sequence(WmEnableWindowSeq_2, "EnableWindow(TRUE)", FALSE);
4404 test_MsgWaitForMultipleObjects(hparent);
4406 /* the following test causes an exception in user.exe under win9x */
4407 if (!PostMessageW( hparent, WM_USER, 0, 0 ))
4409 DestroyWindow(hparent);
4413 PostMessageW( hparent, WM_USER+1, 0, 0 );
4414 /* PeekMessage(NULL) fails, but still removes the message */
4415 SetLastError(0xdeadbeef);
4416 ok( !PeekMessageW( NULL, 0, 0, 0, PM_REMOVE ), "PeekMessage(NULL) should fail\n" );
4417 ok( GetLastError() == ERROR_NOACCESS || /* Win2k */
4418 GetLastError() == 0xdeadbeef, /* NT4 */
4419 "last error is %d\n", GetLastError() );
4420 ok( PeekMessageW( &msg, 0, 0, 0, PM_REMOVE ), "PeekMessage should succeed\n" );
4421 ok( msg.message == WM_USER+1, "got %x instead of WM_USER+1\n", msg.message );
4423 DestroyWindow(hchild);
4424 DestroyWindow(hparent);
4427 /* Message sequences for WM_SETICON */
4428 trace("testing WM_SETICON\n");
4429 hwnd = CreateWindowExA(0, "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW,
4430 CW_USEDEFAULT, CW_USEDEFAULT, 300, 300, 0,
4432 ShowWindow(hwnd, SW_SHOW);
4436 SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(0, IDI_APPLICATION));
4437 ok_sequence(WmSetIcon_1, "WM_SETICON for shown window with caption", FALSE);
4439 ShowWindow(hwnd, SW_HIDE);
4442 SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(0, IDI_APPLICATION));
4443 ok_sequence(WmSetIcon_2, "WM_SETICON for hidden window with caption", FALSE);
4444 DestroyWindow(hwnd);
4447 hwnd = CreateWindowExA(0, "TestPopupClass", NULL, WS_POPUP,
4448 CW_USEDEFAULT, CW_USEDEFAULT, 300, 300, 0,
4450 ShowWindow(hwnd, SW_SHOW);
4454 SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(0, IDI_APPLICATION));
4455 ok_sequence(WmSetIcon_2, "WM_SETICON for shown window without caption", FALSE);
4457 ShowWindow(hwnd, SW_HIDE);
4460 SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(0, IDI_APPLICATION));
4461 ok_sequence(WmSetIcon_2, "WM_SETICON for hidden window without caption", FALSE);
4464 res = SendMessage(hwnd, 0x3B, 0x8000000b, 0);
4465 ok_sequence(WmInitEndSession, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x8000000b", TRUE);
4467 ok(res == 1, "SendMessage(hwnd, 0x3B, 0x8000000b, 0) should have returned 1 instead of %ld\n", res);
4468 res = SendMessage(hwnd, 0x3B, 0x0000000b, 0);
4469 ok_sequence(WmInitEndSession_2, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x0000000b", TRUE);
4471 ok(res == 1, "SendMessage(hwnd, 0x3B, 0x0000000b, 0) should have returned 1 instead of %ld\n", res);
4472 res = SendMessage(hwnd, 0x3B, 0x0000000f, 0);
4473 ok_sequence(WmInitEndSession_2, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x0000000f", TRUE);
4475 ok(res == 1, "SendMessage(hwnd, 0x3B, 0x0000000f, 0) should have returned 1 instead of %ld\n", res);
4478 res = SendMessage(hwnd, 0x3B, 0x80000008, 0);
4479 ok_sequence(WmInitEndSession_3, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x80000008", TRUE);
4481 ok(res == 2, "SendMessage(hwnd, 0x3B, 0x80000008, 0) should have returned 2 instead of %ld\n", res);
4482 res = SendMessage(hwnd, 0x3B, 0x00000008, 0);
4483 ok_sequence(WmInitEndSession_4, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x00000008", TRUE);
4485 ok(res == 2, "SendMessage(hwnd, 0x3B, 0x00000008, 0) should have returned 2 instead of %ld\n", res);
4487 res = SendMessage(hwnd, 0x3B, 0x80000004, 0);
4488 ok_sequence(WmInitEndSession_3, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x80000004", TRUE);
4490 ok(res == 2, "SendMessage(hwnd, 0x3B, 0x80000004, 0) should have returned 2 instead of %ld\n", res);
4492 res = SendMessage(hwnd, 0x3B, 0x80000001, 0);
4493 ok_sequence(WmInitEndSession_5, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x80000001", TRUE);
4495 ok(res == 2, "SendMessage(hwnd, 0x3B, 0x80000001, 0) should have returned 2 instead of %ld\n", res);
4497 DestroyWindow(hwnd);
4501 static void invisible_parent_tests(void)
4503 HWND hparent, hchild;
4505 hparent = CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW,
4506 100, 100, 200, 200, 0, 0, 0, NULL);
4507 ok (hparent != 0, "Failed to create parent window\n");
4510 /* test showing child with hidden parent */
4512 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
4513 0, 0, 10, 10, hparent, 0, 0, NULL);
4514 ok (hchild != 0, "Failed to create child window\n");
4515 ok_sequence(WmCreateChildSeq, "CreateWindow:child", FALSE);
4517 ShowWindow( hchild, SW_MINIMIZE );
4518 ok_sequence(WmShowChildInvisibleParentSeq_1, "ShowWindow(SW_MINIMIZE) child with invisible parent", FALSE);
4519 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
4520 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4525 ShowWindow( hchild, SW_MINIMIZE );
4526 ok_sequence(WmShowChildInvisibleParentSeq_1r, "ShowWindow(SW_MINIMIZE) child with invisible parent", FALSE);
4528 DestroyWindow(hchild);
4529 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
4530 0, 0, 10, 10, hparent, 0, 0, NULL);
4533 ShowWindow( hchild, SW_MAXIMIZE );
4534 ok_sequence(WmShowChildInvisibleParentSeq_2, "ShowWindow(SW_MAXIMIZE) child with invisible parent", FALSE);
4535 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
4536 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4541 ShowWindow( hchild, SW_MAXIMIZE );
4542 ok_sequence(WmShowChildInvisibleParentSeq_2r, "ShowWindow(SW_MAXIMIZE) child with invisible parent", FALSE);
4544 DestroyWindow(hchild);
4545 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
4546 0, 0, 10, 10, hparent, 0, 0, NULL);
4549 ShowWindow( hchild, SW_RESTORE );
4550 ok_sequence(WmShowChildInvisibleParentSeq_5, "ShowWindow(SW_RESTORE) child with invisible parent", FALSE);
4551 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
4552 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4554 DestroyWindow(hchild);
4555 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
4556 0, 0, 10, 10, hparent, 0, 0, NULL);
4559 ShowWindow( hchild, SW_SHOWMINIMIZED );
4560 ok_sequence(WmShowChildInvisibleParentSeq_3, "ShowWindow(SW_SHOWMINIMIZED) child with invisible parent", FALSE);
4561 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
4562 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4567 ShowWindow( hchild, SW_SHOWMINIMIZED );
4568 ok_sequence(WmShowChildInvisibleParentSeq_3r, "ShowWindow(SW_SHOWMINIMIZED) child with invisible parent", FALSE);
4570 DestroyWindow(hchild);
4571 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
4572 0, 0, 10, 10, hparent, 0, 0, NULL);
4575 /* same as ShowWindow( hchild, SW_MAXIMIZE ); */
4576 ShowWindow( hchild, SW_SHOWMAXIMIZED );
4577 ok_sequence(WmShowChildInvisibleParentSeq_2, "ShowWindow(SW_SHOWMAXIMIZED) child with invisible parent", FALSE);
4578 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
4579 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4581 DestroyWindow(hchild);
4582 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
4583 0, 0, 10, 10, hparent, 0, 0, NULL);
4586 ShowWindow( hchild, SW_SHOWMINNOACTIVE );
4587 ok_sequence(WmShowChildInvisibleParentSeq_4, "ShowWindow(SW_SHOWMINNOACTIVE) child with invisible parent", FALSE);
4588 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
4589 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4594 ShowWindow( hchild, SW_SHOWMINNOACTIVE );
4595 ok_sequence(WmShowChildInvisibleParentSeq_4r, "ShowWindow(SW_SHOWMINNOACTIVE) child with invisible parent", FALSE);
4597 DestroyWindow(hchild);
4598 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
4599 0, 0, 10, 10, hparent, 0, 0, NULL);
4602 /* FIXME: looks like XP SP2 doesn't know about SW_FORCEMINIMIZE at all */
4603 ShowWindow( hchild, SW_FORCEMINIMIZE );
4604 ok_sequence(WmEmptySeq, "ShowWindow(SW_FORCEMINIMIZE) child with invisible parent", TRUE);
4606 ok(!(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE), "WS_VISIBLE should be not set\n");
4608 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4610 DestroyWindow(hchild);
4611 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
4612 0, 0, 10, 10, hparent, 0, 0, NULL);
4615 ShowWindow( hchild, SW_SHOWNA );
4616 ok_sequence(WmShowChildInvisibleParentSeq_5, "ShowWindow(SW_SHOWNA) child with invisible parent", FALSE);
4617 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
4618 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4623 ShowWindow( hchild, SW_SHOWNA );
4624 ok_sequence(WmShowChildInvisibleParentSeq_5, "ShowWindow(SW_SHOWNA) child with invisible parent", FALSE);
4626 DestroyWindow(hchild);
4627 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
4628 0, 0, 10, 10, hparent, 0, 0, NULL);
4631 ShowWindow( hchild, SW_SHOW );
4632 ok_sequence(WmShowChildInvisibleParentSeq_5, "ShowWindow(SW_SHOW) child with invisible parent", FALSE);
4633 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
4634 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4639 ShowWindow( hchild, SW_SHOW );
4640 ok_sequence(WmEmptySeq, "ShowWindow(SW_SHOW) child with invisible parent", FALSE);
4642 ShowWindow( hchild, SW_HIDE );
4643 ok_sequence(WmHideChildInvisibleParentSeq, "ShowWindow:hide child with invisible parent", FALSE);
4644 ok(!(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE), "WS_VISIBLE should be not set\n");
4645 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4647 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER);
4648 ok_sequence(WmShowChildInvisibleParentSeq_6, "SetWindowPos:show child with invisible parent", FALSE);
4649 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
4650 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4652 SetWindowPos(hchild, 0,0,0,0,0, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER);
4653 ok_sequence(WmHideChildInvisibleParentSeq_2, "SetWindowPos:hide child with invisible parent", FALSE);
4654 ok(!(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE), "WS_VISIBLE should not be set\n");
4655 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4657 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER);
4659 DestroyWindow(hchild);
4660 ok_sequence(WmDestroyInvisibleChildSeq, "DestroyInvisibleChildSeq", FALSE);
4662 DestroyWindow(hparent);
4666 /****************** button message test *************************/
4667 static const struct message WmSetFocusButtonSeq[] =
4669 { HCBT_SETFOCUS, hook },
4670 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
4671 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
4672 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
4673 { WM_SETFOCUS, sent|wparam, 0 },
4674 { WM_CTLCOLORBTN, sent|defwinproc },
4677 static const struct message WmKillFocusButtonSeq[] =
4679 { HCBT_SETFOCUS, hook },
4680 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
4681 { WM_KILLFOCUS, sent|wparam, 0 },
4682 { WM_CTLCOLORBTN, sent|defwinproc },
4683 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
4684 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 1 },
4687 static const struct message WmSetFocusStaticSeq[] =
4689 { HCBT_SETFOCUS, hook },
4690 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
4691 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
4692 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
4693 { WM_SETFOCUS, sent|wparam, 0 },
4694 { WM_CTLCOLORSTATIC, sent|defwinproc },
4697 static const struct message WmKillFocusStaticSeq[] =
4699 { HCBT_SETFOCUS, hook },
4700 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
4701 { WM_KILLFOCUS, sent|wparam, 0 },
4702 { WM_CTLCOLORSTATIC, sent|defwinproc },
4703 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
4704 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 1 },
4707 static const struct message WmLButtonDownSeq[] =
4709 { WM_LBUTTONDOWN, sent|wparam|lparam, 0, 0 },
4710 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
4711 { HCBT_SETFOCUS, hook },
4712 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
4713 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
4714 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
4715 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
4716 { WM_CTLCOLORBTN, sent|defwinproc },
4717 { BM_SETSTATE, sent|wparam|defwinproc, TRUE },
4718 { WM_CTLCOLORBTN, sent|defwinproc },
4719 { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
4722 static const struct message WmLButtonUpSeq[] =
4724 { WM_LBUTTONUP, sent|wparam|lparam, 0, 0 },
4725 { BM_SETSTATE, sent|wparam|defwinproc, FALSE },
4726 { WM_CTLCOLORBTN, sent|defwinproc },
4727 { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
4728 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, 0, 0 },
4729 { WM_CAPTURECHANGED, sent|wparam|defwinproc, 0 },
4732 static const struct message WmSetFontButtonSeq[] =
4734 { WM_SETFONT, sent },
4736 { WM_ERASEBKGND, sent|defwinproc|optional },
4737 { WM_CTLCOLORBTN, sent|defwinproc },
4741 static WNDPROC old_button_proc;
4743 static LRESULT CALLBACK button_hook_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
4745 static long defwndproc_counter = 0;
4749 trace("button: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
4751 /* explicitly ignore WM_GETICON message */
4752 if (message == WM_GETICON) return 0;
4754 msg.message = message;
4755 msg.flags = sent|wparam|lparam;
4756 if (defwndproc_counter) msg.flags |= defwinproc;
4757 msg.wParam = wParam;
4758 msg.lParam = lParam;
4761 if (message == BM_SETSTATE)
4762 ok(GetCapture() == hwnd, "GetCapture() = %p\n", GetCapture());
4764 defwndproc_counter++;
4765 ret = CallWindowProcA(old_button_proc, hwnd, message, wParam, lParam);
4766 defwndproc_counter--;
4771 static void subclass_button(void)
4775 if (!GetClassInfoA(0, "button", &cls)) assert(0);
4777 old_button_proc = cls.lpfnWndProc;
4779 cls.hInstance = GetModuleHandle(0);
4780 cls.lpfnWndProc = button_hook_proc;
4781 cls.lpszClassName = "my_button_class";
4782 UnregisterClass(cls.lpszClassName, cls.hInstance);
4783 if (!RegisterClassA(&cls)) assert(0);
4786 static void test_button_messages(void)
4792 const struct message *setfocus;
4793 const struct message *killfocus;
4795 { BS_PUSHBUTTON, DLGC_BUTTON | DLGC_UNDEFPUSHBUTTON,
4796 WmSetFocusButtonSeq, WmKillFocusButtonSeq },
4797 { BS_DEFPUSHBUTTON, DLGC_BUTTON | DLGC_DEFPUSHBUTTON,
4798 WmSetFocusButtonSeq, WmKillFocusButtonSeq },
4799 { BS_CHECKBOX, DLGC_BUTTON,
4800 WmSetFocusStaticSeq, WmKillFocusStaticSeq },
4801 { BS_AUTOCHECKBOX, DLGC_BUTTON,
4802 WmSetFocusStaticSeq, WmKillFocusStaticSeq },
4803 { BS_RADIOBUTTON, DLGC_BUTTON | DLGC_RADIOBUTTON,
4804 WmSetFocusStaticSeq, WmKillFocusStaticSeq },
4805 { BS_3STATE, DLGC_BUTTON,
4806 WmSetFocusStaticSeq, WmKillFocusStaticSeq },
4807 { BS_AUTO3STATE, DLGC_BUTTON,
4808 WmSetFocusStaticSeq, WmKillFocusStaticSeq },
4809 { BS_GROUPBOX, DLGC_STATIC,
4810 WmSetFocusStaticSeq, WmKillFocusStaticSeq },
4811 { BS_USERBUTTON, DLGC_BUTTON | DLGC_UNDEFPUSHBUTTON,
4812 WmSetFocusButtonSeq, WmKillFocusButtonSeq },
4813 { BS_AUTORADIOBUTTON, DLGC_BUTTON | DLGC_RADIOBUTTON,
4814 WmSetFocusStaticSeq, WmKillFocusStaticSeq },
4815 { BS_OWNERDRAW, DLGC_BUTTON,
4816 WmSetFocusButtonSeq, WmKillFocusButtonSeq }
4825 for (i = 0; i < sizeof(button)/sizeof(button[0]); i++)
4827 hwnd = CreateWindowExA(0, "my_button_class", "test", button[i].style | WS_POPUP,
4828 0, 0, 50, 14, 0, 0, 0, NULL);
4829 ok(hwnd != 0, "Failed to create button window\n");
4831 dlg_code = SendMessageA(hwnd, WM_GETDLGCODE, 0, 0);
4832 ok(dlg_code == button[i].dlg_code, "%u: wrong dlg_code %08x\n", i, dlg_code);
4834 ShowWindow(hwnd, SW_SHOW);
4839 trace("button style %08x\n", button[i].style);
4841 ok_sequence(button[i].setfocus, "SetFocus(hwnd) on a button", FALSE);
4844 ok_sequence(button[i].killfocus, "SetFocus(0) on a button", FALSE);
4846 DestroyWindow(hwnd);
4849 hwnd = CreateWindowExA(0, "my_button_class", "test", BS_PUSHBUTTON | WS_POPUP | WS_VISIBLE,
4850 0, 0, 50, 14, 0, 0, 0, NULL);
4851 ok(hwnd != 0, "Failed to create button window\n");
4857 SendMessageA(hwnd, WM_LBUTTONDOWN, 0, 0);
4858 ok_sequence(WmLButtonDownSeq, "WM_LBUTTONDOWN on a button", FALSE);
4860 SendMessageA(hwnd, WM_LBUTTONUP, 0, 0);
4861 ok_sequence(WmLButtonUpSeq, "WM_LBUTTONUP on a button", FALSE);
4864 zfont = (HFONT)GetStockObject(SYSTEM_FONT);
4865 SendMessageA(hwnd, WM_SETFONT, (WPARAM)zfont, TRUE);
4867 ok_sequence(WmSetFontButtonSeq, "WM_SETFONT on a button", FALSE);
4869 DestroyWindow(hwnd);
4872 /****************** static message test *************************/
4873 static const struct message WmSetFontStaticSeq[] =
4875 { WM_SETFONT, sent },
4876 { WM_PAINT, sent|defwinproc },
4877 { WM_ERASEBKGND, sent|defwinproc|optional },
4878 { WM_CTLCOLORSTATIC, sent|defwinproc },
4882 static WNDPROC old_static_proc;
4884 static LRESULT CALLBACK static_hook_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
4886 static long defwndproc_counter = 0;
4890 trace("static: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
4892 /* explicitly ignore WM_GETICON message */
4893 if (message == WM_GETICON) return 0;
4895 msg.message = message;
4896 msg.flags = sent|wparam|lparam;
4897 if (defwndproc_counter) msg.flags |= defwinproc;
4898 msg.wParam = wParam;
4899 msg.lParam = lParam;
4902 defwndproc_counter++;
4903 ret = CallWindowProcA(old_static_proc, hwnd, message, wParam, lParam);
4904 defwndproc_counter--;
4909 static void subclass_static(void)
4913 if (!GetClassInfoA(0, "static", &cls)) assert(0);
4915 old_static_proc = cls.lpfnWndProc;
4917 cls.hInstance = GetModuleHandle(0);
4918 cls.lpfnWndProc = static_hook_proc;
4919 cls.lpszClassName = "my_static_class";
4920 UnregisterClass(cls.lpszClassName, cls.hInstance);
4921 if (!RegisterClassA(&cls)) assert(0);
4924 static void test_static_messages(void)
4926 /* FIXME: make as comprehensive as the button message test */
4931 const struct message *setfont;
4933 { SS_LEFT, DLGC_STATIC,
4934 WmSetFontStaticSeq }
4942 for (i = 0; i < sizeof(static_ctrl)/sizeof(static_ctrl[0]); i++)
4944 hwnd = CreateWindowExA(0, "my_static_class", "test", static_ctrl[i].style | WS_POPUP,
4945 0, 0, 50, 14, 0, 0, 0, NULL);
4946 ok(hwnd != 0, "Failed to create static window\n");
4948 dlg_code = SendMessageA(hwnd, WM_GETDLGCODE, 0, 0);
4949 ok(dlg_code == static_ctrl[i].dlg_code, "%u: wrong dlg_code %08x\n", i, dlg_code);
4951 ShowWindow(hwnd, SW_SHOW);
4956 trace("static style %08x\n", static_ctrl[i].style);
4957 SendMessage(hwnd, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), TRUE);
4958 ok_sequence(static_ctrl[i].setfont, "WM_SETFONT on a static", FALSE);
4960 DestroyWindow(hwnd);
4964 /****************** ComboBox message test *************************/
4965 #define ID_COMBOBOX 0x000f
4967 static const struct message WmKeyDownComboSeq[] =
4969 { WM_KEYDOWN, sent|wparam|lparam, VK_DOWN, 0 },
4970 { WM_COMMAND, sent|wparam|defwinproc, MAKEWPARAM(1000, LBN_SELCHANGE) },
4971 { WM_COMMAND, sent|wparam|parent, MAKEWPARAM(ID_COMBOBOX, CBN_SELENDOK) },
4972 { WM_COMMAND, sent|wparam|parent, MAKEWPARAM(ID_COMBOBOX, CBN_SELCHANGE) },
4973 { WM_CTLCOLOREDIT, sent|parent },
4974 { WM_KEYUP, sent|wparam|lparam, VK_DOWN, 0 },
4978 static WNDPROC old_combobox_proc;
4980 static LRESULT CALLBACK combobox_hook_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
4982 static long defwndproc_counter = 0;
4986 /* do not log painting messages */
4987 if (message != WM_PAINT &&
4988 message != WM_NCPAINT &&
4989 message != WM_SYNCPAINT &&
4990 message != WM_ERASEBKGND &&
4991 message != WM_NCHITTEST &&
4992 message != WM_GETTEXT &&
4993 message != WM_GETICON &&
4994 message != WM_DEVICECHANGE)
4996 trace("combo: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
4998 msg.message = message;
4999 msg.flags = sent|wparam|lparam;
5000 if (defwndproc_counter) msg.flags |= defwinproc;
5001 msg.wParam = wParam;
5002 msg.lParam = lParam;
5006 defwndproc_counter++;
5007 ret = CallWindowProcA(old_combobox_proc, hwnd, message, wParam, lParam);
5008 defwndproc_counter--;
5013 static void subclass_combobox(void)
5017 if (!GetClassInfoA(0, "ComboBox", &cls)) assert(0);
5019 old_combobox_proc = cls.lpfnWndProc;
5021 cls.hInstance = GetModuleHandle(0);
5022 cls.lpfnWndProc = combobox_hook_proc;
5023 cls.lpszClassName = "my_combobox_class";
5024 UnregisterClass(cls.lpszClassName, cls.hInstance);
5025 if (!RegisterClassA(&cls)) assert(0);
5028 static void test_combobox_messages(void)
5033 subclass_combobox();
5035 parent = CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
5036 100, 100, 200, 200, 0, 0, 0, NULL);
5037 ok(parent != 0, "Failed to create parent window\n");
5040 combo = CreateWindowEx(0, "my_combobox_class", "test", WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST | CBS_HASSTRINGS,
5041 0, 0, 100, 150, parent, (HMENU)ID_COMBOBOX, 0, NULL);
5042 ok(combo != 0, "Failed to create combobox window\n");
5044 UpdateWindow(combo);
5046 ret = SendMessage(combo, WM_GETDLGCODE, 0, 0);
5047 ok(ret == (DLGC_WANTCHARS | DLGC_WANTARROWS), "wrong dlg_code %08lx\n", ret);
5049 ret = SendMessage(combo, CB_ADDSTRING, 0, (LPARAM)"item 0");
5050 ok(ret == 0, "expected 0, got %ld\n", ret);
5051 ret = SendMessage(combo, CB_ADDSTRING, 0, (LPARAM)"item 1");
5052 ok(ret == 1, "expected 1, got %ld\n", ret);
5053 ret = SendMessage(combo, CB_ADDSTRING, 0, (LPARAM)"item 2");
5054 ok(ret == 2, "expected 2, got %ld\n", ret);
5056 SendMessage(combo, CB_SETCURSEL, 0, 0);
5060 log_all_parent_messages++;
5061 SendMessage(combo, WM_KEYDOWN, VK_DOWN, 0);
5062 SendMessage(combo, WM_KEYUP, VK_DOWN, 0);
5063 log_all_parent_messages--;
5064 ok_sequence(WmKeyDownComboSeq, "WM_KEYDOWN/VK_DOWN on a ComboBox", FALSE);
5066 DestroyWindow(combo);
5067 DestroyWindow(parent);
5070 /****************** WM_IME_KEYDOWN message test *******************/
5072 static const struct message WmImeKeydownMsgSeq_0[] =
5074 { WM_IME_KEYDOWN, wparam, VK_RETURN },
5075 { WM_CHAR, wparam, 'A' },
5079 static const struct message WmImeKeydownMsgSeq_1[] =
5081 { WM_KEYDOWN, wparam, VK_RETURN },
5082 { WM_CHAR, wparam, VK_RETURN },
5086 static LRESULT WINAPI wmime_keydown_procA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
5090 trace("wmime_keydown_procA: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
5092 msg.message = message;
5093 msg.flags = wparam|lparam;
5094 msg.wParam = wParam;
5095 msg.lParam = lParam;
5098 return DefWindowProcA(hwnd, message, wParam, lParam);
5101 static void register_wmime_keydown_class(void)
5105 ZeroMemory(&cls, sizeof(WNDCLASSA));
5106 cls.lpfnWndProc = wmime_keydown_procA;
5107 cls.hInstance = GetModuleHandleA(0);
5108 cls.lpszClassName = "wmime_keydown_class";
5109 if (!RegisterClassA(&cls)) assert(0);
5112 void test_wmime_keydown_message(void)
5117 trace("Message sequences by WM_IME_KEYDOWN\n");
5119 register_wmime_keydown_class();
5120 hwnd = CreateWindowExA(0, "wmime_keydown_class", NULL, WS_OVERLAPPEDWINDOW,
5121 CW_USEDEFAULT, CW_USEDEFAULT, 300, 300, 0,
5126 SendMessage(hwnd, WM_IME_KEYDOWN, VK_RETURN, 0x1c0001);
5127 SendMessage(hwnd, WM_CHAR, 'A', 1);
5128 ok_sequence(WmImeKeydownMsgSeq_0, "WM_IME_KEYDOWN 0", FALSE);
5130 while ( PeekMessage(&msg, 0, 0, 0, PM_REMOVE) )
5132 TranslateMessage(&msg);
5133 DispatchMessage(&msg);
5135 ok_sequence(WmImeKeydownMsgSeq_1, "WM_IME_KEYDOWN 1", FALSE);
5137 DestroyWindow(hwnd);
5140 /************* painting message test ********************/
5142 void dump_region(HRGN hrgn)
5145 RGNDATA *data = NULL;
5150 printf( "null region\n" );
5153 if (!(size = GetRegionData( hrgn, 0, NULL ))) return;
5154 if (!(data = HeapAlloc( GetProcessHeap(), 0, size ))) return;
5155 GetRegionData( hrgn, size, data );
5156 printf("%d rects:", data->rdh.nCount );
5157 for (i = 0, rect = (RECT *)data->Buffer; i < data->rdh.nCount; i++, rect++)
5158 printf( " (%d,%d)-(%d,%d)", rect->left, rect->top, rect->right, rect->bottom );
5160 HeapFree( GetProcessHeap(), 0, data );
5163 static void check_update_rgn( HWND hwnd, HRGN hrgn )
5167 HRGN tmp = CreateRectRgn( 0, 0, 0, 0 );
5168 HRGN update = CreateRectRgn( 0, 0, 0, 0 );
5170 ret = GetUpdateRgn( hwnd, update, FALSE );
5171 ok( ret != ERROR, "GetUpdateRgn failed\n" );
5172 if (ret == NULLREGION)
5174 ok( !hrgn, "Update region shouldn't be empty\n" );
5178 if (CombineRgn( tmp, hrgn, update, RGN_XOR ) != NULLREGION)
5180 ok( 0, "Regions are different\n" );
5181 if (winetest_debug > 0)
5183 printf( "Update region: " );
5184 dump_region( update );
5185 printf( "Wanted region: " );
5186 dump_region( hrgn );
5190 GetRgnBox( update, &r1 );
5191 GetUpdateRect( hwnd, &r2, FALSE );
5192 ok( r1.left == r2.left && r1.top == r2.top && r1.right == r2.right && r1.bottom == r2.bottom,
5193 "Rectangles are different: %d,%d-%d,%d / %d,%d-%d,%d\n",
5194 r1.left, r1.top, r1.right, r1.bottom, r2.left, r2.top, r2.right, r2.bottom );
5196 DeleteObject( tmp );
5197 DeleteObject( update );
5200 static const struct message WmInvalidateRgn[] = {
5201 { WM_NCPAINT, sent },
5202 { WM_GETTEXT, sent|defwinproc|optional },
5206 static const struct message WmGetUpdateRect[] = {
5207 { WM_NCPAINT, sent },
5208 { WM_GETTEXT, sent|defwinproc|optional },
5213 static const struct message WmInvalidateFull[] = {
5214 { WM_NCPAINT, sent|wparam, 1 },
5215 { WM_GETTEXT, sent|defwinproc|optional },
5219 static const struct message WmInvalidateErase[] = {
5220 { WM_NCPAINT, sent|wparam, 1 },
5221 { WM_GETTEXT, sent|defwinproc|optional },
5222 { WM_ERASEBKGND, sent },
5226 static const struct message WmInvalidatePaint[] = {
5228 { WM_NCPAINT, sent|wparam|beginpaint, 1 },
5229 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
5233 static const struct message WmInvalidateErasePaint[] = {
5235 { WM_NCPAINT, sent|wparam|beginpaint, 1 },
5236 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
5237 { WM_ERASEBKGND, sent|beginpaint },
5241 static const struct message WmInvalidateErasePaint2[] = {
5243 { WM_NCPAINT, sent|beginpaint },
5244 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
5245 { WM_ERASEBKGND, sent|beginpaint },
5249 static const struct message WmErase[] = {
5250 { WM_ERASEBKGND, sent },
5254 static const struct message WmPaint[] = {
5259 static const struct message WmParentOnlyPaint[] = {
5260 { WM_PAINT, sent|parent },
5264 static const struct message WmInvalidateParent[] = {
5265 { WM_NCPAINT, sent|parent },
5266 { WM_GETTEXT, sent|defwinproc|parent|optional },
5267 { WM_ERASEBKGND, sent|parent },
5271 static const struct message WmInvalidateParentChild[] = {
5272 { WM_NCPAINT, sent|parent },
5273 { WM_GETTEXT, sent|defwinproc|parent|optional },
5274 { WM_ERASEBKGND, sent|parent },
5275 { WM_NCPAINT, sent },
5276 { WM_GETTEXT, sent|defwinproc|optional },
5277 { WM_ERASEBKGND, sent },
5281 static const struct message WmInvalidateParentChild2[] = {
5282 { WM_ERASEBKGND, sent|parent },
5283 { WM_NCPAINT, sent },
5284 { WM_GETTEXT, sent|defwinproc|optional },
5285 { WM_ERASEBKGND, sent },
5289 static const struct message WmParentPaint[] = {
5290 { WM_PAINT, sent|parent },
5295 static const struct message WmParentPaintNc[] = {
5296 { WM_PAINT, sent|parent },
5298 { WM_NCPAINT, sent|beginpaint },
5299 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
5300 { WM_ERASEBKGND, sent|beginpaint },
5304 static const struct message WmChildPaintNc[] = {
5306 { WM_NCPAINT, sent|beginpaint },
5307 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
5308 { WM_ERASEBKGND, sent|beginpaint },
5312 static const struct message WmParentErasePaint[] = {
5313 { WM_PAINT, sent|parent },
5314 { WM_NCPAINT, sent|parent|beginpaint },
5315 { WM_GETTEXT, sent|parent|beginpaint|defwinproc|optional },
5316 { WM_ERASEBKGND, sent|parent|beginpaint },
5318 { WM_NCPAINT, sent|beginpaint },
5319 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
5320 { WM_ERASEBKGND, sent|beginpaint },
5324 static const struct message WmParentOnlyNcPaint[] = {
5325 { WM_PAINT, sent|parent },
5326 { WM_NCPAINT, sent|parent|beginpaint },
5327 { WM_GETTEXT, sent|parent|beginpaint|defwinproc|optional },
5331 static const struct message WmSetParentStyle[] = {
5332 { WM_STYLECHANGING, sent|parent },
5333 { WM_STYLECHANGED, sent|parent },
5337 static void test_paint_messages(void)
5343 HWND hparent, hchild;
5344 HRGN hrgn = CreateRectRgn( 0, 0, 0, 0 );
5345 HRGN hrgn2 = CreateRectRgn( 0, 0, 0, 0 );
5346 HWND hwnd = CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW,
5347 100, 100, 200, 200, 0, 0, 0, NULL);
5348 ok (hwnd != 0, "Failed to create overlapped window\n");
5350 ShowWindow( hwnd, SW_SHOW );
5351 UpdateWindow( hwnd );
5355 check_update_rgn( hwnd, 0 );
5356 SetRectRgn( hrgn, 10, 10, 20, 20 );
5357 ret = RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE );
5358 ok(ret, "RedrawWindow returned %d instead of TRUE\n", ret);
5359 check_update_rgn( hwnd, hrgn );
5360 SetRectRgn( hrgn2, 20, 20, 30, 30 );
5361 ret = RedrawWindow( hwnd, NULL, hrgn2, RDW_INVALIDATE );
5362 ok(ret, "RedrawWindow returned %d instead of TRUE\n", ret);
5363 CombineRgn( hrgn, hrgn, hrgn2, RGN_OR );
5364 check_update_rgn( hwnd, hrgn );
5365 /* validate everything */
5366 ret = RedrawWindow( hwnd, NULL, NULL, RDW_VALIDATE );
5367 ok(ret, "RedrawWindow returned %d instead of TRUE\n", ret);
5368 check_update_rgn( hwnd, 0 );
5370 /* test empty region */
5371 SetRectRgn( hrgn, 10, 10, 10, 15 );
5372 ret = RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE );
5373 ok(ret, "RedrawWindow returned %d instead of TRUE\n", ret);
5374 check_update_rgn( hwnd, 0 );
5375 /* test empty rect */
5376 SetRect( &rect, 10, 10, 10, 15 );
5377 ret = RedrawWindow( hwnd, &rect, NULL, RDW_INVALIDATE );
5378 ok(ret, "RedrawWindow returned %d instead of TRUE\n", ret);
5379 check_update_rgn( hwnd, 0 );
5381 /* flush pending messages */
5385 GetClientRect( hwnd, &rect );
5386 SetRectRgn( hrgn, 0, 0, rect.right - rect.left, rect.bottom - rect.top );
5387 /* MSDN: if hwnd parameter is NULL, InvalidateRect invalidates and redraws
5388 * all windows and sends WM_ERASEBKGND and WM_NCPAINT.
5390 trace("testing InvalidateRect(0, NULL, FALSE)\n");
5391 SetRectEmpty( &rect );
5392 ok(InvalidateRect(0, &rect, FALSE), "InvalidateRect(0, &rc, FALSE) should fail\n");
5393 check_update_rgn( hwnd, hrgn );
5394 ok_sequence( WmInvalidateErase, "InvalidateErase", FALSE );
5396 ok_sequence( WmPaint, "Paint", FALSE );
5397 RedrawWindow( hwnd, NULL, NULL, RDW_VALIDATE );
5398 check_update_rgn( hwnd, 0 );
5400 /* MSDN: if hwnd parameter is NULL, ValidateRect invalidates and redraws
5401 * all windows and sends WM_ERASEBKGND and WM_NCPAINT.
5403 trace("testing ValidateRect(0, NULL)\n");
5404 SetRectEmpty( &rect );
5405 ok(ValidateRect(0, &rect), "ValidateRect(0, &rc) should not fail\n");
5406 check_update_rgn( hwnd, hrgn );
5407 ok_sequence( WmInvalidateErase, "InvalidateErase", FALSE );
5409 ok_sequence( WmPaint, "Paint", FALSE );
5410 RedrawWindow( hwnd, NULL, NULL, RDW_VALIDATE );
5411 check_update_rgn( hwnd, 0 );
5413 trace("testing InvalidateRgn(0, NULL, FALSE)\n");
5414 SetLastError(0xdeadbeef);
5415 ok(!InvalidateRgn(0, NULL, FALSE), "InvalidateRgn(0, NULL, FALSE) should fail\n");
5416 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE || GetLastError() == 0xdeadbeef,
5417 "wrong error code %d\n", GetLastError());
5418 check_update_rgn( hwnd, 0 );
5420 ok_sequence( WmEmptySeq, "WmEmptySeq", FALSE );
5422 trace("testing ValidateRgn(0, NULL)\n");
5423 SetLastError(0xdeadbeef);
5424 ok(!ValidateRgn(0, NULL), "ValidateRgn(0, NULL) should fail\n");
5425 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "wrong error code %d\n", GetLastError());
5426 check_update_rgn( hwnd, 0 );
5428 ok_sequence( WmEmptySeq, "WmEmptySeq", FALSE );
5430 /* now with frame */
5431 SetRectRgn( hrgn, -5, -5, 20, 20 );
5433 /* flush pending messages */
5436 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME );
5437 ok_sequence( WmEmptySeq, "EmptySeq", FALSE );
5439 SetRectRgn( hrgn, 0, 0, 20, 20 ); /* GetUpdateRgn clips to client area */
5440 check_update_rgn( hwnd, hrgn );
5443 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME | RDW_ERASENOW );
5444 ok_sequence( WmInvalidateRgn, "InvalidateRgn", FALSE );
5447 RedrawWindow( hwnd, NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_ERASENOW );
5448 ok_sequence( WmInvalidateFull, "InvalidateFull", FALSE );
5450 GetClientRect( hwnd, &rect );
5451 SetRectRgn( hrgn, rect.left, rect.top, rect.right, rect.bottom );
5452 check_update_rgn( hwnd, hrgn );
5455 RedrawWindow( hwnd, NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_ERASE | RDW_ERASENOW );
5456 ok_sequence( WmInvalidateErase, "InvalidateErase", FALSE );
5459 RedrawWindow( hwnd, NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_ERASENOW | RDW_UPDATENOW );
5460 ok_sequence( WmInvalidatePaint, "InvalidatePaint", FALSE );
5461 check_update_rgn( hwnd, 0 );
5464 RedrawWindow( hwnd, NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_ERASE | RDW_UPDATENOW );
5465 ok_sequence( WmInvalidateErasePaint, "InvalidateErasePaint", FALSE );
5466 check_update_rgn( hwnd, 0 );
5469 SetRectRgn( hrgn, 0, 0, 100, 100 );
5470 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE );
5471 SetRectRgn( hrgn, 0, 0, 50, 100 );
5472 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE );
5473 SetRectRgn( hrgn, 50, 0, 100, 100 );
5474 check_update_rgn( hwnd, hrgn );
5475 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_ERASENOW );
5476 ok_sequence( WmEmptySeq, "EmptySeq", FALSE ); /* must not generate messages, everything is valid */
5477 check_update_rgn( hwnd, 0 );
5480 SetRectRgn( hrgn, 0, 0, 100, 100 );
5481 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_ERASE );
5482 SetRectRgn( hrgn, 0, 0, 100, 50 );
5483 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_ERASENOW );
5484 ok_sequence( WmErase, "Erase", FALSE );
5485 SetRectRgn( hrgn, 0, 50, 100, 100 );
5486 check_update_rgn( hwnd, hrgn );
5489 SetRectRgn( hrgn, 0, 0, 100, 100 );
5490 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_ERASE );
5491 SetRectRgn( hrgn, 0, 0, 50, 50 );
5492 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_NOERASE | RDW_UPDATENOW );
5493 ok_sequence( WmPaint, "Paint", FALSE );
5496 SetRectRgn( hrgn, -4, -4, -2, -2 );
5497 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME );
5498 SetRectRgn( hrgn, -200, -200, -198, -198 );
5499 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_NOFRAME | RDW_ERASENOW );
5500 ok_sequence( WmEmptySeq, "EmptySeq", FALSE );
5503 SetRectRgn( hrgn, -4, -4, -2, -2 );
5504 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME );
5505 SetRectRgn( hrgn, -4, -4, -3, -3 );
5506 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_NOFRAME );
5507 SetRectRgn( hrgn, 0, 0, 1, 1 );
5508 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_UPDATENOW );
5509 ok_sequence( WmPaint, "Paint", FALSE );
5512 SetRectRgn( hrgn, -4, -4, -1, -1 );
5513 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME );
5514 RedrawWindow( hwnd, NULL, 0, RDW_ERASENOW );
5515 /* make sure no WM_PAINT was generated */
5517 ok_sequence( WmInvalidateRgn, "InvalidateRgn", FALSE );
5520 SetRectRgn( hrgn, -4, -4, -1, -1 );
5521 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME );
5522 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE ))
5524 if (msg.hwnd == hwnd && msg.message == WM_PAINT)
5526 /* GetUpdateRgn must return empty region since only nonclient area is invalidated */
5527 INT ret = GetUpdateRgn( hwnd, hrgn, FALSE );
5528 ok( ret == NULLREGION, "Invalid GetUpdateRgn result %d\n", ret );
5529 ret = GetUpdateRect( hwnd, &rect, FALSE );
5530 ok( ret, "Invalid GetUpdateRect result %d\n", ret );
5531 /* this will send WM_NCPAINT and validate the non client area */
5532 ret = GetUpdateRect( hwnd, &rect, TRUE );
5533 ok( !ret, "Invalid GetUpdateRect result %d\n", ret );
5535 DispatchMessage( &msg );
5537 ok_sequence( WmGetUpdateRect, "GetUpdateRect", FALSE );
5539 DestroyWindow( hwnd );
5541 /* now test with a child window */
5543 hparent = CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW,
5544 100, 100, 200, 200, 0, 0, 0, NULL);
5545 ok (hparent != 0, "Failed to create parent window\n");
5547 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD | WS_VISIBLE | WS_BORDER,
5548 10, 10, 100, 100, hparent, 0, 0, NULL);
5549 ok (hchild != 0, "Failed to create child window\n");
5551 ShowWindow( hparent, SW_SHOW );
5552 UpdateWindow( hparent );
5553 UpdateWindow( hchild );
5556 log_all_parent_messages++;
5558 SetRect( &rect, 0, 0, 50, 50 );
5559 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
5560 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW | RDW_ALLCHILDREN );
5561 ok_sequence( WmInvalidateParentChild, "InvalidateParentChild", FALSE );
5563 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
5565 MapWindowPoints( hchild, hparent, &pt, 1 );
5566 SetRectRgn( hrgn, 0, 0, 50 - pt.x, 50 - pt.y );
5567 check_update_rgn( hchild, hrgn );
5568 SetRectRgn( hrgn, 0, 0, 50, 50 );
5569 check_update_rgn( hparent, hrgn );
5570 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW );
5571 ok_sequence( WmInvalidateParent, "InvalidateParent", FALSE );
5572 RedrawWindow( hchild, NULL, 0, RDW_ERASENOW );
5573 ok_sequence( WmEmptySeq, "EraseNow child", FALSE );
5576 ok_sequence( WmParentPaintNc, "WmParentPaintNc", FALSE );
5578 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_ALLCHILDREN );
5579 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW );
5580 ok_sequence( WmInvalidateParent, "InvalidateParent2", FALSE );
5581 RedrawWindow( hchild, NULL, 0, RDW_ERASENOW );
5582 ok_sequence( WmEmptySeq, "EraseNow child", FALSE );
5584 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE );
5585 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW | RDW_ALLCHILDREN );
5586 ok_sequence( WmInvalidateParentChild2, "InvalidateParentChild2", FALSE );
5588 SetWindowLong( hparent, GWL_STYLE, GetWindowLong(hparent,GWL_STYLE) | WS_CLIPCHILDREN );
5590 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_ALLCHILDREN );
5591 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW );
5592 ok_sequence( WmInvalidateParentChild, "InvalidateParentChild3", FALSE );
5594 /* flush all paint messages */
5598 /* RDW_UPDATENOW on child with WS_CLIPCHILDREN doesn't change corresponding parent area */
5599 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_ALLCHILDREN );
5600 SetRectRgn( hrgn, 0, 0, 50, 50 );
5601 check_update_rgn( hparent, hrgn );
5602 RedrawWindow( hchild, NULL, 0, RDW_UPDATENOW );
5603 ok_sequence( WmInvalidateErasePaint2, "WmInvalidateErasePaint2", FALSE );
5604 SetRectRgn( hrgn, 0, 0, 50, 50 );
5605 check_update_rgn( hparent, hrgn );
5607 /* flush all paint messages */
5609 SetWindowLong( hparent, GWL_STYLE, GetWindowLong(hparent,GWL_STYLE) & ~WS_CLIPCHILDREN );
5612 /* RDW_UPDATENOW on child without WS_CLIPCHILDREN will validate corresponding parent area */
5613 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
5614 SetRectRgn( hrgn, 0, 0, 50, 50 );
5615 check_update_rgn( hparent, hrgn );
5616 RedrawWindow( hchild, NULL, 0, RDW_UPDATENOW );
5617 ok_sequence( WmInvalidateErasePaint2, "WmInvalidateErasePaint2", FALSE );
5618 SetRectRgn( hrgn2, 10, 10, 50, 50 );
5619 CombineRgn( hrgn, hrgn, hrgn2, RGN_DIFF );
5620 check_update_rgn( hparent, hrgn );
5621 /* flush all paint messages */
5625 /* same as above but parent gets completely validated */
5626 SetRect( &rect, 20, 20, 30, 30 );
5627 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
5628 SetRectRgn( hrgn, 20, 20, 30, 30 );
5629 check_update_rgn( hparent, hrgn );
5630 RedrawWindow( hchild, NULL, 0, RDW_UPDATENOW );
5631 ok_sequence( WmInvalidateErasePaint2, "WmInvalidateErasePaint2", FALSE );
5632 check_update_rgn( hparent, 0 ); /* no update region */
5634 ok_sequence( WmEmptySeq, "WmEmpty", FALSE ); /* and no paint messages */
5636 /* make sure RDW_VALIDATE on child doesn't have the same effect */
5638 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
5639 SetRectRgn( hrgn, 20, 20, 30, 30 );
5640 check_update_rgn( hparent, hrgn );
5641 RedrawWindow( hchild, NULL, 0, RDW_VALIDATE | RDW_NOERASE );
5642 SetRectRgn( hrgn, 20, 20, 30, 30 );
5643 check_update_rgn( hparent, hrgn );
5645 /* same as above but normal WM_PAINT doesn't validate parent */
5647 SetRect( &rect, 20, 20, 30, 30 );
5648 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
5649 SetRectRgn( hrgn, 20, 20, 30, 30 );
5650 check_update_rgn( hparent, hrgn );
5651 /* no WM_PAINT in child while parent still pending */
5652 while (PeekMessage( &msg, hchild, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
5653 ok_sequence( WmEmptySeq, "No WM_PAINT", FALSE );
5654 while (PeekMessage( &msg, hparent, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
5655 ok_sequence( WmParentErasePaint, "WmParentErasePaint", FALSE );
5658 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
5659 /* no WM_PAINT in child while parent still pending */
5660 while (PeekMessage( &msg, hchild, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
5661 ok_sequence( WmEmptySeq, "No WM_PAINT", FALSE );
5662 RedrawWindow( hparent, &rect, 0, RDW_VALIDATE | RDW_NOERASE | RDW_NOCHILDREN );
5663 /* now that parent is valid child should get WM_PAINT */
5664 while (PeekMessage( &msg, hchild, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
5665 ok_sequence( WmInvalidateErasePaint2, "WmInvalidateErasePaint2", FALSE );
5666 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
5667 ok_sequence( WmEmptySeq, "No other message", FALSE );
5669 /* same thing with WS_CLIPCHILDREN in parent */
5671 SetWindowLong( hparent, GWL_STYLE, GetWindowLong(hparent,GWL_STYLE) | WS_CLIPCHILDREN );
5672 ok_sequence( WmSetParentStyle, "WmSetParentStyle", FALSE );
5673 /* changing style invalidates non client area, but we need to invalidate something else to see it */
5674 RedrawWindow( hparent, &rect, 0, RDW_UPDATENOW );
5675 ok_sequence( WmEmptySeq, "No message", FALSE );
5676 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_UPDATENOW );
5677 ok_sequence( WmParentOnlyNcPaint, "WmParentOnlyNcPaint", FALSE );
5680 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_ALLCHILDREN );
5681 SetRectRgn( hrgn, 20, 20, 30, 30 );
5682 check_update_rgn( hparent, hrgn );
5683 /* no WM_PAINT in child while parent still pending */
5684 while (PeekMessage( &msg, hchild, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
5685 ok_sequence( WmEmptySeq, "No WM_PAINT", FALSE );
5686 /* WM_PAINT in parent first */
5687 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
5688 ok_sequence( WmParentPaintNc, "WmParentPaintNc2", FALSE );
5690 /* no RDW_ERASE in parent still causes RDW_ERASE and RDW_FRAME in child */
5692 SetRect( &rect, 0, 0, 30, 30 );
5693 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ALLCHILDREN );
5694 SetRectRgn( hrgn, 0, 0, 30, 30 );
5695 check_update_rgn( hparent, hrgn );
5697 ok_sequence( WmParentPaintNc, "WmParentPaintNc3", FALSE );
5699 /* validate doesn't cause RDW_NOERASE or RDW_NOFRAME in child */
5701 SetRect( &rect, -10, 0, 30, 30 );
5702 RedrawWindow( hchild, &rect, 0, RDW_INVALIDATE | RDW_FRAME | RDW_ERASE );
5703 SetRect( &rect, 0, 0, 20, 20 );
5704 RedrawWindow( hparent, &rect, 0, RDW_VALIDATE | RDW_ALLCHILDREN );
5705 RedrawWindow( hparent, NULL, 0, RDW_UPDATENOW );
5706 ok_sequence( WmChildPaintNc, "WmChildPaintNc", FALSE );
5708 /* validate doesn't cause RDW_NOERASE or RDW_NOFRAME in child */
5710 SetRect( &rect, -10, 0, 30, 30 );
5711 RedrawWindow( hchild, &rect, 0, RDW_INVALIDATE | RDW_FRAME | RDW_ERASE );
5712 SetRect( &rect, 0, 0, 100, 100 );
5713 RedrawWindow( hparent, &rect, 0, RDW_VALIDATE | RDW_ALLCHILDREN );
5714 RedrawWindow( hparent, NULL, 0, RDW_UPDATENOW );
5715 ok_sequence( WmEmptySeq, "WmChildPaintNc2", FALSE );
5716 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW );
5717 ok_sequence( WmEmptySeq, "WmChildPaintNc3", FALSE );
5719 /* test RDW_INTERNALPAINT behavior */
5722 RedrawWindow( hparent, NULL, 0, RDW_INTERNALPAINT | RDW_NOCHILDREN );
5724 ok_sequence( WmParentOnlyPaint, "WmParentOnlyPaint", FALSE );
5726 RedrawWindow( hparent, NULL, 0, RDW_INTERNALPAINT | RDW_ALLCHILDREN );
5728 ok_sequence( WmParentPaint, "WmParentPaint", FALSE );
5730 RedrawWindow( hparent, NULL, 0, RDW_INTERNALPAINT );
5732 ok_sequence( WmParentOnlyPaint, "WmParentOnlyPaint", FALSE );
5734 assert( GetWindowLong(hparent, GWL_STYLE) & WS_CLIPCHILDREN );
5735 UpdateWindow( hparent );
5738 trace("testing SWP_FRAMECHANGED on parent with WS_CLIPCHILDREN\n");
5739 RedrawWindow( hchild, NULL, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
5740 SetWindowPos( hparent, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE |
5741 SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED );
5743 ok_sequence(WmSWP_FrameChanged_clip, "SetWindowPos:FrameChanged_clip", FALSE );
5745 UpdateWindow( hparent );
5748 trace("testing SWP_FRAMECHANGED|SWP_DEFERERASE on parent with WS_CLIPCHILDREN\n");
5749 RedrawWindow( hchild, NULL, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
5750 SetWindowPos( hparent, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_DEFERERASE |
5751 SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED );
5753 ok_sequence(WmSWP_FrameChangedDeferErase, "SetWindowPos:FrameChangedDeferErase", FALSE );
5755 SetWindowLong( hparent, GWL_STYLE, GetWindowLong(hparent,GWL_STYLE) & ~WS_CLIPCHILDREN );
5756 ok_sequence( WmSetParentStyle, "WmSetParentStyle", FALSE );
5757 RedrawWindow( hparent, NULL, 0, RDW_INTERNALPAINT );
5759 ok_sequence( WmParentPaint, "WmParentPaint", FALSE );
5761 assert( !(GetWindowLong(hparent, GWL_STYLE) & WS_CLIPCHILDREN) );
5762 UpdateWindow( hparent );
5765 trace("testing SWP_FRAMECHANGED on parent without WS_CLIPCHILDREN\n");
5766 RedrawWindow( hchild, NULL, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
5767 SetWindowPos( hparent, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE |
5768 SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED );
5770 ok_sequence(WmSWP_FrameChanged_noclip, "SetWindowPos:FrameChanged_noclip", FALSE );
5772 UpdateWindow( hparent );
5775 trace("testing SWP_FRAMECHANGED|SWP_DEFERERASE on parent without WS_CLIPCHILDREN\n");
5776 RedrawWindow( hchild, NULL, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
5777 SetWindowPos( hparent, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_DEFERERASE |
5778 SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED );
5780 ok_sequence(WmSWP_FrameChangedDeferErase, "SetWindowPos:FrameChangedDeferErase", FALSE );
5782 ok(GetWindowLong( hparent, GWL_STYLE ) & WS_VISIBLE, "parent should be visible\n");
5783 ok(GetWindowLong( hchild, GWL_STYLE ) & WS_VISIBLE, "child should be visible\n");
5785 UpdateWindow( hparent );
5788 trace("testing SetWindowPos(-10000, -10000) on child\n");
5789 SetWindowPos( hchild, 0, -10000, -10000, 0, 0, SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER );
5790 check_update_rgn( hchild, 0 );
5793 #if 0 /* this one doesn't pass under Wine yet */
5794 UpdateWindow( hparent );
5797 trace("testing ShowWindow(SW_MINIMIZE) on child\n");
5798 ShowWindow( hchild, SW_MINIMIZE );
5799 check_update_rgn( hchild, 0 );
5803 UpdateWindow( hparent );
5806 trace("testing SetWindowPos(-10000, -10000) on parent\n");
5807 SetWindowPos( hparent, 0, -10000, -10000, 0, 0, SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER );
5808 check_update_rgn( hparent, 0 );
5811 log_all_parent_messages--;
5812 DestroyWindow( hparent );
5813 ok(!IsWindow(hchild), "child must be destroyed with its parent\n");
5815 /* tests for moving windows off-screen (needs simple WS_POPUP windows) */
5817 hparent = CreateWindowExA(0, "TestParentClass", "Test parent", WS_POPUP | WS_VISIBLE,
5818 100, 100, 200, 200, 0, 0, 0, NULL);
5819 ok (hparent != 0, "Failed to create parent window\n");
5821 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD | WS_VISIBLE,
5822 10, 10, 100, 100, hparent, 0, 0, NULL);
5823 ok (hchild != 0, "Failed to create child window\n");
5825 ShowWindow( hparent, SW_SHOW );
5826 UpdateWindow( hparent );
5827 UpdateWindow( hchild );
5831 /* moving child outside of parent boundaries changes update region */
5832 SetRect( &rect, 0, 0, 40, 40 );
5833 RedrawWindow( hchild, &rect, 0, RDW_INVALIDATE | RDW_ERASE );
5834 SetRectRgn( hrgn, 0, 0, 40, 40 );
5835 check_update_rgn( hchild, hrgn );
5836 MoveWindow( hchild, -10, 10, 100, 100, FALSE );
5837 SetRectRgn( hrgn, 10, 0, 40, 40 );
5838 check_update_rgn( hchild, hrgn );
5839 MoveWindow( hchild, -10, -10, 100, 100, FALSE );
5840 SetRectRgn( hrgn, 10, 10, 40, 40 );
5841 check_update_rgn( hchild, hrgn );
5843 /* moving parent off-screen does too */
5844 SetRect( &rect, 0, 0, 100, 100 );
5845 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_NOCHILDREN );
5846 SetRectRgn( hrgn, 0, 0, 100, 100 );
5847 check_update_rgn( hparent, hrgn );
5848 SetRectRgn( hrgn, 10, 10, 40, 40 );
5849 check_update_rgn( hchild, hrgn );
5850 MoveWindow( hparent, -20, -20, 200, 200, FALSE );
5851 SetRectRgn( hrgn, 20, 20, 100, 100 );
5852 check_update_rgn( hparent, hrgn );
5853 SetRectRgn( hrgn, 30, 30, 40, 40 );
5854 check_update_rgn( hchild, hrgn );
5856 /* invalidated region is cropped by the parent rects */
5857 SetRect( &rect, 0, 0, 50, 50 );
5858 RedrawWindow( hchild, &rect, 0, RDW_INVALIDATE | RDW_ERASE );
5859 SetRectRgn( hrgn, 30, 30, 50, 50 );
5860 check_update_rgn( hchild, hrgn );
5862 DestroyWindow( hparent );
5863 ok(!IsWindow(hchild), "child must be destroyed with its parent\n");
5866 DeleteObject( hrgn );
5867 DeleteObject( hrgn2 );
5876 static DWORD WINAPI thread_proc(void *param)
5879 struct wnd_event *wnd_event = (struct wnd_event *)param;
5881 wnd_event->hwnd = CreateWindowExA(0, "TestWindowClass", "window caption text", WS_OVERLAPPEDWINDOW,
5882 100, 100, 200, 200, 0, 0, 0, NULL);
5883 ok(wnd_event->hwnd != 0, "Failed to create overlapped window\n");
5885 SetEvent(wnd_event->event);
5887 while (GetMessage(&msg, 0, 0, 0))
5889 TranslateMessage(&msg);
5890 DispatchMessage(&msg);
5893 ok(IsWindow(wnd_event->hwnd), "window should still exist\n");
5898 static void test_interthread_messages(void)
5905 int len, expected_len;
5906 struct wnd_event wnd_event;
5909 wnd_event.event = CreateEventW(NULL, 0, 0, NULL);
5910 if (!wnd_event.event)
5912 trace("skipping interthread message test under win9x\n");
5916 hThread = CreateThread(NULL, 0, thread_proc, &wnd_event, 0, &tid);
5917 ok(hThread != NULL, "CreateThread failed, error %d\n", GetLastError());
5919 ok(WaitForSingleObject(wnd_event.event, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
5921 CloseHandle(wnd_event.event);
5923 SetLastError(0xdeadbeef);
5924 ok(!DestroyWindow(wnd_event.hwnd), "DestroyWindow succeded\n");
5925 ok(GetLastError() == ERROR_ACCESS_DENIED || GetLastError() == 0xdeadbeef,
5926 "wrong error code %d\n", GetLastError());
5928 proc = (WNDPROC)GetWindowLongPtrA(wnd_event.hwnd, GWLP_WNDPROC);
5929 ok(proc != NULL, "GetWindowLongPtrA(GWLP_WNDPROC) error %d\n", GetLastError());
5931 expected_len = lstrlenA("window caption text");
5932 memset(buf, 0, sizeof(buf));
5933 SetLastError(0xdeadbeef);
5934 len = CallWindowProcA(proc, wnd_event.hwnd, WM_GETTEXT, sizeof(buf), (LPARAM)buf);
5935 ok(len == expected_len, "CallWindowProcA(WM_GETTEXT) error %d, len %d, expected len %d\n", GetLastError(), len, expected_len);
5936 ok(!lstrcmpA(buf, "window caption text"), "window text mismatch\n");
5938 msg.hwnd = wnd_event.hwnd;
5939 msg.message = WM_GETTEXT;
5940 msg.wParam = sizeof(buf);
5941 msg.lParam = (LPARAM)buf;
5942 memset(buf, 0, sizeof(buf));
5943 SetLastError(0xdeadbeef);
5944 len = DispatchMessageA(&msg);
5945 ok(!len && GetLastError() == ERROR_MESSAGE_SYNC_ONLY,
5946 "DispatchMessageA(WM_GETTEXT) succeded on another thread window: ret %d, error %d\n", len, GetLastError());
5948 /* the following test causes an exception in user.exe under win9x */
5949 msg.hwnd = wnd_event.hwnd;
5950 msg.message = WM_TIMER;
5952 msg.lParam = GetWindowLongPtrA(wnd_event.hwnd, GWLP_WNDPROC);
5953 SetLastError(0xdeadbeef);
5954 len = DispatchMessageA(&msg);
5955 ok(!len && GetLastError() == 0xdeadbeef,
5956 "DispatchMessageA(WM_TIMER) failed on another thread window: ret %d, error %d\n", len, GetLastError());
5958 ret = PostMessageA(wnd_event.hwnd, WM_QUIT, 0, 0);
5959 ok( ret, "PostMessageA(WM_QUIT) error %d\n", GetLastError());
5961 ok(WaitForSingleObject(hThread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
5962 CloseHandle(hThread);
5964 ok(!IsWindow(wnd_event.hwnd), "window should be destroyed on thread exit\n");
5968 static const struct message WmVkN[] = {
5969 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 1 }, /* XP */
5970 { WM_KEYDOWN, wparam|lparam, 'N', 1 },
5971 { WM_KEYDOWN, sent|wparam|lparam, 'N', 1 },
5972 { WM_CHAR, wparam|lparam, 'n', 1 },
5973 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1002,1), 0 },
5974 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xc0000001 }, /* XP */
5975 { WM_KEYUP, wparam|lparam, 'N', 0xc0000001 },
5976 { WM_KEYUP, sent|wparam|lparam, 'N', 0xc0000001 },
5979 static const struct message WmShiftVkN[] = {
5980 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_SHIFT, 1 }, /* XP */
5981 { WM_KEYDOWN, wparam|lparam, VK_SHIFT, 1 },
5982 { WM_KEYDOWN, sent|wparam|lparam, VK_SHIFT, 1 },
5983 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 1 }, /* XP */
5984 { WM_KEYDOWN, wparam|lparam, 'N', 1 },
5985 { WM_KEYDOWN, sent|wparam|lparam, 'N', 1 },
5986 { WM_CHAR, wparam|lparam, 'N', 1 },
5987 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1001,1), 0 },
5988 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xc0000001 }, /* XP */
5989 { WM_KEYUP, wparam|lparam, 'N', 0xc0000001 },
5990 { WM_KEYUP, sent|wparam|lparam, 'N', 0xc0000001 },
5991 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_SHIFT, 0xc0000001 }, /* XP */
5992 { WM_KEYUP, wparam|lparam, VK_SHIFT, 0xc0000001 },
5993 { WM_KEYUP, sent|wparam|lparam, VK_SHIFT, 0xc0000001 },
5996 static const struct message WmCtrlVkN[] = {
5997 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 1 }, /* XP */
5998 { WM_KEYDOWN, wparam|lparam, VK_CONTROL, 1 },
5999 { WM_KEYDOWN, sent|wparam|lparam, VK_CONTROL, 1 },
6000 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 1 }, /* XP */
6001 { WM_KEYDOWN, wparam|lparam, 'N', 1 },
6002 { WM_KEYDOWN, sent|wparam|lparam, 'N', 1 },
6003 { WM_CHAR, wparam|lparam, 0x000e, 1 },
6004 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1000,1), 0 },
6005 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xc0000001 }, /* XP */
6006 { WM_KEYUP, wparam|lparam, 'N', 0xc0000001 },
6007 { WM_KEYUP, sent|wparam|lparam, 'N', 0xc0000001 },
6008 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 0xc0000001 }, /* XP */
6009 { WM_KEYUP, wparam|lparam, VK_CONTROL, 0xc0000001 },
6010 { WM_KEYUP, sent|wparam|lparam, VK_CONTROL, 0xc0000001 },
6013 static const struct message WmCtrlVkN_2[] = {
6014 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 1 }, /* XP */
6015 { WM_KEYDOWN, wparam|lparam, VK_CONTROL, 1 },
6016 { WM_KEYDOWN, sent|wparam|lparam, VK_CONTROL, 1 },
6017 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 1 }, /* XP */
6018 { WM_KEYDOWN, wparam|lparam, 'N', 1 },
6019 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1000,1), 0 },
6020 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xc0000001 }, /* XP */
6021 { WM_KEYUP, wparam|lparam, 'N', 0xc0000001 },
6022 { WM_KEYUP, sent|wparam|lparam, 'N', 0xc0000001 },
6023 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 0xc0000001 }, /* XP */
6024 { WM_KEYUP, wparam|lparam, VK_CONTROL, 0xc0000001 },
6025 { WM_KEYUP, sent|wparam|lparam, VK_CONTROL, 0xc0000001 },
6028 static const struct message WmAltVkN[] = {
6029 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0x20000001 }, /* XP */
6030 { WM_SYSKEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
6031 { WM_SYSKEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
6032 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0x20000001 }, /* XP */
6033 { WM_SYSKEYDOWN, wparam|lparam, 'N', 0x20000001 },
6034 { WM_SYSKEYDOWN, sent|wparam|lparam, 'N', 0x20000001 },
6035 { WM_SYSCHAR, wparam|lparam, 'n', 0x20000001 },
6036 { WM_SYSCHAR, sent|wparam|lparam, 'n', 0x20000001 },
6037 { WM_SYSCOMMAND, sent|defwinproc|wparam|lparam, SC_KEYMENU, 'n' },
6038 { HCBT_SYSCOMMAND, hook },
6039 { WM_ENTERMENULOOP, sent|defwinproc|wparam|lparam, 0, 0 },
6040 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
6041 { 0x00AE, sent|defwinproc|optional }, /* XP */
6042 { WM_GETTEXT, sent|defwinproc|optional }, /* XP */
6043 { WM_INITMENU, sent|defwinproc },
6044 { EVENT_SYSTEM_MENUSTART, winevent_hook|wparam|lparam, OBJID_SYSMENU, 0 },
6045 { WM_MENUCHAR, sent|defwinproc|wparam, MAKEWPARAM('n',MF_SYSMENU) },
6046 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, 0, 0 },
6047 { WM_CAPTURECHANGED, sent|defwinproc },
6048 { WM_MENUSELECT, sent|defwinproc|wparam, MAKEWPARAM(0,0xffff) },
6049 { EVENT_SYSTEM_MENUEND, winevent_hook|wparam|lparam, OBJID_SYSMENU, 0 },
6050 { WM_EXITMENULOOP, sent|defwinproc },
6051 { WM_MENUSELECT, sent|defwinproc|wparam|optional, MAKEWPARAM(0,0xffff) }, /* Win95 bug */
6052 { WM_EXITMENULOOP, sent|defwinproc|optional }, /* Win95 bug */
6053 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xe0000001 }, /* XP */
6054 { WM_SYSKEYUP, wparam|lparam, 'N', 0xe0000001 },
6055 { WM_SYSKEYUP, sent|wparam|lparam, 'N', 0xe0000001 },
6056 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0xc0000001 }, /* XP */
6057 { WM_KEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
6058 { WM_KEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
6061 static const struct message WmAltVkN_2[] = {
6062 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0x20000001 }, /* XP */
6063 { WM_SYSKEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
6064 { WM_SYSKEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
6065 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0x20000001 }, /* XP */
6066 { WM_SYSKEYDOWN, wparam|lparam, 'N', 0x20000001 },
6067 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1003,1), 0 },
6068 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xe0000001 }, /* XP */
6069 { WM_SYSKEYUP, wparam|lparam, 'N', 0xe0000001 },
6070 { WM_SYSKEYUP, sent|wparam|lparam, 'N', 0xe0000001 },
6071 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0xc0000001 }, /* XP */
6072 { WM_KEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
6073 { WM_KEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
6076 static const struct message WmCtrlAltVkN[] = {
6077 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 1 }, /* XP */
6078 { WM_KEYDOWN, wparam|lparam, VK_CONTROL, 1 },
6079 { WM_KEYDOWN, sent|wparam|lparam, VK_CONTROL, 1 },
6080 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0x20000001 }, /* XP */
6081 { WM_KEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
6082 { WM_KEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
6083 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0x20000001 }, /* XP */
6084 { WM_KEYDOWN, wparam|lparam, 'N', 0x20000001 },
6085 { WM_KEYDOWN, sent|wparam|lparam, 'N', 0x20000001 },
6086 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xe0000001 }, /* XP */
6087 { WM_KEYUP, wparam|lparam, 'N', 0xe0000001 },
6088 { WM_KEYUP, sent|wparam|lparam, 'N', 0xe0000001 },
6089 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0xc0000001 }, /* XP */
6090 { WM_KEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
6091 { WM_KEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
6092 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 0xc0000001 }, /* XP */
6093 { WM_KEYUP, wparam|lparam, VK_CONTROL, 0xc0000001 },
6094 { WM_KEYUP, sent|wparam|lparam, VK_CONTROL, 0xc0000001 },
6097 static const struct message WmCtrlShiftVkN[] = {
6098 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 1 }, /* XP */
6099 { WM_KEYDOWN, wparam|lparam, VK_CONTROL, 1 },
6100 { WM_KEYDOWN, sent|wparam|lparam, VK_CONTROL, 1 },
6101 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_SHIFT, 1 }, /* XP */
6102 { WM_KEYDOWN, wparam|lparam, VK_SHIFT, 1 },
6103 { WM_KEYDOWN, sent|wparam|lparam, VK_SHIFT, 1 },
6104 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 1 }, /* XP */
6105 { WM_KEYDOWN, wparam|lparam, 'N', 1 },
6106 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1004,1), 0 },
6107 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xc0000001 }, /* XP */
6108 { WM_KEYUP, wparam|lparam, 'N', 0xc0000001 },
6109 { WM_KEYUP, sent|wparam|lparam, 'N', 0xc0000001 },
6110 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_SHIFT, 0xc0000001 }, /* XP */
6111 { WM_KEYUP, wparam|lparam, VK_SHIFT, 0xc0000001 },
6112 { WM_KEYUP, sent|wparam|lparam, VK_SHIFT, 0xc0000001 },
6113 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 0xc0000001 }, /* XP */
6114 { WM_KEYUP, wparam|lparam, VK_CONTROL, 0xc0000001 },
6115 { WM_KEYUP, sent|wparam|lparam, VK_CONTROL, 0xc0000001 },
6118 static const struct message WmCtrlAltShiftVkN[] = {
6119 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 1 }, /* XP */
6120 { WM_KEYDOWN, wparam|lparam, VK_CONTROL, 1 },
6121 { WM_KEYDOWN, sent|wparam|lparam, VK_CONTROL, 1 },
6122 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0x20000001 }, /* XP */
6123 { WM_KEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
6124 { WM_KEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
6125 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_SHIFT, 0x20000001 }, /* XP */
6126 { WM_KEYDOWN, wparam|lparam, VK_SHIFT, 0x20000001 },
6127 { WM_KEYDOWN, sent|wparam|lparam, VK_SHIFT, 0x20000001 },
6128 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0x20000001 }, /* XP */
6129 { WM_KEYDOWN, wparam|lparam, 'N', 0x20000001 },
6130 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1005,1), 0 },
6131 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xe0000001 }, /* XP */
6132 { WM_KEYUP, wparam|lparam, 'N', 0xe0000001 },
6133 { WM_KEYUP, sent|wparam|lparam, 'N', 0xe0000001 },
6134 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_SHIFT, 0xe0000001 }, /* XP */
6135 { WM_KEYUP, wparam|lparam, VK_SHIFT, 0xe0000001 },
6136 { WM_KEYUP, sent|wparam|lparam, VK_SHIFT, 0xe0000001 },
6137 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0xc0000001 }, /* XP */
6138 { WM_KEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
6139 { WM_KEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
6140 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 0xc0000001 }, /* XP */
6141 { WM_KEYUP, wparam|lparam, VK_CONTROL, 0xc0000001 },
6142 { WM_KEYUP, sent|wparam|lparam, VK_CONTROL, 0xc0000001 },
6145 static const struct message WmAltPressRelease[] = {
6146 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0x20000001 }, /* XP */
6147 { WM_SYSKEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
6148 { WM_SYSKEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
6149 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0xc0000001 }, /* XP */
6150 { WM_SYSKEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
6151 { WM_SYSKEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
6152 { WM_SYSCOMMAND, sent|defwinproc|wparam|lparam, SC_KEYMENU, 0 },
6153 { HCBT_SYSCOMMAND, hook },
6154 { WM_ENTERMENULOOP, sent|defwinproc|wparam|lparam, 0, 0 },
6155 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
6156 { WM_INITMENU, sent|defwinproc },
6157 { EVENT_SYSTEM_MENUSTART, winevent_hook|wparam|lparam, OBJID_SYSMENU, 0 },
6158 { WM_MENUSELECT, sent|defwinproc|wparam, MAKEWPARAM(0,MF_SYSMENU|MF_POPUP|MF_HILITE) },
6159 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_SYSMENU, 1 },
6161 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0x30000001 }, /* XP */
6163 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_SYSMENU, 0 },
6164 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, 0, 0, },
6165 { WM_CAPTURECHANGED, sent|defwinproc },
6166 { WM_MENUSELECT, sent|defwinproc|wparam|optional, MAKEWPARAM(0,0xffff) },
6167 { EVENT_SYSTEM_MENUEND, winevent_hook|wparam|lparam, OBJID_SYSMENU, 0 },
6168 { WM_EXITMENULOOP, sent|defwinproc },
6169 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0xc0000001 }, /* XP */
6170 { WM_SYSKEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
6171 { WM_SYSKEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
6174 static const struct message WmAltMouseButton[] = {
6175 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0x20000001 }, /* XP */
6176 { WM_SYSKEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
6177 { WM_SYSKEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
6178 { WM_MOUSEMOVE, wparam|optional, 0, 0 },
6179 { WM_MOUSEMOVE, sent|wparam|optional, 0, 0 },
6180 { WM_LBUTTONDOWN, wparam, MK_LBUTTON, 0 },
6181 { WM_LBUTTONDOWN, sent|wparam, MK_LBUTTON, 0 },
6182 { WM_LBUTTONUP, wparam, 0, 0 },
6183 { WM_LBUTTONUP, sent|wparam, 0, 0 },
6184 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0xc0000001 }, /* XP */
6185 { WM_SYSKEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
6186 { WM_SYSKEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
6189 static const struct message WmF1Seq[] = {
6190 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_F1, 1 }, /* XP */
6191 { WM_KEYDOWN, wparam|lparam, VK_F1, 1 },
6192 { WM_KEYDOWN, sent|wparam|lparam, VK_F1, 0x00000001 },
6193 { WM_KEYF1, wparam|lparam, 0, 0 },
6194 { WM_KEYF1, sent|wparam|lparam, 0, 0 },
6195 { WM_HELP, sent|defwinproc },
6196 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_F1, 0xc0000001 }, /* XP */
6197 { WM_KEYUP, wparam|lparam, VK_F1, 0xc0000001 },
6198 { WM_KEYUP, sent|wparam|lparam, VK_F1, 0xc0000001 },
6201 static const struct message WmVkAppsSeq[] = {
6202 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_APPS, 1 }, /* XP */
6203 { WM_KEYDOWN, wparam|lparam, VK_APPS, 1 },
6204 { WM_KEYDOWN, sent|wparam|lparam, VK_APPS, 0x00000001 },
6205 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_APPS, 0xc0000001 }, /* XP */
6206 { WM_KEYUP, wparam|lparam, VK_APPS, 0xc0000001 },
6207 { WM_KEYUP, sent|wparam|lparam, VK_APPS, 0xc0000001 },
6208 { WM_CONTEXTMENU, lparam, /*hwnd*/0, (LPARAM)-1 },
6209 { WM_CONTEXTMENU, sent|lparam, /*hwnd*/0, (LPARAM)-1 },
6213 static void pump_msg_loop(HWND hwnd, HACCEL hAccel)
6217 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE))
6219 struct message log_msg;
6221 trace("accel: %p, %04x, %08lx, %08lx\n", msg.hwnd, msg.message, msg.wParam, msg.lParam);
6223 /* ignore some unwanted messages */
6224 if (msg.message == WM_MOUSEMOVE ||
6225 msg.message == WM_GETICON ||
6226 msg.message == WM_DEVICECHANGE)
6229 log_msg.message = msg.message;
6230 log_msg.flags = wparam|lparam;
6231 log_msg.wParam = msg.wParam;
6232 log_msg.lParam = msg.lParam;
6233 add_message(&log_msg);
6235 if (!hAccel || !TranslateAccelerator(hwnd, hAccel, &msg))
6237 TranslateMessage(&msg);
6238 DispatchMessage(&msg);
6243 static void test_accelerators(void)
6248 HWND hwnd = CreateWindowExA(0, "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW | WS_VISIBLE,
6249 100, 100, 200, 200, 0, 0, 0, NULL);
6258 ok(GetFocus() == hwnd, "wrong focus window %p\n", GetFocus());
6260 state = GetKeyState(VK_SHIFT);
6261 ok(!(state & 0x8000), "wrong Shift state %04x\n", state);
6262 state = GetKeyState(VK_CAPITAL);
6263 ok(state == 0, "wrong CapsLock state %04x\n", state);
6265 hAccel = LoadAccelerators(GetModuleHandleA(0), MAKEINTRESOURCE(1));
6266 assert(hAccel != 0);
6268 pump_msg_loop(hwnd, 0);
6271 trace("testing VK_N press/release\n");
6273 keybd_event('N', 0, 0, 0);
6274 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
6275 pump_msg_loop(hwnd, hAccel);
6276 ok_sequence(WmVkN, "VK_N press/release", FALSE);
6278 trace("testing Shift+VK_N press/release\n");
6280 keybd_event(VK_SHIFT, 0, 0, 0);
6281 keybd_event('N', 0, 0, 0);
6282 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
6283 keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
6284 pump_msg_loop(hwnd, hAccel);
6285 ok_sequence(WmShiftVkN, "Shift+VK_N press/release", FALSE);
6287 trace("testing Ctrl+VK_N press/release\n");
6289 keybd_event(VK_CONTROL, 0, 0, 0);
6290 keybd_event('N', 0, 0, 0);
6291 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
6292 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
6293 pump_msg_loop(hwnd, hAccel);
6294 ok_sequence(WmCtrlVkN, "Ctrl+VK_N press/release", FALSE);
6296 trace("testing Alt+VK_N press/release\n");
6298 keybd_event(VK_MENU, 0, 0, 0);
6299 keybd_event('N', 0, 0, 0);
6300 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
6301 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
6302 pump_msg_loop(hwnd, hAccel);
6303 ok_sequence(WmAltVkN, "Alt+VK_N press/release", FALSE);
6305 trace("testing Ctrl+Alt+VK_N press/release 1\n");
6307 keybd_event(VK_CONTROL, 0, 0, 0);
6308 keybd_event(VK_MENU, 0, 0, 0);
6309 keybd_event('N', 0, 0, 0);
6310 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
6311 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
6312 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
6313 pump_msg_loop(hwnd, hAccel);
6314 ok_sequence(WmCtrlAltVkN, "Ctrl+Alt+VK_N press/release 1", FALSE);
6316 ret = DestroyAcceleratorTable(hAccel);
6317 ok( ret, "DestroyAcceleratorTable error %d\n", GetLastError());
6319 hAccel = LoadAccelerators(GetModuleHandleA(0), MAKEINTRESOURCE(2));
6320 assert(hAccel != 0);
6322 trace("testing VK_N press/release\n");
6324 keybd_event('N', 0, 0, 0);
6325 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
6326 pump_msg_loop(hwnd, hAccel);
6327 ok_sequence(WmVkN, "VK_N press/release", FALSE);
6329 trace("testing Shift+VK_N press/release\n");
6331 keybd_event(VK_SHIFT, 0, 0, 0);
6332 keybd_event('N', 0, 0, 0);
6333 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
6334 keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
6335 pump_msg_loop(hwnd, hAccel);
6336 ok_sequence(WmShiftVkN, "Shift+VK_N press/release", FALSE);
6338 trace("testing Ctrl+VK_N press/release 2\n");
6340 keybd_event(VK_CONTROL, 0, 0, 0);
6341 keybd_event('N', 0, 0, 0);
6342 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
6343 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
6344 pump_msg_loop(hwnd, hAccel);
6345 ok_sequence(WmCtrlVkN_2, "Ctrl+VK_N press/release 2", FALSE);
6347 trace("testing Alt+VK_N press/release 2\n");
6349 keybd_event(VK_MENU, 0, 0, 0);
6350 keybd_event('N', 0, 0, 0);
6351 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
6352 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
6353 pump_msg_loop(hwnd, hAccel);
6354 ok_sequence(WmAltVkN_2, "Alt+VK_N press/release 2", FALSE);
6356 trace("testing Ctrl+Alt+VK_N press/release 2\n");
6358 keybd_event(VK_CONTROL, 0, 0, 0);
6359 keybd_event(VK_MENU, 0, 0, 0);
6360 keybd_event('N', 0, 0, 0);
6361 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
6362 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
6363 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
6364 pump_msg_loop(hwnd, hAccel);
6365 ok_sequence(WmCtrlAltVkN, "Ctrl+Alt+VK_N press/release 2", FALSE);
6367 trace("testing Ctrl+Shift+VK_N press/release\n");
6369 keybd_event(VK_CONTROL, 0, 0, 0);
6370 keybd_event(VK_SHIFT, 0, 0, 0);
6371 keybd_event('N', 0, 0, 0);
6372 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
6373 keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
6374 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
6375 pump_msg_loop(hwnd, hAccel);
6376 ok_sequence(WmCtrlShiftVkN, "Ctrl+Shift+VK_N press/release", FALSE);
6378 trace("testing Ctrl+Alt+Shift+VK_N press/release\n");
6380 keybd_event(VK_CONTROL, 0, 0, 0);
6381 keybd_event(VK_MENU, 0, 0, 0);
6382 keybd_event(VK_SHIFT, 0, 0, 0);
6383 keybd_event('N', 0, 0, 0);
6384 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
6385 keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
6386 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
6387 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
6388 pump_msg_loop(hwnd, hAccel);
6389 ok_sequence(WmCtrlAltShiftVkN, "Ctrl+Alt+Shift+VK_N press/release", FALSE);
6391 ret = DestroyAcceleratorTable(hAccel);
6392 ok( ret, "DestroyAcceleratorTable error %d\n", GetLastError());
6394 trace("testing Alt press/release\n");
6396 keybd_event(VK_MENU, 0, 0, 0);
6397 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
6398 keybd_event(VK_MENU, 0, 0, 0);
6399 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
6400 pump_msg_loop(hwnd, 0);
6401 /* this test doesn't pass in Wine for managed windows */
6402 ok_sequence(WmAltPressRelease, "Alt press/release", TRUE);
6404 trace("testing Alt+MouseButton press/release\n");
6405 /* first, move mouse pointer inside of the window client area */
6406 GetClientRect(hwnd, &rc);
6407 MapWindowPoints(hwnd, 0, (LPPOINT)&rc, 2);
6408 rc.left += (rc.right - rc.left)/2;
6409 rc.top += (rc.bottom - rc.top)/2;
6410 SetCursorPos(rc.left, rc.top);
6414 keybd_event(VK_MENU, 0, 0, 0);
6415 mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
6416 mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
6417 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
6418 pump_msg_loop(hwnd, 0);
6419 ok_sequence(WmAltMouseButton, "Alt+MouseButton press/release", FALSE);
6421 trace("testing VK_F1 press/release\n");
6422 keybd_event(VK_F1, 0, 0, 0);
6423 keybd_event(VK_F1, 0, KEYEVENTF_KEYUP, 0);
6424 pump_msg_loop(hwnd, 0);
6425 ok_sequence(WmF1Seq, "F1 press/release", FALSE);
6427 trace("testing VK_APPS press/release\n");
6428 keybd_event(VK_APPS, 0, 0, 0);
6429 keybd_event(VK_APPS, 0, KEYEVENTF_KEYUP, 0);
6430 pump_msg_loop(hwnd, 0);
6431 ok_sequence(WmVkAppsSeq, "VK_APPS press/release", FALSE);
6433 DestroyWindow(hwnd);
6436 /************* window procedures ********************/
6438 static LRESULT MsgCheckProc (BOOL unicode, HWND hwnd, UINT message,
6439 WPARAM wParam, LPARAM lParam)
6441 static long defwndproc_counter = 0;
6442 static long beginpaint_counter = 0;
6446 trace("%p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
6448 /* explicitly ignore WM_GETICON message */
6449 if (message == WM_GETICON) return 0;
6455 LONG style = GetWindowLongA(hwnd, GWL_STYLE);
6456 ok((BOOL)wParam == !(style & WS_DISABLED),
6457 "wrong WS_DISABLED state: %ld != %d\n", wParam, !(style & WS_DISABLED));
6461 case WM_CAPTURECHANGED:
6462 if (test_DestroyWindow_flag)
6464 DWORD style = GetWindowLongA(hwnd, GWL_STYLE);
6465 if (style & WS_CHILD)
6466 lParam = GetWindowLongPtrA(hwnd, GWLP_ID);
6467 else if (style & WS_POPUP)
6468 lParam = WND_POPUP_ID;
6470 lParam = WND_PARENT_ID;
6478 ok(!GetWindow(hwnd, GW_CHILD), "children should be unlinked at this point\n");
6479 capture = GetCapture();
6482 ok(capture == hwnd, "capture should NOT be released at this point (capture %p)\n", capture);
6483 trace("current capture %p, releasing...\n", capture);
6490 ok(pGetAncestor(hwnd, GA_PARENT) != 0, "parent should NOT be unlinked at this point\n");
6491 if (test_DestroyWindow_flag)
6493 DWORD style = GetWindowLongA(hwnd, GWL_STYLE);
6494 if (style & WS_CHILD)
6495 lParam = GetWindowLongPtrA(hwnd, GWLP_ID);
6496 else if (style & WS_POPUP)
6497 lParam = WND_POPUP_ID;
6499 lParam = WND_PARENT_ID;
6503 /* test_accelerators() depends on this */
6510 case WM_DEVICECHANGE:
6513 case WM_WINDOWPOSCHANGING:
6514 case WM_WINDOWPOSCHANGED:
6516 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
6518 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
6519 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x ",
6520 winpos->hwnd, winpos->hwndInsertAfter,
6521 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
6522 dump_winpos_flags(winpos->flags);
6524 /* Log only documented flags, win2k uses 0x1000 and 0x2000
6525 * in the high word for internal purposes
6527 wParam = winpos->flags & 0xffff;
6528 /* We are not interested in the flags that don't match under XP and Win9x */
6529 wParam &= ~(SWP_NOZORDER);
6534 msg.message = message;
6535 msg.flags = sent|wparam|lparam;
6536 if (defwndproc_counter) msg.flags |= defwinproc;
6537 if (beginpaint_counter) msg.flags |= beginpaint;
6538 msg.wParam = wParam;
6539 msg.lParam = lParam;
6542 if (message == WM_GETMINMAXINFO && (GetWindowLongA(hwnd, GWL_STYLE) & WS_CHILD))
6544 HWND parent = GetParent(hwnd);
6546 MINMAXINFO *minmax = (MINMAXINFO *)lParam;
6548 GetClientRect(parent, &rc);
6549 trace("parent %p client size = (%d x %d)\n", parent, rc.right, rc.bottom);
6550 trace("Reserved=%d,%d MaxSize=%d,%d MaxPos=%d,%d MinTrack=%d,%d MaxTrack=%d,%d\n",
6551 minmax->ptReserved.x, minmax->ptReserved.y,
6552 minmax->ptMaxSize.x, minmax->ptMaxSize.y,
6553 minmax->ptMaxPosition.x, minmax->ptMaxPosition.y,
6554 minmax->ptMinTrackSize.x, minmax->ptMinTrackSize.y,
6555 minmax->ptMaxTrackSize.x, minmax->ptMaxTrackSize.y);
6557 ok(minmax->ptMaxSize.x == rc.right, "default width of maximized child %d != %d\n",
6558 minmax->ptMaxSize.x, rc.right);
6559 ok(minmax->ptMaxSize.y == rc.bottom, "default height of maximized child %d != %d\n",
6560 minmax->ptMaxSize.y, rc.bottom);
6563 if (message == WM_PAINT)
6566 beginpaint_counter++;
6567 BeginPaint( hwnd, &ps );
6568 beginpaint_counter--;
6569 EndPaint( hwnd, &ps );
6573 defwndproc_counter++;
6574 ret = unicode ? DefWindowProcW(hwnd, message, wParam, lParam)
6575 : DefWindowProcA(hwnd, message, wParam, lParam);
6576 defwndproc_counter--;
6581 static LRESULT WINAPI MsgCheckProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
6583 return MsgCheckProc (FALSE, hwnd, message, wParam, lParam);
6586 static LRESULT WINAPI MsgCheckProcW(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
6588 return MsgCheckProc (TRUE, hwnd, message, wParam, lParam);
6591 static LRESULT WINAPI PopupMsgCheckProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
6593 static long defwndproc_counter = 0;
6597 trace("popup: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
6599 /* explicitly ignore WM_GETICON message */
6600 if (message == WM_GETICON) return 0;
6602 msg.message = message;
6603 msg.flags = sent|wparam|lparam;
6604 if (defwndproc_counter) msg.flags |= defwinproc;
6605 msg.wParam = wParam;
6606 msg.lParam = lParam;
6609 if (message == WM_CREATE)
6611 DWORD style = GetWindowLongA(hwnd, GWL_STYLE) | WS_VISIBLE;
6612 SetWindowLongA(hwnd, GWL_STYLE, style);
6615 defwndproc_counter++;
6616 ret = DefWindowProcA(hwnd, message, wParam, lParam);
6617 defwndproc_counter--;
6622 static LRESULT WINAPI ParentMsgCheckProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
6624 static long defwndproc_counter = 0;
6625 static long beginpaint_counter = 0;
6628 LPARAM logged_lParam;
6630 trace("parent: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
6632 /* explicitly ignore WM_GETICON message */
6633 if (message == WM_GETICON) return 0;
6635 logged_lParam=lParam;
6636 if (log_all_parent_messages ||
6637 message == WM_PARENTNOTIFY || message == WM_CANCELMODE ||
6638 message == WM_SETFOCUS || message == WM_KILLFOCUS ||
6639 message == WM_ENABLE || message == WM_ENTERIDLE ||
6640 message == WM_DRAWITEM ||
6641 message == WM_IME_SETCONTEXT)
6655 INT ret = GetClipBox((HDC)wParam, &rc);
6657 trace("WM_ERASEBKGND: GetClipBox()=%d, (%d,%d-%d,%d)\n",
6658 ret, rc.left, rc.top, rc.right, rc.bottom);
6662 case WM_WINDOWPOSCHANGING:
6663 case WM_WINDOWPOSCHANGED:
6665 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
6667 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
6668 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x ",
6669 winpos->hwnd, winpos->hwndInsertAfter,
6670 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
6671 dump_winpos_flags(winpos->flags);
6673 /* Log only documented flags, win2k uses 0x1000 and 0x2000
6674 * in the high word for internal purposes
6676 wParam = winpos->flags & 0xffff;
6677 /* We are not interested in the flags that don't match under XP and Win9x */
6678 wParam &= ~(SWP_NOZORDER);
6684 /* encode DRAWITEMSTRUCT into an LPARAM */
6685 DRAW_ITEM_STRUCT di;
6686 DRAWITEMSTRUCT *dis = (DRAWITEMSTRUCT *)lParam;
6688 trace("WM_DRAWITEM: type %x, ctl_id %x, item_id %x, action %x, state %x\n",
6689 dis->CtlType, dis->CtlID, dis->itemID, dis->itemAction, dis->itemState);
6691 di.u.item.type = dis->CtlType;
6692 di.u.item.ctl_id = dis->CtlID;
6693 di.u.item.item_id = dis->itemID;
6694 di.u.item.action = dis->itemAction;
6695 di.u.item.state = dis->itemState;
6697 logged_lParam = di.u.lp;
6702 msg.message = message;
6703 msg.flags = sent|parent|wparam|lparam;
6704 if (defwndproc_counter) msg.flags |= defwinproc;
6705 if (beginpaint_counter) msg.flags |= beginpaint;
6706 msg.wParam = wParam;
6707 msg.lParam = logged_lParam;
6711 if (message == WM_PAINT)
6714 beginpaint_counter++;
6715 BeginPaint( hwnd, &ps );
6716 beginpaint_counter--;
6717 EndPaint( hwnd, &ps );
6721 defwndproc_counter++;
6722 ret = DefWindowProcA(hwnd, message, wParam, lParam);
6723 defwndproc_counter--;
6728 static LRESULT WINAPI TestDlgProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
6730 static long defwndproc_counter = 0;
6734 trace("dialog: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
6736 /* explicitly ignore WM_GETICON message */
6737 if (message == WM_GETICON) return 0;
6741 DefDlgProcA(hwnd, DM_SETDEFID, 1, 0);
6742 ret = DefDlgProcA(hwnd, DM_GETDEFID, 0, 0);
6743 if (after_end_dialog)
6744 ok( ret == 0, "DM_GETDEFID should return 0 after EndDialog, got %lx\n", ret );
6746 ok(HIWORD(ret) == DC_HASDEFID, "DM_GETDEFID should return DC_HASDEFID, got %lx\n", ret);
6751 case WM_WINDOWPOSCHANGING:
6752 case WM_WINDOWPOSCHANGED:
6754 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
6756 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
6757 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x ",
6758 winpos->hwnd, winpos->hwndInsertAfter,
6759 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
6760 dump_winpos_flags(winpos->flags);
6762 /* Log only documented flags, win2k uses 0x1000 and 0x2000
6763 * in the high word for internal purposes
6765 wParam = winpos->flags & 0xffff;
6766 /* We are not interested in the flags that don't match under XP and Win9x */
6767 wParam &= ~(SWP_NOZORDER);
6772 msg.message = message;
6773 msg.flags = sent|wparam|lparam;
6774 if (defwndproc_counter) msg.flags |= defwinproc;
6775 msg.wParam = wParam;
6776 msg.lParam = lParam;
6779 defwndproc_counter++;
6780 ret = DefDlgProcA(hwnd, message, wParam, lParam);
6781 defwndproc_counter--;
6786 static void dump_winpos_flags(UINT flags)
6788 if (!winetest_debug) return;
6790 if (flags & SWP_SHOWWINDOW) printf("|SWP_SHOWWINDOW");
6791 if (flags & SWP_HIDEWINDOW) printf("|SWP_HIDEWINDOW");
6792 if (flags & SWP_NOACTIVATE) printf("|SWP_NOACTIVATE");
6793 if (flags & SWP_FRAMECHANGED) printf("|SWP_FRAMECHANGED");
6794 if (flags & SWP_NOCOPYBITS) printf("|SWP_NOCOPYBITS");
6795 if (flags & SWP_NOOWNERZORDER) printf("|SWP_NOOWNERZORDER");
6796 if (flags & SWP_NOSENDCHANGING) printf("|SWP_NOSENDCHANGING");
6797 if (flags & SWP_DEFERERASE) printf("|SWP_DEFERERASE");
6798 if (flags & SWP_ASYNCWINDOWPOS) printf("|SWP_ASYNCWINDOWPOS");
6799 if (flags & SWP_NOZORDER) printf("|SWP_NOZORDER");
6800 if (flags & SWP_NOREDRAW) printf("|SWP_NOREDRAW");
6801 if (flags & SWP_NOSIZE) printf("|SWP_NOSIZE");
6802 if (flags & SWP_NOMOVE) printf("|SWP_NOMOVE");
6803 if (flags & SWP_NOCLIENTSIZE) printf("|SWP_NOCLIENTSIZE");
6804 if (flags & SWP_NOCLIENTMOVE) printf("|SWP_NOCLIENTMOVE");
6806 #define DUMPED_FLAGS \
6812 SWP_FRAMECHANGED | \
6816 SWP_NOOWNERZORDER | \
6817 SWP_NOSENDCHANGING | \
6819 SWP_ASYNCWINDOWPOS | \
6820 SWP_NOCLIENTSIZE | \
6823 if(flags & ~DUMPED_FLAGS) printf("|0x%04x", flags & ~DUMPED_FLAGS);
6828 static LRESULT WINAPI ShowWindowProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
6830 static long defwndproc_counter = 0;
6834 /* log only specific messages we are interested in */
6837 #if 0 /* probably log these as well */
6843 trace("WM_SHOWWINDOW %ld\n", wParam);
6846 trace("WM_SIZE %ld\n", wParam);
6851 case WM_GETMINMAXINFO:
6852 trace("WM_GETMINMAXINFO\n");
6855 case WM_WINDOWPOSCHANGING:
6856 case WM_WINDOWPOSCHANGED:
6858 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
6860 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
6861 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
6862 winpos->hwnd, winpos->hwndInsertAfter,
6863 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
6865 dump_winpos_flags(winpos->flags);
6867 /* Log only documented flags, win2k uses 0x1000 and 0x2000
6868 * in the high word for internal purposes
6870 wParam = winpos->flags & 0xffff;
6871 /* We are not interested in the flags that don't match under XP and Win9x */
6872 wParam &= ~(SWP_NOZORDER);
6876 default: /* ignore */
6877 /*trace("showwindow: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);*/
6878 return DefWindowProcA(hwnd, message, wParam, lParam);
6881 msg.message = message;
6882 msg.flags = sent|wparam|lparam;
6883 if (defwndproc_counter) msg.flags |= defwinproc;
6884 msg.wParam = wParam;
6885 msg.lParam = lParam;
6888 defwndproc_counter++;
6889 ret = DefWindowProcA(hwnd, message, wParam, lParam);
6890 defwndproc_counter--;
6895 static BOOL RegisterWindowClasses(void)
6901 cls.lpfnWndProc = MsgCheckProcA;
6904 cls.hInstance = GetModuleHandleA(0);
6906 cls.hCursor = LoadCursorA(0, (LPSTR)IDC_ARROW);
6907 cls.hbrBackground = GetStockObject(WHITE_BRUSH);
6908 cls.lpszMenuName = NULL;
6909 cls.lpszClassName = "TestWindowClass";
6910 if(!RegisterClassA(&cls)) return FALSE;
6912 cls.lpfnWndProc = ShowWindowProcA;
6913 cls.lpszClassName = "ShowWindowClass";
6914 if(!RegisterClassA(&cls)) return FALSE;
6916 cls.lpfnWndProc = PopupMsgCheckProcA;
6917 cls.lpszClassName = "TestPopupClass";
6918 if(!RegisterClassA(&cls)) return FALSE;
6920 cls.lpfnWndProc = ParentMsgCheckProcA;
6921 cls.lpszClassName = "TestParentClass";
6922 if(!RegisterClassA(&cls)) return FALSE;
6924 cls.lpfnWndProc = DefWindowProcA;
6925 cls.lpszClassName = "SimpleWindowClass";
6926 if(!RegisterClassA(&cls)) return FALSE;
6928 cls.style = CS_NOCLOSE;
6929 cls.lpszClassName = "NoCloseWindowClass";
6930 if(!RegisterClassA(&cls)) return FALSE;
6932 ok(GetClassInfoA(0, "#32770", &cls), "GetClassInfo failed\n");
6934 cls.hInstance = GetModuleHandleA(0);
6935 cls.hbrBackground = 0;
6936 cls.lpfnWndProc = TestDlgProcA;
6937 cls.lpszClassName = "TestDialogClass";
6938 if(!RegisterClassA(&cls)) return FALSE;
6941 clsW.lpfnWndProc = MsgCheckProcW;
6942 clsW.cbClsExtra = 0;
6943 clsW.cbWndExtra = 0;
6944 clsW.hInstance = GetModuleHandleW(0);
6946 clsW.hCursor = LoadCursorW(0, (LPWSTR)IDC_ARROW);
6947 clsW.hbrBackground = GetStockObject(WHITE_BRUSH);
6948 clsW.lpszMenuName = NULL;
6949 clsW.lpszClassName = testWindowClassW;
6950 RegisterClassW(&clsW); /* ignore error, this fails on Win9x */
6955 static BOOL is_our_logged_class(HWND hwnd)
6959 if (GetClassNameA(hwnd, buf, sizeof(buf)))
6961 if (!lstrcmpiA(buf, "TestWindowClass") ||
6962 !lstrcmpiA(buf, "ShowWindowClass") ||
6963 !lstrcmpiA(buf, "TestParentClass") ||
6964 !lstrcmpiA(buf, "TestPopupClass") ||
6965 !lstrcmpiA(buf, "SimpleWindowClass") ||
6966 !lstrcmpiA(buf, "TestDialogClass") ||
6967 !lstrcmpiA(buf, "MDI_frame_class") ||
6968 !lstrcmpiA(buf, "MDI_client_class") ||
6969 !lstrcmpiA(buf, "MDI_child_class") ||
6970 !lstrcmpiA(buf, "my_button_class") ||
6971 !lstrcmpiA(buf, "my_edit_class") ||
6972 !lstrcmpiA(buf, "static") ||
6973 !lstrcmpiA(buf, "ListBox") ||
6974 !lstrcmpiA(buf, "ComboBox") ||
6975 !lstrcmpiA(buf, "MyDialogClass") ||
6976 !lstrcmpiA(buf, "#32770") ||
6977 !lstrcmpiA(buf, "#32768"))
6979 trace("ignoring window class %s\n", buf);
6984 static HHOOK hCBT_hook;
6985 static DWORD cbt_hook_thread_id;
6987 static LRESULT CALLBACK cbt_hook_proc(int nCode, WPARAM wParam, LPARAM lParam)
6989 static const char * const CBT_code_name[10] = {
6996 "HCBT_CLICKSKIPPED",
7000 const char *code_name = (nCode >= 0 && nCode <= HCBT_SETFOCUS) ? CBT_code_name[nCode] : "Unknown";
7003 trace("CBT: %d (%s), %08lx, %08lx\n", nCode, code_name, wParam, lParam);
7005 ok(cbt_hook_thread_id == GetCurrentThreadId(), "we didn't ask for events from other threads\n");
7007 if (nCode == HCBT_CLICKSKIPPED)
7009 /* ignore this event, XP sends it a lot when switching focus between windows */
7010 return CallNextHookEx(hCBT_hook, nCode, wParam, lParam);
7013 if (nCode == HCBT_SYSCOMMAND || nCode == HCBT_KEYSKIPPED)
7017 msg.message = nCode;
7018 msg.flags = hook|wparam|lparam;
7019 msg.wParam = wParam;
7020 msg.lParam = lParam;
7023 return CallNextHookEx(hCBT_hook, nCode, wParam, lParam);
7026 if (nCode == HCBT_DESTROYWND)
7028 if (test_DestroyWindow_flag)
7030 DWORD style = GetWindowLongA((HWND)wParam, GWL_STYLE);
7031 if (style & WS_CHILD)
7032 lParam = GetWindowLongPtrA((HWND)wParam, GWLP_ID);
7033 else if (style & WS_POPUP)
7034 lParam = WND_POPUP_ID;
7036 lParam = WND_PARENT_ID;
7040 /* Log also SetFocus(0) calls */
7041 hwnd = wParam ? (HWND)wParam : (HWND)lParam;
7043 if (is_our_logged_class(hwnd))
7047 msg.message = nCode;
7048 msg.flags = hook|wparam|lparam;
7049 msg.wParam = wParam;
7050 msg.lParam = lParam;
7053 return CallNextHookEx(hCBT_hook, nCode, wParam, lParam);
7056 static void CALLBACK win_event_proc(HWINEVENTHOOK hevent,
7064 trace("WEH:%p,event %08x,hwnd %p,obj %08x,id %08x,thread %08x,time %08x\n",
7065 hevent, event, hwnd, object_id, child_id, thread_id, event_time);
7067 ok(thread_id == GetCurrentThreadId(), "we didn't ask for events from other threads\n");
7069 /* ignore mouse cursor events */
7070 if (object_id == OBJID_CURSOR) return;
7072 if (!hwnd || is_our_logged_class(hwnd))
7076 msg.message = event;
7077 msg.flags = winevent_hook|wparam|lparam;
7078 msg.wParam = object_id;
7079 msg.lParam = child_id;
7084 static const WCHAR wszUnicode[] = {'U','n','i','c','o','d','e',0};
7085 static const WCHAR wszAnsi[] = {'U',0};
7087 static LRESULT CALLBACK MsgConversionProcW(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
7091 case CB_FINDSTRINGEXACT:
7092 trace("String: %p\n", (LPCWSTR)lParam);
7093 if (!lstrcmpW((LPCWSTR)lParam, wszUnicode))
7095 if (!lstrcmpW((LPCWSTR)lParam, wszAnsi))
7099 return DefWindowProcW(hwnd, uMsg, wParam, lParam);
7102 static const struct message WmGetTextLengthAfromW[] = {
7103 { WM_GETTEXTLENGTH, sent },
7104 { WM_GETTEXT, sent },
7108 static const WCHAR dummy_window_text[] = {'d','u','m','m','y',' ','t','e','x','t',0};
7110 /* dummy window proc for WM_GETTEXTLENGTH test */
7111 static LRESULT CALLBACK get_text_len_proc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
7115 case WM_GETTEXTLENGTH:
7116 return lstrlenW(dummy_window_text) + 37; /* some random length */
7118 lstrcpynW( (LPWSTR)lp, dummy_window_text, wp );
7119 return lstrlenW( (LPWSTR)lp );
7121 return DefWindowProcW( hwnd, msg, wp, lp );
7125 static void test_message_conversion(void)
7127 static const WCHAR wszMsgConversionClass[] =
7128 {'M','s','g','C','o','n','v','e','r','s','i','o','n','C','l','a','s','s',0};
7132 WNDPROC wndproc, newproc;
7136 cls.lpfnWndProc = MsgConversionProcW;
7139 cls.hInstance = GetModuleHandleW(NULL);
7141 cls.hCursor = LoadCursorW(NULL, (LPWSTR)IDC_ARROW);
7142 cls.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1);
7143 cls.lpszMenuName = NULL;
7144 cls.lpszClassName = wszMsgConversionClass;
7145 /* this call will fail on Win9x, but that doesn't matter as this test is
7146 * meaningless on those platforms */
7147 if(!RegisterClassW(&cls)) return;
7149 hwnd = CreateWindowExW(0, wszMsgConversionClass, NULL, WS_OVERLAPPED,
7150 100, 100, 200, 200, 0, 0, 0, NULL);
7151 ok(hwnd != NULL, "Window creation failed\n");
7155 wndproc = (WNDPROC)GetWindowLongPtrA(hwnd, GWLP_WNDPROC);
7156 lRes = CallWindowProcA(wndproc, hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
7157 ok(lRes == 0, "String should have been converted\n");
7158 lRes = CallWindowProcW(wndproc, hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
7159 ok(lRes == 1, "String shouldn't have been converted\n");
7163 wndproc = (WNDPROC)GetWindowLongPtrW(hwnd, GWLP_WNDPROC);
7164 lRes = CallWindowProcA(wndproc, hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
7165 ok(lRes == 1, "String shouldn't have been converted\n");
7166 lRes = CallWindowProcW(wndproc, hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
7167 ok(lRes == 1, "String shouldn't have been converted\n");
7169 /* Synchronous messages */
7171 lRes = SendMessageA(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
7172 ok(lRes == 0, "String should have been converted\n");
7173 lRes = SendMessageW(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
7174 ok(lRes == 1, "String shouldn't have been converted\n");
7176 /* Asynchronous messages */
7179 lRes = PostMessageA(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
7180 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
7181 "PostMessage on sync only message returned %ld, last error %d\n", lRes, GetLastError());
7183 lRes = PostMessageW(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
7184 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
7185 "PostMessage on sync only message returned %ld, last error %d\n", lRes, GetLastError());
7187 lRes = PostThreadMessageA(GetCurrentThreadId(), CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
7188 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
7189 "PosThreadtMessage on sync only message returned %ld, last error %d\n", lRes, GetLastError());
7191 lRes = PostThreadMessageW(GetCurrentThreadId(), CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
7192 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
7193 "PosThreadtMessage on sync only message returned %ld, last error %d\n", lRes, GetLastError());
7195 lRes = SendNotifyMessageA(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
7196 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
7197 "SendNotifyMessage on sync only message returned %ld, last error %d\n", lRes, GetLastError());
7199 lRes = SendNotifyMessageW(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
7200 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
7201 "SendNotifyMessage on sync only message returned %ld, last error %d\n", lRes, GetLastError());
7203 lRes = SendMessageCallbackA(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode, NULL, 0);
7204 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
7205 "SendMessageCallback on sync only message returned %ld, last error %d\n", lRes, GetLastError());
7207 lRes = SendMessageCallbackW(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode, NULL, 0);
7208 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
7209 "SendMessageCallback on sync only message returned %ld, last error %d\n", lRes, GetLastError());
7211 /* Check WM_GETTEXTLENGTH A->W behaviour, whether WM_GETTEXT is also sent or not */
7213 hwnd = CreateWindowW (testWindowClassW, wszUnicode,
7214 WS_OVERLAPPEDWINDOW,
7215 100, 100, 200, 200, 0, 0, 0, NULL);
7218 lRes = SendMessageA (hwnd, WM_GETTEXTLENGTH, 0, 0);
7219 ok_sequence(WmGetTextLengthAfromW, "ANSI WM_GETTEXTLENGTH to Unicode window", FALSE);
7220 ok( lRes == WideCharToMultiByte( CP_ACP, 0, wszUnicode, lstrlenW(wszUnicode), NULL, 0, NULL, NULL ),
7221 "got bad length %ld\n", lRes );
7224 lRes = CallWindowProcA( (WNDPROC)GetWindowLongPtrA( hwnd, GWLP_WNDPROC ),
7225 hwnd, WM_GETTEXTLENGTH, 0, 0);
7226 ok_sequence(WmGetTextLengthAfromW, "ANSI WM_GETTEXTLENGTH to Unicode window", FALSE);
7227 ok( lRes == WideCharToMultiByte( CP_ACP, 0, wszUnicode, lstrlenW(wszUnicode), NULL, 0, NULL, NULL ),
7228 "got bad length %ld\n", lRes );
7230 wndproc = (WNDPROC)SetWindowLongPtrW( hwnd, GWLP_WNDPROC, (LONG_PTR)get_text_len_proc );
7231 newproc = (WNDPROC)GetWindowLongPtrA( hwnd, GWLP_WNDPROC );
7232 lRes = CallWindowProcA( newproc, hwnd, WM_GETTEXTLENGTH, 0, 0 );
7233 ok( lRes == WideCharToMultiByte( CP_ACP, 0, dummy_window_text, lstrlenW(dummy_window_text),
7234 NULL, 0, NULL, NULL ),
7235 "got bad length %ld\n", lRes );
7237 SetWindowLongPtrW( hwnd, GWLP_WNDPROC, (LONG_PTR)wndproc ); /* restore old wnd proc */
7238 lRes = CallWindowProcA( newproc, hwnd, WM_GETTEXTLENGTH, 0, 0 );
7239 ok( lRes == WideCharToMultiByte( CP_ACP, 0, dummy_window_text, lstrlenW(dummy_window_text),
7240 NULL, 0, NULL, NULL ),
7241 "got bad length %ld\n", lRes );
7243 ret = DestroyWindow(hwnd);
7244 ok( ret, "DestroyWindow() error %d\n", GetLastError());
7254 static VOID CALLBACK tfunc(HWND hwnd, UINT uMsg, UINT_PTR id, DWORD dwTime)
7258 #define TIMER_ID 0x19
7260 static DWORD WINAPI timer_thread_proc(LPVOID x)
7262 struct timer_info *info = x;
7265 r = KillTimer(info->hWnd, 0x19);
7266 ok(r,"KillTimer failed in thread\n");
7267 r = SetTimer(info->hWnd,TIMER_ID,10000,tfunc);
7268 ok(r,"SetTimer failed in thread\n");
7269 ok(r==TIMER_ID,"SetTimer id different\n");
7270 r = SetEvent(info->handles[0]);
7271 ok(r,"SetEvent failed in thread\n");
7275 static void test_timers(void)
7277 struct timer_info info;
7280 info.hWnd = CreateWindow ("TestWindowClass", NULL,
7281 WS_OVERLAPPEDWINDOW ,
7282 CW_USEDEFAULT, CW_USEDEFAULT, 300, 300, 0,
7285 info.id = SetTimer(info.hWnd,TIMER_ID,10000,tfunc);
7286 ok(info.id, "SetTimer failed\n");
7287 ok(info.id==TIMER_ID, "SetTimer timer ID different\n");
7288 info.handles[0] = CreateEvent(NULL,0,0,NULL);
7289 info.handles[1] = CreateThread(NULL,0,timer_thread_proc,&info,0,&id);
7291 WaitForMultipleObjects(2, info.handles, FALSE, INFINITE);
7293 WaitForSingleObject(info.handles[1], INFINITE);
7295 CloseHandle(info.handles[0]);
7296 CloseHandle(info.handles[1]);
7298 ok( KillTimer(info.hWnd, TIMER_ID), "KillTimer failed\n");
7300 ok(DestroyWindow(info.hWnd), "failed to destroy window\n");
7303 static int count = 0;
7304 static VOID CALLBACK callback_count(
7314 static void test_timers_no_wnd(void)
7320 id = SetTimer(NULL, 0, 100, callback_count);
7321 ok(id != 0, "did not get id from SetTimer.\n");
7322 id2 = SetTimer(NULL, id, 200, callback_count);
7323 ok(id2 == id, "did not get same id from SetTimer when replacing (%li expected %li).\n", id2, id);
7325 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
7326 ok(count == 0, "did not get zero count as expected (%i).\n", count);
7328 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
7329 ok(count == 1, "did not get one count as expected (%i).\n", count);
7330 KillTimer(NULL, id);
7332 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
7333 ok(count == 1, "killing replaced timer did not work (%i).\n", count);
7336 /* Various win events with arbitrary parameters */
7337 static const struct message WmWinEventsSeq[] = {
7338 { EVENT_SYSTEM_SOUND, winevent_hook|wparam|lparam, OBJID_WINDOW, 0 },
7339 { EVENT_SYSTEM_ALERT, winevent_hook|wparam|lparam, OBJID_SYSMENU, 1 },
7340 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, OBJID_TITLEBAR, 2 },
7341 { EVENT_SYSTEM_MENUSTART, winevent_hook|wparam|lparam, OBJID_MENU, 3 },
7342 { EVENT_SYSTEM_MENUEND, winevent_hook|wparam|lparam, OBJID_CLIENT, 4 },
7343 { EVENT_SYSTEM_MENUPOPUPSTART, winevent_hook|wparam|lparam, OBJID_VSCROLL, 5 },
7344 { EVENT_SYSTEM_MENUPOPUPEND, winevent_hook|wparam|lparam, OBJID_HSCROLL, 6 },
7345 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, OBJID_SIZEGRIP, 7 },
7346 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, OBJID_CARET, 8 },
7347 /* our win event hook ignores OBJID_CURSOR events */
7348 /*{ EVENT_SYSTEM_MOVESIZESTART, winevent_hook|wparam|lparam, OBJID_CURSOR, 9 },*/
7349 { EVENT_SYSTEM_MOVESIZEEND, winevent_hook|wparam|lparam, OBJID_ALERT, 10 },
7350 { EVENT_SYSTEM_CONTEXTHELPSTART, winevent_hook|wparam|lparam, OBJID_SOUND, 11 },
7351 { EVENT_SYSTEM_CONTEXTHELPEND, winevent_hook|wparam|lparam, OBJID_QUERYCLASSNAMEIDX, 12 },
7352 { EVENT_SYSTEM_DRAGDROPSTART, winevent_hook|wparam|lparam, OBJID_NATIVEOM, 13 },
7353 { EVENT_SYSTEM_DRAGDROPEND, winevent_hook|wparam|lparam, OBJID_WINDOW, 0 },
7354 { EVENT_SYSTEM_DIALOGSTART, winevent_hook|wparam|lparam, OBJID_SYSMENU, 1 },
7355 { EVENT_SYSTEM_DIALOGEND, winevent_hook|wparam|lparam, OBJID_TITLEBAR, 2 },
7356 { EVENT_SYSTEM_SCROLLINGSTART, winevent_hook|wparam|lparam, OBJID_MENU, 3 },
7357 { EVENT_SYSTEM_SCROLLINGEND, winevent_hook|wparam|lparam, OBJID_CLIENT, 4 },
7358 { EVENT_SYSTEM_SWITCHSTART, winevent_hook|wparam|lparam, OBJID_VSCROLL, 5 },
7359 { EVENT_SYSTEM_SWITCHEND, winevent_hook|wparam|lparam, OBJID_HSCROLL, 6 },
7360 { EVENT_SYSTEM_MINIMIZESTART, winevent_hook|wparam|lparam, OBJID_SIZEGRIP, 7 },
7361 { EVENT_SYSTEM_MINIMIZEEND, winevent_hook|wparam|lparam, OBJID_CARET, 8 },
7364 static const struct message WmWinEventCaretSeq[] = {
7365 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1 */
7366 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1 */
7367 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 2 */
7368 { EVENT_OBJECT_NAMECHANGE, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1 */
7371 static const struct message WmWinEventCaretSeq_2[] = {
7372 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1/2 */
7373 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1/2 */
7374 { EVENT_OBJECT_NAMECHANGE, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1/2 */
7377 static const struct message WmWinEventAlertSeq[] = {
7378 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, OBJID_ALERT, 0 },
7381 static const struct message WmWinEventAlertSeq_2[] = {
7382 /* create window in the thread proc */
7383 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_WINDOW, 2 },
7384 /* our test event */
7385 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, OBJID_ALERT, 2 },
7388 static const struct message WmGlobalHookSeq_1[] = {
7389 /* create window in the thread proc */
7390 { HCBT_CREATEWND, hook|lparam, 0, 2 },
7391 /* our test events */
7392 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_PREVWINDOW, 2 },
7393 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_NEXTWINDOW, 2 },
7396 static const struct message WmGlobalHookSeq_2[] = {
7397 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_NEXTWINDOW, 0 }, /* old local hook */
7398 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_NEXTWINDOW, 2 }, /* new global hook */
7399 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_PREVWINDOW, 0 }, /* old local hook */
7400 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_PREVWINDOW, 2 }, /* new global hook */
7404 static const struct message WmMouseLLHookSeq[] = {
7405 { WM_MOUSEMOVE, hook },
7406 { WM_LBUTTONUP, hook },
7407 { WM_MOUSEMOVE, hook },
7411 static void CALLBACK win_event_global_hook_proc(HWINEVENTHOOK hevent,
7421 trace("WEH_2:%p,event %08x,hwnd %p,obj %08x,id %08x,thread %08x,time %08x\n",
7422 hevent, event, hwnd, object_id, child_id, thread_id, event_time);
7424 if (GetClassNameA(hwnd, buf, sizeof(buf)))
7426 if (!lstrcmpiA(buf, "TestWindowClass") ||
7427 !lstrcmpiA(buf, "static"))
7431 msg.message = event;
7432 msg.flags = winevent_hook|wparam|lparam;
7433 msg.wParam = object_id;
7434 msg.lParam = (thread_id == GetCurrentThreadId()) ? child_id : (child_id + 2);
7440 static HHOOK hCBT_global_hook;
7441 static DWORD cbt_global_hook_thread_id;
7443 static LRESULT CALLBACK cbt_global_hook_proc(int nCode, WPARAM wParam, LPARAM lParam)
7448 trace("CBT_2: %d, %08lx, %08lx\n", nCode, wParam, lParam);
7450 if (nCode == HCBT_SYSCOMMAND)
7454 msg.message = nCode;
7455 msg.flags = hook|wparam|lparam;
7456 msg.wParam = wParam;
7457 msg.lParam = (cbt_global_hook_thread_id == GetCurrentThreadId()) ? 1 : 2;
7460 return CallNextHookEx(hCBT_global_hook, nCode, wParam, lParam);
7462 /* WH_MOUSE_LL hook */
7463 if (nCode == HC_ACTION)
7465 MSLLHOOKSTRUCT *mhll = (MSLLHOOKSTRUCT *)lParam;
7467 /* we can't test for real mouse events */
7468 if (mhll->flags & LLMHF_INJECTED)
7472 memset (&msg, 0, sizeof (msg));
7473 msg.message = wParam;
7477 return CallNextHookEx(hCBT_global_hook, nCode, wParam, lParam);
7480 /* Log also SetFocus(0) calls */
7481 hwnd = wParam ? (HWND)wParam : (HWND)lParam;
7483 if (GetClassNameA(hwnd, buf, sizeof(buf)))
7485 if (!lstrcmpiA(buf, "TestWindowClass") ||
7486 !lstrcmpiA(buf, "static"))
7490 msg.message = nCode;
7491 msg.flags = hook|wparam|lparam;
7492 msg.wParam = wParam;
7493 msg.lParam = (cbt_global_hook_thread_id == GetCurrentThreadId()) ? 1 : 2;
7497 return CallNextHookEx(hCBT_global_hook, nCode, wParam, lParam);
7500 static DWORD WINAPI win_event_global_thread_proc(void *param)
7504 HANDLE hevent = *(HANDLE *)param;
7506 assert(pNotifyWinEvent);
7508 hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP, 0,0,0,0,0,0,0, NULL);
7510 trace("created thread window %p\n", hwnd);
7512 *(HWND *)param = hwnd;
7515 /* this event should be received only by our new hook proc,
7516 * an old one does not expect an event from another thread.
7518 pNotifyWinEvent(EVENT_OBJECT_LOCATIONCHANGE, hwnd, OBJID_ALERT, 0);
7521 while (GetMessage(&msg, 0, 0, 0))
7523 TranslateMessage(&msg);
7524 DispatchMessage(&msg);
7529 static DWORD WINAPI cbt_global_hook_thread_proc(void *param)
7533 HANDLE hevent = *(HANDLE *)param;
7536 /* these events should be received only by our new hook proc,
7537 * an old one does not expect an event from another thread.
7540 hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP, 0,0,0,0,0,0,0, NULL);
7542 trace("created thread window %p\n", hwnd);
7544 *(HWND *)param = hwnd;
7546 /* Windows doesn't like when a thread plays games with the focus,
7547 that leads to all kinds of misbehaviours and failures to activate
7548 a window. So, better keep next lines commented out.
7552 DefWindowProcA(hwnd, WM_SYSCOMMAND, SC_PREVWINDOW, 0);
7553 DefWindowProcA(hwnd, WM_SYSCOMMAND, SC_NEXTWINDOW, 0);
7557 while (GetMessage(&msg, 0, 0, 0))
7559 TranslateMessage(&msg);
7560 DispatchMessage(&msg);
7565 static DWORD WINAPI mouse_ll_global_thread_proc(void *param)
7569 HANDLE hevent = *(HANDLE *)param;
7571 hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP, 0,0,0,0,0,0,0, NULL);
7573 trace("created thread window %p\n", hwnd);
7575 *(HWND *)param = hwnd;
7579 /* Windows doesn't like when a thread plays games with the focus,
7580 * that leads to all kinds of misbehaviours and failures to activate
7581 * a window. So, better don't generate a mouse click message below.
7583 mouse_event(MOUSEEVENTF_MOVE, -1, 0, 0, 0);
7584 mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
7585 mouse_event(MOUSEEVENTF_MOVE, 1, 0, 0, 0);
7588 while (GetMessage(&msg, 0, 0, 0))
7590 TranslateMessage(&msg);
7591 DispatchMessage(&msg);
7596 static void test_winevents(void)
7602 HANDLE hthread, hevent;
7604 HWINEVENTHOOK hhook;
7605 const struct message *events = WmWinEventsSeq;
7607 hwnd = CreateWindowExA(0, "TestWindowClass", NULL,
7608 WS_OVERLAPPEDWINDOW,
7609 CW_USEDEFAULT, CW_USEDEFAULT, 300, 300, 0,
7613 /****** start of global hook test *************/
7614 hCBT_global_hook = SetWindowsHookExA(WH_CBT, cbt_global_hook_proc, GetModuleHandleA(0), 0);
7615 if (!hCBT_global_hook)
7617 ok(DestroyWindow(hwnd), "failed to destroy window\n");
7618 skip( "cannot set global hook\n" );
7622 hevent = CreateEventA(NULL, 0, 0, NULL);
7624 hwnd2 = (HWND)hevent;
7626 hthread = CreateThread(NULL, 0, cbt_global_hook_thread_proc, &hwnd2, 0, &tid);
7627 ok(hthread != NULL, "CreateThread failed, error %d\n", GetLastError());
7629 ok(WaitForSingleObject(hevent, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
7631 ok_sequence(WmGlobalHookSeq_1, "global hook 1", FALSE);
7634 /* this one should be received only by old hook proc */
7635 DefWindowProcA(hwnd, WM_SYSCOMMAND, SC_NEXTWINDOW, 0);
7636 /* this one should be received only by old hook proc */
7637 DefWindowProcA(hwnd, WM_SYSCOMMAND, SC_PREVWINDOW, 0);
7639 ok_sequence(WmGlobalHookSeq_2, "global hook 2", FALSE);
7641 ret = UnhookWindowsHookEx(hCBT_global_hook);
7642 ok( ret, "UnhookWindowsHookEx error %d\n", GetLastError());
7644 PostThreadMessageA(tid, WM_QUIT, 0, 0);
7645 ok(WaitForSingleObject(hthread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
7646 CloseHandle(hthread);
7647 CloseHandle(hevent);
7648 ok(!IsWindow(hwnd2), "window should be destroyed on thread exit\n");
7649 /****** end of global hook test *************/
7651 if (!pSetWinEventHook || !pNotifyWinEvent || !pUnhookWinEvent)
7653 ok(DestroyWindow(hwnd), "failed to destroy window\n");
7661 /* this test doesn't pass under Win9x */
7662 /* win2k ignores events with hwnd == 0 */
7663 SetLastError(0xdeadbeef);
7664 pNotifyWinEvent(events[0].message, 0, events[0].wParam, events[0].lParam);
7665 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE || /* Win2k */
7666 GetLastError() == 0xdeadbeef, /* Win9x */
7667 "unexpected error %d\n", GetLastError());
7668 ok_sequence(WmEmptySeq, "empty notify winevents", FALSE);
7671 for (i = 0; i < sizeof(WmWinEventsSeq)/sizeof(WmWinEventsSeq[0]); i++)
7672 pNotifyWinEvent(events[i].message, hwnd, events[i].wParam, events[i].lParam);
7674 ok_sequence(WmWinEventsSeq, "notify winevents", FALSE);
7676 /****** start of event filtering test *************/
7677 hhook = (HWINEVENTHOOK)pSetWinEventHook(
7678 EVENT_OBJECT_SHOW, /* 0x8002 */
7679 EVENT_OBJECT_LOCATIONCHANGE, /* 0x800B */
7680 GetModuleHandleA(0), win_event_global_hook_proc,
7681 GetCurrentProcessId(), 0,
7682 WINEVENT_INCONTEXT);
7683 ok(hhook != 0, "SetWinEventHook error %d\n", GetLastError());
7685 hevent = CreateEventA(NULL, 0, 0, NULL);
7687 hwnd2 = (HWND)hevent;
7689 hthread = CreateThread(NULL, 0, win_event_global_thread_proc, &hwnd2, 0, &tid);
7690 ok(hthread != NULL, "CreateThread failed, error %d\n", GetLastError());
7692 ok(WaitForSingleObject(hevent, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
7694 ok_sequence(WmWinEventAlertSeq, "alert winevent", FALSE);
7697 /* this one should be received only by old hook proc */
7698 pNotifyWinEvent(EVENT_OBJECT_CREATE, hwnd, OBJID_CARET, 0); /* 0x8000 */
7699 pNotifyWinEvent(EVENT_OBJECT_SHOW, hwnd, OBJID_CARET, 0); /* 0x8002 */
7700 /* this one should be received only by old hook proc */
7701 pNotifyWinEvent(EVENT_OBJECT_NAMECHANGE, hwnd, OBJID_CARET, 0); /* 0x800C */
7703 ok_sequence(WmWinEventCaretSeq, "caret winevent", FALSE);
7705 ret = pUnhookWinEvent(hhook);
7706 ok( ret, "UnhookWinEvent error %d\n", GetLastError());
7708 PostThreadMessageA(tid, WM_QUIT, 0, 0);
7709 ok(WaitForSingleObject(hthread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
7710 CloseHandle(hthread);
7711 CloseHandle(hevent);
7712 ok(!IsWindow(hwnd2), "window should be destroyed on thread exit\n");
7713 /****** end of event filtering test *************/
7715 /****** start of out of context event test *************/
7716 hhook = (HWINEVENTHOOK)pSetWinEventHook(
7717 EVENT_MIN, EVENT_MAX,
7718 0, win_event_global_hook_proc,
7719 GetCurrentProcessId(), 0,
7720 WINEVENT_OUTOFCONTEXT);
7721 ok(hhook != 0, "SetWinEventHook error %d\n", GetLastError());
7723 hevent = CreateEventA(NULL, 0, 0, NULL);
7725 hwnd2 = (HWND)hevent;
7729 hthread = CreateThread(NULL, 0, win_event_global_thread_proc, &hwnd2, 0, &tid);
7730 ok(hthread != NULL, "CreateThread failed, error %d\n", GetLastError());
7732 ok(WaitForSingleObject(hevent, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
7734 ok_sequence(WmEmptySeq, "empty notify winevents", FALSE);
7735 /* process pending winevent messages */
7736 ok(!PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE), "msg queue should be empty\n");
7737 ok_sequence(WmWinEventAlertSeq_2, "alert winevent for out of context proc", FALSE);
7740 /* this one should be received only by old hook proc */
7741 pNotifyWinEvent(EVENT_OBJECT_CREATE, hwnd, OBJID_CARET, 0); /* 0x8000 */
7742 pNotifyWinEvent(EVENT_OBJECT_SHOW, hwnd, OBJID_CARET, 0); /* 0x8002 */
7743 /* this one should be received only by old hook proc */
7744 pNotifyWinEvent(EVENT_OBJECT_NAMECHANGE, hwnd, OBJID_CARET, 0); /* 0x800C */
7746 ok_sequence(WmWinEventCaretSeq_2, "caret winevent for incontext proc", FALSE);
7747 /* process pending winevent messages */
7748 ok(!PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE), "msg queue should be empty\n");
7749 ok_sequence(WmWinEventCaretSeq_2, "caret winevent for out of context proc", FALSE);
7751 ret = pUnhookWinEvent(hhook);
7752 ok( ret, "UnhookWinEvent error %d\n", GetLastError());
7754 PostThreadMessageA(tid, WM_QUIT, 0, 0);
7755 ok(WaitForSingleObject(hthread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
7756 CloseHandle(hthread);
7757 CloseHandle(hevent);
7758 ok(!IsWindow(hwnd2), "window should be destroyed on thread exit\n");
7759 /****** end of out of context event test *************/
7761 /****** start of MOUSE_LL hook test *************/
7762 hCBT_global_hook = SetWindowsHookExA(WH_MOUSE_LL, cbt_global_hook_proc, GetModuleHandleA(0), 0);
7763 /* WH_MOUSE_LL is not supported on Win9x platforms */
7764 if (!hCBT_global_hook)
7766 trace("Skipping WH_MOUSE_LL test on this platform\n");
7767 goto skip_mouse_ll_hook_test;
7770 hevent = CreateEventA(NULL, 0, 0, NULL);
7772 hwnd2 = (HWND)hevent;
7774 hthread = CreateThread(NULL, 0, mouse_ll_global_thread_proc, &hwnd2, 0, &tid);
7775 ok(hthread != NULL, "CreateThread failed, error %d\n", GetLastError());
7777 while (WaitForSingleObject(hevent, 100) == WAIT_TIMEOUT)
7778 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
7780 ok_sequence(WmMouseLLHookSeq, "MOUSE_LL hook other thread", FALSE);
7783 mouse_event(MOUSEEVENTF_MOVE, -1, 0, 0, 0);
7784 mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
7785 mouse_event(MOUSEEVENTF_MOVE, 1, 0, 0, 0);
7787 ok_sequence(WmMouseLLHookSeq, "MOUSE_LL hook same thread", FALSE);
7789 ret = UnhookWindowsHookEx(hCBT_global_hook);
7790 ok( ret, "UnhookWindowsHookEx error %d\n", GetLastError());
7792 PostThreadMessageA(tid, WM_QUIT, 0, 0);
7793 ok(WaitForSingleObject(hthread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
7794 CloseHandle(hthread);
7795 CloseHandle(hevent);
7796 ok(!IsWindow(hwnd2), "window should be destroyed on thread exit\n");
7797 /****** end of MOUSE_LL hook test *************/
7798 skip_mouse_ll_hook_test:
7800 ok(DestroyWindow(hwnd), "failed to destroy window\n");
7803 static void test_set_hook(void)
7807 HWINEVENTHOOK hwinevent_hook;
7809 hhook = SetWindowsHookExA(WH_CBT, cbt_hook_proc, GetModuleHandleA(0), GetCurrentThreadId());
7810 ok(hhook != 0, "local hook does not require hModule set to 0\n");
7811 UnhookWindowsHookEx(hhook);
7815 /* this test doesn't pass under Win9x: BUG! */
7816 SetLastError(0xdeadbeef);
7817 hhook = SetWindowsHookExA(WH_CBT, cbt_hook_proc, 0, 0);
7818 ok(!hhook, "global hook requires hModule != 0\n");
7819 ok(GetLastError() == ERROR_HOOK_NEEDS_HMOD, "unexpected error %d\n", GetLastError());
7822 SetLastError(0xdeadbeef);
7823 hhook = SetWindowsHookExA(WH_CBT, 0, GetModuleHandleA(0), GetCurrentThreadId());
7824 ok(!hhook, "SetWinEventHook with invalid proc should fail\n");
7825 ok(GetLastError() == ERROR_INVALID_FILTER_PROC || /* Win2k */
7826 GetLastError() == 0xdeadbeef, /* Win9x */
7827 "unexpected error %d\n", GetLastError());
7829 SetLastError(0xdeadbeef);
7830 ok(!UnhookWindowsHookEx((HHOOK)0xdeadbeef), "UnhookWindowsHookEx succeeded\n");
7831 ok(GetLastError() == ERROR_INVALID_HOOK_HANDLE || /* Win2k */
7832 GetLastError() == 0xdeadbeef, /* Win9x */
7833 "unexpected error %d\n", GetLastError());
7835 if (!pSetWinEventHook || !pUnhookWinEvent) return;
7837 /* even process local incontext hooks require hmodule */
7838 SetLastError(0xdeadbeef);
7839 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(EVENT_MIN, EVENT_MAX,
7840 0, win_event_proc, GetCurrentProcessId(), 0, WINEVENT_INCONTEXT);
7841 ok(!hwinevent_hook, "WINEVENT_INCONTEXT requires hModule != 0\n");
7842 ok(GetLastError() == ERROR_HOOK_NEEDS_HMOD || /* Win2k */
7843 GetLastError() == 0xdeadbeef, /* Win9x */
7844 "unexpected error %d\n", GetLastError());
7846 /* even thread local incontext hooks require hmodule */
7847 SetLastError(0xdeadbeef);
7848 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(EVENT_MIN, EVENT_MAX,
7849 0, win_event_proc, GetCurrentProcessId(), GetCurrentThreadId(), WINEVENT_INCONTEXT);
7850 ok(!hwinevent_hook, "WINEVENT_INCONTEXT requires hModule != 0\n");
7851 ok(GetLastError() == ERROR_HOOK_NEEDS_HMOD || /* Win2k */
7852 GetLastError() == 0xdeadbeef, /* Win9x */
7853 "unexpected error %d\n", GetLastError());
7857 /* these 3 tests don't pass under Win9x */
7858 SetLastError(0xdeadbeef);
7859 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(1, 0,
7860 0, win_event_proc, GetCurrentProcessId(), 0, WINEVENT_OUTOFCONTEXT);
7861 ok(!hwinevent_hook, "SetWinEventHook with invalid event range should fail\n");
7862 ok(GetLastError() == ERROR_INVALID_HOOK_FILTER, "unexpected error %d\n", GetLastError());
7864 SetLastError(0xdeadbeef);
7865 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(-1, 1,
7866 0, win_event_proc, GetCurrentProcessId(), 0, WINEVENT_OUTOFCONTEXT);
7867 ok(!hwinevent_hook, "SetWinEventHook with invalid event range should fail\n");
7868 ok(GetLastError() == ERROR_INVALID_HOOK_FILTER, "unexpected error %d\n", GetLastError());
7870 SetLastError(0xdeadbeef);
7871 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(EVENT_MIN, EVENT_MAX,
7872 0, win_event_proc, 0, 0xdeadbeef, WINEVENT_OUTOFCONTEXT);
7873 ok(!hwinevent_hook, "SetWinEventHook with invalid tid should fail\n");
7874 ok(GetLastError() == ERROR_INVALID_THREAD_ID, "unexpected error %d\n", GetLastError());
7877 SetLastError(0xdeadbeef);
7878 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(0, 0,
7879 0, win_event_proc, GetCurrentProcessId(), 0, WINEVENT_OUTOFCONTEXT);
7880 ok(hwinevent_hook != 0, "SetWinEventHook error %d\n", GetLastError());
7881 ok(GetLastError() == 0xdeadbeef, "unexpected error %d\n", GetLastError());
7882 ret = pUnhookWinEvent(hwinevent_hook);
7883 ok( ret, "UnhookWinEvent error %d\n", GetLastError());
7886 /* This call succeeds under win2k SP4, but fails under Wine.
7887 Does win2k test/use passed process id? */
7888 SetLastError(0xdeadbeef);
7889 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(EVENT_MIN, EVENT_MAX,
7890 0, win_event_proc, 0xdeadbeef, 0, WINEVENT_OUTOFCONTEXT);
7891 ok(hwinevent_hook != 0, "SetWinEventHook error %d\n", GetLastError());
7892 ok(GetLastError() == 0xdeadbeef, "unexpected error %d\n", GetLastError());
7893 ret = pUnhookWinEvent(hwinevent_hook);
7894 ok( ret, "UnhookWinEvent error %d\n", GetLastError());
7897 SetLastError(0xdeadbeef);
7898 ok(!pUnhookWinEvent((HWINEVENTHOOK)0xdeadbeef), "UnhookWinEvent succeeded\n");
7899 ok(GetLastError() == ERROR_INVALID_HANDLE || /* Win2k */
7900 GetLastError() == 0xdeadbeef, /* Win9x */
7901 "unexpected error %d\n", GetLastError());
7904 static const struct message ScrollWindowPaint1[] = {
7906 { WM_ERASEBKGND, sent|beginpaint },
7910 static const struct message ScrollWindowPaint2[] = {
7915 static void test_scrollwindowex(void)
7918 RECT rect={0,0,130,130};
7920 hwnd = CreateWindowExA(0, "TestWindowClass", "Test Scroll",
7921 WS_VISIBLE|WS_OVERLAPPEDWINDOW,
7922 100, 100, 200, 200, 0, 0, 0, NULL);
7923 ok (hwnd != 0, "Failed to create overlapped window\n");
7924 hchild = CreateWindowExA(0, "TestWindowClass", "Test child",
7925 WS_VISIBLE|WS_CAPTION|WS_CHILD,
7926 10, 10, 150, 150, hwnd, 0, 0, NULL);
7927 ok (hchild != 0, "Failed to create child\n");
7932 /* scroll without the child window */
7933 trace("start scroll\n");
7934 ScrollWindowEx( hwnd, 10, 10, &rect, NULL, NULL, NULL,
7935 SW_ERASE|SW_INVALIDATE);
7936 ok_sequence(WmEmptySeq, "ScrollWindowEx", 0);
7937 trace("end scroll\n");
7940 ok_sequence(ScrollWindowPaint1, "ScrollWindowEx", 0);
7944 /* Now without the SW_ERASE flag */
7945 trace("start scroll\n");
7946 ScrollWindowEx( hwnd, 10, 10, &rect, NULL, NULL, NULL, SW_INVALIDATE);
7947 ok_sequence(WmEmptySeq, "ScrollWindowEx", 0);
7948 trace("end scroll\n");
7951 ok_sequence(ScrollWindowPaint2, "ScrollWindowEx", 0);
7955 /* now scroll the child window as well */
7956 trace("start scroll\n");
7957 ScrollWindowEx( hwnd, 10, 10, &rect, NULL, NULL, NULL,
7958 SW_SCROLLCHILDREN|SW_ERASE|SW_INVALIDATE);
7959 todo_wine { /* wine sends WM_POSCHANGING, WM_POSCHANGED messages */
7960 /* windows sometimes a WM_MOVE */
7961 ok_sequence(WmEmptySeq, "ScrollWindowEx", 0);
7963 trace("end scroll\n");
7966 ok_sequence(ScrollWindowPaint1, "ScrollWindowEx", 0);
7970 /* now scroll with ScrollWindow() */
7971 trace("start scroll with ScrollWindow\n");
7972 ScrollWindow( hwnd, 5, 5, NULL, NULL);
7973 trace("end scroll\n");
7976 ok_sequence(ScrollWindowPaint1, "ScrollWindow", 0);
7978 ok(DestroyWindow(hchild), "failed to destroy window\n");
7979 ok(DestroyWindow(hwnd), "failed to destroy window\n");
7983 static const struct message destroy_window_with_children[] = {
7984 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 }, /* popup */
7985 { HCBT_DESTROYWND, hook|lparam, 0, WND_PARENT_ID }, /* parent */
7986 { 0x0090, sent|optional },
7987 { HCBT_DESTROYWND, hook|lparam, 0, WND_POPUP_ID }, /* popup */
7988 { 0x0090, sent|optional },
7989 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 }, /* popup */
7990 { WM_DESTROY, sent|wparam|lparam, 0, WND_POPUP_ID }, /* popup */
7991 { WM_CAPTURECHANGED, sent|wparam|lparam, 0, WND_POPUP_ID }, /* popup */
7992 { WM_NCDESTROY, sent|wparam|lparam, 0, WND_POPUP_ID }, /* popup */
7993 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 }, /* parent */
7994 { WM_DESTROY, sent|wparam|lparam, 0, WND_PARENT_ID }, /* parent */
7995 { WM_DESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 2 }, /* child2 */
7996 { WM_DESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 1 }, /* child1 */
7997 { WM_DESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 3 }, /* child3 */
7998 { WM_NCDESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 2 }, /* child2 */
7999 { WM_NCDESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 3 }, /* child3 */
8000 { WM_NCDESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 1 }, /* child1 */
8001 { WM_NCDESTROY, sent|wparam|lparam, 0, WND_PARENT_ID }, /* parent */
8005 static void test_DestroyWindow(void)
8008 HWND parent, child1, child2, child3, child4, test;
8009 UINT child_id = WND_CHILD_ID + 1;
8011 parent = CreateWindowExA(0, "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW,
8012 100, 100, 200, 200, 0, 0, 0, NULL);
8013 assert(parent != 0);
8014 child1 = CreateWindowExA(0, "TestWindowClass", NULL, WS_CHILD,
8015 0, 0, 50, 50, parent, (HMENU)child_id++, 0, NULL);
8016 assert(child1 != 0);
8017 child2 = CreateWindowExA(0, "TestWindowClass", NULL, WS_CHILD,
8018 0, 0, 50, 50, GetDesktopWindow(), (HMENU)child_id++, 0, NULL);
8019 assert(child2 != 0);
8020 child3 = CreateWindowExA(0, "TestWindowClass", NULL, WS_CHILD,
8021 0, 0, 50, 50, child1, (HMENU)child_id++, 0, NULL);
8022 assert(child3 != 0);
8023 child4 = CreateWindowExA(0, "TestWindowClass", NULL, WS_POPUP,
8024 0, 0, 50, 50, parent, 0, 0, NULL);
8025 assert(child4 != 0);
8027 /* test owner/parent of child2 */
8028 test = GetParent(child2);
8029 ok(test == GetDesktopWindow(), "wrong parent %p\n", test);
8030 ok(!IsChild(parent, child2), "wrong parent/child %p/%p\n", parent, child2);
8032 test = pGetAncestor(child2, GA_PARENT);
8033 ok(test == GetDesktopWindow(), "wrong parent %p\n", test);
8035 test = GetWindow(child2, GW_OWNER);
8036 ok(!test, "wrong owner %p\n", test);
8038 test = SetParent(child2, parent);
8039 ok(test == GetDesktopWindow(), "wrong old parent %p\n", test);
8041 /* test owner/parent of the parent */
8042 test = GetParent(parent);
8043 ok(!test, "wrong parent %p\n", test);
8044 ok(!IsChild(GetDesktopWindow(), parent), "wrong parent/child %p/%p\n", GetDesktopWindow(), parent);
8046 test = pGetAncestor(parent, GA_PARENT);
8047 ok(test == GetDesktopWindow(), "wrong parent %p\n", test);
8049 test = GetWindow(parent, GW_OWNER);
8050 ok(!test, "wrong owner %p\n", test);
8052 /* test owner/parent of child1 */
8053 test = GetParent(child1);
8054 ok(test == parent, "wrong parent %p\n", test);
8055 ok(IsChild(parent, child1), "wrong parent/child %p/%p\n", parent, child1);
8057 test = pGetAncestor(child1, GA_PARENT);
8058 ok(test == parent, "wrong parent %p\n", test);
8060 test = GetWindow(child1, GW_OWNER);
8061 ok(!test, "wrong owner %p\n", test);
8063 /* test owner/parent of child2 */
8064 test = GetParent(child2);
8065 ok(test == parent, "wrong parent %p\n", test);
8066 ok(IsChild(parent, child2), "wrong parent/child %p/%p\n", parent, child2);
8068 test = pGetAncestor(child2, GA_PARENT);
8069 ok(test == parent, "wrong parent %p\n", test);
8071 test = GetWindow(child2, GW_OWNER);
8072 ok(!test, "wrong owner %p\n", test);
8074 /* test owner/parent of child3 */
8075 test = GetParent(child3);
8076 ok(test == child1, "wrong parent %p\n", test);
8077 ok(IsChild(parent, child3), "wrong parent/child %p/%p\n", parent, child3);
8079 test = pGetAncestor(child3, GA_PARENT);
8080 ok(test == child1, "wrong parent %p\n", test);
8082 test = GetWindow(child3, GW_OWNER);
8083 ok(!test, "wrong owner %p\n", test);
8085 /* test owner/parent of child4 */
8086 test = GetParent(child4);
8087 ok(test == parent, "wrong parent %p\n", test);
8088 ok(!IsChild(parent, child4), "wrong parent/child %p/%p\n", parent, child4);
8090 test = pGetAncestor(child4, GA_PARENT);
8091 ok(test == GetDesktopWindow(), "wrong parent %p\n", test);
8093 test = GetWindow(child4, GW_OWNER);
8094 ok(test == parent, "wrong owner %p\n", test);
8098 trace("parent %p, child1 %p, child2 %p, child3 %p, child4 %p\n",
8099 parent, child1, child2, child3, child4);
8102 test = GetCapture();
8103 ok(test == child4, "wrong capture window %p\n", test);
8105 test_DestroyWindow_flag = TRUE;
8106 ret = DestroyWindow(parent);
8107 ok( ret, "DestroyWindow() error %d\n", GetLastError());
8108 test_DestroyWindow_flag = FALSE;
8109 ok_sequence(destroy_window_with_children, "destroy window with children", 0);
8111 ok(!IsWindow(parent), "parent still exists\n");
8112 ok(!IsWindow(child1), "child1 still exists\n");
8113 ok(!IsWindow(child2), "child2 still exists\n");
8114 ok(!IsWindow(child3), "child3 still exists\n");
8115 ok(!IsWindow(child4), "child4 still exists\n");
8117 test = GetCapture();
8118 ok(!test, "wrong capture window %p\n", test);
8122 static const struct message WmDispatchPaint[] = {
8123 { WM_NCPAINT, sent },
8124 { WM_GETTEXT, sent|defwinproc|optional },
8125 { WM_GETTEXT, sent|defwinproc|optional },
8126 { WM_ERASEBKGND, sent },
8130 static LRESULT WINAPI DispatchMessageCheckProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
8132 if (message == WM_PAINT) return 0;
8133 return MsgCheckProcA( hwnd, message, wParam, lParam );
8136 static void test_DispatchMessage(void)
8141 HWND hwnd = CreateWindowA( "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW,
8142 100, 100, 200, 200, 0, 0, 0, NULL);
8143 ShowWindow( hwnd, SW_SHOW );
8144 UpdateWindow( hwnd );
8147 SetWindowLongPtrA( hwnd, GWLP_WNDPROC, (LONG_PTR)DispatchMessageCheckProc );
8149 SetRect( &rect, -5, -5, 5, 5 );
8150 RedrawWindow( hwnd, &rect, 0, RDW_INVALIDATE|RDW_ERASE|RDW_FRAME );
8152 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE ))
8154 if (msg.message != WM_PAINT) DispatchMessage( &msg );
8158 DispatchMessage( &msg );
8159 /* DispatchMessage will send WM_NCPAINT if non client area is still invalid after WM_PAINT */
8160 if (!count) ok_sequence( WmDispatchPaint, "WmDispatchPaint", FALSE );
8161 else ok_sequence( WmEmptySeq, "WmEmpty", FALSE );
8162 if (++count > 10) break;
8165 ok( msg.message == WM_PAINT && count > 10, "WM_PAINT messages stopped\n" );
8167 trace("now without DispatchMessage\n");
8169 RedrawWindow( hwnd, &rect, 0, RDW_INVALIDATE|RDW_ERASE|RDW_FRAME );
8171 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE ))
8173 if (msg.message != WM_PAINT) DispatchMessage( &msg );
8176 HRGN hrgn = CreateRectRgn( 0, 0, 0, 0 );
8178 /* this will send WM_NCCPAINT just like DispatchMessage does */
8179 GetUpdateRgn( hwnd, hrgn, TRUE );
8180 ok_sequence( WmDispatchPaint, "WmDispatchPaint", FALSE );
8181 DeleteObject( hrgn );
8182 GetClientRect( hwnd, &rect );
8183 ValidateRect( hwnd, &rect ); /* this will stop WM_PAINTs */
8184 ok( !count, "Got multiple WM_PAINTs\n" );
8185 if (++count > 10) break;
8188 DestroyWindow(hwnd);
8192 static const struct message WmUser[] = {
8204 static DWORD CALLBACK send_msg_thread( LPVOID arg )
8206 struct sendmsg_info *info = arg;
8207 info->ret = SendMessageTimeoutA( info->hwnd, WM_USER, 0, 0, 0, info->timeout, NULL );
8208 if (!info->ret) ok( GetLastError() == ERROR_TIMEOUT, "unexpected error %d\n", GetLastError());
8212 static void wait_for_thread( HANDLE thread )
8214 while (MsgWaitForMultipleObjects(1, &thread, FALSE, INFINITE, QS_SENDMESSAGE) != WAIT_OBJECT_0)
8217 while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage(&msg);
8221 static LRESULT WINAPI send_msg_delay_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
8223 if (message == WM_USER) Sleep(200);
8224 return MsgCheckProcA( hwnd, message, wParam, lParam );
8227 static void test_SendMessageTimeout(void)
8230 struct sendmsg_info info;
8233 info.hwnd = CreateWindowA( "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW,
8234 100, 100, 200, 200, 0, 0, 0, NULL);
8238 info.timeout = 1000;
8239 info.ret = 0xdeadbeef;
8240 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid );
8241 wait_for_thread( thread );
8242 CloseHandle( thread );
8243 ok( info.ret == 1, "SendMessageTimeout failed\n" );
8244 ok_sequence( WmUser, "WmUser", FALSE );
8247 info.ret = 0xdeadbeef;
8248 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid );
8249 Sleep(100); /* SendMessageTimeout should time out here */
8250 wait_for_thread( thread );
8251 CloseHandle( thread );
8252 ok( info.ret == 0, "SendMessageTimeout succeeded\n" );
8253 ok_sequence( WmEmptySeq, "WmEmptySeq", FALSE );
8255 /* 0 means infinite timeout */
8257 info.ret = 0xdeadbeef;
8258 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid );
8260 wait_for_thread( thread );
8261 CloseHandle( thread );
8262 ok( info.ret == 1, "SendMessageTimeout failed\n" );
8263 ok_sequence( WmUser, "WmUser", FALSE );
8265 /* timeout is treated as signed despite the prototype */
8266 info.timeout = 0x7fffffff;
8267 info.ret = 0xdeadbeef;
8268 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid );
8270 wait_for_thread( thread );
8271 CloseHandle( thread );
8272 ok( info.ret == 1, "SendMessageTimeout failed\n" );
8273 ok_sequence( WmUser, "WmUser", FALSE );
8275 info.timeout = 0x80000000;
8276 info.ret = 0xdeadbeef;
8277 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid );
8279 wait_for_thread( thread );
8280 CloseHandle( thread );
8281 ok( info.ret == 0, "SendMessageTimeout succeeded\n" );
8282 ok_sequence( WmEmptySeq, "WmEmptySeq", FALSE );
8284 /* now check for timeout during message processing */
8285 SetWindowLongPtrA( info.hwnd, GWLP_WNDPROC, (LONG_PTR)send_msg_delay_proc );
8287 info.ret = 0xdeadbeef;
8288 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid );
8289 wait_for_thread( thread );
8290 CloseHandle( thread );
8291 /* we should time out but still get the message */
8292 ok( info.ret == 0, "SendMessageTimeout failed\n" );
8293 ok_sequence( WmUser, "WmUser", FALSE );
8295 DestroyWindow( info.hwnd );
8299 /****************** edit message test *************************/
8300 #define ID_EDIT 0x1234
8301 static const struct message sl_edit_setfocus[] =
8303 { HCBT_SETFOCUS, hook },
8304 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
8305 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
8306 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
8307 { WM_SETFOCUS, sent|wparam, 0 },
8308 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 10 },
8309 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 15 },
8310 { WM_CTLCOLOREDIT, sent|parent },
8311 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 11 },
8312 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8313 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8314 { WM_COMMAND, sent|parent|wparam, MAKEWPARAM(ID_EDIT, EN_SETFOCUS) },
8317 static const struct message ml_edit_setfocus[] =
8319 { HCBT_SETFOCUS, hook },
8320 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
8321 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
8322 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
8323 { WM_SETFOCUS, sent|wparam, 0 },
8324 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 10 },
8325 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 11 },
8326 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8327 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8328 { WM_COMMAND, sent|parent|wparam, MAKEWPARAM(ID_EDIT, EN_SETFOCUS) },
8331 static const struct message sl_edit_killfocus[] =
8333 { HCBT_SETFOCUS, hook },
8334 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
8335 { WM_KILLFOCUS, sent|wparam, 0 },
8336 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8337 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8338 { WM_COMMAND, sent|parent|wparam, MAKEWPARAM(ID_EDIT, EN_KILLFOCUS) },
8339 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
8340 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 1 },
8343 static const struct message sl_edit_lbutton_dblclk[] =
8345 { WM_LBUTTONDBLCLK, sent },
8346 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
8349 static const struct message sl_edit_lbutton_down[] =
8351 { WM_LBUTTONDOWN, sent|wparam|lparam, 0, 0 },
8352 { HCBT_SETFOCUS, hook },
8353 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
8354 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
8355 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
8356 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
8357 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 10 },
8358 { WM_CTLCOLOREDIT, sent|parent },
8359 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 11 },
8360 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8361 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8362 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8363 { WM_COMMAND, sent|parent|wparam, MAKEWPARAM(ID_EDIT, EN_SETFOCUS) },
8364 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
8365 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8366 { WM_CTLCOLOREDIT, sent|parent|optional },
8367 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 11 },
8368 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8369 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8372 static const struct message ml_edit_lbutton_down[] =
8374 { WM_LBUTTONDOWN, sent|wparam|lparam, 0, 0 },
8375 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
8376 { HCBT_SETFOCUS, hook },
8377 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
8378 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
8379 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
8380 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
8381 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 10 },
8382 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 11 },
8383 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8384 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8385 { WM_COMMAND, sent|parent|wparam, MAKEWPARAM(ID_EDIT, EN_SETFOCUS) },
8388 static const struct message sl_edit_lbutton_up[] =
8390 { WM_LBUTTONUP, sent|wparam|lparam, 0, 0 },
8391 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8392 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, 0, 0 },
8393 { WM_CAPTURECHANGED, sent|defwinproc },
8394 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8397 static const struct message ml_edit_lbutton_up[] =
8399 { WM_LBUTTONUP, sent|wparam|lparam, 0, 0 },
8400 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, 0, 0 },
8401 { WM_CAPTURECHANGED, sent|defwinproc },
8405 static WNDPROC old_edit_proc;
8407 static LRESULT CALLBACK edit_hook_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
8409 static long defwndproc_counter = 0;
8413 trace("edit: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
8415 /* explicitly ignore WM_GETICON message */
8416 if (message == WM_GETICON) return 0;
8418 msg.message = message;
8419 msg.flags = sent|wparam|lparam;
8420 if (defwndproc_counter) msg.flags |= defwinproc;
8421 msg.wParam = wParam;
8422 msg.lParam = lParam;
8425 defwndproc_counter++;
8426 ret = CallWindowProcA(old_edit_proc, hwnd, message, wParam, lParam);
8427 defwndproc_counter--;
8432 static void subclass_edit(void)
8436 if (!GetClassInfoA(0, "edit", &cls)) assert(0);
8438 old_edit_proc = cls.lpfnWndProc;
8440 cls.hInstance = GetModuleHandle(0);
8441 cls.lpfnWndProc = edit_hook_proc;
8442 cls.lpszClassName = "my_edit_class";
8443 UnregisterClass(cls.lpszClassName, cls.hInstance);
8444 if (!RegisterClassA(&cls)) assert(0);
8447 static void test_edit_messages(void)
8453 log_all_parent_messages++;
8455 parent = CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
8456 100, 100, 200, 200, 0, 0, 0, NULL);
8457 ok (parent != 0, "Failed to create parent window\n");
8459 /* test single line edit */
8460 hwnd = CreateWindowExA(0, "my_edit_class", "test", WS_CHILD,
8461 0, 0, 80, 20, parent, (HMENU)ID_EDIT, 0, NULL);
8462 ok(hwnd != 0, "Failed to create edit window\n");
8464 dlg_code = SendMessageA(hwnd, WM_GETDLGCODE, 0, 0);
8465 ok(dlg_code == (DLGC_WANTCHARS|DLGC_HASSETSEL|DLGC_WANTARROWS), "wrong dlg_code %08x\n", dlg_code);
8467 ShowWindow(hwnd, SW_SHOW);
8473 ok_sequence(sl_edit_setfocus, "SetFocus(hwnd) on an edit", FALSE);
8476 ok_sequence(sl_edit_killfocus, "SetFocus(0) on an edit", FALSE);
8482 SendMessageA(hwnd, WM_LBUTTONDBLCLK, 0, 0);
8483 ok_sequence(sl_edit_lbutton_dblclk, "WM_LBUTTONDBLCLK on an edit", FALSE);
8489 SendMessageA(hwnd, WM_LBUTTONDOWN, 0, 0);
8490 ok_sequence(sl_edit_lbutton_down, "WM_LBUTTONDOWN on an edit", FALSE);
8492 SendMessageA(hwnd, WM_LBUTTONUP, 0, 0);
8493 ok_sequence(sl_edit_lbutton_up, "WM_LBUTTONUP on an edit", FALSE);
8495 DestroyWindow(hwnd);
8497 /* test multiline edit */
8498 hwnd = CreateWindowExA(0, "my_edit_class", "test", WS_CHILD | ES_MULTILINE,
8499 0, 0, 80, 20, parent, (HMENU)ID_EDIT, 0, NULL);
8500 ok(hwnd != 0, "Failed to create edit window\n");
8502 dlg_code = SendMessageA(hwnd, WM_GETDLGCODE, 0, 0);
8503 ok(dlg_code == (DLGC_WANTCHARS|DLGC_HASSETSEL|DLGC_WANTARROWS|DLGC_WANTALLKEYS),
8504 "wrong dlg_code %08x\n", dlg_code);
8506 ShowWindow(hwnd, SW_SHOW);
8512 ok_sequence(ml_edit_setfocus, "SetFocus(hwnd) on multiline edit", FALSE);
8515 ok_sequence(sl_edit_killfocus, "SetFocus(0) on multiline edit", FALSE);
8521 SendMessageA(hwnd, WM_LBUTTONDBLCLK, 0, 0);
8522 ok_sequence(sl_edit_lbutton_dblclk, "WM_LBUTTONDBLCLK on multiline edit", FALSE);
8528 SendMessageA(hwnd, WM_LBUTTONDOWN, 0, 0);
8529 ok_sequence(ml_edit_lbutton_down, "WM_LBUTTONDOWN on multiline edit", FALSE);
8531 SendMessageA(hwnd, WM_LBUTTONUP, 0, 0);
8532 ok_sequence(ml_edit_lbutton_up, "WM_LBUTTONUP on multiline edit", FALSE);
8534 DestroyWindow(hwnd);
8535 DestroyWindow(parent);
8537 log_all_parent_messages--;
8540 /**************************** End of Edit test ******************************/
8542 static const struct message WmKeyDownSkippedSeq[] =
8544 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 1 }, /* XP */
8547 static const struct message WmKeyUpSkippedSeq[] =
8549 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xc0000001 }, /* XP */
8553 #define EV_START_STOP 0
8554 #define EV_SENDMSG 1
8560 HANDLE hevent[3]; /* 0 - start/stop, 1 - SendMessage, 2 - ack */
8563 static DWORD CALLBACK send_msg_thread_2(void *param)
8566 struct peekmsg_info *info = param;
8568 trace("thread: waiting for start\n");
8569 WaitForSingleObject(info->hevent[EV_START_STOP], INFINITE);
8570 trace("thread: looping\n");
8574 ret = WaitForMultipleObjects(2, info->hevent, FALSE, INFINITE);
8578 case WAIT_OBJECT_0 + EV_START_STOP:
8579 trace("thread: exiting\n");
8582 case WAIT_OBJECT_0 + EV_SENDMSG:
8583 trace("thread: sending message\n");
8584 SendNotifyMessageA(info->hwnd, WM_USER, 0, 0);
8585 SetEvent(info->hevent[EV_ACK]);
8589 trace("unexpected return: %04x\n", ret);
8597 static void test_PeekMessage(void)
8602 UINT qs_all_input = QS_ALLINPUT;
8603 UINT qs_input = QS_INPUT;
8605 struct peekmsg_info info;
8607 info.hwnd = CreateWindowA("TestWindowClass", NULL, WS_OVERLAPPEDWINDOW,
8608 100, 100, 200, 200, 0, 0, 0, NULL);
8610 ShowWindow(info.hwnd, SW_SHOW);
8611 UpdateWindow(info.hwnd);
8612 SetFocus(info.hwnd);
8614 info.hevent[EV_START_STOP] = CreateEventA(NULL, 0, 0, NULL);
8615 info.hevent[EV_SENDMSG] = CreateEventA(NULL, 0, 0, NULL);
8616 info.hevent[EV_ACK] = CreateEventA(NULL, 0, 0, NULL);
8618 hthread = CreateThread(NULL, 0, send_msg_thread_2, &info, 0, &tid);
8621 trace("signalling to start looping\n");
8622 SetEvent(info.hevent[EV_START_STOP]);
8627 SetLastError(0xdeadbeef);
8628 qstatus = GetQueueStatus(qs_all_input);
8629 if (GetLastError() == ERROR_INVALID_FLAGS)
8631 trace("QS_RAWINPUT not supported on this platform\n");
8632 qs_all_input &= ~QS_RAWINPUT;
8633 qs_input &= ~QS_RAWINPUT;
8635 ok(qstatus == 0, "wrong qstatus %08x\n", qstatus);
8637 trace("signalling to send message\n");
8638 SetEvent(info.hevent[EV_SENDMSG]);
8639 WaitForSingleObject(info.hevent[EV_ACK], INFINITE);
8641 /* pass invalid QS_xxxx flags */
8642 SetLastError(0xdeadbeef);
8643 qstatus = GetQueueStatus(0xffffffff);
8644 ok(qstatus == 0, "GetQueueStatus should fail: %08x\n", qstatus);
8645 ok(GetLastError() == ERROR_INVALID_FLAGS, "wrong error %d\n", GetLastError());
8647 qstatus = GetQueueStatus(qs_all_input);
8648 ok(qstatus == MAKELONG(QS_SENDMESSAGE, QS_SENDMESSAGE),
8649 "wrong qstatus %08x\n", qstatus);
8652 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE);
8654 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8656 ok_sequence(WmUser, "WmUser", FALSE);
8658 qstatus = GetQueueStatus(qs_all_input);
8659 ok(qstatus == 0, "wrong qstatus %08x\n", qstatus);
8661 keybd_event('N', 0, 0, 0);
8662 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
8663 qstatus = GetQueueStatus(qs_all_input);
8664 ok(qstatus == MAKELONG(QS_KEY, QS_KEY),
8665 "wrong qstatus %08x\n", qstatus);
8667 PostMessageA(info.hwnd, WM_CHAR, 'z', 0);
8668 qstatus = GetQueueStatus(qs_all_input);
8669 ok(qstatus == MAKELONG(QS_POSTMESSAGE, QS_POSTMESSAGE|QS_KEY),
8670 "wrong qstatus %08x\n", qstatus);
8672 InvalidateRect(info.hwnd, NULL, FALSE);
8673 qstatus = GetQueueStatus(qs_all_input);
8674 ok(qstatus == MAKELONG(QS_PAINT, QS_PAINT|QS_POSTMESSAGE|QS_KEY),
8675 "wrong qstatus %08x\n", qstatus);
8677 trace("signalling to send message\n");
8678 SetEvent(info.hevent[EV_SENDMSG]);
8679 WaitForSingleObject(info.hevent[EV_ACK], INFINITE);
8681 qstatus = GetQueueStatus(qs_all_input);
8682 ok(qstatus == MAKELONG(QS_SENDMESSAGE, QS_SENDMESSAGE|QS_PAINT|QS_POSTMESSAGE|QS_KEY),
8683 "wrong qstatus %08x\n", qstatus);
8686 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | (qs_input << 16));
8688 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8690 ok_sequence(WmUser, "WmUser", FALSE);
8692 qstatus = GetQueueStatus(qs_all_input);
8693 ok(qstatus == MAKELONG(0, QS_PAINT|QS_POSTMESSAGE|QS_KEY),
8694 "wrong qstatus %08x\n", qstatus);
8696 trace("signalling to send message\n");
8697 SetEvent(info.hevent[EV_SENDMSG]);
8698 WaitForSingleObject(info.hevent[EV_ACK], INFINITE);
8700 qstatus = GetQueueStatus(qs_all_input);
8701 ok(qstatus == MAKELONG(QS_SENDMESSAGE, QS_SENDMESSAGE|QS_PAINT|QS_POSTMESSAGE|QS_KEY),
8702 "wrong qstatus %08x\n", qstatus);
8705 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | PM_QS_POSTMESSAGE);
8707 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8709 ok_sequence(WmUser, "WmUser", FALSE);
8711 qstatus = GetQueueStatus(qs_all_input);
8712 ok(qstatus == MAKELONG(0, QS_PAINT|QS_POSTMESSAGE|QS_KEY),
8713 "wrong qstatus %08x\n", qstatus);
8716 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | PM_QS_POSTMESSAGE);
8717 ok(ret && msg.message == WM_CHAR && msg.wParam == 'z',
8718 "got %d and %04x wParam %08lx instead of TRUE and WM_CHAR wParam 'z'\n",
8719 ret, msg.message, msg.wParam);
8720 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
8722 qstatus = GetQueueStatus(qs_all_input);
8723 ok(qstatus == MAKELONG(0, QS_PAINT|QS_KEY),
8724 "wrong qstatus %08x\n", qstatus);
8727 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | PM_QS_POSTMESSAGE);
8729 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8731 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
8733 qstatus = GetQueueStatus(qs_all_input);
8734 ok(qstatus == MAKELONG(0, QS_PAINT|QS_KEY),
8735 "wrong qstatus %08x\n", qstatus);
8738 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | PM_QS_PAINT);
8739 ok(ret && msg.message == WM_PAINT,
8740 "got %d and %04x instead of TRUE and WM_PAINT\n", ret, msg.message);
8741 DispatchMessageA(&msg);
8742 ok_sequence(WmPaint, "WmPaint", FALSE);
8744 qstatus = GetQueueStatus(qs_all_input);
8745 ok(qstatus == MAKELONG(0, QS_KEY),
8746 "wrong qstatus %08x\n", qstatus);
8749 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | PM_QS_PAINT);
8751 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8753 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
8755 qstatus = GetQueueStatus(qs_all_input);
8756 ok(qstatus == MAKELONG(0, QS_KEY),
8757 "wrong qstatus %08x\n", qstatus);
8759 trace("signalling to send message\n");
8760 SetEvent(info.hevent[EV_SENDMSG]);
8761 WaitForSingleObject(info.hevent[EV_ACK], INFINITE);
8763 qstatus = GetQueueStatus(qs_all_input);
8764 ok(qstatus == MAKELONG(QS_SENDMESSAGE, QS_SENDMESSAGE|QS_KEY),
8765 "wrong qstatus %08x\n", qstatus);
8767 PostMessageA(info.hwnd, WM_CHAR, 'z', 0);
8769 qstatus = GetQueueStatus(qs_all_input);
8770 ok(qstatus == MAKELONG(QS_POSTMESSAGE, QS_SENDMESSAGE|QS_POSTMESSAGE|QS_KEY),
8771 "wrong qstatus %08x\n", qstatus);
8774 ret = PeekMessageA(&msg, 0, WM_CHAR, WM_CHAR, PM_REMOVE);
8775 ok(ret && msg.message == WM_CHAR && msg.wParam == 'z',
8776 "got %d and %04x wParam %08lx instead of TRUE and WM_CHAR wParam 'z'\n",
8777 ret, msg.message, msg.wParam);
8778 ok_sequence(WmUser, "WmUser", FALSE);
8780 qstatus = GetQueueStatus(qs_all_input);
8781 ok(qstatus == MAKELONG(0, QS_KEY),
8782 "wrong qstatus %08x\n", qstatus);
8785 ret = PeekMessageA(&msg, 0, WM_CHAR, WM_CHAR, PM_REMOVE);
8787 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8789 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
8791 qstatus = GetQueueStatus(qs_all_input);
8792 ok(qstatus == MAKELONG(0, QS_KEY),
8793 "wrong qstatus %08x\n", qstatus);
8795 PostMessageA(info.hwnd, WM_CHAR, 'z', 0);
8797 qstatus = GetQueueStatus(qs_all_input);
8798 ok(qstatus == MAKELONG(QS_POSTMESSAGE, QS_POSTMESSAGE|QS_KEY),
8799 "wrong qstatus %08x\n", qstatus);
8801 trace("signalling to send message\n");
8802 SetEvent(info.hevent[EV_SENDMSG]);
8803 WaitForSingleObject(info.hevent[EV_ACK], INFINITE);
8805 qstatus = GetQueueStatus(qs_all_input);
8806 ok(qstatus == MAKELONG(QS_SENDMESSAGE, QS_SENDMESSAGE|QS_POSTMESSAGE|QS_KEY),
8807 "wrong qstatus %08x\n", qstatus);
8810 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | (QS_KEY << 16));
8812 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8814 ok_sequence(WmUser, "WmUser", FALSE);
8816 qstatus = GetQueueStatus(qs_all_input);
8817 ok(qstatus == MAKELONG(0, QS_POSTMESSAGE|QS_KEY),
8818 "wrong qstatus %08x\n", qstatus);
8821 if (qs_all_input & QS_RAWINPUT) /* use QS_RAWINPUT only if supported */
8822 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | (QS_RAWINPUT << 16));
8823 else /* workaround for a missing QS_RAWINPUT support */
8824 ret = PeekMessageA(&msg, 0, WM_KEYDOWN, WM_KEYDOWN, PM_REMOVE);
8825 ok(ret && msg.message == WM_KEYDOWN && msg.wParam == 'N',
8826 "got %d and %04x wParam %08lx instead of TRUE and WM_KEYDOWN wParam 'N'\n",
8827 ret, msg.message, msg.wParam);
8828 ok_sequence(WmKeyDownSkippedSeq, "WmKeyDownSkippedSeq", FALSE);
8830 qstatus = GetQueueStatus(qs_all_input);
8831 ok(qstatus == MAKELONG(0, QS_POSTMESSAGE|QS_KEY),
8832 "wrong qstatus %08x\n", qstatus);
8835 if (qs_all_input & QS_RAWINPUT) /* use QS_RAWINPUT only if supported */
8836 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | (QS_RAWINPUT << 16));
8837 else /* workaround for a missing QS_RAWINPUT support */
8838 ret = PeekMessageA(&msg, 0, WM_KEYUP, WM_KEYUP, PM_REMOVE);
8839 ok(ret && msg.message == WM_KEYUP && msg.wParam == 'N',
8840 "got %d and %04x wParam %08lx instead of TRUE and WM_KEYUP wParam 'N'\n",
8841 ret, msg.message, msg.wParam);
8842 ok_sequence(WmKeyUpSkippedSeq, "WmKeyUpSkippedSeq", FALSE);
8844 qstatus = GetQueueStatus(qs_all_input);
8845 ok(qstatus == MAKELONG(0, QS_POSTMESSAGE),
8846 "wrong qstatus %08x\n", qstatus);
8849 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | PM_QS_SENDMESSAGE);
8851 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8853 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
8855 qstatus = GetQueueStatus(qs_all_input);
8856 ok(qstatus == MAKELONG(0, QS_POSTMESSAGE),
8857 "wrong qstatus %08x\n", qstatus);
8860 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE);
8861 ok(ret && msg.message == WM_CHAR && msg.wParam == 'z',
8862 "got %d and %04x wParam %08lx instead of TRUE and WM_CHAR wParam 'z'\n",
8863 ret, msg.message, msg.wParam);
8864 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
8866 qstatus = GetQueueStatus(qs_all_input);
8868 "wrong qstatus %08x\n", qstatus);
8871 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE);
8873 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8875 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
8877 qstatus = GetQueueStatus(qs_all_input);
8879 "wrong qstatus %08x\n", qstatus);
8881 /* test whether presence of the quit flag in the queue affects
8884 PostQuitMessage(0x1234abcd);
8886 qstatus = GetQueueStatus(qs_all_input);
8887 ok(qstatus == MAKELONG(QS_POSTMESSAGE, QS_POSTMESSAGE),
8888 "wrong qstatus %08x\n", qstatus);
8890 PostMessageA(info.hwnd, WM_USER, 0, 0);
8892 qstatus = GetQueueStatus(qs_all_input);
8893 ok(qstatus == MAKELONG(QS_POSTMESSAGE, QS_POSTMESSAGE),
8894 "wrong qstatus %08x\n", qstatus);
8897 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE);
8898 ok(ret && msg.message == WM_USER,
8899 "got %d and %04x instead of TRUE and WM_USER\n", ret, msg.message);
8900 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
8902 qstatus = GetQueueStatus(qs_all_input);
8903 ok(qstatus == MAKELONG(0, QS_POSTMESSAGE),
8904 "wrong qstatus %08x\n", qstatus);
8907 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE);
8908 ok(ret && msg.message == WM_QUIT,
8909 "got %d and %04x instead of TRUE and WM_QUIT\n", ret, msg.message);
8910 ok(msg.wParam == 0x1234abcd, "got wParam %08lx instead of 0x1234abcd\n", msg.wParam);
8911 ok(msg.lParam == 0, "got lParam %08lx instead of 0\n", msg.lParam);
8912 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
8914 qstatus = GetQueueStatus(qs_all_input);
8916 ok(qstatus == MAKELONG(0, QS_POSTMESSAGE),
8917 "wrong qstatus %08x\n", qstatus);
8921 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE);
8923 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8925 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
8927 qstatus = GetQueueStatus(qs_all_input);
8929 "wrong qstatus %08x\n", qstatus);
8931 trace("signalling to exit\n");
8932 SetEvent(info.hevent[EV_START_STOP]);
8934 WaitForSingleObject(hthread, INFINITE);
8936 CloseHandle(hthread);
8937 CloseHandle(info.hevent[0]);
8938 CloseHandle(info.hevent[1]);
8939 CloseHandle(info.hevent[2]);
8941 DestroyWindow(info.hwnd);
8944 static void wait_move_event(HWND hwnd, int x, int y)
8951 time = GetTickCount();
8952 while (GetTickCount() - time < 200 && !go) {
8953 ret = PeekMessageA(&msg, hwnd, WM_MOUSEMOVE, WM_MOUSEMOVE, PM_NOREMOVE);
8954 go = ret && msg.pt.x > x && msg.pt.y > y;
8959 static void test_PeekMessage2(void)
8965 DWORD time1, time2, time3;
8966 int x1, y1, x2, y2, x3, y3;
8969 time1 = time2 = time3 = 0;
8970 x1 = y1 = x2 = y2 = x3 = y3 = 0;
8972 /* Initialise window and make sure it is ready for events */
8973 hwnd = CreateWindow("TestWindowClass", "PeekMessage2", WS_OVERLAPPEDWINDOW,
8974 10, 10, 800, 800, NULL, NULL, NULL, NULL);
8976 trace("Window for test_PeekMessage2 %p\n", hwnd);
8977 ShowWindow(hwnd, SW_SHOW);
8981 SetCursorPos(100, 100);
8982 mouse_event(MOUSEEVENTF_MOVE, -STEP, -STEP, 0, 0);
8985 /* Do initial mousemove, wait until we can see it
8986 and then do our test peek with PM_NOREMOVE. */
8987 mouse_event(MOUSEEVENTF_MOVE, STEP, STEP, 0, 0);
8988 wait_move_event(hwnd, 80, 80);
8990 ret = PeekMessageA(&msg, hwnd, WM_MOUSEMOVE, WM_MOUSEMOVE, PM_NOREMOVE);
8991 ok(ret, "no message available\n");
8993 trace("1st move event: %04x %x %d %d\n", msg.message, msg.time, msg.pt.x, msg.pt.y);
8994 message = msg.message;
8998 ok(message == WM_MOUSEMOVE, "message not WM_MOUSEMOVE, %04x instead\n", message);
9001 /* Allow time to advance a bit, and then simulate the user moving their
9002 * mouse around. After that we peek again with PM_NOREMOVE.
9003 * Although the previous mousemove message was never removed, the
9004 * mousemove we now peek should reflect the recent mouse movements
9005 * because the input queue will merge the move events. */
9007 mouse_event(MOUSEEVENTF_MOVE, STEP, STEP, 0, 0);
9008 wait_move_event(hwnd, x1, y1);
9010 ret = PeekMessageA(&msg, hwnd, WM_MOUSEMOVE, WM_MOUSEMOVE, PM_NOREMOVE);
9011 ok(ret, "no message available\n");
9013 trace("2nd move event: %04x %x %d %d\n", msg.message, msg.time, msg.pt.x, msg.pt.y);
9014 message = msg.message;
9018 ok(message == WM_MOUSEMOVE, "message not WM_MOUSEMOVE, %04x instead\n", message);
9019 ok(time2 > time1, "message time not advanced: %x %x\n", time1, time2);
9020 ok(x2 != x1 && y2 != y1, "coords not changed: (%d %d) (%d %d)\n", x1, y1, x2, y2);
9023 /* Have another go, to drive the point home */
9025 mouse_event(MOUSEEVENTF_MOVE, STEP, STEP, 0, 0);
9026 wait_move_event(hwnd, x2, y2);
9028 ret = PeekMessageA(&msg, hwnd, WM_MOUSEMOVE, WM_MOUSEMOVE, PM_NOREMOVE);
9029 ok(ret, "no message available\n");
9031 trace("3rd move event: %04x %x %d %d\n", msg.message, msg.time, msg.pt.x, msg.pt.y);
9032 message = msg.message;
9036 ok(message == WM_MOUSEMOVE, "message not WM_MOUSEMOVE, %04x instead\n", message);
9037 ok(time3 > time2, "message time not advanced: %x %x\n", time2, time3);
9038 ok(x3 != x2 && y3 != y2, "coords not changed: (%d %d) (%d %d)\n", x2, y2, x3, y3);
9041 DestroyWindow(hwnd);
9042 SetCursorPos(pos.x, pos.y);
9046 static void test_quit_message(void)
9051 /* test using PostQuitMessage */
9052 PostQuitMessage(0xbeef);
9054 ret = PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE);
9055 ok(ret, "PeekMessage failed with error %d\n", GetLastError());
9056 ok(msg.message == WM_QUIT, "Received message 0x%04x instead of WM_QUIT\n", msg.message);
9057 ok(msg.wParam == 0xbeef, "wParam was 0x%lx instead of 0xbeef\n", msg.wParam);
9059 ret = PostThreadMessage(GetCurrentThreadId(), WM_USER, 0, 0);
9060 ok(ret, "PostMessage failed with error %d\n", GetLastError());
9062 ret = GetMessage(&msg, NULL, 0, 0);
9063 ok(ret > 0, "GetMessage failed with error %d\n", GetLastError());
9064 ok(msg.message == WM_USER, "Received message 0x%04x instead of WM_USER\n", msg.message);
9066 /* note: WM_QUIT message received after WM_USER message */
9067 ret = GetMessage(&msg, NULL, 0, 0);
9068 ok(!ret, "GetMessage return %d with error %d instead of FALSE\n", ret, GetLastError());
9069 ok(msg.message == WM_QUIT, "Received message 0x%04x instead of WM_QUIT\n", msg.message);
9070 ok(msg.wParam == 0xbeef, "wParam was 0x%lx instead of 0xbeef\n", msg.wParam);
9072 ret = PeekMessage(&msg, NULL, 0, 0, PM_REMOVE);
9073 ok( !ret || msg.message != WM_QUIT, "Received WM_QUIT again\n" );
9075 /* now test with PostThreadMessage - different behaviour! */
9076 PostThreadMessage(GetCurrentThreadId(), WM_QUIT, 0xdead, 0);
9078 ret = PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE);
9079 ok(ret, "PeekMessage failed with error %d\n", GetLastError());
9080 ok(msg.message == WM_QUIT, "Received message 0x%04x instead of WM_QUIT\n", msg.message);
9081 ok(msg.wParam == 0xdead, "wParam was 0x%lx instead of 0xdead\n", msg.wParam);
9083 ret = PostThreadMessage(GetCurrentThreadId(), WM_USER, 0, 0);
9084 ok(ret, "PostMessage failed with error %d\n", GetLastError());
9086 /* note: we receive the WM_QUIT message first this time */
9087 ret = GetMessage(&msg, NULL, 0, 0);
9088 ok(!ret, "GetMessage return %d with error %d instead of FALSE\n", ret, GetLastError());
9089 ok(msg.message == WM_QUIT, "Received message 0x%04x instead of WM_QUIT\n", msg.message);
9090 ok(msg.wParam == 0xdead, "wParam was 0x%lx instead of 0xdead\n", msg.wParam);
9092 ret = GetMessage(&msg, NULL, 0, 0);
9093 ok(ret > 0, "GetMessage failed with error %d\n", GetLastError());
9094 ok(msg.message == WM_USER, "Received message 0x%04x instead of WM_USER\n", msg.message);
9097 static const struct message WmMouseHoverSeq[] = {
9098 { WM_MOUSEACTIVATE, sent|optional }, /* we can get those when moving the mouse in focus-follow-mouse mode under X11 */
9099 { WM_MOUSEACTIVATE, sent|optional },
9100 { WM_TIMER, sent|optional }, /* XP sends it */
9101 { WM_SYSTIMER, sent },
9102 { WM_MOUSEHOVER, sent|wparam, 0 },
9106 static void pump_msg_loop_timeout(DWORD timeout, BOOL inject_mouse_move)
9109 DWORD start_ticks, end_ticks;
9111 start_ticks = GetTickCount();
9112 /* add some deviation (5%) to cover not expected delays */
9113 start_ticks += timeout / 20;
9117 while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
9119 /* Timer proc messages are not dispatched to the window proc,
9120 * and therefore not logged.
9122 if (msg.message == WM_TIMER || msg.message == WM_SYSTIMER)
9124 struct message s_msg;
9126 s_msg.message = msg.message;
9127 s_msg.flags = sent|wparam|lparam;
9128 s_msg.wParam = msg.wParam;
9129 s_msg.lParam = msg.lParam;
9130 add_message(&s_msg);
9132 DispatchMessage(&msg);
9135 end_ticks = GetTickCount();
9137 /* inject WM_MOUSEMOVE to see how it changes tracking */
9138 if (inject_mouse_move && start_ticks + timeout / 2 >= end_ticks)
9140 mouse_event(MOUSEEVENTF_MOVE, -1, 0, 0, 0);
9141 mouse_event(MOUSEEVENTF_MOVE, 1, 0, 0, 0);
9143 inject_mouse_move = FALSE;
9145 } while (start_ticks + timeout >= end_ticks);
9148 static void test_TrackMouseEvent(void)
9150 TRACKMOUSEEVENT tme;
9153 RECT rc_parent, rc_child;
9154 UINT default_hover_time, hover_width = 0, hover_height = 0;
9156 #define track_hover(track_hwnd, track_hover_time) \
9157 tme.cbSize = sizeof(tme); \
9158 tme.dwFlags = TME_HOVER; \
9159 tme.hwndTrack = track_hwnd; \
9160 tme.dwHoverTime = track_hover_time; \
9161 SetLastError(0xdeadbeef); \
9162 ret = pTrackMouseEvent(&tme); \
9163 ok(ret, "TrackMouseEvent(TME_HOVER) error %d\n", GetLastError())
9165 #define track_query(expected_track_flags, expected_track_hwnd, expected_hover_time) \
9166 tme.cbSize = sizeof(tme); \
9167 tme.dwFlags = TME_QUERY; \
9168 tme.hwndTrack = (HWND)0xdeadbeef; \
9169 tme.dwHoverTime = 0xdeadbeef; \
9170 SetLastError(0xdeadbeef); \
9171 ret = pTrackMouseEvent(&tme); \
9172 ok(ret, "TrackMouseEvent(TME_QUERY) error %d\n", GetLastError());\
9173 ok(tme.cbSize == sizeof(tme), "wrong tme.cbSize %u\n", tme.cbSize); \
9174 ok(tme.dwFlags == (expected_track_flags), \
9175 "wrong tme.dwFlags %08x, expected %08x\n", tme.dwFlags, (expected_track_flags)); \
9176 ok(tme.hwndTrack == (expected_track_hwnd), \
9177 "wrong tme.hwndTrack %p, expected %p\n", tme.hwndTrack, (expected_track_hwnd)); \
9178 ok(tme.dwHoverTime == (expected_hover_time), \
9179 "wrong tme.dwHoverTime %u, expected %u\n", tme.dwHoverTime, (expected_hover_time))
9181 #define track_hover_cancel(track_hwnd) \
9182 tme.cbSize = sizeof(tme); \
9183 tme.dwFlags = TME_HOVER | TME_CANCEL; \
9184 tme.hwndTrack = track_hwnd; \
9185 tme.dwHoverTime = 0xdeadbeef; \
9186 SetLastError(0xdeadbeef); \
9187 ret = pTrackMouseEvent(&tme); \
9188 ok(ret, "TrackMouseEvent(TME_HOVER | TME_CANCEL) error %d\n", GetLastError())
9190 default_hover_time = 0xdeadbeef;
9191 SetLastError(0xdeadbeef);
9192 ret = SystemParametersInfo(SPI_GETMOUSEHOVERTIME, 0, &default_hover_time, 0);
9193 ok(ret, "SystemParametersInfo(SPI_GETMOUSEHOVERTIME) error %u\n", GetLastError());
9194 if (!ret) default_hover_time = 400;
9195 trace("SPI_GETMOUSEHOVERTIME returned %u ms\n", default_hover_time);
9197 SetLastError(0xdeadbeef);
9198 ret = SystemParametersInfo(SPI_GETMOUSEHOVERWIDTH, 0, &hover_width, 0);
9199 ok(ret, "SystemParametersInfo(SPI_GETMOUSEHOVERWIDTH) error %u\n", GetLastError());
9200 if (!ret) hover_width = 4;
9201 SetLastError(0xdeadbeef);
9202 ret = SystemParametersInfo(SPI_GETMOUSEHOVERHEIGHT, 0, &hover_height, 0);
9203 ok(ret, "SystemParametersInfo(SPI_GETMOUSEHOVERHEIGHT) error %u\n", GetLastError());
9204 if (!ret) hover_height = 4;
9205 trace("hover rect is %u x %d\n", hover_width, hover_height);
9207 hwnd = CreateWindowEx(0, "TestWindowClass", NULL,
9208 WS_OVERLAPPEDWINDOW | WS_VISIBLE,
9209 CW_USEDEFAULT, CW_USEDEFAULT, 300, 300, 0,
9213 hchild = CreateWindowEx(0, "TestWindowClass", NULL,
9214 WS_CHILD | WS_BORDER | WS_VISIBLE,
9215 50, 50, 200, 200, hwnd,
9223 tme.dwFlags = TME_QUERY;
9224 tme.hwndTrack = (HWND)0xdeadbeef;
9225 tme.dwHoverTime = 0xdeadbeef;
9226 SetLastError(0xdeadbeef);
9227 ret = pTrackMouseEvent(&tme);
9228 ok(!ret, "TrackMouseEvent should fail\n");
9229 ok(GetLastError() == ERROR_INVALID_PARAMETER, "not expected error %d\n", GetLastError());
9231 tme.cbSize = sizeof(tme);
9232 tme.dwFlags = TME_HOVER;
9233 tme.hwndTrack = (HWND)0xdeadbeef;
9234 tme.dwHoverTime = 0xdeadbeef;
9235 SetLastError(0xdeadbeef);
9236 ret = pTrackMouseEvent(&tme);
9237 ok(!ret, "TrackMouseEvent should fail\n");
9238 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "not expected error %d\n", GetLastError());
9240 tme.cbSize = sizeof(tme);
9241 tme.dwFlags = TME_HOVER | TME_CANCEL;
9242 tme.hwndTrack = (HWND)0xdeadbeef;
9243 tme.dwHoverTime = 0xdeadbeef;
9244 SetLastError(0xdeadbeef);
9245 ret = pTrackMouseEvent(&tme);
9246 ok(!ret, "TrackMouseEvent should fail\n");
9247 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "not expected error %d\n", GetLastError());
9249 GetWindowRect(hwnd, &rc_parent);
9250 GetWindowRect(hchild, &rc_child);
9251 SetCursorPos(rc_child.left - 10, rc_child.top - 10);
9253 /* Process messages so that the system updates its internal current
9254 * window and hittest, otherwise TrackMouseEvent calls don't have any
9260 track_query(0, NULL, 0);
9261 track_hover(hchild, 0);
9262 track_query(0, NULL, 0);
9267 track_hover(hwnd, 0);
9268 track_query(TME_HOVER, hwnd, default_hover_time);
9270 pump_msg_loop_timeout(default_hover_time, FALSE);
9271 ok_sequence(WmMouseHoverSeq, "WmMouseHoverSeq", FALSE);
9273 track_query(0, NULL, 0);
9275 track_hover(hwnd, HOVER_DEFAULT);
9276 track_query(TME_HOVER, hwnd, default_hover_time);
9278 Sleep(default_hover_time / 2);
9279 mouse_event(MOUSEEVENTF_MOVE, -1, 0, 0, 0);
9280 mouse_event(MOUSEEVENTF_MOVE, 1, 0, 0, 0);
9282 track_query(TME_HOVER, hwnd, default_hover_time);
9284 pump_msg_loop_timeout(default_hover_time / 2, FALSE);
9285 ok_sequence(WmMouseHoverSeq, "WmMouseHoverSeq", FALSE);
9287 track_query(0, NULL, 0);
9289 track_hover(hwnd, HOVER_DEFAULT);
9290 track_query(TME_HOVER, hwnd, default_hover_time);
9292 pump_msg_loop_timeout(default_hover_time, TRUE);
9293 ok_sequence(WmMouseHoverSeq, "WmMouseHoverSeq", FALSE);
9295 track_query(0, NULL, 0);
9297 track_hover(hwnd, HOVER_DEFAULT);
9298 track_query(TME_HOVER, hwnd, default_hover_time);
9299 track_hover_cancel(hwnd);
9301 DestroyWindow(hwnd);
9305 #undef track_hover_cancel
9309 static const struct message WmSetWindowRgn[] = {
9310 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE },
9311 { WM_NCCALCSIZE, sent|wparam, 1 },
9312 { WM_NCPAINT, sent }, /* wparam != 1 */
9313 { WM_GETTEXT, sent|defwinproc|optional },
9314 { WM_ERASEBKGND, sent|optional }, /* FIXME: remove optional once Wine is fixed */
9315 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE },
9316 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
9320 static const struct message WmSetWindowRgn_no_redraw[] = {
9321 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW },
9322 { WM_NCCALCSIZE, sent|wparam, 1 },
9323 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW },
9324 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
9328 static const struct message WmSetWindowRgn_clear[] = {
9329 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
9330 { WM_NCCALCSIZE, sent|wparam, 1 },
9331 { WM_NCPAINT, sent }, /* wparam != 1 */
9332 { WM_GETTEXT, sent|defwinproc|optional },
9333 { WM_ERASEBKGND, sent|optional }, /* FIXME: remove optional once Wine is fixed */
9334 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE },
9335 { WM_NCCALCSIZE, sent|wparam|optional, 1 },
9336 { WM_NCPAINT, sent|optional }, /* wparam != 1 */
9337 { WM_GETTEXT, sent|defwinproc|optional },
9338 { WM_ERASEBKGND, sent|optional },
9339 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
9340 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
9344 static void test_SetWindowRgn(void)
9347 HWND hwnd = CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW,
9348 100, 100, 200, 200, 0, 0, 0, NULL);
9349 ok( hwnd != 0, "Failed to create overlapped window\n" );
9351 ShowWindow( hwnd, SW_SHOW );
9352 UpdateWindow( hwnd );
9356 trace("testing SetWindowRgn\n");
9357 hrgn = CreateRectRgn( 0, 0, 150, 150 );
9358 SetWindowRgn( hwnd, hrgn, TRUE );
9359 ok_sequence( WmSetWindowRgn, "WmSetWindowRgn", FALSE );
9361 hrgn = CreateRectRgn( 30, 30, 160, 160 );
9362 SetWindowRgn( hwnd, hrgn, FALSE );
9363 ok_sequence( WmSetWindowRgn_no_redraw, "WmSetWindowRgn_no_redraw", FALSE );
9365 hrgn = CreateRectRgn( 0, 0, 180, 180 );
9366 SetWindowRgn( hwnd, hrgn, TRUE );
9367 ok_sequence( WmSetWindowRgn, "WmSetWindowRgn2", FALSE );
9369 SetWindowRgn( hwnd, 0, TRUE );
9370 ok_sequence( WmSetWindowRgn_clear, "WmSetWindowRgn_clear", FALSE );
9372 DestroyWindow( hwnd );
9375 /*************************** ShowWindow() test ******************************/
9376 static const struct message WmShowNormal[] = {
9377 { WM_SHOWWINDOW, sent|wparam, 1 },
9378 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
9379 { HCBT_ACTIVATE, hook },
9380 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* win2003 doesn't send it */
9381 { HCBT_SETFOCUS, hook },
9382 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
9385 static const struct message WmShow[] = {
9386 { WM_SHOWWINDOW, sent|wparam, 1 },
9387 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
9388 { HCBT_ACTIVATE, hook|optional }, /* win2000 doesn't send it */
9389 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* win2000 doesn't send it */
9390 { HCBT_SETFOCUS, hook|optional }, /* win2000 doesn't send it */
9391 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
9394 static const struct message WmShowNoActivate_1[] = {
9395 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWNOACTIVATE },
9396 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_STATECHANGED },
9397 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_STATECHANGED },
9398 { WM_MOVE, sent|defwinproc },
9399 { WM_SIZE, sent|wparam|defwinproc, SIZE_RESTORED },
9402 static const struct message WmShowNoActivate_2[] = {
9403 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWNOACTIVATE },
9404 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
9405 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
9406 { WM_MOVE, sent|defwinproc },
9407 { WM_SIZE, sent|wparam|defwinproc, SIZE_RESTORED },
9408 { HCBT_SETFOCUS, hook|optional },
9409 { HCBT_ACTIVATE, hook|optional }, /* win2003 doesn't send it */
9410 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* win2003 doesn't send it */
9411 { HCBT_SETFOCUS, hook|optional }, /* win2003 doesn't send it */
9414 static const struct message WmShowNA_1[] = {
9415 { WM_SHOWWINDOW, sent|wparam, 1 },
9416 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
9417 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
9420 static const struct message WmShowNA_2[] = {
9421 { WM_SHOWWINDOW, sent|wparam, 1 },
9422 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
9425 static const struct message WmRestore_1[] = {
9426 { HCBT_MINMAX, hook|lparam, 0, SW_RESTORE },
9427 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
9428 { HCBT_ACTIVATE, hook|optional }, /* win2000 doesn't send it */
9429 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* win2000 doesn't send it */
9430 { HCBT_SETFOCUS, hook|optional }, /* win2000 doesn't send it */
9431 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
9432 { WM_MOVE, sent|defwinproc },
9433 { WM_SIZE, sent|wparam|defwinproc, SIZE_RESTORED },
9434 { HCBT_SETFOCUS, hook|optional }, /* win2000 sends it */
9437 static const struct message WmRestore_2[] = {
9438 { WM_SHOWWINDOW, sent|wparam, 1 },
9439 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
9440 { HCBT_ACTIVATE, hook|optional }, /* win2000 doesn't send it */
9441 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* win2000 doesn't send it */
9442 { HCBT_SETFOCUS, hook|optional }, /* win2000 doesn't send it */
9443 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
9446 static const struct message WmRestore_3[] = {
9447 { HCBT_MINMAX, hook|lparam, 0, SW_RESTORE },
9448 { WM_GETMINMAXINFO, sent },
9449 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
9450 { HCBT_ACTIVATE, hook|optional }, /* win2003 doesn't send it */
9451 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* win2003 doesn't send it */
9452 { HCBT_SETFOCUS, hook|optional }, /* win2003 doesn't send it */
9453 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
9454 { WM_MOVE, sent|defwinproc },
9455 { WM_SIZE, sent|wparam|defwinproc, SIZE_MAXIMIZED },
9456 { HCBT_SETFOCUS, hook|optional }, /* win2003 sends it */
9459 static const struct message WmRestore_4[] = {
9460 { HCBT_MINMAX, hook|lparam, 0, SW_RESTORE },
9461 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_STATECHANGED },
9462 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_STATECHANGED },
9463 { WM_MOVE, sent|defwinproc },
9464 { WM_SIZE, sent|wparam|defwinproc, SIZE_RESTORED },
9467 static const struct message WmRestore_5[] = {
9468 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWNORMAL },
9469 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_STATECHANGED },
9470 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_STATECHANGED },
9471 { WM_MOVE, sent|defwinproc },
9472 { WM_SIZE, sent|wparam|defwinproc, SIZE_RESTORED },
9475 static const struct message WmHide_1[] = {
9476 { WM_SHOWWINDOW, sent|wparam, 0 },
9477 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE },
9478 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
9479 { HCBT_SETFOCUS, hook|optional }, /* win2000 sends it */
9482 static const struct message WmHide_2[] = {
9483 { WM_SHOWWINDOW, sent|wparam, 0 },
9484 { WM_WINDOWPOSCHANGING, sent /*|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE*/ }, /* win2000 doesn't add SWP_NOACTIVATE */
9485 { WM_WINDOWPOSCHANGED, sent /*|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE*/ }, /* win2000 doesn't add SWP_NOACTIVATE */
9488 static const struct message WmHide_3[] = {
9489 { WM_SHOWWINDOW, sent|wparam, 0 },
9490 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE },
9491 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
9492 { HCBT_SETFOCUS, hook },
9493 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
9496 static const struct message WmShowMinimized_1[] = {
9497 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMINIMIZED },
9498 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
9499 { HCBT_ACTIVATE, hook|optional }, /* win2000 doesn't send it */
9500 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* win2000 doesn't send it */
9501 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
9502 { WM_MOVE, sent|defwinproc },
9503 { WM_SIZE, sent|wparam|defwinproc, SIZE_MINIMIZED },
9506 static const struct message WmMinimize_1[] = {
9507 { HCBT_MINMAX, hook|lparam, 0, SW_MINIMIZE },
9508 { HCBT_SETFOCUS, hook|optional }, /* win2000 doesn't send it */
9509 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
9510 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
9511 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
9512 { WM_MOVE, sent|defwinproc },
9513 { WM_SIZE, sent|wparam|defwinproc, SIZE_MINIMIZED },
9516 static const struct message WmMinimize_2[] = {
9517 { HCBT_MINMAX, hook|lparam, 0, SW_MINIMIZE },
9518 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
9519 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
9520 { WM_MOVE, sent|defwinproc },
9521 { WM_SIZE, sent|wparam|defwinproc, SIZE_MINIMIZED },
9524 static const struct message WmMinimize_3[] = {
9525 { HCBT_MINMAX, hook|lparam, 0, SW_MINIMIZE },
9526 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
9527 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
9528 { WM_MOVE, sent|defwinproc },
9529 { WM_SIZE, sent|wparam|defwinproc, SIZE_MINIMIZED },
9532 static const struct message WmShowMinNoActivate[] = {
9533 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMINNOACTIVE },
9534 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
9535 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
9538 static const struct message WmMinMax_1[] = {
9539 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMINIMIZED },
9542 static const struct message WmMinMax_2[] = {
9543 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMAXIMIZED },
9546 static const struct message WmMinMax_3[] = {
9547 { HCBT_MINMAX, hook|lparam, 0, SW_MINIMIZE },
9550 static const struct message WmMinMax_4[] = {
9551 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMINNOACTIVE },
9554 static const struct message WmShowMaximized_1[] = {
9555 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMAXIMIZED },
9556 { WM_GETMINMAXINFO, sent },
9557 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
9558 { HCBT_ACTIVATE, hook|optional }, /* win2000 doesn't send it */
9559 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* win2000 doesn't send it */
9560 { HCBT_SETFOCUS, hook|optional }, /* win2000 doesn't send it */
9561 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
9562 { WM_MOVE, sent|defwinproc },
9563 { WM_SIZE, sent|wparam|defwinproc, SIZE_MAXIMIZED },
9564 { HCBT_SETFOCUS, hook|optional }, /* win2003 sends it */
9567 static const struct message WmShowMaximized_2[] = {
9568 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMAXIMIZED },
9569 { WM_GETMINMAXINFO, sent },
9570 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE },
9571 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
9572 { WM_MOVE, sent|optional }, /* Win9x doesn't send it */
9573 { WM_SIZE, sent|wparam|optional, SIZE_MAXIMIZED }, /* Win9x doesn't send it */
9574 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
9575 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
9576 { WM_MOVE, sent|defwinproc },
9577 { WM_SIZE, sent|wparam|defwinproc, SIZE_MAXIMIZED },
9578 { HCBT_SETFOCUS, hook },
9581 static const struct message WmShowMaximized_3[] = {
9582 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMAXIMIZED },
9583 { WM_GETMINMAXINFO, sent },
9584 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_STATECHANGED },
9585 { HCBT_ACTIVATE, hook|optional }, /* win2000 doesn't send it */
9586 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* win2000 doesn't send it */
9587 { HCBT_SETFOCUS, hook|optional }, /* win2000 doesn't send it */
9588 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_STATECHANGED },
9589 { WM_MOVE, sent|defwinproc },
9590 { WM_SIZE, sent|wparam|defwinproc, SIZE_MAXIMIZED },
9594 static void test_ShowWindow(void)
9596 /* ShowWindow commands in random order */
9599 INT cmd; /* ShowWindow command */
9600 LPARAM ret; /* ShowWindow return value */
9601 DWORD style; /* window style after the command */
9602 const struct message *msg; /* message sequence the command produces */
9603 BOOL todo_msg; /* message sequence doesn't match what Wine does */
9606 /* 1 */ { SW_SHOWNORMAL, FALSE, WS_VISIBLE, WmShowNormal, FALSE },
9607 /* 2 */ { SW_SHOWNORMAL, TRUE, WS_VISIBLE, WmEmptySeq, FALSE },
9608 /* 3 */ { SW_HIDE, TRUE, 0, WmHide_1, FALSE },
9609 /* 4 */ { SW_HIDE, FALSE, 0, WmEmptySeq, FALSE },
9610 /* 5 */ { SW_SHOWMINIMIZED, FALSE, WS_VISIBLE|WS_MINIMIZE, WmShowMinimized_1, FALSE },
9611 /* 6 */ { SW_SHOWMINIMIZED, TRUE, WS_VISIBLE|WS_MINIMIZE, WmMinMax_1, FALSE },
9612 /* 7 */ { SW_HIDE, TRUE, WS_MINIMIZE, WmHide_1, FALSE },
9613 /* 8 */ { SW_HIDE, FALSE, WS_MINIMIZE, WmEmptySeq, FALSE },
9614 /* 9 */ { SW_SHOWMAXIMIZED, FALSE, WS_VISIBLE|WS_MAXIMIZE, WmShowMaximized_1, FALSE },
9615 /* 10 */ { SW_SHOWMAXIMIZED, TRUE, WS_VISIBLE|WS_MAXIMIZE, WmMinMax_2, FALSE },
9616 /* 11 */ { SW_HIDE, TRUE, WS_MAXIMIZE, WmHide_1, FALSE },
9617 /* 12 */ { SW_HIDE, FALSE, WS_MAXIMIZE, WmEmptySeq, FALSE },
9618 /* 13 */ { SW_SHOWNOACTIVATE, FALSE, WS_VISIBLE, WmShowNoActivate_1, FALSE },
9619 /* 14 */ { SW_SHOWNOACTIVATE, TRUE, WS_VISIBLE, WmEmptySeq, FALSE },
9620 /* 15 */ { SW_HIDE, TRUE, 0, WmHide_2, FALSE },
9621 /* 16 */ { SW_HIDE, FALSE, 0, WmEmptySeq, FALSE },
9622 /* 17 */ { SW_SHOW, FALSE, WS_VISIBLE, WmShow, FALSE },
9623 /* 18 */ { SW_SHOW, TRUE, WS_VISIBLE, WmEmptySeq, FALSE },
9624 /* 19 */ { SW_MINIMIZE, TRUE, WS_VISIBLE|WS_MINIMIZE, WmMinimize_1, FALSE },
9625 /* 20 */ { SW_MINIMIZE, TRUE, WS_VISIBLE|WS_MINIMIZE, WmMinMax_3, FALSE },
9626 /* 21 */ { SW_HIDE, TRUE, WS_MINIMIZE, WmHide_2, FALSE },
9627 /* 22 */ { SW_SHOWMINNOACTIVE, FALSE, WS_VISIBLE|WS_MINIMIZE, WmShowMinNoActivate, TRUE },
9628 /* 23 */ { SW_SHOWMINNOACTIVE, TRUE, WS_VISIBLE|WS_MINIMIZE, WmMinMax_4, FALSE },
9629 /* 24 */ { SW_HIDE, TRUE, WS_MINIMIZE, WmHide_2, FALSE },
9630 /* 25 */ { SW_HIDE, FALSE, WS_MINIMIZE, WmEmptySeq, FALSE },
9631 /* 26 */ { SW_SHOWNA, FALSE, WS_VISIBLE|WS_MINIMIZE, WmShowNA_1, FALSE },
9632 /* 27 */ { SW_SHOWNA, TRUE, WS_VISIBLE|WS_MINIMIZE, WmShowNA_2, FALSE },
9633 /* 28 */ { SW_HIDE, TRUE, WS_MINIMIZE, WmHide_2, FALSE },
9634 /* 29 */ { SW_HIDE, FALSE, WS_MINIMIZE, WmEmptySeq, FALSE },
9635 /* 30 */ { SW_RESTORE, FALSE, WS_VISIBLE, WmRestore_1, FALSE },
9636 /* 31 */ { SW_RESTORE, TRUE, WS_VISIBLE, WmEmptySeq, FALSE },
9637 /* 32 */ { SW_HIDE, TRUE, 0, WmHide_3, TRUE },
9638 /* 33 */ { SW_HIDE, FALSE, 0, WmEmptySeq, FALSE },
9639 /* 34 */ { SW_NORMALNA, FALSE, 0, WmEmptySeq, FALSE }, /* what does this mean?! */
9640 /* 35 */ { SW_NORMALNA, FALSE, 0, WmEmptySeq, FALSE },
9641 /* 36 */ { SW_HIDE, FALSE, 0, WmEmptySeq, FALSE },
9642 /* 37 */ { SW_RESTORE, FALSE, WS_VISIBLE, WmRestore_2, FALSE },
9643 /* 38 */ { SW_RESTORE, TRUE, WS_VISIBLE, WmEmptySeq, FALSE },
9644 /* 39 */ { SW_SHOWNOACTIVATE, TRUE, WS_VISIBLE, WmEmptySeq, FALSE },
9645 /* 40 */ { SW_MINIMIZE, TRUE, WS_VISIBLE|WS_MINIMIZE, WmMinimize_2, FALSE },
9646 /* 41 */ { SW_MINIMIZE, TRUE, WS_VISIBLE|WS_MINIMIZE, WmMinMax_3, FALSE },
9647 /* 42 */ { SW_SHOWMAXIMIZED, TRUE, WS_VISIBLE|WS_MAXIMIZE, WmShowMaximized_2, TRUE },
9648 /* 43 */ { SW_SHOWMAXIMIZED, TRUE, WS_VISIBLE|WS_MAXIMIZE, WmMinMax_2, FALSE },
9649 /* 44 */ { SW_MINIMIZE, TRUE, WS_VISIBLE|WS_MINIMIZE, WmMinimize_1, FALSE },
9650 /* 45 */ { SW_MINIMIZE, TRUE, WS_VISIBLE|WS_MINIMIZE, WmMinMax_3, FALSE },
9651 /* 46 */ { SW_RESTORE, TRUE, WS_VISIBLE|WS_MAXIMIZE, WmRestore_3, FALSE },
9652 /* 47 */ { SW_RESTORE, TRUE, WS_VISIBLE, WmRestore_4, FALSE },
9653 /* 48 */ { SW_SHOWMAXIMIZED, TRUE, WS_VISIBLE|WS_MAXIMIZE, WmShowMaximized_3, FALSE },
9654 /* 49 */ { SW_SHOW, TRUE, WS_VISIBLE|WS_MAXIMIZE, WmEmptySeq, FALSE },
9655 /* 50 */ { SW_SHOWNORMAL, TRUE, WS_VISIBLE, WmRestore_5, FALSE },
9656 /* 51 */ { SW_SHOWNORMAL, TRUE, WS_VISIBLE, WmEmptySeq, FALSE },
9657 /* 52 */ { SW_HIDE, TRUE, 0, WmHide_1, FALSE },
9658 /* 53 */ { SW_HIDE, FALSE, 0, WmEmptySeq, FALSE },
9659 /* 54 */ { SW_MINIMIZE, FALSE, WS_VISIBLE|WS_MINIMIZE, WmMinimize_3, FALSE },
9660 /* 55 */ { SW_HIDE, TRUE, WS_MINIMIZE, WmHide_2, FALSE },
9661 /* 56 */ { SW_SHOWNOACTIVATE, FALSE, WS_VISIBLE, WmShowNoActivate_2, FALSE },
9662 /* 57 */ { SW_SHOW, TRUE, WS_VISIBLE, WmEmptySeq, FALSE }
9669 #define WS_BASE (WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX|WS_MAXIMIZEBOX|WS_POPUP|WS_CLIPSIBLINGS)
9670 hwnd = CreateWindowEx(0, "ShowWindowClass", NULL, WS_BASE,
9675 style = GetWindowLong(hwnd, GWL_STYLE) & ~WS_BASE;
9676 ok(style == 0, "expected style 0, got %08x\n", style);
9681 for (i = 0; i < sizeof(sw)/sizeof(sw[0]); i++)
9683 static const char * const sw_cmd_name[13] =
9685 "SW_HIDE", "SW_SHOWNORMAL", "SW_SHOWMINIMIZED", "SW_SHOWMAXIMIZED",
9686 "SW_SHOWNOACTIVATE", "SW_SHOW", "SW_MINIMIZE", "SW_SHOWMINNOACTIVE",
9687 "SW_SHOWNA", "SW_RESTORE", "SW_SHOWDEFAULT", "SW_FORCEMINIMIZE",
9688 "SW_NORMALNA" /* 0xCC */
9691 INT idx; /* index into the above array of names */
9693 idx = (sw[i].cmd == SW_NORMALNA) ? 12 : sw[i].cmd;
9695 style = GetWindowLong(hwnd, GWL_STYLE);
9696 trace("%d: sending %s, current window style %08x\n", i+1, sw_cmd_name[idx], style);
9697 ret = ShowWindow(hwnd, sw[i].cmd);
9698 ok(!ret == !sw[i].ret, "%d: cmd %s: expected ret %lu, got %lu\n", i+1, sw_cmd_name[idx], sw[i].ret, ret);
9699 style = GetWindowLong(hwnd, GWL_STYLE) & ~WS_BASE;
9700 ok(style == sw[i].style, "%d: expected style %08x, got %08x\n", i+1, sw[i].style, style);
9702 sprintf(comment, "%d: ShowWindow(%s)", i+1, sw_cmd_name[idx]);
9703 ok_sequence(sw[i].msg, comment, sw[i].todo_msg);
9709 DestroyWindow(hwnd);
9712 static INT_PTR WINAPI test_dlg_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
9716 trace("dialog: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
9720 case WM_WINDOWPOSCHANGING:
9721 case WM_WINDOWPOSCHANGED:
9723 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
9725 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
9726 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x ",
9727 winpos->hwnd, winpos->hwndInsertAfter,
9728 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
9729 dump_winpos_flags(winpos->flags);
9731 /* Log only documented flags, win2k uses 0x1000 and 0x2000
9732 * in the high word for internal purposes
9734 wParam = winpos->flags & 0xffff;
9735 /* We are not interested in the flags that don't match under XP and Win9x */
9736 wParam &= ~(SWP_NOZORDER);
9740 /* explicitly ignore WM_GETICON message */
9745 msg.message = message;
9746 msg.flags = sent|wparam|lparam;
9747 msg.wParam = wParam;
9748 msg.lParam = lParam;
9751 /* calling DefDlgProc leads to a recursion under XP */
9762 static const struct message WmDefDlgSetFocus_1[] = {
9763 { WM_GETDLGCODE, sent|wparam|lparam, 0, 0 },
9764 { WM_GETTEXTLENGTH, sent|wparam|lparam|optional, 0, 0 }, /* XP */
9765 { WM_GETTEXT, sent|wparam|optional, 6 }, /* XP */
9766 { WM_GETTEXT, sent|wparam|optional, 12 }, /* XP */
9767 { EM_SETSEL, sent|wparam, 0 }, /* XP sets lparam to text length, Win9x to -2 */
9768 { HCBT_SETFOCUS, hook },
9769 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
9770 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
9771 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
9772 { WM_SETFOCUS, sent|wparam, 0 },
9773 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 10 },
9774 { WM_CTLCOLOREDIT, sent },
9775 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 11 },
9776 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
9777 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
9778 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
9779 { WM_COMMAND, sent|wparam, MAKEWPARAM(1, EN_SETFOCUS) },
9782 static const struct message WmDefDlgSetFocus_2[] = {
9783 { WM_GETDLGCODE, sent|wparam|lparam, 0, 0 },
9784 { WM_GETTEXTLENGTH, sent|wparam|lparam|optional, 0, 0 }, /* XP */
9785 { WM_GETTEXT, sent|wparam|optional, 6 }, /* XP */
9786 { WM_GETTEXT, sent|wparam|optional, 12 }, /* XP */
9787 { EM_SETSEL, sent|wparam, 0 }, /* XP sets lparam to text length, Win9x to -2 */
9788 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
9789 { WM_CTLCOLOREDIT, sent|optional }, /* XP */
9790 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
9793 /* Creation of a dialog */
9794 static const struct message WmCreateDialogParamSeq_1[] = {
9795 { HCBT_CREATEWND, hook },
9796 { WM_NCCREATE, sent },
9797 { WM_NCCALCSIZE, sent|wparam, 0 },
9798 { WM_CREATE, sent },
9799 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
9800 { WM_SIZE, sent|wparam, SIZE_RESTORED },
9802 { WM_SETFONT, sent },
9803 { WM_INITDIALOG, sent },
9804 { WM_CHANGEUISTATE, sent|optional },
9807 /* Creation of a dialog */
9808 static const struct message WmCreateDialogParamSeq_2[] = {
9809 { HCBT_CREATEWND, hook },
9810 { WM_NCCREATE, sent },
9811 { WM_NCCALCSIZE, sent|wparam, 0 },
9812 { WM_CREATE, sent },
9813 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
9814 { WM_SIZE, sent|wparam, SIZE_RESTORED },
9816 { WM_CHANGEUISTATE, sent|optional },
9820 static void test_dialog_messages(void)
9823 HWND hdlg, hedit1, hedit2, hfocus;
9826 #define set_selection(hctl, start, end) \
9827 ret = SendMessage(hctl, EM_SETSEL, start, end); \
9828 ok(ret == 1, "EM_SETSEL returned %ld\n", ret);
9830 #define check_selection(hctl, start, end) \
9831 ret = SendMessage(hctl, EM_GETSEL, 0, 0); \
9832 ok(ret == MAKELRESULT(start, end), "wrong selection (%d - %d)\n", LOWORD(ret), HIWORD(ret));
9836 hdlg = CreateWindowEx(WS_EX_DLGMODALFRAME, "TestDialogClass", NULL,
9837 WS_VISIBLE|WS_CAPTION|WS_SYSMENU|WS_DLGFRAME,
9838 0, 0, 100, 100, 0, 0, 0, NULL);
9839 ok(hdlg != 0, "Failed to create custom dialog window\n");
9841 hedit1 = CreateWindowEx(0, "my_edit_class", NULL,
9842 WS_CHILD|WS_BORDER|WS_VISIBLE|WS_TABSTOP,
9843 0, 0, 80, 20, hdlg, (HMENU)1, 0, NULL);
9844 ok(hedit1 != 0, "Failed to create edit control\n");
9845 hedit2 = CreateWindowEx(0, "my_edit_class", NULL,
9846 WS_CHILD|WS_BORDER|WS_VISIBLE|WS_TABSTOP,
9847 0, 40, 80, 20, hdlg, (HMENU)2, 0, NULL);
9848 ok(hedit2 != 0, "Failed to create edit control\n");
9850 SendMessage(hedit1, WM_SETTEXT, 0, (LPARAM)"hello");
9851 SendMessage(hedit2, WM_SETTEXT, 0, (LPARAM)"bye");
9853 hfocus = GetFocus();
9854 ok(hfocus == hdlg, "wrong focus %p\n", hfocus);
9857 hfocus = GetFocus();
9858 ok(hfocus == hedit2, "wrong focus %p\n", hfocus);
9860 check_selection(hedit1, 0, 0);
9861 check_selection(hedit2, 0, 0);
9863 set_selection(hedit2, 0, -1);
9864 check_selection(hedit2, 0, 3);
9867 hfocus = GetFocus();
9868 ok(hfocus == 0, "wrong focus %p\n", hfocus);
9871 ret = DefDlgProc(hdlg, WM_SETFOCUS, 0, 0);
9872 ok(ret == 0, "WM_SETFOCUS returned %ld\n", ret);
9873 ok_sequence(WmDefDlgSetFocus_1, "DefDlgProc(WM_SETFOCUS) 1", FALSE);
9875 hfocus = GetFocus();
9876 ok(hfocus == hedit1, "wrong focus %p\n", hfocus);
9878 check_selection(hedit1, 0, 5);
9879 check_selection(hedit2, 0, 3);
9882 ret = DefDlgProc(hdlg, WM_SETFOCUS, 0, 0);
9883 ok(ret == 0, "WM_SETFOCUS returned %ld\n", ret);
9884 ok_sequence(WmDefDlgSetFocus_2, "DefDlgProc(WM_SETFOCUS) 2", FALSE);
9886 hfocus = GetFocus();
9887 ok(hfocus == hedit1, "wrong focus %p\n", hfocus);
9889 check_selection(hedit1, 0, 5);
9890 check_selection(hedit2, 0, 3);
9893 DestroyWindow(hedit1);
9894 DestroyWindow(hedit2);
9895 DestroyWindow(hdlg);
9898 #undef set_selection
9899 #undef check_selection
9901 ok(GetClassInfo(0, "#32770", &cls), "GetClassInfo failed\n");
9902 cls.lpszClassName = "MyDialogClass";
9903 cls.hInstance = GetModuleHandle(0);
9904 /* need a cast since a dlgproc is used as a wndproc */
9905 cls.lpfnWndProc = (WNDPROC)test_dlg_proc;
9906 if (!RegisterClass(&cls)) assert(0);
9908 hdlg = CreateDialogParam(0, "CLASS_TEST_DIALOG_2", 0, test_dlg_proc, 0);
9909 ok(IsWindow(hdlg), "CreateDialogParam failed\n");
9910 ok_sequence(WmCreateDialogParamSeq_1, "CreateDialogParam_1", FALSE);
9912 DestroyWindow(hdlg);
9915 hdlg = CreateDialogParam(0, "CLASS_TEST_DIALOG_2", 0, NULL, 0);
9916 ok(IsWindow(hdlg), "CreateDialogParam failed\n");
9917 ok_sequence(WmCreateDialogParamSeq_2, "CreateDialogParam_2", FALSE);
9919 DestroyWindow(hdlg);
9922 UnregisterClass(cls.lpszClassName, cls.hInstance);
9925 static void test_nullCallback(void)
9929 hwnd = CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW,
9930 100, 100, 200, 200, 0, 0, 0, NULL);
9931 ok (hwnd != 0, "Failed to create overlapped window\n");
9933 SendMessageCallbackA(hwnd,WM_NULL,0,0,NULL,0);
9935 DestroyWindow(hwnd);
9938 static const struct message SetForegroundWindowSeq[] =
9940 { WM_NCACTIVATE, sent|wparam, 0 },
9941 { WM_GETTEXT, sent|defwinproc|optional },
9942 { WM_ACTIVATE, sent|wparam, 0 },
9943 { WM_ACTIVATEAPP, sent|wparam, 0 },
9944 { WM_KILLFOCUS, sent },
9945 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
9946 { WM_IME_NOTIFY, sent|wparam|optional|defwinproc, 1 },
9950 static void test_SetForegroundWindow(void)
9954 hwnd = CreateWindowExA(0, "TestWindowClass", "Test SetForegroundWindow",
9955 WS_OVERLAPPEDWINDOW | WS_VISIBLE,
9956 100, 100, 200, 200, 0, 0, 0, NULL);
9957 ok (hwnd != 0, "Failed to create overlapped window\n");
9960 trace("SetForegroundWindow( 0 )\n");
9961 SetForegroundWindow( 0 );
9962 ok_sequence(WmEmptySeq, "SetForegroundWindow( 0 ) away from foreground top level window", FALSE);
9963 trace("SetForegroundWindow( GetDesktopWindow() )\n");
9964 SetForegroundWindow( GetDesktopWindow() );
9965 ok_sequence(SetForegroundWindowSeq, "SetForegroundWindow( desktop ) away from "
9966 "foreground top level window", FALSE);
9969 DestroyWindow(hwnd);
9972 static void test_dbcs_wm_char(void)
9983 struct message wmCharSeq[2];
9987 skip("GetCPInfoExA is not available\n");
9991 pGetCPInfoExA( CP_ACP, 0, &cpinfo );
9992 if (cpinfo.MaxCharSize != 2)
9994 skip( "Skipping DBCS WM_CHAR test in SBCS codepage '%s'\n", cpinfo.CodePageName );
9998 dbch[0] = dbch[1] = 0;
10000 bad_wch = cpinfo.UnicodeDefaultChar;
10001 for (i = 0; !wch && i < MAX_LEADBYTES && cpinfo.LeadByte[i]; i += 2)
10002 for (j = cpinfo.LeadByte[i]; !wch && j <= cpinfo.LeadByte[i+1]; j++)
10003 for (k = 128; k <= 255; k++)
10009 if (MultiByteToWideChar( CP_ACP, 0, str, 2, wstr, 2 ) == 1 &&
10010 WideCharToMultiByte( CP_ACP, 0, wstr, 1, str, 2, NULL, NULL ) == 2 &&
10011 (BYTE)str[0] == j && (BYTE)str[1] == k &&
10012 HIBYTE(wstr[0]) && HIBYTE(wstr[0]) != 0xff)
10023 skip( "Skipping DBCS WM_CHAR test, no appropriate char found\n" );
10026 trace( "using dbcs char %02x,%02x wchar %04x bad wchar %04x codepage '%s'\n",
10027 dbch[0], dbch[1], wch, bad_wch, cpinfo.CodePageName );
10029 hwnd = CreateWindowExW(0, testWindowClassW, NULL,
10030 WS_OVERLAPPEDWINDOW, 100, 100, 200, 200, 0, 0, 0, NULL);
10031 hwnd2 = CreateWindowExW(0, testWindowClassW, NULL,
10032 WS_OVERLAPPEDWINDOW, 100, 100, 200, 200, 0, 0, 0, NULL);
10033 ok (hwnd != 0, "Failed to create overlapped window\n");
10034 ok (hwnd2 != 0, "Failed to create overlapped window\n");
10037 memset( wmCharSeq, 0, sizeof(wmCharSeq) );
10038 wmCharSeq[0].message = WM_CHAR;
10039 wmCharSeq[0].flags = sent|wparam;
10040 wmCharSeq[0].wParam = wch;
10042 /* posted message */
10043 PostMessageA( hwnd, WM_CHAR, dbch[0], 0 );
10044 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10045 PostMessageA( hwnd, WM_CHAR, dbch[1], 0 );
10046 ok( PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "no message\n" );
10047 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
10048 ok( msg.wParam == wch, "bad wparam %lx/%x\n", msg.wParam, wch );
10049 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10051 /* posted thread message */
10052 PostThreadMessageA( GetCurrentThreadId(), WM_CHAR, dbch[0], 0 );
10053 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10054 PostMessageA( hwnd, WM_CHAR, dbch[1], 0 );
10055 ok( PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "no message\n" );
10056 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
10057 ok( msg.wParam == wch, "bad wparam %lx/%x\n", msg.wParam, wch );
10058 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10062 SendMessageA( hwnd, WM_CHAR, dbch[0], 0 );
10063 ok_sequence( WmEmptySeq, "no messages", FALSE );
10064 SendMessageA( hwnd, WM_CHAR, dbch[1], 0 );
10065 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
10066 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10068 /* sent message with timeout */
10070 SendMessageTimeoutA( hwnd, WM_CHAR, dbch[0], 0, SMTO_NORMAL, 0, &res );
10071 ok_sequence( WmEmptySeq, "no messages", FALSE );
10072 SendMessageTimeoutA( hwnd, WM_CHAR, dbch[1], 0, SMTO_NORMAL, 0, &res );
10073 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
10074 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10076 /* sent message with timeout and callback */
10078 SendMessageTimeoutA( hwnd, WM_CHAR, dbch[0], 0, SMTO_NORMAL, 0, &res );
10079 ok_sequence( WmEmptySeq, "no messages", FALSE );
10080 SendMessageCallbackA( hwnd, WM_CHAR, dbch[1], 0, NULL, 0 );
10081 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
10082 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10084 /* sent message with callback */
10086 SendNotifyMessageA( hwnd, WM_CHAR, dbch[0], 0 );
10087 ok_sequence( WmEmptySeq, "no messages", FALSE );
10088 SendMessageCallbackA( hwnd, WM_CHAR, dbch[1], 0, NULL, 0 );
10089 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
10090 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10092 /* direct window proc call */
10094 CallWindowProcA( (WNDPROC)GetWindowLongPtrA( hwnd, GWLP_WNDPROC ), hwnd, WM_CHAR, dbch[0], 0 );
10095 ok_sequence( WmEmptySeq, "no messages", FALSE );
10096 CallWindowProcA( (WNDPROC)GetWindowLongPtrA( hwnd, GWLP_WNDPROC ), hwnd, WM_CHAR, dbch[1], 0 );
10097 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
10099 /* dispatch message */
10101 msg.message = WM_CHAR;
10102 msg.wParam = dbch[0];
10104 DispatchMessageA( &msg );
10105 ok_sequence( WmEmptySeq, "no messages", FALSE );
10106 msg.wParam = dbch[1];
10107 DispatchMessageA( &msg );
10108 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
10110 /* window handle is irrelevant */
10112 SendMessageA( hwnd2, WM_CHAR, dbch[0], 0 );
10113 ok_sequence( WmEmptySeq, "no messages", FALSE );
10114 SendMessageA( hwnd, WM_CHAR, dbch[1], 0 );
10115 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
10116 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10118 /* interleaved post and send */
10120 PostMessageA( hwnd2, WM_CHAR, dbch[0], 0 );
10121 SendMessageA( hwnd2, WM_CHAR, dbch[0], 0 );
10122 ok_sequence( WmEmptySeq, "no messages", FALSE );
10123 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10124 PostMessageA( hwnd, WM_CHAR, dbch[1], 0 );
10125 ok_sequence( WmEmptySeq, "no messages", FALSE );
10126 ok( PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "no message\n" );
10127 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
10128 ok( msg.wParam == wch, "bad wparam %lx/%x\n", msg.wParam, wch );
10129 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10130 SendMessageA( hwnd, WM_CHAR, dbch[1], 0 );
10131 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
10132 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10134 /* interleaved sent message and winproc */
10136 SendMessageA( hwnd, WM_CHAR, dbch[0], 0 );
10137 CallWindowProcA( (WNDPROC)GetWindowLongPtrA( hwnd, GWLP_WNDPROC ), hwnd, WM_CHAR, dbch[0], 0 );
10138 ok_sequence( WmEmptySeq, "no messages", FALSE );
10139 SendMessageA( hwnd, WM_CHAR, dbch[1], 0 );
10140 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
10141 CallWindowProcA( (WNDPROC)GetWindowLongPtrA( hwnd, GWLP_WNDPROC ), hwnd, WM_CHAR, dbch[1], 0 );
10142 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
10144 /* interleaved winproc and dispatch */
10146 msg.message = WM_CHAR;
10147 msg.wParam = dbch[0];
10149 CallWindowProcA( (WNDPROC)GetWindowLongPtrA( hwnd, GWLP_WNDPROC ), hwnd, WM_CHAR, dbch[0], 0 );
10150 DispatchMessageA( &msg );
10151 ok_sequence( WmEmptySeq, "no messages", FALSE );
10152 msg.wParam = dbch[1];
10153 DispatchMessageA( &msg );
10154 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
10155 CallWindowProcA( (WNDPROC)GetWindowLongPtrA( hwnd, GWLP_WNDPROC ), hwnd, WM_CHAR, dbch[1], 0 );
10156 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
10158 /* interleaved sends */
10160 SendMessageA( hwnd, WM_CHAR, dbch[0], 0 );
10161 SendMessageCallbackA( hwnd, WM_CHAR, dbch[0], 0, NULL, 0 );
10162 ok_sequence( WmEmptySeq, "no messages", FALSE );
10163 SendMessageTimeoutA( hwnd, WM_CHAR, dbch[1], 0, SMTO_NORMAL, 0, &res );
10164 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
10165 SendMessageA( hwnd, WM_CHAR, dbch[1], 0 );
10166 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
10170 SendMessageA( hwnd2, WM_CHAR, (dbch[1] << 8) | dbch[0], 0 );
10171 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
10172 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10174 /* other char messages are not magic */
10175 PostMessageA( hwnd, WM_SYSCHAR, dbch[0], 0 );
10176 ok( PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "no message\n" );
10177 ok( msg.message == WM_SYSCHAR, "unexpected message %x\n", msg.message );
10178 ok( msg.wParam == bad_wch, "bad wparam %lx/%x\n", msg.wParam, bad_wch );
10179 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10180 PostMessageA( hwnd, WM_DEADCHAR, dbch[0], 0 );
10181 ok( PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "no message\n" );
10182 ok( msg.message == WM_DEADCHAR, "unexpected message %x\n", msg.message );
10183 ok( msg.wParam == bad_wch, "bad wparam %lx/%x\n", msg.wParam, bad_wch );
10184 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10186 /* test retrieving messages */
10188 PostMessageW( hwnd, WM_CHAR, wch, 0 );
10189 ok( PeekMessageA( &msg, hwnd, 0, 0, PM_REMOVE ), "no message\n" );
10190 ok( msg.hwnd == hwnd, "unexpected hwnd %p\n", msg.hwnd );
10191 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
10192 ok( msg.wParam == dbch[0], "bad wparam %lx/%x\n", msg.wParam, dbch[0] );
10193 ok( PeekMessageA( &msg, hwnd, 0, 0, PM_REMOVE ), "no message\n" );
10194 ok( msg.hwnd == hwnd, "unexpected hwnd %p\n", msg.hwnd );
10195 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
10196 ok( msg.wParam == dbch[1], "bad wparam %lx/%x\n", msg.wParam, dbch[0] );
10197 ok( !PeekMessageA( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10199 /* message filters */
10200 PostMessageW( hwnd, WM_CHAR, wch, 0 );
10201 ok( PeekMessageA( &msg, hwnd, 0, 0, PM_REMOVE ), "no message\n" );
10202 ok( msg.hwnd == hwnd, "unexpected hwnd %p\n", msg.hwnd );
10203 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
10204 ok( msg.wParam == dbch[0], "bad wparam %lx/%x\n", msg.wParam, dbch[0] );
10205 /* message id is filtered, hwnd is not */
10206 ok( !PeekMessageA( &msg, hwnd, WM_MOUSEFIRST, WM_MOUSELAST, PM_REMOVE ), "no message\n" );
10207 ok( PeekMessageA( &msg, hwnd2, 0, 0, PM_REMOVE ), "no message\n" );
10208 ok( msg.hwnd == hwnd, "unexpected hwnd %p\n", msg.hwnd );
10209 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
10210 ok( msg.wParam == dbch[1], "bad wparam %lx/%x\n", msg.wParam, dbch[0] );
10211 ok( !PeekMessageA( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10213 /* mixing GetMessage and PostMessage */
10214 PostMessageW( hwnd, WM_CHAR, wch, 0xbeef );
10215 ok( GetMessageA( &msg, hwnd, 0, 0 ), "no message\n" );
10216 ok( msg.hwnd == hwnd, "unexpected hwnd %p\n", msg.hwnd );
10217 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
10218 ok( msg.wParam == dbch[0], "bad wparam %lx/%x\n", msg.wParam, dbch[0] );
10219 ok( msg.lParam == 0xbeef, "bad lparam %lx\n", msg.lParam );
10222 ok( time - GetTickCount() <= 100, "bad time %x\n", msg.time );
10223 ok( PeekMessageA( &msg, 0, 0, 0, PM_REMOVE ), "no message\n" );
10224 ok( msg.hwnd == hwnd, "unexpected hwnd %p\n", msg.hwnd );
10225 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
10226 ok( msg.wParam == dbch[1], "bad wparam %lx/%x\n", msg.wParam, dbch[0] );
10227 ok( msg.lParam == 0xbeef, "bad lparam %lx\n", msg.lParam );
10228 ok( msg.time == time, "bad time %x/%x\n", msg.time, time );
10229 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 );
10230 ok( !PeekMessageA( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10232 /* without PM_REMOVE */
10233 PostMessageW( hwnd, WM_CHAR, wch, 0 );
10234 ok( PeekMessageA( &msg, 0, 0, 0, PM_NOREMOVE ), "no message\n" );
10235 ok( msg.hwnd == hwnd, "unexpected hwnd %p\n", msg.hwnd );
10236 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
10237 ok( msg.wParam == dbch[0], "bad wparam %lx/%x\n", msg.wParam, dbch[0] );
10238 ok( PeekMessageA( &msg, 0, 0, 0, PM_REMOVE ), "no message\n" );
10239 ok( msg.hwnd == hwnd, "unexpected hwnd %p\n", msg.hwnd );
10240 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
10241 ok( msg.wParam == dbch[0], "bad wparam %lx/%x\n", msg.wParam, dbch[0] );
10242 ok( PeekMessageA( &msg, 0, 0, 0, PM_NOREMOVE ), "no message\n" );
10243 ok( msg.hwnd == hwnd, "unexpected hwnd %p\n", msg.hwnd );
10244 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
10245 ok( msg.wParam == dbch[1], "bad wparam %lx/%x\n", msg.wParam, dbch[0] );
10246 ok( PeekMessageA( &msg, 0, 0, 0, PM_REMOVE ), "no message\n" );
10247 ok( msg.hwnd == hwnd, "unexpected hwnd %p\n", msg.hwnd );
10248 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
10249 ok( msg.wParam == dbch[1], "bad wparam %lx/%x\n", msg.wParam, dbch[0] );
10250 ok( !PeekMessageA( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10252 DestroyWindow(hwnd);
10255 #define ID_LISTBOX 0x000f
10257 static const struct message wm_lb_setcursel_0[] =
10259 { LB_SETCURSEL, sent|wparam|lparam, 0, 0 },
10260 { WM_CTLCOLORLISTBOX, sent|parent },
10261 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_LISTBOX, 0x000120f2 },
10262 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 1 },
10263 { EVENT_OBJECT_SELECTION, winevent_hook|wparam|lparam, OBJID_CLIENT, 1 },
10266 static const struct message wm_lb_setcursel_1[] =
10268 { LB_SETCURSEL, sent|wparam|lparam, 1, 0 },
10269 { WM_CTLCOLORLISTBOX, sent|parent },
10270 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_LISTBOX, 0x000020f2 },
10271 { WM_CTLCOLORLISTBOX, sent|parent },
10272 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_LISTBOX, 0x000121f2 },
10273 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 2 },
10274 { EVENT_OBJECT_SELECTION, winevent_hook|wparam|lparam, OBJID_CLIENT, 2 },
10277 static const struct message wm_lb_setcursel_2[] =
10279 { LB_SETCURSEL, sent|wparam|lparam, 2, 0 },
10280 { WM_CTLCOLORLISTBOX, sent|parent },
10281 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_LISTBOX, 0x000021f2 },
10282 { WM_CTLCOLORLISTBOX, sent|parent },
10283 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_LISTBOX, 0x000122f2 },
10284 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 3 },
10285 { EVENT_OBJECT_SELECTION, winevent_hook|wparam|lparam, OBJID_CLIENT, 3 },
10288 static const struct message wm_lb_click_0[] =
10290 { WM_LBUTTONDOWN, sent|wparam|lparam, 0, MAKELPARAM(1,1) },
10291 { HCBT_SETFOCUS, hook },
10292 { WM_KILLFOCUS, sent|parent },
10293 { WM_IME_SETCONTEXT, sent|wparam|optional|parent, 0 },
10294 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
10295 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
10296 { WM_SETFOCUS, sent|defwinproc },
10298 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_LISTBOX, 0x001142f2 },
10299 { WM_COMMAND, sent|wparam|parent, MAKEWPARAM(ID_LISTBOX, LBN_SETFOCUS) },
10300 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 3 },
10301 { WM_LBTRACKPOINT, sent|wparam|lparam|parent, 0, MAKELPARAM(1,1) },
10302 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
10304 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_LISTBOX, 0x000142f2 },
10305 { WM_CTLCOLORLISTBOX, sent|parent },
10306 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_LISTBOX, 0x000022f2 },
10307 { WM_CTLCOLORLISTBOX, sent|parent },
10308 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_LISTBOX, 0x000120f2 },
10309 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_LISTBOX, 0x001140f2 },
10311 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 1 },
10312 { EVENT_OBJECT_SELECTION, winevent_hook|wparam|lparam, OBJID_CLIENT, 1 },
10314 { WM_LBUTTONUP, sent|wparam|lparam, 0, 0 },
10315 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, 0, 0 },
10316 { WM_CAPTURECHANGED, sent|wparam|lparam|defwinproc, 0, 0 },
10317 { WM_COMMAND, sent|wparam|parent, MAKEWPARAM(ID_LISTBOX, LBN_SELCHANGE) },
10321 #define check_lb_state(a1, a2, a3, a4, a5) check_lb_state_dbg(a1, a2, a3, a4, a5, __LINE__)
10323 static LRESULT (WINAPI *listbox_orig_proc)(HWND, UINT, WPARAM, LPARAM);
10325 static LRESULT WINAPI listbox_hook_proc(HWND hwnd, UINT message, WPARAM wp, LPARAM lp)
10327 static long defwndproc_counter = 0;
10329 struct message msg;
10331 /* do not log painting messages */
10332 if (message != WM_PAINT &&
10333 message != WM_NCPAINT &&
10334 message != WM_SYNCPAINT &&
10335 message != WM_ERASEBKGND &&
10336 message != WM_NCHITTEST &&
10337 message != WM_GETTEXT &&
10338 message != WM_GETICON &&
10339 message != WM_DEVICECHANGE)
10341 trace("listbox: %p, %04x, %08lx, %08lx\n", hwnd, message, wp, lp);
10343 msg.message = message;
10344 msg.flags = sent|wparam|lparam;
10345 if (defwndproc_counter) msg.flags |= defwinproc;
10351 defwndproc_counter++;
10352 ret = CallWindowProcA(listbox_orig_proc, hwnd, message, wp, lp);
10353 defwndproc_counter--;
10358 static void check_lb_state_dbg(HWND listbox, int count, int cur_sel,
10359 int caret_index, int top_index, int line)
10363 /* calling an orig proc helps to avoid unnecessary message logging */
10364 ret = CallWindowProcA(listbox_orig_proc, listbox, LB_GETCOUNT, 0, 0);
10365 ok_(__FILE__, line)(ret == count, "expected count %d, got %ld\n", count, ret);
10366 ret = CallWindowProcA(listbox_orig_proc, listbox, LB_GETCURSEL, 0, 0);
10367 ok_(__FILE__, line)(ret == cur_sel, "expected cur sel %d, got %ld\n", cur_sel, ret);
10368 ret = CallWindowProcA(listbox_orig_proc, listbox, LB_GETCARETINDEX, 0, 0);
10369 ok_(__FILE__, line)(ret == caret_index, "expected caret index %d, got %ld\n", caret_index, ret);
10370 ret = CallWindowProcA(listbox_orig_proc, listbox, LB_GETTOPINDEX, 0, 0);
10371 ok_(__FILE__, line)(ret == top_index, "expected top index %d, got %ld\n", top_index, ret);
10374 static void test_listbox_messages(void)
10376 HWND parent, listbox;
10379 parent = CreateWindowExA(0, "TestParentClass", NULL, WS_OVERLAPPEDWINDOW | WS_VISIBLE,
10380 100, 100, 200, 200, 0, 0, 0, NULL);
10381 listbox = CreateWindowExA(WS_EX_NOPARENTNOTIFY, "ListBox", NULL,
10382 WS_CHILD | LBS_NOTIFY | LBS_OWNERDRAWVARIABLE | LBS_HASSTRINGS | WS_VISIBLE,
10383 10, 10, 80, 80, parent, (HMENU)ID_LISTBOX, 0, NULL);
10384 listbox_orig_proc = (WNDPROC)SetWindowLongPtrA(listbox, GWLP_WNDPROC, (ULONG_PTR)listbox_hook_proc);
10386 check_lb_state(listbox, 0, LB_ERR, 0, 0);
10388 ret = SendMessage(listbox, LB_ADDSTRING, 0, (LPARAM)"item 0");
10389 ok(ret == 0, "expected 0, got %ld\n", ret);
10390 ret = SendMessage(listbox, LB_ADDSTRING, 0, (LPARAM)"item 1");
10391 ok(ret == 1, "expected 1, got %ld\n", ret);
10392 ret = SendMessage(listbox, LB_ADDSTRING, 0, (LPARAM)"item 2");
10393 ok(ret == 2, "expected 2, got %ld\n", ret);
10395 check_lb_state(listbox, 3, LB_ERR, 0, 0);
10399 log_all_parent_messages++;
10401 trace("selecting item 0\n");
10402 ret = SendMessage(listbox, LB_SETCURSEL, 0, 0);
10403 ok(ret == 0, "expected 0, got %ld\n", ret);
10404 ok_sequence(wm_lb_setcursel_0, "LB_SETCURSEL 0", FALSE );
10405 check_lb_state(listbox, 3, 0, 0, 0);
10408 trace("selecting item 1\n");
10409 ret = SendMessage(listbox, LB_SETCURSEL, 1, 0);
10410 ok(ret == 1, "expected 1, got %ld\n", ret);
10411 ok_sequence(wm_lb_setcursel_1, "LB_SETCURSEL 1", FALSE );
10412 check_lb_state(listbox, 3, 1, 1, 0);
10414 trace("selecting item 2\n");
10415 ret = SendMessage(listbox, LB_SETCURSEL, 2, 0);
10416 ok(ret == 2, "expected 2, got %ld\n", ret);
10417 ok_sequence(wm_lb_setcursel_2, "LB_SETCURSEL 2", FALSE );
10418 check_lb_state(listbox, 3, 2, 2, 0);
10420 trace("clicking on item 0\n");
10421 ret = SendMessage(listbox, WM_LBUTTONDOWN, 0, MAKELPARAM(1, 1));
10422 ok(ret == LB_OKAY, "expected LB_OKAY, got %ld\n", ret);
10423 ret = SendMessage(listbox, WM_LBUTTONUP, 0, 0);
10424 ok(ret == LB_OKAY, "expected LB_OKAY, got %ld\n", ret);
10425 ok_sequence(wm_lb_click_0, "WM_LBUTTONDOWN 0", FALSE );
10426 check_lb_state(listbox, 3, 0, 0, 0);
10429 log_all_parent_messages--;
10431 DestroyWindow(listbox);
10432 DestroyWindow(parent);
10435 /*************************** Menu test ******************************/
10436 static const struct message wm_popup_menu_1[] =
10438 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0x20000001 },
10439 { WM_SYSKEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
10440 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'E', 0x20000001 },
10441 { WM_SYSKEYDOWN, sent|wparam|lparam, 'E', 0x20000001 },
10442 { WM_SYSCHAR, sent|wparam|lparam, 'e', 0x20000001 },
10443 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_KEYMENU, 'e' },
10444 { WM_ENTERMENULOOP, sent|wparam|lparam, 0, 0 },
10445 { WM_INITMENU, sent|lparam, 0, 0 },
10446 { WM_MENUSELECT, sent|wparam, MAKEWPARAM(1,MF_HILITE|MF_POPUP) },
10447 { WM_INITMENUPOPUP, sent|lparam, 0, 1 },
10448 { HCBT_CREATEWND, hook|optional }, /* Win9x doesn't create a window */
10449 { WM_MENUSELECT, sent|wparam, MAKEWPARAM(200,MF_HILITE) },
10450 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'E', 0xf0000001 },
10451 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0xd0000001 },
10452 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_RETURN, 0x10000001 },
10453 { HCBT_DESTROYWND, hook|optional }, /* Win9x doesn't create a window */
10454 { WM_UNINITMENUPOPUP, sent|lparam, 0, 0 },
10455 { WM_MENUSELECT, sent|wparam|lparam, MAKEWPARAM(0,0xffff), 0 },
10456 { WM_EXITMENULOOP, sent|wparam|lparam, 0, 0 },
10457 { WM_MENUCOMMAND, sent }, /* |wparam, 200 - Win9x */
10458 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_RETURN, 0xc0000001 },
10459 { WM_KEYUP, sent|wparam|lparam, VK_RETURN, 0xc0000001 },
10462 static const struct message wm_popup_menu_2[] =
10464 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0x20000001 },
10465 { WM_SYSKEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
10466 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'F', 0x20000001 },
10467 { WM_SYSKEYDOWN, sent|wparam|lparam, 'F', 0x20000001 },
10468 { WM_SYSCHAR, sent|wparam|lparam, 'f', 0x20000001 },
10469 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_KEYMENU, 'f' },
10470 { WM_ENTERMENULOOP, sent|wparam|lparam, 0, 0 },
10471 { WM_INITMENU, sent|lparam, 0, 0 },
10472 { WM_MENUSELECT, sent|wparam, MAKEWPARAM(0,MF_HILITE|MF_POPUP) },
10473 { WM_INITMENUPOPUP, sent|lparam, 0, 0 },
10474 { WM_MENUSELECT, sent|wparam|optional, MAKEWPARAM(0,MF_HILITE|MF_POPUP) }, /* Win9x */
10475 { WM_INITMENUPOPUP, sent|lparam|optional, 0, 0 }, /* Win9x */
10476 { HCBT_CREATEWND, hook },
10477 { WM_MENUSELECT, sent }, /*|wparam, MAKEWPARAM(0,MF_HILITE|MF_POPUP) - XP
10478 |wparam, MAKEWPARAM(100,MF_HILITE) - Win9x */
10479 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'F', 0xf0000001 },
10480 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0xd0000001 },
10481 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_RIGHT, 0x10000001 },
10482 { WM_INITMENUPOPUP, sent|lparam|optional, 0, 0 }, /* Win9x doesn't send it */
10483 { HCBT_CREATEWND, hook|optional }, /* Win9x doesn't send it */
10484 { WM_MENUSELECT, sent|wparam|optional, MAKEWPARAM(100,MF_HILITE) },
10485 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_RIGHT, 0xd0000001 },
10486 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_RETURN, 0x10000001 },
10487 { HCBT_DESTROYWND, hook },
10488 { WM_UNINITMENUPOPUP, sent|lparam, 0, 0 },
10489 { HCBT_DESTROYWND, hook|optional }, /* Win9x doesn't send it */
10490 { WM_UNINITMENUPOPUP, sent|lparam, 0, 0 },
10491 { WM_MENUSELECT, sent|wparam|lparam, MAKEWPARAM(0,0xffff), 0 },
10492 { WM_EXITMENULOOP, sent|wparam|lparam, 0, 0 },
10493 { WM_MENUCOMMAND, sent }, /* |wparam, 100 - Win9x */
10494 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_RETURN, 0xc0000001 },
10495 { WM_KEYUP, sent|wparam|lparam, VK_RETURN, 0xc0000001 },
10498 static const struct message wm_popup_menu_3[] =
10500 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0x20000001 },
10501 { WM_SYSKEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
10502 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'F', 0x20000001 },
10503 { WM_SYSKEYDOWN, sent|wparam|lparam, 'F', 0x20000001 },
10504 { WM_SYSCHAR, sent|wparam|lparam, 'f', 0x20000001 },
10505 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_KEYMENU, 'f' },
10506 { WM_ENTERMENULOOP, sent|wparam|lparam, 0, 0 },
10507 { WM_INITMENU, sent|lparam, 0, 0 },
10508 { WM_MENUSELECT, sent|wparam, MAKEWPARAM(0,MF_HILITE|MF_POPUP) },
10509 { WM_INITMENUPOPUP, sent|lparam, 0, 0 },
10510 { WM_MENUSELECT, sent|wparam|optional, MAKEWPARAM(0,MF_HILITE|MF_POPUP) }, /* Win9x */
10511 { WM_INITMENUPOPUP, sent|lparam|optional, 0, 0 }, /* Win9x */
10512 { HCBT_CREATEWND, hook },
10513 { WM_MENUSELECT, sent }, /*|wparam, MAKEWPARAM(0,MF_HILITE|MF_POPUP) - XP
10514 |wparam, MAKEWPARAM(100,MF_HILITE) - Win9x */
10515 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'F', 0xf0000001 },
10516 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0xd0000001 },
10517 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_RIGHT, 0x10000001 },
10518 { WM_INITMENUPOPUP, sent|lparam|optional, 0, 0 }, /* Win9x doesn't send it */
10519 { HCBT_CREATEWND, hook|optional }, /* Win9x doesn't send it */
10520 { WM_MENUSELECT, sent|wparam|optional, MAKEWPARAM(100,MF_HILITE) },
10521 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_RIGHT, 0xd0000001 },
10522 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_RETURN, 0x10000001 },
10523 { HCBT_DESTROYWND, hook },
10524 { WM_UNINITMENUPOPUP, sent|lparam, 0, 0 },
10525 { HCBT_DESTROYWND, hook|optional }, /* Win9x doesn't send it */
10526 { WM_UNINITMENUPOPUP, sent|lparam, 0, 0 },
10527 { WM_MENUSELECT, sent|wparam|lparam, MAKEWPARAM(0,0xffff), 0 },
10528 { WM_EXITMENULOOP, sent|wparam|lparam, 0, 0 },
10529 { WM_COMMAND, sent|wparam|lparam, 100, 0 },
10530 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_RETURN, 0xc0000001 },
10531 { WM_KEYUP, sent|wparam|lparam, VK_RETURN, 0xc0000001 },
10535 static LRESULT WINAPI parent_menu_proc(HWND hwnd, UINT message, WPARAM wp, LPARAM lp)
10537 if (message == WM_ENTERIDLE ||
10538 message == WM_INITMENU ||
10539 message == WM_INITMENUPOPUP ||
10540 message == WM_MENUSELECT ||
10541 message == WM_PARENTNOTIFY ||
10542 message == WM_ENTERMENULOOP ||
10543 message == WM_EXITMENULOOP ||
10544 message == WM_UNINITMENUPOPUP ||
10545 message == WM_KEYDOWN ||
10546 message == WM_KEYUP ||
10547 message == WM_CHAR ||
10548 message == WM_SYSKEYDOWN ||
10549 message == WM_SYSKEYUP ||
10550 message == WM_SYSCHAR ||
10551 message == WM_COMMAND ||
10552 message == WM_MENUCOMMAND)
10554 struct message msg;
10556 trace("parent_menu_proc: %p, %04x, %08lx, %08lx\n", hwnd, message, wp, lp);
10558 msg.message = message;
10559 msg.flags = sent|wparam|lparam;
10565 return DefWindowProcA(hwnd, message, wp, lp);
10568 static void set_menu_style(HMENU hmenu, DWORD style)
10573 mi.cbSize = sizeof(mi);
10574 mi.fMask = MIM_STYLE;
10575 mi.dwStyle = style;
10576 SetLastError(0xdeadbeef);
10577 ret = SetMenuInfo(hmenu, &mi);
10578 ok(ret, "SetMenuInfo error %u\n", GetLastError());
10581 static DWORD get_menu_style(HMENU hmenu)
10586 mi.cbSize = sizeof(mi);
10587 mi.fMask = MIM_STYLE;
10589 SetLastError(0xdeadbeef);
10590 ret = GetMenuInfo(hmenu, &mi);
10591 ok(ret, "GetMenuInfo error %u\n", GetLastError());
10596 static void test_menu_messages(void)
10600 HMENU hmenu, hmenu_popup;
10605 cls.lpfnWndProc = parent_menu_proc;
10606 cls.cbClsExtra = 0;
10607 cls.cbWndExtra = 0;
10608 cls.hInstance = GetModuleHandleA(0);
10610 cls.hCursor = LoadCursorA(0, (LPSTR)IDC_ARROW);
10611 cls.hbrBackground = GetStockObject(WHITE_BRUSH);
10612 cls.lpszMenuName = NULL;
10613 cls.lpszClassName = "TestMenuClass";
10614 UnregisterClass(cls.lpszClassName, cls.hInstance);
10615 if (!RegisterClassA(&cls)) assert(0);
10617 SetLastError(0xdeadbeef);
10618 hwnd = CreateWindowExA(0, "TestMenuClass", NULL, WS_OVERLAPPEDWINDOW | WS_VISIBLE,
10619 100, 100, 200, 200, 0, 0, 0, NULL);
10620 ok(hwnd != 0, "LoadMenuA error %u\n", GetLastError());
10622 SetLastError(0xdeadbeef);
10623 hmenu = LoadMenuA(GetModuleHandle(0), MAKEINTRESOURCE(1));
10624 ok(hmenu != 0, "LoadMenuA error %u\n", GetLastError());
10626 SetMenu(hwnd, hmenu);
10628 set_menu_style(hmenu, MNS_NOTIFYBYPOS);
10629 style = get_menu_style(hmenu);
10630 ok(style == MNS_NOTIFYBYPOS, "expected MNS_NOTIFYBYPOS, got %u\n", style);
10632 hmenu_popup = GetSubMenu(hmenu, 0);
10633 ok(hmenu_popup != 0, "GetSubMenu returned 0 for submenu 0\n");
10634 style = get_menu_style(hmenu_popup);
10635 ok(style == 0, "expected 0, got %u\n", style);
10637 hmenu_popup = GetSubMenu(hmenu_popup, 0);
10638 ok(hmenu_popup != 0, "GetSubMenu returned 0 for submenu 0\n");
10639 style = get_menu_style(hmenu_popup);
10640 ok(style == 0, "expected 0, got %u\n", style);
10643 trace("testing a popup menu command\n");
10645 keybd_event(VK_MENU, 0, 0, 0);
10646 keybd_event('E', 0, 0, 0);
10647 keybd_event('E', 0, KEYEVENTF_KEYUP, 0);
10648 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
10649 keybd_event(VK_RETURN, 0, 0, 0);
10650 keybd_event(VK_RETURN, 0, KEYEVENTF_KEYUP, 0);
10651 while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
10653 TranslateMessage(&msg);
10654 DispatchMessage(&msg);
10656 ok_sequence(wm_popup_menu_1, "popup menu command", FALSE);
10658 /* Alt+F, Right, Enter */
10659 trace("testing submenu of a popup menu command\n");
10661 keybd_event(VK_MENU, 0, 0, 0);
10662 keybd_event('F', 0, 0, 0);
10663 keybd_event('F', 0, KEYEVENTF_KEYUP, 0);
10664 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
10665 keybd_event(VK_RIGHT, 0, 0, 0);
10666 keybd_event(VK_RIGHT, 0, KEYEVENTF_KEYUP, 0);
10667 keybd_event(VK_RETURN, 0, 0, 0);
10668 keybd_event(VK_RETURN, 0, KEYEVENTF_KEYUP, 0);
10669 while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
10671 TranslateMessage(&msg);
10672 DispatchMessage(&msg);
10674 ok_sequence(wm_popup_menu_2, "submenu of a popup menu command", FALSE);
10676 set_menu_style(hmenu, 0);
10677 style = get_menu_style(hmenu);
10678 ok(style == 0, "expected MNS_NOTIFYBYPOS, got %u\n", style);
10680 hmenu_popup = GetSubMenu(hmenu, 0);
10681 ok(hmenu_popup != 0, "GetSubMenu returned 0 for submenu 0\n");
10682 set_menu_style(hmenu_popup, MNS_NOTIFYBYPOS);
10683 style = get_menu_style(hmenu_popup);
10684 ok(style == MNS_NOTIFYBYPOS, "expected MNS_NOTIFYBYPOS, got %u\n", style);
10686 hmenu_popup = GetSubMenu(hmenu_popup, 0);
10687 ok(hmenu_popup != 0, "GetSubMenu returned 0 for submenu 0\n");
10688 style = get_menu_style(hmenu_popup);
10689 ok(style == 0, "expected 0, got %u\n", style);
10691 /* Alt+F, Right, Enter */
10692 trace("testing submenu of a popup menu command\n");
10694 keybd_event(VK_MENU, 0, 0, 0);
10695 keybd_event('F', 0, 0, 0);
10696 keybd_event('F', 0, KEYEVENTF_KEYUP, 0);
10697 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
10698 keybd_event(VK_RIGHT, 0, 0, 0);
10699 keybd_event(VK_RIGHT, 0, KEYEVENTF_KEYUP, 0);
10700 keybd_event(VK_RETURN, 0, 0, 0);
10701 keybd_event(VK_RETURN, 0, KEYEVENTF_KEYUP, 0);
10702 while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
10704 TranslateMessage(&msg);
10705 DispatchMessage(&msg);
10707 ok_sequence(wm_popup_menu_3, "submenu of a popup menu command", FALSE);
10709 DestroyWindow(hwnd);
10710 DestroyMenu(hmenu);
10716 FARPROC pIsWinEventHookInstalled = 0;/*GetProcAddress(user32, "IsWinEventHookInstalled");*/
10720 if (!RegisterWindowClasses()) assert(0);
10722 if (pSetWinEventHook)
10724 hEvent_hook = (HWINEVENTHOOK)pSetWinEventHook(EVENT_MIN, EVENT_MAX,
10725 GetModuleHandleA(0),
10728 GetCurrentThreadId(),
10729 WINEVENT_INCONTEXT);
10730 assert(hEvent_hook);
10732 if (pIsWinEventHookInstalled)
10735 for (event = EVENT_MIN; event <= EVENT_MAX; event++)
10736 ok(pIsWinEventHookInstalled(event), "IsWinEventHookInstalled(%u) failed\n", event);
10740 cbt_hook_thread_id = GetCurrentThreadId();
10741 hCBT_hook = SetWindowsHookExA(WH_CBT, cbt_hook_proc, 0, GetCurrentThreadId());
10746 /* Fix message sequences before removing 4 lines below */
10748 if (pUnhookWinEvent && hEvent_hook)
10750 ret = pUnhookWinEvent(hEvent_hook);
10751 ok( ret, "UnhookWinEvent error %d\n", GetLastError());
10752 pUnhookWinEvent = 0;
10758 test_PeekMessage();
10759 test_PeekMessage2();
10760 test_scrollwindowex();
10763 invisible_parent_tests();
10764 test_mdi_messages();
10765 test_button_messages();
10766 test_static_messages();
10767 test_listbox_messages();
10768 test_combobox_messages();
10769 test_wmime_keydown_message();
10770 test_paint_messages();
10771 test_interthread_messages();
10772 test_message_conversion();
10773 test_accelerators();
10775 test_timers_no_wnd();
10777 test_DestroyWindow();
10778 test_DispatchMessage();
10779 test_SendMessageTimeout();
10780 test_edit_messages();
10781 test_quit_message();
10783 if (!pTrackMouseEvent)
10784 skip("TrackMouseEvent is not available\n");
10786 test_TrackMouseEvent();
10788 test_SetWindowRgn();
10790 test_dialog_messages();
10791 test_nullCallback();
10792 test_SetForegroundWindow();
10793 test_dbcs_wm_char();
10794 test_menu_messages();
10796 UnhookWindowsHookEx(hCBT_hook);
10797 if (pUnhookWinEvent)
10799 ret = pUnhookWinEvent(hEvent_hook);
10800 ok( ret, "UnhookWinEvent error %d\n", GetLastError());
10801 SetLastError(0xdeadbeef);
10802 ok(!pUnhookWinEvent(hEvent_hook), "UnhookWinEvent succeeded\n");
10803 ok(GetLastError() == ERROR_INVALID_HANDLE || /* Win2k */
10804 GetLastError() == 0xdeadbeef, /* Win9x */
10805 "unexpected error %d\n", GetLastError());
10808 skip("UnhookWinEvent is not available\n");