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 },
168 /* SetWindowPos(SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE)
169 * for a visible overlapped window.
171 static const struct message WmSWP_HideOverlappedSeq[] = {
172 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE },
173 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
174 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
178 /* SetWindowPos(SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOMOVE)
179 * for a visible overlapped window.
181 static const struct message WmSWP_ResizeSeq[] = {
182 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE },
183 { WM_GETMINMAXINFO, sent|defwinproc },
184 { WM_NCCALCSIZE, sent|wparam, TRUE },
185 { WM_NCPAINT, sent|optional },
186 { WM_GETTEXT, sent|defwinproc|optional },
187 { WM_ERASEBKGND, sent|optional },
188 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOCLIENTMOVE },
189 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
190 { WM_NCCALCSIZE, sent|wparam|optional, TRUE },
191 { WM_NCPAINT, sent|optional },
192 { WM_GETTEXT, sent|defwinproc|optional },
193 { WM_ERASEBKGND, sent|optional },
194 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
195 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* XP sends a duplicate */
199 /* SetWindowPos(SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOMOVE)
200 * for a visible popup window.
202 static const struct message WmSWP_ResizePopupSeq[] = {
203 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE },
204 { WM_GETMINMAXINFO, sent|defwinproc|optional }, /* Win9x */
205 { WM_NCCALCSIZE, sent|wparam, TRUE },
206 { WM_NCPAINT, sent|optional },
207 { WM_GETTEXT, sent|defwinproc|optional },
208 { WM_ERASEBKGND, sent|optional },
209 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOCLIENTMOVE },
210 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
211 { WM_NCCALCSIZE, sent|wparam|optional, TRUE },
212 { WM_NCPAINT, sent|optional },
213 { WM_GETTEXT, sent|defwinproc|optional },
214 { WM_ERASEBKGND, sent|optional },
215 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
219 /* SetWindowPos(SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOSIZE)
220 * for a visible overlapped window.
222 static const struct message WmSWP_MoveSeq[] = {
223 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_NOSIZE },
224 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOCLIENTSIZE },
225 { WM_MOVE, sent|defwinproc|wparam, 0 },
226 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
229 /* Resize with SetWindowPos(SWP_NOZORDER)
230 * for a visible overlapped window
231 * SWP_NOZORDER is stripped by the logging code
233 static const struct message WmSWP_ResizeNoZOrder[] = {
234 { WM_WINDOWPOSCHANGING, sent|wparam, 0/*SWP_NOZORDER*/ },
235 { WM_GETMINMAXINFO, sent|defwinproc },
236 { WM_NCCALCSIZE, sent|wparam, 1 },
237 { WM_NCPAINT, sent },
238 { WM_GETTEXT, sent|defwinproc|optional },
239 { WM_ERASEBKGND, sent|optional }, /* FIXME: remove optional once Wine is fixed */
240 { WM_WINDOWPOSCHANGED, sent|wparam, /*SWP_NOZORDER|*/SWP_NOMOVE|SWP_NOCLIENTMOVE },
241 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
242 { WM_NCCALCSIZE, sent|wparam|optional, 1 }, /* Win9x doesn't send it */
243 { WM_NCPAINT, sent|optional }, /* Win9x doesn't send it */
244 { WM_GETTEXT, sent|defwinproc|optional }, /* Win9x doesn't send it */
245 { WM_ERASEBKGND, sent|optional }, /* Win9x doesn't send it */
246 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
247 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
251 /* Switch visible mdi children */
252 static const struct message WmSwitchChild[] = {
253 /* Switch MDI child */
254 { WM_MDIACTIVATE, sent },/* in the MDI client */
255 { WM_WINDOWPOSCHANGING, sent|wparam,SWP_NOSIZE|SWP_NOMOVE },/* in the 1st MDI child */
256 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
257 { WM_CHILDACTIVATE, sent },/* in the 1st MDI child */
258 /* Deactivate 2nd MDI child */
259 { WM_NCACTIVATE, sent|wparam|defwinproc, 0 }, /* in the 2nd MDI child */
260 { WM_MDIACTIVATE, sent|defwinproc }, /* in the 2nd MDI child */
261 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
262 /* Preparing for maximize and maximaze the 1st MDI child */
263 { WM_GETMINMAXINFO, sent|defwinproc }, /* in the 1st MDI child */
264 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_STATECHANGED }, /* in the 1st MDI child */
265 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 }, /* in the 1st MDI child */
266 { WM_CHILDACTIVATE, sent|defwinproc }, /* in the 1st MDI child */
267 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_STATECHANGED }, /* in the 1st MDI child */
268 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED }, /* in the 1st MDI child */
269 /* Lock redraw 2nd MDI child */
270 { WM_SETREDRAW, sent|wparam|defwinproc, 0 }, /* in the 2nd MDI child */
271 { HCBT_MINMAX, hook|lparam, 0, SW_NORMALNA },
272 /* Restore 2nd MDI child */
273 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_STATECHANGED },/* in the 2nd MDI child */
274 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 },/* in the 2nd MDI child */
275 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 }, /* in the 2nd MDI child */
276 { 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 */
277 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED }, /* in the 2nd MDI child */
278 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* in the 2nd MDI child */
279 /* Redraw 2nd MDI child */
280 { WM_SETREDRAW, sent|wparam|defwinproc, 1 },/* in the 2nd MDI child */
281 /* Redraw MDI frame */
282 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE },/* in MDI frame */
283 { WM_NCCALCSIZE, sent|wparam, 1 },/* in MDI frame */
284 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE}, /* in MDI frame */
285 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* in MDI frame */
286 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* in the 1st MDI child */
287 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE }, /* in the 1st MDI child */
288 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 }, /* in the 1st MDI child */
289 { HCBT_SETFOCUS, hook },
290 { WM_KILLFOCUS, sent|defwinproc }, /* in the 2nd MDI child */
291 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 0 },/* in the 1st MDI child */
292 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
293 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
294 { WM_SETFOCUS, sent },/* in the MDI client */
295 { HCBT_SETFOCUS, hook },
296 { WM_KILLFOCUS, sent },/* in the MDI client */
297 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
298 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 }, /* in the 1st MDI child */
299 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
300 { WM_SETFOCUS, sent|defwinproc }, /* in the 1st MDI child */
301 { WM_MDIACTIVATE, sent|defwinproc },/* in the 1st MDI child */
302 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE }, /* in the 1st MDI child */
306 /* Switch visible not maximized mdi children */
307 static const struct message WmSwitchNotMaximizedChild[] = {
308 /* Switch not maximized MDI child */
309 { WM_MDIACTIVATE, sent },/* in the MDI client */
310 { WM_WINDOWPOSCHANGING, sent|wparam,SWP_NOSIZE|SWP_NOMOVE },/* in the 2nd MDI child */
311 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
312 { WM_CHILDACTIVATE, sent },/* in the 2nd MDI child */
313 /* Deactivate 1st MDI child */
314 { WM_NCACTIVATE, sent|wparam|defwinproc, 0 }, /* in the 1st MDI child */
315 { WM_MDIACTIVATE, sent|defwinproc }, /* in the 1st MDI child */
316 /* Activate 2nd MDI child */
317 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE}, /* in the 2nd MDI child */
318 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 }, /* in the 2nd MDI child */
319 { HCBT_SETFOCUS, hook }, /* in the 1st MDI child */
320 { WM_KILLFOCUS, sent|defwinproc }, /* in the 1st MDI child */
321 { WM_IME_SETCONTEXT, sent|defwinproc|optional }, /* in the 1st MDI child */
322 { WM_IME_SETCONTEXT, sent|optional }, /* in the MDI client */
323 { WM_SETFOCUS, sent, 0 }, /* in the MDI client */
324 { HCBT_SETFOCUS, hook },
325 { WM_KILLFOCUS, sent }, /* in the MDI client */
326 { WM_IME_SETCONTEXT, sent|optional }, /* in the MDI client */
327 { WM_IME_SETCONTEXT, sent|defwinproc|optional }, /* in the 1st MDI child */
328 { WM_SETFOCUS, sent|defwinproc }, /* in the 2nd MDI child */
329 { WM_MDIACTIVATE, sent|defwinproc }, /* in the 2nd MDI child */
330 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE}, /* in the 2nd MDI child */
335 /* SetWindowPos(SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|
336 SWP_NOZORDER|SWP_FRAMECHANGED)
337 * for a visible overlapped window with WS_CLIPCHILDREN style set.
339 static const struct message WmSWP_FrameChanged_clip[] = {
340 { WM_WINDOWPOSCHANGING, sent|wparam|parent, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED },
341 { WM_NCCALCSIZE, sent|wparam|parent, 1 },
342 { WM_NCPAINT, sent|parent }, /* wparam != 1 */
343 { WM_GETTEXT, sent|parent|defwinproc|optional },
344 { WM_ERASEBKGND, sent|parent|optional }, /* FIXME: remove optional once Wine is fixed */
345 { WM_NCPAINT, sent }, /* wparam != 1 */
346 { WM_ERASEBKGND, sent },
347 { WM_WINDOWPOSCHANGED, sent|wparam|parent, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
348 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
352 /* SetWindowPos(SWP_NOSIZE|SWP_NOMOVE|SWP_DEFERERASE|SWP_NOACTIVATE|
353 SWP_NOZORDER|SWP_FRAMECHANGED)
354 * for a visible overlapped window.
356 static const struct message WmSWP_FrameChangedDeferErase[] = {
357 { WM_WINDOWPOSCHANGING, sent|wparam|parent, SWP_NOSIZE|SWP_NOMOVE|SWP_DEFERERASE|SWP_NOACTIVATE|SWP_FRAMECHANGED },
358 { WM_NCCALCSIZE, sent|wparam|parent, 1 },
359 { WM_WINDOWPOSCHANGED, sent|wparam|parent, SWP_NOSIZE|SWP_NOMOVE|SWP_DEFERERASE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
360 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
361 { WM_PAINT, sent|parent },
362 { WM_NCPAINT, sent|beginpaint|parent }, /* wparam != 1 */
363 { WM_GETTEXT, sent|beginpaint|parent|defwinproc|optional },
365 { WM_NCPAINT, sent|beginpaint }, /* wparam != 1 */
366 { WM_ERASEBKGND, sent|beginpaint },
370 /* SetWindowPos(SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|
371 SWP_NOZORDER|SWP_FRAMECHANGED)
372 * for a visible overlapped window without WS_CLIPCHILDREN style set.
374 static const struct message WmSWP_FrameChanged_noclip[] = {
375 { WM_WINDOWPOSCHANGING, sent|wparam|parent, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED },
376 { WM_NCCALCSIZE, sent|wparam|parent, 1 },
377 { WM_NCPAINT, sent|parent }, /* wparam != 1 */
378 { WM_GETTEXT, sent|parent|defwinproc|optional },
379 { WM_ERASEBKGND, sent|parent|optional }, /* FIXME: remove optional once Wine is fixed */
380 { WM_WINDOWPOSCHANGED, sent|wparam|parent, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
381 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
383 { WM_NCPAINT, sent|beginpaint }, /* wparam != 1 */
384 { WM_ERASEBKGND, sent|beginpaint },
388 /* ShowWindow(SW_SHOW) for a not visible overlapped window */
389 static const struct message WmShowOverlappedSeq[] = {
390 { WM_SHOWWINDOW, sent|wparam, 1 },
391 { WM_NCPAINT, sent|wparam|optional, 1 },
392 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
393 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
394 { WM_NCPAINT, sent|wparam|optional, 1 },
395 { WM_GETTEXT, sent|defwinproc|optional },
396 { WM_ERASEBKGND, sent|optional },
397 { HCBT_ACTIVATE, hook },
398 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
399 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
400 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE },
401 { WM_NCPAINT, sent|wparam|optional, 1 },
402 { WM_ACTIVATEAPP, sent|wparam, 1 },
403 { WM_NCACTIVATE, sent|wparam, 1 },
404 { WM_GETTEXT, sent|defwinproc|optional },
405 { WM_ACTIVATE, sent|wparam, 1 },
406 { HCBT_SETFOCUS, hook },
407 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
408 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
409 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
410 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
411 { WM_NCPAINT, sent|wparam|optional, 1 },
412 { WM_GETTEXT, sent|defwinproc|optional },
413 { WM_ERASEBKGND, sent|optional },
414 /* Win9x adds SWP_NOZORDER below */
415 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
416 { WM_NCCALCSIZE, sent|optional },
417 { WM_NCPAINT, sent|optional },
418 { WM_ERASEBKGND, sent|optional },
419 #if 0 /* CreateWindow/ShowWindow(SW_SHOW) also generates WM_SIZE/WM_MOVE
420 * messages. Does that mean that CreateWindow doesn't set initial
421 * window dimensions for overlapped windows?
428 /* ShowWindow(SW_SHOWMAXIMIZED) for a not visible overlapped window */
429 static const struct message WmShowMaxOverlappedSeq[] = {
430 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
431 { WM_GETMINMAXINFO, sent },
432 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_STATECHANGED },
433 { WM_GETMINMAXINFO, sent|defwinproc },
434 { WM_NCCALCSIZE, sent|wparam, TRUE },
435 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
436 { HCBT_ACTIVATE, hook },
437 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
438 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
439 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE },
440 { WM_ACTIVATEAPP, sent|wparam, 1 },
441 { WM_NCACTIVATE, sent|wparam, 1 },
442 { WM_GETTEXT, sent|defwinproc|optional },
443 { WM_ACTIVATE, sent|wparam, 1 },
444 { HCBT_SETFOCUS, hook },
445 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
446 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
447 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
448 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
449 { WM_NCPAINT, sent|wparam|optional, 1 },
450 { WM_GETTEXT, sent|defwinproc|optional },
451 { WM_ERASEBKGND, sent|optional },
452 /* Win9x adds SWP_NOZORDER below */
453 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_STATECHANGED },
454 { WM_MOVE, sent|defwinproc },
455 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
456 { WM_NCCALCSIZE, sent|optional },
457 { WM_NCPAINT, sent|optional },
458 { WM_ERASEBKGND, sent|optional },
459 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
460 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
463 /* ShowWindow(SW_SHOWMINIMIZED) for a not visible overlapped window */
464 static const struct message WmShowMinOverlappedSeq[] = {
465 { HCBT_MINMAX, hook|lparam, 0, SW_MINIMIZE },
466 { HCBT_SETFOCUS, hook },
467 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
468 { WM_KILLFOCUS, sent },
469 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
470 { WM_IME_NOTIFY, sent|wparam|optional|defwinproc, 1 },
471 { WM_GETTEXT, sent|optional },
472 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOCOPYBITS|SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_STATECHANGED },
473 { WM_GETMINMAXINFO, sent|defwinproc },
474 { WM_NCCALCSIZE, sent|wparam, TRUE },
475 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
476 { WM_NCPAINT, sent },
477 { WM_GETTEXT, sent|defwinproc|optional },
478 { WM_WINDOWPOSCHANGED, sent },
479 { WM_MOVE, sent|defwinproc },
480 { WM_SIZE, sent|defwinproc|wparam, SIZE_MINIMIZED },
481 { WM_NCCALCSIZE, sent|optional },
482 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
483 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
484 { EVENT_SYSTEM_MINIMIZESTART, winevent_hook|wparam|lparam, 0, 0 },
485 { WM_NCACTIVATE, sent|wparam, 0 },
486 { WM_GETTEXT, sent|defwinproc|optional },
487 { WM_ACTIVATE, sent },
488 { WM_ACTIVATEAPP, sent|wparam, 0 },
491 /* ShowWindow(SW_HIDE) for a visible overlapped window */
492 static const struct message WmHideOverlappedSeq[] = {
493 { WM_SHOWWINDOW, sent|wparam, 0 },
494 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE },
495 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
496 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
497 { WM_SIZE, sent|optional }, /* XP doesn't send it */
498 { WM_MOVE, sent|optional }, /* XP doesn't send it */
499 { WM_NCACTIVATE, sent|wparam, 0 },
500 { WM_ACTIVATE, sent|wparam, 0 },
501 { WM_ACTIVATEAPP, sent|wparam, 0 },
502 { WM_KILLFOCUS, sent|wparam, 0 },
503 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
504 { WM_IME_NOTIFY, sent|wparam|optional|defwinproc, 1 },
507 /* DestroyWindow for a visible overlapped window */
508 static const struct message WmDestroyOverlappedSeq[] = {
509 { HCBT_DESTROYWND, hook },
510 { 0x0090, sent|optional },
511 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
512 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
513 { 0x0090, sent|optional },
514 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
515 { WM_NCACTIVATE, sent|wparam, 0 },
516 { WM_ACTIVATE, sent|wparam, 0 },
517 { WM_ACTIVATEAPP, sent|wparam, 0 },
518 { WM_KILLFOCUS, sent|wparam, 0 },
519 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
520 { WM_IME_NOTIFY, sent|wparam|optional|defwinproc, 1 },
521 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
522 { WM_DESTROY, sent },
523 { WM_NCDESTROY, sent },
526 /* CreateWindow(WS_MAXIMIZE|WS_VISIBLE) for popup window */
527 static const struct message WmCreateMaxPopupSeq[] = {
528 { HCBT_CREATEWND, hook },
529 { WM_NCCREATE, sent },
530 { WM_NCCALCSIZE, sent|wparam, 0 },
532 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
533 { WM_SIZE, sent|wparam, SIZE_RESTORED },
535 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
536 { WM_GETMINMAXINFO, sent },
537 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_STATECHANGED },
538 { WM_NCCALCSIZE, sent|wparam, TRUE },
539 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOREDRAW|SWP_STATECHANGED },
540 { WM_MOVE, sent|defwinproc },
541 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
542 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
543 { WM_SHOWWINDOW, sent|wparam, 1 },
544 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
545 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
546 { HCBT_ACTIVATE, hook },
547 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
548 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
549 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE },
550 { WM_ACTIVATEAPP, sent|wparam, 1 },
551 { WM_NCACTIVATE, sent|wparam, 1 },
552 { WM_ACTIVATE, sent|wparam, 1 },
553 { HCBT_SETFOCUS, hook },
554 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
555 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
556 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
557 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
558 { WM_SYNCPAINT, sent|wparam|optional, 4 },
559 { WM_NCPAINT, sent|wparam|optional, 1 },
560 { WM_ERASEBKGND, sent|optional },
561 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOCLIENTMOVE|SWP_NOCLIENTSIZE|SWP_SHOWWINDOW|SWP_NOMOVE|SWP_NOSIZE },
564 /* CreateWindow(WS_MAXIMIZE) for popup window, not initially visible */
565 static const struct message WmCreateInvisibleMaxPopupSeq[] = {
566 { HCBT_CREATEWND, hook },
567 { WM_NCCREATE, sent },
568 { WM_NCCALCSIZE, sent|wparam, 0 },
570 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
571 { WM_SIZE, sent|wparam, SIZE_RESTORED },
573 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
574 { WM_GETMINMAXINFO, sent },
575 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_STATECHANGED },
576 { WM_NCCALCSIZE, sent|wparam, TRUE },
577 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOREDRAW|SWP_STATECHANGED },
578 { WM_MOVE, sent|defwinproc },
579 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
580 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
583 /* ShowWindow(SW_SHOWMAXIMIZED) for a resized not visible popup window */
584 static const struct message WmShowMaxPopupResizedSeq[] = {
585 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
586 { WM_GETMINMAXINFO, sent },
587 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED },
588 { WM_NCCALCSIZE, sent|wparam, TRUE },
589 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
590 { HCBT_ACTIVATE, hook },
591 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
592 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
593 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE },
594 { WM_ACTIVATEAPP, sent|wparam, 1 },
595 { WM_NCACTIVATE, sent|wparam, 1 },
596 { WM_ACTIVATE, sent|wparam, 1 },
597 { HCBT_SETFOCUS, hook },
598 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
599 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
600 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
601 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
602 { WM_NCPAINT, sent|wparam|optional, 1 },
603 { WM_ERASEBKGND, sent|optional },
604 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOCLIENTMOVE|SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOMOVE },
605 /* WinNT4.0 sends WM_MOVE */
606 { WM_MOVE, sent|defwinproc|optional },
607 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
608 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
611 /* ShowWindow(SW_SHOWMAXIMIZED) for a not visible popup window */
612 static const struct message WmShowMaxPopupSeq[] = {
613 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
614 { WM_GETMINMAXINFO, sent },
615 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED },
616 { WM_NCCALCSIZE, sent|wparam, TRUE },
617 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
618 { HCBT_ACTIVATE, hook },
619 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
620 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
621 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE },
622 { WM_ACTIVATEAPP, sent|wparam, 1 },
623 { WM_NCACTIVATE, sent|wparam, 1 },
624 { WM_ACTIVATE, sent|wparam, 1 },
625 { HCBT_SETFOCUS, hook },
626 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
627 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
628 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
629 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
630 { WM_SYNCPAINT, sent|wparam|optional, 4 },
631 { WM_NCPAINT, sent|wparam|optional, 1 },
632 { WM_ERASEBKGND, sent|optional },
633 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOMOVE|SWP_NOSIZE },
634 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
637 /* CreateWindow(WS_VISIBLE) for popup window */
638 static const struct message WmCreatePopupSeq[] = {
639 { HCBT_CREATEWND, hook },
640 { WM_NCCREATE, sent },
641 { WM_NCCALCSIZE, sent|wparam, 0 },
643 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
644 { WM_SIZE, sent|wparam, SIZE_RESTORED },
646 { WM_SHOWWINDOW, sent|wparam, 1 },
647 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
648 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
649 { HCBT_ACTIVATE, hook },
650 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
651 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
652 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE },
653 { WM_NCPAINT, sent|wparam|optional, 1 },
654 { WM_ERASEBKGND, sent|optional },
655 { WM_ACTIVATEAPP, sent|wparam, 1 },
656 { WM_NCACTIVATE, sent|wparam, 1 },
657 { WM_ACTIVATE, sent|wparam, 1 },
658 { HCBT_SETFOCUS, hook },
659 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
660 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
661 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
662 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
663 { WM_SYNCPAINT, sent|wparam|optional, 4 },
664 { WM_NCPAINT, sent|wparam|optional, 1 },
665 { WM_ERASEBKGND, sent|optional },
666 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOCLIENTMOVE|SWP_NOCLIENTSIZE|SWP_SHOWWINDOW|SWP_NOMOVE|SWP_NOSIZE },
669 /* ShowWindow(SW_SHOWMAXIMIZED) for a visible popup window */
670 static const struct message WmShowVisMaxPopupSeq[] = {
671 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
672 { WM_GETMINMAXINFO, sent },
673 { WM_GETTEXT, sent|optional },
674 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_STATECHANGED },
675 { WM_NCCALCSIZE, sent|wparam, TRUE },
676 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
677 { WM_NCPAINT, sent|wparam|optional, 1 },
678 { WM_ERASEBKGND, sent|optional },
679 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_STATECHANGED },
680 { WM_MOVE, sent|defwinproc },
681 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
682 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
685 /* CreateWindow (for a child popup window, not initially visible) */
686 static const struct message WmCreateChildPopupSeq[] = {
687 { HCBT_CREATEWND, hook },
688 { WM_NCCREATE, sent },
689 { WM_NCCALCSIZE, sent|wparam, 0 },
691 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
692 { WM_SIZE, sent|wparam, SIZE_RESTORED },
696 /* CreateWindow (for a popup window, not initially visible,
697 * which sets WS_VISIBLE in WM_CREATE handler)
699 static const struct message WmCreateInvisiblePopupSeq[] = {
700 { HCBT_CREATEWND, hook },
701 { WM_NCCREATE, sent },
702 { WM_NCCALCSIZE, sent|wparam, 0 },
704 { WM_STYLECHANGING, sent },
705 { WM_STYLECHANGED, sent },
706 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
707 { WM_SIZE, sent|wparam, SIZE_RESTORED },
711 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER)
712 * for a popup window with WS_VISIBLE style set
714 static const struct message WmShowVisiblePopupSeq_2[] = {
715 { WM_WINDOWPOSCHANGING, sent|wparam, 0 },
718 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
719 * for a popup window with WS_VISIBLE style set
721 static const struct message WmShowVisiblePopupSeq_3[] = {
722 { WM_WINDOWPOSCHANGING, sent|wparam, 0 },
723 { HCBT_ACTIVATE, hook },
724 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
725 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
726 { WM_WINDOWPOSCHANGING, sent|wparam, 0 },
727 { WM_NCACTIVATE, sent|wparam, 1 },
728 { WM_ACTIVATE, sent|wparam, 1 },
729 { HCBT_SETFOCUS, hook },
730 { WM_KILLFOCUS, sent|parent },
731 { WM_IME_SETCONTEXT, sent|parent|wparam|optional, 0 },
732 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
733 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
734 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
735 { WM_SETFOCUS, sent|defwinproc },
738 /* CreateWindow (for child window, not initially visible) */
739 static const struct message WmCreateChildSeq[] = {
740 { HCBT_CREATEWND, hook },
741 { WM_NCCREATE, sent },
742 /* child is inserted into parent's child list after WM_NCCREATE returns */
743 { WM_NCCALCSIZE, sent|wparam, 0 },
745 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
746 { WM_SIZE, sent|wparam, SIZE_RESTORED },
748 { WM_PARENTNOTIFY, sent|parent|wparam, WM_CREATE },
751 /* CreateWindow (for maximized child window, not initially visible) */
752 static const struct message WmCreateMaximizedChildSeq[] = {
753 { HCBT_CREATEWND, hook },
754 { WM_NCCREATE, sent },
755 { WM_NCCALCSIZE, sent|wparam, 0 },
757 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
758 { WM_SIZE, sent|wparam, SIZE_RESTORED },
760 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
761 { WM_GETMINMAXINFO, sent },
762 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_STATECHANGED },
763 { WM_NCCALCSIZE, sent|wparam, 1 },
764 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTMOVE|SWP_STATECHANGED },
765 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
766 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
767 { WM_PARENTNOTIFY, sent|parent|wparam, WM_CREATE },
770 /* CreateWindow (for a child window, initially visible) */
771 static const struct message WmCreateVisibleChildSeq[] = {
772 { HCBT_CREATEWND, hook },
773 { WM_NCCREATE, sent },
774 /* child is inserted into parent's child list after WM_NCCREATE returns */
775 { WM_NCCALCSIZE, sent|wparam, 0 },
776 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
778 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
779 { WM_SIZE, sent|wparam, SIZE_RESTORED },
781 { WM_PARENTNOTIFY, sent|parent|wparam, WM_CREATE },
782 { WM_SHOWWINDOW, sent|wparam, 1 },
783 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
784 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
785 { WM_ERASEBKGND, sent|parent|optional },
786 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
787 { WM_NCCALCSIZE, sent|wparam|optional, 1 }, /* WinXP */
788 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
791 /* ShowWindow(SW_SHOW) for a not visible child window */
792 static const struct message WmShowChildSeq[] = {
793 { WM_SHOWWINDOW, sent|wparam, 1 },
794 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
795 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
796 { WM_ERASEBKGND, sent|parent|optional },
797 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
800 /* ShowWindow(SW_HIDE) for a visible child window */
801 static const struct message WmHideChildSeq[] = {
802 { WM_SHOWWINDOW, sent|wparam, 0 },
803 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
804 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
805 { WM_ERASEBKGND, sent|parent|optional },
806 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
809 /* ShowWindow(SW_HIDE) for a visible child window checking all parent events*/
810 static const struct message WmHideChildSeq2[] = {
811 { WM_SHOWWINDOW, sent|wparam, 0 },
812 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
813 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
814 { WM_ERASEBKGND, sent|parent },
815 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
818 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
819 * for a not visible child window
821 static const struct message WmShowChildSeq_2[] = {
822 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
823 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
824 { WM_CHILDACTIVATE, sent },
825 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
828 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE)
829 * for a not visible child window
831 static const struct message WmShowChildSeq_3[] = {
832 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
833 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
834 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
837 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
838 * for a visible child window with a caption
840 static const struct message WmShowChildSeq_4[] = {
841 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
842 { WM_CHILDACTIVATE, sent },
845 /* ShowWindow(SW_MINIMIZE) for child with invisible parent */
846 static const struct message WmShowChildInvisibleParentSeq_1[] = {
847 { HCBT_MINMAX, hook|lparam, 0, SW_MINIMIZE },
848 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOCOPYBITS|SWP_STATECHANGED },
849 { WM_NCCALCSIZE, sent|wparam, 1 },
850 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
851 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOREDRAW|SWP_NOCOPYBITS|SWP_STATECHANGED },
852 { WM_MOVE, sent|defwinproc },
853 { WM_SIZE, sent|defwinproc|wparam, SIZE_MINIMIZED },
854 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
855 { EVENT_SYSTEM_MINIMIZESTART, winevent_hook|wparam|lparam, 0, 0 },
856 /* FIXME: Wine creates an icon/title window while Windows doesn't */
857 { WM_PARENTNOTIFY, sent|parent|wparam|optional, WM_CREATE },
858 { WM_GETTEXT, sent|optional },
861 /* repeated ShowWindow(SW_MINIMIZE) for child with invisible parent */
862 static const struct message WmShowChildInvisibleParentSeq_1r[] = {
863 { HCBT_MINMAX, hook|lparam, 0, SW_MINIMIZE },
866 /* ShowWindow(SW_MAXIMIZE) for child with invisible parent */
867 static const struct message WmShowChildInvisibleParentSeq_2[] = {
868 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
869 { WM_GETMINMAXINFO, sent },
870 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_STATECHANGED },
871 { WM_NCCALCSIZE, sent|wparam, 1 },
872 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
873 { WM_CHILDACTIVATE, sent },
874 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTMOVE|SWP_STATECHANGED },
875 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
876 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
879 /* repeated ShowWindow(SW_MAXIMIZE) for child with invisible parent */
880 static const struct message WmShowChildInvisibleParentSeq_2r[] = {
881 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
884 /* ShowWindow(SW_SHOWMINIMIZED) for child with invisible parent */
885 static const struct message WmShowChildInvisibleParentSeq_3[] = {
886 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMINIMIZED },
887 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
888 { WM_NCCALCSIZE, sent|wparam, 1 },
889 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
890 { WM_CHILDACTIVATE, sent },
891 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOREDRAW|SWP_NOCOPYBITS|SWP_STATECHANGED },
892 { WM_MOVE, sent|defwinproc },
893 { WM_SIZE, sent|defwinproc|wparam, SIZE_MINIMIZED },
894 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
895 { EVENT_SYSTEM_MINIMIZESTART, winevent_hook|wparam|lparam, 0, 0 },
896 /* FIXME: Wine creates an icon/title window while Windows doesn't */
897 { WM_PARENTNOTIFY, sent|parent|wparam|optional, WM_CREATE },
898 { WM_GETTEXT, sent|optional },
901 /* repeated ShowWindow(SW_SHOWMINIMIZED) for child with invisible parent */
902 static const struct message WmShowChildInvisibleParentSeq_3r[] = {
903 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMINIMIZED },
906 /* ShowWindow(SW_SHOWMINNOACTIVE) for child with invisible parent */
907 static const struct message WmShowChildInvisibleParentSeq_4[] = {
908 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMINNOACTIVE },
909 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOCOPYBITS|SWP_STATECHANGED },
910 { WM_NCCALCSIZE, sent|wparam, 1 },
911 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
912 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOREDRAW|SWP_NOCOPYBITS|SWP_STATECHANGED },
913 { WM_MOVE, sent|defwinproc },
914 { WM_SIZE, sent|defwinproc|wparam, SIZE_MINIMIZED },
915 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
916 { EVENT_SYSTEM_MINIMIZESTART, winevent_hook|wparam|lparam, 0, 0 },
917 /* FIXME: Wine creates an icon/title window while Windows doesn't */
918 { WM_PARENTNOTIFY, sent|parent|wparam|optional, WM_CREATE },
919 { WM_GETTEXT, sent|optional },
922 /* repeated ShowWindow(SW_SHOWMINNOACTIVE) for child with invisible parent */
923 static const struct message WmShowChildInvisibleParentSeq_4r[] = {
924 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMINNOACTIVE },
927 /* ShowWindow(SW_SHOW) for child with invisible parent */
928 static const struct message WmShowChildInvisibleParentSeq_5[] = {
929 { WM_SHOWWINDOW, sent|wparam, 1 },
932 /* ShowWindow(SW_HIDE) for child with invisible parent */
933 static const struct message WmHideChildInvisibleParentSeq[] = {
934 { WM_SHOWWINDOW, sent|wparam, 0 },
937 /* SetWindowPos(SWP_SHOWWINDOW) for child with invisible parent */
938 static const struct message WmShowChildInvisibleParentSeq_6[] = {
939 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
940 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
941 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
944 /* SetWindowPos(SWP_HIDEWINDOW) for child with invisible parent */
945 static const struct message WmHideChildInvisibleParentSeq_2[] = {
946 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
947 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
948 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
951 /* DestroyWindow for a visible child window */
952 static const struct message WmDestroyChildSeq[] = {
953 { HCBT_DESTROYWND, hook },
954 { 0x0090, sent|optional },
955 { WM_PARENTNOTIFY, sent|parent|wparam, WM_DESTROY },
956 { WM_SHOWWINDOW, sent|wparam, 0 },
957 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
958 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
959 { WM_ERASEBKGND, sent|parent|optional },
960 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
961 { HCBT_SETFOCUS, hook }, /* set focus to a parent */
962 { WM_KILLFOCUS, sent },
963 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
964 { WM_IME_SETCONTEXT, sent|wparam|parent|optional, 1 },
965 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
966 { WM_SETFOCUS, sent|parent },
967 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
968 { WM_DESTROY, sent },
969 { WM_DESTROY, sent|optional }, /* some other (IME?) window */
970 { WM_NCDESTROY, sent|optional }, /* some other (IME?) window */
971 { WM_NCDESTROY, sent },
974 /* DestroyWindow for a visible child window with invisible parent */
975 static const struct message WmDestroyInvisibleChildSeq[] = {
976 { HCBT_DESTROYWND, hook },
977 { 0x0090, sent|optional },
978 { WM_PARENTNOTIFY, sent|parent|wparam, WM_DESTROY },
979 { WM_SHOWWINDOW, sent|wparam, 0 },
980 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
981 { WM_DESTROY, sent },
982 { WM_NCDESTROY, sent },
985 /* Moving the mouse in nonclient area */
986 static const struct message WmMouseMoveInNonClientAreaSeq[] = { /* FIXME: add */
987 { WM_NCHITTEST, sent },
988 { WM_SETCURSOR, sent },
989 { WM_NCMOUSEMOVE, posted },
992 /* Moving the mouse in client area */
993 static const struct message WmMouseMoveInClientAreaSeq[] = { /* FIXME: add */
994 { WM_NCHITTEST, sent },
995 { WM_SETCURSOR, sent },
996 { WM_MOUSEMOVE, posted },
999 /* Moving by dragging the title bar (after WM_NCHITTEST and WM_SETCURSOR) (outline move) */
1000 static const struct message WmDragTitleBarSeq[] = { /* FIXME: add */
1001 { WM_NCLBUTTONDOWN, sent|wparam, HTCAPTION },
1002 { WM_SYSCOMMAND, sent|defwinproc|wparam, SC_MOVE+2 },
1003 { WM_GETMINMAXINFO, sent|defwinproc },
1004 { WM_ENTERSIZEMOVE, sent|defwinproc },
1005 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, 0 },
1006 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, 0 },
1007 { WM_MOVE, sent|defwinproc },
1008 { WM_EXITSIZEMOVE, sent|defwinproc },
1011 /* Sizing by dragging the thick borders (after WM_NCHITTEST and WM_SETCURSOR) (outline move) */
1012 static const struct message WmDragThickBordersBarSeq[] = { /* FIXME: add */
1013 { WM_NCLBUTTONDOWN, sent|wparam, 0xd },
1014 { WM_SYSCOMMAND, sent|defwinproc|wparam, 0xf004 },
1015 { WM_GETMINMAXINFO, sent|defwinproc },
1016 { WM_ENTERSIZEMOVE, sent|defwinproc },
1017 { WM_SIZING, sent|defwinproc|wparam, 4}, /* one for each mouse movement */
1018 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, 0 },
1019 { WM_GETMINMAXINFO, sent|defwinproc },
1020 { WM_NCCALCSIZE, sent|defwinproc|wparam, 1 },
1021 { WM_NCPAINT, sent|defwinproc|wparam, 1 },
1022 { WM_GETTEXT, sent|defwinproc },
1023 { WM_ERASEBKGND, sent|defwinproc },
1024 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, 0 },
1025 { WM_MOVE, sent|defwinproc },
1026 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
1027 { WM_EXITSIZEMOVE, sent|defwinproc },
1030 /* Resizing child window with MoveWindow (32) */
1031 static const struct message WmResizingChildWithMoveWindowSeq[] = {
1032 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE },
1033 { WM_NCCALCSIZE, sent|wparam, 1 },
1034 { WM_ERASEBKGND, sent|parent|optional },
1035 { WM_ERASEBKGND, sent|optional },
1036 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE },
1037 { WM_MOVE, sent|defwinproc },
1038 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
1039 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1042 /* Clicking on inactive button */
1043 static const struct message WmClickInactiveButtonSeq[] = { /* FIXME: add */
1044 { WM_NCHITTEST, sent },
1045 { WM_PARENTNOTIFY, sent|parent|wparam, WM_LBUTTONDOWN },
1046 { WM_MOUSEACTIVATE, sent },
1047 { WM_MOUSEACTIVATE, sent|parent|defwinproc },
1048 { WM_SETCURSOR, sent },
1049 { WM_SETCURSOR, sent|parent|defwinproc },
1050 { WM_LBUTTONDOWN, posted },
1051 { WM_KILLFOCUS, posted|parent },
1052 { WM_SETFOCUS, posted },
1053 { WM_CTLCOLORBTN, posted|parent },
1054 { BM_SETSTATE, posted },
1055 { WM_CTLCOLORBTN, posted|parent },
1056 { WM_LBUTTONUP, posted },
1057 { BM_SETSTATE, posted },
1058 { WM_CTLCOLORBTN, posted|parent },
1059 { WM_COMMAND, posted|parent },
1062 /* Reparenting a button (16/32) */
1063 /* The last child (button) reparented gets topmost for its new parent. */
1064 static const struct message WmReparentButtonSeq[] = { /* FIXME: add */
1065 { WM_SHOWWINDOW, sent|wparam, 0 },
1066 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE },
1067 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
1068 { WM_ERASEBKGND, sent|parent },
1069 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE },
1070 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE },
1071 { WM_CHILDACTIVATE, sent },
1072 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOSIZE|SWP_NOREDRAW },
1073 { WM_MOVE, sent|defwinproc },
1074 { WM_SHOWWINDOW, sent|wparam, 1 },
1077 /* Creation of a custom dialog (32) */
1078 static const struct message WmCreateCustomDialogSeq[] = {
1079 { HCBT_CREATEWND, hook },
1080 { WM_GETMINMAXINFO, sent },
1081 { WM_NCCREATE, sent },
1082 { WM_NCCALCSIZE, sent|wparam, 0 },
1083 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
1084 { WM_CREATE, sent },
1085 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1086 { WM_SHOWWINDOW, sent|wparam, 1 },
1087 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
1088 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1089 { HCBT_ACTIVATE, hook },
1090 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
1093 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
1095 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE },
1097 { WM_NCACTIVATE, sent|wparam, 1 },
1098 { WM_GETTEXT, sent|optional|defwinproc },
1099 { WM_GETTEXT, sent|optional|defwinproc },
1100 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
1101 { WM_ACTIVATE, sent|wparam, 1 },
1102 { WM_KILLFOCUS, sent|parent },
1103 { WM_IME_SETCONTEXT, sent|parent|wparam|optional, 0 },
1104 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
1105 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
1106 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1107 { WM_SETFOCUS, sent },
1108 { WM_GETDLGCODE, sent|defwinproc|wparam, 0 },
1109 { WM_NCPAINT, sent|wparam, 1 },
1110 { WM_GETTEXT, sent|optional|defwinproc },
1111 { WM_GETTEXT, sent|optional|defwinproc },
1112 { WM_ERASEBKGND, sent },
1113 { WM_CTLCOLORDLG, sent|defwinproc },
1114 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1115 { WM_GETTEXT, sent|optional },
1116 { WM_GETTEXT, sent|optional },
1117 { WM_NCCALCSIZE, sent|optional },
1118 { WM_NCPAINT, sent|optional },
1119 { WM_GETTEXT, sent|optional|defwinproc },
1120 { WM_GETTEXT, sent|optional|defwinproc },
1121 { WM_ERASEBKGND, sent|optional },
1122 { WM_CTLCOLORDLG, sent|optional|defwinproc },
1123 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1124 { WM_SIZE, sent|wparam, SIZE_RESTORED },
1128 /* Calling EndDialog for a custom dialog (32) */
1129 static const struct message WmEndCustomDialogSeq[] = {
1130 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1131 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
1132 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1133 { WM_GETTEXT, sent|optional },
1134 { HCBT_ACTIVATE, hook },
1135 { WM_NCACTIVATE, sent|wparam, 0 },
1136 { WM_GETTEXT, sent|optional|defwinproc },
1137 { WM_GETTEXT, sent|optional|defwinproc },
1138 { WM_ACTIVATE, sent|wparam, 0 },
1139 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
1140 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1141 { HCBT_SETFOCUS, hook },
1142 { WM_KILLFOCUS, sent },
1143 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
1144 { WM_IME_SETCONTEXT, sent|parent|wparam|defwinproc|optional, 1 },
1145 { WM_IME_NOTIFY, sent|wparam|optional, 1 },
1146 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1147 { WM_SETFOCUS, sent|parent|defwinproc },
1150 /* ShowWindow(SW_SHOW) for a custom dialog (initially invisible) */
1151 static const struct message WmShowCustomDialogSeq[] = {
1152 { WM_SHOWWINDOW, sent|wparam, 1 },
1153 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
1154 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1155 { HCBT_ACTIVATE, hook },
1156 { 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 },
1161 { WM_ACTIVATEAPP, sent|wparam|optional, 1 },
1162 { WM_NCACTIVATE, sent|wparam, 1 },
1163 { WM_ACTIVATE, sent|wparam, 1 },
1165 { WM_KILLFOCUS, sent|parent },
1166 { WM_IME_SETCONTEXT, sent|parent|wparam|optional, 0 },
1167 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
1168 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
1169 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1170 { WM_SETFOCUS, sent },
1171 { WM_GETDLGCODE, sent|defwinproc|wparam, 0 },
1172 { WM_NCPAINT, sent|wparam, 1 },
1173 { WM_ERASEBKGND, sent },
1174 { WM_CTLCOLORDLG, sent|defwinproc },
1175 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1178 /* Creation and destruction of a modal dialog (32) */
1179 static const struct message WmModalDialogSeq[] = {
1180 { WM_CANCELMODE, sent|parent },
1181 { HCBT_SETFOCUS, hook },
1182 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1183 { WM_KILLFOCUS, sent|parent },
1184 { WM_IME_SETCONTEXT, sent|parent|wparam|optional, 0 },
1185 { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, 0, 0 },
1186 { WM_ENABLE, sent|parent|wparam, 0 },
1187 { HCBT_CREATEWND, hook },
1188 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
1189 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1190 { WM_SETFONT, sent },
1191 { WM_INITDIALOG, sent },
1192 { WM_CHANGEUISTATE, sent|optional },
1193 { WM_UPDATEUISTATE, sent|optional },
1194 { WM_SHOWWINDOW, sent },
1195 { HCBT_ACTIVATE, hook },
1196 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
1197 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
1198 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE },
1199 { WM_NCACTIVATE, sent|wparam, 1 },
1200 { WM_GETTEXT, sent|optional },
1201 { WM_ACTIVATE, sent|wparam, 1 },
1202 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
1203 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1204 { WM_NCPAINT, sent },
1205 { WM_GETTEXT, sent|optional },
1206 { WM_ERASEBKGND, sent },
1207 { WM_CTLCOLORDLG, sent },
1208 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1209 { WM_GETTEXT, sent|optional },
1210 { WM_NCCALCSIZE, sent|optional },
1211 { WM_NCPAINT, sent|optional },
1212 { WM_GETTEXT, sent|optional },
1213 { WM_ERASEBKGND, sent|optional },
1214 { WM_CTLCOLORDLG, sent|optional },
1215 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1216 { WM_PAINT, sent|optional },
1217 { WM_CTLCOLORBTN, sent },
1218 { WM_ENTERIDLE, sent|parent|optional },
1219 { WM_ENTERIDLE, sent|parent|optional },
1220 { WM_ENTERIDLE, sent|parent|optional },
1221 { WM_ENTERIDLE, sent|parent|optional },
1222 { WM_ENTERIDLE, sent|parent|optional },
1223 { WM_ENTERIDLE, sent|parent|optional },
1224 { WM_ENTERIDLE, sent|parent|optional },
1225 { WM_ENTERIDLE, sent|parent|optional },
1226 { WM_ENTERIDLE, sent|parent|optional },
1227 { WM_ENTERIDLE, sent|parent|optional },
1228 { WM_ENTERIDLE, sent|parent|optional },
1229 { WM_ENTERIDLE, sent|parent|optional },
1230 { WM_ENTERIDLE, sent|parent|optional },
1231 { WM_ENTERIDLE, sent|parent|optional },
1232 { WM_ENTERIDLE, sent|parent|optional },
1233 { WM_ENTERIDLE, sent|parent|optional },
1234 { WM_ENTERIDLE, sent|parent|optional },
1235 { WM_ENTERIDLE, sent|parent|optional },
1236 { WM_ENTERIDLE, sent|parent|optional },
1237 { WM_ENTERIDLE, sent|parent|optional },
1239 { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, 0, 0 },
1240 { WM_ENABLE, sent|parent|wparam, 1 },
1241 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
1242 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
1243 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1244 { WM_GETTEXT, sent|optional },
1245 { HCBT_ACTIVATE, hook },
1246 { WM_NCACTIVATE, sent|wparam, 0 },
1247 { WM_GETTEXT, sent|optional },
1248 { WM_ACTIVATE, sent|wparam, 0 },
1249 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
1250 { WM_WINDOWPOSCHANGING, sent|optional },
1251 { HCBT_SETFOCUS, hook },
1252 { WM_IME_SETCONTEXT, sent|parent|wparam|defwinproc|optional, 1 },
1253 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1254 { WM_SETFOCUS, sent|parent|defwinproc },
1255 { EVENT_SYSTEM_DIALOGEND, winevent_hook|wparam|lparam, 0, 0 },
1256 { HCBT_DESTROYWND, hook },
1257 { 0x0090, sent|optional },
1258 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
1259 { WM_DESTROY, sent },
1260 { WM_NCDESTROY, sent },
1263 /* Creation of a modal dialog that is resized inside WM_INITDIALOG (32) */
1264 static const struct message WmCreateModalDialogResizeSeq[] = { /* FIXME: add */
1265 /* (inside dialog proc, handling WM_INITDIALOG) */
1266 { WM_WINDOWPOSCHANGING, sent|wparam, 0 },
1267 { WM_NCCALCSIZE, sent },
1268 { WM_NCACTIVATE, sent|parent|wparam, 0 },
1269 { WM_GETTEXT, sent|defwinproc },
1270 { WM_ACTIVATE, sent|parent|wparam, 0 },
1271 { WM_WINDOWPOSCHANGING, sent|wparam, 0 },
1272 { WM_WINDOWPOSCHANGING, sent|parent },
1273 { WM_NCACTIVATE, sent|wparam, 1 },
1274 { WM_ACTIVATE, sent|wparam, 1 },
1275 { WM_WINDOWPOSCHANGED, sent|wparam, 0 },
1276 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
1277 /* (setting focus) */
1278 { WM_SHOWWINDOW, sent|wparam, 1 },
1279 { WM_WINDOWPOSCHANGING, sent|wparam, 0 },
1280 { WM_NCPAINT, sent },
1281 { WM_GETTEXT, sent|defwinproc },
1282 { WM_ERASEBKGND, sent },
1283 { WM_CTLCOLORDLG, sent|defwinproc },
1284 { WM_WINDOWPOSCHANGED, sent|wparam, 0 },
1286 /* (bunch of WM_CTLCOLOR* for each control) */
1287 { WM_PAINT, sent|parent },
1288 { WM_ENTERIDLE, sent|parent|wparam, 0 },
1289 { WM_SETCURSOR, sent|parent },
1292 /* SetMenu for NonVisible windows with size change*/
1293 static const struct message WmSetMenuNonVisibleSizeChangeSeq[] = {
1294 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1295 { WM_NCCALCSIZE, sent|wparam, 1 },
1296 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
1297 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW },
1298 { WM_MOVE, sent|defwinproc },
1299 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
1300 { WM_NCCALCSIZE,sent|wparam|optional, 1 }, /* XP */
1301 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1302 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* XP sends a duplicate */
1303 { WM_GETTEXT, sent|optional },
1304 { WM_NCCALCSIZE, sent|wparam|optional, 1 },
1307 /* SetMenu for NonVisible windows with no size change */
1308 static const struct message WmSetMenuNonVisibleNoSizeChangeSeq[] = {
1309 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1310 { WM_NCCALCSIZE, sent|wparam, 1 },
1311 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1312 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1315 /* SetMenu for Visible windows with size change */
1316 static const struct message WmSetMenuVisibleSizeChangeSeq[] = {
1317 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1318 { WM_NCCALCSIZE, sent|wparam, 1 },
1319 { 0x0093, sent|defwinproc|optional },
1320 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
1321 { WM_NCPAINT, sent }, /* wparam != 1 */
1322 { 0x0093, sent|defwinproc|optional },
1323 { 0x0093, sent|defwinproc|optional },
1324 { 0x0091, sent|defwinproc|optional },
1325 { 0x0092, sent|defwinproc|optional },
1326 { WM_GETTEXT, sent|defwinproc|optional },
1327 { WM_ERASEBKGND, sent|optional },
1328 { WM_ACTIVATE, sent|optional },
1329 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1330 { WM_MOVE, sent|defwinproc },
1331 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
1332 { 0x0093, sent|optional },
1333 { WM_NCCALCSIZE, sent|wparam|optional, 1 },
1334 { 0x0093, sent|defwinproc|optional },
1335 { WM_NCPAINT, sent|optional }, /* wparam != 1 */
1336 { 0x0093, sent|defwinproc|optional },
1337 { 0x0093, sent|defwinproc|optional },
1338 { 0x0091, sent|defwinproc|optional },
1339 { 0x0092, sent|defwinproc|optional },
1340 { WM_ERASEBKGND, sent|optional },
1341 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1342 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* XP sends a duplicate */
1345 /* SetMenu for Visible windows with no size change */
1346 static const struct message WmSetMenuVisibleNoSizeChangeSeq[] = {
1347 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1348 { WM_NCCALCSIZE, sent|wparam, 1 },
1349 { WM_NCPAINT, sent }, /* wparam != 1 */
1350 { WM_GETTEXT, sent|defwinproc|optional },
1351 { WM_ERASEBKGND, sent|optional },
1352 { WM_ACTIVATE, sent|optional },
1353 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1354 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1357 /* DrawMenuBar for a visible window */
1358 static const struct message WmDrawMenuBarSeq[] =
1360 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1361 { WM_NCCALCSIZE, sent|wparam, 1 },
1362 { 0x0093, sent|defwinproc|optional },
1363 { WM_NCPAINT, sent }, /* wparam != 1 */
1364 { 0x0093, sent|defwinproc|optional },
1365 { 0x0093, sent|defwinproc|optional },
1366 { 0x0091, sent|defwinproc|optional },
1367 { 0x0092, sent|defwinproc|optional },
1368 { WM_GETTEXT, sent|defwinproc|optional },
1369 { WM_ERASEBKGND, sent|optional },
1370 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1371 { 0x0093, sent|optional },
1372 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1376 static const struct message WmSetRedrawFalseSeq[] =
1378 { WM_SETREDRAW, sent|wparam, 0 },
1382 static const struct message WmSetRedrawTrueSeq[] =
1384 { WM_SETREDRAW, sent|wparam, 1 },
1388 static const struct message WmEnableWindowSeq_1[] =
1390 { WM_CANCELMODE, sent|wparam|lparam, 0, 0 },
1391 { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, 0, 0 },
1392 { WM_ENABLE, sent|wparam|lparam, FALSE, 0 },
1396 static const struct message WmEnableWindowSeq_2[] =
1398 { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, 0, 0 },
1399 { WM_ENABLE, sent|wparam|lparam, TRUE, 0 },
1403 static const struct message WmGetScrollRangeSeq[] =
1405 { SBM_GETRANGE, sent },
1408 static const struct message WmGetScrollInfoSeq[] =
1410 { SBM_GETSCROLLINFO, sent },
1413 static const struct message WmSetScrollRangeSeq[] =
1415 /* MSDN claims that Windows sends SBM_SETRANGE message, but win2k SP4
1416 sends SBM_SETSCROLLINFO.
1418 { SBM_SETSCROLLINFO, sent },
1421 /* SetScrollRange for a window without a non-client area */
1422 static const struct message WmSetScrollRangeHSeq_empty[] =
1424 { EVENT_OBJECT_VALUECHANGE, winevent_hook|wparam|lparam, OBJID_HSCROLL, 0 },
1427 static const struct message WmSetScrollRangeVSeq_empty[] =
1429 { EVENT_OBJECT_VALUECHANGE, winevent_hook|wparam|lparam, OBJID_VSCROLL, 0 },
1432 static const struct message WmSetScrollRangeHVSeq[] =
1434 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE },
1435 { WM_NCCALCSIZE, sent|wparam, 1 },
1436 { WM_GETTEXT, sent|defwinproc|optional },
1437 { WM_ERASEBKGND, sent|optional },
1438 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1439 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1440 { EVENT_OBJECT_VALUECHANGE, winevent_hook|lparam|optional, 0/*OBJID_HSCROLL or OBJID_VSCROLL*/, 0 },
1443 /* SetScrollRange for a window with a non-client area */
1444 static const struct message WmSetScrollRangeHV_NC_Seq[] =
1446 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE },
1447 { WM_NCCALCSIZE, sent|wparam, 1 },
1448 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
1449 { WM_NCPAINT, sent|optional },
1450 { WM_STYLECHANGING, sent|defwinproc|optional },
1451 { WM_STYLECHANGED, sent|defwinproc|optional },
1452 { WM_STYLECHANGING, sent|defwinproc|optional },
1453 { WM_STYLECHANGED, sent|defwinproc|optional },
1454 { WM_STYLECHANGING, sent|defwinproc|optional },
1455 { WM_STYLECHANGED, sent|defwinproc|optional },
1456 { WM_STYLECHANGING, sent|defwinproc|optional },
1457 { WM_STYLECHANGED, sent|defwinproc|optional },
1458 { WM_GETTEXT, sent|defwinproc|optional },
1459 { WM_GETTEXT, sent|defwinproc|optional },
1460 { WM_ERASEBKGND, sent|optional },
1461 { WM_CTLCOLORDLG, sent|defwinproc|optional }, /* sent to a parent of the dialog */
1462 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE|SWP_NOCLIENTMOVE },
1463 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
1464 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1465 { EVENT_OBJECT_VALUECHANGE, winevent_hook|lparam|optional, 0/*OBJID_HSCROLL or OBJID_VSCROLL*/, 0 },
1466 { WM_GETTEXT, sent|optional },
1467 { WM_GETTEXT, sent|optional },
1468 { WM_GETTEXT, sent|optional },
1469 { WM_GETTEXT, sent|optional },
1472 /* test if we receive the right sequence of messages */
1473 /* after calling ShowWindow( SW_SHOWNA) */
1474 static const struct message WmSHOWNAChildInvisParInvis[] = {
1475 { WM_SHOWWINDOW, sent|wparam, 1 },
1478 static const struct message WmSHOWNAChildVisParInvis[] = {
1479 { WM_SHOWWINDOW, sent|wparam, 1 },
1482 static const struct message WmSHOWNAChildVisParVis[] = {
1483 { WM_SHOWWINDOW, sent|wparam, 1 },
1484 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
1487 static const struct message WmSHOWNAChildInvisParVis[] = {
1488 { WM_SHOWWINDOW, sent|wparam, 1 },
1489 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1490 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1491 { WM_ERASEBKGND, sent|optional },
1492 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOACTIVATE|SWP_NOCLIENTMOVE },
1495 static const struct message WmSHOWNATopVisible[] = {
1496 { WM_SHOWWINDOW, sent|wparam, 1 },
1497 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
1500 static const struct message WmSHOWNATopInvisible[] = {
1501 { WM_SHOWWINDOW, sent|wparam, 1 },
1502 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1503 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1504 { WM_NCPAINT, sent|wparam, 1 },
1505 { WM_GETTEXT, sent|defwinproc|optional },
1506 { WM_ERASEBKGND, sent|optional },
1507 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1508 { WM_NCCALCSIZE, sent|wparam|optional, 1 },
1509 { WM_NCPAINT, sent|wparam|optional, 1 },
1510 { WM_ERASEBKGND, sent|optional },
1511 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1512 { WM_SIZE, sent|wparam, SIZE_RESTORED },
1517 static int after_end_dialog, test_def_id;
1518 static int sequence_cnt, sequence_size;
1519 static struct message* sequence;
1520 static int log_all_parent_messages;
1522 /* user32 functions */
1523 static HWND (WINAPI *pGetAncestor)(HWND,UINT);
1524 static void (WINAPI *pNotifyWinEvent)(DWORD, HWND, LONG, LONG);
1525 static HWINEVENTHOOK (WINAPI *pSetWinEventHook)(DWORD, DWORD, HMODULE, WINEVENTPROC, DWORD, DWORD, DWORD);
1526 static BOOL (WINAPI *pTrackMouseEvent)(TRACKMOUSEEVENT*);
1527 static BOOL (WINAPI *pUnhookWinEvent)(HWINEVENTHOOK);
1528 /* kernel32 functions */
1529 static BOOL (WINAPI *pGetCPInfoExA)(UINT, DWORD, LPCPINFOEXA);
1531 static void init_procs(void)
1533 HMODULE user32 = GetModuleHandleA("user32.dll");
1534 HMODULE kernel32 = GetModuleHandleA("kernel32.dll");
1536 #define GET_PROC(dll, func) \
1537 p ## func = (void*)GetProcAddress(dll, #func); \
1539 trace("GetProcAddress(%s) failed\n", #func); \
1542 GET_PROC(user32, GetAncestor)
1543 GET_PROC(user32, NotifyWinEvent)
1544 GET_PROC(user32, SetWinEventHook)
1545 GET_PROC(user32, TrackMouseEvent)
1546 GET_PROC(user32, UnhookWinEvent)
1548 GET_PROC(kernel32, GetCPInfoExA)
1553 static void add_message(const struct message *msg)
1558 sequence = HeapAlloc( GetProcessHeap(), 0, sequence_size * sizeof (struct message) );
1560 if (sequence_cnt == sequence_size)
1563 sequence = HeapReAlloc( GetProcessHeap(), 0, sequence, sequence_size * sizeof (struct message) );
1567 sequence[sequence_cnt].message = msg->message;
1568 sequence[sequence_cnt].flags = msg->flags;
1569 sequence[sequence_cnt].wParam = msg->wParam;
1570 sequence[sequence_cnt].lParam = msg->lParam;
1575 /* try to make sure pending X events have been processed before continuing */
1576 static void flush_events(void)
1580 int min_timeout = 50;
1581 DWORD time = GetTickCount() + diff;
1585 if (MsgWaitForMultipleObjects( 0, NULL, FALSE, min_timeout, QS_ALLINPUT ) == WAIT_TIMEOUT) break;
1586 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
1587 diff = time - GetTickCount();
1592 static void flush_sequence(void)
1594 HeapFree(GetProcessHeap(), 0, sequence);
1596 sequence_cnt = sequence_size = 0;
1599 #define ok_sequence( exp, contx, todo) \
1600 ok_sequence_( (exp), (contx), (todo), __FILE__, __LINE__)
1603 static void ok_sequence_(const struct message *expected, const char *context, int todo,
1604 const char *file, int line)
1606 static const struct message end_of_sequence = { 0, 0, 0, 0 };
1607 const struct message *actual;
1610 add_message(&end_of_sequence);
1614 while (expected->message && actual->message)
1616 trace_( file, line)("expected %04x - actual %04x\n", expected->message, actual->message);
1618 if (expected->message == actual->message)
1620 if (expected->flags & wparam)
1622 if (expected->wParam != actual->wParam && todo)
1626 ok_( file, line) (FALSE,
1627 "%s: in msg 0x%04x expecting wParam 0x%lx got 0x%lx\n",
1628 context, expected->message, expected->wParam, actual->wParam);
1632 ok_( file, line) (expected->wParam == actual->wParam,
1633 "%s: in msg 0x%04x expecting wParam 0x%lx got 0x%lx\n",
1634 context, expected->message, expected->wParam, actual->wParam);
1636 if (expected->flags & lparam)
1638 if (expected->lParam != actual->lParam && todo)
1642 ok_( file, line) (FALSE,
1643 "%s: in msg 0x%04x expecting lParam 0x%lx got 0x%lx\n",
1644 context, expected->message, expected->lParam, actual->lParam);
1648 ok_( file, line) (expected->lParam == actual->lParam,
1649 "%s: in msg 0x%04x expecting lParam 0x%lx got 0x%lx\n",
1650 context, expected->message, expected->lParam, actual->lParam);
1652 if ((expected->flags & defwinproc) != (actual->flags & defwinproc) && todo)
1656 ok_( file, line) (FALSE,
1657 "%s: the msg 0x%04x should %shave been sent by DefWindowProc\n",
1658 context, expected->message, (expected->flags & defwinproc) ? "" : "NOT ");
1662 ok_( file, line) ((expected->flags & defwinproc) == (actual->flags & defwinproc),
1663 "%s: the msg 0x%04x should %shave been sent by DefWindowProc\n",
1664 context, expected->message, (expected->flags & defwinproc) ? "" : "NOT ");
1665 ok_( file, line) ((expected->flags & beginpaint) == (actual->flags & beginpaint),
1666 "%s: the msg 0x%04x should %shave been sent by BeginPaint\n",
1667 context, expected->message, (expected->flags & beginpaint) ? "" : "NOT ");
1668 ok_( file, line) ((expected->flags & (sent|posted)) == (actual->flags & (sent|posted)),
1669 "%s: the msg 0x%04x should have been %s\n",
1670 context, expected->message, (expected->flags & posted) ? "posted" : "sent");
1671 ok_( file, line) ((expected->flags & parent) == (actual->flags & parent),
1672 "%s: the msg 0x%04x was expected in %s\n",
1673 context, expected->message, (expected->flags & parent) ? "parent" : "child");
1674 ok_( file, line) ((expected->flags & hook) == (actual->flags & hook),
1675 "%s: the msg 0x%04x should have been sent by a hook\n",
1676 context, expected->message);
1677 ok_( file, line) ((expected->flags & winevent_hook) == (actual->flags & winevent_hook),
1678 "%s: the msg 0x%04x should have been sent by a winevent hook\n",
1679 context, expected->message);
1683 /* silently drop winevent messages if there is no support for them */
1684 else if ((expected->flags & optional) || ((expected->flags & winevent_hook) && !hEvent_hook))
1690 ok_( file, line) (FALSE, "%s: the msg 0x%04x was expected, but got msg 0x%04x instead\n",
1691 context, expected->message, actual->message);
1698 ok_( file, line) (FALSE, "%s: the msg 0x%04x was expected, but got msg 0x%04x instead\n",
1699 context, expected->message, actual->message);
1705 /* skip all optional trailing messages */
1706 while (expected->message && ((expected->flags & optional) ||
1707 ((expected->flags & winevent_hook) && !hEvent_hook)))
1713 if (expected->message || actual->message) {
1715 ok_( file, line) (FALSE, "%s: the msg sequence is not complete: expected %04x - actual %04x\n",
1716 context, expected->message, actual->message);
1722 if (expected->message || actual->message)
1723 ok_( file, line) (FALSE, "%s: the msg sequence is not complete: expected %04x - actual %04x\n",
1724 context, expected->message, actual->message);
1726 if( todo && !failcount) /* succeeded yet marked todo */
1728 ok_( file, line)( TRUE, "%s: marked \"todo_wine\" but succeeds\n", context);
1734 /******************************** MDI test **********************************/
1736 /* CreateWindow for MDI frame window, initially visible */
1737 static const struct message WmCreateMDIframeSeq[] = {
1738 { HCBT_CREATEWND, hook },
1739 { WM_GETMINMAXINFO, sent },
1740 { WM_NCCREATE, sent },
1741 { WM_NCCALCSIZE, sent|wparam, 0 },
1742 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
1743 { WM_CREATE, sent },
1744 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1745 { WM_SHOWWINDOW, sent|wparam, 1 },
1746 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
1747 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1748 { HCBT_ACTIVATE, hook },
1749 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
1750 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
1751 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* XP */
1752 { WM_ACTIVATEAPP, sent|wparam|optional, 1 }, /* Win9x doesn't send it */
1753 { WM_NCACTIVATE, sent|wparam, 1 },
1754 { WM_GETTEXT, sent|defwinproc|optional },
1755 { WM_ACTIVATE, sent|wparam, 1 },
1756 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* Win9x */
1757 { HCBT_SETFOCUS, hook },
1758 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
1759 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
1760 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1761 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
1762 /* Win9x adds SWP_NOZORDER below */
1763 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1764 { WM_NCCALCSIZE, sent|wparam|optional, 1 }, /* XP */
1765 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1766 { WM_SIZE, sent|wparam, SIZE_RESTORED },
1770 /* DestroyWindow for MDI frame window, initially visible */
1771 static const struct message WmDestroyMDIframeSeq[] = {
1772 { HCBT_DESTROYWND, hook },
1773 { 0x0090, sent|optional },
1774 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1775 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
1776 { WM_NCACTIVATE, sent|wparam|optional, 0 }, /* Win9x */
1777 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1778 { WM_NCACTIVATE, sent|wparam|optional, 0 }, /* XP */
1779 { WM_ACTIVATE, sent|wparam|optional, 0 }, /* Win9x */
1780 { WM_ACTIVATEAPP, sent|wparam|optional, 0 }, /* Win9x */
1781 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
1782 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
1783 { WM_DESTROY, sent },
1784 { WM_NCDESTROY, sent },
1787 /* CreateWindow for MDI client window, initially visible */
1788 static const struct message WmCreateMDIclientSeq[] = {
1789 { HCBT_CREATEWND, hook },
1790 { WM_NCCREATE, sent },
1791 { WM_NCCALCSIZE, sent|wparam, 0 },
1792 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam|optional, 0, 0 },
1793 { WM_CREATE, sent },
1794 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam|optional, 0, 0 },
1795 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1796 { WM_SIZE, sent|wparam, SIZE_RESTORED },
1798 { WM_PARENTNOTIFY, sent|wparam, WM_CREATE }, /* in MDI frame */
1799 { WM_SHOWWINDOW, sent|wparam, 1 },
1800 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1801 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1802 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1805 /* ShowWindow(SW_SHOW) for MDI client window */
1806 static const struct message WmShowMDIclientSeq[] = {
1807 { WM_SHOWWINDOW, sent|wparam, 1 },
1808 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1809 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1810 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1813 /* ShowWindow(SW_HIDE) for MDI client window */
1814 static const struct message WmHideMDIclientSeq[] = {
1815 { WM_SHOWWINDOW, sent|wparam, 0 },
1816 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1817 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam|optional, 0, 0 }, /* win2000 */
1818 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* XP */
1819 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1822 /* DestroyWindow for MDI client window, initially visible */
1823 static const struct message WmDestroyMDIclientSeq[] = {
1824 { HCBT_DESTROYWND, hook },
1825 { 0x0090, sent|optional },
1826 { WM_PARENTNOTIFY, sent|wparam, WM_DESTROY }, /* in MDI frame */
1827 { WM_SHOWWINDOW, sent|wparam, 0 },
1828 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1829 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
1830 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1831 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
1832 { WM_DESTROY, sent },
1833 { WM_NCDESTROY, sent },
1836 /* CreateWindow for MDI child window, initially visible */
1837 static const struct message WmCreateMDIchildVisibleSeq[] = {
1838 { HCBT_CREATEWND, hook },
1839 { WM_NCCREATE, sent },
1840 { WM_NCCALCSIZE, sent|wparam, 0 },
1841 { WM_CREATE, sent },
1842 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1843 { WM_SIZE, sent|wparam, SIZE_RESTORED },
1845 /* Win2k sends wparam set to
1846 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
1847 * while Win9x doesn't bother to set child window id according to
1848 * CLIENTCREATESTRUCT.idFirstChild
1850 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
1851 { WM_SHOWWINDOW, sent|wparam, 1 },
1852 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1853 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1854 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1855 { WM_MDIREFRESHMENU, sent/*|wparam|lparam, 0, 0*/ },
1856 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
1857 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
1858 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1860 /* Win9x: message sequence terminates here. */
1862 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
1863 { HCBT_SETFOCUS, hook }, /* in MDI client */
1864 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
1865 { WM_IME_NOTIFY, sent|wparam|optional, 2 }, /* in MDI client */
1866 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1867 { WM_SETFOCUS, sent }, /* in MDI client */
1868 { HCBT_SETFOCUS, hook },
1869 { WM_KILLFOCUS, sent }, /* in MDI client */
1870 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
1871 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
1872 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1873 { WM_SETFOCUS, sent|defwinproc },
1874 { WM_MDIACTIVATE, sent|defwinproc },
1877 /* CreateWindow for MDI child window with invisible parent */
1878 static const struct message WmCreateMDIchildInvisibleParentSeq[] = {
1879 { HCBT_CREATEWND, hook },
1880 { WM_GETMINMAXINFO, sent },
1881 { WM_NCCREATE, sent },
1882 { WM_NCCALCSIZE, sent|wparam, 0 },
1883 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam|optional, 0, 0 },
1884 { WM_CREATE, sent },
1885 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1886 { WM_SIZE, sent|wparam, SIZE_RESTORED },
1888 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
1889 { WM_SHOWWINDOW, sent|wparam, 1 },
1890 { WM_MDIREFRESHMENU, sent }, /* in MDI client */
1891 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
1892 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
1893 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1895 /* Win9x: message sequence terminates here. */
1897 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
1898 { HCBT_SETFOCUS, hook }, /* in MDI client */
1899 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
1900 { WM_IME_NOTIFY, sent|wparam|optional, 2 }, /* in MDI client */
1901 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1902 { WM_SETFOCUS, sent }, /* in MDI client */
1903 { HCBT_SETFOCUS, hook },
1904 { WM_KILLFOCUS, sent }, /* in MDI client */
1905 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
1906 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
1907 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1908 { WM_SETFOCUS, sent|defwinproc },
1909 { WM_MDIACTIVATE, sent|defwinproc },
1912 /* DestroyWindow for MDI child window, initially visible */
1913 static const struct message WmDestroyMDIchildVisibleSeq[] = {
1914 { HCBT_DESTROYWND, hook },
1915 /* Win2k sends wparam set to
1916 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
1917 * while Win9x doesn't bother to set child window id according to
1918 * CLIENTCREATESTRUCT.idFirstChild
1920 { 0x0090, sent|optional },
1921 { WM_PARENTNOTIFY, sent /*|wparam, WM_DESTROY*/ }, /* in MDI client */
1922 { WM_SHOWWINDOW, sent|wparam, 0 },
1923 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1924 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
1925 { WM_ERASEBKGND, sent|parent|optional },
1926 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1928 /* { WM_DESTROY, sent }
1929 * Win9x: message sequence terminates here.
1932 { HCBT_SETFOCUS, hook }, /* set focus to MDI client */
1933 { WM_KILLFOCUS, sent },
1934 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
1935 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
1936 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1937 { WM_SETFOCUS, sent }, /* in MDI client */
1939 { HCBT_SETFOCUS, hook }, /* MDI client sets focus back to MDI child */
1940 { WM_KILLFOCUS, sent }, /* in MDI client */
1941 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
1942 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
1943 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1944 { WM_SETFOCUS, sent }, /* in MDI client */
1946 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
1948 { HCBT_SETFOCUS, hook }, /* set focus to MDI client */
1949 { WM_KILLFOCUS, sent },
1950 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
1951 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
1952 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1953 { WM_SETFOCUS, sent }, /* in MDI client */
1955 { HCBT_SETFOCUS, hook }, /* MDI client sets focus back to MDI child */
1956 { WM_KILLFOCUS, sent }, /* in MDI client */
1957 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
1958 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
1959 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1960 { WM_SETFOCUS, sent }, /* in MDI client */
1962 { WM_DESTROY, sent },
1964 { HCBT_SETFOCUS, hook }, /* set focus to MDI client */
1965 { WM_KILLFOCUS, sent },
1966 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
1967 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
1968 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1969 { WM_SETFOCUS, sent }, /* in MDI client */
1971 { HCBT_SETFOCUS, hook }, /* MDI client sets focus back to MDI child */
1972 { WM_KILLFOCUS, sent }, /* in MDI client */
1973 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
1974 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
1975 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1976 { WM_SETFOCUS, sent }, /* in MDI client */
1978 { WM_NCDESTROY, sent },
1981 /* CreateWindow for MDI child window, initially invisible */
1982 static const struct message WmCreateMDIchildInvisibleSeq[] = {
1983 { HCBT_CREATEWND, hook },
1984 { WM_NCCREATE, sent },
1985 { WM_NCCALCSIZE, sent|wparam, 0 },
1986 { WM_CREATE, sent },
1987 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1988 { WM_SIZE, sent|wparam, SIZE_RESTORED },
1990 /* Win2k sends wparam set to
1991 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
1992 * while Win9x doesn't bother to set child window id according to
1993 * CLIENTCREATESTRUCT.idFirstChild
1995 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
1998 /* DestroyWindow for MDI child window, initially invisible */
1999 static const struct message WmDestroyMDIchildInvisibleSeq[] = {
2000 { HCBT_DESTROYWND, hook },
2001 /* Win2k sends wparam set to
2002 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
2003 * while Win9x doesn't bother to set child window id according to
2004 * CLIENTCREATESTRUCT.idFirstChild
2006 { 0x0090, sent|optional },
2007 { WM_PARENTNOTIFY, sent /*|wparam, WM_DESTROY*/ }, /* in MDI client */
2008 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
2009 { WM_DESTROY, sent },
2010 { WM_NCDESTROY, sent },
2011 /* FIXME: Wine destroys an icon/title window while Windows doesn't */
2012 { WM_PARENTNOTIFY, sent|wparam|optional, WM_DESTROY }, /* MDI client */
2015 /* CreateWindow for the 1st MDI child window, initially visible and maximized */
2016 static const struct message WmCreateMDIchildVisibleMaxSeq1[] = {
2017 { HCBT_CREATEWND, hook },
2018 { WM_NCCREATE, sent },
2019 { WM_NCCALCSIZE, sent|wparam, 0 },
2020 { WM_CREATE, sent },
2021 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
2022 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2024 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
2025 { WM_GETMINMAXINFO, sent },
2026 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_STATECHANGED },
2027 { WM_NCCALCSIZE, sent|wparam, 1 },
2028 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_STATECHANGED },
2029 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2031 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2032 { WM_NCCALCSIZE, sent|wparam, 1 },
2033 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2034 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2035 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2036 /* Win2k sends wparam set to
2037 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2038 * while Win9x doesn't bother to set child window id according to
2039 * CLIENTCREATESTRUCT.idFirstChild
2041 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
2042 { WM_SHOWWINDOW, sent|wparam, 1 },
2043 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2044 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2045 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2046 { WM_MDIREFRESHMENU, sent/*|wparam|lparam, 0, 0*/ },
2047 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
2048 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2049 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2051 /* Win9x: message sequence terminates here. */
2053 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
2054 { HCBT_SETFOCUS, hook }, /* in MDI client */
2055 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2056 { WM_IME_NOTIFY, sent|wparam|optional, 2 }, /* in MDI client */
2057 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2058 { WM_SETFOCUS, sent }, /* in MDI client */
2059 { HCBT_SETFOCUS, hook },
2060 { WM_KILLFOCUS, sent }, /* in MDI client */
2061 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
2062 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
2063 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2064 { WM_SETFOCUS, sent|defwinproc },
2065 { WM_MDIACTIVATE, sent|defwinproc },
2067 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2068 { WM_NCCALCSIZE, sent|wparam, 1 },
2069 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2070 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2073 /* CreateWindow for the 2nd MDI child window, initially visible and maximized */
2074 static const struct message WmCreateMDIchildVisibleMaxSeq2[] = {
2075 /* restore the 1st MDI child */
2076 { WM_SETREDRAW, sent|wparam, 0 },
2077 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWNORMAL },
2078 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_STATECHANGED },
2079 { WM_NCCALCSIZE, sent|wparam, 1 },
2080 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2081 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_STATECHANGED },
2082 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2084 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2085 { WM_NCCALCSIZE, sent|wparam, 1 },
2086 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2087 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2088 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2089 { WM_SETREDRAW, sent|wparam, 1 }, /* in the 1st MDI child */
2090 /* create the 2nd MDI child */
2091 { HCBT_CREATEWND, hook },
2092 { WM_NCCREATE, sent },
2093 { WM_NCCALCSIZE, sent|wparam, 0 },
2094 { WM_CREATE, sent },
2095 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
2096 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2098 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
2099 { WM_GETMINMAXINFO, sent },
2100 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_STATECHANGED },
2101 { WM_NCCALCSIZE, sent|wparam, 1 },
2102 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2103 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_STATECHANGED },
2104 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2106 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2107 { WM_NCCALCSIZE, sent|wparam, 1 },
2108 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2109 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2110 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2111 /* Win2k sends wparam set to
2112 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2113 * while Win9x doesn't bother to set child window id according to
2114 * CLIENTCREATESTRUCT.idFirstChild
2116 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
2117 { WM_SHOWWINDOW, sent|wparam, 1 },
2118 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2119 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2120 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2121 { WM_MDIREFRESHMENU, sent/*|wparam|lparam, 0, 0*/ },
2122 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
2123 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2125 { WM_NCACTIVATE, sent|wparam|defwinproc, 0 }, /* in the 1st MDI child */
2126 { WM_MDIACTIVATE, sent|defwinproc }, /* in the 1st MDI child */
2128 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2130 /* Win9x: message sequence terminates here. */
2132 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
2133 { HCBT_SETFOCUS, hook },
2134 { WM_KILLFOCUS, sent|defwinproc }, /* in the 1st MDI child */
2135 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 0 }, /* in the 1st MDI child */
2136 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2137 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2138 { WM_SETFOCUS, sent }, /* in MDI client */
2139 { HCBT_SETFOCUS, hook },
2140 { WM_KILLFOCUS, sent }, /* in MDI client */
2141 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
2142 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
2143 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2144 { WM_SETFOCUS, sent|defwinproc },
2146 { WM_MDIACTIVATE, sent|defwinproc },
2148 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2149 { WM_NCCALCSIZE, sent|wparam, 1 },
2150 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2151 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2154 /* WM_MDICREATE MDI child window, initially visible and maximized */
2155 static const struct message WmCreateMDIchildVisibleMaxSeq3[] = {
2156 { WM_MDICREATE, sent },
2157 { HCBT_CREATEWND, hook },
2158 { WM_NCCREATE, sent },
2159 { WM_NCCALCSIZE, sent|wparam, 0 },
2160 { WM_CREATE, sent },
2161 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
2162 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2164 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
2165 { WM_GETMINMAXINFO, sent },
2166 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_STATECHANGED },
2167 { WM_NCCALCSIZE, sent|wparam, 1 },
2168 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_STATECHANGED },
2169 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2172 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2173 { WM_NCCALCSIZE, sent|wparam, 1 },
2174 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2175 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2176 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2178 /* Win2k sends wparam set to
2179 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2180 * while Win9x doesn't bother to set child window id according to
2181 * CLIENTCREATESTRUCT.idFirstChild
2183 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
2184 { WM_SHOWWINDOW, sent|wparam, 1 },
2185 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2187 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2189 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2190 { WM_MDIREFRESHMENU, sent/*|wparam|lparam, 0, 0*/ },
2191 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
2193 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2194 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2196 /* Win9x: message sequence terminates here. */
2198 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
2199 { WM_SETFOCUS, sent|optional }, /* in MDI client */
2200 { HCBT_SETFOCUS, hook }, /* in MDI client */
2201 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2202 { WM_IME_NOTIFY, sent|wparam|optional, 2 },
2203 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
2204 { WM_SETFOCUS, sent|optional }, /* in MDI client */
2205 { HCBT_SETFOCUS, hook|optional },
2206 { WM_KILLFOCUS, sent }, /* in MDI client */
2207 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
2208 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
2209 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2210 { WM_SETFOCUS, sent|defwinproc },
2212 { WM_MDIACTIVATE, sent|defwinproc },
2215 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2216 { WM_NCCALCSIZE, sent|wparam, 1 },
2217 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2218 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
2221 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2222 { WM_NCCALCSIZE, sent|wparam, 1 },
2223 { 0x0093, sent|defwinproc|optional },
2224 { 0x0093, sent|defwinproc|optional },
2225 { 0x0093, sent|defwinproc|optional },
2226 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2227 { WM_MOVE, sent|defwinproc },
2228 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2231 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE },
2232 { WM_NCCALCSIZE, sent|wparam, 1 },
2233 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOCLIENTMOVE },
2234 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2237 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE },
2238 { WM_NCCALCSIZE, sent|wparam, 1 },
2239 { 0x0093, sent|optional },
2240 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOCLIENTMOVE },
2241 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2243 { 0x0093, sent|optional },
2244 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2245 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI client */
2246 { WM_NCCALCSIZE, sent|wparam|optional, 1 }, /* XP sends it to MDI frame */
2247 { 0x0093, sent|defwinproc|optional },
2248 { 0x0093, sent|defwinproc|optional },
2249 { 0x0093, sent|defwinproc|optional },
2250 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2251 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* XP sends a duplicate */
2255 /* CreateWindow for the 1st MDI child window, initially invisible and maximized */
2256 static const struct message WmCreateMDIchildInvisibleMaxSeq4[] = {
2257 { HCBT_CREATEWND, hook },
2258 { WM_GETMINMAXINFO, sent },
2259 { WM_NCCREATE, sent },
2260 { WM_NCCALCSIZE, sent|wparam, 0 },
2261 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
2262 { WM_CREATE, sent },
2263 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
2264 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2266 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
2267 { WM_GETMINMAXINFO, sent },
2268 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_STATECHANGED },
2269 { WM_GETMINMAXINFO, sent|defwinproc },
2270 { WM_NCCALCSIZE, sent|wparam, 1 },
2271 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_STATECHANGED },
2272 { WM_MOVE, sent|defwinproc },
2273 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2275 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2276 { WM_NCCALCSIZE, sent|wparam, 1 },
2277 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2278 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2279 { WM_NCCALCSIZE, sent|wparam|optional, 1 }, /* MDI child */
2280 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2281 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2282 /* Win2k sends wparam set to
2283 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2284 * while Win9x doesn't bother to set child window id according to
2285 * CLIENTCREATESTRUCT.idFirstChild
2287 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
2290 /* WM_SYSCOMMAND/SC_CLOSE for the 2nd MDI child window, initially visible and maximized */
2291 static const struct message WmDestroyMDIchildVisibleMaxSeq2[] = {
2292 { WM_SYSCOMMAND, sent|wparam, SC_CLOSE },
2293 { HCBT_SYSCOMMAND, hook },
2294 { WM_CLOSE, sent|defwinproc },
2295 { WM_MDIDESTROY, sent }, /* in MDI client */
2297 /* bring the 1st MDI child to top */
2298 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOSIZE|SWP_NOMOVE }, /* in the 1st MDI child */
2299 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE }, /* in the 2nd MDI child */
2301 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2303 { WM_CHILDACTIVATE, sent|defwinproc|wparam|lparam, 0, 0 }, /* in the 1st MDI child */
2304 { WM_NCACTIVATE, sent|wparam|defwinproc, 0 }, /* in the 1st MDI child */
2305 { WM_MDIACTIVATE, sent|defwinproc }, /* in the 1st MDI child */
2307 /* maximize the 1st MDI child */
2308 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
2309 { WM_GETMINMAXINFO, sent|defwinproc },
2310 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_STATECHANGED },
2311 { WM_NCCALCSIZE, sent|defwinproc|wparam, 1 },
2312 { WM_CHILDACTIVATE, sent|defwinproc|wparam|lparam, 0, 0 },
2313 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_STATECHANGED },
2314 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2316 /* restore the 2nd MDI child */
2317 { WM_SETREDRAW, sent|defwinproc|wparam, 0 },
2318 { HCBT_MINMAX, hook|lparam, 0, SW_NORMALNA },
2319 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_SHOWWINDOW|SWP_STATECHANGED },
2320 { WM_NCCALCSIZE, sent|defwinproc|wparam, 1 },
2322 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2324 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_STATECHANGED },
2325 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2327 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2329 { WM_SETREDRAW, sent|defwinproc|wparam, 1 },
2331 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2332 { WM_NCCALCSIZE, sent|wparam, 1 },
2333 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2334 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2335 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2337 /* bring the 1st MDI child to top */
2338 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2339 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
2340 { HCBT_SETFOCUS, hook },
2341 { WM_KILLFOCUS, sent|defwinproc },
2342 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 0 },
2343 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2344 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2345 { WM_SETFOCUS, sent }, /* in MDI client */
2346 { HCBT_SETFOCUS, hook },
2347 { WM_KILLFOCUS, sent }, /* in MDI client */
2348 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
2349 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
2350 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2351 { WM_SETFOCUS, sent|defwinproc },
2352 { WM_MDIACTIVATE, sent|defwinproc },
2353 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2355 /* apparently ShowWindow(SW_SHOW) on an MDI client */
2356 { WM_SHOWWINDOW, sent|wparam, 1 },
2357 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2358 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2359 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2360 { WM_MDIREFRESHMENU, sent },
2362 { HCBT_DESTROYWND, hook },
2363 /* Win2k sends wparam set to
2364 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
2365 * while Win9x doesn't bother to set child window id according to
2366 * CLIENTCREATESTRUCT.idFirstChild
2368 { 0x0090, sent|defwinproc|optional },
2369 { WM_PARENTNOTIFY, sent /*|wparam, WM_DESTROY*/ }, /* in MDI client */
2370 { WM_SHOWWINDOW, sent|defwinproc|wparam, 0 },
2371 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2372 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
2373 { WM_ERASEBKGND, sent|parent|optional },
2374 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2376 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
2377 { WM_DESTROY, sent|defwinproc },
2378 { WM_NCDESTROY, sent|defwinproc },
2381 /* WM_MDIDESTROY for the single MDI child window, initially visible and maximized */
2382 static const struct message WmDestroyMDIchildVisibleMaxSeq1[] = {
2383 { WM_MDIDESTROY, sent }, /* in MDI client */
2384 { WM_SHOWWINDOW, sent|wparam, 0 },
2385 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2386 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
2387 { WM_ERASEBKGND, sent|parent|optional },
2388 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2390 { HCBT_SETFOCUS, hook },
2391 { WM_KILLFOCUS, sent },
2392 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
2393 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2394 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2395 { WM_SETFOCUS, sent }, /* in MDI client */
2396 { HCBT_SETFOCUS, hook },
2397 { WM_KILLFOCUS, sent }, /* in MDI client */
2398 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
2399 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
2400 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2401 { WM_SETFOCUS, sent },
2404 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2405 { WM_NCCALCSIZE, sent|wparam, 1 },
2406 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2407 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2410 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2411 { WM_NCCALCSIZE, sent|wparam, 1 },
2412 { 0x0093, sent|defwinproc|optional },
2413 { 0x0093, sent|defwinproc|optional },
2414 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2415 { WM_MOVE, sent|defwinproc },
2416 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2419 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE },
2420 { WM_NCCALCSIZE, sent|wparam, 1 },
2421 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOCLIENTMOVE },
2422 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2425 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE },
2426 { WM_NCCALCSIZE, sent|wparam, 1 },
2427 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTMOVE },
2428 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2431 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2432 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 },
2433 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2434 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2437 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2438 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 },
2439 { 0x0093, sent|defwinproc|optional },
2440 { 0x0093, sent|defwinproc|optional },
2441 { 0x0093, sent|defwinproc|optional },
2442 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2443 { WM_MOVE, sent|defwinproc },
2444 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2447 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE },
2448 { WM_NCCALCSIZE, sent|wparam, 1 },
2449 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOCLIENTMOVE },
2450 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2453 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE },
2454 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 },
2455 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTMOVE },
2456 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2457 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2458 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI client */
2460 { 0x0093, sent|defwinproc|optional },
2461 { WM_NCCALCSIZE, sent|wparam|defwinproc|optional, 1 }, /* XP sends it to MDI frame */
2462 { 0x0093, sent|defwinproc|optional },
2463 { 0x0093, sent|defwinproc|optional },
2464 { 0x0093, sent|defwinproc|optional },
2465 { 0x0093, sent|optional },
2467 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2468 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2469 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI client */
2470 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2471 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* XP sends a duplicate */
2474 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2475 { WM_NCCALCSIZE, sent|wparam, 1 },
2476 { 0x0093, sent|defwinproc|optional },
2477 { 0x0093, sent|defwinproc|optional },
2478 { 0x0093, sent|defwinproc|optional },
2479 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2480 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2481 { 0x0093, sent|optional },
2483 { WM_NCACTIVATE, sent|wparam, 0 },
2484 { WM_MDIACTIVATE, sent },
2486 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWNORMAL },
2487 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_SHOWWINDOW|SWP_STATECHANGED },
2488 { WM_NCCALCSIZE, sent|wparam, 1 },
2490 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2492 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2493 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_SHOWWINDOW|SWP_NOMOVE|SWP_NOCLIENTMOVE|SWP_STATECHANGED },
2494 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2497 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2498 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 },
2499 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2500 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2503 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2504 { WM_NCCALCSIZE, sent|wparam, 1 },
2505 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2506 { WM_MOVE, sent|defwinproc },
2507 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2510 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE },
2511 { WM_NCCALCSIZE, sent|wparam, 1 },
2512 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOCLIENTMOVE },
2513 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2514 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2515 { WM_NCCALCSIZE, sent|wparam|optional, 1 }, /* XP */
2516 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI client */
2517 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2518 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* XP sends a duplicate */
2520 { HCBT_SETFOCUS, hook },
2521 { WM_KILLFOCUS, sent },
2522 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
2523 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2524 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2525 { WM_SETFOCUS, sent }, /* in MDI client */
2527 { WM_MDIREFRESHMENU, sent }, /* in MDI client */
2529 { HCBT_DESTROYWND, hook },
2530 /* Win2k sends wparam set to
2531 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
2532 * while Win9x doesn't bother to set child window id according to
2533 * CLIENTCREATESTRUCT.idFirstChild
2535 { 0x0090, sent|optional },
2536 { WM_PARENTNOTIFY, sent /*|wparam, WM_DESTROY*/ }, /* in MDI client */
2538 { WM_SHOWWINDOW, sent|wparam, 0 },
2539 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2540 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
2541 { WM_ERASEBKGND, sent|parent|optional },
2542 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2544 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
2545 { WM_DESTROY, sent },
2546 { WM_NCDESTROY, sent },
2549 /* ShowWindow(SW_MAXIMIZE) for a not visible MDI child window */
2550 static const struct message WmMaximizeMDIchildInvisibleSeq[] = {
2551 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
2552 { WM_GETMINMAXINFO, sent },
2553 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_STATECHANGED },
2554 { WM_NCCALCSIZE, sent|wparam, 1 },
2555 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2556 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2558 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2559 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
2560 { HCBT_SETFOCUS, hook },
2561 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2562 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2563 { WM_SETFOCUS, sent }, /* in MDI client */
2564 { HCBT_SETFOCUS, hook },
2565 { WM_KILLFOCUS, sent }, /* in MDI client */
2566 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
2567 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
2568 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2569 { WM_SETFOCUS, sent|defwinproc },
2570 { WM_MDIACTIVATE, sent|defwinproc },
2571 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_STATECHANGED },
2572 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2574 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2575 { WM_NCCALCSIZE, sent|wparam, 1 },
2576 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2577 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2578 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2581 /* ShowWindow(SW_MAXIMIZE) for a not visible maximized MDI child window */
2582 static const struct message WmMaximizeMDIchildInvisibleSeq2[] = {
2583 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
2584 { WM_GETMINMAXINFO, sent },
2585 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED },
2586 { WM_GETMINMAXINFO, sent|defwinproc },
2587 { WM_NCCALCSIZE, sent|wparam, 1 },
2588 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2589 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2591 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2592 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
2593 { HCBT_SETFOCUS, hook },
2594 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2595 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2596 { WM_SETFOCUS, sent }, /* in MDI client */
2597 { HCBT_SETFOCUS, hook },
2598 { WM_KILLFOCUS, sent }, /* in MDI client */
2599 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
2600 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
2601 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2602 { WM_SETFOCUS, sent|defwinproc },
2603 { WM_MDIACTIVATE, sent|defwinproc },
2604 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2605 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2608 /* WM_MDIMAXIMIZE for an MDI child window with invisible parent */
2609 static const struct message WmMaximizeMDIchildInvisibleParentSeq[] = {
2610 { WM_MDIMAXIMIZE, sent }, /* in MDI client */
2611 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
2612 { WM_GETMINMAXINFO, sent },
2613 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_STATECHANGED },
2614 { WM_GETMINMAXINFO, sent|defwinproc },
2615 { WM_NCCALCSIZE, sent|wparam, 1 },
2616 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam|optional, 0, 0 }, /* XP doesn't send it */
2617 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2618 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOREDRAW|SWP_STATECHANGED },
2619 { WM_MOVE, sent|defwinproc },
2620 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2622 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2623 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 },
2624 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2625 { WM_NCCALCSIZE, sent|wparam|defwinproc|optional, 1 },
2626 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI child XP */
2627 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI client XP */
2629 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2630 { WM_NCCALCSIZE, sent|wparam, 1 },
2631 { 0x0093, sent|defwinproc|optional },
2632 { 0x0094, sent|defwinproc|optional },
2633 { 0x0094, sent|defwinproc|optional },
2634 { 0x0094, sent|defwinproc|optional },
2635 { 0x0094, sent|defwinproc|optional },
2636 { 0x0093, sent|defwinproc|optional },
2637 { 0x0093, sent|defwinproc|optional },
2638 { 0x0091, sent|defwinproc|optional },
2639 { 0x0092, sent|defwinproc|optional },
2640 { 0x0092, sent|defwinproc|optional },
2641 { 0x0092, sent|defwinproc|optional },
2642 { 0x0092, sent|defwinproc|optional },
2643 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2644 { WM_MOVE, sent|defwinproc },
2645 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2646 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI frame win2000 */
2648 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE },
2649 { WM_NCCALCSIZE, sent|wparam, 1 },
2650 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTMOVE },
2651 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2653 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE },
2654 { WM_GETMINMAXINFO, sent|defwinproc },
2655 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 },
2656 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTMOVE },
2657 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2658 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI child win2000 */
2659 { WM_NCCALCSIZE, sent|wparam|defwinproc|optional, 1 },
2660 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI child XP */
2661 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI child XP */
2662 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI client XP */
2664 { 0x0093, sent|optional },
2665 { WM_NCCALCSIZE, sent|wparam|optional, 1 },
2666 { 0x0093, sent|defwinproc|optional },
2667 { 0x0093, sent|defwinproc|optional },
2668 { 0x0093, sent|defwinproc|optional },
2669 { 0x0091, sent|defwinproc|optional },
2670 { 0x0092, sent|defwinproc|optional },
2671 { 0x0092, sent|defwinproc|optional },
2672 { 0x0092, sent|defwinproc|optional },
2673 { 0x0092, sent|defwinproc|optional },
2674 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI frame XP */
2675 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI frame XP */
2676 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI child XP */
2679 /* ShowWindow(SW_MAXIMIZE) for a visible MDI child window */
2680 static const struct message WmMaximizeMDIchildVisibleSeq[] = {
2681 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
2682 { WM_GETMINMAXINFO, sent },
2683 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_STATECHANGED },
2684 { WM_NCCALCSIZE, sent|wparam, 1 },
2685 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2686 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_STATECHANGED },
2687 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2689 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2690 { WM_NCCALCSIZE, sent|wparam, 1 },
2691 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2692 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2693 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2696 /* ShowWindow(SW_RESTORE) for a visible maximized MDI child window */
2697 static const struct message WmRestoreMDIchildVisibleSeq[] = {
2698 { HCBT_MINMAX, hook|lparam, 0, SW_RESTORE },
2699 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_STATECHANGED },
2700 { WM_NCCALCSIZE, sent|wparam, 1 },
2701 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2702 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_STATECHANGED },
2703 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2705 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2706 { WM_NCCALCSIZE, sent|wparam, 1 },
2707 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2708 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2709 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2712 /* ShowWindow(SW_RESTORE) for a visible minimized MDI child window */
2713 static const struct message WmRestoreMDIchildVisibleSeq_2[] = {
2714 { HCBT_MINMAX, hook|lparam, 0, SW_RESTORE },
2715 { WM_QUERYOPEN, sent|wparam|lparam, 0, 0 },
2716 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
2717 { WM_NCCALCSIZE, sent|wparam, 1 },
2718 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2719 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_NOCLIENTSIZE|SWP_STATECHANGED },
2720 { WM_MOVE, sent|defwinproc },
2721 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2722 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2723 { EVENT_SYSTEM_MINIMIZEEND, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2724 { HCBT_SETFOCUS, hook },
2725 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
2726 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
2727 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2728 { WM_SETFOCUS, sent },
2731 /* ShowWindow(SW_MINIMIZE) for a visible restored MDI child window */
2732 static const struct message WmMinimizeMDIchildVisibleSeq[] = {
2733 { HCBT_MINMAX, hook|lparam, 0, SW_MINIMIZE },
2734 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOCOPYBITS|SWP_STATECHANGED },
2735 { WM_NCCALCSIZE, sent|wparam, 1 },
2736 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOCOPYBITS|SWP_NOCLIENTSIZE|SWP_STATECHANGED },
2737 { WM_MOVE, sent|defwinproc },
2738 { WM_SIZE, sent|defwinproc|wparam, SIZE_MINIMIZED },
2739 { WM_CHILDACTIVATE, sent|wparam|lparam|defwinproc, 0, 0 },
2740 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2741 { EVENT_SYSTEM_MINIMIZESTART, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2742 /* FIXME: Wine creates an icon/title window while Windows doesn't */
2743 { WM_PARENTNOTIFY, sent|parent|wparam|optional, WM_CREATE }, /* MDI client */
2746 /* ShowWindow(SW_RESTORE) for a not visible MDI child window */
2747 static const struct message WmRestoreMDIchildInisibleSeq[] = {
2748 { HCBT_MINMAX, hook|lparam, 0, SW_RESTORE },
2749 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_STATECHANGED },
2750 { WM_NCCALCSIZE, sent|wparam, 1 },
2751 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2752 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2753 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_STATECHANGED },
2754 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2756 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2757 { WM_NCCALCSIZE, sent|wparam, 1 },
2758 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2759 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2760 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2764 static HWND mdi_client;
2765 static WNDPROC old_mdi_client_proc;
2767 static LRESULT WINAPI mdi_client_hook_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
2771 /* do not log painting messages */
2772 if (message != WM_PAINT &&
2773 message != WM_NCPAINT &&
2774 message != WM_SYNCPAINT &&
2775 message != WM_ERASEBKGND &&
2776 message != WM_NCHITTEST &&
2777 message != WM_GETTEXT &&
2778 message != WM_MDIGETACTIVE &&
2779 message != WM_GETICON &&
2780 message != WM_DEVICECHANGE)
2782 trace("mdi client: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
2786 case WM_WINDOWPOSCHANGING:
2787 case WM_WINDOWPOSCHANGED:
2789 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
2791 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
2792 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
2793 winpos->hwnd, winpos->hwndInsertAfter,
2794 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
2795 dump_winpos_flags(winpos->flags);
2797 /* Log only documented flags, win2k uses 0x1000 and 0x2000
2798 * in the high word for internal purposes
2800 wParam = winpos->flags & 0xffff;
2801 /* We are not interested in the flags that don't match under XP and Win9x */
2802 wParam &= ~(SWP_NOZORDER);
2807 msg.message = message;
2808 msg.flags = sent|wparam|lparam;
2809 msg.wParam = wParam;
2810 msg.lParam = lParam;
2814 return CallWindowProcA(old_mdi_client_proc, hwnd, message, wParam, lParam);
2817 static LRESULT WINAPI mdi_child_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
2819 static long defwndproc_counter = 0;
2823 /* do not log painting messages */
2824 if (message != WM_PAINT &&
2825 message != WM_NCPAINT &&
2826 message != WM_SYNCPAINT &&
2827 message != WM_ERASEBKGND &&
2828 message != WM_NCHITTEST &&
2829 message != WM_GETTEXT &&
2830 message != WM_GETICON &&
2831 message != WM_DEVICECHANGE)
2833 trace("mdi child: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
2837 case WM_WINDOWPOSCHANGING:
2838 case WM_WINDOWPOSCHANGED:
2840 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
2842 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
2843 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
2844 winpos->hwnd, winpos->hwndInsertAfter,
2845 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
2846 dump_winpos_flags(winpos->flags);
2848 /* Log only documented flags, win2k uses 0x1000 and 0x2000
2849 * in the high word for internal purposes
2851 wParam = winpos->flags & 0xffff;
2852 /* We are not interested in the flags that don't match under XP and Win9x */
2853 wParam &= ~(SWP_NOZORDER);
2857 case WM_MDIACTIVATE:
2859 HWND active, client = GetParent(hwnd);
2861 active = (HWND)SendMessageA(client, WM_MDIGETACTIVE, 0, 0);
2863 if (hwnd == (HWND)lParam) /* if we are being activated */
2864 ok (active == (HWND)lParam, "new active %p != active %p\n", (HWND)lParam, active);
2866 ok (active == (HWND)wParam, "old active %p != active %p\n", (HWND)wParam, active);
2871 msg.message = message;
2872 msg.flags = sent|wparam|lparam;
2873 if (defwndproc_counter) msg.flags |= defwinproc;
2874 msg.wParam = wParam;
2875 msg.lParam = lParam;
2879 defwndproc_counter++;
2880 ret = DefMDIChildProcA(hwnd, message, wParam, lParam);
2881 defwndproc_counter--;
2886 static LRESULT WINAPI mdi_frame_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
2888 static long defwndproc_counter = 0;
2892 /* do not log painting messages */
2893 if (message != WM_PAINT &&
2894 message != WM_NCPAINT &&
2895 message != WM_SYNCPAINT &&
2896 message != WM_ERASEBKGND &&
2897 message != WM_NCHITTEST &&
2898 message != WM_GETTEXT &&
2899 message != WM_GETICON &&
2900 message != WM_DEVICECHANGE)
2902 trace("mdi frame: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
2906 case WM_WINDOWPOSCHANGING:
2907 case WM_WINDOWPOSCHANGED:
2909 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
2911 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
2912 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
2913 winpos->hwnd, winpos->hwndInsertAfter,
2914 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
2915 dump_winpos_flags(winpos->flags);
2917 /* Log only documented flags, win2k uses 0x1000 and 0x2000
2918 * in the high word for internal purposes
2920 wParam = winpos->flags & 0xffff;
2921 /* We are not interested in the flags that don't match under XP and Win9x */
2922 wParam &= ~(SWP_NOZORDER);
2927 msg.message = message;
2928 msg.flags = sent|wparam|lparam;
2929 if (defwndproc_counter) msg.flags |= defwinproc;
2930 msg.wParam = wParam;
2931 msg.lParam = lParam;
2935 defwndproc_counter++;
2936 ret = DefFrameProcA(hwnd, mdi_client, message, wParam, lParam);
2937 defwndproc_counter--;
2942 static BOOL mdi_RegisterWindowClasses(void)
2947 cls.lpfnWndProc = mdi_frame_wnd_proc;
2950 cls.hInstance = GetModuleHandleA(0);
2952 cls.hCursor = LoadCursorA(0, (LPSTR)IDC_ARROW);
2953 cls.hbrBackground = GetStockObject(WHITE_BRUSH);
2954 cls.lpszMenuName = NULL;
2955 cls.lpszClassName = "MDI_frame_class";
2956 if (!RegisterClassA(&cls)) return FALSE;
2958 cls.lpfnWndProc = mdi_child_wnd_proc;
2959 cls.lpszClassName = "MDI_child_class";
2960 if (!RegisterClassA(&cls)) return FALSE;
2962 if (!GetClassInfoA(0, "MDIClient", &cls)) assert(0);
2963 old_mdi_client_proc = cls.lpfnWndProc;
2964 cls.hInstance = GetModuleHandleA(0);
2965 cls.lpfnWndProc = mdi_client_hook_proc;
2966 cls.lpszClassName = "MDI_client_class";
2967 if (!RegisterClassA(&cls)) assert(0);
2972 static void test_mdi_messages(void)
2974 MDICREATESTRUCTA mdi_cs;
2975 CLIENTCREATESTRUCT client_cs;
2976 HWND mdi_frame, mdi_child, mdi_child2, active_child;
2978 HMENU hMenu = CreateMenu();
2980 assert(mdi_RegisterWindowClasses());
2984 trace("creating MDI frame window\n");
2985 mdi_frame = CreateWindowExA(0, "MDI_frame_class", "MDI frame window",
2986 WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX |
2987 WS_MAXIMIZEBOX | WS_VISIBLE,
2988 100, 100, CW_USEDEFAULT, CW_USEDEFAULT,
2989 GetDesktopWindow(), hMenu,
2990 GetModuleHandleA(0), NULL);
2992 ok_sequence(WmCreateMDIframeSeq, "Create MDI frame window", FALSE);
2994 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2995 ok(GetFocus() == mdi_frame, "wrong focus window %p\n", GetFocus());
2997 trace("creating MDI client window\n");
2998 client_cs.hWindowMenu = 0;
2999 client_cs.idFirstChild = MDI_FIRST_CHILD_ID;
3000 mdi_client = CreateWindowExA(0, "MDI_client_class",
3002 WS_CHILD | WS_VISIBLE | MDIS_ALLCHILDSTYLES,
3004 mdi_frame, 0, GetModuleHandleA(0), &client_cs);
3006 ok_sequence(WmCreateMDIclientSeq, "Create visible MDI client window", FALSE);
3008 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3009 ok(GetFocus() == mdi_frame, "input focus should be on MDI frame not on %p\n", GetFocus());
3011 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3012 ok(!active_child, "wrong active MDI child %p\n", active_child);
3013 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
3018 trace("creating invisible MDI child window\n");
3019 mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
3021 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
3022 mdi_client, 0, GetModuleHandleA(0), NULL);
3026 ShowWindow(mdi_child, SW_SHOWNORMAL);
3027 ok_sequence(WmShowChildSeq, "ShowWindow(SW_SHOWNORMAL) MDI child window", FALSE);
3029 ok(GetWindowLongA(mdi_child, GWL_STYLE) & WS_VISIBLE, "MDI child should be visible\n");
3030 ok(IsWindowVisible(mdi_child), "MDI child should be visible\n");
3032 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3033 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3035 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3036 ok(!active_child, "wrong active MDI child %p\n", active_child);
3037 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
3039 ShowWindow(mdi_child, SW_HIDE);
3040 ok_sequence(WmHideChildSeq, "ShowWindow(SW_HIDE) MDI child window", FALSE);
3043 ShowWindow(mdi_child, SW_SHOW);
3044 ok_sequence(WmShowChildSeq, "ShowWindow(SW_SHOW) MDI child window", FALSE);
3046 ok(GetWindowLongA(mdi_child, GWL_STYLE) & WS_VISIBLE, "MDI child should be visible\n");
3047 ok(IsWindowVisible(mdi_child), "MDI child should be visible\n");
3049 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3050 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3052 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3053 ok(!active_child, "wrong active MDI child %p\n", active_child);
3054 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
3056 DestroyWindow(mdi_child);
3059 trace("creating visible MDI child window\n");
3060 mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
3061 WS_CHILD | WS_VISIBLE,
3062 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
3063 mdi_client, 0, GetModuleHandleA(0), NULL);
3065 ok_sequence(WmCreateMDIchildVisibleSeq, "Create visible MDI child window", FALSE);
3067 ok(GetWindowLongA(mdi_child, GWL_STYLE) & WS_VISIBLE, "MDI child should be visible\n");
3068 ok(IsWindowVisible(mdi_child), "MDI child should be visible\n");
3070 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3071 ok(GetFocus() == mdi_child, "wrong focus window %p\n", GetFocus());
3073 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3074 ok(active_child == mdi_child, "wrong active MDI child %p\n", active_child);
3075 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
3078 DestroyWindow(mdi_child);
3079 ok_sequence(WmDestroyMDIchildVisibleSeq, "Destroy visible MDI child window", TRUE);
3081 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3082 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3084 /* Win2k: MDI client still returns a just destroyed child as active
3085 * Win9x: MDI client returns 0
3087 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3088 ok(active_child == mdi_child || /* win2k */
3089 !active_child, /* win9x */
3090 "wrong active MDI child %p\n", active_child);
3091 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
3095 trace("creating invisible MDI child window\n");
3096 mdi_child2 = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
3098 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
3099 mdi_client, 0, GetModuleHandleA(0), NULL);
3101 ok_sequence(WmCreateMDIchildInvisibleSeq, "Create invisible MDI child window", FALSE);
3103 ok(!(GetWindowLongA(mdi_child2, GWL_STYLE) & WS_VISIBLE), "MDI child should not be visible\n");
3104 ok(!IsWindowVisible(mdi_child2), "MDI child should not be visible\n");
3106 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3107 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3109 /* Win2k: MDI client still returns a just destroyed child as active
3110 * Win9x: MDI client returns mdi_child2
3112 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3113 ok(active_child == mdi_child || /* win2k */
3114 active_child == mdi_child2, /* win9x */
3115 "wrong active MDI child %p\n", active_child);
3116 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
3119 ShowWindow(mdi_child2, SW_MAXIMIZE);
3120 ok_sequence(WmMaximizeMDIchildInvisibleSeq, "ShowWindow(SW_MAXIMIZE):invisible MDI child", FALSE);
3122 ok(GetWindowLongA(mdi_child2, GWL_STYLE) & WS_VISIBLE, "MDI child should be visible\n");
3123 ok(IsWindowVisible(mdi_child2), "MDI child should be visible\n");
3125 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3126 ok(active_child == mdi_child2, "wrong active MDI child %p\n", active_child);
3127 ok(zoomed, "wrong zoomed state %d\n", zoomed);
3130 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3131 ok(GetFocus() == mdi_child2 || /* win2k */
3132 GetFocus() == 0, /* win9x */
3133 "wrong focus window %p\n", GetFocus());
3138 ShowWindow(mdi_child2, SW_HIDE);
3139 ok_sequence(WmHideChildSeq, "ShowWindow(SW_HIDE):MDI child", FALSE);
3141 ShowWindow(mdi_child2, SW_RESTORE);
3142 ok_sequence(WmRestoreMDIchildInisibleSeq, "ShowWindow(SW_RESTORE):invisible MDI child", FALSE);
3145 ok(GetWindowLongA(mdi_child2, GWL_STYLE) & WS_VISIBLE, "MDI child should be visible\n");
3146 ok(IsWindowVisible(mdi_child2), "MDI child should be visible\n");
3148 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3149 ok(active_child == mdi_child2, "wrong active MDI child %p\n", active_child);
3150 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
3156 ShowWindow(mdi_child2, SW_HIDE);
3157 ok_sequence(WmHideChildSeq, "ShowWindow(SW_HIDE):MDI child", FALSE);
3159 ShowWindow(mdi_child2, SW_SHOW);
3160 ok_sequence(WmShowChildSeq, "ShowWindow(SW_SHOW):MDI child", FALSE);
3162 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3163 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3165 ShowWindow(mdi_child2, SW_MAXIMIZE);
3166 ok_sequence(WmMaximizeMDIchildVisibleSeq, "ShowWindow(SW_MAXIMIZE):MDI child", FALSE);
3168 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3169 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3171 ShowWindow(mdi_child2, SW_RESTORE);
3172 ok_sequence(WmRestoreMDIchildVisibleSeq, "ShowWindow(SW_RESTORE):maximized MDI child", FALSE);
3174 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3175 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3177 ShowWindow(mdi_child2, SW_MINIMIZE);
3178 ok_sequence(WmMinimizeMDIchildVisibleSeq, "ShowWindow(SW_MINIMIZE):MDI child", TRUE);
3180 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3181 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3183 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3184 ok(active_child == mdi_child2, "wrong active MDI child %p\n", active_child);
3185 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
3188 ShowWindow(mdi_child2, SW_RESTORE);
3189 ok_sequence(WmRestoreMDIchildVisibleSeq_2, "ShowWindow(SW_RESTORE):minimized MDI child", TRUE);
3191 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3192 ok(GetFocus() == mdi_child2, "wrong focus window %p\n", GetFocus());
3194 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3195 ok(active_child == mdi_child2, "wrong active MDI child %p\n", active_child);
3196 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
3202 ShowWindow(mdi_child2, SW_HIDE);
3203 ok_sequence(WmHideChildSeq, "ShowWindow(SW_HIDE):MDI child", FALSE);
3205 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3206 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3208 DestroyWindow(mdi_child2);
3209 ok_sequence(WmDestroyMDIchildInvisibleSeq, "Destroy invisible MDI child window", FALSE);
3211 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3212 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3214 /* test for maximized MDI children */
3215 trace("creating maximized visible MDI child window 1\n");
3216 mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
3217 WS_CHILD | WS_VISIBLE | WS_MAXIMIZEBOX | WS_MAXIMIZE,
3218 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
3219 mdi_client, 0, GetModuleHandleA(0), NULL);
3221 ok_sequence(WmCreateMDIchildVisibleMaxSeq1, "Create maximized visible 1st MDI child window", TRUE);
3222 ok(IsZoomed(mdi_child), "1st MDI child should be maximized\n");
3224 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3225 ok(GetFocus() == mdi_child || /* win2k */
3226 GetFocus() == 0, /* win9x */
3227 "wrong focus window %p\n", GetFocus());
3229 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3230 ok(active_child == mdi_child, "wrong active MDI child %p\n", active_child);
3231 ok(zoomed, "wrong zoomed state %d\n", zoomed);
3234 trace("creating maximized visible MDI child window 2\n");
3235 mdi_child2 = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
3236 WS_CHILD | WS_VISIBLE | WS_MAXIMIZEBOX | WS_MAXIMIZE,
3237 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
3238 mdi_client, 0, GetModuleHandleA(0), NULL);
3240 ok_sequence(WmCreateMDIchildVisibleMaxSeq2, "Create maximized visible 2nd MDI child 2 window", TRUE);
3241 ok(IsZoomed(mdi_child2), "2nd MDI child should be maximized\n");
3242 ok(!IsZoomed(mdi_child), "1st MDI child should NOT be maximized\n");
3244 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3245 ok(GetFocus() == mdi_child2, "wrong focus window %p\n", GetFocus());
3247 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3248 ok(active_child == mdi_child2, "wrong active MDI child %p\n", active_child);
3249 ok(zoomed, "wrong zoomed state %d\n", zoomed);
3252 trace("destroying maximized visible MDI child window 2\n");
3253 DestroyWindow(mdi_child2);
3254 ok_sequence(WmDestroyMDIchildVisibleSeq, "Destroy visible MDI child window", TRUE);
3256 ok(!IsZoomed(mdi_child), "1st MDI child should NOT be maximized\n");
3258 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3259 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3261 /* Win2k: MDI client still returns a just destroyed child as active
3262 * Win9x: MDI client returns 0
3264 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3265 ok(active_child == mdi_child2 || /* win2k */
3266 !active_child, /* win9x */
3267 "wrong active MDI child %p\n", active_child);
3270 ShowWindow(mdi_child, SW_MAXIMIZE);
3271 ok(IsZoomed(mdi_child), "1st MDI child should be maximized\n");
3274 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3275 ok(GetFocus() == mdi_child, "wrong focus window %p\n", GetFocus());
3277 trace("re-creating maximized visible MDI child window 2\n");
3278 mdi_child2 = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
3279 WS_CHILD | WS_VISIBLE | WS_MAXIMIZEBOX | WS_MAXIMIZE,
3280 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
3281 mdi_client, 0, GetModuleHandleA(0), NULL);
3283 ok_sequence(WmCreateMDIchildVisibleMaxSeq2, "Create maximized visible 2nd MDI child 2 window", TRUE);
3284 ok(IsZoomed(mdi_child2), "2nd MDI child should be maximized\n");
3285 ok(!IsZoomed(mdi_child), "1st MDI child should NOT be maximized\n");
3287 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3288 ok(GetFocus() == mdi_child2, "wrong focus window %p\n", GetFocus());
3290 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3291 ok(active_child == mdi_child2, "wrong active MDI child %p\n", active_child);
3292 ok(zoomed, "wrong zoomed state %d\n", zoomed);
3295 SendMessageA(mdi_child2, WM_SYSCOMMAND, SC_CLOSE, 0);
3296 ok_sequence(WmDestroyMDIchildVisibleMaxSeq2, "WM_SYSCOMMAND/SC_CLOSE on a visible maximized MDI child window", TRUE);
3297 ok(!IsWindow(mdi_child2), "MDI child 2 should be destroyed\n");
3299 ok(IsZoomed(mdi_child), "1st MDI child should be maximized\n");
3300 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3301 ok(GetFocus() == mdi_child, "wrong focus window %p\n", GetFocus());
3303 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3304 ok(active_child == mdi_child, "wrong active MDI child %p\n", active_child);
3305 ok(zoomed, "wrong zoomed state %d\n", zoomed);
3308 DestroyWindow(mdi_child);
3309 ok_sequence(WmDestroyMDIchildVisibleSeq, "Destroy visible MDI child window", TRUE);
3311 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3312 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3314 /* Win2k: MDI client still returns a just destroyed child as active
3315 * Win9x: MDI client returns 0
3317 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3318 ok(active_child == mdi_child || /* win2k */
3319 !active_child, /* win9x */
3320 "wrong active MDI child %p\n", active_child);
3323 trace("creating maximized invisible MDI child window\n");
3324 mdi_child2 = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
3325 WS_CHILD | WS_MAXIMIZE | WS_CAPTION | WS_THICKFRAME,
3326 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
3327 mdi_client, 0, GetModuleHandleA(0), NULL);
3329 ok_sequence(WmCreateMDIchildInvisibleMaxSeq4, "Create maximized invisible MDI child window", TRUE);
3330 ok(IsZoomed(mdi_child2), "MDI child should be maximized\n");
3331 ok(!(GetWindowLongA(mdi_child2, GWL_STYLE) & WS_VISIBLE), "MDI child should be not visible\n");
3332 ok(!IsWindowVisible(mdi_child2), "MDI child should be not visible\n");
3334 /* Win2k: MDI client still returns a just destroyed child as active
3335 * Win9x: MDI client returns 0
3337 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3338 ok(active_child == mdi_child || /* win2k */
3339 !active_child, /* win9x */
3340 "wrong active MDI child %p\n", active_child);
3343 trace("call ShowWindow(mdi_child, SW_MAXIMIZE)\n");
3344 ShowWindow(mdi_child2, SW_MAXIMIZE);
3345 ok_sequence(WmMaximizeMDIchildInvisibleSeq2, "ShowWindow(SW_MAXIMIZE):invisible maximized MDI child", FALSE);
3346 ok(IsZoomed(mdi_child2), "MDI child should be maximized\n");
3347 ok(GetWindowLongA(mdi_child2, GWL_STYLE) & WS_VISIBLE, "MDI child should be visible\n");
3348 ok(IsWindowVisible(mdi_child2), "MDI child should be visible\n");
3350 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3351 ok(active_child == mdi_child2, "wrong active MDI child %p\n", active_child);
3352 ok(zoomed, "wrong zoomed state %d\n", zoomed);
3355 SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child2, 0);
3358 /* end of test for maximized MDI children */
3361 trace("creating maximized visible MDI child window 1(Switch test)\n");
3362 mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
3363 WS_CHILD | WS_VISIBLE | WS_MAXIMIZEBOX | WS_MAXIMIZE,
3364 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
3365 mdi_client, 0, GetModuleHandleA(0), NULL);
3367 ok_sequence(WmCreateMDIchildVisibleMaxSeq1, "Create maximized visible 1st MDI child window(Switch test)", TRUE);
3368 ok(IsZoomed(mdi_child), "1st MDI child should be maximized(Switch test)\n");
3370 ok(GetActiveWindow() == mdi_frame, "wrong active window %p(Switch test)\n", GetActiveWindow());
3371 ok(GetFocus() == mdi_child || /* win2k */
3372 GetFocus() == 0, /* win9x */
3373 "wrong focus window %p(Switch test)\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(Switch test)\n", active_child);
3377 ok(zoomed, "wrong zoomed state %d(Switch test)\n", zoomed);
3380 trace("creating maximized visible MDI child window 2(Switch test)\n");
3381 mdi_child2 = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
3382 WS_CHILD | WS_VISIBLE | WS_MAXIMIZEBOX | WS_MAXIMIZE,
3383 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
3384 mdi_client, 0, GetModuleHandleA(0), NULL);
3386 ok_sequence(WmCreateMDIchildVisibleMaxSeq2, "Create maximized visible 2nd MDI child window (Switch test)", TRUE);
3388 ok(IsZoomed(mdi_child2), "2nd MDI child should be maximized(Switch test)\n");
3389 ok(!IsZoomed(mdi_child), "1st MDI child should NOT be maximized(Switch test)\n");
3391 ok(GetActiveWindow() == mdi_frame, "wrong active window %p(Switch test)\n", GetActiveWindow());
3392 ok(GetFocus() == mdi_child2, "wrong focus window %p(Switch test)\n", GetFocus());
3394 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3395 ok(active_child == mdi_child2, "wrong active MDI child %p(Switch test)\n", active_child);
3396 ok(zoomed, "wrong zoomed state %d(Switch test)\n", zoomed);
3399 trace("Switch child window.\n");
3400 SendMessageA(mdi_client, WM_MDIACTIVATE, (WPARAM)mdi_child, 0);
3401 ok_sequence(WmSwitchChild, "Child did not switch correctly", TRUE);
3402 trace("end of test for switch maximized MDI children\n");
3405 /* Prepare for switching test of not maximized MDI children */
3406 ShowWindow( mdi_child, SW_NORMAL );
3407 ok(!IsZoomed(mdi_child), "wrong zoomed state for %p(Switch test)\n", mdi_child);
3408 ok(!IsZoomed(mdi_child2), "wrong zoomed state for %p(Switch test)\n", mdi_child2);
3409 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, 0);
3410 ok(active_child == mdi_child, "wrong active MDI child %p(Switch test)\n", active_child);
3413 SendMessageA(mdi_client, WM_MDIACTIVATE, (WPARAM)mdi_child2, 0);
3414 ok_sequence(WmSwitchNotMaximizedChild, "Not maximized child did not switch correctly", FALSE);
3415 trace("end of test for switch not maximized MDI children\n");
3418 SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child, 0);
3421 SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child2, 0);
3426 /* end of tests for switch maximized/not maximized MDI children */
3428 mdi_cs.szClass = "MDI_child_Class";
3429 mdi_cs.szTitle = "MDI child";
3430 mdi_cs.hOwner = GetModuleHandleA(0);
3433 mdi_cs.cx = CW_USEDEFAULT;
3434 mdi_cs.cy = CW_USEDEFAULT;
3435 mdi_cs.style = WS_CHILD | WS_SYSMENU | WS_VISIBLE | WS_MAXIMIZEBOX | WS_MAXIMIZE;
3437 mdi_child = (HWND)SendMessageA(mdi_client, WM_MDICREATE, 0, (LPARAM)&mdi_cs);
3438 ok(mdi_child != 0, "MDI child creation failed\n");
3439 ok_sequence(WmCreateMDIchildVisibleMaxSeq3, "WM_MDICREATE for maximized visible MDI child window", TRUE);
3441 ok(GetMenuItemID(hMenu, GetMenuItemCount(hMenu) - 1) == SC_CLOSE, "SC_CLOSE menu item not found\n");
3443 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3444 ok(active_child == mdi_child, "wrong active MDI child %p\n", active_child);
3446 ok(IsZoomed(mdi_child), "MDI child should be maximized\n");
3447 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3448 ok(GetFocus() == mdi_child, "wrong focus window %p\n", GetFocus());
3450 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3451 ok(active_child == mdi_child, "wrong active MDI child %p\n", active_child);
3452 ok(zoomed, "wrong zoomed state %d\n", zoomed);
3455 SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child, 0);
3456 ok_sequence(WmDestroyMDIchildVisibleMaxSeq1, "Destroy visible maximized MDI child window", TRUE);
3458 ok(!IsWindow(mdi_child), "MDI child should be destroyed\n");
3459 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3460 ok(!active_child, "wrong active MDI child %p\n", active_child);
3465 DestroyWindow(mdi_client);
3466 ok_sequence(WmDestroyMDIclientSeq, "Destroy MDI client window", FALSE);
3468 /* test maximization of MDI child with invisible parent */
3469 client_cs.hWindowMenu = 0;
3470 mdi_client = CreateWindow("MDI_client_class",
3472 WS_CHILD | WS_CLIPCHILDREN | WS_VSCROLL | WS_HSCROLL | WS_VISIBLE,
3474 mdi_frame, 0, GetModuleHandleA(0), &client_cs);
3475 ok_sequence(WmCreateMDIclientSeq, "Create MDI client window", FALSE);
3477 ShowWindow(mdi_client, SW_HIDE);
3478 ok_sequence(WmHideMDIclientSeq, "Hide MDI client window", FALSE);
3480 mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
3481 WS_CHILD | WS_CLIPCHILDREN | WS_VSCROLL | WS_HSCROLL,
3483 mdi_client, 0, GetModuleHandleA(0), NULL);
3484 ok_sequence(WmCreateMDIchildInvisibleParentSeq, "Create MDI child window with invisible parent", FALSE);
3486 SendMessage(mdi_client, WM_MDIMAXIMIZE, (WPARAM) mdi_child, 0);
3487 ok_sequence(WmMaximizeMDIchildInvisibleParentSeq, "Maximize MDI child window with invisible parent", TRUE);
3488 zoomed = IsZoomed(mdi_child);
3489 ok(zoomed, "wrong zoomed state %d\n", zoomed);
3491 ShowWindow(mdi_client, SW_SHOW);
3492 ok_sequence(WmShowMDIclientSeq, "Show MDI client window", FALSE);
3494 DestroyWindow(mdi_child);
3495 ok_sequence(WmDestroyMDIchildVisibleSeq, "Destroy visible maximized MDI child window", TRUE);
3497 /* end of test for maximization of MDI child with invisible parent */
3499 DestroyWindow(mdi_client);
3500 ok_sequence(WmDestroyMDIclientSeq, "Destroy MDI client window", FALSE);
3502 DestroyWindow(mdi_frame);
3503 ok_sequence(WmDestroyMDIframeSeq, "Destroy MDI frame window", FALSE);
3505 /************************* End of MDI test **********************************/
3507 static void test_WM_SETREDRAW(HWND hwnd)
3509 DWORD style = GetWindowLongA(hwnd, GWL_STYLE);
3513 SendMessageA(hwnd, WM_SETREDRAW, FALSE, 0);
3514 ok_sequence(WmSetRedrawFalseSeq, "SetRedraw:FALSE", FALSE);
3516 ok(!(GetWindowLongA(hwnd, GWL_STYLE) & WS_VISIBLE), "WS_VISIBLE should NOT be set\n");
3517 ok(!IsWindowVisible(hwnd), "IsWindowVisible() should return FALSE\n");
3520 SendMessageA(hwnd, WM_SETREDRAW, TRUE, 0);
3521 ok_sequence(WmSetRedrawTrueSeq, "SetRedraw:TRUE", FALSE);
3523 ok(GetWindowLongA(hwnd, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
3524 ok(IsWindowVisible(hwnd), "IsWindowVisible() should return TRUE\n");
3526 /* restore original WS_VISIBLE state */
3527 SetWindowLongA(hwnd, GWL_STYLE, style);
3532 static INT_PTR CALLBACK TestModalDlgProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
3536 trace("dialog: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
3538 /* explicitly ignore WM_GETICON message */
3539 if (message == WM_GETICON) return 0;
3546 case WM_DEVICECHANGE:
3551 case WM_WINDOWPOSCHANGING:
3552 case WM_WINDOWPOSCHANGED:
3554 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
3556 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
3557 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
3558 winpos->hwnd, winpos->hwndInsertAfter,
3559 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
3560 dump_winpos_flags(winpos->flags);
3562 /* Log only documented flags, win2k uses 0x1000 and 0x2000
3563 * in the high word for internal purposes
3565 wParam = winpos->flags & 0xffff;
3566 /* We are not interested in the flags that don't match under XP and Win9x */
3567 wParam &= ~(SWP_NOZORDER);
3572 msg.message = message;
3573 msg.flags = sent|wparam|lparam;
3574 msg.wParam = wParam;
3575 msg.lParam = lParam;
3578 if (message == WM_INITDIALOG) SetTimer( hwnd, 1, 100, NULL );
3579 if (message == WM_TIMER) EndDialog( hwnd, 0 );
3583 static void test_hv_scroll_1(HWND hwnd, INT ctl, DWORD clear, DWORD set, INT min, INT max)
3585 DWORD style, exstyle;
3589 exstyle = GetWindowLongA(hwnd, GWL_EXSTYLE);
3590 style = GetWindowLongA(hwnd, GWL_STYLE);
3591 /* do not be confused by WS_DLGFRAME set */
3592 if ((style & WS_CAPTION) == WS_CAPTION) style &= ~WS_CAPTION;
3594 if (clear) ok(style & clear, "style %08x should be set\n", clear);
3595 if (set) ok(!(style & set), "style %08x should not be set\n", set);
3597 ret = SetScrollRange(hwnd, ctl, min, max, FALSE);
3598 ok( ret, "SetScrollRange(%d) error %d\n", ctl, GetLastError());
3599 if ((style & (WS_DLGFRAME | WS_BORDER | WS_THICKFRAME)) || (exstyle & WS_EX_DLGMODALFRAME))
3600 ok_sequence(WmSetScrollRangeHV_NC_Seq, "SetScrollRange(SB_HORZ/SB_VERT) NC", FALSE);
3602 ok_sequence(WmSetScrollRangeHVSeq, "SetScrollRange(SB_HORZ/SB_VERT)", FALSE);
3604 style = GetWindowLongA(hwnd, GWL_STYLE);
3605 if (set) ok(style & set, "style %08x should be set\n", set);
3606 if (clear) ok(!(style & clear), "style %08x should not be set\n", clear);
3608 /* a subsequent call should do nothing */
3609 ret = SetScrollRange(hwnd, ctl, min, max, FALSE);
3610 ok( ret, "SetScrollRange(%d) error %d\n", ctl, GetLastError());
3611 ok_sequence(WmEmptySeq, "SetScrollRange(SB_HORZ/SB_VERT) empty sequence", FALSE);
3615 trace("Ignore GetScrollRange error below if you are on Win9x\n");
3616 ret = GetScrollRange(hwnd, ctl, &xmin, &xmax);
3617 ok( ret, "GetScrollRange(%d) error %d\n", ctl, GetLastError());
3618 ok_sequence(WmEmptySeq, "GetScrollRange(SB_HORZ/SB_VERT) empty sequence", FALSE);
3619 ok(xmin == min, "unexpected min scroll value %d\n", xmin);
3620 ok(xmax == max, "unexpected max scroll value %d\n", xmax);
3623 static void test_hv_scroll_2(HWND hwnd, INT ctl, DWORD clear, DWORD set, INT min, INT max)
3625 DWORD style, exstyle;
3629 exstyle = GetWindowLongA(hwnd, GWL_EXSTYLE);
3630 style = GetWindowLongA(hwnd, GWL_STYLE);
3631 /* do not be confused by WS_DLGFRAME set */
3632 if ((style & WS_CAPTION) == WS_CAPTION) style &= ~WS_CAPTION;
3634 if (clear) ok(style & clear, "style %08x should be set\n", clear);
3635 if (set) ok(!(style & set), "style %08x should not be set\n", set);
3637 si.cbSize = sizeof(si);
3638 si.fMask = SIF_RANGE;
3641 SetScrollInfo(hwnd, ctl, &si, TRUE);
3642 if ((style & (WS_DLGFRAME | WS_BORDER | WS_THICKFRAME)) || (exstyle & WS_EX_DLGMODALFRAME))
3643 ok_sequence(WmSetScrollRangeHV_NC_Seq, "SetScrollInfo(SB_HORZ/SB_VERT) NC", FALSE);
3645 ok_sequence(WmSetScrollRangeHVSeq, "SetScrollInfo(SB_HORZ/SB_VERT)", FALSE);
3647 style = GetWindowLongA(hwnd, GWL_STYLE);
3648 if (set) ok(style & set, "style %08x should be set\n", set);
3649 if (clear) ok(!(style & clear), "style %08x should not be set\n", clear);
3651 /* a subsequent call should do nothing */
3652 SetScrollInfo(hwnd, ctl, &si, TRUE);
3653 if (style & WS_HSCROLL)
3654 ok_sequence(WmSetScrollRangeHSeq_empty, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE);
3655 else if (style & WS_VSCROLL)
3656 ok_sequence(WmSetScrollRangeVSeq_empty, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE);
3658 ok_sequence(WmEmptySeq, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE);
3660 si.fMask = SIF_PAGE;
3662 SetScrollInfo(hwnd, ctl, &si, FALSE);
3663 ok_sequence(WmEmptySeq, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE);
3667 SetScrollInfo(hwnd, ctl, &si, FALSE);
3668 ok_sequence(WmEmptySeq, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE);
3670 si.fMask = SIF_RANGE;
3671 si.nMin = 0xdeadbeef;
3672 si.nMax = 0xdeadbeef;
3673 ret = GetScrollInfo(hwnd, ctl, &si);
3674 ok( ret, "GetScrollInfo error %d\n", GetLastError());
3675 ok_sequence(WmEmptySeq, "GetScrollRange(SB_HORZ/SB_VERT) empty sequence", FALSE);
3676 ok(si.nMin == min, "unexpected min scroll value %d\n", si.nMin);
3677 ok(si.nMax == max, "unexpected max scroll value %d\n", si.nMax);
3680 /* Win9x sends WM_USER+xxx while and NT versions send SBM_xxx messages */
3681 static void test_scroll_messages(HWND hwnd)
3689 ret = GetScrollRange(hwnd, SB_CTL, &min, &max);
3690 ok( ret, "GetScrollRange error %d\n", GetLastError());
3691 if (sequence->message != WmGetScrollRangeSeq[0].message)
3692 trace("GetScrollRange(SB_CTL) generated unknown message %04x\n", sequence->message);
3693 /* values of min and max are undefined */
3696 ret = SetScrollRange(hwnd, SB_CTL, 10, 150, FALSE);
3697 ok( ret, "SetScrollRange error %d\n", GetLastError());
3698 if (sequence->message != WmSetScrollRangeSeq[0].message)
3699 trace("SetScrollRange(SB_CTL) generated unknown message %04x\n", sequence->message);
3704 ret = GetScrollRange(hwnd, SB_CTL, &min, &max);
3705 ok( ret, "GetScrollRange error %d\n", GetLastError());
3706 if (sequence->message != WmGetScrollRangeSeq[0].message)
3707 trace("GetScrollRange(SB_CTL) generated unknown message %04x\n", sequence->message);
3708 /* values of min and max are undefined */
3711 si.cbSize = sizeof(si);
3712 si.fMask = SIF_RANGE;
3715 SetScrollInfo(hwnd, SB_CTL, &si, FALSE);
3716 if (sequence->message != WmSetScrollRangeSeq[0].message)
3717 trace("SetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence->message);
3720 si.fMask = SIF_PAGE;
3722 SetScrollInfo(hwnd, SB_CTL, &si, FALSE);
3723 if (sequence->message != WmSetScrollRangeSeq[0].message)
3724 trace("SetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence->message);
3729 SetScrollInfo(hwnd, SB_CTL, &si, FALSE);
3730 if (sequence->message != WmSetScrollRangeSeq[0].message)
3731 trace("SetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence->message);
3734 si.fMask = SIF_RANGE;
3735 si.nMin = 0xdeadbeef;
3736 si.nMax = 0xdeadbeef;
3737 ret = GetScrollInfo(hwnd, SB_CTL, &si);
3738 ok( ret, "GetScrollInfo error %d\n", GetLastError());
3739 if (sequence->message != WmGetScrollInfoSeq[0].message)
3740 trace("GetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence->message);
3741 /* values of min and max are undefined */
3744 /* set WS_HSCROLL */
3745 test_hv_scroll_1(hwnd, SB_HORZ, 0, WS_HSCROLL, 10, 150);
3746 /* clear WS_HSCROLL */
3747 test_hv_scroll_1(hwnd, SB_HORZ, WS_HSCROLL, 0, 0, 0);
3749 /* set WS_HSCROLL */
3750 test_hv_scroll_2(hwnd, SB_HORZ, 0, WS_HSCROLL, 10, 150);
3751 /* clear WS_HSCROLL */
3752 test_hv_scroll_2(hwnd, SB_HORZ, WS_HSCROLL, 0, 0, 0);
3754 /* set WS_VSCROLL */
3755 test_hv_scroll_1(hwnd, SB_VERT, 0, WS_VSCROLL, 10, 150);
3756 /* clear WS_VSCROLL */
3757 test_hv_scroll_1(hwnd, SB_VERT, WS_VSCROLL, 0, 0, 0);
3759 /* set WS_VSCROLL */
3760 test_hv_scroll_2(hwnd, SB_VERT, 0, WS_VSCROLL, 10, 150);
3761 /* clear WS_VSCROLL */
3762 test_hv_scroll_2(hwnd, SB_VERT, WS_VSCROLL, 0, 0, 0);
3765 static void test_showwindow(void)
3770 hwnd = CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW,
3771 100, 100, 200, 200, 0, 0, 0, NULL);
3772 ok (hwnd != 0, "Failed to create overlapped window\n");
3773 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
3774 0, 0, 10, 10, hwnd, 0, 0, NULL);
3775 ok (hchild != 0, "Failed to create child\n");
3778 /* ShowWindow( SW_SHOWNA) for invisible top level window */
3779 trace("calling ShowWindow( SW_SHOWNA) for invisible top level window\n");
3780 ok( ShowWindow(hwnd, SW_SHOWNA) == FALSE, "ShowWindow: window was visible\n" );
3781 ok_sequence(WmSHOWNATopInvisible, "ShowWindow(SW_SHOWNA) on invisible top level window", TRUE);
3784 /* ShowWindow( SW_SHOWNA) for now visible top level window */
3785 trace("calling ShowWindow( SW_SHOWNA) for now visible top level window\n");
3786 ok( ShowWindow(hwnd, SW_SHOWNA) != FALSE, "ShowWindow: window was invisible\n" );
3787 ok_sequence(WmSHOWNATopVisible, "ShowWindow(SW_SHOWNA) on visible top level window", FALSE);
3789 /* back to invisible */
3790 ShowWindow(hchild, SW_HIDE);
3791 ShowWindow(hwnd, SW_HIDE);
3793 /* ShowWindow(SW_SHOWNA) with child and parent invisible */
3794 trace("calling ShowWindow( SW_SHOWNA) for invisible child with invisible parent\n");
3795 ok( ShowWindow(hchild, SW_SHOWNA) == FALSE, "ShowWindow: window was visible\n" );
3796 ok_sequence(WmSHOWNAChildInvisParInvis, "ShowWindow(SW_SHOWNA) invisible child and parent", FALSE);
3798 /* ShowWindow(SW_SHOWNA) with child visible and parent invisible */
3799 ok( ShowWindow(hchild, SW_SHOW) != FALSE, "ShowWindow: window was invisible\n" );
3801 trace("calling ShowWindow( SW_SHOWNA) for the visible child and invisible parent\n");
3802 ok( ShowWindow(hchild, SW_SHOWNA) != FALSE, "ShowWindow: window was invisible\n" );
3803 ok_sequence(WmSHOWNAChildVisParInvis, "ShowWindow(SW_SHOWNA) visible child and invisible parent", FALSE);
3805 /* ShowWindow(SW_SHOWNA) with child visible and parent visible */
3806 ShowWindow( hwnd, SW_SHOW);
3808 trace("calling ShowWindow( SW_SHOWNA) for the visible child and parent\n");
3809 ok( ShowWindow(hchild, SW_SHOWNA) != FALSE, "ShowWindow: window was invisible\n" );
3810 ok_sequence(WmSHOWNAChildVisParVis, "ShowWindow(SW_SHOWNA) for the visible child and parent", FALSE);
3813 /* ShowWindow(SW_SHOWNA) with child invisible and parent visible */
3814 ShowWindow( hchild, SW_HIDE);
3816 trace("calling ShowWindow( SW_SHOWNA) for the invisible child and visible parent\n");
3817 ok( ShowWindow(hchild, SW_SHOWNA) == FALSE, "ShowWindow: window was visible\n" );
3818 ok_sequence(WmSHOWNAChildInvisParVis, "ShowWindow(SW_SHOWNA) for the invisible child and visible parent", FALSE);
3822 ok(GetCapture() == hchild, "wrong capture window %p\n", GetCapture());
3823 DestroyWindow(hchild);
3824 ok(!GetCapture(), "wrong capture window %p\n", GetCapture());
3826 DestroyWindow(hwnd);
3831 * 1. Create invisible maximized popup window.
3832 * 2. Move and resize it.
3833 * 3. Show it maximized.
3835 trace("calling CreateWindowExA( WS_MAXIMIZE ) for invisible maximized popup window\n");
3836 hwnd = CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP | WS_MAXIMIZE,
3837 100, 100, 200, 200, 0, 0, 0, NULL);
3838 ok (hwnd != 0, "Failed to create popup window\n");
3839 ok(IsZoomed(hwnd), "window should be maximized\n");
3840 ok_sequence(WmCreateInvisibleMaxPopupSeq, "CreateWindow(WS_MAXIMIZED):popup", FALSE);
3843 GetWindowRect(hwnd, &rc);
3844 ok( rc.right-rc.left == GetSystemMetrics(SM_CXSCREEN) &&
3845 rc.bottom-rc.top == GetSystemMetrics(SM_CYSCREEN),
3846 "Invalid maximized size before ShowWindow (%d,%d)-(%d,%d)\n",
3847 rc.left, rc.top, rc.right, rc.bottom);
3848 /* Reset window's size & position */
3849 SetWindowPos(hwnd, 0, 10, 10, 200, 200, SWP_NOZORDER | SWP_NOACTIVATE);
3850 ok(IsZoomed(hwnd), "window should be maximized\n");
3853 trace("calling ShowWindow( SW_SHOWMAXIMIZE ) for invisible maximized popup window\n");
3854 ShowWindow(hwnd, SW_SHOWMAXIMIZED);
3855 ok(IsZoomed(hwnd), "window should be maximized\n");
3856 ok_sequence(WmShowMaxPopupResizedSeq, "ShowWindow(SW_SHOWMAXIMIZED):invisible maximized and resized popup", FALSE);
3859 GetWindowRect(hwnd, &rc);
3860 ok( rc.right-rc.left == GetSystemMetrics(SM_CXSCREEN) &&
3861 rc.bottom-rc.top == GetSystemMetrics(SM_CYSCREEN),
3862 "Invalid maximized size after ShowWindow (%d,%d)-(%d,%d)\n",
3863 rc.left, rc.top, rc.right, rc.bottom);
3864 DestroyWindow(hwnd);
3868 * 1. Create invisible maximized popup window.
3869 * 2. Show it maximized.
3871 trace("calling CreateWindowExA( WS_MAXIMIZE ) for invisible maximized popup window\n");
3872 hwnd = CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP | WS_MAXIMIZE,
3873 100, 100, 200, 200, 0, 0, 0, NULL);
3874 ok (hwnd != 0, "Failed to create popup window\n");
3875 ok(IsZoomed(hwnd), "window should be maximized\n");
3876 ok_sequence(WmCreateInvisibleMaxPopupSeq, "CreateWindow(WS_MAXIMIZED):popup", FALSE);
3879 trace("calling ShowWindow( SW_SHOWMAXIMIZE ) for invisible maximized popup window\n");
3880 ShowWindow(hwnd, SW_SHOWMAXIMIZED);
3881 ok(IsZoomed(hwnd), "window should be maximized\n");
3882 ok_sequence(WmShowMaxPopupSeq, "ShowWindow(SW_SHOWMAXIMIZED):invisible maximized popup", FALSE);
3884 DestroyWindow(hwnd);
3888 * 1. Create visible maximized popup window.
3890 trace("calling CreateWindowExA( WS_MAXIMIZE ) for maximized popup window\n");
3891 hwnd = CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP | WS_MAXIMIZE | WS_VISIBLE,
3892 100, 100, 200, 200, 0, 0, 0, NULL);
3893 ok (hwnd != 0, "Failed to create popup window\n");
3894 ok(IsZoomed(hwnd), "window should be maximized\n");
3895 ok_sequence(WmCreateMaxPopupSeq, "CreateWindow(WS_MAXIMIZED):popup", FALSE);
3897 DestroyWindow(hwnd);
3901 * 1. Create visible popup window.
3904 trace("calling CreateWindowExA( WS_VISIBLE ) for popup window\n");
3905 hwnd = CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP | WS_VISIBLE,
3906 100, 100, 200, 200, 0, 0, 0, NULL);
3907 ok (hwnd != 0, "Failed to create popup window\n");
3908 ok(!IsZoomed(hwnd), "window should NOT be maximized\n");
3909 ok_sequence(WmCreatePopupSeq, "CreateWindow(WS_VISIBLE):popup", FALSE);
3912 trace("calling ShowWindow( SW_SHOWMAXIMIZE ) for visible popup window\n");
3913 ShowWindow(hwnd, SW_SHOWMAXIMIZED);
3914 ok(IsZoomed(hwnd), "window should be maximized\n");
3915 ok_sequence(WmShowVisMaxPopupSeq, "ShowWindow(SW_SHOWMAXIMIZED):popup", FALSE);
3917 DestroyWindow(hwnd);
3921 static void test_sys_menu(void)
3927 hwnd = CreateWindowExA(0, "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW,
3928 100, 100, 200, 200, 0, 0, 0, NULL);
3929 ok (hwnd != 0, "Failed to create overlapped window\n");
3933 /* test existing window without CS_NOCLOSE style */
3934 hmenu = GetSystemMenu(hwnd, FALSE);
3935 ok(hmenu != 0, "GetSystemMenu error %d\n", GetLastError());
3937 state = GetMenuState(hmenu, SC_CLOSE, MF_BYCOMMAND);
3938 ok(state != 0xffffffff, "wrong SC_CLOSE state %x\n", state);
3939 ok(!(state & (MF_DISABLED | MF_GRAYED)), "wrong SC_CLOSE state %x\n", state);
3941 EnableMenuItem(hmenu, SC_CLOSE, MF_BYCOMMAND | MF_GRAYED);
3942 ok_sequence(WmEmptySeq, "WmEnableMenuItem", FALSE);
3944 state = GetMenuState(hmenu, SC_CLOSE, MF_BYCOMMAND);
3945 ok(state != 0xffffffff, "wrong SC_CLOSE state %x\n", state);
3946 ok((state & (MF_DISABLED | MF_GRAYED)) == MF_GRAYED, "wrong SC_CLOSE state %x\n", state);
3948 EnableMenuItem(hmenu, SC_CLOSE, 0);
3949 ok_sequence(WmEmptySeq, "WmEnableMenuItem", FALSE);
3951 state = GetMenuState(hmenu, SC_CLOSE, MF_BYCOMMAND);
3952 ok(state != 0xffffffff, "wrong SC_CLOSE state %x\n", state);
3953 ok(!(state & (MF_DISABLED | MF_GRAYED)), "wrong SC_CLOSE state %x\n", state);
3955 /* test whether removing WS_SYSMENU destroys a system menu */
3956 SetWindowLongW(hwnd, GWL_STYLE, WS_POPUP);
3957 SetWindowPos(hwnd, 0, 0, 0, 0, 0, SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_FRAMECHANGED);
3959 hmenu = GetSystemMenu(hwnd, FALSE);
3960 ok(hmenu != 0, "GetSystemMenu error %d\n", GetLastError());
3962 DestroyWindow(hwnd);
3964 /* test new window with CS_NOCLOSE style */
3965 hwnd = CreateWindowExA(0, "NoCloseWindowClass", NULL, WS_OVERLAPPEDWINDOW,
3966 100, 100, 200, 200, 0, 0, 0, NULL);
3967 ok (hwnd != 0, "Failed to create overlapped window\n");
3969 hmenu = GetSystemMenu(hwnd, FALSE);
3970 ok(hmenu != 0, "GetSystemMenu error %d\n", GetLastError());
3972 state = GetMenuState(hmenu, SC_CLOSE, MF_BYCOMMAND);
3973 ok(state == 0xffffffff, "wrong SC_CLOSE state %x\n", state);
3975 DestroyWindow(hwnd);
3977 /* test new window without WS_SYSMENU style */
3978 hwnd = CreateWindowExA(0, "NoCloseWindowClass", NULL, WS_OVERLAPPEDWINDOW & ~WS_SYSMENU,
3979 100, 100, 200, 200, 0, 0, 0, NULL);
3980 ok(hwnd != 0, "Failed to create overlapped window\n");
3982 hmenu = GetSystemMenu(hwnd, FALSE);
3983 ok(!hmenu, "GetSystemMenu error %d\n", GetLastError());
3985 DestroyWindow(hwnd);
3988 /* For shown WS_OVERLAPPEDWINDOW */
3989 static const struct message WmSetIcon_1[] = {
3990 { WM_SETICON, sent },
3991 { 0x00AE, sent|defwinproc|optional }, /* XP */
3992 { WM_GETTEXT, sent|defwinproc|optional },
3993 { WM_GETTEXT, sent|defwinproc|optional }, /* XP sends a duplicate */
3997 /* For WS_POPUP and hidden WS_OVERLAPPEDWINDOW */
3998 static const struct message WmSetIcon_2[] = {
3999 { WM_SETICON, sent },
4003 /* Sending undocumented 0x3B message with wparam = 0x8000000b */
4004 static const struct message WmInitEndSession[] = {
4006 { WM_QUERYENDSESSION, sent|defwinproc|wparam|lparam, 0, ENDSESSION_LOGOFF },
4010 /* Sending undocumented 0x3B message with wparam = 0x0000000b */
4011 static const struct message WmInitEndSession_2[] = {
4013 { WM_QUERYENDSESSION, sent|defwinproc|wparam|lparam, 0, 0 },
4017 /* Sending undocumented 0x3B message with wparam = 0x80000008 */
4018 static const struct message WmInitEndSession_3[] = {
4020 { WM_ENDSESSION, sent|defwinproc|wparam|lparam, 0, ENDSESSION_LOGOFF },
4024 /* Sending undocumented 0x3B message with wparam = 0x00000008 */
4025 static const struct message WmInitEndSession_4[] = {
4027 { WM_ENDSESSION, sent|defwinproc|wparam|lparam, 0, 0 },
4031 /* Sending undocumented 0x3B message with wparam = 0x80000001 */
4032 static const struct message WmInitEndSession_5[] = {
4034 { WM_ENDSESSION, sent|defwinproc|wparam|lparam, 1, ENDSESSION_LOGOFF },
4038 static void test_MsgWaitForMultipleObjects(HWND hwnd)
4043 ret = MsgWaitForMultipleObjects(0, NULL, FALSE, 0, QS_POSTMESSAGE);
4044 ok(ret == WAIT_TIMEOUT, "MsgWaitForMultipleObjects returned %x\n", ret);
4046 PostMessageA(hwnd, WM_USER, 0, 0);
4048 ret = MsgWaitForMultipleObjects(0, NULL, FALSE, 0, QS_POSTMESSAGE);
4049 ok(ret == WAIT_OBJECT_0, "MsgWaitForMultipleObjects returned %x\n", ret);
4051 ok(PeekMessageW( &msg, 0, 0, 0, PM_REMOVE ), "PeekMessage should succeed\n");
4052 ok(msg.message == WM_USER, "got %04x instead of WM_USER\n", msg.message);
4054 ret = MsgWaitForMultipleObjects(0, NULL, FALSE, 0, QS_POSTMESSAGE);
4055 ok(ret == WAIT_TIMEOUT, "MsgWaitForMultipleObjects returned %x\n", ret);
4057 PostMessageA(hwnd, WM_USER, 0, 0);
4059 ret = MsgWaitForMultipleObjects(0, NULL, FALSE, 0, QS_POSTMESSAGE);
4060 ok(ret == WAIT_OBJECT_0, "MsgWaitForMultipleObjects returned %x\n", ret);
4062 ok(PeekMessageW( &msg, 0, 0, 0, PM_NOREMOVE ), "PeekMessage should succeed\n");
4063 ok(msg.message == WM_USER, "got %04x instead of WM_USER\n", msg.message);
4065 /* shows QS_POSTMESSAGE flag is cleared in the PeekMessage call */
4066 ret = MsgWaitForMultipleObjects(0, NULL, FALSE, 0, QS_POSTMESSAGE);
4067 ok(ret == WAIT_TIMEOUT, "MsgWaitForMultipleObjects returned %x\n", ret);
4069 PostMessageA(hwnd, WM_USER, 0, 0);
4071 /* new incoming message causes it to become signaled again */
4072 ret = MsgWaitForMultipleObjects(0, NULL, FALSE, 0, QS_POSTMESSAGE);
4073 ok(ret == WAIT_OBJECT_0, "MsgWaitForMultipleObjects returned %x\n", ret);
4075 ok(PeekMessageW( &msg, 0, 0, 0, PM_REMOVE ), "PeekMessage should succeed\n");
4076 ok(msg.message == WM_USER, "got %04x instead of WM_USER\n", msg.message);
4077 ok(PeekMessageW( &msg, 0, 0, 0, PM_REMOVE ), "PeekMessage should succeed\n");
4078 ok(msg.message == WM_USER, "got %04x instead of WM_USER\n", msg.message);
4081 /* test if we receive the right sequence of messages */
4082 static void test_messages(void)
4084 HWND hwnd, hparent, hchild;
4085 HWND hchild2, hbutton;
4092 hwnd = CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW,
4093 100, 100, 200, 200, 0, 0, 0, NULL);
4094 ok (hwnd != 0, "Failed to create overlapped window\n");
4095 ok_sequence(WmCreateOverlappedSeq, "CreateWindow:overlapped", FALSE);
4097 /* test ShowWindow(SW_HIDE) on a newly created invisible window */
4098 ok( ShowWindow(hwnd, SW_HIDE) == FALSE, "ShowWindow: window was visible\n" );
4099 ok_sequence(WmEmptySeq, "ShowWindow(SW_HIDE):overlapped, invisible", FALSE);
4101 /* test WM_SETREDRAW on a not visible top level window */
4102 test_WM_SETREDRAW(hwnd);
4104 SetWindowPos(hwnd, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE);
4105 ok_sequence(WmSWP_ShowOverlappedSeq, "SetWindowPos:SWP_SHOWWINDOW:overlapped", FALSE);
4106 ok(IsWindowVisible(hwnd), "window should be visible at this point\n");
4108 ok(GetActiveWindow() == hwnd, "window should be active\n");
4109 ok(GetFocus() == hwnd, "window should have input focus\n");
4110 ShowWindow(hwnd, SW_HIDE);
4111 ok_sequence(WmHideOverlappedSeq, "ShowWindow(SW_HIDE):overlapped", TRUE);
4113 ShowWindow(hwnd, SW_SHOW);
4114 ok_sequence(WmShowOverlappedSeq, "ShowWindow(SW_SHOW):overlapped", TRUE);
4116 ShowWindow(hwnd, SW_HIDE);
4117 ok_sequence(WmHideOverlappedSeq, "ShowWindow(SW_HIDE):overlapped", FALSE);
4119 ShowWindow(hwnd, SW_SHOWMAXIMIZED);
4120 ok_sequence(WmShowMaxOverlappedSeq, "ShowWindow(SW_SHOWMAXIMIZED):overlapped", TRUE);
4122 ShowWindow(hwnd, SW_RESTORE);
4123 /* FIXME: add ok_sequence() here */
4126 ShowWindow(hwnd, SW_MINIMIZE);
4127 ok_sequence(WmShowMinOverlappedSeq, "ShowWindow(SW_SHOWMINIMIZED):overlapped", TRUE);
4130 ShowWindow(hwnd, SW_RESTORE);
4131 /* FIXME: add ok_sequence() here */
4134 ShowWindow(hwnd, SW_SHOW);
4135 ok_sequence(WmEmptySeq, "ShowWindow(SW_SHOW):overlapped already visible", FALSE);
4137 ok(GetActiveWindow() == hwnd, "window should be active\n");
4138 ok(GetFocus() == hwnd, "window should have input focus\n");
4139 SetWindowPos(hwnd, 0,0,0,0,0, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE);
4140 ok_sequence(WmSWP_HideOverlappedSeq, "SetWindowPos:SWP_HIDEWINDOW:overlapped", FALSE);
4141 ok(!IsWindowVisible(hwnd), "window should not be visible at this point\n");
4142 ok(GetActiveWindow() == hwnd, "window should still be active\n");
4144 /* test WM_SETREDRAW on a visible top level window */
4145 ShowWindow(hwnd, SW_SHOW);
4146 test_WM_SETREDRAW(hwnd);
4148 trace("testing scroll APIs on a visible top level window %p\n", hwnd);
4149 test_scroll_messages(hwnd);
4151 /* test resizing and moving */
4152 SetWindowPos( hwnd, 0, 0, 0, 300, 300, SWP_NOMOVE|SWP_NOACTIVATE );
4153 ok_sequence(WmSWP_ResizeSeq, "SetWindowPos:Resize", FALSE );
4156 SetWindowPos( hwnd, 0, 200, 200, 0, 0, SWP_NOSIZE|SWP_NOACTIVATE );
4157 ok_sequence(WmSWP_MoveSeq, "SetWindowPos:Move", FALSE );
4160 SetWindowPos( hwnd, 0, 200, 200, 250, 250, SWP_NOZORDER );
4161 ok_sequence(WmSWP_ResizeNoZOrder, "SetWindowPos:WmSWP_ResizeNoZOrder", FALSE );
4165 /* popups don't get WM_GETMINMAXINFO */
4166 SetWindowLongW( hwnd, GWL_STYLE, WS_VISIBLE|WS_POPUP );
4167 SetWindowPos( hwnd, 0, 0, 0, 0, 0, SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_FRAMECHANGED);
4169 SetWindowPos( hwnd, 0, 0, 0, 200, 200, SWP_NOMOVE|SWP_NOACTIVATE );
4170 ok_sequence(WmSWP_ResizePopupSeq, "SetWindowPos:ResizePopup", FALSE );
4172 DestroyWindow(hwnd);
4173 ok_sequence(WmDestroyOverlappedSeq, "DestroyWindow:overlapped", FALSE);
4175 hparent = CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
4176 100, 100, 200, 200, 0, 0, 0, NULL);
4177 ok (hparent != 0, "Failed to create parent window\n");
4180 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD | WS_MAXIMIZE,
4181 0, 0, 10, 10, hparent, 0, 0, NULL);
4182 ok (hchild != 0, "Failed to create child window\n");
4183 ok_sequence(WmCreateMaximizedChildSeq, "CreateWindow:maximized child", FALSE);
4184 DestroyWindow(hchild);
4187 /* visible child window with a caption */
4188 hchild = CreateWindowExA(0, "TestWindowClass", "Test child",
4189 WS_CHILD | WS_VISIBLE | WS_CAPTION,
4190 0, 0, 10, 10, hparent, 0, 0, NULL);
4191 ok (hchild != 0, "Failed to create child window\n");
4192 ok_sequence(WmCreateVisibleChildSeq, "CreateWindow:visible child", FALSE);
4194 trace("testing scroll APIs on a visible child window %p\n", hchild);
4195 test_scroll_messages(hchild);
4197 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE);
4198 ok_sequence(WmShowChildSeq_4, "SetWindowPos(SWP_SHOWWINDOW):child with a caption", FALSE);
4200 DestroyWindow(hchild);
4203 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
4204 0, 0, 10, 10, hparent, 0, 0, NULL);
4205 ok (hchild != 0, "Failed to create child window\n");
4206 ok_sequence(WmCreateChildSeq, "CreateWindow:child", FALSE);
4208 hchild2 = CreateWindowExA(0, "SimpleWindowClass", "Test child2", WS_CHILD,
4209 100, 100, 50, 50, hparent, 0, 0, NULL);
4210 ok (hchild2 != 0, "Failed to create child2 window\n");
4213 hbutton = CreateWindowExA(0, "TestWindowClass", "Test button", WS_CHILD,
4214 0, 100, 50, 50, hchild, 0, 0, NULL);
4215 ok (hbutton != 0, "Failed to create button window\n");
4217 /* test WM_SETREDRAW on a not visible child window */
4218 test_WM_SETREDRAW(hchild);
4220 ShowWindow(hchild, SW_SHOW);
4221 ok_sequence(WmShowChildSeq, "ShowWindow(SW_SHOW):child", FALSE);
4223 /* check parent messages too */
4224 log_all_parent_messages++;
4225 ShowWindow(hchild, SW_HIDE);
4226 ok_sequence(WmHideChildSeq2, "ShowWindow(SW_HIDE):child", FALSE);
4227 log_all_parent_messages--;
4229 ShowWindow(hchild, SW_SHOW);
4230 ok_sequence(WmShowChildSeq, "ShowWindow(SW_SHOW):child", FALSE);
4232 ShowWindow(hchild, SW_HIDE);
4233 ok_sequence(WmHideChildSeq, "ShowWindow(SW_HIDE):child", FALSE);
4235 ShowWindow(hchild, SW_SHOW);
4236 ok_sequence(WmShowChildSeq, "ShowWindow(SW_SHOW):child", FALSE);
4238 /* test WM_SETREDRAW on a visible child window */
4239 test_WM_SETREDRAW(hchild);
4241 log_all_parent_messages++;
4242 MoveWindow(hchild, 10, 10, 20, 20, TRUE);
4243 ok_sequence(WmResizingChildWithMoveWindowSeq, "MoveWindow:child", FALSE);
4244 log_all_parent_messages--;
4246 ShowWindow(hchild, SW_HIDE);
4248 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE);
4249 ok_sequence(WmShowChildSeq_2, "SetWindowPos:show_child_2", FALSE);
4251 ShowWindow(hchild, SW_HIDE);
4253 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE);
4254 ok_sequence(WmShowChildSeq_3, "SetWindowPos:show_child_3", FALSE);
4256 /* DestroyWindow sequence below expects that a child has focus */
4260 DestroyWindow(hchild);
4261 ok_sequence(WmDestroyChildSeq, "DestroyWindow:child", FALSE);
4262 DestroyWindow(hchild2);
4263 DestroyWindow(hbutton);
4266 hchild = CreateWindowExA(0, "TestWindowClass", "Test Child Popup", WS_CHILD | WS_POPUP,
4267 0, 0, 100, 100, hparent, 0, 0, NULL);
4268 ok (hchild != 0, "Failed to create child popup window\n");
4269 ok_sequence(WmCreateChildPopupSeq, "CreateWindow:child_popup", FALSE);
4270 DestroyWindow(hchild);
4272 /* test what happens to a window which sets WS_VISIBLE in WM_CREATE */
4274 hchild = CreateWindowExA(0, "TestPopupClass", "Test Popup", WS_POPUP,
4275 0, 0, 100, 100, hparent, 0, 0, NULL);
4276 ok (hchild != 0, "Failed to create popup window\n");
4277 ok_sequence(WmCreateInvisiblePopupSeq, "CreateWindow:invisible_popup", FALSE);
4278 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
4279 ok(IsWindowVisible(hchild), "IsWindowVisible() should return TRUE\n");
4281 ShowWindow(hchild, SW_SHOW);
4282 ok_sequence(WmEmptySeq, "ShowWindow:show_visible_popup", FALSE);
4284 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER);
4285 ok_sequence(WmShowVisiblePopupSeq_2, "SetWindowPos:show_visible_popup_2", FALSE);
4287 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE);
4288 ok_sequence(WmShowVisiblePopupSeq_3, "SetWindowPos:show_visible_popup_3", TRUE);
4289 DestroyWindow(hchild);
4291 /* this time add WS_VISIBLE for CreateWindowEx, but this fact actually
4292 * changes nothing in message sequences.
4295 hchild = CreateWindowExA(0, "TestPopupClass", "Test Popup", WS_POPUP | WS_VISIBLE,
4296 0, 0, 100, 100, hparent, 0, 0, NULL);
4297 ok (hchild != 0, "Failed to create popup window\n");
4298 ok_sequence(WmCreateInvisiblePopupSeq, "CreateWindow:invisible_popup", FALSE);
4299 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
4300 ok(IsWindowVisible(hchild), "IsWindowVisible() should return TRUE\n");
4302 ShowWindow(hchild, SW_SHOW);
4303 ok_sequence(WmEmptySeq, "ShowWindow:show_visible_popup", FALSE);
4305 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER);
4306 ok_sequence(WmShowVisiblePopupSeq_2, "SetWindowPos:show_visible_popup_2", FALSE);
4307 DestroyWindow(hchild);
4310 hwnd = CreateWindowExA(WS_EX_DLGMODALFRAME, "TestDialogClass", NULL, WS_VISIBLE|WS_CAPTION|WS_SYSMENU|WS_DLGFRAME,
4311 0, 0, 100, 100, hparent, 0, 0, NULL);
4312 ok(hwnd != 0, "Failed to create custom dialog window\n");
4313 ok_sequence(WmCreateCustomDialogSeq, "CreateCustomDialog", TRUE);
4316 trace("testing scroll APIs on a visible dialog %p\n", hwnd);
4317 test_scroll_messages(hwnd);
4323 SendMessage(hwnd, WM_NULL, 0, 0);
4326 after_end_dialog = 1;
4327 EndDialog( hwnd, 0 );
4328 ok_sequence(WmEndCustomDialogSeq, "EndCustomDialog", FALSE);
4330 DestroyWindow(hwnd);
4331 after_end_dialog = 0;
4334 hwnd = CreateWindowExA(0, "TestDialogClass", NULL, WS_POPUP,
4335 0, 0, 100, 100, 0, 0, GetModuleHandleA(0), NULL);
4336 ok(hwnd != 0, "Failed to create custom dialog window\n");
4338 trace("call ShowWindow(%p, SW_SHOW)\n", hwnd);
4339 ShowWindow(hwnd, SW_SHOW);
4340 ok_sequence(WmShowCustomDialogSeq, "ShowCustomDialog", TRUE);
4341 DestroyWindow(hwnd);
4344 DialogBoxA( 0, "TEST_DIALOG", hparent, TestModalDlgProcA );
4345 ok_sequence(WmModalDialogSeq, "ModalDialog", TRUE);
4347 DestroyWindow(hparent);
4350 /* Message sequence for SetMenu */
4351 ok(!DrawMenuBar(hwnd), "DrawMenuBar should return FALSE for a window without a menu\n");
4352 ok_sequence(WmEmptySeq, "DrawMenuBar for a window without a menu", FALSE);
4354 hmenu = CreateMenu();
4355 ok (hmenu != 0, "Failed to create menu\n");
4356 ok (InsertMenuA(hmenu, -1, MF_BYPOSITION, 0x1000, "foo"), "InsertMenu failed\n");
4357 hwnd = CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW,
4358 100, 100, 200, 200, 0, hmenu, 0, NULL);
4359 ok_sequence(WmCreateOverlappedSeq, "CreateWindow:overlapped", FALSE);
4360 ok (SetMenu(hwnd, 0), "SetMenu\n");
4361 ok_sequence(WmSetMenuNonVisibleSizeChangeSeq, "SetMenu:NonVisibleSizeChange", FALSE);
4362 ok (SetMenu(hwnd, 0), "SetMenu\n");
4363 ok_sequence(WmSetMenuNonVisibleNoSizeChangeSeq, "SetMenu:NonVisibleNoSizeChange", FALSE);
4364 ShowWindow(hwnd, SW_SHOW);
4365 UpdateWindow( hwnd );
4368 ok (SetMenu(hwnd, 0), "SetMenu\n");
4369 ok_sequence(WmSetMenuVisibleNoSizeChangeSeq, "SetMenu:VisibleNoSizeChange", FALSE);
4370 ok (SetMenu(hwnd, hmenu), "SetMenu\n");
4371 ok_sequence(WmSetMenuVisibleSizeChangeSeq, "SetMenu:VisibleSizeChange", FALSE);
4373 UpdateWindow( hwnd );
4376 ok(DrawMenuBar(hwnd), "DrawMenuBar\n");
4378 ok_sequence(WmDrawMenuBarSeq, "DrawMenuBar", FALSE);
4380 DestroyWindow(hwnd);
4383 /* Message sequence for EnableWindow */
4384 hparent = CreateWindowExA(0, "TestWindowClass", "Test parent", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
4385 100, 100, 200, 200, 0, 0, 0, NULL);
4386 ok (hparent != 0, "Failed to create parent window\n");
4387 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD | WS_VISIBLE,
4388 0, 0, 10, 10, hparent, 0, 0, NULL);
4389 ok (hchild != 0, "Failed to create child window\n");
4395 EnableWindow(hparent, FALSE);
4396 ok_sequence(WmEnableWindowSeq_1, "EnableWindow(FALSE)", FALSE);
4398 EnableWindow(hparent, TRUE);
4399 ok_sequence(WmEnableWindowSeq_2, "EnableWindow(TRUE)", FALSE);
4404 test_MsgWaitForMultipleObjects(hparent);
4406 /* the following test causes an exception in user.exe under win9x */
4407 if (!PostMessageW( hparent, WM_USER, 0, 0 ))
4409 DestroyWindow(hparent);
4413 PostMessageW( hparent, WM_USER+1, 0, 0 );
4414 /* PeekMessage(NULL) fails, but still removes the message */
4415 SetLastError(0xdeadbeef);
4416 ok( !PeekMessageW( NULL, 0, 0, 0, PM_REMOVE ), "PeekMessage(NULL) should fail\n" );
4417 ok( GetLastError() == ERROR_NOACCESS || /* Win2k */
4418 GetLastError() == 0xdeadbeef, /* NT4 */
4419 "last error is %d\n", GetLastError() );
4420 ok( PeekMessageW( &msg, 0, 0, 0, PM_REMOVE ), "PeekMessage should succeed\n" );
4421 ok( msg.message == WM_USER+1, "got %x instead of WM_USER+1\n", msg.message );
4423 DestroyWindow(hchild);
4424 DestroyWindow(hparent);
4427 /* Message sequences for WM_SETICON */
4428 trace("testing WM_SETICON\n");
4429 hwnd = CreateWindowExA(0, "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW,
4430 CW_USEDEFAULT, CW_USEDEFAULT, 300, 300, 0,
4432 ShowWindow(hwnd, SW_SHOW);
4436 SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(0, IDI_APPLICATION));
4437 ok_sequence(WmSetIcon_1, "WM_SETICON for shown window with caption", FALSE);
4439 ShowWindow(hwnd, SW_HIDE);
4442 SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(0, IDI_APPLICATION));
4443 ok_sequence(WmSetIcon_2, "WM_SETICON for hidden window with caption", FALSE);
4444 DestroyWindow(hwnd);
4447 hwnd = CreateWindowExA(0, "TestPopupClass", NULL, WS_POPUP,
4448 CW_USEDEFAULT, CW_USEDEFAULT, 300, 300, 0,
4450 ShowWindow(hwnd, SW_SHOW);
4454 SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(0, IDI_APPLICATION));
4455 ok_sequence(WmSetIcon_2, "WM_SETICON for shown window without caption", FALSE);
4457 ShowWindow(hwnd, SW_HIDE);
4460 SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(0, IDI_APPLICATION));
4461 ok_sequence(WmSetIcon_2, "WM_SETICON for hidden window without caption", FALSE);
4464 res = SendMessage(hwnd, 0x3B, 0x8000000b, 0);
4465 ok_sequence(WmInitEndSession, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x8000000b", TRUE);
4467 ok(res == 1, "SendMessage(hwnd, 0x3B, 0x8000000b, 0) should have returned 1 instead of %ld\n", res);
4468 res = SendMessage(hwnd, 0x3B, 0x0000000b, 0);
4469 ok_sequence(WmInitEndSession_2, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x0000000b", TRUE);
4471 ok(res == 1, "SendMessage(hwnd, 0x3B, 0x0000000b, 0) should have returned 1 instead of %ld\n", res);
4472 res = SendMessage(hwnd, 0x3B, 0x0000000f, 0);
4473 ok_sequence(WmInitEndSession_2, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x0000000f", TRUE);
4475 ok(res == 1, "SendMessage(hwnd, 0x3B, 0x0000000f, 0) should have returned 1 instead of %ld\n", res);
4478 res = SendMessage(hwnd, 0x3B, 0x80000008, 0);
4479 ok_sequence(WmInitEndSession_3, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x80000008", TRUE);
4481 ok(res == 2, "SendMessage(hwnd, 0x3B, 0x80000008, 0) should have returned 2 instead of %ld\n", res);
4482 res = SendMessage(hwnd, 0x3B, 0x00000008, 0);
4483 ok_sequence(WmInitEndSession_4, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x00000008", TRUE);
4485 ok(res == 2, "SendMessage(hwnd, 0x3B, 0x00000008, 0) should have returned 2 instead of %ld\n", res);
4487 res = SendMessage(hwnd, 0x3B, 0x80000004, 0);
4488 ok_sequence(WmInitEndSession_3, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x80000004", TRUE);
4490 ok(res == 2, "SendMessage(hwnd, 0x3B, 0x80000004, 0) should have returned 2 instead of %ld\n", res);
4492 res = SendMessage(hwnd, 0x3B, 0x80000001, 0);
4493 ok_sequence(WmInitEndSession_5, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x80000001", TRUE);
4495 ok(res == 2, "SendMessage(hwnd, 0x3B, 0x80000001, 0) should have returned 2 instead of %ld\n", res);
4497 DestroyWindow(hwnd);
4501 static void invisible_parent_tests(void)
4503 HWND hparent, hchild;
4505 hparent = CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW,
4506 100, 100, 200, 200, 0, 0, 0, NULL);
4507 ok (hparent != 0, "Failed to create parent window\n");
4510 /* test showing child with hidden parent */
4512 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
4513 0, 0, 10, 10, hparent, 0, 0, NULL);
4514 ok (hchild != 0, "Failed to create child window\n");
4515 ok_sequence(WmCreateChildSeq, "CreateWindow:child", FALSE);
4517 ShowWindow( hchild, SW_MINIMIZE );
4518 ok_sequence(WmShowChildInvisibleParentSeq_1, "ShowWindow(SW_MINIMIZE) child with invisible parent", FALSE);
4519 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
4520 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4525 ShowWindow( hchild, SW_MINIMIZE );
4526 ok_sequence(WmShowChildInvisibleParentSeq_1r, "ShowWindow(SW_MINIMIZE) child with invisible parent", FALSE);
4528 DestroyWindow(hchild);
4529 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
4530 0, 0, 10, 10, hparent, 0, 0, NULL);
4533 ShowWindow( hchild, SW_MAXIMIZE );
4534 ok_sequence(WmShowChildInvisibleParentSeq_2, "ShowWindow(SW_MAXIMIZE) child with invisible parent", FALSE);
4535 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
4536 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4541 ShowWindow( hchild, SW_MAXIMIZE );
4542 ok_sequence(WmShowChildInvisibleParentSeq_2r, "ShowWindow(SW_MAXIMIZE) child with invisible parent", FALSE);
4544 DestroyWindow(hchild);
4545 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
4546 0, 0, 10, 10, hparent, 0, 0, NULL);
4549 ShowWindow( hchild, SW_RESTORE );
4550 ok_sequence(WmShowChildInvisibleParentSeq_5, "ShowWindow(SW_RESTORE) child with invisible parent", FALSE);
4551 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
4552 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4554 DestroyWindow(hchild);
4555 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
4556 0, 0, 10, 10, hparent, 0, 0, NULL);
4559 ShowWindow( hchild, SW_SHOWMINIMIZED );
4560 ok_sequence(WmShowChildInvisibleParentSeq_3, "ShowWindow(SW_SHOWMINIMIZED) child with invisible parent", FALSE);
4561 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
4562 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4567 ShowWindow( hchild, SW_SHOWMINIMIZED );
4568 ok_sequence(WmShowChildInvisibleParentSeq_3r, "ShowWindow(SW_SHOWMINIMIZED) child with invisible parent", FALSE);
4570 DestroyWindow(hchild);
4571 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
4572 0, 0, 10, 10, hparent, 0, 0, NULL);
4575 /* same as ShowWindow( hchild, SW_MAXIMIZE ); */
4576 ShowWindow( hchild, SW_SHOWMAXIMIZED );
4577 ok_sequence(WmShowChildInvisibleParentSeq_2, "ShowWindow(SW_SHOWMAXIMIZED) child with invisible parent", FALSE);
4578 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
4579 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4581 DestroyWindow(hchild);
4582 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
4583 0, 0, 10, 10, hparent, 0, 0, NULL);
4586 ShowWindow( hchild, SW_SHOWMINNOACTIVE );
4587 ok_sequence(WmShowChildInvisibleParentSeq_4, "ShowWindow(SW_SHOWMINNOACTIVE) child with invisible parent", FALSE);
4588 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
4589 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4594 ShowWindow( hchild, SW_SHOWMINNOACTIVE );
4595 ok_sequence(WmShowChildInvisibleParentSeq_4r, "ShowWindow(SW_SHOWMINNOACTIVE) child with invisible parent", FALSE);
4597 DestroyWindow(hchild);
4598 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
4599 0, 0, 10, 10, hparent, 0, 0, NULL);
4602 /* FIXME: looks like XP SP2 doesn't know about SW_FORCEMINIMIZE at all */
4603 ShowWindow( hchild, SW_FORCEMINIMIZE );
4604 ok_sequence(WmEmptySeq, "ShowWindow(SW_FORCEMINIMIZE) child with invisible parent", TRUE);
4606 ok(!(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE), "WS_VISIBLE should be not set\n");
4608 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4610 DestroyWindow(hchild);
4611 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
4612 0, 0, 10, 10, hparent, 0, 0, NULL);
4615 ShowWindow( hchild, SW_SHOWNA );
4616 ok_sequence(WmShowChildInvisibleParentSeq_5, "ShowWindow(SW_SHOWNA) child with invisible parent", FALSE);
4617 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
4618 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4623 ShowWindow( hchild, SW_SHOWNA );
4624 ok_sequence(WmShowChildInvisibleParentSeq_5, "ShowWindow(SW_SHOWNA) child with invisible parent", FALSE);
4626 DestroyWindow(hchild);
4627 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
4628 0, 0, 10, 10, hparent, 0, 0, NULL);
4631 ShowWindow( hchild, SW_SHOW );
4632 ok_sequence(WmShowChildInvisibleParentSeq_5, "ShowWindow(SW_SHOW) child with invisible parent", FALSE);
4633 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
4634 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4639 ShowWindow( hchild, SW_SHOW );
4640 ok_sequence(WmEmptySeq, "ShowWindow(SW_SHOW) child with invisible parent", FALSE);
4642 ShowWindow( hchild, SW_HIDE );
4643 ok_sequence(WmHideChildInvisibleParentSeq, "ShowWindow:hide child with invisible parent", FALSE);
4644 ok(!(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE), "WS_VISIBLE should be not set\n");
4645 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4647 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER);
4648 ok_sequence(WmShowChildInvisibleParentSeq_6, "SetWindowPos:show child with invisible parent", FALSE);
4649 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
4650 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4652 SetWindowPos(hchild, 0,0,0,0,0, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER);
4653 ok_sequence(WmHideChildInvisibleParentSeq_2, "SetWindowPos:hide child with invisible parent", FALSE);
4654 ok(!(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE), "WS_VISIBLE should not be set\n");
4655 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4657 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER);
4659 DestroyWindow(hchild);
4660 ok_sequence(WmDestroyInvisibleChildSeq, "DestroyInvisibleChildSeq", FALSE);
4662 DestroyWindow(hparent);
4666 /****************** button message test *************************/
4667 static const struct message WmSetFocusButtonSeq[] =
4669 { HCBT_SETFOCUS, hook },
4670 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
4671 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
4672 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
4673 { WM_SETFOCUS, sent|wparam, 0 },
4674 { WM_CTLCOLORBTN, sent|defwinproc },
4677 static const struct message WmKillFocusButtonSeq[] =
4679 { HCBT_SETFOCUS, hook },
4680 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
4681 { WM_KILLFOCUS, sent|wparam, 0 },
4682 { WM_CTLCOLORBTN, sent|defwinproc },
4683 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
4684 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 1 },
4687 static const struct message WmSetFocusStaticSeq[] =
4689 { HCBT_SETFOCUS, hook },
4690 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
4691 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
4692 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
4693 { WM_SETFOCUS, sent|wparam, 0 },
4694 { WM_CTLCOLORSTATIC, sent|defwinproc },
4697 static const struct message WmKillFocusStaticSeq[] =
4699 { HCBT_SETFOCUS, hook },
4700 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
4701 { WM_KILLFOCUS, sent|wparam, 0 },
4702 { WM_CTLCOLORSTATIC, sent|defwinproc },
4703 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
4704 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 1 },
4707 static const struct message WmLButtonDownSeq[] =
4709 { WM_LBUTTONDOWN, sent|wparam|lparam, 0, 0 },
4710 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
4711 { HCBT_SETFOCUS, hook },
4712 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
4713 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
4714 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
4715 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
4716 { WM_CTLCOLORBTN, sent|defwinproc },
4717 { BM_SETSTATE, sent|wparam|defwinproc, TRUE },
4718 { WM_CTLCOLORBTN, sent|defwinproc },
4719 { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
4722 static const struct message WmLButtonUpSeq[] =
4724 { WM_LBUTTONUP, sent|wparam|lparam, 0, 0 },
4725 { BM_SETSTATE, sent|wparam|defwinproc, FALSE },
4726 { WM_CTLCOLORBTN, sent|defwinproc },
4727 { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
4728 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, 0, 0 },
4729 { WM_CAPTURECHANGED, sent|wparam|defwinproc, 0 },
4732 static const struct message WmSetFontButtonSeq[] =
4734 { WM_SETFONT, sent },
4736 { WM_ERASEBKGND, sent|defwinproc|optional },
4737 { WM_CTLCOLORBTN, sent|defwinproc },
4741 static WNDPROC old_button_proc;
4743 static LRESULT CALLBACK button_hook_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
4745 static long defwndproc_counter = 0;
4749 trace("button: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
4751 /* explicitly ignore WM_GETICON message */
4752 if (message == WM_GETICON) return 0;
4754 msg.message = message;
4755 msg.flags = sent|wparam|lparam;
4756 if (defwndproc_counter) msg.flags |= defwinproc;
4757 msg.wParam = wParam;
4758 msg.lParam = lParam;
4761 if (message == BM_SETSTATE)
4762 ok(GetCapture() == hwnd, "GetCapture() = %p\n", GetCapture());
4764 defwndproc_counter++;
4765 ret = CallWindowProcA(old_button_proc, hwnd, message, wParam, lParam);
4766 defwndproc_counter--;
4771 static void subclass_button(void)
4775 if (!GetClassInfoA(0, "button", &cls)) assert(0);
4777 old_button_proc = cls.lpfnWndProc;
4779 cls.hInstance = GetModuleHandle(0);
4780 cls.lpfnWndProc = button_hook_proc;
4781 cls.lpszClassName = "my_button_class";
4782 UnregisterClass(cls.lpszClassName, cls.hInstance);
4783 if (!RegisterClassA(&cls)) assert(0);
4786 static void test_button_messages(void)
4792 const struct message *setfocus;
4793 const struct message *killfocus;
4795 { BS_PUSHBUTTON, DLGC_BUTTON | DLGC_UNDEFPUSHBUTTON,
4796 WmSetFocusButtonSeq, WmKillFocusButtonSeq },
4797 { BS_DEFPUSHBUTTON, DLGC_BUTTON | DLGC_DEFPUSHBUTTON,
4798 WmSetFocusButtonSeq, WmKillFocusButtonSeq },
4799 { BS_CHECKBOX, DLGC_BUTTON,
4800 WmSetFocusStaticSeq, WmKillFocusStaticSeq },
4801 { BS_AUTOCHECKBOX, DLGC_BUTTON,
4802 WmSetFocusStaticSeq, WmKillFocusStaticSeq },
4803 { BS_RADIOBUTTON, DLGC_BUTTON | DLGC_RADIOBUTTON,
4804 WmSetFocusStaticSeq, WmKillFocusStaticSeq },
4805 { BS_3STATE, DLGC_BUTTON,
4806 WmSetFocusStaticSeq, WmKillFocusStaticSeq },
4807 { BS_AUTO3STATE, DLGC_BUTTON,
4808 WmSetFocusStaticSeq, WmKillFocusStaticSeq },
4809 { BS_GROUPBOX, DLGC_STATIC,
4810 WmSetFocusStaticSeq, WmKillFocusStaticSeq },
4811 { BS_USERBUTTON, DLGC_BUTTON | DLGC_UNDEFPUSHBUTTON,
4812 WmSetFocusButtonSeq, WmKillFocusButtonSeq },
4813 { BS_AUTORADIOBUTTON, DLGC_BUTTON | DLGC_RADIOBUTTON,
4814 WmSetFocusStaticSeq, WmKillFocusStaticSeq },
4815 { BS_OWNERDRAW, DLGC_BUTTON,
4816 WmSetFocusButtonSeq, WmKillFocusButtonSeq }
4825 for (i = 0; i < sizeof(button)/sizeof(button[0]); i++)
4827 hwnd = CreateWindowExA(0, "my_button_class", "test", button[i].style | WS_POPUP,
4828 0, 0, 50, 14, 0, 0, 0, NULL);
4829 ok(hwnd != 0, "Failed to create button window\n");
4831 dlg_code = SendMessageA(hwnd, WM_GETDLGCODE, 0, 0);
4832 ok(dlg_code == button[i].dlg_code, "%u: wrong dlg_code %08x\n", i, dlg_code);
4834 ShowWindow(hwnd, SW_SHOW);
4839 trace("button style %08x\n", button[i].style);
4841 ok_sequence(button[i].setfocus, "SetFocus(hwnd) on a button", FALSE);
4844 ok_sequence(button[i].killfocus, "SetFocus(0) on a button", FALSE);
4846 DestroyWindow(hwnd);
4849 hwnd = CreateWindowExA(0, "my_button_class", "test", BS_PUSHBUTTON | WS_POPUP | WS_VISIBLE,
4850 0, 0, 50, 14, 0, 0, 0, NULL);
4851 ok(hwnd != 0, "Failed to create button window\n");
4857 SendMessageA(hwnd, WM_LBUTTONDOWN, 0, 0);
4858 ok_sequence(WmLButtonDownSeq, "WM_LBUTTONDOWN on a button", FALSE);
4860 SendMessageA(hwnd, WM_LBUTTONUP, 0, 0);
4861 ok_sequence(WmLButtonUpSeq, "WM_LBUTTONUP on a button", FALSE);
4864 zfont = (HFONT)GetStockObject(SYSTEM_FONT);
4865 SendMessageA(hwnd, WM_SETFONT, (WPARAM)zfont, TRUE);
4867 ok_sequence(WmSetFontButtonSeq, "WM_SETFONT on a button", FALSE);
4869 DestroyWindow(hwnd);
4872 /****************** static message test *************************/
4873 static const struct message WmSetFontStaticSeq[] =
4875 { WM_SETFONT, sent },
4876 { WM_PAINT, sent|defwinproc },
4877 { WM_ERASEBKGND, sent|defwinproc|optional },
4878 { WM_CTLCOLORSTATIC, sent|defwinproc },
4882 static WNDPROC old_static_proc;
4884 static LRESULT CALLBACK static_hook_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
4886 static long defwndproc_counter = 0;
4890 trace("static: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
4892 /* explicitly ignore WM_GETICON message */
4893 if (message == WM_GETICON) return 0;
4895 msg.message = message;
4896 msg.flags = sent|wparam|lparam;
4897 if (defwndproc_counter) msg.flags |= defwinproc;
4898 msg.wParam = wParam;
4899 msg.lParam = lParam;
4902 defwndproc_counter++;
4903 ret = CallWindowProcA(old_static_proc, hwnd, message, wParam, lParam);
4904 defwndproc_counter--;
4909 static void subclass_static(void)
4913 if (!GetClassInfoA(0, "static", &cls)) assert(0);
4915 old_static_proc = cls.lpfnWndProc;
4917 cls.hInstance = GetModuleHandle(0);
4918 cls.lpfnWndProc = static_hook_proc;
4919 cls.lpszClassName = "my_static_class";
4920 UnregisterClass(cls.lpszClassName, cls.hInstance);
4921 if (!RegisterClassA(&cls)) assert(0);
4924 static void test_static_messages(void)
4926 /* FIXME: make as comprehensive as the button message test */
4931 const struct message *setfont;
4933 { SS_LEFT, DLGC_STATIC,
4934 WmSetFontStaticSeq }
4942 for (i = 0; i < sizeof(static_ctrl)/sizeof(static_ctrl[0]); i++)
4944 hwnd = CreateWindowExA(0, "my_static_class", "test", static_ctrl[i].style | WS_POPUP,
4945 0, 0, 50, 14, 0, 0, 0, NULL);
4946 ok(hwnd != 0, "Failed to create static window\n");
4948 dlg_code = SendMessageA(hwnd, WM_GETDLGCODE, 0, 0);
4949 ok(dlg_code == static_ctrl[i].dlg_code, "%u: wrong dlg_code %08x\n", i, dlg_code);
4951 ShowWindow(hwnd, SW_SHOW);
4956 trace("static style %08x\n", static_ctrl[i].style);
4957 SendMessage(hwnd, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), TRUE);
4958 ok_sequence(static_ctrl[i].setfont, "WM_SETFONT on a static", FALSE);
4960 DestroyWindow(hwnd);
4964 /****************** ComboBox message test *************************/
4965 #define ID_COMBOBOX 0x000f
4967 static const struct message WmKeyDownComboSeq[] =
4969 { WM_KEYDOWN, sent|wparam|lparam, VK_DOWN, 0 },
4970 { WM_COMMAND, sent|wparam|defwinproc, MAKEWPARAM(1000, LBN_SELCHANGE) },
4971 { WM_COMMAND, sent|wparam|parent, MAKEWPARAM(ID_COMBOBOX, CBN_SELENDOK) },
4972 { WM_COMMAND, sent|wparam|parent, MAKEWPARAM(ID_COMBOBOX, CBN_SELCHANGE) },
4973 { WM_CTLCOLOREDIT, sent|parent },
4974 { WM_KEYUP, sent|wparam|lparam, VK_DOWN, 0 },
4978 static WNDPROC old_combobox_proc;
4980 static LRESULT CALLBACK combobox_hook_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
4982 static long defwndproc_counter = 0;
4986 /* do not log painting messages */
4987 if (message != WM_PAINT &&
4988 message != WM_NCPAINT &&
4989 message != WM_SYNCPAINT &&
4990 message != WM_ERASEBKGND &&
4991 message != WM_NCHITTEST &&
4992 message != WM_GETTEXT &&
4993 message != WM_GETICON &&
4994 message != WM_DEVICECHANGE)
4996 trace("combo: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
4998 msg.message = message;
4999 msg.flags = sent|wparam|lparam;
5000 if (defwndproc_counter) msg.flags |= defwinproc;
5001 msg.wParam = wParam;
5002 msg.lParam = lParam;
5006 defwndproc_counter++;
5007 ret = CallWindowProcA(old_combobox_proc, hwnd, message, wParam, lParam);
5008 defwndproc_counter--;
5013 static void subclass_combobox(void)
5017 if (!GetClassInfoA(0, "ComboBox", &cls)) assert(0);
5019 old_combobox_proc = cls.lpfnWndProc;
5021 cls.hInstance = GetModuleHandle(0);
5022 cls.lpfnWndProc = combobox_hook_proc;
5023 cls.lpszClassName = "my_combobox_class";
5024 UnregisterClass(cls.lpszClassName, cls.hInstance);
5025 if (!RegisterClassA(&cls)) assert(0);
5028 static void test_combobox_messages(void)
5033 subclass_combobox();
5035 parent = CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
5036 100, 100, 200, 200, 0, 0, 0, NULL);
5037 ok(parent != 0, "Failed to create parent window\n");
5040 combo = CreateWindowEx(0, "my_combobox_class", "test", WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST | CBS_HASSTRINGS,
5041 0, 0, 100, 150, parent, (HMENU)ID_COMBOBOX, 0, NULL);
5042 ok(combo != 0, "Failed to create combobox window\n");
5044 UpdateWindow(combo);
5046 ret = SendMessage(combo, WM_GETDLGCODE, 0, 0);
5047 ok(ret == (DLGC_WANTCHARS | DLGC_WANTARROWS), "wrong dlg_code %08lx\n", ret);
5049 ret = SendMessage(combo, CB_ADDSTRING, 0, (LPARAM)"item 0");
5050 ok(ret == 0, "expected 0, got %ld\n", ret);
5051 ret = SendMessage(combo, CB_ADDSTRING, 0, (LPARAM)"item 1");
5052 ok(ret == 1, "expected 1, got %ld\n", ret);
5053 ret = SendMessage(combo, CB_ADDSTRING, 0, (LPARAM)"item 2");
5054 ok(ret == 2, "expected 2, got %ld\n", ret);
5056 SendMessage(combo, CB_SETCURSEL, 0, 0);
5060 log_all_parent_messages++;
5061 SendMessage(combo, WM_KEYDOWN, VK_DOWN, 0);
5062 SendMessage(combo, WM_KEYUP, VK_DOWN, 0);
5063 log_all_parent_messages--;
5064 ok_sequence(WmKeyDownComboSeq, "WM_KEYDOWN/VK_DOWN on a ComboBox", FALSE);
5066 DestroyWindow(combo);
5067 DestroyWindow(parent);
5070 /****************** WM_IME_KEYDOWN message test *******************/
5072 static const struct message WmImeKeydownMsgSeq_0[] =
5074 { WM_IME_KEYDOWN, wparam, VK_RETURN },
5075 { WM_CHAR, wparam, 'A' },
5079 static const struct message WmImeKeydownMsgSeq_1[] =
5081 { WM_KEYDOWN, wparam, VK_RETURN },
5082 { WM_CHAR, wparam, VK_RETURN },
5086 static LRESULT WINAPI wmime_keydown_procA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
5090 trace("wmime_keydown_procA: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
5092 msg.message = message;
5093 msg.flags = wparam|lparam;
5094 msg.wParam = wParam;
5095 msg.lParam = lParam;
5098 return DefWindowProcA(hwnd, message, wParam, lParam);
5101 static void register_wmime_keydown_class(void)
5105 ZeroMemory(&cls, sizeof(WNDCLASSA));
5106 cls.lpfnWndProc = wmime_keydown_procA;
5107 cls.hInstance = GetModuleHandleA(0);
5108 cls.lpszClassName = "wmime_keydown_class";
5109 if (!RegisterClassA(&cls)) assert(0);
5112 void test_wmime_keydown_message(void)
5117 trace("Message sequences by WM_IME_KEYDOWN\n");
5119 register_wmime_keydown_class();
5120 hwnd = CreateWindowExA(0, "wmime_keydown_class", NULL, WS_OVERLAPPEDWINDOW,
5121 CW_USEDEFAULT, CW_USEDEFAULT, 300, 300, 0,
5126 SendMessage(hwnd, WM_IME_KEYDOWN, VK_RETURN, 0x1c0001);
5127 SendMessage(hwnd, WM_CHAR, 'A', 1);
5128 ok_sequence(WmImeKeydownMsgSeq_0, "WM_IME_KEYDOWN 0", FALSE);
5130 while ( PeekMessage(&msg, 0, 0, 0, PM_REMOVE) )
5132 TranslateMessage(&msg);
5133 DispatchMessage(&msg);
5135 ok_sequence(WmImeKeydownMsgSeq_1, "WM_IME_KEYDOWN 1", FALSE);
5137 DestroyWindow(hwnd);
5140 /************* painting message test ********************/
5142 void dump_region(HRGN hrgn)
5145 RGNDATA *data = NULL;
5150 printf( "null region\n" );
5153 if (!(size = GetRegionData( hrgn, 0, NULL ))) return;
5154 if (!(data = HeapAlloc( GetProcessHeap(), 0, size ))) return;
5155 GetRegionData( hrgn, size, data );
5156 printf("%d rects:", data->rdh.nCount );
5157 for (i = 0, rect = (RECT *)data->Buffer; i < data->rdh.nCount; i++, rect++)
5158 printf( " (%d,%d)-(%d,%d)", rect->left, rect->top, rect->right, rect->bottom );
5160 HeapFree( GetProcessHeap(), 0, data );
5163 static void check_update_rgn( HWND hwnd, HRGN hrgn )
5167 HRGN tmp = CreateRectRgn( 0, 0, 0, 0 );
5168 HRGN update = CreateRectRgn( 0, 0, 0, 0 );
5170 ret = GetUpdateRgn( hwnd, update, FALSE );
5171 ok( ret != ERROR, "GetUpdateRgn failed\n" );
5172 if (ret == NULLREGION)
5174 ok( !hrgn, "Update region shouldn't be empty\n" );
5178 if (CombineRgn( tmp, hrgn, update, RGN_XOR ) != NULLREGION)
5180 ok( 0, "Regions are different\n" );
5181 if (winetest_debug > 0)
5183 printf( "Update region: " );
5184 dump_region( update );
5185 printf( "Wanted region: " );
5186 dump_region( hrgn );
5190 GetRgnBox( update, &r1 );
5191 GetUpdateRect( hwnd, &r2, FALSE );
5192 ok( r1.left == r2.left && r1.top == r2.top && r1.right == r2.right && r1.bottom == r2.bottom,
5193 "Rectangles are different: %d,%d-%d,%d / %d,%d-%d,%d\n",
5194 r1.left, r1.top, r1.right, r1.bottom, r2.left, r2.top, r2.right, r2.bottom );
5196 DeleteObject( tmp );
5197 DeleteObject( update );
5200 static const struct message WmInvalidateRgn[] = {
5201 { WM_NCPAINT, sent },
5202 { WM_GETTEXT, sent|defwinproc|optional },
5206 static const struct message WmGetUpdateRect[] = {
5207 { WM_NCPAINT, sent },
5208 { WM_GETTEXT, sent|defwinproc|optional },
5213 static const struct message WmInvalidateFull[] = {
5214 { WM_NCPAINT, sent|wparam, 1 },
5215 { WM_GETTEXT, sent|defwinproc|optional },
5219 static const struct message WmInvalidateErase[] = {
5220 { WM_NCPAINT, sent|wparam, 1 },
5221 { WM_GETTEXT, sent|defwinproc|optional },
5222 { WM_ERASEBKGND, sent },
5226 static const struct message WmInvalidatePaint[] = {
5228 { WM_NCPAINT, sent|wparam|beginpaint, 1 },
5229 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
5233 static const struct message WmInvalidateErasePaint[] = {
5235 { WM_NCPAINT, sent|wparam|beginpaint, 1 },
5236 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
5237 { WM_ERASEBKGND, sent|beginpaint },
5241 static const struct message WmInvalidateErasePaint2[] = {
5243 { WM_NCPAINT, sent|beginpaint },
5244 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
5245 { WM_ERASEBKGND, sent|beginpaint },
5249 static const struct message WmErase[] = {
5250 { WM_ERASEBKGND, sent },
5254 static const struct message WmPaint[] = {
5259 static const struct message WmParentOnlyPaint[] = {
5260 { WM_PAINT, sent|parent },
5264 static const struct message WmInvalidateParent[] = {
5265 { WM_NCPAINT, sent|parent },
5266 { WM_GETTEXT, sent|defwinproc|parent|optional },
5267 { WM_ERASEBKGND, sent|parent },
5271 static const struct message WmInvalidateParentChild[] = {
5272 { WM_NCPAINT, sent|parent },
5273 { WM_GETTEXT, sent|defwinproc|parent|optional },
5274 { WM_ERASEBKGND, sent|parent },
5275 { WM_NCPAINT, sent },
5276 { WM_GETTEXT, sent|defwinproc|optional },
5277 { WM_ERASEBKGND, sent },
5281 static const struct message WmInvalidateParentChild2[] = {
5282 { WM_ERASEBKGND, sent|parent },
5283 { WM_NCPAINT, sent },
5284 { WM_GETTEXT, sent|defwinproc|optional },
5285 { WM_ERASEBKGND, sent },
5289 static const struct message WmParentPaint[] = {
5290 { WM_PAINT, sent|parent },
5295 static const struct message WmParentPaintNc[] = {
5296 { WM_PAINT, sent|parent },
5298 { WM_NCPAINT, sent|beginpaint },
5299 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
5300 { WM_ERASEBKGND, sent|beginpaint },
5304 static const struct message WmChildPaintNc[] = {
5306 { WM_NCPAINT, sent|beginpaint },
5307 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
5308 { WM_ERASEBKGND, sent|beginpaint },
5312 static const struct message WmParentErasePaint[] = {
5313 { WM_PAINT, sent|parent },
5314 { WM_NCPAINT, sent|parent|beginpaint },
5315 { WM_GETTEXT, sent|parent|beginpaint|defwinproc|optional },
5316 { WM_ERASEBKGND, sent|parent|beginpaint },
5318 { WM_NCPAINT, sent|beginpaint },
5319 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
5320 { WM_ERASEBKGND, sent|beginpaint },
5324 static const struct message WmParentOnlyNcPaint[] = {
5325 { WM_PAINT, sent|parent },
5326 { WM_NCPAINT, sent|parent|beginpaint },
5327 { WM_GETTEXT, sent|parent|beginpaint|defwinproc|optional },
5331 static const struct message WmSetParentStyle[] = {
5332 { WM_STYLECHANGING, sent|parent },
5333 { WM_STYLECHANGED, sent|parent },
5337 static void test_paint_messages(void)
5343 HWND hparent, hchild;
5344 HRGN hrgn = CreateRectRgn( 0, 0, 0, 0 );
5345 HRGN hrgn2 = CreateRectRgn( 0, 0, 0, 0 );
5346 HWND hwnd = CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW,
5347 100, 100, 200, 200, 0, 0, 0, NULL);
5348 ok (hwnd != 0, "Failed to create overlapped window\n");
5350 ShowWindow( hwnd, SW_SHOW );
5351 UpdateWindow( hwnd );
5355 check_update_rgn( hwnd, 0 );
5356 SetRectRgn( hrgn, 10, 10, 20, 20 );
5357 ret = RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE );
5358 ok(ret, "RedrawWindow returned %d instead of TRUE\n", ret);
5359 check_update_rgn( hwnd, hrgn );
5360 SetRectRgn( hrgn2, 20, 20, 30, 30 );
5361 ret = RedrawWindow( hwnd, NULL, hrgn2, RDW_INVALIDATE );
5362 ok(ret, "RedrawWindow returned %d instead of TRUE\n", ret);
5363 CombineRgn( hrgn, hrgn, hrgn2, RGN_OR );
5364 check_update_rgn( hwnd, hrgn );
5365 /* validate everything */
5366 ret = RedrawWindow( hwnd, NULL, NULL, RDW_VALIDATE );
5367 ok(ret, "RedrawWindow returned %d instead of TRUE\n", ret);
5368 check_update_rgn( hwnd, 0 );
5370 /* test empty region */
5371 SetRectRgn( hrgn, 10, 10, 10, 15 );
5372 ret = RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE );
5373 ok(ret, "RedrawWindow returned %d instead of TRUE\n", ret);
5374 check_update_rgn( hwnd, 0 );
5375 /* test empty rect */
5376 SetRect( &rect, 10, 10, 10, 15 );
5377 ret = RedrawWindow( hwnd, &rect, NULL, RDW_INVALIDATE );
5378 ok(ret, "RedrawWindow returned %d instead of TRUE\n", ret);
5379 check_update_rgn( hwnd, 0 );
5381 /* flush pending messages */
5385 GetClientRect( hwnd, &rect );
5386 SetRectRgn( hrgn, 0, 0, rect.right - rect.left, rect.bottom - rect.top );
5387 /* MSDN: if hwnd parameter is NULL, InvalidateRect invalidates and redraws
5388 * all windows and sends WM_ERASEBKGND and WM_NCPAINT.
5390 trace("testing InvalidateRect(0, NULL, FALSE)\n");
5391 SetRectEmpty( &rect );
5392 ok(InvalidateRect(0, &rect, FALSE), "InvalidateRect(0, &rc, FALSE) should fail\n");
5393 check_update_rgn( hwnd, hrgn );
5394 ok_sequence( WmInvalidateErase, "InvalidateErase", FALSE );
5396 ok_sequence( WmPaint, "Paint", FALSE );
5397 RedrawWindow( hwnd, NULL, NULL, RDW_VALIDATE );
5398 check_update_rgn( hwnd, 0 );
5400 /* MSDN: if hwnd parameter is NULL, ValidateRect invalidates and redraws
5401 * all windows and sends WM_ERASEBKGND and WM_NCPAINT.
5403 trace("testing ValidateRect(0, NULL)\n");
5404 SetRectEmpty( &rect );
5405 ok(ValidateRect(0, &rect), "ValidateRect(0, &rc) should not fail\n");
5406 check_update_rgn( hwnd, hrgn );
5407 ok_sequence( WmInvalidateErase, "InvalidateErase", FALSE );
5409 ok_sequence( WmPaint, "Paint", FALSE );
5410 RedrawWindow( hwnd, NULL, NULL, RDW_VALIDATE );
5411 check_update_rgn( hwnd, 0 );
5413 trace("testing InvalidateRgn(0, NULL, FALSE)\n");
5414 SetLastError(0xdeadbeef);
5415 ok(!InvalidateRgn(0, NULL, FALSE), "InvalidateRgn(0, NULL, FALSE) should fail\n");
5416 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE || GetLastError() == 0xdeadbeef,
5417 "wrong error code %d\n", GetLastError());
5418 check_update_rgn( hwnd, 0 );
5420 ok_sequence( WmEmptySeq, "WmEmptySeq", FALSE );
5422 trace("testing ValidateRgn(0, NULL)\n");
5423 SetLastError(0xdeadbeef);
5424 ok(!ValidateRgn(0, NULL), "ValidateRgn(0, NULL) should fail\n");
5425 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "wrong error code %d\n", GetLastError());
5426 check_update_rgn( hwnd, 0 );
5428 ok_sequence( WmEmptySeq, "WmEmptySeq", FALSE );
5430 /* now with frame */
5431 SetRectRgn( hrgn, -5, -5, 20, 20 );
5433 /* flush pending messages */
5436 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME );
5437 ok_sequence( WmEmptySeq, "EmptySeq", FALSE );
5439 SetRectRgn( hrgn, 0, 0, 20, 20 ); /* GetUpdateRgn clips to client area */
5440 check_update_rgn( hwnd, hrgn );
5443 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME | RDW_ERASENOW );
5444 ok_sequence( WmInvalidateRgn, "InvalidateRgn", FALSE );
5447 RedrawWindow( hwnd, NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_ERASENOW );
5448 ok_sequence( WmInvalidateFull, "InvalidateFull", FALSE );
5450 GetClientRect( hwnd, &rect );
5451 SetRectRgn( hrgn, rect.left, rect.top, rect.right, rect.bottom );
5452 check_update_rgn( hwnd, hrgn );
5455 RedrawWindow( hwnd, NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_ERASE | RDW_ERASENOW );
5456 ok_sequence( WmInvalidateErase, "InvalidateErase", FALSE );
5459 RedrawWindow( hwnd, NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_ERASENOW | RDW_UPDATENOW );
5460 ok_sequence( WmInvalidatePaint, "InvalidatePaint", FALSE );
5461 check_update_rgn( hwnd, 0 );
5464 RedrawWindow( hwnd, NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_ERASE | RDW_UPDATENOW );
5465 ok_sequence( WmInvalidateErasePaint, "InvalidateErasePaint", FALSE );
5466 check_update_rgn( hwnd, 0 );
5469 SetRectRgn( hrgn, 0, 0, 100, 100 );
5470 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE );
5471 SetRectRgn( hrgn, 0, 0, 50, 100 );
5472 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE );
5473 SetRectRgn( hrgn, 50, 0, 100, 100 );
5474 check_update_rgn( hwnd, hrgn );
5475 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_ERASENOW );
5476 ok_sequence( WmEmptySeq, "EmptySeq", FALSE ); /* must not generate messages, everything is valid */
5477 check_update_rgn( hwnd, 0 );
5480 SetRectRgn( hrgn, 0, 0, 100, 100 );
5481 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_ERASE );
5482 SetRectRgn( hrgn, 0, 0, 100, 50 );
5483 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_ERASENOW );
5484 ok_sequence( WmErase, "Erase", FALSE );
5485 SetRectRgn( hrgn, 0, 50, 100, 100 );
5486 check_update_rgn( hwnd, hrgn );
5489 SetRectRgn( hrgn, 0, 0, 100, 100 );
5490 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_ERASE );
5491 SetRectRgn( hrgn, 0, 0, 50, 50 );
5492 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_NOERASE | RDW_UPDATENOW );
5493 ok_sequence( WmPaint, "Paint", FALSE );
5496 SetRectRgn( hrgn, -4, -4, -2, -2 );
5497 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME );
5498 SetRectRgn( hrgn, -200, -200, -198, -198 );
5499 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_NOFRAME | RDW_ERASENOW );
5500 ok_sequence( WmEmptySeq, "EmptySeq", FALSE );
5503 SetRectRgn( hrgn, -4, -4, -2, -2 );
5504 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME );
5505 SetRectRgn( hrgn, -4, -4, -3, -3 );
5506 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_NOFRAME );
5507 SetRectRgn( hrgn, 0, 0, 1, 1 );
5508 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_UPDATENOW );
5509 ok_sequence( WmPaint, "Paint", FALSE );
5512 SetRectRgn( hrgn, -4, -4, -1, -1 );
5513 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME );
5514 RedrawWindow( hwnd, NULL, 0, RDW_ERASENOW );
5515 /* make sure no WM_PAINT was generated */
5517 ok_sequence( WmInvalidateRgn, "InvalidateRgn", FALSE );
5520 SetRectRgn( hrgn, -4, -4, -1, -1 );
5521 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME );
5522 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE ))
5524 if (msg.hwnd == hwnd && msg.message == WM_PAINT)
5526 /* GetUpdateRgn must return empty region since only nonclient area is invalidated */
5527 INT ret = GetUpdateRgn( hwnd, hrgn, FALSE );
5528 ok( ret == NULLREGION, "Invalid GetUpdateRgn result %d\n", ret );
5529 ret = GetUpdateRect( hwnd, &rect, FALSE );
5530 ok( ret, "Invalid GetUpdateRect result %d\n", ret );
5531 /* this will send WM_NCPAINT and validate the non client area */
5532 ret = GetUpdateRect( hwnd, &rect, TRUE );
5533 ok( !ret, "Invalid GetUpdateRect result %d\n", ret );
5535 DispatchMessage( &msg );
5537 ok_sequence( WmGetUpdateRect, "GetUpdateRect", FALSE );
5539 DestroyWindow( hwnd );
5541 /* now test with a child window */
5543 hparent = CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW,
5544 100, 100, 200, 200, 0, 0, 0, NULL);
5545 ok (hparent != 0, "Failed to create parent window\n");
5547 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD | WS_VISIBLE | WS_BORDER,
5548 10, 10, 100, 100, hparent, 0, 0, NULL);
5549 ok (hchild != 0, "Failed to create child window\n");
5551 ShowWindow( hparent, SW_SHOW );
5552 UpdateWindow( hparent );
5553 UpdateWindow( hchild );
5556 log_all_parent_messages++;
5558 SetRect( &rect, 0, 0, 50, 50 );
5559 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
5560 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW | RDW_ALLCHILDREN );
5561 ok_sequence( WmInvalidateParentChild, "InvalidateParentChild", FALSE );
5563 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
5565 MapWindowPoints( hchild, hparent, &pt, 1 );
5566 SetRectRgn( hrgn, 0, 0, 50 - pt.x, 50 - pt.y );
5567 check_update_rgn( hchild, hrgn );
5568 SetRectRgn( hrgn, 0, 0, 50, 50 );
5569 check_update_rgn( hparent, hrgn );
5570 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW );
5571 ok_sequence( WmInvalidateParent, "InvalidateParent", FALSE );
5572 RedrawWindow( hchild, NULL, 0, RDW_ERASENOW );
5573 ok_sequence( WmEmptySeq, "EraseNow child", FALSE );
5576 ok_sequence( WmParentPaintNc, "WmParentPaintNc", FALSE );
5578 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_ALLCHILDREN );
5579 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW );
5580 ok_sequence( WmInvalidateParent, "InvalidateParent2", FALSE );
5581 RedrawWindow( hchild, NULL, 0, RDW_ERASENOW );
5582 ok_sequence( WmEmptySeq, "EraseNow child", FALSE );
5584 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE );
5585 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW | RDW_ALLCHILDREN );
5586 ok_sequence( WmInvalidateParentChild2, "InvalidateParentChild2", FALSE );
5588 SetWindowLong( hparent, GWL_STYLE, GetWindowLong(hparent,GWL_STYLE) | WS_CLIPCHILDREN );
5590 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_ALLCHILDREN );
5591 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW );
5592 ok_sequence( WmInvalidateParentChild, "InvalidateParentChild3", FALSE );
5594 /* flush all paint messages */
5598 /* RDW_UPDATENOW on child with WS_CLIPCHILDREN doesn't change corresponding parent area */
5599 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_ALLCHILDREN );
5600 SetRectRgn( hrgn, 0, 0, 50, 50 );
5601 check_update_rgn( hparent, hrgn );
5602 RedrawWindow( hchild, NULL, 0, RDW_UPDATENOW );
5603 ok_sequence( WmInvalidateErasePaint2, "WmInvalidateErasePaint2", FALSE );
5604 SetRectRgn( hrgn, 0, 0, 50, 50 );
5605 check_update_rgn( hparent, hrgn );
5607 /* flush all paint messages */
5609 SetWindowLong( hparent, GWL_STYLE, GetWindowLong(hparent,GWL_STYLE) & ~WS_CLIPCHILDREN );
5612 /* RDW_UPDATENOW on child without WS_CLIPCHILDREN will validate corresponding parent area */
5613 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
5614 SetRectRgn( hrgn, 0, 0, 50, 50 );
5615 check_update_rgn( hparent, hrgn );
5616 RedrawWindow( hchild, NULL, 0, RDW_UPDATENOW );
5617 ok_sequence( WmInvalidateErasePaint2, "WmInvalidateErasePaint2", FALSE );
5618 SetRectRgn( hrgn2, 10, 10, 50, 50 );
5619 CombineRgn( hrgn, hrgn, hrgn2, RGN_DIFF );
5620 check_update_rgn( hparent, hrgn );
5621 /* flush all paint messages */
5625 /* same as above but parent gets completely validated */
5626 SetRect( &rect, 20, 20, 30, 30 );
5627 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
5628 SetRectRgn( hrgn, 20, 20, 30, 30 );
5629 check_update_rgn( hparent, hrgn );
5630 RedrawWindow( hchild, NULL, 0, RDW_UPDATENOW );
5631 ok_sequence( WmInvalidateErasePaint2, "WmInvalidateErasePaint2", FALSE );
5632 check_update_rgn( hparent, 0 ); /* no update region */
5634 ok_sequence( WmEmptySeq, "WmEmpty", FALSE ); /* and no paint messages */
5636 /* make sure RDW_VALIDATE on child doesn't have the same effect */
5638 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
5639 SetRectRgn( hrgn, 20, 20, 30, 30 );
5640 check_update_rgn( hparent, hrgn );
5641 RedrawWindow( hchild, NULL, 0, RDW_VALIDATE | RDW_NOERASE );
5642 SetRectRgn( hrgn, 20, 20, 30, 30 );
5643 check_update_rgn( hparent, hrgn );
5645 /* same as above but normal WM_PAINT doesn't validate parent */
5647 SetRect( &rect, 20, 20, 30, 30 );
5648 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
5649 SetRectRgn( hrgn, 20, 20, 30, 30 );
5650 check_update_rgn( hparent, hrgn );
5651 /* no WM_PAINT in child while parent still pending */
5652 while (PeekMessage( &msg, hchild, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
5653 ok_sequence( WmEmptySeq, "No WM_PAINT", FALSE );
5654 while (PeekMessage( &msg, hparent, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
5655 ok_sequence( WmParentErasePaint, "WmParentErasePaint", FALSE );
5658 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
5659 /* no WM_PAINT in child while parent still pending */
5660 while (PeekMessage( &msg, hchild, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
5661 ok_sequence( WmEmptySeq, "No WM_PAINT", FALSE );
5662 RedrawWindow( hparent, &rect, 0, RDW_VALIDATE | RDW_NOERASE | RDW_NOCHILDREN );
5663 /* now that parent is valid child should get WM_PAINT */
5664 while (PeekMessage( &msg, hchild, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
5665 ok_sequence( WmInvalidateErasePaint2, "WmInvalidateErasePaint2", FALSE );
5666 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
5667 ok_sequence( WmEmptySeq, "No other message", FALSE );
5669 /* same thing with WS_CLIPCHILDREN in parent */
5671 SetWindowLong( hparent, GWL_STYLE, GetWindowLong(hparent,GWL_STYLE) | WS_CLIPCHILDREN );
5672 ok_sequence( WmSetParentStyle, "WmSetParentStyle", FALSE );
5673 /* changing style invalidates non client area, but we need to invalidate something else to see it */
5674 RedrawWindow( hparent, &rect, 0, RDW_UPDATENOW );
5675 ok_sequence( WmEmptySeq, "No message", FALSE );
5676 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_UPDATENOW );
5677 ok_sequence( WmParentOnlyNcPaint, "WmParentOnlyNcPaint", FALSE );
5680 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_ALLCHILDREN );
5681 SetRectRgn( hrgn, 20, 20, 30, 30 );
5682 check_update_rgn( hparent, hrgn );
5683 /* no WM_PAINT in child while parent still pending */
5684 while (PeekMessage( &msg, hchild, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
5685 ok_sequence( WmEmptySeq, "No WM_PAINT", FALSE );
5686 /* WM_PAINT in parent first */
5687 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
5688 ok_sequence( WmParentPaintNc, "WmParentPaintNc2", FALSE );
5690 /* no RDW_ERASE in parent still causes RDW_ERASE and RDW_FRAME in child */
5692 SetRect( &rect, 0, 0, 30, 30 );
5693 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ALLCHILDREN );
5694 SetRectRgn( hrgn, 0, 0, 30, 30 );
5695 check_update_rgn( hparent, hrgn );
5697 ok_sequence( WmParentPaintNc, "WmParentPaintNc3", FALSE );
5699 /* validate doesn't cause RDW_NOERASE or RDW_NOFRAME in child */
5701 SetRect( &rect, -10, 0, 30, 30 );
5702 RedrawWindow( hchild, &rect, 0, RDW_INVALIDATE | RDW_FRAME | RDW_ERASE );
5703 SetRect( &rect, 0, 0, 20, 20 );
5704 RedrawWindow( hparent, &rect, 0, RDW_VALIDATE | RDW_ALLCHILDREN );
5705 RedrawWindow( hparent, NULL, 0, RDW_UPDATENOW );
5706 ok_sequence( WmChildPaintNc, "WmChildPaintNc", FALSE );
5708 /* validate doesn't cause RDW_NOERASE or RDW_NOFRAME in child */
5710 SetRect( &rect, -10, 0, 30, 30 );
5711 RedrawWindow( hchild, &rect, 0, RDW_INVALIDATE | RDW_FRAME | RDW_ERASE );
5712 SetRect( &rect, 0, 0, 100, 100 );
5713 RedrawWindow( hparent, &rect, 0, RDW_VALIDATE | RDW_ALLCHILDREN );
5714 RedrawWindow( hparent, NULL, 0, RDW_UPDATENOW );
5715 ok_sequence( WmEmptySeq, "WmChildPaintNc2", FALSE );
5716 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW );
5717 ok_sequence( WmEmptySeq, "WmChildPaintNc3", FALSE );
5719 /* test RDW_INTERNALPAINT behavior */
5722 RedrawWindow( hparent, NULL, 0, RDW_INTERNALPAINT | RDW_NOCHILDREN );
5724 ok_sequence( WmParentOnlyPaint, "WmParentOnlyPaint", FALSE );
5726 RedrawWindow( hparent, NULL, 0, RDW_INTERNALPAINT | RDW_ALLCHILDREN );
5728 ok_sequence( WmParentPaint, "WmParentPaint", FALSE );
5730 RedrawWindow( hparent, NULL, 0, RDW_INTERNALPAINT );
5732 ok_sequence( WmParentOnlyPaint, "WmParentOnlyPaint", FALSE );
5734 assert( GetWindowLong(hparent, GWL_STYLE) & WS_CLIPCHILDREN );
5735 UpdateWindow( hparent );
5738 trace("testing SWP_FRAMECHANGED on parent with WS_CLIPCHILDREN\n");
5739 RedrawWindow( hchild, NULL, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
5740 SetWindowPos( hparent, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE |
5741 SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED );
5743 ok_sequence(WmSWP_FrameChanged_clip, "SetWindowPos:FrameChanged_clip", FALSE );
5745 UpdateWindow( hparent );
5748 trace("testing SWP_FRAMECHANGED|SWP_DEFERERASE on parent with WS_CLIPCHILDREN\n");
5749 RedrawWindow( hchild, NULL, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
5750 SetWindowPos( hparent, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_DEFERERASE |
5751 SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED );
5753 ok_sequence(WmSWP_FrameChangedDeferErase, "SetWindowPos:FrameChangedDeferErase", FALSE );
5755 SetWindowLong( hparent, GWL_STYLE, GetWindowLong(hparent,GWL_STYLE) & ~WS_CLIPCHILDREN );
5756 ok_sequence( WmSetParentStyle, "WmSetParentStyle", FALSE );
5757 RedrawWindow( hparent, NULL, 0, RDW_INTERNALPAINT );
5759 ok_sequence( WmParentPaint, "WmParentPaint", FALSE );
5761 assert( !(GetWindowLong(hparent, GWL_STYLE) & WS_CLIPCHILDREN) );
5762 UpdateWindow( hparent );
5765 trace("testing SWP_FRAMECHANGED on parent without WS_CLIPCHILDREN\n");
5766 RedrawWindow( hchild, NULL, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
5767 SetWindowPos( hparent, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE |
5768 SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED );
5770 ok_sequence(WmSWP_FrameChanged_noclip, "SetWindowPos:FrameChanged_noclip", FALSE );
5772 UpdateWindow( hparent );
5775 trace("testing SWP_FRAMECHANGED|SWP_DEFERERASE on parent without WS_CLIPCHILDREN\n");
5776 RedrawWindow( hchild, NULL, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
5777 SetWindowPos( hparent, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_DEFERERASE |
5778 SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED );
5780 ok_sequence(WmSWP_FrameChangedDeferErase, "SetWindowPos:FrameChangedDeferErase", FALSE );
5782 ok(GetWindowLong( hparent, GWL_STYLE ) & WS_VISIBLE, "parent should be visible\n");
5783 ok(GetWindowLong( hchild, GWL_STYLE ) & WS_VISIBLE, "child should be visible\n");
5785 UpdateWindow( hparent );
5788 trace("testing SetWindowPos(-10000, -10000) on child\n");
5789 SetWindowPos( hchild, 0, -10000, -10000, 0, 0, SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER );
5790 check_update_rgn( hchild, 0 );
5793 #if 0 /* this one doesn't pass under Wine yet */
5794 UpdateWindow( hparent );
5797 trace("testing ShowWindow(SW_MINIMIZE) on child\n");
5798 ShowWindow( hchild, SW_MINIMIZE );
5799 check_update_rgn( hchild, 0 );
5803 UpdateWindow( hparent );
5806 trace("testing SetWindowPos(-10000, -10000) on parent\n");
5807 SetWindowPos( hparent, 0, -10000, -10000, 0, 0, SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER );
5808 check_update_rgn( hparent, 0 );
5811 log_all_parent_messages--;
5812 DestroyWindow( hparent );
5813 ok(!IsWindow(hchild), "child must be destroyed with its parent\n");
5815 /* tests for moving windows off-screen (needs simple WS_POPUP windows) */
5817 hparent = CreateWindowExA(0, "TestParentClass", "Test parent", WS_POPUP | WS_VISIBLE,
5818 100, 100, 200, 200, 0, 0, 0, NULL);
5819 ok (hparent != 0, "Failed to create parent window\n");
5821 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD | WS_VISIBLE,
5822 10, 10, 100, 100, hparent, 0, 0, NULL);
5823 ok (hchild != 0, "Failed to create child window\n");
5825 ShowWindow( hparent, SW_SHOW );
5826 UpdateWindow( hparent );
5827 UpdateWindow( hchild );
5831 /* moving child outside of parent boundaries changes update region */
5832 SetRect( &rect, 0, 0, 40, 40 );
5833 RedrawWindow( hchild, &rect, 0, RDW_INVALIDATE | RDW_ERASE );
5834 SetRectRgn( hrgn, 0, 0, 40, 40 );
5835 check_update_rgn( hchild, hrgn );
5836 MoveWindow( hchild, -10, 10, 100, 100, FALSE );
5837 SetRectRgn( hrgn, 10, 0, 40, 40 );
5838 check_update_rgn( hchild, hrgn );
5839 MoveWindow( hchild, -10, -10, 100, 100, FALSE );
5840 SetRectRgn( hrgn, 10, 10, 40, 40 );
5841 check_update_rgn( hchild, hrgn );
5843 /* moving parent off-screen does too */
5844 SetRect( &rect, 0, 0, 100, 100 );
5845 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_NOCHILDREN );
5846 SetRectRgn( hrgn, 0, 0, 100, 100 );
5847 check_update_rgn( hparent, hrgn );
5848 SetRectRgn( hrgn, 10, 10, 40, 40 );
5849 check_update_rgn( hchild, hrgn );
5850 MoveWindow( hparent, -20, -20, 200, 200, FALSE );
5851 SetRectRgn( hrgn, 20, 20, 100, 100 );
5852 check_update_rgn( hparent, hrgn );
5853 SetRectRgn( hrgn, 30, 30, 40, 40 );
5854 check_update_rgn( hchild, hrgn );
5856 /* invalidated region is cropped by the parent rects */
5857 SetRect( &rect, 0, 0, 50, 50 );
5858 RedrawWindow( hchild, &rect, 0, RDW_INVALIDATE | RDW_ERASE );
5859 SetRectRgn( hrgn, 30, 30, 50, 50 );
5860 check_update_rgn( hchild, hrgn );
5862 DestroyWindow( hparent );
5863 ok(!IsWindow(hchild), "child must be destroyed with its parent\n");
5866 DeleteObject( hrgn );
5867 DeleteObject( hrgn2 );
5876 static DWORD WINAPI thread_proc(void *param)
5879 struct wnd_event *wnd_event = (struct wnd_event *)param;
5881 wnd_event->hwnd = CreateWindowExA(0, "TestWindowClass", "window caption text", WS_OVERLAPPEDWINDOW,
5882 100, 100, 200, 200, 0, 0, 0, NULL);
5883 ok(wnd_event->hwnd != 0, "Failed to create overlapped window\n");
5885 SetEvent(wnd_event->event);
5887 while (GetMessage(&msg, 0, 0, 0))
5889 TranslateMessage(&msg);
5890 DispatchMessage(&msg);
5893 ok(IsWindow(wnd_event->hwnd), "window should still exist\n");
5898 static void test_interthread_messages(void)
5905 int len, expected_len;
5906 struct wnd_event wnd_event;
5909 wnd_event.event = CreateEventW(NULL, 0, 0, NULL);
5910 if (!wnd_event.event)
5912 trace("skipping interthread message test under win9x\n");
5916 hThread = CreateThread(NULL, 0, thread_proc, &wnd_event, 0, &tid);
5917 ok(hThread != NULL, "CreateThread failed, error %d\n", GetLastError());
5919 ok(WaitForSingleObject(wnd_event.event, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
5921 CloseHandle(wnd_event.event);
5923 SetLastError(0xdeadbeef);
5924 ok(!DestroyWindow(wnd_event.hwnd), "DestroyWindow succeded\n");
5925 ok(GetLastError() == ERROR_ACCESS_DENIED || GetLastError() == 0xdeadbeef,
5926 "wrong error code %d\n", GetLastError());
5928 proc = (WNDPROC)GetWindowLongPtrA(wnd_event.hwnd, GWLP_WNDPROC);
5929 ok(proc != NULL, "GetWindowLongPtrA(GWLP_WNDPROC) error %d\n", GetLastError());
5931 expected_len = lstrlenA("window caption text");
5932 memset(buf, 0, sizeof(buf));
5933 SetLastError(0xdeadbeef);
5934 len = CallWindowProcA(proc, wnd_event.hwnd, WM_GETTEXT, sizeof(buf), (LPARAM)buf);
5935 ok(len == expected_len, "CallWindowProcA(WM_GETTEXT) error %d, len %d, expected len %d\n", GetLastError(), len, expected_len);
5936 ok(!lstrcmpA(buf, "window caption text"), "window text mismatch\n");
5938 msg.hwnd = wnd_event.hwnd;
5939 msg.message = WM_GETTEXT;
5940 msg.wParam = sizeof(buf);
5941 msg.lParam = (LPARAM)buf;
5942 memset(buf, 0, sizeof(buf));
5943 SetLastError(0xdeadbeef);
5944 len = DispatchMessageA(&msg);
5945 ok(!len && GetLastError() == ERROR_MESSAGE_SYNC_ONLY,
5946 "DispatchMessageA(WM_GETTEXT) succeded on another thread window: ret %d, error %d\n", len, GetLastError());
5948 /* the following test causes an exception in user.exe under win9x */
5949 msg.hwnd = wnd_event.hwnd;
5950 msg.message = WM_TIMER;
5952 msg.lParam = GetWindowLongPtrA(wnd_event.hwnd, GWLP_WNDPROC);
5953 SetLastError(0xdeadbeef);
5954 len = DispatchMessageA(&msg);
5955 ok(!len && GetLastError() == 0xdeadbeef,
5956 "DispatchMessageA(WM_TIMER) failed on another thread window: ret %d, error %d\n", len, GetLastError());
5958 ret = PostMessageA(wnd_event.hwnd, WM_QUIT, 0, 0);
5959 ok( ret, "PostMessageA(WM_QUIT) error %d\n", GetLastError());
5961 ok(WaitForSingleObject(hThread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
5962 CloseHandle(hThread);
5964 ok(!IsWindow(wnd_event.hwnd), "window should be destroyed on thread exit\n");
5968 static const struct message WmVkN[] = {
5969 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 1 }, /* XP */
5970 { WM_KEYDOWN, wparam|lparam, 'N', 1 },
5971 { WM_KEYDOWN, sent|wparam|lparam, 'N', 1 },
5972 { WM_CHAR, wparam|lparam, 'n', 1 },
5973 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1002,1), 0 },
5974 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xc0000001 }, /* XP */
5975 { WM_KEYUP, wparam|lparam, 'N', 0xc0000001 },
5976 { WM_KEYUP, sent|wparam|lparam, 'N', 0xc0000001 },
5979 static const struct message WmShiftVkN[] = {
5980 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_SHIFT, 1 }, /* XP */
5981 { WM_KEYDOWN, wparam|lparam, VK_SHIFT, 1 },
5982 { WM_KEYDOWN, sent|wparam|lparam, VK_SHIFT, 1 },
5983 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 1 }, /* XP */
5984 { WM_KEYDOWN, wparam|lparam, 'N', 1 },
5985 { WM_KEYDOWN, sent|wparam|lparam, 'N', 1 },
5986 { WM_CHAR, wparam|lparam, 'N', 1 },
5987 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1001,1), 0 },
5988 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xc0000001 }, /* XP */
5989 { WM_KEYUP, wparam|lparam, 'N', 0xc0000001 },
5990 { WM_KEYUP, sent|wparam|lparam, 'N', 0xc0000001 },
5991 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_SHIFT, 0xc0000001 }, /* XP */
5992 { WM_KEYUP, wparam|lparam, VK_SHIFT, 0xc0000001 },
5993 { WM_KEYUP, sent|wparam|lparam, VK_SHIFT, 0xc0000001 },
5996 static const struct message WmCtrlVkN[] = {
5997 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 1 }, /* XP */
5998 { WM_KEYDOWN, wparam|lparam, VK_CONTROL, 1 },
5999 { WM_KEYDOWN, sent|wparam|lparam, VK_CONTROL, 1 },
6000 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 1 }, /* XP */
6001 { WM_KEYDOWN, wparam|lparam, 'N', 1 },
6002 { WM_KEYDOWN, sent|wparam|lparam, 'N', 1 },
6003 { WM_CHAR, wparam|lparam, 0x000e, 1 },
6004 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1000,1), 0 },
6005 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xc0000001 }, /* XP */
6006 { WM_KEYUP, wparam|lparam, 'N', 0xc0000001 },
6007 { WM_KEYUP, sent|wparam|lparam, 'N', 0xc0000001 },
6008 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 0xc0000001 }, /* XP */
6009 { WM_KEYUP, wparam|lparam, VK_CONTROL, 0xc0000001 },
6010 { WM_KEYUP, sent|wparam|lparam, VK_CONTROL, 0xc0000001 },
6013 static const struct message WmCtrlVkN_2[] = {
6014 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 1 }, /* XP */
6015 { WM_KEYDOWN, wparam|lparam, VK_CONTROL, 1 },
6016 { WM_KEYDOWN, sent|wparam|lparam, VK_CONTROL, 1 },
6017 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 1 }, /* XP */
6018 { WM_KEYDOWN, wparam|lparam, 'N', 1 },
6019 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1000,1), 0 },
6020 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xc0000001 }, /* XP */
6021 { WM_KEYUP, wparam|lparam, 'N', 0xc0000001 },
6022 { WM_KEYUP, sent|wparam|lparam, 'N', 0xc0000001 },
6023 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 0xc0000001 }, /* XP */
6024 { WM_KEYUP, wparam|lparam, VK_CONTROL, 0xc0000001 },
6025 { WM_KEYUP, sent|wparam|lparam, VK_CONTROL, 0xc0000001 },
6028 static const struct message WmAltVkN[] = {
6029 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0x20000001 }, /* XP */
6030 { WM_SYSKEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
6031 { WM_SYSKEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
6032 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0x20000001 }, /* XP */
6033 { WM_SYSKEYDOWN, wparam|lparam, 'N', 0x20000001 },
6034 { WM_SYSKEYDOWN, sent|wparam|lparam, 'N', 0x20000001 },
6035 { WM_SYSCHAR, wparam|lparam, 'n', 0x20000001 },
6036 { WM_SYSCHAR, sent|wparam|lparam, 'n', 0x20000001 },
6037 { WM_SYSCOMMAND, sent|defwinproc|wparam|lparam, SC_KEYMENU, 'n' },
6038 { HCBT_SYSCOMMAND, hook },
6039 { WM_ENTERMENULOOP, sent|defwinproc|wparam|lparam, 0, 0 },
6040 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
6041 { 0x00AE, sent|defwinproc|optional }, /* XP */
6042 { WM_GETTEXT, sent|defwinproc|optional }, /* XP */
6043 { WM_INITMENU, sent|defwinproc },
6044 { EVENT_SYSTEM_MENUSTART, winevent_hook|wparam|lparam, OBJID_SYSMENU, 0 },
6045 { WM_MENUCHAR, sent|defwinproc|wparam, MAKEWPARAM('n',MF_SYSMENU) },
6046 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, 0, 0 },
6047 { WM_CAPTURECHANGED, sent|defwinproc },
6048 { WM_MENUSELECT, sent|defwinproc|wparam, MAKEWPARAM(0,0xffff) },
6049 { EVENT_SYSTEM_MENUEND, winevent_hook|wparam|lparam, OBJID_SYSMENU, 0 },
6050 { WM_EXITMENULOOP, sent|defwinproc },
6051 { WM_MENUSELECT, sent|defwinproc|wparam|optional, MAKEWPARAM(0,0xffff) }, /* Win95 bug */
6052 { WM_EXITMENULOOP, sent|defwinproc|optional }, /* Win95 bug */
6053 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xe0000001 }, /* XP */
6054 { WM_SYSKEYUP, wparam|lparam, 'N', 0xe0000001 },
6055 { WM_SYSKEYUP, sent|wparam|lparam, 'N', 0xe0000001 },
6056 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0xc0000001 }, /* XP */
6057 { WM_KEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
6058 { WM_KEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
6061 static const struct message WmAltVkN_2[] = {
6062 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0x20000001 }, /* XP */
6063 { WM_SYSKEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
6064 { WM_SYSKEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
6065 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0x20000001 }, /* XP */
6066 { WM_SYSKEYDOWN, wparam|lparam, 'N', 0x20000001 },
6067 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1003,1), 0 },
6068 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xe0000001 }, /* XP */
6069 { WM_SYSKEYUP, wparam|lparam, 'N', 0xe0000001 },
6070 { WM_SYSKEYUP, sent|wparam|lparam, 'N', 0xe0000001 },
6071 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0xc0000001 }, /* XP */
6072 { WM_KEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
6073 { WM_KEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
6076 static const struct message WmCtrlAltVkN[] = {
6077 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 1 }, /* XP */
6078 { WM_KEYDOWN, wparam|lparam, VK_CONTROL, 1 },
6079 { WM_KEYDOWN, sent|wparam|lparam, VK_CONTROL, 1 },
6080 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0x20000001 }, /* XP */
6081 { WM_KEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
6082 { WM_KEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
6083 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0x20000001 }, /* XP */
6084 { WM_KEYDOWN, wparam|lparam, 'N', 0x20000001 },
6085 { WM_KEYDOWN, sent|wparam|lparam, 'N', 0x20000001 },
6086 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xe0000001 }, /* XP */
6087 { WM_KEYUP, wparam|lparam, 'N', 0xe0000001 },
6088 { WM_KEYUP, sent|wparam|lparam, 'N', 0xe0000001 },
6089 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0xc0000001 }, /* XP */
6090 { WM_KEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
6091 { WM_KEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
6092 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 0xc0000001 }, /* XP */
6093 { WM_KEYUP, wparam|lparam, VK_CONTROL, 0xc0000001 },
6094 { WM_KEYUP, sent|wparam|lparam, VK_CONTROL, 0xc0000001 },
6097 static const struct message WmCtrlShiftVkN[] = {
6098 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 1 }, /* XP */
6099 { WM_KEYDOWN, wparam|lparam, VK_CONTROL, 1 },
6100 { WM_KEYDOWN, sent|wparam|lparam, VK_CONTROL, 1 },
6101 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_SHIFT, 1 }, /* XP */
6102 { WM_KEYDOWN, wparam|lparam, VK_SHIFT, 1 },
6103 { WM_KEYDOWN, sent|wparam|lparam, VK_SHIFT, 1 },
6104 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 1 }, /* XP */
6105 { WM_KEYDOWN, wparam|lparam, 'N', 1 },
6106 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1004,1), 0 },
6107 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xc0000001 }, /* XP */
6108 { WM_KEYUP, wparam|lparam, 'N', 0xc0000001 },
6109 { WM_KEYUP, sent|wparam|lparam, 'N', 0xc0000001 },
6110 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_SHIFT, 0xc0000001 }, /* XP */
6111 { WM_KEYUP, wparam|lparam, VK_SHIFT, 0xc0000001 },
6112 { WM_KEYUP, sent|wparam|lparam, VK_SHIFT, 0xc0000001 },
6113 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 0xc0000001 }, /* XP */
6114 { WM_KEYUP, wparam|lparam, VK_CONTROL, 0xc0000001 },
6115 { WM_KEYUP, sent|wparam|lparam, VK_CONTROL, 0xc0000001 },
6118 static const struct message WmCtrlAltShiftVkN[] = {
6119 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 1 }, /* XP */
6120 { WM_KEYDOWN, wparam|lparam, VK_CONTROL, 1 },
6121 { WM_KEYDOWN, sent|wparam|lparam, VK_CONTROL, 1 },
6122 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0x20000001 }, /* XP */
6123 { WM_KEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
6124 { WM_KEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
6125 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_SHIFT, 0x20000001 }, /* XP */
6126 { WM_KEYDOWN, wparam|lparam, VK_SHIFT, 0x20000001 },
6127 { WM_KEYDOWN, sent|wparam|lparam, VK_SHIFT, 0x20000001 },
6128 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0x20000001 }, /* XP */
6129 { WM_KEYDOWN, wparam|lparam, 'N', 0x20000001 },
6130 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1005,1), 0 },
6131 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xe0000001 }, /* XP */
6132 { WM_KEYUP, wparam|lparam, 'N', 0xe0000001 },
6133 { WM_KEYUP, sent|wparam|lparam, 'N', 0xe0000001 },
6134 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_SHIFT, 0xe0000001 }, /* XP */
6135 { WM_KEYUP, wparam|lparam, VK_SHIFT, 0xe0000001 },
6136 { WM_KEYUP, sent|wparam|lparam, VK_SHIFT, 0xe0000001 },
6137 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0xc0000001 }, /* XP */
6138 { WM_KEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
6139 { WM_KEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
6140 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 0xc0000001 }, /* XP */
6141 { WM_KEYUP, wparam|lparam, VK_CONTROL, 0xc0000001 },
6142 { WM_KEYUP, sent|wparam|lparam, VK_CONTROL, 0xc0000001 },
6145 static const struct message WmAltPressRelease[] = {
6146 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0x20000001 }, /* XP */
6147 { WM_SYSKEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
6148 { WM_SYSKEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
6149 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0xc0000001 }, /* XP */
6150 { WM_SYSKEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
6151 { WM_SYSKEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
6152 { WM_SYSCOMMAND, sent|defwinproc|wparam|lparam, SC_KEYMENU, 0 },
6153 { HCBT_SYSCOMMAND, hook },
6154 { WM_ENTERMENULOOP, sent|defwinproc|wparam|lparam, 0, 0 },
6155 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
6156 { WM_INITMENU, sent|defwinproc },
6157 { EVENT_SYSTEM_MENUSTART, winevent_hook|wparam|lparam, OBJID_SYSMENU, 0 },
6158 { WM_MENUSELECT, sent|defwinproc|wparam, MAKEWPARAM(0,MF_SYSMENU|MF_POPUP|MF_HILITE) },
6159 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_SYSMENU, 1 },
6161 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0x30000001 }, /* XP */
6163 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_SYSMENU, 0 },
6164 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, 0, 0, },
6165 { WM_CAPTURECHANGED, sent|defwinproc },
6166 { WM_MENUSELECT, sent|defwinproc|wparam|optional, MAKEWPARAM(0,0xffff) },
6167 { EVENT_SYSTEM_MENUEND, winevent_hook|wparam|lparam, OBJID_SYSMENU, 0 },
6168 { WM_EXITMENULOOP, sent|defwinproc },
6169 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0xc0000001 }, /* XP */
6170 { WM_SYSKEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
6171 { WM_SYSKEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
6174 static const struct message WmAltMouseButton[] = {
6175 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0x20000001 }, /* XP */
6176 { WM_SYSKEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
6177 { WM_SYSKEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
6178 { WM_MOUSEMOVE, wparam|optional, 0, 0 },
6179 { WM_MOUSEMOVE, sent|wparam|optional, 0, 0 },
6180 { WM_LBUTTONDOWN, wparam, MK_LBUTTON, 0 },
6181 { WM_LBUTTONDOWN, sent|wparam, MK_LBUTTON, 0 },
6182 { WM_LBUTTONUP, wparam, 0, 0 },
6183 { WM_LBUTTONUP, sent|wparam, 0, 0 },
6184 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0xc0000001 }, /* XP */
6185 { WM_SYSKEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
6186 { WM_SYSKEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
6189 static const struct message WmF1Seq[] = {
6190 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_F1, 1 }, /* XP */
6191 { WM_KEYDOWN, wparam|lparam, VK_F1, 1 },
6192 { WM_KEYDOWN, sent|wparam|lparam, VK_F1, 0x00000001 },
6193 { WM_KEYF1, wparam|lparam, 0, 0 },
6194 { WM_KEYF1, sent|wparam|lparam, 0, 0 },
6195 { WM_HELP, sent|defwinproc },
6196 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_F1, 0xc0000001 }, /* XP */
6197 { WM_KEYUP, wparam|lparam, VK_F1, 0xc0000001 },
6198 { WM_KEYUP, sent|wparam|lparam, VK_F1, 0xc0000001 },
6201 static const struct message WmVkAppsSeq[] = {
6202 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_APPS, 1 }, /* XP */
6203 { WM_KEYDOWN, wparam|lparam, VK_APPS, 1 },
6204 { WM_KEYDOWN, sent|wparam|lparam, VK_APPS, 0x00000001 },
6205 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_APPS, 0xc0000001 }, /* XP */
6206 { WM_KEYUP, wparam|lparam, VK_APPS, 0xc0000001 },
6207 { WM_KEYUP, sent|wparam|lparam, VK_APPS, 0xc0000001 },
6208 { WM_CONTEXTMENU, lparam, /*hwnd*/0, (LPARAM)-1 },
6209 { WM_CONTEXTMENU, sent|lparam, /*hwnd*/0, (LPARAM)-1 },
6213 static void pump_msg_loop(HWND hwnd, HACCEL hAccel)
6217 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE))
6219 struct message log_msg;
6221 trace("accel: %p, %04x, %08lx, %08lx\n", msg.hwnd, msg.message, msg.wParam, msg.lParam);
6223 /* ignore some unwanted messages */
6224 if (msg.message == WM_MOUSEMOVE ||
6225 msg.message == WM_GETICON ||
6226 msg.message == WM_DEVICECHANGE)
6229 log_msg.message = msg.message;
6230 log_msg.flags = wparam|lparam;
6231 log_msg.wParam = msg.wParam;
6232 log_msg.lParam = msg.lParam;
6233 add_message(&log_msg);
6235 if (!hAccel || !TranslateAccelerator(hwnd, hAccel, &msg))
6237 TranslateMessage(&msg);
6238 DispatchMessage(&msg);
6243 static void test_accelerators(void)
6248 HWND hwnd = CreateWindowExA(0, "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW | WS_VISIBLE,
6249 100, 100, 200, 200, 0, 0, 0, NULL);
6258 ok(GetFocus() == hwnd, "wrong focus window %p\n", GetFocus());
6260 state = GetKeyState(VK_SHIFT);
6261 ok(!(state & 0x8000), "wrong Shift state %04x\n", state);
6262 state = GetKeyState(VK_CAPITAL);
6263 ok(state == 0, "wrong CapsLock state %04x\n", state);
6265 hAccel = LoadAccelerators(GetModuleHandleA(0), MAKEINTRESOURCE(1));
6266 assert(hAccel != 0);
6268 pump_msg_loop(hwnd, 0);
6271 trace("testing VK_N press/release\n");
6273 keybd_event('N', 0, 0, 0);
6274 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
6275 pump_msg_loop(hwnd, hAccel);
6276 ok_sequence(WmVkN, "VK_N press/release", FALSE);
6278 trace("testing Shift+VK_N press/release\n");
6280 keybd_event(VK_SHIFT, 0, 0, 0);
6281 keybd_event('N', 0, 0, 0);
6282 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
6283 keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
6284 pump_msg_loop(hwnd, hAccel);
6285 ok_sequence(WmShiftVkN, "Shift+VK_N press/release", FALSE);
6287 trace("testing Ctrl+VK_N press/release\n");
6289 keybd_event(VK_CONTROL, 0, 0, 0);
6290 keybd_event('N', 0, 0, 0);
6291 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
6292 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
6293 pump_msg_loop(hwnd, hAccel);
6294 ok_sequence(WmCtrlVkN, "Ctrl+VK_N press/release", FALSE);
6296 trace("testing Alt+VK_N press/release\n");
6298 keybd_event(VK_MENU, 0, 0, 0);
6299 keybd_event('N', 0, 0, 0);
6300 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
6301 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
6302 pump_msg_loop(hwnd, hAccel);
6303 ok_sequence(WmAltVkN, "Alt+VK_N press/release", FALSE);
6305 trace("testing Ctrl+Alt+VK_N press/release 1\n");
6307 keybd_event(VK_CONTROL, 0, 0, 0);
6308 keybd_event(VK_MENU, 0, 0, 0);
6309 keybd_event('N', 0, 0, 0);
6310 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
6311 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
6312 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
6313 pump_msg_loop(hwnd, hAccel);
6314 ok_sequence(WmCtrlAltVkN, "Ctrl+Alt+VK_N press/release 1", FALSE);
6316 ret = DestroyAcceleratorTable(hAccel);
6317 ok( ret, "DestroyAcceleratorTable error %d\n", GetLastError());
6319 hAccel = LoadAccelerators(GetModuleHandleA(0), MAKEINTRESOURCE(2));
6320 assert(hAccel != 0);
6322 trace("testing VK_N press/release\n");
6324 keybd_event('N', 0, 0, 0);
6325 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
6326 pump_msg_loop(hwnd, hAccel);
6327 ok_sequence(WmVkN, "VK_N press/release", FALSE);
6329 trace("testing Shift+VK_N press/release\n");
6331 keybd_event(VK_SHIFT, 0, 0, 0);
6332 keybd_event('N', 0, 0, 0);
6333 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
6334 keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
6335 pump_msg_loop(hwnd, hAccel);
6336 ok_sequence(WmShiftVkN, "Shift+VK_N press/release", FALSE);
6338 trace("testing Ctrl+VK_N press/release 2\n");
6340 keybd_event(VK_CONTROL, 0, 0, 0);
6341 keybd_event('N', 0, 0, 0);
6342 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
6343 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
6344 pump_msg_loop(hwnd, hAccel);
6345 ok_sequence(WmCtrlVkN_2, "Ctrl+VK_N press/release 2", FALSE);
6347 trace("testing Alt+VK_N press/release 2\n");
6349 keybd_event(VK_MENU, 0, 0, 0);
6350 keybd_event('N', 0, 0, 0);
6351 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
6352 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
6353 pump_msg_loop(hwnd, hAccel);
6354 ok_sequence(WmAltVkN_2, "Alt+VK_N press/release 2", FALSE);
6356 trace("testing Ctrl+Alt+VK_N press/release 2\n");
6358 keybd_event(VK_CONTROL, 0, 0, 0);
6359 keybd_event(VK_MENU, 0, 0, 0);
6360 keybd_event('N', 0, 0, 0);
6361 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
6362 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
6363 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
6364 pump_msg_loop(hwnd, hAccel);
6365 ok_sequence(WmCtrlAltVkN, "Ctrl+Alt+VK_N press/release 2", FALSE);
6367 trace("testing Ctrl+Shift+VK_N press/release\n");
6369 keybd_event(VK_CONTROL, 0, 0, 0);
6370 keybd_event(VK_SHIFT, 0, 0, 0);
6371 keybd_event('N', 0, 0, 0);
6372 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
6373 keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
6374 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
6375 pump_msg_loop(hwnd, hAccel);
6376 ok_sequence(WmCtrlShiftVkN, "Ctrl+Shift+VK_N press/release", FALSE);
6378 trace("testing Ctrl+Alt+Shift+VK_N press/release\n");
6380 keybd_event(VK_CONTROL, 0, 0, 0);
6381 keybd_event(VK_MENU, 0, 0, 0);
6382 keybd_event(VK_SHIFT, 0, 0, 0);
6383 keybd_event('N', 0, 0, 0);
6384 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
6385 keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
6386 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
6387 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
6388 pump_msg_loop(hwnd, hAccel);
6389 ok_sequence(WmCtrlAltShiftVkN, "Ctrl+Alt+Shift+VK_N press/release", FALSE);
6391 ret = DestroyAcceleratorTable(hAccel);
6392 ok( ret, "DestroyAcceleratorTable error %d\n", GetLastError());
6394 trace("testing Alt press/release\n");
6396 keybd_event(VK_MENU, 0, 0, 0);
6397 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
6398 keybd_event(VK_MENU, 0, 0, 0);
6399 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
6400 pump_msg_loop(hwnd, 0);
6401 /* this test doesn't pass in Wine for managed windows */
6402 ok_sequence(WmAltPressRelease, "Alt press/release", TRUE);
6404 trace("testing Alt+MouseButton press/release\n");
6405 /* first, move mouse pointer inside of the window client area */
6406 GetClientRect(hwnd, &rc);
6407 MapWindowPoints(hwnd, 0, (LPPOINT)&rc, 2);
6408 rc.left += (rc.right - rc.left)/2;
6409 rc.top += (rc.bottom - rc.top)/2;
6410 SetCursorPos(rc.left, rc.top);
6414 keybd_event(VK_MENU, 0, 0, 0);
6415 mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
6416 mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
6417 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
6418 pump_msg_loop(hwnd, 0);
6419 ok_sequence(WmAltMouseButton, "Alt+MouseButton press/release", FALSE);
6421 trace("testing VK_F1 press/release\n");
6422 keybd_event(VK_F1, 0, 0, 0);
6423 keybd_event(VK_F1, 0, KEYEVENTF_KEYUP, 0);
6424 pump_msg_loop(hwnd, 0);
6425 ok_sequence(WmF1Seq, "F1 press/release", FALSE);
6427 trace("testing VK_APPS press/release\n");
6428 keybd_event(VK_APPS, 0, 0, 0);
6429 keybd_event(VK_APPS, 0, KEYEVENTF_KEYUP, 0);
6430 pump_msg_loop(hwnd, 0);
6431 ok_sequence(WmVkAppsSeq, "VK_APPS press/release", FALSE);
6433 DestroyWindow(hwnd);
6436 /************* window procedures ********************/
6438 static LRESULT MsgCheckProc (BOOL unicode, HWND hwnd, UINT message,
6439 WPARAM wParam, LPARAM lParam)
6441 static long defwndproc_counter = 0;
6442 static long beginpaint_counter = 0;
6446 trace("%p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
6448 /* explicitly ignore WM_GETICON message */
6449 if (message == WM_GETICON) return 0;
6455 LONG style = GetWindowLongA(hwnd, GWL_STYLE);
6456 ok((BOOL)wParam == !(style & WS_DISABLED),
6457 "wrong WS_DISABLED state: %ld != %d\n", wParam, !(style & WS_DISABLED));
6461 case WM_CAPTURECHANGED:
6462 if (test_DestroyWindow_flag)
6464 DWORD style = GetWindowLongA(hwnd, GWL_STYLE);
6465 if (style & WS_CHILD)
6466 lParam = GetWindowLongPtrA(hwnd, GWLP_ID);
6467 else if (style & WS_POPUP)
6468 lParam = WND_POPUP_ID;
6470 lParam = WND_PARENT_ID;
6478 ok(!GetWindow(hwnd, GW_CHILD), "children should be unlinked at this point\n");
6479 capture = GetCapture();
6482 ok(capture == hwnd, "capture should NOT be released at this point (capture %p)\n", capture);
6483 trace("current capture %p, releasing...\n", capture);
6490 ok(pGetAncestor(hwnd, GA_PARENT) != 0, "parent should NOT be unlinked at this point\n");
6491 if (test_DestroyWindow_flag)
6493 DWORD style = GetWindowLongA(hwnd, GWL_STYLE);
6494 if (style & WS_CHILD)
6495 lParam = GetWindowLongPtrA(hwnd, GWLP_ID);
6496 else if (style & WS_POPUP)
6497 lParam = WND_POPUP_ID;
6499 lParam = WND_PARENT_ID;
6503 /* test_accelerators() depends on this */
6510 case WM_DEVICECHANGE:
6513 case WM_WINDOWPOSCHANGING:
6514 case WM_WINDOWPOSCHANGED:
6516 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
6518 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
6519 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
6520 winpos->hwnd, winpos->hwndInsertAfter,
6521 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
6522 dump_winpos_flags(winpos->flags);
6524 /* Log only documented flags, win2k uses 0x1000 and 0x2000
6525 * in the high word for internal purposes
6527 wParam = winpos->flags & 0xffff;
6528 /* We are not interested in the flags that don't match under XP and Win9x */
6529 wParam &= ~(SWP_NOZORDER);
6534 msg.message = message;
6535 msg.flags = sent|wparam|lparam;
6536 if (defwndproc_counter) msg.flags |= defwinproc;
6537 if (beginpaint_counter) msg.flags |= beginpaint;
6538 msg.wParam = wParam;
6539 msg.lParam = lParam;
6542 if (message == WM_GETMINMAXINFO && (GetWindowLongA(hwnd, GWL_STYLE) & WS_CHILD))
6544 HWND parent = GetParent(hwnd);
6546 MINMAXINFO *minmax = (MINMAXINFO *)lParam;
6548 GetClientRect(parent, &rc);
6549 trace("parent %p client size = (%d x %d)\n", parent, rc.right, rc.bottom);
6551 trace("ptReserved = (%d,%d)\n"
6552 "ptMaxSize = (%d,%d)\n"
6553 "ptMaxPosition = (%d,%d)\n"
6554 "ptMinTrackSize = (%d,%d)\n"
6555 "ptMaxTrackSize = (%d,%d)\n",
6556 minmax->ptReserved.x, minmax->ptReserved.y,
6557 minmax->ptMaxSize.x, minmax->ptMaxSize.y,
6558 minmax->ptMaxPosition.x, minmax->ptMaxPosition.y,
6559 minmax->ptMinTrackSize.x, minmax->ptMinTrackSize.y,
6560 minmax->ptMaxTrackSize.x, minmax->ptMaxTrackSize.y);
6562 ok(minmax->ptMaxSize.x == rc.right, "default width of maximized child %d != %d\n",
6563 minmax->ptMaxSize.x, rc.right);
6564 ok(minmax->ptMaxSize.y == rc.bottom, "default height of maximized child %d != %d\n",
6565 minmax->ptMaxSize.y, rc.bottom);
6568 if (message == WM_PAINT)
6571 beginpaint_counter++;
6572 BeginPaint( hwnd, &ps );
6573 beginpaint_counter--;
6574 EndPaint( hwnd, &ps );
6578 defwndproc_counter++;
6579 ret = unicode ? DefWindowProcW(hwnd, message, wParam, lParam)
6580 : DefWindowProcA(hwnd, message, wParam, lParam);
6581 defwndproc_counter--;
6586 static LRESULT WINAPI MsgCheckProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
6588 return MsgCheckProc (FALSE, hwnd, message, wParam, lParam);
6591 static LRESULT WINAPI MsgCheckProcW(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
6593 return MsgCheckProc (TRUE, hwnd, message, wParam, lParam);
6596 static LRESULT WINAPI PopupMsgCheckProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
6598 static long defwndproc_counter = 0;
6602 trace("popup: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
6604 /* explicitly ignore WM_GETICON message */
6605 if (message == WM_GETICON) return 0;
6607 msg.message = message;
6608 msg.flags = sent|wparam|lparam;
6609 if (defwndproc_counter) msg.flags |= defwinproc;
6610 msg.wParam = wParam;
6611 msg.lParam = lParam;
6614 if (message == WM_CREATE)
6616 DWORD style = GetWindowLongA(hwnd, GWL_STYLE) | WS_VISIBLE;
6617 SetWindowLongA(hwnd, GWL_STYLE, style);
6620 defwndproc_counter++;
6621 ret = DefWindowProcA(hwnd, message, wParam, lParam);
6622 defwndproc_counter--;
6627 static LRESULT WINAPI ParentMsgCheckProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
6629 static long defwndproc_counter = 0;
6630 static long beginpaint_counter = 0;
6633 LPARAM logged_lParam;
6635 trace("parent: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
6637 /* explicitly ignore WM_GETICON message */
6638 if (message == WM_GETICON) return 0;
6640 logged_lParam=lParam;
6641 if (log_all_parent_messages ||
6642 message == WM_PARENTNOTIFY || message == WM_CANCELMODE ||
6643 message == WM_SETFOCUS || message == WM_KILLFOCUS ||
6644 message == WM_ENABLE || message == WM_ENTERIDLE ||
6645 message == WM_DRAWITEM ||
6646 message == WM_IME_SETCONTEXT)
6660 INT ret = GetClipBox((HDC)wParam, &rc);
6662 trace("WM_ERASEBKGND: GetClipBox()=%d, (%d,%d-%d,%d)\n",
6663 ret, rc.left, rc.top, rc.right, rc.bottom);
6667 case WM_WINDOWPOSCHANGING:
6668 case WM_WINDOWPOSCHANGED:
6670 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
6672 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
6673 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
6674 winpos->hwnd, winpos->hwndInsertAfter,
6675 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
6676 dump_winpos_flags(winpos->flags);
6678 /* Log only documented flags, win2k uses 0x1000 and 0x2000
6679 * in the high word for internal purposes
6681 wParam = winpos->flags & 0xffff;
6682 /* We are not interested in the flags that don't match under XP and Win9x */
6683 wParam &= ~(SWP_NOZORDER);
6689 /* encode DRAWITEMSTRUCT into an LPARAM */
6690 DRAW_ITEM_STRUCT di;
6691 DRAWITEMSTRUCT *dis = (DRAWITEMSTRUCT *)lParam;
6693 trace("WM_DRAWITEM: type %x, ctl_id %x, item_id %x, action %x, state %x\n",
6694 dis->CtlType, dis->CtlID, dis->itemID, dis->itemAction, dis->itemState);
6696 di.u.item.type = dis->CtlType;
6697 di.u.item.ctl_id = dis->CtlID;
6698 di.u.item.item_id = dis->itemID;
6699 di.u.item.action = dis->itemAction;
6700 di.u.item.state = dis->itemState;
6702 logged_lParam = di.u.lp;
6707 msg.message = message;
6708 msg.flags = sent|parent|wparam|lparam;
6709 if (defwndproc_counter) msg.flags |= defwinproc;
6710 if (beginpaint_counter) msg.flags |= beginpaint;
6711 msg.wParam = wParam;
6712 msg.lParam = logged_lParam;
6716 if (message == WM_PAINT)
6719 beginpaint_counter++;
6720 BeginPaint( hwnd, &ps );
6721 beginpaint_counter--;
6722 EndPaint( hwnd, &ps );
6726 defwndproc_counter++;
6727 ret = DefWindowProcA(hwnd, message, wParam, lParam);
6728 defwndproc_counter--;
6733 static LRESULT WINAPI TestDlgProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
6735 static long defwndproc_counter = 0;
6739 trace("dialog: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
6741 /* explicitly ignore WM_GETICON message */
6742 if (message == WM_GETICON) return 0;
6746 DefDlgProcA(hwnd, DM_SETDEFID, 1, 0);
6747 ret = DefDlgProcA(hwnd, DM_GETDEFID, 0, 0);
6748 if (after_end_dialog)
6749 ok( ret == 0, "DM_GETDEFID should return 0 after EndDialog, got %lx\n", ret );
6751 ok(HIWORD(ret) == DC_HASDEFID, "DM_GETDEFID should return DC_HASDEFID, got %lx\n", ret);
6756 case WM_WINDOWPOSCHANGING:
6757 case WM_WINDOWPOSCHANGED:
6759 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
6761 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
6762 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
6763 winpos->hwnd, winpos->hwndInsertAfter,
6764 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
6765 dump_winpos_flags(winpos->flags);
6767 /* Log only documented flags, win2k uses 0x1000 and 0x2000
6768 * in the high word for internal purposes
6770 wParam = winpos->flags & 0xffff;
6771 /* We are not interested in the flags that don't match under XP and Win9x */
6772 wParam &= ~(SWP_NOZORDER);
6777 msg.message = message;
6778 msg.flags = sent|wparam|lparam;
6779 if (defwndproc_counter) msg.flags |= defwinproc;
6780 msg.wParam = wParam;
6781 msg.lParam = lParam;
6784 defwndproc_counter++;
6785 ret = DefDlgProcA(hwnd, message, wParam, lParam);
6786 defwndproc_counter--;
6791 static void dump_winpos_flags(UINT flags)
6793 if (!winetest_debug) return;
6795 if (flags & SWP_SHOWWINDOW) printf("|SWP_SHOWWINDOW");
6796 if (flags & SWP_HIDEWINDOW) printf("|SWP_HIDEWINDOW");
6797 if (flags & SWP_NOACTIVATE) printf("|SWP_NOACTIVATE");
6798 if (flags & SWP_FRAMECHANGED) printf("|SWP_FRAMECHANGED");
6799 if (flags & SWP_NOCOPYBITS) printf("|SWP_NOCOPYBITS");
6800 if (flags & SWP_NOOWNERZORDER) printf("|SWP_NOOWNERZORDER");
6801 if (flags & SWP_NOSENDCHANGING) printf("|SWP_NOSENDCHANGING");
6802 if (flags & SWP_DEFERERASE) printf("|SWP_DEFERERASE");
6803 if (flags & SWP_ASYNCWINDOWPOS) printf("|SWP_ASYNCWINDOWPOS");
6804 if (flags & SWP_NOZORDER) printf("|SWP_NOZORDER");
6805 if (flags & SWP_NOREDRAW) printf("|SWP_NOREDRAW");
6806 if (flags & SWP_NOSIZE) printf("|SWP_NOSIZE");
6807 if (flags & SWP_NOMOVE) printf("|SWP_NOMOVE");
6808 if (flags & SWP_NOCLIENTSIZE) printf("|SWP_NOCLIENTSIZE");
6809 if (flags & SWP_NOCLIENTMOVE) printf("|SWP_NOCLIENTMOVE");
6811 #define DUMPED_FLAGS \
6817 SWP_FRAMECHANGED | \
6821 SWP_NOOWNERZORDER | \
6822 SWP_NOSENDCHANGING | \
6824 SWP_ASYNCWINDOWPOS | \
6825 SWP_NOCLIENTSIZE | \
6828 if(flags & ~DUMPED_FLAGS) printf("|0x%04x", flags & ~DUMPED_FLAGS);
6833 static LRESULT WINAPI ShowWindowProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
6835 static long defwndproc_counter = 0;
6839 /* log only specific messages we are interested in */
6842 #if 0 /* probably log these as well */
6848 trace("WM_SHOWWINDOW %ld\n", wParam);
6851 trace("WM_SIZE %ld\n", wParam);
6856 case WM_GETMINMAXINFO:
6857 trace("WM_GETMINMAXINFO\n");
6860 case WM_WINDOWPOSCHANGING:
6861 case WM_WINDOWPOSCHANGED:
6863 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
6865 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
6866 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
6867 winpos->hwnd, winpos->hwndInsertAfter,
6868 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
6870 dump_winpos_flags(winpos->flags);
6872 /* Log only documented flags, win2k uses 0x1000 and 0x2000
6873 * in the high word for internal purposes
6875 wParam = winpos->flags & 0xffff;
6876 /* We are not interested in the flags that don't match under XP and Win9x */
6877 wParam &= ~(SWP_NOZORDER);
6881 default: /* ignore */
6882 /*trace("showwindow: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);*/
6883 return DefWindowProcA(hwnd, message, wParam, lParam);
6886 msg.message = message;
6887 msg.flags = sent|wparam|lparam;
6888 if (defwndproc_counter) msg.flags |= defwinproc;
6889 msg.wParam = wParam;
6890 msg.lParam = lParam;
6893 defwndproc_counter++;
6894 ret = DefWindowProcA(hwnd, message, wParam, lParam);
6895 defwndproc_counter--;
6900 static BOOL RegisterWindowClasses(void)
6906 cls.lpfnWndProc = MsgCheckProcA;
6909 cls.hInstance = GetModuleHandleA(0);
6911 cls.hCursor = LoadCursorA(0, (LPSTR)IDC_ARROW);
6912 cls.hbrBackground = GetStockObject(WHITE_BRUSH);
6913 cls.lpszMenuName = NULL;
6914 cls.lpszClassName = "TestWindowClass";
6915 if(!RegisterClassA(&cls)) return FALSE;
6917 cls.lpfnWndProc = ShowWindowProcA;
6918 cls.lpszClassName = "ShowWindowClass";
6919 if(!RegisterClassA(&cls)) return FALSE;
6921 cls.lpfnWndProc = PopupMsgCheckProcA;
6922 cls.lpszClassName = "TestPopupClass";
6923 if(!RegisterClassA(&cls)) return FALSE;
6925 cls.lpfnWndProc = ParentMsgCheckProcA;
6926 cls.lpszClassName = "TestParentClass";
6927 if(!RegisterClassA(&cls)) return FALSE;
6929 cls.lpfnWndProc = DefWindowProcA;
6930 cls.lpszClassName = "SimpleWindowClass";
6931 if(!RegisterClassA(&cls)) return FALSE;
6933 cls.style = CS_NOCLOSE;
6934 cls.lpszClassName = "NoCloseWindowClass";
6935 if(!RegisterClassA(&cls)) return FALSE;
6937 ok(GetClassInfoA(0, "#32770", &cls), "GetClassInfo failed\n");
6939 cls.hInstance = GetModuleHandleA(0);
6940 cls.hbrBackground = 0;
6941 cls.lpfnWndProc = TestDlgProcA;
6942 cls.lpszClassName = "TestDialogClass";
6943 if(!RegisterClassA(&cls)) return FALSE;
6946 clsW.lpfnWndProc = MsgCheckProcW;
6947 clsW.cbClsExtra = 0;
6948 clsW.cbWndExtra = 0;
6949 clsW.hInstance = GetModuleHandleW(0);
6951 clsW.hCursor = LoadCursorW(0, (LPWSTR)IDC_ARROW);
6952 clsW.hbrBackground = GetStockObject(WHITE_BRUSH);
6953 clsW.lpszMenuName = NULL;
6954 clsW.lpszClassName = testWindowClassW;
6955 RegisterClassW(&clsW); /* ignore error, this fails on Win9x */
6960 static HHOOK hCBT_hook;
6961 static DWORD cbt_hook_thread_id;
6963 static LRESULT CALLBACK cbt_hook_proc(int nCode, WPARAM wParam, LPARAM lParam)
6965 static const char * const CBT_code_name[10] = {
6972 "HCBT_CLICKSKIPPED",
6976 const char *code_name = (nCode >= 0 && nCode <= HCBT_SETFOCUS) ? CBT_code_name[nCode] : "Unknown";
6980 trace("CBT: %d (%s), %08lx, %08lx\n", nCode, code_name, wParam, lParam);
6982 ok(cbt_hook_thread_id == GetCurrentThreadId(), "we didn't ask for events from other threads\n");
6984 if (nCode == HCBT_CLICKSKIPPED)
6986 /* ignore this event, XP sends it a lot when switching focus between windows */
6987 return CallNextHookEx(hCBT_hook, nCode, wParam, lParam);
6990 if (nCode == HCBT_SYSCOMMAND || nCode == HCBT_KEYSKIPPED)
6994 msg.message = nCode;
6995 msg.flags = hook|wparam|lparam;
6996 msg.wParam = wParam;
6997 msg.lParam = lParam;
7000 return CallNextHookEx(hCBT_hook, nCode, wParam, lParam);
7003 if (nCode == HCBT_DESTROYWND)
7005 if (test_DestroyWindow_flag)
7007 DWORD style = GetWindowLongA((HWND)wParam, GWL_STYLE);
7008 if (style & WS_CHILD)
7009 lParam = GetWindowLongPtrA((HWND)wParam, GWLP_ID);
7010 else if (style & WS_POPUP)
7011 lParam = WND_POPUP_ID;
7013 lParam = WND_PARENT_ID;
7017 /* Log also SetFocus(0) calls */
7018 hwnd = wParam ? (HWND)wParam : (HWND)lParam;
7020 if (GetClassNameA(hwnd, buf, sizeof(buf)))
7022 if (!lstrcmpiA(buf, "TestWindowClass") ||
7023 !lstrcmpiA(buf, "ShowWindowClass") ||
7024 !lstrcmpiA(buf, "TestParentClass") ||
7025 !lstrcmpiA(buf, "TestPopupClass") ||
7026 !lstrcmpiA(buf, "SimpleWindowClass") ||
7027 !lstrcmpiA(buf, "TestDialogClass") ||
7028 !lstrcmpiA(buf, "MDI_frame_class") ||
7029 !lstrcmpiA(buf, "MDI_client_class") ||
7030 !lstrcmpiA(buf, "MDI_child_class") ||
7031 !lstrcmpiA(buf, "my_button_class") ||
7032 !lstrcmpiA(buf, "my_edit_class") ||
7033 !lstrcmpiA(buf, "static") ||
7034 !lstrcmpiA(buf, "ListBox") ||
7035 !lstrcmpiA(buf, "ComboBox") ||
7036 !lstrcmpiA(buf, "MyDialogClass") ||
7037 !lstrcmpiA(buf, "#32770"))
7041 msg.message = nCode;
7042 msg.flags = hook|wparam|lparam;
7043 msg.wParam = wParam;
7044 msg.lParam = lParam;
7048 return CallNextHookEx(hCBT_hook, nCode, wParam, lParam);
7051 static void CALLBACK win_event_proc(HWINEVENTHOOK hevent,
7061 trace("WEH:%p,event %08x,hwnd %p,obj %08x,id %08x,thread %08x,time %08x\n",
7062 hevent, event, hwnd, object_id, child_id, thread_id, event_time);
7064 ok(thread_id == GetCurrentThreadId(), "we didn't ask for events from other threads\n");
7066 /* ignore mouse cursor events */
7067 if (object_id == OBJID_CURSOR) return;
7069 if (!hwnd || GetClassNameA(hwnd, buf, sizeof(buf)))
7072 !lstrcmpiA(buf, "TestWindowClass") ||
7073 !lstrcmpiA(buf, "TestParentClass") ||
7074 !lstrcmpiA(buf, "TestPopupClass") ||
7075 !lstrcmpiA(buf, "SimpleWindowClass") ||
7076 !lstrcmpiA(buf, "TestDialogClass") ||
7077 !lstrcmpiA(buf, "MDI_frame_class") ||
7078 !lstrcmpiA(buf, "MDI_client_class") ||
7079 !lstrcmpiA(buf, "MDI_child_class") ||
7080 !lstrcmpiA(buf, "my_button_class") ||
7081 !lstrcmpiA(buf, "my_edit_class") ||
7082 !lstrcmpiA(buf, "static") ||
7083 !lstrcmpiA(buf, "ListBox") ||
7084 !lstrcmpiA(buf, "ComboBox") ||
7085 !lstrcmpiA(buf, "MyDialogClass") ||
7086 !lstrcmpiA(buf, "#32770"))
7090 msg.message = event;
7091 msg.flags = winevent_hook|wparam|lparam;
7092 msg.wParam = object_id;
7093 msg.lParam = child_id;
7099 static const WCHAR wszUnicode[] = {'U','n','i','c','o','d','e',0};
7100 static const WCHAR wszAnsi[] = {'U',0};
7102 static LRESULT CALLBACK MsgConversionProcW(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
7106 case CB_FINDSTRINGEXACT:
7107 trace("String: %p\n", (LPCWSTR)lParam);
7108 if (!lstrcmpW((LPCWSTR)lParam, wszUnicode))
7110 if (!lstrcmpW((LPCWSTR)lParam, wszAnsi))
7114 return DefWindowProcW(hwnd, uMsg, wParam, lParam);
7117 static const struct message WmGetTextLengthAfromW[] = {
7118 { WM_GETTEXTLENGTH, sent },
7119 { WM_GETTEXT, sent },
7123 static const WCHAR dummy_window_text[] = {'d','u','m','m','y',' ','t','e','x','t',0};
7125 /* dummy window proc for WM_GETTEXTLENGTH test */
7126 static LRESULT CALLBACK get_text_len_proc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
7130 case WM_GETTEXTLENGTH:
7131 return lstrlenW(dummy_window_text) + 37; /* some random length */
7133 lstrcpynW( (LPWSTR)lp, dummy_window_text, wp );
7134 return lstrlenW( (LPWSTR)lp );
7136 return DefWindowProcW( hwnd, msg, wp, lp );
7140 static void test_message_conversion(void)
7142 static const WCHAR wszMsgConversionClass[] =
7143 {'M','s','g','C','o','n','v','e','r','s','i','o','n','C','l','a','s','s',0};
7147 WNDPROC wndproc, newproc;
7151 cls.lpfnWndProc = MsgConversionProcW;
7154 cls.hInstance = GetModuleHandleW(NULL);
7156 cls.hCursor = LoadCursorW(NULL, (LPWSTR)IDC_ARROW);
7157 cls.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1);
7158 cls.lpszMenuName = NULL;
7159 cls.lpszClassName = wszMsgConversionClass;
7160 /* this call will fail on Win9x, but that doesn't matter as this test is
7161 * meaningless on those platforms */
7162 if(!RegisterClassW(&cls)) return;
7164 hwnd = CreateWindowExW(0, wszMsgConversionClass, NULL, WS_OVERLAPPED,
7165 100, 100, 200, 200, 0, 0, 0, NULL);
7166 ok(hwnd != NULL, "Window creation failed\n");
7170 wndproc = (WNDPROC)GetWindowLongPtrA(hwnd, GWLP_WNDPROC);
7171 lRes = CallWindowProcA(wndproc, hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
7172 ok(lRes == 0, "String should have been converted\n");
7173 lRes = CallWindowProcW(wndproc, hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
7174 ok(lRes == 1, "String shouldn't have been converted\n");
7178 wndproc = (WNDPROC)GetWindowLongPtrW(hwnd, GWLP_WNDPROC);
7179 lRes = CallWindowProcA(wndproc, hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
7180 ok(lRes == 1, "String shouldn't have been converted\n");
7181 lRes = CallWindowProcW(wndproc, hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
7182 ok(lRes == 1, "String shouldn't have been converted\n");
7184 /* Synchronous messages */
7186 lRes = SendMessageA(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
7187 ok(lRes == 0, "String should have been converted\n");
7188 lRes = SendMessageW(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
7189 ok(lRes == 1, "String shouldn't have been converted\n");
7191 /* Asynchronous messages */
7194 lRes = PostMessageA(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
7195 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
7196 "PostMessage on sync only message returned %ld, last error %d\n", lRes, GetLastError());
7198 lRes = PostMessageW(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
7199 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
7200 "PostMessage on sync only message returned %ld, last error %d\n", lRes, GetLastError());
7202 lRes = PostThreadMessageA(GetCurrentThreadId(), CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
7203 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
7204 "PosThreadtMessage on sync only message returned %ld, last error %d\n", lRes, GetLastError());
7206 lRes = PostThreadMessageW(GetCurrentThreadId(), CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
7207 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
7208 "PosThreadtMessage on sync only message returned %ld, last error %d\n", lRes, GetLastError());
7210 lRes = SendNotifyMessageA(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
7211 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
7212 "SendNotifyMessage on sync only message returned %ld, last error %d\n", lRes, GetLastError());
7214 lRes = SendNotifyMessageW(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
7215 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
7216 "SendNotifyMessage on sync only message returned %ld, last error %d\n", lRes, GetLastError());
7218 lRes = SendMessageCallbackA(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode, NULL, 0);
7219 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
7220 "SendMessageCallback on sync only message returned %ld, last error %d\n", lRes, GetLastError());
7222 lRes = SendMessageCallbackW(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode, NULL, 0);
7223 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
7224 "SendMessageCallback on sync only message returned %ld, last error %d\n", lRes, GetLastError());
7226 /* Check WM_GETTEXTLENGTH A->W behaviour, whether WM_GETTEXT is also sent or not */
7228 hwnd = CreateWindowW (testWindowClassW, wszUnicode,
7229 WS_OVERLAPPEDWINDOW,
7230 100, 100, 200, 200, 0, 0, 0, NULL);
7233 lRes = SendMessageA (hwnd, WM_GETTEXTLENGTH, 0, 0);
7234 ok_sequence(WmGetTextLengthAfromW, "ANSI WM_GETTEXTLENGTH to Unicode window", FALSE);
7235 ok( lRes == WideCharToMultiByte( CP_ACP, 0, wszUnicode, lstrlenW(wszUnicode), NULL, 0, NULL, NULL ),
7236 "got bad length %ld\n", lRes );
7239 lRes = CallWindowProcA( (WNDPROC)GetWindowLongPtrA( hwnd, GWLP_WNDPROC ),
7240 hwnd, WM_GETTEXTLENGTH, 0, 0);
7241 ok_sequence(WmGetTextLengthAfromW, "ANSI WM_GETTEXTLENGTH to Unicode window", FALSE);
7242 ok( lRes == WideCharToMultiByte( CP_ACP, 0, wszUnicode, lstrlenW(wszUnicode), NULL, 0, NULL, NULL ),
7243 "got bad length %ld\n", lRes );
7245 wndproc = (WNDPROC)SetWindowLongPtrW( hwnd, GWLP_WNDPROC, (LONG_PTR)get_text_len_proc );
7246 newproc = (WNDPROC)GetWindowLongPtrA( hwnd, GWLP_WNDPROC );
7247 lRes = CallWindowProcA( newproc, hwnd, WM_GETTEXTLENGTH, 0, 0 );
7248 ok( lRes == WideCharToMultiByte( CP_ACP, 0, dummy_window_text, lstrlenW(dummy_window_text),
7249 NULL, 0, NULL, NULL ),
7250 "got bad length %ld\n", lRes );
7252 SetWindowLongPtrW( hwnd, GWLP_WNDPROC, (LONG_PTR)wndproc ); /* restore old wnd proc */
7253 lRes = CallWindowProcA( newproc, hwnd, WM_GETTEXTLENGTH, 0, 0 );
7254 ok( lRes == WideCharToMultiByte( CP_ACP, 0, dummy_window_text, lstrlenW(dummy_window_text),
7255 NULL, 0, NULL, NULL ),
7256 "got bad length %ld\n", lRes );
7258 ret = DestroyWindow(hwnd);
7259 ok( ret, "DestroyWindow() error %d\n", GetLastError());
7269 static VOID CALLBACK tfunc(HWND hwnd, UINT uMsg, UINT_PTR id, DWORD dwTime)
7273 #define TIMER_ID 0x19
7275 static DWORD WINAPI timer_thread_proc(LPVOID x)
7277 struct timer_info *info = x;
7280 r = KillTimer(info->hWnd, 0x19);
7281 ok(r,"KillTimer failed in thread\n");
7282 r = SetTimer(info->hWnd,TIMER_ID,10000,tfunc);
7283 ok(r,"SetTimer failed in thread\n");
7284 ok(r==TIMER_ID,"SetTimer id different\n");
7285 r = SetEvent(info->handles[0]);
7286 ok(r,"SetEvent failed in thread\n");
7290 static void test_timers(void)
7292 struct timer_info info;
7295 info.hWnd = CreateWindow ("TestWindowClass", NULL,
7296 WS_OVERLAPPEDWINDOW ,
7297 CW_USEDEFAULT, CW_USEDEFAULT, 300, 300, 0,
7300 info.id = SetTimer(info.hWnd,TIMER_ID,10000,tfunc);
7301 ok(info.id, "SetTimer failed\n");
7302 ok(info.id==TIMER_ID, "SetTimer timer ID different\n");
7303 info.handles[0] = CreateEvent(NULL,0,0,NULL);
7304 info.handles[1] = CreateThread(NULL,0,timer_thread_proc,&info,0,&id);
7306 WaitForMultipleObjects(2, info.handles, FALSE, INFINITE);
7308 WaitForSingleObject(info.handles[1], INFINITE);
7310 CloseHandle(info.handles[0]);
7311 CloseHandle(info.handles[1]);
7313 ok( KillTimer(info.hWnd, TIMER_ID), "KillTimer failed\n");
7315 ok(DestroyWindow(info.hWnd), "failed to destroy window\n");
7318 static int count = 0;
7319 static VOID CALLBACK callback_count(
7329 static void test_timers_no_wnd(void)
7335 id = SetTimer(NULL, 0, 100, callback_count);
7336 ok(id != 0, "did not get id from SetTimer.\n");
7337 id2 = SetTimer(NULL, id, 200, callback_count);
7338 ok(id2 == id, "did not get same id from SetTimer when replacing (%li expected %li).\n", id2, id);
7340 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
7341 ok(count == 0, "did not get zero count as expected (%i).\n", count);
7343 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
7344 ok(count == 1, "did not get one count as expected (%i).\n", count);
7345 KillTimer(NULL, id);
7347 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
7348 ok(count == 1, "killing replaced timer did not work (%i).\n", count);
7351 /* Various win events with arbitrary parameters */
7352 static const struct message WmWinEventsSeq[] = {
7353 { EVENT_SYSTEM_SOUND, winevent_hook|wparam|lparam, OBJID_WINDOW, 0 },
7354 { EVENT_SYSTEM_ALERT, winevent_hook|wparam|lparam, OBJID_SYSMENU, 1 },
7355 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, OBJID_TITLEBAR, 2 },
7356 { EVENT_SYSTEM_MENUSTART, winevent_hook|wparam|lparam, OBJID_MENU, 3 },
7357 { EVENT_SYSTEM_MENUEND, winevent_hook|wparam|lparam, OBJID_CLIENT, 4 },
7358 { EVENT_SYSTEM_MENUPOPUPSTART, winevent_hook|wparam|lparam, OBJID_VSCROLL, 5 },
7359 { EVENT_SYSTEM_MENUPOPUPEND, winevent_hook|wparam|lparam, OBJID_HSCROLL, 6 },
7360 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, OBJID_SIZEGRIP, 7 },
7361 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, OBJID_CARET, 8 },
7362 /* our win event hook ignores OBJID_CURSOR events */
7363 /*{ EVENT_SYSTEM_MOVESIZESTART, winevent_hook|wparam|lparam, OBJID_CURSOR, 9 },*/
7364 { EVENT_SYSTEM_MOVESIZEEND, winevent_hook|wparam|lparam, OBJID_ALERT, 10 },
7365 { EVENT_SYSTEM_CONTEXTHELPSTART, winevent_hook|wparam|lparam, OBJID_SOUND, 11 },
7366 { EVENT_SYSTEM_CONTEXTHELPEND, winevent_hook|wparam|lparam, OBJID_QUERYCLASSNAMEIDX, 12 },
7367 { EVENT_SYSTEM_DRAGDROPSTART, winevent_hook|wparam|lparam, OBJID_NATIVEOM, 13 },
7368 { EVENT_SYSTEM_DRAGDROPEND, winevent_hook|wparam|lparam, OBJID_WINDOW, 0 },
7369 { EVENT_SYSTEM_DIALOGSTART, winevent_hook|wparam|lparam, OBJID_SYSMENU, 1 },
7370 { EVENT_SYSTEM_DIALOGEND, winevent_hook|wparam|lparam, OBJID_TITLEBAR, 2 },
7371 { EVENT_SYSTEM_SCROLLINGSTART, winevent_hook|wparam|lparam, OBJID_MENU, 3 },
7372 { EVENT_SYSTEM_SCROLLINGEND, winevent_hook|wparam|lparam, OBJID_CLIENT, 4 },
7373 { EVENT_SYSTEM_SWITCHSTART, winevent_hook|wparam|lparam, OBJID_VSCROLL, 5 },
7374 { EVENT_SYSTEM_SWITCHEND, winevent_hook|wparam|lparam, OBJID_HSCROLL, 6 },
7375 { EVENT_SYSTEM_MINIMIZESTART, winevent_hook|wparam|lparam, OBJID_SIZEGRIP, 7 },
7376 { EVENT_SYSTEM_MINIMIZEEND, winevent_hook|wparam|lparam, OBJID_CARET, 8 },
7379 static const struct message WmWinEventCaretSeq[] = {
7380 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1 */
7381 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1 */
7382 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 2 */
7383 { EVENT_OBJECT_NAMECHANGE, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1 */
7386 static const struct message WmWinEventCaretSeq_2[] = {
7387 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1/2 */
7388 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1/2 */
7389 { EVENT_OBJECT_NAMECHANGE, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1/2 */
7392 static const struct message WmWinEventAlertSeq[] = {
7393 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, OBJID_ALERT, 0 },
7396 static const struct message WmWinEventAlertSeq_2[] = {
7397 /* create window in the thread proc */
7398 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_WINDOW, 2 },
7399 /* our test event */
7400 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, OBJID_ALERT, 2 },
7403 static const struct message WmGlobalHookSeq_1[] = {
7404 /* create window in the thread proc */
7405 { HCBT_CREATEWND, hook|lparam, 0, 2 },
7406 /* our test events */
7407 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_PREVWINDOW, 2 },
7408 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_NEXTWINDOW, 2 },
7411 static const struct message WmGlobalHookSeq_2[] = {
7412 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_NEXTWINDOW, 0 }, /* old local hook */
7413 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_NEXTWINDOW, 2 }, /* new global hook */
7414 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_PREVWINDOW, 0 }, /* old local hook */
7415 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_PREVWINDOW, 2 }, /* new global hook */
7419 static const struct message WmMouseLLHookSeq[] = {
7420 { WM_MOUSEMOVE, hook },
7421 { WM_LBUTTONUP, hook },
7422 { WM_MOUSEMOVE, hook },
7426 static void CALLBACK win_event_global_hook_proc(HWINEVENTHOOK hevent,
7436 trace("WEH_2:%p,event %08x,hwnd %p,obj %08x,id %08x,thread %08x,time %08x\n",
7437 hevent, event, hwnd, object_id, child_id, thread_id, event_time);
7439 if (GetClassNameA(hwnd, buf, sizeof(buf)))
7441 if (!lstrcmpiA(buf, "TestWindowClass") ||
7442 !lstrcmpiA(buf, "static"))
7446 msg.message = event;
7447 msg.flags = winevent_hook|wparam|lparam;
7448 msg.wParam = object_id;
7449 msg.lParam = (thread_id == GetCurrentThreadId()) ? child_id : (child_id + 2);
7455 static HHOOK hCBT_global_hook;
7456 static DWORD cbt_global_hook_thread_id;
7458 static LRESULT CALLBACK cbt_global_hook_proc(int nCode, WPARAM wParam, LPARAM lParam)
7463 trace("CBT_2: %d, %08lx, %08lx\n", nCode, wParam, lParam);
7465 if (nCode == HCBT_SYSCOMMAND)
7469 msg.message = nCode;
7470 msg.flags = hook|wparam|lparam;
7471 msg.wParam = wParam;
7472 msg.lParam = (cbt_global_hook_thread_id == GetCurrentThreadId()) ? 1 : 2;
7475 return CallNextHookEx(hCBT_global_hook, nCode, wParam, lParam);
7477 /* WH_MOUSE_LL hook */
7478 if (nCode == HC_ACTION)
7480 MSLLHOOKSTRUCT *mhll = (MSLLHOOKSTRUCT *)lParam;
7482 /* we can't test for real mouse events */
7483 if (mhll->flags & LLMHF_INJECTED)
7487 memset (&msg, 0, sizeof (msg));
7488 msg.message = wParam;
7492 return CallNextHookEx(hCBT_global_hook, nCode, wParam, lParam);
7495 /* Log also SetFocus(0) calls */
7496 hwnd = wParam ? (HWND)wParam : (HWND)lParam;
7498 if (GetClassNameA(hwnd, buf, sizeof(buf)))
7500 if (!lstrcmpiA(buf, "TestWindowClass") ||
7501 !lstrcmpiA(buf, "static"))
7505 msg.message = nCode;
7506 msg.flags = hook|wparam|lparam;
7507 msg.wParam = wParam;
7508 msg.lParam = (cbt_global_hook_thread_id == GetCurrentThreadId()) ? 1 : 2;
7512 return CallNextHookEx(hCBT_global_hook, nCode, wParam, lParam);
7515 static DWORD WINAPI win_event_global_thread_proc(void *param)
7519 HANDLE hevent = *(HANDLE *)param;
7521 assert(pNotifyWinEvent);
7523 hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP, 0,0,0,0,0,0,0, NULL);
7525 trace("created thread window %p\n", hwnd);
7527 *(HWND *)param = hwnd;
7530 /* this event should be received only by our new hook proc,
7531 * an old one does not expect an event from another thread.
7533 pNotifyWinEvent(EVENT_OBJECT_LOCATIONCHANGE, hwnd, OBJID_ALERT, 0);
7536 while (GetMessage(&msg, 0, 0, 0))
7538 TranslateMessage(&msg);
7539 DispatchMessage(&msg);
7544 static DWORD WINAPI cbt_global_hook_thread_proc(void *param)
7548 HANDLE hevent = *(HANDLE *)param;
7551 /* these events should be received only by our new hook proc,
7552 * an old one does not expect an event from another thread.
7555 hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP, 0,0,0,0,0,0,0, NULL);
7557 trace("created thread window %p\n", hwnd);
7559 *(HWND *)param = hwnd;
7561 /* Windows doesn't like when a thread plays games with the focus,
7562 that leads to all kinds of misbehaviours and failures to activate
7563 a window. So, better keep next lines commented out.
7567 DefWindowProcA(hwnd, WM_SYSCOMMAND, SC_PREVWINDOW, 0);
7568 DefWindowProcA(hwnd, WM_SYSCOMMAND, SC_NEXTWINDOW, 0);
7572 while (GetMessage(&msg, 0, 0, 0))
7574 TranslateMessage(&msg);
7575 DispatchMessage(&msg);
7580 static DWORD WINAPI mouse_ll_global_thread_proc(void *param)
7584 HANDLE hevent = *(HANDLE *)param;
7586 hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP, 0,0,0,0,0,0,0, NULL);
7588 trace("created thread window %p\n", hwnd);
7590 *(HWND *)param = hwnd;
7594 /* Windows doesn't like when a thread plays games with the focus,
7595 * that leads to all kinds of misbehaviours and failures to activate
7596 * a window. So, better don't generate a mouse click message below.
7598 mouse_event(MOUSEEVENTF_MOVE, -1, 0, 0, 0);
7599 mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
7600 mouse_event(MOUSEEVENTF_MOVE, 1, 0, 0, 0);
7603 while (GetMessage(&msg, 0, 0, 0))
7605 TranslateMessage(&msg);
7606 DispatchMessage(&msg);
7611 static void test_winevents(void)
7617 HANDLE hthread, hevent;
7619 HWINEVENTHOOK hhook;
7620 const struct message *events = WmWinEventsSeq;
7622 hwnd = CreateWindowExA(0, "TestWindowClass", NULL,
7623 WS_OVERLAPPEDWINDOW,
7624 CW_USEDEFAULT, CW_USEDEFAULT, 300, 300, 0,
7628 /****** start of global hook test *************/
7629 hCBT_global_hook = SetWindowsHookExA(WH_CBT, cbt_global_hook_proc, GetModuleHandleA(0), 0);
7630 if (!hCBT_global_hook)
7632 ok(DestroyWindow(hwnd), "failed to destroy window\n");
7633 skip( "cannot set global hook\n" );
7637 hevent = CreateEventA(NULL, 0, 0, NULL);
7639 hwnd2 = (HWND)hevent;
7641 hthread = CreateThread(NULL, 0, cbt_global_hook_thread_proc, &hwnd2, 0, &tid);
7642 ok(hthread != NULL, "CreateThread failed, error %d\n", GetLastError());
7644 ok(WaitForSingleObject(hevent, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
7646 ok_sequence(WmGlobalHookSeq_1, "global hook 1", FALSE);
7649 /* this one should be received only by old hook proc */
7650 DefWindowProcA(hwnd, WM_SYSCOMMAND, SC_NEXTWINDOW, 0);
7651 /* this one should be received only by old hook proc */
7652 DefWindowProcA(hwnd, WM_SYSCOMMAND, SC_PREVWINDOW, 0);
7654 ok_sequence(WmGlobalHookSeq_2, "global hook 2", FALSE);
7656 ret = UnhookWindowsHookEx(hCBT_global_hook);
7657 ok( ret, "UnhookWindowsHookEx error %d\n", GetLastError());
7659 PostThreadMessageA(tid, WM_QUIT, 0, 0);
7660 ok(WaitForSingleObject(hthread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
7661 CloseHandle(hthread);
7662 CloseHandle(hevent);
7663 ok(!IsWindow(hwnd2), "window should be destroyed on thread exit\n");
7664 /****** end of global hook test *************/
7666 if (!pSetWinEventHook || !pNotifyWinEvent || !pUnhookWinEvent)
7668 ok(DestroyWindow(hwnd), "failed to destroy window\n");
7676 /* this test doesn't pass under Win9x */
7677 /* win2k ignores events with hwnd == 0 */
7678 SetLastError(0xdeadbeef);
7679 pNotifyWinEvent(events[0].message, 0, events[0].wParam, events[0].lParam);
7680 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE || /* Win2k */
7681 GetLastError() == 0xdeadbeef, /* Win9x */
7682 "unexpected error %d\n", GetLastError());
7683 ok_sequence(WmEmptySeq, "empty notify winevents", FALSE);
7686 for (i = 0; i < sizeof(WmWinEventsSeq)/sizeof(WmWinEventsSeq[0]); i++)
7687 pNotifyWinEvent(events[i].message, hwnd, events[i].wParam, events[i].lParam);
7689 ok_sequence(WmWinEventsSeq, "notify winevents", FALSE);
7691 /****** start of event filtering test *************/
7692 hhook = (HWINEVENTHOOK)pSetWinEventHook(
7693 EVENT_OBJECT_SHOW, /* 0x8002 */
7694 EVENT_OBJECT_LOCATIONCHANGE, /* 0x800B */
7695 GetModuleHandleA(0), win_event_global_hook_proc,
7696 GetCurrentProcessId(), 0,
7697 WINEVENT_INCONTEXT);
7698 ok(hhook != 0, "SetWinEventHook error %d\n", GetLastError());
7700 hevent = CreateEventA(NULL, 0, 0, NULL);
7702 hwnd2 = (HWND)hevent;
7704 hthread = CreateThread(NULL, 0, win_event_global_thread_proc, &hwnd2, 0, &tid);
7705 ok(hthread != NULL, "CreateThread failed, error %d\n", GetLastError());
7707 ok(WaitForSingleObject(hevent, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
7709 ok_sequence(WmWinEventAlertSeq, "alert winevent", FALSE);
7712 /* this one should be received only by old hook proc */
7713 pNotifyWinEvent(EVENT_OBJECT_CREATE, hwnd, OBJID_CARET, 0); /* 0x8000 */
7714 pNotifyWinEvent(EVENT_OBJECT_SHOW, hwnd, OBJID_CARET, 0); /* 0x8002 */
7715 /* this one should be received only by old hook proc */
7716 pNotifyWinEvent(EVENT_OBJECT_NAMECHANGE, hwnd, OBJID_CARET, 0); /* 0x800C */
7718 ok_sequence(WmWinEventCaretSeq, "caret winevent", FALSE);
7720 ret = pUnhookWinEvent(hhook);
7721 ok( ret, "UnhookWinEvent error %d\n", GetLastError());
7723 PostThreadMessageA(tid, WM_QUIT, 0, 0);
7724 ok(WaitForSingleObject(hthread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
7725 CloseHandle(hthread);
7726 CloseHandle(hevent);
7727 ok(!IsWindow(hwnd2), "window should be destroyed on thread exit\n");
7728 /****** end of event filtering test *************/
7730 /****** start of out of context event test *************/
7731 hhook = (HWINEVENTHOOK)pSetWinEventHook(
7732 EVENT_MIN, EVENT_MAX,
7733 0, win_event_global_hook_proc,
7734 GetCurrentProcessId(), 0,
7735 WINEVENT_OUTOFCONTEXT);
7736 ok(hhook != 0, "SetWinEventHook error %d\n", GetLastError());
7738 hevent = CreateEventA(NULL, 0, 0, NULL);
7740 hwnd2 = (HWND)hevent;
7744 hthread = CreateThread(NULL, 0, win_event_global_thread_proc, &hwnd2, 0, &tid);
7745 ok(hthread != NULL, "CreateThread failed, error %d\n", GetLastError());
7747 ok(WaitForSingleObject(hevent, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
7749 ok_sequence(WmEmptySeq, "empty notify winevents", FALSE);
7750 /* process pending winevent messages */
7751 ok(!PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE), "msg queue should be empty\n");
7752 ok_sequence(WmWinEventAlertSeq_2, "alert winevent for out of context proc", FALSE);
7755 /* this one should be received only by old hook proc */
7756 pNotifyWinEvent(EVENT_OBJECT_CREATE, hwnd, OBJID_CARET, 0); /* 0x8000 */
7757 pNotifyWinEvent(EVENT_OBJECT_SHOW, hwnd, OBJID_CARET, 0); /* 0x8002 */
7758 /* this one should be received only by old hook proc */
7759 pNotifyWinEvent(EVENT_OBJECT_NAMECHANGE, hwnd, OBJID_CARET, 0); /* 0x800C */
7761 ok_sequence(WmWinEventCaretSeq_2, "caret winevent for incontext proc", FALSE);
7762 /* process pending winevent messages */
7763 ok(!PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE), "msg queue should be empty\n");
7764 ok_sequence(WmWinEventCaretSeq_2, "caret winevent for out of context proc", FALSE);
7766 ret = pUnhookWinEvent(hhook);
7767 ok( ret, "UnhookWinEvent error %d\n", GetLastError());
7769 PostThreadMessageA(tid, WM_QUIT, 0, 0);
7770 ok(WaitForSingleObject(hthread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
7771 CloseHandle(hthread);
7772 CloseHandle(hevent);
7773 ok(!IsWindow(hwnd2), "window should be destroyed on thread exit\n");
7774 /****** end of out of context event test *************/
7776 /****** start of MOUSE_LL hook test *************/
7777 hCBT_global_hook = SetWindowsHookExA(WH_MOUSE_LL, cbt_global_hook_proc, GetModuleHandleA(0), 0);
7778 /* WH_MOUSE_LL is not supported on Win9x platforms */
7779 if (!hCBT_global_hook)
7781 trace("Skipping WH_MOUSE_LL test on this platform\n");
7782 goto skip_mouse_ll_hook_test;
7785 hevent = CreateEventA(NULL, 0, 0, NULL);
7787 hwnd2 = (HWND)hevent;
7789 hthread = CreateThread(NULL, 0, mouse_ll_global_thread_proc, &hwnd2, 0, &tid);
7790 ok(hthread != NULL, "CreateThread failed, error %d\n", GetLastError());
7792 while (WaitForSingleObject(hevent, 100) == WAIT_TIMEOUT)
7793 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
7795 ok_sequence(WmMouseLLHookSeq, "MOUSE_LL hook other thread", FALSE);
7798 mouse_event(MOUSEEVENTF_MOVE, -1, 0, 0, 0);
7799 mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
7800 mouse_event(MOUSEEVENTF_MOVE, 1, 0, 0, 0);
7802 ok_sequence(WmMouseLLHookSeq, "MOUSE_LL hook same thread", FALSE);
7804 ret = UnhookWindowsHookEx(hCBT_global_hook);
7805 ok( ret, "UnhookWindowsHookEx error %d\n", GetLastError());
7807 PostThreadMessageA(tid, WM_QUIT, 0, 0);
7808 ok(WaitForSingleObject(hthread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
7809 CloseHandle(hthread);
7810 CloseHandle(hevent);
7811 ok(!IsWindow(hwnd2), "window should be destroyed on thread exit\n");
7812 /****** end of MOUSE_LL hook test *************/
7813 skip_mouse_ll_hook_test:
7815 ok(DestroyWindow(hwnd), "failed to destroy window\n");
7818 static void test_set_hook(void)
7822 HWINEVENTHOOK hwinevent_hook;
7824 hhook = SetWindowsHookExA(WH_CBT, cbt_hook_proc, GetModuleHandleA(0), GetCurrentThreadId());
7825 ok(hhook != 0, "local hook does not require hModule set to 0\n");
7826 UnhookWindowsHookEx(hhook);
7830 /* this test doesn't pass under Win9x: BUG! */
7831 SetLastError(0xdeadbeef);
7832 hhook = SetWindowsHookExA(WH_CBT, cbt_hook_proc, 0, 0);
7833 ok(!hhook, "global hook requires hModule != 0\n");
7834 ok(GetLastError() == ERROR_HOOK_NEEDS_HMOD, "unexpected error %d\n", GetLastError());
7837 SetLastError(0xdeadbeef);
7838 hhook = SetWindowsHookExA(WH_CBT, 0, GetModuleHandleA(0), GetCurrentThreadId());
7839 ok(!hhook, "SetWinEventHook with invalid proc should fail\n");
7840 ok(GetLastError() == ERROR_INVALID_FILTER_PROC || /* Win2k */
7841 GetLastError() == 0xdeadbeef, /* Win9x */
7842 "unexpected error %d\n", GetLastError());
7844 SetLastError(0xdeadbeef);
7845 ok(!UnhookWindowsHookEx((HHOOK)0xdeadbeef), "UnhookWindowsHookEx succeeded\n");
7846 ok(GetLastError() == ERROR_INVALID_HOOK_HANDLE || /* Win2k */
7847 GetLastError() == 0xdeadbeef, /* Win9x */
7848 "unexpected error %d\n", GetLastError());
7850 if (!pSetWinEventHook || !pUnhookWinEvent) return;
7852 /* even process local incontext hooks require hmodule */
7853 SetLastError(0xdeadbeef);
7854 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(EVENT_MIN, EVENT_MAX,
7855 0, win_event_proc, GetCurrentProcessId(), 0, WINEVENT_INCONTEXT);
7856 ok(!hwinevent_hook, "WINEVENT_INCONTEXT requires hModule != 0\n");
7857 ok(GetLastError() == ERROR_HOOK_NEEDS_HMOD || /* Win2k */
7858 GetLastError() == 0xdeadbeef, /* Win9x */
7859 "unexpected error %d\n", GetLastError());
7861 /* even thread local incontext hooks require hmodule */
7862 SetLastError(0xdeadbeef);
7863 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(EVENT_MIN, EVENT_MAX,
7864 0, win_event_proc, GetCurrentProcessId(), GetCurrentThreadId(), WINEVENT_INCONTEXT);
7865 ok(!hwinevent_hook, "WINEVENT_INCONTEXT requires hModule != 0\n");
7866 ok(GetLastError() == ERROR_HOOK_NEEDS_HMOD || /* Win2k */
7867 GetLastError() == 0xdeadbeef, /* Win9x */
7868 "unexpected error %d\n", GetLastError());
7872 /* these 3 tests don't pass under Win9x */
7873 SetLastError(0xdeadbeef);
7874 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(1, 0,
7875 0, win_event_proc, GetCurrentProcessId(), 0, WINEVENT_OUTOFCONTEXT);
7876 ok(!hwinevent_hook, "SetWinEventHook with invalid event range should fail\n");
7877 ok(GetLastError() == ERROR_INVALID_HOOK_FILTER, "unexpected error %d\n", GetLastError());
7879 SetLastError(0xdeadbeef);
7880 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(-1, 1,
7881 0, win_event_proc, GetCurrentProcessId(), 0, WINEVENT_OUTOFCONTEXT);
7882 ok(!hwinevent_hook, "SetWinEventHook with invalid event range should fail\n");
7883 ok(GetLastError() == ERROR_INVALID_HOOK_FILTER, "unexpected error %d\n", GetLastError());
7885 SetLastError(0xdeadbeef);
7886 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(EVENT_MIN, EVENT_MAX,
7887 0, win_event_proc, 0, 0xdeadbeef, WINEVENT_OUTOFCONTEXT);
7888 ok(!hwinevent_hook, "SetWinEventHook with invalid tid should fail\n");
7889 ok(GetLastError() == ERROR_INVALID_THREAD_ID, "unexpected error %d\n", GetLastError());
7892 SetLastError(0xdeadbeef);
7893 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(0, 0,
7894 0, win_event_proc, GetCurrentProcessId(), 0, WINEVENT_OUTOFCONTEXT);
7895 ok(hwinevent_hook != 0, "SetWinEventHook error %d\n", GetLastError());
7896 ok(GetLastError() == 0xdeadbeef, "unexpected error %d\n", GetLastError());
7897 ret = pUnhookWinEvent(hwinevent_hook);
7898 ok( ret, "UnhookWinEvent error %d\n", GetLastError());
7901 /* This call succeeds under win2k SP4, but fails under Wine.
7902 Does win2k test/use passed process id? */
7903 SetLastError(0xdeadbeef);
7904 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(EVENT_MIN, EVENT_MAX,
7905 0, win_event_proc, 0xdeadbeef, 0, WINEVENT_OUTOFCONTEXT);
7906 ok(hwinevent_hook != 0, "SetWinEventHook error %d\n", GetLastError());
7907 ok(GetLastError() == 0xdeadbeef, "unexpected error %d\n", GetLastError());
7908 ret = pUnhookWinEvent(hwinevent_hook);
7909 ok( ret, "UnhookWinEvent error %d\n", GetLastError());
7912 SetLastError(0xdeadbeef);
7913 ok(!pUnhookWinEvent((HWINEVENTHOOK)0xdeadbeef), "UnhookWinEvent succeeded\n");
7914 ok(GetLastError() == ERROR_INVALID_HANDLE || /* Win2k */
7915 GetLastError() == 0xdeadbeef, /* Win9x */
7916 "unexpected error %d\n", GetLastError());
7919 static const struct message ScrollWindowPaint1[] = {
7921 { WM_ERASEBKGND, sent|beginpaint },
7925 static const struct message ScrollWindowPaint2[] = {
7930 static void test_scrollwindowex(void)
7933 RECT rect={0,0,130,130};
7935 hwnd = CreateWindowExA(0, "TestWindowClass", "Test Scroll",
7936 WS_VISIBLE|WS_OVERLAPPEDWINDOW,
7937 100, 100, 200, 200, 0, 0, 0, NULL);
7938 ok (hwnd != 0, "Failed to create overlapped window\n");
7939 hchild = CreateWindowExA(0, "TestWindowClass", "Test child",
7940 WS_VISIBLE|WS_CAPTION|WS_CHILD,
7941 10, 10, 150, 150, hwnd, 0, 0, NULL);
7942 ok (hchild != 0, "Failed to create child\n");
7947 /* scroll without the child window */
7948 trace("start scroll\n");
7949 ScrollWindowEx( hwnd, 10, 10, &rect, NULL, NULL, NULL,
7950 SW_ERASE|SW_INVALIDATE);
7951 ok_sequence(WmEmptySeq, "ScrollWindowEx", 0);
7952 trace("end scroll\n");
7955 ok_sequence(ScrollWindowPaint1, "ScrollWindowEx", 0);
7959 /* Now without the SW_ERASE flag */
7960 trace("start scroll\n");
7961 ScrollWindowEx( hwnd, 10, 10, &rect, NULL, NULL, NULL, SW_INVALIDATE);
7962 ok_sequence(WmEmptySeq, "ScrollWindowEx", 0);
7963 trace("end scroll\n");
7966 ok_sequence(ScrollWindowPaint2, "ScrollWindowEx", 0);
7970 /* now scroll the child window as well */
7971 trace("start scroll\n");
7972 ScrollWindowEx( hwnd, 10, 10, &rect, NULL, NULL, NULL,
7973 SW_SCROLLCHILDREN|SW_ERASE|SW_INVALIDATE);
7974 todo_wine { /* wine sends WM_POSCHANGING, WM_POSCHANGED messages */
7975 /* windows sometimes a WM_MOVE */
7976 ok_sequence(WmEmptySeq, "ScrollWindowEx", 0);
7978 trace("end scroll\n");
7981 ok_sequence(ScrollWindowPaint1, "ScrollWindowEx", 0);
7985 /* now scroll with ScrollWindow() */
7986 trace("start scroll with ScrollWindow\n");
7987 ScrollWindow( hwnd, 5, 5, NULL, NULL);
7988 trace("end scroll\n");
7991 ok_sequence(ScrollWindowPaint1, "ScrollWindow", 0);
7993 ok(DestroyWindow(hchild), "failed to destroy window\n");
7994 ok(DestroyWindow(hwnd), "failed to destroy window\n");
7998 static const struct message destroy_window_with_children[] = {
7999 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 }, /* popup */
8000 { HCBT_DESTROYWND, hook|lparam, 0, WND_PARENT_ID }, /* parent */
8001 { 0x0090, sent|optional },
8002 { HCBT_DESTROYWND, hook|lparam, 0, WND_POPUP_ID }, /* popup */
8003 { 0x0090, sent|optional },
8004 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 }, /* popup */
8005 { WM_DESTROY, sent|wparam|lparam, 0, WND_POPUP_ID }, /* popup */
8006 { WM_CAPTURECHANGED, sent|wparam|lparam, 0, WND_POPUP_ID }, /* popup */
8007 { WM_NCDESTROY, sent|wparam|lparam, 0, WND_POPUP_ID }, /* popup */
8008 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 }, /* parent */
8009 { WM_DESTROY, sent|wparam|lparam, 0, WND_PARENT_ID }, /* parent */
8010 { WM_DESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 2 }, /* child2 */
8011 { WM_DESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 1 }, /* child1 */
8012 { WM_DESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 3 }, /* child3 */
8013 { WM_NCDESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 2 }, /* child2 */
8014 { WM_NCDESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 3 }, /* child3 */
8015 { WM_NCDESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 1 }, /* child1 */
8016 { WM_NCDESTROY, sent|wparam|lparam, 0, WND_PARENT_ID }, /* parent */
8020 static void test_DestroyWindow(void)
8023 HWND parent, child1, child2, child3, child4, test;
8024 UINT child_id = WND_CHILD_ID + 1;
8026 parent = CreateWindowExA(0, "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW,
8027 100, 100, 200, 200, 0, 0, 0, NULL);
8028 assert(parent != 0);
8029 child1 = CreateWindowExA(0, "TestWindowClass", NULL, WS_CHILD,
8030 0, 0, 50, 50, parent, (HMENU)child_id++, 0, NULL);
8031 assert(child1 != 0);
8032 child2 = CreateWindowExA(0, "TestWindowClass", NULL, WS_CHILD,
8033 0, 0, 50, 50, GetDesktopWindow(), (HMENU)child_id++, 0, NULL);
8034 assert(child2 != 0);
8035 child3 = CreateWindowExA(0, "TestWindowClass", NULL, WS_CHILD,
8036 0, 0, 50, 50, child1, (HMENU)child_id++, 0, NULL);
8037 assert(child3 != 0);
8038 child4 = CreateWindowExA(0, "TestWindowClass", NULL, WS_POPUP,
8039 0, 0, 50, 50, parent, 0, 0, NULL);
8040 assert(child4 != 0);
8042 /* test owner/parent of child2 */
8043 test = GetParent(child2);
8044 ok(test == GetDesktopWindow(), "wrong parent %p\n", test);
8045 ok(!IsChild(parent, child2), "wrong parent/child %p/%p\n", parent, child2);
8047 test = pGetAncestor(child2, GA_PARENT);
8048 ok(test == GetDesktopWindow(), "wrong parent %p\n", test);
8050 test = GetWindow(child2, GW_OWNER);
8051 ok(!test, "wrong owner %p\n", test);
8053 test = SetParent(child2, parent);
8054 ok(test == GetDesktopWindow(), "wrong old parent %p\n", test);
8056 /* test owner/parent of the parent */
8057 test = GetParent(parent);
8058 ok(!test, "wrong parent %p\n", test);
8059 ok(!IsChild(GetDesktopWindow(), parent), "wrong parent/child %p/%p\n", GetDesktopWindow(), parent);
8061 test = pGetAncestor(parent, GA_PARENT);
8062 ok(test == GetDesktopWindow(), "wrong parent %p\n", test);
8064 test = GetWindow(parent, GW_OWNER);
8065 ok(!test, "wrong owner %p\n", test);
8067 /* test owner/parent of child1 */
8068 test = GetParent(child1);
8069 ok(test == parent, "wrong parent %p\n", test);
8070 ok(IsChild(parent, child1), "wrong parent/child %p/%p\n", parent, child1);
8072 test = pGetAncestor(child1, GA_PARENT);
8073 ok(test == parent, "wrong parent %p\n", test);
8075 test = GetWindow(child1, GW_OWNER);
8076 ok(!test, "wrong owner %p\n", test);
8078 /* test owner/parent of child2 */
8079 test = GetParent(child2);
8080 ok(test == parent, "wrong parent %p\n", test);
8081 ok(IsChild(parent, child2), "wrong parent/child %p/%p\n", parent, child2);
8083 test = pGetAncestor(child2, GA_PARENT);
8084 ok(test == parent, "wrong parent %p\n", test);
8086 test = GetWindow(child2, GW_OWNER);
8087 ok(!test, "wrong owner %p\n", test);
8089 /* test owner/parent of child3 */
8090 test = GetParent(child3);
8091 ok(test == child1, "wrong parent %p\n", test);
8092 ok(IsChild(parent, child3), "wrong parent/child %p/%p\n", parent, child3);
8094 test = pGetAncestor(child3, GA_PARENT);
8095 ok(test == child1, "wrong parent %p\n", test);
8097 test = GetWindow(child3, GW_OWNER);
8098 ok(!test, "wrong owner %p\n", test);
8100 /* test owner/parent of child4 */
8101 test = GetParent(child4);
8102 ok(test == parent, "wrong parent %p\n", test);
8103 ok(!IsChild(parent, child4), "wrong parent/child %p/%p\n", parent, child4);
8105 test = pGetAncestor(child4, GA_PARENT);
8106 ok(test == GetDesktopWindow(), "wrong parent %p\n", test);
8108 test = GetWindow(child4, GW_OWNER);
8109 ok(test == parent, "wrong owner %p\n", test);
8113 trace("parent %p, child1 %p, child2 %p, child3 %p, child4 %p\n",
8114 parent, child1, child2, child3, child4);
8117 test = GetCapture();
8118 ok(test == child4, "wrong capture window %p\n", test);
8120 test_DestroyWindow_flag = TRUE;
8121 ret = DestroyWindow(parent);
8122 ok( ret, "DestroyWindow() error %d\n", GetLastError());
8123 test_DestroyWindow_flag = FALSE;
8124 ok_sequence(destroy_window_with_children, "destroy window with children", 0);
8126 ok(!IsWindow(parent), "parent still exists\n");
8127 ok(!IsWindow(child1), "child1 still exists\n");
8128 ok(!IsWindow(child2), "child2 still exists\n");
8129 ok(!IsWindow(child3), "child3 still exists\n");
8130 ok(!IsWindow(child4), "child4 still exists\n");
8132 test = GetCapture();
8133 ok(!test, "wrong capture window %p\n", test);
8137 static const struct message WmDispatchPaint[] = {
8138 { WM_NCPAINT, sent },
8139 { WM_GETTEXT, sent|defwinproc|optional },
8140 { WM_GETTEXT, sent|defwinproc|optional },
8141 { WM_ERASEBKGND, sent },
8145 static LRESULT WINAPI DispatchMessageCheckProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
8147 if (message == WM_PAINT) return 0;
8148 return MsgCheckProcA( hwnd, message, wParam, lParam );
8151 static void test_DispatchMessage(void)
8156 HWND hwnd = CreateWindowA( "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW,
8157 100, 100, 200, 200, 0, 0, 0, NULL);
8158 ShowWindow( hwnd, SW_SHOW );
8159 UpdateWindow( hwnd );
8162 SetWindowLongPtrA( hwnd, GWLP_WNDPROC, (LONG_PTR)DispatchMessageCheckProc );
8164 SetRect( &rect, -5, -5, 5, 5 );
8165 RedrawWindow( hwnd, &rect, 0, RDW_INVALIDATE|RDW_ERASE|RDW_FRAME );
8167 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE ))
8169 if (msg.message != WM_PAINT) DispatchMessage( &msg );
8173 DispatchMessage( &msg );
8174 /* DispatchMessage will send WM_NCPAINT if non client area is still invalid after WM_PAINT */
8175 if (!count) ok_sequence( WmDispatchPaint, "WmDispatchPaint", FALSE );
8176 else ok_sequence( WmEmptySeq, "WmEmpty", FALSE );
8177 if (++count > 10) break;
8180 ok( msg.message == WM_PAINT && count > 10, "WM_PAINT messages stopped\n" );
8182 trace("now without DispatchMessage\n");
8184 RedrawWindow( hwnd, &rect, 0, RDW_INVALIDATE|RDW_ERASE|RDW_FRAME );
8186 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE ))
8188 if (msg.message != WM_PAINT) DispatchMessage( &msg );
8191 HRGN hrgn = CreateRectRgn( 0, 0, 0, 0 );
8193 /* this will send WM_NCCPAINT just like DispatchMessage does */
8194 GetUpdateRgn( hwnd, hrgn, TRUE );
8195 ok_sequence( WmDispatchPaint, "WmDispatchPaint", FALSE );
8196 DeleteObject( hrgn );
8197 GetClientRect( hwnd, &rect );
8198 ValidateRect( hwnd, &rect ); /* this will stop WM_PAINTs */
8199 ok( !count, "Got multiple WM_PAINTs\n" );
8200 if (++count > 10) break;
8203 DestroyWindow(hwnd);
8207 static const struct message WmUser[] = {
8219 static DWORD CALLBACK send_msg_thread( LPVOID arg )
8221 struct sendmsg_info *info = arg;
8222 info->ret = SendMessageTimeoutA( info->hwnd, WM_USER, 0, 0, 0, info->timeout, NULL );
8223 if (!info->ret) ok( GetLastError() == ERROR_TIMEOUT, "unexpected error %d\n", GetLastError());
8227 static void wait_for_thread( HANDLE thread )
8229 while (MsgWaitForMultipleObjects(1, &thread, FALSE, INFINITE, QS_SENDMESSAGE) != WAIT_OBJECT_0)
8232 while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage(&msg);
8236 static LRESULT WINAPI send_msg_delay_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
8238 if (message == WM_USER) Sleep(200);
8239 return MsgCheckProcA( hwnd, message, wParam, lParam );
8242 static void test_SendMessageTimeout(void)
8245 struct sendmsg_info info;
8248 info.hwnd = CreateWindowA( "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW,
8249 100, 100, 200, 200, 0, 0, 0, NULL);
8253 info.timeout = 1000;
8254 info.ret = 0xdeadbeef;
8255 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid );
8256 wait_for_thread( thread );
8257 CloseHandle( thread );
8258 ok( info.ret == 1, "SendMessageTimeout failed\n" );
8259 ok_sequence( WmUser, "WmUser", FALSE );
8262 info.ret = 0xdeadbeef;
8263 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid );
8264 Sleep(100); /* SendMessageTimeout should time out here */
8265 wait_for_thread( thread );
8266 CloseHandle( thread );
8267 ok( info.ret == 0, "SendMessageTimeout succeeded\n" );
8268 ok_sequence( WmEmptySeq, "WmEmptySeq", FALSE );
8270 /* 0 means infinite timeout */
8272 info.ret = 0xdeadbeef;
8273 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid );
8275 wait_for_thread( thread );
8276 CloseHandle( thread );
8277 ok( info.ret == 1, "SendMessageTimeout failed\n" );
8278 ok_sequence( WmUser, "WmUser", FALSE );
8280 /* timeout is treated as signed despite the prototype */
8281 info.timeout = 0x7fffffff;
8282 info.ret = 0xdeadbeef;
8283 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid );
8285 wait_for_thread( thread );
8286 CloseHandle( thread );
8287 ok( info.ret == 1, "SendMessageTimeout failed\n" );
8288 ok_sequence( WmUser, "WmUser", FALSE );
8290 info.timeout = 0x80000000;
8291 info.ret = 0xdeadbeef;
8292 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid );
8294 wait_for_thread( thread );
8295 CloseHandle( thread );
8296 ok( info.ret == 0, "SendMessageTimeout succeeded\n" );
8297 ok_sequence( WmEmptySeq, "WmEmptySeq", FALSE );
8299 /* now check for timeout during message processing */
8300 SetWindowLongPtrA( info.hwnd, GWLP_WNDPROC, (LONG_PTR)send_msg_delay_proc );
8302 info.ret = 0xdeadbeef;
8303 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid );
8304 wait_for_thread( thread );
8305 CloseHandle( thread );
8306 /* we should time out but still get the message */
8307 ok( info.ret == 0, "SendMessageTimeout failed\n" );
8308 ok_sequence( WmUser, "WmUser", FALSE );
8310 DestroyWindow( info.hwnd );
8314 /****************** edit message test *************************/
8315 #define ID_EDIT 0x1234
8316 static const struct message sl_edit_setfocus[] =
8318 { HCBT_SETFOCUS, hook },
8319 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
8320 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
8321 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
8322 { WM_SETFOCUS, sent|wparam, 0 },
8323 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 10 },
8324 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 15 },
8325 { WM_CTLCOLOREDIT, sent|parent },
8326 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 11 },
8327 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8328 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8329 { WM_COMMAND, sent|parent|wparam, MAKEWPARAM(ID_EDIT, EN_SETFOCUS) },
8332 static const struct message ml_edit_setfocus[] =
8334 { HCBT_SETFOCUS, hook },
8335 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
8336 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
8337 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
8338 { WM_SETFOCUS, sent|wparam, 0 },
8339 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 10 },
8340 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 11 },
8341 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8342 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8343 { WM_COMMAND, sent|parent|wparam, MAKEWPARAM(ID_EDIT, EN_SETFOCUS) },
8346 static const struct message sl_edit_killfocus[] =
8348 { HCBT_SETFOCUS, hook },
8349 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
8350 { WM_KILLFOCUS, sent|wparam, 0 },
8351 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8352 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8353 { WM_COMMAND, sent|parent|wparam, MAKEWPARAM(ID_EDIT, EN_KILLFOCUS) },
8354 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
8355 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 1 },
8358 static const struct message sl_edit_lbutton_dblclk[] =
8360 { WM_LBUTTONDBLCLK, sent },
8361 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
8364 static const struct message sl_edit_lbutton_down[] =
8366 { WM_LBUTTONDOWN, sent|wparam|lparam, 0, 0 },
8367 { HCBT_SETFOCUS, hook },
8368 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
8369 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
8370 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
8371 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
8372 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 10 },
8373 { WM_CTLCOLOREDIT, sent|parent },
8374 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 11 },
8375 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8376 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8377 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8378 { WM_COMMAND, sent|parent|wparam, MAKEWPARAM(ID_EDIT, EN_SETFOCUS) },
8379 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
8380 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8381 { WM_CTLCOLOREDIT, sent|parent|optional },
8382 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 11 },
8383 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8384 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8387 static const struct message ml_edit_lbutton_down[] =
8389 { WM_LBUTTONDOWN, sent|wparam|lparam, 0, 0 },
8390 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
8391 { HCBT_SETFOCUS, hook },
8392 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
8393 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
8394 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
8395 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
8396 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 10 },
8397 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 11 },
8398 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8399 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8400 { WM_COMMAND, sent|parent|wparam, MAKEWPARAM(ID_EDIT, EN_SETFOCUS) },
8403 static const struct message sl_edit_lbutton_up[] =
8405 { WM_LBUTTONUP, sent|wparam|lparam, 0, 0 },
8406 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8407 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, 0, 0 },
8408 { WM_CAPTURECHANGED, sent|defwinproc },
8409 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8412 static const struct message ml_edit_lbutton_up[] =
8414 { WM_LBUTTONUP, sent|wparam|lparam, 0, 0 },
8415 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, 0, 0 },
8416 { WM_CAPTURECHANGED, sent|defwinproc },
8420 static WNDPROC old_edit_proc;
8422 static LRESULT CALLBACK edit_hook_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
8424 static long defwndproc_counter = 0;
8428 trace("edit: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
8430 /* explicitly ignore WM_GETICON message */
8431 if (message == WM_GETICON) return 0;
8433 msg.message = message;
8434 msg.flags = sent|wparam|lparam;
8435 if (defwndproc_counter) msg.flags |= defwinproc;
8436 msg.wParam = wParam;
8437 msg.lParam = lParam;
8440 defwndproc_counter++;
8441 ret = CallWindowProcA(old_edit_proc, hwnd, message, wParam, lParam);
8442 defwndproc_counter--;
8447 static void subclass_edit(void)
8451 if (!GetClassInfoA(0, "edit", &cls)) assert(0);
8453 old_edit_proc = cls.lpfnWndProc;
8455 cls.hInstance = GetModuleHandle(0);
8456 cls.lpfnWndProc = edit_hook_proc;
8457 cls.lpszClassName = "my_edit_class";
8458 UnregisterClass(cls.lpszClassName, cls.hInstance);
8459 if (!RegisterClassA(&cls)) assert(0);
8462 static void test_edit_messages(void)
8468 log_all_parent_messages++;
8470 parent = CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
8471 100, 100, 200, 200, 0, 0, 0, NULL);
8472 ok (parent != 0, "Failed to create parent window\n");
8474 /* test single line edit */
8475 hwnd = CreateWindowExA(0, "my_edit_class", "test", WS_CHILD,
8476 0, 0, 80, 20, parent, (HMENU)ID_EDIT, 0, NULL);
8477 ok(hwnd != 0, "Failed to create edit window\n");
8479 dlg_code = SendMessageA(hwnd, WM_GETDLGCODE, 0, 0);
8480 ok(dlg_code == (DLGC_WANTCHARS|DLGC_HASSETSEL|DLGC_WANTARROWS), "wrong dlg_code %08x\n", dlg_code);
8482 ShowWindow(hwnd, SW_SHOW);
8488 ok_sequence(sl_edit_setfocus, "SetFocus(hwnd) on an edit", FALSE);
8491 ok_sequence(sl_edit_killfocus, "SetFocus(0) on an edit", FALSE);
8497 SendMessageA(hwnd, WM_LBUTTONDBLCLK, 0, 0);
8498 ok_sequence(sl_edit_lbutton_dblclk, "WM_LBUTTONDBLCLK on an edit", FALSE);
8504 SendMessageA(hwnd, WM_LBUTTONDOWN, 0, 0);
8505 ok_sequence(sl_edit_lbutton_down, "WM_LBUTTONDOWN on an edit", FALSE);
8507 SendMessageA(hwnd, WM_LBUTTONUP, 0, 0);
8508 ok_sequence(sl_edit_lbutton_up, "WM_LBUTTONUP on an edit", FALSE);
8510 DestroyWindow(hwnd);
8512 /* test multiline edit */
8513 hwnd = CreateWindowExA(0, "my_edit_class", "test", WS_CHILD | ES_MULTILINE,
8514 0, 0, 80, 20, parent, (HMENU)ID_EDIT, 0, NULL);
8515 ok(hwnd != 0, "Failed to create edit window\n");
8517 dlg_code = SendMessageA(hwnd, WM_GETDLGCODE, 0, 0);
8518 ok(dlg_code == (DLGC_WANTCHARS|DLGC_HASSETSEL|DLGC_WANTARROWS|DLGC_WANTALLKEYS),
8519 "wrong dlg_code %08x\n", dlg_code);
8521 ShowWindow(hwnd, SW_SHOW);
8527 ok_sequence(ml_edit_setfocus, "SetFocus(hwnd) on multiline edit", FALSE);
8530 ok_sequence(sl_edit_killfocus, "SetFocus(0) on multiline edit", FALSE);
8536 SendMessageA(hwnd, WM_LBUTTONDBLCLK, 0, 0);
8537 ok_sequence(sl_edit_lbutton_dblclk, "WM_LBUTTONDBLCLK on multiline edit", FALSE);
8543 SendMessageA(hwnd, WM_LBUTTONDOWN, 0, 0);
8544 ok_sequence(ml_edit_lbutton_down, "WM_LBUTTONDOWN on multiline edit", FALSE);
8546 SendMessageA(hwnd, WM_LBUTTONUP, 0, 0);
8547 ok_sequence(ml_edit_lbutton_up, "WM_LBUTTONUP on multiline edit", FALSE);
8549 DestroyWindow(hwnd);
8550 DestroyWindow(parent);
8552 log_all_parent_messages--;
8555 /**************************** End of Edit test ******************************/
8557 static const struct message WmKeyDownSkippedSeq[] =
8559 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 1 }, /* XP */
8562 static const struct message WmKeyUpSkippedSeq[] =
8564 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xc0000001 }, /* XP */
8568 #define EV_START_STOP 0
8569 #define EV_SENDMSG 1
8575 HANDLE hevent[3]; /* 0 - start/stop, 1 - SendMessage, 2 - ack */
8578 static DWORD CALLBACK send_msg_thread_2(void *param)
8581 struct peekmsg_info *info = param;
8583 trace("thread: waiting for start\n");
8584 WaitForSingleObject(info->hevent[EV_START_STOP], INFINITE);
8585 trace("thread: looping\n");
8589 ret = WaitForMultipleObjects(2, info->hevent, FALSE, INFINITE);
8593 case WAIT_OBJECT_0 + EV_START_STOP:
8594 trace("thread: exiting\n");
8597 case WAIT_OBJECT_0 + EV_SENDMSG:
8598 trace("thread: sending message\n");
8599 SendNotifyMessageA(info->hwnd, WM_USER, 0, 0);
8600 SetEvent(info->hevent[EV_ACK]);
8604 trace("unexpected return: %04x\n", ret);
8612 static void test_PeekMessage(void)
8617 UINT qs_all_input = QS_ALLINPUT;
8618 UINT qs_input = QS_INPUT;
8620 struct peekmsg_info info;
8622 info.hwnd = CreateWindowA("TestWindowClass", NULL, WS_OVERLAPPEDWINDOW,
8623 100, 100, 200, 200, 0, 0, 0, NULL);
8625 ShowWindow(info.hwnd, SW_SHOW);
8626 UpdateWindow(info.hwnd);
8627 SetFocus(info.hwnd);
8629 info.hevent[EV_START_STOP] = CreateEventA(NULL, 0, 0, NULL);
8630 info.hevent[EV_SENDMSG] = CreateEventA(NULL, 0, 0, NULL);
8631 info.hevent[EV_ACK] = CreateEventA(NULL, 0, 0, NULL);
8633 hthread = CreateThread(NULL, 0, send_msg_thread_2, &info, 0, &tid);
8636 trace("signalling to start looping\n");
8637 SetEvent(info.hevent[EV_START_STOP]);
8642 SetLastError(0xdeadbeef);
8643 qstatus = GetQueueStatus(qs_all_input);
8644 if (GetLastError() == ERROR_INVALID_FLAGS)
8646 trace("QS_RAWINPUT not supported on this platform\n");
8647 qs_all_input &= ~QS_RAWINPUT;
8648 qs_input &= ~QS_RAWINPUT;
8650 ok(qstatus == 0, "wrong qstatus %08x\n", qstatus);
8652 trace("signalling to send message\n");
8653 SetEvent(info.hevent[EV_SENDMSG]);
8654 WaitForSingleObject(info.hevent[EV_ACK], INFINITE);
8656 /* pass invalid QS_xxxx flags */
8657 SetLastError(0xdeadbeef);
8658 qstatus = GetQueueStatus(0xffffffff);
8659 ok(qstatus == 0, "GetQueueStatus should fail: %08x\n", qstatus);
8660 ok(GetLastError() == ERROR_INVALID_FLAGS, "wrong error %d\n", GetLastError());
8662 qstatus = GetQueueStatus(qs_all_input);
8663 ok(qstatus == MAKELONG(QS_SENDMESSAGE, QS_SENDMESSAGE),
8664 "wrong qstatus %08x\n", qstatus);
8667 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE);
8669 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8671 ok_sequence(WmUser, "WmUser", FALSE);
8673 qstatus = GetQueueStatus(qs_all_input);
8674 ok(qstatus == 0, "wrong qstatus %08x\n", qstatus);
8676 keybd_event('N', 0, 0, 0);
8677 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
8678 qstatus = GetQueueStatus(qs_all_input);
8679 ok(qstatus == MAKELONG(QS_KEY, QS_KEY),
8680 "wrong qstatus %08x\n", qstatus);
8682 PostMessageA(info.hwnd, WM_CHAR, 'z', 0);
8683 qstatus = GetQueueStatus(qs_all_input);
8684 ok(qstatus == MAKELONG(QS_POSTMESSAGE, QS_POSTMESSAGE|QS_KEY),
8685 "wrong qstatus %08x\n", qstatus);
8687 InvalidateRect(info.hwnd, NULL, FALSE);
8688 qstatus = GetQueueStatus(qs_all_input);
8689 ok(qstatus == MAKELONG(QS_PAINT, QS_PAINT|QS_POSTMESSAGE|QS_KEY),
8690 "wrong qstatus %08x\n", qstatus);
8692 trace("signalling to send message\n");
8693 SetEvent(info.hevent[EV_SENDMSG]);
8694 WaitForSingleObject(info.hevent[EV_ACK], INFINITE);
8696 qstatus = GetQueueStatus(qs_all_input);
8697 ok(qstatus == MAKELONG(QS_SENDMESSAGE, QS_SENDMESSAGE|QS_PAINT|QS_POSTMESSAGE|QS_KEY),
8698 "wrong qstatus %08x\n", qstatus);
8701 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | (qs_input << 16));
8703 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8705 ok_sequence(WmUser, "WmUser", FALSE);
8707 qstatus = GetQueueStatus(qs_all_input);
8708 ok(qstatus == MAKELONG(0, QS_PAINT|QS_POSTMESSAGE|QS_KEY),
8709 "wrong qstatus %08x\n", qstatus);
8711 trace("signalling to send message\n");
8712 SetEvent(info.hevent[EV_SENDMSG]);
8713 WaitForSingleObject(info.hevent[EV_ACK], INFINITE);
8715 qstatus = GetQueueStatus(qs_all_input);
8716 ok(qstatus == MAKELONG(QS_SENDMESSAGE, QS_SENDMESSAGE|QS_PAINT|QS_POSTMESSAGE|QS_KEY),
8717 "wrong qstatus %08x\n", qstatus);
8720 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | PM_QS_POSTMESSAGE);
8722 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8724 ok_sequence(WmUser, "WmUser", FALSE);
8726 qstatus = GetQueueStatus(qs_all_input);
8727 ok(qstatus == MAKELONG(0, QS_PAINT|QS_POSTMESSAGE|QS_KEY),
8728 "wrong qstatus %08x\n", qstatus);
8731 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | PM_QS_POSTMESSAGE);
8732 ok(ret && msg.message == WM_CHAR && msg.wParam == 'z',
8733 "got %d and %04x wParam %08lx instead of TRUE and WM_CHAR wParam 'z'\n",
8734 ret, msg.message, msg.wParam);
8735 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
8737 qstatus = GetQueueStatus(qs_all_input);
8738 ok(qstatus == MAKELONG(0, QS_PAINT|QS_KEY),
8739 "wrong qstatus %08x\n", qstatus);
8742 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | PM_QS_POSTMESSAGE);
8744 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8746 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
8748 qstatus = GetQueueStatus(qs_all_input);
8749 ok(qstatus == MAKELONG(0, QS_PAINT|QS_KEY),
8750 "wrong qstatus %08x\n", qstatus);
8753 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | PM_QS_PAINT);
8754 ok(ret && msg.message == WM_PAINT,
8755 "got %d and %04x instead of TRUE and WM_PAINT\n", ret, msg.message);
8756 DispatchMessageA(&msg);
8757 ok_sequence(WmPaint, "WmPaint", FALSE);
8759 qstatus = GetQueueStatus(qs_all_input);
8760 ok(qstatus == MAKELONG(0, QS_KEY),
8761 "wrong qstatus %08x\n", qstatus);
8764 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | PM_QS_PAINT);
8766 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8768 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
8770 qstatus = GetQueueStatus(qs_all_input);
8771 ok(qstatus == MAKELONG(0, QS_KEY),
8772 "wrong qstatus %08x\n", qstatus);
8774 trace("signalling to send message\n");
8775 SetEvent(info.hevent[EV_SENDMSG]);
8776 WaitForSingleObject(info.hevent[EV_ACK], INFINITE);
8778 qstatus = GetQueueStatus(qs_all_input);
8779 ok(qstatus == MAKELONG(QS_SENDMESSAGE, QS_SENDMESSAGE|QS_KEY),
8780 "wrong qstatus %08x\n", qstatus);
8782 PostMessageA(info.hwnd, WM_CHAR, 'z', 0);
8784 qstatus = GetQueueStatus(qs_all_input);
8785 ok(qstatus == MAKELONG(QS_POSTMESSAGE, QS_SENDMESSAGE|QS_POSTMESSAGE|QS_KEY),
8786 "wrong qstatus %08x\n", qstatus);
8789 ret = PeekMessageA(&msg, 0, WM_CHAR, WM_CHAR, PM_REMOVE);
8790 ok(ret && msg.message == WM_CHAR && msg.wParam == 'z',
8791 "got %d and %04x wParam %08lx instead of TRUE and WM_CHAR wParam 'z'\n",
8792 ret, msg.message, msg.wParam);
8793 ok_sequence(WmUser, "WmUser", FALSE);
8795 qstatus = GetQueueStatus(qs_all_input);
8796 ok(qstatus == MAKELONG(0, QS_KEY),
8797 "wrong qstatus %08x\n", qstatus);
8800 ret = PeekMessageA(&msg, 0, WM_CHAR, WM_CHAR, PM_REMOVE);
8802 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8804 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
8806 qstatus = GetQueueStatus(qs_all_input);
8807 ok(qstatus == MAKELONG(0, QS_KEY),
8808 "wrong qstatus %08x\n", qstatus);
8810 PostMessageA(info.hwnd, WM_CHAR, 'z', 0);
8812 qstatus = GetQueueStatus(qs_all_input);
8813 ok(qstatus == MAKELONG(QS_POSTMESSAGE, QS_POSTMESSAGE|QS_KEY),
8814 "wrong qstatus %08x\n", qstatus);
8816 trace("signalling to send message\n");
8817 SetEvent(info.hevent[EV_SENDMSG]);
8818 WaitForSingleObject(info.hevent[EV_ACK], INFINITE);
8820 qstatus = GetQueueStatus(qs_all_input);
8821 ok(qstatus == MAKELONG(QS_SENDMESSAGE, QS_SENDMESSAGE|QS_POSTMESSAGE|QS_KEY),
8822 "wrong qstatus %08x\n", qstatus);
8825 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | (QS_KEY << 16));
8827 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8829 ok_sequence(WmUser, "WmUser", FALSE);
8831 qstatus = GetQueueStatus(qs_all_input);
8832 ok(qstatus == MAKELONG(0, QS_POSTMESSAGE|QS_KEY),
8833 "wrong qstatus %08x\n", qstatus);
8836 if (qs_all_input & QS_RAWINPUT) /* use QS_RAWINPUT only if supported */
8837 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | (QS_RAWINPUT << 16));
8838 else /* workaround for a missing QS_RAWINPUT support */
8839 ret = PeekMessageA(&msg, 0, WM_KEYDOWN, WM_KEYDOWN, PM_REMOVE);
8840 ok(ret && msg.message == WM_KEYDOWN && msg.wParam == 'N',
8841 "got %d and %04x wParam %08lx instead of TRUE and WM_KEYDOWN wParam 'N'\n",
8842 ret, msg.message, msg.wParam);
8843 ok_sequence(WmKeyDownSkippedSeq, "WmKeyDownSkippedSeq", FALSE);
8845 qstatus = GetQueueStatus(qs_all_input);
8846 ok(qstatus == MAKELONG(0, QS_POSTMESSAGE|QS_KEY),
8847 "wrong qstatus %08x\n", qstatus);
8850 if (qs_all_input & QS_RAWINPUT) /* use QS_RAWINPUT only if supported */
8851 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | (QS_RAWINPUT << 16));
8852 else /* workaround for a missing QS_RAWINPUT support */
8853 ret = PeekMessageA(&msg, 0, WM_KEYUP, WM_KEYUP, PM_REMOVE);
8854 ok(ret && msg.message == WM_KEYUP && msg.wParam == 'N',
8855 "got %d and %04x wParam %08lx instead of TRUE and WM_KEYUP wParam 'N'\n",
8856 ret, msg.message, msg.wParam);
8857 ok_sequence(WmKeyUpSkippedSeq, "WmKeyUpSkippedSeq", FALSE);
8859 qstatus = GetQueueStatus(qs_all_input);
8860 ok(qstatus == MAKELONG(0, QS_POSTMESSAGE),
8861 "wrong qstatus %08x\n", qstatus);
8864 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | PM_QS_SENDMESSAGE);
8866 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8868 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
8870 qstatus = GetQueueStatus(qs_all_input);
8871 ok(qstatus == MAKELONG(0, QS_POSTMESSAGE),
8872 "wrong qstatus %08x\n", qstatus);
8875 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE);
8876 ok(ret && msg.message == WM_CHAR && msg.wParam == 'z',
8877 "got %d and %04x wParam %08lx instead of TRUE and WM_CHAR wParam 'z'\n",
8878 ret, msg.message, msg.wParam);
8879 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
8881 qstatus = GetQueueStatus(qs_all_input);
8883 "wrong qstatus %08x\n", qstatus);
8886 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE);
8888 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8890 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
8892 qstatus = GetQueueStatus(qs_all_input);
8894 "wrong qstatus %08x\n", qstatus);
8896 /* test whether presence of the quit flag in the queue affects
8899 PostQuitMessage(0x1234abcd);
8901 qstatus = GetQueueStatus(qs_all_input);
8902 ok(qstatus == MAKELONG(QS_POSTMESSAGE, QS_POSTMESSAGE),
8903 "wrong qstatus %08x\n", qstatus);
8905 PostMessageA(info.hwnd, WM_USER, 0, 0);
8907 qstatus = GetQueueStatus(qs_all_input);
8908 ok(qstatus == MAKELONG(QS_POSTMESSAGE, QS_POSTMESSAGE),
8909 "wrong qstatus %08x\n", qstatus);
8912 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE);
8913 ok(ret && msg.message == WM_USER,
8914 "got %d and %04x instead of TRUE and WM_USER\n", ret, msg.message);
8915 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
8917 qstatus = GetQueueStatus(qs_all_input);
8918 ok(qstatus == MAKELONG(0, QS_POSTMESSAGE),
8919 "wrong qstatus %08x\n", qstatus);
8922 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE);
8923 ok(ret && msg.message == WM_QUIT,
8924 "got %d and %04x instead of TRUE and WM_QUIT\n", ret, msg.message);
8925 ok(msg.wParam == 0x1234abcd, "got wParam %08lx instead of 0x1234abcd\n", msg.wParam);
8926 ok(msg.lParam == 0, "got lParam %08lx instead of 0\n", msg.lParam);
8927 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
8929 qstatus = GetQueueStatus(qs_all_input);
8931 ok(qstatus == MAKELONG(0, QS_POSTMESSAGE),
8932 "wrong qstatus %08x\n", qstatus);
8936 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE);
8938 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8940 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
8942 qstatus = GetQueueStatus(qs_all_input);
8944 "wrong qstatus %08x\n", qstatus);
8946 trace("signalling to exit\n");
8947 SetEvent(info.hevent[EV_START_STOP]);
8949 WaitForSingleObject(hthread, INFINITE);
8951 CloseHandle(hthread);
8952 CloseHandle(info.hevent[0]);
8953 CloseHandle(info.hevent[1]);
8954 CloseHandle(info.hevent[2]);
8956 DestroyWindow(info.hwnd);
8959 static void wait_move_event(HWND hwnd, int x, int y)
8966 time = GetTickCount();
8967 while (GetTickCount() - time < 200 && !go) {
8968 ret = PeekMessageA(&msg, hwnd, WM_MOUSEMOVE, WM_MOUSEMOVE, PM_NOREMOVE);
8969 go = ret && msg.pt.x > x && msg.pt.y > y;
8974 static void test_PeekMessage2(void)
8980 DWORD time1, time2, time3;
8981 int x1, y1, x2, y2, x3, y3;
8984 time1 = time2 = time3 = 0;
8985 x1 = y1 = x2 = y2 = x3 = y3 = 0;
8987 /* Initialise window and make sure it is ready for events */
8988 hwnd = CreateWindow("TestWindowClass", "PeekMessage2", WS_OVERLAPPEDWINDOW,
8989 10, 10, 800, 800, NULL, NULL, NULL, NULL);
8991 trace("Window for test_PeekMessage2 %p\n", hwnd);
8992 ShowWindow(hwnd, SW_SHOW);
8996 SetCursorPos(100, 100);
8997 mouse_event(MOUSEEVENTF_MOVE, -STEP, -STEP, 0, 0);
9000 /* Do initial mousemove, wait until we can see it
9001 and then do our test peek with PM_NOREMOVE. */
9002 mouse_event(MOUSEEVENTF_MOVE, STEP, STEP, 0, 0);
9003 wait_move_event(hwnd, 80, 80);
9005 ret = PeekMessageA(&msg, hwnd, WM_MOUSEMOVE, WM_MOUSEMOVE, PM_NOREMOVE);
9006 ok(ret, "no message available\n");
9008 trace("1st move event: %04x %x %d %d\n", msg.message, msg.time, msg.pt.x, msg.pt.y);
9009 message = msg.message;
9013 ok(message == WM_MOUSEMOVE, "message not WM_MOUSEMOVE, %04x instead\n", message);
9016 /* Allow time to advance a bit, and then simulate the user moving their
9017 * mouse around. After that we peek again with PM_NOREMOVE.
9018 * Although the previous mousemove message was never removed, the
9019 * mousemove we now peek should reflect the recent mouse movements
9020 * because the input queue will merge the move events. */
9022 mouse_event(MOUSEEVENTF_MOVE, STEP, STEP, 0, 0);
9023 wait_move_event(hwnd, x1, y1);
9025 ret = PeekMessageA(&msg, hwnd, WM_MOUSEMOVE, WM_MOUSEMOVE, PM_NOREMOVE);
9026 ok(ret, "no message available\n");
9028 trace("2nd move event: %04x %x %d %d\n", msg.message, msg.time, msg.pt.x, msg.pt.y);
9029 message = msg.message;
9033 ok(message == WM_MOUSEMOVE, "message not WM_MOUSEMOVE, %04x instead\n", message);
9034 ok(time2 > time1, "message time not advanced: %x %x\n", time1, time2);
9035 ok(x2 != x1 && y2 != y1, "coords not changed: (%d %d) (%d %d)\n", x1, y1, x2, y2);
9038 /* Have another go, to drive the point home */
9040 mouse_event(MOUSEEVENTF_MOVE, STEP, STEP, 0, 0);
9041 wait_move_event(hwnd, x2, y2);
9043 ret = PeekMessageA(&msg, hwnd, WM_MOUSEMOVE, WM_MOUSEMOVE, PM_NOREMOVE);
9044 ok(ret, "no message available\n");
9046 trace("3rd move event: %04x %x %d %d\n", msg.message, msg.time, msg.pt.x, msg.pt.y);
9047 message = msg.message;
9051 ok(message == WM_MOUSEMOVE, "message not WM_MOUSEMOVE, %04x instead\n", message);
9052 ok(time3 > time2, "message time not advanced: %x %x\n", time2, time3);
9053 ok(x3 != x2 && y3 != y2, "coords not changed: (%d %d) (%d %d)\n", x2, y2, x3, y3);
9056 DestroyWindow(hwnd);
9057 SetCursorPos(pos.x, pos.y);
9061 static void test_quit_message(void)
9066 /* test using PostQuitMessage */
9067 PostQuitMessage(0xbeef);
9069 ret = PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE);
9070 ok(ret, "PeekMessage failed with error %d\n", GetLastError());
9071 ok(msg.message == WM_QUIT, "Received message 0x%04x instead of WM_QUIT\n", msg.message);
9072 ok(msg.wParam == 0xbeef, "wParam was 0x%lx instead of 0xbeef\n", msg.wParam);
9074 ret = PostThreadMessage(GetCurrentThreadId(), WM_USER, 0, 0);
9075 ok(ret, "PostMessage failed with error %d\n", GetLastError());
9077 ret = GetMessage(&msg, NULL, 0, 0);
9078 ok(ret > 0, "GetMessage failed with error %d\n", GetLastError());
9079 ok(msg.message == WM_USER, "Received message 0x%04x instead of WM_USER\n", msg.message);
9081 /* note: WM_QUIT message received after WM_USER message */
9082 ret = GetMessage(&msg, NULL, 0, 0);
9083 ok(!ret, "GetMessage return %d with error %d instead of FALSE\n", ret, GetLastError());
9084 ok(msg.message == WM_QUIT, "Received message 0x%04x instead of WM_QUIT\n", msg.message);
9085 ok(msg.wParam == 0xbeef, "wParam was 0x%lx instead of 0xbeef\n", msg.wParam);
9087 ret = PeekMessage(&msg, NULL, 0, 0, PM_REMOVE);
9088 ok( !ret || msg.message != WM_QUIT, "Received WM_QUIT again\n" );
9090 /* now test with PostThreadMessage - different behaviour! */
9091 PostThreadMessage(GetCurrentThreadId(), WM_QUIT, 0xdead, 0);
9093 ret = PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE);
9094 ok(ret, "PeekMessage failed with error %d\n", GetLastError());
9095 ok(msg.message == WM_QUIT, "Received message 0x%04x instead of WM_QUIT\n", msg.message);
9096 ok(msg.wParam == 0xdead, "wParam was 0x%lx instead of 0xdead\n", msg.wParam);
9098 ret = PostThreadMessage(GetCurrentThreadId(), WM_USER, 0, 0);
9099 ok(ret, "PostMessage failed with error %d\n", GetLastError());
9101 /* note: we receive the WM_QUIT message first this time */
9102 ret = GetMessage(&msg, NULL, 0, 0);
9103 ok(!ret, "GetMessage return %d with error %d instead of FALSE\n", ret, GetLastError());
9104 ok(msg.message == WM_QUIT, "Received message 0x%04x instead of WM_QUIT\n", msg.message);
9105 ok(msg.wParam == 0xdead, "wParam was 0x%lx instead of 0xdead\n", msg.wParam);
9107 ret = GetMessage(&msg, NULL, 0, 0);
9108 ok(ret > 0, "GetMessage failed with error %d\n", GetLastError());
9109 ok(msg.message == WM_USER, "Received message 0x%04x instead of WM_USER\n", msg.message);
9112 static const struct message WmMouseHoverSeq[] = {
9113 { WM_MOUSEACTIVATE, sent|optional }, /* we can get those when moving the mouse in focus-follow-mouse mode under X11 */
9114 { WM_MOUSEACTIVATE, sent|optional },
9115 { WM_TIMER, sent|optional }, /* XP sends it */
9116 { WM_SYSTIMER, sent },
9117 { WM_MOUSEHOVER, sent|wparam, 0 },
9121 static void pump_msg_loop_timeout(DWORD timeout, BOOL inject_mouse_move)
9124 DWORD start_ticks, end_ticks;
9126 start_ticks = GetTickCount();
9127 /* add some deviation (5%) to cover not expected delays */
9128 start_ticks += timeout / 20;
9132 while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
9134 /* Timer proc messages are not dispatched to the window proc,
9135 * and therefore not logged.
9137 if (msg.message == WM_TIMER || msg.message == WM_SYSTIMER)
9139 struct message s_msg;
9141 s_msg.message = msg.message;
9142 s_msg.flags = sent|wparam|lparam;
9143 s_msg.wParam = msg.wParam;
9144 s_msg.lParam = msg.lParam;
9145 add_message(&s_msg);
9147 DispatchMessage(&msg);
9150 end_ticks = GetTickCount();
9152 /* inject WM_MOUSEMOVE to see how it changes tracking */
9153 if (inject_mouse_move && start_ticks + timeout / 2 >= end_ticks)
9155 mouse_event(MOUSEEVENTF_MOVE, -1, 0, 0, 0);
9156 mouse_event(MOUSEEVENTF_MOVE, 1, 0, 0, 0);
9158 inject_mouse_move = FALSE;
9160 } while (start_ticks + timeout >= end_ticks);
9163 static void test_TrackMouseEvent(void)
9165 TRACKMOUSEEVENT tme;
9168 RECT rc_parent, rc_child;
9169 UINT default_hover_time, hover_width = 0, hover_height = 0;
9171 #define track_hover(track_hwnd, track_hover_time) \
9172 tme.cbSize = sizeof(tme); \
9173 tme.dwFlags = TME_HOVER; \
9174 tme.hwndTrack = track_hwnd; \
9175 tme.dwHoverTime = track_hover_time; \
9176 SetLastError(0xdeadbeef); \
9177 ret = pTrackMouseEvent(&tme); \
9178 ok(ret, "TrackMouseEvent(TME_HOVER) error %d\n", GetLastError())
9180 #define track_query(expected_track_flags, expected_track_hwnd, expected_hover_time) \
9181 tme.cbSize = sizeof(tme); \
9182 tme.dwFlags = TME_QUERY; \
9183 tme.hwndTrack = (HWND)0xdeadbeef; \
9184 tme.dwHoverTime = 0xdeadbeef; \
9185 SetLastError(0xdeadbeef); \
9186 ret = pTrackMouseEvent(&tme); \
9187 ok(ret, "TrackMouseEvent(TME_QUERY) error %d\n", GetLastError());\
9188 ok(tme.cbSize == sizeof(tme), "wrong tme.cbSize %u\n", tme.cbSize); \
9189 ok(tme.dwFlags == (expected_track_flags), \
9190 "wrong tme.dwFlags %08x, expected %08x\n", tme.dwFlags, (expected_track_flags)); \
9191 ok(tme.hwndTrack == (expected_track_hwnd), \
9192 "wrong tme.hwndTrack %p, expected %p\n", tme.hwndTrack, (expected_track_hwnd)); \
9193 ok(tme.dwHoverTime == (expected_hover_time), \
9194 "wrong tme.dwHoverTime %u, expected %u\n", tme.dwHoverTime, (expected_hover_time))
9196 #define track_hover_cancel(track_hwnd) \
9197 tme.cbSize = sizeof(tme); \
9198 tme.dwFlags = TME_HOVER | TME_CANCEL; \
9199 tme.hwndTrack = track_hwnd; \
9200 tme.dwHoverTime = 0xdeadbeef; \
9201 SetLastError(0xdeadbeef); \
9202 ret = pTrackMouseEvent(&tme); \
9203 ok(ret, "TrackMouseEvent(TME_HOVER | TME_CANCEL) error %d\n", GetLastError())
9205 default_hover_time = 0xdeadbeef;
9206 SetLastError(0xdeadbeef);
9207 ret = SystemParametersInfo(SPI_GETMOUSEHOVERTIME, 0, &default_hover_time, 0);
9208 ok(ret, "SystemParametersInfo(SPI_GETMOUSEHOVERTIME) error %u\n", GetLastError());
9209 if (!ret) default_hover_time = 400;
9210 trace("SPI_GETMOUSEHOVERTIME returned %u ms\n", default_hover_time);
9212 SetLastError(0xdeadbeef);
9213 ret = SystemParametersInfo(SPI_GETMOUSEHOVERWIDTH, 0, &hover_width, 0);
9214 ok(ret, "SystemParametersInfo(SPI_GETMOUSEHOVERWIDTH) error %u\n", GetLastError());
9215 if (!ret) hover_width = 4;
9216 SetLastError(0xdeadbeef);
9217 ret = SystemParametersInfo(SPI_GETMOUSEHOVERHEIGHT, 0, &hover_height, 0);
9218 ok(ret, "SystemParametersInfo(SPI_GETMOUSEHOVERHEIGHT) error %u\n", GetLastError());
9219 if (!ret) hover_height = 4;
9220 trace("hover rect is %u x %d\n", hover_width, hover_height);
9222 hwnd = CreateWindowEx(0, "TestWindowClass", NULL,
9223 WS_OVERLAPPEDWINDOW | WS_VISIBLE,
9224 CW_USEDEFAULT, CW_USEDEFAULT, 300, 300, 0,
9228 hchild = CreateWindowEx(0, "TestWindowClass", NULL,
9229 WS_CHILD | WS_BORDER | WS_VISIBLE,
9230 50, 50, 200, 200, hwnd,
9238 tme.dwFlags = TME_QUERY;
9239 tme.hwndTrack = (HWND)0xdeadbeef;
9240 tme.dwHoverTime = 0xdeadbeef;
9241 SetLastError(0xdeadbeef);
9242 ret = pTrackMouseEvent(&tme);
9243 ok(!ret, "TrackMouseEvent should fail\n");
9244 ok(GetLastError() == ERROR_INVALID_PARAMETER, "not expected error %d\n", GetLastError());
9246 tme.cbSize = sizeof(tme);
9247 tme.dwFlags = TME_HOVER;
9248 tme.hwndTrack = (HWND)0xdeadbeef;
9249 tme.dwHoverTime = 0xdeadbeef;
9250 SetLastError(0xdeadbeef);
9251 ret = pTrackMouseEvent(&tme);
9252 ok(!ret, "TrackMouseEvent should fail\n");
9253 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "not expected error %d\n", GetLastError());
9255 tme.cbSize = sizeof(tme);
9256 tme.dwFlags = TME_HOVER | TME_CANCEL;
9257 tme.hwndTrack = (HWND)0xdeadbeef;
9258 tme.dwHoverTime = 0xdeadbeef;
9259 SetLastError(0xdeadbeef);
9260 ret = pTrackMouseEvent(&tme);
9261 ok(!ret, "TrackMouseEvent should fail\n");
9262 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "not expected error %d\n", GetLastError());
9264 GetWindowRect(hwnd, &rc_parent);
9265 GetWindowRect(hchild, &rc_child);
9266 SetCursorPos(rc_child.left - 10, rc_child.top - 10);
9268 /* Process messages so that the system updates its internal current
9269 * window and hittest, otherwise TrackMouseEvent calls don't have any
9275 track_query(0, NULL, 0);
9276 track_hover(hchild, 0);
9277 track_query(0, NULL, 0);
9282 track_hover(hwnd, 0);
9283 track_query(TME_HOVER, hwnd, default_hover_time);
9285 pump_msg_loop_timeout(default_hover_time, FALSE);
9286 ok_sequence(WmMouseHoverSeq, "WmMouseHoverSeq", FALSE);
9288 track_query(0, NULL, 0);
9290 track_hover(hwnd, HOVER_DEFAULT);
9291 track_query(TME_HOVER, hwnd, default_hover_time);
9293 Sleep(default_hover_time / 2);
9294 mouse_event(MOUSEEVENTF_MOVE, -1, 0, 0, 0);
9295 mouse_event(MOUSEEVENTF_MOVE, 1, 0, 0, 0);
9297 track_query(TME_HOVER, hwnd, default_hover_time);
9299 pump_msg_loop_timeout(default_hover_time / 2, FALSE);
9300 ok_sequence(WmMouseHoverSeq, "WmMouseHoverSeq", FALSE);
9302 track_query(0, NULL, 0);
9304 track_hover(hwnd, HOVER_DEFAULT);
9305 track_query(TME_HOVER, hwnd, default_hover_time);
9307 pump_msg_loop_timeout(default_hover_time, TRUE);
9308 ok_sequence(WmMouseHoverSeq, "WmMouseHoverSeq", FALSE);
9310 track_query(0, NULL, 0);
9312 track_hover(hwnd, HOVER_DEFAULT);
9313 track_query(TME_HOVER, hwnd, default_hover_time);
9314 track_hover_cancel(hwnd);
9316 DestroyWindow(hwnd);
9320 #undef track_hover_cancel
9324 static const struct message WmSetWindowRgn[] = {
9325 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE },
9326 { WM_NCCALCSIZE, sent|wparam, 1 },
9327 { WM_NCPAINT, sent }, /* wparam != 1 */
9328 { WM_GETTEXT, sent|defwinproc|optional },
9329 { WM_ERASEBKGND, sent|optional }, /* FIXME: remove optional once Wine is fixed */
9330 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE },
9331 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
9335 static const struct message WmSetWindowRgn_no_redraw[] = {
9336 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW },
9337 { WM_NCCALCSIZE, sent|wparam, 1 },
9338 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW },
9339 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
9343 static const struct message WmSetWindowRgn_clear[] = {
9344 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
9345 { WM_NCCALCSIZE, sent|wparam, 1 },
9346 { WM_NCPAINT, sent }, /* wparam != 1 */
9347 { WM_GETTEXT, sent|defwinproc|optional },
9348 { WM_ERASEBKGND, sent|optional }, /* FIXME: remove optional once Wine is fixed */
9349 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE },
9350 { WM_NCCALCSIZE, sent|wparam|optional, 1 },
9351 { WM_NCPAINT, sent|optional }, /* wparam != 1 */
9352 { WM_GETTEXT, sent|defwinproc|optional },
9353 { WM_ERASEBKGND, sent|optional },
9354 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
9355 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
9359 static void test_SetWindowRgn(void)
9362 HWND hwnd = CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW,
9363 100, 100, 200, 200, 0, 0, 0, NULL);
9364 ok( hwnd != 0, "Failed to create overlapped window\n" );
9366 ShowWindow( hwnd, SW_SHOW );
9367 UpdateWindow( hwnd );
9371 trace("testing SetWindowRgn\n");
9372 hrgn = CreateRectRgn( 0, 0, 150, 150 );
9373 SetWindowRgn( hwnd, hrgn, TRUE );
9374 ok_sequence( WmSetWindowRgn, "WmSetWindowRgn", FALSE );
9376 hrgn = CreateRectRgn( 30, 30, 160, 160 );
9377 SetWindowRgn( hwnd, hrgn, FALSE );
9378 ok_sequence( WmSetWindowRgn_no_redraw, "WmSetWindowRgn_no_redraw", FALSE );
9380 hrgn = CreateRectRgn( 0, 0, 180, 180 );
9381 SetWindowRgn( hwnd, hrgn, TRUE );
9382 ok_sequence( WmSetWindowRgn, "WmSetWindowRgn2", FALSE );
9384 SetWindowRgn( hwnd, 0, TRUE );
9385 ok_sequence( WmSetWindowRgn_clear, "WmSetWindowRgn_clear", FALSE );
9387 DestroyWindow( hwnd );
9390 /*************************** ShowWindow() test ******************************/
9391 static const struct message WmShowNormal[] = {
9392 { WM_SHOWWINDOW, sent|wparam, 1 },
9393 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
9394 { HCBT_ACTIVATE, hook },
9395 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* win2003 doesn't send it */
9396 { HCBT_SETFOCUS, hook },
9397 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
9400 static const struct message WmShow[] = {
9401 { WM_SHOWWINDOW, sent|wparam, 1 },
9402 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
9403 { HCBT_ACTIVATE, hook|optional }, /* win2000 doesn't send it */
9404 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* win2000 doesn't send it */
9405 { HCBT_SETFOCUS, hook|optional }, /* win2000 doesn't send it */
9406 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
9409 static const struct message WmShowNoActivate_1[] = {
9410 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWNOACTIVATE },
9411 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_STATECHANGED },
9412 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_STATECHANGED },
9413 { WM_MOVE, sent|defwinproc },
9414 { WM_SIZE, sent|wparam|defwinproc, SIZE_RESTORED },
9417 static const struct message WmShowNoActivate_2[] = {
9418 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWNOACTIVATE },
9419 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
9420 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
9421 { WM_MOVE, sent|defwinproc },
9422 { WM_SIZE, sent|wparam|defwinproc, SIZE_RESTORED },
9423 { HCBT_SETFOCUS, hook|optional },
9424 { HCBT_ACTIVATE, hook|optional }, /* win2003 doesn't send it */
9425 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* win2003 doesn't send it */
9426 { HCBT_SETFOCUS, hook|optional }, /* win2003 doesn't send it */
9429 static const struct message WmShowNA_1[] = {
9430 { WM_SHOWWINDOW, sent|wparam, 1 },
9431 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
9432 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
9435 static const struct message WmShowNA_2[] = {
9436 { WM_SHOWWINDOW, sent|wparam, 1 },
9437 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
9440 static const struct message WmRestore_1[] = {
9441 { HCBT_MINMAX, hook|lparam, 0, SW_RESTORE },
9442 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
9443 { HCBT_ACTIVATE, hook|optional }, /* win2000 doesn't send it */
9444 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* win2000 doesn't send it */
9445 { HCBT_SETFOCUS, hook|optional }, /* win2000 doesn't send it */
9446 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
9447 { WM_MOVE, sent|defwinproc },
9448 { WM_SIZE, sent|wparam|defwinproc, SIZE_RESTORED },
9449 { HCBT_SETFOCUS, hook|optional }, /* win2000 sends it */
9452 static const struct message WmRestore_2[] = {
9453 { WM_SHOWWINDOW, sent|wparam, 1 },
9454 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
9455 { HCBT_ACTIVATE, hook|optional }, /* win2000 doesn't send it */
9456 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* win2000 doesn't send it */
9457 { HCBT_SETFOCUS, hook|optional }, /* win2000 doesn't send it */
9458 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
9461 static const struct message WmRestore_3[] = {
9462 { HCBT_MINMAX, hook|lparam, 0, SW_RESTORE },
9463 { WM_GETMINMAXINFO, sent },
9464 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
9465 { HCBT_ACTIVATE, hook|optional }, /* win2003 doesn't send it */
9466 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* win2003 doesn't send it */
9467 { HCBT_SETFOCUS, hook|optional }, /* win2003 doesn't send it */
9468 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
9469 { WM_MOVE, sent|defwinproc },
9470 { WM_SIZE, sent|wparam|defwinproc, SIZE_MAXIMIZED },
9471 { HCBT_SETFOCUS, hook|optional }, /* win2003 sends it */
9474 static const struct message WmRestore_4[] = {
9475 { HCBT_MINMAX, hook|lparam, 0, SW_RESTORE },
9476 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_STATECHANGED },
9477 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_STATECHANGED },
9478 { WM_MOVE, sent|defwinproc },
9479 { WM_SIZE, sent|wparam|defwinproc, SIZE_RESTORED },
9482 static const struct message WmRestore_5[] = {
9483 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWNORMAL },
9484 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_STATECHANGED },
9485 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_STATECHANGED },
9486 { WM_MOVE, sent|defwinproc },
9487 { WM_SIZE, sent|wparam|defwinproc, SIZE_RESTORED },
9490 static const struct message WmHide_1[] = {
9491 { WM_SHOWWINDOW, sent|wparam, 0 },
9492 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE },
9493 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
9494 { HCBT_SETFOCUS, hook|optional }, /* win2000 sends it */
9497 static const struct message WmHide_2[] = {
9498 { WM_SHOWWINDOW, sent|wparam, 0 },
9499 { WM_WINDOWPOSCHANGING, sent /*|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE*/ }, /* win2000 doesn't add SWP_NOACTIVATE */
9500 { WM_WINDOWPOSCHANGED, sent /*|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE*/ }, /* win2000 doesn't add SWP_NOACTIVATE */
9503 static const struct message WmHide_3[] = {
9504 { WM_SHOWWINDOW, sent|wparam, 0 },
9505 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE },
9506 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
9507 { HCBT_SETFOCUS, hook },
9508 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
9511 static const struct message WmShowMinimized_1[] = {
9512 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMINIMIZED },
9513 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
9514 { HCBT_ACTIVATE, hook|optional }, /* win2000 doesn't send it */
9515 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* win2000 doesn't send it */
9516 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
9517 { WM_MOVE, sent|defwinproc },
9518 { WM_SIZE, sent|wparam|defwinproc, SIZE_MINIMIZED },
9521 static const struct message WmMinimize_1[] = {
9522 { HCBT_MINMAX, hook|lparam, 0, SW_MINIMIZE },
9523 { HCBT_SETFOCUS, hook|optional }, /* win2000 doesn't send it */
9524 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
9525 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
9526 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
9527 { WM_MOVE, sent|defwinproc },
9528 { WM_SIZE, sent|wparam|defwinproc, SIZE_MINIMIZED },
9531 static const struct message WmMinimize_2[] = {
9532 { HCBT_MINMAX, hook|lparam, 0, SW_MINIMIZE },
9533 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
9534 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
9535 { WM_MOVE, sent|defwinproc },
9536 { WM_SIZE, sent|wparam|defwinproc, SIZE_MINIMIZED },
9539 static const struct message WmMinimize_3[] = {
9540 { HCBT_MINMAX, hook|lparam, 0, SW_MINIMIZE },
9541 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
9542 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
9543 { WM_MOVE, sent|defwinproc },
9544 { WM_SIZE, sent|wparam|defwinproc, SIZE_MINIMIZED },
9547 static const struct message WmShowMinNoActivate[] = {
9548 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMINNOACTIVE },
9549 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
9550 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
9553 static const struct message WmMinMax_1[] = {
9554 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMINIMIZED },
9557 static const struct message WmMinMax_2[] = {
9558 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMAXIMIZED },
9561 static const struct message WmMinMax_3[] = {
9562 { HCBT_MINMAX, hook|lparam, 0, SW_MINIMIZE },
9565 static const struct message WmMinMax_4[] = {
9566 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMINNOACTIVE },
9569 static const struct message WmShowMaximized_1[] = {
9570 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMAXIMIZED },
9571 { WM_GETMINMAXINFO, sent },
9572 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
9573 { HCBT_ACTIVATE, hook|optional }, /* win2000 doesn't send it */
9574 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* win2000 doesn't send it */
9575 { HCBT_SETFOCUS, hook|optional }, /* win2000 doesn't send it */
9576 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
9577 { WM_MOVE, sent|defwinproc },
9578 { WM_SIZE, sent|wparam|defwinproc, SIZE_MAXIMIZED },
9579 { HCBT_SETFOCUS, hook|optional }, /* win2003 sends it */
9582 static const struct message WmShowMaximized_2[] = {
9583 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMAXIMIZED },
9584 { WM_GETMINMAXINFO, sent },
9585 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE },
9586 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
9587 { WM_MOVE, sent|optional }, /* Win9x doesn't send it */
9588 { WM_SIZE, sent|wparam|optional, SIZE_MAXIMIZED }, /* Win9x doesn't send it */
9589 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
9590 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
9591 { WM_MOVE, sent|defwinproc },
9592 { WM_SIZE, sent|wparam|defwinproc, SIZE_MAXIMIZED },
9593 { HCBT_SETFOCUS, hook },
9596 static const struct message WmShowMaximized_3[] = {
9597 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMAXIMIZED },
9598 { WM_GETMINMAXINFO, sent },
9599 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_STATECHANGED },
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_FRAMECHANGED|SWP_STATECHANGED },
9604 { WM_MOVE, sent|defwinproc },
9605 { WM_SIZE, sent|wparam|defwinproc, SIZE_MAXIMIZED },
9609 static void test_ShowWindow(void)
9611 /* ShowWindow commands in random order */
9614 INT cmd; /* ShowWindow command */
9615 LPARAM ret; /* ShowWindow return value */
9616 DWORD style; /* window style after the command */
9617 const struct message *msg; /* message sequence the command produces */
9618 BOOL todo_msg; /* message sequence doesn't match what Wine does */
9621 /* 1 */ { SW_SHOWNORMAL, FALSE, WS_VISIBLE, WmShowNormal, FALSE },
9622 /* 2 */ { SW_SHOWNORMAL, TRUE, WS_VISIBLE, WmEmptySeq, FALSE },
9623 /* 3 */ { SW_HIDE, TRUE, 0, WmHide_1, FALSE },
9624 /* 4 */ { SW_HIDE, FALSE, 0, WmEmptySeq, FALSE },
9625 /* 5 */ { SW_SHOWMINIMIZED, FALSE, WS_VISIBLE|WS_MINIMIZE, WmShowMinimized_1, FALSE },
9626 /* 6 */ { SW_SHOWMINIMIZED, TRUE, WS_VISIBLE|WS_MINIMIZE, WmMinMax_1, FALSE },
9627 /* 7 */ { SW_HIDE, TRUE, WS_MINIMIZE, WmHide_1, FALSE },
9628 /* 8 */ { SW_HIDE, FALSE, WS_MINIMIZE, WmEmptySeq, FALSE },
9629 /* 9 */ { SW_SHOWMAXIMIZED, FALSE, WS_VISIBLE|WS_MAXIMIZE, WmShowMaximized_1, FALSE },
9630 /* 10 */ { SW_SHOWMAXIMIZED, TRUE, WS_VISIBLE|WS_MAXIMIZE, WmMinMax_2, FALSE },
9631 /* 11 */ { SW_HIDE, TRUE, WS_MAXIMIZE, WmHide_1, FALSE },
9632 /* 12 */ { SW_HIDE, FALSE, WS_MAXIMIZE, WmEmptySeq, FALSE },
9633 /* 13 */ { SW_SHOWNOACTIVATE, FALSE, WS_VISIBLE, WmShowNoActivate_1, FALSE },
9634 /* 14 */ { SW_SHOWNOACTIVATE, TRUE, WS_VISIBLE, WmEmptySeq, FALSE },
9635 /* 15 */ { SW_HIDE, TRUE, 0, WmHide_2, FALSE },
9636 /* 16 */ { SW_HIDE, FALSE, 0, WmEmptySeq, FALSE },
9637 /* 17 */ { SW_SHOW, FALSE, WS_VISIBLE, WmShow, FALSE },
9638 /* 18 */ { SW_SHOW, TRUE, WS_VISIBLE, WmEmptySeq, FALSE },
9639 /* 19 */ { SW_MINIMIZE, TRUE, WS_VISIBLE|WS_MINIMIZE, WmMinimize_1, FALSE },
9640 /* 20 */ { SW_MINIMIZE, TRUE, WS_VISIBLE|WS_MINIMIZE, WmMinMax_3, FALSE },
9641 /* 21 */ { SW_HIDE, TRUE, WS_MINIMIZE, WmHide_2, FALSE },
9642 /* 22 */ { SW_SHOWMINNOACTIVE, FALSE, WS_VISIBLE|WS_MINIMIZE, WmShowMinNoActivate, TRUE },
9643 /* 23 */ { SW_SHOWMINNOACTIVE, TRUE, WS_VISIBLE|WS_MINIMIZE, WmMinMax_4, FALSE },
9644 /* 24 */ { SW_HIDE, TRUE, WS_MINIMIZE, WmHide_2, FALSE },
9645 /* 25 */ { SW_HIDE, FALSE, WS_MINIMIZE, WmEmptySeq, FALSE },
9646 /* 26 */ { SW_SHOWNA, FALSE, WS_VISIBLE|WS_MINIMIZE, WmShowNA_1, FALSE },
9647 /* 27 */ { SW_SHOWNA, TRUE, WS_VISIBLE|WS_MINIMIZE, WmShowNA_2, FALSE },
9648 /* 28 */ { SW_HIDE, TRUE, WS_MINIMIZE, WmHide_2, FALSE },
9649 /* 29 */ { SW_HIDE, FALSE, WS_MINIMIZE, WmEmptySeq, FALSE },
9650 /* 30 */ { SW_RESTORE, FALSE, WS_VISIBLE, WmRestore_1, FALSE },
9651 /* 31 */ { SW_RESTORE, TRUE, WS_VISIBLE, WmEmptySeq, FALSE },
9652 /* 32 */ { SW_HIDE, TRUE, 0, WmHide_3, TRUE },
9653 /* 33 */ { SW_HIDE, FALSE, 0, WmEmptySeq, FALSE },
9654 /* 34 */ { SW_NORMALNA, FALSE, 0, WmEmptySeq, FALSE }, /* what does this mean?! */
9655 /* 35 */ { SW_NORMALNA, FALSE, 0, WmEmptySeq, FALSE },
9656 /* 36 */ { SW_HIDE, FALSE, 0, WmEmptySeq, FALSE },
9657 /* 37 */ { SW_RESTORE, FALSE, WS_VISIBLE, WmRestore_2, FALSE },
9658 /* 38 */ { SW_RESTORE, TRUE, WS_VISIBLE, WmEmptySeq, FALSE },
9659 /* 39 */ { SW_SHOWNOACTIVATE, TRUE, WS_VISIBLE, WmEmptySeq, FALSE },
9660 /* 40 */ { SW_MINIMIZE, TRUE, WS_VISIBLE|WS_MINIMIZE, WmMinimize_2, FALSE },
9661 /* 41 */ { SW_MINIMIZE, TRUE, WS_VISIBLE|WS_MINIMIZE, WmMinMax_3, FALSE },
9662 /* 42 */ { SW_SHOWMAXIMIZED, TRUE, WS_VISIBLE|WS_MAXIMIZE, WmShowMaximized_2, TRUE },
9663 /* 43 */ { SW_SHOWMAXIMIZED, TRUE, WS_VISIBLE|WS_MAXIMIZE, WmMinMax_2, FALSE },
9664 /* 44 */ { SW_MINIMIZE, TRUE, WS_VISIBLE|WS_MINIMIZE, WmMinimize_1, FALSE },
9665 /* 45 */ { SW_MINIMIZE, TRUE, WS_VISIBLE|WS_MINIMIZE, WmMinMax_3, FALSE },
9666 /* 46 */ { SW_RESTORE, TRUE, WS_VISIBLE|WS_MAXIMIZE, WmRestore_3, FALSE },
9667 /* 47 */ { SW_RESTORE, TRUE, WS_VISIBLE, WmRestore_4, FALSE },
9668 /* 48 */ { SW_SHOWMAXIMIZED, TRUE, WS_VISIBLE|WS_MAXIMIZE, WmShowMaximized_3, FALSE },
9669 /* 49 */ { SW_SHOW, TRUE, WS_VISIBLE|WS_MAXIMIZE, WmEmptySeq, FALSE },
9670 /* 50 */ { SW_SHOWNORMAL, TRUE, WS_VISIBLE, WmRestore_5, FALSE },
9671 /* 51 */ { SW_SHOWNORMAL, TRUE, WS_VISIBLE, WmEmptySeq, FALSE },
9672 /* 52 */ { SW_HIDE, TRUE, 0, WmHide_1, FALSE },
9673 /* 53 */ { SW_HIDE, FALSE, 0, WmEmptySeq, FALSE },
9674 /* 54 */ { SW_MINIMIZE, FALSE, WS_VISIBLE|WS_MINIMIZE, WmMinimize_3, FALSE },
9675 /* 55 */ { SW_HIDE, TRUE, WS_MINIMIZE, WmHide_2, FALSE },
9676 /* 56 */ { SW_SHOWNOACTIVATE, FALSE, WS_VISIBLE, WmShowNoActivate_2, FALSE },
9677 /* 57 */ { SW_SHOW, TRUE, WS_VISIBLE, WmEmptySeq, FALSE }
9684 #define WS_BASE (WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX|WS_MAXIMIZEBOX|WS_POPUP|WS_CLIPSIBLINGS)
9685 hwnd = CreateWindowEx(0, "ShowWindowClass", NULL, WS_BASE,
9690 style = GetWindowLong(hwnd, GWL_STYLE) & ~WS_BASE;
9691 ok(style == 0, "expected style 0, got %08x\n", style);
9696 for (i = 0; i < sizeof(sw)/sizeof(sw[0]); i++)
9698 static const char * const sw_cmd_name[13] =
9700 "SW_HIDE", "SW_SHOWNORMAL", "SW_SHOWMINIMIZED", "SW_SHOWMAXIMIZED",
9701 "SW_SHOWNOACTIVATE", "SW_SHOW", "SW_MINIMIZE", "SW_SHOWMINNOACTIVE",
9702 "SW_SHOWNA", "SW_RESTORE", "SW_SHOWDEFAULT", "SW_FORCEMINIMIZE",
9703 "SW_NORMALNA" /* 0xCC */
9706 INT idx; /* index into the above array of names */
9708 idx = (sw[i].cmd == SW_NORMALNA) ? 12 : sw[i].cmd;
9710 style = GetWindowLong(hwnd, GWL_STYLE);
9711 trace("%d: sending %s, current window style %08x\n", i+1, sw_cmd_name[idx], style);
9712 ret = ShowWindow(hwnd, sw[i].cmd);
9713 ok(!ret == !sw[i].ret, "%d: cmd %s: expected ret %lu, got %lu\n", i+1, sw_cmd_name[idx], sw[i].ret, ret);
9714 style = GetWindowLong(hwnd, GWL_STYLE) & ~WS_BASE;
9715 ok(style == sw[i].style, "%d: expected style %08x, got %08x\n", i+1, sw[i].style, style);
9717 sprintf(comment, "%d: ShowWindow(%s)", i+1, sw_cmd_name[idx]);
9718 ok_sequence(sw[i].msg, comment, sw[i].todo_msg);
9724 DestroyWindow(hwnd);
9727 static INT_PTR WINAPI test_dlg_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
9731 trace("dialog: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
9735 case WM_WINDOWPOSCHANGING:
9736 case WM_WINDOWPOSCHANGED:
9738 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
9740 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
9741 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
9742 winpos->hwnd, winpos->hwndInsertAfter,
9743 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
9744 dump_winpos_flags(winpos->flags);
9746 /* Log only documented flags, win2k uses 0x1000 and 0x2000
9747 * in the high word for internal purposes
9749 wParam = winpos->flags & 0xffff;
9750 /* We are not interested in the flags that don't match under XP and Win9x */
9751 wParam &= ~(SWP_NOZORDER);
9755 /* explicitly ignore WM_GETICON message */
9760 msg.message = message;
9761 msg.flags = sent|wparam|lparam;
9762 msg.wParam = wParam;
9763 msg.lParam = lParam;
9766 /* calling DefDlgProc leads to a recursion under XP */
9777 static const struct message WmDefDlgSetFocus_1[] = {
9778 { WM_GETDLGCODE, sent|wparam|lparam, 0, 0 },
9779 { WM_GETTEXTLENGTH, sent|wparam|lparam|optional, 0, 0 }, /* XP */
9780 { WM_GETTEXT, sent|wparam|optional, 6 }, /* XP */
9781 { WM_GETTEXT, sent|wparam|optional, 12 }, /* XP */
9782 { EM_SETSEL, sent|wparam, 0 }, /* XP sets lparam to text length, Win9x to -2 */
9783 { HCBT_SETFOCUS, hook },
9784 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
9785 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
9786 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
9787 { WM_SETFOCUS, sent|wparam, 0 },
9788 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 10 },
9789 { WM_CTLCOLOREDIT, sent },
9790 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 11 },
9791 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
9792 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
9793 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
9794 { WM_COMMAND, sent|wparam, MAKEWPARAM(1, EN_SETFOCUS) },
9797 static const struct message WmDefDlgSetFocus_2[] = {
9798 { WM_GETDLGCODE, sent|wparam|lparam, 0, 0 },
9799 { WM_GETTEXTLENGTH, sent|wparam|lparam|optional, 0, 0 }, /* XP */
9800 { WM_GETTEXT, sent|wparam|optional, 6 }, /* XP */
9801 { WM_GETTEXT, sent|wparam|optional, 12 }, /* XP */
9802 { EM_SETSEL, sent|wparam, 0 }, /* XP sets lparam to text length, Win9x to -2 */
9803 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
9804 { WM_CTLCOLOREDIT, sent|optional }, /* XP */
9805 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
9808 /* Creation of a dialog */
9809 static const struct message WmCreateDialogParamSeq_1[] = {
9810 { HCBT_CREATEWND, hook },
9811 { WM_NCCREATE, sent },
9812 { WM_NCCALCSIZE, sent|wparam, 0 },
9813 { WM_CREATE, sent },
9814 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
9815 { WM_SIZE, sent|wparam, SIZE_RESTORED },
9817 { WM_SETFONT, sent },
9818 { WM_INITDIALOG, sent },
9819 { WM_CHANGEUISTATE, sent|optional },
9822 /* Creation of a dialog */
9823 static const struct message WmCreateDialogParamSeq_2[] = {
9824 { HCBT_CREATEWND, hook },
9825 { WM_NCCREATE, sent },
9826 { WM_NCCALCSIZE, sent|wparam, 0 },
9827 { WM_CREATE, sent },
9828 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
9829 { WM_SIZE, sent|wparam, SIZE_RESTORED },
9831 { WM_CHANGEUISTATE, sent|optional },
9835 static void test_dialog_messages(void)
9838 HWND hdlg, hedit1, hedit2, hfocus;
9841 #define set_selection(hctl, start, end) \
9842 ret = SendMessage(hctl, EM_SETSEL, start, end); \
9843 ok(ret == 1, "EM_SETSEL returned %ld\n", ret);
9845 #define check_selection(hctl, start, end) \
9846 ret = SendMessage(hctl, EM_GETSEL, 0, 0); \
9847 ok(ret == MAKELRESULT(start, end), "wrong selection (%d - %d)\n", LOWORD(ret), HIWORD(ret));
9851 hdlg = CreateWindowEx(WS_EX_DLGMODALFRAME, "TestDialogClass", NULL,
9852 WS_VISIBLE|WS_CAPTION|WS_SYSMENU|WS_DLGFRAME,
9853 0, 0, 100, 100, 0, 0, 0, NULL);
9854 ok(hdlg != 0, "Failed to create custom dialog window\n");
9856 hedit1 = CreateWindowEx(0, "my_edit_class", NULL,
9857 WS_CHILD|WS_BORDER|WS_VISIBLE|WS_TABSTOP,
9858 0, 0, 80, 20, hdlg, (HMENU)1, 0, NULL);
9859 ok(hedit1 != 0, "Failed to create edit control\n");
9860 hedit2 = CreateWindowEx(0, "my_edit_class", NULL,
9861 WS_CHILD|WS_BORDER|WS_VISIBLE|WS_TABSTOP,
9862 0, 40, 80, 20, hdlg, (HMENU)2, 0, NULL);
9863 ok(hedit2 != 0, "Failed to create edit control\n");
9865 SendMessage(hedit1, WM_SETTEXT, 0, (LPARAM)"hello");
9866 SendMessage(hedit2, WM_SETTEXT, 0, (LPARAM)"bye");
9868 hfocus = GetFocus();
9869 ok(hfocus == hdlg, "wrong focus %p\n", hfocus);
9872 hfocus = GetFocus();
9873 ok(hfocus == hedit2, "wrong focus %p\n", hfocus);
9875 check_selection(hedit1, 0, 0);
9876 check_selection(hedit2, 0, 0);
9878 set_selection(hedit2, 0, -1);
9879 check_selection(hedit2, 0, 3);
9882 hfocus = GetFocus();
9883 ok(hfocus == 0, "wrong focus %p\n", hfocus);
9886 ret = DefDlgProc(hdlg, WM_SETFOCUS, 0, 0);
9887 ok(ret == 0, "WM_SETFOCUS returned %ld\n", ret);
9888 ok_sequence(WmDefDlgSetFocus_1, "DefDlgProc(WM_SETFOCUS) 1", FALSE);
9890 hfocus = GetFocus();
9891 ok(hfocus == hedit1, "wrong focus %p\n", hfocus);
9893 check_selection(hedit1, 0, 5);
9894 check_selection(hedit2, 0, 3);
9897 ret = DefDlgProc(hdlg, WM_SETFOCUS, 0, 0);
9898 ok(ret == 0, "WM_SETFOCUS returned %ld\n", ret);
9899 ok_sequence(WmDefDlgSetFocus_2, "DefDlgProc(WM_SETFOCUS) 2", FALSE);
9901 hfocus = GetFocus();
9902 ok(hfocus == hedit1, "wrong focus %p\n", hfocus);
9904 check_selection(hedit1, 0, 5);
9905 check_selection(hedit2, 0, 3);
9908 DestroyWindow(hedit1);
9909 DestroyWindow(hedit2);
9910 DestroyWindow(hdlg);
9913 #undef set_selection
9914 #undef check_selection
9916 ok(GetClassInfo(0, "#32770", &cls), "GetClassInfo failed\n");
9917 cls.lpszClassName = "MyDialogClass";
9918 cls.hInstance = GetModuleHandle(0);
9919 /* need a cast since a dlgproc is used as a wndproc */
9920 cls.lpfnWndProc = (WNDPROC)test_dlg_proc;
9921 if (!RegisterClass(&cls)) assert(0);
9923 hdlg = CreateDialogParam(0, "CLASS_TEST_DIALOG_2", 0, test_dlg_proc, 0);
9924 ok(IsWindow(hdlg), "CreateDialogParam failed\n");
9925 ok_sequence(WmCreateDialogParamSeq_1, "CreateDialogParam_1", FALSE);
9927 DestroyWindow(hdlg);
9930 hdlg = CreateDialogParam(0, "CLASS_TEST_DIALOG_2", 0, NULL, 0);
9931 ok(IsWindow(hdlg), "CreateDialogParam failed\n");
9932 ok_sequence(WmCreateDialogParamSeq_2, "CreateDialogParam_2", FALSE);
9934 DestroyWindow(hdlg);
9937 UnregisterClass(cls.lpszClassName, cls.hInstance);
9940 static void test_nullCallback(void)
9944 hwnd = CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW,
9945 100, 100, 200, 200, 0, 0, 0, NULL);
9946 ok (hwnd != 0, "Failed to create overlapped window\n");
9948 SendMessageCallbackA(hwnd,WM_NULL,0,0,NULL,0);
9950 DestroyWindow(hwnd);
9953 static const struct message SetForegroundWindowSeq[] =
9955 { WM_NCACTIVATE, sent|wparam, 0 },
9956 { WM_GETTEXT, sent|defwinproc|optional },
9957 { WM_ACTIVATE, sent|wparam, 0 },
9958 { WM_ACTIVATEAPP, sent|wparam, 0 },
9959 { WM_KILLFOCUS, sent },
9960 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
9961 { WM_IME_NOTIFY, sent|wparam|optional|defwinproc, 1 },
9965 static void test_SetForegroundWindow(void)
9969 hwnd = CreateWindowExA(0, "TestWindowClass", "Test SetForegroundWindow",
9970 WS_OVERLAPPEDWINDOW | WS_VISIBLE,
9971 100, 100, 200, 200, 0, 0, 0, NULL);
9972 ok (hwnd != 0, "Failed to create overlapped window\n");
9975 trace("SetForegroundWindow( 0 )\n");
9976 SetForegroundWindow( 0 );
9977 ok_sequence(WmEmptySeq, "SetForegroundWindow( 0 ) away from foreground top level window", FALSE);
9978 trace("SetForegroundWindow( GetDesktopWindow() )\n");
9979 SetForegroundWindow( GetDesktopWindow() );
9980 ok_sequence(SetForegroundWindowSeq, "SetForegroundWindow( desktop ) away from "
9981 "foreground top level window", FALSE);
9984 DestroyWindow(hwnd);
9987 static void test_dbcs_wm_char(void)
9998 struct message wmCharSeq[2];
10000 if (!pGetCPInfoExA)
10002 skip("GetCPInfoExA is not available\n");
10006 pGetCPInfoExA( CP_ACP, 0, &cpinfo );
10007 if (cpinfo.MaxCharSize != 2)
10009 skip( "Skipping DBCS WM_CHAR test in SBCS codepage '%s'\n", cpinfo.CodePageName );
10013 dbch[0] = dbch[1] = 0;
10015 bad_wch = cpinfo.UnicodeDefaultChar;
10016 for (i = 0; !wch && i < MAX_LEADBYTES && cpinfo.LeadByte[i]; i += 2)
10017 for (j = cpinfo.LeadByte[i]; !wch && j <= cpinfo.LeadByte[i+1]; j++)
10018 for (k = 128; k <= 255; k++)
10024 if (MultiByteToWideChar( CP_ACP, 0, str, 2, wstr, 2 ) == 1 &&
10025 WideCharToMultiByte( CP_ACP, 0, wstr, 1, str, 2, NULL, NULL ) == 2 &&
10026 (BYTE)str[0] == j && (BYTE)str[1] == k &&
10027 HIBYTE(wstr[0]) && HIBYTE(wstr[0]) != 0xff)
10038 skip( "Skipping DBCS WM_CHAR test, no appropriate char found\n" );
10041 trace( "using dbcs char %02x,%02x wchar %04x bad wchar %04x codepage '%s'\n",
10042 dbch[0], dbch[1], wch, bad_wch, cpinfo.CodePageName );
10044 hwnd = CreateWindowExW(0, testWindowClassW, NULL,
10045 WS_OVERLAPPEDWINDOW, 100, 100, 200, 200, 0, 0, 0, NULL);
10046 hwnd2 = CreateWindowExW(0, testWindowClassW, NULL,
10047 WS_OVERLAPPEDWINDOW, 100, 100, 200, 200, 0, 0, 0, NULL);
10048 ok (hwnd != 0, "Failed to create overlapped window\n");
10049 ok (hwnd2 != 0, "Failed to create overlapped window\n");
10052 memset( wmCharSeq, 0, sizeof(wmCharSeq) );
10053 wmCharSeq[0].message = WM_CHAR;
10054 wmCharSeq[0].flags = sent|wparam;
10055 wmCharSeq[0].wParam = wch;
10057 /* posted message */
10058 PostMessageA( hwnd, WM_CHAR, dbch[0], 0 );
10059 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10060 PostMessageA( hwnd, WM_CHAR, dbch[1], 0 );
10061 ok( PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "no message\n" );
10062 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
10063 ok( msg.wParam == wch, "bad wparam %lx/%x\n", msg.wParam, wch );
10064 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10066 /* posted thread message */
10067 PostThreadMessageA( GetCurrentThreadId(), WM_CHAR, dbch[0], 0 );
10068 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10069 PostMessageA( hwnd, WM_CHAR, dbch[1], 0 );
10070 ok( PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "no message\n" );
10071 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
10072 ok( msg.wParam == wch, "bad wparam %lx/%x\n", msg.wParam, wch );
10073 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10077 SendMessageA( hwnd, WM_CHAR, dbch[0], 0 );
10078 ok_sequence( WmEmptySeq, "no messages", FALSE );
10079 SendMessageA( hwnd, WM_CHAR, dbch[1], 0 );
10080 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
10081 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10083 /* sent message with timeout */
10085 SendMessageTimeoutA( hwnd, WM_CHAR, dbch[0], 0, SMTO_NORMAL, 0, &res );
10086 ok_sequence( WmEmptySeq, "no messages", FALSE );
10087 SendMessageTimeoutA( hwnd, WM_CHAR, dbch[1], 0, SMTO_NORMAL, 0, &res );
10088 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
10089 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10091 /* sent message with timeout and callback */
10093 SendMessageTimeoutA( hwnd, WM_CHAR, dbch[0], 0, SMTO_NORMAL, 0, &res );
10094 ok_sequence( WmEmptySeq, "no messages", FALSE );
10095 SendMessageCallbackA( hwnd, WM_CHAR, dbch[1], 0, NULL, 0 );
10096 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
10097 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10099 /* sent message with callback */
10101 SendNotifyMessageA( hwnd, WM_CHAR, dbch[0], 0 );
10102 ok_sequence( WmEmptySeq, "no messages", FALSE );
10103 SendMessageCallbackA( hwnd, WM_CHAR, dbch[1], 0, NULL, 0 );
10104 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
10105 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10107 /* direct window proc call */
10109 CallWindowProcA( (WNDPROC)GetWindowLongPtrA( hwnd, GWLP_WNDPROC ), hwnd, WM_CHAR, dbch[0], 0 );
10110 ok_sequence( WmEmptySeq, "no messages", FALSE );
10111 CallWindowProcA( (WNDPROC)GetWindowLongPtrA( hwnd, GWLP_WNDPROC ), hwnd, WM_CHAR, dbch[1], 0 );
10112 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
10114 /* dispatch message */
10116 msg.message = WM_CHAR;
10117 msg.wParam = dbch[0];
10119 DispatchMessageA( &msg );
10120 ok_sequence( WmEmptySeq, "no messages", FALSE );
10121 msg.wParam = dbch[1];
10122 DispatchMessageA( &msg );
10123 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
10125 /* window handle is irrelevant */
10127 SendMessageA( hwnd2, WM_CHAR, dbch[0], 0 );
10128 ok_sequence( WmEmptySeq, "no messages", FALSE );
10129 SendMessageA( hwnd, WM_CHAR, dbch[1], 0 );
10130 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
10131 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10133 /* interleaved post and send */
10135 PostMessageA( hwnd2, WM_CHAR, dbch[0], 0 );
10136 SendMessageA( hwnd2, WM_CHAR, dbch[0], 0 );
10137 ok_sequence( WmEmptySeq, "no messages", FALSE );
10138 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10139 PostMessageA( hwnd, WM_CHAR, dbch[1], 0 );
10140 ok_sequence( WmEmptySeq, "no messages", FALSE );
10141 ok( PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "no message\n" );
10142 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
10143 ok( msg.wParam == wch, "bad wparam %lx/%x\n", msg.wParam, wch );
10144 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10145 SendMessageA( hwnd, WM_CHAR, dbch[1], 0 );
10146 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
10147 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10149 /* interleaved sent message and winproc */
10151 SendMessageA( hwnd, WM_CHAR, dbch[0], 0 );
10152 CallWindowProcA( (WNDPROC)GetWindowLongPtrA( hwnd, GWLP_WNDPROC ), hwnd, WM_CHAR, dbch[0], 0 );
10153 ok_sequence( WmEmptySeq, "no messages", FALSE );
10154 SendMessageA( hwnd, WM_CHAR, dbch[1], 0 );
10155 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
10156 CallWindowProcA( (WNDPROC)GetWindowLongPtrA( hwnd, GWLP_WNDPROC ), hwnd, WM_CHAR, dbch[1], 0 );
10157 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
10159 /* interleaved winproc and dispatch */
10161 msg.message = WM_CHAR;
10162 msg.wParam = dbch[0];
10164 CallWindowProcA( (WNDPROC)GetWindowLongPtrA( hwnd, GWLP_WNDPROC ), hwnd, WM_CHAR, dbch[0], 0 );
10165 DispatchMessageA( &msg );
10166 ok_sequence( WmEmptySeq, "no messages", FALSE );
10167 msg.wParam = dbch[1];
10168 DispatchMessageA( &msg );
10169 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
10170 CallWindowProcA( (WNDPROC)GetWindowLongPtrA( hwnd, GWLP_WNDPROC ), hwnd, WM_CHAR, dbch[1], 0 );
10171 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
10173 /* interleaved sends */
10175 SendMessageA( hwnd, WM_CHAR, dbch[0], 0 );
10176 SendMessageCallbackA( hwnd, WM_CHAR, dbch[0], 0, NULL, 0 );
10177 ok_sequence( WmEmptySeq, "no messages", FALSE );
10178 SendMessageTimeoutA( hwnd, WM_CHAR, dbch[1], 0, SMTO_NORMAL, 0, &res );
10179 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
10180 SendMessageA( hwnd, WM_CHAR, dbch[1], 0 );
10181 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
10185 SendMessageA( hwnd2, WM_CHAR, (dbch[1] << 8) | dbch[0], 0 );
10186 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
10187 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10189 /* other char messages are not magic */
10190 PostMessageA( hwnd, WM_SYSCHAR, dbch[0], 0 );
10191 ok( PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "no message\n" );
10192 ok( msg.message == WM_SYSCHAR, "unexpected message %x\n", msg.message );
10193 ok( msg.wParam == bad_wch, "bad wparam %lx/%x\n", msg.wParam, bad_wch );
10194 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10195 PostMessageA( hwnd, WM_DEADCHAR, dbch[0], 0 );
10196 ok( PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "no message\n" );
10197 ok( msg.message == WM_DEADCHAR, "unexpected message %x\n", msg.message );
10198 ok( msg.wParam == bad_wch, "bad wparam %lx/%x\n", msg.wParam, bad_wch );
10199 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10201 /* test retrieving messages */
10203 PostMessageW( hwnd, WM_CHAR, wch, 0 );
10204 ok( PeekMessageA( &msg, hwnd, 0, 0, PM_REMOVE ), "no message\n" );
10205 ok( msg.hwnd == hwnd, "unexpected hwnd %p\n", msg.hwnd );
10206 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
10207 ok( msg.wParam == dbch[0], "bad wparam %lx/%x\n", msg.wParam, dbch[0] );
10208 ok( PeekMessageA( &msg, hwnd, 0, 0, PM_REMOVE ), "no message\n" );
10209 ok( msg.hwnd == hwnd, "unexpected hwnd %p\n", msg.hwnd );
10210 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
10211 ok( msg.wParam == dbch[1], "bad wparam %lx/%x\n", msg.wParam, dbch[0] );
10212 ok( !PeekMessageA( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10214 /* message filters */
10215 PostMessageW( hwnd, WM_CHAR, wch, 0 );
10216 ok( PeekMessageA( &msg, hwnd, 0, 0, PM_REMOVE ), "no message\n" );
10217 ok( msg.hwnd == hwnd, "unexpected hwnd %p\n", msg.hwnd );
10218 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
10219 ok( msg.wParam == dbch[0], "bad wparam %lx/%x\n", msg.wParam, dbch[0] );
10220 /* message id is filtered, hwnd is not */
10221 ok( !PeekMessageA( &msg, hwnd, WM_MOUSEFIRST, WM_MOUSELAST, PM_REMOVE ), "no message\n" );
10222 ok( PeekMessageA( &msg, hwnd2, 0, 0, PM_REMOVE ), "no message\n" );
10223 ok( msg.hwnd == hwnd, "unexpected hwnd %p\n", msg.hwnd );
10224 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
10225 ok( msg.wParam == dbch[1], "bad wparam %lx/%x\n", msg.wParam, dbch[0] );
10226 ok( !PeekMessageA( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10228 /* mixing GetMessage and PostMessage */
10229 PostMessageW( hwnd, WM_CHAR, wch, 0xbeef );
10230 ok( GetMessageA( &msg, hwnd, 0, 0 ), "no message\n" );
10231 ok( msg.hwnd == hwnd, "unexpected hwnd %p\n", msg.hwnd );
10232 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
10233 ok( msg.wParam == dbch[0], "bad wparam %lx/%x\n", msg.wParam, dbch[0] );
10234 ok( msg.lParam == 0xbeef, "bad lparam %lx\n", msg.lParam );
10237 ok( time - GetTickCount() <= 100, "bad time %x\n", msg.time );
10238 ok( PeekMessageA( &msg, 0, 0, 0, PM_REMOVE ), "no message\n" );
10239 ok( msg.hwnd == hwnd, "unexpected hwnd %p\n", msg.hwnd );
10240 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
10241 ok( msg.wParam == dbch[1], "bad wparam %lx/%x\n", msg.wParam, dbch[0] );
10242 ok( msg.lParam == 0xbeef, "bad lparam %lx\n", msg.lParam );
10243 ok( msg.time == time, "bad time %x/%x\n", msg.time, time );
10244 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 );
10245 ok( !PeekMessageA( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10247 /* without PM_REMOVE */
10248 PostMessageW( hwnd, WM_CHAR, wch, 0 );
10249 ok( PeekMessageA( &msg, 0, 0, 0, PM_NOREMOVE ), "no message\n" );
10250 ok( msg.hwnd == hwnd, "unexpected hwnd %p\n", msg.hwnd );
10251 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
10252 ok( msg.wParam == dbch[0], "bad wparam %lx/%x\n", msg.wParam, dbch[0] );
10253 ok( PeekMessageA( &msg, 0, 0, 0, PM_REMOVE ), "no message\n" );
10254 ok( msg.hwnd == hwnd, "unexpected hwnd %p\n", msg.hwnd );
10255 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
10256 ok( msg.wParam == dbch[0], "bad wparam %lx/%x\n", msg.wParam, dbch[0] );
10257 ok( PeekMessageA( &msg, 0, 0, 0, PM_NOREMOVE ), "no message\n" );
10258 ok( msg.hwnd == hwnd, "unexpected hwnd %p\n", msg.hwnd );
10259 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
10260 ok( msg.wParam == dbch[1], "bad wparam %lx/%x\n", msg.wParam, dbch[0] );
10261 ok( PeekMessageA( &msg, 0, 0, 0, PM_REMOVE ), "no message\n" );
10262 ok( msg.hwnd == hwnd, "unexpected hwnd %p\n", msg.hwnd );
10263 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
10264 ok( msg.wParam == dbch[1], "bad wparam %lx/%x\n", msg.wParam, dbch[0] );
10265 ok( !PeekMessageA( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10267 DestroyWindow(hwnd);
10270 #define ID_LISTBOX 0x000f
10272 static const struct message wm_lb_setcursel_0[] =
10274 { LB_SETCURSEL, sent|wparam|lparam, 0, 0 },
10275 { WM_CTLCOLORLISTBOX, sent|parent },
10276 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_LISTBOX, 0x000120f2 },
10277 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 1 },
10278 { EVENT_OBJECT_SELECTION, winevent_hook|wparam|lparam, OBJID_CLIENT, 1 },
10281 static const struct message wm_lb_setcursel_1[] =
10283 { LB_SETCURSEL, sent|wparam|lparam, 1, 0 },
10284 { WM_CTLCOLORLISTBOX, sent|parent },
10285 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_LISTBOX, 0x000020f2 },
10286 { WM_CTLCOLORLISTBOX, sent|parent },
10287 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_LISTBOX, 0x000121f2 },
10288 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 2 },
10289 { EVENT_OBJECT_SELECTION, winevent_hook|wparam|lparam, OBJID_CLIENT, 2 },
10292 static const struct message wm_lb_setcursel_2[] =
10294 { LB_SETCURSEL, sent|wparam|lparam, 2, 0 },
10295 { WM_CTLCOLORLISTBOX, sent|parent },
10296 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_LISTBOX, 0x000021f2 },
10297 { WM_CTLCOLORLISTBOX, sent|parent },
10298 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_LISTBOX, 0x000122f2 },
10299 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 3 },
10300 { EVENT_OBJECT_SELECTION, winevent_hook|wparam|lparam, OBJID_CLIENT, 3 },
10303 static const struct message wm_lb_click_0[] =
10305 { WM_LBUTTONDOWN, sent|wparam|lparam, 0, MAKELPARAM(1,1) },
10306 { HCBT_SETFOCUS, hook },
10307 { WM_KILLFOCUS, sent|parent },
10308 { WM_IME_SETCONTEXT, sent|wparam|optional|parent, 0 },
10309 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
10310 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
10311 { WM_SETFOCUS, sent|defwinproc },
10313 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_LISTBOX, 0x001142f2 },
10314 { WM_COMMAND, sent|wparam|parent, MAKEWPARAM(ID_LISTBOX, LBN_SETFOCUS) },
10315 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 3 },
10316 { WM_LBTRACKPOINT, sent|wparam|lparam|parent, 0, MAKELPARAM(1,1) },
10317 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
10319 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_LISTBOX, 0x000142f2 },
10320 { WM_CTLCOLORLISTBOX, sent|parent },
10321 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_LISTBOX, 0x000022f2 },
10322 { WM_CTLCOLORLISTBOX, sent|parent },
10323 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_LISTBOX, 0x000120f2 },
10324 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_LISTBOX, 0x001140f2 },
10326 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 1 },
10327 { EVENT_OBJECT_SELECTION, winevent_hook|wparam|lparam, OBJID_CLIENT, 1 },
10329 { WM_LBUTTONUP, sent|wparam|lparam, 0, 0 },
10330 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, 0, 0 },
10331 { WM_CAPTURECHANGED, sent|wparam|lparam|defwinproc, 0, 0 },
10332 { WM_COMMAND, sent|wparam|parent, MAKEWPARAM(ID_LISTBOX, LBN_SELCHANGE) },
10336 #define check_lb_state(a1, a2, a3, a4, a5) check_lb_state_dbg(a1, a2, a3, a4, a5, __LINE__)
10338 static LRESULT (WINAPI *listbox_orig_proc)(HWND, UINT, WPARAM, LPARAM);
10340 static LRESULT WINAPI listbox_hook_proc(HWND hwnd, UINT message, WPARAM wp, LPARAM lp)
10342 static long defwndproc_counter = 0;
10344 struct message msg;
10346 /* do not log painting messages */
10347 if (message != WM_PAINT &&
10348 message != WM_NCPAINT &&
10349 message != WM_SYNCPAINT &&
10350 message != WM_ERASEBKGND &&
10351 message != WM_NCHITTEST &&
10352 message != WM_GETTEXT &&
10353 message != WM_GETICON &&
10354 message != WM_DEVICECHANGE)
10356 trace("listbox: %p, %04x, %08lx, %08lx\n", hwnd, message, wp, lp);
10358 msg.message = message;
10359 msg.flags = sent|wparam|lparam;
10360 if (defwndproc_counter) msg.flags |= defwinproc;
10366 defwndproc_counter++;
10367 ret = CallWindowProcA(listbox_orig_proc, hwnd, message, wp, lp);
10368 defwndproc_counter--;
10373 static void check_lb_state_dbg(HWND listbox, int count, int cur_sel,
10374 int caret_index, int top_index, int line)
10378 /* calling an orig proc helps to avoid unnecessary message logging */
10379 ret = CallWindowProcA(listbox_orig_proc, listbox, LB_GETCOUNT, 0, 0);
10380 ok_(__FILE__, line)(ret == count, "expected count %d, got %ld\n", count, ret);
10381 ret = CallWindowProcA(listbox_orig_proc, listbox, LB_GETCURSEL, 0, 0);
10382 ok_(__FILE__, line)(ret == cur_sel, "expected cur sel %d, got %ld\n", cur_sel, ret);
10383 ret = CallWindowProcA(listbox_orig_proc, listbox, LB_GETCARETINDEX, 0, 0);
10384 ok_(__FILE__, line)(ret == caret_index, "expected caret index %d, got %ld\n", caret_index, ret);
10385 ret = CallWindowProcA(listbox_orig_proc, listbox, LB_GETTOPINDEX, 0, 0);
10386 ok_(__FILE__, line)(ret == top_index, "expected top index %d, got %ld\n", top_index, ret);
10389 static void test_listbox_messages(void)
10391 HWND parent, listbox;
10394 parent = CreateWindowExA(0, "TestParentClass", NULL, WS_OVERLAPPEDWINDOW | WS_VISIBLE,
10395 100, 100, 200, 200, 0, 0, 0, NULL);
10396 listbox = CreateWindowExA(WS_EX_NOPARENTNOTIFY, "ListBox", NULL,
10397 WS_CHILD | LBS_NOTIFY | LBS_OWNERDRAWVARIABLE | LBS_HASSTRINGS | WS_VISIBLE,
10398 10, 10, 80, 80, parent, (HMENU)ID_LISTBOX, 0, NULL);
10399 listbox_orig_proc = (WNDPROC)SetWindowLongPtrA(listbox, GWLP_WNDPROC, (ULONG_PTR)listbox_hook_proc);
10401 check_lb_state(listbox, 0, LB_ERR, 0, 0);
10403 ret = SendMessage(listbox, LB_ADDSTRING, 0, (LPARAM)"item 0");
10404 ok(ret == 0, "expected 0, got %ld\n", ret);
10405 ret = SendMessage(listbox, LB_ADDSTRING, 0, (LPARAM)"item 1");
10406 ok(ret == 1, "expected 1, got %ld\n", ret);
10407 ret = SendMessage(listbox, LB_ADDSTRING, 0, (LPARAM)"item 2");
10408 ok(ret == 2, "expected 2, got %ld\n", ret);
10410 check_lb_state(listbox, 3, LB_ERR, 0, 0);
10414 log_all_parent_messages++;
10416 trace("selecting item 0\n");
10417 ret = SendMessage(listbox, LB_SETCURSEL, 0, 0);
10418 ok(ret == 0, "expected 0, got %ld\n", ret);
10419 ok_sequence(wm_lb_setcursel_0, "LB_SETCURSEL 0", FALSE );
10420 check_lb_state(listbox, 3, 0, 0, 0);
10423 trace("selecting item 1\n");
10424 ret = SendMessage(listbox, LB_SETCURSEL, 1, 0);
10425 ok(ret == 1, "expected 1, got %ld\n", ret);
10426 ok_sequence(wm_lb_setcursel_1, "LB_SETCURSEL 1", FALSE );
10427 check_lb_state(listbox, 3, 1, 1, 0);
10429 trace("selecting item 2\n");
10430 ret = SendMessage(listbox, LB_SETCURSEL, 2, 0);
10431 ok(ret == 2, "expected 2, got %ld\n", ret);
10432 ok_sequence(wm_lb_setcursel_2, "LB_SETCURSEL 2", FALSE );
10433 check_lb_state(listbox, 3, 2, 2, 0);
10435 trace("clicking on item 0\n");
10436 ret = SendMessage(listbox, WM_LBUTTONDOWN, 0, MAKELPARAM(1, 1));
10437 ok(ret == LB_OKAY, "expected LB_OKAY, got %ld\n", ret);
10438 ret = SendMessage(listbox, WM_LBUTTONUP, 0, 0);
10439 ok(ret == LB_OKAY, "expected LB_OKAY, got %ld\n", ret);
10440 ok_sequence(wm_lb_click_0, "WM_LBUTTONDOWN 0", FALSE );
10441 check_lb_state(listbox, 3, 0, 0, 0);
10444 log_all_parent_messages--;
10446 DestroyWindow(listbox);
10447 DestroyWindow(parent);
10453 FARPROC pIsWinEventHookInstalled = 0;/*GetProcAddress(user32, "IsWinEventHookInstalled");*/
10457 if (!RegisterWindowClasses()) assert(0);
10459 if (pSetWinEventHook)
10461 hEvent_hook = (HWINEVENTHOOK)pSetWinEventHook(EVENT_MIN, EVENT_MAX,
10462 GetModuleHandleA(0),
10465 GetCurrentThreadId(),
10466 WINEVENT_INCONTEXT);
10467 assert(hEvent_hook);
10469 if (pIsWinEventHookInstalled)
10472 for (event = EVENT_MIN; event <= EVENT_MAX; event++)
10473 ok(pIsWinEventHookInstalled(event), "IsWinEventHookInstalled(%u) failed\n", event);
10477 cbt_hook_thread_id = GetCurrentThreadId();
10478 hCBT_hook = SetWindowsHookExA(WH_CBT, cbt_hook_proc, 0, GetCurrentThreadId());
10483 /* Fix message sequences before removing 4 lines below */
10485 if (pUnhookWinEvent && hEvent_hook)
10487 ret = pUnhookWinEvent(hEvent_hook);
10488 ok( ret, "UnhookWinEvent error %d\n", GetLastError());
10489 pUnhookWinEvent = 0;
10495 test_PeekMessage();
10496 test_PeekMessage2();
10497 test_scrollwindowex();
10500 invisible_parent_tests();
10501 test_mdi_messages();
10502 test_button_messages();
10503 test_static_messages();
10504 test_listbox_messages();
10505 test_combobox_messages();
10506 test_wmime_keydown_message();
10507 test_paint_messages();
10508 test_interthread_messages();
10509 test_message_conversion();
10510 test_accelerators();
10512 test_timers_no_wnd();
10514 test_DestroyWindow();
10515 test_DispatchMessage();
10516 test_SendMessageTimeout();
10517 test_edit_messages();
10518 test_quit_message();
10520 if (!pTrackMouseEvent)
10521 skip("TrackMouseEvent is not available\n");
10523 test_TrackMouseEvent();
10525 test_SetWindowRgn();
10527 test_dialog_messages();
10528 test_nullCallback();
10529 test_SetForegroundWindow();
10530 test_dbcs_wm_char();
10532 UnhookWindowsHookEx(hCBT_hook);
10533 if (pUnhookWinEvent)
10535 ret = pUnhookWinEvent(hEvent_hook);
10536 ok( ret, "UnhookWinEvent error %d\n", GetLastError());
10537 SetLastError(0xdeadbeef);
10538 ok(!pUnhookWinEvent(hEvent_hook), "UnhookWinEvent succeeded\n");
10539 ok(GetLastError() == ERROR_INVALID_HANDLE || /* Win2k */
10540 GetLastError() == 0xdeadbeef, /* Win9x */
10541 "unexpected error %d\n", GetLastError());
10544 skip("UnhookWinEvent is not available\n");