[ADVAPI32_WINETEST] Revert service.c changes from 3c1b7834e1 to avoid testbot hangs...
[reactos.git] / modules / rostests / winetests / user32 / msg.c
1 /*
2 * Unit tests for window message handling
3 *
4 * Copyright 1999 Ove Kaaven
5 * Copyright 2003 Dimitrie O. Paun
6 * Copyright 2004,2005,2016 Dmitry Timoshkov
7 *
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.
12 *
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.
17 *
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
21 */
22
23 #include "precomp.h"
24
25 #include <dbt.h>
26
27 #define MDI_FIRST_CHILD_ID 2004
28
29 /* undocumented SWP flags - from SDK 3.1 */
30 #define SWP_NOCLIENTSIZE 0x0800
31 #define SWP_NOCLIENTMOVE 0x1000
32 #define SWP_STATECHANGED 0x8000
33
34 #define SW_NORMALNA 0xCC /* undoc. flag in MinMaximize */
35
36 #ifndef WM_KEYF1
37 #define WM_KEYF1 0x004d
38 #endif
39
40 #ifndef WM_SYSTIMER
41 #define WM_SYSTIMER 0x0118
42 #endif
43
44 #define WND_PARENT_ID 1
45 #define WND_POPUP_ID 2
46 #define WND_CHILD_ID 3
47
48 #ifndef WM_LBTRACKPOINT
49 #define WM_LBTRACKPOINT 0x0131
50 #endif
51
52 #ifdef __i386__
53 #define ARCH "x86"
54 #elif defined __x86_64__
55 #define ARCH "amd64"
56 #elif defined __arm__
57 #define ARCH "arm"
58 #elif defined __aarch64__
59 #define ARCH "arm64"
60 #else
61 #define ARCH "none"
62 #endif
63
64 static BOOL (WINAPI *pActivateActCtx)(HANDLE,ULONG_PTR*);
65 static HANDLE (WINAPI *pCreateActCtxW)(PCACTCTXW);
66 static BOOL (WINAPI *pDeactivateActCtx)(DWORD,ULONG_PTR);
67 static BOOL (WINAPI *pGetCurrentActCtx)(HANDLE *);
68 static BOOL (WINAPI *pQueryActCtxW)(DWORD,HANDLE,void*,ULONG,void*,SIZE_T,SIZE_T*);
69 static void (WINAPI *pReleaseActCtx)(HANDLE);
70
71 /* encoded DRAWITEMSTRUCT into an LPARAM */
72 typedef struct
73 {
74 union
75 {
76 struct
77 {
78 UINT type : 4; /* ODT_* flags */
79 UINT ctl_id : 4; /* Control ID */
80 UINT item_id : 4; /* Menu item ID */
81 UINT action : 4; /* ODA_* flags */
82 UINT state : 16; /* ODS_* flags */
83 } item;
84 LPARAM lp;
85 } u;
86 } DRAW_ITEM_STRUCT;
87
88 /* encoded MEASUREITEMSTRUCT into a WPARAM */
89 typedef struct
90 {
91 union
92 {
93 struct
94 {
95 UINT CtlType : 4;
96 UINT CtlID : 4;
97 UINT itemID : 4;
98 UINT wParam : 20;
99 } item;
100 WPARAM wp;
101 } u;
102 } MEASURE_ITEM_STRUCT;
103
104 static BOOL test_DestroyWindow_flag;
105 static HWINEVENTHOOK hEvent_hook;
106 static HHOOK hKBD_hook;
107 static HHOOK hCBT_hook;
108 static DWORD cbt_hook_thread_id;
109
110 static const WCHAR testWindowClassW[] =
111 { 'T','e','s','t','W','i','n','d','o','w','C','l','a','s','s','W',0 };
112
113 static LRESULT WINAPI ParentMsgCheckProcA(HWND, UINT, WPARAM, LPARAM);
114
115 /*
116 FIXME: add tests for these
117 Window Edge Styles (Win31/Win95/98 look), in order of precedence:
118 WS_EX_DLGMODALFRAME: double border, WS_CAPTION allowed
119 WS_THICKFRAME: thick border
120 WS_DLGFRAME: double border, WS_CAPTION not allowed (but possibly shown anyway)
121 WS_BORDER (default for overlapped windows): single black border
122 none (default for child (and popup?) windows): no border
123 */
124
125 typedef enum {
126 sent=0x1,
127 posted=0x2,
128 parent=0x4,
129 wparam=0x8,
130 lparam=0x10,
131 defwinproc=0x20,
132 beginpaint=0x40,
133 optional=0x80,
134 hook=0x100,
135 winevent_hook=0x200,
136 kbd_hook=0x400
137 } msg_flags_t;
138
139 struct message {
140 UINT message; /* the WM_* code */
141 msg_flags_t flags; /* message props */
142 WPARAM wParam; /* expected value of wParam */
143 LPARAM lParam; /* expected value of lParam */
144 WPARAM wp_mask; /* mask for wParam checks */
145 LPARAM lp_mask; /* mask for lParam checks */
146 };
147
148 struct recvd_message {
149 UINT message; /* the WM_* code */
150 msg_flags_t flags; /* message props */
151 HWND hwnd; /* window that received the message */
152 WPARAM wParam; /* expected value of wParam */
153 LPARAM lParam; /* expected value of lParam */
154 int line; /* source line where logged */
155 const char *descr; /* description for trace output */
156 char output[512]; /* trace output */
157 };
158
159 /* Empty message sequence */
160 static const struct message WmEmptySeq[] =
161 {
162 { 0 }
163 };
164 /* CreateWindow (for overlapped window, not initially visible) (16/32) */
165 static const struct message WmCreateOverlappedSeq[] = {
166 { HCBT_CREATEWND, hook },
167 { WM_GETMINMAXINFO, sent },
168 { WM_NCCREATE, sent },
169 { WM_NCCALCSIZE, sent|wparam, 0 },
170 { 0x0093, sent|defwinproc|optional },
171 { 0x0094, sent|defwinproc|optional },
172 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
173 { WM_CREATE, sent },
174 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
175 { 0 }
176 };
177 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
178 * for a not visible overlapped window.
179 */
180 static const struct message WmSWP_ShowOverlappedSeq[] = {
181 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
182 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
183 { WM_NCPAINT, sent|wparam|optional, 1 },
184 { WM_GETTEXT, sent|defwinproc|optional },
185 { WM_ERASEBKGND, sent|optional },
186 { HCBT_ACTIVATE, hook },
187 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
188 { WM_NOTIFYFORMAT, sent|optional },
189 { WM_QUERYUISTATE, sent|optional },
190 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
191 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* Win9x: SWP_NOSENDCHANGING */
192 { WM_ACTIVATEAPP, sent|wparam, 1 },
193 { WM_NCACTIVATE, sent },
194 { WM_GETTEXT, sent|defwinproc|optional },
195 { WM_ACTIVATE, sent|wparam, 1 },
196 { HCBT_SETFOCUS, hook },
197 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
198 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
199 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
200 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
201 { WM_GETTEXT, sent|optional },
202 { WM_NCPAINT, sent|wparam|optional, 1 },
203 { WM_GETTEXT, sent|defwinproc|optional },
204 { WM_ERASEBKGND, sent|optional },
205 /* Win9x adds SWP_NOZORDER below */
206 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
207 { WM_GETTEXT, sent|optional },
208 { WM_NCCALCSIZE, sent|wparam|optional, 1 },
209 { WM_NCPAINT, sent|wparam|optional, 1 },
210 { WM_ERASEBKGND, sent|optional },
211 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
212 { WM_SYNCPAINT, sent|optional },
213 { WM_GETTITLEBARINFOEX, sent|optional },
214 { WM_PAINT, sent|optional },
215 { WM_NCPAINT, sent|beginpaint|optional },
216 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
217 { WM_ERASEBKGND, sent|beginpaint|optional },
218 { 0 }
219 };
220 /* SetWindowPos(SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE)
221 * for a visible overlapped window.
222 */
223 static const struct message WmSWP_HideOverlappedSeq[] = {
224 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE },
225 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
226 { HCBT_ACTIVATE, hook|optional },
227 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE },
228 { WM_ACTIVATEAPP, sent|wparam|optional, 1 },
229 { WM_NCACTIVATE, sent|optional },
230 { WM_ACTIVATE, sent|optional },
231 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
232 { 0 }
233 };
234
235 /* SetWindowPos(SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOMOVE)
236 * for a visible overlapped window.
237 */
238 static const struct message WmSWP_ResizeSeq[] = {
239 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE },
240 { WM_GETMINMAXINFO, sent|defwinproc },
241 { WM_NCCALCSIZE, sent|wparam|optional, TRUE },
242 { WM_NCPAINT, sent|optional },
243 { WM_GETTEXT, sent|defwinproc|optional },
244 { WM_ERASEBKGND, sent|optional },
245 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOCLIENTMOVE },
246 { WM_SIZE, sent|defwinproc|optional },
247 { WM_NCCALCSIZE, sent|wparam|optional, TRUE },
248 { WM_NCPAINT, sent|optional },
249 { WM_GETTEXT, sent|defwinproc|optional },
250 { WM_ERASEBKGND, sent|optional },
251 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
252 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* XP sends a duplicate */
253 { 0 }
254 };
255
256 /* SetWindowPos(SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOMOVE)
257 * for a visible popup window.
258 */
259 static const struct message WmSWP_ResizePopupSeq[] = {
260 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE },
261 { WM_GETMINMAXINFO, sent|defwinproc|optional }, /* Win9x */
262 { WM_NCCALCSIZE, sent|wparam|optional, TRUE },
263 { WM_NCPAINT, sent|optional },
264 { WM_GETTEXT, sent|defwinproc|optional },
265 { WM_ERASEBKGND, sent|optional },
266 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOCLIENTMOVE },
267 { WM_SIZE, sent|defwinproc|wparam|optional, SIZE_RESTORED },
268 { WM_NCCALCSIZE, sent|wparam|optional, TRUE },
269 { WM_NCPAINT, sent|optional },
270 { WM_GETTEXT, sent|defwinproc|optional },
271 { WM_ERASEBKGND, sent|optional },
272 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
273 { 0 }
274 };
275
276 /* SetWindowPos(SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOSIZE)
277 * for a visible overlapped window.
278 */
279 static const struct message WmSWP_MoveSeq[] = {
280 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_NOSIZE },
281 { WM_NCPAINT, sent|optional },
282 { WM_GETTEXT, sent|defwinproc|optional },
283 { WM_ERASEBKGND, sent|optional },
284 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOCLIENTSIZE },
285 { WM_MOVE, sent|defwinproc|wparam, 0 },
286 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
287 { 0 }
288 };
289 /* Resize with SetWindowPos(SWP_NOZORDER)
290 * for a visible overlapped window
291 * SWP_NOZORDER is stripped by the logging code
292 */
293 static const struct message WmSWP_ResizeNoZOrder[] = {
294 { WM_WINDOWPOSCHANGING, sent|wparam, /*SWP_NOZORDER|*/SWP_NOACTIVATE },
295 { WM_GETMINMAXINFO, sent|defwinproc },
296 { WM_NCCALCSIZE, sent|wparam|optional, 1 },
297 { WM_NCPAINT, sent|optional },
298 { WM_GETTEXT, sent|defwinproc|optional },
299 { WM_ERASEBKGND, sent|optional },
300 { WM_WINDOWPOSCHANGED, sent|wparam|optional, /*SWP_NOZORDER|*/SWP_NOACTIVATE, 0,
301 SWP_NOMOVE|SWP_NOCLIENTMOVE|SWP_NOSIZE|SWP_NOCLIENTSIZE },
302 { WM_MOVE, sent|defwinproc|optional },
303 { WM_SIZE, sent|defwinproc|optional },
304 { WM_NCCALCSIZE, sent|wparam|optional, 1 }, /* Win9x doesn't send it */
305 { WM_NCPAINT, sent|optional }, /* Win9x doesn't send it */
306 { WM_GETTEXT, sent|defwinproc|optional }, /* Win9x doesn't send it */
307 { WM_ERASEBKGND, sent|optional }, /* Win9x doesn't send it */
308 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
309 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
310 { 0 }
311 };
312
313 /* Switch visible mdi children */
314 static const struct message WmSwitchChild[] = {
315 /* Switch MDI child */
316 { WM_MDIACTIVATE, sent },/* in the MDI client */
317 { WM_WINDOWPOSCHANGING, sent|wparam,SWP_NOSIZE|SWP_NOMOVE },/* in the 1st MDI child */
318 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
319 { WM_CHILDACTIVATE, sent },/* in the 1st MDI child */
320 /* Deactivate 2nd MDI child */
321 { WM_NCACTIVATE, sent|wparam|defwinproc, 0 }, /* in the 2nd MDI child */
322 { WM_MDIACTIVATE, sent|defwinproc }, /* in the 2nd MDI child */
323 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
324 /* Preparing for maximize and maximize the 1st MDI child */
325 { WM_GETMINMAXINFO, sent|defwinproc }, /* in the 1st MDI child */
326 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_STATECHANGED }, /* in the 1st MDI child */
327 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 }, /* in the 1st MDI child */
328 { WM_CHILDACTIVATE, sent|defwinproc }, /* in the 1st MDI child */
329 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOMOVE|SWP_NOCLIENTMOVE|SWP_STATECHANGED }, /* in the 1st MDI child */
330 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED }, /* in the 1st MDI child */
331 /* Lock redraw 2nd MDI child */
332 { WM_SETREDRAW, sent|wparam|defwinproc, 0 }, /* in the 2nd MDI child */
333 { HCBT_MINMAX, hook|lparam, 0, SW_NORMALNA },
334 /* Restore 2nd MDI child */
335 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_STATECHANGED },/* in the 2nd MDI child */
336 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 },/* in the 2nd MDI child */
337 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 }, /* in the 2nd MDI child */
338 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOMOVE|SWP_NOCLIENTMOVE|SWP_STATECHANGED }, /* in the 2nd MDI child */
339 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED }, /* in the 2nd MDI child */
340 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* in the 2nd MDI child */
341 /* Redraw 2nd MDI child */
342 { WM_SETREDRAW, sent|wparam|defwinproc, 1 },/* in the 2nd MDI child */
343 /* Redraw MDI frame */
344 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE },/* in MDI frame */
345 { WM_NCCALCSIZE, sent|wparam, 1 },/* in MDI frame */
346 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE}, /* in MDI frame */
347 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* in MDI frame */
348 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* in the 1st MDI child */
349 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE }, /* in the 1st MDI child */
350 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 }, /* in the 1st MDI child */
351 { HCBT_SETFOCUS, hook },
352 { WM_KILLFOCUS, sent|defwinproc }, /* in the 2nd MDI child */
353 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 0 },/* in the 1st MDI child */
354 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
355 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
356 { WM_SETFOCUS, sent },/* in the MDI client */
357 { HCBT_SETFOCUS, hook },
358 { WM_KILLFOCUS, sent },/* in the MDI client */
359 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
360 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 }, /* in the 1st MDI child */
361 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
362 { WM_SETFOCUS, sent|defwinproc }, /* in the 1st MDI child */
363 { WM_MDIACTIVATE, sent|defwinproc },/* in the 1st MDI child */
364 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE }, /* in the 1st MDI child */
365 { 0 }
366 };
367
368 /* Switch visible not maximized mdi children */
369 static const struct message WmSwitchNotMaximizedChild[] = {
370 /* Switch not maximized MDI child */
371 { WM_MDIACTIVATE, sent },/* in the MDI client */
372 { WM_WINDOWPOSCHANGING, sent|wparam,SWP_NOSIZE|SWP_NOMOVE },/* in the 2nd MDI child */
373 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
374 { WM_CHILDACTIVATE, sent },/* in the 2nd MDI child */
375 /* Deactivate 1st MDI child */
376 { WM_NCACTIVATE, sent|wparam|defwinproc, 0 }, /* in the 1st MDI child */
377 { WM_MDIACTIVATE, sent|defwinproc }, /* in the 1st MDI child */
378 /* Activate 2nd MDI child */
379 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE}, /* in the 2nd MDI child */
380 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 }, /* in the 2nd MDI child */
381 { HCBT_SETFOCUS, hook }, /* in the 1st MDI child */
382 { WM_KILLFOCUS, sent|defwinproc }, /* in the 1st MDI child */
383 { WM_IME_SETCONTEXT, sent|defwinproc|optional }, /* in the 1st MDI child */
384 { WM_IME_SETCONTEXT, sent|optional }, /* in the MDI client */
385 { WM_SETFOCUS, sent, 0 }, /* in the MDI client */
386 { HCBT_SETFOCUS, hook },
387 { WM_KILLFOCUS, sent }, /* in the MDI client */
388 { WM_IME_SETCONTEXT, sent|optional }, /* in the MDI client */
389 { WM_IME_SETCONTEXT, sent|defwinproc|optional }, /* in the 1st MDI child */
390 { WM_SETFOCUS, sent|defwinproc }, /* in the 2nd MDI child */
391 { WM_MDIACTIVATE, sent|defwinproc }, /* in the 2nd MDI child */
392 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE}, /* in the 2nd MDI child */
393 { 0 }
394 };
395
396
397 /* SetWindowPos(SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|
398 SWP_NOZORDER|SWP_FRAMECHANGED)
399 * for a visible overlapped window with WS_CLIPCHILDREN style set.
400 */
401 static const struct message WmSWP_FrameChanged_clip[] = {
402 { WM_WINDOWPOSCHANGING, sent|wparam|parent, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED },
403 { WM_NCCALCSIZE, sent|wparam|parent, 1 },
404 { WM_NCPAINT, sent|parent|optional }, /* wparam != 1 */
405 { WM_GETTEXT, sent|parent|defwinproc|optional },
406 { WM_ERASEBKGND, sent|parent|optional }, /* FIXME: remove optional once Wine is fixed */
407 { WM_NCPAINT, sent }, /* wparam != 1 */
408 { WM_ERASEBKGND, sent },
409 { WM_WINDOWPOSCHANGED, sent|wparam|parent, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
410 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
411 { WM_PAINT, sent },
412 { 0 }
413 };
414 /* SetWindowPos(SWP_NOSIZE|SWP_NOMOVE|SWP_DEFERERASE|SWP_NOACTIVATE|
415 SWP_NOZORDER|SWP_FRAMECHANGED)
416 * for a visible overlapped window.
417 */
418 static const struct message WmSWP_FrameChangedDeferErase[] = {
419 { WM_WINDOWPOSCHANGING, sent|wparam|parent, SWP_NOSIZE|SWP_NOMOVE|SWP_DEFERERASE|SWP_NOACTIVATE|SWP_FRAMECHANGED },
420 { WM_NCCALCSIZE, sent|wparam|parent, 1 },
421 { WM_WINDOWPOSCHANGED, sent|wparam|parent, SWP_NOSIZE|SWP_NOMOVE|SWP_DEFERERASE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
422 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
423 { WM_PAINT, sent|parent|optional },
424 { WM_NCPAINT, sent|beginpaint|parent|optional }, /* wparam != 1 */
425 { WM_GETTEXT, sent|beginpaint|parent|defwinproc|optional },
426 { WM_PAINT, sent },
427 { WM_NCPAINT, sent|beginpaint }, /* wparam != 1 */
428 { WM_ERASEBKGND, sent|beginpaint|optional },
429 { 0 }
430 };
431
432 /* SetWindowPos(SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|
433 SWP_NOZORDER|SWP_FRAMECHANGED)
434 * for a visible overlapped window without WS_CLIPCHILDREN style set.
435 */
436 static const struct message WmSWP_FrameChanged_noclip[] = {
437 { WM_WINDOWPOSCHANGING, sent|wparam|parent, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED },
438 { WM_NCCALCSIZE, sent|wparam|parent, 1 },
439 { WM_NCPAINT, sent|parent|optional }, /* wparam != 1 */
440 { WM_GETTEXT, sent|parent|defwinproc|optional },
441 { WM_ERASEBKGND, sent|parent|optional },
442 { WM_WINDOWPOSCHANGED, sent|wparam|parent, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
443 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
444 { WM_PAINT, sent },
445 { WM_NCPAINT, sent|beginpaint }, /* wparam != 1 */
446 { WM_ERASEBKGND, sent|beginpaint|optional },
447 { 0 }
448 };
449
450 /* ShowWindow(SW_SHOW) for a not visible overlapped window */
451 static const struct message WmShowOverlappedSeq[] = {
452 { WM_SHOWWINDOW, sent|wparam, 1 },
453 { WM_NCPAINT, sent|wparam|optional, 1 },
454 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
455 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
456 { WM_NCPAINT, sent|wparam|optional, 1 },
457 { WM_GETTEXT, sent|defwinproc|optional },
458 { WM_ERASEBKGND, sent|optional },
459 { HCBT_ACTIVATE, hook|optional },
460 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
461 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
462 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE },
463 { WM_NCPAINT, sent|wparam|optional, 1 },
464 { WM_ACTIVATEAPP, sent|wparam|optional, 1 },
465 { WM_NCACTIVATE, sent|wparam|optional, 1 },
466 { WM_GETTEXT, sent|defwinproc|optional },
467 { WM_ACTIVATE, sent|wparam|optional, 1 },
468 { HCBT_SETFOCUS, hook|optional },
469 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
470 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
471 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
472 { WM_SETFOCUS, sent|wparam|defwinproc|optional, 0 },
473 { WM_GETTEXT, sent|optional },
474 { WM_NCPAINT, sent|wparam|optional, 1 },
475 { WM_GETTEXT, sent|defwinproc|optional },
476 { WM_ERASEBKGND, sent|optional },
477 /* Win9x adds SWP_NOZORDER below */
478 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
479 { WM_NCCALCSIZE, sent|optional },
480 { WM_GETTEXT, sent|optional },
481 { WM_NCPAINT, sent|optional },
482 { WM_ERASEBKGND, sent|optional },
483 { WM_SYNCPAINT, sent|optional },
484 #if 0 /* CreateWindow/ShowWindow(SW_SHOW) also generates WM_SIZE/WM_MOVE
485 * messages. Does that mean that CreateWindow doesn't set initial
486 * window dimensions for overlapped windows?
487 */
488 { WM_SIZE, sent },
489 { WM_MOVE, sent },
490 #endif
491 { WM_PAINT, sent|optional },
492 { WM_NCPAINT, sent|beginpaint|optional },
493 { 0 }
494 };
495 /* ShowWindow(SW_SHOWMAXIMIZED) for a not visible overlapped window */
496 static const struct message WmShowMaxOverlappedSeq[] = {
497 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
498 { WM_GETMINMAXINFO, sent },
499 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_STATECHANGED },
500 { WM_GETMINMAXINFO, sent|defwinproc },
501 { WM_NCCALCSIZE, sent|wparam, TRUE },
502 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
503 { HCBT_ACTIVATE, hook|optional },
504 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
505 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
506 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE },
507 { WM_ACTIVATEAPP, sent|wparam|optional, 1 },
508 { WM_NCACTIVATE, sent|wparam|optional, 1 },
509 { WM_GETTEXT, sent|defwinproc|optional },
510 { WM_ACTIVATE, sent|wparam|optional, 1 },
511 { HCBT_SETFOCUS, hook|optional },
512 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
513 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
514 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
515 { WM_SETFOCUS, sent|wparam|defwinproc|optional, 0 },
516 { WM_GETTEXT, sent|optional },
517 { WM_NCPAINT, sent|wparam|optional, 1 },
518 { WM_GETTEXT, sent|defwinproc|optional },
519 { WM_ERASEBKGND, sent|optional },
520 /* Win9x adds SWP_NOZORDER below */
521 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_STATECHANGED },
522 { WM_MOVE, sent|defwinproc },
523 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
524 { WM_GETTEXT, sent|optional },
525 { WM_NCCALCSIZE, sent|optional },
526 { WM_NCPAINT, sent|optional },
527 { WM_ERASEBKGND, sent|optional },
528 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
529 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
530 { WM_SYNCPAINT, sent|optional },
531 { WM_GETTITLEBARINFOEX, sent|optional },
532 { WM_PAINT, sent|optional },
533 { WM_NCPAINT, sent|beginpaint|optional },
534 { WM_ERASEBKGND, sent|beginpaint|optional },
535 { 0 }
536 };
537 /* ShowWindow(SW_RESTORE) for a not visible maximized overlapped window */
538 static const struct message WmShowRestoreMaxOverlappedSeq[] = {
539 { HCBT_MINMAX, hook|lparam, 0, SW_RESTORE },
540 { WM_GETTEXT, sent|optional },
541 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_STATECHANGED },
542 { WM_GETMINMAXINFO, sent|defwinproc },
543 { WM_NCCALCSIZE, sent|wparam, TRUE },
544 { WM_NCPAINT, sent|optional },
545 { WM_GETTEXT, sent|defwinproc|optional },
546 { WM_ERASEBKGND, sent|optional },
547 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_STATECHANGED, 0, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOSIZE|SWP_NOMOVE },
548 { WM_MOVE, sent|defwinproc|optional },
549 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
550 { WM_NCCALCSIZE, sent|wparam|optional, TRUE },
551 { WM_NCPAINT, sent|optional },
552 { WM_ERASEBKGND, sent|optional },
553 { WM_PAINT, sent|optional },
554 { WM_GETTITLEBARINFOEX, sent|optional },
555 { WM_NCPAINT, sent|beginpaint|optional },
556 { WM_ERASEBKGND, sent|beginpaint|optional },
557 { 0 }
558 };
559 /* ShowWindow(SW_RESTORE) for a not visible minimized overlapped window */
560 static const struct message WmShowRestoreMinOverlappedSeq[] = {
561 { HCBT_MINMAX, hook|lparam, 0, SW_RESTORE },
562 { WM_QUERYOPEN, sent|optional },
563 { WM_GETTEXT, sent|optional },
564 { WM_NCACTIVATE, sent|wparam|optional, 1 },
565 { WM_WINDOWPOSCHANGING, sent|optional }, /* SWP_NOSIZE|SWP_NOMOVE */
566 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
567 { WM_NCCALCSIZE, sent|wparam|optional, TRUE },
568 { WM_MOVE, sent|optional },
569 { WM_SIZE, sent|wparam|optional, SIZE_RESTORED },
570 { WM_GETTEXT, sent|optional },
571 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_FRAMECHANGED|SWP_STATECHANGED|SWP_NOCOPYBITS },
572 { WM_GETMINMAXINFO, sent|defwinproc|optional },
573 { WM_NCCALCSIZE, sent|wparam|optional, TRUE },
574 { HCBT_ACTIVATE, hook|optional },
575 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
576 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE },
577 { WM_ACTIVATEAPP, sent|wparam|optional, 1 },
578 { WM_NCACTIVATE, sent|wparam|optional, 1 },
579 { WM_GETTEXT, sent|defwinproc|optional },
580 { WM_ACTIVATE, sent|wparam|optional, 1 },
581 { HCBT_SETFOCUS, hook|optional },
582 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
583 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
584 { WM_SETFOCUS, sent|wparam|defwinproc|optional, 0 },
585 { WM_GETTEXT, sent|optional },
586 { WM_NCPAINT, sent|wparam|optional, 1 },
587 { WM_GETTEXT, sent|defwinproc|optional },
588 { WM_ERASEBKGND, sent },
589 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_STATECHANGED|SWP_FRAMECHANGED|SWP_NOCOPYBITS },
590 { WM_MOVE, sent|defwinproc },
591 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
592 { HCBT_SETFOCUS, hook|optional },
593 { WM_SETFOCUS, sent|wparam|optional, 0 },
594 { WM_NCCALCSIZE, sent|wparam|optional, TRUE },
595 { WM_NCPAINT, sent|wparam|optional, 1 },
596 { WM_ERASEBKGND, sent|optional },
597 { HCBT_SETFOCUS, hook|optional },
598 { WM_SETFOCUS, sent|wparam|optional, 0 },
599 { WM_ACTIVATE, sent|wparam, 1 },
600 { WM_GETTEXT, sent|optional },
601 { WM_PAINT, sent|optional },
602 { WM_GETTITLEBARINFOEX, sent|optional },
603 { WM_NCPAINT, sent|beginpaint|optional },
604 { WM_ERASEBKGND, sent|beginpaint|optional },
605 { 0 }
606 };
607 /* ShowWindow(SW_SHOWMINIMIZED) for a not visible overlapped window */
608 static const struct message WmShowMinOverlappedSeq[] = {
609 { HCBT_MINMAX, hook|lparam, 0, SW_MINIMIZE },
610 { HCBT_SETFOCUS, hook|optional },
611 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
612 { WM_KILLFOCUS, sent|optional },
613 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
614 { WM_IME_NOTIFY, sent|wparam|optional|defwinproc, 1 },
615 { WM_GETTEXT, sent|optional },
616 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOCOPYBITS|SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_STATECHANGED },
617 { WM_GETMINMAXINFO, sent|defwinproc },
618 { WM_NCCALCSIZE, sent|wparam, TRUE },
619 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
620 { WM_NCPAINT, sent|optional },
621 { WM_GETTEXT, sent|defwinproc|optional },
622 { WM_WINDOWPOSCHANGED, sent },
623 { WM_MOVE, sent|defwinproc },
624 { WM_SIZE, sent|defwinproc|wparam|lparam, SIZE_MINIMIZED, 0 },
625 { WM_NCCALCSIZE, sent|optional },
626 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
627 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
628 { EVENT_SYSTEM_MINIMIZESTART, winevent_hook|wparam|lparam, 0, 0 },
629 { WM_NCACTIVATE, sent|wparam|optional, 0 },
630 { WM_GETTEXT, sent|defwinproc|optional },
631 { WM_ACTIVATE, sent|optional },
632 { WM_ACTIVATEAPP, sent|wparam|optional, 0 },
633
634 /* Vista sometimes restores the window right away... */
635 { WM_SYSCOMMAND, sent|optional|wparam, SC_RESTORE },
636 { HCBT_SYSCOMMAND, hook|optional|wparam, SC_RESTORE },
637 { HCBT_MINMAX, hook|optional|lparam, 0, SW_RESTORE },
638 { WM_QUERYOPEN, sent|optional },
639 { WM_WINDOWPOSCHANGING, sent|optional|wparam, SWP_FRAMECHANGED|SWP_STATECHANGED },
640 { WM_GETMINMAXINFO, sent|optional|defwinproc },
641 { WM_NCCALCSIZE, sent|optional|wparam, TRUE },
642 { HCBT_ACTIVATE, hook|optional },
643 { WM_ACTIVATEAPP, sent|optional|wparam, 1 },
644 { WM_NCACTIVATE, sent|optional },
645 { WM_GETTEXT, sent|optional },
646 { WM_ACTIVATE, sent|optional|wparam, 1 },
647 { HCBT_SETFOCUS, hook|optional },
648 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
649 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
650 { WM_SETFOCUS, sent|optional },
651 { WM_NCPAINT, sent|optional },
652 { WM_GETTEXT, sent|defwinproc|optional },
653 { WM_ERASEBKGND, sent|optional },
654 { WM_WINDOWPOSCHANGED, sent|optional|wparam, SWP_FRAMECHANGED|SWP_STATECHANGED },
655 { WM_MOVE, sent|defwinproc|optional },
656 { WM_SIZE, sent|defwinproc|optional|wparam, SIZE_RESTORED },
657 { WM_ACTIVATE, sent|optional|wparam, 1 },
658 { WM_SYSCOMMAND, sent|optional|wparam, SC_RESTORE },
659 { HCBT_SYSCOMMAND, hook|optional|wparam, SC_RESTORE },
660
661 { WM_PAINT, sent|optional },
662 { WM_NCPAINT, sent|beginpaint|optional },
663 { WM_ERASEBKGND, sent|beginpaint|optional },
664 { 0 }
665 };
666 /* ShowWindow(SW_HIDE) for a visible overlapped window */
667 static const struct message WmHideOverlappedSeq[] = {
668 { WM_SHOWWINDOW, sent|wparam, 0 },
669 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE },
670 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
671 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
672 { WM_SIZE, sent|optional }, /* XP doesn't send it */
673 { WM_MOVE, sent|optional }, /* XP doesn't send it */
674 { WM_NCACTIVATE, sent|wparam|optional, 0 },
675 { WM_ACTIVATE, sent|wparam|optional, 0 },
676 { WM_ACTIVATEAPP, sent|wparam|optional, 0 },
677 { HCBT_SETFOCUS, hook|optional },
678 { WM_KILLFOCUS, sent|wparam|optional, 0 },
679 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
680 { WM_IME_NOTIFY, sent|wparam|optional|defwinproc, 1 },
681 { 0 }
682 };
683 /* DestroyWindow for a visible overlapped window */
684 static const struct message WmDestroyOverlappedSeq[] = {
685 { HCBT_DESTROYWND, hook },
686 { 0x0090, sent|optional },
687 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
688 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
689 { 0x0090, sent|optional },
690 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
691 { WM_NCACTIVATE, sent|optional|wparam, 0 },
692 { WM_ACTIVATE, sent|optional },
693 { WM_ACTIVATEAPP, sent|optional|wparam, 0 },
694 { WM_KILLFOCUS, sent|optional|wparam, 0 },
695 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
696 { WM_IME_NOTIFY, sent|wparam|optional|defwinproc, 1 },
697 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
698 { WM_DESTROY, sent },
699 { WM_NCDESTROY, sent },
700 { 0 }
701 };
702 /* CreateWindow(WS_MAXIMIZE|WS_VISIBLE) for popup window */
703 static const struct message WmCreateMaxPopupSeq[] = {
704 { HCBT_CREATEWND, hook },
705 { WM_NCCREATE, sent },
706 { WM_NCCALCSIZE, sent|wparam, 0 },
707 { WM_CREATE, sent },
708 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
709 { WM_SIZE, sent|wparam, SIZE_RESTORED },
710 { WM_MOVE, sent },
711 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
712 { WM_GETMINMAXINFO, sent },
713 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_STATECHANGED },
714 { WM_NCCALCSIZE, sent|wparam, TRUE },
715 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOREDRAW|SWP_STATECHANGED },
716 { WM_MOVE, sent|defwinproc },
717 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
718 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
719 { WM_SHOWWINDOW, sent|wparam, 1 },
720 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
721 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
722 { HCBT_ACTIVATE, hook },
723 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
724 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
725 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE },
726 { WM_NCPAINT, sent|wparam|optional, 1 },
727 { WM_ERASEBKGND, sent|optional },
728 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_NOCLIENTMOVE|SWP_NOCLIENTSIZE|SWP_NOMOVE|SWP_NOSIZE },
729 { WM_ACTIVATEAPP, sent|wparam, 1 },
730 { WM_NCACTIVATE, sent },
731 { WM_ACTIVATE, sent|wparam, 1 },
732 { HCBT_SETFOCUS, hook },
733 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
734 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
735 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
736 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
737 { WM_GETTEXT, sent|optional },
738 { WM_SYNCPAINT, sent|wparam|optional, 4 },
739 { WM_NCPAINT, sent|wparam|optional, 1 },
740 { WM_ERASEBKGND, sent|optional },
741 { WM_NCPAINT, sent|wparam|defwinproc|optional, 1 },
742 { WM_ERASEBKGND, sent|defwinproc|optional },
743 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOCLIENTMOVE|SWP_NOCLIENTSIZE|SWP_SHOWWINDOW|SWP_NOMOVE|SWP_NOSIZE },
744 { 0 }
745 };
746 /* CreateWindow(WS_MAXIMIZE) for popup window, not initially visible */
747 static const struct message WmCreateInvisibleMaxPopupSeq[] = {
748 { HCBT_CREATEWND, hook },
749 { WM_NCCREATE, sent },
750 { WM_NCCALCSIZE, sent|wparam, 0 },
751 { WM_CREATE, sent },
752 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
753 { WM_SIZE, sent|wparam, SIZE_RESTORED },
754 { WM_MOVE, sent },
755 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
756 { WM_GETMINMAXINFO, sent },
757 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_STATECHANGED },
758 { WM_NCCALCSIZE, sent|wparam, TRUE },
759 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOREDRAW|SWP_STATECHANGED },
760 { WM_MOVE, sent|defwinproc },
761 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
762 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
763 { 0 }
764 };
765 /* ShowWindow(SW_SHOWMAXIMIZED) for a resized not visible popup window */
766 static const struct message WmShowMaxPopupResizedSeq_todo[] = {
767 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
768 { WM_GETMINMAXINFO, sent },
769 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED },
770 { WM_NCCALCSIZE, sent|wparam, TRUE },
771 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
772 { HCBT_ACTIVATE, hook },
773 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
774 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
775 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE },
776 { WM_NCPAINT, sent|wparam|optional, 1 },
777 { WM_ERASEBKGND, sent|optional },
778 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
779 { WM_ACTIVATEAPP, sent|wparam, 1 },
780 { WM_NCACTIVATE, sent },
781 { WM_ACTIVATE, sent|wparam, 1 },
782 { HCBT_SETFOCUS, hook },
783 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
784 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
785 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
786 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
787 { WM_GETTEXT, sent|optional },
788 { WM_NCPAINT, sent|wparam|optional, 1 },
789 { WM_ERASEBKGND, sent|optional },
790 { WM_WINDOWPOSCHANGED, sent },
791 /* WinNT4.0 sends WM_MOVE */
792 { WM_MOVE, sent|defwinproc|optional },
793 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
794 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
795 { 0 }
796 };
797 static const struct message WmShowMaxPopupResizedSeq[] = {
798 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
799 { WM_GETMINMAXINFO, sent },
800 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED },
801 { WM_NCCALCSIZE, sent|wparam, TRUE },
802 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
803 { HCBT_ACTIVATE, hook },
804 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
805 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
806 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE },
807 { WM_NCPAINT, sent|wparam|optional, 1 },
808 { WM_ERASEBKGND, sent|optional },
809 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
810 { WM_ACTIVATEAPP, sent|wparam, 1 },
811 { WM_NCACTIVATE, sent },
812 { WM_ACTIVATE, sent|wparam, 1 },
813 { HCBT_SETFOCUS, hook },
814 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
815 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
816 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
817 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
818 { WM_GETTEXT, sent|optional },
819 { WM_NCPAINT, sent|optional }, /* We'll check WM_NCPAINT behaviour in another test */
820 { WM_ERASEBKGND, sent|optional },
821 { WM_WINDOWPOSCHANGED, sent },
822 /* WinNT4.0 sends WM_MOVE */
823 { WM_MOVE, sent|defwinproc|optional },
824 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
825 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
826 { 0 }
827 };
828 /* ShowWindow(SW_SHOWMAXIMIZED) for a not visible popup window */
829 static const struct message WmShowMaxPopupSeq[] = {
830 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
831 { WM_GETMINMAXINFO, sent },
832 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED },
833 { WM_NCCALCSIZE, sent|wparam, TRUE },
834 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
835 { HCBT_ACTIVATE, hook },
836 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
837 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
838 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE },
839 { WM_NCPAINT, sent|wparam|optional, 1 },
840 { WM_ERASEBKGND, sent|optional },
841 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOMOVE|SWP_NOSIZE },
842 { WM_ACTIVATEAPP, sent|wparam, 1 },
843 { WM_NCACTIVATE, sent },
844 { WM_ACTIVATE, sent|wparam, 1 },
845 { HCBT_SETFOCUS, hook },
846 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
847 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
848 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
849 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
850 { WM_GETTEXT, sent|optional },
851 { WM_SYNCPAINT, sent|wparam|optional, 4 },
852 { WM_NCPAINT, sent|wparam|optional, 1 },
853 { WM_ERASEBKGND, sent|optional },
854 { WM_NCPAINT, sent|wparam|defwinproc|optional, 1 },
855 { WM_ERASEBKGND, sent|defwinproc|optional },
856 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOMOVE|SWP_NOSIZE },
857 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
858 { 0 }
859 };
860 /* CreateWindow(WS_VISIBLE) for popup window */
861 static const struct message WmCreatePopupSeq[] = {
862 { HCBT_CREATEWND, hook },
863 { WM_NCCREATE, sent },
864 { WM_NCCALCSIZE, sent|wparam, 0 },
865 { WM_CREATE, sent },
866 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
867 { WM_SIZE, sent|wparam, SIZE_RESTORED },
868 { WM_MOVE, sent },
869 { WM_SHOWWINDOW, sent|wparam, 1 },
870 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
871 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
872 { HCBT_ACTIVATE, hook },
873 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
874 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
875 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE },
876 { WM_NCPAINT, sent|wparam|optional, 1 },
877 { WM_ERASEBKGND, sent|optional },
878 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
879 { WM_ACTIVATEAPP, sent|wparam, 1 },
880 { WM_NCACTIVATE, sent },
881 { WM_ACTIVATE, sent|wparam, 1 },
882 { HCBT_SETFOCUS, hook },
883 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
884 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
885 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
886 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
887 { WM_GETTEXT, sent|optional },
888 { WM_SYNCPAINT, sent|wparam|optional, 4 },
889 { WM_NCPAINT, sent|wparam|optional, 1 },
890 { WM_ERASEBKGND, sent|optional },
891 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOCLIENTMOVE|SWP_NOCLIENTSIZE|SWP_SHOWWINDOW|SWP_NOMOVE|SWP_NOSIZE },
892 { 0 }
893 };
894 /* ShowWindow(SW_SHOWMAXIMIZED) for a visible popup window */
895 static const struct message WmShowVisMaxPopupSeq[] = {
896 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
897 { WM_GETMINMAXINFO, sent },
898 { WM_GETTEXT, sent|optional },
899 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_STATECHANGED },
900 { WM_GETTEXT, sent|optional },
901 { WM_NCCALCSIZE, sent|wparam, TRUE },
902 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
903 { WM_NCPAINT, sent|wparam|optional, 1 },
904 { WM_ERASEBKGND, sent|optional },
905 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_STATECHANGED },
906 { WM_MOVE, sent|defwinproc },
907 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
908 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
909 { 0 }
910 };
911 /* CreateWindow (for a child popup window, not initially visible) */
912 static const struct message WmCreateChildPopupSeq[] = {
913 { HCBT_CREATEWND, hook },
914 { WM_NCCREATE, sent },
915 { WM_NCCALCSIZE, sent|wparam, 0 },
916 { WM_CREATE, sent },
917 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
918 { WM_SIZE, sent|wparam, SIZE_RESTORED },
919 { WM_MOVE, sent },
920 { 0 }
921 };
922 /* CreateWindow (for a popup window, not initially visible,
923 * which sets WS_VISIBLE in WM_CREATE handler)
924 */
925 static const struct message WmCreateInvisiblePopupSeq[] = {
926 { HCBT_CREATEWND, hook },
927 { WM_NCCREATE, sent },
928 { WM_NCCALCSIZE, sent|wparam, 0 },
929 { WM_CREATE, sent },
930 { WM_STYLECHANGING, sent },
931 { WM_STYLECHANGED, sent },
932 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
933 { WM_SIZE, sent|wparam, SIZE_RESTORED },
934 { WM_MOVE, sent },
935 { 0 }
936 };
937 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER)
938 * for a popup window with WS_VISIBLE style set
939 */
940 static const struct message WmShowVisiblePopupSeq_2[] = {
941 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
942 { 0 }
943 };
944 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
945 * for a popup window with WS_VISIBLE style set
946 */
947 static const struct message WmShowVisiblePopupSeq_3[] = {
948 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
949 { HCBT_ACTIVATE, hook },
950 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
951 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
952 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE },
953 { WM_NCACTIVATE, sent },
954 { WM_ACTIVATE, sent|wparam, 1 },
955 { HCBT_SETFOCUS, hook },
956 { WM_KILLFOCUS, sent|parent },
957 { WM_IME_SETCONTEXT, sent|parent|wparam|optional, 0 },
958 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
959 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
960 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
961 { WM_SETFOCUS, sent|defwinproc },
962 { WM_GETTEXT, sent|optional },
963 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE, 0, SWP_SHOWWINDOW },
964 { 0 }
965 };
966 /* CreateWindow (for a popup window with WS_VISIBLE style set and extreme location)
967 */
968 static const struct message WmShowPopupExtremeLocationSeq[] = {
969 { HCBT_CREATEWND, hook },
970 { WM_NCCREATE, sent },
971 { WM_NCCALCSIZE, sent|wparam, 0 },
972 { WM_CREATE, sent },
973 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
974 { WM_SIZE, sent|wparam, SIZE_RESTORED },
975 { WM_MOVE, sent },
976 { WM_SHOWWINDOW, sent|wparam, 1 },
977 { WM_WINDOWPOSCHANGING, sent },
978 { HCBT_ACTIVATE, hook },
979 { WM_WINDOWPOSCHANGING, sent|optional },
980 { WM_QUERYNEWPALETTE, sent|optional },
981 { WM_ACTIVATEAPP, sent },
982 { WM_NCACTIVATE, sent },
983 { WM_ACTIVATE, sent },
984 { WM_IME_SETCONTEXT, sent|parent|wparam|optional, 0 },
985 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
986 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
987 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
988 { HCBT_SETFOCUS, hook },
989 { WM_SETFOCUS, sent|defwinproc },
990 { WM_NCPAINT, sent|wparam, 1 },
991 { WM_ERASEBKGND, sent },
992 { WM_WINDOWPOSCHANGED, sent },
993 /* occasionally received on test machines */
994 { WM_NCPAINT, sent|optional },
995 { WM_ERASEBKGND, sent|optional },
996 { 0 }
997 };
998 /* CreateWindow (for a popup window with WS_VISIBLE style set)
999 */
1000 static const struct message WmShowPopupFirstDrawSeq_1[] = {
1001 { HCBT_CREATEWND, hook },
1002 { WM_NCCREATE, sent },
1003 { WM_NCCALCSIZE, sent|wparam, 0 },
1004 { WM_CREATE, sent },
1005 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1006 { WM_SIZE, sent|wparam, SIZE_RESTORED },
1007 { WM_MOVE, sent },
1008 { WM_SHOWWINDOW, sent|wparam, 1 },
1009 { WM_WINDOWPOSCHANGING, sent },
1010 { HCBT_ACTIVATE, hook },
1011 { WM_WINDOWPOSCHANGING, sent|optional },
1012 { WM_QUERYNEWPALETTE, sent|optional },
1013 { WM_ACTIVATEAPP, sent },
1014 { WM_NCACTIVATE, sent },
1015 { WM_ACTIVATE, sent },
1016 { WM_IME_SETCONTEXT, sent|parent|wparam|optional, 0 },
1017 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
1018 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
1019 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1020 { HCBT_SETFOCUS, hook },
1021 { WM_SETFOCUS, sent|defwinproc },
1022 { WM_NCPAINT, sent|wparam, 1 },
1023 { WM_ERASEBKGND, sent },
1024 { WM_WINDOWPOSCHANGED, sent },
1025 { WM_PAINT, sent },
1026 /* occasionally received on test machines */
1027 { WM_NCPAINT, sent|beginpaint|optional },
1028 { WM_ERASEBKGND, sent|beginpaint|optional },
1029 { 0 }
1030 };
1031 /* CreateWindow (for a popup window that is shown with ShowWindow(SW_SHOWMAXIMIZED))
1032 */
1033 static const struct message WmShowPopupFirstDrawSeq_2[] = {
1034 { HCBT_CREATEWND, hook },
1035 { WM_NCCREATE, sent },
1036 { WM_NCCALCSIZE, sent|wparam, 0 },
1037 { WM_CREATE, sent },
1038 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1039 { WM_SIZE, sent|wparam, SIZE_RESTORED },
1040 { WM_MOVE, sent },
1041 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
1042 { WM_GETMINMAXINFO, sent },
1043 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_STATECHANGED|SWP_SHOWWINDOW|SWP_FRAMECHANGED },
1044 { WM_NCCALCSIZE, sent|wparam, TRUE },
1045 { HCBT_ACTIVATE, hook },
1046 { WM_WINDOWPOSCHANGING, sent|optional },
1047 { WM_NCPAINT, sent|optional|wparam, 1 },
1048 { WM_ERASEBKGND, sent|optional },
1049 { WM_WINDOWPOSCHANGED, sent|optional },
1050 { WM_QUERYNEWPALETTE, sent|optional },
1051 { WM_ACTIVATEAPP, sent },
1052 { WM_NCACTIVATE, sent },
1053 { WM_ACTIVATE, sent },
1054 { WM_IME_SETCONTEXT, sent|parent|wparam|optional, 0 },
1055 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
1056 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
1057 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1058 { HCBT_SETFOCUS, hook },
1059 { WM_SETFOCUS, sent|defwinproc },
1060 { WM_NCPAINT, sent|wparam, 1 },
1061 { WM_ERASEBKGND, sent },
1062 { WM_WINDOWPOSCHANGED, sent|optional },
1063 { WM_MOVE, sent|defwinproc },
1064 { WM_SIZE, sent|defwinproc, 0 },
1065 { WM_PAINT, sent},
1066 /* occasionally received on test machines */
1067 { WM_NCPAINT, sent|beginpaint|optional },
1068 { WM_ERASEBKGND, sent|beginpaint|optional },
1069 { 0 }
1070 };
1071 static const struct message WmFirstDrawSetWindowPosSeq1[] = {
1072 { HCBT_CREATEWND, hook },
1073 { WM_NCCREATE, sent },
1074 { WM_NCCALCSIZE, sent|wparam, 0 },
1075 { WM_CREATE, sent },
1076 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1077 { WM_SIZE, sent|wparam, SIZE_RESTORED },
1078 { WM_MOVE, sent },
1079 { WM_WINDOWPOSCHANGING, sent },
1080 { HCBT_ACTIVATE, hook },
1081 { WM_WINDOWPOSCHANGING, sent|optional },
1082 { WM_QUERYNEWPALETTE, sent|optional },
1083 { WM_ACTIVATEAPP, sent },
1084 { WM_NCACTIVATE, sent },
1085 { WM_ACTIVATE, sent },
1086 { WM_IME_SETCONTEXT, sent|parent|wparam|optional, 0 },
1087 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
1088 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
1089 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1090 { HCBT_SETFOCUS, hook },
1091 { WM_SETFOCUS, sent|defwinproc },
1092 { WM_NCPAINT, sent|wparam, 1 },
1093 { WM_ERASEBKGND, sent },
1094 { WM_WINDOWPOSCHANGED, sent },
1095 { WM_MOVE, sent|defwinproc },
1096 { 0 }
1097 };
1098 static const struct message WmFirstDrawSetWindowPosSeq2[] = {
1099 { HCBT_CREATEWND, hook },
1100 { WM_NCCREATE, sent },
1101 { WM_NCCALCSIZE, sent|wparam, 0 },
1102 { WM_CREATE, sent },
1103 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1104 { WM_SIZE, sent|wparam, SIZE_RESTORED },
1105 { WM_MOVE, sent },
1106 { WM_WINDOWPOSCHANGING, sent },
1107 { HCBT_ACTIVATE, hook },
1108 { WM_QUERYNEWPALETTE, sent|optional },
1109 { WM_WINDOWPOSCHANGING, sent|optional },
1110 { WM_ACTIVATEAPP, sent },
1111 { WM_NCACTIVATE, sent },
1112 { WM_ACTIVATE, sent },
1113 { WM_IME_SETCONTEXT, sent|parent|wparam|optional, 0 },
1114 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
1115 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
1116 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1117 { HCBT_SETFOCUS, hook },
1118 { WM_SETFOCUS, sent|defwinproc },
1119 { WM_WINDOWPOSCHANGED, sent },
1120 { WM_MOVE, sent|defwinproc },
1121 { 0 }
1122 };
1123 static const struct message WmFirstDrawSetWindowPosSeq3[] = {
1124 { HCBT_CREATEWND, hook },
1125 { WM_NCCREATE, sent },
1126 { WM_NCCALCSIZE, sent|wparam, 0 },
1127 { WM_CREATE, sent },
1128 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1129 { WM_SIZE, sent|wparam, SIZE_RESTORED },
1130 { WM_MOVE, sent },
1131 { HCBT_ACTIVATE, hook|optional },
1132 /* Probably shouldn't happen, but not part of this test */
1133 { WM_QUERYNEWPALETTE, sent|optional },
1134 { WM_ACTIVATEAPP, sent|optional },
1135 { WM_NCACTIVATE, sent|optional },
1136 { WM_ACTIVATE, sent|optional },
1137 { HCBT_SETFOCUS, hook|optional },
1138 { WM_SETFOCUS, sent|defwinproc|optional },
1139 { 0 }
1140 };
1141 static const struct message WmFirstDrawSetWindowPosSeq4[] = {
1142 { HCBT_CREATEWND, hook },
1143 { WM_NCCREATE, sent },
1144 { WM_NCCALCSIZE, sent|wparam, 0 },
1145 { WM_CREATE, sent },
1146 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1147 { WM_SIZE, sent|wparam, SIZE_RESTORED },
1148 { WM_MOVE, sent },
1149 { WM_WINDOWPOSCHANGING, sent },
1150 { HCBT_ACTIVATE, hook },
1151 { WM_WINDOWPOSCHANGING, sent|optional },
1152 { WM_QUERYNEWPALETTE, sent|optional },
1153 { WM_ACTIVATEAPP, sent },
1154 { WM_NCACTIVATE, sent },
1155 { WM_ACTIVATE, sent },
1156 { WM_IME_SETCONTEXT, sent|parent|wparam|optional, 0 },
1157 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
1158 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
1159 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1160 { HCBT_SETFOCUS, hook },
1161 { WM_SETFOCUS, sent|defwinproc },
1162 { WM_NCPAINT, sent|wparam, 1 },
1163 { WM_ERASEBKGND, sent },
1164 { WM_WINDOWPOSCHANGED, sent },
1165 { 0 }
1166 };
1167 static const struct message WmFirstDrawSetWindowPosSeq5[] = {
1168 { HCBT_CREATEWND, hook },
1169 { WM_NCCREATE, sent },
1170 { WM_NCCALCSIZE, sent|wparam, 0 },
1171 { WM_CREATE, sent },
1172 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1173 { WM_SIZE, sent|wparam, SIZE_RESTORED },
1174 { WM_MOVE, sent },
1175 { WM_WINDOWPOSCHANGING, sent },
1176 { HCBT_ACTIVATE, hook },
1177 { WM_WINDOWPOSCHANGING, sent|optional },
1178 { WM_QUERYNEWPALETTE, sent|optional },
1179 { WM_ACTIVATEAPP, sent },
1180 { WM_NCACTIVATE, sent },
1181 { WM_ACTIVATE, sent },
1182 { WM_IME_SETCONTEXT, sent|parent|wparam|optional, 0 },
1183 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
1184 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
1185 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1186 { HCBT_SETFOCUS, hook },
1187 { WM_SETFOCUS, sent|defwinproc },
1188 { WM_WINDOWPOSCHANGED, sent },
1189 { 0 }
1190 };
1191 static const struct message WmFirstDrawChildSeq1[] = {
1192 { 0 }
1193 };
1194 static const struct message WmFirstDrawChildSeq2[] = {
1195 { WM_NCPAINT, sent|wparam, 1 },
1196 { WM_ERASEBKGND, sent },
1197 /* occasionally received on test machines */
1198 { WM_NCPAINT, sent|optional },
1199 { WM_ERASEBKGND, sent|optional },
1200 { 0 }
1201 };
1202 /* CreateWindow (for child window, not initially visible) */
1203 static const struct message WmCreateChildSeq[] = {
1204 { HCBT_CREATEWND, hook },
1205 { WM_NCCREATE, sent },
1206 /* child is inserted into parent's child list after WM_NCCREATE returns */
1207 { WM_NCCALCSIZE, sent|wparam, 0 },
1208 { WM_CREATE, sent },
1209 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1210 { WM_SIZE, sent|wparam, SIZE_RESTORED },
1211 { WM_MOVE, sent },
1212 { WM_PARENTNOTIFY, sent|parent|wparam, WM_CREATE },
1213 { 0 }
1214 };
1215 /* CreateWindow (for maximized child window, not initially visible) */
1216 static const struct message WmCreateMaximizedChildSeq[] = {
1217 { HCBT_CREATEWND, hook },
1218 { WM_NCCREATE, sent },
1219 { WM_NCCALCSIZE, sent|wparam, 0 },
1220 { WM_CREATE, sent },
1221 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1222 { WM_SIZE, sent|wparam, SIZE_RESTORED },
1223 { WM_MOVE, sent },
1224 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
1225 { WM_GETMINMAXINFO, sent },
1226 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_STATECHANGED },
1227 { WM_NCCALCSIZE, sent|wparam, 1 },
1228 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTMOVE|SWP_STATECHANGED },
1229 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
1230 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1231 { WM_PARENTNOTIFY, sent|parent|wparam, WM_CREATE },
1232 { 0 }
1233 };
1234 /* CreateWindow (for a child window, initially visible) */
1235 static const struct message WmCreateVisibleChildSeq[] = {
1236 { HCBT_CREATEWND, hook },
1237 { WM_NCCREATE, sent },
1238 /* child is inserted into parent's child list after WM_NCCREATE returns */
1239 { WM_NCCALCSIZE, sent|wparam, 0 },
1240 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
1241 { WM_CREATE, sent },
1242 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1243 { WM_SIZE, sent|wparam, SIZE_RESTORED },
1244 { WM_MOVE, sent },
1245 { WM_PARENTNOTIFY, sent|parent|wparam, WM_CREATE },
1246 { WM_SHOWWINDOW, sent|wparam, 1 },
1247 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
1248 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1249 { WM_ERASEBKGND, sent|parent|optional },
1250 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1251 { WM_NCCALCSIZE, sent|wparam|optional, 1 }, /* WinXP */
1252 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1253 { 0 }
1254 };
1255 /* ShowWindow(SW_SHOW) for a not visible child window */
1256 static const struct message WmShowChildSeq[] = {
1257 { WM_SHOWWINDOW, sent|wparam, 1 },
1258 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1259 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1260 { WM_ERASEBKGND, sent|parent|optional },
1261 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1262 { 0 }
1263 };
1264 /* ShowWindow(SW_HIDE) for a visible child window */
1265 static const struct message WmHideChildSeq[] = {
1266 { WM_SHOWWINDOW, sent|wparam, 0 },
1267 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1268 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
1269 { WM_ERASEBKGND, sent|parent|optional },
1270 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1271 { 0 }
1272 };
1273 /* ShowWindow(SW_HIDE) for a visible child window checking all parent events*/
1274 static const struct message WmHideChildSeq2[] = {
1275 { WM_SHOWWINDOW, sent|wparam, 0 },
1276 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1277 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
1278 { WM_ERASEBKGND, sent|parent|optional },
1279 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1280 { 0 }
1281 };
1282 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
1283 * for a not visible child window
1284 */
1285 static const struct message WmShowChildSeq_2[] = {
1286 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
1287 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1288 { WM_CHILDACTIVATE, sent },
1289 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1290 { 0 }
1291 };
1292 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE)
1293 * for a not visible child window
1294 */
1295 static const struct message WmShowChildSeq_3[] = {
1296 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
1297 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1298 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1299 { 0 }
1300 };
1301 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
1302 * for a visible child window with a caption
1303 */
1304 static const struct message WmShowChildSeq_4[] = {
1305 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
1306 { WM_CHILDACTIVATE, sent },
1307 { 0 }
1308 };
1309 /* ShowWindow(SW_MINIMIZE) for child with invisible parent */
1310 static const struct message WmShowChildInvisibleParentSeq_1[] = {
1311 { HCBT_MINMAX, hook|lparam, 0, SW_MINIMIZE },
1312 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED, 0, SWP_NOACTIVATE },
1313 { WM_NCCALCSIZE, sent|wparam, 1 },
1314 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1315 { WM_CHILDACTIVATE, sent|optional },
1316 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOREDRAW|SWP_NOCOPYBITS|SWP_STATECHANGED, 0, SWP_NOACTIVATE },
1317 { WM_MOVE, sent|defwinproc },
1318 { WM_SIZE, sent|defwinproc|wparam|lparam, SIZE_MINIMIZED, 0 },
1319 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1320 { EVENT_SYSTEM_MINIMIZESTART, winevent_hook|wparam|lparam, 0, 0 },
1321 /* FIXME: Wine creates an icon/title window while Windows doesn't */
1322 { WM_PARENTNOTIFY, sent|parent|wparam|optional, WM_CREATE },
1323 { WM_GETTEXT, sent|optional },
1324 { 0 }
1325 };
1326 /* repeated ShowWindow(SW_MINIMIZE) for child with invisible parent */
1327 static const struct message WmShowChildInvisibleParentSeq_1r[] = {
1328 { HCBT_MINMAX, hook|lparam, 0, SW_MINIMIZE },
1329 { 0 }
1330 };
1331 /* ShowWindow(SW_MAXIMIZE) for child with invisible parent */
1332 static const struct message WmShowChildInvisibleParentSeq_2[] = {
1333 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
1334 { WM_GETMINMAXINFO, sent },
1335 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_STATECHANGED },
1336 { WM_NCCALCSIZE, sent|wparam, 1 },
1337 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1338 { WM_CHILDACTIVATE, sent },
1339 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTMOVE|SWP_STATECHANGED },
1340 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
1341 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1342 { 0 }
1343 };
1344 /* repeated ShowWindow(SW_MAXIMIZE) for child with invisible parent */
1345 static const struct message WmShowChildInvisibleParentSeq_2r[] = {
1346 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
1347 { 0 }
1348 };
1349 /* ShowWindow(SW_SHOWMINIMIZED) for child with invisible parent */
1350 static const struct message WmShowChildInvisibleParentSeq_3[] = {
1351 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMINIMIZED },
1352 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
1353 { WM_NCCALCSIZE, sent|wparam, 1 },
1354 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1355 { WM_CHILDACTIVATE, sent },
1356 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOREDRAW|SWP_NOCOPYBITS|SWP_STATECHANGED },
1357 { WM_MOVE, sent|defwinproc },
1358 { WM_SIZE, sent|defwinproc|wparam|lparam, SIZE_MINIMIZED, 0 },
1359 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1360 { EVENT_SYSTEM_MINIMIZESTART, winevent_hook|wparam|lparam, 0, 0 },
1361 /* FIXME: Wine creates an icon/title window while Windows doesn't */
1362 { WM_PARENTNOTIFY, sent|parent|wparam|optional, WM_CREATE },
1363 { WM_GETTEXT, sent|optional },
1364 { 0 }
1365 };
1366 /* repeated ShowWindow(SW_SHOWMINIMIZED) for child with invisible parent */
1367 static const struct message WmShowChildInvisibleParentSeq_3r[] = {
1368 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMINIMIZED },
1369 { 0 }
1370 };
1371 /* ShowWindow(SW_SHOWMINNOACTIVE) for child with invisible parent */
1372 static const struct message WmShowChildInvisibleParentSeq_4[] = {
1373 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMINNOACTIVE },
1374 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOCOPYBITS|SWP_STATECHANGED },
1375 { WM_NCCALCSIZE, sent|wparam, 1 },
1376 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1377 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOREDRAW|SWP_NOCOPYBITS|SWP_STATECHANGED },
1378 { WM_MOVE, sent|defwinproc },
1379 { WM_SIZE, sent|defwinproc|wparam|lparam, SIZE_MINIMIZED, 0 },
1380 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1381 { EVENT_SYSTEM_MINIMIZESTART, winevent_hook|wparam|lparam, 0, 0 },
1382 /* FIXME: Wine creates an icon/title window while Windows doesn't */
1383 { WM_PARENTNOTIFY, sent|parent|wparam|optional, WM_CREATE },
1384 { WM_GETTEXT, sent|optional },
1385 { 0 }
1386 };
1387 /* repeated ShowWindow(SW_SHOWMINNOACTIVE) for child with invisible parent */
1388 static const struct message WmShowChildInvisibleParentSeq_4r[] = {
1389 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMINNOACTIVE },
1390 { 0 }
1391 };
1392 /* ShowWindow(SW_SHOW) for child with invisible parent */
1393 static const struct message WmShowChildInvisibleParentSeq_5[] = {
1394 { WM_SHOWWINDOW, sent|wparam, 1 },
1395 { 0 }
1396 };
1397 /* ShowWindow(SW_HIDE) for child with invisible parent */
1398 static const struct message WmHideChildInvisibleParentSeq[] = {
1399 { WM_SHOWWINDOW, sent|wparam, 0 },
1400 { 0 }
1401 };
1402 /* SetWindowPos(SWP_SHOWWINDOW) for child with invisible parent */
1403 static const struct message WmShowChildInvisibleParentSeq_6[] = {
1404 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
1405 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1406 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1407 { 0 }
1408 };
1409 /* SetWindowPos(SWP_HIDEWINDOW) for child with invisible parent */
1410 static const struct message WmHideChildInvisibleParentSeq_2[] = {
1411 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1412 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
1413 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1414 { 0 }
1415 };
1416 /* DestroyWindow for a visible child window */
1417 static const struct message WmDestroyChildSeq[] = {
1418 { HCBT_DESTROYWND, hook },
1419 { 0x0090, sent|optional },
1420 { WM_PARENTNOTIFY, sent|parent|wparam, WM_DESTROY },
1421 { WM_SHOWWINDOW, sent|wparam, 0 },
1422 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1423 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
1424 { WM_ERASEBKGND, sent|parent|optional },
1425 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1426 { HCBT_SETFOCUS, hook }, /* set focus to a parent */
1427 { WM_KILLFOCUS, sent },
1428 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
1429 { WM_IME_SETCONTEXT, sent|wparam|parent|optional, 1 },
1430 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1431 { WM_SETFOCUS, sent|parent },
1432 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
1433 { WM_DESTROY, sent },
1434 { WM_DESTROY, sent|optional }, /* some other (IME?) window */
1435 { WM_NCDESTROY, sent|optional }, /* some other (IME?) window */
1436 { WM_NCDESTROY, sent },
1437 { 0 }
1438 };
1439 /* visible child window destroyed by thread exit */
1440 static const struct message WmExitThreadSeq[] = {
1441 { WM_NCDESTROY, sent }, /* actually in grandchild */
1442 { WM_PAINT, sent|parent },
1443 { WM_ERASEBKGND, sent|parent|beginpaint },
1444 { 0 }
1445 };
1446 /* DestroyWindow for a visible child window with invisible parent */
1447 static const struct message WmDestroyInvisibleChildSeq[] = {
1448 { HCBT_DESTROYWND, hook },
1449 { 0x0090, sent|optional },
1450 { WM_PARENTNOTIFY, sent|parent|wparam, WM_DESTROY },
1451 { WM_SHOWWINDOW, sent|wparam, 0 },
1452 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
1453 { WM_DESTROY, sent },
1454 { WM_NCDESTROY, sent },
1455 { 0 }
1456 };
1457 /* Resizing child window with MoveWindow (32) */
1458 static const struct message WmResizingChildWithMoveWindowSeq[] = {
1459 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE },
1460 { WM_NCCALCSIZE, sent|wparam, 1 },
1461 { WM_ERASEBKGND, sent|parent|optional },
1462 { WM_ERASEBKGND, sent|optional },
1463 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE },
1464 { WM_MOVE, sent|defwinproc },
1465 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
1466 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1467 { 0 }
1468 };
1469 /* Creation of a custom dialog (32) */
1470 static const struct message WmCreateCustomDialogSeq[] = {
1471 { HCBT_CREATEWND, hook },
1472 { WM_GETMINMAXINFO, sent },
1473 { WM_NCCREATE, sent },
1474 { WM_NCCALCSIZE, sent|wparam, 0 },
1475 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
1476 { WM_CREATE, sent },
1477 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1478 { WM_NOTIFYFORMAT, sent|optional },
1479 { WM_QUERYUISTATE, sent|optional },
1480 { WM_WINDOWPOSCHANGING, sent|optional },
1481 { WM_GETMINMAXINFO, sent|optional },
1482 { WM_NCCALCSIZE, sent|optional },
1483 { WM_WINDOWPOSCHANGED, sent|optional },
1484 { WM_SHOWWINDOW, sent|wparam, 1 },
1485 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
1486 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1487 { HCBT_ACTIVATE, hook },
1488 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
1489
1490
1491 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
1492
1493 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE },
1494
1495 { WM_NCACTIVATE, sent },
1496 { WM_GETTEXT, sent|optional|defwinproc },
1497 { WM_GETTEXT, sent|optional|defwinproc },
1498 { WM_GETTEXT, sent|optional|defwinproc },
1499 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
1500 { WM_ACTIVATE, sent|wparam, 1 },
1501 { WM_GETTEXT, sent|optional },
1502 { WM_KILLFOCUS, sent|parent },
1503 { WM_IME_SETCONTEXT, sent|parent|wparam|optional, 0 },
1504 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
1505 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
1506 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1507 { WM_SETFOCUS, sent },
1508 { WM_GETDLGCODE, sent|defwinproc|wparam, 0 },
1509 { WM_NCPAINT, sent|wparam, 1 },
1510 { WM_GETTEXT, sent|optional|defwinproc },
1511 { WM_GETTEXT, sent|optional|defwinproc },
1512 { WM_ERASEBKGND, sent },
1513 { WM_CTLCOLORDLG, sent|optional|defwinproc },
1514 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1515 { WM_GETTEXT, sent|optional },
1516 { WM_GETTEXT, sent|optional },
1517 { WM_NCCALCSIZE, sent|optional },
1518 { WM_NCPAINT, sent|optional },
1519 { WM_GETTEXT, sent|optional|defwinproc },
1520 { WM_GETTEXT, sent|optional|defwinproc },
1521 { WM_ERASEBKGND, sent|optional },
1522 { WM_CTLCOLORDLG, sent|optional|defwinproc },
1523 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1524 { WM_SIZE, sent|wparam, SIZE_RESTORED },
1525 { WM_MOVE, sent },
1526 { 0 }
1527 };
1528 /* Calling EndDialog for a custom dialog (32) */
1529 static const struct message WmEndCustomDialogSeq[] = {
1530 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1531 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
1532 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1533 { WM_GETTEXT, sent|optional },
1534 { HCBT_ACTIVATE, hook },
1535 { WM_NCACTIVATE, sent|wparam, 0 },
1536 { WM_GETTEXT, sent|optional|defwinproc },
1537 { WM_GETTEXT, sent|optional|defwinproc },
1538 { WM_ACTIVATE, sent|wparam, 0 },
1539 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
1540 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1541 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_NOACTIVATE|SWP_NOREDRAW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1542 { WM_GETTEXT, sent|optional|defwinproc },
1543 { WM_GETTEXT, sent|optional|defwinproc },
1544 { HCBT_SETFOCUS, hook },
1545 { WM_KILLFOCUS, sent },
1546 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
1547 { WM_IME_SETCONTEXT, sent|parent|wparam|defwinproc|optional, 1 },
1548 { WM_IME_NOTIFY, sent|wparam|optional, 1 },
1549 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1550 { WM_SETFOCUS, sent|parent|defwinproc },
1551 { 0 }
1552 };
1553 /* ShowWindow(SW_SHOW) for a custom dialog (initially invisible) */
1554 static const struct message WmShowCustomDialogSeq[] = {
1555 { WM_SHOWWINDOW, sent|wparam, 1 },
1556 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
1557 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1558 { HCBT_ACTIVATE, hook },
1559 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
1560
1561 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
1562
1563 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE },
1564 { WM_ACTIVATEAPP, sent|wparam|optional, 1 },
1565 { WM_NCACTIVATE, sent },
1566 { WM_ACTIVATE, sent|wparam, 1 },
1567 { WM_GETTEXT, sent|optional },
1568
1569 { WM_KILLFOCUS, sent|parent },
1570 { WM_IME_SETCONTEXT, sent|parent|wparam|optional, 0 },
1571 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
1572 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
1573 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1574 { WM_SETFOCUS, sent },
1575 { WM_GETDLGCODE, sent|defwinproc|wparam, 0 },
1576 { WM_NCPAINT, sent|wparam, 1 },
1577 { WM_ERASEBKGND, sent },
1578 { WM_CTLCOLORDLG, sent|defwinproc },
1579 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1580 { 0 }
1581 };
1582 /* Creation and destruction of a modal dialog (32) */
1583 static const struct message WmModalDialogSeq[] = {
1584 { WM_CANCELMODE, sent|parent },
1585 { HCBT_SETFOCUS, hook },
1586 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1587 { WM_KILLFOCUS, sent|parent },
1588 { WM_IME_SETCONTEXT, sent|parent|wparam|optional, 0 },
1589 { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, 0, 0 },
1590 { WM_ENABLE, sent|parent|wparam, 0 },
1591 { HCBT_CREATEWND, hook },
1592 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
1593 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1594 { WM_SETFONT, sent },
1595 { WM_INITDIALOG, sent },
1596 { WM_CHANGEUISTATE, sent|optional },
1597 { WM_UPDATEUISTATE, sent|optional },
1598 { WM_SHOWWINDOW, sent },
1599 { HCBT_ACTIVATE, hook },
1600 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
1601 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
1602 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE },
1603 { WM_NCACTIVATE, sent },
1604 { WM_GETTEXT, sent|optional },
1605 { WM_ACTIVATE, sent|wparam, 1 },
1606 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
1607 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1608 { WM_NCPAINT, sent|optional },
1609 { WM_GETTEXT, sent|optional },
1610 { WM_ERASEBKGND, sent|optional },
1611 { WM_CTLCOLORDLG, sent|optional },
1612 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1613 { WM_GETTEXT, sent|optional },
1614 { WM_NCCALCSIZE, sent|optional },
1615 { WM_NCPAINT, sent|optional },
1616 { WM_GETTEXT, sent|optional },
1617 { WM_ERASEBKGND, sent|optional },
1618 { WM_CTLCOLORDLG, sent|optional },
1619 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1620 { WM_PAINT, sent|optional },
1621 { WM_CTLCOLORBTN, sent|optional },
1622 { WM_GETTITLEBARINFOEX, sent|optional },
1623 { WM_ENTERIDLE, sent|parent|optional },
1624 { WM_ENTERIDLE, sent|parent|optional },
1625 { WM_ENTERIDLE, sent|parent|optional },
1626 { WM_ENTERIDLE, sent|parent|optional },
1627 { WM_ENTERIDLE, sent|parent|optional },
1628 { WM_ENTERIDLE, sent|parent|optional },
1629 { WM_ENTERIDLE, sent|parent|optional },
1630 { WM_ENTERIDLE, sent|parent|optional },
1631 { WM_ENTERIDLE, sent|parent|optional },
1632 { WM_ENTERIDLE, sent|parent|optional },
1633 { WM_ENTERIDLE, sent|parent|optional },
1634 { WM_ENTERIDLE, sent|parent|optional },
1635 { WM_ENTERIDLE, sent|parent|optional },
1636 { WM_ENTERIDLE, sent|parent|optional },
1637 { WM_ENTERIDLE, sent|parent|optional },
1638 { WM_ENTERIDLE, sent|parent|optional },
1639 { WM_ENTERIDLE, sent|parent|optional },
1640 { WM_ENTERIDLE, sent|parent|optional },
1641 { WM_ENTERIDLE, sent|parent|optional },
1642 { WM_ENTERIDLE, sent|parent|optional },
1643 { WM_TIMER, sent },
1644 { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, 0, 0 },
1645 { WM_ENABLE, sent|parent|wparam, 1 },
1646 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
1647 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
1648 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1649 { WM_GETTEXT, sent|optional },
1650 { HCBT_ACTIVATE, hook },
1651 { WM_NCACTIVATE, sent|wparam, 0 },
1652 { WM_GETTEXT, sent|optional },
1653 { WM_ACTIVATE, sent|wparam, 0 },
1654 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
1655 { WM_WINDOWPOSCHANGING, sent|optional },
1656 { WM_WINDOWPOSCHANGED, sent|optional },
1657 { HCBT_SETFOCUS, hook },
1658 { WM_IME_SETCONTEXT, sent|parent|wparam|defwinproc|optional, 1 },
1659 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1660 { WM_SETFOCUS, sent|parent|defwinproc },
1661 { EVENT_SYSTEM_DIALOGEND, winevent_hook|wparam|lparam, 0, 0 },
1662 { HCBT_DESTROYWND, hook },
1663 { 0x0090, sent|optional },
1664 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
1665 { WM_DESTROY, sent },
1666 { WM_NCDESTROY, sent },
1667 { 0 }
1668 };
1669 static const struct message WmModalDialogSeq_2[] = {
1670 { WM_CANCELMODE, sent },
1671 { HCBT_SETFOCUS, hook },
1672 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1673 { WM_KILLFOCUS, sent },
1674 { WM_IME_SETCONTEXT, sent|parent|wparam|optional, 0 },
1675 { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, 0, 0 },
1676 { WM_ENABLE, sent|wparam, 0 },
1677 { HCBT_CREATEWND, hook },
1678 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
1679 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1680 { WM_SETFONT, sent },
1681 { WM_INITDIALOG, sent },
1682 { WM_CHANGEUISTATE, sent|optional },
1683 { WM_UPDATEUISTATE, sent|optional },
1684 { WM_ENABLE, sent|wparam, 1 },
1685 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
1686 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
1687 { WM_CHANGEUISTATE, sent|optional },
1688 { WM_UPDATEUISTATE, sent|optional },
1689 { HCBT_DESTROYWND, hook },
1690 { 0x0090, sent|optional },
1691 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
1692 { WM_DESTROY, sent },
1693 { WM_NCDESTROY, sent },
1694 { 0 }
1695 };
1696 /* SetMenu for NonVisible windows with size change*/
1697 static const struct message WmSetMenuNonVisibleSizeChangeSeq[] = {
1698 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1699 { WM_NCCALCSIZE, sent|wparam, 1 },
1700 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
1701 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW },
1702 { WM_MOVE, sent|defwinproc },
1703 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
1704 { WM_NCCALCSIZE,sent|wparam|optional, 1 }, /* XP */
1705 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1706 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* XP sends a duplicate */
1707 { WM_GETTEXT, sent|optional },
1708 { WM_NCCALCSIZE, sent|wparam|optional, 1 },
1709 { 0 }
1710 };
1711 /* SetMenu for NonVisible windows with no size change */
1712 static const struct message WmSetMenuNonVisibleNoSizeChangeSeq[] = {
1713 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1714 { WM_NCCALCSIZE, sent|wparam, 1 },
1715 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1716 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1717 { 0 }
1718 };
1719 /* SetMenu for Visible windows with size change */
1720 static const struct message WmSetMenuVisibleSizeChangeSeq[] = {
1721 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1722 { WM_NCCALCSIZE, sent|wparam, 1 },
1723 { 0x0093, sent|defwinproc|optional },
1724 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
1725 { WM_NCPAINT, sent|optional }, /* wparam != 1 */
1726 { 0x0093, sent|defwinproc|optional },
1727 { 0x0093, sent|defwinproc|optional },
1728 { 0x0091, sent|defwinproc|optional },
1729 { 0x0092, sent|defwinproc|optional },
1730 { WM_GETTEXT, sent|defwinproc|optional },
1731 { WM_ERASEBKGND, sent|optional },
1732 { WM_ACTIVATE, sent|optional },
1733 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1734 { WM_MOVE, sent|defwinproc },
1735 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
1736 { 0x0093, sent|optional },
1737 { WM_NCCALCSIZE, sent|wparam|optional, 1 },
1738 { 0x0093, sent|defwinproc|optional },
1739 { WM_NCPAINT, sent|optional }, /* wparam != 1 */
1740 { 0x0093, sent|defwinproc|optional },
1741 { 0x0093, sent|defwinproc|optional },
1742 { 0x0091, sent|defwinproc|optional },
1743 { 0x0092, sent|defwinproc|optional },
1744 { WM_ERASEBKGND, sent|optional },
1745 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1746 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* XP sends a duplicate */
1747 { 0 }
1748 };
1749 /* SetMenu for Visible windows with no size change */
1750 static const struct message WmSetMenuVisibleNoSizeChangeSeq[] = {
1751 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1752 { WM_NCCALCSIZE, sent|wparam, 1 },
1753 { WM_NCPAINT, sent|optional }, /* wparam != 1 */
1754 { WM_GETTEXT, sent|defwinproc|optional },
1755 { WM_ERASEBKGND, sent|optional },
1756 { WM_ACTIVATE, sent|optional },
1757 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1758 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1759 { 0 }
1760 };
1761 /* DrawMenuBar for a visible window */
1762 static const struct message WmDrawMenuBarSeq[] =
1763 {
1764 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1765 { WM_NCCALCSIZE, sent|wparam, 1 },
1766 { 0x0093, sent|defwinproc|optional },
1767 { WM_NCPAINT, sent|optional }, /* wparam != 1 */
1768 { 0x0093, sent|defwinproc|optional },
1769 { 0x0093, sent|defwinproc|optional },
1770 { 0x0091, sent|defwinproc|optional },
1771 { 0x0092, sent|defwinproc|optional },
1772 { WM_GETTEXT, sent|defwinproc|optional },
1773 { WM_ERASEBKGND, sent|optional },
1774 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1775 { 0x0093, sent|optional },
1776 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1777 { 0 }
1778 };
1779
1780 static const struct message WmSetRedrawFalseSeq[] =
1781 {
1782 { WM_SETREDRAW, sent|wparam, 0 },
1783 { 0 }
1784 };
1785
1786 static const struct message WmSetRedrawTrueSeq[] =
1787 {
1788 { WM_SETREDRAW, sent|wparam, 1 },
1789 { 0 }
1790 };
1791
1792 static const struct message WmEnableWindowSeq_1[] =
1793 {
1794 { WM_CANCELMODE, sent|wparam|lparam, 0, 0 },
1795 { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, 0, 0 },
1796 { HCBT_SETFOCUS, hook|optional },
1797 { WM_KILLFOCUS, sent|optional },
1798 { WM_ENABLE, sent|wparam|lparam, FALSE, 0 },
1799 { 0 }
1800 };
1801
1802 static const struct message WmEnableWindowSeq_2[] =
1803 {
1804 { WM_CANCELMODE, sent|wparam|lparam, 0, 0 },
1805 { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, 0, 0 },
1806 { 0 }
1807 };
1808
1809 static const struct message WmEnableWindowSeq_3[] =
1810 {
1811 { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, 0, 0 },
1812 { WM_ENABLE, sent|wparam|lparam, TRUE, 0 },
1813 { 0 }
1814 };
1815
1816 static const struct message WmEnableWindowSeq_4[] =
1817 {
1818 { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, 0, 0 },
1819 { 0 }
1820 };
1821
1822 static const struct message WmGetScrollRangeSeq[] =
1823 {
1824 { SBM_GETRANGE, sent },
1825 { 0 }
1826 };
1827 static const struct message WmGetScrollInfoSeq[] =
1828 {
1829 { SBM_GETSCROLLINFO, sent },
1830 { 0 }
1831 };
1832 static const struct message WmSetScrollRangeSeq[] =
1833 {
1834 /* MSDN claims that Windows sends SBM_SETRANGE message, but win2k SP4
1835 sends SBM_SETSCROLLINFO.
1836 */
1837 { SBM_SETSCROLLINFO, sent },
1838 { 0 }
1839 };
1840 /* SetScrollRange for a window without a non-client area */
1841 static const struct message WmSetScrollRangeHSeq_empty[] =
1842 {
1843 { EVENT_OBJECT_VALUECHANGE, winevent_hook|wparam|lparam, OBJID_HSCROLL, 0 },
1844 { 0 }
1845 };
1846 static const struct message WmSetScrollRangeVSeq_empty[] =
1847 {
1848 { EVENT_OBJECT_VALUECHANGE, winevent_hook|wparam|lparam, OBJID_VSCROLL, 0 },
1849 { 0 }
1850 };
1851 static const struct message WmSetScrollRangeHVSeq[] =
1852 {
1853 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE },
1854 { WM_NCCALCSIZE, sent|wparam, 1 },
1855 { WM_GETTEXT, sent|defwinproc|optional },
1856 { WM_ERASEBKGND, sent|optional },
1857 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1858 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1859 { EVENT_OBJECT_VALUECHANGE, winevent_hook|lparam|optional, 0/*OBJID_HSCROLL or OBJID_VSCROLL*/, 0 },
1860 { 0 }
1861 };
1862 /* SetScrollRange for a window with a non-client area */
1863 static const struct message WmSetScrollRangeHV_NC_Seq[] =
1864 {
1865 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE },
1866 { WM_NCCALCSIZE, sent|wparam, 1 },
1867 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
1868 { WM_NCPAINT, sent|optional },
1869 { WM_STYLECHANGING, sent|defwinproc|optional },
1870 { WM_STYLECHANGED, sent|defwinproc|optional },
1871 { WM_STYLECHANGING, sent|defwinproc|optional },
1872 { WM_STYLECHANGED, sent|defwinproc|optional },
1873 { WM_STYLECHANGING, sent|defwinproc|optional },
1874 { WM_STYLECHANGED, sent|defwinproc|optional },
1875 { WM_STYLECHANGING, sent|defwinproc|optional },
1876 { WM_STYLECHANGED, sent|defwinproc|optional },
1877 { WM_GETTEXT, sent|defwinproc|optional },
1878 { WM_GETTEXT, sent|defwinproc|optional },
1879 { WM_ERASEBKGND, sent|optional },
1880 { WM_CTLCOLORDLG, sent|defwinproc|optional }, /* sent to a parent of the dialog */
1881 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE|SWP_NOCLIENTMOVE, 0, SWP_NOCLIENTSIZE },
1882 { WM_SIZE, sent|defwinproc|optional },
1883 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1884 { EVENT_OBJECT_VALUECHANGE, winevent_hook|lparam|optional, 0/*OBJID_HSCROLL or OBJID_VSCROLL*/, 0 },
1885 { WM_GETTEXT, sent|optional },
1886 { WM_GETTEXT, sent|optional },
1887 { WM_GETTEXT, sent|optional },
1888 { WM_GETTEXT, sent|optional },
1889 { 0 }
1890 };
1891 /* test if we receive the right sequence of messages */
1892 /* after calling ShowWindow( SW_SHOWNA) */
1893 static const struct message WmSHOWNAChildInvisParInvis[] = {
1894 { WM_SHOWWINDOW, sent|wparam, 1 },
1895 { 0 }
1896 };
1897 static const struct message WmSHOWNAChildVisParInvis[] = {
1898 { WM_SHOWWINDOW, sent|wparam, 1 },
1899 { 0 }
1900 };
1901 static const struct message WmSHOWNAChildVisParVis[] = {
1902 { WM_SHOWWINDOW, sent|wparam, 1 },
1903 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
1904 { 0 }
1905 };
1906 static const struct message WmSHOWNAChildInvisParVis[] = {
1907 { WM_SHOWWINDOW, sent|wparam, 1 },
1908 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1909 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1910 { WM_ERASEBKGND, sent|optional },
1911 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOACTIVATE|SWP_NOCLIENTMOVE },
1912 { 0 }
1913 };
1914 static const struct message WmSHOWNATopVisible[] = {
1915 { WM_SHOWWINDOW, sent|wparam, 1 },
1916 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
1917 { WM_NCPAINT, sent|wparam|optional, 1 },
1918 { WM_GETTEXT, sent|defwinproc|optional },
1919 { WM_ERASEBKGND, sent|optional },
1920 { WM_WINDOWPOSCHANGED, sent|optional },
1921 { 0 }
1922 };
1923 static const struct message WmSHOWNATopInvisible[] = {
1924 { WM_NOTIFYFORMAT, sent|optional },
1925 { WM_QUERYUISTATE, sent|optional },
1926 { WM_WINDOWPOSCHANGING, sent|optional },
1927 { WM_GETMINMAXINFO, sent|optional },
1928 { WM_NCCALCSIZE, sent|optional },
1929 { WM_WINDOWPOSCHANGED, sent|optional },
1930 { WM_SHOWWINDOW, sent|wparam, 1 },
1931 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1932 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1933 { WM_NCPAINT, sent|wparam|optional, 1 },
1934 { WM_GETTEXT, sent|defwinproc|optional },
1935 { WM_ERASEBKGND, sent|optional },
1936 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1937 { WM_NCCALCSIZE, sent|wparam|optional, 1 },
1938 { WM_NCPAINT, sent|wparam|optional, 1 },
1939 { WM_ERASEBKGND, sent|optional },
1940 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1941 { WM_SIZE, sent|wparam, SIZE_RESTORED },
1942 { WM_MOVE, sent },
1943 { 0 }
1944 };
1945
1946 static const struct message WmTrackPopupMenu[] = {
1947 { HCBT_CREATEWND, hook },
1948 { WM_ENTERMENULOOP, sent|wparam|lparam, TRUE, 0 },
1949 { WM_INITMENU, sent|lparam, 0, 0 },
1950 { WM_INITMENUPOPUP, sent|lparam, 0, 0 },
1951 { 0x0093, sent|optional },
1952 { 0x0094, sent|optional },
1953 { 0x0094, sent|optional },
1954 { WM_ENTERIDLE, sent|wparam, 2 },
1955 { WM_CAPTURECHANGED, sent },
1956 { HCBT_DESTROYWND, hook },
1957 { WM_UNINITMENUPOPUP, sent|lparam, 0, 0 },
1958 { WM_MENUSELECT, sent|wparam|lparam, 0xffff0000, 0 },
1959 { WM_EXITMENULOOP, sent|wparam|lparam, 1, 0 },
1960 { 0 }
1961 };
1962
1963 static const struct message WmTrackPopupMenuEsc[] = {
1964 { 0 }
1965 };
1966
1967 static const struct message WmTrackPopupMenuCapture[] = {
1968 { HCBT_CREATEWND, hook },
1969 { WM_ENTERMENULOOP, sent|wparam|lparam, TRUE, 0 },
1970 { WM_CAPTURECHANGED, sent },
1971 { WM_INITMENU, sent|lparam, 0, 0 },
1972 { WM_INITMENUPOPUP, sent|lparam, 0, 0 },
1973 { 0x0093, sent|optional },
1974 { 0x0094, sent|optional },
1975 { 0x0094, sent|optional },
1976 { WM_ENTERIDLE, sent|wparam, 2 },
1977 { WM_CAPTURECHANGED, sent },
1978 { HCBT_DESTROYWND, hook },
1979 { WM_UNINITMENUPOPUP, sent|lparam, 0, 0 },
1980 { WM_MENUSELECT, sent|wparam|lparam, 0xffff0000, 0 },
1981 { WM_EXITMENULOOP, sent|wparam|lparam, 1, 0 },
1982 { 0 }
1983 };
1984
1985 static const struct message WmTrackPopupMenuEmpty[] = {
1986 { HCBT_CREATEWND, hook },
1987 { WM_ENTERMENULOOP, sent|wparam|lparam, TRUE, 0 },
1988 { WM_INITMENU, sent|lparam, 0, 0 },
1989 { WM_INITMENUPOPUP, sent|lparam, 0, 0 },
1990 { 0x0093, sent|optional },
1991 { 0x0094, sent|optional },
1992 { 0x0094, sent|optional },
1993 { WM_CAPTURECHANGED, sent },
1994 { WM_EXITMENULOOP, sent|wparam|lparam, 1, 0 },
1995 { HCBT_DESTROYWND, hook },
1996 { WM_UNINITMENUPOPUP, sent|lparam, 0, 0 },
1997 { 0 }
1998 };
1999
2000 static const struct message WmTrackPopupMenuAbort[] = {
2001 { HCBT_CREATEWND, hook },
2002 { WM_ENTERMENULOOP, sent|wparam|lparam, TRUE, 0 },
2003 { WM_INITMENU, sent|lparam, 0, 0 },
2004 { WM_INITMENUPOPUP, sent|lparam, 0, 0 },
2005 { 0x0093, sent|optional },
2006 { 0x0094, sent|optional },
2007 { 0x0094, sent|optional },
2008 { WM_CAPTURECHANGED, sent },
2009 { HCBT_DESTROYWND, hook },
2010 { WM_UNINITMENUPOPUP, sent|lparam, 0, 0 },
2011 { WM_MENUSELECT, sent|wparam|lparam, 0xffff0000, 0 },
2012 { WM_EXITMENULOOP, sent|wparam|lparam, 1, 0 },
2013 { 0 }
2014 };
2015
2016 static BOOL after_end_dialog, test_def_id, paint_loop_done;
2017 static int sequence_cnt, sequence_size;
2018 static struct recvd_message* sequence;
2019 static int log_all_parent_messages;
2020 static CRITICAL_SECTION sequence_cs;
2021
2022 /* user32 functions */
2023 static HWND (WINAPI *pGetAncestor)(HWND,UINT);
2024 static BOOL (WINAPI *pGetMenuInfo)(HMENU,LPCMENUINFO);
2025 static void (WINAPI *pNotifyWinEvent)(DWORD, HWND, LONG, LONG);
2026 static BOOL (WINAPI *pSetMenuInfo)(HMENU,LPCMENUINFO);
2027 static HWINEVENTHOOK (WINAPI *pSetWinEventHook)(DWORD, DWORD, HMODULE, WINEVENTPROC, DWORD, DWORD, DWORD);
2028 static BOOL (WINAPI *pTrackMouseEvent)(TRACKMOUSEEVENT*);
2029 static BOOL (WINAPI *pUnhookWinEvent)(HWINEVENTHOOK);
2030 static BOOL (WINAPI *pGetMonitorInfoA)(HMONITOR,LPMONITORINFO);
2031 static HMONITOR (WINAPI *pMonitorFromPoint)(POINT,DWORD);
2032 static BOOL (WINAPI *pUpdateLayeredWindow)(HWND,HDC,POINT*,SIZE*,HDC,POINT*,COLORREF,BLENDFUNCTION*,DWORD);
2033 static UINT_PTR (WINAPI *pSetSystemTimer)(HWND, UINT_PTR, UINT, TIMERPROC);
2034 static UINT_PTR (WINAPI *pKillSystemTimer)(HWND, UINT_PTR);
2035 static UINT_PTR (WINAPI *pSetCoalescableTimer)(HWND, UINT_PTR, UINT, TIMERPROC, ULONG);
2036 /* kernel32 functions */
2037 static BOOL (WINAPI *pGetCPInfoExA)(UINT, DWORD, LPCPINFOEXA);
2038
2039 static void init_procs(void)
2040 {
2041 HMODULE user32 = GetModuleHandleA("user32.dll");
2042 HMODULE kernel32 = GetModuleHandleA("kernel32.dll");
2043
2044 #define GET_PROC(dll, func) \
2045 p ## func = (void*)GetProcAddress(dll, #func); \
2046 if(!p ## func) { \
2047 trace("GetProcAddress(%s) failed\n", #func); \
2048 }
2049
2050 GET_PROC(user32, GetAncestor)
2051 GET_PROC(user32, GetMenuInfo)
2052 GET_PROC(user32, NotifyWinEvent)
2053 GET_PROC(user32, SetMenuInfo)
2054 GET_PROC(user32, SetWinEventHook)
2055 GET_PROC(user32, TrackMouseEvent)
2056 GET_PROC(user32, UnhookWinEvent)
2057 GET_PROC(user32, GetMonitorInfoA)
2058 GET_PROC(user32, MonitorFromPoint)
2059 GET_PROC(user32, UpdateLayeredWindow)
2060 GET_PROC(user32, SetSystemTimer)
2061 GET_PROC(user32, KillSystemTimer)
2062 GET_PROC(user32, SetCoalescableTimer)
2063
2064 GET_PROC(kernel32, GetCPInfoExA)
2065
2066 #undef GET_PROC
2067 }
2068
2069 static const char *get_winpos_flags(UINT flags)
2070 {
2071 static char buffer[300];
2072
2073 buffer[0] = 0;
2074 #define DUMP(flag) do { if (flags & flag) { strcat( buffer, "|" #flag ); flags &= ~flag; } } while(0)
2075 DUMP( SWP_SHOWWINDOW );
2076 DUMP( SWP_HIDEWINDOW );
2077 DUMP( SWP_NOACTIVATE );
2078 DUMP( SWP_FRAMECHANGED );
2079 DUMP( SWP_NOCOPYBITS );
2080 DUMP( SWP_NOOWNERZORDER );
2081 DUMP( SWP_NOSENDCHANGING );
2082 DUMP( SWP_DEFERERASE );
2083 DUMP( SWP_ASYNCWINDOWPOS );
2084 DUMP( SWP_NOZORDER );
2085 DUMP( SWP_NOREDRAW );
2086 DUMP( SWP_NOSIZE );
2087 DUMP( SWP_NOMOVE );
2088 DUMP( SWP_NOCLIENTSIZE );
2089 DUMP( SWP_NOCLIENTMOVE );
2090 if (flags) sprintf(buffer + strlen(buffer),"|0x%04x", flags);
2091 return buffer + 1;
2092 #undef DUMP
2093 }
2094
2095 static BOOL ignore_message( UINT message )
2096 {
2097 /* these are always ignored */
2098 return (message >= 0xc000 ||
2099 message == WM_GETICON ||
2100 message == WM_GETOBJECT ||
2101 message == WM_TIMECHANGE ||
2102 message == WM_DISPLAYCHANGE ||
2103 message == WM_DEVICECHANGE ||
2104 message == WM_DWMNCRENDERINGCHANGED);
2105 }
2106
2107 static unsigned hash_Ly_W(const WCHAR *str)
2108 {
2109 unsigned hash = 0;
2110
2111 for (; *str; str++)
2112 hash = hash * 1664525u + (unsigned char)(*str) + 1013904223u;
2113
2114 return hash;
2115 }
2116
2117 static unsigned hash_Ly(const char *str)
2118 {
2119 unsigned hash = 0;
2120
2121 for (; *str; str++)
2122 hash = hash * 1664525u + (unsigned char)(*str) + 1013904223u;
2123
2124 return hash;
2125 }
2126
2127 #define add_message(msg) add_message_(__LINE__,msg);
2128 static void add_message_(int line, const struct recvd_message *msg)
2129 {
2130 struct recvd_message *seq;
2131
2132 EnterCriticalSection( &sequence_cs );
2133 if (!sequence)
2134 {
2135 sequence_size = 10;
2136 sequence = HeapAlloc( GetProcessHeap(), 0, sequence_size * sizeof(*sequence) );
2137 }
2138 if (sequence_cnt == sequence_size)
2139 {
2140 sequence_size *= 2;
2141 sequence = HeapReAlloc( GetProcessHeap(), 0, sequence, sequence_size * sizeof(*sequence) );
2142 }
2143 assert(sequence);
2144
2145 seq = &sequence[sequence_cnt++];
2146 seq->hwnd = msg->hwnd;
2147 seq->message = msg->message;
2148 seq->flags = msg->flags;
2149 seq->wParam = msg->wParam;
2150 seq->lParam = msg->lParam;
2151 seq->line = line;
2152 seq->descr = msg->descr;
2153 seq->output[0] = 0;
2154 LeaveCriticalSection( &sequence_cs );
2155
2156 if (msg->descr)
2157 {
2158 if (msg->flags & hook)
2159 {
2160 static const char * const CBT_code_name[10] =
2161 {
2162 "HCBT_MOVESIZE",
2163 "HCBT_MINMAX",
2164 "HCBT_QS",
2165 "HCBT_CREATEWND",
2166 "HCBT_DESTROYWND",
2167 "HCBT_ACTIVATE",
2168 "HCBT_CLICKSKIPPED",
2169 "HCBT_KEYSKIPPED",
2170 "HCBT_SYSCOMMAND",
2171 "HCBT_SETFOCUS"
2172 };
2173 const char *code_name = (msg->message <= HCBT_SETFOCUS) ? CBT_code_name[msg->message] : "Unknown";
2174
2175 sprintf( seq->output, "%s: hook %d (%s) wp %08lx lp %08lx",
2176 msg->descr, msg->message, code_name, msg->wParam, msg->lParam );
2177 }
2178 else if (msg->flags & winevent_hook)
2179 {
2180 sprintf( seq->output, "%s: winevent %p %08x %08lx %08lx",
2181 msg->descr, msg->hwnd, msg->message, msg->wParam, msg->lParam );
2182 }
2183 else
2184 {
2185 switch (msg->message)
2186 {
2187 case WM_WINDOWPOSCHANGING:
2188 case WM_WINDOWPOSCHANGED:
2189 {
2190 WINDOWPOS *winpos = (WINDOWPOS *)msg->lParam;
2191
2192 sprintf( seq->output, "%s: %p WM_WINDOWPOS%s wp %08lx lp %08lx after %p x %d y %d cx %d cy %d flags %s",
2193 msg->descr, msg->hwnd,
2194 (msg->message == WM_WINDOWPOSCHANGING) ? "CHANGING" : "CHANGED",
2195 msg->wParam, msg->lParam, winpos->hwndInsertAfter,
2196 winpos->x, winpos->y, winpos->cx, winpos->cy,
2197 get_winpos_flags(winpos->flags) );
2198
2199 /* Log only documented flags, win2k uses 0x1000 and 0x2000
2200 * in the high word for internal purposes
2201 */
2202 seq->wParam = winpos->flags & 0xffff;
2203 /* We are not interested in the flags that don't match under XP and Win9x */
2204 seq->wParam &= ~SWP_NOZORDER;
2205 break;
2206 }
2207
2208 case WM_DRAWITEM:
2209 {
2210 DRAW_ITEM_STRUCT di;
2211 DRAWITEMSTRUCT *dis = (DRAWITEMSTRUCT *)msg->lParam;
2212
2213 sprintf( seq->output, "%s: %p WM_DRAWITEM: type %x, ctl_id %x, item_id %x, action %x, state %x",
2214 msg->descr, msg->hwnd, dis->CtlType, dis->CtlID,
2215 dis->itemID, dis->itemAction, dis->itemState);
2216
2217 di.u.lp = 0;
2218 di.u.item.type = dis->CtlType;
2219 di.u.item.ctl_id = dis->CtlID;
2220 if (dis->CtlType == ODT_LISTBOX ||
2221 dis->CtlType == ODT_COMBOBOX ||
2222 dis->CtlType == ODT_MENU)
2223 di.u.item.item_id = dis->itemID;
2224 di.u.item.action = dis->itemAction;
2225 di.u.item.state = dis->itemState;
2226
2227 seq->lParam = di.u.lp;
2228 break;
2229 }
2230
2231 case WM_MEASUREITEM:
2232 {
2233 MEASURE_ITEM_STRUCT mi;
2234 MEASUREITEMSTRUCT *mis = (MEASUREITEMSTRUCT *)msg->lParam;
2235 BOOL is_unicode_data = TRUE;
2236
2237 sprintf( seq->output, "%s: %p WM_MEASUREITEM: CtlType %#x, CtlID %#x, itemID %#x, itemData %#lx",
2238 msg->descr, msg->hwnd, mis->CtlType, mis->CtlID,
2239 mis->itemID, mis->itemData);
2240
2241 if (mis->CtlType == ODT_LISTBOX)
2242 {
2243 HWND ctrl = GetDlgItem(msg->hwnd, mis->CtlID);
2244 is_unicode_data = GetWindowLongA(ctrl, GWL_STYLE) & LBS_HASSTRINGS;
2245 }
2246
2247 mi.u.wp = 0;
2248 mi.u.item.CtlType = mis->CtlType;
2249 mi.u.item.CtlID = mis->CtlID;
2250 mi.u.item.itemID = mis->itemID;
2251 mi.u.item.wParam = msg->wParam;
2252 seq->wParam = mi.u.wp;
2253 if (is_unicode_data)
2254 seq->lParam = mis->itemData ? hash_Ly_W((const WCHAR *)mis->itemData) : 0;
2255 else
2256 seq->lParam = mis->itemData ? hash_Ly((const char *)mis->itemData) : 0;
2257 break;
2258 }
2259
2260 case WM_COMPAREITEM:
2261 {
2262 COMPAREITEMSTRUCT *cis = (COMPAREITEMSTRUCT *)msg->lParam;
2263 HWND ctrl = GetDlgItem(msg->hwnd, cis->CtlID);
2264 BOOL is_unicode_data = TRUE;
2265
2266 ok(msg->wParam == cis->CtlID, "expected %#x, got %#lx\n", cis->CtlID, msg->wParam);
2267 ok(cis->hwndItem == ctrl, "expected %p, got %p\n", ctrl, cis->hwndItem);
2268 ok((int)cis->itemID1 >= 0, "expected >= 0, got %d\n", cis->itemID1);
2269 ok((int)cis->itemID2 == -1, "expected -1, got %d\n", cis->itemID2);
2270
2271 sprintf( seq->output, "%s: %p WM_COMPAREITEM: CtlType %#x, CtlID %#x, itemID1 %#x, itemData1 %#lx, itemID2 %#x, itemData2 %#lx",
2272 msg->descr, msg->hwnd, cis->CtlType, cis->CtlID,
2273 cis->itemID1, cis->itemData1, cis->itemID2, cis->itemData2);
2274
2275 if (cis->CtlType == ODT_LISTBOX)
2276 is_unicode_data = GetWindowLongA(ctrl, GWL_STYLE) & LBS_HASSTRINGS;
2277
2278 if (is_unicode_data)
2279 {
2280 seq->wParam = cis->itemData1 ? hash_Ly_W((const WCHAR *)cis->itemData1) : 0;
2281 seq->lParam = cis->itemData2 ? hash_Ly_W((const WCHAR *)cis->itemData2) : 0;
2282 }
2283 else
2284 {
2285 seq->wParam = cis->itemData1 ? hash_Ly((const char *)cis->itemData1) : 0;
2286 seq->lParam = cis->itemData2 ? hash_Ly((const char *)cis->itemData2) : 0;
2287 }
2288 break;
2289 }
2290
2291 default:
2292 if (msg->message >= 0xc000) return; /* ignore registered messages */
2293 sprintf( seq->output, "%s: %p %04x wp %08lx lp %08lx",
2294 msg->descr, msg->hwnd, msg->message, msg->wParam, msg->lParam );
2295 }
2296 if (msg->flags & (sent|posted|parent|defwinproc|beginpaint))
2297 sprintf( seq->output + strlen(seq->output), " (flags %x)", msg->flags );
2298 }
2299 }
2300 }
2301
2302 /* try to make sure pending X events have been processed before continuing */
2303 static void flush_events(void)
2304 {
2305 MSG msg;
2306 int diff = 200;
2307 int min_timeout = 100;
2308 DWORD time = GetTickCount() + diff;
2309
2310 while (diff > 0)
2311 {
2312 if (MsgWaitForMultipleObjects( 0, NULL, FALSE, min_timeout, QS_ALLINPUT ) == WAIT_TIMEOUT) break;
2313 while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageA( &msg );
2314 diff = time - GetTickCount();
2315 }
2316 }
2317
2318 static void flush_sequence(void)
2319 {
2320 EnterCriticalSection( &sequence_cs );
2321 HeapFree(GetProcessHeap(), 0, sequence);
2322 sequence = 0;
2323 sequence_cnt = sequence_size = 0;
2324 LeaveCriticalSection( &sequence_cs );
2325 }
2326
2327 static void dump_sequence(const struct message *expected, const char *context, const char *file, int line)
2328 {
2329 const struct recvd_message *actual = sequence;
2330 unsigned int count = 0;
2331
2332 trace_(file, line)("Failed sequence %s:\n", context );
2333 while (expected->message && actual->message)
2334 {
2335 if (actual->output[0])
2336 {
2337 if (expected->flags & hook)
2338 {
2339 trace_(file, line)( " %u: expected: hook %04x - actual: %s\n",
2340 count, expected->message, actual->output );
2341 }
2342 else if (expected->flags & winevent_hook)
2343 {
2344 trace_(file, line)( " %u: expected: winevent %04x - actual: %s\n",
2345 count, expected->message, actual->output );
2346 }
2347 else if (expected->flags & kbd_hook)
2348 {
2349 trace_(file, line)( " %u: expected: kbd %04x - actual: %s\n",
2350 count, expected->message, actual->output );
2351 }
2352 else
2353 {
2354 trace_(file, line)( " %u: expected: msg %04x - actual: %s\n",
2355 count, expected->message, actual->output );
2356 }
2357 }
2358
2359 if (expected->message == actual->message)
2360 {
2361 if ((expected->flags & defwinproc) != (actual->flags & defwinproc) &&
2362 (expected->flags & optional))
2363 {
2364 /* don't match messages if their defwinproc status differs */
2365 expected++;
2366 }
2367 else
2368 {
2369 expected++;
2370 actual++;
2371 }
2372 }
2373 /* silently drop winevent messages if there is no support for them */
2374 else if ((expected->flags & optional) || ((expected->flags & winevent_hook) && !hEvent_hook))
2375 expected++;
2376 else
2377 {
2378 expected++;
2379 actual++;
2380 }
2381 count++;
2382 }
2383
2384 /* optional trailing messages */
2385 while (expected->message && ((expected->flags & optional) ||
2386 ((expected->flags & winevent_hook) && !hEvent_hook)))
2387 {
2388 trace_(file, line)( " %u: expected: msg %04x - actual: nothing\n", count, expected->message );
2389 expected++;
2390 count++;
2391 }
2392
2393 if (expected->message)
2394 {
2395 trace_(file, line)( " %u: expected: msg %04x - actual: nothing\n", count, expected->message );
2396 return;
2397 }
2398
2399 while (actual->message && actual->output[0])
2400 {
2401 trace_(file, line)( " %u: expected: nothing - actual: %s\n", count, actual->output );
2402 actual++;
2403 count++;
2404 }
2405 }
2406
2407 #define ok_sequence( exp, contx, todo) \
2408 ok_sequence_( (exp), (contx), (todo), __FILE__, __LINE__)
2409
2410
2411 static void ok_sequence_(const struct message *expected_list, const char *context, BOOL todo,
2412 const char *file, int line)
2413 {
2414 static const struct recvd_message end_of_sequence;
2415 const struct message *expected = expected_list;
2416 const struct recvd_message *actual;
2417 int failcount = 0, dump = 0;
2418 unsigned int count = 0;
2419
2420 add_message(&end_of_sequence);
2421
2422 actual = sequence;
2423
2424 while (expected->message && actual->message)
2425 {
2426 if (expected->message == actual->message &&
2427 !((expected->flags ^ actual->flags) & (hook|winevent_hook|kbd_hook)))
2428 {
2429 if (expected->flags & wparam)
2430 {
2431 if (((expected->wParam ^ actual->wParam) & ~expected->wp_mask) && todo)
2432 {
2433 todo_wine {
2434 failcount ++;
2435 if (strcmp(winetest_platform, "wine")) dump++;
2436 ok_( file, line) (FALSE,
2437 "%s: %u: in msg 0x%04x expecting wParam 0x%lx got 0x%lx\n",
2438 context, count, expected->message, expected->wParam, actual->wParam);
2439 }
2440 }
2441 else
2442 {
2443 ok_( file, line)( ((expected->wParam ^ actual->wParam) & ~expected->wp_mask) == 0,
2444 "%s: %u: in msg 0x%04x expecting wParam 0x%lx got 0x%lx\n",
2445 context, count, expected->message, expected->wParam, actual->wParam);
2446 if ((expected->wParam ^ actual->wParam) & ~expected->wp_mask) dump++;
2447 }
2448
2449 }
2450 if (expected->flags & lparam)
2451 {
2452 if (((expected->lParam ^ actual->lParam) & ~expected->lp_mask) && todo)
2453 {
2454 todo_wine {
2455 failcount ++;
2456 if (strcmp(winetest_platform, "wine")) dump++;
2457 ok_( file, line) (FALSE,
2458 "%s: %u: in msg 0x%04x expecting lParam 0x%lx got 0x%lx\n",
2459 context, count, expected->message, expected->lParam, actual->lParam);
2460 }
2461 }
2462 else
2463 {
2464 ok_( file, line)(((expected->lParam ^ actual->lParam) & ~expected->lp_mask) == 0,
2465 "%s: %u: in msg 0x%04x expecting lParam 0x%lx got 0x%lx\n",
2466 context, count, expected->message, expected->lParam, actual->lParam);
2467 if ((expected->lParam ^ actual->lParam) & ~expected->lp_mask) dump++;
2468 }
2469 }
2470 if ((expected->flags & optional) &&
2471 ((expected->flags ^ actual->flags) & (defwinproc|parent)))
2472 {
2473 /* don't match optional messages if their defwinproc or parent status differs */
2474 expected++;
2475 count++;
2476 continue;
2477 }
2478 if ((expected->flags & defwinproc) != (actual->flags & defwinproc) && todo)
2479 {
2480 todo_wine {
2481 failcount ++;
2482 if (strcmp(winetest_platform, "wine")) dump++;
2483 ok_( file, line) (FALSE,
2484 "%s: %u: the msg 0x%04x should %shave been sent by DefWindowProc\n",
2485 context, count, expected->message, (expected->flags & defwinproc) ? "" : "NOT ");
2486 }
2487 }
2488 else
2489 {
2490 ok_( file, line) ((expected->flags & defwinproc) == (actual->flags & defwinproc),
2491 "%s: %u: the msg 0x%04x should %shave been sent by DefWindowProc\n",
2492 context, count, expected->message, (expected->flags & defwinproc) ? "" : "NOT ");
2493 if ((expected->flags & defwinproc) != (actual->flags & defwinproc)) dump++;
2494 }
2495
2496 ok_( file, line) ((expected->flags & beginpaint) == (actual->flags & beginpaint),
2497 "%s: %u: the msg 0x%04x should %shave been sent by BeginPaint\n",
2498 context, count, expected->message, (expected->flags & beginpaint) ? "" : "NOT ");
2499 if ((expected->flags & beginpaint) != (actual->flags & beginpaint)) dump++;
2500
2501 ok_( file, line) ((expected->flags & (sent|posted)) == (actual->flags & (sent|posted)),
2502 "%s: %u: the msg 0x%04x should have been %s\n",
2503 context, count, expected->message, (expected->flags & posted) ? "posted" : "sent");
2504 if ((expected->flags & (sent|posted)) != (actual->flags & (sent|posted))) dump++;
2505
2506 ok_( file, line) ((expected->flags & parent) == (actual->flags & parent),
2507 "%s: %u: the msg 0x%04x was expected in %s\n",
2508 context, count, expected->message, (expected->flags & parent) ? "parent" : "child");
2509 if ((expected->flags & parent) != (actual->flags & parent)) dump++;
2510
2511 ok_( file, line) ((expected->flags & hook) == (actual->flags & hook),
2512 "%s: %u: the msg 0x%04x should have been sent by a hook\n",
2513 context, count, expected->message);
2514 if ((expected->flags & hook) != (actual->flags & hook)) dump++;
2515
2516 ok_( file, line) ((expected->flags & winevent_hook) == (actual->flags & winevent_hook),
2517 "%s: %u: the msg 0x%04x should have been sent by a winevent hook\n",
2518 context, count, expected->message);
2519 if ((expected->flags & winevent_hook) != (actual->flags & winevent_hook)) dump++;
2520
2521 ok_( file, line) ((expected->flags & kbd_hook) == (actual->flags & kbd_hook),
2522 "%s: %u: the msg 0x%04x should have been sent by a keyboard hook\n",
2523 context, count, expected->message);
2524 if ((expected->flags & kbd_hook) != (actual->flags & kbd_hook)) dump++;
2525
2526 expected++;
2527 actual++;
2528 }
2529 /* silently drop hook messages if there is no support for them */
2530 else if ((expected->flags & optional) ||
2531 ((expected->flags & hook) && !hCBT_hook) ||
2532 ((expected->flags & winevent_hook) && !hEvent_hook) ||
2533 ((expected->flags & kbd_hook) && !hKBD_hook))
2534 expected++;
2535 else if (todo)
2536 {
2537 failcount++;
2538 todo_wine {
2539 if (strcmp(winetest_platform, "wine")) dump++;
2540 ok_( file, line) (FALSE, "%s: %u: the msg 0x%04x was expected, but got msg 0x%04x instead\n",
2541 context, count, expected->message, actual->message);
2542 }
2543 goto done;
2544 }
2545 else
2546 {
2547 ok_( file, line) (FALSE, "%s: %u: the msg 0x%04x was expected, but got msg 0x%04x instead\n",
2548 context, count, expected->message, actual->message);
2549 dump++;
2550 expected++;
2551 actual++;
2552 }
2553 count++;
2554 }
2555
2556 /* skip all optional trailing messages */
2557 while (expected->message && ((expected->flags & optional) ||
2558 ((expected->flags & hook) && !hCBT_hook) ||
2559 ((expected->flags & winevent_hook) && !hEvent_hook)))
2560 expected++;
2561
2562 if (todo)
2563 {
2564 todo_wine {
2565 if (expected->message || actual->message) {
2566 failcount++;
2567 if (strcmp(winetest_platform, "wine")) dump++;
2568 ok_( file, line) (FALSE, "%s: %u: the msg sequence is not complete: expected %04x - actual %04x\n",
2569 context, count, expected->message, actual->message);
2570 }
2571 }
2572 }
2573 else
2574 {
2575 if (expected->message || actual->message)
2576 {
2577 dump++;
2578 ok_( file, line) (FALSE, "%s: %u: the msg sequence is not complete: expected %04x - actual %04x\n",
2579 context, count, expected->message, actual->message);
2580 }
2581 }
2582 if( todo && !failcount) /* succeeded yet marked todo */
2583 todo_wine {
2584 if (!strcmp(winetest_platform, "wine")) dump++;
2585 ok_( file, line)( TRUE, "%s: marked \"todo_wine\" but succeeds\n", context);
2586 }
2587
2588 done:
2589 if (dump) dump_sequence(expected_list, context, file, line);
2590 flush_sequence();
2591 }
2592
2593 #define expect(EXPECTED,GOT) ok((GOT)==(EXPECTED), "Expected %d, got %d\n", (EXPECTED), (GOT))
2594
2595 /******************************** MDI test **********************************/
2596
2597 /* CreateWindow for MDI frame window, initially visible */
2598 static const struct message WmCreateMDIframeSeq[] = {
2599 { HCBT_CREATEWND, hook },
2600 { WM_GETMINMAXINFO, sent },
2601 { WM_NCCREATE, sent },
2602 { WM_NCCALCSIZE, sent|wparam, 0 },
2603 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
2604 { WM_CREATE, sent },
2605 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
2606 { WM_NOTIFYFORMAT, sent|optional },
2607 { WM_QUERYUISTATE, sent|optional },
2608 { WM_WINDOWPOSCHANGING, sent|optional },
2609 { WM_GETMINMAXINFO, sent|optional },
2610 { WM_NCCALCSIZE, sent|optional },
2611 { WM_WINDOWPOSCHANGED, sent|optional },
2612 { WM_SHOWWINDOW, sent|wparam, 1 },
2613 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
2614 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2615 { HCBT_ACTIVATE, hook },
2616 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
2617 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
2618 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* XP */
2619 { WM_ACTIVATEAPP, sent|wparam|optional, 1 }, /* Win9x doesn't send it */
2620 { WM_NCACTIVATE, sent },
2621 { WM_GETTEXT, sent|defwinproc|optional },
2622 { WM_ACTIVATE, sent|wparam, 1 },
2623 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* Win9x */
2624 { HCBT_SETFOCUS, hook },
2625 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
2626 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
2627 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2628 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
2629 /* Win9x adds SWP_NOZORDER below */
2630 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2631 { WM_NCCALCSIZE, sent|wparam|optional, 1 }, /* XP */
2632 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
2633 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2634 { WM_MOVE, sent },
2635 { 0 }
2636 };
2637 /* DestroyWindow for MDI frame window, initially visible */
2638 static const struct message WmDestroyMDIframeSeq[] = {
2639 { HCBT_DESTROYWND, hook },
2640 { 0x0090, sent|optional },
2641 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2642 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
2643 { WM_NCACTIVATE, sent|wparam|optional, 0 }, /* Win9x */
2644 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2645 { WM_NCACTIVATE, sent|wparam|optional, 0 }, /* XP */
2646 { WM_ACTIVATE, sent|wparam|optional, 0 }, /* Win9x */
2647 { WM_ACTIVATEAPP, sent|wparam|optional, 0 }, /* Win9x */
2648 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
2649 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
2650 { WM_DESTROY, sent },
2651 { WM_NCDESTROY, sent },
2652 { 0 }
2653 };
2654 /* CreateWindow for MDI client window, initially visible */
2655 static const struct message WmCreateMDIclientSeq[] = {
2656 { HCBT_CREATEWND, hook },
2657 { WM_NCCREATE, sent },
2658 { WM_NCCALCSIZE, sent|wparam, 0 },
2659 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam|optional, 0, 0 },
2660 { WM_CREATE, sent },
2661 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam|optional, 0, 0 },
2662 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
2663 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2664 { WM_MOVE, sent },
2665 { WM_PARENTNOTIFY, sent|wparam, WM_CREATE }, /* in MDI frame */
2666