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