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_KEYF1 0x004d
51 #define WM_SYSTIMER 0x0118
54 #define WND_PARENT_ID 1
55 #define WND_POPUP_ID 2
56 #define WND_CHILD_ID 3
58 #ifndef WM_LBTRACKPOINT
59 #define WM_LBTRACKPOINT 0x0131
62 /* encoded DRAWITEMSTRUCT into an LPARAM */
69 UINT type : 4; /* ODT_* flags */
70 UINT ctl_id : 4; /* Control ID */
71 UINT item_id : 4; /* Menu item ID */
72 UINT action : 4; /* ODA_* flags */
73 UINT state : 16; /* ODS_* flags */
79 static BOOL test_DestroyWindow_flag;
80 static HWINEVENTHOOK hEvent_hook;
82 static void dump_winpos_flags(UINT flags);
84 static const WCHAR testWindowClassW[] =
85 { 'T','e','s','t','W','i','n','d','o','w','C','l','a','s','s','W',0 };
88 FIXME: add tests for these
89 Window Edge Styles (Win31/Win95/98 look), in order of precedence:
90 WS_EX_DLGMODALFRAME: double border, WS_CAPTION allowed
91 WS_THICKFRAME: thick border
92 WS_DLGFRAME: double border, WS_CAPTION not allowed (but possibly shown anyway)
93 WS_BORDER (default for overlapped windows): single black border
94 none (default for child (and popup?) windows): no border
111 UINT message; /* the WM_* code */
112 msg_flags_t flags; /* message props */
113 WPARAM wParam; /* expected value of wParam */
114 LPARAM lParam; /* expected value of lParam */
117 /* Empty message sequence */
118 static const struct message WmEmptySeq[] =
122 /* CreateWindow (for overlapped window, not initially visible) (16/32) */
123 static const struct message WmCreateOverlappedSeq[] = {
124 { HCBT_CREATEWND, hook },
125 { WM_GETMINMAXINFO, sent },
126 { WM_NCCREATE, sent },
127 { WM_NCCALCSIZE, sent|wparam, 0 },
128 { 0x0093, sent|defwinproc|optional },
129 { 0x0094, sent|defwinproc|optional },
130 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
132 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
135 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
136 * for a not visible overlapped window.
138 static const struct message WmSWP_ShowOverlappedSeq[] = {
139 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
140 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
141 { WM_NCPAINT, sent|wparam|optional, 1 },
142 { WM_GETTEXT, sent|defwinproc|optional },
143 { WM_ERASEBKGND, sent|optional },
144 { HCBT_ACTIVATE, hook },
145 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
146 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
147 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* Win9x: SWP_NOSENDCHANGING */
148 { WM_ACTIVATEAPP, sent|wparam, 1 },
149 { WM_NCACTIVATE, sent|wparam, 1 },
150 { WM_GETTEXT, sent|defwinproc|optional },
151 { WM_ACTIVATE, sent|wparam, 1 },
152 { HCBT_SETFOCUS, hook },
153 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
154 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
155 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
156 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
157 { WM_NCPAINT, sent|wparam|optional, 1 },
158 { WM_GETTEXT, sent|defwinproc|optional },
159 { WM_ERASEBKGND, sent|optional },
160 /* Win9x adds SWP_NOZORDER below */
161 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
162 { WM_NCCALCSIZE, sent|wparam|optional, 1 },
163 { WM_NCPAINT, sent|wparam|optional, 1 },
164 { WM_ERASEBKGND, sent|optional },
165 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
166 { WM_PAINT, sent|optional },
167 { WM_NCPAINT, sent|beginpaint|optional },
168 { WM_ERASEBKGND, sent|beginpaint|optional },
171 /* SetWindowPos(SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE)
172 * for a visible overlapped window.
174 static const struct message WmSWP_HideOverlappedSeq[] = {
175 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE },
176 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
177 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
181 /* SetWindowPos(SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOMOVE)
182 * for a visible overlapped window.
184 static const struct message WmSWP_ResizeSeq[] = {
185 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE },
186 { WM_GETMINMAXINFO, sent|defwinproc },
187 { WM_NCCALCSIZE, sent|wparam, TRUE },
188 { WM_NCPAINT, sent|optional },
189 { WM_GETTEXT, sent|defwinproc|optional },
190 { WM_ERASEBKGND, sent|optional },
191 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOCLIENTMOVE },
192 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
193 { WM_NCCALCSIZE, sent|wparam|optional, TRUE },
194 { WM_NCPAINT, sent|optional },
195 { WM_GETTEXT, sent|defwinproc|optional },
196 { WM_ERASEBKGND, sent|optional },
197 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
198 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* XP sends a duplicate */
202 /* SetWindowPos(SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOMOVE)
203 * for a visible popup window.
205 static const struct message WmSWP_ResizePopupSeq[] = {
206 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE },
207 { WM_GETMINMAXINFO, sent|defwinproc|optional }, /* Win9x */
208 { WM_NCCALCSIZE, sent|wparam, TRUE },
209 { WM_NCPAINT, sent|optional },
210 { WM_GETTEXT, sent|defwinproc|optional },
211 { WM_ERASEBKGND, sent|optional },
212 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOCLIENTMOVE },
213 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
214 { WM_NCCALCSIZE, sent|wparam|optional, TRUE },
215 { WM_NCPAINT, sent|optional },
216 { WM_GETTEXT, sent|defwinproc|optional },
217 { WM_ERASEBKGND, sent|optional },
218 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
222 /* SetWindowPos(SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOSIZE)
223 * for a visible overlapped window.
225 static const struct message WmSWP_MoveSeq[] = {
226 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_NOSIZE },
227 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOCLIENTSIZE },
228 { WM_MOVE, sent|defwinproc|wparam, 0 },
229 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
232 /* Resize with SetWindowPos(SWP_NOZORDER)
233 * for a visible overlapped window
234 * SWP_NOZORDER is stripped by the logging code
236 static const struct message WmSWP_ResizeNoZOrder[] = {
237 { WM_WINDOWPOSCHANGING, sent|wparam, /*SWP_NOZORDER|*/SWP_NOACTIVATE },
238 { WM_GETMINMAXINFO, sent|defwinproc },
239 { WM_NCCALCSIZE, sent|wparam, 1 },
240 { WM_NCPAINT, sent },
241 { WM_GETTEXT, sent|defwinproc|optional },
242 { WM_ERASEBKGND, sent|optional }, /* FIXME: remove optional once Wine is fixed */
243 { WM_WINDOWPOSCHANGED, sent|wparam, /*SWP_NOZORDER|*/SWP_NOMOVE|SWP_NOCLIENTMOVE|SWP_NOACTIVATE },
244 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
245 { WM_NCCALCSIZE, sent|wparam|optional, 1 }, /* Win9x doesn't send it */
246 { WM_NCPAINT, sent|optional }, /* Win9x doesn't send it */
247 { WM_GETTEXT, sent|defwinproc|optional }, /* Win9x doesn't send it */
248 { WM_ERASEBKGND, sent|optional }, /* Win9x doesn't send it */
249 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
250 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
254 /* Switch visible mdi children */
255 static const struct message WmSwitchChild[] = {
256 /* Switch MDI child */
257 { WM_MDIACTIVATE, sent },/* in the MDI client */
258 { WM_WINDOWPOSCHANGING, sent|wparam,SWP_NOSIZE|SWP_NOMOVE },/* in the 1st MDI child */
259 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
260 { WM_CHILDACTIVATE, sent },/* in the 1st MDI child */
261 /* Deactivate 2nd MDI child */
262 { WM_NCACTIVATE, sent|wparam|defwinproc, 0 }, /* in the 2nd MDI child */
263 { WM_MDIACTIVATE, sent|defwinproc }, /* in the 2nd MDI child */
264 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
265 /* Preparing for maximize and maximaze the 1st MDI child */
266 { WM_GETMINMAXINFO, sent|defwinproc }, /* in the 1st MDI child */
267 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_STATECHANGED }, /* in the 1st MDI child */
268 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 }, /* in the 1st MDI child */
269 { WM_CHILDACTIVATE, sent|defwinproc }, /* in the 1st MDI child */
270 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_STATECHANGED }, /* in the 1st MDI child */
271 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED }, /* in the 1st MDI child */
272 /* Lock redraw 2nd MDI child */
273 { WM_SETREDRAW, sent|wparam|defwinproc, 0 }, /* in the 2nd MDI child */
274 { HCBT_MINMAX, hook|lparam, 0, SW_NORMALNA },
275 /* Restore 2nd MDI child */
276 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_STATECHANGED },/* in the 2nd MDI child */
277 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 },/* in the 2nd MDI child */
278 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 }, /* in the 2nd MDI child */
279 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_STATECHANGED }, /* in the 2nd MDI child */
280 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED }, /* in the 2nd MDI child */
281 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* in the 2nd MDI child */
282 /* Redraw 2nd MDI child */
283 { WM_SETREDRAW, sent|wparam|defwinproc, 1 },/* in the 2nd MDI child */
284 /* Redraw MDI frame */
285 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE },/* in MDI frame */
286 { WM_NCCALCSIZE, sent|wparam, 1 },/* in MDI frame */
287 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE}, /* in MDI frame */
288 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* in MDI frame */
289 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* in the 1st MDI child */
290 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE }, /* in the 1st MDI child */
291 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 }, /* in the 1st MDI child */
292 { HCBT_SETFOCUS, hook },
293 { WM_KILLFOCUS, sent|defwinproc }, /* in the 2nd MDI child */
294 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 0 },/* in the 1st MDI child */
295 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
296 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
297 { WM_SETFOCUS, sent },/* in the MDI client */
298 { HCBT_SETFOCUS, hook },
299 { WM_KILLFOCUS, sent },/* in the MDI client */
300 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
301 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 }, /* in the 1st MDI child */
302 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
303 { WM_SETFOCUS, sent|defwinproc }, /* in the 1st MDI child */
304 { WM_MDIACTIVATE, sent|defwinproc },/* in the 1st MDI child */
305 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE }, /* in the 1st MDI child */
309 /* Switch visible not maximized mdi children */
310 static const struct message WmSwitchNotMaximizedChild[] = {
311 /* Switch not maximized MDI child */
312 { WM_MDIACTIVATE, sent },/* in the MDI client */
313 { WM_WINDOWPOSCHANGING, sent|wparam,SWP_NOSIZE|SWP_NOMOVE },/* in the 2nd MDI child */
314 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
315 { WM_CHILDACTIVATE, sent },/* in the 2nd MDI child */
316 /* Deactivate 1st MDI child */
317 { WM_NCACTIVATE, sent|wparam|defwinproc, 0 }, /* in the 1st MDI child */
318 { WM_MDIACTIVATE, sent|defwinproc }, /* in the 1st MDI child */
319 /* Activate 2nd MDI child */
320 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE}, /* in the 2nd MDI child */
321 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 }, /* in the 2nd MDI child */
322 { HCBT_SETFOCUS, hook }, /* in the 1st MDI child */
323 { WM_KILLFOCUS, sent|defwinproc }, /* in the 1st MDI child */
324 { WM_IME_SETCONTEXT, sent|defwinproc|optional }, /* in the 1st MDI child */
325 { WM_IME_SETCONTEXT, sent|optional }, /* in the MDI client */
326 { WM_SETFOCUS, sent, 0 }, /* in the MDI client */
327 { HCBT_SETFOCUS, hook },
328 { WM_KILLFOCUS, sent }, /* in the MDI client */
329 { WM_IME_SETCONTEXT, sent|optional }, /* in the MDI client */
330 { WM_IME_SETCONTEXT, sent|defwinproc|optional }, /* in the 1st MDI child */
331 { WM_SETFOCUS, sent|defwinproc }, /* in the 2nd MDI child */
332 { WM_MDIACTIVATE, sent|defwinproc }, /* in the 2nd MDI child */
333 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE}, /* in the 2nd MDI child */
338 /* SetWindowPos(SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|
339 SWP_NOZORDER|SWP_FRAMECHANGED)
340 * for a visible overlapped window with WS_CLIPCHILDREN style set.
342 static const struct message WmSWP_FrameChanged_clip[] = {
343 { WM_WINDOWPOSCHANGING, sent|wparam|parent, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED },
344 { WM_NCCALCSIZE, sent|wparam|parent, 1 },
345 { WM_NCPAINT, sent|parent }, /* wparam != 1 */
346 { WM_GETTEXT, sent|parent|defwinproc|optional },
347 { WM_ERASEBKGND, sent|parent|optional }, /* FIXME: remove optional once Wine is fixed */
348 { WM_NCPAINT, sent }, /* wparam != 1 */
349 { WM_ERASEBKGND, sent },
350 { WM_WINDOWPOSCHANGED, sent|wparam|parent, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
351 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
355 /* SetWindowPos(SWP_NOSIZE|SWP_NOMOVE|SWP_DEFERERASE|SWP_NOACTIVATE|
356 SWP_NOZORDER|SWP_FRAMECHANGED)
357 * for a visible overlapped window.
359 static const struct message WmSWP_FrameChangedDeferErase[] = {
360 { WM_WINDOWPOSCHANGING, sent|wparam|parent, SWP_NOSIZE|SWP_NOMOVE|SWP_DEFERERASE|SWP_NOACTIVATE|SWP_FRAMECHANGED },
361 { WM_NCCALCSIZE, sent|wparam|parent, 1 },
362 { WM_WINDOWPOSCHANGED, sent|wparam|parent, SWP_NOSIZE|SWP_NOMOVE|SWP_DEFERERASE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
363 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
364 { WM_PAINT, sent|parent },
365 { WM_NCPAINT, sent|beginpaint|parent }, /* wparam != 1 */
366 { WM_GETTEXT, sent|beginpaint|parent|defwinproc|optional },
368 { WM_NCPAINT, sent|beginpaint }, /* wparam != 1 */
369 { WM_ERASEBKGND, sent|beginpaint },
373 /* SetWindowPos(SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|
374 SWP_NOZORDER|SWP_FRAMECHANGED)
375 * for a visible overlapped window without WS_CLIPCHILDREN style set.
377 static const struct message WmSWP_FrameChanged_noclip[] = {
378 { WM_WINDOWPOSCHANGING, sent|wparam|parent, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED },
379 { WM_NCCALCSIZE, sent|wparam|parent, 1 },
380 { WM_NCPAINT, sent|parent }, /* wparam != 1 */
381 { WM_GETTEXT, sent|parent|defwinproc|optional },
382 { WM_ERASEBKGND, sent|parent|optional }, /* FIXME: remove optional once Wine is fixed */
383 { WM_WINDOWPOSCHANGED, sent|wparam|parent, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
384 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
386 { WM_NCPAINT, sent|beginpaint }, /* wparam != 1 */
387 { WM_ERASEBKGND, sent|beginpaint },
391 /* ShowWindow(SW_SHOW) for a not visible overlapped window */
392 static const struct message WmShowOverlappedSeq[] = {
393 { WM_SHOWWINDOW, sent|wparam, 1 },
394 { WM_NCPAINT, sent|wparam|optional, 1 },
395 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
396 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
397 { WM_NCPAINT, sent|wparam|optional, 1 },
398 { WM_GETTEXT, sent|defwinproc|optional },
399 { WM_ERASEBKGND, sent|optional },
400 { HCBT_ACTIVATE, hook },
401 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
402 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
403 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE },
404 { WM_NCPAINT, sent|wparam|optional, 1 },
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_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
419 { WM_NCCALCSIZE, sent|optional },
420 { WM_NCPAINT, sent|optional },
421 { WM_ERASEBKGND, sent|optional },
422 #if 0 /* CreateWindow/ShowWindow(SW_SHOW) also generates WM_SIZE/WM_MOVE
423 * messages. Does that mean that CreateWindow doesn't set initial
424 * window dimensions for overlapped windows?
429 { WM_PAINT, sent|optional },
430 { WM_NCPAINT, sent|beginpaint|optional },
433 /* ShowWindow(SW_SHOWMAXIMIZED) for a not visible overlapped window */
434 static const struct message WmShowMaxOverlappedSeq[] = {
435 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
436 { WM_GETMINMAXINFO, sent },
437 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_STATECHANGED },
438 { WM_GETMINMAXINFO, sent|defwinproc },
439 { WM_NCCALCSIZE, sent|wparam, TRUE },
440 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
441 { HCBT_ACTIVATE, hook },
442 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
443 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
444 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE },
445 { WM_ACTIVATEAPP, sent|wparam, 1 },
446 { WM_NCACTIVATE, sent|wparam, 1 },
447 { WM_GETTEXT, sent|defwinproc|optional },
448 { WM_ACTIVATE, sent|wparam, 1 },
449 { HCBT_SETFOCUS, hook },
450 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
451 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
452 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
453 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
454 { WM_NCPAINT, sent|wparam|optional, 1 },
455 { WM_GETTEXT, sent|defwinproc|optional },
456 { WM_ERASEBKGND, sent|optional },
457 /* Win9x adds SWP_NOZORDER below */
458 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_STATECHANGED },
459 { WM_MOVE, sent|defwinproc },
460 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
461 { WM_NCCALCSIZE, sent|optional },
462 { WM_NCPAINT, sent|optional },
463 { WM_ERASEBKGND, sent|optional },
464 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
465 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
466 { WM_PAINT, sent|optional },
467 { WM_NCPAINT, sent|beginpaint|optional },
468 { WM_ERASEBKGND, sent|beginpaint|optional },
471 /* ShowWindow(SW_RESTORE) for a not visible maximized overlapped window */
472 static const struct message WmShowRestoreMaxOverlappedSeq[] = {
473 { HCBT_MINMAX, hook|lparam, 0, SW_RESTORE },
474 { WM_GETTEXT, sent|optional },
475 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_STATECHANGED },
476 { WM_GETMINMAXINFO, sent|defwinproc },
477 { WM_NCCALCSIZE, sent|wparam, TRUE },
478 { WM_NCPAINT, sent|optional },
479 { WM_GETTEXT, sent|defwinproc|optional },
480 { WM_ERASEBKGND, sent|optional },
481 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_STATECHANGED },
482 { WM_MOVE, sent|defwinproc },
483 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
484 { WM_NCCALCSIZE, sent|wparam|optional, TRUE },
485 { WM_NCPAINT, sent|optional },
486 { WM_ERASEBKGND, sent|optional },
487 { WM_PAINT, sent|optional },
488 { WM_NCPAINT, sent|beginpaint|optional },
489 { WM_ERASEBKGND, sent|beginpaint|optional },
492 /* ShowWindow(SW_RESTORE) for a not visible minimized overlapped window */
493 static const struct message WmShowRestoreMinOverlappedSeq[] = {
494 { HCBT_MINMAX, hook|lparam, 0, SW_RESTORE },
495 { WM_QUERYOPEN, sent|optional },
496 { WM_GETTEXT, sent|optional },
497 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_STATECHANGED|SWP_NOCOPYBITS },
498 { WM_GETMINMAXINFO, sent|defwinproc },
499 { WM_NCCALCSIZE, sent|wparam, TRUE },
500 { HCBT_ACTIVATE, hook },
501 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE },
502 { WM_ACTIVATEAPP, sent|wparam, 1 },
503 { WM_NCACTIVATE, sent|wparam, 1 },
504 { WM_GETTEXT, sent|defwinproc|optional },
505 { WM_ACTIVATE, sent|wparam, 1 },
506 { HCBT_SETFOCUS, hook },
507 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
508 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
509 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
510 { WM_NCPAINT, sent|wparam|optional, 1 },
511 { WM_GETTEXT, sent|defwinproc|optional },
512 { WM_ERASEBKGND, sent },
513 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_STATECHANGED|SWP_FRAMECHANGED|SWP_NOCOPYBITS },
514 { WM_MOVE, sent|defwinproc },
515 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
516 { WM_NCCALCSIZE, sent|wparam|optional, TRUE },
517 { WM_NCPAINT, sent|wparam|optional, 1 },
518 { WM_ERASEBKGND, sent|optional },
519 { WM_ACTIVATE, sent|wparam, 1 },
520 { WM_PAINT, sent|optional },
521 { WM_NCPAINT, sent|beginpaint|optional },
522 { WM_ERASEBKGND, sent|beginpaint|optional },
525 /* ShowWindow(SW_SHOWMINIMIZED) for a not visible overlapped window */
526 static const struct message WmShowMinOverlappedSeq[] = {
527 { HCBT_MINMAX, hook|lparam, 0, SW_MINIMIZE },
528 { HCBT_SETFOCUS, hook },
529 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
530 { WM_KILLFOCUS, sent },
531 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
532 { WM_IME_NOTIFY, sent|wparam|optional|defwinproc, 1 },
533 { WM_GETTEXT, sent|optional },
534 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOCOPYBITS|SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_STATECHANGED },
535 { WM_GETMINMAXINFO, sent|defwinproc },
536 { WM_NCCALCSIZE, sent|wparam, TRUE },
537 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
538 { WM_NCPAINT, sent|optional },
539 { WM_GETTEXT, sent|defwinproc|optional },
540 { WM_WINDOWPOSCHANGED, sent },
541 { WM_MOVE, sent|defwinproc },
542 { WM_SIZE, sent|defwinproc|wparam, SIZE_MINIMIZED },
543 { WM_NCCALCSIZE, sent|optional },
544 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
545 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
546 { EVENT_SYSTEM_MINIMIZESTART, winevent_hook|wparam|lparam, 0, 0 },
547 { WM_NCACTIVATE, sent|wparam, 0 },
548 { WM_GETTEXT, sent|defwinproc|optional },
549 { WM_ACTIVATE, sent },
550 { WM_ACTIVATEAPP, sent|wparam, 0 },
551 { WM_PAINT, sent|optional },
552 { WM_NCPAINT, sent|beginpaint|optional },
553 { WM_ERASEBKGND, sent|beginpaint|optional },
556 /* ShowWindow(SW_HIDE) for a visible overlapped window */
557 static const struct message WmHideOverlappedSeq[] = {
558 { WM_SHOWWINDOW, sent|wparam, 0 },
559 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE },
560 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
561 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
562 { WM_SIZE, sent|optional }, /* XP doesn't send it */
563 { WM_MOVE, sent|optional }, /* XP doesn't send it */
564 { WM_NCACTIVATE, sent|wparam, 0 },
565 { WM_ACTIVATE, sent|wparam, 0 },
566 { WM_ACTIVATEAPP, sent|wparam, 0 },
567 { WM_KILLFOCUS, sent|wparam, 0 },
568 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
569 { WM_IME_NOTIFY, sent|wparam|optional|defwinproc, 1 },
572 /* DestroyWindow for a visible overlapped window */
573 static const struct message WmDestroyOverlappedSeq[] = {
574 { HCBT_DESTROYWND, hook },
575 { 0x0090, sent|optional },
576 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
577 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
578 { 0x0090, sent|optional },
579 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
580 { WM_NCACTIVATE, sent|optional|wparam, 0 },
581 { WM_ACTIVATE, sent|optional|wparam, 0 },
582 { WM_ACTIVATEAPP, sent|optional|wparam, 0 },
583 { WM_KILLFOCUS, sent|optional|wparam, 0 },
584 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
585 { WM_IME_NOTIFY, sent|wparam|optional|defwinproc, 1 },
586 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
587 { WM_DESTROY, sent },
588 { WM_NCDESTROY, sent },
591 /* CreateWindow(WS_MAXIMIZE|WS_VISIBLE) for popup window */
592 static const struct message WmCreateMaxPopupSeq[] = {
593 { HCBT_CREATEWND, hook },
594 { WM_NCCREATE, sent },
595 { WM_NCCALCSIZE, sent|wparam, 0 },
597 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
598 { WM_SIZE, sent|wparam, SIZE_RESTORED },
600 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
601 { WM_GETMINMAXINFO, sent },
602 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_STATECHANGED },
603 { WM_NCCALCSIZE, sent|wparam, TRUE },
604 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOREDRAW|SWP_STATECHANGED },
605 { WM_MOVE, sent|defwinproc },
606 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
607 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
608 { WM_SHOWWINDOW, sent|wparam, 1 },
609 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
610 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
611 { HCBT_ACTIVATE, hook },
612 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
613 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
614 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE },
615 { WM_ACTIVATEAPP, sent|wparam, 1 },
616 { WM_NCACTIVATE, sent|wparam, 1 },
617 { WM_ACTIVATE, sent|wparam, 1 },
618 { HCBT_SETFOCUS, hook },
619 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
620 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
621 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
622 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
623 { WM_SYNCPAINT, sent|wparam|optional, 4 },
624 { WM_NCPAINT, sent|wparam|optional, 1 },
625 { WM_ERASEBKGND, sent|optional },
626 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOCLIENTMOVE|SWP_NOCLIENTSIZE|SWP_SHOWWINDOW|SWP_NOMOVE|SWP_NOSIZE },
629 /* CreateWindow(WS_MAXIMIZE) for popup window, not initially visible */
630 static const struct message WmCreateInvisibleMaxPopupSeq[] = {
631 { HCBT_CREATEWND, hook },
632 { WM_NCCREATE, sent },
633 { WM_NCCALCSIZE, sent|wparam, 0 },
635 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
636 { WM_SIZE, sent|wparam, SIZE_RESTORED },
638 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
639 { WM_GETMINMAXINFO, sent },
640 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_STATECHANGED },
641 { WM_NCCALCSIZE, sent|wparam, TRUE },
642 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOREDRAW|SWP_STATECHANGED },
643 { WM_MOVE, sent|defwinproc },
644 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
645 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
648 /* ShowWindow(SW_SHOWMAXIMIZED) for a resized not visible popup window */
649 static const struct message WmShowMaxPopupResizedSeq[] = {
650 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
651 { WM_GETMINMAXINFO, sent },
652 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED },
653 { WM_NCCALCSIZE, sent|wparam, TRUE },
654 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
655 { HCBT_ACTIVATE, hook },
656 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
657 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
658 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE },
659 { WM_ACTIVATEAPP, sent|wparam, 1 },
660 { WM_NCACTIVATE, sent|wparam, 1 },
661 { WM_ACTIVATE, sent|wparam, 1 },
662 { HCBT_SETFOCUS, hook },
663 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
664 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
665 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
666 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
667 { WM_NCPAINT, sent|wparam|optional, 1 },
668 { WM_ERASEBKGND, sent|optional },
669 { WM_WINDOWPOSCHANGED, sent },
670 /* WinNT4.0 sends WM_MOVE */
671 { WM_MOVE, sent|defwinproc|optional },
672 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
673 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
676 /* ShowWindow(SW_SHOWMAXIMIZED) for a not visible popup window */
677 static const struct message WmShowMaxPopupSeq[] = {
678 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
679 { WM_GETMINMAXINFO, sent },
680 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED },
681 { WM_NCCALCSIZE, sent|wparam, TRUE },
682 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
683 { HCBT_ACTIVATE, hook },
684 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
685 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
686 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE },
687 { WM_ACTIVATEAPP, sent|wparam, 1 },
688 { WM_NCACTIVATE, sent|wparam, 1 },
689 { WM_ACTIVATE, sent|wparam, 1 },
690 { HCBT_SETFOCUS, hook },
691 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
692 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
693 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
694 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
695 { WM_SYNCPAINT, sent|wparam|optional, 4 },
696 { WM_NCPAINT, sent|wparam|optional, 1 },
697 { WM_ERASEBKGND, sent|optional },
698 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOMOVE|SWP_NOSIZE },
699 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
702 /* CreateWindow(WS_VISIBLE) for popup window */
703 static const struct message WmCreatePopupSeq[] = {
704 { HCBT_CREATEWND, hook },
705 { WM_NCCREATE, sent },
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_SHOWWINDOW, sent|wparam, 1 },
712 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
713 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
714 { HCBT_ACTIVATE, hook },
715 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
716 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
717 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE },
718 { WM_NCPAINT, sent|wparam|optional, 1 },
719 { WM_ERASEBKGND, sent|optional },
720 { WM_ACTIVATEAPP, sent|wparam, 1 },
721 { WM_NCACTIVATE, sent|wparam, 1 },
722 { WM_ACTIVATE, sent|wparam, 1 },
723 { HCBT_SETFOCUS, hook },
724 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
725 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
726 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
727 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
728 { WM_SYNCPAINT, sent|wparam|optional, 4 },
729 { WM_NCPAINT, sent|wparam|optional, 1 },
730 { WM_ERASEBKGND, sent|optional },
731 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOCLIENTMOVE|SWP_NOCLIENTSIZE|SWP_SHOWWINDOW|SWP_NOMOVE|SWP_NOSIZE },
734 /* ShowWindow(SW_SHOWMAXIMIZED) for a visible popup window */
735 static const struct message WmShowVisMaxPopupSeq[] = {
736 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
737 { WM_GETMINMAXINFO, sent },
738 { WM_GETTEXT, sent|optional },
739 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_STATECHANGED },
740 { WM_NCCALCSIZE, sent|wparam, TRUE },
741 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
742 { WM_NCPAINT, sent|wparam|optional, 1 },
743 { WM_ERASEBKGND, sent|optional },
744 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_STATECHANGED },
745 { WM_MOVE, sent|defwinproc },
746 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
747 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
750 /* CreateWindow (for a child popup window, not initially visible) */
751 static const struct message WmCreateChildPopupSeq[] = {
752 { HCBT_CREATEWND, hook },
753 { WM_NCCREATE, sent },
754 { WM_NCCALCSIZE, sent|wparam, 0 },
756 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
757 { WM_SIZE, sent|wparam, SIZE_RESTORED },
761 /* CreateWindow (for a popup window, not initially visible,
762 * which sets WS_VISIBLE in WM_CREATE handler)
764 static const struct message WmCreateInvisiblePopupSeq[] = {
765 { HCBT_CREATEWND, hook },
766 { WM_NCCREATE, sent },
767 { WM_NCCALCSIZE, sent|wparam, 0 },
769 { WM_STYLECHANGING, sent },
770 { WM_STYLECHANGED, sent },
771 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
772 { WM_SIZE, sent|wparam, SIZE_RESTORED },
776 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER)
777 * for a popup window with WS_VISIBLE style set
779 static const struct message WmShowVisiblePopupSeq_2[] = {
780 { WM_WINDOWPOSCHANGING, sent|wparam, 0 },
783 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
784 * for a popup window with WS_VISIBLE style set
786 static const struct message WmShowVisiblePopupSeq_3[] = {
787 { WM_WINDOWPOSCHANGING, sent|wparam, 0 },
788 { HCBT_ACTIVATE, hook },
789 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
790 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
791 { WM_WINDOWPOSCHANGING, sent|wparam, 0 },
792 { WM_NCACTIVATE, sent|wparam, 1 },
793 { WM_ACTIVATE, sent|wparam, 1 },
794 { HCBT_SETFOCUS, hook },
795 { WM_KILLFOCUS, sent|parent },
796 { WM_IME_SETCONTEXT, sent|parent|wparam|optional, 0 },
797 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
798 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
799 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
800 { WM_SETFOCUS, sent|defwinproc },
803 /* CreateWindow (for child window, not initially visible) */
804 static const struct message WmCreateChildSeq[] = {
805 { HCBT_CREATEWND, hook },
806 { WM_NCCREATE, sent },
807 /* child is inserted into parent's child list after WM_NCCREATE returns */
808 { WM_NCCALCSIZE, sent|wparam, 0 },
810 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
811 { WM_SIZE, sent|wparam, SIZE_RESTORED },
813 { WM_PARENTNOTIFY, sent|parent|wparam, WM_CREATE },
816 /* CreateWindow (for maximized child window, not initially visible) */
817 static const struct message WmCreateMaximizedChildSeq[] = {
818 { HCBT_CREATEWND, hook },
819 { WM_NCCREATE, sent },
820 { WM_NCCALCSIZE, sent|wparam, 0 },
822 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
823 { WM_SIZE, sent|wparam, SIZE_RESTORED },
825 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
826 { WM_GETMINMAXINFO, sent },
827 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_STATECHANGED },
828 { WM_NCCALCSIZE, sent|wparam, 1 },
829 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTMOVE|SWP_STATECHANGED },
830 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
831 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
832 { WM_PARENTNOTIFY, sent|parent|wparam, WM_CREATE },
835 /* CreateWindow (for a child window, initially visible) */
836 static const struct message WmCreateVisibleChildSeq[] = {
837 { HCBT_CREATEWND, hook },
838 { WM_NCCREATE, sent },
839 /* child is inserted into parent's child list after WM_NCCREATE returns */
840 { WM_NCCALCSIZE, sent|wparam, 0 },
841 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
843 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
844 { WM_SIZE, sent|wparam, SIZE_RESTORED },
846 { WM_PARENTNOTIFY, sent|parent|wparam, WM_CREATE },
847 { WM_SHOWWINDOW, sent|wparam, 1 },
848 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
849 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
850 { WM_ERASEBKGND, sent|parent|optional },
851 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
852 { WM_NCCALCSIZE, sent|wparam|optional, 1 }, /* WinXP */
853 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
856 /* ShowWindow(SW_SHOW) for a not visible child window */
857 static const struct message WmShowChildSeq[] = {
858 { WM_SHOWWINDOW, sent|wparam, 1 },
859 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
860 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
861 { WM_ERASEBKGND, sent|parent|optional },
862 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
865 /* ShowWindow(SW_HIDE) for a visible child window */
866 static const struct message WmHideChildSeq[] = {
867 { WM_SHOWWINDOW, sent|wparam, 0 },
868 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
869 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
870 { WM_ERASEBKGND, sent|parent|optional },
871 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
874 /* ShowWindow(SW_HIDE) for a visible child window checking all parent events*/
875 static const struct message WmHideChildSeq2[] = {
876 { WM_SHOWWINDOW, sent|wparam, 0 },
877 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
878 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
879 { WM_ERASEBKGND, sent|parent },
880 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
883 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
884 * for a not visible child window
886 static const struct message WmShowChildSeq_2[] = {
887 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
888 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
889 { WM_CHILDACTIVATE, sent },
890 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
893 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE)
894 * for a not visible child window
896 static const struct message WmShowChildSeq_3[] = {
897 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
898 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
899 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
902 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
903 * for a visible child window with a caption
905 static const struct message WmShowChildSeq_4[] = {
906 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
907 { WM_CHILDACTIVATE, sent },
910 /* ShowWindow(SW_MINIMIZE) for child with invisible parent */
911 static const struct message WmShowChildInvisibleParentSeq_1[] = {
912 { HCBT_MINMAX, hook|lparam, 0, SW_MINIMIZE },
913 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOCOPYBITS|SWP_STATECHANGED },
914 { WM_NCCALCSIZE, sent|wparam, 1 },
915 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
916 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOREDRAW|SWP_NOCOPYBITS|SWP_STATECHANGED },
917 { WM_MOVE, sent|defwinproc },
918 { WM_SIZE, sent|defwinproc|wparam, SIZE_MINIMIZED },
919 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
920 { EVENT_SYSTEM_MINIMIZESTART, winevent_hook|wparam|lparam, 0, 0 },
921 /* FIXME: Wine creates an icon/title window while Windows doesn't */
922 { WM_PARENTNOTIFY, sent|parent|wparam|optional, WM_CREATE },
923 { WM_GETTEXT, sent|optional },
926 /* repeated ShowWindow(SW_MINIMIZE) for child with invisible parent */
927 static const struct message WmShowChildInvisibleParentSeq_1r[] = {
928 { HCBT_MINMAX, hook|lparam, 0, SW_MINIMIZE },
931 /* ShowWindow(SW_MAXIMIZE) for child with invisible parent */
932 static const struct message WmShowChildInvisibleParentSeq_2[] = {
933 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
934 { WM_GETMINMAXINFO, sent },
935 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_STATECHANGED },
936 { WM_NCCALCSIZE, sent|wparam, 1 },
937 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
938 { WM_CHILDACTIVATE, sent },
939 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTMOVE|SWP_STATECHANGED },
940 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
941 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
944 /* repeated ShowWindow(SW_MAXIMIZE) for child with invisible parent */
945 static const struct message WmShowChildInvisibleParentSeq_2r[] = {
946 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
949 /* ShowWindow(SW_SHOWMINIMIZED) for child with invisible parent */
950 static const struct message WmShowChildInvisibleParentSeq_3[] = {
951 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMINIMIZED },
952 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
953 { WM_NCCALCSIZE, sent|wparam, 1 },
954 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
955 { WM_CHILDACTIVATE, sent },
956 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOREDRAW|SWP_NOCOPYBITS|SWP_STATECHANGED },
957 { WM_MOVE, sent|defwinproc },
958 { WM_SIZE, sent|defwinproc|wparam, SIZE_MINIMIZED },
959 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
960 { EVENT_SYSTEM_MINIMIZESTART, winevent_hook|wparam|lparam, 0, 0 },
961 /* FIXME: Wine creates an icon/title window while Windows doesn't */
962 { WM_PARENTNOTIFY, sent|parent|wparam|optional, WM_CREATE },
963 { WM_GETTEXT, sent|optional },
966 /* repeated ShowWindow(SW_SHOWMINIMIZED) for child with invisible parent */
967 static const struct message WmShowChildInvisibleParentSeq_3r[] = {
968 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMINIMIZED },
971 /* ShowWindow(SW_SHOWMINNOACTIVE) for child with invisible parent */
972 static const struct message WmShowChildInvisibleParentSeq_4[] = {
973 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMINNOACTIVE },
974 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOCOPYBITS|SWP_STATECHANGED },
975 { WM_NCCALCSIZE, sent|wparam, 1 },
976 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
977 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOREDRAW|SWP_NOCOPYBITS|SWP_STATECHANGED },
978 { WM_MOVE, sent|defwinproc },
979 { WM_SIZE, sent|defwinproc|wparam, SIZE_MINIMIZED },
980 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
981 { EVENT_SYSTEM_MINIMIZESTART, winevent_hook|wparam|lparam, 0, 0 },
982 /* FIXME: Wine creates an icon/title window while Windows doesn't */
983 { WM_PARENTNOTIFY, sent|parent|wparam|optional, WM_CREATE },
984 { WM_GETTEXT, sent|optional },
987 /* repeated ShowWindow(SW_SHOWMINNOACTIVE) for child with invisible parent */
988 static const struct message WmShowChildInvisibleParentSeq_4r[] = {
989 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMINNOACTIVE },
992 /* ShowWindow(SW_SHOW) for child with invisible parent */
993 static const struct message WmShowChildInvisibleParentSeq_5[] = {
994 { WM_SHOWWINDOW, sent|wparam, 1 },
997 /* ShowWindow(SW_HIDE) for child with invisible parent */
998 static const struct message WmHideChildInvisibleParentSeq[] = {
999 { WM_SHOWWINDOW, sent|wparam, 0 },
1002 /* SetWindowPos(SWP_SHOWWINDOW) for child with invisible parent */
1003 static const struct message WmShowChildInvisibleParentSeq_6[] = {
1004 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
1005 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1006 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1009 /* SetWindowPos(SWP_HIDEWINDOW) for child with invisible parent */
1010 static const struct message WmHideChildInvisibleParentSeq_2[] = {
1011 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1012 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
1013 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1016 /* DestroyWindow for a visible child window */
1017 static const struct message WmDestroyChildSeq[] = {
1018 { HCBT_DESTROYWND, hook },
1019 { 0x0090, sent|optional },
1020 { WM_PARENTNOTIFY, sent|parent|wparam, WM_DESTROY },
1021 { WM_SHOWWINDOW, sent|wparam, 0 },
1022 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1023 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
1024 { WM_ERASEBKGND, sent|parent|optional },
1025 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1026 { HCBT_SETFOCUS, hook }, /* set focus to a parent */
1027 { WM_KILLFOCUS, sent },
1028 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
1029 { WM_IME_SETCONTEXT, sent|wparam|parent|optional, 1 },
1030 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1031 { WM_SETFOCUS, sent|parent },
1032 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
1033 { WM_DESTROY, sent },
1034 { WM_DESTROY, sent|optional }, /* some other (IME?) window */
1035 { WM_NCDESTROY, sent|optional }, /* some other (IME?) window */
1036 { WM_NCDESTROY, sent },
1039 /* DestroyWindow for a visible child window with invisible parent */
1040 static const struct message WmDestroyInvisibleChildSeq[] = {
1041 { HCBT_DESTROYWND, hook },
1042 { 0x0090, sent|optional },
1043 { WM_PARENTNOTIFY, sent|parent|wparam, WM_DESTROY },
1044 { WM_SHOWWINDOW, sent|wparam, 0 },
1045 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
1046 { WM_DESTROY, sent },
1047 { WM_NCDESTROY, sent },
1050 /* Moving the mouse in nonclient area */
1051 static const struct message WmMouseMoveInNonClientAreaSeq[] = { /* FIXME: add */
1052 { WM_NCHITTEST, sent },
1053 { WM_SETCURSOR, sent },
1054 { WM_NCMOUSEMOVE, posted },
1057 /* Moving the mouse in client area */
1058 static const struct message WmMouseMoveInClientAreaSeq[] = { /* FIXME: add */
1059 { WM_NCHITTEST, sent },
1060 { WM_SETCURSOR, sent },
1061 { WM_MOUSEMOVE, posted },
1064 /* Moving by dragging the title bar (after WM_NCHITTEST and WM_SETCURSOR) (outline move) */
1065 static const struct message WmDragTitleBarSeq[] = { /* FIXME: add */
1066 { WM_NCLBUTTONDOWN, sent|wparam, HTCAPTION },
1067 { WM_SYSCOMMAND, sent|defwinproc|wparam, SC_MOVE+2 },
1068 { WM_GETMINMAXINFO, sent|defwinproc },
1069 { WM_ENTERSIZEMOVE, sent|defwinproc },
1070 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, 0 },
1071 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, 0 },
1072 { WM_MOVE, sent|defwinproc },
1073 { WM_EXITSIZEMOVE, sent|defwinproc },
1076 /* Sizing by dragging the thick borders (after WM_NCHITTEST and WM_SETCURSOR) (outline move) */
1077 static const struct message WmDragThickBordersBarSeq[] = { /* FIXME: add */
1078 { WM_NCLBUTTONDOWN, sent|wparam, 0xd },
1079 { WM_SYSCOMMAND, sent|defwinproc|wparam, 0xf004 },
1080 { WM_GETMINMAXINFO, sent|defwinproc },
1081 { WM_ENTERSIZEMOVE, sent|defwinproc },
1082 { WM_SIZING, sent|defwinproc|wparam, 4}, /* one for each mouse movement */
1083 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, 0 },
1084 { WM_GETMINMAXINFO, sent|defwinproc },
1085 { WM_NCCALCSIZE, sent|defwinproc|wparam, 1 },
1086 { WM_NCPAINT, sent|defwinproc|wparam, 1 },
1087 { WM_GETTEXT, sent|defwinproc },
1088 { WM_ERASEBKGND, sent|defwinproc },
1089 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, 0 },
1090 { WM_MOVE, sent|defwinproc },
1091 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
1092 { WM_EXITSIZEMOVE, sent|defwinproc },
1095 /* Resizing child window with MoveWindow (32) */
1096 static const struct message WmResizingChildWithMoveWindowSeq[] = {
1097 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE },
1098 { WM_NCCALCSIZE, sent|wparam, 1 },
1099 { WM_ERASEBKGND, sent|parent|optional },
1100 { WM_ERASEBKGND, sent|optional },
1101 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE },
1102 { WM_MOVE, sent|defwinproc },
1103 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
1104 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1107 /* Clicking on inactive button */
1108 static const struct message WmClickInactiveButtonSeq[] = { /* FIXME: add */
1109 { WM_NCHITTEST, sent },
1110 { WM_PARENTNOTIFY, sent|parent|wparam, WM_LBUTTONDOWN },
1111 { WM_MOUSEACTIVATE, sent },
1112 { WM_MOUSEACTIVATE, sent|parent|defwinproc },
1113 { WM_SETCURSOR, sent },
1114 { WM_SETCURSOR, sent|parent|defwinproc },
1115 { WM_LBUTTONDOWN, posted },
1116 { WM_KILLFOCUS, posted|parent },
1117 { WM_SETFOCUS, posted },
1118 { WM_CTLCOLORBTN, posted|parent },
1119 { BM_SETSTATE, posted },
1120 { WM_CTLCOLORBTN, posted|parent },
1121 { WM_LBUTTONUP, posted },
1122 { BM_SETSTATE, posted },
1123 { WM_CTLCOLORBTN, posted|parent },
1124 { WM_COMMAND, posted|parent },
1127 /* Reparenting a button (16/32) */
1128 /* The last child (button) reparented gets topmost for its new parent. */
1129 static const struct message WmReparentButtonSeq[] = { /* FIXME: add */
1130 { WM_SHOWWINDOW, sent|wparam, 0 },
1131 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE },
1132 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
1133 { WM_ERASEBKGND, sent|parent },
1134 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE },
1135 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE },
1136 { WM_CHILDACTIVATE, sent },
1137 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOSIZE|SWP_NOREDRAW },
1138 { WM_MOVE, sent|defwinproc },
1139 { WM_SHOWWINDOW, sent|wparam, 1 },
1142 /* Creation of a custom dialog (32) */
1143 static const struct message WmCreateCustomDialogSeq[] = {
1144 { HCBT_CREATEWND, hook },
1145 { WM_GETMINMAXINFO, sent },
1146 { WM_NCCREATE, sent },
1147 { WM_NCCALCSIZE, sent|wparam, 0 },
1148 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
1149 { WM_CREATE, sent },
1150 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1151 { WM_SHOWWINDOW, sent|wparam, 1 },
1152 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
1153 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1154 { HCBT_ACTIVATE, hook },
1155 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
1158 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
1160 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE },
1162 { WM_NCACTIVATE, sent|wparam, 1 },
1163 { WM_GETTEXT, sent|optional|defwinproc },
1164 { WM_GETTEXT, sent|optional|defwinproc },
1165 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
1166 { WM_ACTIVATE, sent|wparam, 1 },
1167 { WM_KILLFOCUS, sent|parent },
1168 { WM_IME_SETCONTEXT, sent|parent|wparam|optional, 0 },
1169 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
1170 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
1171 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1172 { WM_SETFOCUS, sent },
1173 { WM_GETDLGCODE, sent|defwinproc|wparam, 0 },
1174 { WM_NCPAINT, sent|wparam, 1 },
1175 { WM_GETTEXT, sent|optional|defwinproc },
1176 { WM_GETTEXT, sent|optional|defwinproc },
1177 { WM_ERASEBKGND, sent },
1178 { WM_CTLCOLORDLG, sent|defwinproc },
1179 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1180 { WM_GETTEXT, sent|optional },
1181 { WM_GETTEXT, sent|optional },
1182 { WM_NCCALCSIZE, sent|optional },
1183 { WM_NCPAINT, sent|optional },
1184 { WM_GETTEXT, sent|optional|defwinproc },
1185 { WM_GETTEXT, sent|optional|defwinproc },
1186 { WM_ERASEBKGND, sent|optional },
1187 { WM_CTLCOLORDLG, sent|optional|defwinproc },
1188 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1189 { WM_SIZE, sent|wparam, SIZE_RESTORED },
1193 /* Calling EndDialog for a custom dialog (32) */
1194 static const struct message WmEndCustomDialogSeq[] = {
1195 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1196 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
1197 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1198 { WM_GETTEXT, sent|optional },
1199 { HCBT_ACTIVATE, hook },
1200 { WM_NCACTIVATE, sent|wparam, 0 },
1201 { WM_GETTEXT, sent|optional|defwinproc },
1202 { WM_GETTEXT, sent|optional|defwinproc },
1203 { WM_ACTIVATE, sent|wparam, 0 },
1204 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
1205 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1206 { HCBT_SETFOCUS, hook },
1207 { WM_KILLFOCUS, sent },
1208 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
1209 { WM_IME_SETCONTEXT, sent|parent|wparam|defwinproc|optional, 1 },
1210 { WM_IME_NOTIFY, sent|wparam|optional, 1 },
1211 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1212 { WM_SETFOCUS, sent|parent|defwinproc },
1215 /* ShowWindow(SW_SHOW) for a custom dialog (initially invisible) */
1216 static const struct message WmShowCustomDialogSeq[] = {
1217 { WM_SHOWWINDOW, sent|wparam, 1 },
1218 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
1219 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1220 { HCBT_ACTIVATE, hook },
1221 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
1223 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
1225 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE },
1226 { WM_ACTIVATEAPP, sent|wparam|optional, 1 },
1227 { WM_NCACTIVATE, sent|wparam, 1 },
1228 { WM_ACTIVATE, sent|wparam, 1 },
1230 { WM_KILLFOCUS, sent|parent },
1231 { WM_IME_SETCONTEXT, sent|parent|wparam|optional, 0 },
1232 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
1233 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
1234 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1235 { WM_SETFOCUS, sent },
1236 { WM_GETDLGCODE, sent|defwinproc|wparam, 0 },
1237 { WM_NCPAINT, sent|wparam, 1 },
1238 { WM_ERASEBKGND, sent },
1239 { WM_CTLCOLORDLG, sent|defwinproc },
1240 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1243 /* Creation and destruction of a modal dialog (32) */
1244 static const struct message WmModalDialogSeq[] = {
1245 { WM_CANCELMODE, sent|parent },
1246 { HCBT_SETFOCUS, hook },
1247 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1248 { WM_KILLFOCUS, sent|parent },
1249 { WM_IME_SETCONTEXT, sent|parent|wparam|optional, 0 },
1250 { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, 0, 0 },
1251 { WM_ENABLE, sent|parent|wparam, 0 },
1252 { HCBT_CREATEWND, hook },
1253 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
1254 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1255 { WM_SETFONT, sent },
1256 { WM_INITDIALOG, sent },
1257 { WM_CHANGEUISTATE, sent|optional },
1258 { WM_UPDATEUISTATE, sent|optional },
1259 { WM_SHOWWINDOW, sent },
1260 { HCBT_ACTIVATE, hook },
1261 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
1262 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
1263 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE },
1264 { WM_NCACTIVATE, sent|wparam, 1 },
1265 { WM_GETTEXT, sent|optional },
1266 { WM_ACTIVATE, sent|wparam, 1 },
1267 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
1268 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1269 { WM_NCPAINT, sent },
1270 { WM_GETTEXT, sent|optional },
1271 { WM_ERASEBKGND, sent },
1272 { WM_CTLCOLORDLG, sent },
1273 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1274 { WM_GETTEXT, sent|optional },
1275 { WM_NCCALCSIZE, sent|optional },
1276 { WM_NCPAINT, sent|optional },
1277 { WM_GETTEXT, sent|optional },
1278 { WM_ERASEBKGND, sent|optional },
1279 { WM_CTLCOLORDLG, sent|optional },
1280 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1281 { WM_PAINT, sent|optional },
1282 { WM_CTLCOLORBTN, sent },
1283 { WM_ENTERIDLE, sent|parent|optional },
1284 { WM_ENTERIDLE, sent|parent|optional },
1285 { WM_ENTERIDLE, sent|parent|optional },
1286 { WM_ENTERIDLE, sent|parent|optional },
1287 { WM_ENTERIDLE, sent|parent|optional },
1288 { WM_ENTERIDLE, sent|parent|optional },
1289 { WM_ENTERIDLE, sent|parent|optional },
1290 { WM_ENTERIDLE, sent|parent|optional },
1291 { WM_ENTERIDLE, sent|parent|optional },
1292 { WM_ENTERIDLE, sent|parent|optional },
1293 { WM_ENTERIDLE, sent|parent|optional },
1294 { WM_ENTERIDLE, sent|parent|optional },
1295 { WM_ENTERIDLE, sent|parent|optional },
1296 { WM_ENTERIDLE, sent|parent|optional },
1297 { WM_ENTERIDLE, sent|parent|optional },
1298 { WM_ENTERIDLE, sent|parent|optional },
1299 { WM_ENTERIDLE, sent|parent|optional },
1300 { WM_ENTERIDLE, sent|parent|optional },
1301 { WM_ENTERIDLE, sent|parent|optional },
1302 { WM_ENTERIDLE, sent|parent|optional },
1304 { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, 0, 0 },
1305 { WM_ENABLE, sent|parent|wparam, 1 },
1306 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
1307 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
1308 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1309 { WM_GETTEXT, sent|optional },
1310 { HCBT_ACTIVATE, hook },
1311 { WM_NCACTIVATE, sent|wparam, 0 },
1312 { WM_GETTEXT, sent|optional },
1313 { WM_ACTIVATE, sent|wparam, 0 },
1314 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
1315 { WM_WINDOWPOSCHANGING, sent|optional },
1316 { WM_WINDOWPOSCHANGED, sent|optional },
1317 { HCBT_SETFOCUS, hook },
1318 { WM_IME_SETCONTEXT, sent|parent|wparam|defwinproc|optional, 1 },
1319 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1320 { WM_SETFOCUS, sent|parent|defwinproc },
1321 { EVENT_SYSTEM_DIALOGEND, winevent_hook|wparam|lparam, 0, 0 },
1322 { HCBT_DESTROYWND, hook },
1323 { 0x0090, sent|optional },
1324 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
1325 { WM_DESTROY, sent },
1326 { WM_NCDESTROY, sent },
1329 /* Creation of a modal dialog that is resized inside WM_INITDIALOG (32) */
1330 static const struct message WmCreateModalDialogResizeSeq[] = { /* FIXME: add */
1331 /* (inside dialog proc, handling WM_INITDIALOG) */
1332 { WM_WINDOWPOSCHANGING, sent|wparam, 0 },
1333 { WM_NCCALCSIZE, sent },
1334 { WM_NCACTIVATE, sent|parent|wparam, 0 },
1335 { WM_GETTEXT, sent|defwinproc },
1336 { WM_ACTIVATE, sent|parent|wparam, 0 },
1337 { WM_WINDOWPOSCHANGING, sent|wparam, 0 },
1338 { WM_WINDOWPOSCHANGING, sent|parent },
1339 { WM_NCACTIVATE, sent|wparam, 1 },
1340 { WM_ACTIVATE, sent|wparam, 1 },
1341 { WM_WINDOWPOSCHANGED, sent|wparam, 0 },
1342 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
1343 /* (setting focus) */
1344 { WM_SHOWWINDOW, sent|wparam, 1 },
1345 { WM_WINDOWPOSCHANGING, sent|wparam, 0 },
1346 { WM_NCPAINT, sent },
1347 { WM_GETTEXT, sent|defwinproc },
1348 { WM_ERASEBKGND, sent },
1349 { WM_CTLCOLORDLG, sent|defwinproc },
1350 { WM_WINDOWPOSCHANGED, sent|wparam, 0 },
1352 /* (bunch of WM_CTLCOLOR* for each control) */
1353 { WM_PAINT, sent|parent },
1354 { WM_ENTERIDLE, sent|parent|wparam, 0 },
1355 { WM_SETCURSOR, sent|parent },
1358 /* SetMenu for NonVisible windows with size change*/
1359 static const struct message WmSetMenuNonVisibleSizeChangeSeq[] = {
1360 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1361 { WM_NCCALCSIZE, sent|wparam, 1 },
1362 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
1363 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW },
1364 { WM_MOVE, sent|defwinproc },
1365 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
1366 { WM_NCCALCSIZE,sent|wparam|optional, 1 }, /* XP */
1367 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1368 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* XP sends a duplicate */
1369 { WM_GETTEXT, sent|optional },
1370 { WM_NCCALCSIZE, sent|wparam|optional, 1 },
1373 /* SetMenu for NonVisible windows with no size change */
1374 static const struct message WmSetMenuNonVisibleNoSizeChangeSeq[] = {
1375 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1376 { WM_NCCALCSIZE, sent|wparam, 1 },
1377 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1378 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1381 /* SetMenu for Visible windows with size change */
1382 static const struct message WmSetMenuVisibleSizeChangeSeq[] = {
1383 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1384 { WM_NCCALCSIZE, sent|wparam, 1 },
1385 { 0x0093, sent|defwinproc|optional },
1386 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
1387 { WM_NCPAINT, sent }, /* wparam != 1 */
1388 { 0x0093, sent|defwinproc|optional },
1389 { 0x0093, sent|defwinproc|optional },
1390 { 0x0091, sent|defwinproc|optional },
1391 { 0x0092, sent|defwinproc|optional },
1392 { WM_GETTEXT, sent|defwinproc|optional },
1393 { WM_ERASEBKGND, sent|optional },
1394 { WM_ACTIVATE, sent|optional },
1395 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1396 { WM_MOVE, sent|defwinproc },
1397 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
1398 { 0x0093, sent|optional },
1399 { WM_NCCALCSIZE, sent|wparam|optional, 1 },
1400 { 0x0093, sent|defwinproc|optional },
1401 { WM_NCPAINT, sent|optional }, /* wparam != 1 */
1402 { 0x0093, sent|defwinproc|optional },
1403 { 0x0093, sent|defwinproc|optional },
1404 { 0x0091, sent|defwinproc|optional },
1405 { 0x0092, sent|defwinproc|optional },
1406 { WM_ERASEBKGND, sent|optional },
1407 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1408 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* XP sends a duplicate */
1411 /* SetMenu for Visible windows with no size change */
1412 static const struct message WmSetMenuVisibleNoSizeChangeSeq[] = {
1413 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1414 { WM_NCCALCSIZE, sent|wparam, 1 },
1415 { WM_NCPAINT, sent }, /* wparam != 1 */
1416 { WM_GETTEXT, sent|defwinproc|optional },
1417 { WM_ERASEBKGND, sent|optional },
1418 { WM_ACTIVATE, sent|optional },
1419 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1420 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1423 /* DrawMenuBar for a visible window */
1424 static const struct message WmDrawMenuBarSeq[] =
1426 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1427 { WM_NCCALCSIZE, sent|wparam, 1 },
1428 { 0x0093, sent|defwinproc|optional },
1429 { WM_NCPAINT, sent }, /* wparam != 1 */
1430 { 0x0093, sent|defwinproc|optional },
1431 { 0x0093, sent|defwinproc|optional },
1432 { 0x0091, sent|defwinproc|optional },
1433 { 0x0092, sent|defwinproc|optional },
1434 { WM_GETTEXT, sent|defwinproc|optional },
1435 { WM_ERASEBKGND, sent|optional },
1436 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1437 { 0x0093, sent|optional },
1438 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1442 static const struct message WmSetRedrawFalseSeq[] =
1444 { WM_SETREDRAW, sent|wparam, 0 },
1448 static const struct message WmSetRedrawTrueSeq[] =
1450 { WM_SETREDRAW, sent|wparam, 1 },
1454 static const struct message WmEnableWindowSeq_1[] =
1456 { WM_CANCELMODE, sent|wparam|lparam, 0, 0 },
1457 { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, 0, 0 },
1458 { WM_ENABLE, sent|wparam|lparam, FALSE, 0 },
1462 static const struct message WmEnableWindowSeq_2[] =
1464 { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, 0, 0 },
1465 { WM_ENABLE, sent|wparam|lparam, TRUE, 0 },
1469 static const struct message WmGetScrollRangeSeq[] =
1471 { SBM_GETRANGE, sent },
1474 static const struct message WmGetScrollInfoSeq[] =
1476 { SBM_GETSCROLLINFO, sent },
1479 static const struct message WmSetScrollRangeSeq[] =
1481 /* MSDN claims that Windows sends SBM_SETRANGE message, but win2k SP4
1482 sends SBM_SETSCROLLINFO.
1484 { SBM_SETSCROLLINFO, sent },
1487 /* SetScrollRange for a window without a non-client area */
1488 static const struct message WmSetScrollRangeHSeq_empty[] =
1490 { EVENT_OBJECT_VALUECHANGE, winevent_hook|wparam|lparam, OBJID_HSCROLL, 0 },
1493 static const struct message WmSetScrollRangeVSeq_empty[] =
1495 { EVENT_OBJECT_VALUECHANGE, winevent_hook|wparam|lparam, OBJID_VSCROLL, 0 },
1498 static const struct message WmSetScrollRangeHVSeq[] =
1500 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE },
1501 { WM_NCCALCSIZE, sent|wparam, 1 },
1502 { WM_GETTEXT, sent|defwinproc|optional },
1503 { WM_ERASEBKGND, sent|optional },
1504 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1505 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1506 { EVENT_OBJECT_VALUECHANGE, winevent_hook|lparam|optional, 0/*OBJID_HSCROLL or OBJID_VSCROLL*/, 0 },
1509 /* SetScrollRange for a window with a non-client area */
1510 static const struct message WmSetScrollRangeHV_NC_Seq[] =
1512 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE },
1513 { WM_NCCALCSIZE, sent|wparam, 1 },
1514 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
1515 { WM_NCPAINT, sent|optional },
1516 { WM_STYLECHANGING, sent|defwinproc|optional },
1517 { WM_STYLECHANGED, sent|defwinproc|optional },
1518 { WM_STYLECHANGING, sent|defwinproc|optional },
1519 { WM_STYLECHANGED, sent|defwinproc|optional },
1520 { WM_STYLECHANGING, sent|defwinproc|optional },
1521 { WM_STYLECHANGED, sent|defwinproc|optional },
1522 { WM_STYLECHANGING, sent|defwinproc|optional },
1523 { WM_STYLECHANGED, sent|defwinproc|optional },
1524 { WM_GETTEXT, sent|defwinproc|optional },
1525 { WM_GETTEXT, sent|defwinproc|optional },
1526 { WM_ERASEBKGND, sent|optional },
1527 { WM_CTLCOLORDLG, sent|defwinproc|optional }, /* sent to a parent of the dialog */
1528 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE|SWP_NOCLIENTMOVE },
1529 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
1530 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1531 { EVENT_OBJECT_VALUECHANGE, winevent_hook|lparam|optional, 0/*OBJID_HSCROLL or OBJID_VSCROLL*/, 0 },
1532 { WM_GETTEXT, sent|optional },
1533 { WM_GETTEXT, sent|optional },
1534 { WM_GETTEXT, sent|optional },
1535 { WM_GETTEXT, sent|optional },
1538 /* test if we receive the right sequence of messages */
1539 /* after calling ShowWindow( SW_SHOWNA) */
1540 static const struct message WmSHOWNAChildInvisParInvis[] = {
1541 { WM_SHOWWINDOW, sent|wparam, 1 },
1544 static const struct message WmSHOWNAChildVisParInvis[] = {
1545 { WM_SHOWWINDOW, sent|wparam, 1 },
1548 static const struct message WmSHOWNAChildVisParVis[] = {
1549 { WM_SHOWWINDOW, sent|wparam, 1 },
1550 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
1553 static const struct message WmSHOWNAChildInvisParVis[] = {
1554 { WM_SHOWWINDOW, sent|wparam, 1 },
1555 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1556 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1557 { WM_ERASEBKGND, sent|optional },
1558 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOACTIVATE|SWP_NOCLIENTMOVE },
1561 static const struct message WmSHOWNATopVisible[] = {
1562 { WM_SHOWWINDOW, sent|wparam, 1 },
1563 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
1566 static const struct message WmSHOWNATopInvisible[] = {
1567 { WM_SHOWWINDOW, sent|wparam, 1 },
1568 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1569 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1570 { WM_NCPAINT, sent|wparam, 1 },
1571 { WM_GETTEXT, sent|defwinproc|optional },
1572 { WM_ERASEBKGND, sent|optional },
1573 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1574 { WM_NCCALCSIZE, sent|wparam|optional, 1 },
1575 { WM_NCPAINT, sent|wparam|optional, 1 },
1576 { WM_ERASEBKGND, sent|optional },
1577 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1578 { WM_SIZE, sent|wparam, SIZE_RESTORED },
1583 static int after_end_dialog, test_def_id;
1584 static int sequence_cnt, sequence_size;
1585 static struct message* sequence;
1586 static int log_all_parent_messages;
1588 /* user32 functions */
1589 static HWND (WINAPI *pGetAncestor)(HWND,UINT);
1590 static BOOL (WINAPI *pGetMenuInfo)(HMENU,LPCMENUINFO);
1591 static void (WINAPI *pNotifyWinEvent)(DWORD, HWND, LONG, LONG);
1592 static BOOL (WINAPI *pSetMenuInfo)(HMENU,LPCMENUINFO);
1593 static HWINEVENTHOOK (WINAPI *pSetWinEventHook)(DWORD, DWORD, HMODULE, WINEVENTPROC, DWORD, DWORD, DWORD);
1594 static BOOL (WINAPI *pTrackMouseEvent)(TRACKMOUSEEVENT*);
1595 static BOOL (WINAPI *pUnhookWinEvent)(HWINEVENTHOOK);
1596 /* kernel32 functions */
1597 static BOOL (WINAPI *pGetCPInfoExA)(UINT, DWORD, LPCPINFOEXA);
1599 static void init_procs(void)
1601 HMODULE user32 = GetModuleHandleA("user32.dll");
1602 HMODULE kernel32 = GetModuleHandleA("kernel32.dll");
1604 #define GET_PROC(dll, func) \
1605 p ## func = (void*)GetProcAddress(dll, #func); \
1607 trace("GetProcAddress(%s) failed\n", #func); \
1610 GET_PROC(user32, GetAncestor)
1611 GET_PROC(user32, GetMenuInfo)
1612 GET_PROC(user32, NotifyWinEvent)
1613 GET_PROC(user32, SetMenuInfo)
1614 GET_PROC(user32, SetWinEventHook)
1615 GET_PROC(user32, TrackMouseEvent)
1616 GET_PROC(user32, UnhookWinEvent)
1618 GET_PROC(kernel32, GetCPInfoExA)
1623 static void add_message(const struct message *msg)
1628 sequence = HeapAlloc( GetProcessHeap(), 0, sequence_size * sizeof (struct message) );
1630 if (sequence_cnt == sequence_size)
1633 sequence = HeapReAlloc( GetProcessHeap(), 0, sequence, sequence_size * sizeof (struct message) );
1637 sequence[sequence_cnt].message = msg->message;
1638 sequence[sequence_cnt].flags = msg->flags;
1639 sequence[sequence_cnt].wParam = msg->wParam;
1640 sequence[sequence_cnt].lParam = msg->lParam;
1645 /* try to make sure pending X events have been processed before continuing */
1646 static void flush_events(void)
1650 int min_timeout = 50;
1651 DWORD time = GetTickCount() + diff;
1655 if (MsgWaitForMultipleObjects( 0, NULL, FALSE, min_timeout, QS_ALLINPUT ) == WAIT_TIMEOUT) break;
1656 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
1657 diff = time - GetTickCount();
1662 static void flush_sequence(void)
1664 HeapFree(GetProcessHeap(), 0, sequence);
1666 sequence_cnt = sequence_size = 0;
1669 #define ok_sequence( exp, contx, todo) \
1670 ok_sequence_( (exp), (contx), (todo), __FILE__, __LINE__)
1673 static void ok_sequence_(const struct message *expected, const char *context, int todo,
1674 const char *file, int line)
1676 static const struct message end_of_sequence = { 0, 0, 0, 0 };
1677 const struct message *actual;
1680 add_message(&end_of_sequence);
1684 while (expected->message && actual->message)
1686 trace_( file, line)("expected %04x - actual %04x\n", expected->message, actual->message);
1688 if (expected->message == actual->message)
1690 if (expected->flags & wparam)
1692 if (expected->wParam != actual->wParam && todo)
1696 ok_( file, line) (FALSE,
1697 "%s: in msg 0x%04x expecting wParam 0x%lx got 0x%lx\n",
1698 context, expected->message, expected->wParam, actual->wParam);
1702 ok_( file, line) (expected->wParam == actual->wParam,
1703 "%s: in msg 0x%04x expecting wParam 0x%lx got 0x%lx\n",
1704 context, expected->message, expected->wParam, actual->wParam);
1706 if (expected->flags & lparam)
1708 if (expected->lParam != actual->lParam && todo)
1712 ok_( file, line) (FALSE,
1713 "%s: in msg 0x%04x expecting lParam 0x%lx got 0x%lx\n",
1714 context, expected->message, expected->lParam, actual->lParam);
1718 ok_( file, line) (expected->lParam == actual->lParam,
1719 "%s: in msg 0x%04x expecting lParam 0x%lx got 0x%lx\n",
1720 context, expected->message, expected->lParam, actual->lParam);
1722 if ((expected->flags & defwinproc) != (actual->flags & defwinproc) && todo)
1726 ok_( file, line) (FALSE,
1727 "%s: the msg 0x%04x should %shave been sent by DefWindowProc\n",
1728 context, expected->message, (expected->flags & defwinproc) ? "" : "NOT ");
1732 ok_( file, line) ((expected->flags & defwinproc) == (actual->flags & defwinproc),
1733 "%s: the msg 0x%04x should %shave been sent by DefWindowProc\n",
1734 context, expected->message, (expected->flags & defwinproc) ? "" : "NOT ");
1735 ok_( file, line) ((expected->flags & beginpaint) == (actual->flags & beginpaint),
1736 "%s: the msg 0x%04x should %shave been sent by BeginPaint\n",
1737 context, expected->message, (expected->flags & beginpaint) ? "" : "NOT ");
1738 ok_( file, line) ((expected->flags & (sent|posted)) == (actual->flags & (sent|posted)),
1739 "%s: the msg 0x%04x should have been %s\n",
1740 context, expected->message, (expected->flags & posted) ? "posted" : "sent");
1741 ok_( file, line) ((expected->flags & parent) == (actual->flags & parent),
1742 "%s: the msg 0x%04x was expected in %s\n",
1743 context, expected->message, (expected->flags & parent) ? "parent" : "child");
1744 ok_( file, line) ((expected->flags & hook) == (actual->flags & hook),
1745 "%s: the msg 0x%04x should have been sent by a hook\n",
1746 context, expected->message);
1747 ok_( file, line) ((expected->flags & winevent_hook) == (actual->flags & winevent_hook),
1748 "%s: the msg 0x%04x should have been sent by a winevent hook\n",
1749 context, expected->message);
1753 /* silently drop winevent messages if there is no support for them */
1754 else if ((expected->flags & optional) || ((expected->flags & winevent_hook) && !hEvent_hook))
1760 ok_( file, line) (FALSE, "%s: the msg 0x%04x was expected, but got msg 0x%04x instead\n",
1761 context, expected->message, actual->message);
1768 ok_( file, line) (FALSE, "%s: the msg 0x%04x was expected, but got msg 0x%04x instead\n",
1769 context, expected->message, actual->message);
1775 /* skip all optional trailing messages */
1776 while (expected->message && ((expected->flags & optional) ||
1777 ((expected->flags & winevent_hook) && !hEvent_hook)))
1783 if (expected->message || actual->message) {
1785 ok_( file, line) (FALSE, "%s: the msg sequence is not complete: expected %04x - actual %04x\n",
1786 context, expected->message, actual->message);
1792 if (expected->message || actual->message)
1793 ok_( file, line) (FALSE, "%s: the msg sequence is not complete: expected %04x - actual %04x\n",
1794 context, expected->message, actual->message);
1796 if( todo && !failcount) /* succeeded yet marked todo */
1798 ok_( file, line)( TRUE, "%s: marked \"todo_wine\" but succeeds\n", context);
1804 #define expect(EXPECTED,GOT) ok((GOT)==(EXPECTED), "Expected %d, got %d\n", (EXPECTED), (GOT))
1806 /******************************** MDI test **********************************/
1808 /* CreateWindow for MDI frame window, initially visible */
1809 static const struct message WmCreateMDIframeSeq[] = {
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, 0, 0 },
1815 { WM_CREATE, sent },
1816 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1817 { WM_SHOWWINDOW, sent|wparam, 1 },
1818 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
1819 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1820 { HCBT_ACTIVATE, hook },
1821 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
1822 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
1823 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* XP */
1824 { WM_ACTIVATEAPP, sent|wparam|optional, 1 }, /* Win9x doesn't send it */
1825 { WM_NCACTIVATE, sent|wparam, 1 },
1826 { WM_GETTEXT, sent|defwinproc|optional },
1827 { WM_ACTIVATE, sent|wparam, 1 },
1828 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* Win9x */
1829 { HCBT_SETFOCUS, hook },
1830 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
1831 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
1832 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1833 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
1834 /* Win9x adds SWP_NOZORDER below */
1835 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1836 { WM_NCCALCSIZE, sent|wparam|optional, 1 }, /* XP */
1837 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1838 { WM_SIZE, sent|wparam, SIZE_RESTORED },
1842 /* DestroyWindow for MDI frame window, initially visible */
1843 static const struct message WmDestroyMDIframeSeq[] = {
1844 { HCBT_DESTROYWND, hook },
1845 { 0x0090, sent|optional },
1846 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1847 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
1848 { WM_NCACTIVATE, sent|wparam|optional, 0 }, /* Win9x */
1849 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1850 { WM_NCACTIVATE, sent|wparam|optional, 0 }, /* XP */
1851 { WM_ACTIVATE, sent|wparam|optional, 0 }, /* Win9x */
1852 { WM_ACTIVATEAPP, sent|wparam|optional, 0 }, /* Win9x */
1853 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
1854 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
1855 { WM_DESTROY, sent },
1856 { WM_NCDESTROY, sent },
1859 /* CreateWindow for MDI client window, initially visible */
1860 static const struct message WmCreateMDIclientSeq[] = {
1861 { HCBT_CREATEWND, hook },
1862 { WM_NCCREATE, sent },
1863 { WM_NCCALCSIZE, sent|wparam, 0 },
1864 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam|optional, 0, 0 },
1865 { WM_CREATE, sent },
1866 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam|optional, 0, 0 },
1867 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1868 { WM_SIZE, sent|wparam, SIZE_RESTORED },
1870 { WM_PARENTNOTIFY, sent|wparam, WM_CREATE }, /* in MDI frame */
1871 { WM_SHOWWINDOW, sent|wparam, 1 },
1872 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1873 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1874 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1877 /* ShowWindow(SW_SHOW) for MDI client window */
1878 static const struct message WmShowMDIclientSeq[] = {
1879 { WM_SHOWWINDOW, sent|wparam, 1 },
1880 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1881 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1882 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1885 /* ShowWindow(SW_HIDE) for MDI client window */
1886 static const struct message WmHideMDIclientSeq[] = {
1887 { WM_SHOWWINDOW, sent|wparam, 0 },
1888 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1889 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam|optional, 0, 0 }, /* win2000 */
1890 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* XP */
1891 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1894 /* DestroyWindow for MDI client window, initially visible */
1895 static const struct message WmDestroyMDIclientSeq[] = {
1896 { HCBT_DESTROYWND, hook },
1897 { 0x0090, sent|optional },
1898 { WM_PARENTNOTIFY, sent|wparam, WM_DESTROY }, /* in MDI frame */
1899 { WM_SHOWWINDOW, sent|wparam, 0 },
1900 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1901 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
1902 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1903 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
1904 { WM_DESTROY, sent },
1905 { WM_NCDESTROY, sent },
1908 /* CreateWindow for MDI child window, initially visible */
1909 static const struct message WmCreateMDIchildVisibleSeq[] = {
1910 { HCBT_CREATEWND, hook },
1911 { WM_NCCREATE, sent },
1912 { WM_NCCALCSIZE, sent|wparam, 0 },
1913 { WM_CREATE, sent },
1914 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1915 { WM_SIZE, sent|wparam, SIZE_RESTORED },
1917 /* Win2k sends wparam set to
1918 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
1919 * while Win9x doesn't bother to set child window id according to
1920 * CLIENTCREATESTRUCT.idFirstChild
1922 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
1923 { WM_SHOWWINDOW, sent|wparam, 1 },
1924 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1925 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1926 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1927 { WM_MDIREFRESHMENU, sent/*|wparam|lparam, 0, 0*/ },
1928 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
1929 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
1930 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1932 /* Win9x: message sequence terminates here. */
1934 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
1935 { HCBT_SETFOCUS, hook }, /* in MDI client */
1936 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
1937 { WM_IME_NOTIFY, sent|wparam|optional, 2 }, /* in MDI client */
1938 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1939 { WM_SETFOCUS, sent }, /* in MDI client */
1940 { HCBT_SETFOCUS, hook },
1941 { WM_KILLFOCUS, sent }, /* in MDI client */
1942 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
1943 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
1944 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1945 { WM_SETFOCUS, sent|defwinproc },
1946 { WM_MDIACTIVATE, sent|defwinproc },
1949 /* CreateWindow for MDI child window with invisible parent */
1950 static const struct message WmCreateMDIchildInvisibleParentSeq[] = {
1951 { HCBT_CREATEWND, hook },
1952 { WM_GETMINMAXINFO, sent },
1953 { WM_NCCREATE, sent },
1954 { WM_NCCALCSIZE, sent|wparam, 0 },
1955 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam|optional, 0, 0 },
1956 { WM_CREATE, sent },
1957 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1958 { WM_SIZE, sent|wparam, SIZE_RESTORED },
1960 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
1961 { WM_SHOWWINDOW, sent|wparam, 1 },
1962 { WM_MDIREFRESHMENU, sent }, /* in MDI client */
1963 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
1964 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
1965 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1967 /* Win9x: message sequence terminates here. */
1969 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
1970 { HCBT_SETFOCUS, hook }, /* in MDI client */
1971 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
1972 { WM_IME_NOTIFY, sent|wparam|optional, 2 }, /* in MDI client */
1973 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1974 { WM_SETFOCUS, sent }, /* in MDI client */
1975 { HCBT_SETFOCUS, hook },
1976 { WM_KILLFOCUS, sent }, /* in MDI client */
1977 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
1978 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
1979 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1980 { WM_SETFOCUS, sent|defwinproc },
1981 { WM_MDIACTIVATE, sent|defwinproc },
1984 /* DestroyWindow for MDI child window, initially visible */
1985 static const struct message WmDestroyMDIchildVisibleSeq[] = {
1986 { HCBT_DESTROYWND, hook },
1987 /* Win2k sends wparam set to
1988 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
1989 * while Win9x doesn't bother to set child window id according to
1990 * CLIENTCREATESTRUCT.idFirstChild
1992 { 0x0090, sent|optional },
1993 { WM_PARENTNOTIFY, sent /*|wparam, WM_DESTROY*/ }, /* in MDI client */
1994 { WM_SHOWWINDOW, sent|wparam, 0 },
1995 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1996 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
1997 { WM_ERASEBKGND, sent|parent|optional },
1998 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2000 /* { WM_DESTROY, sent }
2001 * Win9x: message sequence terminates here.
2004 { HCBT_SETFOCUS, hook }, /* set focus to MDI client */
2005 { WM_KILLFOCUS, sent },
2006 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
2007 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2008 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2009 { WM_SETFOCUS, sent }, /* in MDI client */
2011 { HCBT_SETFOCUS, hook }, /* MDI client sets focus back to MDI child */
2012 { WM_KILLFOCUS, sent }, /* in MDI client */
2013 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
2014 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
2015 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2016 { WM_SETFOCUS, sent }, /* in MDI client */
2018 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
2020 { HCBT_SETFOCUS, hook }, /* set focus to MDI client */
2021 { WM_KILLFOCUS, sent },
2022 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
2023 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2024 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2025 { WM_SETFOCUS, sent }, /* in MDI client */
2027 { HCBT_SETFOCUS, hook }, /* MDI client sets focus back to MDI child */
2028 { WM_KILLFOCUS, sent }, /* in MDI client */
2029 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
2030 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
2031 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2032 { WM_SETFOCUS, sent }, /* in MDI client */
2034 { WM_DESTROY, sent },
2036 { HCBT_SETFOCUS, hook }, /* set focus to MDI client */
2037 { WM_KILLFOCUS, sent },
2038 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
2039 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2040 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2041 { WM_SETFOCUS, sent }, /* in MDI client */
2043 { HCBT_SETFOCUS, hook }, /* MDI client sets focus back to MDI child */
2044 { WM_KILLFOCUS, sent }, /* in MDI client */
2045 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
2046 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
2047 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2048 { WM_SETFOCUS, sent }, /* in MDI client */
2050 { WM_NCDESTROY, sent },
2053 /* CreateWindow for MDI child window, initially invisible */
2054 static const struct message WmCreateMDIchildInvisibleSeq[] = {
2055 { HCBT_CREATEWND, hook },
2056 { WM_NCCREATE, sent },
2057 { WM_NCCALCSIZE, sent|wparam, 0 },
2058 { WM_CREATE, sent },
2059 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
2060 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2062 /* Win2k sends wparam set to
2063 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2064 * while Win9x doesn't bother to set child window id according to
2065 * CLIENTCREATESTRUCT.idFirstChild
2067 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
2070 /* DestroyWindow for MDI child window, initially invisible */
2071 static const struct message WmDestroyMDIchildInvisibleSeq[] = {
2072 { HCBT_DESTROYWND, hook },
2073 /* Win2k sends wparam set to
2074 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
2075 * while Win9x doesn't bother to set child window id according to
2076 * CLIENTCREATESTRUCT.idFirstChild
2078 { 0x0090, sent|optional },
2079 { WM_PARENTNOTIFY, sent /*|wparam, WM_DESTROY*/ }, /* in MDI client */
2080 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
2081 { WM_DESTROY, sent },
2082 { WM_NCDESTROY, sent },
2083 /* FIXME: Wine destroys an icon/title window while Windows doesn't */
2084 { WM_PARENTNOTIFY, sent|wparam|optional, WM_DESTROY }, /* MDI client */
2087 /* CreateWindow for the 1st MDI child window, initially visible and maximized */
2088 static const struct message WmCreateMDIchildVisibleMaxSeq1[] = {
2089 { HCBT_CREATEWND, hook },
2090 { WM_NCCREATE, sent },
2091 { WM_NCCALCSIZE, sent|wparam, 0 },
2092 { WM_CREATE, sent },
2093 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
2094 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2096 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
2097 { WM_GETMINMAXINFO, sent },
2098 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_STATECHANGED },
2099 { WM_NCCALCSIZE, sent|wparam, 1 },
2100 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_STATECHANGED },
2101 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2103 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2104 { WM_NCCALCSIZE, sent|wparam, 1 },
2105 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2106 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2107 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2108 /* Win2k sends wparam set to
2109 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2110 * while Win9x doesn't bother to set child window id according to
2111 * CLIENTCREATESTRUCT.idFirstChild
2113 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
2114 { WM_SHOWWINDOW, sent|wparam, 1 },
2115 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2116 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2117 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2118 { WM_MDIREFRESHMENU, sent/*|wparam|lparam, 0, 0*/ },
2119 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
2120 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2121 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2123 /* Win9x: message sequence terminates here. */
2125 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
2126 { HCBT_SETFOCUS, hook }, /* in MDI client */
2127 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2128 { WM_IME_NOTIFY, sent|wparam|optional, 2 }, /* in MDI client */
2129 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2130 { WM_SETFOCUS, sent }, /* in MDI client */
2131 { HCBT_SETFOCUS, hook },
2132 { WM_KILLFOCUS, sent }, /* in MDI client */
2133 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
2134 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
2135 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2136 { WM_SETFOCUS, sent|defwinproc },
2137 { WM_MDIACTIVATE, sent|defwinproc },
2139 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2140 { WM_NCCALCSIZE, sent|wparam, 1 },
2141 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2142 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2145 /* CreateWindow for the 2nd MDI child window, initially visible and maximized */
2146 static const struct message WmCreateMDIchildVisibleMaxSeq2[] = {
2147 /* restore the 1st MDI child */
2148 { WM_SETREDRAW, sent|wparam, 0 },
2149 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWNORMAL },
2150 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_STATECHANGED },
2151 { WM_NCCALCSIZE, sent|wparam, 1 },
2152 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2153 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_STATECHANGED },
2154 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2156 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2157 { WM_NCCALCSIZE, sent|wparam, 1 },
2158 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2159 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2160 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2161 { WM_SETREDRAW, sent|wparam, 1 }, /* in the 1st MDI child */
2162 /* create the 2nd MDI child */
2163 { HCBT_CREATEWND, hook },
2164 { WM_NCCREATE, sent },
2165 { WM_NCCALCSIZE, sent|wparam, 0 },
2166 { WM_CREATE, sent },
2167 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
2168 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2170 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
2171 { WM_GETMINMAXINFO, sent },
2172 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_STATECHANGED },
2173 { WM_NCCALCSIZE, sent|wparam, 1 },
2174 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2175 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_STATECHANGED },
2176 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2178 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2179 { WM_NCCALCSIZE, sent|wparam, 1 },
2180 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2181 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2182 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2183 /* Win2k sends wparam set to
2184 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2185 * while Win9x doesn't bother to set child window id according to
2186 * CLIENTCREATESTRUCT.idFirstChild
2188 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
2189 { WM_SHOWWINDOW, sent|wparam, 1 },
2190 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2191 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2192 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2193 { WM_MDIREFRESHMENU, sent/*|wparam|lparam, 0, 0*/ },
2194 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
2195 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2197 { WM_NCACTIVATE, sent|wparam|defwinproc, 0 }, /* in the 1st MDI child */
2198 { WM_MDIACTIVATE, sent|defwinproc }, /* in the 1st MDI child */
2200 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2202 /* Win9x: message sequence terminates here. */
2204 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
2205 { HCBT_SETFOCUS, hook },
2206 { WM_KILLFOCUS, sent|defwinproc }, /* in the 1st MDI child */
2207 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 0 }, /* in the 1st MDI child */
2208 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2209 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2210 { WM_SETFOCUS, sent }, /* in MDI client */
2211 { HCBT_SETFOCUS, hook },
2212 { WM_KILLFOCUS, sent }, /* in MDI client */
2213 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
2214 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
2215 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2216 { WM_SETFOCUS, sent|defwinproc },
2218 { WM_MDIACTIVATE, sent|defwinproc },
2220 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2221 { WM_NCCALCSIZE, sent|wparam, 1 },
2222 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2223 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2226 /* WM_MDICREATE MDI child window, initially visible and maximized */
2227 static const struct message WmCreateMDIchildVisibleMaxSeq3[] = {
2228 { WM_MDICREATE, sent },
2229 { HCBT_CREATEWND, hook },
2230 { WM_NCCREATE, sent },
2231 { WM_NCCALCSIZE, sent|wparam, 0 },
2232 { WM_CREATE, sent },
2233 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
2234 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2236 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
2237 { WM_GETMINMAXINFO, sent },
2238 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_STATECHANGED },
2239 { WM_NCCALCSIZE, sent|wparam, 1 },
2240 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_STATECHANGED },
2241 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2244 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2245 { WM_NCCALCSIZE, sent|wparam, 1 },
2246 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2247 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2248 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2250 /* Win2k sends wparam set to
2251 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2252 * while Win9x doesn't bother to set child window id according to
2253 * CLIENTCREATESTRUCT.idFirstChild
2255 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
2256 { WM_SHOWWINDOW, sent|wparam, 1 },
2257 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2259 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2261 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2262 { WM_MDIREFRESHMENU, sent/*|wparam|lparam, 0, 0*/ },
2263 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
2265 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2266 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2268 /* Win9x: message sequence terminates here. */
2270 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
2271 { WM_SETFOCUS, sent|optional }, /* in MDI client */
2272 { HCBT_SETFOCUS, hook }, /* in MDI client */
2273 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2274 { WM_IME_NOTIFY, sent|wparam|optional, 2 },
2275 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
2276 { WM_SETFOCUS, sent|optional }, /* in MDI client */
2277 { HCBT_SETFOCUS, hook|optional },
2278 { WM_KILLFOCUS, sent }, /* in MDI client */
2279 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
2280 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
2281 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2282 { WM_SETFOCUS, sent|defwinproc },
2284 { WM_MDIACTIVATE, sent|defwinproc },
2287 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2288 { WM_NCCALCSIZE, sent|wparam, 1 },
2289 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2290 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
2293 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2294 { WM_NCCALCSIZE, sent|wparam, 1 },
2295 { 0x0093, sent|defwinproc|optional },
2296 { 0x0093, sent|defwinproc|optional },
2297 { 0x0093, sent|defwinproc|optional },
2298 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2299 { WM_MOVE, sent|defwinproc },
2300 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2303 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE },
2304 { WM_NCCALCSIZE, sent|wparam, 1 },
2305 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOCLIENTMOVE },
2306 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2309 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE },
2310 { WM_NCCALCSIZE, sent|wparam, 1 },
2311 { 0x0093, sent|optional },
2312 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOCLIENTMOVE },
2313 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2315 { 0x0093, sent|optional },
2316 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2317 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI client */
2318 { WM_NCCALCSIZE, sent|wparam|optional, 1 }, /* XP sends it to MDI frame */
2319 { 0x0093, sent|defwinproc|optional },
2320 { 0x0093, sent|defwinproc|optional },
2321 { 0x0093, sent|defwinproc|optional },
2322 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2323 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* XP sends a duplicate */
2327 /* CreateWindow for the 1st MDI child window, initially invisible and maximized */
2328 static const struct message WmCreateMDIchildInvisibleMaxSeq4[] = {
2329 { HCBT_CREATEWND, hook },
2330 { WM_GETMINMAXINFO, sent },
2331 { WM_NCCREATE, sent },
2332 { WM_NCCALCSIZE, sent|wparam, 0 },
2333 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
2334 { WM_CREATE, sent },
2335 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
2336 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2338 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
2339 { WM_GETMINMAXINFO, sent },
2340 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_STATECHANGED },
2341 { WM_GETMINMAXINFO, sent|defwinproc },
2342 { WM_NCCALCSIZE, sent|wparam, 1 },
2343 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_STATECHANGED },
2344 { WM_MOVE, sent|defwinproc },
2345 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2347 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2348 { WM_NCCALCSIZE, sent|wparam, 1 },
2349 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2350 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2351 { WM_NCCALCSIZE, sent|wparam|optional, 1 }, /* MDI child */
2352 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2353 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2354 /* Win2k sends wparam set to
2355 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2356 * while Win9x doesn't bother to set child window id according to
2357 * CLIENTCREATESTRUCT.idFirstChild
2359 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
2362 /* WM_SYSCOMMAND/SC_CLOSE for the 2nd MDI child window, initially visible and maximized */
2363 static const struct message WmDestroyMDIchildVisibleMaxSeq2[] = {
2364 { WM_SYSCOMMAND, sent|wparam, SC_CLOSE },
2365 { HCBT_SYSCOMMAND, hook },
2366 { WM_CLOSE, sent|defwinproc },
2367 { WM_MDIDESTROY, sent }, /* in MDI client */
2369 /* bring the 1st MDI child to top */
2370 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOSIZE|SWP_NOMOVE }, /* in the 1st MDI child */
2371 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE }, /* in the 2nd MDI child */
2373 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2375 { WM_CHILDACTIVATE, sent|defwinproc|wparam|lparam, 0, 0 }, /* in the 1st MDI child */
2376 { WM_NCACTIVATE, sent|wparam|defwinproc, 0 }, /* in the 1st MDI child */
2377 { WM_MDIACTIVATE, sent|defwinproc }, /* in the 1st MDI child */
2379 /* maximize the 1st MDI child */
2380 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
2381 { WM_GETMINMAXINFO, sent|defwinproc },
2382 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_STATECHANGED },
2383 { WM_NCCALCSIZE, sent|defwinproc|wparam, 1 },
2384 { WM_CHILDACTIVATE, sent|defwinproc|wparam|lparam, 0, 0 },
2385 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_STATECHANGED },
2386 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2388 /* restore the 2nd MDI child */
2389 { WM_SETREDRAW, sent|defwinproc|wparam, 0 },
2390 { HCBT_MINMAX, hook|lparam, 0, SW_NORMALNA },
2391 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_SHOWWINDOW|SWP_STATECHANGED },
2392 { WM_NCCALCSIZE, sent|defwinproc|wparam, 1 },
2394 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2396 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_STATECHANGED },
2397 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2399 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2401 { WM_SETREDRAW, sent|defwinproc|wparam, 1 },
2403 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2404 { WM_NCCALCSIZE, sent|wparam, 1 },
2405 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2406 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2407 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2409 /* bring the 1st MDI child to top */
2410 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2411 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
2412 { HCBT_SETFOCUS, hook },
2413 { WM_KILLFOCUS, sent|defwinproc },
2414 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 0 },
2415 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2416 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2417 { WM_SETFOCUS, sent }, /* in MDI client */
2418 { HCBT_SETFOCUS, hook },
2419 { WM_KILLFOCUS, sent }, /* in MDI client */
2420 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
2421 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
2422 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2423 { WM_SETFOCUS, sent|defwinproc },
2424 { WM_MDIACTIVATE, sent|defwinproc },
2425 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2427 /* apparently ShowWindow(SW_SHOW) on an MDI client */
2428 { WM_SHOWWINDOW, sent|wparam, 1 },
2429 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2430 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2431 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2432 { WM_MDIREFRESHMENU, sent },
2434 { HCBT_DESTROYWND, hook },
2435 /* Win2k sends wparam set to
2436 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
2437 * while Win9x doesn't bother to set child window id according to
2438 * CLIENTCREATESTRUCT.idFirstChild
2440 { 0x0090, sent|defwinproc|optional },
2441 { WM_PARENTNOTIFY, sent /*|wparam, WM_DESTROY*/ }, /* in MDI client */
2442 { WM_SHOWWINDOW, sent|defwinproc|wparam, 0 },
2443 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2444 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
2445 { WM_ERASEBKGND, sent|parent|optional },
2446 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2448 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
2449 { WM_DESTROY, sent|defwinproc },
2450 { WM_NCDESTROY, sent|defwinproc },
2453 /* WM_MDIDESTROY for the single MDI child window, initially visible and maximized */
2454 static const struct message WmDestroyMDIchildVisibleMaxSeq1[] = {
2455 { WM_MDIDESTROY, sent }, /* in MDI client */
2456 { WM_SHOWWINDOW, sent|wparam, 0 },
2457 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2458 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
2459 { WM_ERASEBKGND, sent|parent|optional },
2460 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2462 { HCBT_SETFOCUS, hook },
2463 { WM_KILLFOCUS, sent },
2464 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
2465 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2466 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2467 { WM_SETFOCUS, sent }, /* in MDI client */
2468 { HCBT_SETFOCUS, hook },
2469 { WM_KILLFOCUS, sent }, /* in MDI client */
2470 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
2471 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
2472 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2473 { WM_SETFOCUS, sent },
2476 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2477 { WM_NCCALCSIZE, sent|wparam, 1 },
2478 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2479 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2482 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2483 { WM_NCCALCSIZE, sent|wparam, 1 },
2484 { 0x0093, sent|defwinproc|optional },
2485 { 0x0093, sent|defwinproc|optional },
2486 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2487 { WM_MOVE, sent|defwinproc },
2488 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2491 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE },
2492 { WM_NCCALCSIZE, sent|wparam, 1 },
2493 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOCLIENTMOVE },
2494 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2497 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE },
2498 { WM_NCCALCSIZE, sent|wparam, 1 },
2499 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTMOVE },
2500 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2503 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2504 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 },
2505 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2506 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2509 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2510 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 },
2511 { 0x0093, sent|defwinproc|optional },
2512 { 0x0093, sent|defwinproc|optional },
2513 { 0x0093, sent|defwinproc|optional },
2514 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2515 { WM_MOVE, sent|defwinproc },
2516 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2519 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE },
2520 { WM_NCCALCSIZE, sent|wparam, 1 },
2521 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOCLIENTMOVE },
2522 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2525 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE },
2526 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 },
2527 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTMOVE },
2528 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2529 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2530 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI client */
2532 { 0x0093, sent|defwinproc|optional },
2533 { WM_NCCALCSIZE, sent|wparam|defwinproc|optional, 1 }, /* XP sends it to MDI frame */
2534 { 0x0093, sent|defwinproc|optional },
2535 { 0x0093, sent|defwinproc|optional },
2536 { 0x0093, sent|defwinproc|optional },
2537 { 0x0093, sent|optional },
2539 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2540 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2541 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI client */
2542 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2543 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* XP sends a duplicate */
2546 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2547 { WM_NCCALCSIZE, sent|wparam, 1 },
2548 { 0x0093, sent|defwinproc|optional },
2549 { 0x0093, sent|defwinproc|optional },
2550 { 0x0093, sent|defwinproc|optional },
2551 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2552 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2553 { 0x0093, sent|optional },
2555 { WM_NCACTIVATE, sent|wparam, 0 },
2556 { WM_MDIACTIVATE, sent },
2558 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWNORMAL },
2559 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_SHOWWINDOW|SWP_STATECHANGED },
2560 { WM_NCCALCSIZE, sent|wparam, 1 },
2562 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2564 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2565 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_SHOWWINDOW|SWP_NOMOVE|SWP_NOCLIENTMOVE|SWP_STATECHANGED },
2566 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2569 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2570 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 },
2571 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2572 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2575 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2576 { WM_NCCALCSIZE, sent|wparam, 1 },
2577 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2578 { WM_MOVE, sent|defwinproc },
2579 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2582 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE },
2583 { WM_NCCALCSIZE, sent|wparam, 1 },
2584 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOCLIENTMOVE },
2585 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2586 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2587 { WM_NCCALCSIZE, sent|wparam|optional, 1 }, /* XP */
2588 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI client */
2589 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2590 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* XP sends a duplicate */
2592 { HCBT_SETFOCUS, hook },
2593 { WM_KILLFOCUS, sent },
2594 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
2595 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2596 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2597 { WM_SETFOCUS, sent }, /* in MDI client */
2599 { WM_MDIREFRESHMENU, sent }, /* in MDI client */
2601 { HCBT_DESTROYWND, hook },
2602 /* Win2k sends wparam set to
2603 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
2604 * while Win9x doesn't bother to set child window id according to
2605 * CLIENTCREATESTRUCT.idFirstChild
2607 { 0x0090, sent|optional },
2608 { WM_PARENTNOTIFY, sent /*|wparam, WM_DESTROY*/ }, /* in MDI client */
2610 { WM_SHOWWINDOW, sent|wparam, 0 },
2611 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2612 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
2613 { WM_ERASEBKGND, sent|parent|optional },
2614 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2616 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
2617 { WM_DESTROY, sent },
2618 { WM_NCDESTROY, sent },
2621 /* ShowWindow(SW_MAXIMIZE) for a not visible MDI child window */
2622 static const struct message WmMaximizeMDIchildInvisibleSeq[] = {
2623 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
2624 { WM_GETMINMAXINFO, sent },
2625 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_STATECHANGED },
2626 { WM_NCCALCSIZE, sent|wparam, 1 },
2627 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2628 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2630 { WM_WINDOWPOSCHANGING, sent|wparam|optional|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2631 { WM_NCACTIVATE, sent|wparam|optional|defwinproc, 1 },
2632 { HCBT_SETFOCUS, hook|optional },
2633 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2634 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2635 { WM_SETFOCUS, sent|optional }, /* in MDI client */
2636 { HCBT_SETFOCUS, hook|optional },
2637 { WM_KILLFOCUS, sent|optional }, /* in MDI client */
2638 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
2639 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
2640 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2641 { WM_SETFOCUS, sent|optional|defwinproc },
2642 { WM_MDIACTIVATE, sent|optional|defwinproc },
2643 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_STATECHANGED },
2644 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2646 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2647 { WM_NCCALCSIZE, sent|wparam, 1 },
2648 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2649 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2650 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2653 /* ShowWindow(SW_MAXIMIZE) for a not visible maximized MDI child window */
2654 static const struct message WmMaximizeMDIchildInvisibleSeq2[] = {
2655 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
2656 { WM_GETMINMAXINFO, sent },
2657 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED },
2658 { WM_GETMINMAXINFO, sent|defwinproc },
2659 { WM_NCCALCSIZE, sent|wparam, 1 },
2660 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2661 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2663 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2664 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
2665 { HCBT_SETFOCUS, hook },
2666 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2667 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2668 { WM_SETFOCUS, sent }, /* in MDI client */
2669 { HCBT_SETFOCUS, hook },
2670 { WM_KILLFOCUS, sent }, /* in MDI client */
2671 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
2672 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
2673 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2674 { WM_SETFOCUS, sent|defwinproc },
2675 { WM_MDIACTIVATE, sent|defwinproc },
2676 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2677 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2680 /* WM_MDIMAXIMIZE for an MDI child window with invisible parent */
2681 static const struct message WmMaximizeMDIchildInvisibleParentSeq[] = {
2682 { WM_MDIMAXIMIZE, sent }, /* in MDI client */
2683 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
2684 { WM_GETMINMAXINFO, sent },
2685 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_STATECHANGED },
2686 { WM_GETMINMAXINFO, sent|defwinproc },
2687 { WM_NCCALCSIZE, sent|wparam, 1 },
2688 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam|optional, 0, 0 }, /* XP doesn't send it */
2689 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2690 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOREDRAW|SWP_STATECHANGED },
2691 { WM_MOVE, sent|defwinproc },
2692 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2694 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2695 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 },
2696 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2697 { WM_NCCALCSIZE, sent|wparam|defwinproc|optional, 1 },
2698 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI child XP */
2699 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI client XP */
2701 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2702 { WM_NCCALCSIZE, sent|wparam, 1 },
2703 { 0x0093, sent|defwinproc|optional },
2704 { 0x0094, sent|defwinproc|optional },
2705 { 0x0094, sent|defwinproc|optional },
2706 { 0x0094, sent|defwinproc|optional },
2707 { 0x0094, sent|defwinproc|optional },
2708 { 0x0093, sent|defwinproc|optional },
2709 { 0x0093, sent|defwinproc|optional },
2710 { 0x0091, sent|defwinproc|optional },
2711 { 0x0092, sent|defwinproc|optional },
2712 { 0x0092, sent|defwinproc|optional },
2713 { 0x0092, sent|defwinproc|optional },
2714 { 0x0092, sent|defwinproc|optional },
2715 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2716 { WM_MOVE, sent|defwinproc },
2717 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2718 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI frame win2000 */
2720 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE },
2721 { WM_NCCALCSIZE, sent|wparam, 1 },
2722 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTMOVE },
2723 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2725 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE },
2726 { WM_GETMINMAXINFO, sent|defwinproc },
2727 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 },
2728 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTMOVE },
2729 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2730 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI child win2000 */
2731 { WM_NCCALCSIZE, sent|wparam|defwinproc|optional, 1 },
2732 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI child XP */
2733 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI child XP */
2734 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI client XP */
2736 { 0x0093, sent|optional },
2737 { WM_NCCALCSIZE, sent|wparam|optional, 1 },
2738 { 0x0093, sent|defwinproc|optional },
2739 { 0x0093, sent|defwinproc|optional },
2740 { 0x0093, sent|defwinproc|optional },
2741 { 0x0091, sent|defwinproc|optional },
2742 { 0x0092, sent|defwinproc|optional },
2743 { 0x0092, sent|defwinproc|optional },
2744 { 0x0092, sent|defwinproc|optional },
2745 { 0x0092, sent|defwinproc|optional },
2746 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI frame XP */
2747 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI frame XP */
2748 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI child XP */
2751 /* ShowWindow(SW_MAXIMIZE) for a visible MDI child window */
2752 static const struct message WmMaximizeMDIchildVisibleSeq[] = {
2753 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
2754 { WM_GETMINMAXINFO, sent },
2755 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_STATECHANGED },
2756 { WM_NCCALCSIZE, sent|wparam, 1 },
2757 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2758 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_STATECHANGED },
2759 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2761 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2762 { WM_NCCALCSIZE, sent|wparam, 1 },
2763 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2764 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2765 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2768 /* ShowWindow(SW_RESTORE) for a visible maximized MDI child window */
2769 static const struct message WmRestoreMDIchildVisibleSeq[] = {
2770 { HCBT_MINMAX, hook|lparam, 0, SW_RESTORE },
2771 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_STATECHANGED },
2772 { WM_NCCALCSIZE, sent|wparam, 1 },
2773 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2774 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_STATECHANGED },
2775 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2777 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2778 { WM_NCCALCSIZE, sent|wparam, 1 },
2779 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2780 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2781 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2784 /* ShowWindow(SW_RESTORE) for a visible minimized MDI child window */
2785 static const struct message WmRestoreMDIchildVisibleSeq_2[] = {
2786 { HCBT_MINMAX, hook|lparam, 0, SW_RESTORE },
2787 { WM_QUERYOPEN, sent|wparam|lparam, 0, 0 },
2788 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
2789 { WM_NCCALCSIZE, sent|wparam, 1 },
2790 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2791 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_NOCLIENTSIZE|SWP_STATECHANGED },
2792 { WM_MOVE, sent|defwinproc },
2793 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2794 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2795 { EVENT_SYSTEM_MINIMIZEEND, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2796 { HCBT_SETFOCUS, hook },
2797 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
2798 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
2799 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2800 { WM_SETFOCUS, sent },
2803 /* ShowWindow(SW_MINIMIZE) for a visible restored MDI child window */
2804 static const struct message WmMinimizeMDIchildVisibleSeq[] = {
2805 { HCBT_MINMAX, hook|lparam, 0, SW_MINIMIZE },
2806 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOCOPYBITS|SWP_STATECHANGED },
2807 { WM_NCCALCSIZE, sent|wparam, 1 },
2808 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOCOPYBITS|SWP_NOCLIENTSIZE|SWP_STATECHANGED },
2809 { WM_MOVE, sent|defwinproc },
2810 { WM_SIZE, sent|defwinproc|wparam, SIZE_MINIMIZED },
2811 { WM_CHILDACTIVATE, sent|wparam|lparam|defwinproc, 0, 0 },
2812 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2813 { EVENT_SYSTEM_MINIMIZESTART, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2814 /* FIXME: Wine creates an icon/title window while Windows doesn't */
2815 { WM_PARENTNOTIFY, sent|parent|wparam|optional, WM_CREATE }, /* MDI client */
2818 /* ShowWindow(SW_RESTORE) for a not visible MDI child window */
2819 static const struct message WmRestoreMDIchildInisibleSeq[] = {
2820 { HCBT_MINMAX, hook|lparam, 0, SW_RESTORE },
2821 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_STATECHANGED },
2822 { WM_NCCALCSIZE, sent|wparam, 1 },
2823 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2824 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2825 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_STATECHANGED },
2826 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2828 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2829 { WM_NCCALCSIZE, sent|wparam, 1 },
2830 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2831 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2832 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2836 static HWND mdi_client;
2837 static WNDPROC old_mdi_client_proc;
2839 static LRESULT WINAPI mdi_client_hook_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
2843 /* do not log painting messages */
2844 if (message != WM_PAINT &&
2845 message != WM_NCPAINT &&
2846 message != WM_SYNCPAINT &&
2847 message != WM_ERASEBKGND &&
2848 message != WM_NCHITTEST &&
2849 message != WM_GETTEXT &&
2850 message != WM_MDIGETACTIVE &&
2851 message != WM_GETICON &&
2852 message != WM_DEVICECHANGE)
2854 trace("mdi client: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
2858 case WM_WINDOWPOSCHANGING:
2859 case WM_WINDOWPOSCHANGED:
2861 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
2863 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
2864 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x ",
2865 winpos->hwnd, winpos->hwndInsertAfter,
2866 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
2867 dump_winpos_flags(winpos->flags);
2869 /* Log only documented flags, win2k uses 0x1000 and 0x2000
2870 * in the high word for internal purposes
2872 wParam = winpos->flags & 0xffff;
2873 /* We are not interested in the flags that don't match under XP and Win9x */
2874 wParam &= ~(SWP_NOZORDER);
2879 msg.message = message;
2880 msg.flags = sent|wparam|lparam;
2881 msg.wParam = wParam;
2882 msg.lParam = lParam;
2886 return CallWindowProcA(old_mdi_client_proc, hwnd, message, wParam, lParam);
2889 static LRESULT WINAPI mdi_child_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
2891 static long defwndproc_counter = 0;
2895 /* do not log painting messages */
2896 if (message != WM_PAINT &&
2897 message != WM_NCPAINT &&
2898 message != WM_SYNCPAINT &&
2899 message != WM_ERASEBKGND &&
2900 message != WM_NCHITTEST &&
2901 message != WM_GETTEXT &&
2902 message != WM_GETICON &&
2903 message != WM_DEVICECHANGE)
2905 trace("mdi child: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
2909 case WM_WINDOWPOSCHANGING:
2910 case WM_WINDOWPOSCHANGED:
2912 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
2914 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
2915 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x ",
2916 winpos->hwnd, winpos->hwndInsertAfter,
2917 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
2918 dump_winpos_flags(winpos->flags);
2920 /* Log only documented flags, win2k uses 0x1000 and 0x2000
2921 * in the high word for internal purposes
2923 wParam = winpos->flags & 0xffff;
2924 /* We are not interested in the flags that don't match under XP and Win9x */
2925 wParam &= ~(SWP_NOZORDER);
2929 case WM_MDIACTIVATE:
2931 HWND active, client = GetParent(hwnd);
2933 active = (HWND)SendMessageA(client, WM_MDIGETACTIVE, 0, 0);
2935 if (hwnd == (HWND)lParam) /* if we are being activated */
2936 ok (active == (HWND)lParam, "new active %p != active %p\n", (HWND)lParam, active);
2938 ok (active == (HWND)wParam, "old active %p != active %p\n", (HWND)wParam, active);
2943 msg.message = message;
2944 msg.flags = sent|wparam|lparam;
2945 if (defwndproc_counter) msg.flags |= defwinproc;
2946 msg.wParam = wParam;
2947 msg.lParam = lParam;
2951 defwndproc_counter++;
2952 ret = DefMDIChildProcA(hwnd, message, wParam, lParam);
2953 defwndproc_counter--;
2958 static LRESULT WINAPI mdi_frame_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
2960 static long defwndproc_counter = 0;
2964 /* do not log painting messages */
2965 if (message != WM_PAINT &&
2966 message != WM_NCPAINT &&
2967 message != WM_SYNCPAINT &&
2968 message != WM_ERASEBKGND &&
2969 message != WM_NCHITTEST &&
2970 message != WM_GETTEXT &&
2971 message != WM_GETICON &&
2972 message != WM_DEVICECHANGE)
2974 trace("mdi frame: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
2978 case WM_WINDOWPOSCHANGING:
2979 case WM_WINDOWPOSCHANGED:
2981 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
2983 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
2984 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x ",
2985 winpos->hwnd, winpos->hwndInsertAfter,
2986 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
2987 dump_winpos_flags(winpos->flags);
2989 /* Log only documented flags, win2k uses 0x1000 and 0x2000
2990 * in the high word for internal purposes
2992 wParam = winpos->flags & 0xffff;
2993 /* We are not interested in the flags that don't match under XP and Win9x */
2994 wParam &= ~(SWP_NOZORDER);
2999 msg.message = message;
3000 msg.flags = sent|wparam|lparam;
3001 if (defwndproc_counter) msg.flags |= defwinproc;
3002 msg.wParam = wParam;
3003 msg.lParam = lParam;
3007 defwndproc_counter++;
3008 ret = DefFrameProcA(hwnd, mdi_client, message, wParam, lParam);
3009 defwndproc_counter--;
3014 static BOOL mdi_RegisterWindowClasses(void)
3019 cls.lpfnWndProc = mdi_frame_wnd_proc;
3022 cls.hInstance = GetModuleHandleA(0);
3024 cls.hCursor = LoadCursorA(0, (LPSTR)IDC_ARROW);
3025 cls.hbrBackground = GetStockObject(WHITE_BRUSH);
3026 cls.lpszMenuName = NULL;
3027 cls.lpszClassName = "MDI_frame_class";
3028 if (!RegisterClassA(&cls)) return FALSE;
3030 cls.lpfnWndProc = mdi_child_wnd_proc;
3031 cls.lpszClassName = "MDI_child_class";
3032 if (!RegisterClassA(&cls)) return FALSE;
3034 if (!GetClassInfoA(0, "MDIClient", &cls)) assert(0);
3035 old_mdi_client_proc = cls.lpfnWndProc;
3036 cls.hInstance = GetModuleHandleA(0);
3037 cls.lpfnWndProc = mdi_client_hook_proc;
3038 cls.lpszClassName = "MDI_client_class";
3039 if (!RegisterClassA(&cls)) assert(0);
3044 static void test_mdi_messages(void)
3046 MDICREATESTRUCTA mdi_cs;
3047 CLIENTCREATESTRUCT client_cs;
3048 HWND mdi_frame, mdi_child, mdi_child2, active_child;
3050 HMENU hMenu = CreateMenu();
3052 assert(mdi_RegisterWindowClasses());
3056 trace("creating MDI frame window\n");
3057 mdi_frame = CreateWindowExA(0, "MDI_frame_class", "MDI frame window",
3058 WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX |
3059 WS_MAXIMIZEBOX | WS_VISIBLE,
3060 100, 100, CW_USEDEFAULT, CW_USEDEFAULT,
3061 GetDesktopWindow(), hMenu,
3062 GetModuleHandleA(0), NULL);
3064 ok_sequence(WmCreateMDIframeSeq, "Create MDI frame window", FALSE);
3066 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3067 ok(GetFocus() == mdi_frame, "wrong focus window %p\n", GetFocus());
3069 trace("creating MDI client window\n");
3070 client_cs.hWindowMenu = 0;
3071 client_cs.idFirstChild = MDI_FIRST_CHILD_ID;
3072 mdi_client = CreateWindowExA(0, "MDI_client_class",
3074 WS_CHILD | WS_VISIBLE | MDIS_ALLCHILDSTYLES,
3076 mdi_frame, 0, GetModuleHandleA(0), &client_cs);
3078 ok_sequence(WmCreateMDIclientSeq, "Create visible MDI client window", FALSE);
3080 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3081 ok(GetFocus() == mdi_frame, "input focus should be on MDI frame not on %p\n", GetFocus());
3083 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3084 ok(!active_child, "wrong active MDI child %p\n", active_child);
3085 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
3090 trace("creating invisible MDI child window\n");
3091 mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
3093 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
3094 mdi_client, 0, GetModuleHandleA(0), NULL);
3098 ShowWindow(mdi_child, SW_SHOWNORMAL);
3099 ok_sequence(WmShowChildSeq, "ShowWindow(SW_SHOWNORMAL) MDI child window", FALSE);
3101 ok(GetWindowLongA(mdi_child, GWL_STYLE) & WS_VISIBLE, "MDI child should be visible\n");
3102 ok(IsWindowVisible(mdi_child), "MDI child should be visible\n");
3104 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3105 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3107 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3108 ok(!active_child, "wrong active MDI child %p\n", active_child);
3109 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
3111 ShowWindow(mdi_child, SW_HIDE);
3112 ok_sequence(WmHideChildSeq, "ShowWindow(SW_HIDE) MDI child window", FALSE);
3115 ShowWindow(mdi_child, SW_SHOW);
3116 ok_sequence(WmShowChildSeq, "ShowWindow(SW_SHOW) MDI child window", FALSE);
3118 ok(GetWindowLongA(mdi_child, GWL_STYLE) & WS_VISIBLE, "MDI child should be visible\n");
3119 ok(IsWindowVisible(mdi_child), "MDI child should be visible\n");
3121 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3122 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3124 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3125 ok(!active_child, "wrong active MDI child %p\n", active_child);
3126 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
3128 DestroyWindow(mdi_child);
3131 trace("creating visible MDI child window\n");
3132 mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
3133 WS_CHILD | WS_VISIBLE,
3134 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
3135 mdi_client, 0, GetModuleHandleA(0), NULL);
3137 ok_sequence(WmCreateMDIchildVisibleSeq, "Create visible MDI child window", FALSE);
3139 ok(GetWindowLongA(mdi_child, GWL_STYLE) & WS_VISIBLE, "MDI child should be visible\n");
3140 ok(IsWindowVisible(mdi_child), "MDI child should be visible\n");
3142 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3143 ok(GetFocus() == mdi_child, "wrong focus window %p\n", GetFocus());
3145 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3146 ok(active_child == mdi_child, "wrong active MDI child %p\n", active_child);
3147 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
3150 DestroyWindow(mdi_child);
3151 ok_sequence(WmDestroyMDIchildVisibleSeq, "Destroy visible MDI child window", TRUE);
3153 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3154 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3156 /* Win2k: MDI client still returns a just destroyed child as active
3157 * Win9x: MDI client returns 0
3159 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3160 ok(active_child == mdi_child || /* win2k */
3161 !active_child, /* win9x */
3162 "wrong active MDI child %p\n", active_child);
3163 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
3167 trace("creating invisible MDI child window\n");
3168 mdi_child2 = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
3170 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
3171 mdi_client, 0, GetModuleHandleA(0), NULL);
3173 ok_sequence(WmCreateMDIchildInvisibleSeq, "Create invisible MDI child window", FALSE);
3175 ok(!(GetWindowLongA(mdi_child2, GWL_STYLE) & WS_VISIBLE), "MDI child should not be visible\n");
3176 ok(!IsWindowVisible(mdi_child2), "MDI child should not be visible\n");
3178 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3179 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3181 /* Win2k: MDI client still returns a just destroyed child as active
3182 * Win9x: MDI client returns mdi_child2
3184 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3185 ok(active_child == mdi_child || /* win2k */
3186 active_child == mdi_child2, /* win9x */
3187 "wrong active MDI child %p\n", active_child);
3188 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
3191 ShowWindow(mdi_child2, SW_MAXIMIZE);
3192 ok_sequence(WmMaximizeMDIchildInvisibleSeq, "ShowWindow(SW_MAXIMIZE):invisible MDI child", FALSE);
3194 ok(GetWindowLongA(mdi_child2, GWL_STYLE) & WS_VISIBLE, "MDI child should be visible\n");
3195 ok(IsWindowVisible(mdi_child2), "MDI child should be visible\n");
3197 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3198 ok(active_child == mdi_child2, "wrong active MDI child %p\n", active_child);
3199 ok(zoomed, "wrong zoomed state %d\n", zoomed);
3202 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3203 ok(GetFocus() == mdi_child2 || /* win2k */
3204 GetFocus() == 0, /* win9x */
3205 "wrong focus window %p\n", GetFocus());
3210 ShowWindow(mdi_child2, SW_HIDE);
3211 ok_sequence(WmHideChildSeq, "ShowWindow(SW_HIDE):MDI child", FALSE);
3213 ShowWindow(mdi_child2, SW_RESTORE);
3214 ok_sequence(WmRestoreMDIchildInisibleSeq, "ShowWindow(SW_RESTORE):invisible MDI child", FALSE);
3217 ok(GetWindowLongA(mdi_child2, GWL_STYLE) & WS_VISIBLE, "MDI child should be visible\n");
3218 ok(IsWindowVisible(mdi_child2), "MDI child should be visible\n");
3220 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3221 ok(active_child == mdi_child2, "wrong active MDI child %p\n", active_child);
3222 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
3228 ShowWindow(mdi_child2, SW_HIDE);
3229 ok_sequence(WmHideChildSeq, "ShowWindow(SW_HIDE):MDI child", FALSE);
3231 ShowWindow(mdi_child2, SW_SHOW);
3232 ok_sequence(WmShowChildSeq, "ShowWindow(SW_SHOW):MDI child", FALSE);
3234 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3235 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3237 ShowWindow(mdi_child2, SW_MAXIMIZE);
3238 ok_sequence(WmMaximizeMDIchildVisibleSeq, "ShowWindow(SW_MAXIMIZE):MDI child", FALSE);
3240 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3241 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3243 ShowWindow(mdi_child2, SW_RESTORE);
3244 ok_sequence(WmRestoreMDIchildVisibleSeq, "ShowWindow(SW_RESTORE):maximized MDI child", FALSE);
3246 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3247 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3249 ShowWindow(mdi_child2, SW_MINIMIZE);
3250 ok_sequence(WmMinimizeMDIchildVisibleSeq, "ShowWindow(SW_MINIMIZE):MDI child", TRUE);
3252 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3253 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3255 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3256 ok(active_child == mdi_child2, "wrong active MDI child %p\n", active_child);
3257 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
3260 ShowWindow(mdi_child2, SW_RESTORE);
3261 ok_sequence(WmRestoreMDIchildVisibleSeq_2, "ShowWindow(SW_RESTORE):minimized MDI child", TRUE);
3263 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3264 ok(GetFocus() == mdi_child2, "wrong focus window %p\n", GetFocus());
3266 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3267 ok(active_child == mdi_child2, "wrong active MDI child %p\n", active_child);
3268 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
3274 ShowWindow(mdi_child2, SW_HIDE);
3275 ok_sequence(WmHideChildSeq, "ShowWindow(SW_HIDE):MDI child", FALSE);
3277 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3278 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3280 DestroyWindow(mdi_child2);
3281 ok_sequence(WmDestroyMDIchildInvisibleSeq, "Destroy invisible MDI child window", FALSE);
3283 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3284 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3286 /* test for maximized MDI children */
3287 trace("creating maximized visible MDI child window 1\n");
3288 mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
3289 WS_CHILD | WS_VISIBLE | WS_MAXIMIZEBOX | WS_MAXIMIZE,
3290 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
3291 mdi_client, 0, GetModuleHandleA(0), NULL);
3293 ok_sequence(WmCreateMDIchildVisibleMaxSeq1, "Create maximized visible 1st MDI child window", TRUE);
3294 ok(IsZoomed(mdi_child), "1st MDI child should be maximized\n");
3296 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3297 ok(GetFocus() == mdi_child || /* win2k */
3298 GetFocus() == 0, /* win9x */
3299 "wrong focus window %p\n", GetFocus());
3301 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3302 ok(active_child == mdi_child, "wrong active MDI child %p\n", active_child);
3303 ok(zoomed, "wrong zoomed state %d\n", zoomed);
3306 trace("creating maximized visible MDI child window 2\n");
3307 mdi_child2 = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
3308 WS_CHILD | WS_VISIBLE | WS_MAXIMIZEBOX | WS_MAXIMIZE,
3309 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
3310 mdi_client, 0, GetModuleHandleA(0), NULL);
3312 ok_sequence(WmCreateMDIchildVisibleMaxSeq2, "Create maximized visible 2nd MDI child 2 window", TRUE);
3313 ok(IsZoomed(mdi_child2), "2nd MDI child should be maximized\n");
3314 ok(!IsZoomed(mdi_child), "1st MDI child should NOT be maximized\n");
3316 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3317 ok(GetFocus() == mdi_child2, "wrong focus window %p\n", GetFocus());
3319 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3320 ok(active_child == mdi_child2, "wrong active MDI child %p\n", active_child);
3321 ok(zoomed, "wrong zoomed state %d\n", zoomed);
3324 trace("destroying maximized visible MDI child window 2\n");
3325 DestroyWindow(mdi_child2);
3326 ok_sequence(WmDestroyMDIchildVisibleSeq, "Destroy visible MDI child window", TRUE);
3328 ok(!IsZoomed(mdi_child), "1st MDI child should NOT be maximized\n");
3330 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3331 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3333 /* Win2k: MDI client still returns a just destroyed child as active
3334 * Win9x: MDI client returns 0
3336 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3337 ok(active_child == mdi_child2 || /* win2k */
3338 !active_child, /* win9x */
3339 "wrong active MDI child %p\n", active_child);
3342 ShowWindow(mdi_child, SW_MAXIMIZE);
3343 ok(IsZoomed(mdi_child), "1st MDI child should be maximized\n");
3346 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3347 ok(GetFocus() == mdi_child, "wrong focus window %p\n", GetFocus());
3349 trace("re-creating maximized visible MDI child window 2\n");
3350 mdi_child2 = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
3351 WS_CHILD | WS_VISIBLE | WS_MAXIMIZEBOX | WS_MAXIMIZE,
3352 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
3353 mdi_client, 0, GetModuleHandleA(0), NULL);
3355 ok_sequence(WmCreateMDIchildVisibleMaxSeq2, "Create maximized visible 2nd MDI child 2 window", TRUE);
3356 ok(IsZoomed(mdi_child2), "2nd MDI child should be maximized\n");
3357 ok(!IsZoomed(mdi_child), "1st MDI child should NOT be maximized\n");
3359 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3360 ok(GetFocus() == mdi_child2, "wrong focus window %p\n", GetFocus());
3362 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3363 ok(active_child == mdi_child2, "wrong active MDI child %p\n", active_child);
3364 ok(zoomed, "wrong zoomed state %d\n", zoomed);
3367 SendMessageA(mdi_child2, WM_SYSCOMMAND, SC_CLOSE, 0);
3368 ok_sequence(WmDestroyMDIchildVisibleMaxSeq2, "WM_SYSCOMMAND/SC_CLOSE on a visible maximized MDI child window", TRUE);
3369 ok(!IsWindow(mdi_child2), "MDI child 2 should be destroyed\n");
3371 ok(IsZoomed(mdi_child), "1st MDI child should be maximized\n");
3372 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3373 ok(GetFocus() == mdi_child, "wrong focus window %p\n", GetFocus());
3375 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3376 ok(active_child == mdi_child, "wrong active MDI child %p\n", active_child);
3377 ok(zoomed, "wrong zoomed state %d\n", zoomed);
3380 DestroyWindow(mdi_child);
3381 ok_sequence(WmDestroyMDIchildVisibleSeq, "Destroy visible MDI child window", TRUE);
3383 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3384 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3386 /* Win2k: MDI client still returns a just destroyed child as active
3387 * Win9x: MDI client returns 0
3389 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3390 ok(active_child == mdi_child || /* win2k */
3391 !active_child, /* win9x */
3392 "wrong active MDI child %p\n", active_child);
3395 trace("creating maximized invisible MDI child window\n");
3396 mdi_child2 = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
3397 WS_CHILD | WS_MAXIMIZE | WS_CAPTION | WS_THICKFRAME,
3398 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
3399 mdi_client, 0, GetModuleHandleA(0), NULL);
3401 ok_sequence(WmCreateMDIchildInvisibleMaxSeq4, "Create maximized invisible MDI child window", FALSE);
3402 ok(IsZoomed(mdi_child2), "MDI child should be maximized\n");
3403 ok(!(GetWindowLongA(mdi_child2, GWL_STYLE) & WS_VISIBLE), "MDI child should be not visible\n");
3404 ok(!IsWindowVisible(mdi_child2), "MDI child should be not visible\n");
3406 /* Win2k: MDI client still returns a just destroyed child as active
3407 * Win9x: MDI client returns 0
3409 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3410 ok(active_child == mdi_child || /* win2k */
3411 !active_child, /* win9x */
3412 "wrong active MDI child %p\n", active_child);
3415 trace("call ShowWindow(mdi_child, SW_MAXIMIZE)\n");
3416 ShowWindow(mdi_child2, SW_MAXIMIZE);
3417 ok_sequence(WmMaximizeMDIchildInvisibleSeq2, "ShowWindow(SW_MAXIMIZE):invisible maximized MDI child", FALSE);
3418 ok(IsZoomed(mdi_child2), "MDI child should be maximized\n");
3419 ok(GetWindowLongA(mdi_child2, GWL_STYLE) & WS_VISIBLE, "MDI child should be visible\n");
3420 ok(IsWindowVisible(mdi_child2), "MDI child should be visible\n");
3422 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3423 ok(active_child == mdi_child2, "wrong active MDI child %p\n", active_child);
3424 ok(zoomed, "wrong zoomed state %d\n", zoomed);
3427 SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child2, 0);
3430 /* end of test for maximized MDI children */
3433 trace("creating maximized visible MDI child window 1(Switch test)\n");
3434 mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
3435 WS_CHILD | WS_VISIBLE | WS_MAXIMIZEBOX | WS_MAXIMIZE,
3436 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
3437 mdi_client, 0, GetModuleHandleA(0), NULL);
3439 ok_sequence(WmCreateMDIchildVisibleMaxSeq1, "Create maximized visible 1st MDI child window(Switch test)", TRUE);
3440 ok(IsZoomed(mdi_child), "1st MDI child should be maximized(Switch test)\n");
3442 ok(GetActiveWindow() == mdi_frame, "wrong active window %p(Switch test)\n", GetActiveWindow());
3443 ok(GetFocus() == mdi_child || /* win2k */
3444 GetFocus() == 0, /* win9x */
3445 "wrong focus window %p(Switch test)\n", GetFocus());
3447 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3448 ok(active_child == mdi_child, "wrong active MDI child %p(Switch test)\n", active_child);
3449 ok(zoomed, "wrong zoomed state %d(Switch test)\n", zoomed);
3452 trace("creating maximized visible MDI child window 2(Switch test)\n");
3453 mdi_child2 = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
3454 WS_CHILD | WS_VISIBLE | WS_MAXIMIZEBOX | WS_MAXIMIZE,
3455 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
3456 mdi_client, 0, GetModuleHandleA(0), NULL);
3458 ok_sequence(WmCreateMDIchildVisibleMaxSeq2, "Create maximized visible 2nd MDI child window (Switch test)", TRUE);
3460 ok(IsZoomed(mdi_child2), "2nd MDI child should be maximized(Switch test)\n");
3461 ok(!IsZoomed(mdi_child), "1st MDI child should NOT be maximized(Switch test)\n");
3463 ok(GetActiveWindow() == mdi_frame, "wrong active window %p(Switch test)\n", GetActiveWindow());
3464 ok(GetFocus() == mdi_child2, "wrong focus window %p(Switch test)\n", GetFocus());
3466 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3467 ok(active_child == mdi_child2, "wrong active MDI child %p(Switch test)\n", active_child);
3468 ok(zoomed, "wrong zoomed state %d(Switch test)\n", zoomed);
3471 trace("Switch child window.\n");
3472 SendMessageA(mdi_client, WM_MDIACTIVATE, (WPARAM)mdi_child, 0);
3473 ok_sequence(WmSwitchChild, "Child did not switch correctly", TRUE);
3474 trace("end of test for switch maximized MDI children\n");
3477 /* Prepare for switching test of not maximized MDI children */
3478 ShowWindow( mdi_child, SW_NORMAL );
3479 ok(!IsZoomed(mdi_child), "wrong zoomed state for %p(Switch test)\n", mdi_child);
3480 ok(!IsZoomed(mdi_child2), "wrong zoomed state for %p(Switch test)\n", mdi_child2);
3481 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, 0);
3482 ok(active_child == mdi_child, "wrong active MDI child %p(Switch test)\n", active_child);
3485 SendMessageA(mdi_client, WM_MDIACTIVATE, (WPARAM)mdi_child2, 0);
3486 ok_sequence(WmSwitchNotMaximizedChild, "Not maximized child did not switch correctly", FALSE);
3487 trace("end of test for switch not maximized MDI children\n");
3490 SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child, 0);
3493 SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child2, 0);
3498 /* end of tests for switch maximized/not maximized MDI children */
3500 mdi_cs.szClass = "MDI_child_Class";
3501 mdi_cs.szTitle = "MDI child";
3502 mdi_cs.hOwner = GetModuleHandleA(0);
3505 mdi_cs.cx = CW_USEDEFAULT;
3506 mdi_cs.cy = CW_USEDEFAULT;
3507 mdi_cs.style = WS_CHILD | WS_SYSMENU | WS_VISIBLE | WS_MAXIMIZEBOX | WS_MAXIMIZE;
3509 mdi_child = (HWND)SendMessageA(mdi_client, WM_MDICREATE, 0, (LPARAM)&mdi_cs);
3510 ok(mdi_child != 0, "MDI child creation failed\n");
3511 ok_sequence(WmCreateMDIchildVisibleMaxSeq3, "WM_MDICREATE for maximized visible MDI child window", TRUE);
3513 ok(GetMenuItemID(hMenu, GetMenuItemCount(hMenu) - 1) == SC_CLOSE, "SC_CLOSE menu item not found\n");
3515 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3516 ok(active_child == mdi_child, "wrong active MDI child %p\n", active_child);
3518 ok(IsZoomed(mdi_child), "MDI child should be maximized\n");
3519 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3520 ok(GetFocus() == mdi_child, "wrong focus window %p\n", GetFocus());
3522 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3523 ok(active_child == mdi_child, "wrong active MDI child %p\n", active_child);
3524 ok(zoomed, "wrong zoomed state %d\n", zoomed);
3527 SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child, 0);
3528 ok_sequence(WmDestroyMDIchildVisibleMaxSeq1, "Destroy visible maximized MDI child window", TRUE);
3530 ok(!IsWindow(mdi_child), "MDI child should be destroyed\n");
3531 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3532 ok(!active_child, "wrong active MDI child %p\n", active_child);
3537 DestroyWindow(mdi_client);
3538 ok_sequence(WmDestroyMDIclientSeq, "Destroy MDI client window", FALSE);
3540 /* test maximization of MDI child with invisible parent */
3541 client_cs.hWindowMenu = 0;
3542 mdi_client = CreateWindow("MDI_client_class",
3544 WS_CHILD | WS_CLIPCHILDREN | WS_VSCROLL | WS_HSCROLL | WS_VISIBLE,
3546 mdi_frame, 0, GetModuleHandleA(0), &client_cs);
3547 ok_sequence(WmCreateMDIclientSeq, "Create MDI client window", FALSE);
3549 ShowWindow(mdi_client, SW_HIDE);
3550 ok_sequence(WmHideMDIclientSeq, "Hide MDI client window", FALSE);
3552 mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
3553 WS_CHILD | WS_CLIPCHILDREN | WS_VSCROLL | WS_HSCROLL,
3555 mdi_client, 0, GetModuleHandleA(0), NULL);
3556 ok_sequence(WmCreateMDIchildInvisibleParentSeq, "Create MDI child window with invisible parent", FALSE);
3558 SendMessage(mdi_client, WM_MDIMAXIMIZE, (WPARAM) mdi_child, 0);
3559 ok_sequence(WmMaximizeMDIchildInvisibleParentSeq, "Maximize MDI child window with invisible parent", TRUE);
3560 zoomed = IsZoomed(mdi_child);
3561 ok(zoomed, "wrong zoomed state %d\n", zoomed);
3563 ShowWindow(mdi_client, SW_SHOW);
3564 ok_sequence(WmShowMDIclientSeq, "Show MDI client window", FALSE);
3566 DestroyWindow(mdi_child);
3567 ok_sequence(WmDestroyMDIchildVisibleSeq, "Destroy visible maximized MDI child window", TRUE);
3569 /* end of test for maximization of MDI child with invisible parent */
3571 DestroyWindow(mdi_client);
3572 ok_sequence(WmDestroyMDIclientSeq, "Destroy MDI client window", FALSE);
3574 DestroyWindow(mdi_frame);
3575 ok_sequence(WmDestroyMDIframeSeq, "Destroy MDI frame window", FALSE);
3577 /************************* End of MDI test **********************************/
3579 static void test_WM_SETREDRAW(HWND hwnd)
3581 DWORD style = GetWindowLongA(hwnd, GWL_STYLE);
3586 SendMessageA(hwnd, WM_SETREDRAW, FALSE, 0);
3587 ok_sequence(WmSetRedrawFalseSeq, "SetRedraw:FALSE", FALSE);
3589 ok(!(GetWindowLongA(hwnd, GWL_STYLE) & WS_VISIBLE), "WS_VISIBLE should NOT be set\n");
3590 ok(!IsWindowVisible(hwnd), "IsWindowVisible() should return FALSE\n");
3593 SendMessageA(hwnd, WM_SETREDRAW, TRUE, 0);
3594 ok_sequence(WmSetRedrawTrueSeq, "SetRedraw:TRUE", FALSE);
3596 ok(GetWindowLongA(hwnd, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
3597 ok(IsWindowVisible(hwnd), "IsWindowVisible() should return TRUE\n");
3599 /* restore original WS_VISIBLE state */
3600 SetWindowLongA(hwnd, GWL_STYLE, style);
3606 static INT_PTR CALLBACK TestModalDlgProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
3610 trace("dialog: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
3612 /* explicitly ignore WM_GETICON message */
3613 if (message == WM_GETICON) return 0;
3620 case WM_DEVICECHANGE:
3625 case WM_WINDOWPOSCHANGING:
3626 case WM_WINDOWPOSCHANGED:
3628 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
3630 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
3631 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x ",
3632 winpos->hwnd, winpos->hwndInsertAfter,
3633 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
3634 dump_winpos_flags(winpos->flags);
3636 /* Log only documented flags, win2k uses 0x1000 and 0x2000
3637 * in the high word for internal purposes
3639 wParam = winpos->flags & 0xffff;
3640 /* We are not interested in the flags that don't match under XP and Win9x */
3641 wParam &= ~(SWP_NOZORDER);
3646 msg.message = message;
3647 msg.flags = sent|wparam|lparam;
3648 msg.wParam = wParam;
3649 msg.lParam = lParam;
3652 if (message == WM_INITDIALOG) SetTimer( hwnd, 1, 100, NULL );
3653 if (message == WM_TIMER) EndDialog( hwnd, 0 );
3657 static void test_hv_scroll_1(HWND hwnd, INT ctl, DWORD clear, DWORD set, INT min, INT max)
3659 DWORD style, exstyle;
3663 exstyle = GetWindowLongA(hwnd, GWL_EXSTYLE);
3664 style = GetWindowLongA(hwnd, GWL_STYLE);
3665 /* do not be confused by WS_DLGFRAME set */
3666 if ((style & WS_CAPTION) == WS_CAPTION) style &= ~WS_CAPTION;
3668 if (clear) ok(style & clear, "style %08x should be set\n", clear);
3669 if (set) ok(!(style & set), "style %08x should not be set\n", set);
3671 ret = SetScrollRange(hwnd, ctl, min, max, FALSE);
3672 ok( ret, "SetScrollRange(%d) error %d\n", ctl, GetLastError());
3673 if ((style & (WS_DLGFRAME | WS_BORDER | WS_THICKFRAME)) || (exstyle & WS_EX_DLGMODALFRAME))
3674 ok_sequence(WmSetScrollRangeHV_NC_Seq, "SetScrollRange(SB_HORZ/SB_VERT) NC", FALSE);
3676 ok_sequence(WmSetScrollRangeHVSeq, "SetScrollRange(SB_HORZ/SB_VERT)", FALSE);
3678 style = GetWindowLongA(hwnd, GWL_STYLE);
3679 if (set) ok(style & set, "style %08x should be set\n", set);
3680 if (clear) ok(!(style & clear), "style %08x should not be set\n", clear);
3682 /* a subsequent call should do nothing */
3683 ret = SetScrollRange(hwnd, ctl, min, max, FALSE);
3684 ok( ret, "SetScrollRange(%d) error %d\n", ctl, GetLastError());
3685 ok_sequence(WmEmptySeq, "SetScrollRange(SB_HORZ/SB_VERT) empty sequence", FALSE);
3689 trace("Ignore GetScrollRange error below if you are on Win9x\n");
3690 ret = GetScrollRange(hwnd, ctl, &xmin, &xmax);
3691 ok( ret, "GetScrollRange(%d) error %d\n", ctl, GetLastError());
3692 ok_sequence(WmEmptySeq, "GetScrollRange(SB_HORZ/SB_VERT) empty sequence", FALSE);
3693 ok(xmin == min, "unexpected min scroll value %d\n", xmin);
3694 ok(xmax == max, "unexpected max scroll value %d\n", xmax);
3697 static void test_hv_scroll_2(HWND hwnd, INT ctl, DWORD clear, DWORD set, INT min, INT max)
3699 DWORD style, exstyle;
3703 exstyle = GetWindowLongA(hwnd, GWL_EXSTYLE);
3704 style = GetWindowLongA(hwnd, GWL_STYLE);
3705 /* do not be confused by WS_DLGFRAME set */
3706 if ((style & WS_CAPTION) == WS_CAPTION) style &= ~WS_CAPTION;
3708 if (clear) ok(style & clear, "style %08x should be set\n", clear);
3709 if (set) ok(!(style & set), "style %08x should not be set\n", set);
3711 si.cbSize = sizeof(si);
3712 si.fMask = SIF_RANGE;
3715 SetScrollInfo(hwnd, ctl, &si, TRUE);
3716 if ((style & (WS_DLGFRAME | WS_BORDER | WS_THICKFRAME)) || (exstyle & WS_EX_DLGMODALFRAME))
3717 ok_sequence(WmSetScrollRangeHV_NC_Seq, "SetScrollInfo(SB_HORZ/SB_VERT) NC", FALSE);
3719 ok_sequence(WmSetScrollRangeHVSeq, "SetScrollInfo(SB_HORZ/SB_VERT)", FALSE);
3721 style = GetWindowLongA(hwnd, GWL_STYLE);
3722 if (set) ok(style & set, "style %08x should be set\n", set);
3723 if (clear) ok(!(style & clear), "style %08x should not be set\n", clear);
3725 /* a subsequent call should do nothing */
3726 SetScrollInfo(hwnd, ctl, &si, TRUE);
3727 if (style & WS_HSCROLL)
3728 ok_sequence(WmSetScrollRangeHSeq_empty, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE);
3729 else if (style & WS_VSCROLL)
3730 ok_sequence(WmSetScrollRangeVSeq_empty, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE);
3732 ok_sequence(WmEmptySeq, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE);
3734 si.fMask = SIF_PAGE;
3736 SetScrollInfo(hwnd, ctl, &si, FALSE);
3737 ok_sequence(WmEmptySeq, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE);
3741 SetScrollInfo(hwnd, ctl, &si, FALSE);
3742 ok_sequence(WmEmptySeq, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE);
3744 si.fMask = SIF_RANGE;
3745 si.nMin = 0xdeadbeef;
3746 si.nMax = 0xdeadbeef;
3747 ret = GetScrollInfo(hwnd, ctl, &si);
3748 ok( ret, "GetScrollInfo error %d\n", GetLastError());
3749 ok_sequence(WmEmptySeq, "GetScrollRange(SB_HORZ/SB_VERT) empty sequence", FALSE);
3750 ok(si.nMin == min, "unexpected min scroll value %d\n", si.nMin);
3751 ok(si.nMax == max, "unexpected max scroll value %d\n", si.nMax);
3754 /* Win9x sends WM_USER+xxx while and NT versions send SBM_xxx messages */
3755 static void test_scroll_messages(HWND hwnd)
3766 ret = GetScrollRange(hwnd, SB_CTL, &min, &max);
3767 ok( ret, "GetScrollRange error %d\n", GetLastError());
3768 if (sequence->message != WmGetScrollRangeSeq[0].message)
3769 trace("GetScrollRange(SB_CTL) generated unknown message %04x\n", sequence->message);
3770 /* values of min and max are undefined */
3773 ret = SetScrollRange(hwnd, SB_CTL, 10, 150, FALSE);
3774 ok( ret, "SetScrollRange error %d\n", GetLastError());
3775 if (sequence->message != WmSetScrollRangeSeq[0].message)
3776 trace("SetScrollRange(SB_CTL) generated unknown message %04x\n", sequence->message);
3781 ret = GetScrollRange(hwnd, SB_CTL, &min, &max);
3782 ok( ret, "GetScrollRange error %d\n", GetLastError());
3783 if (sequence->message != WmGetScrollRangeSeq[0].message)
3784 trace("GetScrollRange(SB_CTL) generated unknown message %04x\n", sequence->message);
3785 /* values of min and max are undefined */
3788 si.cbSize = sizeof(si);
3789 si.fMask = SIF_RANGE;
3792 SetScrollInfo(hwnd, SB_CTL, &si, FALSE);
3793 if (sequence->message != WmSetScrollRangeSeq[0].message)
3794 trace("SetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence->message);
3797 si.fMask = SIF_PAGE;
3799 SetScrollInfo(hwnd, SB_CTL, &si, FALSE);
3800 if (sequence->message != WmSetScrollRangeSeq[0].message)
3801 trace("SetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence->message);
3806 SetScrollInfo(hwnd, SB_CTL, &si, FALSE);
3807 if (sequence->message != WmSetScrollRangeSeq[0].message)
3808 trace("SetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence->message);
3811 si.fMask = SIF_RANGE;
3812 si.nMin = 0xdeadbeef;
3813 si.nMax = 0xdeadbeef;
3814 ret = GetScrollInfo(hwnd, SB_CTL, &si);
3815 ok( ret, "GetScrollInfo error %d\n", GetLastError());
3816 if (sequence->message != WmGetScrollInfoSeq[0].message)
3817 trace("GetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence->message);
3818 /* values of min and max are undefined */
3821 /* set WS_HSCROLL */
3822 test_hv_scroll_1(hwnd, SB_HORZ, 0, WS_HSCROLL, 10, 150);
3823 /* clear WS_HSCROLL */
3824 test_hv_scroll_1(hwnd, SB_HORZ, WS_HSCROLL, 0, 0, 0);
3826 /* set WS_HSCROLL */
3827 test_hv_scroll_2(hwnd, SB_HORZ, 0, WS_HSCROLL, 10, 150);
3828 /* clear WS_HSCROLL */
3829 test_hv_scroll_2(hwnd, SB_HORZ, WS_HSCROLL, 0, 0, 0);
3831 /* set WS_VSCROLL */
3832 test_hv_scroll_1(hwnd, SB_VERT, 0, WS_VSCROLL, 10, 150);
3833 /* clear WS_VSCROLL */
3834 test_hv_scroll_1(hwnd, SB_VERT, WS_VSCROLL, 0, 0, 0);
3836 /* set WS_VSCROLL */
3837 test_hv_scroll_2(hwnd, SB_VERT, 0, WS_VSCROLL, 10, 150);
3838 /* clear WS_VSCROLL */
3839 test_hv_scroll_2(hwnd, SB_VERT, WS_VSCROLL, 0, 0, 0);
3842 static void test_showwindow(void)
3847 hwnd = CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW,
3848 100, 100, 200, 200, 0, 0, 0, NULL);
3849 ok (hwnd != 0, "Failed to create overlapped window\n");
3850 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
3851 0, 0, 10, 10, hwnd, 0, 0, NULL);
3852 ok (hchild != 0, "Failed to create child\n");
3855 /* ShowWindow( SW_SHOWNA) for invisible top level window */
3856 trace("calling ShowWindow( SW_SHOWNA) for invisible top level window\n");
3857 ok( ShowWindow(hwnd, SW_SHOWNA) == FALSE, "ShowWindow: window was visible\n" );
3858 ok_sequence(WmSHOWNATopInvisible, "ShowWindow(SW_SHOWNA) on invisible top level window", TRUE);
3861 /* ShowWindow( SW_SHOWNA) for now visible top level window */
3862 trace("calling ShowWindow( SW_SHOWNA) for now visible top level window\n");
3863 ok( ShowWindow(hwnd, SW_SHOWNA) != FALSE, "ShowWindow: window was invisible\n" );
3864 ok_sequence(WmSHOWNATopVisible, "ShowWindow(SW_SHOWNA) on visible top level window", FALSE);
3866 /* back to invisible */
3867 ShowWindow(hchild, SW_HIDE);
3868 ShowWindow(hwnd, SW_HIDE);
3870 /* ShowWindow(SW_SHOWNA) with child and parent invisible */
3871 trace("calling ShowWindow( SW_SHOWNA) for invisible child with invisible parent\n");
3872 ok( ShowWindow(hchild, SW_SHOWNA) == FALSE, "ShowWindow: window was visible\n" );
3873 ok_sequence(WmSHOWNAChildInvisParInvis, "ShowWindow(SW_SHOWNA) invisible child and parent", FALSE);
3875 /* ShowWindow(SW_SHOWNA) with child visible and parent invisible */
3876 ok( ShowWindow(hchild, SW_SHOW) != FALSE, "ShowWindow: window was invisible\n" );
3878 trace("calling ShowWindow( SW_SHOWNA) for the visible child and invisible parent\n");
3879 ok( ShowWindow(hchild, SW_SHOWNA) != FALSE, "ShowWindow: window was invisible\n" );
3880 ok_sequence(WmSHOWNAChildVisParInvis, "ShowWindow(SW_SHOWNA) visible child and invisible parent", FALSE);
3882 /* ShowWindow(SW_SHOWNA) with child visible and parent visible */
3883 ShowWindow( hwnd, SW_SHOW);
3885 trace("calling ShowWindow( SW_SHOWNA) for the visible child and parent\n");
3886 ok( ShowWindow(hchild, SW_SHOWNA) != FALSE, "ShowWindow: window was invisible\n" );
3887 ok_sequence(WmSHOWNAChildVisParVis, "ShowWindow(SW_SHOWNA) for the visible child and parent", FALSE);
3890 /* ShowWindow(SW_SHOWNA) with child invisible and parent visible */
3891 ShowWindow( hchild, SW_HIDE);
3893 trace("calling ShowWindow( SW_SHOWNA) for the invisible child and visible parent\n");
3894 ok( ShowWindow(hchild, SW_SHOWNA) == FALSE, "ShowWindow: window was visible\n" );
3895 ok_sequence(WmSHOWNAChildInvisParVis, "ShowWindow(SW_SHOWNA) for the invisible child and visible parent", FALSE);
3899 ok(GetCapture() == hchild, "wrong capture window %p\n", GetCapture());
3900 DestroyWindow(hchild);
3901 ok(!GetCapture(), "wrong capture window %p\n", GetCapture());
3903 DestroyWindow(hwnd);
3908 * 1. Create invisible maximized popup window.
3909 * 2. Move and resize it.
3910 * 3. Show it maximized.
3912 trace("calling CreateWindowExA( WS_MAXIMIZE ) for invisible maximized popup window\n");
3913 hwnd = CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP | WS_MAXIMIZE,
3914 100, 100, 200, 200, 0, 0, 0, NULL);
3915 ok (hwnd != 0, "Failed to create popup window\n");
3916 ok(IsZoomed(hwnd), "window should be maximized\n");
3917 ok_sequence(WmCreateInvisibleMaxPopupSeq, "CreateWindow(WS_MAXIMIZED):popup", FALSE);
3920 GetWindowRect(hwnd, &rc);
3921 ok( rc.right-rc.left == GetSystemMetrics(SM_CXSCREEN) &&
3922 rc.bottom-rc.top == GetSystemMetrics(SM_CYSCREEN),
3923 "Invalid maximized size before ShowWindow (%d,%d)-(%d,%d)\n",
3924 rc.left, rc.top, rc.right, rc.bottom);
3925 /* Reset window's size & position */
3926 SetWindowPos(hwnd, 0, 10, 10, 200, 200, SWP_NOZORDER | SWP_NOACTIVATE);
3927 ok(IsZoomed(hwnd), "window should be maximized\n");
3930 trace("calling ShowWindow( SW_SHOWMAXIMIZE ) for invisible maximized popup window\n");
3931 ShowWindow(hwnd, SW_SHOWMAXIMIZED);
3932 ok(IsZoomed(hwnd), "window should be maximized\n");
3933 ok_sequence(WmShowMaxPopupResizedSeq, "ShowWindow(SW_SHOWMAXIMIZED):invisible maximized and resized popup", FALSE);
3936 GetWindowRect(hwnd, &rc);
3937 ok( rc.right-rc.left == GetSystemMetrics(SM_CXSCREEN) &&
3938 rc.bottom-rc.top == GetSystemMetrics(SM_CYSCREEN),
3939 "Invalid maximized size after ShowWindow (%d,%d)-(%d,%d)\n",
3940 rc.left, rc.top, rc.right, rc.bottom);
3941 DestroyWindow(hwnd);
3945 * 1. Create invisible maximized popup window.
3946 * 2. Show it maximized.
3948 trace("calling CreateWindowExA( WS_MAXIMIZE ) for invisible maximized popup window\n");
3949 hwnd = CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP | WS_MAXIMIZE,
3950 100, 100, 200, 200, 0, 0, 0, NULL);
3951 ok (hwnd != 0, "Failed to create popup window\n");
3952 ok(IsZoomed(hwnd), "window should be maximized\n");
3953 ok_sequence(WmCreateInvisibleMaxPopupSeq, "CreateWindow(WS_MAXIMIZED):popup", FALSE);
3956 trace("calling ShowWindow( SW_SHOWMAXIMIZE ) for invisible maximized popup window\n");
3957 ShowWindow(hwnd, SW_SHOWMAXIMIZED);
3958 ok(IsZoomed(hwnd), "window should be maximized\n");
3959 ok_sequence(WmShowMaxPopupSeq, "ShowWindow(SW_SHOWMAXIMIZED):invisible maximized popup", FALSE);
3961 DestroyWindow(hwnd);
3965 * 1. Create visible maximized popup window.
3967 trace("calling CreateWindowExA( WS_MAXIMIZE ) for maximized popup window\n");
3968 hwnd = CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP | WS_MAXIMIZE | WS_VISIBLE,
3969 100, 100, 200, 200, 0, 0, 0, NULL);
3970 ok (hwnd != 0, "Failed to create popup window\n");
3971 ok(IsZoomed(hwnd), "window should be maximized\n");
3972 ok_sequence(WmCreateMaxPopupSeq, "CreateWindow(WS_MAXIMIZED):popup", FALSE);
3974 DestroyWindow(hwnd);
3978 * 1. Create visible popup window.
3981 trace("calling CreateWindowExA( WS_VISIBLE ) for popup window\n");
3982 hwnd = CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP | WS_VISIBLE,
3983 100, 100, 200, 200, 0, 0, 0, NULL);
3984 ok (hwnd != 0, "Failed to create popup window\n");
3985 ok(!IsZoomed(hwnd), "window should NOT be maximized\n");
3986 ok_sequence(WmCreatePopupSeq, "CreateWindow(WS_VISIBLE):popup", FALSE);
3989 trace("calling ShowWindow( SW_SHOWMAXIMIZE ) for visible popup window\n");
3990 ShowWindow(hwnd, SW_SHOWMAXIMIZED);
3991 ok(IsZoomed(hwnd), "window should be maximized\n");
3992 ok_sequence(WmShowVisMaxPopupSeq, "ShowWindow(SW_SHOWMAXIMIZED):popup", FALSE);
3994 DestroyWindow(hwnd);
3998 static void test_sys_menu(void)
4004 hwnd = CreateWindowExA(0, "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW,
4005 100, 100, 200, 200, 0, 0, 0, NULL);
4006 ok (hwnd != 0, "Failed to create overlapped window\n");
4010 /* test existing window without CS_NOCLOSE style */
4011 hmenu = GetSystemMenu(hwnd, FALSE);
4012 ok(hmenu != 0, "GetSystemMenu error %d\n", GetLastError());
4014 state = GetMenuState(hmenu, SC_CLOSE, MF_BYCOMMAND);
4015 ok(state != 0xffffffff, "wrong SC_CLOSE state %x\n", state);
4016 ok(!(state & (MF_DISABLED | MF_GRAYED)), "wrong SC_CLOSE state %x\n", state);
4018 EnableMenuItem(hmenu, SC_CLOSE, MF_BYCOMMAND | MF_GRAYED);
4019 ok_sequence(WmEmptySeq, "WmEnableMenuItem", FALSE);
4021 state = GetMenuState(hmenu, SC_CLOSE, MF_BYCOMMAND);
4022 ok(state != 0xffffffff, "wrong SC_CLOSE state %x\n", state);
4023 ok((state & (MF_DISABLED | MF_GRAYED)) == MF_GRAYED, "wrong SC_CLOSE state %x\n", state);
4025 EnableMenuItem(hmenu, SC_CLOSE, 0);
4026 ok_sequence(WmEmptySeq, "WmEnableMenuItem", FALSE);
4028 state = GetMenuState(hmenu, SC_CLOSE, MF_BYCOMMAND);
4029 ok(state != 0xffffffff, "wrong SC_CLOSE state %x\n", state);
4030 ok(!(state & (MF_DISABLED | MF_GRAYED)), "wrong SC_CLOSE state %x\n", state);
4032 /* test whether removing WS_SYSMENU destroys a system menu */
4033 SetWindowLongW(hwnd, GWL_STYLE, WS_POPUP);
4034 SetWindowPos(hwnd, 0, 0, 0, 0, 0, SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_FRAMECHANGED);
4036 hmenu = GetSystemMenu(hwnd, FALSE);
4037 ok(hmenu != 0, "GetSystemMenu error %d\n", GetLastError());
4039 DestroyWindow(hwnd);
4041 /* test new window with CS_NOCLOSE style */
4042 hwnd = CreateWindowExA(0, "NoCloseWindowClass", NULL, WS_OVERLAPPEDWINDOW,
4043 100, 100, 200, 200, 0, 0, 0, NULL);
4044 ok (hwnd != 0, "Failed to create overlapped window\n");
4046 hmenu = GetSystemMenu(hwnd, FALSE);
4047 ok(hmenu != 0, "GetSystemMenu error %d\n", GetLastError());
4049 state = GetMenuState(hmenu, SC_CLOSE, MF_BYCOMMAND);
4050 ok(state == 0xffffffff, "wrong SC_CLOSE state %x\n", state);
4052 DestroyWindow(hwnd);
4054 /* test new window without WS_SYSMENU style */
4055 hwnd = CreateWindowExA(0, "NoCloseWindowClass", NULL, WS_OVERLAPPEDWINDOW & ~WS_SYSMENU,
4056 100, 100, 200, 200, 0, 0, 0, NULL);
4057 ok(hwnd != 0, "Failed to create overlapped window\n");
4059 hmenu = GetSystemMenu(hwnd, FALSE);
4060 ok(!hmenu, "GetSystemMenu error %d\n", GetLastError());
4062 DestroyWindow(hwnd);
4065 /* For shown WS_OVERLAPPEDWINDOW */
4066 static const struct message WmSetIcon_1[] = {
4067 { WM_SETICON, sent },
4068 { 0x00AE, sent|defwinproc|optional }, /* XP */
4069 { WM_GETTEXT, sent|defwinproc|optional },
4070 { WM_GETTEXT, sent|defwinproc|optional }, /* XP sends a duplicate */
4074 /* For WS_POPUP and hidden WS_OVERLAPPEDWINDOW */
4075 static const struct message WmSetIcon_2[] = {
4076 { WM_SETICON, sent },
4080 /* Sending undocumented 0x3B message with wparam = 0x8000000b */
4081 static const struct message WmInitEndSession[] = {
4083 { WM_QUERYENDSESSION, sent|defwinproc|wparam|lparam, 0, ENDSESSION_LOGOFF },
4087 /* Sending undocumented 0x3B message with wparam = 0x0000000b */
4088 static const struct message WmInitEndSession_2[] = {
4090 { WM_QUERYENDSESSION, sent|defwinproc|wparam|lparam, 0, 0 },
4094 /* Sending undocumented 0x3B message with wparam = 0x80000008 */
4095 static const struct message WmInitEndSession_3[] = {
4097 { WM_ENDSESSION, sent|defwinproc|wparam|lparam, 0, ENDSESSION_LOGOFF },
4101 /* Sending undocumented 0x3B message with wparam = 0x00000008 */
4102 static const struct message WmInitEndSession_4[] = {
4104 { WM_ENDSESSION, sent|defwinproc|wparam|lparam, 0, 0 },
4108 /* Sending undocumented 0x3B message with wparam = 0x80000001 */
4109 static const struct message WmInitEndSession_5[] = {
4111 { WM_ENDSESSION, sent|defwinproc/*|wparam*/|lparam, 1, ENDSESSION_LOGOFF },
4115 static const struct message WmZOrder[] = {
4116 { WM_WINDOWPOSCHANGING, sent|wparam, 0, 0 },
4117 { WM_GETMINMAXINFO, sent|defwinproc|wparam, 0, 0 },
4118 { HCBT_ACTIVATE, hook },
4119 { WM_WINDOWPOSCHANGING, sent|wparam, 3, 0 },
4120 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_NOREDRAW|SWP_NOMOVE|SWP_NOSIZE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE, 0 },
4121 { WM_GETTEXT, sent|optional },
4122 { WM_NCCALCSIZE, sent|wparam|optional, 1 },
4123 { WM_ACTIVATEAPP, sent|wparam, 1, 0 },
4124 { WM_NCACTIVATE, sent|wparam|lparam, 1, 0 },
4125 { WM_GETTEXT, sent|defwinproc|optional },
4126 { WM_GETTEXT, sent|defwinproc|optional },
4127 { WM_ACTIVATE, sent|wparam|lparam, 1, 0 },
4128 { HCBT_SETFOCUS, hook },
4129 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
4130 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
4131 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
4132 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
4133 { WM_GETTEXT, sent|optional },
4134 { WM_NCCALCSIZE, sent|optional },
4138 static void test_MsgWaitForMultipleObjects(HWND hwnd)
4143 ret = MsgWaitForMultipleObjects(0, NULL, FALSE, 0, QS_POSTMESSAGE);
4144 ok(ret == WAIT_TIMEOUT, "MsgWaitForMultipleObjects returned %x\n", ret);
4146 PostMessageA(hwnd, WM_USER, 0, 0);
4148 ret = MsgWaitForMultipleObjects(0, NULL, FALSE, 0, QS_POSTMESSAGE);
4149 ok(ret == WAIT_OBJECT_0, "MsgWaitForMultipleObjects returned %x\n", ret);
4151 ok(PeekMessageA( &msg, 0, 0, 0, PM_REMOVE ), "PeekMessage should succeed\n");
4152 ok(msg.message == WM_USER, "got %04x instead of WM_USER\n", msg.message);
4154 ret = MsgWaitForMultipleObjects(0, NULL, FALSE, 0, QS_POSTMESSAGE);
4155 ok(ret == WAIT_TIMEOUT, "MsgWaitForMultipleObjects returned %x\n", ret);
4157 PostMessageA(hwnd, WM_USER, 0, 0);
4159 ret = MsgWaitForMultipleObjects(0, NULL, FALSE, 0, QS_POSTMESSAGE);
4160 ok(ret == WAIT_OBJECT_0, "MsgWaitForMultipleObjects returned %x\n", ret);
4162 ok(PeekMessageA( &msg, 0, 0, 0, PM_NOREMOVE ), "PeekMessage should succeed\n");
4163 ok(msg.message == WM_USER, "got %04x instead of WM_USER\n", msg.message);
4165 /* shows QS_POSTMESSAGE flag is cleared in the PeekMessage call */
4166 ret = MsgWaitForMultipleObjects(0, NULL, FALSE, 0, QS_POSTMESSAGE);
4167 ok(ret == WAIT_TIMEOUT, "MsgWaitForMultipleObjects returned %x\n", ret);
4169 PostMessageA(hwnd, WM_USER, 0, 0);
4171 /* new incoming message causes it to become signaled again */
4172 ret = MsgWaitForMultipleObjects(0, NULL, FALSE, 0, QS_POSTMESSAGE);
4173 ok(ret == WAIT_OBJECT_0, "MsgWaitForMultipleObjects returned %x\n", ret);
4175 ok(PeekMessageA( &msg, 0, 0, 0, PM_REMOVE ), "PeekMessage should succeed\n");
4176 ok(msg.message == WM_USER, "got %04x instead of WM_USER\n", msg.message);
4177 ok(PeekMessageA( &msg, 0, 0, 0, PM_REMOVE ), "PeekMessage should succeed\n");
4178 ok(msg.message == WM_USER, "got %04x instead of WM_USER\n", msg.message);
4181 /* test if we receive the right sequence of messages */
4182 static void test_messages(void)
4184 HWND hwnd, hparent, hchild;
4185 HWND hchild2, hbutton;
4192 hwnd = CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW,
4193 100, 100, 200, 200, 0, 0, 0, NULL);
4194 ok (hwnd != 0, "Failed to create overlapped window\n");
4195 ok_sequence(WmCreateOverlappedSeq, "CreateWindow:overlapped", FALSE);
4197 /* test ShowWindow(SW_HIDE) on a newly created invisible window */
4198 ok( ShowWindow(hwnd, SW_HIDE) == FALSE, "ShowWindow: window was visible\n" );
4199 ok_sequence(WmEmptySeq, "ShowWindow(SW_HIDE):overlapped, invisible", FALSE);
4201 /* test WM_SETREDRAW on a not visible top level window */
4202 test_WM_SETREDRAW(hwnd);
4204 SetWindowPos(hwnd, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE);
4206 ok_sequence(WmSWP_ShowOverlappedSeq, "SetWindowPos:SWP_SHOWWINDOW:overlapped", FALSE);
4207 ok(IsWindowVisible(hwnd), "window should be visible at this point\n");
4209 ok(GetActiveWindow() == hwnd, "window should be active\n");
4210 ok(GetFocus() == hwnd, "window should have input focus\n");
4211 ShowWindow(hwnd, SW_HIDE);
4213 ok_sequence(WmHideOverlappedSeq, "ShowWindow(SW_HIDE):overlapped", FALSE);
4215 ShowWindow(hwnd, SW_SHOW);
4217 ok_sequence(WmShowOverlappedSeq, "ShowWindow(SW_SHOW):overlapped", TRUE);
4219 ShowWindow(hwnd, SW_HIDE);
4221 ok_sequence(WmHideOverlappedSeq, "ShowWindow(SW_HIDE):overlapped", FALSE);
4223 ShowWindow(hwnd, SW_SHOWMAXIMIZED);
4225 ok_sequence(WmShowMaxOverlappedSeq, "ShowWindow(SW_SHOWMAXIMIZED):overlapped", TRUE);
4227 ShowWindow(hwnd, SW_RESTORE);
4228 ok_sequence(WmShowRestoreMaxOverlappedSeq, "ShowWindow(SW_RESTORE):overlapped", FALSE);
4232 ShowWindow(hwnd, SW_MINIMIZE);
4234 ok_sequence(WmShowMinOverlappedSeq, "ShowWindow(SW_SHOWMINIMIZED):overlapped", TRUE);
4237 ShowWindow(hwnd, SW_RESTORE);
4239 ok_sequence(WmShowRestoreMinOverlappedSeq, "ShowWindow(SW_RESTORE):overlapped", TRUE);
4242 ShowWindow(hwnd, SW_SHOW);
4244 ok_sequence(WmEmptySeq, "ShowWindow(SW_SHOW):overlapped already visible", FALSE);
4246 ok(GetActiveWindow() == hwnd, "window should be active\n");
4247 ok(GetFocus() == hwnd, "window should have input focus\n");
4248 SetWindowPos(hwnd, 0,0,0,0,0, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE);
4249 ok_sequence(WmSWP_HideOverlappedSeq, "SetWindowPos:SWP_HIDEWINDOW:overlapped", FALSE);
4250 ok(!IsWindowVisible(hwnd), "window should not be visible at this point\n");
4251 ok(GetActiveWindow() == hwnd, "window should still be active\n");
4253 /* test WM_SETREDRAW on a visible top level window */
4254 ShowWindow(hwnd, SW_SHOW);
4256 test_WM_SETREDRAW(hwnd);
4258 trace("testing scroll APIs on a visible top level window %p\n", hwnd);
4259 test_scroll_messages(hwnd);
4261 /* test resizing and moving */
4262 SetWindowPos( hwnd, 0, 0, 0, 300, 300, SWP_NOMOVE|SWP_NOACTIVATE );
4263 ok_sequence(WmSWP_ResizeSeq, "SetWindowPos:Resize", FALSE );
4266 SetWindowPos( hwnd, 0, 200, 200, 0, 0, SWP_NOSIZE|SWP_NOACTIVATE );
4267 ok_sequence(WmSWP_MoveSeq, "SetWindowPos:Move", FALSE );
4270 SetWindowPos( hwnd, 0, 200, 200, 250, 250, SWP_NOZORDER|SWP_NOACTIVATE );
4271 ok_sequence(WmSWP_ResizeNoZOrder, "SetWindowPos:WmSWP_ResizeNoZOrder", FALSE );
4275 /* popups don't get WM_GETMINMAXINFO */
4276 SetWindowLongW( hwnd, GWL_STYLE, WS_VISIBLE|WS_POPUP );
4277 SetWindowPos( hwnd, 0, 0, 0, 0, 0, SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_FRAMECHANGED);
4279 SetWindowPos( hwnd, 0, 0, 0, 200, 200, SWP_NOMOVE|SWP_NOACTIVATE );
4280 ok_sequence(WmSWP_ResizePopupSeq, "SetWindowPos:ResizePopup", FALSE );
4282 DestroyWindow(hwnd);
4283 ok_sequence(WmDestroyOverlappedSeq, "DestroyWindow:overlapped", FALSE);
4285 hparent = CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
4286 100, 100, 200, 200, 0, 0, 0, NULL);
4287 ok (hparent != 0, "Failed to create parent window\n");
4290 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD | WS_MAXIMIZE,
4291 0, 0, 10, 10, hparent, 0, 0, NULL);
4292 ok (hchild != 0, "Failed to create child window\n");
4293 ok_sequence(WmCreateMaximizedChildSeq, "CreateWindow:maximized child", FALSE);
4294 DestroyWindow(hchild);
4297 /* visible child window with a caption */
4298 hchild = CreateWindowExA(0, "TestWindowClass", "Test child",
4299 WS_CHILD | WS_VISIBLE | WS_CAPTION,
4300 0, 0, 10, 10, hparent, 0, 0, NULL);
4301 ok (hchild != 0, "Failed to create child window\n");
4302 ok_sequence(WmCreateVisibleChildSeq, "CreateWindow:visible child", FALSE);
4304 trace("testing scroll APIs on a visible child window %p\n", hchild);
4305 test_scroll_messages(hchild);
4307 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE);
4308 ok_sequence(WmShowChildSeq_4, "SetWindowPos(SWP_SHOWWINDOW):child with a caption", FALSE);
4310 DestroyWindow(hchild);
4313 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
4314 0, 0, 10, 10, hparent, 0, 0, NULL);
4315 ok (hchild != 0, "Failed to create child window\n");
4316 ok_sequence(WmCreateChildSeq, "CreateWindow:child", FALSE);
4318 hchild2 = CreateWindowExA(0, "SimpleWindowClass", "Test child2", WS_CHILD,
4319 100, 100, 50, 50, hparent, 0, 0, NULL);
4320 ok (hchild2 != 0, "Failed to create child2 window\n");
4323 hbutton = CreateWindowExA(0, "TestWindowClass", "Test button", WS_CHILD,
4324 0, 100, 50, 50, hchild, 0, 0, NULL);
4325 ok (hbutton != 0, "Failed to create button window\n");
4327 /* test WM_SETREDRAW on a not visible child window */
4328 test_WM_SETREDRAW(hchild);
4330 ShowWindow(hchild, SW_SHOW);
4331 ok_sequence(WmShowChildSeq, "ShowWindow(SW_SHOW):child", FALSE);
4333 /* check parent messages too */
4334 log_all_parent_messages++;
4335 ShowWindow(hchild, SW_HIDE);
4336 ok_sequence(WmHideChildSeq2, "ShowWindow(SW_HIDE):child", FALSE);
4337 log_all_parent_messages--;
4339 ShowWindow(hchild, SW_SHOW);
4340 ok_sequence(WmShowChildSeq, "ShowWindow(SW_SHOW):child", FALSE);
4342 ShowWindow(hchild, SW_HIDE);
4343 ok_sequence(WmHideChildSeq, "ShowWindow(SW_HIDE):child", FALSE);
4345 ShowWindow(hchild, SW_SHOW);
4346 ok_sequence(WmShowChildSeq, "ShowWindow(SW_SHOW):child", FALSE);
4348 /* test WM_SETREDRAW on a visible child window */
4349 test_WM_SETREDRAW(hchild);
4351 log_all_parent_messages++;
4352 MoveWindow(hchild, 10, 10, 20, 20, TRUE);
4353 ok_sequence(WmResizingChildWithMoveWindowSeq, "MoveWindow:child", FALSE);
4354 log_all_parent_messages--;
4356 ShowWindow(hchild, SW_HIDE);
4358 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE);
4359 ok_sequence(WmShowChildSeq_2, "SetWindowPos:show_child_2", FALSE);
4361 ShowWindow(hchild, SW_HIDE);
4363 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE);
4364 ok_sequence(WmShowChildSeq_3, "SetWindowPos:show_child_3", FALSE);
4366 /* DestroyWindow sequence below expects that a child has focus */
4370 DestroyWindow(hchild);
4371 ok_sequence(WmDestroyChildSeq, "DestroyWindow:child", FALSE);
4372 DestroyWindow(hchild2);
4373 DestroyWindow(hbutton);
4376 hchild = CreateWindowExA(0, "TestWindowClass", "Test Child Popup", WS_CHILD | WS_POPUP,
4377 0, 0, 100, 100, hparent, 0, 0, NULL);
4378 ok (hchild != 0, "Failed to create child popup window\n");
4379 ok_sequence(WmCreateChildPopupSeq, "CreateWindow:child_popup", FALSE);
4380 DestroyWindow(hchild);
4382 /* test what happens to a window which sets WS_VISIBLE in WM_CREATE */
4384 hchild = CreateWindowExA(0, "TestPopupClass", "Test Popup", WS_POPUP,
4385 0, 0, 100, 100, hparent, 0, 0, NULL);
4386 ok (hchild != 0, "Failed to create popup window\n");
4387 ok_sequence(WmCreateInvisiblePopupSeq, "CreateWindow:invisible_popup", FALSE);
4388 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
4389 ok(IsWindowVisible(hchild), "IsWindowVisible() should return TRUE\n");
4391 ShowWindow(hchild, SW_SHOW);
4392 ok_sequence(WmEmptySeq, "ShowWindow:show_visible_popup", FALSE);
4394 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER);
4395 ok_sequence(WmShowVisiblePopupSeq_2, "SetWindowPos:show_visible_popup_2", FALSE);
4397 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE);
4398 ok_sequence(WmShowVisiblePopupSeq_3, "SetWindowPos:show_visible_popup_3", TRUE);
4399 DestroyWindow(hchild);
4401 /* this time add WS_VISIBLE for CreateWindowEx, but this fact actually
4402 * changes nothing in message sequences.
4405 hchild = CreateWindowExA(0, "TestPopupClass", "Test Popup", WS_POPUP | WS_VISIBLE,
4406 0, 0, 100, 100, hparent, 0, 0, NULL);
4407 ok (hchild != 0, "Failed to create popup window\n");
4408 ok_sequence(WmCreateInvisiblePopupSeq, "CreateWindow:invisible_popup", FALSE);
4409 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
4410 ok(IsWindowVisible(hchild), "IsWindowVisible() should return TRUE\n");
4412 ShowWindow(hchild, SW_SHOW);
4413 ok_sequence(WmEmptySeq, "ShowWindow:show_visible_popup", FALSE);
4415 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER);
4416 ok_sequence(WmShowVisiblePopupSeq_2, "SetWindowPos:show_visible_popup_2", FALSE);
4417 DestroyWindow(hchild);
4420 hwnd = CreateWindowExA(WS_EX_DLGMODALFRAME, "TestDialogClass", NULL, WS_VISIBLE|WS_CAPTION|WS_SYSMENU|WS_DLGFRAME,
4421 0, 0, 100, 100, hparent, 0, 0, NULL);
4422 ok(hwnd != 0, "Failed to create custom dialog window\n");
4423 ok_sequence(WmCreateCustomDialogSeq, "CreateCustomDialog", TRUE);
4426 trace("testing scroll APIs on a visible dialog %p\n", hwnd);
4427 test_scroll_messages(hwnd);
4433 SendMessage(hwnd, WM_NULL, 0, 0);
4436 after_end_dialog = 1;
4437 EndDialog( hwnd, 0 );
4438 ok_sequence(WmEndCustomDialogSeq, "EndCustomDialog", FALSE);
4440 DestroyWindow(hwnd);
4441 after_end_dialog = 0;
4444 hwnd = CreateWindowExA(0, "TestDialogClass", NULL, WS_POPUP,
4445 0, 0, 100, 100, 0, 0, GetModuleHandleA(0), NULL);
4446 ok(hwnd != 0, "Failed to create custom dialog window\n");
4448 trace("call ShowWindow(%p, SW_SHOW)\n", hwnd);
4449 ShowWindow(hwnd, SW_SHOW);
4450 ok_sequence(WmShowCustomDialogSeq, "ShowCustomDialog", TRUE);
4451 DestroyWindow(hwnd);
4454 DialogBoxA( 0, "TEST_DIALOG", hparent, TestModalDlgProcA );
4455 ok_sequence(WmModalDialogSeq, "ModalDialog", TRUE);
4457 DestroyWindow(hparent);
4460 /* Message sequence for SetMenu */
4461 ok(!DrawMenuBar(hwnd), "DrawMenuBar should return FALSE for a window without a menu\n");
4462 ok_sequence(WmEmptySeq, "DrawMenuBar for a window without a menu", FALSE);
4464 hmenu = CreateMenu();
4465 ok (hmenu != 0, "Failed to create menu\n");
4466 ok (InsertMenuA(hmenu, -1, MF_BYPOSITION, 0x1000, "foo"), "InsertMenu failed\n");
4467 hwnd = CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW,
4468 100, 100, 200, 200, 0, hmenu, 0, NULL);
4469 ok_sequence(WmCreateOverlappedSeq, "CreateWindow:overlapped", FALSE);
4470 ok (SetMenu(hwnd, 0), "SetMenu\n");
4471 ok_sequence(WmSetMenuNonVisibleSizeChangeSeq, "SetMenu:NonVisibleSizeChange", FALSE);
4472 ok (SetMenu(hwnd, 0), "SetMenu\n");
4473 ok_sequence(WmSetMenuNonVisibleNoSizeChangeSeq, "SetMenu:NonVisibleNoSizeChange", FALSE);
4474 ShowWindow(hwnd, SW_SHOW);
4475 UpdateWindow( hwnd );
4478 ok (SetMenu(hwnd, 0), "SetMenu\n");
4479 ok_sequence(WmSetMenuVisibleNoSizeChangeSeq, "SetMenu:VisibleNoSizeChange", FALSE);
4480 ok (SetMenu(hwnd, hmenu), "SetMenu\n");
4481 ok_sequence(WmSetMenuVisibleSizeChangeSeq, "SetMenu:VisibleSizeChange", FALSE);
4483 UpdateWindow( hwnd );
4486 ok(DrawMenuBar(hwnd), "DrawMenuBar\n");
4488 ok_sequence(WmDrawMenuBarSeq, "DrawMenuBar", FALSE);
4490 DestroyWindow(hwnd);
4493 /* Message sequence for EnableWindow */
4494 hparent = CreateWindowExA(0, "TestWindowClass", "Test parent", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
4495 100, 100, 200, 200, 0, 0, 0, NULL);
4496 ok (hparent != 0, "Failed to create parent window\n");
4497 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD | WS_VISIBLE,
4498 0, 0, 10, 10, hparent, 0, 0, NULL);
4499 ok (hchild != 0, "Failed to create child window\n");
4505 EnableWindow(hparent, FALSE);
4506 ok_sequence(WmEnableWindowSeq_1, "EnableWindow(FALSE)", FALSE);
4508 EnableWindow(hparent, TRUE);
4509 ok_sequence(WmEnableWindowSeq_2, "EnableWindow(TRUE)", FALSE);
4514 test_MsgWaitForMultipleObjects(hparent);
4516 /* the following test causes an exception in user.exe under win9x */
4517 if (!PostMessageW( hparent, WM_USER, 0, 0 ))
4519 DestroyWindow(hparent);
4523 PostMessageW( hparent, WM_USER+1, 0, 0 );
4524 /* PeekMessage(NULL) fails, but still removes the message */
4525 SetLastError(0xdeadbeef);
4526 ok( !PeekMessageW( NULL, 0, 0, 0, PM_REMOVE ), "PeekMessage(NULL) should fail\n" );
4527 ok( GetLastError() == ERROR_NOACCESS || /* Win2k */
4528 GetLastError() == 0xdeadbeef, /* NT4 */
4529 "last error is %d\n", GetLastError() );
4530 ok( PeekMessageW( &msg, 0, 0, 0, PM_REMOVE ), "PeekMessage should succeed\n" );
4531 ok( msg.message == WM_USER+1, "got %x instead of WM_USER+1\n", msg.message );
4533 DestroyWindow(hchild);
4534 DestroyWindow(hparent);
4537 /* Message sequences for WM_SETICON */
4538 trace("testing WM_SETICON\n");
4539 hwnd = CreateWindowExA(0, "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW,
4540 CW_USEDEFAULT, CW_USEDEFAULT, 300, 300, 0,
4542 ShowWindow(hwnd, SW_SHOW);
4546 SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(0, IDI_APPLICATION));
4547 ok_sequence(WmSetIcon_1, "WM_SETICON for shown window with caption", FALSE);
4549 ShowWindow(hwnd, SW_HIDE);
4552 SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(0, IDI_APPLICATION));
4553 ok_sequence(WmSetIcon_2, "WM_SETICON for hidden window with caption", FALSE);
4554 DestroyWindow(hwnd);
4557 hwnd = CreateWindowExA(0, "TestPopupClass", NULL, WS_POPUP,
4558 CW_USEDEFAULT, CW_USEDEFAULT, 300, 300, 0,
4560 ShowWindow(hwnd, SW_SHOW);
4564 SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(0, IDI_APPLICATION));
4565 ok_sequence(WmSetIcon_2, "WM_SETICON for shown window without caption", FALSE);
4567 ShowWindow(hwnd, SW_HIDE);
4570 SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(0, IDI_APPLICATION));
4571 ok_sequence(WmSetIcon_2, "WM_SETICON for hidden window without caption", FALSE);
4574 res = SendMessage(hwnd, 0x3B, 0x8000000b, 0);
4577 todo_wine win_skip( "Message 0x3b not supported\n" );
4580 ok_sequence(WmInitEndSession, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x8000000b", TRUE);
4581 ok(res == 1, "SendMessage(hwnd, 0x3B, 0x8000000b, 0) should have returned 1 instead of %ld\n", res);
4582 res = SendMessage(hwnd, 0x3B, 0x0000000b, 0);
4583 ok_sequence(WmInitEndSession_2, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x0000000b", TRUE);
4584 ok(res == 1, "SendMessage(hwnd, 0x3B, 0x0000000b, 0) should have returned 1 instead of %ld\n", res);
4585 res = SendMessage(hwnd, 0x3B, 0x0000000f, 0);
4586 ok_sequence(WmInitEndSession_2, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x0000000f", TRUE);
4587 ok(res == 1, "SendMessage(hwnd, 0x3B, 0x0000000f, 0) should have returned 1 instead of %ld\n", res);
4590 res = SendMessage(hwnd, 0x3B, 0x80000008, 0);
4591 ok_sequence(WmInitEndSession_3, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x80000008", TRUE);
4592 ok(res == 2, "SendMessage(hwnd, 0x3B, 0x80000008, 0) should have returned 2 instead of %ld\n", res);
4593 res = SendMessage(hwnd, 0x3B, 0x00000008, 0);
4594 ok_sequence(WmInitEndSession_4, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x00000008", TRUE);
4595 ok(res == 2, "SendMessage(hwnd, 0x3B, 0x00000008, 0) should have returned 2 instead of %ld\n", res);
4597 res = SendMessage(hwnd, 0x3B, 0x80000004, 0);
4598 ok_sequence(WmInitEndSession_3, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x80000004", TRUE);
4599 ok(res == 2, "SendMessage(hwnd, 0x3B, 0x80000004, 0) should have returned 2 instead of %ld\n", res);
4601 res = SendMessage(hwnd, 0x3B, 0x80000001, 0);
4602 ok_sequence(WmInitEndSession_5, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x80000001", TRUE);
4603 ok(res == 2, "SendMessage(hwnd, 0x3B, 0x80000001, 0) should have returned 2 instead of %ld\n", res);
4606 DestroyWindow(hwnd);
4610 static void test_setwindowpos(void)
4615 const INT winX = 100;
4616 const INT winY = 100;
4617 const INT sysX = GetSystemMetrics(SM_CXMINTRACK);
4619 hwnd = CreateWindowExA(0, "TestWindowClass", NULL, 0,
4620 0, 0, winX, winY, 0,
4623 GetWindowRect(hwnd, &rc);
4624 expect(sysX, rc.right);
4625 expect(winY, rc.bottom);
4629 res = SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, winX, winY, 0);
4630 ok_sequence(WmZOrder, "Z-Order", TRUE);
4631 ok(res == TRUE, "SetWindowPos expected TRUE, got %ld\n", res);
4633 GetWindowRect(hwnd, &rc);
4634 expect(sysX, rc.right);
4635 expect(winY, rc.bottom);
4636 DestroyWindow(hwnd);
4639 static void invisible_parent_tests(void)
4641 HWND hparent, hchild;
4643 hparent = CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW,
4644 100, 100, 200, 200, 0, 0, 0, NULL);
4645 ok (hparent != 0, "Failed to create parent window\n");
4648 /* test showing child with hidden parent */
4650 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
4651 0, 0, 10, 10, hparent, 0, 0, NULL);
4652 ok (hchild != 0, "Failed to create child window\n");
4653 ok_sequence(WmCreateChildSeq, "CreateWindow:child", FALSE);
4655 ShowWindow( hchild, SW_MINIMIZE );
4656 ok_sequence(WmShowChildInvisibleParentSeq_1, "ShowWindow(SW_MINIMIZE) child with invisible parent", FALSE);
4657 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
4658 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4663 ShowWindow( hchild, SW_MINIMIZE );
4664 ok_sequence(WmShowChildInvisibleParentSeq_1r, "ShowWindow(SW_MINIMIZE) child with invisible parent", FALSE);
4666 DestroyWindow(hchild);
4667 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
4668 0, 0, 10, 10, hparent, 0, 0, NULL);
4671 ShowWindow( hchild, SW_MAXIMIZE );
4672 ok_sequence(WmShowChildInvisibleParentSeq_2, "ShowWindow(SW_MAXIMIZE) child with invisible parent", FALSE);
4673 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
4674 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4679 ShowWindow( hchild, SW_MAXIMIZE );
4680 ok_sequence(WmShowChildInvisibleParentSeq_2r, "ShowWindow(SW_MAXIMIZE) child with invisible parent", FALSE);
4682 DestroyWindow(hchild);
4683 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
4684 0, 0, 10, 10, hparent, 0, 0, NULL);
4687 ShowWindow( hchild, SW_RESTORE );
4688 ok_sequence(WmShowChildInvisibleParentSeq_5, "ShowWindow(SW_RESTORE) child with invisible parent", FALSE);
4689 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
4690 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4692 DestroyWindow(hchild);
4693 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
4694 0, 0, 10, 10, hparent, 0, 0, NULL);
4697 ShowWindow( hchild, SW_SHOWMINIMIZED );
4698 ok_sequence(WmShowChildInvisibleParentSeq_3, "ShowWindow(SW_SHOWMINIMIZED) child with invisible parent", FALSE);
4699 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
4700 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4705 ShowWindow( hchild, SW_SHOWMINIMIZED );
4706 ok_sequence(WmShowChildInvisibleParentSeq_3r, "ShowWindow(SW_SHOWMINIMIZED) child with invisible parent", FALSE);
4708 DestroyWindow(hchild);
4709 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
4710 0, 0, 10, 10, hparent, 0, 0, NULL);
4713 /* same as ShowWindow( hchild, SW_MAXIMIZE ); */
4714 ShowWindow( hchild, SW_SHOWMAXIMIZED );
4715 ok_sequence(WmShowChildInvisibleParentSeq_2, "ShowWindow(SW_SHOWMAXIMIZED) child with invisible parent", FALSE);
4716 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
4717 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4719 DestroyWindow(hchild);
4720 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
4721 0, 0, 10, 10, hparent, 0, 0, NULL);
4724 ShowWindow( hchild, SW_SHOWMINNOACTIVE );
4725 ok_sequence(WmShowChildInvisibleParentSeq_4, "ShowWindow(SW_SHOWMINNOACTIVE) child with invisible parent", FALSE);
4726 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
4727 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4732 ShowWindow( hchild, SW_SHOWMINNOACTIVE );
4733 ok_sequence(WmShowChildInvisibleParentSeq_4r, "ShowWindow(SW_SHOWMINNOACTIVE) child with invisible parent", FALSE);
4735 DestroyWindow(hchild);
4736 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
4737 0, 0, 10, 10, hparent, 0, 0, NULL);
4740 /* FIXME: looks like XP SP2 doesn't know about SW_FORCEMINIMIZE at all */
4741 ShowWindow( hchild, SW_FORCEMINIMIZE );
4742 ok_sequence(WmEmptySeq, "ShowWindow(SW_FORCEMINIMIZE) child with invisible parent", TRUE);
4744 ok(!(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE), "WS_VISIBLE should be not set\n");
4746 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4748 DestroyWindow(hchild);
4749 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
4750 0, 0, 10, 10, hparent, 0, 0, NULL);
4753 ShowWindow( hchild, SW_SHOWNA );
4754 ok_sequence(WmShowChildInvisibleParentSeq_5, "ShowWindow(SW_SHOWNA) child with invisible parent", FALSE);
4755 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
4756 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4761 ShowWindow( hchild, SW_SHOWNA );
4762 ok_sequence(WmShowChildInvisibleParentSeq_5, "ShowWindow(SW_SHOWNA) child with invisible parent", FALSE);
4764 DestroyWindow(hchild);
4765 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
4766 0, 0, 10, 10, hparent, 0, 0, NULL);
4769 ShowWindow( hchild, SW_SHOW );
4770 ok_sequence(WmShowChildInvisibleParentSeq_5, "ShowWindow(SW_SHOW) child with invisible parent", FALSE);
4771 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
4772 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4777 ShowWindow( hchild, SW_SHOW );
4778 ok_sequence(WmEmptySeq, "ShowWindow(SW_SHOW) child with invisible parent", FALSE);
4780 ShowWindow( hchild, SW_HIDE );
4781 ok_sequence(WmHideChildInvisibleParentSeq, "ShowWindow:hide child with invisible parent", FALSE);
4782 ok(!(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE), "WS_VISIBLE should be not set\n");
4783 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4785 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER);
4786 ok_sequence(WmShowChildInvisibleParentSeq_6, "SetWindowPos:show child with invisible parent", FALSE);
4787 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
4788 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4790 SetWindowPos(hchild, 0,0,0,0,0, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER);
4791 ok_sequence(WmHideChildInvisibleParentSeq_2, "SetWindowPos:hide child with invisible parent", FALSE);
4792 ok(!(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE), "WS_VISIBLE should not be set\n");
4793 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4795 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER);
4797 DestroyWindow(hchild);
4798 ok_sequence(WmDestroyInvisibleChildSeq, "DestroyInvisibleChildSeq", FALSE);
4800 DestroyWindow(hparent);
4804 /****************** button message test *************************/
4805 static const struct message WmSetFocusButtonSeq[] =
4807 { HCBT_SETFOCUS, hook },
4808 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
4809 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
4810 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
4811 { WM_SETFOCUS, sent|wparam, 0 },
4812 { WM_CTLCOLORBTN, sent|defwinproc },
4815 static const struct message WmKillFocusButtonSeq[] =
4817 { HCBT_SETFOCUS, hook },
4818 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
4819 { WM_KILLFOCUS, sent|wparam, 0 },
4820 { WM_CTLCOLORBTN, sent|defwinproc },
4821 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
4822 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 1 },
4825 static const struct message WmSetFocusStaticSeq[] =
4827 { HCBT_SETFOCUS, hook },
4828 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
4829 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
4830 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
4831 { WM_SETFOCUS, sent|wparam, 0 },
4832 { WM_CTLCOLORSTATIC, sent|defwinproc },
4835 static const struct message WmKillFocusStaticSeq[] =
4837 { HCBT_SETFOCUS, hook },
4838 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
4839 { WM_KILLFOCUS, sent|wparam, 0 },
4840 { WM_CTLCOLORSTATIC, sent|defwinproc },
4841 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
4842 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 1 },
4845 static const struct message WmLButtonDownSeq[] =
4847 { WM_LBUTTONDOWN, sent|wparam|lparam, 0, 0 },
4848 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
4849 { HCBT_SETFOCUS, hook },
4850 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
4851 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
4852 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
4853 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
4854 { WM_CTLCOLORBTN, sent|defwinproc },
4855 { BM_SETSTATE, sent|wparam|defwinproc, TRUE },
4856 { WM_CTLCOLORBTN, sent|defwinproc },
4857 { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
4860 static const struct message WmLButtonUpSeq[] =
4862 { WM_LBUTTONUP, sent|wparam|lparam, 0, 0 },
4863 { BM_SETSTATE, sent|wparam|defwinproc, FALSE },
4864 { WM_CTLCOLORBTN, sent|defwinproc },
4865 { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
4866 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, 0, 0 },
4867 { WM_CAPTURECHANGED, sent|wparam|defwinproc, 0 },
4870 static const struct message WmSetFontButtonSeq[] =
4872 { WM_SETFONT, sent },
4874 { WM_ERASEBKGND, sent|defwinproc|optional },
4875 { WM_CTLCOLORBTN, sent|defwinproc },
4879 static WNDPROC old_button_proc;
4881 static LRESULT CALLBACK button_hook_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
4883 static long defwndproc_counter = 0;
4887 trace("button: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
4889 /* explicitly ignore WM_GETICON message */
4890 if (message == WM_GETICON) return 0;
4892 msg.message = message;
4893 msg.flags = sent|wparam|lparam;
4894 if (defwndproc_counter) msg.flags |= defwinproc;
4895 msg.wParam = wParam;
4896 msg.lParam = lParam;
4899 if (message == BM_SETSTATE)
4900 ok(GetCapture() == hwnd, "GetCapture() = %p\n", GetCapture());
4902 defwndproc_counter++;
4903 ret = CallWindowProcA(old_button_proc, hwnd, message, wParam, lParam);
4904 defwndproc_counter--;
4909 static void subclass_button(void)
4913 if (!GetClassInfoA(0, "button", &cls)) assert(0);
4915 old_button_proc = cls.lpfnWndProc;
4917 cls.hInstance = GetModuleHandle(0);
4918 cls.lpfnWndProc = button_hook_proc;
4919 cls.lpszClassName = "my_button_class";
4920 UnregisterClass(cls.lpszClassName, cls.hInstance);
4921 if (!RegisterClassA(&cls)) assert(0);
4924 static void test_button_messages(void)
4930 const struct message *setfocus;
4931 const struct message *killfocus;
4933 { BS_PUSHBUTTON, DLGC_BUTTON | DLGC_UNDEFPUSHBUTTON,
4934 WmSetFocusButtonSeq, WmKillFocusButtonSeq },
4935 { BS_DEFPUSHBUTTON, DLGC_BUTTON | DLGC_DEFPUSHBUTTON,
4936 WmSetFocusButtonSeq, WmKillFocusButtonSeq },
4937 { BS_CHECKBOX, DLGC_BUTTON,
4938 WmSetFocusStaticSeq, WmKillFocusStaticSeq },
4939 { BS_AUTOCHECKBOX, DLGC_BUTTON,
4940 WmSetFocusStaticSeq, WmKillFocusStaticSeq },
4941 { BS_RADIOBUTTON, DLGC_BUTTON | DLGC_RADIOBUTTON,
4942 WmSetFocusStaticSeq, WmKillFocusStaticSeq },
4943 { BS_3STATE, DLGC_BUTTON,
4944 WmSetFocusStaticSeq, WmKillFocusStaticSeq },
4945 { BS_AUTO3STATE, DLGC_BUTTON,
4946 WmSetFocusStaticSeq, WmKillFocusStaticSeq },
4947 { BS_GROUPBOX, DLGC_STATIC,
4948 WmSetFocusStaticSeq, WmKillFocusStaticSeq },
4949 { BS_USERBUTTON, DLGC_BUTTON | DLGC_UNDEFPUSHBUTTON,
4950 WmSetFocusButtonSeq, WmKillFocusButtonSeq },
4951 { BS_AUTORADIOBUTTON, DLGC_BUTTON | DLGC_RADIOBUTTON,
4952 WmSetFocusStaticSeq, WmKillFocusStaticSeq },
4953 { BS_OWNERDRAW, DLGC_BUTTON,
4954 WmSetFocusButtonSeq, WmKillFocusButtonSeq }
4963 for (i = 0; i < sizeof(button)/sizeof(button[0]); i++)
4965 hwnd = CreateWindowExA(0, "my_button_class", "test", button[i].style | WS_POPUP,
4966 0, 0, 50, 14, 0, 0, 0, NULL);
4967 ok(hwnd != 0, "Failed to create button window\n");
4969 dlg_code = SendMessageA(hwnd, WM_GETDLGCODE, 0, 0);
4970 ok(dlg_code == button[i].dlg_code, "%u: wrong dlg_code %08x\n", i, dlg_code);
4972 ShowWindow(hwnd, SW_SHOW);
4977 trace("button style %08x\n", button[i].style);
4979 ok_sequence(button[i].setfocus, "SetFocus(hwnd) on a button", FALSE);
4982 ok_sequence(button[i].killfocus, "SetFocus(0) on a button", FALSE);
4984 DestroyWindow(hwnd);
4987 hwnd = CreateWindowExA(0, "my_button_class", "test", BS_PUSHBUTTON | WS_POPUP | WS_VISIBLE,
4988 0, 0, 50, 14, 0, 0, 0, NULL);
4989 ok(hwnd != 0, "Failed to create button window\n");
4995 SendMessageA(hwnd, WM_LBUTTONDOWN, 0, 0);
4996 ok_sequence(WmLButtonDownSeq, "WM_LBUTTONDOWN on a button", FALSE);
4998 SendMessageA(hwnd, WM_LBUTTONUP, 0, 0);
4999 ok_sequence(WmLButtonUpSeq, "WM_LBUTTONUP on a button", FALSE);
5002 zfont = (HFONT)GetStockObject(SYSTEM_FONT);
5003 SendMessageA(hwnd, WM_SETFONT, (WPARAM)zfont, TRUE);
5005 ok_sequence(WmSetFontButtonSeq, "WM_SETFONT on a button", FALSE);
5007 DestroyWindow(hwnd);
5010 /****************** static message test *************************/
5011 static const struct message WmSetFontStaticSeq[] =
5013 { WM_SETFONT, sent },
5014 { WM_PAINT, sent|defwinproc },
5015 { WM_ERASEBKGND, sent|defwinproc|optional },
5016 { WM_CTLCOLORSTATIC, sent|defwinproc },
5020 static WNDPROC old_static_proc;
5022 static LRESULT CALLBACK static_hook_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
5024 static long defwndproc_counter = 0;
5028 trace("static: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
5030 /* explicitly ignore WM_GETICON message */
5031 if (message == WM_GETICON) return 0;
5033 msg.message = message;
5034 msg.flags = sent|wparam|lparam;
5035 if (defwndproc_counter) msg.flags |= defwinproc;
5036 msg.wParam = wParam;
5037 msg.lParam = lParam;
5040 defwndproc_counter++;
5041 ret = CallWindowProcA(old_static_proc, hwnd, message, wParam, lParam);
5042 defwndproc_counter--;
5047 static void subclass_static(void)
5051 if (!GetClassInfoA(0, "static", &cls)) assert(0);
5053 old_static_proc = cls.lpfnWndProc;
5055 cls.hInstance = GetModuleHandle(0);
5056 cls.lpfnWndProc = static_hook_proc;
5057 cls.lpszClassName = "my_static_class";
5058 UnregisterClass(cls.lpszClassName, cls.hInstance);
5059 if (!RegisterClassA(&cls)) assert(0);
5062 static void test_static_messages(void)
5064 /* FIXME: make as comprehensive as the button message test */
5069 const struct message *setfont;
5071 { SS_LEFT, DLGC_STATIC,
5072 WmSetFontStaticSeq }
5080 for (i = 0; i < sizeof(static_ctrl)/sizeof(static_ctrl[0]); i++)
5082 hwnd = CreateWindowExA(0, "my_static_class", "test", static_ctrl[i].style | WS_POPUP,
5083 0, 0, 50, 14, 0, 0, 0, NULL);
5084 ok(hwnd != 0, "Failed to create static window\n");
5086 dlg_code = SendMessageA(hwnd, WM_GETDLGCODE, 0, 0);
5087 ok(dlg_code == static_ctrl[i].dlg_code, "%u: wrong dlg_code %08x\n", i, dlg_code);
5089 ShowWindow(hwnd, SW_SHOW);
5094 trace("static style %08x\n", static_ctrl[i].style);
5095 SendMessage(hwnd, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), TRUE);
5096 ok_sequence(static_ctrl[i].setfont, "WM_SETFONT on a static", FALSE);
5098 DestroyWindow(hwnd);
5102 /****************** ComboBox message test *************************/
5103 #define ID_COMBOBOX 0x000f
5105 static const struct message WmKeyDownComboSeq[] =
5107 { WM_KEYDOWN, sent|wparam|lparam, VK_DOWN, 0 },
5108 { WM_COMMAND, sent|wparam|defwinproc, MAKEWPARAM(1000, LBN_SELCHANGE) },
5109 { WM_COMMAND, sent|wparam|parent, MAKEWPARAM(ID_COMBOBOX, CBN_SELENDOK) },
5110 { WM_COMMAND, sent|wparam|parent, MAKEWPARAM(ID_COMBOBOX, CBN_SELCHANGE) },
5111 { WM_CTLCOLOREDIT, sent|parent },
5112 { WM_KEYUP, sent|wparam|lparam, VK_DOWN, 0 },
5116 static WNDPROC old_combobox_proc;
5118 static LRESULT CALLBACK combobox_hook_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
5120 static long defwndproc_counter = 0;
5124 /* do not log painting messages */
5125 if (message != WM_PAINT &&
5126 message != WM_NCPAINT &&
5127 message != WM_SYNCPAINT &&
5128 message != WM_ERASEBKGND &&
5129 message != WM_NCHITTEST &&
5130 message != WM_GETTEXT &&
5131 message != WM_GETICON &&
5132 message != WM_DEVICECHANGE)
5134 trace("combo: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
5136 msg.message = message;
5137 msg.flags = sent|wparam|lparam;
5138 if (defwndproc_counter) msg.flags |= defwinproc;
5139 msg.wParam = wParam;
5140 msg.lParam = lParam;
5144 defwndproc_counter++;
5145 ret = CallWindowProcA(old_combobox_proc, hwnd, message, wParam, lParam);
5146 defwndproc_counter--;
5151 static void subclass_combobox(void)
5155 if (!GetClassInfoA(0, "ComboBox", &cls)) assert(0);
5157 old_combobox_proc = cls.lpfnWndProc;
5159 cls.hInstance = GetModuleHandle(0);
5160 cls.lpfnWndProc = combobox_hook_proc;
5161 cls.lpszClassName = "my_combobox_class";
5162 UnregisterClass(cls.lpszClassName, cls.hInstance);
5163 if (!RegisterClassA(&cls)) assert(0);
5166 static void test_combobox_messages(void)
5171 subclass_combobox();
5173 parent = CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
5174 100, 100, 200, 200, 0, 0, 0, NULL);
5175 ok(parent != 0, "Failed to create parent window\n");
5178 combo = CreateWindowEx(0, "my_combobox_class", "test", WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST | CBS_HASSTRINGS,
5179 0, 0, 100, 150, parent, (HMENU)ID_COMBOBOX, 0, NULL);
5180 ok(combo != 0, "Failed to create combobox window\n");
5182 UpdateWindow(combo);
5184 ret = SendMessage(combo, WM_GETDLGCODE, 0, 0);
5185 ok(ret == (DLGC_WANTCHARS | DLGC_WANTARROWS), "wrong dlg_code %08lx\n", ret);
5187 ret = SendMessage(combo, CB_ADDSTRING, 0, (LPARAM)"item 0");
5188 ok(ret == 0, "expected 0, got %ld\n", ret);
5189 ret = SendMessage(combo, CB_ADDSTRING, 0, (LPARAM)"item 1");
5190 ok(ret == 1, "expected 1, got %ld\n", ret);
5191 ret = SendMessage(combo, CB_ADDSTRING, 0, (LPARAM)"item 2");
5192 ok(ret == 2, "expected 2, got %ld\n", ret);
5194 SendMessage(combo, CB_SETCURSEL, 0, 0);
5198 log_all_parent_messages++;
5199 SendMessage(combo, WM_KEYDOWN, VK_DOWN, 0);
5200 SendMessage(combo, WM_KEYUP, VK_DOWN, 0);
5201 log_all_parent_messages--;
5202 ok_sequence(WmKeyDownComboSeq, "WM_KEYDOWN/VK_DOWN on a ComboBox", FALSE);
5204 DestroyWindow(combo);
5205 DestroyWindow(parent);
5208 /****************** WM_IME_KEYDOWN message test *******************/
5210 static const struct message WmImeKeydownMsgSeq_0[] =
5212 { WM_IME_KEYDOWN, wparam, VK_RETURN },
5213 { WM_CHAR, wparam, 'A' },
5217 static const struct message WmImeKeydownMsgSeq_1[] =
5219 { WM_KEYDOWN, optional|wparam, VK_RETURN },
5220 { WM_CHAR, optional|wparam, VK_RETURN },
5224 static LRESULT WINAPI wmime_keydown_procA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
5228 trace("wmime_keydown_procA: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
5230 msg.message = message;
5231 msg.flags = wparam|lparam;
5232 msg.wParam = wParam;
5233 msg.lParam = lParam;
5236 return DefWindowProcA(hwnd, message, wParam, lParam);
5239 static void register_wmime_keydown_class(void)
5243 ZeroMemory(&cls, sizeof(WNDCLASSA));
5244 cls.lpfnWndProc = wmime_keydown_procA;
5245 cls.hInstance = GetModuleHandleA(0);
5246 cls.lpszClassName = "wmime_keydown_class";
5247 if (!RegisterClassA(&cls)) assert(0);
5250 void test_wmime_keydown_message(void)
5255 trace("Message sequences by WM_IME_KEYDOWN\n");
5257 register_wmime_keydown_class();
5258 hwnd = CreateWindowExA(0, "wmime_keydown_class", NULL, WS_OVERLAPPEDWINDOW,
5259 CW_USEDEFAULT, CW_USEDEFAULT, 300, 300, 0,
5264 SendMessage(hwnd, WM_IME_KEYDOWN, VK_RETURN, 0x1c0001);
5265 SendMessage(hwnd, WM_CHAR, 'A', 1);
5266 ok_sequence(WmImeKeydownMsgSeq_0, "WM_IME_KEYDOWN 0", FALSE);
5268 while ( PeekMessage(&msg, 0, 0, 0, PM_REMOVE) )
5270 TranslateMessage(&msg);
5271 DispatchMessage(&msg);
5273 ok_sequence(WmImeKeydownMsgSeq_1, "WM_IME_KEYDOWN 1", FALSE);
5275 DestroyWindow(hwnd);
5278 /************* painting message test ********************/
5280 void dump_region(HRGN hrgn)
5283 RGNDATA *data = NULL;
5288 printf( "null region\n" );
5291 if (!(size = GetRegionData( hrgn, 0, NULL ))) return;
5292 if (!(data = HeapAlloc( GetProcessHeap(), 0, size ))) return;
5293 GetRegionData( hrgn, size, data );
5294 printf("%d rects:", data->rdh.nCount );
5295 for (i = 0, rect = (RECT *)data->Buffer; i < data->rdh.nCount; i++, rect++)
5296 printf( " (%d,%d)-(%d,%d)", rect->left, rect->top, rect->right, rect->bottom );
5298 HeapFree( GetProcessHeap(), 0, data );
5301 static void check_update_rgn( HWND hwnd, HRGN hrgn )
5305 HRGN tmp = CreateRectRgn( 0, 0, 0, 0 );
5306 HRGN update = CreateRectRgn( 0, 0, 0, 0 );
5308 ret = GetUpdateRgn( hwnd, update, FALSE );
5309 ok( ret != ERROR, "GetUpdateRgn failed\n" );
5310 if (ret == NULLREGION)
5312 ok( !hrgn, "Update region shouldn't be empty\n" );
5316 if (CombineRgn( tmp, hrgn, update, RGN_XOR ) != NULLREGION)
5318 ok( 0, "Regions are different\n" );
5319 if (winetest_debug > 0)
5321 printf( "Update region: " );
5322 dump_region( update );
5323 printf( "Wanted region: " );
5324 dump_region( hrgn );
5328 GetRgnBox( update, &r1 );
5329 GetUpdateRect( hwnd, &r2, FALSE );
5330 ok( r1.left == r2.left && r1.top == r2.top && r1.right == r2.right && r1.bottom == r2.bottom,
5331 "Rectangles are different: %d,%d-%d,%d / %d,%d-%d,%d\n",
5332 r1.left, r1.top, r1.right, r1.bottom, r2.left, r2.top, r2.right, r2.bottom );
5334 DeleteObject( tmp );
5335 DeleteObject( update );
5338 static const struct message WmInvalidateRgn[] = {
5339 { WM_NCPAINT, sent },
5340 { WM_GETTEXT, sent|defwinproc|optional },
5344 static const struct message WmGetUpdateRect[] = {
5345 { WM_NCPAINT, sent },
5346 { WM_GETTEXT, sent|defwinproc|optional },
5351 static const struct message WmInvalidateFull[] = {
5352 { WM_NCPAINT, sent|wparam, 1 },
5353 { WM_GETTEXT, sent|defwinproc|optional },
5357 static const struct message WmInvalidateErase[] = {
5358 { WM_NCPAINT, sent|wparam, 1 },
5359 { WM_GETTEXT, sent|defwinproc|optional },
5360 { WM_ERASEBKGND, sent },
5364 static const struct message WmInvalidatePaint[] = {
5366 { WM_NCPAINT, sent|wparam|beginpaint, 1 },
5367 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
5371 static const struct message WmInvalidateErasePaint[] = {
5373 { WM_NCPAINT, sent|wparam|beginpaint, 1 },
5374 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
5375 { WM_ERASEBKGND, sent|beginpaint },
5379 static const struct message WmInvalidateErasePaint2[] = {
5381 { WM_NCPAINT, sent|beginpaint },
5382 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
5383 { WM_ERASEBKGND, sent|beginpaint },
5387 static const struct message WmErase[] = {
5388 { WM_ERASEBKGND, sent },
5392 static const struct message WmPaint[] = {
5397 static const struct message WmParentOnlyPaint[] = {
5398 { WM_PAINT, sent|parent },
5402 static const struct message WmInvalidateParent[] = {
5403 { WM_NCPAINT, sent|parent },
5404 { WM_GETTEXT, sent|defwinproc|parent|optional },
5405 { WM_ERASEBKGND, sent|parent },
5409 static const struct message WmInvalidateParentChild[] = {
5410 { WM_NCPAINT, sent|parent },
5411 { WM_GETTEXT, sent|defwinproc|parent|optional },
5412 { WM_ERASEBKGND, sent|parent },
5413 { WM_NCPAINT, sent },
5414 { WM_GETTEXT, sent|defwinproc|optional },
5415 { WM_ERASEBKGND, sent },
5419 static const struct message WmInvalidateParentChild2[] = {
5420 { WM_ERASEBKGND, sent|parent },
5421 { WM_NCPAINT, sent },
5422 { WM_GETTEXT, sent|defwinproc|optional },
5423 { WM_ERASEBKGND, sent },
5427 static const struct message WmParentPaint[] = {
5428 { WM_PAINT, sent|parent },
5433 static const struct message WmParentPaintNc[] = {
5434 { WM_PAINT, sent|parent },
5436 { WM_NCPAINT, sent|beginpaint },
5437 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
5438 { WM_ERASEBKGND, sent|beginpaint },
5442 static const struct message WmChildPaintNc[] = {
5444 { WM_NCPAINT, sent|beginpaint },
5445 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
5446 { WM_ERASEBKGND, sent|beginpaint },
5450 static const struct message WmParentErasePaint[] = {
5451 { WM_PAINT, sent|parent },
5452 { WM_NCPAINT, sent|parent|beginpaint },
5453 { WM_GETTEXT, sent|parent|beginpaint|defwinproc|optional },
5454 { WM_ERASEBKGND, sent|parent|beginpaint },
5456 { WM_NCPAINT, sent|beginpaint },
5457 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
5458 { WM_ERASEBKGND, sent|beginpaint },
5462 static const struct message WmParentOnlyNcPaint[] = {
5463 { WM_PAINT, sent|parent },
5464 { WM_NCPAINT, sent|parent|beginpaint },
5465 { WM_GETTEXT, sent|parent|beginpaint|defwinproc|optional },
5469 static const struct message WmSetParentStyle[] = {
5470 { WM_STYLECHANGING, sent|parent },
5471 { WM_STYLECHANGED, sent|parent },
5475 static void test_paint_messages(void)
5481 HWND hparent, hchild;
5482 HRGN hrgn = CreateRectRgn( 0, 0, 0, 0 );
5483 HRGN hrgn2 = CreateRectRgn( 0, 0, 0, 0 );
5484 HWND hwnd = CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW,
5485 100, 100, 200, 200, 0, 0, 0, NULL);
5486 ok (hwnd != 0, "Failed to create overlapped window\n");
5488 ShowWindow( hwnd, SW_SHOW );
5489 UpdateWindow( hwnd );
5493 check_update_rgn( hwnd, 0 );
5494 SetRectRgn( hrgn, 10, 10, 20, 20 );
5495 ret = RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE );
5496 ok(ret, "RedrawWindow returned %d instead of TRUE\n", ret);
5497 check_update_rgn( hwnd, hrgn );
5498 SetRectRgn( hrgn2, 20, 20, 30, 30 );
5499 ret = RedrawWindow( hwnd, NULL, hrgn2, RDW_INVALIDATE );
5500 ok(ret, "RedrawWindow returned %d instead of TRUE\n", ret);
5501 CombineRgn( hrgn, hrgn, hrgn2, RGN_OR );
5502 check_update_rgn( hwnd, hrgn );
5503 /* validate everything */
5504 ret = RedrawWindow( hwnd, NULL, NULL, RDW_VALIDATE );
5505 ok(ret, "RedrawWindow returned %d instead of TRUE\n", ret);
5506 check_update_rgn( hwnd, 0 );
5508 /* test empty region */
5509 SetRectRgn( hrgn, 10, 10, 10, 15 );
5510 ret = RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE );
5511 ok(ret, "RedrawWindow returned %d instead of TRUE\n", ret);
5512 check_update_rgn( hwnd, 0 );
5513 /* test empty rect */
5514 SetRect( &rect, 10, 10, 10, 15 );
5515 ret = RedrawWindow( hwnd, &rect, NULL, RDW_INVALIDATE );
5516 ok(ret, "RedrawWindow returned %d instead of TRUE\n", ret);
5517 check_update_rgn( hwnd, 0 );
5519 /* flush pending messages */
5523 GetClientRect( hwnd, &rect );
5524 SetRectRgn( hrgn, 0, 0, rect.right - rect.left, rect.bottom - rect.top );
5525 /* MSDN: if hwnd parameter is NULL, InvalidateRect invalidates and redraws
5526 * all windows and sends WM_ERASEBKGND and WM_NCPAINT.
5528 trace("testing InvalidateRect(0, NULL, FALSE)\n");
5529 SetRectEmpty( &rect );
5530 ok(InvalidateRect(0, &rect, FALSE), "InvalidateRect(0, &rc, FALSE) should fail\n");
5531 check_update_rgn( hwnd, hrgn );
5532 ok_sequence( WmInvalidateErase, "InvalidateErase", FALSE );
5534 ok_sequence( WmPaint, "Paint", FALSE );
5535 RedrawWindow( hwnd, NULL, NULL, RDW_VALIDATE );
5536 check_update_rgn( hwnd, 0 );
5538 /* MSDN: if hwnd parameter is NULL, ValidateRect invalidates and redraws
5539 * all windows and sends WM_ERASEBKGND and WM_NCPAINT.
5541 trace("testing ValidateRect(0, NULL)\n");
5542 SetRectEmpty( &rect );
5543 ok(ValidateRect(0, &rect), "ValidateRect(0, &rc) should not fail\n");
5544 check_update_rgn( hwnd, hrgn );
5545 ok_sequence( WmInvalidateErase, "InvalidateErase", FALSE );
5547 ok_sequence( WmPaint, "Paint", FALSE );
5548 RedrawWindow( hwnd, NULL, NULL, RDW_VALIDATE );
5549 check_update_rgn( hwnd, 0 );
5551 trace("testing InvalidateRgn(0, NULL, FALSE)\n");
5552 SetLastError(0xdeadbeef);
5553 ok(!InvalidateRgn(0, NULL, FALSE), "InvalidateRgn(0, NULL, FALSE) should fail\n");
5554 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE || GetLastError() == 0xdeadbeef,
5555 "wrong error code %d\n", GetLastError());
5556 check_update_rgn( hwnd, 0 );
5558 ok_sequence( WmEmptySeq, "WmEmptySeq", FALSE );
5560 trace("testing ValidateRgn(0, NULL)\n");
5561 SetLastError(0xdeadbeef);
5562 ok(!ValidateRgn(0, NULL), "ValidateRgn(0, NULL) should fail\n");
5563 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "wrong error code %d\n", GetLastError());
5564 check_update_rgn( hwnd, 0 );
5566 ok_sequence( WmEmptySeq, "WmEmptySeq", FALSE );
5568 /* now with frame */
5569 SetRectRgn( hrgn, -5, -5, 20, 20 );
5571 /* flush pending messages */
5574 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME );
5575 ok_sequence( WmEmptySeq, "EmptySeq", FALSE );
5577 SetRectRgn( hrgn, 0, 0, 20, 20 ); /* GetUpdateRgn clips to client area */
5578 check_update_rgn( hwnd, hrgn );
5581 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME | RDW_ERASENOW );
5582 ok_sequence( WmInvalidateRgn, "InvalidateRgn", FALSE );
5585 RedrawWindow( hwnd, NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_ERASENOW );
5586 ok_sequence( WmInvalidateFull, "InvalidateFull", FALSE );
5588 GetClientRect( hwnd, &rect );
5589 SetRectRgn( hrgn, rect.left, rect.top, rect.right, rect.bottom );
5590 check_update_rgn( hwnd, hrgn );
5593 RedrawWindow( hwnd, NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_ERASE | RDW_ERASENOW );
5594 ok_sequence( WmInvalidateErase, "InvalidateErase", FALSE );
5597 RedrawWindow( hwnd, NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_ERASENOW | RDW_UPDATENOW );
5598 ok_sequence( WmInvalidatePaint, "InvalidatePaint", FALSE );
5599 check_update_rgn( hwnd, 0 );
5602 RedrawWindow( hwnd, NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_ERASE | RDW_UPDATENOW );
5603 ok_sequence( WmInvalidateErasePaint, "InvalidateErasePaint", FALSE );
5604 check_update_rgn( hwnd, 0 );
5607 SetRectRgn( hrgn, 0, 0, 100, 100 );
5608 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE );
5609 SetRectRgn( hrgn, 0, 0, 50, 100 );
5610 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE );
5611 SetRectRgn( hrgn, 50, 0, 100, 100 );
5612 check_update_rgn( hwnd, hrgn );
5613 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_ERASENOW );
5614 ok_sequence( WmEmptySeq, "EmptySeq", FALSE ); /* must not generate messages, everything is valid */
5615 check_update_rgn( hwnd, 0 );
5618 SetRectRgn( hrgn, 0, 0, 100, 100 );
5619 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_ERASE );
5620 SetRectRgn( hrgn, 0, 0, 100, 50 );
5621 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_ERASENOW );
5622 ok_sequence( WmErase, "Erase", FALSE );
5623 SetRectRgn( hrgn, 0, 50, 100, 100 );
5624 check_update_rgn( hwnd, hrgn );
5627 SetRectRgn( hrgn, 0, 0, 100, 100 );
5628 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_ERASE );
5629 SetRectRgn( hrgn, 0, 0, 50, 50 );
5630 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_NOERASE | RDW_UPDATENOW );
5631 ok_sequence( WmPaint, "Paint", FALSE );
5634 SetRectRgn( hrgn, -4, -4, -2, -2 );
5635 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME );
5636 SetRectRgn( hrgn, -200, -200, -198, -198 );
5637 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_NOFRAME | RDW_ERASENOW );
5638 ok_sequence( WmEmptySeq, "EmptySeq", FALSE );
5641 SetRectRgn( hrgn, -4, -4, -2, -2 );
5642 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME );
5643 SetRectRgn( hrgn, -4, -4, -3, -3 );
5644 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_NOFRAME );
5645 SetRectRgn( hrgn, 0, 0, 1, 1 );
5646 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_UPDATENOW );
5647 ok_sequence( WmPaint, "Paint", FALSE );
5650 SetRectRgn( hrgn, -4, -4, -1, -1 );
5651 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME );
5652 RedrawWindow( hwnd, NULL, 0, RDW_ERASENOW );
5653 /* make sure no WM_PAINT was generated */
5655 ok_sequence( WmInvalidateRgn, "InvalidateRgn", FALSE );
5658 SetRectRgn( hrgn, -4, -4, -1, -1 );
5659 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME );
5660 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE ))
5662 if (msg.hwnd == hwnd && msg.message == WM_PAINT)
5664 /* GetUpdateRgn must return empty region since only nonclient area is invalidated */
5665 INT ret = GetUpdateRgn( hwnd, hrgn, FALSE );
5666 ok( ret == NULLREGION, "Invalid GetUpdateRgn result %d\n", ret );
5667 ret = GetUpdateRect( hwnd, &rect, FALSE );
5668 ok( ret, "Invalid GetUpdateRect result %d\n", ret );
5669 /* this will send WM_NCPAINT and validate the non client area */
5670 ret = GetUpdateRect( hwnd, &rect, TRUE );
5671 ok( !ret, "Invalid GetUpdateRect result %d\n", ret );
5673 DispatchMessage( &msg );
5675 ok_sequence( WmGetUpdateRect, "GetUpdateRect", FALSE );
5677 DestroyWindow( hwnd );
5679 /* now test with a child window */
5681 hparent = CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW,
5682 100, 100, 200, 200, 0, 0, 0, NULL);
5683 ok (hparent != 0, "Failed to create parent window\n");
5685 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD | WS_VISIBLE | WS_BORDER,
5686 10, 10, 100, 100, hparent, 0, 0, NULL);
5687 ok (hchild != 0, "Failed to create child window\n");
5689 ShowWindow( hparent, SW_SHOW );
5690 UpdateWindow( hparent );
5691 UpdateWindow( hchild );
5694 log_all_parent_messages++;
5696 SetRect( &rect, 0, 0, 50, 50 );
5697 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
5698 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW | RDW_ALLCHILDREN );
5699 ok_sequence( WmInvalidateParentChild, "InvalidateParentChild", FALSE );
5701 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
5703 MapWindowPoints( hchild, hparent, &pt, 1 );
5704 SetRectRgn( hrgn, 0, 0, 50 - pt.x, 50 - pt.y );
5705 check_update_rgn( hchild, hrgn );
5706 SetRectRgn( hrgn, 0, 0, 50, 50 );
5707 check_update_rgn( hparent, hrgn );
5708 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW );
5709 ok_sequence( WmInvalidateParent, "InvalidateParent", FALSE );
5710 RedrawWindow( hchild, NULL, 0, RDW_ERASENOW );
5711 ok_sequence( WmEmptySeq, "EraseNow child", FALSE );
5714 ok_sequence( WmParentPaintNc, "WmParentPaintNc", FALSE );
5716 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_ALLCHILDREN );
5717 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW );
5718 ok_sequence( WmInvalidateParent, "InvalidateParent2", FALSE );
5719 RedrawWindow( hchild, NULL, 0, RDW_ERASENOW );
5720 ok_sequence( WmEmptySeq, "EraseNow child", FALSE );
5722 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE );
5723 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW | RDW_ALLCHILDREN );
5724 ok_sequence( WmInvalidateParentChild2, "InvalidateParentChild2", FALSE );
5726 SetWindowLong( hparent, GWL_STYLE, GetWindowLong(hparent,GWL_STYLE) | WS_CLIPCHILDREN );
5728 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_ALLCHILDREN );
5729 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW );
5730 ok_sequence( WmInvalidateParentChild, "InvalidateParentChild3", FALSE );
5732 /* flush all paint messages */
5736 /* RDW_UPDATENOW on child with WS_CLIPCHILDREN doesn't change corresponding parent area */
5737 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_ALLCHILDREN );
5738 SetRectRgn( hrgn, 0, 0, 50, 50 );
5739 check_update_rgn( hparent, hrgn );
5740 RedrawWindow( hchild, NULL, 0, RDW_UPDATENOW );
5741 ok_sequence( WmInvalidateErasePaint2, "WmInvalidateErasePaint2", FALSE );
5742 SetRectRgn( hrgn, 0, 0, 50, 50 );
5743 check_update_rgn( hparent, hrgn );
5745 /* flush all paint messages */
5747 SetWindowLong( hparent, GWL_STYLE, GetWindowLong(hparent,GWL_STYLE) & ~WS_CLIPCHILDREN );
5750 /* RDW_UPDATENOW on child without WS_CLIPCHILDREN will validate corresponding parent area */
5751 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
5752 SetRectRgn( hrgn, 0, 0, 50, 50 );
5753 check_update_rgn( hparent, hrgn );
5754 RedrawWindow( hchild, NULL, 0, RDW_UPDATENOW );
5755 ok_sequence( WmInvalidateErasePaint2, "WmInvalidateErasePaint2", FALSE );
5756 SetRectRgn( hrgn2, 10, 10, 50, 50 );
5757 CombineRgn( hrgn, hrgn, hrgn2, RGN_DIFF );
5758 check_update_rgn( hparent, hrgn );
5759 /* flush all paint messages */
5763 /* same as above but parent gets completely validated */
5764 SetRect( &rect, 20, 20, 30, 30 );
5765 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
5766 SetRectRgn( hrgn, 20, 20, 30, 30 );
5767 check_update_rgn( hparent, hrgn );
5768 RedrawWindow( hchild, NULL, 0, RDW_UPDATENOW );
5769 ok_sequence( WmInvalidateErasePaint2, "WmInvalidateErasePaint2", FALSE );
5770 check_update_rgn( hparent, 0 ); /* no update region */
5772 ok_sequence( WmEmptySeq, "WmEmpty", FALSE ); /* and no paint messages */
5774 /* make sure RDW_VALIDATE on child doesn't have the same effect */
5776 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
5777 SetRectRgn( hrgn, 20, 20, 30, 30 );
5778 check_update_rgn( hparent, hrgn );
5779 RedrawWindow( hchild, NULL, 0, RDW_VALIDATE | RDW_NOERASE );
5780 SetRectRgn( hrgn, 20, 20, 30, 30 );
5781 check_update_rgn( hparent, hrgn );
5783 /* same as above but normal WM_PAINT doesn't validate parent */
5785 SetRect( &rect, 20, 20, 30, 30 );
5786 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
5787 SetRectRgn( hrgn, 20, 20, 30, 30 );
5788 check_update_rgn( hparent, hrgn );
5789 /* no WM_PAINT in child while parent still pending */
5790 while (PeekMessage( &msg, hchild, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
5791 ok_sequence( WmEmptySeq, "No WM_PAINT", FALSE );
5792 while (PeekMessage( &msg, hparent, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
5793 ok_sequence( WmParentErasePaint, "WmParentErasePaint", FALSE );
5796 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
5797 /* no WM_PAINT in child while parent still pending */
5798 while (PeekMessage( &msg, hchild, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
5799 ok_sequence( WmEmptySeq, "No WM_PAINT", FALSE );
5800 RedrawWindow( hparent, &rect, 0, RDW_VALIDATE | RDW_NOERASE | RDW_NOCHILDREN );
5801 /* now that parent is valid child should get WM_PAINT */
5802 while (PeekMessage( &msg, hchild, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
5803 ok_sequence( WmInvalidateErasePaint2, "WmInvalidateErasePaint2", FALSE );
5804 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
5805 ok_sequence( WmEmptySeq, "No other message", FALSE );
5807 /* same thing with WS_CLIPCHILDREN in parent */
5809 SetWindowLong( hparent, GWL_STYLE, GetWindowLong(hparent,GWL_STYLE) | WS_CLIPCHILDREN );
5810 ok_sequence( WmSetParentStyle, "WmSetParentStyle", FALSE );
5811 /* changing style invalidates non client area, but we need to invalidate something else to see it */
5812 RedrawWindow( hparent, &rect, 0, RDW_UPDATENOW );
5813 ok_sequence( WmEmptySeq, "No message", FALSE );
5814 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_UPDATENOW );
5815 ok_sequence( WmParentOnlyNcPaint, "WmParentOnlyNcPaint", FALSE );
5818 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_ALLCHILDREN );
5819 SetRectRgn( hrgn, 20, 20, 30, 30 );
5820 check_update_rgn( hparent, hrgn );
5821 /* no WM_PAINT in child while parent still pending */
5822 while (PeekMessage( &msg, hchild, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
5823 ok_sequence( WmEmptySeq, "No WM_PAINT", FALSE );
5824 /* WM_PAINT in parent first */
5825 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
5826 ok_sequence( WmParentPaintNc, "WmParentPaintNc2", FALSE );
5828 /* no RDW_ERASE in parent still causes RDW_ERASE and RDW_FRAME in child */
5830 SetRect( &rect, 0, 0, 30, 30 );
5831 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ALLCHILDREN );
5832 SetRectRgn( hrgn, 0, 0, 30, 30 );
5833 check_update_rgn( hparent, hrgn );
5835 ok_sequence( WmParentPaintNc, "WmParentPaintNc3", FALSE );
5837 /* validate doesn't cause RDW_NOERASE or RDW_NOFRAME in child */
5839 SetRect( &rect, -10, 0, 30, 30 );
5840 RedrawWindow( hchild, &rect, 0, RDW_INVALIDATE | RDW_FRAME | RDW_ERASE );
5841 SetRect( &rect, 0, 0, 20, 20 );
5842 RedrawWindow( hparent, &rect, 0, RDW_VALIDATE | RDW_ALLCHILDREN );
5843 RedrawWindow( hparent, NULL, 0, RDW_UPDATENOW );
5844 ok_sequence( WmChildPaintNc, "WmChildPaintNc", FALSE );
5846 /* validate doesn't cause RDW_NOERASE or RDW_NOFRAME in child */
5848 SetRect( &rect, -10, 0, 30, 30 );
5849 RedrawWindow( hchild, &rect, 0, RDW_INVALIDATE | RDW_FRAME | RDW_ERASE );
5850 SetRect( &rect, 0, 0, 100, 100 );
5851 RedrawWindow( hparent, &rect, 0, RDW_VALIDATE | RDW_ALLCHILDREN );
5852 RedrawWindow( hparent, NULL, 0, RDW_UPDATENOW );
5853 ok_sequence( WmEmptySeq, "WmChildPaintNc2", FALSE );
5854 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW );
5855 ok_sequence( WmEmptySeq, "WmChildPaintNc3", FALSE );
5857 /* test RDW_INTERNALPAINT behavior */
5860 RedrawWindow( hparent, NULL, 0, RDW_INTERNALPAINT | RDW_NOCHILDREN );
5862 ok_sequence( WmParentOnlyPaint, "WmParentOnlyPaint", FALSE );
5864 RedrawWindow( hparent, NULL, 0, RDW_INTERNALPAINT | RDW_ALLCHILDREN );
5866 ok_sequence( WmParentPaint, "WmParentPaint", FALSE );
5868 RedrawWindow( hparent, NULL, 0, RDW_INTERNALPAINT );
5870 ok_sequence( WmParentOnlyPaint, "WmParentOnlyPaint", FALSE );
5872 assert( GetWindowLong(hparent, GWL_STYLE) & WS_CLIPCHILDREN );
5873 UpdateWindow( hparent );
5876 trace("testing SWP_FRAMECHANGED on parent with WS_CLIPCHILDREN\n");
5877 RedrawWindow( hchild, NULL, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
5878 SetWindowPos( hparent, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE |
5879 SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED );
5881 ok_sequence(WmSWP_FrameChanged_clip, "SetWindowPos:FrameChanged_clip", FALSE );
5883 UpdateWindow( hparent );
5886 trace("testing SWP_FRAMECHANGED|SWP_DEFERERASE on parent with WS_CLIPCHILDREN\n");
5887 RedrawWindow( hchild, NULL, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
5888 SetWindowPos( hparent, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_DEFERERASE |
5889 SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED );
5891 ok_sequence(WmSWP_FrameChangedDeferErase, "SetWindowPos:FrameChangedDeferErase", FALSE );
5893 SetWindowLong( hparent, GWL_STYLE, GetWindowLong(hparent,GWL_STYLE) & ~WS_CLIPCHILDREN );
5894 ok_sequence( WmSetParentStyle, "WmSetParentStyle", FALSE );
5895 RedrawWindow( hparent, NULL, 0, RDW_INTERNALPAINT );
5897 ok_sequence( WmParentPaint, "WmParentPaint", FALSE );
5899 assert( !(GetWindowLong(hparent, GWL_STYLE) & WS_CLIPCHILDREN) );
5900 UpdateWindow( hparent );
5903 trace("testing SWP_FRAMECHANGED on parent without WS_CLIPCHILDREN\n");
5904 RedrawWindow( hchild, NULL, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
5905 SetWindowPos( hparent, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE |
5906 SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED );
5908 ok_sequence(WmSWP_FrameChanged_noclip, "SetWindowPos:FrameChanged_noclip", FALSE );
5910 UpdateWindow( hparent );
5913 trace("testing SWP_FRAMECHANGED|SWP_DEFERERASE on parent without WS_CLIPCHILDREN\n");
5914 RedrawWindow( hchild, NULL, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
5915 SetWindowPos( hparent, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_DEFERERASE |
5916 SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED );
5918 ok_sequence(WmSWP_FrameChangedDeferErase, "SetWindowPos:FrameChangedDeferErase", FALSE );
5920 ok(GetWindowLong( hparent, GWL_STYLE ) & WS_VISIBLE, "parent should be visible\n");
5921 ok(GetWindowLong( hchild, GWL_STYLE ) & WS_VISIBLE, "child should be visible\n");
5923 UpdateWindow( hparent );
5926 trace("testing SetWindowPos(-10000, -10000) on child\n");
5927 SetWindowPos( hchild, 0, -10000, -10000, 0, 0, SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER );
5928 check_update_rgn( hchild, 0 );
5931 #if 0 /* this one doesn't pass under Wine yet */
5932 UpdateWindow( hparent );
5935 trace("testing ShowWindow(SW_MINIMIZE) on child\n");
5936 ShowWindow( hchild, SW_MINIMIZE );
5937 check_update_rgn( hchild, 0 );
5941 UpdateWindow( hparent );
5944 trace("testing SetWindowPos(-10000, -10000) on parent\n");
5945 SetWindowPos( hparent, 0, -10000, -10000, 0, 0, SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER );
5946 check_update_rgn( hparent, 0 );
5949 log_all_parent_messages--;
5950 DestroyWindow( hparent );
5951 ok(!IsWindow(hchild), "child must be destroyed with its parent\n");
5953 /* tests for moving windows off-screen (needs simple WS_POPUP windows) */
5955 hparent = CreateWindowExA(0, "TestParentClass", "Test parent", WS_POPUP | WS_VISIBLE,
5956 100, 100, 200, 200, 0, 0, 0, NULL);
5957 ok (hparent != 0, "Failed to create parent window\n");
5959 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD | WS_VISIBLE,
5960 10, 10, 100, 100, hparent, 0, 0, NULL);
5961 ok (hchild != 0, "Failed to create child window\n");
5963 ShowWindow( hparent, SW_SHOW );
5964 UpdateWindow( hparent );
5965 UpdateWindow( hchild );
5969 /* moving child outside of parent boundaries changes update region */
5970 SetRect( &rect, 0, 0, 40, 40 );
5971 RedrawWindow( hchild, &rect, 0, RDW_INVALIDATE | RDW_ERASE );
5972 SetRectRgn( hrgn, 0, 0, 40, 40 );
5973 check_update_rgn( hchild, hrgn );
5974 MoveWindow( hchild, -10, 10, 100, 100, FALSE );
5975 SetRectRgn( hrgn, 10, 0, 40, 40 );
5976 check_update_rgn( hchild, hrgn );
5977 MoveWindow( hchild, -10, -10, 100, 100, FALSE );
5978 SetRectRgn( hrgn, 10, 10, 40, 40 );
5979 check_update_rgn( hchild, hrgn );
5981 /* moving parent off-screen does too */
5982 SetRect( &rect, 0, 0, 100, 100 );
5983 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_NOCHILDREN );
5984 SetRectRgn( hrgn, 0, 0, 100, 100 );
5985 check_update_rgn( hparent, hrgn );
5986 SetRectRgn( hrgn, 10, 10, 40, 40 );
5987 check_update_rgn( hchild, hrgn );
5988 MoveWindow( hparent, -20, -20, 200, 200, FALSE );
5989 SetRectRgn( hrgn, 20, 20, 100, 100 );
5990 check_update_rgn( hparent, hrgn );
5991 SetRectRgn( hrgn, 30, 30, 40, 40 );
5992 check_update_rgn( hchild, hrgn );
5994 /* invalidated region is cropped by the parent rects */
5995 SetRect( &rect, 0, 0, 50, 50 );
5996 RedrawWindow( hchild, &rect, 0, RDW_INVALIDATE | RDW_ERASE );
5997 SetRectRgn( hrgn, 30, 30, 50, 50 );
5998 check_update_rgn( hchild, hrgn );
6000 DestroyWindow( hparent );
6001 ok(!IsWindow(hchild), "child must be destroyed with its parent\n");
6004 DeleteObject( hrgn );
6005 DeleteObject( hrgn2 );
6014 static DWORD WINAPI thread_proc(void *param)
6017 struct wnd_event *wnd_event = (struct wnd_event *)param;
6019 wnd_event->hwnd = CreateWindowExA(0, "TestWindowClass", "window caption text", WS_OVERLAPPEDWINDOW,
6020 100, 100, 200, 200, 0, 0, 0, NULL);
6021 ok(wnd_event->hwnd != 0, "Failed to create overlapped window\n");
6023 SetEvent(wnd_event->event);
6025 while (GetMessage(&msg, 0, 0, 0))
6027 TranslateMessage(&msg);
6028 DispatchMessage(&msg);
6031 ok(IsWindow(wnd_event->hwnd), "window should still exist\n");
6036 static void test_interthread_messages(void)
6043 int len, expected_len;
6044 struct wnd_event wnd_event;
6047 wnd_event.event = CreateEventW(NULL, 0, 0, NULL);
6048 if (!wnd_event.event)
6050 trace("skipping interthread message test under win9x\n");
6054 hThread = CreateThread(NULL, 0, thread_proc, &wnd_event, 0, &tid);
6055 ok(hThread != NULL, "CreateThread failed, error %d\n", GetLastError());
6057 ok(WaitForSingleObject(wnd_event.event, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
6059 CloseHandle(wnd_event.event);
6061 SetLastError(0xdeadbeef);
6062 ok(!DestroyWindow(wnd_event.hwnd), "DestroyWindow succeded\n");
6063 ok(GetLastError() == ERROR_ACCESS_DENIED || GetLastError() == 0xdeadbeef,
6064 "wrong error code %d\n", GetLastError());
6066 proc = (WNDPROC)GetWindowLongPtrA(wnd_event.hwnd, GWLP_WNDPROC);
6067 ok(proc != NULL, "GetWindowLongPtrA(GWLP_WNDPROC) error %d\n", GetLastError());
6069 expected_len = lstrlenA("window caption text");
6070 memset(buf, 0, sizeof(buf));
6071 SetLastError(0xdeadbeef);
6072 len = CallWindowProcA(proc, wnd_event.hwnd, WM_GETTEXT, sizeof(buf), (LPARAM)buf);
6073 ok(len == expected_len, "CallWindowProcA(WM_GETTEXT) error %d, len %d, expected len %d\n", GetLastError(), len, expected_len);
6074 ok(!lstrcmpA(buf, "window caption text"), "window text mismatch\n");
6076 msg.hwnd = wnd_event.hwnd;
6077 msg.message = WM_GETTEXT;
6078 msg.wParam = sizeof(buf);
6079 msg.lParam = (LPARAM)buf;
6080 memset(buf, 0, sizeof(buf));
6081 SetLastError(0xdeadbeef);
6082 len = DispatchMessageA(&msg);
6083 ok((!len && GetLastError() == ERROR_MESSAGE_SYNC_ONLY) || broken(len), /* nt4 */
6084 "DispatchMessageA(WM_GETTEXT) succeded on another thread window: ret %d, error %d\n", len, GetLastError());
6086 /* the following test causes an exception in user.exe under win9x */
6087 msg.hwnd = wnd_event.hwnd;
6088 msg.message = WM_TIMER;
6090 msg.lParam = GetWindowLongPtrA(wnd_event.hwnd, GWLP_WNDPROC);
6091 SetLastError(0xdeadbeef);
6092 len = DispatchMessageA(&msg);
6093 ok(!len && GetLastError() == 0xdeadbeef,
6094 "DispatchMessageA(WM_TIMER) failed on another thread window: ret %d, error %d\n", len, GetLastError());
6096 ret = PostMessageA(wnd_event.hwnd, WM_QUIT, 0, 0);
6097 ok( ret, "PostMessageA(WM_QUIT) error %d\n", GetLastError());
6099 ok(WaitForSingleObject(hThread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
6100 CloseHandle(hThread);
6102 ok(!IsWindow(wnd_event.hwnd), "window should be destroyed on thread exit\n");
6106 static const struct message WmVkN[] = {
6107 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 1 }, /* XP */
6108 { WM_KEYDOWN, wparam|lparam, 'N', 1 },
6109 { WM_KEYDOWN, sent|wparam|lparam, 'N', 1 },
6110 { WM_CHAR, wparam|lparam, 'n', 1 },
6111 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1002,1), 0 },
6112 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xc0000001 }, /* XP */
6113 { WM_KEYUP, wparam|lparam, 'N', 0xc0000001 },
6114 { WM_KEYUP, sent|wparam|lparam, 'N', 0xc0000001 },
6117 static const struct message WmShiftVkN[] = {
6118 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_SHIFT, 1 }, /* XP */
6119 { WM_KEYDOWN, wparam|lparam, VK_SHIFT, 1 },
6120 { WM_KEYDOWN, sent|wparam|lparam, VK_SHIFT, 1 },
6121 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 1 }, /* XP */
6122 { WM_KEYDOWN, wparam|lparam, 'N', 1 },
6123 { WM_KEYDOWN, sent|wparam|lparam, 'N', 1 },
6124 { WM_CHAR, wparam|lparam, 'N', 1 },
6125 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1001,1), 0 },
6126 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xc0000001 }, /* XP */
6127 { WM_KEYUP, wparam|lparam, 'N', 0xc0000001 },
6128 { WM_KEYUP, sent|wparam|lparam, 'N', 0xc0000001 },
6129 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_SHIFT, 0xc0000001 }, /* XP */
6130 { WM_KEYUP, wparam|lparam, VK_SHIFT, 0xc0000001 },
6131 { WM_KEYUP, sent|wparam|lparam, VK_SHIFT, 0xc0000001 },
6134 static const struct message WmCtrlVkN[] = {
6135 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 1 }, /* XP */
6136 { WM_KEYDOWN, wparam|lparam, VK_CONTROL, 1 },
6137 { WM_KEYDOWN, sent|wparam|lparam, VK_CONTROL, 1 },
6138 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 1 }, /* XP */
6139 { WM_KEYDOWN, wparam|lparam, 'N', 1 },
6140 { WM_KEYDOWN, sent|wparam|lparam, 'N', 1 },
6141 { WM_CHAR, wparam|lparam, 0x000e, 1 },
6142 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1000,1), 0 },
6143 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xc0000001 }, /* XP */
6144 { WM_KEYUP, wparam|lparam, 'N', 0xc0000001 },
6145 { WM_KEYUP, sent|wparam|lparam, 'N', 0xc0000001 },
6146 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 0xc0000001 }, /* XP */
6147 { WM_KEYUP, wparam|lparam, VK_CONTROL, 0xc0000001 },
6148 { WM_KEYUP, sent|wparam|lparam, VK_CONTROL, 0xc0000001 },
6151 static const struct message WmCtrlVkN_2[] = {
6152 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 1 }, /* XP */
6153 { WM_KEYDOWN, wparam|lparam, VK_CONTROL, 1 },
6154 { WM_KEYDOWN, sent|wparam|lparam, VK_CONTROL, 1 },
6155 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 1 }, /* XP */
6156 { WM_KEYDOWN, wparam|lparam, 'N', 1 },
6157 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1000,1), 0 },
6158 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xc0000001 }, /* XP */
6159 { WM_KEYUP, wparam|lparam, 'N', 0xc0000001 },
6160 { WM_KEYUP, sent|wparam|lparam, 'N', 0xc0000001 },
6161 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 0xc0000001 }, /* XP */
6162 { WM_KEYUP, wparam|lparam, VK_CONTROL, 0xc0000001 },
6163 { WM_KEYUP, sent|wparam|lparam, VK_CONTROL, 0xc0000001 },
6166 static const struct message WmAltVkN[] = {
6167 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0x20000001 }, /* XP */
6168 { WM_SYSKEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
6169 { WM_SYSKEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
6170 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0x20000001 }, /* XP */
6171 { WM_SYSKEYDOWN, wparam|lparam, 'N', 0x20000001 },
6172 { WM_SYSKEYDOWN, sent|wparam|lparam, 'N', 0x20000001 },
6173 { WM_SYSCHAR, wparam|lparam, 'n', 0x20000001 },
6174 { WM_SYSCHAR, sent|wparam|lparam, 'n', 0x20000001 },
6175 { WM_SYSCOMMAND, sent|defwinproc|wparam|lparam, SC_KEYMENU, 'n' },
6176 { HCBT_SYSCOMMAND, hook },
6177 { WM_ENTERMENULOOP, sent|defwinproc|wparam|lparam, 0, 0 },
6178 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
6179 { 0x00AE, sent|defwinproc|optional }, /* XP */
6180 { WM_GETTEXT, sent|defwinproc|optional }, /* XP */
6181 { WM_INITMENU, sent|defwinproc },
6182 { EVENT_SYSTEM_MENUSTART, winevent_hook|wparam|lparam, OBJID_SYSMENU, 0 },
6183 { WM_MENUCHAR, sent|defwinproc|wparam, MAKEWPARAM('n',MF_SYSMENU) },
6184 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, 0, 0 },
6185 { WM_CAPTURECHANGED, sent|defwinproc },
6186 { WM_MENUSELECT, sent|defwinproc|wparam, MAKEWPARAM(0,0xffff) },
6187 { EVENT_SYSTEM_MENUEND, winevent_hook|wparam|lparam, OBJID_SYSMENU, 0 },
6188 { WM_EXITMENULOOP, sent|defwinproc },
6189 { WM_MENUSELECT, sent|defwinproc|wparam|optional, MAKEWPARAM(0,0xffff) }, /* Win95 bug */
6190 { WM_EXITMENULOOP, sent|defwinproc|optional }, /* Win95 bug */
6191 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xe0000001 }, /* XP */
6192 { WM_SYSKEYUP, wparam|lparam, 'N', 0xe0000001 },
6193 { WM_SYSKEYUP, sent|wparam|lparam, 'N', 0xe0000001 },
6194 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0xc0000001 }, /* XP */
6195 { WM_KEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
6196 { WM_KEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
6199 static const struct message WmAltVkN_2[] = {
6200 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0x20000001 }, /* XP */
6201 { WM_SYSKEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
6202 { WM_SYSKEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
6203 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0x20000001 }, /* XP */
6204 { WM_SYSKEYDOWN, wparam|lparam, 'N', 0x20000001 },
6205 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1003,1), 0 },
6206 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xe0000001 }, /* XP */
6207 { WM_SYSKEYUP, wparam|lparam, 'N', 0xe0000001 },
6208 { WM_SYSKEYUP, sent|wparam|lparam, 'N', 0xe0000001 },
6209 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0xc0000001 }, /* XP */
6210 { WM_KEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
6211 { WM_KEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
6214 static const struct message WmCtrlAltVkN[] = {
6215 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 1 }, /* XP */
6216 { WM_KEYDOWN, wparam|lparam, VK_CONTROL, 1 },
6217 { WM_KEYDOWN, sent|wparam|lparam, VK_CONTROL, 1 },
6218 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0x20000001 }, /* XP */
6219 { WM_KEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
6220 { WM_KEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
6221 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0x20000001 }, /* XP */
6222 { WM_KEYDOWN, wparam|lparam, 'N', 0x20000001 },
6223 { WM_KEYDOWN, sent|wparam|lparam, 'N', 0x20000001 },
6224 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xe0000001 }, /* XP */
6225 { WM_KEYUP, wparam|lparam, 'N', 0xe0000001 },
6226 { WM_KEYUP, sent|wparam|lparam, 'N', 0xe0000001 },
6227 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0xc0000001 }, /* XP */
6228 { WM_KEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
6229 { WM_KEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
6230 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 0xc0000001 }, /* XP */
6231 { WM_KEYUP, wparam|lparam, VK_CONTROL, 0xc0000001 },
6232 { WM_KEYUP, sent|wparam|lparam, VK_CONTROL, 0xc0000001 },
6235 static const struct message WmCtrlShiftVkN[] = {
6236 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 1 }, /* XP */
6237 { WM_KEYDOWN, wparam|lparam, VK_CONTROL, 1 },
6238 { WM_KEYDOWN, sent|wparam|lparam, VK_CONTROL, 1 },
6239 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_SHIFT, 1 }, /* XP */
6240 { WM_KEYDOWN, wparam|lparam, VK_SHIFT, 1 },
6241 { WM_KEYDOWN, sent|wparam|lparam, VK_SHIFT, 1 },
6242 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 1 }, /* XP */
6243 { WM_KEYDOWN, wparam|lparam, 'N', 1 },
6244 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1004,1), 0 },
6245 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xc0000001 }, /* XP */
6246 { WM_KEYUP, wparam|lparam, 'N', 0xc0000001 },
6247 { WM_KEYUP, sent|wparam|lparam, 'N', 0xc0000001 },
6248 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_SHIFT, 0xc0000001 }, /* XP */
6249 { WM_KEYUP, wparam|lparam, VK_SHIFT, 0xc0000001 },
6250 { WM_KEYUP, sent|wparam|lparam, VK_SHIFT, 0xc0000001 },
6251 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 0xc0000001 }, /* XP */
6252 { WM_KEYUP, wparam|lparam, VK_CONTROL, 0xc0000001 },
6253 { WM_KEYUP, sent|wparam|lparam, VK_CONTROL, 0xc0000001 },
6256 static const struct message WmCtrlAltShiftVkN[] = {
6257 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 1 }, /* XP */
6258 { WM_KEYDOWN, wparam|lparam, VK_CONTROL, 1 },
6259 { WM_KEYDOWN, sent|wparam|lparam, VK_CONTROL, 1 },
6260 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0x20000001 }, /* XP */
6261 { WM_KEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
6262 { WM_KEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
6263 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_SHIFT, 0x20000001 }, /* XP */
6264 { WM_KEYDOWN, wparam|lparam, VK_SHIFT, 0x20000001 },
6265 { WM_KEYDOWN, sent|wparam|lparam, VK_SHIFT, 0x20000001 },
6266 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0x20000001 }, /* XP */
6267 { WM_KEYDOWN, wparam|lparam, 'N', 0x20000001 },
6268 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1005,1), 0 },
6269 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xe0000001 }, /* XP */
6270 { WM_KEYUP, wparam|lparam, 'N', 0xe0000001 },
6271 { WM_KEYUP, sent|wparam|lparam, 'N', 0xe0000001 },
6272 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_SHIFT, 0xe0000001 }, /* XP */
6273 { WM_KEYUP, wparam|lparam, VK_SHIFT, 0xe0000001 },
6274 { WM_KEYUP, sent|wparam|lparam, VK_SHIFT, 0xe0000001 },
6275 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0xc0000001 }, /* XP */
6276 { WM_KEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
6277 { WM_KEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
6278 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 0xc0000001 }, /* XP */
6279 { WM_KEYUP, wparam|lparam, VK_CONTROL, 0xc0000001 },
6280 { WM_KEYUP, sent|wparam|lparam, VK_CONTROL, 0xc0000001 },
6283 static const struct message WmAltPressRelease[] = {
6284 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0x20000001 }, /* XP */
6285 { WM_SYSKEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
6286 { WM_SYSKEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
6287 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0xc0000001 }, /* XP */
6288 { WM_SYSKEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
6289 { WM_SYSKEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
6290 { WM_SYSCOMMAND, sent|defwinproc|wparam|lparam, SC_KEYMENU, 0 },
6291 { HCBT_SYSCOMMAND, hook },
6292 { WM_ENTERMENULOOP, sent|defwinproc|wparam|lparam, 0, 0 },
6293 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
6294 { WM_INITMENU, sent|defwinproc },
6295 { EVENT_SYSTEM_MENUSTART, winevent_hook|wparam|lparam, OBJID_SYSMENU, 0 },
6296 { WM_MENUSELECT, sent|defwinproc|wparam, MAKEWPARAM(0,MF_SYSMENU|MF_POPUP|MF_HILITE) },
6297 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_SYSMENU, 1 },
6299 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0x30000001 }, /* XP */
6301 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_SYSMENU, 0 },
6302 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, 0, 0, },
6303 { WM_CAPTURECHANGED, sent|defwinproc },
6304 { WM_MENUSELECT, sent|defwinproc|wparam|optional, MAKEWPARAM(0,0xffff) },
6305 { EVENT_SYSTEM_MENUEND, winevent_hook|wparam|lparam, OBJID_SYSMENU, 0 },
6306 { WM_EXITMENULOOP, sent|defwinproc },
6307 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0xc0000001 }, /* XP */
6308 { WM_SYSKEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
6309 { WM_SYSKEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
6312 static const struct message WmAltMouseButton[] = {
6313 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0x20000001 }, /* XP */
6314 { WM_SYSKEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
6315 { WM_SYSKEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
6316 { WM_MOUSEMOVE, wparam|optional, 0, 0 },
6317 { WM_MOUSEMOVE, sent|wparam|optional, 0, 0 },
6318 { WM_LBUTTONDOWN, wparam, MK_LBUTTON, 0 },
6319 { WM_LBUTTONDOWN, sent|wparam, MK_LBUTTON, 0 },
6320 { WM_LBUTTONUP, wparam, 0, 0 },
6321 { WM_LBUTTONUP, sent|wparam, 0, 0 },
6322 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0xc0000001 }, /* XP */
6323 { WM_SYSKEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
6324 { WM_SYSKEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
6327 static const struct message WmF1Seq[] = {
6328 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_F1, 1 }, /* XP */
6329 { WM_KEYDOWN, wparam|lparam, VK_F1, 1 },
6330 { WM_KEYDOWN, sent|wparam|lparam, VK_F1, 0x00000001 },
6331 { WM_KEYF1, wparam|lparam, 0, 0 },
6332 { WM_KEYF1, sent|wparam|lparam, 0, 0 },
6333 { WM_HELP, sent|defwinproc },
6334 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_F1, 0xc0000001 }, /* XP */
6335 { WM_KEYUP, wparam|lparam, VK_F1, 0xc0000001 },
6336 { WM_KEYUP, sent|wparam|lparam, VK_F1, 0xc0000001 },
6339 static const struct message WmVkAppsSeq[] = {
6340 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_APPS, 1 }, /* XP */
6341 { WM_KEYDOWN, wparam|lparam, VK_APPS, 1 },
6342 { WM_KEYDOWN, sent|wparam|lparam, VK_APPS, 0x00000001 },
6343 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_APPS, 0xc0000001 }, /* XP */
6344 { WM_KEYUP, wparam|lparam, VK_APPS, 0xc0000001 },
6345 { WM_KEYUP, sent|wparam|lparam, VK_APPS, 0xc0000001 },
6346 { WM_CONTEXTMENU, lparam, /*hwnd*/0, (LPARAM)-1 },
6347 { WM_CONTEXTMENU, sent|lparam, /*hwnd*/0, (LPARAM)-1 },
6351 static void pump_msg_loop(HWND hwnd, HACCEL hAccel)
6355 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE))
6357 struct message log_msg;
6359 trace("accel: %p, %04x, %08lx, %08lx\n", msg.hwnd, msg.message, msg.wParam, msg.lParam);
6361 /* ignore some unwanted messages */
6362 if (msg.message == WM_MOUSEMOVE ||
6363 msg.message == WM_GETICON ||
6364 msg.message == WM_DEVICECHANGE)
6367 log_msg.message = msg.message;
6368 log_msg.flags = wparam|lparam;
6369 log_msg.wParam = msg.wParam;
6370 log_msg.lParam = msg.lParam;
6371 add_message(&log_msg);
6373 if (!hAccel || !TranslateAccelerator(hwnd, hAccel, &msg))
6375 TranslateMessage(&msg);
6376 DispatchMessage(&msg);
6381 static void test_accelerators(void)
6386 HWND hwnd = CreateWindowExA(0, "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW | WS_VISIBLE,
6387 100, 100, 200, 200, 0, 0, 0, NULL);
6396 ok(GetFocus() == hwnd, "wrong focus window %p\n", GetFocus());
6398 state = GetKeyState(VK_SHIFT);
6399 ok(!(state & 0x8000), "wrong Shift state %04x\n", state);
6400 state = GetKeyState(VK_CAPITAL);
6401 ok(state == 0, "wrong CapsLock state %04x\n", state);
6403 hAccel = LoadAccelerators(GetModuleHandleA(0), MAKEINTRESOURCE(1));
6404 assert(hAccel != 0);
6407 pump_msg_loop(hwnd, 0);
6410 trace("testing VK_N press/release\n");
6412 keybd_event('N', 0, 0, 0);
6413 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
6414 pump_msg_loop(hwnd, hAccel);
6415 ok_sequence(WmVkN, "VK_N press/release", FALSE);
6417 trace("testing Shift+VK_N press/release\n");
6419 keybd_event(VK_SHIFT, 0, 0, 0);
6420 keybd_event('N', 0, 0, 0);
6421 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
6422 keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
6423 pump_msg_loop(hwnd, hAccel);
6424 ok_sequence(WmShiftVkN, "Shift+VK_N press/release", FALSE);
6426 trace("testing Ctrl+VK_N press/release\n");
6428 keybd_event(VK_CONTROL, 0, 0, 0);
6429 keybd_event('N', 0, 0, 0);
6430 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
6431 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
6432 pump_msg_loop(hwnd, hAccel);
6433 ok_sequence(WmCtrlVkN, "Ctrl+VK_N press/release", FALSE);
6435 trace("testing Alt+VK_N press/release\n");
6437 keybd_event(VK_MENU, 0, 0, 0);
6438 keybd_event('N', 0, 0, 0);
6439 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
6440 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
6441 pump_msg_loop(hwnd, hAccel);
6442 ok_sequence(WmAltVkN, "Alt+VK_N press/release", FALSE);
6444 trace("testing Ctrl+Alt+VK_N press/release 1\n");
6446 keybd_event(VK_CONTROL, 0, 0, 0);
6447 keybd_event(VK_MENU, 0, 0, 0);
6448 keybd_event('N', 0, 0, 0);
6449 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
6450 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
6451 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
6452 pump_msg_loop(hwnd, hAccel);
6453 ok_sequence(WmCtrlAltVkN, "Ctrl+Alt+VK_N press/release 1", FALSE);
6455 ret = DestroyAcceleratorTable(hAccel);
6456 ok( ret, "DestroyAcceleratorTable error %d\n", GetLastError());
6458 hAccel = LoadAccelerators(GetModuleHandleA(0), MAKEINTRESOURCE(2));
6459 assert(hAccel != 0);
6461 trace("testing VK_N press/release\n");
6463 keybd_event('N', 0, 0, 0);
6464 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
6465 pump_msg_loop(hwnd, hAccel);
6466 ok_sequence(WmVkN, "VK_N press/release", FALSE);
6468 trace("testing Shift+VK_N press/release\n");
6470 keybd_event(VK_SHIFT, 0, 0, 0);
6471 keybd_event('N', 0, 0, 0);
6472 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
6473 keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
6474 pump_msg_loop(hwnd, hAccel);
6475 ok_sequence(WmShiftVkN, "Shift+VK_N press/release", FALSE);
6477 trace("testing Ctrl+VK_N press/release 2\n");
6479 keybd_event(VK_CONTROL, 0, 0, 0);
6480 keybd_event('N', 0, 0, 0);
6481 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
6482 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
6483 pump_msg_loop(hwnd, hAccel);
6484 ok_sequence(WmCtrlVkN_2, "Ctrl+VK_N press/release 2", FALSE);
6486 trace("testing Alt+VK_N press/release 2\n");
6488 keybd_event(VK_MENU, 0, 0, 0);
6489 keybd_event('N', 0, 0, 0);
6490 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
6491 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
6492 pump_msg_loop(hwnd, hAccel);
6493 ok_sequence(WmAltVkN_2, "Alt+VK_N press/release 2", FALSE);
6495 trace("testing Ctrl+Alt+VK_N press/release 2\n");
6497 keybd_event(VK_CONTROL, 0, 0, 0);
6498 keybd_event(VK_MENU, 0, 0, 0);
6499 keybd_event('N', 0, 0, 0);
6500 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
6501 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
6502 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
6503 pump_msg_loop(hwnd, hAccel);
6504 ok_sequence(WmCtrlAltVkN, "Ctrl+Alt+VK_N press/release 2", FALSE);
6506 trace("testing Ctrl+Shift+VK_N press/release\n");
6508 keybd_event(VK_CONTROL, 0, 0, 0);
6509 keybd_event(VK_SHIFT, 0, 0, 0);
6510 keybd_event('N', 0, 0, 0);
6511 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
6512 keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
6513 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
6514 pump_msg_loop(hwnd, hAccel);
6515 ok_sequence(WmCtrlShiftVkN, "Ctrl+Shift+VK_N press/release", FALSE);
6517 trace("testing Ctrl+Alt+Shift+VK_N press/release\n");
6519 keybd_event(VK_CONTROL, 0, 0, 0);
6520 keybd_event(VK_MENU, 0, 0, 0);
6521 keybd_event(VK_SHIFT, 0, 0, 0);
6522 keybd_event('N', 0, 0, 0);
6523 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
6524 keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
6525 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
6526 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
6527 pump_msg_loop(hwnd, hAccel);
6528 ok_sequence(WmCtrlAltShiftVkN, "Ctrl+Alt+Shift+VK_N press/release", FALSE);
6530 ret = DestroyAcceleratorTable(hAccel);
6531 ok( ret, "DestroyAcceleratorTable error %d\n", GetLastError());
6533 trace("testing Alt press/release\n");
6535 keybd_event(VK_MENU, 0, 0, 0);
6536 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
6537 keybd_event(VK_MENU, 0, 0, 0);
6538 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
6539 pump_msg_loop(hwnd, 0);
6540 /* this test doesn't pass in Wine for managed windows */
6541 ok_sequence(WmAltPressRelease, "Alt press/release", TRUE);
6543 trace("testing Alt+MouseButton press/release\n");
6544 /* first, move mouse pointer inside of the window client area */
6545 GetClientRect(hwnd, &rc);
6546 MapWindowPoints(hwnd, 0, (LPPOINT)&rc, 2);
6547 rc.left += (rc.right - rc.left)/2;
6548 rc.top += (rc.bottom - rc.top)/2;
6549 SetCursorPos(rc.left, rc.top);
6553 keybd_event(VK_MENU, 0, 0, 0);
6554 mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
6555 mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
6556 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
6557 pump_msg_loop(hwnd, 0);
6558 ok_sequence(WmAltMouseButton, "Alt+MouseButton press/release", FALSE);
6560 trace("testing VK_F1 press/release\n");
6561 keybd_event(VK_F1, 0, 0, 0);
6562 keybd_event(VK_F1, 0, KEYEVENTF_KEYUP, 0);
6563 pump_msg_loop(hwnd, 0);
6564 ok_sequence(WmF1Seq, "F1 press/release", FALSE);
6566 trace("testing VK_APPS press/release\n");
6567 keybd_event(VK_APPS, 0, 0, 0);
6568 keybd_event(VK_APPS, 0, KEYEVENTF_KEYUP, 0);
6569 pump_msg_loop(hwnd, 0);
6570 ok_sequence(WmVkAppsSeq, "VK_APPS press/release", FALSE);
6572 DestroyWindow(hwnd);
6575 /************* window procedures ********************/
6577 static LRESULT MsgCheckProc (BOOL unicode, HWND hwnd, UINT message,
6578 WPARAM wParam, LPARAM lParam)
6580 static long defwndproc_counter = 0;
6581 static long beginpaint_counter = 0;
6585 trace("%p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
6587 /* explicitly ignore WM_GETICON message */
6588 if (message == WM_GETICON) return 0;
6594 LONG style = GetWindowLongA(hwnd, GWL_STYLE);
6595 ok((BOOL)wParam == !(style & WS_DISABLED),
6596 "wrong WS_DISABLED state: %ld != %d\n", wParam, !(style & WS_DISABLED));
6600 case WM_CAPTURECHANGED:
6601 if (test_DestroyWindow_flag)
6603 DWORD style = GetWindowLongA(hwnd, GWL_STYLE);
6604 if (style & WS_CHILD)
6605 lParam = GetWindowLongPtrA(hwnd, GWLP_ID);
6606 else if (style & WS_POPUP)
6607 lParam = WND_POPUP_ID;
6609 lParam = WND_PARENT_ID;
6617 ok(!GetWindow(hwnd, GW_CHILD), "children should be unlinked at this point\n");
6618 capture = GetCapture();
6621 ok(capture == hwnd, "capture should NOT be released at this point (capture %p)\n", capture);
6622 trace("current capture %p, releasing...\n", capture);
6629 ok(pGetAncestor(hwnd, GA_PARENT) != 0, "parent should NOT be unlinked at this point\n");
6630 if (test_DestroyWindow_flag)
6632 DWORD style = GetWindowLongA(hwnd, GWL_STYLE);
6633 if (style & WS_CHILD)
6634 lParam = GetWindowLongPtrA(hwnd, GWLP_ID);
6635 else if (style & WS_POPUP)
6636 lParam = WND_POPUP_ID;
6638 lParam = WND_PARENT_ID;
6642 /* test_accelerators() depends on this */
6649 case WM_DEVICECHANGE:
6652 case WM_WINDOWPOSCHANGING:
6653 case WM_WINDOWPOSCHANGED:
6655 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
6657 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
6658 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x ",
6659 winpos->hwnd, winpos->hwndInsertAfter,
6660 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
6661 dump_winpos_flags(winpos->flags);
6663 /* Log only documented flags, win2k uses 0x1000 and 0x2000
6664 * in the high word for internal purposes
6666 wParam = winpos->flags & 0xffff;
6667 /* We are not interested in the flags that don't match under XP and Win9x */
6668 wParam &= ~(SWP_NOZORDER);
6673 msg.message = message;
6674 msg.flags = sent|wparam|lparam;
6675 if (defwndproc_counter) msg.flags |= defwinproc;
6676 if (beginpaint_counter) msg.flags |= beginpaint;
6677 msg.wParam = wParam;
6678 msg.lParam = lParam;
6681 if (message == WM_GETMINMAXINFO && (GetWindowLongA(hwnd, GWL_STYLE) & WS_CHILD))
6683 HWND parent = GetParent(hwnd);
6685 MINMAXINFO *minmax = (MINMAXINFO *)lParam;
6687 GetClientRect(parent, &rc);
6688 trace("parent %p client size = (%d x %d)\n", parent, rc.right, rc.bottom);
6689 trace("Reserved=%d,%d MaxSize=%d,%d MaxPos=%d,%d MinTrack=%d,%d MaxTrack=%d,%d\n",
6690 minmax->ptReserved.x, minmax->ptReserved.y,
6691 minmax->ptMaxSize.x, minmax->ptMaxSize.y,
6692 minmax->ptMaxPosition.x, minmax->ptMaxPosition.y,
6693 minmax->ptMinTrackSize.x, minmax->ptMinTrackSize.y,
6694 minmax->ptMaxTrackSize.x, minmax->ptMaxTrackSize.y);
6696 ok(minmax->ptMaxSize.x == rc.right, "default width of maximized child %d != %d\n",
6697 minmax->ptMaxSize.x, rc.right);
6698 ok(minmax->ptMaxSize.y == rc.bottom, "default height of maximized child %d != %d\n",
6699 minmax->ptMaxSize.y, rc.bottom);
6702 if (message == WM_PAINT)
6705 beginpaint_counter++;
6706 BeginPaint( hwnd, &ps );
6707 beginpaint_counter--;
6708 EndPaint( hwnd, &ps );
6712 defwndproc_counter++;
6713 ret = unicode ? DefWindowProcW(hwnd, message, wParam, lParam)
6714 : DefWindowProcA(hwnd, message, wParam, lParam);
6715 defwndproc_counter--;
6720 static LRESULT WINAPI MsgCheckProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
6722 return MsgCheckProc (FALSE, hwnd, message, wParam, lParam);
6725 static LRESULT WINAPI MsgCheckProcW(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
6727 return MsgCheckProc (TRUE, hwnd, message, wParam, lParam);
6730 static LRESULT WINAPI PopupMsgCheckProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
6732 static long defwndproc_counter = 0;
6736 trace("popup: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
6741 /* explicitly ignore WM_GETICON message */
6743 case WM_QUERYENDSESSION:
6745 lParam &= ~0x01; /* Vista adds a 0x01 flag */
6749 msg.message = message;
6750 msg.flags = sent|wparam|lparam;
6751 if (defwndproc_counter) msg.flags |= defwinproc;
6752 msg.wParam = wParam;
6753 msg.lParam = lParam;
6756 if (message == WM_CREATE)
6758 DWORD style = GetWindowLongA(hwnd, GWL_STYLE) | WS_VISIBLE;
6759 SetWindowLongA(hwnd, GWL_STYLE, style);
6762 defwndproc_counter++;
6763 ret = DefWindowProcA(hwnd, message, wParam, lParam);
6764 defwndproc_counter--;
6769 static LRESULT WINAPI ParentMsgCheckProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
6771 static long defwndproc_counter = 0;
6772 static long beginpaint_counter = 0;
6775 LPARAM logged_lParam;
6777 trace("parent: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
6779 /* explicitly ignore WM_GETICON message */
6780 if (message == WM_GETICON) return 0;
6782 logged_lParam=lParam;
6783 if (log_all_parent_messages ||
6784 message == WM_PARENTNOTIFY || message == WM_CANCELMODE ||
6785 message == WM_SETFOCUS || message == WM_KILLFOCUS ||
6786 message == WM_ENABLE || message == WM_ENTERIDLE ||
6787 message == WM_DRAWITEM ||
6788 message == WM_IME_SETCONTEXT)
6802 INT ret = GetClipBox((HDC)wParam, &rc);
6804 trace("WM_ERASEBKGND: GetClipBox()=%d, (%d,%d-%d,%d)\n",
6805 ret, rc.left, rc.top, rc.right, rc.bottom);
6809 case WM_WINDOWPOSCHANGING:
6810 case WM_WINDOWPOSCHANGED:
6812 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
6814 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
6815 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x ",
6816 winpos->hwnd, winpos->hwndInsertAfter,
6817 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
6818 dump_winpos_flags(winpos->flags);
6820 /* Log only documented flags, win2k uses 0x1000 and 0x2000
6821 * in the high word for internal purposes
6823 wParam = winpos->flags & 0xffff;
6824 /* We are not interested in the flags that don't match under XP and Win9x */
6825 wParam &= ~(SWP_NOZORDER);
6831 /* encode DRAWITEMSTRUCT into an LPARAM */
6832 DRAW_ITEM_STRUCT di;
6833 DRAWITEMSTRUCT *dis = (DRAWITEMSTRUCT *)lParam;
6835 trace("WM_DRAWITEM: type %x, ctl_id %x, item_id %x, action %x, state %x\n",
6836 dis->CtlType, dis->CtlID, dis->itemID, dis->itemAction, dis->itemState);
6838 di.u.item.type = dis->CtlType;
6839 di.u.item.ctl_id = dis->CtlID;
6840 di.u.item.item_id = dis->itemID;
6841 di.u.item.action = dis->itemAction;
6842 di.u.item.state = dis->itemState;
6844 logged_lParam = di.u.lp;
6849 msg.message = message;
6850 msg.flags = sent|parent|wparam|lparam;
6851 if (defwndproc_counter) msg.flags |= defwinproc;
6852 if (beginpaint_counter) msg.flags |= beginpaint;
6853 msg.wParam = wParam;
6854 msg.lParam = logged_lParam;
6858 if (message == WM_PAINT)
6861 beginpaint_counter++;
6862 BeginPaint( hwnd, &ps );
6863 beginpaint_counter--;
6864 EndPaint( hwnd, &ps );
6868 defwndproc_counter++;
6869 ret = DefWindowProcA(hwnd, message, wParam, lParam);
6870 defwndproc_counter--;
6875 static LRESULT WINAPI TestDlgProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
6877 static long defwndproc_counter = 0;
6881 trace("dialog: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
6883 /* explicitly ignore WM_GETICON message */
6884 if (message == WM_GETICON) return 0;
6888 DefDlgProcA(hwnd, DM_SETDEFID, 1, 0);
6889 ret = DefDlgProcA(hwnd, DM_GETDEFID, 0, 0);
6890 if (after_end_dialog)
6891 ok( ret == 0, "DM_GETDEFID should return 0 after EndDialog, got %lx\n", ret );
6893 ok(HIWORD(ret) == DC_HASDEFID, "DM_GETDEFID should return DC_HASDEFID, got %lx\n", ret);
6898 case WM_WINDOWPOSCHANGING:
6899 case WM_WINDOWPOSCHANGED:
6901 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
6903 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
6904 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x ",
6905 winpos->hwnd, winpos->hwndInsertAfter,
6906 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
6907 dump_winpos_flags(winpos->flags);
6909 /* Log only documented flags, win2k uses 0x1000 and 0x2000
6910 * in the high word for internal purposes
6912 wParam = winpos->flags & 0xffff;
6913 /* We are not interested in the flags that don't match under XP and Win9x */
6914 wParam &= ~(SWP_NOZORDER);
6919 msg.message = message;
6920 msg.flags = sent|wparam|lparam;
6921 if (defwndproc_counter) msg.flags |= defwinproc;
6922 msg.wParam = wParam;
6923 msg.lParam = lParam;
6926 defwndproc_counter++;
6927 ret = DefDlgProcA(hwnd, message, wParam, lParam);
6928 defwndproc_counter--;
6933 static void dump_winpos_flags(UINT flags)
6935 if (!winetest_debug) return;
6937 if (flags & SWP_SHOWWINDOW) printf("|SWP_SHOWWINDOW");
6938 if (flags & SWP_HIDEWINDOW) printf("|SWP_HIDEWINDOW");
6939 if (flags & SWP_NOACTIVATE) printf("|SWP_NOACTIVATE");
6940 if (flags & SWP_FRAMECHANGED) printf("|SWP_FRAMECHANGED");
6941 if (flags & SWP_NOCOPYBITS) printf("|SWP_NOCOPYBITS");
6942 if (flags & SWP_NOOWNERZORDER) printf("|SWP_NOOWNERZORDER");
6943 if (flags & SWP_NOSENDCHANGING) printf("|SWP_NOSENDCHANGING");
6944 if (flags & SWP_DEFERERASE) printf("|SWP_DEFERERASE");
6945 if (flags & SWP_ASYNCWINDOWPOS) printf("|SWP_ASYNCWINDOWPOS");
6946 if (flags & SWP_NOZORDER) printf("|SWP_NOZORDER");
6947 if (flags & SWP_NOREDRAW) printf("|SWP_NOREDRAW");
6948 if (flags & SWP_NOSIZE) printf("|SWP_NOSIZE");
6949 if (flags & SWP_NOMOVE) printf("|SWP_NOMOVE");
6950 if (flags & SWP_NOCLIENTSIZE) printf("|SWP_NOCLIENTSIZE");
6951 if (flags & SWP_NOCLIENTMOVE) printf("|SWP_NOCLIENTMOVE");
6953 #define DUMPED_FLAGS \
6959 SWP_FRAMECHANGED | \
6963 SWP_NOOWNERZORDER | \
6964 SWP_NOSENDCHANGING | \
6966 SWP_ASYNCWINDOWPOS | \
6967 SWP_NOCLIENTSIZE | \
6970 if(flags & ~DUMPED_FLAGS) printf("|0x%04x", flags & ~DUMPED_FLAGS);
6975 static LRESULT WINAPI ShowWindowProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
6977 static long defwndproc_counter = 0;
6981 /* log only specific messages we are interested in */
6984 #if 0 /* probably log these as well */
6990 trace("WM_SHOWWINDOW %ld\n", wParam);
6993 trace("WM_SIZE %ld\n", wParam);
6998 case WM_GETMINMAXINFO:
6999 trace("WM_GETMINMAXINFO\n");
7002 case WM_WINDOWPOSCHANGING:
7003 case WM_WINDOWPOSCHANGED:
7005 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
7007 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
7008 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
7009 winpos->hwnd, winpos->hwndInsertAfter,
7010 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
7012 dump_winpos_flags(winpos->flags);
7014 /* Log only documented flags, win2k uses 0x1000 and 0x2000
7015 * in the high word for internal purposes
7017 wParam = winpos->flags & 0xffff;
7018 /* We are not interested in the flags that don't match under XP and Win9x */
7019 wParam &= ~(SWP_NOZORDER);
7023 default: /* ignore */
7024 /*trace("showwindow: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);*/
7025 return DefWindowProcA(hwnd, message, wParam, lParam);
7028 msg.message = message;
7029 msg.flags = sent|wparam|lparam;
7030 if (defwndproc_counter) msg.flags |= defwinproc;
7031 msg.wParam = wParam;
7032 msg.lParam = lParam;
7035 defwndproc_counter++;
7036 ret = DefWindowProcA(hwnd, message, wParam, lParam);
7037 defwndproc_counter--;
7042 static BOOL RegisterWindowClasses(void)
7048 cls.lpfnWndProc = MsgCheckProcA;
7051 cls.hInstance = GetModuleHandleA(0);
7053 cls.hCursor = LoadCursorA(0, (LPSTR)IDC_ARROW);
7054 cls.hbrBackground = GetStockObject(WHITE_BRUSH);
7055 cls.lpszMenuName = NULL;
7056 cls.lpszClassName = "TestWindowClass";
7057 if(!RegisterClassA(&cls)) return FALSE;
7059 cls.lpfnWndProc = ShowWindowProcA;
7060 cls.lpszClassName = "ShowWindowClass";
7061 if(!RegisterClassA(&cls)) return FALSE;
7063 cls.lpfnWndProc = PopupMsgCheckProcA;
7064 cls.lpszClassName = "TestPopupClass";
7065 if(!RegisterClassA(&cls)) return FALSE;
7067 cls.lpfnWndProc = ParentMsgCheckProcA;
7068 cls.lpszClassName = "TestParentClass";
7069 if(!RegisterClassA(&cls)) return FALSE;
7071 cls.lpfnWndProc = DefWindowProcA;
7072 cls.lpszClassName = "SimpleWindowClass";
7073 if(!RegisterClassA(&cls)) return FALSE;
7075 cls.style = CS_NOCLOSE;
7076 cls.lpszClassName = "NoCloseWindowClass";
7077 if(!RegisterClassA(&cls)) return FALSE;
7079 ok(GetClassInfoA(0, "#32770", &cls), "GetClassInfo failed\n");
7081 cls.hInstance = GetModuleHandleA(0);
7082 cls.hbrBackground = 0;
7083 cls.lpfnWndProc = TestDlgProcA;
7084 cls.lpszClassName = "TestDialogClass";
7085 if(!RegisterClassA(&cls)) return FALSE;
7088 clsW.lpfnWndProc = MsgCheckProcW;
7089 clsW.cbClsExtra = 0;
7090 clsW.cbWndExtra = 0;
7091 clsW.hInstance = GetModuleHandleW(0);
7093 clsW.hCursor = LoadCursorW(0, (LPWSTR)IDC_ARROW);
7094 clsW.hbrBackground = GetStockObject(WHITE_BRUSH);
7095 clsW.lpszMenuName = NULL;
7096 clsW.lpszClassName = testWindowClassW;
7097 RegisterClassW(&clsW); /* ignore error, this fails on Win9x */
7102 static BOOL is_our_logged_class(HWND hwnd)
7106 if (GetClassNameA(hwnd, buf, sizeof(buf)))
7108 if (!lstrcmpiA(buf, "TestWindowClass") ||
7109 !lstrcmpiA(buf, "ShowWindowClass") ||
7110 !lstrcmpiA(buf, "TestParentClass") ||
7111 !lstrcmpiA(buf, "TestPopupClass") ||
7112 !lstrcmpiA(buf, "SimpleWindowClass") ||
7113 !lstrcmpiA(buf, "TestDialogClass") ||
7114 !lstrcmpiA(buf, "MDI_frame_class") ||
7115 !lstrcmpiA(buf, "MDI_client_class") ||
7116 !lstrcmpiA(buf, "MDI_child_class") ||
7117 !lstrcmpiA(buf, "my_button_class") ||
7118 !lstrcmpiA(buf, "my_edit_class") ||
7119 !lstrcmpiA(buf, "static") ||
7120 !lstrcmpiA(buf, "ListBox") ||
7121 !lstrcmpiA(buf, "ComboBox") ||
7122 !lstrcmpiA(buf, "MyDialogClass") ||
7123 !lstrcmpiA(buf, "#32770") ||
7124 !lstrcmpiA(buf, "#32768"))
7126 trace("ignoring window class %s\n", buf);
7131 static HHOOK hCBT_hook;
7132 static DWORD cbt_hook_thread_id;
7134 static LRESULT CALLBACK cbt_hook_proc(int nCode, WPARAM wParam, LPARAM lParam)
7136 static const char * const CBT_code_name[10] = {
7143 "HCBT_CLICKSKIPPED",
7147 const char *code_name = (nCode >= 0 && nCode <= HCBT_SETFOCUS) ? CBT_code_name[nCode] : "Unknown";
7150 trace("CBT: %d (%s), %08lx, %08lx\n", nCode, code_name, wParam, lParam);
7152 ok(cbt_hook_thread_id == GetCurrentThreadId(), "we didn't ask for events from other threads\n");
7154 if (nCode == HCBT_CLICKSKIPPED)
7156 /* ignore this event, XP sends it a lot when switching focus between windows */
7157 return CallNextHookEx(hCBT_hook, nCode, wParam, lParam);
7160 if (nCode == HCBT_SYSCOMMAND || nCode == HCBT_KEYSKIPPED)
7164 msg.message = nCode;
7165 msg.flags = hook|wparam|lparam;
7166 msg.wParam = wParam;
7167 msg.lParam = lParam;
7170 return CallNextHookEx(hCBT_hook, nCode, wParam, lParam);
7173 if (nCode == HCBT_DESTROYWND)
7175 if (test_DestroyWindow_flag)
7177 DWORD style = GetWindowLongA((HWND)wParam, GWL_STYLE);
7178 if (style & WS_CHILD)
7179 lParam = GetWindowLongPtrA((HWND)wParam, GWLP_ID);
7180 else if (style & WS_POPUP)
7181 lParam = WND_POPUP_ID;
7183 lParam = WND_PARENT_ID;
7187 /* Log also SetFocus(0) calls */
7188 hwnd = wParam ? (HWND)wParam : (HWND)lParam;
7190 if (is_our_logged_class(hwnd))
7194 msg.message = nCode;
7195 msg.flags = hook|wparam|lparam;
7196 msg.wParam = wParam;
7197 msg.lParam = lParam;
7200 return CallNextHookEx(hCBT_hook, nCode, wParam, lParam);
7203 static void CALLBACK win_event_proc(HWINEVENTHOOK hevent,
7211 trace("WEH:%p,event %08x,hwnd %p,obj %08x,id %08x,thread %08x,time %08x\n",
7212 hevent, event, hwnd, object_id, child_id, thread_id, event_time);
7214 ok(thread_id == GetCurrentThreadId(), "we didn't ask for events from other threads\n");
7216 /* ignore mouse cursor events */
7217 if (object_id == OBJID_CURSOR) return;
7219 if (!hwnd || is_our_logged_class(hwnd))
7223 msg.message = event;
7224 msg.flags = winevent_hook|wparam|lparam;
7225 msg.wParam = object_id;
7226 msg.lParam = child_id;
7231 static const WCHAR wszUnicode[] = {'U','n','i','c','o','d','e',0};
7232 static const WCHAR wszAnsi[] = {'U',0};
7234 static LRESULT CALLBACK MsgConversionProcW(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
7238 case CB_FINDSTRINGEXACT:
7239 trace("String: %p\n", (LPCWSTR)lParam);
7240 if (!lstrcmpW((LPCWSTR)lParam, wszUnicode))
7242 if (!lstrcmpW((LPCWSTR)lParam, wszAnsi))
7246 return DefWindowProcW(hwnd, uMsg, wParam, lParam);
7249 static const struct message WmGetTextLengthAfromW[] = {
7250 { WM_GETTEXTLENGTH, sent },
7251 { WM_GETTEXT, sent|optional },
7255 static const WCHAR dummy_window_text[] = {'d','u','m','m','y',' ','t','e','x','t',0};
7257 /* dummy window proc for WM_GETTEXTLENGTH test */
7258 static LRESULT CALLBACK get_text_len_proc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
7262 case WM_GETTEXTLENGTH:
7263 return lstrlenW(dummy_window_text) + 37; /* some random length */
7265 lstrcpynW( (LPWSTR)lp, dummy_window_text, wp );
7266 return lstrlenW( (LPWSTR)lp );
7268 return DefWindowProcW( hwnd, msg, wp, lp );
7272 static void test_message_conversion(void)
7274 static const WCHAR wszMsgConversionClass[] =
7275 {'M','s','g','C','o','n','v','e','r','s','i','o','n','C','l','a','s','s',0};
7279 WNDPROC wndproc, newproc;
7283 cls.lpfnWndProc = MsgConversionProcW;
7286 cls.hInstance = GetModuleHandleW(NULL);
7288 cls.hCursor = LoadCursorW(NULL, (LPWSTR)IDC_ARROW);
7289 cls.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1);
7290 cls.lpszMenuName = NULL;
7291 cls.lpszClassName = wszMsgConversionClass;
7292 /* this call will fail on Win9x, but that doesn't matter as this test is
7293 * meaningless on those platforms */
7294 if(!RegisterClassW(&cls)) return;
7296 hwnd = CreateWindowExW(0, wszMsgConversionClass, NULL, WS_OVERLAPPED,
7297 100, 100, 200, 200, 0, 0, 0, NULL);
7298 ok(hwnd != NULL, "Window creation failed\n");
7302 wndproc = (WNDPROC)GetWindowLongPtrA(hwnd, GWLP_WNDPROC);
7303 lRes = CallWindowProcA(wndproc, hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
7304 ok(lRes == 0, "String should have been converted\n");
7305 lRes = CallWindowProcW(wndproc, hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
7306 ok(lRes == 1, "String shouldn't have been converted\n");
7310 wndproc = (WNDPROC)GetWindowLongPtrW(hwnd, GWLP_WNDPROC);
7311 lRes = CallWindowProcA(wndproc, hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
7312 ok(lRes == 1, "String shouldn't have been converted\n");
7313 lRes = CallWindowProcW(wndproc, hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
7314 ok(lRes == 1, "String shouldn't have been converted\n");
7316 /* Synchronous messages */
7318 lRes = SendMessageA(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
7319 ok(lRes == 0, "String should have been converted\n");
7320 lRes = SendMessageW(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
7321 ok(lRes == 1, "String shouldn't have been converted\n");
7323 /* Asynchronous messages */
7326 lRes = PostMessageA(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
7327 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
7328 "PostMessage on sync only message returned %ld, last error %d\n", lRes, GetLastError());
7330 lRes = PostMessageW(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
7331 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
7332 "PostMessage on sync only message returned %ld, last error %d\n", lRes, GetLastError());
7334 lRes = PostThreadMessageA(GetCurrentThreadId(), CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
7335 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
7336 "PosThreadtMessage on sync only message returned %ld, last error %d\n", lRes, GetLastError());
7338 lRes = PostThreadMessageW(GetCurrentThreadId(), CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
7339 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
7340 "PosThreadtMessage on sync only message returned %ld, last error %d\n", lRes, GetLastError());
7342 lRes = SendNotifyMessageA(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
7343 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
7344 "SendNotifyMessage on sync only message returned %ld, last error %d\n", lRes, GetLastError());
7346 lRes = SendNotifyMessageW(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
7347 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
7348 "SendNotifyMessage on sync only message returned %ld, last error %d\n", lRes, GetLastError());
7350 lRes = SendMessageCallbackA(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode, NULL, 0);
7351 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
7352 "SendMessageCallback on sync only message returned %ld, last error %d\n", lRes, GetLastError());
7354 lRes = SendMessageCallbackW(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode, NULL, 0);
7355 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
7356 "SendMessageCallback on sync only message returned %ld, last error %d\n", lRes, GetLastError());
7358 /* Check WM_GETTEXTLENGTH A->W behaviour, whether WM_GETTEXT is also sent or not */
7360 hwnd = CreateWindowW (testWindowClassW, wszUnicode,
7361 WS_OVERLAPPEDWINDOW,
7362 100, 100, 200, 200, 0, 0, 0, NULL);
7365 lRes = SendMessageA (hwnd, WM_GETTEXTLENGTH, 0, 0);
7366 ok_sequence(WmGetTextLengthAfromW, "ANSI WM_GETTEXTLENGTH to Unicode window", FALSE);
7367 ok( lRes == WideCharToMultiByte( CP_ACP, 0, wszUnicode, lstrlenW(wszUnicode), NULL, 0, NULL, NULL ),
7368 "got bad length %ld\n", lRes );
7371 lRes = CallWindowProcA( (WNDPROC)GetWindowLongPtrA( hwnd, GWLP_WNDPROC ),
7372 hwnd, WM_GETTEXTLENGTH, 0, 0);
7373 ok_sequence(WmGetTextLengthAfromW, "ANSI WM_GETTEXTLENGTH to Unicode window", FALSE);
7374 ok( lRes == WideCharToMultiByte( CP_ACP, 0, wszUnicode, lstrlenW(wszUnicode), NULL, 0, NULL, NULL ),
7375 "got bad length %ld\n", lRes );
7377 wndproc = (WNDPROC)SetWindowLongPtrW( hwnd, GWLP_WNDPROC, (LONG_PTR)get_text_len_proc );
7378 newproc = (WNDPROC)GetWindowLongPtrA( hwnd, GWLP_WNDPROC );
7379 lRes = CallWindowProcA( newproc, hwnd, WM_GETTEXTLENGTH, 0, 0 );
7380 ok( lRes == WideCharToMultiByte( CP_ACP, 0, dummy_window_text, lstrlenW(dummy_window_text),
7381 NULL, 0, NULL, NULL ) ||
7382 broken(lRes == lstrlenW(dummy_window_text) + 37),
7383 "got bad length %ld\n", lRes );
7385 SetWindowLongPtrW( hwnd, GWLP_WNDPROC, (LONG_PTR)wndproc ); /* restore old wnd proc */
7386 lRes = CallWindowProcA( newproc, hwnd, WM_GETTEXTLENGTH, 0, 0 );
7387 ok( lRes == WideCharToMultiByte( CP_ACP, 0, dummy_window_text, lstrlenW(dummy_window_text),
7388 NULL, 0, NULL, NULL ) ||
7389 broken(lRes == lstrlenW(dummy_window_text) + 37),
7390 "got bad length %ld\n", lRes );
7392 ret = DestroyWindow(hwnd);
7393 ok( ret, "DestroyWindow() error %d\n", GetLastError());
7403 static VOID CALLBACK tfunc(HWND hwnd, UINT uMsg, UINT_PTR id, DWORD dwTime)
7407 #define TIMER_ID 0x19
7409 static DWORD WINAPI timer_thread_proc(LPVOID x)
7411 struct timer_info *info = x;
7414 r = KillTimer(info->hWnd, 0x19);
7415 ok(r,"KillTimer failed in thread\n");
7416 r = SetTimer(info->hWnd,TIMER_ID,10000,tfunc);
7417 ok(r,"SetTimer failed in thread\n");
7418 ok(r==TIMER_ID,"SetTimer id different\n");
7419 r = SetEvent(info->handles[0]);
7420 ok(r,"SetEvent failed in thread\n");
7424 static void test_timers(void)
7426 struct timer_info info;
7429 info.hWnd = CreateWindow ("TestWindowClass", NULL,
7430 WS_OVERLAPPEDWINDOW ,
7431 CW_USEDEFAULT, CW_USEDEFAULT, 300, 300, 0,
7434 info.id = SetTimer(info.hWnd,TIMER_ID,10000,tfunc);
7435 ok(info.id, "SetTimer failed\n");
7436 ok(info.id==TIMER_ID, "SetTimer timer ID different\n");
7437 info.handles[0] = CreateEvent(NULL,0,0,NULL);
7438 info.handles[1] = CreateThread(NULL,0,timer_thread_proc,&info,0,&id);
7440 WaitForMultipleObjects(2, info.handles, FALSE, INFINITE);
7442 WaitForSingleObject(info.handles[1], INFINITE);
7444 CloseHandle(info.handles[0]);
7445 CloseHandle(info.handles[1]);
7447 ok( KillTimer(info.hWnd, TIMER_ID), "KillTimer failed\n");
7449 ok(DestroyWindow(info.hWnd), "failed to destroy window\n");
7452 static int count = 0;
7453 static VOID CALLBACK callback_count(
7463 static void test_timers_no_wnd(void)
7469 id = SetTimer(NULL, 0, 100, callback_count);
7470 ok(id != 0, "did not get id from SetTimer.\n");
7471 id2 = SetTimer(NULL, id, 200, callback_count);
7472 ok(id2 == id, "did not get same id from SetTimer when replacing (%li expected %li).\n", id2, id);
7474 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
7475 ok(count == 0, "did not get zero count as expected (%i).\n", count);
7477 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
7478 ok(count == 1, "did not get one count as expected (%i).\n", count);
7479 KillTimer(NULL, id);
7481 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
7482 ok(count == 1, "killing replaced timer did not work (%i).\n", count);
7485 /* Various win events with arbitrary parameters */
7486 static const struct message WmWinEventsSeq[] = {
7487 { EVENT_SYSTEM_SOUND, winevent_hook|wparam|lparam, OBJID_WINDOW, 0 },
7488 { EVENT_SYSTEM_ALERT, winevent_hook|wparam|lparam, OBJID_SYSMENU, 1 },
7489 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, OBJID_TITLEBAR, 2 },
7490 { EVENT_SYSTEM_MENUSTART, winevent_hook|wparam|lparam, OBJID_MENU, 3 },
7491 { EVENT_SYSTEM_MENUEND, winevent_hook|wparam|lparam, OBJID_CLIENT, 4 },
7492 { EVENT_SYSTEM_MENUPOPUPSTART, winevent_hook|wparam|lparam, OBJID_VSCROLL, 5 },
7493 { EVENT_SYSTEM_MENUPOPUPEND, winevent_hook|wparam|lparam, OBJID_HSCROLL, 6 },
7494 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, OBJID_SIZEGRIP, 7 },
7495 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, OBJID_CARET, 8 },
7496 /* our win event hook ignores OBJID_CURSOR events */
7497 /*{ EVENT_SYSTEM_MOVESIZESTART, winevent_hook|wparam|lparam, OBJID_CURSOR, 9 },*/
7498 { EVENT_SYSTEM_MOVESIZEEND, winevent_hook|wparam|lparam, OBJID_ALERT, 10 },
7499 { EVENT_SYSTEM_CONTEXTHELPSTART, winevent_hook|wparam|lparam, OBJID_SOUND, 11 },
7500 { EVENT_SYSTEM_CONTEXTHELPEND, winevent_hook|wparam|lparam, OBJID_QUERYCLASSNAMEIDX, 12 },
7501 { EVENT_SYSTEM_DRAGDROPSTART, winevent_hook|wparam|lparam, OBJID_NATIVEOM, 13 },
7502 { EVENT_SYSTEM_DRAGDROPEND, winevent_hook|wparam|lparam, OBJID_WINDOW, 0 },
7503 { EVENT_SYSTEM_DIALOGSTART, winevent_hook|wparam|lparam, OBJID_SYSMENU, 1 },
7504 { EVENT_SYSTEM_DIALOGEND, winevent_hook|wparam|lparam, OBJID_TITLEBAR, 2 },
7505 { EVENT_SYSTEM_SCROLLINGSTART, winevent_hook|wparam|lparam, OBJID_MENU, 3 },
7506 { EVENT_SYSTEM_SCROLLINGEND, winevent_hook|wparam|lparam, OBJID_CLIENT, 4 },
7507 { EVENT_SYSTEM_SWITCHSTART, winevent_hook|wparam|lparam, OBJID_VSCROLL, 5 },
7508 { EVENT_SYSTEM_SWITCHEND, winevent_hook|wparam|lparam, OBJID_HSCROLL, 6 },
7509 { EVENT_SYSTEM_MINIMIZESTART, winevent_hook|wparam|lparam, OBJID_SIZEGRIP, 7 },
7510 { EVENT_SYSTEM_MINIMIZEEND, winevent_hook|wparam|lparam, OBJID_CARET, 8 },
7513 static const struct message WmWinEventCaretSeq[] = {
7514 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1 */
7515 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1 */
7516 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 2 */
7517 { EVENT_OBJECT_NAMECHANGE, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1 */
7520 static const struct message WmWinEventCaretSeq_2[] = {
7521 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1/2 */
7522 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1/2 */
7523 { EVENT_OBJECT_NAMECHANGE, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1/2 */
7526 static const struct message WmWinEventAlertSeq[] = {
7527 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, OBJID_ALERT, 0 },
7530 static const struct message WmWinEventAlertSeq_2[] = {
7531 /* create window in the thread proc */
7532 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_WINDOW, 2 },
7533 /* our test event */
7534 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, OBJID_ALERT, 2 },
7537 static const struct message WmGlobalHookSeq_1[] = {
7538 /* create window in the thread proc */
7539 { HCBT_CREATEWND, hook|lparam, 0, 2 },
7540 /* our test events */
7541 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_PREVWINDOW, 2 },
7542 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_NEXTWINDOW, 2 },
7545 static const struct message WmGlobalHookSeq_2[] = {
7546 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_NEXTWINDOW, 0 }, /* old local hook */
7547 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_NEXTWINDOW, 2 }, /* new global hook */
7548 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_PREVWINDOW, 0 }, /* old local hook */
7549 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_PREVWINDOW, 2 }, /* new global hook */
7553 static const struct message WmMouseLLHookSeq[] = {
7554 { WM_MOUSEMOVE, hook },
7555 { WM_LBUTTONUP, hook },
7556 { WM_MOUSEMOVE, hook },
7560 static void CALLBACK win_event_global_hook_proc(HWINEVENTHOOK hevent,
7570 trace("WEH_2:%p,event %08x,hwnd %p,obj %08x,id %08x,thread %08x,time %08x\n",
7571 hevent, event, hwnd, object_id, child_id, thread_id, event_time);
7573 if (GetClassNameA(hwnd, buf, sizeof(buf)))
7575 if (!lstrcmpiA(buf, "TestWindowClass") ||
7576 !lstrcmpiA(buf, "static"))
7580 msg.message = event;
7581 msg.flags = winevent_hook|wparam|lparam;
7582 msg.wParam = object_id;
7583 msg.lParam = (thread_id == GetCurrentThreadId()) ? child_id : (child_id + 2);
7589 static HHOOK hCBT_global_hook;
7590 static DWORD cbt_global_hook_thread_id;
7592 static LRESULT CALLBACK cbt_global_hook_proc(int nCode, WPARAM wParam, LPARAM lParam)
7597 trace("CBT_2: %d, %08lx, %08lx\n", nCode, wParam, lParam);
7599 if (nCode == HCBT_SYSCOMMAND)
7603 msg.message = nCode;
7604 msg.flags = hook|wparam|lparam;
7605 msg.wParam = wParam;
7606 msg.lParam = (cbt_global_hook_thread_id == GetCurrentThreadId()) ? 1 : 2;
7609 return CallNextHookEx(hCBT_global_hook, nCode, wParam, lParam);
7611 /* WH_MOUSE_LL hook */
7612 if (nCode == HC_ACTION)
7614 MSLLHOOKSTRUCT *mhll = (MSLLHOOKSTRUCT *)lParam;
7616 /* we can't test for real mouse events */
7617 if (mhll->flags & LLMHF_INJECTED)
7621 memset (&msg, 0, sizeof (msg));
7622 msg.message = wParam;
7626 return CallNextHookEx(hCBT_global_hook, nCode, wParam, lParam);
7629 /* Log also SetFocus(0) calls */
7630 hwnd = wParam ? (HWND)wParam : (HWND)lParam;
7632 if (GetClassNameA(hwnd, buf, sizeof(buf)))
7634 if (!lstrcmpiA(buf, "TestWindowClass") ||
7635 !lstrcmpiA(buf, "static"))
7639 msg.message = nCode;
7640 msg.flags = hook|wparam|lparam;
7641 msg.wParam = wParam;
7642 msg.lParam = (cbt_global_hook_thread_id == GetCurrentThreadId()) ? 1 : 2;
7646 return CallNextHookEx(hCBT_global_hook, nCode, wParam, lParam);
7649 static DWORD WINAPI win_event_global_thread_proc(void *param)
7653 HANDLE hevent = *(HANDLE *)param;
7655 assert(pNotifyWinEvent);
7657 hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP, 0,0,0,0,0,0,0, NULL);
7659 trace("created thread window %p\n", hwnd);
7661 *(HWND *)param = hwnd;
7664 /* this event should be received only by our new hook proc,
7665 * an old one does not expect an event from another thread.
7667 pNotifyWinEvent(EVENT_OBJECT_LOCATIONCHANGE, hwnd, OBJID_ALERT, 0);
7670 while (GetMessage(&msg, 0, 0, 0))
7672 TranslateMessage(&msg);
7673 DispatchMessage(&msg);
7678 static DWORD WINAPI cbt_global_hook_thread_proc(void *param)
7682 HANDLE hevent = *(HANDLE *)param;
7685 /* these events should be received only by our new hook proc,
7686 * an old one does not expect an event from another thread.
7689 hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP, 0,0,0,0,0,0,0, NULL);
7691 trace("created thread window %p\n", hwnd);
7693 *(HWND *)param = hwnd;
7695 /* Windows doesn't like when a thread plays games with the focus,
7696 that leads to all kinds of misbehaviours and failures to activate
7697 a window. So, better keep next lines commented out.
7701 DefWindowProcA(hwnd, WM_SYSCOMMAND, SC_PREVWINDOW, 0);
7702 DefWindowProcA(hwnd, WM_SYSCOMMAND, SC_NEXTWINDOW, 0);
7706 while (GetMessage(&msg, 0, 0, 0))
7708 TranslateMessage(&msg);
7709 DispatchMessage(&msg);
7714 static DWORD WINAPI mouse_ll_global_thread_proc(void *param)
7718 HANDLE hevent = *(HANDLE *)param;
7720 hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP, 0,0,0,0,0,0,0, NULL);
7722 trace("created thread window %p\n", hwnd);
7724 *(HWND *)param = hwnd;
7728 /* Windows doesn't like when a thread plays games with the focus,
7729 * that leads to all kinds of misbehaviours and failures to activate
7730 * a window. So, better don't generate a mouse click message below.
7732 mouse_event(MOUSEEVENTF_MOVE, -1, 0, 0, 0);
7733 mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
7734 mouse_event(MOUSEEVENTF_MOVE, 1, 0, 0, 0);
7737 while (GetMessage(&msg, 0, 0, 0))
7739 TranslateMessage(&msg);
7740 DispatchMessage(&msg);
7745 static void test_winevents(void)
7751 HANDLE hthread, hevent;
7753 HWINEVENTHOOK hhook;
7754 const struct message *events = WmWinEventsSeq;
7756 hwnd = CreateWindowExA(0, "TestWindowClass", NULL,
7757 WS_OVERLAPPEDWINDOW,
7758 CW_USEDEFAULT, CW_USEDEFAULT, 300, 300, 0,
7762 /****** start of global hook test *************/
7763 hCBT_global_hook = SetWindowsHookExA(WH_CBT, cbt_global_hook_proc, GetModuleHandleA(0), 0);
7764 if (!hCBT_global_hook)
7766 ok(DestroyWindow(hwnd), "failed to destroy window\n");
7767 skip( "cannot set global hook\n" );
7771 hevent = CreateEventA(NULL, 0, 0, NULL);
7773 hwnd2 = (HWND)hevent;
7775 hthread = CreateThread(NULL, 0, cbt_global_hook_thread_proc, &hwnd2, 0, &tid);
7776 ok(hthread != NULL, "CreateThread failed, error %d\n", GetLastError());
7778 ok(WaitForSingleObject(hevent, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
7780 ok_sequence(WmGlobalHookSeq_1, "global hook 1", FALSE);
7783 /* this one should be received only by old hook proc */
7784 DefWindowProcA(hwnd, WM_SYSCOMMAND, SC_NEXTWINDOW, 0);
7785 /* this one should be received only by old hook proc */
7786 DefWindowProcA(hwnd, WM_SYSCOMMAND, SC_PREVWINDOW, 0);
7788 ok_sequence(WmGlobalHookSeq_2, "global hook 2", FALSE);
7790 ret = UnhookWindowsHookEx(hCBT_global_hook);
7791 ok( ret, "UnhookWindowsHookEx error %d\n", GetLastError());
7793 PostThreadMessageA(tid, WM_QUIT, 0, 0);
7794 ok(WaitForSingleObject(hthread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
7795 CloseHandle(hthread);
7796 CloseHandle(hevent);
7797 ok(!IsWindow(hwnd2), "window should be destroyed on thread exit\n");
7798 /****** end of global hook test *************/
7800 if (!pSetWinEventHook || !pNotifyWinEvent || !pUnhookWinEvent)
7802 ok(DestroyWindow(hwnd), "failed to destroy window\n");
7810 /* this test doesn't pass under Win9x */
7811 /* win2k ignores events with hwnd == 0 */
7812 SetLastError(0xdeadbeef);
7813 pNotifyWinEvent(events[0].message, 0, events[0].wParam, events[0].lParam);
7814 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE || /* Win2k */
7815 GetLastError() == 0xdeadbeef, /* Win9x */
7816 "unexpected error %d\n", GetLastError());
7817 ok_sequence(WmEmptySeq, "empty notify winevents", FALSE);
7820 for (i = 0; i < sizeof(WmWinEventsSeq)/sizeof(WmWinEventsSeq[0]); i++)
7821 pNotifyWinEvent(events[i].message, hwnd, events[i].wParam, events[i].lParam);
7823 ok_sequence(WmWinEventsSeq, "notify winevents", FALSE);
7825 /****** start of event filtering test *************/
7826 hhook = (HWINEVENTHOOK)pSetWinEventHook(
7827 EVENT_OBJECT_SHOW, /* 0x8002 */
7828 EVENT_OBJECT_LOCATIONCHANGE, /* 0x800B */
7829 GetModuleHandleA(0), win_event_global_hook_proc,
7830 GetCurrentProcessId(), 0,
7831 WINEVENT_INCONTEXT);
7832 ok(hhook != 0, "SetWinEventHook error %d\n", GetLastError());
7834 hevent = CreateEventA(NULL, 0, 0, NULL);
7836 hwnd2 = (HWND)hevent;
7838 hthread = CreateThread(NULL, 0, win_event_global_thread_proc, &hwnd2, 0, &tid);
7839 ok(hthread != NULL, "CreateThread failed, error %d\n", GetLastError());
7841 ok(WaitForSingleObject(hevent, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
7843 ok_sequence(WmWinEventAlertSeq, "alert winevent", FALSE);
7846 /* this one should be received only by old hook proc */
7847 pNotifyWinEvent(EVENT_OBJECT_CREATE, hwnd, OBJID_CARET, 0); /* 0x8000 */
7848 pNotifyWinEvent(EVENT_OBJECT_SHOW, hwnd, OBJID_CARET, 0); /* 0x8002 */
7849 /* this one should be received only by old hook proc */
7850 pNotifyWinEvent(EVENT_OBJECT_NAMECHANGE, hwnd, OBJID_CARET, 0); /* 0x800C */
7852 ok_sequence(WmWinEventCaretSeq, "caret winevent", FALSE);
7854 ret = pUnhookWinEvent(hhook);
7855 ok( ret, "UnhookWinEvent error %d\n", GetLastError());
7857 PostThreadMessageA(tid, WM_QUIT, 0, 0);
7858 ok(WaitForSingleObject(hthread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
7859 CloseHandle(hthread);
7860 CloseHandle(hevent);
7861 ok(!IsWindow(hwnd2), "window should be destroyed on thread exit\n");
7862 /****** end of event filtering test *************/
7864 /****** start of out of context event test *************/
7865 hhook = (HWINEVENTHOOK)pSetWinEventHook(
7866 EVENT_MIN, EVENT_MAX,
7867 0, win_event_global_hook_proc,
7868 GetCurrentProcessId(), 0,
7869 WINEVENT_OUTOFCONTEXT);
7870 ok(hhook != 0, "SetWinEventHook error %d\n", GetLastError());
7872 hevent = CreateEventA(NULL, 0, 0, NULL);
7874 hwnd2 = (HWND)hevent;
7878 hthread = CreateThread(NULL, 0, win_event_global_thread_proc, &hwnd2, 0, &tid);
7879 ok(hthread != NULL, "CreateThread failed, error %d\n", GetLastError());
7881 ok(WaitForSingleObject(hevent, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
7883 ok_sequence(WmEmptySeq, "empty notify winevents", FALSE);
7884 /* process pending winevent messages */
7885 ok(!PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE), "msg queue should be empty\n");
7886 ok_sequence(WmWinEventAlertSeq_2, "alert winevent for out of context proc", FALSE);
7889 /* this one should be received only by old hook proc */
7890 pNotifyWinEvent(EVENT_OBJECT_CREATE, hwnd, OBJID_CARET, 0); /* 0x8000 */
7891 pNotifyWinEvent(EVENT_OBJECT_SHOW, hwnd, OBJID_CARET, 0); /* 0x8002 */
7892 /* this one should be received only by old hook proc */
7893 pNotifyWinEvent(EVENT_OBJECT_NAMECHANGE, hwnd, OBJID_CARET, 0); /* 0x800C */
7895 ok_sequence(WmWinEventCaretSeq_2, "caret winevent for incontext proc", FALSE);
7896 /* process pending winevent messages */
7897 ok(!PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE), "msg queue should be empty\n");
7898 ok_sequence(WmWinEventCaretSeq_2, "caret winevent for out of context proc", FALSE);
7900 ret = pUnhookWinEvent(hhook);
7901 ok( ret, "UnhookWinEvent error %d\n", GetLastError());
7903 PostThreadMessageA(tid, WM_QUIT, 0, 0);
7904 ok(WaitForSingleObject(hthread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
7905 CloseHandle(hthread);
7906 CloseHandle(hevent);
7907 ok(!IsWindow(hwnd2), "window should be destroyed on thread exit\n");
7908 /****** end of out of context event test *************/
7910 /****** start of MOUSE_LL hook test *************/
7911 hCBT_global_hook = SetWindowsHookExA(WH_MOUSE_LL, cbt_global_hook_proc, GetModuleHandleA(0), 0);
7912 /* WH_MOUSE_LL is not supported on Win9x platforms */
7913 if (!hCBT_global_hook)
7915 trace("Skipping WH_MOUSE_LL test on this platform\n");
7916 goto skip_mouse_ll_hook_test;
7919 hevent = CreateEventA(NULL, 0, 0, NULL);
7921 hwnd2 = (HWND)hevent;
7923 hthread = CreateThread(NULL, 0, mouse_ll_global_thread_proc, &hwnd2, 0, &tid);
7924 ok(hthread != NULL, "CreateThread failed, error %d\n", GetLastError());
7926 while (WaitForSingleObject(hevent, 100) == WAIT_TIMEOUT)
7927 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
7929 ok_sequence(WmMouseLLHookSeq, "MOUSE_LL hook other thread", FALSE);
7932 mouse_event(MOUSEEVENTF_MOVE, -1, 0, 0, 0);
7933 mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
7934 mouse_event(MOUSEEVENTF_MOVE, 1, 0, 0, 0);
7936 ok_sequence(WmMouseLLHookSeq, "MOUSE_LL hook same thread", FALSE);
7938 ret = UnhookWindowsHookEx(hCBT_global_hook);
7939 ok( ret, "UnhookWindowsHookEx error %d\n", GetLastError());
7941 PostThreadMessageA(tid, WM_QUIT, 0, 0);
7942 ok(WaitForSingleObject(hthread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
7943 CloseHandle(hthread);
7944 CloseHandle(hevent);
7945 ok(!IsWindow(hwnd2), "window should be destroyed on thread exit\n");
7946 /****** end of MOUSE_LL hook test *************/
7947 skip_mouse_ll_hook_test:
7949 ok(DestroyWindow(hwnd), "failed to destroy window\n");
7952 static void test_set_hook(void)
7956 HWINEVENTHOOK hwinevent_hook;
7958 hhook = SetWindowsHookExA(WH_CBT, cbt_hook_proc, GetModuleHandleA(0), GetCurrentThreadId());
7959 ok(hhook != 0, "local hook does not require hModule set to 0\n");
7960 UnhookWindowsHookEx(hhook);
7964 /* this test doesn't pass under Win9x: BUG! */
7965 SetLastError(0xdeadbeef);
7966 hhook = SetWindowsHookExA(WH_CBT, cbt_hook_proc, 0, 0);
7967 ok(!hhook, "global hook requires hModule != 0\n");
7968 ok(GetLastError() == ERROR_HOOK_NEEDS_HMOD, "unexpected error %d\n", GetLastError());
7971 SetLastError(0xdeadbeef);
7972 hhook = SetWindowsHookExA(WH_CBT, 0, GetModuleHandleA(0), GetCurrentThreadId());
7973 ok(!hhook, "SetWinEventHook with invalid proc should fail\n");
7974 ok(GetLastError() == ERROR_INVALID_FILTER_PROC || /* Win2k */
7975 GetLastError() == 0xdeadbeef, /* Win9x */
7976 "unexpected error %d\n", GetLastError());
7978 SetLastError(0xdeadbeef);
7979 ok(!UnhookWindowsHookEx((HHOOK)0xdeadbeef), "UnhookWindowsHookEx succeeded\n");
7980 ok(GetLastError() == ERROR_INVALID_HOOK_HANDLE || /* Win2k */
7981 GetLastError() == 0xdeadbeef, /* Win9x */
7982 "unexpected error %d\n", GetLastError());
7984 if (!pSetWinEventHook || !pUnhookWinEvent) return;
7986 /* even process local incontext hooks require hmodule */
7987 SetLastError(0xdeadbeef);
7988 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(EVENT_MIN, EVENT_MAX,
7989 0, win_event_proc, GetCurrentProcessId(), 0, WINEVENT_INCONTEXT);
7990 ok(!hwinevent_hook, "WINEVENT_INCONTEXT requires hModule != 0\n");
7991 ok(GetLastError() == ERROR_HOOK_NEEDS_HMOD || /* Win2k */
7992 GetLastError() == 0xdeadbeef, /* Win9x */
7993 "unexpected error %d\n", GetLastError());
7995 /* even thread local incontext hooks require hmodule */
7996 SetLastError(0xdeadbeef);
7997 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(EVENT_MIN, EVENT_MAX,
7998 0, win_event_proc, GetCurrentProcessId(), GetCurrentThreadId(), WINEVENT_INCONTEXT);
7999 ok(!hwinevent_hook, "WINEVENT_INCONTEXT requires hModule != 0\n");
8000 ok(GetLastError() == ERROR_HOOK_NEEDS_HMOD || /* Win2k */
8001 GetLastError() == 0xdeadbeef, /* Win9x */
8002 "unexpected error %d\n", GetLastError());
8006 /* these 3 tests don't pass under Win9x */
8007 SetLastError(0xdeadbeef);
8008 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(1, 0,
8009 0, win_event_proc, GetCurrentProcessId(), 0, WINEVENT_OUTOFCONTEXT);
8010 ok(!hwinevent_hook, "SetWinEventHook with invalid event range should fail\n");
8011 ok(GetLastError() == ERROR_INVALID_HOOK_FILTER, "unexpected error %d\n", GetLastError());
8013 SetLastError(0xdeadbeef);
8014 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(-1, 1,
8015 0, win_event_proc, GetCurrentProcessId(), 0, WINEVENT_OUTOFCONTEXT);
8016 ok(!hwinevent_hook, "SetWinEventHook with invalid event range should fail\n");
8017 ok(GetLastError() == ERROR_INVALID_HOOK_FILTER, "unexpected error %d\n", GetLastError());
8019 SetLastError(0xdeadbeef);
8020 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(EVENT_MIN, EVENT_MAX,
8021 0, win_event_proc, 0, 0xdeadbeef, WINEVENT_OUTOFCONTEXT);
8022 ok(!hwinevent_hook, "SetWinEventHook with invalid tid should fail\n");
8023 ok(GetLastError() == ERROR_INVALID_THREAD_ID, "unexpected error %d\n", GetLastError());
8026 SetLastError(0xdeadbeef);
8027 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(0, 0,
8028 0, win_event_proc, GetCurrentProcessId(), 0, WINEVENT_OUTOFCONTEXT);
8029 ok(hwinevent_hook != 0, "SetWinEventHook error %d\n", GetLastError());
8030 ok(GetLastError() == 0xdeadbeef, "unexpected error %d\n", GetLastError());
8031 ret = pUnhookWinEvent(hwinevent_hook);
8032 ok( ret, "UnhookWinEvent error %d\n", GetLastError());
8035 /* This call succeeds under win2k SP4, but fails under Wine.
8036 Does win2k test/use passed process id? */
8037 SetLastError(0xdeadbeef);
8038 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(EVENT_MIN, EVENT_MAX,
8039 0, win_event_proc, 0xdeadbeef, 0, WINEVENT_OUTOFCONTEXT);
8040 ok(hwinevent_hook != 0, "SetWinEventHook error %d\n", GetLastError());
8041 ok(GetLastError() == 0xdeadbeef, "unexpected error %d\n", GetLastError());
8042 ret = pUnhookWinEvent(hwinevent_hook);
8043 ok( ret, "UnhookWinEvent error %d\n", GetLastError());
8046 SetLastError(0xdeadbeef);
8047 ok(!pUnhookWinEvent((HWINEVENTHOOK)0xdeadbeef), "UnhookWinEvent succeeded\n");
8048 ok(GetLastError() == ERROR_INVALID_HANDLE || /* Win2k */
8049 GetLastError() == 0xdeadbeef, /* Win9x */
8050 "unexpected error %d\n", GetLastError());
8053 static const struct message ScrollWindowPaint1[] = {
8055 { WM_ERASEBKGND, sent|beginpaint },
8059 static const struct message ScrollWindowPaint2[] = {
8064 static void test_scrollwindowex(void)
8067 RECT rect={0,0,130,130};
8069 hwnd = CreateWindowExA(0, "TestWindowClass", "Test Scroll",
8070 WS_VISIBLE|WS_OVERLAPPEDWINDOW,
8071 100, 100, 200, 200, 0, 0, 0, NULL);
8072 ok (hwnd != 0, "Failed to create overlapped window\n");
8073 hchild = CreateWindowExA(0, "TestWindowClass", "Test child",
8074 WS_VISIBLE|WS_CAPTION|WS_CHILD,
8075 10, 10, 150, 150, hwnd, 0, 0, NULL);
8076 ok (hchild != 0, "Failed to create child\n");
8081 /* scroll without the child window */
8082 trace("start scroll\n");
8083 ScrollWindowEx( hwnd, 10, 10, &rect, NULL, NULL, NULL,
8084 SW_ERASE|SW_INVALIDATE);
8085 ok_sequence(WmEmptySeq, "ScrollWindowEx", 0);
8086 trace("end scroll\n");
8089 ok_sequence(ScrollWindowPaint1, "ScrollWindowEx", 0);
8093 /* Now without the SW_ERASE flag */
8094 trace("start scroll\n");
8095 ScrollWindowEx( hwnd, 10, 10, &rect, NULL, NULL, NULL, SW_INVALIDATE);
8096 ok_sequence(WmEmptySeq, "ScrollWindowEx", 0);
8097 trace("end scroll\n");
8100 ok_sequence(ScrollWindowPaint2, "ScrollWindowEx", 0);
8104 /* now scroll the child window as well */
8105 trace("start scroll\n");
8106 ScrollWindowEx( hwnd, 10, 10, &rect, NULL, NULL, NULL,
8107 SW_SCROLLCHILDREN|SW_ERASE|SW_INVALIDATE);
8108 todo_wine { /* wine sends WM_POSCHANGING, WM_POSCHANGED messages */
8109 /* windows sometimes a WM_MOVE */
8110 ok_sequence(WmEmptySeq, "ScrollWindowEx", 0);
8112 trace("end scroll\n");
8115 ok_sequence(ScrollWindowPaint1, "ScrollWindowEx", 0);
8119 /* now scroll with ScrollWindow() */
8120 trace("start scroll with ScrollWindow\n");
8121 ScrollWindow( hwnd, 5, 5, NULL, NULL);
8122 trace("end scroll\n");
8125 ok_sequence(ScrollWindowPaint1, "ScrollWindow", 0);
8127 ok(DestroyWindow(hchild), "failed to destroy window\n");
8128 ok(DestroyWindow(hwnd), "failed to destroy window\n");
8132 static const struct message destroy_window_with_children[] = {
8133 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 }, /* popup */
8134 { HCBT_DESTROYWND, hook|lparam, 0, WND_PARENT_ID }, /* parent */
8135 { 0x0090, sent|optional },
8136 { HCBT_DESTROYWND, hook|lparam, 0, WND_POPUP_ID }, /* popup */
8137 { 0x0090, sent|optional },
8138 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 }, /* popup */
8139 { WM_DESTROY, sent|wparam|lparam, 0, WND_POPUP_ID }, /* popup */
8140 { WM_CAPTURECHANGED, sent|wparam|lparam, 0, WND_POPUP_ID }, /* popup */
8141 { WM_NCDESTROY, sent|wparam|lparam, 0, WND_POPUP_ID }, /* popup */
8142 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 }, /* parent */
8143 { WM_DESTROY, sent|wparam|lparam, 0, WND_PARENT_ID }, /* parent */
8144 { WM_DESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 2 }, /* child2 */
8145 { WM_DESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 1 }, /* child1 */
8146 { WM_DESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 3 }, /* child3 */
8147 { WM_NCDESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 2 }, /* child2 */
8148 { WM_NCDESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 3 }, /* child3 */
8149 { WM_NCDESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 1 }, /* child1 */
8150 { WM_NCDESTROY, sent|wparam|lparam, 0, WND_PARENT_ID }, /* parent */
8154 static void test_DestroyWindow(void)
8157 HWND parent, child1, child2, child3, child4, test;
8158 UINT child_id = WND_CHILD_ID + 1;
8160 parent = CreateWindowExA(0, "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW,
8161 100, 100, 200, 200, 0, 0, 0, NULL);
8162 assert(parent != 0);
8163 child1 = CreateWindowExA(0, "TestWindowClass", NULL, WS_CHILD,
8164 0, 0, 50, 50, parent, (HMENU)child_id++, 0, NULL);
8165 assert(child1 != 0);
8166 child2 = CreateWindowExA(0, "TestWindowClass", NULL, WS_CHILD,
8167 0, 0, 50, 50, GetDesktopWindow(), (HMENU)child_id++, 0, NULL);
8168 assert(child2 != 0);
8169 child3 = CreateWindowExA(0, "TestWindowClass", NULL, WS_CHILD,
8170 0, 0, 50, 50, child1, (HMENU)child_id++, 0, NULL);
8171 assert(child3 != 0);
8172 child4 = CreateWindowExA(0, "TestWindowClass", NULL, WS_POPUP,
8173 0, 0, 50, 50, parent, 0, 0, NULL);
8174 assert(child4 != 0);
8176 /* test owner/parent of child2 */
8177 test = GetParent(child2);
8178 ok(test == GetDesktopWindow(), "wrong parent %p\n", test);
8179 ok(!IsChild(parent, child2), "wrong parent/child %p/%p\n", parent, child2);
8181 test = pGetAncestor(child2, GA_PARENT);
8182 ok(test == GetDesktopWindow(), "wrong parent %p\n", test);
8184 test = GetWindow(child2, GW_OWNER);
8185 ok(!test, "wrong owner %p\n", test);
8187 test = SetParent(child2, parent);
8188 ok(test == GetDesktopWindow(), "wrong old parent %p\n", test);
8190 /* test owner/parent of the parent */
8191 test = GetParent(parent);
8192 ok(!test, "wrong parent %p\n", test);
8193 ok(!IsChild(GetDesktopWindow(), parent), "wrong parent/child %p/%p\n", GetDesktopWindow(), parent);
8195 test = pGetAncestor(parent, GA_PARENT);
8196 ok(test == GetDesktopWindow(), "wrong parent %p\n", test);
8198 test = GetWindow(parent, GW_OWNER);
8199 ok(!test, "wrong owner %p\n", test);
8201 /* test owner/parent of child1 */
8202 test = GetParent(child1);
8203 ok(test == parent, "wrong parent %p\n", test);
8204 ok(IsChild(parent, child1), "wrong parent/child %p/%p\n", parent, child1);
8206 test = pGetAncestor(child1, GA_PARENT);
8207 ok(test == parent, "wrong parent %p\n", test);
8209 test = GetWindow(child1, GW_OWNER);
8210 ok(!test, "wrong owner %p\n", test);
8212 /* test owner/parent of child2 */
8213 test = GetParent(child2);
8214 ok(test == parent, "wrong parent %p\n", test);
8215 ok(IsChild(parent, child2), "wrong parent/child %p/%p\n", parent, child2);
8217 test = pGetAncestor(child2, GA_PARENT);
8218 ok(test == parent, "wrong parent %p\n", test);
8220 test = GetWindow(child2, GW_OWNER);
8221 ok(!test, "wrong owner %p\n", test);
8223 /* test owner/parent of child3 */
8224 test = GetParent(child3);
8225 ok(test == child1, "wrong parent %p\n", test);
8226 ok(IsChild(parent, child3), "wrong parent/child %p/%p\n", parent, child3);
8228 test = pGetAncestor(child3, GA_PARENT);
8229 ok(test == child1, "wrong parent %p\n", test);
8231 test = GetWindow(child3, GW_OWNER);
8232 ok(!test, "wrong owner %p\n", test);
8234 /* test owner/parent of child4 */
8235 test = GetParent(child4);
8236 ok(test == parent, "wrong parent %p\n", test);
8237 ok(!IsChild(parent, child4), "wrong parent/child %p/%p\n", parent, child4);
8239 test = pGetAncestor(child4, GA_PARENT);
8240 ok(test == GetDesktopWindow(), "wrong parent %p\n", test);
8242 test = GetWindow(child4, GW_OWNER);
8243 ok(test == parent, "wrong owner %p\n", test);
8247 trace("parent %p, child1 %p, child2 %p, child3 %p, child4 %p\n",
8248 parent, child1, child2, child3, child4);
8251 test = GetCapture();
8252 ok(test == child4, "wrong capture window %p\n", test);
8254 test_DestroyWindow_flag = TRUE;
8255 ret = DestroyWindow(parent);
8256 ok( ret, "DestroyWindow() error %d\n", GetLastError());
8257 test_DestroyWindow_flag = FALSE;
8258 ok_sequence(destroy_window_with_children, "destroy window with children", 0);
8260 ok(!IsWindow(parent), "parent still exists\n");
8261 ok(!IsWindow(child1), "child1 still exists\n");
8262 ok(!IsWindow(child2), "child2 still exists\n");
8263 ok(!IsWindow(child3), "child3 still exists\n");
8264 ok(!IsWindow(child4), "child4 still exists\n");
8266 test = GetCapture();
8267 ok(!test, "wrong capture window %p\n", test);
8271 static const struct message WmDispatchPaint[] = {
8272 { WM_NCPAINT, sent },
8273 { WM_GETTEXT, sent|defwinproc|optional },
8274 { WM_GETTEXT, sent|defwinproc|optional },
8275 { WM_ERASEBKGND, sent },
8279 static LRESULT WINAPI DispatchMessageCheckProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
8281 if (message == WM_PAINT) return 0;
8282 return MsgCheckProcA( hwnd, message, wParam, lParam );
8285 static void test_DispatchMessage(void)
8290 HWND hwnd = CreateWindowA( "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW,
8291 100, 100, 200, 200, 0, 0, 0, NULL);
8292 ShowWindow( hwnd, SW_SHOW );
8293 UpdateWindow( hwnd );
8296 SetWindowLongPtrA( hwnd, GWLP_WNDPROC, (LONG_PTR)DispatchMessageCheckProc );
8298 SetRect( &rect, -5, -5, 5, 5 );
8299 RedrawWindow( hwnd, &rect, 0, RDW_INVALIDATE|RDW_ERASE|RDW_FRAME );
8301 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE ))
8303 if (msg.message != WM_PAINT) DispatchMessage( &msg );
8307 DispatchMessage( &msg );
8308 /* DispatchMessage will send WM_NCPAINT if non client area is still invalid after WM_PAINT */
8309 if (!count) ok_sequence( WmDispatchPaint, "WmDispatchPaint", FALSE );
8310 else ok_sequence( WmEmptySeq, "WmEmpty", FALSE );
8311 if (++count > 10) break;
8314 ok( msg.message == WM_PAINT && count > 10, "WM_PAINT messages stopped\n" );
8316 trace("now without DispatchMessage\n");
8318 RedrawWindow( hwnd, &rect, 0, RDW_INVALIDATE|RDW_ERASE|RDW_FRAME );
8320 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE ))
8322 if (msg.message != WM_PAINT) DispatchMessage( &msg );
8325 HRGN hrgn = CreateRectRgn( 0, 0, 0, 0 );
8327 /* this will send WM_NCCPAINT just like DispatchMessage does */
8328 GetUpdateRgn( hwnd, hrgn, TRUE );
8329 ok_sequence( WmDispatchPaint, "WmDispatchPaint", FALSE );
8330 DeleteObject( hrgn );
8331 GetClientRect( hwnd, &rect );
8332 ValidateRect( hwnd, &rect ); /* this will stop WM_PAINTs */
8333 ok( !count, "Got multiple WM_PAINTs\n" );
8334 if (++count > 10) break;
8337 DestroyWindow(hwnd);
8341 static const struct message WmUser[] = {
8353 static DWORD CALLBACK send_msg_thread( LPVOID arg )
8355 struct sendmsg_info *info = arg;
8356 info->ret = SendMessageTimeoutA( info->hwnd, WM_USER, 0, 0, 0, info->timeout, NULL );
8357 if (!info->ret) ok( GetLastError() == ERROR_TIMEOUT, "unexpected error %d\n", GetLastError());
8361 static void wait_for_thread( HANDLE thread )
8363 while (MsgWaitForMultipleObjects(1, &thread, FALSE, INFINITE, QS_SENDMESSAGE) != WAIT_OBJECT_0)
8366 while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage(&msg);
8370 static LRESULT WINAPI send_msg_delay_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
8372 if (message == WM_USER) Sleep(200);
8373 return MsgCheckProcA( hwnd, message, wParam, lParam );
8376 static void test_SendMessageTimeout(void)
8379 struct sendmsg_info info;
8382 info.hwnd = CreateWindowA( "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW,
8383 100, 100, 200, 200, 0, 0, 0, NULL);
8387 info.timeout = 1000;
8388 info.ret = 0xdeadbeef;
8389 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid );
8390 wait_for_thread( thread );
8391 CloseHandle( thread );
8392 ok( info.ret == 1, "SendMessageTimeout failed\n" );
8393 ok_sequence( WmUser, "WmUser", FALSE );
8396 info.ret = 0xdeadbeef;
8397 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid );
8398 Sleep(100); /* SendMessageTimeout should time out here */
8399 wait_for_thread( thread );
8400 CloseHandle( thread );
8401 ok( info.ret == 0, "SendMessageTimeout succeeded\n" );
8402 ok_sequence( WmEmptySeq, "WmEmptySeq", FALSE );
8404 /* 0 means infinite timeout */
8406 info.ret = 0xdeadbeef;
8407 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid );
8409 wait_for_thread( thread );
8410 CloseHandle( thread );
8411 ok( info.ret == 1, "SendMessageTimeout failed\n" );
8412 ok_sequence( WmUser, "WmUser", FALSE );
8414 /* timeout is treated as signed despite the prototype */
8415 info.timeout = 0x7fffffff;
8416 info.ret = 0xdeadbeef;
8417 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid );
8419 wait_for_thread( thread );
8420 CloseHandle( thread );
8421 ok( info.ret == 1, "SendMessageTimeout failed\n" );
8422 ok_sequence( WmUser, "WmUser", FALSE );
8424 info.timeout = 0x80000000;
8425 info.ret = 0xdeadbeef;
8426 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid );
8428 wait_for_thread( thread );
8429 CloseHandle( thread );
8430 ok( info.ret == 0, "SendMessageTimeout succeeded\n" );
8431 ok_sequence( WmEmptySeq, "WmEmptySeq", FALSE );
8433 /* now check for timeout during message processing */
8434 SetWindowLongPtrA( info.hwnd, GWLP_WNDPROC, (LONG_PTR)send_msg_delay_proc );
8436 info.ret = 0xdeadbeef;
8437 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid );
8438 wait_for_thread( thread );
8439 CloseHandle( thread );
8440 /* we should time out but still get the message */
8441 ok( info.ret == 0, "SendMessageTimeout failed\n" );
8442 ok_sequence( WmUser, "WmUser", FALSE );
8444 DestroyWindow( info.hwnd );
8448 /****************** edit message test *************************/
8449 #define ID_EDIT 0x1234
8450 static const struct message sl_edit_setfocus[] =
8452 { HCBT_SETFOCUS, hook },
8453 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
8454 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
8455 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
8456 { WM_SETFOCUS, sent|wparam, 0 },
8457 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 10 },
8458 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 15 },
8459 { WM_CTLCOLOREDIT, sent|parent },
8460 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 11 },
8461 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8462 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8463 { WM_COMMAND, sent|parent|wparam, MAKEWPARAM(ID_EDIT, EN_SETFOCUS) },
8466 static const struct message ml_edit_setfocus[] =
8468 { HCBT_SETFOCUS, hook },
8469 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
8470 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
8471 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
8472 { WM_SETFOCUS, sent|wparam, 0 },
8473 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 10 },
8474 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 11 },
8475 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8476 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8477 { WM_COMMAND, sent|parent|wparam, MAKEWPARAM(ID_EDIT, EN_SETFOCUS) },
8480 static const struct message sl_edit_killfocus[] =
8482 { HCBT_SETFOCUS, hook },
8483 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
8484 { WM_KILLFOCUS, sent|wparam, 0 },
8485 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8486 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8487 { WM_COMMAND, sent|parent|wparam, MAKEWPARAM(ID_EDIT, EN_KILLFOCUS) },
8488 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
8489 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 1 },
8492 static const struct message sl_edit_lbutton_dblclk[] =
8494 { WM_LBUTTONDBLCLK, sent },
8495 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
8498 static const struct message sl_edit_lbutton_down[] =
8500 { WM_LBUTTONDOWN, sent|wparam|lparam, 0, 0 },
8501 { HCBT_SETFOCUS, hook },
8502 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
8503 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
8504 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
8505 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
8506 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 10 },
8507 { WM_CTLCOLOREDIT, sent|parent },
8508 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 11 },
8509 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8510 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8511 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8512 { WM_COMMAND, sent|parent|wparam, MAKEWPARAM(ID_EDIT, EN_SETFOCUS) },
8513 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
8514 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8515 { WM_CTLCOLOREDIT, sent|parent|optional },
8516 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 11 },
8517 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8518 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8521 static const struct message ml_edit_lbutton_down[] =
8523 { WM_LBUTTONDOWN, sent|wparam|lparam, 0, 0 },
8524 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
8525 { HCBT_SETFOCUS, hook },
8526 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
8527 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
8528 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
8529 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
8530 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 10 },
8531 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 11 },
8532 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8533 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8534 { WM_COMMAND, sent|parent|wparam, MAKEWPARAM(ID_EDIT, EN_SETFOCUS) },
8537 static const struct message sl_edit_lbutton_up[] =
8539 { WM_LBUTTONUP, sent|wparam|lparam, 0, 0 },
8540 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8541 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, 0, 0 },
8542 { WM_CAPTURECHANGED, sent|defwinproc },
8543 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8546 static const struct message ml_edit_lbutton_up[] =
8548 { WM_LBUTTONUP, sent|wparam|lparam, 0, 0 },
8549 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, 0, 0 },
8550 { WM_CAPTURECHANGED, sent|defwinproc },
8554 static WNDPROC old_edit_proc;
8556 static LRESULT CALLBACK edit_hook_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
8558 static long defwndproc_counter = 0;
8562 trace("edit: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
8564 /* explicitly ignore WM_GETICON message */
8565 if (message == WM_GETICON) return 0;
8567 msg.message = message;
8568 msg.flags = sent|wparam|lparam;
8569 if (defwndproc_counter) msg.flags |= defwinproc;
8570 msg.wParam = wParam;
8571 msg.lParam = lParam;
8574 defwndproc_counter++;
8575 ret = CallWindowProcA(old_edit_proc, hwnd, message, wParam, lParam);
8576 defwndproc_counter--;
8581 static void subclass_edit(void)
8585 if (!GetClassInfoA(0, "edit", &cls)) assert(0);
8587 old_edit_proc = cls.lpfnWndProc;
8589 cls.hInstance = GetModuleHandle(0);
8590 cls.lpfnWndProc = edit_hook_proc;
8591 cls.lpszClassName = "my_edit_class";
8592 UnregisterClass(cls.lpszClassName, cls.hInstance);
8593 if (!RegisterClassA(&cls)) assert(0);
8596 static void test_edit_messages(void)
8602 log_all_parent_messages++;
8604 parent = CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
8605 100, 100, 200, 200, 0, 0, 0, NULL);
8606 ok (parent != 0, "Failed to create parent window\n");
8608 /* test single line edit */
8609 hwnd = CreateWindowExA(0, "my_edit_class", "test", WS_CHILD,
8610 0, 0, 80, 20, parent, (HMENU)ID_EDIT, 0, NULL);
8611 ok(hwnd != 0, "Failed to create edit window\n");
8613 dlg_code = SendMessageA(hwnd, WM_GETDLGCODE, 0, 0);
8614 ok(dlg_code == (DLGC_WANTCHARS|DLGC_HASSETSEL|DLGC_WANTARROWS), "wrong dlg_code %08x\n", dlg_code);
8616 ShowWindow(hwnd, SW_SHOW);
8622 ok_sequence(sl_edit_setfocus, "SetFocus(hwnd) on an edit", FALSE);
8625 ok_sequence(sl_edit_killfocus, "SetFocus(0) on an edit", FALSE);
8631 SendMessageA(hwnd, WM_LBUTTONDBLCLK, 0, 0);
8632 ok_sequence(sl_edit_lbutton_dblclk, "WM_LBUTTONDBLCLK on an edit", FALSE);
8638 SendMessageA(hwnd, WM_LBUTTONDOWN, 0, 0);
8639 ok_sequence(sl_edit_lbutton_down, "WM_LBUTTONDOWN on an edit", FALSE);
8641 SendMessageA(hwnd, WM_LBUTTONUP, 0, 0);
8642 ok_sequence(sl_edit_lbutton_up, "WM_LBUTTONUP on an edit", FALSE);
8644 DestroyWindow(hwnd);
8646 /* test multiline edit */
8647 hwnd = CreateWindowExA(0, "my_edit_class", "test", WS_CHILD | ES_MULTILINE,
8648 0, 0, 80, 20, parent, (HMENU)ID_EDIT, 0, NULL);
8649 ok(hwnd != 0, "Failed to create edit window\n");
8651 dlg_code = SendMessageA(hwnd, WM_GETDLGCODE, 0, 0);
8652 ok(dlg_code == (DLGC_WANTCHARS|DLGC_HASSETSEL|DLGC_WANTARROWS|DLGC_WANTALLKEYS),
8653 "wrong dlg_code %08x\n", dlg_code);
8655 ShowWindow(hwnd, SW_SHOW);
8661 ok_sequence(ml_edit_setfocus, "SetFocus(hwnd) on multiline edit", FALSE);
8664 ok_sequence(sl_edit_killfocus, "SetFocus(0) on multiline edit", FALSE);
8670 SendMessageA(hwnd, WM_LBUTTONDBLCLK, 0, 0);
8671 ok_sequence(sl_edit_lbutton_dblclk, "WM_LBUTTONDBLCLK on multiline edit", FALSE);
8677 SendMessageA(hwnd, WM_LBUTTONDOWN, 0, 0);
8678 ok_sequence(ml_edit_lbutton_down, "WM_LBUTTONDOWN on multiline edit", FALSE);
8680 SendMessageA(hwnd, WM_LBUTTONUP, 0, 0);
8681 ok_sequence(ml_edit_lbutton_up, "WM_LBUTTONUP on multiline edit", FALSE);
8683 DestroyWindow(hwnd);
8684 DestroyWindow(parent);
8686 log_all_parent_messages--;
8689 /**************************** End of Edit test ******************************/
8691 static const struct message WmKeyDownSkippedSeq[] =
8693 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 1 }, /* XP */
8696 static const struct message WmKeyUpSkippedSeq[] =
8698 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xc0000001 }, /* XP */
8703 #define EV_SENDMSG 1
8709 HANDLE hevent[3]; /* 0 - start/stop, 1 - SendMessage, 2 - ack */
8712 static DWORD CALLBACK send_msg_thread_2(void *param)
8715 struct peekmsg_info *info = param;
8717 trace("thread: looping\n");
8718 SetEvent(info->hevent[EV_ACK]);
8722 ret = WaitForMultipleObjects(2, info->hevent, FALSE, INFINITE);
8726 case WAIT_OBJECT_0 + EV_STOP:
8727 trace("thread: exiting\n");
8730 case WAIT_OBJECT_0 + EV_SENDMSG:
8731 trace("thread: sending message\n");
8732 ok( SendNotifyMessageA(info->hwnd, WM_USER, 0, 0),
8733 "SendNotifyMessageA failed error %u\n", GetLastError());
8734 SetEvent(info->hevent[EV_ACK]);
8738 trace("unexpected return: %04x\n", ret);
8746 static void test_PeekMessage(void)
8751 UINT qs_all_input = QS_ALLINPUT;
8752 UINT qs_input = QS_INPUT;
8754 struct peekmsg_info info;
8756 info.hwnd = CreateWindowA("TestWindowClass", NULL, WS_OVERLAPPEDWINDOW,
8757 100, 100, 200, 200, 0, 0, 0, NULL);
8759 ShowWindow(info.hwnd, SW_SHOW);
8760 UpdateWindow(info.hwnd);
8761 SetFocus(info.hwnd);
8763 info.hevent[EV_STOP] = CreateEventA(NULL, 0, 0, NULL);
8764 info.hevent[EV_SENDMSG] = CreateEventA(NULL, 0, 0, NULL);
8765 info.hevent[EV_ACK] = CreateEventA(NULL, 0, 0, NULL);
8767 hthread = CreateThread(NULL, 0, send_msg_thread_2, &info, 0, &tid);
8768 WaitForSingleObject(info.hevent[EV_ACK], 10000);
8773 SetLastError(0xdeadbeef);
8774 qstatus = GetQueueStatus(qs_all_input);
8775 if (GetLastError() == ERROR_INVALID_FLAGS)
8777 trace("QS_RAWINPUT not supported on this platform\n");
8778 qs_all_input &= ~QS_RAWINPUT;
8779 qs_input &= ~QS_RAWINPUT;
8781 ok(qstatus == 0, "wrong qstatus %08x\n", qstatus);
8783 trace("signalling to send message\n");
8784 SetEvent(info.hevent[EV_SENDMSG]);
8785 WaitForSingleObject(info.hevent[EV_ACK], INFINITE);
8787 /* pass invalid QS_xxxx flags */
8788 SetLastError(0xdeadbeef);
8789 qstatus = GetQueueStatus(0xffffffff);
8790 ok(qstatus == 0, "GetQueueStatus should fail: %08x\n", qstatus);
8791 ok(GetLastError() == ERROR_INVALID_FLAGS, "wrong error %d\n", GetLastError());
8793 qstatus = GetQueueStatus(qs_all_input);
8794 ok(qstatus == MAKELONG(QS_SENDMESSAGE, QS_SENDMESSAGE),
8795 "wrong qstatus %08x\n", qstatus);
8798 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE);
8800 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8802 ok_sequence(WmUser, "WmUser", FALSE);
8804 qstatus = GetQueueStatus(qs_all_input);
8805 ok(qstatus == 0, "wrong qstatus %08x\n", qstatus);
8807 keybd_event('N', 0, 0, 0);
8808 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
8809 qstatus = GetQueueStatus(qs_all_input);
8810 ok(qstatus == MAKELONG(QS_KEY, QS_KEY),
8811 "wrong qstatus %08x\n", qstatus);
8813 PostMessageA(info.hwnd, WM_CHAR, 'z', 0);
8814 qstatus = GetQueueStatus(qs_all_input);
8815 ok(qstatus == MAKELONG(QS_POSTMESSAGE, QS_POSTMESSAGE|QS_KEY),
8816 "wrong qstatus %08x\n", qstatus);
8818 InvalidateRect(info.hwnd, NULL, FALSE);
8819 qstatus = GetQueueStatus(qs_all_input);
8820 ok(qstatus == MAKELONG(QS_PAINT, QS_PAINT|QS_POSTMESSAGE|QS_KEY),
8821 "wrong qstatus %08x\n", qstatus);
8823 trace("signalling to send message\n");
8824 SetEvent(info.hevent[EV_SENDMSG]);
8825 WaitForSingleObject(info.hevent[EV_ACK], INFINITE);
8827 qstatus = GetQueueStatus(qs_all_input);
8828 ok(qstatus == MAKELONG(QS_SENDMESSAGE, QS_SENDMESSAGE|QS_PAINT|QS_POSTMESSAGE|QS_KEY),
8829 "wrong qstatus %08x\n", qstatus);
8832 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | (qs_input << 16));
8834 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8836 ok_sequence(WmUser, "WmUser", FALSE);
8838 qstatus = GetQueueStatus(qs_all_input);
8839 ok(qstatus == MAKELONG(0, QS_PAINT|QS_POSTMESSAGE|QS_KEY),
8840 "wrong qstatus %08x\n", qstatus);
8842 trace("signalling to send message\n");
8843 SetEvent(info.hevent[EV_SENDMSG]);
8844 WaitForSingleObject(info.hevent[EV_ACK], INFINITE);
8846 qstatus = GetQueueStatus(qs_all_input);
8847 ok(qstatus == MAKELONG(QS_SENDMESSAGE, QS_SENDMESSAGE|QS_PAINT|QS_POSTMESSAGE|QS_KEY),
8848 "wrong qstatus %08x\n", qstatus);
8851 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | PM_QS_POSTMESSAGE);
8853 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8855 ok_sequence(WmUser, "WmUser", FALSE);
8857 qstatus = GetQueueStatus(qs_all_input);
8858 ok(qstatus == MAKELONG(0, QS_PAINT|QS_POSTMESSAGE|QS_KEY),
8859 "wrong qstatus %08x\n", qstatus);
8862 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | PM_QS_POSTMESSAGE);
8863 ok(ret && msg.message == WM_CHAR && msg.wParam == 'z',
8864 "got %d and %04x wParam %08lx instead of TRUE and WM_CHAR wParam 'z'\n",
8865 ret, msg.message, msg.wParam);
8866 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
8868 qstatus = GetQueueStatus(qs_all_input);
8869 ok(qstatus == MAKELONG(0, QS_PAINT|QS_KEY),
8870 "wrong qstatus %08x\n", qstatus);
8873 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | PM_QS_POSTMESSAGE);
8875 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8877 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
8879 qstatus = GetQueueStatus(qs_all_input);
8880 ok(qstatus == MAKELONG(0, QS_PAINT|QS_KEY),
8881 "wrong qstatus %08x\n", qstatus);
8884 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | PM_QS_PAINT);
8885 ok(ret && msg.message == WM_PAINT,
8886 "got %d and %04x instead of TRUE and WM_PAINT\n", ret, msg.message);
8887 DispatchMessageA(&msg);
8888 ok_sequence(WmPaint, "WmPaint", FALSE);
8890 qstatus = GetQueueStatus(qs_all_input);
8891 ok(qstatus == MAKELONG(0, QS_KEY),
8892 "wrong qstatus %08x\n", qstatus);
8895 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | PM_QS_PAINT);
8897 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8899 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
8901 qstatus = GetQueueStatus(qs_all_input);
8902 ok(qstatus == MAKELONG(0, QS_KEY),
8903 "wrong qstatus %08x\n", qstatus);
8905 trace("signalling to send message\n");
8906 SetEvent(info.hevent[EV_SENDMSG]);
8907 WaitForSingleObject(info.hevent[EV_ACK], INFINITE);
8909 qstatus = GetQueueStatus(qs_all_input);
8910 ok(qstatus == MAKELONG(QS_SENDMESSAGE, QS_SENDMESSAGE|QS_KEY),
8911 "wrong qstatus %08x\n", qstatus);
8913 PostMessageA(info.hwnd, WM_CHAR, 'z', 0);
8915 qstatus = GetQueueStatus(qs_all_input);
8916 ok(qstatus == MAKELONG(QS_POSTMESSAGE, QS_SENDMESSAGE|QS_POSTMESSAGE|QS_KEY),
8917 "wrong qstatus %08x\n", qstatus);
8920 ret = PeekMessageA(&msg, 0, WM_CHAR, WM_CHAR, PM_REMOVE);
8921 ok(ret && msg.message == WM_CHAR && msg.wParam == 'z',
8922 "got %d and %04x wParam %08lx instead of TRUE and WM_CHAR wParam 'z'\n",
8923 ret, msg.message, msg.wParam);
8924 ok_sequence(WmUser, "WmUser", FALSE);
8926 qstatus = GetQueueStatus(qs_all_input);
8927 ok(qstatus == MAKELONG(0, QS_KEY),
8928 "wrong qstatus %08x\n", qstatus);
8931 ret = PeekMessageA(&msg, 0, WM_CHAR, WM_CHAR, PM_REMOVE);
8933 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8935 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
8937 qstatus = GetQueueStatus(qs_all_input);
8938 ok(qstatus == MAKELONG(0, QS_KEY),
8939 "wrong qstatus %08x\n", qstatus);
8941 PostMessageA(info.hwnd, WM_CHAR, 'z', 0);
8943 qstatus = GetQueueStatus(qs_all_input);
8944 ok(qstatus == MAKELONG(QS_POSTMESSAGE, QS_POSTMESSAGE|QS_KEY),
8945 "wrong qstatus %08x\n", qstatus);
8947 trace("signalling to send message\n");
8948 SetEvent(info.hevent[EV_SENDMSG]);
8949 WaitForSingleObject(info.hevent[EV_ACK], INFINITE);
8951 qstatus = GetQueueStatus(qs_all_input);
8952 ok(qstatus == MAKELONG(QS_SENDMESSAGE, QS_SENDMESSAGE|QS_POSTMESSAGE|QS_KEY),
8953 "wrong qstatus %08x\n", qstatus);
8956 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | (QS_KEY << 16));
8958 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8960 ok_sequence(WmUser, "WmUser", FALSE);
8962 qstatus = GetQueueStatus(qs_all_input);
8963 ok(qstatus == MAKELONG(0, QS_POSTMESSAGE|QS_KEY),
8964 "wrong qstatus %08x\n", qstatus);
8967 if (qs_all_input & QS_RAWINPUT) /* use QS_RAWINPUT only if supported */
8968 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | (QS_RAWINPUT << 16));
8969 else /* workaround for a missing QS_RAWINPUT support */
8970 ret = PeekMessageA(&msg, 0, WM_KEYDOWN, WM_KEYDOWN, PM_REMOVE);
8971 ok(ret && msg.message == WM_KEYDOWN && msg.wParam == 'N',
8972 "got %d and %04x wParam %08lx instead of TRUE and WM_KEYDOWN wParam 'N'\n",
8973 ret, msg.message, msg.wParam);
8974 ok_sequence(WmKeyDownSkippedSeq, "WmKeyDownSkippedSeq", FALSE);
8976 qstatus = GetQueueStatus(qs_all_input);
8977 ok(qstatus == MAKELONG(0, QS_POSTMESSAGE|QS_KEY),
8978 "wrong qstatus %08x\n", qstatus);
8981 if (qs_all_input & QS_RAWINPUT) /* use QS_RAWINPUT only if supported */
8982 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | (QS_RAWINPUT << 16));
8983 else /* workaround for a missing QS_RAWINPUT support */
8984 ret = PeekMessageA(&msg, 0, WM_KEYUP, WM_KEYUP, PM_REMOVE);
8985 ok(ret && msg.message == WM_KEYUP && msg.wParam == 'N',
8986 "got %d and %04x wParam %08lx instead of TRUE and WM_KEYUP wParam 'N'\n",
8987 ret, msg.message, msg.wParam);
8988 ok_sequence(WmKeyUpSkippedSeq, "WmKeyUpSkippedSeq", FALSE);
8990 qstatus = GetQueueStatus(qs_all_input);
8991 ok(qstatus == MAKELONG(0, QS_POSTMESSAGE),
8992 "wrong qstatus %08x\n", qstatus);
8995 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | PM_QS_SENDMESSAGE);
8997 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8999 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
9001 qstatus = GetQueueStatus(qs_all_input);
9002 ok(qstatus == MAKELONG(0, QS_POSTMESSAGE),
9003 "wrong qstatus %08x\n", qstatus);
9006 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE);
9007 ok(ret && msg.message == WM_CHAR && msg.wParam == 'z',
9008 "got %d and %04x wParam %08lx instead of TRUE and WM_CHAR wParam 'z'\n",
9009 ret, msg.message, msg.wParam);
9010 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
9012 qstatus = GetQueueStatus(qs_all_input);
9014 "wrong qstatus %08x\n", qstatus);
9017 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE);
9019 "PeekMessageA should have returned FALSE instead of msg %04x\n",
9021 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
9023 qstatus = GetQueueStatus(qs_all_input);
9025 "wrong qstatus %08x\n", qstatus);
9027 /* test whether presence of the quit flag in the queue affects
9030 PostQuitMessage(0x1234abcd);
9032 qstatus = GetQueueStatus(qs_all_input);
9033 ok(qstatus == MAKELONG(QS_POSTMESSAGE, QS_POSTMESSAGE),
9034 "wrong qstatus %08x\n", qstatus);
9036 PostMessageA(info.hwnd, WM_USER, 0, 0);
9038 qstatus = GetQueueStatus(qs_all_input);
9039 ok(qstatus == MAKELONG(QS_POSTMESSAGE, QS_POSTMESSAGE),
9040 "wrong qstatus %08x\n", qstatus);
9043 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE);
9044 ok(ret && msg.message == WM_USER,
9045 "got %d and %04x instead of TRUE and WM_USER\n", ret, msg.message);
9046 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
9048 qstatus = GetQueueStatus(qs_all_input);
9049 ok(qstatus == MAKELONG(0, QS_POSTMESSAGE),
9050 "wrong qstatus %08x\n", qstatus);
9053 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE);
9054 ok(ret && msg.message == WM_QUIT,
9055 "got %d and %04x instead of TRUE and WM_QUIT\n", ret, msg.message);
9056 ok(msg.wParam == 0x1234abcd, "got wParam %08lx instead of 0x1234abcd\n", msg.wParam);
9057 ok(msg.lParam == 0, "got lParam %08lx instead of 0\n", msg.lParam);
9058 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
9060 qstatus = GetQueueStatus(qs_all_input);
9062 ok(qstatus == MAKELONG(0, QS_POSTMESSAGE),
9063 "wrong qstatus %08x\n", qstatus);
9067 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE);
9069 "PeekMessageA should have returned FALSE instead of msg %04x\n",
9071 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
9073 qstatus = GetQueueStatus(qs_all_input);
9075 "wrong qstatus %08x\n", qstatus);
9077 trace("signalling to exit\n");
9078 SetEvent(info.hevent[EV_STOP]);
9080 WaitForSingleObject(hthread, INFINITE);
9082 CloseHandle(hthread);
9083 CloseHandle(info.hevent[0]);
9084 CloseHandle(info.hevent[1]);
9085 CloseHandle(info.hevent[2]);
9087 DestroyWindow(info.hwnd);
9090 static void wait_move_event(HWND hwnd, int x, int y)
9097 time = GetTickCount();
9098 while (GetTickCount() - time < 200 && !go) {
9099 ret = PeekMessageA(&msg, hwnd, WM_MOUSEMOVE, WM_MOUSEMOVE, PM_NOREMOVE);
9100 go = ret && msg.pt.x > x && msg.pt.y > y;
9105 static void test_PeekMessage2(void)
9111 DWORD time1, time2, time3;
9112 int x1, y1, x2, y2, x3, y3;
9115 time1 = time2 = time3 = 0;
9116 x1 = y1 = x2 = y2 = x3 = y3 = 0;
9118 /* Initialise window and make sure it is ready for events */
9119 hwnd = CreateWindow("TestWindowClass", "PeekMessage2", WS_OVERLAPPEDWINDOW,
9120 10, 10, 800, 800, NULL, NULL, NULL, NULL);
9122 trace("Window for test_PeekMessage2 %p\n", hwnd);
9123 ShowWindow(hwnd, SW_SHOW);
9127 SetCursorPos(100, 100);
9128 mouse_event(MOUSEEVENTF_MOVE, -STEP, -STEP, 0, 0);
9131 /* Do initial mousemove, wait until we can see it
9132 and then do our test peek with PM_NOREMOVE. */
9133 mouse_event(MOUSEEVENTF_MOVE, STEP, STEP, 0, 0);
9134 wait_move_event(hwnd, 80, 80);
9136 ret = PeekMessageA(&msg, hwnd, WM_MOUSEMOVE, WM_MOUSEMOVE, PM_NOREMOVE);
9137 ok(ret, "no message available\n");
9139 trace("1st move event: %04x %x %d %d\n", msg.message, msg.time, msg.pt.x, msg.pt.y);
9140 message = msg.message;
9144 ok(message == WM_MOUSEMOVE, "message not WM_MOUSEMOVE, %04x instead\n", message);
9147 /* Allow time to advance a bit, and then simulate the user moving their
9148 * mouse around. After that we peek again with PM_NOREMOVE.
9149 * Although the previous mousemove message was never removed, the
9150 * mousemove we now peek should reflect the recent mouse movements
9151 * because the input queue will merge the move events. */
9153 mouse_event(MOUSEEVENTF_MOVE, STEP, STEP, 0, 0);
9154 wait_move_event(hwnd, x1, y1);
9156 ret = PeekMessageA(&msg, hwnd, WM_MOUSEMOVE, WM_MOUSEMOVE, PM_NOREMOVE);
9157 ok(ret, "no message available\n");
9159 trace("2nd move event: %04x %x %d %d\n", msg.message, msg.time, msg.pt.x, msg.pt.y);
9160 message = msg.message;
9164 ok(message == WM_MOUSEMOVE, "message not WM_MOUSEMOVE, %04x instead\n", message);
9165 ok(time2 > time1, "message time not advanced: %x %x\n", time1, time2);
9166 ok(x2 != x1 && y2 != y1, "coords not changed: (%d %d) (%d %d)\n", x1, y1, x2, y2);
9169 /* Have another go, to drive the point home */
9171 mouse_event(MOUSEEVENTF_MOVE, STEP, STEP, 0, 0);
9172 wait_move_event(hwnd, x2, y2);
9174 ret = PeekMessageA(&msg, hwnd, WM_MOUSEMOVE, WM_MOUSEMOVE, PM_NOREMOVE);
9175 ok(ret, "no message available\n");
9177 trace("3rd move event: %04x %x %d %d\n", msg.message, msg.time, msg.pt.x, msg.pt.y);
9178 message = msg.message;
9182 ok(message == WM_MOUSEMOVE, "message not WM_MOUSEMOVE, %04x instead\n", message);
9183 ok(time3 > time2, "message time not advanced: %x %x\n", time2, time3);
9184 ok(x3 != x2 && y3 != y2, "coords not changed: (%d %d) (%d %d)\n", x2, y2, x3, y3);
9187 DestroyWindow(hwnd);
9188 SetCursorPos(pos.x, pos.y);
9192 static void test_quit_message(void)
9197 /* test using PostQuitMessage */
9199 PostQuitMessage(0xbeef);
9201 ret = PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE);
9202 ok(ret, "PeekMessage failed with error %d\n", GetLastError());
9203 ok(msg.message == WM_QUIT, "Received message 0x%04x instead of WM_QUIT\n", msg.message);
9204 ok(msg.wParam == 0xbeef, "wParam was 0x%lx instead of 0xbeef\n", msg.wParam);
9206 ret = PostThreadMessage(GetCurrentThreadId(), WM_USER, 0, 0);
9207 ok(ret, "PostMessage failed with error %d\n", GetLastError());
9209 ret = GetMessage(&msg, NULL, 0, 0);
9210 ok(ret > 0, "GetMessage failed with error %d\n", GetLastError());
9211 ok(msg.message == WM_USER, "Received message 0x%04x instead of WM_USER\n", msg.message);
9213 /* note: WM_QUIT message received after WM_USER message */
9214 ret = GetMessage(&msg, NULL, 0, 0);
9215 ok(!ret, "GetMessage return %d with error %d instead of FALSE\n", ret, GetLastError());
9216 ok(msg.message == WM_QUIT, "Received message 0x%04x instead of WM_QUIT\n", msg.message);
9217 ok(msg.wParam == 0xbeef, "wParam was 0x%lx instead of 0xbeef\n", msg.wParam);
9219 ret = PeekMessage(&msg, NULL, 0, 0, PM_REMOVE);
9220 ok( !ret || msg.message != WM_QUIT, "Received WM_QUIT again\n" );
9222 /* now test with PostThreadMessage - different behaviour! */
9223 PostThreadMessage(GetCurrentThreadId(), WM_QUIT, 0xdead, 0);
9225 ret = PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE);
9226 ok(ret, "PeekMessage failed with error %d\n", GetLastError());
9227 ok(msg.message == WM_QUIT, "Received message 0x%04x instead of WM_QUIT\n", msg.message);
9228 ok(msg.wParam == 0xdead, "wParam was 0x%lx instead of 0xdead\n", msg.wParam);
9230 ret = PostThreadMessage(GetCurrentThreadId(), WM_USER, 0, 0);
9231 ok(ret, "PostMessage failed with error %d\n", GetLastError());
9233 /* note: we receive the WM_QUIT message first this time */
9234 ret = GetMessage(&msg, NULL, 0, 0);
9235 ok(!ret, "GetMessage return %d with error %d instead of FALSE\n", ret, GetLastError());
9236 ok(msg.message == WM_QUIT, "Received message 0x%04x instead of WM_QUIT\n", msg.message);
9237 ok(msg.wParam == 0xdead, "wParam was 0x%lx instead of 0xdead\n", msg.wParam);
9239 ret = GetMessage(&msg, NULL, 0, 0);
9240 ok(ret > 0, "GetMessage failed with error %d\n", GetLastError());
9241 ok(msg.message == WM_USER, "Received message 0x%04x instead of WM_USER\n", msg.message);
9244 static const struct message WmMouseHoverSeq[] = {
9245 { WM_MOUSEACTIVATE, sent|optional }, /* we can get those when moving the mouse in focus-follow-mouse mode under X11 */
9246 { WM_MOUSEACTIVATE, sent|optional },
9247 { WM_TIMER, sent|optional }, /* XP sends it */
9248 { WM_SYSTIMER, sent },
9249 { WM_MOUSEHOVER, sent|wparam, 0 },
9253 static void pump_msg_loop_timeout(DWORD timeout, BOOL inject_mouse_move)
9256 DWORD start_ticks, end_ticks;
9258 start_ticks = GetTickCount();
9259 /* add some deviation (5%) to cover not expected delays */
9260 start_ticks += timeout / 20;
9264 while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
9266 /* Timer proc messages are not dispatched to the window proc,
9267 * and therefore not logged.
9269 if (msg.message == WM_TIMER || msg.message == WM_SYSTIMER)
9271 struct message s_msg;
9273 s_msg.message = msg.message;
9274 s_msg.flags = sent|wparam|lparam;
9275 s_msg.wParam = msg.wParam;
9276 s_msg.lParam = msg.lParam;
9277 add_message(&s_msg);
9279 DispatchMessage(&msg);
9282 end_ticks = GetTickCount();
9284 /* inject WM_MOUSEMOVE to see how it changes tracking */
9285 if (inject_mouse_move && start_ticks + timeout / 2 >= end_ticks)
9287 mouse_event(MOUSEEVENTF_MOVE, -1, 0, 0, 0);
9288 mouse_event(MOUSEEVENTF_MOVE, 1, 0, 0, 0);
9290 inject_mouse_move = FALSE;
9292 } while (start_ticks + timeout >= end_ticks);
9295 static void test_TrackMouseEvent(void)
9297 TRACKMOUSEEVENT tme;
9300 RECT rc_parent, rc_child;
9301 UINT default_hover_time, hover_width = 0, hover_height = 0;
9303 #define track_hover(track_hwnd, track_hover_time) \
9304 tme.cbSize = sizeof(tme); \
9305 tme.dwFlags = TME_HOVER; \
9306 tme.hwndTrack = track_hwnd; \
9307 tme.dwHoverTime = track_hover_time; \
9308 SetLastError(0xdeadbeef); \
9309 ret = pTrackMouseEvent(&tme); \
9310 ok(ret, "TrackMouseEvent(TME_HOVER) error %d\n", GetLastError())
9312 #define track_query(expected_track_flags, expected_track_hwnd, expected_hover_time) \
9313 tme.cbSize = sizeof(tme); \
9314 tme.dwFlags = TME_QUERY; \
9315 tme.hwndTrack = (HWND)0xdeadbeef; \
9316 tme.dwHoverTime = 0xdeadbeef; \
9317 SetLastError(0xdeadbeef); \
9318 ret = pTrackMouseEvent(&tme); \
9319 ok(ret, "TrackMouseEvent(TME_QUERY) error %d\n", GetLastError());\
9320 ok(tme.cbSize == sizeof(tme), "wrong tme.cbSize %u\n", tme.cbSize); \
9321 ok(tme.dwFlags == (expected_track_flags), \
9322 "wrong tme.dwFlags %08x, expected %08x\n", tme.dwFlags, (expected_track_flags)); \
9323 ok(tme.hwndTrack == (expected_track_hwnd), \
9324 "wrong tme.hwndTrack %p, expected %p\n", tme.hwndTrack, (expected_track_hwnd)); \
9325 ok(tme.dwHoverTime == (expected_hover_time), \
9326 "wrong tme.dwHoverTime %u, expected %u\n", tme.dwHoverTime, (expected_hover_time))
9328 #define track_hover_cancel(track_hwnd) \
9329 tme.cbSize = sizeof(tme); \
9330 tme.dwFlags = TME_HOVER | TME_CANCEL; \
9331 tme.hwndTrack = track_hwnd; \
9332 tme.dwHoverTime = 0xdeadbeef; \
9333 SetLastError(0xdeadbeef); \
9334 ret = pTrackMouseEvent(&tme); \
9335 ok(ret, "TrackMouseEvent(TME_HOVER | TME_CANCEL) error %d\n", GetLastError())
9337 default_hover_time = 0xdeadbeef;
9338 SetLastError(0xdeadbeef);
9339 ret = SystemParametersInfo(SPI_GETMOUSEHOVERTIME, 0, &default_hover_time, 0);
9340 ok(ret, "SystemParametersInfo(SPI_GETMOUSEHOVERTIME) error %u\n", GetLastError());
9341 if (!ret) default_hover_time = 400;
9342 trace("SPI_GETMOUSEHOVERTIME returned %u ms\n", default_hover_time);
9344 SetLastError(0xdeadbeef);
9345 ret = SystemParametersInfo(SPI_GETMOUSEHOVERWIDTH, 0, &hover_width, 0);
9346 ok(ret, "SystemParametersInfo(SPI_GETMOUSEHOVERWIDTH) error %u\n", GetLastError());
9347 if (!ret) hover_width = 4;
9348 SetLastError(0xdeadbeef);
9349 ret = SystemParametersInfo(SPI_GETMOUSEHOVERHEIGHT, 0, &hover_height, 0);
9350 ok(ret, "SystemParametersInfo(SPI_GETMOUSEHOVERHEIGHT) error %u\n", GetLastError());
9351 if (!ret) hover_height = 4;
9352 trace("hover rect is %u x %d\n", hover_width, hover_height);
9354 hwnd = CreateWindowEx(0, "TestWindowClass", NULL,
9355 WS_OVERLAPPEDWINDOW | WS_VISIBLE,
9356 CW_USEDEFAULT, CW_USEDEFAULT, 300, 300, 0,
9360 hchild = CreateWindowEx(0, "TestWindowClass", NULL,
9361 WS_CHILD | WS_BORDER | WS_VISIBLE,
9362 50, 50, 200, 200, hwnd,
9370 tme.dwFlags = TME_QUERY;
9371 tme.hwndTrack = (HWND)0xdeadbeef;
9372 tme.dwHoverTime = 0xdeadbeef;
9373 SetLastError(0xdeadbeef);
9374 ret = pTrackMouseEvent(&tme);
9375 ok(!ret, "TrackMouseEvent should fail\n");
9376 ok(GetLastError() == ERROR_INVALID_PARAMETER || broken(GetLastError() == 0xdeadbeef),
9377 "not expected error %u\n", GetLastError());
9379 tme.cbSize = sizeof(tme);
9380 tme.dwFlags = TME_HOVER;
9381 tme.hwndTrack = (HWND)0xdeadbeef;
9382 tme.dwHoverTime = 0xdeadbeef;
9383 SetLastError(0xdeadbeef);
9384 ret = pTrackMouseEvent(&tme);
9385 ok(!ret, "TrackMouseEvent should fail\n");
9386 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE || broken(GetLastError() == 0xdeadbeef),
9387 "not expected error %u\n", GetLastError());
9389 tme.cbSize = sizeof(tme);
9390 tme.dwFlags = TME_HOVER | TME_CANCEL;
9391 tme.hwndTrack = (HWND)0xdeadbeef;
9392 tme.dwHoverTime = 0xdeadbeef;
9393 SetLastError(0xdeadbeef);
9394 ret = pTrackMouseEvent(&tme);
9395 ok(!ret, "TrackMouseEvent should fail\n");
9396 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE || broken(GetLastError() == 0xdeadbeef),
9397 "not expected error %u\n", GetLastError());
9399 GetWindowRect(hwnd, &rc_parent);
9400 GetWindowRect(hchild, &rc_child);
9401 SetCursorPos(rc_child.left - 10, rc_child.top - 10);
9403 /* Process messages so that the system updates its internal current
9404 * window and hittest, otherwise TrackMouseEvent calls don't have any
9410 track_query(0, NULL, 0);
9411 track_hover(hchild, 0);
9412 track_query(0, NULL, 0);
9417 track_hover(hwnd, 0);
9418 track_query(TME_HOVER, hwnd, default_hover_time);
9420 pump_msg_loop_timeout(default_hover_time, FALSE);
9421 ok_sequence(WmMouseHoverSeq, "WmMouseHoverSeq", FALSE);
9423 track_query(0, NULL, 0);
9425 track_hover(hwnd, HOVER_DEFAULT);
9426 track_query(TME_HOVER, hwnd, default_hover_time);
9428 Sleep(default_hover_time / 2);
9429 mouse_event(MOUSEEVENTF_MOVE, -1, 0, 0, 0);
9430 mouse_event(MOUSEEVENTF_MOVE, 1, 0, 0, 0);
9432 track_query(TME_HOVER, hwnd, default_hover_time);
9434 pump_msg_loop_timeout(default_hover_time / 2, FALSE);
9435 ok_sequence(WmMouseHoverSeq, "WmMouseHoverSeq", FALSE);
9437 track_query(0, NULL, 0);
9439 track_hover(hwnd, HOVER_DEFAULT);
9440 track_query(TME_HOVER, hwnd, default_hover_time);
9442 pump_msg_loop_timeout(default_hover_time, TRUE);
9443 ok_sequence(WmMouseHoverSeq, "WmMouseHoverSeq", FALSE);
9445 track_query(0, NULL, 0);
9447 track_hover(hwnd, HOVER_DEFAULT);
9448 track_query(TME_HOVER, hwnd, default_hover_time);
9449 track_hover_cancel(hwnd);
9451 DestroyWindow(hwnd);
9455 #undef track_hover_cancel
9459 static const struct message WmSetWindowRgn[] = {
9460 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE },
9461 { WM_NCCALCSIZE, sent|wparam, 1 },
9462 { WM_NCPAINT, sent|optional }, /* wparam != 1 */
9463 { WM_GETTEXT, sent|defwinproc|optional },
9464 { WM_ERASEBKGND, sent|optional },
9465 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE },
9466 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
9470 static const struct message WmSetWindowRgn_no_redraw[] = {
9471 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW },
9472 { WM_NCCALCSIZE, sent|wparam, 1 },
9473 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW },
9474 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
9478 static const struct message WmSetWindowRgn_clear[] = {
9479 { WM_WINDOWPOSCHANGING, sent/*|wparam*/, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE/*|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE only on some Windows versions */ },
9480 { WM_NCCALCSIZE, sent|wparam, 1 },
9481 { WM_NCPAINT, sent|optional },
9482 { WM_GETTEXT, sent|defwinproc|optional },
9483 { WM_ERASEBKGND, sent|optional }, /* FIXME: remove optional once Wine is fixed */
9484 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE },
9485 { WM_NCCALCSIZE, sent|wparam|optional, 1 },
9486 { WM_NCPAINT, sent|optional },
9487 { WM_GETTEXT, sent|defwinproc|optional },
9488 { WM_ERASEBKGND, sent|optional },
9489 { WM_WINDOWPOSCHANGING, sent|optional },
9490 { WM_NCCALCSIZE, sent|optional|wparam, 1 },
9491 { WM_NCPAINT, sent|optional },
9492 { WM_GETTEXT, sent|defwinproc|optional },
9493 { WM_ERASEBKGND, sent|optional },
9494 { WM_WINDOWPOSCHANGED, sent|optional|wparam, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE },
9495 { WM_NCCALCSIZE, sent|optional|wparam, 1 },
9496 { WM_NCPAINT, sent|optional },
9497 { WM_GETTEXT, sent|defwinproc|optional },
9498 { WM_ERASEBKGND, sent|optional },
9499 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
9500 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
9504 static void test_SetWindowRgn(void)
9507 HWND hwnd = CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW,
9508 100, 100, 200, 200, 0, 0, 0, NULL);
9509 ok( hwnd != 0, "Failed to create overlapped window\n" );
9511 ShowWindow( hwnd, SW_SHOW );
9512 UpdateWindow( hwnd );
9516 trace("testing SetWindowRgn\n");
9517 hrgn = CreateRectRgn( 0, 0, 150, 150 );
9518 SetWindowRgn( hwnd, hrgn, TRUE );
9519 ok_sequence( WmSetWindowRgn, "WmSetWindowRgn", FALSE );
9521 hrgn = CreateRectRgn( 30, 30, 160, 160 );
9522 SetWindowRgn( hwnd, hrgn, FALSE );
9523 ok_sequence( WmSetWindowRgn_no_redraw, "WmSetWindowRgn_no_redraw", FALSE );
9525 hrgn = CreateRectRgn( 0, 0, 180, 180 );
9526 SetWindowRgn( hwnd, hrgn, TRUE );
9527 ok_sequence( WmSetWindowRgn, "WmSetWindowRgn2", FALSE );
9529 SetWindowRgn( hwnd, 0, TRUE );
9530 ok_sequence( WmSetWindowRgn_clear, "WmSetWindowRgn_clear", FALSE );
9532 DestroyWindow( hwnd );
9535 /*************************** ShowWindow() test ******************************/
9536 static const struct message WmShowNormal[] = {
9537 { WM_SHOWWINDOW, sent|wparam, 1 },
9538 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
9539 { HCBT_ACTIVATE, hook },
9540 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* win2003 doesn't send it */
9541 { HCBT_SETFOCUS, hook },
9542 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
9545 static const struct message WmShow[] = {
9546 { WM_SHOWWINDOW, sent|wparam, 1 },
9547 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
9548 { HCBT_ACTIVATE, hook|optional }, /* win2000 doesn't send it */
9549 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* win2000 doesn't send it */
9550 { HCBT_SETFOCUS, hook|optional }, /* win2000 doesn't send it */
9551 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
9554 static const struct message WmShowNoActivate_1[] = {
9555 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWNOACTIVATE },
9556 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_STATECHANGED },
9557 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_STATECHANGED },
9558 { WM_MOVE, sent|defwinproc },
9559 { WM_SIZE, sent|wparam|defwinproc, SIZE_RESTORED },
9562 static const struct message WmShowNoActivate_2[] = {
9563 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWNOACTIVATE },
9564 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
9565 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
9566 { WM_MOVE, sent|defwinproc },
9567 { WM_SIZE, sent|wparam|defwinproc, SIZE_RESTORED },
9568 { HCBT_SETFOCUS, hook|optional },
9569 { HCBT_ACTIVATE, hook|optional }, /* win2003 doesn't send it */
9570 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* win2003 doesn't send it */
9571 { HCBT_SETFOCUS, hook|optional }, /* win2003 doesn't send it */
9574 static const struct message WmShowNA_1[] = {
9575 { WM_SHOWWINDOW, sent|wparam, 1 },
9576 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
9577 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
9580 static const struct message WmShowNA_2[] = {
9581 { WM_SHOWWINDOW, sent|wparam, 1 },
9582 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
9585 static const struct message WmRestore_1[] = {
9586 { HCBT_MINMAX, hook|lparam, 0, SW_RESTORE },
9587 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
9588 { HCBT_ACTIVATE, hook|optional }, /* win2000 doesn't send it */
9589 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* win2000 doesn't send it */
9590 { HCBT_SETFOCUS, hook|optional }, /* win2000 doesn't send it */
9591 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
9592 { WM_MOVE, sent|defwinproc },
9593 { WM_SIZE, sent|wparam|defwinproc, SIZE_RESTORED },
9594 { HCBT_SETFOCUS, hook|optional }, /* win2000 sends it */
9597 static const struct message WmRestore_2[] = {
9598 { WM_SHOWWINDOW, sent|wparam, 1 },
9599 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
9600 { HCBT_ACTIVATE, hook|optional }, /* win2000 doesn't send it */
9601 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* win2000 doesn't send it */
9602 { HCBT_SETFOCUS, hook|optional }, /* win2000 doesn't send it */
9603 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
9606 static const struct message WmRestore_3[] = {
9607 { HCBT_MINMAX, hook|lparam, 0, SW_RESTORE },
9608 { WM_GETMINMAXINFO, sent },
9609 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
9610 { HCBT_ACTIVATE, hook|optional }, /* win2003 doesn't send it */
9611 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* win2003 doesn't send it */
9612 { HCBT_SETFOCUS, hook|optional }, /* win2003 doesn't send it */
9613 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
9614 { WM_MOVE, sent|defwinproc },
9615 { WM_SIZE, sent|wparam|defwinproc, SIZE_MAXIMIZED },
9616 { HCBT_SETFOCUS, hook|optional }, /* win2003 sends it */
9619 static const struct message WmRestore_4[] = {
9620 { HCBT_MINMAX, hook|lparam, 0, SW_RESTORE },
9621 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_STATECHANGED },
9622 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_STATECHANGED },
9623 { WM_MOVE, sent|defwinproc },
9624 { WM_SIZE, sent|wparam|defwinproc, SIZE_RESTORED },
9627 static const struct message WmRestore_5[] = {
9628 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWNORMAL },
9629 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_STATECHANGED },
9630 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_STATECHANGED },
9631 { WM_MOVE, sent|defwinproc },
9632 { WM_SIZE, sent|wparam|defwinproc, SIZE_RESTORED },
9635 static const struct message WmHide_1[] = {
9636 { WM_SHOWWINDOW, sent|wparam, 0 },
9637 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE },
9638 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
9639 { HCBT_SETFOCUS, hook|optional }, /* win2000 sends it */
9642 static const struct message WmHide_2[] = {
9643 { WM_SHOWWINDOW, sent|wparam, 0 },
9644 { WM_WINDOWPOSCHANGING, sent /*|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE*/ }, /* win2000 doesn't add SWP_NOACTIVATE */
9645 { WM_WINDOWPOSCHANGED, sent /*|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE*/ }, /* win2000 doesn't add SWP_NOACTIVATE */
9648 static const struct message WmHide_3[] = {
9649 { WM_SHOWWINDOW, sent|wparam, 0 },
9650 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE },
9651 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
9652 { HCBT_SETFOCUS, hook|optional },
9653 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
9656 static const struct message WmShowMinimized_1[] = {
9657 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMINIMIZED },
9658 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
9659 { HCBT_ACTIVATE, hook|optional }, /* win2000 doesn't send it */
9660 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* win2000 doesn't send it */
9661 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
9662 { WM_MOVE, sent|defwinproc },
9663 { WM_SIZE, sent|wparam|defwinproc, SIZE_MINIMIZED },
9666 static const struct message WmMinimize_1[] = {
9667 { HCBT_MINMAX, hook|lparam, 0, SW_MINIMIZE },
9668 { HCBT_SETFOCUS, hook|optional }, /* win2000 doesn't send it */
9669 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
9670 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
9671 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
9672 { WM_MOVE, sent|defwinproc },
9673 { WM_SIZE, sent|wparam|defwinproc, SIZE_MINIMIZED },
9676 static const struct message WmMinimize_2[] = {
9677 { HCBT_MINMAX, hook|lparam, 0, SW_MINIMIZE },
9678 { HCBT_SETFOCUS, hook|optional },
9679 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
9680 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
9681 { WM_MOVE, sent|defwinproc },
9682 { WM_SIZE, sent|wparam|defwinproc, SIZE_MINIMIZED },
9685 static const struct message WmMinimize_3[] = {
9686 { HCBT_MINMAX, hook|lparam, 0, SW_MINIMIZE },
9687 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
9688 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
9689 { WM_MOVE, sent|defwinproc },
9690 { WM_SIZE, sent|wparam|defwinproc, SIZE_MINIMIZED },
9693 static const struct message WmShowMinNoActivate[] = {
9694 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMINNOACTIVE },
9695 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
9696 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
9699 static const struct message WmMinMax_1[] = {
9700 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMINIMIZED },
9703 static const struct message WmMinMax_2[] = {
9704 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMAXIMIZED },
9707 static const struct message WmMinMax_3[] = {
9708 { HCBT_MINMAX, hook|lparam, 0, SW_MINIMIZE },
9711 static const struct message WmMinMax_4[] = {
9712 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMINNOACTIVE },
9715 static const struct message WmShowMaximized_1[] = {
9716 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMAXIMIZED },
9717 { WM_GETMINMAXINFO, sent },
9718 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
9719 { HCBT_ACTIVATE, hook|optional }, /* win2000 doesn't send it */
9720 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* win2000 doesn't send it */
9721 { HCBT_SETFOCUS, hook|optional }, /* win2000 doesn't send it */
9722 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
9723 { WM_MOVE, sent|defwinproc },
9724 { WM_SIZE, sent|wparam|defwinproc, SIZE_MAXIMIZED },
9725 { HCBT_SETFOCUS, hook|optional }, /* win2003 sends it */
9728 static const struct message WmShowMaximized_2[] = {
9729 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMAXIMIZED },
9730 { WM_GETMINMAXINFO, sent },
9731 { WM_WINDOWPOSCHANGING, sent|optional },
9732 { HCBT_ACTIVATE, hook|optional },
9733 { WM_WINDOWPOSCHANGED, sent|optional },
9734 { WM_MOVE, sent|optional }, /* Win9x doesn't send it */
9735 { WM_SIZE, sent|wparam|optional, SIZE_MAXIMIZED }, /* Win9x doesn't send it */
9736 { WM_WINDOWPOSCHANGING, sent },
9737 { HCBT_SETFOCUS, hook|optional },
9738 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
9739 { WM_MOVE, sent|defwinproc },
9740 { WM_SIZE, sent|wparam|defwinproc, SIZE_MAXIMIZED },
9741 { HCBT_SETFOCUS, hook|optional },
9744 static const struct message WmShowMaximized_3[] = {
9745 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMAXIMIZED },
9746 { WM_GETMINMAXINFO, sent },
9747 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_STATECHANGED },
9748 { HCBT_ACTIVATE, hook|optional }, /* win2000 doesn't send it */
9749 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* win2000 doesn't send it */
9750 { HCBT_SETFOCUS, hook|optional }, /* win2000 doesn't send it */
9751 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_STATECHANGED },
9752 { WM_MOVE, sent|defwinproc },
9753 { WM_SIZE, sent|wparam|defwinproc, SIZE_MAXIMIZED },
9757 static void test_ShowWindow(void)
9759 /* ShowWindow commands in random order */
9762 INT cmd; /* ShowWindow command */
9763 LPARAM ret; /* ShowWindow return value */
9764 DWORD style; /* window style after the command */
9765 const struct message *msg; /* message sequence the command produces */
9766 BOOL todo_msg; /* message sequence doesn't match what Wine does */
9769 /* 1 */ { SW_SHOWNORMAL, FALSE, WS_VISIBLE, WmShowNormal, FALSE },
9770 /* 2 */ { SW_SHOWNORMAL, TRUE, WS_VISIBLE, WmEmptySeq, FALSE },
9771 /* 3 */ { SW_HIDE, TRUE, 0, WmHide_1, FALSE },
9772 /* 4 */ { SW_HIDE, FALSE, 0, WmEmptySeq, FALSE },
9773 /* 5 */ { SW_SHOWMINIMIZED, FALSE, WS_VISIBLE|WS_MINIMIZE, WmShowMinimized_1, FALSE },
9774 /* 6 */ { SW_SHOWMINIMIZED, TRUE, WS_VISIBLE|WS_MINIMIZE, WmMinMax_1, FALSE },
9775 /* 7 */ { SW_HIDE, TRUE, WS_MINIMIZE, WmHide_1, FALSE },
9776 /* 8 */ { SW_HIDE, FALSE, WS_MINIMIZE, WmEmptySeq, FALSE },
9777 /* 9 */ { SW_SHOWMAXIMIZED, FALSE, WS_VISIBLE|WS_MAXIMIZE, WmShowMaximized_1, FALSE },
9778 /* 10 */ { SW_SHOWMAXIMIZED, TRUE, WS_VISIBLE|WS_MAXIMIZE, WmMinMax_2, FALSE },
9779 /* 11 */ { SW_HIDE, TRUE, WS_MAXIMIZE, WmHide_1, FALSE },
9780 /* 12 */ { SW_HIDE, FALSE, WS_MAXIMIZE, WmEmptySeq, FALSE },
9781 /* 13 */ { SW_SHOWNOACTIVATE, FALSE, WS_VISIBLE, WmShowNoActivate_1, FALSE },
9782 /* 14 */ { SW_SHOWNOACTIVATE, TRUE, WS_VISIBLE, WmEmptySeq, FALSE },
9783 /* 15 */ { SW_HIDE, TRUE, 0, WmHide_2, FALSE },
9784 /* 16 */ { SW_HIDE, FALSE, 0, WmEmptySeq, FALSE },
9785 /* 17 */ { SW_SHOW, FALSE, WS_VISIBLE, WmShow, FALSE },
9786 /* 18 */ { SW_SHOW, TRUE, WS_VISIBLE, WmEmptySeq, FALSE },
9787 /* 19 */ { SW_MINIMIZE, TRUE, WS_VISIBLE|WS_MINIMIZE, WmMinimize_1, FALSE },
9788 /* 20 */ { SW_MINIMIZE, TRUE, WS_VISIBLE|WS_MINIMIZE, WmMinMax_3, FALSE },
9789 /* 21 */ { SW_HIDE, TRUE, WS_MINIMIZE, WmHide_2, FALSE },
9790 /* 22 */ { SW_SHOWMINNOACTIVE, FALSE, WS_VISIBLE|WS_MINIMIZE, WmShowMinNoActivate, TRUE },
9791 /* 23 */ { SW_SHOWMINNOACTIVE, TRUE, WS_VISIBLE|WS_MINIMIZE, WmMinMax_4, FALSE },
9792 /* 24 */ { SW_HIDE, TRUE, WS_MINIMIZE, WmHide_2, FALSE },
9793 /* 25 */ { SW_HIDE, FALSE, WS_MINIMIZE, WmEmptySeq, FALSE },
9794 /* 26 */ { SW_SHOWNA, FALSE, WS_VISIBLE|WS_MINIMIZE, WmShowNA_1, FALSE },
9795 /* 27 */ { SW_SHOWNA, TRUE, WS_VISIBLE|WS_MINIMIZE, WmShowNA_2, FALSE },
9796 /* 28 */ { SW_HIDE, TRUE, WS_MINIMIZE, WmHide_2, FALSE },
9797 /* 29 */ { SW_HIDE, FALSE, WS_MINIMIZE, WmEmptySeq, FALSE },
9798 /* 30 */ { SW_RESTORE, FALSE, WS_VISIBLE, WmRestore_1, FALSE },
9799 /* 31 */ { SW_RESTORE, TRUE, WS_VISIBLE, WmEmptySeq, FALSE },
9800 /* 32 */ { SW_HIDE, TRUE, 0, WmHide_3, FALSE },
9801 /* 33 */ { SW_HIDE, FALSE, 0, WmEmptySeq, FALSE },
9802 /* 34 */ { SW_NORMALNA, FALSE, 0, WmEmptySeq, FALSE }, /* what does this mean?! */
9803 /* 35 */ { SW_NORMALNA, FALSE, 0, WmEmptySeq, FALSE },
9804 /* 36 */ { SW_HIDE, FALSE, 0, WmEmptySeq, FALSE },
9805 /* 37 */ { SW_RESTORE, FALSE, WS_VISIBLE, WmRestore_2, FALSE },
9806 /* 38 */ { SW_RESTORE, TRUE, WS_VISIBLE, WmEmptySeq, FALSE },
9807 /* 39 */ { SW_SHOWNOACTIVATE, TRUE, WS_VISIBLE, WmEmptySeq, FALSE },
9808 /* 40 */ { SW_MINIMIZE, TRUE, WS_VISIBLE|WS_MINIMIZE, WmMinimize_2, FALSE },
9809 /* 41 */ { SW_MINIMIZE, TRUE, WS_VISIBLE|WS_MINIMIZE, WmMinMax_3, FALSE },
9810 /* 42 */ { SW_SHOWMAXIMIZED, TRUE, WS_VISIBLE|WS_MAXIMIZE, WmShowMaximized_2, TRUE },
9811 /* 43 */ { SW_SHOWMAXIMIZED, TRUE, WS_VISIBLE|WS_MAXIMIZE, WmMinMax_2, FALSE },
9812 /* 44 */ { SW_MINIMIZE, TRUE, WS_VISIBLE|WS_MINIMIZE, WmMinimize_1, FALSE },
9813 /* 45 */ { SW_MINIMIZE, TRUE, WS_VISIBLE|WS_MINIMIZE, WmMinMax_3, FALSE },
9814 /* 46 */ { SW_RESTORE, TRUE, WS_VISIBLE|WS_MAXIMIZE, WmRestore_3, FALSE },
9815 /* 47 */ { SW_RESTORE, TRUE, WS_VISIBLE, WmRestore_4, FALSE },
9816 /* 48 */ { SW_SHOWMAXIMIZED, TRUE, WS_VISIBLE|WS_MAXIMIZE, WmShowMaximized_3, FALSE },
9817 /* 49 */ { SW_SHOW, TRUE, WS_VISIBLE|WS_MAXIMIZE, WmEmptySeq, FALSE },
9818 /* 50 */ { SW_SHOWNORMAL, TRUE, WS_VISIBLE, WmRestore_5, FALSE },
9819 /* 51 */ { SW_SHOWNORMAL, TRUE, WS_VISIBLE, WmEmptySeq, FALSE },
9820 /* 52 */ { SW_HIDE, TRUE, 0, WmHide_1, FALSE },
9821 /* 53 */ { SW_HIDE, FALSE, 0, WmEmptySeq, FALSE },
9822 /* 54 */ { SW_MINIMIZE, FALSE, WS_VISIBLE|WS_MINIMIZE, WmMinimize_3, FALSE },
9823 /* 55 */ { SW_HIDE, TRUE, WS_MINIMIZE, WmHide_2, FALSE },
9824 /* 56 */ { SW_SHOWNOACTIVATE, FALSE, WS_VISIBLE, WmShowNoActivate_2, FALSE },
9825 /* 57 */ { SW_SHOW, TRUE, WS_VISIBLE, WmEmptySeq, FALSE }
9832 #define WS_BASE (WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX|WS_MAXIMIZEBOX|WS_POPUP|WS_CLIPSIBLINGS)
9833 hwnd = CreateWindowEx(0, "ShowWindowClass", NULL, WS_BASE,
9838 style = GetWindowLong(hwnd, GWL_STYLE) & ~WS_BASE;
9839 ok(style == 0, "expected style 0, got %08x\n", style);
9844 for (i = 0; i < sizeof(sw)/sizeof(sw[0]); i++)
9846 static const char * const sw_cmd_name[13] =
9848 "SW_HIDE", "SW_SHOWNORMAL", "SW_SHOWMINIMIZED", "SW_SHOWMAXIMIZED",
9849 "SW_SHOWNOACTIVATE", "SW_SHOW", "SW_MINIMIZE", "SW_SHOWMINNOACTIVE",
9850 "SW_SHOWNA", "SW_RESTORE", "SW_SHOWDEFAULT", "SW_FORCEMINIMIZE",
9851 "SW_NORMALNA" /* 0xCC */
9854 INT idx; /* index into the above array of names */
9856 idx = (sw[i].cmd == SW_NORMALNA) ? 12 : sw[i].cmd;
9858 style = GetWindowLong(hwnd, GWL_STYLE);
9859 trace("%d: sending %s, current window style %08x\n", i+1, sw_cmd_name[idx], style);
9860 ret = ShowWindow(hwnd, sw[i].cmd);
9861 ok(!ret == !sw[i].ret, "%d: cmd %s: expected ret %lu, got %lu\n", i+1, sw_cmd_name[idx], sw[i].ret, ret);
9862 style = GetWindowLong(hwnd, GWL_STYLE) & ~WS_BASE;
9863 ok(style == sw[i].style, "%d: expected style %08x, got %08x\n", i+1, sw[i].style, style);
9865 sprintf(comment, "%d: ShowWindow(%s)", i+1, sw_cmd_name[idx]);
9866 ok_sequence(sw[i].msg, comment, sw[i].todo_msg);
9872 DestroyWindow(hwnd);
9875 static INT_PTR WINAPI test_dlg_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
9879 trace("dialog: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
9883 case WM_WINDOWPOSCHANGING:
9884 case WM_WINDOWPOSCHANGED:
9886 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
9888 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
9889 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x ",
9890 winpos->hwnd, winpos->hwndInsertAfter,
9891 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
9892 dump_winpos_flags(winpos->flags);
9894 /* Log only documented flags, win2k uses 0x1000 and 0x2000
9895 * in the high word for internal purposes
9897 wParam = winpos->flags & 0xffff;
9898 /* We are not interested in the flags that don't match under XP and Win9x */
9899 wParam &= ~(SWP_NOZORDER);
9903 /* explicitly ignore WM_GETICON message */
9908 msg.message = message;
9909 msg.flags = sent|wparam|lparam;
9910 msg.wParam = wParam;
9911 msg.lParam = lParam;
9914 /* calling DefDlgProc leads to a recursion under XP */
9925 static const struct message WmDefDlgSetFocus_1[] = {
9926 { WM_GETDLGCODE, sent|wparam|lparam, 0, 0 },
9927 { WM_GETTEXTLENGTH, sent|wparam|lparam|optional, 0, 0 }, /* XP */
9928 { WM_GETTEXT, sent|wparam|optional, 6 }, /* XP */
9929 { WM_GETTEXT, sent|wparam|optional, 12 }, /* XP */
9930 { EM_SETSEL, sent|wparam, 0 }, /* XP sets lparam to text length, Win9x to -2 */
9931 { HCBT_SETFOCUS, hook },
9932 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
9933 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
9934 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
9935 { WM_SETFOCUS, sent|wparam, 0 },
9936 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 10 },
9937 { WM_CTLCOLOREDIT, sent },
9938 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 11 },
9939 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
9940 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
9941 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
9942 { WM_COMMAND, sent|wparam, MAKEWPARAM(1, EN_SETFOCUS) },
9945 static const struct message WmDefDlgSetFocus_2[] = {
9946 { WM_GETDLGCODE, sent|wparam|lparam, 0, 0 },
9947 { WM_GETTEXTLENGTH, sent|wparam|lparam|optional, 0, 0 }, /* XP */
9948 { WM_GETTEXT, sent|wparam|optional, 6 }, /* XP */
9949 { WM_GETTEXT, sent|wparam|optional, 12 }, /* XP */
9950 { EM_SETSEL, sent|wparam, 0 }, /* XP sets lparam to text length, Win9x to -2 */
9951 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
9952 { WM_CTLCOLOREDIT, sent|optional }, /* XP */
9953 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
9956 /* Creation of a dialog */
9957 static const struct message WmCreateDialogParamSeq_1[] = {
9958 { HCBT_CREATEWND, hook },
9959 { WM_NCCREATE, sent },
9960 { WM_NCCALCSIZE, sent|wparam, 0 },
9961 { WM_CREATE, sent },
9962 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
9963 { WM_SIZE, sent|wparam, SIZE_RESTORED },
9965 { WM_SETFONT, sent },
9966 { WM_INITDIALOG, sent },
9967 { WM_CHANGEUISTATE, sent|optional },
9970 /* Creation of a dialog */
9971 static const struct message WmCreateDialogParamSeq_2[] = {
9972 { HCBT_CREATEWND, hook },
9973 { WM_NCCREATE, sent },
9974 { WM_NCCALCSIZE, sent|wparam, 0 },
9975 { WM_CREATE, sent },
9976 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
9977 { WM_SIZE, sent|wparam, SIZE_RESTORED },
9979 { WM_CHANGEUISTATE, sent|optional },
9983 static void test_dialog_messages(void)
9986 HWND hdlg, hedit1, hedit2, hfocus;
9989 #define set_selection(hctl, start, end) \
9990 ret = SendMessage(hctl, EM_SETSEL, start, end); \
9991 ok(ret == 1, "EM_SETSEL returned %ld\n", ret);
9993 #define check_selection(hctl, start, end) \
9994 ret = SendMessage(hctl, EM_GETSEL, 0, 0); \
9995 ok(ret == MAKELRESULT(start, end), "wrong selection (%d - %d)\n", LOWORD(ret), HIWORD(ret));
9999 hdlg = CreateWindowEx(WS_EX_DLGMODALFRAME, "TestDialogClass", NULL,
10000 WS_VISIBLE|WS_CAPTION|WS_SYSMENU|WS_DLGFRAME,
10001 0, 0, 100, 100, 0, 0, 0, NULL);
10002 ok(hdlg != 0, "Failed to create custom dialog window\n");
10004 hedit1 = CreateWindowEx(0, "my_edit_class", NULL,
10005 WS_CHILD|WS_BORDER|WS_VISIBLE|WS_TABSTOP,
10006 0, 0, 80, 20, hdlg, (HMENU)1, 0, NULL);
10007 ok(hedit1 != 0, "Failed to create edit control\n");
10008 hedit2 = CreateWindowEx(0, "my_edit_class", NULL,
10009 WS_CHILD|WS_BORDER|WS_VISIBLE|WS_TABSTOP,
10010 0, 40, 80, 20, hdlg, (HMENU)2, 0, NULL);
10011 ok(hedit2 != 0, "Failed to create edit control\n");
10013 SendMessage(hedit1, WM_SETTEXT, 0, (LPARAM)"hello");
10014 SendMessage(hedit2, WM_SETTEXT, 0, (LPARAM)"bye");
10016 hfocus = GetFocus();
10017 ok(hfocus == hdlg, "wrong focus %p\n", hfocus);
10020 hfocus = GetFocus();
10021 ok(hfocus == hedit2, "wrong focus %p\n", hfocus);
10023 check_selection(hedit1, 0, 0);
10024 check_selection(hedit2, 0, 0);
10026 set_selection(hedit2, 0, -1);
10027 check_selection(hedit2, 0, 3);
10030 hfocus = GetFocus();
10031 ok(hfocus == 0, "wrong focus %p\n", hfocus);
10034 ret = DefDlgProc(hdlg, WM_SETFOCUS, 0, 0);
10035 ok(ret == 0, "WM_SETFOCUS returned %ld\n", ret);
10036 ok_sequence(WmDefDlgSetFocus_1, "DefDlgProc(WM_SETFOCUS) 1", FALSE);
10038 hfocus = GetFocus();
10039 ok(hfocus == hedit1, "wrong focus %p\n", hfocus);
10041 check_selection(hedit1, 0, 5);
10042 check_selection(hedit2, 0, 3);
10045 ret = DefDlgProc(hdlg, WM_SETFOCUS, 0, 0);
10046 ok(ret == 0, "WM_SETFOCUS returned %ld\n", ret);
10047 ok_sequence(WmDefDlgSetFocus_2, "DefDlgProc(WM_SETFOCUS) 2", FALSE);
10049 hfocus = GetFocus();
10050 ok(hfocus == hedit1, "wrong focus %p\n", hfocus);
10052 check_selection(hedit1, 0, 5);
10053 check_selection(hedit2, 0, 3);
10055 EndDialog(hdlg, 0);
10056 DestroyWindow(hedit1);
10057 DestroyWindow(hedit2);
10058 DestroyWindow(hdlg);
10061 #undef set_selection
10062 #undef check_selection
10064 ok(GetClassInfo(0, "#32770", &cls), "GetClassInfo failed\n");
10065 cls.lpszClassName = "MyDialogClass";
10066 cls.hInstance = GetModuleHandle(0);
10067 /* need a cast since a dlgproc is used as a wndproc */
10068 cls.lpfnWndProc = (WNDPROC)test_dlg_proc;
10069 if (!RegisterClass(&cls)) assert(0);
10071 hdlg = CreateDialogParam(0, "CLASS_TEST_DIALOG_2", 0, test_dlg_proc, 0);
10072 ok(IsWindow(hdlg), "CreateDialogParam failed\n");
10073 ok_sequence(WmCreateDialogParamSeq_1, "CreateDialogParam_1", FALSE);
10074 EndDialog(hdlg, 0);
10075 DestroyWindow(hdlg);
10078 hdlg = CreateDialogParam(0, "CLASS_TEST_DIALOG_2", 0, NULL, 0);
10079 ok(IsWindow(hdlg), "CreateDialogParam failed\n");
10080 ok_sequence(WmCreateDialogParamSeq_2, "CreateDialogParam_2", FALSE);
10081 EndDialog(hdlg, 0);
10082 DestroyWindow(hdlg);
10085 UnregisterClass(cls.lpszClassName, cls.hInstance);
10088 static void test_nullCallback(void)
10092 hwnd = CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW,
10093 100, 100, 200, 200, 0, 0, 0, NULL);
10094 ok (hwnd != 0, "Failed to create overlapped window\n");
10096 SendMessageCallbackA(hwnd,WM_NULL,0,0,NULL,0);
10098 DestroyWindow(hwnd);
10101 /* SetActiveWindow( 0 ) hwnd visible */
10102 static const struct message SetActiveWindowSeq0[] =
10104 { HCBT_ACTIVATE, hook },
10105 { WM_NCACTIVATE, sent|wparam, 0 },
10106 { WM_GETTEXT, sent|defwinproc|optional },
10107 { WM_ACTIVATE, sent|wparam, 0 },
10108 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
10109 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE },
10110 { WM_NCACTIVATE, sent|wparam, 1 },
10111 { WM_GETTEXT, sent|defwinproc|optional },
10112 { WM_ACTIVATE, sent|wparam, 1 },
10113 { HCBT_SETFOCUS, hook },
10114 { WM_KILLFOCUS, sent|defwinproc },
10115 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 0 },
10116 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
10117 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 1 },
10118 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
10119 { WM_SETFOCUS, sent|defwinproc },
10122 /* SetActiveWindow( hwnd ) hwnd visible */
10123 static const struct message SetActiveWindowSeq1[] =
10127 /* SetActiveWindow( popup ) hwnd visible, popup visible */
10128 static const struct message SetActiveWindowSeq2[] =
10130 { HCBT_ACTIVATE, hook },
10131 { WM_NCACTIVATE, sent|wparam, 0 },
10132 { WM_GETTEXT, sent|defwinproc|optional },
10133 { WM_ACTIVATE, sent|wparam, 0 },
10134 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE },
10135 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
10136 { WM_NCPAINT, sent|optional },
10137 { WM_GETTEXT, sent|defwinproc|optional },
10138 { WM_ERASEBKGND, sent|optional },
10139 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
10140 { WM_NCACTIVATE, sent|wparam, 1 },
10141 { WM_GETTEXT, sent|defwinproc|optional },
10142 { WM_ACTIVATE, sent|wparam, 1 },
10143 { HCBT_SETFOCUS, hook },
10144 { WM_KILLFOCUS, sent|defwinproc },
10145 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 0 },
10146 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
10147 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 1 },
10148 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
10149 { WM_SETFOCUS, sent|defwinproc },
10153 /* SetActiveWindow( hwnd ) hwnd not visible */
10154 static const struct message SetActiveWindowSeq3[] =
10156 { HCBT_ACTIVATE, hook },
10157 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
10158 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE },
10159 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOACTIVATE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
10160 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
10161 { WM_ACTIVATEAPP, sent|wparam, 1 },
10162 { WM_ACTIVATEAPP, sent|wparam, 1 },
10163 { WM_NCACTIVATE, sent|wparam, 1 },
10164 { WM_ACTIVATE, sent|wparam, 1 },
10165 { HCBT_SETFOCUS, hook },
10166 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
10167 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
10168 { WM_SETFOCUS, sent|defwinproc },
10171 /* SetActiveWindow( popup ) hwnd not visible, popup not visible */
10172 static const struct message SetActiveWindowSeq4[] =
10174 { HCBT_ACTIVATE, hook },
10175 { WM_NCACTIVATE, sent|wparam, 0 },
10176 { WM_GETTEXT, sent|defwinproc|optional },
10177 { WM_ACTIVATE, sent|wparam, 0 },
10178 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE },
10179 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
10180 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
10181 { WM_NCACTIVATE, sent|wparam, 1 },
10182 { WM_GETTEXT, sent|defwinproc|optional },
10183 { WM_ACTIVATE, sent|wparam, 1 },
10184 { HCBT_SETFOCUS, hook },
10185 { WM_KILLFOCUS, sent|defwinproc },
10186 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 0 },
10187 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
10188 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 1 },
10189 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
10190 { WM_SETFOCUS, sent|defwinproc },
10195 static void test_SetActiveWindow(void)
10197 HWND hwnd, popup, ret;
10199 hwnd = CreateWindowExA(0, "TestWindowClass", "Test SetActiveWindow",
10200 WS_OVERLAPPEDWINDOW | WS_VISIBLE,
10201 100, 100, 200, 200, 0, 0, 0, NULL);
10203 popup = CreateWindowExA(0, "TestWindowClass", "Test SetActiveWindow",
10204 WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_POPUP,
10205 100, 100, 200, 200, hwnd, 0, 0, NULL);
10207 ok(hwnd != 0, "Failed to create overlapped window\n");
10210 ok(popup != 0, "Failed to create popup window\n");
10213 trace("SetActiveWindow(0)\n");
10214 ret = SetActiveWindow(0);
10215 ok( ret == popup, "Failed to SetActiveWindow(0)\n");
10216 ok_sequence(SetActiveWindowSeq0, "SetActiveWindow(0)", TRUE);
10219 trace("SetActiveWindow(hwnd), hwnd visible\n");
10220 ret = SetActiveWindow(hwnd);
10223 ok( ret == hwnd, "Failed to SetActiveWindow(hwnd), hwnd visible\n");
10225 ok_sequence(SetActiveWindowSeq1, "SetActiveWindow(hwnd), hwnd visible", TRUE);
10228 trace("SetActiveWindow(popup), hwnd visible, popup visible\n");
10229 ret = SetActiveWindow(popup);
10230 ok( ret == hwnd, "Failed to SetActiveWindow(popup), popup visible\n");
10231 ok_sequence(SetActiveWindowSeq2, "SetActiveWindow(popup), hwnd visible, popup visible", TRUE);
10234 ShowWindow(hwnd, SW_HIDE);
10235 ShowWindow(popup, SW_HIDE);
10238 trace("SetActiveWindow(hwnd), hwnd not visible\n");
10239 ret = SetActiveWindow(hwnd);
10240 ok( ret == NULL, "Failed to SetActiveWindow(hwnd), hwnd not visible\n");
10241 ok_sequence(SetActiveWindowSeq3, "SetActiveWindow(hwnd), hwnd not visible", TRUE);
10244 trace("SetActiveWindow(popup), hwnd not visible, popup not visible\n");
10245 ret = SetActiveWindow(popup);
10246 ok( ret == hwnd, "Failed to SetActiveWindow(popup)\n");
10247 ok_sequence(SetActiveWindowSeq4, "SetActiveWindow(popup), hwnd not visible, popup not visible", TRUE);
10252 DestroyWindow(hwnd);
10255 static const struct message SetForegroundWindowSeq[] =
10257 { WM_NCACTIVATE, sent|wparam, 0 },
10258 { WM_GETTEXT, sent|defwinproc|optional },
10259 { WM_ACTIVATE, sent|wparam, 0 },
10260 { WM_ACTIVATEAPP, sent|wparam, 0 },
10261 { WM_KILLFOCUS, sent },
10262 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
10263 { WM_IME_NOTIFY, sent|wparam|optional|defwinproc, 1 },
10267 static void test_SetForegroundWindow(void)
10271 hwnd = CreateWindowExA(0, "TestWindowClass", "Test SetForegroundWindow",
10272 WS_OVERLAPPEDWINDOW | WS_VISIBLE,
10273 100, 100, 200, 200, 0, 0, 0, NULL);
10274 ok (hwnd != 0, "Failed to create overlapped window\n");
10277 trace("SetForegroundWindow( 0 )\n");
10278 SetForegroundWindow( 0 );
10279 ok_sequence(WmEmptySeq, "SetForegroundWindow( 0 ) away from foreground top level window", FALSE);
10280 trace("SetForegroundWindow( GetDesktopWindow() )\n");
10281 SetForegroundWindow( GetDesktopWindow() );
10282 ok_sequence(SetForegroundWindowSeq, "SetForegroundWindow( desktop ) away from "
10283 "foreground top level window", FALSE);
10286 DestroyWindow(hwnd);
10289 static void test_dbcs_wm_char(void)
10292 WCHAR wch, bad_wch;
10300 struct message wmCharSeq[2];
10302 if (!pGetCPInfoExA)
10304 skip("GetCPInfoExA is not available\n");
10308 pGetCPInfoExA( CP_ACP, 0, &cpinfo );
10309 if (cpinfo.MaxCharSize != 2)
10311 skip( "Skipping DBCS WM_CHAR test in SBCS codepage '%s'\n", cpinfo.CodePageName );
10315 dbch[0] = dbch[1] = 0;
10317 bad_wch = cpinfo.UnicodeDefaultChar;
10318 for (i = 0; !wch && i < MAX_LEADBYTES && cpinfo.LeadByte[i]; i += 2)
10319 for (j = cpinfo.LeadByte[i]; !wch && j <= cpinfo.LeadByte[i+1]; j++)
10320 for (k = 128; k <= 255; k++)
10326 if (MultiByteToWideChar( CP_ACP, 0, str, 2, wstr, 2 ) == 1 &&
10327 WideCharToMultiByte( CP_ACP, 0, wstr, 1, str, 2, NULL, NULL ) == 2 &&
10328 (BYTE)str[0] == j && (BYTE)str[1] == k &&
10329 HIBYTE(wstr[0]) && HIBYTE(wstr[0]) != 0xff)
10340 skip( "Skipping DBCS WM_CHAR test, no appropriate char found\n" );
10343 trace( "using dbcs char %02x,%02x wchar %04x bad wchar %04x codepage '%s'\n",
10344 dbch[0], dbch[1], wch, bad_wch, cpinfo.CodePageName );
10346 hwnd = CreateWindowExW(0, testWindowClassW, NULL,
10347 WS_OVERLAPPEDWINDOW, 100, 100, 200, 200, 0, 0, 0, NULL);
10348 hwnd2 = CreateWindowExW(0, testWindowClassW, NULL,
10349 WS_OVERLAPPEDWINDOW, 100, 100, 200, 200, 0, 0, 0, NULL);
10350 ok (hwnd != 0, "Failed to create overlapped window\n");
10351 ok (hwnd2 != 0, "Failed to create overlapped window\n");
10354 memset( wmCharSeq, 0, sizeof(wmCharSeq) );
10355 wmCharSeq[0].message = WM_CHAR;
10356 wmCharSeq[0].flags = sent|wparam;
10357 wmCharSeq[0].wParam = wch;
10359 /* posted message */
10360 PostMessageA( hwnd, WM_CHAR, dbch[0], 0 );
10361 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10362 PostMessageA( hwnd, WM_CHAR, dbch[1], 0 );
10363 ok( PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "no message\n" );
10364 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
10365 ok( msg.wParam == wch, "bad wparam %lx/%x\n", msg.wParam, wch );
10366 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10368 /* posted thread message */
10369 PostThreadMessageA( GetCurrentThreadId(), WM_CHAR, dbch[0], 0 );
10370 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10371 PostMessageA( hwnd, WM_CHAR, dbch[1], 0 );
10372 ok( PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "no message\n" );
10373 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
10374 ok( msg.wParam == wch, "bad wparam %lx/%x\n", msg.wParam, wch );
10375 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10379 SendMessageA( hwnd, WM_CHAR, dbch[0], 0 );
10380 ok_sequence( WmEmptySeq, "no messages", FALSE );
10381 SendMessageA( hwnd, WM_CHAR, dbch[1], 0 );
10382 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
10383 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10385 /* sent message with timeout */
10387 SendMessageTimeoutA( hwnd, WM_CHAR, dbch[0], 0, SMTO_NORMAL, 0, &res );
10388 ok_sequence( WmEmptySeq, "no messages", FALSE );
10389 SendMessageTimeoutA( hwnd, WM_CHAR, dbch[1], 0, SMTO_NORMAL, 0, &res );
10390 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
10391 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10393 /* sent message with timeout and callback */
10395 SendMessageTimeoutA( hwnd, WM_CHAR, dbch[0], 0, SMTO_NORMAL, 0, &res );
10396 ok_sequence( WmEmptySeq, "no messages", FALSE );
10397 SendMessageCallbackA( hwnd, WM_CHAR, dbch[1], 0, NULL, 0 );
10398 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
10399 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10401 /* sent message with callback */
10403 SendNotifyMessageA( hwnd, WM_CHAR, dbch[0], 0 );
10404 ok_sequence( WmEmptySeq, "no messages", FALSE );
10405 SendMessageCallbackA( hwnd, WM_CHAR, dbch[1], 0, NULL, 0 );
10406 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
10407 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10409 /* direct window proc call */
10411 CallWindowProcA( (WNDPROC)GetWindowLongPtrA( hwnd, GWLP_WNDPROC ), hwnd, WM_CHAR, dbch[0], 0 );
10412 ok_sequence( WmEmptySeq, "no messages", FALSE );
10413 CallWindowProcA( (WNDPROC)GetWindowLongPtrA( hwnd, GWLP_WNDPROC ), hwnd, WM_CHAR, dbch[1], 0 );
10414 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
10416 /* dispatch message */
10418 msg.message = WM_CHAR;
10419 msg.wParam = dbch[0];
10421 DispatchMessageA( &msg );
10422 ok_sequence( WmEmptySeq, "no messages", FALSE );
10423 msg.wParam = dbch[1];
10424 DispatchMessageA( &msg );
10425 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
10427 /* window handle is irrelevant */
10429 SendMessageA( hwnd2, WM_CHAR, dbch[0], 0 );
10430 ok_sequence( WmEmptySeq, "no messages", FALSE );
10431 SendMessageA( hwnd, WM_CHAR, dbch[1], 0 );
10432 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
10433 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10435 /* interleaved post and send */
10437 PostMessageA( hwnd2, WM_CHAR, dbch[0], 0 );
10438 SendMessageA( hwnd2, WM_CHAR, dbch[0], 0 );
10439 ok_sequence( WmEmptySeq, "no messages", FALSE );
10440 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10441 PostMessageA( hwnd, WM_CHAR, dbch[1], 0 );
10442 ok_sequence( WmEmptySeq, "no messages", FALSE );
10443 ok( PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "no message\n" );
10444 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
10445 ok( msg.wParam == wch, "bad wparam %lx/%x\n", msg.wParam, wch );
10446 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10447 SendMessageA( hwnd, WM_CHAR, dbch[1], 0 );
10448 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
10449 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10451 /* interleaved sent message and winproc */
10453 SendMessageA( hwnd, WM_CHAR, dbch[0], 0 );
10454 CallWindowProcA( (WNDPROC)GetWindowLongPtrA( hwnd, GWLP_WNDPROC ), hwnd, WM_CHAR, dbch[0], 0 );
10455 ok_sequence( WmEmptySeq, "no messages", FALSE );
10456 SendMessageA( hwnd, WM_CHAR, dbch[1], 0 );
10457 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
10458 CallWindowProcA( (WNDPROC)GetWindowLongPtrA( hwnd, GWLP_WNDPROC ), hwnd, WM_CHAR, dbch[1], 0 );
10459 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
10461 /* interleaved winproc and dispatch */
10463 msg.message = WM_CHAR;
10464 msg.wParam = dbch[0];
10466 CallWindowProcA( (WNDPROC)GetWindowLongPtrA( hwnd, GWLP_WNDPROC ), hwnd, WM_CHAR, dbch[0], 0 );
10467 DispatchMessageA( &msg );
10468 ok_sequence( WmEmptySeq, "no messages", FALSE );
10469 msg.wParam = dbch[1];
10470 DispatchMessageA( &msg );
10471 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
10472 CallWindowProcA( (WNDPROC)GetWindowLongPtrA( hwnd, GWLP_WNDPROC ), hwnd, WM_CHAR, dbch[1], 0 );
10473 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
10475 /* interleaved sends */
10477 SendMessageA( hwnd, WM_CHAR, dbch[0], 0 );
10478 SendMessageCallbackA( hwnd, WM_CHAR, dbch[0], 0, NULL, 0 );
10479 ok_sequence( WmEmptySeq, "no messages", FALSE );
10480 SendMessageTimeoutA( hwnd, WM_CHAR, dbch[1], 0, SMTO_NORMAL, 0, &res );
10481 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
10482 SendMessageA( hwnd, WM_CHAR, dbch[1], 0 );
10483 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
10487 SendMessageA( hwnd2, WM_CHAR, (dbch[1] << 8) | dbch[0], 0 );
10488 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
10489 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10491 /* other char messages are not magic */
10492 PostMessageA( hwnd, WM_SYSCHAR, dbch[0], 0 );
10493 ok( PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "no message\n" );
10494 ok( msg.message == WM_SYSCHAR, "unexpected message %x\n", msg.message );
10495 ok( msg.wParam == bad_wch, "bad wparam %lx/%x\n", msg.wParam, bad_wch );
10496 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10497 PostMessageA( hwnd, WM_DEADCHAR, dbch[0], 0 );
10498 ok( PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "no message\n" );
10499 ok( msg.message == WM_DEADCHAR, "unexpected message %x\n", msg.message );
10500 ok( msg.wParam == bad_wch, "bad wparam %lx/%x\n", msg.wParam, bad_wch );
10501 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10503 /* test retrieving messages */
10505 PostMessageW( hwnd, WM_CHAR, wch, 0 );
10506 ok( PeekMessageA( &msg, hwnd, 0, 0, PM_REMOVE ), "no message\n" );
10507 ok( msg.hwnd == hwnd, "unexpected hwnd %p\n", msg.hwnd );
10508 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
10509 ok( msg.wParam == dbch[0], "bad wparam %lx/%x\n", msg.wParam, dbch[0] );
10510 ok( PeekMessageA( &msg, hwnd, 0, 0, PM_REMOVE ), "no message\n" );
10511 ok( msg.hwnd == hwnd, "unexpected hwnd %p\n", msg.hwnd );
10512 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
10513 ok( msg.wParam == dbch[1], "bad wparam %lx/%x\n", msg.wParam, dbch[0] );
10514 ok( !PeekMessageA( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10516 /* message filters */
10517 PostMessageW( hwnd, WM_CHAR, wch, 0 );
10518 ok( PeekMessageA( &msg, hwnd, 0, 0, PM_REMOVE ), "no message\n" );
10519 ok( msg.hwnd == hwnd, "unexpected hwnd %p\n", msg.hwnd );
10520 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
10521 ok( msg.wParam == dbch[0], "bad wparam %lx/%x\n", msg.wParam, dbch[0] );
10522 /* message id is filtered, hwnd is not */
10523 ok( !PeekMessageA( &msg, hwnd, WM_MOUSEFIRST, WM_MOUSELAST, PM_REMOVE ), "no message\n" );
10524 ok( PeekMessageA( &msg, hwnd2, 0, 0, PM_REMOVE ), "no message\n" );
10525 ok( msg.hwnd == hwnd, "unexpected hwnd %p\n", msg.hwnd );
10526 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
10527 ok( msg.wParam == dbch[1], "bad wparam %lx/%x\n", msg.wParam, dbch[0] );
10528 ok( !PeekMessageA( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10530 /* mixing GetMessage and PostMessage */
10531 PostMessageW( hwnd, WM_CHAR, wch, 0xbeef );
10532 ok( GetMessageA( &msg, hwnd, 0, 0 ), "no message\n" );
10533 ok( msg.hwnd == hwnd, "unexpected hwnd %p\n", msg.hwnd );
10534 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
10535 ok( msg.wParam == dbch[0], "bad wparam %lx/%x\n", msg.wParam, dbch[0] );
10536 ok( msg.lParam == 0xbeef, "bad lparam %lx\n", msg.lParam );
10539 ok( time - GetTickCount() <= 100, "bad time %x\n", msg.time );
10540 ok( PeekMessageA( &msg, 0, 0, 0, PM_REMOVE ), "no message\n" );
10541 ok( msg.hwnd == hwnd, "unexpected hwnd %p\n", msg.hwnd );
10542 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
10543 ok( msg.wParam == dbch[1], "bad wparam %lx/%x\n", msg.wParam, dbch[0] );
10544 ok( msg.lParam == 0xbeef, "bad lparam %lx\n", msg.lParam );
10545 ok( msg.time == time, "bad time %x/%x\n", msg.time, time );
10546 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 );
10547 ok( !PeekMessageA( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10549 /* without PM_REMOVE */
10550 PostMessageW( hwnd, WM_CHAR, wch, 0 );
10551 ok( PeekMessageA( &msg, 0, 0, 0, PM_NOREMOVE ), "no message\n" );
10552 ok( msg.hwnd == hwnd, "unexpected hwnd %p\n", msg.hwnd );
10553 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
10554 ok( msg.wParam == dbch[0], "bad wparam %lx/%x\n", msg.wParam, dbch[0] );
10555 ok( PeekMessageA( &msg, 0, 0, 0, PM_REMOVE ), "no message\n" );
10556 ok( msg.hwnd == hwnd, "unexpected hwnd %p\n", msg.hwnd );
10557 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
10558 ok( msg.wParam == dbch[0], "bad wparam %lx/%x\n", msg.wParam, dbch[0] );
10559 ok( PeekMessageA( &msg, 0, 0, 0, PM_NOREMOVE ), "no message\n" );
10560 ok( msg.hwnd == hwnd, "unexpected hwnd %p\n", msg.hwnd );
10561 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
10562 ok( msg.wParam == dbch[1], "bad wparam %lx/%x\n", msg.wParam, dbch[0] );
10563 ok( PeekMessageA( &msg, 0, 0, 0, PM_REMOVE ), "no message\n" );
10564 ok( msg.hwnd == hwnd, "unexpected hwnd %p\n", msg.hwnd );
10565 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
10566 ok( msg.wParam == dbch[1], "bad wparam %lx/%x\n", msg.wParam, dbch[0] );
10567 ok( !PeekMessageA( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10569 DestroyWindow(hwnd);
10572 #define ID_LISTBOX 0x000f
10574 static const struct message wm_lb_setcursel_0[] =
10576 { LB_SETCURSEL, sent|wparam|lparam, 0, 0 },
10577 { WM_CTLCOLORLISTBOX, sent|parent },
10578 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_LISTBOX, 0x000120f2 },
10579 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 1 },
10580 { EVENT_OBJECT_SELECTION, winevent_hook|wparam|lparam, OBJID_CLIENT, 1 },
10583 static const struct message wm_lb_setcursel_1[] =
10585 { LB_SETCURSEL, sent|wparam|lparam, 1, 0 },
10586 { WM_CTLCOLORLISTBOX, sent|parent },
10587 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_LISTBOX, 0x000020f2 },
10588 { WM_CTLCOLORLISTBOX, sent|parent },
10589 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_LISTBOX, 0x000121f2 },
10590 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 2 },
10591 { EVENT_OBJECT_SELECTION, winevent_hook|wparam|lparam, OBJID_CLIENT, 2 },
10594 static const struct message wm_lb_setcursel_2[] =
10596 { LB_SETCURSEL, sent|wparam|lparam, 2, 0 },
10597 { WM_CTLCOLORLISTBOX, sent|parent },
10598 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_LISTBOX, 0x000021f2 },
10599 { WM_CTLCOLORLISTBOX, sent|parent },
10600 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_LISTBOX, 0x000122f2 },
10601 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 3 },
10602 { EVENT_OBJECT_SELECTION, winevent_hook|wparam|lparam, OBJID_CLIENT, 3 },
10605 static const struct message wm_lb_click_0[] =
10607 { WM_LBUTTONDOWN, sent|wparam|lparam, 0, MAKELPARAM(1,1) },
10608 { HCBT_SETFOCUS, hook },
10609 { WM_KILLFOCUS, sent|parent },
10610 { WM_IME_SETCONTEXT, sent|wparam|optional|parent, 0 },
10611 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
10612 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
10613 { WM_SETFOCUS, sent|defwinproc },
10615 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_LISTBOX, 0x001142f2 },
10616 { WM_COMMAND, sent|wparam|parent, MAKEWPARAM(ID_LISTBOX, LBN_SETFOCUS) },
10617 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 3 },
10618 { WM_LBTRACKPOINT, sent|wparam|lparam|parent, 0, MAKELPARAM(1,1) },
10619 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
10621 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_LISTBOX, 0x000142f2 },
10622 { WM_CTLCOLORLISTBOX, sent|parent },
10623 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_LISTBOX, 0x000022f2 },
10624 { WM_CTLCOLORLISTBOX, sent|parent },
10625 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_LISTBOX, 0x000120f2 },
10626 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_LISTBOX, 0x001140f2 },
10628 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 1 },
10629 { EVENT_OBJECT_SELECTION, winevent_hook|wparam|lparam, OBJID_CLIENT, 1 },
10631 { WM_LBUTTONUP, sent|wparam|lparam, 0, 0 },
10632 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, 0, 0 },
10633 { WM_CAPTURECHANGED, sent|wparam|lparam|defwinproc, 0, 0 },
10634 { WM_COMMAND, sent|wparam|parent, MAKEWPARAM(ID_LISTBOX, LBN_SELCHANGE) },
10638 #define check_lb_state(a1, a2, a3, a4, a5) check_lb_state_dbg(a1, a2, a3, a4, a5, __LINE__)
10640 static LRESULT (WINAPI *listbox_orig_proc)(HWND, UINT, WPARAM, LPARAM);
10642 static LRESULT WINAPI listbox_hook_proc(HWND hwnd, UINT message, WPARAM wp, LPARAM lp)
10644 static long defwndproc_counter = 0;
10646 struct message msg;
10648 /* do not log painting messages */
10649 if (message != WM_PAINT &&
10650 message != WM_NCPAINT &&
10651 message != WM_SYNCPAINT &&
10652 message != WM_ERASEBKGND &&
10653 message != WM_NCHITTEST &&
10654 message != WM_GETTEXT &&
10655 message != WM_GETICON &&
10656 message != WM_DEVICECHANGE)
10658 trace("listbox: %p, %04x, %08lx, %08lx\n", hwnd, message, wp, lp);
10660 msg.message = message;
10661 msg.flags = sent|wparam|lparam;
10662 if (defwndproc_counter) msg.flags |= defwinproc;
10668 defwndproc_counter++;
10669 ret = CallWindowProcA(listbox_orig_proc, hwnd, message, wp, lp);
10670 defwndproc_counter--;
10675 static void check_lb_state_dbg(HWND listbox, int count, int cur_sel,
10676 int caret_index, int top_index, int line)
10680 /* calling an orig proc helps to avoid unnecessary message logging */
10681 ret = CallWindowProcA(listbox_orig_proc, listbox, LB_GETCOUNT, 0, 0);
10682 ok_(__FILE__, line)(ret == count, "expected count %d, got %ld\n", count, ret);
10683 ret = CallWindowProcA(listbox_orig_proc, listbox, LB_GETCURSEL, 0, 0);
10684 ok_(__FILE__, line)(ret == cur_sel, "expected cur sel %d, got %ld\n", cur_sel, ret);
10685 ret = CallWindowProcA(listbox_orig_proc, listbox, LB_GETCARETINDEX, 0, 0);
10686 ok_(__FILE__, line)(ret == caret_index, "expected caret index %d, got %ld\n", caret_index, ret);
10687 ret = CallWindowProcA(listbox_orig_proc, listbox, LB_GETTOPINDEX, 0, 0);
10688 ok_(__FILE__, line)(ret == top_index, "expected top index %d, got %ld\n", top_index, ret);
10691 static void test_listbox_messages(void)
10693 HWND parent, listbox;
10696 parent = CreateWindowExA(0, "TestParentClass", NULL, WS_OVERLAPPEDWINDOW | WS_VISIBLE,
10697 100, 100, 200, 200, 0, 0, 0, NULL);
10698 listbox = CreateWindowExA(WS_EX_NOPARENTNOTIFY, "ListBox", NULL,
10699 WS_CHILD | LBS_NOTIFY | LBS_OWNERDRAWVARIABLE | LBS_HASSTRINGS | WS_VISIBLE,
10700 10, 10, 80, 80, parent, (HMENU)ID_LISTBOX, 0, NULL);
10701 listbox_orig_proc = (WNDPROC)SetWindowLongPtrA(listbox, GWLP_WNDPROC, (ULONG_PTR)listbox_hook_proc);
10703 check_lb_state(listbox, 0, LB_ERR, 0, 0);
10705 ret = SendMessage(listbox, LB_ADDSTRING, 0, (LPARAM)"item 0");
10706 ok(ret == 0, "expected 0, got %ld\n", ret);
10707 ret = SendMessage(listbox, LB_ADDSTRING, 0, (LPARAM)"item 1");
10708 ok(ret == 1, "expected 1, got %ld\n", ret);
10709 ret = SendMessage(listbox, LB_ADDSTRING, 0, (LPARAM)"item 2");
10710 ok(ret == 2, "expected 2, got %ld\n", ret);
10712 check_lb_state(listbox, 3, LB_ERR, 0, 0);
10716 log_all_parent_messages++;
10718 trace("selecting item 0\n");
10719 ret = SendMessage(listbox, LB_SETCURSEL, 0, 0);
10720 ok(ret == 0, "expected 0, got %ld\n", ret);
10721 ok_sequence(wm_lb_setcursel_0, "LB_SETCURSEL 0", FALSE );
10722 check_lb_state(listbox, 3, 0, 0, 0);
10725 trace("selecting item 1\n");
10726 ret = SendMessage(listbox, LB_SETCURSEL, 1, 0);
10727 ok(ret == 1, "expected 1, got %ld\n", ret);
10728 ok_sequence(wm_lb_setcursel_1, "LB_SETCURSEL 1", FALSE );
10729 check_lb_state(listbox, 3, 1, 1, 0);
10731 trace("selecting item 2\n");
10732 ret = SendMessage(listbox, LB_SETCURSEL, 2, 0);
10733 ok(ret == 2, "expected 2, got %ld\n", ret);
10734 ok_sequence(wm_lb_setcursel_2, "LB_SETCURSEL 2", FALSE );
10735 check_lb_state(listbox, 3, 2, 2, 0);
10737 trace("clicking on item 0\n");
10738 ret = SendMessage(listbox, WM_LBUTTONDOWN, 0, MAKELPARAM(1, 1));
10739 ok(ret == LB_OKAY, "expected LB_OKAY, got %ld\n", ret);
10740 ret = SendMessage(listbox, WM_LBUTTONUP, 0, 0);
10741 ok(ret == LB_OKAY, "expected LB_OKAY, got %ld\n", ret);
10742 ok_sequence(wm_lb_click_0, "WM_LBUTTONDOWN 0", FALSE );
10743 check_lb_state(listbox, 3, 0, 0, 0);
10746 log_all_parent_messages--;
10748 DestroyWindow(listbox);
10749 DestroyWindow(parent);
10752 /*************************** Menu test ******************************/
10753 static const struct message wm_popup_menu_1[] =
10755 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0x20000001 },
10756 { WM_SYSKEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
10757 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'E', 0x20000001 },
10758 { WM_SYSKEYDOWN, sent|wparam|lparam, 'E', 0x20000001 },
10759 { WM_SYSCHAR, sent|wparam|lparam, 'e', 0x20000001 },
10760 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_KEYMENU, 'e' },
10761 { WM_ENTERMENULOOP, sent|wparam|lparam, 0, 0 },
10762 { WM_INITMENU, sent|lparam, 0, 0 },
10763 { WM_MENUSELECT, sent|wparam, MAKEWPARAM(1,MF_HILITE|MF_POPUP) },
10764 { WM_INITMENUPOPUP, sent|lparam, 0, 1 },
10765 { HCBT_CREATEWND, hook|optional }, /* Win9x doesn't create a window */
10766 { WM_MENUSELECT, sent|wparam, MAKEWPARAM(200,MF_HILITE) },
10767 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'E', 0xf0000001 },
10768 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0xd0000001 },
10769 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_RETURN, 0x10000001 },
10770 { HCBT_DESTROYWND, hook|optional }, /* Win9x doesn't create a window */
10771 { WM_UNINITMENUPOPUP, sent|lparam, 0, 0 },
10772 { WM_MENUSELECT, sent|wparam|lparam, MAKEWPARAM(0,0xffff), 0 },
10773 { WM_EXITMENULOOP, sent|wparam|lparam, 0, 0 },
10774 { WM_MENUCOMMAND, sent }, /* |wparam, 200 - Win9x */
10775 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_RETURN, 0xc0000001 },
10776 { WM_KEYUP, sent|wparam|lparam, VK_RETURN, 0xc0000001 },
10779 static const struct message wm_popup_menu_2[] =
10781 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0x20000001 },
10782 { WM_SYSKEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
10783 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'F', 0x20000001 },
10784 { WM_SYSKEYDOWN, sent|wparam|lparam, 'F', 0x20000001 },
10785 { WM_SYSCHAR, sent|wparam|lparam, 'f', 0x20000001 },
10786 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_KEYMENU, 'f' },
10787 { WM_ENTERMENULOOP, sent|wparam|lparam, 0, 0 },
10788 { WM_INITMENU, sent|lparam, 0, 0 },
10789 { WM_MENUSELECT, sent|wparam, MAKEWPARAM(0,MF_HILITE|MF_POPUP) },
10790 { WM_INITMENUPOPUP, sent|lparam, 0, 0 },
10791 { WM_MENUSELECT, sent|wparam|optional, MAKEWPARAM(0,MF_HILITE|MF_POPUP) }, /* Win9x */
10792 { WM_INITMENUPOPUP, sent|lparam|optional, 0, 0 }, /* Win9x */
10793 { HCBT_CREATEWND, hook },
10794 { WM_MENUSELECT, sent }, /*|wparam, MAKEWPARAM(0,MF_HILITE|MF_POPUP) - XP
10795 |wparam, MAKEWPARAM(100,MF_HILITE) - Win9x */
10796 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'F', 0xf0000001 },
10797 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0xd0000001 },
10798 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_RIGHT, 0x10000001 },
10799 { WM_INITMENUPOPUP, sent|lparam|optional, 0, 0 }, /* Win9x doesn't send it */
10800 { HCBT_CREATEWND, hook|optional }, /* Win9x doesn't send it */
10801 { WM_MENUSELECT, sent|wparam|optional, MAKEWPARAM(100,MF_HILITE) },
10802 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_RIGHT, 0xd0000001 },
10803 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_RETURN, 0x10000001 },
10804 { HCBT_DESTROYWND, hook },
10805 { WM_UNINITMENUPOPUP, sent|lparam, 0, 0 },
10806 { HCBT_DESTROYWND, hook|optional }, /* Win9x doesn't send it */
10807 { WM_UNINITMENUPOPUP, sent|lparam, 0, 0 },
10808 { WM_MENUSELECT, sent|wparam|lparam, MAKEWPARAM(0,0xffff), 0 },
10809 { WM_EXITMENULOOP, sent|wparam|lparam, 0, 0 },
10810 { WM_MENUCOMMAND, sent }, /* |wparam, 100 - Win9x */
10811 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_RETURN, 0xc0000001 },
10812 { WM_KEYUP, sent|wparam|lparam, VK_RETURN, 0xc0000001 },
10815 static const struct message wm_popup_menu_3[] =
10817 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0x20000001 },
10818 { WM_SYSKEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
10819 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'F', 0x20000001 },
10820 { WM_SYSKEYDOWN, sent|wparam|lparam, 'F', 0x20000001 },
10821 { WM_SYSCHAR, sent|wparam|lparam, 'f', 0x20000001 },
10822 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_KEYMENU, 'f' },
10823 { WM_ENTERMENULOOP, sent|wparam|lparam, 0, 0 },
10824 { WM_INITMENU, sent|lparam, 0, 0 },
10825 { WM_MENUSELECT, sent|wparam, MAKEWPARAM(0,MF_HILITE|MF_POPUP) },
10826 { WM_INITMENUPOPUP, sent|lparam, 0, 0 },
10827 { WM_MENUSELECT, sent|wparam|optional, MAKEWPARAM(0,MF_HILITE|MF_POPUP) }, /* Win9x */
10828 { WM_INITMENUPOPUP, sent|lparam|optional, 0, 0 }, /* Win9x */
10829 { HCBT_CREATEWND, hook },
10830 { WM_MENUSELECT, sent }, /*|wparam, MAKEWPARAM(0,MF_HILITE|MF_POPUP) - XP
10831 |wparam, MAKEWPARAM(100,MF_HILITE) - Win9x */
10832 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'F', 0xf0000001 },
10833 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0xd0000001 },
10834 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_RIGHT, 0x10000001 },
10835 { WM_INITMENUPOPUP, sent|lparam|optional, 0, 0 }, /* Win9x doesn't send it */
10836 { HCBT_CREATEWND, hook|optional }, /* Win9x doesn't send it */
10837 { WM_MENUSELECT, sent|wparam|optional, MAKEWPARAM(100,MF_HILITE) },
10838 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_RIGHT, 0xd0000001 },
10839 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_RETURN, 0x10000001 },
10840 { HCBT_DESTROYWND, hook },
10841 { WM_UNINITMENUPOPUP, sent|lparam, 0, 0 },
10842 { HCBT_DESTROYWND, hook|optional }, /* Win9x doesn't send it */
10843 { WM_UNINITMENUPOPUP, sent|lparam, 0, 0 },
10844 { WM_MENUSELECT, sent|wparam|lparam, MAKEWPARAM(0,0xffff), 0 },
10845 { WM_EXITMENULOOP, sent|wparam|lparam, 0, 0 },
10846 { WM_COMMAND, sent|wparam|lparam, 100, 0 },
10847 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_RETURN, 0xc0000001 },
10848 { WM_KEYUP, sent|wparam|lparam, VK_RETURN, 0xc0000001 },
10852 static LRESULT WINAPI parent_menu_proc(HWND hwnd, UINT message, WPARAM wp, LPARAM lp)
10854 if (message == WM_ENTERIDLE ||
10855 message == WM_INITMENU ||
10856 message == WM_INITMENUPOPUP ||
10857 message == WM_MENUSELECT ||
10858 message == WM_PARENTNOTIFY ||
10859 message == WM_ENTERMENULOOP ||
10860 message == WM_EXITMENULOOP ||
10861 message == WM_UNINITMENUPOPUP ||
10862 message == WM_KEYDOWN ||
10863 message == WM_KEYUP ||
10864 message == WM_CHAR ||
10865 message == WM_SYSKEYDOWN ||
10866 message == WM_SYSKEYUP ||
10867 message == WM_SYSCHAR ||
10868 message == WM_COMMAND ||
10869 message == WM_MENUCOMMAND)
10871 struct message msg;
10873 trace("parent_menu_proc: %p, %04x, %08lx, %08lx\n", hwnd, message, wp, lp);
10875 msg.message = message;
10876 msg.flags = sent|wparam|lparam;
10882 return DefWindowProcA(hwnd, message, wp, lp);
10885 static void set_menu_style(HMENU hmenu, DWORD style)
10890 mi.cbSize = sizeof(mi);
10891 mi.fMask = MIM_STYLE;
10892 mi.dwStyle = style;
10893 SetLastError(0xdeadbeef);
10894 ret = pSetMenuInfo(hmenu, &mi);
10895 ok(ret, "SetMenuInfo error %u\n", GetLastError());
10898 static DWORD get_menu_style(HMENU hmenu)
10903 mi.cbSize = sizeof(mi);
10904 mi.fMask = MIM_STYLE;
10906 SetLastError(0xdeadbeef);
10907 ret = pGetMenuInfo(hmenu, &mi);
10908 ok(ret, "GetMenuInfo error %u\n", GetLastError());
10913 static void test_menu_messages(void)
10917 HMENU hmenu, hmenu_popup;
10921 if (!pGetMenuInfo || !pSetMenuInfo)
10923 skip("GetMenuInfo and/or SetMenuInfo are not available\n");
10927 cls.lpfnWndProc = parent_menu_proc;
10928 cls.cbClsExtra = 0;
10929 cls.cbWndExtra = 0;
10930 cls.hInstance = GetModuleHandleA(0);
10932 cls.hCursor = LoadCursorA(0, (LPSTR)IDC_ARROW);
10933 cls.hbrBackground = GetStockObject(WHITE_BRUSH);
10934 cls.lpszMenuName = NULL;
10935 cls.lpszClassName = "TestMenuClass";
10936 UnregisterClass(cls.lpszClassName, cls.hInstance);
10937 if (!RegisterClassA(&cls)) assert(0);
10939 SetLastError(0xdeadbeef);
10940 hwnd = CreateWindowExA(0, "TestMenuClass", NULL, WS_OVERLAPPEDWINDOW | WS_VISIBLE,
10941 100, 100, 200, 200, 0, 0, 0, NULL);
10942 ok(hwnd != 0, "LoadMenuA error %u\n", GetLastError());
10944 SetLastError(0xdeadbeef);
10945 hmenu = LoadMenuA(GetModuleHandle(0), MAKEINTRESOURCE(1));
10946 ok(hmenu != 0, "LoadMenuA error %u\n", GetLastError());
10948 SetMenu(hwnd, hmenu);
10949 SetForegroundWindow( hwnd );
10951 set_menu_style(hmenu, MNS_NOTIFYBYPOS);
10952 style = get_menu_style(hmenu);
10953 ok(style == MNS_NOTIFYBYPOS, "expected MNS_NOTIFYBYPOS, got %u\n", style);
10955 hmenu_popup = GetSubMenu(hmenu, 0);
10956 ok(hmenu_popup != 0, "GetSubMenu returned 0 for submenu 0\n");
10957 style = get_menu_style(hmenu_popup);
10958 ok(style == 0, "expected 0, got %u\n", style);
10960 hmenu_popup = GetSubMenu(hmenu_popup, 0);
10961 ok(hmenu_popup != 0, "GetSubMenu returned 0 for submenu 0\n");
10962 style = get_menu_style(hmenu_popup);
10963 ok(style == 0, "expected 0, got %u\n", style);
10966 trace("testing a popup menu command\n");
10968 keybd_event(VK_MENU, 0, 0, 0);
10969 keybd_event('E', 0, 0, 0);
10970 keybd_event('E', 0, KEYEVENTF_KEYUP, 0);
10971 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
10972 keybd_event(VK_RETURN, 0, 0, 0);
10973 keybd_event(VK_RETURN, 0, KEYEVENTF_KEYUP, 0);
10974 while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
10976 TranslateMessage(&msg);
10977 DispatchMessage(&msg);
10979 ok_sequence(wm_popup_menu_1, "popup menu command", FALSE);
10981 /* Alt+F, Right, Enter */
10982 trace("testing submenu of a popup menu command\n");
10984 keybd_event(VK_MENU, 0, 0, 0);
10985 keybd_event('F', 0, 0, 0);
10986 keybd_event('F', 0, KEYEVENTF_KEYUP, 0);
10987 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
10988 keybd_event(VK_RIGHT, 0, 0, 0);
10989 keybd_event(VK_RIGHT, 0, KEYEVENTF_KEYUP, 0);
10990 keybd_event(VK_RETURN, 0, 0, 0);
10991 keybd_event(VK_RETURN, 0, KEYEVENTF_KEYUP, 0);
10992 while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
10994 TranslateMessage(&msg);
10995 DispatchMessage(&msg);
10997 ok_sequence(wm_popup_menu_2, "submenu of a popup menu command", FALSE);
10999 set_menu_style(hmenu, 0);
11000 style = get_menu_style(hmenu);
11001 ok(style == 0, "expected 0, got %u\n", style);
11003 hmenu_popup = GetSubMenu(hmenu, 0);
11004 ok(hmenu_popup != 0, "GetSubMenu returned 0 for submenu 0\n");
11005 set_menu_style(hmenu_popup, MNS_NOTIFYBYPOS);
11006 style = get_menu_style(hmenu_popup);
11007 ok(style == MNS_NOTIFYBYPOS, "expected MNS_NOTIFYBYPOS, got %u\n", style);
11009 hmenu_popup = GetSubMenu(hmenu_popup, 0);
11010 ok(hmenu_popup != 0, "GetSubMenu returned 0 for submenu 0\n");
11011 style = get_menu_style(hmenu_popup);
11012 ok(style == 0, "expected 0, got %u\n", style);
11014 /* Alt+F, Right, Enter */
11015 trace("testing submenu of a popup menu command\n");
11017 keybd_event(VK_MENU, 0, 0, 0);
11018 keybd_event('F', 0, 0, 0);
11019 keybd_event('F', 0, KEYEVENTF_KEYUP, 0);
11020 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
11021 keybd_event(VK_RIGHT, 0, 0, 0);
11022 keybd_event(VK_RIGHT, 0, KEYEVENTF_KEYUP, 0);
11023 keybd_event(VK_RETURN, 0, 0, 0);
11024 keybd_event(VK_RETURN, 0, KEYEVENTF_KEYUP, 0);
11025 while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
11027 TranslateMessage(&msg);
11028 DispatchMessage(&msg);
11030 ok_sequence(wm_popup_menu_3, "submenu of a popup menu command", FALSE);
11032 DestroyWindow(hwnd);
11033 DestroyMenu(hmenu);
11039 FARPROC pIsWinEventHookInstalled = 0;/*GetProcAddress(user32, "IsWinEventHookInstalled");*/
11043 if (!RegisterWindowClasses()) assert(0);
11045 if (pSetWinEventHook)
11047 hEvent_hook = (HWINEVENTHOOK)pSetWinEventHook(EVENT_MIN, EVENT_MAX,
11048 GetModuleHandleA(0),
11051 GetCurrentThreadId(),
11052 WINEVENT_INCONTEXT);
11053 assert(hEvent_hook);
11055 if (pIsWinEventHookInstalled)
11058 for (event = EVENT_MIN; event <= EVENT_MAX; event++)
11059 ok(pIsWinEventHookInstalled(event), "IsWinEventHookInstalled(%u) failed\n", event);
11063 cbt_hook_thread_id = GetCurrentThreadId();
11064 hCBT_hook = SetWindowsHookExA(WH_CBT, cbt_hook_proc, 0, GetCurrentThreadId());
11069 /* Fix message sequences before removing 4 lines below */
11071 if (pUnhookWinEvent && hEvent_hook)
11073 ret = pUnhookWinEvent(hEvent_hook);
11074 ok( ret, "UnhookWinEvent error %d\n", GetLastError());
11075 pUnhookWinEvent = 0;
11081 test_PeekMessage();
11082 test_PeekMessage2();
11083 test_scrollwindowex();
11085 test_setwindowpos();
11087 invisible_parent_tests();
11088 test_mdi_messages();
11089 test_button_messages();
11090 test_static_messages();
11091 test_listbox_messages();
11092 test_combobox_messages();
11093 test_wmime_keydown_message();
11094 test_paint_messages();
11095 test_interthread_messages();
11096 test_message_conversion();
11097 test_accelerators();
11099 test_timers_no_wnd();
11101 test_DestroyWindow();
11102 test_DispatchMessage();
11103 test_SendMessageTimeout();
11104 test_edit_messages();
11105 test_quit_message();
11106 test_SetActiveWindow();
11108 if (!pTrackMouseEvent)
11109 skip("TrackMouseEvent is not available\n");
11111 test_TrackMouseEvent();
11113 test_SetWindowRgn();
11115 test_dialog_messages();
11116 test_nullCallback();
11117 test_dbcs_wm_char();
11118 test_menu_messages();
11119 /* keep it the last test, under Windows it tends to break the tests
11120 * which rely on active/foreground windows being correct.
11122 test_SetForegroundWindow();
11124 UnhookWindowsHookEx(hCBT_hook);
11125 if (pUnhookWinEvent)
11127 ret = pUnhookWinEvent(hEvent_hook);
11128 ok( ret, "UnhookWinEvent error %d\n", GetLastError());
11129 SetLastError(0xdeadbeef);
11130 ok(!pUnhookWinEvent(hEvent_hook), "UnhookWinEvent succeeded\n");
11131 ok(GetLastError() == ERROR_INVALID_HANDLE || /* Win2k */
11132 GetLastError() == 0xdeadbeef, /* Win9x */
11133 "unexpected error %d\n", GetLastError());
11136 skip("UnhookWinEvent is not available\n");