2 * Unit tests for window message handling
4 * Copyright 1999 Ove Kaaven
5 * Copyright 2003 Dimitrie O. Paun
6 * Copyright 2004, 2005 Dmitry Timoshkov
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
27 #define _WIN32_WINNT 0x0501 /* For WM_CHANGEUISTATE,QS_RAWINPUT */
35 #include "wine/test.h"
37 #define MDI_FIRST_CHILD_ID 2004
39 /* undocumented SWP flags - from SDK 3.1 */
40 #define SWP_NOCLIENTSIZE 0x0800
41 #define SWP_NOCLIENTMOVE 0x1000
42 #define SWP_STATECHANGED 0x8000
44 #define SW_NORMALNA 0xCC /* undoc. flag in MinMaximize */
47 #define WM_SYSTIMER 0x0118
50 #define WND_PARENT_ID 1
51 #define WND_POPUP_ID 2
52 #define WND_CHILD_ID 3
54 #ifndef WM_LBTRACKPOINT
55 #define WM_LBTRACKPOINT 0x0131
58 /* encoded DRAWITEMSTRUCT into an LPARAM */
65 UINT type
: 4; /* ODT_* flags */
66 UINT ctl_id
: 4; /* Control ID */
67 UINT item_id
: 4; /* Menu item ID */
68 UINT action
: 4; /* ODA_* flags */
69 UINT state
: 16; /* ODS_* flags */
75 static BOOL test_DestroyWindow_flag
;
76 static HWINEVENTHOOK hEvent_hook
;
78 static void dump_winpos_flags(UINT flags
);
80 static const WCHAR testWindowClassW
[] =
81 { 'T','e','s','t','W','i','n','d','o','w','C','l','a','s','s','W',0 };
84 FIXME: add tests for these
85 Window Edge Styles (Win31/Win95/98 look), in order of precedence:
86 WS_EX_DLGMODALFRAME: double border, WS_CAPTION allowed
87 WS_THICKFRAME: thick border
88 WS_DLGFRAME: double border, WS_CAPTION not allowed (but possibly shown anyway)
89 WS_BORDER (default for overlapped windows): single black border
90 none (default for child (and popup?) windows): no border
107 UINT message
; /* the WM_* code */
108 msg_flags_t flags
; /* message props */
109 WPARAM wParam
; /* expected value of wParam */
110 LPARAM lParam
; /* expected value of lParam */
113 /* Empty message sequence */
114 static const struct message WmEmptySeq
[] =
118 /* CreateWindow (for overlapped window, not initially visible) (16/32) */
119 static const struct message WmCreateOverlappedSeq
[] = {
120 { HCBT_CREATEWND
, hook
},
121 { WM_GETMINMAXINFO
, sent
},
122 { WM_NCCREATE
, sent
},
123 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
124 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
126 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
129 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
130 * for a not visible overlapped window.
132 static const struct message WmSWP_ShowOverlappedSeq
[] = {
133 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
134 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
135 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
136 { WM_GETTEXT
, sent
|defwinproc
|optional
},
137 { WM_ERASEBKGND
, sent
|optional
},
138 { HCBT_ACTIVATE
, hook
},
139 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
140 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
141 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* Win9x: SWP_NOSENDCHANGING */
142 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
143 { WM_NCACTIVATE
, sent
|wparam
, 1 },
144 { WM_GETTEXT
, sent
|defwinproc
|optional
},
145 { WM_ACTIVATE
, sent
|wparam
, 1 },
146 { HCBT_SETFOCUS
, hook
},
147 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
148 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
149 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
150 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
151 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
152 { WM_GETTEXT
, sent
|defwinproc
|optional
},
153 { WM_ERASEBKGND
, sent
|optional
},
154 /* Win9x adds SWP_NOZORDER below */
155 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
156 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
157 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
158 { WM_ERASEBKGND
, sent
|optional
},
159 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
162 /* SetWindowPos(SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE)
163 * for a visible overlapped window.
165 static const struct message WmSWP_HideOverlappedSeq
[] = {
166 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
167 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
168 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
172 /* SetWindowPos(SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOMOVE)
173 * for a visible overlapped window.
175 static const struct message WmSWP_ResizeSeq
[] = {
176 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
},
177 { WM_GETMINMAXINFO
, sent
|defwinproc
},
178 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
179 { WM_NCPAINT
, sent
|optional
},
180 { WM_GETTEXT
, sent
|defwinproc
|optional
},
181 { WM_ERASEBKGND
, sent
|optional
},
182 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
},
183 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
184 { WM_NCCALCSIZE
, sent
|wparam
|optional
, TRUE
},
185 { WM_NCPAINT
, sent
|optional
},
186 { WM_GETTEXT
, sent
|defwinproc
|optional
},
187 { WM_ERASEBKGND
, sent
|optional
},
188 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
189 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* XP sends a duplicate */
193 /* SetWindowPos(SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOMOVE)
194 * for a visible popup window.
196 static const struct message WmSWP_ResizePopupSeq
[] = {
197 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
},
198 { WM_GETMINMAXINFO
, sent
|defwinproc
|optional
}, /* Win9x */
199 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
200 { WM_NCPAINT
, sent
|optional
},
201 { WM_GETTEXT
, sent
|defwinproc
|optional
},
202 { WM_ERASEBKGND
, sent
|optional
},
203 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
},
204 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
205 { WM_NCCALCSIZE
, sent
|wparam
|optional
, TRUE
},
206 { WM_NCPAINT
, sent
|optional
},
207 { WM_GETTEXT
, sent
|defwinproc
|optional
},
208 { WM_ERASEBKGND
, sent
|optional
},
209 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
213 /* SetWindowPos(SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOSIZE)
214 * for a visible overlapped window.
216 static const struct message WmSWP_MoveSeq
[] = {
217 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOSIZE
},
218 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOCLIENTSIZE
},
219 { WM_MOVE
, sent
|defwinproc
|wparam
, 0 },
220 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
223 /* Resize with SetWindowPos(SWP_NOZORDER)
224 * for a visible overlapped window
225 * SWP_NOZORDER is stripped by the logging code
227 static const struct message WmSWP_ResizeNoZOrder
[] = {
228 { WM_WINDOWPOSCHANGING
, sent
|wparam
, 0/*SWP_NOZORDER*/ },
229 { WM_GETMINMAXINFO
, sent
|defwinproc
},
230 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
231 { WM_NCPAINT
, sent
},
232 { WM_GETTEXT
, sent
|defwinproc
|optional
},
233 { WM_ERASEBKGND
, sent
|optional
}, /* FIXME: remove optional once Wine is fixed */
234 { WM_WINDOWPOSCHANGED
, sent
|wparam
, /*SWP_NOZORDER|*/SWP_NOMOVE
|SWP_NOCLIENTMOVE
},
235 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
236 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 }, /* Win9x doesn't send it */
237 { WM_NCPAINT
, sent
|optional
}, /* Win9x doesn't send it */
238 { WM_GETTEXT
, sent
|defwinproc
|optional
}, /* Win9x doesn't send it */
239 { WM_ERASEBKGND
, sent
|optional
}, /* Win9x doesn't send it */
240 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
241 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
245 /* Switch visible mdi children */
246 static const struct message WmSwitchChild
[] = {
247 /* Switch MDI child */
248 { WM_MDIACTIVATE
, sent
},/* in the MDI client */
249 { WM_WINDOWPOSCHANGING
, sent
|wparam
,SWP_NOSIZE
|SWP_NOMOVE
},/* in the 1st MDI child */
250 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
251 { WM_CHILDACTIVATE
, sent
},/* in the 1st MDI child */
252 /* Deactivate 2nd MDI child */
253 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 0 }, /* in the 2nd MDI child */
254 { WM_MDIACTIVATE
, sent
|defwinproc
}, /* in the 2nd MDI child */
255 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
256 /* Preparing for maximize and maximaze the 1st MDI child */
257 { WM_GETMINMAXINFO
, sent
|defwinproc
}, /* in the 1st MDI child */
258 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_STATECHANGED
}, /* in the 1st MDI child */
259 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 }, /* in the 1st MDI child */
260 { WM_CHILDACTIVATE
, sent
|defwinproc
}, /* in the 1st MDI child */
261 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|0x8000 }, /* in the 1st MDI child */
262 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
}, /* in the 1st MDI child */
263 /* Lock redraw 2nd MDI child */
264 { WM_SETREDRAW
, sent
|wparam
|defwinproc
, 0 }, /* in the 2nd MDI child */
265 { HCBT_MINMAX
, hook
|lparam
, 0, SW_NORMALNA
},
266 /* Restore 2nd MDI child */
267 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|0x8000 },/* in the 2nd MDI child */
268 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 },/* in the 2nd MDI child */
269 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* in the 2nd MDI child */
270 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|0x8000 }, /* in the 2nd MDI child */
271 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
}, /* in the 2nd MDI child */
272 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* in the 2nd MDI child */
273 /* Redraw 2nd MDI child */
274 { WM_SETREDRAW
, sent
|wparam
|defwinproc
, 1 },/* in the 2nd MDI child */
275 /* Redraw MDI frame */
276 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
},/* in MDI frame */
277 { WM_NCCALCSIZE
, sent
|wparam
, 1 },/* in MDI frame */
278 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
}, /* in MDI frame */
279 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* in MDI frame */
280 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* in the 1st MDI child */
281 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
}, /* in the 1st MDI child */
282 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 }, /* in the 1st MDI child */
283 { HCBT_SETFOCUS
, hook
},
284 { WM_KILLFOCUS
, sent
|defwinproc
}, /* in the 2nd MDI child */
285 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 0 },/* in the 1st MDI child */
286 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
287 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
288 { WM_SETFOCUS
, sent
},/* in the MDI client */
289 { HCBT_SETFOCUS
, hook
},
290 { WM_KILLFOCUS
, sent
},/* in the MDI client */
291 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
292 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 }, /* in the 1st MDI child */
293 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
294 { WM_SETFOCUS
, sent
|defwinproc
}, /* in the 1st MDI child */
295 { WM_MDIACTIVATE
, sent
|defwinproc
},/* in the 1st MDI child */
296 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
}, /* in the 1st MDI child */
300 /* SetWindowPos(SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|
301 SWP_NOZORDER|SWP_FRAMECHANGED)
302 * for a visible overlapped window with WS_CLIPCHILDREN style set.
304 static const struct message WmSWP_FrameChanged_clip
[] = {
305 { WM_WINDOWPOSCHANGING
, sent
|wparam
|parent
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
},
306 { WM_NCCALCSIZE
, sent
|wparam
|parent
, 1 },
307 { WM_NCPAINT
, sent
|parent
}, /* wparam != 1 */
308 { WM_GETTEXT
, sent
|parent
|defwinproc
|optional
},
309 { WM_ERASEBKGND
, sent
|parent
|optional
}, /* FIXME: remove optional once Wine is fixed */
310 { WM_NCPAINT
, sent
}, /* wparam != 1 */
311 { WM_ERASEBKGND
, sent
},
312 { WM_WINDOWPOSCHANGED
, sent
|wparam
|parent
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
313 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
317 /* SetWindowPos(SWP_NOSIZE|SWP_NOMOVE|SWP_DEFERERASE|SWP_NOACTIVATE|
318 SWP_NOZORDER|SWP_FRAMECHANGED)
319 * for a visible overlapped window.
321 static const struct message WmSWP_FrameChangedDeferErase
[] = {
322 { WM_WINDOWPOSCHANGING
, sent
|wparam
|parent
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_DEFERERASE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
},
323 { WM_NCCALCSIZE
, sent
|wparam
|parent
, 1 },
324 { WM_WINDOWPOSCHANGED
, sent
|wparam
|parent
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_DEFERERASE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
325 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
326 { WM_PAINT
, sent
|parent
},
327 { WM_NCPAINT
, sent
|beginpaint
|parent
}, /* wparam != 1 */
328 { WM_GETTEXT
, sent
|beginpaint
|parent
|defwinproc
|optional
},
330 { WM_NCPAINT
, sent
|beginpaint
}, /* wparam != 1 */
331 { WM_ERASEBKGND
, sent
|beginpaint
},
335 /* SetWindowPos(SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|
336 SWP_NOZORDER|SWP_FRAMECHANGED)
337 * for a visible overlapped window without WS_CLIPCHILDREN style set.
339 static const struct message WmSWP_FrameChanged_noclip
[] = {
340 { WM_WINDOWPOSCHANGING
, sent
|wparam
|parent
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
},
341 { WM_NCCALCSIZE
, sent
|wparam
|parent
, 1 },
342 { WM_NCPAINT
, sent
|parent
}, /* wparam != 1 */
343 { WM_GETTEXT
, sent
|parent
|defwinproc
|optional
},
344 { WM_ERASEBKGND
, sent
|parent
|optional
}, /* FIXME: remove optional once Wine is fixed */
345 { WM_WINDOWPOSCHANGED
, sent
|wparam
|parent
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
346 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
348 { WM_NCPAINT
, sent
|beginpaint
}, /* wparam != 1 */
349 { WM_ERASEBKGND
, sent
|beginpaint
},
353 /* ShowWindow(SW_SHOW) for a not visible overlapped window */
354 static const struct message WmShowOverlappedSeq
[] = {
355 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
356 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
357 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
358 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
359 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
360 { WM_GETTEXT
, sent
|defwinproc
|optional
},
361 { WM_ERASEBKGND
, sent
|optional
},
362 { HCBT_ACTIVATE
, hook
},
363 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
364 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
365 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
},
366 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
367 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
368 { WM_NCACTIVATE
, sent
|wparam
, 1 },
369 { WM_GETTEXT
, sent
|defwinproc
|optional
},
370 { WM_ACTIVATE
, sent
|wparam
, 1 },
371 { HCBT_SETFOCUS
, hook
},
372 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
373 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
374 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
375 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
376 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
377 { WM_GETTEXT
, sent
|defwinproc
|optional
},
378 { WM_ERASEBKGND
, sent
|optional
},
379 /* Win9x adds SWP_NOZORDER below */
380 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
381 { WM_NCCALCSIZE
, sent
|optional
},
382 { WM_NCPAINT
, sent
|optional
},
383 { WM_ERASEBKGND
, sent
|optional
},
384 #if 0 /* CreateWindow/ShowWindow(SW_SHOW) also generates WM_SIZE/WM_MOVE
385 * messages. Does that mean that CreateWindow doesn't set initial
386 * window dimensions for overlapped windows?
393 /* ShowWindow(SW_SHOWMAXIMIZED) for a not visible overlapped window */
394 static const struct message WmShowMaxOverlappedSeq
[] = {
395 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
396 { WM_GETMINMAXINFO
, sent
},
397 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|0x8000 },
398 { WM_GETMINMAXINFO
, sent
|defwinproc
},
399 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
400 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
401 { HCBT_ACTIVATE
, hook
},
402 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
403 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
404 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
},
405 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
406 { WM_NCACTIVATE
, sent
|wparam
, 1 },
407 { WM_GETTEXT
, sent
|defwinproc
|optional
},
408 { WM_ACTIVATE
, sent
|wparam
, 1 },
409 { HCBT_SETFOCUS
, hook
},
410 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
411 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
412 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
413 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
414 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
415 { WM_GETTEXT
, sent
|defwinproc
|optional
},
416 { WM_ERASEBKGND
, sent
|optional
},
417 /* Win9x adds SWP_NOZORDER below */
418 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|0x8000 },
419 { WM_MOVE
, sent
|defwinproc
},
420 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
421 { WM_NCCALCSIZE
, sent
|optional
},
422 { WM_NCPAINT
, sent
|optional
},
423 { WM_ERASEBKGND
, sent
|optional
},
424 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
425 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
428 /* ShowWindow(SW_SHOWMINIMIZED) for a not visible overlapped window */
429 static const struct message WmShowMinOverlappedSeq
[] = {
430 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
431 { HCBT_SETFOCUS
, hook
},
432 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
433 { WM_KILLFOCUS
, sent
},
434 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
435 { WM_IME_NOTIFY
, sent
|wparam
|optional
|defwinproc
, 1 },
436 { WM_GETTEXT
, sent
|optional
},
437 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOCOPYBITS
|SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_STATECHANGED
},
438 { WM_GETMINMAXINFO
, sent
|defwinproc
},
439 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
440 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
441 { WM_NCPAINT
, sent
},
442 { WM_GETTEXT
, sent
|defwinproc
|optional
},
443 { WM_WINDOWPOSCHANGED
, sent
},
444 { WM_MOVE
, sent
|defwinproc
},
445 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MINIMIZED
},
446 { WM_NCCALCSIZE
, sent
|optional
},
447 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
448 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
449 { EVENT_SYSTEM_MINIMIZESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
450 { WM_NCACTIVATE
, sent
|wparam
, 0 },
451 { WM_GETTEXT
, sent
|defwinproc
|optional
},
452 { WM_ACTIVATE
, sent
},
453 { WM_ACTIVATEAPP
, sent
|wparam
, 0 },
456 /* ShowWindow(SW_HIDE) for a visible overlapped window */
457 static const struct message WmHideOverlappedSeq
[] = {
458 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
459 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
460 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
461 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
462 { WM_SIZE
, sent
|optional
}, /* XP doesn't send it */
463 { WM_MOVE
, sent
|optional
}, /* XP doesn't send it */
464 { WM_NCACTIVATE
, sent
|wparam
, 0 },
465 { WM_ACTIVATE
, sent
|wparam
, 0 },
466 { WM_ACTIVATEAPP
, sent
|wparam
, 0 },
467 { WM_KILLFOCUS
, sent
|wparam
, 0 },
468 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
469 { WM_IME_NOTIFY
, sent
|wparam
|optional
|defwinproc
, 1 },
472 /* DestroyWindow for a visible overlapped window */
473 static const struct message WmDestroyOverlappedSeq
[] = {
474 { HCBT_DESTROYWND
, hook
},
475 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
476 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
477 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
478 { WM_NCACTIVATE
, sent
|wparam
, 0 },
479 { WM_ACTIVATE
, sent
|wparam
, 0 },
480 { WM_ACTIVATEAPP
, sent
|wparam
, 0 },
481 { WM_KILLFOCUS
, sent
|wparam
, 0 },
482 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
483 { WM_IME_NOTIFY
, sent
|wparam
|optional
|defwinproc
, 1 },
484 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
485 { WM_DESTROY
, sent
},
486 { WM_NCDESTROY
, sent
},
489 /* CreateWindow(WS_MAXIMIZE|WS_VISIBLE) for popup window */
490 static const struct message WmCreateMaxPopupSeq
[] = {
491 { HCBT_CREATEWND
, hook
},
492 { WM_NCCREATE
, sent
},
493 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
495 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
496 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
498 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
499 { WM_GETMINMAXINFO
, sent
},
500 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|0x8000 },
501 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
502 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOREDRAW
|0x8000 },
503 { WM_MOVE
, sent
|defwinproc
},
504 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
505 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
506 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
507 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
508 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
509 { HCBT_ACTIVATE
, hook
},
510 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
511 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
512 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
513 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
514 { WM_NCACTIVATE
, sent
|wparam
, 1 },
515 { WM_ACTIVATE
, sent
|wparam
, 1 },
516 { HCBT_SETFOCUS
, hook
},
517 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
518 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
519 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
520 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
521 { WM_SYNCPAINT
, sent
|wparam
|optional
, 4 },
522 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
523 { WM_ERASEBKGND
, sent
|optional
},
524 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOCLIENTMOVE
|SWP_NOCLIENTSIZE
|SWP_SHOWWINDOW
|SWP_NOMOVE
|SWP_NOSIZE
},
527 /* CreateWindow(WS_MAXIMIZE) for popup window, not initially visible */
528 static const struct message WmCreateInvisibleMaxPopupSeq
[] = {
529 { HCBT_CREATEWND
, hook
},
530 { WM_NCCREATE
, sent
},
531 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
533 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
534 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
536 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
537 { WM_GETMINMAXINFO
, sent
},
538 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|0x8000 },
539 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
540 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOREDRAW
|0x8000 },
541 { WM_MOVE
, sent
|defwinproc
},
542 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
543 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
546 /* ShowWindow(SW_SHOWMAXIMIZED) for a resized not visible popup window */
547 static const struct message WmShowMaxPopupResizedSeq
[] = {
548 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
549 { WM_GETMINMAXINFO
, sent
},
550 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
},
551 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
552 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
553 { HCBT_ACTIVATE
, hook
},
554 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
555 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
556 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
557 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
558 { WM_NCACTIVATE
, sent
|wparam
, 1 },
559 { WM_ACTIVATE
, sent
|wparam
, 1 },
560 { HCBT_SETFOCUS
, hook
},
561 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
562 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
563 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
564 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
565 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
566 { WM_ERASEBKGND
, sent
|optional
},
567 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOCLIENTMOVE
|SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOMOVE
},
568 /* WinNT4.0 sends WM_MOVE */
569 { WM_MOVE
, sent
|defwinproc
|optional
},
570 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
571 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
574 /* ShowWindow(SW_SHOWMAXIMIZED) for a not visible popup window */
575 static const struct message WmShowMaxPopupSeq
[] = {
576 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
577 { WM_GETMINMAXINFO
, sent
},
578 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
},
579 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
580 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
581 { HCBT_ACTIVATE
, hook
},
582 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
583 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
584 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
585 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
586 { WM_NCACTIVATE
, sent
|wparam
, 1 },
587 { WM_ACTIVATE
, sent
|wparam
, 1 },
588 { HCBT_SETFOCUS
, hook
},
589 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
590 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
591 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
592 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
593 { WM_SYNCPAINT
, sent
|wparam
|optional
, 4 },
594 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
595 { WM_ERASEBKGND
, sent
|optional
},
596 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOMOVE
|SWP_NOSIZE
},
597 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
600 /* CreateWindow(WS_VISIBLE) for popup window */
601 static const struct message WmCreatePopupSeq
[] = {
602 { HCBT_CREATEWND
, hook
},
603 { WM_NCCREATE
, sent
},
604 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
606 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
607 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
609 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
610 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
611 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
612 { HCBT_ACTIVATE
, hook
},
613 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
614 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
615 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
616 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
617 { WM_ERASEBKGND
, sent
|optional
},
618 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
619 { WM_NCACTIVATE
, sent
|wparam
, 1 },
620 { WM_ACTIVATE
, sent
|wparam
, 1 },
621 { HCBT_SETFOCUS
, hook
},
622 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
623 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
624 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
625 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
626 { WM_SYNCPAINT
, sent
|wparam
|optional
, 4 },
627 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
628 { WM_ERASEBKGND
, sent
|optional
},
629 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOCLIENTMOVE
|SWP_NOCLIENTSIZE
|SWP_SHOWWINDOW
|SWP_NOMOVE
|SWP_NOSIZE
},
632 /* ShowWindow(SW_SHOWMAXIMIZED) for a visible popup window */
633 static const struct message WmShowVisMaxPopupSeq
[] = {
634 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
635 { WM_GETMINMAXINFO
, sent
},
636 { WM_GETTEXT
, sent
|optional
},
637 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|0x8000 },
638 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
639 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
640 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
641 { WM_ERASEBKGND
, sent
|optional
},
642 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|0x8000 },
643 { WM_MOVE
, sent
|defwinproc
},
644 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
645 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
648 /* CreateWindow (for a child popup window, not initially visible) */
649 static const struct message WmCreateChildPopupSeq
[] = {
650 { HCBT_CREATEWND
, hook
},
651 { WM_NCCREATE
, sent
},
652 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
654 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
655 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
659 /* CreateWindow (for a popup window, not initially visible,
660 * which sets WS_VISIBLE in WM_CREATE handler)
662 static const struct message WmCreateInvisiblePopupSeq
[] = {
663 { HCBT_CREATEWND
, hook
},
664 { WM_NCCREATE
, sent
},
665 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
667 { WM_STYLECHANGING
, sent
},
668 { WM_STYLECHANGED
, sent
},
669 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
670 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
674 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER)
675 * for a popup window with WS_VISIBLE style set
677 static const struct message WmShowVisiblePopupSeq_2
[] = {
678 { WM_WINDOWPOSCHANGING
, sent
|wparam
, 0 },
681 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
682 * for a popup window with WS_VISIBLE style set
684 static const struct message WmShowVisiblePopupSeq_3
[] = {
685 { WM_WINDOWPOSCHANGING
, sent
|wparam
, 0 },
686 { HCBT_ACTIVATE
, hook
},
687 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
688 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
689 { WM_WINDOWPOSCHANGING
, sent
|wparam
, 0 },
690 { WM_NCACTIVATE
, sent
|wparam
, 1 },
691 { WM_ACTIVATE
, sent
|wparam
, 1 },
692 { HCBT_SETFOCUS
, hook
},
693 { WM_KILLFOCUS
, sent
|parent
},
694 { WM_IME_SETCONTEXT
, sent
|parent
|wparam
|optional
, 0 },
695 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
696 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
697 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
698 { WM_SETFOCUS
, sent
|defwinproc
},
701 /* CreateWindow (for child window, not initially visible) */
702 static const struct message WmCreateChildSeq
[] = {
703 { HCBT_CREATEWND
, hook
},
704 { WM_NCCREATE
, sent
},
705 /* child is inserted into parent's child list after WM_NCCREATE returns */
706 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
708 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
709 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
711 { WM_PARENTNOTIFY
, sent
|parent
|wparam
, WM_CREATE
},
714 /* CreateWindow (for maximized child window, not initially visible) */
715 static const struct message WmCreateMaximizedChildSeq
[] = {
716 { HCBT_CREATEWND
, hook
},
717 { WM_NCCREATE
, sent
},
718 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
720 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
721 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
723 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
724 { WM_GETMINMAXINFO
, sent
},
725 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|0x8000 },
726 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
727 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
|0x8000 },
728 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
729 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
730 { WM_PARENTNOTIFY
, sent
|parent
|wparam
, WM_CREATE
},
733 /* CreateWindow (for a child window, initially visible) */
734 static const struct message WmCreateVisibleChildSeq
[] = {
735 { HCBT_CREATEWND
, hook
},
736 { WM_NCCREATE
, sent
},
737 /* child is inserted into parent's child list after WM_NCCREATE returns */
738 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
739 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
741 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
742 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
744 { WM_PARENTNOTIFY
, sent
|parent
|wparam
, WM_CREATE
},
745 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
746 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
747 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
748 { WM_ERASEBKGND
, sent
|parent
|optional
},
749 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
750 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 }, /* WinXP */
751 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
754 /* ShowWindow(SW_SHOW) for a not visible child window */
755 static const struct message WmShowChildSeq
[] = {
756 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
757 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
758 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
759 { WM_ERASEBKGND
, sent
|parent
|optional
},
760 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
763 /* ShowWindow(SW_HIDE) for a visible child window */
764 static const struct message WmHideChildSeq
[] = {
765 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
766 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
767 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
768 { WM_ERASEBKGND
, sent
|parent
|optional
},
769 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
772 /* ShowWindow(SW_HIDE) for a visible child window checking all parent events*/
773 static const struct message WmHideChildSeq2
[] = {
774 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
775 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
776 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
777 { WM_ERASEBKGND
, sent
|parent
},
778 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
781 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
782 * for a not visible child window
784 static const struct message WmShowChildSeq_2
[] = {
785 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
786 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
787 { WM_CHILDACTIVATE
, sent
},
788 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
791 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE)
792 * for a not visible child window
794 static const struct message WmShowChildSeq_3
[] = {
795 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
796 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
797 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
800 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
801 * for a visible child window with a caption
803 static const struct message WmShowChildSeq_4
[] = {
804 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
805 { WM_CHILDACTIVATE
, sent
},
808 /* ShowWindow(SW_MINIMIZE) for child with invisible parent */
809 static const struct message WmShowChildInvisibleParentSeq_1
[] = {
810 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
811 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOCOPYBITS
|0x8000 },
812 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
813 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
814 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOREDRAW
|SWP_NOCOPYBITS
|0x8000 },
815 { WM_MOVE
, sent
|defwinproc
},
816 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MINIMIZED
},
817 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
818 { EVENT_SYSTEM_MINIMIZESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
819 /* FIXME: Wine creates an icon/title window while Windows doesn't */
820 { WM_PARENTNOTIFY
, sent
|parent
|wparam
|optional
, WM_CREATE
},
821 { WM_GETTEXT
, sent
|optional
},
824 /* repeated ShowWindow(SW_MINIMIZE) for child with invisible parent */
825 static const struct message WmShowChildInvisibleParentSeq_1r
[] = {
826 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
829 /* ShowWindow(SW_MAXIMIZE) for child with invisible parent */
830 static const struct message WmShowChildInvisibleParentSeq_2
[] = {
831 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
832 { WM_GETMINMAXINFO
, sent
},
833 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|0x8000 },
834 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
835 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
836 { WM_CHILDACTIVATE
, sent
},
837 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
|0x8000 },
838 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
839 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
842 /* repeated ShowWindow(SW_MAXIMIZE) for child with invisible parent */
843 static const struct message WmShowChildInvisibleParentSeq_2r
[] = {
844 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
847 /* ShowWindow(SW_SHOWMINIMIZED) for child with invisible parent */
848 static const struct message WmShowChildInvisibleParentSeq_3
[] = {
849 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINIMIZED
},
850 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|0x8000 },
851 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
852 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
853 { WM_CHILDACTIVATE
, sent
},
854 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOREDRAW
|SWP_NOCOPYBITS
|0x8000 },
855 { WM_MOVE
, sent
|defwinproc
},
856 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MINIMIZED
},
857 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
858 { EVENT_SYSTEM_MINIMIZESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
859 /* FIXME: Wine creates an icon/title window while Windows doesn't */
860 { WM_PARENTNOTIFY
, sent
|parent
|wparam
|optional
, WM_CREATE
},
861 { WM_GETTEXT
, sent
|optional
},
864 /* repeated ShowWindow(SW_SHOWMINIMIZED) for child with invisible parent */
865 static const struct message WmShowChildInvisibleParentSeq_3r
[] = {
866 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINIMIZED
},
869 /* ShowWindow(SW_SHOWMINNOACTIVE) for child with invisible parent */
870 static const struct message WmShowChildInvisibleParentSeq_4
[] = {
871 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINNOACTIVE
},
872 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOCOPYBITS
|0x8000 },
873 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
874 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
875 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOREDRAW
|SWP_NOCOPYBITS
|0x8000 },
876 { WM_MOVE
, sent
|defwinproc
},
877 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MINIMIZED
},
878 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
879 { EVENT_SYSTEM_MINIMIZESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
880 /* FIXME: Wine creates an icon/title window while Windows doesn't */
881 { WM_PARENTNOTIFY
, sent
|parent
|wparam
|optional
, WM_CREATE
},
882 { WM_GETTEXT
, sent
|optional
},
885 /* repeated ShowWindow(SW_SHOWMINNOACTIVE) for child with invisible parent */
886 static const struct message WmShowChildInvisibleParentSeq_4r
[] = {
887 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINNOACTIVE
},
890 /* ShowWindow(SW_SHOW) for child with invisible parent */
891 static const struct message WmShowChildInvisibleParentSeq_5
[] = {
892 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
895 /* ShowWindow(SW_HIDE) for child with invisible parent */
896 static const struct message WmHideChildInvisibleParentSeq
[] = {
897 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
900 /* SetWindowPos(SWP_SHOWWINDOW) for child with invisible parent */
901 static const struct message WmShowChildInvisibleParentSeq_6
[] = {
902 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
903 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
904 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
907 /* SetWindowPos(SWP_HIDEWINDOW) for child with invisible parent */
908 static const struct message WmHideChildInvisibleParentSeq_2
[] = {
909 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
910 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
911 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
914 /* DestroyWindow for a visible child window */
915 static const struct message WmDestroyChildSeq
[] = {
916 { HCBT_DESTROYWND
, hook
},
917 { WM_PARENTNOTIFY
, sent
|parent
|wparam
, WM_DESTROY
},
918 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
919 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
920 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
921 { WM_ERASEBKGND
, sent
|parent
|optional
},
922 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
923 { HCBT_SETFOCUS
, hook
}, /* set focus to a parent */
924 { WM_KILLFOCUS
, sent
},
925 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
926 { WM_IME_SETCONTEXT
, sent
|wparam
|parent
|optional
, 1 },
927 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
928 { WM_SETFOCUS
, sent
|parent
},
929 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
930 { WM_DESTROY
, sent
},
931 { WM_DESTROY
, sent
|optional
}, /* some other (IME?) window */
932 { WM_NCDESTROY
, sent
|optional
}, /* some other (IME?) window */
933 { WM_NCDESTROY
, sent
},
936 /* DestroyWindow for a visible child window with invisible parent */
937 static const struct message WmDestroyInvisibleChildSeq
[] = {
938 { HCBT_DESTROYWND
, hook
},
939 { WM_PARENTNOTIFY
, sent
|parent
|wparam
, WM_DESTROY
},
940 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
941 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
942 { WM_DESTROY
, sent
},
943 { WM_NCDESTROY
, sent
},
946 /* Moving the mouse in nonclient area */
947 static const struct message WmMouseMoveInNonClientAreaSeq
[] = { /* FIXME: add */
948 { WM_NCHITTEST
, sent
},
949 { WM_SETCURSOR
, sent
},
950 { WM_NCMOUSEMOVE
, posted
},
953 /* Moving the mouse in client area */
954 static const struct message WmMouseMoveInClientAreaSeq
[] = { /* FIXME: add */
955 { WM_NCHITTEST
, sent
},
956 { WM_SETCURSOR
, sent
},
957 { WM_MOUSEMOVE
, posted
},
960 /* Moving by dragging the title bar (after WM_NCHITTEST and WM_SETCURSOR) (outline move) */
961 static const struct message WmDragTitleBarSeq
[] = { /* FIXME: add */
962 { WM_NCLBUTTONDOWN
, sent
|wparam
, HTCAPTION
},
963 { WM_SYSCOMMAND
, sent
|defwinproc
|wparam
, SC_MOVE
+2 },
964 { WM_GETMINMAXINFO
, sent
|defwinproc
},
965 { WM_ENTERSIZEMOVE
, sent
|defwinproc
},
966 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, 0 },
967 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, 0 },
968 { WM_MOVE
, sent
|defwinproc
},
969 { WM_EXITSIZEMOVE
, sent
|defwinproc
},
972 /* Sizing by dragging the thick borders (after WM_NCHITTEST and WM_SETCURSOR) (outline move) */
973 static const struct message WmDragThickBordersBarSeq
[] = { /* FIXME: add */
974 { WM_NCLBUTTONDOWN
, sent
|wparam
, 0xd },
975 { WM_SYSCOMMAND
, sent
|defwinproc
|wparam
, 0xf004 },
976 { WM_GETMINMAXINFO
, sent
|defwinproc
},
977 { WM_ENTERSIZEMOVE
, sent
|defwinproc
},
978 { WM_SIZING
, sent
|defwinproc
|wparam
, 4}, /* one for each mouse movement */
979 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, 0 },
980 { WM_GETMINMAXINFO
, sent
|defwinproc
},
981 { WM_NCCALCSIZE
, sent
|defwinproc
|wparam
, 1 },
982 { WM_NCPAINT
, sent
|defwinproc
|wparam
, 1 },
983 { WM_GETTEXT
, sent
|defwinproc
},
984 { WM_ERASEBKGND
, sent
|defwinproc
},
985 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, 0 },
986 { WM_MOVE
, sent
|defwinproc
},
987 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
988 { WM_EXITSIZEMOVE
, sent
|defwinproc
},
991 /* Resizing child window with MoveWindow (32) */
992 static const struct message WmResizingChildWithMoveWindowSeq
[] = {
993 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
994 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
995 { WM_ERASEBKGND
, sent
|parent
|optional
},
996 { WM_ERASEBKGND
, sent
|optional
},
997 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
},
998 { WM_MOVE
, sent
|defwinproc
},
999 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
1000 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1003 /* Clicking on inactive button */
1004 static const struct message WmClickInactiveButtonSeq
[] = { /* FIXME: add */
1005 { WM_NCHITTEST
, sent
},
1006 { WM_PARENTNOTIFY
, sent
|parent
|wparam
, WM_LBUTTONDOWN
},
1007 { WM_MOUSEACTIVATE
, sent
},
1008 { WM_MOUSEACTIVATE
, sent
|parent
|defwinproc
},
1009 { WM_SETCURSOR
, sent
},
1010 { WM_SETCURSOR
, sent
|parent
|defwinproc
},
1011 { WM_LBUTTONDOWN
, posted
},
1012 { WM_KILLFOCUS
, posted
|parent
},
1013 { WM_SETFOCUS
, posted
},
1014 { WM_CTLCOLORBTN
, posted
|parent
},
1015 { BM_SETSTATE
, posted
},
1016 { WM_CTLCOLORBTN
, posted
|parent
},
1017 { WM_LBUTTONUP
, posted
},
1018 { BM_SETSTATE
, posted
},
1019 { WM_CTLCOLORBTN
, posted
|parent
},
1020 { WM_COMMAND
, posted
|parent
},
1023 /* Reparenting a button (16/32) */
1024 /* The last child (button) reparented gets topmost for its new parent. */
1025 static const struct message WmReparentButtonSeq
[] = { /* FIXME: add */
1026 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
1027 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOSIZE
},
1028 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1029 { WM_ERASEBKGND
, sent
|parent
},
1030 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOSIZE
},
1031 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
},
1032 { WM_CHILDACTIVATE
, sent
},
1033 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOSIZE
|SWP_NOREDRAW
},
1034 { WM_MOVE
, sent
|defwinproc
},
1035 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1038 /* Creation of a custom dialog (32) */
1039 static const struct message WmCreateCustomDialogSeq
[] = {
1040 { HCBT_CREATEWND
, hook
},
1041 { WM_GETMINMAXINFO
, sent
},
1042 { WM_NCCREATE
, sent
},
1043 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
1044 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
1045 { WM_CREATE
, sent
},
1046 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1047 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1048 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
1049 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1050 { HCBT_ACTIVATE
, hook
},
1051 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
1054 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
1056 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
},
1058 { WM_NCACTIVATE
, sent
|wparam
, 1 },
1059 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1060 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1061 { EVENT_OBJECT_DEFACTIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, OBJID_CLIENT
, 0 },
1062 { WM_ACTIVATE
, sent
|wparam
, 1 },
1063 { WM_KILLFOCUS
, sent
|parent
},
1064 { WM_IME_SETCONTEXT
, sent
|parent
|wparam
|optional
, 0 },
1065 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
1066 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
1067 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1068 { WM_SETFOCUS
, sent
},
1069 { WM_GETDLGCODE
, sent
|defwinproc
|wparam
, 0 },
1070 { WM_NCPAINT
, sent
|wparam
, 1 },
1071 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1072 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1073 { WM_ERASEBKGND
, sent
},
1074 { WM_CTLCOLORDLG
, sent
|defwinproc
},
1075 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1076 { WM_GETTEXT
, sent
|optional
},
1077 { WM_GETTEXT
, sent
|optional
},
1078 { WM_NCCALCSIZE
, sent
|optional
},
1079 { WM_NCPAINT
, sent
|optional
},
1080 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1081 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1082 { WM_ERASEBKGND
, sent
|optional
},
1083 { WM_CTLCOLORDLG
, sent
|optional
|defwinproc
},
1084 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1085 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
1089 /* Calling EndDialog for a custom dialog (32) */
1090 static const struct message WmEndCustomDialogSeq
[] = {
1091 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1092 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1093 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1094 { WM_GETTEXT
, sent
|optional
},
1095 { HCBT_ACTIVATE
, hook
},
1096 { WM_NCACTIVATE
, sent
|wparam
, 0 },
1097 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1098 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1099 { WM_ACTIVATE
, sent
|wparam
, 0 },
1100 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
1101 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1102 { HCBT_SETFOCUS
, hook
},
1103 { WM_KILLFOCUS
, sent
},
1104 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
1105 { WM_IME_SETCONTEXT
, sent
|parent
|wparam
|defwinproc
|optional
, 1 },
1106 { WM_IME_NOTIFY
, sent
|wparam
|optional
, 1 },
1107 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1108 { WM_SETFOCUS
, sent
|parent
|defwinproc
},
1111 /* ShowWindow(SW_SHOW) for a custom dialog (initially invisible) */
1112 static const struct message WmShowCustomDialogSeq
[] = {
1113 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1114 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
1115 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1116 { HCBT_ACTIVATE
, hook
},
1117 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
1119 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
1121 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
},
1122 { WM_ACTIVATEAPP
, sent
|wparam
|optional
, 1 },
1123 { WM_NCACTIVATE
, sent
|wparam
, 1 },
1124 { WM_ACTIVATE
, sent
|wparam
, 1 },
1126 { WM_KILLFOCUS
, sent
|parent
},
1127 { WM_IME_SETCONTEXT
, sent
|parent
|wparam
|optional
, 0 },
1128 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
1129 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
1130 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1131 { WM_SETFOCUS
, sent
},
1132 { WM_GETDLGCODE
, sent
|defwinproc
|wparam
, 0 },
1133 { WM_NCPAINT
, sent
|wparam
, 1 },
1134 { WM_ERASEBKGND
, sent
},
1135 { WM_CTLCOLORDLG
, sent
|defwinproc
},
1136 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1139 /* Creation and destruction of a modal dialog (32) */
1140 static const struct message WmModalDialogSeq
[] = {
1141 { WM_CANCELMODE
, sent
|parent
},
1142 { HCBT_SETFOCUS
, hook
},
1143 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1144 { WM_KILLFOCUS
, sent
|parent
},
1145 { WM_IME_SETCONTEXT
, sent
|parent
|wparam
|optional
, 0 },
1146 { EVENT_OBJECT_STATECHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1147 { WM_ENABLE
, sent
|parent
|wparam
, 0 },
1148 { HCBT_CREATEWND
, hook
},
1149 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
1150 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1151 { WM_SETFONT
, sent
},
1152 { WM_INITDIALOG
, sent
},
1153 { WM_CHANGEUISTATE
, sent
|optional
},
1154 { WM_UPDATEUISTATE
, sent
|optional
},
1155 { WM_SHOWWINDOW
, sent
},
1156 { HCBT_ACTIVATE
, hook
},
1157 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
1158 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
1159 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
},
1160 { WM_NCACTIVATE
, sent
|wparam
, 1 },
1161 { WM_GETTEXT
, sent
|optional
},
1162 { WM_ACTIVATE
, sent
|wparam
, 1 },
1163 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
1164 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1165 { WM_NCPAINT
, sent
},
1166 { WM_GETTEXT
, sent
|optional
},
1167 { WM_ERASEBKGND
, sent
},
1168 { WM_CTLCOLORDLG
, sent
},
1169 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1170 { WM_GETTEXT
, sent
|optional
},
1171 { WM_NCCALCSIZE
, sent
|optional
},
1172 { WM_NCPAINT
, sent
|optional
},
1173 { WM_GETTEXT
, sent
|optional
},
1174 { WM_ERASEBKGND
, sent
|optional
},
1175 { WM_CTLCOLORDLG
, sent
|optional
},
1176 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1177 { WM_PAINT
, sent
|optional
},
1178 { WM_CTLCOLORBTN
, sent
},
1179 { WM_ENTERIDLE
, sent
|parent
|optional
},
1180 { WM_ENTERIDLE
, sent
|parent
|optional
},
1181 { WM_ENTERIDLE
, sent
|parent
|optional
},
1182 { WM_ENTERIDLE
, sent
|parent
|optional
},
1183 { WM_ENTERIDLE
, sent
|parent
|optional
},
1184 { WM_ENTERIDLE
, sent
|parent
|optional
},
1185 { WM_ENTERIDLE
, sent
|parent
|optional
},
1186 { WM_ENTERIDLE
, sent
|parent
|optional
},
1187 { WM_ENTERIDLE
, sent
|parent
|optional
},
1188 { WM_ENTERIDLE
, sent
|parent
|optional
},
1189 { WM_ENTERIDLE
, sent
|parent
|optional
},
1190 { WM_ENTERIDLE
, sent
|parent
|optional
},
1191 { WM_ENTERIDLE
, sent
|parent
|optional
},
1192 { WM_ENTERIDLE
, sent
|parent
|optional
},
1193 { WM_ENTERIDLE
, sent
|parent
|optional
},
1194 { WM_ENTERIDLE
, sent
|parent
|optional
},
1195 { WM_ENTERIDLE
, sent
|parent
|optional
},
1196 { WM_ENTERIDLE
, sent
|parent
|optional
},
1197 { WM_ENTERIDLE
, sent
|parent
|optional
},
1198 { WM_ENTERIDLE
, sent
|parent
|optional
},
1200 { EVENT_OBJECT_STATECHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1201 { WM_ENABLE
, sent
|parent
|wparam
, 1 },
1202 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
1203 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1204 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1205 { WM_GETTEXT
, sent
|optional
},
1206 { HCBT_ACTIVATE
, hook
},
1207 { WM_NCACTIVATE
, sent
|wparam
, 0 },
1208 { WM_GETTEXT
, sent
|optional
},
1209 { WM_ACTIVATE
, sent
|wparam
, 0 },
1210 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
1211 { WM_WINDOWPOSCHANGING
, sent
|optional
},
1212 { HCBT_SETFOCUS
, hook
},
1213 { WM_IME_SETCONTEXT
, sent
|parent
|wparam
|defwinproc
|optional
, 1 },
1214 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1215 { WM_SETFOCUS
, sent
|parent
|defwinproc
},
1216 { EVENT_SYSTEM_DIALOGEND
, winevent_hook
|wparam
|lparam
, 0, 0 },
1217 { HCBT_DESTROYWND
, hook
},
1218 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
1219 { WM_DESTROY
, sent
},
1220 { WM_NCDESTROY
, sent
},
1223 /* Creation of a modal dialog that is resized inside WM_INITDIALOG (32) */
1224 static const struct message WmCreateModalDialogResizeSeq
[] = { /* FIXME: add */
1225 /* (inside dialog proc, handling WM_INITDIALOG) */
1226 { WM_WINDOWPOSCHANGING
, sent
|wparam
, 0 },
1227 { WM_NCCALCSIZE
, sent
},
1228 { WM_NCACTIVATE
, sent
|parent
|wparam
, 0 },
1229 { WM_GETTEXT
, sent
|defwinproc
},
1230 { WM_ACTIVATE
, sent
|parent
|wparam
, 0 },
1231 { WM_WINDOWPOSCHANGING
, sent
|wparam
, 0 },
1232 { WM_WINDOWPOSCHANGING
, sent
|parent
},
1233 { WM_NCACTIVATE
, sent
|wparam
, 1 },
1234 { WM_ACTIVATE
, sent
|wparam
, 1 },
1235 { WM_WINDOWPOSCHANGED
, sent
|wparam
, 0 },
1236 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
1237 /* (setting focus) */
1238 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1239 { WM_WINDOWPOSCHANGING
, sent
|wparam
, 0 },
1240 { WM_NCPAINT
, sent
},
1241 { WM_GETTEXT
, sent
|defwinproc
},
1242 { WM_ERASEBKGND
, sent
},
1243 { WM_CTLCOLORDLG
, sent
|defwinproc
},
1244 { WM_WINDOWPOSCHANGED
, sent
|wparam
, 0 },
1246 /* (bunch of WM_CTLCOLOR* for each control) */
1247 { WM_PAINT
, sent
|parent
},
1248 { WM_ENTERIDLE
, sent
|parent
|wparam
, 0 },
1249 { WM_SETCURSOR
, sent
|parent
},
1252 /* SetMenu for NonVisible windows with size change*/
1253 static const struct message WmSetMenuNonVisibleSizeChangeSeq
[] = {
1254 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1255 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1256 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
1257 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
},
1258 { WM_MOVE
, sent
|defwinproc
},
1259 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
1260 { WM_NCCALCSIZE
,sent
|wparam
|optional
, 1 }, /* XP */
1261 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1262 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* XP sends a duplicate */
1263 { WM_GETTEXT
, sent
|optional
},
1264 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
1267 /* SetMenu for NonVisible windows with no size change */
1268 static const struct message WmSetMenuNonVisibleNoSizeChangeSeq
[] = {
1269 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1270 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1271 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1272 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1275 /* SetMenu for Visible windows with size change */
1276 static const struct message WmSetMenuVisibleSizeChangeSeq
[] = {
1277 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1278 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1279 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
1280 { WM_NCPAINT
, sent
}, /* wparam != 1 */
1281 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1282 { WM_ERASEBKGND
, sent
|optional
},
1283 { WM_ACTIVATE
, sent
|optional
},
1284 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1285 { WM_MOVE
, sent
|defwinproc
},
1286 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
1287 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
1288 { WM_NCPAINT
, sent
|optional
}, /* wparam != 1 */
1289 { WM_ERASEBKGND
, sent
|optional
},
1290 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1291 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* XP sends a duplicate */
1294 /* SetMenu for Visible windows with no size change */
1295 static const struct message WmSetMenuVisibleNoSizeChangeSeq
[] = {
1296 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1297 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1298 { WM_NCPAINT
, sent
}, /* wparam != 1 */
1299 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1300 { WM_ERASEBKGND
, sent
|optional
},
1301 { WM_ACTIVATE
, sent
|optional
},
1302 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1303 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1306 /* DrawMenuBar for a visible window */
1307 static const struct message WmDrawMenuBarSeq
[] =
1309 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1310 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1311 { WM_NCPAINT
, sent
}, /* wparam != 1 */
1312 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1313 { WM_ERASEBKGND
, sent
|optional
},
1314 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1315 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1319 static const struct message WmSetRedrawFalseSeq
[] =
1321 { WM_SETREDRAW
, sent
|wparam
, 0 },
1325 static const struct message WmSetRedrawTrueSeq
[] =
1327 { WM_SETREDRAW
, sent
|wparam
, 1 },
1331 static const struct message WmEnableWindowSeq_1
[] =
1333 { WM_CANCELMODE
, sent
|wparam
|lparam
, 0, 0 },
1334 { EVENT_OBJECT_STATECHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1335 { WM_ENABLE
, sent
|wparam
|lparam
, FALSE
, 0 },
1339 static const struct message WmEnableWindowSeq_2
[] =
1341 { EVENT_OBJECT_STATECHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1342 { WM_ENABLE
, sent
|wparam
|lparam
, TRUE
, 0 },
1346 static const struct message WmGetScrollRangeSeq
[] =
1348 { SBM_GETRANGE
, sent
},
1351 static const struct message WmGetScrollInfoSeq
[] =
1353 { SBM_GETSCROLLINFO
, sent
},
1356 static const struct message WmSetScrollRangeSeq
[] =
1358 /* MSDN claims that Windows sends SBM_SETRANGE message, but win2k SP4
1359 sends SBM_SETSCROLLINFO.
1361 { SBM_SETSCROLLINFO
, sent
},
1364 /* SetScrollRange for a window without a non-client area */
1365 static const struct message WmSetScrollRangeHSeq_empty
[] =
1367 { EVENT_OBJECT_VALUECHANGE
, winevent_hook
|wparam
|lparam
, OBJID_HSCROLL
, 0 },
1370 static const struct message WmSetScrollRangeVSeq_empty
[] =
1372 { EVENT_OBJECT_VALUECHANGE
, winevent_hook
|wparam
|lparam
, OBJID_VSCROLL
, 0 },
1375 static const struct message WmSetScrollRangeHVSeq
[] =
1377 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOSIZE
},
1378 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1379 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1380 { WM_ERASEBKGND
, sent
|optional
},
1381 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1382 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1383 { EVENT_OBJECT_VALUECHANGE
, winevent_hook
|lparam
|optional
, 0/*OBJID_HSCROLL or OBJID_VSCROLL*/, 0 },
1386 /* SetScrollRange for a window with a non-client area */
1387 static const struct message WmSetScrollRangeHV_NC_Seq
[] =
1389 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOSIZE
},
1390 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1391 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
1392 { WM_NCPAINT
, sent
|optional
},
1393 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1394 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1395 { WM_ERASEBKGND
, sent
|optional
},
1396 { WM_CTLCOLORDLG
, sent
|defwinproc
|optional
}, /* sent to a parent of the dialog */
1397 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOCLIENTMOVE
},
1398 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
1399 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1400 { EVENT_OBJECT_VALUECHANGE
, winevent_hook
|lparam
|optional
, 0/*OBJID_HSCROLL or OBJID_VSCROLL*/, 0 },
1401 { WM_GETTEXT
, sent
|optional
},
1402 { WM_GETTEXT
, sent
|optional
},
1403 { WM_GETTEXT
, sent
|optional
},
1404 { WM_GETTEXT
, sent
|optional
},
1407 /* test if we receive the right sequence of messages */
1408 /* after calling ShowWindow( SW_SHOWNA) */
1409 static const struct message WmSHOWNAChildInvisParInvis
[] = {
1410 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1413 static const struct message WmSHOWNAChildVisParInvis
[] = {
1414 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1417 static const struct message WmSHOWNAChildVisParVis
[] = {
1418 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1419 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
1422 static const struct message WmSHOWNAChildInvisParVis
[] = {
1423 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1424 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1425 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1426 { WM_ERASEBKGND
, sent
|optional
},
1427 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOACTIVATE
|SWP_NOCLIENTMOVE
},
1430 static const struct message WmSHOWNATopVisible
[] = {
1431 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1432 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
1435 static const struct message WmSHOWNATopInvisible
[] = {
1436 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1437 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1438 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1439 { WM_NCPAINT
, sent
|wparam
, 1 },
1440 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1441 { WM_ERASEBKGND
, sent
|optional
},
1442 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1443 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
1444 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
1445 { WM_ERASEBKGND
, sent
|optional
},
1446 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1447 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
1452 static int after_end_dialog
, test_def_id
;
1453 static int sequence_cnt
, sequence_size
;
1454 static struct message
* sequence
;
1455 static int log_all_parent_messages
;
1457 /* user32 functions */
1458 static HWND (WINAPI
*pGetAncestor
)(HWND
,UINT
);
1459 static void (WINAPI
*pNotifyWinEvent
)(DWORD
, HWND
, LONG
, LONG
);
1460 static HWINEVENTHOOK (WINAPI
*pSetWinEventHook
)(DWORD
, DWORD
, HMODULE
, WINEVENTPROC
, DWORD
, DWORD
, DWORD
);
1461 static BOOL (WINAPI
*pTrackMouseEvent
)(TRACKMOUSEEVENT
*);
1462 static BOOL (WINAPI
*pUnhookWinEvent
)(HWINEVENTHOOK
);
1463 /* kernel32 functions */
1464 static BOOL (WINAPI
*pGetCPInfoExA
)(UINT
, DWORD
, LPCPINFOEXA
);
1466 static void init_procs(void)
1468 HMODULE user32
= GetModuleHandleA("user32.dll");
1469 HMODULE kernel32
= GetModuleHandleA("kernel32.dll");
1471 #define GET_PROC(dll, func) \
1472 p ## func = (void*)GetProcAddress(dll, #func); \
1474 trace("GetProcAddress(%s) failed\n", #func); \
1477 GET_PROC(user32
, GetAncestor
)
1478 GET_PROC(user32
, NotifyWinEvent
)
1479 GET_PROC(user32
, SetWinEventHook
)
1480 GET_PROC(user32
, TrackMouseEvent
)
1481 GET_PROC(user32
, UnhookWinEvent
)
1483 GET_PROC(kernel32
, GetCPInfoExA
)
1488 static void add_message(const struct message
*msg
)
1493 sequence
= HeapAlloc( GetProcessHeap(), 0, sequence_size
* sizeof (struct message
) );
1495 if (sequence_cnt
== sequence_size
)
1498 sequence
= HeapReAlloc( GetProcessHeap(), 0, sequence
, sequence_size
* sizeof (struct message
) );
1502 sequence
[sequence_cnt
].message
= msg
->message
;
1503 sequence
[sequence_cnt
].flags
= msg
->flags
;
1504 sequence
[sequence_cnt
].wParam
= msg
->wParam
;
1505 sequence
[sequence_cnt
].lParam
= msg
->lParam
;
1510 /* try to make sure pending X events have been processed before continuing */
1511 static void flush_events(void)
1515 DWORD time
= GetTickCount() + diff
;
1519 if (MsgWaitForMultipleObjects( 0, NULL
, FALSE
, min(10,diff
), QS_ALLINPUT
) == WAIT_TIMEOUT
) break;
1520 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
1521 diff
= time
- GetTickCount();
1525 static void flush_sequence(void)
1527 HeapFree(GetProcessHeap(), 0, sequence
);
1529 sequence_cnt
= sequence_size
= 0;
1532 #define ok_sequence( exp, contx, todo) \
1533 ok_sequence_( (exp), (contx), (todo), __FILE__, __LINE__)
1536 static void ok_sequence_(const struct message
*expected
, const char *context
, int todo
,
1537 const char *file
, int line
)
1539 static const struct message end_of_sequence
= { 0, 0, 0, 0 };
1540 const struct message
*actual
;
1543 add_message(&end_of_sequence
);
1547 while (expected
->message
&& actual
->message
)
1549 trace_( file
, line
)("expected %04x - actual %04x\n", expected
->message
, actual
->message
);
1551 if (expected
->message
== actual
->message
)
1553 if (expected
->flags
& wparam
)
1555 if (expected
->wParam
!= actual
->wParam
&& todo
)
1559 ok_( file
, line
) (FALSE
,
1560 "%s: in msg 0x%04x expecting wParam 0x%lx got 0x%lx\n",
1561 context
, expected
->message
, expected
->wParam
, actual
->wParam
);
1565 ok_( file
, line
) (expected
->wParam
== actual
->wParam
,
1566 "%s: in msg 0x%04x expecting wParam 0x%lx got 0x%lx\n",
1567 context
, expected
->message
, expected
->wParam
, actual
->wParam
);
1569 if (expected
->flags
& lparam
)
1571 if (expected
->lParam
!= actual
->lParam
&& todo
)
1575 ok_( file
, line
) (FALSE
,
1576 "%s: in msg 0x%04x expecting lParam 0x%lx got 0x%lx\n",
1577 context
, expected
->message
, expected
->lParam
, actual
->lParam
);
1581 ok_( file
, line
) (expected
->lParam
== actual
->lParam
,
1582 "%s: in msg 0x%04x expecting lParam 0x%lx got 0x%lx\n",
1583 context
, expected
->message
, expected
->lParam
, actual
->lParam
);
1585 if ((expected
->flags
& defwinproc
) != (actual
->flags
& defwinproc
) && todo
)
1589 ok_( file
, line
) (FALSE
,
1590 "%s: the msg 0x%04x should %shave been sent by DefWindowProc\n",
1591 context
, expected
->message
, (expected
->flags
& defwinproc
) ? "" : "NOT ");
1595 ok_( file
, line
) ((expected
->flags
& defwinproc
) == (actual
->flags
& defwinproc
),
1596 "%s: the msg 0x%04x should %shave been sent by DefWindowProc\n",
1597 context
, expected
->message
, (expected
->flags
& defwinproc
) ? "" : "NOT ");
1598 ok_( file
, line
) ((expected
->flags
& beginpaint
) == (actual
->flags
& beginpaint
),
1599 "%s: the msg 0x%04x should %shave been sent by BeginPaint\n",
1600 context
, expected
->message
, (expected
->flags
& beginpaint
) ? "" : "NOT ");
1601 ok_( file
, line
) ((expected
->flags
& (sent
|posted
)) == (actual
->flags
& (sent
|posted
)),
1602 "%s: the msg 0x%04x should have been %s\n",
1603 context
, expected
->message
, (expected
->flags
& posted
) ? "posted" : "sent");
1604 ok_( file
, line
) ((expected
->flags
& parent
) == (actual
->flags
& parent
),
1605 "%s: the msg 0x%04x was expected in %s\n",
1606 context
, expected
->message
, (expected
->flags
& parent
) ? "parent" : "child");
1607 ok_( file
, line
) ((expected
->flags
& hook
) == (actual
->flags
& hook
),
1608 "%s: the msg 0x%04x should have been sent by a hook\n",
1609 context
, expected
->message
);
1610 ok_( file
, line
) ((expected
->flags
& winevent_hook
) == (actual
->flags
& winevent_hook
),
1611 "%s: the msg 0x%04x should have been sent by a winevent hook\n",
1612 context
, expected
->message
);
1616 /* silently drop winevent messages if there is no support for them */
1617 else if ((expected
->flags
& optional
) || ((expected
->flags
& winevent_hook
) && !hEvent_hook
))
1623 ok_( file
, line
) (FALSE
, "%s: the msg 0x%04x was expected, but got msg 0x%04x instead\n",
1624 context
, expected
->message
, actual
->message
);
1631 ok_( file
, line
) (FALSE
, "%s: the msg 0x%04x was expected, but got msg 0x%04x instead\n",
1632 context
, expected
->message
, actual
->message
);
1638 /* skip all optional trailing messages */
1639 while (expected
->message
&& ((expected
->flags
& optional
) ||
1640 ((expected
->flags
& winevent_hook
) && !hEvent_hook
)))
1646 if (expected
->message
|| actual
->message
) {
1648 ok_( file
, line
) (FALSE
, "%s: the msg sequence is not complete: expected %04x - actual %04x\n",
1649 context
, expected
->message
, actual
->message
);
1655 if (expected
->message
|| actual
->message
)
1656 ok_( file
, line
) (FALSE
, "%s: the msg sequence is not complete: expected %04x - actual %04x\n",
1657 context
, expected
->message
, actual
->message
);
1659 if( todo
&& !failcount
) /* succeeded yet marked todo */
1661 ok_( file
, line
)( TRUE
, "%s: marked \"todo_wine\" but succeeds\n", context
);
1667 /******************************** MDI test **********************************/
1669 /* CreateWindow for MDI frame window, initially visible */
1670 static const struct message WmCreateMDIframeSeq
[] = {
1671 { HCBT_CREATEWND
, hook
},
1672 { WM_GETMINMAXINFO
, sent
},
1673 { WM_NCCREATE
, sent
},
1674 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
1675 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
1676 { WM_CREATE
, sent
},
1677 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1678 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1679 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
1680 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1681 { HCBT_ACTIVATE
, hook
},
1682 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
1683 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
1684 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* XP */
1685 { WM_ACTIVATEAPP
, sent
|wparam
|optional
, 1 }, /* Win9x doesn't send it */
1686 { WM_NCACTIVATE
, sent
|wparam
, 1 },
1687 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1688 { WM_ACTIVATE
, sent
|wparam
, 1 },
1689 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* Win9x */
1690 { HCBT_SETFOCUS
, hook
},
1691 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
1692 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
1693 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1694 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
1695 /* Win9x adds SWP_NOZORDER below */
1696 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1697 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 }, /* XP */
1698 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1699 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
1703 /* DestroyWindow for MDI frame window, initially visible */
1704 static const struct message WmDestroyMDIframeSeq
[] = {
1705 { HCBT_DESTROYWND
, hook
},
1706 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1707 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1708 { WM_NCACTIVATE
, sent
|wparam
|optional
, 0 }, /* Win9x */
1709 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1710 { WM_NCACTIVATE
, sent
|wparam
|optional
, 0 }, /* XP */
1711 { WM_ACTIVATE
, sent
|wparam
|optional
, 0 }, /* Win9x */
1712 { WM_ACTIVATEAPP
, sent
|wparam
|optional
, 0 }, /* Win9x */
1713 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
1714 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
1715 { WM_DESTROY
, sent
},
1716 { WM_NCDESTROY
, sent
},
1719 /* CreateWindow for MDI client window, initially visible */
1720 static const struct message WmCreateMDIclientSeq
[] = {
1721 { HCBT_CREATEWND
, hook
},
1722 { WM_NCCREATE
, sent
},
1723 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
1724 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 },
1725 { WM_CREATE
, sent
},
1726 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 },
1727 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1728 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
1730 { WM_PARENTNOTIFY
, sent
|wparam
, WM_CREATE
}, /* in MDI frame */
1731 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1732 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1733 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1734 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1737 /* ShowWindow(SW_SHOW) for MDI client window */
1738 static const struct message WmShowMDIclientSeq
[] = {
1739 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1740 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1741 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1742 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1745 /* ShowWindow(SW_HIDE) for MDI client window */
1746 static const struct message WmHideMDIclientSeq
[] = {
1747 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
1748 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1749 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* win2000 */
1750 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* XP */
1751 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1754 /* DestroyWindow for MDI client window, initially visible */
1755 static const struct message WmDestroyMDIclientSeq
[] = {
1756 { HCBT_DESTROYWND
, hook
},
1757 { WM_PARENTNOTIFY
, sent
|wparam
, WM_DESTROY
}, /* in MDI frame */
1758 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
1759 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1760 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1761 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1762 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
1763 { WM_DESTROY
, sent
},
1764 { WM_NCDESTROY
, sent
},
1767 /* CreateWindow for MDI child window, initially visible */
1768 static const struct message WmCreateMDIchildVisibleSeq
[] = {
1769 { HCBT_CREATEWND
, hook
},
1770 { WM_NCCREATE
, sent
},
1771 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
1772 { WM_CREATE
, sent
},
1773 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1774 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
1776 /* Win2k sends wparam set to
1777 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
1778 * while Win9x doesn't bother to set child window id according to
1779 * CLIENTCREATESTRUCT.idFirstChild
1781 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
1782 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1783 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1784 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1785 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1786 { WM_MDIREFRESHMENU
, sent
/*|wparam|lparam, 0, 0*/ },
1787 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
1788 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
1789 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1791 /* Win9x: message sequence terminates here. */
1793 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 },
1794 { HCBT_SETFOCUS
, hook
}, /* in MDI client */
1795 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
1796 { WM_IME_NOTIFY
, sent
|wparam
|optional
, 2 }, /* in MDI client */
1797 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1798 { WM_SETFOCUS
, sent
}, /* in MDI client */
1799 { HCBT_SETFOCUS
, hook
},
1800 { WM_KILLFOCUS
, sent
}, /* in MDI client */
1801 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
1802 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
1803 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1804 { WM_SETFOCUS
, sent
|defwinproc
},
1805 { WM_MDIACTIVATE
, sent
|defwinproc
},
1808 /* CreateWindow for MDI child window with invisible parent */
1809 static const struct message WmCreateMDIchildInvisibleParentSeq
[] = {
1810 { HCBT_CREATEWND
, hook
},
1811 { WM_GETMINMAXINFO
, sent
},
1812 { WM_NCCREATE
, sent
},
1813 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
1814 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 },
1815 { WM_CREATE
, sent
},
1816 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1817 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
1819 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
1820 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1821 { WM_MDIREFRESHMENU
, sent
}, /* in MDI client */
1822 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
1823 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
1824 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1826 /* Win9x: message sequence terminates here. */
1828 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 },
1829 { HCBT_SETFOCUS
, hook
}, /* in MDI client */
1830 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
1831 { WM_IME_NOTIFY
, sent
|wparam
|optional
, 2 }, /* in MDI client */
1832 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1833 { WM_SETFOCUS
, sent
}, /* in MDI client */
1834 { HCBT_SETFOCUS
, hook
},
1835 { WM_KILLFOCUS
, sent
}, /* in MDI client */
1836 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
1837 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
1838 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1839 { WM_SETFOCUS
, sent
|defwinproc
},
1840 { WM_MDIACTIVATE
, sent
|defwinproc
},
1843 /* DestroyWindow for MDI child window, initially visible */
1844 static const struct message WmDestroyMDIchildVisibleSeq
[] = {
1845 { HCBT_DESTROYWND
, hook
},
1846 /* Win2k sends wparam set to
1847 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
1848 * while Win9x doesn't bother to set child window id according to
1849 * CLIENTCREATESTRUCT.idFirstChild
1851 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_DESTROY*/ }, /* in MDI client */
1852 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
1853 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1854 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1855 { WM_ERASEBKGND
, sent
|parent
|optional
},
1856 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1858 /* { WM_DESTROY, sent }
1859 * Win9x: message sequence terminates here.
1862 { HCBT_SETFOCUS
, hook
}, /* set focus to MDI client */
1863 { WM_KILLFOCUS
, sent
},
1864 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
1865 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
1866 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1867 { WM_SETFOCUS
, sent
}, /* in MDI client */
1869 { HCBT_SETFOCUS
, hook
}, /* MDI client sets focus back to MDI child */
1870 { WM_KILLFOCUS
, sent
}, /* in MDI client */
1871 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
1872 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
1873 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1874 { WM_SETFOCUS
, sent
}, /* in MDI client */
1876 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
1878 { HCBT_SETFOCUS
, hook
}, /* set focus to MDI client */
1879 { WM_KILLFOCUS
, sent
},
1880 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
1881 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
1882 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1883 { WM_SETFOCUS
, sent
}, /* in MDI client */
1885 { HCBT_SETFOCUS
, hook
}, /* MDI client sets focus back to MDI child */
1886 { WM_KILLFOCUS
, sent
}, /* in MDI client */
1887 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
1888 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
1889 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1890 { WM_SETFOCUS
, sent
}, /* in MDI client */
1892 { WM_DESTROY
, sent
},
1894 { HCBT_SETFOCUS
, hook
}, /* set focus to MDI client */
1895 { WM_KILLFOCUS
, sent
},
1896 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
1897 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
1898 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1899 { WM_SETFOCUS
, sent
}, /* in MDI client */
1901 { HCBT_SETFOCUS
, hook
}, /* MDI client sets focus back to MDI child */
1902 { WM_KILLFOCUS
, sent
}, /* in MDI client */
1903 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
1904 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
1905 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1906 { WM_SETFOCUS
, sent
}, /* in MDI client */
1908 { WM_NCDESTROY
, sent
},
1911 /* CreateWindow for MDI child window, initially invisible */
1912 static const struct message WmCreateMDIchildInvisibleSeq
[] = {
1913 { HCBT_CREATEWND
, hook
},
1914 { WM_NCCREATE
, sent
},
1915 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
1916 { WM_CREATE
, sent
},
1917 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1918 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
1920 /* Win2k sends wparam set to
1921 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
1922 * while Win9x doesn't bother to set child window id according to
1923 * CLIENTCREATESTRUCT.idFirstChild
1925 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
1928 /* DestroyWindow for MDI child window, initially invisible */
1929 static const struct message WmDestroyMDIchildInvisibleSeq
[] = {
1930 { HCBT_DESTROYWND
, hook
},
1931 /* Win2k sends wparam set to
1932 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
1933 * while Win9x doesn't bother to set child window id according to
1934 * CLIENTCREATESTRUCT.idFirstChild
1936 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_DESTROY*/ }, /* in MDI client */
1937 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
1938 { WM_DESTROY
, sent
},
1939 { WM_NCDESTROY
, sent
},
1940 /* FIXME: Wine destroys an icon/title window while Windows doesn't */
1941 { WM_PARENTNOTIFY
, sent
|wparam
|optional
, WM_DESTROY
}, /* MDI client */
1944 /* CreateWindow for the 1st MDI child window, initially visible and maximized */
1945 static const struct message WmCreateMDIchildVisibleMaxSeq1
[] = {
1946 { HCBT_CREATEWND
, hook
},
1947 { WM_NCCREATE
, sent
},
1948 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
1949 { WM_CREATE
, sent
},
1950 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1951 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
1953 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
1954 { WM_GETMINMAXINFO
, sent
},
1955 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|0x8000 },
1956 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1957 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|0x8000 },
1958 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
1960 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1961 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1962 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1963 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
1964 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
1965 /* Win2k sends wparam set to
1966 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
1967 * while Win9x doesn't bother to set child window id according to
1968 * CLIENTCREATESTRUCT.idFirstChild
1970 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
1971 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1972 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1973 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1974 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1975 { WM_MDIREFRESHMENU
, sent
/*|wparam|lparam, 0, 0*/ },
1976 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
1977 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
1978 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1980 /* Win9x: message sequence terminates here. */
1982 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 },
1983 { HCBT_SETFOCUS
, hook
}, /* in MDI client */
1984 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
1985 { WM_IME_NOTIFY
, sent
|wparam
|optional
, 2 }, /* in MDI client */
1986 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1987 { WM_SETFOCUS
, sent
}, /* in MDI client */
1988 { HCBT_SETFOCUS
, hook
},
1989 { WM_KILLFOCUS
, sent
}, /* in MDI client */
1990 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
1991 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
1992 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1993 { WM_SETFOCUS
, sent
|defwinproc
},
1994 { WM_MDIACTIVATE
, sent
|defwinproc
},
1996 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1997 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1998 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1999 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2002 /* CreateWindow for the 2nd MDI child window, initially visible and maximized */
2003 static const struct message WmCreateMDIchildVisibleMaxSeq2
[] = {
2004 /* restore the 1st MDI child */
2005 { WM_SETREDRAW
, sent
|wparam
, 0 },
2006 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWNORMAL
},
2007 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|0x8000 },
2008 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2009 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2010 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|0x8000 },
2011 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2013 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2014 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2015 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2016 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2017 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2018 { WM_SETREDRAW
, sent
|wparam
, 1 }, /* in the 1st MDI child */
2019 /* create the 2nd MDI child */
2020 { HCBT_CREATEWND
, hook
},
2021 { WM_NCCREATE
, sent
},
2022 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
2023 { WM_CREATE
, sent
},
2024 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2025 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2027 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
2028 { WM_GETMINMAXINFO
, sent
},
2029 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|0x8000 },
2030 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2031 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2032 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|0x8000 },
2033 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2035 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2036 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2037 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2038 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2039 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2040 /* Win2k sends wparam set to
2041 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2042 * while Win9x doesn't bother to set child window id according to
2043 * CLIENTCREATESTRUCT.idFirstChild
2045 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
2046 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
2047 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2048 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2049 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2050 { WM_MDIREFRESHMENU
, sent
/*|wparam|lparam, 0, 0*/ },
2051 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
2052 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2054 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 0 }, /* in the 1st MDI child */
2055 { WM_MDIACTIVATE
, sent
|defwinproc
}, /* in the 1st MDI child */
2057 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2059 /* Win9x: message sequence terminates here. */
2061 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 },
2062 { HCBT_SETFOCUS
, hook
},
2063 { WM_KILLFOCUS
, sent
|defwinproc
}, /* in the 1st MDI child */
2064 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 0 }, /* in the 1st MDI child */
2065 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2066 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2067 { WM_SETFOCUS
, sent
}, /* in MDI client */
2068 { HCBT_SETFOCUS
, hook
},
2069 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2070 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2071 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
2072 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2073 { WM_SETFOCUS
, sent
|defwinproc
},
2075 { WM_MDIACTIVATE
, sent
|defwinproc
},
2077 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2078 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2079 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2080 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2083 /* WM_MDICREATE MDI child window, initially visible and maximized */
2084 static const struct message WmCreateMDIchildVisibleMaxSeq3
[] = {
2085 { WM_MDICREATE
, sent
},
2086 { HCBT_CREATEWND
, hook
},
2087 { WM_NCCREATE
, sent
},
2088 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
2089 { WM_CREATE
, sent
},
2090 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2091 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2093 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
2094 { WM_GETMINMAXINFO
, sent
},
2095 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|0x8000 },
2096 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2097 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|0x8000 },
2098 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2101 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2102 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2103 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2104 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2105 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2107 /* Win2k sends wparam set to
2108 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2109 * while Win9x doesn't bother to set child window id according to
2110 * CLIENTCREATESTRUCT.idFirstChild
2112 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
2113 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
2114 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2116 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2118 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2119 { WM_MDIREFRESHMENU
, sent
/*|wparam|lparam, 0, 0*/ },
2120 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
2122 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2123 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2125 /* Win9x: message sequence terminates here. */
2127 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 },
2128 { WM_SETFOCUS
, sent
|optional
}, /* in MDI client */
2129 { HCBT_SETFOCUS
, hook
}, /* in MDI client */
2130 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2131 { WM_IME_NOTIFY
, sent
|wparam
|optional
, 2 },
2132 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
|optional
, OBJID_CLIENT
, 0 },
2133 { WM_SETFOCUS
, sent
|optional
}, /* in MDI client */
2134 { HCBT_SETFOCUS
, hook
|optional
},
2135 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2136 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2137 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
2138 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2139 { WM_SETFOCUS
, sent
|defwinproc
},
2141 { WM_MDIACTIVATE
, sent
|defwinproc
},
2144 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2145 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2146 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2147 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2150 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2151 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2152 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2153 { WM_MOVE
, sent
|defwinproc
},
2154 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2157 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
2158 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2159 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
},
2160 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2163 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
2164 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2165 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
},
2166 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2168 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2169 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI client */
2170 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 }, /* XP sends it to MDI frame */
2171 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2172 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* XP sends a duplicate */
2176 /* CreateWindow for the 1st MDI child window, initially invisible and maximized */
2177 static const struct message WmCreateMDIchildInvisibleMaxSeq4
[] = {
2178 { HCBT_CREATEWND
, hook
},
2179 { WM_GETMINMAXINFO
, sent
},
2180 { WM_NCCREATE
, sent
},
2181 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
2182 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
2183 { WM_CREATE
, sent
},
2184 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2185 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2187 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
2188 { WM_GETMINMAXINFO
, sent
},
2189 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|0x8000 },
2190 { WM_GETMINMAXINFO
, sent
|defwinproc
},
2191 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2192 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|0x8000 },
2193 { WM_MOVE
, sent
|defwinproc
},
2194 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2196 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2197 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2198 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2199 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2200 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 }, /* MDI child */
2201 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2202 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2203 /* Win2k sends wparam set to
2204 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2205 * while Win9x doesn't bother to set child window id according to
2206 * CLIENTCREATESTRUCT.idFirstChild
2208 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
2211 /* WM_SYSCOMMAND/SC_CLOSE for the 2nd MDI child window, initially visible and maximized */
2212 static const struct message WmDestroyMDIchildVisibleMaxSeq2
[] = {
2213 { WM_SYSCOMMAND
, sent
|wparam
, SC_CLOSE
},
2214 { HCBT_SYSCOMMAND
, hook
},
2215 { WM_CLOSE
, sent
|defwinproc
},
2216 { WM_MDIDESTROY
, sent
}, /* in MDI client */
2218 /* bring the 1st MDI child to top */
2219 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOSIZE
|SWP_NOMOVE
}, /* in the 1st MDI child */
2220 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
}, /* in the 2nd MDI child */
2222 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2224 { WM_CHILDACTIVATE
, sent
|defwinproc
|wparam
|lparam
, 0, 0 }, /* in the 1st MDI child */
2225 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 0 }, /* in the 1st MDI child */
2226 { WM_MDIACTIVATE
, sent
|defwinproc
}, /* in the 1st MDI child */
2228 /* maximize the 1st MDI child */
2229 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
2230 { WM_GETMINMAXINFO
, sent
|defwinproc
},
2231 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|0x8000 },
2232 { WM_NCCALCSIZE
, sent
|defwinproc
|wparam
, 1 },
2233 { WM_CHILDACTIVATE
, sent
|defwinproc
|wparam
|lparam
, 0, 0 },
2234 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|0x8000 },
2235 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2237 /* restore the 2nd MDI child */
2238 { WM_SETREDRAW
, sent
|defwinproc
|wparam
, 0 },
2239 { HCBT_MINMAX
, hook
|lparam
, 0, SW_NORMALNA
},
2240 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_SHOWWINDOW
|0x8000 },
2241 { WM_NCCALCSIZE
, sent
|defwinproc
|wparam
, 1 },
2243 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2245 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|0x8000 },
2246 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2248 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2250 { WM_SETREDRAW
, sent
|defwinproc
|wparam
, 1 },
2252 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2253 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2254 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2255 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2256 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2258 /* bring the 1st MDI child to top */
2259 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2260 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 },
2261 { HCBT_SETFOCUS
, hook
},
2262 { WM_KILLFOCUS
, sent
|defwinproc
},
2263 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 0 },
2264 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2265 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2266 { WM_SETFOCUS
, sent
}, /* in MDI client */
2267 { HCBT_SETFOCUS
, hook
},
2268 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2269 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2270 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
2271 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2272 { WM_SETFOCUS
, sent
|defwinproc
},
2273 { WM_MDIACTIVATE
, sent
|defwinproc
},
2274 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2276 /* apparently ShowWindow(SW_SHOW) on an MDI client */
2277 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
2278 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2279 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2280 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2281 { WM_MDIREFRESHMENU
, sent
},
2283 { HCBT_DESTROYWND
, hook
},
2284 /* Win2k sends wparam set to
2285 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
2286 * while Win9x doesn't bother to set child window id according to
2287 * CLIENTCREATESTRUCT.idFirstChild
2289 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_DESTROY*/ }, /* in MDI client */
2290 { WM_SHOWWINDOW
, sent
|defwinproc
|wparam
, 0 },
2291 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2292 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2293 { WM_ERASEBKGND
, sent
|parent
|optional
},
2294 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2296 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
2297 { WM_DESTROY
, sent
|defwinproc
},
2298 { WM_NCDESTROY
, sent
|defwinproc
},
2301 /* WM_MDIDESTROY for the single MDI child window, initially visible and maximized */
2302 static const struct message WmDestroyMDIchildVisibleMaxSeq1
[] = {
2303 { WM_MDIDESTROY
, sent
}, /* in MDI client */
2304 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
2305 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2306 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2307 { WM_ERASEBKGND
, sent
|parent
|optional
},
2308 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2310 { HCBT_SETFOCUS
, hook
},
2311 { WM_KILLFOCUS
, sent
},
2312 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
2313 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2314 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2315 { WM_SETFOCUS
, sent
}, /* in MDI client */
2316 { HCBT_SETFOCUS
, hook
},
2317 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2318 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2319 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
2320 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2321 { WM_SETFOCUS
, sent
},
2324 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2325 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2326 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2327 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2330 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2331 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2332 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2333 { WM_MOVE
, sent
|defwinproc
},
2334 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2337 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
2338 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2339 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
},
2340 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2343 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
2344 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2345 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
},
2346 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2349 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2350 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 },
2351 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2352 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2355 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2356 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 },
2357 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2358 { WM_MOVE
, sent
|defwinproc
},
2359 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2362 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
2363 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2364 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
},
2365 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2368 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
},
2369 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 },
2370 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
},
2371 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2372 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2373 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI client */
2375 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
|optional
, 1 }, /* XP sends it to MDI frame */
2377 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2378 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2379 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI client */
2380 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2381 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* XP sends a duplicate */
2384 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2385 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2386 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2387 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2389 { WM_NCACTIVATE
, sent
|wparam
, 0 },
2390 { WM_MDIACTIVATE
, sent
},
2392 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWNORMAL
},
2393 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_SHOWWINDOW
|0x8000 },
2394 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2396 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2398 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2399 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_SHOWWINDOW
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
|0x8000 },
2400 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2403 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2404 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 },
2405 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2406 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2409 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2410 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2411 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2412 { WM_MOVE
, sent
|defwinproc
},
2413 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2416 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
2417 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2418 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
},
2419 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2420 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2421 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 }, /* XP */
2422 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI client */
2423 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2424 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* XP sends a duplicate */
2426 { HCBT_SETFOCUS
, hook
},
2427 { WM_KILLFOCUS
, sent
},
2428 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
2429 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2430 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2431 { WM_SETFOCUS
, sent
}, /* in MDI client */
2433 { WM_MDIREFRESHMENU
, sent
}, /* in MDI client */
2435 { HCBT_DESTROYWND
, hook
},
2436 /* Win2k sends wparam set to
2437 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
2438 * while Win9x doesn't bother to set child window id according to
2439 * CLIENTCREATESTRUCT.idFirstChild
2441 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_DESTROY*/ }, /* in MDI client */
2443 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
2444 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2445 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2446 { WM_ERASEBKGND
, sent
|parent
|optional
},
2447 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2449 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
2450 { WM_DESTROY
, sent
},
2451 { WM_NCDESTROY
, sent
},
2454 /* ShowWindow(SW_MAXIMIZE) for a not visible MDI child window */
2455 static const struct message WmMaximizeMDIchildInvisibleSeq
[] = {
2456 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
2457 { WM_GETMINMAXINFO
, sent
},
2458 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|0x8000 },
2459 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2460 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2461 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2463 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2464 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 },
2465 { HCBT_SETFOCUS
, hook
},
2466 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2467 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2468 { WM_SETFOCUS
, sent
}, /* in MDI client */
2469 { HCBT_SETFOCUS
, hook
},
2470 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2471 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2472 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
2473 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2474 { WM_SETFOCUS
, sent
|defwinproc
},
2475 { WM_MDIACTIVATE
, sent
|defwinproc
},
2476 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|0x8000 },
2477 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2479 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2480 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2481 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2482 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2483 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2486 /* ShowWindow(SW_MAXIMIZE) for a not visible maximized MDI child window */
2487 static const struct message WmMaximizeMDIchildInvisibleSeq2
[] = {
2488 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
2489 { WM_GETMINMAXINFO
, sent
},
2490 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
},
2491 { WM_GETMINMAXINFO
, sent
|defwinproc
},
2492 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2493 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2494 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2496 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2497 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 },
2498 { HCBT_SETFOCUS
, hook
},
2499 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2500 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2501 { WM_SETFOCUS
, sent
}, /* in MDI client */
2502 { HCBT_SETFOCUS
, hook
},
2503 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2504 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2505 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
2506 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2507 { WM_SETFOCUS
, sent
|defwinproc
},
2508 { WM_MDIACTIVATE
, sent
|defwinproc
},
2509 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2510 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2513 /* WM_MDIMAXIMIZE for an MDI child window with invisible parent */
2514 static const struct message WmMaximizeMDIchildInvisibleParentSeq
[] = {
2515 { WM_MDIMAXIMIZE
, sent
}, /* in MDI client */
2516 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
2517 { WM_GETMINMAXINFO
, sent
},
2518 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|0x8000 },
2519 { WM_GETMINMAXINFO
, sent
|defwinproc
},
2520 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2521 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* XP doesn't send it */
2522 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2523 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOREDRAW
|0x8000 },
2524 { WM_MOVE
, sent
|defwinproc
},
2525 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2527 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2528 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 },
2529 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2530 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
|optional
, 1 },
2531 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI child XP */
2532 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI client XP */
2534 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2535 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2536 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2537 { WM_MOVE
, sent
|defwinproc
},
2538 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2539 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI frame win2000 */
2541 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
2542 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2543 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
},
2544 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2546 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
},
2547 { WM_GETMINMAXINFO
, sent
|defwinproc
},
2548 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 },
2549 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
},
2550 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2551 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI child win2000 */
2552 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
|optional
, 1 },
2553 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI child XP */
2554 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI child XP */
2555 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI client XP */
2557 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
2558 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI frame XP */
2559 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI frame XP */
2560 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI child XP */
2563 /* ShowWindow(SW_MAXIMIZE) for a visible MDI child window */
2564 static const struct message WmMaximizeMDIchildVisibleSeq
[] = {
2565 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
2566 { WM_GETMINMAXINFO
, sent
},
2567 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|0x8000 },
2568 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2569 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2570 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|0x8000 },
2571 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2573 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2574 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2575 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2576 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2577 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2580 /* ShowWindow(SW_RESTORE) for a visible maximized MDI child window */
2581 static const struct message WmRestoreMDIchildVisibleSeq
[] = {
2582 { HCBT_MINMAX
, hook
|lparam
, 0, SW_RESTORE
},
2583 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|0x8000 },
2584 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2585 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2586 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|0x8000 },
2587 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2589 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2590 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2591 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2592 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2593 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2596 /* ShowWindow(SW_RESTORE) for a visible minimized MDI child window */
2597 static const struct message WmRestoreMDIchildVisibleSeq_2
[] = {
2598 { HCBT_MINMAX
, hook
|lparam
, 0, SW_RESTORE
},
2599 { WM_QUERYOPEN
, sent
|wparam
|lparam
, 0, 0 },
2600 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|0x8000 },
2601 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2602 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2603 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_NOCLIENTSIZE
|0x8000 },
2604 { WM_MOVE
, sent
|defwinproc
},
2605 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2606 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2607 { EVENT_SYSTEM_MINIMIZEEND
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2608 { HCBT_SETFOCUS
, hook
},
2609 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
2610 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
2611 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2612 { WM_SETFOCUS
, sent
},
2615 /* ShowWindow(SW_MINIMIZE) for a visible restored MDI child window */
2616 static const struct message WmMinimizeMDIchildVisibleSeq
[] = {
2617 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
2618 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOCOPYBITS
|0x8000 },
2619 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2620 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOCOPYBITS
|SWP_NOCLIENTSIZE
|0x8000 },
2621 { WM_MOVE
, sent
|defwinproc
},
2622 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MINIMIZED
},
2623 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
|defwinproc
, 0, 0 },
2624 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2625 { EVENT_SYSTEM_MINIMIZESTART
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2626 /* FIXME: Wine creates an icon/title window while Windows doesn't */
2627 { WM_PARENTNOTIFY
, sent
|parent
|wparam
|optional
, WM_CREATE
}, /* MDI client */
2630 /* ShowWindow(SW_RESTORE) for a not visible MDI child window */
2631 static const struct message WmRestoreMDIchildInisibleSeq
[] = {
2632 { HCBT_MINMAX
, hook
|lparam
, 0, SW_RESTORE
},
2633 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|0x8000 },
2634 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2635 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2636 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2637 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|0x8000 },
2638 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2640 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2641 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2642 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2643 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2644 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2648 static HWND mdi_client
;
2649 static WNDPROC old_mdi_client_proc
;
2651 static LRESULT WINAPI
mdi_client_hook_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
2655 /* do not log painting messages */
2656 if (message
!= WM_PAINT
&&
2657 message
!= WM_NCPAINT
&&
2658 message
!= WM_SYNCPAINT
&&
2659 message
!= WM_ERASEBKGND
&&
2660 message
!= WM_NCPAINT
&&
2661 message
!= WM_NCHITTEST
&&
2662 message
!= WM_GETTEXT
&&
2663 message
!= WM_MDIGETACTIVE
&&
2664 message
!= WM_GETICON
&&
2665 message
!= WM_DEVICECHANGE
)
2667 trace("mdi client: %p, %04x, %08lx, %08lx\n", hwnd
, message
, wParam
, lParam
);
2671 case WM_WINDOWPOSCHANGING
:
2672 case WM_WINDOWPOSCHANGED
:
2674 WINDOWPOS
*winpos
= (WINDOWPOS
*)lParam
;
2676 trace("%s\n", (message
== WM_WINDOWPOSCHANGING
) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
2677 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
2678 winpos
->hwnd
, winpos
->hwndInsertAfter
,
2679 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
2680 dump_winpos_flags(winpos
->flags
);
2682 /* Log only documented flags, win2k uses 0x1000 and 0x2000
2683 * in the high word for internal purposes
2685 wParam
= winpos
->flags
& 0xffff;
2686 /* We are not interested in the flags that don't match under XP and Win9x */
2687 wParam
&= ~(SWP_NOZORDER
);
2692 msg
.message
= message
;
2693 msg
.flags
= sent
|wparam
|lparam
;
2694 msg
.wParam
= wParam
;
2695 msg
.lParam
= lParam
;
2699 return CallWindowProcA(old_mdi_client_proc
, hwnd
, message
, wParam
, lParam
);
2702 static LRESULT WINAPI
mdi_child_wnd_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
2704 static long defwndproc_counter
= 0;
2708 /* do not log painting messages */
2709 if (message
!= WM_PAINT
&&
2710 message
!= WM_NCPAINT
&&
2711 message
!= WM_SYNCPAINT
&&
2712 message
!= WM_ERASEBKGND
&&
2713 message
!= WM_NCPAINT
&&
2714 message
!= WM_NCHITTEST
&&
2715 message
!= WM_GETTEXT
&&
2716 message
!= WM_GETICON
&&
2717 message
!= WM_DEVICECHANGE
)
2719 trace("mdi child: %p, %04x, %08lx, %08lx\n", hwnd
, message
, wParam
, lParam
);
2723 case WM_WINDOWPOSCHANGING
:
2724 case WM_WINDOWPOSCHANGED
:
2726 WINDOWPOS
*winpos
= (WINDOWPOS
*)lParam
;
2728 trace("%s\n", (message
== WM_WINDOWPOSCHANGING
) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
2729 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
2730 winpos
->hwnd
, winpos
->hwndInsertAfter
,
2731 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
2732 dump_winpos_flags(winpos
->flags
);
2734 /* Log only documented flags, win2k uses 0x1000 and 0x2000
2735 * in the high word for internal purposes
2737 wParam
= winpos
->flags
& 0xffff;
2738 /* We are not interested in the flags that don't match under XP and Win9x */
2739 wParam
&= ~(SWP_NOZORDER
);
2743 case WM_MDIACTIVATE
:
2745 HWND active
, client
= GetParent(hwnd
);
2747 active
= (HWND
)SendMessageA(client
, WM_MDIGETACTIVE
, 0, 0);
2749 if (hwnd
== (HWND
)lParam
) /* if we are being activated */
2750 ok (active
== (HWND
)lParam
, "new active %p != active %p\n", (HWND
)lParam
, active
);
2752 ok (active
== (HWND
)wParam
, "old active %p != active %p\n", (HWND
)wParam
, active
);
2757 msg
.message
= message
;
2758 msg
.flags
= sent
|wparam
|lparam
;
2759 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
2760 msg
.wParam
= wParam
;
2761 msg
.lParam
= lParam
;
2765 defwndproc_counter
++;
2766 ret
= DefMDIChildProcA(hwnd
, message
, wParam
, lParam
);
2767 defwndproc_counter
--;
2772 static LRESULT WINAPI
mdi_frame_wnd_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
2774 static long defwndproc_counter
= 0;
2778 /* do not log painting messages */
2779 if (message
!= WM_PAINT
&&
2780 message
!= WM_NCPAINT
&&
2781 message
!= WM_SYNCPAINT
&&
2782 message
!= WM_ERASEBKGND
&&
2783 message
!= WM_NCPAINT
&&
2784 message
!= WM_NCHITTEST
&&
2785 message
!= WM_GETTEXT
&&
2786 message
!= WM_GETICON
&&
2787 message
!= WM_DEVICECHANGE
)
2789 trace("mdi frame: %p, %04x, %08lx, %08lx\n", hwnd
, message
, wParam
, lParam
);
2793 case WM_WINDOWPOSCHANGING
:
2794 case WM_WINDOWPOSCHANGED
:
2796 WINDOWPOS
*winpos
= (WINDOWPOS
*)lParam
;
2798 trace("%s\n", (message
== WM_WINDOWPOSCHANGING
) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
2799 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
2800 winpos
->hwnd
, winpos
->hwndInsertAfter
,
2801 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
2802 dump_winpos_flags(winpos
->flags
);
2804 /* Log only documented flags, win2k uses 0x1000 and 0x2000
2805 * in the high word for internal purposes
2807 wParam
= winpos
->flags
& 0xffff;
2808 /* We are not interested in the flags that don't match under XP and Win9x */
2809 wParam
&= ~(SWP_NOZORDER
);
2814 msg
.message
= message
;
2815 msg
.flags
= sent
|wparam
|lparam
;
2816 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
2817 msg
.wParam
= wParam
;
2818 msg
.lParam
= lParam
;
2822 defwndproc_counter
++;
2823 ret
= DefFrameProcA(hwnd
, mdi_client
, message
, wParam
, lParam
);
2824 defwndproc_counter
--;
2829 static BOOL
mdi_RegisterWindowClasses(void)
2834 cls
.lpfnWndProc
= mdi_frame_wnd_proc
;
2837 cls
.hInstance
= GetModuleHandleA(0);
2839 cls
.hCursor
= LoadCursorA(0, (LPSTR
)IDC_ARROW
);
2840 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
2841 cls
.lpszMenuName
= NULL
;
2842 cls
.lpszClassName
= "MDI_frame_class";
2843 if (!RegisterClassA(&cls
)) return FALSE
;
2845 cls
.lpfnWndProc
= mdi_child_wnd_proc
;
2846 cls
.lpszClassName
= "MDI_child_class";
2847 if (!RegisterClassA(&cls
)) return FALSE
;
2849 if (!GetClassInfoA(0, "MDIClient", &cls
)) assert(0);
2850 old_mdi_client_proc
= cls
.lpfnWndProc
;
2851 cls
.hInstance
= GetModuleHandleA(0);
2852 cls
.lpfnWndProc
= mdi_client_hook_proc
;
2853 cls
.lpszClassName
= "MDI_client_class";
2854 if (!RegisterClassA(&cls
)) assert(0);
2859 static void test_mdi_messages(void)
2861 MDICREATESTRUCTA mdi_cs
;
2862 CLIENTCREATESTRUCT client_cs
;
2863 HWND mdi_frame
, mdi_child
, mdi_child2
, active_child
;
2865 HMENU hMenu
= CreateMenu();
2867 assert(mdi_RegisterWindowClasses());
2871 trace("creating MDI frame window\n");
2872 mdi_frame
= CreateWindowExA(0, "MDI_frame_class", "MDI frame window",
2873 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
|
2874 WS_MAXIMIZEBOX
| WS_VISIBLE
,
2875 100, 100, CW_USEDEFAULT
, CW_USEDEFAULT
,
2876 GetDesktopWindow(), hMenu
,
2877 GetModuleHandleA(0), NULL
);
2879 ok_sequence(WmCreateMDIframeSeq
, "Create MDI frame window", FALSE
);
2881 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
2882 ok(GetFocus() == mdi_frame
, "wrong focus window %p\n", GetFocus());
2884 trace("creating MDI client window\n");
2885 client_cs
.hWindowMenu
= 0;
2886 client_cs
.idFirstChild
= MDI_FIRST_CHILD_ID
;
2887 mdi_client
= CreateWindowExA(0, "MDI_client_class",
2889 WS_CHILD
| WS_VISIBLE
| MDIS_ALLCHILDSTYLES
,
2891 mdi_frame
, 0, GetModuleHandleA(0), &client_cs
);
2893 ok_sequence(WmCreateMDIclientSeq
, "Create visible MDI client window", FALSE
);
2895 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
2896 ok(GetFocus() == mdi_frame
, "input focus should be on MDI frame not on %p\n", GetFocus());
2898 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
2899 ok(!active_child
, "wrong active MDI child %p\n", active_child
);
2900 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
2905 trace("creating invisible MDI child window\n");
2906 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
2908 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
2909 mdi_client
, 0, GetModuleHandleA(0), NULL
);
2913 ShowWindow(mdi_child
, SW_SHOWNORMAL
);
2914 ok_sequence(WmShowChildSeq
, "ShowWindow(SW_SHOWNORMAL) MDI child window", FALSE
);
2916 ok(GetWindowLongA(mdi_child
, GWL_STYLE
) & WS_VISIBLE
, "MDI child should be visible\n");
2917 ok(IsWindowVisible(mdi_child
), "MDI child should be visible\n");
2919 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
2920 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2922 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
2923 ok(!active_child
, "wrong active MDI child %p\n", active_child
);
2924 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
2926 ShowWindow(mdi_child
, SW_HIDE
);
2927 ok_sequence(WmHideChildSeq
, "ShowWindow(SW_HIDE) MDI child window", FALSE
);
2930 ShowWindow(mdi_child
, SW_SHOW
);
2931 ok_sequence(WmShowChildSeq
, "ShowWindow(SW_SHOW) MDI child window", FALSE
);
2933 ok(GetWindowLongA(mdi_child
, GWL_STYLE
) & WS_VISIBLE
, "MDI child should be visible\n");
2934 ok(IsWindowVisible(mdi_child
), "MDI child should be visible\n");
2936 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
2937 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2939 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
2940 ok(!active_child
, "wrong active MDI child %p\n", active_child
);
2941 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
2943 DestroyWindow(mdi_child
);
2946 trace("creating visible MDI child window\n");
2947 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
2948 WS_CHILD
| WS_VISIBLE
,
2949 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
2950 mdi_client
, 0, GetModuleHandleA(0), NULL
);
2952 ok_sequence(WmCreateMDIchildVisibleSeq
, "Create visible MDI child window", FALSE
);
2954 ok(GetWindowLongA(mdi_child
, GWL_STYLE
) & WS_VISIBLE
, "MDI child should be visible\n");
2955 ok(IsWindowVisible(mdi_child
), "MDI child should be visible\n");
2957 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
2958 ok(GetFocus() == mdi_child
, "wrong focus window %p\n", GetFocus());
2960 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
2961 ok(active_child
== mdi_child
, "wrong active MDI child %p\n", active_child
);
2962 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
2965 DestroyWindow(mdi_child
);
2966 ok_sequence(WmDestroyMDIchildVisibleSeq
, "Destroy visible MDI child window", TRUE
);
2968 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
2969 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2971 /* Win2k: MDI client still returns a just destroyed child as active
2972 * Win9x: MDI client returns 0
2974 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
2975 ok(active_child
== mdi_child
|| /* win2k */
2976 !active_child
, /* win9x */
2977 "wrong active MDI child %p\n", active_child
);
2978 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
2982 trace("creating invisible MDI child window\n");
2983 mdi_child2
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
2985 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
2986 mdi_client
, 0, GetModuleHandleA(0), NULL
);
2988 ok_sequence(WmCreateMDIchildInvisibleSeq
, "Create invisible MDI child window", FALSE
);
2990 ok(!(GetWindowLongA(mdi_child2
, GWL_STYLE
) & WS_VISIBLE
), "MDI child should not be visible\n");
2991 ok(!IsWindowVisible(mdi_child2
), "MDI child should not be visible\n");
2993 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
2994 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2996 /* Win2k: MDI client still returns a just destroyed child as active
2997 * Win9x: MDI client returns mdi_child2
2999 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3000 ok(active_child
== mdi_child
|| /* win2k */
3001 active_child
== mdi_child2
, /* win9x */
3002 "wrong active MDI child %p\n", active_child
);
3003 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
3006 ShowWindow(mdi_child2
, SW_MAXIMIZE
);
3007 ok_sequence(WmMaximizeMDIchildInvisibleSeq
, "ShowWindow(SW_MAXIMIZE):invisible MDI child", FALSE
);
3009 ok(GetWindowLongA(mdi_child2
, GWL_STYLE
) & WS_VISIBLE
, "MDI child should be visible\n");
3010 ok(IsWindowVisible(mdi_child2
), "MDI child should be visible\n");
3012 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3013 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
3014 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
3017 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3018 ok(GetFocus() == mdi_child2
|| /* win2k */
3019 GetFocus() == 0, /* win9x */
3020 "wrong focus window %p\n", GetFocus());
3025 ShowWindow(mdi_child2
, SW_HIDE
);
3026 ok_sequence(WmHideChildSeq
, "ShowWindow(SW_HIDE):MDI child", FALSE
);
3028 ShowWindow(mdi_child2
, SW_RESTORE
);
3029 ok_sequence(WmRestoreMDIchildInisibleSeq
, "ShowWindow(SW_RESTORE):invisible MDI child", FALSE
);
3032 ok(GetWindowLongA(mdi_child2
, GWL_STYLE
) & WS_VISIBLE
, "MDI child should be visible\n");
3033 ok(IsWindowVisible(mdi_child2
), "MDI child should be visible\n");
3035 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3036 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
3037 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
3043 ShowWindow(mdi_child2
, SW_HIDE
);
3044 ok_sequence(WmHideChildSeq
, "ShowWindow(SW_HIDE):MDI child", FALSE
);
3046 ShowWindow(mdi_child2
, SW_SHOW
);
3047 ok_sequence(WmShowChildSeq
, "ShowWindow(SW_SHOW):MDI child", FALSE
);
3049 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3050 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3052 ShowWindow(mdi_child2
, SW_MAXIMIZE
);
3053 ok_sequence(WmMaximizeMDIchildVisibleSeq
, "ShowWindow(SW_MAXIMIZE):MDI child", FALSE
);
3055 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3056 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3058 ShowWindow(mdi_child2
, SW_RESTORE
);
3059 ok_sequence(WmRestoreMDIchildVisibleSeq
, "ShowWindow(SW_RESTORE):maximized MDI child", FALSE
);
3061 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3062 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3064 ShowWindow(mdi_child2
, SW_MINIMIZE
);
3065 ok_sequence(WmMinimizeMDIchildVisibleSeq
, "ShowWindow(SW_MINIMIZE):MDI child", TRUE
);
3067 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3068 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3070 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3071 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
3072 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
3075 ShowWindow(mdi_child2
, SW_RESTORE
);
3076 ok_sequence(WmRestoreMDIchildVisibleSeq_2
, "ShowWindow(SW_RESTORE):minimized MDI child", TRUE
);
3078 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3079 ok(GetFocus() == mdi_child2
, "wrong focus window %p\n", GetFocus());
3081 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3082 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
3083 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
3089 ShowWindow(mdi_child2
, SW_HIDE
);
3090 ok_sequence(WmHideChildSeq
, "ShowWindow(SW_HIDE):MDI child", FALSE
);
3092 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3093 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3095 DestroyWindow(mdi_child2
);
3096 ok_sequence(WmDestroyMDIchildInvisibleSeq
, "Destroy invisible MDI child window", FALSE
);
3098 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3099 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3101 /* test for maximized MDI children */
3102 trace("creating maximized visible MDI child window 1\n");
3103 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3104 WS_CHILD
| WS_VISIBLE
| WS_MAXIMIZEBOX
| WS_MAXIMIZE
,
3105 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
3106 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3108 ok_sequence(WmCreateMDIchildVisibleMaxSeq1
, "Create maximized visible 1st MDI child window", TRUE
);
3109 ok(IsZoomed(mdi_child
), "1st MDI child should be maximized\n");
3111 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3112 ok(GetFocus() == mdi_child
|| /* win2k */
3113 GetFocus() == 0, /* win9x */
3114 "wrong focus window %p\n", GetFocus());
3116 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3117 ok(active_child
== mdi_child
, "wrong active MDI child %p\n", active_child
);
3118 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
3121 trace("creating maximized visible MDI child window 2\n");
3122 mdi_child2
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3123 WS_CHILD
| WS_VISIBLE
| WS_MAXIMIZEBOX
| WS_MAXIMIZE
,
3124 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
3125 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3127 ok_sequence(WmCreateMDIchildVisibleMaxSeq2
, "Create maximized visible 2nd MDI child 2 window", TRUE
);
3128 ok(IsZoomed(mdi_child2
), "2nd MDI child should be maximized\n");
3129 ok(!IsZoomed(mdi_child
), "1st MDI child should NOT be maximized\n");
3131 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3132 ok(GetFocus() == mdi_child2
, "wrong focus window %p\n", GetFocus());
3134 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3135 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
3136 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
3139 trace("destroying maximized visible MDI child window 2\n");
3140 DestroyWindow(mdi_child2
);
3141 ok_sequence(WmDestroyMDIchildVisibleSeq
, "Destroy visible MDI child window", TRUE
);
3143 ok(!IsZoomed(mdi_child
), "1st MDI child should NOT be maximized\n");
3145 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3146 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3148 /* Win2k: MDI client still returns a just destroyed child as active
3149 * Win9x: MDI client returns 0
3151 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3152 ok(active_child
== mdi_child2
|| /* win2k */
3153 !active_child
, /* win9x */
3154 "wrong active MDI child %p\n", active_child
);
3157 ShowWindow(mdi_child
, SW_MAXIMIZE
);
3158 ok(IsZoomed(mdi_child
), "1st MDI child should be maximized\n");
3161 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3162 ok(GetFocus() == mdi_child
, "wrong focus window %p\n", GetFocus());
3164 trace("re-creating maximized visible MDI child window 2\n");
3165 mdi_child2
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3166 WS_CHILD
| WS_VISIBLE
| WS_MAXIMIZEBOX
| WS_MAXIMIZE
,
3167 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
3168 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3170 ok_sequence(WmCreateMDIchildVisibleMaxSeq2
, "Create maximized visible 2nd MDI child 2 window", TRUE
);
3171 ok(IsZoomed(mdi_child2
), "2nd MDI child should be maximized\n");
3172 ok(!IsZoomed(mdi_child
), "1st MDI child should NOT be maximized\n");
3174 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3175 ok(GetFocus() == mdi_child2
, "wrong focus window %p\n", GetFocus());
3177 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3178 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
3179 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
3182 SendMessageA(mdi_child2
, WM_SYSCOMMAND
, SC_CLOSE
, 0);
3183 ok_sequence(WmDestroyMDIchildVisibleMaxSeq2
, "WM_SYSCOMMAND/SC_CLOSE on a visible maximized MDI child window", TRUE
);
3184 ok(!IsWindow(mdi_child2
), "MDI child 2 should be destroyed\n");
3186 ok(IsZoomed(mdi_child
), "1st MDI child should be maximized\n");
3187 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3188 ok(GetFocus() == mdi_child
, "wrong focus window %p\n", GetFocus());
3190 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3191 ok(active_child
== mdi_child
, "wrong active MDI child %p\n", active_child
);
3192 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
3195 DestroyWindow(mdi_child
);
3196 ok_sequence(WmDestroyMDIchildVisibleSeq
, "Destroy visible MDI child window", TRUE
);
3198 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3199 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3201 /* Win2k: MDI client still returns a just destroyed child as active
3202 * Win9x: MDI client returns 0
3204 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3205 ok(active_child
== mdi_child
|| /* win2k */
3206 !active_child
, /* win9x */
3207 "wrong active MDI child %p\n", active_child
);
3210 trace("creating maximized invisible MDI child window\n");
3211 mdi_child2
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3212 WS_CHILD
| WS_MAXIMIZE
| WS_CAPTION
| WS_THICKFRAME
,
3213 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
3214 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3216 ok_sequence(WmCreateMDIchildInvisibleMaxSeq4
, "Create maximized invisible MDI child window", TRUE
);
3217 ok(IsZoomed(mdi_child2
), "MDI child should be maximized\n");
3218 ok(!(GetWindowLongA(mdi_child2
, GWL_STYLE
) & WS_VISIBLE
), "MDI child should be not visible\n");
3219 ok(!IsWindowVisible(mdi_child2
), "MDI child should be not visible\n");
3221 /* Win2k: MDI client still returns a just destroyed child as active
3222 * Win9x: MDI client returns 0
3224 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3225 ok(active_child
== mdi_child
|| /* win2k */
3226 !active_child
, /* win9x */
3227 "wrong active MDI child %p\n", active_child
);
3230 trace("call ShowWindow(mdi_child, SW_MAXIMIZE)\n");
3231 ShowWindow(mdi_child2
, SW_MAXIMIZE
);
3232 ok_sequence(WmMaximizeMDIchildInvisibleSeq2
, "ShowWindow(SW_MAXIMIZE):invisible maximized MDI child", FALSE
);
3233 ok(IsZoomed(mdi_child2
), "MDI child should be maximized\n");
3234 ok(GetWindowLongA(mdi_child2
, GWL_STYLE
) & WS_VISIBLE
, "MDI child should be visible\n");
3235 ok(IsWindowVisible(mdi_child2
), "MDI child should be visible\n");
3237 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3238 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
3239 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
3242 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child2
, 0);
3245 /* end of test for maximized MDI children */
3248 trace("creating maximized visible MDI child window 1(Switch test)\n");
3249 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3250 WS_CHILD
| WS_VISIBLE
| WS_MAXIMIZEBOX
| WS_MAXIMIZE
,
3251 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
3252 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3254 ok_sequence(WmCreateMDIchildVisibleMaxSeq1
, "Create maximized visible 1st MDI child window(Switch test)", TRUE
);
3255 ok(IsZoomed(mdi_child
), "1st MDI child should be maximized(Switch test)\n");
3257 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p(Switch test)\n", GetActiveWindow());
3258 ok(GetFocus() == mdi_child
|| /* win2k */
3259 GetFocus() == 0, /* win9x */
3260 "wrong focus window %p(Switch test)\n", GetFocus());
3262 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3263 ok(active_child
== mdi_child
, "wrong active MDI child %p(Switch test)\n", active_child
);
3264 ok(zoomed
, "wrong zoomed state %d(Switch test)\n", zoomed
);
3267 trace("creating maximized visible MDI child window 2(Switch test)\n");
3268 mdi_child2
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3269 WS_CHILD
| WS_VISIBLE
| WS_MAXIMIZEBOX
| WS_MAXIMIZE
,
3270 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
3271 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3273 ok_sequence(WmCreateMDIchildVisibleMaxSeq2
, "Create maximized visible 2nd MDI child window (Switch test)", TRUE
);
3275 ok(IsZoomed(mdi_child2
), "2nd MDI child should be maximized(Switch test)\n");
3276 ok(!IsZoomed(mdi_child
), "1st MDI child should NOT be maximized(Switch test)\n");
3278 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p(Switch test)\n", GetActiveWindow());
3279 ok(GetFocus() == mdi_child2
, "wrong focus window %p(Switch test)\n", GetFocus());
3281 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3282 ok(active_child
== mdi_child2
, "wrong active MDI child %p(Switch test)\n", active_child
);
3283 ok(zoomed
, "wrong zoomed state %d(Switch test)\n", zoomed
);
3286 trace("Switch child window.\n");
3287 SendMessageA(mdi_client
, WM_MDIACTIVATE
, (WPARAM
)mdi_child
, 0);
3288 ok_sequence(WmSwitchChild
, "Child did not switch correctly", TRUE
);
3289 trace("end of test for switch maximized MDI children\n");
3291 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
3294 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child2
, 0);
3299 /* end of test for switch maximized MDI children */
3301 mdi_cs
.szClass
= "MDI_child_Class";
3302 mdi_cs
.szTitle
= "MDI child";
3303 mdi_cs
.hOwner
= GetModuleHandleA(0);
3306 mdi_cs
.cx
= CW_USEDEFAULT
;
3307 mdi_cs
.cy
= CW_USEDEFAULT
;
3308 mdi_cs
.style
= WS_CHILD
| WS_SYSMENU
| WS_VISIBLE
| WS_MAXIMIZEBOX
| WS_MAXIMIZE
;
3310 mdi_child
= (HWND
)SendMessageA(mdi_client
, WM_MDICREATE
, 0, (LPARAM
)&mdi_cs
);
3311 ok(mdi_child
!= 0, "MDI child creation failed\n");
3312 ok_sequence(WmCreateMDIchildVisibleMaxSeq3
, "WM_MDICREATE for maximized visible MDI child window", TRUE
);
3314 ok(GetMenuItemID(hMenu
, GetMenuItemCount(hMenu
) - 1) == SC_CLOSE
, "SC_CLOSE menu item not found\n");
3316 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3317 ok(active_child
== mdi_child
, "wrong active MDI child %p\n", active_child
);
3319 ok(IsZoomed(mdi_child
), "MDI child should be maximized\n");
3320 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3321 ok(GetFocus() == mdi_child
, "wrong focus window %p\n", GetFocus());
3323 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3324 ok(active_child
== mdi_child
, "wrong active MDI child %p\n", active_child
);
3325 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
3328 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
3329 ok_sequence(WmDestroyMDIchildVisibleMaxSeq1
, "Destroy visible maximized MDI child window", TRUE
);
3331 ok(!IsWindow(mdi_child
), "MDI child should be destroyed\n");
3332 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3333 ok(!active_child
, "wrong active MDI child %p\n", active_child
);
3338 DestroyWindow(mdi_client
);
3339 ok_sequence(WmDestroyMDIclientSeq
, "Destroy MDI client window", FALSE
);
3341 /* test maximization of MDI child with invisible parent */
3342 client_cs
.hWindowMenu
= 0;
3343 mdi_client
= CreateWindow("MDI_client_class",
3345 WS_CHILD
| WS_CLIPCHILDREN
| WS_VSCROLL
| WS_HSCROLL
| WS_VISIBLE
,
3347 mdi_frame
, 0, GetModuleHandleA(0), &client_cs
);
3348 ok_sequence(WmCreateMDIclientSeq
, "Create MDI client window", FALSE
);
3350 ShowWindow(mdi_client
, SW_HIDE
);
3351 ok_sequence(WmHideMDIclientSeq
, "Hide MDI client window", FALSE
);
3353 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3354 WS_CHILD
| WS_CLIPCHILDREN
| WS_VSCROLL
| WS_HSCROLL
,
3356 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3357 ok_sequence(WmCreateMDIchildInvisibleParentSeq
, "Create MDI child window with invisible parent", FALSE
);
3359 SendMessage(mdi_client
, WM_MDIMAXIMIZE
, (WPARAM
) mdi_child
, 0);
3360 ok_sequence(WmMaximizeMDIchildInvisibleParentSeq
, "Maximize MDI child window with invisible parent", TRUE
);
3361 zoomed
= IsZoomed(mdi_child
);
3362 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
3364 ShowWindow(mdi_client
, SW_SHOW
);
3365 ok_sequence(WmShowMDIclientSeq
, "Show MDI client window", FALSE
);
3367 DestroyWindow(mdi_child
);
3368 ok_sequence(WmDestroyMDIchildVisibleSeq
, "Destroy visible maximized MDI child window", TRUE
);
3370 /* end of test for maximization of MDI child with invisible parent */
3372 DestroyWindow(mdi_client
);
3373 ok_sequence(WmDestroyMDIclientSeq
, "Destroy MDI client window", FALSE
);
3375 DestroyWindow(mdi_frame
);
3376 ok_sequence(WmDestroyMDIframeSeq
, "Destroy MDI frame window", FALSE
);
3378 /************************* End of MDI test **********************************/
3380 static void test_WM_SETREDRAW(HWND hwnd
)
3382 DWORD style
= GetWindowLongA(hwnd
, GWL_STYLE
);
3386 SendMessageA(hwnd
, WM_SETREDRAW
, FALSE
, 0);
3387 ok_sequence(WmSetRedrawFalseSeq
, "SetRedraw:FALSE", FALSE
);
3389 ok(!(GetWindowLongA(hwnd
, GWL_STYLE
) & WS_VISIBLE
), "WS_VISIBLE should NOT be set\n");
3390 ok(!IsWindowVisible(hwnd
), "IsWindowVisible() should return FALSE\n");
3393 SendMessageA(hwnd
, WM_SETREDRAW
, TRUE
, 0);
3394 ok_sequence(WmSetRedrawTrueSeq
, "SetRedraw:TRUE", FALSE
);
3396 ok(GetWindowLongA(hwnd
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
3397 ok(IsWindowVisible(hwnd
), "IsWindowVisible() should return TRUE\n");
3399 /* restore original WS_VISIBLE state */
3400 SetWindowLongA(hwnd
, GWL_STYLE
, style
);
3405 static INT_PTR CALLBACK
TestModalDlgProcA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
3409 trace("dialog: %p, %04x, %08lx, %08lx\n", hwnd
, message
, wParam
, lParam
);
3411 /* explicitly ignore WM_GETICON message */
3412 if (message
== WM_GETICON
) return 0;
3419 case WM_DEVICECHANGE
:
3424 case WM_WINDOWPOSCHANGING
:
3425 case WM_WINDOWPOSCHANGED
:
3427 WINDOWPOS
*winpos
= (WINDOWPOS
*)lParam
;
3429 trace("%s\n", (message
== WM_WINDOWPOSCHANGING
) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
3430 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
3431 winpos
->hwnd
, winpos
->hwndInsertAfter
,
3432 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
3433 dump_winpos_flags(winpos
->flags
);
3435 /* Log only documented flags, win2k uses 0x1000 and 0x2000
3436 * in the high word for internal purposes
3438 wParam
= winpos
->flags
& 0xffff;
3439 /* We are not interested in the flags that don't match under XP and Win9x */
3440 wParam
&= ~(SWP_NOZORDER
);
3445 msg
.message
= message
;
3446 msg
.flags
= sent
|wparam
|lparam
;
3447 msg
.wParam
= wParam
;
3448 msg
.lParam
= lParam
;
3451 if (message
== WM_INITDIALOG
) SetTimer( hwnd
, 1, 100, NULL
);
3452 if (message
== WM_TIMER
) EndDialog( hwnd
, 0 );
3456 static void test_hv_scroll_1(HWND hwnd
, INT ctl
, DWORD clear
, DWORD set
, INT min
, INT max
)
3458 DWORD style
, exstyle
;
3462 exstyle
= GetWindowLongA(hwnd
, GWL_EXSTYLE
);
3463 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
3464 /* do not be confused by WS_DLGFRAME set */
3465 if ((style
& WS_CAPTION
) == WS_CAPTION
) style
&= ~WS_CAPTION
;
3467 if (clear
) ok(style
& clear
, "style %08x should be set\n", clear
);
3468 if (set
) ok(!(style
& set
), "style %08x should not be set\n", set
);
3470 ret
= SetScrollRange(hwnd
, ctl
, min
, max
, FALSE
);
3471 ok( ret
, "SetScrollRange(%d) error %d\n", ctl
, GetLastError());
3472 if ((style
& (WS_DLGFRAME
| WS_BORDER
| WS_THICKFRAME
)) || (exstyle
& WS_EX_DLGMODALFRAME
))
3473 ok_sequence(WmSetScrollRangeHV_NC_Seq
, "SetScrollRange(SB_HORZ/SB_VERT) NC", FALSE
);
3475 ok_sequence(WmSetScrollRangeHVSeq
, "SetScrollRange(SB_HORZ/SB_VERT)", FALSE
);
3477 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
3478 if (set
) ok(style
& set
, "style %08x should be set\n", set
);
3479 if (clear
) ok(!(style
& clear
), "style %08x should not be set\n", clear
);
3481 /* a subsequent call should do nothing */
3482 ret
= SetScrollRange(hwnd
, ctl
, min
, max
, FALSE
);
3483 ok( ret
, "SetScrollRange(%d) error %d\n", ctl
, GetLastError());
3484 ok_sequence(WmEmptySeq
, "SetScrollRange(SB_HORZ/SB_VERT) empty sequence", FALSE
);
3488 trace("Ignore GetScrollRange error below if you are on Win9x\n");
3489 ret
= GetScrollRange(hwnd
, ctl
, &xmin
, &xmax
);
3490 ok( ret
, "GetScrollRange(%d) error %d\n", ctl
, GetLastError());
3491 ok_sequence(WmEmptySeq
, "GetScrollRange(SB_HORZ/SB_VERT) empty sequence", FALSE
);
3492 ok(xmin
== min
, "unexpected min scroll value %d\n", xmin
);
3493 ok(xmax
== max
, "unexpected max scroll value %d\n", xmax
);
3496 static void test_hv_scroll_2(HWND hwnd
, INT ctl
, DWORD clear
, DWORD set
, INT min
, INT max
)
3498 DWORD style
, exstyle
;
3502 exstyle
= GetWindowLongA(hwnd
, GWL_EXSTYLE
);
3503 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
3504 /* do not be confused by WS_DLGFRAME set */
3505 if ((style
& WS_CAPTION
) == WS_CAPTION
) style
&= ~WS_CAPTION
;
3507 if (clear
) ok(style
& clear
, "style %08x should be set\n", clear
);
3508 if (set
) ok(!(style
& set
), "style %08x should not be set\n", set
);
3510 si
.cbSize
= sizeof(si
);
3511 si
.fMask
= SIF_RANGE
;
3514 SetScrollInfo(hwnd
, ctl
, &si
, TRUE
);
3515 if ((style
& (WS_DLGFRAME
| WS_BORDER
| WS_THICKFRAME
)) || (exstyle
& WS_EX_DLGMODALFRAME
))
3516 ok_sequence(WmSetScrollRangeHV_NC_Seq
, "SetScrollInfo(SB_HORZ/SB_VERT) NC", FALSE
);
3518 ok_sequence(WmSetScrollRangeHVSeq
, "SetScrollInfo(SB_HORZ/SB_VERT)", FALSE
);
3520 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
3521 if (set
) ok(style
& set
, "style %08x should be set\n", set
);
3522 if (clear
) ok(!(style
& clear
), "style %08x should not be set\n", clear
);
3524 /* a subsequent call should do nothing */
3525 SetScrollInfo(hwnd
, ctl
, &si
, TRUE
);
3526 if (style
& WS_HSCROLL
)
3527 ok_sequence(WmSetScrollRangeHSeq_empty
, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE
);
3528 else if (style
& WS_VSCROLL
)
3529 ok_sequence(WmSetScrollRangeVSeq_empty
, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE
);
3531 ok_sequence(WmEmptySeq
, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE
);
3533 si
.fMask
= SIF_PAGE
;
3535 SetScrollInfo(hwnd
, ctl
, &si
, FALSE
);
3536 ok_sequence(WmEmptySeq
, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE
);
3540 SetScrollInfo(hwnd
, ctl
, &si
, FALSE
);
3541 ok_sequence(WmEmptySeq
, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE
);
3543 si
.fMask
= SIF_RANGE
;
3544 si
.nMin
= 0xdeadbeef;
3545 si
.nMax
= 0xdeadbeef;
3546 ret
= GetScrollInfo(hwnd
, ctl
, &si
);
3547 ok( ret
, "GetScrollInfo error %d\n", GetLastError());
3548 ok_sequence(WmEmptySeq
, "GetScrollRange(SB_HORZ/SB_VERT) empty sequence", FALSE
);
3549 ok(si
.nMin
== min
, "unexpected min scroll value %d\n", si
.nMin
);
3550 ok(si
.nMax
== max
, "unexpected max scroll value %d\n", si
.nMax
);
3553 /* Win9x sends WM_USER+xxx while and NT versions send SBM_xxx messages */
3554 static void test_scroll_messages(HWND hwnd
)
3562 ret
= GetScrollRange(hwnd
, SB_CTL
, &min
, &max
);
3563 ok( ret
, "GetScrollRange error %d\n", GetLastError());
3564 if (sequence
->message
!= WmGetScrollRangeSeq
[0].message
)
3565 trace("GetScrollRange(SB_CTL) generated unknown message %04x\n", sequence
->message
);
3566 /* values of min and max are undefined */
3569 ret
= SetScrollRange(hwnd
, SB_CTL
, 10, 150, FALSE
);
3570 ok( ret
, "SetScrollRange error %d\n", GetLastError());
3571 if (sequence
->message
!= WmSetScrollRangeSeq
[0].message
)
3572 trace("SetScrollRange(SB_CTL) generated unknown message %04x\n", sequence
->message
);
3577 ret
= GetScrollRange(hwnd
, SB_CTL
, &min
, &max
);
3578 ok( ret
, "GetScrollRange error %d\n", GetLastError());
3579 if (sequence
->message
!= WmGetScrollRangeSeq
[0].message
)
3580 trace("GetScrollRange(SB_CTL) generated unknown message %04x\n", sequence
->message
);
3581 /* values of min and max are undefined */
3584 si
.cbSize
= sizeof(si
);
3585 si
.fMask
= SIF_RANGE
;
3588 SetScrollInfo(hwnd
, SB_CTL
, &si
, FALSE
);
3589 if (sequence
->message
!= WmSetScrollRangeSeq
[0].message
)
3590 trace("SetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence
->message
);
3593 si
.fMask
= SIF_PAGE
;
3595 SetScrollInfo(hwnd
, SB_CTL
, &si
, FALSE
);
3596 if (sequence
->message
!= WmSetScrollRangeSeq
[0].message
)
3597 trace("SetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence
->message
);
3602 SetScrollInfo(hwnd
, SB_CTL
, &si
, FALSE
);
3603 if (sequence
->message
!= WmSetScrollRangeSeq
[0].message
)
3604 trace("SetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence
->message
);
3607 si
.fMask
= SIF_RANGE
;
3608 si
.nMin
= 0xdeadbeef;
3609 si
.nMax
= 0xdeadbeef;
3610 ret
= GetScrollInfo(hwnd
, SB_CTL
, &si
);
3611 ok( ret
, "GetScrollInfo error %d\n", GetLastError());
3612 if (sequence
->message
!= WmGetScrollInfoSeq
[0].message
)
3613 trace("GetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence
->message
);
3614 /* values of min and max are undefined */
3617 /* set WS_HSCROLL */
3618 test_hv_scroll_1(hwnd
, SB_HORZ
, 0, WS_HSCROLL
, 10, 150);
3619 /* clear WS_HSCROLL */
3620 test_hv_scroll_1(hwnd
, SB_HORZ
, WS_HSCROLL
, 0, 0, 0);
3622 /* set WS_HSCROLL */
3623 test_hv_scroll_2(hwnd
, SB_HORZ
, 0, WS_HSCROLL
, 10, 150);
3624 /* clear WS_HSCROLL */
3625 test_hv_scroll_2(hwnd
, SB_HORZ
, WS_HSCROLL
, 0, 0, 0);
3627 /* set WS_VSCROLL */
3628 test_hv_scroll_1(hwnd
, SB_VERT
, 0, WS_VSCROLL
, 10, 150);
3629 /* clear WS_VSCROLL */
3630 test_hv_scroll_1(hwnd
, SB_VERT
, WS_VSCROLL
, 0, 0, 0);
3632 /* set WS_VSCROLL */
3633 test_hv_scroll_2(hwnd
, SB_VERT
, 0, WS_VSCROLL
, 10, 150);
3634 /* clear WS_VSCROLL */
3635 test_hv_scroll_2(hwnd
, SB_VERT
, WS_VSCROLL
, 0, 0, 0);
3638 static void test_showwindow(void)
3643 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW
,
3644 100, 100, 200, 200, 0, 0, 0, NULL
);
3645 ok (hwnd
!= 0, "Failed to create overlapped window\n");
3646 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
3647 0, 0, 10, 10, hwnd
, 0, 0, NULL
);
3648 ok (hchild
!= 0, "Failed to create child\n");
3651 /* ShowWindow( SW_SHOWNA) for invisible top level window */
3652 trace("calling ShowWindow( SW_SHOWNA) for invisible top level window\n");
3653 ok( ShowWindow(hwnd
, SW_SHOWNA
) == FALSE
, "ShowWindow: window was visible\n" );
3654 ok_sequence(WmSHOWNATopInvisible
, "ShowWindow(SW_SHOWNA) on invisible top level window", TRUE
);
3657 /* ShowWindow( SW_SHOWNA) for now visible top level window */
3658 trace("calling ShowWindow( SW_SHOWNA) for now visible top level window\n");
3659 ok( ShowWindow(hwnd
, SW_SHOWNA
) != FALSE
, "ShowWindow: window was invisible\n" );
3660 ok_sequence(WmSHOWNATopVisible
, "ShowWindow(SW_SHOWNA) on visible top level window", FALSE
);
3662 /* back to invisible */
3663 ShowWindow(hchild
, SW_HIDE
);
3664 ShowWindow(hwnd
, SW_HIDE
);
3666 /* ShowWindow(SW_SHOWNA) with child and parent invisible */
3667 trace("calling ShowWindow( SW_SHOWNA) for invisible child with invisible parent\n");
3668 ok( ShowWindow(hchild
, SW_SHOWNA
) == FALSE
, "ShowWindow: window was visible\n" );
3669 ok_sequence(WmSHOWNAChildInvisParInvis
, "ShowWindow(SW_SHOWNA) invisible child and parent", FALSE
);
3671 /* ShowWindow(SW_SHOWNA) with child visible and parent invisible */
3672 ok( ShowWindow(hchild
, SW_SHOW
) != FALSE
, "ShowWindow: window was invisible\n" );
3674 trace("calling ShowWindow( SW_SHOWNA) for the visible child and invisible parent\n");
3675 ok( ShowWindow(hchild
, SW_SHOWNA
) != FALSE
, "ShowWindow: window was invisible\n" );
3676 ok_sequence(WmSHOWNAChildVisParInvis
, "ShowWindow(SW_SHOWNA) visible child and invisible parent", FALSE
);
3678 /* ShowWindow(SW_SHOWNA) with child visible and parent visible */
3679 ShowWindow( hwnd
, SW_SHOW
);
3681 trace("calling ShowWindow( SW_SHOWNA) for the visible child and parent\n");
3682 ok( ShowWindow(hchild
, SW_SHOWNA
) != FALSE
, "ShowWindow: window was invisible\n" );
3683 ok_sequence(WmSHOWNAChildVisParVis
, "ShowWindow(SW_SHOWNA) for the visible child and parent", FALSE
);
3686 /* ShowWindow(SW_SHOWNA) with child invisible and parent visible */
3687 ShowWindow( hchild
, SW_HIDE
);
3689 trace("calling ShowWindow( SW_SHOWNA) for the invisible child and visible parent\n");
3690 ok( ShowWindow(hchild
, SW_SHOWNA
) == FALSE
, "ShowWindow: window was visible\n" );
3691 ok_sequence(WmSHOWNAChildInvisParVis
, "ShowWindow(SW_SHOWNA) for the invisible child and visible parent", FALSE
);
3695 ok(GetCapture() == hchild
, "wrong capture window %p\n", GetCapture());
3696 DestroyWindow(hchild
);
3697 ok(!GetCapture(), "wrong capture window %p\n", GetCapture());
3699 DestroyWindow(hwnd
);
3704 * 1. Create invisible maximized popup window.
3705 * 2. Move and resize it.
3706 * 3. Show it maximized.
3708 trace("calling CreateWindowExA( WS_MAXIMIZE ) for invisible maximized popup window\n");
3709 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP
| WS_MAXIMIZE
,
3710 100, 100, 200, 200, 0, 0, 0, NULL
);
3711 ok (hwnd
!= 0, "Failed to create popup window\n");
3712 ok(IsZoomed(hwnd
), "window should be maximized\n");
3713 ok_sequence(WmCreateInvisibleMaxPopupSeq
, "CreateWindow(WS_MAXIMIZED):popup", FALSE
);
3716 GetWindowRect(hwnd
, &rc
);
3717 ok( rc
.right
-rc
.left
== GetSystemMetrics(SM_CXSCREEN
) &&
3718 rc
.bottom
-rc
.top
== GetSystemMetrics(SM_CYSCREEN
),
3719 "Invalid maximized size before ShowWindow (%d,%d)-(%d,%d)\n",
3720 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
3721 /* Reset window's size & position */
3722 SetWindowPos(hwnd
, 0, 10, 10, 200, 200, SWP_NOZORDER
| SWP_NOACTIVATE
);
3723 ok(IsZoomed(hwnd
), "window should be maximized\n");
3726 trace("calling ShowWindow( SW_SHOWMAXIMIZE ) for invisible maximized popup window\n");
3727 ShowWindow(hwnd
, SW_SHOWMAXIMIZED
);
3728 ok(IsZoomed(hwnd
), "window should be maximized\n");
3729 ok_sequence(WmShowMaxPopupResizedSeq
, "ShowWindow(SW_SHOWMAXIMIZED):invisible maximized and resized popup", FALSE
);
3732 GetWindowRect(hwnd
, &rc
);
3733 ok( rc
.right
-rc
.left
== GetSystemMetrics(SM_CXSCREEN
) &&
3734 rc
.bottom
-rc
.top
== GetSystemMetrics(SM_CYSCREEN
),
3735 "Invalid maximized size after ShowWindow (%d,%d)-(%d,%d)\n",
3736 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
3737 DestroyWindow(hwnd
);
3741 * 1. Create invisible maximized popup window.
3742 * 2. Show it maximized.
3744 trace("calling CreateWindowExA( WS_MAXIMIZE ) for invisible maximized popup window\n");
3745 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP
| WS_MAXIMIZE
,
3746 100, 100, 200, 200, 0, 0, 0, NULL
);
3747 ok (hwnd
!= 0, "Failed to create popup window\n");
3748 ok(IsZoomed(hwnd
), "window should be maximized\n");
3749 ok_sequence(WmCreateInvisibleMaxPopupSeq
, "CreateWindow(WS_MAXIMIZED):popup", FALSE
);
3752 trace("calling ShowWindow( SW_SHOWMAXIMIZE ) for invisible maximized popup window\n");
3753 ShowWindow(hwnd
, SW_SHOWMAXIMIZED
);
3754 ok(IsZoomed(hwnd
), "window should be maximized\n");
3755 ok_sequence(WmShowMaxPopupSeq
, "ShowWindow(SW_SHOWMAXIMIZED):invisible maximized popup", FALSE
);
3757 DestroyWindow(hwnd
);
3761 * 1. Create visible maximized popup window.
3763 trace("calling CreateWindowExA( WS_MAXIMIZE ) for maximized popup window\n");
3764 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP
| WS_MAXIMIZE
| WS_VISIBLE
,
3765 100, 100, 200, 200, 0, 0, 0, NULL
);
3766 ok (hwnd
!= 0, "Failed to create popup window\n");
3767 ok(IsZoomed(hwnd
), "window should be maximized\n");
3768 ok_sequence(WmCreateMaxPopupSeq
, "CreateWindow(WS_MAXIMIZED):popup", FALSE
);
3770 DestroyWindow(hwnd
);
3774 * 1. Create visible popup window.
3777 trace("calling CreateWindowExA( WS_VISIBLE ) for popup window\n");
3778 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP
| WS_VISIBLE
,
3779 100, 100, 200, 200, 0, 0, 0, NULL
);
3780 ok (hwnd
!= 0, "Failed to create popup window\n");
3781 ok(!IsZoomed(hwnd
), "window should NOT be maximized\n");
3782 ok_sequence(WmCreatePopupSeq
, "CreateWindow(WS_VISIBLE):popup", FALSE
);
3785 trace("calling ShowWindow( SW_SHOWMAXIMIZE ) for visible popup window\n");
3786 ShowWindow(hwnd
, SW_SHOWMAXIMIZED
);
3787 ok(IsZoomed(hwnd
), "window should be maximized\n");
3788 ok_sequence(WmShowVisMaxPopupSeq
, "ShowWindow(SW_SHOWMAXIMIZED):popup", FALSE
);
3790 DestroyWindow(hwnd
);
3794 static void test_sys_menu(void)
3800 hwnd
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
3801 100, 100, 200, 200, 0, 0, 0, NULL
);
3802 ok (hwnd
!= 0, "Failed to create overlapped window\n");
3806 /* test existing window without CS_NOCLOSE style */
3807 hmenu
= GetSystemMenu(hwnd
, FALSE
);
3808 ok(hmenu
!= 0, "GetSystemMenu error %d\n", GetLastError());
3810 state
= GetMenuState(hmenu
, SC_CLOSE
, MF_BYCOMMAND
);
3811 ok(state
!= 0xffffffff, "wrong SC_CLOSE state %x\n", state
);
3812 ok(!(state
& (MF_DISABLED
| MF_GRAYED
)), "wrong SC_CLOSE state %x\n", state
);
3814 EnableMenuItem(hmenu
, SC_CLOSE
, MF_BYCOMMAND
| MF_GRAYED
);
3815 ok_sequence(WmEmptySeq
, "WmEnableMenuItem", FALSE
);
3817 state
= GetMenuState(hmenu
, SC_CLOSE
, MF_BYCOMMAND
);
3818 ok(state
!= 0xffffffff, "wrong SC_CLOSE state %x\n", state
);
3819 ok((state
& (MF_DISABLED
| MF_GRAYED
)) == MF_GRAYED
, "wrong SC_CLOSE state %x\n", state
);
3821 EnableMenuItem(hmenu
, SC_CLOSE
, 0);
3822 ok_sequence(WmEmptySeq
, "WmEnableMenuItem", FALSE
);
3824 state
= GetMenuState(hmenu
, SC_CLOSE
, MF_BYCOMMAND
);
3825 ok(state
!= 0xffffffff, "wrong SC_CLOSE state %x\n", state
);
3826 ok(!(state
& (MF_DISABLED
| MF_GRAYED
)), "wrong SC_CLOSE state %x\n", state
);
3828 /* test whether removing WS_SYSMENU destroys a system menu */
3829 SetWindowLongW(hwnd
, GWL_STYLE
, WS_POPUP
);
3830 SetWindowPos(hwnd
, 0, 0, 0, 0, 0, SWP_NOZORDER
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_FRAMECHANGED
);
3832 hmenu
= GetSystemMenu(hwnd
, FALSE
);
3833 ok(hmenu
!= 0, "GetSystemMenu error %d\n", GetLastError());
3835 DestroyWindow(hwnd
);
3837 /* test new window with CS_NOCLOSE style */
3838 hwnd
= CreateWindowExA(0, "NoCloseWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
3839 100, 100, 200, 200, 0, 0, 0, NULL
);
3840 ok (hwnd
!= 0, "Failed to create overlapped window\n");
3842 hmenu
= GetSystemMenu(hwnd
, FALSE
);
3843 ok(hmenu
!= 0, "GetSystemMenu error %d\n", GetLastError());
3845 state
= GetMenuState(hmenu
, SC_CLOSE
, MF_BYCOMMAND
);
3846 ok(state
== 0xffffffff, "wrong SC_CLOSE state %x\n", state
);
3848 DestroyWindow(hwnd
);
3850 /* test new window without WS_SYSMENU style */
3851 hwnd
= CreateWindowExA(0, "NoCloseWindowClass", NULL
, WS_OVERLAPPEDWINDOW
& ~WS_SYSMENU
,
3852 100, 100, 200, 200, 0, 0, 0, NULL
);
3853 ok(hwnd
!= 0, "Failed to create overlapped window\n");
3855 hmenu
= GetSystemMenu(hwnd
, FALSE
);
3856 ok(!hmenu
, "GetSystemMenu error %d\n", GetLastError());
3858 DestroyWindow(hwnd
);
3861 /* For shown WS_OVERLAPPEDWINDOW */
3862 static const struct message WmSetIcon_1
[] = {
3863 { WM_SETICON
, sent
},
3864 { 0x00AE, sent
|defwinproc
|optional
}, /* XP */
3865 { WM_GETTEXT
, sent
|defwinproc
|optional
},
3866 { WM_GETTEXT
, sent
|defwinproc
|optional
}, /* XP sends a duplicate */
3870 /* For WS_POPUP and hidden WS_OVERLAPPEDWINDOW */
3871 static const struct message WmSetIcon_2
[] = {
3872 { WM_SETICON
, sent
},
3876 /* Sending undocumented 0x3B message with wparam = 0x8000000b */
3877 static const struct message WmInitEndSession
[] = {
3879 { WM_QUERYENDSESSION
, sent
|defwinproc
|wparam
|lparam
, 0, ENDSESSION_LOGOFF
},
3883 /* Sending undocumented 0x3B message with wparam = 0x0000000b */
3884 static const struct message WmInitEndSession_2
[] = {
3886 { WM_QUERYENDSESSION
, sent
|defwinproc
|wparam
|lparam
, 0, 0 },
3890 /* Sending undocumented 0x3B message with wparam = 0x80000008 */
3891 static const struct message WmInitEndSession_3
[] = {
3893 { WM_ENDSESSION
, sent
|defwinproc
|wparam
|lparam
, 0, ENDSESSION_LOGOFF
},
3897 /* Sending undocumented 0x3B message with wparam = 0x00000008 */
3898 static const struct message WmInitEndSession_4
[] = {
3900 { WM_ENDSESSION
, sent
|defwinproc
|wparam
|lparam
, 0, 0 },
3904 /* Sending undocumented 0x3B message with wparam = 0x80000001 */
3905 static const struct message WmInitEndSession_5
[] = {
3907 { WM_ENDSESSION
, sent
|defwinproc
|wparam
|lparam
, 1, ENDSESSION_LOGOFF
},
3911 static void test_MsgWaitForMultipleObjects(HWND hwnd
)
3916 ret
= MsgWaitForMultipleObjects(0, NULL
, FALSE
, 0, QS_POSTMESSAGE
);
3917 ok(ret
== WAIT_TIMEOUT
, "MsgWaitForMultipleObjects returned %x\n", ret
);
3919 PostMessageA(hwnd
, WM_USER
, 0, 0);
3921 ret
= MsgWaitForMultipleObjects(0, NULL
, FALSE
, 0, QS_POSTMESSAGE
);
3922 ok(ret
== WAIT_OBJECT_0
, "MsgWaitForMultipleObjects returned %x\n", ret
);
3924 ok(PeekMessageW( &msg
, 0, 0, 0, PM_REMOVE
), "PeekMessage should succeed\n");
3925 ok(msg
.message
== WM_USER
, "got %04x instead of WM_USER\n", msg
.message
);
3927 ret
= MsgWaitForMultipleObjects(0, NULL
, FALSE
, 0, QS_POSTMESSAGE
);
3928 ok(ret
== WAIT_TIMEOUT
, "MsgWaitForMultipleObjects returned %x\n", ret
);
3930 PostMessageA(hwnd
, WM_USER
, 0, 0);
3932 ret
= MsgWaitForMultipleObjects(0, NULL
, FALSE
, 0, QS_POSTMESSAGE
);
3933 ok(ret
== WAIT_OBJECT_0
, "MsgWaitForMultipleObjects returned %x\n", ret
);
3935 ok(PeekMessageW( &msg
, 0, 0, 0, PM_NOREMOVE
), "PeekMessage should succeed\n");
3936 ok(msg
.message
== WM_USER
, "got %04x instead of WM_USER\n", msg
.message
);
3938 /* shows QS_POSTMESSAGE flag is cleared in the PeekMessage call */
3939 ret
= MsgWaitForMultipleObjects(0, NULL
, FALSE
, 0, QS_POSTMESSAGE
);
3940 ok(ret
== WAIT_TIMEOUT
, "MsgWaitForMultipleObjects returned %x\n", ret
);
3942 PostMessageA(hwnd
, WM_USER
, 0, 0);
3944 /* new incoming message causes it to become signaled again */
3945 ret
= MsgWaitForMultipleObjects(0, NULL
, FALSE
, 0, QS_POSTMESSAGE
);
3946 ok(ret
== WAIT_OBJECT_0
, "MsgWaitForMultipleObjects returned %x\n", ret
);
3948 ok(PeekMessageW( &msg
, 0, 0, 0, PM_REMOVE
), "PeekMessage should succeed\n");
3949 ok(msg
.message
== WM_USER
, "got %04x instead of WM_USER\n", msg
.message
);
3950 ok(PeekMessageW( &msg
, 0, 0, 0, PM_REMOVE
), "PeekMessage should succeed\n");
3951 ok(msg
.message
== WM_USER
, "got %04x instead of WM_USER\n", msg
.message
);
3954 /* test if we receive the right sequence of messages */
3955 static void test_messages(void)
3957 HWND hwnd
, hparent
, hchild
;
3958 HWND hchild2
, hbutton
;
3965 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW
,
3966 100, 100, 200, 200, 0, 0, 0, NULL
);
3967 ok (hwnd
!= 0, "Failed to create overlapped window\n");
3968 ok_sequence(WmCreateOverlappedSeq
, "CreateWindow:overlapped", FALSE
);
3970 /* test ShowWindow(SW_HIDE) on a newly created invisible window */
3971 ok( ShowWindow(hwnd
, SW_HIDE
) == FALSE
, "ShowWindow: window was visible\n" );
3972 ok_sequence(WmEmptySeq
, "ShowWindow(SW_HIDE):overlapped, invisible", FALSE
);
3974 /* test WM_SETREDRAW on a not visible top level window */
3975 test_WM_SETREDRAW(hwnd
);
3977 SetWindowPos(hwnd
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
);
3978 ok_sequence(WmSWP_ShowOverlappedSeq
, "SetWindowPos:SWP_SHOWWINDOW:overlapped", FALSE
);
3979 ok(IsWindowVisible(hwnd
), "window should be visible at this point\n");
3981 ok(GetActiveWindow() == hwnd
, "window should be active\n");
3982 ok(GetFocus() == hwnd
, "window should have input focus\n");
3983 ShowWindow(hwnd
, SW_HIDE
);
3984 ok_sequence(WmHideOverlappedSeq
, "ShowWindow(SW_HIDE):overlapped", TRUE
);
3986 ShowWindow(hwnd
, SW_SHOW
);
3987 ok_sequence(WmShowOverlappedSeq
, "ShowWindow(SW_SHOW):overlapped", TRUE
);
3989 ShowWindow(hwnd
, SW_HIDE
);
3990 ok_sequence(WmHideOverlappedSeq
, "ShowWindow(SW_HIDE):overlapped", FALSE
);
3992 ShowWindow(hwnd
, SW_SHOWMAXIMIZED
);
3993 ok_sequence(WmShowMaxOverlappedSeq
, "ShowWindow(SW_SHOWMAXIMIZED):overlapped", TRUE
);
3995 ShowWindow(hwnd
, SW_RESTORE
);
3996 /* FIXME: add ok_sequence() here */
3999 ShowWindow(hwnd
, SW_MINIMIZE
);
4000 ok_sequence(WmShowMinOverlappedSeq
, "ShowWindow(SW_SHOWMINIMIZED):overlapped", TRUE
);
4003 ShowWindow(hwnd
, SW_RESTORE
);
4004 /* FIXME: add ok_sequence() here */
4007 ShowWindow(hwnd
, SW_SHOW
);
4008 ok_sequence(WmEmptySeq
, "ShowWindow(SW_SHOW):overlapped already visible", FALSE
);
4010 ok(GetActiveWindow() == hwnd
, "window should be active\n");
4011 ok(GetFocus() == hwnd
, "window should have input focus\n");
4012 SetWindowPos(hwnd
, 0,0,0,0,0, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
);
4013 ok_sequence(WmSWP_HideOverlappedSeq
, "SetWindowPos:SWP_HIDEWINDOW:overlapped", FALSE
);
4014 ok(!IsWindowVisible(hwnd
), "window should not be visible at this point\n");
4015 ok(GetActiveWindow() == hwnd
, "window should still be active\n");
4017 /* test WM_SETREDRAW on a visible top level window */
4018 ShowWindow(hwnd
, SW_SHOW
);
4019 test_WM_SETREDRAW(hwnd
);
4021 trace("testing scroll APIs on a visible top level window %p\n", hwnd
);
4022 test_scroll_messages(hwnd
);
4024 /* test resizing and moving */
4025 SetWindowPos( hwnd
, 0, 0, 0, 300, 300, SWP_NOMOVE
|SWP_NOACTIVATE
);
4026 ok_sequence(WmSWP_ResizeSeq
, "SetWindowPos:Resize", FALSE
);
4029 SetWindowPos( hwnd
, 0, 200, 200, 0, 0, SWP_NOSIZE
|SWP_NOACTIVATE
);
4030 ok_sequence(WmSWP_MoveSeq
, "SetWindowPos:Move", FALSE
);
4033 SetWindowPos( hwnd
, 0, 200, 200, 250, 250, SWP_NOZORDER
);
4034 ok_sequence(WmSWP_ResizeNoZOrder
, "SetWindowPos:WmSWP_ResizeNoZOrder", FALSE
);
4038 /* popups don't get WM_GETMINMAXINFO */
4039 SetWindowLongW( hwnd
, GWL_STYLE
, WS_VISIBLE
|WS_POPUP
);
4040 SetWindowPos( hwnd
, 0, 0, 0, 0, 0, SWP_NOZORDER
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_FRAMECHANGED
);
4042 SetWindowPos( hwnd
, 0, 0, 0, 200, 200, SWP_NOMOVE
|SWP_NOACTIVATE
);
4043 ok_sequence(WmSWP_ResizePopupSeq
, "SetWindowPos:ResizePopup", FALSE
);
4045 DestroyWindow(hwnd
);
4046 ok_sequence(WmDestroyOverlappedSeq
, "DestroyWindow:overlapped", FALSE
);
4048 hparent
= CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
4049 100, 100, 200, 200, 0, 0, 0, NULL
);
4050 ok (hparent
!= 0, "Failed to create parent window\n");
4053 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
| WS_MAXIMIZE
,
4054 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4055 ok (hchild
!= 0, "Failed to create child window\n");
4056 ok_sequence(WmCreateMaximizedChildSeq
, "CreateWindow:maximized child", FALSE
);
4057 DestroyWindow(hchild
);
4060 /* visible child window with a caption */
4061 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child",
4062 WS_CHILD
| WS_VISIBLE
| WS_CAPTION
,
4063 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4064 ok (hchild
!= 0, "Failed to create child window\n");
4065 ok_sequence(WmCreateVisibleChildSeq
, "CreateWindow:visible child", FALSE
);
4067 trace("testing scroll APIs on a visible child window %p\n", hchild
);
4068 test_scroll_messages(hchild
);
4070 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
);
4071 ok_sequence(WmShowChildSeq_4
, "SetWindowPos(SWP_SHOWWINDOW):child with a caption", FALSE
);
4073 DestroyWindow(hchild
);
4076 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
4077 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4078 ok (hchild
!= 0, "Failed to create child window\n");
4079 ok_sequence(WmCreateChildSeq
, "CreateWindow:child", FALSE
);
4081 hchild2
= CreateWindowExA(0, "SimpleWindowClass", "Test child2", WS_CHILD
,
4082 100, 100, 50, 50, hparent
, 0, 0, NULL
);
4083 ok (hchild2
!= 0, "Failed to create child2 window\n");
4086 hbutton
= CreateWindowExA(0, "TestWindowClass", "Test button", WS_CHILD
,
4087 0, 100, 50, 50, hchild
, 0, 0, NULL
);
4088 ok (hbutton
!= 0, "Failed to create button window\n");
4090 /* test WM_SETREDRAW on a not visible child window */
4091 test_WM_SETREDRAW(hchild
);
4093 ShowWindow(hchild
, SW_SHOW
);
4094 ok_sequence(WmShowChildSeq
, "ShowWindow(SW_SHOW):child", FALSE
);
4096 /* check parent messages too */
4097 log_all_parent_messages
++;
4098 ShowWindow(hchild
, SW_HIDE
);
4099 ok_sequence(WmHideChildSeq2
, "ShowWindow(SW_HIDE):child", FALSE
);
4100 log_all_parent_messages
--;
4102 ShowWindow(hchild
, SW_SHOW
);
4103 ok_sequence(WmShowChildSeq
, "ShowWindow(SW_SHOW):child", FALSE
);
4105 ShowWindow(hchild
, SW_HIDE
);
4106 ok_sequence(WmHideChildSeq
, "ShowWindow(SW_HIDE):child", FALSE
);
4108 ShowWindow(hchild
, SW_SHOW
);
4109 ok_sequence(WmShowChildSeq
, "ShowWindow(SW_SHOW):child", FALSE
);
4111 /* test WM_SETREDRAW on a visible child window */
4112 test_WM_SETREDRAW(hchild
);
4114 log_all_parent_messages
++;
4115 MoveWindow(hchild
, 10, 10, 20, 20, TRUE
);
4116 ok_sequence(WmResizingChildWithMoveWindowSeq
, "MoveWindow:child", FALSE
);
4117 log_all_parent_messages
--;
4119 ShowWindow(hchild
, SW_HIDE
);
4121 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
);
4122 ok_sequence(WmShowChildSeq_2
, "SetWindowPos:show_child_2", FALSE
);
4124 ShowWindow(hchild
, SW_HIDE
);
4126 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
);
4127 ok_sequence(WmShowChildSeq_3
, "SetWindowPos:show_child_3", FALSE
);
4129 /* DestroyWindow sequence below expects that a child has focus */
4133 DestroyWindow(hchild
);
4134 ok_sequence(WmDestroyChildSeq
, "DestroyWindow:child", FALSE
);
4135 DestroyWindow(hchild2
);
4136 DestroyWindow(hbutton
);
4139 hchild
= CreateWindowExA(0, "TestWindowClass", "Test Child Popup", WS_CHILD
| WS_POPUP
,
4140 0, 0, 100, 100, hparent
, 0, 0, NULL
);
4141 ok (hchild
!= 0, "Failed to create child popup window\n");
4142 ok_sequence(WmCreateChildPopupSeq
, "CreateWindow:child_popup", FALSE
);
4143 DestroyWindow(hchild
);
4145 /* test what happens to a window which sets WS_VISIBLE in WM_CREATE */
4147 hchild
= CreateWindowExA(0, "TestPopupClass", "Test Popup", WS_POPUP
,
4148 0, 0, 100, 100, hparent
, 0, 0, NULL
);
4149 ok (hchild
!= 0, "Failed to create popup window\n");
4150 ok_sequence(WmCreateInvisiblePopupSeq
, "CreateWindow:invisible_popup", FALSE
);
4151 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
4152 ok(IsWindowVisible(hchild
), "IsWindowVisible() should return TRUE\n");
4154 ShowWindow(hchild
, SW_SHOW
);
4155 ok_sequence(WmEmptySeq
, "ShowWindow:show_visible_popup", FALSE
);
4157 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOZORDER
);
4158 ok_sequence(WmShowVisiblePopupSeq_2
, "SetWindowPos:show_visible_popup_2", FALSE
);
4160 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
);
4161 ok_sequence(WmShowVisiblePopupSeq_3
, "SetWindowPos:show_visible_popup_3", TRUE
);
4162 DestroyWindow(hchild
);
4164 /* this time add WS_VISIBLE for CreateWindowEx, but this fact actually
4165 * changes nothing in message sequences.
4168 hchild
= CreateWindowExA(0, "TestPopupClass", "Test Popup", WS_POPUP
| WS_VISIBLE
,
4169 0, 0, 100, 100, hparent
, 0, 0, NULL
);
4170 ok (hchild
!= 0, "Failed to create popup window\n");
4171 ok_sequence(WmCreateInvisiblePopupSeq
, "CreateWindow:invisible_popup", FALSE
);
4172 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
4173 ok(IsWindowVisible(hchild
), "IsWindowVisible() should return TRUE\n");
4175 ShowWindow(hchild
, SW_SHOW
);
4176 ok_sequence(WmEmptySeq
, "ShowWindow:show_visible_popup", FALSE
);
4178 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOZORDER
);
4179 ok_sequence(WmShowVisiblePopupSeq_2
, "SetWindowPos:show_visible_popup_2", FALSE
);
4180 DestroyWindow(hchild
);
4183 hwnd
= CreateWindowExA(WS_EX_DLGMODALFRAME
, "TestDialogClass", NULL
, WS_VISIBLE
|WS_CAPTION
|WS_SYSMENU
|WS_DLGFRAME
,
4184 0, 0, 100, 100, hparent
, 0, 0, NULL
);
4185 ok(hwnd
!= 0, "Failed to create custom dialog window\n");
4186 ok_sequence(WmCreateCustomDialogSeq
, "CreateCustomDialog", TRUE
);
4189 trace("testing scroll APIs on a visible dialog %p\n", hwnd);
4190 test_scroll_messages(hwnd);
4196 SendMessage(hwnd
, WM_NULL
, 0, 0);
4199 after_end_dialog
= 1;
4200 EndDialog( hwnd
, 0 );
4201 ok_sequence(WmEndCustomDialogSeq
, "EndCustomDialog", FALSE
);
4203 DestroyWindow(hwnd
);
4204 after_end_dialog
= 0;
4207 hwnd
= CreateWindowExA(0, "TestDialogClass", NULL
, WS_POPUP
,
4208 0, 0, 100, 100, 0, 0, GetModuleHandleA(0), NULL
);
4209 ok(hwnd
!= 0, "Failed to create custom dialog window\n");
4211 trace("call ShowWindow(%p, SW_SHOW)\n", hwnd
);
4212 ShowWindow(hwnd
, SW_SHOW
);
4213 ok_sequence(WmShowCustomDialogSeq
, "ShowCustomDialog", TRUE
);
4214 DestroyWindow(hwnd
);
4217 DialogBoxA( 0, "TEST_DIALOG", hparent
, TestModalDlgProcA
);
4218 ok_sequence(WmModalDialogSeq
, "ModalDialog", TRUE
);
4220 DestroyWindow(hparent
);
4223 /* Message sequence for SetMenu */
4224 ok(!DrawMenuBar(hwnd
), "DrawMenuBar should return FALSE for a window without a menu\n");
4225 ok_sequence(WmEmptySeq
, "DrawMenuBar for a window without a menu", FALSE
);
4227 hmenu
= CreateMenu();
4228 ok (hmenu
!= 0, "Failed to create menu\n");
4229 ok (InsertMenuA(hmenu
, -1, MF_BYPOSITION
, 0x1000, "foo"), "InsertMenu failed\n");
4230 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW
,
4231 100, 100, 200, 200, 0, hmenu
, 0, NULL
);
4232 ok_sequence(WmCreateOverlappedSeq
, "CreateWindow:overlapped", FALSE
);
4233 ok (SetMenu(hwnd
, 0), "SetMenu\n");
4234 ok_sequence(WmSetMenuNonVisibleSizeChangeSeq
, "SetMenu:NonVisibleSizeChange", FALSE
);
4235 ok (SetMenu(hwnd
, 0), "SetMenu\n");
4236 ok_sequence(WmSetMenuNonVisibleNoSizeChangeSeq
, "SetMenu:NonVisibleNoSizeChange", FALSE
);
4237 ShowWindow(hwnd
, SW_SHOW
);
4238 UpdateWindow( hwnd
);
4241 ok (SetMenu(hwnd
, 0), "SetMenu\n");
4242 ok_sequence(WmSetMenuVisibleNoSizeChangeSeq
, "SetMenu:VisibleNoSizeChange", FALSE
);
4243 ok (SetMenu(hwnd
, hmenu
), "SetMenu\n");
4244 ok_sequence(WmSetMenuVisibleSizeChangeSeq
, "SetMenu:VisibleSizeChange", FALSE
);
4246 UpdateWindow( hwnd
);
4249 ok(DrawMenuBar(hwnd
), "DrawMenuBar\n");
4251 ok_sequence(WmDrawMenuBarSeq
, "DrawMenuBar", FALSE
);
4253 DestroyWindow(hwnd
);
4256 /* Message sequence for EnableWindow */
4257 hparent
= CreateWindowExA(0, "TestWindowClass", "Test parent", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
4258 100, 100, 200, 200, 0, 0, 0, NULL
);
4259 ok (hparent
!= 0, "Failed to create parent window\n");
4260 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
| WS_VISIBLE
,
4261 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4262 ok (hchild
!= 0, "Failed to create child window\n");
4268 EnableWindow(hparent
, FALSE
);
4269 ok_sequence(WmEnableWindowSeq_1
, "EnableWindow(FALSE)", FALSE
);
4271 EnableWindow(hparent
, TRUE
);
4272 ok_sequence(WmEnableWindowSeq_2
, "EnableWindow(TRUE)", FALSE
);
4277 test_MsgWaitForMultipleObjects(hparent
);
4279 /* the following test causes an exception in user.exe under win9x */
4280 if (!PostMessageW( hparent
, WM_USER
, 0, 0 ))
4282 DestroyWindow(hparent
);
4286 PostMessageW( hparent
, WM_USER
+1, 0, 0 );
4287 /* PeekMessage(NULL) fails, but still removes the message */
4288 SetLastError(0xdeadbeef);
4289 ok( !PeekMessageW( NULL
, 0, 0, 0, PM_REMOVE
), "PeekMessage(NULL) should fail\n" );
4290 ok( GetLastError() == ERROR_NOACCESS
|| /* Win2k */
4291 GetLastError() == 0xdeadbeef, /* NT4 */
4292 "last error is %d\n", GetLastError() );
4293 ok( PeekMessageW( &msg
, 0, 0, 0, PM_REMOVE
), "PeekMessage should succeed\n" );
4294 ok( msg
.message
== WM_USER
+1, "got %x instead of WM_USER+1\n", msg
.message
);
4296 DestroyWindow(hchild
);
4297 DestroyWindow(hparent
);
4300 /* Message sequences for WM_SETICON */
4301 trace("testing WM_SETICON\n");
4302 hwnd
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
4303 CW_USEDEFAULT
, CW_USEDEFAULT
, 300, 300, 0,
4305 ShowWindow(hwnd
, SW_SHOW
);
4309 SendMessage(hwnd
, WM_SETICON
, ICON_SMALL
, (LPARAM
)LoadIcon(0, IDI_APPLICATION
));
4310 ok_sequence(WmSetIcon_1
, "WM_SETICON for shown window with caption", FALSE
);
4312 ShowWindow(hwnd
, SW_HIDE
);
4315 SendMessage(hwnd
, WM_SETICON
, ICON_SMALL
, (LPARAM
)LoadIcon(0, IDI_APPLICATION
));
4316 ok_sequence(WmSetIcon_2
, "WM_SETICON for hidden window with caption", FALSE
);
4317 DestroyWindow(hwnd
);
4320 hwnd
= CreateWindowExA(0, "TestPopupClass", NULL
, WS_POPUP
,
4321 CW_USEDEFAULT
, CW_USEDEFAULT
, 300, 300, 0,
4323 ShowWindow(hwnd
, SW_SHOW
);
4327 SendMessage(hwnd
, WM_SETICON
, ICON_SMALL
, (LPARAM
)LoadIcon(0, IDI_APPLICATION
));
4328 ok_sequence(WmSetIcon_2
, "WM_SETICON for shown window without caption", FALSE
);
4330 ShowWindow(hwnd
, SW_HIDE
);
4333 SendMessage(hwnd
, WM_SETICON
, ICON_SMALL
, (LPARAM
)LoadIcon(0, IDI_APPLICATION
));
4334 ok_sequence(WmSetIcon_2
, "WM_SETICON for hidden window without caption", FALSE
);
4337 res
= SendMessage(hwnd
, 0x3B, 0x8000000b, 0);
4338 ok_sequence(WmInitEndSession
, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x8000000b", TRUE
);
4340 ok(res
== 1, "SendMessage(hwnd, 0x3B, 0x8000000b, 0) should have returned 1 instead of %ld\n", res
);
4341 res
= SendMessage(hwnd
, 0x3B, 0x0000000b, 0);
4342 ok_sequence(WmInitEndSession_2
, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x0000000b", TRUE
);
4344 ok(res
== 1, "SendMessage(hwnd, 0x3B, 0x0000000b, 0) should have returned 1 instead of %ld\n", res
);
4345 res
= SendMessage(hwnd
, 0x3B, 0x0000000f, 0);
4346 ok_sequence(WmInitEndSession_2
, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x0000000f", TRUE
);
4348 ok(res
== 1, "SendMessage(hwnd, 0x3B, 0x0000000f, 0) should have returned 1 instead of %ld\n", res
);
4351 res
= SendMessage(hwnd
, 0x3B, 0x80000008, 0);
4352 ok_sequence(WmInitEndSession_3
, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x80000008", TRUE
);
4354 ok(res
== 2, "SendMessage(hwnd, 0x3B, 0x80000008, 0) should have returned 2 instead of %ld\n", res
);
4355 res
= SendMessage(hwnd
, 0x3B, 0x00000008, 0);
4356 ok_sequence(WmInitEndSession_4
, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x00000008", TRUE
);
4358 ok(res
== 2, "SendMessage(hwnd, 0x3B, 0x00000008, 0) should have returned 2 instead of %ld\n", res
);
4360 res
= SendMessage(hwnd
, 0x3B, 0x80000004, 0);
4361 ok_sequence(WmInitEndSession_3
, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x80000004", TRUE
);
4363 ok(res
== 2, "SendMessage(hwnd, 0x3B, 0x80000004, 0) should have returned 2 instead of %ld\n", res
);
4365 res
= SendMessage(hwnd
, 0x3B, 0x80000001, 0);
4366 ok_sequence(WmInitEndSession_5
, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x80000001", TRUE
);
4368 ok(res
== 2, "SendMessage(hwnd, 0x3B, 0x80000001, 0) should have returned 2 instead of %ld\n", res
);
4370 DestroyWindow(hwnd
);
4374 static void invisible_parent_tests(void)
4376 HWND hparent
, hchild
;
4378 hparent
= CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW
,
4379 100, 100, 200, 200, 0, 0, 0, NULL
);
4380 ok (hparent
!= 0, "Failed to create parent window\n");
4383 /* test showing child with hidden parent */
4385 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
4386 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4387 ok (hchild
!= 0, "Failed to create child window\n");
4388 ok_sequence(WmCreateChildSeq
, "CreateWindow:child", FALSE
);
4390 ShowWindow( hchild
, SW_MINIMIZE
);
4391 ok_sequence(WmShowChildInvisibleParentSeq_1
, "ShowWindow(SW_MINIMIZE) child with invisible parent", FALSE
);
4392 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
4393 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
4398 ShowWindow( hchild
, SW_MINIMIZE
);
4399 ok_sequence(WmShowChildInvisibleParentSeq_1r
, "ShowWindow(SW_MINIMIZE) child with invisible parent", FALSE
);
4401 DestroyWindow(hchild
);
4402 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
4403 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4406 ShowWindow( hchild
, SW_MAXIMIZE
);
4407 ok_sequence(WmShowChildInvisibleParentSeq_2
, "ShowWindow(SW_MAXIMIZE) child with invisible parent", FALSE
);
4408 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
4409 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
4414 ShowWindow( hchild
, SW_MAXIMIZE
);
4415 ok_sequence(WmShowChildInvisibleParentSeq_2r
, "ShowWindow(SW_MAXIMIZE) child with invisible parent", FALSE
);
4417 DestroyWindow(hchild
);
4418 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
4419 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4422 ShowWindow( hchild
, SW_RESTORE
);
4423 ok_sequence(WmShowChildInvisibleParentSeq_5
, "ShowWindow(SW_RESTORE) child with invisible parent", FALSE
);
4424 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
4425 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
4427 DestroyWindow(hchild
);
4428 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
4429 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4432 ShowWindow( hchild
, SW_SHOWMINIMIZED
);
4433 ok_sequence(WmShowChildInvisibleParentSeq_3
, "ShowWindow(SW_SHOWMINIMIZED) child with invisible parent", FALSE
);
4434 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
4435 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
4440 ShowWindow( hchild
, SW_SHOWMINIMIZED
);
4441 ok_sequence(WmShowChildInvisibleParentSeq_3r
, "ShowWindow(SW_SHOWMINIMIZED) child with invisible parent", FALSE
);
4443 DestroyWindow(hchild
);
4444 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
4445 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4448 /* same as ShowWindow( hchild, SW_MAXIMIZE ); */
4449 ShowWindow( hchild
, SW_SHOWMAXIMIZED
);
4450 ok_sequence(WmShowChildInvisibleParentSeq_2
, "ShowWindow(SW_SHOWMAXIMIZED) child with invisible parent", FALSE
);
4451 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
4452 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
4454 DestroyWindow(hchild
);
4455 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
4456 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4459 ShowWindow( hchild
, SW_SHOWMINNOACTIVE
);
4460 ok_sequence(WmShowChildInvisibleParentSeq_4
, "ShowWindow(SW_SHOWMINNOACTIVE) child with invisible parent", FALSE
);
4461 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
4462 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
4467 ShowWindow( hchild
, SW_SHOWMINNOACTIVE
);
4468 ok_sequence(WmShowChildInvisibleParentSeq_4r
, "ShowWindow(SW_SHOWMINNOACTIVE) child with invisible parent", FALSE
);
4470 DestroyWindow(hchild
);
4471 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
4472 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4475 /* FIXME: looks like XP SP2 doesn't know about SW_FORCEMINIMIZE at all */
4476 ShowWindow( hchild
, SW_FORCEMINIMIZE
);
4477 ok_sequence(WmEmptySeq
, "ShowWindow(SW_FORCEMINIMIZE) child with invisible parent", TRUE
);
4479 ok(!(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
), "WS_VISIBLE should be not set\n");
4481 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
4483 DestroyWindow(hchild
);
4484 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
4485 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4488 ShowWindow( hchild
, SW_SHOWNA
);
4489 ok_sequence(WmShowChildInvisibleParentSeq_5
, "ShowWindow(SW_SHOWNA) child with invisible parent", FALSE
);
4490 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
4491 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
4496 ShowWindow( hchild
, SW_SHOWNA
);
4497 ok_sequence(WmShowChildInvisibleParentSeq_5
, "ShowWindow(SW_SHOWNA) child with invisible parent", FALSE
);
4499 DestroyWindow(hchild
);
4500 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
4501 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4504 ShowWindow( hchild
, SW_SHOW
);
4505 ok_sequence(WmShowChildInvisibleParentSeq_5
, "ShowWindow(SW_SHOW) child with invisible parent", FALSE
);
4506 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
4507 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
4512 ShowWindow( hchild
, SW_SHOW
);
4513 ok_sequence(WmEmptySeq
, "ShowWindow(SW_SHOW) child with invisible parent", FALSE
);
4515 ShowWindow( hchild
, SW_HIDE
);
4516 ok_sequence(WmHideChildInvisibleParentSeq
, "ShowWindow:hide child with invisible parent", FALSE
);
4517 ok(!(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
), "WS_VISIBLE should be not set\n");
4518 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
4520 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOZORDER
);
4521 ok_sequence(WmShowChildInvisibleParentSeq_6
, "SetWindowPos:show child with invisible parent", FALSE
);
4522 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
4523 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
4525 SetWindowPos(hchild
, 0,0,0,0,0, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOZORDER
);
4526 ok_sequence(WmHideChildInvisibleParentSeq_2
, "SetWindowPos:hide child with invisible parent", FALSE
);
4527 ok(!(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
), "WS_VISIBLE should not be set\n");
4528 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
4530 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOZORDER
);
4532 DestroyWindow(hchild
);
4533 ok_sequence(WmDestroyInvisibleChildSeq
, "DestroyInvisibleChildSeq", FALSE
);
4535 DestroyWindow(hparent
);
4539 /****************** button message test *************************/
4540 static const struct message WmSetFocusButtonSeq
[] =
4542 { HCBT_SETFOCUS
, hook
},
4543 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
4544 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
4545 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
4546 { WM_SETFOCUS
, sent
|wparam
, 0 },
4547 { WM_CTLCOLORBTN
, sent
|defwinproc
},
4550 static const struct message WmKillFocusButtonSeq
[] =
4552 { HCBT_SETFOCUS
, hook
},
4553 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
4554 { WM_KILLFOCUS
, sent
|wparam
, 0 },
4555 { WM_CTLCOLORBTN
, sent
|defwinproc
},
4556 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
4557 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 1 },
4560 static const struct message WmSetFocusStaticSeq
[] =
4562 { HCBT_SETFOCUS
, hook
},
4563 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
4564 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
4565 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
4566 { WM_SETFOCUS
, sent
|wparam
, 0 },
4567 { WM_CTLCOLORSTATIC
, sent
|defwinproc
},
4570 static const struct message WmKillFocusStaticSeq
[] =
4572 { HCBT_SETFOCUS
, hook
},
4573 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
4574 { WM_KILLFOCUS
, sent
|wparam
, 0 },
4575 { WM_CTLCOLORSTATIC
, sent
|defwinproc
},
4576 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
4577 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 1 },
4580 static const struct message WmLButtonDownSeq
[] =
4582 { WM_LBUTTONDOWN
, sent
|wparam
|lparam
, 0, 0 },
4583 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
4584 { HCBT_SETFOCUS
, hook
},
4585 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
4586 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
4587 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
4588 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
4589 { WM_CTLCOLORBTN
, sent
|defwinproc
},
4590 { BM_SETSTATE
, sent
|wparam
|defwinproc
, TRUE
},
4591 { WM_CTLCOLORBTN
, sent
|defwinproc
},
4592 { EVENT_OBJECT_STATECHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
4595 static const struct message WmLButtonUpSeq
[] =
4597 { WM_LBUTTONUP
, sent
|wparam
|lparam
, 0, 0 },
4598 { BM_SETSTATE
, sent
|wparam
|defwinproc
, FALSE
},
4599 { WM_CTLCOLORBTN
, sent
|defwinproc
},
4600 { EVENT_OBJECT_STATECHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
4601 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, 0, 0 },
4602 { WM_CAPTURECHANGED
, sent
|wparam
|defwinproc
, 0 },
4605 static const struct message WmSetFontButtonSeq
[] =
4607 { WM_SETFONT
, sent
},
4609 { WM_ERASEBKGND
, sent
|defwinproc
|optional
},
4610 { WM_CTLCOLORBTN
, sent
|defwinproc
},
4614 static WNDPROC old_button_proc
;
4616 static LRESULT CALLBACK
button_hook_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
4618 static long defwndproc_counter
= 0;
4622 trace("button: %p, %04x, %08lx, %08lx\n", hwnd
, message
, wParam
, lParam
);
4624 /* explicitly ignore WM_GETICON message */
4625 if (message
== WM_GETICON
) return 0;
4627 msg
.message
= message
;
4628 msg
.flags
= sent
|wparam
|lparam
;
4629 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
4630 msg
.wParam
= wParam
;
4631 msg
.lParam
= lParam
;
4634 if (message
== BM_SETSTATE
)
4635 ok(GetCapture() == hwnd
, "GetCapture() = %p\n", GetCapture());
4637 defwndproc_counter
++;
4638 ret
= CallWindowProcA(old_button_proc
, hwnd
, message
, wParam
, lParam
);
4639 defwndproc_counter
--;
4644 static void subclass_button(void)
4648 if (!GetClassInfoA(0, "button", &cls
)) assert(0);
4650 old_button_proc
= cls
.lpfnWndProc
;
4652 cls
.hInstance
= GetModuleHandle(0);
4653 cls
.lpfnWndProc
= button_hook_proc
;
4654 cls
.lpszClassName
= "my_button_class";
4655 UnregisterClass(cls
.lpszClassName
, cls
.hInstance
);
4656 if (!RegisterClassA(&cls
)) assert(0);
4659 static void test_button_messages(void)
4665 const struct message
*setfocus
;
4666 const struct message
*killfocus
;
4668 { BS_PUSHBUTTON
, DLGC_BUTTON
| DLGC_UNDEFPUSHBUTTON
,
4669 WmSetFocusButtonSeq
, WmKillFocusButtonSeq
},
4670 { BS_DEFPUSHBUTTON
, DLGC_BUTTON
| DLGC_DEFPUSHBUTTON
,
4671 WmSetFocusButtonSeq
, WmKillFocusButtonSeq
},
4672 { BS_CHECKBOX
, DLGC_BUTTON
,
4673 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
},
4674 { BS_AUTOCHECKBOX
, DLGC_BUTTON
,
4675 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
},
4676 { BS_RADIOBUTTON
, DLGC_BUTTON
| DLGC_RADIOBUTTON
,
4677 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
},
4678 { BS_3STATE
, DLGC_BUTTON
,
4679 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
},
4680 { BS_AUTO3STATE
, DLGC_BUTTON
,
4681 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
},
4682 { BS_GROUPBOX
, DLGC_STATIC
,
4683 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
},
4684 { BS_USERBUTTON
, DLGC_BUTTON
| DLGC_UNDEFPUSHBUTTON
,
4685 WmSetFocusButtonSeq
, WmKillFocusButtonSeq
},
4686 { BS_AUTORADIOBUTTON
, DLGC_BUTTON
| DLGC_RADIOBUTTON
,
4687 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
},
4688 { BS_OWNERDRAW
, DLGC_BUTTON
,
4689 WmSetFocusButtonSeq
, WmKillFocusButtonSeq
}
4698 for (i
= 0; i
< sizeof(button
)/sizeof(button
[0]); i
++)
4700 hwnd
= CreateWindowExA(0, "my_button_class", "test", button
[i
].style
| WS_POPUP
,
4701 0, 0, 50, 14, 0, 0, 0, NULL
);
4702 ok(hwnd
!= 0, "Failed to create button window\n");
4704 dlg_code
= SendMessageA(hwnd
, WM_GETDLGCODE
, 0, 0);
4705 ok(dlg_code
== button
[i
].dlg_code
, "%u: wrong dlg_code %08x\n", i
, dlg_code
);
4707 ShowWindow(hwnd
, SW_SHOW
);
4712 trace("button style %08x\n", button
[i
].style
);
4714 ok_sequence(button
[i
].setfocus
, "SetFocus(hwnd) on a button", FALSE
);
4717 ok_sequence(button
[i
].killfocus
, "SetFocus(0) on a button", FALSE
);
4719 DestroyWindow(hwnd
);
4722 hwnd
= CreateWindowExA(0, "my_button_class", "test", BS_PUSHBUTTON
| WS_POPUP
| WS_VISIBLE
,
4723 0, 0, 50, 14, 0, 0, 0, NULL
);
4724 ok(hwnd
!= 0, "Failed to create button window\n");
4730 SendMessageA(hwnd
, WM_LBUTTONDOWN
, 0, 0);
4731 ok_sequence(WmLButtonDownSeq
, "WM_LBUTTONDOWN on a button", FALSE
);
4733 SendMessageA(hwnd
, WM_LBUTTONUP
, 0, 0);
4734 ok_sequence(WmLButtonUpSeq
, "WM_LBUTTONUP on a button", FALSE
);
4737 zfont
= (HFONT
)GetStockObject(SYSTEM_FONT
);
4738 SendMessageA(hwnd
, WM_SETFONT
, (WPARAM
)zfont
, TRUE
);
4740 ok_sequence(WmSetFontButtonSeq
, "WM_SETFONT on a button", FALSE
);
4742 DestroyWindow(hwnd
);
4745 /****************** static message test *************************/
4746 static const struct message WmSetFontStaticSeq
[] =
4748 { WM_SETFONT
, sent
},
4749 { WM_PAINT
, sent
|defwinproc
},
4750 { WM_ERASEBKGND
, sent
|defwinproc
|optional
},
4751 { WM_CTLCOLORSTATIC
, sent
|defwinproc
},
4755 static WNDPROC old_static_proc
;
4757 static LRESULT CALLBACK
static_hook_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
4759 static long defwndproc_counter
= 0;
4763 trace("static: %p, %04x, %08lx, %08lx\n", hwnd
, message
, wParam
, lParam
);
4765 /* explicitly ignore WM_GETICON message */
4766 if (message
== WM_GETICON
) return 0;
4768 msg
.message
= message
;
4769 msg
.flags
= sent
|wparam
|lparam
;
4770 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
4771 msg
.wParam
= wParam
;
4772 msg
.lParam
= lParam
;
4776 defwndproc_counter
++;
4777 ret
= CallWindowProcA(old_static_proc
, hwnd
, message
, wParam
, lParam
);
4778 defwndproc_counter
--;
4783 static void subclass_static(void)
4787 if (!GetClassInfoA(0, "static", &cls
)) assert(0);
4789 old_static_proc
= cls
.lpfnWndProc
;
4791 cls
.hInstance
= GetModuleHandle(0);
4792 cls
.lpfnWndProc
= static_hook_proc
;
4793 cls
.lpszClassName
= "my_static_class";
4794 UnregisterClass(cls
.lpszClassName
, cls
.hInstance
);
4795 if (!RegisterClassA(&cls
)) assert(0);
4798 static void test_static_messages(void)
4800 /* FIXME: make as comprehensive as the button message test */
4805 const struct message
*setfont
;
4807 { SS_LEFT
, DLGC_STATIC
,
4808 WmSetFontStaticSeq
}
4816 for (i
= 0; i
< sizeof(static_ctrl
)/sizeof(static_ctrl
[0]); i
++)
4818 hwnd
= CreateWindowExA(0, "my_static_class", "test", static_ctrl
[i
].style
| WS_POPUP
,
4819 0, 0, 50, 14, 0, 0, 0, NULL
);
4820 ok(hwnd
!= 0, "Failed to create static window\n");
4822 dlg_code
= SendMessageA(hwnd
, WM_GETDLGCODE
, 0, 0);
4823 ok(dlg_code
== static_ctrl
[i
].dlg_code
, "%u: wrong dlg_code %08x\n", i
, dlg_code
);
4825 ShowWindow(hwnd
, SW_SHOW
);
4830 trace("static style %08x\n", static_ctrl
[i
].style
);
4831 SendMessage(hwnd
, WM_SETFONT
, (WPARAM
)GetStockObject(DEFAULT_GUI_FONT
), TRUE
);
4832 ok_sequence(static_ctrl
[i
].setfont
, "WM_SETFONT on a static", FALSE
);
4834 DestroyWindow(hwnd
);
4838 /************* painting message test ********************/
4840 void dump_region(HRGN hrgn
)
4843 RGNDATA
*data
= NULL
;
4848 printf( "null region\n" );
4851 if (!(size
= GetRegionData( hrgn
, 0, NULL
))) return;
4852 if (!(data
= HeapAlloc( GetProcessHeap(), 0, size
))) return;
4853 GetRegionData( hrgn
, size
, data
);
4854 printf("%d rects:", data
->rdh
.nCount
);
4855 for (i
= 0, rect
= (RECT
*)data
->Buffer
; i
< data
->rdh
.nCount
; i
++, rect
++)
4856 printf( " (%d,%d)-(%d,%d)", rect
->left
, rect
->top
, rect
->right
, rect
->bottom
);
4858 HeapFree( GetProcessHeap(), 0, data
);
4861 static void check_update_rgn( HWND hwnd
, HRGN hrgn
)
4865 HRGN tmp
= CreateRectRgn( 0, 0, 0, 0 );
4866 HRGN update
= CreateRectRgn( 0, 0, 0, 0 );
4868 ret
= GetUpdateRgn( hwnd
, update
, FALSE
);
4869 ok( ret
!= ERROR
, "GetUpdateRgn failed\n" );
4870 if (ret
== NULLREGION
)
4872 ok( !hrgn
, "Update region shouldn't be empty\n" );
4876 if (CombineRgn( tmp
, hrgn
, update
, RGN_XOR
) != NULLREGION
)
4878 ok( 0, "Regions are different\n" );
4879 if (winetest_debug
> 0)
4881 printf( "Update region: " );
4882 dump_region( update
);
4883 printf( "Wanted region: " );
4884 dump_region( hrgn
);
4888 GetRgnBox( update
, &r1
);
4889 GetUpdateRect( hwnd
, &r2
, FALSE
);
4890 ok( r1
.left
== r2
.left
&& r1
.top
== r2
.top
&& r1
.right
== r2
.right
&& r1
.bottom
== r2
.bottom
,
4891 "Rectangles are different: %d,%d-%d,%d / %d,%d-%d,%d\n",
4892 r1
.left
, r1
.top
, r1
.right
, r1
.bottom
, r2
.left
, r2
.top
, r2
.right
, r2
.bottom
);
4894 DeleteObject( tmp
);
4895 DeleteObject( update
);
4898 static const struct message WmInvalidateRgn
[] = {
4899 { WM_NCPAINT
, sent
},
4900 { WM_GETTEXT
, sent
|defwinproc
|optional
},
4904 static const struct message WmGetUpdateRect
[] = {
4905 { WM_NCPAINT
, sent
},
4906 { WM_GETTEXT
, sent
|defwinproc
|optional
},
4911 static const struct message WmInvalidateFull
[] = {
4912 { WM_NCPAINT
, sent
|wparam
, 1 },
4913 { WM_GETTEXT
, sent
|defwinproc
|optional
},
4917 static const struct message WmInvalidateErase
[] = {
4918 { WM_NCPAINT
, sent
|wparam
, 1 },
4919 { WM_GETTEXT
, sent
|defwinproc
|optional
},
4920 { WM_ERASEBKGND
, sent
},
4924 static const struct message WmInvalidatePaint
[] = {
4926 { WM_NCPAINT
, sent
|wparam
|beginpaint
, 1 },
4927 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
4931 static const struct message WmInvalidateErasePaint
[] = {
4933 { WM_NCPAINT
, sent
|wparam
|beginpaint
, 1 },
4934 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
4935 { WM_ERASEBKGND
, sent
|beginpaint
},
4939 static const struct message WmInvalidateErasePaint2
[] = {
4941 { WM_NCPAINT
, sent
|beginpaint
},
4942 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
4943 { WM_ERASEBKGND
, sent
|beginpaint
},
4947 static const struct message WmErase
[] = {
4948 { WM_ERASEBKGND
, sent
},
4952 static const struct message WmPaint
[] = {
4957 static const struct message WmParentOnlyPaint
[] = {
4958 { WM_PAINT
, sent
|parent
},
4962 static const struct message WmInvalidateParent
[] = {
4963 { WM_NCPAINT
, sent
|parent
},
4964 { WM_GETTEXT
, sent
|defwinproc
|parent
|optional
},
4965 { WM_ERASEBKGND
, sent
|parent
},
4969 static const struct message WmInvalidateParentChild
[] = {
4970 { WM_NCPAINT
, sent
|parent
},
4971 { WM_GETTEXT
, sent
|defwinproc
|parent
|optional
},
4972 { WM_ERASEBKGND
, sent
|parent
},
4973 { WM_NCPAINT
, sent
},
4974 { WM_GETTEXT
, sent
|defwinproc
|optional
},
4975 { WM_ERASEBKGND
, sent
},
4979 static const struct message WmInvalidateParentChild2
[] = {
4980 { WM_ERASEBKGND
, sent
|parent
},
4981 { WM_NCPAINT
, sent
},
4982 { WM_GETTEXT
, sent
|defwinproc
|optional
},
4983 { WM_ERASEBKGND
, sent
},
4987 static const struct message WmParentPaint
[] = {
4988 { WM_PAINT
, sent
|parent
},
4993 static const struct message WmParentPaintNc
[] = {
4994 { WM_PAINT
, sent
|parent
},
4996 { WM_NCPAINT
, sent
|beginpaint
},
4997 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
4998 { WM_ERASEBKGND
, sent
|beginpaint
},
5002 static const struct message WmChildPaintNc
[] = {
5004 { WM_NCPAINT
, sent
|beginpaint
},
5005 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
5006 { WM_ERASEBKGND
, sent
|beginpaint
},
5010 static const struct message WmParentErasePaint
[] = {
5011 { WM_PAINT
, sent
|parent
},
5012 { WM_NCPAINT
, sent
|parent
|beginpaint
},
5013 { WM_GETTEXT
, sent
|parent
|beginpaint
|defwinproc
|optional
},
5014 { WM_ERASEBKGND
, sent
|parent
|beginpaint
},
5016 { WM_NCPAINT
, sent
|beginpaint
},
5017 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
5018 { WM_ERASEBKGND
, sent
|beginpaint
},
5022 static const struct message WmParentOnlyNcPaint
[] = {
5023 { WM_PAINT
, sent
|parent
},
5024 { WM_NCPAINT
, sent
|parent
|beginpaint
},
5025 { WM_GETTEXT
, sent
|parent
|beginpaint
|defwinproc
|optional
},
5029 static const struct message WmSetParentStyle
[] = {
5030 { WM_STYLECHANGING
, sent
|parent
},
5031 { WM_STYLECHANGED
, sent
|parent
},
5035 static void test_paint_messages(void)
5041 HWND hparent
, hchild
;
5042 HRGN hrgn
= CreateRectRgn( 0, 0, 0, 0 );
5043 HRGN hrgn2
= CreateRectRgn( 0, 0, 0, 0 );
5044 HWND hwnd
= CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW
,
5045 100, 100, 200, 200, 0, 0, 0, NULL
);
5046 ok (hwnd
!= 0, "Failed to create overlapped window\n");
5048 ShowWindow( hwnd
, SW_SHOW
);
5049 UpdateWindow( hwnd
);
5053 check_update_rgn( hwnd
, 0 );
5054 SetRectRgn( hrgn
, 10, 10, 20, 20 );
5055 ret
= RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
);
5056 ok(ret
, "RedrawWindow returned %d instead of TRUE\n", ret
);
5057 check_update_rgn( hwnd
, hrgn
);
5058 SetRectRgn( hrgn2
, 20, 20, 30, 30 );
5059 ret
= RedrawWindow( hwnd
, NULL
, hrgn2
, RDW_INVALIDATE
);
5060 ok(ret
, "RedrawWindow returned %d instead of TRUE\n", ret
);
5061 CombineRgn( hrgn
, hrgn
, hrgn2
, RGN_OR
);
5062 check_update_rgn( hwnd
, hrgn
);
5063 /* validate everything */
5064 ret
= RedrawWindow( hwnd
, NULL
, NULL
, RDW_VALIDATE
);
5065 ok(ret
, "RedrawWindow returned %d instead of TRUE\n", ret
);
5066 check_update_rgn( hwnd
, 0 );
5068 /* test empty region */
5069 SetRectRgn( hrgn
, 10, 10, 10, 15 );
5070 ret
= RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
);
5071 ok(ret
, "RedrawWindow returned %d instead of TRUE\n", ret
);
5072 check_update_rgn( hwnd
, 0 );
5073 /* test empty rect */
5074 SetRect( &rect
, 10, 10, 10, 15 );
5075 ret
= RedrawWindow( hwnd
, &rect
, NULL
, RDW_INVALIDATE
);
5076 ok(ret
, "RedrawWindow returned %d instead of TRUE\n", ret
);
5077 check_update_rgn( hwnd
, 0 );
5079 /* flush pending messages */
5083 GetClientRect( hwnd
, &rect
);
5084 SetRectRgn( hrgn
, 0, 0, rect
.right
- rect
.left
, rect
.bottom
- rect
.top
);
5085 /* MSDN: if hwnd parameter is NULL, InvalidateRect invalidates and redraws
5086 * all windows and sends WM_ERASEBKGND and WM_NCPAINT.
5088 trace("testing InvalidateRect(0, NULL, FALSE)\n");
5089 SetRectEmpty( &rect
);
5090 ok(InvalidateRect(0, &rect
, FALSE
), "InvalidateRect(0, &rc, FALSE) should fail\n");
5091 check_update_rgn( hwnd
, hrgn
);
5092 ok_sequence( WmInvalidateErase
, "InvalidateErase", FALSE
);
5094 ok_sequence( WmPaint
, "Paint", FALSE
);
5095 RedrawWindow( hwnd
, NULL
, NULL
, RDW_VALIDATE
);
5096 check_update_rgn( hwnd
, 0 );
5098 /* MSDN: if hwnd parameter is NULL, ValidateRect invalidates and redraws
5099 * all windows and sends WM_ERASEBKGND and WM_NCPAINT.
5101 trace("testing ValidateRect(0, NULL)\n");
5102 SetRectEmpty( &rect
);
5103 ok(ValidateRect(0, &rect
), "ValidateRect(0, &rc) should not fail\n");
5104 check_update_rgn( hwnd
, hrgn
);
5105 ok_sequence( WmInvalidateErase
, "InvalidateErase", FALSE
);
5107 ok_sequence( WmPaint
, "Paint", FALSE
);
5108 RedrawWindow( hwnd
, NULL
, NULL
, RDW_VALIDATE
);
5109 check_update_rgn( hwnd
, 0 );
5111 trace("testing InvalidateRgn(0, NULL, FALSE)\n");
5112 SetLastError(0xdeadbeef);
5113 ok(!InvalidateRgn(0, NULL
, FALSE
), "InvalidateRgn(0, NULL, FALSE) should fail\n");
5114 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
, "wrong error code %d\n", GetLastError());
5115 check_update_rgn( hwnd
, 0 );
5117 ok_sequence( WmEmptySeq
, "WmEmptySeq", FALSE
);
5119 trace("testing ValidateRgn(0, NULL)\n");
5120 SetLastError(0xdeadbeef);
5121 ok(!ValidateRgn(0, NULL
), "ValidateRgn(0, NULL) should fail\n");
5122 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
, "wrong error code %d\n", GetLastError());
5123 check_update_rgn( hwnd
, 0 );
5125 ok_sequence( WmEmptySeq
, "WmEmptySeq", FALSE
);
5127 /* now with frame */
5128 SetRectRgn( hrgn
, -5, -5, 20, 20 );
5130 /* flush pending messages */
5133 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_FRAME
);
5134 ok_sequence( WmEmptySeq
, "EmptySeq", FALSE
);
5136 SetRectRgn( hrgn
, 0, 0, 20, 20 ); /* GetUpdateRgn clips to client area */
5137 check_update_rgn( hwnd
, hrgn
);
5140 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASENOW
);
5141 ok_sequence( WmInvalidateRgn
, "InvalidateRgn", FALSE
);
5144 RedrawWindow( hwnd
, NULL
, NULL
, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASENOW
);
5145 ok_sequence( WmInvalidateFull
, "InvalidateFull", FALSE
);
5147 GetClientRect( hwnd
, &rect
);
5148 SetRectRgn( hrgn
, rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
5149 check_update_rgn( hwnd
, hrgn
);
5152 RedrawWindow( hwnd
, NULL
, NULL
, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASE
| RDW_ERASENOW
);
5153 ok_sequence( WmInvalidateErase
, "InvalidateErase", FALSE
);
5156 RedrawWindow( hwnd
, NULL
, NULL
, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASENOW
| RDW_UPDATENOW
);
5157 ok_sequence( WmInvalidatePaint
, "InvalidatePaint", FALSE
);
5158 check_update_rgn( hwnd
, 0 );
5161 RedrawWindow( hwnd
, NULL
, NULL
, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASE
| RDW_UPDATENOW
);
5162 ok_sequence( WmInvalidateErasePaint
, "InvalidateErasePaint", FALSE
);
5163 check_update_rgn( hwnd
, 0 );
5166 SetRectRgn( hrgn
, 0, 0, 100, 100 );
5167 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
);
5168 SetRectRgn( hrgn
, 0, 0, 50, 100 );
5169 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_VALIDATE
);
5170 SetRectRgn( hrgn
, 50, 0, 100, 100 );
5171 check_update_rgn( hwnd
, hrgn
);
5172 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_VALIDATE
| RDW_ERASENOW
);
5173 ok_sequence( WmEmptySeq
, "EmptySeq", FALSE
); /* must not generate messages, everything is valid */
5174 check_update_rgn( hwnd
, 0 );
5177 SetRectRgn( hrgn
, 0, 0, 100, 100 );
5178 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_ERASE
);
5179 SetRectRgn( hrgn
, 0, 0, 100, 50 );
5180 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_VALIDATE
| RDW_ERASENOW
);
5181 ok_sequence( WmErase
, "Erase", FALSE
);
5182 SetRectRgn( hrgn
, 0, 50, 100, 100 );
5183 check_update_rgn( hwnd
, hrgn
);
5186 SetRectRgn( hrgn
, 0, 0, 100, 100 );
5187 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_ERASE
);
5188 SetRectRgn( hrgn
, 0, 0, 50, 50 );
5189 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_VALIDATE
| RDW_NOERASE
| RDW_UPDATENOW
);
5190 ok_sequence( WmPaint
, "Paint", FALSE
);
5193 SetRectRgn( hrgn
, -4, -4, -2, -2 );
5194 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_FRAME
);
5195 SetRectRgn( hrgn
, -200, -200, -198, -198 );
5196 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_VALIDATE
| RDW_NOFRAME
| RDW_ERASENOW
);
5197 ok_sequence( WmEmptySeq
, "EmptySeq", FALSE
);
5200 SetRectRgn( hrgn
, -4, -4, -2, -2 );
5201 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_FRAME
);
5202 SetRectRgn( hrgn
, -4, -4, -3, -3 );
5203 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_VALIDATE
| RDW_NOFRAME
);
5204 SetRectRgn( hrgn
, 0, 0, 1, 1 );
5205 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_UPDATENOW
);
5206 ok_sequence( WmPaint
, "Paint", FALSE
);
5209 SetRectRgn( hrgn
, -4, -4, -1, -1 );
5210 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_FRAME
);
5211 RedrawWindow( hwnd
, NULL
, 0, RDW_ERASENOW
);
5212 /* make sure no WM_PAINT was generated */
5214 ok_sequence( WmInvalidateRgn
, "InvalidateRgn", FALSE
);
5217 SetRectRgn( hrgn
, -4, -4, -1, -1 );
5218 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_FRAME
);
5219 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
))
5221 if (msg
.hwnd
== hwnd
&& msg
.message
== WM_PAINT
)
5223 /* GetUpdateRgn must return empty region since only nonclient area is invalidated */
5224 INT ret
= GetUpdateRgn( hwnd
, hrgn
, FALSE
);
5225 ok( ret
== NULLREGION
, "Invalid GetUpdateRgn result %d\n", ret
);
5226 ret
= GetUpdateRect( hwnd
, &rect
, FALSE
);
5227 ok( ret
, "Invalid GetUpdateRect result %d\n", ret
);
5228 /* this will send WM_NCPAINT and validate the non client area */
5229 ret
= GetUpdateRect( hwnd
, &rect
, TRUE
);
5230 ok( !ret
, "Invalid GetUpdateRect result %d\n", ret
);
5232 DispatchMessage( &msg
);
5234 ok_sequence( WmGetUpdateRect
, "GetUpdateRect", FALSE
);
5236 DestroyWindow( hwnd
);
5238 /* now test with a child window */
5240 hparent
= CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW
,
5241 100, 100, 200, 200, 0, 0, 0, NULL
);
5242 ok (hparent
!= 0, "Failed to create parent window\n");
5244 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
| WS_VISIBLE
| WS_BORDER
,
5245 10, 10, 100, 100, hparent
, 0, 0, NULL
);
5246 ok (hchild
!= 0, "Failed to create child window\n");
5248 ShowWindow( hparent
, SW_SHOW
);
5249 UpdateWindow( hparent
);
5250 UpdateWindow( hchild
);
5253 log_all_parent_messages
++;
5255 SetRect( &rect
, 0, 0, 50, 50 );
5256 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
5257 RedrawWindow( hparent
, NULL
, 0, RDW_ERASENOW
| RDW_ALLCHILDREN
);
5258 ok_sequence( WmInvalidateParentChild
, "InvalidateParentChild", FALSE
);
5260 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
5262 MapWindowPoints( hchild
, hparent
, &pt
, 1 );
5263 SetRectRgn( hrgn
, 0, 0, 50 - pt
.x
, 50 - pt
.y
);
5264 check_update_rgn( hchild
, hrgn
);
5265 SetRectRgn( hrgn
, 0, 0, 50, 50 );
5266 check_update_rgn( hparent
, hrgn
);
5267 RedrawWindow( hparent
, NULL
, 0, RDW_ERASENOW
);
5268 ok_sequence( WmInvalidateParent
, "InvalidateParent", FALSE
);
5269 RedrawWindow( hchild
, NULL
, 0, RDW_ERASENOW
);
5270 ok_sequence( WmEmptySeq
, "EraseNow child", FALSE
);
5273 ok_sequence( WmParentPaintNc
, "WmParentPaintNc", FALSE
);
5275 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
| RDW_ALLCHILDREN
);
5276 RedrawWindow( hparent
, NULL
, 0, RDW_ERASENOW
);
5277 ok_sequence( WmInvalidateParent
, "InvalidateParent2", FALSE
);
5278 RedrawWindow( hchild
, NULL
, 0, RDW_ERASENOW
);
5279 ok_sequence( WmEmptySeq
, "EraseNow child", FALSE
);
5281 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
);
5282 RedrawWindow( hparent
, NULL
, 0, RDW_ERASENOW
| RDW_ALLCHILDREN
);
5283 ok_sequence( WmInvalidateParentChild2
, "InvalidateParentChild2", FALSE
);
5285 SetWindowLong( hparent
, GWL_STYLE
, GetWindowLong(hparent
,GWL_STYLE
) | WS_CLIPCHILDREN
);
5287 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
| RDW_ALLCHILDREN
);
5288 RedrawWindow( hparent
, NULL
, 0, RDW_ERASENOW
);
5289 ok_sequence( WmInvalidateParentChild
, "InvalidateParentChild3", FALSE
);
5291 /* flush all paint messages */
5295 /* RDW_UPDATENOW on child with WS_CLIPCHILDREN doesn't change corresponding parent area */
5296 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
| RDW_ALLCHILDREN
);
5297 SetRectRgn( hrgn
, 0, 0, 50, 50 );
5298 check_update_rgn( hparent
, hrgn
);
5299 RedrawWindow( hchild
, NULL
, 0, RDW_UPDATENOW
);
5300 ok_sequence( WmInvalidateErasePaint2
, "WmInvalidateErasePaint2", FALSE
);
5301 SetRectRgn( hrgn
, 0, 0, 50, 50 );
5302 check_update_rgn( hparent
, hrgn
);
5304 /* flush all paint messages */
5306 SetWindowLong( hparent
, GWL_STYLE
, GetWindowLong(hparent
,GWL_STYLE
) & ~WS_CLIPCHILDREN
);
5309 /* RDW_UPDATENOW on child without WS_CLIPCHILDREN will validate corresponding parent area */
5310 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
5311 SetRectRgn( hrgn
, 0, 0, 50, 50 );
5312 check_update_rgn( hparent
, hrgn
);
5313 RedrawWindow( hchild
, NULL
, 0, RDW_UPDATENOW
);
5314 ok_sequence( WmInvalidateErasePaint2
, "WmInvalidateErasePaint2", FALSE
);
5315 SetRectRgn( hrgn2
, 10, 10, 50, 50 );
5316 CombineRgn( hrgn
, hrgn
, hrgn2
, RGN_DIFF
);
5317 check_update_rgn( hparent
, hrgn
);
5318 /* flush all paint messages */
5322 /* same as above but parent gets completely validated */
5323 SetRect( &rect
, 20, 20, 30, 30 );
5324 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
5325 SetRectRgn( hrgn
, 20, 20, 30, 30 );
5326 check_update_rgn( hparent
, hrgn
);
5327 RedrawWindow( hchild
, NULL
, 0, RDW_UPDATENOW
);
5328 ok_sequence( WmInvalidateErasePaint2
, "WmInvalidateErasePaint2", FALSE
);
5329 check_update_rgn( hparent
, 0 ); /* no update region */
5331 ok_sequence( WmEmptySeq
, "WmEmpty", FALSE
); /* and no paint messages */
5333 /* make sure RDW_VALIDATE on child doesn't have the same effect */
5335 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
5336 SetRectRgn( hrgn
, 20, 20, 30, 30 );
5337 check_update_rgn( hparent
, hrgn
);
5338 RedrawWindow( hchild
, NULL
, 0, RDW_VALIDATE
| RDW_NOERASE
);
5339 SetRectRgn( hrgn
, 20, 20, 30, 30 );
5340 check_update_rgn( hparent
, hrgn
);
5342 /* same as above but normal WM_PAINT doesn't validate parent */
5344 SetRect( &rect
, 20, 20, 30, 30 );
5345 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
5346 SetRectRgn( hrgn
, 20, 20, 30, 30 );
5347 check_update_rgn( hparent
, hrgn
);
5348 /* no WM_PAINT in child while parent still pending */
5349 while (PeekMessage( &msg
, hchild
, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
5350 ok_sequence( WmEmptySeq
, "No WM_PAINT", FALSE
);
5351 while (PeekMessage( &msg
, hparent
, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
5352 ok_sequence( WmParentErasePaint
, "WmParentErasePaint", FALSE
);
5355 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
5356 /* no WM_PAINT in child while parent still pending */
5357 while (PeekMessage( &msg
, hchild
, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
5358 ok_sequence( WmEmptySeq
, "No WM_PAINT", FALSE
);
5359 RedrawWindow( hparent
, &rect
, 0, RDW_VALIDATE
| RDW_NOERASE
| RDW_NOCHILDREN
);
5360 /* now that parent is valid child should get WM_PAINT */
5361 while (PeekMessage( &msg
, hchild
, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
5362 ok_sequence( WmInvalidateErasePaint2
, "WmInvalidateErasePaint2", FALSE
);
5363 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
5364 ok_sequence( WmEmptySeq
, "No other message", FALSE
);
5366 /* same thing with WS_CLIPCHILDREN in parent */
5368 SetWindowLong( hparent
, GWL_STYLE
, GetWindowLong(hparent
,GWL_STYLE
) | WS_CLIPCHILDREN
);
5369 ok_sequence( WmSetParentStyle
, "WmSetParentStyle", FALSE
);
5370 /* changing style invalidates non client area, but we need to invalidate something else to see it */
5371 RedrawWindow( hparent
, &rect
, 0, RDW_UPDATENOW
);
5372 ok_sequence( WmEmptySeq
, "No message", FALSE
);
5373 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_UPDATENOW
);
5374 ok_sequence( WmParentOnlyNcPaint
, "WmParentOnlyNcPaint", FALSE
);
5377 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_ALLCHILDREN
);
5378 SetRectRgn( hrgn
, 20, 20, 30, 30 );
5379 check_update_rgn( hparent
, hrgn
);
5380 /* no WM_PAINT in child while parent still pending */
5381 while (PeekMessage( &msg
, hchild
, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
5382 ok_sequence( WmEmptySeq
, "No WM_PAINT", FALSE
);
5383 /* WM_PAINT in parent first */
5384 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
5385 ok_sequence( WmParentPaintNc
, "WmParentPaintNc2", FALSE
);
5387 /* no RDW_ERASE in parent still causes RDW_ERASE and RDW_FRAME in child */
5389 SetRect( &rect
, 0, 0, 30, 30 );
5390 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ALLCHILDREN
);
5391 SetRectRgn( hrgn
, 0, 0, 30, 30 );
5392 check_update_rgn( hparent
, hrgn
);
5394 ok_sequence( WmParentPaintNc
, "WmParentPaintNc3", FALSE
);
5396 /* validate doesn't cause RDW_NOERASE or RDW_NOFRAME in child */
5398 SetRect( &rect
, -10, 0, 30, 30 );
5399 RedrawWindow( hchild
, &rect
, 0, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASE
);
5400 SetRect( &rect
, 0, 0, 20, 20 );
5401 RedrawWindow( hparent
, &rect
, 0, RDW_VALIDATE
| RDW_ALLCHILDREN
);
5402 RedrawWindow( hparent
, NULL
, 0, RDW_UPDATENOW
);
5403 ok_sequence( WmChildPaintNc
, "WmChildPaintNc", FALSE
);
5405 /* validate doesn't cause RDW_NOERASE or RDW_NOFRAME in child */
5407 SetRect( &rect
, -10, 0, 30, 30 );
5408 RedrawWindow( hchild
, &rect
, 0, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASE
);
5409 SetRect( &rect
, 0, 0, 100, 100 );
5410 RedrawWindow( hparent
, &rect
, 0, RDW_VALIDATE
| RDW_ALLCHILDREN
);
5411 RedrawWindow( hparent
, NULL
, 0, RDW_UPDATENOW
);
5412 ok_sequence( WmEmptySeq
, "WmChildPaintNc2", FALSE
);
5413 RedrawWindow( hparent
, NULL
, 0, RDW_ERASENOW
);
5414 ok_sequence( WmEmptySeq
, "WmChildPaintNc3", FALSE
);
5416 /* test RDW_INTERNALPAINT behavior */
5419 RedrawWindow( hparent
, NULL
, 0, RDW_INTERNALPAINT
| RDW_NOCHILDREN
);
5421 ok_sequence( WmParentOnlyPaint
, "WmParentOnlyPaint", FALSE
);
5423 RedrawWindow( hparent
, NULL
, 0, RDW_INTERNALPAINT
| RDW_ALLCHILDREN
);
5425 ok_sequence( WmParentPaint
, "WmParentPaint", FALSE
);
5427 RedrawWindow( hparent
, NULL
, 0, RDW_INTERNALPAINT
);
5429 ok_sequence( WmParentOnlyPaint
, "WmParentOnlyPaint", FALSE
);
5431 assert( GetWindowLong(hparent
, GWL_STYLE
) & WS_CLIPCHILDREN
);
5432 UpdateWindow( hparent
);
5435 trace("testing SWP_FRAMECHANGED on parent with WS_CLIPCHILDREN\n");
5436 RedrawWindow( hchild
, NULL
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
5437 SetWindowPos( hparent
, 0, 0, 0, 0, 0, SWP_NOSIZE
| SWP_NOMOVE
|
5438 SWP_NOACTIVATE
| SWP_NOZORDER
| SWP_FRAMECHANGED
);
5440 ok_sequence(WmSWP_FrameChanged_clip
, "SetWindowPos:FrameChanged_clip", FALSE
);
5442 UpdateWindow( hparent
);
5445 trace("testing SWP_FRAMECHANGED|SWP_DEFERERASE on parent with WS_CLIPCHILDREN\n");
5446 RedrawWindow( hchild
, NULL
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
5447 SetWindowPos( hparent
, 0, 0, 0, 0, 0, SWP_NOSIZE
| SWP_NOMOVE
| SWP_DEFERERASE
|
5448 SWP_NOACTIVATE
| SWP_NOZORDER
| SWP_FRAMECHANGED
);
5450 ok_sequence(WmSWP_FrameChangedDeferErase
, "SetWindowPos:FrameChangedDeferErase", FALSE
);
5452 SetWindowLong( hparent
, GWL_STYLE
, GetWindowLong(hparent
,GWL_STYLE
) & ~WS_CLIPCHILDREN
);
5453 ok_sequence( WmSetParentStyle
, "WmSetParentStyle", FALSE
);
5454 RedrawWindow( hparent
, NULL
, 0, RDW_INTERNALPAINT
);
5456 ok_sequence( WmParentPaint
, "WmParentPaint", FALSE
);
5458 assert( !(GetWindowLong(hparent
, GWL_STYLE
) & WS_CLIPCHILDREN
) );
5459 UpdateWindow( hparent
);
5462 trace("testing SWP_FRAMECHANGED on parent without WS_CLIPCHILDREN\n");
5463 RedrawWindow( hchild
, NULL
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
5464 SetWindowPos( hparent
, 0, 0, 0, 0, 0, SWP_NOSIZE
| SWP_NOMOVE
|
5465 SWP_NOACTIVATE
| SWP_NOZORDER
| SWP_FRAMECHANGED
);
5467 ok_sequence(WmSWP_FrameChanged_noclip
, "SetWindowPos:FrameChanged_noclip", FALSE
);
5469 UpdateWindow( hparent
);
5472 trace("testing SWP_FRAMECHANGED|SWP_DEFERERASE on parent without WS_CLIPCHILDREN\n");
5473 RedrawWindow( hchild
, NULL
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
5474 SetWindowPos( hparent
, 0, 0, 0, 0, 0, SWP_NOSIZE
| SWP_NOMOVE
| SWP_DEFERERASE
|
5475 SWP_NOACTIVATE
| SWP_NOZORDER
| SWP_FRAMECHANGED
);
5477 ok_sequence(WmSWP_FrameChangedDeferErase
, "SetWindowPos:FrameChangedDeferErase", FALSE
);
5479 log_all_parent_messages
--;
5480 DestroyWindow( hparent
);
5481 ok(!IsWindow(hchild
), "child must be destroyed with its parent\n");
5483 DeleteObject( hrgn
);
5484 DeleteObject( hrgn2
);
5493 static DWORD WINAPI
thread_proc(void *param
)
5496 struct wnd_event
*wnd_event
= (struct wnd_event
*)param
;
5498 wnd_event
->hwnd
= CreateWindowExA(0, "TestWindowClass", "window caption text", WS_OVERLAPPEDWINDOW
,
5499 100, 100, 200, 200, 0, 0, 0, NULL
);
5500 ok(wnd_event
->hwnd
!= 0, "Failed to create overlapped window\n");
5502 SetEvent(wnd_event
->event
);
5504 while (GetMessage(&msg
, 0, 0, 0))
5506 TranslateMessage(&msg
);
5507 DispatchMessage(&msg
);
5510 ok(IsWindow(wnd_event
->hwnd
), "window should still exist\n");
5515 static void test_interthread_messages(void)
5522 int len
, expected_len
;
5523 struct wnd_event wnd_event
;
5526 wnd_event
.event
= CreateEventW(NULL
, 0, 0, NULL
);
5527 if (!wnd_event
.event
)
5529 trace("skipping interthread message test under win9x\n");
5533 hThread
= CreateThread(NULL
, 0, thread_proc
, &wnd_event
, 0, &tid
);
5534 ok(hThread
!= NULL
, "CreateThread failed, error %d\n", GetLastError());
5536 ok(WaitForSingleObject(wnd_event
.event
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
5538 CloseHandle(wnd_event
.event
);
5540 SetLastError(0xdeadbeef);
5541 ok(!DestroyWindow(wnd_event
.hwnd
), "DestroyWindow succeded\n");
5542 ok(GetLastError() == ERROR_ACCESS_DENIED
, "wrong error code %d\n", GetLastError());
5544 proc
= (WNDPROC
)GetWindowLongPtrA(wnd_event
.hwnd
, GWLP_WNDPROC
);
5545 ok(proc
!= NULL
, "GetWindowLongPtrA(GWLP_WNDPROC) error %d\n", GetLastError());
5547 expected_len
= lstrlenA("window caption text");
5548 memset(buf
, 0, sizeof(buf
));
5549 SetLastError(0xdeadbeef);
5550 len
= CallWindowProcA(proc
, wnd_event
.hwnd
, WM_GETTEXT
, sizeof(buf
), (LPARAM
)buf
);
5551 ok(len
== expected_len
, "CallWindowProcA(WM_GETTEXT) error %d, len %d, expected len %d\n", GetLastError(), len
, expected_len
);
5552 ok(!lstrcmpA(buf
, "window caption text"), "window text mismatch\n");
5554 msg
.hwnd
= wnd_event
.hwnd
;
5555 msg
.message
= WM_GETTEXT
;
5556 msg
.wParam
= sizeof(buf
);
5557 msg
.lParam
= (LPARAM
)buf
;
5558 memset(buf
, 0, sizeof(buf
));
5559 SetLastError(0xdeadbeef);
5560 len
= DispatchMessageA(&msg
);
5561 ok(!len
&& GetLastError() == ERROR_MESSAGE_SYNC_ONLY
,
5562 "DispatchMessageA(WM_GETTEXT) succeded on another thread window: ret %d, error %d\n", len
, GetLastError());
5564 /* the following test causes an exception in user.exe under win9x */
5565 msg
.hwnd
= wnd_event
.hwnd
;
5566 msg
.message
= WM_TIMER
;
5568 msg
.lParam
= GetWindowLongPtrA(wnd_event
.hwnd
, GWLP_WNDPROC
);
5569 SetLastError(0xdeadbeef);
5570 len
= DispatchMessageA(&msg
);
5571 ok(!len
&& GetLastError() == 0xdeadbeef,
5572 "DispatchMessageA(WM_TIMER) failed on another thread window: ret %d, error %d\n", len
, GetLastError());
5574 ret
= PostMessageA(wnd_event
.hwnd
, WM_QUIT
, 0, 0);
5575 ok( ret
, "PostMessageA(WM_QUIT) error %d\n", GetLastError());
5577 ok(WaitForSingleObject(hThread
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
5578 CloseHandle(hThread
);
5580 ok(!IsWindow(wnd_event
.hwnd
), "window should be destroyed on thread exit\n");
5584 static const struct message WmVkN
[] = {
5585 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 1 }, /* XP */
5586 { WM_KEYDOWN
, wparam
|lparam
, 'N', 1 },
5587 { WM_KEYDOWN
, sent
|wparam
|lparam
, 'N', 1 },
5588 { WM_CHAR
, wparam
|lparam
, 'n', 1 },
5589 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1002,1), 0 },
5590 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xc0000001 }, /* XP */
5591 { WM_KEYUP
, wparam
|lparam
, 'N', 0xc0000001 },
5592 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xc0000001 },
5595 static const struct message WmShiftVkN
[] = {
5596 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 1 }, /* XP */
5597 { WM_KEYDOWN
, wparam
|lparam
, VK_SHIFT
, 1 },
5598 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_SHIFT
, 1 },
5599 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 1 }, /* XP */
5600 { WM_KEYDOWN
, wparam
|lparam
, 'N', 1 },
5601 { WM_KEYDOWN
, sent
|wparam
|lparam
, 'N', 1 },
5602 { WM_CHAR
, wparam
|lparam
, 'N', 1 },
5603 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1001,1), 0 },
5604 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xc0000001 }, /* XP */
5605 { WM_KEYUP
, wparam
|lparam
, 'N', 0xc0000001 },
5606 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xc0000001 },
5607 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 0xc0000001 }, /* XP */
5608 { WM_KEYUP
, wparam
|lparam
, VK_SHIFT
, 0xc0000001 },
5609 { WM_KEYUP
, sent
|wparam
|lparam
, VK_SHIFT
, 0xc0000001 },
5612 static const struct message WmCtrlVkN
[] = {
5613 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 1 }, /* XP */
5614 { WM_KEYDOWN
, wparam
|lparam
, VK_CONTROL
, 1 },
5615 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_CONTROL
, 1 },
5616 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 1 }, /* XP */
5617 { WM_KEYDOWN
, wparam
|lparam
, 'N', 1 },
5618 { WM_KEYDOWN
, sent
|wparam
|lparam
, 'N', 1 },
5619 { WM_CHAR
, wparam
|lparam
, 0x000e, 1 },
5620 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1000,1), 0 },
5621 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xc0000001 }, /* XP */
5622 { WM_KEYUP
, wparam
|lparam
, 'N', 0xc0000001 },
5623 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xc0000001 },
5624 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 0xc0000001 }, /* XP */
5625 { WM_KEYUP
, wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
5626 { WM_KEYUP
, sent
|wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
5629 static const struct message WmCtrlVkN_2
[] = {
5630 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 1 }, /* XP */
5631 { WM_KEYDOWN
, wparam
|lparam
, VK_CONTROL
, 1 },
5632 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_CONTROL
, 1 },
5633 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 1 }, /* XP */
5634 { WM_KEYDOWN
, wparam
|lparam
, 'N', 1 },
5635 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1000,1), 0 },
5636 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xc0000001 }, /* XP */
5637 { WM_KEYUP
, wparam
|lparam
, 'N', 0xc0000001 },
5638 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xc0000001 },
5639 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 0xc0000001 }, /* XP */
5640 { WM_KEYUP
, wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
5641 { WM_KEYUP
, sent
|wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
5644 static const struct message WmAltVkN
[] = {
5645 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 }, /* XP */
5646 { WM_SYSKEYDOWN
, wparam
|lparam
, VK_MENU
, 0x20000001 },
5647 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
5648 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0x20000001 }, /* XP */
5649 { WM_SYSKEYDOWN
, wparam
|lparam
, 'N', 0x20000001 },
5650 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, 'N', 0x20000001 },
5651 { WM_SYSCHAR
, wparam
|lparam
, 'n', 0x20000001 },
5652 { WM_SYSCHAR
, sent
|wparam
|lparam
, 'n', 0x20000001 },
5653 { WM_SYSCOMMAND
, sent
|defwinproc
|wparam
|lparam
, SC_KEYMENU
, 'n' },
5654 { HCBT_SYSCOMMAND
, hook
},
5655 { WM_ENTERMENULOOP
, sent
|defwinproc
|wparam
|lparam
, 0, 0 },
5656 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
5657 { 0x00AE, sent
|defwinproc
|optional
}, /* XP */
5658 { WM_GETTEXT
, sent
|defwinproc
|optional
}, /* XP */
5659 { WM_INITMENU
, sent
|defwinproc
},
5660 { EVENT_SYSTEM_MENUSTART
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 0 },
5661 { WM_MENUCHAR
, sent
|defwinproc
|wparam
, MAKEWPARAM('n',MF_SYSMENU
) },
5662 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, 0, 0 },
5663 { WM_CAPTURECHANGED
, sent
|defwinproc
},
5664 { WM_MENUSELECT
, sent
|defwinproc
|wparam
, MAKEWPARAM(0,0xffff) },
5665 { EVENT_SYSTEM_MENUEND
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 0 },
5666 { WM_EXITMENULOOP
, sent
|defwinproc
},
5667 { WM_MENUSELECT
, sent
|defwinproc
|wparam
|optional
, MAKEWPARAM(0,0xffff) }, /* Win95 bug */
5668 { WM_EXITMENULOOP
, sent
|defwinproc
|optional
}, /* Win95 bug */
5669 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xe0000001 }, /* XP */
5670 { WM_SYSKEYUP
, wparam
|lparam
, 'N', 0xe0000001 },
5671 { WM_SYSKEYUP
, sent
|wparam
|lparam
, 'N', 0xe0000001 },
5672 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xc0000001 }, /* XP */
5673 { WM_KEYUP
, wparam
|lparam
, VK_MENU
, 0xc0000001 },
5674 { WM_KEYUP
, sent
|wparam
|lparam
, VK_MENU
, 0xc0000001 },
5677 static const struct message WmAltVkN_2
[] = {
5678 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 }, /* XP */
5679 { WM_SYSKEYDOWN
, wparam
|lparam
, VK_MENU
, 0x20000001 },
5680 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
5681 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0x20000001 }, /* XP */
5682 { WM_SYSKEYDOWN
, wparam
|lparam
, 'N', 0x20000001 },
5683 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1003,1), 0 },
5684 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xe0000001 }, /* XP */
5685 { WM_SYSKEYUP
, wparam
|lparam
, 'N', 0xe0000001 },
5686 { WM_SYSKEYUP
, sent
|wparam
|lparam
, 'N', 0xe0000001 },
5687 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xc0000001 }, /* XP */
5688 { WM_KEYUP
, wparam
|lparam
, VK_MENU
, 0xc0000001 },
5689 { WM_KEYUP
, sent
|wparam
|lparam
, VK_MENU
, 0xc0000001 },
5692 static const struct message WmCtrlAltVkN
[] = {
5693 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 1 }, /* XP */
5694 { WM_KEYDOWN
, wparam
|lparam
, VK_CONTROL
, 1 },
5695 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_CONTROL
, 1 },
5696 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 }, /* XP */
5697 { WM_KEYDOWN
, wparam
|lparam
, VK_MENU
, 0x20000001 },
5698 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
5699 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0x20000001 }, /* XP */
5700 { WM_KEYDOWN
, wparam
|lparam
, 'N', 0x20000001 },
5701 { WM_KEYDOWN
, sent
|wparam
|lparam
, 'N', 0x20000001 },
5702 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xe0000001 }, /* XP */
5703 { WM_KEYUP
, wparam
|lparam
, 'N', 0xe0000001 },
5704 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xe0000001 },
5705 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xc0000001 }, /* XP */
5706 { WM_KEYUP
, wparam
|lparam
, VK_MENU
, 0xc0000001 },
5707 { WM_KEYUP
, sent
|wparam
|lparam
, VK_MENU
, 0xc0000001 },
5708 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 0xc0000001 }, /* XP */
5709 { WM_KEYUP
, wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
5710 { WM_KEYUP
, sent
|wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
5713 static const struct message WmCtrlShiftVkN
[] = {
5714 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 1 }, /* XP */
5715 { WM_KEYDOWN
, wparam
|lparam
, VK_CONTROL
, 1 },
5716 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_CONTROL
, 1 },
5717 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 1 }, /* XP */
5718 { WM_KEYDOWN
, wparam
|lparam
, VK_SHIFT
, 1 },
5719 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_SHIFT
, 1 },
5720 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 1 }, /* XP */
5721 { WM_KEYDOWN
, wparam
|lparam
, 'N', 1 },
5722 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1004,1), 0 },
5723 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xc0000001 }, /* XP */
5724 { WM_KEYUP
, wparam
|lparam
, 'N', 0xc0000001 },
5725 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xc0000001 },
5726 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 0xc0000001 }, /* XP */
5727 { WM_KEYUP
, wparam
|lparam
, VK_SHIFT
, 0xc0000001 },
5728 { WM_KEYUP
, sent
|wparam
|lparam
, VK_SHIFT
, 0xc0000001 },
5729 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 0xc0000001 }, /* XP */
5730 { WM_KEYUP
, wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
5731 { WM_KEYUP
, sent
|wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
5734 static const struct message WmCtrlAltShiftVkN
[] = {
5735 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 1 }, /* XP */
5736 { WM_KEYDOWN
, wparam
|lparam
, VK_CONTROL
, 1 },
5737 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_CONTROL
, 1 },
5738 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 }, /* XP */
5739 { WM_KEYDOWN
, wparam
|lparam
, VK_MENU
, 0x20000001 },
5740 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
5741 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 0x20000001 }, /* XP */
5742 { WM_KEYDOWN
, wparam
|lparam
, VK_SHIFT
, 0x20000001 },
5743 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_SHIFT
, 0x20000001 },
5744 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0x20000001 }, /* XP */
5745 { WM_KEYDOWN
, wparam
|lparam
, 'N', 0x20000001 },
5746 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1005,1), 0 },
5747 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xe0000001 }, /* XP */
5748 { WM_KEYUP
, wparam
|lparam
, 'N', 0xe0000001 },
5749 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xe0000001 },
5750 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 0xe0000001 }, /* XP */
5751 { WM_KEYUP
, wparam
|lparam
, VK_SHIFT
, 0xe0000001 },
5752 { WM_KEYUP
, sent
|wparam
|lparam
, VK_SHIFT
, 0xe0000001 },
5753 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xc0000001 }, /* XP */
5754 { WM_KEYUP
, wparam
|lparam
, VK_MENU
, 0xc0000001 },
5755 { WM_KEYUP
, sent
|wparam
|lparam
, VK_MENU
, 0xc0000001 },
5756 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 0xc0000001 }, /* XP */
5757 { WM_KEYUP
, wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
5758 { WM_KEYUP
, sent
|wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
5761 static const struct message WmAltPressRelease
[] = {
5762 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 }, /* XP */
5763 { WM_SYSKEYDOWN
, wparam
|lparam
, VK_MENU
, 0x20000001 },
5764 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
5765 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xc0000001 }, /* XP */
5766 { WM_SYSKEYUP
, wparam
|lparam
, VK_MENU
, 0xc0000001 },
5767 { WM_SYSKEYUP
, sent
|wparam
|lparam
, VK_MENU
, 0xc0000001 },
5768 { WM_SYSCOMMAND
, sent
|defwinproc
|wparam
|lparam
, SC_KEYMENU
, 0 },
5769 { HCBT_SYSCOMMAND
, hook
},
5770 { WM_ENTERMENULOOP
, sent
|defwinproc
|wparam
|lparam
, 0, 0 },
5771 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
5772 { WM_INITMENU
, sent
|defwinproc
},
5773 { EVENT_SYSTEM_MENUSTART
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 0 },
5774 { WM_MENUSELECT
, sent
|defwinproc
|wparam
, MAKEWPARAM(0,MF_SYSMENU
|MF_POPUP
|MF_HILITE
) },
5775 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 1 },
5777 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x30000001 }, /* XP */
5779 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 0 },
5780 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, 0, 0, },
5781 { WM_CAPTURECHANGED
, sent
|defwinproc
},
5782 { WM_MENUSELECT
, sent
|defwinproc
|wparam
|optional
, MAKEWPARAM(0,0xffff) },
5783 { EVENT_SYSTEM_MENUEND
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 0 },
5784 { WM_EXITMENULOOP
, sent
|defwinproc
},
5785 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xc0000001 }, /* XP */
5786 { WM_SYSKEYUP
, wparam
|lparam
, VK_MENU
, 0xc0000001 },
5787 { WM_SYSKEYUP
, sent
|wparam
|lparam
, VK_MENU
, 0xc0000001 },
5790 static const struct message WmAltMouseButton
[] = {
5791 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 }, /* XP */
5792 { WM_SYSKEYDOWN
, wparam
|lparam
, VK_MENU
, 0x20000001 },
5793 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
5794 { WM_MOUSEMOVE
, wparam
|optional
, 0, 0 },
5795 { WM_MOUSEMOVE
, sent
|wparam
|optional
, 0, 0 },
5796 { WM_LBUTTONDOWN
, wparam
, MK_LBUTTON
, 0 },
5797 { WM_LBUTTONDOWN
, sent
|wparam
, MK_LBUTTON
, 0 },
5798 { WM_LBUTTONUP
, wparam
, 0, 0 },
5799 { WM_LBUTTONUP
, sent
|wparam
, 0, 0 },
5800 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xc0000001 }, /* XP */
5801 { WM_SYSKEYUP
, wparam
|lparam
, VK_MENU
, 0xc0000001 },
5802 { WM_SYSKEYUP
, sent
|wparam
|lparam
, VK_MENU
, 0xc0000001 },
5805 static const struct message WmF1Seq
[] = {
5806 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_F1
, 1 }, /* XP */
5807 { WM_KEYDOWN
, wparam
|lparam
, VK_F1
, 1 },
5808 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_F1
, 0x00000001 },
5809 { 0x4d, wparam
|lparam
, 0, 0 },
5810 { 0x4d, sent
|wparam
|lparam
, 0, 0 },
5811 { WM_HELP
, sent
|defwinproc
},
5812 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_F1
, 0xc0000001 }, /* XP */
5813 { WM_KEYUP
, wparam
|lparam
, VK_F1
, 0xc0000001 },
5814 { WM_KEYUP
, sent
|wparam
|lparam
, VK_F1
, 0xc0000001 },
5817 static const struct message WmVkAppsSeq
[] = {
5818 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_APPS
, 1 }, /* XP */
5819 { WM_KEYDOWN
, wparam
|lparam
, VK_APPS
, 1 },
5820 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_APPS
, 0x00000001 },
5821 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_APPS
, 0xc0000001 }, /* XP */
5822 { WM_KEYUP
, wparam
|lparam
, VK_APPS
, 0xc0000001 },
5823 { WM_KEYUP
, sent
|wparam
|lparam
, VK_APPS
, 0xc0000001 },
5824 { WM_CONTEXTMENU
, lparam
, /*hwnd*/0, (LPARAM
)-1 },
5825 { WM_CONTEXTMENU
, sent
|lparam
, /*hwnd*/0, (LPARAM
)-1 },
5829 static void pump_msg_loop(HWND hwnd
, HACCEL hAccel
)
5833 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
))
5835 struct message log_msg
;
5837 trace("accel: %p, %04x, %08lx, %08lx\n", msg
.hwnd
, msg
.message
, msg
.wParam
, msg
.lParam
);
5839 /* ignore some unwanted messages */
5840 if (msg
.message
== WM_MOUSEMOVE
||
5841 msg
.message
== WM_GETICON
||
5842 msg
.message
== WM_DEVICECHANGE
)
5845 log_msg
.message
= msg
.message
;
5846 log_msg
.flags
= wparam
|lparam
;
5847 log_msg
.wParam
= msg
.wParam
;
5848 log_msg
.lParam
= msg
.lParam
;
5849 add_message(&log_msg
);
5851 if (!hAccel
|| !TranslateAccelerator(hwnd
, hAccel
, &msg
))
5853 TranslateMessage(&msg
);
5854 DispatchMessage(&msg
);
5859 static void test_accelerators(void)
5864 HWND hwnd
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
5865 100, 100, 200, 200, 0, 0, 0, NULL
);
5874 ok(GetFocus() == hwnd
, "wrong focus window %p\n", GetFocus());
5876 state
= GetKeyState(VK_SHIFT
);
5877 ok(!(state
& 0x8000), "wrong Shift state %04x\n", state
);
5878 state
= GetKeyState(VK_CAPITAL
);
5879 ok(state
== 0, "wrong CapsLock state %04x\n", state
);
5881 hAccel
= LoadAccelerators(GetModuleHandleA(0), MAKEINTRESOURCE(1));
5882 assert(hAccel
!= 0);
5884 pump_msg_loop(hwnd
, 0);
5887 trace("testing VK_N press/release\n");
5889 keybd_event('N', 0, 0, 0);
5890 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
5891 pump_msg_loop(hwnd
, hAccel
);
5892 ok_sequence(WmVkN
, "VK_N press/release", FALSE
);
5894 trace("testing Shift+VK_N press/release\n");
5896 keybd_event(VK_SHIFT
, 0, 0, 0);
5897 keybd_event('N', 0, 0, 0);
5898 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
5899 keybd_event(VK_SHIFT
, 0, KEYEVENTF_KEYUP
, 0);
5900 pump_msg_loop(hwnd
, hAccel
);
5901 ok_sequence(WmShiftVkN
, "Shift+VK_N press/release", FALSE
);
5903 trace("testing Ctrl+VK_N press/release\n");
5905 keybd_event(VK_CONTROL
, 0, 0, 0);
5906 keybd_event('N', 0, 0, 0);
5907 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
5908 keybd_event(VK_CONTROL
, 0, KEYEVENTF_KEYUP
, 0);
5909 pump_msg_loop(hwnd
, hAccel
);
5910 ok_sequence(WmCtrlVkN
, "Ctrl+VK_N press/release", FALSE
);
5912 trace("testing Alt+VK_N press/release\n");
5914 keybd_event(VK_MENU
, 0, 0, 0);
5915 keybd_event('N', 0, 0, 0);
5916 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
5917 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
5918 pump_msg_loop(hwnd
, hAccel
);
5919 ok_sequence(WmAltVkN
, "Alt+VK_N press/release", FALSE
);
5921 trace("testing Ctrl+Alt+VK_N press/release 1\n");
5923 keybd_event(VK_CONTROL
, 0, 0, 0);
5924 keybd_event(VK_MENU
, 0, 0, 0);
5925 keybd_event('N', 0, 0, 0);
5926 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
5927 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
5928 keybd_event(VK_CONTROL
, 0, KEYEVENTF_KEYUP
, 0);
5929 pump_msg_loop(hwnd
, hAccel
);
5930 ok_sequence(WmCtrlAltVkN
, "Ctrl+Alt+VK_N press/release 1", FALSE
);
5932 ret
= DestroyAcceleratorTable(hAccel
);
5933 ok( ret
, "DestroyAcceleratorTable error %d\n", GetLastError());
5935 hAccel
= LoadAccelerators(GetModuleHandleA(0), MAKEINTRESOURCE(2));
5936 assert(hAccel
!= 0);
5938 trace("testing VK_N press/release\n");
5940 keybd_event('N', 0, 0, 0);
5941 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
5942 pump_msg_loop(hwnd
, hAccel
);
5943 ok_sequence(WmVkN
, "VK_N press/release", FALSE
);
5945 trace("testing Shift+VK_N press/release\n");
5947 keybd_event(VK_SHIFT
, 0, 0, 0);
5948 keybd_event('N', 0, 0, 0);
5949 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
5950 keybd_event(VK_SHIFT
, 0, KEYEVENTF_KEYUP
, 0);
5951 pump_msg_loop(hwnd
, hAccel
);
5952 ok_sequence(WmShiftVkN
, "Shift+VK_N press/release", FALSE
);
5954 trace("testing Ctrl+VK_N press/release 2\n");
5956 keybd_event(VK_CONTROL
, 0, 0, 0);
5957 keybd_event('N', 0, 0, 0);
5958 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
5959 keybd_event(VK_CONTROL
, 0, KEYEVENTF_KEYUP
, 0);
5960 pump_msg_loop(hwnd
, hAccel
);
5961 ok_sequence(WmCtrlVkN_2
, "Ctrl+VK_N press/release 2", FALSE
);
5963 trace("testing Alt+VK_N press/release 2\n");
5965 keybd_event(VK_MENU
, 0, 0, 0);
5966 keybd_event('N', 0, 0, 0);
5967 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
5968 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
5969 pump_msg_loop(hwnd
, hAccel
);
5970 ok_sequence(WmAltVkN_2
, "Alt+VK_N press/release 2", FALSE
);
5972 trace("testing Ctrl+Alt+VK_N press/release 2\n");
5974 keybd_event(VK_CONTROL
, 0, 0, 0);
5975 keybd_event(VK_MENU
, 0, 0, 0);
5976 keybd_event('N', 0, 0, 0);
5977 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
5978 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
5979 keybd_event(VK_CONTROL
, 0, KEYEVENTF_KEYUP
, 0);
5980 pump_msg_loop(hwnd
, hAccel
);
5981 ok_sequence(WmCtrlAltVkN
, "Ctrl+Alt+VK_N press/release 2", FALSE
);
5983 trace("testing Ctrl+Shift+VK_N press/release\n");
5985 keybd_event(VK_CONTROL
, 0, 0, 0);
5986 keybd_event(VK_SHIFT
, 0, 0, 0);
5987 keybd_event('N', 0, 0, 0);
5988 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
5989 keybd_event(VK_SHIFT
, 0, KEYEVENTF_KEYUP
, 0);
5990 keybd_event(VK_CONTROL
, 0, KEYEVENTF_KEYUP
, 0);
5991 pump_msg_loop(hwnd
, hAccel
);
5992 ok_sequence(WmCtrlShiftVkN
, "Ctrl+Shift+VK_N press/release", FALSE
);
5994 trace("testing Ctrl+Alt+Shift+VK_N press/release\n");
5996 keybd_event(VK_CONTROL
, 0, 0, 0);
5997 keybd_event(VK_MENU
, 0, 0, 0);
5998 keybd_event(VK_SHIFT
, 0, 0, 0);
5999 keybd_event('N', 0, 0, 0);
6000 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
6001 keybd_event(VK_SHIFT
, 0, KEYEVENTF_KEYUP
, 0);
6002 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
6003 keybd_event(VK_CONTROL
, 0, KEYEVENTF_KEYUP
, 0);
6004 pump_msg_loop(hwnd
, hAccel
);
6005 ok_sequence(WmCtrlAltShiftVkN
, "Ctrl+Alt+Shift+VK_N press/release", FALSE
);
6007 ret
= DestroyAcceleratorTable(hAccel
);
6008 ok( ret
, "DestroyAcceleratorTable error %d\n", GetLastError());
6010 trace("testing Alt press/release\n");
6012 keybd_event(VK_MENU
, 0, 0, 0);
6013 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
6014 keybd_event(VK_MENU
, 0, 0, 0);
6015 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
6016 pump_msg_loop(hwnd
, 0);
6017 /* this test doesn't pass in Wine for managed windows */
6018 ok_sequence(WmAltPressRelease
, "Alt press/release", TRUE
);
6020 trace("testing Alt+MouseButton press/release\n");
6021 /* first, move mouse pointer inside of the window client area */
6022 GetClientRect(hwnd
, &rc
);
6023 MapWindowPoints(hwnd
, 0, (LPPOINT
)&rc
, 2);
6024 rc
.left
+= (rc
.right
- rc
.left
)/2;
6025 rc
.top
+= (rc
.bottom
- rc
.top
)/2;
6026 SetCursorPos(rc
.left
, rc
.top
);
6030 keybd_event(VK_MENU
, 0, 0, 0);
6031 mouse_event(MOUSEEVENTF_LEFTDOWN
, 0, 0, 0, 0);
6032 mouse_event(MOUSEEVENTF_LEFTUP
, 0, 0, 0, 0);
6033 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
6034 pump_msg_loop(hwnd
, 0);
6035 ok_sequence(WmAltMouseButton
, "Alt+MouseButton press/release", FALSE
);
6037 trace("testing VK_F1 press/release\n");
6038 keybd_event(VK_F1
, 0, 0, 0);
6039 keybd_event(VK_F1
, 0, KEYEVENTF_KEYUP
, 0);
6040 pump_msg_loop(hwnd
, 0);
6041 ok_sequence(WmF1Seq
, "F1 press/release", TRUE
);
6043 trace("testing VK_APPS press/release\n");
6044 keybd_event(VK_APPS
, 0, 0, 0);
6045 keybd_event(VK_APPS
, 0, KEYEVENTF_KEYUP
, 0);
6046 pump_msg_loop(hwnd
, 0);
6047 ok_sequence(WmVkAppsSeq
, "VK_APPS press/release", FALSE
);
6049 DestroyWindow(hwnd
);
6052 /************* window procedures ********************/
6054 static LRESULT
MsgCheckProc (BOOL unicode
, HWND hwnd
, UINT message
,
6055 WPARAM wParam
, LPARAM lParam
)
6057 static long defwndproc_counter
= 0;
6058 static long beginpaint_counter
= 0;
6062 trace("%p, %04x, %08lx, %08lx\n", hwnd
, message
, wParam
, lParam
);
6064 /* explicitly ignore WM_GETICON message */
6065 if (message
== WM_GETICON
) return 0;
6071 LONG style
= GetWindowLongA(hwnd
, GWL_STYLE
);
6072 ok((BOOL
)wParam
== !(style
& WS_DISABLED
),
6073 "wrong WS_DISABLED state: %ld != %d\n", wParam
, !(style
& WS_DISABLED
));
6077 case WM_CAPTURECHANGED
:
6078 if (test_DestroyWindow_flag
)
6080 DWORD style
= GetWindowLongA(hwnd
, GWL_STYLE
);
6081 if (style
& WS_CHILD
)
6082 lParam
= GetWindowLongPtrA(hwnd
, GWLP_ID
);
6083 else if (style
& WS_POPUP
)
6084 lParam
= WND_POPUP_ID
;
6086 lParam
= WND_PARENT_ID
;
6094 ok(!GetWindow(hwnd
, GW_CHILD
), "children should be unlinked at this point\n");
6095 capture
= GetCapture();
6098 ok(capture
== hwnd
, "capture should NOT be released at this point (capture %p)\n", capture
);
6099 trace("current capture %p, releasing...\n", capture
);
6106 ok(pGetAncestor(hwnd
, GA_PARENT
) != 0, "parent should NOT be unlinked at this point\n");
6107 if (test_DestroyWindow_flag
)
6109 DWORD style
= GetWindowLongA(hwnd
, GWL_STYLE
);
6110 if (style
& WS_CHILD
)
6111 lParam
= GetWindowLongPtrA(hwnd
, GWLP_ID
);
6112 else if (style
& WS_POPUP
)
6113 lParam
= WND_POPUP_ID
;
6115 lParam
= WND_PARENT_ID
;
6119 /* test_accelerators() depends on this */
6126 case WM_DEVICECHANGE
:
6129 case WM_WINDOWPOSCHANGING
:
6130 case WM_WINDOWPOSCHANGED
:
6132 WINDOWPOS
*winpos
= (WINDOWPOS
*)lParam
;
6134 trace("%s\n", (message
== WM_WINDOWPOSCHANGING
) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
6135 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
6136 winpos
->hwnd
, winpos
->hwndInsertAfter
,
6137 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
6138 dump_winpos_flags(winpos
->flags
);
6140 /* Log only documented flags, win2k uses 0x1000 and 0x2000
6141 * in the high word for internal purposes
6143 wParam
= winpos
->flags
& 0xffff;
6144 /* We are not interested in the flags that don't match under XP and Win9x */
6145 wParam
&= ~(SWP_NOZORDER
);
6150 msg
.message
= message
;
6151 msg
.flags
= sent
|wparam
|lparam
;
6152 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
6153 if (beginpaint_counter
) msg
.flags
|= beginpaint
;
6154 msg
.wParam
= wParam
;
6155 msg
.lParam
= lParam
;
6158 if (message
== WM_GETMINMAXINFO
&& (GetWindowLongA(hwnd
, GWL_STYLE
) & WS_CHILD
))
6160 HWND parent
= GetParent(hwnd
);
6162 MINMAXINFO
*minmax
= (MINMAXINFO
*)lParam
;
6164 GetClientRect(parent
, &rc
);
6165 trace("parent %p client size = (%d x %d)\n", parent
, rc
.right
, rc
.bottom
);
6167 trace("ptReserved = (%d,%d)\n"
6168 "ptMaxSize = (%d,%d)\n"
6169 "ptMaxPosition = (%d,%d)\n"
6170 "ptMinTrackSize = (%d,%d)\n"
6171 "ptMaxTrackSize = (%d,%d)\n",
6172 minmax
->ptReserved
.x
, minmax
->ptReserved
.y
,
6173 minmax
->ptMaxSize
.x
, minmax
->ptMaxSize
.y
,
6174 minmax
->ptMaxPosition
.x
, minmax
->ptMaxPosition
.y
,
6175 minmax
->ptMinTrackSize
.x
, minmax
->ptMinTrackSize
.y
,
6176 minmax
->ptMaxTrackSize
.x
, minmax
->ptMaxTrackSize
.y
);
6178 ok(minmax
->ptMaxSize
.x
== rc
.right
, "default width of maximized child %d != %d\n",
6179 minmax
->ptMaxSize
.x
, rc
.right
);
6180 ok(minmax
->ptMaxSize
.y
== rc
.bottom
, "default height of maximized child %d != %d\n",
6181 minmax
->ptMaxSize
.y
, rc
.bottom
);
6184 if (message
== WM_PAINT
)
6187 beginpaint_counter
++;
6188 BeginPaint( hwnd
, &ps
);
6189 beginpaint_counter
--;
6190 EndPaint( hwnd
, &ps
);
6194 defwndproc_counter
++;
6195 ret
= unicode
? DefWindowProcW(hwnd
, message
, wParam
, lParam
)
6196 : DefWindowProcA(hwnd
, message
, wParam
, lParam
);
6197 defwndproc_counter
--;
6202 static LRESULT WINAPI
MsgCheckProcA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
6204 return MsgCheckProc (FALSE
, hwnd
, message
, wParam
, lParam
);
6207 static LRESULT WINAPI
MsgCheckProcW(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
6209 return MsgCheckProc (TRUE
, hwnd
, message
, wParam
, lParam
);
6212 static LRESULT WINAPI
PopupMsgCheckProcA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
6214 static long defwndproc_counter
= 0;
6218 trace("popup: %p, %04x, %08lx, %08lx\n", hwnd
, message
, wParam
, lParam
);
6220 /* explicitly ignore WM_GETICON message */
6221 if (message
== WM_GETICON
) return 0;
6223 msg
.message
= message
;
6224 msg
.flags
= sent
|wparam
|lparam
;
6225 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
6226 msg
.wParam
= wParam
;
6227 msg
.lParam
= lParam
;
6230 if (message
== WM_CREATE
)
6232 DWORD style
= GetWindowLongA(hwnd
, GWL_STYLE
) | WS_VISIBLE
;
6233 SetWindowLongA(hwnd
, GWL_STYLE
, style
);
6236 defwndproc_counter
++;
6237 ret
= DefWindowProcA(hwnd
, message
, wParam
, lParam
);
6238 defwndproc_counter
--;
6243 static LRESULT WINAPI
ParentMsgCheckProcA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
6245 static long defwndproc_counter
= 0;
6246 static long beginpaint_counter
= 0;
6250 trace("parent: %p, %04x, %08lx, %08lx\n", hwnd
, message
, wParam
, lParam
);
6252 /* explicitly ignore WM_GETICON message */
6253 if (message
== WM_GETICON
) return 0;
6255 if (log_all_parent_messages
||
6256 message
== WM_PARENTNOTIFY
|| message
== WM_CANCELMODE
||
6257 message
== WM_SETFOCUS
|| message
== WM_KILLFOCUS
||
6258 message
== WM_ENABLE
|| message
== WM_ENTERIDLE
||
6259 message
== WM_DRAWITEM
||
6260 message
== WM_IME_SETCONTEXT
)
6274 INT ret
= GetClipBox((HDC
)wParam
, &rc
);
6276 trace("WM_ERASEBKGND: GetClipBox()=%d, (%d,%d-%d,%d)\n",
6277 ret
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
6281 case WM_WINDOWPOSCHANGING
:
6282 case WM_WINDOWPOSCHANGED
:
6284 WINDOWPOS
*winpos
= (WINDOWPOS
*)lParam
;
6286 trace("%s\n", (message
== WM_WINDOWPOSCHANGING
) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
6287 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
6288 winpos
->hwnd
, winpos
->hwndInsertAfter
,
6289 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
6290 dump_winpos_flags(winpos
->flags
);
6292 /* Log only documented flags, win2k uses 0x1000 and 0x2000
6293 * in the high word for internal purposes
6295 wParam
= winpos
->flags
& 0xffff;
6296 /* We are not interested in the flags that don't match under XP and Win9x */
6297 wParam
&= ~(SWP_NOZORDER
);
6303 /* encode DRAWITEMSTRUCT into an LPARAM */
6304 DRAW_ITEM_STRUCT di
;
6305 DRAWITEMSTRUCT
*dis
= (DRAWITEMSTRUCT
*)lParam
;
6307 trace("WM_DRAWITEM: type %x, ctl_id %x, item_id %x, action %x, state %x\n",
6308 dis
->CtlType
, dis
->CtlID
, dis
->itemID
, dis
->itemAction
, dis
->itemState
);
6310 di
.u
.item
.type
= dis
->CtlType
;
6311 di
.u
.item
.ctl_id
= dis
->CtlID
;
6312 di
.u
.item
.item_id
= dis
->itemID
;
6313 di
.u
.item
.action
= dis
->itemAction
;
6314 di
.u
.item
.state
= dis
->itemState
;
6321 msg
.message
= message
;
6322 msg
.flags
= sent
|parent
|wparam
|lparam
;
6323 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
6324 if (beginpaint_counter
) msg
.flags
|= beginpaint
;
6325 msg
.wParam
= wParam
;
6326 msg
.lParam
= lParam
;
6330 if (message
== WM_PAINT
)
6333 beginpaint_counter
++;
6334 BeginPaint( hwnd
, &ps
);
6335 beginpaint_counter
--;
6336 EndPaint( hwnd
, &ps
);
6340 defwndproc_counter
++;
6341 ret
= DefWindowProcA(hwnd
, message
, wParam
, lParam
);
6342 defwndproc_counter
--;
6347 static LRESULT WINAPI
TestDlgProcA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
6349 static long defwndproc_counter
= 0;
6353 trace("dialog: %p, %04x, %08lx, %08lx\n", hwnd
, message
, wParam
, lParam
);
6355 /* explicitly ignore WM_GETICON message */
6356 if (message
== WM_GETICON
) return 0;
6360 DefDlgProcA(hwnd
, DM_SETDEFID
, 1, 0);
6361 ret
= DefDlgProcA(hwnd
, DM_GETDEFID
, 0, 0);
6362 if (after_end_dialog
)
6363 ok( ret
== 0, "DM_GETDEFID should return 0 after EndDialog, got %lx\n", ret
);
6365 ok(HIWORD(ret
) == DC_HASDEFID
, "DM_GETDEFID should return DC_HASDEFID, got %lx\n", ret
);
6370 case WM_WINDOWPOSCHANGING
:
6371 case WM_WINDOWPOSCHANGED
:
6373 WINDOWPOS
*winpos
= (WINDOWPOS
*)lParam
;
6375 trace("%s\n", (message
== WM_WINDOWPOSCHANGING
) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
6376 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
6377 winpos
->hwnd
, winpos
->hwndInsertAfter
,
6378 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
6379 dump_winpos_flags(winpos
->flags
);
6381 /* Log only documented flags, win2k uses 0x1000 and 0x2000
6382 * in the high word for internal purposes
6384 wParam
= winpos
->flags
& 0xffff;
6385 /* We are not interested in the flags that don't match under XP and Win9x */
6386 wParam
&= ~(SWP_NOZORDER
);
6391 msg
.message
= message
;
6392 msg
.flags
= sent
|wparam
|lparam
;
6393 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
6394 msg
.wParam
= wParam
;
6395 msg
.lParam
= lParam
;
6398 defwndproc_counter
++;
6399 ret
= DefDlgProcA(hwnd
, message
, wParam
, lParam
);
6400 defwndproc_counter
--;
6405 static void dump_winpos_flags(UINT flags
)
6407 if (!winetest_debug
) return;
6409 if (flags
& SWP_SHOWWINDOW
) printf("|SWP_SHOWWINDOW");
6410 if (flags
& SWP_HIDEWINDOW
) printf("|SWP_HIDEWINDOW");
6411 if (flags
& SWP_NOACTIVATE
) printf("|SWP_NOACTIVATE");
6412 if (flags
& SWP_FRAMECHANGED
) printf("|SWP_FRAMECHANGED");
6413 if (flags
& SWP_NOCOPYBITS
) printf("|SWP_NOCOPYBITS");
6414 if (flags
& SWP_NOOWNERZORDER
) printf("|SWP_NOOWNERZORDER");
6415 if (flags
& SWP_NOSENDCHANGING
) printf("|SWP_NOSENDCHANGING");
6416 if (flags
& SWP_DEFERERASE
) printf("|SWP_DEFERERASE");
6417 if (flags
& SWP_ASYNCWINDOWPOS
) printf("|SWP_ASYNCWINDOWPOS");
6418 if (flags
& SWP_NOZORDER
) printf("|SWP_NOZORDER");
6419 if (flags
& SWP_NOREDRAW
) printf("|SWP_NOREDRAW");
6420 if (flags
& SWP_NOSIZE
) printf("|SWP_NOSIZE");
6421 if (flags
& SWP_NOMOVE
) printf("|SWP_NOMOVE");
6422 if (flags
& SWP_NOCLIENTSIZE
) printf("|SWP_NOCLIENTSIZE");
6423 if (flags
& SWP_NOCLIENTMOVE
) printf("|SWP_NOCLIENTMOVE");
6425 #define DUMPED_FLAGS \
6431 SWP_FRAMECHANGED | \
6435 SWP_NOOWNERZORDER | \
6436 SWP_NOSENDCHANGING | \
6438 SWP_ASYNCWINDOWPOS | \
6439 SWP_NOCLIENTSIZE | \
6442 if(flags
& ~DUMPED_FLAGS
) printf("|0x%04x", flags
& ~DUMPED_FLAGS
);
6447 static LRESULT WINAPI
ShowWindowProcA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
6449 static long defwndproc_counter
= 0;
6453 /* log only specific messages we are interested in */
6456 #if 0 /* probably log these as well */
6462 trace("WM_SHOWWINDOW %ld\n", wParam
);
6465 trace("WM_SIZE %ld\n", wParam
);
6470 case WM_GETMINMAXINFO
:
6471 trace("WM_GETMINMAXINFO\n");
6474 case WM_WINDOWPOSCHANGING
:
6475 case WM_WINDOWPOSCHANGED
:
6477 WINDOWPOS
*winpos
= (WINDOWPOS
*)lParam
;
6479 trace("%s\n", (message
== WM_WINDOWPOSCHANGING
) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
6480 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
6481 winpos
->hwnd
, winpos
->hwndInsertAfter
,
6482 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
6484 dump_winpos_flags(winpos
->flags
);
6486 /* Log only documented flags, win2k uses 0x1000 and 0x2000
6487 * in the high word for internal purposes
6489 wParam
= winpos
->flags
& 0xffff;
6490 /* We are not interested in the flags that don't match under XP and Win9x */
6491 wParam
&= ~(SWP_NOZORDER
);
6495 default: /* ignore */
6496 /*trace("showwindow: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);*/
6497 return DefWindowProcA(hwnd
, message
, wParam
, lParam
);
6500 msg
.message
= message
;
6501 msg
.flags
= sent
|wparam
|lparam
;
6502 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
6503 msg
.wParam
= wParam
;
6504 msg
.lParam
= lParam
;
6507 defwndproc_counter
++;
6508 ret
= DefWindowProcA(hwnd
, message
, wParam
, lParam
);
6509 defwndproc_counter
--;
6514 static BOOL
RegisterWindowClasses(void)
6520 cls
.lpfnWndProc
= MsgCheckProcA
;
6523 cls
.hInstance
= GetModuleHandleA(0);
6525 cls
.hCursor
= LoadCursorA(0, (LPSTR
)IDC_ARROW
);
6526 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
6527 cls
.lpszMenuName
= NULL
;
6528 cls
.lpszClassName
= "TestWindowClass";
6529 if(!RegisterClassA(&cls
)) return FALSE
;
6531 cls
.lpfnWndProc
= ShowWindowProcA
;
6532 cls
.lpszClassName
= "ShowWindowClass";
6533 if(!RegisterClassA(&cls
)) return FALSE
;
6535 cls
.lpfnWndProc
= PopupMsgCheckProcA
;
6536 cls
.lpszClassName
= "TestPopupClass";
6537 if(!RegisterClassA(&cls
)) return FALSE
;
6539 cls
.lpfnWndProc
= ParentMsgCheckProcA
;
6540 cls
.lpszClassName
= "TestParentClass";
6541 if(!RegisterClassA(&cls
)) return FALSE
;
6543 cls
.lpfnWndProc
= DefWindowProcA
;
6544 cls
.lpszClassName
= "SimpleWindowClass";
6545 if(!RegisterClassA(&cls
)) return FALSE
;
6547 cls
.style
= CS_NOCLOSE
;
6548 cls
.lpszClassName
= "NoCloseWindowClass";
6549 if(!RegisterClassA(&cls
)) return FALSE
;
6551 ok(GetClassInfoA(0, "#32770", &cls
), "GetClassInfo failed\n");
6553 cls
.hInstance
= GetModuleHandleA(0);
6554 cls
.hbrBackground
= 0;
6555 cls
.lpfnWndProc
= TestDlgProcA
;
6556 cls
.lpszClassName
= "TestDialogClass";
6557 if(!RegisterClassA(&cls
)) return FALSE
;
6560 clsW
.lpfnWndProc
= MsgCheckProcW
;
6561 clsW
.cbClsExtra
= 0;
6562 clsW
.cbWndExtra
= 0;
6563 clsW
.hInstance
= GetModuleHandleW(0);
6565 clsW
.hCursor
= LoadCursorW(0, (LPWSTR
)IDC_ARROW
);
6566 clsW
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
6567 clsW
.lpszMenuName
= NULL
;
6568 clsW
.lpszClassName
= testWindowClassW
;
6569 RegisterClassW(&clsW
); /* ignore error, this fails on Win9x */
6574 static HHOOK hCBT_hook
;
6575 static DWORD cbt_hook_thread_id
;
6577 static LRESULT CALLBACK
cbt_hook_proc(int nCode
, WPARAM wParam
, LPARAM lParam
)
6579 static const char * const CBT_code_name
[10] = {
6586 "HCBT_CLICKSKIPPED",
6590 const char *code_name
= (nCode
>= 0 && nCode
<= HCBT_SETFOCUS
) ? CBT_code_name
[nCode
] : "Unknown";
6594 trace("CBT: %d (%s), %08lx, %08lx\n", nCode
, code_name
, wParam
, lParam
);
6596 ok(cbt_hook_thread_id
== GetCurrentThreadId(), "we didn't ask for events from other threads\n");
6598 if (nCode
== HCBT_CLICKSKIPPED
)
6600 /* ignore this event, XP sends it a lot when switching focus between windows */
6601 return CallNextHookEx(hCBT_hook
, nCode
, wParam
, lParam
);
6604 if (nCode
== HCBT_SYSCOMMAND
|| nCode
== HCBT_KEYSKIPPED
)
6608 msg
.message
= nCode
;
6609 msg
.flags
= hook
|wparam
|lparam
;
6610 msg
.wParam
= wParam
;
6611 msg
.lParam
= lParam
;
6614 return CallNextHookEx(hCBT_hook
, nCode
, wParam
, lParam
);
6617 if (nCode
== HCBT_DESTROYWND
)
6619 if (test_DestroyWindow_flag
)
6621 DWORD style
= GetWindowLongA((HWND
)wParam
, GWL_STYLE
);
6622 if (style
& WS_CHILD
)
6623 lParam
= GetWindowLongPtrA((HWND
)wParam
, GWLP_ID
);
6624 else if (style
& WS_POPUP
)
6625 lParam
= WND_POPUP_ID
;
6627 lParam
= WND_PARENT_ID
;
6631 /* Log also SetFocus(0) calls */
6632 hwnd
= wParam
? (HWND
)wParam
: (HWND
)lParam
;
6634 if (GetClassNameA(hwnd
, buf
, sizeof(buf
)))
6636 if (!lstrcmpiA(buf
, "TestWindowClass") ||
6637 !lstrcmpiA(buf
, "ShowWindowClass") ||
6638 !lstrcmpiA(buf
, "TestParentClass") ||
6639 !lstrcmpiA(buf
, "TestPopupClass") ||
6640 !lstrcmpiA(buf
, "SimpleWindowClass") ||
6641 !lstrcmpiA(buf
, "TestDialogClass") ||
6642 !lstrcmpiA(buf
, "MDI_frame_class") ||
6643 !lstrcmpiA(buf
, "MDI_client_class") ||
6644 !lstrcmpiA(buf
, "MDI_child_class") ||
6645 !lstrcmpiA(buf
, "my_button_class") ||
6646 !lstrcmpiA(buf
, "my_edit_class") ||
6647 !lstrcmpiA(buf
, "static") ||
6648 !lstrcmpiA(buf
, "ListBox") ||
6649 !lstrcmpiA(buf
, "MyDialogClass") ||
6650 !lstrcmpiA(buf
, "#32770"))
6654 msg
.message
= nCode
;
6655 msg
.flags
= hook
|wparam
|lparam
;
6656 msg
.wParam
= wParam
;
6657 msg
.lParam
= lParam
;
6661 return CallNextHookEx(hCBT_hook
, nCode
, wParam
, lParam
);
6664 static void CALLBACK
win_event_proc(HWINEVENTHOOK hevent
,
6674 trace("WEH:%p,event %08x,hwnd %p,obj %08x,id %08x,thread %08x,time %08x\n",
6675 hevent
, event
, hwnd
, object_id
, child_id
, thread_id
, event_time
);
6677 ok(thread_id
== GetCurrentThreadId(), "we didn't ask for events from other threads\n");
6679 /* ignore mouse cursor events */
6680 if (object_id
== OBJID_CURSOR
) return;
6682 if (!hwnd
|| GetClassNameA(hwnd
, buf
, sizeof(buf
)))
6685 !lstrcmpiA(buf
, "TestWindowClass") ||
6686 !lstrcmpiA(buf
, "TestParentClass") ||
6687 !lstrcmpiA(buf
, "TestPopupClass") ||
6688 !lstrcmpiA(buf
, "SimpleWindowClass") ||
6689 !lstrcmpiA(buf
, "TestDialogClass") ||
6690 !lstrcmpiA(buf
, "MDI_frame_class") ||
6691 !lstrcmpiA(buf
, "MDI_client_class") ||
6692 !lstrcmpiA(buf
, "MDI_child_class") ||
6693 !lstrcmpiA(buf
, "my_button_class") ||
6694 !lstrcmpiA(buf
, "my_edit_class") ||
6695 !lstrcmpiA(buf
, "static") ||
6696 !lstrcmpiA(buf
, "ListBox") ||
6697 !lstrcmpiA(buf
, "MyDialogClass") ||
6698 !lstrcmpiA(buf
, "#32770"))
6702 msg
.message
= event
;
6703 msg
.flags
= winevent_hook
|wparam
|lparam
;
6704 msg
.wParam
= object_id
;
6705 msg
.lParam
= child_id
;
6711 static const WCHAR wszUnicode
[] = {'U','n','i','c','o','d','e',0};
6712 static const WCHAR wszAnsi
[] = {'U',0};
6714 static LRESULT CALLBACK
MsgConversionProcW(HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
6718 case CB_FINDSTRINGEXACT
:
6719 trace("String: %p\n", (LPCWSTR
)lParam
);
6720 if (!lstrcmpW((LPCWSTR
)lParam
, wszUnicode
))
6722 if (!lstrcmpW((LPCWSTR
)lParam
, wszAnsi
))
6726 return DefWindowProcW(hwnd
, uMsg
, wParam
, lParam
);
6729 static const struct message WmGetTextLengthAfromW
[] = {
6730 { WM_GETTEXTLENGTH
, sent
},
6731 { WM_GETTEXT
, sent
},
6735 static const WCHAR dummy_window_text
[] = {'d','u','m','m','y',' ','t','e','x','t',0};
6737 /* dummy window proc for WM_GETTEXTLENGTH test */
6738 static LRESULT CALLBACK
get_text_len_proc( HWND hwnd
, UINT msg
, WPARAM wp
, LPARAM lp
)
6742 case WM_GETTEXTLENGTH
:
6743 return lstrlenW(dummy_window_text
) + 37; /* some random length */
6745 lstrcpynW( (LPWSTR
)lp
, dummy_window_text
, wp
);
6746 return lstrlenW( (LPWSTR
)lp
);
6748 return DefWindowProcW( hwnd
, msg
, wp
, lp
);
6752 static void test_message_conversion(void)
6754 static const WCHAR wszMsgConversionClass
[] =
6755 {'M','s','g','C','o','n','v','e','r','s','i','o','n','C','l','a','s','s',0};
6759 WNDPROC wndproc
, newproc
;
6763 cls
.lpfnWndProc
= MsgConversionProcW
;
6766 cls
.hInstance
= GetModuleHandleW(NULL
);
6768 cls
.hCursor
= LoadCursorW(NULL
, (LPWSTR
)IDC_ARROW
);
6769 cls
.hbrBackground
= (HBRUSH
)(COLOR_BTNFACE
+1);
6770 cls
.lpszMenuName
= NULL
;
6771 cls
.lpszClassName
= wszMsgConversionClass
;
6772 /* this call will fail on Win9x, but that doesn't matter as this test is
6773 * meaningless on those platforms */
6774 if(!RegisterClassW(&cls
)) return;
6776 hwnd
= CreateWindowExW(0, wszMsgConversionClass
, NULL
, WS_OVERLAPPED
,
6777 100, 100, 200, 200, 0, 0, 0, NULL
);
6778 ok(hwnd
!= NULL
, "Window creation failed\n");
6782 wndproc
= (WNDPROC
)GetWindowLongPtrA(hwnd
, GWLP_WNDPROC
);
6783 lRes
= CallWindowProcA(wndproc
, hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
6784 ok(lRes
== 0, "String should have been converted\n");
6785 lRes
= CallWindowProcW(wndproc
, hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
6786 ok(lRes
== 1, "String shouldn't have been converted\n");
6790 wndproc
= (WNDPROC
)GetWindowLongPtrW(hwnd
, GWLP_WNDPROC
);
6791 lRes
= CallWindowProcA(wndproc
, hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
6792 ok(lRes
== 1, "String shouldn't have been converted\n");
6793 lRes
= CallWindowProcW(wndproc
, hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
6794 ok(lRes
== 1, "String shouldn't have been converted\n");
6796 /* Synchronous messages */
6798 lRes
= SendMessageA(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
6799 ok(lRes
== 0, "String should have been converted\n");
6800 lRes
= SendMessageW(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
6801 ok(lRes
== 1, "String shouldn't have been converted\n");
6803 /* Asynchronous messages */
6806 lRes
= PostMessageA(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
6807 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
6808 "PostMessage on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
6810 lRes
= PostMessageW(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
6811 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
6812 "PostMessage on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
6814 lRes
= PostThreadMessageA(GetCurrentThreadId(), CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
6815 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
6816 "PosThreadtMessage on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
6818 lRes
= PostThreadMessageW(GetCurrentThreadId(), CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
6819 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
6820 "PosThreadtMessage on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
6822 lRes
= SendNotifyMessageA(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
6823 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
6824 "SendNotifyMessage on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
6826 lRes
= SendNotifyMessageW(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
6827 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
6828 "SendNotifyMessage on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
6830 lRes
= SendMessageCallbackA(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
, NULL
, 0);
6831 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
6832 "SendMessageCallback on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
6834 lRes
= SendMessageCallbackW(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
, NULL
, 0);
6835 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
6836 "SendMessageCallback on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
6838 /* Check WM_GETTEXTLENGTH A->W behaviour, whether WM_GETTEXT is also sent or not */
6840 hwnd
= CreateWindowW (testWindowClassW
, wszUnicode
,
6841 WS_OVERLAPPEDWINDOW
,
6842 100, 100, 200, 200, 0, 0, 0, NULL
);
6845 lRes
= SendMessageA (hwnd
, WM_GETTEXTLENGTH
, 0, 0);
6846 ok_sequence(WmGetTextLengthAfromW
, "ANSI WM_GETTEXTLENGTH to Unicode window", FALSE
);
6847 ok( lRes
== WideCharToMultiByte( CP_ACP
, 0, wszUnicode
, lstrlenW(wszUnicode
), NULL
, 0, NULL
, NULL
),
6848 "got bad length %ld\n", lRes
);
6851 lRes
= CallWindowProcA( (WNDPROC
)GetWindowLongPtrA( hwnd
, GWLP_WNDPROC
),
6852 hwnd
, WM_GETTEXTLENGTH
, 0, 0);
6853 ok_sequence(WmGetTextLengthAfromW
, "ANSI WM_GETTEXTLENGTH to Unicode window", FALSE
);
6854 ok( lRes
== WideCharToMultiByte( CP_ACP
, 0, wszUnicode
, lstrlenW(wszUnicode
), NULL
, 0, NULL
, NULL
),
6855 "got bad length %ld\n", lRes
);
6857 wndproc
= (WNDPROC
)SetWindowLongPtrW( hwnd
, GWLP_WNDPROC
, (LONG_PTR
)get_text_len_proc
);
6858 newproc
= (WNDPROC
)GetWindowLongPtrA( hwnd
, GWLP_WNDPROC
);
6859 lRes
= CallWindowProcA( newproc
, hwnd
, WM_GETTEXTLENGTH
, 0, 0 );
6860 ok( lRes
== WideCharToMultiByte( CP_ACP
, 0, dummy_window_text
, lstrlenW(dummy_window_text
),
6861 NULL
, 0, NULL
, NULL
),
6862 "got bad length %ld\n", lRes
);
6864 SetWindowLongPtrW( hwnd
, GWLP_WNDPROC
, (LONG_PTR
)wndproc
); /* restore old wnd proc */
6865 lRes
= CallWindowProcA( newproc
, hwnd
, WM_GETTEXTLENGTH
, 0, 0 );
6866 ok( lRes
== WideCharToMultiByte( CP_ACP
, 0, dummy_window_text
, lstrlenW(dummy_window_text
),
6867 NULL
, 0, NULL
, NULL
),
6868 "got bad length %ld\n", lRes
);
6870 ret
= DestroyWindow(hwnd
);
6871 ok( ret
, "DestroyWindow() error %d\n", GetLastError());
6881 static VOID CALLBACK
tfunc(HWND hwnd
, UINT uMsg
, UINT_PTR id
, DWORD dwTime
)
6885 #define TIMER_ID 0x19
6887 static DWORD WINAPI
timer_thread_proc(LPVOID x
)
6889 struct timer_info
*info
= x
;
6892 r
= KillTimer(info
->hWnd
, 0x19);
6893 ok(r
,"KillTimer failed in thread\n");
6894 r
= SetTimer(info
->hWnd
,TIMER_ID
,10000,tfunc
);
6895 ok(r
,"SetTimer failed in thread\n");
6896 ok(r
==TIMER_ID
,"SetTimer id different\n");
6897 r
= SetEvent(info
->handles
[0]);
6898 ok(r
,"SetEvent failed in thread\n");
6902 static void test_timers(void)
6904 struct timer_info info
;
6907 info
.hWnd
= CreateWindow ("TestWindowClass", NULL
,
6908 WS_OVERLAPPEDWINDOW
,
6909 CW_USEDEFAULT
, CW_USEDEFAULT
, 300, 300, 0,
6912 info
.id
= SetTimer(info
.hWnd
,TIMER_ID
,10000,tfunc
);
6913 ok(info
.id
, "SetTimer failed\n");
6914 ok(info
.id
==TIMER_ID
, "SetTimer timer ID different\n");
6915 info
.handles
[0] = CreateEvent(NULL
,0,0,NULL
);
6916 info
.handles
[1] = CreateThread(NULL
,0,timer_thread_proc
,&info
,0,&id
);
6918 WaitForMultipleObjects(2, info
.handles
, FALSE
, INFINITE
);
6920 WaitForSingleObject(info
.handles
[1], INFINITE
);
6922 CloseHandle(info
.handles
[0]);
6923 CloseHandle(info
.handles
[1]);
6925 ok( KillTimer(info
.hWnd
, TIMER_ID
), "KillTimer failed\n");
6927 ok(DestroyWindow(info
.hWnd
), "failed to destroy window\n");
6930 static int count
= 0;
6931 static VOID CALLBACK
callback_count(
6941 static void test_timers_no_wnd(void)
6947 id
= SetTimer(NULL
, 0, 100, callback_count
);
6948 ok(id
!= 0, "did not get id from SetTimer.\n");
6949 id2
= SetTimer(NULL
, id
, 200, callback_count
);
6950 ok(id2
== id
, "did not get same id from SetTimer when replacing (%li expected %li).\n", id2
, id
);
6952 while (PeekMessage(&msg
, NULL
, 0, 0, PM_REMOVE
)) DispatchMessage(&msg
);
6953 ok(count
== 0, "did not get zero count as expected (%i).\n", count
);
6955 while (PeekMessage(&msg
, NULL
, 0, 0, PM_REMOVE
)) DispatchMessage(&msg
);
6956 ok(count
== 1, "did not get one count as expected (%i).\n", count
);
6957 KillTimer(NULL
, id
);
6959 while (PeekMessage(&msg
, NULL
, 0, 0, PM_REMOVE
)) DispatchMessage(&msg
);
6960 ok(count
== 1, "killing replaced timer did not work (%i).\n", count
);
6963 /* Various win events with arbitrary parameters */
6964 static const struct message WmWinEventsSeq
[] = {
6965 { EVENT_SYSTEM_SOUND
, winevent_hook
|wparam
|lparam
, OBJID_WINDOW
, 0 },
6966 { EVENT_SYSTEM_ALERT
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 1 },
6967 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, OBJID_TITLEBAR
, 2 },
6968 { EVENT_SYSTEM_MENUSTART
, winevent_hook
|wparam
|lparam
, OBJID_MENU
, 3 },
6969 { EVENT_SYSTEM_MENUEND
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 4 },
6970 { EVENT_SYSTEM_MENUPOPUPSTART
, winevent_hook
|wparam
|lparam
, OBJID_VSCROLL
, 5 },
6971 { EVENT_SYSTEM_MENUPOPUPEND
, winevent_hook
|wparam
|lparam
, OBJID_HSCROLL
, 6 },
6972 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, OBJID_SIZEGRIP
, 7 },
6973 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 8 },
6974 /* our win event hook ignores OBJID_CURSOR events */
6975 /*{ EVENT_SYSTEM_MOVESIZESTART, winevent_hook|wparam|lparam, OBJID_CURSOR, 9 },*/
6976 { EVENT_SYSTEM_MOVESIZEEND
, winevent_hook
|wparam
|lparam
, OBJID_ALERT
, 10 },
6977 { EVENT_SYSTEM_CONTEXTHELPSTART
, winevent_hook
|wparam
|lparam
, OBJID_SOUND
, 11 },
6978 { EVENT_SYSTEM_CONTEXTHELPEND
, winevent_hook
|wparam
|lparam
, OBJID_QUERYCLASSNAMEIDX
, 12 },
6979 { EVENT_SYSTEM_DRAGDROPSTART
, winevent_hook
|wparam
|lparam
, OBJID_NATIVEOM
, 13 },
6980 { EVENT_SYSTEM_DRAGDROPEND
, winevent_hook
|wparam
|lparam
, OBJID_WINDOW
, 0 },
6981 { EVENT_SYSTEM_DIALOGSTART
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 1 },
6982 { EVENT_SYSTEM_DIALOGEND
, winevent_hook
|wparam
|lparam
, OBJID_TITLEBAR
, 2 },
6983 { EVENT_SYSTEM_SCROLLINGSTART
, winevent_hook
|wparam
|lparam
, OBJID_MENU
, 3 },
6984 { EVENT_SYSTEM_SCROLLINGEND
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 4 },
6985 { EVENT_SYSTEM_SWITCHSTART
, winevent_hook
|wparam
|lparam
, OBJID_VSCROLL
, 5 },
6986 { EVENT_SYSTEM_SWITCHEND
, winevent_hook
|wparam
|lparam
, OBJID_HSCROLL
, 6 },
6987 { EVENT_SYSTEM_MINIMIZESTART
, winevent_hook
|wparam
|lparam
, OBJID_SIZEGRIP
, 7 },
6988 { EVENT_SYSTEM_MINIMIZEEND
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 8 },
6991 static const struct message WmWinEventCaretSeq
[] = {
6992 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 1 */
6993 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 1 */
6994 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 2 */
6995 { EVENT_OBJECT_NAMECHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 1 */
6998 static const struct message WmWinEventCaretSeq_2
[] = {
6999 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 1/2 */
7000 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 1/2 */
7001 { EVENT_OBJECT_NAMECHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 1/2 */
7004 static const struct message WmWinEventAlertSeq
[] = {
7005 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_ALERT
, 0 },
7008 static const struct message WmWinEventAlertSeq_2
[] = {
7009 /* create window in the thread proc */
7010 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_WINDOW
, 2 },
7011 /* our test event */
7012 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_ALERT
, 2 },
7015 static const struct message WmGlobalHookSeq_1
[] = {
7016 /* create window in the thread proc */
7017 { HCBT_CREATEWND
, hook
|lparam
, 0, 2 },
7018 /* our test events */
7019 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_PREVWINDOW
, 2 },
7020 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_NEXTWINDOW
, 2 },
7023 static const struct message WmGlobalHookSeq_2
[] = {
7024 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_NEXTWINDOW
, 0 }, /* old local hook */
7025 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_NEXTWINDOW
, 2 }, /* new global hook */
7026 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_PREVWINDOW
, 0 }, /* old local hook */
7027 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_PREVWINDOW
, 2 }, /* new global hook */
7031 static const struct message WmMouseLLHookSeq
[] = {
7032 { WM_MOUSEMOVE
, hook
},
7033 { WM_LBUTTONUP
, hook
},
7034 { WM_MOUSEMOVE
, hook
},
7038 static void CALLBACK
win_event_global_hook_proc(HWINEVENTHOOK hevent
,
7048 trace("WEH_2:%p,event %08x,hwnd %p,obj %08x,id %08x,thread %08x,time %08x\n",
7049 hevent
, event
, hwnd
, object_id
, child_id
, thread_id
, event_time
);
7051 if (GetClassNameA(hwnd
, buf
, sizeof(buf
)))
7053 if (!lstrcmpiA(buf
, "TestWindowClass") ||
7054 !lstrcmpiA(buf
, "static"))
7058 msg
.message
= event
;
7059 msg
.flags
= winevent_hook
|wparam
|lparam
;
7060 msg
.wParam
= object_id
;
7061 msg
.lParam
= (thread_id
== GetCurrentThreadId()) ? child_id
: (child_id
+ 2);
7067 static HHOOK hCBT_global_hook
;
7068 static DWORD cbt_global_hook_thread_id
;
7070 static LRESULT CALLBACK
cbt_global_hook_proc(int nCode
, WPARAM wParam
, LPARAM lParam
)
7075 trace("CBT_2: %d, %08lx, %08lx\n", nCode
, wParam
, lParam
);
7077 if (nCode
== HCBT_SYSCOMMAND
)
7081 msg
.message
= nCode
;
7082 msg
.flags
= hook
|wparam
|lparam
;
7083 msg
.wParam
= wParam
;
7084 msg
.lParam
= (cbt_global_hook_thread_id
== GetCurrentThreadId()) ? 1 : 2;
7087 return CallNextHookEx(hCBT_global_hook
, nCode
, wParam
, lParam
);
7089 /* WH_MOUSE_LL hook */
7090 if (nCode
== HC_ACTION
)
7093 MSLLHOOKSTRUCT
*mhll
= (MSLLHOOKSTRUCT
*)lParam
;
7095 /* we can't test for real mouse events */
7096 if (mhll
->flags
& LLMHF_INJECTED
)
7098 msg
.message
= wParam
;
7102 return CallNextHookEx(hCBT_global_hook
, nCode
, wParam
, lParam
);
7105 /* Log also SetFocus(0) calls */
7106 hwnd
= wParam
? (HWND
)wParam
: (HWND
)lParam
;
7108 if (GetClassNameA(hwnd
, buf
, sizeof(buf
)))
7110 if (!lstrcmpiA(buf
, "TestWindowClass") ||
7111 !lstrcmpiA(buf
, "static"))
7115 msg
.message
= nCode
;
7116 msg
.flags
= hook
|wparam
|lparam
;
7117 msg
.wParam
= wParam
;
7118 msg
.lParam
= (cbt_global_hook_thread_id
== GetCurrentThreadId()) ? 1 : 2;
7122 return CallNextHookEx(hCBT_global_hook
, nCode
, wParam
, lParam
);
7125 static DWORD WINAPI
win_event_global_thread_proc(void *param
)
7129 HANDLE hevent
= *(HANDLE
*)param
;
7131 assert(pNotifyWinEvent
);
7133 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
, 0,0,0,0,0,0,0, NULL
);
7135 trace("created thread window %p\n", hwnd
);
7137 *(HWND
*)param
= hwnd
;
7140 /* this event should be received only by our new hook proc,
7141 * an old one does not expect an event from another thread.
7143 pNotifyWinEvent(EVENT_OBJECT_LOCATIONCHANGE
, hwnd
, OBJID_ALERT
, 0);
7146 while (GetMessage(&msg
, 0, 0, 0))
7148 TranslateMessage(&msg
);
7149 DispatchMessage(&msg
);
7154 static DWORD WINAPI
cbt_global_hook_thread_proc(void *param
)
7158 HANDLE hevent
= *(HANDLE
*)param
;
7161 /* these events should be received only by our new hook proc,
7162 * an old one does not expect an event from another thread.
7165 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
, 0,0,0,0,0,0,0, NULL
);
7167 trace("created thread window %p\n", hwnd
);
7169 *(HWND
*)param
= hwnd
;
7171 /* Windows doesn't like when a thread plays games with the focus,
7172 that leads to all kinds of misbehaviours and failures to activate
7173 a window. So, better keep next lines commented out.
7177 DefWindowProcA(hwnd
, WM_SYSCOMMAND
, SC_PREVWINDOW
, 0);
7178 DefWindowProcA(hwnd
, WM_SYSCOMMAND
, SC_NEXTWINDOW
, 0);
7182 while (GetMessage(&msg
, 0, 0, 0))
7184 TranslateMessage(&msg
);
7185 DispatchMessage(&msg
);
7190 static DWORD WINAPI
mouse_ll_global_thread_proc(void *param
)
7194 HANDLE hevent
= *(HANDLE
*)param
;
7196 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
, 0,0,0,0,0,0,0, NULL
);
7198 trace("created thread window %p\n", hwnd
);
7200 *(HWND
*)param
= hwnd
;
7204 /* Windows doesn't like when a thread plays games with the focus,
7205 * that leads to all kinds of misbehaviours and failures to activate
7206 * a window. So, better don't generate a mouse click message below.
7208 mouse_event(MOUSEEVENTF_MOVE
, -1, 0, 0, 0);
7209 mouse_event(MOUSEEVENTF_LEFTUP
, 0, 0, 0, 0);
7210 mouse_event(MOUSEEVENTF_MOVE
, 1, 0, 0, 0);
7213 while (GetMessage(&msg
, 0, 0, 0))
7215 TranslateMessage(&msg
);
7216 DispatchMessage(&msg
);
7221 static void test_winevents(void)
7227 HANDLE hthread
, hevent
;
7229 HWINEVENTHOOK hhook
;
7230 const struct message
*events
= WmWinEventsSeq
;
7232 hwnd
= CreateWindowExA(0, "TestWindowClass", NULL
,
7233 WS_OVERLAPPEDWINDOW
,
7234 CW_USEDEFAULT
, CW_USEDEFAULT
, 300, 300, 0,
7238 /****** start of global hook test *************/
7239 hCBT_global_hook
= SetWindowsHookExA(WH_CBT
, cbt_global_hook_proc
, GetModuleHandleA(0), 0);
7240 assert(hCBT_global_hook
);
7242 hevent
= CreateEventA(NULL
, 0, 0, NULL
);
7244 hwnd2
= (HWND
)hevent
;
7246 hthread
= CreateThread(NULL
, 0, cbt_global_hook_thread_proc
, &hwnd2
, 0, &tid
);
7247 ok(hthread
!= NULL
, "CreateThread failed, error %d\n", GetLastError());
7249 ok(WaitForSingleObject(hevent
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
7251 ok_sequence(WmGlobalHookSeq_1
, "global hook 1", FALSE
);
7254 /* this one should be received only by old hook proc */
7255 DefWindowProcA(hwnd
, WM_SYSCOMMAND
, SC_NEXTWINDOW
, 0);
7256 /* this one should be received only by old hook proc */
7257 DefWindowProcA(hwnd
, WM_SYSCOMMAND
, SC_PREVWINDOW
, 0);
7259 ok_sequence(WmGlobalHookSeq_2
, "global hook 2", FALSE
);
7261 ret
= UnhookWindowsHookEx(hCBT_global_hook
);
7262 ok( ret
, "UnhookWindowsHookEx error %d\n", GetLastError());
7264 PostThreadMessageA(tid
, WM_QUIT
, 0, 0);
7265 ok(WaitForSingleObject(hthread
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
7266 CloseHandle(hthread
);
7267 CloseHandle(hevent
);
7268 ok(!IsWindow(hwnd2
), "window should be destroyed on thread exit\n");
7269 /****** end of global hook test *************/
7271 if (!pSetWinEventHook
|| !pNotifyWinEvent
|| !pUnhookWinEvent
)
7273 ok(DestroyWindow(hwnd
), "failed to destroy window\n");
7281 /* this test doesn't pass under Win9x */
7282 /* win2k ignores events with hwnd == 0 */
7283 SetLastError(0xdeadbeef);
7284 pNotifyWinEvent(events
[0].message
, 0, events
[0].wParam
, events
[0].lParam
);
7285 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
|| /* Win2k */
7286 GetLastError() == 0xdeadbeef, /* Win9x */
7287 "unexpected error %d\n", GetLastError());
7288 ok_sequence(WmEmptySeq
, "empty notify winevents", FALSE
);
7291 for (i
= 0; i
< sizeof(WmWinEventsSeq
)/sizeof(WmWinEventsSeq
[0]); i
++)
7292 pNotifyWinEvent(events
[i
].message
, hwnd
, events
[i
].wParam
, events
[i
].lParam
);
7294 ok_sequence(WmWinEventsSeq
, "notify winevents", FALSE
);
7296 /****** start of event filtering test *************/
7297 hhook
= (HWINEVENTHOOK
)pSetWinEventHook(
7298 EVENT_OBJECT_SHOW
, /* 0x8002 */
7299 EVENT_OBJECT_LOCATIONCHANGE
, /* 0x800B */
7300 GetModuleHandleA(0), win_event_global_hook_proc
,
7301 GetCurrentProcessId(), 0,
7302 WINEVENT_INCONTEXT
);
7303 ok(hhook
!= 0, "SetWinEventHook error %d\n", GetLastError());
7305 hevent
= CreateEventA(NULL
, 0, 0, NULL
);
7307 hwnd2
= (HWND
)hevent
;
7309 hthread
= CreateThread(NULL
, 0, win_event_global_thread_proc
, &hwnd2
, 0, &tid
);
7310 ok(hthread
!= NULL
, "CreateThread failed, error %d\n", GetLastError());
7312 ok(WaitForSingleObject(hevent
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
7314 ok_sequence(WmWinEventAlertSeq
, "alert winevent", FALSE
);
7317 /* this one should be received only by old hook proc */
7318 pNotifyWinEvent(EVENT_OBJECT_CREATE
, hwnd
, OBJID_CARET
, 0); /* 0x8000 */
7319 pNotifyWinEvent(EVENT_OBJECT_SHOW
, hwnd
, OBJID_CARET
, 0); /* 0x8002 */
7320 /* this one should be received only by old hook proc */
7321 pNotifyWinEvent(EVENT_OBJECT_NAMECHANGE
, hwnd
, OBJID_CARET
, 0); /* 0x800C */
7323 ok_sequence(WmWinEventCaretSeq
, "caret winevent", FALSE
);
7325 ret
= pUnhookWinEvent(hhook
);
7326 ok( ret
, "UnhookWinEvent error %d\n", GetLastError());
7328 PostThreadMessageA(tid
, WM_QUIT
, 0, 0);
7329 ok(WaitForSingleObject(hthread
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
7330 CloseHandle(hthread
);
7331 CloseHandle(hevent
);
7332 ok(!IsWindow(hwnd2
), "window should be destroyed on thread exit\n");
7333 /****** end of event filtering test *************/
7335 /****** start of out of context event test *************/
7336 hhook
= (HWINEVENTHOOK
)pSetWinEventHook(
7337 EVENT_MIN
, EVENT_MAX
,
7338 0, win_event_global_hook_proc
,
7339 GetCurrentProcessId(), 0,
7340 WINEVENT_OUTOFCONTEXT
);
7341 ok(hhook
!= 0, "SetWinEventHook error %d\n", GetLastError());
7343 hevent
= CreateEventA(NULL
, 0, 0, NULL
);
7345 hwnd2
= (HWND
)hevent
;
7349 hthread
= CreateThread(NULL
, 0, win_event_global_thread_proc
, &hwnd2
, 0, &tid
);
7350 ok(hthread
!= NULL
, "CreateThread failed, error %d\n", GetLastError());
7352 ok(WaitForSingleObject(hevent
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
7354 ok_sequence(WmEmptySeq
, "empty notify winevents", FALSE
);
7355 /* process pending winevent messages */
7356 ok(!PeekMessageA(&msg
, 0, 0, 0, PM_NOREMOVE
), "msg queue should be empty\n");
7357 ok_sequence(WmWinEventAlertSeq_2
, "alert winevent for out of context proc", FALSE
);
7360 /* this one should be received only by old hook proc */
7361 pNotifyWinEvent(EVENT_OBJECT_CREATE
, hwnd
, OBJID_CARET
, 0); /* 0x8000 */
7362 pNotifyWinEvent(EVENT_OBJECT_SHOW
, hwnd
, OBJID_CARET
, 0); /* 0x8002 */
7363 /* this one should be received only by old hook proc */
7364 pNotifyWinEvent(EVENT_OBJECT_NAMECHANGE
, hwnd
, OBJID_CARET
, 0); /* 0x800C */
7366 ok_sequence(WmWinEventCaretSeq_2
, "caret winevent for incontext proc", FALSE
);
7367 /* process pending winevent messages */
7368 ok(!PeekMessageA(&msg
, 0, 0, 0, PM_NOREMOVE
), "msg queue should be empty\n");
7369 ok_sequence(WmWinEventCaretSeq_2
, "caret winevent for out of context proc", FALSE
);
7371 ret
= pUnhookWinEvent(hhook
);
7372 ok( ret
, "UnhookWinEvent error %d\n", GetLastError());
7374 PostThreadMessageA(tid
, WM_QUIT
, 0, 0);
7375 ok(WaitForSingleObject(hthread
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
7376 CloseHandle(hthread
);
7377 CloseHandle(hevent
);
7378 ok(!IsWindow(hwnd2
), "window should be destroyed on thread exit\n");
7379 /****** end of out of context event test *************/
7381 /****** start of MOUSE_LL hook test *************/
7382 hCBT_global_hook
= SetWindowsHookExA(WH_MOUSE_LL
, cbt_global_hook_proc
, GetModuleHandleA(0), 0);
7383 /* WH_MOUSE_LL is not supported on Win9x platforms */
7384 if (!hCBT_global_hook
)
7386 trace("Skipping WH_MOUSE_LL test on this platform\n");
7387 goto skip_mouse_ll_hook_test
;
7390 hevent
= CreateEventA(NULL
, 0, 0, NULL
);
7392 hwnd2
= (HWND
)hevent
;
7394 hthread
= CreateThread(NULL
, 0, mouse_ll_global_thread_proc
, &hwnd2
, 0, &tid
);
7395 ok(hthread
!= NULL
, "CreateThread failed, error %d\n", GetLastError());
7397 while (WaitForSingleObject(hevent
, 100) == WAIT_TIMEOUT
)
7398 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
7400 ok_sequence(WmMouseLLHookSeq
, "MOUSE_LL hook other thread", FALSE
);
7403 mouse_event(MOUSEEVENTF_MOVE
, -1, 0, 0, 0);
7404 mouse_event(MOUSEEVENTF_LEFTUP
, 0, 0, 0, 0);
7405 mouse_event(MOUSEEVENTF_MOVE
, 1, 0, 0, 0);
7407 ok_sequence(WmMouseLLHookSeq
, "MOUSE_LL hook same thread", FALSE
);
7409 ret
= UnhookWindowsHookEx(hCBT_global_hook
);
7410 ok( ret
, "UnhookWindowsHookEx error %d\n", GetLastError());
7412 PostThreadMessageA(tid
, WM_QUIT
, 0, 0);
7413 ok(WaitForSingleObject(hthread
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
7414 CloseHandle(hthread
);
7415 CloseHandle(hevent
);
7416 ok(!IsWindow(hwnd2
), "window should be destroyed on thread exit\n");
7417 /****** end of MOUSE_LL hook test *************/
7418 skip_mouse_ll_hook_test
:
7420 ok(DestroyWindow(hwnd
), "failed to destroy window\n");
7423 static void test_set_hook(void)
7427 HWINEVENTHOOK hwinevent_hook
;
7429 hhook
= SetWindowsHookExA(WH_CBT
, cbt_hook_proc
, GetModuleHandleA(0), GetCurrentThreadId());
7430 ok(hhook
!= 0, "local hook does not require hModule set to 0\n");
7431 UnhookWindowsHookEx(hhook
);
7435 /* this test doesn't pass under Win9x: BUG! */
7436 SetLastError(0xdeadbeef);
7437 hhook
= SetWindowsHookExA(WH_CBT
, cbt_hook_proc
, 0, 0);
7438 ok(!hhook
, "global hook requires hModule != 0\n");
7439 ok(GetLastError() == ERROR_HOOK_NEEDS_HMOD
, "unexpected error %d\n", GetLastError());
7442 SetLastError(0xdeadbeef);
7443 hhook
= SetWindowsHookExA(WH_CBT
, 0, GetModuleHandleA(0), GetCurrentThreadId());
7444 ok(!hhook
, "SetWinEventHook with invalid proc should fail\n");
7445 ok(GetLastError() == ERROR_INVALID_FILTER_PROC
|| /* Win2k */
7446 GetLastError() == 0xdeadbeef, /* Win9x */
7447 "unexpected error %d\n", GetLastError());
7449 SetLastError(0xdeadbeef);
7450 ok(!UnhookWindowsHookEx((HHOOK
)0xdeadbeef), "UnhookWindowsHookEx succeeded\n");
7451 ok(GetLastError() == ERROR_INVALID_HOOK_HANDLE
|| /* Win2k */
7452 GetLastError() == 0xdeadbeef, /* Win9x */
7453 "unexpected error %d\n", GetLastError());
7455 if (!pSetWinEventHook
|| !pUnhookWinEvent
) return;
7457 /* even process local incontext hooks require hmodule */
7458 SetLastError(0xdeadbeef);
7459 hwinevent_hook
= (HWINEVENTHOOK
)pSetWinEventHook(EVENT_MIN
, EVENT_MAX
,
7460 0, win_event_proc
, GetCurrentProcessId(), 0, WINEVENT_INCONTEXT
);
7461 ok(!hwinevent_hook
, "WINEVENT_INCONTEXT requires hModule != 0\n");
7462 ok(GetLastError() == ERROR_HOOK_NEEDS_HMOD
|| /* Win2k */
7463 GetLastError() == 0xdeadbeef, /* Win9x */
7464 "unexpected error %d\n", GetLastError());
7466 /* even thread local incontext hooks require hmodule */
7467 SetLastError(0xdeadbeef);
7468 hwinevent_hook
= (HWINEVENTHOOK
)pSetWinEventHook(EVENT_MIN
, EVENT_MAX
,
7469 0, win_event_proc
, GetCurrentProcessId(), GetCurrentThreadId(), WINEVENT_INCONTEXT
);
7470 ok(!hwinevent_hook
, "WINEVENT_INCONTEXT requires hModule != 0\n");
7471 ok(GetLastError() == ERROR_HOOK_NEEDS_HMOD
|| /* Win2k */
7472 GetLastError() == 0xdeadbeef, /* Win9x */
7473 "unexpected error %d\n", GetLastError());
7477 /* these 3 tests don't pass under Win9x */
7478 SetLastError(0xdeadbeef);
7479 hwinevent_hook
= (HWINEVENTHOOK
)pSetWinEventHook(1, 0,
7480 0, win_event_proc
, GetCurrentProcessId(), 0, WINEVENT_OUTOFCONTEXT
);
7481 ok(!hwinevent_hook
, "SetWinEventHook with invalid event range should fail\n");
7482 ok(GetLastError() == ERROR_INVALID_HOOK_FILTER
, "unexpected error %d\n", GetLastError());
7484 SetLastError(0xdeadbeef);
7485 hwinevent_hook
= (HWINEVENTHOOK
)pSetWinEventHook(-1, 1,
7486 0, win_event_proc
, GetCurrentProcessId(), 0, WINEVENT_OUTOFCONTEXT
);
7487 ok(!hwinevent_hook
, "SetWinEventHook with invalid event range should fail\n");
7488 ok(GetLastError() == ERROR_INVALID_HOOK_FILTER
, "unexpected error %d\n", GetLastError());
7490 SetLastError(0xdeadbeef);
7491 hwinevent_hook
= (HWINEVENTHOOK
)pSetWinEventHook(EVENT_MIN
, EVENT_MAX
,
7492 0, win_event_proc
, 0, 0xdeadbeef, WINEVENT_OUTOFCONTEXT
);
7493 ok(!hwinevent_hook
, "SetWinEventHook with invalid tid should fail\n");
7494 ok(GetLastError() == ERROR_INVALID_THREAD_ID
, "unexpected error %d\n", GetLastError());
7497 SetLastError(0xdeadbeef);
7498 hwinevent_hook
= (HWINEVENTHOOK
)pSetWinEventHook(0, 0,
7499 0, win_event_proc
, GetCurrentProcessId(), 0, WINEVENT_OUTOFCONTEXT
);
7500 ok(hwinevent_hook
!= 0, "SetWinEventHook error %d\n", GetLastError());
7501 ok(GetLastError() == 0xdeadbeef, "unexpected error %d\n", GetLastError());
7502 ret
= pUnhookWinEvent(hwinevent_hook
);
7503 ok( ret
, "UnhookWinEvent error %d\n", GetLastError());
7506 /* This call succeeds under win2k SP4, but fails under Wine.
7507 Does win2k test/use passed process id? */
7508 SetLastError(0xdeadbeef);
7509 hwinevent_hook
= (HWINEVENTHOOK
)pSetWinEventHook(EVENT_MIN
, EVENT_MAX
,
7510 0, win_event_proc
, 0xdeadbeef, 0, WINEVENT_OUTOFCONTEXT
);
7511 ok(hwinevent_hook
!= 0, "SetWinEventHook error %d\n", GetLastError());
7512 ok(GetLastError() == 0xdeadbeef, "unexpected error %d\n", GetLastError());
7513 ret
= pUnhookWinEvent(hwinevent_hook
);
7514 ok( ret
, "UnhookWinEvent error %d\n", GetLastError());
7517 SetLastError(0xdeadbeef);
7518 ok(!pUnhookWinEvent((HWINEVENTHOOK
)0xdeadbeef), "UnhookWinEvent succeeded\n");
7519 ok(GetLastError() == ERROR_INVALID_HANDLE
|| /* Win2k */
7520 GetLastError() == 0xdeadbeef, /* Win9x */
7521 "unexpected error %d\n", GetLastError());
7524 static const struct message ScrollWindowPaint1
[] = {
7526 { WM_ERASEBKGND
, sent
|beginpaint
},
7530 static const struct message ScrollWindowPaint2
[] = {
7535 static void test_scrollwindowex(void)
7538 RECT rect
={0,0,130,130};
7540 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test Scroll",
7541 WS_VISIBLE
|WS_OVERLAPPEDWINDOW
,
7542 100, 100, 200, 200, 0, 0, 0, NULL
);
7543 ok (hwnd
!= 0, "Failed to create overlapped window\n");
7544 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child",
7545 WS_VISIBLE
|WS_CAPTION
|WS_CHILD
,
7546 10, 10, 150, 150, hwnd
, 0, 0, NULL
);
7547 ok (hchild
!= 0, "Failed to create child\n");
7552 /* scroll without the child window */
7553 trace("start scroll\n");
7554 ScrollWindowEx( hwnd
, 10, 10, &rect
, NULL
, NULL
, NULL
,
7555 SW_ERASE
|SW_INVALIDATE
);
7556 ok_sequence(WmEmptySeq
, "ScrollWindowEx", 0);
7557 trace("end scroll\n");
7560 ok_sequence(ScrollWindowPaint1
, "ScrollWindowEx", 0);
7564 /* Now without the SW_ERASE flag */
7565 trace("start scroll\n");
7566 ScrollWindowEx( hwnd
, 10, 10, &rect
, NULL
, NULL
, NULL
, SW_INVALIDATE
);
7567 ok_sequence(WmEmptySeq
, "ScrollWindowEx", 0);
7568 trace("end scroll\n");
7571 ok_sequence(ScrollWindowPaint2
, "ScrollWindowEx", 0);
7575 /* now scroll the child window as well */
7576 trace("start scroll\n");
7577 ScrollWindowEx( hwnd
, 10, 10, &rect
, NULL
, NULL
, NULL
,
7578 SW_SCROLLCHILDREN
|SW_ERASE
|SW_INVALIDATE
);
7579 todo_wine
{ /* wine sends WM_POSCHANGING, WM_POSCHANGED messages */
7580 /* windows sometimes a WM_MOVE */
7581 ok_sequence(WmEmptySeq
, "ScrollWindowEx", 0);
7583 trace("end scroll\n");
7586 ok_sequence(ScrollWindowPaint1
, "ScrollWindowEx", 0);
7590 /* now scroll with ScrollWindow() */
7591 trace("start scroll with ScrollWindow\n");
7592 ScrollWindow( hwnd
, 5, 5, NULL
, NULL
);
7593 trace("end scroll\n");
7596 ok_sequence(ScrollWindowPaint1
, "ScrollWindow", 0);
7598 ok(DestroyWindow(hchild
), "failed to destroy window\n");
7599 ok(DestroyWindow(hwnd
), "failed to destroy window\n");
7603 static const struct message destroy_window_with_children
[] = {
7604 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* popup */
7605 { HCBT_DESTROYWND
, hook
|lparam
, 0, WND_PARENT_ID
}, /* parent */
7606 { HCBT_DESTROYWND
, hook
|lparam
, 0, WND_POPUP_ID
}, /* popup */
7607 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* popup */
7608 { WM_DESTROY
, sent
|wparam
|lparam
, 0, WND_POPUP_ID
}, /* popup */
7609 { WM_CAPTURECHANGED
, sent
|wparam
|lparam
, 0, WND_POPUP_ID
}, /* popup */
7610 { WM_NCDESTROY
, sent
|wparam
|lparam
, 0, WND_POPUP_ID
}, /* popup */
7611 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* parent */
7612 { WM_DESTROY
, sent
|wparam
|lparam
, 0, WND_PARENT_ID
}, /* parent */
7613 { WM_DESTROY
, sent
|wparam
|lparam
, 0, WND_CHILD_ID
+ 2 }, /* child2 */
7614 { WM_DESTROY
, sent
|wparam
|lparam
, 0, WND_CHILD_ID
+ 1 }, /* child1 */
7615 { WM_DESTROY
, sent
|wparam
|lparam
, 0, WND_CHILD_ID
+ 3 }, /* child3 */
7616 { WM_NCDESTROY
, sent
|wparam
|lparam
, 0, WND_CHILD_ID
+ 2 }, /* child2 */
7617 { WM_NCDESTROY
, sent
|wparam
|lparam
, 0, WND_CHILD_ID
+ 3 }, /* child3 */
7618 { WM_NCDESTROY
, sent
|wparam
|lparam
, 0, WND_CHILD_ID
+ 1 }, /* child1 */
7619 { WM_NCDESTROY
, sent
|wparam
|lparam
, 0, WND_PARENT_ID
}, /* parent */
7623 static void test_DestroyWindow(void)
7626 HWND parent
, child1
, child2
, child3
, child4
, test
;
7627 UINT child_id
= WND_CHILD_ID
+ 1;
7629 parent
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
7630 100, 100, 200, 200, 0, 0, 0, NULL
);
7631 assert(parent
!= 0);
7632 child1
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_CHILD
,
7633 0, 0, 50, 50, parent
, (HMENU
)child_id
++, 0, NULL
);
7634 assert(child1
!= 0);
7635 child2
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_CHILD
,
7636 0, 0, 50, 50, GetDesktopWindow(), (HMENU
)child_id
++, 0, NULL
);
7637 assert(child2
!= 0);
7638 child3
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_CHILD
,
7639 0, 0, 50, 50, child1
, (HMENU
)child_id
++, 0, NULL
);
7640 assert(child3
!= 0);
7641 child4
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_POPUP
,
7642 0, 0, 50, 50, parent
, 0, 0, NULL
);
7643 assert(child4
!= 0);
7645 /* test owner/parent of child2 */
7646 test
= GetParent(child2
);
7647 ok(test
== GetDesktopWindow(), "wrong parent %p\n", test
);
7648 ok(!IsChild(parent
, child2
), "wrong parent/child %p/%p\n", parent
, child2
);
7650 test
= pGetAncestor(child2
, GA_PARENT
);
7651 ok(test
== GetDesktopWindow(), "wrong parent %p\n", test
);
7653 test
= GetWindow(child2
, GW_OWNER
);
7654 ok(!test
, "wrong owner %p\n", test
);
7656 test
= SetParent(child2
, parent
);
7657 ok(test
== GetDesktopWindow(), "wrong old parent %p\n", test
);
7659 /* test owner/parent of the parent */
7660 test
= GetParent(parent
);
7661 ok(!test
, "wrong parent %p\n", test
);
7662 ok(!IsChild(GetDesktopWindow(), parent
), "wrong parent/child %p/%p\n", GetDesktopWindow(), parent
);
7664 test
= pGetAncestor(parent
, GA_PARENT
);
7665 ok(test
== GetDesktopWindow(), "wrong parent %p\n", test
);
7667 test
= GetWindow(parent
, GW_OWNER
);
7668 ok(!test
, "wrong owner %p\n", test
);
7670 /* test owner/parent of child1 */
7671 test
= GetParent(child1
);
7672 ok(test
== parent
, "wrong parent %p\n", test
);
7673 ok(IsChild(parent
, child1
), "wrong parent/child %p/%p\n", parent
, child1
);
7675 test
= pGetAncestor(child1
, GA_PARENT
);
7676 ok(test
== parent
, "wrong parent %p\n", test
);
7678 test
= GetWindow(child1
, GW_OWNER
);
7679 ok(!test
, "wrong owner %p\n", test
);
7681 /* test owner/parent of child2 */
7682 test
= GetParent(child2
);
7683 ok(test
== parent
, "wrong parent %p\n", test
);
7684 ok(IsChild(parent
, child2
), "wrong parent/child %p/%p\n", parent
, child2
);
7686 test
= pGetAncestor(child2
, GA_PARENT
);
7687 ok(test
== parent
, "wrong parent %p\n", test
);
7689 test
= GetWindow(child2
, GW_OWNER
);
7690 ok(!test
, "wrong owner %p\n", test
);
7692 /* test owner/parent of child3 */
7693 test
= GetParent(child3
);
7694 ok(test
== child1
, "wrong parent %p\n", test
);
7695 ok(IsChild(parent
, child3
), "wrong parent/child %p/%p\n", parent
, child3
);
7697 test
= pGetAncestor(child3
, GA_PARENT
);
7698 ok(test
== child1
, "wrong parent %p\n", test
);
7700 test
= GetWindow(child3
, GW_OWNER
);
7701 ok(!test
, "wrong owner %p\n", test
);
7703 /* test owner/parent of child4 */
7704 test
= GetParent(child4
);
7705 ok(test
== parent
, "wrong parent %p\n", test
);
7706 ok(!IsChild(parent
, child4
), "wrong parent/child %p/%p\n", parent
, child4
);
7708 test
= pGetAncestor(child4
, GA_PARENT
);
7709 ok(test
== GetDesktopWindow(), "wrong parent %p\n", test
);
7711 test
= GetWindow(child4
, GW_OWNER
);
7712 ok(test
== parent
, "wrong owner %p\n", test
);
7716 trace("parent %p, child1 %p, child2 %p, child3 %p, child4 %p\n",
7717 parent
, child1
, child2
, child3
, child4
);
7720 test
= GetCapture();
7721 ok(test
== child4
, "wrong capture window %p\n", test
);
7723 test_DestroyWindow_flag
= TRUE
;
7724 ret
= DestroyWindow(parent
);
7725 ok( ret
, "DestroyWindow() error %d\n", GetLastError());
7726 test_DestroyWindow_flag
= FALSE
;
7727 ok_sequence(destroy_window_with_children
, "destroy window with children", 0);
7729 ok(!IsWindow(parent
), "parent still exists\n");
7730 ok(!IsWindow(child1
), "child1 still exists\n");
7731 ok(!IsWindow(child2
), "child2 still exists\n");
7732 ok(!IsWindow(child3
), "child3 still exists\n");
7733 ok(!IsWindow(child4
), "child4 still exists\n");
7735 test
= GetCapture();
7736 ok(!test
, "wrong capture window %p\n", test
);
7740 static const struct message WmDispatchPaint
[] = {
7741 { WM_NCPAINT
, sent
},
7742 { WM_GETTEXT
, sent
|defwinproc
|optional
},
7743 { WM_GETTEXT
, sent
|defwinproc
|optional
},
7744 { WM_ERASEBKGND
, sent
},
7748 static LRESULT WINAPI
DispatchMessageCheckProc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
7750 if (message
== WM_PAINT
) return 0;
7751 return MsgCheckProcA( hwnd
, message
, wParam
, lParam
);
7754 static void test_DispatchMessage(void)
7759 HWND hwnd
= CreateWindowA( "TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
7760 100, 100, 200, 200, 0, 0, 0, NULL
);
7761 ShowWindow( hwnd
, SW_SHOW
);
7762 UpdateWindow( hwnd
);
7765 SetWindowLongPtrA( hwnd
, GWLP_WNDPROC
, (LONG_PTR
)DispatchMessageCheckProc
);
7767 SetRect( &rect
, -5, -5, 5, 5 );
7768 RedrawWindow( hwnd
, &rect
, 0, RDW_INVALIDATE
|RDW_ERASE
|RDW_FRAME
);
7770 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
))
7772 if (msg
.message
!= WM_PAINT
) DispatchMessage( &msg
);
7776 DispatchMessage( &msg
);
7777 /* DispatchMessage will send WM_NCPAINT if non client area is still invalid after WM_PAINT */
7778 if (!count
) ok_sequence( WmDispatchPaint
, "WmDispatchPaint", FALSE
);
7779 else ok_sequence( WmEmptySeq
, "WmEmpty", FALSE
);
7780 if (++count
> 10) break;
7783 ok( msg
.message
== WM_PAINT
&& count
> 10, "WM_PAINT messages stopped\n" );
7785 trace("now without DispatchMessage\n");
7787 RedrawWindow( hwnd
, &rect
, 0, RDW_INVALIDATE
|RDW_ERASE
|RDW_FRAME
);
7789 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
))
7791 if (msg
.message
!= WM_PAINT
) DispatchMessage( &msg
);
7794 HRGN hrgn
= CreateRectRgn( 0, 0, 0, 0 );
7796 /* this will send WM_NCCPAINT just like DispatchMessage does */
7797 GetUpdateRgn( hwnd
, hrgn
, TRUE
);
7798 ok_sequence( WmDispatchPaint
, "WmDispatchPaint", FALSE
);
7799 DeleteObject( hrgn
);
7800 GetClientRect( hwnd
, &rect
);
7801 ValidateRect( hwnd
, &rect
); /* this will stop WM_PAINTs */
7802 ok( !count
, "Got multiple WM_PAINTs\n" );
7803 if (++count
> 10) break;
7806 DestroyWindow(hwnd
);
7810 static const struct message WmUser
[] = {
7822 static DWORD CALLBACK
send_msg_thread( LPVOID arg
)
7824 struct sendmsg_info
*info
= arg
;
7825 info
->ret
= SendMessageTimeoutA( info
->hwnd
, WM_USER
, 0, 0, 0, info
->timeout
, NULL
);
7826 if (!info
->ret
) ok( GetLastError() == ERROR_TIMEOUT
, "unexpected error %d\n", GetLastError());
7830 static void wait_for_thread( HANDLE thread
)
7832 while (MsgWaitForMultipleObjects(1, &thread
, FALSE
, INFINITE
, QS_SENDMESSAGE
) != WAIT_OBJECT_0
)
7835 while (PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage(&msg
);
7839 static LRESULT WINAPI
send_msg_delay_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
7841 if (message
== WM_USER
) Sleep(200);
7842 return MsgCheckProcA( hwnd
, message
, wParam
, lParam
);
7845 static void test_SendMessageTimeout(void)
7848 struct sendmsg_info info
;
7851 info
.hwnd
= CreateWindowA( "TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
7852 100, 100, 200, 200, 0, 0, 0, NULL
);
7856 info
.timeout
= 1000;
7857 info
.ret
= 0xdeadbeef;
7858 thread
= CreateThread( NULL
, 0, send_msg_thread
, &info
, 0, &tid
);
7859 wait_for_thread( thread
);
7860 CloseHandle( thread
);
7861 ok( info
.ret
== 1, "SendMessageTimeout failed\n" );
7862 ok_sequence( WmUser
, "WmUser", FALSE
);
7865 info
.ret
= 0xdeadbeef;
7866 thread
= CreateThread( NULL
, 0, send_msg_thread
, &info
, 0, &tid
);
7867 Sleep(100); /* SendMessageTimeout should timeout here */
7868 wait_for_thread( thread
);
7869 CloseHandle( thread
);
7870 ok( info
.ret
== 0, "SendMessageTimeout succeeded\n" );
7871 ok_sequence( WmEmptySeq
, "WmEmptySeq", FALSE
);
7873 /* 0 means infinite timeout */
7875 info
.ret
= 0xdeadbeef;
7876 thread
= CreateThread( NULL
, 0, send_msg_thread
, &info
, 0, &tid
);
7878 wait_for_thread( thread
);
7879 CloseHandle( thread
);
7880 ok( info
.ret
== 1, "SendMessageTimeout failed\n" );
7881 ok_sequence( WmUser
, "WmUser", FALSE
);
7883 /* timeout is treated as signed despite the prototype */
7884 info
.timeout
= 0x7fffffff;
7885 info
.ret
= 0xdeadbeef;
7886 thread
= CreateThread( NULL
, 0, send_msg_thread
, &info
, 0, &tid
);
7888 wait_for_thread( thread
);
7889 CloseHandle( thread
);
7890 ok( info
.ret
== 1, "SendMessageTimeout failed\n" );
7891 ok_sequence( WmUser
, "WmUser", FALSE
);
7893 info
.timeout
= 0x80000000;
7894 info
.ret
= 0xdeadbeef;
7895 thread
= CreateThread( NULL
, 0, send_msg_thread
, &info
, 0, &tid
);
7897 wait_for_thread( thread
);
7898 CloseHandle( thread
);
7899 ok( info
.ret
== 0, "SendMessageTimeout succeeded\n" );
7900 ok_sequence( WmEmptySeq
, "WmEmptySeq", FALSE
);
7902 /* now check for timeout during message processing */
7903 SetWindowLongPtrA( info
.hwnd
, GWLP_WNDPROC
, (LONG_PTR
)send_msg_delay_proc
);
7905 info
.ret
= 0xdeadbeef;
7906 thread
= CreateThread( NULL
, 0, send_msg_thread
, &info
, 0, &tid
);
7907 wait_for_thread( thread
);
7908 CloseHandle( thread
);
7909 /* we should timeout but still get the message */
7910 ok( info
.ret
== 0, "SendMessageTimeout failed\n" );
7911 ok_sequence( WmUser
, "WmUser", FALSE
);
7913 DestroyWindow( info
.hwnd
);
7917 /****************** edit message test *************************/
7918 #define ID_EDIT 0x1234
7919 static const struct message sl_edit_setfocus
[] =
7921 { HCBT_SETFOCUS
, hook
},
7922 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
7923 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
7924 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
7925 { WM_SETFOCUS
, sent
|wparam
, 0 },
7926 { WM_CTLCOLOREDIT
, sent
|parent
},
7927 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
7928 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
7929 { WM_COMMAND
, sent
|parent
|wparam
, MAKEWPARAM(ID_EDIT
, EN_SETFOCUS
) },
7932 static const struct message ml_edit_setfocus
[] =
7934 { HCBT_SETFOCUS
, hook
},
7935 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
7936 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
7937 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
7938 { WM_SETFOCUS
, sent
|wparam
, 0 },
7939 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
7940 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
7941 { WM_COMMAND
, sent
|parent
|wparam
, MAKEWPARAM(ID_EDIT
, EN_SETFOCUS
) },
7944 static const struct message sl_edit_killfocus
[] =
7946 { HCBT_SETFOCUS
, hook
},
7947 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
7948 { WM_KILLFOCUS
, sent
|wparam
, 0 },
7949 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
7950 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
7951 { WM_COMMAND
, sent
|parent
|wparam
, MAKEWPARAM(ID_EDIT
, EN_KILLFOCUS
) },
7952 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
7953 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 1 },
7956 static const struct message sl_edit_lbutton_dblclk
[] =
7958 { WM_LBUTTONDBLCLK
, sent
},
7959 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
7962 static const struct message sl_edit_lbutton_down
[] =
7964 { WM_LBUTTONDOWN
, sent
|wparam
|lparam
, 0, 0 },
7965 { HCBT_SETFOCUS
, hook
},
7966 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
7967 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
7968 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
7969 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
7970 { WM_CTLCOLOREDIT
, sent
|parent
},
7971 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
7972 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
7973 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
7974 { WM_COMMAND
, sent
|parent
|wparam
, MAKEWPARAM(ID_EDIT
, EN_SETFOCUS
) },
7975 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
7976 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
7977 { WM_CTLCOLOREDIT
, sent
|parent
|optional
},
7978 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
7979 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
7982 static const struct message ml_edit_lbutton_down
[] =
7984 { WM_LBUTTONDOWN
, sent
|wparam
|lparam
, 0, 0 },
7985 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
7986 { HCBT_SETFOCUS
, hook
},
7987 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
7988 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
7989 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
7990 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
7991 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
7992 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
7993 { WM_COMMAND
, sent
|parent
|wparam
, MAKEWPARAM(ID_EDIT
, EN_SETFOCUS
) },
7996 static const struct message sl_edit_lbutton_up
[] =
7998 { WM_LBUTTONUP
, sent
|wparam
|lparam
, 0, 0 },
7999 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
8000 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, 0, 0 },
8001 { WM_CAPTURECHANGED
, sent
|defwinproc
},
8002 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
8005 static const struct message ml_edit_lbutton_up
[] =
8007 { WM_LBUTTONUP
, sent
|wparam
|lparam
, 0, 0 },
8008 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, 0, 0 },
8009 { WM_CAPTURECHANGED
, sent
|defwinproc
},
8013 static WNDPROC old_edit_proc
;
8015 static LRESULT CALLBACK
edit_hook_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
8017 static long defwndproc_counter
= 0;
8021 trace("edit: %p, %04x, %08lx, %08lx\n", hwnd
, message
, wParam
, lParam
);
8023 /* explicitly ignore WM_GETICON message */
8024 if (message
== WM_GETICON
) return 0;
8026 msg
.message
= message
;
8027 msg
.flags
= sent
|wparam
|lparam
;
8028 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
8029 msg
.wParam
= wParam
;
8030 msg
.lParam
= lParam
;
8033 defwndproc_counter
++;
8034 ret
= CallWindowProcA(old_edit_proc
, hwnd
, message
, wParam
, lParam
);
8035 defwndproc_counter
--;
8040 static void subclass_edit(void)
8044 if (!GetClassInfoA(0, "edit", &cls
)) assert(0);
8046 old_edit_proc
= cls
.lpfnWndProc
;
8048 cls
.hInstance
= GetModuleHandle(0);
8049 cls
.lpfnWndProc
= edit_hook_proc
;
8050 cls
.lpszClassName
= "my_edit_class";
8051 UnregisterClass(cls
.lpszClassName
, cls
.hInstance
);
8052 if (!RegisterClassA(&cls
)) assert(0);
8055 static void test_edit_messages(void)
8061 log_all_parent_messages
++;
8063 parent
= CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
8064 100, 100, 200, 200, 0, 0, 0, NULL
);
8065 ok (parent
!= 0, "Failed to create parent window\n");
8067 /* test single line edit */
8068 hwnd
= CreateWindowExA(0, "my_edit_class", "test", WS_CHILD
,
8069 0, 0, 80, 20, parent
, (HMENU
)ID_EDIT
, 0, NULL
);
8070 ok(hwnd
!= 0, "Failed to create edit window\n");
8072 dlg_code
= SendMessageA(hwnd
, WM_GETDLGCODE
, 0, 0);
8073 ok(dlg_code
== (DLGC_WANTCHARS
|DLGC_HASSETSEL
|DLGC_WANTARROWS
), "wrong dlg_code %08x\n", dlg_code
);
8075 ShowWindow(hwnd
, SW_SHOW
);
8081 ok_sequence(sl_edit_setfocus
, "SetFocus(hwnd) on an edit", FALSE
);
8084 ok_sequence(sl_edit_killfocus
, "SetFocus(0) on an edit", FALSE
);
8090 SendMessageA(hwnd
, WM_LBUTTONDBLCLK
, 0, 0);
8091 ok_sequence(sl_edit_lbutton_dblclk
, "WM_LBUTTONDBLCLK on an edit", FALSE
);
8097 SendMessageA(hwnd
, WM_LBUTTONDOWN
, 0, 0);
8098 ok_sequence(sl_edit_lbutton_down
, "WM_LBUTTONDOWN on an edit", FALSE
);
8100 SendMessageA(hwnd
, WM_LBUTTONUP
, 0, 0);
8101 ok_sequence(sl_edit_lbutton_up
, "WM_LBUTTONUP on an edit", FALSE
);
8103 DestroyWindow(hwnd
);
8105 /* test multiline edit */
8106 hwnd
= CreateWindowExA(0, "my_edit_class", "test", WS_CHILD
| ES_MULTILINE
,
8107 0, 0, 80, 20, parent
, (HMENU
)ID_EDIT
, 0, NULL
);
8108 ok(hwnd
!= 0, "Failed to create edit window\n");
8110 dlg_code
= SendMessageA(hwnd
, WM_GETDLGCODE
, 0, 0);
8111 ok(dlg_code
== (DLGC_WANTCHARS
|DLGC_HASSETSEL
|DLGC_WANTARROWS
|DLGC_WANTALLKEYS
),
8112 "wrong dlg_code %08x\n", dlg_code
);
8114 ShowWindow(hwnd
, SW_SHOW
);
8120 ok_sequence(ml_edit_setfocus
, "SetFocus(hwnd) on multiline edit", FALSE
);
8123 ok_sequence(sl_edit_killfocus
, "SetFocus(0) on multiline edit", FALSE
);
8129 SendMessageA(hwnd
, WM_LBUTTONDBLCLK
, 0, 0);
8130 ok_sequence(sl_edit_lbutton_dblclk
, "WM_LBUTTONDBLCLK on multiline edit", FALSE
);
8136 SendMessageA(hwnd
, WM_LBUTTONDOWN
, 0, 0);
8137 ok_sequence(ml_edit_lbutton_down
, "WM_LBUTTONDOWN on multiline edit", FALSE
);
8139 SendMessageA(hwnd
, WM_LBUTTONUP
, 0, 0);
8140 ok_sequence(ml_edit_lbutton_up
, "WM_LBUTTONUP on multiline edit", FALSE
);
8142 DestroyWindow(hwnd
);
8143 DestroyWindow(parent
);
8145 log_all_parent_messages
--;
8148 /**************************** End of Edit test ******************************/
8150 static const struct message WmKeyDownSkippedSeq
[] =
8152 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 1 }, /* XP */
8155 static const struct message WmKeyUpSkippedSeq
[] =
8157 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xc0000001 }, /* XP */
8161 #define EV_START_STOP 0
8162 #define EV_SENDMSG 1
8168 HANDLE hevent
[3]; /* 0 - start/stop, 1 - SendMessage, 2 - ack */
8171 static DWORD CALLBACK
send_msg_thread_2(void *param
)
8174 struct peekmsg_info
*info
= param
;
8176 trace("thread: waiting for start\n");
8177 WaitForSingleObject(info
->hevent
[EV_START_STOP
], INFINITE
);
8178 trace("thread: looping\n");
8182 ret
= WaitForMultipleObjects(2, info
->hevent
, FALSE
, INFINITE
);
8186 case WAIT_OBJECT_0
+ EV_START_STOP
:
8187 trace("thread: exiting\n");
8190 case WAIT_OBJECT_0
+ EV_SENDMSG
:
8191 trace("thread: sending message\n");
8192 SendNotifyMessageA(info
->hwnd
, WM_USER
, 0, 0);
8193 SetEvent(info
->hevent
[EV_ACK
]);
8197 trace("unexpected return: %04x\n", ret
);
8205 static void test_PeekMessage(void)
8210 UINT qs_all_input
= QS_ALLINPUT
;
8211 UINT qs_input
= QS_INPUT
;
8213 struct peekmsg_info info
;
8215 info
.hwnd
= CreateWindowA("TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
8216 100, 100, 200, 200, 0, 0, 0, NULL
);
8218 ShowWindow(info
.hwnd
, SW_SHOW
);
8219 UpdateWindow(info
.hwnd
);
8220 SetFocus(info
.hwnd
);
8222 info
.hevent
[EV_START_STOP
] = CreateEventA(NULL
, 0, 0, NULL
);
8223 info
.hevent
[EV_SENDMSG
] = CreateEventA(NULL
, 0, 0, NULL
);
8224 info
.hevent
[EV_ACK
] = CreateEventA(NULL
, 0, 0, NULL
);
8226 hthread
= CreateThread(NULL
, 0, send_msg_thread_2
, &info
, 0, &tid
);
8229 trace("signalling to start looping\n");
8230 SetEvent(info
.hevent
[EV_START_STOP
]);
8235 SetLastError(0xdeadbeef);
8236 qstatus
= GetQueueStatus(qs_all_input
);
8237 if (GetLastError() == ERROR_INVALID_FLAGS
)
8239 trace("QS_RAWINPUT not supported on this platform\n");
8240 qs_all_input
&= ~QS_RAWINPUT
;
8241 qs_input
&= ~QS_RAWINPUT
;
8243 ok(qstatus
== 0, "wrong qstatus %08x\n", qstatus
);
8245 trace("signalling to send message\n");
8246 SetEvent(info
.hevent
[EV_SENDMSG
]);
8247 WaitForSingleObject(info
.hevent
[EV_ACK
], INFINITE
);
8249 /* pass invalid QS_xxxx flags */
8250 SetLastError(0xdeadbeef);
8251 qstatus
= GetQueueStatus(0xffffffff);
8252 ok(qstatus
== 0, "GetQueueStatus should fail: %08x\n", qstatus
);
8253 ok(GetLastError() == ERROR_INVALID_FLAGS
, "wrong error %d\n", GetLastError());
8255 qstatus
= GetQueueStatus(qs_all_input
);
8256 ok(qstatus
== MAKELONG(QS_SENDMESSAGE
, QS_SENDMESSAGE
),
8257 "wrong qstatus %08x\n", qstatus
);
8260 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
8262 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8264 ok_sequence(WmUser
, "WmUser", FALSE
);
8266 qstatus
= GetQueueStatus(qs_all_input
);
8267 ok(qstatus
== 0, "wrong qstatus %08x\n", qstatus
);
8269 keybd_event('N', 0, 0, 0);
8270 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
8271 qstatus
= GetQueueStatus(qs_all_input
);
8272 ok(qstatus
== MAKELONG(QS_KEY
, QS_KEY
),
8273 "wrong qstatus %08x\n", qstatus
);
8275 PostMessageA(info
.hwnd
, WM_CHAR
, 'z', 0);
8276 qstatus
= GetQueueStatus(qs_all_input
);
8277 ok(qstatus
== MAKELONG(QS_POSTMESSAGE
, QS_POSTMESSAGE
|QS_KEY
),
8278 "wrong qstatus %08x\n", qstatus
);
8280 InvalidateRect(info
.hwnd
, NULL
, FALSE
);
8281 qstatus
= GetQueueStatus(qs_all_input
);
8282 ok(qstatus
== MAKELONG(QS_PAINT
, QS_PAINT
|QS_POSTMESSAGE
|QS_KEY
),
8283 "wrong qstatus %08x\n", qstatus
);
8285 trace("signalling to send message\n");
8286 SetEvent(info
.hevent
[EV_SENDMSG
]);
8287 WaitForSingleObject(info
.hevent
[EV_ACK
], INFINITE
);
8289 qstatus
= GetQueueStatus(qs_all_input
);
8290 ok(qstatus
== MAKELONG(QS_SENDMESSAGE
, QS_SENDMESSAGE
|QS_PAINT
|QS_POSTMESSAGE
|QS_KEY
),
8291 "wrong qstatus %08x\n", qstatus
);
8294 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| (qs_input
<< 16));
8296 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8298 ok_sequence(WmUser
, "WmUser", FALSE
);
8300 qstatus
= GetQueueStatus(qs_all_input
);
8301 ok(qstatus
== MAKELONG(0, QS_PAINT
|QS_POSTMESSAGE
|QS_KEY
),
8302 "wrong qstatus %08x\n", qstatus
);
8304 trace("signalling to send message\n");
8305 SetEvent(info
.hevent
[EV_SENDMSG
]);
8306 WaitForSingleObject(info
.hevent
[EV_ACK
], INFINITE
);
8308 qstatus
= GetQueueStatus(qs_all_input
);
8309 ok(qstatus
== MAKELONG(QS_SENDMESSAGE
, QS_SENDMESSAGE
|QS_PAINT
|QS_POSTMESSAGE
|QS_KEY
),
8310 "wrong qstatus %08x\n", qstatus
);
8313 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| PM_QS_POSTMESSAGE
);
8315 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8317 ok_sequence(WmUser
, "WmUser", FALSE
);
8319 qstatus
= GetQueueStatus(qs_all_input
);
8320 ok(qstatus
== MAKELONG(0, QS_PAINT
|QS_POSTMESSAGE
|QS_KEY
),
8321 "wrong qstatus %08x\n", qstatus
);
8324 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| PM_QS_POSTMESSAGE
);
8325 ok(ret
&& msg
.message
== WM_CHAR
&& msg
.wParam
== 'z',
8326 "got %d and %04x wParam %08lx instead of TRUE and WM_CHAR wParam 'z'\n",
8327 ret
, msg
.message
, msg
.wParam
);
8328 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
8330 qstatus
= GetQueueStatus(qs_all_input
);
8331 ok(qstatus
== MAKELONG(0, QS_PAINT
|QS_KEY
),
8332 "wrong qstatus %08x\n", qstatus
);
8335 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| PM_QS_POSTMESSAGE
);
8337 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8339 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
8341 qstatus
= GetQueueStatus(qs_all_input
);
8342 ok(qstatus
== MAKELONG(0, QS_PAINT
|QS_KEY
),
8343 "wrong qstatus %08x\n", qstatus
);
8346 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| PM_QS_PAINT
);
8347 ok(ret
&& msg
.message
== WM_PAINT
,
8348 "got %d and %04x instead of TRUE and WM_PAINT\n", ret
, msg
.message
);
8349 DispatchMessageA(&msg
);
8350 ok_sequence(WmPaint
, "WmPaint", FALSE
);
8352 qstatus
= GetQueueStatus(qs_all_input
);
8353 ok(qstatus
== MAKELONG(0, QS_KEY
),
8354 "wrong qstatus %08x\n", qstatus
);
8357 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| PM_QS_PAINT
);
8359 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8361 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
8363 qstatus
= GetQueueStatus(qs_all_input
);
8364 ok(qstatus
== MAKELONG(0, QS_KEY
),
8365 "wrong qstatus %08x\n", qstatus
);
8367 trace("signalling to send message\n");
8368 SetEvent(info
.hevent
[EV_SENDMSG
]);
8369 WaitForSingleObject(info
.hevent
[EV_ACK
], INFINITE
);
8371 qstatus
= GetQueueStatus(qs_all_input
);
8372 ok(qstatus
== MAKELONG(QS_SENDMESSAGE
, QS_SENDMESSAGE
|QS_KEY
),
8373 "wrong qstatus %08x\n", qstatus
);
8375 PostMessageA(info
.hwnd
, WM_CHAR
, 'z', 0);
8377 qstatus
= GetQueueStatus(qs_all_input
);
8378 ok(qstatus
== MAKELONG(QS_POSTMESSAGE
, QS_SENDMESSAGE
|QS_POSTMESSAGE
|QS_KEY
),
8379 "wrong qstatus %08x\n", qstatus
);
8382 ret
= PeekMessageA(&msg
, 0, WM_CHAR
, WM_CHAR
, PM_REMOVE
);
8383 ok(ret
&& msg
.message
== WM_CHAR
&& msg
.wParam
== 'z',
8384 "got %d and %04x wParam %08lx instead of TRUE and WM_CHAR wParam 'z'\n",
8385 ret
, msg
.message
, msg
.wParam
);
8386 ok_sequence(WmUser
, "WmUser", FALSE
);
8388 qstatus
= GetQueueStatus(qs_all_input
);
8389 ok(qstatus
== MAKELONG(0, QS_KEY
),
8390 "wrong qstatus %08x\n", qstatus
);
8393 ret
= PeekMessageA(&msg
, 0, WM_CHAR
, WM_CHAR
, PM_REMOVE
);
8395 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8397 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
8399 qstatus
= GetQueueStatus(qs_all_input
);
8400 ok(qstatus
== MAKELONG(0, QS_KEY
),
8401 "wrong qstatus %08x\n", qstatus
);
8403 PostMessageA(info
.hwnd
, WM_CHAR
, 'z', 0);
8405 qstatus
= GetQueueStatus(qs_all_input
);
8406 ok(qstatus
== MAKELONG(QS_POSTMESSAGE
, QS_POSTMESSAGE
|QS_KEY
),
8407 "wrong qstatus %08x\n", qstatus
);
8409 trace("signalling to send message\n");
8410 SetEvent(info
.hevent
[EV_SENDMSG
]);
8411 WaitForSingleObject(info
.hevent
[EV_ACK
], INFINITE
);
8413 qstatus
= GetQueueStatus(qs_all_input
);
8414 ok(qstatus
== MAKELONG(QS_SENDMESSAGE
, QS_SENDMESSAGE
|QS_POSTMESSAGE
|QS_KEY
),
8415 "wrong qstatus %08x\n", qstatus
);
8418 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| (QS_KEY
<< 16));
8420 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8422 ok_sequence(WmUser
, "WmUser", FALSE
);
8424 qstatus
= GetQueueStatus(qs_all_input
);
8425 ok(qstatus
== MAKELONG(0, QS_POSTMESSAGE
|QS_KEY
),
8426 "wrong qstatus %08x\n", qstatus
);
8429 if (qs_all_input
& QS_RAWINPUT
) /* use QS_RAWINPUT only if supported */
8430 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| (QS_RAWINPUT
<< 16));
8431 else /* workaround for a missing QS_RAWINPUT support */
8432 ret
= PeekMessageA(&msg
, 0, WM_KEYDOWN
, WM_KEYDOWN
, PM_REMOVE
);
8433 ok(ret
&& msg
.message
== WM_KEYDOWN
&& msg
.wParam
== 'N',
8434 "got %d and %04x wParam %08lx instead of TRUE and WM_KEYDOWN wParam 'N'\n",
8435 ret
, msg
.message
, msg
.wParam
);
8436 ok_sequence(WmKeyDownSkippedSeq
, "WmKeyDownSkippedSeq", FALSE
);
8438 qstatus
= GetQueueStatus(qs_all_input
);
8439 ok(qstatus
== MAKELONG(0, QS_POSTMESSAGE
|QS_KEY
),
8440 "wrong qstatus %08x\n", qstatus
);
8443 if (qs_all_input
& QS_RAWINPUT
) /* use QS_RAWINPUT only if supported */
8444 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| (QS_RAWINPUT
<< 16));
8445 else /* workaround for a missing QS_RAWINPUT support */
8446 ret
= PeekMessageA(&msg
, 0, WM_KEYUP
, WM_KEYUP
, PM_REMOVE
);
8447 ok(ret
&& msg
.message
== WM_KEYUP
&& msg
.wParam
== 'N',
8448 "got %d and %04x wParam %08lx instead of TRUE and WM_KEYUP wParam 'N'\n",
8449 ret
, msg
.message
, msg
.wParam
);
8450 ok_sequence(WmKeyUpSkippedSeq
, "WmKeyUpSkippedSeq", FALSE
);
8452 qstatus
= GetQueueStatus(qs_all_input
);
8453 ok(qstatus
== MAKELONG(0, QS_POSTMESSAGE
),
8454 "wrong qstatus %08x\n", qstatus
);
8457 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| PM_QS_SENDMESSAGE
);
8459 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8461 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
8463 qstatus
= GetQueueStatus(qs_all_input
);
8464 ok(qstatus
== MAKELONG(0, QS_POSTMESSAGE
),
8465 "wrong qstatus %08x\n", qstatus
);
8468 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
8469 ok(ret
&& msg
.message
== WM_CHAR
&& msg
.wParam
== 'z',
8470 "got %d and %04x wParam %08lx instead of TRUE and WM_CHAR wParam 'z'\n",
8471 ret
, msg
.message
, msg
.wParam
);
8472 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
8474 qstatus
= GetQueueStatus(qs_all_input
);
8476 "wrong qstatus %08x\n", qstatus
);
8479 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
8481 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8483 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
8485 qstatus
= GetQueueStatus(qs_all_input
);
8487 "wrong qstatus %08x\n", qstatus
);
8489 /* test whether presence of the quit flag in the queue affects
8492 PostQuitMessage(0x1234abcd);
8494 qstatus
= GetQueueStatus(qs_all_input
);
8495 ok(qstatus
== MAKELONG(QS_POSTMESSAGE
, QS_POSTMESSAGE
),
8496 "wrong qstatus %08x\n", qstatus
);
8498 PostMessageA(info
.hwnd
, WM_USER
, 0, 0);
8500 qstatus
= GetQueueStatus(qs_all_input
);
8501 ok(qstatus
== MAKELONG(QS_POSTMESSAGE
, QS_POSTMESSAGE
),
8502 "wrong qstatus %08x\n", qstatus
);
8505 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
8506 ok(ret
&& msg
.message
== WM_USER
,
8507 "got %d and %04x instead of TRUE and WM_USER\n", ret
, msg
.message
);
8508 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
8510 qstatus
= GetQueueStatus(qs_all_input
);
8511 ok(qstatus
== MAKELONG(0, QS_POSTMESSAGE
),
8512 "wrong qstatus %08x\n", qstatus
);
8515 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
8516 ok(ret
&& msg
.message
== WM_QUIT
,
8517 "got %d and %04x instead of TRUE and WM_QUIT\n", ret
, msg
.message
);
8518 ok(msg
.wParam
== 0x1234abcd, "got wParam %08lx instead of 0x1234abcd\n", msg
.wParam
);
8519 ok(msg
.lParam
== 0, "got lParam %08lx instead of 0\n", msg
.lParam
);
8520 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
8522 qstatus
= GetQueueStatus(qs_all_input
);
8524 ok(qstatus
== MAKELONG(0, QS_POSTMESSAGE
),
8525 "wrong qstatus %08x\n", qstatus
);
8529 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
8531 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8533 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
8535 qstatus
= GetQueueStatus(qs_all_input
);
8537 "wrong qstatus %08x\n", qstatus
);
8539 trace("signalling to exit\n");
8540 SetEvent(info
.hevent
[EV_START_STOP
]);
8542 WaitForSingleObject(hthread
, INFINITE
);
8544 CloseHandle(hthread
);
8545 CloseHandle(info
.hevent
[0]);
8546 CloseHandle(info
.hevent
[1]);
8547 CloseHandle(info
.hevent
[2]);
8549 DestroyWindow(info
.hwnd
);
8552 static void wait_move_event(HWND hwnd
, int x
, int y
)
8559 time
= GetTickCount();
8560 while (GetTickCount() - time
< 200 && !go
) {
8561 ret
= PeekMessageA(&msg
, hwnd
, WM_MOUSEMOVE
, WM_MOUSEMOVE
, PM_NOREMOVE
);
8562 go
= ret
&& msg
.pt
.x
> x
&& msg
.pt
.y
> y
;
8567 static void test_PeekMessage2(void)
8573 DWORD time1
, time2
, time3
;
8574 int x1
, y1
, x2
, y2
, x3
, y3
;
8577 time1
= time2
= time3
= 0;
8578 x1
= y1
= x2
= y2
= x3
= y3
= 0;
8580 /* Initialise window and make sure it is ready for events */
8581 hwnd
= CreateWindow("TestWindowClass", "PeekMessage2", WS_OVERLAPPEDWINDOW
,
8582 10, 10, 800, 800, NULL
, NULL
, NULL
, NULL
);
8584 trace("Window for test_PeekMessage2 %p\n", hwnd
);
8585 ShowWindow(hwnd
, SW_SHOW
);
8589 SetCursorPos(100, 100);
8590 mouse_event(MOUSEEVENTF_MOVE
, -STEP
, -STEP
, 0, 0);
8593 /* Do initial mousemove, wait until we can see it
8594 and then do our test peek with PM_NOREMOVE. */
8595 mouse_event(MOUSEEVENTF_MOVE
, STEP
, STEP
, 0, 0);
8596 wait_move_event(hwnd
, 80, 80);
8598 ret
= PeekMessageA(&msg
, hwnd
, WM_MOUSEMOVE
, WM_MOUSEMOVE
, PM_NOREMOVE
);
8599 ok(ret
, "no message available\n");
8601 trace("1st move event: %04x %x %d %d\n", msg
.message
, msg
.time
, msg
.pt
.x
, msg
.pt
.y
);
8602 message
= msg
.message
;
8606 ok(message
== WM_MOUSEMOVE
, "message not WM_MOUSEMOVE, %04x instead\n", message
);
8609 /* Allow time to advance a bit, and then simulate the user moving their
8610 * mouse around. After that we peek again with PM_NOREMOVE.
8611 * Although the previous mousemove message was never removed, the
8612 * mousemove we now peek should reflect the recent mouse movements
8613 * because the input queue will merge the move events. */
8615 mouse_event(MOUSEEVENTF_MOVE
, STEP
, STEP
, 0, 0);
8616 wait_move_event(hwnd
, x1
, y1
);
8618 ret
= PeekMessageA(&msg
, hwnd
, WM_MOUSEMOVE
, WM_MOUSEMOVE
, PM_NOREMOVE
);
8619 ok(ret
, "no message available\n");
8621 trace("2nd move event: %04x %x %d %d\n", msg
.message
, msg
.time
, msg
.pt
.x
, msg
.pt
.y
);
8622 message
= msg
.message
;
8626 ok(message
== WM_MOUSEMOVE
, "message not WM_MOUSEMOVE, %04x instead\n", message
);
8627 ok(time2
> time1
, "message time not advanced: %x %x\n", time1
, time2
);
8628 ok(x2
!= x1
&& y2
!= y1
, "coords not changed: (%d %d) (%d %d)\n", x1
, y1
, x2
, y2
);
8631 /* Have another go, to drive the point home */
8633 mouse_event(MOUSEEVENTF_MOVE
, STEP
, STEP
, 0, 0);
8634 wait_move_event(hwnd
, x2
, y2
);
8636 ret
= PeekMessageA(&msg
, hwnd
, WM_MOUSEMOVE
, WM_MOUSEMOVE
, PM_NOREMOVE
);
8637 ok(ret
, "no message available\n");
8639 trace("3rd move event: %04x %x %d %d\n", msg
.message
, msg
.time
, msg
.pt
.x
, msg
.pt
.y
);
8640 message
= msg
.message
;
8644 ok(message
== WM_MOUSEMOVE
, "message not WM_MOUSEMOVE, %04x instead\n", message
);
8645 ok(time3
> time2
, "message time not advanced: %x %x\n", time2
, time3
);
8646 ok(x3
!= x2
&& y3
!= y2
, "coords not changed: (%d %d) (%d %d)\n", x2
, y2
, x3
, y3
);
8649 DestroyWindow(hwnd
);
8650 SetCursorPos(pos
.x
, pos
.y
);
8654 static void test_quit_message(void)
8659 /* test using PostQuitMessage */
8660 PostQuitMessage(0xbeef);
8662 ret
= PeekMessage(&msg
, NULL
, 0, 0, PM_NOREMOVE
);
8663 ok(ret
, "PeekMessage failed with error %d\n", GetLastError());
8664 ok(msg
.message
== WM_QUIT
, "Received message 0x%04x instead of WM_QUIT\n", msg
.message
);
8665 ok(msg
.wParam
== 0xbeef, "wParam was 0x%lx instead of 0xbeef\n", msg
.wParam
);
8667 ret
= PostThreadMessage(GetCurrentThreadId(), WM_USER
, 0, 0);
8668 ok(ret
, "PostMessage failed with error %d\n", GetLastError());
8670 ret
= GetMessage(&msg
, NULL
, 0, 0);
8671 ok(ret
> 0, "GetMessage failed with error %d\n", GetLastError());
8672 ok(msg
.message
== WM_USER
, "Received message 0x%04x instead of WM_USER\n", msg
.message
);
8674 /* note: WM_QUIT message received after WM_USER message */
8675 ret
= GetMessage(&msg
, NULL
, 0, 0);
8676 ok(!ret
, "GetMessage return %d with error %d instead of FALSE\n", ret
, GetLastError());
8677 ok(msg
.message
== WM_QUIT
, "Received message 0x%04x instead of WM_QUIT\n", msg
.message
);
8678 ok(msg
.wParam
== 0xbeef, "wParam was 0x%lx instead of 0xbeef\n", msg
.wParam
);
8680 ret
= PeekMessage(&msg
, NULL
, 0, 0, PM_REMOVE
);
8681 ok( !ret
|| msg
.message
!= WM_QUIT
, "Received WM_QUIT again\n" );
8683 /* now test with PostThreadMessage - different behaviour! */
8684 PostThreadMessage(GetCurrentThreadId(), WM_QUIT
, 0xdead, 0);
8686 ret
= PeekMessage(&msg
, NULL
, 0, 0, PM_NOREMOVE
);
8687 ok(ret
, "PeekMessage failed with error %d\n", GetLastError());
8688 ok(msg
.message
== WM_QUIT
, "Received message 0x%04x instead of WM_QUIT\n", msg
.message
);
8689 ok(msg
.wParam
== 0xdead, "wParam was 0x%lx instead of 0xdead\n", msg
.wParam
);
8691 ret
= PostThreadMessage(GetCurrentThreadId(), WM_USER
, 0, 0);
8692 ok(ret
, "PostMessage failed with error %d\n", GetLastError());
8694 /* note: we receive the WM_QUIT message first this time */
8695 ret
= GetMessage(&msg
, NULL
, 0, 0);
8696 ok(!ret
, "GetMessage return %d with error %d instead of FALSE\n", ret
, GetLastError());
8697 ok(msg
.message
== WM_QUIT
, "Received message 0x%04x instead of WM_QUIT\n", msg
.message
);
8698 ok(msg
.wParam
== 0xdead, "wParam was 0x%lx instead of 0xdead\n", msg
.wParam
);
8700 ret
= GetMessage(&msg
, NULL
, 0, 0);
8701 ok(ret
> 0, "GetMessage failed with error %d\n", GetLastError());
8702 ok(msg
.message
== WM_USER
, "Received message 0x%04x instead of WM_USER\n", msg
.message
);
8705 static const struct message WmMouseHoverSeq
[] = {
8706 { WM_MOUSEACTIVATE
, sent
|optional
}, /* we can get those when moving the mouse in focus-follow-mouse mode under X11 */
8707 { WM_MOUSEACTIVATE
, sent
|optional
},
8708 { WM_TIMER
, sent
|optional
}, /* XP sends it */
8709 { WM_SYSTIMER
, sent
},
8710 { WM_MOUSEHOVER
, sent
|wparam
, 0 },
8714 static void pump_msg_loop_timeout(DWORD timeout
, BOOL inject_mouse_move
)
8717 DWORD start_ticks
, end_ticks
;
8719 start_ticks
= GetTickCount();
8720 /* add some deviation (5%) to cover not expected delays */
8721 start_ticks
+= timeout
/ 20;
8725 while (PeekMessage(&msg
, 0, 0, 0, PM_REMOVE
))
8727 /* Timer proc messages are not dispatched to the window proc,
8728 * and therefore not logged.
8730 if (msg
.message
== WM_TIMER
|| msg
.message
== WM_SYSTIMER
)
8732 struct message s_msg
;
8734 s_msg
.message
= msg
.message
;
8735 s_msg
.flags
= sent
|wparam
|lparam
;
8736 s_msg
.wParam
= msg
.wParam
;
8737 s_msg
.lParam
= msg
.lParam
;
8738 add_message(&s_msg
);
8740 DispatchMessage(&msg
);
8743 end_ticks
= GetTickCount();
8745 /* inject WM_MOUSEMOVE to see how it changes tracking */
8746 if (inject_mouse_move
&& start_ticks
+ timeout
/ 2 >= end_ticks
)
8748 mouse_event(MOUSEEVENTF_MOVE
, -1, 0, 0, 0);
8749 mouse_event(MOUSEEVENTF_MOVE
, 1, 0, 0, 0);
8751 inject_mouse_move
= FALSE
;
8753 } while (start_ticks
+ timeout
>= end_ticks
);
8756 static void test_TrackMouseEvent(void)
8758 TRACKMOUSEEVENT tme
;
8761 RECT rc_parent
, rc_child
;
8762 UINT default_hover_time
, hover_width
= 0, hover_height
= 0;
8764 #define track_hover(track_hwnd, track_hover_time) \
8765 tme.cbSize = sizeof(tme); \
8766 tme.dwFlags = TME_HOVER; \
8767 tme.hwndTrack = track_hwnd; \
8768 tme.dwHoverTime = track_hover_time; \
8769 SetLastError(0xdeadbeef); \
8770 ret = pTrackMouseEvent(&tme); \
8771 ok(ret, "TrackMouseEvent(TME_HOVER) error %d\n", GetLastError())
8773 #define track_query(expected_track_flags, expected_track_hwnd, expected_hover_time) \
8774 tme.cbSize = sizeof(tme); \
8775 tme.dwFlags = TME_QUERY; \
8776 tme.hwndTrack = (HWND)0xdeadbeef; \
8777 tme.dwHoverTime = 0xdeadbeef; \
8778 SetLastError(0xdeadbeef); \
8779 ret = pTrackMouseEvent(&tme); \
8780 ok(ret, "TrackMouseEvent(TME_QUERY) error %d\n", GetLastError());\
8781 ok(tme.cbSize == sizeof(tme), "wrong tme.cbSize %u\n", tme.cbSize); \
8782 ok(tme.dwFlags == (expected_track_flags), \
8783 "wrong tme.dwFlags %08x, expected %08x\n", tme.dwFlags, (expected_track_flags)); \
8784 ok(tme.hwndTrack == (expected_track_hwnd), \
8785 "wrong tme.hwndTrack %p, expected %p\n", tme.hwndTrack, (expected_track_hwnd)); \
8786 ok(tme.dwHoverTime == (expected_hover_time), \
8787 "wrong tme.dwHoverTime %u, expected %u\n", tme.dwHoverTime, (expected_hover_time))
8789 #define track_hover_cancel(track_hwnd) \
8790 tme.cbSize = sizeof(tme); \
8791 tme.dwFlags = TME_HOVER | TME_CANCEL; \
8792 tme.hwndTrack = track_hwnd; \
8793 tme.dwHoverTime = 0xdeadbeef; \
8794 SetLastError(0xdeadbeef); \
8795 ret = pTrackMouseEvent(&tme); \
8796 ok(ret, "TrackMouseEvent(TME_HOVER | TME_CANCEL) error %d\n", GetLastError())
8798 default_hover_time
= 0xdeadbeef;
8799 SetLastError(0xdeadbeef);
8800 ret
= SystemParametersInfo(SPI_GETMOUSEHOVERTIME
, 0, &default_hover_time
, 0);
8801 ok(ret
, "SystemParametersInfo(SPI_GETMOUSEHOVERTIME) error %u\n", GetLastError());
8802 if (!ret
) default_hover_time
= 400;
8803 trace("SPI_GETMOUSEHOVERTIME returned %u ms\n", default_hover_time
);
8805 SetLastError(0xdeadbeef);
8806 ret
= SystemParametersInfo(SPI_GETMOUSEHOVERWIDTH
, 0, &hover_width
, 0);
8807 ok(ret
, "SystemParametersInfo(SPI_GETMOUSEHOVERWIDTH) error %u\n", GetLastError());
8808 if (!ret
) hover_width
= 4;
8809 SetLastError(0xdeadbeef);
8810 ret
= SystemParametersInfo(SPI_GETMOUSEHOVERHEIGHT
, 0, &hover_height
, 0);
8811 ok(ret
, "SystemParametersInfo(SPI_GETMOUSEHOVERHEIGHT) error %u\n", GetLastError());
8812 if (!ret
) hover_height
= 4;
8813 trace("hover rect is %u x %d\n", hover_width
, hover_height
);
8815 hwnd
= CreateWindowEx(0, "TestWindowClass", NULL
,
8816 WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
8817 CW_USEDEFAULT
, CW_USEDEFAULT
, 300, 300, 0,
8821 hchild
= CreateWindowEx(0, "TestWindowClass", NULL
,
8822 WS_CHILD
| WS_BORDER
| WS_VISIBLE
,
8823 50, 50, 200, 200, hwnd
,
8831 tme
.dwFlags
= TME_QUERY
;
8832 tme
.hwndTrack
= (HWND
)0xdeadbeef;
8833 tme
.dwHoverTime
= 0xdeadbeef;
8834 SetLastError(0xdeadbeef);
8835 ret
= pTrackMouseEvent(&tme
);
8836 ok(!ret
, "TrackMouseEvent should fail\n");
8837 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "not expected error %d\n", GetLastError());
8839 tme
.cbSize
= sizeof(tme
);
8840 tme
.dwFlags
= TME_HOVER
;
8841 tme
.hwndTrack
= (HWND
)0xdeadbeef;
8842 tme
.dwHoverTime
= 0xdeadbeef;
8843 SetLastError(0xdeadbeef);
8844 ret
= pTrackMouseEvent(&tme
);
8845 ok(!ret
, "TrackMouseEvent should fail\n");
8846 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
, "not expected error %d\n", GetLastError());
8848 tme
.cbSize
= sizeof(tme
);
8849 tme
.dwFlags
= TME_HOVER
| TME_CANCEL
;
8850 tme
.hwndTrack
= (HWND
)0xdeadbeef;
8851 tme
.dwHoverTime
= 0xdeadbeef;
8852 SetLastError(0xdeadbeef);
8853 ret
= pTrackMouseEvent(&tme
);
8854 ok(!ret
, "TrackMouseEvent should fail\n");
8855 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
, "not expected error %d\n", GetLastError());
8857 GetWindowRect(hwnd
, &rc_parent
);
8858 GetWindowRect(hchild
, &rc_child
);
8859 SetCursorPos(rc_child
.left
- 10, rc_child
.top
- 10);
8861 /* Process messages so that the system updates its internal current
8862 * window and hittest, otherwise TrackMouseEvent calls don't have any
8868 track_query(0, NULL
, 0);
8869 track_hover(hchild
, 0);
8870 track_query(0, NULL
, 0);
8875 track_hover(hwnd
, 0);
8876 track_query(TME_HOVER
, hwnd
, default_hover_time
);
8878 pump_msg_loop_timeout(default_hover_time
, FALSE
);
8879 ok_sequence(WmMouseHoverSeq
, "WmMouseHoverSeq", FALSE
);
8881 track_query(0, NULL
, 0);
8883 track_hover(hwnd
, HOVER_DEFAULT
);
8884 track_query(TME_HOVER
, hwnd
, default_hover_time
);
8886 Sleep(default_hover_time
/ 2);
8887 mouse_event(MOUSEEVENTF_MOVE
, -1, 0, 0, 0);
8888 mouse_event(MOUSEEVENTF_MOVE
, 1, 0, 0, 0);
8890 track_query(TME_HOVER
, hwnd
, default_hover_time
);
8892 pump_msg_loop_timeout(default_hover_time
/ 2, FALSE
);
8893 ok_sequence(WmMouseHoverSeq
, "WmMouseHoverSeq", FALSE
);
8895 track_query(0, NULL
, 0);
8897 track_hover(hwnd
, HOVER_DEFAULT
);
8898 track_query(TME_HOVER
, hwnd
, default_hover_time
);
8900 pump_msg_loop_timeout(default_hover_time
, TRUE
);
8901 ok_sequence(WmMouseHoverSeq
, "WmMouseHoverSeq", FALSE
);
8903 track_query(0, NULL
, 0);
8905 track_hover(hwnd
, HOVER_DEFAULT
);
8906 track_query(TME_HOVER
, hwnd
, default_hover_time
);
8907 track_hover_cancel(hwnd
);
8909 DestroyWindow(hwnd
);
8913 #undef track_hover_cancel
8917 static const struct message WmSetWindowRgn
[] = {
8918 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
},
8919 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
8920 { WM_NCPAINT
, sent
}, /* wparam != 1 */
8921 { WM_GETTEXT
, sent
|defwinproc
|optional
},
8922 { WM_ERASEBKGND
, sent
|optional
}, /* FIXME: remove optional once Wine is fixed */
8923 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
},
8924 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
8928 static const struct message WmSetWindowRgn_no_redraw
[] = {
8929 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
},
8930 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
8931 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
},
8932 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
8936 static const struct message WmSetWindowRgn_clear
[] = {
8937 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
}, /* some versions of 2000/XP also has SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE in wparam */
8938 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
8939 { WM_NCPAINT
, sent
}, /* wparam != 1 */
8940 { WM_GETTEXT
, sent
|defwinproc
|optional
},
8941 { WM_ERASEBKGND
, sent
|optional
}, /* FIXME: remove optional once Wine is fixed */
8942 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
},
8943 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
8944 { WM_NCPAINT
, sent
|optional
}, /* wparam != 1 */
8945 { WM_GETTEXT
, sent
|defwinproc
|optional
},
8946 { WM_ERASEBKGND
, sent
|optional
},
8947 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
8948 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
8952 static void test_SetWindowRgn(void)
8955 HWND hwnd
= CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW
,
8956 100, 100, 200, 200, 0, 0, 0, NULL
);
8957 ok( hwnd
!= 0, "Failed to create overlapped window\n" );
8959 ShowWindow( hwnd
, SW_SHOW
);
8960 UpdateWindow( hwnd
);
8964 trace("testing SetWindowRgn\n");
8965 hrgn
= CreateRectRgn( 0, 0, 150, 150 );
8966 SetWindowRgn( hwnd
, hrgn
, TRUE
);
8967 ok_sequence( WmSetWindowRgn
, "WmSetWindowRgn", FALSE
);
8969 hrgn
= CreateRectRgn( 30, 30, 160, 160 );
8970 SetWindowRgn( hwnd
, hrgn
, FALSE
);
8971 ok_sequence( WmSetWindowRgn_no_redraw
, "WmSetWindowRgn_no_redraw", FALSE
);
8973 hrgn
= CreateRectRgn( 0, 0, 180, 180 );
8974 SetWindowRgn( hwnd
, hrgn
, TRUE
);
8975 ok_sequence( WmSetWindowRgn
, "WmSetWindowRgn2", FALSE
);
8977 SetWindowRgn( hwnd
, 0, TRUE
);
8978 ok_sequence( WmSetWindowRgn_clear
, "WmSetWindowRgn_clear", FALSE
);
8980 DestroyWindow( hwnd
);
8983 /*************************** ShowWindow() test ******************************/
8984 static const struct message WmShowNormal
[] = {
8985 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
8986 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
8987 { HCBT_ACTIVATE
, hook
},
8988 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2003 doesn't send it */
8989 { HCBT_SETFOCUS
, hook
},
8990 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
8993 static const struct message WmShow
[] = {
8994 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
8995 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
8996 { HCBT_ACTIVATE
, hook
|optional
}, /* win2000 doesn't send it */
8997 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2000 doesn't send it */
8998 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 doesn't send it */
8999 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
9002 static const struct message WmShowNoActivate_1
[] = {
9003 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWNOACTIVATE
},
9004 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|0x8000 },
9005 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|0x8000 },
9006 { WM_MOVE
, sent
|defwinproc
},
9007 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_RESTORED
},
9010 static const struct message WmShowNoActivate_2
[] = {
9011 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWNOACTIVATE
},
9012 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|0x8000 },
9013 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|0x8000 },
9014 { WM_MOVE
, sent
|defwinproc
},
9015 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_RESTORED
},
9016 { HCBT_SETFOCUS
, hook
},
9017 { HCBT_ACTIVATE
, hook
|optional
}, /* win2003 doesn't send it */
9018 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2003 doesn't send it */
9019 { HCBT_SETFOCUS
, hook
|optional
}, /* win2003 doesn't send it */
9022 static const struct message WmShowNA_1
[] = {
9023 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
9024 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
9025 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
9028 static const struct message WmShowNA_2
[] = {
9029 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
9030 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
9033 static const struct message WmRestore_1
[] = {
9034 { HCBT_MINMAX
, hook
|lparam
, 0, SW_RESTORE
},
9035 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|0x8000 },
9036 { HCBT_ACTIVATE
, hook
|optional
}, /* win2000 doesn't send it */
9037 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2000 doesn't send it */
9038 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 doesn't send it */
9039 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|0x8000 },
9040 { WM_MOVE
, sent
|defwinproc
},
9041 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_RESTORED
},
9042 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 sends it */
9045 static const struct message WmRestore_2
[] = {
9046 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
9047 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
9048 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
9051 static const struct message WmRestore_3
[] = {
9052 { HCBT_MINMAX
, hook
|lparam
, 0, SW_RESTORE
},
9053 { WM_GETMINMAXINFO
, sent
},
9054 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|0x8000 },
9055 { HCBT_ACTIVATE
, hook
|optional
}, /* win2003 doesn't send it */
9056 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2003 doesn't send it */
9057 { HCBT_SETFOCUS
, hook
|optional
}, /* win2003 doesn't send it */
9058 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|0x8000 },
9059 { WM_MOVE
, sent
|defwinproc
},
9060 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_MAXIMIZED
},
9061 { HCBT_SETFOCUS
, hook
|optional
}, /* win2003 sends it */
9064 static const struct message WmRestore_4
[] = {
9065 { HCBT_MINMAX
, hook
|lparam
, 0, SW_RESTORE
},
9066 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|0x8000 },
9067 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|0x8000 },
9068 { WM_MOVE
, sent
|defwinproc
},
9069 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_RESTORED
},
9072 static const struct message WmRestore_5
[] = {
9073 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWNORMAL
},
9074 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|0x8000 },
9075 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|0x8000 },
9076 { WM_MOVE
, sent
|defwinproc
},
9077 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_RESTORED
},
9080 static const struct message WmHide_1
[] = {
9081 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
9082 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
9083 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
9084 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 sends it */
9087 static const struct message WmHide_2
[] = {
9088 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
9089 { WM_WINDOWPOSCHANGING
, sent
/*|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE*/ }, /* win2000 doesn't add SWP_NOACTIVATE */
9090 { WM_WINDOWPOSCHANGED
, sent
/*|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE*/ }, /* win2000 doesn't add SWP_NOACTIVATE */
9093 static const struct message WmHide_3
[] = {
9094 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
9095 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
9096 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
9097 { HCBT_SETFOCUS
, hook
},
9098 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
9101 static const struct message WmShowMinimized_1
[] = {
9102 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINIMIZED
},
9103 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|0x8000 },
9104 { HCBT_ACTIVATE
, hook
|optional
}, /* win2000 doesn't send it */
9105 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2000 doesn't send it */
9106 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|0x8000 },
9107 { WM_MOVE
, sent
|defwinproc
},
9108 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_MINIMIZED
},
9111 static const struct message WmMinimize_1
[] = {
9112 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
9113 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 doesn't send it */
9114 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
9115 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|0x8000 },
9116 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|0x8000 },
9117 { WM_MOVE
, sent
|defwinproc
},
9118 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_MINIMIZED
},
9121 static const struct message WmMinimize_2
[] = {
9122 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
9123 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|0x8000 },
9124 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|0x8000 },
9125 { WM_MOVE
, sent
|defwinproc
},
9126 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_MINIMIZED
},
9129 static const struct message WmMinimize_3
[] = {
9130 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
9131 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|0x8000 },
9132 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|0x8000 },
9133 { WM_MOVE
, sent
|defwinproc
},
9134 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_MINIMIZED
},
9137 static const struct message WmShowMinNoActivate
[] = {
9138 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINNOACTIVE
},
9139 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
9140 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
9143 static const struct message WmMinMax_1
[] = {
9144 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINIMIZED
},
9147 static const struct message WmMinMax_2
[] = {
9148 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMAXIMIZED
},
9151 static const struct message WmMinMax_3
[] = {
9152 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
9155 static const struct message WmMinMax_4
[] = {
9156 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINNOACTIVE
},
9159 static const struct message WmShowMaximized_1
[] = {
9160 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMAXIMIZED
},
9161 { WM_GETMINMAXINFO
, sent
},
9162 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|0x8000 },
9163 { HCBT_ACTIVATE
, hook
|optional
}, /* win2000 doesn't send it */
9164 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2000 doesn't send it */
9165 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 doesn't send it */
9166 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|0x8000 },
9167 { WM_MOVE
, sent
|defwinproc
},
9168 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_MAXIMIZED
},
9169 { HCBT_SETFOCUS
, hook
|optional
}, /* win2003 sends it */
9172 static const struct message WmShowMaximized_2
[] = {
9173 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMAXIMIZED
},
9174 { WM_GETMINMAXINFO
, sent
},
9175 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
},
9176 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
9177 { WM_MOVE
, sent
|optional
}, /* Win9x doesn't send it */
9178 { WM_SIZE
, sent
|wparam
|optional
, SIZE_MAXIMIZED
}, /* Win9x doesn't send it */
9179 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|0x8000 },
9180 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|0x8000 },
9181 { WM_MOVE
, sent
|defwinproc
},
9182 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_MAXIMIZED
},
9183 { HCBT_SETFOCUS
, hook
},
9186 static const struct message WmShowMaximized_3
[] = {
9187 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMAXIMIZED
},
9188 { WM_GETMINMAXINFO
, sent
},
9189 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|0x8000 },
9190 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|0x8000 },
9191 { WM_MOVE
, sent
|defwinproc
},
9192 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_MAXIMIZED
},
9196 static void test_ShowWindow(void)
9198 /* ShowWindow commands in random order */
9201 INT cmd
; /* ShowWindow command */
9202 LPARAM ret
; /* ShowWindow return value */
9203 DWORD style
; /* window style after the command */
9204 const struct message
*msg
; /* message sequence the command produces */
9205 BOOL todo_msg
; /* message sequence doesn't match what Wine does */
9208 /* 1 */ { SW_SHOWNORMAL
, FALSE
, WS_VISIBLE
, WmShowNormal
, FALSE
},
9209 /* 2 */ { SW_SHOWNORMAL
, TRUE
, WS_VISIBLE
, WmEmptySeq
, FALSE
},
9210 /* 3 */ { SW_HIDE
, TRUE
, 0, WmHide_1
, FALSE
},
9211 /* 4 */ { SW_HIDE
, FALSE
, 0, WmEmptySeq
, FALSE
},
9212 /* 5 */ { SW_SHOWMINIMIZED
, FALSE
, WS_VISIBLE
|WS_MINIMIZE
, WmShowMinimized_1
, FALSE
},
9213 /* 6 */ { SW_SHOWMINIMIZED
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinMax_1
, FALSE
},
9214 /* 7 */ { SW_HIDE
, TRUE
, WS_MINIMIZE
, WmHide_1
, FALSE
},
9215 /* 8 */ { SW_HIDE
, FALSE
, WS_MINIMIZE
, WmEmptySeq
, FALSE
},
9216 /* 9 */ { SW_SHOWMAXIMIZED
, FALSE
, WS_VISIBLE
|WS_MAXIMIZE
, WmShowMaximized_1
, FALSE
},
9217 /* 10 */ { SW_SHOWMAXIMIZED
, TRUE
, WS_VISIBLE
|WS_MAXIMIZE
, WmMinMax_2
, FALSE
},
9218 /* 11 */ { SW_HIDE
, TRUE
, WS_MAXIMIZE
, WmHide_1
, FALSE
},
9219 /* 12 */ { SW_HIDE
, FALSE
, WS_MAXIMIZE
, WmEmptySeq
, FALSE
},
9220 /* 13 */ { SW_SHOWNOACTIVATE
, FALSE
, WS_VISIBLE
, WmShowNoActivate_1
, FALSE
},
9221 /* 14 */ { SW_SHOWNOACTIVATE
, TRUE
, WS_VISIBLE
, WmEmptySeq
, FALSE
},
9222 /* 15 */ { SW_HIDE
, TRUE
, 0, WmHide_2
, FALSE
},
9223 /* 16 */ { SW_HIDE
, FALSE
, 0, WmEmptySeq
, FALSE
},
9224 /* 17 */ { SW_SHOW
, FALSE
, WS_VISIBLE
, WmShow
, FALSE
},
9225 /* 18 */ { SW_SHOW
, TRUE
, WS_VISIBLE
, WmEmptySeq
, FALSE
},
9226 /* 19 */ { SW_MINIMIZE
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinimize_1
, TRUE
},
9227 /* 20 */ { SW_MINIMIZE
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinMax_3
, FALSE
},
9228 /* 21 */ { SW_HIDE
, TRUE
, WS_MINIMIZE
, WmHide_2
, FALSE
},
9229 /* 22 */ { SW_SHOWMINNOACTIVE
, FALSE
, WS_VISIBLE
|WS_MINIMIZE
, WmShowMinNoActivate
, TRUE
},
9230 /* 23 */ { SW_SHOWMINNOACTIVE
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinMax_4
, FALSE
},
9231 /* 24 */ { SW_HIDE
, TRUE
, WS_MINIMIZE
, WmHide_2
, FALSE
},
9232 /* 25 */ { SW_HIDE
, FALSE
, WS_MINIMIZE
, WmEmptySeq
, FALSE
},
9233 /* 26 */ { SW_SHOWNA
, FALSE
, WS_VISIBLE
|WS_MINIMIZE
, WmShowNA_1
, FALSE
},
9234 /* 27 */ { SW_SHOWNA
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmShowNA_2
, FALSE
},
9235 /* 28 */ { SW_HIDE
, TRUE
, WS_MINIMIZE
, WmHide_2
, FALSE
},
9236 /* 29 */ { SW_HIDE
, FALSE
, WS_MINIMIZE
, WmEmptySeq
, FALSE
},
9237 /* 30 */ { SW_RESTORE
, FALSE
, WS_VISIBLE
, WmRestore_1
, FALSE
},
9238 /* 31 */ { SW_RESTORE
, TRUE
, WS_VISIBLE
, WmEmptySeq
, FALSE
},
9239 /* 32 */ { SW_HIDE
, TRUE
, 0, WmHide_3
, TRUE
},
9240 /* 33 */ { SW_HIDE
, FALSE
, 0, WmEmptySeq
, FALSE
},
9241 /* 34 */ { SW_NORMALNA
, FALSE
, 0, WmEmptySeq
, TRUE
}, /* what does this mean?! */
9242 /* 35 */ { SW_NORMALNA
, FALSE
, 0, WmEmptySeq
, TRUE
},
9243 /* 36 */ { SW_HIDE
, FALSE
, 0, WmEmptySeq
, FALSE
},
9244 /* 37 */ { SW_RESTORE
, FALSE
, WS_VISIBLE
, WmRestore_2
, FALSE
},
9245 /* 38 */ { SW_RESTORE
, TRUE
, WS_VISIBLE
, WmEmptySeq
, FALSE
},
9246 /* 39 */ { SW_SHOWNOACTIVATE
, TRUE
, WS_VISIBLE
, WmEmptySeq
, FALSE
},
9247 /* 40 */ { SW_MINIMIZE
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinimize_2
, TRUE
},
9248 /* 41 */ { SW_MINIMIZE
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinMax_3
, FALSE
},
9249 /* 42 */ { SW_SHOWMAXIMIZED
, TRUE
, WS_VISIBLE
|WS_MAXIMIZE
, WmShowMaximized_2
, TRUE
},
9250 /* 43 */ { SW_SHOWMAXIMIZED
, TRUE
, WS_VISIBLE
|WS_MAXIMIZE
, WmMinMax_2
, FALSE
},
9251 /* 44 */ { SW_MINIMIZE
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinimize_1
, TRUE
},
9252 /* 45 */ { SW_MINIMIZE
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinMax_3
, FALSE
},
9253 /* 46 */ { SW_RESTORE
, TRUE
, WS_VISIBLE
|WS_MAXIMIZE
, WmRestore_3
, FALSE
},
9254 /* 47 */ { SW_RESTORE
, TRUE
, WS_VISIBLE
, WmRestore_4
, FALSE
},
9255 /* 48 */ { SW_SHOWMAXIMIZED
, TRUE
, WS_VISIBLE
|WS_MAXIMIZE
, WmShowMaximized_3
, FALSE
},
9256 /* 49 */ { SW_SHOW
, TRUE
, WS_VISIBLE
|WS_MAXIMIZE
, WmEmptySeq
, FALSE
},
9257 /* 50 */ { SW_SHOWNORMAL
, TRUE
, WS_VISIBLE
, WmRestore_5
, FALSE
},
9258 /* 51 */ { SW_SHOWNORMAL
, TRUE
, WS_VISIBLE
, WmEmptySeq
, FALSE
},
9259 /* 52 */ { SW_HIDE
, TRUE
, 0, WmHide_1
, FALSE
},
9260 /* 53 */ { SW_HIDE
, FALSE
, 0, WmEmptySeq
, FALSE
},
9261 /* 54 */ { SW_MINIMIZE
, FALSE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinimize_3
, TRUE
},
9262 /* 55 */ { SW_HIDE
, TRUE
, WS_MINIMIZE
, WmHide_2
, FALSE
},
9263 /* 56 */ { SW_SHOWNOACTIVATE
, FALSE
, WS_VISIBLE
, WmShowNoActivate_2
, FALSE
},
9264 /* 57 */ { SW_SHOW
, TRUE
, WS_VISIBLE
, WmEmptySeq
, FALSE
}
9271 #define WS_BASE (WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX|WS_MAXIMIZEBOX|WS_POPUP|WS_CLIPSIBLINGS)
9272 hwnd
= CreateWindowEx(0, "ShowWindowClass", NULL
, WS_BASE
,
9277 style
= GetWindowLong(hwnd
, GWL_STYLE
) & ~WS_BASE
;
9278 ok(style
== 0, "expected style 0, got %08x\n", style
);
9283 for (i
= 0; i
< sizeof(sw
)/sizeof(sw
[0]); i
++)
9285 static const char * const sw_cmd_name
[13] =
9287 "SW_HIDE", "SW_SHOWNORMAL", "SW_SHOWMINIMIZED", "SW_SHOWMAXIMIZED",
9288 "SW_SHOWNOACTIVATE", "SW_SHOW", "SW_MINIMIZE", "SW_SHOWMINNOACTIVE",
9289 "SW_SHOWNA", "SW_RESTORE", "SW_SHOWDEFAULT", "SW_FORCEMINIMIZE",
9290 "SW_NORMALNA" /* 0xCC */
9293 INT idx
; /* index into the above array of names */
9295 idx
= (sw
[i
].cmd
== SW_NORMALNA
) ? 12 : sw
[i
].cmd
;
9297 style
= GetWindowLong(hwnd
, GWL_STYLE
);
9298 trace("%d: sending %s, current window style %08x\n", i
+1, sw_cmd_name
[idx
], style
);
9299 ret
= ShowWindow(hwnd
, sw
[i
].cmd
);
9300 ok(!ret
== !sw
[i
].ret
, "%d: cmd %s: expected ret %lu, got %lu\n", i
+1, sw_cmd_name
[idx
], sw
[i
].ret
, ret
);
9301 style
= GetWindowLong(hwnd
, GWL_STYLE
) & ~WS_BASE
;
9302 ok(style
== sw
[i
].style
, "%d: expected style %08x, got %08x\n", i
+1, sw
[i
].style
, style
);
9304 sprintf(comment
, "%d: ShowWindow(%s)", i
+1, sw_cmd_name
[idx
]);
9305 ok_sequence(sw
[i
].msg
, comment
, sw
[i
].todo_msg
);
9311 DestroyWindow(hwnd
);
9314 static INT_PTR WINAPI
test_dlg_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
9318 trace("dialog: %p, %04x, %08lx, %08lx\n", hwnd
, message
, wParam
, lParam
);
9322 case WM_WINDOWPOSCHANGING
:
9323 case WM_WINDOWPOSCHANGED
:
9325 WINDOWPOS
*winpos
= (WINDOWPOS
*)lParam
;
9327 trace("%s\n", (message
== WM_WINDOWPOSCHANGING
) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
9328 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
9329 winpos
->hwnd
, winpos
->hwndInsertAfter
,
9330 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
9331 dump_winpos_flags(winpos
->flags
);
9333 /* Log only documented flags, win2k uses 0x1000 and 0x2000
9334 * in the high word for internal purposes
9336 wParam
= winpos
->flags
& 0xffff;
9337 /* We are not interested in the flags that don't match under XP and Win9x */
9338 wParam
&= ~(SWP_NOZORDER
);
9342 /* explicitly ignore WM_GETICON message */
9347 msg
.message
= message
;
9348 msg
.flags
= sent
|wparam
|lparam
;
9349 msg
.wParam
= wParam
;
9350 msg
.lParam
= lParam
;
9353 /* calling DefDlgProc leads to a recursion under XP */
9364 static const struct message WmDefDlgSetFocus_1
[] = {
9365 { WM_GETDLGCODE
, sent
|wparam
|lparam
, 0, 0 },
9366 { WM_GETTEXTLENGTH
, sent
|wparam
|lparam
|optional
, 0, 0 }, /* XP */
9367 { WM_GETTEXT
, sent
|wparam
|optional
, 6 }, /* XP */
9368 { WM_GETTEXT
, sent
|wparam
|optional
, 12 }, /* XP */
9369 { EM_SETSEL
, sent
|wparam
, 0 }, /* XP sets lparam to text length, Win9x to -2 */
9370 { HCBT_SETFOCUS
, hook
},
9371 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
9372 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
9373 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
9374 { WM_SETFOCUS
, sent
|wparam
, 0 },
9375 { WM_CTLCOLOREDIT
, sent
},
9376 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
9377 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
9378 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
9379 { WM_COMMAND
, sent
|wparam
, MAKEWPARAM(1, EN_SETFOCUS
) },
9382 static const struct message WmDefDlgSetFocus_2
[] = {
9383 { WM_GETDLGCODE
, sent
|wparam
|lparam
, 0, 0 },
9384 { WM_GETTEXTLENGTH
, sent
|wparam
|lparam
|optional
, 0, 0 }, /* XP */
9385 { WM_GETTEXT
, sent
|wparam
|optional
, 6 }, /* XP */
9386 { WM_GETTEXT
, sent
|wparam
|optional
, 12 }, /* XP */
9387 { EM_SETSEL
, sent
|wparam
, 0 }, /* XP sets lparam to text length, Win9x to -2 */
9388 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
9389 { WM_CTLCOLOREDIT
, sent
|optional
}, /* XP */
9390 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
9393 /* Creation of a dialog */
9394 static const struct message WmCreateDialogParamSeq_1
[] = {
9395 { HCBT_CREATEWND
, hook
},
9396 { WM_NCCREATE
, sent
},
9397 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
9398 { WM_CREATE
, sent
},
9399 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
9400 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
9402 { WM_SETFONT
, sent
},
9403 { WM_INITDIALOG
, sent
},
9404 { WM_CHANGEUISTATE
, sent
|optional
},
9407 /* Creation of a dialog */
9408 static const struct message WmCreateDialogParamSeq_2
[] = {
9409 { HCBT_CREATEWND
, hook
},
9410 { WM_NCCREATE
, sent
},
9411 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
9412 { WM_CREATE
, sent
},
9413 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
9414 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
9416 { WM_CHANGEUISTATE
, sent
|optional
},
9420 static void test_dialog_messages(void)
9423 HWND hdlg
, hedit1
, hedit2
, hfocus
;
9426 #define set_selection(hctl, start, end) \
9427 ret = SendMessage(hctl, EM_SETSEL, start, end); \
9428 ok(ret == 1, "EM_SETSEL returned %ld\n", ret);
9430 #define check_selection(hctl, start, end) \
9431 ret = SendMessage(hctl, EM_GETSEL, 0, 0); \
9432 ok(ret == MAKELRESULT(start, end), "wrong selection (%d - %d)\n", LOWORD(ret), HIWORD(ret));
9436 hdlg
= CreateWindowEx(WS_EX_DLGMODALFRAME
, "TestDialogClass", NULL
,
9437 WS_VISIBLE
|WS_CAPTION
|WS_SYSMENU
|WS_DLGFRAME
,
9438 0, 0, 100, 100, 0, 0, 0, NULL
);
9439 ok(hdlg
!= 0, "Failed to create custom dialog window\n");
9441 hedit1
= CreateWindowEx(0, "my_edit_class", NULL
,
9442 WS_CHILD
|WS_BORDER
|WS_VISIBLE
|WS_TABSTOP
,
9443 0, 0, 80, 20, hdlg
, (HMENU
)1, 0, NULL
);
9444 ok(hedit1
!= 0, "Failed to create edit control\n");
9445 hedit2
= CreateWindowEx(0, "my_edit_class", NULL
,
9446 WS_CHILD
|WS_BORDER
|WS_VISIBLE
|WS_TABSTOP
,
9447 0, 40, 80, 20, hdlg
, (HMENU
)2, 0, NULL
);
9448 ok(hedit2
!= 0, "Failed to create edit control\n");
9450 SendMessage(hedit1
, WM_SETTEXT
, 0, (LPARAM
)"hello");
9451 SendMessage(hedit2
, WM_SETTEXT
, 0, (LPARAM
)"bye");
9453 hfocus
= GetFocus();
9454 ok(hfocus
== hdlg
, "wrong focus %p\n", hfocus
);
9457 hfocus
= GetFocus();
9458 ok(hfocus
== hedit2
, "wrong focus %p\n", hfocus
);
9460 check_selection(hedit1
, 0, 0);
9461 check_selection(hedit2
, 0, 0);
9463 set_selection(hedit2
, 0, -1);
9464 check_selection(hedit2
, 0, 3);
9467 hfocus
= GetFocus();
9468 ok(hfocus
== 0, "wrong focus %p\n", hfocus
);
9471 ret
= DefDlgProc(hdlg
, WM_SETFOCUS
, 0, 0);
9472 ok(ret
== 0, "WM_SETFOCUS returned %ld\n", ret
);
9473 ok_sequence(WmDefDlgSetFocus_1
, "DefDlgProc(WM_SETFOCUS) 1", FALSE
);
9475 hfocus
= GetFocus();
9476 ok(hfocus
== hedit1
, "wrong focus %p\n", hfocus
);
9478 check_selection(hedit1
, 0, 5);
9479 check_selection(hedit2
, 0, 3);
9482 ret
= DefDlgProc(hdlg
, WM_SETFOCUS
, 0, 0);
9483 ok(ret
== 0, "WM_SETFOCUS returned %ld\n", ret
);
9484 ok_sequence(WmDefDlgSetFocus_2
, "DefDlgProc(WM_SETFOCUS) 2", FALSE
);
9486 hfocus
= GetFocus();
9487 ok(hfocus
== hedit1
, "wrong focus %p\n", hfocus
);
9489 check_selection(hedit1
, 0, 5);
9490 check_selection(hedit2
, 0, 3);
9493 DestroyWindow(hedit1
);
9494 DestroyWindow(hedit2
);
9495 DestroyWindow(hdlg
);
9498 #undef set_selection
9499 #undef check_selection
9501 ok(GetClassInfo(0, "#32770", &cls
), "GetClassInfo failed\n");
9502 cls
.lpszClassName
= "MyDialogClass";
9503 cls
.hInstance
= GetModuleHandle(0);
9504 /* need a cast since a dlgproc is used as a wndproc */
9505 cls
.lpfnWndProc
= (WNDPROC
)test_dlg_proc
;
9506 if (!RegisterClass(&cls
)) assert(0);
9508 hdlg
= CreateDialogParam(0, "CLASS_TEST_DIALOG_2", 0, test_dlg_proc
, 0);
9509 ok(IsWindow(hdlg
), "CreateDialogParam failed\n");
9510 ok_sequence(WmCreateDialogParamSeq_1
, "CreateDialogParam_1", FALSE
);
9512 DestroyWindow(hdlg
);
9515 hdlg
= CreateDialogParam(0, "CLASS_TEST_DIALOG_2", 0, NULL
, 0);
9516 ok(IsWindow(hdlg
), "CreateDialogParam failed\n");
9517 ok_sequence(WmCreateDialogParamSeq_2
, "CreateDialogParam_2", FALSE
);
9519 DestroyWindow(hdlg
);
9522 UnregisterClass(cls
.lpszClassName
, cls
.hInstance
);
9525 static void test_nullCallback(void)
9529 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW
,
9530 100, 100, 200, 200, 0, 0, 0, NULL
);
9531 ok (hwnd
!= 0, "Failed to create overlapped window\n");
9533 SendMessageCallbackA(hwnd
,WM_NULL
,0,0,NULL
,0);
9535 DestroyWindow(hwnd
);
9538 static const struct message SetForegroundWindowSeq
[] =
9540 { WM_NCACTIVATE
, sent
|wparam
, 0 },
9541 { WM_GETTEXT
, sent
|defwinproc
|optional
},
9542 { WM_ACTIVATE
, sent
|wparam
, 0 },
9543 { WM_ACTIVATEAPP
, sent
|wparam
, 0 },
9544 { WM_KILLFOCUS
, sent
},
9545 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
9546 { WM_IME_NOTIFY
, sent
|wparam
|optional
|defwinproc
, 1 },
9550 static void test_SetForegroundWindow(void)
9554 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test SetForegroundWindow",
9555 WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
9556 100, 100, 200, 200, 0, 0, 0, NULL
);
9557 ok (hwnd
!= 0, "Failed to create overlapped window\n");
9560 trace("SetForegroundWindow( 0 )\n");
9561 SetForegroundWindow( 0 );
9562 ok_sequence(WmEmptySeq
, "SetForegroundWindow( 0 ) away from foreground top level window", FALSE
);
9563 trace("SetForegroundWindow( GetDesktopWindow() )\n");
9564 SetForegroundWindow( GetDesktopWindow() );
9565 ok_sequence(SetForegroundWindowSeq
, "SetForegroundWindow( desktop ) away from "
9566 "foreground top level window", FALSE
);
9569 DestroyWindow(hwnd
);
9572 static void test_dbcs_wm_char(void)
9583 struct message wmCharSeq
[2];
9585 pGetCPInfoExA( CP_ACP
, 0, &cpinfo
);
9586 if (cpinfo
.MaxCharSize
!= 2)
9588 skip( "Skipping DBCS WM_CHAR test in SBCS codepage '%s'\n", cpinfo
.CodePageName
);
9592 dbch
[0] = dbch
[1] = 0;
9594 bad_wch
= cpinfo
.UnicodeDefaultChar
;
9595 for (i
= 0; !wch
&& i
< MAX_LEADBYTES
&& cpinfo
.LeadByte
[i
]; i
+= 2)
9596 for (j
= cpinfo
.LeadByte
[i
]; !wch
&& j
<= cpinfo
.LeadByte
[i
+1]; j
++)
9597 for (k
= 128; k
<= 255; k
++)
9603 if (MultiByteToWideChar( CP_ACP
, 0, str
, 2, wstr
, 2 ) == 1 &&
9604 WideCharToMultiByte( CP_ACP
, 0, wstr
, 1, str
, 2, NULL
, NULL
) == 2 &&
9605 (BYTE
)str
[0] == j
&& (BYTE
)str
[1] == k
&&
9606 HIBYTE(wstr
[0]) && HIBYTE(wstr
[0]) != 0xff)
9617 skip( "Skipping DBCS WM_CHAR test, no appropriate char found\n" );
9620 trace( "using dbcs char %02x,%02x wchar %04x bad wchar %04x codepage '%s'\n",
9621 dbch
[0], dbch
[1], wch
, bad_wch
, cpinfo
.CodePageName
);
9623 hwnd
= CreateWindowExW(0, testWindowClassW
, NULL
,
9624 WS_OVERLAPPEDWINDOW
, 100, 100, 200, 200, 0, 0, 0, NULL
);
9625 hwnd2
= CreateWindowExW(0, testWindowClassW
, NULL
,
9626 WS_OVERLAPPEDWINDOW
, 100, 100, 200, 200, 0, 0, 0, NULL
);
9627 ok (hwnd
!= 0, "Failed to create overlapped window\n");
9628 ok (hwnd2
!= 0, "Failed to create overlapped window\n");
9631 memset( wmCharSeq
, 0, sizeof(wmCharSeq
) );
9632 wmCharSeq
[0].message
= WM_CHAR
;
9633 wmCharSeq
[0].flags
= sent
|wparam
;
9634 wmCharSeq
[0].wParam
= wch
;
9636 /* posted message */
9637 PostMessageA( hwnd
, WM_CHAR
, dbch
[0], 0 );
9638 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
9639 PostMessageA( hwnd
, WM_CHAR
, dbch
[1], 0 );
9640 ok( PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "no message\n" );
9641 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
9642 ok( msg
.wParam
== wch
, "bad wparam %lx/%x\n", msg
.wParam
, wch
);
9643 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
9645 /* posted thread message */
9646 PostThreadMessageA( GetCurrentThreadId(), WM_CHAR
, dbch
[0], 0 );
9647 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
9648 PostMessageA( hwnd
, WM_CHAR
, dbch
[1], 0 );
9649 ok( PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "no message\n" );
9650 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
9651 ok( msg
.wParam
== wch
, "bad wparam %lx/%x\n", msg
.wParam
, wch
);
9652 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
9656 SendMessageA( hwnd
, WM_CHAR
, dbch
[0], 0 );
9657 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
9658 SendMessageA( hwnd
, WM_CHAR
, dbch
[1], 0 );
9659 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
9660 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
9662 /* sent message with timeout */
9664 SendMessageTimeoutA( hwnd
, WM_CHAR
, dbch
[0], 0, SMTO_NORMAL
, 0, &res
);
9665 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
9666 SendMessageTimeoutA( hwnd
, WM_CHAR
, dbch
[1], 0, SMTO_NORMAL
, 0, &res
);
9667 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
9668 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
9670 /* sent message with timeout and callback */
9672 SendMessageTimeoutA( hwnd
, WM_CHAR
, dbch
[0], 0, SMTO_NORMAL
, 0, &res
);
9673 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
9674 SendMessageCallbackA( hwnd
, WM_CHAR
, dbch
[1], 0, NULL
, 0 );
9675 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
9676 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
9678 /* sent message with callback */
9680 SendNotifyMessageA( hwnd
, WM_CHAR
, dbch
[0], 0 );
9681 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
9682 SendMessageCallbackA( hwnd
, WM_CHAR
, dbch
[1], 0, NULL
, 0 );
9683 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
9684 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
9686 /* direct window proc call */
9688 CallWindowProcA( (WNDPROC
)GetWindowLongPtrA( hwnd
, GWLP_WNDPROC
), hwnd
, WM_CHAR
, dbch
[0], 0 );
9689 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
9690 CallWindowProcA( (WNDPROC
)GetWindowLongPtrA( hwnd
, GWLP_WNDPROC
), hwnd
, WM_CHAR
, dbch
[1], 0 );
9691 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
9693 /* dispatch message */
9695 msg
.message
= WM_CHAR
;
9696 msg
.wParam
= dbch
[0];
9698 DispatchMessageA( &msg
);
9699 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
9700 msg
.wParam
= dbch
[1];
9701 DispatchMessageA( &msg
);
9702 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
9704 /* window handle is irrelevant */
9706 SendMessageA( hwnd2
, WM_CHAR
, dbch
[0], 0 );
9707 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
9708 SendMessageA( hwnd
, WM_CHAR
, dbch
[1], 0 );
9709 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
9710 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
9712 /* interleaved post and send */
9714 PostMessageA( hwnd2
, WM_CHAR
, dbch
[0], 0 );
9715 SendMessageA( hwnd2
, WM_CHAR
, dbch
[0], 0 );
9716 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
9717 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
9718 PostMessageA( hwnd
, WM_CHAR
, dbch
[1], 0 );
9719 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
9720 ok( PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "no message\n" );
9721 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
9722 ok( msg
.wParam
== wch
, "bad wparam %lx/%x\n", msg
.wParam
, wch
);
9723 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
9724 SendMessageA( hwnd
, WM_CHAR
, dbch
[1], 0 );
9725 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
9726 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
9728 /* interleaved sent message and winproc */
9730 SendMessageA( hwnd
, WM_CHAR
, dbch
[0], 0 );
9731 CallWindowProcA( (WNDPROC
)GetWindowLongPtrA( hwnd
, GWLP_WNDPROC
), hwnd
, WM_CHAR
, dbch
[0], 0 );
9732 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
9733 SendMessageA( hwnd
, WM_CHAR
, dbch
[1], 0 );
9734 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
9735 CallWindowProcA( (WNDPROC
)GetWindowLongPtrA( hwnd
, GWLP_WNDPROC
), hwnd
, WM_CHAR
, dbch
[1], 0 );
9736 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
9738 /* interleaved winproc and dispatch */
9740 msg
.message
= WM_CHAR
;
9741 msg
.wParam
= dbch
[0];
9743 CallWindowProcA( (WNDPROC
)GetWindowLongPtrA( hwnd
, GWLP_WNDPROC
), hwnd
, WM_CHAR
, dbch
[0], 0 );
9744 DispatchMessageA( &msg
);
9745 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
9746 msg
.wParam
= dbch
[1];
9747 DispatchMessageA( &msg
);
9748 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
9749 CallWindowProcA( (WNDPROC
)GetWindowLongPtrA( hwnd
, GWLP_WNDPROC
), hwnd
, WM_CHAR
, dbch
[1], 0 );
9750 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
9752 /* interleaved sends */
9754 SendMessageA( hwnd
, WM_CHAR
, dbch
[0], 0 );
9755 SendMessageCallbackA( hwnd
, WM_CHAR
, dbch
[0], 0, NULL
, 0 );
9756 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
9757 SendMessageTimeoutA( hwnd
, WM_CHAR
, dbch
[1], 0, SMTO_NORMAL
, 0, &res
);
9758 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
9759 SendMessageA( hwnd
, WM_CHAR
, dbch
[1], 0 );
9760 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
9764 SendMessageA( hwnd2
, WM_CHAR
, (dbch
[1] << 8) | dbch
[0], 0 );
9765 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
9766 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
9768 /* other char messages are not magic */
9769 PostMessageA( hwnd
, WM_SYSCHAR
, dbch
[0], 0 );
9770 ok( PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "no message\n" );
9771 ok( msg
.message
== WM_SYSCHAR
, "unexpected message %x\n", msg
.message
);
9772 ok( msg
.wParam
== bad_wch
, "bad wparam %lx/%x\n", msg
.wParam
, bad_wch
);
9773 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
9774 PostMessageA( hwnd
, WM_DEADCHAR
, dbch
[0], 0 );
9775 ok( PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "no message\n" );
9776 ok( msg
.message
== WM_DEADCHAR
, "unexpected message %x\n", msg
.message
);
9777 ok( msg
.wParam
== bad_wch
, "bad wparam %lx/%x\n", msg
.wParam
, bad_wch
);
9778 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
9780 /* test retrieving messages */
9782 PostMessageW( hwnd
, WM_CHAR
, wch
, 0 );
9783 ok( PeekMessageA( &msg
, hwnd
, 0, 0, PM_REMOVE
), "no message\n" );
9784 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
9785 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
9786 ok( msg
.wParam
== dbch
[0], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
9787 ok( PeekMessageA( &msg
, hwnd
, 0, 0, PM_REMOVE
), "no message\n" );
9788 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
9789 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
9790 ok( msg
.wParam
== dbch
[1], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
9791 ok( !PeekMessageA( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
9793 /* message filters */
9794 PostMessageW( hwnd
, WM_CHAR
, wch
, 0 );
9795 ok( PeekMessageA( &msg
, hwnd
, 0, 0, PM_REMOVE
), "no message\n" );
9796 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
9797 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
9798 ok( msg
.wParam
== dbch
[0], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
9799 /* message id is filtered, hwnd is not */
9800 ok( !PeekMessageA( &msg
, hwnd
, WM_MOUSEFIRST
, WM_MOUSELAST
, PM_REMOVE
), "no message\n" );
9801 ok( PeekMessageA( &msg
, hwnd2
, 0, 0, PM_REMOVE
), "no message\n" );
9802 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
9803 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
9804 ok( msg
.wParam
== dbch
[1], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
9805 ok( !PeekMessageA( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
9807 /* mixing GetMessage and PostMessage */
9808 PostMessageW( hwnd
, WM_CHAR
, wch
, 0xbeef );
9809 ok( GetMessageA( &msg
, hwnd
, 0, 0 ), "no message\n" );
9810 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
9811 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
9812 ok( msg
.wParam
== dbch
[0], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
9813 ok( msg
.lParam
== 0xbeef, "bad lparam %lx\n", msg
.lParam
);
9816 ok( time
- GetTickCount() <= 100, "bad time %x\n", msg
.time
);
9817 ok( PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
), "no message\n" );
9818 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
9819 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
9820 ok( msg
.wParam
== dbch
[1], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
9821 ok( msg
.lParam
== 0xbeef, "bad lparam %lx\n", msg
.lParam
);
9822 ok( msg
.time
== time
, "bad time %x/%x\n", msg
.time
, time
);
9823 ok( msg
.pt
.x
== pt
.x
&& msg
.pt
.y
== pt
.y
, "bad point %u,%u/%u,%u\n", msg
.pt
.x
, msg
.pt
.y
, pt
.x
, pt
.y
);
9824 ok( !PeekMessageA( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
9826 /* without PM_REMOVE */
9827 PostMessageW( hwnd
, WM_CHAR
, wch
, 0 );
9828 ok( PeekMessageA( &msg
, 0, 0, 0, PM_NOREMOVE
), "no message\n" );
9829 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
9830 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
9831 ok( msg
.wParam
== dbch
[0], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
9832 ok( PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
), "no message\n" );
9833 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
9834 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
9835 ok( msg
.wParam
== dbch
[0], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
9836 ok( PeekMessageA( &msg
, 0, 0, 0, PM_NOREMOVE
), "no message\n" );
9837 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
9838 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
9839 ok( msg
.wParam
== dbch
[1], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
9840 ok( PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
), "no message\n" );
9841 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
9842 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
9843 ok( msg
.wParam
== dbch
[1], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
9844 ok( !PeekMessageA( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
9846 DestroyWindow(hwnd
);
9849 #define ID_LISTBOX 0x000f
9851 static const struct message wm_lb_setcursel_0
[] =
9853 { LB_SETCURSEL
, sent
|wparam
|lparam
, 0, 0 },
9854 { WM_CTLCOLORLISTBOX
, sent
|parent
},
9855 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x000120f2 },
9856 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 1 },
9857 { EVENT_OBJECT_SELECTION
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 1 },
9860 static const struct message wm_lb_setcursel_1
[] =
9862 { LB_SETCURSEL
, sent
|wparam
|lparam
, 1, 0 },
9863 { WM_CTLCOLORLISTBOX
, sent
|parent
},
9864 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x000020f2 },
9865 { WM_CTLCOLORLISTBOX
, sent
|parent
},
9866 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x000121f2 },
9867 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 2 },
9868 { EVENT_OBJECT_SELECTION
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 2 },
9871 static const struct message wm_lb_setcursel_2
[] =
9873 { LB_SETCURSEL
, sent
|wparam
|lparam
, 2, 0 },
9874 { WM_CTLCOLORLISTBOX
, sent
|parent
},
9875 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x000021f2 },
9876 { WM_CTLCOLORLISTBOX
, sent
|parent
},
9877 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x000122f2 },
9878 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 3 },
9879 { EVENT_OBJECT_SELECTION
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 3 },
9882 static const struct message wm_lb_click_0
[] =
9884 { WM_LBUTTONDOWN
, sent
|wparam
|lparam
, 0, MAKELPARAM(1,1) },
9885 { HCBT_SETFOCUS
, hook
},
9886 { WM_KILLFOCUS
, sent
|parent
},
9887 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
|parent
, 0 },
9888 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
9889 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
9890 { WM_SETFOCUS
, sent
},
9892 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x001142f2 },
9893 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_LISTBOX
, LBN_SETFOCUS
) },
9894 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 3 },
9895 { WM_LBTRACKPOINT
, sent
|wparam
|lparam
|parent
, 0, MAKELPARAM(1,1) },
9896 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
9898 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x000142f2 },
9899 { WM_CTLCOLORLISTBOX
, sent
|parent
},
9900 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x000022f2 },
9901 { WM_CTLCOLORLISTBOX
, sent
|parent
},
9902 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x000120f2 },
9903 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x001140f2 },
9905 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 1 },
9906 { EVENT_OBJECT_SELECTION
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 1 },
9908 { WM_LBUTTONUP
, sent
|wparam
|lparam
, 0, 0 },
9909 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, 0, 0 },
9910 { WM_CAPTURECHANGED
, sent
|wparam
|lparam
, 0, 0 },
9911 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_LISTBOX
, LBN_SELCHANGE
) },
9915 #define check_lb_state(a1, a2, a3, a4, a5) check_lb_state_dbg(a1, a2, a3, a4, a5, __LINE__)
9917 static LRESULT (WINAPI
*listbox_orig_proc
)(HWND
, UINT
, WPARAM
, LPARAM
);
9919 static LRESULT WINAPI
listbox_hook_proc(HWND hwnd
, UINT message
, WPARAM wp
, LPARAM lp
)
9923 /* do not log painting messages */
9924 if (message
!= WM_PAINT
&&
9925 message
!= WM_NCPAINT
&&
9926 message
!= WM_SYNCPAINT
&&
9927 message
!= WM_ERASEBKGND
&&
9928 message
!= WM_NCHITTEST
&&
9929 message
!= WM_GETTEXT
&&
9930 message
!= WM_GETICON
&&
9931 message
!= WM_DEVICECHANGE
)
9933 trace("listbox: %p, %04x, %08lx, %08lx\n", hwnd
, message
, wp
, lp
);
9935 msg
.message
= message
;
9936 msg
.flags
= sent
|wparam
|lparam
;
9942 return CallWindowProcA(listbox_orig_proc
, hwnd
, message
, wp
, lp
);
9945 static void check_lb_state_dbg(HWND listbox
, int count
, int cur_sel
,
9946 int caret_index
, int top_index
, int line
)
9950 /* calling an orig proc helps to avoid unnecessary message logging */
9951 ret
= CallWindowProcA(listbox_orig_proc
, listbox
, LB_GETCOUNT
, 0, 0);
9952 ok_(__FILE__
, line
)(ret
== count
, "expected count %d, got %ld\n", count
, ret
);
9953 ret
= CallWindowProcA(listbox_orig_proc
, listbox
, LB_GETCURSEL
, 0, 0);
9954 ok_(__FILE__
, line
)(ret
== cur_sel
, "expected cur sel %d, got %ld\n", cur_sel
, ret
);
9955 ret
= CallWindowProcA(listbox_orig_proc
, listbox
, LB_GETCARETINDEX
, 0, 0);
9956 ok_(__FILE__
, line
)(ret
== caret_index
, "expected caret index %d, got %ld\n", caret_index
, ret
);
9957 ret
= CallWindowProcA(listbox_orig_proc
, listbox
, LB_GETTOPINDEX
, 0, 0);
9958 ok_(__FILE__
, line
)(ret
== top_index
, "expected top index %d, got %ld\n", top_index
, ret
);
9961 static void test_listbox(void)
9963 HWND parent
, listbox
;
9966 parent
= CreateWindowExA(0, "TestParentClass", NULL
, WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
9967 100, 100, 200, 200, 0, 0, 0, NULL
);
9968 listbox
= CreateWindowExA(WS_EX_NOPARENTNOTIFY
, "ListBox", NULL
,
9969 WS_CHILD
| LBS_NOTIFY
| LBS_OWNERDRAWVARIABLE
| LBS_HASSTRINGS
| WS_VISIBLE
,
9970 10, 10, 80, 80, parent
, (HMENU
)ID_LISTBOX
, 0, NULL
);
9971 listbox_orig_proc
= (WNDPROC
)SetWindowLongPtrA(listbox
, GWLP_WNDPROC
, (ULONG_PTR
)listbox_hook_proc
);
9973 check_lb_state(listbox
, 0, LB_ERR
, 0, 0);
9975 ret
= SendMessage(listbox
, LB_ADDSTRING
, 0, (LPARAM
)"item 0");
9976 ok(ret
== 0, "expected 0, got %ld\n", ret
);
9977 ret
= SendMessage(listbox
, LB_ADDSTRING
, 0, (LPARAM
)"item 1");
9978 ok(ret
== 1, "expected 1, got %ld\n", ret
);
9979 ret
= SendMessage(listbox
, LB_ADDSTRING
, 0, (LPARAM
)"item 2");
9980 ok(ret
== 2, "expected 2, got %ld\n", ret
);
9982 check_lb_state(listbox
, 3, LB_ERR
, 0, 0);
9986 log_all_parent_messages
++;
9988 trace("selecting item 0\n");
9989 ret
= SendMessage(listbox
, LB_SETCURSEL
, 0, 0);
9990 ok(ret
== 0, "expected 0, got %ld\n", ret
);
9991 ok_sequence(wm_lb_setcursel_0
, "LB_SETCURSEL 0", FALSE
);
9992 check_lb_state(listbox
, 3, 0, 0, 0);
9995 trace("selecting item 1\n");
9996 ret
= SendMessage(listbox
, LB_SETCURSEL
, 1, 0);
9997 ok(ret
== 1, "expected 1, got %ld\n", ret
);
9998 ok_sequence(wm_lb_setcursel_1
, "LB_SETCURSEL 1", FALSE
);
9999 check_lb_state(listbox
, 3, 1, 1, 0);
10001 trace("selecting item 2\n");
10002 ret
= SendMessage(listbox
, LB_SETCURSEL
, 2, 0);
10003 ok(ret
== 2, "expected 2, got %ld\n", ret
);
10004 ok_sequence(wm_lb_setcursel_2
, "LB_SETCURSEL 2", FALSE
);
10005 check_lb_state(listbox
, 3, 2, 2, 0);
10007 trace("clicking on item 0\n");
10008 ret
= SendMessage(listbox
, WM_LBUTTONDOWN
, 0, MAKELPARAM(1, 1));
10009 ok(ret
== LB_OKAY
, "expected LB_OKAY, got %ld\n", ret
);
10010 ret
= SendMessage(listbox
, WM_LBUTTONUP
, 0, 0);
10011 ok(ret
== LB_OKAY
, "expected LB_OKAY, got %ld\n", ret
);
10012 ok_sequence(wm_lb_click_0
, "WM_LBUTTONDOWN 0", FALSE
);
10013 check_lb_state(listbox
, 3, 0, 0, 0);
10016 log_all_parent_messages
--;
10018 DestroyWindow(parent
);
10024 FARPROC pIsWinEventHookInstalled
= 0;/*GetProcAddress(user32, "IsWinEventHookInstalled");*/
10028 if (!RegisterWindowClasses()) assert(0);
10030 if (pSetWinEventHook
)
10032 hEvent_hook
= (HWINEVENTHOOK
)pSetWinEventHook(EVENT_MIN
, EVENT_MAX
,
10033 GetModuleHandleA(0),
10036 GetCurrentThreadId(),
10037 WINEVENT_INCONTEXT
);
10038 assert(hEvent_hook
);
10040 if (pIsWinEventHookInstalled
)
10043 for (event
= EVENT_MIN
; event
<= EVENT_MAX
; event
++)
10044 ok(pIsWinEventHookInstalled(event
), "IsWinEventHookInstalled(%u) failed\n", event
);
10048 cbt_hook_thread_id
= GetCurrentThreadId();
10049 hCBT_hook
= SetWindowsHookExA(WH_CBT
, cbt_hook_proc
, 0, GetCurrentThreadId());
10054 /* Fix message sequences before removing 4 lines below */
10056 if (pUnhookWinEvent
&& hEvent_hook
)
10058 ret
= pUnhookWinEvent(hEvent_hook
);
10059 ok( ret
, "UnhookWinEvent error %d\n", GetLastError());
10060 pUnhookWinEvent
= 0;
10066 test_PeekMessage();
10067 test_PeekMessage2();
10068 test_scrollwindowex();
10071 invisible_parent_tests();
10072 test_mdi_messages();
10073 test_button_messages();
10074 test_static_messages();
10075 test_paint_messages();
10076 test_interthread_messages();
10077 test_message_conversion();
10078 test_accelerators();
10080 test_timers_no_wnd();
10082 test_DestroyWindow();
10083 test_DispatchMessage();
10084 test_SendMessageTimeout();
10085 test_edit_messages();
10086 test_quit_message();
10088 if (!pTrackMouseEvent
)
10089 skip("TrackMouseEvent is not available\n");
10091 test_TrackMouseEvent();
10093 test_SetWindowRgn();
10095 test_dialog_messages();
10096 test_nullCallback();
10097 test_SetForegroundWindow();
10098 test_dbcs_wm_char();
10101 UnhookWindowsHookEx(hCBT_hook
);
10102 if (pUnhookWinEvent
)
10104 ret
= pUnhookWinEvent(hEvent_hook
);
10105 ok( ret
, "UnhookWinEvent error %d\n", GetLastError());
10106 SetLastError(0xdeadbeef);
10107 ok(!pUnhookWinEvent(hEvent_hook
), "UnhookWinEvent succeeded\n");
10108 ok(GetLastError() == ERROR_INVALID_HANDLE
|| /* Win2k */
10109 GetLastError() == 0xdeadbeef, /* Win9x */
10110 "unexpected error %d\n", GetLastError());
10113 skip("UnhookWinEvent is not available\n");