push 5dd2d658b972a733854ca32020d79186875eac82
[wine/hacks.git] / dlls / user32 / tests / msg.c
bloba86698757f76a8a8c638163bc4d80ff8d1df0ada
1 /*
2 * Unit tests for window message handling
4 * Copyright 1999 Ove Kaaven
5 * Copyright 2003 Dimitrie O. Paun
6 * Copyright 2004, 2005 Dmitry Timoshkov
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #include <assert.h>
24 #include <stdarg.h>
25 #include <stdio.h>
27 #define _WIN32_WINNT 0x0501 /* For WM_CHANGEUISTATE,QS_RAWINPUT */
29 #include "windef.h"
30 #include "winbase.h"
31 #include "wingdi.h"
32 #include "winuser.h"
33 #include "winnls.h"
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 */
46 #ifndef WM_KEYF1
47 #define WM_KEYF1 0x004d
48 #endif
50 #ifndef WM_SYSTIMER
51 #define WM_SYSTIMER 0x0118
52 #endif
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
60 #endif
62 /* encoded DRAWITEMSTRUCT into an LPARAM */
63 typedef struct
65 union
67 struct
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 */
74 } item;
75 LPARAM lp;
76 } u;
77 } DRAW_ITEM_STRUCT;
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
97 typedef enum {
98 sent=0x1,
99 posted=0x2,
100 parent=0x4,
101 wparam=0x8,
102 lparam=0x10,
103 defwinproc=0x20,
104 beginpaint=0x40,
105 optional=0x80,
106 hook=0x100,
107 winevent_hook=0x200
108 } msg_flags_t;
110 struct message {
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[] =
120 { 0 }
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 },
131 { WM_CREATE, sent },
132 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
133 { 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 },
166 { 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 },
175 { 0 }
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 */
196 { 0 }
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 },
216 { 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 },
227 { 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 },
248 { 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|0x8000 }, /* 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|0x8000 },/* 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|0x8000 }, /* 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 */
303 { 0 }
306 /* SetWindowPos(SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|
307 SWP_NOZORDER|SWP_FRAMECHANGED)
308 * for a visible overlapped window with WS_CLIPCHILDREN style set.
310 static const struct message WmSWP_FrameChanged_clip[] = {
311 { WM_WINDOWPOSCHANGING, sent|wparam|parent, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED },
312 { WM_NCCALCSIZE, sent|wparam|parent, 1 },
313 { WM_NCPAINT, sent|parent }, /* wparam != 1 */
314 { WM_GETTEXT, sent|parent|defwinproc|optional },
315 { WM_ERASEBKGND, sent|parent|optional }, /* FIXME: remove optional once Wine is fixed */
316 { WM_NCPAINT, sent }, /* wparam != 1 */
317 { WM_ERASEBKGND, sent },
318 { WM_WINDOWPOSCHANGED, sent|wparam|parent, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
319 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
320 { WM_PAINT, sent },
321 { 0 }
323 /* SetWindowPos(SWP_NOSIZE|SWP_NOMOVE|SWP_DEFERERASE|SWP_NOACTIVATE|
324 SWP_NOZORDER|SWP_FRAMECHANGED)
325 * for a visible overlapped window.
327 static const struct message WmSWP_FrameChangedDeferErase[] = {
328 { WM_WINDOWPOSCHANGING, sent|wparam|parent, SWP_NOSIZE|SWP_NOMOVE|SWP_DEFERERASE|SWP_NOACTIVATE|SWP_FRAMECHANGED },
329 { WM_NCCALCSIZE, sent|wparam|parent, 1 },
330 { WM_WINDOWPOSCHANGED, sent|wparam|parent, SWP_NOSIZE|SWP_NOMOVE|SWP_DEFERERASE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
331 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
332 { WM_PAINT, sent|parent },
333 { WM_NCPAINT, sent|beginpaint|parent }, /* wparam != 1 */
334 { WM_GETTEXT, sent|beginpaint|parent|defwinproc|optional },
335 { WM_PAINT, sent },
336 { WM_NCPAINT, sent|beginpaint }, /* wparam != 1 */
337 { WM_ERASEBKGND, sent|beginpaint },
338 { 0 }
341 /* SetWindowPos(SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|
342 SWP_NOZORDER|SWP_FRAMECHANGED)
343 * for a visible overlapped window without WS_CLIPCHILDREN style set.
345 static const struct message WmSWP_FrameChanged_noclip[] = {
346 { WM_WINDOWPOSCHANGING, sent|wparam|parent, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED },
347 { WM_NCCALCSIZE, sent|wparam|parent, 1 },
348 { WM_NCPAINT, sent|parent }, /* wparam != 1 */
349 { WM_GETTEXT, sent|parent|defwinproc|optional },
350 { WM_ERASEBKGND, sent|parent|optional }, /* FIXME: remove optional once Wine is fixed */
351 { WM_WINDOWPOSCHANGED, sent|wparam|parent, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
352 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
353 { WM_PAINT, sent },
354 { WM_NCPAINT, sent|beginpaint }, /* wparam != 1 */
355 { WM_ERASEBKGND, sent|beginpaint },
356 { 0 }
359 /* ShowWindow(SW_SHOW) for a not visible overlapped window */
360 static const struct message WmShowOverlappedSeq[] = {
361 { WM_SHOWWINDOW, sent|wparam, 1 },
362 { WM_NCPAINT, sent|wparam|optional, 1 },
363 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
364 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
365 { WM_NCPAINT, sent|wparam|optional, 1 },
366 { WM_GETTEXT, sent|defwinproc|optional },
367 { WM_ERASEBKGND, sent|optional },
368 { HCBT_ACTIVATE, hook },
369 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
370 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
371 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE },
372 { WM_NCPAINT, sent|wparam|optional, 1 },
373 { WM_ACTIVATEAPP, sent|wparam, 1 },
374 { WM_NCACTIVATE, sent|wparam, 1 },
375 { WM_GETTEXT, sent|defwinproc|optional },
376 { WM_ACTIVATE, sent|wparam, 1 },
377 { HCBT_SETFOCUS, hook },
378 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
379 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
380 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
381 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
382 { WM_NCPAINT, sent|wparam|optional, 1 },
383 { WM_GETTEXT, sent|defwinproc|optional },
384 { WM_ERASEBKGND, sent|optional },
385 /* Win9x adds SWP_NOZORDER below */
386 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
387 { WM_NCCALCSIZE, sent|optional },
388 { WM_NCPAINT, sent|optional },
389 { WM_ERASEBKGND, sent|optional },
390 #if 0 /* CreateWindow/ShowWindow(SW_SHOW) also generates WM_SIZE/WM_MOVE
391 * messages. Does that mean that CreateWindow doesn't set initial
392 * window dimensions for overlapped windows?
394 { WM_SIZE, sent },
395 { WM_MOVE, sent },
396 #endif
397 { 0 }
399 /* ShowWindow(SW_SHOWMAXIMIZED) for a not visible overlapped window */
400 static const struct message WmShowMaxOverlappedSeq[] = {
401 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
402 { WM_GETMINMAXINFO, sent },
403 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|0x8000 },
404 { WM_GETMINMAXINFO, sent|defwinproc },
405 { WM_NCCALCSIZE, sent|wparam, TRUE },
406 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
407 { HCBT_ACTIVATE, hook },
408 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
409 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
410 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE },
411 { WM_ACTIVATEAPP, sent|wparam, 1 },
412 { WM_NCACTIVATE, sent|wparam, 1 },
413 { WM_GETTEXT, sent|defwinproc|optional },
414 { WM_ACTIVATE, sent|wparam, 1 },
415 { HCBT_SETFOCUS, hook },
416 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
417 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
418 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
419 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
420 { WM_NCPAINT, sent|wparam|optional, 1 },
421 { WM_GETTEXT, sent|defwinproc|optional },
422 { WM_ERASEBKGND, sent|optional },
423 /* Win9x adds SWP_NOZORDER below */
424 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|0x8000 },
425 { WM_MOVE, sent|defwinproc },
426 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
427 { WM_NCCALCSIZE, sent|optional },
428 { WM_NCPAINT, sent|optional },
429 { WM_ERASEBKGND, sent|optional },
430 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
431 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
432 { 0 }
434 /* ShowWindow(SW_SHOWMINIMIZED) for a not visible overlapped window */
435 static const struct message WmShowMinOverlappedSeq[] = {
436 { HCBT_MINMAX, hook|lparam, 0, SW_MINIMIZE },
437 { HCBT_SETFOCUS, hook },
438 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
439 { WM_KILLFOCUS, sent },
440 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
441 { WM_IME_NOTIFY, sent|wparam|optional|defwinproc, 1 },
442 { WM_GETTEXT, sent|optional },
443 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOCOPYBITS|SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_STATECHANGED },
444 { WM_GETMINMAXINFO, sent|defwinproc },
445 { WM_NCCALCSIZE, sent|wparam, TRUE },
446 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
447 { WM_NCPAINT, sent },
448 { WM_GETTEXT, sent|defwinproc|optional },
449 { WM_WINDOWPOSCHANGED, sent },
450 { WM_MOVE, sent|defwinproc },
451 { WM_SIZE, sent|defwinproc|wparam, SIZE_MINIMIZED },
452 { WM_NCCALCSIZE, sent|optional },
453 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
454 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
455 { EVENT_SYSTEM_MINIMIZESTART, winevent_hook|wparam|lparam, 0, 0 },
456 { WM_NCACTIVATE, sent|wparam, 0 },
457 { WM_GETTEXT, sent|defwinproc|optional },
458 { WM_ACTIVATE, sent },
459 { WM_ACTIVATEAPP, sent|wparam, 0 },
460 { 0 }
462 /* ShowWindow(SW_HIDE) for a visible overlapped window */
463 static const struct message WmHideOverlappedSeq[] = {
464 { WM_SHOWWINDOW, sent|wparam, 0 },
465 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE },
466 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
467 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
468 { WM_SIZE, sent|optional }, /* XP doesn't send it */
469 { WM_MOVE, sent|optional }, /* XP doesn't send it */
470 { WM_NCACTIVATE, sent|wparam, 0 },
471 { WM_ACTIVATE, sent|wparam, 0 },
472 { WM_ACTIVATEAPP, sent|wparam, 0 },
473 { WM_KILLFOCUS, sent|wparam, 0 },
474 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
475 { WM_IME_NOTIFY, sent|wparam|optional|defwinproc, 1 },
476 { 0 }
478 /* DestroyWindow for a visible overlapped window */
479 static const struct message WmDestroyOverlappedSeq[] = {
480 { HCBT_DESTROYWND, hook },
481 { 0x0090, sent|optional },
482 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
483 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
484 { 0x0090, sent|optional },
485 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
486 { WM_NCACTIVATE, sent|wparam, 0 },
487 { WM_ACTIVATE, sent|wparam, 0 },
488 { WM_ACTIVATEAPP, sent|wparam, 0 },
489 { WM_KILLFOCUS, sent|wparam, 0 },
490 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
491 { WM_IME_NOTIFY, sent|wparam|optional|defwinproc, 1 },
492 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
493 { WM_DESTROY, sent },
494 { WM_NCDESTROY, sent },
495 { 0 }
497 /* CreateWindow(WS_MAXIMIZE|WS_VISIBLE) for popup window */
498 static const struct message WmCreateMaxPopupSeq[] = {
499 { HCBT_CREATEWND, hook },
500 { WM_NCCREATE, sent },
501 { WM_NCCALCSIZE, sent|wparam, 0 },
502 { WM_CREATE, sent },
503 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
504 { WM_SIZE, sent|wparam, SIZE_RESTORED },
505 { WM_MOVE, sent },
506 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
507 { WM_GETMINMAXINFO, sent },
508 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|0x8000 },
509 { WM_NCCALCSIZE, sent|wparam, TRUE },
510 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOREDRAW|0x8000 },
511 { WM_MOVE, sent|defwinproc },
512 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
513 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
514 { WM_SHOWWINDOW, sent|wparam, 1 },
515 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
516 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
517 { HCBT_ACTIVATE, hook },
518 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
519 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
520 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE },
521 { WM_ACTIVATEAPP, sent|wparam, 1 },
522 { WM_NCACTIVATE, sent|wparam, 1 },
523 { WM_ACTIVATE, sent|wparam, 1 },
524 { HCBT_SETFOCUS, hook },
525 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
526 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
527 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
528 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
529 { WM_SYNCPAINT, sent|wparam|optional, 4 },
530 { WM_NCPAINT, sent|wparam|optional, 1 },
531 { WM_ERASEBKGND, sent|optional },
532 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOCLIENTMOVE|SWP_NOCLIENTSIZE|SWP_SHOWWINDOW|SWP_NOMOVE|SWP_NOSIZE },
533 { 0 }
535 /* CreateWindow(WS_MAXIMIZE) for popup window, not initially visible */
536 static const struct message WmCreateInvisibleMaxPopupSeq[] = {
537 { HCBT_CREATEWND, hook },
538 { WM_NCCREATE, sent },
539 { WM_NCCALCSIZE, sent|wparam, 0 },
540 { WM_CREATE, sent },
541 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
542 { WM_SIZE, sent|wparam, SIZE_RESTORED },
543 { WM_MOVE, sent },
544 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
545 { WM_GETMINMAXINFO, sent },
546 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|0x8000 },
547 { WM_NCCALCSIZE, sent|wparam, TRUE },
548 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOREDRAW|0x8000 },
549 { WM_MOVE, sent|defwinproc },
550 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
551 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
552 { 0 }
554 /* ShowWindow(SW_SHOWMAXIMIZED) for a resized not visible popup window */
555 static const struct message WmShowMaxPopupResizedSeq[] = {
556 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
557 { WM_GETMINMAXINFO, sent },
558 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED },
559 { WM_NCCALCSIZE, sent|wparam, TRUE },
560 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
561 { HCBT_ACTIVATE, hook },
562 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
563 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
564 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE },
565 { WM_ACTIVATEAPP, sent|wparam, 1 },
566 { WM_NCACTIVATE, sent|wparam, 1 },
567 { WM_ACTIVATE, sent|wparam, 1 },
568 { HCBT_SETFOCUS, hook },
569 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
570 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
571 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
572 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
573 { WM_NCPAINT, sent|wparam|optional, 1 },
574 { WM_ERASEBKGND, sent|optional },
575 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOCLIENTMOVE|SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOMOVE },
576 /* WinNT4.0 sends WM_MOVE */
577 { WM_MOVE, sent|defwinproc|optional },
578 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
579 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
580 { 0 }
582 /* ShowWindow(SW_SHOWMAXIMIZED) for a not visible popup window */
583 static const struct message WmShowMaxPopupSeq[] = {
584 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
585 { WM_GETMINMAXINFO, sent },
586 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED },
587 { WM_NCCALCSIZE, sent|wparam, TRUE },
588 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
589 { HCBT_ACTIVATE, hook },
590 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
591 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
592 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE },
593 { WM_ACTIVATEAPP, sent|wparam, 1 },
594 { WM_NCACTIVATE, sent|wparam, 1 },
595 { WM_ACTIVATE, sent|wparam, 1 },
596 { HCBT_SETFOCUS, hook },
597 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
598 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
599 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
600 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
601 { WM_SYNCPAINT, sent|wparam|optional, 4 },
602 { WM_NCPAINT, sent|wparam|optional, 1 },
603 { WM_ERASEBKGND, sent|optional },
604 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOMOVE|SWP_NOSIZE },
605 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
606 { 0 }
608 /* CreateWindow(WS_VISIBLE) for popup window */
609 static const struct message WmCreatePopupSeq[] = {
610 { HCBT_CREATEWND, hook },
611 { WM_NCCREATE, sent },
612 { WM_NCCALCSIZE, sent|wparam, 0 },
613 { WM_CREATE, sent },
614 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
615 { WM_SIZE, sent|wparam, SIZE_RESTORED },
616 { WM_MOVE, sent },
617 { WM_SHOWWINDOW, sent|wparam, 1 },
618 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
619 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
620 { HCBT_ACTIVATE, hook },
621 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
622 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
623 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE },
624 { WM_NCPAINT, sent|wparam|optional, 1 },
625 { WM_ERASEBKGND, sent|optional },
626 { WM_ACTIVATEAPP, sent|wparam, 1 },
627 { WM_NCACTIVATE, sent|wparam, 1 },
628 { WM_ACTIVATE, sent|wparam, 1 },
629 { HCBT_SETFOCUS, hook },
630 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
631 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
632 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
633 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
634 { WM_SYNCPAINT, sent|wparam|optional, 4 },
635 { WM_NCPAINT, sent|wparam|optional, 1 },
636 { WM_ERASEBKGND, sent|optional },
637 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOCLIENTMOVE|SWP_NOCLIENTSIZE|SWP_SHOWWINDOW|SWP_NOMOVE|SWP_NOSIZE },
638 { 0 }
640 /* ShowWindow(SW_SHOWMAXIMIZED) for a visible popup window */
641 static const struct message WmShowVisMaxPopupSeq[] = {
642 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
643 { WM_GETMINMAXINFO, sent },
644 { WM_GETTEXT, sent|optional },
645 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|0x8000 },
646 { WM_NCCALCSIZE, sent|wparam, TRUE },
647 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
648 { WM_NCPAINT, sent|wparam|optional, 1 },
649 { WM_ERASEBKGND, sent|optional },
650 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|0x8000 },
651 { WM_MOVE, sent|defwinproc },
652 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
653 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
654 { 0 }
656 /* CreateWindow (for a child popup window, not initially visible) */
657 static const struct message WmCreateChildPopupSeq[] = {
658 { HCBT_CREATEWND, hook },
659 { WM_NCCREATE, sent },
660 { WM_NCCALCSIZE, sent|wparam, 0 },
661 { WM_CREATE, sent },
662 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
663 { WM_SIZE, sent|wparam, SIZE_RESTORED },
664 { WM_MOVE, sent },
665 { 0 }
667 /* CreateWindow (for a popup window, not initially visible,
668 * which sets WS_VISIBLE in WM_CREATE handler)
670 static const struct message WmCreateInvisiblePopupSeq[] = {
671 { HCBT_CREATEWND, hook },
672 { WM_NCCREATE, sent },
673 { WM_NCCALCSIZE, sent|wparam, 0 },
674 { WM_CREATE, sent },
675 { WM_STYLECHANGING, sent },
676 { WM_STYLECHANGED, sent },
677 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
678 { WM_SIZE, sent|wparam, SIZE_RESTORED },
679 { WM_MOVE, sent },
680 { 0 }
682 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER)
683 * for a popup window with WS_VISIBLE style set
685 static const struct message WmShowVisiblePopupSeq_2[] = {
686 { WM_WINDOWPOSCHANGING, sent|wparam, 0 },
687 { 0 }
689 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
690 * for a popup window with WS_VISIBLE style set
692 static const struct message WmShowVisiblePopupSeq_3[] = {
693 { WM_WINDOWPOSCHANGING, sent|wparam, 0 },
694 { HCBT_ACTIVATE, hook },
695 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
696 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
697 { WM_WINDOWPOSCHANGING, sent|wparam, 0 },
698 { WM_NCACTIVATE, sent|wparam, 1 },
699 { WM_ACTIVATE, sent|wparam, 1 },
700 { HCBT_SETFOCUS, hook },
701 { WM_KILLFOCUS, sent|parent },
702 { WM_IME_SETCONTEXT, sent|parent|wparam|optional, 0 },
703 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
704 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
705 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
706 { WM_SETFOCUS, sent|defwinproc },
707 { 0 }
709 /* CreateWindow (for child window, not initially visible) */
710 static const struct message WmCreateChildSeq[] = {
711 { HCBT_CREATEWND, hook },
712 { WM_NCCREATE, sent },
713 /* child is inserted into parent's child list after WM_NCCREATE returns */
714 { WM_NCCALCSIZE, sent|wparam, 0 },
715 { WM_CREATE, sent },
716 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
717 { WM_SIZE, sent|wparam, SIZE_RESTORED },
718 { WM_MOVE, sent },
719 { WM_PARENTNOTIFY, sent|parent|wparam, WM_CREATE },
720 { 0 }
722 /* CreateWindow (for maximized child window, not initially visible) */
723 static const struct message WmCreateMaximizedChildSeq[] = {
724 { HCBT_CREATEWND, hook },
725 { WM_NCCREATE, sent },
726 { WM_NCCALCSIZE, sent|wparam, 0 },
727 { WM_CREATE, sent },
728 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
729 { WM_SIZE, sent|wparam, SIZE_RESTORED },
730 { WM_MOVE, sent },
731 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
732 { WM_GETMINMAXINFO, sent },
733 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|0x8000 },
734 { WM_NCCALCSIZE, sent|wparam, 1 },
735 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTMOVE|0x8000 },
736 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
737 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
738 { WM_PARENTNOTIFY, sent|parent|wparam, WM_CREATE },
739 { 0 }
741 /* CreateWindow (for a child window, initially visible) */
742 static const struct message WmCreateVisibleChildSeq[] = {
743 { HCBT_CREATEWND, hook },
744 { WM_NCCREATE, sent },
745 /* child is inserted into parent's child list after WM_NCCREATE returns */
746 { WM_NCCALCSIZE, sent|wparam, 0 },
747 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
748 { WM_CREATE, sent },
749 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
750 { WM_SIZE, sent|wparam, SIZE_RESTORED },
751 { WM_MOVE, sent },
752 { WM_PARENTNOTIFY, sent|parent|wparam, WM_CREATE },
753 { WM_SHOWWINDOW, sent|wparam, 1 },
754 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
755 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
756 { WM_ERASEBKGND, sent|parent|optional },
757 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
758 { WM_NCCALCSIZE, sent|wparam|optional, 1 }, /* WinXP */
759 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
760 { 0 }
762 /* ShowWindow(SW_SHOW) for a not visible child window */
763 static const struct message WmShowChildSeq[] = {
764 { WM_SHOWWINDOW, sent|wparam, 1 },
765 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
766 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
767 { WM_ERASEBKGND, sent|parent|optional },
768 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
769 { 0 }
771 /* ShowWindow(SW_HIDE) for a visible child window */
772 static const struct message WmHideChildSeq[] = {
773 { WM_SHOWWINDOW, sent|wparam, 0 },
774 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
775 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
776 { WM_ERASEBKGND, sent|parent|optional },
777 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
778 { 0 }
780 /* ShowWindow(SW_HIDE) for a visible child window checking all parent events*/
781 static const struct message WmHideChildSeq2[] = {
782 { WM_SHOWWINDOW, sent|wparam, 0 },
783 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
784 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
785 { WM_ERASEBKGND, sent|parent },
786 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
787 { 0 }
789 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
790 * for a not visible child window
792 static const struct message WmShowChildSeq_2[] = {
793 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
794 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
795 { WM_CHILDACTIVATE, sent },
796 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
797 { 0 }
799 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE)
800 * for a not visible child window
802 static const struct message WmShowChildSeq_3[] = {
803 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
804 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
805 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
806 { 0 }
808 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
809 * for a visible child window with a caption
811 static const struct message WmShowChildSeq_4[] = {
812 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
813 { WM_CHILDACTIVATE, sent },
814 { 0 }
816 /* ShowWindow(SW_MINIMIZE) for child with invisible parent */
817 static const struct message WmShowChildInvisibleParentSeq_1[] = {
818 { HCBT_MINMAX, hook|lparam, 0, SW_MINIMIZE },
819 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOCOPYBITS|0x8000 },
820 { WM_NCCALCSIZE, sent|wparam, 1 },
821 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
822 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOREDRAW|SWP_NOCOPYBITS|0x8000 },
823 { WM_MOVE, sent|defwinproc },
824 { WM_SIZE, sent|defwinproc|wparam, SIZE_MINIMIZED },
825 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
826 { EVENT_SYSTEM_MINIMIZESTART, winevent_hook|wparam|lparam, 0, 0 },
827 /* FIXME: Wine creates an icon/title window while Windows doesn't */
828 { WM_PARENTNOTIFY, sent|parent|wparam|optional, WM_CREATE },
829 { WM_GETTEXT, sent|optional },
830 { 0 }
832 /* repeated ShowWindow(SW_MINIMIZE) for child with invisible parent */
833 static const struct message WmShowChildInvisibleParentSeq_1r[] = {
834 { HCBT_MINMAX, hook|lparam, 0, SW_MINIMIZE },
835 { 0 }
837 /* ShowWindow(SW_MAXIMIZE) for child with invisible parent */
838 static const struct message WmShowChildInvisibleParentSeq_2[] = {
839 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
840 { WM_GETMINMAXINFO, sent },
841 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|0x8000 },
842 { WM_NCCALCSIZE, sent|wparam, 1 },
843 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
844 { WM_CHILDACTIVATE, sent },
845 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTMOVE|0x8000 },
846 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
847 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
848 { 0 }
850 /* repeated ShowWindow(SW_MAXIMIZE) for child with invisible parent */
851 static const struct message WmShowChildInvisibleParentSeq_2r[] = {
852 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
853 { 0 }
855 /* ShowWindow(SW_SHOWMINIMIZED) for child with invisible parent */
856 static const struct message WmShowChildInvisibleParentSeq_3[] = {
857 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMINIMIZED },
858 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOCOPYBITS|0x8000 },
859 { WM_NCCALCSIZE, sent|wparam, 1 },
860 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
861 { WM_CHILDACTIVATE, sent },
862 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOREDRAW|SWP_NOCOPYBITS|0x8000 },
863 { WM_MOVE, sent|defwinproc },
864 { WM_SIZE, sent|defwinproc|wparam, SIZE_MINIMIZED },
865 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
866 { EVENT_SYSTEM_MINIMIZESTART, winevent_hook|wparam|lparam, 0, 0 },
867 /* FIXME: Wine creates an icon/title window while Windows doesn't */
868 { WM_PARENTNOTIFY, sent|parent|wparam|optional, WM_CREATE },
869 { WM_GETTEXT, sent|optional },
870 { 0 }
872 /* repeated ShowWindow(SW_SHOWMINIMIZED) for child with invisible parent */
873 static const struct message WmShowChildInvisibleParentSeq_3r[] = {
874 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMINIMIZED },
875 { 0 }
877 /* ShowWindow(SW_SHOWMINNOACTIVE) for child with invisible parent */
878 static const struct message WmShowChildInvisibleParentSeq_4[] = {
879 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMINNOACTIVE },
880 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOCOPYBITS|0x8000 },
881 { WM_NCCALCSIZE, sent|wparam, 1 },
882 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
883 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOREDRAW|SWP_NOCOPYBITS|0x8000 },
884 { WM_MOVE, sent|defwinproc },
885 { WM_SIZE, sent|defwinproc|wparam, SIZE_MINIMIZED },
886 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
887 { EVENT_SYSTEM_MINIMIZESTART, winevent_hook|wparam|lparam, 0, 0 },
888 /* FIXME: Wine creates an icon/title window while Windows doesn't */
889 { WM_PARENTNOTIFY, sent|parent|wparam|optional, WM_CREATE },
890 { WM_GETTEXT, sent|optional },
891 { 0 }
893 /* repeated ShowWindow(SW_SHOWMINNOACTIVE) for child with invisible parent */
894 static const struct message WmShowChildInvisibleParentSeq_4r[] = {
895 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMINNOACTIVE },
896 { 0 }
898 /* ShowWindow(SW_SHOW) for child with invisible parent */
899 static const struct message WmShowChildInvisibleParentSeq_5[] = {
900 { WM_SHOWWINDOW, sent|wparam, 1 },
901 { 0 }
903 /* ShowWindow(SW_HIDE) for child with invisible parent */
904 static const struct message WmHideChildInvisibleParentSeq[] = {
905 { WM_SHOWWINDOW, sent|wparam, 0 },
906 { 0 }
908 /* SetWindowPos(SWP_SHOWWINDOW) for child with invisible parent */
909 static const struct message WmShowChildInvisibleParentSeq_6[] = {
910 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
911 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
912 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
913 { 0 }
915 /* SetWindowPos(SWP_HIDEWINDOW) for child with invisible parent */
916 static const struct message WmHideChildInvisibleParentSeq_2[] = {
917 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
918 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
919 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
920 { 0 }
922 /* DestroyWindow for a visible child window */
923 static const struct message WmDestroyChildSeq[] = {
924 { HCBT_DESTROYWND, hook },
925 { 0x0090, sent|optional },
926 { WM_PARENTNOTIFY, sent|parent|wparam, WM_DESTROY },
927 { WM_SHOWWINDOW, sent|wparam, 0 },
928 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
929 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
930 { WM_ERASEBKGND, sent|parent|optional },
931 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
932 { HCBT_SETFOCUS, hook }, /* set focus to a parent */
933 { WM_KILLFOCUS, sent },
934 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
935 { WM_IME_SETCONTEXT, sent|wparam|parent|optional, 1 },
936 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
937 { WM_SETFOCUS, sent|parent },
938 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
939 { WM_DESTROY, sent },
940 { WM_DESTROY, sent|optional }, /* some other (IME?) window */
941 { WM_NCDESTROY, sent|optional }, /* some other (IME?) window */
942 { WM_NCDESTROY, sent },
943 { 0 }
945 /* DestroyWindow for a visible child window with invisible parent */
946 static const struct message WmDestroyInvisibleChildSeq[] = {
947 { HCBT_DESTROYWND, hook },
948 { 0x0090, sent|optional },
949 { WM_PARENTNOTIFY, sent|parent|wparam, WM_DESTROY },
950 { WM_SHOWWINDOW, sent|wparam, 0 },
951 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
952 { WM_DESTROY, sent },
953 { WM_NCDESTROY, sent },
954 { 0 }
956 /* Moving the mouse in nonclient area */
957 static const struct message WmMouseMoveInNonClientAreaSeq[] = { /* FIXME: add */
958 { WM_NCHITTEST, sent },
959 { WM_SETCURSOR, sent },
960 { WM_NCMOUSEMOVE, posted },
961 { 0 }
963 /* Moving the mouse in client area */
964 static const struct message WmMouseMoveInClientAreaSeq[] = { /* FIXME: add */
965 { WM_NCHITTEST, sent },
966 { WM_SETCURSOR, sent },
967 { WM_MOUSEMOVE, posted },
968 { 0 }
970 /* Moving by dragging the title bar (after WM_NCHITTEST and WM_SETCURSOR) (outline move) */
971 static const struct message WmDragTitleBarSeq[] = { /* FIXME: add */
972 { WM_NCLBUTTONDOWN, sent|wparam, HTCAPTION },
973 { WM_SYSCOMMAND, sent|defwinproc|wparam, SC_MOVE+2 },
974 { WM_GETMINMAXINFO, sent|defwinproc },
975 { WM_ENTERSIZEMOVE, sent|defwinproc },
976 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, 0 },
977 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, 0 },
978 { WM_MOVE, sent|defwinproc },
979 { WM_EXITSIZEMOVE, sent|defwinproc },
980 { 0 }
982 /* Sizing by dragging the thick borders (after WM_NCHITTEST and WM_SETCURSOR) (outline move) */
983 static const struct message WmDragThickBordersBarSeq[] = { /* FIXME: add */
984 { WM_NCLBUTTONDOWN, sent|wparam, 0xd },
985 { WM_SYSCOMMAND, sent|defwinproc|wparam, 0xf004 },
986 { WM_GETMINMAXINFO, sent|defwinproc },
987 { WM_ENTERSIZEMOVE, sent|defwinproc },
988 { WM_SIZING, sent|defwinproc|wparam, 4}, /* one for each mouse movement */
989 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, 0 },
990 { WM_GETMINMAXINFO, sent|defwinproc },
991 { WM_NCCALCSIZE, sent|defwinproc|wparam, 1 },
992 { WM_NCPAINT, sent|defwinproc|wparam, 1 },
993 { WM_GETTEXT, sent|defwinproc },
994 { WM_ERASEBKGND, sent|defwinproc },
995 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, 0 },
996 { WM_MOVE, sent|defwinproc },
997 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
998 { WM_EXITSIZEMOVE, sent|defwinproc },
999 { 0 }
1001 /* Resizing child window with MoveWindow (32) */
1002 static const struct message WmResizingChildWithMoveWindowSeq[] = {
1003 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE },
1004 { WM_NCCALCSIZE, sent|wparam, 1 },
1005 { WM_ERASEBKGND, sent|parent|optional },
1006 { WM_ERASEBKGND, sent|optional },
1007 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE },
1008 { WM_MOVE, sent|defwinproc },
1009 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
1010 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1011 { 0 }
1013 /* Clicking on inactive button */
1014 static const struct message WmClickInactiveButtonSeq[] = { /* FIXME: add */
1015 { WM_NCHITTEST, sent },
1016 { WM_PARENTNOTIFY, sent|parent|wparam, WM_LBUTTONDOWN },
1017 { WM_MOUSEACTIVATE, sent },
1018 { WM_MOUSEACTIVATE, sent|parent|defwinproc },
1019 { WM_SETCURSOR, sent },
1020 { WM_SETCURSOR, sent|parent|defwinproc },
1021 { WM_LBUTTONDOWN, posted },
1022 { WM_KILLFOCUS, posted|parent },
1023 { WM_SETFOCUS, posted },
1024 { WM_CTLCOLORBTN, posted|parent },
1025 { BM_SETSTATE, posted },
1026 { WM_CTLCOLORBTN, posted|parent },
1027 { WM_LBUTTONUP, posted },
1028 { BM_SETSTATE, posted },
1029 { WM_CTLCOLORBTN, posted|parent },
1030 { WM_COMMAND, posted|parent },
1031 { 0 }
1033 /* Reparenting a button (16/32) */
1034 /* The last child (button) reparented gets topmost for its new parent. */
1035 static const struct message WmReparentButtonSeq[] = { /* FIXME: add */
1036 { WM_SHOWWINDOW, sent|wparam, 0 },
1037 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE },
1038 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
1039 { WM_ERASEBKGND, sent|parent },
1040 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE },
1041 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE },
1042 { WM_CHILDACTIVATE, sent },
1043 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOSIZE|SWP_NOREDRAW },
1044 { WM_MOVE, sent|defwinproc },
1045 { WM_SHOWWINDOW, sent|wparam, 1 },
1046 { 0 }
1048 /* Creation of a custom dialog (32) */
1049 static const struct message WmCreateCustomDialogSeq[] = {
1050 { HCBT_CREATEWND, hook },
1051 { WM_GETMINMAXINFO, sent },
1052 { WM_NCCREATE, sent },
1053 { WM_NCCALCSIZE, sent|wparam, 0 },
1054 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
1055 { WM_CREATE, sent },
1056 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1057 { WM_SHOWWINDOW, sent|wparam, 1 },
1058 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
1059 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1060 { HCBT_ACTIVATE, hook },
1061 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
1064 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
1066 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE },
1068 { WM_NCACTIVATE, sent|wparam, 1 },
1069 { WM_GETTEXT, sent|optional|defwinproc },
1070 { WM_GETTEXT, sent|optional|defwinproc },
1071 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
1072 { WM_ACTIVATE, sent|wparam, 1 },
1073 { WM_KILLFOCUS, sent|parent },
1074 { WM_IME_SETCONTEXT, sent|parent|wparam|optional, 0 },
1075 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
1076 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
1077 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1078 { WM_SETFOCUS, sent },
1079 { WM_GETDLGCODE, sent|defwinproc|wparam, 0 },
1080 { WM_NCPAINT, sent|wparam, 1 },
1081 { WM_GETTEXT, sent|optional|defwinproc },
1082 { WM_GETTEXT, sent|optional|defwinproc },
1083 { WM_ERASEBKGND, sent },
1084 { WM_CTLCOLORDLG, sent|defwinproc },
1085 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1086 { WM_GETTEXT, sent|optional },
1087 { WM_GETTEXT, sent|optional },
1088 { WM_NCCALCSIZE, sent|optional },
1089 { WM_NCPAINT, sent|optional },
1090 { WM_GETTEXT, sent|optional|defwinproc },
1091 { WM_GETTEXT, sent|optional|defwinproc },
1092 { WM_ERASEBKGND, sent|optional },
1093 { WM_CTLCOLORDLG, sent|optional|defwinproc },
1094 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1095 { WM_SIZE, sent|wparam, SIZE_RESTORED },
1096 { WM_MOVE, sent },
1097 { 0 }
1099 /* Calling EndDialog for a custom dialog (32) */
1100 static const struct message WmEndCustomDialogSeq[] = {
1101 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1102 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
1103 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1104 { WM_GETTEXT, sent|optional },
1105 { HCBT_ACTIVATE, hook },
1106 { WM_NCACTIVATE, sent|wparam, 0 },
1107 { WM_GETTEXT, sent|optional|defwinproc },
1108 { WM_GETTEXT, sent|optional|defwinproc },
1109 { WM_ACTIVATE, sent|wparam, 0 },
1110 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
1111 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1112 { HCBT_SETFOCUS, hook },
1113 { WM_KILLFOCUS, sent },
1114 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
1115 { WM_IME_SETCONTEXT, sent|parent|wparam|defwinproc|optional, 1 },
1116 { WM_IME_NOTIFY, sent|wparam|optional, 1 },
1117 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1118 { WM_SETFOCUS, sent|parent|defwinproc },
1119 { 0 }
1121 /* ShowWindow(SW_SHOW) for a custom dialog (initially invisible) */
1122 static const struct message WmShowCustomDialogSeq[] = {
1123 { WM_SHOWWINDOW, sent|wparam, 1 },
1124 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
1125 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1126 { HCBT_ACTIVATE, hook },
1127 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
1129 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
1131 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE },
1132 { WM_ACTIVATEAPP, sent|wparam|optional, 1 },
1133 { WM_NCACTIVATE, sent|wparam, 1 },
1134 { WM_ACTIVATE, sent|wparam, 1 },
1136 { WM_KILLFOCUS, sent|parent },
1137 { WM_IME_SETCONTEXT, sent|parent|wparam|optional, 0 },
1138 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
1139 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
1140 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1141 { WM_SETFOCUS, sent },
1142 { WM_GETDLGCODE, sent|defwinproc|wparam, 0 },
1143 { WM_NCPAINT, sent|wparam, 1 },
1144 { WM_ERASEBKGND, sent },
1145 { WM_CTLCOLORDLG, sent|defwinproc },
1146 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1147 { 0 }
1149 /* Creation and destruction of a modal dialog (32) */
1150 static const struct message WmModalDialogSeq[] = {
1151 { WM_CANCELMODE, sent|parent },
1152 { HCBT_SETFOCUS, hook },
1153 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1154 { WM_KILLFOCUS, sent|parent },
1155 { WM_IME_SETCONTEXT, sent|parent|wparam|optional, 0 },
1156 { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, 0, 0 },
1157 { WM_ENABLE, sent|parent|wparam, 0 },
1158 { HCBT_CREATEWND, hook },
1159 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
1160 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1161 { WM_SETFONT, sent },
1162 { WM_INITDIALOG, sent },
1163 { WM_CHANGEUISTATE, sent|optional },
1164 { WM_UPDATEUISTATE, sent|optional },
1165 { WM_SHOWWINDOW, sent },
1166 { HCBT_ACTIVATE, hook },
1167 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
1168 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
1169 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE },
1170 { WM_NCACTIVATE, sent|wparam, 1 },
1171 { WM_GETTEXT, sent|optional },
1172 { WM_ACTIVATE, sent|wparam, 1 },
1173 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
1174 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1175 { WM_NCPAINT, sent },
1176 { WM_GETTEXT, sent|optional },
1177 { WM_ERASEBKGND, sent },
1178 { WM_CTLCOLORDLG, sent },
1179 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1180 { WM_GETTEXT, sent|optional },
1181 { WM_NCCALCSIZE, sent|optional },
1182 { WM_NCPAINT, sent|optional },
1183 { WM_GETTEXT, sent|optional },
1184 { WM_ERASEBKGND, sent|optional },
1185 { WM_CTLCOLORDLG, sent|optional },
1186 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1187 { WM_PAINT, sent|optional },
1188 { WM_CTLCOLORBTN, sent },
1189 { WM_ENTERIDLE, sent|parent|optional },
1190 { WM_ENTERIDLE, sent|parent|optional },
1191 { WM_ENTERIDLE, sent|parent|optional },
1192 { WM_ENTERIDLE, sent|parent|optional },
1193 { WM_ENTERIDLE, sent|parent|optional },
1194 { WM_ENTERIDLE, sent|parent|optional },
1195 { WM_ENTERIDLE, sent|parent|optional },
1196 { WM_ENTERIDLE, sent|parent|optional },
1197 { WM_ENTERIDLE, sent|parent|optional },
1198 { WM_ENTERIDLE, sent|parent|optional },
1199 { WM_ENTERIDLE, sent|parent|optional },
1200 { WM_ENTERIDLE, sent|parent|optional },
1201 { WM_ENTERIDLE, sent|parent|optional },
1202 { WM_ENTERIDLE, sent|parent|optional },
1203 { WM_ENTERIDLE, sent|parent|optional },
1204 { WM_ENTERIDLE, sent|parent|optional },
1205 { WM_ENTERIDLE, sent|parent|optional },
1206 { WM_ENTERIDLE, sent|parent|optional },
1207 { WM_ENTERIDLE, sent|parent|optional },
1208 { WM_ENTERIDLE, sent|parent|optional },
1209 { WM_TIMER, sent },
1210 { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, 0, 0 },
1211 { WM_ENABLE, sent|parent|wparam, 1 },
1212 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
1213 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
1214 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1215 { WM_GETTEXT, sent|optional },
1216 { HCBT_ACTIVATE, hook },
1217 { WM_NCACTIVATE, sent|wparam, 0 },
1218 { WM_GETTEXT, sent|optional },
1219 { WM_ACTIVATE, sent|wparam, 0 },
1220 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
1221 { WM_WINDOWPOSCHANGING, sent|optional },
1222 { HCBT_SETFOCUS, hook },
1223 { WM_IME_SETCONTEXT, sent|parent|wparam|defwinproc|optional, 1 },
1224 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1225 { WM_SETFOCUS, sent|parent|defwinproc },
1226 { EVENT_SYSTEM_DIALOGEND, winevent_hook|wparam|lparam, 0, 0 },
1227 { HCBT_DESTROYWND, hook },
1228 { 0x0090, sent|optional },
1229 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
1230 { WM_DESTROY, sent },
1231 { WM_NCDESTROY, sent },
1232 { 0 }
1234 /* Creation of a modal dialog that is resized inside WM_INITDIALOG (32) */
1235 static const struct message WmCreateModalDialogResizeSeq[] = { /* FIXME: add */
1236 /* (inside dialog proc, handling WM_INITDIALOG) */
1237 { WM_WINDOWPOSCHANGING, sent|wparam, 0 },
1238 { WM_NCCALCSIZE, sent },
1239 { WM_NCACTIVATE, sent|parent|wparam, 0 },
1240 { WM_GETTEXT, sent|defwinproc },
1241 { WM_ACTIVATE, sent|parent|wparam, 0 },
1242 { WM_WINDOWPOSCHANGING, sent|wparam, 0 },
1243 { WM_WINDOWPOSCHANGING, sent|parent },
1244 { WM_NCACTIVATE, sent|wparam, 1 },
1245 { WM_ACTIVATE, sent|wparam, 1 },
1246 { WM_WINDOWPOSCHANGED, sent|wparam, 0 },
1247 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
1248 /* (setting focus) */
1249 { WM_SHOWWINDOW, sent|wparam, 1 },
1250 { WM_WINDOWPOSCHANGING, sent|wparam, 0 },
1251 { WM_NCPAINT, sent },
1252 { WM_GETTEXT, sent|defwinproc },
1253 { WM_ERASEBKGND, sent },
1254 { WM_CTLCOLORDLG, sent|defwinproc },
1255 { WM_WINDOWPOSCHANGED, sent|wparam, 0 },
1256 { WM_PAINT, sent },
1257 /* (bunch of WM_CTLCOLOR* for each control) */
1258 { WM_PAINT, sent|parent },
1259 { WM_ENTERIDLE, sent|parent|wparam, 0 },
1260 { WM_SETCURSOR, sent|parent },
1261 { 0 }
1263 /* SetMenu for NonVisible windows with size change*/
1264 static const struct message WmSetMenuNonVisibleSizeChangeSeq[] = {
1265 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1266 { WM_NCCALCSIZE, sent|wparam, 1 },
1267 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
1268 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW },
1269 { WM_MOVE, sent|defwinproc },
1270 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
1271 { WM_NCCALCSIZE,sent|wparam|optional, 1 }, /* XP */
1272 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1273 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* XP sends a duplicate */
1274 { WM_GETTEXT, sent|optional },
1275 { WM_NCCALCSIZE, sent|wparam|optional, 1 },
1276 { 0 }
1278 /* SetMenu for NonVisible windows with no size change */
1279 static const struct message WmSetMenuNonVisibleNoSizeChangeSeq[] = {
1280 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1281 { WM_NCCALCSIZE, sent|wparam, 1 },
1282 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1283 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1284 { 0 }
1286 /* SetMenu for Visible windows with size change */
1287 static const struct message WmSetMenuVisibleSizeChangeSeq[] = {
1288 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1289 { WM_NCCALCSIZE, sent|wparam, 1 },
1290 { 0x0093, sent|defwinproc|optional },
1291 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
1292 { WM_NCPAINT, sent }, /* wparam != 1 */
1293 { 0x0093, sent|defwinproc|optional },
1294 { 0x0093, sent|defwinproc|optional },
1295 { 0x0091, sent|defwinproc|optional },
1296 { 0x0092, sent|defwinproc|optional },
1297 { WM_GETTEXT, sent|defwinproc|optional },
1298 { WM_ERASEBKGND, sent|optional },
1299 { WM_ACTIVATE, sent|optional },
1300 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1301 { WM_MOVE, sent|defwinproc },
1302 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
1303 { 0x0093, sent|optional },
1304 { WM_NCCALCSIZE, sent|wparam|optional, 1 },
1305 { 0x0093, sent|defwinproc|optional },
1306 { WM_NCPAINT, sent|optional }, /* wparam != 1 */
1307 { 0x0093, sent|defwinproc|optional },
1308 { 0x0093, sent|defwinproc|optional },
1309 { 0x0091, sent|defwinproc|optional },
1310 { 0x0092, sent|defwinproc|optional },
1311 { WM_ERASEBKGND, sent|optional },
1312 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1313 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* XP sends a duplicate */
1314 { 0 }
1316 /* SetMenu for Visible windows with no size change */
1317 static const struct message WmSetMenuVisibleNoSizeChangeSeq[] = {
1318 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1319 { WM_NCCALCSIZE, sent|wparam, 1 },
1320 { WM_NCPAINT, sent }, /* wparam != 1 */
1321 { WM_GETTEXT, sent|defwinproc|optional },
1322 { WM_ERASEBKGND, sent|optional },
1323 { WM_ACTIVATE, sent|optional },
1324 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1325 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1326 { 0 }
1328 /* DrawMenuBar for a visible window */
1329 static const struct message WmDrawMenuBarSeq[] =
1331 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1332 { WM_NCCALCSIZE, sent|wparam, 1 },
1333 { 0x0093, sent|defwinproc|optional },
1334 { WM_NCPAINT, sent }, /* wparam != 1 */
1335 { 0x0093, sent|defwinproc|optional },
1336 { 0x0093, sent|defwinproc|optional },
1337 { 0x0091, sent|defwinproc|optional },
1338 { 0x0092, sent|defwinproc|optional },
1339 { WM_GETTEXT, sent|defwinproc|optional },
1340 { WM_ERASEBKGND, sent|optional },
1341 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1342 { 0x0093, sent|optional },
1343 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1344 { 0 }
1347 static const struct message WmSetRedrawFalseSeq[] =
1349 { WM_SETREDRAW, sent|wparam, 0 },
1350 { 0 }
1353 static const struct message WmSetRedrawTrueSeq[] =
1355 { WM_SETREDRAW, sent|wparam, 1 },
1356 { 0 }
1359 static const struct message WmEnableWindowSeq_1[] =
1361 { WM_CANCELMODE, sent|wparam|lparam, 0, 0 },
1362 { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, 0, 0 },
1363 { WM_ENABLE, sent|wparam|lparam, FALSE, 0 },
1364 { 0 }
1367 static const struct message WmEnableWindowSeq_2[] =
1369 { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, 0, 0 },
1370 { WM_ENABLE, sent|wparam|lparam, TRUE, 0 },
1371 { 0 }
1374 static const struct message WmGetScrollRangeSeq[] =
1376 { SBM_GETRANGE, sent },
1377 { 0 }
1379 static const struct message WmGetScrollInfoSeq[] =
1381 { SBM_GETSCROLLINFO, sent },
1382 { 0 }
1384 static const struct message WmSetScrollRangeSeq[] =
1386 /* MSDN claims that Windows sends SBM_SETRANGE message, but win2k SP4
1387 sends SBM_SETSCROLLINFO.
1389 { SBM_SETSCROLLINFO, sent },
1390 { 0 }
1392 /* SetScrollRange for a window without a non-client area */
1393 static const struct message WmSetScrollRangeHSeq_empty[] =
1395 { EVENT_OBJECT_VALUECHANGE, winevent_hook|wparam|lparam, OBJID_HSCROLL, 0 },
1396 { 0 }
1398 static const struct message WmSetScrollRangeVSeq_empty[] =
1400 { EVENT_OBJECT_VALUECHANGE, winevent_hook|wparam|lparam, OBJID_VSCROLL, 0 },
1401 { 0 }
1403 static const struct message WmSetScrollRangeHVSeq[] =
1405 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE },
1406 { WM_NCCALCSIZE, sent|wparam, 1 },
1407 { WM_GETTEXT, sent|defwinproc|optional },
1408 { WM_ERASEBKGND, sent|optional },
1409 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1410 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1411 { EVENT_OBJECT_VALUECHANGE, winevent_hook|lparam|optional, 0/*OBJID_HSCROLL or OBJID_VSCROLL*/, 0 },
1412 { 0 }
1414 /* SetScrollRange for a window with a non-client area */
1415 static const struct message WmSetScrollRangeHV_NC_Seq[] =
1417 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE },
1418 { WM_NCCALCSIZE, sent|wparam, 1 },
1419 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
1420 { WM_NCPAINT, sent|optional },
1421 { WM_STYLECHANGING, sent|defwinproc|optional },
1422 { WM_STYLECHANGED, sent|defwinproc|optional },
1423 { WM_STYLECHANGING, sent|defwinproc|optional },
1424 { WM_STYLECHANGED, sent|defwinproc|optional },
1425 { WM_STYLECHANGING, sent|defwinproc|optional },
1426 { WM_STYLECHANGED, sent|defwinproc|optional },
1427 { WM_STYLECHANGING, sent|defwinproc|optional },
1428 { WM_STYLECHANGED, sent|defwinproc|optional },
1429 { WM_GETTEXT, sent|defwinproc|optional },
1430 { WM_GETTEXT, sent|defwinproc|optional },
1431 { WM_ERASEBKGND, sent|optional },
1432 { WM_CTLCOLORDLG, sent|defwinproc|optional }, /* sent to a parent of the dialog */
1433 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE|SWP_NOCLIENTMOVE },
1434 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
1435 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1436 { EVENT_OBJECT_VALUECHANGE, winevent_hook|lparam|optional, 0/*OBJID_HSCROLL or OBJID_VSCROLL*/, 0 },
1437 { WM_GETTEXT, sent|optional },
1438 { WM_GETTEXT, sent|optional },
1439 { WM_GETTEXT, sent|optional },
1440 { WM_GETTEXT, sent|optional },
1441 { 0 }
1443 /* test if we receive the right sequence of messages */
1444 /* after calling ShowWindow( SW_SHOWNA) */
1445 static const struct message WmSHOWNAChildInvisParInvis[] = {
1446 { WM_SHOWWINDOW, sent|wparam, 1 },
1447 { 0 }
1449 static const struct message WmSHOWNAChildVisParInvis[] = {
1450 { WM_SHOWWINDOW, sent|wparam, 1 },
1451 { 0 }
1453 static const struct message WmSHOWNAChildVisParVis[] = {
1454 { WM_SHOWWINDOW, sent|wparam, 1 },
1455 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
1456 { 0 }
1458 static const struct message WmSHOWNAChildInvisParVis[] = {
1459 { WM_SHOWWINDOW, sent|wparam, 1 },
1460 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1461 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1462 { WM_ERASEBKGND, sent|optional },
1463 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOACTIVATE|SWP_NOCLIENTMOVE },
1464 { 0 }
1466 static const struct message WmSHOWNATopVisible[] = {
1467 { WM_SHOWWINDOW, sent|wparam, 1 },
1468 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
1469 { 0 }
1471 static const struct message WmSHOWNATopInvisible[] = {
1472 { WM_SHOWWINDOW, sent|wparam, 1 },
1473 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1474 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1475 { WM_NCPAINT, sent|wparam, 1 },
1476 { WM_GETTEXT, sent|defwinproc|optional },
1477 { WM_ERASEBKGND, sent|optional },
1478 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1479 { WM_NCCALCSIZE, sent|wparam|optional, 1 },
1480 { WM_NCPAINT, sent|wparam|optional, 1 },
1481 { WM_ERASEBKGND, sent|optional },
1482 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1483 { WM_SIZE, sent|wparam, SIZE_RESTORED },
1484 { WM_MOVE, sent },
1485 { 0 }
1488 static int after_end_dialog, test_def_id;
1489 static int sequence_cnt, sequence_size;
1490 static struct message* sequence;
1491 static int log_all_parent_messages;
1493 /* user32 functions */
1494 static HWND (WINAPI *pGetAncestor)(HWND,UINT);
1495 static void (WINAPI *pNotifyWinEvent)(DWORD, HWND, LONG, LONG);
1496 static HWINEVENTHOOK (WINAPI *pSetWinEventHook)(DWORD, DWORD, HMODULE, WINEVENTPROC, DWORD, DWORD, DWORD);
1497 static BOOL (WINAPI *pTrackMouseEvent)(TRACKMOUSEEVENT*);
1498 static BOOL (WINAPI *pUnhookWinEvent)(HWINEVENTHOOK);
1499 /* kernel32 functions */
1500 static BOOL (WINAPI *pGetCPInfoExA)(UINT, DWORD, LPCPINFOEXA);
1502 static void init_procs(void)
1504 HMODULE user32 = GetModuleHandleA("user32.dll");
1505 HMODULE kernel32 = GetModuleHandleA("kernel32.dll");
1507 #define GET_PROC(dll, func) \
1508 p ## func = (void*)GetProcAddress(dll, #func); \
1509 if(!p ## func) { \
1510 trace("GetProcAddress(%s) failed\n", #func); \
1513 GET_PROC(user32, GetAncestor)
1514 GET_PROC(user32, NotifyWinEvent)
1515 GET_PROC(user32, SetWinEventHook)
1516 GET_PROC(user32, TrackMouseEvent)
1517 GET_PROC(user32, UnhookWinEvent)
1519 GET_PROC(kernel32, GetCPInfoExA)
1521 #undef GET_PROC
1524 static void add_message(const struct message *msg)
1526 if (!sequence)
1528 sequence_size = 10;
1529 sequence = HeapAlloc( GetProcessHeap(), 0, sequence_size * sizeof (struct message) );
1531 if (sequence_cnt == sequence_size)
1533 sequence_size *= 2;
1534 sequence = HeapReAlloc( GetProcessHeap(), 0, sequence, sequence_size * sizeof (struct message) );
1536 assert(sequence);
1538 sequence[sequence_cnt].message = msg->message;
1539 sequence[sequence_cnt].flags = msg->flags;
1540 sequence[sequence_cnt].wParam = msg->wParam;
1541 sequence[sequence_cnt].lParam = msg->lParam;
1543 sequence_cnt++;
1546 /* try to make sure pending X events have been processed before continuing */
1547 static void flush_events(void)
1549 MSG msg;
1550 int diff = 200;
1551 int min_timeout = 50;
1552 DWORD time = GetTickCount() + diff;
1554 while (diff > 0)
1556 if (MsgWaitForMultipleObjects( 0, NULL, FALSE, min_timeout, QS_ALLINPUT ) == WAIT_TIMEOUT) break;
1557 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
1558 diff = time - GetTickCount();
1559 min_timeout = 10;
1563 static void flush_sequence(void)
1565 HeapFree(GetProcessHeap(), 0, sequence);
1566 sequence = 0;
1567 sequence_cnt = sequence_size = 0;
1570 #define ok_sequence( exp, contx, todo) \
1571 ok_sequence_( (exp), (contx), (todo), __FILE__, __LINE__)
1574 static void ok_sequence_(const struct message *expected, const char *context, int todo,
1575 const char *file, int line)
1577 static const struct message end_of_sequence = { 0, 0, 0, 0 };
1578 const struct message *actual;
1579 int failcount = 0;
1581 add_message(&end_of_sequence);
1583 actual = sequence;
1585 while (expected->message && actual->message)
1587 trace_( file, line)("expected %04x - actual %04x\n", expected->message, actual->message);
1589 if (expected->message == actual->message)
1591 if (expected->flags & wparam)
1593 if (expected->wParam != actual->wParam && todo)
1595 todo_wine {
1596 failcount ++;
1597 ok_( file, line) (FALSE,
1598 "%s: in msg 0x%04x expecting wParam 0x%lx got 0x%lx\n",
1599 context, expected->message, expected->wParam, actual->wParam);
1602 else
1603 ok_( file, line) (expected->wParam == actual->wParam,
1604 "%s: in msg 0x%04x expecting wParam 0x%lx got 0x%lx\n",
1605 context, expected->message, expected->wParam, actual->wParam);
1607 if (expected->flags & lparam)
1609 if (expected->lParam != actual->lParam && todo)
1611 todo_wine {
1612 failcount ++;
1613 ok_( file, line) (FALSE,
1614 "%s: in msg 0x%04x expecting lParam 0x%lx got 0x%lx\n",
1615 context, expected->message, expected->lParam, actual->lParam);
1618 else
1619 ok_( file, line) (expected->lParam == actual->lParam,
1620 "%s: in msg 0x%04x expecting lParam 0x%lx got 0x%lx\n",
1621 context, expected->message, expected->lParam, actual->lParam);
1623 if ((expected->flags & defwinproc) != (actual->flags & defwinproc) && todo)
1625 todo_wine {
1626 failcount ++;
1627 ok_( file, line) (FALSE,
1628 "%s: the msg 0x%04x should %shave been sent by DefWindowProc\n",
1629 context, expected->message, (expected->flags & defwinproc) ? "" : "NOT ");
1632 else
1633 ok_( file, line) ((expected->flags & defwinproc) == (actual->flags & defwinproc),
1634 "%s: the msg 0x%04x should %shave been sent by DefWindowProc\n",
1635 context, expected->message, (expected->flags & defwinproc) ? "" : "NOT ");
1636 ok_( file, line) ((expected->flags & beginpaint) == (actual->flags & beginpaint),
1637 "%s: the msg 0x%04x should %shave been sent by BeginPaint\n",
1638 context, expected->message, (expected->flags & beginpaint) ? "" : "NOT ");
1639 ok_( file, line) ((expected->flags & (sent|posted)) == (actual->flags & (sent|posted)),
1640 "%s: the msg 0x%04x should have been %s\n",
1641 context, expected->message, (expected->flags & posted) ? "posted" : "sent");
1642 ok_( file, line) ((expected->flags & parent) == (actual->flags & parent),
1643 "%s: the msg 0x%04x was expected in %s\n",
1644 context, expected->message, (expected->flags & parent) ? "parent" : "child");
1645 ok_( file, line) ((expected->flags & hook) == (actual->flags & hook),
1646 "%s: the msg 0x%04x should have been sent by a hook\n",
1647 context, expected->message);
1648 ok_( file, line) ((expected->flags & winevent_hook) == (actual->flags & winevent_hook),
1649 "%s: the msg 0x%04x should have been sent by a winevent hook\n",
1650 context, expected->message);
1651 expected++;
1652 actual++;
1654 /* silently drop winevent messages if there is no support for them */
1655 else if ((expected->flags & optional) || ((expected->flags & winevent_hook) && !hEvent_hook))
1656 expected++;
1657 else if (todo)
1659 failcount++;
1660 todo_wine {
1661 ok_( file, line) (FALSE, "%s: the msg 0x%04x was expected, but got msg 0x%04x instead\n",
1662 context, expected->message, actual->message);
1664 flush_sequence();
1665 return;
1667 else
1669 ok_( file, line) (FALSE, "%s: the msg 0x%04x was expected, but got msg 0x%04x instead\n",
1670 context, expected->message, actual->message);
1671 expected++;
1672 actual++;
1676 /* skip all optional trailing messages */
1677 while (expected->message && ((expected->flags & optional) ||
1678 ((expected->flags & winevent_hook) && !hEvent_hook)))
1679 expected++;
1681 if (todo)
1683 todo_wine {
1684 if (expected->message || actual->message) {
1685 failcount++;
1686 ok_( file, line) (FALSE, "%s: the msg sequence is not complete: expected %04x - actual %04x\n",
1687 context, expected->message, actual->message);
1691 else
1693 if (expected->message || actual->message)
1694 ok_( file, line) (FALSE, "%s: the msg sequence is not complete: expected %04x - actual %04x\n",
1695 context, expected->message, actual->message);
1697 if( todo && !failcount) /* succeeded yet marked todo */
1698 todo_wine {
1699 ok_( file, line)( TRUE, "%s: marked \"todo_wine\" but succeeds\n", context);
1702 flush_sequence();
1705 /******************************** MDI test **********************************/
1707 /* CreateWindow for MDI frame window, initially visible */
1708 static const struct message WmCreateMDIframeSeq[] = {
1709 { HCBT_CREATEWND, hook },
1710 { WM_GETMINMAXINFO, sent },
1711 { WM_NCCREATE, sent },
1712 { WM_NCCALCSIZE, sent|wparam, 0 },
1713 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
1714 { WM_CREATE, sent },
1715 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1716 { WM_SHOWWINDOW, sent|wparam, 1 },
1717 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
1718 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1719 { HCBT_ACTIVATE, hook },
1720 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
1721 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
1722 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* XP */
1723 { WM_ACTIVATEAPP, sent|wparam|optional, 1 }, /* Win9x doesn't send it */
1724 { WM_NCACTIVATE, sent|wparam, 1 },
1725 { WM_GETTEXT, sent|defwinproc|optional },
1726 { WM_ACTIVATE, sent|wparam, 1 },
1727 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* Win9x */
1728 { HCBT_SETFOCUS, hook },
1729 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
1730 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
1731 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1732 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
1733 /* Win9x adds SWP_NOZORDER below */
1734 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1735 { WM_NCCALCSIZE, sent|wparam|optional, 1 }, /* XP */
1736 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1737 { WM_SIZE, sent|wparam, SIZE_RESTORED },
1738 { WM_MOVE, sent },
1739 { 0 }
1741 /* DestroyWindow for MDI frame window, initially visible */
1742 static const struct message WmDestroyMDIframeSeq[] = {
1743 { HCBT_DESTROYWND, hook },
1744 { 0x0090, sent|optional },
1745 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1746 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
1747 { WM_NCACTIVATE, sent|wparam|optional, 0 }, /* Win9x */
1748 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1749 { WM_NCACTIVATE, sent|wparam|optional, 0 }, /* XP */
1750 { WM_ACTIVATE, sent|wparam|optional, 0 }, /* Win9x */
1751 { WM_ACTIVATEAPP, sent|wparam|optional, 0 }, /* Win9x */
1752 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
1753 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
1754 { WM_DESTROY, sent },
1755 { WM_NCDESTROY, sent },
1756 { 0 }
1758 /* CreateWindow for MDI client window, initially visible */
1759 static const struct message WmCreateMDIclientSeq[] = {
1760 { HCBT_CREATEWND, hook },
1761 { WM_NCCREATE, sent },
1762 { WM_NCCALCSIZE, sent|wparam, 0 },
1763 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam|optional, 0, 0 },
1764 { WM_CREATE, sent },
1765 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam|optional, 0, 0 },
1766 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1767 { WM_SIZE, sent|wparam, SIZE_RESTORED },
1768 { WM_MOVE, sent },
1769 { WM_PARENTNOTIFY, sent|wparam, WM_CREATE }, /* in MDI frame */
1770 { WM_SHOWWINDOW, sent|wparam, 1 },
1771 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1772 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1773 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1774 { 0 }
1776 /* ShowWindow(SW_SHOW) for MDI client window */
1777 static const struct message WmShowMDIclientSeq[] = {
1778 { WM_SHOWWINDOW, sent|wparam, 1 },
1779 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1780 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1781 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1782 { 0 }
1784 /* ShowWindow(SW_HIDE) for MDI client window */
1785 static const struct message WmHideMDIclientSeq[] = {
1786 { WM_SHOWWINDOW, sent|wparam, 0 },
1787 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1788 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam|optional, 0, 0 }, /* win2000 */
1789 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* XP */
1790 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1791 { 0 }
1793 /* DestroyWindow for MDI client window, initially visible */
1794 static const struct message WmDestroyMDIclientSeq[] = {
1795 { HCBT_DESTROYWND, hook },
1796 { 0x0090, sent|optional },
1797 { WM_PARENTNOTIFY, sent|wparam, WM_DESTROY }, /* in MDI frame */
1798 { WM_SHOWWINDOW, sent|wparam, 0 },
1799 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1800 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
1801 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1802 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
1803 { WM_DESTROY, sent },
1804 { WM_NCDESTROY, sent },
1805 { 0 }
1807 /* CreateWindow for MDI child window, initially visible */
1808 static const struct message WmCreateMDIchildVisibleSeq[] = {
1809 { HCBT_CREATEWND, hook },
1810 { WM_NCCREATE, sent },
1811 { WM_NCCALCSIZE, sent|wparam, 0 },
1812 { WM_CREATE, sent },
1813 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1814 { WM_SIZE, sent|wparam, SIZE_RESTORED },
1815 { WM_MOVE, sent },
1816 /* Win2k sends wparam set to
1817 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
1818 * while Win9x doesn't bother to set child window id according to
1819 * CLIENTCREATESTRUCT.idFirstChild
1821 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
1822 { WM_SHOWWINDOW, sent|wparam, 1 },
1823 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1824 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1825 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1826 { WM_MDIREFRESHMENU, sent/*|wparam|lparam, 0, 0*/ },
1827 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
1828 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
1829 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1831 /* Win9x: message sequence terminates here. */
1833 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
1834 { HCBT_SETFOCUS, hook }, /* in MDI client */
1835 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
1836 { WM_IME_NOTIFY, sent|wparam|optional, 2 }, /* in MDI client */
1837 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1838 { WM_SETFOCUS, sent }, /* in MDI client */
1839 { HCBT_SETFOCUS, hook },
1840 { WM_KILLFOCUS, sent }, /* in MDI client */
1841 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
1842 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
1843 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1844 { WM_SETFOCUS, sent|defwinproc },
1845 { WM_MDIACTIVATE, sent|defwinproc },
1846 { 0 }
1848 /* CreateWindow for MDI child window with invisible parent */
1849 static const struct message WmCreateMDIchildInvisibleParentSeq[] = {
1850 { HCBT_CREATEWND, hook },
1851 { WM_GETMINMAXINFO, sent },
1852 { WM_NCCREATE, sent },
1853 { WM_NCCALCSIZE, sent|wparam, 0 },
1854 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam|optional, 0, 0 },
1855 { WM_CREATE, sent },
1856 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1857 { WM_SIZE, sent|wparam, SIZE_RESTORED },
1858 { WM_MOVE, sent },
1859 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
1860 { WM_SHOWWINDOW, sent|wparam, 1 },
1861 { WM_MDIREFRESHMENU, sent }, /* in MDI client */
1862 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
1863 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
1864 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1866 /* Win9x: message sequence terminates here. */
1868 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
1869 { HCBT_SETFOCUS, hook }, /* in MDI client */
1870 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
1871 { WM_IME_NOTIFY, sent|wparam|optional, 2 }, /* in MDI client */
1872 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1873 { WM_SETFOCUS, sent }, /* in MDI client */
1874 { HCBT_SETFOCUS, hook },
1875 { WM_KILLFOCUS, sent }, /* in MDI client */
1876 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
1877 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
1878 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1879 { WM_SETFOCUS, sent|defwinproc },
1880 { WM_MDIACTIVATE, sent|defwinproc },
1881 { 0 }
1883 /* DestroyWindow for MDI child window, initially visible */
1884 static const struct message WmDestroyMDIchildVisibleSeq[] = {
1885 { HCBT_DESTROYWND, hook },
1886 /* Win2k sends wparam set to
1887 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
1888 * while Win9x doesn't bother to set child window id according to
1889 * CLIENTCREATESTRUCT.idFirstChild
1891 { 0x0090, sent|optional },
1892 { WM_PARENTNOTIFY, sent /*|wparam, WM_DESTROY*/ }, /* in MDI client */
1893 { WM_SHOWWINDOW, sent|wparam, 0 },
1894 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1895 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
1896 { WM_ERASEBKGND, sent|parent|optional },
1897 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1899 /* { WM_DESTROY, sent }
1900 * Win9x: message sequence terminates here.
1903 { HCBT_SETFOCUS, hook }, /* set focus to MDI client */
1904 { WM_KILLFOCUS, sent },
1905 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
1906 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
1907 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1908 { WM_SETFOCUS, sent }, /* in MDI client */
1910 { HCBT_SETFOCUS, hook }, /* MDI client sets focus back to MDI child */
1911 { WM_KILLFOCUS, sent }, /* in MDI client */
1912 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
1913 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
1914 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1915 { WM_SETFOCUS, sent }, /* in MDI client */
1917 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
1919 { HCBT_SETFOCUS, hook }, /* set focus to MDI client */
1920 { WM_KILLFOCUS, sent },
1921 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
1922 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
1923 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1924 { WM_SETFOCUS, sent }, /* in MDI client */
1926 { HCBT_SETFOCUS, hook }, /* MDI client sets focus back to MDI child */
1927 { WM_KILLFOCUS, sent }, /* in MDI client */
1928 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
1929 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
1930 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1931 { WM_SETFOCUS, sent }, /* in MDI client */
1933 { WM_DESTROY, sent },
1935 { HCBT_SETFOCUS, hook }, /* set focus to MDI client */
1936 { WM_KILLFOCUS, sent },
1937 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
1938 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
1939 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1940 { WM_SETFOCUS, sent }, /* in MDI client */
1942 { HCBT_SETFOCUS, hook }, /* MDI client sets focus back to MDI child */
1943 { WM_KILLFOCUS, sent }, /* in MDI client */
1944 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
1945 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
1946 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1947 { WM_SETFOCUS, sent }, /* in MDI client */
1949 { WM_NCDESTROY, sent },
1950 { 0 }
1952 /* CreateWindow for MDI child window, initially invisible */
1953 static const struct message WmCreateMDIchildInvisibleSeq[] = {
1954 { HCBT_CREATEWND, hook },
1955 { WM_NCCREATE, sent },
1956 { WM_NCCALCSIZE, sent|wparam, 0 },
1957 { WM_CREATE, sent },
1958 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1959 { WM_SIZE, sent|wparam, SIZE_RESTORED },
1960 { WM_MOVE, sent },
1961 /* Win2k sends wparam set to
1962 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
1963 * while Win9x doesn't bother to set child window id according to
1964 * CLIENTCREATESTRUCT.idFirstChild
1966 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
1967 { 0 }
1969 /* DestroyWindow for MDI child window, initially invisible */
1970 static const struct message WmDestroyMDIchildInvisibleSeq[] = {
1971 { HCBT_DESTROYWND, hook },
1972 /* Win2k sends wparam set to
1973 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
1974 * while Win9x doesn't bother to set child window id according to
1975 * CLIENTCREATESTRUCT.idFirstChild
1977 { 0x0090, sent|optional },
1978 { WM_PARENTNOTIFY, sent /*|wparam, WM_DESTROY*/ }, /* in MDI client */
1979 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
1980 { WM_DESTROY, sent },
1981 { WM_NCDESTROY, sent },
1982 /* FIXME: Wine destroys an icon/title window while Windows doesn't */
1983 { WM_PARENTNOTIFY, sent|wparam|optional, WM_DESTROY }, /* MDI client */
1984 { 0 }
1986 /* CreateWindow for the 1st MDI child window, initially visible and maximized */
1987 static const struct message WmCreateMDIchildVisibleMaxSeq1[] = {
1988 { HCBT_CREATEWND, hook },
1989 { WM_NCCREATE, sent },
1990 { WM_NCCALCSIZE, sent|wparam, 0 },
1991 { WM_CREATE, sent },
1992 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1993 { WM_SIZE, sent|wparam, SIZE_RESTORED },
1994 { WM_MOVE, sent },
1995 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
1996 { WM_GETMINMAXINFO, sent },
1997 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|0x8000 },
1998 { WM_NCCALCSIZE, sent|wparam, 1 },
1999 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|0x8000 },
2000 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2001 /* in MDI frame */
2002 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2003 { WM_NCCALCSIZE, sent|wparam, 1 },
2004 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2005 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2006 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2007 /* Win2k sends wparam set to
2008 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2009 * while Win9x doesn't bother to set child window id according to
2010 * CLIENTCREATESTRUCT.idFirstChild
2012 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
2013 { WM_SHOWWINDOW, sent|wparam, 1 },
2014 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2015 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2016 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2017 { WM_MDIREFRESHMENU, sent/*|wparam|lparam, 0, 0*/ },
2018 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
2019 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2020 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2022 /* Win9x: message sequence terminates here. */
2024 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
2025 { HCBT_SETFOCUS, hook }, /* in MDI client */
2026 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2027 { WM_IME_NOTIFY, sent|wparam|optional, 2 }, /* in MDI client */
2028 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2029 { WM_SETFOCUS, sent }, /* in MDI client */
2030 { HCBT_SETFOCUS, hook },
2031 { WM_KILLFOCUS, sent }, /* in MDI client */
2032 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
2033 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
2034 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2035 { WM_SETFOCUS, sent|defwinproc },
2036 { WM_MDIACTIVATE, sent|defwinproc },
2037 /* in MDI frame */
2038 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2039 { WM_NCCALCSIZE, sent|wparam, 1 },
2040 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2041 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2042 { 0 }
2044 /* CreateWindow for the 2nd MDI child window, initially visible and maximized */
2045 static const struct message WmCreateMDIchildVisibleMaxSeq2[] = {
2046 /* restore the 1st MDI child */
2047 { WM_SETREDRAW, sent|wparam, 0 },
2048 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWNORMAL },
2049 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|0x8000 },
2050 { WM_NCCALCSIZE, sent|wparam, 1 },
2051 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2052 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|0x8000 },
2053 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2054 /* in MDI frame */
2055 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2056 { WM_NCCALCSIZE, sent|wparam, 1 },
2057 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2058 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2059 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2060 { WM_SETREDRAW, sent|wparam, 1 }, /* in the 1st MDI child */
2061 /* create the 2nd MDI child */
2062 { HCBT_CREATEWND, hook },
2063 { WM_NCCREATE, sent },
2064 { WM_NCCALCSIZE, sent|wparam, 0 },
2065 { WM_CREATE, sent },
2066 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
2067 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2068 { WM_MOVE, sent },
2069 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
2070 { WM_GETMINMAXINFO, sent },
2071 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|0x8000 },
2072 { WM_NCCALCSIZE, sent|wparam, 1 },
2073 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2074 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|0x8000 },
2075 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2076 /* in MDI frame */
2077 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2078 { WM_NCCALCSIZE, sent|wparam, 1 },
2079 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2080 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2081 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2082 /* Win2k sends wparam set to
2083 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2084 * while Win9x doesn't bother to set child window id according to
2085 * CLIENTCREATESTRUCT.idFirstChild
2087 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
2088 { WM_SHOWWINDOW, sent|wparam, 1 },
2089 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2090 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2091 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2092 { WM_MDIREFRESHMENU, sent/*|wparam|lparam, 0, 0*/ },
2093 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
2094 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2096 { WM_NCACTIVATE, sent|wparam|defwinproc, 0 }, /* in the 1st MDI child */
2097 { WM_MDIACTIVATE, sent|defwinproc }, /* in the 1st MDI child */
2099 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2101 /* Win9x: message sequence terminates here. */
2103 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
2104 { HCBT_SETFOCUS, hook },
2105 { WM_KILLFOCUS, sent|defwinproc }, /* in the 1st MDI child */
2106 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 0 }, /* in the 1st MDI child */
2107 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2108 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2109 { WM_SETFOCUS, sent }, /* in MDI client */
2110 { HCBT_SETFOCUS, hook },
2111 { WM_KILLFOCUS, sent }, /* in MDI client */
2112 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
2113 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
2114 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2115 { WM_SETFOCUS, sent|defwinproc },
2117 { WM_MDIACTIVATE, sent|defwinproc },
2118 /* in MDI frame */
2119 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2120 { WM_NCCALCSIZE, sent|wparam, 1 },
2121 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2122 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2123 { 0 }
2125 /* WM_MDICREATE MDI child window, initially visible and maximized */
2126 static const struct message WmCreateMDIchildVisibleMaxSeq3[] = {
2127 { WM_MDICREATE, sent },
2128 { HCBT_CREATEWND, hook },
2129 { WM_NCCREATE, sent },
2130 { WM_NCCALCSIZE, sent|wparam, 0 },
2131 { WM_CREATE, sent },
2132 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
2133 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2134 { WM_MOVE, sent },
2135 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
2136 { WM_GETMINMAXINFO, sent },
2137 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|0x8000 },
2138 { WM_NCCALCSIZE, sent|wparam, 1 },
2139 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|0x8000 },
2140 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2142 /* in MDI frame */
2143 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2144 { WM_NCCALCSIZE, sent|wparam, 1 },
2145 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2146 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2147 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2149 /* Win2k sends wparam set to
2150 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2151 * while Win9x doesn't bother to set child window id according to
2152 * CLIENTCREATESTRUCT.idFirstChild
2154 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
2155 { WM_SHOWWINDOW, sent|wparam, 1 },
2156 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2158 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2160 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2161 { WM_MDIREFRESHMENU, sent/*|wparam|lparam, 0, 0*/ },
2162 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
2164 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2165 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2167 /* Win9x: message sequence terminates here. */
2169 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
2170 { WM_SETFOCUS, sent|optional }, /* in MDI client */
2171 { HCBT_SETFOCUS, hook }, /* in MDI client */
2172 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2173 { WM_IME_NOTIFY, sent|wparam|optional, 2 },
2174 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
2175 { WM_SETFOCUS, sent|optional }, /* in MDI client */
2176 { HCBT_SETFOCUS, hook|optional },
2177 { WM_KILLFOCUS, sent }, /* in MDI client */
2178 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
2179 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
2180 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2181 { WM_SETFOCUS, sent|defwinproc },
2183 { WM_MDIACTIVATE, sent|defwinproc },
2185 /* in MDI child */
2186 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2187 { WM_NCCALCSIZE, sent|wparam, 1 },
2188 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2189 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
2191 /* in MDI frame */
2192 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2193 { WM_NCCALCSIZE, sent|wparam, 1 },
2194 { 0x0093, sent|defwinproc|optional },
2195 { 0x0093, sent|defwinproc|optional },
2196 { 0x0093, sent|defwinproc|optional },
2197 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2198 { WM_MOVE, sent|defwinproc },
2199 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2201 /* in MDI client */
2202 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE },
2203 { WM_NCCALCSIZE, sent|wparam, 1 },
2204 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOCLIENTMOVE },
2205 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2207 /* in MDI child */
2208 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE },
2209 { WM_NCCALCSIZE, sent|wparam, 1 },
2210 { 0x0093, sent|optional },
2211 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOCLIENTMOVE },
2212 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2214 { 0x0093, sent|optional },
2215 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2216 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI client */
2217 { WM_NCCALCSIZE, sent|wparam|optional, 1 }, /* XP sends it to MDI frame */
2218 { 0x0093, sent|defwinproc|optional },
2219 { 0x0093, sent|defwinproc|optional },
2220 { 0x0093, sent|defwinproc|optional },
2221 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2222 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* XP sends a duplicate */
2224 { 0 }
2226 /* CreateWindow for the 1st MDI child window, initially invisible and maximized */
2227 static const struct message WmCreateMDIchildInvisibleMaxSeq4[] = {
2228 { HCBT_CREATEWND, hook },
2229 { WM_GETMINMAXINFO, sent },
2230 { WM_NCCREATE, sent },
2231 { WM_NCCALCSIZE, sent|wparam, 0 },
2232 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
2233 { WM_CREATE, sent },
2234 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
2235 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2236 { WM_MOVE, sent },
2237 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
2238 { WM_GETMINMAXINFO, sent },
2239 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|0x8000 },
2240 { WM_GETMINMAXINFO, sent|defwinproc },
2241 { WM_NCCALCSIZE, sent|wparam, 1 },
2242 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|0x8000 },
2243 { WM_MOVE, sent|defwinproc },
2244 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2245 /* in MDI frame */
2246 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2247 { WM_NCCALCSIZE, sent|wparam, 1 },
2248 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2249 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2250 { WM_NCCALCSIZE, sent|wparam|optional, 1 }, /* MDI child */
2251 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2252 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2253 /* Win2k sends wparam set to
2254 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2255 * while Win9x doesn't bother to set child window id according to
2256 * CLIENTCREATESTRUCT.idFirstChild
2258 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
2259 { 0 }
2261 /* WM_SYSCOMMAND/SC_CLOSE for the 2nd MDI child window, initially visible and maximized */
2262 static const struct message WmDestroyMDIchildVisibleMaxSeq2[] = {
2263 { WM_SYSCOMMAND, sent|wparam, SC_CLOSE },
2264 { HCBT_SYSCOMMAND, hook },
2265 { WM_CLOSE, sent|defwinproc },
2266 { WM_MDIDESTROY, sent }, /* in MDI client */
2268 /* bring the 1st MDI child to top */
2269 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOSIZE|SWP_NOMOVE }, /* in the 1st MDI child */
2270 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE }, /* in the 2nd MDI child */
2272 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2274 { WM_CHILDACTIVATE, sent|defwinproc|wparam|lparam, 0, 0 }, /* in the 1st MDI child */
2275 { WM_NCACTIVATE, sent|wparam|defwinproc, 0 }, /* in the 1st MDI child */
2276 { WM_MDIACTIVATE, sent|defwinproc }, /* in the 1st MDI child */
2278 /* maximize the 1st MDI child */
2279 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
2280 { WM_GETMINMAXINFO, sent|defwinproc },
2281 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_FRAMECHANGED|0x8000 },
2282 { WM_NCCALCSIZE, sent|defwinproc|wparam, 1 },
2283 { WM_CHILDACTIVATE, sent|defwinproc|wparam|lparam, 0, 0 },
2284 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|0x8000 },
2285 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2287 /* restore the 2nd MDI child */
2288 { WM_SETREDRAW, sent|defwinproc|wparam, 0 },
2289 { HCBT_MINMAX, hook|lparam, 0, SW_NORMALNA },
2290 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_SHOWWINDOW|0x8000 },
2291 { WM_NCCALCSIZE, sent|defwinproc|wparam, 1 },
2293 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2295 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|0x8000 },
2296 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2298 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2300 { WM_SETREDRAW, sent|defwinproc|wparam, 1 },
2301 /* in MDI frame */
2302 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2303 { WM_NCCALCSIZE, sent|wparam, 1 },
2304 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2305 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2306 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2308 /* bring the 1st MDI child to top */
2309 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2310 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
2311 { HCBT_SETFOCUS, hook },
2312 { WM_KILLFOCUS, sent|defwinproc },
2313 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 0 },
2314 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2315 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2316 { WM_SETFOCUS, sent }, /* in MDI client */
2317 { HCBT_SETFOCUS, hook },
2318 { WM_KILLFOCUS, sent }, /* in MDI client */
2319 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
2320 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
2321 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2322 { WM_SETFOCUS, sent|defwinproc },
2323 { WM_MDIACTIVATE, sent|defwinproc },
2324 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2326 /* apparently ShowWindow(SW_SHOW) on an MDI client */
2327 { WM_SHOWWINDOW, sent|wparam, 1 },
2328 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2329 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2330 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2331 { WM_MDIREFRESHMENU, sent },
2333 { HCBT_DESTROYWND, hook },
2334 /* Win2k sends wparam set to
2335 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
2336 * while Win9x doesn't bother to set child window id according to
2337 * CLIENTCREATESTRUCT.idFirstChild
2339 { 0x0090, sent|defwinproc|optional },
2340 { WM_PARENTNOTIFY, sent /*|wparam, WM_DESTROY*/ }, /* in MDI client */
2341 { WM_SHOWWINDOW, sent|defwinproc|wparam, 0 },
2342 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2343 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
2344 { WM_ERASEBKGND, sent|parent|optional },
2345 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2347 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
2348 { WM_DESTROY, sent|defwinproc },
2349 { WM_NCDESTROY, sent|defwinproc },
2350 { 0 }
2352 /* WM_MDIDESTROY for the single MDI child window, initially visible and maximized */
2353 static const struct message WmDestroyMDIchildVisibleMaxSeq1[] = {
2354 { WM_MDIDESTROY, sent }, /* in MDI client */
2355 { WM_SHOWWINDOW, sent|wparam, 0 },
2356 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2357 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
2358 { WM_ERASEBKGND, sent|parent|optional },
2359 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2361 { HCBT_SETFOCUS, hook },
2362 { WM_KILLFOCUS, sent },
2363 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
2364 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2365 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2366 { WM_SETFOCUS, sent }, /* in MDI client */
2367 { HCBT_SETFOCUS, hook },
2368 { WM_KILLFOCUS, sent }, /* in MDI client */
2369 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
2370 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
2371 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2372 { WM_SETFOCUS, sent },
2374 /* in MDI child */
2375 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2376 { WM_NCCALCSIZE, sent|wparam, 1 },
2377 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2378 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2380 /* in MDI frame */
2381 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2382 { WM_NCCALCSIZE, sent|wparam, 1 },
2383 { 0x0093, sent|defwinproc|optional },
2384 { 0x0093, sent|defwinproc|optional },
2385 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2386 { WM_MOVE, sent|defwinproc },
2387 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2389 /* in MDI client */
2390 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE },
2391 { WM_NCCALCSIZE, sent|wparam, 1 },
2392 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOCLIENTMOVE },
2393 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2395 /* in MDI child */
2396 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE },
2397 { WM_NCCALCSIZE, sent|wparam, 1 },
2398 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTMOVE },
2399 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2401 /* in MDI child */
2402 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2403 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 },
2404 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2405 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2407 /* in MDI frame */
2408 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2409 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 },
2410 { 0x0093, sent|defwinproc|optional },
2411 { 0x0093, sent|defwinproc|optional },
2412 { 0x0093, sent|defwinproc|optional },
2413 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2414 { WM_MOVE, sent|defwinproc },
2415 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2417 /* in MDI client */
2418 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE },
2419 { WM_NCCALCSIZE, sent|wparam, 1 },
2420 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOCLIENTMOVE },
2421 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2423 /* in MDI child */
2424 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE },
2425 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 },
2426 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTMOVE },
2427 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2428 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2429 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI client */
2431 { 0x0093, sent|defwinproc|optional },
2432 { WM_NCCALCSIZE, sent|wparam|defwinproc|optional, 1 }, /* XP sends it to MDI frame */
2433 { 0x0093, sent|defwinproc|optional },
2434 { 0x0093, sent|defwinproc|optional },
2435 { 0x0093, sent|defwinproc|optional },
2436 { 0x0093, sent|optional },
2438 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2439 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2440 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI client */
2441 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2442 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* XP sends a duplicate */
2444 /* in MDI frame */
2445 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2446 { WM_NCCALCSIZE, sent|wparam, 1 },
2447 { 0x0093, sent|defwinproc|optional },
2448 { 0x0093, sent|defwinproc|optional },
2449 { 0x0093, sent|defwinproc|optional },
2450 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2451 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2452 { 0x0093, sent|optional },
2454 { WM_NCACTIVATE, sent|wparam, 0 },
2455 { WM_MDIACTIVATE, sent },
2457 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWNORMAL },
2458 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_SHOWWINDOW|0x8000 },
2459 { WM_NCCALCSIZE, sent|wparam, 1 },
2461 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2463 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2464 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_SHOWWINDOW|SWP_NOMOVE|SWP_NOCLIENTMOVE|0x8000 },
2465 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2467 /* in MDI child */
2468 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2469 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 },
2470 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2471 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2473 /* in MDI frame */
2474 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2475 { WM_NCCALCSIZE, sent|wparam, 1 },
2476 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2477 { WM_MOVE, sent|defwinproc },
2478 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2480 /* in MDI client */
2481 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE },
2482 { WM_NCCALCSIZE, sent|wparam, 1 },
2483 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOCLIENTMOVE },
2484 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2485 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2486 { WM_NCCALCSIZE, sent|wparam|optional, 1 }, /* XP */
2487 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI client */
2488 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2489 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* XP sends a duplicate */
2491 { HCBT_SETFOCUS, hook },
2492 { WM_KILLFOCUS, sent },
2493 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
2494 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2495 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2496 { WM_SETFOCUS, sent }, /* in MDI client */
2498 { WM_MDIREFRESHMENU, sent }, /* in MDI client */
2500 { HCBT_DESTROYWND, hook },
2501 /* Win2k sends wparam set to
2502 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
2503 * while Win9x doesn't bother to set child window id according to
2504 * CLIENTCREATESTRUCT.idFirstChild
2506 { 0x0090, sent|optional },
2507 { WM_PARENTNOTIFY, sent /*|wparam, WM_DESTROY*/ }, /* in MDI client */
2509 { WM_SHOWWINDOW, sent|wparam, 0 },
2510 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2511 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
2512 { WM_ERASEBKGND, sent|parent|optional },
2513 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2515 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
2516 { WM_DESTROY, sent },
2517 { WM_NCDESTROY, sent },
2518 { 0 }
2520 /* ShowWindow(SW_MAXIMIZE) for a not visible MDI child window */
2521 static const struct message WmMaximizeMDIchildInvisibleSeq[] = {
2522 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
2523 { WM_GETMINMAXINFO, sent },
2524 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|0x8000 },
2525 { WM_NCCALCSIZE, sent|wparam, 1 },
2526 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2527 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2529 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2530 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
2531 { HCBT_SETFOCUS, hook },
2532 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2533 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2534 { WM_SETFOCUS, sent }, /* in MDI client */
2535 { HCBT_SETFOCUS, hook },
2536 { WM_KILLFOCUS, sent }, /* in MDI client */
2537 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
2538 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
2539 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2540 { WM_SETFOCUS, sent|defwinproc },
2541 { WM_MDIACTIVATE, sent|defwinproc },
2542 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|0x8000 },
2543 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2544 /* in MDI frame */
2545 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2546 { WM_NCCALCSIZE, sent|wparam, 1 },
2547 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2548 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2549 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2550 { 0 }
2552 /* ShowWindow(SW_MAXIMIZE) for a not visible maximized MDI child window */
2553 static const struct message WmMaximizeMDIchildInvisibleSeq2[] = {
2554 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
2555 { WM_GETMINMAXINFO, sent },
2556 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED },
2557 { WM_GETMINMAXINFO, sent|defwinproc },
2558 { WM_NCCALCSIZE, sent|wparam, 1 },
2559 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2560 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2562 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2563 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
2564 { HCBT_SETFOCUS, hook },
2565 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2566 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2567 { WM_SETFOCUS, sent }, /* in MDI client */
2568 { HCBT_SETFOCUS, hook },
2569 { WM_KILLFOCUS, sent }, /* in MDI client */
2570 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
2571 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
2572 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2573 { WM_SETFOCUS, sent|defwinproc },
2574 { WM_MDIACTIVATE, sent|defwinproc },
2575 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2576 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2577 { 0 }
2579 /* WM_MDIMAXIMIZE for an MDI child window with invisible parent */
2580 static const struct message WmMaximizeMDIchildInvisibleParentSeq[] = {
2581 { WM_MDIMAXIMIZE, sent }, /* in MDI client */
2582 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
2583 { WM_GETMINMAXINFO, sent },
2584 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|0x8000 },
2585 { WM_GETMINMAXINFO, sent|defwinproc },
2586 { WM_NCCALCSIZE, sent|wparam, 1 },
2587 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam|optional, 0, 0 }, /* XP doesn't send it */
2588 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2589 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOREDRAW|0x8000 },
2590 { WM_MOVE, sent|defwinproc },
2591 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2593 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2594 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 },
2595 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2596 { WM_NCCALCSIZE, sent|wparam|defwinproc|optional, 1 },
2597 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI child XP */
2598 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI client XP */
2599 /* in MDI frame */
2600 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2601 { WM_NCCALCSIZE, sent|wparam, 1 },
2602 { 0x0093, sent|defwinproc|optional },
2603 { 0x0094, sent|defwinproc|optional },
2604 { 0x0094, sent|defwinproc|optional },
2605 { 0x0094, sent|defwinproc|optional },
2606 { 0x0094, sent|defwinproc|optional },
2607 { 0x0093, sent|defwinproc|optional },
2608 { 0x0093, sent|defwinproc|optional },
2609 { 0x0091, sent|defwinproc|optional },
2610 { 0x0092, sent|defwinproc|optional },
2611 { 0x0092, sent|defwinproc|optional },
2612 { 0x0092, sent|defwinproc|optional },
2613 { 0x0092, sent|defwinproc|optional },
2614 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2615 { WM_MOVE, sent|defwinproc },
2616 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2617 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI frame win2000 */
2618 /* in MDI client */
2619 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE },
2620 { WM_NCCALCSIZE, sent|wparam, 1 },
2621 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTMOVE },
2622 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2623 /* in MDI child */
2624 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE },
2625 { WM_GETMINMAXINFO, sent|defwinproc },
2626 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 },
2627 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTMOVE },
2628 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2629 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI child win2000 */
2630 { WM_NCCALCSIZE, sent|wparam|defwinproc|optional, 1 },
2631 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI child XP */
2632 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI child XP */
2633 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI client XP */
2634 /* in MDI frame */
2635 { 0x0093, sent|optional },
2636 { WM_NCCALCSIZE, sent|wparam|optional, 1 },
2637 { 0x0093, sent|defwinproc|optional },
2638 { 0x0093, sent|defwinproc|optional },
2639 { 0x0093, sent|defwinproc|optional },
2640 { 0x0091, sent|defwinproc|optional },
2641 { 0x0092, sent|defwinproc|optional },
2642 { 0x0092, sent|defwinproc|optional },
2643 { 0x0092, sent|defwinproc|optional },
2644 { 0x0092, sent|defwinproc|optional },
2645 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI frame XP */
2646 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI frame XP */
2647 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI child XP */
2648 { 0 }
2650 /* ShowWindow(SW_MAXIMIZE) for a visible MDI child window */
2651 static const struct message WmMaximizeMDIchildVisibleSeq[] = {
2652 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
2653 { WM_GETMINMAXINFO, sent },
2654 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|0x8000 },
2655 { WM_NCCALCSIZE, sent|wparam, 1 },
2656 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2657 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|0x8000 },
2658 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2659 /* in MDI frame */
2660 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2661 { WM_NCCALCSIZE, sent|wparam, 1 },
2662 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2663 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2664 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2665 { 0 }
2667 /* ShowWindow(SW_RESTORE) for a visible maximized MDI child window */
2668 static const struct message WmRestoreMDIchildVisibleSeq[] = {
2669 { HCBT_MINMAX, hook|lparam, 0, SW_RESTORE },
2670 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|0x8000 },
2671 { WM_NCCALCSIZE, sent|wparam, 1 },
2672 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2673 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|0x8000 },
2674 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2675 /* in MDI frame */
2676 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2677 { WM_NCCALCSIZE, sent|wparam, 1 },
2678 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2679 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2680 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2681 { 0 }
2683 /* ShowWindow(SW_RESTORE) for a visible minimized MDI child window */
2684 static const struct message WmRestoreMDIchildVisibleSeq_2[] = {
2685 { HCBT_MINMAX, hook|lparam, 0, SW_RESTORE },
2686 { WM_QUERYOPEN, sent|wparam|lparam, 0, 0 },
2687 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOCOPYBITS|0x8000 },
2688 { WM_NCCALCSIZE, sent|wparam, 1 },
2689 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2690 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_NOCLIENTSIZE|0x8000 },
2691 { WM_MOVE, sent|defwinproc },
2692 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2693 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2694 { EVENT_SYSTEM_MINIMIZEEND, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2695 { HCBT_SETFOCUS, hook },
2696 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
2697 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
2698 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2699 { WM_SETFOCUS, sent },
2700 { 0 }
2702 /* ShowWindow(SW_MINIMIZE) for a visible restored MDI child window */
2703 static const struct message WmMinimizeMDIchildVisibleSeq[] = {
2704 { HCBT_MINMAX, hook|lparam, 0, SW_MINIMIZE },
2705 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOCOPYBITS|0x8000 },
2706 { WM_NCCALCSIZE, sent|wparam, 1 },
2707 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOCOPYBITS|SWP_NOCLIENTSIZE|0x8000 },
2708 { WM_MOVE, sent|defwinproc },
2709 { WM_SIZE, sent|defwinproc|wparam, SIZE_MINIMIZED },
2710 { WM_CHILDACTIVATE, sent|wparam|lparam|defwinproc, 0, 0 },
2711 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2712 { EVENT_SYSTEM_MINIMIZESTART, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2713 /* FIXME: Wine creates an icon/title window while Windows doesn't */
2714 { WM_PARENTNOTIFY, sent|parent|wparam|optional, WM_CREATE }, /* MDI client */
2715 { 0 }
2717 /* ShowWindow(SW_RESTORE) for a not visible MDI child window */
2718 static const struct message WmRestoreMDIchildInisibleSeq[] = {
2719 { HCBT_MINMAX, hook|lparam, 0, SW_RESTORE },
2720 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|0x8000 },
2721 { WM_NCCALCSIZE, sent|wparam, 1 },
2722 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2723 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2724 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|0x8000 },
2725 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2726 /* in MDI frame */
2727 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2728 { WM_NCCALCSIZE, sent|wparam, 1 },
2729 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2730 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2731 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2732 { 0 }
2735 static HWND mdi_client;
2736 static WNDPROC old_mdi_client_proc;
2738 static LRESULT WINAPI mdi_client_hook_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
2740 struct message msg;
2742 /* do not log painting messages */
2743 if (message != WM_PAINT &&
2744 message != WM_NCPAINT &&
2745 message != WM_SYNCPAINT &&
2746 message != WM_ERASEBKGND &&
2747 message != WM_NCHITTEST &&
2748 message != WM_GETTEXT &&
2749 message != WM_MDIGETACTIVE &&
2750 message != WM_GETICON &&
2751 message != WM_DEVICECHANGE)
2753 trace("mdi client: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
2755 switch (message)
2757 case WM_WINDOWPOSCHANGING:
2758 case WM_WINDOWPOSCHANGED:
2760 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
2762 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
2763 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
2764 winpos->hwnd, winpos->hwndInsertAfter,
2765 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
2766 dump_winpos_flags(winpos->flags);
2768 /* Log only documented flags, win2k uses 0x1000 and 0x2000
2769 * in the high word for internal purposes
2771 wParam = winpos->flags & 0xffff;
2772 /* We are not interested in the flags that don't match under XP and Win9x */
2773 wParam &= ~(SWP_NOZORDER);
2774 break;
2778 msg.message = message;
2779 msg.flags = sent|wparam|lparam;
2780 msg.wParam = wParam;
2781 msg.lParam = lParam;
2782 add_message(&msg);
2785 return CallWindowProcA(old_mdi_client_proc, hwnd, message, wParam, lParam);
2788 static LRESULT WINAPI mdi_child_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
2790 static long defwndproc_counter = 0;
2791 LRESULT ret;
2792 struct message msg;
2794 /* do not log painting messages */
2795 if (message != WM_PAINT &&
2796 message != WM_NCPAINT &&
2797 message != WM_SYNCPAINT &&
2798 message != WM_ERASEBKGND &&
2799 message != WM_NCHITTEST &&
2800 message != WM_GETTEXT &&
2801 message != WM_GETICON &&
2802 message != WM_DEVICECHANGE)
2804 trace("mdi child: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
2806 switch (message)
2808 case WM_WINDOWPOSCHANGING:
2809 case WM_WINDOWPOSCHANGED:
2811 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
2813 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
2814 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
2815 winpos->hwnd, winpos->hwndInsertAfter,
2816 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
2817 dump_winpos_flags(winpos->flags);
2819 /* Log only documented flags, win2k uses 0x1000 and 0x2000
2820 * in the high word for internal purposes
2822 wParam = winpos->flags & 0xffff;
2823 /* We are not interested in the flags that don't match under XP and Win9x */
2824 wParam &= ~(SWP_NOZORDER);
2825 break;
2828 case WM_MDIACTIVATE:
2830 HWND active, client = GetParent(hwnd);
2832 active = (HWND)SendMessageA(client, WM_MDIGETACTIVE, 0, 0);
2834 if (hwnd == (HWND)lParam) /* if we are being activated */
2835 ok (active == (HWND)lParam, "new active %p != active %p\n", (HWND)lParam, active);
2836 else
2837 ok (active == (HWND)wParam, "old active %p != active %p\n", (HWND)wParam, active);
2838 break;
2842 msg.message = message;
2843 msg.flags = sent|wparam|lparam;
2844 if (defwndproc_counter) msg.flags |= defwinproc;
2845 msg.wParam = wParam;
2846 msg.lParam = lParam;
2847 add_message(&msg);
2850 defwndproc_counter++;
2851 ret = DefMDIChildProcA(hwnd, message, wParam, lParam);
2852 defwndproc_counter--;
2854 return ret;
2857 static LRESULT WINAPI mdi_frame_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
2859 static long defwndproc_counter = 0;
2860 LRESULT ret;
2861 struct message msg;
2863 /* do not log painting messages */
2864 if (message != WM_PAINT &&
2865 message != WM_NCPAINT &&
2866 message != WM_SYNCPAINT &&
2867 message != WM_ERASEBKGND &&
2868 message != WM_NCHITTEST &&
2869 message != WM_GETTEXT &&
2870 message != WM_GETICON &&
2871 message != WM_DEVICECHANGE)
2873 trace("mdi frame: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
2875 switch (message)
2877 case WM_WINDOWPOSCHANGING:
2878 case WM_WINDOWPOSCHANGED:
2880 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
2882 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
2883 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
2884 winpos->hwnd, winpos->hwndInsertAfter,
2885 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
2886 dump_winpos_flags(winpos->flags);
2888 /* Log only documented flags, win2k uses 0x1000 and 0x2000
2889 * in the high word for internal purposes
2891 wParam = winpos->flags & 0xffff;
2892 /* We are not interested in the flags that don't match under XP and Win9x */
2893 wParam &= ~(SWP_NOZORDER);
2894 break;
2898 msg.message = message;
2899 msg.flags = sent|wparam|lparam;
2900 if (defwndproc_counter) msg.flags |= defwinproc;
2901 msg.wParam = wParam;
2902 msg.lParam = lParam;
2903 add_message(&msg);
2906 defwndproc_counter++;
2907 ret = DefFrameProcA(hwnd, mdi_client, message, wParam, lParam);
2908 defwndproc_counter--;
2910 return ret;
2913 static BOOL mdi_RegisterWindowClasses(void)
2915 WNDCLASSA cls;
2917 cls.style = 0;
2918 cls.lpfnWndProc = mdi_frame_wnd_proc;
2919 cls.cbClsExtra = 0;
2920 cls.cbWndExtra = 0;
2921 cls.hInstance = GetModuleHandleA(0);
2922 cls.hIcon = 0;
2923 cls.hCursor = LoadCursorA(0, (LPSTR)IDC_ARROW);
2924 cls.hbrBackground = GetStockObject(WHITE_BRUSH);
2925 cls.lpszMenuName = NULL;
2926 cls.lpszClassName = "MDI_frame_class";
2927 if (!RegisterClassA(&cls)) return FALSE;
2929 cls.lpfnWndProc = mdi_child_wnd_proc;
2930 cls.lpszClassName = "MDI_child_class";
2931 if (!RegisterClassA(&cls)) return FALSE;
2933 if (!GetClassInfoA(0, "MDIClient", &cls)) assert(0);
2934 old_mdi_client_proc = cls.lpfnWndProc;
2935 cls.hInstance = GetModuleHandleA(0);
2936 cls.lpfnWndProc = mdi_client_hook_proc;
2937 cls.lpszClassName = "MDI_client_class";
2938 if (!RegisterClassA(&cls)) assert(0);
2940 return TRUE;
2943 static void test_mdi_messages(void)
2945 MDICREATESTRUCTA mdi_cs;
2946 CLIENTCREATESTRUCT client_cs;
2947 HWND mdi_frame, mdi_child, mdi_child2, active_child;
2948 BOOL zoomed;
2949 HMENU hMenu = CreateMenu();
2951 assert(mdi_RegisterWindowClasses());
2953 flush_sequence();
2955 trace("creating MDI frame window\n");
2956 mdi_frame = CreateWindowExA(0, "MDI_frame_class", "MDI frame window",
2957 WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX |
2958 WS_MAXIMIZEBOX | WS_VISIBLE,
2959 100, 100, CW_USEDEFAULT, CW_USEDEFAULT,
2960 GetDesktopWindow(), hMenu,
2961 GetModuleHandleA(0), NULL);
2962 assert(mdi_frame);
2963 ok_sequence(WmCreateMDIframeSeq, "Create MDI frame window", FALSE);
2965 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2966 ok(GetFocus() == mdi_frame, "wrong focus window %p\n", GetFocus());
2968 trace("creating MDI client window\n");
2969 client_cs.hWindowMenu = 0;
2970 client_cs.idFirstChild = MDI_FIRST_CHILD_ID;
2971 mdi_client = CreateWindowExA(0, "MDI_client_class",
2972 NULL,
2973 WS_CHILD | WS_VISIBLE | MDIS_ALLCHILDSTYLES,
2974 0, 0, 0, 0,
2975 mdi_frame, 0, GetModuleHandleA(0), &client_cs);
2976 assert(mdi_client);
2977 ok_sequence(WmCreateMDIclientSeq, "Create visible MDI client window", FALSE);
2979 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2980 ok(GetFocus() == mdi_frame, "input focus should be on MDI frame not on %p\n", GetFocus());
2982 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2983 ok(!active_child, "wrong active MDI child %p\n", active_child);
2984 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
2986 SetFocus(0);
2987 flush_sequence();
2989 trace("creating invisible MDI child window\n");
2990 mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
2991 WS_CHILD,
2992 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
2993 mdi_client, 0, GetModuleHandleA(0), NULL);
2994 assert(mdi_child);
2996 flush_sequence();
2997 ShowWindow(mdi_child, SW_SHOWNORMAL);
2998 ok_sequence(WmShowChildSeq, "ShowWindow(SW_SHOWNORMAL) MDI child window", FALSE);
3000 ok(GetWindowLongA(mdi_child, GWL_STYLE) & WS_VISIBLE, "MDI child should be visible\n");
3001 ok(IsWindowVisible(mdi_child), "MDI child should be visible\n");
3003 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3004 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3006 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3007 ok(!active_child, "wrong active MDI child %p\n", active_child);
3008 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
3010 ShowWindow(mdi_child, SW_HIDE);
3011 ok_sequence(WmHideChildSeq, "ShowWindow(SW_HIDE) MDI child window", FALSE);
3012 flush_sequence();
3014 ShowWindow(mdi_child, SW_SHOW);
3015 ok_sequence(WmShowChildSeq, "ShowWindow(SW_SHOW) MDI child window", FALSE);
3017 ok(GetWindowLongA(mdi_child, GWL_STYLE) & WS_VISIBLE, "MDI child should be visible\n");
3018 ok(IsWindowVisible(mdi_child), "MDI child should be visible\n");
3020 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3021 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3023 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3024 ok(!active_child, "wrong active MDI child %p\n", active_child);
3025 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
3027 DestroyWindow(mdi_child);
3028 flush_sequence();
3030 trace("creating visible MDI child window\n");
3031 mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
3032 WS_CHILD | WS_VISIBLE,
3033 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
3034 mdi_client, 0, GetModuleHandleA(0), NULL);
3035 assert(mdi_child);
3036 ok_sequence(WmCreateMDIchildVisibleSeq, "Create visible MDI child window", FALSE);
3038 ok(GetWindowLongA(mdi_child, GWL_STYLE) & WS_VISIBLE, "MDI child should be visible\n");
3039 ok(IsWindowVisible(mdi_child), "MDI child should be visible\n");
3041 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3042 ok(GetFocus() == mdi_child, "wrong focus window %p\n", GetFocus());
3044 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3045 ok(active_child == mdi_child, "wrong active MDI child %p\n", active_child);
3046 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
3047 flush_sequence();
3049 DestroyWindow(mdi_child);
3050 ok_sequence(WmDestroyMDIchildVisibleSeq, "Destroy visible MDI child window", TRUE);
3052 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3053 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3055 /* Win2k: MDI client still returns a just destroyed child as active
3056 * Win9x: MDI client returns 0
3058 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3059 ok(active_child == mdi_child || /* win2k */
3060 !active_child, /* win9x */
3061 "wrong active MDI child %p\n", active_child);
3062 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
3064 flush_sequence();
3066 trace("creating invisible MDI child window\n");
3067 mdi_child2 = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
3068 WS_CHILD,
3069 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
3070 mdi_client, 0, GetModuleHandleA(0), NULL);
3071 assert(mdi_child2);
3072 ok_sequence(WmCreateMDIchildInvisibleSeq, "Create invisible MDI child window", FALSE);
3074 ok(!(GetWindowLongA(mdi_child2, GWL_STYLE) & WS_VISIBLE), "MDI child should not be visible\n");
3075 ok(!IsWindowVisible(mdi_child2), "MDI child should not be visible\n");
3077 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3078 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3080 /* Win2k: MDI client still returns a just destroyed child as active
3081 * Win9x: MDI client returns mdi_child2
3083 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3084 ok(active_child == mdi_child || /* win2k */
3085 active_child == mdi_child2, /* win9x */
3086 "wrong active MDI child %p\n", active_child);
3087 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
3088 flush_sequence();
3090 ShowWindow(mdi_child2, SW_MAXIMIZE);
3091 ok_sequence(WmMaximizeMDIchildInvisibleSeq, "ShowWindow(SW_MAXIMIZE):invisible MDI child", FALSE);
3093 ok(GetWindowLongA(mdi_child2, GWL_STYLE) & WS_VISIBLE, "MDI child should be visible\n");
3094 ok(IsWindowVisible(mdi_child2), "MDI child should be visible\n");
3096 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3097 ok(active_child == mdi_child2, "wrong active MDI child %p\n", active_child);
3098 ok(zoomed, "wrong zoomed state %d\n", zoomed);
3099 flush_sequence();
3101 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3102 ok(GetFocus() == mdi_child2 || /* win2k */
3103 GetFocus() == 0, /* win9x */
3104 "wrong focus window %p\n", GetFocus());
3106 SetFocus(0);
3107 flush_sequence();
3109 ShowWindow(mdi_child2, SW_HIDE);
3110 ok_sequence(WmHideChildSeq, "ShowWindow(SW_HIDE):MDI child", FALSE);
3112 ShowWindow(mdi_child2, SW_RESTORE);
3113 ok_sequence(WmRestoreMDIchildInisibleSeq, "ShowWindow(SW_RESTORE):invisible MDI child", FALSE);
3114 flush_sequence();
3116 ok(GetWindowLongA(mdi_child2, GWL_STYLE) & WS_VISIBLE, "MDI child should be visible\n");
3117 ok(IsWindowVisible(mdi_child2), "MDI child should be visible\n");
3119 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3120 ok(active_child == mdi_child2, "wrong active MDI child %p\n", active_child);
3121 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
3122 flush_sequence();
3124 SetFocus(0);
3125 flush_sequence();
3127 ShowWindow(mdi_child2, SW_HIDE);
3128 ok_sequence(WmHideChildSeq, "ShowWindow(SW_HIDE):MDI child", FALSE);
3130 ShowWindow(mdi_child2, SW_SHOW);
3131 ok_sequence(WmShowChildSeq, "ShowWindow(SW_SHOW):MDI child", FALSE);
3133 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3134 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3136 ShowWindow(mdi_child2, SW_MAXIMIZE);
3137 ok_sequence(WmMaximizeMDIchildVisibleSeq, "ShowWindow(SW_MAXIMIZE):MDI child", FALSE);
3139 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3140 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3142 ShowWindow(mdi_child2, SW_RESTORE);
3143 ok_sequence(WmRestoreMDIchildVisibleSeq, "ShowWindow(SW_RESTORE):maximized MDI child", FALSE);
3145 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3146 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3148 ShowWindow(mdi_child2, SW_MINIMIZE);
3149 ok_sequence(WmMinimizeMDIchildVisibleSeq, "ShowWindow(SW_MINIMIZE):MDI child", TRUE);
3151 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3152 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3154 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3155 ok(active_child == mdi_child2, "wrong active MDI child %p\n", active_child);
3156 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
3157 flush_sequence();
3159 ShowWindow(mdi_child2, SW_RESTORE);
3160 ok_sequence(WmRestoreMDIchildVisibleSeq_2, "ShowWindow(SW_RESTORE):minimized MDI child", TRUE);
3162 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3163 ok(GetFocus() == mdi_child2, "wrong focus window %p\n", GetFocus());
3165 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3166 ok(active_child == mdi_child2, "wrong active MDI child %p\n", active_child);
3167 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
3168 flush_sequence();
3170 SetFocus(0);
3171 flush_sequence();
3173 ShowWindow(mdi_child2, SW_HIDE);
3174 ok_sequence(WmHideChildSeq, "ShowWindow(SW_HIDE):MDI child", FALSE);
3176 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3177 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3179 DestroyWindow(mdi_child2);
3180 ok_sequence(WmDestroyMDIchildInvisibleSeq, "Destroy invisible MDI child window", FALSE);
3182 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3183 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3185 /* test for maximized MDI children */
3186 trace("creating maximized visible MDI child window 1\n");
3187 mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
3188 WS_CHILD | WS_VISIBLE | WS_MAXIMIZEBOX | WS_MAXIMIZE,
3189 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
3190 mdi_client, 0, GetModuleHandleA(0), NULL);
3191 assert(mdi_child);
3192 ok_sequence(WmCreateMDIchildVisibleMaxSeq1, "Create maximized visible 1st MDI child window", TRUE);
3193 ok(IsZoomed(mdi_child), "1st MDI child should be maximized\n");
3195 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3196 ok(GetFocus() == mdi_child || /* win2k */
3197 GetFocus() == 0, /* win9x */
3198 "wrong focus window %p\n", GetFocus());
3200 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3201 ok(active_child == mdi_child, "wrong active MDI child %p\n", active_child);
3202 ok(zoomed, "wrong zoomed state %d\n", zoomed);
3203 flush_sequence();
3205 trace("creating maximized visible MDI child window 2\n");
3206 mdi_child2 = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
3207 WS_CHILD | WS_VISIBLE | WS_MAXIMIZEBOX | WS_MAXIMIZE,
3208 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
3209 mdi_client, 0, GetModuleHandleA(0), NULL);
3210 assert(mdi_child2);
3211 ok_sequence(WmCreateMDIchildVisibleMaxSeq2, "Create maximized visible 2nd MDI child 2 window", TRUE);
3212 ok(IsZoomed(mdi_child2), "2nd MDI child should be maximized\n");
3213 ok(!IsZoomed(mdi_child), "1st MDI child should NOT be maximized\n");
3215 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3216 ok(GetFocus() == mdi_child2, "wrong focus window %p\n", GetFocus());
3218 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3219 ok(active_child == mdi_child2, "wrong active MDI child %p\n", active_child);
3220 ok(zoomed, "wrong zoomed state %d\n", zoomed);
3221 flush_sequence();
3223 trace("destroying maximized visible MDI child window 2\n");
3224 DestroyWindow(mdi_child2);
3225 ok_sequence(WmDestroyMDIchildVisibleSeq, "Destroy visible MDI child window", TRUE);
3227 ok(!IsZoomed(mdi_child), "1st MDI child should NOT be maximized\n");
3229 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3230 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3232 /* Win2k: MDI client still returns a just destroyed child as active
3233 * Win9x: MDI client returns 0
3235 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3236 ok(active_child == mdi_child2 || /* win2k */
3237 !active_child, /* win9x */
3238 "wrong active MDI child %p\n", active_child);
3239 flush_sequence();
3241 ShowWindow(mdi_child, SW_MAXIMIZE);
3242 ok(IsZoomed(mdi_child), "1st MDI child should be maximized\n");
3243 flush_sequence();
3245 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3246 ok(GetFocus() == mdi_child, "wrong focus window %p\n", GetFocus());
3248 trace("re-creating maximized visible MDI child window 2\n");
3249 mdi_child2 = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
3250 WS_CHILD | WS_VISIBLE | WS_MAXIMIZEBOX | WS_MAXIMIZE,
3251 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
3252 mdi_client, 0, GetModuleHandleA(0), NULL);
3253 assert(mdi_child2);
3254 ok_sequence(WmCreateMDIchildVisibleMaxSeq2, "Create maximized visible 2nd MDI child 2 window", TRUE);
3255 ok(IsZoomed(mdi_child2), "2nd MDI child should be maximized\n");
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() == mdi_child2, "wrong focus window %p\n", GetFocus());
3261 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3262 ok(active_child == mdi_child2, "wrong active MDI child %p\n", active_child);
3263 ok(zoomed, "wrong zoomed state %d\n", zoomed);
3264 flush_sequence();
3266 SendMessageA(mdi_child2, WM_SYSCOMMAND, SC_CLOSE, 0);
3267 ok_sequence(WmDestroyMDIchildVisibleMaxSeq2, "WM_SYSCOMMAND/SC_CLOSE on a visible maximized MDI child window", TRUE);
3268 ok(!IsWindow(mdi_child2), "MDI child 2 should be destroyed\n");
3270 ok(IsZoomed(mdi_child), "1st MDI child should be maximized\n");
3271 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3272 ok(GetFocus() == mdi_child, "wrong focus window %p\n", GetFocus());
3274 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3275 ok(active_child == mdi_child, "wrong active MDI child %p\n", active_child);
3276 ok(zoomed, "wrong zoomed state %d\n", zoomed);
3277 flush_sequence();
3279 DestroyWindow(mdi_child);
3280 ok_sequence(WmDestroyMDIchildVisibleSeq, "Destroy visible MDI child window", TRUE);
3282 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3283 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3285 /* Win2k: MDI client still returns a just destroyed child as active
3286 * Win9x: MDI client returns 0
3288 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3289 ok(active_child == mdi_child || /* win2k */
3290 !active_child, /* win9x */
3291 "wrong active MDI child %p\n", active_child);
3292 flush_sequence();
3294 trace("creating maximized invisible MDI child window\n");
3295 mdi_child2 = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
3296 WS_CHILD | WS_MAXIMIZE | WS_CAPTION | WS_THICKFRAME,
3297 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
3298 mdi_client, 0, GetModuleHandleA(0), NULL);
3299 assert(mdi_child2);
3300 ok_sequence(WmCreateMDIchildInvisibleMaxSeq4, "Create maximized invisible MDI child window", TRUE);
3301 ok(IsZoomed(mdi_child2), "MDI child should be maximized\n");
3302 ok(!(GetWindowLongA(mdi_child2, GWL_STYLE) & WS_VISIBLE), "MDI child should be not visible\n");
3303 ok(!IsWindowVisible(mdi_child2), "MDI child should be not visible\n");
3305 /* Win2k: MDI client still returns a just destroyed child as active
3306 * Win9x: MDI client returns 0
3308 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3309 ok(active_child == mdi_child || /* win2k */
3310 !active_child, /* win9x */
3311 "wrong active MDI child %p\n", active_child);
3312 flush_sequence();
3314 trace("call ShowWindow(mdi_child, SW_MAXIMIZE)\n");
3315 ShowWindow(mdi_child2, SW_MAXIMIZE);
3316 ok_sequence(WmMaximizeMDIchildInvisibleSeq2, "ShowWindow(SW_MAXIMIZE):invisible maximized MDI child", FALSE);
3317 ok(IsZoomed(mdi_child2), "MDI child should be maximized\n");
3318 ok(GetWindowLongA(mdi_child2, GWL_STYLE) & WS_VISIBLE, "MDI child should be visible\n");
3319 ok(IsWindowVisible(mdi_child2), "MDI child should be visible\n");
3321 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3322 ok(active_child == mdi_child2, "wrong active MDI child %p\n", active_child);
3323 ok(zoomed, "wrong zoomed state %d\n", zoomed);
3324 flush_sequence();
3326 SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child2, 0);
3327 flush_sequence();
3329 /* end of test for maximized MDI children */
3330 SetFocus(0);
3331 flush_sequence();
3332 trace("creating maximized visible MDI child window 1(Switch test)\n");
3333 mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
3334 WS_CHILD | WS_VISIBLE | WS_MAXIMIZEBOX | WS_MAXIMIZE,
3335 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
3336 mdi_client, 0, GetModuleHandleA(0), NULL);
3337 assert(mdi_child);
3338 ok_sequence(WmCreateMDIchildVisibleMaxSeq1, "Create maximized visible 1st MDI child window(Switch test)", TRUE);
3339 ok(IsZoomed(mdi_child), "1st MDI child should be maximized(Switch test)\n");
3341 ok(GetActiveWindow() == mdi_frame, "wrong active window %p(Switch test)\n", GetActiveWindow());
3342 ok(GetFocus() == mdi_child || /* win2k */
3343 GetFocus() == 0, /* win9x */
3344 "wrong focus window %p(Switch test)\n", GetFocus());
3346 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3347 ok(active_child == mdi_child, "wrong active MDI child %p(Switch test)\n", active_child);
3348 ok(zoomed, "wrong zoomed state %d(Switch test)\n", zoomed);
3349 flush_sequence();
3351 trace("creating maximized visible MDI child window 2(Switch test)\n");
3352 mdi_child2 = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
3353 WS_CHILD | WS_VISIBLE | WS_MAXIMIZEBOX | WS_MAXIMIZE,
3354 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
3355 mdi_client, 0, GetModuleHandleA(0), NULL);
3356 assert(mdi_child2);
3357 ok_sequence(WmCreateMDIchildVisibleMaxSeq2, "Create maximized visible 2nd MDI child window (Switch test)", TRUE);
3359 ok(IsZoomed(mdi_child2), "2nd MDI child should be maximized(Switch test)\n");
3360 ok(!IsZoomed(mdi_child), "1st MDI child should NOT be maximized(Switch test)\n");
3362 ok(GetActiveWindow() == mdi_frame, "wrong active window %p(Switch test)\n", GetActiveWindow());
3363 ok(GetFocus() == mdi_child2, "wrong focus window %p(Switch test)\n", GetFocus());
3365 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3366 ok(active_child == mdi_child2, "wrong active MDI child %p(Switch test)\n", active_child);
3367 ok(zoomed, "wrong zoomed state %d(Switch test)\n", zoomed);
3368 flush_sequence();
3370 trace("Switch child window.\n");
3371 SendMessageA(mdi_client, WM_MDIACTIVATE, (WPARAM)mdi_child, 0);
3372 ok_sequence(WmSwitchChild, "Child did not switch correctly", TRUE);
3373 trace("end of test for switch maximized MDI children\n");
3375 SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child, 0);
3376 flush_sequence();
3378 SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child2, 0);
3379 flush_sequence();
3381 SetFocus(0);
3382 flush_sequence();
3383 /* end of test for switch maximized MDI children */
3385 mdi_cs.szClass = "MDI_child_Class";
3386 mdi_cs.szTitle = "MDI child";
3387 mdi_cs.hOwner = GetModuleHandleA(0);
3388 mdi_cs.x = 0;
3389 mdi_cs.y = 0;
3390 mdi_cs.cx = CW_USEDEFAULT;
3391 mdi_cs.cy = CW_USEDEFAULT;
3392 mdi_cs.style = WS_CHILD | WS_SYSMENU | WS_VISIBLE | WS_MAXIMIZEBOX | WS_MAXIMIZE;
3393 mdi_cs.lParam = 0;
3394 mdi_child = (HWND)SendMessageA(mdi_client, WM_MDICREATE, 0, (LPARAM)&mdi_cs);
3395 ok(mdi_child != 0, "MDI child creation failed\n");
3396 ok_sequence(WmCreateMDIchildVisibleMaxSeq3, "WM_MDICREATE for maximized visible MDI child window", TRUE);
3398 ok(GetMenuItemID(hMenu, GetMenuItemCount(hMenu) - 1) == SC_CLOSE, "SC_CLOSE menu item not found\n");
3400 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3401 ok(active_child == mdi_child, "wrong active MDI child %p\n", active_child);
3403 ok(IsZoomed(mdi_child), "MDI child should be maximized\n");
3404 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3405 ok(GetFocus() == mdi_child, "wrong focus window %p\n", GetFocus());
3407 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3408 ok(active_child == mdi_child, "wrong active MDI child %p\n", active_child);
3409 ok(zoomed, "wrong zoomed state %d\n", zoomed);
3410 flush_sequence();
3412 SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child, 0);
3413 ok_sequence(WmDestroyMDIchildVisibleMaxSeq1, "Destroy visible maximized MDI child window", TRUE);
3415 ok(!IsWindow(mdi_child), "MDI child should be destroyed\n");
3416 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3417 ok(!active_child, "wrong active MDI child %p\n", active_child);
3419 SetFocus(0);
3420 flush_sequence();
3422 DestroyWindow(mdi_client);
3423 ok_sequence(WmDestroyMDIclientSeq, "Destroy MDI client window", FALSE);
3425 /* test maximization of MDI child with invisible parent */
3426 client_cs.hWindowMenu = 0;
3427 mdi_client = CreateWindow("MDI_client_class",
3428 NULL,
3429 WS_CHILD | WS_CLIPCHILDREN | WS_VSCROLL | WS_HSCROLL | WS_VISIBLE,
3430 0, 0, 660, 430,
3431 mdi_frame, 0, GetModuleHandleA(0), &client_cs);
3432 ok_sequence(WmCreateMDIclientSeq, "Create MDI client window", FALSE);
3434 ShowWindow(mdi_client, SW_HIDE);
3435 ok_sequence(WmHideMDIclientSeq, "Hide MDI client window", FALSE);
3437 mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
3438 WS_CHILD | WS_CLIPCHILDREN | WS_VSCROLL | WS_HSCROLL,
3439 0, 0, 650, 440,
3440 mdi_client, 0, GetModuleHandleA(0), NULL);
3441 ok_sequence(WmCreateMDIchildInvisibleParentSeq, "Create MDI child window with invisible parent", FALSE);
3443 SendMessage(mdi_client, WM_MDIMAXIMIZE, (WPARAM) mdi_child, 0);
3444 ok_sequence(WmMaximizeMDIchildInvisibleParentSeq, "Maximize MDI child window with invisible parent", TRUE);
3445 zoomed = IsZoomed(mdi_child);
3446 ok(zoomed, "wrong zoomed state %d\n", zoomed);
3448 ShowWindow(mdi_client, SW_SHOW);
3449 ok_sequence(WmShowMDIclientSeq, "Show MDI client window", FALSE);
3451 DestroyWindow(mdi_child);
3452 ok_sequence(WmDestroyMDIchildVisibleSeq, "Destroy visible maximized MDI child window", TRUE);
3454 /* end of test for maximization of MDI child with invisible parent */
3456 DestroyWindow(mdi_client);
3457 ok_sequence(WmDestroyMDIclientSeq, "Destroy MDI client window", FALSE);
3459 DestroyWindow(mdi_frame);
3460 ok_sequence(WmDestroyMDIframeSeq, "Destroy MDI frame window", FALSE);
3462 /************************* End of MDI test **********************************/
3464 static void test_WM_SETREDRAW(HWND hwnd)
3466 DWORD style = GetWindowLongA(hwnd, GWL_STYLE);
3468 flush_sequence();
3470 SendMessageA(hwnd, WM_SETREDRAW, FALSE, 0);
3471 ok_sequence(WmSetRedrawFalseSeq, "SetRedraw:FALSE", FALSE);
3473 ok(!(GetWindowLongA(hwnd, GWL_STYLE) & WS_VISIBLE), "WS_VISIBLE should NOT be set\n");
3474 ok(!IsWindowVisible(hwnd), "IsWindowVisible() should return FALSE\n");
3476 flush_sequence();
3477 SendMessageA(hwnd, WM_SETREDRAW, TRUE, 0);
3478 ok_sequence(WmSetRedrawTrueSeq, "SetRedraw:TRUE", FALSE);
3480 ok(GetWindowLongA(hwnd, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
3481 ok(IsWindowVisible(hwnd), "IsWindowVisible() should return TRUE\n");
3483 /* restore original WS_VISIBLE state */
3484 SetWindowLongA(hwnd, GWL_STYLE, style);
3486 flush_sequence();
3489 static INT_PTR CALLBACK TestModalDlgProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
3491 struct message msg;
3493 trace("dialog: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
3495 /* explicitly ignore WM_GETICON message */
3496 if (message == WM_GETICON) return 0;
3498 switch (message)
3500 /* ignore */
3501 case WM_MOUSEMOVE:
3502 case WM_SETCURSOR:
3503 case WM_DEVICECHANGE:
3504 return 0;
3505 case WM_NCHITTEST:
3506 return HTCLIENT;
3508 case WM_WINDOWPOSCHANGING:
3509 case WM_WINDOWPOSCHANGED:
3511 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
3513 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
3514 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
3515 winpos->hwnd, winpos->hwndInsertAfter,
3516 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
3517 dump_winpos_flags(winpos->flags);
3519 /* Log only documented flags, win2k uses 0x1000 and 0x2000
3520 * in the high word for internal purposes
3522 wParam = winpos->flags & 0xffff;
3523 /* We are not interested in the flags that don't match under XP and Win9x */
3524 wParam &= ~(SWP_NOZORDER);
3525 break;
3529 msg.message = message;
3530 msg.flags = sent|wparam|lparam;
3531 msg.wParam = wParam;
3532 msg.lParam = lParam;
3533 add_message(&msg);
3535 if (message == WM_INITDIALOG) SetTimer( hwnd, 1, 100, NULL );
3536 if (message == WM_TIMER) EndDialog( hwnd, 0 );
3537 return 0;
3540 static void test_hv_scroll_1(HWND hwnd, INT ctl, DWORD clear, DWORD set, INT min, INT max)
3542 DWORD style, exstyle;
3543 INT xmin, xmax;
3544 BOOL ret;
3546 exstyle = GetWindowLongA(hwnd, GWL_EXSTYLE);
3547 style = GetWindowLongA(hwnd, GWL_STYLE);
3548 /* do not be confused by WS_DLGFRAME set */
3549 if ((style & WS_CAPTION) == WS_CAPTION) style &= ~WS_CAPTION;
3551 if (clear) ok(style & clear, "style %08x should be set\n", clear);
3552 if (set) ok(!(style & set), "style %08x should not be set\n", set);
3554 ret = SetScrollRange(hwnd, ctl, min, max, FALSE);
3555 ok( ret, "SetScrollRange(%d) error %d\n", ctl, GetLastError());
3556 if ((style & (WS_DLGFRAME | WS_BORDER | WS_THICKFRAME)) || (exstyle & WS_EX_DLGMODALFRAME))
3557 ok_sequence(WmSetScrollRangeHV_NC_Seq, "SetScrollRange(SB_HORZ/SB_VERT) NC", FALSE);
3558 else
3559 ok_sequence(WmSetScrollRangeHVSeq, "SetScrollRange(SB_HORZ/SB_VERT)", FALSE);
3561 style = GetWindowLongA(hwnd, GWL_STYLE);
3562 if (set) ok(style & set, "style %08x should be set\n", set);
3563 if (clear) ok(!(style & clear), "style %08x should not be set\n", clear);
3565 /* a subsequent call should do nothing */
3566 ret = SetScrollRange(hwnd, ctl, min, max, FALSE);
3567 ok( ret, "SetScrollRange(%d) error %d\n", ctl, GetLastError());
3568 ok_sequence(WmEmptySeq, "SetScrollRange(SB_HORZ/SB_VERT) empty sequence", FALSE);
3570 xmin = 0xdeadbeef;
3571 xmax = 0xdeadbeef;
3572 trace("Ignore GetScrollRange error below if you are on Win9x\n");
3573 ret = GetScrollRange(hwnd, ctl, &xmin, &xmax);
3574 ok( ret, "GetScrollRange(%d) error %d\n", ctl, GetLastError());
3575 ok_sequence(WmEmptySeq, "GetScrollRange(SB_HORZ/SB_VERT) empty sequence", FALSE);
3576 ok(xmin == min, "unexpected min scroll value %d\n", xmin);
3577 ok(xmax == max, "unexpected max scroll value %d\n", xmax);
3580 static void test_hv_scroll_2(HWND hwnd, INT ctl, DWORD clear, DWORD set, INT min, INT max)
3582 DWORD style, exstyle;
3583 SCROLLINFO si;
3584 BOOL ret;
3586 exstyle = GetWindowLongA(hwnd, GWL_EXSTYLE);
3587 style = GetWindowLongA(hwnd, GWL_STYLE);
3588 /* do not be confused by WS_DLGFRAME set */
3589 if ((style & WS_CAPTION) == WS_CAPTION) style &= ~WS_CAPTION;
3591 if (clear) ok(style & clear, "style %08x should be set\n", clear);
3592 if (set) ok(!(style & set), "style %08x should not be set\n", set);
3594 si.cbSize = sizeof(si);
3595 si.fMask = SIF_RANGE;
3596 si.nMin = min;
3597 si.nMax = max;
3598 SetScrollInfo(hwnd, ctl, &si, TRUE);
3599 if ((style & (WS_DLGFRAME | WS_BORDER | WS_THICKFRAME)) || (exstyle & WS_EX_DLGMODALFRAME))
3600 ok_sequence(WmSetScrollRangeHV_NC_Seq, "SetScrollInfo(SB_HORZ/SB_VERT) NC", FALSE);
3601 else
3602 ok_sequence(WmSetScrollRangeHVSeq, "SetScrollInfo(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 SetScrollInfo(hwnd, ctl, &si, TRUE);
3610 if (style & WS_HSCROLL)
3611 ok_sequence(WmSetScrollRangeHSeq_empty, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE);
3612 else if (style & WS_VSCROLL)
3613 ok_sequence(WmSetScrollRangeVSeq_empty, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE);
3614 else
3615 ok_sequence(WmEmptySeq, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE);
3617 si.fMask = SIF_PAGE;
3618 si.nPage = 5;
3619 SetScrollInfo(hwnd, ctl, &si, FALSE);
3620 ok_sequence(WmEmptySeq, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE);
3622 si.fMask = SIF_POS;
3623 si.nPos = max - 1;
3624 SetScrollInfo(hwnd, ctl, &si, FALSE);
3625 ok_sequence(WmEmptySeq, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE);
3627 si.fMask = SIF_RANGE;
3628 si.nMin = 0xdeadbeef;
3629 si.nMax = 0xdeadbeef;
3630 ret = GetScrollInfo(hwnd, ctl, &si);
3631 ok( ret, "GetScrollInfo error %d\n", GetLastError());
3632 ok_sequence(WmEmptySeq, "GetScrollRange(SB_HORZ/SB_VERT) empty sequence", FALSE);
3633 ok(si.nMin == min, "unexpected min scroll value %d\n", si.nMin);
3634 ok(si.nMax == max, "unexpected max scroll value %d\n", si.nMax);
3637 /* Win9x sends WM_USER+xxx while and NT versions send SBM_xxx messages */
3638 static void test_scroll_messages(HWND hwnd)
3640 SCROLLINFO si;
3641 INT min, max;
3642 BOOL ret;
3644 min = 0xdeadbeef;
3645 max = 0xdeadbeef;
3646 ret = GetScrollRange(hwnd, SB_CTL, &min, &max);
3647 ok( ret, "GetScrollRange error %d\n", GetLastError());
3648 if (sequence->message != WmGetScrollRangeSeq[0].message)
3649 trace("GetScrollRange(SB_CTL) generated unknown message %04x\n", sequence->message);
3650 /* values of min and max are undefined */
3651 flush_sequence();
3653 ret = SetScrollRange(hwnd, SB_CTL, 10, 150, FALSE);
3654 ok( ret, "SetScrollRange error %d\n", GetLastError());
3655 if (sequence->message != WmSetScrollRangeSeq[0].message)
3656 trace("SetScrollRange(SB_CTL) generated unknown message %04x\n", sequence->message);
3657 flush_sequence();
3659 min = 0xdeadbeef;
3660 max = 0xdeadbeef;
3661 ret = GetScrollRange(hwnd, SB_CTL, &min, &max);
3662 ok( ret, "GetScrollRange error %d\n", GetLastError());
3663 if (sequence->message != WmGetScrollRangeSeq[0].message)
3664 trace("GetScrollRange(SB_CTL) generated unknown message %04x\n", sequence->message);
3665 /* values of min and max are undefined */
3666 flush_sequence();
3668 si.cbSize = sizeof(si);
3669 si.fMask = SIF_RANGE;
3670 si.nMin = 20;
3671 si.nMax = 160;
3672 SetScrollInfo(hwnd, SB_CTL, &si, FALSE);
3673 if (sequence->message != WmSetScrollRangeSeq[0].message)
3674 trace("SetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence->message);
3675 flush_sequence();
3677 si.fMask = SIF_PAGE;
3678 si.nPage = 10;
3679 SetScrollInfo(hwnd, SB_CTL, &si, FALSE);
3680 if (sequence->message != WmSetScrollRangeSeq[0].message)
3681 trace("SetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence->message);
3682 flush_sequence();
3684 si.fMask = SIF_POS;
3685 si.nPos = 20;
3686 SetScrollInfo(hwnd, SB_CTL, &si, FALSE);
3687 if (sequence->message != WmSetScrollRangeSeq[0].message)
3688 trace("SetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence->message);
3689 flush_sequence();
3691 si.fMask = SIF_RANGE;
3692 si.nMin = 0xdeadbeef;
3693 si.nMax = 0xdeadbeef;
3694 ret = GetScrollInfo(hwnd, SB_CTL, &si);
3695 ok( ret, "GetScrollInfo error %d\n", GetLastError());
3696 if (sequence->message != WmGetScrollInfoSeq[0].message)
3697 trace("GetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence->message);
3698 /* values of min and max are undefined */
3699 flush_sequence();
3701 /* set WS_HSCROLL */
3702 test_hv_scroll_1(hwnd, SB_HORZ, 0, WS_HSCROLL, 10, 150);
3703 /* clear WS_HSCROLL */
3704 test_hv_scroll_1(hwnd, SB_HORZ, WS_HSCROLL, 0, 0, 0);
3706 /* set WS_HSCROLL */
3707 test_hv_scroll_2(hwnd, SB_HORZ, 0, WS_HSCROLL, 10, 150);
3708 /* clear WS_HSCROLL */
3709 test_hv_scroll_2(hwnd, SB_HORZ, WS_HSCROLL, 0, 0, 0);
3711 /* set WS_VSCROLL */
3712 test_hv_scroll_1(hwnd, SB_VERT, 0, WS_VSCROLL, 10, 150);
3713 /* clear WS_VSCROLL */
3714 test_hv_scroll_1(hwnd, SB_VERT, WS_VSCROLL, 0, 0, 0);
3716 /* set WS_VSCROLL */
3717 test_hv_scroll_2(hwnd, SB_VERT, 0, WS_VSCROLL, 10, 150);
3718 /* clear WS_VSCROLL */
3719 test_hv_scroll_2(hwnd, SB_VERT, WS_VSCROLL, 0, 0, 0);
3722 static void test_showwindow(void)
3724 HWND hwnd, hchild;
3725 RECT rc;
3727 hwnd = CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW,
3728 100, 100, 200, 200, 0, 0, 0, NULL);
3729 ok (hwnd != 0, "Failed to create overlapped window\n");
3730 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
3731 0, 0, 10, 10, hwnd, 0, 0, NULL);
3732 ok (hchild != 0, "Failed to create child\n");
3733 flush_sequence();
3735 /* ShowWindow( SW_SHOWNA) for invisible top level window */
3736 trace("calling ShowWindow( SW_SHOWNA) for invisible top level window\n");
3737 ok( ShowWindow(hwnd, SW_SHOWNA) == FALSE, "ShowWindow: window was visible\n" );
3738 ok_sequence(WmSHOWNATopInvisible, "ShowWindow(SW_SHOWNA) on invisible top level window", TRUE);
3739 trace("done\n");
3741 /* ShowWindow( SW_SHOWNA) for now visible top level window */
3742 trace("calling ShowWindow( SW_SHOWNA) for now visible top level window\n");
3743 ok( ShowWindow(hwnd, SW_SHOWNA) != FALSE, "ShowWindow: window was invisible\n" );
3744 ok_sequence(WmSHOWNATopVisible, "ShowWindow(SW_SHOWNA) on visible top level window", FALSE);
3745 trace("done\n");
3746 /* back to invisible */
3747 ShowWindow(hchild, SW_HIDE);
3748 ShowWindow(hwnd, SW_HIDE);
3749 flush_sequence();
3750 /* ShowWindow(SW_SHOWNA) with child and parent invisible */
3751 trace("calling ShowWindow( SW_SHOWNA) for invisible child with invisible parent\n");
3752 ok( ShowWindow(hchild, SW_SHOWNA) == FALSE, "ShowWindow: window was visible\n" );
3753 ok_sequence(WmSHOWNAChildInvisParInvis, "ShowWindow(SW_SHOWNA) invisible child and parent", FALSE);
3754 trace("done\n");
3755 /* ShowWindow(SW_SHOWNA) with child visible and parent invisible */
3756 ok( ShowWindow(hchild, SW_SHOW) != FALSE, "ShowWindow: window was invisible\n" );
3757 flush_sequence();
3758 trace("calling ShowWindow( SW_SHOWNA) for the visible child and invisible parent\n");
3759 ok( ShowWindow(hchild, SW_SHOWNA) != FALSE, "ShowWindow: window was invisible\n" );
3760 ok_sequence(WmSHOWNAChildVisParInvis, "ShowWindow(SW_SHOWNA) visible child and invisible parent", FALSE);
3761 trace("done\n");
3762 /* ShowWindow(SW_SHOWNA) with child visible and parent visible */
3763 ShowWindow( hwnd, SW_SHOW);
3764 flush_sequence();
3765 trace("calling ShowWindow( SW_SHOWNA) for the visible child and parent\n");
3766 ok( ShowWindow(hchild, SW_SHOWNA) != FALSE, "ShowWindow: window was invisible\n" );
3767 ok_sequence(WmSHOWNAChildVisParVis, "ShowWindow(SW_SHOWNA) for the visible child and parent", FALSE);
3768 trace("done\n");
3770 /* ShowWindow(SW_SHOWNA) with child invisible and parent visible */
3771 ShowWindow( hchild, SW_HIDE);
3772 flush_sequence();
3773 trace("calling ShowWindow( SW_SHOWNA) for the invisible child and visible parent\n");
3774 ok( ShowWindow(hchild, SW_SHOWNA) == FALSE, "ShowWindow: window was visible\n" );
3775 ok_sequence(WmSHOWNAChildInvisParVis, "ShowWindow(SW_SHOWNA) for the invisible child and visible parent", FALSE);
3776 trace("done\n");
3778 SetCapture(hchild);
3779 ok(GetCapture() == hchild, "wrong capture window %p\n", GetCapture());
3780 DestroyWindow(hchild);
3781 ok(!GetCapture(), "wrong capture window %p\n", GetCapture());
3783 DestroyWindow(hwnd);
3784 flush_sequence();
3786 /* Popup windows */
3787 /* Test 1:
3788 * 1. Create invisible maximized popup window.
3789 * 2. Move and resize it.
3790 * 3. Show it maximized.
3792 trace("calling CreateWindowExA( WS_MAXIMIZE ) for invisible maximized popup window\n");
3793 hwnd = CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP | WS_MAXIMIZE,
3794 100, 100, 200, 200, 0, 0, 0, NULL);
3795 ok (hwnd != 0, "Failed to create popup window\n");
3796 ok(IsZoomed(hwnd), "window should be maximized\n");
3797 ok_sequence(WmCreateInvisibleMaxPopupSeq, "CreateWindow(WS_MAXIMIZED):popup", FALSE);
3798 trace("done\n");
3800 GetWindowRect(hwnd, &rc);
3801 ok( rc.right-rc.left == GetSystemMetrics(SM_CXSCREEN) &&
3802 rc.bottom-rc.top == GetSystemMetrics(SM_CYSCREEN),
3803 "Invalid maximized size before ShowWindow (%d,%d)-(%d,%d)\n",
3804 rc.left, rc.top, rc.right, rc.bottom);
3805 /* Reset window's size & position */
3806 SetWindowPos(hwnd, 0, 10, 10, 200, 200, SWP_NOZORDER | SWP_NOACTIVATE);
3807 ok(IsZoomed(hwnd), "window should be maximized\n");
3808 flush_sequence();
3810 trace("calling ShowWindow( SW_SHOWMAXIMIZE ) for invisible maximized popup window\n");
3811 ShowWindow(hwnd, SW_SHOWMAXIMIZED);
3812 ok(IsZoomed(hwnd), "window should be maximized\n");
3813 ok_sequence(WmShowMaxPopupResizedSeq, "ShowWindow(SW_SHOWMAXIMIZED):invisible maximized and resized popup", FALSE);
3814 trace("done\n");
3816 GetWindowRect(hwnd, &rc);
3817 ok( rc.right-rc.left == GetSystemMetrics(SM_CXSCREEN) &&
3818 rc.bottom-rc.top == GetSystemMetrics(SM_CYSCREEN),
3819 "Invalid maximized size after ShowWindow (%d,%d)-(%d,%d)\n",
3820 rc.left, rc.top, rc.right, rc.bottom);
3821 DestroyWindow(hwnd);
3822 flush_sequence();
3824 /* Test 2:
3825 * 1. Create invisible maximized popup window.
3826 * 2. Show it maximized.
3828 trace("calling CreateWindowExA( WS_MAXIMIZE ) for invisible maximized popup window\n");
3829 hwnd = CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP | WS_MAXIMIZE,
3830 100, 100, 200, 200, 0, 0, 0, NULL);
3831 ok (hwnd != 0, "Failed to create popup window\n");
3832 ok(IsZoomed(hwnd), "window should be maximized\n");
3833 ok_sequence(WmCreateInvisibleMaxPopupSeq, "CreateWindow(WS_MAXIMIZED):popup", FALSE);
3834 trace("done\n");
3836 trace("calling ShowWindow( SW_SHOWMAXIMIZE ) for invisible maximized popup window\n");
3837 ShowWindow(hwnd, SW_SHOWMAXIMIZED);
3838 ok(IsZoomed(hwnd), "window should be maximized\n");
3839 ok_sequence(WmShowMaxPopupSeq, "ShowWindow(SW_SHOWMAXIMIZED):invisible maximized popup", FALSE);
3840 trace("done\n");
3841 DestroyWindow(hwnd);
3842 flush_sequence();
3844 /* Test 3:
3845 * 1. Create visible maximized popup window.
3847 trace("calling CreateWindowExA( WS_MAXIMIZE ) for maximized popup window\n");
3848 hwnd = CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP | WS_MAXIMIZE | WS_VISIBLE,
3849 100, 100, 200, 200, 0, 0, 0, NULL);
3850 ok (hwnd != 0, "Failed to create popup window\n");
3851 ok(IsZoomed(hwnd), "window should be maximized\n");
3852 ok_sequence(WmCreateMaxPopupSeq, "CreateWindow(WS_MAXIMIZED):popup", FALSE);
3853 trace("done\n");
3854 DestroyWindow(hwnd);
3855 flush_sequence();
3857 /* Test 4:
3858 * 1. Create visible popup window.
3859 * 2. Maximize it.
3861 trace("calling CreateWindowExA( WS_VISIBLE ) for popup window\n");
3862 hwnd = CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP | WS_VISIBLE,
3863 100, 100, 200, 200, 0, 0, 0, NULL);
3864 ok (hwnd != 0, "Failed to create popup window\n");
3865 ok(!IsZoomed(hwnd), "window should NOT be maximized\n");
3866 ok_sequence(WmCreatePopupSeq, "CreateWindow(WS_VISIBLE):popup", FALSE);
3867 trace("done\n");
3869 trace("calling ShowWindow( SW_SHOWMAXIMIZE ) for visible popup window\n");
3870 ShowWindow(hwnd, SW_SHOWMAXIMIZED);
3871 ok(IsZoomed(hwnd), "window should be maximized\n");
3872 ok_sequence(WmShowVisMaxPopupSeq, "ShowWindow(SW_SHOWMAXIMIZED):popup", FALSE);
3873 trace("done\n");
3874 DestroyWindow(hwnd);
3875 flush_sequence();
3878 static void test_sys_menu(void)
3880 HWND hwnd;
3881 HMENU hmenu;
3882 UINT state;
3884 hwnd = CreateWindowExA(0, "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW,
3885 100, 100, 200, 200, 0, 0, 0, NULL);
3886 ok (hwnd != 0, "Failed to create overlapped window\n");
3888 flush_sequence();
3890 /* test existing window without CS_NOCLOSE style */
3891 hmenu = GetSystemMenu(hwnd, FALSE);
3892 ok(hmenu != 0, "GetSystemMenu error %d\n", GetLastError());
3894 state = GetMenuState(hmenu, SC_CLOSE, MF_BYCOMMAND);
3895 ok(state != 0xffffffff, "wrong SC_CLOSE state %x\n", state);
3896 ok(!(state & (MF_DISABLED | MF_GRAYED)), "wrong SC_CLOSE state %x\n", state);
3898 EnableMenuItem(hmenu, SC_CLOSE, MF_BYCOMMAND | MF_GRAYED);
3899 ok_sequence(WmEmptySeq, "WmEnableMenuItem", FALSE);
3901 state = GetMenuState(hmenu, SC_CLOSE, MF_BYCOMMAND);
3902 ok(state != 0xffffffff, "wrong SC_CLOSE state %x\n", state);
3903 ok((state & (MF_DISABLED | MF_GRAYED)) == MF_GRAYED, "wrong SC_CLOSE state %x\n", state);
3905 EnableMenuItem(hmenu, SC_CLOSE, 0);
3906 ok_sequence(WmEmptySeq, "WmEnableMenuItem", FALSE);
3908 state = GetMenuState(hmenu, SC_CLOSE, MF_BYCOMMAND);
3909 ok(state != 0xffffffff, "wrong SC_CLOSE state %x\n", state);
3910 ok(!(state & (MF_DISABLED | MF_GRAYED)), "wrong SC_CLOSE state %x\n", state);
3912 /* test whether removing WS_SYSMENU destroys a system menu */
3913 SetWindowLongW(hwnd, GWL_STYLE, WS_POPUP);
3914 SetWindowPos(hwnd, 0, 0, 0, 0, 0, SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_FRAMECHANGED);
3915 flush_sequence();
3916 hmenu = GetSystemMenu(hwnd, FALSE);
3917 ok(hmenu != 0, "GetSystemMenu error %d\n", GetLastError());
3919 DestroyWindow(hwnd);
3921 /* test new window with CS_NOCLOSE style */
3922 hwnd = CreateWindowExA(0, "NoCloseWindowClass", NULL, WS_OVERLAPPEDWINDOW,
3923 100, 100, 200, 200, 0, 0, 0, NULL);
3924 ok (hwnd != 0, "Failed to create overlapped window\n");
3926 hmenu = GetSystemMenu(hwnd, FALSE);
3927 ok(hmenu != 0, "GetSystemMenu error %d\n", GetLastError());
3929 state = GetMenuState(hmenu, SC_CLOSE, MF_BYCOMMAND);
3930 ok(state == 0xffffffff, "wrong SC_CLOSE state %x\n", state);
3932 DestroyWindow(hwnd);
3934 /* test new window without WS_SYSMENU style */
3935 hwnd = CreateWindowExA(0, "NoCloseWindowClass", NULL, WS_OVERLAPPEDWINDOW & ~WS_SYSMENU,
3936 100, 100, 200, 200, 0, 0, 0, NULL);
3937 ok(hwnd != 0, "Failed to create overlapped window\n");
3939 hmenu = GetSystemMenu(hwnd, FALSE);
3940 ok(!hmenu, "GetSystemMenu error %d\n", GetLastError());
3942 DestroyWindow(hwnd);
3945 /* For shown WS_OVERLAPPEDWINDOW */
3946 static const struct message WmSetIcon_1[] = {
3947 { WM_SETICON, sent },
3948 { 0x00AE, sent|defwinproc|optional }, /* XP */
3949 { WM_GETTEXT, sent|defwinproc|optional },
3950 { WM_GETTEXT, sent|defwinproc|optional }, /* XP sends a duplicate */
3951 { 0 }
3954 /* For WS_POPUP and hidden WS_OVERLAPPEDWINDOW */
3955 static const struct message WmSetIcon_2[] = {
3956 { WM_SETICON, sent },
3957 { 0 }
3960 /* Sending undocumented 0x3B message with wparam = 0x8000000b */
3961 static const struct message WmInitEndSession[] = {
3962 { 0x003B, sent },
3963 { WM_QUERYENDSESSION, sent|defwinproc|wparam|lparam, 0, ENDSESSION_LOGOFF },
3964 { 0 }
3967 /* Sending undocumented 0x3B message with wparam = 0x0000000b */
3968 static const struct message WmInitEndSession_2[] = {
3969 { 0x003B, sent },
3970 { WM_QUERYENDSESSION, sent|defwinproc|wparam|lparam, 0, 0 },
3971 { 0 }
3974 /* Sending undocumented 0x3B message with wparam = 0x80000008 */
3975 static const struct message WmInitEndSession_3[] = {
3976 { 0x003B, sent },
3977 { WM_ENDSESSION, sent|defwinproc|wparam|lparam, 0, ENDSESSION_LOGOFF },
3978 { 0 }
3981 /* Sending undocumented 0x3B message with wparam = 0x00000008 */
3982 static const struct message WmInitEndSession_4[] = {
3983 { 0x003B, sent },
3984 { WM_ENDSESSION, sent|defwinproc|wparam|lparam, 0, 0 },
3985 { 0 }
3988 /* Sending undocumented 0x3B message with wparam = 0x80000001 */
3989 static const struct message WmInitEndSession_5[] = {
3990 { 0x003B, sent },
3991 { WM_ENDSESSION, sent|defwinproc|wparam|lparam, 1, ENDSESSION_LOGOFF },
3992 { 0 }
3995 static void test_MsgWaitForMultipleObjects(HWND hwnd)
3997 DWORD ret;
3998 MSG msg;
4000 ret = MsgWaitForMultipleObjects(0, NULL, FALSE, 0, QS_POSTMESSAGE);
4001 ok(ret == WAIT_TIMEOUT, "MsgWaitForMultipleObjects returned %x\n", ret);
4003 PostMessageA(hwnd, WM_USER, 0, 0);
4005 ret = MsgWaitForMultipleObjects(0, NULL, FALSE, 0, QS_POSTMESSAGE);
4006 ok(ret == WAIT_OBJECT_0, "MsgWaitForMultipleObjects returned %x\n", ret);
4008 ok(PeekMessageW( &msg, 0, 0, 0, PM_REMOVE ), "PeekMessage should succeed\n");
4009 ok(msg.message == WM_USER, "got %04x instead of WM_USER\n", msg.message);
4011 ret = MsgWaitForMultipleObjects(0, NULL, FALSE, 0, QS_POSTMESSAGE);
4012 ok(ret == WAIT_TIMEOUT, "MsgWaitForMultipleObjects returned %x\n", ret);
4014 PostMessageA(hwnd, WM_USER, 0, 0);
4016 ret = MsgWaitForMultipleObjects(0, NULL, FALSE, 0, QS_POSTMESSAGE);
4017 ok(ret == WAIT_OBJECT_0, "MsgWaitForMultipleObjects returned %x\n", ret);
4019 ok(PeekMessageW( &msg, 0, 0, 0, PM_NOREMOVE ), "PeekMessage should succeed\n");
4020 ok(msg.message == WM_USER, "got %04x instead of WM_USER\n", msg.message);
4022 /* shows QS_POSTMESSAGE flag is cleared in the PeekMessage call */
4023 ret = MsgWaitForMultipleObjects(0, NULL, FALSE, 0, QS_POSTMESSAGE);
4024 ok(ret == WAIT_TIMEOUT, "MsgWaitForMultipleObjects returned %x\n", ret);
4026 PostMessageA(hwnd, WM_USER, 0, 0);
4028 /* new incoming message causes it to become signaled again */
4029 ret = MsgWaitForMultipleObjects(0, NULL, FALSE, 0, QS_POSTMESSAGE);
4030 ok(ret == WAIT_OBJECT_0, "MsgWaitForMultipleObjects returned %x\n", ret);
4032 ok(PeekMessageW( &msg, 0, 0, 0, PM_REMOVE ), "PeekMessage should succeed\n");
4033 ok(msg.message == WM_USER, "got %04x instead of WM_USER\n", msg.message);
4034 ok(PeekMessageW( &msg, 0, 0, 0, PM_REMOVE ), "PeekMessage should succeed\n");
4035 ok(msg.message == WM_USER, "got %04x instead of WM_USER\n", msg.message);
4038 /* test if we receive the right sequence of messages */
4039 static void test_messages(void)
4041 HWND hwnd, hparent, hchild;
4042 HWND hchild2, hbutton;
4043 HMENU hmenu;
4044 MSG msg;
4045 LRESULT res;
4047 flush_sequence();
4049 hwnd = CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW,
4050 100, 100, 200, 200, 0, 0, 0, NULL);
4051 ok (hwnd != 0, "Failed to create overlapped window\n");
4052 ok_sequence(WmCreateOverlappedSeq, "CreateWindow:overlapped", FALSE);
4054 /* test ShowWindow(SW_HIDE) on a newly created invisible window */
4055 ok( ShowWindow(hwnd, SW_HIDE) == FALSE, "ShowWindow: window was visible\n" );
4056 ok_sequence(WmEmptySeq, "ShowWindow(SW_HIDE):overlapped, invisible", FALSE);
4058 /* test WM_SETREDRAW on a not visible top level window */
4059 test_WM_SETREDRAW(hwnd);
4061 SetWindowPos(hwnd, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE);
4062 ok_sequence(WmSWP_ShowOverlappedSeq, "SetWindowPos:SWP_SHOWWINDOW:overlapped", FALSE);
4063 ok(IsWindowVisible(hwnd), "window should be visible at this point\n");
4065 ok(GetActiveWindow() == hwnd, "window should be active\n");
4066 ok(GetFocus() == hwnd, "window should have input focus\n");
4067 ShowWindow(hwnd, SW_HIDE);
4068 ok_sequence(WmHideOverlappedSeq, "ShowWindow(SW_HIDE):overlapped", TRUE);
4070 ShowWindow(hwnd, SW_SHOW);
4071 ok_sequence(WmShowOverlappedSeq, "ShowWindow(SW_SHOW):overlapped", TRUE);
4073 ShowWindow(hwnd, SW_HIDE);
4074 ok_sequence(WmHideOverlappedSeq, "ShowWindow(SW_HIDE):overlapped", FALSE);
4076 ShowWindow(hwnd, SW_SHOWMAXIMIZED);
4077 ok_sequence(WmShowMaxOverlappedSeq, "ShowWindow(SW_SHOWMAXIMIZED):overlapped", TRUE);
4079 ShowWindow(hwnd, SW_RESTORE);
4080 /* FIXME: add ok_sequence() here */
4081 flush_sequence();
4083 ShowWindow(hwnd, SW_MINIMIZE);
4084 ok_sequence(WmShowMinOverlappedSeq, "ShowWindow(SW_SHOWMINIMIZED):overlapped", TRUE);
4085 flush_sequence();
4087 ShowWindow(hwnd, SW_RESTORE);
4088 /* FIXME: add ok_sequence() here */
4089 flush_sequence();
4091 ShowWindow(hwnd, SW_SHOW);
4092 ok_sequence(WmEmptySeq, "ShowWindow(SW_SHOW):overlapped already visible", FALSE);
4094 ok(GetActiveWindow() == hwnd, "window should be active\n");
4095 ok(GetFocus() == hwnd, "window should have input focus\n");
4096 SetWindowPos(hwnd, 0,0,0,0,0, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE);
4097 ok_sequence(WmSWP_HideOverlappedSeq, "SetWindowPos:SWP_HIDEWINDOW:overlapped", FALSE);
4098 ok(!IsWindowVisible(hwnd), "window should not be visible at this point\n");
4099 ok(GetActiveWindow() == hwnd, "window should still be active\n");
4101 /* test WM_SETREDRAW on a visible top level window */
4102 ShowWindow(hwnd, SW_SHOW);
4103 test_WM_SETREDRAW(hwnd);
4105 trace("testing scroll APIs on a visible top level window %p\n", hwnd);
4106 test_scroll_messages(hwnd);
4108 /* test resizing and moving */
4109 SetWindowPos( hwnd, 0, 0, 0, 300, 300, SWP_NOMOVE|SWP_NOACTIVATE );
4110 ok_sequence(WmSWP_ResizeSeq, "SetWindowPos:Resize", FALSE );
4111 flush_events();
4112 flush_sequence();
4113 SetWindowPos( hwnd, 0, 200, 200, 0, 0, SWP_NOSIZE|SWP_NOACTIVATE );
4114 ok_sequence(WmSWP_MoveSeq, "SetWindowPos:Move", FALSE );
4115 flush_events();
4116 flush_sequence();
4117 SetWindowPos( hwnd, 0, 200, 200, 250, 250, SWP_NOZORDER );
4118 ok_sequence(WmSWP_ResizeNoZOrder, "SetWindowPos:WmSWP_ResizeNoZOrder", FALSE );
4119 flush_events();
4120 flush_sequence();
4122 /* popups don't get WM_GETMINMAXINFO */
4123 SetWindowLongW( hwnd, GWL_STYLE, WS_VISIBLE|WS_POPUP );
4124 SetWindowPos( hwnd, 0, 0, 0, 0, 0, SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_FRAMECHANGED);
4125 flush_sequence();
4126 SetWindowPos( hwnd, 0, 0, 0, 200, 200, SWP_NOMOVE|SWP_NOACTIVATE );
4127 ok_sequence(WmSWP_ResizePopupSeq, "SetWindowPos:ResizePopup", FALSE );
4129 DestroyWindow(hwnd);
4130 ok_sequence(WmDestroyOverlappedSeq, "DestroyWindow:overlapped", FALSE);
4132 hparent = CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
4133 100, 100, 200, 200, 0, 0, 0, NULL);
4134 ok (hparent != 0, "Failed to create parent window\n");
4135 flush_sequence();
4137 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD | WS_MAXIMIZE,
4138 0, 0, 10, 10, hparent, 0, 0, NULL);
4139 ok (hchild != 0, "Failed to create child window\n");
4140 ok_sequence(WmCreateMaximizedChildSeq, "CreateWindow:maximized child", FALSE);
4141 DestroyWindow(hchild);
4142 flush_sequence();
4144 /* visible child window with a caption */
4145 hchild = CreateWindowExA(0, "TestWindowClass", "Test child",
4146 WS_CHILD | WS_VISIBLE | WS_CAPTION,
4147 0, 0, 10, 10, hparent, 0, 0, NULL);
4148 ok (hchild != 0, "Failed to create child window\n");
4149 ok_sequence(WmCreateVisibleChildSeq, "CreateWindow:visible child", FALSE);
4151 trace("testing scroll APIs on a visible child window %p\n", hchild);
4152 test_scroll_messages(hchild);
4154 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE);
4155 ok_sequence(WmShowChildSeq_4, "SetWindowPos(SWP_SHOWWINDOW):child with a caption", FALSE);
4157 DestroyWindow(hchild);
4158 flush_sequence();
4160 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
4161 0, 0, 10, 10, hparent, 0, 0, NULL);
4162 ok (hchild != 0, "Failed to create child window\n");
4163 ok_sequence(WmCreateChildSeq, "CreateWindow:child", FALSE);
4165 hchild2 = CreateWindowExA(0, "SimpleWindowClass", "Test child2", WS_CHILD,
4166 100, 100, 50, 50, hparent, 0, 0, NULL);
4167 ok (hchild2 != 0, "Failed to create child2 window\n");
4168 flush_sequence();
4170 hbutton = CreateWindowExA(0, "TestWindowClass", "Test button", WS_CHILD,
4171 0, 100, 50, 50, hchild, 0, 0, NULL);
4172 ok (hbutton != 0, "Failed to create button window\n");
4174 /* test WM_SETREDRAW on a not visible child window */
4175 test_WM_SETREDRAW(hchild);
4177 ShowWindow(hchild, SW_SHOW);
4178 ok_sequence(WmShowChildSeq, "ShowWindow(SW_SHOW):child", FALSE);
4180 /* check parent messages too */
4181 log_all_parent_messages++;
4182 ShowWindow(hchild, SW_HIDE);
4183 ok_sequence(WmHideChildSeq2, "ShowWindow(SW_HIDE):child", FALSE);
4184 log_all_parent_messages--;
4186 ShowWindow(hchild, SW_SHOW);
4187 ok_sequence(WmShowChildSeq, "ShowWindow(SW_SHOW):child", FALSE);
4189 ShowWindow(hchild, SW_HIDE);
4190 ok_sequence(WmHideChildSeq, "ShowWindow(SW_HIDE):child", FALSE);
4192 ShowWindow(hchild, SW_SHOW);
4193 ok_sequence(WmShowChildSeq, "ShowWindow(SW_SHOW):child", FALSE);
4195 /* test WM_SETREDRAW on a visible child window */
4196 test_WM_SETREDRAW(hchild);
4198 log_all_parent_messages++;
4199 MoveWindow(hchild, 10, 10, 20, 20, TRUE);
4200 ok_sequence(WmResizingChildWithMoveWindowSeq, "MoveWindow:child", FALSE);
4201 log_all_parent_messages--;
4203 ShowWindow(hchild, SW_HIDE);
4204 flush_sequence();
4205 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE);
4206 ok_sequence(WmShowChildSeq_2, "SetWindowPos:show_child_2", FALSE);
4208 ShowWindow(hchild, SW_HIDE);
4209 flush_sequence();
4210 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE);
4211 ok_sequence(WmShowChildSeq_3, "SetWindowPos:show_child_3", FALSE);
4213 /* DestroyWindow sequence below expects that a child has focus */
4214 SetFocus(hchild);
4215 flush_sequence();
4217 DestroyWindow(hchild);
4218 ok_sequence(WmDestroyChildSeq, "DestroyWindow:child", FALSE);
4219 DestroyWindow(hchild2);
4220 DestroyWindow(hbutton);
4222 flush_sequence();
4223 hchild = CreateWindowExA(0, "TestWindowClass", "Test Child Popup", WS_CHILD | WS_POPUP,
4224 0, 0, 100, 100, hparent, 0, 0, NULL);
4225 ok (hchild != 0, "Failed to create child popup window\n");
4226 ok_sequence(WmCreateChildPopupSeq, "CreateWindow:child_popup", FALSE);
4227 DestroyWindow(hchild);
4229 /* test what happens to a window which sets WS_VISIBLE in WM_CREATE */
4230 flush_sequence();
4231 hchild = CreateWindowExA(0, "TestPopupClass", "Test Popup", WS_POPUP,
4232 0, 0, 100, 100, hparent, 0, 0, NULL);
4233 ok (hchild != 0, "Failed to create popup window\n");
4234 ok_sequence(WmCreateInvisiblePopupSeq, "CreateWindow:invisible_popup", FALSE);
4235 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
4236 ok(IsWindowVisible(hchild), "IsWindowVisible() should return TRUE\n");
4237 flush_sequence();
4238 ShowWindow(hchild, SW_SHOW);
4239 ok_sequence(WmEmptySeq, "ShowWindow:show_visible_popup", FALSE);
4240 flush_sequence();
4241 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER);
4242 ok_sequence(WmShowVisiblePopupSeq_2, "SetWindowPos:show_visible_popup_2", FALSE);
4243 flush_sequence();
4244 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE);
4245 ok_sequence(WmShowVisiblePopupSeq_3, "SetWindowPos:show_visible_popup_3", TRUE);
4246 DestroyWindow(hchild);
4248 /* this time add WS_VISIBLE for CreateWindowEx, but this fact actually
4249 * changes nothing in message sequences.
4251 flush_sequence();
4252 hchild = CreateWindowExA(0, "TestPopupClass", "Test Popup", WS_POPUP | WS_VISIBLE,
4253 0, 0, 100, 100, hparent, 0, 0, NULL);
4254 ok (hchild != 0, "Failed to create popup window\n");
4255 ok_sequence(WmCreateInvisiblePopupSeq, "CreateWindow:invisible_popup", FALSE);
4256 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
4257 ok(IsWindowVisible(hchild), "IsWindowVisible() should return TRUE\n");
4258 flush_sequence();
4259 ShowWindow(hchild, SW_SHOW);
4260 ok_sequence(WmEmptySeq, "ShowWindow:show_visible_popup", FALSE);
4261 flush_sequence();
4262 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER);
4263 ok_sequence(WmShowVisiblePopupSeq_2, "SetWindowPos:show_visible_popup_2", FALSE);
4264 DestroyWindow(hchild);
4266 flush_sequence();
4267 hwnd = CreateWindowExA(WS_EX_DLGMODALFRAME, "TestDialogClass", NULL, WS_VISIBLE|WS_CAPTION|WS_SYSMENU|WS_DLGFRAME,
4268 0, 0, 100, 100, hparent, 0, 0, NULL);
4269 ok(hwnd != 0, "Failed to create custom dialog window\n");
4270 ok_sequence(WmCreateCustomDialogSeq, "CreateCustomDialog", TRUE);
4273 trace("testing scroll APIs on a visible dialog %p\n", hwnd);
4274 test_scroll_messages(hwnd);
4277 flush_sequence();
4279 test_def_id = 1;
4280 SendMessage(hwnd, WM_NULL, 0, 0);
4282 flush_sequence();
4283 after_end_dialog = 1;
4284 EndDialog( hwnd, 0 );
4285 ok_sequence(WmEndCustomDialogSeq, "EndCustomDialog", FALSE);
4287 DestroyWindow(hwnd);
4288 after_end_dialog = 0;
4289 test_def_id = 0;
4291 hwnd = CreateWindowExA(0, "TestDialogClass", NULL, WS_POPUP,
4292 0, 0, 100, 100, 0, 0, GetModuleHandleA(0), NULL);
4293 ok(hwnd != 0, "Failed to create custom dialog window\n");
4294 flush_sequence();
4295 trace("call ShowWindow(%p, SW_SHOW)\n", hwnd);
4296 ShowWindow(hwnd, SW_SHOW);
4297 ok_sequence(WmShowCustomDialogSeq, "ShowCustomDialog", TRUE);
4298 DestroyWindow(hwnd);
4300 flush_sequence();
4301 DialogBoxA( 0, "TEST_DIALOG", hparent, TestModalDlgProcA );
4302 ok_sequence(WmModalDialogSeq, "ModalDialog", TRUE);
4304 DestroyWindow(hparent);
4305 flush_sequence();
4307 /* Message sequence for SetMenu */
4308 ok(!DrawMenuBar(hwnd), "DrawMenuBar should return FALSE for a window without a menu\n");
4309 ok_sequence(WmEmptySeq, "DrawMenuBar for a window without a menu", FALSE);
4311 hmenu = CreateMenu();
4312 ok (hmenu != 0, "Failed to create menu\n");
4313 ok (InsertMenuA(hmenu, -1, MF_BYPOSITION, 0x1000, "foo"), "InsertMenu failed\n");
4314 hwnd = CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW,
4315 100, 100, 200, 200, 0, hmenu, 0, NULL);
4316 ok_sequence(WmCreateOverlappedSeq, "CreateWindow:overlapped", FALSE);
4317 ok (SetMenu(hwnd, 0), "SetMenu\n");
4318 ok_sequence(WmSetMenuNonVisibleSizeChangeSeq, "SetMenu:NonVisibleSizeChange", FALSE);
4319 ok (SetMenu(hwnd, 0), "SetMenu\n");
4320 ok_sequence(WmSetMenuNonVisibleNoSizeChangeSeq, "SetMenu:NonVisibleNoSizeChange", FALSE);
4321 ShowWindow(hwnd, SW_SHOW);
4322 UpdateWindow( hwnd );
4323 flush_events();
4324 flush_sequence();
4325 ok (SetMenu(hwnd, 0), "SetMenu\n");
4326 ok_sequence(WmSetMenuVisibleNoSizeChangeSeq, "SetMenu:VisibleNoSizeChange", FALSE);
4327 ok (SetMenu(hwnd, hmenu), "SetMenu\n");
4328 ok_sequence(WmSetMenuVisibleSizeChangeSeq, "SetMenu:VisibleSizeChange", FALSE);
4330 UpdateWindow( hwnd );
4331 flush_events();
4332 flush_sequence();
4333 ok(DrawMenuBar(hwnd), "DrawMenuBar\n");
4334 flush_events();
4335 ok_sequence(WmDrawMenuBarSeq, "DrawMenuBar", FALSE);
4337 DestroyWindow(hwnd);
4338 flush_sequence();
4340 /* Message sequence for EnableWindow */
4341 hparent = CreateWindowExA(0, "TestWindowClass", "Test parent", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
4342 100, 100, 200, 200, 0, 0, 0, NULL);
4343 ok (hparent != 0, "Failed to create parent window\n");
4344 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD | WS_VISIBLE,
4345 0, 0, 10, 10, hparent, 0, 0, NULL);
4346 ok (hchild != 0, "Failed to create child window\n");
4348 SetFocus(hchild);
4349 flush_events();
4350 flush_sequence();
4352 EnableWindow(hparent, FALSE);
4353 ok_sequence(WmEnableWindowSeq_1, "EnableWindow(FALSE)", FALSE);
4355 EnableWindow(hparent, TRUE);
4356 ok_sequence(WmEnableWindowSeq_2, "EnableWindow(TRUE)", FALSE);
4358 flush_events();
4359 flush_sequence();
4361 test_MsgWaitForMultipleObjects(hparent);
4363 /* the following test causes an exception in user.exe under win9x */
4364 if (!PostMessageW( hparent, WM_USER, 0, 0 ))
4366 DestroyWindow(hparent);
4367 flush_sequence();
4368 return;
4370 PostMessageW( hparent, WM_USER+1, 0, 0 );
4371 /* PeekMessage(NULL) fails, but still removes the message */
4372 SetLastError(0xdeadbeef);
4373 ok( !PeekMessageW( NULL, 0, 0, 0, PM_REMOVE ), "PeekMessage(NULL) should fail\n" );
4374 ok( GetLastError() == ERROR_NOACCESS || /* Win2k */
4375 GetLastError() == 0xdeadbeef, /* NT4 */
4376 "last error is %d\n", GetLastError() );
4377 ok( PeekMessageW( &msg, 0, 0, 0, PM_REMOVE ), "PeekMessage should succeed\n" );
4378 ok( msg.message == WM_USER+1, "got %x instead of WM_USER+1\n", msg.message );
4380 DestroyWindow(hchild);
4381 DestroyWindow(hparent);
4382 flush_sequence();
4384 /* Message sequences for WM_SETICON */
4385 trace("testing WM_SETICON\n");
4386 hwnd = CreateWindowExA(0, "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW,
4387 CW_USEDEFAULT, CW_USEDEFAULT, 300, 300, 0,
4388 NULL, NULL, 0);
4389 ShowWindow(hwnd, SW_SHOW);
4390 UpdateWindow(hwnd);
4391 flush_events();
4392 flush_sequence();
4393 SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(0, IDI_APPLICATION));
4394 ok_sequence(WmSetIcon_1, "WM_SETICON for shown window with caption", FALSE);
4396 ShowWindow(hwnd, SW_HIDE);
4397 flush_events();
4398 flush_sequence();
4399 SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(0, IDI_APPLICATION));
4400 ok_sequence(WmSetIcon_2, "WM_SETICON for hidden window with caption", FALSE);
4401 DestroyWindow(hwnd);
4402 flush_sequence();
4404 hwnd = CreateWindowExA(0, "TestPopupClass", NULL, WS_POPUP,
4405 CW_USEDEFAULT, CW_USEDEFAULT, 300, 300, 0,
4406 NULL, NULL, 0);
4407 ShowWindow(hwnd, SW_SHOW);
4408 UpdateWindow(hwnd);
4409 flush_events();
4410 flush_sequence();
4411 SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(0, IDI_APPLICATION));
4412 ok_sequence(WmSetIcon_2, "WM_SETICON for shown window without caption", FALSE);
4414 ShowWindow(hwnd, SW_HIDE);
4415 flush_events();
4416 flush_sequence();
4417 SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(0, IDI_APPLICATION));
4418 ok_sequence(WmSetIcon_2, "WM_SETICON for hidden window without caption", FALSE);
4420 flush_sequence();
4421 res = SendMessage(hwnd, 0x3B, 0x8000000b, 0);
4422 ok_sequence(WmInitEndSession, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x8000000b", TRUE);
4423 todo_wine
4424 ok(res == 1, "SendMessage(hwnd, 0x3B, 0x8000000b, 0) should have returned 1 instead of %ld\n", res);
4425 res = SendMessage(hwnd, 0x3B, 0x0000000b, 0);
4426 ok_sequence(WmInitEndSession_2, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x0000000b", TRUE);
4427 todo_wine
4428 ok(res == 1, "SendMessage(hwnd, 0x3B, 0x0000000b, 0) should have returned 1 instead of %ld\n", res);
4429 res = SendMessage(hwnd, 0x3B, 0x0000000f, 0);
4430 ok_sequence(WmInitEndSession_2, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x0000000f", TRUE);
4431 todo_wine
4432 ok(res == 1, "SendMessage(hwnd, 0x3B, 0x0000000f, 0) should have returned 1 instead of %ld\n", res);
4434 flush_sequence();
4435 res = SendMessage(hwnd, 0x3B, 0x80000008, 0);
4436 ok_sequence(WmInitEndSession_3, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x80000008", TRUE);
4437 todo_wine
4438 ok(res == 2, "SendMessage(hwnd, 0x3B, 0x80000008, 0) should have returned 2 instead of %ld\n", res);
4439 res = SendMessage(hwnd, 0x3B, 0x00000008, 0);
4440 ok_sequence(WmInitEndSession_4, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x00000008", TRUE);
4441 todo_wine
4442 ok(res == 2, "SendMessage(hwnd, 0x3B, 0x00000008, 0) should have returned 2 instead of %ld\n", res);
4444 res = SendMessage(hwnd, 0x3B, 0x80000004, 0);
4445 ok_sequence(WmInitEndSession_3, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x80000004", TRUE);
4446 todo_wine
4447 ok(res == 2, "SendMessage(hwnd, 0x3B, 0x80000004, 0) should have returned 2 instead of %ld\n", res);
4449 res = SendMessage(hwnd, 0x3B, 0x80000001, 0);
4450 ok_sequence(WmInitEndSession_5, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x80000001", TRUE);
4451 todo_wine
4452 ok(res == 2, "SendMessage(hwnd, 0x3B, 0x80000001, 0) should have returned 2 instead of %ld\n", res);
4454 DestroyWindow(hwnd);
4455 flush_sequence();
4458 static void invisible_parent_tests(void)
4460 HWND hparent, hchild;
4462 hparent = CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW,
4463 100, 100, 200, 200, 0, 0, 0, NULL);
4464 ok (hparent != 0, "Failed to create parent window\n");
4465 flush_sequence();
4467 /* test showing child with hidden parent */
4469 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
4470 0, 0, 10, 10, hparent, 0, 0, NULL);
4471 ok (hchild != 0, "Failed to create child window\n");
4472 ok_sequence(WmCreateChildSeq, "CreateWindow:child", FALSE);
4474 ShowWindow( hchild, SW_MINIMIZE );
4475 ok_sequence(WmShowChildInvisibleParentSeq_1, "ShowWindow(SW_MINIMIZE) child with invisible parent", FALSE);
4476 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
4477 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4479 /* repeat */
4480 flush_events();
4481 flush_sequence();
4482 ShowWindow( hchild, SW_MINIMIZE );
4483 ok_sequence(WmShowChildInvisibleParentSeq_1r, "ShowWindow(SW_MINIMIZE) child with invisible parent", FALSE);
4485 DestroyWindow(hchild);
4486 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
4487 0, 0, 10, 10, hparent, 0, 0, NULL);
4488 flush_sequence();
4490 ShowWindow( hchild, SW_MAXIMIZE );
4491 ok_sequence(WmShowChildInvisibleParentSeq_2, "ShowWindow(SW_MAXIMIZE) child with invisible parent", FALSE);
4492 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
4493 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4495 /* repeat */
4496 flush_events();
4497 flush_sequence();
4498 ShowWindow( hchild, SW_MAXIMIZE );
4499 ok_sequence(WmShowChildInvisibleParentSeq_2r, "ShowWindow(SW_MAXIMIZE) child with invisible parent", FALSE);
4501 DestroyWindow(hchild);
4502 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
4503 0, 0, 10, 10, hparent, 0, 0, NULL);
4504 flush_sequence();
4506 ShowWindow( hchild, SW_RESTORE );
4507 ok_sequence(WmShowChildInvisibleParentSeq_5, "ShowWindow(SW_RESTORE) child with invisible parent", FALSE);
4508 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
4509 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4511 DestroyWindow(hchild);
4512 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
4513 0, 0, 10, 10, hparent, 0, 0, NULL);
4514 flush_sequence();
4516 ShowWindow( hchild, SW_SHOWMINIMIZED );
4517 ok_sequence(WmShowChildInvisibleParentSeq_3, "ShowWindow(SW_SHOWMINIMIZED) child with invisible parent", FALSE);
4518 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
4519 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4521 /* repeat */
4522 flush_events();
4523 flush_sequence();
4524 ShowWindow( hchild, SW_SHOWMINIMIZED );
4525 ok_sequence(WmShowChildInvisibleParentSeq_3r, "ShowWindow(SW_SHOWMINIMIZED) child with invisible parent", FALSE);
4527 DestroyWindow(hchild);
4528 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
4529 0, 0, 10, 10, hparent, 0, 0, NULL);
4530 flush_sequence();
4532 /* same as ShowWindow( hchild, SW_MAXIMIZE ); */
4533 ShowWindow( hchild, SW_SHOWMAXIMIZED );
4534 ok_sequence(WmShowChildInvisibleParentSeq_2, "ShowWindow(SW_SHOWMAXIMIZED) 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");
4538 DestroyWindow(hchild);
4539 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
4540 0, 0, 10, 10, hparent, 0, 0, NULL);
4541 flush_sequence();
4543 ShowWindow( hchild, SW_SHOWMINNOACTIVE );
4544 ok_sequence(WmShowChildInvisibleParentSeq_4, "ShowWindow(SW_SHOWMINNOACTIVE) child with invisible parent", FALSE);
4545 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
4546 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4548 /* repeat */
4549 flush_events();
4550 flush_sequence();
4551 ShowWindow( hchild, SW_SHOWMINNOACTIVE );
4552 ok_sequence(WmShowChildInvisibleParentSeq_4r, "ShowWindow(SW_SHOWMINNOACTIVE) child with invisible parent", FALSE);
4554 DestroyWindow(hchild);
4555 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
4556 0, 0, 10, 10, hparent, 0, 0, NULL);
4557 flush_sequence();
4559 /* FIXME: looks like XP SP2 doesn't know about SW_FORCEMINIMIZE at all */
4560 ShowWindow( hchild, SW_FORCEMINIMIZE );
4561 ok_sequence(WmEmptySeq, "ShowWindow(SW_FORCEMINIMIZE) child with invisible parent", TRUE);
4562 todo_wine {
4563 ok(!(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE), "WS_VISIBLE should be not set\n");
4565 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4567 DestroyWindow(hchild);
4568 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
4569 0, 0, 10, 10, hparent, 0, 0, NULL);
4570 flush_sequence();
4572 ShowWindow( hchild, SW_SHOWNA );
4573 ok_sequence(WmShowChildInvisibleParentSeq_5, "ShowWindow(SW_SHOWNA) child with invisible parent", FALSE);
4574 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
4575 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4577 /* repeat */
4578 flush_events();
4579 flush_sequence();
4580 ShowWindow( hchild, SW_SHOWNA );
4581 ok_sequence(WmShowChildInvisibleParentSeq_5, "ShowWindow(SW_SHOWNA) child with invisible parent", FALSE);
4583 DestroyWindow(hchild);
4584 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
4585 0, 0, 10, 10, hparent, 0, 0, NULL);
4586 flush_sequence();
4588 ShowWindow( hchild, SW_SHOW );
4589 ok_sequence(WmShowChildInvisibleParentSeq_5, "ShowWindow(SW_SHOW) child with invisible parent", FALSE);
4590 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
4591 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4593 /* repeat */
4594 flush_events();
4595 flush_sequence();
4596 ShowWindow( hchild, SW_SHOW );
4597 ok_sequence(WmEmptySeq, "ShowWindow(SW_SHOW) child with invisible parent", FALSE);
4599 ShowWindow( hchild, SW_HIDE );
4600 ok_sequence(WmHideChildInvisibleParentSeq, "ShowWindow:hide child with invisible parent", FALSE);
4601 ok(!(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE), "WS_VISIBLE should be not set\n");
4602 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4604 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER);
4605 ok_sequence(WmShowChildInvisibleParentSeq_6, "SetWindowPos:show child with invisible parent", FALSE);
4606 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
4607 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4609 SetWindowPos(hchild, 0,0,0,0,0, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER);
4610 ok_sequence(WmHideChildInvisibleParentSeq_2, "SetWindowPos:hide child with invisible parent", FALSE);
4611 ok(!(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE), "WS_VISIBLE should not be set\n");
4612 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4614 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER);
4615 flush_sequence();
4616 DestroyWindow(hchild);
4617 ok_sequence(WmDestroyInvisibleChildSeq, "DestroyInvisibleChildSeq", FALSE);
4619 DestroyWindow(hparent);
4620 flush_sequence();
4623 /****************** button message test *************************/
4624 static const struct message WmSetFocusButtonSeq[] =
4626 { HCBT_SETFOCUS, hook },
4627 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
4628 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
4629 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
4630 { WM_SETFOCUS, sent|wparam, 0 },
4631 { WM_CTLCOLORBTN, sent|defwinproc },
4632 { 0 }
4634 static const struct message WmKillFocusButtonSeq[] =
4636 { HCBT_SETFOCUS, hook },
4637 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
4638 { WM_KILLFOCUS, sent|wparam, 0 },
4639 { WM_CTLCOLORBTN, sent|defwinproc },
4640 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
4641 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 1 },
4642 { 0 }
4644 static const struct message WmSetFocusStaticSeq[] =
4646 { HCBT_SETFOCUS, hook },
4647 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
4648 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
4649 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
4650 { WM_SETFOCUS, sent|wparam, 0 },
4651 { WM_CTLCOLORSTATIC, sent|defwinproc },
4652 { 0 }
4654 static const struct message WmKillFocusStaticSeq[] =
4656 { HCBT_SETFOCUS, hook },
4657 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
4658 { WM_KILLFOCUS, sent|wparam, 0 },
4659 { WM_CTLCOLORSTATIC, sent|defwinproc },
4660 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
4661 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 1 },
4662 { 0 }
4664 static const struct message WmLButtonDownSeq[] =
4666 { WM_LBUTTONDOWN, sent|wparam|lparam, 0, 0 },
4667 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
4668 { HCBT_SETFOCUS, hook },
4669 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
4670 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
4671 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
4672 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
4673 { WM_CTLCOLORBTN, sent|defwinproc },
4674 { BM_SETSTATE, sent|wparam|defwinproc, TRUE },
4675 { WM_CTLCOLORBTN, sent|defwinproc },
4676 { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
4677 { 0 }
4679 static const struct message WmLButtonUpSeq[] =
4681 { WM_LBUTTONUP, sent|wparam|lparam, 0, 0 },
4682 { BM_SETSTATE, sent|wparam|defwinproc, FALSE },
4683 { WM_CTLCOLORBTN, sent|defwinproc },
4684 { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
4685 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, 0, 0 },
4686 { WM_CAPTURECHANGED, sent|wparam|defwinproc, 0 },
4687 { 0 }
4689 static const struct message WmSetFontButtonSeq[] =
4691 { WM_SETFONT, sent },
4692 { WM_PAINT, sent },
4693 { WM_ERASEBKGND, sent|defwinproc|optional },
4694 { WM_CTLCOLORBTN, sent|defwinproc },
4695 { 0 }
4698 static WNDPROC old_button_proc;
4700 static LRESULT CALLBACK button_hook_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
4702 static long defwndproc_counter = 0;
4703 LRESULT ret;
4704 struct message msg;
4706 trace("button: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
4708 /* explicitly ignore WM_GETICON message */
4709 if (message == WM_GETICON) return 0;
4711 msg.message = message;
4712 msg.flags = sent|wparam|lparam;
4713 if (defwndproc_counter) msg.flags |= defwinproc;
4714 msg.wParam = wParam;
4715 msg.lParam = lParam;
4716 add_message(&msg);
4718 if (message == BM_SETSTATE)
4719 ok(GetCapture() == hwnd, "GetCapture() = %p\n", GetCapture());
4721 defwndproc_counter++;
4722 ret = CallWindowProcA(old_button_proc, hwnd, message, wParam, lParam);
4723 defwndproc_counter--;
4725 return ret;
4728 static void subclass_button(void)
4730 WNDCLASSA cls;
4732 if (!GetClassInfoA(0, "button", &cls)) assert(0);
4734 old_button_proc = cls.lpfnWndProc;
4736 cls.hInstance = GetModuleHandle(0);
4737 cls.lpfnWndProc = button_hook_proc;
4738 cls.lpszClassName = "my_button_class";
4739 UnregisterClass(cls.lpszClassName, cls.hInstance);
4740 if (!RegisterClassA(&cls)) assert(0);
4743 static void test_button_messages(void)
4745 static const struct
4747 DWORD style;
4748 DWORD dlg_code;
4749 const struct message *setfocus;
4750 const struct message *killfocus;
4751 } button[] = {
4752 { BS_PUSHBUTTON, DLGC_BUTTON | DLGC_UNDEFPUSHBUTTON,
4753 WmSetFocusButtonSeq, WmKillFocusButtonSeq },
4754 { BS_DEFPUSHBUTTON, DLGC_BUTTON | DLGC_DEFPUSHBUTTON,
4755 WmSetFocusButtonSeq, WmKillFocusButtonSeq },
4756 { BS_CHECKBOX, DLGC_BUTTON,
4757 WmSetFocusStaticSeq, WmKillFocusStaticSeq },
4758 { BS_AUTOCHECKBOX, DLGC_BUTTON,
4759 WmSetFocusStaticSeq, WmKillFocusStaticSeq },
4760 { BS_RADIOBUTTON, DLGC_BUTTON | DLGC_RADIOBUTTON,
4761 WmSetFocusStaticSeq, WmKillFocusStaticSeq },
4762 { BS_3STATE, DLGC_BUTTON,
4763 WmSetFocusStaticSeq, WmKillFocusStaticSeq },
4764 { BS_AUTO3STATE, DLGC_BUTTON,
4765 WmSetFocusStaticSeq, WmKillFocusStaticSeq },
4766 { BS_GROUPBOX, DLGC_STATIC,
4767 WmSetFocusStaticSeq, WmKillFocusStaticSeq },
4768 { BS_USERBUTTON, DLGC_BUTTON | DLGC_UNDEFPUSHBUTTON,
4769 WmSetFocusButtonSeq, WmKillFocusButtonSeq },
4770 { BS_AUTORADIOBUTTON, DLGC_BUTTON | DLGC_RADIOBUTTON,
4771 WmSetFocusStaticSeq, WmKillFocusStaticSeq },
4772 { BS_OWNERDRAW, DLGC_BUTTON,
4773 WmSetFocusButtonSeq, WmKillFocusButtonSeq }
4775 unsigned int i;
4776 HWND hwnd;
4777 DWORD dlg_code;
4778 HFONT zfont;
4780 subclass_button();
4782 for (i = 0; i < sizeof(button)/sizeof(button[0]); i++)
4784 hwnd = CreateWindowExA(0, "my_button_class", "test", button[i].style | WS_POPUP,
4785 0, 0, 50, 14, 0, 0, 0, NULL);
4786 ok(hwnd != 0, "Failed to create button window\n");
4788 dlg_code = SendMessageA(hwnd, WM_GETDLGCODE, 0, 0);
4789 ok(dlg_code == button[i].dlg_code, "%u: wrong dlg_code %08x\n", i, dlg_code);
4791 ShowWindow(hwnd, SW_SHOW);
4792 UpdateWindow(hwnd);
4793 SetFocus(0);
4794 flush_sequence();
4796 trace("button style %08x\n", button[i].style);
4797 SetFocus(hwnd);
4798 ok_sequence(button[i].setfocus, "SetFocus(hwnd) on a button", FALSE);
4800 SetFocus(0);
4801 ok_sequence(button[i].killfocus, "SetFocus(0) on a button", FALSE);
4803 DestroyWindow(hwnd);
4806 hwnd = CreateWindowExA(0, "my_button_class", "test", BS_PUSHBUTTON | WS_POPUP | WS_VISIBLE,
4807 0, 0, 50, 14, 0, 0, 0, NULL);
4808 ok(hwnd != 0, "Failed to create button window\n");
4810 SetFocus(0);
4811 flush_events();
4812 flush_sequence();
4814 SendMessageA(hwnd, WM_LBUTTONDOWN, 0, 0);
4815 ok_sequence(WmLButtonDownSeq, "WM_LBUTTONDOWN on a button", FALSE);
4817 SendMessageA(hwnd, WM_LBUTTONUP, 0, 0);
4818 ok_sequence(WmLButtonUpSeq, "WM_LBUTTONUP on a button", FALSE);
4820 flush_sequence();
4821 zfont = (HFONT)GetStockObject(SYSTEM_FONT);
4822 SendMessageA(hwnd, WM_SETFONT, (WPARAM)zfont, TRUE);
4823 UpdateWindow(hwnd);
4824 ok_sequence(WmSetFontButtonSeq, "WM_SETFONT on a button", FALSE);
4826 DestroyWindow(hwnd);
4829 /****************** static message test *************************/
4830 static const struct message WmSetFontStaticSeq[] =
4832 { WM_SETFONT, sent },
4833 { WM_PAINT, sent|defwinproc },
4834 { WM_ERASEBKGND, sent|defwinproc|optional },
4835 { WM_CTLCOLORSTATIC, sent|defwinproc },
4836 { 0 }
4839 static WNDPROC old_static_proc;
4841 static LRESULT CALLBACK static_hook_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
4843 static long defwndproc_counter = 0;
4844 LRESULT ret;
4845 struct message msg;
4847 trace("static: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
4849 /* explicitly ignore WM_GETICON message */
4850 if (message == WM_GETICON) return 0;
4852 msg.message = message;
4853 msg.flags = sent|wparam|lparam;
4854 if (defwndproc_counter) msg.flags |= defwinproc;
4855 msg.wParam = wParam;
4856 msg.lParam = lParam;
4857 add_message(&msg);
4859 defwndproc_counter++;
4860 ret = CallWindowProcA(old_static_proc, hwnd, message, wParam, lParam);
4861 defwndproc_counter--;
4863 return ret;
4866 static void subclass_static(void)
4868 WNDCLASSA cls;
4870 if (!GetClassInfoA(0, "static", &cls)) assert(0);
4872 old_static_proc = cls.lpfnWndProc;
4874 cls.hInstance = GetModuleHandle(0);
4875 cls.lpfnWndProc = static_hook_proc;
4876 cls.lpszClassName = "my_static_class";
4877 UnregisterClass(cls.lpszClassName, cls.hInstance);
4878 if (!RegisterClassA(&cls)) assert(0);
4881 static void test_static_messages(void)
4883 /* FIXME: make as comprehensive as the button message test */
4884 static const struct
4886 DWORD style;
4887 DWORD dlg_code;
4888 const struct message *setfont;
4889 } static_ctrl[] = {
4890 { SS_LEFT, DLGC_STATIC,
4891 WmSetFontStaticSeq }
4893 unsigned int i;
4894 HWND hwnd;
4895 DWORD dlg_code;
4897 subclass_static();
4899 for (i = 0; i < sizeof(static_ctrl)/sizeof(static_ctrl[0]); i++)
4901 hwnd = CreateWindowExA(0, "my_static_class", "test", static_ctrl[i].style | WS_POPUP,
4902 0, 0, 50, 14, 0, 0, 0, NULL);
4903 ok(hwnd != 0, "Failed to create static window\n");
4905 dlg_code = SendMessageA(hwnd, WM_GETDLGCODE, 0, 0);
4906 ok(dlg_code == static_ctrl[i].dlg_code, "%u: wrong dlg_code %08x\n", i, dlg_code);
4908 ShowWindow(hwnd, SW_SHOW);
4909 UpdateWindow(hwnd);
4910 SetFocus(0);
4911 flush_sequence();
4913 trace("static style %08x\n", static_ctrl[i].style);
4914 SendMessage(hwnd, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), TRUE);
4915 ok_sequence(static_ctrl[i].setfont, "WM_SETFONT on a static", FALSE);
4917 DestroyWindow(hwnd);
4921 /****************** ComboBox message test *************************/
4922 #define ID_COMBOBOX 0x000f
4924 static const struct message WmKeyDownComboSeq[] =
4926 { WM_KEYDOWN, sent|wparam|lparam, VK_DOWN, 0 },
4927 { WM_COMMAND, sent|wparam|defwinproc, MAKEWPARAM(1000, LBN_SELCHANGE) },
4928 { WM_COMMAND, sent|wparam|parent, MAKEWPARAM(ID_COMBOBOX, CBN_SELENDOK) },
4929 { WM_COMMAND, sent|wparam|parent, MAKEWPARAM(ID_COMBOBOX, CBN_SELCHANGE) },
4930 { WM_CTLCOLOREDIT, sent|parent },
4931 { WM_KEYUP, sent|wparam|lparam, VK_DOWN, 0 },
4932 { 0 }
4935 static WNDPROC old_combobox_proc;
4937 static LRESULT CALLBACK combobox_hook_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
4939 static long defwndproc_counter = 0;
4940 LRESULT ret;
4941 struct message msg;
4943 /* do not log painting messages */
4944 if (message != WM_PAINT &&
4945 message != WM_NCPAINT &&
4946 message != WM_SYNCPAINT &&
4947 message != WM_ERASEBKGND &&
4948 message != WM_NCHITTEST &&
4949 message != WM_GETTEXT &&
4950 message != WM_GETICON &&
4951 message != WM_DEVICECHANGE)
4953 trace("combo: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
4955 msg.message = message;
4956 msg.flags = sent|wparam|lparam;
4957 if (defwndproc_counter) msg.flags |= defwinproc;
4958 msg.wParam = wParam;
4959 msg.lParam = lParam;
4960 add_message(&msg);
4963 defwndproc_counter++;
4964 ret = CallWindowProcA(old_combobox_proc, hwnd, message, wParam, lParam);
4965 defwndproc_counter--;
4967 return ret;
4970 static void subclass_combobox(void)
4972 WNDCLASSA cls;
4974 if (!GetClassInfoA(0, "ComboBox", &cls)) assert(0);
4976 old_combobox_proc = cls.lpfnWndProc;
4978 cls.hInstance = GetModuleHandle(0);
4979 cls.lpfnWndProc = combobox_hook_proc;
4980 cls.lpszClassName = "my_combobox_class";
4981 UnregisterClass(cls.lpszClassName, cls.hInstance);
4982 if (!RegisterClassA(&cls)) assert(0);
4985 static void test_combobox_messages(void)
4987 HWND parent, combo;
4988 LRESULT ret;
4990 subclass_combobox();
4992 parent = CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
4993 100, 100, 200, 200, 0, 0, 0, NULL);
4994 ok(parent != 0, "Failed to create parent window\n");
4995 flush_sequence();
4997 combo = CreateWindowEx(0, "my_combobox_class", "test", WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST | CBS_HASSTRINGS,
4998 0, 0, 100, 150, parent, (HMENU)ID_COMBOBOX, 0, NULL);
4999 ok(combo != 0, "Failed to create combobox window\n");
5001 UpdateWindow(combo);
5003 ret = SendMessage(combo, WM_GETDLGCODE, 0, 0);
5004 ok(ret == (DLGC_WANTCHARS | DLGC_WANTARROWS), "wrong dlg_code %08lx\n", ret);
5006 ret = SendMessage(combo, CB_ADDSTRING, 0, (LPARAM)"item 0");
5007 ok(ret == 0, "expected 0, got %ld\n", ret);
5008 ret = SendMessage(combo, CB_ADDSTRING, 0, (LPARAM)"item 1");
5009 ok(ret == 1, "expected 1, got %ld\n", ret);
5010 ret = SendMessage(combo, CB_ADDSTRING, 0, (LPARAM)"item 2");
5011 ok(ret == 2, "expected 2, got %ld\n", ret);
5013 SendMessage(combo, CB_SETCURSEL, 0, 0);
5014 SetFocus(combo);
5015 flush_sequence();
5017 log_all_parent_messages++;
5018 SendMessage(combo, WM_KEYDOWN, VK_DOWN, 0);
5019 SendMessage(combo, WM_KEYUP, VK_DOWN, 0);
5020 log_all_parent_messages--;
5021 ok_sequence(WmKeyDownComboSeq, "WM_KEYDOWN/VK_DOWN on a ComboBox", FALSE);
5023 DestroyWindow(combo);
5024 DestroyWindow(parent);
5027 /************* painting message test ********************/
5029 void dump_region(HRGN hrgn)
5031 DWORD i, size;
5032 RGNDATA *data = NULL;
5033 RECT *rect;
5035 if (!hrgn)
5037 printf( "null region\n" );
5038 return;
5040 if (!(size = GetRegionData( hrgn, 0, NULL ))) return;
5041 if (!(data = HeapAlloc( GetProcessHeap(), 0, size ))) return;
5042 GetRegionData( hrgn, size, data );
5043 printf("%d rects:", data->rdh.nCount );
5044 for (i = 0, rect = (RECT *)data->Buffer; i < data->rdh.nCount; i++, rect++)
5045 printf( " (%d,%d)-(%d,%d)", rect->left, rect->top, rect->right, rect->bottom );
5046 printf("\n");
5047 HeapFree( GetProcessHeap(), 0, data );
5050 static void check_update_rgn( HWND hwnd, HRGN hrgn )
5052 INT ret;
5053 RECT r1, r2;
5054 HRGN tmp = CreateRectRgn( 0, 0, 0, 0 );
5055 HRGN update = CreateRectRgn( 0, 0, 0, 0 );
5057 ret = GetUpdateRgn( hwnd, update, FALSE );
5058 ok( ret != ERROR, "GetUpdateRgn failed\n" );
5059 if (ret == NULLREGION)
5061 ok( !hrgn, "Update region shouldn't be empty\n" );
5063 else
5065 if (CombineRgn( tmp, hrgn, update, RGN_XOR ) != NULLREGION)
5067 ok( 0, "Regions are different\n" );
5068 if (winetest_debug > 0)
5070 printf( "Update region: " );
5071 dump_region( update );
5072 printf( "Wanted region: " );
5073 dump_region( hrgn );
5077 GetRgnBox( update, &r1 );
5078 GetUpdateRect( hwnd, &r2, FALSE );
5079 ok( r1.left == r2.left && r1.top == r2.top && r1.right == r2.right && r1.bottom == r2.bottom,
5080 "Rectangles are different: %d,%d-%d,%d / %d,%d-%d,%d\n",
5081 r1.left, r1.top, r1.right, r1.bottom, r2.left, r2.top, r2.right, r2.bottom );
5083 DeleteObject( tmp );
5084 DeleteObject( update );
5087 static const struct message WmInvalidateRgn[] = {
5088 { WM_NCPAINT, sent },
5089 { WM_GETTEXT, sent|defwinproc|optional },
5090 { 0 }
5093 static const struct message WmGetUpdateRect[] = {
5094 { WM_NCPAINT, sent },
5095 { WM_GETTEXT, sent|defwinproc|optional },
5096 { WM_PAINT, sent },
5097 { 0 }
5100 static const struct message WmInvalidateFull[] = {
5101 { WM_NCPAINT, sent|wparam, 1 },
5102 { WM_GETTEXT, sent|defwinproc|optional },
5103 { 0 }
5106 static const struct message WmInvalidateErase[] = {
5107 { WM_NCPAINT, sent|wparam, 1 },
5108 { WM_GETTEXT, sent|defwinproc|optional },
5109 { WM_ERASEBKGND, sent },
5110 { 0 }
5113 static const struct message WmInvalidatePaint[] = {
5114 { WM_PAINT, sent },
5115 { WM_NCPAINT, sent|wparam|beginpaint, 1 },
5116 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
5117 { 0 }
5120 static const struct message WmInvalidateErasePaint[] = {
5121 { WM_PAINT, sent },
5122 { WM_NCPAINT, sent|wparam|beginpaint, 1 },
5123 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
5124 { WM_ERASEBKGND, sent|beginpaint },
5125 { 0 }
5128 static const struct message WmInvalidateErasePaint2[] = {
5129 { WM_PAINT, sent },
5130 { WM_NCPAINT, sent|beginpaint },
5131 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
5132 { WM_ERASEBKGND, sent|beginpaint },
5133 { 0 }
5136 static const struct message WmErase[] = {
5137 { WM_ERASEBKGND, sent },
5138 { 0 }
5141 static const struct message WmPaint[] = {
5142 { WM_PAINT, sent },
5143 { 0 }
5146 static const struct message WmParentOnlyPaint[] = {
5147 { WM_PAINT, sent|parent },
5148 { 0 }
5151 static const struct message WmInvalidateParent[] = {
5152 { WM_NCPAINT, sent|parent },
5153 { WM_GETTEXT, sent|defwinproc|parent|optional },
5154 { WM_ERASEBKGND, sent|parent },
5155 { 0 }
5158 static const struct message WmInvalidateParentChild[] = {
5159 { WM_NCPAINT, sent|parent },
5160 { WM_GETTEXT, sent|defwinproc|parent|optional },
5161 { WM_ERASEBKGND, sent|parent },
5162 { WM_NCPAINT, sent },
5163 { WM_GETTEXT, sent|defwinproc|optional },
5164 { WM_ERASEBKGND, sent },
5165 { 0 }
5168 static const struct message WmInvalidateParentChild2[] = {
5169 { WM_ERASEBKGND, sent|parent },
5170 { WM_NCPAINT, sent },
5171 { WM_GETTEXT, sent|defwinproc|optional },
5172 { WM_ERASEBKGND, sent },
5173 { 0 }
5176 static const struct message WmParentPaint[] = {
5177 { WM_PAINT, sent|parent },
5178 { WM_PAINT, sent },
5179 { 0 }
5182 static const struct message WmParentPaintNc[] = {
5183 { WM_PAINT, sent|parent },
5184 { WM_PAINT, sent },
5185 { WM_NCPAINT, sent|beginpaint },
5186 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
5187 { WM_ERASEBKGND, sent|beginpaint },
5188 { 0 }
5191 static const struct message WmChildPaintNc[] = {
5192 { WM_PAINT, sent },
5193 { WM_NCPAINT, sent|beginpaint },
5194 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
5195 { WM_ERASEBKGND, sent|beginpaint },
5196 { 0 }
5199 static const struct message WmParentErasePaint[] = {
5200 { WM_PAINT, sent|parent },
5201 { WM_NCPAINT, sent|parent|beginpaint },
5202 { WM_GETTEXT, sent|parent|beginpaint|defwinproc|optional },
5203 { WM_ERASEBKGND, sent|parent|beginpaint },
5204 { WM_PAINT, sent },
5205 { WM_NCPAINT, sent|beginpaint },
5206 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
5207 { WM_ERASEBKGND, sent|beginpaint },
5208 { 0 }
5211 static const struct message WmParentOnlyNcPaint[] = {
5212 { WM_PAINT, sent|parent },
5213 { WM_NCPAINT, sent|parent|beginpaint },
5214 { WM_GETTEXT, sent|parent|beginpaint|defwinproc|optional },
5215 { 0 }
5218 static const struct message WmSetParentStyle[] = {
5219 { WM_STYLECHANGING, sent|parent },
5220 { WM_STYLECHANGED, sent|parent },
5221 { 0 }
5224 static void test_paint_messages(void)
5226 BOOL ret;
5227 RECT rect;
5228 POINT pt;
5229 MSG msg;
5230 HWND hparent, hchild;
5231 HRGN hrgn = CreateRectRgn( 0, 0, 0, 0 );
5232 HRGN hrgn2 = CreateRectRgn( 0, 0, 0, 0 );
5233 HWND hwnd = CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW,
5234 100, 100, 200, 200, 0, 0, 0, NULL);
5235 ok (hwnd != 0, "Failed to create overlapped window\n");
5237 ShowWindow( hwnd, SW_SHOW );
5238 UpdateWindow( hwnd );
5239 flush_events();
5240 flush_sequence();
5242 check_update_rgn( hwnd, 0 );
5243 SetRectRgn( hrgn, 10, 10, 20, 20 );
5244 ret = RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE );
5245 ok(ret, "RedrawWindow returned %d instead of TRUE\n", ret);
5246 check_update_rgn( hwnd, hrgn );
5247 SetRectRgn( hrgn2, 20, 20, 30, 30 );
5248 ret = RedrawWindow( hwnd, NULL, hrgn2, RDW_INVALIDATE );
5249 ok(ret, "RedrawWindow returned %d instead of TRUE\n", ret);
5250 CombineRgn( hrgn, hrgn, hrgn2, RGN_OR );
5251 check_update_rgn( hwnd, hrgn );
5252 /* validate everything */
5253 ret = RedrawWindow( hwnd, NULL, NULL, RDW_VALIDATE );
5254 ok(ret, "RedrawWindow returned %d instead of TRUE\n", ret);
5255 check_update_rgn( hwnd, 0 );
5257 /* test empty region */
5258 SetRectRgn( hrgn, 10, 10, 10, 15 );
5259 ret = RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE );
5260 ok(ret, "RedrawWindow returned %d instead of TRUE\n", ret);
5261 check_update_rgn( hwnd, 0 );
5262 /* test empty rect */
5263 SetRect( &rect, 10, 10, 10, 15 );
5264 ret = RedrawWindow( hwnd, &rect, NULL, RDW_INVALIDATE );
5265 ok(ret, "RedrawWindow returned %d instead of TRUE\n", ret);
5266 check_update_rgn( hwnd, 0 );
5268 /* flush pending messages */
5269 flush_events();
5270 flush_sequence();
5272 GetClientRect( hwnd, &rect );
5273 SetRectRgn( hrgn, 0, 0, rect.right - rect.left, rect.bottom - rect.top );
5274 /* MSDN: if hwnd parameter is NULL, InvalidateRect invalidates and redraws
5275 * all windows and sends WM_ERASEBKGND and WM_NCPAINT.
5277 trace("testing InvalidateRect(0, NULL, FALSE)\n");
5278 SetRectEmpty( &rect );
5279 ok(InvalidateRect(0, &rect, FALSE), "InvalidateRect(0, &rc, FALSE) should fail\n");
5280 check_update_rgn( hwnd, hrgn );
5281 ok_sequence( WmInvalidateErase, "InvalidateErase", FALSE );
5282 flush_events();
5283 ok_sequence( WmPaint, "Paint", FALSE );
5284 RedrawWindow( hwnd, NULL, NULL, RDW_VALIDATE );
5285 check_update_rgn( hwnd, 0 );
5287 /* MSDN: if hwnd parameter is NULL, ValidateRect invalidates and redraws
5288 * all windows and sends WM_ERASEBKGND and WM_NCPAINT.
5290 trace("testing ValidateRect(0, NULL)\n");
5291 SetRectEmpty( &rect );
5292 ok(ValidateRect(0, &rect), "ValidateRect(0, &rc) should not fail\n");
5293 check_update_rgn( hwnd, hrgn );
5294 ok_sequence( WmInvalidateErase, "InvalidateErase", FALSE );
5295 flush_events();
5296 ok_sequence( WmPaint, "Paint", FALSE );
5297 RedrawWindow( hwnd, NULL, NULL, RDW_VALIDATE );
5298 check_update_rgn( hwnd, 0 );
5300 trace("testing InvalidateRgn(0, NULL, FALSE)\n");
5301 SetLastError(0xdeadbeef);
5302 ok(!InvalidateRgn(0, NULL, FALSE), "InvalidateRgn(0, NULL, FALSE) should fail\n");
5303 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE || GetLastError() == 0xdeadbeef,
5304 "wrong error code %d\n", GetLastError());
5305 check_update_rgn( hwnd, 0 );
5306 flush_events();
5307 ok_sequence( WmEmptySeq, "WmEmptySeq", FALSE );
5309 trace("testing ValidateRgn(0, NULL)\n");
5310 SetLastError(0xdeadbeef);
5311 ok(!ValidateRgn(0, NULL), "ValidateRgn(0, NULL) should fail\n");
5312 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "wrong error code %d\n", GetLastError());
5313 check_update_rgn( hwnd, 0 );
5314 flush_events();
5315 ok_sequence( WmEmptySeq, "WmEmptySeq", FALSE );
5317 /* now with frame */
5318 SetRectRgn( hrgn, -5, -5, 20, 20 );
5320 /* flush pending messages */
5321 flush_events();
5322 flush_sequence();
5323 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME );
5324 ok_sequence( WmEmptySeq, "EmptySeq", FALSE );
5326 SetRectRgn( hrgn, 0, 0, 20, 20 ); /* GetUpdateRgn clips to client area */
5327 check_update_rgn( hwnd, hrgn );
5329 flush_sequence();
5330 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME | RDW_ERASENOW );
5331 ok_sequence( WmInvalidateRgn, "InvalidateRgn", FALSE );
5333 flush_sequence();
5334 RedrawWindow( hwnd, NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_ERASENOW );
5335 ok_sequence( WmInvalidateFull, "InvalidateFull", FALSE );
5337 GetClientRect( hwnd, &rect );
5338 SetRectRgn( hrgn, rect.left, rect.top, rect.right, rect.bottom );
5339 check_update_rgn( hwnd, hrgn );
5341 flush_sequence();
5342 RedrawWindow( hwnd, NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_ERASE | RDW_ERASENOW );
5343 ok_sequence( WmInvalidateErase, "InvalidateErase", FALSE );
5345 flush_sequence();
5346 RedrawWindow( hwnd, NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_ERASENOW | RDW_UPDATENOW );
5347 ok_sequence( WmInvalidatePaint, "InvalidatePaint", FALSE );
5348 check_update_rgn( hwnd, 0 );
5350 flush_sequence();
5351 RedrawWindow( hwnd, NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_ERASE | RDW_UPDATENOW );
5352 ok_sequence( WmInvalidateErasePaint, "InvalidateErasePaint", FALSE );
5353 check_update_rgn( hwnd, 0 );
5355 flush_sequence();
5356 SetRectRgn( hrgn, 0, 0, 100, 100 );
5357 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE );
5358 SetRectRgn( hrgn, 0, 0, 50, 100 );
5359 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE );
5360 SetRectRgn( hrgn, 50, 0, 100, 100 );
5361 check_update_rgn( hwnd, hrgn );
5362 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_ERASENOW );
5363 ok_sequence( WmEmptySeq, "EmptySeq", FALSE ); /* must not generate messages, everything is valid */
5364 check_update_rgn( hwnd, 0 );
5366 flush_sequence();
5367 SetRectRgn( hrgn, 0, 0, 100, 100 );
5368 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_ERASE );
5369 SetRectRgn( hrgn, 0, 0, 100, 50 );
5370 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_ERASENOW );
5371 ok_sequence( WmErase, "Erase", FALSE );
5372 SetRectRgn( hrgn, 0, 50, 100, 100 );
5373 check_update_rgn( hwnd, hrgn );
5375 flush_sequence();
5376 SetRectRgn( hrgn, 0, 0, 100, 100 );
5377 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_ERASE );
5378 SetRectRgn( hrgn, 0, 0, 50, 50 );
5379 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_NOERASE | RDW_UPDATENOW );
5380 ok_sequence( WmPaint, "Paint", FALSE );
5382 flush_sequence();
5383 SetRectRgn( hrgn, -4, -4, -2, -2 );
5384 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME );
5385 SetRectRgn( hrgn, -200, -200, -198, -198 );
5386 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_NOFRAME | RDW_ERASENOW );
5387 ok_sequence( WmEmptySeq, "EmptySeq", FALSE );
5389 flush_sequence();
5390 SetRectRgn( hrgn, -4, -4, -2, -2 );
5391 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME );
5392 SetRectRgn( hrgn, -4, -4, -3, -3 );
5393 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_NOFRAME );
5394 SetRectRgn( hrgn, 0, 0, 1, 1 );
5395 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_UPDATENOW );
5396 ok_sequence( WmPaint, "Paint", FALSE );
5398 flush_sequence();
5399 SetRectRgn( hrgn, -4, -4, -1, -1 );
5400 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME );
5401 RedrawWindow( hwnd, NULL, 0, RDW_ERASENOW );
5402 /* make sure no WM_PAINT was generated */
5403 flush_events();
5404 ok_sequence( WmInvalidateRgn, "InvalidateRgn", FALSE );
5406 flush_sequence();
5407 SetRectRgn( hrgn, -4, -4, -1, -1 );
5408 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME );
5409 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE ))
5411 if (msg.hwnd == hwnd && msg.message == WM_PAINT)
5413 /* GetUpdateRgn must return empty region since only nonclient area is invalidated */
5414 INT ret = GetUpdateRgn( hwnd, hrgn, FALSE );
5415 ok( ret == NULLREGION, "Invalid GetUpdateRgn result %d\n", ret );
5416 ret = GetUpdateRect( hwnd, &rect, FALSE );
5417 ok( ret, "Invalid GetUpdateRect result %d\n", ret );
5418 /* this will send WM_NCPAINT and validate the non client area */
5419 ret = GetUpdateRect( hwnd, &rect, TRUE );
5420 ok( !ret, "Invalid GetUpdateRect result %d\n", ret );
5422 DispatchMessage( &msg );
5424 ok_sequence( WmGetUpdateRect, "GetUpdateRect", FALSE );
5426 DestroyWindow( hwnd );
5428 /* now test with a child window */
5430 hparent = CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW,
5431 100, 100, 200, 200, 0, 0, 0, NULL);
5432 ok (hparent != 0, "Failed to create parent window\n");
5434 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD | WS_VISIBLE | WS_BORDER,
5435 10, 10, 100, 100, hparent, 0, 0, NULL);
5436 ok (hchild != 0, "Failed to create child window\n");
5438 ShowWindow( hparent, SW_SHOW );
5439 UpdateWindow( hparent );
5440 UpdateWindow( hchild );
5441 flush_events();
5442 flush_sequence();
5443 log_all_parent_messages++;
5445 SetRect( &rect, 0, 0, 50, 50 );
5446 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
5447 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW | RDW_ALLCHILDREN );
5448 ok_sequence( WmInvalidateParentChild, "InvalidateParentChild", FALSE );
5450 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
5451 pt.x = pt.y = 0;
5452 MapWindowPoints( hchild, hparent, &pt, 1 );
5453 SetRectRgn( hrgn, 0, 0, 50 - pt.x, 50 - pt.y );
5454 check_update_rgn( hchild, hrgn );
5455 SetRectRgn( hrgn, 0, 0, 50, 50 );
5456 check_update_rgn( hparent, hrgn );
5457 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW );
5458 ok_sequence( WmInvalidateParent, "InvalidateParent", FALSE );
5459 RedrawWindow( hchild, NULL, 0, RDW_ERASENOW );
5460 ok_sequence( WmEmptySeq, "EraseNow child", FALSE );
5462 flush_events();
5463 ok_sequence( WmParentPaintNc, "WmParentPaintNc", FALSE );
5465 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_ALLCHILDREN );
5466 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW );
5467 ok_sequence( WmInvalidateParent, "InvalidateParent2", FALSE );
5468 RedrawWindow( hchild, NULL, 0, RDW_ERASENOW );
5469 ok_sequence( WmEmptySeq, "EraseNow child", FALSE );
5471 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE );
5472 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW | RDW_ALLCHILDREN );
5473 ok_sequence( WmInvalidateParentChild2, "InvalidateParentChild2", FALSE );
5475 SetWindowLong( hparent, GWL_STYLE, GetWindowLong(hparent,GWL_STYLE) | WS_CLIPCHILDREN );
5476 flush_sequence();
5477 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_ALLCHILDREN );
5478 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW );
5479 ok_sequence( WmInvalidateParentChild, "InvalidateParentChild3", FALSE );
5481 /* flush all paint messages */
5482 flush_events();
5483 flush_sequence();
5485 /* RDW_UPDATENOW on child with WS_CLIPCHILDREN doesn't change corresponding parent area */
5486 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_ALLCHILDREN );
5487 SetRectRgn( hrgn, 0, 0, 50, 50 );
5488 check_update_rgn( hparent, hrgn );
5489 RedrawWindow( hchild, NULL, 0, RDW_UPDATENOW );
5490 ok_sequence( WmInvalidateErasePaint2, "WmInvalidateErasePaint2", FALSE );
5491 SetRectRgn( hrgn, 0, 0, 50, 50 );
5492 check_update_rgn( hparent, hrgn );
5494 /* flush all paint messages */
5495 flush_events();
5496 SetWindowLong( hparent, GWL_STYLE, GetWindowLong(hparent,GWL_STYLE) & ~WS_CLIPCHILDREN );
5497 flush_sequence();
5499 /* RDW_UPDATENOW on child without WS_CLIPCHILDREN will validate corresponding parent area */
5500 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
5501 SetRectRgn( hrgn, 0, 0, 50, 50 );
5502 check_update_rgn( hparent, hrgn );
5503 RedrawWindow( hchild, NULL, 0, RDW_UPDATENOW );
5504 ok_sequence( WmInvalidateErasePaint2, "WmInvalidateErasePaint2", FALSE );
5505 SetRectRgn( hrgn2, 10, 10, 50, 50 );
5506 CombineRgn( hrgn, hrgn, hrgn2, RGN_DIFF );
5507 check_update_rgn( hparent, hrgn );
5508 /* flush all paint messages */
5509 flush_events();
5510 flush_sequence();
5512 /* same as above but parent gets completely validated */
5513 SetRect( &rect, 20, 20, 30, 30 );
5514 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
5515 SetRectRgn( hrgn, 20, 20, 30, 30 );
5516 check_update_rgn( hparent, hrgn );
5517 RedrawWindow( hchild, NULL, 0, RDW_UPDATENOW );
5518 ok_sequence( WmInvalidateErasePaint2, "WmInvalidateErasePaint2", FALSE );
5519 check_update_rgn( hparent, 0 ); /* no update region */
5520 flush_events();
5521 ok_sequence( WmEmptySeq, "WmEmpty", FALSE ); /* and no paint messages */
5523 /* make sure RDW_VALIDATE on child doesn't have the same effect */
5524 flush_sequence();
5525 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
5526 SetRectRgn( hrgn, 20, 20, 30, 30 );
5527 check_update_rgn( hparent, hrgn );
5528 RedrawWindow( hchild, NULL, 0, RDW_VALIDATE | RDW_NOERASE );
5529 SetRectRgn( hrgn, 20, 20, 30, 30 );
5530 check_update_rgn( hparent, hrgn );
5532 /* same as above but normal WM_PAINT doesn't validate parent */
5533 flush_sequence();
5534 SetRect( &rect, 20, 20, 30, 30 );
5535 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
5536 SetRectRgn( hrgn, 20, 20, 30, 30 );
5537 check_update_rgn( hparent, hrgn );
5538 /* no WM_PAINT in child while parent still pending */
5539 while (PeekMessage( &msg, hchild, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
5540 ok_sequence( WmEmptySeq, "No WM_PAINT", FALSE );
5541 while (PeekMessage( &msg, hparent, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
5542 ok_sequence( WmParentErasePaint, "WmParentErasePaint", FALSE );
5544 flush_sequence();
5545 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
5546 /* no WM_PAINT in child while parent still pending */
5547 while (PeekMessage( &msg, hchild, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
5548 ok_sequence( WmEmptySeq, "No WM_PAINT", FALSE );
5549 RedrawWindow( hparent, &rect, 0, RDW_VALIDATE | RDW_NOERASE | RDW_NOCHILDREN );
5550 /* now that parent is valid child should get WM_PAINT */
5551 while (PeekMessage( &msg, hchild, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
5552 ok_sequence( WmInvalidateErasePaint2, "WmInvalidateErasePaint2", FALSE );
5553 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
5554 ok_sequence( WmEmptySeq, "No other message", FALSE );
5556 /* same thing with WS_CLIPCHILDREN in parent */
5557 flush_sequence();
5558 SetWindowLong( hparent, GWL_STYLE, GetWindowLong(hparent,GWL_STYLE) | WS_CLIPCHILDREN );
5559 ok_sequence( WmSetParentStyle, "WmSetParentStyle", FALSE );
5560 /* changing style invalidates non client area, but we need to invalidate something else to see it */
5561 RedrawWindow( hparent, &rect, 0, RDW_UPDATENOW );
5562 ok_sequence( WmEmptySeq, "No message", FALSE );
5563 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_UPDATENOW );
5564 ok_sequence( WmParentOnlyNcPaint, "WmParentOnlyNcPaint", FALSE );
5566 flush_sequence();
5567 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_ALLCHILDREN );
5568 SetRectRgn( hrgn, 20, 20, 30, 30 );
5569 check_update_rgn( hparent, hrgn );
5570 /* no WM_PAINT in child while parent still pending */
5571 while (PeekMessage( &msg, hchild, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
5572 ok_sequence( WmEmptySeq, "No WM_PAINT", FALSE );
5573 /* WM_PAINT in parent first */
5574 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
5575 ok_sequence( WmParentPaintNc, "WmParentPaintNc2", FALSE );
5577 /* no RDW_ERASE in parent still causes RDW_ERASE and RDW_FRAME in child */
5578 flush_sequence();
5579 SetRect( &rect, 0, 0, 30, 30 );
5580 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ALLCHILDREN );
5581 SetRectRgn( hrgn, 0, 0, 30, 30 );
5582 check_update_rgn( hparent, hrgn );
5583 flush_events();
5584 ok_sequence( WmParentPaintNc, "WmParentPaintNc3", FALSE );
5586 /* validate doesn't cause RDW_NOERASE or RDW_NOFRAME in child */
5587 flush_sequence();
5588 SetRect( &rect, -10, 0, 30, 30 );
5589 RedrawWindow( hchild, &rect, 0, RDW_INVALIDATE | RDW_FRAME | RDW_ERASE );
5590 SetRect( &rect, 0, 0, 20, 20 );
5591 RedrawWindow( hparent, &rect, 0, RDW_VALIDATE | RDW_ALLCHILDREN );
5592 RedrawWindow( hparent, NULL, 0, RDW_UPDATENOW );
5593 ok_sequence( WmChildPaintNc, "WmChildPaintNc", FALSE );
5595 /* validate doesn't cause RDW_NOERASE or RDW_NOFRAME in child */
5596 flush_sequence();
5597 SetRect( &rect, -10, 0, 30, 30 );
5598 RedrawWindow( hchild, &rect, 0, RDW_INVALIDATE | RDW_FRAME | RDW_ERASE );
5599 SetRect( &rect, 0, 0, 100, 100 );
5600 RedrawWindow( hparent, &rect, 0, RDW_VALIDATE | RDW_ALLCHILDREN );
5601 RedrawWindow( hparent, NULL, 0, RDW_UPDATENOW );
5602 ok_sequence( WmEmptySeq, "WmChildPaintNc2", FALSE );
5603 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW );
5604 ok_sequence( WmEmptySeq, "WmChildPaintNc3", FALSE );
5606 /* test RDW_INTERNALPAINT behavior */
5608 flush_sequence();
5609 RedrawWindow( hparent, NULL, 0, RDW_INTERNALPAINT | RDW_NOCHILDREN );
5610 flush_events();
5611 ok_sequence( WmParentOnlyPaint, "WmParentOnlyPaint", FALSE );
5613 RedrawWindow( hparent, NULL, 0, RDW_INTERNALPAINT | RDW_ALLCHILDREN );
5614 flush_events();
5615 ok_sequence( WmParentPaint, "WmParentPaint", FALSE );
5617 RedrawWindow( hparent, NULL, 0, RDW_INTERNALPAINT );
5618 flush_events();
5619 ok_sequence( WmParentOnlyPaint, "WmParentOnlyPaint", FALSE );
5621 assert( GetWindowLong(hparent, GWL_STYLE) & WS_CLIPCHILDREN );
5622 UpdateWindow( hparent );
5623 flush_events();
5624 flush_sequence();
5625 trace("testing SWP_FRAMECHANGED on parent with WS_CLIPCHILDREN\n");
5626 RedrawWindow( hchild, NULL, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
5627 SetWindowPos( hparent, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE |
5628 SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED );
5629 flush_events();
5630 ok_sequence(WmSWP_FrameChanged_clip, "SetWindowPos:FrameChanged_clip", FALSE );
5632 UpdateWindow( hparent );
5633 flush_events();
5634 flush_sequence();
5635 trace("testing SWP_FRAMECHANGED|SWP_DEFERERASE on parent with WS_CLIPCHILDREN\n");
5636 RedrawWindow( hchild, NULL, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
5637 SetWindowPos( hparent, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_DEFERERASE |
5638 SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED );
5639 flush_events();
5640 ok_sequence(WmSWP_FrameChangedDeferErase, "SetWindowPos:FrameChangedDeferErase", FALSE );
5642 SetWindowLong( hparent, GWL_STYLE, GetWindowLong(hparent,GWL_STYLE) & ~WS_CLIPCHILDREN );
5643 ok_sequence( WmSetParentStyle, "WmSetParentStyle", FALSE );
5644 RedrawWindow( hparent, NULL, 0, RDW_INTERNALPAINT );
5645 flush_events();
5646 ok_sequence( WmParentPaint, "WmParentPaint", FALSE );
5648 assert( !(GetWindowLong(hparent, GWL_STYLE) & WS_CLIPCHILDREN) );
5649 UpdateWindow( hparent );
5650 flush_events();
5651 flush_sequence();
5652 trace("testing SWP_FRAMECHANGED on parent without WS_CLIPCHILDREN\n");
5653 RedrawWindow( hchild, NULL, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
5654 SetWindowPos( hparent, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE |
5655 SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED );
5656 flush_events();
5657 ok_sequence(WmSWP_FrameChanged_noclip, "SetWindowPos:FrameChanged_noclip", FALSE );
5659 UpdateWindow( hparent );
5660 flush_events();
5661 flush_sequence();
5662 trace("testing SWP_FRAMECHANGED|SWP_DEFERERASE on parent without WS_CLIPCHILDREN\n");
5663 RedrawWindow( hchild, NULL, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
5664 SetWindowPos( hparent, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_DEFERERASE |
5665 SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED );
5666 flush_events();
5667 ok_sequence(WmSWP_FrameChangedDeferErase, "SetWindowPos:FrameChangedDeferErase", FALSE );
5669 log_all_parent_messages--;
5670 DestroyWindow( hparent );
5671 ok(!IsWindow(hchild), "child must be destroyed with its parent\n");
5673 DeleteObject( hrgn );
5674 DeleteObject( hrgn2 );
5677 struct wnd_event
5679 HWND hwnd;
5680 HANDLE event;
5683 static DWORD WINAPI thread_proc(void *param)
5685 MSG msg;
5686 struct wnd_event *wnd_event = (struct wnd_event *)param;
5688 wnd_event->hwnd = CreateWindowExA(0, "TestWindowClass", "window caption text", WS_OVERLAPPEDWINDOW,
5689 100, 100, 200, 200, 0, 0, 0, NULL);
5690 ok(wnd_event->hwnd != 0, "Failed to create overlapped window\n");
5692 SetEvent(wnd_event->event);
5694 while (GetMessage(&msg, 0, 0, 0))
5696 TranslateMessage(&msg);
5697 DispatchMessage(&msg);
5700 ok(IsWindow(wnd_event->hwnd), "window should still exist\n");
5702 return 0;
5705 static void test_interthread_messages(void)
5707 HANDLE hThread;
5708 DWORD tid;
5709 WNDPROC proc;
5710 MSG msg;
5711 char buf[256];
5712 int len, expected_len;
5713 struct wnd_event wnd_event;
5714 BOOL ret;
5716 wnd_event.event = CreateEventW(NULL, 0, 0, NULL);
5717 if (!wnd_event.event)
5719 trace("skipping interthread message test under win9x\n");
5720 return;
5723 hThread = CreateThread(NULL, 0, thread_proc, &wnd_event, 0, &tid);
5724 ok(hThread != NULL, "CreateThread failed, error %d\n", GetLastError());
5726 ok(WaitForSingleObject(wnd_event.event, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
5728 CloseHandle(wnd_event.event);
5730 SetLastError(0xdeadbeef);
5731 ok(!DestroyWindow(wnd_event.hwnd), "DestroyWindow succeded\n");
5732 ok(GetLastError() == ERROR_ACCESS_DENIED || GetLastError() == 0xdeadbeef,
5733 "wrong error code %d\n", GetLastError());
5735 proc = (WNDPROC)GetWindowLongPtrA(wnd_event.hwnd, GWLP_WNDPROC);
5736 ok(proc != NULL, "GetWindowLongPtrA(GWLP_WNDPROC) error %d\n", GetLastError());
5738 expected_len = lstrlenA("window caption text");
5739 memset(buf, 0, sizeof(buf));
5740 SetLastError(0xdeadbeef);
5741 len = CallWindowProcA(proc, wnd_event.hwnd, WM_GETTEXT, sizeof(buf), (LPARAM)buf);
5742 ok(len == expected_len, "CallWindowProcA(WM_GETTEXT) error %d, len %d, expected len %d\n", GetLastError(), len, expected_len);
5743 ok(!lstrcmpA(buf, "window caption text"), "window text mismatch\n");
5745 msg.hwnd = wnd_event.hwnd;
5746 msg.message = WM_GETTEXT;
5747 msg.wParam = sizeof(buf);
5748 msg.lParam = (LPARAM)buf;
5749 memset(buf, 0, sizeof(buf));
5750 SetLastError(0xdeadbeef);
5751 len = DispatchMessageA(&msg);
5752 ok(!len && GetLastError() == ERROR_MESSAGE_SYNC_ONLY,
5753 "DispatchMessageA(WM_GETTEXT) succeded on another thread window: ret %d, error %d\n", len, GetLastError());
5755 /* the following test causes an exception in user.exe under win9x */
5756 msg.hwnd = wnd_event.hwnd;
5757 msg.message = WM_TIMER;
5758 msg.wParam = 0;
5759 msg.lParam = GetWindowLongPtrA(wnd_event.hwnd, GWLP_WNDPROC);
5760 SetLastError(0xdeadbeef);
5761 len = DispatchMessageA(&msg);
5762 ok(!len && GetLastError() == 0xdeadbeef,
5763 "DispatchMessageA(WM_TIMER) failed on another thread window: ret %d, error %d\n", len, GetLastError());
5765 ret = PostMessageA(wnd_event.hwnd, WM_QUIT, 0, 0);
5766 ok( ret, "PostMessageA(WM_QUIT) error %d\n", GetLastError());
5768 ok(WaitForSingleObject(hThread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
5769 CloseHandle(hThread);
5771 ok(!IsWindow(wnd_event.hwnd), "window should be destroyed on thread exit\n");
5775 static const struct message WmVkN[] = {
5776 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 1 }, /* XP */
5777 { WM_KEYDOWN, wparam|lparam, 'N', 1 },
5778 { WM_KEYDOWN, sent|wparam|lparam, 'N', 1 },
5779 { WM_CHAR, wparam|lparam, 'n', 1 },
5780 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1002,1), 0 },
5781 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xc0000001 }, /* XP */
5782 { WM_KEYUP, wparam|lparam, 'N', 0xc0000001 },
5783 { WM_KEYUP, sent|wparam|lparam, 'N', 0xc0000001 },
5784 { 0 }
5786 static const struct message WmShiftVkN[] = {
5787 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_SHIFT, 1 }, /* XP */
5788 { WM_KEYDOWN, wparam|lparam, VK_SHIFT, 1 },
5789 { WM_KEYDOWN, sent|wparam|lparam, VK_SHIFT, 1 },
5790 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 1 }, /* XP */
5791 { WM_KEYDOWN, wparam|lparam, 'N', 1 },
5792 { WM_KEYDOWN, sent|wparam|lparam, 'N', 1 },
5793 { WM_CHAR, wparam|lparam, 'N', 1 },
5794 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1001,1), 0 },
5795 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xc0000001 }, /* XP */
5796 { WM_KEYUP, wparam|lparam, 'N', 0xc0000001 },
5797 { WM_KEYUP, sent|wparam|lparam, 'N', 0xc0000001 },
5798 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_SHIFT, 0xc0000001 }, /* XP */
5799 { WM_KEYUP, wparam|lparam, VK_SHIFT, 0xc0000001 },
5800 { WM_KEYUP, sent|wparam|lparam, VK_SHIFT, 0xc0000001 },
5801 { 0 }
5803 static const struct message WmCtrlVkN[] = {
5804 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 1 }, /* XP */
5805 { WM_KEYDOWN, wparam|lparam, VK_CONTROL, 1 },
5806 { WM_KEYDOWN, sent|wparam|lparam, VK_CONTROL, 1 },
5807 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 1 }, /* XP */
5808 { WM_KEYDOWN, wparam|lparam, 'N', 1 },
5809 { WM_KEYDOWN, sent|wparam|lparam, 'N', 1 },
5810 { WM_CHAR, wparam|lparam, 0x000e, 1 },
5811 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1000,1), 0 },
5812 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xc0000001 }, /* XP */
5813 { WM_KEYUP, wparam|lparam, 'N', 0xc0000001 },
5814 { WM_KEYUP, sent|wparam|lparam, 'N', 0xc0000001 },
5815 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 0xc0000001 }, /* XP */
5816 { WM_KEYUP, wparam|lparam, VK_CONTROL, 0xc0000001 },
5817 { WM_KEYUP, sent|wparam|lparam, VK_CONTROL, 0xc0000001 },
5818 { 0 }
5820 static const struct message WmCtrlVkN_2[] = {
5821 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 1 }, /* XP */
5822 { WM_KEYDOWN, wparam|lparam, VK_CONTROL, 1 },
5823 { WM_KEYDOWN, sent|wparam|lparam, VK_CONTROL, 1 },
5824 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 1 }, /* XP */
5825 { WM_KEYDOWN, wparam|lparam, 'N', 1 },
5826 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1000,1), 0 },
5827 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xc0000001 }, /* XP */
5828 { WM_KEYUP, wparam|lparam, 'N', 0xc0000001 },
5829 { WM_KEYUP, sent|wparam|lparam, 'N', 0xc0000001 },
5830 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 0xc0000001 }, /* XP */
5831 { WM_KEYUP, wparam|lparam, VK_CONTROL, 0xc0000001 },
5832 { WM_KEYUP, sent|wparam|lparam, VK_CONTROL, 0xc0000001 },
5833 { 0 }
5835 static const struct message WmAltVkN[] = {
5836 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0x20000001 }, /* XP */
5837 { WM_SYSKEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
5838 { WM_SYSKEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
5839 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0x20000001 }, /* XP */
5840 { WM_SYSKEYDOWN, wparam|lparam, 'N', 0x20000001 },
5841 { WM_SYSKEYDOWN, sent|wparam|lparam, 'N', 0x20000001 },
5842 { WM_SYSCHAR, wparam|lparam, 'n', 0x20000001 },
5843 { WM_SYSCHAR, sent|wparam|lparam, 'n', 0x20000001 },
5844 { WM_SYSCOMMAND, sent|defwinproc|wparam|lparam, SC_KEYMENU, 'n' },
5845 { HCBT_SYSCOMMAND, hook },
5846 { WM_ENTERMENULOOP, sent|defwinproc|wparam|lparam, 0, 0 },
5847 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
5848 { 0x00AE, sent|defwinproc|optional }, /* XP */
5849 { WM_GETTEXT, sent|defwinproc|optional }, /* XP */
5850 { WM_INITMENU, sent|defwinproc },
5851 { EVENT_SYSTEM_MENUSTART, winevent_hook|wparam|lparam, OBJID_SYSMENU, 0 },
5852 { WM_MENUCHAR, sent|defwinproc|wparam, MAKEWPARAM('n',MF_SYSMENU) },
5853 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, 0, 0 },
5854 { WM_CAPTURECHANGED, sent|defwinproc },
5855 { WM_MENUSELECT, sent|defwinproc|wparam, MAKEWPARAM(0,0xffff) },
5856 { EVENT_SYSTEM_MENUEND, winevent_hook|wparam|lparam, OBJID_SYSMENU, 0 },
5857 { WM_EXITMENULOOP, sent|defwinproc },
5858 { WM_MENUSELECT, sent|defwinproc|wparam|optional, MAKEWPARAM(0,0xffff) }, /* Win95 bug */
5859 { WM_EXITMENULOOP, sent|defwinproc|optional }, /* Win95 bug */
5860 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xe0000001 }, /* XP */
5861 { WM_SYSKEYUP, wparam|lparam, 'N', 0xe0000001 },
5862 { WM_SYSKEYUP, sent|wparam|lparam, 'N', 0xe0000001 },
5863 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0xc0000001 }, /* XP */
5864 { WM_KEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
5865 { WM_KEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
5866 { 0 }
5868 static const struct message WmAltVkN_2[] = {
5869 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0x20000001 }, /* XP */
5870 { WM_SYSKEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
5871 { WM_SYSKEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
5872 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0x20000001 }, /* XP */
5873 { WM_SYSKEYDOWN, wparam|lparam, 'N', 0x20000001 },
5874 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1003,1), 0 },
5875 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xe0000001 }, /* XP */
5876 { WM_SYSKEYUP, wparam|lparam, 'N', 0xe0000001 },
5877 { WM_SYSKEYUP, sent|wparam|lparam, 'N', 0xe0000001 },
5878 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0xc0000001 }, /* XP */
5879 { WM_KEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
5880 { WM_KEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
5881 { 0 }
5883 static const struct message WmCtrlAltVkN[] = {
5884 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 1 }, /* XP */
5885 { WM_KEYDOWN, wparam|lparam, VK_CONTROL, 1 },
5886 { WM_KEYDOWN, sent|wparam|lparam, VK_CONTROL, 1 },
5887 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0x20000001 }, /* XP */
5888 { WM_KEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
5889 { WM_KEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
5890 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0x20000001 }, /* XP */
5891 { WM_KEYDOWN, wparam|lparam, 'N', 0x20000001 },
5892 { WM_KEYDOWN, sent|wparam|lparam, 'N', 0x20000001 },
5893 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xe0000001 }, /* XP */
5894 { WM_KEYUP, wparam|lparam, 'N', 0xe0000001 },
5895 { WM_KEYUP, sent|wparam|lparam, 'N', 0xe0000001 },
5896 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0xc0000001 }, /* XP */
5897 { WM_KEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
5898 { WM_KEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
5899 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 0xc0000001 }, /* XP */
5900 { WM_KEYUP, wparam|lparam, VK_CONTROL, 0xc0000001 },
5901 { WM_KEYUP, sent|wparam|lparam, VK_CONTROL, 0xc0000001 },
5902 { 0 }
5904 static const struct message WmCtrlShiftVkN[] = {
5905 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 1 }, /* XP */
5906 { WM_KEYDOWN, wparam|lparam, VK_CONTROL, 1 },
5907 { WM_KEYDOWN, sent|wparam|lparam, VK_CONTROL, 1 },
5908 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_SHIFT, 1 }, /* XP */
5909 { WM_KEYDOWN, wparam|lparam, VK_SHIFT, 1 },
5910 { WM_KEYDOWN, sent|wparam|lparam, VK_SHIFT, 1 },
5911 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 1 }, /* XP */
5912 { WM_KEYDOWN, wparam|lparam, 'N', 1 },
5913 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1004,1), 0 },
5914 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xc0000001 }, /* XP */
5915 { WM_KEYUP, wparam|lparam, 'N', 0xc0000001 },
5916 { WM_KEYUP, sent|wparam|lparam, 'N', 0xc0000001 },
5917 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_SHIFT, 0xc0000001 }, /* XP */
5918 { WM_KEYUP, wparam|lparam, VK_SHIFT, 0xc0000001 },
5919 { WM_KEYUP, sent|wparam|lparam, VK_SHIFT, 0xc0000001 },
5920 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 0xc0000001 }, /* XP */
5921 { WM_KEYUP, wparam|lparam, VK_CONTROL, 0xc0000001 },
5922 { WM_KEYUP, sent|wparam|lparam, VK_CONTROL, 0xc0000001 },
5923 { 0 }
5925 static const struct message WmCtrlAltShiftVkN[] = {
5926 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 1 }, /* XP */
5927 { WM_KEYDOWN, wparam|lparam, VK_CONTROL, 1 },
5928 { WM_KEYDOWN, sent|wparam|lparam, VK_CONTROL, 1 },
5929 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0x20000001 }, /* XP */
5930 { WM_KEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
5931 { WM_KEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
5932 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_SHIFT, 0x20000001 }, /* XP */
5933 { WM_KEYDOWN, wparam|lparam, VK_SHIFT, 0x20000001 },
5934 { WM_KEYDOWN, sent|wparam|lparam, VK_SHIFT, 0x20000001 },
5935 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0x20000001 }, /* XP */
5936 { WM_KEYDOWN, wparam|lparam, 'N', 0x20000001 },
5937 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1005,1), 0 },
5938 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xe0000001 }, /* XP */
5939 { WM_KEYUP, wparam|lparam, 'N', 0xe0000001 },
5940 { WM_KEYUP, sent|wparam|lparam, 'N', 0xe0000001 },
5941 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_SHIFT, 0xe0000001 }, /* XP */
5942 { WM_KEYUP, wparam|lparam, VK_SHIFT, 0xe0000001 },
5943 { WM_KEYUP, sent|wparam|lparam, VK_SHIFT, 0xe0000001 },
5944 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0xc0000001 }, /* XP */
5945 { WM_KEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
5946 { WM_KEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
5947 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 0xc0000001 }, /* XP */
5948 { WM_KEYUP, wparam|lparam, VK_CONTROL, 0xc0000001 },
5949 { WM_KEYUP, sent|wparam|lparam, VK_CONTROL, 0xc0000001 },
5950 { 0 }
5952 static const struct message WmAltPressRelease[] = {
5953 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0x20000001 }, /* XP */
5954 { WM_SYSKEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
5955 { WM_SYSKEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
5956 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0xc0000001 }, /* XP */
5957 { WM_SYSKEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
5958 { WM_SYSKEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
5959 { WM_SYSCOMMAND, sent|defwinproc|wparam|lparam, SC_KEYMENU, 0 },
5960 { HCBT_SYSCOMMAND, hook },
5961 { WM_ENTERMENULOOP, sent|defwinproc|wparam|lparam, 0, 0 },
5962 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
5963 { WM_INITMENU, sent|defwinproc },
5964 { EVENT_SYSTEM_MENUSTART, winevent_hook|wparam|lparam, OBJID_SYSMENU, 0 },
5965 { WM_MENUSELECT, sent|defwinproc|wparam, MAKEWPARAM(0,MF_SYSMENU|MF_POPUP|MF_HILITE) },
5966 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_SYSMENU, 1 },
5968 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0x30000001 }, /* XP */
5970 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_SYSMENU, 0 },
5971 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, 0, 0, },
5972 { WM_CAPTURECHANGED, sent|defwinproc },
5973 { WM_MENUSELECT, sent|defwinproc|wparam|optional, MAKEWPARAM(0,0xffff) },
5974 { EVENT_SYSTEM_MENUEND, winevent_hook|wparam|lparam, OBJID_SYSMENU, 0 },
5975 { WM_EXITMENULOOP, sent|defwinproc },
5976 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0xc0000001 }, /* XP */
5977 { WM_SYSKEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
5978 { WM_SYSKEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
5979 { 0 }
5981 static const struct message WmAltMouseButton[] = {
5982 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0x20000001 }, /* XP */
5983 { WM_SYSKEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
5984 { WM_SYSKEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
5985 { WM_MOUSEMOVE, wparam|optional, 0, 0 },
5986 { WM_MOUSEMOVE, sent|wparam|optional, 0, 0 },
5987 { WM_LBUTTONDOWN, wparam, MK_LBUTTON, 0 },
5988 { WM_LBUTTONDOWN, sent|wparam, MK_LBUTTON, 0 },
5989 { WM_LBUTTONUP, wparam, 0, 0 },
5990 { WM_LBUTTONUP, sent|wparam, 0, 0 },
5991 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0xc0000001 }, /* XP */
5992 { WM_SYSKEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
5993 { WM_SYSKEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
5994 { 0 }
5996 static const struct message WmF1Seq[] = {
5997 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_F1, 1 }, /* XP */
5998 { WM_KEYDOWN, wparam|lparam, VK_F1, 1 },
5999 { WM_KEYDOWN, sent|wparam|lparam, VK_F1, 0x00000001 },
6000 { WM_KEYF1, wparam|lparam, 0, 0 },
6001 { WM_KEYF1, sent|wparam|lparam, 0, 0 },
6002 { WM_HELP, sent|defwinproc },
6003 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_F1, 0xc0000001 }, /* XP */
6004 { WM_KEYUP, wparam|lparam, VK_F1, 0xc0000001 },
6005 { WM_KEYUP, sent|wparam|lparam, VK_F1, 0xc0000001 },
6006 { 0 }
6008 static const struct message WmVkAppsSeq[] = {
6009 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_APPS, 1 }, /* XP */
6010 { WM_KEYDOWN, wparam|lparam, VK_APPS, 1 },
6011 { WM_KEYDOWN, sent|wparam|lparam, VK_APPS, 0x00000001 },
6012 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_APPS, 0xc0000001 }, /* XP */
6013 { WM_KEYUP, wparam|lparam, VK_APPS, 0xc0000001 },
6014 { WM_KEYUP, sent|wparam|lparam, VK_APPS, 0xc0000001 },
6015 { WM_CONTEXTMENU, lparam, /*hwnd*/0, (LPARAM)-1 },
6016 { WM_CONTEXTMENU, sent|lparam, /*hwnd*/0, (LPARAM)-1 },
6017 { 0 }
6020 static void pump_msg_loop(HWND hwnd, HACCEL hAccel)
6022 MSG msg;
6024 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE))
6026 struct message log_msg;
6028 trace("accel: %p, %04x, %08lx, %08lx\n", msg.hwnd, msg.message, msg.wParam, msg.lParam);
6030 /* ignore some unwanted messages */
6031 if (msg.message == WM_MOUSEMOVE ||
6032 msg.message == WM_GETICON ||
6033 msg.message == WM_DEVICECHANGE)
6034 continue;
6036 log_msg.message = msg.message;
6037 log_msg.flags = wparam|lparam;
6038 log_msg.wParam = msg.wParam;
6039 log_msg.lParam = msg.lParam;
6040 add_message(&log_msg);
6042 if (!hAccel || !TranslateAccelerator(hwnd, hAccel, &msg))
6044 TranslateMessage(&msg);
6045 DispatchMessage(&msg);
6050 static void test_accelerators(void)
6052 RECT rc;
6053 SHORT state;
6054 HACCEL hAccel;
6055 HWND hwnd = CreateWindowExA(0, "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW | WS_VISIBLE,
6056 100, 100, 200, 200, 0, 0, 0, NULL);
6057 BOOL ret;
6059 assert(hwnd != 0);
6060 UpdateWindow(hwnd);
6061 flush_events();
6062 flush_sequence();
6064 SetFocus(hwnd);
6065 ok(GetFocus() == hwnd, "wrong focus window %p\n", GetFocus());
6067 state = GetKeyState(VK_SHIFT);
6068 ok(!(state & 0x8000), "wrong Shift state %04x\n", state);
6069 state = GetKeyState(VK_CAPITAL);
6070 ok(state == 0, "wrong CapsLock state %04x\n", state);
6072 hAccel = LoadAccelerators(GetModuleHandleA(0), MAKEINTRESOURCE(1));
6073 assert(hAccel != 0);
6075 pump_msg_loop(hwnd, 0);
6076 flush_sequence();
6078 trace("testing VK_N press/release\n");
6079 flush_sequence();
6080 keybd_event('N', 0, 0, 0);
6081 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
6082 pump_msg_loop(hwnd, hAccel);
6083 ok_sequence(WmVkN, "VK_N press/release", FALSE);
6085 trace("testing Shift+VK_N press/release\n");
6086 flush_sequence();
6087 keybd_event(VK_SHIFT, 0, 0, 0);
6088 keybd_event('N', 0, 0, 0);
6089 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
6090 keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
6091 pump_msg_loop(hwnd, hAccel);
6092 ok_sequence(WmShiftVkN, "Shift+VK_N press/release", FALSE);
6094 trace("testing Ctrl+VK_N press/release\n");
6095 flush_sequence();
6096 keybd_event(VK_CONTROL, 0, 0, 0);
6097 keybd_event('N', 0, 0, 0);
6098 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
6099 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
6100 pump_msg_loop(hwnd, hAccel);
6101 ok_sequence(WmCtrlVkN, "Ctrl+VK_N press/release", FALSE);
6103 trace("testing Alt+VK_N press/release\n");
6104 flush_sequence();
6105 keybd_event(VK_MENU, 0, 0, 0);
6106 keybd_event('N', 0, 0, 0);
6107 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
6108 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
6109 pump_msg_loop(hwnd, hAccel);
6110 ok_sequence(WmAltVkN, "Alt+VK_N press/release", FALSE);
6112 trace("testing Ctrl+Alt+VK_N press/release 1\n");
6113 flush_sequence();
6114 keybd_event(VK_CONTROL, 0, 0, 0);
6115 keybd_event(VK_MENU, 0, 0, 0);
6116 keybd_event('N', 0, 0, 0);
6117 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
6118 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
6119 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
6120 pump_msg_loop(hwnd, hAccel);
6121 ok_sequence(WmCtrlAltVkN, "Ctrl+Alt+VK_N press/release 1", FALSE);
6123 ret = DestroyAcceleratorTable(hAccel);
6124 ok( ret, "DestroyAcceleratorTable error %d\n", GetLastError());
6126 hAccel = LoadAccelerators(GetModuleHandleA(0), MAKEINTRESOURCE(2));
6127 assert(hAccel != 0);
6129 trace("testing VK_N press/release\n");
6130 flush_sequence();
6131 keybd_event('N', 0, 0, 0);
6132 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
6133 pump_msg_loop(hwnd, hAccel);
6134 ok_sequence(WmVkN, "VK_N press/release", FALSE);
6136 trace("testing Shift+VK_N press/release\n");
6137 flush_sequence();
6138 keybd_event(VK_SHIFT, 0, 0, 0);
6139 keybd_event('N', 0, 0, 0);
6140 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
6141 keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
6142 pump_msg_loop(hwnd, hAccel);
6143 ok_sequence(WmShiftVkN, "Shift+VK_N press/release", FALSE);
6145 trace("testing Ctrl+VK_N press/release 2\n");
6146 flush_sequence();
6147 keybd_event(VK_CONTROL, 0, 0, 0);
6148 keybd_event('N', 0, 0, 0);
6149 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
6150 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
6151 pump_msg_loop(hwnd, hAccel);
6152 ok_sequence(WmCtrlVkN_2, "Ctrl+VK_N press/release 2", FALSE);
6154 trace("testing Alt+VK_N press/release 2\n");
6155 flush_sequence();
6156 keybd_event(VK_MENU, 0, 0, 0);
6157 keybd_event('N', 0, 0, 0);
6158 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
6159 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
6160 pump_msg_loop(hwnd, hAccel);
6161 ok_sequence(WmAltVkN_2, "Alt+VK_N press/release 2", FALSE);
6163 trace("testing Ctrl+Alt+VK_N press/release 2\n");
6164 flush_sequence();
6165 keybd_event(VK_CONTROL, 0, 0, 0);
6166 keybd_event(VK_MENU, 0, 0, 0);
6167 keybd_event('N', 0, 0, 0);
6168 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
6169 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
6170 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
6171 pump_msg_loop(hwnd, hAccel);
6172 ok_sequence(WmCtrlAltVkN, "Ctrl+Alt+VK_N press/release 2", FALSE);
6174 trace("testing Ctrl+Shift+VK_N press/release\n");
6175 flush_sequence();
6176 keybd_event(VK_CONTROL, 0, 0, 0);
6177 keybd_event(VK_SHIFT, 0, 0, 0);
6178 keybd_event('N', 0, 0, 0);
6179 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
6180 keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
6181 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
6182 pump_msg_loop(hwnd, hAccel);
6183 ok_sequence(WmCtrlShiftVkN, "Ctrl+Shift+VK_N press/release", FALSE);
6185 trace("testing Ctrl+Alt+Shift+VK_N press/release\n");
6186 flush_sequence();
6187 keybd_event(VK_CONTROL, 0, 0, 0);
6188 keybd_event(VK_MENU, 0, 0, 0);
6189 keybd_event(VK_SHIFT, 0, 0, 0);
6190 keybd_event('N', 0, 0, 0);
6191 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
6192 keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
6193 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
6194 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
6195 pump_msg_loop(hwnd, hAccel);
6196 ok_sequence(WmCtrlAltShiftVkN, "Ctrl+Alt+Shift+VK_N press/release", FALSE);
6198 ret = DestroyAcceleratorTable(hAccel);
6199 ok( ret, "DestroyAcceleratorTable error %d\n", GetLastError());
6201 trace("testing Alt press/release\n");
6202 flush_sequence();
6203 keybd_event(VK_MENU, 0, 0, 0);
6204 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
6205 keybd_event(VK_MENU, 0, 0, 0);
6206 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
6207 pump_msg_loop(hwnd, 0);
6208 /* this test doesn't pass in Wine for managed windows */
6209 ok_sequence(WmAltPressRelease, "Alt press/release", TRUE);
6211 trace("testing Alt+MouseButton press/release\n");
6212 /* first, move mouse pointer inside of the window client area */
6213 GetClientRect(hwnd, &rc);
6214 MapWindowPoints(hwnd, 0, (LPPOINT)&rc, 2);
6215 rc.left += (rc.right - rc.left)/2;
6216 rc.top += (rc.bottom - rc.top)/2;
6217 SetCursorPos(rc.left, rc.top);
6219 flush_events();
6220 flush_sequence();
6221 keybd_event(VK_MENU, 0, 0, 0);
6222 mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
6223 mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
6224 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
6225 pump_msg_loop(hwnd, 0);
6226 ok_sequence(WmAltMouseButton, "Alt+MouseButton press/release", FALSE);
6228 trace("testing VK_F1 press/release\n");
6229 keybd_event(VK_F1, 0, 0, 0);
6230 keybd_event(VK_F1, 0, KEYEVENTF_KEYUP, 0);
6231 pump_msg_loop(hwnd, 0);
6232 ok_sequence(WmF1Seq, "F1 press/release", FALSE);
6234 trace("testing VK_APPS press/release\n");
6235 keybd_event(VK_APPS, 0, 0, 0);
6236 keybd_event(VK_APPS, 0, KEYEVENTF_KEYUP, 0);
6237 pump_msg_loop(hwnd, 0);
6238 ok_sequence(WmVkAppsSeq, "VK_APPS press/release", FALSE);
6240 DestroyWindow(hwnd);
6243 /************* window procedures ********************/
6245 static LRESULT MsgCheckProc (BOOL unicode, HWND hwnd, UINT message,
6246 WPARAM wParam, LPARAM lParam)
6248 static long defwndproc_counter = 0;
6249 static long beginpaint_counter = 0;
6250 LRESULT ret;
6251 struct message msg;
6253 trace("%p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
6255 /* explicitly ignore WM_GETICON message */
6256 if (message == WM_GETICON) return 0;
6258 switch (message)
6260 case WM_ENABLE:
6262 LONG style = GetWindowLongA(hwnd, GWL_STYLE);
6263 ok((BOOL)wParam == !(style & WS_DISABLED),
6264 "wrong WS_DISABLED state: %ld != %d\n", wParam, !(style & WS_DISABLED));
6265 break;
6268 case WM_CAPTURECHANGED:
6269 if (test_DestroyWindow_flag)
6271 DWORD style = GetWindowLongA(hwnd, GWL_STYLE);
6272 if (style & WS_CHILD)
6273 lParam = GetWindowLongPtrA(hwnd, GWLP_ID);
6274 else if (style & WS_POPUP)
6275 lParam = WND_POPUP_ID;
6276 else
6277 lParam = WND_PARENT_ID;
6279 break;
6281 case WM_NCDESTROY:
6283 HWND capture;
6285 ok(!GetWindow(hwnd, GW_CHILD), "children should be unlinked at this point\n");
6286 capture = GetCapture();
6287 if (capture)
6289 ok(capture == hwnd, "capture should NOT be released at this point (capture %p)\n", capture);
6290 trace("current capture %p, releasing...\n", capture);
6291 ReleaseCapture();
6294 /* fall through */
6295 case WM_DESTROY:
6296 if (pGetAncestor)
6297 ok(pGetAncestor(hwnd, GA_PARENT) != 0, "parent should NOT be unlinked at this point\n");
6298 if (test_DestroyWindow_flag)
6300 DWORD style = GetWindowLongA(hwnd, GWL_STYLE);
6301 if (style & WS_CHILD)
6302 lParam = GetWindowLongPtrA(hwnd, GWLP_ID);
6303 else if (style & WS_POPUP)
6304 lParam = WND_POPUP_ID;
6305 else
6306 lParam = WND_PARENT_ID;
6308 break;
6310 /* test_accelerators() depends on this */
6311 case WM_NCHITTEST:
6312 return HTCLIENT;
6314 /* ignore */
6315 case WM_MOUSEMOVE:
6316 case WM_SETCURSOR:
6317 case WM_DEVICECHANGE:
6318 return 0;
6320 case WM_WINDOWPOSCHANGING:
6321 case WM_WINDOWPOSCHANGED:
6323 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
6325 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
6326 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
6327 winpos->hwnd, winpos->hwndInsertAfter,
6328 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
6329 dump_winpos_flags(winpos->flags);
6331 /* Log only documented flags, win2k uses 0x1000 and 0x2000
6332 * in the high word for internal purposes
6334 wParam = winpos->flags & 0xffff;
6335 /* We are not interested in the flags that don't match under XP and Win9x */
6336 wParam &= ~(SWP_NOZORDER);
6337 break;
6341 msg.message = message;
6342 msg.flags = sent|wparam|lparam;
6343 if (defwndproc_counter) msg.flags |= defwinproc;
6344 if (beginpaint_counter) msg.flags |= beginpaint;
6345 msg.wParam = wParam;
6346 msg.lParam = lParam;
6347 add_message(&msg);
6349 if (message == WM_GETMINMAXINFO && (GetWindowLongA(hwnd, GWL_STYLE) & WS_CHILD))
6351 HWND parent = GetParent(hwnd);
6352 RECT rc;
6353 MINMAXINFO *minmax = (MINMAXINFO *)lParam;
6355 GetClientRect(parent, &rc);
6356 trace("parent %p client size = (%d x %d)\n", parent, rc.right, rc.bottom);
6358 trace("ptReserved = (%d,%d)\n"
6359 "ptMaxSize = (%d,%d)\n"
6360 "ptMaxPosition = (%d,%d)\n"
6361 "ptMinTrackSize = (%d,%d)\n"
6362 "ptMaxTrackSize = (%d,%d)\n",
6363 minmax->ptReserved.x, minmax->ptReserved.y,
6364 minmax->ptMaxSize.x, minmax->ptMaxSize.y,
6365 minmax->ptMaxPosition.x, minmax->ptMaxPosition.y,
6366 minmax->ptMinTrackSize.x, minmax->ptMinTrackSize.y,
6367 minmax->ptMaxTrackSize.x, minmax->ptMaxTrackSize.y);
6369 ok(minmax->ptMaxSize.x == rc.right, "default width of maximized child %d != %d\n",
6370 minmax->ptMaxSize.x, rc.right);
6371 ok(minmax->ptMaxSize.y == rc.bottom, "default height of maximized child %d != %d\n",
6372 minmax->ptMaxSize.y, rc.bottom);
6375 if (message == WM_PAINT)
6377 PAINTSTRUCT ps;
6378 beginpaint_counter++;
6379 BeginPaint( hwnd, &ps );
6380 beginpaint_counter--;
6381 EndPaint( hwnd, &ps );
6382 return 0;
6385 defwndproc_counter++;
6386 ret = unicode ? DefWindowProcW(hwnd, message, wParam, lParam)
6387 : DefWindowProcA(hwnd, message, wParam, lParam);
6388 defwndproc_counter--;
6390 return ret;
6393 static LRESULT WINAPI MsgCheckProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
6395 return MsgCheckProc (FALSE, hwnd, message, wParam, lParam);
6398 static LRESULT WINAPI MsgCheckProcW(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
6400 return MsgCheckProc (TRUE, hwnd, message, wParam, lParam);
6403 static LRESULT WINAPI PopupMsgCheckProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
6405 static long defwndproc_counter = 0;
6406 LRESULT ret;
6407 struct message msg;
6409 trace("popup: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
6411 /* explicitly ignore WM_GETICON message */
6412 if (message == WM_GETICON) return 0;
6414 msg.message = message;
6415 msg.flags = sent|wparam|lparam;
6416 if (defwndproc_counter) msg.flags |= defwinproc;
6417 msg.wParam = wParam;
6418 msg.lParam = lParam;
6419 add_message(&msg);
6421 if (message == WM_CREATE)
6423 DWORD style = GetWindowLongA(hwnd, GWL_STYLE) | WS_VISIBLE;
6424 SetWindowLongA(hwnd, GWL_STYLE, style);
6427 defwndproc_counter++;
6428 ret = DefWindowProcA(hwnd, message, wParam, lParam);
6429 defwndproc_counter--;
6431 return ret;
6434 static LRESULT WINAPI ParentMsgCheckProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
6436 static long defwndproc_counter = 0;
6437 static long beginpaint_counter = 0;
6438 LRESULT ret;
6439 struct message msg;
6440 LPARAM logged_lParam;
6442 trace("parent: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
6444 /* explicitly ignore WM_GETICON message */
6445 if (message == WM_GETICON) return 0;
6447 logged_lParam=lParam;
6448 if (log_all_parent_messages ||
6449 message == WM_PARENTNOTIFY || message == WM_CANCELMODE ||
6450 message == WM_SETFOCUS || message == WM_KILLFOCUS ||
6451 message == WM_ENABLE || message == WM_ENTERIDLE ||
6452 message == WM_DRAWITEM ||
6453 message == WM_IME_SETCONTEXT)
6455 switch (message)
6457 /* ignore */
6458 case WM_NCHITTEST:
6459 return HTCLIENT;
6460 case WM_SETCURSOR:
6461 case WM_MOUSEMOVE:
6462 return 0;
6464 case WM_ERASEBKGND:
6466 RECT rc;
6467 INT ret = GetClipBox((HDC)wParam, &rc);
6469 trace("WM_ERASEBKGND: GetClipBox()=%d, (%d,%d-%d,%d)\n",
6470 ret, rc.left, rc.top, rc.right, rc.bottom);
6471 break;
6474 case WM_WINDOWPOSCHANGING:
6475 case WM_WINDOWPOSCHANGED:
6477 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
6479 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
6480 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
6481 winpos->hwnd, winpos->hwndInsertAfter,
6482 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
6483 dump_winpos_flags(winpos->flags);
6485 /* Log only documented flags, win2k uses 0x1000 and 0x2000
6486 * in the high word for internal purposes
6488 wParam = winpos->flags & 0xffff;
6489 /* We are not interested in the flags that don't match under XP and Win9x */
6490 wParam &= ~(SWP_NOZORDER);
6491 break;
6494 case WM_DRAWITEM:
6496 /* encode DRAWITEMSTRUCT into an LPARAM */
6497 DRAW_ITEM_STRUCT di;
6498 DRAWITEMSTRUCT *dis = (DRAWITEMSTRUCT *)lParam;
6500 trace("WM_DRAWITEM: type %x, ctl_id %x, item_id %x, action %x, state %x\n",
6501 dis->CtlType, dis->CtlID, dis->itemID, dis->itemAction, dis->itemState);
6503 di.u.item.type = dis->CtlType;
6504 di.u.item.ctl_id = dis->CtlID;
6505 di.u.item.item_id = dis->itemID;
6506 di.u.item.action = dis->itemAction;
6507 di.u.item.state = dis->itemState;
6509 logged_lParam = di.u.lp;
6510 break;
6514 msg.message = message;
6515 msg.flags = sent|parent|wparam|lparam;
6516 if (defwndproc_counter) msg.flags |= defwinproc;
6517 if (beginpaint_counter) msg.flags |= beginpaint;
6518 msg.wParam = wParam;
6519 msg.lParam = logged_lParam;
6520 add_message(&msg);
6523 if (message == WM_PAINT)
6525 PAINTSTRUCT ps;
6526 beginpaint_counter++;
6527 BeginPaint( hwnd, &ps );
6528 beginpaint_counter--;
6529 EndPaint( hwnd, &ps );
6530 return 0;
6533 defwndproc_counter++;
6534 ret = DefWindowProcA(hwnd, message, wParam, lParam);
6535 defwndproc_counter--;
6537 return ret;
6540 static LRESULT WINAPI TestDlgProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
6542 static long defwndproc_counter = 0;
6543 LRESULT ret;
6544 struct message msg;
6546 trace("dialog: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
6548 /* explicitly ignore WM_GETICON message */
6549 if (message == WM_GETICON) return 0;
6551 if (test_def_id)
6553 DefDlgProcA(hwnd, DM_SETDEFID, 1, 0);
6554 ret = DefDlgProcA(hwnd, DM_GETDEFID, 0, 0);
6555 if (after_end_dialog)
6556 ok( ret == 0, "DM_GETDEFID should return 0 after EndDialog, got %lx\n", ret );
6557 else
6558 ok(HIWORD(ret) == DC_HASDEFID, "DM_GETDEFID should return DC_HASDEFID, got %lx\n", ret);
6561 switch (message)
6563 case WM_WINDOWPOSCHANGING:
6564 case WM_WINDOWPOSCHANGED:
6566 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
6568 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
6569 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
6570 winpos->hwnd, winpos->hwndInsertAfter,
6571 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
6572 dump_winpos_flags(winpos->flags);
6574 /* Log only documented flags, win2k uses 0x1000 and 0x2000
6575 * in the high word for internal purposes
6577 wParam = winpos->flags & 0xffff;
6578 /* We are not interested in the flags that don't match under XP and Win9x */
6579 wParam &= ~(SWP_NOZORDER);
6580 break;
6584 msg.message = message;
6585 msg.flags = sent|wparam|lparam;
6586 if (defwndproc_counter) msg.flags |= defwinproc;
6587 msg.wParam = wParam;
6588 msg.lParam = lParam;
6589 add_message(&msg);
6591 defwndproc_counter++;
6592 ret = DefDlgProcA(hwnd, message, wParam, lParam);
6593 defwndproc_counter--;
6595 return ret;
6598 static void dump_winpos_flags(UINT flags)
6600 if (!winetest_debug) return;
6602 if (flags & SWP_SHOWWINDOW) printf("|SWP_SHOWWINDOW");
6603 if (flags & SWP_HIDEWINDOW) printf("|SWP_HIDEWINDOW");
6604 if (flags & SWP_NOACTIVATE) printf("|SWP_NOACTIVATE");
6605 if (flags & SWP_FRAMECHANGED) printf("|SWP_FRAMECHANGED");
6606 if (flags & SWP_NOCOPYBITS) printf("|SWP_NOCOPYBITS");
6607 if (flags & SWP_NOOWNERZORDER) printf("|SWP_NOOWNERZORDER");
6608 if (flags & SWP_NOSENDCHANGING) printf("|SWP_NOSENDCHANGING");
6609 if (flags & SWP_DEFERERASE) printf("|SWP_DEFERERASE");
6610 if (flags & SWP_ASYNCWINDOWPOS) printf("|SWP_ASYNCWINDOWPOS");
6611 if (flags & SWP_NOZORDER) printf("|SWP_NOZORDER");
6612 if (flags & SWP_NOREDRAW) printf("|SWP_NOREDRAW");
6613 if (flags & SWP_NOSIZE) printf("|SWP_NOSIZE");
6614 if (flags & SWP_NOMOVE) printf("|SWP_NOMOVE");
6615 if (flags & SWP_NOCLIENTSIZE) printf("|SWP_NOCLIENTSIZE");
6616 if (flags & SWP_NOCLIENTMOVE) printf("|SWP_NOCLIENTMOVE");
6618 #define DUMPED_FLAGS \
6619 (SWP_NOSIZE | \
6620 SWP_NOMOVE | \
6621 SWP_NOZORDER | \
6622 SWP_NOREDRAW | \
6623 SWP_NOACTIVATE | \
6624 SWP_FRAMECHANGED | \
6625 SWP_SHOWWINDOW | \
6626 SWP_HIDEWINDOW | \
6627 SWP_NOCOPYBITS | \
6628 SWP_NOOWNERZORDER | \
6629 SWP_NOSENDCHANGING | \
6630 SWP_DEFERERASE | \
6631 SWP_ASYNCWINDOWPOS | \
6632 SWP_NOCLIENTSIZE | \
6633 SWP_NOCLIENTMOVE)
6635 if(flags & ~DUMPED_FLAGS) printf("|0x%04x", flags & ~DUMPED_FLAGS);
6636 printf("\n");
6637 #undef DUMPED_FLAGS
6640 static LRESULT WINAPI ShowWindowProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
6642 static long defwndproc_counter = 0;
6643 LRESULT ret;
6644 struct message msg;
6646 /* log only specific messages we are interested in */
6647 switch (message)
6649 #if 0 /* probably log these as well */
6650 case WM_ACTIVATE:
6651 case WM_SETFOCUS:
6652 case WM_KILLFOCUS:
6653 #endif
6654 case WM_SHOWWINDOW:
6655 trace("WM_SHOWWINDOW %ld\n", wParam);
6656 break;
6657 case WM_SIZE:
6658 trace("WM_SIZE %ld\n", wParam);
6659 break;
6660 case WM_MOVE:
6661 trace("WM_MOVE\n");
6662 break;
6663 case WM_GETMINMAXINFO:
6664 trace("WM_GETMINMAXINFO\n");
6665 break;
6667 case WM_WINDOWPOSCHANGING:
6668 case WM_WINDOWPOSCHANGED:
6670 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
6672 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
6673 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
6674 winpos->hwnd, winpos->hwndInsertAfter,
6675 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
6676 trace("flags: ");
6677 dump_winpos_flags(winpos->flags);
6679 /* Log only documented flags, win2k uses 0x1000 and 0x2000
6680 * in the high word for internal purposes
6682 wParam = winpos->flags & 0xffff;
6683 /* We are not interested in the flags that don't match under XP and Win9x */
6684 wParam &= ~(SWP_NOZORDER);
6685 break;
6688 default: /* ignore */
6689 /*trace("showwindow: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);*/
6690 return DefWindowProcA(hwnd, message, wParam, lParam);
6693 msg.message = message;
6694 msg.flags = sent|wparam|lparam;
6695 if (defwndproc_counter) msg.flags |= defwinproc;
6696 msg.wParam = wParam;
6697 msg.lParam = lParam;
6698 add_message(&msg);
6700 defwndproc_counter++;
6701 ret = DefWindowProcA(hwnd, message, wParam, lParam);
6702 defwndproc_counter--;
6704 return ret;
6707 static BOOL RegisterWindowClasses(void)
6709 WNDCLASSA cls;
6710 WNDCLASSW clsW;
6712 cls.style = 0;
6713 cls.lpfnWndProc = MsgCheckProcA;
6714 cls.cbClsExtra = 0;
6715 cls.cbWndExtra = 0;
6716 cls.hInstance = GetModuleHandleA(0);
6717 cls.hIcon = 0;
6718 cls.hCursor = LoadCursorA(0, (LPSTR)IDC_ARROW);
6719 cls.hbrBackground = GetStockObject(WHITE_BRUSH);
6720 cls.lpszMenuName = NULL;
6721 cls.lpszClassName = "TestWindowClass";
6722 if(!RegisterClassA(&cls)) return FALSE;
6724 cls.lpfnWndProc = ShowWindowProcA;
6725 cls.lpszClassName = "ShowWindowClass";
6726 if(!RegisterClassA(&cls)) return FALSE;
6728 cls.lpfnWndProc = PopupMsgCheckProcA;
6729 cls.lpszClassName = "TestPopupClass";
6730 if(!RegisterClassA(&cls)) return FALSE;
6732 cls.lpfnWndProc = ParentMsgCheckProcA;
6733 cls.lpszClassName = "TestParentClass";
6734 if(!RegisterClassA(&cls)) return FALSE;
6736 cls.lpfnWndProc = DefWindowProcA;
6737 cls.lpszClassName = "SimpleWindowClass";
6738 if(!RegisterClassA(&cls)) return FALSE;
6740 cls.style = CS_NOCLOSE;
6741 cls.lpszClassName = "NoCloseWindowClass";
6742 if(!RegisterClassA(&cls)) return FALSE;
6744 ok(GetClassInfoA(0, "#32770", &cls), "GetClassInfo failed\n");
6745 cls.style = 0;
6746 cls.hInstance = GetModuleHandleA(0);
6747 cls.hbrBackground = 0;
6748 cls.lpfnWndProc = TestDlgProcA;
6749 cls.lpszClassName = "TestDialogClass";
6750 if(!RegisterClassA(&cls)) return FALSE;
6752 clsW.style = 0;
6753 clsW.lpfnWndProc = MsgCheckProcW;
6754 clsW.cbClsExtra = 0;
6755 clsW.cbWndExtra = 0;
6756 clsW.hInstance = GetModuleHandleW(0);
6757 clsW.hIcon = 0;
6758 clsW.hCursor = LoadCursorW(0, (LPWSTR)IDC_ARROW);
6759 clsW.hbrBackground = GetStockObject(WHITE_BRUSH);
6760 clsW.lpszMenuName = NULL;
6761 clsW.lpszClassName = testWindowClassW;
6762 RegisterClassW(&clsW); /* ignore error, this fails on Win9x */
6764 return TRUE;
6767 static HHOOK hCBT_hook;
6768 static DWORD cbt_hook_thread_id;
6770 static LRESULT CALLBACK cbt_hook_proc(int nCode, WPARAM wParam, LPARAM lParam)
6772 static const char * const CBT_code_name[10] = {
6773 "HCBT_MOVESIZE",
6774 "HCBT_MINMAX",
6775 "HCBT_QS",
6776 "HCBT_CREATEWND",
6777 "HCBT_DESTROYWND",
6778 "HCBT_ACTIVATE",
6779 "HCBT_CLICKSKIPPED",
6780 "HCBT_KEYSKIPPED",
6781 "HCBT_SYSCOMMAND",
6782 "HCBT_SETFOCUS" };
6783 const char *code_name = (nCode >= 0 && nCode <= HCBT_SETFOCUS) ? CBT_code_name[nCode] : "Unknown";
6784 HWND hwnd;
6785 char buf[256];
6787 trace("CBT: %d (%s), %08lx, %08lx\n", nCode, code_name, wParam, lParam);
6789 ok(cbt_hook_thread_id == GetCurrentThreadId(), "we didn't ask for events from other threads\n");
6791 if (nCode == HCBT_CLICKSKIPPED)
6793 /* ignore this event, XP sends it a lot when switching focus between windows */
6794 return CallNextHookEx(hCBT_hook, nCode, wParam, lParam);
6797 if (nCode == HCBT_SYSCOMMAND || nCode == HCBT_KEYSKIPPED)
6799 struct message msg;
6801 msg.message = nCode;
6802 msg.flags = hook|wparam|lparam;
6803 msg.wParam = wParam;
6804 msg.lParam = lParam;
6805 add_message(&msg);
6807 return CallNextHookEx(hCBT_hook, nCode, wParam, lParam);
6810 if (nCode == HCBT_DESTROYWND)
6812 if (test_DestroyWindow_flag)
6814 DWORD style = GetWindowLongA((HWND)wParam, GWL_STYLE);
6815 if (style & WS_CHILD)
6816 lParam = GetWindowLongPtrA((HWND)wParam, GWLP_ID);
6817 else if (style & WS_POPUP)
6818 lParam = WND_POPUP_ID;
6819 else
6820 lParam = WND_PARENT_ID;
6824 /* Log also SetFocus(0) calls */
6825 hwnd = wParam ? (HWND)wParam : (HWND)lParam;
6827 if (GetClassNameA(hwnd, buf, sizeof(buf)))
6829 if (!lstrcmpiA(buf, "TestWindowClass") ||
6830 !lstrcmpiA(buf, "ShowWindowClass") ||
6831 !lstrcmpiA(buf, "TestParentClass") ||
6832 !lstrcmpiA(buf, "TestPopupClass") ||
6833 !lstrcmpiA(buf, "SimpleWindowClass") ||
6834 !lstrcmpiA(buf, "TestDialogClass") ||
6835 !lstrcmpiA(buf, "MDI_frame_class") ||
6836 !lstrcmpiA(buf, "MDI_client_class") ||
6837 !lstrcmpiA(buf, "MDI_child_class") ||
6838 !lstrcmpiA(buf, "my_button_class") ||
6839 !lstrcmpiA(buf, "my_edit_class") ||
6840 !lstrcmpiA(buf, "static") ||
6841 !lstrcmpiA(buf, "ListBox") ||
6842 !lstrcmpiA(buf, "ComboBox") ||
6843 !lstrcmpiA(buf, "MyDialogClass") ||
6844 !lstrcmpiA(buf, "#32770"))
6846 struct message msg;
6848 msg.message = nCode;
6849 msg.flags = hook|wparam|lparam;
6850 msg.wParam = wParam;
6851 msg.lParam = lParam;
6852 add_message(&msg);
6855 return CallNextHookEx(hCBT_hook, nCode, wParam, lParam);
6858 static void CALLBACK win_event_proc(HWINEVENTHOOK hevent,
6859 DWORD event,
6860 HWND hwnd,
6861 LONG object_id,
6862 LONG child_id,
6863 DWORD thread_id,
6864 DWORD event_time)
6866 char buf[256];
6868 trace("WEH:%p,event %08x,hwnd %p,obj %08x,id %08x,thread %08x,time %08x\n",
6869 hevent, event, hwnd, object_id, child_id, thread_id, event_time);
6871 ok(thread_id == GetCurrentThreadId(), "we didn't ask for events from other threads\n");
6873 /* ignore mouse cursor events */
6874 if (object_id == OBJID_CURSOR) return;
6876 if (!hwnd || GetClassNameA(hwnd, buf, sizeof(buf)))
6878 if (!hwnd ||
6879 !lstrcmpiA(buf, "TestWindowClass") ||
6880 !lstrcmpiA(buf, "TestParentClass") ||
6881 !lstrcmpiA(buf, "TestPopupClass") ||
6882 !lstrcmpiA(buf, "SimpleWindowClass") ||
6883 !lstrcmpiA(buf, "TestDialogClass") ||
6884 !lstrcmpiA(buf, "MDI_frame_class") ||
6885 !lstrcmpiA(buf, "MDI_client_class") ||
6886 !lstrcmpiA(buf, "MDI_child_class") ||
6887 !lstrcmpiA(buf, "my_button_class") ||
6888 !lstrcmpiA(buf, "my_edit_class") ||
6889 !lstrcmpiA(buf, "static") ||
6890 !lstrcmpiA(buf, "ListBox") ||
6891 !lstrcmpiA(buf, "ComboBox") ||
6892 !lstrcmpiA(buf, "MyDialogClass") ||
6893 !lstrcmpiA(buf, "#32770"))
6895 struct message msg;
6897 msg.message = event;
6898 msg.flags = winevent_hook|wparam|lparam;
6899 msg.wParam = object_id;
6900 msg.lParam = child_id;
6901 add_message(&msg);
6906 static const WCHAR wszUnicode[] = {'U','n','i','c','o','d','e',0};
6907 static const WCHAR wszAnsi[] = {'U',0};
6909 static LRESULT CALLBACK MsgConversionProcW(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
6911 switch (uMsg)
6913 case CB_FINDSTRINGEXACT:
6914 trace("String: %p\n", (LPCWSTR)lParam);
6915 if (!lstrcmpW((LPCWSTR)lParam, wszUnicode))
6916 return 1;
6917 if (!lstrcmpW((LPCWSTR)lParam, wszAnsi))
6918 return 0;
6919 return -1;
6921 return DefWindowProcW(hwnd, uMsg, wParam, lParam);
6924 static const struct message WmGetTextLengthAfromW[] = {
6925 { WM_GETTEXTLENGTH, sent },
6926 { WM_GETTEXT, sent },
6927 { 0 }
6930 static const WCHAR dummy_window_text[] = {'d','u','m','m','y',' ','t','e','x','t',0};
6932 /* dummy window proc for WM_GETTEXTLENGTH test */
6933 static LRESULT CALLBACK get_text_len_proc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
6935 switch(msg)
6937 case WM_GETTEXTLENGTH:
6938 return lstrlenW(dummy_window_text) + 37; /* some random length */
6939 case WM_GETTEXT:
6940 lstrcpynW( (LPWSTR)lp, dummy_window_text, wp );
6941 return lstrlenW( (LPWSTR)lp );
6942 default:
6943 return DefWindowProcW( hwnd, msg, wp, lp );
6947 static void test_message_conversion(void)
6949 static const WCHAR wszMsgConversionClass[] =
6950 {'M','s','g','C','o','n','v','e','r','s','i','o','n','C','l','a','s','s',0};
6951 WNDCLASSW cls;
6952 LRESULT lRes;
6953 HWND hwnd;
6954 WNDPROC wndproc, newproc;
6955 BOOL ret;
6957 cls.style = 0;
6958 cls.lpfnWndProc = MsgConversionProcW;
6959 cls.cbClsExtra = 0;
6960 cls.cbWndExtra = 0;
6961 cls.hInstance = GetModuleHandleW(NULL);
6962 cls.hIcon = NULL;
6963 cls.hCursor = LoadCursorW(NULL, (LPWSTR)IDC_ARROW);
6964 cls.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1);
6965 cls.lpszMenuName = NULL;
6966 cls.lpszClassName = wszMsgConversionClass;
6967 /* this call will fail on Win9x, but that doesn't matter as this test is
6968 * meaningless on those platforms */
6969 if(!RegisterClassW(&cls)) return;
6971 hwnd = CreateWindowExW(0, wszMsgConversionClass, NULL, WS_OVERLAPPED,
6972 100, 100, 200, 200, 0, 0, 0, NULL);
6973 ok(hwnd != NULL, "Window creation failed\n");
6975 /* {W, A} -> A */
6977 wndproc = (WNDPROC)GetWindowLongPtrA(hwnd, GWLP_WNDPROC);
6978 lRes = CallWindowProcA(wndproc, hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
6979 ok(lRes == 0, "String should have been converted\n");
6980 lRes = CallWindowProcW(wndproc, hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
6981 ok(lRes == 1, "String shouldn't have been converted\n");
6983 /* {W, A} -> W */
6985 wndproc = (WNDPROC)GetWindowLongPtrW(hwnd, GWLP_WNDPROC);
6986 lRes = CallWindowProcA(wndproc, hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
6987 ok(lRes == 1, "String shouldn't have been converted\n");
6988 lRes = CallWindowProcW(wndproc, hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
6989 ok(lRes == 1, "String shouldn't have been converted\n");
6991 /* Synchronous messages */
6993 lRes = SendMessageA(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
6994 ok(lRes == 0, "String should have been converted\n");
6995 lRes = SendMessageW(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
6996 ok(lRes == 1, "String shouldn't have been converted\n");
6998 /* Asynchronous messages */
7000 SetLastError(0);
7001 lRes = PostMessageA(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
7002 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
7003 "PostMessage on sync only message returned %ld, last error %d\n", lRes, GetLastError());
7004 SetLastError(0);
7005 lRes = PostMessageW(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
7006 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
7007 "PostMessage on sync only message returned %ld, last error %d\n", lRes, GetLastError());
7008 SetLastError(0);
7009 lRes = PostThreadMessageA(GetCurrentThreadId(), CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
7010 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
7011 "PosThreadtMessage on sync only message returned %ld, last error %d\n", lRes, GetLastError());
7012 SetLastError(0);
7013 lRes = PostThreadMessageW(GetCurrentThreadId(), CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
7014 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
7015 "PosThreadtMessage on sync only message returned %ld, last error %d\n", lRes, GetLastError());
7016 SetLastError(0);
7017 lRes = SendNotifyMessageA(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
7018 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
7019 "SendNotifyMessage on sync only message returned %ld, last error %d\n", lRes, GetLastError());
7020 SetLastError(0);
7021 lRes = SendNotifyMessageW(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
7022 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
7023 "SendNotifyMessage on sync only message returned %ld, last error %d\n", lRes, GetLastError());
7024 SetLastError(0);
7025 lRes = SendMessageCallbackA(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode, NULL, 0);
7026 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
7027 "SendMessageCallback on sync only message returned %ld, last error %d\n", lRes, GetLastError());
7028 SetLastError(0);
7029 lRes = SendMessageCallbackW(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode, NULL, 0);
7030 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
7031 "SendMessageCallback on sync only message returned %ld, last error %d\n", lRes, GetLastError());
7033 /* Check WM_GETTEXTLENGTH A->W behaviour, whether WM_GETTEXT is also sent or not */
7035 hwnd = CreateWindowW (testWindowClassW, wszUnicode,
7036 WS_OVERLAPPEDWINDOW,
7037 100, 100, 200, 200, 0, 0, 0, NULL);
7038 assert(hwnd);
7039 flush_sequence();
7040 lRes = SendMessageA (hwnd, WM_GETTEXTLENGTH, 0, 0);
7041 ok_sequence(WmGetTextLengthAfromW, "ANSI WM_GETTEXTLENGTH to Unicode window", FALSE);
7042 ok( lRes == WideCharToMultiByte( CP_ACP, 0, wszUnicode, lstrlenW(wszUnicode), NULL, 0, NULL, NULL ),
7043 "got bad length %ld\n", lRes );
7045 flush_sequence();
7046 lRes = CallWindowProcA( (WNDPROC)GetWindowLongPtrA( hwnd, GWLP_WNDPROC ),
7047 hwnd, WM_GETTEXTLENGTH, 0, 0);
7048 ok_sequence(WmGetTextLengthAfromW, "ANSI WM_GETTEXTLENGTH to Unicode window", FALSE);
7049 ok( lRes == WideCharToMultiByte( CP_ACP, 0, wszUnicode, lstrlenW(wszUnicode), NULL, 0, NULL, NULL ),
7050 "got bad length %ld\n", lRes );
7052 wndproc = (WNDPROC)SetWindowLongPtrW( hwnd, GWLP_WNDPROC, (LONG_PTR)get_text_len_proc );
7053 newproc = (WNDPROC)GetWindowLongPtrA( hwnd, GWLP_WNDPROC );
7054 lRes = CallWindowProcA( newproc, hwnd, WM_GETTEXTLENGTH, 0, 0 );
7055 ok( lRes == WideCharToMultiByte( CP_ACP, 0, dummy_window_text, lstrlenW(dummy_window_text),
7056 NULL, 0, NULL, NULL ),
7057 "got bad length %ld\n", lRes );
7059 SetWindowLongPtrW( hwnd, GWLP_WNDPROC, (LONG_PTR)wndproc ); /* restore old wnd proc */
7060 lRes = CallWindowProcA( newproc, hwnd, WM_GETTEXTLENGTH, 0, 0 );
7061 ok( lRes == WideCharToMultiByte( CP_ACP, 0, dummy_window_text, lstrlenW(dummy_window_text),
7062 NULL, 0, NULL, NULL ),
7063 "got bad length %ld\n", lRes );
7065 ret = DestroyWindow(hwnd);
7066 ok( ret, "DestroyWindow() error %d\n", GetLastError());
7069 struct timer_info
7071 HWND hWnd;
7072 HANDLE handles[2];
7073 DWORD id;
7076 static VOID CALLBACK tfunc(HWND hwnd, UINT uMsg, UINT_PTR id, DWORD dwTime)
7080 #define TIMER_ID 0x19
7082 static DWORD WINAPI timer_thread_proc(LPVOID x)
7084 struct timer_info *info = x;
7085 DWORD r;
7087 r = KillTimer(info->hWnd, 0x19);
7088 ok(r,"KillTimer failed in thread\n");
7089 r = SetTimer(info->hWnd,TIMER_ID,10000,tfunc);
7090 ok(r,"SetTimer failed in thread\n");
7091 ok(r==TIMER_ID,"SetTimer id different\n");
7092 r = SetEvent(info->handles[0]);
7093 ok(r,"SetEvent failed in thread\n");
7094 return 0;
7097 static void test_timers(void)
7099 struct timer_info info;
7100 DWORD id;
7102 info.hWnd = CreateWindow ("TestWindowClass", NULL,
7103 WS_OVERLAPPEDWINDOW ,
7104 CW_USEDEFAULT, CW_USEDEFAULT, 300, 300, 0,
7105 NULL, NULL, 0);
7107 info.id = SetTimer(info.hWnd,TIMER_ID,10000,tfunc);
7108 ok(info.id, "SetTimer failed\n");
7109 ok(info.id==TIMER_ID, "SetTimer timer ID different\n");
7110 info.handles[0] = CreateEvent(NULL,0,0,NULL);
7111 info.handles[1] = CreateThread(NULL,0,timer_thread_proc,&info,0,&id);
7113 WaitForMultipleObjects(2, info.handles, FALSE, INFINITE);
7115 WaitForSingleObject(info.handles[1], INFINITE);
7117 CloseHandle(info.handles[0]);
7118 CloseHandle(info.handles[1]);
7120 ok( KillTimer(info.hWnd, TIMER_ID), "KillTimer failed\n");
7122 ok(DestroyWindow(info.hWnd), "failed to destroy window\n");
7125 static int count = 0;
7126 static VOID CALLBACK callback_count(
7127 HWND hwnd,
7128 UINT uMsg,
7129 UINT_PTR idEvent,
7130 DWORD dwTime
7133 count++;
7136 static void test_timers_no_wnd(void)
7138 UINT_PTR id, id2;
7139 MSG msg;
7141 count = 0;
7142 id = SetTimer(NULL, 0, 100, callback_count);
7143 ok(id != 0, "did not get id from SetTimer.\n");
7144 id2 = SetTimer(NULL, id, 200, callback_count);
7145 ok(id2 == id, "did not get same id from SetTimer when replacing (%li expected %li).\n", id2, id);
7146 Sleep(150);
7147 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
7148 ok(count == 0, "did not get zero count as expected (%i).\n", count);
7149 Sleep(150);
7150 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
7151 ok(count == 1, "did not get one count as expected (%i).\n", count);
7152 KillTimer(NULL, id);
7153 Sleep(250);
7154 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
7155 ok(count == 1, "killing replaced timer did not work (%i).\n", count);
7158 /* Various win events with arbitrary parameters */
7159 static const struct message WmWinEventsSeq[] = {
7160 { EVENT_SYSTEM_SOUND, winevent_hook|wparam|lparam, OBJID_WINDOW, 0 },
7161 { EVENT_SYSTEM_ALERT, winevent_hook|wparam|lparam, OBJID_SYSMENU, 1 },
7162 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, OBJID_TITLEBAR, 2 },
7163 { EVENT_SYSTEM_MENUSTART, winevent_hook|wparam|lparam, OBJID_MENU, 3 },
7164 { EVENT_SYSTEM_MENUEND, winevent_hook|wparam|lparam, OBJID_CLIENT, 4 },
7165 { EVENT_SYSTEM_MENUPOPUPSTART, winevent_hook|wparam|lparam, OBJID_VSCROLL, 5 },
7166 { EVENT_SYSTEM_MENUPOPUPEND, winevent_hook|wparam|lparam, OBJID_HSCROLL, 6 },
7167 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, OBJID_SIZEGRIP, 7 },
7168 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, OBJID_CARET, 8 },
7169 /* our win event hook ignores OBJID_CURSOR events */
7170 /*{ EVENT_SYSTEM_MOVESIZESTART, winevent_hook|wparam|lparam, OBJID_CURSOR, 9 },*/
7171 { EVENT_SYSTEM_MOVESIZEEND, winevent_hook|wparam|lparam, OBJID_ALERT, 10 },
7172 { EVENT_SYSTEM_CONTEXTHELPSTART, winevent_hook|wparam|lparam, OBJID_SOUND, 11 },
7173 { EVENT_SYSTEM_CONTEXTHELPEND, winevent_hook|wparam|lparam, OBJID_QUERYCLASSNAMEIDX, 12 },
7174 { EVENT_SYSTEM_DRAGDROPSTART, winevent_hook|wparam|lparam, OBJID_NATIVEOM, 13 },
7175 { EVENT_SYSTEM_DRAGDROPEND, winevent_hook|wparam|lparam, OBJID_WINDOW, 0 },
7176 { EVENT_SYSTEM_DIALOGSTART, winevent_hook|wparam|lparam, OBJID_SYSMENU, 1 },
7177 { EVENT_SYSTEM_DIALOGEND, winevent_hook|wparam|lparam, OBJID_TITLEBAR, 2 },
7178 { EVENT_SYSTEM_SCROLLINGSTART, winevent_hook|wparam|lparam, OBJID_MENU, 3 },
7179 { EVENT_SYSTEM_SCROLLINGEND, winevent_hook|wparam|lparam, OBJID_CLIENT, 4 },
7180 { EVENT_SYSTEM_SWITCHSTART, winevent_hook|wparam|lparam, OBJID_VSCROLL, 5 },
7181 { EVENT_SYSTEM_SWITCHEND, winevent_hook|wparam|lparam, OBJID_HSCROLL, 6 },
7182 { EVENT_SYSTEM_MINIMIZESTART, winevent_hook|wparam|lparam, OBJID_SIZEGRIP, 7 },
7183 { EVENT_SYSTEM_MINIMIZEEND, winevent_hook|wparam|lparam, OBJID_CARET, 8 },
7184 { 0 }
7186 static const struct message WmWinEventCaretSeq[] = {
7187 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1 */
7188 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1 */
7189 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 2 */
7190 { EVENT_OBJECT_NAMECHANGE, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1 */
7191 { 0 }
7193 static const struct message WmWinEventCaretSeq_2[] = {
7194 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1/2 */
7195 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1/2 */
7196 { EVENT_OBJECT_NAMECHANGE, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1/2 */
7197 { 0 }
7199 static const struct message WmWinEventAlertSeq[] = {
7200 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, OBJID_ALERT, 0 },
7201 { 0 }
7203 static const struct message WmWinEventAlertSeq_2[] = {
7204 /* create window in the thread proc */
7205 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_WINDOW, 2 },
7206 /* our test event */
7207 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, OBJID_ALERT, 2 },
7208 { 0 }
7210 static const struct message WmGlobalHookSeq_1[] = {
7211 /* create window in the thread proc */
7212 { HCBT_CREATEWND, hook|lparam, 0, 2 },
7213 /* our test events */
7214 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_PREVWINDOW, 2 },
7215 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_NEXTWINDOW, 2 },
7216 { 0 }
7218 static const struct message WmGlobalHookSeq_2[] = {
7219 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_NEXTWINDOW, 0 }, /* old local hook */
7220 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_NEXTWINDOW, 2 }, /* new global hook */
7221 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_PREVWINDOW, 0 }, /* old local hook */
7222 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_PREVWINDOW, 2 }, /* new global hook */
7223 { 0 }
7226 static const struct message WmMouseLLHookSeq[] = {
7227 { WM_MOUSEMOVE, hook },
7228 { WM_LBUTTONUP, hook },
7229 { WM_MOUSEMOVE, hook },
7230 { 0 }
7233 static void CALLBACK win_event_global_hook_proc(HWINEVENTHOOK hevent,
7234 DWORD event,
7235 HWND hwnd,
7236 LONG object_id,
7237 LONG child_id,
7238 DWORD thread_id,
7239 DWORD event_time)
7241 char buf[256];
7243 trace("WEH_2:%p,event %08x,hwnd %p,obj %08x,id %08x,thread %08x,time %08x\n",
7244 hevent, event, hwnd, object_id, child_id, thread_id, event_time);
7246 if (GetClassNameA(hwnd, buf, sizeof(buf)))
7248 if (!lstrcmpiA(buf, "TestWindowClass") ||
7249 !lstrcmpiA(buf, "static"))
7251 struct message msg;
7253 msg.message = event;
7254 msg.flags = winevent_hook|wparam|lparam;
7255 msg.wParam = object_id;
7256 msg.lParam = (thread_id == GetCurrentThreadId()) ? child_id : (child_id + 2);
7257 add_message(&msg);
7262 static HHOOK hCBT_global_hook;
7263 static DWORD cbt_global_hook_thread_id;
7265 static LRESULT CALLBACK cbt_global_hook_proc(int nCode, WPARAM wParam, LPARAM lParam)
7267 HWND hwnd;
7268 char buf[256];
7270 trace("CBT_2: %d, %08lx, %08lx\n", nCode, wParam, lParam);
7272 if (nCode == HCBT_SYSCOMMAND)
7274 struct message msg;
7276 msg.message = nCode;
7277 msg.flags = hook|wparam|lparam;
7278 msg.wParam = wParam;
7279 msg.lParam = (cbt_global_hook_thread_id == GetCurrentThreadId()) ? 1 : 2;
7280 add_message(&msg);
7282 return CallNextHookEx(hCBT_global_hook, nCode, wParam, lParam);
7284 /* WH_MOUSE_LL hook */
7285 if (nCode == HC_ACTION)
7287 MSLLHOOKSTRUCT *mhll = (MSLLHOOKSTRUCT *)lParam;
7289 /* we can't test for real mouse events */
7290 if (mhll->flags & LLMHF_INJECTED)
7292 struct message msg;
7294 memset (&msg, 0, sizeof (msg));
7295 msg.message = wParam;
7296 msg.flags = hook;
7297 add_message(&msg);
7299 return CallNextHookEx(hCBT_global_hook, nCode, wParam, lParam);
7302 /* Log also SetFocus(0) calls */
7303 hwnd = wParam ? (HWND)wParam : (HWND)lParam;
7305 if (GetClassNameA(hwnd, buf, sizeof(buf)))
7307 if (!lstrcmpiA(buf, "TestWindowClass") ||
7308 !lstrcmpiA(buf, "static"))
7310 struct message msg;
7312 msg.message = nCode;
7313 msg.flags = hook|wparam|lparam;
7314 msg.wParam = wParam;
7315 msg.lParam = (cbt_global_hook_thread_id == GetCurrentThreadId()) ? 1 : 2;
7316 add_message(&msg);
7319 return CallNextHookEx(hCBT_global_hook, nCode, wParam, lParam);
7322 static DWORD WINAPI win_event_global_thread_proc(void *param)
7324 HWND hwnd;
7325 MSG msg;
7326 HANDLE hevent = *(HANDLE *)param;
7328 assert(pNotifyWinEvent);
7330 hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP, 0,0,0,0,0,0,0, NULL);
7331 assert(hwnd);
7332 trace("created thread window %p\n", hwnd);
7334 *(HWND *)param = hwnd;
7336 flush_sequence();
7337 /* this event should be received only by our new hook proc,
7338 * an old one does not expect an event from another thread.
7340 pNotifyWinEvent(EVENT_OBJECT_LOCATIONCHANGE, hwnd, OBJID_ALERT, 0);
7341 SetEvent(hevent);
7343 while (GetMessage(&msg, 0, 0, 0))
7345 TranslateMessage(&msg);
7346 DispatchMessage(&msg);
7348 return 0;
7351 static DWORD WINAPI cbt_global_hook_thread_proc(void *param)
7353 HWND hwnd;
7354 MSG msg;
7355 HANDLE hevent = *(HANDLE *)param;
7357 flush_sequence();
7358 /* these events should be received only by our new hook proc,
7359 * an old one does not expect an event from another thread.
7362 hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP, 0,0,0,0,0,0,0, NULL);
7363 assert(hwnd);
7364 trace("created thread window %p\n", hwnd);
7366 *(HWND *)param = hwnd;
7368 /* Windows doesn't like when a thread plays games with the focus,
7369 that leads to all kinds of misbehaviours and failures to activate
7370 a window. So, better keep next lines commented out.
7371 SetFocus(0);
7372 SetFocus(hwnd);*/
7374 DefWindowProcA(hwnd, WM_SYSCOMMAND, SC_PREVWINDOW, 0);
7375 DefWindowProcA(hwnd, WM_SYSCOMMAND, SC_NEXTWINDOW, 0);
7377 SetEvent(hevent);
7379 while (GetMessage(&msg, 0, 0, 0))
7381 TranslateMessage(&msg);
7382 DispatchMessage(&msg);
7384 return 0;
7387 static DWORD WINAPI mouse_ll_global_thread_proc(void *param)
7389 HWND hwnd;
7390 MSG msg;
7391 HANDLE hevent = *(HANDLE *)param;
7393 hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP, 0,0,0,0,0,0,0, NULL);
7394 assert(hwnd);
7395 trace("created thread window %p\n", hwnd);
7397 *(HWND *)param = hwnd;
7399 flush_sequence();
7401 /* Windows doesn't like when a thread plays games with the focus,
7402 * that leads to all kinds of misbehaviours and failures to activate
7403 * a window. So, better don't generate a mouse click message below.
7405 mouse_event(MOUSEEVENTF_MOVE, -1, 0, 0, 0);
7406 mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
7407 mouse_event(MOUSEEVENTF_MOVE, 1, 0, 0, 0);
7409 SetEvent(hevent);
7410 while (GetMessage(&msg, 0, 0, 0))
7412 TranslateMessage(&msg);
7413 DispatchMessage(&msg);
7415 return 0;
7418 static void test_winevents(void)
7420 BOOL ret;
7421 MSG msg;
7422 HWND hwnd, hwnd2;
7423 UINT i;
7424 HANDLE hthread, hevent;
7425 DWORD tid;
7426 HWINEVENTHOOK hhook;
7427 const struct message *events = WmWinEventsSeq;
7429 hwnd = CreateWindowExA(0, "TestWindowClass", NULL,
7430 WS_OVERLAPPEDWINDOW,
7431 CW_USEDEFAULT, CW_USEDEFAULT, 300, 300, 0,
7432 NULL, NULL, 0);
7433 assert(hwnd);
7435 /****** start of global hook test *************/
7436 hCBT_global_hook = SetWindowsHookExA(WH_CBT, cbt_global_hook_proc, GetModuleHandleA(0), 0);
7437 if (!hCBT_global_hook)
7439 ok(DestroyWindow(hwnd), "failed to destroy window\n");
7440 skip( "cannot set global hook\n" );
7441 return;
7444 hevent = CreateEventA(NULL, 0, 0, NULL);
7445 assert(hevent);
7446 hwnd2 = (HWND)hevent;
7448 hthread = CreateThread(NULL, 0, cbt_global_hook_thread_proc, &hwnd2, 0, &tid);
7449 ok(hthread != NULL, "CreateThread failed, error %d\n", GetLastError());
7451 ok(WaitForSingleObject(hevent, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
7453 ok_sequence(WmGlobalHookSeq_1, "global hook 1", FALSE);
7455 flush_sequence();
7456 /* this one should be received only by old hook proc */
7457 DefWindowProcA(hwnd, WM_SYSCOMMAND, SC_NEXTWINDOW, 0);
7458 /* this one should be received only by old hook proc */
7459 DefWindowProcA(hwnd, WM_SYSCOMMAND, SC_PREVWINDOW, 0);
7461 ok_sequence(WmGlobalHookSeq_2, "global hook 2", FALSE);
7463 ret = UnhookWindowsHookEx(hCBT_global_hook);
7464 ok( ret, "UnhookWindowsHookEx error %d\n", GetLastError());
7466 PostThreadMessageA(tid, WM_QUIT, 0, 0);
7467 ok(WaitForSingleObject(hthread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
7468 CloseHandle(hthread);
7469 CloseHandle(hevent);
7470 ok(!IsWindow(hwnd2), "window should be destroyed on thread exit\n");
7471 /****** end of global hook test *************/
7473 if (!pSetWinEventHook || !pNotifyWinEvent || !pUnhookWinEvent)
7475 ok(DestroyWindow(hwnd), "failed to destroy window\n");
7476 return;
7479 flush_sequence();
7481 if (0)
7483 /* this test doesn't pass under Win9x */
7484 /* win2k ignores events with hwnd == 0 */
7485 SetLastError(0xdeadbeef);
7486 pNotifyWinEvent(events[0].message, 0, events[0].wParam, events[0].lParam);
7487 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE || /* Win2k */
7488 GetLastError() == 0xdeadbeef, /* Win9x */
7489 "unexpected error %d\n", GetLastError());
7490 ok_sequence(WmEmptySeq, "empty notify winevents", FALSE);
7493 for (i = 0; i < sizeof(WmWinEventsSeq)/sizeof(WmWinEventsSeq[0]); i++)
7494 pNotifyWinEvent(events[i].message, hwnd, events[i].wParam, events[i].lParam);
7496 ok_sequence(WmWinEventsSeq, "notify winevents", FALSE);
7498 /****** start of event filtering test *************/
7499 hhook = (HWINEVENTHOOK)pSetWinEventHook(
7500 EVENT_OBJECT_SHOW, /* 0x8002 */
7501 EVENT_OBJECT_LOCATIONCHANGE, /* 0x800B */
7502 GetModuleHandleA(0), win_event_global_hook_proc,
7503 GetCurrentProcessId(), 0,
7504 WINEVENT_INCONTEXT);
7505 ok(hhook != 0, "SetWinEventHook error %d\n", GetLastError());
7507 hevent = CreateEventA(NULL, 0, 0, NULL);
7508 assert(hevent);
7509 hwnd2 = (HWND)hevent;
7511 hthread = CreateThread(NULL, 0, win_event_global_thread_proc, &hwnd2, 0, &tid);
7512 ok(hthread != NULL, "CreateThread failed, error %d\n", GetLastError());
7514 ok(WaitForSingleObject(hevent, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
7516 ok_sequence(WmWinEventAlertSeq, "alert winevent", FALSE);
7518 flush_sequence();
7519 /* this one should be received only by old hook proc */
7520 pNotifyWinEvent(EVENT_OBJECT_CREATE, hwnd, OBJID_CARET, 0); /* 0x8000 */
7521 pNotifyWinEvent(EVENT_OBJECT_SHOW, hwnd, OBJID_CARET, 0); /* 0x8002 */
7522 /* this one should be received only by old hook proc */
7523 pNotifyWinEvent(EVENT_OBJECT_NAMECHANGE, hwnd, OBJID_CARET, 0); /* 0x800C */
7525 ok_sequence(WmWinEventCaretSeq, "caret winevent", FALSE);
7527 ret = pUnhookWinEvent(hhook);
7528 ok( ret, "UnhookWinEvent error %d\n", GetLastError());
7530 PostThreadMessageA(tid, WM_QUIT, 0, 0);
7531 ok(WaitForSingleObject(hthread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
7532 CloseHandle(hthread);
7533 CloseHandle(hevent);
7534 ok(!IsWindow(hwnd2), "window should be destroyed on thread exit\n");
7535 /****** end of event filtering test *************/
7537 /****** start of out of context event test *************/
7538 hhook = (HWINEVENTHOOK)pSetWinEventHook(
7539 EVENT_MIN, EVENT_MAX,
7540 0, win_event_global_hook_proc,
7541 GetCurrentProcessId(), 0,
7542 WINEVENT_OUTOFCONTEXT);
7543 ok(hhook != 0, "SetWinEventHook error %d\n", GetLastError());
7545 hevent = CreateEventA(NULL, 0, 0, NULL);
7546 assert(hevent);
7547 hwnd2 = (HWND)hevent;
7549 flush_sequence();
7551 hthread = CreateThread(NULL, 0, win_event_global_thread_proc, &hwnd2, 0, &tid);
7552 ok(hthread != NULL, "CreateThread failed, error %d\n", GetLastError());
7554 ok(WaitForSingleObject(hevent, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
7556 ok_sequence(WmEmptySeq, "empty notify winevents", FALSE);
7557 /* process pending winevent messages */
7558 ok(!PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE), "msg queue should be empty\n");
7559 ok_sequence(WmWinEventAlertSeq_2, "alert winevent for out of context proc", FALSE);
7561 flush_sequence();
7562 /* this one should be received only by old hook proc */
7563 pNotifyWinEvent(EVENT_OBJECT_CREATE, hwnd, OBJID_CARET, 0); /* 0x8000 */
7564 pNotifyWinEvent(EVENT_OBJECT_SHOW, hwnd, OBJID_CARET, 0); /* 0x8002 */
7565 /* this one should be received only by old hook proc */
7566 pNotifyWinEvent(EVENT_OBJECT_NAMECHANGE, hwnd, OBJID_CARET, 0); /* 0x800C */
7568 ok_sequence(WmWinEventCaretSeq_2, "caret winevent for incontext proc", FALSE);
7569 /* process pending winevent messages */
7570 ok(!PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE), "msg queue should be empty\n");
7571 ok_sequence(WmWinEventCaretSeq_2, "caret winevent for out of context proc", FALSE);
7573 ret = pUnhookWinEvent(hhook);
7574 ok( ret, "UnhookWinEvent error %d\n", GetLastError());
7576 PostThreadMessageA(tid, WM_QUIT, 0, 0);
7577 ok(WaitForSingleObject(hthread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
7578 CloseHandle(hthread);
7579 CloseHandle(hevent);
7580 ok(!IsWindow(hwnd2), "window should be destroyed on thread exit\n");
7581 /****** end of out of context event test *************/
7583 /****** start of MOUSE_LL hook test *************/
7584 hCBT_global_hook = SetWindowsHookExA(WH_MOUSE_LL, cbt_global_hook_proc, GetModuleHandleA(0), 0);
7585 /* WH_MOUSE_LL is not supported on Win9x platforms */
7586 if (!hCBT_global_hook)
7588 trace("Skipping WH_MOUSE_LL test on this platform\n");
7589 goto skip_mouse_ll_hook_test;
7592 hevent = CreateEventA(NULL, 0, 0, NULL);
7593 assert(hevent);
7594 hwnd2 = (HWND)hevent;
7596 hthread = CreateThread(NULL, 0, mouse_ll_global_thread_proc, &hwnd2, 0, &tid);
7597 ok(hthread != NULL, "CreateThread failed, error %d\n", GetLastError());
7599 while (WaitForSingleObject(hevent, 100) == WAIT_TIMEOUT)
7600 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
7602 ok_sequence(WmMouseLLHookSeq, "MOUSE_LL hook other thread", FALSE);
7603 flush_sequence();
7605 mouse_event(MOUSEEVENTF_MOVE, -1, 0, 0, 0);
7606 mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
7607 mouse_event(MOUSEEVENTF_MOVE, 1, 0, 0, 0);
7609 ok_sequence(WmMouseLLHookSeq, "MOUSE_LL hook same thread", FALSE);
7611 ret = UnhookWindowsHookEx(hCBT_global_hook);
7612 ok( ret, "UnhookWindowsHookEx error %d\n", GetLastError());
7614 PostThreadMessageA(tid, WM_QUIT, 0, 0);
7615 ok(WaitForSingleObject(hthread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
7616 CloseHandle(hthread);
7617 CloseHandle(hevent);
7618 ok(!IsWindow(hwnd2), "window should be destroyed on thread exit\n");
7619 /****** end of MOUSE_LL hook test *************/
7620 skip_mouse_ll_hook_test:
7622 ok(DestroyWindow(hwnd), "failed to destroy window\n");
7625 static void test_set_hook(void)
7627 BOOL ret;
7628 HHOOK hhook;
7629 HWINEVENTHOOK hwinevent_hook;
7631 hhook = SetWindowsHookExA(WH_CBT, cbt_hook_proc, GetModuleHandleA(0), GetCurrentThreadId());
7632 ok(hhook != 0, "local hook does not require hModule set to 0\n");
7633 UnhookWindowsHookEx(hhook);
7635 if (0)
7637 /* this test doesn't pass under Win9x: BUG! */
7638 SetLastError(0xdeadbeef);
7639 hhook = SetWindowsHookExA(WH_CBT, cbt_hook_proc, 0, 0);
7640 ok(!hhook, "global hook requires hModule != 0\n");
7641 ok(GetLastError() == ERROR_HOOK_NEEDS_HMOD, "unexpected error %d\n", GetLastError());
7644 SetLastError(0xdeadbeef);
7645 hhook = SetWindowsHookExA(WH_CBT, 0, GetModuleHandleA(0), GetCurrentThreadId());
7646 ok(!hhook, "SetWinEventHook with invalid proc should fail\n");
7647 ok(GetLastError() == ERROR_INVALID_FILTER_PROC || /* Win2k */
7648 GetLastError() == 0xdeadbeef, /* Win9x */
7649 "unexpected error %d\n", GetLastError());
7651 SetLastError(0xdeadbeef);
7652 ok(!UnhookWindowsHookEx((HHOOK)0xdeadbeef), "UnhookWindowsHookEx succeeded\n");
7653 ok(GetLastError() == ERROR_INVALID_HOOK_HANDLE || /* Win2k */
7654 GetLastError() == 0xdeadbeef, /* Win9x */
7655 "unexpected error %d\n", GetLastError());
7657 if (!pSetWinEventHook || !pUnhookWinEvent) return;
7659 /* even process local incontext hooks require hmodule */
7660 SetLastError(0xdeadbeef);
7661 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(EVENT_MIN, EVENT_MAX,
7662 0, win_event_proc, GetCurrentProcessId(), 0, WINEVENT_INCONTEXT);
7663 ok(!hwinevent_hook, "WINEVENT_INCONTEXT requires hModule != 0\n");
7664 ok(GetLastError() == ERROR_HOOK_NEEDS_HMOD || /* Win2k */
7665 GetLastError() == 0xdeadbeef, /* Win9x */
7666 "unexpected error %d\n", GetLastError());
7668 /* even thread local incontext hooks require hmodule */
7669 SetLastError(0xdeadbeef);
7670 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(EVENT_MIN, EVENT_MAX,
7671 0, win_event_proc, GetCurrentProcessId(), GetCurrentThreadId(), WINEVENT_INCONTEXT);
7672 ok(!hwinevent_hook, "WINEVENT_INCONTEXT requires hModule != 0\n");
7673 ok(GetLastError() == ERROR_HOOK_NEEDS_HMOD || /* Win2k */
7674 GetLastError() == 0xdeadbeef, /* Win9x */
7675 "unexpected error %d\n", GetLastError());
7677 if (0)
7679 /* these 3 tests don't pass under Win9x */
7680 SetLastError(0xdeadbeef);
7681 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(1, 0,
7682 0, win_event_proc, GetCurrentProcessId(), 0, WINEVENT_OUTOFCONTEXT);
7683 ok(!hwinevent_hook, "SetWinEventHook with invalid event range should fail\n");
7684 ok(GetLastError() == ERROR_INVALID_HOOK_FILTER, "unexpected error %d\n", GetLastError());
7686 SetLastError(0xdeadbeef);
7687 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(-1, 1,
7688 0, win_event_proc, GetCurrentProcessId(), 0, WINEVENT_OUTOFCONTEXT);
7689 ok(!hwinevent_hook, "SetWinEventHook with invalid event range should fail\n");
7690 ok(GetLastError() == ERROR_INVALID_HOOK_FILTER, "unexpected error %d\n", GetLastError());
7692 SetLastError(0xdeadbeef);
7693 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(EVENT_MIN, EVENT_MAX,
7694 0, win_event_proc, 0, 0xdeadbeef, WINEVENT_OUTOFCONTEXT);
7695 ok(!hwinevent_hook, "SetWinEventHook with invalid tid should fail\n");
7696 ok(GetLastError() == ERROR_INVALID_THREAD_ID, "unexpected error %d\n", GetLastError());
7699 SetLastError(0xdeadbeef);
7700 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(0, 0,
7701 0, win_event_proc, GetCurrentProcessId(), 0, WINEVENT_OUTOFCONTEXT);
7702 ok(hwinevent_hook != 0, "SetWinEventHook error %d\n", GetLastError());
7703 ok(GetLastError() == 0xdeadbeef, "unexpected error %d\n", GetLastError());
7704 ret = pUnhookWinEvent(hwinevent_hook);
7705 ok( ret, "UnhookWinEvent error %d\n", GetLastError());
7707 todo_wine {
7708 /* This call succeeds under win2k SP4, but fails under Wine.
7709 Does win2k test/use passed process id? */
7710 SetLastError(0xdeadbeef);
7711 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(EVENT_MIN, EVENT_MAX,
7712 0, win_event_proc, 0xdeadbeef, 0, WINEVENT_OUTOFCONTEXT);
7713 ok(hwinevent_hook != 0, "SetWinEventHook error %d\n", GetLastError());
7714 ok(GetLastError() == 0xdeadbeef, "unexpected error %d\n", GetLastError());
7715 ret = pUnhookWinEvent(hwinevent_hook);
7716 ok( ret, "UnhookWinEvent error %d\n", GetLastError());
7719 SetLastError(0xdeadbeef);
7720 ok(!pUnhookWinEvent((HWINEVENTHOOK)0xdeadbeef), "UnhookWinEvent succeeded\n");
7721 ok(GetLastError() == ERROR_INVALID_HANDLE || /* Win2k */
7722 GetLastError() == 0xdeadbeef, /* Win9x */
7723 "unexpected error %d\n", GetLastError());
7726 static const struct message ScrollWindowPaint1[] = {
7727 { WM_PAINT, sent },
7728 { WM_ERASEBKGND, sent|beginpaint },
7729 { 0 }
7732 static const struct message ScrollWindowPaint2[] = {
7733 { WM_PAINT, sent },
7734 { 0 }
7737 static void test_scrollwindowex(void)
7739 HWND hwnd, hchild;
7740 RECT rect={0,0,130,130};
7742 hwnd = CreateWindowExA(0, "TestWindowClass", "Test Scroll",
7743 WS_VISIBLE|WS_OVERLAPPEDWINDOW,
7744 100, 100, 200, 200, 0, 0, 0, NULL);
7745 ok (hwnd != 0, "Failed to create overlapped window\n");
7746 hchild = CreateWindowExA(0, "TestWindowClass", "Test child",
7747 WS_VISIBLE|WS_CAPTION|WS_CHILD,
7748 10, 10, 150, 150, hwnd, 0, 0, NULL);
7749 ok (hchild != 0, "Failed to create child\n");
7750 UpdateWindow(hwnd);
7751 flush_events();
7752 flush_sequence();
7754 /* scroll without the child window */
7755 trace("start scroll\n");
7756 ScrollWindowEx( hwnd, 10, 10, &rect, NULL, NULL, NULL,
7757 SW_ERASE|SW_INVALIDATE);
7758 ok_sequence(WmEmptySeq, "ScrollWindowEx", 0);
7759 trace("end scroll\n");
7760 flush_sequence();
7761 flush_events();
7762 ok_sequence(ScrollWindowPaint1, "ScrollWindowEx", 0);
7763 flush_events();
7764 flush_sequence();
7766 /* Now without the SW_ERASE flag */
7767 trace("start scroll\n");
7768 ScrollWindowEx( hwnd, 10, 10, &rect, NULL, NULL, NULL, SW_INVALIDATE);
7769 ok_sequence(WmEmptySeq, "ScrollWindowEx", 0);
7770 trace("end scroll\n");
7771 flush_sequence();
7772 flush_events();
7773 ok_sequence(ScrollWindowPaint2, "ScrollWindowEx", 0);
7774 flush_events();
7775 flush_sequence();
7777 /* now scroll the child window as well */
7778 trace("start scroll\n");
7779 ScrollWindowEx( hwnd, 10, 10, &rect, NULL, NULL, NULL,
7780 SW_SCROLLCHILDREN|SW_ERASE|SW_INVALIDATE);
7781 todo_wine { /* wine sends WM_POSCHANGING, WM_POSCHANGED messages */
7782 /* windows sometimes a WM_MOVE */
7783 ok_sequence(WmEmptySeq, "ScrollWindowEx", 0);
7785 trace("end scroll\n");
7786 flush_sequence();
7787 flush_events();
7788 ok_sequence(ScrollWindowPaint1, "ScrollWindowEx", 0);
7789 flush_events();
7790 flush_sequence();
7792 /* now scroll with ScrollWindow() */
7793 trace("start scroll with ScrollWindow\n");
7794 ScrollWindow( hwnd, 5, 5, NULL, NULL);
7795 trace("end scroll\n");
7796 flush_sequence();
7797 flush_events();
7798 ok_sequence(ScrollWindowPaint1, "ScrollWindow", 0);
7800 ok(DestroyWindow(hchild), "failed to destroy window\n");
7801 ok(DestroyWindow(hwnd), "failed to destroy window\n");
7802 flush_sequence();
7805 static const struct message destroy_window_with_children[] = {
7806 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 }, /* popup */
7807 { HCBT_DESTROYWND, hook|lparam, 0, WND_PARENT_ID }, /* parent */
7808 { 0x0090, sent|optional },
7809 { HCBT_DESTROYWND, hook|lparam, 0, WND_POPUP_ID }, /* popup */
7810 { 0x0090, sent|optional },
7811 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 }, /* popup */
7812 { WM_DESTROY, sent|wparam|lparam, 0, WND_POPUP_ID }, /* popup */
7813 { WM_CAPTURECHANGED, sent|wparam|lparam, 0, WND_POPUP_ID }, /* popup */
7814 { WM_NCDESTROY, sent|wparam|lparam, 0, WND_POPUP_ID }, /* popup */
7815 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 }, /* parent */
7816 { WM_DESTROY, sent|wparam|lparam, 0, WND_PARENT_ID }, /* parent */
7817 { WM_DESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 2 }, /* child2 */
7818 { WM_DESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 1 }, /* child1 */
7819 { WM_DESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 3 }, /* child3 */
7820 { WM_NCDESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 2 }, /* child2 */
7821 { WM_NCDESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 3 }, /* child3 */
7822 { WM_NCDESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 1 }, /* child1 */
7823 { WM_NCDESTROY, sent|wparam|lparam, 0, WND_PARENT_ID }, /* parent */
7824 { 0 }
7827 static void test_DestroyWindow(void)
7829 BOOL ret;
7830 HWND parent, child1, child2, child3, child4, test;
7831 UINT child_id = WND_CHILD_ID + 1;
7833 parent = CreateWindowExA(0, "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW,
7834 100, 100, 200, 200, 0, 0, 0, NULL);
7835 assert(parent != 0);
7836 child1 = CreateWindowExA(0, "TestWindowClass", NULL, WS_CHILD,
7837 0, 0, 50, 50, parent, (HMENU)child_id++, 0, NULL);
7838 assert(child1 != 0);
7839 child2 = CreateWindowExA(0, "TestWindowClass", NULL, WS_CHILD,
7840 0, 0, 50, 50, GetDesktopWindow(), (HMENU)child_id++, 0, NULL);
7841 assert(child2 != 0);
7842 child3 = CreateWindowExA(0, "TestWindowClass", NULL, WS_CHILD,
7843 0, 0, 50, 50, child1, (HMENU)child_id++, 0, NULL);
7844 assert(child3 != 0);
7845 child4 = CreateWindowExA(0, "TestWindowClass", NULL, WS_POPUP,
7846 0, 0, 50, 50, parent, 0, 0, NULL);
7847 assert(child4 != 0);
7849 /* test owner/parent of child2 */
7850 test = GetParent(child2);
7851 ok(test == GetDesktopWindow(), "wrong parent %p\n", test);
7852 ok(!IsChild(parent, child2), "wrong parent/child %p/%p\n", parent, child2);
7853 if(pGetAncestor) {
7854 test = pGetAncestor(child2, GA_PARENT);
7855 ok(test == GetDesktopWindow(), "wrong parent %p\n", test);
7857 test = GetWindow(child2, GW_OWNER);
7858 ok(!test, "wrong owner %p\n", test);
7860 test = SetParent(child2, parent);
7861 ok(test == GetDesktopWindow(), "wrong old parent %p\n", test);
7863 /* test owner/parent of the parent */
7864 test = GetParent(parent);
7865 ok(!test, "wrong parent %p\n", test);
7866 ok(!IsChild(GetDesktopWindow(), parent), "wrong parent/child %p/%p\n", GetDesktopWindow(), parent);
7867 if(pGetAncestor) {
7868 test = pGetAncestor(parent, GA_PARENT);
7869 ok(test == GetDesktopWindow(), "wrong parent %p\n", test);
7871 test = GetWindow(parent, GW_OWNER);
7872 ok(!test, "wrong owner %p\n", test);
7874 /* test owner/parent of child1 */
7875 test = GetParent(child1);
7876 ok(test == parent, "wrong parent %p\n", test);
7877 ok(IsChild(parent, child1), "wrong parent/child %p/%p\n", parent, child1);
7878 if(pGetAncestor) {
7879 test = pGetAncestor(child1, GA_PARENT);
7880 ok(test == parent, "wrong parent %p\n", test);
7882 test = GetWindow(child1, GW_OWNER);
7883 ok(!test, "wrong owner %p\n", test);
7885 /* test owner/parent of child2 */
7886 test = GetParent(child2);
7887 ok(test == parent, "wrong parent %p\n", test);
7888 ok(IsChild(parent, child2), "wrong parent/child %p/%p\n", parent, child2);
7889 if(pGetAncestor) {
7890 test = pGetAncestor(child2, GA_PARENT);
7891 ok(test == parent, "wrong parent %p\n", test);
7893 test = GetWindow(child2, GW_OWNER);
7894 ok(!test, "wrong owner %p\n", test);
7896 /* test owner/parent of child3 */
7897 test = GetParent(child3);
7898 ok(test == child1, "wrong parent %p\n", test);
7899 ok(IsChild(parent, child3), "wrong parent/child %p/%p\n", parent, child3);
7900 if(pGetAncestor) {
7901 test = pGetAncestor(child3, GA_PARENT);
7902 ok(test == child1, "wrong parent %p\n", test);
7904 test = GetWindow(child3, GW_OWNER);
7905 ok(!test, "wrong owner %p\n", test);
7907 /* test owner/parent of child4 */
7908 test = GetParent(child4);
7909 ok(test == parent, "wrong parent %p\n", test);
7910 ok(!IsChild(parent, child4), "wrong parent/child %p/%p\n", parent, child4);
7911 if(pGetAncestor) {
7912 test = pGetAncestor(child4, GA_PARENT);
7913 ok(test == GetDesktopWindow(), "wrong parent %p\n", test);
7915 test = GetWindow(child4, GW_OWNER);
7916 ok(test == parent, "wrong owner %p\n", test);
7918 flush_sequence();
7920 trace("parent %p, child1 %p, child2 %p, child3 %p, child4 %p\n",
7921 parent, child1, child2, child3, child4);
7923 SetCapture(child4);
7924 test = GetCapture();
7925 ok(test == child4, "wrong capture window %p\n", test);
7927 test_DestroyWindow_flag = TRUE;
7928 ret = DestroyWindow(parent);
7929 ok( ret, "DestroyWindow() error %d\n", GetLastError());
7930 test_DestroyWindow_flag = FALSE;
7931 ok_sequence(destroy_window_with_children, "destroy window with children", 0);
7933 ok(!IsWindow(parent), "parent still exists\n");
7934 ok(!IsWindow(child1), "child1 still exists\n");
7935 ok(!IsWindow(child2), "child2 still exists\n");
7936 ok(!IsWindow(child3), "child3 still exists\n");
7937 ok(!IsWindow(child4), "child4 still exists\n");
7939 test = GetCapture();
7940 ok(!test, "wrong capture window %p\n", test);
7944 static const struct message WmDispatchPaint[] = {
7945 { WM_NCPAINT, sent },
7946 { WM_GETTEXT, sent|defwinproc|optional },
7947 { WM_GETTEXT, sent|defwinproc|optional },
7948 { WM_ERASEBKGND, sent },
7949 { 0 }
7952 static LRESULT WINAPI DispatchMessageCheckProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
7954 if (message == WM_PAINT) return 0;
7955 return MsgCheckProcA( hwnd, message, wParam, lParam );
7958 static void test_DispatchMessage(void)
7960 RECT rect;
7961 MSG msg;
7962 int count;
7963 HWND hwnd = CreateWindowA( "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW,
7964 100, 100, 200, 200, 0, 0, 0, NULL);
7965 ShowWindow( hwnd, SW_SHOW );
7966 UpdateWindow( hwnd );
7967 flush_events();
7968 flush_sequence();
7969 SetWindowLongPtrA( hwnd, GWLP_WNDPROC, (LONG_PTR)DispatchMessageCheckProc );
7971 SetRect( &rect, -5, -5, 5, 5 );
7972 RedrawWindow( hwnd, &rect, 0, RDW_INVALIDATE|RDW_ERASE|RDW_FRAME );
7973 count = 0;
7974 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE ))
7976 if (msg.message != WM_PAINT) DispatchMessage( &msg );
7977 else
7979 flush_sequence();
7980 DispatchMessage( &msg );
7981 /* DispatchMessage will send WM_NCPAINT if non client area is still invalid after WM_PAINT */
7982 if (!count) ok_sequence( WmDispatchPaint, "WmDispatchPaint", FALSE );
7983 else ok_sequence( WmEmptySeq, "WmEmpty", FALSE );
7984 if (++count > 10) break;
7987 ok( msg.message == WM_PAINT && count > 10, "WM_PAINT messages stopped\n" );
7989 trace("now without DispatchMessage\n");
7990 flush_sequence();
7991 RedrawWindow( hwnd, &rect, 0, RDW_INVALIDATE|RDW_ERASE|RDW_FRAME );
7992 count = 0;
7993 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE ))
7995 if (msg.message != WM_PAINT) DispatchMessage( &msg );
7996 else
7998 HRGN hrgn = CreateRectRgn( 0, 0, 0, 0 );
7999 flush_sequence();
8000 /* this will send WM_NCCPAINT just like DispatchMessage does */
8001 GetUpdateRgn( hwnd, hrgn, TRUE );
8002 ok_sequence( WmDispatchPaint, "WmDispatchPaint", FALSE );
8003 DeleteObject( hrgn );
8004 GetClientRect( hwnd, &rect );
8005 ValidateRect( hwnd, &rect ); /* this will stop WM_PAINTs */
8006 ok( !count, "Got multiple WM_PAINTs\n" );
8007 if (++count > 10) break;
8010 DestroyWindow(hwnd);
8014 static const struct message WmUser[] = {
8015 { WM_USER, sent },
8016 { 0 }
8019 struct sendmsg_info
8021 HWND hwnd;
8022 DWORD timeout;
8023 DWORD ret;
8026 static DWORD CALLBACK send_msg_thread( LPVOID arg )
8028 struct sendmsg_info *info = arg;
8029 info->ret = SendMessageTimeoutA( info->hwnd, WM_USER, 0, 0, 0, info->timeout, NULL );
8030 if (!info->ret) ok( GetLastError() == ERROR_TIMEOUT, "unexpected error %d\n", GetLastError());
8031 return 0;
8034 static void wait_for_thread( HANDLE thread )
8036 while (MsgWaitForMultipleObjects(1, &thread, FALSE, INFINITE, QS_SENDMESSAGE) != WAIT_OBJECT_0)
8038 MSG msg;
8039 while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage(&msg);
8043 static LRESULT WINAPI send_msg_delay_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
8045 if (message == WM_USER) Sleep(200);
8046 return MsgCheckProcA( hwnd, message, wParam, lParam );
8049 static void test_SendMessageTimeout(void)
8051 HANDLE thread;
8052 struct sendmsg_info info;
8053 DWORD tid;
8055 info.hwnd = CreateWindowA( "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW,
8056 100, 100, 200, 200, 0, 0, 0, NULL);
8057 flush_events();
8058 flush_sequence();
8060 info.timeout = 1000;
8061 info.ret = 0xdeadbeef;
8062 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid );
8063 wait_for_thread( thread );
8064 CloseHandle( thread );
8065 ok( info.ret == 1, "SendMessageTimeout failed\n" );
8066 ok_sequence( WmUser, "WmUser", FALSE );
8068 info.timeout = 1;
8069 info.ret = 0xdeadbeef;
8070 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid );
8071 Sleep(100); /* SendMessageTimeout should time out here */
8072 wait_for_thread( thread );
8073 CloseHandle( thread );
8074 ok( info.ret == 0, "SendMessageTimeout succeeded\n" );
8075 ok_sequence( WmEmptySeq, "WmEmptySeq", FALSE );
8077 /* 0 means infinite timeout */
8078 info.timeout = 0;
8079 info.ret = 0xdeadbeef;
8080 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid );
8081 Sleep(100);
8082 wait_for_thread( thread );
8083 CloseHandle( thread );
8084 ok( info.ret == 1, "SendMessageTimeout failed\n" );
8085 ok_sequence( WmUser, "WmUser", FALSE );
8087 /* timeout is treated as signed despite the prototype */
8088 info.timeout = 0x7fffffff;
8089 info.ret = 0xdeadbeef;
8090 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid );
8091 Sleep(100);
8092 wait_for_thread( thread );
8093 CloseHandle( thread );
8094 ok( info.ret == 1, "SendMessageTimeout failed\n" );
8095 ok_sequence( WmUser, "WmUser", FALSE );
8097 info.timeout = 0x80000000;
8098 info.ret = 0xdeadbeef;
8099 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid );
8100 Sleep(100);
8101 wait_for_thread( thread );
8102 CloseHandle( thread );
8103 ok( info.ret == 0, "SendMessageTimeout succeeded\n" );
8104 ok_sequence( WmEmptySeq, "WmEmptySeq", FALSE );
8106 /* now check for timeout during message processing */
8107 SetWindowLongPtrA( info.hwnd, GWLP_WNDPROC, (LONG_PTR)send_msg_delay_proc );
8108 info.timeout = 100;
8109 info.ret = 0xdeadbeef;
8110 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid );
8111 wait_for_thread( thread );
8112 CloseHandle( thread );
8113 /* we should time out but still get the message */
8114 ok( info.ret == 0, "SendMessageTimeout failed\n" );
8115 ok_sequence( WmUser, "WmUser", FALSE );
8117 DestroyWindow( info.hwnd );
8121 /****************** edit message test *************************/
8122 #define ID_EDIT 0x1234
8123 static const struct message sl_edit_setfocus[] =
8125 { HCBT_SETFOCUS, hook },
8126 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
8127 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
8128 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
8129 { WM_SETFOCUS, sent|wparam, 0 },
8130 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 10 },
8131 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 15 },
8132 { WM_CTLCOLOREDIT, sent|parent },
8133 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 11 },
8134 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8135 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8136 { WM_COMMAND, sent|parent|wparam, MAKEWPARAM(ID_EDIT, EN_SETFOCUS) },
8137 { 0 }
8139 static const struct message ml_edit_setfocus[] =
8141 { HCBT_SETFOCUS, hook },
8142 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
8143 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
8144 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
8145 { WM_SETFOCUS, sent|wparam, 0 },
8146 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 10 },
8147 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 11 },
8148 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8149 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8150 { WM_COMMAND, sent|parent|wparam, MAKEWPARAM(ID_EDIT, EN_SETFOCUS) },
8151 { 0 }
8153 static const struct message sl_edit_killfocus[] =
8155 { HCBT_SETFOCUS, hook },
8156 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
8157 { WM_KILLFOCUS, sent|wparam, 0 },
8158 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8159 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8160 { WM_COMMAND, sent|parent|wparam, MAKEWPARAM(ID_EDIT, EN_KILLFOCUS) },
8161 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
8162 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 1 },
8163 { 0 }
8165 static const struct message sl_edit_lbutton_dblclk[] =
8167 { WM_LBUTTONDBLCLK, sent },
8168 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
8169 { 0 }
8171 static const struct message sl_edit_lbutton_down[] =
8173 { WM_LBUTTONDOWN, sent|wparam|lparam, 0, 0 },
8174 { HCBT_SETFOCUS, hook },
8175 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
8176 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
8177 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
8178 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
8179 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 10 },
8180 { WM_CTLCOLOREDIT, sent|parent },
8181 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 11 },
8182 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8183 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8184 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8185 { WM_COMMAND, sent|parent|wparam, MAKEWPARAM(ID_EDIT, EN_SETFOCUS) },
8186 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
8187 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8188 { WM_CTLCOLOREDIT, sent|parent|optional },
8189 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 11 },
8190 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8191 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8192 { 0 }
8194 static const struct message ml_edit_lbutton_down[] =
8196 { WM_LBUTTONDOWN, sent|wparam|lparam, 0, 0 },
8197 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
8198 { HCBT_SETFOCUS, hook },
8199 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
8200 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
8201 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
8202 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
8203 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 10 },
8204 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 11 },
8205 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8206 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8207 { WM_COMMAND, sent|parent|wparam, MAKEWPARAM(ID_EDIT, EN_SETFOCUS) },
8208 { 0 }
8210 static const struct message sl_edit_lbutton_up[] =
8212 { WM_LBUTTONUP, sent|wparam|lparam, 0, 0 },
8213 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8214 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, 0, 0 },
8215 { WM_CAPTURECHANGED, sent|defwinproc },
8216 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8217 { 0 }
8219 static const struct message ml_edit_lbutton_up[] =
8221 { WM_LBUTTONUP, sent|wparam|lparam, 0, 0 },
8222 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, 0, 0 },
8223 { WM_CAPTURECHANGED, sent|defwinproc },
8224 { 0 }
8227 static WNDPROC old_edit_proc;
8229 static LRESULT CALLBACK edit_hook_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
8231 static long defwndproc_counter = 0;
8232 LRESULT ret;
8233 struct message msg;
8235 trace("edit: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
8237 /* explicitly ignore WM_GETICON message */
8238 if (message == WM_GETICON) return 0;
8240 msg.message = message;
8241 msg.flags = sent|wparam|lparam;
8242 if (defwndproc_counter) msg.flags |= defwinproc;
8243 msg.wParam = wParam;
8244 msg.lParam = lParam;
8245 add_message(&msg);
8247 defwndproc_counter++;
8248 ret = CallWindowProcA(old_edit_proc, hwnd, message, wParam, lParam);
8249 defwndproc_counter--;
8251 return ret;
8254 static void subclass_edit(void)
8256 WNDCLASSA cls;
8258 if (!GetClassInfoA(0, "edit", &cls)) assert(0);
8260 old_edit_proc = cls.lpfnWndProc;
8262 cls.hInstance = GetModuleHandle(0);
8263 cls.lpfnWndProc = edit_hook_proc;
8264 cls.lpszClassName = "my_edit_class";
8265 UnregisterClass(cls.lpszClassName, cls.hInstance);
8266 if (!RegisterClassA(&cls)) assert(0);
8269 static void test_edit_messages(void)
8271 HWND hwnd, parent;
8272 DWORD dlg_code;
8274 subclass_edit();
8275 log_all_parent_messages++;
8277 parent = CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
8278 100, 100, 200, 200, 0, 0, 0, NULL);
8279 ok (parent != 0, "Failed to create parent window\n");
8281 /* test single line edit */
8282 hwnd = CreateWindowExA(0, "my_edit_class", "test", WS_CHILD,
8283 0, 0, 80, 20, parent, (HMENU)ID_EDIT, 0, NULL);
8284 ok(hwnd != 0, "Failed to create edit window\n");
8286 dlg_code = SendMessageA(hwnd, WM_GETDLGCODE, 0, 0);
8287 ok(dlg_code == (DLGC_WANTCHARS|DLGC_HASSETSEL|DLGC_WANTARROWS), "wrong dlg_code %08x\n", dlg_code);
8289 ShowWindow(hwnd, SW_SHOW);
8290 UpdateWindow(hwnd);
8291 SetFocus(0);
8292 flush_sequence();
8294 SetFocus(hwnd);
8295 ok_sequence(sl_edit_setfocus, "SetFocus(hwnd) on an edit", FALSE);
8297 SetFocus(0);
8298 ok_sequence(sl_edit_killfocus, "SetFocus(0) on an edit", FALSE);
8300 SetFocus(0);
8301 ReleaseCapture();
8302 flush_sequence();
8304 SendMessageA(hwnd, WM_LBUTTONDBLCLK, 0, 0);
8305 ok_sequence(sl_edit_lbutton_dblclk, "WM_LBUTTONDBLCLK on an edit", FALSE);
8307 SetFocus(0);
8308 ReleaseCapture();
8309 flush_sequence();
8311 SendMessageA(hwnd, WM_LBUTTONDOWN, 0, 0);
8312 ok_sequence(sl_edit_lbutton_down, "WM_LBUTTONDOWN on an edit", FALSE);
8314 SendMessageA(hwnd, WM_LBUTTONUP, 0, 0);
8315 ok_sequence(sl_edit_lbutton_up, "WM_LBUTTONUP on an edit", FALSE);
8317 DestroyWindow(hwnd);
8319 /* test multiline edit */
8320 hwnd = CreateWindowExA(0, "my_edit_class", "test", WS_CHILD | ES_MULTILINE,
8321 0, 0, 80, 20, parent, (HMENU)ID_EDIT, 0, NULL);
8322 ok(hwnd != 0, "Failed to create edit window\n");
8324 dlg_code = SendMessageA(hwnd, WM_GETDLGCODE, 0, 0);
8325 ok(dlg_code == (DLGC_WANTCHARS|DLGC_HASSETSEL|DLGC_WANTARROWS|DLGC_WANTALLKEYS),
8326 "wrong dlg_code %08x\n", dlg_code);
8328 ShowWindow(hwnd, SW_SHOW);
8329 UpdateWindow(hwnd);
8330 SetFocus(0);
8331 flush_sequence();
8333 SetFocus(hwnd);
8334 ok_sequence(ml_edit_setfocus, "SetFocus(hwnd) on multiline edit", FALSE);
8336 SetFocus(0);
8337 ok_sequence(sl_edit_killfocus, "SetFocus(0) on multiline edit", FALSE);
8339 SetFocus(0);
8340 ReleaseCapture();
8341 flush_sequence();
8343 SendMessageA(hwnd, WM_LBUTTONDBLCLK, 0, 0);
8344 ok_sequence(sl_edit_lbutton_dblclk, "WM_LBUTTONDBLCLK on multiline edit", FALSE);
8346 SetFocus(0);
8347 ReleaseCapture();
8348 flush_sequence();
8350 SendMessageA(hwnd, WM_LBUTTONDOWN, 0, 0);
8351 ok_sequence(ml_edit_lbutton_down, "WM_LBUTTONDOWN on multiline edit", FALSE);
8353 SendMessageA(hwnd, WM_LBUTTONUP, 0, 0);
8354 ok_sequence(ml_edit_lbutton_up, "WM_LBUTTONUP on multiline edit", FALSE);
8356 DestroyWindow(hwnd);
8357 DestroyWindow(parent);
8359 log_all_parent_messages--;
8362 /**************************** End of Edit test ******************************/
8364 static const struct message WmKeyDownSkippedSeq[] =
8366 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 1 }, /* XP */
8367 { 0 }
8369 static const struct message WmKeyUpSkippedSeq[] =
8371 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xc0000001 }, /* XP */
8372 { 0 }
8375 #define EV_START_STOP 0
8376 #define EV_SENDMSG 1
8377 #define EV_ACK 2
8379 struct peekmsg_info
8381 HWND hwnd;
8382 HANDLE hevent[3]; /* 0 - start/stop, 1 - SendMessage, 2 - ack */
8385 static DWORD CALLBACK send_msg_thread_2(void *param)
8387 DWORD ret;
8388 struct peekmsg_info *info = param;
8390 trace("thread: waiting for start\n");
8391 WaitForSingleObject(info->hevent[EV_START_STOP], INFINITE);
8392 trace("thread: looping\n");
8394 while (1)
8396 ret = WaitForMultipleObjects(2, info->hevent, FALSE, INFINITE);
8398 switch (ret)
8400 case WAIT_OBJECT_0 + EV_START_STOP:
8401 trace("thread: exiting\n");
8402 return 0;
8404 case WAIT_OBJECT_0 + EV_SENDMSG:
8405 trace("thread: sending message\n");
8406 SendNotifyMessageA(info->hwnd, WM_USER, 0, 0);
8407 SetEvent(info->hevent[EV_ACK]);
8408 break;
8410 default:
8411 trace("unexpected return: %04x\n", ret);
8412 assert(0);
8413 break;
8416 return 0;
8419 static void test_PeekMessage(void)
8421 MSG msg;
8422 HANDLE hthread;
8423 DWORD tid, qstatus;
8424 UINT qs_all_input = QS_ALLINPUT;
8425 UINT qs_input = QS_INPUT;
8426 BOOL ret;
8427 struct peekmsg_info info;
8429 info.hwnd = CreateWindowA("TestWindowClass", NULL, WS_OVERLAPPEDWINDOW,
8430 100, 100, 200, 200, 0, 0, 0, NULL);
8431 assert(info.hwnd);
8432 ShowWindow(info.hwnd, SW_SHOW);
8433 UpdateWindow(info.hwnd);
8434 SetFocus(info.hwnd);
8436 info.hevent[EV_START_STOP] = CreateEventA(NULL, 0, 0, NULL);
8437 info.hevent[EV_SENDMSG] = CreateEventA(NULL, 0, 0, NULL);
8438 info.hevent[EV_ACK] = CreateEventA(NULL, 0, 0, NULL);
8440 hthread = CreateThread(NULL, 0, send_msg_thread_2, &info, 0, &tid);
8441 Sleep(100);
8443 trace("signalling to start looping\n");
8444 SetEvent(info.hevent[EV_START_STOP]);
8446 flush_events();
8447 flush_sequence();
8449 SetLastError(0xdeadbeef);
8450 qstatus = GetQueueStatus(qs_all_input);
8451 if (GetLastError() == ERROR_INVALID_FLAGS)
8453 trace("QS_RAWINPUT not supported on this platform\n");
8454 qs_all_input &= ~QS_RAWINPUT;
8455 qs_input &= ~QS_RAWINPUT;
8457 ok(qstatus == 0, "wrong qstatus %08x\n", qstatus);
8459 trace("signalling to send message\n");
8460 SetEvent(info.hevent[EV_SENDMSG]);
8461 WaitForSingleObject(info.hevent[EV_ACK], INFINITE);
8463 /* pass invalid QS_xxxx flags */
8464 SetLastError(0xdeadbeef);
8465 qstatus = GetQueueStatus(0xffffffff);
8466 ok(qstatus == 0, "GetQueueStatus should fail: %08x\n", qstatus);
8467 ok(GetLastError() == ERROR_INVALID_FLAGS, "wrong error %d\n", GetLastError());
8469 qstatus = GetQueueStatus(qs_all_input);
8470 ok(qstatus == MAKELONG(QS_SENDMESSAGE, QS_SENDMESSAGE),
8471 "wrong qstatus %08x\n", qstatus);
8473 msg.message = 0;
8474 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE);
8475 ok(!ret,
8476 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8477 msg.message);
8478 ok_sequence(WmUser, "WmUser", FALSE);
8480 qstatus = GetQueueStatus(qs_all_input);
8481 ok(qstatus == 0, "wrong qstatus %08x\n", qstatus);
8483 keybd_event('N', 0, 0, 0);
8484 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
8485 qstatus = GetQueueStatus(qs_all_input);
8486 ok(qstatus == MAKELONG(QS_KEY, QS_KEY),
8487 "wrong qstatus %08x\n", qstatus);
8489 PostMessageA(info.hwnd, WM_CHAR, 'z', 0);
8490 qstatus = GetQueueStatus(qs_all_input);
8491 ok(qstatus == MAKELONG(QS_POSTMESSAGE, QS_POSTMESSAGE|QS_KEY),
8492 "wrong qstatus %08x\n", qstatus);
8494 InvalidateRect(info.hwnd, NULL, FALSE);
8495 qstatus = GetQueueStatus(qs_all_input);
8496 ok(qstatus == MAKELONG(QS_PAINT, QS_PAINT|QS_POSTMESSAGE|QS_KEY),
8497 "wrong qstatus %08x\n", qstatus);
8499 trace("signalling to send message\n");
8500 SetEvent(info.hevent[EV_SENDMSG]);
8501 WaitForSingleObject(info.hevent[EV_ACK], INFINITE);
8503 qstatus = GetQueueStatus(qs_all_input);
8504 ok(qstatus == MAKELONG(QS_SENDMESSAGE, QS_SENDMESSAGE|QS_PAINT|QS_POSTMESSAGE|QS_KEY),
8505 "wrong qstatus %08x\n", qstatus);
8507 msg.message = 0;
8508 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | (qs_input << 16));
8509 ok(!ret,
8510 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8511 msg.message);
8512 ok_sequence(WmUser, "WmUser", FALSE);
8514 qstatus = GetQueueStatus(qs_all_input);
8515 ok(qstatus == MAKELONG(0, QS_PAINT|QS_POSTMESSAGE|QS_KEY),
8516 "wrong qstatus %08x\n", qstatus);
8518 trace("signalling to send message\n");
8519 SetEvent(info.hevent[EV_SENDMSG]);
8520 WaitForSingleObject(info.hevent[EV_ACK], INFINITE);
8522 qstatus = GetQueueStatus(qs_all_input);
8523 ok(qstatus == MAKELONG(QS_SENDMESSAGE, QS_SENDMESSAGE|QS_PAINT|QS_POSTMESSAGE|QS_KEY),
8524 "wrong qstatus %08x\n", qstatus);
8526 msg.message = 0;
8527 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | PM_QS_POSTMESSAGE);
8528 ok(!ret,
8529 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8530 msg.message);
8531 ok_sequence(WmUser, "WmUser", FALSE);
8533 qstatus = GetQueueStatus(qs_all_input);
8534 ok(qstatus == MAKELONG(0, QS_PAINT|QS_POSTMESSAGE|QS_KEY),
8535 "wrong qstatus %08x\n", qstatus);
8537 msg.message = 0;
8538 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | PM_QS_POSTMESSAGE);
8539 ok(ret && msg.message == WM_CHAR && msg.wParam == 'z',
8540 "got %d and %04x wParam %08lx instead of TRUE and WM_CHAR wParam 'z'\n",
8541 ret, msg.message, msg.wParam);
8542 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
8544 qstatus = GetQueueStatus(qs_all_input);
8545 ok(qstatus == MAKELONG(0, QS_PAINT|QS_KEY),
8546 "wrong qstatus %08x\n", qstatus);
8548 msg.message = 0;
8549 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | PM_QS_POSTMESSAGE);
8550 ok(!ret,
8551 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8552 msg.message);
8553 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
8555 qstatus = GetQueueStatus(qs_all_input);
8556 ok(qstatus == MAKELONG(0, QS_PAINT|QS_KEY),
8557 "wrong qstatus %08x\n", qstatus);
8559 msg.message = 0;
8560 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | PM_QS_PAINT);
8561 ok(ret && msg.message == WM_PAINT,
8562 "got %d and %04x instead of TRUE and WM_PAINT\n", ret, msg.message);
8563 DispatchMessageA(&msg);
8564 ok_sequence(WmPaint, "WmPaint", FALSE);
8566 qstatus = GetQueueStatus(qs_all_input);
8567 ok(qstatus == MAKELONG(0, QS_KEY),
8568 "wrong qstatus %08x\n", qstatus);
8570 msg.message = 0;
8571 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | PM_QS_PAINT);
8572 ok(!ret,
8573 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8574 msg.message);
8575 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
8577 qstatus = GetQueueStatus(qs_all_input);
8578 ok(qstatus == MAKELONG(0, QS_KEY),
8579 "wrong qstatus %08x\n", qstatus);
8581 trace("signalling to send message\n");
8582 SetEvent(info.hevent[EV_SENDMSG]);
8583 WaitForSingleObject(info.hevent[EV_ACK], INFINITE);
8585 qstatus = GetQueueStatus(qs_all_input);
8586 ok(qstatus == MAKELONG(QS_SENDMESSAGE, QS_SENDMESSAGE|QS_KEY),
8587 "wrong qstatus %08x\n", qstatus);
8589 PostMessageA(info.hwnd, WM_CHAR, 'z', 0);
8591 qstatus = GetQueueStatus(qs_all_input);
8592 ok(qstatus == MAKELONG(QS_POSTMESSAGE, QS_SENDMESSAGE|QS_POSTMESSAGE|QS_KEY),
8593 "wrong qstatus %08x\n", qstatus);
8595 msg.message = 0;
8596 ret = PeekMessageA(&msg, 0, WM_CHAR, WM_CHAR, PM_REMOVE);
8597 ok(ret && msg.message == WM_CHAR && msg.wParam == 'z',
8598 "got %d and %04x wParam %08lx instead of TRUE and WM_CHAR wParam 'z'\n",
8599 ret, msg.message, msg.wParam);
8600 ok_sequence(WmUser, "WmUser", FALSE);
8602 qstatus = GetQueueStatus(qs_all_input);
8603 ok(qstatus == MAKELONG(0, QS_KEY),
8604 "wrong qstatus %08x\n", qstatus);
8606 msg.message = 0;
8607 ret = PeekMessageA(&msg, 0, WM_CHAR, WM_CHAR, PM_REMOVE);
8608 ok(!ret,
8609 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8610 msg.message);
8611 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
8613 qstatus = GetQueueStatus(qs_all_input);
8614 ok(qstatus == MAKELONG(0, QS_KEY),
8615 "wrong qstatus %08x\n", qstatus);
8617 PostMessageA(info.hwnd, WM_CHAR, 'z', 0);
8619 qstatus = GetQueueStatus(qs_all_input);
8620 ok(qstatus == MAKELONG(QS_POSTMESSAGE, QS_POSTMESSAGE|QS_KEY),
8621 "wrong qstatus %08x\n", qstatus);
8623 trace("signalling to send message\n");
8624 SetEvent(info.hevent[EV_SENDMSG]);
8625 WaitForSingleObject(info.hevent[EV_ACK], INFINITE);
8627 qstatus = GetQueueStatus(qs_all_input);
8628 ok(qstatus == MAKELONG(QS_SENDMESSAGE, QS_SENDMESSAGE|QS_POSTMESSAGE|QS_KEY),
8629 "wrong qstatus %08x\n", qstatus);
8631 msg.message = 0;
8632 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | (QS_KEY << 16));
8633 ok(!ret,
8634 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8635 msg.message);
8636 ok_sequence(WmUser, "WmUser", FALSE);
8638 qstatus = GetQueueStatus(qs_all_input);
8639 ok(qstatus == MAKELONG(0, QS_POSTMESSAGE|QS_KEY),
8640 "wrong qstatus %08x\n", qstatus);
8642 msg.message = 0;
8643 if (qs_all_input & QS_RAWINPUT) /* use QS_RAWINPUT only if supported */
8644 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | (QS_RAWINPUT << 16));
8645 else /* workaround for a missing QS_RAWINPUT support */
8646 ret = PeekMessageA(&msg, 0, WM_KEYDOWN, WM_KEYDOWN, PM_REMOVE);
8647 ok(ret && msg.message == WM_KEYDOWN && msg.wParam == 'N',
8648 "got %d and %04x wParam %08lx instead of TRUE and WM_KEYDOWN wParam 'N'\n",
8649 ret, msg.message, msg.wParam);
8650 ok_sequence(WmKeyDownSkippedSeq, "WmKeyDownSkippedSeq", FALSE);
8652 qstatus = GetQueueStatus(qs_all_input);
8653 ok(qstatus == MAKELONG(0, QS_POSTMESSAGE|QS_KEY),
8654 "wrong qstatus %08x\n", qstatus);
8656 msg.message = 0;
8657 if (qs_all_input & QS_RAWINPUT) /* use QS_RAWINPUT only if supported */
8658 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | (QS_RAWINPUT << 16));
8659 else /* workaround for a missing QS_RAWINPUT support */
8660 ret = PeekMessageA(&msg, 0, WM_KEYUP, WM_KEYUP, PM_REMOVE);
8661 ok(ret && msg.message == WM_KEYUP && msg.wParam == 'N',
8662 "got %d and %04x wParam %08lx instead of TRUE and WM_KEYUP wParam 'N'\n",
8663 ret, msg.message, msg.wParam);
8664 ok_sequence(WmKeyUpSkippedSeq, "WmKeyUpSkippedSeq", FALSE);
8666 qstatus = GetQueueStatus(qs_all_input);
8667 ok(qstatus == MAKELONG(0, QS_POSTMESSAGE),
8668 "wrong qstatus %08x\n", qstatus);
8670 msg.message = 0;
8671 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | PM_QS_SENDMESSAGE);
8672 ok(!ret,
8673 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8674 msg.message);
8675 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
8677 qstatus = GetQueueStatus(qs_all_input);
8678 ok(qstatus == MAKELONG(0, QS_POSTMESSAGE),
8679 "wrong qstatus %08x\n", qstatus);
8681 msg.message = 0;
8682 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE);
8683 ok(ret && msg.message == WM_CHAR && msg.wParam == 'z',
8684 "got %d and %04x wParam %08lx instead of TRUE and WM_CHAR wParam 'z'\n",
8685 ret, msg.message, msg.wParam);
8686 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
8688 qstatus = GetQueueStatus(qs_all_input);
8689 ok(qstatus == 0,
8690 "wrong qstatus %08x\n", qstatus);
8692 msg.message = 0;
8693 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE);
8694 ok(!ret,
8695 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8696 msg.message);
8697 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
8699 qstatus = GetQueueStatus(qs_all_input);
8700 ok(qstatus == 0,
8701 "wrong qstatus %08x\n", qstatus);
8703 /* test whether presence of the quit flag in the queue affects
8704 * the queue state
8706 PostQuitMessage(0x1234abcd);
8708 qstatus = GetQueueStatus(qs_all_input);
8709 ok(qstatus == MAKELONG(QS_POSTMESSAGE, QS_POSTMESSAGE),
8710 "wrong qstatus %08x\n", qstatus);
8712 PostMessageA(info.hwnd, WM_USER, 0, 0);
8714 qstatus = GetQueueStatus(qs_all_input);
8715 ok(qstatus == MAKELONG(QS_POSTMESSAGE, QS_POSTMESSAGE),
8716 "wrong qstatus %08x\n", qstatus);
8718 msg.message = 0;
8719 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE);
8720 ok(ret && msg.message == WM_USER,
8721 "got %d and %04x instead of TRUE and WM_USER\n", ret, msg.message);
8722 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
8724 qstatus = GetQueueStatus(qs_all_input);
8725 ok(qstatus == MAKELONG(0, QS_POSTMESSAGE),
8726 "wrong qstatus %08x\n", qstatus);
8728 msg.message = 0;
8729 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE);
8730 ok(ret && msg.message == WM_QUIT,
8731 "got %d and %04x instead of TRUE and WM_QUIT\n", ret, msg.message);
8732 ok(msg.wParam == 0x1234abcd, "got wParam %08lx instead of 0x1234abcd\n", msg.wParam);
8733 ok(msg.lParam == 0, "got lParam %08lx instead of 0\n", msg.lParam);
8734 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
8736 qstatus = GetQueueStatus(qs_all_input);
8737 todo_wine {
8738 ok(qstatus == MAKELONG(0, QS_POSTMESSAGE),
8739 "wrong qstatus %08x\n", qstatus);
8742 msg.message = 0;
8743 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE);
8744 ok(!ret,
8745 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8746 msg.message);
8747 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
8749 qstatus = GetQueueStatus(qs_all_input);
8750 ok(qstatus == 0,
8751 "wrong qstatus %08x\n", qstatus);
8753 trace("signalling to exit\n");
8754 SetEvent(info.hevent[EV_START_STOP]);
8756 WaitForSingleObject(hthread, INFINITE);
8758 CloseHandle(hthread);
8759 CloseHandle(info.hevent[0]);
8760 CloseHandle(info.hevent[1]);
8761 CloseHandle(info.hevent[2]);
8763 DestroyWindow(info.hwnd);
8766 static void wait_move_event(HWND hwnd, int x, int y)
8768 MSG msg;
8769 DWORD time;
8770 BOOL ret;
8771 int go = 0;
8773 time = GetTickCount();
8774 while (GetTickCount() - time < 200 && !go) {
8775 ret = PeekMessageA(&msg, hwnd, WM_MOUSEMOVE, WM_MOUSEMOVE, PM_NOREMOVE);
8776 go = ret && msg.pt.x > x && msg.pt.y > y;
8780 #define STEP 20
8781 static void test_PeekMessage2(void)
8783 HWND hwnd;
8784 BOOL ret;
8785 MSG msg;
8786 UINT message;
8787 DWORD time1, time2, time3;
8788 int x1, y1, x2, y2, x3, y3;
8789 POINT pos;
8791 time1 = time2 = time3 = 0;
8792 x1 = y1 = x2 = y2 = x3 = y3 = 0;
8794 /* Initialise window and make sure it is ready for events */
8795 hwnd = CreateWindow("TestWindowClass", "PeekMessage2", WS_OVERLAPPEDWINDOW,
8796 10, 10, 800, 800, NULL, NULL, NULL, NULL);
8797 assert(hwnd);
8798 trace("Window for test_PeekMessage2 %p\n", hwnd);
8799 ShowWindow(hwnd, SW_SHOW);
8800 UpdateWindow(hwnd);
8801 SetFocus(hwnd);
8802 GetCursorPos(&pos);
8803 SetCursorPos(100, 100);
8804 mouse_event(MOUSEEVENTF_MOVE, -STEP, -STEP, 0, 0);
8805 flush_events();
8807 /* Do initial mousemove, wait until we can see it
8808 and then do our test peek with PM_NOREMOVE. */
8809 mouse_event(MOUSEEVENTF_MOVE, STEP, STEP, 0, 0);
8810 wait_move_event(hwnd, 80, 80);
8812 ret = PeekMessageA(&msg, hwnd, WM_MOUSEMOVE, WM_MOUSEMOVE, PM_NOREMOVE);
8813 ok(ret, "no message available\n");
8814 if (ret) {
8815 trace("1st move event: %04x %x %d %d\n", msg.message, msg.time, msg.pt.x, msg.pt.y);
8816 message = msg.message;
8817 time1 = msg.time;
8818 x1 = msg.pt.x;
8819 y1 = msg.pt.y;
8820 ok(message == WM_MOUSEMOVE, "message not WM_MOUSEMOVE, %04x instead\n", message);
8823 /* Allow time to advance a bit, and then simulate the user moving their
8824 * mouse around. After that we peek again with PM_NOREMOVE.
8825 * Although the previous mousemove message was never removed, the
8826 * mousemove we now peek should reflect the recent mouse movements
8827 * because the input queue will merge the move events. */
8828 Sleep(2);
8829 mouse_event(MOUSEEVENTF_MOVE, STEP, STEP, 0, 0);
8830 wait_move_event(hwnd, x1, y1);
8832 ret = PeekMessageA(&msg, hwnd, WM_MOUSEMOVE, WM_MOUSEMOVE, PM_NOREMOVE);
8833 ok(ret, "no message available\n");
8834 if (ret) {
8835 trace("2nd move event: %04x %x %d %d\n", msg.message, msg.time, msg.pt.x, msg.pt.y);
8836 message = msg.message;
8837 time2 = msg.time;
8838 x2 = msg.pt.x;
8839 y2 = msg.pt.y;
8840 ok(message == WM_MOUSEMOVE, "message not WM_MOUSEMOVE, %04x instead\n", message);
8841 ok(time2 > time1, "message time not advanced: %x %x\n", time1, time2);
8842 ok(x2 != x1 && y2 != y1, "coords not changed: (%d %d) (%d %d)\n", x1, y1, x2, y2);
8845 /* Have another go, to drive the point home */
8846 Sleep(2);
8847 mouse_event(MOUSEEVENTF_MOVE, STEP, STEP, 0, 0);
8848 wait_move_event(hwnd, x2, y2);
8850 ret = PeekMessageA(&msg, hwnd, WM_MOUSEMOVE, WM_MOUSEMOVE, PM_NOREMOVE);
8851 ok(ret, "no message available\n");
8852 if (ret) {
8853 trace("3rd move event: %04x %x %d %d\n", msg.message, msg.time, msg.pt.x, msg.pt.y);
8854 message = msg.message;
8855 time3 = msg.time;
8856 x3 = msg.pt.x;
8857 y3 = msg.pt.y;
8858 ok(message == WM_MOUSEMOVE, "message not WM_MOUSEMOVE, %04x instead\n", message);
8859 ok(time3 > time2, "message time not advanced: %x %x\n", time2, time3);
8860 ok(x3 != x2 && y3 != y2, "coords not changed: (%d %d) (%d %d)\n", x2, y2, x3, y3);
8863 DestroyWindow(hwnd);
8864 SetCursorPos(pos.x, pos.y);
8865 flush_events();
8868 static void test_quit_message(void)
8870 MSG msg;
8871 BOOL ret;
8873 /* test using PostQuitMessage */
8874 PostQuitMessage(0xbeef);
8876 ret = PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE);
8877 ok(ret, "PeekMessage failed with error %d\n", GetLastError());
8878 ok(msg.message == WM_QUIT, "Received message 0x%04x instead of WM_QUIT\n", msg.message);
8879 ok(msg.wParam == 0xbeef, "wParam was 0x%lx instead of 0xbeef\n", msg.wParam);
8881 ret = PostThreadMessage(GetCurrentThreadId(), WM_USER, 0, 0);
8882 ok(ret, "PostMessage failed with error %d\n", GetLastError());
8884 ret = GetMessage(&msg, NULL, 0, 0);
8885 ok(ret > 0, "GetMessage failed with error %d\n", GetLastError());
8886 ok(msg.message == WM_USER, "Received message 0x%04x instead of WM_USER\n", msg.message);
8888 /* note: WM_QUIT message received after WM_USER message */
8889 ret = GetMessage(&msg, NULL, 0, 0);
8890 ok(!ret, "GetMessage return %d with error %d instead of FALSE\n", ret, GetLastError());
8891 ok(msg.message == WM_QUIT, "Received message 0x%04x instead of WM_QUIT\n", msg.message);
8892 ok(msg.wParam == 0xbeef, "wParam was 0x%lx instead of 0xbeef\n", msg.wParam);
8894 ret = PeekMessage(&msg, NULL, 0, 0, PM_REMOVE);
8895 ok( !ret || msg.message != WM_QUIT, "Received WM_QUIT again\n" );
8897 /* now test with PostThreadMessage - different behaviour! */
8898 PostThreadMessage(GetCurrentThreadId(), WM_QUIT, 0xdead, 0);
8900 ret = PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE);
8901 ok(ret, "PeekMessage failed with error %d\n", GetLastError());
8902 ok(msg.message == WM_QUIT, "Received message 0x%04x instead of WM_QUIT\n", msg.message);
8903 ok(msg.wParam == 0xdead, "wParam was 0x%lx instead of 0xdead\n", msg.wParam);
8905 ret = PostThreadMessage(GetCurrentThreadId(), WM_USER, 0, 0);
8906 ok(ret, "PostMessage failed with error %d\n", GetLastError());
8908 /* note: we receive the WM_QUIT message first this time */
8909 ret = GetMessage(&msg, NULL, 0, 0);
8910 ok(!ret, "GetMessage return %d with error %d instead of FALSE\n", ret, GetLastError());
8911 ok(msg.message == WM_QUIT, "Received message 0x%04x instead of WM_QUIT\n", msg.message);
8912 ok(msg.wParam == 0xdead, "wParam was 0x%lx instead of 0xdead\n", msg.wParam);
8914 ret = GetMessage(&msg, NULL, 0, 0);
8915 ok(ret > 0, "GetMessage failed with error %d\n", GetLastError());
8916 ok(msg.message == WM_USER, "Received message 0x%04x instead of WM_USER\n", msg.message);
8919 static const struct message WmMouseHoverSeq[] = {
8920 { WM_MOUSEACTIVATE, sent|optional }, /* we can get those when moving the mouse in focus-follow-mouse mode under X11 */
8921 { WM_MOUSEACTIVATE, sent|optional },
8922 { WM_TIMER, sent|optional }, /* XP sends it */
8923 { WM_SYSTIMER, sent },
8924 { WM_MOUSEHOVER, sent|wparam, 0 },
8925 { 0 }
8928 static void pump_msg_loop_timeout(DWORD timeout, BOOL inject_mouse_move)
8930 MSG msg;
8931 DWORD start_ticks, end_ticks;
8933 start_ticks = GetTickCount();
8934 /* add some deviation (5%) to cover not expected delays */
8935 start_ticks += timeout / 20;
8939 while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
8941 /* Timer proc messages are not dispatched to the window proc,
8942 * and therefore not logged.
8944 if (msg.message == WM_TIMER || msg.message == WM_SYSTIMER)
8946 struct message s_msg;
8948 s_msg.message = msg.message;
8949 s_msg.flags = sent|wparam|lparam;
8950 s_msg.wParam = msg.wParam;
8951 s_msg.lParam = msg.lParam;
8952 add_message(&s_msg);
8954 DispatchMessage(&msg);
8957 end_ticks = GetTickCount();
8959 /* inject WM_MOUSEMOVE to see how it changes tracking */
8960 if (inject_mouse_move && start_ticks + timeout / 2 >= end_ticks)
8962 mouse_event(MOUSEEVENTF_MOVE, -1, 0, 0, 0);
8963 mouse_event(MOUSEEVENTF_MOVE, 1, 0, 0, 0);
8965 inject_mouse_move = FALSE;
8967 } while (start_ticks + timeout >= end_ticks);
8970 static void test_TrackMouseEvent(void)
8972 TRACKMOUSEEVENT tme;
8973 BOOL ret;
8974 HWND hwnd, hchild;
8975 RECT rc_parent, rc_child;
8976 UINT default_hover_time, hover_width = 0, hover_height = 0;
8978 #define track_hover(track_hwnd, track_hover_time) \
8979 tme.cbSize = sizeof(tme); \
8980 tme.dwFlags = TME_HOVER; \
8981 tme.hwndTrack = track_hwnd; \
8982 tme.dwHoverTime = track_hover_time; \
8983 SetLastError(0xdeadbeef); \
8984 ret = pTrackMouseEvent(&tme); \
8985 ok(ret, "TrackMouseEvent(TME_HOVER) error %d\n", GetLastError())
8987 #define track_query(expected_track_flags, expected_track_hwnd, expected_hover_time) \
8988 tme.cbSize = sizeof(tme); \
8989 tme.dwFlags = TME_QUERY; \
8990 tme.hwndTrack = (HWND)0xdeadbeef; \
8991 tme.dwHoverTime = 0xdeadbeef; \
8992 SetLastError(0xdeadbeef); \
8993 ret = pTrackMouseEvent(&tme); \
8994 ok(ret, "TrackMouseEvent(TME_QUERY) error %d\n", GetLastError());\
8995 ok(tme.cbSize == sizeof(tme), "wrong tme.cbSize %u\n", tme.cbSize); \
8996 ok(tme.dwFlags == (expected_track_flags), \
8997 "wrong tme.dwFlags %08x, expected %08x\n", tme.dwFlags, (expected_track_flags)); \
8998 ok(tme.hwndTrack == (expected_track_hwnd), \
8999 "wrong tme.hwndTrack %p, expected %p\n", tme.hwndTrack, (expected_track_hwnd)); \
9000 ok(tme.dwHoverTime == (expected_hover_time), \
9001 "wrong tme.dwHoverTime %u, expected %u\n", tme.dwHoverTime, (expected_hover_time))
9003 #define track_hover_cancel(track_hwnd) \
9004 tme.cbSize = sizeof(tme); \
9005 tme.dwFlags = TME_HOVER | TME_CANCEL; \
9006 tme.hwndTrack = track_hwnd; \
9007 tme.dwHoverTime = 0xdeadbeef; \
9008 SetLastError(0xdeadbeef); \
9009 ret = pTrackMouseEvent(&tme); \
9010 ok(ret, "TrackMouseEvent(TME_HOVER | TME_CANCEL) error %d\n", GetLastError())
9012 default_hover_time = 0xdeadbeef;
9013 SetLastError(0xdeadbeef);
9014 ret = SystemParametersInfo(SPI_GETMOUSEHOVERTIME, 0, &default_hover_time, 0);
9015 ok(ret, "SystemParametersInfo(SPI_GETMOUSEHOVERTIME) error %u\n", GetLastError());
9016 if (!ret) default_hover_time = 400;
9017 trace("SPI_GETMOUSEHOVERTIME returned %u ms\n", default_hover_time);
9019 SetLastError(0xdeadbeef);
9020 ret = SystemParametersInfo(SPI_GETMOUSEHOVERWIDTH, 0, &hover_width, 0);
9021 ok(ret, "SystemParametersInfo(SPI_GETMOUSEHOVERWIDTH) error %u\n", GetLastError());
9022 if (!ret) hover_width = 4;
9023 SetLastError(0xdeadbeef);
9024 ret = SystemParametersInfo(SPI_GETMOUSEHOVERHEIGHT, 0, &hover_height, 0);
9025 ok(ret, "SystemParametersInfo(SPI_GETMOUSEHOVERHEIGHT) error %u\n", GetLastError());
9026 if (!ret) hover_height = 4;
9027 trace("hover rect is %u x %d\n", hover_width, hover_height);
9029 hwnd = CreateWindowEx(0, "TestWindowClass", NULL,
9030 WS_OVERLAPPEDWINDOW | WS_VISIBLE,
9031 CW_USEDEFAULT, CW_USEDEFAULT, 300, 300, 0,
9032 NULL, NULL, 0);
9033 assert(hwnd);
9035 hchild = CreateWindowEx(0, "TestWindowClass", NULL,
9036 WS_CHILD | WS_BORDER | WS_VISIBLE,
9037 50, 50, 200, 200, hwnd,
9038 NULL, NULL, 0);
9039 assert(hchild);
9041 flush_events();
9042 flush_sequence();
9044 tme.cbSize = 0;
9045 tme.dwFlags = TME_QUERY;
9046 tme.hwndTrack = (HWND)0xdeadbeef;
9047 tme.dwHoverTime = 0xdeadbeef;
9048 SetLastError(0xdeadbeef);
9049 ret = pTrackMouseEvent(&tme);
9050 ok(!ret, "TrackMouseEvent should fail\n");
9051 ok(GetLastError() == ERROR_INVALID_PARAMETER, "not expected error %d\n", GetLastError());
9053 tme.cbSize = sizeof(tme);
9054 tme.dwFlags = TME_HOVER;
9055 tme.hwndTrack = (HWND)0xdeadbeef;
9056 tme.dwHoverTime = 0xdeadbeef;
9057 SetLastError(0xdeadbeef);
9058 ret = pTrackMouseEvent(&tme);
9059 ok(!ret, "TrackMouseEvent should fail\n");
9060 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "not expected error %d\n", GetLastError());
9062 tme.cbSize = sizeof(tme);
9063 tme.dwFlags = TME_HOVER | TME_CANCEL;
9064 tme.hwndTrack = (HWND)0xdeadbeef;
9065 tme.dwHoverTime = 0xdeadbeef;
9066 SetLastError(0xdeadbeef);
9067 ret = pTrackMouseEvent(&tme);
9068 ok(!ret, "TrackMouseEvent should fail\n");
9069 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "not expected error %d\n", GetLastError());
9071 GetWindowRect(hwnd, &rc_parent);
9072 GetWindowRect(hchild, &rc_child);
9073 SetCursorPos(rc_child.left - 10, rc_child.top - 10);
9075 /* Process messages so that the system updates its internal current
9076 * window and hittest, otherwise TrackMouseEvent calls don't have any
9077 * effect.
9079 flush_events();
9080 flush_sequence();
9082 track_query(0, NULL, 0);
9083 track_hover(hchild, 0);
9084 track_query(0, NULL, 0);
9086 flush_events();
9087 flush_sequence();
9089 track_hover(hwnd, 0);
9090 track_query(TME_HOVER, hwnd, default_hover_time);
9092 pump_msg_loop_timeout(default_hover_time, FALSE);
9093 ok_sequence(WmMouseHoverSeq, "WmMouseHoverSeq", FALSE);
9095 track_query(0, NULL, 0);
9097 track_hover(hwnd, HOVER_DEFAULT);
9098 track_query(TME_HOVER, hwnd, default_hover_time);
9100 Sleep(default_hover_time / 2);
9101 mouse_event(MOUSEEVENTF_MOVE, -1, 0, 0, 0);
9102 mouse_event(MOUSEEVENTF_MOVE, 1, 0, 0, 0);
9104 track_query(TME_HOVER, hwnd, default_hover_time);
9106 pump_msg_loop_timeout(default_hover_time / 2, FALSE);
9107 ok_sequence(WmMouseHoverSeq, "WmMouseHoverSeq", FALSE);
9109 track_query(0, NULL, 0);
9111 track_hover(hwnd, HOVER_DEFAULT);
9112 track_query(TME_HOVER, hwnd, default_hover_time);
9114 pump_msg_loop_timeout(default_hover_time, TRUE);
9115 ok_sequence(WmMouseHoverSeq, "WmMouseHoverSeq", FALSE);
9117 track_query(0, NULL, 0);
9119 track_hover(hwnd, HOVER_DEFAULT);
9120 track_query(TME_HOVER, hwnd, default_hover_time);
9121 track_hover_cancel(hwnd);
9123 DestroyWindow(hwnd);
9125 #undef track_hover
9126 #undef track_query
9127 #undef track_hover_cancel
9131 static const struct message WmSetWindowRgn[] = {
9132 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE },
9133 { WM_NCCALCSIZE, sent|wparam, 1 },
9134 { WM_NCPAINT, sent }, /* wparam != 1 */
9135 { WM_GETTEXT, sent|defwinproc|optional },
9136 { WM_ERASEBKGND, sent|optional }, /* FIXME: remove optional once Wine is fixed */
9137 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE },
9138 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
9139 { 0 }
9142 static const struct message WmSetWindowRgn_no_redraw[] = {
9143 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW },
9144 { WM_NCCALCSIZE, sent|wparam, 1 },
9145 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW },
9146 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
9147 { 0 }
9150 static const struct message WmSetWindowRgn_clear[] = {
9151 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
9152 { WM_NCCALCSIZE, sent|wparam, 1 },
9153 { WM_NCPAINT, sent }, /* wparam != 1 */
9154 { WM_GETTEXT, sent|defwinproc|optional },
9155 { WM_ERASEBKGND, sent|optional }, /* FIXME: remove optional once Wine is fixed */
9156 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE },
9157 { WM_NCCALCSIZE, sent|wparam|optional, 1 },
9158 { WM_NCPAINT, sent|optional }, /* wparam != 1 */
9159 { WM_GETTEXT, sent|defwinproc|optional },
9160 { WM_ERASEBKGND, sent|optional },
9161 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
9162 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
9163 { 0 }
9166 static void test_SetWindowRgn(void)
9168 HRGN hrgn;
9169 HWND hwnd = CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW,
9170 100, 100, 200, 200, 0, 0, 0, NULL);
9171 ok( hwnd != 0, "Failed to create overlapped window\n" );
9173 ShowWindow( hwnd, SW_SHOW );
9174 UpdateWindow( hwnd );
9175 flush_events();
9176 flush_sequence();
9178 trace("testing SetWindowRgn\n");
9179 hrgn = CreateRectRgn( 0, 0, 150, 150 );
9180 SetWindowRgn( hwnd, hrgn, TRUE );
9181 ok_sequence( WmSetWindowRgn, "WmSetWindowRgn", FALSE );
9183 hrgn = CreateRectRgn( 30, 30, 160, 160 );
9184 SetWindowRgn( hwnd, hrgn, FALSE );
9185 ok_sequence( WmSetWindowRgn_no_redraw, "WmSetWindowRgn_no_redraw", FALSE );
9187 hrgn = CreateRectRgn( 0, 0, 180, 180 );
9188 SetWindowRgn( hwnd, hrgn, TRUE );
9189 ok_sequence( WmSetWindowRgn, "WmSetWindowRgn2", FALSE );
9191 SetWindowRgn( hwnd, 0, TRUE );
9192 ok_sequence( WmSetWindowRgn_clear, "WmSetWindowRgn_clear", FALSE );
9194 DestroyWindow( hwnd );
9197 /*************************** ShowWindow() test ******************************/
9198 static const struct message WmShowNormal[] = {
9199 { WM_SHOWWINDOW, sent|wparam, 1 },
9200 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
9201 { HCBT_ACTIVATE, hook },
9202 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* win2003 doesn't send it */
9203 { HCBT_SETFOCUS, hook },
9204 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
9205 { 0 }
9207 static const struct message WmShow[] = {
9208 { WM_SHOWWINDOW, sent|wparam, 1 },
9209 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
9210 { HCBT_ACTIVATE, hook|optional }, /* win2000 doesn't send it */
9211 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* win2000 doesn't send it */
9212 { HCBT_SETFOCUS, hook|optional }, /* win2000 doesn't send it */
9213 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
9214 { 0 }
9216 static const struct message WmShowNoActivate_1[] = {
9217 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWNOACTIVATE },
9218 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|0x8000 },
9219 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|0x8000 },
9220 { WM_MOVE, sent|defwinproc },
9221 { WM_SIZE, sent|wparam|defwinproc, SIZE_RESTORED },
9222 { 0 }
9224 static const struct message WmShowNoActivate_2[] = {
9225 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWNOACTIVATE },
9226 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|0x8000 },
9227 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|0x8000 },
9228 { WM_MOVE, sent|defwinproc },
9229 { WM_SIZE, sent|wparam|defwinproc, SIZE_RESTORED },
9230 { HCBT_SETFOCUS, hook|optional },
9231 { HCBT_ACTIVATE, hook|optional }, /* win2003 doesn't send it */
9232 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* win2003 doesn't send it */
9233 { HCBT_SETFOCUS, hook|optional }, /* win2003 doesn't send it */
9234 { 0 }
9236 static const struct message WmShowNA_1[] = {
9237 { WM_SHOWWINDOW, sent|wparam, 1 },
9238 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
9239 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
9240 { 0 }
9242 static const struct message WmShowNA_2[] = {
9243 { WM_SHOWWINDOW, sent|wparam, 1 },
9244 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
9245 { 0 }
9247 static const struct message WmRestore_1[] = {
9248 { HCBT_MINMAX, hook|lparam, 0, SW_RESTORE },
9249 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOCOPYBITS|0x8000 },
9250 { HCBT_ACTIVATE, hook|optional }, /* win2000 doesn't send it */
9251 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* win2000 doesn't send it */
9252 { HCBT_SETFOCUS, hook|optional }, /* win2000 doesn't send it */
9253 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOCOPYBITS|0x8000 },
9254 { WM_MOVE, sent|defwinproc },
9255 { WM_SIZE, sent|wparam|defwinproc, SIZE_RESTORED },
9256 { HCBT_SETFOCUS, hook|optional }, /* win2000 sends it */
9257 { 0 }
9259 static const struct message WmRestore_2[] = {
9260 { WM_SHOWWINDOW, sent|wparam, 1 },
9261 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
9262 { HCBT_ACTIVATE, hook|optional }, /* win2000 doesn't send it */
9263 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* win2000 doesn't send it */
9264 { HCBT_SETFOCUS, hook|optional }, /* win2000 doesn't send it */
9265 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
9266 { 0 }
9268 static const struct message WmRestore_3[] = {
9269 { HCBT_MINMAX, hook|lparam, 0, SW_RESTORE },
9270 { WM_GETMINMAXINFO, sent },
9271 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOCOPYBITS|0x8000 },
9272 { HCBT_ACTIVATE, hook|optional }, /* win2003 doesn't send it */
9273 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* win2003 doesn't send it */
9274 { HCBT_SETFOCUS, hook|optional }, /* win2003 doesn't send it */
9275 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOCOPYBITS|0x8000 },
9276 { WM_MOVE, sent|defwinproc },
9277 { WM_SIZE, sent|wparam|defwinproc, SIZE_MAXIMIZED },
9278 { HCBT_SETFOCUS, hook|optional }, /* win2003 sends it */
9279 { 0 }
9281 static const struct message WmRestore_4[] = {
9282 { HCBT_MINMAX, hook|lparam, 0, SW_RESTORE },
9283 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|0x8000 },
9284 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|0x8000 },
9285 { WM_MOVE, sent|defwinproc },
9286 { WM_SIZE, sent|wparam|defwinproc, SIZE_RESTORED },
9287 { 0 }
9289 static const struct message WmRestore_5[] = {
9290 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWNORMAL },
9291 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|0x8000 },
9292 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|0x8000 },
9293 { WM_MOVE, sent|defwinproc },
9294 { WM_SIZE, sent|wparam|defwinproc, SIZE_RESTORED },
9295 { 0 }
9297 static const struct message WmHide_1[] = {
9298 { WM_SHOWWINDOW, sent|wparam, 0 },
9299 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE },
9300 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
9301 { HCBT_SETFOCUS, hook|optional }, /* win2000 sends it */
9302 { 0 }
9304 static const struct message WmHide_2[] = {
9305 { WM_SHOWWINDOW, sent|wparam, 0 },
9306 { WM_WINDOWPOSCHANGING, sent /*|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE*/ }, /* win2000 doesn't add SWP_NOACTIVATE */
9307 { WM_WINDOWPOSCHANGED, sent /*|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE*/ }, /* win2000 doesn't add SWP_NOACTIVATE */
9308 { 0 }
9310 static const struct message WmHide_3[] = {
9311 { WM_SHOWWINDOW, sent|wparam, 0 },
9312 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE },
9313 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
9314 { HCBT_SETFOCUS, hook },
9315 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
9316 { 0 }
9318 static const struct message WmShowMinimized_1[] = {
9319 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMINIMIZED },
9320 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOCOPYBITS|0x8000 },
9321 { HCBT_ACTIVATE, hook|optional }, /* win2000 doesn't send it */
9322 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* win2000 doesn't send it */
9323 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOCOPYBITS|0x8000 },
9324 { WM_MOVE, sent|defwinproc },
9325 { WM_SIZE, sent|wparam|defwinproc, SIZE_MINIMIZED },
9326 { 0 }
9328 static const struct message WmMinimize_1[] = {
9329 { HCBT_MINMAX, hook|lparam, 0, SW_MINIMIZE },
9330 { HCBT_SETFOCUS, hook|optional }, /* win2000 doesn't send it */
9331 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
9332 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|0x8000 },
9333 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|0x8000 },
9334 { WM_MOVE, sent|defwinproc },
9335 { WM_SIZE, sent|wparam|defwinproc, SIZE_MINIMIZED },
9336 { 0 }
9338 static const struct message WmMinimize_2[] = {
9339 { HCBT_MINMAX, hook|lparam, 0, SW_MINIMIZE },
9340 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|0x8000 },
9341 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|0x8000 },
9342 { WM_MOVE, sent|defwinproc },
9343 { WM_SIZE, sent|wparam|defwinproc, SIZE_MINIMIZED },
9344 { 0 }
9346 static const struct message WmMinimize_3[] = {
9347 { HCBT_MINMAX, hook|lparam, 0, SW_MINIMIZE },
9348 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|0x8000 },
9349 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|0x8000 },
9350 { WM_MOVE, sent|defwinproc },
9351 { WM_SIZE, sent|wparam|defwinproc, SIZE_MINIMIZED },
9352 { 0 }
9354 static const struct message WmShowMinNoActivate[] = {
9355 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMINNOACTIVE },
9356 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
9357 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
9358 { 0 }
9360 static const struct message WmMinMax_1[] = {
9361 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMINIMIZED },
9362 { 0 }
9364 static const struct message WmMinMax_2[] = {
9365 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMAXIMIZED },
9366 { 0 }
9368 static const struct message WmMinMax_3[] = {
9369 { HCBT_MINMAX, hook|lparam, 0, SW_MINIMIZE },
9370 { 0 }
9372 static const struct message WmMinMax_4[] = {
9373 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMINNOACTIVE },
9374 { 0 }
9376 static const struct message WmShowMaximized_1[] = {
9377 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMAXIMIZED },
9378 { WM_GETMINMAXINFO, sent },
9379 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOCOPYBITS|0x8000 },
9380 { HCBT_ACTIVATE, hook|optional }, /* win2000 doesn't send it */
9381 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* win2000 doesn't send it */
9382 { HCBT_SETFOCUS, hook|optional }, /* win2000 doesn't send it */
9383 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOCOPYBITS|0x8000 },
9384 { WM_MOVE, sent|defwinproc },
9385 { WM_SIZE, sent|wparam|defwinproc, SIZE_MAXIMIZED },
9386 { HCBT_SETFOCUS, hook|optional }, /* win2003 sends it */
9387 { 0 }
9389 static const struct message WmShowMaximized_2[] = {
9390 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMAXIMIZED },
9391 { WM_GETMINMAXINFO, sent },
9392 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE },
9393 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
9394 { WM_MOVE, sent|optional }, /* Win9x doesn't send it */
9395 { WM_SIZE, sent|wparam|optional, SIZE_MAXIMIZED }, /* Win9x doesn't send it */
9396 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOCOPYBITS|0x8000 },
9397 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOCOPYBITS|0x8000 },
9398 { WM_MOVE, sent|defwinproc },
9399 { WM_SIZE, sent|wparam|defwinproc, SIZE_MAXIMIZED },
9400 { HCBT_SETFOCUS, hook },
9401 { 0 }
9403 static const struct message WmShowMaximized_3[] = {
9404 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMAXIMIZED },
9405 { WM_GETMINMAXINFO, sent },
9406 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|0x8000 },
9407 { HCBT_ACTIVATE, hook|optional }, /* win2000 doesn't send it */
9408 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* win2000 doesn't send it */
9409 { HCBT_SETFOCUS, hook|optional }, /* win2000 doesn't send it */
9410 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|0x8000 },
9411 { WM_MOVE, sent|defwinproc },
9412 { WM_SIZE, sent|wparam|defwinproc, SIZE_MAXIMIZED },
9413 { 0 }
9416 static void test_ShowWindow(void)
9418 /* ShowWindow commands in random order */
9419 static const struct
9421 INT cmd; /* ShowWindow command */
9422 LPARAM ret; /* ShowWindow return value */
9423 DWORD style; /* window style after the command */
9424 const struct message *msg; /* message sequence the command produces */
9425 BOOL todo_msg; /* message sequence doesn't match what Wine does */
9426 } sw[] =
9428 /* 1 */ { SW_SHOWNORMAL, FALSE, WS_VISIBLE, WmShowNormal, FALSE },
9429 /* 2 */ { SW_SHOWNORMAL, TRUE, WS_VISIBLE, WmEmptySeq, FALSE },
9430 /* 3 */ { SW_HIDE, TRUE, 0, WmHide_1, FALSE },
9431 /* 4 */ { SW_HIDE, FALSE, 0, WmEmptySeq, FALSE },
9432 /* 5 */ { SW_SHOWMINIMIZED, FALSE, WS_VISIBLE|WS_MINIMIZE, WmShowMinimized_1, FALSE },
9433 /* 6 */ { SW_SHOWMINIMIZED, TRUE, WS_VISIBLE|WS_MINIMIZE, WmMinMax_1, FALSE },
9434 /* 7 */ { SW_HIDE, TRUE, WS_MINIMIZE, WmHide_1, FALSE },
9435 /* 8 */ { SW_HIDE, FALSE, WS_MINIMIZE, WmEmptySeq, FALSE },
9436 /* 9 */ { SW_SHOWMAXIMIZED, FALSE, WS_VISIBLE|WS_MAXIMIZE, WmShowMaximized_1, FALSE },
9437 /* 10 */ { SW_SHOWMAXIMIZED, TRUE, WS_VISIBLE|WS_MAXIMIZE, WmMinMax_2, FALSE },
9438 /* 11 */ { SW_HIDE, TRUE, WS_MAXIMIZE, WmHide_1, FALSE },
9439 /* 12 */ { SW_HIDE, FALSE, WS_MAXIMIZE, WmEmptySeq, FALSE },
9440 /* 13 */ { SW_SHOWNOACTIVATE, FALSE, WS_VISIBLE, WmShowNoActivate_1, FALSE },
9441 /* 14 */ { SW_SHOWNOACTIVATE, TRUE, WS_VISIBLE, WmEmptySeq, FALSE },
9442 /* 15 */ { SW_HIDE, TRUE, 0, WmHide_2, FALSE },
9443 /* 16 */ { SW_HIDE, FALSE, 0, WmEmptySeq, FALSE },
9444 /* 17 */ { SW_SHOW, FALSE, WS_VISIBLE, WmShow, FALSE },
9445 /* 18 */ { SW_SHOW, TRUE, WS_VISIBLE, WmEmptySeq, FALSE },
9446 /* 19 */ { SW_MINIMIZE, TRUE, WS_VISIBLE|WS_MINIMIZE, WmMinimize_1, FALSE },
9447 /* 20 */ { SW_MINIMIZE, TRUE, WS_VISIBLE|WS_MINIMIZE, WmMinMax_3, FALSE },
9448 /* 21 */ { SW_HIDE, TRUE, WS_MINIMIZE, WmHide_2, FALSE },
9449 /* 22 */ { SW_SHOWMINNOACTIVE, FALSE, WS_VISIBLE|WS_MINIMIZE, WmShowMinNoActivate, TRUE },
9450 /* 23 */ { SW_SHOWMINNOACTIVE, TRUE, WS_VISIBLE|WS_MINIMIZE, WmMinMax_4, FALSE },
9451 /* 24 */ { SW_HIDE, TRUE, WS_MINIMIZE, WmHide_2, FALSE },
9452 /* 25 */ { SW_HIDE, FALSE, WS_MINIMIZE, WmEmptySeq, FALSE },
9453 /* 26 */ { SW_SHOWNA, FALSE, WS_VISIBLE|WS_MINIMIZE, WmShowNA_1, FALSE },
9454 /* 27 */ { SW_SHOWNA, TRUE, WS_VISIBLE|WS_MINIMIZE, WmShowNA_2, FALSE },
9455 /* 28 */ { SW_HIDE, TRUE, WS_MINIMIZE, WmHide_2, FALSE },
9456 /* 29 */ { SW_HIDE, FALSE, WS_MINIMIZE, WmEmptySeq, FALSE },
9457 /* 30 */ { SW_RESTORE, FALSE, WS_VISIBLE, WmRestore_1, FALSE },
9458 /* 31 */ { SW_RESTORE, TRUE, WS_VISIBLE, WmEmptySeq, FALSE },
9459 /* 32 */ { SW_HIDE, TRUE, 0, WmHide_3, TRUE },
9460 /* 33 */ { SW_HIDE, FALSE, 0, WmEmptySeq, FALSE },
9461 /* 34 */ { SW_NORMALNA, FALSE, 0, WmEmptySeq, FALSE }, /* what does this mean?! */
9462 /* 35 */ { SW_NORMALNA, FALSE, 0, WmEmptySeq, FALSE },
9463 /* 36 */ { SW_HIDE, FALSE, 0, WmEmptySeq, FALSE },
9464 /* 37 */ { SW_RESTORE, FALSE, WS_VISIBLE, WmRestore_2, FALSE },
9465 /* 38 */ { SW_RESTORE, TRUE, WS_VISIBLE, WmEmptySeq, FALSE },
9466 /* 39 */ { SW_SHOWNOACTIVATE, TRUE, WS_VISIBLE, WmEmptySeq, FALSE },
9467 /* 40 */ { SW_MINIMIZE, TRUE, WS_VISIBLE|WS_MINIMIZE, WmMinimize_2, FALSE },
9468 /* 41 */ { SW_MINIMIZE, TRUE, WS_VISIBLE|WS_MINIMIZE, WmMinMax_3, FALSE },
9469 /* 42 */ { SW_SHOWMAXIMIZED, TRUE, WS_VISIBLE|WS_MAXIMIZE, WmShowMaximized_2, TRUE },
9470 /* 43 */ { SW_SHOWMAXIMIZED, TRUE, WS_VISIBLE|WS_MAXIMIZE, WmMinMax_2, FALSE },
9471 /* 44 */ { SW_MINIMIZE, TRUE, WS_VISIBLE|WS_MINIMIZE, WmMinimize_1, FALSE },
9472 /* 45 */ { SW_MINIMIZE, TRUE, WS_VISIBLE|WS_MINIMIZE, WmMinMax_3, FALSE },
9473 /* 46 */ { SW_RESTORE, TRUE, WS_VISIBLE|WS_MAXIMIZE, WmRestore_3, FALSE },
9474 /* 47 */ { SW_RESTORE, TRUE, WS_VISIBLE, WmRestore_4, FALSE },
9475 /* 48 */ { SW_SHOWMAXIMIZED, TRUE, WS_VISIBLE|WS_MAXIMIZE, WmShowMaximized_3, FALSE },
9476 /* 49 */ { SW_SHOW, TRUE, WS_VISIBLE|WS_MAXIMIZE, WmEmptySeq, FALSE },
9477 /* 50 */ { SW_SHOWNORMAL, TRUE, WS_VISIBLE, WmRestore_5, FALSE },
9478 /* 51 */ { SW_SHOWNORMAL, TRUE, WS_VISIBLE, WmEmptySeq, FALSE },
9479 /* 52 */ { SW_HIDE, TRUE, 0, WmHide_1, FALSE },
9480 /* 53 */ { SW_HIDE, FALSE, 0, WmEmptySeq, FALSE },
9481 /* 54 */ { SW_MINIMIZE, FALSE, WS_VISIBLE|WS_MINIMIZE, WmMinimize_3, FALSE },
9482 /* 55 */ { SW_HIDE, TRUE, WS_MINIMIZE, WmHide_2, FALSE },
9483 /* 56 */ { SW_SHOWNOACTIVATE, FALSE, WS_VISIBLE, WmShowNoActivate_2, FALSE },
9484 /* 57 */ { SW_SHOW, TRUE, WS_VISIBLE, WmEmptySeq, FALSE }
9486 HWND hwnd;
9487 DWORD style;
9488 LPARAM ret;
9489 INT i;
9491 #define WS_BASE (WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX|WS_MAXIMIZEBOX|WS_POPUP|WS_CLIPSIBLINGS)
9492 hwnd = CreateWindowEx(0, "ShowWindowClass", NULL, WS_BASE,
9493 120, 120, 90, 90,
9494 0, 0, 0, NULL);
9495 assert(hwnd);
9497 style = GetWindowLong(hwnd, GWL_STYLE) & ~WS_BASE;
9498 ok(style == 0, "expected style 0, got %08x\n", style);
9500 flush_events();
9501 flush_sequence();
9503 for (i = 0; i < sizeof(sw)/sizeof(sw[0]); i++)
9505 static const char * const sw_cmd_name[13] =
9507 "SW_HIDE", "SW_SHOWNORMAL", "SW_SHOWMINIMIZED", "SW_SHOWMAXIMIZED",
9508 "SW_SHOWNOACTIVATE", "SW_SHOW", "SW_MINIMIZE", "SW_SHOWMINNOACTIVE",
9509 "SW_SHOWNA", "SW_RESTORE", "SW_SHOWDEFAULT", "SW_FORCEMINIMIZE",
9510 "SW_NORMALNA" /* 0xCC */
9512 char comment[64];
9513 INT idx; /* index into the above array of names */
9515 idx = (sw[i].cmd == SW_NORMALNA) ? 12 : sw[i].cmd;
9517 style = GetWindowLong(hwnd, GWL_STYLE);
9518 trace("%d: sending %s, current window style %08x\n", i+1, sw_cmd_name[idx], style);
9519 ret = ShowWindow(hwnd, sw[i].cmd);
9520 ok(!ret == !sw[i].ret, "%d: cmd %s: expected ret %lu, got %lu\n", i+1, sw_cmd_name[idx], sw[i].ret, ret);
9521 style = GetWindowLong(hwnd, GWL_STYLE) & ~WS_BASE;
9522 ok(style == sw[i].style, "%d: expected style %08x, got %08x\n", i+1, sw[i].style, style);
9524 sprintf(comment, "%d: ShowWindow(%s)", i+1, sw_cmd_name[idx]);
9525 ok_sequence(sw[i].msg, comment, sw[i].todo_msg);
9527 flush_events();
9528 flush_sequence();
9531 DestroyWindow(hwnd);
9534 static INT_PTR WINAPI test_dlg_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
9536 struct message msg;
9538 trace("dialog: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
9540 switch (message)
9542 case WM_WINDOWPOSCHANGING:
9543 case WM_WINDOWPOSCHANGED:
9545 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
9547 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
9548 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
9549 winpos->hwnd, winpos->hwndInsertAfter,
9550 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
9551 dump_winpos_flags(winpos->flags);
9553 /* Log only documented flags, win2k uses 0x1000 and 0x2000
9554 * in the high word for internal purposes
9556 wParam = winpos->flags & 0xffff;
9557 /* We are not interested in the flags that don't match under XP and Win9x */
9558 wParam &= ~(SWP_NOZORDER);
9559 break;
9562 /* explicitly ignore WM_GETICON message */
9563 case WM_GETICON:
9564 return 0;
9567 msg.message = message;
9568 msg.flags = sent|wparam|lparam;
9569 msg.wParam = wParam;
9570 msg.lParam = lParam;
9571 add_message(&msg);
9573 /* calling DefDlgProc leads to a recursion under XP */
9575 switch (message)
9577 case WM_INITDIALOG:
9578 case WM_GETDLGCODE:
9579 return 0;
9581 return 1;
9584 static const struct message WmDefDlgSetFocus_1[] = {
9585 { WM_GETDLGCODE, sent|wparam|lparam, 0, 0 },
9586 { WM_GETTEXTLENGTH, sent|wparam|lparam|optional, 0, 0 }, /* XP */
9587 { WM_GETTEXT, sent|wparam|optional, 6 }, /* XP */
9588 { WM_GETTEXT, sent|wparam|optional, 12 }, /* XP */
9589 { EM_SETSEL, sent|wparam, 0 }, /* XP sets lparam to text length, Win9x to -2 */
9590 { HCBT_SETFOCUS, hook },
9591 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
9592 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
9593 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
9594 { WM_SETFOCUS, sent|wparam, 0 },
9595 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 10 },
9596 { WM_CTLCOLOREDIT, sent },
9597 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 11 },
9598 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
9599 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
9600 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
9601 { WM_COMMAND, sent|wparam, MAKEWPARAM(1, EN_SETFOCUS) },
9602 { 0 }
9604 static const struct message WmDefDlgSetFocus_2[] = {
9605 { WM_GETDLGCODE, sent|wparam|lparam, 0, 0 },
9606 { WM_GETTEXTLENGTH, sent|wparam|lparam|optional, 0, 0 }, /* XP */
9607 { WM_GETTEXT, sent|wparam|optional, 6 }, /* XP */
9608 { WM_GETTEXT, sent|wparam|optional, 12 }, /* XP */
9609 { EM_SETSEL, sent|wparam, 0 }, /* XP sets lparam to text length, Win9x to -2 */
9610 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
9611 { WM_CTLCOLOREDIT, sent|optional }, /* XP */
9612 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
9613 { 0 }
9615 /* Creation of a dialog */
9616 static const struct message WmCreateDialogParamSeq_1[] = {
9617 { HCBT_CREATEWND, hook },
9618 { WM_NCCREATE, sent },
9619 { WM_NCCALCSIZE, sent|wparam, 0 },
9620 { WM_CREATE, sent },
9621 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
9622 { WM_SIZE, sent|wparam, SIZE_RESTORED },
9623 { WM_MOVE, sent },
9624 { WM_SETFONT, sent },
9625 { WM_INITDIALOG, sent },
9626 { WM_CHANGEUISTATE, sent|optional },
9627 { 0 }
9629 /* Creation of a dialog */
9630 static const struct message WmCreateDialogParamSeq_2[] = {
9631 { HCBT_CREATEWND, hook },
9632 { WM_NCCREATE, sent },
9633 { WM_NCCALCSIZE, sent|wparam, 0 },
9634 { WM_CREATE, sent },
9635 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
9636 { WM_SIZE, sent|wparam, SIZE_RESTORED },
9637 { WM_MOVE, sent },
9638 { WM_CHANGEUISTATE, sent|optional },
9639 { 0 }
9642 static void test_dialog_messages(void)
9644 WNDCLASS cls;
9645 HWND hdlg, hedit1, hedit2, hfocus;
9646 LRESULT ret;
9648 #define set_selection(hctl, start, end) \
9649 ret = SendMessage(hctl, EM_SETSEL, start, end); \
9650 ok(ret == 1, "EM_SETSEL returned %ld\n", ret);
9652 #define check_selection(hctl, start, end) \
9653 ret = SendMessage(hctl, EM_GETSEL, 0, 0); \
9654 ok(ret == MAKELRESULT(start, end), "wrong selection (%d - %d)\n", LOWORD(ret), HIWORD(ret));
9656 subclass_edit();
9658 hdlg = CreateWindowEx(WS_EX_DLGMODALFRAME, "TestDialogClass", NULL,
9659 WS_VISIBLE|WS_CAPTION|WS_SYSMENU|WS_DLGFRAME,
9660 0, 0, 100, 100, 0, 0, 0, NULL);
9661 ok(hdlg != 0, "Failed to create custom dialog window\n");
9663 hedit1 = CreateWindowEx(0, "my_edit_class", NULL,
9664 WS_CHILD|WS_BORDER|WS_VISIBLE|WS_TABSTOP,
9665 0, 0, 80, 20, hdlg, (HMENU)1, 0, NULL);
9666 ok(hedit1 != 0, "Failed to create edit control\n");
9667 hedit2 = CreateWindowEx(0, "my_edit_class", NULL,
9668 WS_CHILD|WS_BORDER|WS_VISIBLE|WS_TABSTOP,
9669 0, 40, 80, 20, hdlg, (HMENU)2, 0, NULL);
9670 ok(hedit2 != 0, "Failed to create edit control\n");
9672 SendMessage(hedit1, WM_SETTEXT, 0, (LPARAM)"hello");
9673 SendMessage(hedit2, WM_SETTEXT, 0, (LPARAM)"bye");
9675 hfocus = GetFocus();
9676 ok(hfocus == hdlg, "wrong focus %p\n", hfocus);
9678 SetFocus(hedit2);
9679 hfocus = GetFocus();
9680 ok(hfocus == hedit2, "wrong focus %p\n", hfocus);
9682 check_selection(hedit1, 0, 0);
9683 check_selection(hedit2, 0, 0);
9685 set_selection(hedit2, 0, -1);
9686 check_selection(hedit2, 0, 3);
9688 SetFocus(0);
9689 hfocus = GetFocus();
9690 ok(hfocus == 0, "wrong focus %p\n", hfocus);
9692 flush_sequence();
9693 ret = DefDlgProc(hdlg, WM_SETFOCUS, 0, 0);
9694 ok(ret == 0, "WM_SETFOCUS returned %ld\n", ret);
9695 ok_sequence(WmDefDlgSetFocus_1, "DefDlgProc(WM_SETFOCUS) 1", FALSE);
9697 hfocus = GetFocus();
9698 ok(hfocus == hedit1, "wrong focus %p\n", hfocus);
9700 check_selection(hedit1, 0, 5);
9701 check_selection(hedit2, 0, 3);
9703 flush_sequence();
9704 ret = DefDlgProc(hdlg, WM_SETFOCUS, 0, 0);
9705 ok(ret == 0, "WM_SETFOCUS returned %ld\n", ret);
9706 ok_sequence(WmDefDlgSetFocus_2, "DefDlgProc(WM_SETFOCUS) 2", FALSE);
9708 hfocus = GetFocus();
9709 ok(hfocus == hedit1, "wrong focus %p\n", hfocus);
9711 check_selection(hedit1, 0, 5);
9712 check_selection(hedit2, 0, 3);
9714 EndDialog(hdlg, 0);
9715 DestroyWindow(hedit1);
9716 DestroyWindow(hedit2);
9717 DestroyWindow(hdlg);
9718 flush_sequence();
9720 #undef set_selection
9721 #undef check_selection
9723 ok(GetClassInfo(0, "#32770", &cls), "GetClassInfo failed\n");
9724 cls.lpszClassName = "MyDialogClass";
9725 cls.hInstance = GetModuleHandle(0);
9726 /* need a cast since a dlgproc is used as a wndproc */
9727 cls.lpfnWndProc = (WNDPROC)test_dlg_proc;
9728 if (!RegisterClass(&cls)) assert(0);
9730 hdlg = CreateDialogParam(0, "CLASS_TEST_DIALOG_2", 0, test_dlg_proc, 0);
9731 ok(IsWindow(hdlg), "CreateDialogParam failed\n");
9732 ok_sequence(WmCreateDialogParamSeq_1, "CreateDialogParam_1", FALSE);
9733 EndDialog(hdlg, 0);
9734 DestroyWindow(hdlg);
9735 flush_sequence();
9737 hdlg = CreateDialogParam(0, "CLASS_TEST_DIALOG_2", 0, NULL, 0);
9738 ok(IsWindow(hdlg), "CreateDialogParam failed\n");
9739 ok_sequence(WmCreateDialogParamSeq_2, "CreateDialogParam_2", FALSE);
9740 EndDialog(hdlg, 0);
9741 DestroyWindow(hdlg);
9742 flush_sequence();
9744 UnregisterClass(cls.lpszClassName, cls.hInstance);
9747 static void test_nullCallback(void)
9749 HWND hwnd;
9751 hwnd = CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW,
9752 100, 100, 200, 200, 0, 0, 0, NULL);
9753 ok (hwnd != 0, "Failed to create overlapped window\n");
9755 SendMessageCallbackA(hwnd,WM_NULL,0,0,NULL,0);
9756 flush_events();
9757 DestroyWindow(hwnd);
9760 static const struct message SetForegroundWindowSeq[] =
9762 { WM_NCACTIVATE, sent|wparam, 0 },
9763 { WM_GETTEXT, sent|defwinproc|optional },
9764 { WM_ACTIVATE, sent|wparam, 0 },
9765 { WM_ACTIVATEAPP, sent|wparam, 0 },
9766 { WM_KILLFOCUS, sent },
9767 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
9768 { WM_IME_NOTIFY, sent|wparam|optional|defwinproc, 1 },
9769 { 0 }
9772 static void test_SetForegroundWindow(void)
9774 HWND hwnd;
9776 hwnd = CreateWindowExA(0, "TestWindowClass", "Test SetForegroundWindow",
9777 WS_OVERLAPPEDWINDOW | WS_VISIBLE,
9778 100, 100, 200, 200, 0, 0, 0, NULL);
9779 ok (hwnd != 0, "Failed to create overlapped window\n");
9780 flush_sequence();
9782 trace("SetForegroundWindow( 0 )\n");
9783 SetForegroundWindow( 0 );
9784 ok_sequence(WmEmptySeq, "SetForegroundWindow( 0 ) away from foreground top level window", FALSE);
9785 trace("SetForegroundWindow( GetDesktopWindow() )\n");
9786 SetForegroundWindow( GetDesktopWindow() );
9787 ok_sequence(SetForegroundWindowSeq, "SetForegroundWindow( desktop ) away from "
9788 "foreground top level window", FALSE);
9789 trace("done\n");
9791 DestroyWindow(hwnd);
9794 static void test_dbcs_wm_char(void)
9796 BYTE dbch[2];
9797 WCHAR wch, bad_wch;
9798 HWND hwnd, hwnd2;
9799 MSG msg;
9800 DWORD time;
9801 POINT pt;
9802 DWORD_PTR res;
9803 CPINFOEXA cpinfo;
9804 UINT i, j, k;
9805 struct message wmCharSeq[2];
9807 if (!pGetCPInfoExA)
9809 skip("GetCPInfoExA is not available\n");
9810 return;
9813 pGetCPInfoExA( CP_ACP, 0, &cpinfo );
9814 if (cpinfo.MaxCharSize != 2)
9816 skip( "Skipping DBCS WM_CHAR test in SBCS codepage '%s'\n", cpinfo.CodePageName );
9817 return;
9820 dbch[0] = dbch[1] = 0;
9821 wch = 0;
9822 bad_wch = cpinfo.UnicodeDefaultChar;
9823 for (i = 0; !wch && i < MAX_LEADBYTES && cpinfo.LeadByte[i]; i += 2)
9824 for (j = cpinfo.LeadByte[i]; !wch && j <= cpinfo.LeadByte[i+1]; j++)
9825 for (k = 128; k <= 255; k++)
9827 char str[2];
9828 WCHAR wstr[2];
9829 str[0] = j;
9830 str[1] = k;
9831 if (MultiByteToWideChar( CP_ACP, 0, str, 2, wstr, 2 ) == 1 &&
9832 WideCharToMultiByte( CP_ACP, 0, wstr, 1, str, 2, NULL, NULL ) == 2 &&
9833 (BYTE)str[0] == j && (BYTE)str[1] == k &&
9834 HIBYTE(wstr[0]) && HIBYTE(wstr[0]) != 0xff)
9836 dbch[0] = j;
9837 dbch[1] = k;
9838 wch = wstr[0];
9839 break;
9843 if (!wch)
9845 skip( "Skipping DBCS WM_CHAR test, no appropriate char found\n" );
9846 return;
9848 trace( "using dbcs char %02x,%02x wchar %04x bad wchar %04x codepage '%s'\n",
9849 dbch[0], dbch[1], wch, bad_wch, cpinfo.CodePageName );
9851 hwnd = CreateWindowExW(0, testWindowClassW, NULL,
9852 WS_OVERLAPPEDWINDOW, 100, 100, 200, 200, 0, 0, 0, NULL);
9853 hwnd2 = CreateWindowExW(0, testWindowClassW, NULL,
9854 WS_OVERLAPPEDWINDOW, 100, 100, 200, 200, 0, 0, 0, NULL);
9855 ok (hwnd != 0, "Failed to create overlapped window\n");
9856 ok (hwnd2 != 0, "Failed to create overlapped window\n");
9857 flush_sequence();
9859 memset( wmCharSeq, 0, sizeof(wmCharSeq) );
9860 wmCharSeq[0].message = WM_CHAR;
9861 wmCharSeq[0].flags = sent|wparam;
9862 wmCharSeq[0].wParam = wch;
9864 /* posted message */
9865 PostMessageA( hwnd, WM_CHAR, dbch[0], 0 );
9866 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
9867 PostMessageA( hwnd, WM_CHAR, dbch[1], 0 );
9868 ok( PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "no message\n" );
9869 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
9870 ok( msg.wParam == wch, "bad wparam %lx/%x\n", msg.wParam, wch );
9871 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
9873 /* posted thread message */
9874 PostThreadMessageA( GetCurrentThreadId(), WM_CHAR, dbch[0], 0 );
9875 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
9876 PostMessageA( hwnd, WM_CHAR, dbch[1], 0 );
9877 ok( PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "no message\n" );
9878 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
9879 ok( msg.wParam == wch, "bad wparam %lx/%x\n", msg.wParam, wch );
9880 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
9882 /* sent message */
9883 flush_sequence();
9884 SendMessageA( hwnd, WM_CHAR, dbch[0], 0 );
9885 ok_sequence( WmEmptySeq, "no messages", FALSE );
9886 SendMessageA( hwnd, WM_CHAR, dbch[1], 0 );
9887 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
9888 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
9890 /* sent message with timeout */
9891 flush_sequence();
9892 SendMessageTimeoutA( hwnd, WM_CHAR, dbch[0], 0, SMTO_NORMAL, 0, &res );
9893 ok_sequence( WmEmptySeq, "no messages", FALSE );
9894 SendMessageTimeoutA( hwnd, WM_CHAR, dbch[1], 0, SMTO_NORMAL, 0, &res );
9895 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
9896 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
9898 /* sent message with timeout and callback */
9899 flush_sequence();
9900 SendMessageTimeoutA( hwnd, WM_CHAR, dbch[0], 0, SMTO_NORMAL, 0, &res );
9901 ok_sequence( WmEmptySeq, "no messages", FALSE );
9902 SendMessageCallbackA( hwnd, WM_CHAR, dbch[1], 0, NULL, 0 );
9903 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
9904 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
9906 /* sent message with callback */
9907 flush_sequence();
9908 SendNotifyMessageA( hwnd, WM_CHAR, dbch[0], 0 );
9909 ok_sequence( WmEmptySeq, "no messages", FALSE );
9910 SendMessageCallbackA( hwnd, WM_CHAR, dbch[1], 0, NULL, 0 );
9911 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
9912 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
9914 /* direct window proc call */
9915 flush_sequence();
9916 CallWindowProcA( (WNDPROC)GetWindowLongPtrA( hwnd, GWLP_WNDPROC ), hwnd, WM_CHAR, dbch[0], 0 );
9917 ok_sequence( WmEmptySeq, "no messages", FALSE );
9918 CallWindowProcA( (WNDPROC)GetWindowLongPtrA( hwnd, GWLP_WNDPROC ), hwnd, WM_CHAR, dbch[1], 0 );
9919 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
9921 /* dispatch message */
9922 msg.hwnd = hwnd;
9923 msg.message = WM_CHAR;
9924 msg.wParam = dbch[0];
9925 msg.lParam = 0;
9926 DispatchMessageA( &msg );
9927 ok_sequence( WmEmptySeq, "no messages", FALSE );
9928 msg.wParam = dbch[1];
9929 DispatchMessageA( &msg );
9930 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
9932 /* window handle is irrelevant */
9933 flush_sequence();
9934 SendMessageA( hwnd2, WM_CHAR, dbch[0], 0 );
9935 ok_sequence( WmEmptySeq, "no messages", FALSE );
9936 SendMessageA( hwnd, WM_CHAR, dbch[1], 0 );
9937 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
9938 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
9940 /* interleaved post and send */
9941 flush_sequence();
9942 PostMessageA( hwnd2, WM_CHAR, dbch[0], 0 );
9943 SendMessageA( hwnd2, WM_CHAR, dbch[0], 0 );
9944 ok_sequence( WmEmptySeq, "no messages", FALSE );
9945 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
9946 PostMessageA( hwnd, WM_CHAR, dbch[1], 0 );
9947 ok_sequence( WmEmptySeq, "no messages", FALSE );
9948 ok( PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "no message\n" );
9949 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
9950 ok( msg.wParam == wch, "bad wparam %lx/%x\n", msg.wParam, wch );
9951 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
9952 SendMessageA( hwnd, WM_CHAR, dbch[1], 0 );
9953 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
9954 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
9956 /* interleaved sent message and winproc */
9957 flush_sequence();
9958 SendMessageA( hwnd, WM_CHAR, dbch[0], 0 );
9959 CallWindowProcA( (WNDPROC)GetWindowLongPtrA( hwnd, GWLP_WNDPROC ), hwnd, WM_CHAR, dbch[0], 0 );
9960 ok_sequence( WmEmptySeq, "no messages", FALSE );
9961 SendMessageA( hwnd, WM_CHAR, dbch[1], 0 );
9962 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
9963 CallWindowProcA( (WNDPROC)GetWindowLongPtrA( hwnd, GWLP_WNDPROC ), hwnd, WM_CHAR, dbch[1], 0 );
9964 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
9966 /* interleaved winproc and dispatch */
9967 msg.hwnd = hwnd;
9968 msg.message = WM_CHAR;
9969 msg.wParam = dbch[0];
9970 msg.lParam = 0;
9971 CallWindowProcA( (WNDPROC)GetWindowLongPtrA( hwnd, GWLP_WNDPROC ), hwnd, WM_CHAR, dbch[0], 0 );
9972 DispatchMessageA( &msg );
9973 ok_sequence( WmEmptySeq, "no messages", FALSE );
9974 msg.wParam = dbch[1];
9975 DispatchMessageA( &msg );
9976 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
9977 CallWindowProcA( (WNDPROC)GetWindowLongPtrA( hwnd, GWLP_WNDPROC ), hwnd, WM_CHAR, dbch[1], 0 );
9978 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
9980 /* interleaved sends */
9981 flush_sequence();
9982 SendMessageA( hwnd, WM_CHAR, dbch[0], 0 );
9983 SendMessageCallbackA( hwnd, WM_CHAR, dbch[0], 0, NULL, 0 );
9984 ok_sequence( WmEmptySeq, "no messages", FALSE );
9985 SendMessageTimeoutA( hwnd, WM_CHAR, dbch[1], 0, SMTO_NORMAL, 0, &res );
9986 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
9987 SendMessageA( hwnd, WM_CHAR, dbch[1], 0 );
9988 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
9990 /* dbcs WM_CHAR */
9991 flush_sequence();
9992 SendMessageA( hwnd2, WM_CHAR, (dbch[1] << 8) | dbch[0], 0 );
9993 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
9994 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
9996 /* other char messages are not magic */
9997 PostMessageA( hwnd, WM_SYSCHAR, dbch[0], 0 );
9998 ok( PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "no message\n" );
9999 ok( msg.message == WM_SYSCHAR, "unexpected message %x\n", msg.message );
10000 ok( msg.wParam == bad_wch, "bad wparam %lx/%x\n", msg.wParam, bad_wch );
10001 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10002 PostMessageA( hwnd, WM_DEADCHAR, dbch[0], 0 );
10003 ok( PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "no message\n" );
10004 ok( msg.message == WM_DEADCHAR, "unexpected message %x\n", msg.message );
10005 ok( msg.wParam == bad_wch, "bad wparam %lx/%x\n", msg.wParam, bad_wch );
10006 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10008 /* test retrieving messages */
10010 PostMessageW( hwnd, WM_CHAR, wch, 0 );
10011 ok( PeekMessageA( &msg, hwnd, 0, 0, PM_REMOVE ), "no message\n" );
10012 ok( msg.hwnd == hwnd, "unexpected hwnd %p\n", msg.hwnd );
10013 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
10014 ok( msg.wParam == dbch[0], "bad wparam %lx/%x\n", msg.wParam, dbch[0] );
10015 ok( PeekMessageA( &msg, hwnd, 0, 0, PM_REMOVE ), "no message\n" );
10016 ok( msg.hwnd == hwnd, "unexpected hwnd %p\n", msg.hwnd );
10017 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
10018 ok( msg.wParam == dbch[1], "bad wparam %lx/%x\n", msg.wParam, dbch[0] );
10019 ok( !PeekMessageA( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10021 /* message filters */
10022 PostMessageW( hwnd, WM_CHAR, wch, 0 );
10023 ok( PeekMessageA( &msg, hwnd, 0, 0, PM_REMOVE ), "no message\n" );
10024 ok( msg.hwnd == hwnd, "unexpected hwnd %p\n", msg.hwnd );
10025 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
10026 ok( msg.wParam == dbch[0], "bad wparam %lx/%x\n", msg.wParam, dbch[0] );
10027 /* message id is filtered, hwnd is not */
10028 ok( !PeekMessageA( &msg, hwnd, WM_MOUSEFIRST, WM_MOUSELAST, PM_REMOVE ), "no message\n" );
10029 ok( PeekMessageA( &msg, hwnd2, 0, 0, PM_REMOVE ), "no message\n" );
10030 ok( msg.hwnd == hwnd, "unexpected hwnd %p\n", msg.hwnd );
10031 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
10032 ok( msg.wParam == dbch[1], "bad wparam %lx/%x\n", msg.wParam, dbch[0] );
10033 ok( !PeekMessageA( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10035 /* mixing GetMessage and PostMessage */
10036 PostMessageW( hwnd, WM_CHAR, wch, 0xbeef );
10037 ok( GetMessageA( &msg, hwnd, 0, 0 ), "no message\n" );
10038 ok( msg.hwnd == hwnd, "unexpected hwnd %p\n", msg.hwnd );
10039 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
10040 ok( msg.wParam == dbch[0], "bad wparam %lx/%x\n", msg.wParam, dbch[0] );
10041 ok( msg.lParam == 0xbeef, "bad lparam %lx\n", msg.lParam );
10042 time = msg.time;
10043 pt = msg.pt;
10044 ok( time - GetTickCount() <= 100, "bad time %x\n", msg.time );
10045 ok( PeekMessageA( &msg, 0, 0, 0, PM_REMOVE ), "no message\n" );
10046 ok( msg.hwnd == hwnd, "unexpected hwnd %p\n", msg.hwnd );
10047 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
10048 ok( msg.wParam == dbch[1], "bad wparam %lx/%x\n", msg.wParam, dbch[0] );
10049 ok( msg.lParam == 0xbeef, "bad lparam %lx\n", msg.lParam );
10050 ok( msg.time == time, "bad time %x/%x\n", msg.time, time );
10051 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 );
10052 ok( !PeekMessageA( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10054 /* without PM_REMOVE */
10055 PostMessageW( hwnd, WM_CHAR, wch, 0 );
10056 ok( PeekMessageA( &msg, 0, 0, 0, PM_NOREMOVE ), "no message\n" );
10057 ok( msg.hwnd == hwnd, "unexpected hwnd %p\n", msg.hwnd );
10058 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
10059 ok( msg.wParam == dbch[0], "bad wparam %lx/%x\n", msg.wParam, dbch[0] );
10060 ok( PeekMessageA( &msg, 0, 0, 0, PM_REMOVE ), "no message\n" );
10061 ok( msg.hwnd == hwnd, "unexpected hwnd %p\n", msg.hwnd );
10062 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
10063 ok( msg.wParam == dbch[0], "bad wparam %lx/%x\n", msg.wParam, dbch[0] );
10064 ok( PeekMessageA( &msg, 0, 0, 0, PM_NOREMOVE ), "no message\n" );
10065 ok( msg.hwnd == hwnd, "unexpected hwnd %p\n", msg.hwnd );
10066 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
10067 ok( msg.wParam == dbch[1], "bad wparam %lx/%x\n", msg.wParam, dbch[0] );
10068 ok( PeekMessageA( &msg, 0, 0, 0, PM_REMOVE ), "no message\n" );
10069 ok( msg.hwnd == hwnd, "unexpected hwnd %p\n", msg.hwnd );
10070 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
10071 ok( msg.wParam == dbch[1], "bad wparam %lx/%x\n", msg.wParam, dbch[0] );
10072 ok( !PeekMessageA( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10074 DestroyWindow(hwnd);
10077 #define ID_LISTBOX 0x000f
10079 static const struct message wm_lb_setcursel_0[] =
10081 { LB_SETCURSEL, sent|wparam|lparam, 0, 0 },
10082 { WM_CTLCOLORLISTBOX, sent|parent },
10083 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_LISTBOX, 0x000120f2 },
10084 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 1 },
10085 { EVENT_OBJECT_SELECTION, winevent_hook|wparam|lparam, OBJID_CLIENT, 1 },
10086 { 0 }
10088 static const struct message wm_lb_setcursel_1[] =
10090 { LB_SETCURSEL, sent|wparam|lparam, 1, 0 },
10091 { WM_CTLCOLORLISTBOX, sent|parent },
10092 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_LISTBOX, 0x000020f2 },
10093 { WM_CTLCOLORLISTBOX, sent|parent },
10094 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_LISTBOX, 0x000121f2 },
10095 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 2 },
10096 { EVENT_OBJECT_SELECTION, winevent_hook|wparam|lparam, OBJID_CLIENT, 2 },
10097 { 0 }
10099 static const struct message wm_lb_setcursel_2[] =
10101 { LB_SETCURSEL, sent|wparam|lparam, 2, 0 },
10102 { WM_CTLCOLORLISTBOX, sent|parent },
10103 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_LISTBOX, 0x000021f2 },
10104 { WM_CTLCOLORLISTBOX, sent|parent },
10105 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_LISTBOX, 0x000122f2 },
10106 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 3 },
10107 { EVENT_OBJECT_SELECTION, winevent_hook|wparam|lparam, OBJID_CLIENT, 3 },
10108 { 0 }
10110 static const struct message wm_lb_click_0[] =
10112 { WM_LBUTTONDOWN, sent|wparam|lparam, 0, MAKELPARAM(1,1) },
10113 { HCBT_SETFOCUS, hook },
10114 { WM_KILLFOCUS, sent|parent },
10115 { WM_IME_SETCONTEXT, sent|wparam|optional|parent, 0 },
10116 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
10117 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
10118 { WM_SETFOCUS, sent|defwinproc },
10120 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_LISTBOX, 0x001142f2 },
10121 { WM_COMMAND, sent|wparam|parent, MAKEWPARAM(ID_LISTBOX, LBN_SETFOCUS) },
10122 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 3 },
10123 { WM_LBTRACKPOINT, sent|wparam|lparam|parent, 0, MAKELPARAM(1,1) },
10124 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
10126 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_LISTBOX, 0x000142f2 },
10127 { WM_CTLCOLORLISTBOX, sent|parent },
10128 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_LISTBOX, 0x000022f2 },
10129 { WM_CTLCOLORLISTBOX, sent|parent },
10130 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_LISTBOX, 0x000120f2 },
10131 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_LISTBOX, 0x001140f2 },
10133 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 1 },
10134 { EVENT_OBJECT_SELECTION, winevent_hook|wparam|lparam, OBJID_CLIENT, 1 },
10136 { WM_LBUTTONUP, sent|wparam|lparam, 0, 0 },
10137 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, 0, 0 },
10138 { WM_CAPTURECHANGED, sent|wparam|lparam|defwinproc, 0, 0 },
10139 { WM_COMMAND, sent|wparam|parent, MAKEWPARAM(ID_LISTBOX, LBN_SELCHANGE) },
10140 { 0 }
10143 #define check_lb_state(a1, a2, a3, a4, a5) check_lb_state_dbg(a1, a2, a3, a4, a5, __LINE__)
10145 static LRESULT (WINAPI *listbox_orig_proc)(HWND, UINT, WPARAM, LPARAM);
10147 static LRESULT WINAPI listbox_hook_proc(HWND hwnd, UINT message, WPARAM wp, LPARAM lp)
10149 static long defwndproc_counter = 0;
10150 LRESULT ret;
10151 struct message msg;
10153 /* do not log painting messages */
10154 if (message != WM_PAINT &&
10155 message != WM_NCPAINT &&
10156 message != WM_SYNCPAINT &&
10157 message != WM_ERASEBKGND &&
10158 message != WM_NCHITTEST &&
10159 message != WM_GETTEXT &&
10160 message != WM_GETICON &&
10161 message != WM_DEVICECHANGE)
10163 trace("listbox: %p, %04x, %08lx, %08lx\n", hwnd, message, wp, lp);
10165 msg.message = message;
10166 msg.flags = sent|wparam|lparam;
10167 if (defwndproc_counter) msg.flags |= defwinproc;
10168 msg.wParam = wp;
10169 msg.lParam = lp;
10170 add_message(&msg);
10173 defwndproc_counter++;
10174 ret = CallWindowProcA(listbox_orig_proc, hwnd, message, wp, lp);
10175 defwndproc_counter--;
10177 return ret;
10180 static void check_lb_state_dbg(HWND listbox, int count, int cur_sel,
10181 int caret_index, int top_index, int line)
10183 LRESULT ret;
10185 /* calling an orig proc helps to avoid unnecessary message logging */
10186 ret = CallWindowProcA(listbox_orig_proc, listbox, LB_GETCOUNT, 0, 0);
10187 ok_(__FILE__, line)(ret == count, "expected count %d, got %ld\n", count, ret);
10188 ret = CallWindowProcA(listbox_orig_proc, listbox, LB_GETCURSEL, 0, 0);
10189 ok_(__FILE__, line)(ret == cur_sel, "expected cur sel %d, got %ld\n", cur_sel, ret);
10190 ret = CallWindowProcA(listbox_orig_proc, listbox, LB_GETCARETINDEX, 0, 0);
10191 ok_(__FILE__, line)(ret == caret_index, "expected caret index %d, got %ld\n", caret_index, ret);
10192 ret = CallWindowProcA(listbox_orig_proc, listbox, LB_GETTOPINDEX, 0, 0);
10193 ok_(__FILE__, line)(ret == top_index, "expected top index %d, got %ld\n", top_index, ret);
10196 static void test_listbox_messages(void)
10198 HWND parent, listbox;
10199 LRESULT ret;
10201 parent = CreateWindowExA(0, "TestParentClass", NULL, WS_OVERLAPPEDWINDOW | WS_VISIBLE,
10202 100, 100, 200, 200, 0, 0, 0, NULL);
10203 listbox = CreateWindowExA(WS_EX_NOPARENTNOTIFY, "ListBox", NULL,
10204 WS_CHILD | LBS_NOTIFY | LBS_OWNERDRAWVARIABLE | LBS_HASSTRINGS | WS_VISIBLE,
10205 10, 10, 80, 80, parent, (HMENU)ID_LISTBOX, 0, NULL);
10206 listbox_orig_proc = (WNDPROC)SetWindowLongPtrA(listbox, GWLP_WNDPROC, (ULONG_PTR)listbox_hook_proc);
10208 check_lb_state(listbox, 0, LB_ERR, 0, 0);
10210 ret = SendMessage(listbox, LB_ADDSTRING, 0, (LPARAM)"item 0");
10211 ok(ret == 0, "expected 0, got %ld\n", ret);
10212 ret = SendMessage(listbox, LB_ADDSTRING, 0, (LPARAM)"item 1");
10213 ok(ret == 1, "expected 1, got %ld\n", ret);
10214 ret = SendMessage(listbox, LB_ADDSTRING, 0, (LPARAM)"item 2");
10215 ok(ret == 2, "expected 2, got %ld\n", ret);
10217 check_lb_state(listbox, 3, LB_ERR, 0, 0);
10219 flush_sequence();
10221 log_all_parent_messages++;
10223 trace("selecting item 0\n");
10224 ret = SendMessage(listbox, LB_SETCURSEL, 0, 0);
10225 ok(ret == 0, "expected 0, got %ld\n", ret);
10226 ok_sequence(wm_lb_setcursel_0, "LB_SETCURSEL 0", FALSE );
10227 check_lb_state(listbox, 3, 0, 0, 0);
10228 flush_sequence();
10230 trace("selecting item 1\n");
10231 ret = SendMessage(listbox, LB_SETCURSEL, 1, 0);
10232 ok(ret == 1, "expected 1, got %ld\n", ret);
10233 ok_sequence(wm_lb_setcursel_1, "LB_SETCURSEL 1", FALSE );
10234 check_lb_state(listbox, 3, 1, 1, 0);
10236 trace("selecting item 2\n");
10237 ret = SendMessage(listbox, LB_SETCURSEL, 2, 0);
10238 ok(ret == 2, "expected 2, got %ld\n", ret);
10239 ok_sequence(wm_lb_setcursel_2, "LB_SETCURSEL 2", FALSE );
10240 check_lb_state(listbox, 3, 2, 2, 0);
10242 trace("clicking on item 0\n");
10243 ret = SendMessage(listbox, WM_LBUTTONDOWN, 0, MAKELPARAM(1, 1));
10244 ok(ret == LB_OKAY, "expected LB_OKAY, got %ld\n", ret);
10245 ret = SendMessage(listbox, WM_LBUTTONUP, 0, 0);
10246 ok(ret == LB_OKAY, "expected LB_OKAY, got %ld\n", ret);
10247 ok_sequence(wm_lb_click_0, "WM_LBUTTONDOWN 0", FALSE );
10248 check_lb_state(listbox, 3, 0, 0, 0);
10249 flush_sequence();
10251 log_all_parent_messages--;
10253 DestroyWindow(listbox);
10254 DestroyWindow(parent);
10257 START_TEST(msg)
10259 BOOL ret;
10260 FARPROC pIsWinEventHookInstalled = 0;/*GetProcAddress(user32, "IsWinEventHookInstalled");*/
10262 init_procs();
10264 if (!RegisterWindowClasses()) assert(0);
10266 if (pSetWinEventHook)
10268 hEvent_hook = (HWINEVENTHOOK)pSetWinEventHook(EVENT_MIN, EVENT_MAX,
10269 GetModuleHandleA(0),
10270 win_event_proc,
10272 GetCurrentThreadId(),
10273 WINEVENT_INCONTEXT);
10274 assert(hEvent_hook);
10276 if (pIsWinEventHookInstalled)
10278 UINT event;
10279 for (event = EVENT_MIN; event <= EVENT_MAX; event++)
10280 ok(pIsWinEventHookInstalled(event), "IsWinEventHookInstalled(%u) failed\n", event);
10284 cbt_hook_thread_id = GetCurrentThreadId();
10285 hCBT_hook = SetWindowsHookExA(WH_CBT, cbt_hook_proc, 0, GetCurrentThreadId());
10286 assert(hCBT_hook);
10288 test_winevents();
10290 /* Fix message sequences before removing 4 lines below */
10291 #if 1
10292 if (pUnhookWinEvent && hEvent_hook)
10294 ret = pUnhookWinEvent(hEvent_hook);
10295 ok( ret, "UnhookWinEvent error %d\n", GetLastError());
10296 pUnhookWinEvent = 0;
10298 hEvent_hook = 0;
10299 #endif
10301 test_ShowWindow();
10302 test_PeekMessage();
10303 test_PeekMessage2();
10304 test_scrollwindowex();
10305 test_messages();
10306 test_showwindow();
10307 invisible_parent_tests();
10308 test_mdi_messages();
10309 test_button_messages();
10310 test_static_messages();
10311 test_listbox_messages();
10312 test_combobox_messages();
10313 test_paint_messages();
10314 test_interthread_messages();
10315 test_message_conversion();
10316 test_accelerators();
10317 test_timers();
10318 test_timers_no_wnd();
10319 test_set_hook();
10320 test_DestroyWindow();
10321 test_DispatchMessage();
10322 test_SendMessageTimeout();
10323 test_edit_messages();
10324 test_quit_message();
10326 if (!pTrackMouseEvent)
10327 skip("TrackMouseEvent is not available\n");
10328 else
10329 test_TrackMouseEvent();
10331 test_SetWindowRgn();
10332 test_sys_menu();
10333 test_dialog_messages();
10334 test_nullCallback();
10335 test_SetForegroundWindow();
10336 test_dbcs_wm_char();
10338 UnhookWindowsHookEx(hCBT_hook);
10339 if (pUnhookWinEvent)
10341 ret = pUnhookWinEvent(hEvent_hook);
10342 ok( ret, "UnhookWinEvent error %d\n", GetLastError());
10343 SetLastError(0xdeadbeef);
10344 ok(!pUnhookWinEvent(hEvent_hook), "UnhookWinEvent succeeded\n");
10345 ok(GetLastError() == ERROR_INVALID_HANDLE || /* Win2k */
10346 GetLastError() == 0xdeadbeef, /* Win9x */
10347 "unexpected error %d\n", GetLastError());
10349 else
10350 skip("UnhookWinEvent is not available\n");