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
43 #define SW_NORMALNA 0xCC /* undoc. flag in MinMaximize */
46 #define WM_SYSTIMER 0x0118
49 #define WND_PARENT_ID 1
50 #define WND_POPUP_ID 2
51 #define WND_CHILD_ID 3
53 static BOOL test_DestroyWindow_flag
;
54 static HWINEVENTHOOK hEvent_hook
;
56 static HWND (WINAPI
*pGetAncestor
)(HWND
,UINT
);
58 static void dump_winpos_flags(UINT flags
);
61 FIXME: add tests for these
62 Window Edge Styles (Win31/Win95/98 look), in order of precedence:
63 WS_EX_DLGMODALFRAME: double border, WS_CAPTION allowed
64 WS_THICKFRAME: thick border
65 WS_DLGFRAME: double border, WS_CAPTION not allowed (but possibly shown anyway)
66 WS_BORDER (default for overlapped windows): single black border
67 none (default for child (and popup?) windows): no border
84 UINT message
; /* the WM_* code */
85 msg_flags_t flags
; /* message props */
86 WPARAM wParam
; /* expected value of wParam */
87 LPARAM lParam
; /* expected value of lParam */
90 /* Empty message sequence */
91 static const struct message WmEmptySeq
[] =
95 /* CreateWindow (for overlapped window, not initially visible) (16/32) */
96 static const struct message WmCreateOverlappedSeq
[] = {
97 { HCBT_CREATEWND
, hook
},
98 { WM_GETMINMAXINFO
, sent
},
99 { WM_NCCREATE
, sent
},
100 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
101 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
103 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
106 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
107 * for a not visible overlapped window.
109 static const struct message WmSWP_ShowOverlappedSeq
[] = {
110 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
111 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
112 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
113 { WM_GETTEXT
, sent
|defwinproc
|optional
},
114 { WM_ERASEBKGND
, sent
|optional
},
115 { HCBT_ACTIVATE
, hook
},
116 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
117 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
118 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* Win9x: SWP_NOSENDCHANGING */
119 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
120 { WM_NCACTIVATE
, sent
|wparam
, 1 },
121 { WM_GETTEXT
, sent
|defwinproc
|optional
},
122 { WM_ACTIVATE
, sent
|wparam
, 1 },
123 { HCBT_SETFOCUS
, hook
},
124 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
125 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
126 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
127 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
128 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
129 { WM_GETTEXT
, sent
|defwinproc
|optional
},
130 { WM_ERASEBKGND
, sent
|optional
},
131 /* Win9x adds SWP_NOZORDER below */
132 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
133 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
134 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
135 { WM_ERASEBKGND
, sent
|optional
},
136 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
139 /* SetWindowPos(SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE)
140 * for a visible overlapped window.
142 static const struct message WmSWP_HideOverlappedSeq
[] = {
143 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
144 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
145 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
149 /* SetWindowPos(SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOMOVE)
150 * for a visible overlapped window.
152 static const struct message WmSWP_ResizeSeq
[] = {
153 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
},
154 { WM_GETMINMAXINFO
, sent
|defwinproc
},
155 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
156 { WM_NCPAINT
, sent
|optional
},
157 { WM_GETTEXT
, sent
|defwinproc
|optional
},
158 { WM_ERASEBKGND
, sent
|optional
},
159 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
},
160 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
161 { WM_NCCALCSIZE
, sent
|wparam
|optional
, TRUE
},
162 { WM_NCPAINT
, sent
|optional
},
163 { WM_GETTEXT
, sent
|defwinproc
|optional
},
164 { WM_ERASEBKGND
, sent
|optional
},
165 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
166 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* XP sends a duplicate */
170 /* SetWindowPos(SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOMOVE)
171 * for a visible popup window.
173 static const struct message WmSWP_ResizePopupSeq
[] = {
174 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
},
175 { WM_GETMINMAXINFO
, sent
|defwinproc
|optional
}, /* Win9x */
176 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
177 { WM_NCPAINT
, sent
|optional
},
178 { WM_GETTEXT
, sent
|defwinproc
|optional
},
179 { WM_ERASEBKGND
, sent
|optional
},
180 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
},
181 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
182 { WM_NCCALCSIZE
, sent
|wparam
|optional
, TRUE
},
183 { WM_NCPAINT
, sent
|optional
},
184 { WM_GETTEXT
, sent
|defwinproc
|optional
},
185 { WM_ERASEBKGND
, sent
|optional
},
186 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
190 /* SetWindowPos(SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOSIZE)
191 * for a visible overlapped window.
193 static const struct message WmSWP_MoveSeq
[] = {
194 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOSIZE
},
195 { WM_NCPAINT
, sent
|optional
},
196 { WM_GETTEXT
, sent
|defwinproc
|optional
},
197 { WM_ERASEBKGND
, sent
|optional
},
198 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOCLIENTSIZE
},
199 { WM_MOVE
, sent
|defwinproc
|wparam
, 0 },
200 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
204 /* SetWindowPos(SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|
205 SWP_NOZORDER|SWP_FRAMECHANGED)
206 * for a visible overlapped window with WS_CLIPCHILDREN style set.
208 static const struct message WmSWP_FrameChanged_clip
[] = {
209 { WM_WINDOWPOSCHANGING
, sent
|wparam
|parent
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
},
210 { WM_NCCALCSIZE
, sent
|wparam
|parent
, 1 },
211 { WM_NCPAINT
, sent
|parent
}, /* wparam != 1 */
212 { WM_GETTEXT
, sent
|parent
|defwinproc
|optional
},
213 { WM_ERASEBKGND
, sent
|parent
|optional
}, /* FIXME: remove optional once Wine is fixed */
214 { WM_NCPAINT
, sent
}, /* wparam != 1 */
215 { WM_ERASEBKGND
, sent
},
216 { WM_WINDOWPOSCHANGED
, sent
|wparam
|parent
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
217 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
221 /* SetWindowPos(SWP_NOSIZE|SWP_NOMOVE|SWP_DEFERERASE|SWP_NOACTIVATE|
222 SWP_NOZORDER|SWP_FRAMECHANGED)
223 * for a visible overlapped window.
225 static const struct message WmSWP_FrameChangedDeferErase
[] = {
226 { WM_WINDOWPOSCHANGING
, sent
|wparam
|parent
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_DEFERERASE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
},
227 { WM_NCCALCSIZE
, sent
|wparam
|parent
, 1 },
228 { WM_WINDOWPOSCHANGED
, sent
|wparam
|parent
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_DEFERERASE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
229 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
230 { WM_PAINT
, sent
|parent
},
231 { WM_NCPAINT
, sent
|beginpaint
|parent
}, /* wparam != 1 */
232 { WM_GETTEXT
, sent
|beginpaint
|parent
|defwinproc
|optional
},
234 { WM_NCPAINT
, sent
|beginpaint
}, /* wparam != 1 */
235 { WM_ERASEBKGND
, sent
|beginpaint
},
239 /* SetWindowPos(SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|
240 SWP_NOZORDER|SWP_FRAMECHANGED)
241 * for a visible overlapped window without WS_CLIPCHILDREN style set.
243 static const struct message WmSWP_FrameChanged_noclip
[] = {
244 { WM_WINDOWPOSCHANGING
, sent
|wparam
|parent
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
},
245 { WM_NCCALCSIZE
, sent
|wparam
|parent
, 1 },
246 { WM_NCPAINT
, sent
|parent
}, /* wparam != 1 */
247 { WM_GETTEXT
, sent
|parent
|defwinproc
|optional
},
248 { WM_ERASEBKGND
, sent
|parent
|optional
}, /* FIXME: remove optional once Wine is fixed */
249 { WM_WINDOWPOSCHANGED
, sent
|wparam
|parent
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
250 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
252 { WM_NCPAINT
, sent
|beginpaint
}, /* wparam != 1 */
253 { WM_ERASEBKGND
, sent
|beginpaint
},
257 /* ShowWindow(SW_SHOW) for a not visible overlapped window */
258 static const struct message WmShowOverlappedSeq
[] = {
259 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
260 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
261 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
262 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
263 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
264 { WM_GETTEXT
, sent
|defwinproc
|optional
},
265 { WM_ERASEBKGND
, sent
|optional
},
266 { HCBT_ACTIVATE
, hook
},
267 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
268 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
269 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
},
270 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
271 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
272 { WM_NCACTIVATE
, sent
|wparam
, 1 },
273 { WM_GETTEXT
, sent
|defwinproc
|optional
},
274 { WM_ACTIVATE
, sent
|wparam
, 1 },
275 { HCBT_SETFOCUS
, hook
},
276 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
277 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
278 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
279 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
280 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
281 { WM_GETTEXT
, sent
|defwinproc
|optional
},
282 { WM_ERASEBKGND
, sent
|optional
},
283 /* Win9x adds SWP_NOZORDER below */
284 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
285 { WM_NCCALCSIZE
, sent
|optional
},
286 { WM_NCPAINT
, sent
|optional
},
287 { WM_ERASEBKGND
, sent
|optional
},
288 #if 0 /* CreateWindow/ShowWindow(SW_SHOW) also generates WM_SIZE/WM_MOVE
289 * messages. Does that mean that CreateWindow doesn't set initial
290 * window dimensions for overlapped windows?
297 /* ShowWindow(SW_SHOWMAXIMIZED) for a not visible overlapped window */
298 static const struct message WmShowMaxOverlappedSeq
[] = {
299 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
300 { WM_GETMINMAXINFO
, sent
},
301 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|0x8000 },
302 { WM_GETMINMAXINFO
, sent
|defwinproc
},
303 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
304 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
305 { HCBT_ACTIVATE
, hook
},
306 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
307 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
308 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
},
309 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
310 { WM_NCACTIVATE
, sent
|wparam
, 1 },
311 { WM_GETTEXT
, sent
|defwinproc
|optional
},
312 { WM_ACTIVATE
, sent
|wparam
, 1 },
313 { HCBT_SETFOCUS
, hook
},
314 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
315 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
316 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
317 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
318 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
319 { WM_GETTEXT
, sent
|defwinproc
|optional
},
320 { WM_ERASEBKGND
, sent
|optional
},
321 /* Win9x adds SWP_NOZORDER below */
322 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|0x8000 },
323 { WM_MOVE
, sent
|defwinproc
},
324 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
325 { WM_NCCALCSIZE
, sent
|optional
},
326 { WM_NCPAINT
, sent
|optional
},
327 { WM_ERASEBKGND
, sent
|optional
},
328 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
329 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
332 /* ShowWindow(SW_HIDE) for a visible overlapped window */
333 static const struct message WmHideOverlappedSeq
[] = {
334 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
335 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
336 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
337 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
338 { WM_SIZE
, sent
|optional
}, /* XP doesn't send it */
339 { WM_MOVE
, sent
|optional
}, /* XP doesn't send it */
340 { WM_NCACTIVATE
, sent
|wparam
, 0 },
341 { WM_ACTIVATE
, sent
|wparam
, 0 },
342 { WM_ACTIVATEAPP
, sent
|wparam
, 0 },
343 { WM_KILLFOCUS
, sent
|wparam
, 0 },
344 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
345 { WM_IME_NOTIFY
, sent
|wparam
|optional
|defwinproc
, 1 },
348 /* DestroyWindow for a visible overlapped window */
349 static const struct message WmDestroyOverlappedSeq
[] = {
350 { HCBT_DESTROYWND
, hook
},
351 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
352 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
353 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
354 { WM_NCACTIVATE
, sent
|wparam
, 0 },
355 { WM_ACTIVATE
, sent
|wparam
, 0 },
356 { WM_ACTIVATEAPP
, sent
|wparam
, 0 },
357 { WM_KILLFOCUS
, sent
|wparam
, 0 },
358 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
359 { WM_IME_NOTIFY
, sent
|wparam
|optional
|defwinproc
, 1 },
360 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
361 { WM_DESTROY
, sent
},
362 { WM_NCDESTROY
, sent
},
365 /* CreateWindow(WS_MAXIMIZE|WS_VISIBLE) for popup window */
366 static const struct message WmCreateMaxPopupSeq
[] = {
367 { HCBT_CREATEWND
, hook
},
368 { WM_NCCREATE
, sent
},
369 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
371 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
373 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
374 { WM_GETMINMAXINFO
, sent
},
375 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|0x8000 },
376 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
377 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOREDRAW
|0x8000 },
378 { WM_MOVE
, sent
|defwinproc
},
379 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
380 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
381 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
382 { HCBT_ACTIVATE
, hook
},
383 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
384 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
385 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
386 { WM_NCACTIVATE
, sent
|wparam
, 1 },
387 { WM_ACTIVATE
, sent
|wparam
, 1 },
388 { HCBT_SETFOCUS
, hook
},
389 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
390 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
391 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
392 { WM_SYNCPAINT
, sent
|wparam
|optional
, 4 },
393 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
394 { WM_ERASEBKGND
, sent
|optional
},
395 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOCLIENTMOVE
|SWP_NOCLIENTSIZE
|SWP_SHOWWINDOW
|SWP_NOMOVE
|SWP_NOSIZE
},
398 /* CreateWindow(WS_MAXIMIZE) for popup window, not initially visible */
399 static const struct message WmCreateInvisibleMaxPopupSeq
[] = {
400 { HCBT_CREATEWND
, hook
},
401 { WM_NCCREATE
, sent
},
402 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
404 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
406 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
407 { WM_GETMINMAXINFO
, sent
},
408 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|0x8000 },
409 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
410 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOREDRAW
|0x8000 },
411 { WM_MOVE
, sent
|defwinproc
},
412 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
415 /* ShowWindow(SW_SHOWMAXIMIZED) for a resized not visible popup window */
416 static const struct message WmShowMaxPopupResizedSeq
[] = {
417 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
418 { WM_GETMINMAXINFO
, sent
},
419 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
},
420 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
421 { HCBT_ACTIVATE
, hook
},
422 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
423 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
424 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
425 { WM_NCACTIVATE
, sent
|wparam
, 1 },
426 { WM_ACTIVATE
, sent
|wparam
, 1 },
427 { HCBT_SETFOCUS
, hook
},
428 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
429 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
430 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
431 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
432 { WM_ERASEBKGND
, sent
|optional
},
433 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOCLIENTMOVE
|SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOMOVE
},
434 /* WinNT4.0 sends WM_MOVE */
435 { WM_MOVE
, sent
|defwinproc
|optional
},
436 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
439 /* ShowWindow(SW_SHOWMAXIMIZED) for a not visible popup window */
440 static const struct message WmShowMaxPopupSeq
[] = {
441 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
442 { WM_GETMINMAXINFO
, sent
},
443 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
},
444 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
445 { HCBT_ACTIVATE
, hook
},
446 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
447 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
448 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
449 { WM_NCACTIVATE
, sent
|wparam
, 1 },
450 { WM_ACTIVATE
, sent
|wparam
, 1 },
451 { HCBT_SETFOCUS
, hook
},
452 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
453 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
454 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
455 { WM_SYNCPAINT
, sent
|wparam
|optional
, 4 },
456 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
457 { WM_ERASEBKGND
, sent
|optional
},
458 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOMOVE
|SWP_NOSIZE
},
461 /* CreateWindow(WS_VISIBLE) for popup window */
462 static const struct message WmCreatePopupSeq
[] = {
463 { HCBT_CREATEWND
, hook
},
464 { WM_NCCREATE
, sent
},
465 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
467 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
469 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
470 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
471 { HCBT_ACTIVATE
, hook
},
472 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
473 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
474 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
475 { WM_ERASEBKGND
, sent
|optional
},
476 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
477 { WM_NCACTIVATE
, sent
|wparam
, 1 },
478 { WM_ACTIVATE
, sent
|wparam
, 1 },
479 { HCBT_SETFOCUS
, hook
},
480 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
481 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
482 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
483 { WM_SYNCPAINT
, sent
|wparam
|optional
, 4 },
484 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
485 { WM_ERASEBKGND
, sent
|optional
},
486 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOCLIENTMOVE
|SWP_NOCLIENTSIZE
|SWP_SHOWWINDOW
|SWP_NOMOVE
|SWP_NOSIZE
},
489 /* ShowWindow(SW_SHOWMAXIMIZED) for a visible popup window */
490 static const struct message WmShowVisMaxPopupSeq
[] = {
491 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
492 { WM_GETMINMAXINFO
, sent
},
493 { WM_GETTEXT
, sent
|optional
},
494 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|0x8000 },
495 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
496 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
497 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
498 { WM_ERASEBKGND
, sent
|optional
},
499 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|0x8000 },
500 { WM_MOVE
, sent
|defwinproc
},
501 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
504 /* CreateWindow (for a child popup window, not initially visible) */
505 static const struct message WmCreateChildPopupSeq
[] = {
506 { HCBT_CREATEWND
, hook
},
507 { WM_NCCREATE
, sent
},
508 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
510 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
511 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
515 /* CreateWindow (for a popup window, not initially visible,
516 * which sets WS_VISIBLE in WM_CREATE handler)
518 static const struct message WmCreateInvisiblePopupSeq
[] = {
519 { HCBT_CREATEWND
, hook
},
520 { WM_NCCREATE
, sent
},
521 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
523 { WM_STYLECHANGING
, sent
},
524 { WM_STYLECHANGED
, sent
},
525 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
526 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
530 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER)
531 * for a popup window with WS_VISIBLE style set
533 static const struct message WmShowVisiblePopupSeq_2
[] = {
534 { WM_WINDOWPOSCHANGING
, sent
|wparam
, 0 },
537 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
538 * for a popup window with WS_VISIBLE style set
540 static const struct message WmShowVisiblePopupSeq_3
[] = {
541 { WM_WINDOWPOSCHANGING
, sent
|wparam
, 0 },
542 { HCBT_ACTIVATE
, hook
},
543 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
544 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
545 { WM_WINDOWPOSCHANGING
, sent
|wparam
, 0 },
546 { WM_NCACTIVATE
, sent
|wparam
, 1 },
547 { WM_ACTIVATE
, sent
|wparam
, 1 },
548 { HCBT_SETFOCUS
, hook
},
549 { WM_KILLFOCUS
, sent
|parent
},
550 { WM_IME_SETCONTEXT
, sent
|parent
|wparam
|optional
, 0 },
551 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
552 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
553 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
554 { WM_SETFOCUS
, sent
|defwinproc
},
557 /* CreateWindow (for child window, not initially visible) */
558 static const struct message WmCreateChildSeq
[] = {
559 { HCBT_CREATEWND
, hook
},
560 { WM_NCCREATE
, sent
},
561 /* child is inserted into parent's child list after WM_NCCREATE returns */
562 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
564 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
565 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
567 { WM_PARENTNOTIFY
, sent
|parent
|wparam
, WM_CREATE
},
570 /* CreateWindow (for maximized child window, not initially visible) */
571 static const struct message WmCreateMaximizedChildSeq
[] = {
572 { HCBT_CREATEWND
, hook
},
573 { WM_NCCREATE
, sent
},
574 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
576 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
577 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
579 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
580 { WM_GETMINMAXINFO
, sent
},
581 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|0x8000 },
582 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
583 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
|0x8000 },
584 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
585 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
586 { WM_PARENTNOTIFY
, sent
|parent
|wparam
, WM_CREATE
},
589 /* CreateWindow (for a child window, initially visible) */
590 static const struct message WmCreateVisibleChildSeq
[] = {
591 { HCBT_CREATEWND
, hook
},
592 { WM_NCCREATE
, sent
},
593 /* child is inserted into parent's child list after WM_NCCREATE returns */
594 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
595 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
597 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
598 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
600 { WM_PARENTNOTIFY
, sent
|parent
|wparam
, WM_CREATE
},
601 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
602 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
603 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
604 { WM_ERASEBKGND
, sent
|parent
|optional
},
605 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
606 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 }, /* WinXP */
607 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
610 /* ShowWindow(SW_SHOW) for a not visible child window */
611 static const struct message WmShowChildSeq
[] = {
612 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
613 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
614 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
615 { WM_ERASEBKGND
, sent
|parent
|optional
},
616 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
619 /* ShowWindow(SW_HIDE) for a visible child window */
620 static const struct message WmHideChildSeq
[] = {
621 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
622 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
623 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
624 { WM_ERASEBKGND
, sent
|parent
|optional
},
625 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
628 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
629 * for a not visible child window
631 static const struct message WmShowChildSeq_2
[] = {
632 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
633 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
634 { WM_CHILDACTIVATE
, sent
},
635 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
638 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE)
639 * for a not visible child window
641 static const struct message WmShowChildSeq_3
[] = {
642 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
643 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
644 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
647 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
648 * for a visible child window with a caption
650 static const struct message WmShowChildSeq_4
[] = {
651 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
652 { WM_CHILDACTIVATE
, sent
},
655 /* ShowWindow(SW_MINIMIZE) for child with invisible parent */
656 static const struct message WmShowChildInvisibleParentSeq_1
[] = {
657 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
658 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOCOPYBITS
|0x8000 },
659 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
660 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOREDRAW
|SWP_NOCOPYBITS
|0x8000 },
661 { WM_MOVE
, sent
|defwinproc
},
662 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MINIMIZED
},
663 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
664 /* FIXME: Wine creates an icon/title window while Windows doesn't */
665 { WM_PARENTNOTIFY
, sent
|parent
|wparam
|optional
, WM_CREATE
},
666 { WM_GETTEXT
, sent
|optional
},
669 /* repeated ShowWindow(SW_MINIMIZE) for child with invisible parent */
670 static const struct message WmShowChildInvisibleParentSeq_1r
[] = {
671 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
674 /* ShowWindow(SW_MAXIMIZE) for child with invisible parent */
675 static const struct message WmShowChildInvisibleParentSeq_2
[] = {
676 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
677 { WM_GETMINMAXINFO
, sent
},
678 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|0x8000 },
679 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
680 { WM_CHILDACTIVATE
, sent
},
681 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
|0x8000 },
682 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
683 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
686 /* repeated ShowWindow(SW_MAXIMIZE) for child with invisible parent */
687 static const struct message WmShowChildInvisibleParentSeq_2r
[] = {
688 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
691 /* ShowWindow(SW_SHOWMINIMIZED) for child with invisible parent */
692 static const struct message WmShowChildInvisibleParentSeq_3
[] = {
693 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINIMIZED
},
694 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|0x8000 },
695 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
696 { WM_CHILDACTIVATE
, sent
},
697 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOREDRAW
|SWP_NOCOPYBITS
|0x8000 },
698 { WM_MOVE
, sent
|defwinproc
},
699 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MINIMIZED
},
700 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
701 /* FIXME: Wine creates an icon/title window while Windows doesn't */
702 { WM_PARENTNOTIFY
, sent
|parent
|wparam
|optional
, WM_CREATE
},
703 { WM_GETTEXT
, sent
|optional
},
706 /* repeated ShowWindow(SW_SHOWMINIMIZED) for child with invisible parent */
707 static const struct message WmShowChildInvisibleParentSeq_3r
[] = {
708 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINIMIZED
},
711 /* ShowWindow(SW_SHOWMINNOACTIVE) for child with invisible parent */
712 static const struct message WmShowChildInvisibleParentSeq_4
[] = {
713 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINNOACTIVE
},
714 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOCOPYBITS
|0x8000 },
715 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
716 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOREDRAW
|SWP_NOCOPYBITS
|0x8000 },
717 { WM_MOVE
, sent
|defwinproc
},
718 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MINIMIZED
},
719 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
720 /* FIXME: Wine creates an icon/title window while Windows doesn't */
721 { WM_PARENTNOTIFY
, sent
|parent
|wparam
|optional
, WM_CREATE
},
722 { WM_GETTEXT
, sent
|optional
},
725 /* repeated ShowWindow(SW_SHOWMINNOACTIVE) for child with invisible parent */
726 static const struct message WmShowChildInvisibleParentSeq_4r
[] = {
727 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINNOACTIVE
},
730 /* ShowWindow(SW_SHOW) for child with invisible parent */
731 static const struct message WmShowChildInvisibleParentSeq_5
[] = {
732 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
735 /* ShowWindow(SW_HIDE) for child with invisible parent */
736 static const struct message WmHideChildInvisibleParentSeq
[] = {
737 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
740 /* SetWindowPos(SWP_SHOWWINDOW) for child with invisible parent */
741 static const struct message WmShowChildInvisibleParentSeq_6
[] = {
742 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
743 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
744 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
747 /* SetWindowPos(SWP_HIDEWINDOW) for child with invisible parent */
748 static const struct message WmHideChildInvisibleParentSeq_2
[] = {
749 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
750 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
751 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
754 /* DestroyWindow for a visible child window */
755 static const struct message WmDestroyChildSeq
[] = {
756 { HCBT_DESTROYWND
, hook
},
757 { WM_PARENTNOTIFY
, sent
|parent
|wparam
, WM_DESTROY
},
758 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
759 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
760 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
761 { WM_ERASEBKGND
, sent
|parent
|optional
},
762 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
763 { HCBT_SETFOCUS
, hook
}, /* set focus to a parent */
764 { WM_KILLFOCUS
, sent
},
765 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
766 { WM_IME_SETCONTEXT
, sent
|wparam
|parent
|optional
, 1 },
767 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
768 { WM_SETFOCUS
, sent
|parent
},
769 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
770 { WM_DESTROY
, sent
},
771 { WM_DESTROY
, sent
|optional
}, /* some other (IME?) window */
772 { WM_NCDESTROY
, sent
|optional
}, /* some other (IME?) window */
773 { WM_NCDESTROY
, sent
},
776 /* DestroyWindow for a visible child window with invisible parent */
777 static const struct message WmDestroyInvisibleChildSeq
[] = {
778 { HCBT_DESTROYWND
, hook
},
779 { WM_PARENTNOTIFY
, sent
|parent
|wparam
, WM_DESTROY
},
780 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
781 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
782 { WM_DESTROY
, sent
},
783 { WM_NCDESTROY
, sent
},
786 /* Moving the mouse in nonclient area */
787 static const struct message WmMouseMoveInNonClientAreaSeq
[] = { /* FIXME: add */
788 { WM_NCHITTEST
, sent
},
789 { WM_SETCURSOR
, sent
},
790 { WM_NCMOUSEMOVE
, posted
},
793 /* Moving the mouse in client area */
794 static const struct message WmMouseMoveInClientAreaSeq
[] = { /* FIXME: add */
795 { WM_NCHITTEST
, sent
},
796 { WM_SETCURSOR
, sent
},
797 { WM_MOUSEMOVE
, posted
},
800 /* Moving by dragging the title bar (after WM_NCHITTEST and WM_SETCURSOR) (outline move) */
801 static const struct message WmDragTitleBarSeq
[] = { /* FIXME: add */
802 { WM_NCLBUTTONDOWN
, sent
|wparam
, HTCAPTION
},
803 { WM_SYSCOMMAND
, sent
|defwinproc
|wparam
, SC_MOVE
+2 },
804 { WM_GETMINMAXINFO
, sent
|defwinproc
},
805 { WM_ENTERSIZEMOVE
, sent
|defwinproc
},
806 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, 0 },
807 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, 0 },
808 { WM_MOVE
, sent
|defwinproc
},
809 { WM_EXITSIZEMOVE
, sent
|defwinproc
},
812 /* Sizing by dragging the thick borders (after WM_NCHITTEST and WM_SETCURSOR) (outline move) */
813 static const struct message WmDragThickBordersBarSeq
[] = { /* FIXME: add */
814 { WM_NCLBUTTONDOWN
, sent
|wparam
, 0xd },
815 { WM_SYSCOMMAND
, sent
|defwinproc
|wparam
, 0xf004 },
816 { WM_GETMINMAXINFO
, sent
|defwinproc
},
817 { WM_ENTERSIZEMOVE
, sent
|defwinproc
},
818 { WM_SIZING
, sent
|defwinproc
|wparam
, 4}, /* one for each mouse movement */
819 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, 0 },
820 { WM_GETMINMAXINFO
, sent
|defwinproc
},
821 { WM_NCCALCSIZE
, sent
|defwinproc
|wparam
, 1 },
822 { WM_NCPAINT
, sent
|defwinproc
|wparam
, 1 },
823 { WM_GETTEXT
, sent
|defwinproc
},
824 { WM_ERASEBKGND
, sent
|defwinproc
},
825 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, 0 },
826 { WM_MOVE
, sent
|defwinproc
},
827 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
828 { WM_EXITSIZEMOVE
, sent
|defwinproc
},
831 /* Resizing child window with MoveWindow (32) */
832 static const struct message WmResizingChildWithMoveWindowSeq
[] = {
833 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
834 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
835 { WM_ERASEBKGND
, sent
|optional
},
836 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
},
837 { WM_MOVE
, sent
|defwinproc
},
838 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
839 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
842 /* Clicking on inactive button */
843 static const struct message WmClickInactiveButtonSeq
[] = { /* FIXME: add */
844 { WM_NCHITTEST
, sent
},
845 { WM_PARENTNOTIFY
, sent
|parent
|wparam
, WM_LBUTTONDOWN
},
846 { WM_MOUSEACTIVATE
, sent
},
847 { WM_MOUSEACTIVATE
, sent
|parent
|defwinproc
},
848 { WM_SETCURSOR
, sent
},
849 { WM_SETCURSOR
, sent
|parent
|defwinproc
},
850 { WM_LBUTTONDOWN
, posted
},
851 { WM_KILLFOCUS
, posted
|parent
},
852 { WM_SETFOCUS
, posted
},
853 { WM_CTLCOLORBTN
, posted
|parent
},
854 { BM_SETSTATE
, posted
},
855 { WM_CTLCOLORBTN
, posted
|parent
},
856 { WM_LBUTTONUP
, posted
},
857 { BM_SETSTATE
, posted
},
858 { WM_CTLCOLORBTN
, posted
|parent
},
859 { WM_COMMAND
, posted
|parent
},
862 /* Reparenting a button (16/32) */
863 /* The last child (button) reparented gets topmost for its new parent. */
864 static const struct message WmReparentButtonSeq
[] = { /* FIXME: add */
865 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
866 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOSIZE
},
867 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
868 { WM_ERASEBKGND
, sent
|parent
},
869 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOSIZE
},
870 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
},
871 { WM_CHILDACTIVATE
, sent
},
872 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOSIZE
|SWP_NOREDRAW
},
873 { WM_MOVE
, sent
|defwinproc
},
874 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
877 /* Creation of a custom dialog (32) */
878 static const struct message WmCreateCustomDialogSeq
[] = {
879 { HCBT_CREATEWND
, hook
},
880 { WM_GETMINMAXINFO
, sent
},
881 { WM_NCCREATE
, sent
},
882 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
883 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
885 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
886 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
887 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
888 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
889 { HCBT_ACTIVATE
, hook
},
890 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
893 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
895 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
},
897 { WM_NCACTIVATE
, sent
|wparam
, 1 },
898 { WM_GETTEXT
, sent
|optional
|defwinproc
},
899 { WM_GETTEXT
, sent
|optional
|defwinproc
},
900 { EVENT_OBJECT_DEFACTIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, OBJID_CLIENT
, 0 },
901 { WM_ACTIVATE
, sent
|wparam
, 1 },
902 { WM_KILLFOCUS
, sent
|parent
},
903 { WM_IME_SETCONTEXT
, sent
|parent
|wparam
|optional
, 0 },
904 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
905 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
906 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
907 { WM_SETFOCUS
, sent
},
908 { WM_GETDLGCODE
, sent
|defwinproc
|wparam
, 0 },
909 { WM_NCPAINT
, sent
|wparam
, 1 },
910 { WM_GETTEXT
, sent
|optional
|defwinproc
},
911 { WM_GETTEXT
, sent
|optional
|defwinproc
},
912 { WM_ERASEBKGND
, sent
},
913 { WM_CTLCOLORDLG
, sent
|defwinproc
},
914 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
915 { WM_GETTEXT
, sent
|optional
},
916 { WM_GETTEXT
, sent
|optional
},
917 { WM_NCCALCSIZE
, sent
|optional
},
918 { WM_NCPAINT
, sent
|optional
},
919 { WM_GETTEXT
, sent
|optional
|defwinproc
},
920 { WM_GETTEXT
, sent
|optional
|defwinproc
},
921 { WM_ERASEBKGND
, sent
|optional
},
922 { WM_CTLCOLORDLG
, sent
|optional
|defwinproc
},
923 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
924 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
928 /* Calling EndDialog for a custom dialog (32) */
929 static const struct message WmEndCustomDialogSeq
[] = {
930 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
931 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
932 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
933 { WM_GETTEXT
, sent
|optional
},
934 { HCBT_ACTIVATE
, hook
},
935 { WM_NCACTIVATE
, sent
|wparam
, 0 },
936 { WM_GETTEXT
, sent
|optional
|defwinproc
},
937 { WM_GETTEXT
, sent
|optional
|defwinproc
},
938 { WM_ACTIVATE
, sent
|wparam
, 0 },
939 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
940 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
941 { HCBT_SETFOCUS
, hook
},
942 { WM_KILLFOCUS
, sent
},
943 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
944 { WM_IME_SETCONTEXT
, sent
|parent
|wparam
|defwinproc
|optional
, 1 },
945 { WM_IME_NOTIFY
, sent
|wparam
|optional
, 1 },
946 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
947 { WM_SETFOCUS
, sent
|parent
|defwinproc
},
950 /* ShowWindow(SW_SHOW) for a custom dialog (initially invisible) */
951 static const struct message WmShowCustomDialogSeq
[] = {
952 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
953 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
954 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
955 { HCBT_ACTIVATE
, hook
},
956 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
958 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
960 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
},
961 { WM_ACTIVATEAPP
, sent
|wparam
|optional
, 1 },
962 { WM_NCACTIVATE
, sent
|wparam
, 1 },
963 { WM_ACTIVATE
, sent
|wparam
, 1 },
965 { WM_KILLFOCUS
, sent
|parent
},
966 { WM_IME_SETCONTEXT
, sent
|parent
|wparam
|optional
, 0 },
967 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
968 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
969 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
970 { WM_SETFOCUS
, sent
},
971 { WM_GETDLGCODE
, sent
|defwinproc
|wparam
, 0 },
972 { WM_NCPAINT
, sent
|wparam
, 1 },
973 { WM_ERASEBKGND
, sent
},
974 { WM_CTLCOLORDLG
, sent
|defwinproc
},
975 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
978 /* Creation and destruction of a modal dialog (32) */
979 static const struct message WmModalDialogSeq
[] = {
980 { WM_CANCELMODE
, sent
|parent
},
981 { HCBT_SETFOCUS
, hook
},
982 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
983 { WM_KILLFOCUS
, sent
|parent
},
984 { WM_IME_SETCONTEXT
, sent
|parent
|wparam
|optional
, 0 },
985 { EVENT_OBJECT_STATECHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
986 { WM_ENABLE
, sent
|parent
|wparam
, 0 },
987 { HCBT_CREATEWND
, hook
},
988 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
989 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
990 { WM_SETFONT
, sent
},
991 { WM_INITDIALOG
, sent
},
992 { WM_CHANGEUISTATE
, sent
|optional
},
993 { WM_UPDATEUISTATE
, sent
|optional
},
994 { WM_SHOWWINDOW
, sent
},
995 { HCBT_ACTIVATE
, hook
},
996 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
997 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
998 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
},
999 { WM_NCACTIVATE
, sent
|wparam
, 1 },
1000 { WM_GETTEXT
, sent
|optional
},
1001 { WM_ACTIVATE
, sent
|wparam
, 1 },
1002 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
1003 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1004 { WM_NCPAINT
, sent
},
1005 { WM_GETTEXT
, sent
|optional
},
1006 { WM_ERASEBKGND
, sent
},
1007 { WM_CTLCOLORDLG
, sent
},
1008 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1009 { WM_GETTEXT
, sent
|optional
},
1010 { WM_NCCALCSIZE
, sent
|optional
},
1011 { WM_NCPAINT
, sent
|optional
},
1012 { WM_GETTEXT
, sent
|optional
},
1013 { WM_ERASEBKGND
, sent
|optional
},
1014 { WM_CTLCOLORDLG
, sent
|optional
},
1015 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1016 { WM_PAINT
, sent
|optional
},
1017 { WM_CTLCOLORBTN
, sent
},
1018 { WM_ENTERIDLE
, sent
|parent
|optional
},
1019 { WM_ENTERIDLE
, sent
|parent
|optional
},
1020 { WM_ENTERIDLE
, sent
|parent
|optional
},
1021 { WM_ENTERIDLE
, sent
|parent
|optional
},
1022 { WM_ENTERIDLE
, sent
|parent
|optional
},
1023 { WM_ENTERIDLE
, sent
|parent
|optional
},
1024 { WM_ENTERIDLE
, sent
|parent
|optional
},
1025 { WM_ENTERIDLE
, sent
|parent
|optional
},
1026 { WM_ENTERIDLE
, sent
|parent
|optional
},
1027 { WM_ENTERIDLE
, sent
|parent
|optional
},
1028 { WM_ENTERIDLE
, sent
|parent
|optional
},
1029 { WM_ENTERIDLE
, sent
|parent
|optional
},
1030 { WM_ENTERIDLE
, sent
|parent
|optional
},
1031 { WM_ENTERIDLE
, sent
|parent
|optional
},
1032 { WM_ENTERIDLE
, sent
|parent
|optional
},
1033 { WM_ENTERIDLE
, sent
|parent
|optional
},
1034 { WM_ENTERIDLE
, sent
|parent
|optional
},
1035 { WM_ENTERIDLE
, sent
|parent
|optional
},
1036 { WM_ENTERIDLE
, sent
|parent
|optional
},
1037 { WM_ENTERIDLE
, sent
|parent
|optional
},
1039 { EVENT_OBJECT_STATECHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1040 { WM_ENABLE
, sent
|parent
|wparam
, 1 },
1041 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
1042 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1043 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1044 { WM_GETTEXT
, sent
|optional
},
1045 { HCBT_ACTIVATE
, hook
},
1046 { WM_NCACTIVATE
, sent
|wparam
, 0 },
1047 { WM_GETTEXT
, sent
|optional
},
1048 { WM_ACTIVATE
, sent
|wparam
, 0 },
1049 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
1050 { WM_WINDOWPOSCHANGING
, sent
|optional
},
1051 { HCBT_SETFOCUS
, hook
},
1052 { WM_IME_SETCONTEXT
, sent
|parent
|wparam
|defwinproc
|optional
, 1 },
1053 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1054 { WM_SETFOCUS
, sent
|parent
|defwinproc
},
1055 { EVENT_SYSTEM_DIALOGEND
, winevent_hook
|wparam
|lparam
, 0, 0 },
1056 { HCBT_DESTROYWND
, hook
},
1057 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
1058 { WM_DESTROY
, sent
},
1059 { WM_NCDESTROY
, sent
},
1062 /* Creation of a modal dialog that is resized inside WM_INITDIALOG (32) */
1063 static const struct message WmCreateModalDialogResizeSeq
[] = { /* FIXME: add */
1064 /* (inside dialog proc, handling WM_INITDIALOG) */
1065 { WM_WINDOWPOSCHANGING
, sent
|wparam
, 0 },
1066 { WM_NCCALCSIZE
, sent
},
1067 { WM_NCACTIVATE
, sent
|parent
|wparam
, 0 },
1068 { WM_GETTEXT
, sent
|defwinproc
},
1069 { WM_ACTIVATE
, sent
|parent
|wparam
, 0 },
1070 { WM_WINDOWPOSCHANGING
, sent
|wparam
, 0 },
1071 { WM_WINDOWPOSCHANGING
, sent
|parent
},
1072 { WM_NCACTIVATE
, sent
|wparam
, 1 },
1073 { WM_ACTIVATE
, sent
|wparam
, 1 },
1074 { WM_WINDOWPOSCHANGED
, sent
|wparam
, 0 },
1075 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
1076 /* (setting focus) */
1077 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1078 { WM_WINDOWPOSCHANGING
, sent
|wparam
, 0 },
1079 { WM_NCPAINT
, sent
},
1080 { WM_GETTEXT
, sent
|defwinproc
},
1081 { WM_ERASEBKGND
, sent
},
1082 { WM_CTLCOLORDLG
, sent
|defwinproc
},
1083 { WM_WINDOWPOSCHANGED
, sent
|wparam
, 0 },
1085 /* (bunch of WM_CTLCOLOR* for each control) */
1086 { WM_PAINT
, sent
|parent
},
1087 { WM_ENTERIDLE
, sent
|parent
|wparam
, 0 },
1088 { WM_SETCURSOR
, sent
|parent
},
1091 /* SetMenu for NonVisible windows with size change*/
1092 static const struct message WmSetMenuNonVisibleSizeChangeSeq
[] = {
1093 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1094 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1095 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
1096 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
},
1097 { WM_MOVE
, sent
|defwinproc
},
1098 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
1099 { WM_NCCALCSIZE
,sent
|wparam
|optional
, 1 }, /* XP */
1100 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1101 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* XP sends a duplicate */
1102 { WM_GETTEXT
, sent
|optional
},
1103 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
1106 /* SetMenu for NonVisible windows with no size change */
1107 static const struct message WmSetMenuNonVisibleNoSizeChangeSeq
[] = {
1108 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1109 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1110 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1111 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1114 /* SetMenu for Visible windows with size change */
1115 static const struct message WmSetMenuVisibleSizeChangeSeq
[] = {
1116 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1117 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1118 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
1119 { WM_NCPAINT
, sent
}, /* wparam != 1 */
1120 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1121 { WM_ERASEBKGND
, sent
|optional
},
1122 { WM_ACTIVATE
, sent
|optional
},
1123 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1124 { WM_MOVE
, sent
|defwinproc
},
1125 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
1126 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
1127 { WM_NCPAINT
, sent
|optional
}, /* wparam != 1 */
1128 { WM_ERASEBKGND
, sent
|optional
},
1129 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1130 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* XP sends a duplicate */
1133 /* SetMenu for Visible windows with no size change */
1134 static const struct message WmSetMenuVisibleNoSizeChangeSeq
[] = {
1135 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1136 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1137 { WM_NCPAINT
, sent
}, /* wparam != 1 */
1138 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1139 { WM_ERASEBKGND
, sent
|optional
},
1140 { WM_ACTIVATE
, sent
|optional
},
1141 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1142 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1145 /* DrawMenuBar for a visible window */
1146 static const struct message WmDrawMenuBarSeq
[] =
1148 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1149 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1150 { WM_NCPAINT
, sent
}, /* wparam != 1 */
1151 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1152 { WM_ERASEBKGND
, sent
|optional
},
1153 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1154 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1158 static const struct message WmSetRedrawFalseSeq
[] =
1160 { WM_SETREDRAW
, sent
|wparam
, 0 },
1164 static const struct message WmSetRedrawTrueSeq
[] =
1166 { WM_SETREDRAW
, sent
|wparam
, 1 },
1170 static const struct message WmEnableWindowSeq_1
[] =
1172 { WM_CANCELMODE
, sent
|wparam
|lparam
, 0, 0 },
1173 { EVENT_OBJECT_STATECHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1174 { WM_ENABLE
, sent
|wparam
|lparam
, FALSE
, 0 },
1178 static const struct message WmEnableWindowSeq_2
[] =
1180 { EVENT_OBJECT_STATECHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1181 { WM_ENABLE
, sent
|wparam
|lparam
, TRUE
, 0 },
1185 static const struct message WmGetScrollRangeSeq
[] =
1187 { SBM_GETRANGE
, sent
},
1190 static const struct message WmGetScrollInfoSeq
[] =
1192 { SBM_GETSCROLLINFO
, sent
},
1195 static const struct message WmSetScrollRangeSeq
[] =
1197 /* MSDN claims that Windows sends SBM_SETRANGE message, but win2k SP4
1198 sends SBM_SETSCROLLINFO.
1200 { SBM_SETSCROLLINFO
, sent
},
1203 /* SetScrollRange for a window without a non-client area */
1204 static const struct message WmSetScrollRangeHSeq_empty
[] =
1206 { EVENT_OBJECT_VALUECHANGE
, winevent_hook
|wparam
|lparam
, OBJID_HSCROLL
, 0 },
1209 static const struct message WmSetScrollRangeVSeq_empty
[] =
1211 { EVENT_OBJECT_VALUECHANGE
, winevent_hook
|wparam
|lparam
, OBJID_VSCROLL
, 0 },
1214 static const struct message WmSetScrollRangeHVSeq
[] =
1216 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOSIZE
},
1217 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1218 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1219 { WM_ERASEBKGND
, sent
|optional
},
1220 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1221 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1222 { EVENT_OBJECT_VALUECHANGE
, winevent_hook
|lparam
|optional
, 0/*OBJID_HSCROLL or OBJID_VSCROLL*/, 0 },
1225 /* SetScrollRange for a window with a non-client area */
1226 static const struct message WmSetScrollRangeHV_NC_Seq
[] =
1228 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOSIZE
},
1229 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1230 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
1231 { WM_NCPAINT
, sent
|optional
},
1232 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1233 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1234 { WM_ERASEBKGND
, sent
|optional
},
1235 { WM_CTLCOLORDLG
, sent
|defwinproc
|optional
}, /* sent to a parent of the dialog */
1236 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOCLIENTMOVE
},
1237 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
1238 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1239 { EVENT_OBJECT_VALUECHANGE
, winevent_hook
|lparam
|optional
, 0/*OBJID_HSCROLL or OBJID_VSCROLL*/, 0 },
1240 { WM_GETTEXT
, sent
|optional
},
1241 { WM_GETTEXT
, sent
|optional
},
1242 { WM_GETTEXT
, sent
|optional
},
1243 { WM_GETTEXT
, sent
|optional
},
1246 /* test if we receive the right sequence of messages */
1247 /* after calling ShowWindow( SW_SHOWNA) */
1248 static const struct message WmSHOWNAChildInvisParInvis
[] = {
1249 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1252 static const struct message WmSHOWNAChildVisParInvis
[] = {
1253 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1256 static const struct message WmSHOWNAChildVisParVis
[] = {
1257 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1258 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
1261 static const struct message WmSHOWNAChildInvisParVis
[] = {
1262 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1263 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1264 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1265 { WM_ERASEBKGND
, sent
|optional
},
1266 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOACTIVATE
|SWP_NOCLIENTMOVE
},
1269 static const struct message WmSHOWNATopVisible
[] = {
1270 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1271 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
1274 static const struct message WmSHOWNATopInvisible
[] = {
1275 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1276 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1277 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1278 { WM_NCPAINT
, sent
|wparam
, 1 },
1279 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1280 { WM_ERASEBKGND
, sent
|optional
},
1281 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1282 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
1283 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
1284 { WM_ERASEBKGND
, sent
|optional
},
1285 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1286 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
1291 static int after_end_dialog
, test_def_id
;
1292 static int sequence_cnt
, sequence_size
;
1293 static struct message
* sequence
;
1294 static int log_all_parent_messages
;
1296 static void add_message(const struct message
*msg
)
1301 sequence
= HeapAlloc( GetProcessHeap(), 0, sequence_size
* sizeof (struct message
) );
1303 if (sequence_cnt
== sequence_size
)
1306 sequence
= HeapReAlloc( GetProcessHeap(), 0, sequence
, sequence_size
* sizeof (struct message
) );
1310 sequence
[sequence_cnt
].message
= msg
->message
;
1311 sequence
[sequence_cnt
].flags
= msg
->flags
;
1312 sequence
[sequence_cnt
].wParam
= msg
->wParam
;
1313 sequence
[sequence_cnt
].lParam
= msg
->lParam
;
1318 /* try to make sure pending X events have been processed before continuing */
1319 static void flush_events(void)
1323 DWORD time
= GetTickCount() + diff
;
1327 MsgWaitForMultipleObjects( 0, NULL
, FALSE
, diff
, QS_ALLINPUT
);
1328 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
1329 diff
= time
- GetTickCount();
1333 static void flush_sequence(void)
1335 HeapFree(GetProcessHeap(), 0, sequence
);
1337 sequence_cnt
= sequence_size
= 0;
1340 #define ok_sequence( exp, contx, todo) \
1341 ok_sequence_( (exp), (contx), (todo), __FILE__, __LINE__)
1344 static void ok_sequence_(const struct message
*expected
, const char *context
, int todo
,
1345 const char *file
, int line
)
1347 static const struct message end_of_sequence
= { 0, 0, 0, 0 };
1348 const struct message
*actual
;
1351 add_message(&end_of_sequence
);
1355 while (expected
->message
&& actual
->message
)
1357 trace_( file
, line
)("expected %04x - actual %04x\n", expected
->message
, actual
->message
);
1359 if (expected
->message
== actual
->message
)
1361 if (expected
->flags
& wparam
)
1363 if (expected
->wParam
!= actual
->wParam
&& todo
)
1367 ok_( file
, line
) (FALSE
,
1368 "%s: in msg 0x%04x expecting wParam 0x%x got 0x%x\n",
1369 context
, expected
->message
, expected
->wParam
, actual
->wParam
);
1373 ok_( file
, line
) (expected
->wParam
== actual
->wParam
,
1374 "%s: in msg 0x%04x expecting wParam 0x%x got 0x%x\n",
1375 context
, expected
->message
, expected
->wParam
, actual
->wParam
);
1377 if (expected
->flags
& lparam
)
1379 if (expected
->lParam
!= actual
->lParam
&& todo
)
1383 ok_( file
, line
) (FALSE
,
1384 "%s: in msg 0x%04x expecting lParam 0x%lx got 0x%lx\n",
1385 context
, expected
->message
, expected
->lParam
, actual
->lParam
);
1389 ok_( file
, line
) (expected
->lParam
== actual
->lParam
,
1390 "%s: in msg 0x%04x expecting lParam 0x%lx got 0x%lx\n",
1391 context
, expected
->message
, expected
->lParam
, actual
->lParam
);
1393 if ((expected
->flags
& defwinproc
) != (actual
->flags
& defwinproc
) && todo
)
1397 ok_( file
, line
) (FALSE
,
1398 "%s: the msg 0x%04x should %shave been sent by DefWindowProc\n",
1399 context
, expected
->message
, (expected
->flags
& defwinproc
) ? "" : "NOT ");
1403 ok_( file
, line
) ((expected
->flags
& defwinproc
) == (actual
->flags
& defwinproc
),
1404 "%s: the msg 0x%04x should %shave been sent by DefWindowProc\n",
1405 context
, expected
->message
, (expected
->flags
& defwinproc
) ? "" : "NOT ");
1406 ok_( file
, line
) ((expected
->flags
& beginpaint
) == (actual
->flags
& beginpaint
),
1407 "%s: the msg 0x%04x should %shave been sent by BeginPaint\n",
1408 context
, expected
->message
, (expected
->flags
& beginpaint
) ? "" : "NOT ");
1409 ok_( file
, line
) ((expected
->flags
& (sent
|posted
)) == (actual
->flags
& (sent
|posted
)),
1410 "%s: the msg 0x%04x should have been %s\n",
1411 context
, expected
->message
, (expected
->flags
& posted
) ? "posted" : "sent");
1412 ok_( file
, line
) ((expected
->flags
& parent
) == (actual
->flags
& parent
),
1413 "%s: the msg 0x%04x was expected in %s\n",
1414 context
, expected
->message
, (expected
->flags
& parent
) ? "parent" : "child");
1415 ok_( file
, line
) ((expected
->flags
& hook
) == (actual
->flags
& hook
),
1416 "%s: the msg 0x%04x should have been sent by a hook\n",
1417 context
, expected
->message
);
1418 ok_( file
, line
) ((expected
->flags
& winevent_hook
) == (actual
->flags
& winevent_hook
),
1419 "%s: the msg 0x%04x should have been sent by a winevent hook\n",
1420 context
, expected
->message
);
1424 /* silently drop winevent messages if there is no support for them */
1425 else if ((expected
->flags
& optional
) || ((expected
->flags
& winevent_hook
) && !hEvent_hook
))
1431 ok_( file
, line
) (FALSE
, "%s: the msg 0x%04x was expected, but got msg 0x%04x instead\n",
1432 context
, expected
->message
, actual
->message
);
1439 ok_( file
, line
) (FALSE
, "%s: the msg 0x%04x was expected, but got msg 0x%04x instead\n",
1440 context
, expected
->message
, actual
->message
);
1446 /* skip all optional trailing messages */
1447 while (expected
->message
&& ((expected
->flags
& optional
) ||
1448 ((expected
->flags
& winevent_hook
) && !hEvent_hook
)))
1454 if (expected
->message
|| actual
->message
) {
1456 ok_( file
, line
) (FALSE
, "%s: the msg sequence is not complete: expected %04x - actual %04x\n",
1457 context
, expected
->message
, actual
->message
);
1463 if (expected
->message
|| actual
->message
)
1464 ok_( file
, line
) (FALSE
, "%s: the msg sequence is not complete: expected %04x - actual %04x\n",
1465 context
, expected
->message
, actual
->message
);
1467 if( todo
&& !failcount
) /* succeeded yet marked todo */
1469 ok_( file
, line
)( TRUE
, "%s: marked \"todo_wine\" but succeeds\n", context
);
1475 /******************************** MDI test **********************************/
1477 /* CreateWindow for MDI frame window, initially visible */
1478 static const struct message WmCreateMDIframeSeq
[] = {
1479 { HCBT_CREATEWND
, hook
},
1480 { WM_GETMINMAXINFO
, sent
},
1481 { WM_NCCREATE
, sent
},
1482 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
1483 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
1484 { WM_CREATE
, sent
},
1485 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1486 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1487 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
1488 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1489 { HCBT_ACTIVATE
, hook
},
1490 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
1491 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
1492 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* XP */
1493 { WM_ACTIVATEAPP
, sent
|wparam
|optional
, 1 }, /* Win9x doesn't send it */
1494 { WM_NCACTIVATE
, sent
|wparam
, 1 },
1495 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1496 { WM_ACTIVATE
, sent
|wparam
, 1 },
1497 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* Win9x */
1498 { HCBT_SETFOCUS
, hook
},
1499 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
1500 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
1501 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1502 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
1503 /* Win9x adds SWP_NOZORDER below */
1504 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1505 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 }, /* XP */
1506 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1507 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
1511 /* DestroyWindow for MDI frame window, initially visible */
1512 static const struct message WmDestroyMDIframeSeq
[] = {
1513 { HCBT_DESTROYWND
, hook
},
1514 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1515 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1516 { WM_NCACTIVATE
, sent
|wparam
|optional
, 0 }, /* Win9x */
1517 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1518 { WM_NCACTIVATE
, sent
|wparam
|optional
, 0 }, /* XP */
1519 { WM_ACTIVATE
, sent
|wparam
|optional
, 0 }, /* Win9x */
1520 { WM_ACTIVATEAPP
, sent
|wparam
|optional
, 0 }, /* Win9x */
1521 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
1522 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
1523 { WM_DESTROY
, sent
},
1524 { WM_NCDESTROY
, sent
},
1527 /* CreateWindow for MDI client window, initially visible */
1528 static const struct message WmCreateMDIclientSeq
[] = {
1529 { HCBT_CREATEWND
, hook
},
1530 { WM_NCCREATE
, sent
},
1531 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
1532 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 },
1533 { WM_CREATE
, sent
},
1534 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 },
1535 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1536 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
1538 { WM_PARENTNOTIFY
, sent
|wparam
, WM_CREATE
}, /* in MDI frame */
1539 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1540 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1541 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1542 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1545 /* ShowWindow(SW_SHOW) for MDI client window */
1546 static const struct message WmShowMDIclientSeq
[] = {
1547 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1548 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1549 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1550 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1553 /* ShowWindow(SW_HIDE) for MDI client window */
1554 static const struct message WmHideMDIclientSeq
[] = {
1555 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
1556 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1557 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* win2000 */
1558 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* XP */
1559 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1562 /* DestroyWindow for MDI client window, initially visible */
1563 static const struct message WmDestroyMDIclientSeq
[] = {
1564 { HCBT_DESTROYWND
, hook
},
1565 { WM_PARENTNOTIFY
, sent
|wparam
, WM_DESTROY
}, /* in MDI frame */
1566 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
1567 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1568 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1569 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1570 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
1571 { WM_DESTROY
, sent
},
1572 { WM_NCDESTROY
, sent
},
1575 /* CreateWindow for MDI child window, initially visible */
1576 static const struct message WmCreateMDIchildVisibleSeq
[] = {
1577 { HCBT_CREATEWND
, hook
},
1578 { WM_NCCREATE
, sent
},
1579 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
1580 { WM_CREATE
, sent
},
1581 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1582 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
1584 /* Win2k sends wparam set to
1585 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
1586 * while Win9x doesn't bother to set child window id according to
1587 * CLIENTCREATESTRUCT.idFirstChild
1589 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
1590 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1591 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1592 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1593 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1594 { WM_MDIREFRESHMENU
, sent
/*|wparam|lparam, 0, 0*/ },
1595 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
1596 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
1597 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1599 /* Win9x: message sequence terminates here. */
1601 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 },
1602 { HCBT_SETFOCUS
, hook
}, /* in MDI client */
1603 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
1604 { WM_IME_NOTIFY
, sent
|wparam
|optional
, 2 }, /* in MDI client */
1605 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1606 { WM_SETFOCUS
, sent
}, /* in MDI client */
1607 { HCBT_SETFOCUS
, hook
},
1608 { WM_KILLFOCUS
, sent
}, /* in MDI client */
1609 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
1610 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
1611 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1612 { WM_SETFOCUS
, sent
|defwinproc
},
1613 { WM_MDIACTIVATE
, sent
|defwinproc
},
1616 /* CreateWindow for MDI child window with invisible parent */
1617 static const struct message WmCreateMDIchildInvisibleParentSeq
[] = {
1618 { HCBT_CREATEWND
, hook
},
1619 { WM_GETMINMAXINFO
, sent
},
1620 { WM_NCCREATE
, sent
},
1621 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
1622 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 },
1623 { WM_CREATE
, sent
},
1624 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1625 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
1627 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
1628 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1629 { WM_MDIREFRESHMENU
, sent
}, /* in MDI client */
1630 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
1631 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
1632 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1634 /* Win9x: message sequence terminates here. */
1636 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 },
1637 { HCBT_SETFOCUS
, hook
}, /* in MDI client */
1638 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
1639 { WM_IME_NOTIFY
, sent
|wparam
|optional
, 2 }, /* in MDI client */
1640 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1641 { WM_SETFOCUS
, sent
}, /* in MDI client */
1642 { HCBT_SETFOCUS
, hook
},
1643 { WM_KILLFOCUS
, sent
}, /* in MDI client */
1644 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
1645 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
1646 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1647 { WM_SETFOCUS
, sent
|defwinproc
},
1648 { WM_MDIACTIVATE
, sent
|defwinproc
},
1651 /* DestroyWindow for MDI child window, initially visible */
1652 static const struct message WmDestroyMDIchildVisibleSeq
[] = {
1653 { HCBT_DESTROYWND
, hook
},
1654 /* Win2k sends wparam set to
1655 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
1656 * while Win9x doesn't bother to set child window id according to
1657 * CLIENTCREATESTRUCT.idFirstChild
1659 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_DESTROY*/ }, /* in MDI client */
1660 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
1661 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1662 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1663 { WM_ERASEBKGND
, sent
|parent
|optional
},
1664 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1666 /* { WM_DESTROY, sent }
1667 * Win9x: message sequence terminates here.
1670 { HCBT_SETFOCUS
, hook
}, /* set focus to MDI client */
1671 { WM_KILLFOCUS
, sent
},
1672 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
1673 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
1674 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1675 { WM_SETFOCUS
, sent
}, /* in MDI client */
1677 { HCBT_SETFOCUS
, hook
}, /* MDI client sets focus back to MDI child */
1678 { WM_KILLFOCUS
, sent
}, /* in MDI client */
1679 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
1680 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
1681 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1682 { WM_SETFOCUS
, sent
}, /* in MDI client */
1684 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
1686 { HCBT_SETFOCUS
, hook
}, /* set focus to MDI client */
1687 { WM_KILLFOCUS
, sent
},
1688 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
1689 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
1690 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1691 { WM_SETFOCUS
, sent
}, /* in MDI client */
1693 { HCBT_SETFOCUS
, hook
}, /* MDI client sets focus back to MDI child */
1694 { WM_KILLFOCUS
, sent
}, /* in MDI client */
1695 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
1696 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
1697 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1698 { WM_SETFOCUS
, sent
}, /* in MDI client */
1700 { WM_DESTROY
, sent
},
1702 { HCBT_SETFOCUS
, hook
}, /* set focus to MDI client */
1703 { WM_KILLFOCUS
, sent
},
1704 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
1705 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
1706 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1707 { WM_SETFOCUS
, sent
}, /* in MDI client */
1709 { HCBT_SETFOCUS
, hook
}, /* MDI client sets focus back to MDI child */
1710 { WM_KILLFOCUS
, sent
}, /* in MDI client */
1711 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
1712 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
1713 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1714 { WM_SETFOCUS
, sent
}, /* in MDI client */
1716 { WM_NCDESTROY
, sent
},
1719 /* CreateWindow for MDI child window, initially invisible */
1720 static const struct message WmCreateMDIchildInvisibleSeq
[] = {
1721 { HCBT_CREATEWND
, hook
},
1722 { WM_NCCREATE
, sent
},
1723 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
1724 { WM_CREATE
, sent
},
1725 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1726 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
1728 /* Win2k sends wparam set to
1729 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
1730 * while Win9x doesn't bother to set child window id according to
1731 * CLIENTCREATESTRUCT.idFirstChild
1733 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
1736 /* DestroyWindow for MDI child window, initially invisible */
1737 static const struct message WmDestroyMDIchildInvisibleSeq
[] = {
1738 { HCBT_DESTROYWND
, hook
},
1739 /* Win2k sends wparam set to
1740 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
1741 * while Win9x doesn't bother to set child window id according to
1742 * CLIENTCREATESTRUCT.idFirstChild
1744 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_DESTROY*/ }, /* in MDI client */
1745 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
1746 { WM_DESTROY
, sent
},
1747 { WM_NCDESTROY
, sent
},
1748 /* FIXME: Wine destroys an icon/title window while Windows doesn't */
1749 { WM_PARENTNOTIFY
, sent
|wparam
|optional
, WM_DESTROY
}, /* MDI client */
1752 /* CreateWindow for the 1st MDI child window, initially visible and maximized */
1753 static const struct message WmCreateMDIchildVisibleMaxSeq1
[] = {
1754 { HCBT_CREATEWND
, hook
},
1755 { WM_NCCREATE
, sent
},
1756 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
1757 { WM_CREATE
, sent
},
1758 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1759 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
1761 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
1762 { WM_GETMINMAXINFO
, sent
},
1763 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|0x8000 },
1764 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1765 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|0x8000 },
1766 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
1768 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1769 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1770 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1771 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
1772 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
1773 /* Win2k sends wparam set to
1774 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
1775 * while Win9x doesn't bother to set child window id according to
1776 * CLIENTCREATESTRUCT.idFirstChild
1778 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
1779 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1780 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1781 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1782 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1783 { WM_MDIREFRESHMENU
, sent
/*|wparam|lparam, 0, 0*/ },
1784 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
1785 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
1786 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1788 /* Win9x: message sequence terminates here. */
1790 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 },
1791 { HCBT_SETFOCUS
, hook
}, /* in MDI client */
1792 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
1793 { WM_IME_NOTIFY
, sent
|wparam
|optional
, 2 }, /* in MDI client */
1794 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1795 { WM_SETFOCUS
, sent
}, /* in MDI client */
1796 { HCBT_SETFOCUS
, hook
},
1797 { WM_KILLFOCUS
, sent
}, /* in MDI client */
1798 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
1799 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
1800 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1801 { WM_SETFOCUS
, sent
|defwinproc
},
1802 { WM_MDIACTIVATE
, sent
|defwinproc
},
1804 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1805 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1806 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1807 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
1810 /* CreateWindow for the 2nd MDI child window, initially visible and maximized */
1811 static const struct message WmCreateMDIchildVisibleMaxSeq2
[] = {
1812 /* restore the 1st MDI child */
1813 { WM_SETREDRAW
, sent
|wparam
, 0 },
1814 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWNORMAL
},
1815 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|0x8000 },
1816 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1817 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
1818 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|0x8000 },
1819 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
1821 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1822 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1823 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1824 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
1825 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
1826 { WM_SETREDRAW
, sent
|wparam
, 1 }, /* in the 1st MDI child */
1827 /* create the 2nd MDI child */
1828 { HCBT_CREATEWND
, hook
},
1829 { WM_NCCREATE
, sent
},
1830 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
1831 { WM_CREATE
, sent
},
1832 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1833 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
1835 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
1836 { WM_GETMINMAXINFO
, sent
},
1837 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|0x8000 },
1838 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1839 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1840 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|0x8000 },
1841 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
1843 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1844 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1845 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1846 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
1847 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
1848 /* Win2k sends wparam set to
1849 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
1850 * while Win9x doesn't bother to set child window id according to
1851 * CLIENTCREATESTRUCT.idFirstChild
1853 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
1854 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1855 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1856 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1857 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1858 { WM_MDIREFRESHMENU
, sent
/*|wparam|lparam, 0, 0*/ },
1859 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
1860 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
1862 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 0 }, /* in the 1st MDI child */
1863 { WM_MDIACTIVATE
, sent
|defwinproc
}, /* in the 1st MDI child */
1865 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1867 /* Win9x: message sequence terminates here. */
1869 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 },
1870 { HCBT_SETFOCUS
, hook
},
1871 { WM_KILLFOCUS
, sent
|defwinproc
}, /* in the 1st MDI child */
1872 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 0 }, /* in the 1st MDI child */
1873 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
1874 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1875 { WM_SETFOCUS
, sent
}, /* in MDI client */
1876 { HCBT_SETFOCUS
, hook
},
1877 { WM_KILLFOCUS
, sent
}, /* in MDI client */
1878 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
1879 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
1880 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1881 { WM_SETFOCUS
, sent
|defwinproc
},
1883 { WM_MDIACTIVATE
, sent
|defwinproc
},
1885 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1886 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1887 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1888 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
1891 /* WM_MDICREATE MDI child window, initially visible and maximized */
1892 static const struct message WmCreateMDIchildVisibleMaxSeq3
[] = {
1893 { WM_MDICREATE
, sent
},
1894 { HCBT_CREATEWND
, hook
},
1895 { WM_NCCREATE
, sent
},
1896 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
1897 { WM_CREATE
, sent
},
1898 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1899 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
1901 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
1902 { WM_GETMINMAXINFO
, sent
},
1903 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|0x8000 },
1904 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1905 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|0x8000 },
1906 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
1909 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1910 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1911 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1912 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
1913 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
1915 /* Win2k sends wparam set to
1916 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
1917 * while Win9x doesn't bother to set child window id according to
1918 * CLIENTCREATESTRUCT.idFirstChild
1920 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
1921 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1922 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1924 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1926 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1927 { WM_MDIREFRESHMENU
, sent
/*|wparam|lparam, 0, 0*/ },
1928 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
1930 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
1931 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1933 /* Win9x: message sequence terminates here. */
1935 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 },
1936 { WM_SETFOCUS
, sent
|optional
}, /* in MDI client */
1937 { HCBT_SETFOCUS
, hook
}, /* in MDI client */
1938 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
1939 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
|optional
, OBJID_CLIENT
, 0 },
1940 { WM_SETFOCUS
, sent
|optional
}, /* in MDI client */
1941 { HCBT_SETFOCUS
, hook
|optional
},
1942 { WM_KILLFOCUS
, sent
}, /* in MDI client */
1943 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
1944 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
1945 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1946 { WM_SETFOCUS
, sent
|defwinproc
},
1948 { WM_MDIACTIVATE
, sent
|defwinproc
},
1951 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1952 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1953 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1954 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1957 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1958 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1959 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1960 { WM_MOVE
, sent
|defwinproc
},
1961 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
1964 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
1965 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1966 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
},
1967 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
1970 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
1971 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1972 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
},
1973 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
1975 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
1976 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI client */
1977 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 }, /* XP sends it to MDI frame */
1978 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
1979 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* XP sends a duplicate */
1983 /* CreateWindow for the 1st MDI child window, initially invisible and maximized */
1984 static const struct message WmCreateMDIchildInvisibleMaxSeq4
[] = {
1985 { HCBT_CREATEWND
, hook
},
1986 { WM_GETMINMAXINFO
, sent
},
1987 { WM_NCCREATE
, sent
},
1988 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
1989 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
1990 { WM_CREATE
, sent
},
1991 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1992 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
1994 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
1995 { WM_GETMINMAXINFO
, sent
},
1996 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|0x8000 },
1997 { WM_GETMINMAXINFO
, sent
|defwinproc
},
1998 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1999 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|0x8000 },
2000 { WM_MOVE
, sent
|defwinproc
},
2001 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2003 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2004 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2005 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2006 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2007 { WM_NCCALCSIZE
, sent
|wparam
, 1 }, /* MDI child */
2008 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2009 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2010 /* Win2k sends wparam set to
2011 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2012 * while Win9x doesn't bother to set child window id according to
2013 * CLIENTCREATESTRUCT.idFirstChild
2015 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
2018 /* WM_SYSCOMMAND/SC_CLOSE for the 2nd MDI child window, initially visible and maximized */
2019 static const struct message WmDestroyMDIchildVisibleMaxSeq2
[] = {
2020 { WM_SYSCOMMAND
, sent
|wparam
, SC_CLOSE
},
2021 { HCBT_SYSCOMMAND
, hook
},
2022 { WM_CLOSE
, sent
|defwinproc
},
2023 { WM_MDIDESTROY
, sent
}, /* in MDI client */
2025 /* bring the 1st MDI child to top */
2026 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOSIZE
|SWP_NOMOVE
}, /* in the 1st MDI child */
2027 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
}, /* in the 2nd MDI child */
2029 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2031 { WM_CHILDACTIVATE
, sent
|defwinproc
|wparam
|lparam
, 0, 0 }, /* in the 1st MDI child */
2032 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 0 }, /* in the 1st MDI child */
2033 { WM_MDIACTIVATE
, sent
|defwinproc
}, /* in the 1st MDI child */
2035 /* maximize the 1st MDI child */
2036 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
2037 { WM_GETMINMAXINFO
, sent
|defwinproc
},
2038 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|0x8000 },
2039 { WM_NCCALCSIZE
, sent
|defwinproc
|wparam
, 1 },
2040 { WM_CHILDACTIVATE
, sent
|defwinproc
|wparam
|lparam
, 0, 0 },
2041 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|0x8000 },
2042 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2044 /* restore the 2nd MDI child */
2045 { WM_SETREDRAW
, sent
|defwinproc
|wparam
, 0 },
2046 { HCBT_MINMAX
, hook
|lparam
, 0, SW_NORMALNA
},
2047 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_SHOWWINDOW
|0x8000 },
2048 { WM_NCCALCSIZE
, sent
|defwinproc
|wparam
, 1 },
2050 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2052 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|0x8000 },
2053 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2055 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2057 { WM_SETREDRAW
, sent
|defwinproc
|wparam
, 1 },
2059 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2060 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2061 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2062 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2063 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2065 /* bring the 1st MDI child to top */
2066 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2067 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 },
2068 { HCBT_SETFOCUS
, hook
},
2069 { WM_KILLFOCUS
, sent
|defwinproc
},
2070 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 0 },
2071 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2072 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2073 { WM_SETFOCUS
, sent
}, /* in MDI client */
2074 { HCBT_SETFOCUS
, hook
},
2075 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2076 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2077 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
2078 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2079 { WM_SETFOCUS
, sent
|defwinproc
},
2080 { WM_MDIACTIVATE
, sent
|defwinproc
},
2081 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2083 /* apparently ShowWindow(SW_SHOW) on an MDI client */
2084 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
2085 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2086 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2087 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2088 { WM_MDIREFRESHMENU
, sent
},
2090 { HCBT_DESTROYWND
, hook
},
2091 /* Win2k sends wparam set to
2092 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
2093 * while Win9x doesn't bother to set child window id according to
2094 * CLIENTCREATESTRUCT.idFirstChild
2096 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_DESTROY*/ }, /* in MDI client */
2097 { WM_SHOWWINDOW
, sent
|defwinproc
|wparam
, 0 },
2098 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2099 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2100 { WM_ERASEBKGND
, sent
|parent
|optional
},
2101 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2103 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
2104 { WM_DESTROY
, sent
|defwinproc
},
2105 { WM_NCDESTROY
, sent
|defwinproc
},
2108 /* WM_MDIDESTROY for the single MDI child window, initially visible and maximized */
2109 static const struct message WmDestroyMDIchildVisibleMaxSeq1
[] = {
2110 { WM_MDIDESTROY
, sent
}, /* in MDI client */
2111 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
2112 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2113 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2114 { WM_ERASEBKGND
, sent
|parent
|optional
},
2115 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2117 { HCBT_SETFOCUS
, hook
},
2118 { WM_KILLFOCUS
, sent
},
2119 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
2120 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2121 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2122 { WM_SETFOCUS
, sent
}, /* in MDI client */
2123 { HCBT_SETFOCUS
, hook
},
2124 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2125 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2126 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
2127 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2128 { WM_SETFOCUS
, sent
},
2131 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2132 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2133 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2134 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2137 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2138 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2139 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2140 { WM_MOVE
, sent
|defwinproc
},
2141 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2144 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
2145 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2146 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
},
2147 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2150 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
2151 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2152 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
},
2153 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2156 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2157 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 },
2158 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2159 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2162 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2163 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 },
2164 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2165 { WM_MOVE
, sent
|defwinproc
},
2166 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2169 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
2170 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2171 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
},
2172 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2175 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
},
2176 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 },
2177 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
},
2178 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2179 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2180 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI client */
2182 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
|optional
, 1 }, /* XP sends it to MDI frame */
2184 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2185 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2186 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI client */
2187 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2188 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* XP sends a duplicate */
2191 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2192 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2193 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2194 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2196 { WM_NCACTIVATE
, sent
|wparam
, 0 },
2197 { WM_MDIACTIVATE
, sent
},
2199 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWNORMAL
},
2200 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_SHOWWINDOW
|0x8000 },
2201 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2203 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2205 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2206 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_SHOWWINDOW
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
|0x8000 },
2207 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2210 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2211 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 },
2212 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2213 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2216 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2217 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2218 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2219 { WM_MOVE
, sent
|defwinproc
},
2220 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2223 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
2224 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2225 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
},
2226 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2227 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2228 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 }, /* XP */
2229 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI client */
2230 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2231 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* XP sends a duplicate */
2233 { HCBT_SETFOCUS
, hook
},
2234 { WM_KILLFOCUS
, sent
},
2235 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
2236 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2237 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2238 { WM_SETFOCUS
, sent
}, /* in MDI client */
2240 { WM_MDIREFRESHMENU
, sent
}, /* in MDI client */
2242 { HCBT_DESTROYWND
, hook
},
2243 /* Win2k sends wparam set to
2244 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
2245 * while Win9x doesn't bother to set child window id according to
2246 * CLIENTCREATESTRUCT.idFirstChild
2248 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_DESTROY*/ }, /* in MDI client */
2250 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
2251 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2252 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2253 { WM_ERASEBKGND
, sent
|parent
|optional
},
2254 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2256 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
2257 { WM_DESTROY
, sent
},
2258 { WM_NCDESTROY
, sent
},
2261 /* ShowWindow(SW_MAXIMIZE) for a not visible MDI child window */
2262 static const struct message WmMaximizeMDIchildInvisibleSeq
[] = {
2263 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
2264 { WM_GETMINMAXINFO
, sent
},
2265 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|0x8000 },
2266 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2267 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2268 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2270 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2271 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 },
2272 { HCBT_SETFOCUS
, hook
},
2273 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2274 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2275 { WM_SETFOCUS
, sent
}, /* in MDI client */
2276 { HCBT_SETFOCUS
, hook
},
2277 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2278 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2279 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
2280 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2281 { WM_SETFOCUS
, sent
|defwinproc
},
2282 { WM_MDIACTIVATE
, sent
|defwinproc
},
2283 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|0x8000 },
2284 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2286 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2287 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2288 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2289 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2290 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2293 /* ShowWindow(SW_MAXIMIZE) for a not visible maximized MDI child window */
2294 static const struct message WmMaximizeMDIchildInvisibleSeq2
[] = {
2295 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
2296 { WM_GETMINMAXINFO
, sent
},
2297 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
},
2298 { WM_GETMINMAXINFO
, sent
|defwinproc
},
2299 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2300 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2301 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2303 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2304 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 },
2305 { HCBT_SETFOCUS
, hook
},
2306 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2307 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2308 { WM_SETFOCUS
, sent
}, /* in MDI client */
2309 { HCBT_SETFOCUS
, hook
},
2310 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2311 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2312 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
2313 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2314 { WM_SETFOCUS
, sent
|defwinproc
},
2315 { WM_MDIACTIVATE
, sent
|defwinproc
},
2316 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2317 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2320 /* WM_MDIMAXIMIZE for an MDI child window with invisible parent */
2321 static const struct message WmMaximizeMDIchildInvisibleParentSeq
[] = {
2322 { WM_MDIMAXIMIZE
, sent
}, /* in MDI client */
2323 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
2324 { WM_GETMINMAXINFO
, sent
},
2325 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|0x8000 },
2326 { WM_GETMINMAXINFO
, sent
|defwinproc
},
2327 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2328 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* XP doesn't send it */
2329 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2330 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOREDRAW
|0x8000 },
2331 { WM_MOVE
, sent
|defwinproc
},
2332 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2334 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2335 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 },
2336 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2337 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
|optional
, 1 },
2338 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI child XP */
2339 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI client XP */
2341 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2342 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2343 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2344 { WM_MOVE
, sent
|defwinproc
},
2345 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2346 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI frame win2000 */
2348 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
2349 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2350 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
},
2351 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2353 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
},
2354 { WM_GETMINMAXINFO
, sent
|defwinproc
},
2355 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 },
2356 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
},
2357 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2358 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI child win2000 */
2359 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
|optional
, 1 },
2360 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI child XP */
2361 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI child XP */
2362 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI client XP */
2364 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
2365 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI frame XP */
2366 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI frame XP */
2367 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI child XP */
2370 /* ShowWindow(SW_MAXIMIZE) for a visible MDI child window */
2371 static const struct message WmMaximizeMDIchildVisibleSeq
[] = {
2372 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
2373 { WM_GETMINMAXINFO
, sent
},
2374 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|0x8000 },
2375 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2376 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2377 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|0x8000 },
2378 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2380 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2381 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2382 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2383 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2384 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2387 /* ShowWindow(SW_RESTORE) for a visible maximized MDI child window */
2388 static const struct message WmRestoreMDIchildVisibleSeq
[] = {
2389 { HCBT_MINMAX
, hook
|lparam
, 0, SW_RESTORE
},
2390 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|0x8000 },
2391 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2392 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2393 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|0x8000 },
2394 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2396 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2397 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2398 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2399 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2400 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2403 /* ShowWindow(SW_RESTORE) for a visible minimized MDI child window */
2404 static const struct message WmRestoreMDIchildVisibleSeq_2
[] = {
2405 { HCBT_MINMAX
, hook
|lparam
, 0, SW_RESTORE
},
2406 { WM_QUERYOPEN
, sent
|wparam
|lparam
, 0, 0 },
2407 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|0x8000 },
2408 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2409 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2410 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_NOCLIENTSIZE
|0x8000 },
2411 { WM_MOVE
, sent
|defwinproc
},
2412 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2413 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2414 { EVENT_SYSTEM_MINIMIZEEND
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2415 { HCBT_SETFOCUS
, hook
},
2416 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
2417 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
2418 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2419 { WM_SETFOCUS
, sent
},
2422 /* ShowWindow(SW_MINIMIZE) for a visible restored MDI child window */
2423 static const struct message WmMinimizeMDIchildVisibleSeq
[] = {
2424 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
2425 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOCOPYBITS
|0x8000 },
2426 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2427 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOCOPYBITS
|SWP_NOCLIENTSIZE
|0x8000 },
2428 { WM_MOVE
, sent
|defwinproc
},
2429 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MINIMIZED
},
2430 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
|defwinproc
, 0, 0 },
2431 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2432 { EVENT_SYSTEM_MINIMIZESTART
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2433 /* FIXME: Wine creates an icon/title window while Windows doesn't */
2434 { WM_PARENTNOTIFY
, sent
|parent
|wparam
|optional
, WM_CREATE
}, /* MDI client */
2437 /* ShowWindow(SW_RESTORE) for a not visible MDI child window */
2438 static const struct message WmRestoreMDIchildInisibleSeq
[] = {
2439 { HCBT_MINMAX
, hook
|lparam
, 0, SW_RESTORE
},
2440 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|0x8000 },
2441 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2442 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2443 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2444 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|0x8000 },
2445 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2447 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2448 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2449 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2450 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2451 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2455 static HWND mdi_client
;
2456 static WNDPROC old_mdi_client_proc
;
2458 static LRESULT WINAPI
mdi_client_hook_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
2462 /* do not log painting messages */
2463 if (message
!= WM_PAINT
&&
2464 message
!= WM_NCPAINT
&&
2465 message
!= WM_SYNCPAINT
&&
2466 message
!= WM_ERASEBKGND
&&
2467 message
!= WM_NCPAINT
&&
2468 message
!= WM_NCHITTEST
&&
2469 message
!= WM_GETTEXT
&&
2470 message
!= WM_MDIGETACTIVE
&&
2471 message
!= WM_GETICON
&&
2472 message
!= WM_DEVICECHANGE
)
2474 trace("mdi client: %p, %04x, %08x, %08lx\n", hwnd
, message
, wParam
, lParam
);
2478 case WM_WINDOWPOSCHANGING
:
2479 case WM_WINDOWPOSCHANGED
:
2481 WINDOWPOS
*winpos
= (WINDOWPOS
*)lParam
;
2483 trace("%s\n", (message
== WM_WINDOWPOSCHANGING
) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
2484 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
2485 winpos
->hwnd
, winpos
->hwndInsertAfter
,
2486 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
2487 dump_winpos_flags(winpos
->flags
);
2489 /* Log only documented flags, win2k uses 0x1000 and 0x2000
2490 * in the high word for internal purposes
2492 wParam
= winpos
->flags
& 0xffff;
2493 /* We are not interested in the flags that don't match under XP and Win9x */
2494 wParam
&= ~(SWP_NOZORDER
);
2499 msg
.message
= message
;
2500 msg
.flags
= sent
|wparam
|lparam
;
2501 msg
.wParam
= wParam
;
2502 msg
.lParam
= lParam
;
2506 return CallWindowProcA(old_mdi_client_proc
, hwnd
, message
, wParam
, lParam
);
2509 static LRESULT WINAPI
mdi_child_wnd_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
2511 static long defwndproc_counter
= 0;
2515 /* do not log painting messages */
2516 if (message
!= WM_PAINT
&&
2517 message
!= WM_NCPAINT
&&
2518 message
!= WM_SYNCPAINT
&&
2519 message
!= WM_ERASEBKGND
&&
2520 message
!= WM_NCPAINT
&&
2521 message
!= WM_NCHITTEST
&&
2522 message
!= WM_GETTEXT
&&
2523 message
!= WM_GETICON
&&
2524 message
!= WM_DEVICECHANGE
)
2526 trace("mdi child: %p, %04x, %08x, %08lx\n", hwnd
, message
, wParam
, lParam
);
2530 case WM_WINDOWPOSCHANGING
:
2531 case WM_WINDOWPOSCHANGED
:
2533 WINDOWPOS
*winpos
= (WINDOWPOS
*)lParam
;
2535 trace("%s\n", (message
== WM_WINDOWPOSCHANGING
) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
2536 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
2537 winpos
->hwnd
, winpos
->hwndInsertAfter
,
2538 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
2539 dump_winpos_flags(winpos
->flags
);
2541 /* Log only documented flags, win2k uses 0x1000 and 0x2000
2542 * in the high word for internal purposes
2544 wParam
= winpos
->flags
& 0xffff;
2545 /* We are not interested in the flags that don't match under XP and Win9x */
2546 wParam
&= ~(SWP_NOZORDER
);
2550 case WM_MDIACTIVATE
:
2552 HWND active
, client
= GetParent(hwnd
);
2554 active
= (HWND
)SendMessageA(client
, WM_MDIGETACTIVE
, 0, 0);
2556 if (hwnd
== (HWND
)lParam
) /* if we are being activated */
2557 ok (active
== (HWND
)lParam
, "new active %p != active %p\n", (HWND
)lParam
, active
);
2559 ok (active
== (HWND
)wParam
, "old active %p != active %p\n", (HWND
)wParam
, active
);
2564 msg
.message
= message
;
2565 msg
.flags
= sent
|wparam
|lparam
;
2566 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
2567 msg
.wParam
= wParam
;
2568 msg
.lParam
= lParam
;
2572 defwndproc_counter
++;
2573 ret
= DefMDIChildProcA(hwnd
, message
, wParam
, lParam
);
2574 defwndproc_counter
--;
2579 static LRESULT WINAPI
mdi_frame_wnd_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
2581 static long defwndproc_counter
= 0;
2585 /* do not log painting messages */
2586 if (message
!= WM_PAINT
&&
2587 message
!= WM_NCPAINT
&&
2588 message
!= WM_SYNCPAINT
&&
2589 message
!= WM_ERASEBKGND
&&
2590 message
!= WM_NCPAINT
&&
2591 message
!= WM_NCHITTEST
&&
2592 message
!= WM_GETTEXT
&&
2593 message
!= WM_GETICON
&&
2594 message
!= WM_DEVICECHANGE
)
2596 trace("mdi frame: %p, %04x, %08x, %08lx\n", hwnd
, message
, wParam
, lParam
);
2600 case WM_WINDOWPOSCHANGING
:
2601 case WM_WINDOWPOSCHANGED
:
2603 WINDOWPOS
*winpos
= (WINDOWPOS
*)lParam
;
2605 trace("%s\n", (message
== WM_WINDOWPOSCHANGING
) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
2606 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
2607 winpos
->hwnd
, winpos
->hwndInsertAfter
,
2608 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
2609 dump_winpos_flags(winpos
->flags
);
2611 /* Log only documented flags, win2k uses 0x1000 and 0x2000
2612 * in the high word for internal purposes
2614 wParam
= winpos
->flags
& 0xffff;
2615 /* We are not interested in the flags that don't match under XP and Win9x */
2616 wParam
&= ~(SWP_NOZORDER
);
2621 msg
.message
= message
;
2622 msg
.flags
= sent
|wparam
|lparam
;
2623 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
2624 msg
.wParam
= wParam
;
2625 msg
.lParam
= lParam
;
2629 defwndproc_counter
++;
2630 ret
= DefFrameProcA(hwnd
, mdi_client
, message
, wParam
, lParam
);
2631 defwndproc_counter
--;
2636 static BOOL
mdi_RegisterWindowClasses(void)
2641 cls
.lpfnWndProc
= mdi_frame_wnd_proc
;
2644 cls
.hInstance
= GetModuleHandleA(0);
2646 cls
.hCursor
= LoadCursorA(0, (LPSTR
)IDC_ARROW
);
2647 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
2648 cls
.lpszMenuName
= NULL
;
2649 cls
.lpszClassName
= "MDI_frame_class";
2650 if (!RegisterClassA(&cls
)) return FALSE
;
2652 cls
.lpfnWndProc
= mdi_child_wnd_proc
;
2653 cls
.lpszClassName
= "MDI_child_class";
2654 if (!RegisterClassA(&cls
)) return FALSE
;
2656 if (!GetClassInfoA(0, "MDIClient", &cls
)) assert(0);
2657 old_mdi_client_proc
= cls
.lpfnWndProc
;
2658 cls
.hInstance
= GetModuleHandleA(0);
2659 cls
.lpfnWndProc
= mdi_client_hook_proc
;
2660 cls
.lpszClassName
= "MDI_client_class";
2661 if (!RegisterClassA(&cls
)) assert(0);
2666 static void test_mdi_messages(void)
2668 MDICREATESTRUCTA mdi_cs
;
2669 CLIENTCREATESTRUCT client_cs
;
2670 HWND mdi_frame
, mdi_child
, mdi_child2
, active_child
;
2672 HMENU hMenu
= CreateMenu();
2674 assert(mdi_RegisterWindowClasses());
2678 trace("creating MDI frame window\n");
2679 mdi_frame
= CreateWindowExA(0, "MDI_frame_class", "MDI frame window",
2680 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
|
2681 WS_MAXIMIZEBOX
| WS_VISIBLE
,
2682 100, 100, CW_USEDEFAULT
, CW_USEDEFAULT
,
2683 GetDesktopWindow(), hMenu
,
2684 GetModuleHandleA(0), NULL
);
2686 ok_sequence(WmCreateMDIframeSeq
, "Create MDI frame window", FALSE
);
2688 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
2689 ok(GetFocus() == mdi_frame
, "wrong focus window %p\n", GetFocus());
2691 trace("creating MDI client window\n");
2692 client_cs
.hWindowMenu
= 0;
2693 client_cs
.idFirstChild
= MDI_FIRST_CHILD_ID
;
2694 mdi_client
= CreateWindowExA(0, "MDI_client_class",
2696 WS_CHILD
| WS_VISIBLE
| MDIS_ALLCHILDSTYLES
,
2698 mdi_frame
, 0, GetModuleHandleA(0), &client_cs
);
2700 ok_sequence(WmCreateMDIclientSeq
, "Create visible MDI client window", FALSE
);
2702 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
2703 ok(GetFocus() == mdi_frame
, "input focus should be on MDI frame not on %p\n", GetFocus());
2705 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
2706 ok(!active_child
, "wrong active MDI child %p\n", active_child
);
2707 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
2712 trace("creating invisible MDI child window\n");
2713 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
2715 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
2716 mdi_client
, 0, GetModuleHandleA(0), NULL
);
2720 ShowWindow(mdi_child
, SW_SHOWNORMAL
);
2721 ok_sequence(WmShowChildSeq
, "ShowWindow(SW_SHOWNORMAL) MDI child window", FALSE
);
2723 ok(GetWindowLongA(mdi_child
, GWL_STYLE
) & WS_VISIBLE
, "MDI child should be visible\n");
2724 ok(IsWindowVisible(mdi_child
), "MDI child should be visible\n");
2726 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
2727 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2729 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
2730 ok(!active_child
, "wrong active MDI child %p\n", active_child
);
2731 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
2733 ShowWindow(mdi_child
, SW_HIDE
);
2734 ok_sequence(WmHideChildSeq
, "ShowWindow(SW_HIDE) MDI child window", FALSE
);
2737 ShowWindow(mdi_child
, SW_SHOW
);
2738 ok_sequence(WmShowChildSeq
, "ShowWindow(SW_SHOW) MDI child window", FALSE
);
2740 ok(GetWindowLongA(mdi_child
, GWL_STYLE
) & WS_VISIBLE
, "MDI child should be visible\n");
2741 ok(IsWindowVisible(mdi_child
), "MDI child should be visible\n");
2743 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
2744 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2746 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
2747 ok(!active_child
, "wrong active MDI child %p\n", active_child
);
2748 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
2750 DestroyWindow(mdi_child
);
2753 trace("creating visible MDI child window\n");
2754 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
2755 WS_CHILD
| WS_VISIBLE
,
2756 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
2757 mdi_client
, 0, GetModuleHandleA(0), NULL
);
2759 ok_sequence(WmCreateMDIchildVisibleSeq
, "Create visible MDI child window", FALSE
);
2761 ok(GetWindowLongA(mdi_child
, GWL_STYLE
) & WS_VISIBLE
, "MDI child should be visible\n");
2762 ok(IsWindowVisible(mdi_child
), "MDI child should be visible\n");
2764 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
2765 ok(GetFocus() == mdi_child
, "wrong focus window %p\n", GetFocus());
2767 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
2768 ok(active_child
== mdi_child
, "wrong active MDI child %p\n", active_child
);
2769 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
2772 DestroyWindow(mdi_child
);
2773 ok_sequence(WmDestroyMDIchildVisibleSeq
, "Destroy visible MDI child window", TRUE
);
2775 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
2776 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2778 /* Win2k: MDI client still returns a just destroyed child as active
2779 * Win9x: MDI client returns 0
2781 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
2782 ok(active_child
== mdi_child
|| /* win2k */
2783 !active_child
, /* win9x */
2784 "wrong active MDI child %p\n", active_child
);
2785 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
2789 trace("creating invisible MDI child window\n");
2790 mdi_child2
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
2792 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
2793 mdi_client
, 0, GetModuleHandleA(0), NULL
);
2795 ok_sequence(WmCreateMDIchildInvisibleSeq
, "Create invisible MDI child window", FALSE
);
2797 ok(!(GetWindowLongA(mdi_child2
, GWL_STYLE
) & WS_VISIBLE
), "MDI child should not be visible\n");
2798 ok(!IsWindowVisible(mdi_child2
), "MDI child should not be visible\n");
2800 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
2801 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2803 /* Win2k: MDI client still returns a just destroyed child as active
2804 * Win9x: MDI client returns mdi_child2
2806 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
2807 ok(active_child
== mdi_child
|| /* win2k */
2808 active_child
== mdi_child2
, /* win9x */
2809 "wrong active MDI child %p\n", active_child
);
2810 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
2813 ShowWindow(mdi_child2
, SW_MAXIMIZE
);
2814 ok_sequence(WmMaximizeMDIchildInvisibleSeq
, "ShowWindow(SW_MAXIMIZE):invisible MDI child", FALSE
);
2816 ok(GetWindowLongA(mdi_child2
, GWL_STYLE
) & WS_VISIBLE
, "MDI child should be visible\n");
2817 ok(IsWindowVisible(mdi_child2
), "MDI child should be visible\n");
2819 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
2820 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
2821 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
2824 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
2825 ok(GetFocus() == mdi_child2
|| /* win2k */
2826 GetFocus() == 0, /* win9x */
2827 "wrong focus window %p\n", GetFocus());
2832 ShowWindow(mdi_child2
, SW_HIDE
);
2833 ok_sequence(WmHideChildSeq
, "ShowWindow(SW_HIDE):MDI child", FALSE
);
2835 ShowWindow(mdi_child2
, SW_RESTORE
);
2836 ok_sequence(WmRestoreMDIchildInisibleSeq
, "ShowWindow(SW_RESTORE):invisible MDI child", FALSE
);
2839 ok(GetWindowLongA(mdi_child2
, GWL_STYLE
) & WS_VISIBLE
, "MDI child should be visible\n");
2840 ok(IsWindowVisible(mdi_child2
), "MDI child should be visible\n");
2842 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
2843 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
2844 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
2850 ShowWindow(mdi_child2
, SW_HIDE
);
2851 ok_sequence(WmHideChildSeq
, "ShowWindow(SW_HIDE):MDI child", FALSE
);
2853 ShowWindow(mdi_child2
, SW_SHOW
);
2854 ok_sequence(WmShowChildSeq
, "ShowWindow(SW_SHOW):MDI child", FALSE
);
2856 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
2857 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2859 ShowWindow(mdi_child2
, SW_MAXIMIZE
);
2860 ok_sequence(WmMaximizeMDIchildVisibleSeq
, "ShowWindow(SW_MAXIMIZE):MDI child", FALSE
);
2862 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
2863 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2865 ShowWindow(mdi_child2
, SW_RESTORE
);
2866 ok_sequence(WmRestoreMDIchildVisibleSeq
, "ShowWindow(SW_RESTORE):maximized MDI child", FALSE
);
2868 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
2869 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2871 ShowWindow(mdi_child2
, SW_MINIMIZE
);
2872 ok_sequence(WmMinimizeMDIchildVisibleSeq
, "ShowWindow(SW_MINIMIZE):MDI child", TRUE
);
2874 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
2875 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2877 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
2878 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
2879 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
2882 ShowWindow(mdi_child2
, SW_RESTORE
);
2883 ok_sequence(WmRestoreMDIchildVisibleSeq_2
, "ShowWindow(SW_RESTORE):minimized MDI child", TRUE
);
2885 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
2886 ok(GetFocus() == mdi_child2
, "wrong focus window %p\n", GetFocus());
2888 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
2889 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
2890 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
2896 ShowWindow(mdi_child2
, SW_HIDE
);
2897 ok_sequence(WmHideChildSeq
, "ShowWindow(SW_HIDE):MDI child", FALSE
);
2899 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
2900 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2902 DestroyWindow(mdi_child2
);
2903 ok_sequence(WmDestroyMDIchildInvisibleSeq
, "Destroy invisible MDI child window", FALSE
);
2905 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
2906 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2908 /* test for maximized MDI children */
2909 trace("creating maximized visible MDI child window 1\n");
2910 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
2911 WS_CHILD
| WS_VISIBLE
| WS_MAXIMIZEBOX
| WS_MAXIMIZE
,
2912 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
2913 mdi_client
, 0, GetModuleHandleA(0), NULL
);
2915 ok_sequence(WmCreateMDIchildVisibleMaxSeq1
, "Create maximized visible 1st MDI child window", TRUE
);
2916 ok(IsZoomed(mdi_child
), "1st MDI child should be maximized\n");
2918 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
2919 ok(GetFocus() == mdi_child
|| /* win2k */
2920 GetFocus() == 0, /* win9x */
2921 "wrong focus window %p\n", GetFocus());
2923 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
2924 ok(active_child
== mdi_child
, "wrong active MDI child %p\n", active_child
);
2925 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
2928 trace("creating maximized visible MDI child window 2\n");
2929 mdi_child2
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
2930 WS_CHILD
| WS_VISIBLE
| WS_MAXIMIZEBOX
| WS_MAXIMIZE
,
2931 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
2932 mdi_client
, 0, GetModuleHandleA(0), NULL
);
2934 ok_sequence(WmCreateMDIchildVisibleMaxSeq2
, "Create maximized visible 2nd MDI child 2 window", TRUE
);
2935 ok(IsZoomed(mdi_child2
), "2nd MDI child should be maximized\n");
2936 ok(!IsZoomed(mdi_child
), "1st MDI child should NOT be maximized\n");
2938 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
2939 ok(GetFocus() == mdi_child2
, "wrong focus window %p\n", GetFocus());
2941 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
2942 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
2943 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
2946 trace("destroying maximized visible MDI child window 2\n");
2947 DestroyWindow(mdi_child2
);
2948 ok_sequence(WmDestroyMDIchildVisibleSeq
, "Destroy visible MDI child window", TRUE
);
2950 ok(!IsZoomed(mdi_child
), "1st MDI child should NOT be maximized\n");
2952 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
2953 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2955 /* Win2k: MDI client still returns a just destroyed child as active
2956 * Win9x: MDI client returns 0
2958 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
2959 ok(active_child
== mdi_child2
|| /* win2k */
2960 !active_child
, /* win9x */
2961 "wrong active MDI child %p\n", active_child
);
2964 ShowWindow(mdi_child
, SW_MAXIMIZE
);
2965 ok(IsZoomed(mdi_child
), "1st MDI child should be maximized\n");
2968 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
2969 ok(GetFocus() == mdi_child
, "wrong focus window %p\n", GetFocus());
2971 trace("re-creating maximized visible MDI child window 2\n");
2972 mdi_child2
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
2973 WS_CHILD
| WS_VISIBLE
| WS_MAXIMIZEBOX
| WS_MAXIMIZE
,
2974 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
2975 mdi_client
, 0, GetModuleHandleA(0), NULL
);
2977 ok_sequence(WmCreateMDIchildVisibleMaxSeq2
, "Create maximized visible 2nd MDI child 2 window", TRUE
);
2978 ok(IsZoomed(mdi_child2
), "2nd MDI child should be maximized\n");
2979 ok(!IsZoomed(mdi_child
), "1st MDI child should NOT be maximized\n");
2981 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
2982 ok(GetFocus() == mdi_child2
, "wrong focus window %p\n", GetFocus());
2984 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
2985 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
2986 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
2989 SendMessageA(mdi_child2
, WM_SYSCOMMAND
, SC_CLOSE
, 0);
2990 ok_sequence(WmDestroyMDIchildVisibleMaxSeq2
, "WM_SYSCOMMAND/SC_CLOSE on a visible maximized MDI child window", TRUE
);
2991 ok(!IsWindow(mdi_child2
), "MDI child 2 should be destroyed\n");
2993 ok(IsZoomed(mdi_child
), "1st MDI child should be maximized\n");
2994 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
2995 ok(GetFocus() == mdi_child
, "wrong focus window %p\n", GetFocus());
2997 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
2998 ok(active_child
== mdi_child
, "wrong active MDI child %p\n", active_child
);
2999 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
3002 DestroyWindow(mdi_child
);
3003 ok_sequence(WmDestroyMDIchildVisibleSeq
, "Destroy visible MDI child window", TRUE
);
3005 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3006 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3008 /* Win2k: MDI client still returns a just destroyed child as active
3009 * Win9x: MDI client returns 0
3011 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3012 ok(active_child
== mdi_child
|| /* win2k */
3013 !active_child
, /* win9x */
3014 "wrong active MDI child %p\n", active_child
);
3017 trace("creating maximized invisible MDI child window\n");
3018 mdi_child2
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3019 WS_CHILD
| WS_MAXIMIZE
| WS_CAPTION
| WS_THICKFRAME
,
3020 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
3021 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3023 ok_sequence(WmCreateMDIchildInvisibleMaxSeq4
, "Create maximized invisible MDI child window", TRUE
);
3024 ok(IsZoomed(mdi_child2
), "MDI child should be maximized\n");
3025 ok(!(GetWindowLongA(mdi_child2
, GWL_STYLE
) & WS_VISIBLE
), "MDI child should be not visible\n");
3026 ok(!IsWindowVisible(mdi_child2
), "MDI child should be not visible\n");
3028 /* Win2k: MDI client still returns a just destroyed child as active
3029 * Win9x: MDI client returns 0
3031 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3032 ok(active_child
== mdi_child
|| /* win2k */
3033 !active_child
, /* win9x */
3034 "wrong active MDI child %p\n", active_child
);
3037 trace("call ShowWindow(mdi_child, SW_MAXIMIZE)\n");
3038 ShowWindow(mdi_child2
, SW_MAXIMIZE
);
3039 ok_sequence(WmMaximizeMDIchildInvisibleSeq2
, "ShowWindow(SW_MAXIMIZE):invisible maximized MDI child", FALSE
);
3040 ok(IsZoomed(mdi_child2
), "MDI child should be maximized\n");
3041 ok(GetWindowLongA(mdi_child2
, GWL_STYLE
) & WS_VISIBLE
, "MDI child should be visible\n");
3042 ok(IsWindowVisible(mdi_child2
), "MDI child should be visible\n");
3044 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3045 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
3046 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
3049 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child2
, 0);
3052 /* end of test for maximized MDI children */
3054 mdi_cs
.szClass
= "MDI_child_Class";
3055 mdi_cs
.szTitle
= "MDI child";
3056 mdi_cs
.hOwner
= GetModuleHandleA(0);
3059 mdi_cs
.cx
= CW_USEDEFAULT
;
3060 mdi_cs
.cy
= CW_USEDEFAULT
;
3061 mdi_cs
.style
= WS_CHILD
| WS_SYSMENU
| WS_VISIBLE
| WS_MAXIMIZEBOX
| WS_MAXIMIZE
;
3063 mdi_child
= (HWND
)SendMessageA(mdi_client
, WM_MDICREATE
, 0, (LPARAM
)&mdi_cs
);
3064 ok(mdi_child
!= 0, "MDI child creation failed\n");
3065 ok_sequence(WmCreateMDIchildVisibleMaxSeq3
, "WM_MDICREATE for maximized visible MDI child window", TRUE
);
3067 ok(GetMenuItemID(hMenu
, GetMenuItemCount(hMenu
) - 1) == SC_CLOSE
, "SC_CLOSE menu item not found\n");
3069 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3070 ok(active_child
== mdi_child
, "wrong active MDI child %p\n", active_child
);
3072 ok(IsZoomed(mdi_child
), "MDI child should be maximized\n");
3073 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3074 ok(GetFocus() == mdi_child
, "wrong focus window %p\n", GetFocus());
3076 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3077 ok(active_child
== mdi_child
, "wrong active MDI child %p\n", active_child
);
3078 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
3081 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
3082 ok_sequence(WmDestroyMDIchildVisibleMaxSeq1
, "Destroy visible maximized MDI child window", TRUE
);
3084 ok(!IsWindow(mdi_child
), "MDI child should be destroyed\n");
3085 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3086 ok(!active_child
, "wrong active MDI child %p\n", active_child
);
3091 DestroyWindow(mdi_client
);
3092 ok_sequence(WmDestroyMDIclientSeq
, "Destroy MDI client window", FALSE
);
3094 /* test maximization of MDI child with invisible parent */
3095 client_cs
.hWindowMenu
= 0;
3096 mdi_client
= CreateWindow("MDI_client_class",
3098 WS_CHILD
| WS_CLIPCHILDREN
| WS_VSCROLL
| WS_HSCROLL
| WS_VISIBLE
,
3100 mdi_frame
, 0, GetModuleHandleA(0), &client_cs
);
3101 ok_sequence(WmCreateMDIclientSeq
, "Create MDI client window", FALSE
);
3103 ShowWindow(mdi_client
, SW_HIDE
);
3104 ok_sequence(WmHideMDIclientSeq
, "Hide MDI client window", FALSE
);
3106 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3107 WS_CHILD
| WS_CLIPCHILDREN
| WS_VSCROLL
| WS_HSCROLL
,
3109 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3110 ok_sequence(WmCreateMDIchildInvisibleParentSeq
, "Create MDI child window with invisible parent", FALSE
);
3112 SendMessage(mdi_client
, WM_MDIMAXIMIZE
, (WPARAM
) mdi_child
, 0);
3113 ok_sequence(WmMaximizeMDIchildInvisibleParentSeq
, "Maximize MDI child window with invisible parent", TRUE
);
3114 zoomed
= IsZoomed(mdi_child
);
3115 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
3117 ShowWindow(mdi_client
, SW_SHOW
);
3118 ok_sequence(WmShowMDIclientSeq
, "Show MDI client window", FALSE
);
3120 DestroyWindow(mdi_child
);
3121 ok_sequence(WmDestroyMDIchildVisibleSeq
, "Destroy visible maximized MDI child window", TRUE
);
3123 DestroyWindow(mdi_client
);
3124 ok_sequence(WmDestroyMDIclientSeq
, "Destroy MDI client window", FALSE
);
3125 /* end of test for maximization of MDI child with invisible parent */
3127 DestroyWindow(mdi_frame
);
3128 ok_sequence(WmDestroyMDIframeSeq
, "Destroy MDI frame window", FALSE
);
3130 /************************* End of MDI test **********************************/
3132 static void test_WM_SETREDRAW(HWND hwnd
)
3134 DWORD style
= GetWindowLongA(hwnd
, GWL_STYLE
);
3138 SendMessageA(hwnd
, WM_SETREDRAW
, FALSE
, 0);
3139 ok_sequence(WmSetRedrawFalseSeq
, "SetRedraw:FALSE", FALSE
);
3141 ok(!(GetWindowLongA(hwnd
, GWL_STYLE
) & WS_VISIBLE
), "WS_VISIBLE should NOT be set\n");
3142 ok(!IsWindowVisible(hwnd
), "IsWindowVisible() should return FALSE\n");
3145 SendMessageA(hwnd
, WM_SETREDRAW
, TRUE
, 0);
3146 ok_sequence(WmSetRedrawTrueSeq
, "SetRedraw:TRUE", FALSE
);
3148 ok(GetWindowLongA(hwnd
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
3149 ok(IsWindowVisible(hwnd
), "IsWindowVisible() should return TRUE\n");
3151 /* restore original WS_VISIBLE state */
3152 SetWindowLongA(hwnd
, GWL_STYLE
, style
);
3157 static INT_PTR CALLBACK
TestModalDlgProcA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
3161 trace("dialog: %p, %04x, %08x, %08lx\n", hwnd
, message
, wParam
, lParam
);
3163 /* explicitly ignore WM_GETICON message */
3164 if (message
== WM_GETICON
) return 0;
3171 case WM_DEVICECHANGE
:
3176 case WM_WINDOWPOSCHANGING
:
3177 case WM_WINDOWPOSCHANGED
:
3179 WINDOWPOS
*winpos
= (WINDOWPOS
*)lParam
;
3181 trace("%s\n", (message
== WM_WINDOWPOSCHANGING
) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
3182 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
3183 winpos
->hwnd
, winpos
->hwndInsertAfter
,
3184 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
3185 dump_winpos_flags(winpos
->flags
);
3187 /* Log only documented flags, win2k uses 0x1000 and 0x2000
3188 * in the high word for internal purposes
3190 wParam
= winpos
->flags
& 0xffff;
3191 /* We are not interested in the flags that don't match under XP and Win9x */
3192 wParam
&= ~(SWP_NOZORDER
);
3197 msg
.message
= message
;
3198 msg
.flags
= sent
|wparam
|lparam
;
3199 msg
.wParam
= wParam
;
3200 msg
.lParam
= lParam
;
3203 if (message
== WM_INITDIALOG
) SetTimer( hwnd
, 1, 100, NULL
);
3204 if (message
== WM_TIMER
) EndDialog( hwnd
, 0 );
3208 static void test_hv_scroll_1(HWND hwnd
, INT ctl
, DWORD clear
, DWORD set
, INT min
, INT max
)
3210 DWORD style
, exstyle
;
3214 exstyle
= GetWindowLongA(hwnd
, GWL_EXSTYLE
);
3215 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
3216 /* do not be confused by WS_DLGFRAME set */
3217 if ((style
& WS_CAPTION
) == WS_CAPTION
) style
&= ~WS_CAPTION
;
3219 if (clear
) ok(style
& clear
, "style %08x should be set\n", clear
);
3220 if (set
) ok(!(style
& set
), "style %08x should not be set\n", set
);
3222 ret
= SetScrollRange(hwnd
, ctl
, min
, max
, FALSE
);
3223 ok( ret
, "SetScrollRange(%d) error %d\n", ctl
, GetLastError());
3224 if ((style
& (WS_DLGFRAME
| WS_BORDER
| WS_THICKFRAME
)) || (exstyle
& WS_EX_DLGMODALFRAME
))
3225 ok_sequence(WmSetScrollRangeHV_NC_Seq
, "SetScrollRange(SB_HORZ/SB_VERT) NC", FALSE
);
3227 ok_sequence(WmSetScrollRangeHVSeq
, "SetScrollRange(SB_HORZ/SB_VERT)", FALSE
);
3229 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
3230 if (set
) ok(style
& set
, "style %08x should be set\n", set
);
3231 if (clear
) ok(!(style
& clear
), "style %08x should not be set\n", clear
);
3233 /* a subsequent call should do nothing */
3234 ret
= SetScrollRange(hwnd
, ctl
, min
, max
, FALSE
);
3235 ok( ret
, "SetScrollRange(%d) error %d\n", ctl
, GetLastError());
3236 ok_sequence(WmEmptySeq
, "SetScrollRange(SB_HORZ/SB_VERT) empty sequence", FALSE
);
3240 trace("Ignore GetScrollRange error below if you are on Win9x\n");
3241 ret
= GetScrollRange(hwnd
, ctl
, &xmin
, &xmax
);
3242 ok( ret
, "GetScrollRange(%d) error %d\n", ctl
, GetLastError());
3243 ok_sequence(WmEmptySeq
, "GetScrollRange(SB_HORZ/SB_VERT) empty sequence", FALSE
);
3244 ok(xmin
== min
, "unexpected min scroll value %d\n", xmin
);
3245 ok(xmax
== max
, "unexpected max scroll value %d\n", xmax
);
3248 static void test_hv_scroll_2(HWND hwnd
, INT ctl
, DWORD clear
, DWORD set
, INT min
, INT max
)
3250 DWORD style
, exstyle
;
3254 exstyle
= GetWindowLongA(hwnd
, GWL_EXSTYLE
);
3255 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
3256 /* do not be confused by WS_DLGFRAME set */
3257 if ((style
& WS_CAPTION
) == WS_CAPTION
) style
&= ~WS_CAPTION
;
3259 if (clear
) ok(style
& clear
, "style %08x should be set\n", clear
);
3260 if (set
) ok(!(style
& set
), "style %08x should not be set\n", set
);
3262 si
.cbSize
= sizeof(si
);
3263 si
.fMask
= SIF_RANGE
;
3266 SetScrollInfo(hwnd
, ctl
, &si
, TRUE
);
3267 if ((style
& (WS_DLGFRAME
| WS_BORDER
| WS_THICKFRAME
)) || (exstyle
& WS_EX_DLGMODALFRAME
))
3268 ok_sequence(WmSetScrollRangeHV_NC_Seq
, "SetScrollInfo(SB_HORZ/SB_VERT) NC", FALSE
);
3270 ok_sequence(WmSetScrollRangeHVSeq
, "SetScrollInfo(SB_HORZ/SB_VERT)", FALSE
);
3272 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
3273 if (set
) ok(style
& set
, "style %08x should be set\n", set
);
3274 if (clear
) ok(!(style
& clear
), "style %08x should not be set\n", clear
);
3276 /* a subsequent call should do nothing */
3277 SetScrollInfo(hwnd
, ctl
, &si
, TRUE
);
3278 if (style
& WS_HSCROLL
)
3279 ok_sequence(WmSetScrollRangeHSeq_empty
, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE
);
3280 else if (style
& WS_VSCROLL
)
3281 ok_sequence(WmSetScrollRangeVSeq_empty
, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE
);
3283 ok_sequence(WmEmptySeq
, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE
);
3285 si
.fMask
= SIF_PAGE
;
3287 SetScrollInfo(hwnd
, ctl
, &si
, FALSE
);
3288 ok_sequence(WmEmptySeq
, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE
);
3292 SetScrollInfo(hwnd
, ctl
, &si
, FALSE
);
3293 ok_sequence(WmEmptySeq
, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE
);
3295 si
.fMask
= SIF_RANGE
;
3296 si
.nMin
= 0xdeadbeef;
3297 si
.nMax
= 0xdeadbeef;
3298 ret
= GetScrollInfo(hwnd
, ctl
, &si
);
3299 ok( ret
, "GetScrollInfo error %d\n", GetLastError());
3300 ok_sequence(WmEmptySeq
, "GetScrollRange(SB_HORZ/SB_VERT) empty sequence", FALSE
);
3301 ok(si
.nMin
== min
, "unexpected min scroll value %d\n", si
.nMin
);
3302 ok(si
.nMax
== max
, "unexpected max scroll value %d\n", si
.nMax
);
3305 /* Win9x sends WM_USER+xxx while and NT versions send SBM_xxx messages */
3306 static void test_scroll_messages(HWND hwnd
)
3314 ret
= GetScrollRange(hwnd
, SB_CTL
, &min
, &max
);
3315 ok( ret
, "GetScrollRange error %d\n", GetLastError());
3316 if (sequence
->message
!= WmGetScrollRangeSeq
[0].message
)
3317 trace("GetScrollRange(SB_CTL) generated unknown message %04x\n", sequence
->message
);
3318 /* values of min and max are undefined */
3321 ret
= SetScrollRange(hwnd
, SB_CTL
, 10, 150, FALSE
);
3322 ok( ret
, "SetScrollRange error %d\n", GetLastError());
3323 if (sequence
->message
!= WmSetScrollRangeSeq
[0].message
)
3324 trace("SetScrollRange(SB_CTL) generated unknown message %04x\n", sequence
->message
);
3329 ret
= GetScrollRange(hwnd
, SB_CTL
, &min
, &max
);
3330 ok( ret
, "GetScrollRange error %d\n", GetLastError());
3331 if (sequence
->message
!= WmGetScrollRangeSeq
[0].message
)
3332 trace("GetScrollRange(SB_CTL) generated unknown message %04x\n", sequence
->message
);
3333 /* values of min and max are undefined */
3336 si
.cbSize
= sizeof(si
);
3337 si
.fMask
= SIF_RANGE
;
3340 SetScrollInfo(hwnd
, SB_CTL
, &si
, FALSE
);
3341 if (sequence
->message
!= WmSetScrollRangeSeq
[0].message
)
3342 trace("SetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence
->message
);
3345 si
.fMask
= SIF_PAGE
;
3347 SetScrollInfo(hwnd
, SB_CTL
, &si
, FALSE
);
3348 if (sequence
->message
!= WmSetScrollRangeSeq
[0].message
)
3349 trace("SetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence
->message
);
3354 SetScrollInfo(hwnd
, SB_CTL
, &si
, FALSE
);
3355 if (sequence
->message
!= WmSetScrollRangeSeq
[0].message
)
3356 trace("SetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence
->message
);
3359 si
.fMask
= SIF_RANGE
;
3360 si
.nMin
= 0xdeadbeef;
3361 si
.nMax
= 0xdeadbeef;
3362 ret
= GetScrollInfo(hwnd
, SB_CTL
, &si
);
3363 ok( ret
, "GetScrollInfo error %d\n", GetLastError());
3364 if (sequence
->message
!= WmGetScrollInfoSeq
[0].message
)
3365 trace("GetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence
->message
);
3366 /* values of min and max are undefined */
3369 /* set WS_HSCROLL */
3370 test_hv_scroll_1(hwnd
, SB_HORZ
, 0, WS_HSCROLL
, 10, 150);
3371 /* clear WS_HSCROLL */
3372 test_hv_scroll_1(hwnd
, SB_HORZ
, WS_HSCROLL
, 0, 0, 0);
3374 /* set WS_HSCROLL */
3375 test_hv_scroll_2(hwnd
, SB_HORZ
, 0, WS_HSCROLL
, 10, 150);
3376 /* clear WS_HSCROLL */
3377 test_hv_scroll_2(hwnd
, SB_HORZ
, WS_HSCROLL
, 0, 0, 0);
3379 /* set WS_VSCROLL */
3380 test_hv_scroll_1(hwnd
, SB_VERT
, 0, WS_VSCROLL
, 10, 150);
3381 /* clear WS_VSCROLL */
3382 test_hv_scroll_1(hwnd
, SB_VERT
, WS_VSCROLL
, 0, 0, 0);
3384 /* set WS_VSCROLL */
3385 test_hv_scroll_2(hwnd
, SB_VERT
, 0, WS_VSCROLL
, 10, 150);
3386 /* clear WS_VSCROLL */
3387 test_hv_scroll_2(hwnd
, SB_VERT
, WS_VSCROLL
, 0, 0, 0);
3390 static void test_showwindow(void)
3395 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW
,
3396 100, 100, 200, 200, 0, 0, 0, NULL
);
3397 ok (hwnd
!= 0, "Failed to create overlapped window\n");
3398 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
3399 0, 0, 10, 10, hwnd
, 0, 0, NULL
);
3400 ok (hchild
!= 0, "Failed to create child\n");
3403 /* ShowWindow( SW_SHOWNA) for invisible top level window */
3404 trace("calling ShowWindow( SW_SHOWNA) for invisible top level window\n");
3405 ok( ShowWindow(hwnd
, SW_SHOWNA
) == FALSE
, "ShowWindow: window was visible\n" );
3406 ok_sequence(WmSHOWNATopInvisible
, "ShowWindow(SW_SHOWNA) on invisible top level window", TRUE
);
3409 /* ShowWindow( SW_SHOWNA) for now visible top level window */
3410 trace("calling ShowWindow( SW_SHOWNA) for now visible top level window\n");
3411 ok( ShowWindow(hwnd
, SW_SHOWNA
) != FALSE
, "ShowWindow: window was invisible\n" );
3412 ok_sequence(WmSHOWNATopVisible
, "ShowWindow(SW_SHOWNA) on visible top level window", FALSE
);
3414 /* back to invisible */
3415 ShowWindow(hchild
, SW_HIDE
);
3416 ShowWindow(hwnd
, SW_HIDE
);
3418 /* ShowWindow(SW_SHOWNA) with child and parent invisible */
3419 trace("calling ShowWindow( SW_SHOWNA) for invisible child with invisible parent\n");
3420 ok( ShowWindow(hchild
, SW_SHOWNA
) == FALSE
, "ShowWindow: window was visible\n" );
3421 ok_sequence(WmSHOWNAChildInvisParInvis
, "ShowWindow(SW_SHOWNA) invisible child and parent", FALSE
);
3423 /* ShowWindow(SW_SHOWNA) with child visible and parent invisible */
3424 ok( ShowWindow(hchild
, SW_SHOW
) != FALSE
, "ShowWindow: window was invisible\n" );
3426 trace("calling ShowWindow( SW_SHOWNA) for the visible child and invisible parent\n");
3427 ok( ShowWindow(hchild
, SW_SHOWNA
) != FALSE
, "ShowWindow: window was invisible\n" );
3428 ok_sequence(WmSHOWNAChildVisParInvis
, "ShowWindow(SW_SHOWNA) visible child and invisible parent", FALSE
);
3430 /* ShowWindow(SW_SHOWNA) with child visible and parent visible */
3431 ShowWindow( hwnd
, SW_SHOW
);
3433 trace("calling ShowWindow( SW_SHOWNA) for the visible child and parent\n");
3434 ok( ShowWindow(hchild
, SW_SHOWNA
) != FALSE
, "ShowWindow: window was invisible\n" );
3435 ok_sequence(WmSHOWNAChildVisParVis
, "ShowWindow(SW_SHOWNA) for the visible child and parent", FALSE
);
3438 /* ShowWindow(SW_SHOWNA) with child invisible and parent visible */
3439 ShowWindow( hchild
, SW_HIDE
);
3441 trace("calling ShowWindow( SW_SHOWNA) for the invisible child and visible parent\n");
3442 ok( ShowWindow(hchild
, SW_SHOWNA
) == FALSE
, "ShowWindow: window was visible\n" );
3443 ok_sequence(WmSHOWNAChildInvisParVis
, "ShowWindow(SW_SHOWNA) for the invisible child and visible parent", FALSE
);
3447 ok(GetCapture() == hchild
, "wrong capture window %p\n", GetCapture());
3448 DestroyWindow(hchild
);
3449 ok(!GetCapture(), "wrong capture window %p\n", GetCapture());
3451 DestroyWindow(hwnd
);
3456 * 1. Create invisible maximized popup window.
3457 * 2. Move and resize it.
3458 * 3. Show it maximized.
3460 trace("calling CreateWindowExA( WS_MAXIMIZE ) for invisible maximized popup window\n");
3461 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP
| WS_MAXIMIZE
,
3462 100, 100, 200, 200, 0, 0, 0, NULL
);
3463 ok (hwnd
!= 0, "Failed to create popup window\n");
3464 ok(IsZoomed(hwnd
), "window should be maximized\n");
3465 ok_sequence(WmCreateInvisibleMaxPopupSeq
, "CreateWindow(WS_MAXIMIZED):popup", FALSE
);
3468 GetWindowRect(hwnd
, &rc
);
3469 ok( rc
.right
-rc
.left
== GetSystemMetrics(SM_CXSCREEN
) &&
3470 rc
.bottom
-rc
.top
== GetSystemMetrics(SM_CYSCREEN
),
3471 "Invalid maximized size before ShowWindow (%d,%d)-(%d,%d)\n",
3472 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
3473 /* Reset window's size & position */
3474 SetWindowPos(hwnd
, 0, 10, 10, 200, 200, SWP_NOZORDER
| SWP_NOACTIVATE
);
3475 ok(IsZoomed(hwnd
), "window should be maximized\n");
3478 trace("calling ShowWindow( SW_SHOWMAXIMIZE ) for invisible maximized popup window\n");
3479 ShowWindow(hwnd
, SW_SHOWMAXIMIZED
);
3480 ok(IsZoomed(hwnd
), "window should be maximized\n");
3481 ok_sequence(WmShowMaxPopupResizedSeq
, "ShowWindow(SW_SHOWMAXIMIZED):invisible maximized and resized popup", FALSE
);
3484 GetWindowRect(hwnd
, &rc
);
3485 ok( rc
.right
-rc
.left
== GetSystemMetrics(SM_CXSCREEN
) &&
3486 rc
.bottom
-rc
.top
== GetSystemMetrics(SM_CYSCREEN
),
3487 "Invalid maximized size after ShowWindow (%d,%d)-(%d,%d)\n",
3488 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
3489 DestroyWindow(hwnd
);
3493 * 1. Create invisible maximized popup window.
3494 * 2. Show it maximized.
3496 trace("calling CreateWindowExA( WS_MAXIMIZE ) for invisible maximized popup window\n");
3497 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP
| WS_MAXIMIZE
,
3498 100, 100, 200, 200, 0, 0, 0, NULL
);
3499 ok (hwnd
!= 0, "Failed to create popup window\n");
3500 ok(IsZoomed(hwnd
), "window should be maximized\n");
3501 ok_sequence(WmCreateInvisibleMaxPopupSeq
, "CreateWindow(WS_MAXIMIZED):popup", FALSE
);
3504 trace("calling ShowWindow( SW_SHOWMAXIMIZE ) for invisible maximized popup window\n");
3505 ShowWindow(hwnd
, SW_SHOWMAXIMIZED
);
3506 ok(IsZoomed(hwnd
), "window should be maximized\n");
3507 ok_sequence(WmShowMaxPopupSeq
, "ShowWindow(SW_SHOWMAXIMIZED):invisible maximized popup", FALSE
);
3509 DestroyWindow(hwnd
);
3513 * 1. Create visible maximized popup window.
3515 trace("calling CreateWindowExA( WS_MAXIMIZE ) for maximized popup window\n");
3516 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP
| WS_MAXIMIZE
| WS_VISIBLE
,
3517 100, 100, 200, 200, 0, 0, 0, NULL
);
3518 ok (hwnd
!= 0, "Failed to create popup window\n");
3519 ok(IsZoomed(hwnd
), "window should be maximized\n");
3520 ok_sequence(WmCreateMaxPopupSeq
, "CreateWindow(WS_MAXIMIZED):popup", FALSE
);
3522 DestroyWindow(hwnd
);
3526 * 1. Create visible popup window.
3529 trace("calling CreateWindowExA( WS_VISIBLE ) for popup window\n");
3530 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP
| WS_VISIBLE
,
3531 100, 100, 200, 200, 0, 0, 0, NULL
);
3532 ok (hwnd
!= 0, "Failed to create popup window\n");
3533 ok(!IsZoomed(hwnd
), "window should NOT be maximized\n");
3534 ok_sequence(WmCreatePopupSeq
, "CreateWindow(WS_VISIBLE):popup", TRUE
);
3537 trace("calling ShowWindow( SW_SHOWMAXIMIZE ) for visible popup window\n");
3538 ShowWindow(hwnd
, SW_SHOWMAXIMIZED
);
3539 ok(IsZoomed(hwnd
), "window should be maximized\n");
3540 ok_sequence(WmShowVisMaxPopupSeq
, "ShowWindow(SW_SHOWMAXIMIZED):popup", FALSE
);
3542 DestroyWindow(hwnd
);
3546 static void test_sys_menu(void)
3552 hwnd
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
3553 100, 100, 200, 200, 0, 0, 0, NULL
);
3554 ok (hwnd
!= 0, "Failed to create overlapped window\n");
3558 /* test existing window without CS_NOCLOSE style */
3559 hmenu
= GetSystemMenu(hwnd
, FALSE
);
3560 ok(hmenu
!= 0, "GetSystemMenu error %d\n", GetLastError());
3562 state
= GetMenuState(hmenu
, SC_CLOSE
, MF_BYCOMMAND
);
3563 ok(state
!= 0xffffffff, "wrong SC_CLOSE state %x\n", state
);
3564 ok(!(state
& (MF_DISABLED
| MF_GRAYED
)), "wrong SC_CLOSE state %x\n", state
);
3566 EnableMenuItem(hmenu
, SC_CLOSE
, MF_BYCOMMAND
| MF_GRAYED
);
3567 ok_sequence(WmEmptySeq
, "WmEnableMenuItem", FALSE
);
3569 state
= GetMenuState(hmenu
, SC_CLOSE
, MF_BYCOMMAND
);
3570 ok(state
!= 0xffffffff, "wrong SC_CLOSE state %x\n", state
);
3571 ok((state
& (MF_DISABLED
| MF_GRAYED
)) == MF_GRAYED
, "wrong SC_CLOSE state %x\n", state
);
3573 EnableMenuItem(hmenu
, SC_CLOSE
, 0);
3574 ok_sequence(WmEmptySeq
, "WmEnableMenuItem", FALSE
);
3576 state
= GetMenuState(hmenu
, SC_CLOSE
, MF_BYCOMMAND
);
3577 ok(state
!= 0xffffffff, "wrong SC_CLOSE state %x\n", state
);
3578 ok(!(state
& (MF_DISABLED
| MF_GRAYED
)), "wrong SC_CLOSE state %x\n", state
);
3580 /* test whether removing WS_SYSMENU destroys a system menu */
3581 SetWindowLongW(hwnd
, GWL_STYLE
, WS_POPUP
);
3582 SetWindowPos(hwnd
, 0, 0, 0, 0, 0, SWP_NOZORDER
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_FRAMECHANGED
);
3584 hmenu
= GetSystemMenu(hwnd
, FALSE
);
3585 ok(hmenu
!= 0, "GetSystemMenu error %d\n", GetLastError());
3587 DestroyWindow(hwnd
);
3589 /* test new window with CS_NOCLOSE style */
3590 hwnd
= CreateWindowExA(0, "NoCloseWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
3591 100, 100, 200, 200, 0, 0, 0, NULL
);
3592 ok (hwnd
!= 0, "Failed to create overlapped window\n");
3594 hmenu
= GetSystemMenu(hwnd
, FALSE
);
3595 ok(hmenu
!= 0, "GetSystemMenu error %d\n", GetLastError());
3597 state
= GetMenuState(hmenu
, SC_CLOSE
, MF_BYCOMMAND
);
3598 ok(state
== 0xffffffff, "wrong SC_CLOSE state %x\n", state
);
3600 DestroyWindow(hwnd
);
3602 /* test new window without WS_SYSMENU style */
3603 hwnd
= CreateWindowExA(0, "NoCloseWindowClass", NULL
, WS_OVERLAPPEDWINDOW
& ~WS_SYSMENU
,
3604 100, 100, 200, 200, 0, 0, 0, NULL
);
3605 ok(hwnd
!= 0, "Failed to create overlapped window\n");
3607 hmenu
= GetSystemMenu(hwnd
, FALSE
);
3608 ok(!hmenu
, "GetSystemMenu error %d\n", GetLastError());
3610 DestroyWindow(hwnd
);
3613 /* For shown WS_OVERLAPPEDWINDOW */
3614 static const struct message WmSetIcon_1
[] = {
3615 { WM_SETICON
, sent
},
3616 { 0x00AE, sent
|defwinproc
|optional
}, /* XP */
3617 { WM_GETTEXT
, sent
|defwinproc
|optional
},
3618 { WM_GETTEXT
, sent
|defwinproc
|optional
}, /* XP sends a duplicate */
3622 /* For WS_POPUP and hidden WS_OVERLAPPEDWINDOW */
3623 static const struct message WmSetIcon_2
[] = {
3624 { WM_SETICON
, sent
},
3628 /* test if we receive the right sequence of messages */
3629 static void test_messages(void)
3631 HWND hwnd
, hparent
, hchild
;
3632 HWND hchild2
, hbutton
;
3639 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW
,
3640 100, 100, 200, 200, 0, 0, 0, NULL
);
3641 ok (hwnd
!= 0, "Failed to create overlapped window\n");
3642 ok_sequence(WmCreateOverlappedSeq
, "CreateWindow:overlapped", FALSE
);
3644 /* test ShowWindow(SW_HIDE) on a newly created invisible window */
3645 ok( ShowWindow(hwnd
, SW_HIDE
) == FALSE
, "ShowWindow: window was visible\n" );
3646 ok_sequence(WmEmptySeq
, "ShowWindow(SW_HIDE):overlapped, invisible", FALSE
);
3648 /* test WM_SETREDRAW on a not visible top level window */
3649 test_WM_SETREDRAW(hwnd
);
3651 SetWindowPos(hwnd
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
);
3652 ok_sequence(WmSWP_ShowOverlappedSeq
, "SetWindowPos:SWP_SHOWWINDOW:overlapped", FALSE
);
3653 ok(IsWindowVisible(hwnd
), "window should be visible at this point\n");
3655 ok(GetActiveWindow() == hwnd
, "window should be active\n");
3656 ok(GetFocus() == hwnd
, "window should have input focus\n");
3657 ShowWindow(hwnd
, SW_HIDE
);
3658 ok_sequence(WmHideOverlappedSeq
, "ShowWindow(SW_HIDE):overlapped", TRUE
);
3660 ShowWindow(hwnd
, SW_SHOW
);
3661 ok_sequence(WmShowOverlappedSeq
, "ShowWindow(SW_SHOW):overlapped", TRUE
);
3663 ShowWindow(hwnd
, SW_HIDE
);
3664 ok_sequence(WmHideOverlappedSeq
, "ShowWindow(SW_HIDE):overlapped", FALSE
);
3666 ShowWindow(hwnd
, SW_SHOWMAXIMIZED
);
3667 ok_sequence(WmShowMaxOverlappedSeq
, "ShowWindow(SW_SHOWMAXIMIZED):overlapped", TRUE
);
3669 ShowWindow(hwnd
, SW_RESTORE
);
3670 /* FIXME: add ok_sequence() here */
3673 ShowWindow(hwnd
, SW_SHOW
);
3674 ok_sequence(WmEmptySeq
, "ShowWindow(SW_SHOW):overlapped already visible", FALSE
);
3676 ok(GetActiveWindow() == hwnd
, "window should be active\n");
3677 ok(GetFocus() == hwnd
, "window should have input focus\n");
3678 SetWindowPos(hwnd
, 0,0,0,0,0, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
);
3679 ok_sequence(WmSWP_HideOverlappedSeq
, "SetWindowPos:SWP_HIDEWINDOW:overlapped", FALSE
);
3680 ok(!IsWindowVisible(hwnd
), "window should not be visible at this point\n");
3681 ok(GetActiveWindow() == hwnd
, "window should still be active\n");
3683 /* test WM_SETREDRAW on a visible top level window */
3684 ShowWindow(hwnd
, SW_SHOW
);
3685 test_WM_SETREDRAW(hwnd
);
3687 trace("testing scroll APIs on a visible top level window %p\n", hwnd
);
3688 test_scroll_messages(hwnd
);
3690 /* test resizing and moving */
3691 SetWindowPos( hwnd
, 0, 0, 0, 300, 300, SWP_NOMOVE
|SWP_NOACTIVATE
);
3692 ok_sequence(WmSWP_ResizeSeq
, "SetWindowPos:Resize", FALSE
);
3693 SetWindowPos( hwnd
, 0, 200, 200, 0, 0, SWP_NOSIZE
|SWP_NOACTIVATE
);
3694 ok_sequence(WmSWP_MoveSeq
, "SetWindowPos:Move", FALSE
);
3696 /* popups don't get WM_GETMINMAXINFO */
3697 SetWindowLongW( hwnd
, GWL_STYLE
, WS_VISIBLE
|WS_POPUP
);
3698 SetWindowPos( hwnd
, 0, 0, 0, 0, 0, SWP_NOZORDER
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_FRAMECHANGED
);
3700 SetWindowPos( hwnd
, 0, 0, 0, 200, 200, SWP_NOMOVE
|SWP_NOACTIVATE
);
3701 ok_sequence(WmSWP_ResizePopupSeq
, "SetWindowPos:ResizePopup", FALSE
);
3703 DestroyWindow(hwnd
);
3704 ok_sequence(WmDestroyOverlappedSeq
, "DestroyWindow:overlapped", FALSE
);
3706 hparent
= CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
3707 100, 100, 200, 200, 0, 0, 0, NULL
);
3708 ok (hparent
!= 0, "Failed to create parent window\n");
3711 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
| WS_MAXIMIZE
,
3712 0, 0, 10, 10, hparent
, 0, 0, NULL
);
3713 ok (hchild
!= 0, "Failed to create child window\n");
3714 ok_sequence(WmCreateMaximizedChildSeq
, "CreateWindow:maximized child", FALSE
);
3715 DestroyWindow(hchild
);
3718 /* visible child window with a caption */
3719 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child",
3720 WS_CHILD
| WS_VISIBLE
| WS_CAPTION
,
3721 0, 0, 10, 10, hparent
, 0, 0, NULL
);
3722 ok (hchild
!= 0, "Failed to create child window\n");
3723 ok_sequence(WmCreateVisibleChildSeq
, "CreateWindow:visible child", FALSE
);
3725 trace("testing scroll APIs on a visible child window %p\n", hchild
);
3726 test_scroll_messages(hchild
);
3728 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
);
3729 ok_sequence(WmShowChildSeq_4
, "SetWindowPos(SWP_SHOWWINDOW):child with a caption", FALSE
);
3731 DestroyWindow(hchild
);
3734 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
3735 0, 0, 10, 10, hparent
, 0, 0, NULL
);
3736 ok (hchild
!= 0, "Failed to create child window\n");
3737 ok_sequence(WmCreateChildSeq
, "CreateWindow:child", FALSE
);
3739 hchild2
= CreateWindowExA(0, "SimpleWindowClass", "Test child2", WS_CHILD
,
3740 100, 100, 50, 50, hparent
, 0, 0, NULL
);
3741 ok (hchild2
!= 0, "Failed to create child2 window\n");
3744 hbutton
= CreateWindowExA(0, "TestWindowClass", "Test button", WS_CHILD
,
3745 0, 100, 50, 50, hchild
, 0, 0, NULL
);
3746 ok (hbutton
!= 0, "Failed to create button window\n");
3748 /* test WM_SETREDRAW on a not visible child window */
3749 test_WM_SETREDRAW(hchild
);
3751 ShowWindow(hchild
, SW_SHOW
);
3752 ok_sequence(WmShowChildSeq
, "ShowWindow(SW_SHOW):child", FALSE
);
3754 ShowWindow(hchild
, SW_HIDE
);
3755 ok_sequence(WmHideChildSeq
, "ShowWindow(SW_HIDE):child", FALSE
);
3757 ShowWindow(hchild
, SW_SHOW
);
3758 ok_sequence(WmShowChildSeq
, "ShowWindow(SW_SHOW):child", FALSE
);
3760 /* test WM_SETREDRAW on a visible child window */
3761 test_WM_SETREDRAW(hchild
);
3763 MoveWindow(hchild
, 10, 10, 20, 20, TRUE
);
3764 ok_sequence(WmResizingChildWithMoveWindowSeq
, "MoveWindow:child", FALSE
);
3766 ShowWindow(hchild
, SW_HIDE
);
3768 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
);
3769 ok_sequence(WmShowChildSeq_2
, "SetWindowPos:show_child_2", FALSE
);
3771 ShowWindow(hchild
, SW_HIDE
);
3773 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
);
3774 ok_sequence(WmShowChildSeq_3
, "SetWindowPos:show_child_3", FALSE
);
3776 /* DestroyWindow sequence below expects that a child has focus */
3780 DestroyWindow(hchild
);
3781 ok_sequence(WmDestroyChildSeq
, "DestroyWindow:child", FALSE
);
3782 DestroyWindow(hchild2
);
3783 DestroyWindow(hbutton
);
3786 hchild
= CreateWindowExA(0, "TestWindowClass", "Test Child Popup", WS_CHILD
| WS_POPUP
,
3787 0, 0, 100, 100, hparent
, 0, 0, NULL
);
3788 ok (hchild
!= 0, "Failed to create child popup window\n");
3789 ok_sequence(WmCreateChildPopupSeq
, "CreateWindow:child_popup", FALSE
);
3790 DestroyWindow(hchild
);
3792 /* test what happens to a window which sets WS_VISIBLE in WM_CREATE */
3794 hchild
= CreateWindowExA(0, "TestPopupClass", "Test Popup", WS_POPUP
,
3795 0, 0, 100, 100, hparent
, 0, 0, NULL
);
3796 ok (hchild
!= 0, "Failed to create popup window\n");
3797 ok_sequence(WmCreateInvisiblePopupSeq
, "CreateWindow:invisible_popup", FALSE
);
3798 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
3799 ok(IsWindowVisible(hchild
), "IsWindowVisible() should return TRUE\n");
3801 ShowWindow(hchild
, SW_SHOW
);
3802 ok_sequence(WmEmptySeq
, "ShowWindow:show_visible_popup", FALSE
);
3804 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOZORDER
);
3805 ok_sequence(WmShowVisiblePopupSeq_2
, "SetWindowPos:show_visible_popup_2", FALSE
);
3807 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
);
3808 ok_sequence(WmShowVisiblePopupSeq_3
, "SetWindowPos:show_visible_popup_3", FALSE
);
3809 DestroyWindow(hchild
);
3811 /* this time add WS_VISIBLE for CreateWindowEx, but this fact actually
3812 * changes nothing in message sequences.
3815 hchild
= CreateWindowExA(0, "TestPopupClass", "Test Popup", WS_POPUP
| WS_VISIBLE
,
3816 0, 0, 100, 100, hparent
, 0, 0, NULL
);
3817 ok (hchild
!= 0, "Failed to create popup window\n");
3818 ok_sequence(WmCreateInvisiblePopupSeq
, "CreateWindow:invisible_popup", FALSE
);
3819 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
3820 ok(IsWindowVisible(hchild
), "IsWindowVisible() should return TRUE\n");
3822 ShowWindow(hchild
, SW_SHOW
);
3823 ok_sequence(WmEmptySeq
, "ShowWindow:show_visible_popup", FALSE
);
3825 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOZORDER
);
3826 ok_sequence(WmShowVisiblePopupSeq_2
, "SetWindowPos:show_visible_popup_2", FALSE
);
3827 DestroyWindow(hchild
);
3830 hwnd
= CreateWindowExA(WS_EX_DLGMODALFRAME
, "TestDialogClass", NULL
, WS_VISIBLE
|WS_CAPTION
|WS_SYSMENU
|WS_DLGFRAME
,
3831 0, 0, 100, 100, hparent
, 0, 0, NULL
);
3832 ok(hwnd
!= 0, "Failed to create custom dialog window\n");
3833 ok_sequence(WmCreateCustomDialogSeq
, "CreateCustomDialog", TRUE
);
3836 trace("testing scroll APIs on a visible dialog %p\n", hwnd);
3837 test_scroll_messages(hwnd);
3843 SendMessage(hwnd
, WM_NULL
, 0, 0);
3846 after_end_dialog
= 1;
3847 EndDialog( hwnd
, 0 );
3848 ok_sequence(WmEndCustomDialogSeq
, "EndCustomDialog", FALSE
);
3850 DestroyWindow(hwnd
);
3851 after_end_dialog
= 0;
3854 hwnd
= CreateWindowExA(0, "TestDialogClass", NULL
, WS_POPUP
,
3855 0, 0, 100, 100, 0, 0, GetModuleHandleA(0), NULL
);
3856 ok(hwnd
!= 0, "Failed to create custom dialog window\n");
3858 trace("call ShowWindow(%p, SW_SHOW)\n", hwnd
);
3859 ShowWindow(hwnd
, SW_SHOW
);
3860 ok_sequence(WmShowCustomDialogSeq
, "ShowCustomDialog", TRUE
);
3861 DestroyWindow(hwnd
);
3864 DialogBoxA( 0, "TEST_DIALOG", hparent
, TestModalDlgProcA
);
3865 ok_sequence(WmModalDialogSeq
, "ModalDialog", TRUE
);
3867 DestroyWindow(hparent
);
3870 /* Message sequence for SetMenu */
3871 ok(!DrawMenuBar(hwnd
), "DrawMenuBar should return FALSE for a window without a menu\n");
3872 ok_sequence(WmEmptySeq
, "DrawMenuBar for a window without a menu", FALSE
);
3874 hmenu
= CreateMenu();
3875 ok (hmenu
!= 0, "Failed to create menu\n");
3876 ok (InsertMenuA(hmenu
, -1, MF_BYPOSITION
, 0x1000, "foo"), "InsertMenu failed\n");
3877 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW
,
3878 100, 100, 200, 200, 0, hmenu
, 0, NULL
);
3879 ok_sequence(WmCreateOverlappedSeq
, "CreateWindow:overlapped", FALSE
);
3880 ok (SetMenu(hwnd
, 0), "SetMenu\n");
3881 ok_sequence(WmSetMenuNonVisibleSizeChangeSeq
, "SetMenu:NonVisibleSizeChange", FALSE
);
3882 ok (SetMenu(hwnd
, 0), "SetMenu\n");
3883 ok_sequence(WmSetMenuNonVisibleNoSizeChangeSeq
, "SetMenu:NonVisibleNoSizeChange", FALSE
);
3884 ShowWindow(hwnd
, SW_SHOW
);
3885 UpdateWindow( hwnd
);
3886 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
3888 ok (SetMenu(hwnd
, 0), "SetMenu\n");
3889 ok_sequence(WmSetMenuVisibleNoSizeChangeSeq
, "SetMenu:VisibleNoSizeChange", FALSE
);
3890 ok (SetMenu(hwnd
, hmenu
), "SetMenu\n");
3891 ok_sequence(WmSetMenuVisibleSizeChangeSeq
, "SetMenu:VisibleSizeChange", FALSE
);
3893 UpdateWindow( hwnd
);
3894 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
3896 ok(DrawMenuBar(hwnd
), "DrawMenuBar\n");
3897 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
3898 ok_sequence(WmDrawMenuBarSeq
, "DrawMenuBar", FALSE
);
3900 DestroyWindow(hwnd
);
3903 /* Message sequence for EnableWindow */
3904 hparent
= CreateWindowExA(0, "TestWindowClass", "Test parent", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
3905 100, 100, 200, 200, 0, 0, 0, NULL
);
3906 ok (hparent
!= 0, "Failed to create parent window\n");
3907 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
| WS_VISIBLE
,
3908 0, 0, 10, 10, hparent
, 0, 0, NULL
);
3909 ok (hchild
!= 0, "Failed to create child window\n");
3915 EnableWindow(hparent
, FALSE
);
3916 ok_sequence(WmEnableWindowSeq_1
, "EnableWindow(FALSE)", FALSE
);
3918 EnableWindow(hparent
, TRUE
);
3919 ok_sequence(WmEnableWindowSeq_2
, "EnableWindow(TRUE)", FALSE
);
3921 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
3924 /* MsgWaitForMultipleObjects test */
3925 ret
= MsgWaitForMultipleObjects(0, NULL
, FALSE
, 0, QS_POSTMESSAGE
);
3926 ok(ret
== WAIT_TIMEOUT
, "MsgWaitForMultipleObjects returned %x\n", ret
);
3928 PostMessageA(hparent
, WM_USER
, 0, 0);
3930 ret
= MsgWaitForMultipleObjects(0, NULL
, FALSE
, 0, QS_POSTMESSAGE
);
3931 ok(ret
== WAIT_OBJECT_0
, "MsgWaitForMultipleObjects returned %x\n", ret
);
3933 ok(PeekMessageW( &msg
, 0, 0, 0, PM_REMOVE
), "PeekMessage should succeed\n");
3934 ok(msg
.message
== WM_USER
, "got %04x instead of WM_USER\n", msg
.message
);
3936 ret
= MsgWaitForMultipleObjects(0, NULL
, FALSE
, 0, QS_POSTMESSAGE
);
3937 ok(ret
== WAIT_TIMEOUT
, "MsgWaitForMultipleObjects returned %x\n", ret
);
3938 /* end of MsgWaitForMultipleObjects test */
3940 /* the following test causes an exception in user.exe under win9x */
3941 if (!PostMessageW( hparent
, WM_USER
, 0, 0 ))
3943 DestroyWindow(hparent
);
3947 PostMessageW( hparent
, WM_USER
+1, 0, 0 );
3948 /* PeekMessage(NULL) fails, but still removes the message */
3949 SetLastError(0xdeadbeef);
3950 ok( !PeekMessageW( NULL
, 0, 0, 0, PM_REMOVE
), "PeekMessage(NULL) should fail\n" );
3951 ok( GetLastError() == ERROR_NOACCESS
|| /* Win2k */
3952 GetLastError() == 0xdeadbeef, /* NT4 */
3953 "last error is %d\n", GetLastError() );
3954 ok( PeekMessageW( &msg
, 0, 0, 0, PM_REMOVE
), "PeekMessage should succeed\n" );
3955 ok( msg
.message
== WM_USER
+1, "got %x instead of WM_USER+1\n", msg
.message
);
3957 DestroyWindow(hchild
);
3958 DestroyWindow(hparent
);
3961 /* Message sequences for WM_SETICON */
3962 trace("testing WM_SETICON\n");
3963 hwnd
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
3964 CW_USEDEFAULT
, CW_USEDEFAULT
, 300, 300, 0,
3966 ShowWindow(hwnd
, SW_SHOW
);
3968 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
3970 SendMessage(hwnd
, WM_SETICON
, ICON_SMALL
, (LPARAM
)LoadIcon(0, IDI_APPLICATION
));
3971 ok_sequence(WmSetIcon_1
, "WM_SETICON for shown window with caption", FALSE
);
3973 ShowWindow(hwnd
, SW_HIDE
);
3974 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
3976 SendMessage(hwnd
, WM_SETICON
, ICON_SMALL
, (LPARAM
)LoadIcon(0, IDI_APPLICATION
));
3977 ok_sequence(WmSetIcon_2
, "WM_SETICON for hidden window with caption", FALSE
);
3978 DestroyWindow(hwnd
);
3981 hwnd
= CreateWindowExA(0, "TestPopupClass", NULL
, WS_POPUP
,
3982 CW_USEDEFAULT
, CW_USEDEFAULT
, 300, 300, 0,
3984 ShowWindow(hwnd
, SW_SHOW
);
3986 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
3988 SendMessage(hwnd
, WM_SETICON
, ICON_SMALL
, (LPARAM
)LoadIcon(0, IDI_APPLICATION
));
3989 ok_sequence(WmSetIcon_2
, "WM_SETICON for shown window without caption", FALSE
);
3991 ShowWindow(hwnd
, SW_HIDE
);
3992 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
3994 SendMessage(hwnd
, WM_SETICON
, ICON_SMALL
, (LPARAM
)LoadIcon(0, IDI_APPLICATION
));
3995 ok_sequence(WmSetIcon_2
, "WM_SETICON for hidden window without caption", FALSE
);
3996 DestroyWindow(hwnd
);
4000 static void invisible_parent_tests(void)
4002 HWND hparent
, hchild
;
4004 hparent
= CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW
,
4005 100, 100, 200, 200, 0, 0, 0, NULL
);
4006 ok (hparent
!= 0, "Failed to create parent window\n");
4009 /* test showing child with hidden parent */
4011 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
4012 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4013 ok (hchild
!= 0, "Failed to create child window\n");
4014 ok_sequence(WmCreateChildSeq
, "CreateWindow:child", FALSE
);
4016 ShowWindow( hchild
, SW_MINIMIZE
);
4017 ok_sequence(WmShowChildInvisibleParentSeq_1
, "ShowWindow(SW_MINIMIZE) child with invisible parent", FALSE
);
4018 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
4019 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
4024 ShowWindow( hchild
, SW_MINIMIZE
);
4025 ok_sequence(WmShowChildInvisibleParentSeq_1r
, "ShowWindow(SW_MINIMIZE) child with invisible parent", FALSE
);
4027 DestroyWindow(hchild
);
4028 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
4029 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4032 ShowWindow( hchild
, SW_MAXIMIZE
);
4033 ok_sequence(WmShowChildInvisibleParentSeq_2
, "ShowWindow(SW_MAXIMIZE) child with invisible parent", FALSE
);
4034 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
4035 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
4040 ShowWindow( hchild
, SW_MAXIMIZE
);
4041 ok_sequence(WmShowChildInvisibleParentSeq_2r
, "ShowWindow(SW_MAXIMIZE) child with invisible parent", FALSE
);
4043 DestroyWindow(hchild
);
4044 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
4045 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4048 ShowWindow( hchild
, SW_RESTORE
);
4049 ok_sequence(WmShowChildInvisibleParentSeq_5
, "ShowWindow(SW_RESTORE) child with invisible parent", FALSE
);
4050 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
4051 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
4053 DestroyWindow(hchild
);
4054 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
4055 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4058 ShowWindow( hchild
, SW_SHOWMINIMIZED
);
4059 ok_sequence(WmShowChildInvisibleParentSeq_3
, "ShowWindow(SW_SHOWMINIMIZED) child with invisible parent", FALSE
);
4060 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
4061 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
4066 ShowWindow( hchild
, SW_SHOWMINIMIZED
);
4067 ok_sequence(WmShowChildInvisibleParentSeq_3r
, "ShowWindow(SW_SHOWMINIMIZED) child with invisible parent", FALSE
);
4069 DestroyWindow(hchild
);
4070 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
4071 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4074 /* same as ShowWindow( hchild, SW_MAXIMIZE ); */
4075 ShowWindow( hchild
, SW_SHOWMAXIMIZED
);
4076 ok_sequence(WmShowChildInvisibleParentSeq_2
, "ShowWindow(SW_SHOWMAXIMIZED) child with invisible parent", FALSE
);
4077 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
4078 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
4080 DestroyWindow(hchild
);
4081 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
4082 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4085 ShowWindow( hchild
, SW_SHOWMINNOACTIVE
);
4086 ok_sequence(WmShowChildInvisibleParentSeq_4
, "ShowWindow(SW_SHOWMINNOACTIVE) child with invisible parent", FALSE
);
4087 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
4088 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
4093 ShowWindow( hchild
, SW_SHOWMINNOACTIVE
);
4094 ok_sequence(WmShowChildInvisibleParentSeq_4r
, "ShowWindow(SW_SHOWMINNOACTIVE) child with invisible parent", FALSE
);
4096 DestroyWindow(hchild
);
4097 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
4098 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4101 /* FIXME: looks like XP SP2 doesn't know about SW_FORCEMINIMIZE at all */
4102 ShowWindow( hchild
, SW_FORCEMINIMIZE
);
4103 ok_sequence(WmEmptySeq
, "ShowWindow(SW_FORCEMINIMIZE) child with invisible parent", TRUE
);
4105 ok(!(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
), "WS_VISIBLE should be not set\n");
4107 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
4109 DestroyWindow(hchild
);
4110 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
4111 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4114 ShowWindow( hchild
, SW_SHOWNA
);
4115 ok_sequence(WmShowChildInvisibleParentSeq_5
, "ShowWindow(SW_SHOWNA) child with invisible parent", FALSE
);
4116 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
4117 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
4122 ShowWindow( hchild
, SW_SHOWNA
);
4123 ok_sequence(WmShowChildInvisibleParentSeq_5
, "ShowWindow(SW_SHOWNA) child with invisible parent", FALSE
);
4125 DestroyWindow(hchild
);
4126 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
4127 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4130 ShowWindow( hchild
, SW_SHOW
);
4131 ok_sequence(WmShowChildInvisibleParentSeq_5
, "ShowWindow(SW_SHOW) child with invisible parent", FALSE
);
4132 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
4133 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
4138 ShowWindow( hchild
, SW_SHOW
);
4139 ok_sequence(WmEmptySeq
, "ShowWindow(SW_SHOW) child with invisible parent", FALSE
);
4141 ShowWindow( hchild
, SW_HIDE
);
4142 ok_sequence(WmHideChildInvisibleParentSeq
, "ShowWindow:hide child with invisible parent", FALSE
);
4143 ok(!(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
), "WS_VISIBLE should be not set\n");
4144 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
4146 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOZORDER
);
4147 ok_sequence(WmShowChildInvisibleParentSeq_6
, "SetWindowPos:show child with invisible parent", FALSE
);
4148 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
4149 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
4151 SetWindowPos(hchild
, 0,0,0,0,0, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOZORDER
);
4152 ok_sequence(WmHideChildInvisibleParentSeq_2
, "SetWindowPos:hide child with invisible parent", FALSE
);
4153 ok(!(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
), "WS_VISIBLE should not be set\n");
4154 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
4156 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOZORDER
);
4158 DestroyWindow(hchild
);
4159 ok_sequence(WmDestroyInvisibleChildSeq
, "DestroyInvisibleChildSeq", FALSE
);
4161 DestroyWindow(hparent
);
4165 /****************** button message test *************************/
4166 static const struct message WmSetFocusButtonSeq
[] =
4168 { HCBT_SETFOCUS
, hook
},
4169 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
4170 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
4171 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
4172 { WM_SETFOCUS
, sent
|wparam
, 0 },
4173 { WM_CTLCOLORBTN
, sent
|defwinproc
},
4176 static const struct message WmKillFocusButtonSeq
[] =
4178 { HCBT_SETFOCUS
, hook
},
4179 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
4180 { WM_KILLFOCUS
, sent
|wparam
, 0 },
4181 { WM_CTLCOLORBTN
, sent
|defwinproc
},
4182 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
4183 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 1 },
4186 static const struct message WmSetFocusStaticSeq
[] =
4188 { HCBT_SETFOCUS
, hook
},
4189 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
4190 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
4191 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
4192 { WM_SETFOCUS
, sent
|wparam
, 0 },
4193 { WM_CTLCOLORSTATIC
, sent
|defwinproc
},
4196 static const struct message WmKillFocusStaticSeq
[] =
4198 { HCBT_SETFOCUS
, hook
},
4199 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
4200 { WM_KILLFOCUS
, sent
|wparam
, 0 },
4201 { WM_CTLCOLORSTATIC
, sent
|defwinproc
},
4202 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
4203 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 1 },
4206 static const struct message WmLButtonDownSeq
[] =
4208 { WM_LBUTTONDOWN
, sent
|wparam
|lparam
, 0, 0 },
4209 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
4210 { HCBT_SETFOCUS
, hook
},
4211 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
4212 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
4213 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
4214 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
4215 { WM_CTLCOLORBTN
, sent
|defwinproc
},
4216 { BM_SETSTATE
, sent
|wparam
|defwinproc
, TRUE
},
4217 { WM_CTLCOLORBTN
, sent
|defwinproc
},
4218 { EVENT_OBJECT_STATECHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
4221 static const struct message WmLButtonUpSeq
[] =
4223 { WM_LBUTTONUP
, sent
|wparam
|lparam
, 0, 0 },
4224 { BM_SETSTATE
, sent
|wparam
|defwinproc
, FALSE
},
4225 { WM_CTLCOLORBTN
, sent
|defwinproc
},
4226 { EVENT_OBJECT_STATECHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
4227 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, 0, 0 },
4228 { WM_CAPTURECHANGED
, sent
|wparam
|defwinproc
, 0 },
4231 static const struct message WmSetFontButtonSeq
[] =
4233 { WM_SETFONT
, sent
},
4235 { WM_ERASEBKGND
, sent
|defwinproc
},
4236 { WM_CTLCOLORBTN
, sent
|defwinproc
},
4240 static WNDPROC old_button_proc
;
4242 static LRESULT CALLBACK
button_hook_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
4244 static long defwndproc_counter
= 0;
4248 trace("button: %p, %04x, %08x, %08lx\n", hwnd
, message
, wParam
, lParam
);
4250 /* explicitly ignore WM_GETICON message */
4251 if (message
== WM_GETICON
) return 0;
4253 msg
.message
= message
;
4254 msg
.flags
= sent
|wparam
|lparam
;
4255 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
4256 msg
.wParam
= wParam
;
4257 msg
.lParam
= lParam
;
4260 if (message
== BM_SETSTATE
)
4261 ok(GetCapture() == hwnd
, "GetCapture() = %p\n", GetCapture());
4263 defwndproc_counter
++;
4264 ret
= CallWindowProcA(old_button_proc
, hwnd
, message
, wParam
, lParam
);
4265 defwndproc_counter
--;
4270 static void subclass_button(void)
4274 if (!GetClassInfoA(0, "button", &cls
)) assert(0);
4276 old_button_proc
= cls
.lpfnWndProc
;
4278 cls
.hInstance
= GetModuleHandle(0);
4279 cls
.lpfnWndProc
= button_hook_proc
;
4280 cls
.lpszClassName
= "my_button_class";
4281 if (!RegisterClassA(&cls
)) assert(0);
4284 static void test_button_messages(void)
4290 const struct message
*setfocus
;
4291 const struct message
*killfocus
;
4293 { BS_PUSHBUTTON
, DLGC_BUTTON
| DLGC_UNDEFPUSHBUTTON
,
4294 WmSetFocusButtonSeq
, WmKillFocusButtonSeq
},
4295 { BS_DEFPUSHBUTTON
, DLGC_BUTTON
| DLGC_DEFPUSHBUTTON
,
4296 WmSetFocusButtonSeq
, WmKillFocusButtonSeq
},
4297 { BS_CHECKBOX
, DLGC_BUTTON
,
4298 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
},
4299 { BS_AUTOCHECKBOX
, DLGC_BUTTON
,
4300 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
},
4301 { BS_RADIOBUTTON
, DLGC_BUTTON
| DLGC_RADIOBUTTON
,
4302 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
},
4303 { BS_3STATE
, DLGC_BUTTON
,
4304 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
},
4305 { BS_AUTO3STATE
, DLGC_BUTTON
,
4306 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
},
4307 { BS_GROUPBOX
, DLGC_STATIC
,
4308 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
},
4309 { BS_USERBUTTON
, DLGC_BUTTON
| DLGC_UNDEFPUSHBUTTON
,
4310 WmSetFocusButtonSeq
, WmKillFocusButtonSeq
},
4311 { BS_AUTORADIOBUTTON
, DLGC_BUTTON
| DLGC_RADIOBUTTON
,
4312 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
},
4313 { BS_OWNERDRAW
, DLGC_BUTTON
,
4314 WmSetFocusButtonSeq
, WmKillFocusButtonSeq
}
4323 for (i
= 0; i
< sizeof(button
)/sizeof(button
[0]); i
++)
4325 hwnd
= CreateWindowExA(0, "my_button_class", "test", button
[i
].style
| WS_POPUP
,
4326 0, 0, 50, 14, 0, 0, 0, NULL
);
4327 ok(hwnd
!= 0, "Failed to create button window\n");
4329 dlg_code
= SendMessageA(hwnd
, WM_GETDLGCODE
, 0, 0);
4330 ok(dlg_code
== button
[i
].dlg_code
, "%u: wrong dlg_code %08x\n", i
, dlg_code
);
4332 ShowWindow(hwnd
, SW_SHOW
);
4337 trace("button style %08x\n", button
[i
].style
);
4339 ok_sequence(button
[i
].setfocus
, "SetFocus(hwnd) on a button", FALSE
);
4342 ok_sequence(button
[i
].killfocus
, "SetFocus(0) on a button", FALSE
);
4344 DestroyWindow(hwnd
);
4347 hwnd
= CreateWindowExA(0, "my_button_class", "test", BS_PUSHBUTTON
| WS_POPUP
| WS_VISIBLE
,
4348 0, 0, 50, 14, 0, 0, 0, NULL
);
4349 ok(hwnd
!= 0, "Failed to create button window\n");
4354 SendMessageA(hwnd
, WM_LBUTTONDOWN
, 0, 0);
4355 ok_sequence(WmLButtonDownSeq
, "WM_LBUTTONDOWN on a button", FALSE
);
4357 SendMessageA(hwnd
, WM_LBUTTONUP
, 0, 0);
4358 ok_sequence(WmLButtonUpSeq
, "WM_LBUTTONUP on a button", FALSE
);
4361 zfont
= (HFONT
)GetStockObject(SYSTEM_FONT
);
4362 SendMessageA(hwnd
, WM_SETFONT
, (WPARAM
)zfont
, TRUE
);
4364 ok_sequence(WmSetFontButtonSeq
, "WM_SETFONT on a button", FALSE
);
4366 DestroyWindow(hwnd
);
4369 /****************** static message test *************************/
4370 static const struct message WmSetFontStaticSeq
[] =
4372 { WM_SETFONT
, sent
},
4373 { WM_PAINT
, sent
|defwinproc
},
4374 { WM_ERASEBKGND
, sent
|defwinproc
},
4375 { WM_CTLCOLORSTATIC
, sent
|defwinproc
},
4379 static WNDPROC old_static_proc
;
4381 static LRESULT CALLBACK
static_hook_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
4383 static long defwndproc_counter
= 0;
4387 trace("static: %p, %04x, %08x, %08lx\n", hwnd
, message
, wParam
, lParam
);
4389 /* explicitly ignore WM_GETICON message */
4390 if (message
== WM_GETICON
) return 0;
4392 msg
.message
= message
;
4393 msg
.flags
= sent
|wparam
|lparam
;
4394 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
4395 msg
.wParam
= wParam
;
4396 msg
.lParam
= lParam
;
4400 defwndproc_counter
++;
4401 ret
= CallWindowProcA(old_static_proc
, hwnd
, message
, wParam
, lParam
);
4402 defwndproc_counter
--;
4407 static void subclass_static(void)
4411 if (!GetClassInfoA(0, "static", &cls
)) assert(0);
4413 old_static_proc
= cls
.lpfnWndProc
;
4415 cls
.hInstance
= GetModuleHandle(0);
4416 cls
.lpfnWndProc
= static_hook_proc
;
4417 cls
.lpszClassName
= "my_static_class";
4418 if (!RegisterClassA(&cls
)) assert(0);
4421 static void test_static_messages(void)
4423 /* FIXME: make as comprehensive as the button message test */
4428 const struct message
*setfont
;
4430 { SS_LEFT
, DLGC_STATIC
,
4431 WmSetFontStaticSeq
}
4439 for (i
= 0; i
< sizeof(static_ctrl
)/sizeof(static_ctrl
[0]); i
++)
4441 hwnd
= CreateWindowExA(0, "my_static_class", "test", static_ctrl
[i
].style
| WS_POPUP
,
4442 0, 0, 50, 14, 0, 0, 0, NULL
);
4443 ok(hwnd
!= 0, "Failed to create static window\n");
4445 dlg_code
= SendMessageA(hwnd
, WM_GETDLGCODE
, 0, 0);
4446 ok(dlg_code
== static_ctrl
[i
].dlg_code
, "%u: wrong dlg_code %08x\n", i
, dlg_code
);
4448 ShowWindow(hwnd
, SW_SHOW
);
4453 trace("static style %08x\n", static_ctrl
[i
].style
);
4454 SendMessage(hwnd
, WM_SETFONT
, (WPARAM
)GetStockObject(DEFAULT_GUI_FONT
), TRUE
);
4455 ok_sequence(static_ctrl
[i
].setfont
, "WM_SETFONT on a static", FALSE
);
4457 DestroyWindow(hwnd
);
4461 /************* painting message test ********************/
4463 void dump_region(HRGN hrgn
)
4466 RGNDATA
*data
= NULL
;
4471 printf( "null region\n" );
4474 if (!(size
= GetRegionData( hrgn
, 0, NULL
))) return;
4475 if (!(data
= HeapAlloc( GetProcessHeap(), 0, size
))) return;
4476 GetRegionData( hrgn
, size
, data
);
4477 printf("%d rects:", data
->rdh
.nCount
);
4478 for (i
= 0, rect
= (RECT
*)data
->Buffer
; i
< data
->rdh
.nCount
; i
++, rect
++)
4479 printf( " (%d,%d)-(%d,%d)", rect
->left
, rect
->top
, rect
->right
, rect
->bottom
);
4481 HeapFree( GetProcessHeap(), 0, data
);
4484 static void check_update_rgn( HWND hwnd
, HRGN hrgn
)
4488 HRGN tmp
= CreateRectRgn( 0, 0, 0, 0 );
4489 HRGN update
= CreateRectRgn( 0, 0, 0, 0 );
4491 ret
= GetUpdateRgn( hwnd
, update
, FALSE
);
4492 ok( ret
!= ERROR
, "GetUpdateRgn failed\n" );
4493 if (ret
== NULLREGION
)
4495 ok( !hrgn
, "Update region shouldn't be empty\n" );
4499 if (CombineRgn( tmp
, hrgn
, update
, RGN_XOR
) != NULLREGION
)
4501 ok( 0, "Regions are different\n" );
4502 if (winetest_debug
> 0)
4504 printf( "Update region: " );
4505 dump_region( update
);
4506 printf( "Wanted region: " );
4507 dump_region( hrgn
);
4511 GetRgnBox( update
, &r1
);
4512 GetUpdateRect( hwnd
, &r2
, FALSE
);
4513 ok( r1
.left
== r2
.left
&& r1
.top
== r2
.top
&& r1
.right
== r2
.right
&& r1
.bottom
== r2
.bottom
,
4514 "Rectangles are different: %d,%d-%d,%d / %d,%d-%d,%d\n",
4515 r1
.left
, r1
.top
, r1
.right
, r1
.bottom
, r2
.left
, r2
.top
, r2
.right
, r2
.bottom
);
4517 DeleteObject( tmp
);
4518 DeleteObject( update
);
4521 static const struct message WmInvalidateRgn
[] = {
4522 { WM_NCPAINT
, sent
},
4523 { WM_GETTEXT
, sent
|defwinproc
|optional
},
4527 static const struct message WmGetUpdateRect
[] = {
4528 { WM_NCPAINT
, sent
},
4529 { WM_GETTEXT
, sent
|defwinproc
|optional
},
4534 static const struct message WmInvalidateFull
[] = {
4535 { WM_NCPAINT
, sent
|wparam
, 1 },
4536 { WM_GETTEXT
, sent
|defwinproc
|optional
},
4540 static const struct message WmInvalidateErase
[] = {
4541 { WM_NCPAINT
, sent
|wparam
, 1 },
4542 { WM_GETTEXT
, sent
|defwinproc
|optional
},
4543 { WM_ERASEBKGND
, sent
},
4547 static const struct message WmInvalidatePaint
[] = {
4549 { WM_NCPAINT
, sent
|wparam
|beginpaint
, 1 },
4550 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
4554 static const struct message WmInvalidateErasePaint
[] = {
4556 { WM_NCPAINT
, sent
|wparam
|beginpaint
, 1 },
4557 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
4558 { WM_ERASEBKGND
, sent
|beginpaint
},
4562 static const struct message WmInvalidateErasePaint2
[] = {
4564 { WM_NCPAINT
, sent
|beginpaint
},
4565 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
4566 { WM_ERASEBKGND
, sent
|beginpaint
},
4570 static const struct message WmErase
[] = {
4571 { WM_ERASEBKGND
, sent
},
4575 static const struct message WmPaint
[] = {
4580 static const struct message WmParentOnlyPaint
[] = {
4581 { WM_PAINT
, sent
|parent
},
4585 static const struct message WmInvalidateParent
[] = {
4586 { WM_NCPAINT
, sent
|parent
},
4587 { WM_GETTEXT
, sent
|defwinproc
|parent
|optional
},
4588 { WM_ERASEBKGND
, sent
|parent
},
4592 static const struct message WmInvalidateParentChild
[] = {
4593 { WM_NCPAINT
, sent
|parent
},
4594 { WM_GETTEXT
, sent
|defwinproc
|parent
|optional
},
4595 { WM_ERASEBKGND
, sent
|parent
},
4596 { WM_NCPAINT
, sent
},
4597 { WM_GETTEXT
, sent
|defwinproc
|optional
},
4598 { WM_ERASEBKGND
, sent
},
4602 static const struct message WmInvalidateParentChild2
[] = {
4603 { WM_ERASEBKGND
, sent
|parent
},
4604 { WM_NCPAINT
, sent
},
4605 { WM_GETTEXT
, sent
|defwinproc
|optional
},
4606 { WM_ERASEBKGND
, sent
},
4610 static const struct message WmParentPaint
[] = {
4611 { WM_PAINT
, sent
|parent
},
4616 static const struct message WmParentPaintNc
[] = {
4617 { WM_PAINT
, sent
|parent
},
4619 { WM_NCPAINT
, sent
|beginpaint
},
4620 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
4621 { WM_ERASEBKGND
, sent
|beginpaint
},
4625 static const struct message WmChildPaintNc
[] = {
4627 { WM_NCPAINT
, sent
|beginpaint
},
4628 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
4629 { WM_ERASEBKGND
, sent
|beginpaint
},
4633 static const struct message WmParentErasePaint
[] = {
4634 { WM_PAINT
, sent
|parent
},
4635 { WM_NCPAINT
, sent
|parent
|beginpaint
},
4636 { WM_GETTEXT
, sent
|parent
|beginpaint
|defwinproc
|optional
},
4637 { WM_ERASEBKGND
, sent
|parent
|beginpaint
},
4639 { WM_NCPAINT
, sent
|beginpaint
},
4640 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
4641 { WM_ERASEBKGND
, sent
|beginpaint
},
4645 static const struct message WmParentOnlyNcPaint
[] = {
4646 { WM_PAINT
, sent
|parent
},
4647 { WM_NCPAINT
, sent
|parent
|beginpaint
},
4648 { WM_GETTEXT
, sent
|parent
|beginpaint
|defwinproc
|optional
},
4652 static const struct message WmSetParentStyle
[] = {
4653 { WM_STYLECHANGING
, sent
|parent
},
4654 { WM_STYLECHANGED
, sent
|parent
},
4658 static void test_paint_messages(void)
4664 HWND hparent
, hchild
;
4665 HRGN hrgn
= CreateRectRgn( 0, 0, 0, 0 );
4666 HRGN hrgn2
= CreateRectRgn( 0, 0, 0, 0 );
4667 HWND hwnd
= CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW
,
4668 100, 100, 200, 200, 0, 0, 0, NULL
);
4669 ok (hwnd
!= 0, "Failed to create overlapped window\n");
4671 ShowWindow( hwnd
, SW_SHOW
);
4672 UpdateWindow( hwnd
);
4676 check_update_rgn( hwnd
, 0 );
4677 SetRectRgn( hrgn
, 10, 10, 20, 20 );
4678 ret
= RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
);
4679 ok(ret
, "RedrawWindow returned %d instead of TRUE\n", ret
);
4680 check_update_rgn( hwnd
, hrgn
);
4681 SetRectRgn( hrgn2
, 20, 20, 30, 30 );
4682 ret
= RedrawWindow( hwnd
, NULL
, hrgn2
, RDW_INVALIDATE
);
4683 ok(ret
, "RedrawWindow returned %d instead of TRUE\n", ret
);
4684 CombineRgn( hrgn
, hrgn
, hrgn2
, RGN_OR
);
4685 check_update_rgn( hwnd
, hrgn
);
4686 /* validate everything */
4687 ret
= RedrawWindow( hwnd
, NULL
, NULL
, RDW_VALIDATE
);
4688 ok(ret
, "RedrawWindow returned %d instead of TRUE\n", ret
);
4689 check_update_rgn( hwnd
, 0 );
4691 /* test empty region */
4692 SetRectRgn( hrgn
, 10, 10, 10, 15 );
4693 ret
= RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
);
4694 ok(ret
, "RedrawWindow returned %d instead of TRUE\n", ret
);
4695 check_update_rgn( hwnd
, 0 );
4696 /* test empty rect */
4697 SetRect( &rect
, 10, 10, 10, 15 );
4698 ret
= RedrawWindow( hwnd
, &rect
, NULL
, RDW_INVALIDATE
);
4699 ok(ret
, "RedrawWindow returned %d instead of TRUE\n", ret
);
4700 check_update_rgn( hwnd
, 0 );
4702 /* flush pending messages */
4703 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
4706 GetClientRect( hwnd
, &rect
);
4707 SetRectRgn( hrgn
, 0, 0, rect
.right
- rect
.left
, rect
.bottom
- rect
.top
);
4708 /* MSDN: if hwnd parameter is NULL, InvalidateRect invalidates and redraws
4709 * all windows and sends WM_ERASEBKGND and WM_NCPAINT.
4711 trace("testing InvalidateRect(0, NULL, FALSE)\n");
4712 SetRectEmpty( &rect
);
4713 ok(InvalidateRect(0, &rect
, FALSE
), "InvalidateRect(0, &rc, FALSE) should fail\n");
4714 check_update_rgn( hwnd
, hrgn
);
4715 ok_sequence( WmInvalidateErase
, "InvalidateErase", FALSE
);
4716 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
4717 ok_sequence( WmPaint
, "Paint", FALSE
);
4718 RedrawWindow( hwnd
, NULL
, NULL
, RDW_VALIDATE
);
4719 check_update_rgn( hwnd
, 0 );
4721 /* MSDN: if hwnd parameter is NULL, ValidateRect invalidates and redraws
4722 * all windows and sends WM_ERASEBKGND and WM_NCPAINT.
4724 trace("testing ValidateRect(0, NULL)\n");
4725 SetRectEmpty( &rect
);
4726 ok(ValidateRect(0, &rect
), "ValidateRect(0, &rc) should not fail\n");
4727 check_update_rgn( hwnd
, hrgn
);
4728 ok_sequence( WmInvalidateErase
, "InvalidateErase", FALSE
);
4729 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
4730 ok_sequence( WmPaint
, "Paint", FALSE
);
4731 RedrawWindow( hwnd
, NULL
, NULL
, RDW_VALIDATE
);
4732 check_update_rgn( hwnd
, 0 );
4734 trace("testing InvalidateRgn(0, NULL, FALSE)\n");
4735 SetLastError(0xdeadbeef);
4736 ok(!InvalidateRgn(0, NULL
, FALSE
), "InvalidateRgn(0, NULL, FALSE) should fail\n");
4737 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
, "wrong error code %d\n", GetLastError());
4738 check_update_rgn( hwnd
, 0 );
4739 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
4740 ok_sequence( WmEmptySeq
, "WmEmptySeq", FALSE
);
4742 trace("testing ValidateRgn(0, NULL)\n");
4743 SetLastError(0xdeadbeef);
4744 ok(!ValidateRgn(0, NULL
), "ValidateRgn(0, NULL) should fail\n");
4745 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
, "wrong error code %d\n", GetLastError());
4746 check_update_rgn( hwnd
, 0 );
4747 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
4748 ok_sequence( WmEmptySeq
, "WmEmptySeq", FALSE
);
4750 /* now with frame */
4751 SetRectRgn( hrgn
, -5, -5, 20, 20 );
4753 /* flush pending messages */
4754 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
4757 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_FRAME
);
4758 ok_sequence( WmEmptySeq
, "EmptySeq", FALSE
);
4760 SetRectRgn( hrgn
, 0, 0, 20, 20 ); /* GetUpdateRgn clips to client area */
4761 check_update_rgn( hwnd
, hrgn
);
4764 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASENOW
);
4765 ok_sequence( WmInvalidateRgn
, "InvalidateRgn", FALSE
);
4768 RedrawWindow( hwnd
, NULL
, NULL
, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASENOW
);
4769 ok_sequence( WmInvalidateFull
, "InvalidateFull", FALSE
);
4771 GetClientRect( hwnd
, &rect
);
4772 SetRectRgn( hrgn
, rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
4773 check_update_rgn( hwnd
, hrgn
);
4776 RedrawWindow( hwnd
, NULL
, NULL
, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASE
| RDW_ERASENOW
);
4777 ok_sequence( WmInvalidateErase
, "InvalidateErase", FALSE
);
4780 RedrawWindow( hwnd
, NULL
, NULL
, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASENOW
| RDW_UPDATENOW
);
4781 ok_sequence( WmInvalidatePaint
, "InvalidatePaint", FALSE
);
4782 check_update_rgn( hwnd
, 0 );
4785 RedrawWindow( hwnd
, NULL
, NULL
, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASE
| RDW_UPDATENOW
);
4786 ok_sequence( WmInvalidateErasePaint
, "InvalidateErasePaint", FALSE
);
4787 check_update_rgn( hwnd
, 0 );
4790 SetRectRgn( hrgn
, 0, 0, 100, 100 );
4791 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
);
4792 SetRectRgn( hrgn
, 0, 0, 50, 100 );
4793 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_VALIDATE
);
4794 SetRectRgn( hrgn
, 50, 0, 100, 100 );
4795 check_update_rgn( hwnd
, hrgn
);
4796 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_VALIDATE
| RDW_ERASENOW
);
4797 ok_sequence( WmEmptySeq
, "EmptySeq", FALSE
); /* must not generate messages, everything is valid */
4798 check_update_rgn( hwnd
, 0 );
4801 SetRectRgn( hrgn
, 0, 0, 100, 100 );
4802 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_ERASE
);
4803 SetRectRgn( hrgn
, 0, 0, 100, 50 );
4804 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_VALIDATE
| RDW_ERASENOW
);
4805 ok_sequence( WmErase
, "Erase", FALSE
);
4806 SetRectRgn( hrgn
, 0, 50, 100, 100 );
4807 check_update_rgn( hwnd
, hrgn
);
4810 SetRectRgn( hrgn
, 0, 0, 100, 100 );
4811 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_ERASE
);
4812 SetRectRgn( hrgn
, 0, 0, 50, 50 );
4813 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_VALIDATE
| RDW_NOERASE
| RDW_UPDATENOW
);
4814 ok_sequence( WmPaint
, "Paint", FALSE
);
4817 SetRectRgn( hrgn
, -4, -4, -2, -2 );
4818 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_FRAME
);
4819 SetRectRgn( hrgn
, -200, -200, -198, -198 );
4820 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_VALIDATE
| RDW_NOFRAME
| RDW_ERASENOW
);
4821 ok_sequence( WmEmptySeq
, "EmptySeq", FALSE
);
4824 SetRectRgn( hrgn
, -4, -4, -2, -2 );
4825 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_FRAME
);
4826 SetRectRgn( hrgn
, -4, -4, -3, -3 );
4827 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_VALIDATE
| RDW_NOFRAME
);
4828 SetRectRgn( hrgn
, 0, 0, 1, 1 );
4829 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_UPDATENOW
);
4830 ok_sequence( WmPaint
, "Paint", FALSE
);
4833 SetRectRgn( hrgn
, -4, -4, -1, -1 );
4834 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_FRAME
);
4835 RedrawWindow( hwnd
, NULL
, 0, RDW_ERASENOW
);
4836 /* make sure no WM_PAINT was generated */
4837 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
4838 ok_sequence( WmInvalidateRgn
, "InvalidateRgn", FALSE
);
4841 SetRectRgn( hrgn
, -4, -4, -1, -1 );
4842 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_FRAME
);
4843 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
))
4845 if (msg
.hwnd
== hwnd
&& msg
.message
== WM_PAINT
)
4847 /* GetUpdateRgn must return empty region since only nonclient area is invalidated */
4848 INT ret
= GetUpdateRgn( hwnd
, hrgn
, FALSE
);
4849 ok( ret
== NULLREGION
, "Invalid GetUpdateRgn result %d\n", ret
);
4850 ret
= GetUpdateRect( hwnd
, &rect
, FALSE
);
4851 ok( ret
, "Invalid GetUpdateRect result %d\n", ret
);
4852 /* this will send WM_NCPAINT and validate the non client area */
4853 ret
= GetUpdateRect( hwnd
, &rect
, TRUE
);
4854 ok( !ret
, "Invalid GetUpdateRect result %d\n", ret
);
4856 DispatchMessage( &msg
);
4858 ok_sequence( WmGetUpdateRect
, "GetUpdateRect", FALSE
);
4860 DestroyWindow( hwnd
);
4862 /* now test with a child window */
4864 hparent
= CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW
,
4865 100, 100, 200, 200, 0, 0, 0, NULL
);
4866 ok (hparent
!= 0, "Failed to create parent window\n");
4868 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
| WS_VISIBLE
| WS_BORDER
,
4869 10, 10, 100, 100, hparent
, 0, 0, NULL
);
4870 ok (hchild
!= 0, "Failed to create child window\n");
4872 ShowWindow( hparent
, SW_SHOW
);
4873 UpdateWindow( hparent
);
4874 UpdateWindow( hchild
);
4877 log_all_parent_messages
++;
4879 SetRect( &rect
, 0, 0, 50, 50 );
4880 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
4881 RedrawWindow( hparent
, NULL
, 0, RDW_ERASENOW
| RDW_ALLCHILDREN
);
4882 ok_sequence( WmInvalidateParentChild
, "InvalidateParentChild", FALSE
);
4884 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
4886 MapWindowPoints( hchild
, hparent
, &pt
, 1 );
4887 SetRectRgn( hrgn
, 0, 0, 50 - pt
.x
, 50 - pt
.y
);
4888 check_update_rgn( hchild
, hrgn
);
4889 SetRectRgn( hrgn
, 0, 0, 50, 50 );
4890 check_update_rgn( hparent
, hrgn
);
4891 RedrawWindow( hparent
, NULL
, 0, RDW_ERASENOW
);
4892 ok_sequence( WmInvalidateParent
, "InvalidateParent", FALSE
);
4893 RedrawWindow( hchild
, NULL
, 0, RDW_ERASENOW
);
4894 ok_sequence( WmEmptySeq
, "EraseNow child", FALSE
);
4896 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
4897 ok_sequence( WmParentPaintNc
, "WmParentPaintNc", FALSE
);
4899 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
| RDW_ALLCHILDREN
);
4900 RedrawWindow( hparent
, NULL
, 0, RDW_ERASENOW
);
4901 ok_sequence( WmInvalidateParent
, "InvalidateParent2", FALSE
);
4902 RedrawWindow( hchild
, NULL
, 0, RDW_ERASENOW
);
4903 ok_sequence( WmEmptySeq
, "EraseNow child", FALSE
);
4905 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
);
4906 RedrawWindow( hparent
, NULL
, 0, RDW_ERASENOW
| RDW_ALLCHILDREN
);
4907 ok_sequence( WmInvalidateParentChild2
, "InvalidateParentChild2", FALSE
);
4909 SetWindowLong( hparent
, GWL_STYLE
, GetWindowLong(hparent
,GWL_STYLE
) | WS_CLIPCHILDREN
);
4911 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
| RDW_ALLCHILDREN
);
4912 RedrawWindow( hparent
, NULL
, 0, RDW_ERASENOW
);
4913 ok_sequence( WmInvalidateParentChild
, "InvalidateParentChild3", FALSE
);
4915 /* flush all paint messages */
4916 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
4919 /* RDW_UPDATENOW on child with WS_CLIPCHILDREN doesn't change corresponding parent area */
4920 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
| RDW_ALLCHILDREN
);
4921 SetRectRgn( hrgn
, 0, 0, 50, 50 );
4922 check_update_rgn( hparent
, hrgn
);
4923 RedrawWindow( hchild
, NULL
, 0, RDW_UPDATENOW
);
4924 ok_sequence( WmInvalidateErasePaint2
, "WmInvalidateErasePaint2", FALSE
);
4925 SetRectRgn( hrgn
, 0, 0, 50, 50 );
4926 check_update_rgn( hparent
, hrgn
);
4928 /* flush all paint messages */
4929 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
4930 SetWindowLong( hparent
, GWL_STYLE
, GetWindowLong(hparent
,GWL_STYLE
) & ~WS_CLIPCHILDREN
);
4933 /* RDW_UPDATENOW on child without WS_CLIPCHILDREN will validate corresponding parent area */
4934 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
4935 SetRectRgn( hrgn
, 0, 0, 50, 50 );
4936 check_update_rgn( hparent
, hrgn
);
4937 RedrawWindow( hchild
, NULL
, 0, RDW_UPDATENOW
);
4938 ok_sequence( WmInvalidateErasePaint2
, "WmInvalidateErasePaint2", FALSE
);
4939 SetRectRgn( hrgn2
, 10, 10, 50, 50 );
4940 CombineRgn( hrgn
, hrgn
, hrgn2
, RGN_DIFF
);
4941 check_update_rgn( hparent
, hrgn
);
4942 /* flush all paint messages */
4943 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
4946 /* same as above but parent gets completely validated */
4947 SetRect( &rect
, 20, 20, 30, 30 );
4948 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
4949 SetRectRgn( hrgn
, 20, 20, 30, 30 );
4950 check_update_rgn( hparent
, hrgn
);
4951 RedrawWindow( hchild
, NULL
, 0, RDW_UPDATENOW
);
4952 ok_sequence( WmInvalidateErasePaint2
, "WmInvalidateErasePaint2", FALSE
);
4953 check_update_rgn( hparent
, 0 ); /* no update region */
4954 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
4955 ok_sequence( WmEmptySeq
, "WmEmpty", FALSE
); /* and no paint messages */
4957 /* make sure RDW_VALIDATE on child doesn't have the same effect */
4959 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
4960 SetRectRgn( hrgn
, 20, 20, 30, 30 );
4961 check_update_rgn( hparent
, hrgn
);
4962 RedrawWindow( hchild
, NULL
, 0, RDW_VALIDATE
| RDW_NOERASE
);
4963 SetRectRgn( hrgn
, 20, 20, 30, 30 );
4964 check_update_rgn( hparent
, hrgn
);
4966 /* same as above but normal WM_PAINT doesn't validate parent */
4968 SetRect( &rect
, 20, 20, 30, 30 );
4969 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
4970 SetRectRgn( hrgn
, 20, 20, 30, 30 );
4971 check_update_rgn( hparent
, hrgn
);
4972 /* no WM_PAINT in child while parent still pending */
4973 while (PeekMessage( &msg
, hchild
, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
4974 ok_sequence( WmEmptySeq
, "No WM_PAINT", FALSE
);
4975 while (PeekMessage( &msg
, hparent
, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
4976 ok_sequence( WmParentErasePaint
, "WmParentErasePaint", FALSE
);
4979 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
4980 /* no WM_PAINT in child while parent still pending */
4981 while (PeekMessage( &msg
, hchild
, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
4982 ok_sequence( WmEmptySeq
, "No WM_PAINT", FALSE
);
4983 RedrawWindow( hparent
, &rect
, 0, RDW_VALIDATE
| RDW_NOERASE
| RDW_NOCHILDREN
);
4984 /* now that parent is valid child should get WM_PAINT */
4985 while (PeekMessage( &msg
, hchild
, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
4986 ok_sequence( WmInvalidateErasePaint2
, "WmInvalidateErasePaint2", FALSE
);
4987 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
4988 ok_sequence( WmEmptySeq
, "No other message", FALSE
);
4990 /* same thing with WS_CLIPCHILDREN in parent */
4992 SetWindowLong( hparent
, GWL_STYLE
, GetWindowLong(hparent
,GWL_STYLE
) | WS_CLIPCHILDREN
);
4993 ok_sequence( WmSetParentStyle
, "WmSetParentStyle", FALSE
);
4994 /* changing style invalidates non client area, but we need to invalidate something else to see it */
4995 RedrawWindow( hparent
, &rect
, 0, RDW_UPDATENOW
);
4996 ok_sequence( WmEmptySeq
, "No message", FALSE
);
4997 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_UPDATENOW
);
4998 ok_sequence( WmParentOnlyNcPaint
, "WmParentOnlyNcPaint", FALSE
);
5001 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_ALLCHILDREN
);
5002 SetRectRgn( hrgn
, 20, 20, 30, 30 );
5003 check_update_rgn( hparent
, hrgn
);
5004 /* no WM_PAINT in child while parent still pending */
5005 while (PeekMessage( &msg
, hchild
, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
5006 ok_sequence( WmEmptySeq
, "No WM_PAINT", FALSE
);
5007 /* WM_PAINT in parent first */
5008 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
5009 ok_sequence( WmParentPaintNc
, "WmParentPaintNc2", FALSE
);
5011 /* no RDW_ERASE in parent still causes RDW_ERASE and RDW_FRAME in child */
5013 SetRect( &rect
, 0, 0, 30, 30 );
5014 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ALLCHILDREN
);
5015 SetRectRgn( hrgn
, 0, 0, 30, 30 );
5016 check_update_rgn( hparent
, hrgn
);
5017 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
5018 ok_sequence( WmParentPaintNc
, "WmParentPaintNc3", FALSE
);
5020 /* validate doesn't cause RDW_NOERASE or RDW_NOFRAME in child */
5022 SetRect( &rect
, -10, 0, 30, 30 );
5023 RedrawWindow( hchild
, &rect
, 0, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASE
);
5024 SetRect( &rect
, 0, 0, 20, 20 );
5025 RedrawWindow( hparent
, &rect
, 0, RDW_VALIDATE
| RDW_ALLCHILDREN
);
5026 RedrawWindow( hparent
, NULL
, 0, RDW_UPDATENOW
);
5027 ok_sequence( WmChildPaintNc
, "WmChildPaintNc", FALSE
);
5029 /* validate doesn't cause RDW_NOERASE or RDW_NOFRAME in child */
5031 SetRect( &rect
, -10, 0, 30, 30 );
5032 RedrawWindow( hchild
, &rect
, 0, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASE
);
5033 SetRect( &rect
, 0, 0, 100, 100 );
5034 RedrawWindow( hparent
, &rect
, 0, RDW_VALIDATE
| RDW_ALLCHILDREN
);
5035 RedrawWindow( hparent
, NULL
, 0, RDW_UPDATENOW
);
5036 ok_sequence( WmEmptySeq
, "WmChildPaintNc2", FALSE
);
5037 RedrawWindow( hparent
, NULL
, 0, RDW_ERASENOW
);
5038 ok_sequence( WmEmptySeq
, "WmChildPaintNc3", FALSE
);
5040 /* test RDW_INTERNALPAINT behavior */
5043 RedrawWindow( hparent
, NULL
, 0, RDW_INTERNALPAINT
| RDW_NOCHILDREN
);
5044 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
5045 ok_sequence( WmParentOnlyPaint
, "WmParentOnlyPaint", FALSE
);
5047 RedrawWindow( hparent
, NULL
, 0, RDW_INTERNALPAINT
| RDW_ALLCHILDREN
);
5048 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
5049 ok_sequence( WmParentPaint
, "WmParentPaint", FALSE
);
5051 RedrawWindow( hparent
, NULL
, 0, RDW_INTERNALPAINT
);
5052 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
5053 ok_sequence( WmParentOnlyPaint
, "WmParentOnlyPaint", FALSE
);
5055 assert( GetWindowLong(hparent
, GWL_STYLE
) & WS_CLIPCHILDREN
);
5056 UpdateWindow( hparent
);
5057 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
5059 trace("testing SWP_FRAMECHANGED on parent with WS_CLIPCHILDREN\n");
5060 RedrawWindow( hchild
, NULL
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
5061 SetWindowPos( hparent
, 0, 0, 0, 0, 0, SWP_NOSIZE
| SWP_NOMOVE
|
5062 SWP_NOACTIVATE
| SWP_NOZORDER
| SWP_FRAMECHANGED
);
5063 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
5064 ok_sequence(WmSWP_FrameChanged_clip
, "SetWindowPos:FrameChanged_clip", FALSE
);
5066 UpdateWindow( hparent
);
5067 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
5069 trace("testing SWP_FRAMECHANGED|SWP_DEFERERASE on parent with WS_CLIPCHILDREN\n");
5070 RedrawWindow( hchild
, NULL
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
5071 SetWindowPos( hparent
, 0, 0, 0, 0, 0, SWP_NOSIZE
| SWP_NOMOVE
| SWP_DEFERERASE
|
5072 SWP_NOACTIVATE
| SWP_NOZORDER
| SWP_FRAMECHANGED
);
5073 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
5074 ok_sequence(WmSWP_FrameChangedDeferErase
, "SetWindowPos:FrameChangedDeferErase", FALSE
);
5076 SetWindowLong( hparent
, GWL_STYLE
, GetWindowLong(hparent
,GWL_STYLE
) & ~WS_CLIPCHILDREN
);
5077 ok_sequence( WmSetParentStyle
, "WmSetParentStyle", FALSE
);
5078 RedrawWindow( hparent
, NULL
, 0, RDW_INTERNALPAINT
);
5079 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
5080 ok_sequence( WmParentPaint
, "WmParentPaint", FALSE
);
5082 assert( !(GetWindowLong(hparent
, GWL_STYLE
) & WS_CLIPCHILDREN
) );
5083 UpdateWindow( hparent
);
5084 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
5086 trace("testing SWP_FRAMECHANGED on parent without WS_CLIPCHILDREN\n");
5087 RedrawWindow( hchild
, NULL
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
5088 SetWindowPos( hparent
, 0, 0, 0, 0, 0, SWP_NOSIZE
| SWP_NOMOVE
|
5089 SWP_NOACTIVATE
| SWP_NOZORDER
| SWP_FRAMECHANGED
);
5090 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
5091 ok_sequence(WmSWP_FrameChanged_noclip
, "SetWindowPos:FrameChanged_noclip", FALSE
);
5093 UpdateWindow( hparent
);
5094 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
5096 trace("testing SWP_FRAMECHANGED|SWP_DEFERERASE on parent without WS_CLIPCHILDREN\n");
5097 RedrawWindow( hchild
, NULL
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
5098 SetWindowPos( hparent
, 0, 0, 0, 0, 0, SWP_NOSIZE
| SWP_NOMOVE
| SWP_DEFERERASE
|
5099 SWP_NOACTIVATE
| SWP_NOZORDER
| SWP_FRAMECHANGED
);
5100 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
5101 ok_sequence(WmSWP_FrameChangedDeferErase
, "SetWindowPos:FrameChangedDeferErase", FALSE
);
5103 log_all_parent_messages
--;
5104 DestroyWindow( hparent
);
5105 ok(!IsWindow(hchild
), "child must be destroyed with its parent\n");
5107 DeleteObject( hrgn
);
5108 DeleteObject( hrgn2
);
5117 static DWORD WINAPI
thread_proc(void *param
)
5120 struct wnd_event
*wnd_event
= (struct wnd_event
*)param
;
5122 wnd_event
->hwnd
= CreateWindowExA(0, "TestWindowClass", "window caption text", WS_OVERLAPPEDWINDOW
,
5123 100, 100, 200, 200, 0, 0, 0, NULL
);
5124 ok(wnd_event
->hwnd
!= 0, "Failed to create overlapped window\n");
5126 SetEvent(wnd_event
->event
);
5128 while (GetMessage(&msg
, 0, 0, 0))
5130 TranslateMessage(&msg
);
5131 DispatchMessage(&msg
);
5134 ok(IsWindow(wnd_event
->hwnd
), "window should still exist\n");
5139 static void test_interthread_messages(void)
5146 int len
, expected_len
;
5147 struct wnd_event wnd_event
;
5150 wnd_event
.event
= CreateEventW(NULL
, 0, 0, NULL
);
5151 if (!wnd_event
.event
)
5153 trace("skipping interthread message test under win9x\n");
5157 hThread
= CreateThread(NULL
, 0, thread_proc
, &wnd_event
, 0, &tid
);
5158 ok(hThread
!= NULL
, "CreateThread failed, error %d\n", GetLastError());
5160 ok(WaitForSingleObject(wnd_event
.event
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
5162 CloseHandle(wnd_event
.event
);
5164 SetLastError(0xdeadbeef);
5165 ok(!DestroyWindow(wnd_event
.hwnd
), "DestroyWindow succeded\n");
5166 ok(GetLastError() == ERROR_ACCESS_DENIED
, "wrong error code %d\n", GetLastError());
5168 proc
= (WNDPROC
)GetWindowLongPtrA(wnd_event
.hwnd
, GWLP_WNDPROC
);
5169 ok(proc
!= NULL
, "GetWindowLongPtrA(GWLP_WNDPROC) error %d\n", GetLastError());
5171 expected_len
= lstrlenA("window caption text");
5172 memset(buf
, 0, sizeof(buf
));
5173 SetLastError(0xdeadbeef);
5174 len
= CallWindowProcA(proc
, wnd_event
.hwnd
, WM_GETTEXT
, sizeof(buf
), (LPARAM
)buf
);
5175 ok(len
== expected_len
, "CallWindowProcA(WM_GETTEXT) error %d, len %d, expected len %d\n", GetLastError(), len
, expected_len
);
5176 ok(!lstrcmpA(buf
, "window caption text"), "window text mismatch\n");
5178 msg
.hwnd
= wnd_event
.hwnd
;
5179 msg
.message
= WM_GETTEXT
;
5180 msg
.wParam
= sizeof(buf
);
5181 msg
.lParam
= (LPARAM
)buf
;
5182 memset(buf
, 0, sizeof(buf
));
5183 SetLastError(0xdeadbeef);
5184 len
= DispatchMessageA(&msg
);
5185 ok(!len
&& GetLastError() == ERROR_MESSAGE_SYNC_ONLY
,
5186 "DispatchMessageA(WM_GETTEXT) succeded on another thread window: ret %d, error %d\n", len
, GetLastError());
5188 /* the following test causes an exception in user.exe under win9x */
5189 msg
.hwnd
= wnd_event
.hwnd
;
5190 msg
.message
= WM_TIMER
;
5192 msg
.lParam
= GetWindowLongPtrA(wnd_event
.hwnd
, GWLP_WNDPROC
);
5193 SetLastError(0xdeadbeef);
5194 len
= DispatchMessageA(&msg
);
5195 ok(!len
&& GetLastError() == 0xdeadbeef,
5196 "DispatchMessageA(WM_TIMER) failed on another thread window: ret %d, error %d\n", len
, GetLastError());
5198 ret
= PostMessageA(wnd_event
.hwnd
, WM_QUIT
, 0, 0);
5199 ok( ret
, "PostMessageA(WM_QUIT) error %d\n", GetLastError());
5201 ok(WaitForSingleObject(hThread
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
5202 CloseHandle(hThread
);
5204 ok(!IsWindow(wnd_event
.hwnd
), "window should be destroyed on thread exit\n");
5208 static const struct message WmVkN
[] = {
5209 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 1 }, /* XP */
5210 { WM_KEYDOWN
, wparam
|lparam
, 'N', 1 },
5211 { WM_KEYDOWN
, sent
|wparam
|lparam
, 'N', 1 },
5212 { WM_CHAR
, wparam
|lparam
, 'n', 1 },
5213 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1002,1), 0 },
5214 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xc0000001 }, /* XP */
5215 { WM_KEYUP
, wparam
|lparam
, 'N', 0xc0000001 },
5216 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xc0000001 },
5219 static const struct message WmShiftVkN
[] = {
5220 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 1 }, /* XP */
5221 { WM_KEYDOWN
, wparam
|lparam
, VK_SHIFT
, 1 },
5222 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_SHIFT
, 1 },
5223 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 1 }, /* XP */
5224 { WM_KEYDOWN
, wparam
|lparam
, 'N', 1 },
5225 { WM_KEYDOWN
, sent
|wparam
|lparam
, 'N', 1 },
5226 { WM_CHAR
, wparam
|lparam
, 'N', 1 },
5227 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1001,1), 0 },
5228 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xc0000001 }, /* XP */
5229 { WM_KEYUP
, wparam
|lparam
, 'N', 0xc0000001 },
5230 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xc0000001 },
5231 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 0xc0000001 }, /* XP */
5232 { WM_KEYUP
, wparam
|lparam
, VK_SHIFT
, 0xc0000001 },
5233 { WM_KEYUP
, sent
|wparam
|lparam
, VK_SHIFT
, 0xc0000001 },
5236 static const struct message WmCtrlVkN
[] = {
5237 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 1 }, /* XP */
5238 { WM_KEYDOWN
, wparam
|lparam
, VK_CONTROL
, 1 },
5239 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_CONTROL
, 1 },
5240 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 1 }, /* XP */
5241 { WM_KEYDOWN
, wparam
|lparam
, 'N', 1 },
5242 { WM_KEYDOWN
, sent
|wparam
|lparam
, 'N', 1 },
5243 { WM_CHAR
, wparam
|lparam
, 0x000e, 1 },
5244 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1000,1), 0 },
5245 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xc0000001 }, /* XP */
5246 { WM_KEYUP
, wparam
|lparam
, 'N', 0xc0000001 },
5247 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xc0000001 },
5248 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 0xc0000001 }, /* XP */
5249 { WM_KEYUP
, wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
5250 { WM_KEYUP
, sent
|wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
5253 static const struct message WmCtrlVkN_2
[] = {
5254 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 1 }, /* XP */
5255 { WM_KEYDOWN
, wparam
|lparam
, VK_CONTROL
, 1 },
5256 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_CONTROL
, 1 },
5257 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 1 }, /* XP */
5258 { WM_KEYDOWN
, wparam
|lparam
, 'N', 1 },
5259 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1000,1), 0 },
5260 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xc0000001 }, /* XP */
5261 { WM_KEYUP
, wparam
|lparam
, 'N', 0xc0000001 },
5262 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xc0000001 },
5263 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 0xc0000001 }, /* XP */
5264 { WM_KEYUP
, wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
5265 { WM_KEYUP
, sent
|wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
5268 static const struct message WmAltVkN
[] = {
5269 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 }, /* XP */
5270 { WM_SYSKEYDOWN
, wparam
|lparam
, VK_MENU
, 0x20000001 },
5271 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
5272 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0x20000001 }, /* XP */
5273 { WM_SYSKEYDOWN
, wparam
|lparam
, 'N', 0x20000001 },
5274 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, 'N', 0x20000001 },
5275 { WM_SYSCHAR
, wparam
|lparam
, 'n', 0x20000001 },
5276 { WM_SYSCHAR
, sent
|wparam
|lparam
, 'n', 0x20000001 },
5277 { WM_SYSCOMMAND
, sent
|defwinproc
|wparam
|lparam
, SC_KEYMENU
, 'n' },
5278 { HCBT_SYSCOMMAND
, hook
},
5279 { WM_ENTERMENULOOP
, sent
|defwinproc
|wparam
|lparam
, 0, 0 },
5280 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
5281 { 0x00AE, sent
|defwinproc
|optional
}, /* XP */
5282 { WM_GETTEXT
, sent
|defwinproc
|optional
}, /* XP */
5283 { WM_INITMENU
, sent
|defwinproc
},
5284 { EVENT_SYSTEM_MENUSTART
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 0 },
5285 { WM_MENUCHAR
, sent
|defwinproc
|wparam
, MAKEWPARAM('n',MF_SYSMENU
) },
5286 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, 0, 0 },
5287 { WM_CAPTURECHANGED
, sent
|defwinproc
},
5288 { WM_MENUSELECT
, sent
|defwinproc
|wparam
, MAKEWPARAM(0,0xffff) },
5289 { EVENT_SYSTEM_MENUEND
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 0 },
5290 { WM_EXITMENULOOP
, sent
|defwinproc
},
5291 { WM_MENUSELECT
, sent
|defwinproc
|wparam
|optional
, MAKEWPARAM(0,0xffff) }, /* Win95 bug */
5292 { WM_EXITMENULOOP
, sent
|defwinproc
|optional
}, /* Win95 bug */
5293 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xe0000001 }, /* XP */
5294 { WM_SYSKEYUP
, wparam
|lparam
, 'N', 0xe0000001 },
5295 { WM_SYSKEYUP
, sent
|wparam
|lparam
, 'N', 0xe0000001 },
5296 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xc0000001 }, /* XP */
5297 { WM_KEYUP
, wparam
|lparam
, VK_MENU
, 0xc0000001 },
5298 { WM_KEYUP
, sent
|wparam
|lparam
, VK_MENU
, 0xc0000001 },
5301 static const struct message WmAltVkN_2
[] = {
5302 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 }, /* XP */
5303 { WM_SYSKEYDOWN
, wparam
|lparam
, VK_MENU
, 0x20000001 },
5304 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
5305 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0x20000001 }, /* XP */
5306 { WM_SYSKEYDOWN
, wparam
|lparam
, 'N', 0x20000001 },
5307 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1003,1), 0 },
5308 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xe0000001 }, /* XP */
5309 { WM_SYSKEYUP
, wparam
|lparam
, 'N', 0xe0000001 },
5310 { WM_SYSKEYUP
, sent
|wparam
|lparam
, 'N', 0xe0000001 },
5311 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xc0000001 }, /* XP */
5312 { WM_KEYUP
, wparam
|lparam
, VK_MENU
, 0xc0000001 },
5313 { WM_KEYUP
, sent
|wparam
|lparam
, VK_MENU
, 0xc0000001 },
5316 static const struct message WmCtrlAltVkN
[] = {
5317 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 1 }, /* XP */
5318 { WM_KEYDOWN
, wparam
|lparam
, VK_CONTROL
, 1 },
5319 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_CONTROL
, 1 },
5320 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 }, /* XP */
5321 { WM_KEYDOWN
, wparam
|lparam
, VK_MENU
, 0x20000001 },
5322 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
5323 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0x20000001 }, /* XP */
5324 { WM_KEYDOWN
, wparam
|lparam
, 'N', 0x20000001 },
5325 { WM_KEYDOWN
, sent
|wparam
|lparam
, 'N', 0x20000001 },
5326 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xe0000001 }, /* XP */
5327 { WM_KEYUP
, wparam
|lparam
, 'N', 0xe0000001 },
5328 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xe0000001 },
5329 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xc0000001 }, /* XP */
5330 { WM_KEYUP
, wparam
|lparam
, VK_MENU
, 0xc0000001 },
5331 { WM_KEYUP
, sent
|wparam
|lparam
, VK_MENU
, 0xc0000001 },
5332 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 0xc0000001 }, /* XP */
5333 { WM_KEYUP
, wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
5334 { WM_KEYUP
, sent
|wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
5337 static const struct message WmCtrlShiftVkN
[] = {
5338 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 1 }, /* XP */
5339 { WM_KEYDOWN
, wparam
|lparam
, VK_CONTROL
, 1 },
5340 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_CONTROL
, 1 },
5341 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 1 }, /* XP */
5342 { WM_KEYDOWN
, wparam
|lparam
, VK_SHIFT
, 1 },
5343 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_SHIFT
, 1 },
5344 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 1 }, /* XP */
5345 { WM_KEYDOWN
, wparam
|lparam
, 'N', 1 },
5346 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1004,1), 0 },
5347 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xc0000001 }, /* XP */
5348 { WM_KEYUP
, wparam
|lparam
, 'N', 0xc0000001 },
5349 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xc0000001 },
5350 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 0xc0000001 }, /* XP */
5351 { WM_KEYUP
, wparam
|lparam
, VK_SHIFT
, 0xc0000001 },
5352 { WM_KEYUP
, sent
|wparam
|lparam
, VK_SHIFT
, 0xc0000001 },
5353 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 0xc0000001 }, /* XP */
5354 { WM_KEYUP
, wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
5355 { WM_KEYUP
, sent
|wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
5358 static const struct message WmCtrlAltShiftVkN
[] = {
5359 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 1 }, /* XP */
5360 { WM_KEYDOWN
, wparam
|lparam
, VK_CONTROL
, 1 },
5361 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_CONTROL
, 1 },
5362 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 }, /* XP */
5363 { WM_KEYDOWN
, wparam
|lparam
, VK_MENU
, 0x20000001 },
5364 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
5365 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 0x20000001 }, /* XP */
5366 { WM_KEYDOWN
, wparam
|lparam
, VK_SHIFT
, 0x20000001 },
5367 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_SHIFT
, 0x20000001 },
5368 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0x20000001 }, /* XP */
5369 { WM_KEYDOWN
, wparam
|lparam
, 'N', 0x20000001 },
5370 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1005,1), 0 },
5371 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xe0000001 }, /* XP */
5372 { WM_KEYUP
, wparam
|lparam
, 'N', 0xe0000001 },
5373 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xe0000001 },
5374 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 0xe0000001 }, /* XP */
5375 { WM_KEYUP
, wparam
|lparam
, VK_SHIFT
, 0xe0000001 },
5376 { WM_KEYUP
, sent
|wparam
|lparam
, VK_SHIFT
, 0xe0000001 },
5377 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xc0000001 }, /* XP */
5378 { WM_KEYUP
, wparam
|lparam
, VK_MENU
, 0xc0000001 },
5379 { WM_KEYUP
, sent
|wparam
|lparam
, VK_MENU
, 0xc0000001 },
5380 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 0xc0000001 }, /* XP */
5381 { WM_KEYUP
, wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
5382 { WM_KEYUP
, sent
|wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
5385 static const struct message WmAltPressRelease
[] = {
5386 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 }, /* XP */
5387 { WM_SYSKEYDOWN
, wparam
|lparam
, VK_MENU
, 0x20000001 },
5388 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
5389 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xc0000001 }, /* XP */
5390 { WM_SYSKEYUP
, wparam
|lparam
, VK_MENU
, 0xc0000001 },
5391 { WM_SYSKEYUP
, sent
|wparam
|lparam
, VK_MENU
, 0xc0000001 },
5392 { WM_SYSCOMMAND
, sent
|defwinproc
|wparam
|lparam
, SC_KEYMENU
, 0 },
5393 { HCBT_SYSCOMMAND
, hook
},
5394 { WM_ENTERMENULOOP
, sent
|defwinproc
|wparam
|lparam
, 0, 0 },
5395 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
5396 { WM_INITMENU
, sent
|defwinproc
},
5397 { EVENT_SYSTEM_MENUSTART
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 0 },
5398 { WM_MENUSELECT
, sent
|defwinproc
|wparam
, MAKEWPARAM(0,MF_SYSMENU
|MF_POPUP
|MF_HILITE
) },
5399 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 1 },
5401 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x30000001 }, /* XP */
5403 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 0 },
5404 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, 0, 0, },
5405 { WM_CAPTURECHANGED
, sent
|defwinproc
},
5406 { WM_MENUSELECT
, sent
|defwinproc
|wparam
|optional
, MAKEWPARAM(0,0xffff) },
5407 { EVENT_SYSTEM_MENUEND
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 0 },
5408 { WM_EXITMENULOOP
, sent
|defwinproc
},
5409 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xc0000001 }, /* XP */
5410 { WM_SYSKEYUP
, wparam
|lparam
, VK_MENU
, 0xc0000001 },
5411 { WM_SYSKEYUP
, sent
|wparam
|lparam
, VK_MENU
, 0xc0000001 },
5414 static const struct message WmAltMouseButton
[] = {
5415 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 }, /* XP */
5416 { WM_SYSKEYDOWN
, wparam
|lparam
, VK_MENU
, 0x20000001 },
5417 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
5418 { WM_MOUSEMOVE
, wparam
|optional
, 0, 0 },
5419 { WM_MOUSEMOVE
, sent
|wparam
|optional
, 0, 0 },
5420 { WM_LBUTTONDOWN
, wparam
, MK_LBUTTON
, 0 },
5421 { WM_LBUTTONDOWN
, sent
|wparam
, MK_LBUTTON
, 0 },
5422 { WM_LBUTTONUP
, wparam
, 0, 0 },
5423 { WM_LBUTTONUP
, sent
|wparam
, 0, 0 },
5424 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xc0000001 }, /* XP */
5425 { WM_SYSKEYUP
, wparam
|lparam
, VK_MENU
, 0xc0000001 },
5426 { WM_SYSKEYUP
, sent
|wparam
|lparam
, VK_MENU
, 0xc0000001 },
5429 static const struct message WmF1Seq
[] = {
5430 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_F1
, 1 }, /* XP */
5431 { WM_KEYDOWN
, wparam
|lparam
, VK_F1
, 1 },
5432 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_F1
, 0x00000001 },
5433 { 0x4d, wparam
|lparam
, 0, 0 },
5434 { 0x4d, sent
|wparam
|lparam
, 0, 0 },
5435 { WM_HELP
, sent
|defwinproc
},
5436 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_F1
, 0xc0000001 }, /* XP */
5437 { WM_KEYUP
, wparam
|lparam
, VK_F1
, 0xc0000001 },
5438 { WM_KEYUP
, sent
|wparam
|lparam
, VK_F1
, 0xc0000001 },
5441 static const struct message WmVkAppsSeq
[] = {
5442 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_APPS
, 1 }, /* XP */
5443 { WM_KEYDOWN
, wparam
|lparam
, VK_APPS
, 1 },
5444 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_APPS
, 0x00000001 },
5445 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_APPS
, 0xc0000001 }, /* XP */
5446 { WM_KEYUP
, wparam
|lparam
, VK_APPS
, 0xc0000001 },
5447 { WM_KEYUP
, sent
|wparam
|lparam
, VK_APPS
, 0xc0000001 },
5448 { WM_CONTEXTMENU
, lparam
, /*hwnd*/0, (LPARAM
)-1 },
5449 { WM_CONTEXTMENU
, sent
|lparam
, /*hwnd*/0, (LPARAM
)-1 },
5453 static void pump_msg_loop(HWND hwnd
, HACCEL hAccel
)
5457 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
))
5459 struct message log_msg
;
5461 trace("accel: %p, %04x, %08x, %08lx\n", msg
.hwnd
, msg
.message
, msg
.wParam
, msg
.lParam
);
5463 /* ignore some unwanted messages */
5464 if (msg
.message
== WM_MOUSEMOVE
||
5465 msg
.message
== WM_GETICON
||
5466 msg
.message
== WM_DEVICECHANGE
)
5469 log_msg
.message
= msg
.message
;
5470 log_msg
.flags
= wparam
|lparam
;
5471 log_msg
.wParam
= msg
.wParam
;
5472 log_msg
.lParam
= msg
.lParam
;
5473 add_message(&log_msg
);
5475 if (!hAccel
|| !TranslateAccelerator(hwnd
, hAccel
, &msg
))
5477 TranslateMessage(&msg
);
5478 DispatchMessage(&msg
);
5483 static void test_accelerators(void)
5488 HWND hwnd
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
5489 100, 100, 200, 200, 0, 0, 0, NULL
);
5498 ok(GetFocus() == hwnd
, "wrong focus window %p\n", GetFocus());
5500 state
= GetKeyState(VK_SHIFT
);
5501 ok(!(state
& 0x8000), "wrong Shift state %04x\n", state
);
5502 state
= GetKeyState(VK_CAPITAL
);
5503 ok(state
== 0, "wrong CapsLock state %04x\n", state
);
5505 hAccel
= LoadAccelerators(GetModuleHandleA(0), MAKEINTRESOURCE(1));
5506 assert(hAccel
!= 0);
5508 pump_msg_loop(hwnd
, 0);
5511 trace("testing VK_N press/release\n");
5513 keybd_event('N', 0, 0, 0);
5514 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
5515 pump_msg_loop(hwnd
, hAccel
);
5516 ok_sequence(WmVkN
, "VK_N press/release", FALSE
);
5518 trace("testing Shift+VK_N press/release\n");
5520 keybd_event(VK_SHIFT
, 0, 0, 0);
5521 keybd_event('N', 0, 0, 0);
5522 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
5523 keybd_event(VK_SHIFT
, 0, KEYEVENTF_KEYUP
, 0);
5524 pump_msg_loop(hwnd
, hAccel
);
5525 ok_sequence(WmShiftVkN
, "Shift+VK_N press/release", FALSE
);
5527 trace("testing Ctrl+VK_N press/release\n");
5529 keybd_event(VK_CONTROL
, 0, 0, 0);
5530 keybd_event('N', 0, 0, 0);
5531 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
5532 keybd_event(VK_CONTROL
, 0, KEYEVENTF_KEYUP
, 0);
5533 pump_msg_loop(hwnd
, hAccel
);
5534 ok_sequence(WmCtrlVkN
, "Ctrl+VK_N press/release", FALSE
);
5536 trace("testing Alt+VK_N press/release\n");
5538 keybd_event(VK_MENU
, 0, 0, 0);
5539 keybd_event('N', 0, 0, 0);
5540 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
5541 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
5542 pump_msg_loop(hwnd
, hAccel
);
5543 ok_sequence(WmAltVkN
, "Alt+VK_N press/release", FALSE
);
5545 trace("testing Ctrl+Alt+VK_N press/release 1\n");
5547 keybd_event(VK_CONTROL
, 0, 0, 0);
5548 keybd_event(VK_MENU
, 0, 0, 0);
5549 keybd_event('N', 0, 0, 0);
5550 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
5551 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
5552 keybd_event(VK_CONTROL
, 0, KEYEVENTF_KEYUP
, 0);
5553 pump_msg_loop(hwnd
, hAccel
);
5554 ok_sequence(WmCtrlAltVkN
, "Ctrl+Alt+VK_N press/release 1", FALSE
);
5556 ret
= DestroyAcceleratorTable(hAccel
);
5557 ok( ret
, "DestroyAcceleratorTable error %d\n", GetLastError());
5559 hAccel
= LoadAccelerators(GetModuleHandleA(0), MAKEINTRESOURCE(2));
5560 assert(hAccel
!= 0);
5562 trace("testing VK_N press/release\n");
5564 keybd_event('N', 0, 0, 0);
5565 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
5566 pump_msg_loop(hwnd
, hAccel
);
5567 ok_sequence(WmVkN
, "VK_N press/release", FALSE
);
5569 trace("testing Shift+VK_N press/release\n");
5571 keybd_event(VK_SHIFT
, 0, 0, 0);
5572 keybd_event('N', 0, 0, 0);
5573 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
5574 keybd_event(VK_SHIFT
, 0, KEYEVENTF_KEYUP
, 0);
5575 pump_msg_loop(hwnd
, hAccel
);
5576 ok_sequence(WmShiftVkN
, "Shift+VK_N press/release", FALSE
);
5578 trace("testing Ctrl+VK_N press/release 2\n");
5580 keybd_event(VK_CONTROL
, 0, 0, 0);
5581 keybd_event('N', 0, 0, 0);
5582 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
5583 keybd_event(VK_CONTROL
, 0, KEYEVENTF_KEYUP
, 0);
5584 pump_msg_loop(hwnd
, hAccel
);
5585 ok_sequence(WmCtrlVkN_2
, "Ctrl+VK_N press/release 2", FALSE
);
5587 trace("testing Alt+VK_N press/release 2\n");
5589 keybd_event(VK_MENU
, 0, 0, 0);
5590 keybd_event('N', 0, 0, 0);
5591 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
5592 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
5593 pump_msg_loop(hwnd
, hAccel
);
5594 ok_sequence(WmAltVkN_2
, "Alt+VK_N press/release 2", FALSE
);
5596 trace("testing Ctrl+Alt+VK_N press/release 2\n");
5598 keybd_event(VK_CONTROL
, 0, 0, 0);
5599 keybd_event(VK_MENU
, 0, 0, 0);
5600 keybd_event('N', 0, 0, 0);
5601 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
5602 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
5603 keybd_event(VK_CONTROL
, 0, KEYEVENTF_KEYUP
, 0);
5604 pump_msg_loop(hwnd
, hAccel
);
5605 ok_sequence(WmCtrlAltVkN
, "Ctrl+Alt+VK_N press/release 2", FALSE
);
5607 trace("testing Ctrl+Shift+VK_N press/release\n");
5609 keybd_event(VK_CONTROL
, 0, 0, 0);
5610 keybd_event(VK_SHIFT
, 0, 0, 0);
5611 keybd_event('N', 0, 0, 0);
5612 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
5613 keybd_event(VK_SHIFT
, 0, KEYEVENTF_KEYUP
, 0);
5614 keybd_event(VK_CONTROL
, 0, KEYEVENTF_KEYUP
, 0);
5615 pump_msg_loop(hwnd
, hAccel
);
5616 ok_sequence(WmCtrlShiftVkN
, "Ctrl+Shift+VK_N press/release", FALSE
);
5618 trace("testing Ctrl+Alt+Shift+VK_N press/release\n");
5620 keybd_event(VK_CONTROL
, 0, 0, 0);
5621 keybd_event(VK_MENU
, 0, 0, 0);
5622 keybd_event(VK_SHIFT
, 0, 0, 0);
5623 keybd_event('N', 0, 0, 0);
5624 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
5625 keybd_event(VK_SHIFT
, 0, KEYEVENTF_KEYUP
, 0);
5626 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
5627 keybd_event(VK_CONTROL
, 0, KEYEVENTF_KEYUP
, 0);
5628 pump_msg_loop(hwnd
, hAccel
);
5629 ok_sequence(WmCtrlAltShiftVkN
, "Ctrl+Alt+Shift+VK_N press/release", FALSE
);
5631 ret
= DestroyAcceleratorTable(hAccel
);
5632 ok( ret
, "DestroyAcceleratorTable error %d\n", GetLastError());
5634 trace("testing Alt press/release\n");
5636 keybd_event(VK_MENU
, 0, 0, 0);
5637 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
5638 keybd_event(VK_MENU
, 0, 0, 0);
5639 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
5640 pump_msg_loop(hwnd
, 0);
5641 /* this test doesn't pass in Wine for managed windows */
5642 ok_sequence(WmAltPressRelease
, "Alt press/release", TRUE
);
5644 trace("testing Alt+MouseButton press/release\n");
5645 /* first, move mouse pointer inside of the window client area */
5646 GetClientRect(hwnd
, &rc
);
5647 MapWindowPoints(hwnd
, 0, (LPPOINT
)&rc
, 2);
5648 rc
.left
+= (rc
.right
- rc
.left
)/2;
5649 rc
.top
+= (rc
.bottom
- rc
.top
)/2;
5650 SetCursorPos(rc
.left
, rc
.top
);
5652 pump_msg_loop(hwnd
, 0);
5654 keybd_event(VK_MENU
, 0, 0, 0);
5655 mouse_event(MOUSEEVENTF_LEFTDOWN
, 0, 0, 0, 0);
5656 mouse_event(MOUSEEVENTF_LEFTUP
, 0, 0, 0, 0);
5657 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
5658 pump_msg_loop(hwnd
, 0);
5659 ok_sequence(WmAltMouseButton
, "Alt+MouseButton press/release", FALSE
);
5661 trace("testing VK_F1 press/release\n");
5662 keybd_event(VK_F1
, 0, 0, 0);
5663 keybd_event(VK_F1
, 0, KEYEVENTF_KEYUP
, 0);
5664 pump_msg_loop(hwnd
, 0);
5665 ok_sequence(WmF1Seq
, "F1 press/release", TRUE
);
5667 trace("testing VK_APPS press/release\n");
5668 keybd_event(VK_APPS
, 0, 0, 0);
5669 keybd_event(VK_APPS
, 0, KEYEVENTF_KEYUP
, 0);
5670 pump_msg_loop(hwnd
, 0);
5671 ok_sequence(WmVkAppsSeq
, "VK_APPS press/release", FALSE
);
5673 DestroyWindow(hwnd
);
5676 /************* window procedures ********************/
5678 static LRESULT
MsgCheckProc (BOOL unicode
, HWND hwnd
, UINT message
,
5679 WPARAM wParam
, LPARAM lParam
)
5681 static long defwndproc_counter
= 0;
5682 static long beginpaint_counter
= 0;
5686 trace("%p, %04x, %08x, %08lx\n", hwnd
, message
, wParam
, lParam
);
5688 /* explicitly ignore WM_GETICON message */
5689 if (message
== WM_GETICON
) return 0;
5695 LONG style
= GetWindowLongA(hwnd
, GWL_STYLE
);
5696 ok((BOOL
)wParam
== !(style
& WS_DISABLED
),
5697 "wrong WS_DISABLED state: %d != %d\n", wParam
, !(style
& WS_DISABLED
));
5701 case WM_CAPTURECHANGED
:
5702 if (test_DestroyWindow_flag
)
5704 DWORD style
= GetWindowLongA(hwnd
, GWL_STYLE
);
5705 if (style
& WS_CHILD
)
5706 lParam
= GetWindowLongPtrA(hwnd
, GWLP_ID
);
5707 else if (style
& WS_POPUP
)
5708 lParam
= WND_POPUP_ID
;
5710 lParam
= WND_PARENT_ID
;
5718 ok(!GetWindow(hwnd
, GW_CHILD
), "children should be unlinked at this point\n");
5719 capture
= GetCapture();
5722 ok(capture
== hwnd
, "capture should NOT be released at this point (capture %p)\n", capture
);
5723 trace("current capture %p, releasing...\n", capture
);
5730 ok(pGetAncestor(hwnd
, GA_PARENT
) != 0, "parent should NOT be unlinked at this point\n");
5731 if (test_DestroyWindow_flag
)
5733 DWORD style
= GetWindowLongA(hwnd
, GWL_STYLE
);
5734 if (style
& WS_CHILD
)
5735 lParam
= GetWindowLongPtrA(hwnd
, GWLP_ID
);
5736 else if (style
& WS_POPUP
)
5737 lParam
= WND_POPUP_ID
;
5739 lParam
= WND_PARENT_ID
;
5743 /* test_accelerators() depends on this */
5750 case WM_DEVICECHANGE
:
5753 case WM_WINDOWPOSCHANGING
:
5754 case WM_WINDOWPOSCHANGED
:
5756 WINDOWPOS
*winpos
= (WINDOWPOS
*)lParam
;
5758 trace("%s\n", (message
== WM_WINDOWPOSCHANGING
) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
5759 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
5760 winpos
->hwnd
, winpos
->hwndInsertAfter
,
5761 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
5762 dump_winpos_flags(winpos
->flags
);
5764 /* Log only documented flags, win2k uses 0x1000 and 0x2000
5765 * in the high word for internal purposes
5767 wParam
= winpos
->flags
& 0xffff;
5768 /* We are not interested in the flags that don't match under XP and Win9x */
5769 wParam
&= ~(SWP_NOZORDER
);
5774 msg
.message
= message
;
5775 msg
.flags
= sent
|wparam
|lparam
;
5776 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
5777 if (beginpaint_counter
) msg
.flags
|= beginpaint
;
5778 msg
.wParam
= wParam
;
5779 msg
.lParam
= lParam
;
5782 if (message
== WM_GETMINMAXINFO
&& (GetWindowLongA(hwnd
, GWL_STYLE
) & WS_CHILD
))
5784 HWND parent
= GetParent(hwnd
);
5786 MINMAXINFO
*minmax
= (MINMAXINFO
*)lParam
;
5788 GetClientRect(parent
, &rc
);
5789 trace("parent %p client size = (%d x %d)\n", parent
, rc
.right
, rc
.bottom
);
5791 trace("ptReserved = (%d,%d)\n"
5792 "ptMaxSize = (%d,%d)\n"
5793 "ptMaxPosition = (%d,%d)\n"
5794 "ptMinTrackSize = (%d,%d)\n"
5795 "ptMaxTrackSize = (%d,%d)\n",
5796 minmax
->ptReserved
.x
, minmax
->ptReserved
.y
,
5797 minmax
->ptMaxSize
.x
, minmax
->ptMaxSize
.y
,
5798 minmax
->ptMaxPosition
.x
, minmax
->ptMaxPosition
.y
,
5799 minmax
->ptMinTrackSize
.x
, minmax
->ptMinTrackSize
.y
,
5800 minmax
->ptMaxTrackSize
.x
, minmax
->ptMaxTrackSize
.y
);
5802 ok(minmax
->ptMaxSize
.x
== rc
.right
, "default width of maximized child %d != %d\n",
5803 minmax
->ptMaxSize
.x
, rc
.right
);
5804 ok(minmax
->ptMaxSize
.y
== rc
.bottom
, "default height of maximized child %d != %d\n",
5805 minmax
->ptMaxSize
.y
, rc
.bottom
);
5808 if (message
== WM_PAINT
)
5811 beginpaint_counter
++;
5812 BeginPaint( hwnd
, &ps
);
5813 beginpaint_counter
--;
5814 EndPaint( hwnd
, &ps
);
5818 defwndproc_counter
++;
5819 ret
= unicode
? DefWindowProcW(hwnd
, message
, wParam
, lParam
)
5820 : DefWindowProcA(hwnd
, message
, wParam
, lParam
);
5821 defwndproc_counter
--;
5826 static LRESULT WINAPI
MsgCheckProcA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
5828 return MsgCheckProc (FALSE
, hwnd
, message
, wParam
, lParam
);
5831 static LRESULT WINAPI
MsgCheckProcW(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
5833 return MsgCheckProc (TRUE
, hwnd
, message
, wParam
, lParam
);
5836 static LRESULT WINAPI
PopupMsgCheckProcA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
5838 static long defwndproc_counter
= 0;
5842 trace("popup: %p, %04x, %08x, %08lx\n", hwnd
, message
, wParam
, lParam
);
5844 /* explicitly ignore WM_GETICON message */
5845 if (message
== WM_GETICON
) return 0;
5847 msg
.message
= message
;
5848 msg
.flags
= sent
|wparam
|lparam
;
5849 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
5850 msg
.wParam
= wParam
;
5851 msg
.lParam
= lParam
;
5854 if (message
== WM_CREATE
)
5856 DWORD style
= GetWindowLongA(hwnd
, GWL_STYLE
) | WS_VISIBLE
;
5857 SetWindowLongA(hwnd
, GWL_STYLE
, style
);
5860 defwndproc_counter
++;
5861 ret
= DefWindowProcA(hwnd
, message
, wParam
, lParam
);
5862 defwndproc_counter
--;
5867 static LRESULT WINAPI
ParentMsgCheckProcA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
5869 static long defwndproc_counter
= 0;
5870 static long beginpaint_counter
= 0;
5874 trace("parent: %p, %04x, %08x, %08lx\n", hwnd
, message
, wParam
, lParam
);
5876 /* explicitly ignore WM_GETICON message */
5877 if (message
== WM_GETICON
) return 0;
5879 if (log_all_parent_messages
||
5880 message
== WM_PARENTNOTIFY
|| message
== WM_CANCELMODE
||
5881 message
== WM_SETFOCUS
|| message
== WM_KILLFOCUS
||
5882 message
== WM_ENABLE
|| message
== WM_ENTERIDLE
||
5883 message
== WM_IME_SETCONTEXT
)
5897 INT ret
= GetClipBox((HDC
)wParam
, &rc
);
5899 trace("WM_ERASEBKGND: GetClipBox()=%d, (%d,%d-%d,%d)\n",
5900 ret
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5904 case WM_WINDOWPOSCHANGING
:
5905 case WM_WINDOWPOSCHANGED
:
5907 WINDOWPOS
*winpos
= (WINDOWPOS
*)lParam
;
5909 trace("%s\n", (message
== WM_WINDOWPOSCHANGING
) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
5910 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
5911 winpos
->hwnd
, winpos
->hwndInsertAfter
,
5912 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
5913 dump_winpos_flags(winpos
->flags
);
5915 /* Log only documented flags, win2k uses 0x1000 and 0x2000
5916 * in the high word for internal purposes
5918 wParam
= winpos
->flags
& 0xffff;
5919 /* We are not interested in the flags that don't match under XP and Win9x */
5920 wParam
&= ~(SWP_NOZORDER
);
5925 msg
.message
= message
;
5926 msg
.flags
= sent
|parent
|wparam
|lparam
;
5927 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
5928 if (beginpaint_counter
) msg
.flags
|= beginpaint
;
5929 msg
.wParam
= wParam
;
5930 msg
.lParam
= lParam
;
5934 if (message
== WM_PAINT
)
5937 beginpaint_counter
++;
5938 BeginPaint( hwnd
, &ps
);
5939 beginpaint_counter
--;
5940 EndPaint( hwnd
, &ps
);
5944 defwndproc_counter
++;
5945 ret
= DefWindowProcA(hwnd
, message
, wParam
, lParam
);
5946 defwndproc_counter
--;
5951 static LRESULT WINAPI
TestDlgProcA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
5953 static long defwndproc_counter
= 0;
5957 trace("dialog: %p, %04x, %08x, %08lx\n", hwnd
, message
, wParam
, lParam
);
5959 /* explicitly ignore WM_GETICON message */
5960 if (message
== WM_GETICON
) return 0;
5964 DefDlgProcA(hwnd
, DM_SETDEFID
, 1, 0);
5965 ret
= DefDlgProcA(hwnd
, DM_GETDEFID
, 0, 0);
5966 if (after_end_dialog
)
5967 ok( ret
== 0, "DM_GETDEFID should return 0 after EndDialog, got %lx\n", ret
);
5969 ok(HIWORD(ret
) == DC_HASDEFID
, "DM_GETDEFID should return DC_HASDEFID, got %lx\n", ret
);
5974 case WM_WINDOWPOSCHANGING
:
5975 case WM_WINDOWPOSCHANGED
:
5977 WINDOWPOS
*winpos
= (WINDOWPOS
*)lParam
;
5979 trace("%s\n", (message
== WM_WINDOWPOSCHANGING
) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
5980 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
5981 winpos
->hwnd
, winpos
->hwndInsertAfter
,
5982 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
5983 dump_winpos_flags(winpos
->flags
);
5985 /* Log only documented flags, win2k uses 0x1000 and 0x2000
5986 * in the high word for internal purposes
5988 wParam
= winpos
->flags
& 0xffff;
5989 /* We are not interested in the flags that don't match under XP and Win9x */
5990 wParam
&= ~(SWP_NOZORDER
);
5995 msg
.message
= message
;
5996 msg
.flags
= sent
|wparam
|lparam
;
5997 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
5998 msg
.wParam
= wParam
;
5999 msg
.lParam
= lParam
;
6002 defwndproc_counter
++;
6003 ret
= DefDlgProcA(hwnd
, message
, wParam
, lParam
);
6004 defwndproc_counter
--;
6009 static void dump_winpos_flags(UINT flags
)
6011 if (!winetest_debug
) return;
6013 if (flags
& SWP_SHOWWINDOW
) printf("|SWP_SHOWWINDOW");
6014 if (flags
& SWP_HIDEWINDOW
) printf("|SWP_HIDEWINDOW");
6015 if (flags
& SWP_NOACTIVATE
) printf("|SWP_NOACTIVATE");
6016 if (flags
& SWP_FRAMECHANGED
) printf("|SWP_FRAMECHANGED");
6017 if (flags
& SWP_NOCOPYBITS
) printf("|SWP_NOCOPYBITS");
6018 if (flags
& SWP_NOOWNERZORDER
) printf("|SWP_NOOWNERZORDER");
6019 if (flags
& SWP_NOSENDCHANGING
) printf("|SWP_NOSENDCHANGING");
6020 if (flags
& SWP_DEFERERASE
) printf("|SWP_DEFERERASE");
6021 if (flags
& SWP_ASYNCWINDOWPOS
) printf("|SWP_ASYNCWINDOWPOS");
6022 if (flags
& SWP_NOZORDER
) printf("|SWP_NOZORDER");
6023 if (flags
& SWP_NOREDRAW
) printf("|SWP_NOREDRAW");
6024 if (flags
& SWP_NOSIZE
) printf("|SWP_NOSIZE");
6025 if (flags
& SWP_NOMOVE
) printf("|SWP_NOMOVE");
6026 if (flags
& SWP_NOCLIENTSIZE
) printf("|SWP_NOCLIENTSIZE");
6027 if (flags
& SWP_NOCLIENTMOVE
) printf("|SWP_NOCLIENTMOVE");
6029 #define DUMPED_FLAGS \
6035 SWP_FRAMECHANGED | \
6039 SWP_NOOWNERZORDER | \
6040 SWP_NOSENDCHANGING | \
6042 SWP_ASYNCWINDOWPOS | \
6043 SWP_NOCLIENTSIZE | \
6046 if(flags
& ~DUMPED_FLAGS
) printf("|0x%04x", flags
& ~DUMPED_FLAGS
);
6051 static LRESULT WINAPI
ShowWindowProcA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
6053 static long defwndproc_counter
= 0;
6057 /* log only specific messages we are interested in */
6060 #if 0 /* probably log these as well */
6066 trace("WM_SHOWWINDOW %d\n", wParam
);
6069 trace("WM_SIZE %d\n", wParam
);
6074 case WM_GETMINMAXINFO
:
6075 trace("WM_GETMINMAXINFO\n");
6078 case WM_WINDOWPOSCHANGING
:
6079 case WM_WINDOWPOSCHANGED
:
6081 WINDOWPOS
*winpos
= (WINDOWPOS
*)lParam
;
6083 trace("%s\n", (message
== WM_WINDOWPOSCHANGING
) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
6084 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
6085 winpos
->hwnd
, winpos
->hwndInsertAfter
,
6086 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
6088 dump_winpos_flags(winpos
->flags
);
6090 /* Log only documented flags, win2k uses 0x1000 and 0x2000
6091 * in the high word for internal purposes
6093 wParam
= winpos
->flags
& 0xffff;
6094 /* We are not interested in the flags that don't match under XP and Win9x */
6095 wParam
&= ~(SWP_NOZORDER
);
6099 default: /* ignore */
6100 /*trace("showwindow: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);*/
6101 return DefWindowProcA(hwnd
, message
, wParam
, lParam
);
6104 msg
.message
= message
;
6105 msg
.flags
= sent
|wparam
|lparam
;
6106 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
6107 msg
.wParam
= wParam
;
6108 msg
.lParam
= lParam
;
6111 defwndproc_counter
++;
6112 ret
= DefWindowProcA(hwnd
, message
, wParam
, lParam
);
6113 defwndproc_counter
--;
6118 static BOOL
RegisterWindowClasses(void)
6123 cls
.lpfnWndProc
= MsgCheckProcA
;
6126 cls
.hInstance
= GetModuleHandleA(0);
6128 cls
.hCursor
= LoadCursorA(0, (LPSTR
)IDC_ARROW
);
6129 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
6130 cls
.lpszMenuName
= NULL
;
6131 cls
.lpszClassName
= "TestWindowClass";
6132 if(!RegisterClassA(&cls
)) return FALSE
;
6134 cls
.lpfnWndProc
= ShowWindowProcA
;
6135 cls
.lpszClassName
= "ShowWindowClass";
6136 if(!RegisterClassA(&cls
)) return FALSE
;
6138 cls
.lpfnWndProc
= PopupMsgCheckProcA
;
6139 cls
.lpszClassName
= "TestPopupClass";
6140 if(!RegisterClassA(&cls
)) return FALSE
;
6142 cls
.lpfnWndProc
= ParentMsgCheckProcA
;
6143 cls
.lpszClassName
= "TestParentClass";
6144 if(!RegisterClassA(&cls
)) return FALSE
;
6146 cls
.lpfnWndProc
= DefWindowProcA
;
6147 cls
.lpszClassName
= "SimpleWindowClass";
6148 if(!RegisterClassA(&cls
)) return FALSE
;
6150 cls
.style
= CS_NOCLOSE
;
6151 cls
.lpszClassName
= "NoCloseWindowClass";
6152 if(!RegisterClassA(&cls
)) return FALSE
;
6154 ok(GetClassInfoA(0, "#32770", &cls
), "GetClassInfo failed\n");
6156 cls
.hInstance
= GetModuleHandleA(0);
6157 cls
.hbrBackground
= 0;
6158 cls
.lpfnWndProc
= TestDlgProcA
;
6159 cls
.lpszClassName
= "TestDialogClass";
6160 if(!RegisterClassA(&cls
)) return FALSE
;
6165 static HHOOK hCBT_hook
;
6166 static DWORD cbt_hook_thread_id
;
6168 static LRESULT CALLBACK
cbt_hook_proc(int nCode
, WPARAM wParam
, LPARAM lParam
)
6170 static const char * const CBT_code_name
[10] = {
6177 "HCBT_CLICKSKIPPED",
6181 const char *code_name
= (nCode
>= 0 && nCode
<= HCBT_SETFOCUS
) ? CBT_code_name
[nCode
] : "Unknown";
6185 trace("CBT: %d (%s), %08x, %08lx\n", nCode
, code_name
, wParam
, lParam
);
6187 ok(cbt_hook_thread_id
== GetCurrentThreadId(), "we didn't ask for events from other threads\n");
6189 if (nCode
== HCBT_CLICKSKIPPED
)
6191 /* ignore this event, XP sends it a lot when switching focus between windows */
6192 return CallNextHookEx(hCBT_hook
, nCode
, wParam
, lParam
);
6195 if (nCode
== HCBT_SYSCOMMAND
|| nCode
== HCBT_KEYSKIPPED
)
6199 msg
.message
= nCode
;
6200 msg
.flags
= hook
|wparam
|lparam
;
6201 msg
.wParam
= wParam
;
6202 msg
.lParam
= lParam
;
6205 return CallNextHookEx(hCBT_hook
, nCode
, wParam
, lParam
);
6208 if (nCode
== HCBT_DESTROYWND
)
6210 if (test_DestroyWindow_flag
)
6212 DWORD style
= GetWindowLongA((HWND
)wParam
, GWL_STYLE
);
6213 if (style
& WS_CHILD
)
6214 lParam
= GetWindowLongPtrA((HWND
)wParam
, GWLP_ID
);
6215 else if (style
& WS_POPUP
)
6216 lParam
= WND_POPUP_ID
;
6218 lParam
= WND_PARENT_ID
;
6222 /* Log also SetFocus(0) calls */
6223 hwnd
= wParam
? (HWND
)wParam
: (HWND
)lParam
;
6225 if (GetClassNameA(hwnd
, buf
, sizeof(buf
)))
6227 if (!lstrcmpiA(buf
, "TestWindowClass") ||
6228 !lstrcmpiA(buf
, "ShowWindowClass") ||
6229 !lstrcmpiA(buf
, "TestParentClass") ||
6230 !lstrcmpiA(buf
, "TestPopupClass") ||
6231 !lstrcmpiA(buf
, "SimpleWindowClass") ||
6232 !lstrcmpiA(buf
, "TestDialogClass") ||
6233 !lstrcmpiA(buf
, "MDI_frame_class") ||
6234 !lstrcmpiA(buf
, "MDI_client_class") ||
6235 !lstrcmpiA(buf
, "MDI_child_class") ||
6236 !lstrcmpiA(buf
, "my_button_class") ||
6237 !lstrcmpiA(buf
, "my_edit_class") ||
6238 !lstrcmpiA(buf
, "static") ||
6239 !lstrcmpiA(buf
, "#32770"))
6243 msg
.message
= nCode
;
6244 msg
.flags
= hook
|wparam
|lparam
;
6245 msg
.wParam
= wParam
;
6246 msg
.lParam
= lParam
;
6250 return CallNextHookEx(hCBT_hook
, nCode
, wParam
, lParam
);
6253 static void CALLBACK
win_event_proc(HWINEVENTHOOK hevent
,
6263 trace("WEH:%p,event %08x,hwnd %p,obj %08x,id %08x,thread %08x,time %08x\n",
6264 hevent
, event
, hwnd
, object_id
, child_id
, thread_id
, event_time
);
6266 ok(thread_id
== GetCurrentThreadId(), "we didn't ask for events from other threads\n");
6268 /* ignore mouse cursor events */
6269 if (object_id
== OBJID_CURSOR
) return;
6271 if (!hwnd
|| GetClassNameA(hwnd
, buf
, sizeof(buf
)))
6274 !lstrcmpiA(buf
, "TestWindowClass") ||
6275 !lstrcmpiA(buf
, "TestParentClass") ||
6276 !lstrcmpiA(buf
, "TestPopupClass") ||
6277 !lstrcmpiA(buf
, "SimpleWindowClass") ||
6278 !lstrcmpiA(buf
, "TestDialogClass") ||
6279 !lstrcmpiA(buf
, "MDI_frame_class") ||
6280 !lstrcmpiA(buf
, "MDI_client_class") ||
6281 !lstrcmpiA(buf
, "MDI_child_class") ||
6282 !lstrcmpiA(buf
, "my_button_class") ||
6283 !lstrcmpiA(buf
, "my_edit_class") ||
6284 !lstrcmpiA(buf
, "static") ||
6285 !lstrcmpiA(buf
, "#32770"))
6289 msg
.message
= event
;
6290 msg
.flags
= winevent_hook
|wparam
|lparam
;
6291 msg
.wParam
= object_id
;
6292 msg
.lParam
= child_id
;
6298 static const WCHAR wszUnicode
[] = {'U','n','i','c','o','d','e',0};
6299 static const WCHAR wszAnsi
[] = {'U',0};
6301 static LRESULT CALLBACK
MsgConversionProcW(HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
6305 case CB_FINDSTRINGEXACT
:
6306 trace("String: %p\n", (LPCWSTR
)lParam
);
6307 if (!lstrcmpW((LPCWSTR
)lParam
, wszUnicode
))
6309 if (!lstrcmpW((LPCWSTR
)lParam
, wszAnsi
))
6313 return DefWindowProcW(hwnd
, uMsg
, wParam
, lParam
);
6316 static const struct message WmGetTextLengthAfromW
[] = {
6317 { WM_GETTEXTLENGTH
, sent
},
6318 { WM_GETTEXT
, sent
},
6322 static const WCHAR testWindowClassW
[] =
6323 { 'T','e','s','t','W','i','n','d','o','w','C','l','a','s','s','W',0 };
6325 static const WCHAR dummy_window_text
[] = {'d','u','m','m','y',' ','t','e','x','t',0};
6327 /* dummy window proc for WM_GETTEXTLENGTH test */
6328 static LRESULT CALLBACK
get_text_len_proc( HWND hwnd
, UINT msg
, WPARAM wp
, LPARAM lp
)
6332 case WM_GETTEXTLENGTH
:
6333 return lstrlenW(dummy_window_text
) + 37; /* some random length */
6335 lstrcpynW( (LPWSTR
)lp
, dummy_window_text
, wp
);
6336 return lstrlenW( (LPWSTR
)lp
);
6338 return DefWindowProcW( hwnd
, msg
, wp
, lp
);
6342 static void test_message_conversion(void)
6344 static const WCHAR wszMsgConversionClass
[] =
6345 {'M','s','g','C','o','n','v','e','r','s','i','o','n','C','l','a','s','s',0};
6349 WNDPROC wndproc
, newproc
;
6353 cls
.lpfnWndProc
= MsgConversionProcW
;
6356 cls
.hInstance
= GetModuleHandleW(NULL
);
6358 cls
.hCursor
= LoadCursorW(NULL
, (LPWSTR
)IDC_ARROW
);
6359 cls
.hbrBackground
= (HBRUSH
)(COLOR_BTNFACE
+1);
6360 cls
.lpszMenuName
= NULL
;
6361 cls
.lpszClassName
= wszMsgConversionClass
;
6362 /* this call will fail on Win9x, but that doesn't matter as this test is
6363 * meaningless on those platforms */
6364 if(!RegisterClassW(&cls
)) return;
6367 cls
.lpfnWndProc
= MsgCheckProcW
;
6370 cls
.hInstance
= GetModuleHandleW(0);
6372 cls
.hCursor
= LoadCursorW(0, (LPWSTR
)IDC_ARROW
);
6373 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
6374 cls
.lpszMenuName
= NULL
;
6375 cls
.lpszClassName
= testWindowClassW
;
6376 if(!RegisterClassW(&cls
)) return;
6378 hwnd
= CreateWindowExW(0, wszMsgConversionClass
, NULL
, WS_OVERLAPPED
,
6379 100, 100, 200, 200, 0, 0, 0, NULL
);
6380 ok(hwnd
!= NULL
, "Window creation failed\n");
6384 wndproc
= (WNDPROC
)GetWindowLongPtrA(hwnd
, GWLP_WNDPROC
);
6385 lRes
= CallWindowProcA(wndproc
, hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
6386 ok(lRes
== 0, "String should have been converted\n");
6387 lRes
= CallWindowProcW(wndproc
, hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
6388 ok(lRes
== 1, "String shouldn't have been converted\n");
6392 wndproc
= (WNDPROC
)GetWindowLongPtrW(hwnd
, GWLP_WNDPROC
);
6393 lRes
= CallWindowProcA(wndproc
, hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
6394 ok(lRes
== 1, "String shouldn't have been converted\n");
6395 lRes
= CallWindowProcW(wndproc
, hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
6396 ok(lRes
== 1, "String shouldn't have been converted\n");
6398 /* Synchronous messages */
6400 lRes
= SendMessageA(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
6401 ok(lRes
== 0, "String should have been converted\n");
6402 lRes
= SendMessageW(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
6403 ok(lRes
== 1, "String shouldn't have been converted\n");
6405 /* Asynchronous messages */
6408 lRes
= PostMessageA(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
6409 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
6410 "PostMessage on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
6412 lRes
= PostMessageW(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
6413 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
6414 "PostMessage on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
6416 lRes
= PostThreadMessageA(GetCurrentThreadId(), CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
6417 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
6418 "PosThreadtMessage on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
6420 lRes
= PostThreadMessageW(GetCurrentThreadId(), CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
6421 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
6422 "PosThreadtMessage on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
6424 lRes
= SendNotifyMessageA(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
6425 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
6426 "SendNotifyMessage on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
6428 lRes
= SendNotifyMessageW(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
6429 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
6430 "SendNotifyMessage on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
6432 lRes
= SendMessageCallbackA(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
, NULL
, 0);
6433 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
6434 "SendMessageCallback on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
6436 lRes
= SendMessageCallbackW(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
, NULL
, 0);
6437 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
6438 "SendMessageCallback on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
6440 /* Check WM_GETTEXTLENGTH A->W behaviour, whether WM_GETTEXT is also sent or not */
6442 hwnd
= CreateWindowW (testWindowClassW
, wszUnicode
,
6443 WS_OVERLAPPEDWINDOW
,
6444 100, 100, 200, 200, 0, 0, 0, NULL
);
6447 lRes
= SendMessageA (hwnd
, WM_GETTEXTLENGTH
, 0, 0);
6448 ok_sequence(WmGetTextLengthAfromW
, "ANSI WM_GETTEXTLENGTH to Unicode window", FALSE
);
6449 ok( lRes
== WideCharToMultiByte( CP_ACP
, 0, wszUnicode
, lstrlenW(wszUnicode
), NULL
, 0, NULL
, NULL
),
6450 "got bad length %ld\n", lRes
);
6453 lRes
= CallWindowProcA( (WNDPROC
)GetWindowLongPtrA( hwnd
, GWLP_WNDPROC
),
6454 hwnd
, WM_GETTEXTLENGTH
, 0, 0);
6455 ok_sequence(WmGetTextLengthAfromW
, "ANSI WM_GETTEXTLENGTH to Unicode window", FALSE
);
6456 ok( lRes
== WideCharToMultiByte( CP_ACP
, 0, wszUnicode
, lstrlenW(wszUnicode
), NULL
, 0, NULL
, NULL
),
6457 "got bad length %ld\n", lRes
);
6459 wndproc
= (WNDPROC
)SetWindowLongPtrW( hwnd
, GWLP_WNDPROC
, (LONG_PTR
)get_text_len_proc
);
6460 newproc
= (WNDPROC
)GetWindowLongPtrA( hwnd
, GWLP_WNDPROC
);
6461 lRes
= CallWindowProcA( newproc
, hwnd
, WM_GETTEXTLENGTH
, 0, 0 );
6462 ok( lRes
== WideCharToMultiByte( CP_ACP
, 0, dummy_window_text
, lstrlenW(dummy_window_text
),
6463 NULL
, 0, NULL
, NULL
),
6464 "got bad length %ld\n", lRes
);
6466 SetWindowLongPtrW( hwnd
, GWLP_WNDPROC
, (LONG_PTR
)wndproc
); /* restore old wnd proc */
6467 lRes
= CallWindowProcA( newproc
, hwnd
, WM_GETTEXTLENGTH
, 0, 0 );
6468 ok( lRes
== WideCharToMultiByte( CP_ACP
, 0, dummy_window_text
, lstrlenW(dummy_window_text
),
6469 NULL
, 0, NULL
, NULL
),
6470 "got bad length %ld\n", lRes
);
6472 ret
= DestroyWindow(hwnd
);
6473 ok( ret
, "DestroyWindow() error %d\n", GetLastError());
6483 static VOID CALLBACK
tfunc(HWND hwnd
, UINT uMsg
, UINT id
, DWORD dwTime
)
6487 #define TIMER_ID 0x19
6489 static DWORD WINAPI
timer_thread_proc(LPVOID x
)
6491 struct timer_info
*info
= x
;
6494 r
= KillTimer(info
->hWnd
, 0x19);
6495 ok(r
,"KillTimer failed in thread\n");
6496 r
= SetTimer(info
->hWnd
,TIMER_ID
,10000,tfunc
);
6497 ok(r
,"SetTimer failed in thread\n");
6498 ok(r
==TIMER_ID
,"SetTimer id different\n");
6499 r
= SetEvent(info
->handles
[0]);
6500 ok(r
,"SetEvent failed in thread\n");
6504 static void test_timers(void)
6506 struct timer_info info
;
6509 info
.hWnd
= CreateWindow ("TestWindowClass", NULL
,
6510 WS_OVERLAPPEDWINDOW
,
6511 CW_USEDEFAULT
, CW_USEDEFAULT
, 300, 300, 0,
6514 info
.id
= SetTimer(info
.hWnd
,TIMER_ID
,10000,tfunc
);
6515 ok(info
.id
, "SetTimer failed\n");
6516 ok(info
.id
==TIMER_ID
, "SetTimer timer ID different\n");
6517 info
.handles
[0] = CreateEvent(NULL
,0,0,NULL
);
6518 info
.handles
[1] = CreateThread(NULL
,0,timer_thread_proc
,&info
,0,&id
);
6520 WaitForMultipleObjects(2, info
.handles
, FALSE
, INFINITE
);
6522 WaitForSingleObject(info
.handles
[1], INFINITE
);
6524 CloseHandle(info
.handles
[0]);
6525 CloseHandle(info
.handles
[1]);
6527 ok( KillTimer(info
.hWnd
, TIMER_ID
), "KillTimer failed\n");
6529 ok(DestroyWindow(info
.hWnd
), "failed to destroy window\n");
6532 /* Various win events with arbitrary parameters */
6533 static const struct message WmWinEventsSeq
[] = {
6534 { EVENT_SYSTEM_SOUND
, winevent_hook
|wparam
|lparam
, OBJID_WINDOW
, 0 },
6535 { EVENT_SYSTEM_ALERT
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 1 },
6536 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, OBJID_TITLEBAR
, 2 },
6537 { EVENT_SYSTEM_MENUSTART
, winevent_hook
|wparam
|lparam
, OBJID_MENU
, 3 },
6538 { EVENT_SYSTEM_MENUEND
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 4 },
6539 { EVENT_SYSTEM_MENUPOPUPSTART
, winevent_hook
|wparam
|lparam
, OBJID_VSCROLL
, 5 },
6540 { EVENT_SYSTEM_MENUPOPUPEND
, winevent_hook
|wparam
|lparam
, OBJID_HSCROLL
, 6 },
6541 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, OBJID_SIZEGRIP
, 7 },
6542 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 8 },
6543 /* our win event hook ignores OBJID_CURSOR events */
6544 /*{ EVENT_SYSTEM_MOVESIZESTART, winevent_hook|wparam|lparam, OBJID_CURSOR, 9 },*/
6545 { EVENT_SYSTEM_MOVESIZEEND
, winevent_hook
|wparam
|lparam
, OBJID_ALERT
, 10 },
6546 { EVENT_SYSTEM_CONTEXTHELPSTART
, winevent_hook
|wparam
|lparam
, OBJID_SOUND
, 11 },
6547 { EVENT_SYSTEM_CONTEXTHELPEND
, winevent_hook
|wparam
|lparam
, OBJID_QUERYCLASSNAMEIDX
, 12 },
6548 { EVENT_SYSTEM_DRAGDROPSTART
, winevent_hook
|wparam
|lparam
, OBJID_NATIVEOM
, 13 },
6549 { EVENT_SYSTEM_DRAGDROPEND
, winevent_hook
|wparam
|lparam
, OBJID_WINDOW
, 0 },
6550 { EVENT_SYSTEM_DIALOGSTART
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 1 },
6551 { EVENT_SYSTEM_DIALOGEND
, winevent_hook
|wparam
|lparam
, OBJID_TITLEBAR
, 2 },
6552 { EVENT_SYSTEM_SCROLLINGSTART
, winevent_hook
|wparam
|lparam
, OBJID_MENU
, 3 },
6553 { EVENT_SYSTEM_SCROLLINGEND
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 4 },
6554 { EVENT_SYSTEM_SWITCHSTART
, winevent_hook
|wparam
|lparam
, OBJID_VSCROLL
, 5 },
6555 { EVENT_SYSTEM_SWITCHEND
, winevent_hook
|wparam
|lparam
, OBJID_HSCROLL
, 6 },
6556 { EVENT_SYSTEM_MINIMIZESTART
, winevent_hook
|wparam
|lparam
, OBJID_SIZEGRIP
, 7 },
6557 { EVENT_SYSTEM_MINIMIZEEND
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 8 },
6560 static const struct message WmWinEventCaretSeq
[] = {
6561 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 1 */
6562 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 1 */
6563 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 2 */
6564 { EVENT_OBJECT_NAMECHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 1 */
6567 static const struct message WmWinEventCaretSeq_2
[] = {
6568 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 1/2 */
6569 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 1/2 */
6570 { EVENT_OBJECT_NAMECHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 1/2 */
6573 static const struct message WmWinEventAlertSeq
[] = {
6574 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_ALERT
, 0 },
6577 static const struct message WmWinEventAlertSeq_2
[] = {
6578 /* create window in the thread proc */
6579 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_WINDOW
, 2 },
6580 /* our test event */
6581 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_ALERT
, 2 },
6584 static const struct message WmGlobalHookSeq_1
[] = {
6585 /* create window in the thread proc */
6586 { HCBT_CREATEWND
, hook
|lparam
, 0, 2 },
6587 /* our test events */
6588 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_PREVWINDOW
, 2 },
6589 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_NEXTWINDOW
, 2 },
6592 static const struct message WmGlobalHookSeq_2
[] = {
6593 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_NEXTWINDOW
, 0 }, /* old local hook */
6594 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_NEXTWINDOW
, 2 }, /* new global hook */
6595 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_PREVWINDOW
, 0 }, /* old local hook */
6596 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_PREVWINDOW
, 2 }, /* new global hook */
6600 static const struct message WmMouseLLHookSeq
[] = {
6601 { WM_MOUSEMOVE
, hook
},
6602 { WM_LBUTTONUP
, hook
},
6603 { WM_MOUSEMOVE
, hook
},
6607 static void CALLBACK
win_event_global_hook_proc(HWINEVENTHOOK hevent
,
6617 trace("WEH_2:%p,event %08x,hwnd %p,obj %08x,id %08x,thread %08x,time %08x\n",
6618 hevent
, event
, hwnd
, object_id
, child_id
, thread_id
, event_time
);
6620 if (GetClassNameA(hwnd
, buf
, sizeof(buf
)))
6622 if (!lstrcmpiA(buf
, "TestWindowClass") ||
6623 !lstrcmpiA(buf
, "static"))
6627 msg
.message
= event
;
6628 msg
.flags
= winevent_hook
|wparam
|lparam
;
6629 msg
.wParam
= object_id
;
6630 msg
.lParam
= (thread_id
== GetCurrentThreadId()) ? child_id
: (child_id
+ 2);
6636 static HHOOK hCBT_global_hook
;
6637 static DWORD cbt_global_hook_thread_id
;
6639 static LRESULT CALLBACK
cbt_global_hook_proc(int nCode
, WPARAM wParam
, LPARAM lParam
)
6644 trace("CBT_2: %d, %08x, %08lx\n", nCode
, wParam
, lParam
);
6646 if (nCode
== HCBT_SYSCOMMAND
)
6650 msg
.message
= nCode
;
6651 msg
.flags
= hook
|wparam
|lparam
;
6652 msg
.wParam
= wParam
;
6653 msg
.lParam
= (cbt_global_hook_thread_id
== GetCurrentThreadId()) ? 1 : 2;
6656 return CallNextHookEx(hCBT_global_hook
, nCode
, wParam
, lParam
);
6658 /* WH_MOUSE_LL hook */
6659 if (nCode
== HC_ACTION
)
6662 MSLLHOOKSTRUCT
*mhll
= (MSLLHOOKSTRUCT
*)lParam
;
6664 /* we can't test for real mouse events */
6665 if (mhll
->flags
& LLMHF_INJECTED
)
6667 msg
.message
= wParam
;
6671 return CallNextHookEx(hCBT_global_hook
, nCode
, wParam
, lParam
);
6674 /* Log also SetFocus(0) calls */
6675 hwnd
= wParam
? (HWND
)wParam
: (HWND
)lParam
;
6677 if (GetClassNameA(hwnd
, buf
, sizeof(buf
)))
6679 if (!lstrcmpiA(buf
, "TestWindowClass") ||
6680 !lstrcmpiA(buf
, "static"))
6684 msg
.message
= nCode
;
6685 msg
.flags
= hook
|wparam
|lparam
;
6686 msg
.wParam
= wParam
;
6687 msg
.lParam
= (cbt_global_hook_thread_id
== GetCurrentThreadId()) ? 1 : 2;
6691 return CallNextHookEx(hCBT_global_hook
, nCode
, wParam
, lParam
);
6694 static DWORD WINAPI
win_event_global_thread_proc(void *param
)
6698 HANDLE hevent
= *(HANDLE
*)param
;
6699 HMODULE user32
= GetModuleHandleA("user32.dll");
6700 FARPROC pNotifyWinEvent
= GetProcAddress(user32
, "NotifyWinEvent");
6702 assert(pNotifyWinEvent
);
6704 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
, 0,0,0,0,0,0,0, NULL
);
6706 trace("created thread window %p\n", hwnd
);
6708 *(HWND
*)param
= hwnd
;
6711 /* this event should be received only by our new hook proc,
6712 * an old one does not expect an event from another thread.
6714 pNotifyWinEvent(EVENT_OBJECT_LOCATIONCHANGE
, hwnd
, OBJID_ALERT
, 0);
6717 while (GetMessage(&msg
, 0, 0, 0))
6719 TranslateMessage(&msg
);
6720 DispatchMessage(&msg
);
6725 static DWORD WINAPI
cbt_global_hook_thread_proc(void *param
)
6729 HANDLE hevent
= *(HANDLE
*)param
;
6732 /* these events should be received only by our new hook proc,
6733 * an old one does not expect an event from another thread.
6736 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
, 0,0,0,0,0,0,0, NULL
);
6738 trace("created thread window %p\n", hwnd
);
6740 *(HWND
*)param
= hwnd
;
6742 /* Windows doesn't like when a thread plays games with the focus,
6743 that leads to all kinds of misbehaviours and failures to activate
6744 a window. So, better keep next lines commented out.
6748 DefWindowProcA(hwnd
, WM_SYSCOMMAND
, SC_PREVWINDOW
, 0);
6749 DefWindowProcA(hwnd
, WM_SYSCOMMAND
, SC_NEXTWINDOW
, 0);
6753 while (GetMessage(&msg
, 0, 0, 0))
6755 TranslateMessage(&msg
);
6756 DispatchMessage(&msg
);
6761 static DWORD WINAPI
mouse_ll_global_thread_proc(void *param
)
6765 HANDLE hevent
= *(HANDLE
*)param
;
6767 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
, 0,0,0,0,0,0,0, NULL
);
6769 trace("created thread window %p\n", hwnd
);
6771 *(HWND
*)param
= hwnd
;
6775 /* Windows doesn't like when a thread plays games with the focus,
6776 * that leads to all kinds of misbehaviours and failures to activate
6777 * a window. So, better don't generate a mouse click message below.
6779 mouse_event(MOUSEEVENTF_MOVE
, -1, 0, 0, 0);
6780 mouse_event(MOUSEEVENTF_LEFTUP
, 0, 0, 0, 0);
6781 mouse_event(MOUSEEVENTF_MOVE
, 1, 0, 0, 0);
6784 while (GetMessage(&msg
, 0, 0, 0))
6786 TranslateMessage(&msg
);
6787 DispatchMessage(&msg
);
6792 static void test_winevents(void)
6798 HANDLE hthread
, hevent
;
6800 HWINEVENTHOOK hhook
;
6801 const struct message
*events
= WmWinEventsSeq
;
6802 HMODULE user32
= GetModuleHandleA("user32.dll");
6803 FARPROC pSetWinEventHook
= GetProcAddress(user32
, "SetWinEventHook");
6804 FARPROC pUnhookWinEvent
= GetProcAddress(user32
, "UnhookWinEvent");
6805 FARPROC pNotifyWinEvent
= GetProcAddress(user32
, "NotifyWinEvent");
6807 hwnd
= CreateWindowExA(0, "TestWindowClass", NULL
,
6808 WS_OVERLAPPEDWINDOW
,
6809 CW_USEDEFAULT
, CW_USEDEFAULT
, 300, 300, 0,
6813 /****** start of global hook test *************/
6814 hCBT_global_hook
= SetWindowsHookExA(WH_CBT
, cbt_global_hook_proc
, GetModuleHandleA(0), 0);
6815 assert(hCBT_global_hook
);
6817 hevent
= CreateEventA(NULL
, 0, 0, NULL
);
6819 hwnd2
= (HWND
)hevent
;
6821 hthread
= CreateThread(NULL
, 0, cbt_global_hook_thread_proc
, &hwnd2
, 0, &tid
);
6822 ok(hthread
!= NULL
, "CreateThread failed, error %d\n", GetLastError());
6824 ok(WaitForSingleObject(hevent
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
6826 ok_sequence(WmGlobalHookSeq_1
, "global hook 1", FALSE
);
6829 /* this one should be received only by old hook proc */
6830 DefWindowProcA(hwnd
, WM_SYSCOMMAND
, SC_NEXTWINDOW
, 0);
6831 /* this one should be received only by old hook proc */
6832 DefWindowProcA(hwnd
, WM_SYSCOMMAND
, SC_PREVWINDOW
, 0);
6834 ok_sequence(WmGlobalHookSeq_2
, "global hook 2", FALSE
);
6836 ret
= UnhookWindowsHookEx(hCBT_global_hook
);
6837 ok( ret
, "UnhookWindowsHookEx error %d\n", GetLastError());
6839 PostThreadMessageA(tid
, WM_QUIT
, 0, 0);
6840 ok(WaitForSingleObject(hthread
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
6841 CloseHandle(hthread
);
6842 CloseHandle(hevent
);
6843 ok(!IsWindow(hwnd2
), "window should be destroyed on thread exit\n");
6844 /****** end of global hook test *************/
6846 if (!pSetWinEventHook
|| !pNotifyWinEvent
|| !pUnhookWinEvent
)
6848 ok(DestroyWindow(hwnd
), "failed to destroy window\n");
6856 /* this test doesn't pass under Win9x */
6857 /* win2k ignores events with hwnd == 0 */
6858 SetLastError(0xdeadbeef);
6859 pNotifyWinEvent(events
[0].message
, 0, events
[0].wParam
, events
[0].lParam
);
6860 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
|| /* Win2k */
6861 GetLastError() == 0xdeadbeef, /* Win9x */
6862 "unexpected error %d\n", GetLastError());
6863 ok_sequence(WmEmptySeq
, "empty notify winevents", FALSE
);
6866 for (i
= 0; i
< sizeof(WmWinEventsSeq
)/sizeof(WmWinEventsSeq
[0]); i
++)
6867 pNotifyWinEvent(events
[i
].message
, hwnd
, events
[i
].wParam
, events
[i
].lParam
);
6869 ok_sequence(WmWinEventsSeq
, "notify winevents", FALSE
);
6871 /****** start of event filtering test *************/
6872 hhook
= (HWINEVENTHOOK
)pSetWinEventHook(
6873 EVENT_OBJECT_SHOW
, /* 0x8002 */
6874 EVENT_OBJECT_LOCATIONCHANGE
, /* 0x800B */
6875 GetModuleHandleA(0), win_event_global_hook_proc
,
6876 GetCurrentProcessId(), 0,
6877 WINEVENT_INCONTEXT
);
6878 ok(hhook
!= 0, "SetWinEventHook error %d\n", GetLastError());
6880 hevent
= CreateEventA(NULL
, 0, 0, NULL
);
6882 hwnd2
= (HWND
)hevent
;
6884 hthread
= CreateThread(NULL
, 0, win_event_global_thread_proc
, &hwnd2
, 0, &tid
);
6885 ok(hthread
!= NULL
, "CreateThread failed, error %d\n", GetLastError());
6887 ok(WaitForSingleObject(hevent
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
6889 ok_sequence(WmWinEventAlertSeq
, "alert winevent", FALSE
);
6892 /* this one should be received only by old hook proc */
6893 pNotifyWinEvent(EVENT_OBJECT_CREATE
, hwnd
, OBJID_CARET
, 0); /* 0x8000 */
6894 pNotifyWinEvent(EVENT_OBJECT_SHOW
, hwnd
, OBJID_CARET
, 0); /* 0x8002 */
6895 /* this one should be received only by old hook proc */
6896 pNotifyWinEvent(EVENT_OBJECT_NAMECHANGE
, hwnd
, OBJID_CARET
, 0); /* 0x800C */
6898 ok_sequence(WmWinEventCaretSeq
, "caret winevent", FALSE
);
6900 ret
= pUnhookWinEvent(hhook
);
6901 ok( ret
, "UnhookWinEvent error %d\n", GetLastError());
6903 PostThreadMessageA(tid
, WM_QUIT
, 0, 0);
6904 ok(WaitForSingleObject(hthread
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
6905 CloseHandle(hthread
);
6906 CloseHandle(hevent
);
6907 ok(!IsWindow(hwnd2
), "window should be destroyed on thread exit\n");
6908 /****** end of event filtering test *************/
6910 /****** start of out of context event test *************/
6911 hhook
= (HWINEVENTHOOK
)pSetWinEventHook(
6912 EVENT_MIN
, EVENT_MAX
,
6913 0, win_event_global_hook_proc
,
6914 GetCurrentProcessId(), 0,
6915 WINEVENT_OUTOFCONTEXT
);
6916 ok(hhook
!= 0, "SetWinEventHook error %d\n", GetLastError());
6918 hevent
= CreateEventA(NULL
, 0, 0, NULL
);
6920 hwnd2
= (HWND
)hevent
;
6924 hthread
= CreateThread(NULL
, 0, win_event_global_thread_proc
, &hwnd2
, 0, &tid
);
6925 ok(hthread
!= NULL
, "CreateThread failed, error %d\n", GetLastError());
6927 ok(WaitForSingleObject(hevent
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
6929 ok_sequence(WmEmptySeq
, "empty notify winevents", FALSE
);
6930 /* process pending winevent messages */
6931 ok(!PeekMessageA(&msg
, 0, 0, 0, PM_NOREMOVE
), "msg queue should be empty\n");
6932 ok_sequence(WmWinEventAlertSeq_2
, "alert winevent for out of context proc", FALSE
);
6935 /* this one should be received only by old hook proc */
6936 pNotifyWinEvent(EVENT_OBJECT_CREATE
, hwnd
, OBJID_CARET
, 0); /* 0x8000 */
6937 pNotifyWinEvent(EVENT_OBJECT_SHOW
, hwnd
, OBJID_CARET
, 0); /* 0x8002 */
6938 /* this one should be received only by old hook proc */
6939 pNotifyWinEvent(EVENT_OBJECT_NAMECHANGE
, hwnd
, OBJID_CARET
, 0); /* 0x800C */
6941 ok_sequence(WmWinEventCaretSeq_2
, "caret winevent for incontext proc", FALSE
);
6942 /* process pending winevent messages */
6943 ok(!PeekMessageA(&msg
, 0, 0, 0, PM_NOREMOVE
), "msg queue should be empty\n");
6944 ok_sequence(WmWinEventCaretSeq_2
, "caret winevent for out of context proc", FALSE
);
6946 ret
= pUnhookWinEvent(hhook
);
6947 ok( ret
, "UnhookWinEvent error %d\n", GetLastError());
6949 PostThreadMessageA(tid
, WM_QUIT
, 0, 0);
6950 ok(WaitForSingleObject(hthread
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
6951 CloseHandle(hthread
);
6952 CloseHandle(hevent
);
6953 ok(!IsWindow(hwnd2
), "window should be destroyed on thread exit\n");
6954 /****** end of out of context event test *************/
6956 /****** start of MOUSE_LL hook test *************/
6957 hCBT_global_hook
= SetWindowsHookExA(WH_MOUSE_LL
, cbt_global_hook_proc
, GetModuleHandleA(0), 0);
6958 /* WH_MOUSE_LL is not supported on Win9x platforms */
6959 if (!hCBT_global_hook
)
6961 trace("Skipping WH_MOUSE_LL test on this platform\n");
6962 goto skip_mouse_ll_hook_test
;
6965 hevent
= CreateEventA(NULL
, 0, 0, NULL
);
6967 hwnd2
= (HWND
)hevent
;
6969 hthread
= CreateThread(NULL
, 0, mouse_ll_global_thread_proc
, &hwnd2
, 0, &tid
);
6970 ok(hthread
!= NULL
, "CreateThread failed, error %d\n", GetLastError());
6972 while (WaitForSingleObject(hevent
, 100) == WAIT_TIMEOUT
)
6973 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
6975 ok_sequence(WmMouseLLHookSeq
, "MOUSE_LL hook other thread", FALSE
);
6978 mouse_event(MOUSEEVENTF_MOVE
, -1, 0, 0, 0);
6979 mouse_event(MOUSEEVENTF_LEFTUP
, 0, 0, 0, 0);
6980 mouse_event(MOUSEEVENTF_MOVE
, 1, 0, 0, 0);
6982 ok_sequence(WmMouseLLHookSeq
, "MOUSE_LL hook same thread", FALSE
);
6984 ret
= UnhookWindowsHookEx(hCBT_global_hook
);
6985 ok( ret
, "UnhookWindowsHookEx error %d\n", GetLastError());
6987 PostThreadMessageA(tid
, WM_QUIT
, 0, 0);
6988 ok(WaitForSingleObject(hthread
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
6989 CloseHandle(hthread
);
6990 CloseHandle(hevent
);
6991 ok(!IsWindow(hwnd2
), "window should be destroyed on thread exit\n");
6992 /****** end of MOUSE_LL hook test *************/
6993 skip_mouse_ll_hook_test
:
6995 ok(DestroyWindow(hwnd
), "failed to destroy window\n");
6998 static void test_set_hook(void)
7002 HWINEVENTHOOK hwinevent_hook
;
7003 HMODULE user32
= GetModuleHandleA("user32.dll");
7004 FARPROC pSetWinEventHook
= GetProcAddress(user32
, "SetWinEventHook");
7005 FARPROC pUnhookWinEvent
= GetProcAddress(user32
, "UnhookWinEvent");
7007 hhook
= SetWindowsHookExA(WH_CBT
, cbt_hook_proc
, GetModuleHandleA(0), GetCurrentThreadId());
7008 ok(hhook
!= 0, "local hook does not require hModule set to 0\n");
7009 UnhookWindowsHookEx(hhook
);
7013 /* this test doesn't pass under Win9x: BUG! */
7014 SetLastError(0xdeadbeef);
7015 hhook
= SetWindowsHookExA(WH_CBT
, cbt_hook_proc
, 0, 0);
7016 ok(!hhook
, "global hook requires hModule != 0\n");
7017 ok(GetLastError() == ERROR_HOOK_NEEDS_HMOD
, "unexpected error %d\n", GetLastError());
7020 SetLastError(0xdeadbeef);
7021 hhook
= SetWindowsHookExA(WH_CBT
, 0, GetModuleHandleA(0), GetCurrentThreadId());
7022 ok(!hhook
, "SetWinEventHook with invalid proc should fail\n");
7023 ok(GetLastError() == ERROR_INVALID_FILTER_PROC
|| /* Win2k */
7024 GetLastError() == 0xdeadbeef, /* Win9x */
7025 "unexpected error %d\n", GetLastError());
7027 SetLastError(0xdeadbeef);
7028 ok(!UnhookWindowsHookEx((HHOOK
)0xdeadbeef), "UnhookWindowsHookEx succeeded\n");
7029 ok(GetLastError() == ERROR_INVALID_HOOK_HANDLE
|| /* Win2k */
7030 GetLastError() == 0xdeadbeef, /* Win9x */
7031 "unexpected error %d\n", GetLastError());
7033 if (!pSetWinEventHook
|| !pUnhookWinEvent
) return;
7035 /* even process local incontext hooks require hmodule */
7036 SetLastError(0xdeadbeef);
7037 hwinevent_hook
= (HWINEVENTHOOK
)pSetWinEventHook(EVENT_MIN
, EVENT_MAX
,
7038 0, win_event_proc
, GetCurrentProcessId(), 0, WINEVENT_INCONTEXT
);
7039 ok(!hwinevent_hook
, "WINEVENT_INCONTEXT requires hModule != 0\n");
7040 ok(GetLastError() == ERROR_HOOK_NEEDS_HMOD
|| /* Win2k */
7041 GetLastError() == 0xdeadbeef, /* Win9x */
7042 "unexpected error %d\n", GetLastError());
7044 /* even thread local incontext hooks require hmodule */
7045 SetLastError(0xdeadbeef);
7046 hwinevent_hook
= (HWINEVENTHOOK
)pSetWinEventHook(EVENT_MIN
, EVENT_MAX
,
7047 0, win_event_proc
, GetCurrentProcessId(), GetCurrentThreadId(), WINEVENT_INCONTEXT
);
7048 ok(!hwinevent_hook
, "WINEVENT_INCONTEXT requires hModule != 0\n");
7049 ok(GetLastError() == ERROR_HOOK_NEEDS_HMOD
|| /* Win2k */
7050 GetLastError() == 0xdeadbeef, /* Win9x */
7051 "unexpected error %d\n", GetLastError());
7055 /* these 3 tests don't pass under Win9x */
7056 SetLastError(0xdeadbeef);
7057 hwinevent_hook
= (HWINEVENTHOOK
)pSetWinEventHook(1, 0,
7058 0, win_event_proc
, GetCurrentProcessId(), 0, WINEVENT_OUTOFCONTEXT
);
7059 ok(!hwinevent_hook
, "SetWinEventHook with invalid event range should fail\n");
7060 ok(GetLastError() == ERROR_INVALID_HOOK_FILTER
, "unexpected error %d\n", GetLastError());
7062 SetLastError(0xdeadbeef);
7063 hwinevent_hook
= (HWINEVENTHOOK
)pSetWinEventHook(-1, 1,
7064 0, win_event_proc
, GetCurrentProcessId(), 0, WINEVENT_OUTOFCONTEXT
);
7065 ok(!hwinevent_hook
, "SetWinEventHook with invalid event range should fail\n");
7066 ok(GetLastError() == ERROR_INVALID_HOOK_FILTER
, "unexpected error %d\n", GetLastError());
7068 SetLastError(0xdeadbeef);
7069 hwinevent_hook
= (HWINEVENTHOOK
)pSetWinEventHook(EVENT_MIN
, EVENT_MAX
,
7070 0, win_event_proc
, 0, 0xdeadbeef, WINEVENT_OUTOFCONTEXT
);
7071 ok(!hwinevent_hook
, "SetWinEventHook with invalid tid should fail\n");
7072 ok(GetLastError() == ERROR_INVALID_THREAD_ID
, "unexpected error %d\n", GetLastError());
7075 SetLastError(0xdeadbeef);
7076 hwinevent_hook
= (HWINEVENTHOOK
)pSetWinEventHook(0, 0,
7077 0, win_event_proc
, GetCurrentProcessId(), 0, WINEVENT_OUTOFCONTEXT
);
7078 ok(hwinevent_hook
!= 0, "SetWinEventHook error %d\n", GetLastError());
7079 ok(GetLastError() == 0xdeadbeef, "unexpected error %d\n", GetLastError());
7080 ret
= pUnhookWinEvent(hwinevent_hook
);
7081 ok( ret
, "UnhookWinEvent error %d\n", GetLastError());
7084 /* This call succeeds under win2k SP4, but fails under Wine.
7085 Does win2k test/use passed process id? */
7086 SetLastError(0xdeadbeef);
7087 hwinevent_hook
= (HWINEVENTHOOK
)pSetWinEventHook(EVENT_MIN
, EVENT_MAX
,
7088 0, win_event_proc
, 0xdeadbeef, 0, WINEVENT_OUTOFCONTEXT
);
7089 ok(hwinevent_hook
!= 0, "SetWinEventHook error %d\n", GetLastError());
7090 ok(GetLastError() == 0xdeadbeef, "unexpected error %d\n", GetLastError());
7091 ret
= pUnhookWinEvent(hwinevent_hook
);
7092 ok( ret
, "UnhookWinEvent error %d\n", GetLastError());
7095 SetLastError(0xdeadbeef);
7096 ok(!pUnhookWinEvent((HWINEVENTHOOK
)0xdeadbeef), "UnhookWinEvent succeeded\n");
7097 ok(GetLastError() == ERROR_INVALID_HANDLE
|| /* Win2k */
7098 GetLastError() == 0xdeadbeef, /* Win9x */
7099 "unexpected error %d\n", GetLastError());
7102 static const struct message ScrollWindowPaint1
[] = {
7104 { WM_ERASEBKGND
, sent
|beginpaint
},
7108 static const struct message ScrollWindowPaint2
[] = {
7113 static void test_scrollwindowex(void)
7116 RECT rect
={0,0,130,130};
7119 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test Scroll",
7120 WS_VISIBLE
|WS_OVERLAPPEDWINDOW
,
7121 100, 100, 200, 200, 0, 0, 0, NULL
);
7122 ok (hwnd
!= 0, "Failed to create overlapped window\n");
7123 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child",
7124 WS_VISIBLE
|WS_CAPTION
|WS_CHILD
,
7125 10, 10, 150, 150, hwnd
, 0, 0, NULL
);
7126 ok (hchild
!= 0, "Failed to create child\n");
7131 /* scroll without the child window */
7132 trace("start scroll\n");
7133 ScrollWindowEx( hwnd
, 10, 10, &rect
, NULL
, NULL
, NULL
,
7134 SW_ERASE
|SW_INVALIDATE
);
7135 ok_sequence(WmEmptySeq
, "ScrollWindowEx", 0);
7136 trace("end scroll\n");
7138 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
7139 ok_sequence(ScrollWindowPaint1
, "ScrollWindowEx", 0);
7143 /* Now without the SW_ERASE flag */
7144 trace("start scroll\n");
7145 ScrollWindowEx( hwnd
, 10, 10, &rect
, NULL
, NULL
, NULL
, SW_INVALIDATE
);
7146 ok_sequence(WmEmptySeq
, "ScrollWindowEx", 0);
7147 trace("end scroll\n");
7149 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
7150 ok_sequence(ScrollWindowPaint2
, "ScrollWindowEx", 0);
7154 /* now scroll the child window as well */
7155 trace("start scroll\n");
7156 ScrollWindowEx( hwnd
, 10, 10, &rect
, NULL
, NULL
, NULL
,
7157 SW_SCROLLCHILDREN
|SW_ERASE
|SW_INVALIDATE
);
7158 todo_wine
{ /* wine sends WM_POSCHANGING, WM_POSCHANGED messages */
7159 /* windows sometimes a WM_MOVE */
7160 ok_sequence(WmEmptySeq
, "ScrollWindowEx", 0);
7162 trace("end scroll\n");
7164 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
7165 ok_sequence(ScrollWindowPaint1
, "ScrollWindowEx", 0);
7169 /* now scroll with ScrollWindow() */
7170 trace("start scroll with ScrollWindow\n");
7171 ScrollWindow( hwnd
, 5, 5, NULL
, NULL
);
7172 trace("end scroll\n");
7174 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
7175 ok_sequence(ScrollWindowPaint1
, "ScrollWindow", 0);
7177 ok(DestroyWindow(hchild
), "failed to destroy window\n");
7178 ok(DestroyWindow(hwnd
), "failed to destroy window\n");
7182 static const struct message destroy_window_with_children
[] = {
7183 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* popup */
7184 { HCBT_DESTROYWND
, hook
|lparam
, 0, WND_PARENT_ID
}, /* parent */
7185 { HCBT_DESTROYWND
, hook
|lparam
, 0, WND_POPUP_ID
}, /* popup */
7186 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* popup */
7187 { WM_DESTROY
, sent
|wparam
|lparam
, 0, WND_POPUP_ID
}, /* popup */
7188 { WM_CAPTURECHANGED
, sent
|wparam
|lparam
, 0, WND_POPUP_ID
}, /* popup */
7189 { WM_NCDESTROY
, sent
|wparam
|lparam
, 0, WND_POPUP_ID
}, /* popup */
7190 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* parent */
7191 { WM_DESTROY
, sent
|wparam
|lparam
, 0, WND_PARENT_ID
}, /* parent */
7192 { WM_DESTROY
, sent
|wparam
|lparam
, 0, WND_CHILD_ID
+ 2 }, /* child2 */
7193 { WM_DESTROY
, sent
|wparam
|lparam
, 0, WND_CHILD_ID
+ 1 }, /* child1 */
7194 { WM_DESTROY
, sent
|wparam
|lparam
, 0, WND_CHILD_ID
+ 3 }, /* child3 */
7195 { WM_NCDESTROY
, sent
|wparam
|lparam
, 0, WND_CHILD_ID
+ 2 }, /* child2 */
7196 { WM_NCDESTROY
, sent
|wparam
|lparam
, 0, WND_CHILD_ID
+ 3 }, /* child3 */
7197 { WM_NCDESTROY
, sent
|wparam
|lparam
, 0, WND_CHILD_ID
+ 1 }, /* child1 */
7198 { WM_NCDESTROY
, sent
|wparam
|lparam
, 0, WND_PARENT_ID
}, /* parent */
7202 static void test_DestroyWindow(void)
7205 HWND parent
, child1
, child2
, child3
, child4
, test
;
7206 UINT child_id
= WND_CHILD_ID
+ 1;
7208 parent
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
7209 100, 100, 200, 200, 0, 0, 0, NULL
);
7210 assert(parent
!= 0);
7211 child1
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_CHILD
,
7212 0, 0, 50, 50, parent
, (HMENU
)child_id
++, 0, NULL
);
7213 assert(child1
!= 0);
7214 child2
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_CHILD
,
7215 0, 0, 50, 50, GetDesktopWindow(), (HMENU
)child_id
++, 0, NULL
);
7216 assert(child2
!= 0);
7217 child3
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_CHILD
,
7218 0, 0, 50, 50, child1
, (HMENU
)child_id
++, 0, NULL
);
7219 assert(child3
!= 0);
7220 child4
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_POPUP
,
7221 0, 0, 50, 50, parent
, 0, 0, NULL
);
7222 assert(child4
!= 0);
7224 /* test owner/parent of child2 */
7225 test
= GetParent(child2
);
7226 ok(test
== GetDesktopWindow(), "wrong parent %p\n", test
);
7227 ok(!IsChild(parent
, child2
), "wrong parent/child %p/%p\n", parent
, child2
);
7229 test
= pGetAncestor(child2
, GA_PARENT
);
7230 ok(test
== GetDesktopWindow(), "wrong parent %p\n", test
);
7232 test
= GetWindow(child2
, GW_OWNER
);
7233 ok(!test
, "wrong owner %p\n", test
);
7235 test
= SetParent(child2
, parent
);
7236 ok(test
== GetDesktopWindow(), "wrong old parent %p\n", test
);
7238 /* test owner/parent of the parent */
7239 test
= GetParent(parent
);
7240 ok(!test
, "wrong parent %p\n", test
);
7242 ok(!IsChild(GetDesktopWindow(), parent
), "wrong parent/child %p/%p\n", GetDesktopWindow(), parent
);
7245 test
= pGetAncestor(parent
, GA_PARENT
);
7246 ok(test
== GetDesktopWindow(), "wrong parent %p\n", test
);
7248 test
= GetWindow(parent
, GW_OWNER
);
7249 ok(!test
, "wrong owner %p\n", test
);
7251 /* test owner/parent of child1 */
7252 test
= GetParent(child1
);
7253 ok(test
== parent
, "wrong parent %p\n", test
);
7254 ok(IsChild(parent
, child1
), "wrong parent/child %p/%p\n", parent
, child1
);
7256 test
= pGetAncestor(child1
, GA_PARENT
);
7257 ok(test
== parent
, "wrong parent %p\n", test
);
7259 test
= GetWindow(child1
, GW_OWNER
);
7260 ok(!test
, "wrong owner %p\n", test
);
7262 /* test owner/parent of child2 */
7263 test
= GetParent(child2
);
7264 ok(test
== parent
, "wrong parent %p\n", test
);
7265 ok(IsChild(parent
, child2
), "wrong parent/child %p/%p\n", parent
, child2
);
7267 test
= pGetAncestor(child2
, GA_PARENT
);
7268 ok(test
== parent
, "wrong parent %p\n", test
);
7270 test
= GetWindow(child2
, GW_OWNER
);
7271 ok(!test
, "wrong owner %p\n", test
);
7273 /* test owner/parent of child3 */
7274 test
= GetParent(child3
);
7275 ok(test
== child1
, "wrong parent %p\n", test
);
7276 ok(IsChild(parent
, child3
), "wrong parent/child %p/%p\n", parent
, child3
);
7278 test
= pGetAncestor(child3
, GA_PARENT
);
7279 ok(test
== child1
, "wrong parent %p\n", test
);
7281 test
= GetWindow(child3
, GW_OWNER
);
7282 ok(!test
, "wrong owner %p\n", test
);
7284 /* test owner/parent of child4 */
7285 test
= GetParent(child4
);
7286 ok(test
== parent
, "wrong parent %p\n", test
);
7287 ok(!IsChild(parent
, child4
), "wrong parent/child %p/%p\n", parent
, child4
);
7289 test
= pGetAncestor(child4
, GA_PARENT
);
7290 ok(test
== GetDesktopWindow(), "wrong parent %p\n", test
);
7292 test
= GetWindow(child4
, GW_OWNER
);
7293 ok(test
== parent
, "wrong owner %p\n", test
);
7297 trace("parent %p, child1 %p, child2 %p, child3 %p, child4 %p\n",
7298 parent
, child1
, child2
, child3
, child4
);
7301 test
= GetCapture();
7302 ok(test
== child4
, "wrong capture window %p\n", test
);
7304 test_DestroyWindow_flag
= TRUE
;
7305 ret
= DestroyWindow(parent
);
7306 ok( ret
, "DestroyWindow() error %d\n", GetLastError());
7307 test_DestroyWindow_flag
= FALSE
;
7308 ok_sequence(destroy_window_with_children
, "destroy window with children", 0);
7310 ok(!IsWindow(parent
), "parent still exists\n");
7311 ok(!IsWindow(child1
), "child1 still exists\n");
7312 ok(!IsWindow(child2
), "child2 still exists\n");
7313 ok(!IsWindow(child3
), "child3 still exists\n");
7314 ok(!IsWindow(child4
), "child4 still exists\n");
7316 test
= GetCapture();
7317 ok(!test
, "wrong capture window %p\n", test
);
7321 static const struct message WmDispatchPaint
[] = {
7322 { WM_NCPAINT
, sent
},
7323 { WM_GETTEXT
, sent
|defwinproc
|optional
},
7324 { WM_GETTEXT
, sent
|defwinproc
|optional
},
7325 { WM_ERASEBKGND
, sent
},
7329 static LRESULT WINAPI
DispatchMessageCheckProc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
7331 if (message
== WM_PAINT
) return 0;
7332 return MsgCheckProcA( hwnd
, message
, wParam
, lParam
);
7335 static void test_DispatchMessage(void)
7340 HWND hwnd
= CreateWindowA( "TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
7341 100, 100, 200, 200, 0, 0, 0, NULL
);
7342 ShowWindow( hwnd
, SW_SHOW
);
7343 UpdateWindow( hwnd
);
7344 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
7346 SetWindowLongPtrA( hwnd
, GWLP_WNDPROC
, (LONG_PTR
)DispatchMessageCheckProc
);
7348 SetRect( &rect
, -5, -5, 5, 5 );
7349 RedrawWindow( hwnd
, &rect
, 0, RDW_INVALIDATE
|RDW_ERASE
|RDW_FRAME
);
7351 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
))
7353 if (msg
.message
!= WM_PAINT
) DispatchMessage( &msg
);
7357 DispatchMessage( &msg
);
7358 /* DispatchMessage will send WM_NCPAINT if non client area is still invalid after WM_PAINT */
7359 if (!count
) ok_sequence( WmDispatchPaint
, "WmDispatchPaint", FALSE
);
7360 else ok_sequence( WmEmptySeq
, "WmEmpty", FALSE
);
7361 if (++count
> 10) break;
7364 ok( msg
.message
== WM_PAINT
&& count
> 10, "WM_PAINT messages stopped\n" );
7366 trace("now without DispatchMessage\n");
7368 RedrawWindow( hwnd
, &rect
, 0, RDW_INVALIDATE
|RDW_ERASE
|RDW_FRAME
);
7370 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
))
7372 if (msg
.message
!= WM_PAINT
) DispatchMessage( &msg
);
7375 HRGN hrgn
= CreateRectRgn( 0, 0, 0, 0 );
7377 /* this will send WM_NCCPAINT just like DispatchMessage does */
7378 GetUpdateRgn( hwnd
, hrgn
, TRUE
);
7379 ok_sequence( WmDispatchPaint
, "WmDispatchPaint", FALSE
);
7380 DeleteObject( hrgn
);
7381 GetClientRect( hwnd
, &rect
);
7382 ValidateRect( hwnd
, &rect
); /* this will stop WM_PAINTs */
7383 ok( !count
, "Got multiple WM_PAINTs\n" );
7384 if (++count
> 10) break;
7387 DestroyWindow(hwnd
);
7391 static const struct message WmUser
[] = {
7403 static DWORD CALLBACK
send_msg_thread( LPVOID arg
)
7405 struct sendmsg_info
*info
= arg
;
7406 info
->ret
= SendMessageTimeoutA( info
->hwnd
, WM_USER
, 0, 0, 0, info
->timeout
, NULL
);
7407 if (!info
->ret
) ok( GetLastError() == ERROR_TIMEOUT
, "unexpected error %d\n", GetLastError());
7411 static void wait_for_thread( HANDLE thread
)
7413 while (MsgWaitForMultipleObjects(1, &thread
, FALSE
, INFINITE
, QS_SENDMESSAGE
) != WAIT_OBJECT_0
)
7416 while (PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage(&msg
);
7420 static LRESULT WINAPI
send_msg_delay_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
7422 if (message
== WM_USER
) Sleep(200);
7423 return MsgCheckProcA( hwnd
, message
, wParam
, lParam
);
7426 static void test_SendMessageTimeout(void)
7430 struct sendmsg_info info
;
7433 info
.hwnd
= CreateWindowA( "TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
7434 100, 100, 200, 200, 0, 0, 0, NULL
);
7435 while (PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
7438 info
.timeout
= 1000;
7439 info
.ret
= 0xdeadbeef;
7440 thread
= CreateThread( NULL
, 0, send_msg_thread
, &info
, 0, &tid
);
7441 wait_for_thread( thread
);
7442 CloseHandle( thread
);
7443 ok( info
.ret
== 1, "SendMessageTimeout failed\n" );
7444 ok_sequence( WmUser
, "WmUser", FALSE
);
7447 info
.ret
= 0xdeadbeef;
7448 thread
= CreateThread( NULL
, 0, send_msg_thread
, &info
, 0, &tid
);
7449 Sleep(100); /* SendMessageTimeout should timeout here */
7450 wait_for_thread( thread
);
7451 CloseHandle( thread
);
7452 ok( info
.ret
== 0, "SendMessageTimeout succeeded\n" );
7453 ok_sequence( WmEmptySeq
, "WmEmptySeq", FALSE
);
7455 /* 0 means infinite timeout */
7457 info
.ret
= 0xdeadbeef;
7458 thread
= CreateThread( NULL
, 0, send_msg_thread
, &info
, 0, &tid
);
7460 wait_for_thread( thread
);
7461 CloseHandle( thread
);
7462 ok( info
.ret
== 1, "SendMessageTimeout failed\n" );
7463 ok_sequence( WmUser
, "WmUser", FALSE
);
7465 /* timeout is treated as signed despite the prototype */
7466 info
.timeout
= 0x7fffffff;
7467 info
.ret
= 0xdeadbeef;
7468 thread
= CreateThread( NULL
, 0, send_msg_thread
, &info
, 0, &tid
);
7470 wait_for_thread( thread
);
7471 CloseHandle( thread
);
7472 ok( info
.ret
== 1, "SendMessageTimeout failed\n" );
7473 ok_sequence( WmUser
, "WmUser", FALSE
);
7475 info
.timeout
= 0x80000000;
7476 info
.ret
= 0xdeadbeef;
7477 thread
= CreateThread( NULL
, 0, send_msg_thread
, &info
, 0, &tid
);
7479 wait_for_thread( thread
);
7480 CloseHandle( thread
);
7481 ok( info
.ret
== 0, "SendMessageTimeout succeeded\n" );
7482 ok_sequence( WmEmptySeq
, "WmEmptySeq", FALSE
);
7484 /* now check for timeout during message processing */
7485 SetWindowLongPtrA( info
.hwnd
, GWLP_WNDPROC
, (LONG_PTR
)send_msg_delay_proc
);
7487 info
.ret
= 0xdeadbeef;
7488 thread
= CreateThread( NULL
, 0, send_msg_thread
, &info
, 0, &tid
);
7489 wait_for_thread( thread
);
7490 CloseHandle( thread
);
7491 /* we should timeout but still get the message */
7492 ok( info
.ret
== 0, "SendMessageTimeout failed\n" );
7493 ok_sequence( WmUser
, "WmUser", FALSE
);
7495 DestroyWindow( info
.hwnd
);
7499 /****************** edit message test *************************/
7500 #define ID_EDIT 0x1234
7501 static const struct message sl_edit_setfocus
[] =
7503 { HCBT_SETFOCUS
, hook
},
7504 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
7505 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
7506 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
7507 { WM_SETFOCUS
, sent
|wparam
, 0 },
7508 { WM_CTLCOLOREDIT
, sent
|parent
},
7509 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
7510 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
7511 { WM_COMMAND
, sent
|parent
|wparam
, MAKEWPARAM(ID_EDIT
, EN_SETFOCUS
) },
7514 static const struct message ml_edit_setfocus
[] =
7516 { HCBT_SETFOCUS
, hook
},
7517 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
7518 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
7519 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
7520 { WM_SETFOCUS
, sent
|wparam
, 0 },
7521 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
7522 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
7523 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
7524 { WM_COMMAND
, sent
|parent
|wparam
, MAKEWPARAM(ID_EDIT
, EN_SETFOCUS
) },
7527 static const struct message sl_edit_killfocus
[] =
7529 { HCBT_SETFOCUS
, hook
},
7530 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
7531 { WM_KILLFOCUS
, sent
|wparam
, 0 },
7532 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
7533 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
7534 { WM_COMMAND
, sent
|parent
|wparam
, MAKEWPARAM(ID_EDIT
, EN_KILLFOCUS
) },
7535 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
7536 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 1 },
7539 static const struct message sl_edit_lbutton_dblclk
[] =
7541 { WM_LBUTTONDBLCLK
, sent
},
7542 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
7545 static const struct message sl_edit_lbutton_down
[] =
7547 { WM_LBUTTONDOWN
, sent
|wparam
|lparam
, 0, 0 },
7548 { HCBT_SETFOCUS
, hook
},
7549 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
7550 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
7551 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
7552 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
7553 { WM_CTLCOLOREDIT
, sent
|parent
},
7554 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
7555 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
7556 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
7557 { WM_COMMAND
, sent
|parent
|wparam
, MAKEWPARAM(ID_EDIT
, EN_SETFOCUS
) },
7558 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
7559 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
7560 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
7561 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
7564 static const struct message ml_edit_lbutton_down
[] =
7566 { WM_LBUTTONDOWN
, sent
|wparam
|lparam
, 0, 0 },
7567 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
7568 { HCBT_SETFOCUS
, hook
},
7569 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
7570 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
7571 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
7572 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
7573 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
7574 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
7575 { WM_COMMAND
, sent
|parent
|wparam
, MAKEWPARAM(ID_EDIT
, EN_SETFOCUS
) },
7578 static const struct message sl_edit_lbutton_up
[] =
7580 { WM_LBUTTONUP
, sent
|wparam
|lparam
, 0, 0 },
7581 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
7582 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, 0, 0 },
7583 { WM_CAPTURECHANGED
, sent
|defwinproc
},
7584 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
7587 static const struct message ml_edit_lbutton_up
[] =
7589 { WM_LBUTTONUP
, sent
|wparam
|lparam
, 0, 0 },
7590 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, 0, 0 },
7591 { WM_CAPTURECHANGED
, sent
|defwinproc
},
7595 static WNDPROC old_edit_proc
;
7597 static LRESULT CALLBACK
edit_hook_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
7599 static long defwndproc_counter
= 0;
7603 trace("edit: %p, %04x, %08x, %08lx\n", hwnd
, message
, wParam
, lParam
);
7605 /* explicitly ignore WM_GETICON message */
7606 if (message
== WM_GETICON
) return 0;
7608 msg
.message
= message
;
7609 msg
.flags
= sent
|wparam
|lparam
;
7610 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
7611 msg
.wParam
= wParam
;
7612 msg
.lParam
= lParam
;
7615 defwndproc_counter
++;
7616 ret
= CallWindowProcA(old_edit_proc
, hwnd
, message
, wParam
, lParam
);
7617 defwndproc_counter
--;
7622 static void subclass_edit(void)
7626 if (!GetClassInfoA(0, "edit", &cls
)) assert(0);
7628 old_edit_proc
= cls
.lpfnWndProc
;
7630 cls
.hInstance
= GetModuleHandle(0);
7631 cls
.lpfnWndProc
= edit_hook_proc
;
7632 cls
.lpszClassName
= "my_edit_class";
7633 if (!RegisterClassA(&cls
)) assert(0);
7636 static void test_edit_messages(void)
7642 log_all_parent_messages
++;
7644 parent
= CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
7645 100, 100, 200, 200, 0, 0, 0, NULL
);
7646 ok (parent
!= 0, "Failed to create parent window\n");
7648 /* test single line edit */
7649 hwnd
= CreateWindowExA(0, "my_edit_class", "test", WS_CHILD
,
7650 0, 0, 80, 20, parent
, (HMENU
)ID_EDIT
, 0, NULL
);
7651 ok(hwnd
!= 0, "Failed to create edit window\n");
7653 dlg_code
= SendMessageA(hwnd
, WM_GETDLGCODE
, 0, 0);
7654 ok(dlg_code
== (DLGC_WANTCHARS
|DLGC_HASSETSEL
|DLGC_WANTARROWS
), "wrong dlg_code %08x\n", dlg_code
);
7656 ShowWindow(hwnd
, SW_SHOW
);
7662 ok_sequence(sl_edit_setfocus
, "SetFocus(hwnd) on an edit", FALSE
);
7665 ok_sequence(sl_edit_killfocus
, "SetFocus(0) on an edit", FALSE
);
7671 SendMessageA(hwnd
, WM_LBUTTONDBLCLK
, 0, 0);
7672 ok_sequence(sl_edit_lbutton_dblclk
, "WM_LBUTTONDBLCLK on an edit", FALSE
);
7678 SendMessageA(hwnd
, WM_LBUTTONDOWN
, 0, 0);
7679 ok_sequence(sl_edit_lbutton_down
, "WM_LBUTTONDOWN on an edit", FALSE
);
7681 SendMessageA(hwnd
, WM_LBUTTONUP
, 0, 0);
7682 ok_sequence(sl_edit_lbutton_up
, "WM_LBUTTONUP on an edit", FALSE
);
7684 DestroyWindow(hwnd
);
7686 /* test multiline edit */
7687 hwnd
= CreateWindowExA(0, "my_edit_class", "test", WS_CHILD
| ES_MULTILINE
,
7688 0, 0, 80, 20, parent
, (HMENU
)ID_EDIT
, 0, NULL
);
7689 ok(hwnd
!= 0, "Failed to create edit window\n");
7691 dlg_code
= SendMessageA(hwnd
, WM_GETDLGCODE
, 0, 0);
7692 ok(dlg_code
== (DLGC_WANTCHARS
|DLGC_HASSETSEL
|DLGC_WANTARROWS
|DLGC_WANTALLKEYS
),
7693 "wrong dlg_code %08x\n", dlg_code
);
7695 ShowWindow(hwnd
, SW_SHOW
);
7701 ok_sequence(ml_edit_setfocus
, "SetFocus(hwnd) on multiline edit", FALSE
);
7704 ok_sequence(sl_edit_killfocus
, "SetFocus(0) on multiline edit", FALSE
);
7710 SendMessageA(hwnd
, WM_LBUTTONDBLCLK
, 0, 0);
7711 ok_sequence(sl_edit_lbutton_dblclk
, "WM_LBUTTONDBLCLK on multiline edit", FALSE
);
7717 SendMessageA(hwnd
, WM_LBUTTONDOWN
, 0, 0);
7718 ok_sequence(ml_edit_lbutton_down
, "WM_LBUTTONDOWN on multiline edit", FALSE
);
7720 SendMessageA(hwnd
, WM_LBUTTONUP
, 0, 0);
7721 ok_sequence(ml_edit_lbutton_up
, "WM_LBUTTONUP on multiline edit", FALSE
);
7723 DestroyWindow(hwnd
);
7724 DestroyWindow(parent
);
7726 log_all_parent_messages
--;
7729 /**************************** End of Edit test ******************************/
7731 static const struct message WmKeyDownSkippedSeq
[] =
7733 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 1 }, /* XP */
7736 static const struct message WmKeyUpSkippedSeq
[] =
7738 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xc0000001 }, /* XP */
7742 #define EV_START_STOP 0
7743 #define EV_SENDMSG 1
7749 HANDLE hevent
[3]; /* 0 - start/stop, 1 - SendMessage, 2 - ack */
7752 static DWORD CALLBACK
send_msg_thread_2(void *param
)
7755 struct peekmsg_info
*info
= param
;
7757 trace("thread: waiting for start\n");
7758 WaitForSingleObject(info
->hevent
[EV_START_STOP
], INFINITE
);
7759 trace("thread: looping\n");
7763 ret
= WaitForMultipleObjects(2, info
->hevent
, FALSE
, INFINITE
);
7767 case WAIT_OBJECT_0
+ EV_START_STOP
:
7768 trace("thread: exiting\n");
7771 case WAIT_OBJECT_0
+ EV_SENDMSG
:
7772 trace("thread: sending message\n");
7773 SendNotifyMessageA(info
->hwnd
, WM_USER
, 0, 0);
7774 SetEvent(info
->hevent
[EV_ACK
]);
7778 trace("unexpected return: %04x\n", ret
);
7786 static void test_PeekMessage(void)
7791 UINT qs_all_input
= QS_ALLINPUT
;
7792 UINT qs_input
= QS_INPUT
;
7794 struct peekmsg_info info
;
7796 info
.hwnd
= CreateWindowA("TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
7797 100, 100, 200, 200, 0, 0, 0, NULL
);
7799 ShowWindow(info
.hwnd
, SW_SHOW
);
7800 UpdateWindow(info
.hwnd
);
7801 SetFocus(info
.hwnd
);
7803 info
.hevent
[EV_START_STOP
] = CreateEventA(NULL
, 0, 0, NULL
);
7804 info
.hevent
[EV_SENDMSG
] = CreateEventA(NULL
, 0, 0, NULL
);
7805 info
.hevent
[EV_ACK
] = CreateEventA(NULL
, 0, 0, NULL
);
7807 hthread
= CreateThread(NULL
, 0, send_msg_thread_2
, &info
, 0, &tid
);
7810 trace("signalling to start looping\n");
7811 SetEvent(info
.hevent
[EV_START_STOP
]);
7813 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
7816 SetLastError(0xdeadbeef);
7817 qstatus
= GetQueueStatus(qs_all_input
);
7818 if (GetLastError() == ERROR_INVALID_FLAGS
)
7820 trace("QS_RAWINPUT not supported on this platform\n");
7821 qs_all_input
&= ~QS_RAWINPUT
;
7822 qs_input
&= ~QS_RAWINPUT
;
7824 ok(qstatus
== 0, "wrong qstatus %08x\n", qstatus
);
7826 trace("signalling to send message\n");
7827 SetEvent(info
.hevent
[EV_SENDMSG
]);
7828 WaitForSingleObject(info
.hevent
[EV_ACK
], INFINITE
);
7830 /* pass invalid QS_xxxx flags */
7831 SetLastError(0xdeadbeef);
7832 qstatus
= GetQueueStatus(0xffffffff);
7833 ok(qstatus
== 0, "GetQueueStatus should fail: %08x\n", qstatus
);
7834 ok(GetLastError() == ERROR_INVALID_FLAGS
, "wrong error %d\n", GetLastError());
7836 qstatus
= GetQueueStatus(qs_all_input
);
7837 ok(qstatus
== MAKELONG(QS_SENDMESSAGE
, QS_SENDMESSAGE
),
7838 "wrong qstatus %08x\n", qstatus
);
7841 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
7843 "PeekMessageA should have returned FALSE instead of msg %04x\n",
7845 ok_sequence(WmUser
, "WmUser", FALSE
);
7847 qstatus
= GetQueueStatus(qs_all_input
);
7848 ok(qstatus
== 0, "wrong qstatus %08x\n", qstatus
);
7850 keybd_event('N', 0, 0, 0);
7851 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
7852 qstatus
= GetQueueStatus(qs_all_input
);
7853 ok(qstatus
== MAKELONG(QS_KEY
, QS_KEY
),
7854 "wrong qstatus %08x\n", qstatus
);
7856 PostMessageA(info
.hwnd
, WM_CHAR
, 'z', 0);
7857 qstatus
= GetQueueStatus(qs_all_input
);
7858 ok(qstatus
== MAKELONG(QS_POSTMESSAGE
, QS_POSTMESSAGE
|QS_KEY
),
7859 "wrong qstatus %08x\n", qstatus
);
7861 InvalidateRect(info
.hwnd
, NULL
, FALSE
);
7862 qstatus
= GetQueueStatus(qs_all_input
);
7863 ok(qstatus
== MAKELONG(QS_PAINT
, QS_PAINT
|QS_POSTMESSAGE
|QS_KEY
),
7864 "wrong qstatus %08x\n", qstatus
);
7866 trace("signalling to send message\n");
7867 SetEvent(info
.hevent
[EV_SENDMSG
]);
7868 WaitForSingleObject(info
.hevent
[EV_ACK
], INFINITE
);
7870 qstatus
= GetQueueStatus(qs_all_input
);
7871 ok(qstatus
== MAKELONG(QS_SENDMESSAGE
, QS_SENDMESSAGE
|QS_PAINT
|QS_POSTMESSAGE
|QS_KEY
),
7872 "wrong qstatus %08x\n", qstatus
);
7875 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| (qs_input
<< 16));
7878 "PeekMessageA should have returned FALSE instead of msg %04x\n",
7881 ok_sequence(WmUser
, "WmUser", FALSE
);
7883 qstatus
= GetQueueStatus(qs_all_input
);
7885 ok(qstatus
== MAKELONG(0, QS_PAINT
|QS_POSTMESSAGE
|QS_KEY
),
7886 "wrong qstatus %08x\n", qstatus
);
7889 trace("signalling to send message\n");
7890 SetEvent(info
.hevent
[EV_SENDMSG
]);
7891 WaitForSingleObject(info
.hevent
[EV_ACK
], INFINITE
);
7893 qstatus
= GetQueueStatus(qs_all_input
);
7895 ok(qstatus
== MAKELONG(QS_SENDMESSAGE
, QS_SENDMESSAGE
|QS_PAINT
|QS_POSTMESSAGE
|QS_KEY
),
7896 "wrong qstatus %08x\n", qstatus
);
7900 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| PM_QS_POSTMESSAGE
);
7903 "PeekMessageA should have returned FALSE instead of msg %04x\n",
7906 ok_sequence(WmUser
, "WmUser", FALSE
);
7908 qstatus
= GetQueueStatus(qs_all_input
);
7910 ok(qstatus
== MAKELONG(0, QS_PAINT
|QS_POSTMESSAGE
|QS_KEY
),
7911 "wrong qstatus %08x\n", qstatus
);
7915 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| PM_QS_POSTMESSAGE
);
7917 ok(ret
&& msg
.message
== WM_CHAR
&& msg
.wParam
== 'z',
7918 "got %d and %04x wParam %08x instead of TRUE and WM_CHAR wParam 'z'\n",
7919 ret
, msg
.message
, msg
.wParam
);
7921 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
7923 qstatus
= GetQueueStatus(qs_all_input
);
7925 ok(qstatus
== MAKELONG(0, QS_PAINT
|QS_KEY
),
7926 "wrong qstatus %08x\n", qstatus
);
7930 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| PM_QS_POSTMESSAGE
);
7933 "PeekMessageA should have returned FALSE instead of msg %04x\n",
7936 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
7938 qstatus
= GetQueueStatus(qs_all_input
);
7940 ok(qstatus
== MAKELONG(0, QS_PAINT
|QS_KEY
),
7941 "wrong qstatus %08x\n", qstatus
);
7945 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| PM_QS_PAINT
);
7946 ok(ret
&& msg
.message
== WM_PAINT
,
7947 "got %d and %04x instead of TRUE and WM_PAINT\n", ret
, msg
.message
);
7948 DispatchMessageA(&msg
);
7949 ok_sequence(WmPaint
, "WmPaint", FALSE
);
7951 qstatus
= GetQueueStatus(qs_all_input
);
7953 ok(qstatus
== MAKELONG(0, QS_KEY
),
7954 "wrong qstatus %08x\n", qstatus
);
7958 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| PM_QS_PAINT
);
7960 "PeekMessageA should have returned FALSE instead of msg %04x\n",
7962 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
7964 qstatus
= GetQueueStatus(qs_all_input
);
7966 ok(qstatus
== MAKELONG(0, QS_KEY
),
7967 "wrong qstatus %08x\n", qstatus
);
7970 trace("signalling to send message\n");
7971 SetEvent(info
.hevent
[EV_SENDMSG
]);
7972 WaitForSingleObject(info
.hevent
[EV_ACK
], INFINITE
);
7974 qstatus
= GetQueueStatus(qs_all_input
);
7976 ok(qstatus
== MAKELONG(QS_SENDMESSAGE
, QS_SENDMESSAGE
|QS_KEY
),
7977 "wrong qstatus %08x\n", qstatus
);
7980 PostMessageA(info
.hwnd
, WM_CHAR
, 'z', 0);
7982 qstatus
= GetQueueStatus(qs_all_input
);
7984 ok(qstatus
== MAKELONG(QS_POSTMESSAGE
, QS_SENDMESSAGE
|QS_POSTMESSAGE
|QS_KEY
),
7985 "wrong qstatus %08x\n", qstatus
);
7989 ret
= PeekMessageA(&msg
, 0, WM_CHAR
, WM_CHAR
, PM_REMOVE
);
7990 ok(ret
&& msg
.message
== WM_CHAR
&& msg
.wParam
== 'z',
7991 "got %d and %04x wParam %08x instead of TRUE and WM_CHAR wParam 'z'\n",
7992 ret
, msg
.message
, msg
.wParam
);
7993 ok_sequence(WmUser
, "WmUser", FALSE
);
7995 qstatus
= GetQueueStatus(qs_all_input
);
7997 ok(qstatus
== MAKELONG(0, QS_KEY
),
7998 "wrong qstatus %08x\n", qstatus
);
8002 ret
= PeekMessageA(&msg
, 0, WM_CHAR
, WM_CHAR
, PM_REMOVE
);
8004 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8006 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
8008 qstatus
= GetQueueStatus(qs_all_input
);
8010 ok(qstatus
== MAKELONG(0, QS_KEY
),
8011 "wrong qstatus %08x\n", qstatus
);
8014 PostMessageA(info
.hwnd
, WM_CHAR
, 'z', 0);
8016 qstatus
= GetQueueStatus(qs_all_input
);
8018 ok(qstatus
== MAKELONG(QS_POSTMESSAGE
, QS_POSTMESSAGE
|QS_KEY
),
8019 "wrong qstatus %08x\n", qstatus
);
8022 trace("signalling to send message\n");
8023 SetEvent(info
.hevent
[EV_SENDMSG
]);
8024 WaitForSingleObject(info
.hevent
[EV_ACK
], INFINITE
);
8026 qstatus
= GetQueueStatus(qs_all_input
);
8028 ok(qstatus
== MAKELONG(QS_SENDMESSAGE
, QS_SENDMESSAGE
|QS_POSTMESSAGE
|QS_KEY
),
8029 "wrong qstatus %08x\n", qstatus
);
8033 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| (QS_KEY
<< 16));
8036 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8039 ok_sequence(WmUser
, "WmUser", FALSE
);
8041 qstatus
= GetQueueStatus(qs_all_input
);
8043 ok(qstatus
== MAKELONG(0, QS_POSTMESSAGE
|QS_KEY
),
8044 "wrong qstatus %08x\n", qstatus
);
8048 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| (QS_RAWINPUT
<< 16));
8050 ok(ret
&& msg
.message
== WM_KEYDOWN
&& msg
.wParam
== 'N',
8051 "got %d and %04x wParam %08x instead of TRUE and WM_KEYDOWN wParam 'N'\n",
8052 ret
, msg
.message
, msg
.wParam
);
8053 ok_sequence(WmKeyDownSkippedSeq
, "WmKeyDownSkippedSeq", FALSE
);
8056 qstatus
= GetQueueStatus(qs_all_input
);
8058 ok(qstatus
== MAKELONG(0, QS_POSTMESSAGE
|QS_KEY
),
8059 "wrong qstatus %08x\n", qstatus
);
8063 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| (QS_RAWINPUT
<< 16));
8065 ok(ret
&& msg
.message
== WM_KEYUP
&& msg
.wParam
== 'N',
8066 "got %d and %04x wParam %08x instead of TRUE and WM_KEYUP wParam 'N'\n",
8067 ret
, msg
.message
, msg
.wParam
);
8068 ok_sequence(WmKeyUpSkippedSeq
, "WmKeyUpSkippedSeq", FALSE
);
8071 qstatus
= GetQueueStatus(qs_all_input
);
8073 ok(qstatus
== MAKELONG(0, QS_POSTMESSAGE
),
8074 "wrong qstatus %08x\n", qstatus
);
8078 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| PM_QS_SENDMESSAGE
);
8080 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8082 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
8084 qstatus
= GetQueueStatus(qs_all_input
);
8086 ok(qstatus
== MAKELONG(0, QS_POSTMESSAGE
),
8087 "wrong qstatus %08x\n", qstatus
);
8091 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
8093 ok(ret
&& msg
.message
== WM_CHAR
&& msg
.wParam
== 'z',
8094 "got %d and %04x wParam %08x instead of TRUE and WM_CHAR wParam 'z'\n",
8095 ret
, msg
.message
, msg
.wParam
);
8097 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
8099 qstatus
= GetQueueStatus(qs_all_input
);
8101 "wrong qstatus %08x\n", qstatus
);
8104 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
8106 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8108 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
8110 qstatus
= GetQueueStatus(qs_all_input
);
8112 "wrong qstatus %08x\n", qstatus
);
8114 /* test whether presence of the quit flag in the queue affects
8117 PostQuitMessage(0x1234abcd);
8119 qstatus
= GetQueueStatus(qs_all_input
);
8120 ok(qstatus
== MAKELONG(QS_POSTMESSAGE
, QS_POSTMESSAGE
),
8121 "wrong qstatus %08x\n", qstatus
);
8123 PostMessageA(info
.hwnd
, WM_USER
, 0, 0);
8125 qstatus
= GetQueueStatus(qs_all_input
);
8126 ok(qstatus
== MAKELONG(QS_POSTMESSAGE
, QS_POSTMESSAGE
),
8127 "wrong qstatus %08x\n", qstatus
);
8130 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
8131 ok(ret
&& msg
.message
== WM_USER
,
8132 "got %d and %04x instead of TRUE and WM_USER\n", ret
, msg
.message
);
8133 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
8135 qstatus
= GetQueueStatus(qs_all_input
);
8136 ok(qstatus
== MAKELONG(0, QS_POSTMESSAGE
),
8137 "wrong qstatus %08x\n", qstatus
);
8140 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
8141 ok(ret
&& msg
.message
== WM_QUIT
,
8142 "got %d and %04x instead of TRUE and WM_QUIT\n", ret
, msg
.message
);
8143 ok(msg
.wParam
== 0x1234abcd, "got wParam %08x instead of 0x1234abcd\n", msg
.wParam
);
8144 ok(msg
.lParam
== 0, "got lParam %08lx instead of 0\n", msg
.lParam
);
8145 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
8147 qstatus
= GetQueueStatus(qs_all_input
);
8149 ok(qstatus
== MAKELONG(0, QS_POSTMESSAGE
),
8150 "wrong qstatus %08x\n", qstatus
);
8154 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
8156 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8158 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
8160 qstatus
= GetQueueStatus(qs_all_input
);
8162 "wrong qstatus %08x\n", qstatus
);
8164 trace("signalling to exit\n");
8165 SetEvent(info
.hevent
[EV_START_STOP
]);
8167 WaitForSingleObject(hthread
, INFINITE
);
8169 CloseHandle(hthread
);
8170 CloseHandle(info
.hevent
[0]);
8171 CloseHandle(info
.hevent
[1]);
8172 CloseHandle(info
.hevent
[2]);
8174 DestroyWindow(info
.hwnd
);
8178 static void test_quit_message(void)
8183 /* test using PostQuitMessage */
8184 PostQuitMessage(0xbeef);
8186 ret
= PeekMessage(&msg
, NULL
, 0, 0, PM_NOREMOVE
);
8187 ok(ret
, "PeekMessage failed with error %d\n", GetLastError());
8188 ok(msg
.message
== WM_QUIT
, "Received message 0x%04x instead of WM_QUIT\n", msg
.message
);
8189 ok(msg
.wParam
== 0xbeef, "wParam was 0x%x instead of 0xbeef\n", msg
.wParam
);
8191 ret
= PostThreadMessage(GetCurrentThreadId(), WM_USER
, 0, 0);
8192 ok(ret
, "PostMessage failed with error %d\n", GetLastError());
8194 ret
= GetMessage(&msg
, NULL
, 0, 0);
8195 ok(ret
> 0, "GetMessage failed with error %d\n", GetLastError());
8196 ok(msg
.message
== WM_USER
, "Received message 0x%04x instead of WM_USER\n", msg
.message
);
8198 /* note: WM_QUIT message received after WM_USER message */
8199 ret
= GetMessage(&msg
, NULL
, 0, 0);
8200 ok(!ret
, "GetMessage return %d with error %d instead of FALSE\n", ret
, GetLastError());
8201 ok(msg
.message
== WM_QUIT
, "Received message 0x%04x instead of WM_QUIT\n", msg
.message
);
8202 ok(msg
.wParam
== 0xbeef, "wParam was 0x%x instead of 0xbeef\n", msg
.wParam
);
8204 ret
= PeekMessage(&msg
, NULL
, 0, 0, PM_REMOVE
);
8205 ok( !ret
|| msg
.message
!= WM_QUIT
, "Received WM_QUIT again\n" );
8207 /* now test with PostThreadMessage - different behaviour! */
8208 PostThreadMessage(GetCurrentThreadId(), WM_QUIT
, 0xdead, 0);
8210 ret
= PeekMessage(&msg
, NULL
, 0, 0, PM_NOREMOVE
);
8211 ok(ret
, "PeekMessage failed with error %d\n", GetLastError());
8212 ok(msg
.message
== WM_QUIT
, "Received message 0x%04x instead of WM_QUIT\n", msg
.message
);
8213 ok(msg
.wParam
== 0xdead, "wParam was 0x%x instead of 0xdead\n", msg
.wParam
);
8215 ret
= PostThreadMessage(GetCurrentThreadId(), WM_USER
, 0, 0);
8216 ok(ret
, "PostMessage failed with error %d\n", GetLastError());
8218 /* note: we receive the WM_QUIT message first this time */
8219 ret
= GetMessage(&msg
, NULL
, 0, 0);
8220 ok(!ret
, "GetMessage return %d with error %d instead of FALSE\n", ret
, GetLastError());
8221 ok(msg
.message
== WM_QUIT
, "Received message 0x%04x instead of WM_QUIT\n", msg
.message
);
8222 ok(msg
.wParam
== 0xdead, "wParam was 0x%x instead of 0xdead\n", msg
.wParam
);
8224 ret
= GetMessage(&msg
, NULL
, 0, 0);
8225 ok(ret
> 0, "GetMessage failed with error %d\n", GetLastError());
8226 ok(msg
.message
== WM_USER
, "Received message 0x%04x instead of WM_USER\n", msg
.message
);
8229 static const struct message WmMouseHoverSeq
[] = {
8230 { WM_TIMER
, sent
|optional
}, /* XP sends it */
8231 { WM_SYSTIMER
, sent
},
8232 { WM_MOUSEHOVER
, sent
|wparam
, 0 },
8236 static void pump_msg_loop_timeout(DWORD timeout
, BOOL inject_mouse_move
)
8239 DWORD start_ticks
, end_ticks
;
8241 start_ticks
= GetTickCount();
8242 /* add some deviation (5%) to cover not expected delays */
8243 start_ticks
+= timeout
/ 20;
8247 while (PeekMessage(&msg
, 0, 0, 0, PM_REMOVE
))
8249 /* Timer proc messages are not dispatched to the window proc,
8250 * and therefore not logged.
8252 if (msg
.message
== WM_TIMER
|| msg
.message
== WM_SYSTIMER
)
8254 struct message s_msg
;
8256 s_msg
.message
= msg
.message
;
8257 s_msg
.flags
= sent
|wparam
|lparam
;
8258 s_msg
.wParam
= msg
.wParam
;
8259 s_msg
.lParam
= msg
.lParam
;
8260 add_message(&s_msg
);
8262 DispatchMessage(&msg
);
8265 end_ticks
= GetTickCount();
8267 /* inject WM_MOUSEMOVE to see how it changes tracking */
8268 if (inject_mouse_move
&& start_ticks
+ timeout
/ 2 >= end_ticks
)
8270 mouse_event(MOUSEEVENTF_MOVE
, -1, 0, 0, 0);
8271 mouse_event(MOUSEEVENTF_MOVE
, 1, 0, 0, 0);
8273 inject_mouse_move
= FALSE
;
8275 } while (start_ticks
+ timeout
>= end_ticks
);
8278 static void test_TrackMouseEvent(void)
8281 TRACKMOUSEEVENT tme
;
8284 RECT rc_parent
, rc_child
;
8285 UINT default_hover_time
, hover_width
= 0, hover_height
= 0;
8287 #define track_hover(track_hwnd, track_hover_time) \
8288 tme.cbSize = sizeof(tme); \
8289 tme.dwFlags = TME_HOVER; \
8290 tme.hwndTrack = track_hwnd; \
8291 tme.dwHoverTime = track_hover_time; \
8292 SetLastError(0xdeadbeef); \
8293 ret = TrackMouseEvent(&tme); \
8294 ok(ret, "TrackMouseEvent(TME_HOVER) error %d\n", GetLastError())
8296 #define track_query(expected_track_flags, expected_track_hwnd, expected_hover_time) \
8297 tme.cbSize = sizeof(tme); \
8298 tme.dwFlags = TME_QUERY; \
8299 tme.hwndTrack = (HWND)0xdeadbeef; \
8300 tme.dwHoverTime = 0xdeadbeef; \
8301 SetLastError(0xdeadbeef); \
8302 ret = TrackMouseEvent(&tme); \
8303 ok(ret, "TrackMouseEvent(TME_QUERY) error %d\n", GetLastError());\
8304 ok(tme.cbSize == sizeof(tme), "wrong tme.cbSize %u\n", tme.cbSize); \
8305 ok(tme.dwFlags == (expected_track_flags), \
8306 "wrong tme.dwFlags %08x, expected %08x\n", tme.dwFlags, (expected_track_flags)); \
8307 ok(tme.hwndTrack == (expected_track_hwnd), \
8308 "wrong tme.hwndTrack %p, expected %p\n", tme.hwndTrack, (expected_track_hwnd)); \
8309 ok(tme.dwHoverTime == (expected_hover_time), \
8310 "wrong tme.dwHoverTime %u, expected %u\n", tme.dwHoverTime, (expected_hover_time))
8312 #define track_hover_cancel(track_hwnd) \
8313 tme.cbSize = sizeof(tme); \
8314 tme.dwFlags = TME_HOVER | TME_CANCEL; \
8315 tme.hwndTrack = track_hwnd; \
8316 tme.dwHoverTime = 0xdeadbeef; \
8317 SetLastError(0xdeadbeef); \
8318 ret = TrackMouseEvent(&tme); \
8319 ok(ret, "TrackMouseEvent(TME_HOVER | TME_CANCEL) error %d\n", GetLastError())
8321 default_hover_time
= 0xdeadbeef;
8322 SetLastError(0xdeadbeef);
8323 ret
= SystemParametersInfo(SPI_GETMOUSEHOVERTIME
, 0, &default_hover_time
, 0);
8324 ok(ret
, "SystemParametersInfo(SPI_GETMOUSEHOVERTIME) error %u\n", GetLastError());
8325 if (!ret
) default_hover_time
= 400;
8326 trace("SPI_GETMOUSEHOVERTIME returned %u ms\n", default_hover_time
);
8328 SetLastError(0xdeadbeef);
8329 ret
= SystemParametersInfo(SPI_GETMOUSEHOVERWIDTH
, 0, &hover_width
, 0);
8330 ok(ret
, "SystemParametersInfo(SPI_GETMOUSEHOVERWIDTH) error %u\n", GetLastError());
8331 if (!ret
) hover_width
= 4;
8332 SetLastError(0xdeadbeef);
8333 ret
= SystemParametersInfo(SPI_GETMOUSEHOVERHEIGHT
, 0, &hover_height
, 0);
8334 ok(ret
, "SystemParametersInfo(SPI_GETMOUSEHOVERHEIGHT) error %u\n", GetLastError());
8335 if (!ret
) hover_height
= 4;
8336 trace("hover rect is %u x %d\n", hover_width
, hover_height
);
8338 hwnd
= CreateWindowEx(0, "TestWindowClass", NULL
,
8339 WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
8340 CW_USEDEFAULT
, CW_USEDEFAULT
, 300, 300, 0,
8344 hchild
= CreateWindowEx(0, "TestWindowClass", NULL
,
8345 WS_CHILD
| WS_BORDER
| WS_VISIBLE
,
8346 50, 50, 200, 200, hwnd
,
8354 tme
.dwFlags
= TME_QUERY
;
8355 tme
.hwndTrack
= (HWND
)0xdeadbeef;
8356 tme
.dwHoverTime
= 0xdeadbeef;
8357 SetLastError(0xdeadbeef);
8358 ret
= TrackMouseEvent(&tme
);
8359 ok(!ret
, "TrackMouseEvent should fail\n");
8360 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "not expected error %d\n", GetLastError());
8362 tme
.cbSize
= sizeof(tme
);
8363 tme
.dwFlags
= TME_HOVER
;
8364 tme
.hwndTrack
= (HWND
)0xdeadbeef;
8365 tme
.dwHoverTime
= 0xdeadbeef;
8366 SetLastError(0xdeadbeef);
8367 ret
= TrackMouseEvent(&tme
);
8368 ok(!ret
, "TrackMouseEvent should fail\n");
8369 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
, "not expected error %d\n", GetLastError());
8371 tme
.cbSize
= sizeof(tme
);
8372 tme
.dwFlags
= TME_HOVER
| TME_CANCEL
;
8373 tme
.hwndTrack
= (HWND
)0xdeadbeef;
8374 tme
.dwHoverTime
= 0xdeadbeef;
8375 SetLastError(0xdeadbeef);
8376 ret
= TrackMouseEvent(&tme
);
8377 ok(!ret
, "TrackMouseEvent should fail\n");
8378 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
, "not expected error %d\n", GetLastError());
8380 GetWindowRect(hwnd
, &rc_parent
);
8381 GetWindowRect(hchild
, &rc_child
);
8382 SetCursorPos(rc_child
.left
- 10, rc_child
.top
- 10);
8384 /* Process messages so that the system updates its internal current
8385 * window and hittest, otherwise TrackMouseEvent calls don't have any
8388 while (PeekMessage(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage(&msg
);
8391 track_query(0, NULL
, 0);
8392 track_hover(hchild
, 0);
8393 track_query(0, NULL
, 0);
8395 while (PeekMessage(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage(&msg
);
8398 track_hover(hwnd
, 0);
8399 track_query(TME_HOVER
, hwnd
, default_hover_time
);
8401 pump_msg_loop_timeout(default_hover_time
, FALSE
);
8402 ok_sequence(WmMouseHoverSeq
, "WmMouseHoverSeq", FALSE
);
8404 track_query(0, NULL
, 0);
8406 track_hover(hwnd
, HOVER_DEFAULT
);
8407 track_query(TME_HOVER
, hwnd
, default_hover_time
);
8409 Sleep(default_hover_time
/ 2);
8410 mouse_event(MOUSEEVENTF_MOVE
, -1, 0, 0, 0);
8411 mouse_event(MOUSEEVENTF_MOVE
, 1, 0, 0, 0);
8413 track_query(TME_HOVER
, hwnd
, default_hover_time
);
8415 pump_msg_loop_timeout(default_hover_time
/ 2, FALSE
);
8416 ok_sequence(WmMouseHoverSeq
, "WmMouseHoverSeq", FALSE
);
8418 track_query(0, NULL
, 0);
8420 track_hover(hwnd
, HOVER_DEFAULT
);
8421 track_query(TME_HOVER
, hwnd
, default_hover_time
);
8423 pump_msg_loop_timeout(default_hover_time
, TRUE
);
8424 ok_sequence(WmMouseHoverSeq
, "WmMouseHoverSeq", FALSE
);
8426 track_query(0, NULL
, 0);
8428 track_hover(hwnd
, HOVER_DEFAULT
);
8429 track_query(TME_HOVER
, hwnd
, default_hover_time
);
8430 track_hover_cancel(hwnd
);
8432 DestroyWindow(hwnd
);
8436 #undef track_hover_cancel
8440 static const struct message WmSetWindowRgn
[] = {
8441 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
},
8442 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
8443 { WM_NCPAINT
, sent
}, /* wparam != 1 */
8444 { WM_GETTEXT
, sent
|defwinproc
|optional
},
8445 { WM_ERASEBKGND
, sent
|optional
}, /* FIXME: remove optional once Wine is fixed */
8446 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
},
8447 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
8451 static const struct message WmSetWindowRgn_no_redraw
[] = {
8452 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
},
8453 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
8454 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
},
8455 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
8459 static const struct message WmSetWindowRgn_clear
[] = {
8460 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
},
8461 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
8462 { WM_NCPAINT
, sent
}, /* wparam != 1 */
8463 { WM_GETTEXT
, sent
|defwinproc
|optional
},
8464 { WM_ERASEBKGND
, sent
|optional
}, /* FIXME: remove optional once Wine is fixed */
8465 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
},
8466 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
8467 { WM_NCPAINT
, sent
|optional
}, /* wparam != 1 */
8468 { WM_GETTEXT
, sent
|defwinproc
|optional
},
8469 { WM_ERASEBKGND
, sent
|optional
},
8470 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
8471 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
8475 static void test_SetWindowRgn(void)
8478 HWND hwnd
= CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW
,
8479 100, 100, 200, 200, 0, 0, 0, NULL
);
8480 ok( hwnd
!= 0, "Failed to create overlapped window\n" );
8482 ShowWindow( hwnd
, SW_SHOW
);
8483 UpdateWindow( hwnd
);
8487 trace("testing SetWindowRgn\n");
8488 hrgn
= CreateRectRgn( 0, 0, 150, 150 );
8489 SetWindowRgn( hwnd
, hrgn
, TRUE
);
8490 ok_sequence( WmSetWindowRgn
, "WmSetWindowRgn", FALSE
);
8492 hrgn
= CreateRectRgn( 30, 30, 160, 160 );
8493 SetWindowRgn( hwnd
, hrgn
, FALSE
);
8494 ok_sequence( WmSetWindowRgn_no_redraw
, "WmSetWindowRgn_no_redraw", FALSE
);
8496 hrgn
= CreateRectRgn( 0, 0, 180, 180 );
8497 SetWindowRgn( hwnd
, hrgn
, TRUE
);
8498 ok_sequence( WmSetWindowRgn
, "WmSetWindowRgn2", FALSE
);
8500 SetWindowRgn( hwnd
, 0, TRUE
);
8501 ok_sequence( WmSetWindowRgn_clear
, "WmSetWindowRgn_clear", FALSE
);
8503 DestroyWindow( hwnd
);
8506 /*************************** ShowWindow() test ******************************/
8507 static const struct message WmShowNormal
[] = {
8508 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
8509 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
8510 { HCBT_ACTIVATE
, hook
},
8511 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2003 doesn't send it */
8512 { HCBT_SETFOCUS
, hook
},
8513 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
8516 static const struct message WmShow
[] = {
8517 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
8518 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
8519 { HCBT_ACTIVATE
, hook
|optional
}, /* win2000 doesn't send it */
8520 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2000 doesn't send it */
8521 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 doesn't send it */
8522 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
8525 static const struct message WmShowNoActivate_1
[] = {
8526 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWNOACTIVATE
},
8527 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|0x8000 },
8528 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|0x8000 },
8529 { WM_MOVE
, sent
|defwinproc
},
8530 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_RESTORED
},
8533 static const struct message WmShowNoActivate_2
[] = {
8534 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWNOACTIVATE
},
8535 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|0x8000 },
8536 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|0x8000 },
8537 { WM_MOVE
, sent
|defwinproc
},
8538 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_RESTORED
},
8539 { HCBT_SETFOCUS
, hook
},
8540 { HCBT_ACTIVATE
, hook
|optional
}, /* win2003 doesn't send it */
8541 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2003 doesn't send it */
8542 { HCBT_SETFOCUS
, hook
|optional
}, /* win2003 doesn't send it */
8545 static const struct message WmShowNA_1
[] = {
8546 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
8547 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
8548 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
8551 static const struct message WmShowNA_2
[] = {
8552 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
8553 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
8556 static const struct message WmRestore_1
[] = {
8557 { HCBT_MINMAX
, hook
|lparam
, 0, SW_RESTORE
},
8558 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|0x8000 },
8559 { HCBT_ACTIVATE
, hook
|optional
}, /* win2000 doesn't send it */
8560 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2000 doesn't send it */
8561 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 doesn't send it */
8562 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|0x8000 },
8563 { WM_MOVE
, sent
|defwinproc
},
8564 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_RESTORED
},
8565 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 sends it */
8568 static const struct message WmRestore_2
[] = {
8569 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
8570 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
8571 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
8574 static const struct message WmRestore_3
[] = {
8575 { HCBT_MINMAX
, hook
|lparam
, 0, SW_RESTORE
},
8576 { WM_GETMINMAXINFO
, sent
},
8577 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|0x8000 },
8578 { HCBT_ACTIVATE
, hook
|optional
}, /* win2003 doesn't send it */
8579 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2003 doesn't send it */
8580 { HCBT_SETFOCUS
, hook
|optional
}, /* win2003 doesn't send it */
8581 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|0x8000 },
8582 { WM_MOVE
, sent
|defwinproc
},
8583 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_MAXIMIZED
},
8584 { HCBT_SETFOCUS
, hook
|optional
}, /* win2003 sends it */
8587 static const struct message WmRestore_4
[] = {
8588 { HCBT_MINMAX
, hook
|lparam
, 0, SW_RESTORE
},
8589 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|0x8000 },
8590 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|0x8000 },
8591 { WM_MOVE
, sent
|defwinproc
},
8592 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_RESTORED
},
8595 static const struct message WmRestore_5
[] = {
8596 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWNORMAL
},
8597 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|0x8000 },
8598 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|0x8000 },
8599 { WM_MOVE
, sent
|defwinproc
},
8600 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_RESTORED
},
8603 static const struct message WmHide_1
[] = {
8604 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
8605 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
8606 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
8607 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 sends it */
8610 static const struct message WmHide_2
[] = {
8611 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
8612 { WM_WINDOWPOSCHANGING
, sent
/*|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE*/ }, /* win2000 doesn't add SWP_NOACTIVATE */
8613 { WM_WINDOWPOSCHANGED
, sent
/*|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE*/ }, /* win2000 doesn't add SWP_NOACTIVATE */
8616 static const struct message WmHide_3
[] = {
8617 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
8618 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
8619 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
8620 { HCBT_SETFOCUS
, hook
},
8623 static const struct message WmShowMinimized_1
[] = {
8624 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINIMIZED
},
8625 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|0x8000 },
8626 { HCBT_ACTIVATE
, hook
|optional
}, /* win2000 doesn't send it */
8627 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2000 doesn't send it */
8628 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|0x8000 },
8629 { WM_MOVE
, sent
|defwinproc
},
8630 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_MINIMIZED
},
8633 static const struct message WmMinimize_1
[] = {
8634 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
8635 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 doesn't send it */
8636 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|0x8000 },
8637 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|0x8000 },
8638 { WM_MOVE
, sent
|defwinproc
},
8639 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_MINIMIZED
},
8642 static const struct message WmMinimize_2
[] = {
8643 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
8644 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|0x8000 },
8645 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|0x8000 },
8646 { WM_MOVE
, sent
|defwinproc
},
8647 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_MINIMIZED
},
8650 static const struct message WmMinimize_3
[] = {
8651 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
8652 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|0x8000 },
8653 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|0x8000 },
8654 { WM_MOVE
, sent
|defwinproc
},
8655 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_MINIMIZED
},
8658 static const struct message WmShowMinNoActivate
[] = {
8659 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINNOACTIVE
},
8660 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
8661 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
8664 static const struct message WmMinMax_1
[] = {
8665 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINIMIZED
},
8668 static const struct message WmMinMax_2
[] = {
8669 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMAXIMIZED
},
8672 static const struct message WmMinMax_3
[] = {
8673 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
8676 static const struct message WmMinMax_4
[] = {
8677 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINNOACTIVE
},
8680 static const struct message WmShowMaximized_1
[] = {
8681 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMAXIMIZED
},
8682 { WM_GETMINMAXINFO
, sent
},
8683 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|0x8000 },
8684 { HCBT_ACTIVATE
, hook
|optional
}, /* win2000 doesn't send it */
8685 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2000 doesn't send it */
8686 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 doesn't send it */
8687 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|0x8000 },
8688 { WM_MOVE
, sent
|defwinproc
},
8689 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_MAXIMIZED
},
8690 { HCBT_SETFOCUS
, hook
|optional
}, /* win2003 sends it */
8693 static const struct message WmShowMaximized_2
[] = {
8694 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMAXIMIZED
},
8695 { WM_GETMINMAXINFO
, sent
},
8696 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
},
8697 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
8698 { WM_MOVE
, sent
|optional
}, /* Win9x doesn't send it */
8699 { WM_SIZE
, sent
|wparam
|optional
, SIZE_MAXIMIZED
}, /* Win9x doesn't send it */
8700 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|0x8000 },
8701 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|0x8000 },
8702 { WM_MOVE
, sent
|defwinproc
},
8703 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_MAXIMIZED
},
8704 { HCBT_SETFOCUS
, hook
},
8707 static const struct message WmShowMaximized_3
[] = {
8708 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMAXIMIZED
},
8709 { WM_GETMINMAXINFO
, sent
},
8710 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|0x8000 },
8711 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|0x8000 },
8712 { WM_MOVE
, sent
|defwinproc
},
8713 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_MAXIMIZED
},
8717 static void test_ShowWindow(void)
8719 /* ShowWindow commands in random order */
8722 INT cmd
; /* ShowWindow command */
8723 LPARAM ret
; /* ShowWindow return value */
8724 DWORD style
; /* window style after the command */
8725 const struct message
*msg
; /* message sequence the command produces */
8726 BOOL todo_msg
; /* message sequence doesn't match what Wine does */
8729 /* 1 */ { SW_SHOWNORMAL
, FALSE
, WS_VISIBLE
, WmShowNormal
, FALSE
},
8730 /* 2 */ { SW_SHOWNORMAL
, TRUE
, WS_VISIBLE
, WmEmptySeq
, FALSE
},
8731 /* 3 */ { SW_HIDE
, TRUE
, 0, WmHide_1
, FALSE
},
8732 /* 4 */ { SW_HIDE
, FALSE
, 0, WmEmptySeq
, FALSE
},
8733 /* 5 */ { SW_SHOWMINIMIZED
, FALSE
, WS_VISIBLE
|WS_MINIMIZE
, WmShowMinimized_1
, FALSE
},
8734 /* 6 */ { SW_SHOWMINIMIZED
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinMax_1
, FALSE
},
8735 /* 7 */ { SW_HIDE
, TRUE
, WS_MINIMIZE
, WmHide_1
, FALSE
},
8736 /* 8 */ { SW_HIDE
, FALSE
, WS_MINIMIZE
, WmEmptySeq
, FALSE
},
8737 /* 9 */ { SW_SHOWMAXIMIZED
, FALSE
, WS_VISIBLE
|WS_MAXIMIZE
, WmShowMaximized_1
, FALSE
},
8738 /* 10 */ { SW_SHOWMAXIMIZED
, TRUE
, WS_VISIBLE
|WS_MAXIMIZE
, WmMinMax_2
, FALSE
},
8739 /* 11 */ { SW_HIDE
, TRUE
, WS_MAXIMIZE
, WmHide_1
, FALSE
},
8740 /* 12 */ { SW_HIDE
, FALSE
, WS_MAXIMIZE
, WmEmptySeq
, FALSE
},
8741 /* 13 */ { SW_SHOWNOACTIVATE
, FALSE
, WS_VISIBLE
, WmShowNoActivate_1
, FALSE
},
8742 /* 14 */ { SW_SHOWNOACTIVATE
, TRUE
, WS_VISIBLE
, WmEmptySeq
, FALSE
},
8743 /* 15 */ { SW_HIDE
, TRUE
, 0, WmHide_2
, FALSE
},
8744 /* 16 */ { SW_HIDE
, FALSE
, 0, WmEmptySeq
, FALSE
},
8745 /* 17 */ { SW_SHOW
, FALSE
, WS_VISIBLE
, WmShow
, FALSE
},
8746 /* 18 */ { SW_SHOW
, TRUE
, WS_VISIBLE
, WmEmptySeq
, FALSE
},
8747 /* 19 */ { SW_MINIMIZE
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinimize_1
, TRUE
},
8748 /* 20 */ { SW_MINIMIZE
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinMax_3
, FALSE
},
8749 /* 21 */ { SW_HIDE
, TRUE
, WS_MINIMIZE
, WmHide_2
, FALSE
},
8750 /* 22 */ { SW_SHOWMINNOACTIVE
, FALSE
, WS_VISIBLE
|WS_MINIMIZE
, WmShowMinNoActivate
, TRUE
},
8751 /* 23 */ { SW_SHOWMINNOACTIVE
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinMax_4
, FALSE
},
8752 /* 24 */ { SW_HIDE
, TRUE
, WS_MINIMIZE
, WmHide_2
, FALSE
},
8753 /* 25 */ { SW_HIDE
, FALSE
, WS_MINIMIZE
, WmEmptySeq
, FALSE
},
8754 /* 26 */ { SW_SHOWNA
, FALSE
, WS_VISIBLE
|WS_MINIMIZE
, WmShowNA_1
, FALSE
},
8755 /* 27 */ { SW_SHOWNA
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmShowNA_2
, FALSE
},
8756 /* 28 */ { SW_HIDE
, TRUE
, WS_MINIMIZE
, WmHide_2
, FALSE
},
8757 /* 29 */ { SW_HIDE
, FALSE
, WS_MINIMIZE
, WmEmptySeq
, FALSE
},
8758 /* 30 */ { SW_RESTORE
, FALSE
, WS_VISIBLE
, WmRestore_1
, FALSE
},
8759 /* 31 */ { SW_RESTORE
, TRUE
, WS_VISIBLE
, WmEmptySeq
, FALSE
},
8760 /* 32 */ { SW_HIDE
, TRUE
, 0, WmHide_3
, TRUE
},
8761 /* 33 */ { SW_HIDE
, FALSE
, 0, WmEmptySeq
, FALSE
},
8762 /* 34 */ { SW_NORMALNA
, FALSE
, 0, WmEmptySeq
, TRUE
}, /* what does this mean?! */
8763 /* 35 */ { SW_NORMALNA
, FALSE
, 0, WmEmptySeq
, TRUE
},
8764 /* 36 */ { SW_HIDE
, FALSE
, 0, WmEmptySeq
, FALSE
},
8765 /* 37 */ { SW_RESTORE
, FALSE
, WS_VISIBLE
, WmRestore_2
, FALSE
},
8766 /* 38 */ { SW_RESTORE
, TRUE
, WS_VISIBLE
, WmEmptySeq
, FALSE
},
8767 /* 39 */ { SW_SHOWNOACTIVATE
, TRUE
, WS_VISIBLE
, WmEmptySeq
, FALSE
},
8768 /* 40 */ { SW_MINIMIZE
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinimize_2
, TRUE
},
8769 /* 41 */ { SW_MINIMIZE
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinMax_3
, FALSE
},
8770 /* 42 */ { SW_SHOWMAXIMIZED
, TRUE
, WS_VISIBLE
|WS_MAXIMIZE
, WmShowMaximized_2
, TRUE
},
8771 /* 43 */ { SW_SHOWMAXIMIZED
, TRUE
, WS_VISIBLE
|WS_MAXIMIZE
, WmMinMax_2
, FALSE
},
8772 /* 44 */ { SW_MINIMIZE
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinimize_1
, TRUE
},
8773 /* 45 */ { SW_MINIMIZE
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinMax_3
, FALSE
},
8774 /* 46 */ { SW_RESTORE
, TRUE
, WS_VISIBLE
|WS_MAXIMIZE
, WmRestore_3
, FALSE
},
8775 /* 47 */ { SW_RESTORE
, TRUE
, WS_VISIBLE
, WmRestore_4
, FALSE
},
8776 /* 48 */ { SW_SHOWMAXIMIZED
, TRUE
, WS_VISIBLE
|WS_MAXIMIZE
, WmShowMaximized_3
, FALSE
},
8777 /* 49 */ { SW_SHOW
, TRUE
, WS_VISIBLE
|WS_MAXIMIZE
, WmEmptySeq
, FALSE
},
8778 /* 50 */ { SW_SHOWNORMAL
, TRUE
, WS_VISIBLE
, WmRestore_5
, FALSE
},
8779 /* 51 */ { SW_SHOWNORMAL
, TRUE
, WS_VISIBLE
, WmEmptySeq
, FALSE
},
8780 /* 52 */ { SW_HIDE
, TRUE
, 0, WmHide_1
, FALSE
},
8781 /* 53 */ { SW_HIDE
, FALSE
, 0, WmEmptySeq
, FALSE
},
8782 /* 54 */ { SW_MINIMIZE
, FALSE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinimize_3
, TRUE
},
8783 /* 55 */ { SW_HIDE
, TRUE
, WS_MINIMIZE
, WmHide_2
, FALSE
},
8784 /* 56 */ { SW_SHOWNOACTIVATE
, FALSE
, WS_VISIBLE
, WmShowNoActivate_2
, FALSE
},
8785 /* 57 */ { SW_SHOW
, TRUE
, WS_VISIBLE
, WmEmptySeq
, FALSE
}
8792 #define WS_BASE (WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX|WS_MAXIMIZEBOX|WS_POPUP|WS_CLIPSIBLINGS)
8793 hwnd
= CreateWindowEx(0, "ShowWindowClass", NULL
, WS_BASE
,
8798 style
= GetWindowLong(hwnd
, GWL_STYLE
) & ~WS_BASE
;
8799 ok(style
== 0, "expected style 0, got %08x\n", style
);
8804 for (i
= 0; i
< sizeof(sw
)/sizeof(sw
[0]); i
++)
8806 static const char * const sw_cmd_name
[13] =
8808 "SW_HIDE", "SW_SHOWNORMAL", "SW_SHOWMINIMIZED", "SW_SHOWMAXIMIZED",
8809 "SW_SHOWNOACTIVATE", "SW_SHOW", "SW_MINIMIZE", "SW_SHOWMINNOACTIVE",
8810 "SW_SHOWNA", "SW_RESTORE", "SW_SHOWDEFAULT", "SW_FORCEMINIMIZE",
8811 "SW_NORMALNA" /* 0xCC */
8814 INT idx
; /* index into the above array of names */
8816 idx
= (sw
[i
].cmd
== SW_NORMALNA
) ? 12 : sw
[i
].cmd
;
8818 style
= GetWindowLong(hwnd
, GWL_STYLE
);
8819 trace("%d: sending %s, current window style %08x\n", i
+1, sw_cmd_name
[idx
], style
);
8820 ret
= ShowWindow(hwnd
, sw
[i
].cmd
);
8821 ok(!ret
== !sw
[i
].ret
, "%d: cmd %s: expected ret %lu, got %lu\n", i
+1, sw_cmd_name
[idx
], sw
[i
].ret
, ret
);
8822 style
= GetWindowLong(hwnd
, GWL_STYLE
) & ~WS_BASE
;
8823 ok(style
== sw
[i
].style
, "%d: expected style %08x, got %08x\n", i
+1, sw
[i
].style
, style
);
8825 sprintf(comment
, "%d: ShowWindow(%s)", i
+1, sw_cmd_name
[idx
]);
8826 ok_sequence(sw
[i
].msg
, comment
, sw
[i
].todo_msg
);
8832 DestroyWindow(hwnd
);
8838 HMODULE user32
= GetModuleHandleA("user32.dll");
8839 FARPROC pSetWinEventHook
= GetProcAddress(user32
, "SetWinEventHook");
8840 FARPROC pUnhookWinEvent
= GetProcAddress(user32
, "UnhookWinEvent");
8841 FARPROC pIsWinEventHookInstalled
= 0;/*GetProcAddress(user32, "IsWinEventHookInstalled");*/
8842 pGetAncestor
= (void*) GetProcAddress(user32
, "GetAncestor");
8844 if (!RegisterWindowClasses()) assert(0);
8846 if (pSetWinEventHook
)
8848 hEvent_hook
= (HWINEVENTHOOK
)pSetWinEventHook(EVENT_MIN
, EVENT_MAX
,
8849 GetModuleHandleA(0),
8852 GetCurrentThreadId(),
8853 WINEVENT_INCONTEXT
);
8854 assert(hEvent_hook
);
8856 if (pIsWinEventHookInstalled
)
8859 for (event
= EVENT_MIN
; event
<= EVENT_MAX
; event
++)
8860 ok(pIsWinEventHookInstalled(event
), "IsWinEventHookInstalled(%u) failed\n", event
);
8864 cbt_hook_thread_id
= GetCurrentThreadId();
8865 hCBT_hook
= SetWindowsHookExA(WH_CBT
, cbt_hook_proc
, 0, GetCurrentThreadId());
8870 /* Fix message sequences before removing 4 lines below */
8872 if (pUnhookWinEvent
&& hEvent_hook
)
8874 ret
= pUnhookWinEvent(hEvent_hook
);
8875 ok( ret
, "UnhookWinEvent error %d\n", GetLastError());
8876 pUnhookWinEvent
= 0;
8883 test_scrollwindowex();
8886 invisible_parent_tests();
8887 test_mdi_messages();
8888 test_button_messages();
8889 test_static_messages();
8890 test_paint_messages();
8891 test_interthread_messages();
8892 test_message_conversion();
8893 test_accelerators();
8896 test_DestroyWindow();
8897 test_DispatchMessage();
8898 test_SendMessageTimeout();
8899 test_edit_messages();
8900 test_quit_message();
8901 test_TrackMouseEvent();
8902 test_SetWindowRgn();
8905 UnhookWindowsHookEx(hCBT_hook
);
8906 if (pUnhookWinEvent
)
8908 ret
= pUnhookWinEvent(hEvent_hook
);
8909 ok( ret
, "UnhookWinEvent error %d\n", GetLastError());
8910 SetLastError(0xdeadbeef);
8911 ok(!pUnhookWinEvent(hEvent_hook
), "UnhookWinEvent succeeded\n");
8912 ok(GetLastError() == ERROR_INVALID_HANDLE
|| /* Win2k */
8913 GetLastError() == 0xdeadbeef, /* Win9x */
8914 "unexpected error %d\n", GetLastError());