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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 #define _WIN32_WINNT 0x0500 /* For WM_CHANGEUISTATE */
34 #include "wine/test.h"
36 #define MDI_FIRST_CHILD_ID 2004
38 /* undocumented SWP flags - from SDK 3.1 */
39 #define SWP_NOCLIENTSIZE 0x0800
40 #define SWP_NOCLIENTMOVE 0x1000
42 #define WND_PARENT_ID 1
43 #define WND_POPUP_ID 2
44 #define WND_CHILD_ID 3
46 static BOOL test_DestroyWindow_flag
;
47 static HWINEVENTHOOK hEvent_hook
;
49 static HWND (WINAPI
*pGetAncestor
)(HWND
,UINT
);
52 FIXME: add tests for these
53 Window Edge Styles (Win31/Win95/98 look), in order of precedence:
54 WS_EX_DLGMODALFRAME: double border, WS_CAPTION allowed
55 WS_THICKFRAME: thick border
56 WS_DLGFRAME: double border, WS_CAPTION not allowed (but possibly shown anyway)
57 WS_BORDER (default for overlapped windows): single black border
58 none (default for child (and popup?) windows): no border
75 UINT message
; /* the WM_* code */
76 msg_flags_t flags
; /* message props */
77 WPARAM wParam
; /* expected value of wParam */
78 LPARAM lParam
; /* expected value of lParam */
81 /* Empty message sequence */
82 static const struct message WmEmptySeq
[] =
86 /* CreateWindow (for overlapped window, not initially visible) (16/32) */
87 static const struct message WmCreateOverlappedSeq
[] = {
88 { HCBT_CREATEWND
, hook
},
89 { WM_GETMINMAXINFO
, sent
},
90 { WM_NCCREATE
, sent
},
91 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
92 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
94 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
97 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
98 * for a not visible overlapped window.
100 static const struct message WmSWP_ShowOverlappedSeq
[] = {
101 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
102 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
103 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
104 { WM_GETTEXT
, sent
|defwinproc
|optional
},
105 { WM_ERASEBKGND
, sent
|optional
},
106 { HCBT_ACTIVATE
, hook
},
107 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
108 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
109 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* Win9x: SWP_NOSENDCHANGING */
110 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
111 { WM_NCACTIVATE
, sent
|wparam
, 1 },
112 { WM_GETTEXT
, sent
|defwinproc
|optional
},
113 { WM_ACTIVATE
, sent
|wparam
, 1 },
114 { HCBT_SETFOCUS
, hook
},
115 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
116 { WM_IME_NOTIFY
, sent
|defwinproc
|optional
},
117 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
118 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
119 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
120 { WM_GETTEXT
, sent
|defwinproc
|optional
},
121 { WM_ERASEBKGND
, sent
|optional
},
122 /* Win9x adds SWP_NOZORDER below */
123 { WM_WINDOWPOSCHANGED
, sent
, /*|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE*/ },
124 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
125 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
126 { WM_ERASEBKGND
, sent
|optional
},
129 /* SetWindowPos(SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE)
130 * for a visible overlapped window.
132 static const struct message WmSWP_HideOverlappedSeq
[] = {
133 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
134 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
135 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
139 /* SetWindowPos(SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOMOVE)
140 * for a visible overlapped window.
142 static const struct message WmSWP_ResizeSeq
[] = {
143 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOZORDER
|SWP_NOMOVE
},
144 { WM_GETMINMAXINFO
, sent
|defwinproc
},
145 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
146 { WM_NCPAINT
, sent
|optional
},
147 { WM_GETTEXT
, sent
|defwinproc
|optional
},
148 { WM_ERASEBKGND
, sent
|optional
},
149 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOZORDER
|SWP_NOCLIENTMOVE
},
150 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
151 { WM_NCCALCSIZE
, sent
|wparam
|optional
, TRUE
},
152 { WM_NCPAINT
, sent
|optional
},
153 { WM_GETTEXT
, sent
|defwinproc
|optional
},
154 { WM_ERASEBKGND
, sent
|optional
},
155 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
159 /* SetWindowPos(SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOMOVE)
160 * for a visible popup window.
162 static const struct message WmSWP_ResizePopupSeq
[] = {
163 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOZORDER
|SWP_NOMOVE
},
164 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
165 { WM_NCPAINT
, sent
|optional
},
166 { WM_GETTEXT
, sent
|defwinproc
|optional
},
167 { WM_ERASEBKGND
, sent
|optional
},
168 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOZORDER
|SWP_NOCLIENTMOVE
},
169 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
170 { WM_NCCALCSIZE
, sent
|wparam
|optional
, TRUE
},
171 { WM_NCPAINT
, sent
|optional
},
172 { WM_GETTEXT
, sent
|defwinproc
|optional
},
173 { WM_ERASEBKGND
, sent
|optional
},
174 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
178 /* SetWindowPos(SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOSIZE)
179 * for a visible overlapped window.
181 static const struct message WmSWP_MoveSeq
[] = {
182 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOZORDER
|SWP_NOSIZE
},
183 { WM_NCPAINT
, sent
|optional
},
184 { WM_GETTEXT
, sent
|defwinproc
|optional
},
185 { WM_ERASEBKGND
, sent
|optional
},
186 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOZORDER
|SWP_NOCLIENTSIZE
},
187 { WM_MOVE
, sent
|defwinproc
|wparam
, 0 },
188 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
192 /* ShowWindow(SW_SHOW) for a not visible overlapped window */
193 static const struct message WmShowOverlappedSeq
[] = {
194 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
195 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
196 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
197 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
198 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
199 { WM_GETTEXT
, sent
|defwinproc
|optional
},
200 { WM_ERASEBKGND
, sent
|optional
},
201 { HCBT_ACTIVATE
, hook
},
202 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
203 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
204 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
},
205 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
206 { WM_NCACTIVATE
, sent
|wparam
, 1 },
207 { WM_GETTEXT
, sent
|defwinproc
|optional
},
208 { WM_ACTIVATE
, sent
|wparam
, 1 },
209 { HCBT_SETFOCUS
, hook
},
210 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
211 { WM_IME_NOTIFY
, sent
|defwinproc
|optional
},
212 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
213 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
214 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
215 { WM_GETTEXT
, sent
|defwinproc
|optional
},
216 { WM_ERASEBKGND
, sent
|optional
},
217 /* Win9x adds SWP_NOZORDER below */
218 { WM_WINDOWPOSCHANGED
, sent
, /*|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE*/ },
219 { WM_NCCALCSIZE
, sent
|optional
},
220 { WM_NCPAINT
, sent
|optional
},
221 { WM_ERASEBKGND
, sent
|optional
},
222 #if 0 /* CreateWindow/ShowWindow(SW_SHOW) also generates WM_SIZE/WM_MOVE
223 * messages. Does that mean that CreateWindow doesn't set initial
224 * window dimensions for overlapped windows?
231 /* ShowWindow(SW_HIDE) for a visible overlapped window */
232 static const struct message WmHideOverlappedSeq
[] = {
233 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
234 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
235 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
236 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
239 { WM_NCACTIVATE
, sent
|wparam
, 0 },
240 { WM_ACTIVATE
, sent
|wparam
, 0 },
241 { WM_ACTIVATEAPP
, sent
|wparam
, 0 },
242 { WM_KILLFOCUS
, sent
|wparam
, 0 },
243 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
244 { WM_IME_NOTIFY
, sent
|optional
|defwinproc
},
247 /* DestroyWindow for a visible overlapped window */
248 static const struct message WmDestroyOverlappedSeq
[] = {
249 { HCBT_DESTROYWND
, hook
},
250 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
},
251 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
252 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
253 { WM_NCACTIVATE
, sent
|wparam
, 0 },
254 { WM_ACTIVATE
, sent
|wparam
, 0 },
255 { WM_ACTIVATEAPP
, sent
|wparam
, 0 },
256 { WM_KILLFOCUS
, sent
|wparam
, 0 },
257 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
258 { WM_IME_NOTIFY
, sent
|optional
|defwinproc
},
259 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
260 { WM_DESTROY
, sent
},
261 { WM_NCDESTROY
, sent
},
264 /* CreateWindow (for a child popup window, not initially visible) */
265 static const struct message WmCreateChildPopupSeq
[] = {
266 { HCBT_CREATEWND
, hook
},
267 { WM_NCCREATE
, sent
},
268 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
270 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
275 /* CreateWindow (for a popup window, not initially visible,
276 * which sets WS_VISIBLE in WM_CREATE handler)
278 static const struct message WmCreateInvisiblePopupSeq
[] = {
279 { HCBT_CREATEWND
, hook
},
280 { WM_NCCREATE
, sent
},
281 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
283 { WM_STYLECHANGING
, sent
},
284 { WM_STYLECHANGED
, sent
},
285 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
290 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER)
291 * for a popup window with WS_VISIBLE style set
293 static const struct message WmShowVisiblePopupSeq_2
[] = {
294 { WM_WINDOWPOSCHANGING
, sent
|wparam
, 0 },
297 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
298 * for a popup window with WS_VISIBLE style set
300 static const struct message WmShowVisiblePopupSeq_3
[] = {
301 { WM_WINDOWPOSCHANGING
, sent
|wparam
, 0 },
302 { HCBT_ACTIVATE
, hook
},
303 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
304 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
305 { WM_WINDOWPOSCHANGING
, sent
|wparam
, 0 },
306 { WM_NCACTIVATE
, sent
|wparam
, 1 },
307 { WM_ACTIVATE
, sent
|wparam
, 1 },
308 { HCBT_SETFOCUS
, hook
},
309 { WM_KILLFOCUS
, sent
|parent
},
310 { WM_IME_SETCONTEXT
, sent
|parent
|wparam
|optional
, 0 },
311 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
312 { WM_IME_NOTIFY
, sent
|defwinproc
|optional
},
313 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
314 { WM_SETFOCUS
, sent
|defwinproc
},
317 /* CreateWindow (for child window, not initially visible) */
318 static const struct message WmCreateChildSeq
[] = {
319 { HCBT_CREATEWND
, hook
},
320 { WM_NCCREATE
, sent
},
321 /* child is inserted into parent's child list after WM_NCCREATE returns */
322 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
324 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
327 { WM_PARENTNOTIFY
, sent
|parent
|wparam
, WM_CREATE
},
330 /* CreateWindow (for maximized child window, not initially visible) */
331 static const struct message WmCreateMaximizedChildSeq
[] = {
332 { HCBT_CREATEWND
, hook
},
333 { WM_NCCREATE
, sent
},
334 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
336 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
339 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
340 { WM_GETMINMAXINFO
, sent
},
341 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|0x8000 },
342 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
343 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOZORDER
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
|0x8000 },
344 { WM_SIZE
, sent
|defwinproc
},
345 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
346 { WM_PARENTNOTIFY
, sent
|parent
|wparam
, WM_CREATE
},
349 /* CreateWindow (for a child window, initially visible) */
350 static const struct message WmCreateVisibleChildSeq
[] = {
351 { HCBT_CREATEWND
, hook
},
352 { WM_NCCREATE
, sent
},
353 /* child is inserted into parent's child list after WM_NCCREATE returns */
354 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
355 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
357 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
360 { WM_PARENTNOTIFY
, sent
|parent
|wparam
, WM_CREATE
},
361 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
362 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOZORDER
},
363 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
364 { WM_ERASEBKGND
, sent
|parent
|optional
},
365 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOZORDER
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
366 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 }, /* WinXP */
369 /* ShowWindow(SW_SHOW) for a not visible child window */
370 static const struct message WmShowChildSeq
[] = {
371 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
372 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
},
373 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
374 { WM_ERASEBKGND
, sent
|parent
|optional
},
375 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
378 /* ShowWindow(SW_HIDE) for a visible child window */
379 static const struct message WmHideChildSeq
[] = {
380 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
381 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
},
382 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
383 { WM_ERASEBKGND
, sent
|parent
|optional
},
384 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
387 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
388 * for a not visible child window
390 static const struct message WmShowChildSeq_2
[] = {
391 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
392 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
393 { WM_CHILDACTIVATE
, sent
},
394 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
397 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE)
398 * for a not visible child window
400 static const struct message WmShowChildSeq_3
[] = {
401 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
402 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
403 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOZORDER
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
406 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
407 * for a visible child window with a caption
409 static const struct message WmShowChildSeq_4
[] = {
410 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
411 { WM_CHILDACTIVATE
, sent
},
414 /* ShowWindow(SW_SHOW) for child with invisible parent */
415 static const struct message WmShowChildInvisibleParentSeq
[] = {
416 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
419 /* ShowWindow(SW_HIDE) for child with invisible parent */
420 static const struct message WmHideChildInvisibleParentSeq
[] = {
421 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
424 /* SetWindowPos(SWP_SHOWWINDOW) for child with invisible parent */
425 static const struct message WmShowChildInvisibleParentSeq_2
[] = {
426 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOZORDER
},
427 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
428 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOZORDER
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
431 /* SetWindowPos(SWP_HIDEWINDOW) for child with invisible parent */
432 static const struct message WmHideChildInvisibleParentSeq_2
[] = {
433 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
},
434 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
435 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
438 /* DestroyWindow for a visible child window */
439 static const struct message WmDestroyChildSeq
[] = {
440 { HCBT_DESTROYWND
, hook
},
441 { WM_PARENTNOTIFY
, sent
|parent
|wparam
, WM_DESTROY
},
442 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
443 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
},
444 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
445 { WM_ERASEBKGND
, sent
|parent
|optional
},
446 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
447 { HCBT_SETFOCUS
, hook
}, /* set focus to a parent */
448 { WM_KILLFOCUS
, sent
},
449 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
450 { WM_IME_SETCONTEXT
, sent
|wparam
|parent
|optional
, 1 },
451 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
452 { WM_SETFOCUS
, sent
|parent
},
453 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
454 { WM_DESTROY
, sent
},
455 { WM_DESTROY
, sent
|optional
}, /* some other (IME?) window */
456 { WM_NCDESTROY
, sent
|optional
}, /* some other (IME?) window */
457 { WM_NCDESTROY
, sent
},
460 /* Moving the mouse in nonclient area */
461 static const struct message WmMouseMoveInNonClientAreaSeq
[] = { /* FIXME: add */
462 { WM_NCHITTEST
, sent
},
463 { WM_SETCURSOR
, sent
},
464 { WM_NCMOUSEMOVE
, posted
},
467 /* Moving the mouse in client area */
468 static const struct message WmMouseMoveInClientAreaSeq
[] = { /* FIXME: add */
469 { WM_NCHITTEST
, sent
},
470 { WM_SETCURSOR
, sent
},
471 { WM_MOUSEMOVE
, posted
},
474 /* Moving by dragging the title bar (after WM_NCHITTEST and WM_SETCURSOR) (outline move) */
475 static const struct message WmDragTitleBarSeq
[] = { /* FIXME: add */
476 { WM_NCLBUTTONDOWN
, sent
|wparam
, HTCAPTION
},
477 { WM_SYSCOMMAND
, sent
|defwinproc
|wparam
, SC_MOVE
+2 },
478 { WM_GETMINMAXINFO
, sent
|defwinproc
},
479 { WM_ENTERSIZEMOVE
, sent
|defwinproc
},
480 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, 0 },
481 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, 0 },
482 { WM_MOVE
, sent
|defwinproc
},
483 { WM_EXITSIZEMOVE
, sent
|defwinproc
},
486 /* Sizing by dragging the thick borders (after WM_NCHITTEST and WM_SETCURSOR) (outline move) */
487 static const struct message WmDragThickBordersBarSeq
[] = { /* FIXME: add */
488 { WM_NCLBUTTONDOWN
, sent
|wparam
, 0xd },
489 { WM_SYSCOMMAND
, sent
|defwinproc
|wparam
, 0xf004 },
490 { WM_GETMINMAXINFO
, sent
|defwinproc
},
491 { WM_ENTERSIZEMOVE
, sent
|defwinproc
},
492 { WM_SIZING
, sent
|defwinproc
|wparam
, 4}, /* one for each mouse movement */
493 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, 0 },
494 { WM_GETMINMAXINFO
, sent
|defwinproc
},
495 { WM_NCCALCSIZE
, sent
|defwinproc
|wparam
, 1 },
496 { WM_NCPAINT
, sent
|defwinproc
|wparam
, 1 },
497 { WM_GETTEXT
, sent
|defwinproc
},
498 { WM_ERASEBKGND
, sent
|defwinproc
},
499 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, 0 },
500 { WM_MOVE
, sent
|defwinproc
},
501 { WM_SIZE
, sent
|defwinproc
},
502 { WM_EXITSIZEMOVE
, sent
|defwinproc
},
505 /* Resizing child window with MoveWindow (32) */
506 static const struct message WmResizingChildWithMoveWindowSeq
[] = {
507 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOZORDER
},
508 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
509 { WM_ERASEBKGND
, sent
|optional
},
510 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOZORDER
},
511 { WM_MOVE
, sent
|defwinproc
},
512 { WM_SIZE
, sent
|defwinproc
},
513 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
516 /* Clicking on inactive button */
517 static const struct message WmClickInactiveButtonSeq
[] = { /* FIXME: add */
518 { WM_NCHITTEST
, sent
},
519 { WM_PARENTNOTIFY
, sent
|parent
|wparam
, WM_LBUTTONDOWN
},
520 { WM_MOUSEACTIVATE
, sent
},
521 { WM_MOUSEACTIVATE
, sent
|parent
|defwinproc
},
522 { WM_SETCURSOR
, sent
},
523 { WM_SETCURSOR
, sent
|parent
|defwinproc
},
524 { WM_LBUTTONDOWN
, posted
},
525 { WM_KILLFOCUS
, posted
|parent
},
526 { WM_SETFOCUS
, posted
},
527 { WM_CTLCOLORBTN
, posted
|parent
},
528 { BM_SETSTATE
, posted
},
529 { WM_CTLCOLORBTN
, posted
|parent
},
530 { WM_LBUTTONUP
, posted
},
531 { BM_SETSTATE
, posted
},
532 { WM_CTLCOLORBTN
, posted
|parent
},
533 { WM_COMMAND
, posted
|parent
},
536 /* Reparenting a button (16/32) */
537 /* The last child (button) reparented gets topmost for its new parent. */
538 static const struct message WmReparentButtonSeq
[] = { /* FIXME: add */
539 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
540 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOZORDER
},
541 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
542 { WM_ERASEBKGND
, sent
|parent
},
543 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOZORDER
},
544 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
|SWP_NOZORDER
},
545 { WM_CHILDACTIVATE
, sent
},
546 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOSIZE
|SWP_NOREDRAW
|SWP_NOZORDER
},
547 { WM_MOVE
, sent
|defwinproc
},
548 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
551 /* Creation of a custom dialog (32) */
552 static const struct message WmCreateCustomDialogSeq
[] = {
553 { HCBT_CREATEWND
, hook
},
554 { EVENT_OBJECT_DEFACTIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
555 { WM_GETMINMAXINFO
, sent
},
556 { EVENT_OBJECT_DEFACTIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
557 { WM_NCCREATE
, sent
},
558 { EVENT_OBJECT_DEFACTIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
559 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
560 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
561 { EVENT_OBJECT_DEFACTIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
563 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
564 { EVENT_OBJECT_DEFACTIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
565 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
566 { EVENT_OBJECT_DEFACTIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
567 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
568 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
569 { HCBT_ACTIVATE
, hook
},
570 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
572 { EVENT_OBJECT_DEFACTIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
574 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
575 { EVENT_OBJECT_DEFACTIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, OBJID_CLIENT
, 0 },
577 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
},
579 { EVENT_OBJECT_DEFACTIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
580 { WM_NCACTIVATE
, sent
|wparam
, 1 },
581 { EVENT_OBJECT_DEFACTIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
582 { WM_GETTEXT
, sent
|optional
|defwinproc
},
583 { EVENT_OBJECT_DEFACTIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, OBJID_CLIENT
, 0 },
584 { WM_GETICON
, sent
|optional
|defwinproc
},
585 { EVENT_OBJECT_DEFACTIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, OBJID_CLIENT
, 0 },
586 { WM_GETICON
, sent
|optional
|defwinproc
},
587 { EVENT_OBJECT_DEFACTIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, OBJID_CLIENT
, 0 },
588 { WM_GETICON
, sent
|optional
|defwinproc
},
589 { EVENT_OBJECT_DEFACTIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, OBJID_CLIENT
, 0 },
590 { WM_GETTEXT
, sent
|optional
|defwinproc
},
591 { EVENT_OBJECT_DEFACTIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, OBJID_CLIENT
, 0 },
592 { WM_ACTIVATE
, sent
|wparam
, 1 },
593 { WM_KILLFOCUS
, sent
|parent
},
594 { EVENT_OBJECT_DEFACTIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, OBJID_CLIENT
, 0 },
595 { WM_IME_SETCONTEXT
, sent
|parent
|wparam
|optional
, 0 },
596 { EVENT_OBJECT_DEFACTIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, OBJID_CLIENT
, 0 },
597 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
598 { EVENT_OBJECT_DEFACTIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, OBJID_CLIENT
, 0 },
599 { WM_IME_NOTIFY
, sent
|optional
|defwinproc
},
600 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
601 { EVENT_OBJECT_DEFACTIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
602 { WM_SETFOCUS
, sent
},
603 { EVENT_OBJECT_DEFACTIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
604 { WM_GETDLGCODE
, sent
|defwinproc
|wparam
, 0 },
605 { EVENT_OBJECT_DEFACTIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
606 { WM_NCPAINT
, sent
|wparam
, 1 },
607 { EVENT_OBJECT_DEFACTIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, OBJID_CLIENT
, 0 },
608 { WM_GETTEXT
, sent
|optional
|defwinproc
},
609 { EVENT_OBJECT_DEFACTIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, OBJID_CLIENT
, 0 },
610 { WM_GETICON
, sent
|optional
|defwinproc
},
611 { EVENT_OBJECT_DEFACTIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, OBJID_CLIENT
, 0 },
612 { WM_GETICON
, sent
|optional
|defwinproc
},
613 { EVENT_OBJECT_DEFACTIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, OBJID_CLIENT
, 0 },
614 { WM_GETICON
, sent
|optional
|defwinproc
},
615 { EVENT_OBJECT_DEFACTIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, OBJID_CLIENT
, 0 },
616 { WM_GETTEXT
, sent
|optional
|defwinproc
},
617 { WM_ERASEBKGND
, sent
},
618 { EVENT_OBJECT_DEFACTIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
619 { WM_CTLCOLORDLG
, sent
|defwinproc
},
620 { EVENT_OBJECT_DEFACTIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
621 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
622 { EVENT_OBJECT_DEFACTIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, OBJID_CLIENT
, 0 },
623 { WM_GETTEXT
, sent
|optional
},
624 { EVENT_OBJECT_DEFACTIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, OBJID_CLIENT
, 0 },
625 { WM_GETICON
, sent
|optional
},
626 { EVENT_OBJECT_DEFACTIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, OBJID_CLIENT
, 0 },
627 { WM_GETICON
, sent
|optional
},
628 { EVENT_OBJECT_DEFACTIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, OBJID_CLIENT
, 0 },
629 { WM_GETICON
, sent
|optional
},
630 { EVENT_OBJECT_DEFACTIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, OBJID_CLIENT
, 0 },
631 { WM_GETTEXT
, sent
|optional
},
632 { EVENT_OBJECT_DEFACTIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, OBJID_CLIENT
, 0 },
633 { WM_NCCALCSIZE
, sent
|optional
},
634 { EVENT_OBJECT_DEFACTIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, OBJID_CLIENT
, 0 },
635 { WM_NCPAINT
, sent
|optional
},
636 { EVENT_OBJECT_DEFACTIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, OBJID_CLIENT
, 0 },
637 { WM_GETTEXT
, sent
|optional
|defwinproc
},
638 { EVENT_OBJECT_DEFACTIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, OBJID_CLIENT
, 0 },
639 { WM_GETICON
, sent
|optional
|defwinproc
},
640 { EVENT_OBJECT_DEFACTIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, OBJID_CLIENT
, 0 },
641 { WM_GETICON
, sent
|optional
|defwinproc
},
642 { EVENT_OBJECT_DEFACTIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, OBJID_CLIENT
, 0 },
643 { WM_GETICON
, sent
|optional
|defwinproc
},
644 { EVENT_OBJECT_DEFACTIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, OBJID_CLIENT
, 0 },
645 { WM_GETTEXT
, sent
|optional
|defwinproc
},
646 { WM_ERASEBKGND
, sent
|optional
},
647 { EVENT_OBJECT_DEFACTIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, OBJID_CLIENT
, 0 },
648 { WM_CTLCOLORDLG
, sent
|optional
|defwinproc
},
650 { EVENT_OBJECT_DEFACTIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
654 /* Calling EndDialog for a custom dialog (32) */
655 static const struct message WmEndCustomDialogSeq
[] = {
656 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
},
657 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
658 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
659 { WM_GETTEXT
, sent
|optional
},
660 { WM_GETICON
, sent
|optional
},
661 { WM_GETICON
, sent
|optional
},
662 { WM_GETICON
, sent
|optional
},
663 { HCBT_ACTIVATE
, hook
},
664 { WM_NCACTIVATE
, sent
|wparam
, 0 },
665 { WM_GETTEXT
, sent
|optional
|defwinproc
},
666 { WM_GETICON
, sent
|optional
|defwinproc
},
667 { WM_GETICON
, sent
|optional
|defwinproc
},
668 { WM_GETICON
, sent
|optional
|defwinproc
},
669 { WM_GETTEXT
, sent
|optional
|defwinproc
},
670 { WM_ACTIVATE
, sent
|wparam
, 0 },
671 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
672 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
673 { HCBT_SETFOCUS
, hook
},
674 { WM_KILLFOCUS
, sent
},
675 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
676 { WM_IME_SETCONTEXT
, sent
|parent
|wparam
|defwinproc
|optional
, 1 },
677 { WM_IME_NOTIFY
, sent
|optional
},
678 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
679 { WM_SETFOCUS
, sent
|parent
|defwinproc
},
682 /* ShowWindow(SW_SHOW) for a custom dialog (initially invisible) */
683 static const struct message WmShowCustomDialogSeq
[] = {
684 { EVENT_OBJECT_DEFACTIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
685 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
686 { EVENT_OBJECT_DEFACTIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
687 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
688 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
689 { HCBT_ACTIVATE
, hook
},
690 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
692 { EVENT_OBJECT_DEFACTIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, OBJID_CLIENT
, 0 },
693 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
695 { EVENT_OBJECT_DEFACTIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, OBJID_CLIENT
, 0 },
696 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
},
697 { EVENT_OBJECT_DEFACTIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
698 { WM_ACTIVATEAPP
, sent
|wparam
|optional
, 1 },
699 { EVENT_OBJECT_DEFACTIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, OBJID_CLIENT
, 0 },
700 { WM_NCACTIVATE
, sent
|wparam
, 1 },
701 { EVENT_OBJECT_DEFACTIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
702 { WM_ACTIVATE
, sent
|wparam
, 1 },
704 { WM_KILLFOCUS
, sent
|parent
},
705 { WM_IME_SETCONTEXT
, sent
|parent
|wparam
|optional
, 0 },
706 { EVENT_OBJECT_DEFACTIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, OBJID_CLIENT
, 0 },
707 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
708 { EVENT_OBJECT_DEFACTIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, OBJID_CLIENT
, 0 },
709 { WM_IME_NOTIFY
, sent
|optional
|defwinproc
},
710 { EVENT_OBJECT_DEFACTIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, OBJID_CLIENT
, 0 },
711 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
712 { EVENT_OBJECT_DEFACTIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
713 { WM_SETFOCUS
, sent
},
714 { EVENT_OBJECT_DEFACTIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
715 { WM_GETDLGCODE
, sent
|defwinproc
|wparam
, 0 },
716 { EVENT_OBJECT_DEFACTIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
717 { WM_NCPAINT
, sent
|wparam
, 1 },
718 { EVENT_OBJECT_DEFACTIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
719 { WM_ERASEBKGND
, sent
},
720 { EVENT_OBJECT_DEFACTIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
721 { WM_CTLCOLORDLG
, sent
|defwinproc
},
723 { EVENT_OBJECT_DEFACTIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
724 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
727 /* Creation and destruction of a modal dialog (32) */
728 static const struct message WmModalDialogSeq
[] = {
729 { WM_CANCELMODE
, sent
|parent
},
730 { HCBT_SETFOCUS
, hook
},
731 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
732 { WM_KILLFOCUS
, sent
|parent
},
733 { WM_IME_SETCONTEXT
, sent
|parent
|wparam
|optional
, 0 },
734 { EVENT_OBJECT_STATECHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
735 { WM_ENABLE
, sent
|parent
|wparam
, 0 },
736 { HCBT_CREATEWND
, hook
},
737 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
738 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
739 { WM_SETFONT
, sent
},
740 { WM_INITDIALOG
, sent
},
741 { WM_CHANGEUISTATE
, sent
|optional
},
742 { WM_SHOWWINDOW
, sent
},
743 { HCBT_ACTIVATE
, hook
},
744 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
745 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
746 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
},
747 { WM_NCACTIVATE
, sent
|wparam
, 1 },
748 { WM_GETICON
, sent
|optional
},
749 { WM_GETICON
, sent
|optional
},
750 { WM_GETICON
, sent
|optional
},
751 { WM_GETTEXT
, sent
|optional
},
752 { WM_ACTIVATE
, sent
|wparam
, 1 },
753 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
|SWP_NOACTIVATE
},
754 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
755 { WM_NCPAINT
, sent
},
756 { WM_GETICON
, sent
|optional
},
757 { WM_GETICON
, sent
|optional
},
758 { WM_GETICON
, sent
|optional
},
759 { WM_GETTEXT
, sent
|optional
},
760 { WM_ERASEBKGND
, sent
},
761 { WM_CTLCOLORDLG
, sent
},
762 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
|SWP_NOACTIVATE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
763 { WM_GETICON
, sent
|optional
},
764 { WM_GETICON
, sent
|optional
},
765 { WM_GETICON
, sent
|optional
},
766 { WM_GETTEXT
, sent
|optional
},
767 { WM_NCCALCSIZE
, sent
|optional
},
768 { WM_NCPAINT
, sent
|optional
},
769 { WM_GETICON
, sent
|optional
},
770 { WM_GETICON
, sent
|optional
},
771 { WM_GETICON
, sent
|optional
},
772 { WM_GETTEXT
, sent
|optional
},
773 { WM_ERASEBKGND
, sent
|optional
},
774 { WM_CTLCOLORDLG
, sent
|optional
},
775 { WM_PAINT
, sent
|optional
},
776 { WM_CTLCOLORBTN
, sent
},
777 { WM_ENTERIDLE
, sent
|parent
|optional
},
778 { WM_ENTERIDLE
, sent
|parent
|optional
},
779 { WM_ENTERIDLE
, sent
|parent
|optional
},
780 { WM_ENTERIDLE
, sent
|parent
|optional
},
781 { WM_ENTERIDLE
, sent
|parent
|optional
},
782 { WM_ENTERIDLE
, sent
|parent
|optional
},
783 { WM_ENTERIDLE
, sent
|parent
|optional
},
784 { WM_ENTERIDLE
, sent
|parent
|optional
},
785 { WM_ENTERIDLE
, sent
|parent
|optional
},
786 { WM_ENTERIDLE
, sent
|parent
|optional
},
787 { WM_ENTERIDLE
, sent
|parent
|optional
},
788 { WM_ENTERIDLE
, sent
|parent
|optional
},
789 { WM_ENTERIDLE
, sent
|parent
|optional
},
790 { WM_ENTERIDLE
, sent
|parent
|optional
},
791 { WM_ENTERIDLE
, sent
|parent
|optional
},
792 { WM_ENTERIDLE
, sent
|parent
|optional
},
793 { WM_ENTERIDLE
, sent
|parent
|optional
},
794 { WM_ENTERIDLE
, sent
|parent
|optional
},
795 { WM_ENTERIDLE
, sent
|parent
|optional
},
796 { WM_ENTERIDLE
, sent
|parent
|optional
},
797 { WM_GETICON
, sent
|parent
|optional
},
798 { WM_GETICON
, sent
|parent
|optional
},
799 { WM_GETICON
, sent
|parent
|optional
},
801 { EVENT_OBJECT_STATECHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
802 { WM_ENABLE
, sent
|parent
|wparam
, 1 },
803 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
|SWP_NOACTIVATE
},
804 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
805 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
|SWP_NOACTIVATE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
806 { WM_GETICON
, sent
|optional
},
807 { WM_GETICON
, sent
|optional
},
808 { WM_GETICON
, sent
|optional
},
809 { WM_GETTEXT
, sent
|optional
},
810 { HCBT_ACTIVATE
, hook
},
811 { WM_NCACTIVATE
, sent
|wparam
, 0 },
812 { WM_GETICON
, sent
|optional
},
813 { WM_GETICON
, sent
|optional
},
814 { WM_GETICON
, sent
|optional
},
815 { WM_GETTEXT
, sent
|optional
},
816 { WM_ACTIVATE
, sent
|wparam
, 0 },
817 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
818 { WM_WINDOWPOSCHANGING
, sent
|optional
},
819 { HCBT_SETFOCUS
, hook
},
820 { WM_IME_SETCONTEXT
, sent
|parent
|wparam
|defwinproc
|optional
, 1 },
821 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
822 { WM_SETFOCUS
, sent
|parent
|defwinproc
},
823 { EVENT_SYSTEM_DIALOGEND
, winevent_hook
|wparam
|lparam
, 0, 0 },
824 { HCBT_DESTROYWND
, hook
},
825 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
826 { WM_DESTROY
, sent
},
827 { WM_NCDESTROY
, sent
},
830 /* Creation of a modal dialog that is resized inside WM_INITDIALOG (32) */
831 static const struct message WmCreateModalDialogResizeSeq
[] = { /* FIXME: add */
832 /* (inside dialog proc, handling WM_INITDIALOG) */
833 { WM_WINDOWPOSCHANGING
, sent
|wparam
, 0 },
834 { WM_NCCALCSIZE
, sent
},
835 { WM_NCACTIVATE
, sent
|parent
|wparam
, 0 },
836 { WM_GETTEXT
, sent
|defwinproc
},
837 { WM_ACTIVATE
, sent
|parent
|wparam
, 0 },
838 { WM_WINDOWPOSCHANGING
, sent
|wparam
, 0 },
839 { WM_WINDOWPOSCHANGING
, sent
|parent
},
840 { WM_NCACTIVATE
, sent
|wparam
, 1 },
841 { WM_ACTIVATE
, sent
|wparam
, 1 },
842 { WM_WINDOWPOSCHANGED
, sent
|wparam
, 0 },
843 { WM_SIZE
, sent
|defwinproc
},
844 /* (setting focus) */
845 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
846 { WM_WINDOWPOSCHANGING
, sent
|wparam
, 0 },
847 { WM_NCPAINT
, sent
},
848 { WM_GETTEXT
, sent
|defwinproc
},
849 { WM_ERASEBKGND
, sent
},
850 { WM_CTLCOLORDLG
, sent
|defwinproc
},
851 { WM_WINDOWPOSCHANGED
, sent
|wparam
, 0 },
853 /* (bunch of WM_CTLCOLOR* for each control) */
854 { WM_PAINT
, sent
|parent
},
855 { WM_ENTERIDLE
, sent
|parent
|wparam
, 0 },
856 { WM_SETCURSOR
, sent
|parent
},
859 /* SetMenu for NonVisible windows with size change*/
860 static const struct message WmSetMenuNonVisibleSizeChangeSeq
[] = {
861 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
},
862 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
863 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
864 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
|SWP_NOREDRAW
},
865 { WM_MOVE
, sent
|defwinproc
},
866 { WM_SIZE
, sent
|defwinproc
},
867 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
868 { WM_GETICON
, sent
|optional
},
869 { WM_GETICON
, sent
|optional
},
870 { WM_GETICON
, sent
|optional
},
871 { WM_GETTEXT
, sent
|optional
},
872 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
875 /* SetMenu for NonVisible windows with no size change */
876 static const struct message WmSetMenuNonVisibleNoSizeChangeSeq
[] = {
877 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
},
878 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
879 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
880 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
883 /* SetMenu for Visible windows with size change */
884 static const struct message WmSetMenuVisibleSizeChangeSeq
[] = {
885 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
},
886 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
887 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
888 { WM_NCPAINT
, sent
|wparam
, 1 },
889 { WM_GETTEXT
, sent
|defwinproc
|optional
},
890 { WM_ERASEBKGND
, sent
|optional
},
891 { WM_ACTIVATE
, sent
|optional
},
892 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
},
893 { WM_MOVE
, sent
|defwinproc
},
894 { WM_SIZE
, sent
|defwinproc
},
895 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
896 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
897 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
898 { WM_ERASEBKGND
, sent
|optional
},
901 /* SetMenu for Visible windows with no size change */
902 static const struct message WmSetMenuVisibleNoSizeChangeSeq
[] = {
903 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
},
904 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
905 { WM_NCPAINT
, sent
|wparam
, 1 },
906 { WM_GETTEXT
, sent
|defwinproc
|optional
},
907 { WM_ERASEBKGND
, sent
|optional
},
908 { WM_ACTIVATE
, sent
|optional
},
909 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
910 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
913 /* DrawMenuBar for a visible window */
914 static const struct message WmDrawMenuBarSeq
[] =
916 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
},
917 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
918 { WM_NCPAINT
, sent
|wparam
, 1 },
919 { WM_GETTEXT
, sent
|defwinproc
|optional
},
920 { WM_ERASEBKGND
, sent
|optional
},
921 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
922 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
926 static const struct message WmSetRedrawFalseSeq
[] =
928 { WM_SETREDRAW
, sent
|wparam
, 0 },
932 static const struct message WmSetRedrawTrueSeq
[] =
934 { WM_SETREDRAW
, sent
|wparam
, 1 },
938 static const struct message WmEnableWindowSeq
[] =
940 { WM_CANCELMODE
, sent
},
941 { EVENT_OBJECT_STATECHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
946 static const struct message WmGetScrollRangeSeq
[] =
948 { SBM_GETRANGE
, sent
},
951 static const struct message WmGetScrollInfoSeq
[] =
953 { SBM_GETSCROLLINFO
, sent
},
956 static const struct message WmSetScrollRangeSeq
[] =
958 /* MSDN claims that Windows sends SBM_SETRANGE message, but win2k SP4
959 sends SBM_SETSCROLLINFO.
961 { SBM_SETSCROLLINFO
, sent
},
964 /* SetScrollRange for a window without a non-client area */
965 static const struct message WmSetScrollRangeHSeq_empty
[] =
967 { EVENT_OBJECT_VALUECHANGE
, winevent_hook
|wparam
|lparam
, OBJID_HSCROLL
, 0 },
970 static const struct message WmSetScrollRangeVSeq_empty
[] =
972 { EVENT_OBJECT_VALUECHANGE
, winevent_hook
|wparam
|lparam
, OBJID_VSCROLL
, 0 },
975 static const struct message WmSetScrollRangeHVSeq
[] =
977 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOZORDER
},
978 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
979 { WM_GETTEXT
, sent
|defwinproc
|optional
},
980 { WM_ERASEBKGND
, sent
|optional
},
981 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOZORDER
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
982 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
985 /* SetScrollRange for a window with a non-client area */
986 static const struct message WmSetScrollRangeHV_NC_Seq
[] =
988 { WM_WINDOWPOSCHANGING
, sent
, /*|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER*/ },
989 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
990 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
991 { WM_NCPAINT
, sent
|optional
},
992 { WM_GETTEXT
, sent
|defwinproc
|optional
},
993 { WM_GETICON
, sent
|optional
|defwinproc
},
994 { WM_GETICON
, sent
|optional
|defwinproc
},
995 { WM_GETICON
, sent
|optional
|defwinproc
},
996 { WM_GETTEXT
, sent
|defwinproc
|optional
},
997 { WM_ERASEBKGND
, sent
|optional
},
998 { WM_CTLCOLORDLG
, sent
|defwinproc
|optional
}, /* sent to a parent of the dialog */
999 { WM_WINDOWPOSCHANGED
, sent
, /*|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|0x1000*/ },
1000 { WM_SIZE
, sent
|defwinproc
},
1001 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1002 { WM_GETTEXT
, sent
|optional
},
1003 { WM_GETICON
, sent
|optional
},
1004 { WM_GETICON
, sent
|optional
},
1005 { WM_GETICON
, sent
|optional
},
1006 { WM_GETTEXT
, sent
|optional
},
1007 { WM_GETICON
, sent
|optional
},
1008 { WM_GETICON
, sent
|optional
},
1009 { WM_GETICON
, sent
|optional
},
1010 { WM_GETTEXT
, sent
|optional
},
1011 { WM_GETICON
, sent
|optional
},
1012 { WM_GETICON
, sent
|optional
},
1013 { WM_GETICON
, sent
|optional
},
1014 { WM_GETTEXT
, sent
|optional
},
1017 /* test if we receive the right sequence of messages */
1018 /* after calling ShowWindow( SW_SHOWNA) */
1019 static const struct message WmSHOWNAChildInvisParInvis
[] = {
1020 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1023 static const struct message WmSHOWNAChildVisParInvis
[] = {
1024 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1027 static const struct message WmSHOWNAChildVisParVis
[] = {
1028 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1029 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOZORDER
},
1032 static const struct message WmSHOWNAChildInvisParVis
[] = {
1033 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1034 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
},
1035 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1036 { WM_ERASEBKGND
, sent
|optional
},
1037 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOACTIVATE
|SWP_NOZORDER
|SWP_NOCLIENTMOVE
},
1040 static const struct message WmSHOWNATopVisible
[] = {
1041 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1042 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
1045 static const struct message WmSHOWNATopInvisible
[] = {
1046 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1047 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1048 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1049 { WM_NCPAINT
, sent
|wparam
, 1 },
1050 { WM_GETICON
, sent
|optional
},
1051 { WM_GETICON
, sent
|optional
},
1052 { WM_GETICON
, sent
|optional
},
1053 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1054 { WM_ERASEBKGND
, sent
|optional
},
1055 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1056 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
1057 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
1058 { WM_ERASEBKGND
, sent
|optional
},
1064 static int after_end_dialog
;
1065 static int sequence_cnt
, sequence_size
;
1066 static struct message
* sequence
;
1067 static int log_all_parent_messages
;
1069 static void add_message(const struct message
*msg
)
1074 sequence
= HeapAlloc( GetProcessHeap(), 0, sequence_size
* sizeof (struct message
) );
1076 if (sequence_cnt
== sequence_size
)
1079 sequence
= HeapReAlloc( GetProcessHeap(), 0, sequence
, sequence_size
* sizeof (struct message
) );
1083 sequence
[sequence_cnt
].message
= msg
->message
;
1084 sequence
[sequence_cnt
].flags
= msg
->flags
;
1085 sequence
[sequence_cnt
].wParam
= msg
->wParam
;
1086 sequence
[sequence_cnt
].lParam
= msg
->lParam
;
1091 static void flush_sequence()
1093 HeapFree(GetProcessHeap(), 0, sequence
);
1095 sequence_cnt
= sequence_size
= 0;
1098 #define ok_sequence( exp, contx, todo) \
1099 ok_sequence_( (exp), (contx), (todo), __FILE__, __LINE__)
1102 static void ok_sequence_(const struct message
*expected
, const char *context
, int todo
,
1103 const char *file
, int line
)
1105 static const struct message end_of_sequence
= { 0, 0, 0, 0 };
1106 const struct message
*actual
;
1109 add_message(&end_of_sequence
);
1113 while (expected
->message
&& actual
->message
)
1115 trace_( file
, line
)("expected %04x - actual %04x\n", expected
->message
, actual
->message
);
1117 if (expected
->message
== actual
->message
)
1119 if (expected
->flags
& wparam
)
1121 if (expected
->wParam
!= actual
->wParam
&& todo
)
1125 ok_( file
, line
) (FALSE
,
1126 "%s: in msg 0x%04x expecting wParam 0x%x got 0x%x\n",
1127 context
, expected
->message
, expected
->wParam
, actual
->wParam
);
1131 ok_( file
, line
) (expected
->wParam
== actual
->wParam
,
1132 "%s: in msg 0x%04x expecting wParam 0x%x got 0x%x\n",
1133 context
, expected
->message
, expected
->wParam
, actual
->wParam
);
1135 if (expected
->flags
& lparam
)
1136 ok_( file
, line
) (expected
->lParam
== actual
->lParam
,
1137 "%s: in msg 0x%04x expecting lParam 0x%lx got 0x%lx\n",
1138 context
, expected
->message
, expected
->lParam
, actual
->lParam
);
1139 ok_( file
, line
) ((expected
->flags
& defwinproc
) == (actual
->flags
& defwinproc
),
1140 "%s: the msg 0x%04x should %shave been sent by DefWindowProc\n",
1141 context
, expected
->message
, (expected
->flags
& defwinproc
) ? "" : "NOT ");
1142 ok_( file
, line
) ((expected
->flags
& beginpaint
) == (actual
->flags
& beginpaint
),
1143 "%s: the msg 0x%04x should %shave been sent by BeginPaint\n",
1144 context
, expected
->message
, (expected
->flags
& beginpaint
) ? "" : "NOT ");
1145 ok_( file
, line
) ((expected
->flags
& (sent
|posted
)) == (actual
->flags
& (sent
|posted
)),
1146 "%s: the msg 0x%04x should have been %s\n",
1147 context
, expected
->message
, (expected
->flags
& posted
) ? "posted" : "sent");
1148 ok_( file
, line
) ((expected
->flags
& parent
) == (actual
->flags
& parent
),
1149 "%s: the msg 0x%04x was expected in %s\n",
1150 context
, expected
->message
, (expected
->flags
& parent
) ? "parent" : "child");
1151 ok_( file
, line
) ((expected
->flags
& hook
) == (actual
->flags
& hook
),
1152 "%s: the msg 0x%04x should have been sent by a hook\n",
1153 context
, expected
->message
);
1154 ok_( file
, line
) ((expected
->flags
& winevent_hook
) == (actual
->flags
& winevent_hook
),
1155 "%s: the msg 0x%04x should have been sent by a winevent hook\n",
1156 context
, expected
->message
);
1160 /* silently drop winevent messages if there is no support for them */
1161 else if ((expected
->flags
& optional
) || ((expected
->flags
& winevent_hook
) && !hEvent_hook
))
1167 ok_( file
, line
) (FALSE
, "%s: the msg 0x%04x was expected, but got msg 0x%04x instead\n",
1168 context
, expected
->message
, actual
->message
);
1175 ok_( file
, line
) (FALSE
, "%s: the msg 0x%04x was expected, but got msg 0x%04x instead\n",
1176 context
, expected
->message
, actual
->message
);
1182 /* skip all optional trailing messages */
1183 while (expected
->message
&& ((expected
->flags
& optional
) ||
1184 ((expected
->flags
& winevent_hook
) && !hEvent_hook
)))
1190 if (expected
->message
|| actual
->message
) {
1192 ok_( file
, line
) (FALSE
, "%s: the msg sequence is not complete: expected %04x - actual %04x\n",
1193 context
, expected
->message
, actual
->message
);
1199 if (expected
->message
|| actual
->message
)
1200 ok_( file
, line
) (FALSE
, "%s: the msg sequence is not complete: expected %04x - actual %04x\n",
1201 context
, expected
->message
, actual
->message
);
1203 if( todo
&& !failcount
) /* succeeded yet marked todo */
1205 ok_( file
, line
)( TRUE
, "%s: marked \"todo_wine\" but succeeds\n", context
);
1211 /******************************** MDI test **********************************/
1213 /* CreateWindow for MDI frame window, initially visible */
1214 static const struct message WmCreateMDIframeSeq
[] = {
1215 { HCBT_CREATEWND
, hook
},
1216 { WM_GETMINMAXINFO
, sent
},
1217 { WM_NCCREATE
, sent
},
1218 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
1219 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
1220 { WM_CREATE
, sent
},
1221 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1222 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1223 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
1224 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1225 { HCBT_ACTIVATE
, hook
},
1226 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
1227 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
1228 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
},
1229 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
}, /* Win9x */
1230 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
1231 { WM_NCACTIVATE
, sent
|wparam
, 1 },
1232 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1233 { WM_GETICON
, sent
|defwinproc
|optional
},
1234 { WM_GETICON
, sent
|defwinproc
|optional
},
1235 { WM_ACTIVATE
, sent
|wparam
, 1 },
1236 { HCBT_SETFOCUS
, hook
},
1237 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
1238 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1239 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
1240 /* Win9x adds SWP_NOZORDER below */
1241 { WM_WINDOWPOSCHANGED
, sent
, /*|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE*/ },
1246 /* DestroyWindow for MDI frame window, initially visible */
1247 static const struct message WmDestroyMDIframeSeq
[] = {
1248 { HCBT_DESTROYWND
, hook
},
1249 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
},
1250 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1251 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1252 { WM_NCACTIVATE
, sent
|wparam
, 0 },
1253 { WM_ACTIVATE
, sent
|wparam
|optional
, 0 }, /* Win9x */
1254 { WM_ACTIVATEAPP
, sent
|wparam
|optional
, 0 }, /* Win9x */
1255 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
1256 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
1257 { WM_DESTROY
, sent
},
1258 { WM_NCDESTROY
, sent
},
1261 /* CreateWindow for MDI client window, initially visible */
1262 static const struct message WmCreateMDIclientSeq
[] = {
1263 { HCBT_CREATEWND
, hook
},
1264 { WM_NCCREATE
, sent
},
1265 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
1266 { WM_CREATE
, sent
},
1267 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1270 { WM_PARENTNOTIFY
, sent
|wparam
, WM_CREATE
}, /* in MDI frame */
1271 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1272 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOZORDER
|SWP_NOSIZE
|SWP_NOMOVE
},
1273 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1274 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOZORDER
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1277 /* DestroyWindow for MDI client window, initially visible */
1278 static const struct message WmDestroyMDIclientSeq
[] = {
1279 { HCBT_DESTROYWND
, hook
},
1280 { WM_PARENTNOTIFY
, sent
|wparam
, WM_DESTROY
}, /* in MDI frame */
1281 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
1282 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
},
1283 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1284 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1285 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
1286 { WM_DESTROY
, sent
},
1287 { WM_NCDESTROY
, sent
},
1290 /* CreateWindow for MDI child window, initially visible */
1291 static const struct message WmCreateMDIchildVisibleSeq
[] = {
1292 { HCBT_CREATEWND
, hook
},
1293 { WM_NCCREATE
, sent
},
1294 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
1295 { WM_CREATE
, sent
},
1296 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1299 /* Win2k sends wparam set to
1300 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
1301 * while Win9x doesn't bother to set child window id according to
1302 * CLIENTCREATESTRUCT.idFirstChild
1304 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
1305 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1306 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
},
1307 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1308 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1309 { WM_MDIREFRESHMENU
, sent
/*|wparam|lparam, 0, 0*/ },
1310 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
1311 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
1312 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1314 /* Win9x: message sequence terminates here. */
1316 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 },
1317 { HCBT_SETFOCUS
, hook
}, /* in MDI client */
1318 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
1319 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1320 { WM_SETFOCUS
, sent
}, /* in MDI client */
1321 { HCBT_SETFOCUS
, hook
},
1322 { WM_KILLFOCUS
, sent
}, /* in MDI client */
1323 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
1324 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
1325 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1326 { WM_SETFOCUS
, sent
|defwinproc
},
1327 { WM_MDIACTIVATE
, sent
|defwinproc
},
1330 /* DestroyWindow for MDI child window, initially visible */
1331 static const struct message WmDestroyMDIchildVisibleSeq
[] = {
1332 { HCBT_DESTROYWND
, hook
},
1333 /* Win2k sends wparam set to
1334 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
1335 * while Win9x doesn't bother to set child window id according to
1336 * CLIENTCREATESTRUCT.idFirstChild
1338 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_DESTROY*/ }, /* in MDI client */
1339 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
1340 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
},
1341 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1342 { WM_ERASEBKGND
, sent
|parent
|optional
},
1343 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1345 /* { WM_DESTROY, sent }
1346 * Win9x: message sequence terminates here.
1349 { HCBT_SETFOCUS
, hook
}, /* set focus to MDI client */
1350 { WM_KILLFOCUS
, sent
},
1351 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
1352 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
1353 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1354 { WM_SETFOCUS
, sent
}, /* in MDI client */
1356 { HCBT_SETFOCUS
, hook
}, /* MDI client sets focus back to MDI child */
1357 { WM_KILLFOCUS
, sent
}, /* in MDI client */
1358 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
1359 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
1360 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1361 { WM_SETFOCUS
, sent
}, /* in MDI client */
1363 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
1365 { HCBT_SETFOCUS
, hook
}, /* set focus to MDI client */
1366 { WM_KILLFOCUS
, sent
},
1367 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
1368 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
1369 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1370 { WM_SETFOCUS
, sent
}, /* in MDI client */
1372 { HCBT_SETFOCUS
, hook
}, /* MDI client sets focus back to MDI child */
1373 { WM_KILLFOCUS
, sent
}, /* in MDI client */
1374 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
1375 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
1376 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1377 { WM_SETFOCUS
, sent
}, /* in MDI client */
1379 { WM_DESTROY
, sent
},
1381 { HCBT_SETFOCUS
, hook
}, /* set focus to MDI client */
1382 { WM_KILLFOCUS
, sent
},
1383 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
1384 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
1385 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1386 { WM_SETFOCUS
, sent
}, /* in MDI client */
1388 { HCBT_SETFOCUS
, hook
}, /* MDI client sets focus back to MDI child */
1389 { WM_KILLFOCUS
, sent
}, /* in MDI client */
1390 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
1391 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
1392 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1393 { WM_SETFOCUS
, sent
}, /* in MDI client */
1395 { WM_NCDESTROY
, sent
},
1398 /* CreateWindow for MDI child window, initially invisible */
1399 static const struct message WmCreateMDIchildInvisibleSeq
[] = {
1400 { HCBT_CREATEWND
, hook
},
1401 { WM_NCCREATE
, sent
},
1402 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
1403 { WM_CREATE
, sent
},
1404 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1407 /* Win2k sends wparam set to
1408 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
1409 * while Win9x doesn't bother to set child window id according to
1410 * CLIENTCREATESTRUCT.idFirstChild
1412 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
1415 /* DestroyWindow for MDI child window, initially invisible */
1416 static const struct message WmDestroyMDIchildInvisibleSeq
[] = {
1417 { HCBT_DESTROYWND
, hook
},
1418 /* Win2k sends wparam set to
1419 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
1420 * while Win9x doesn't bother to set child window id according to
1421 * CLIENTCREATESTRUCT.idFirstChild
1423 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_DESTROY*/ }, /* in MDI client */
1424 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
1425 { WM_DESTROY
, sent
},
1426 { WM_NCDESTROY
, sent
},
1429 /* CreateWindow for the 1st MDI child window, initially visible and maximized */
1430 static const struct message WmCreateMDIchildVisibleMaxSeq1
[] = {
1431 { HCBT_CREATEWND
, hook
},
1432 { WM_NCCREATE
, sent
},
1433 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
1434 { WM_CREATE
, sent
},
1435 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1438 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
1439 { WM_GETMINMAXINFO
, sent
},
1440 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|0x8000 },
1441 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1442 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|0x8000 },
1443 { WM_SIZE
, sent
|defwinproc
},
1445 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
},
1446 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1447 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1448 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
1449 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
1450 /* Win2k sends wparam set to
1451 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
1452 * while Win9x doesn't bother to set child window id according to
1453 * CLIENTCREATESTRUCT.idFirstChild
1455 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
1456 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1457 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
},
1458 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1459 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1460 { WM_MDIREFRESHMENU
, sent
/*|wparam|lparam, 0, 0*/ },
1461 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
1462 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
1463 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1465 /* Win9x: message sequence terminates here. */
1467 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 },
1468 { HCBT_SETFOCUS
, hook
}, /* in MDI client */
1469 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
1470 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1471 { WM_SETFOCUS
, sent
}, /* in MDI client */
1472 { HCBT_SETFOCUS
, hook
},
1473 { WM_KILLFOCUS
, sent
}, /* in MDI client */
1474 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
1475 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
1476 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1477 { WM_SETFOCUS
, sent
|defwinproc
},
1478 { WM_MDIACTIVATE
, sent
|defwinproc
},
1480 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
},
1481 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1482 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1483 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
1486 /* CreateWindow for the 2nd MDI child window, initially visible and maximized */
1487 static const struct message WmCreateMDIchildVisibleMaxSeq2
[] = {
1488 /* restore the 1st MDI child */
1489 { WM_SETREDRAW
, sent
|wparam
, 0 },
1490 { HCBT_MINMAX
, hook
},
1491 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|0x8000 },
1492 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1493 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
1494 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|0x8000 },
1495 { WM_SIZE
, sent
|defwinproc
},
1497 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
},
1498 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1499 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1500 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
1501 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
1502 { WM_SETREDRAW
, sent
|wparam
, 1 }, /* in the 1st MDI child */
1503 /* create the 2nd MDI child */
1504 { HCBT_CREATEWND
, hook
},
1505 { WM_NCCREATE
, sent
},
1506 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
1507 { WM_CREATE
, sent
},
1508 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1511 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
1512 { WM_GETMINMAXINFO
, sent
},
1513 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|0x8000 },
1514 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1515 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1516 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|0x8000 },
1517 { WM_SIZE
, sent
|defwinproc
},
1519 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
},
1520 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1521 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1522 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
1523 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
1524 /* Win2k sends wparam set to
1525 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
1526 * while Win9x doesn't bother to set child window id according to
1527 * CLIENTCREATESTRUCT.idFirstChild
1529 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
1530 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1531 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
},
1532 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1533 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1534 { WM_MDIREFRESHMENU
, sent
/*|wparam|lparam, 0, 0*/ },
1535 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
1536 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
1538 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 0 }, /* in the 1st MDI child */
1539 { WM_MDIACTIVATE
, sent
|defwinproc
}, /* in the 1st MDI child */
1541 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1543 /* Win9x: message sequence terminates here. */
1545 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 },
1546 { HCBT_SETFOCUS
, hook
},
1547 { WM_KILLFOCUS
, sent
|defwinproc
}, /* in the 1st MDI child */
1548 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 0 }, /* in the 1st MDI child */
1549 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
1550 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1551 { WM_SETFOCUS
, sent
}, /* in MDI client */
1552 { HCBT_SETFOCUS
, hook
},
1553 { WM_KILLFOCUS
, sent
}, /* in MDI client */
1554 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
1555 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
1556 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1557 { WM_SETFOCUS
, sent
|defwinproc
},
1559 { WM_MDIACTIVATE
, sent
|defwinproc
},
1561 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
},
1562 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1563 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1564 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
1567 /* WM_MDICREATE MDI child window, initially visible and maximized */
1568 static const struct message WmCreateMDIchildVisibleMaxSeq3
[] = {
1569 { WM_MDICREATE
, sent
},
1570 { HCBT_CREATEWND
, hook
},
1571 { WM_NCCREATE
, sent
},
1572 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
1573 { WM_CREATE
, sent
},
1574 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1577 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
1578 { WM_GETMINMAXINFO
, sent
},
1579 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|0x8000 },
1580 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1581 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|0x8000 },
1582 { WM_SIZE
, sent
|defwinproc
},
1585 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
},
1586 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1587 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1588 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
1589 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
1591 /* Win2k sends wparam set to
1592 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
1593 * while Win9x doesn't bother to set child window id according to
1594 * CLIENTCREATESTRUCT.idFirstChild
1596 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
1597 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1598 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
},
1600 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1602 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1603 { WM_MDIREFRESHMENU
, sent
/*|wparam|lparam, 0, 0*/ },
1604 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
1606 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
1607 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1609 /* Win9x: message sequence terminates here. */
1611 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 },
1612 { HCBT_SETFOCUS
, hook
}, /* in MDI client */
1613 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
1614 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1615 { WM_SETFOCUS
, sent
}, /* in MDI client */
1616 { HCBT_SETFOCUS
, hook
},
1617 { WM_KILLFOCUS
, sent
}, /* in MDI client */
1618 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
1619 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
1620 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1621 { WM_SETFOCUS
, sent
|defwinproc
},
1623 { WM_MDIACTIVATE
, sent
|defwinproc
},
1626 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
},
1627 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1628 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1629 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1632 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
},
1633 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1634 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
},
1635 { WM_MOVE
, sent
|defwinproc
},
1636 { WM_SIZE
, sent
|defwinproc
},
1639 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOZORDER
},
1640 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1641 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOZORDER
|SWP_NOCLIENTMOVE
},
1645 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOZORDER
},
1646 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1647 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOZORDER
|SWP_NOCLIENTMOVE
},
1648 { WM_SIZE
, sent
|defwinproc
},
1650 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
1651 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI client */
1652 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
1656 /* WM_SYSCOMMAND/SC_CLOSE for the 2nd MDI child window, initially visible and maximized */
1657 static const struct message WmDestroyMDIchildVisibleMaxSeq2
[] = {
1658 { WM_SYSCOMMAND
, sent
|wparam
, SC_CLOSE
},
1659 { HCBT_SYSCOMMAND
, hook
},
1660 { WM_CLOSE
, sent
|defwinproc
},
1661 { WM_MDIDESTROY
, sent
}, /* in MDI client */
1663 /* bring the 1st MDI child to top */
1664 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOSIZE
|SWP_NOMOVE
}, /* in the 1st MDI child */
1665 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
}, /* in the 2nd MDI child */
1667 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1669 { WM_CHILDACTIVATE
, sent
|defwinproc
|wparam
|lparam
, 0, 0 }, /* in the 1st MDI child */
1670 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 0 }, /* in the 1st MDI child */
1671 { WM_MDIACTIVATE
, sent
|defwinproc
}, /* in the 1st MDI child */
1673 /* maximize the 1st MDI child */
1674 { HCBT_MINMAX
, hook
},
1675 { WM_GETMINMAXINFO
, sent
|defwinproc
},
1676 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|0x8000 },
1677 { WM_NCCALCSIZE
, sent
|defwinproc
|wparam
, 1 },
1678 { WM_CHILDACTIVATE
, sent
|defwinproc
|wparam
|lparam
, 0, 0 },
1679 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|0x8000 },
1680 { WM_SIZE
, sent
|defwinproc
},
1682 /* restore the 2nd MDI child */
1683 { WM_SETREDRAW
, sent
|defwinproc
|wparam
, 0 },
1684 { HCBT_MINMAX
, hook
},
1685 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_SHOWWINDOW
|SWP_NOZORDER
|0x8000 },
1686 { WM_NCCALCSIZE
, sent
|defwinproc
|wparam
, 1 },
1688 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1690 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|0x8000 },
1691 { WM_SIZE
, sent
|defwinproc
},
1693 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
1695 { WM_SETREDRAW
, sent
|defwinproc
|wparam
, 1 },
1697 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
},
1698 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1699 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1700 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
1701 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
1703 /* bring the 1st MDI child to top */
1704 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1705 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 },
1706 { HCBT_SETFOCUS
, hook
},
1707 { WM_KILLFOCUS
, sent
|defwinproc
},
1708 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 0 },
1709 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
1710 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1711 { WM_SETFOCUS
, sent
}, /* in MDI client */
1712 { HCBT_SETFOCUS
, hook
},
1713 { WM_KILLFOCUS
, sent
}, /* in MDI client */
1714 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
1715 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
1716 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1717 { WM_SETFOCUS
, sent
|defwinproc
},
1718 { WM_MDIACTIVATE
, sent
|defwinproc
},
1719 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1721 /* apparently ShowWindow(SW_SHOW) on an MDI client */
1722 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1723 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
},
1724 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1725 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1726 { WM_MDIREFRESHMENU
, sent
},
1728 { HCBT_DESTROYWND
, hook
},
1729 /* Win2k sends wparam set to
1730 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
1731 * while Win9x doesn't bother to set child window id according to
1732 * CLIENTCREATESTRUCT.idFirstChild
1734 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_DESTROY*/ }, /* in MDI client */
1735 { WM_SHOWWINDOW
, sent
|defwinproc
|wparam
, 0 },
1736 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
},
1737 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1738 { WM_ERASEBKGND
, sent
|parent
|optional
},
1739 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1741 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
1742 { WM_DESTROY
, sent
|defwinproc
},
1743 { WM_NCDESTROY
, sent
|defwinproc
},
1746 /* WM_MDIDESTROY for the single MDI child window, initially visible and maximized */
1747 static const struct message WmDestroyMDIchildVisibleMaxSeq1
[] = {
1748 { WM_MDIDESTROY
, sent
}, /* in MDI client */
1749 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
1750 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
},
1751 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1752 { WM_ERASEBKGND
, sent
|parent
|optional
},
1753 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1755 { HCBT_SETFOCUS
, hook
},
1756 { WM_KILLFOCUS
, sent
},
1757 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
1758 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
1759 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1760 { WM_SETFOCUS
, sent
}, /* in MDI client */
1761 { HCBT_SETFOCUS
, hook
},
1762 { WM_KILLFOCUS
, sent
}, /* in MDI client */
1763 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
1764 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
1765 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1766 { WM_SETFOCUS
, sent
},
1769 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
},
1770 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1771 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1772 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
1775 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
},
1776 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1777 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
},
1778 { WM_MOVE
, sent
|defwinproc
},
1779 { WM_SIZE
, sent
|defwinproc
},
1782 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOZORDER
},
1783 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1784 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOZORDER
|SWP_NOCLIENTMOVE
},
1788 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOZORDER
},
1789 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1790 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOZORDER
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
},
1791 { WM_SIZE
, sent
|defwinproc
},
1794 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
},
1795 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 },
1796 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1797 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
1800 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
},
1801 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 },
1802 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
},
1803 { WM_MOVE
, sent
|defwinproc
},
1804 { WM_SIZE
, sent
|defwinproc
},
1807 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOZORDER
},
1808 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1809 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOZORDER
|SWP_NOCLIENTMOVE
},
1813 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOZORDER
},
1814 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 },
1815 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOZORDER
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
},
1816 { WM_SIZE
, sent
|defwinproc
},
1817 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
1818 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI client */
1819 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
1820 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
1821 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI client */
1822 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
1825 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
},
1826 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1827 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1828 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
1830 { WM_NCACTIVATE
, sent
|wparam
, 0 },
1831 { WM_MDIACTIVATE
, sent
},
1833 { HCBT_MINMAX
, hook
},
1834 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_SHOWWINDOW
|0x8000 },
1835 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1837 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1839 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
1840 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_SHOWWINDOW
|SWP_NOMOVE
|SWP_NOZORDER
|SWP_NOCLIENTMOVE
|0x8000 },
1841 { WM_SIZE
, sent
|defwinproc
},
1844 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
},
1845 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 },
1846 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1847 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
1850 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
},
1851 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1852 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
},
1853 { WM_MOVE
, sent
|defwinproc
},
1854 { WM_SIZE
, sent
|defwinproc
},
1857 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOZORDER
},
1858 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1859 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOZORDER
|SWP_NOCLIENTMOVE
},
1861 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
1862 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI client */
1863 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
1865 { HCBT_SETFOCUS
, hook
},
1866 { WM_KILLFOCUS
, sent
},
1867 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
1868 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
1869 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1870 { WM_SETFOCUS
, sent
}, /* in MDI client */
1872 { WM_MDIREFRESHMENU
, sent
}, /* in MDI client */
1874 { HCBT_DESTROYWND
, hook
},
1875 /* Win2k sends wparam set to
1876 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
1877 * while Win9x doesn't bother to set child window id according to
1878 * CLIENTCREATESTRUCT.idFirstChild
1880 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_DESTROY*/ }, /* in MDI client */
1882 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
1883 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
},
1884 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1885 { WM_ERASEBKGND
, sent
|parent
|optional
},
1886 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1888 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
1889 { WM_DESTROY
, sent
},
1890 { WM_NCDESTROY
, sent
},
1893 /* ShowWindow(SW_MAXIMIZE) for a not visible MDI child window */
1894 static const struct message WmMaximizeMDIchildInvisibleSeq
[] = {
1895 { HCBT_MINMAX
, hook
},
1896 { WM_GETMINMAXINFO
, sent
},
1897 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|0x8000 },
1898 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1899 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1900 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
1902 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1903 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 },
1904 { HCBT_SETFOCUS
, hook
},
1905 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
1906 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1907 { WM_SETFOCUS
, sent
}, /* in MDI client */
1908 { HCBT_SETFOCUS
, hook
},
1909 { WM_KILLFOCUS
, sent
}, /* in MDI client */
1910 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
1911 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
1912 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1913 { WM_SETFOCUS
, sent
|defwinproc
},
1914 { WM_MDIACTIVATE
, sent
|defwinproc
},
1915 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|0x8000 },
1916 { WM_SIZE
, sent
|defwinproc
},
1918 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
},
1919 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1920 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1921 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
1922 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
1925 /* ShowWindow(SW_MAXIMIZE) for a visible MDI child window */
1926 static const struct message WmMaximizeMDIchildVisibleSeq
[] = {
1927 { HCBT_MINMAX
, hook
},
1928 { WM_GETMINMAXINFO
, sent
},
1929 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|0x8000 },
1930 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1931 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
1932 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|0x8000 },
1933 { WM_SIZE
, sent
|defwinproc
},
1935 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
},
1936 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1937 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1938 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
1939 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
1942 /* ShowWindow(SW_RESTORE) for a visible MDI child window */
1943 static const struct message WmRestoreMDIchildVisibleSeq
[] = {
1944 { HCBT_MINMAX
, hook
},
1945 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|0x8000 },
1946 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1947 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
1948 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|0x8000 },
1949 { WM_SIZE
, sent
|defwinproc
},
1951 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
},
1952 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1953 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1954 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
1955 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
1958 /* ShowWindow(SW_RESTORE) for a not visible MDI child window */
1959 static const struct message WmRestoreMDIchildInisibleSeq
[] = {
1960 { HCBT_MINMAX
, hook
},
1961 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|0x8000 },
1962 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1963 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1964 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
1965 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|0x8000 },
1966 { WM_SIZE
, sent
|defwinproc
},
1968 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
},
1969 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1970 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1971 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
1972 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
1976 static HWND mdi_client
;
1977 static WNDPROC old_mdi_client_proc
;
1979 static LRESULT WINAPI
mdi_client_hook_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
1983 /* do not log painting messages */
1984 if (message
!= WM_PAINT
&&
1985 message
!= WM_ERASEBKGND
&&
1986 message
!= WM_NCPAINT
&&
1987 message
!= WM_NCHITTEST
&&
1988 message
!= WM_GETTEXT
&&
1989 message
!= WM_MDIGETACTIVE
&&
1990 message
!= WM_DEVICECHANGE
)
1992 trace("mdi client: %p, %04x, %08x, %08lx\n", hwnd
, message
, wParam
, lParam
);
1996 case WM_WINDOWPOSCHANGING
:
1997 case WM_WINDOWPOSCHANGED
:
1999 WINDOWPOS
*winpos
= (WINDOWPOS
*)lParam
;
2001 trace("%s\n", (message
== WM_WINDOWPOSCHANGING
) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
2002 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
2003 winpos
->hwnd
, winpos
->hwndInsertAfter
,
2004 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
2006 /* Log only documented flags, win2k uses 0x1000 and 0x2000
2007 * in the high word for internal purposes
2009 wParam
= winpos
->flags
& 0xffff;
2014 msg
.message
= message
;
2015 msg
.flags
= sent
|wparam
|lparam
;
2016 msg
.wParam
= wParam
;
2017 msg
.lParam
= lParam
;
2021 return CallWindowProcA(old_mdi_client_proc
, hwnd
, message
, wParam
, lParam
);
2024 static LRESULT WINAPI
mdi_child_wnd_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
2026 static long defwndproc_counter
= 0;
2030 /* do not log painting messages */
2031 if (message
!= WM_PAINT
&&
2032 message
!= WM_ERASEBKGND
&&
2033 message
!= WM_NCPAINT
&&
2034 message
!= WM_NCHITTEST
&&
2035 message
!= WM_GETTEXT
&&
2036 message
!= WM_DEVICECHANGE
)
2038 trace("mdi child: %p, %04x, %08x, %08lx\n", hwnd
, message
, wParam
, lParam
);
2042 case WM_WINDOWPOSCHANGING
:
2043 case WM_WINDOWPOSCHANGED
:
2045 WINDOWPOS
*winpos
= (WINDOWPOS
*)lParam
;
2047 trace("%s\n", (message
== WM_WINDOWPOSCHANGING
) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
2048 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
2049 winpos
->hwnd
, winpos
->hwndInsertAfter
,
2050 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
2052 /* Log only documented flags, win2k uses 0x1000 and 0x2000
2053 * in the high word for internal purposes
2055 wParam
= winpos
->flags
& 0xffff;
2059 case WM_MDIACTIVATE
:
2061 HWND active
, client
= GetParent(hwnd
);
2063 active
= (HWND
)SendMessageA(client
, WM_MDIGETACTIVE
, 0, 0);
2065 if (hwnd
== (HWND
)lParam
) /* if we are being activated */
2066 ok (active
== (HWND
)lParam
, "new active %p != active %p\n", (HWND
)lParam
, active
);
2068 ok (active
== (HWND
)wParam
, "old active %p != active %p\n", (HWND
)wParam
, active
);
2073 msg
.message
= message
;
2074 msg
.flags
= sent
|wparam
|lparam
;
2075 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
2076 msg
.wParam
= wParam
;
2077 msg
.lParam
= lParam
;
2081 defwndproc_counter
++;
2082 ret
= DefMDIChildProcA(hwnd
, message
, wParam
, lParam
);
2083 defwndproc_counter
--;
2088 static LRESULT WINAPI
mdi_frame_wnd_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
2090 static long defwndproc_counter
= 0;
2094 /* do not log painting messages */
2095 if (message
!= WM_PAINT
&&
2096 message
!= WM_ERASEBKGND
&&
2097 message
!= WM_NCPAINT
&&
2098 message
!= WM_NCHITTEST
&&
2099 message
!= WM_GETTEXT
&&
2100 message
!= WM_DEVICECHANGE
)
2102 trace("mdi frame: %p, %04x, %08x, %08lx\n", hwnd
, message
, wParam
, lParam
);
2106 case WM_WINDOWPOSCHANGING
:
2107 case WM_WINDOWPOSCHANGED
:
2109 WINDOWPOS
*winpos
= (WINDOWPOS
*)lParam
;
2111 trace("%s\n", (message
== WM_WINDOWPOSCHANGING
) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
2112 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
2113 winpos
->hwnd
, winpos
->hwndInsertAfter
,
2114 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
2116 /* Log only documented flags, win2k uses 0x1000 and 0x2000
2117 * in the high word for internal purposes
2119 wParam
= winpos
->flags
& 0xffff;
2124 msg
.message
= message
;
2125 msg
.flags
= sent
|wparam
|lparam
;
2126 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
2127 msg
.wParam
= wParam
;
2128 msg
.lParam
= lParam
;
2132 defwndproc_counter
++;
2133 ret
= DefFrameProcA(hwnd
, mdi_client
, message
, wParam
, lParam
);
2134 defwndproc_counter
--;
2139 static BOOL
mdi_RegisterWindowClasses(void)
2144 cls
.lpfnWndProc
= mdi_frame_wnd_proc
;
2147 cls
.hInstance
= GetModuleHandleA(0);
2149 cls
.hCursor
= LoadCursorA(0, (LPSTR
)IDC_ARROW
);
2150 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
2151 cls
.lpszMenuName
= NULL
;
2152 cls
.lpszClassName
= "MDI_frame_class";
2153 if (!RegisterClassA(&cls
)) return FALSE
;
2155 cls
.lpfnWndProc
= mdi_child_wnd_proc
;
2156 cls
.lpszClassName
= "MDI_child_class";
2157 if (!RegisterClassA(&cls
)) return FALSE
;
2159 if (!GetClassInfoA(0, "MDIClient", &cls
)) assert(0);
2160 old_mdi_client_proc
= cls
.lpfnWndProc
;
2161 cls
.hInstance
= GetModuleHandleA(0);
2162 cls
.lpfnWndProc
= mdi_client_hook_proc
;
2163 cls
.lpszClassName
= "MDI_client_class";
2164 if (!RegisterClassA(&cls
)) assert(0);
2169 static void test_mdi_messages(void)
2171 MDICREATESTRUCTA mdi_cs
;
2172 CLIENTCREATESTRUCT client_cs
;
2173 HWND mdi_frame
, mdi_child
, mdi_child2
, active_child
;
2175 HMENU hMenu
= CreateMenu();
2177 assert(mdi_RegisterWindowClasses());
2181 trace("creating MDI frame window\n");
2182 mdi_frame
= CreateWindowExA(0, "MDI_frame_class", "MDI frame window",
2183 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
|
2184 WS_MAXIMIZEBOX
| WS_VISIBLE
,
2185 100, 100, CW_USEDEFAULT
, CW_USEDEFAULT
,
2186 GetDesktopWindow(), hMenu
,
2187 GetModuleHandleA(0), NULL
);
2189 ok_sequence(WmCreateMDIframeSeq
, "Create MDI frame window", TRUE
);
2191 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
2192 ok(GetFocus() == mdi_frame
, "wrong focus window %p\n", GetFocus());
2194 trace("creating MDI client window\n");
2195 client_cs
.hWindowMenu
= 0;
2196 client_cs
.idFirstChild
= MDI_FIRST_CHILD_ID
;
2197 mdi_client
= CreateWindowExA(0, "MDI_client_class",
2199 WS_CHILD
| WS_VISIBLE
| MDIS_ALLCHILDSTYLES
,
2201 mdi_frame
, 0, GetModuleHandleA(0), &client_cs
);
2203 ok_sequence(WmCreateMDIclientSeq
, "Create visible MDI client window", FALSE
);
2205 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
2206 ok(GetFocus() == mdi_frame
, "input focus should be on MDI frame not on %p\n", GetFocus());
2208 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
2209 ok(!active_child
, "wrong active MDI child %p\n", active_child
);
2210 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
2215 trace("creating invisible MDI child window\n");
2216 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
2218 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
2219 mdi_client
, 0, GetModuleHandleA(0), NULL
);
2223 ShowWindow(mdi_child
, SW_SHOWNORMAL
);
2224 ok_sequence(WmShowChildSeq
, "ShowWindow(SW_SHOWNORMAL) MDI child window", FALSE
);
2226 ok(GetWindowLongA(mdi_child
, GWL_STYLE
) & WS_VISIBLE
, "MDI child should be visible\n");
2227 ok(IsWindowVisible(mdi_child
), "MDI child should be visible\n");
2229 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
2230 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2232 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
2233 ok(!active_child
, "wrong active MDI child %p\n", active_child
);
2234 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
2236 ShowWindow(mdi_child
, SW_HIDE
);
2237 ok_sequence(WmHideChildSeq
, "ShowWindow(SW_HIDE) MDI child window", FALSE
);
2240 ShowWindow(mdi_child
, SW_SHOW
);
2241 ok_sequence(WmShowChildSeq
, "ShowWindow(SW_SHOW) MDI child window", FALSE
);
2243 ok(GetWindowLongA(mdi_child
, GWL_STYLE
) & WS_VISIBLE
, "MDI child should be visible\n");
2244 ok(IsWindowVisible(mdi_child
), "MDI child should be visible\n");
2246 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
2247 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2249 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
2250 ok(!active_child
, "wrong active MDI child %p\n", active_child
);
2251 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
2253 DestroyWindow(mdi_child
);
2256 trace("creating visible MDI child window\n");
2257 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
2258 WS_CHILD
| WS_VISIBLE
,
2259 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
2260 mdi_client
, 0, GetModuleHandleA(0), NULL
);
2262 ok_sequence(WmCreateMDIchildVisibleSeq
, "Create visible MDI child window", FALSE
);
2264 ok(GetWindowLongA(mdi_child
, GWL_STYLE
) & WS_VISIBLE
, "MDI child should be visible\n");
2265 ok(IsWindowVisible(mdi_child
), "MDI child should be visible\n");
2267 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
2268 ok(GetFocus() == mdi_child
, "wrong focus window %p\n", GetFocus());
2270 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
2271 ok(active_child
== mdi_child
, "wrong active MDI child %p\n", active_child
);
2272 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
2275 DestroyWindow(mdi_child
);
2276 ok_sequence(WmDestroyMDIchildVisibleSeq
, "Destroy visible MDI child window", TRUE
);
2278 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
2279 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2281 /* Win2k: MDI client still returns a just destroyed child as active
2282 * Win9x: MDI client returns 0
2284 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
2285 ok(active_child
== mdi_child
|| /* win2k */
2286 !active_child
, /* win9x */
2287 "wrong active MDI child %p\n", active_child
);
2288 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
2292 trace("creating invisible MDI child window\n");
2293 mdi_child2
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
2295 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
2296 mdi_client
, 0, GetModuleHandleA(0), NULL
);
2298 ok_sequence(WmCreateMDIchildInvisibleSeq
, "Create invisible MDI child window", FALSE
);
2300 ok(!(GetWindowLongA(mdi_child2
, GWL_STYLE
) & WS_VISIBLE
), "MDI child should not be visible\n");
2301 ok(!IsWindowVisible(mdi_child2
), "MDI child should not be visible\n");
2303 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
2304 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2306 /* Win2k: MDI client still returns a just destroyed child as active
2307 * Win9x: MDI client returns mdi_child2
2309 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
2310 ok(active_child
== mdi_child
|| /* win2k */
2311 active_child
== mdi_child2
, /* win9x */
2312 "wrong active MDI child %p\n", active_child
);
2313 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
2316 ShowWindow(mdi_child2
, SW_MAXIMIZE
);
2317 ok_sequence(WmMaximizeMDIchildInvisibleSeq
, "ShowWindow(SW_MAXIMIZE):invisible MDI child", TRUE
);
2319 ok(GetWindowLongA(mdi_child2
, GWL_STYLE
) & WS_VISIBLE
, "MDI child should be visible\n");
2320 ok(IsWindowVisible(mdi_child2
), "MDI child should be visible\n");
2322 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
2323 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
2324 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
2327 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
2328 ok(GetFocus() == mdi_child2
|| /* win2k */
2329 GetFocus() == 0, /* win9x */
2330 "wrong focus window %p\n", GetFocus());
2335 ShowWindow(mdi_child2
, SW_HIDE
);
2336 ok_sequence(WmHideChildSeq
, "ShowWindow(SW_HIDE):MDI child", FALSE
);
2338 ShowWindow(mdi_child2
, SW_RESTORE
);
2339 ok_sequence(WmRestoreMDIchildInisibleSeq
, "ShowWindow(SW_RESTORE):invisible MDI child", TRUE
);
2342 ok(GetWindowLongA(mdi_child2
, GWL_STYLE
) & WS_VISIBLE
, "MDI child should be visible\n");
2343 ok(IsWindowVisible(mdi_child2
), "MDI child should be visible\n");
2345 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
2346 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
2347 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
2353 ShowWindow(mdi_child2
, SW_HIDE
);
2354 ok_sequence(WmHideChildSeq
, "ShowWindow(SW_HIDE):MDI child", FALSE
);
2356 ShowWindow(mdi_child2
, SW_SHOW
);
2357 ok_sequence(WmShowChildSeq
, "ShowWindow(SW_SHOW):MDI child", FALSE
);
2359 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
2360 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2362 ShowWindow(mdi_child2
, SW_MAXIMIZE
);
2363 ok_sequence(WmMaximizeMDIchildVisibleSeq
, "ShowWindow(SW_MAXIMIZE):MDI child", TRUE
);
2365 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
2366 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2368 ShowWindow(mdi_child2
, SW_RESTORE
);
2369 ok_sequence(WmRestoreMDIchildVisibleSeq
, "ShowWindow(SW_RESTORE):MDI child", TRUE
);
2371 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
2372 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2377 ShowWindow(mdi_child2
, SW_HIDE
);
2378 ok_sequence(WmHideChildSeq
, "ShowWindow(SW_HIDE):MDI child", FALSE
);
2380 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
2381 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2383 DestroyWindow(mdi_child2
);
2384 ok_sequence(WmDestroyMDIchildInvisibleSeq
, "Destroy invisible MDI child window", FALSE
);
2386 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
2387 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2389 /* test for maximized MDI children */
2390 trace("creating maximized visible MDI child window 1\n");
2391 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
2392 WS_CHILD
| WS_VISIBLE
| WS_MAXIMIZEBOX
| WS_MAXIMIZE
,
2393 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
2394 mdi_client
, 0, GetModuleHandleA(0), NULL
);
2396 ok_sequence(WmCreateMDIchildVisibleMaxSeq1
, "Create maximized visible 1st MDI child window", TRUE
);
2397 ok(IsZoomed(mdi_child
), "1st MDI child should be maximized\n");
2399 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
2400 ok(GetFocus() == mdi_child
|| /* win2k */
2401 GetFocus() == 0, /* win9x */
2402 "wrong focus window %p\n", GetFocus());
2404 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
2405 ok(active_child
== mdi_child
, "wrong active MDI child %p\n", active_child
);
2406 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
2409 trace("creating maximized visible MDI child window 2\n");
2410 mdi_child2
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
2411 WS_CHILD
| WS_VISIBLE
| WS_MAXIMIZEBOX
| WS_MAXIMIZE
,
2412 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
2413 mdi_client
, 0, GetModuleHandleA(0), NULL
);
2415 ok_sequence(WmCreateMDIchildVisibleMaxSeq2
, "Create maximized visible 2nd MDI child 2 window", TRUE
);
2416 ok(IsZoomed(mdi_child2
), "2nd MDI child should be maximized\n");
2417 ok(!IsZoomed(mdi_child
), "1st MDI child should NOT be maximized\n");
2419 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
2420 ok(GetFocus() == mdi_child2
, "wrong focus window %p\n", GetFocus());
2422 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
2423 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
2424 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
2427 trace("destroying maximized visible MDI child window 2\n");
2428 DestroyWindow(mdi_child2
);
2429 ok_sequence(WmDestroyMDIchildVisibleSeq
, "Destroy visible MDI child window", TRUE
);
2431 ok(!IsZoomed(mdi_child
), "1st MDI child should NOT be maximized\n");
2433 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
2434 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2436 /* Win2k: MDI client still returns a just destroyed child as active
2437 * Win9x: MDI client returns 0
2439 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
2440 ok(active_child
== mdi_child2
|| /* win2k */
2441 !active_child
, /* win9x */
2442 "wrong active MDI child %p\n", active_child
);
2445 ShowWindow(mdi_child
, SW_MAXIMIZE
);
2446 ok(IsZoomed(mdi_child
), "1st MDI child should be maximized\n");
2449 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
2450 ok(GetFocus() == mdi_child
, "wrong focus window %p\n", GetFocus());
2452 trace("re-creating maximized visible MDI child window 2\n");
2453 mdi_child2
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
2454 WS_CHILD
| WS_VISIBLE
| WS_MAXIMIZEBOX
| WS_MAXIMIZE
,
2455 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
2456 mdi_client
, 0, GetModuleHandleA(0), NULL
);
2458 ok_sequence(WmCreateMDIchildVisibleMaxSeq2
, "Create maximized visible 2nd MDI child 2 window", TRUE
);
2459 ok(IsZoomed(mdi_child2
), "2nd MDI child should be maximized\n");
2460 ok(!IsZoomed(mdi_child
), "1st MDI child should NOT be maximized\n");
2462 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
2463 ok(GetFocus() == mdi_child2
, "wrong focus window %p\n", GetFocus());
2465 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
2466 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
2467 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
2470 SendMessageA(mdi_child2
, WM_SYSCOMMAND
, SC_CLOSE
, 0);
2471 ok_sequence(WmDestroyMDIchildVisibleMaxSeq2
, "WM_SYSCOMMAND/SC_CLOSE on a visible maximized MDI child window", TRUE
);
2472 ok(!IsWindow(mdi_child2
), "MDI child 2 should be destroyed\n");
2474 ok(IsZoomed(mdi_child
), "1st MDI child should be maximized\n");
2475 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
2476 ok(GetFocus() == mdi_child
, "wrong focus window %p\n", GetFocus());
2478 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
2479 ok(active_child
== mdi_child
, "wrong active MDI child %p\n", active_child
);
2480 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
2483 DestroyWindow(mdi_child
);
2484 ok_sequence(WmDestroyMDIchildVisibleSeq
, "Destroy visible MDI child window", TRUE
);
2486 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
2487 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2489 /* Win2k: MDI client still returns a just destroyed child as active
2490 * Win9x: MDI client returns 0
2492 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
2493 ok(active_child
== mdi_child
|| /* win2k */
2494 !active_child
, /* win9x */
2495 "wrong active MDI child %p\n", active_child
);
2497 /* end of test for maximized MDI children */
2499 mdi_cs
.szClass
= "MDI_child_Class";
2500 mdi_cs
.szTitle
= "MDI child";
2501 mdi_cs
.hOwner
= GetModuleHandleA(0);
2504 mdi_cs
.cx
= CW_USEDEFAULT
;
2505 mdi_cs
.cy
= CW_USEDEFAULT
;
2506 mdi_cs
.style
= WS_CHILD
| WS_SYSMENU
| WS_VISIBLE
| WS_MAXIMIZEBOX
| WS_MAXIMIZE
;
2508 mdi_child
= (HWND
)SendMessageA(mdi_client
, WM_MDICREATE
, 0, (LPARAM
)&mdi_cs
);
2509 ok(mdi_child
!= 0, "MDI child creation failed\n");
2510 ok_sequence(WmCreateMDIchildVisibleMaxSeq3
, "WM_MDICREATE for maximized visible MDI child window", TRUE
);
2512 ok(GetMenuItemID(hMenu
, GetMenuItemCount(hMenu
) - 1) == SC_CLOSE
, "SC_CLOSE menu item not found\n");
2514 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
2515 ok(active_child
== mdi_child
, "wrong active MDI child %p\n", active_child
);
2517 ok(IsZoomed(mdi_child
), "MDI child should be maximized\n");
2518 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
2519 ok(GetFocus() == mdi_child
, "wrong focus window %p\n", GetFocus());
2521 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
2522 ok(active_child
== mdi_child
, "wrong active MDI child %p\n", active_child
);
2523 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
2526 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
2527 ok_sequence(WmDestroyMDIchildVisibleMaxSeq1
, "Destroy visible maximized MDI child window", TRUE
);
2529 ok(!IsWindow(mdi_child
), "MDI child should be destroyed\n");
2530 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
2531 ok(!active_child
, "wrong active MDI child %p\n", active_child
);
2536 DestroyWindow(mdi_client
);
2537 ok_sequence(WmDestroyMDIclientSeq
, "Destroy MDI client window", FALSE
);
2539 DestroyWindow(mdi_frame
);
2540 ok_sequence(WmDestroyMDIframeSeq
, "Destroy MDI frame window", FALSE
);
2542 /************************* End of MDI test **********************************/
2544 static void test_WM_SETREDRAW(HWND hwnd
)
2546 DWORD style
= GetWindowLongA(hwnd
, GWL_STYLE
);
2550 SendMessageA(hwnd
, WM_SETREDRAW
, FALSE
, 0);
2551 ok_sequence(WmSetRedrawFalseSeq
, "SetRedraw:FALSE", FALSE
);
2553 ok(!(GetWindowLongA(hwnd
, GWL_STYLE
) & WS_VISIBLE
), "WS_VISIBLE should NOT be set\n");
2554 ok(!IsWindowVisible(hwnd
), "IsWindowVisible() should return FALSE\n");
2557 SendMessageA(hwnd
, WM_SETREDRAW
, TRUE
, 0);
2558 ok_sequence(WmSetRedrawTrueSeq
, "SetRedraw:TRUE", FALSE
);
2560 ok(GetWindowLongA(hwnd
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
2561 ok(IsWindowVisible(hwnd
), "IsWindowVisible() should return TRUE\n");
2563 /* restore original WS_VISIBLE state */
2564 SetWindowLongA(hwnd
, GWL_STYLE
, style
);
2569 static INT_PTR CALLBACK
TestModalDlgProcA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
2573 trace("dialog: %p, %04x, %08x, %08lx\n", hwnd
, message
, wParam
, lParam
);
2577 case WM_WINDOWPOSCHANGING
:
2578 case WM_WINDOWPOSCHANGED
:
2580 WINDOWPOS
*winpos
= (WINDOWPOS
*)lParam
;
2582 trace("%s\n", (message
== WM_WINDOWPOSCHANGING
) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
2583 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
2584 winpos
->hwnd
, winpos
->hwndInsertAfter
,
2585 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
2587 /* Log only documented flags, win2k uses 0x1000 and 0x2000
2588 * in the high word for internal purposes
2590 wParam
= winpos
->flags
& 0xffff;
2595 msg
.message
= message
;
2596 msg
.flags
= sent
|wparam
|lparam
;
2597 msg
.wParam
= wParam
;
2598 msg
.lParam
= lParam
;
2601 if (message
== WM_INITDIALOG
) SetTimer( hwnd
, 1, 100, NULL
);
2602 if (message
== WM_TIMER
) EndDialog( hwnd
, 0 );
2606 static void test_hv_scroll_1(HWND hwnd
, INT ctl
, DWORD clear
, DWORD set
, INT min
, INT max
)
2608 DWORD style
, exstyle
;
2612 exstyle
= GetWindowLongA(hwnd
, GWL_EXSTYLE
);
2613 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
2614 /* do not be confused by WS_DLGFRAME set */
2615 if ((style
& WS_CAPTION
) == WS_CAPTION
) style
&= ~WS_CAPTION
;
2617 if (clear
) ok(style
& clear
, "style %08lx should be set\n", clear
);
2618 if (set
) ok(!(style
& set
), "style %08lx should not be set\n", set
);
2620 ret
= SetScrollRange(hwnd
, ctl
, min
, max
, FALSE
);
2621 ok( ret
, "SetScrollRange(%d) error %ld\n", ctl
, GetLastError());
2622 if ((style
& (WS_DLGFRAME
| WS_BORDER
| WS_THICKFRAME
)) || (exstyle
& WS_EX_DLGMODALFRAME
))
2623 ok_sequence(WmSetScrollRangeHV_NC_Seq
, "SetScrollRange(SB_HORZ/SB_VERT) NC", FALSE
);
2625 ok_sequence(WmSetScrollRangeHVSeq
, "SetScrollRange(SB_HORZ/SB_VERT)", FALSE
);
2627 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
2628 if (set
) ok(style
& set
, "style %08lx should be set\n", set
);
2629 if (clear
) ok(!(style
& clear
), "style %08lx should not be set\n", clear
);
2631 /* a subsequent call should do nothing */
2632 ret
= SetScrollRange(hwnd
, ctl
, min
, max
, FALSE
);
2633 ok( ret
, "SetScrollRange(%d) error %ld\n", ctl
, GetLastError());
2634 ok_sequence(WmEmptySeq
, "SetScrollRange(SB_HORZ/SB_VERT) empty sequence", FALSE
);
2638 trace("Ignore GetScrollRange error below if you are on Win9x\n");
2639 ret
= GetScrollRange(hwnd
, ctl
, &xmin
, &xmax
);
2640 ok( ret
, "GetScrollRange(%d) error %ld\n", ctl
, GetLastError());
2641 ok_sequence(WmEmptySeq
, "GetScrollRange(SB_HORZ/SB_VERT) empty sequence", FALSE
);
2642 ok(xmin
== min
, "unexpected min scroll value %d\n", xmin
);
2643 ok(xmax
== max
, "unexpected max scroll value %d\n", xmax
);
2646 static void test_hv_scroll_2(HWND hwnd
, INT ctl
, DWORD clear
, DWORD set
, INT min
, INT max
)
2648 DWORD style
, exstyle
;
2652 exstyle
= GetWindowLongA(hwnd
, GWL_EXSTYLE
);
2653 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
2654 /* do not be confused by WS_DLGFRAME set */
2655 if ((style
& WS_CAPTION
) == WS_CAPTION
) style
&= ~WS_CAPTION
;
2657 if (clear
) ok(style
& clear
, "style %08lx should be set\n", clear
);
2658 if (set
) ok(!(style
& set
), "style %08lx should not be set\n", set
);
2660 si
.cbSize
= sizeof(si
);
2661 si
.fMask
= SIF_RANGE
;
2664 SetScrollInfo(hwnd
, ctl
, &si
, TRUE
);
2665 if ((style
& (WS_DLGFRAME
| WS_BORDER
| WS_THICKFRAME
)) || (exstyle
& WS_EX_DLGMODALFRAME
))
2666 ok_sequence(WmSetScrollRangeHV_NC_Seq
, "SetScrollInfo(SB_HORZ/SB_VERT) NC", FALSE
);
2668 ok_sequence(WmSetScrollRangeHVSeq
, "SetScrollInfo(SB_HORZ/SB_VERT)", FALSE
);
2670 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
2671 if (set
) ok(style
& set
, "style %08lx should be set\n", set
);
2672 if (clear
) ok(!(style
& clear
), "style %08lx should not be set\n", clear
);
2674 /* a subsequent call should do nothing */
2675 SetScrollInfo(hwnd
, ctl
, &si
, TRUE
);
2676 if (style
& WS_HSCROLL
)
2677 ok_sequence(WmSetScrollRangeHSeq_empty
, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE
);
2678 else if (style
& WS_VSCROLL
)
2679 ok_sequence(WmSetScrollRangeVSeq_empty
, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE
);
2681 ok_sequence(WmEmptySeq
, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE
);
2683 si
.fMask
= SIF_PAGE
;
2685 SetScrollInfo(hwnd
, ctl
, &si
, FALSE
);
2686 ok_sequence(WmEmptySeq
, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE
);
2690 SetScrollInfo(hwnd
, ctl
, &si
, FALSE
);
2691 ok_sequence(WmEmptySeq
, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE
);
2693 si
.fMask
= SIF_RANGE
;
2694 si
.nMin
= 0xdeadbeef;
2695 si
.nMax
= 0xdeadbeef;
2696 ret
= GetScrollInfo(hwnd
, ctl
, &si
);
2697 ok( ret
, "GetScrollInfo error %ld\n", GetLastError());
2698 ok_sequence(WmEmptySeq
, "GetScrollRange(SB_HORZ/SB_VERT) empty sequence", FALSE
);
2699 ok(si
.nMin
== min
, "unexpected min scroll value %d\n", si
.nMin
);
2700 ok(si
.nMax
== max
, "unexpected max scroll value %d\n", si
.nMax
);
2703 /* Win9x sends WM_USER+xxx while and NT versions send SBM_xxx messages */
2704 static void test_scroll_messages(HWND hwnd
)
2712 ret
= GetScrollRange(hwnd
, SB_CTL
, &min
, &max
);
2713 ok( ret
, "GetScrollRange error %ld\n", GetLastError());
2714 if (sequence
->message
!= WmGetScrollRangeSeq
[0].message
)
2715 trace("GetScrollRange(SB_CTL) generated unknown message %04x\n", sequence
->message
);
2716 /* values of min and max are undefined */
2719 ret
= SetScrollRange(hwnd
, SB_CTL
, 10, 150, FALSE
);
2720 ok( ret
, "SetScrollRange error %ld\n", GetLastError());
2721 if (sequence
->message
!= WmSetScrollRangeSeq
[0].message
)
2722 trace("SetScrollRange(SB_CTL) generated unknown message %04x\n", sequence
->message
);
2727 ret
= GetScrollRange(hwnd
, SB_CTL
, &min
, &max
);
2728 ok( ret
, "GetScrollRange error %ld\n", GetLastError());
2729 if (sequence
->message
!= WmGetScrollRangeSeq
[0].message
)
2730 trace("GetScrollRange(SB_CTL) generated unknown message %04x\n", sequence
->message
);
2731 /* values of min and max are undefined */
2734 si
.cbSize
= sizeof(si
);
2735 si
.fMask
= SIF_RANGE
;
2738 SetScrollInfo(hwnd
, SB_CTL
, &si
, FALSE
);
2739 if (sequence
->message
!= WmSetScrollRangeSeq
[0].message
)
2740 trace("SetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence
->message
);
2743 si
.fMask
= SIF_PAGE
;
2745 SetScrollInfo(hwnd
, SB_CTL
, &si
, FALSE
);
2746 if (sequence
->message
!= WmSetScrollRangeSeq
[0].message
)
2747 trace("SetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence
->message
);
2752 SetScrollInfo(hwnd
, SB_CTL
, &si
, FALSE
);
2753 if (sequence
->message
!= WmSetScrollRangeSeq
[0].message
)
2754 trace("SetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence
->message
);
2757 si
.fMask
= SIF_RANGE
;
2758 si
.nMin
= 0xdeadbeef;
2759 si
.nMax
= 0xdeadbeef;
2760 ret
= GetScrollInfo(hwnd
, SB_CTL
, &si
);
2761 ok( ret
, "GetScrollInfo error %ld\n", GetLastError());
2762 if (sequence
->message
!= WmGetScrollInfoSeq
[0].message
)
2763 trace("GetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence
->message
);
2764 /* values of min and max are undefined */
2767 /* set WS_HSCROLL */
2768 test_hv_scroll_1(hwnd
, SB_HORZ
, 0, WS_HSCROLL
, 10, 150);
2769 /* clear WS_HSCROLL */
2770 test_hv_scroll_1(hwnd
, SB_HORZ
, WS_HSCROLL
, 0, 0, 0);
2772 /* set WS_HSCROLL */
2773 test_hv_scroll_2(hwnd
, SB_HORZ
, 0, WS_HSCROLL
, 10, 150);
2774 /* clear WS_HSCROLL */
2775 test_hv_scroll_2(hwnd
, SB_HORZ
, WS_HSCROLL
, 0, 0, 0);
2777 /* set WS_VSCROLL */
2778 test_hv_scroll_1(hwnd
, SB_VERT
, 0, WS_VSCROLL
, 10, 150);
2779 /* clear WS_VSCROLL */
2780 test_hv_scroll_1(hwnd
, SB_VERT
, WS_VSCROLL
, 0, 0, 0);
2782 /* set WS_VSCROLL */
2783 test_hv_scroll_2(hwnd
, SB_VERT
, 0, WS_VSCROLL
, 10, 150);
2784 /* clear WS_VSCROLL */
2785 test_hv_scroll_2(hwnd
, SB_VERT
, WS_VSCROLL
, 0, 0, 0);
2788 static void test_showwindow(void)
2792 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW
,
2793 100, 100, 200, 200, 0, 0, 0, NULL
);
2794 ok (hwnd
!= 0, "Failed to create overlapped window\n");
2795 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
2796 0, 0, 10, 10, hwnd
, 0, 0, NULL
);
2797 ok (hchild
!= 0, "Failed to create child\n");
2800 /* ShowWindow( SW_SHOWNA) for invisible top level window */
2801 trace("calling ShowWindow( SW_SHOWNA) for invisible top level window\n");
2802 ok( ShowWindow(hwnd
, SW_SHOWNA
) == FALSE
, "ShowWindow: window was visible\n" );
2803 ok_sequence(WmSHOWNATopInvisible
, "ShowWindow(SW_SHOWNA) on invisible top level window", TRUE
);
2806 /* ShowWindow( SW_SHOWNA) for now visible top level window */
2807 trace("calling ShowWindow( SW_SHOWNA) for now visible top level window\n");
2808 ok( ShowWindow(hwnd
, SW_SHOWNA
) != FALSE
, "ShowWindow: window was invisible\n" );
2809 ok_sequence(WmSHOWNATopVisible
, "ShowWindow(SW_SHOWNA) on visible top level window", FALSE
);
2811 /* back to invisible */
2812 ShowWindow(hchild
, SW_HIDE
);
2813 ShowWindow(hwnd
, SW_HIDE
);
2815 /* ShowWindow(SW_SHOWNA) with child and parent invisible */
2816 trace("calling ShowWindow( SW_SHOWNA) for invisible child with invisible parent\n");
2817 ok( ShowWindow(hchild
, SW_SHOWNA
) == FALSE
, "ShowWindow: window was visible\n" );
2818 ok_sequence(WmSHOWNAChildInvisParInvis
, "ShowWindow(SW_SHOWNA) invisible child and parent", TRUE
);
2820 /* ShowWindow(SW_SHOWNA) with child visible and parent invisible */
2821 ok( ShowWindow(hchild
, SW_SHOW
) != FALSE
, "ShowWindow: window was invisible\n" );
2823 trace("calling ShowWindow( SW_SHOWNA) for the visible child and invisible parent\n");
2824 ok( ShowWindow(hchild
, SW_SHOWNA
) != FALSE
, "ShowWindow: window was invisible\n" );
2825 ok_sequence(WmSHOWNAChildVisParInvis
, "ShowWindow(SW_SHOWNA) visible child and invisible parent", TRUE
);
2827 /* ShowWindow(SW_SHOWNA) with child visible and parent visible */
2828 ShowWindow( hwnd
, SW_SHOW
);
2830 trace("calling ShowWindow( SW_SHOWNA) for the visible child and parent\n");
2831 ok( ShowWindow(hchild
, SW_SHOWNA
) != FALSE
, "ShowWindow: window was invisible\n" );
2832 ok_sequence(WmSHOWNAChildVisParVis
, "ShowWindow(SW_SHOWNA) for the visible child and parent", FALSE
);
2835 /* ShowWindow(SW_SHOWNA) with child invisible and parent visible */
2836 ShowWindow( hchild
, SW_HIDE
);
2838 trace("calling ShowWindow( SW_SHOWNA) for the invisible child and visible parent\n");
2839 ok( ShowWindow(hchild
, SW_SHOWNA
) == FALSE
, "ShowWindow: window was visible\n" );
2840 ok_sequence(WmSHOWNAChildInvisParVis
, "ShowWindow(SW_SHOWNA) for the invisible child and visible parent", FALSE
);
2844 ok(GetCapture() == hchild
, "wrong capture window %p\n", GetCapture());
2845 DestroyWindow(hchild
);
2846 ok(!GetCapture(), "wrong capture window %p\n", GetCapture());
2848 DestroyWindow(hwnd
);
2852 static void test_sys_menu(HWND hwnd
)
2857 /* test existing window without CS_NOCLOSE style */
2858 hmenu
= GetSystemMenu(hwnd
, FALSE
);
2859 ok(hmenu
!= 0, "GetSystemMenu error %ld\n", GetLastError());
2861 state
= GetMenuState(hmenu
, SC_CLOSE
, MF_BYCOMMAND
);
2862 ok(state
!= 0xffffffff, "wrong SC_CLOSE state %x\n", state
);
2863 ok(!(state
& (MF_DISABLED
| MF_GRAYED
)), "wrong SC_CLOSE state %x\n", state
);
2865 EnableMenuItem(hmenu
, SC_CLOSE
, MF_BYCOMMAND
| MF_GRAYED
);
2866 ok_sequence(WmEmptySeq
, "WmEnableMenuItem", FALSE
);
2868 state
= GetMenuState(hmenu
, SC_CLOSE
, MF_BYCOMMAND
);
2869 ok(state
!= 0xffffffff, "wrong SC_CLOSE state %x\n", state
);
2870 ok((state
& (MF_DISABLED
| MF_GRAYED
)) == MF_GRAYED
, "wrong SC_CLOSE state %x\n", state
);
2872 EnableMenuItem(hmenu
, SC_CLOSE
, 0);
2873 ok_sequence(WmEmptySeq
, "WmEnableMenuItem", FALSE
);
2875 state
= GetMenuState(hmenu
, SC_CLOSE
, MF_BYCOMMAND
);
2876 ok(state
!= 0xffffffff, "wrong SC_CLOSE state %x\n", state
);
2877 ok(!(state
& (MF_DISABLED
| MF_GRAYED
)), "wrong SC_CLOSE state %x\n", state
);
2879 /* test new window with CS_NOCLOSE style */
2880 hwnd
= CreateWindowExA(0, "NoCloseWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
2881 100, 100, 200, 200, 0, 0, 0, NULL
);
2882 ok (hwnd
!= 0, "Failed to create overlapped window\n");
2884 hmenu
= GetSystemMenu(hwnd
, FALSE
);
2885 ok(hmenu
!= 0, "GetSystemMenu error %ld\n", GetLastError());
2887 state
= GetMenuState(hmenu
, SC_CLOSE
, MF_BYCOMMAND
);
2888 ok(state
== 0xffffffff, "wrong SC_CLOSE state %x\n", state
);
2890 DestroyWindow(hwnd
);
2893 /* test if we receive the right sequence of messages */
2894 static void test_messages(void)
2896 HWND hwnd
, hparent
, hchild
;
2897 HWND hchild2
, hbutton
;
2903 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW
,
2904 100, 100, 200, 200, 0, 0, 0, NULL
);
2905 ok (hwnd
!= 0, "Failed to create overlapped window\n");
2906 ok_sequence(WmCreateOverlappedSeq
, "CreateWindow:overlapped", FALSE
);
2908 /* test ShowWindow(SW_HIDE) on a newly created invisible window */
2909 ok( ShowWindow(hwnd
, SW_HIDE
) == FALSE
, "ShowWindow: window was visible\n" );
2910 ok_sequence(WmEmptySeq
, "ShowWindow(SW_HIDE):overlapped, invisible", FALSE
);
2912 /* test WM_SETREDRAW on a not visible top level window */
2913 test_WM_SETREDRAW(hwnd
);
2915 SetWindowPos(hwnd
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
);
2916 ok_sequence(WmSWP_ShowOverlappedSeq
, "SetWindowPos:SWP_SHOWWINDOW:overlapped", FALSE
);
2917 ok(IsWindowVisible(hwnd
), "window should be visible at this point\n");
2919 ok(GetActiveWindow() == hwnd
, "window should be active\n");
2920 ok(GetFocus() == hwnd
, "window should have input focus\n");
2921 ShowWindow(hwnd
, SW_HIDE
);
2922 ok_sequence(WmHideOverlappedSeq
, "ShowWindow(SW_HIDE):overlapped", TRUE
);
2924 ShowWindow(hwnd
, SW_SHOW
);
2925 ok_sequence(WmShowOverlappedSeq
, "ShowWindow(SW_SHOW):overlapped", TRUE
);
2927 ShowWindow(hwnd
, SW_SHOW
);
2928 ok_sequence(WmEmptySeq
, "ShowWindow(SW_SHOW):overlapped already visible", FALSE
);
2930 ok(GetActiveWindow() == hwnd
, "window should be active\n");
2931 ok(GetFocus() == hwnd
, "window should have input focus\n");
2932 SetWindowPos(hwnd
, 0,0,0,0,0, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
);
2933 ok_sequence(WmSWP_HideOverlappedSeq
, "SetWindowPos:SWP_HIDEWINDOW:overlapped", FALSE
);
2934 ok(!IsWindowVisible(hwnd
), "window should not be visible at this point\n");
2936 /* test WM_SETREDRAW on a visible top level window */
2937 ShowWindow(hwnd
, SW_SHOW
);
2938 test_WM_SETREDRAW(hwnd
);
2940 trace("testing scroll APIs on a visible top level window %p\n", hwnd
);
2941 test_scroll_messages(hwnd
);
2943 /* test resizing and moving */
2944 SetWindowPos( hwnd
, 0, 0, 0, 300, 300, SWP_NOMOVE
|SWP_NOZORDER
|SWP_NOACTIVATE
);
2945 ok_sequence(WmSWP_ResizeSeq
, "SetWindowPos:Resize", FALSE
);
2946 SetWindowPos( hwnd
, 0, 200, 200, 0, 0, SWP_NOSIZE
|SWP_NOZORDER
|SWP_NOACTIVATE
);
2947 ok_sequence(WmSWP_MoveSeq
, "SetWindowPos:Move", FALSE
);
2949 /* popups don't get WM_GETMINMAXINFO */
2950 SetWindowLongW( hwnd
, GWL_STYLE
, WS_VISIBLE
|WS_POPUP
);
2951 SetWindowPos( hwnd
, 0, 0, 0, 0, 0, SWP_NOZORDER
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_FRAMECHANGED
);
2953 SetWindowPos( hwnd
, 0, 0, 0, 200, 200, SWP_NOMOVE
|SWP_NOZORDER
|SWP_NOACTIVATE
);
2954 ok_sequence(WmSWP_ResizePopupSeq
, "SetWindowPos:ResizePopup", FALSE
);
2956 test_sys_menu(hwnd
);
2959 DestroyWindow(hwnd
);
2960 ok_sequence(WmDestroyOverlappedSeq
, "DestroyWindow:overlapped", FALSE
);
2962 hparent
= CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
2963 100, 100, 200, 200, 0, 0, 0, NULL
);
2964 ok (hparent
!= 0, "Failed to create parent window\n");
2967 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
| WS_MAXIMIZE
,
2968 0, 0, 10, 10, hparent
, 0, 0, NULL
);
2969 ok (hchild
!= 0, "Failed to create child window\n");
2970 ok_sequence(WmCreateMaximizedChildSeq
, "CreateWindow:maximized child", TRUE
);
2971 DestroyWindow(hchild
);
2974 /* visible child window with a caption */
2975 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child",
2976 WS_CHILD
| WS_VISIBLE
| WS_CAPTION
,
2977 0, 0, 10, 10, hparent
, 0, 0, NULL
);
2978 ok (hchild
!= 0, "Failed to create child window\n");
2979 ok_sequence(WmCreateVisibleChildSeq
, "CreateWindow:visible child", FALSE
);
2981 trace("testing scroll APIs on a visible child window %p\n", hchild
);
2982 test_scroll_messages(hchild
);
2984 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
);
2985 ok_sequence(WmShowChildSeq_4
, "SetWindowPos(SWP_SHOWWINDOW):child with a caption", FALSE
);
2987 DestroyWindow(hchild
);
2990 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
2991 0, 0, 10, 10, hparent
, 0, 0, NULL
);
2992 ok (hchild
!= 0, "Failed to create child window\n");
2993 ok_sequence(WmCreateChildSeq
, "CreateWindow:child", FALSE
);
2995 hchild2
= CreateWindowExA(0, "SimpleWindowClass", "Test child2", WS_CHILD
,
2996 100, 100, 50, 50, hparent
, 0, 0, NULL
);
2997 ok (hchild2
!= 0, "Failed to create child2 window\n");
3000 hbutton
= CreateWindowExA(0, "TestWindowClass", "Test button", WS_CHILD
,
3001 0, 100, 50, 50, hchild
, 0, 0, NULL
);
3002 ok (hbutton
!= 0, "Failed to create button window\n");
3004 /* test WM_SETREDRAW on a not visible child window */
3005 test_WM_SETREDRAW(hchild
);
3007 ShowWindow(hchild
, SW_SHOW
);
3008 ok_sequence(WmShowChildSeq
, "ShowWindow(SW_SHOW):child", FALSE
);
3010 ShowWindow(hchild
, SW_HIDE
);
3011 ok_sequence(WmHideChildSeq
, "ShowWindow(SW_HIDE):child", FALSE
);
3013 ShowWindow(hchild
, SW_SHOW
);
3014 ok_sequence(WmShowChildSeq
, "ShowWindow(SW_SHOW):child", FALSE
);
3016 /* test WM_SETREDRAW on a visible child window */
3017 test_WM_SETREDRAW(hchild
);
3019 MoveWindow(hchild
, 10, 10, 20, 20, TRUE
);
3020 ok_sequence(WmResizingChildWithMoveWindowSeq
, "MoveWindow:child", FALSE
);
3022 ShowWindow(hchild
, SW_HIDE
);
3024 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
);
3025 ok_sequence(WmShowChildSeq_2
, "SetWindowPos:show_child_2", FALSE
);
3027 ShowWindow(hchild
, SW_HIDE
);
3029 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
);
3030 ok_sequence(WmShowChildSeq_3
, "SetWindowPos:show_child_3", FALSE
);
3032 /* DestroyWindow sequence below expects that a child has focus */
3036 DestroyWindow(hchild
);
3037 ok_sequence(WmDestroyChildSeq
, "DestroyWindow:child", FALSE
);
3038 DestroyWindow(hchild2
);
3039 DestroyWindow(hbutton
);
3042 hchild
= CreateWindowExA(0, "TestWindowClass", "Test Child Popup", WS_CHILD
| WS_POPUP
,
3043 0, 0, 100, 100, hparent
, 0, 0, NULL
);
3044 ok (hchild
!= 0, "Failed to create child popup window\n");
3045 ok_sequence(WmCreateChildPopupSeq
, "CreateWindow:child_popup", FALSE
);
3046 DestroyWindow(hchild
);
3048 /* test what happens to a window which sets WS_VISIBLE in WM_CREATE */
3050 hchild
= CreateWindowExA(0, "TestPopupClass", "Test Popup", WS_POPUP
,
3051 0, 0, 100, 100, hparent
, 0, 0, NULL
);
3052 ok (hchild
!= 0, "Failed to create popup window\n");
3053 ok_sequence(WmCreateInvisiblePopupSeq
, "CreateWindow:invisible_popup", FALSE
);
3054 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
3055 ok(IsWindowVisible(hchild
), "IsWindowVisible() should return TRUE\n");
3057 ShowWindow(hchild
, SW_SHOW
);
3058 ok_sequence(WmEmptySeq
, "ShowWindow:show_visible_popup", FALSE
);
3060 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOZORDER
);
3061 ok_sequence(WmShowVisiblePopupSeq_2
, "SetWindowPos:show_visible_popup_2", FALSE
);
3063 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
);
3064 ok_sequence(WmShowVisiblePopupSeq_3
, "SetWindowPos:show_visible_popup_3", FALSE
);
3065 DestroyWindow(hchild
);
3067 /* this time add WS_VISIBLE for CreateWindowEx, but this fact actually
3068 * changes nothing in message sequences.
3071 hchild
= CreateWindowExA(0, "TestPopupClass", "Test Popup", WS_POPUP
| WS_VISIBLE
,
3072 0, 0, 100, 100, hparent
, 0, 0, NULL
);
3073 ok (hchild
!= 0, "Failed to create popup window\n");
3074 ok_sequence(WmCreateInvisiblePopupSeq
, "CreateWindow:invisible_popup", FALSE
);
3075 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
3076 ok(IsWindowVisible(hchild
), "IsWindowVisible() should return TRUE\n");
3078 ShowWindow(hchild
, SW_SHOW
);
3079 ok_sequence(WmEmptySeq
, "ShowWindow:show_visible_popup", FALSE
);
3081 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOZORDER
);
3082 ok_sequence(WmShowVisiblePopupSeq_2
, "SetWindowPos:show_visible_popup_2", FALSE
);
3083 DestroyWindow(hchild
);
3086 hwnd
= CreateWindowExA(WS_EX_DLGMODALFRAME
, "TestDialogClass", NULL
, WS_VISIBLE
|WS_CAPTION
|WS_SYSMENU
|WS_DLGFRAME
,
3087 0, 0, 100, 100, hparent
, 0, 0, NULL
);
3088 ok(hwnd
!= 0, "Failed to create custom dialog window\n");
3089 ok_sequence(WmCreateCustomDialogSeq
, "CreateCustomDialog", TRUE
);
3092 trace("testing scroll APIs on a visible dialog %p\n", hwnd);
3093 test_scroll_messages(hwnd);
3097 after_end_dialog
= 1;
3098 EndDialog( hwnd
, 0 );
3099 ok_sequence(WmEndCustomDialogSeq
, "EndCustomDialog", FALSE
);
3101 DestroyWindow(hwnd
);
3102 after_end_dialog
= 0;
3104 hwnd
= CreateWindowExA(0, "TestDialogClass", NULL
, WS_POPUP
,
3105 0, 0, 100, 100, 0, 0, GetModuleHandleA(0), NULL
);
3106 ok(hwnd
!= 0, "Failed to create custom dialog window\n");
3108 trace("call ShowWindow(%p, SW_SHOW)\n", hwnd
);
3109 ShowWindow(hwnd
, SW_SHOW
);
3110 ok_sequence(WmShowCustomDialogSeq
, "ShowCustomDialog", TRUE
);
3111 DestroyWindow(hwnd
);
3114 DialogBoxA( 0, "TEST_DIALOG", hparent
, TestModalDlgProcA
);
3115 ok_sequence(WmModalDialogSeq
, "ModalDialog", TRUE
);
3117 /* test showing child with hidden parent */
3118 ShowWindow( hparent
, SW_HIDE
);
3121 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
3122 0, 0, 10, 10, hparent
, 0, 0, NULL
);
3123 ok (hchild
!= 0, "Failed to create child window\n");
3124 ok_sequence(WmCreateChildSeq
, "CreateWindow:child", FALSE
);
3126 ShowWindow( hchild
, SW_SHOW
);
3127 ok_sequence(WmShowChildInvisibleParentSeq
, "ShowWindow:show child with invisible parent", TRUE
);
3128 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
3129 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
3131 ShowWindow( hchild
, SW_HIDE
);
3132 ok_sequence(WmHideChildInvisibleParentSeq
, "ShowWindow:hide child with invisible parent", TRUE
);
3133 ok(!(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
), "WS_VISIBLE should be not set\n");
3134 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
3136 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOZORDER
);
3137 ok_sequence(WmShowChildInvisibleParentSeq_2
, "SetWindowPos:show child with invisible parent", FALSE
);
3138 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
3139 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
3141 SetWindowPos(hchild
, 0,0,0,0,0, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOZORDER
);
3142 ok_sequence(WmHideChildInvisibleParentSeq_2
, "SetWindowPos:hide child with invisible parent", FALSE
);
3143 ok(!(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
), "WS_VISIBLE should not be set\n");
3144 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
3146 DestroyWindow(hchild
);
3147 DestroyWindow(hparent
);
3150 /* Message sequence for SetMenu */
3151 ok(!DrawMenuBar(hwnd
), "DrawMenuBar should return FALSE for a window without a menu\n");
3152 ok_sequence(WmEmptySeq
, "DrawMenuBar for a window without a menu", FALSE
);
3154 hmenu
= CreateMenu();
3155 ok (hmenu
!= 0, "Failed to create menu\n");
3156 ok (InsertMenuA(hmenu
, -1, MF_BYPOSITION
, 0x1000, "foo"), "InsertMenu failed\n");
3157 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW
,
3158 100, 100, 200, 200, 0, hmenu
, 0, NULL
);
3159 ok_sequence(WmCreateOverlappedSeq
, "CreateWindow:overlapped", FALSE
);
3160 ok (SetMenu(hwnd
, 0), "SetMenu\n");
3161 ok_sequence(WmSetMenuNonVisibleSizeChangeSeq
, "SetMenu:NonVisibleSizeChange", FALSE
);
3162 ok (SetMenu(hwnd
, 0), "SetMenu\n");
3163 ok_sequence(WmSetMenuNonVisibleNoSizeChangeSeq
, "SetMenu:NonVisibleNoSizeChange", FALSE
);
3164 ShowWindow(hwnd
, SW_SHOW
);
3166 ok (SetMenu(hwnd
, 0), "SetMenu\n");
3167 ok_sequence(WmSetMenuVisibleNoSizeChangeSeq
, "SetMenu:VisibleNoSizeChange", TRUE
);
3168 ok (SetMenu(hwnd
, hmenu
), "SetMenu\n");
3169 ok_sequence(WmSetMenuVisibleSizeChangeSeq
, "SetMenu:VisibleSizeChange", TRUE
);
3171 ok(DrawMenuBar(hwnd
), "DrawMenuBar\n");
3172 ok_sequence(WmDrawMenuBarSeq
, "DrawMenuBar", TRUE
);
3174 DestroyWindow(hwnd
);
3177 /* Message sequence for EnableWindow */
3178 hparent
= CreateWindowExA(0, "TestWindowClass", "Test parent", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
3179 100, 100, 200, 200, 0, 0, 0, NULL
);
3180 ok (hparent
!= 0, "Failed to create parent window\n");
3181 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
| WS_VISIBLE
,
3182 0, 0, 10, 10, hparent
, 0, 0, NULL
);
3183 ok (hchild
!= 0, "Failed to create child window\n");
3188 EnableWindow(hparent
, FALSE
);
3189 ok_sequence(WmEnableWindowSeq
, "EnableWindow", FALSE
);
3191 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
3194 /* the following test causes an exception in user.exe under win9x */
3195 if (!PostMessageW( hparent
, WM_USER
, 0, 0 )) return;
3196 PostMessageW( hparent
, WM_USER
+1, 0, 0 );
3197 /* PeekMessage(NULL) fails, but still removes the message */
3198 SetLastError(0xdeadbeef);
3199 ok( !PeekMessageW( NULL
, 0, 0, 0, PM_REMOVE
), "PeekMessage(NULL) should fail\n" );
3200 ok( GetLastError() == ERROR_NOACCESS
|| /* Win2k */
3201 GetLastError() == 0xdeadbeef, /* NT4 */
3202 "last error is %ld\n", GetLastError() );
3203 ok( PeekMessageW( &msg
, 0, 0, 0, PM_REMOVE
), "PeekMessage should succeed\n" );
3204 ok( msg
.message
== WM_USER
+1, "got %x instead of WM_USER+1\n", msg
.message
);
3206 DestroyWindow(hchild
);
3207 DestroyWindow(hparent
);
3213 /****************** button message test *************************/
3214 static const struct message WmSetFocusButtonSeq
[] =
3216 { HCBT_SETFOCUS
, hook
},
3217 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
3218 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
3219 { WM_SETFOCUS
, sent
|wparam
, 0 },
3220 { WM_CTLCOLORBTN
, sent
|defwinproc
},
3223 static const struct message WmKillFocusButtonSeq
[] =
3225 { HCBT_SETFOCUS
, hook
},
3226 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
3227 { WM_KILLFOCUS
, sent
|wparam
, 0 },
3228 { WM_CTLCOLORBTN
, sent
|defwinproc
},
3229 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
3232 static const struct message WmSetFocusStaticSeq
[] =
3234 { HCBT_SETFOCUS
, hook
},
3235 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
3236 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
3237 { WM_SETFOCUS
, sent
|wparam
, 0 },
3238 { WM_CTLCOLORSTATIC
, sent
|defwinproc
},
3241 static const struct message WmKillFocusStaticSeq
[] =
3243 { HCBT_SETFOCUS
, hook
},
3244 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
3245 { WM_KILLFOCUS
, sent
|wparam
, 0 },
3246 { WM_CTLCOLORSTATIC
, sent
|defwinproc
},
3247 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
3250 static const struct message WmLButtonDownSeq
[] =
3252 { WM_LBUTTONDOWN
, sent
|wparam
|lparam
, 0, 0 },
3253 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
3254 { HCBT_SETFOCUS
, hook
},
3255 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
3256 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
3257 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
3258 { WM_CTLCOLORBTN
, sent
|defwinproc
},
3259 { BM_SETSTATE
, sent
|wparam
|defwinproc
, TRUE
},
3260 { WM_CTLCOLORBTN
, sent
|defwinproc
},
3261 { EVENT_OBJECT_STATECHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
3264 static const struct message WmLButtonUpSeq
[] =
3266 { WM_LBUTTONUP
, sent
|wparam
|lparam
, 0, 0 },
3267 { BM_SETSTATE
, sent
|wparam
|defwinproc
, FALSE
},
3268 { WM_CTLCOLORBTN
, sent
|defwinproc
},
3269 { EVENT_OBJECT_STATECHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
3270 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, 0, 0 },
3271 { WM_CAPTURECHANGED
, sent
|wparam
|defwinproc
, 0 },
3275 static WNDPROC old_button_proc
;
3277 static LRESULT CALLBACK
button_hook_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
3279 static long defwndproc_counter
= 0;
3283 trace("button: %p, %04x, %08x, %08lx\n", hwnd
, message
, wParam
, lParam
);
3285 msg
.message
= message
;
3286 msg
.flags
= sent
|wparam
|lparam
;
3287 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
3288 msg
.wParam
= wParam
;
3289 msg
.lParam
= lParam
;
3292 if (message
== BM_SETSTATE
)
3293 ok(GetCapture() == hwnd
, "GetCapture() = %p\n", GetCapture());
3295 defwndproc_counter
++;
3296 ret
= CallWindowProcA(old_button_proc
, hwnd
, message
, wParam
, lParam
);
3297 defwndproc_counter
--;
3302 static void subclass_button(void)
3306 if (!GetClassInfoA(0, "button", &cls
)) assert(0);
3308 old_button_proc
= cls
.lpfnWndProc
;
3310 cls
.hInstance
= GetModuleHandle(0);
3311 cls
.lpfnWndProc
= button_hook_proc
;
3312 cls
.lpszClassName
= "my_button_class";
3313 if (!RegisterClassA(&cls
)) assert(0);
3316 static void test_button_messages(void)
3322 const struct message
*setfocus
;
3323 const struct message
*killfocus
;
3325 { BS_PUSHBUTTON
, DLGC_BUTTON
| DLGC_UNDEFPUSHBUTTON
,
3326 WmSetFocusButtonSeq
, WmKillFocusButtonSeq
},
3327 { BS_DEFPUSHBUTTON
, DLGC_BUTTON
| DLGC_DEFPUSHBUTTON
,
3328 WmSetFocusButtonSeq
, WmKillFocusButtonSeq
},
3329 { BS_CHECKBOX
, DLGC_BUTTON
,
3330 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
},
3331 { BS_AUTOCHECKBOX
, DLGC_BUTTON
,
3332 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
},
3333 { BS_RADIOBUTTON
, DLGC_BUTTON
| DLGC_RADIOBUTTON
,
3334 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
},
3335 { BS_3STATE
, DLGC_BUTTON
,
3336 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
},
3337 { BS_AUTO3STATE
, DLGC_BUTTON
,
3338 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
},
3339 { BS_GROUPBOX
, DLGC_STATIC
,
3340 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
},
3341 { BS_USERBUTTON
, DLGC_BUTTON
| DLGC_UNDEFPUSHBUTTON
,
3342 WmSetFocusButtonSeq
, WmKillFocusButtonSeq
},
3343 { BS_AUTORADIOBUTTON
, DLGC_BUTTON
| DLGC_RADIOBUTTON
,
3344 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
},
3345 { BS_OWNERDRAW
, DLGC_BUTTON
,
3346 WmSetFocusButtonSeq
, WmKillFocusButtonSeq
}
3354 for (i
= 0; i
< sizeof(button
)/sizeof(button
[0]); i
++)
3356 hwnd
= CreateWindowExA(0, "my_button_class", "test", button
[i
].style
| WS_POPUP
,
3357 0, 0, 50, 14, 0, 0, 0, NULL
);
3358 ok(hwnd
!= 0, "Failed to create button window\n");
3360 dlg_code
= SendMessageA(hwnd
, WM_GETDLGCODE
, 0, 0);
3361 ok(dlg_code
== button
[i
].dlg_code
, "%d: wrong dlg_code %08lx\n", i
, dlg_code
);
3363 ShowWindow(hwnd
, SW_SHOW
);
3368 trace("button style %08lx\n", button
[i
].style
);
3370 ok_sequence(button
[i
].setfocus
, "SetFocus(hwnd) on a button", FALSE
);
3373 ok_sequence(button
[i
].killfocus
, "SetFocus(0) on a button", FALSE
);
3375 DestroyWindow(hwnd
);
3378 hwnd
= CreateWindowExA(0, "my_button_class", "test", BS_PUSHBUTTON
| WS_POPUP
| WS_VISIBLE
,
3379 0, 0, 50, 14, 0, 0, 0, NULL
);
3380 ok(hwnd
!= 0, "Failed to create button window\n");
3385 SendMessageA(hwnd
, WM_LBUTTONDOWN
, 0, 0);
3386 ok_sequence(WmLButtonDownSeq
, "WM_LBUTTONDOWN on a button", FALSE
);
3388 SendMessageA(hwnd
, WM_LBUTTONUP
, 0, 0);
3389 ok_sequence(WmLButtonUpSeq
, "WM_LBUTTONUP on a button", FALSE
);
3390 DestroyWindow(hwnd
);
3393 /************* painting message test ********************/
3395 void dump_region(HRGN hrgn
)
3398 RGNDATA
*data
= NULL
;
3403 printf( "null region\n" );
3406 if (!(size
= GetRegionData( hrgn
, 0, NULL
))) return;
3407 if (!(data
= HeapAlloc( GetProcessHeap(), 0, size
))) return;
3408 GetRegionData( hrgn
, size
, data
);
3409 printf("%ld rects:", data
->rdh
.nCount
);
3410 for (i
= 0, rect
= (RECT
*)data
->Buffer
; i
< data
->rdh
.nCount
; i
++, rect
++)
3411 printf( " (%ld,%ld)-(%ld,%ld)", rect
->left
, rect
->top
, rect
->right
, rect
->bottom
);
3413 HeapFree( GetProcessHeap(), 0, data
);
3416 static void check_update_rgn( HWND hwnd
, HRGN hrgn
)
3420 HRGN tmp
= CreateRectRgn( 0, 0, 0, 0 );
3421 HRGN update
= CreateRectRgn( 0, 0, 0, 0 );
3423 ret
= GetUpdateRgn( hwnd
, update
, FALSE
);
3424 ok( ret
!= ERROR
, "GetUpdateRgn failed\n" );
3425 if (ret
== NULLREGION
)
3427 ok( !hrgn
, "Update region shouldn't be empty\n" );
3431 if (CombineRgn( tmp
, hrgn
, update
, RGN_XOR
) != NULLREGION
)
3433 ok( 0, "Regions are different\n" );
3434 if (winetest_debug
> 0)
3436 printf( "Update region: " );
3437 dump_region( update
);
3438 printf( "Wanted region: " );
3439 dump_region( hrgn
);
3443 GetRgnBox( update
, &r1
);
3444 GetUpdateRect( hwnd
, &r2
, FALSE
);
3445 ok( r1
.left
== r2
.left
&& r1
.top
== r2
.top
&& r1
.right
== r2
.right
&& r1
.bottom
== r2
.bottom
,
3446 "Rectangles are different: %ld,%ld-%ld,%ld / %ld,%ld-%ld,%ld\n",
3447 r1
.left
, r1
.top
, r1
.right
, r1
.bottom
, r2
.left
, r2
.top
, r2
.right
, r2
.bottom
);
3449 DeleteObject( tmp
);
3450 DeleteObject( update
);
3453 static const struct message WmInvalidateRgn
[] = {
3454 { WM_NCPAINT
, sent
},
3455 { WM_GETTEXT
, sent
|defwinproc
|optional
},
3459 static const struct message WmGetUpdateRect
[] = {
3460 { WM_NCPAINT
, sent
},
3461 { WM_GETTEXT
, sent
|defwinproc
|optional
},
3466 static const struct message WmInvalidateFull
[] = {
3467 { WM_NCPAINT
, sent
|wparam
, 1 },
3468 { WM_GETTEXT
, sent
|defwinproc
|optional
},
3472 static const struct message WmInvalidateErase
[] = {
3473 { WM_NCPAINT
, sent
|wparam
, 1 },
3474 { WM_GETTEXT
, sent
|defwinproc
|optional
},
3475 { WM_ERASEBKGND
, sent
},
3479 static const struct message WmInvalidatePaint
[] = {
3481 { WM_NCPAINT
, sent
|wparam
|beginpaint
, 1 },
3482 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
3486 static const struct message WmInvalidateErasePaint
[] = {
3488 { WM_NCPAINT
, sent
|wparam
|beginpaint
, 1 },
3489 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
3490 { WM_ERASEBKGND
, sent
|beginpaint
},
3494 static const struct message WmInvalidateErasePaint2
[] = {
3496 { WM_NCPAINT
, sent
|beginpaint
},
3497 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
3498 { WM_ERASEBKGND
, sent
|beginpaint
},
3502 static const struct message WmErase
[] = {
3503 { WM_ERASEBKGND
, sent
},
3507 static const struct message WmPaint
[] = {
3512 static const struct message WmParentOnlyPaint
[] = {
3513 { WM_PAINT
, sent
|parent
},
3517 static const struct message WmInvalidateParent
[] = {
3518 { WM_NCPAINT
, sent
|parent
},
3519 { WM_GETTEXT
, sent
|defwinproc
|parent
|optional
},
3520 { WM_ERASEBKGND
, sent
|parent
},
3524 static const struct message WmInvalidateParentChild
[] = {
3525 { WM_NCPAINT
, sent
|parent
},
3526 { WM_GETTEXT
, sent
|defwinproc
|parent
|optional
},
3527 { WM_ERASEBKGND
, sent
|parent
},
3528 { WM_NCPAINT
, sent
},
3529 { WM_GETTEXT
, sent
|defwinproc
|optional
},
3530 { WM_ERASEBKGND
, sent
},
3534 static const struct message WmInvalidateParentChild2
[] = {
3535 { WM_ERASEBKGND
, sent
|parent
},
3536 { WM_NCPAINT
, sent
},
3537 { WM_GETTEXT
, sent
|defwinproc
|optional
},
3538 { WM_ERASEBKGND
, sent
},
3542 static const struct message WmParentPaint
[] = {
3543 { WM_PAINT
, sent
|parent
},
3548 static const struct message WmParentPaintNc
[] = {
3549 { WM_PAINT
, sent
|parent
},
3551 { WM_NCPAINT
, sent
|beginpaint
},
3552 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
3553 { WM_ERASEBKGND
, sent
|beginpaint
},
3557 static const struct message WmChildPaintNc
[] = {
3559 { WM_NCPAINT
, sent
|beginpaint
},
3560 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
3561 { WM_ERASEBKGND
, sent
|beginpaint
},
3565 static const struct message WmParentErasePaint
[] = {
3566 { WM_PAINT
, sent
|parent
},
3567 { WM_NCPAINT
, sent
|parent
|beginpaint
},
3568 { WM_GETTEXT
, sent
|parent
|beginpaint
|defwinproc
|optional
},
3569 { WM_ERASEBKGND
, sent
|parent
|beginpaint
},
3571 { WM_NCPAINT
, sent
|beginpaint
},
3572 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
3573 { WM_ERASEBKGND
, sent
|beginpaint
},
3577 static const struct message WmParentOnlyNcPaint
[] = {
3578 { WM_PAINT
, sent
|parent
},
3579 { WM_NCPAINT
, sent
|parent
|beginpaint
},
3580 { WM_GETTEXT
, sent
|parent
|beginpaint
|defwinproc
|optional
},
3584 static const struct message WmSetParentStyle
[] = {
3585 { WM_STYLECHANGING
, sent
|parent
},
3586 { WM_STYLECHANGED
, sent
|parent
},
3590 static void test_paint_messages(void)
3595 HWND hparent
, hchild
;
3596 HRGN hrgn
= CreateRectRgn( 0, 0, 0, 0 );
3597 HRGN hrgn2
= CreateRectRgn( 0, 0, 0, 0 );
3598 HWND hwnd
= CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW
,
3599 100, 100, 200, 200, 0, 0, 0, NULL
);
3600 ok (hwnd
!= 0, "Failed to create overlapped window\n");
3602 ShowWindow( hwnd
, SW_SHOW
);
3603 UpdateWindow( hwnd
);
3605 /* try to flush pending X expose events */
3606 MsgWaitForMultipleObjects( 0, NULL
, FALSE
, 100, QS_ALLINPUT
);
3607 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
3609 check_update_rgn( hwnd
, 0 );
3610 SetRectRgn( hrgn
, 10, 10, 20, 20 );
3611 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
);
3612 check_update_rgn( hwnd
, hrgn
);
3613 SetRectRgn( hrgn2
, 20, 20, 30, 30 );
3614 RedrawWindow( hwnd
, NULL
, hrgn2
, RDW_INVALIDATE
);
3615 CombineRgn( hrgn
, hrgn
, hrgn2
, RGN_OR
);
3616 check_update_rgn( hwnd
, hrgn
);
3617 /* validate everything */
3618 RedrawWindow( hwnd
, NULL
, NULL
, RDW_VALIDATE
);
3619 check_update_rgn( hwnd
, 0 );
3620 /* now with frame */
3621 SetRectRgn( hrgn
, -5, -5, 20, 20 );
3623 /* flush pending messages */
3624 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
3627 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_FRAME
);
3628 ok_sequence( WmEmptySeq
, "EmptySeq", FALSE
);
3630 SetRectRgn( hrgn
, 0, 0, 20, 20 ); /* GetUpdateRgn clips to client area */
3631 check_update_rgn( hwnd
, hrgn
);
3634 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASENOW
);
3635 ok_sequence( WmInvalidateRgn
, "InvalidateRgn", FALSE
);
3638 RedrawWindow( hwnd
, NULL
, NULL
, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASENOW
);
3639 ok_sequence( WmInvalidateFull
, "InvalidateFull", FALSE
);
3641 GetClientRect( hwnd
, &rect
);
3642 SetRectRgn( hrgn
, rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
3643 check_update_rgn( hwnd
, hrgn
);
3646 RedrawWindow( hwnd
, NULL
, NULL
, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASE
| RDW_ERASENOW
);
3647 ok_sequence( WmInvalidateErase
, "InvalidateErase", FALSE
);
3650 RedrawWindow( hwnd
, NULL
, NULL
, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASENOW
| RDW_UPDATENOW
);
3651 ok_sequence( WmInvalidatePaint
, "InvalidatePaint", FALSE
);
3652 check_update_rgn( hwnd
, 0 );
3655 RedrawWindow( hwnd
, NULL
, NULL
, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASE
| RDW_UPDATENOW
);
3656 ok_sequence( WmInvalidateErasePaint
, "InvalidateErasePaint", FALSE
);
3657 check_update_rgn( hwnd
, 0 );
3660 SetRectRgn( hrgn
, 0, 0, 100, 100 );
3661 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
);
3662 SetRectRgn( hrgn
, 0, 0, 50, 100 );
3663 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_VALIDATE
);
3664 SetRectRgn( hrgn
, 50, 0, 100, 100 );
3665 check_update_rgn( hwnd
, hrgn
);
3666 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_VALIDATE
| RDW_ERASENOW
);
3667 ok_sequence( WmEmptySeq
, "EmptySeq", FALSE
); /* must not generate messages, everything is valid */
3668 check_update_rgn( hwnd
, 0 );
3671 SetRectRgn( hrgn
, 0, 0, 100, 100 );
3672 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_ERASE
);
3673 SetRectRgn( hrgn
, 0, 0, 100, 50 );
3674 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_VALIDATE
| RDW_ERASENOW
);
3675 ok_sequence( WmErase
, "Erase", FALSE
);
3676 SetRectRgn( hrgn
, 0, 50, 100, 100 );
3677 check_update_rgn( hwnd
, hrgn
);
3680 SetRectRgn( hrgn
, 0, 0, 100, 100 );
3681 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_ERASE
);
3682 SetRectRgn( hrgn
, 0, 0, 50, 50 );
3683 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_VALIDATE
| RDW_NOERASE
| RDW_UPDATENOW
);
3684 ok_sequence( WmPaint
, "Paint", FALSE
);
3687 SetRectRgn( hrgn
, -4, -4, -2, -2 );
3688 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_FRAME
);
3689 SetRectRgn( hrgn
, -200, -200, -198, -198 );
3690 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_VALIDATE
| RDW_NOFRAME
| RDW_ERASENOW
);
3691 ok_sequence( WmEmptySeq
, "EmptySeq", FALSE
);
3694 SetRectRgn( hrgn
, -4, -4, -2, -2 );
3695 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_FRAME
);
3696 SetRectRgn( hrgn
, -4, -4, -3, -3 );
3697 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_VALIDATE
| RDW_NOFRAME
);
3698 SetRectRgn( hrgn
, 0, 0, 1, 1 );
3699 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_UPDATENOW
);
3700 ok_sequence( WmPaint
, "Paint", FALSE
);
3703 SetRectRgn( hrgn
, -4, -4, -1, -1 );
3704 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_FRAME
);
3705 RedrawWindow( hwnd
, NULL
, 0, RDW_ERASENOW
);
3706 /* make sure no WM_PAINT was generated */
3707 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
3708 ok_sequence( WmInvalidateRgn
, "InvalidateRgn", FALSE
);
3711 SetRectRgn( hrgn
, -4, -4, -1, -1 );
3712 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_FRAME
);
3713 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
))
3715 if (msg
.hwnd
== hwnd
&& msg
.message
== WM_PAINT
)
3717 /* GetUpdateRgn must return empty region since only nonclient area is invalidated */
3718 INT ret
= GetUpdateRgn( hwnd
, hrgn
, FALSE
);
3719 ok( ret
== NULLREGION
, "Invalid GetUpdateRgn result %d\n", ret
);
3720 ret
= GetUpdateRect( hwnd
, &rect
, FALSE
);
3721 ok( ret
, "Invalid GetUpdateRect result %d\n", ret
);
3722 /* this will send WM_NCPAINT and validate the non client area */
3723 ret
= GetUpdateRect( hwnd
, &rect
, TRUE
);
3724 ok( !ret
, "Invalid GetUpdateRect result %d\n", ret
);
3726 DispatchMessage( &msg
);
3728 ok_sequence( WmGetUpdateRect
, "GetUpdateRect", FALSE
);
3730 DestroyWindow( hwnd
);
3732 /* now test with a child window */
3734 hparent
= CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW
,
3735 100, 100, 200, 200, 0, 0, 0, NULL
);
3736 ok (hparent
!= 0, "Failed to create parent window\n");
3738 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
| WS_VISIBLE
| WS_BORDER
,
3739 10, 10, 100, 100, hparent
, 0, 0, NULL
);
3740 ok (hchild
!= 0, "Failed to create child window\n");
3742 ShowWindow( hparent
, SW_SHOW
);
3743 UpdateWindow( hparent
);
3744 UpdateWindow( hchild
);
3745 /* try to flush pending X expose events */
3746 MsgWaitForMultipleObjects( 0, NULL
, FALSE
, 100, QS_ALLINPUT
);
3747 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
3750 log_all_parent_messages
++;
3752 SetRect( &rect
, 0, 0, 50, 50 );
3753 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
3754 RedrawWindow( hparent
, NULL
, 0, RDW_ERASENOW
| RDW_ALLCHILDREN
);
3755 ok_sequence( WmInvalidateParentChild
, "InvalidateParentChild", FALSE
);
3757 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
3759 MapWindowPoints( hchild
, hparent
, &pt
, 1 );
3760 SetRectRgn( hrgn
, 0, 0, 50 - pt
.x
, 50 - pt
.y
);
3761 check_update_rgn( hchild
, hrgn
);
3762 SetRectRgn( hrgn
, 0, 0, 50, 50 );
3763 check_update_rgn( hparent
, hrgn
);
3764 RedrawWindow( hparent
, NULL
, 0, RDW_ERASENOW
);
3765 ok_sequence( WmInvalidateParent
, "InvalidateParent", FALSE
);
3766 RedrawWindow( hchild
, NULL
, 0, RDW_ERASENOW
);
3767 ok_sequence( WmEmptySeq
, "EraseNow child", FALSE
);
3769 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
3770 ok_sequence( WmParentPaintNc
, "WmParentPaintNc", FALSE
);
3772 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
| RDW_ALLCHILDREN
);
3773 RedrawWindow( hparent
, NULL
, 0, RDW_ERASENOW
);
3774 ok_sequence( WmInvalidateParent
, "InvalidateParent2", FALSE
);
3775 RedrawWindow( hchild
, NULL
, 0, RDW_ERASENOW
);
3776 ok_sequence( WmEmptySeq
, "EraseNow child", FALSE
);
3778 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
);
3779 RedrawWindow( hparent
, NULL
, 0, RDW_ERASENOW
| RDW_ALLCHILDREN
);
3780 ok_sequence( WmInvalidateParentChild2
, "InvalidateParentChild2", FALSE
);
3782 SetWindowLong( hparent
, GWL_STYLE
, GetWindowLong(hparent
,GWL_STYLE
) | WS_CLIPCHILDREN
);
3784 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
| RDW_ALLCHILDREN
);
3785 RedrawWindow( hparent
, NULL
, 0, RDW_ERASENOW
);
3786 ok_sequence( WmInvalidateParentChild
, "InvalidateParentChild3", FALSE
);
3788 /* flush all paint messages */
3789 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
3792 /* RDW_UPDATENOW on child with WS_CLIPCHILDREN doesn't change corresponding parent area */
3793 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
| RDW_ALLCHILDREN
);
3794 SetRectRgn( hrgn
, 0, 0, 50, 50 );
3795 check_update_rgn( hparent
, hrgn
);
3796 RedrawWindow( hchild
, NULL
, 0, RDW_UPDATENOW
);
3797 ok_sequence( WmInvalidateErasePaint2
, "WmInvalidateErasePaint2", FALSE
);
3798 SetRectRgn( hrgn
, 0, 0, 50, 50 );
3799 check_update_rgn( hparent
, hrgn
);
3801 /* flush all paint messages */
3802 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
3803 SetWindowLong( hparent
, GWL_STYLE
, GetWindowLong(hparent
,GWL_STYLE
) & ~WS_CLIPCHILDREN
);
3806 /* RDW_UPDATENOW on child without WS_CLIPCHILDREN will validate corresponding parent area */
3807 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
3808 SetRectRgn( hrgn
, 0, 0, 50, 50 );
3809 check_update_rgn( hparent
, hrgn
);
3810 RedrawWindow( hchild
, NULL
, 0, RDW_UPDATENOW
);
3811 ok_sequence( WmInvalidateErasePaint2
, "WmInvalidateErasePaint2", FALSE
);
3812 SetRectRgn( hrgn2
, 10, 10, 50, 50 );
3813 CombineRgn( hrgn
, hrgn
, hrgn2
, RGN_DIFF
);
3814 check_update_rgn( hparent
, hrgn
);
3815 /* flush all paint messages */
3816 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
3819 /* same as above but parent gets completely validated */
3820 SetRect( &rect
, 20, 20, 30, 30 );
3821 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
3822 SetRectRgn( hrgn
, 20, 20, 30, 30 );
3823 check_update_rgn( hparent
, hrgn
);
3824 RedrawWindow( hchild
, NULL
, 0, RDW_UPDATENOW
);
3825 ok_sequence( WmInvalidateErasePaint2
, "WmInvalidateErasePaint2", FALSE
);
3826 check_update_rgn( hparent
, 0 ); /* no update region */
3827 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
3828 ok_sequence( WmEmptySeq
, "WmEmpty", FALSE
); /* and no paint messages */
3830 /* make sure RDW_VALIDATE on child doesn't have the same effect */
3832 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
3833 SetRectRgn( hrgn
, 20, 20, 30, 30 );
3834 check_update_rgn( hparent
, hrgn
);
3835 RedrawWindow( hchild
, NULL
, 0, RDW_VALIDATE
| RDW_NOERASE
);
3836 SetRectRgn( hrgn
, 20, 20, 30, 30 );
3837 check_update_rgn( hparent
, hrgn
);
3839 /* same as above but normal WM_PAINT doesn't validate parent */
3841 SetRect( &rect
, 20, 20, 30, 30 );
3842 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
3843 SetRectRgn( hrgn
, 20, 20, 30, 30 );
3844 check_update_rgn( hparent
, hrgn
);
3845 /* no WM_PAINT in child while parent still pending */
3846 while (PeekMessage( &msg
, hchild
, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
3847 ok_sequence( WmEmptySeq
, "No WM_PAINT", FALSE
);
3848 while (PeekMessage( &msg
, hparent
, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
3849 ok_sequence( WmParentErasePaint
, "WmParentErasePaint", FALSE
);
3852 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
3853 /* no WM_PAINT in child while parent still pending */
3854 while (PeekMessage( &msg
, hchild
, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
3855 ok_sequence( WmEmptySeq
, "No WM_PAINT", FALSE
);
3856 RedrawWindow( hparent
, &rect
, 0, RDW_VALIDATE
| RDW_NOERASE
| RDW_NOCHILDREN
);
3857 /* now that parent is valid child should get WM_PAINT */
3858 while (PeekMessage( &msg
, hchild
, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
3859 ok_sequence( WmInvalidateErasePaint2
, "WmInvalidateErasePaint2", FALSE
);
3860 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
3861 ok_sequence( WmEmptySeq
, "No other message", FALSE
);
3863 /* same thing with WS_CLIPCHILDREN in parent */
3865 SetWindowLong( hparent
, GWL_STYLE
, GetWindowLong(hparent
,GWL_STYLE
) | WS_CLIPCHILDREN
);
3866 ok_sequence( WmSetParentStyle
, "WmSetParentStyle", FALSE
);
3867 /* changing style invalidates non client area, but we need to invalidate something else to see it */
3868 RedrawWindow( hparent
, &rect
, 0, RDW_UPDATENOW
);
3869 ok_sequence( WmEmptySeq
, "No message", FALSE
);
3870 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_UPDATENOW
);
3871 ok_sequence( WmParentOnlyNcPaint
, "WmParentOnlyNcPaint", FALSE
);
3874 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_ALLCHILDREN
);
3875 SetRectRgn( hrgn
, 20, 20, 30, 30 );
3876 check_update_rgn( hparent
, hrgn
);
3877 /* no WM_PAINT in child while parent still pending */
3878 while (PeekMessage( &msg
, hchild
, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
3879 ok_sequence( WmEmptySeq
, "No WM_PAINT", FALSE
);
3880 /* WM_PAINT in parent first */
3881 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
3882 ok_sequence( WmParentPaintNc
, "WmParentPaintNc2", FALSE
);
3884 /* no RDW_ERASE in parent still causes RDW_ERASE and RDW_FRAME in child */
3886 SetRect( &rect
, 0, 0, 30, 30 );
3887 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ALLCHILDREN
);
3888 SetRectRgn( hrgn
, 0, 0, 30, 30 );
3889 check_update_rgn( hparent
, hrgn
);
3890 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
3891 ok_sequence( WmParentPaintNc
, "WmParentPaintNc3", FALSE
);
3893 /* validate doesn't cause RDW_NOERASE or RDW_NOFRAME in child */
3895 SetRect( &rect
, -10, 0, 30, 30 );
3896 RedrawWindow( hchild
, &rect
, 0, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASE
);
3897 SetRect( &rect
, 0, 0, 20, 20 );
3898 RedrawWindow( hparent
, &rect
, 0, RDW_VALIDATE
| RDW_ALLCHILDREN
);
3899 RedrawWindow( hparent
, NULL
, 0, RDW_UPDATENOW
);
3900 ok_sequence( WmChildPaintNc
, "WmChildPaintNc", FALSE
);
3902 /* validate doesn't cause RDW_NOERASE or RDW_NOFRAME in child */
3904 SetRect( &rect
, -10, 0, 30, 30 );
3905 RedrawWindow( hchild
, &rect
, 0, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASE
);
3906 SetRect( &rect
, 0, 0, 100, 100 );
3907 RedrawWindow( hparent
, &rect
, 0, RDW_VALIDATE
| RDW_ALLCHILDREN
);
3908 RedrawWindow( hparent
, NULL
, 0, RDW_UPDATENOW
);
3909 ok_sequence( WmEmptySeq
, "WmChildPaintNc2", FALSE
);
3910 RedrawWindow( hparent
, NULL
, 0, RDW_ERASENOW
);
3911 ok_sequence( WmEmptySeq
, "WmChildPaintNc3", FALSE
);
3913 /* test RDW_INTERNALPAINT behavior */
3916 RedrawWindow( hparent
, NULL
, 0, RDW_INTERNALPAINT
| RDW_NOCHILDREN
);
3917 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
3918 ok_sequence( WmParentOnlyPaint
, "WmParentOnlyPaint", FALSE
);
3920 RedrawWindow( hparent
, NULL
, 0, RDW_INTERNALPAINT
| RDW_ALLCHILDREN
);
3921 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
3922 ok_sequence( WmParentPaint
, "WmParentPaint", FALSE
);
3924 RedrawWindow( hparent
, NULL
, 0, RDW_INTERNALPAINT
);
3925 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
3926 ok_sequence( WmParentOnlyPaint
, "WmParentOnlyPaint", FALSE
);
3928 SetWindowLong( hparent
, GWL_STYLE
, GetWindowLong(hparent
,GWL_STYLE
) & ~WS_CLIPCHILDREN
);
3929 ok_sequence( WmSetParentStyle
, "WmSetParentStyle", FALSE
);
3930 RedrawWindow( hparent
, NULL
, 0, RDW_INTERNALPAINT
);
3931 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
3932 ok_sequence( WmParentPaint
, "WmParentPaint", FALSE
);
3934 log_all_parent_messages
--;
3935 DestroyWindow( hparent
);
3936 ok(!IsWindow(hchild
), "child must be destroyed with its parent\n");
3938 DeleteObject( hrgn
);
3939 DeleteObject( hrgn2
);
3948 static DWORD WINAPI
thread_proc(void *param
)
3951 struct wnd_event
*wnd_event
= (struct wnd_event
*)param
;
3953 wnd_event
->hwnd
= CreateWindowExA(0, "TestWindowClass", "window caption text", WS_OVERLAPPEDWINDOW
,
3954 100, 100, 200, 200, 0, 0, 0, NULL
);
3955 ok(wnd_event
->hwnd
!= 0, "Failed to create overlapped window\n");
3957 SetEvent(wnd_event
->event
);
3959 while (GetMessage(&msg
, 0, 0, 0))
3961 TranslateMessage(&msg
);
3962 DispatchMessage(&msg
);
3965 ok(IsWindow(wnd_event
->hwnd
), "window should still exist\n");
3970 static void test_interthread_messages(void)
3977 int len
, expected_len
;
3978 struct wnd_event wnd_event
;
3981 wnd_event
.event
= CreateEventW(NULL
, 0, 0, NULL
);
3982 if (!wnd_event
.event
)
3984 trace("skipping interthread message test under win9x\n");
3988 hThread
= CreateThread(NULL
, 0, thread_proc
, &wnd_event
, 0, &tid
);
3989 ok(hThread
!= NULL
, "CreateThread failed, error %ld\n", GetLastError());
3991 ok(WaitForSingleObject(wnd_event
.event
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
3993 CloseHandle(wnd_event
.event
);
3995 SetLastError(0xdeadbeef);
3996 ok(!DestroyWindow(wnd_event
.hwnd
), "DestroyWindow succeded\n");
3997 ok(GetLastError() == ERROR_ACCESS_DENIED
, "wrong error code %ld\n", GetLastError());
3999 proc
= (WNDPROC
)GetWindowLongPtrA(wnd_event
.hwnd
, GWLP_WNDPROC
);
4000 ok(proc
!= NULL
, "GetWindowLongPtrA(GWLP_WNDPROC) error %ld\n", GetLastError());
4002 expected_len
= lstrlenA("window caption text");
4003 memset(buf
, 0, sizeof(buf
));
4004 SetLastError(0xdeadbeef);
4005 len
= CallWindowProcA(proc
, wnd_event
.hwnd
, WM_GETTEXT
, sizeof(buf
), (LPARAM
)buf
);
4006 ok(len
== expected_len
, "CallWindowProcA(WM_GETTEXT) error %ld, len %d, expected len %d\n", GetLastError(), len
, expected_len
);
4007 ok(!lstrcmpA(buf
, "window caption text"), "window text mismatch\n");
4009 msg
.hwnd
= wnd_event
.hwnd
;
4010 msg
.message
= WM_GETTEXT
;
4011 msg
.wParam
= sizeof(buf
);
4012 msg
.lParam
= (LPARAM
)buf
;
4013 memset(buf
, 0, sizeof(buf
));
4014 SetLastError(0xdeadbeef);
4015 len
= DispatchMessageA(&msg
);
4016 ok(!len
&& GetLastError() == ERROR_MESSAGE_SYNC_ONLY
,
4017 "DispatchMessageA(WM_GETTEXT) succeded on another thread window: ret %d, error %ld\n", len
, GetLastError());
4019 /* the following test causes an exception in user.exe under win9x */
4020 msg
.hwnd
= wnd_event
.hwnd
;
4021 msg
.message
= WM_TIMER
;
4023 msg
.lParam
= GetWindowLongPtrA(wnd_event
.hwnd
, GWLP_WNDPROC
);
4024 SetLastError(0xdeadbeef);
4025 len
= DispatchMessageA(&msg
);
4026 ok(!len
&& GetLastError() == 0xdeadbeef,
4027 "DispatchMessageA(WM_TIMER) failed on another thread window: ret %d, error %ld\n", len
, GetLastError());
4029 ret
= PostMessageA(wnd_event
.hwnd
, WM_QUIT
, 0, 0);
4030 ok( ret
, "PostMessageA(WM_QUIT) error %ld\n", GetLastError());
4032 ok(WaitForSingleObject(hThread
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
4033 CloseHandle(hThread
);
4035 ok(!IsWindow(wnd_event
.hwnd
), "window should be destroyed on thread exit\n");
4039 static const struct message WmVkN
[] = {
4040 { WM_KEYDOWN
, wparam
|lparam
, 'N', 1 },
4041 { WM_KEYDOWN
, sent
|wparam
|lparam
, 'N', 1 },
4042 { WM_CHAR
, wparam
|lparam
, 'n', 1 },
4043 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1002,1), 0 },
4044 { WM_KEYUP
, wparam
|lparam
, 'N', 0xc0000001 },
4045 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xc0000001 },
4048 static const struct message WmShiftVkN
[] = {
4049 { WM_KEYDOWN
, wparam
|lparam
, VK_SHIFT
, 1 },
4050 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_SHIFT
, 1 },
4051 { WM_KEYDOWN
, wparam
|lparam
, 'N', 1 },
4052 { WM_KEYDOWN
, sent
|wparam
|lparam
, 'N', 1 },
4053 { WM_CHAR
, wparam
|lparam
, 'N', 1 },
4054 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1001,1), 0 },
4055 { WM_KEYUP
, wparam
|lparam
, 'N', 0xc0000001 },
4056 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xc0000001 },
4057 { WM_KEYUP
, wparam
|lparam
, VK_SHIFT
, 0xc0000001 },
4058 { WM_KEYUP
, sent
|wparam
|lparam
, VK_SHIFT
, 0xc0000001 },
4061 static const struct message WmCtrlVkN
[] = {
4062 { WM_KEYDOWN
, wparam
|lparam
, VK_CONTROL
, 1 },
4063 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_CONTROL
, 1 },
4064 { WM_KEYDOWN
, wparam
|lparam
, 'N', 1 },
4065 { WM_KEYDOWN
, sent
|wparam
|lparam
, 'N', 1 },
4066 { WM_CHAR
, wparam
|lparam
, 0x000e, 1 },
4067 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1000,1), 0 },
4068 { WM_KEYUP
, wparam
|lparam
, 'N', 0xc0000001 },
4069 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xc0000001 },
4070 { WM_KEYUP
, wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
4071 { WM_KEYUP
, sent
|wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
4074 static const struct message WmCtrlVkN_2
[] = {
4075 { WM_KEYDOWN
, wparam
|lparam
, VK_CONTROL
, 1 },
4076 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_CONTROL
, 1 },
4077 { WM_KEYDOWN
, wparam
|lparam
, 'N', 1 },
4078 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1000,1), 0 },
4079 { WM_KEYUP
, wparam
|lparam
, 'N', 0xc0000001 },
4080 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xc0000001 },
4081 { WM_KEYUP
, wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
4082 { WM_KEYUP
, sent
|wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
4085 static const struct message WmAltVkN
[] = {
4086 { WM_SYSKEYDOWN
, wparam
|lparam
, VK_MENU
, 0x20000001 },
4087 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
4088 { WM_SYSKEYDOWN
, wparam
|lparam
, 'N', 0x20000001 },
4089 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, 'N', 0x20000001 },
4090 { WM_SYSCHAR
, wparam
|lparam
, 'n', 0x20000001 },
4091 { WM_SYSCHAR
, sent
|wparam
|lparam
, 'n', 0x20000001 },
4092 { WM_SYSCOMMAND
, sent
|defwinproc
|wparam
|lparam
, SC_KEYMENU
, 'n' },
4093 { HCBT_SYSCOMMAND
, hook
},
4094 { WM_ENTERMENULOOP
, sent
|defwinproc
|wparam
|lparam
, 0, 0 },
4095 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
4096 { WM_INITMENU
, sent
|defwinproc
},
4097 { EVENT_SYSTEM_MENUSTART
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 0 },
4098 { WM_MENUCHAR
, sent
|defwinproc
|wparam
, MAKEWPARAM('n',MF_SYSMENU
) },
4099 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, 0, 0 },
4100 { WM_CAPTURECHANGED
, sent
|defwinproc
},
4101 { WM_MENUSELECT
, sent
|defwinproc
|wparam
, MAKEWPARAM(0,0xffff) },
4102 { EVENT_SYSTEM_MENUEND
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 0 },
4103 { WM_EXITMENULOOP
, sent
|defwinproc
},
4104 { WM_MENUSELECT
, sent
|defwinproc
|wparam
|optional
, MAKEWPARAM(0,0xffff) }, /* Win95 bug */
4105 { WM_EXITMENULOOP
, sent
|defwinproc
|optional
}, /* Win95 bug */
4106 { WM_SYSKEYUP
, wparam
|lparam
, 'N', 0xe0000001 },
4107 { WM_SYSKEYUP
, sent
|wparam
|lparam
, 'N', 0xe0000001 },
4108 { WM_KEYUP
, wparam
|lparam
, VK_MENU
, 0xc0000001 },
4109 { WM_KEYUP
, sent
|wparam
|lparam
, VK_MENU
, 0xc0000001 },
4112 static const struct message WmAltVkN_2
[] = {
4113 { WM_SYSKEYDOWN
, wparam
|lparam
, VK_MENU
, 0x20000001 },
4114 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
4115 { WM_SYSKEYDOWN
, wparam
|lparam
, 'N', 0x20000001 },
4116 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1003,1), 0 },
4117 { WM_SYSKEYUP
, wparam
|lparam
, 'N', 0xe0000001 },
4118 { WM_SYSKEYUP
, sent
|wparam
|lparam
, 'N', 0xe0000001 },
4119 { WM_KEYUP
, wparam
|lparam
, VK_MENU
, 0xc0000001 },
4120 { WM_KEYUP
, sent
|wparam
|lparam
, VK_MENU
, 0xc0000001 },
4123 static const struct message WmCtrlAltVkN
[] = {
4124 { WM_KEYDOWN
, wparam
|lparam
, VK_CONTROL
, 1 },
4125 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_CONTROL
, 1 },
4126 { WM_KEYDOWN
, wparam
|lparam
, VK_MENU
, 0x20000001 },
4127 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
4128 { WM_KEYDOWN
, wparam
|lparam
, 'N', 0x20000001 },
4129 { WM_KEYDOWN
, sent
|wparam
|lparam
, 'N', 0x20000001 },
4130 { WM_KEYUP
, wparam
|lparam
, 'N', 0xe0000001 },
4131 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xe0000001 },
4132 { WM_KEYUP
, wparam
|lparam
, VK_MENU
, 0xc0000001 },
4133 { WM_KEYUP
, sent
|wparam
|lparam
, VK_MENU
, 0xc0000001 },
4134 { WM_KEYUP
, wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
4135 { WM_KEYUP
, sent
|wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
4138 static const struct message WmCtrlShiftVkN
[] = {
4139 { WM_KEYDOWN
, wparam
|lparam
, VK_CONTROL
, 1 },
4140 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_CONTROL
, 1 },
4141 { WM_KEYDOWN
, wparam
|lparam
, VK_SHIFT
, 1 },
4142 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_SHIFT
, 1 },
4143 { WM_KEYDOWN
, wparam
|lparam
, 'N', 1 },
4144 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1004,1), 0 },
4145 { WM_KEYUP
, wparam
|lparam
, 'N', 0xc0000001 },
4146 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xc0000001 },
4147 { WM_KEYUP
, wparam
|lparam
, VK_SHIFT
, 0xc0000001 },
4148 { WM_KEYUP
, sent
|wparam
|lparam
, VK_SHIFT
, 0xc0000001 },
4149 { WM_KEYUP
, wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
4150 { WM_KEYUP
, sent
|wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
4153 static const struct message WmCtrlAltShiftVkN
[] = {
4154 { WM_KEYDOWN
, wparam
|lparam
, VK_CONTROL
, 1 },
4155 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_CONTROL
, 1 },
4156 { WM_KEYDOWN
, wparam
|lparam
, VK_MENU
, 0x20000001 },
4157 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
4158 { WM_KEYDOWN
, wparam
|lparam
, VK_SHIFT
, 0x20000001 },
4159 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_SHIFT
, 0x20000001 },
4160 { WM_KEYDOWN
, wparam
|lparam
, 'N', 0x20000001 },
4161 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1005,1), 0 },
4162 { WM_KEYUP
, wparam
|lparam
, 'N', 0xe0000001 },
4163 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xe0000001 },
4164 { WM_KEYUP
, wparam
|lparam
, VK_SHIFT
, 0xe0000001 },
4165 { WM_KEYUP
, sent
|wparam
|lparam
, VK_SHIFT
, 0xe0000001 },
4166 { WM_KEYUP
, wparam
|lparam
, VK_MENU
, 0xc0000001 },
4167 { WM_KEYUP
, sent
|wparam
|lparam
, VK_MENU
, 0xc0000001 },
4168 { WM_KEYUP
, wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
4169 { WM_KEYUP
, sent
|wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
4172 static const struct message WmAltPressRelease
[] = {
4173 { WM_SYSKEYDOWN
, wparam
|lparam
, VK_MENU
, 0x20000001 },
4174 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
4175 { WM_SYSKEYUP
, wparam
|lparam
, VK_MENU
, 0xc0000001 },
4176 { WM_SYSKEYUP
, sent
|wparam
|lparam
, VK_MENU
, 0xc0000001 },
4177 { WM_SYSCOMMAND
, sent
|defwinproc
|wparam
|lparam
, SC_KEYMENU
, 0 },
4178 { HCBT_SYSCOMMAND
, hook
},
4179 { WM_ENTERMENULOOP
, sent
|defwinproc
|wparam
|lparam
, 0, 0 },
4180 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
4181 { WM_INITMENU
, sent
|defwinproc
},
4182 { EVENT_SYSTEM_MENUSTART
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 0 },
4183 { WM_MENUSELECT
, sent
|defwinproc
|wparam
, MAKEWPARAM(0,MF_SYSMENU
|MF_POPUP
|MF_HILITE
) },
4184 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 1 },
4186 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 0 },
4187 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, 0, 0, },
4188 { WM_CAPTURECHANGED
, sent
|defwinproc
},
4189 { WM_MENUSELECT
, sent
|defwinproc
|wparam
|optional
, MAKEWPARAM(0,0xffff) },
4190 { EVENT_SYSTEM_MENUEND
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 0 },
4191 { WM_EXITMENULOOP
, sent
|defwinproc
},
4192 { WM_SYSKEYUP
, wparam
|lparam
, VK_MENU
, 0xc0000001 },
4193 { WM_SYSKEYUP
, sent
|wparam
|lparam
, VK_MENU
, 0xc0000001 },
4196 static const struct message WmAltMouseButton
[] = {
4197 { WM_SYSKEYDOWN
, wparam
|lparam
, VK_MENU
, 0x20000001 },
4198 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
4199 { WM_MOUSEMOVE
, wparam
|optional
, 0, 0 },
4200 { WM_MOUSEMOVE
, sent
|wparam
|optional
, 0, 0 },
4201 { WM_LBUTTONDOWN
, wparam
, MK_LBUTTON
, 0 },
4202 { WM_LBUTTONDOWN
, sent
|wparam
, MK_LBUTTON
, 0 },
4203 { WM_LBUTTONUP
, wparam
, 0, 0 },
4204 { WM_LBUTTONUP
, sent
|wparam
, 0, 0 },
4205 { WM_SYSKEYUP
, wparam
|lparam
, VK_MENU
, 0xc0000001 },
4206 { WM_SYSKEYUP
, sent
|wparam
|lparam
, VK_MENU
, 0xc0000001 },
4210 static void pump_msg_loop(HWND hwnd
, HACCEL hAccel
)
4214 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
))
4216 struct message log_msg
;
4218 trace("accel: %p, %04x, %08x, %08lx\n", msg
.hwnd
, msg
.message
, msg
.wParam
, msg
.lParam
);
4220 /* ignore some unwanted messages */
4221 if (msg
.message
== WM_MOUSEMOVE
||
4222 msg
.message
== WM_DEVICECHANGE
)
4225 log_msg
.message
= msg
.message
;
4226 log_msg
.flags
= wparam
|lparam
;
4227 log_msg
.wParam
= msg
.wParam
;
4228 log_msg
.lParam
= msg
.lParam
;
4229 add_message(&log_msg
);
4231 if (!hAccel
|| !TranslateAccelerator(hwnd
, hAccel
, &msg
))
4233 TranslateMessage(&msg
);
4234 DispatchMessage(&msg
);
4239 static void test_accelerators(void)
4244 HWND hwnd
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
4245 100, 100, 200, 200, 0, 0, 0, NULL
);
4251 ok(GetFocus() == hwnd
, "wrong focus window %p\n", GetFocus());
4253 state
= GetKeyState(VK_SHIFT
);
4254 ok(!(state
& 0x8000), "wrong Shift state %04x\n", state
);
4255 state
= GetKeyState(VK_CAPITAL
);
4256 ok(state
== 0, "wrong CapsLock state %04x\n", state
);
4258 hAccel
= LoadAccelerators(GetModuleHandleA(0), MAKEINTRESOURCE(1));
4259 assert(hAccel
!= 0);
4261 pump_msg_loop(hwnd
, 0);
4264 trace("testing VK_N press/release\n");
4266 keybd_event('N', 0, 0, 0);
4267 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
4268 pump_msg_loop(hwnd
, hAccel
);
4269 ok_sequence(WmVkN
, "VK_N press/release", FALSE
);
4271 trace("testing Shift+VK_N press/release\n");
4273 keybd_event(VK_SHIFT
, 0, 0, 0);
4274 keybd_event('N', 0, 0, 0);
4275 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
4276 keybd_event(VK_SHIFT
, 0, KEYEVENTF_KEYUP
, 0);
4277 pump_msg_loop(hwnd
, hAccel
);
4278 ok_sequence(WmShiftVkN
, "Shift+VK_N press/release", FALSE
);
4280 trace("testing Ctrl+VK_N press/release\n");
4282 keybd_event(VK_CONTROL
, 0, 0, 0);
4283 keybd_event('N', 0, 0, 0);
4284 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
4285 keybd_event(VK_CONTROL
, 0, KEYEVENTF_KEYUP
, 0);
4286 pump_msg_loop(hwnd
, hAccel
);
4287 ok_sequence(WmCtrlVkN
, "Ctrl+VK_N press/release", FALSE
);
4289 trace("testing Alt+VK_N press/release\n");
4291 keybd_event(VK_MENU
, 0, 0, 0);
4292 keybd_event('N', 0, 0, 0);
4293 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
4294 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
4295 pump_msg_loop(hwnd
, hAccel
);
4296 ok_sequence(WmAltVkN
, "Alt+VK_N press/release", FALSE
);
4298 trace("testing Ctrl+Alt+VK_N press/release 1\n");
4300 keybd_event(VK_CONTROL
, 0, 0, 0);
4301 keybd_event(VK_MENU
, 0, 0, 0);
4302 keybd_event('N', 0, 0, 0);
4303 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
4304 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
4305 keybd_event(VK_CONTROL
, 0, KEYEVENTF_KEYUP
, 0);
4306 pump_msg_loop(hwnd
, hAccel
);
4307 ok_sequence(WmCtrlAltVkN
, "Ctrl+Alt+VK_N press/release 1", FALSE
);
4309 ret
= DestroyAcceleratorTable(hAccel
);
4310 ok( ret
, "DestroyAcceleratorTable error %ld\n", GetLastError());
4312 hAccel
= LoadAccelerators(GetModuleHandleA(0), MAKEINTRESOURCE(2));
4313 assert(hAccel
!= 0);
4315 trace("testing VK_N press/release\n");
4317 keybd_event('N', 0, 0, 0);
4318 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
4319 pump_msg_loop(hwnd
, hAccel
);
4320 ok_sequence(WmVkN
, "VK_N press/release", FALSE
);
4322 trace("testing Shift+VK_N press/release\n");
4324 keybd_event(VK_SHIFT
, 0, 0, 0);
4325 keybd_event('N', 0, 0, 0);
4326 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
4327 keybd_event(VK_SHIFT
, 0, KEYEVENTF_KEYUP
, 0);
4328 pump_msg_loop(hwnd
, hAccel
);
4329 ok_sequence(WmShiftVkN
, "Shift+VK_N press/release", FALSE
);
4331 trace("testing Ctrl+VK_N press/release 2\n");
4333 keybd_event(VK_CONTROL
, 0, 0, 0);
4334 keybd_event('N', 0, 0, 0);
4335 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
4336 keybd_event(VK_CONTROL
, 0, KEYEVENTF_KEYUP
, 0);
4337 pump_msg_loop(hwnd
, hAccel
);
4338 ok_sequence(WmCtrlVkN_2
, "Ctrl+VK_N press/release 2", FALSE
);
4340 trace("testing Alt+VK_N press/release 2\n");
4342 keybd_event(VK_MENU
, 0, 0, 0);
4343 keybd_event('N', 0, 0, 0);
4344 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
4345 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
4346 pump_msg_loop(hwnd
, hAccel
);
4347 ok_sequence(WmAltVkN_2
, "Alt+VK_N press/release 2", FALSE
);
4349 trace("testing Ctrl+Alt+VK_N press/release 2\n");
4351 keybd_event(VK_CONTROL
, 0, 0, 0);
4352 keybd_event(VK_MENU
, 0, 0, 0);
4353 keybd_event('N', 0, 0, 0);
4354 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
4355 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
4356 keybd_event(VK_CONTROL
, 0, KEYEVENTF_KEYUP
, 0);
4357 pump_msg_loop(hwnd
, hAccel
);
4358 ok_sequence(WmCtrlAltVkN
, "Ctrl+Alt+VK_N press/release 2", FALSE
);
4360 trace("testing Ctrl+Shift+VK_N press/release\n");
4362 keybd_event(VK_CONTROL
, 0, 0, 0);
4363 keybd_event(VK_SHIFT
, 0, 0, 0);
4364 keybd_event('N', 0, 0, 0);
4365 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
4366 keybd_event(VK_SHIFT
, 0, KEYEVENTF_KEYUP
, 0);
4367 keybd_event(VK_CONTROL
, 0, KEYEVENTF_KEYUP
, 0);
4368 pump_msg_loop(hwnd
, hAccel
);
4369 ok_sequence(WmCtrlShiftVkN
, "Ctrl+Shift+VK_N press/release", FALSE
);
4371 trace("testing Ctrl+Alt+Shift+VK_N press/release\n");
4373 keybd_event(VK_CONTROL
, 0, 0, 0);
4374 keybd_event(VK_MENU
, 0, 0, 0);
4375 keybd_event(VK_SHIFT
, 0, 0, 0);
4376 keybd_event('N', 0, 0, 0);
4377 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
4378 keybd_event(VK_SHIFT
, 0, KEYEVENTF_KEYUP
, 0);
4379 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
4380 keybd_event(VK_CONTROL
, 0, KEYEVENTF_KEYUP
, 0);
4381 pump_msg_loop(hwnd
, hAccel
);
4382 ok_sequence(WmCtrlAltShiftVkN
, "Ctrl+Alt+Shift+VK_N press/release", FALSE
);
4384 ret
= DestroyAcceleratorTable(hAccel
);
4385 ok( ret
, "DestroyAcceleratorTable error %ld\n", GetLastError());
4387 trace("testing Alt press/release\n");
4389 keybd_event(VK_MENU
, 0, 0, 0);
4390 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
4391 keybd_event(VK_MENU
, 0, 0, 0);
4392 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
4393 pump_msg_loop(hwnd
, 0);
4394 /* this test doesn't pass in Wine for managed windows */
4395 ok_sequence(WmAltPressRelease
, "Alt press/release", TRUE
);
4397 trace("testing Alt+MouseButton press/release\n");
4398 /* first, move mouse pointer inside of the window client area */
4399 GetClientRect(hwnd
, &rc
);
4400 MapWindowPoints(hwnd
, 0, (LPPOINT
)&rc
, 2);
4401 rc
.left
+= (rc
.right
- rc
.left
)/2;
4402 rc
.top
+= (rc
.bottom
- rc
.top
)/2;
4403 SetCursorPos(rc
.left
, rc
.top
);
4405 pump_msg_loop(hwnd
, 0);
4407 keybd_event(VK_MENU
, 0, 0, 0);
4408 mouse_event(MOUSEEVENTF_LEFTDOWN
, 0, 0, 0, 0);
4409 mouse_event(MOUSEEVENTF_LEFTUP
, 0, 0, 0, 0);
4410 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
4411 pump_msg_loop(hwnd
, 0);
4412 ok_sequence(WmAltMouseButton
, "Alt+MouseButton press/release", FALSE
);
4414 DestroyWindow(hwnd
);
4417 /************* window procedures ********************/
4419 static LRESULT WINAPI
MsgCheckProcA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
4421 static long defwndproc_counter
= 0;
4422 static long beginpaint_counter
= 0;
4426 trace("%p, %04x, %08x, %08lx\n", hwnd
, message
, wParam
, lParam
);
4430 case WM_CAPTURECHANGED
:
4431 if (test_DestroyWindow_flag
)
4433 DWORD style
= GetWindowLongA(hwnd
, GWL_STYLE
);
4434 if (style
& WS_CHILD
)
4435 lParam
= GetWindowLongA(hwnd
, GWL_ID
);
4436 else if (style
& WS_POPUP
)
4437 lParam
= WND_POPUP_ID
;
4439 lParam
= WND_PARENT_ID
;
4447 ok(!GetWindow(hwnd
, GW_CHILD
), "children should be unlinked at this point\n");
4448 capture
= GetCapture();
4451 ok(capture
== hwnd
, "capture should NOT be released at this point (capture %p)\n", capture
);
4452 trace("current capture %p, releasing...\n", capture
);
4459 ok(pGetAncestor(hwnd
, GA_PARENT
) != 0, "parent should NOT be unlinked at this point\n");
4460 if (test_DestroyWindow_flag
)
4462 DWORD style
= GetWindowLongA(hwnd
, GWL_STYLE
);
4463 if (style
& WS_CHILD
)
4464 lParam
= GetWindowLongA(hwnd
, GWL_ID
);
4465 else if (style
& WS_POPUP
)
4466 lParam
= WND_POPUP_ID
;
4468 lParam
= WND_PARENT_ID
;
4472 /* test_accelerators() depends on this */
4479 case WM_DEVICECHANGE
:
4482 case WM_WINDOWPOSCHANGING
:
4483 case WM_WINDOWPOSCHANGED
:
4485 WINDOWPOS
*winpos
= (WINDOWPOS
*)lParam
;
4487 trace("%s\n", (message
== WM_WINDOWPOSCHANGING
) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
4488 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
4489 winpos
->hwnd
, winpos
->hwndInsertAfter
,
4490 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
4492 /* Log only documented flags, win2k uses 0x1000 and 0x2000
4493 * in the high word for internal purposes
4495 wParam
= winpos
->flags
& 0xffff;
4500 msg
.message
= message
;
4501 msg
.flags
= sent
|wparam
|lparam
;
4502 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
4503 if (beginpaint_counter
) msg
.flags
|= beginpaint
;
4504 msg
.wParam
= wParam
;
4505 msg
.lParam
= lParam
;
4508 if (message
== WM_GETMINMAXINFO
&& (GetWindowLongA(hwnd
, GWL_STYLE
) & WS_CHILD
))
4510 HWND parent
= GetParent(hwnd
);
4512 MINMAXINFO
*minmax
= (MINMAXINFO
*)lParam
;
4514 GetClientRect(parent
, &rc
);
4515 trace("parent %p client size = (%ld x %ld)\n", parent
, rc
.right
, rc
.bottom
);
4517 trace("ptReserved = (%ld,%ld)\n"
4518 "ptMaxSize = (%ld,%ld)\n"
4519 "ptMaxPosition = (%ld,%ld)\n"
4520 "ptMinTrackSize = (%ld,%ld)\n"
4521 "ptMaxTrackSize = (%ld,%ld)\n",
4522 minmax
->ptReserved
.x
, minmax
->ptReserved
.y
,
4523 minmax
->ptMaxSize
.x
, minmax
->ptMaxSize
.y
,
4524 minmax
->ptMaxPosition
.x
, minmax
->ptMaxPosition
.y
,
4525 minmax
->ptMinTrackSize
.x
, minmax
->ptMinTrackSize
.y
,
4526 minmax
->ptMaxTrackSize
.x
, minmax
->ptMaxTrackSize
.y
);
4528 ok(minmax
->ptMaxSize
.x
== rc
.right
, "default width of maximized child %ld != %ld\n",
4529 minmax
->ptMaxSize
.x
, rc
.right
);
4530 ok(minmax
->ptMaxSize
.y
== rc
.bottom
, "default height of maximized child %ld != %ld\n",
4531 minmax
->ptMaxSize
.y
, rc
.bottom
);
4534 if (message
== WM_PAINT
)
4537 beginpaint_counter
++;
4538 BeginPaint( hwnd
, &ps
);
4539 beginpaint_counter
--;
4540 EndPaint( hwnd
, &ps
);
4544 defwndproc_counter
++;
4545 ret
= DefWindowProcA(hwnd
, message
, wParam
, lParam
);
4546 defwndproc_counter
--;
4551 static LRESULT WINAPI
PopupMsgCheckProcA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
4553 static long defwndproc_counter
= 0;
4557 trace("popup: %p, %04x, %08x, %08lx\n", hwnd
, message
, wParam
, lParam
);
4559 msg
.message
= message
;
4560 msg
.flags
= sent
|wparam
|lparam
;
4561 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
4562 msg
.wParam
= wParam
;
4563 msg
.lParam
= lParam
;
4566 if (message
== WM_CREATE
)
4568 DWORD style
= GetWindowLongA(hwnd
, GWL_STYLE
) | WS_VISIBLE
;
4569 SetWindowLongA(hwnd
, GWL_STYLE
, style
);
4572 defwndproc_counter
++;
4573 ret
= DefWindowProcA(hwnd
, message
, wParam
, lParam
);
4574 defwndproc_counter
--;
4579 static LRESULT WINAPI
ParentMsgCheckProcA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
4581 static long defwndproc_counter
= 0;
4582 static long beginpaint_counter
= 0;
4586 trace("parent: %p, %04x, %08x, %08lx\n", hwnd
, message
, wParam
, lParam
);
4588 if (log_all_parent_messages
||
4589 message
== WM_PARENTNOTIFY
|| message
== WM_CANCELMODE
||
4590 message
== WM_SETFOCUS
|| message
== WM_KILLFOCUS
||
4591 message
== WM_ENABLE
|| message
== WM_ENTERIDLE
||
4592 message
== WM_IME_SETCONTEXT
)
4594 msg
.message
= message
;
4595 msg
.flags
= sent
|parent
|wparam
|lparam
;
4596 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
4597 if (beginpaint_counter
) msg
.flags
|= beginpaint
;
4598 msg
.wParam
= wParam
;
4599 msg
.lParam
= lParam
;
4603 if (message
== WM_PAINT
)
4606 beginpaint_counter
++;
4607 BeginPaint( hwnd
, &ps
);
4608 beginpaint_counter
--;
4609 EndPaint( hwnd
, &ps
);
4613 defwndproc_counter
++;
4614 ret
= DefWindowProcA(hwnd
, message
, wParam
, lParam
);
4615 defwndproc_counter
--;
4620 static LRESULT WINAPI
TestDlgProcA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
4622 static long defwndproc_counter
= 0;
4626 trace("dialog: %p, %04x, %08x, %08lx\n", hwnd
, message
, wParam
, lParam
);
4628 DefDlgProcA(hwnd
, DM_SETDEFID
, 1, 0);
4629 ret
= DefDlgProcA(hwnd
, DM_GETDEFID
, 0, 0);
4630 if (after_end_dialog
)
4631 ok( ret
== 0, "DM_GETDEFID should return 0 after EndDialog, got %lx\n", ret
);
4633 ok(HIWORD(ret
) == DC_HASDEFID
, "DM_GETDEFID should return DC_HASDEFID, got %lx\n", ret
);
4637 case WM_WINDOWPOSCHANGING
:
4638 case WM_WINDOWPOSCHANGED
:
4640 WINDOWPOS
*winpos
= (WINDOWPOS
*)lParam
;
4642 trace("%s\n", (message
== WM_WINDOWPOSCHANGING
) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
4643 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
4644 winpos
->hwnd
, winpos
->hwndInsertAfter
,
4645 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
4647 /* Log only documented flags, win2k uses 0x1000 and 0x2000
4648 * in the high word for internal purposes
4650 wParam
= winpos
->flags
& 0xffff;
4655 msg
.message
= message
;
4656 msg
.flags
= sent
|wparam
|lparam
;
4657 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
4658 msg
.wParam
= wParam
;
4659 msg
.lParam
= lParam
;
4662 defwndproc_counter
++;
4663 ret
= DefDlgProcA(hwnd
, message
, wParam
, lParam
);
4664 defwndproc_counter
--;
4669 static BOOL
RegisterWindowClasses(void)
4674 cls
.lpfnWndProc
= MsgCheckProcA
;
4677 cls
.hInstance
= GetModuleHandleA(0);
4679 cls
.hCursor
= LoadCursorA(0, (LPSTR
)IDC_ARROW
);
4680 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
4681 cls
.lpszMenuName
= NULL
;
4682 cls
.lpszClassName
= "TestWindowClass";
4683 if(!RegisterClassA(&cls
)) return FALSE
;
4685 cls
.lpfnWndProc
= PopupMsgCheckProcA
;
4686 cls
.lpszClassName
= "TestPopupClass";
4687 if(!RegisterClassA(&cls
)) return FALSE
;
4689 cls
.lpfnWndProc
= ParentMsgCheckProcA
;
4690 cls
.lpszClassName
= "TestParentClass";
4691 if(!RegisterClassA(&cls
)) return FALSE
;
4693 cls
.lpfnWndProc
= DefWindowProcA
;
4694 cls
.lpszClassName
= "SimpleWindowClass";
4695 if(!RegisterClassA(&cls
)) return FALSE
;
4697 cls
.style
= CS_NOCLOSE
;
4698 cls
.lpszClassName
= "NoCloseWindowClass";
4699 if(!RegisterClassA(&cls
)) return FALSE
;
4701 ok(GetClassInfoA(0, "#32770", &cls
), "GetClassInfo failed\n");
4703 cls
.hInstance
= GetModuleHandleA(0);
4704 cls
.hbrBackground
= 0;
4705 cls
.lpfnWndProc
= TestDlgProcA
;
4706 cls
.lpszClassName
= "TestDialogClass";
4707 if(!RegisterClassA(&cls
)) return FALSE
;
4712 static HHOOK hCBT_hook
;
4713 static DWORD cbt_hook_thread_id
;
4715 static LRESULT CALLBACK
cbt_hook_proc(int nCode
, WPARAM wParam
, LPARAM lParam
)
4717 static const char *CBT_code_name
[10] = {
4724 "HCBT_CLICKSKIPPED",
4728 const char *code_name
= (nCode
>= 0 && nCode
<= HCBT_SETFOCUS
) ? CBT_code_name
[nCode
] : "Unknown";
4732 trace("CBT: %d (%s), %08x, %08lx\n", nCode
, code_name
, wParam
, lParam
);
4734 ok(cbt_hook_thread_id
== GetCurrentThreadId(), "we didn't ask for events from other threads\n");
4736 if (nCode
== HCBT_SYSCOMMAND
)
4740 msg
.message
= nCode
;
4741 msg
.flags
= hook
|wparam
|lparam
;
4742 msg
.wParam
= wParam
;
4743 msg
.lParam
= lParam
;
4746 return CallNextHookEx(hCBT_hook
, nCode
, wParam
, lParam
);
4749 if (nCode
== HCBT_DESTROYWND
)
4751 if (test_DestroyWindow_flag
)
4753 DWORD style
= GetWindowLongA((HWND
)wParam
, GWL_STYLE
);
4754 if (style
& WS_CHILD
)
4755 lParam
= GetWindowLongA((HWND
)wParam
, GWL_ID
);
4756 else if (style
& WS_POPUP
)
4757 lParam
= WND_POPUP_ID
;
4759 lParam
= WND_PARENT_ID
;
4763 /* Log also SetFocus(0) calls */
4764 hwnd
= wParam
? (HWND
)wParam
: (HWND
)lParam
;
4766 if (GetClassNameA(hwnd
, buf
, sizeof(buf
)))
4768 if (!lstrcmpiA(buf
, "TestWindowClass") ||
4769 !lstrcmpiA(buf
, "TestParentClass") ||
4770 !lstrcmpiA(buf
, "TestPopupClass") ||
4771 !lstrcmpiA(buf
, "SimpleWindowClass") ||
4772 !lstrcmpiA(buf
, "TestDialogClass") ||
4773 !lstrcmpiA(buf
, "MDI_frame_class") ||
4774 !lstrcmpiA(buf
, "MDI_client_class") ||
4775 !lstrcmpiA(buf
, "MDI_child_class") ||
4776 !lstrcmpiA(buf
, "my_button_class") ||
4777 !lstrcmpiA(buf
, "static") ||
4778 !lstrcmpiA(buf
, "#32770"))
4782 msg
.message
= nCode
;
4783 msg
.flags
= hook
|wparam
|lparam
;
4784 msg
.wParam
= wParam
;
4785 msg
.lParam
= lParam
;
4789 return CallNextHookEx(hCBT_hook
, nCode
, wParam
, lParam
);
4792 static void CALLBACK
win_event_proc(HWINEVENTHOOK hevent
,
4802 trace("WEH:%p,event %08lx,hwnd %p,obj %08lx,id %08lx,thread %08lx,time %08lx\n",
4803 hevent
, event
, hwnd
, object_id
, child_id
, thread_id
, event_time
);
4805 ok(thread_id
== GetCurrentThreadId(), "we didn't ask for events from other threads\n");
4807 /* ignore mouse cursor events */
4808 if (object_id
== OBJID_CURSOR
) return;
4810 if (!hwnd
|| GetClassNameA(hwnd
, buf
, sizeof(buf
)))
4813 !lstrcmpiA(buf
, "TestWindowClass") ||
4814 !lstrcmpiA(buf
, "TestParentClass") ||
4815 !lstrcmpiA(buf
, "TestPopupClass") ||
4816 !lstrcmpiA(buf
, "SimpleWindowClass") ||
4817 !lstrcmpiA(buf
, "TestDialogClass") ||
4818 !lstrcmpiA(buf
, "MDI_frame_class") ||
4819 !lstrcmpiA(buf
, "MDI_client_class") ||
4820 !lstrcmpiA(buf
, "MDI_child_class") ||
4821 !lstrcmpiA(buf
, "my_button_class") ||
4822 !lstrcmpiA(buf
, "static") ||
4823 !lstrcmpiA(buf
, "#32770"))
4827 msg
.message
= event
;
4828 msg
.flags
= winevent_hook
|wparam
|lparam
;
4829 msg
.wParam
= object_id
;
4830 msg
.lParam
= child_id
;
4836 static const WCHAR wszUnicode
[] = {'U','n','i','c','o','d','e',0};
4837 static const WCHAR wszAnsi
[] = {'U',0};
4839 static LRESULT CALLBACK
MsgConversionProcW(HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
4843 case CB_FINDSTRINGEXACT
:
4844 trace("String: %p\n", (LPCWSTR
)lParam
);
4845 if (!lstrcmpW((LPCWSTR
)lParam
, wszUnicode
))
4847 if (!lstrcmpW((LPCWSTR
)lParam
, wszAnsi
))
4851 return DefWindowProcW(hwnd
, uMsg
, wParam
, lParam
);
4854 static void test_message_conversion(void)
4856 static const WCHAR wszMsgConversionClass
[] =
4857 {'M','s','g','C','o','n','v','e','r','s','i','o','n','C','l','a','s','s',0};
4864 cls
.lpfnWndProc
= MsgConversionProcW
;
4867 cls
.hInstance
= GetModuleHandleW(NULL
);
4869 cls
.hCursor
= LoadCursorW(NULL
, (LPWSTR
)IDC_ARROW
);
4870 cls
.hbrBackground
= (HBRUSH
)(COLOR_BTNFACE
+1);
4871 cls
.lpszMenuName
= NULL
;
4872 cls
.lpszClassName
= wszMsgConversionClass
;
4873 /* this call will fail on Win9x, but that doesn't matter as this test is
4874 * meaningless on those platforms */
4875 if(!RegisterClassW(&cls
)) return;
4877 hwnd
= CreateWindowExW(0, wszMsgConversionClass
, NULL
, WS_OVERLAPPED
,
4878 100, 100, 200, 200, 0, 0, 0, NULL
);
4879 ok(hwnd
!= NULL
, "Window creation failed\n");
4883 wndproc
= (WNDPROC
)GetWindowLongPtrA(hwnd
, GWLP_WNDPROC
);
4884 lRes
= CallWindowProcA(wndproc
, hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
4885 ok(lRes
== 0, "String should have been converted\n");
4886 lRes
= CallWindowProcW(wndproc
, hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
4887 ok(lRes
== 1, "String shouldn't have been converted\n");
4891 wndproc
= (WNDPROC
)GetWindowLongPtrW(hwnd
, GWLP_WNDPROC
);
4892 lRes
= CallWindowProcA(wndproc
, hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
4893 ok(lRes
== 1, "String shouldn't have been converted\n");
4894 lRes
= CallWindowProcW(wndproc
, hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
4895 ok(lRes
== 1, "String shouldn't have been converted\n");
4897 /* Synchronous messages */
4899 lRes
= SendMessageA(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
4900 ok(lRes
== 0, "String should have been converted\n");
4901 lRes
= SendMessageW(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
4902 ok(lRes
== 1, "String shouldn't have been converted\n");
4904 /* Asynchronous messages */
4907 lRes
= PostMessageA(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
4908 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
4909 "PostMessage on sync only message returned %ld, last error %ld\n", lRes
, GetLastError());
4911 lRes
= PostMessageW(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
4912 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
4913 "PostMessage on sync only message returned %ld, last error %ld\n", lRes
, GetLastError());
4915 lRes
= PostThreadMessageA(GetCurrentThreadId(), CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
4916 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
4917 "PosThreadtMessage on sync only message returned %ld, last error %ld\n", lRes
, GetLastError());
4919 lRes
= PostThreadMessageW(GetCurrentThreadId(), CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
4920 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
4921 "PosThreadtMessage on sync only message returned %ld, last error %ld\n", lRes
, GetLastError());
4923 lRes
= SendNotifyMessageA(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
4924 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
4925 "SendNotifyMessage on sync only message returned %ld, last error %ld\n", lRes
, GetLastError());
4927 lRes
= SendNotifyMessageW(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
4928 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
4929 "SendNotifyMessage on sync only message returned %ld, last error %ld\n", lRes
, GetLastError());
4931 lRes
= SendMessageCallbackA(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
, NULL
, 0);
4932 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
4933 "SendMessageCallback on sync only message returned %ld, last error %ld\n", lRes
, GetLastError());
4935 lRes
= SendMessageCallbackW(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
, NULL
, 0);
4936 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
4937 "SendMessageCallback on sync only message returned %ld, last error %ld\n", lRes
, GetLastError());
4940 typedef struct _thread_info
4947 static VOID CALLBACK
tfunc(HWND hwnd
, UINT uMsg
, UINT id
, DWORD dwTime
)
4951 #define TIMER_ID 0x19
4953 static DWORD WINAPI
timer_thread_proc(LPVOID x
)
4955 thread_info
*info
= x
;
4958 r
= KillTimer(info
->hWnd
, 0x19);
4959 ok(r
,"KillTimer failed in thread\n");
4960 r
= SetTimer(info
->hWnd
,TIMER_ID
,10000,tfunc
);
4961 ok(r
,"SetTimer failed in thread\n");
4962 ok(r
==TIMER_ID
,"SetTimer id different\n");
4963 r
= SetEvent(info
->handles
[0]);
4964 ok(r
,"SetEvent failed in thread\n");
4968 static void test_timers(void)
4973 info
.hWnd
= CreateWindow ("TestWindowClass", NULL
,
4974 WS_OVERLAPPEDWINDOW
,
4975 CW_USEDEFAULT
, CW_USEDEFAULT
, 300, 300, 0,
4978 info
.id
= SetTimer(info
.hWnd
,TIMER_ID
,10000,tfunc
);
4979 ok(info
.id
, "SetTimer failed\n");
4980 ok(info
.id
==TIMER_ID
, "SetTimer timer ID different\n");
4981 info
.handles
[0] = CreateEvent(NULL
,0,0,NULL
);
4982 info
.handles
[1] = CreateThread(NULL
,0,timer_thread_proc
,&info
,0,&id
);
4984 WaitForMultipleObjects(2, info
.handles
, FALSE
, INFINITE
);
4986 WaitForSingleObject(info
.handles
[1], INFINITE
);
4988 CloseHandle(info
.handles
[0]);
4989 CloseHandle(info
.handles
[1]);
4991 ok( KillTimer(info
.hWnd
, TIMER_ID
), "KillTimer failed\n");
4993 ok(DestroyWindow(info
.hWnd
), "failed to destroy window\n");
4996 /* Various win events with arbitrary parameters */
4997 static const struct message WmWinEventsSeq
[] = {
4998 { EVENT_SYSTEM_SOUND
, winevent_hook
|wparam
|lparam
, OBJID_WINDOW
, 0 },
4999 { EVENT_SYSTEM_ALERT
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 1 },
5000 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, OBJID_TITLEBAR
, 2 },
5001 { EVENT_SYSTEM_MENUSTART
, winevent_hook
|wparam
|lparam
, OBJID_MENU
, 3 },
5002 { EVENT_SYSTEM_MENUEND
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 4 },
5003 { EVENT_SYSTEM_MENUPOPUPSTART
, winevent_hook
|wparam
|lparam
, OBJID_VSCROLL
, 5 },
5004 { EVENT_SYSTEM_MENUPOPUPEND
, winevent_hook
|wparam
|lparam
, OBJID_HSCROLL
, 6 },
5005 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, OBJID_SIZEGRIP
, 7 },
5006 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 8 },
5007 /* our win event hook ignores OBJID_CURSOR events */
5008 /*{ EVENT_SYSTEM_MOVESIZESTART, winevent_hook|wparam|lparam, OBJID_CURSOR, 9 },*/
5009 { EVENT_SYSTEM_MOVESIZEEND
, winevent_hook
|wparam
|lparam
, OBJID_ALERT
, 10 },
5010 { EVENT_SYSTEM_CONTEXTHELPSTART
, winevent_hook
|wparam
|lparam
, OBJID_SOUND
, 11 },
5011 { EVENT_SYSTEM_CONTEXTHELPEND
, winevent_hook
|wparam
|lparam
, OBJID_QUERYCLASSNAMEIDX
, 12 },
5012 { EVENT_SYSTEM_DRAGDROPSTART
, winevent_hook
|wparam
|lparam
, OBJID_NATIVEOM
, 13 },
5013 { EVENT_SYSTEM_DRAGDROPEND
, winevent_hook
|wparam
|lparam
, OBJID_WINDOW
, 0 },
5014 { EVENT_SYSTEM_DIALOGSTART
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 1 },
5015 { EVENT_SYSTEM_DIALOGEND
, winevent_hook
|wparam
|lparam
, OBJID_TITLEBAR
, 2 },
5016 { EVENT_SYSTEM_SCROLLINGSTART
, winevent_hook
|wparam
|lparam
, OBJID_MENU
, 3 },
5017 { EVENT_SYSTEM_SCROLLINGEND
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 4 },
5018 { EVENT_SYSTEM_SWITCHSTART
, winevent_hook
|wparam
|lparam
, OBJID_VSCROLL
, 5 },
5019 { EVENT_SYSTEM_SWITCHEND
, winevent_hook
|wparam
|lparam
, OBJID_HSCROLL
, 6 },
5020 { EVENT_SYSTEM_MINIMIZESTART
, winevent_hook
|wparam
|lparam
, OBJID_SIZEGRIP
, 7 },
5021 { EVENT_SYSTEM_MINIMIZEEND
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 8 },
5024 static const struct message WmWinEventCaretSeq
[] = {
5025 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 1 */
5026 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 1 */
5027 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 2 */
5028 { EVENT_OBJECT_NAMECHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 1 */
5031 static const struct message WmWinEventCaretSeq_2
[] = {
5032 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 1/2 */
5033 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 1/2 */
5034 { EVENT_OBJECT_NAMECHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 1/2 */
5037 static const struct message WmWinEventAlertSeq
[] = {
5038 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_ALERT
, 0 },
5041 static const struct message WmWinEventAlertSeq_2
[] = {
5042 /* create window in the thread proc */
5043 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_WINDOW
, 2 },
5044 /* our test event */
5045 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_ALERT
, 2 },
5048 static const struct message WmGlobalHookSeq_1
[] = {
5049 /* create window in the thread proc */
5050 { HCBT_CREATEWND
, hook
|lparam
, 0, 2 },
5051 /* our test events */
5052 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_PREVWINDOW
, 2 },
5053 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_NEXTWINDOW
, 2 },
5056 static const struct message WmGlobalHookSeq_2
[] = {
5057 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_NEXTWINDOW
, 0 }, /* old local hook */
5058 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_NEXTWINDOW
, 2 }, /* new global hook */
5059 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_PREVWINDOW
, 0 }, /* old local hook */
5060 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_PREVWINDOW
, 2 }, /* new global hook */
5064 static void CALLBACK
win_event_global_hook_proc(HWINEVENTHOOK hevent
,
5074 trace("WEH_2:%p,event %08lx,hwnd %p,obj %08lx,id %08lx,thread %08lx,time %08lx\n",
5075 hevent
, event
, hwnd
, object_id
, child_id
, thread_id
, event_time
);
5077 if (GetClassNameA(hwnd
, buf
, sizeof(buf
)))
5079 if (!lstrcmpiA(buf
, "TestWindowClass") ||
5080 !lstrcmpiA(buf
, "static"))
5084 msg
.message
= event
;
5085 msg
.flags
= winevent_hook
|wparam
|lparam
;
5086 msg
.wParam
= object_id
;
5087 msg
.lParam
= (thread_id
== GetCurrentThreadId()) ? child_id
: (child_id
+ 2);
5093 static HHOOK hCBT_global_hook
;
5094 static DWORD cbt_global_hook_thread_id
;
5096 static LRESULT CALLBACK
cbt_global_hook_proc(int nCode
, WPARAM wParam
, LPARAM lParam
)
5101 trace("CBT_2: %d, %08x, %08lx\n", nCode
, wParam
, lParam
);
5103 if (nCode
== HCBT_SYSCOMMAND
)
5107 msg
.message
= nCode
;
5108 msg
.flags
= hook
|wparam
|lparam
;
5109 msg
.wParam
= wParam
;
5110 msg
.lParam
= (cbt_global_hook_thread_id
== GetCurrentThreadId()) ? 1 : 2;
5113 return CallNextHookEx(hCBT_global_hook
, nCode
, wParam
, lParam
);
5116 /* Log also SetFocus(0) calls */
5117 hwnd
= wParam
? (HWND
)wParam
: (HWND
)lParam
;
5119 if (GetClassNameA(hwnd
, buf
, sizeof(buf
)))
5121 if (!lstrcmpiA(buf
, "TestWindowClass") ||
5122 !lstrcmpiA(buf
, "static"))
5126 msg
.message
= nCode
;
5127 msg
.flags
= hook
|wparam
|lparam
;
5128 msg
.wParam
= wParam
;
5129 msg
.lParam
= (cbt_global_hook_thread_id
== GetCurrentThreadId()) ? 1 : 2;
5133 return CallNextHookEx(hCBT_global_hook
, nCode
, wParam
, lParam
);
5136 static DWORD WINAPI
win_event_global_thread_proc(void *param
)
5140 HANDLE hevent
= *(HANDLE
*)param
;
5141 HMODULE user32
= GetModuleHandleA("user32.dll");
5142 FARPROC pNotifyWinEvent
= GetProcAddress(user32
, "NotifyWinEvent");
5144 assert(pNotifyWinEvent
);
5146 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
, 0,0,0,0,0,0,0, NULL
);
5148 trace("created thread window %p\n", hwnd
);
5150 *(HWND
*)param
= hwnd
;
5153 /* this event should be received only by our new hook proc,
5154 * an old one does not expect an event from another thread.
5156 pNotifyWinEvent(EVENT_OBJECT_LOCATIONCHANGE
, hwnd
, OBJID_ALERT
, 0);
5159 while (GetMessage(&msg
, 0, 0, 0))
5161 TranslateMessage(&msg
);
5162 DispatchMessage(&msg
);
5167 static DWORD WINAPI
cbt_global_hook_thread_proc(void *param
)
5171 HANDLE hevent
= *(HANDLE
*)param
;
5174 /* these events should be received only by our new hook proc,
5175 * an old one does not expect an event from another thread.
5178 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
, 0,0,0,0,0,0,0, NULL
);
5180 trace("created thread window %p\n", hwnd
);
5182 *(HWND
*)param
= hwnd
;
5184 /* Windows doesn't like when a thread plays games with the focus,
5185 that leads to all kinds of misbehaviours and failures to activate
5186 a window. So, better keep next lines commented out.
5190 DefWindowProcA(hwnd
, WM_SYSCOMMAND
, SC_PREVWINDOW
, 0);
5191 DefWindowProcA(hwnd
, WM_SYSCOMMAND
, SC_NEXTWINDOW
, 0);
5195 while (GetMessage(&msg
, 0, 0, 0))
5197 TranslateMessage(&msg
);
5198 DispatchMessage(&msg
);
5203 static void test_winevents(void)
5209 HANDLE hthread
, hevent
;
5211 HWINEVENTHOOK hhook
;
5212 const struct message
*events
= WmWinEventsSeq
;
5213 HMODULE user32
= GetModuleHandleA("user32.dll");
5214 FARPROC pSetWinEventHook
= GetProcAddress(user32
, "SetWinEventHook");
5215 FARPROC pUnhookWinEvent
= GetProcAddress(user32
, "UnhookWinEvent");
5216 FARPROC pNotifyWinEvent
= GetProcAddress(user32
, "NotifyWinEvent");
5218 hwnd
= CreateWindowExA(0, "TestWindowClass", NULL
,
5219 WS_OVERLAPPEDWINDOW
,
5220 CW_USEDEFAULT
, CW_USEDEFAULT
, 300, 300, 0,
5224 /****** start of global hook test *************/
5225 hCBT_global_hook
= SetWindowsHookExA(WH_CBT
, cbt_global_hook_proc
, GetModuleHandleA(0), 0);
5226 assert(hCBT_global_hook
);
5228 hevent
= CreateEventA(NULL
, 0, 0, NULL
);
5230 hwnd2
= (HWND
)hevent
;
5232 hthread
= CreateThread(NULL
, 0, cbt_global_hook_thread_proc
, &hwnd2
, 0, &tid
);
5233 ok(hthread
!= NULL
, "CreateThread failed, error %ld\n", GetLastError());
5235 ok(WaitForSingleObject(hevent
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
5237 ok_sequence(WmGlobalHookSeq_1
, "global hook 1", FALSE
);
5240 /* this one should be received only by old hook proc */
5241 DefWindowProcA(hwnd
, WM_SYSCOMMAND
, SC_NEXTWINDOW
, 0);
5242 /* this one should be received only by old hook proc */
5243 DefWindowProcA(hwnd
, WM_SYSCOMMAND
, SC_PREVWINDOW
, 0);
5245 ok_sequence(WmGlobalHookSeq_2
, "global hook 2", FALSE
);
5247 ret
= UnhookWindowsHookEx(hCBT_global_hook
);
5248 ok( ret
, "UnhookWindowsHookEx error %ld\n", GetLastError());
5250 PostThreadMessageA(tid
, WM_QUIT
, 0, 0);
5251 ok(WaitForSingleObject(hthread
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
5252 CloseHandle(hthread
);
5253 CloseHandle(hevent
);
5254 ok(!IsWindow(hwnd2
), "window should be destroyed on thread exit\n");
5255 /****** end of global hook test *************/
5257 if (!pSetWinEventHook
|| !pNotifyWinEvent
|| !pUnhookWinEvent
)
5259 ok(DestroyWindow(hwnd
), "failed to destroy window\n");
5265 #if 0 /* this test doesn't pass under Win9x */
5266 /* win2k ignores events with hwnd == 0 */
5267 SetLastError(0xdeadbeef);
5268 pNotifyWinEvent(events
[0].message
, 0, events
[0].wParam
, events
[0].lParam
);
5269 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
|| /* Win2k */
5270 GetLastError() == 0xdeadbeef, /* Win9x */
5271 "unexpected error %ld\n", GetLastError());
5272 ok_sequence(WmEmptySeq
, "empty notify winevents", FALSE
);
5275 for (i
= 0; i
< sizeof(WmWinEventsSeq
)/sizeof(WmWinEventsSeq
[0]); i
++)
5276 pNotifyWinEvent(events
[i
].message
, hwnd
, events
[i
].wParam
, events
[i
].lParam
);
5278 ok_sequence(WmWinEventsSeq
, "notify winevents", FALSE
);
5280 /****** start of event filtering test *************/
5281 hhook
= (HWINEVENTHOOK
)pSetWinEventHook(
5282 EVENT_OBJECT_SHOW
, /* 0x8002 */
5283 EVENT_OBJECT_LOCATIONCHANGE
, /* 0x800B */
5284 GetModuleHandleA(0), win_event_global_hook_proc
,
5285 GetCurrentProcessId(), 0,
5286 WINEVENT_INCONTEXT
);
5287 ok(hhook
!= 0, "SetWinEventHook error %ld\n", GetLastError());
5289 hevent
= CreateEventA(NULL
, 0, 0, NULL
);
5291 hwnd2
= (HWND
)hevent
;
5293 hthread
= CreateThread(NULL
, 0, win_event_global_thread_proc
, &hwnd2
, 0, &tid
);
5294 ok(hthread
!= NULL
, "CreateThread failed, error %ld\n", GetLastError());
5296 ok(WaitForSingleObject(hevent
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
5298 ok_sequence(WmWinEventAlertSeq
, "alert winevent", FALSE
);
5301 /* this one should be received only by old hook proc */
5302 pNotifyWinEvent(EVENT_OBJECT_CREATE
, hwnd
, OBJID_CARET
, 0); /* 0x8000 */
5303 pNotifyWinEvent(EVENT_OBJECT_SHOW
, hwnd
, OBJID_CARET
, 0); /* 0x8002 */
5304 /* this one should be received only by old hook proc */
5305 pNotifyWinEvent(EVENT_OBJECT_NAMECHANGE
, hwnd
, OBJID_CARET
, 0); /* 0x800C */
5307 ok_sequence(WmWinEventCaretSeq
, "caret winevent", FALSE
);
5309 ret
= pUnhookWinEvent(hhook
);
5310 ok( ret
, "UnhookWinEvent error %ld\n", GetLastError());
5312 PostThreadMessageA(tid
, WM_QUIT
, 0, 0);
5313 ok(WaitForSingleObject(hthread
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
5314 CloseHandle(hthread
);
5315 CloseHandle(hevent
);
5316 ok(!IsWindow(hwnd2
), "window should be destroyed on thread exit\n");
5317 /****** end of event filtering test *************/
5319 /****** start of out of context event test *************/
5320 hhook
= (HWINEVENTHOOK
)pSetWinEventHook(
5321 EVENT_MIN
, EVENT_MAX
,
5322 0, win_event_global_hook_proc
,
5323 GetCurrentProcessId(), 0,
5324 WINEVENT_OUTOFCONTEXT
);
5325 ok(hhook
!= 0, "SetWinEventHook error %ld\n", GetLastError());
5327 hevent
= CreateEventA(NULL
, 0, 0, NULL
);
5329 hwnd2
= (HWND
)hevent
;
5333 hthread
= CreateThread(NULL
, 0, win_event_global_thread_proc
, &hwnd2
, 0, &tid
);
5334 ok(hthread
!= NULL
, "CreateThread failed, error %ld\n", GetLastError());
5336 ok(WaitForSingleObject(hevent
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
5338 ok_sequence(WmEmptySeq
, "empty notify winevents", FALSE
);
5339 /* process pending winevent messages */
5340 ok(!PeekMessageA(&msg
, 0, 0, 0, PM_NOREMOVE
), "msg queue should be empty\n");
5341 ok_sequence(WmWinEventAlertSeq_2
, "alert winevent for out of context proc", FALSE
);
5344 /* this one should be received only by old hook proc */
5345 pNotifyWinEvent(EVENT_OBJECT_CREATE
, hwnd
, OBJID_CARET
, 0); /* 0x8000 */
5346 pNotifyWinEvent(EVENT_OBJECT_SHOW
, hwnd
, OBJID_CARET
, 0); /* 0x8002 */
5347 /* this one should be received only by old hook proc */
5348 pNotifyWinEvent(EVENT_OBJECT_NAMECHANGE
, hwnd
, OBJID_CARET
, 0); /* 0x800C */
5350 ok_sequence(WmWinEventCaretSeq_2
, "caret winevent for incontext proc", FALSE
);
5351 /* process pending winevent messages */
5352 ok(!PeekMessageA(&msg
, 0, 0, 0, PM_NOREMOVE
), "msg queue should be empty\n");
5353 ok_sequence(WmWinEventCaretSeq_2
, "caret winevent for out of context proc", FALSE
);
5355 ret
= pUnhookWinEvent(hhook
);
5356 ok( ret
, "UnhookWinEvent error %ld\n", GetLastError());
5358 PostThreadMessageA(tid
, WM_QUIT
, 0, 0);
5359 ok(WaitForSingleObject(hthread
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
5360 CloseHandle(hthread
);
5361 CloseHandle(hevent
);
5362 ok(!IsWindow(hwnd2
), "window should be destroyed on thread exit\n");
5363 /****** end of out of context event test *************/
5365 ok(DestroyWindow(hwnd
), "failed to destroy window\n");
5368 static void test_set_hook(void)
5372 HWINEVENTHOOK hwinevent_hook
;
5373 HMODULE user32
= GetModuleHandleA("user32.dll");
5374 FARPROC pSetWinEventHook
= GetProcAddress(user32
, "SetWinEventHook");
5375 FARPROC pUnhookWinEvent
= GetProcAddress(user32
, "UnhookWinEvent");
5377 hhook
= SetWindowsHookExA(WH_CBT
, cbt_hook_proc
, GetModuleHandleA(0), GetCurrentThreadId());
5378 ok(hhook
!= 0, "local hook does not require hModule set to 0\n");
5379 UnhookWindowsHookEx(hhook
);
5381 #if 0 /* this test doesn't pass under Win9x: BUG! */
5382 SetLastError(0xdeadbeef);
5383 hhook
= SetWindowsHookExA(WH_CBT
, cbt_hook_proc
, 0, 0);
5384 ok(!hhook
, "global hook requires hModule != 0\n");
5385 ok(GetLastError() == ERROR_HOOK_NEEDS_HMOD
, "unexpected error %ld\n", GetLastError());
5388 SetLastError(0xdeadbeef);
5389 hhook
= SetWindowsHookExA(WH_CBT
, 0, GetModuleHandleA(0), GetCurrentThreadId());
5390 ok(!hhook
, "SetWinEventHook with invalid proc should fail\n");
5391 ok(GetLastError() == ERROR_INVALID_FILTER_PROC
|| /* Win2k */
5392 GetLastError() == 0xdeadbeef, /* Win9x */
5393 "unexpected error %ld\n", GetLastError());
5395 SetLastError(0xdeadbeef);
5396 ok(!UnhookWindowsHookEx((HHOOK
)0xdeadbeef), "UnhookWindowsHookEx succeeded\n");
5397 ok(GetLastError() == ERROR_INVALID_HOOK_HANDLE
|| /* Win2k */
5398 GetLastError() == 0xdeadbeef, /* Win9x */
5399 "unexpected error %ld\n", GetLastError());
5401 if (!pSetWinEventHook
|| !pUnhookWinEvent
) return;
5403 /* even process local incontext hooks require hmodule */
5404 SetLastError(0xdeadbeef);
5405 hwinevent_hook
= (HWINEVENTHOOK
)pSetWinEventHook(EVENT_MIN
, EVENT_MAX
,
5406 0, win_event_proc
, GetCurrentProcessId(), 0, WINEVENT_INCONTEXT
);
5407 ok(!hwinevent_hook
, "WINEVENT_INCONTEXT requires hModule != 0\n");
5408 ok(GetLastError() == ERROR_HOOK_NEEDS_HMOD
|| /* Win2k */
5409 GetLastError() == 0xdeadbeef, /* Win9x */
5410 "unexpected error %ld\n", GetLastError());
5412 /* even thread local incontext hooks require hmodule */
5413 SetLastError(0xdeadbeef);
5414 hwinevent_hook
= (HWINEVENTHOOK
)pSetWinEventHook(EVENT_MIN
, EVENT_MAX
,
5415 0, win_event_proc
, GetCurrentProcessId(), GetCurrentThreadId(), WINEVENT_INCONTEXT
);
5416 ok(!hwinevent_hook
, "WINEVENT_INCONTEXT requires hModule != 0\n");
5417 ok(GetLastError() == ERROR_HOOK_NEEDS_HMOD
|| /* Win2k */
5418 GetLastError() == 0xdeadbeef, /* Win9x */
5419 "unexpected error %ld\n", GetLastError());
5421 #if 0 /* these 3 tests don't pass under Win9x */
5422 SetLastError(0xdeadbeef);
5423 hwinevent_hook
= (HWINEVENTHOOK
)pSetWinEventHook(1, 0,
5424 0, win_event_proc
, GetCurrentProcessId(), 0, WINEVENT_OUTOFCONTEXT
);
5425 ok(!hwinevent_hook
, "SetWinEventHook with invalid event range should fail\n");
5426 ok(GetLastError() == ERROR_INVALID_HOOK_FILTER
, "unexpected error %ld\n", GetLastError());
5428 SetLastError(0xdeadbeef);
5429 hwinevent_hook
= (HWINEVENTHOOK
)pSetWinEventHook(-1, 1,
5430 0, win_event_proc
, GetCurrentProcessId(), 0, WINEVENT_OUTOFCONTEXT
);
5431 ok(!hwinevent_hook
, "SetWinEventHook with invalid event range should fail\n");
5432 ok(GetLastError() == ERROR_INVALID_HOOK_FILTER
, "unexpected error %ld\n", GetLastError());
5434 SetLastError(0xdeadbeef);
5435 hwinevent_hook
= (HWINEVENTHOOK
)pSetWinEventHook(EVENT_MIN
, EVENT_MAX
,
5436 0, win_event_proc
, 0, 0xdeadbeef, WINEVENT_OUTOFCONTEXT
);
5437 ok(!hwinevent_hook
, "SetWinEventHook with invalid tid should fail\n");
5438 ok(GetLastError() == ERROR_INVALID_THREAD_ID
, "unexpected error %ld\n", GetLastError());
5441 SetLastError(0xdeadbeef);
5442 hwinevent_hook
= (HWINEVENTHOOK
)pSetWinEventHook(0, 0,
5443 0, win_event_proc
, GetCurrentProcessId(), 0, WINEVENT_OUTOFCONTEXT
);
5444 ok(hwinevent_hook
!= 0, "SetWinEventHook error %ld\n", GetLastError());
5445 ok(GetLastError() == 0xdeadbeef, "unexpected error %ld\n", GetLastError());
5446 ret
= pUnhookWinEvent(hwinevent_hook
);
5447 ok( ret
, "UnhookWinEvent error %ld\n", GetLastError());
5450 /* This call succeeds under win2k SP4, but fails under Wine.
5451 Does win2k test/use passed process id? */
5452 SetLastError(0xdeadbeef);
5453 hwinevent_hook
= (HWINEVENTHOOK
)pSetWinEventHook(EVENT_MIN
, EVENT_MAX
,
5454 0, win_event_proc
, 0xdeadbeef, 0, WINEVENT_OUTOFCONTEXT
);
5455 ok(hwinevent_hook
!= 0, "SetWinEventHook error %ld\n", GetLastError());
5456 ok(GetLastError() == 0xdeadbeef, "unexpected error %ld\n", GetLastError());
5457 ret
= pUnhookWinEvent(hwinevent_hook
);
5458 ok( ret
, "UnhookWinEvent error %ld\n", GetLastError());
5461 SetLastError(0xdeadbeef);
5462 ok(!pUnhookWinEvent((HWINEVENTHOOK
)0xdeadbeef), "UnhookWinEvent succeeded\n");
5463 ok(GetLastError() == ERROR_INVALID_HANDLE
|| /* Win2k */
5464 GetLastError() == 0xdeadbeef, /* Win9x */
5465 "unexpected error %ld\n", GetLastError());
5468 static const struct message ScrollWindowPaint1
[] = {
5470 { WM_ERASEBKGND
, sent
|beginpaint
},
5474 static const struct message ScrollWindowPaint2
[] = {
5479 static void test_scrollwindowex(void)
5482 RECT rect
={0,0,130,130};
5485 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test Scroll",
5486 WS_VISIBLE
|WS_OVERLAPPEDWINDOW
,
5487 100, 100, 200, 200, 0, 0, 0, NULL
);
5488 ok (hwnd
!= 0, "Failed to create overlapped window\n");
5489 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child",
5490 WS_VISIBLE
|WS_CAPTION
|WS_CHILD
,
5491 10, 10, 150, 150, hwnd
, 0, 0, NULL
);
5492 ok (hchild
!= 0, "Failed to create child\n");
5494 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
5497 /* scroll without the child window */
5498 trace("start scroll\n");
5499 ScrollWindowEx( hwnd
, 10, 10, &rect
, NULL
, NULL
, NULL
,
5500 SW_ERASE
|SW_INVALIDATE
);
5501 ok_sequence(WmEmptySeq
, "ScrollWindowEx", 0);
5502 trace("end scroll\n");
5504 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
5505 ok_sequence(ScrollWindowPaint1
, "ScrollWindowEx", 0);
5507 /* Now without the SW_ERASE flag */
5508 trace("start scroll\n");
5509 ScrollWindowEx( hwnd
, 10, 10, &rect
, NULL
, NULL
, NULL
, SW_INVALIDATE
);
5510 ok_sequence(WmEmptySeq
, "ScrollWindowEx", 0);
5511 trace("end scroll\n");
5513 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
5514 ok_sequence(ScrollWindowPaint2
, "ScrollWindowEx", 0);
5516 /* now scroll the child window as well */
5517 trace("start scroll\n");
5518 ScrollWindowEx( hwnd
, 10, 10, &rect
, NULL
, NULL
, NULL
,
5519 SW_SCROLLCHILDREN
|SW_ERASE
|SW_INVALIDATE
);
5520 todo_wine
{ /* wine sends WM_POSCHANGING, WM_POSCHANGED messages */
5521 /* windows sometimes a WM_MOVE */
5522 ok_sequence(WmEmptySeq
, "ScrollWindowEx", 0);
5524 trace("end scroll\n");
5526 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
5527 ok_sequence(ScrollWindowPaint1
, "ScrollWindowEx", 0);
5529 /* now scroll with ScrollWindow() */
5530 trace("start scroll with ScrollWindow\n");
5531 ScrollWindow( hwnd
, 5, 5, NULL
, NULL
);
5532 trace("end scroll\n");
5534 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
5535 ok_sequence(ScrollWindowPaint1
, "ScrollWindow", 0);
5537 ok(DestroyWindow(hchild
), "failed to destroy window\n");
5538 ok(DestroyWindow(hwnd
), "failed to destroy window\n");
5542 static const struct message destroy_window_with_children
[] = {
5543 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* popup */
5544 { HCBT_DESTROYWND
, hook
|lparam
, 0, WND_PARENT_ID
}, /* parent */
5545 { HCBT_DESTROYWND
, hook
|lparam
, 0, WND_POPUP_ID
}, /* popup */
5546 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* popup */
5547 { WM_DESTROY
, sent
|wparam
|lparam
, 0, WND_POPUP_ID
}, /* popup */
5548 { WM_CAPTURECHANGED
, sent
|wparam
|lparam
, 0, WND_POPUP_ID
}, /* popup */
5549 { WM_NCDESTROY
, sent
|wparam
|lparam
, 0, WND_POPUP_ID
}, /* popup */
5550 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* parent */
5551 { WM_DESTROY
, sent
|wparam
|lparam
, 0, WND_PARENT_ID
}, /* parent */
5552 { WM_DESTROY
, sent
|wparam
|lparam
, 0, WND_CHILD_ID
+ 2 }, /* child2 */
5553 { WM_DESTROY
, sent
|wparam
|lparam
, 0, WND_CHILD_ID
+ 1 }, /* child1 */
5554 { WM_DESTROY
, sent
|wparam
|lparam
, 0, WND_CHILD_ID
+ 3 }, /* child3 */
5555 { WM_NCDESTROY
, sent
|wparam
|lparam
, 0, WND_CHILD_ID
+ 2 }, /* child2 */
5556 { WM_NCDESTROY
, sent
|wparam
|lparam
, 0, WND_CHILD_ID
+ 3 }, /* child3 */
5557 { WM_NCDESTROY
, sent
|wparam
|lparam
, 0, WND_CHILD_ID
+ 1 }, /* child1 */
5558 { WM_NCDESTROY
, sent
|wparam
|lparam
, 0, WND_PARENT_ID
}, /* parent */
5562 static void test_DestroyWindow(void)
5565 HWND parent
, child1
, child2
, child3
, child4
, test
;
5566 UINT child_id
= WND_CHILD_ID
+ 1;
5568 parent
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
5569 100, 100, 200, 200, 0, 0, 0, NULL
);
5570 assert(parent
!= 0);
5571 child1
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_CHILD
,
5572 0, 0, 50, 50, parent
, (HMENU
)child_id
++, 0, NULL
);
5573 assert(child1
!= 0);
5574 child2
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_CHILD
,
5575 0, 0, 50, 50, GetDesktopWindow(), (HMENU
)child_id
++, 0, NULL
);
5576 assert(child2
!= 0);
5577 child3
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_CHILD
,
5578 0, 0, 50, 50, child1
, (HMENU
)child_id
++, 0, NULL
);
5579 assert(child3
!= 0);
5580 child4
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_POPUP
,
5581 0, 0, 50, 50, parent
, 0, 0, NULL
);
5582 assert(child4
!= 0);
5584 /* test owner/parent of child2 */
5585 test
= GetParent(child2
);
5586 ok(test
== GetDesktopWindow(), "wrong parent %p\n", test
);
5587 ok(!IsChild(parent
, child2
), "wrong parent/child %p/%p\n", parent
, child2
);
5589 test
= pGetAncestor(child2
, GA_PARENT
);
5590 ok(test
== GetDesktopWindow(), "wrong parent %p\n", test
);
5592 test
= GetWindow(child2
, GW_OWNER
);
5593 ok(!test
, "wrong owner %p\n", test
);
5595 test
= SetParent(child2
, parent
);
5596 ok(test
== GetDesktopWindow(), "wrong old parent %p\n", test
);
5598 /* test owner/parent of the parent */
5599 test
= GetParent(parent
);
5600 ok(!test
, "wrong parent %p\n", test
);
5602 ok(!IsChild(GetDesktopWindow(), parent
), "wrong parent/child %p/%p\n", GetDesktopWindow(), parent
);
5605 test
= pGetAncestor(parent
, GA_PARENT
);
5606 ok(test
== GetDesktopWindow(), "wrong parent %p\n", test
);
5608 test
= GetWindow(parent
, GW_OWNER
);
5609 ok(!test
, "wrong owner %p\n", test
);
5611 /* test owner/parent of child1 */
5612 test
= GetParent(child1
);
5613 ok(test
== parent
, "wrong parent %p\n", test
);
5614 ok(IsChild(parent
, child1
), "wrong parent/child %p/%p\n", parent
, child1
);
5616 test
= pGetAncestor(child1
, GA_PARENT
);
5617 ok(test
== parent
, "wrong parent %p\n", test
);
5619 test
= GetWindow(child1
, GW_OWNER
);
5620 ok(!test
, "wrong owner %p\n", test
);
5622 /* test owner/parent of child2 */
5623 test
= GetParent(child2
);
5624 ok(test
== parent
, "wrong parent %p\n", test
);
5625 ok(IsChild(parent
, child2
), "wrong parent/child %p/%p\n", parent
, child2
);
5627 test
= pGetAncestor(child2
, GA_PARENT
);
5628 ok(test
== parent
, "wrong parent %p\n", test
);
5630 test
= GetWindow(child2
, GW_OWNER
);
5631 ok(!test
, "wrong owner %p\n", test
);
5633 /* test owner/parent of child3 */
5634 test
= GetParent(child3
);
5635 ok(test
== child1
, "wrong parent %p\n", test
);
5636 ok(IsChild(parent
, child3
), "wrong parent/child %p/%p\n", parent
, child3
);
5638 test
= pGetAncestor(child3
, GA_PARENT
);
5639 ok(test
== child1
, "wrong parent %p\n", test
);
5641 test
= GetWindow(child3
, GW_OWNER
);
5642 ok(!test
, "wrong owner %p\n", test
);
5644 /* test owner/parent of child4 */
5645 test
= GetParent(child4
);
5646 ok(test
== parent
, "wrong parent %p\n", test
);
5647 ok(!IsChild(parent
, child4
), "wrong parent/child %p/%p\n", parent
, child4
);
5649 test
= pGetAncestor(child4
, GA_PARENT
);
5650 ok(test
== GetDesktopWindow(), "wrong parent %p\n", test
);
5652 test
= GetWindow(child4
, GW_OWNER
);
5653 ok(test
== parent
, "wrong owner %p\n", test
);
5657 trace("parent %p, child1 %p, child2 %p, child3 %p, child4 %p\n",
5658 parent
, child1
, child2
, child3
, child4
);
5661 test
= GetCapture();
5662 ok(test
== child4
, "wrong capture window %p\n", test
);
5664 test_DestroyWindow_flag
= TRUE
;
5665 ret
= DestroyWindow(parent
);
5666 ok( ret
, "DestroyWindow() error %ld\n", GetLastError());
5667 test_DestroyWindow_flag
= FALSE
;
5668 ok_sequence(destroy_window_with_children
, "destroy window with children", 0);
5670 ok(!IsWindow(parent
), "parent still exists\n");
5671 ok(!IsWindow(child1
), "child1 still exists\n");
5672 ok(!IsWindow(child2
), "child2 still exists\n");
5673 ok(!IsWindow(child3
), "child3 still exists\n");
5674 ok(!IsWindow(child4
), "child4 still exists\n");
5676 test
= GetCapture();
5677 ok(!test
, "wrong capture window %p\n", test
);
5681 static const struct message WmDispatchPaint
[] = {
5682 { WM_NCPAINT
, sent
},
5683 { WM_GETTEXT
, sent
|defwinproc
|optional
},
5684 { WM_GETTEXT
, sent
|defwinproc
|optional
},
5685 { WM_ERASEBKGND
, sent
},
5689 static LRESULT WINAPI
DispatchMessageCheckProc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
5691 if (message
== WM_PAINT
)
5693 trace( "Got WM_PAINT, ignoring\n" );
5696 return MsgCheckProcA( hwnd
, message
, wParam
, lParam
);
5699 static void test_DispatchMessage(void)
5704 HWND hwnd
= CreateWindowA( "TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
5705 100, 100, 200, 200, 0, 0, 0, NULL
);
5706 ShowWindow( hwnd
, SW_SHOW
);
5707 UpdateWindow( hwnd
);
5708 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
5710 SetWindowLongPtrA( hwnd
, GWL_WNDPROC
, (LONG_PTR
)DispatchMessageCheckProc
);
5712 SetRect( &rect
, -5, -5, 5, 5 );
5713 RedrawWindow( hwnd
, &rect
, 0, RDW_INVALIDATE
|RDW_ERASE
|RDW_FRAME
);
5715 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
))
5717 if (msg
.message
!= WM_PAINT
) DispatchMessage( &msg
);
5721 DispatchMessage( &msg
);
5722 /* DispatchMessage will send WM_NCPAINT if non client area is still invalid after WM_PAINT */
5723 if (!count
) ok_sequence( WmDispatchPaint
, "WmDispatchPaint", FALSE
);
5724 else ok_sequence( WmEmptySeq
, "WmEmpty", FALSE
);
5725 if (++count
> 10) break;
5728 ok( msg
.message
== WM_PAINT
&& count
> 10, "WM_PAINT messages stopped\n" );
5730 trace("now without DispatchMessage\n");
5732 RedrawWindow( hwnd
, &rect
, 0, RDW_INVALIDATE
|RDW_ERASE
|RDW_FRAME
);
5734 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
))
5736 if (msg
.message
!= WM_PAINT
) DispatchMessage( &msg
);
5739 HRGN hrgn
= CreateRectRgn( 0, 0, 0, 0 );
5741 /* this will send WM_NCCPAINT just like DispatchMessage does */
5742 GetUpdateRgn( hwnd
, hrgn
, TRUE
);
5743 ok_sequence( WmDispatchPaint
, "WmDispatchPaint", FALSE
);
5744 DeleteObject( hrgn
);
5745 GetClientRect( hwnd
, &rect
);
5746 ValidateRect( hwnd
, &rect
); /* this will stop WM_PAINTs */
5747 ok( !count
, "Got multiple WM_PAINTs\n" );
5748 if (++count
> 10) break;
5757 HMODULE user32
= GetModuleHandleA("user32.dll");
5758 FARPROC pSetWinEventHook
= GetProcAddress(user32
, "SetWinEventHook");
5759 FARPROC pUnhookWinEvent
= GetProcAddress(user32
, "UnhookWinEvent");
5760 FARPROC pIsWinEventHookInstalled
= 0;/*GetProcAddress(user32, "IsWinEventHookInstalled");*/
5761 pGetAncestor
= (void*) GetProcAddress(user32
, "GetAncestor");
5763 if (!RegisterWindowClasses()) assert(0);
5765 if (pSetWinEventHook
)
5767 hEvent_hook
= (HWINEVENTHOOK
)pSetWinEventHook(EVENT_MIN
, EVENT_MAX
,
5768 GetModuleHandleA(0),
5771 GetCurrentThreadId(),
5772 WINEVENT_INCONTEXT
);
5773 assert(hEvent_hook
);
5775 if (pIsWinEventHookInstalled
)
5778 for (event
= EVENT_MIN
; event
<= EVENT_MAX
; event
++)
5779 ok(pIsWinEventHookInstalled(event
), "IsWinEventHookInstalled(%u) failed\n", event
);
5783 cbt_hook_thread_id
= GetCurrentThreadId();
5784 hCBT_hook
= SetWindowsHookExA(WH_CBT
, cbt_hook_proc
, 0, GetCurrentThreadId());
5789 /* Fix message sequences before removing 3 lines below */
5790 ret
= pUnhookWinEvent(hEvent_hook
);
5791 ok( ret
, "UnhookWinEvent error %ld\n", GetLastError());
5792 pUnhookWinEvent
= 0;
5795 test_scrollwindowex();
5797 test_mdi_messages();
5798 test_button_messages();
5799 test_paint_messages();
5800 test_interthread_messages();
5801 test_message_conversion();
5802 test_accelerators();
5805 test_DestroyWindow();
5806 test_DispatchMessage();
5808 UnhookWindowsHookEx(hCBT_hook
);
5809 if (pUnhookWinEvent
)
5811 ret
= pUnhookWinEvent(hEvent_hook
);
5812 ok( ret
, "UnhookWinEvent error %ld\n", GetLastError());
5813 SetLastError(0xdeadbeef);
5814 ok(!pUnhookWinEvent(hEvent_hook
), "UnhookWinEvent succeeded\n");
5815 ok(GetLastError() == ERROR_INVALID_HANDLE
|| /* Win2k */
5816 GetLastError() == 0xdeadbeef, /* Win9x */
5817 "unexpected error %ld\n", GetLastError());