ReactOS  0.4.12-dev-919-gfc3b8d5
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 },
572  { 0 }
573 };
574 /* ShowWindow(SW_RESTORE) for a not visible minimized overlapped window */
575 static const struct message WmShowRestoreMinOverlappedSeq[] = {
578  { WM_GETTEXT, sent|optional },
580  { WM_WINDOWPOSCHANGING, sent|optional }, /* SWP_NOSIZE|SWP_NOMOVE */
583  { WM_MOVE, sent|optional },
585  { WM_GETTEXT, sent|optional },
600  { WM_GETTEXT, sent|optional },
601  { WM_NCPAINT, sent|wparam|optional, 1 },
603  { WM_ERASEBKGND, sent },
605  { WM_MOVE, sent|defwinproc },
610  { WM_NCPAINT, sent|wparam|optional, 1 },
614  { WM_ACTIVATE, sent|wparam, 1 },
615  { WM_GETTEXT, sent|optional },
616  { WM_PAINT, sent|optional },
620  { 0 }
621 };
622 /* ShowWindow(SW_SHOWMINIMIZED) for a not visible overlapped window */
623 static const struct message WmShowMinOverlappedSeq[] = {
626  { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
630  { WM_GETTEXT, sent|optional },
634  { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
635  { WM_NCPAINT, sent|optional },
638  { WM_MOVE, sent|defwinproc },
641  { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
642  { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
643  { EVENT_SYSTEM_MINIMIZESTART, winevent_hook|wparam|lparam, 0, 0 },
648 
649  /* Vista sometimes restores the window right away... */
660  { WM_GETTEXT, sent|optional },
666  { WM_NCPAINT, sent|optional },
675 
676  { WM_PAINT, sent|optional },
679  { 0 }
680 };
681 /* ShowWindow(SW_HIDE) for a visible overlapped window */
682 static const struct message WmHideOverlappedSeq[] = {
683  { WM_SHOWWINDOW, sent|wparam, 0 },
685  { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
687  { WM_SIZE, sent|optional }, /* XP doesn't send it */
688  { WM_MOVE, sent|optional }, /* XP doesn't send it */
696  { 0 }
697 };
698 /* DestroyWindow for a visible overlapped window */
699 static const struct message WmDestroyOverlappedSeq[] = {
700  { HCBT_DESTROYWND, hook },
701  { 0x0090, sent|optional },
703  { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
704  { 0x0090, sent|optional },
712  { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
713  { WM_DESTROY, sent },
714  { WM_NCDESTROY, sent },
715  { 0 }
716 };
717 /* CreateWindow(WS_MAXIMIZE|WS_VISIBLE) for popup window */
718 static const struct message WmCreateMaxPopupSeq[] = {
719  { HCBT_CREATEWND, hook },
720  { WM_NCCREATE, sent },
721  { WM_NCCALCSIZE, sent|wparam, 0 },
722  { WM_CREATE, sent },
723  { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
725  { WM_MOVE, sent },
727  { WM_GETMINMAXINFO, sent },
731  { WM_MOVE, sent|defwinproc },
733  { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
734  { WM_SHOWWINDOW, sent|wparam, 1 },
736  { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
737  { HCBT_ACTIVATE, hook },
738  { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
741  { WM_NCPAINT, sent|wparam|optional, 1 },
744  { WM_ACTIVATEAPP, sent|wparam, 1 },
745  { WM_NCACTIVATE, sent },
746  { WM_ACTIVATE, sent|wparam, 1 },
747  { HCBT_SETFOCUS, hook },
750  { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
752  { WM_GETTEXT, sent|optional },
754  { WM_NCPAINT, sent|wparam|optional, 1 },
759  { 0 }
760 };
761 /* CreateWindow(WS_MAXIMIZE) for popup window, not initially visible */
762 static const struct message WmCreateInvisibleMaxPopupSeq[] = {
763  { HCBT_CREATEWND, hook },
764  { WM_NCCREATE, sent },
765  { WM_NCCALCSIZE, sent|wparam, 0 },
766  { WM_CREATE, sent },
767  { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
769  { WM_MOVE, sent },
771  { WM_GETMINMAXINFO, sent },
775  { WM_MOVE, sent|defwinproc },
777  { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
778  { 0 }
779 };
780 /* ShowWindow(SW_SHOWMAXIMIZED) for a resized not visible popup window */
781 static const struct message WmShowMaxPopupResizedSeq_todo[] = {
783  { WM_GETMINMAXINFO, sent },
786  { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
787  { HCBT_ACTIVATE, hook },
788  { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
791  { WM_NCPAINT, sent|wparam|optional, 1 },
794  { WM_ACTIVATEAPP, sent|wparam, 1 },
795  { WM_NCACTIVATE, sent },
796  { WM_ACTIVATE, sent|wparam, 1 },
797  { HCBT_SETFOCUS, hook },
800  { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
802  { WM_GETTEXT, sent|optional },
803  { WM_NCPAINT, sent|wparam|optional, 1 },
806  /* WinNT4.0 sends WM_MOVE */
809  { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
810  { 0 }
811 };
812 static const struct message WmShowMaxPopupResizedSeq[] = {
814  { WM_GETMINMAXINFO, sent },
817  { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
818  { HCBT_ACTIVATE, hook },
819  { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
822  { WM_NCPAINT, sent|wparam|optional, 1 },
825  { WM_ACTIVATEAPP, sent|wparam, 1 },
826  { WM_NCACTIVATE, sent },
827  { WM_ACTIVATE, sent|wparam, 1 },
828  { HCBT_SETFOCUS, hook },
831  { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
833  { WM_GETTEXT, sent|optional },
834  { WM_NCPAINT, sent|optional }, /* We'll check WM_NCPAINT behaviour in another test */
837  /* WinNT4.0 sends WM_MOVE */
840  { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
841  { 0 }
842 };
843 /* ShowWindow(SW_SHOWMAXIMIZED) for a not visible popup window */
844 static const struct message WmShowMaxPopupSeq[] = {
846  { WM_GETMINMAXINFO, sent },
849  { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
850  { HCBT_ACTIVATE, hook },
851  { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
854  { WM_NCPAINT, sent|wparam|optional, 1 },
857  { WM_ACTIVATEAPP, sent|wparam, 1 },
858  { WM_NCACTIVATE, sent },
859  { WM_ACTIVATE, sent|wparam, 1 },
860  { HCBT_SETFOCUS, hook },
863  { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
865  { WM_GETTEXT, sent|optional },
867  { WM_NCPAINT, sent|wparam|optional, 1 },
872  { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
873  { 0 }
874 };
875 /* CreateWindow(WS_VISIBLE) for popup window */
876 static const struct message WmCreatePopupSeq[] = {
877  { HCBT_CREATEWND, hook },
878  { WM_NCCREATE, sent },
879  { WM_NCCALCSIZE, sent|wparam, 0 },
880  { WM_CREATE, sent },
881  { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
883  { WM_MOVE, sent },
884  { WM_SHOWWINDOW, sent|wparam, 1 },
886  { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
887  { HCBT_ACTIVATE, hook },
888  { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
891  { WM_NCPAINT, sent|wparam|optional, 1 },
894  { WM_ACTIVATEAPP, sent|wparam, 1 },
895  { WM_NCACTIVATE, sent },
896  { WM_ACTIVATE, sent|wparam, 1 },
897  { HCBT_SETFOCUS, hook },
900  { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
902  { WM_GETTEXT, sent|optional },
904  { WM_NCPAINT, sent|wparam|optional, 1 },
907  { 0 }
908 };
909 /* ShowWindow(SW_SHOWMAXIMIZED) for a visible popup window */
910 static const struct message WmShowVisMaxPopupSeq[] = {
912  { WM_GETMINMAXINFO, sent },
913  { WM_GETTEXT, sent|optional },
915  { WM_GETTEXT, sent|optional },
918  { WM_NCPAINT, sent|wparam|optional, 1 },
921  { WM_MOVE, sent|defwinproc },
923  { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
924  { 0 }
925 };
926 /* CreateWindow (for a child popup window, not initially visible) */
927 static const struct message WmCreateChildPopupSeq[] = {
928  { HCBT_CREATEWND, hook },
929  { WM_NCCREATE, sent },
930  { WM_NCCALCSIZE, sent|wparam, 0 },
931  { WM_CREATE, sent },
932  { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
934  { WM_MOVE, sent },
935  { 0 }
936 };
937 /* CreateWindow (for a popup window, not initially visible,
938  * which sets WS_VISIBLE in WM_CREATE handler)
939  */
940 static const struct message WmCreateInvisiblePopupSeq[] = {
941  { HCBT_CREATEWND, hook },
942  { WM_NCCREATE, sent },
943  { WM_NCCALCSIZE, sent|wparam, 0 },
944  { WM_CREATE, sent },
945  { WM_STYLECHANGING, sent },
946  { WM_STYLECHANGED, sent },
947  { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
949  { WM_MOVE, sent },
950  { 0 }
951 };
952 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER)
953  * for a popup window with WS_VISIBLE style set
954  */
955 static const struct message WmShowVisiblePopupSeq_2[] = {
957  { 0 }
958 };
959 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
960  * for a popup window with WS_VISIBLE style set
961  */
962 static const struct message WmShowVisiblePopupSeq_3[] = {
964  { HCBT_ACTIVATE, hook },
965  { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
968  { WM_NCACTIVATE, sent },
969  { WM_ACTIVATE, sent|wparam, 1 },
970  { HCBT_SETFOCUS, hook },
971  { WM_KILLFOCUS, sent|parent },
975  { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
977  { WM_GETTEXT, sent|optional },
979  { 0 }
980 };
981 /* CreateWindow (for a popup window with WS_VISIBLE style set and extreme location)
982  */
983 static const struct message WmShowPopupExtremeLocationSeq[] = {
984  { HCBT_CREATEWND, hook },
985  { WM_NCCREATE, sent },
986  { WM_NCCALCSIZE, sent|wparam, 0 },
987  { WM_CREATE, sent },
988  { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
990  { WM_MOVE, sent },
991  { WM_SHOWWINDOW, sent|wparam, 1 },
993  { HCBT_ACTIVATE, hook },
996  { WM_ACTIVATEAPP, sent },
997  { WM_NCACTIVATE, sent },
998  { WM_ACTIVATE, sent },
1002  { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1003  { HCBT_SETFOCUS, hook },
1005  { WM_NCPAINT, sent|wparam, 1 },
1006  { WM_ERASEBKGND, sent },
1008  /* occasionally received on test machines */
1009  { WM_NCPAINT, sent|optional },
1011  { 0 }
1012 };
1013 /* CreateWindow (for a popup window with WS_VISIBLE style set)
1014  */
1015 static const struct message WmShowPopupFirstDrawSeq_1[] = {
1016  { HCBT_CREATEWND, hook },
1017  { WM_NCCREATE, sent },
1018  { WM_NCCALCSIZE, sent|wparam, 0 },
1019  { WM_CREATE, sent },
1020  { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1022  { WM_MOVE, sent },
1023  { WM_SHOWWINDOW, sent|wparam, 1 },
1025  { HCBT_ACTIVATE, hook },
1028  { WM_ACTIVATEAPP, sent },
1029  { WM_NCACTIVATE, sent },
1030  { WM_ACTIVATE, sent },
1034  { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1035  { HCBT_SETFOCUS, hook },
1037  { WM_NCPAINT, sent|wparam, 1 },
1038  { WM_ERASEBKGND, sent },
1040  { WM_PAINT, sent },
1041  /* occasionally received on test machines */
1044  { 0 }
1045 };
1046 /* CreateWindow (for a popup window that is shown with ShowWindow(SW_SHOWMAXIMIZED))
1047  */
1048 static const struct message WmShowPopupFirstDrawSeq_2[] = {
1049  { HCBT_CREATEWND, hook },
1050  { WM_NCCREATE, sent },
1051  { WM_NCCALCSIZE, sent|wparam, 0 },
1052  { WM_CREATE, sent },
1053  { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1055  { WM_MOVE, sent },
1057  { WM_GETMINMAXINFO, sent },
1059  { WM_NCCALCSIZE, sent|wparam, TRUE },
1060  { HCBT_ACTIVATE, hook },
1062  { WM_NCPAINT, sent|optional|wparam, 1 },
1066  { WM_ACTIVATEAPP, sent },
1067  { WM_NCACTIVATE, sent },
1068  { WM_ACTIVATE, sent },
1072  { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1073  { HCBT_SETFOCUS, hook },
1075  { WM_NCPAINT, sent|wparam, 1 },
1076  { WM_ERASEBKGND, sent },
1078  { WM_MOVE, sent|defwinproc },
1079  { WM_SIZE, sent|defwinproc, 0 },
1080  { WM_PAINT, sent},
1081  /* occasionally received on test machines */
1084  { 0 }
1085 };
1086 static const struct message WmFirstDrawSetWindowPosSeq1[] = {
1087  { HCBT_CREATEWND, hook },
1088  { WM_NCCREATE, sent },
1089  { WM_NCCALCSIZE, sent|wparam, 0 },
1090  { WM_CREATE, sent },
1091  { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1093  { WM_MOVE, sent },
1095  { HCBT_ACTIVATE, hook },
1098  { WM_ACTIVATEAPP, sent },
1099  { WM_NCACTIVATE, sent },
1100  { WM_ACTIVATE, sent },
1104  { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1105  { HCBT_SETFOCUS, hook },
1107  { WM_NCPAINT, sent|wparam, 1 },
1108  { WM_ERASEBKGND, sent },
1110  { WM_MOVE, sent|defwinproc },
1111  { 0 }
1112 };
1113 static const struct message WmFirstDrawSetWindowPosSeq2[] = {
1114  { HCBT_CREATEWND, hook },
1115  { WM_NCCREATE, sent },
1116  { WM_NCCALCSIZE, sent|wparam, 0 },
1117  { WM_CREATE, sent },
1118  { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1120  { WM_MOVE, sent },
1122  { HCBT_ACTIVATE, hook },
1125  { WM_ACTIVATEAPP, sent },
1126  { WM_NCACTIVATE, sent },
1127  { WM_ACTIVATE, sent },
1131  { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1132  { HCBT_SETFOCUS, hook },
1135  { WM_MOVE, sent|defwinproc },
1136  { 0 }
1137 };
1138 static const struct message WmFirstDrawSetWindowPosSeq3[] = {
1139  { HCBT_CREATEWND, hook },
1140  { WM_NCCREATE, sent },
1141  { WM_NCCALCSIZE, sent|wparam, 0 },
1142  { WM_CREATE, sent },
1143  { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1145  { WM_MOVE, sent },
1147  /* Probably shouldn't happen, but not part of this test */
1151  { WM_ACTIVATE, sent|optional },
1154  { 0 }
1155 };
1156 static const struct message WmFirstDrawSetWindowPosSeq4[] = {
1157  { HCBT_CREATEWND, hook },
1158  { WM_NCCREATE, sent },
1159  { WM_NCCALCSIZE, sent|wparam, 0 },
1160  { WM_CREATE, sent },
1161  { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1163  { WM_MOVE, sent },
1165  { HCBT_ACTIVATE, hook },
1168  { WM_ACTIVATEAPP, sent },
1169  { WM_NCACTIVATE, sent },
1170  { WM_ACTIVATE, sent },
1174  { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1175  { HCBT_SETFOCUS, hook },
1177  { WM_NCPAINT, sent|wparam, 1 },
1178  { WM_ERASEBKGND, sent },
1180  { 0 }
1181 };
1182 static const struct message WmFirstDrawSetWindowPosSeq5[] = {
1183  { HCBT_CREATEWND, hook },
1184  { WM_NCCREATE, sent },
1185  { WM_NCCALCSIZE, sent|wparam, 0 },
1186  { WM_CREATE, sent },
1187  { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1189  { WM_MOVE, sent },
1191  { HCBT_ACTIVATE, hook },
1194  { WM_ACTIVATEAPP, sent },
1195  { WM_NCACTIVATE, sent },
1196  { WM_ACTIVATE, sent },
1200  { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1201  { HCBT_SETFOCUS, hook },
1204  { 0 }
1205 };
1206 static const struct message WmFirstDrawChildSeq1[] = {
1207  { 0 }
1208 };
1209 static const struct message WmFirstDrawChildSeq2[] = {
1210  { WM_NCPAINT, sent|wparam, 1 },
1211  { WM_ERASEBKGND, sent },
1212  /* occasionally received on test machines */
1213  { WM_NCPAINT, sent|optional },
1215  { 0 }
1216 };
1217 /* CreateWindow (for child window, not initially visible) */
1218 static const struct message WmCreateChildSeq[] = {
1219  { HCBT_CREATEWND, hook },
1220  { WM_NCCREATE, sent },
1221  /* child is inserted into parent's child list after WM_NCCREATE returns */
1222  { WM_NCCALCSIZE, sent|wparam, 0 },
1223  { WM_CREATE, sent },
1224  { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1226  { WM_MOVE, sent },
1228  { 0 }
1229 };
1230 /* CreateWindow (for maximized child window, not initially visible) */
1231 static const struct message WmCreateMaximizedChildSeq[] = {
1232  { HCBT_CREATEWND, hook },
1233  { WM_NCCREATE, sent },
1234  { WM_NCCALCSIZE, sent|wparam, 0 },
1235  { WM_CREATE, sent },
1236  { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1238  { WM_MOVE, sent },
1240  { WM_GETMINMAXINFO, sent },
1242  { WM_NCCALCSIZE, sent|wparam, 1 },
1245  { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1247  { 0 }
1248 };
1249 /* CreateWindow (for a child window, initially visible) */
1250 static const struct message WmCreateVisibleChildSeq[] = {
1251  { HCBT_CREATEWND, hook },
1252  { WM_NCCREATE, sent },
1253  /* child is inserted into parent's child list after WM_NCCREATE returns */
1254  { WM_NCCALCSIZE, sent|wparam, 0 },
1255  { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
1256  { WM_CREATE, sent },
1257  { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1259  { WM_MOVE, sent },
1261  { WM_SHOWWINDOW, sent|wparam, 1 },
1263  { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1266  { WM_NCCALCSIZE, sent|wparam|optional, 1 }, /* WinXP */
1267  { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1268  { 0 }
1269 };
1270 /* ShowWindow(SW_SHOW) for a not visible child window */
1271 static const struct message WmShowChildSeq[] = {
1272  { WM_SHOWWINDOW, sent|wparam, 1 },
1274  { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1277  { 0 }
1278 };
1279 /* ShowWindow(SW_HIDE) for a visible child window */
1280 static const struct message WmHideChildSeq[] = {
1281  { WM_SHOWWINDOW, sent|wparam, 0 },
1283  { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
1286  { 0 }
1287 };
1288 /* ShowWindow(SW_HIDE) for a visible child window checking all parent events*/
1289 static const struct message WmHideChildSeq2[] = {
1290  { WM_SHOWWINDOW, sent|wparam, 0 },
1292  { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
1295  { 0 }
1296 };
1297 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
1298  * for a not visible child window
1299  */
1300 static const struct message WmShowChildSeq_2[] = {
1302  { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1303  { WM_CHILDACTIVATE, sent },
1305  { 0 }
1306 };
1307 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE)
1308  * for a not visible child window
1309  */
1310 static const struct message WmShowChildSeq_3[] = {
1312  { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1314  { 0 }
1315 };
1316 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
1317  * for a visible child window with a caption
1318  */
1319 static const struct message WmShowChildSeq_4[] = {
1321  { WM_CHILDACTIVATE, sent },
1322  { 0 }
1323 };
1324 /* ShowWindow(SW_MINIMIZE) for child with invisible parent */
1325 static const struct message WmShowChildInvisibleParentSeq_1[] = {
1328  { WM_NCCALCSIZE, sent|wparam, 1 },
1329  { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1332  { WM_MOVE, sent|defwinproc },
1334  { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1335  { EVENT_SYSTEM_MINIMIZESTART, winevent_hook|wparam|lparam, 0, 0 },
1336  /* FIXME: Wine creates an icon/title window while Windows doesn't */
1338  { WM_GETTEXT, sent|optional },
1339  { 0 }
1340 };
1341 /* repeated ShowWindow(SW_MINIMIZE) for child with invisible parent */
1344  { 0 }
1345 };
1346 /* ShowWindow(SW_MAXIMIZE) for child with invisible parent */
1347 static const struct message WmShowChildInvisibleParentSeq_2[] = {
1349  { WM_GETMINMAXINFO, sent },
1351  { WM_NCCALCSIZE, sent|wparam, 1 },
1352  { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1353  { WM_CHILDACTIVATE, sent },
1356  { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1357  { 0 }
1358 };
1359 /* repeated ShowWindow(SW_MAXIMIZE) for child with invisible parent */
1362  { 0 }
1363 };
1364 /* ShowWindow(SW_SHOWMINIMIZED) for child with invisible parent */
1365 static const struct message WmShowChildInvisibleParentSeq_3[] = {
1368  { WM_NCCALCSIZE, sent|wparam, 1 },
1369  { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1370  { WM_CHILDACTIVATE, sent },
1372  { WM_MOVE, sent|defwinproc },
1374  { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1375  { EVENT_SYSTEM_MINIMIZESTART, winevent_hook|wparam|lparam, 0, 0 },
1376  /* FIXME: Wine creates an icon/title window while Windows doesn't */
1378  { WM_GETTEXT, sent|optional },
1379  { 0 }
1380 };
1381 /* repeated ShowWindow(SW_SHOWMINIMIZED) for child with invisible parent */
1384  { 0 }
1385 };
1386 /* ShowWindow(SW_SHOWMINNOACTIVE) for child with invisible parent */
1387 static const struct message WmShowChildInvisibleParentSeq_4[] = {
1390  { WM_NCCALCSIZE, sent|wparam, 1 },
1391  { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1393  { WM_MOVE, sent|defwinproc },
1395  { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1396  { EVENT_SYSTEM_MINIMIZESTART, winevent_hook|wparam|lparam, 0, 0 },
1397  /* FIXME: Wine creates an icon/title window while Windows doesn't */
1399  { WM_GETTEXT, sent|optional },
1400  { 0 }
1401 };
1402 /* repeated ShowWindow(SW_SHOWMINNOACTIVE) for child with invisible parent */
1405  { 0 }
1406 };
1407 /* ShowWindow(SW_SHOW) for child with invisible parent */
1408 static const struct message WmShowChildInvisibleParentSeq_5[] = {
1409  { WM_SHOWWINDOW, sent|wparam, 1 },
1410  { 0 }
1411 };
1412 /* ShowWindow(SW_HIDE) for child with invisible parent */
1413 static const struct message WmHideChildInvisibleParentSeq[] = {
1414  { WM_SHOWWINDOW, sent|wparam, 0 },
1415  { 0 }
1416 };
1417 /* SetWindowPos(SWP_SHOWWINDOW) for child with invisible parent */
1418 static const struct message WmShowChildInvisibleParentSeq_6[] = {
1420  { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1422  { 0 }
1423 };
1424 /* SetWindowPos(SWP_HIDEWINDOW) for child with invisible parent */
1425 static const struct message WmHideChildInvisibleParentSeq_2[] = {
1427  { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
1429  { 0 }
1430 };
1431 /* DestroyWindow for a visible child window */
1432 static const struct message WmDestroyChildSeq[] = {
1433  { HCBT_DESTROYWND, hook },
1434  { 0x0090, sent|optional },
1436  { WM_SHOWWINDOW, sent|wparam, 0 },
1438  { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
1441  { HCBT_SETFOCUS, hook }, /* set focus to a parent */
1442  { WM_KILLFOCUS, sent },
1445  { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1446  { WM_SETFOCUS, sent|parent },
1447  { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
1448  { WM_DESTROY, sent },
1449  { WM_DESTROY, sent|optional }, /* some other (IME?) window */
1450  { WM_NCDESTROY, sent|optional }, /* some other (IME?) window */
1451  { WM_NCDESTROY, sent },
1452  { 0 }
1453 };
1454 /* visible child window destroyed by thread exit */
1455 static const struct message WmExitThreadSeq[] = {
1456  { WM_NCDESTROY, sent }, /* actually in grandchild */
1457  { WM_PAINT, sent|parent },
1459  { 0 }
1460 };
1461 /* DestroyWindow for a visible child window with invisible parent */
1462 static const struct message WmDestroyInvisibleChildSeq[] = {
1463  { HCBT_DESTROYWND, hook },
1464  { 0x0090, sent|optional },
1466  { WM_SHOWWINDOW, sent|wparam, 0 },
1467  { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
1468  { WM_DESTROY, sent },
1469  { WM_NCDESTROY, sent },
1470  { 0 }
1471 };
1472 /* Resizing child window with MoveWindow (32) */
1475  { WM_NCCALCSIZE, sent|wparam, 1 },
1479  { WM_MOVE, sent|defwinproc },
1481  { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1482  { 0 }
1483 };
1484 /* Creation of a custom dialog (32) */
1485 static const struct message WmCreateCustomDialogSeq[] = {
1486  { HCBT_CREATEWND, hook },
1487  { WM_GETMINMAXINFO, sent },
1488  { WM_NCCREATE, sent },
1489  { WM_NCCALCSIZE, sent|wparam, 0 },
1490  { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
1491  { WM_CREATE, sent },
1492  { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1493  { WM_NOTIFYFORMAT, sent|optional },
1494  { WM_QUERYUISTATE, sent|optional },
1499  { WM_SHOWWINDOW, sent|wparam, 1 },
1501  { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1502  { HCBT_ACTIVATE, hook },
1503  { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
1504 
1505 
1507 
1509 
1510  { WM_NCACTIVATE, sent },
1514  { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
1515  { WM_ACTIVATE, sent|wparam, 1 },
1516  { WM_GETTEXT, sent|optional },
1517  { WM_KILLFOCUS, sent|parent },
1521  { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1522  { WM_SETFOCUS, sent },
1524  { WM_NCPAINT, sent|wparam, 1 },
1527  { WM_ERASEBKGND, sent },
1530  { WM_GETTEXT, sent|optional },
1531  { WM_GETTEXT, sent|optional },
1533  { WM_NCPAINT, sent|optional },
1538  { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1540  { WM_MOVE, sent },
1541  { 0 }
1542 };
1543 /* Calling EndDialog for a custom dialog (32) */
1544 static const struct message WmEndCustomDialogSeq[] = {
1546  { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
1548  { WM_GETTEXT, sent|optional },
1549  { HCBT_ACTIVATE, hook },
1550  { WM_NCACTIVATE, sent|wparam, 0 },
1553  { WM_ACTIVATE, sent|wparam, 0 },
1554  { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
1559  { HCBT_SETFOCUS, hook },
1560  { WM_KILLFOCUS, sent },
1564  { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1566  { 0 }
1567 };
1568 /* ShowWindow(SW_SHOW) for a custom dialog (initially invisible) */
1569 static const struct message WmShowCustomDialogSeq[] = {
1570  { WM_SHOWWINDOW, sent|wparam, 1 },
1572  { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1573  { HCBT_ACTIVATE, hook },
1574  { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
1575 
1577 
1580  { WM_NCACTIVATE, sent },
1581  { WM_ACTIVATE, sent|wparam, 1 },
1582  { WM_GETTEXT, sent|optional },
1583 
1584  { WM_KILLFOCUS, sent|parent },
1588  { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1589  { WM_SETFOCUS, sent },
1591  { WM_NCPAINT, sent|wparam, 1 },
1592  { WM_ERASEBKGND, sent },
1595  { 0 }
1596 };
1597 /* Creation and destruction of a modal dialog (32) */
1598 static const struct message WmModalDialogSeq[] = {
1599  { WM_CANCELMODE, sent|parent },
1600  { HCBT_SETFOCUS, hook },
1601  { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1602  { WM_KILLFOCUS, sent|parent },
1604  { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, 0, 0 },
1605  { WM_ENABLE, sent|parent|wparam, 0 },
1606  { HCBT_CREATEWND, hook },
1607  { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
1608  { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1609  { WM_SETFONT, sent },
1610  { WM_INITDIALOG, sent },
1611  { WM_CHANGEUISTATE, sent|optional },
1612  { WM_UPDATEUISTATE, sent|optional },
1613  { WM_SHOWWINDOW, sent },
1614  { HCBT_ACTIVATE, hook },
1615  { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
1618  { WM_NCACTIVATE, sent },
1619  { WM_GETTEXT, sent|optional },
1620  { WM_ACTIVATE, sent|wparam, 1 },
1622  { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1623  { WM_NCPAINT, sent|optional },
1624  { WM_GETTEXT, sent|optional },
1628  { WM_GETTEXT, sent|optional },
1630  { WM_NCPAINT, sent|optional },
1631  { WM_GETTEXT, sent|optional },
1634  { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1635  { WM_PAINT, sent|optional },
1658  { WM_TIMER, sent },
1659  { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, 0, 0 },
1660  { WM_ENABLE, sent|parent|wparam, 1 },
1662  { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
1664  { WM_GETTEXT, sent|optional },
1665  { HCBT_ACTIVATE, hook },
1666  { WM_NCACTIVATE, sent|wparam, 0 },
1667  { WM_GETTEXT, sent|optional },
1668  { WM_ACTIVATE, sent|wparam, 0 },
1669  { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
1672  { HCBT_SETFOCUS, hook },
1674  { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1676  { EVENT_SYSTEM_DIALOGEND, winevent_hook|wparam|lparam, 0, 0 },
1677  { HCBT_DESTROYWND, hook },
1678  { 0x0090, sent|optional },
1679  { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
1680  { WM_DESTROY, sent },
1681  { WM_NCDESTROY, sent },
1682  { 0 }
1683 };
1684 static const struct message WmModalDialogSeq_2[] = {
1685  { WM_CANCELMODE, sent },
1686  { HCBT_SETFOCUS, hook },
1687  { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1688  { WM_KILLFOCUS, sent },
1690  { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, 0, 0 },
1691  { WM_ENABLE, sent|wparam, 0 },
1692  { HCBT_CREATEWND, hook },
1693  { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
1694  { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1695  { WM_SETFONT, sent },
1696  { WM_INITDIALOG, sent },
1697  { WM_CHANGEUISTATE, sent|optional },
1698  { WM_UPDATEUISTATE, sent|optional },
1699  { WM_ENABLE, sent|wparam, 1 },
1701  { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
1702  { WM_CHANGEUISTATE, sent|optional },
1703  { WM_UPDATEUISTATE, sent|optional },
1704  { HCBT_DESTROYWND, hook },
1705  { 0x0090, sent|optional },
1706  { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
1707  { WM_DESTROY, sent },
1708  { WM_NCDESTROY, sent },
1709  { 0 }
1710 };
1711 /* SetMenu for NonVisible windows with size change*/
1714  { WM_NCCALCSIZE, sent|wparam, 1 },
1715  { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
1717  { WM_MOVE, sent|defwinproc },
1719  { WM_NCCALCSIZE,sent|wparam|optional, 1 }, /* XP */
1720  { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1721  { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* XP sends a duplicate */
1722  { WM_GETTEXT, sent|optional },
1724  { 0 }
1725 };
1726 /* SetMenu for NonVisible windows with no size change */
1729  { WM_NCCALCSIZE, sent|wparam, 1 },
1731  { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1732  { 0 }
1733 };
1734 /* SetMenu for Visible windows with size change */
1735 static const struct message WmSetMenuVisibleSizeChangeSeq[] = {
1737  { WM_NCCALCSIZE, sent|wparam, 1 },
1738  { 0x0093, sent|defwinproc|optional },
1739  { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
1740  { WM_NCPAINT, sent|optional }, /* wparam != 1 */
1741  { 0x0093, sent|defwinproc|optional },
1742  { 0x0093, sent|defwinproc|optional },
1743  { 0x0091, sent|defwinproc|optional },
1744  { 0x0092, sent|defwinproc|optional },
1747  { WM_ACTIVATE, sent|optional },
1749  { WM_MOVE, sent|defwinproc },
1751  { 0x0093, sent|optional },
1753  { 0x0093, sent|defwinproc|optional },
1754  { WM_NCPAINT, sent|optional }, /* wparam != 1 */
1755  { 0x0093, sent|defwinproc|optional },
1756  { 0x0093, sent|defwinproc|optional },
1757  { 0x0091, sent|defwinproc|optional },
1758  { 0x0092, sent|defwinproc|optional },
1760  { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1761  { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* XP sends a duplicate */
1762  { 0 }
1763 };
1764 /* SetMenu for Visible windows with no size change */
1765 static const struct message WmSetMenuVisibleNoSizeChangeSeq[] = {
1767  { WM_NCCALCSIZE, sent|wparam, 1 },
1768  { WM_NCPAINT, sent|optional }, /* wparam != 1 */
1771  { WM_ACTIVATE, sent|optional },
1773  { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1774  { 0 }
1775 };
1776 /* DrawMenuBar for a visible window */
1777 static const struct message WmDrawMenuBarSeq[] =
1778 {
1780  { WM_NCCALCSIZE, sent|wparam, 1 },
1781  { 0x0093, sent|defwinproc|optional },
1782  { WM_NCPAINT, sent|optional }, /* wparam != 1 */
1783  { 0x0093, sent|defwinproc|optional },
1784  { 0x0093, sent|defwinproc|optional },
1785  { 0x0091, sent|defwinproc|optional },
1786  { 0x0092, sent|defwinproc|optional },
1790  { 0x0093, sent|optional },
1791  { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1792  { 0 }
1793 };
1794 
1795 static const struct message WmSetRedrawFalseSeq[] =
1796 {
1797  { WM_SETREDRAW, sent|wparam, 0 },
1798  { 0 }
1799 };
1800 
1801 static const struct message WmSetRedrawTrueSeq[] =
1802 {
1803  { WM_SETREDRAW, sent|wparam, 1 },
1804  { 0 }
1805 };
1806 
1807 static const struct message WmEnableWindowSeq_1[] =
1808 {
1809  { WM_CANCELMODE, sent|wparam|lparam, 0, 0 },
1810  { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, 0, 0 },
1812  { WM_KILLFOCUS, sent|optional },
1813  { WM_ENABLE, sent|wparam|lparam, FALSE, 0 },
1814  { 0 }
1815 };
1816 
1817 static const struct message WmEnableWindowSeq_2[] =
1818 {
1819  { WM_CANCELMODE, sent|wparam|lparam, 0, 0 },
1820  { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, 0, 0 },
1821  { 0 }
1822 };
1823 
1824 static const struct message WmEnableWindowSeq_3[] =
1825 {
1826  { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, 0, 0 },
1827  { WM_ENABLE, sent|wparam|lparam, TRUE, 0 },
1828  { 0 }
1829 };
1830 
1831 static const struct message WmEnableWindowSeq_4[] =
1832 {
1833  { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, 0, 0 },
1834  { 0 }
1835 };
1836 
1837 static const struct message WmGetScrollRangeSeq[] =
1838 {
1839  { SBM_GETRANGE, sent },
1840  { 0 }
1841 };
1842 static const struct message WmGetScrollInfoSeq[] =
1843 {
1844  { SBM_GETSCROLLINFO, sent },
1845  { 0 }
1846 };
1847 static const struct message WmSetScrollRangeSeq[] =
1848 {
1849  /* MSDN claims that Windows sends SBM_SETRANGE message, but win2k SP4
1850  sends SBM_SETSCROLLINFO.
1851  */
1852  { SBM_SETSCROLLINFO, sent },
1853  { 0 }
1854 };
1855 /* SetScrollRange for a window without a non-client area */
1856 static const struct message WmSetScrollRangeHSeq_empty[] =
1857 {
1858  { EVENT_OBJECT_VALUECHANGE, winevent_hook|wparam|lparam, OBJID_HSCROLL, 0 },
1859  { 0 }
1860 };
1861 static const struct message WmSetScrollRangeVSeq_empty[] =
1862 {
1863  { EVENT_OBJECT_VALUECHANGE, winevent_hook|wparam|lparam, OBJID_VSCROLL, 0 },
1864  { 0 }
1865 };
1866 static const struct message WmSetScrollRangeHVSeq[] =
1867 {
1869  { WM_NCCALCSIZE, sent|wparam, 1 },
1873  { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1874  { EVENT_OBJECT_VALUECHANGE, winevent_hook|lparam|optional, 0/*OBJID_HSCROLL or OBJID_VSCROLL*/, 0 },
1875  { 0 }
1876 };
1877 /* SetScrollRange for a window with a non-client area */
1878 static const struct message WmSetScrollRangeHV_NC_Seq[] =
1879 {
1881  { WM_NCCALCSIZE, sent|wparam, 1 },
1882  { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
1883  { WM_NCPAINT, sent|optional },
1884  { WM_STYLECHANGING, sent|defwinproc|optional },
1885  { WM_STYLECHANGED, sent|defwinproc|optional },
1886  { WM_STYLECHANGING, sent|defwinproc|optional },
1887  { WM_STYLECHANGED, sent|defwinproc|optional },
1888  { WM_STYLECHANGING, sent|defwinproc|optional },
1889  { WM_STYLECHANGED, sent|defwinproc|optional },
1890  { WM_STYLECHANGING, sent|defwinproc|optional },
1891  { WM_STYLECHANGED, sent|defwinproc|optional },
1895  { WM_CTLCOLORDLG, sent|defwinproc|optional }, /* sent to a parent of the dialog */
1898  { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1899  { EVENT_OBJECT_VALUECHANGE, winevent_hook|lparam|optional, 0/*OBJID_HSCROLL or OBJID_VSCROLL*/, 0 },
1900  { WM_GETTEXT, sent|optional },
1901  { WM_GETTEXT, sent|optional },
1902  { WM_GETTEXT, sent|optional },
1903  { WM_GETTEXT, sent|optional },
1904  { 0 }
1905 };
1906 /* test if we receive the right sequence of messages */
1907 /* after calling ShowWindow( SW_SHOWNA) */
1908 static const struct message WmSHOWNAChildInvisParInvis[] = {
1909  { WM_SHOWWINDOW, sent|wparam, 1 },
1910  { 0 }
1911 };
1912 static const struct message WmSHOWNAChildVisParInvis[] = {
1913  { WM_SHOWWINDOW, sent|wparam, 1 },
1914  { 0 }
1915 };
1916 static const struct message WmSHOWNAChildVisParVis[] = {
1917  { WM_SHOWWINDOW, sent|wparam, 1 },
1919  { 0 }
1920 };
1921 static const struct message WmSHOWNAChildInvisParVis[] = {
1922  { WM_SHOWWINDOW, sent|wparam, 1 },
1924  { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1927  { 0 }
1928 };
1929 static const struct message WmSHOWNATopVisible[] = {
1930  { WM_SHOWWINDOW, sent|wparam, 1 },
1932  { WM_NCPAINT, sent|wparam|optional, 1 },
1936  { 0 }
1937 };
1938 static const struct message WmSHOWNATopInvisible[] = {
1939  { WM_NOTIFYFORMAT, sent|optional },
1940  { WM_QUERYUISTATE, sent|optional },
1945  { WM_SHOWWINDOW, sent|wparam, 1 },
1947  { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1948  { WM_NCPAINT, sent|wparam|optional, 1 },
1953  { WM_NCPAINT, sent|wparam|optional, 1 },
1955  { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1957  { WM_MOVE, sent },
1958  { 0 }
1959 };
1960 
1961 static const struct message WmTrackPopupMenu[] = {
1962  { HCBT_CREATEWND, hook },
1964  { WM_INITMENU, sent|lparam, 0, 0 },
1965  { WM_INITMENUPOPUP, sent|lparam, 0, 0 },
1966  { 0x0093, sent|optional },
1967  { 0x0094, sent|optional },
1968  { 0x0094, sent|optional },
1969  { WM_ENTERIDLE, sent|wparam, 2 },
1970  { WM_CAPTURECHANGED, sent },
1971  { HCBT_DESTROYWND, hook },
1972  { WM_UNINITMENUPOPUP, sent|lparam, 0, 0 },
1973  { WM_MENUSELECT, sent|wparam|lparam, 0xffff0000, 0 },
1974  { WM_EXITMENULOOP, sent|wparam|lparam, 1, 0 },
1975  { 0 }
1976 };
1977 
1978 static const struct message WmTrackPopupMenuEsc[] = {
1979  { 0 }
1980 };
1981 
1982 static const struct message WmTrackPopupMenuCapture[] = {
1983  { HCBT_CREATEWND, hook },
1985  { WM_CAPTURECHANGED, sent },
1986  { WM_INITMENU, sent|lparam, 0, 0 },
1987  { WM_INITMENUPOPUP, sent|lparam, 0, 0 },
1988  { 0x0093, sent|optional },
1989  { 0x0094, sent|optional },
1990  { 0x0094, sent|optional },
1991  { WM_ENTERIDLE, sent|wparam, 2 },
1992  { WM_CAPTURECHANGED, sent },
1993  { HCBT_DESTROYWND, hook },
1994  { WM_UNINITMENUPOPUP, sent|lparam, 0, 0 },
1995  { WM_MENUSELECT, sent|wparam|lparam, 0xffff0000, 0 },
1996  { WM_EXITMENULOOP, sent|wparam|lparam, 1, 0 },
1997  { 0 }
1998 };
1999 
2000 static const struct message WmTrackPopupMenuEmpty[] = {
2001  { HCBT_CREATEWND, hook },
2003  { WM_INITMENU, sent|lparam, 0, 0 },
2004  { WM_INITMENUPOPUP, sent|lparam, 0, 0 },
2005  { 0x0093, sent|optional },
2006  { 0x0094, sent|optional },
2007  { 0x0094, sent|optional },
2008  { WM_CAPTURECHANGED, sent },
2009  { WM_EXITMENULOOP, sent|wparam|lparam, 1, 0 },
2010  { HCBT_DESTROYWND, hook },
2011  { WM_UNINITMENUPOPUP, sent|lparam, 0, 0 },
2012  { 0 }
2013 };
2014 
2015 static const struct message WmTrackPopupMenuAbort[] = {
2016  { HCBT_CREATEWND, hook },
2018  { WM_INITMENU, sent|lparam, 0, 0 },
2019  { WM_INITMENUPOPUP, sent|lparam, 0, 0 },
2020  { 0x0093, sent|optional },
2021  { 0x0094, sent|optional },
2022  { 0x0094, sent|optional },
2023  { WM_CAPTURECHANGED, sent },
2024  { HCBT_DESTROYWND, hook },
2025  { WM_UNINITMENUPOPUP, sent|lparam, 0, 0 },
2026  { WM_MENUSELECT, sent|wparam|lparam, 0xffff0000, 0 },
2027  { WM_EXITMENULOOP, sent|wparam|lparam, 1, 0 },
2028  { 0 }
2029 };
2030 
2033 static struct recvd_message* sequence;
2036 
2037 /* user32 functions */
2038 static HWND (WINAPI *pGetAncestor)(HWND,UINT);
2039 static BOOL (WINAPI *pGetMenuInfo)(HMENU,LPCMENUINFO);
2040 static void (WINAPI *pNotifyWinEvent)(DWORD, HWND, LONG, LONG);
2041 static BOOL (WINAPI *pSetMenuInfo)(HMENU,LPCMENUINFO);
2043 static BOOL (WINAPI *pTrackMouseEvent)(TRACKMOUSEEVENT*);
2044 static BOOL (WINAPI *pUnhookWinEvent)(HWINEVENTHOOK);
2045 static BOOL (WINAPI *pGetMonitorInfoA)(HMONITOR,LPMONITORINFO);
2046 static HMONITOR (WINAPI *pMonitorFromPoint)(POINT,DWORD);
2047 static BOOL (WINAPI *pUpdateLayeredWindow)(HWND,HDC,POINT*,SIZE*,HDC,POINT*,COLORREF,BLENDFUNCTION*,DWORD);
2048 static UINT_PTR (WINAPI *pSetSystemTimer)(HWND, UINT_PTR, UINT, TIMERPROC);
2049 static UINT_PTR (WINAPI *pKillSystemTimer)(HWND, UINT_PTR);
2050 static UINT_PTR (WINAPI *pSetCoalescableTimer)(HWND, UINT_PTR, UINT, TIMERPROC, ULONG);
2051 /* kernel32 functions */
2052 static BOOL (WINAPI *pGetCPInfoExA)(UINT, DWORD, LPCPINFOEXA);
2053 
2054 static void init_procs(void)
2055 {
2056  HMODULE user32 = GetModuleHandleA("user32.dll");
2057  HMODULE kernel32 = GetModuleHandleA("kernel32.dll");
2058 
2059 #define GET_PROC(dll, func) \
2060  p ## func = (void*)GetProcAddress(dll, #func); \
2061  if(!p ## func) { \
2062  trace("GetProcAddress(%s) failed\n", #func); \
2063  }
2064 
2065  GET_PROC(user32, GetAncestor)
2066  GET_PROC(user32, GetMenuInfo)
2067  GET_PROC(user32, NotifyWinEvent)
2068  GET_PROC(user32, SetMenuInfo)
2069  GET_PROC(user32, SetWinEventHook)
2070  GET_PROC(user32, TrackMouseEvent)
2071  GET_PROC(user32, UnhookWinEvent)
2072  GET_PROC(user32, GetMonitorInfoA)
2073  GET_PROC(user32, MonitorFromPoint)
2074  GET_PROC(user32, UpdateLayeredWindow)
2075  GET_PROC(user32, SetSystemTimer)
2076  GET_PROC(user32, KillSystemTimer)
2077  GET_PROC(user32, SetCoalescableTimer)
2078 
2079  GET_PROC(kernel32, GetCPInfoExA)
2080 
2081 #undef GET_PROC
2082 }
2083 
2084 static const char *get_winpos_flags(UINT flags)
2085 {
2086  static char buffer[300];
2087 
2088  buffer[0] = 0;
2089 #define DUMP(flag) do { if (flags & flag) { strcat( buffer, "|" #flag ); flags &= ~flag; } } while(0)
2090  DUMP( SWP_SHOWWINDOW );
2091  DUMP( SWP_HIDEWINDOW );
2092  DUMP( SWP_NOACTIVATE );
2094  DUMP( SWP_NOCOPYBITS );
2097  DUMP( SWP_DEFERERASE );
2099  DUMP( SWP_NOZORDER );
2100  DUMP( SWP_NOREDRAW );
2101  DUMP( SWP_NOSIZE );
2102  DUMP( SWP_NOMOVE );
2105  if (flags) sprintf(buffer + strlen(buffer),"|0x%04x", flags);
2106  return buffer + 1;
2107 #undef DUMP
2108 }
2109 
2111 {
2112  /* these are always ignored */
2113  return (message >= 0xc000 ||
2114  message == WM_GETICON ||
2115  message == WM_GETOBJECT ||
2116  message == WM_TIMECHANGE ||
2117  message == WM_DISPLAYCHANGE ||
2118  message == WM_DEVICECHANGE ||
2120 }
2121 
2122 static unsigned hash_Ly_W(const WCHAR *str)
2123 {
2124  unsigned hash = 0;
2125 
2126  for (; *str; str++)
2127  hash = hash * 1664525u + (unsigned char)(*str) + 1013904223u;
2128 
2129  return hash;
2130 }
2131 
2132 static unsigned hash_Ly(const char *str)
2133 {
2134  unsigned hash = 0;
2135 
2136  for (; *str; str++)
2137  hash = hash * 1664525u + (unsigned char)(*str) + 1013904223u;
2138 
2139  return hash;
2140 }
2141 
2142 #define add_message(msg) add_message_(__LINE__,msg);
2143 static void add_message_(int line, const struct recvd_message *msg)
2144 {
2145  struct recvd_message *seq;
2146 
2148  if (!sequence)
2149  {
2150  sequence_size = 10;
2151  sequence = HeapAlloc( GetProcessHeap(), 0, sequence_size * sizeof(*sequence) );
2152  }
2153  if (sequence_cnt == sequence_size)
2154  {
2155  sequence_size *= 2;
2157  }
2158  assert(sequence);
2159 
2160  seq = &sequence[sequence_cnt++];
2161  seq->hwnd = msg->hwnd;
2162  seq->message = msg->message;
2163  seq->flags = msg->flags;
2164  seq->wParam = msg->wParam;
2165  seq->lParam = msg->lParam;
2166  seq->line = line;
2167  seq->descr = msg->descr;
2168  seq->output[0] = 0;
2170 
2171  if (msg->descr)
2172  {
2173  if (msg->flags & hook)
2174  {
2175  static const char * const CBT_code_name[10] =
2176  {
2177  "HCBT_MOVESIZE",
2178  "HCBT_MINMAX",
2179  "HCBT_QS",
2180  "HCBT_CREATEWND",
2181  "HCBT_DESTROYWND",
2182  "HCBT_ACTIVATE",
2183  "HCBT_CLICKSKIPPED",
2184  "HCBT_KEYSKIPPED",
2185  "HCBT_SYSCOMMAND",
2186  "HCBT_SETFOCUS"
2187  };
2188  const char *code_name = (msg->message <= HCBT_SETFOCUS) ? CBT_code_name[msg->