ReactOS  0.4.14-dev-593-g1793dcc
msg.c
Go to the documentation of this file.
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;
100  } u;
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;
118 
121 static HHOOK hKBD_hook;
122 static HHOOK hCBT_hook;
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 
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,
148  optional=0x80,
149  hook=0x100,
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 
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[] = {
197  { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
198  { WM_NCPAINT, sent|wparam|optional, 1 },
201  { HCBT_ACTIVATE, hook },
202  { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
203  { WM_NOTIFYFORMAT, sent|optional },
204  { WM_QUERYUISTATE, sent|optional },
206  { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* Win9x: SWP_NOSENDCHANGING */
207  { WM_ACTIVATEAPP, sent|wparam, 1 },
208  { WM_NCACTIVATE, sent },
210  { WM_ACTIVATE, sent|wparam, 1 },
211  { HCBT_SETFOCUS, hook },
214  { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
216  { WM_GETTEXT, sent|optional },
217  { WM_NCPAINT, sent|wparam|optional, 1 },
220  /* Win9x adds SWP_NOZORDER below */
222  { WM_GETTEXT, sent|optional },
224  { WM_NCPAINT, sent|wparam|optional, 1 },
226  { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
229  { WM_PAINT, sent|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[] = {
240  { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
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[] = {
257  { WM_NCPAINT, sent|optional },
263  { WM_NCPAINT, 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[] = {
276  { WM_GETMINMAXINFO, sent|defwinproc|optional }, /* Win9x */
278  { WM_NCPAINT, sent|optional },
284  { WM_NCPAINT, 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[] = {
296  { WM_NCPAINT, sent|optional },
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 },
312  { WM_NCPAINT, sent|optional },
315  { WM_WINDOWPOSCHANGED, sent|wparam|optional, /*SWP_NOZORDER|*/SWP_NOACTIVATE, 0,
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 */
339  /* Preparing for maximize and maximize the 1st MDI child */
340  { WM_GETMINMAXINFO, sent|defwinproc }, /* 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 */
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 */
349  /* Restore 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 */
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 */
360  { WM_NCCALCSIZE, sent|wparam, 1 },/* 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 */
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 */
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 */
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 */
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[] = {
419  { WM_NCPAINT, sent|parent|optional }, /* wparam != 1 */
421  { WM_ERASEBKGND, sent|parent|optional }, /* FIXME: remove optional once Wine is fixed */
422  { WM_NCPAINT, sent }, /* wparam != 1 */
423  { WM_ERASEBKGND, sent },
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[] = {
437  { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
439  { WM_NCPAINT, sent|beginpaint|parent|optional }, /* wparam != 1 */
441  { WM_PAINT, sent },
442  { WM_NCPAINT, sent|beginpaint }, /* wparam != 1 */
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[] = {
454  { WM_NCPAINT, sent|parent|optional }, /* wparam != 1 */
458  { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
459  { WM_PAINT, sent },
460  { WM_NCPAINT, sent|beginpaint }, /* wparam != 1 */
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 },
470  { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
471  { WM_NCPAINT, sent|wparam|optional, 1 },
475  { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
478  { WM_NCPAINT, sent|wparam|optional, 1 },
486  { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
488  { WM_GETTEXT, sent|optional },
489  { WM_NCPAINT, sent|wparam|optional, 1 },
492  /* Win9x adds SWP_NOZORDER below */
495  { WM_GETTEXT, sent|optional },
496  { WM_NCPAINT, 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 },
508  { 0 }
509 };
510 /* ShowWindow(SW_SHOWMAXIMIZED) for a not visible overlapped window */
511 static const struct message WmShowMaxOverlappedSeq[] = {
513  { WM_GETMINMAXINFO, sent },
517  { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
519  { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
529  { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
531  { WM_GETTEXT, sent|optional },
532  { WM_NCPAINT, sent|wparam|optional, 1 },
535  /* Win9x adds SWP_NOZORDER below */
537  { WM_MOVE, sent|defwinproc },
539  { WM_GETTEXT, sent|optional },
541  { WM_NCPAINT, sent|optional },
543  { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
544  { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
547  { WM_PAINT, sent|optional },
550  { 0 }
551 };
552 /* ShowWindow(SW_RESTORE) for a not visible maximized overlapped window */
553 static const struct message WmShowRestoreMaxOverlappedSeq[] = {
555  { WM_GETTEXT, sent|optional },
559  { WM_NCPAINT, sent|optional },
566  { WM_NCPAINT, sent|optional },
568  { WM_PAINT, sent|optional },
573  { 0 }
574 };
575 /* ShowWindow(SW_RESTORE) for a not visible minimized overlapped window */
576 static const struct message WmShowRestoreMinOverlappedSeq[] = {
579  { WM_GETTEXT, sent|optional },
581  { WM_WINDOWPOSCHANGING, sent|optional }, /* SWP_NOSIZE|SWP_NOMOVE */
584  { WM_MOVE, sent|optional },
586  { WM_GETTEXT, sent|optional },
601  { WM_GETTEXT, sent|optional },
602  { WM_NCPAINT, sent|wparam|optional, 1 },
604  { WM_ERASEBKGND, sent },
606  { WM_MOVE, sent|defwinproc },
611  { WM_NCPAINT, sent|wparam|optional, 1 },
615  { WM_ACTIVATE, sent|wparam, 1 },
616  { WM_GETTEXT, sent|optional },
617  { WM_PAINT, sent|optional },
621  { 0 }
622 };
623 /* ShowWindow(SW_SHOWMINIMIZED) for a not visible overlapped window */
624 static const struct message WmShowMinOverlappedSeq[] = {
627  { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
631  { WM_GETTEXT, sent|optional },
635  { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
636  { WM_NCPAINT, sent|optional },
639  { WM_MOVE, sent|defwinproc },
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 },
649 
650  /* Vista sometimes restores the window right away... */
661  { WM_GETTEXT, sent|optional },
667  { WM_NCPAINT, sent|optional },
676 
677  { WM_PAINT, sent|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 },
686  { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
688  { WM_SIZE, sent|optional }, /* XP doesn't send it */
689  { WM_MOVE, sent|optional }, /* XP doesn't send it */
697  { 0 }
698 };
699 /* DestroyWindow for a visible overlapped window */
700 static const struct message WmDestroyOverlappedSeq[] = {
701  { HCBT_DESTROYWND, hook },
702  { 0x0090, sent|optional },
704  { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
705  { 0x0090, sent|optional },
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 },
726  { WM_MOVE, sent },
728  { WM_GETMINMAXINFO, sent },
732  { WM_MOVE, sent|defwinproc },
734  { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
735  { WM_SHOWWINDOW, sent|wparam, 1 },
737  { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
738  { HCBT_ACTIVATE, hook },
739  { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
742  { WM_NCPAINT, sent|wparam|optional, 1 },
745  { WM_ACTIVATEAPP, sent|wparam, 1 },
746  { WM_NCACTIVATE, sent },
747  { WM_ACTIVATE, sent|wparam, 1 },
748  { HCBT_SETFOCUS, hook },
751  { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
753  { WM_GETTEXT, sent|optional },
755  { WM_NCPAINT, sent|wparam|optional, 1 },
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 },
770  { WM_MOVE, sent },
772  { WM_GETMINMAXINFO, sent },
776  { WM_MOVE, sent|defwinproc },
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[] = {
784  { WM_GETMINMAXINFO, sent },
787  { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
788  { HCBT_ACTIVATE, hook },
789  { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
792  { WM_NCPAINT, sent|wparam|optional, 1 },
795  { WM_ACTIVATEAPP, sent|wparam, 1 },
796  { WM_NCACTIVATE, sent },
797  { WM_ACTIVATE, sent|wparam, 1 },
798  { HCBT_SETFOCUS, hook },
801  { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
803  { WM_GETTEXT, sent|optional },
804  { WM_NCPAINT, sent|wparam|optional, 1 },
807  /* WinNT4.0 sends WM_MOVE */
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[] = {
816  { WM_GETMINMAXINFO, sent },
819  { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
820  { HCBT_ACTIVATE, hook },
821  { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
824  { WM_NCPAINT, sent|wparam|optional, 1 },
827  { WM_ACTIVATEAPP, sent|wparam, 1 },
828  { WM_NCACTIVATE, sent },
829  { WM_ACTIVATE, sent|wparam, 1 },
830  { HCBT_SETFOCUS, hook },
833  { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
835  { WM_GETTEXT, sent|optional },
837  { WM_NCPAINT, sent|wparam|optional, 1 },
842  { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
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 },
854  { WM_MOVE, sent },
855  { WM_SHOWWINDOW, sent|wparam, 1 },
857  { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
858  { HCBT_ACTIVATE, hook },
859  { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
862  { WM_NCPAINT, sent|wparam|optional, 1 },
865  { WM_ACTIVATEAPP, sent|wparam, 1 },
866  { WM_NCACTIVATE, sent },
867  { WM_ACTIVATE, sent|wparam, 1 },
868  { HCBT_SETFOCUS, hook },
871  { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
873  { WM_GETTEXT, sent|optional },
875  { WM_NCPAINT, sent|wparam|optional, 1 },
878  { 0 }
879 };
880 /* ShowWindow(SW_SHOWMAXIMIZED) for a visible popup window */
881 static const struct message WmShowVisMaxPopupSeq[] = {
883  { WM_GETMINMAXINFO, sent },
884  { WM_GETTEXT, sent|optional },
886  { WM_GETTEXT, sent|optional },
889  { WM_NCPAINT, sent|wparam|optional, 1 },
892  { WM_MOVE, sent|defwinproc },
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 },
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 },
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[] = {
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[] = {
935  { HCBT_ACTIVATE, hook },
936  { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
939  { WM_NCACTIVATE, sent },
940  { WM_ACTIVATE, sent|wparam, 1 },
941  { HCBT_SETFOCUS, hook },
942  { WM_KILLFOCUS, sent|parent },
946  { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
948  { WM_GETTEXT, sent|optional },
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 },
961  { WM_MOVE, sent },
962  { WM_SHOWWINDOW, sent|wparam, 1 },
964  { HCBT_ACTIVATE, hook },
967  { WM_ACTIVATEAPP, sent },
968  { WM_NCACTIVATE, sent },
969  { WM_ACTIVATE, sent },
973  { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
974  { HCBT_SETFOCUS, hook },
976  { WM_NCPAINT, sent|wparam, 1 },
977  { WM_ERASEBKGND, sent },
979  /* occasionally received on test machines */
980  { WM_NCPAINT, 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 },
993  { WM_MOVE, sent },
994  { WM_SHOWWINDOW, sent|wparam, 1 },
996  { HCBT_ACTIVATE, hook },
999  { WM_ACTIVATEAPP, sent },
1000  { WM_NCACTIVATE, sent },
1001  { WM_ACTIVATE, sent },
1005  { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1006  { HCBT_SETFOCUS, hook },
1008  { WM_NCPAINT, sent|wparam, 1 },
1009  { WM_ERASEBKGND, sent },
1011  { WM_PAINT, sent },
1012  /* occasionally received on test machines */
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 },
1026  { WM_MOVE, sent },
1028  { WM_GETMINMAXINFO, sent },
1030  { WM_NCCALCSIZE, sent|wparam, TRUE },
1031  { HCBT_ACTIVATE, hook },
1033  { WM_NCPAINT, sent|optional|wparam, 1 },
1037  { WM_ACTIVATEAPP, sent },
1038  { WM_NCACTIVATE, sent },
1039  { WM_ACTIVATE, sent },
1043  { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1044  { HCBT_SETFOCUS, hook },
1046  { WM_NCPAINT, sent|wparam, 1 },
1047  { WM_ERASEBKGND, sent },
1049  { WM_MOVE, sent|defwinproc },
1050  { WM_SIZE, sent|defwinproc, 0 },
1051  { WM_PAINT, sent},
1052  /* occasionally received on test machines */
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 },
1064  { WM_MOVE, sent },
1066  { HCBT_ACTIVATE, hook },
1069  { WM_ACTIVATEAPP, sent },
1070  { WM_NCACTIVATE, sent },
1071  { WM_ACTIVATE, sent },
1075  { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1076  { HCBT_SETFOCUS, hook },
1078  { WM_NCPAINT, sent|wparam, 1 },
1079  { WM_ERASEBKGND, 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 },
1091  { WM_MOVE, sent },
1093  { HCBT_ACTIVATE, hook },
1096  { WM_ACTIVATEAPP, sent },
1097  { WM_NCACTIVATE, sent },
1098  { WM_ACTIVATE, sent },
1102  { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1103  { HCBT_SETFOCUS, hook },
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 },
1116  { WM_MOVE, sent },
1118  /* Probably shouldn't happen, but not part of this test */
1122  { WM_ACTIVATE, sent|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 },
1134  { WM_MOVE, sent },
1136  { HCBT_ACTIVATE, hook },
1139  { WM_ACTIVATEAPP, sent },
1140  { WM_NCACTIVATE, sent },
1141  { WM_ACTIVATE, sent },
1145  { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1146  { HCBT_SETFOCUS, hook },
1148  { WM_NCPAINT, sent|wparam, 1 },
1149  { WM_ERASEBKGND, 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 },
1160  { WM_MOVE, sent },
1162  { HCBT_ACTIVATE, hook },
1165  { WM_ACTIVATEAPP, sent },
1166  { WM_NCACTIVATE, sent },
1167  { WM_ACTIVATE, sent },
1171  { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1172  { HCBT_SETFOCUS, hook },
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 },
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 },
1197  { WM_MOVE, sent },
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 },
1209  { WM_MOVE, sent },
1211  { WM_GETMINMAXINFO, sent },
1213  { WM_NCCALCSIZE, sent|wparam, 1 },
1216  { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
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 },
1230  { WM_MOVE, sent },
1232  { WM_SHOWWINDOW, sent|wparam, 1 },
1234  { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
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 },
1245  { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1248  { 0 }
1249 };
1250 /* ShowWindow(SW_HIDE) for a visible child window */
1251 static const struct message WmHideChildSeq[] = {
1252  { WM_SHOWWINDOW, sent|wparam, 0 },
1254  { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
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 },
1263  { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
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[] = {
1273  { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1274  { WM_CHILDACTIVATE, sent },
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[] = {
1283  { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
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[] = {
1292  { WM_CHILDACTIVATE, sent },
1293  { 0 }
1294 };
1295 /* ShowWindow(SW_MINIMIZE) for child with invisible parent */
1296 static const struct message WmShowChildInvisibleParentSeq_1[] = {
1299  { WM_NCCALCSIZE, sent|wparam, 1 },
1300  { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1303  { WM_MOVE, sent|defwinproc },
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 */
1309  { WM_GETTEXT, sent|optional },
1310  { 0 }
1311 };
1312 /* repeated ShowWindow(SW_MINIMIZE) for child with invisible parent */
1315  { 0 }
1316 };
1317 /* ShowWindow(SW_MAXIMIZE) for child with invisible parent */
1318 static const struct message WmShowChildInvisibleParentSeq_2[] = {
1320  { WM_GETMINMAXINFO, sent },
1322  { WM_NCCALCSIZE, sent|wparam, 1 },
1323  { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1324  { WM_CHILDACTIVATE, sent },
1327  { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1328  { 0 }
1329 };
1330 /* repeated ShowWindow(SW_MAXIMIZE) for child with invisible parent */
1333  { 0 }
1334 };
1335 /* ShowWindow(SW_SHOWMINIMIZED) for child with invisible parent */
1336 static const struct message WmShowChildInvisibleParentSeq_3[] = {
1339  { WM_NCCALCSIZE, sent|wparam, 1 },
1340  { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1341  { WM_CHILDACTIVATE, sent },
1343  { WM_MOVE, sent|defwinproc },
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 */
1349  { WM_GETTEXT, sent|optional },
1350  { 0 }
1351 };
1352 /* repeated ShowWindow(SW_SHOWMINIMIZED) for child with invisible parent */
1355  { 0 }
1356 };
1357 /* ShowWindow(SW_SHOWMINNOACTIVE) for child with invisible parent */
1358 static const struct message WmShowChildInvisibleParentSeq_4[] = {
1361  { WM_NCCALCSIZE, sent|wparam, 1 },
1362  { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1364  { WM_MOVE, sent|defwinproc },
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 */
1370  { WM_GETTEXT, sent|optional },
1371  { 0 }
1372 };
1373 /* repeated ShowWindow(SW_SHOWMINNOACTIVE) for child with invisible parent */
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[] = {
1391  { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1393  { 0 }
1394 };
1395 /* SetWindowPos(SWP_HIDEWINDOW) for child with invisible parent */
1396 static const struct message WmHideChildInvisibleParentSeq_2[] = {
1398  { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
1400  { 0 }
1401 };
1402 /* DestroyWindow for a visible child window */
1403 static const struct message WmDestroyChildSeq[] = {
1404  { HCBT_DESTROYWND, hook },
1405  { 0x0090, sent|optional },
1407  { WM_SHOWWINDOW, sent|wparam, 0 },
1409  { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
1412  { HCBT_SETFOCUS, hook }, /* set focus to a parent */
1413  { WM_KILLFOCUS, sent },
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 },
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 },
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) */
1446  { WM_NCCALCSIZE, sent|wparam, 1 },
1450  { WM_MOVE, sent|defwinproc },
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 },
1470  { WM_SHOWWINDOW, sent|wparam, 1 },
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 
1478 
1480 
1481  { WM_NCACTIVATE, sent },
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 },
1492  { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1493  { WM_SETFOCUS, sent },
1495  { WM_NCPAINT, sent|wparam, 1 },
1498  { WM_ERASEBKGND, sent },
1501  { WM_GETTEXT, sent|optional },
1502  { WM_GETTEXT, sent|optional },
1504  { WM_NCPAINT, sent|optional },
1509  { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1511  { WM_MOVE, sent },
1512  { 0 }
1513 };
1514 /* Calling EndDialog for a custom dialog (32) */
1515 static const struct message WmEndCustomDialogSeq[] = {
1517  { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
1519  { WM_GETTEXT, sent|optional },
1520  { HCBT_ACTIVATE, hook },
1521  { WM_NCACTIVATE, sent|wparam, 0 },
1524  { WM_ACTIVATE, sent|wparam, 0 },
1525  { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
1530  { HCBT_SETFOCUS, hook },
1531  { WM_KILLFOCUS, sent },
1535  { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
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 },
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 
1548 
1551  { WM_NCACTIVATE, sent },
1552  { WM_ACTIVATE, sent|wparam, 1 },
1553  { WM_GETTEXT, sent|optional },
1554 
1555  { WM_KILLFOCUS, sent|parent },
1559  { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1560  { WM_SETFOCUS, sent },
1562  { WM_NCPAINT, sent|wparam, 1 },
1563  { WM_ERASEBKGND, sent },
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 },
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 },
1589  { WM_NCACTIVATE, sent },
1590  { WM_GETTEXT, sent|optional },
1591  { WM_ACTIVATE, sent|wparam, 1 },
1593  { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1594  { WM_NCPAINT, sent|optional },
1595  { WM_GETTEXT, sent|optional },
1599  { WM_GETTEXT, sent|optional },
1601  { WM_NCPAINT, sent|optional },
1602  { WM_GETTEXT, sent|optional },
1605  { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1606  { WM_PAINT, sent|optional },
1629  { WM_TIMER, sent },
1630  { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, 0, 0 },
1631  { WM_ENABLE, sent|parent|wparam, 1 },
1633  { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
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 },
1643  { HCBT_SETFOCUS, hook },
1645  { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
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 },
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 },
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*/
1685  { WM_NCCALCSIZE, sent|wparam, 1 },
1686  { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
1688  { WM_MOVE, sent|defwinproc },
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 },
1695  { 0 }
1696 };
1697 /* SetMenu for NonVisible windows with no size change */
1700  { WM_NCCALCSIZE, sent|wparam, 1 },
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[] = {
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 },
1718  { WM_ACTIVATE, sent|optional },
1720  { WM_MOVE, sent|defwinproc },
1722  { 0x0093, sent|optional },
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 },
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[] = {
1738  { WM_NCCALCSIZE, sent|wparam, 1 },
1739  { WM_NCPAINT, sent|optional }, /* wparam != 1 */
1742  { WM_ACTIVATE, sent|optional },
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 {
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 },
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 },
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 {
1840  { WM_NCCALCSIZE, sent|wparam, 1 },
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 {
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 },
1866  { WM_CTLCOLORDLG, sent|defwinproc|optional }, /* sent to a parent of the dialog */
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 },
1890  { 0 }
1891 };
1892 static const struct message WmSHOWNAChildInvisParVis[] = {
1893  { WM_SHOWWINDOW, sent|wparam, 1 },
1895  { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1898  { 0 }
1899 };
1900 static const struct message WmSHOWNATopVisible[] = {
1901  { WM_SHOWWINDOW, sent|wparam, 1 },
1903  { WM_NCPAINT, sent|wparam|optional, 1 },
1907  { 0 }
1908 };
1909 static const struct message WmSHOWNATopInvisible[] = {
1910  { WM_NOTIFYFORMAT, sent|optional },
1911  { WM_QUERYUISTATE, sent|optional },
1916  { WM_SHOWWINDOW, sent|wparam, 1 },
1918  { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1919  { WM_NCPAINT, sent|wparam|optional, 1 },
1924  { WM_NCPAINT, sent|wparam|optional, 1 },
1926  { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1928  { WM_MOVE, sent },
1929  { 0 }
1930 };
1931 
1932 static const struct message WmTrackPopupMenu[] = {
1933  { HCBT_CREATEWND, hook },
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 },
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 },
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 },
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 
2004 static struct recvd_message* sequence;
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);
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 );
2065  DUMP( SWP_NOCOPYBITS );
2068  DUMP( SWP_DEFERERASE );
2070  DUMP( SWP_NOZORDER );
2071  DUMP( SWP_NOREDRAW );
2072  DUMP( SWP_NOSIZE );
2073  DUMP( SWP_NOMOVE );
2076  if (flags) sprintf(buffer + strlen(buffer),"|0x%04x", flags);
2077  return buffer + 1;
2078 #undef DUMP
2079 }
2080 
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 ||
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 
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;
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;
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  {
2220  MEASUREITEMSTRUCT *mis = (MEASUREI