2 * Unit tests for window message handling
4 * Copyright 1999 Ove Kaaven
5 * Copyright 2003 Dimitrie O. Paun
6 * Copyright 2004, 2005 Dmitry Timoshkov
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
27 #define _WIN32_WINNT 0x0501 /* For WM_CHANGEUISTATE,QS_RAWINPUT */
35 #include "wine/test.h"
37 #define MDI_FIRST_CHILD_ID 2004
39 /* undocumented SWP flags - from SDK 3.1 */
40 #define SWP_NOCLIENTSIZE 0x0800
41 #define SWP_NOCLIENTMOVE 0x1000
42 #define SWP_STATECHANGED 0x8000
44 #define SW_NORMALNA 0xCC /* undoc. flag in MinMaximize */
47 #define WM_SYSTIMER 0x0118
50 #define WND_PARENT_ID 1
51 #define WND_POPUP_ID 2
52 #define WND_CHILD_ID 3
54 static BOOL test_DestroyWindow_flag
;
55 static HWINEVENTHOOK hEvent_hook
;
57 static HWND (WINAPI
*pGetAncestor
)(HWND
,UINT
);
59 static void dump_winpos_flags(UINT flags
);
62 FIXME: add tests for these
63 Window Edge Styles (Win31/Win95/98 look), in order of precedence:
64 WS_EX_DLGMODALFRAME: double border, WS_CAPTION allowed
65 WS_THICKFRAME: thick border
66 WS_DLGFRAME: double border, WS_CAPTION not allowed (but possibly shown anyway)
67 WS_BORDER (default for overlapped windows): single black border
68 none (default for child (and popup?) windows): no border
85 UINT message
; /* the WM_* code */
86 msg_flags_t flags
; /* message props */
87 WPARAM wParam
; /* expected value of wParam */
88 LPARAM lParam
; /* expected value of lParam */
91 /* Empty message sequence */
92 static const struct message WmEmptySeq
[] =
96 /* CreateWindow (for overlapped window, not initially visible) (16/32) */
97 static const struct message WmCreateOverlappedSeq
[] = {
98 { HCBT_CREATEWND
, hook
},
99 { WM_GETMINMAXINFO
, sent
},
100 { WM_NCCREATE
, sent
},
101 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
102 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
104 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
107 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
108 * for a not visible overlapped window.
110 static const struct message WmSWP_ShowOverlappedSeq
[] = {
111 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
112 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
113 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
114 { WM_GETTEXT
, sent
|defwinproc
|optional
},
115 { WM_ERASEBKGND
, sent
|optional
},
116 { HCBT_ACTIVATE
, hook
},
117 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
118 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
119 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* Win9x: SWP_NOSENDCHANGING */
120 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
121 { WM_NCACTIVATE
, sent
|wparam
, 1 },
122 { WM_GETTEXT
, sent
|defwinproc
|optional
},
123 { WM_ACTIVATE
, sent
|wparam
, 1 },
124 { HCBT_SETFOCUS
, hook
},
125 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
126 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
127 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
128 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
129 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
130 { WM_GETTEXT
, sent
|defwinproc
|optional
},
131 { WM_ERASEBKGND
, sent
|optional
},
132 /* Win9x adds SWP_NOZORDER below */
133 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
134 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
135 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
136 { WM_ERASEBKGND
, sent
|optional
},
137 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
140 /* SetWindowPos(SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE)
141 * for a visible overlapped window.
143 static const struct message WmSWP_HideOverlappedSeq
[] = {
144 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
145 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
146 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
150 /* SetWindowPos(SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOMOVE)
151 * for a visible overlapped window.
153 static const struct message WmSWP_ResizeSeq
[] = {
154 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
},
155 { WM_GETMINMAXINFO
, sent
|defwinproc
},
156 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
157 { WM_NCPAINT
, sent
|optional
},
158 { WM_GETTEXT
, sent
|defwinproc
|optional
},
159 { WM_ERASEBKGND
, sent
|optional
},
160 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
},
161 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
162 { WM_NCCALCSIZE
, sent
|wparam
|optional
, TRUE
},
163 { WM_NCPAINT
, sent
|optional
},
164 { WM_GETTEXT
, sent
|defwinproc
|optional
},
165 { WM_ERASEBKGND
, sent
|optional
},
166 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
167 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* XP sends a duplicate */
171 /* SetWindowPos(SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOMOVE)
172 * for a visible popup window.
174 static const struct message WmSWP_ResizePopupSeq
[] = {
175 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
},
176 { WM_GETMINMAXINFO
, sent
|defwinproc
|optional
}, /* Win9x */
177 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
178 { WM_NCPAINT
, sent
|optional
},
179 { WM_GETTEXT
, sent
|defwinproc
|optional
},
180 { WM_ERASEBKGND
, sent
|optional
},
181 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
},
182 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
183 { WM_NCCALCSIZE
, sent
|wparam
|optional
, TRUE
},
184 { WM_NCPAINT
, sent
|optional
},
185 { WM_GETTEXT
, sent
|defwinproc
|optional
},
186 { WM_ERASEBKGND
, sent
|optional
},
187 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
191 /* SetWindowPos(SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOSIZE)
192 * for a visible overlapped window.
194 static const struct message WmSWP_MoveSeq
[] = {
195 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOSIZE
},
196 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOCLIENTSIZE
},
197 { WM_MOVE
, sent
|defwinproc
|wparam
, 0 },
198 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
201 /* Resize with SetWindowPos(SWP_NOZORDER)
202 * for a visible overlapped window
203 * SWP_NOZORDER is stripped by the logging code
205 static const struct message WmSWP_ResizeNoZOrder
[] = {
206 { WM_WINDOWPOSCHANGING
, sent
|wparam
, 0/*SWP_NOZORDER*/ },
207 { WM_GETMINMAXINFO
, sent
|defwinproc
},
208 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
209 { WM_NCPAINT
, sent
},
210 { WM_GETTEXT
, sent
|defwinproc
|optional
},
211 { WM_ERASEBKGND
, sent
|optional
}, /* FIXME: remove optional once Wine is fixed */
212 { WM_WINDOWPOSCHANGED
, sent
|wparam
, /*SWP_NOZORDER|*/SWP_NOMOVE
|SWP_NOCLIENTMOVE
},
213 { WM_SIZE
, sent
|defwinproc
|wparam
, 0 },
214 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 }, /* Win9x doesn't send it */
215 { WM_NCPAINT
, sent
|optional
}, /* Win9x doesn't send it */
216 { WM_GETTEXT
, sent
|defwinproc
|optional
}, /* Win9x doesn't send it */
217 { WM_ERASEBKGND
, sent
|optional
}, /* Win9x doesn't send it */
221 /* Switch visible mdi children */
222 static const struct message WmSwitchChild
[] = {
223 /* Switch MDI child */
224 { WM_MDIACTIVATE
, sent
},/* in the MDI client */
225 { WM_WINDOWPOSCHANGING
, sent
|wparam
,SWP_NOSIZE
|SWP_NOMOVE
},/* in the 1st MDI child */
226 { WM_CHILDACTIVATE
, sent
},/* in the 1st MDI child */
227 /* Deactivate 2nd MDI child */
228 { WM_NCACTIVATE
, sent
|defwinproc
|optional
},/* in the 2nd MDI child */
229 { WM_MDIACTIVATE
, sent
|defwinproc
|optional
},/* in the 2nd MDI child */
231 /* Preparing for maximize and maximaze the 1st MDI child */
232 { WM_GETMINMAXINFO
, sent
|defwinproc
|optional
},/* in the 1st MDI child */
233 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
|optional
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},/* in the 1st MDI child */
234 { WM_GETMINMAXINFO
, sent
|defwinproc
|optional
},/* in the 1st MDI child */
235 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
|optional
, 1 },/* in the 1st MDI child */
236 { WM_CHILDACTIVATE
, sent
|defwinproc
|optional
},/* in the 1st MDI child */
237 { WM_WINDOWPOSCHANGED
, sent
|defwinproc
|optional
},/* in the 1st MDI child */
238 { WM_MOVE
, sent
|defwinproc
|optional
},/* in the 1st MDI child */
239 { WM_SIZE
, sent
|defwinproc
|optional
},/* in the 1st MDI child */
240 /* Lock redraw 2nd MDI child */
241 { WM_SETREDRAW
, sent
|defwinproc
|optional
},/* in the 2nd MDI child */
242 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
|optional
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},/* in the 2nd MDI child */
243 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
|optional
, 1 },/* in the 2nd MDI child */
244 { WM_WINDOWPOSCHANGED
, sent
|defwinproc
|optional
},/* in the 2nd MDI child */
246 /* Restore 2nd MDI child */
247 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
|optional
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_SHOWWINDOW
|SWP_STATECHANGED
},/* in the 2nd MDI child */
248 { WM_GETMINMAXINFO
, sent
|defwinproc
|optional
},/* in the 2nd MDI child */
249 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
|optional
, 1 },/* in the 2nd MDI child */
250 { WM_WINDOWPOSCHANGED
, sent
|defwinproc
|optional
},/* in the 2nd MDI child */
251 { WM_MOVE
, sent
|defwinproc
|optional
},/* in the 2nd MDI child */
252 { WM_SIZE
, sent
|defwinproc
|optional
},/* in the 2nd MDI child */
253 /* Redraw 2nd MDI child */
254 { WM_SETREDRAW
, sent
|defwinproc
|optional
},/* in the 2nd MDI child */
255 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
|optional
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_FRAMECHANGED
|SWP_NOMOVE
},/* in the 1st MDI child */
256 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
|optional
, 1 },/* in the 1st MDI child */
257 { WM_WINDOWPOSCHANGED
, sent
|defwinproc
|optional
},/* in the 1st MDI child */
258 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_FRAMECHANGED
|SWP_NOMOVE
},/* in the MDI frame */
259 { WM_NCCALCSIZE
, sent
|wparam
, 1 },/* in the MDI frame */
260 { WM_WINDOWPOSCHANGED
, sent
},/* in the MDI frame */
261 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
|optional
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},/* in the 1st MDI child */
262 { WM_NCACTIVATE
, sent
|defwinproc
|optional
},/* in the 1st MDI child */
263 { WM_SETVISIBLE
, hook
},
264 { WM_KILLFOCUS
, sent
|defwinproc
|optional
},/* in the 2nd MDI child */
265 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
266 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
267 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
268 { WM_SETFOCUS
, sent
},/* in the MDI client */
269 { WM_SETVISIBLE
, hook
},
270 { WM_KILLFOCUS
, sent
},/* in the MDI client */
271 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
272 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
273 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
274 { WM_SETFOCUS
, sent
|defwinproc
|optional
},/* in the 1st MDI child */
275 { WM_MDIACTIVATE
, sent
|defwinproc
|optional
},/* in the 1st MDI child */
276 { WM_WINDOWPOSCHANGED
, sent
},/* in the 1st MDI child */
280 /* SetWindowPos(SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|
281 SWP_NOZORDER|SWP_FRAMECHANGED)
282 * for a visible overlapped window with WS_CLIPCHILDREN style set.
284 static const struct message WmSWP_FrameChanged_clip
[] = {
285 { WM_WINDOWPOSCHANGING
, sent
|wparam
|parent
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
},
286 { WM_NCCALCSIZE
, sent
|wparam
|parent
, 1 },
287 { WM_NCPAINT
, sent
|parent
}, /* wparam != 1 */
288 { WM_GETTEXT
, sent
|parent
|defwinproc
|optional
},
289 { WM_ERASEBKGND
, sent
|parent
|optional
}, /* FIXME: remove optional once Wine is fixed */
290 { WM_NCPAINT
, sent
}, /* wparam != 1 */
291 { WM_ERASEBKGND
, sent
},
292 { WM_WINDOWPOSCHANGED
, sent
|wparam
|parent
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
293 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
297 /* SetWindowPos(SWP_NOSIZE|SWP_NOMOVE|SWP_DEFERERASE|SWP_NOACTIVATE|
298 SWP_NOZORDER|SWP_FRAMECHANGED)
299 * for a visible overlapped window.
301 static const struct message WmSWP_FrameChangedDeferErase
[] = {
302 { WM_WINDOWPOSCHANGING
, sent
|wparam
|parent
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_DEFERERASE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
},
303 { WM_NCCALCSIZE
, sent
|wparam
|parent
, 1 },
304 { WM_WINDOWPOSCHANGED
, sent
|wparam
|parent
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_DEFERERASE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
305 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
306 { WM_PAINT
, sent
|parent
},
307 { WM_NCPAINT
, sent
|beginpaint
|parent
}, /* wparam != 1 */
308 { WM_GETTEXT
, sent
|beginpaint
|parent
|defwinproc
|optional
},
310 { WM_NCPAINT
, sent
|beginpaint
}, /* wparam != 1 */
311 { WM_ERASEBKGND
, sent
|beginpaint
},
315 /* SetWindowPos(SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|
316 SWP_NOZORDER|SWP_FRAMECHANGED)
317 * for a visible overlapped window without WS_CLIPCHILDREN style set.
319 static const struct message WmSWP_FrameChanged_noclip
[] = {
320 { WM_WINDOWPOSCHANGING
, sent
|wparam
|parent
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
},
321 { WM_NCCALCSIZE
, sent
|wparam
|parent
, 1 },
322 { WM_NCPAINT
, sent
|parent
}, /* wparam != 1 */
323 { WM_GETTEXT
, sent
|parent
|defwinproc
|optional
},
324 { WM_ERASEBKGND
, sent
|parent
|optional
}, /* FIXME: remove optional once Wine is fixed */
325 { WM_WINDOWPOSCHANGED
, sent
|wparam
|parent
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
326 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
328 { WM_NCPAINT
, sent
|beginpaint
}, /* wparam != 1 */
329 { WM_ERASEBKGND
, sent
|beginpaint
},
333 /* ShowWindow(SW_SHOW) for a not visible overlapped window */
334 static const struct message WmShowOverlappedSeq
[] = {
335 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
336 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
337 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
338 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
339 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
340 { WM_GETTEXT
, sent
|defwinproc
|optional
},
341 { WM_ERASEBKGND
, sent
|optional
},
342 { HCBT_ACTIVATE
, hook
},
343 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
344 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
345 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
},
346 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
347 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
348 { WM_NCACTIVATE
, sent
|wparam
, 1 },
349 { WM_GETTEXT
, sent
|defwinproc
|optional
},
350 { WM_ACTIVATE
, sent
|wparam
, 1 },
351 { HCBT_SETFOCUS
, hook
},
352 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
353 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
354 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
355 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
356 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
357 { WM_GETTEXT
, sent
|defwinproc
|optional
},
358 { WM_ERASEBKGND
, sent
|optional
},
359 /* Win9x adds SWP_NOZORDER below */
360 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
361 { WM_NCCALCSIZE
, sent
|optional
},
362 { WM_NCPAINT
, sent
|optional
},
363 { WM_ERASEBKGND
, sent
|optional
},
364 #if 0 /* CreateWindow/ShowWindow(SW_SHOW) also generates WM_SIZE/WM_MOVE
365 * messages. Does that mean that CreateWindow doesn't set initial
366 * window dimensions for overlapped windows?
373 /* ShowWindow(SW_SHOWMAXIMIZED) for a not visible overlapped window */
374 static const struct message WmShowMaxOverlappedSeq
[] = {
375 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
376 { WM_GETMINMAXINFO
, sent
},
377 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|0x8000 },
378 { WM_GETMINMAXINFO
, sent
|defwinproc
},
379 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
380 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
381 { HCBT_ACTIVATE
, hook
},
382 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
383 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
384 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
},
385 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
386 { WM_NCACTIVATE
, sent
|wparam
, 1 },
387 { WM_GETTEXT
, sent
|defwinproc
|optional
},
388 { WM_ACTIVATE
, sent
|wparam
, 1 },
389 { HCBT_SETFOCUS
, hook
},
390 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
391 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
392 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
393 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
394 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
395 { WM_GETTEXT
, sent
|defwinproc
|optional
},
396 { WM_ERASEBKGND
, sent
|optional
},
397 /* Win9x adds SWP_NOZORDER below */
398 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|0x8000 },
399 { WM_MOVE
, sent
|defwinproc
},
400 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
401 { WM_NCCALCSIZE
, sent
|optional
},
402 { WM_NCPAINT
, sent
|optional
},
403 { WM_ERASEBKGND
, sent
|optional
},
404 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
405 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
408 /* ShowWindow(SW_SHOWMINIMIZED) for a not visible overlapped window */
409 static const struct message WmShowMinOverlappedSeq
[] = {
410 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
411 { HCBT_SETFOCUS
, hook
},
412 { WM_KILLFOCUS
, sent
},
413 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
414 { WM_IME_NOTIFY
, sent
|wparam
|optional
|defwinproc
, 1 },
415 { WM_GETTEXT
, sent
|optional
},
416 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOCOPYBITS
|SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_STATECHANGED
},
417 { WM_GETMINMAXINFO
, sent
|defwinproc
},
418 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
419 { WM_NCPAINT
, sent
},
420 { WM_GETTEXT
, sent
|defwinproc
|optional
},
421 { WM_WINDOWPOSCHANGED
, sent
},
422 { WM_MOVE
, sent
|defwinproc
},
423 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MINIMIZED
},
424 { WM_NCCALCSIZE
, sent
|optional
},
425 { WM_NCACTIVATE
, sent
|wparam
, 0 },
426 { WM_GETTEXT
, sent
|defwinproc
|optional
},
427 { WM_ACTIVATE
, sent
},
428 { WM_ACTIVATEAPP
, sent
|wparam
, 0 },
431 /* ShowWindow(SW_HIDE) for a visible overlapped window */
432 static const struct message WmHideOverlappedSeq
[] = {
433 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
434 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
435 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
436 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
437 { WM_SIZE
, sent
|optional
}, /* XP doesn't send it */
438 { WM_MOVE
, sent
|optional
}, /* XP doesn't send it */
439 { WM_NCACTIVATE
, sent
|wparam
, 0 },
440 { WM_ACTIVATE
, sent
|wparam
, 0 },
441 { WM_ACTIVATEAPP
, sent
|wparam
, 0 },
442 { WM_KILLFOCUS
, sent
|wparam
, 0 },
443 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
444 { WM_IME_NOTIFY
, sent
|wparam
|optional
|defwinproc
, 1 },
447 /* DestroyWindow for a visible overlapped window */
448 static const struct message WmDestroyOverlappedSeq
[] = {
449 { HCBT_DESTROYWND
, hook
},
450 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
451 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
452 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
453 { WM_NCACTIVATE
, sent
|wparam
, 0 },
454 { WM_ACTIVATE
, sent
|wparam
, 0 },
455 { WM_ACTIVATEAPP
, sent
|wparam
, 0 },
456 { WM_KILLFOCUS
, sent
|wparam
, 0 },
457 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
458 { WM_IME_NOTIFY
, sent
|wparam
|optional
|defwinproc
, 1 },
459 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
460 { WM_DESTROY
, sent
},
461 { WM_NCDESTROY
, sent
},
464 /* CreateWindow(WS_MAXIMIZE|WS_VISIBLE) for popup window */
465 static const struct message WmCreateMaxPopupSeq
[] = {
466 { HCBT_CREATEWND
, hook
},
467 { WM_NCCREATE
, sent
},
468 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
470 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
472 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
473 { WM_GETMINMAXINFO
, sent
},
474 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|0x8000 },
475 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
476 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOREDRAW
|0x8000 },
477 { WM_MOVE
, sent
|defwinproc
},
478 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
479 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
480 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
481 { HCBT_ACTIVATE
, hook
},
482 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
483 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
484 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
485 { WM_NCACTIVATE
, sent
|wparam
, 1 },
486 { WM_ACTIVATE
, sent
|wparam
, 1 },
487 { HCBT_SETFOCUS
, hook
},
488 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
489 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
490 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
491 { WM_SYNCPAINT
, sent
|wparam
|optional
, 4 },
492 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
493 { WM_ERASEBKGND
, sent
|optional
},
494 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOCLIENTMOVE
|SWP_NOCLIENTSIZE
|SWP_SHOWWINDOW
|SWP_NOMOVE
|SWP_NOSIZE
},
497 /* CreateWindow(WS_MAXIMIZE) for popup window, not initially visible */
498 static const struct message WmCreateInvisibleMaxPopupSeq
[] = {
499 { HCBT_CREATEWND
, hook
},
500 { WM_NCCREATE
, sent
},
501 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
503 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
505 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
506 { WM_GETMINMAXINFO
, sent
},
507 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|0x8000 },
508 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
509 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOREDRAW
|0x8000 },
510 { WM_MOVE
, sent
|defwinproc
},
511 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
514 /* ShowWindow(SW_SHOWMAXIMIZED) for a resized not visible popup window */
515 static const struct message WmShowMaxPopupResizedSeq
[] = {
516 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
517 { WM_GETMINMAXINFO
, sent
},
518 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
},
519 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
520 { HCBT_ACTIVATE
, hook
},
521 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
522 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
523 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
524 { WM_NCACTIVATE
, sent
|wparam
, 1 },
525 { WM_ACTIVATE
, sent
|wparam
, 1 },
526 { HCBT_SETFOCUS
, hook
},
527 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
528 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
529 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
530 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
531 { WM_ERASEBKGND
, sent
|optional
},
532 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOCLIENTMOVE
|SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOMOVE
},
533 /* WinNT4.0 sends WM_MOVE */
534 { WM_MOVE
, sent
|defwinproc
|optional
},
535 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
538 /* ShowWindow(SW_SHOWMAXIMIZED) for a not visible popup window */
539 static const struct message WmShowMaxPopupSeq
[] = {
540 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
541 { WM_GETMINMAXINFO
, sent
},
542 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
},
543 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
544 { HCBT_ACTIVATE
, hook
},
545 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
546 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
547 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
548 { WM_NCACTIVATE
, sent
|wparam
, 1 },
549 { WM_ACTIVATE
, sent
|wparam
, 1 },
550 { HCBT_SETFOCUS
, hook
},
551 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
552 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
553 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
554 { WM_SYNCPAINT
, sent
|wparam
|optional
, 4 },
555 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
556 { WM_ERASEBKGND
, sent
|optional
},
557 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOMOVE
|SWP_NOSIZE
},
560 /* CreateWindow(WS_VISIBLE) for popup window */
561 static const struct message WmCreatePopupSeq
[] = {
562 { HCBT_CREATEWND
, hook
},
563 { WM_NCCREATE
, sent
},
564 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
566 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
568 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
569 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
570 { HCBT_ACTIVATE
, hook
},
571 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
572 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
573 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
574 { WM_ERASEBKGND
, sent
|optional
},
575 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
576 { WM_NCACTIVATE
, sent
|wparam
, 1 },
577 { WM_ACTIVATE
, sent
|wparam
, 1 },
578 { HCBT_SETFOCUS
, hook
},
579 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
580 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
581 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
582 { WM_SYNCPAINT
, sent
|wparam
|optional
, 4 },
583 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
584 { WM_ERASEBKGND
, sent
|optional
},
585 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOCLIENTMOVE
|SWP_NOCLIENTSIZE
|SWP_SHOWWINDOW
|SWP_NOMOVE
|SWP_NOSIZE
},
588 /* ShowWindow(SW_SHOWMAXIMIZED) for a visible popup window */
589 static const struct message WmShowVisMaxPopupSeq
[] = {
590 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
591 { WM_GETMINMAXINFO
, sent
},
592 { WM_GETTEXT
, sent
|optional
},
593 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|0x8000 },
594 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
595 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
596 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
597 { WM_ERASEBKGND
, sent
|optional
},
598 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|0x8000 },
599 { WM_MOVE
, sent
|defwinproc
},
600 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
603 /* CreateWindow (for a child popup window, not initially visible) */
604 static const struct message WmCreateChildPopupSeq
[] = {
605 { HCBT_CREATEWND
, hook
},
606 { WM_NCCREATE
, sent
},
607 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
609 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
610 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
614 /* CreateWindow (for a popup window, not initially visible,
615 * which sets WS_VISIBLE in WM_CREATE handler)
617 static const struct message WmCreateInvisiblePopupSeq
[] = {
618 { HCBT_CREATEWND
, hook
},
619 { WM_NCCREATE
, sent
},
620 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
622 { WM_STYLECHANGING
, sent
},
623 { WM_STYLECHANGED
, sent
},
624 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
625 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
629 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER)
630 * for a popup window with WS_VISIBLE style set
632 static const struct message WmShowVisiblePopupSeq_2
[] = {
633 { WM_WINDOWPOSCHANGING
, sent
|wparam
, 0 },
636 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
637 * for a popup window with WS_VISIBLE style set
639 static const struct message WmShowVisiblePopupSeq_3
[] = {
640 { WM_WINDOWPOSCHANGING
, sent
|wparam
, 0 },
641 { HCBT_ACTIVATE
, hook
},
642 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
643 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
644 { WM_WINDOWPOSCHANGING
, sent
|wparam
, 0 },
645 { WM_NCACTIVATE
, sent
|wparam
, 1 },
646 { WM_ACTIVATE
, sent
|wparam
, 1 },
647 { HCBT_SETFOCUS
, hook
},
648 { WM_KILLFOCUS
, sent
|parent
},
649 { WM_IME_SETCONTEXT
, sent
|parent
|wparam
|optional
, 0 },
650 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
651 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
652 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
653 { WM_SETFOCUS
, sent
|defwinproc
},
656 /* CreateWindow (for child window, not initially visible) */
657 static const struct message WmCreateChildSeq
[] = {
658 { HCBT_CREATEWND
, hook
},
659 { WM_NCCREATE
, sent
},
660 /* child is inserted into parent's child list after WM_NCCREATE returns */
661 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
663 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
664 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
666 { WM_PARENTNOTIFY
, sent
|parent
|wparam
, WM_CREATE
},
669 /* CreateWindow (for maximized child window, not initially visible) */
670 static const struct message WmCreateMaximizedChildSeq
[] = {
671 { HCBT_CREATEWND
, hook
},
672 { WM_NCCREATE
, sent
},
673 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
675 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
676 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
678 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
679 { WM_GETMINMAXINFO
, sent
},
680 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|0x8000 },
681 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
682 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
|0x8000 },
683 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
684 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
685 { WM_PARENTNOTIFY
, sent
|parent
|wparam
, WM_CREATE
},
688 /* CreateWindow (for a child window, initially visible) */
689 static const struct message WmCreateVisibleChildSeq
[] = {
690 { HCBT_CREATEWND
, hook
},
691 { WM_NCCREATE
, sent
},
692 /* child is inserted into parent's child list after WM_NCCREATE returns */
693 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
694 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
696 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
697 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
699 { WM_PARENTNOTIFY
, sent
|parent
|wparam
, WM_CREATE
},
700 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
701 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
702 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
703 { WM_ERASEBKGND
, sent
|parent
|optional
},
704 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
705 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 }, /* WinXP */
706 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
709 /* ShowWindow(SW_SHOW) for a not visible child window */
710 static const struct message WmShowChildSeq
[] = {
711 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
712 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
713 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
714 { WM_ERASEBKGND
, sent
|parent
|optional
},
715 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
718 /* ShowWindow(SW_HIDE) for a visible child window */
719 static const struct message WmHideChildSeq
[] = {
720 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
721 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
722 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
723 { WM_ERASEBKGND
, sent
|parent
|optional
},
724 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
727 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
728 * for a not visible child window
730 static const struct message WmShowChildSeq_2
[] = {
731 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
732 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
733 { WM_CHILDACTIVATE
, sent
},
734 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
737 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE)
738 * for a not visible child window
740 static const struct message WmShowChildSeq_3
[] = {
741 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
742 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
743 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
746 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
747 * for a visible child window with a caption
749 static const struct message WmShowChildSeq_4
[] = {
750 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
751 { WM_CHILDACTIVATE
, sent
},
754 /* ShowWindow(SW_MINIMIZE) for child with invisible parent */
755 static const struct message WmShowChildInvisibleParentSeq_1
[] = {
756 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
757 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOCOPYBITS
|0x8000 },
758 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
759 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOREDRAW
|SWP_NOCOPYBITS
|0x8000 },
760 { WM_MOVE
, sent
|defwinproc
},
761 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MINIMIZED
},
762 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
763 /* FIXME: Wine creates an icon/title window while Windows doesn't */
764 { WM_PARENTNOTIFY
, sent
|parent
|wparam
|optional
, WM_CREATE
},
765 { WM_GETTEXT
, sent
|optional
},
768 /* repeated ShowWindow(SW_MINIMIZE) for child with invisible parent */
769 static const struct message WmShowChildInvisibleParentSeq_1r
[] = {
770 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
773 /* ShowWindow(SW_MAXIMIZE) for child with invisible parent */
774 static const struct message WmShowChildInvisibleParentSeq_2
[] = {
775 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
776 { WM_GETMINMAXINFO
, sent
},
777 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|0x8000 },
778 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
779 { WM_CHILDACTIVATE
, sent
},
780 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
|0x8000 },
781 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
782 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
785 /* repeated ShowWindow(SW_MAXIMIZE) for child with invisible parent */
786 static const struct message WmShowChildInvisibleParentSeq_2r
[] = {
787 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
790 /* ShowWindow(SW_SHOWMINIMIZED) for child with invisible parent */
791 static const struct message WmShowChildInvisibleParentSeq_3
[] = {
792 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINIMIZED
},
793 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|0x8000 },
794 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
795 { WM_CHILDACTIVATE
, sent
},
796 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOREDRAW
|SWP_NOCOPYBITS
|0x8000 },
797 { WM_MOVE
, sent
|defwinproc
},
798 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MINIMIZED
},
799 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
800 /* FIXME: Wine creates an icon/title window while Windows doesn't */
801 { WM_PARENTNOTIFY
, sent
|parent
|wparam
|optional
, WM_CREATE
},
802 { WM_GETTEXT
, sent
|optional
},
805 /* repeated ShowWindow(SW_SHOWMINIMIZED) for child with invisible parent */
806 static const struct message WmShowChildInvisibleParentSeq_3r
[] = {
807 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINIMIZED
},
810 /* ShowWindow(SW_SHOWMINNOACTIVE) for child with invisible parent */
811 static const struct message WmShowChildInvisibleParentSeq_4
[] = {
812 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINNOACTIVE
},
813 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOCOPYBITS
|0x8000 },
814 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
815 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOREDRAW
|SWP_NOCOPYBITS
|0x8000 },
816 { WM_MOVE
, sent
|defwinproc
},
817 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MINIMIZED
},
818 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
819 /* FIXME: Wine creates an icon/title window while Windows doesn't */
820 { WM_PARENTNOTIFY
, sent
|parent
|wparam
|optional
, WM_CREATE
},
821 { WM_GETTEXT
, sent
|optional
},
824 /* repeated ShowWindow(SW_SHOWMINNOACTIVE) for child with invisible parent */
825 static const struct message WmShowChildInvisibleParentSeq_4r
[] = {
826 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINNOACTIVE
},
829 /* ShowWindow(SW_SHOW) for child with invisible parent */
830 static const struct message WmShowChildInvisibleParentSeq_5
[] = {
831 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
834 /* ShowWindow(SW_HIDE) for child with invisible parent */
835 static const struct message WmHideChildInvisibleParentSeq
[] = {
836 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
839 /* SetWindowPos(SWP_SHOWWINDOW) for child with invisible parent */
840 static const struct message WmShowChildInvisibleParentSeq_6
[] = {
841 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
842 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
843 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
846 /* SetWindowPos(SWP_HIDEWINDOW) for child with invisible parent */
847 static const struct message WmHideChildInvisibleParentSeq_2
[] = {
848 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
849 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
850 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
853 /* DestroyWindow for a visible child window */
854 static const struct message WmDestroyChildSeq
[] = {
855 { HCBT_DESTROYWND
, hook
},
856 { WM_PARENTNOTIFY
, sent
|parent
|wparam
, WM_DESTROY
},
857 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
858 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
859 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
860 { WM_ERASEBKGND
, sent
|parent
|optional
},
861 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
862 { HCBT_SETFOCUS
, hook
}, /* set focus to a parent */
863 { WM_KILLFOCUS
, sent
},
864 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
865 { WM_IME_SETCONTEXT
, sent
|wparam
|parent
|optional
, 1 },
866 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
867 { WM_SETFOCUS
, sent
|parent
},
868 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
869 { WM_DESTROY
, sent
},
870 { WM_DESTROY
, sent
|optional
}, /* some other (IME?) window */
871 { WM_NCDESTROY
, sent
|optional
}, /* some other (IME?) window */
872 { WM_NCDESTROY
, sent
},
875 /* DestroyWindow for a visible child window with invisible parent */
876 static const struct message WmDestroyInvisibleChildSeq
[] = {
877 { HCBT_DESTROYWND
, hook
},
878 { WM_PARENTNOTIFY
, sent
|parent
|wparam
, WM_DESTROY
},
879 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
880 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
881 { WM_DESTROY
, sent
},
882 { WM_NCDESTROY
, sent
},
885 /* Moving the mouse in nonclient area */
886 static const struct message WmMouseMoveInNonClientAreaSeq
[] = { /* FIXME: add */
887 { WM_NCHITTEST
, sent
},
888 { WM_SETCURSOR
, sent
},
889 { WM_NCMOUSEMOVE
, posted
},
892 /* Moving the mouse in client area */
893 static const struct message WmMouseMoveInClientAreaSeq
[] = { /* FIXME: add */
894 { WM_NCHITTEST
, sent
},
895 { WM_SETCURSOR
, sent
},
896 { WM_MOUSEMOVE
, posted
},
899 /* Moving by dragging the title bar (after WM_NCHITTEST and WM_SETCURSOR) (outline move) */
900 static const struct message WmDragTitleBarSeq
[] = { /* FIXME: add */
901 { WM_NCLBUTTONDOWN
, sent
|wparam
, HTCAPTION
},
902 { WM_SYSCOMMAND
, sent
|defwinproc
|wparam
, SC_MOVE
+2 },
903 { WM_GETMINMAXINFO
, sent
|defwinproc
},
904 { WM_ENTERSIZEMOVE
, sent
|defwinproc
},
905 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, 0 },
906 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, 0 },
907 { WM_MOVE
, sent
|defwinproc
},
908 { WM_EXITSIZEMOVE
, sent
|defwinproc
},
911 /* Sizing by dragging the thick borders (after WM_NCHITTEST and WM_SETCURSOR) (outline move) */
912 static const struct message WmDragThickBordersBarSeq
[] = { /* FIXME: add */
913 { WM_NCLBUTTONDOWN
, sent
|wparam
, 0xd },
914 { WM_SYSCOMMAND
, sent
|defwinproc
|wparam
, 0xf004 },
915 { WM_GETMINMAXINFO
, sent
|defwinproc
},
916 { WM_ENTERSIZEMOVE
, sent
|defwinproc
},
917 { WM_SIZING
, sent
|defwinproc
|wparam
, 4}, /* one for each mouse movement */
918 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, 0 },
919 { WM_GETMINMAXINFO
, sent
|defwinproc
},
920 { WM_NCCALCSIZE
, sent
|defwinproc
|wparam
, 1 },
921 { WM_NCPAINT
, sent
|defwinproc
|wparam
, 1 },
922 { WM_GETTEXT
, sent
|defwinproc
},
923 { WM_ERASEBKGND
, sent
|defwinproc
},
924 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, 0 },
925 { WM_MOVE
, sent
|defwinproc
},
926 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
927 { WM_EXITSIZEMOVE
, sent
|defwinproc
},
930 /* Resizing child window with MoveWindow (32) */
931 static const struct message WmResizingChildWithMoveWindowSeq
[] = {
932 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
933 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
934 { WM_ERASEBKGND
, sent
|optional
},
935 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
},
936 { WM_MOVE
, sent
|defwinproc
},
937 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
938 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
941 /* Clicking on inactive button */
942 static const struct message WmClickInactiveButtonSeq
[] = { /* FIXME: add */
943 { WM_NCHITTEST
, sent
},
944 { WM_PARENTNOTIFY
, sent
|parent
|wparam
, WM_LBUTTONDOWN
},
945 { WM_MOUSEACTIVATE
, sent
},
946 { WM_MOUSEACTIVATE
, sent
|parent
|defwinproc
},
947 { WM_SETCURSOR
, sent
},
948 { WM_SETCURSOR
, sent
|parent
|defwinproc
},
949 { WM_LBUTTONDOWN
, posted
},
950 { WM_KILLFOCUS
, posted
|parent
},
951 { WM_SETFOCUS
, posted
},
952 { WM_CTLCOLORBTN
, posted
|parent
},
953 { BM_SETSTATE
, posted
},
954 { WM_CTLCOLORBTN
, posted
|parent
},
955 { WM_LBUTTONUP
, posted
},
956 { BM_SETSTATE
, posted
},
957 { WM_CTLCOLORBTN
, posted
|parent
},
958 { WM_COMMAND
, posted
|parent
},
961 /* Reparenting a button (16/32) */
962 /* The last child (button) reparented gets topmost for its new parent. */
963 static const struct message WmReparentButtonSeq
[] = { /* FIXME: add */
964 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
965 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOSIZE
},
966 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
967 { WM_ERASEBKGND
, sent
|parent
},
968 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOSIZE
},
969 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
},
970 { WM_CHILDACTIVATE
, sent
},
971 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOSIZE
|SWP_NOREDRAW
},
972 { WM_MOVE
, sent
|defwinproc
},
973 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
976 /* Creation of a custom dialog (32) */
977 static const struct message WmCreateCustomDialogSeq
[] = {
978 { HCBT_CREATEWND
, hook
},
979 { WM_GETMINMAXINFO
, sent
},
980 { WM_NCCREATE
, sent
},
981 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
982 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
984 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
985 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
986 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
987 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
988 { HCBT_ACTIVATE
, hook
},
989 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
992 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
994 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
},
996 { WM_NCACTIVATE
, sent
|wparam
, 1 },
997 { WM_GETTEXT
, sent
|optional
|defwinproc
},
998 { WM_GETTEXT
, sent
|optional
|defwinproc
},
999 { EVENT_OBJECT_DEFACTIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, OBJID_CLIENT
, 0 },
1000 { WM_ACTIVATE
, sent
|wparam
, 1 },
1001 { WM_KILLFOCUS
, sent
|parent
},
1002 { WM_IME_SETCONTEXT
, sent
|parent
|wparam
|optional
, 0 },
1003 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
1004 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
1005 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1006 { WM_SETFOCUS
, sent
},
1007 { WM_GETDLGCODE
, sent
|defwinproc
|wparam
, 0 },
1008 { WM_NCPAINT
, sent
|wparam
, 1 },
1009 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1010 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1011 { WM_ERASEBKGND
, sent
},
1012 { WM_CTLCOLORDLG
, sent
|defwinproc
},
1013 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1014 { WM_GETTEXT
, sent
|optional
},
1015 { WM_GETTEXT
, sent
|optional
},
1016 { WM_NCCALCSIZE
, sent
|optional
},
1017 { WM_NCPAINT
, sent
|optional
},
1018 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1019 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1020 { WM_ERASEBKGND
, sent
|optional
},
1021 { WM_CTLCOLORDLG
, sent
|optional
|defwinproc
},
1022 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1023 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
1027 /* Calling EndDialog for a custom dialog (32) */
1028 static const struct message WmEndCustomDialogSeq
[] = {
1029 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1030 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1031 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1032 { WM_GETTEXT
, sent
|optional
},
1033 { HCBT_ACTIVATE
, hook
},
1034 { WM_NCACTIVATE
, sent
|wparam
, 0 },
1035 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1036 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1037 { WM_ACTIVATE
, sent
|wparam
, 0 },
1038 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
1039 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1040 { HCBT_SETFOCUS
, hook
},
1041 { WM_KILLFOCUS
, sent
},
1042 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
1043 { WM_IME_SETCONTEXT
, sent
|parent
|wparam
|defwinproc
|optional
, 1 },
1044 { WM_IME_NOTIFY
, sent
|wparam
|optional
, 1 },
1045 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1046 { WM_SETFOCUS
, sent
|parent
|defwinproc
},
1049 /* ShowWindow(SW_SHOW) for a custom dialog (initially invisible) */
1050 static const struct message WmShowCustomDialogSeq
[] = {
1051 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1052 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
1053 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1054 { HCBT_ACTIVATE
, hook
},
1055 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
1057 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
1059 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
},
1060 { WM_ACTIVATEAPP
, sent
|wparam
|optional
, 1 },
1061 { WM_NCACTIVATE
, sent
|wparam
, 1 },
1062 { WM_ACTIVATE
, sent
|wparam
, 1 },
1064 { WM_KILLFOCUS
, sent
|parent
},
1065 { WM_IME_SETCONTEXT
, sent
|parent
|wparam
|optional
, 0 },
1066 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
1067 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
1068 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1069 { WM_SETFOCUS
, sent
},
1070 { WM_GETDLGCODE
, sent
|defwinproc
|wparam
, 0 },
1071 { WM_NCPAINT
, sent
|wparam
, 1 },
1072 { WM_ERASEBKGND
, sent
},
1073 { WM_CTLCOLORDLG
, sent
|defwinproc
},
1074 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1077 /* Creation and destruction of a modal dialog (32) */
1078 static const struct message WmModalDialogSeq
[] = {
1079 { WM_CANCELMODE
, sent
|parent
},
1080 { HCBT_SETFOCUS
, hook
},
1081 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1082 { WM_KILLFOCUS
, sent
|parent
},
1083 { WM_IME_SETCONTEXT
, sent
|parent
|wparam
|optional
, 0 },
1084 { EVENT_OBJECT_STATECHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1085 { WM_ENABLE
, sent
|parent
|wparam
, 0 },
1086 { HCBT_CREATEWND
, hook
},
1087 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
1088 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1089 { WM_SETFONT
, sent
},
1090 { WM_INITDIALOG
, sent
},
1091 { WM_CHANGEUISTATE
, sent
|optional
},
1092 { WM_UPDATEUISTATE
, sent
|optional
},
1093 { WM_SHOWWINDOW
, sent
},
1094 { HCBT_ACTIVATE
, hook
},
1095 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
1096 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
1097 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
},
1098 { WM_NCACTIVATE
, sent
|wparam
, 1 },
1099 { WM_GETTEXT
, sent
|optional
},
1100 { WM_ACTIVATE
, sent
|wparam
, 1 },
1101 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
1102 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1103 { WM_NCPAINT
, sent
},
1104 { WM_GETTEXT
, sent
|optional
},
1105 { WM_ERASEBKGND
, sent
},
1106 { WM_CTLCOLORDLG
, sent
},
1107 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1108 { WM_GETTEXT
, sent
|optional
},
1109 { WM_NCCALCSIZE
, sent
|optional
},
1110 { WM_NCPAINT
, sent
|optional
},
1111 { WM_GETTEXT
, sent
|optional
},
1112 { WM_ERASEBKGND
, sent
|optional
},
1113 { WM_CTLCOLORDLG
, sent
|optional
},
1114 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1115 { WM_PAINT
, sent
|optional
},
1116 { WM_CTLCOLORBTN
, sent
},
1117 { WM_ENTERIDLE
, sent
|parent
|optional
},
1118 { WM_ENTERIDLE
, sent
|parent
|optional
},
1119 { WM_ENTERIDLE
, sent
|parent
|optional
},
1120 { WM_ENTERIDLE
, sent
|parent
|optional
},
1121 { WM_ENTERIDLE
, sent
|parent
|optional
},
1122 { WM_ENTERIDLE
, sent
|parent
|optional
},
1123 { WM_ENTERIDLE
, sent
|parent
|optional
},
1124 { WM_ENTERIDLE
, sent
|parent
|optional
},
1125 { WM_ENTERIDLE
, sent
|parent
|optional
},
1126 { WM_ENTERIDLE
, sent
|parent
|optional
},
1127 { WM_ENTERIDLE
, sent
|parent
|optional
},
1128 { WM_ENTERIDLE
, sent
|parent
|optional
},
1129 { WM_ENTERIDLE
, sent
|parent
|optional
},
1130 { WM_ENTERIDLE
, sent
|parent
|optional
},
1131 { WM_ENTERIDLE
, sent
|parent
|optional
},
1132 { WM_ENTERIDLE
, sent
|parent
|optional
},
1133 { WM_ENTERIDLE
, sent
|parent
|optional
},
1134 { WM_ENTERIDLE
, sent
|parent
|optional
},
1135 { WM_ENTERIDLE
, sent
|parent
|optional
},
1136 { WM_ENTERIDLE
, sent
|parent
|optional
},
1138 { EVENT_OBJECT_STATECHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1139 { WM_ENABLE
, sent
|parent
|wparam
, 1 },
1140 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
1141 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1142 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1143 { WM_GETTEXT
, sent
|optional
},
1144 { HCBT_ACTIVATE
, hook
},
1145 { WM_NCACTIVATE
, sent
|wparam
, 0 },
1146 { WM_GETTEXT
, sent
|optional
},
1147 { WM_ACTIVATE
, sent
|wparam
, 0 },
1148 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
1149 { WM_WINDOWPOSCHANGING
, sent
|optional
},
1150 { HCBT_SETFOCUS
, hook
},
1151 { WM_IME_SETCONTEXT
, sent
|parent
|wparam
|defwinproc
|optional
, 1 },
1152 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1153 { WM_SETFOCUS
, sent
|parent
|defwinproc
},
1154 { EVENT_SYSTEM_DIALOGEND
, winevent_hook
|wparam
|lparam
, 0, 0 },
1155 { HCBT_DESTROYWND
, hook
},
1156 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
1157 { WM_DESTROY
, sent
},
1158 { WM_NCDESTROY
, sent
},
1161 /* Creation of a modal dialog that is resized inside WM_INITDIALOG (32) */
1162 static const struct message WmCreateModalDialogResizeSeq
[] = { /* FIXME: add */
1163 /* (inside dialog proc, handling WM_INITDIALOG) */
1164 { WM_WINDOWPOSCHANGING
, sent
|wparam
, 0 },
1165 { WM_NCCALCSIZE
, sent
},
1166 { WM_NCACTIVATE
, sent
|parent
|wparam
, 0 },
1167 { WM_GETTEXT
, sent
|defwinproc
},
1168 { WM_ACTIVATE
, sent
|parent
|wparam
, 0 },
1169 { WM_WINDOWPOSCHANGING
, sent
|wparam
, 0 },
1170 { WM_WINDOWPOSCHANGING
, sent
|parent
},
1171 { WM_NCACTIVATE
, sent
|wparam
, 1 },
1172 { WM_ACTIVATE
, sent
|wparam
, 1 },
1173 { WM_WINDOWPOSCHANGED
, sent
|wparam
, 0 },
1174 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
1175 /* (setting focus) */
1176 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1177 { WM_WINDOWPOSCHANGING
, sent
|wparam
, 0 },
1178 { WM_NCPAINT
, sent
},
1179 { WM_GETTEXT
, sent
|defwinproc
},
1180 { WM_ERASEBKGND
, sent
},
1181 { WM_CTLCOLORDLG
, sent
|defwinproc
},
1182 { WM_WINDOWPOSCHANGED
, sent
|wparam
, 0 },
1184 /* (bunch of WM_CTLCOLOR* for each control) */
1185 { WM_PAINT
, sent
|parent
},
1186 { WM_ENTERIDLE
, sent
|parent
|wparam
, 0 },
1187 { WM_SETCURSOR
, sent
|parent
},
1190 /* SetMenu for NonVisible windows with size change*/
1191 static const struct message WmSetMenuNonVisibleSizeChangeSeq
[] = {
1192 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1193 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1194 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
1195 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
},
1196 { WM_MOVE
, sent
|defwinproc
},
1197 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
1198 { WM_NCCALCSIZE
,sent
|wparam
|optional
, 1 }, /* XP */
1199 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1200 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* XP sends a duplicate */
1201 { WM_GETTEXT
, sent
|optional
},
1202 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
1205 /* SetMenu for NonVisible windows with no size change */
1206 static const struct message WmSetMenuNonVisibleNoSizeChangeSeq
[] = {
1207 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1208 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1209 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1210 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1213 /* SetMenu for Visible windows with size change */
1214 static const struct message WmSetMenuVisibleSizeChangeSeq
[] = {
1215 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1216 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1217 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
1218 { WM_NCPAINT
, sent
}, /* wparam != 1 */
1219 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1220 { WM_ERASEBKGND
, sent
|optional
},
1221 { WM_ACTIVATE
, sent
|optional
},
1222 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1223 { WM_MOVE
, sent
|defwinproc
},
1224 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
1225 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
1226 { WM_NCPAINT
, sent
|optional
}, /* wparam != 1 */
1227 { WM_ERASEBKGND
, sent
|optional
},
1228 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1229 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* XP sends a duplicate */
1232 /* SetMenu for Visible windows with no size change */
1233 static const struct message WmSetMenuVisibleNoSizeChangeSeq
[] = {
1234 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1235 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1236 { WM_NCPAINT
, sent
}, /* wparam != 1 */
1237 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1238 { WM_ERASEBKGND
, sent
|optional
},
1239 { WM_ACTIVATE
, sent
|optional
},
1240 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1241 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1244 /* DrawMenuBar for a visible window */
1245 static const struct message WmDrawMenuBarSeq
[] =
1247 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1248 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1249 { WM_NCPAINT
, sent
}, /* wparam != 1 */
1250 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1251 { WM_ERASEBKGND
, sent
|optional
},
1252 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1253 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1257 static const struct message WmSetRedrawFalseSeq
[] =
1259 { WM_SETREDRAW
, sent
|wparam
, 0 },
1263 static const struct message WmSetRedrawTrueSeq
[] =
1265 { WM_SETREDRAW
, sent
|wparam
, 1 },
1269 static const struct message WmEnableWindowSeq_1
[] =
1271 { WM_CANCELMODE
, sent
|wparam
|lparam
, 0, 0 },
1272 { EVENT_OBJECT_STATECHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1273 { WM_ENABLE
, sent
|wparam
|lparam
, FALSE
, 0 },
1277 static const struct message WmEnableWindowSeq_2
[] =
1279 { EVENT_OBJECT_STATECHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1280 { WM_ENABLE
, sent
|wparam
|lparam
, TRUE
, 0 },
1284 static const struct message WmGetScrollRangeSeq
[] =
1286 { SBM_GETRANGE
, sent
},
1289 static const struct message WmGetScrollInfoSeq
[] =
1291 { SBM_GETSCROLLINFO
, sent
},
1294 static const struct message WmSetScrollRangeSeq
[] =
1296 /* MSDN claims that Windows sends SBM_SETRANGE message, but win2k SP4
1297 sends SBM_SETSCROLLINFO.
1299 { SBM_SETSCROLLINFO
, sent
},
1302 /* SetScrollRange for a window without a non-client area */
1303 static const struct message WmSetScrollRangeHSeq_empty
[] =
1305 { EVENT_OBJECT_VALUECHANGE
, winevent_hook
|wparam
|lparam
, OBJID_HSCROLL
, 0 },
1308 static const struct message WmSetScrollRangeVSeq_empty
[] =
1310 { EVENT_OBJECT_VALUECHANGE
, winevent_hook
|wparam
|lparam
, OBJID_VSCROLL
, 0 },
1313 static const struct message WmSetScrollRangeHVSeq
[] =
1315 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOSIZE
},
1316 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1317 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1318 { WM_ERASEBKGND
, sent
|optional
},
1319 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1320 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1321 { EVENT_OBJECT_VALUECHANGE
, winevent_hook
|lparam
|optional
, 0/*OBJID_HSCROLL or OBJID_VSCROLL*/, 0 },
1324 /* SetScrollRange for a window with a non-client area */
1325 static const struct message WmSetScrollRangeHV_NC_Seq
[] =
1327 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOSIZE
},
1328 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1329 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
1330 { WM_NCPAINT
, sent
|optional
},
1331 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1332 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1333 { WM_ERASEBKGND
, sent
|optional
},
1334 { WM_CTLCOLORDLG
, sent
|defwinproc
|optional
}, /* sent to a parent of the dialog */
1335 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOCLIENTMOVE
},
1336 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
1337 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1338 { EVENT_OBJECT_VALUECHANGE
, winevent_hook
|lparam
|optional
, 0/*OBJID_HSCROLL or OBJID_VSCROLL*/, 0 },
1339 { WM_GETTEXT
, sent
|optional
},
1340 { WM_GETTEXT
, sent
|optional
},
1341 { WM_GETTEXT
, sent
|optional
},
1342 { WM_GETTEXT
, sent
|optional
},
1345 /* test if we receive the right sequence of messages */
1346 /* after calling ShowWindow( SW_SHOWNA) */
1347 static const struct message WmSHOWNAChildInvisParInvis
[] = {
1348 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1351 static const struct message WmSHOWNAChildVisParInvis
[] = {
1352 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1355 static const struct message WmSHOWNAChildVisParVis
[] = {
1356 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1357 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
1360 static const struct message WmSHOWNAChildInvisParVis
[] = {
1361 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1362 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1363 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1364 { WM_ERASEBKGND
, sent
|optional
},
1365 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOACTIVATE
|SWP_NOCLIENTMOVE
},
1368 static const struct message WmSHOWNATopVisible
[] = {
1369 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1370 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
1373 static const struct message WmSHOWNATopInvisible
[] = {
1374 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1375 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1376 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1377 { WM_NCPAINT
, sent
|wparam
, 1 },
1378 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1379 { WM_ERASEBKGND
, sent
|optional
},
1380 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1381 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
1382 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
1383 { WM_ERASEBKGND
, sent
|optional
},
1384 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1385 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
1390 static int after_end_dialog
, test_def_id
;
1391 static int sequence_cnt
, sequence_size
;
1392 static struct message
* sequence
;
1393 static int log_all_parent_messages
;
1395 static void add_message(const struct message
*msg
)
1400 sequence
= HeapAlloc( GetProcessHeap(), 0, sequence_size
* sizeof (struct message
) );
1402 if (sequence_cnt
== sequence_size
)
1405 sequence
= HeapReAlloc( GetProcessHeap(), 0, sequence
, sequence_size
* sizeof (struct message
) );
1409 sequence
[sequence_cnt
].message
= msg
->message
;
1410 sequence
[sequence_cnt
].flags
= msg
->flags
;
1411 sequence
[sequence_cnt
].wParam
= msg
->wParam
;
1412 sequence
[sequence_cnt
].lParam
= msg
->lParam
;
1417 /* try to make sure pending X events have been processed before continuing */
1418 static void flush_events(void)
1422 DWORD time
= GetTickCount() + diff
;
1426 MsgWaitForMultipleObjects( 0, NULL
, FALSE
, diff
, QS_ALLINPUT
);
1427 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
1428 diff
= time
- GetTickCount();
1432 static void flush_sequence(void)
1434 HeapFree(GetProcessHeap(), 0, sequence
);
1436 sequence_cnt
= sequence_size
= 0;
1439 #define ok_sequence( exp, contx, todo) \
1440 ok_sequence_( (exp), (contx), (todo), __FILE__, __LINE__)
1443 static void ok_sequence_(const struct message
*expected
, const char *context
, int todo
,
1444 const char *file
, int line
)
1446 static const struct message end_of_sequence
= { 0, 0, 0, 0 };
1447 const struct message
*actual
;
1450 add_message(&end_of_sequence
);
1454 while (expected
->message
&& actual
->message
)
1456 trace_( file
, line
)("expected %04x - actual %04x\n", expected
->message
, actual
->message
);
1458 if (expected
->message
== actual
->message
)
1460 if (expected
->flags
& wparam
)
1462 if (expected
->wParam
!= actual
->wParam
&& todo
)
1466 ok_( file
, line
) (FALSE
,
1467 "%s: in msg 0x%04x expecting wParam 0x%lx got 0x%lx\n",
1468 context
, expected
->message
, expected
->wParam
, actual
->wParam
);
1472 ok_( file
, line
) (expected
->wParam
== actual
->wParam
,
1473 "%s: in msg 0x%04x expecting wParam 0x%lx got 0x%lx\n",
1474 context
, expected
->message
, expected
->wParam
, actual
->wParam
);
1476 if (expected
->flags
& lparam
)
1478 if (expected
->lParam
!= actual
->lParam
&& todo
)
1482 ok_( file
, line
) (FALSE
,
1483 "%s: in msg 0x%04x expecting lParam 0x%lx got 0x%lx\n",
1484 context
, expected
->message
, expected
->lParam
, actual
->lParam
);
1488 ok_( file
, line
) (expected
->lParam
== actual
->lParam
,
1489 "%s: in msg 0x%04x expecting lParam 0x%lx got 0x%lx\n",
1490 context
, expected
->message
, expected
->lParam
, actual
->lParam
);
1492 if ((expected
->flags
& defwinproc
) != (actual
->flags
& defwinproc
) && todo
)
1496 ok_( file
, line
) (FALSE
,
1497 "%s: the msg 0x%04x should %shave been sent by DefWindowProc\n",
1498 context
, expected
->message
, (expected
->flags
& defwinproc
) ? "" : "NOT ");
1502 ok_( file
, line
) ((expected
->flags
& defwinproc
) == (actual
->flags
& defwinproc
),
1503 "%s: the msg 0x%04x should %shave been sent by DefWindowProc\n",
1504 context
, expected
->message
, (expected
->flags
& defwinproc
) ? "" : "NOT ");
1505 ok_( file
, line
) ((expected
->flags
& beginpaint
) == (actual
->flags
& beginpaint
),
1506 "%s: the msg 0x%04x should %shave been sent by BeginPaint\n",
1507 context
, expected
->message
, (expected
->flags
& beginpaint
) ? "" : "NOT ");
1508 ok_( file
, line
) ((expected
->flags
& (sent
|posted
)) == (actual
->flags
& (sent
|posted
)),
1509 "%s: the msg 0x%04x should have been %s\n",
1510 context
, expected
->message
, (expected
->flags
& posted
) ? "posted" : "sent");
1511 ok_( file
, line
) ((expected
->flags
& parent
) == (actual
->flags
& parent
),
1512 "%s: the msg 0x%04x was expected in %s\n",
1513 context
, expected
->message
, (expected
->flags
& parent
) ? "parent" : "child");
1514 ok_( file
, line
) ((expected
->flags
& hook
) == (actual
->flags
& hook
),
1515 "%s: the msg 0x%04x should have been sent by a hook\n",
1516 context
, expected
->message
);
1517 ok_( file
, line
) ((expected
->flags
& winevent_hook
) == (actual
->flags
& winevent_hook
),
1518 "%s: the msg 0x%04x should have been sent by a winevent hook\n",
1519 context
, expected
->message
);
1523 /* silently drop winevent messages if there is no support for them */
1524 else if ((expected
->flags
& optional
) || ((expected
->flags
& winevent_hook
) && !hEvent_hook
))
1530 ok_( file
, line
) (FALSE
, "%s: the msg 0x%04x was expected, but got msg 0x%04x instead\n",
1531 context
, expected
->message
, actual
->message
);
1538 ok_( file
, line
) (FALSE
, "%s: the msg 0x%04x was expected, but got msg 0x%04x instead\n",
1539 context
, expected
->message
, actual
->message
);
1545 /* skip all optional trailing messages */
1546 while (expected
->message
&& ((expected
->flags
& optional
) ||
1547 ((expected
->flags
& winevent_hook
) && !hEvent_hook
)))
1553 if (expected
->message
|| actual
->message
) {
1555 ok_( file
, line
) (FALSE
, "%s: the msg sequence is not complete: expected %04x - actual %04x\n",
1556 context
, expected
->message
, actual
->message
);
1562 if (expected
->message
|| actual
->message
)
1563 ok_( file
, line
) (FALSE
, "%s: the msg sequence is not complete: expected %04x - actual %04x\n",
1564 context
, expected
->message
, actual
->message
);
1566 if( todo
&& !failcount
) /* succeeded yet marked todo */
1568 ok_( file
, line
)( TRUE
, "%s: marked \"todo_wine\" but succeeds\n", context
);
1574 /******************************** MDI test **********************************/
1576 /* CreateWindow for MDI frame window, initially visible */
1577 static const struct message WmCreateMDIframeSeq
[] = {
1578 { HCBT_CREATEWND
, hook
},
1579 { WM_GETMINMAXINFO
, sent
},
1580 { WM_NCCREATE
, sent
},
1581 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
1582 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
1583 { WM_CREATE
, sent
},
1584 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1585 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1586 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
1587 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1588 { HCBT_ACTIVATE
, hook
},
1589 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
1590 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
1591 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* XP */
1592 { WM_ACTIVATEAPP
, sent
|wparam
|optional
, 1 }, /* Win9x doesn't send it */
1593 { WM_NCACTIVATE
, sent
|wparam
, 1 },
1594 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1595 { WM_ACTIVATE
, sent
|wparam
, 1 },
1596 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* Win9x */
1597 { HCBT_SETFOCUS
, hook
},
1598 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
1599 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
1600 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1601 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
1602 /* Win9x adds SWP_NOZORDER below */
1603 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1604 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 }, /* XP */
1605 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1606 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
1610 /* DestroyWindow for MDI frame window, initially visible */
1611 static const struct message WmDestroyMDIframeSeq
[] = {
1612 { HCBT_DESTROYWND
, hook
},
1613 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1614 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1615 { WM_NCACTIVATE
, sent
|wparam
|optional
, 0 }, /* Win9x */
1616 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1617 { WM_NCACTIVATE
, sent
|wparam
|optional
, 0 }, /* XP */
1618 { WM_ACTIVATE
, sent
|wparam
|optional
, 0 }, /* Win9x */
1619 { WM_ACTIVATEAPP
, sent
|wparam
|optional
, 0 }, /* Win9x */
1620 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
1621 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
1622 { WM_DESTROY
, sent
},
1623 { WM_NCDESTROY
, sent
},
1626 /* CreateWindow for MDI client window, initially visible */
1627 static const struct message WmCreateMDIclientSeq
[] = {
1628 { HCBT_CREATEWND
, hook
},
1629 { WM_NCCREATE
, sent
},
1630 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
1631 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 },
1632 { WM_CREATE
, sent
},
1633 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 },
1634 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1635 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
1637 { WM_PARENTNOTIFY
, sent
|wparam
, WM_CREATE
}, /* in MDI frame */
1638 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1639 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1640 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1641 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1644 /* ShowWindow(SW_SHOW) for MDI client window */
1645 static const struct message WmShowMDIclientSeq
[] = {
1646 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1647 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1648 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1649 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1652 /* ShowWindow(SW_HIDE) for MDI client window */
1653 static const struct message WmHideMDIclientSeq
[] = {
1654 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
1655 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1656 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* win2000 */
1657 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* XP */
1658 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1661 /* DestroyWindow for MDI client window, initially visible */
1662 static const struct message WmDestroyMDIclientSeq
[] = {
1663 { HCBT_DESTROYWND
, hook
},
1664 { WM_PARENTNOTIFY
, sent
|wparam
, WM_DESTROY
}, /* in MDI frame */
1665 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
1666 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1667 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1668 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1669 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
1670 { WM_DESTROY
, sent
},
1671 { WM_NCDESTROY
, sent
},
1674 /* CreateWindow for MDI child window, initially visible */
1675 static const struct message WmCreateMDIchildVisibleSeq
[] = {
1676 { HCBT_CREATEWND
, hook
},
1677 { WM_NCCREATE
, sent
},
1678 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
1679 { WM_CREATE
, sent
},
1680 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1681 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
1683 /* Win2k sends wparam set to
1684 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
1685 * while Win9x doesn't bother to set child window id according to
1686 * CLIENTCREATESTRUCT.idFirstChild
1688 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
1689 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1690 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1691 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1692 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1693 { WM_MDIREFRESHMENU
, sent
/*|wparam|lparam, 0, 0*/ },
1694 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
1695 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
1696 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1698 /* Win9x: message sequence terminates here. */
1700 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 },
1701 { HCBT_SETFOCUS
, hook
}, /* in MDI client */
1702 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
1703 { WM_IME_NOTIFY
, sent
|wparam
|optional
, 2 }, /* in MDI client */
1704 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1705 { WM_SETFOCUS
, sent
}, /* in MDI client */
1706 { HCBT_SETFOCUS
, hook
},
1707 { WM_KILLFOCUS
, sent
}, /* in MDI client */
1708 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
1709 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
1710 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1711 { WM_SETFOCUS
, sent
|defwinproc
},
1712 { WM_MDIACTIVATE
, sent
|defwinproc
},
1715 /* CreateWindow for MDI child window with invisible parent */
1716 static const struct message WmCreateMDIchildInvisibleParentSeq
[] = {
1717 { HCBT_CREATEWND
, hook
},
1718 { WM_GETMINMAXINFO
, sent
},
1719 { WM_NCCREATE
, sent
},
1720 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
1721 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 },
1722 { WM_CREATE
, sent
},
1723 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1724 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
1726 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
1727 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1728 { WM_MDIREFRESHMENU
, sent
}, /* in MDI client */
1729 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
1730 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
1731 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1733 /* Win9x: message sequence terminates here. */
1735 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 },
1736 { HCBT_SETFOCUS
, hook
}, /* in MDI client */
1737 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
1738 { WM_IME_NOTIFY
, sent
|wparam
|optional
, 2 }, /* in MDI client */
1739 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1740 { WM_SETFOCUS
, sent
}, /* in MDI client */
1741 { HCBT_SETFOCUS
, hook
},
1742 { WM_KILLFOCUS
, sent
}, /* in MDI client */
1743 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
1744 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
1745 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1746 { WM_SETFOCUS
, sent
|defwinproc
},
1747 { WM_MDIACTIVATE
, sent
|defwinproc
},
1750 /* DestroyWindow for MDI child window, initially visible */
1751 static const struct message WmDestroyMDIchildVisibleSeq
[] = {
1752 { HCBT_DESTROYWND
, hook
},
1753 /* Win2k sends wparam set to
1754 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
1755 * while Win9x doesn't bother to set child window id according to
1756 * CLIENTCREATESTRUCT.idFirstChild
1758 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_DESTROY*/ }, /* in MDI client */
1759 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
1760 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1761 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1762 { WM_ERASEBKGND
, sent
|parent
|optional
},
1763 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1765 /* { WM_DESTROY, sent }
1766 * Win9x: message sequence terminates here.
1769 { HCBT_SETFOCUS
, hook
}, /* set focus to MDI client */
1770 { WM_KILLFOCUS
, sent
},
1771 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
1772 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
1773 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1774 { WM_SETFOCUS
, sent
}, /* in MDI client */
1776 { HCBT_SETFOCUS
, hook
}, /* MDI client sets focus back to MDI child */
1777 { WM_KILLFOCUS
, sent
}, /* in MDI client */
1778 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
1779 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
1780 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1781 { WM_SETFOCUS
, sent
}, /* in MDI client */
1783 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
1785 { HCBT_SETFOCUS
, hook
}, /* set focus to MDI client */
1786 { WM_KILLFOCUS
, sent
},
1787 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
1788 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
1789 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1790 { WM_SETFOCUS
, sent
}, /* in MDI client */
1792 { HCBT_SETFOCUS
, hook
}, /* MDI client sets focus back to MDI child */
1793 { WM_KILLFOCUS
, sent
}, /* in MDI client */
1794 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
1795 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
1796 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1797 { WM_SETFOCUS
, sent
}, /* in MDI client */
1799 { WM_DESTROY
, sent
},
1801 { HCBT_SETFOCUS
, hook
}, /* set focus to MDI client */
1802 { WM_KILLFOCUS
, sent
},
1803 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
1804 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
1805 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1806 { WM_SETFOCUS
, sent
}, /* in MDI client */
1808 { HCBT_SETFOCUS
, hook
}, /* MDI client sets focus back to MDI child */
1809 { WM_KILLFOCUS
, sent
}, /* in MDI client */
1810 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
1811 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
1812 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1813 { WM_SETFOCUS
, sent
}, /* in MDI client */
1815 { WM_NCDESTROY
, sent
},
1818 /* CreateWindow for MDI child window, initially invisible */
1819 static const struct message WmCreateMDIchildInvisibleSeq
[] = {
1820 { HCBT_CREATEWND
, hook
},
1821 { WM_NCCREATE
, sent
},
1822 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
1823 { WM_CREATE
, sent
},
1824 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1825 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
1827 /* Win2k sends wparam set to
1828 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
1829 * while Win9x doesn't bother to set child window id according to
1830 * CLIENTCREATESTRUCT.idFirstChild
1832 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
1835 /* DestroyWindow for MDI child window, initially invisible */
1836 static const struct message WmDestroyMDIchildInvisibleSeq
[] = {
1837 { HCBT_DESTROYWND
, hook
},
1838 /* Win2k sends wparam set to
1839 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
1840 * while Win9x doesn't bother to set child window id according to
1841 * CLIENTCREATESTRUCT.idFirstChild
1843 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_DESTROY*/ }, /* in MDI client */
1844 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
1845 { WM_DESTROY
, sent
},
1846 { WM_NCDESTROY
, sent
},
1847 /* FIXME: Wine destroys an icon/title window while Windows doesn't */
1848 { WM_PARENTNOTIFY
, sent
|wparam
|optional
, WM_DESTROY
}, /* MDI client */
1851 /* CreateWindow for the 1st MDI child window, initially visible and maximized */
1852 static const struct message WmCreateMDIchildVisibleMaxSeq1
[] = {
1853 { HCBT_CREATEWND
, hook
},
1854 { WM_NCCREATE
, sent
},
1855 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
1856 { WM_CREATE
, sent
},
1857 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1858 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
1860 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
1861 { WM_GETMINMAXINFO
, sent
},
1862 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|0x8000 },
1863 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1864 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|0x8000 },
1865 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
1867 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1868 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1869 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1870 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
1871 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
1872 /* Win2k sends wparam set to
1873 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
1874 * while Win9x doesn't bother to set child window id according to
1875 * CLIENTCREATESTRUCT.idFirstChild
1877 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
1878 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1879 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1880 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1881 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1882 { WM_MDIREFRESHMENU
, sent
/*|wparam|lparam, 0, 0*/ },
1883 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
1884 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
1885 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1887 /* Win9x: message sequence terminates here. */
1889 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 },
1890 { HCBT_SETFOCUS
, hook
}, /* in MDI client */
1891 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
1892 { WM_IME_NOTIFY
, sent
|wparam
|optional
, 2 }, /* in MDI client */
1893 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1894 { WM_SETFOCUS
, sent
}, /* in MDI client */
1895 { HCBT_SETFOCUS
, hook
},
1896 { WM_KILLFOCUS
, sent
}, /* in MDI client */
1897 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
1898 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
1899 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1900 { WM_SETFOCUS
, sent
|defwinproc
},
1901 { WM_MDIACTIVATE
, sent
|defwinproc
},
1903 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1904 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1905 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1906 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
1909 /* CreateWindow for the 2nd MDI child window, initially visible and maximized */
1910 static const struct message WmCreateMDIchildVisibleMaxSeq2
[] = {
1911 /* restore the 1st MDI child */
1912 { WM_SETREDRAW
, sent
|wparam
, 0 },
1913 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWNORMAL
},
1914 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|0x8000 },
1915 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1916 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
1917 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|0x8000 },
1918 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
1920 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1921 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1922 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1923 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
1924 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
1925 { WM_SETREDRAW
, sent
|wparam
, 1 }, /* in the 1st MDI child */
1926 /* create the 2nd MDI child */
1927 { HCBT_CREATEWND
, hook
},
1928 { WM_NCCREATE
, sent
},
1929 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
1930 { WM_CREATE
, sent
},
1931 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1932 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
1934 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
1935 { WM_GETMINMAXINFO
, sent
},
1936 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|0x8000 },
1937 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1938 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1939 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|0x8000 },
1940 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
1942 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1943 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1944 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1945 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
1946 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
1947 /* Win2k sends wparam set to
1948 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
1949 * while Win9x doesn't bother to set child window id according to
1950 * CLIENTCREATESTRUCT.idFirstChild
1952 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
1953 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1954 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1955 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1956 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1957 { WM_MDIREFRESHMENU
, sent
/*|wparam|lparam, 0, 0*/ },
1958 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
1959 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
1961 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 0 }, /* in the 1st MDI child */
1962 { WM_MDIACTIVATE
, sent
|defwinproc
}, /* in the 1st MDI child */
1964 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1966 /* Win9x: message sequence terminates here. */
1968 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 },
1969 { HCBT_SETFOCUS
, hook
},
1970 { WM_KILLFOCUS
, sent
|defwinproc
}, /* in the 1st MDI child */
1971 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 0 }, /* in the 1st MDI child */
1972 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
1973 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1974 { WM_SETFOCUS
, sent
}, /* in MDI client */
1975 { HCBT_SETFOCUS
, hook
},
1976 { WM_KILLFOCUS
, sent
}, /* in MDI client */
1977 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
1978 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
1979 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1980 { WM_SETFOCUS
, sent
|defwinproc
},
1982 { WM_MDIACTIVATE
, sent
|defwinproc
},
1984 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1985 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1986 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1987 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
1990 /* WM_MDICREATE MDI child window, initially visible and maximized */
1991 static const struct message WmCreateMDIchildVisibleMaxSeq3
[] = {
1992 { WM_MDICREATE
, sent
},
1993 { HCBT_CREATEWND
, hook
},
1994 { WM_NCCREATE
, sent
},
1995 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
1996 { WM_CREATE
, sent
},
1997 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1998 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2000 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
2001 { WM_GETMINMAXINFO
, sent
},
2002 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|0x8000 },
2003 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2004 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|0x8000 },
2005 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2008 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2009 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2010 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2011 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2012 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2014 /* Win2k sends wparam set to
2015 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2016 * while Win9x doesn't bother to set child window id according to
2017 * CLIENTCREATESTRUCT.idFirstChild
2019 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
2020 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
2021 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2023 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2025 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2026 { WM_MDIREFRESHMENU
, sent
/*|wparam|lparam, 0, 0*/ },
2027 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
2029 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2030 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2032 /* Win9x: message sequence terminates here. */
2034 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 },
2035 { WM_SETFOCUS
, sent
|optional
}, /* in MDI client */
2036 { HCBT_SETFOCUS
, hook
}, /* in MDI client */
2037 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2038 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
|optional
, OBJID_CLIENT
, 0 },
2039 { WM_SETFOCUS
, sent
|optional
}, /* in MDI client */
2040 { HCBT_SETFOCUS
, hook
|optional
},
2041 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2042 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2043 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
2044 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2045 { WM_SETFOCUS
, sent
|defwinproc
},
2047 { WM_MDIACTIVATE
, sent
|defwinproc
},
2050 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2051 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2052 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2053 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2056 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2057 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2058 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2059 { WM_MOVE
, sent
|defwinproc
},
2060 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2063 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
2064 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2065 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
},
2066 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2069 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
2070 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2071 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
},
2072 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2074 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2075 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI client */
2076 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 }, /* XP sends it to MDI frame */
2077 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2078 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* XP sends a duplicate */
2082 /* CreateWindow for the 1st MDI child window, initially invisible and maximized */
2083 static const struct message WmCreateMDIchildInvisibleMaxSeq4
[] = {
2084 { HCBT_CREATEWND
, hook
},
2085 { WM_GETMINMAXINFO
, sent
},
2086 { WM_NCCREATE
, sent
},
2087 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
2088 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
2089 { WM_CREATE
, sent
},
2090 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2091 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2093 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
2094 { WM_GETMINMAXINFO
, sent
},
2095 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|0x8000 },
2096 { WM_GETMINMAXINFO
, sent
|defwinproc
},
2097 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2098 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|0x8000 },
2099 { WM_MOVE
, sent
|defwinproc
},
2100 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2102 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2103 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2104 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2105 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2106 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 }, /* MDI child */
2107 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2108 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2109 /* Win2k sends wparam set to
2110 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2111 * while Win9x doesn't bother to set child window id according to
2112 * CLIENTCREATESTRUCT.idFirstChild
2114 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
2117 /* WM_SYSCOMMAND/SC_CLOSE for the 2nd MDI child window, initially visible and maximized */
2118 static const struct message WmDestroyMDIchildVisibleMaxSeq2
[] = {
2119 { WM_SYSCOMMAND
, sent
|wparam
, SC_CLOSE
},
2120 { HCBT_SYSCOMMAND
, hook
},
2121 { WM_CLOSE
, sent
|defwinproc
},
2122 { WM_MDIDESTROY
, sent
}, /* in MDI client */
2124 /* bring the 1st MDI child to top */
2125 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOSIZE
|SWP_NOMOVE
}, /* in the 1st MDI child */
2126 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
}, /* in the 2nd MDI child */
2128 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2130 { WM_CHILDACTIVATE
, sent
|defwinproc
|wparam
|lparam
, 0, 0 }, /* in the 1st MDI child */
2131 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 0 }, /* in the 1st MDI child */
2132 { WM_MDIACTIVATE
, sent
|defwinproc
}, /* in the 1st MDI child */
2134 /* maximize the 1st MDI child */
2135 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
2136 { WM_GETMINMAXINFO
, sent
|defwinproc
},
2137 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|0x8000 },
2138 { WM_NCCALCSIZE
, sent
|defwinproc
|wparam
, 1 },
2139 { WM_CHILDACTIVATE
, sent
|defwinproc
|wparam
|lparam
, 0, 0 },
2140 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|0x8000 },
2141 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2143 /* restore the 2nd MDI child */
2144 { WM_SETREDRAW
, sent
|defwinproc
|wparam
, 0 },
2145 { HCBT_MINMAX
, hook
|lparam
, 0, SW_NORMALNA
},
2146 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_SHOWWINDOW
|0x8000 },
2147 { WM_NCCALCSIZE
, sent
|defwinproc
|wparam
, 1 },
2149 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2151 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|0x8000 },
2152 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2154 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2156 { WM_SETREDRAW
, sent
|defwinproc
|wparam
, 1 },
2158 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2159 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2160 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2161 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2162 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2164 /* bring the 1st MDI child to top */
2165 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2166 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 },
2167 { HCBT_SETFOCUS
, hook
},
2168 { WM_KILLFOCUS
, sent
|defwinproc
},
2169 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 0 },
2170 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2171 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2172 { WM_SETFOCUS
, sent
}, /* in MDI client */
2173 { HCBT_SETFOCUS
, hook
},
2174 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2175 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2176 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
2177 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2178 { WM_SETFOCUS
, sent
|defwinproc
},
2179 { WM_MDIACTIVATE
, sent
|defwinproc
},
2180 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2182 /* apparently ShowWindow(SW_SHOW) on an MDI client */
2183 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
2184 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2185 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2186 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2187 { WM_MDIREFRESHMENU
, sent
},
2189 { HCBT_DESTROYWND
, hook
},
2190 /* Win2k sends wparam set to
2191 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
2192 * while Win9x doesn't bother to set child window id according to
2193 * CLIENTCREATESTRUCT.idFirstChild
2195 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_DESTROY*/ }, /* in MDI client */
2196 { WM_SHOWWINDOW
, sent
|defwinproc
|wparam
, 0 },
2197 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2198 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2199 { WM_ERASEBKGND
, sent
|parent
|optional
},
2200 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2202 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
2203 { WM_DESTROY
, sent
|defwinproc
},
2204 { WM_NCDESTROY
, sent
|defwinproc
},
2207 /* WM_MDIDESTROY for the single MDI child window, initially visible and maximized */
2208 static const struct message WmDestroyMDIchildVisibleMaxSeq1
[] = {
2209 { WM_MDIDESTROY
, sent
}, /* in MDI client */
2210 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
2211 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2212 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2213 { WM_ERASEBKGND
, sent
|parent
|optional
},
2214 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2216 { HCBT_SETFOCUS
, hook
},
2217 { WM_KILLFOCUS
, sent
},
2218 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
2219 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2220 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2221 { WM_SETFOCUS
, sent
}, /* in MDI client */
2222 { HCBT_SETFOCUS
, hook
},
2223 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2224 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2225 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
2226 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2227 { WM_SETFOCUS
, sent
},
2230 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2231 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2232 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2233 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2236 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2237 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2238 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2239 { WM_MOVE
, sent
|defwinproc
},
2240 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2243 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
2244 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2245 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
},
2246 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2249 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
2250 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2251 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
},
2252 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2255 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2256 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 },
2257 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2258 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2261 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2262 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 },
2263 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2264 { WM_MOVE
, sent
|defwinproc
},
2265 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2268 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
2269 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2270 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
},
2271 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2274 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
},
2275 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 },
2276 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
},
2277 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2278 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2279 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI client */
2281 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
|optional
, 1 }, /* XP sends it to MDI frame */
2283 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2284 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2285 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI client */
2286 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2287 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* XP sends a duplicate */
2290 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2291 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2292 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2293 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2295 { WM_NCACTIVATE
, sent
|wparam
, 0 },
2296 { WM_MDIACTIVATE
, sent
},
2298 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWNORMAL
},
2299 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_SHOWWINDOW
|0x8000 },
2300 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2302 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2304 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2305 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_SHOWWINDOW
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
|0x8000 },
2306 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2309 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2310 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 },
2311 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2312 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2315 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2316 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2317 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2318 { WM_MOVE
, sent
|defwinproc
},
2319 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2322 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
2323 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2324 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
},
2325 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2326 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2327 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 }, /* XP */
2328 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI client */
2329 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2330 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* XP sends a duplicate */
2332 { HCBT_SETFOCUS
, hook
},
2333 { WM_KILLFOCUS
, sent
},
2334 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
2335 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2336 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2337 { WM_SETFOCUS
, sent
}, /* in MDI client */
2339 { WM_MDIREFRESHMENU
, sent
}, /* in MDI client */
2341 { HCBT_DESTROYWND
, hook
},
2342 /* Win2k sends wparam set to
2343 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
2344 * while Win9x doesn't bother to set child window id according to
2345 * CLIENTCREATESTRUCT.idFirstChild
2347 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_DESTROY*/ }, /* in MDI client */
2349 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
2350 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2351 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2352 { WM_ERASEBKGND
, sent
|parent
|optional
},
2353 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2355 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
2356 { WM_DESTROY
, sent
},
2357 { WM_NCDESTROY
, sent
},
2360 /* ShowWindow(SW_MAXIMIZE) for a not visible MDI child window */
2361 static const struct message WmMaximizeMDIchildInvisibleSeq
[] = {
2362 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
2363 { WM_GETMINMAXINFO
, sent
},
2364 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|0x8000 },
2365 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2366 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2367 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2369 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2370 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 },
2371 { HCBT_SETFOCUS
, hook
},
2372 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2373 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2374 { WM_SETFOCUS
, sent
}, /* in MDI client */
2375 { HCBT_SETFOCUS
, hook
},
2376 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2377 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2378 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
2379 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2380 { WM_SETFOCUS
, sent
|defwinproc
},
2381 { WM_MDIACTIVATE
, sent
|defwinproc
},
2382 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|0x8000 },
2383 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2385 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2386 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2387 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2388 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2389 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2392 /* ShowWindow(SW_MAXIMIZE) for a not visible maximized MDI child window */
2393 static const struct message WmMaximizeMDIchildInvisibleSeq2
[] = {
2394 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
2395 { WM_GETMINMAXINFO
, sent
},
2396 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
},
2397 { WM_GETMINMAXINFO
, sent
|defwinproc
},
2398 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2399 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2400 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2402 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2403 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 },
2404 { HCBT_SETFOCUS
, hook
},
2405 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2406 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2407 { WM_SETFOCUS
, sent
}, /* in MDI client */
2408 { HCBT_SETFOCUS
, hook
},
2409 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2410 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2411 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
2412 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2413 { WM_SETFOCUS
, sent
|defwinproc
},
2414 { WM_MDIACTIVATE
, sent
|defwinproc
},
2415 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2416 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2419 /* WM_MDIMAXIMIZE for an MDI child window with invisible parent */
2420 static const struct message WmMaximizeMDIchildInvisibleParentSeq
[] = {
2421 { WM_MDIMAXIMIZE
, sent
}, /* in MDI client */
2422 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
2423 { WM_GETMINMAXINFO
, sent
},
2424 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|0x8000 },
2425 { WM_GETMINMAXINFO
, sent
|defwinproc
},
2426 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2427 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* XP doesn't send it */
2428 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2429 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOREDRAW
|0x8000 },
2430 { WM_MOVE
, sent
|defwinproc
},
2431 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2433 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2434 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 },
2435 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2436 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
|optional
, 1 },
2437 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI child XP */
2438 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI client XP */
2440 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2441 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2442 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2443 { WM_MOVE
, sent
|defwinproc
},
2444 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2445 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI frame win2000 */
2447 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
2448 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2449 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
},
2450 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2452 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
},
2453 { WM_GETMINMAXINFO
, sent
|defwinproc
},
2454 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 },
2455 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
},
2456 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2457 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI child win2000 */
2458 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
|optional
, 1 },
2459 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI child XP */
2460 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI child XP */
2461 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI client XP */
2463 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
2464 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI frame XP */
2465 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI frame XP */
2466 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI child XP */
2469 /* ShowWindow(SW_MAXIMIZE) for a visible MDI child window */
2470 static const struct message WmMaximizeMDIchildVisibleSeq
[] = {
2471 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
2472 { WM_GETMINMAXINFO
, sent
},
2473 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|0x8000 },
2474 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2475 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2476 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|0x8000 },
2477 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2479 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2480 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2481 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2482 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2483 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2486 /* ShowWindow(SW_RESTORE) for a visible maximized MDI child window */
2487 static const struct message WmRestoreMDIchildVisibleSeq
[] = {
2488 { HCBT_MINMAX
, hook
|lparam
, 0, SW_RESTORE
},
2489 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|0x8000 },
2490 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2491 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2492 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|0x8000 },
2493 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2495 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2496 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2497 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2498 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2499 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2502 /* ShowWindow(SW_RESTORE) for a visible minimized MDI child window */
2503 static const struct message WmRestoreMDIchildVisibleSeq_2
[] = {
2504 { HCBT_MINMAX
, hook
|lparam
, 0, SW_RESTORE
},
2505 { WM_QUERYOPEN
, sent
|wparam
|lparam
, 0, 0 },
2506 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|0x8000 },
2507 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2508 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2509 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_NOCLIENTSIZE
|0x8000 },
2510 { WM_MOVE
, sent
|defwinproc
},
2511 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2512 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2513 { EVENT_SYSTEM_MINIMIZEEND
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2514 { HCBT_SETFOCUS
, hook
},
2515 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
2516 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
2517 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2518 { WM_SETFOCUS
, sent
},
2521 /* ShowWindow(SW_MINIMIZE) for a visible restored MDI child window */
2522 static const struct message WmMinimizeMDIchildVisibleSeq
[] = {
2523 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
2524 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOCOPYBITS
|0x8000 },
2525 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2526 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOCOPYBITS
|SWP_NOCLIENTSIZE
|0x8000 },
2527 { WM_MOVE
, sent
|defwinproc
},
2528 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MINIMIZED
},
2529 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
|defwinproc
, 0, 0 },
2530 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2531 { EVENT_SYSTEM_MINIMIZESTART
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2532 /* FIXME: Wine creates an icon/title window while Windows doesn't */
2533 { WM_PARENTNOTIFY
, sent
|parent
|wparam
|optional
, WM_CREATE
}, /* MDI client */
2536 /* ShowWindow(SW_RESTORE) for a not visible MDI child window */
2537 static const struct message WmRestoreMDIchildInisibleSeq
[] = {
2538 { HCBT_MINMAX
, hook
|lparam
, 0, SW_RESTORE
},
2539 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|0x8000 },
2540 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2541 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2542 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2543 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|0x8000 },
2544 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2546 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2547 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2548 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2549 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2550 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2554 static HWND mdi_client
;
2555 static WNDPROC old_mdi_client_proc
;
2557 static LRESULT WINAPI
mdi_client_hook_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
2561 /* do not log painting messages */
2562 if (message
!= WM_PAINT
&&
2563 message
!= WM_NCPAINT
&&
2564 message
!= WM_SYNCPAINT
&&
2565 message
!= WM_ERASEBKGND
&&
2566 message
!= WM_NCPAINT
&&
2567 message
!= WM_NCHITTEST
&&
2568 message
!= WM_GETTEXT
&&
2569 message
!= WM_MDIGETACTIVE
&&
2570 message
!= WM_GETICON
&&
2571 message
!= WM_DEVICECHANGE
)
2573 trace("mdi client: %p, %04x, %08lx, %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
);
2586 dump_winpos_flags(winpos
->flags
);
2588 /* Log only documented flags, win2k uses 0x1000 and 0x2000
2589 * in the high word for internal purposes
2591 wParam
= winpos
->flags
& 0xffff;
2592 /* We are not interested in the flags that don't match under XP and Win9x */
2593 wParam
&= ~(SWP_NOZORDER
);
2598 msg
.message
= message
;
2599 msg
.flags
= sent
|wparam
|lparam
;
2600 msg
.wParam
= wParam
;
2601 msg
.lParam
= lParam
;
2605 return CallWindowProcA(old_mdi_client_proc
, hwnd
, message
, wParam
, lParam
);
2608 static LRESULT WINAPI
mdi_child_wnd_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
2610 static long defwndproc_counter
= 0;
2614 /* do not log painting messages */
2615 if (message
!= WM_PAINT
&&
2616 message
!= WM_NCPAINT
&&
2617 message
!= WM_SYNCPAINT
&&
2618 message
!= WM_ERASEBKGND
&&
2619 message
!= WM_NCPAINT
&&
2620 message
!= WM_NCHITTEST
&&
2621 message
!= WM_GETTEXT
&&
2622 message
!= WM_GETICON
&&
2623 message
!= WM_DEVICECHANGE
)
2625 trace("mdi child: %p, %04x, %08lx, %08lx\n", hwnd
, message
, wParam
, lParam
);
2629 case WM_WINDOWPOSCHANGING
:
2630 case WM_WINDOWPOSCHANGED
:
2632 WINDOWPOS
*winpos
= (WINDOWPOS
*)lParam
;
2634 trace("%s\n", (message
== WM_WINDOWPOSCHANGING
) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
2635 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
2636 winpos
->hwnd
, winpos
->hwndInsertAfter
,
2637 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
2638 dump_winpos_flags(winpos
->flags
);
2640 /* Log only documented flags, win2k uses 0x1000 and 0x2000
2641 * in the high word for internal purposes
2643 wParam
= winpos
->flags
& 0xffff;
2644 /* We are not interested in the flags that don't match under XP and Win9x */
2645 wParam
&= ~(SWP_NOZORDER
);
2649 case WM_MDIACTIVATE
:
2651 HWND active
, client
= GetParent(hwnd
);
2653 active
= (HWND
)SendMessageA(client
, WM_MDIGETACTIVE
, 0, 0);
2655 if (hwnd
== (HWND
)lParam
) /* if we are being activated */
2656 ok (active
== (HWND
)lParam
, "new active %p != active %p\n", (HWND
)lParam
, active
);
2658 ok (active
== (HWND
)wParam
, "old active %p != active %p\n", (HWND
)wParam
, active
);
2663 msg
.message
= message
;
2664 msg
.flags
= sent
|wparam
|lparam
;
2665 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
2666 msg
.wParam
= wParam
;
2667 msg
.lParam
= lParam
;
2671 defwndproc_counter
++;
2672 ret
= DefMDIChildProcA(hwnd
, message
, wParam
, lParam
);
2673 defwndproc_counter
--;
2678 static LRESULT WINAPI
mdi_frame_wnd_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
2680 static long defwndproc_counter
= 0;
2684 /* do not log painting messages */
2685 if (message
!= WM_PAINT
&&
2686 message
!= WM_NCPAINT
&&
2687 message
!= WM_SYNCPAINT
&&
2688 message
!= WM_ERASEBKGND
&&
2689 message
!= WM_NCPAINT
&&
2690 message
!= WM_NCHITTEST
&&
2691 message
!= WM_GETTEXT
&&
2692 message
!= WM_GETICON
&&
2693 message
!= WM_DEVICECHANGE
)
2695 trace("mdi frame: %p, %04x, %08lx, %08lx\n", hwnd
, message
, wParam
, lParam
);
2699 case WM_WINDOWPOSCHANGING
:
2700 case WM_WINDOWPOSCHANGED
:
2702 WINDOWPOS
*winpos
= (WINDOWPOS
*)lParam
;
2704 trace("%s\n", (message
== WM_WINDOWPOSCHANGING
) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
2705 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
2706 winpos
->hwnd
, winpos
->hwndInsertAfter
,
2707 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
2708 dump_winpos_flags(winpos
->flags
);
2710 /* Log only documented flags, win2k uses 0x1000 and 0x2000
2711 * in the high word for internal purposes
2713 wParam
= winpos
->flags
& 0xffff;
2714 /* We are not interested in the flags that don't match under XP and Win9x */
2715 wParam
&= ~(SWP_NOZORDER
);
2720 msg
.message
= message
;
2721 msg
.flags
= sent
|wparam
|lparam
;
2722 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
2723 msg
.wParam
= wParam
;
2724 msg
.lParam
= lParam
;
2728 defwndproc_counter
++;
2729 ret
= DefFrameProcA(hwnd
, mdi_client
, message
, wParam
, lParam
);
2730 defwndproc_counter
--;
2735 static BOOL
mdi_RegisterWindowClasses(void)
2740 cls
.lpfnWndProc
= mdi_frame_wnd_proc
;
2743 cls
.hInstance
= GetModuleHandleA(0);
2745 cls
.hCursor
= LoadCursorA(0, (LPSTR
)IDC_ARROW
);
2746 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
2747 cls
.lpszMenuName
= NULL
;
2748 cls
.lpszClassName
= "MDI_frame_class";
2749 if (!RegisterClassA(&cls
)) return FALSE
;
2751 cls
.lpfnWndProc
= mdi_child_wnd_proc
;
2752 cls
.lpszClassName
= "MDI_child_class";
2753 if (!RegisterClassA(&cls
)) return FALSE
;
2755 if (!GetClassInfoA(0, "MDIClient", &cls
)) assert(0);
2756 old_mdi_client_proc
= cls
.lpfnWndProc
;
2757 cls
.hInstance
= GetModuleHandleA(0);
2758 cls
.lpfnWndProc
= mdi_client_hook_proc
;
2759 cls
.lpszClassName
= "MDI_client_class";
2760 if (!RegisterClassA(&cls
)) assert(0);
2765 static void test_mdi_messages(void)
2767 MDICREATESTRUCTA mdi_cs
;
2768 CLIENTCREATESTRUCT client_cs
;
2769 HWND mdi_frame
, mdi_child
, mdi_child2
, active_child
;
2771 HMENU hMenu
= CreateMenu();
2773 assert(mdi_RegisterWindowClasses());
2777 trace("creating MDI frame window\n");
2778 mdi_frame
= CreateWindowExA(0, "MDI_frame_class", "MDI frame window",
2779 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
|
2780 WS_MAXIMIZEBOX
| WS_VISIBLE
,
2781 100, 100, CW_USEDEFAULT
, CW_USEDEFAULT
,
2782 GetDesktopWindow(), hMenu
,
2783 GetModuleHandleA(0), NULL
);
2785 ok_sequence(WmCreateMDIframeSeq
, "Create MDI frame window", FALSE
);
2787 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
2788 ok(GetFocus() == mdi_frame
, "wrong focus window %p\n", GetFocus());
2790 trace("creating MDI client window\n");
2791 client_cs
.hWindowMenu
= 0;
2792 client_cs
.idFirstChild
= MDI_FIRST_CHILD_ID
;
2793 mdi_client
= CreateWindowExA(0, "MDI_client_class",
2795 WS_CHILD
| WS_VISIBLE
| MDIS_ALLCHILDSTYLES
,
2797 mdi_frame
, 0, GetModuleHandleA(0), &client_cs
);
2799 ok_sequence(WmCreateMDIclientSeq
, "Create visible MDI client window", FALSE
);
2801 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
2802 ok(GetFocus() == mdi_frame
, "input focus should be on MDI frame not on %p\n", GetFocus());
2804 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
2805 ok(!active_child
, "wrong active MDI child %p\n", active_child
);
2806 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
2811 trace("creating invisible MDI child window\n");
2812 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
2814 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
2815 mdi_client
, 0, GetModuleHandleA(0), NULL
);
2819 ShowWindow(mdi_child
, SW_SHOWNORMAL
);
2820 ok_sequence(WmShowChildSeq
, "ShowWindow(SW_SHOWNORMAL) MDI child window", FALSE
);
2822 ok(GetWindowLongA(mdi_child
, GWL_STYLE
) & WS_VISIBLE
, "MDI child should be visible\n");
2823 ok(IsWindowVisible(mdi_child
), "MDI child should be visible\n");
2825 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
2826 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2828 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
2829 ok(!active_child
, "wrong active MDI child %p\n", active_child
);
2830 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
2832 ShowWindow(mdi_child
, SW_HIDE
);
2833 ok_sequence(WmHideChildSeq
, "ShowWindow(SW_HIDE) MDI child window", FALSE
);
2836 ShowWindow(mdi_child
, SW_SHOW
);
2837 ok_sequence(WmShowChildSeq
, "ShowWindow(SW_SHOW) MDI child window", FALSE
);
2839 ok(GetWindowLongA(mdi_child
, GWL_STYLE
) & WS_VISIBLE
, "MDI child should be visible\n");
2840 ok(IsWindowVisible(mdi_child
), "MDI child should be visible\n");
2842 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
2843 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2845 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
2846 ok(!active_child
, "wrong active MDI child %p\n", active_child
);
2847 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
2849 DestroyWindow(mdi_child
);
2852 trace("creating visible MDI child window\n");
2853 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
2854 WS_CHILD
| WS_VISIBLE
,
2855 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
2856 mdi_client
, 0, GetModuleHandleA(0), NULL
);
2858 ok_sequence(WmCreateMDIchildVisibleSeq
, "Create visible MDI child window", FALSE
);
2860 ok(GetWindowLongA(mdi_child
, GWL_STYLE
) & WS_VISIBLE
, "MDI child should be visible\n");
2861 ok(IsWindowVisible(mdi_child
), "MDI child should be visible\n");
2863 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
2864 ok(GetFocus() == mdi_child
, "wrong focus window %p\n", GetFocus());
2866 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
2867 ok(active_child
== mdi_child
, "wrong active MDI child %p\n", active_child
);
2868 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
2871 DestroyWindow(mdi_child
);
2872 ok_sequence(WmDestroyMDIchildVisibleSeq
, "Destroy visible MDI child window", TRUE
);
2874 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
2875 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2877 /* Win2k: MDI client still returns a just destroyed child as active
2878 * Win9x: MDI client returns 0
2880 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
2881 ok(active_child
== mdi_child
|| /* win2k */
2882 !active_child
, /* win9x */
2883 "wrong active MDI child %p\n", active_child
);
2884 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
2888 trace("creating invisible MDI child window\n");
2889 mdi_child2
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
2891 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
2892 mdi_client
, 0, GetModuleHandleA(0), NULL
);
2894 ok_sequence(WmCreateMDIchildInvisibleSeq
, "Create invisible MDI child window", FALSE
);
2896 ok(!(GetWindowLongA(mdi_child2
, GWL_STYLE
) & WS_VISIBLE
), "MDI child should not be visible\n");
2897 ok(!IsWindowVisible(mdi_child2
), "MDI child should not be visible\n");
2899 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
2900 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2902 /* Win2k: MDI client still returns a just destroyed child as active
2903 * Win9x: MDI client returns mdi_child2
2905 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
2906 ok(active_child
== mdi_child
|| /* win2k */
2907 active_child
== mdi_child2
, /* win9x */
2908 "wrong active MDI child %p\n", active_child
);
2909 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
2912 ShowWindow(mdi_child2
, SW_MAXIMIZE
);
2913 ok_sequence(WmMaximizeMDIchildInvisibleSeq
, "ShowWindow(SW_MAXIMIZE):invisible MDI child", FALSE
);
2915 ok(GetWindowLongA(mdi_child2
, GWL_STYLE
) & WS_VISIBLE
, "MDI child should be visible\n");
2916 ok(IsWindowVisible(mdi_child2
), "MDI child should be visible\n");
2918 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
2919 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
2920 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
2923 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
2924 ok(GetFocus() == mdi_child2
|| /* win2k */
2925 GetFocus() == 0, /* win9x */
2926 "wrong focus window %p\n", GetFocus());
2931 ShowWindow(mdi_child2
, SW_HIDE
);
2932 ok_sequence(WmHideChildSeq
, "ShowWindow(SW_HIDE):MDI child", FALSE
);
2934 ShowWindow(mdi_child2
, SW_RESTORE
);
2935 ok_sequence(WmRestoreMDIchildInisibleSeq
, "ShowWindow(SW_RESTORE):invisible MDI child", FALSE
);
2938 ok(GetWindowLongA(mdi_child2
, GWL_STYLE
) & WS_VISIBLE
, "MDI child should be visible\n");
2939 ok(IsWindowVisible(mdi_child2
), "MDI child should be visible\n");
2941 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
2942 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
2943 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
2949 ShowWindow(mdi_child2
, SW_HIDE
);
2950 ok_sequence(WmHideChildSeq
, "ShowWindow(SW_HIDE):MDI child", FALSE
);
2952 ShowWindow(mdi_child2
, SW_SHOW
);
2953 ok_sequence(WmShowChildSeq
, "ShowWindow(SW_SHOW):MDI child", FALSE
);
2955 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
2956 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2958 ShowWindow(mdi_child2
, SW_MAXIMIZE
);
2959 ok_sequence(WmMaximizeMDIchildVisibleSeq
, "ShowWindow(SW_MAXIMIZE):MDI child", FALSE
);
2961 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
2962 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2964 ShowWindow(mdi_child2
, SW_RESTORE
);
2965 ok_sequence(WmRestoreMDIchildVisibleSeq
, "ShowWindow(SW_RESTORE):maximized MDI child", FALSE
);
2967 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
2968 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2970 ShowWindow(mdi_child2
, SW_MINIMIZE
);
2971 ok_sequence(WmMinimizeMDIchildVisibleSeq
, "ShowWindow(SW_MINIMIZE):MDI child", TRUE
);
2973 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
2974 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2976 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
2977 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
2978 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
2981 ShowWindow(mdi_child2
, SW_RESTORE
);
2982 ok_sequence(WmRestoreMDIchildVisibleSeq_2
, "ShowWindow(SW_RESTORE):minimized MDI child", TRUE
);
2984 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
2985 ok(GetFocus() == mdi_child2
, "wrong focus window %p\n", GetFocus());
2987 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
2988 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
2989 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
2995 ShowWindow(mdi_child2
, SW_HIDE
);
2996 ok_sequence(WmHideChildSeq
, "ShowWindow(SW_HIDE):MDI child", FALSE
);
2998 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
2999 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3001 DestroyWindow(mdi_child2
);
3002 ok_sequence(WmDestroyMDIchildInvisibleSeq
, "Destroy invisible MDI child window", FALSE
);
3004 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3005 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3007 /* test for maximized MDI children */
3008 trace("creating maximized visible MDI child window 1\n");
3009 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3010 WS_CHILD
| WS_VISIBLE
| WS_MAXIMIZEBOX
| WS_MAXIMIZE
,
3011 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
3012 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3014 ok_sequence(WmCreateMDIchildVisibleMaxSeq1
, "Create maximized visible 1st MDI child window", TRUE
);
3015 ok(IsZoomed(mdi_child
), "1st MDI child should be maximized\n");
3017 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3018 ok(GetFocus() == mdi_child
|| /* win2k */
3019 GetFocus() == 0, /* win9x */
3020 "wrong focus window %p\n", GetFocus());
3022 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3023 ok(active_child
== mdi_child
, "wrong active MDI child %p\n", active_child
);
3024 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
3027 trace("creating maximized visible MDI child window 2\n");
3028 mdi_child2
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3029 WS_CHILD
| WS_VISIBLE
| WS_MAXIMIZEBOX
| WS_MAXIMIZE
,
3030 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
3031 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3033 ok_sequence(WmCreateMDIchildVisibleMaxSeq2
, "Create maximized visible 2nd MDI child 2 window", TRUE
);
3034 ok(IsZoomed(mdi_child2
), "2nd MDI child should be maximized\n");
3035 ok(!IsZoomed(mdi_child
), "1st MDI child should NOT be maximized\n");
3037 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3038 ok(GetFocus() == mdi_child2
, "wrong focus window %p\n", GetFocus());
3040 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3041 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
3042 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
3045 trace("destroying maximized visible MDI child window 2\n");
3046 DestroyWindow(mdi_child2
);
3047 ok_sequence(WmDestroyMDIchildVisibleSeq
, "Destroy visible MDI child window", TRUE
);
3049 ok(!IsZoomed(mdi_child
), "1st MDI child should NOT be maximized\n");
3051 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3052 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3054 /* Win2k: MDI client still returns a just destroyed child as active
3055 * Win9x: MDI client returns 0
3057 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3058 ok(active_child
== mdi_child2
|| /* win2k */
3059 !active_child
, /* win9x */
3060 "wrong active MDI child %p\n", active_child
);
3063 ShowWindow(mdi_child
, SW_MAXIMIZE
);
3064 ok(IsZoomed(mdi_child
), "1st MDI child should be maximized\n");
3067 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3068 ok(GetFocus() == mdi_child
, "wrong focus window %p\n", GetFocus());
3070 trace("re-creating maximized visible MDI child window 2\n");
3071 mdi_child2
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3072 WS_CHILD
| WS_VISIBLE
| WS_MAXIMIZEBOX
| WS_MAXIMIZE
,
3073 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
3074 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3076 ok_sequence(WmCreateMDIchildVisibleMaxSeq2
, "Create maximized visible 2nd MDI child 2 window", TRUE
);
3077 ok(IsZoomed(mdi_child2
), "2nd MDI child should be maximized\n");
3078 ok(!IsZoomed(mdi_child
), "1st MDI child should NOT be maximized\n");
3080 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3081 ok(GetFocus() == mdi_child2
, "wrong focus window %p\n", GetFocus());
3083 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3084 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
3085 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
3088 SendMessageA(mdi_child2
, WM_SYSCOMMAND
, SC_CLOSE
, 0);
3089 ok_sequence(WmDestroyMDIchildVisibleMaxSeq2
, "WM_SYSCOMMAND/SC_CLOSE on a visible maximized MDI child window", TRUE
);
3090 ok(!IsWindow(mdi_child2
), "MDI child 2 should be destroyed\n");
3092 ok(IsZoomed(mdi_child
), "1st MDI child should be maximized\n");
3093 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3094 ok(GetFocus() == mdi_child
, "wrong focus window %p\n", GetFocus());
3096 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3097 ok(active_child
== mdi_child
, "wrong active MDI child %p\n", active_child
);
3098 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
3101 DestroyWindow(mdi_child
);
3102 ok_sequence(WmDestroyMDIchildVisibleSeq
, "Destroy visible MDI child window", TRUE
);
3104 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3105 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3107 /* Win2k: MDI client still returns a just destroyed child as active
3108 * Win9x: MDI client returns 0
3110 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3111 ok(active_child
== mdi_child
|| /* win2k */
3112 !active_child
, /* win9x */
3113 "wrong active MDI child %p\n", active_child
);
3116 trace("creating maximized invisible MDI child window\n");
3117 mdi_child2
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3118 WS_CHILD
| WS_MAXIMIZE
| WS_CAPTION
| WS_THICKFRAME
,
3119 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
3120 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3122 ok_sequence(WmCreateMDIchildInvisibleMaxSeq4
, "Create maximized invisible MDI child window", TRUE
);
3123 ok(IsZoomed(mdi_child2
), "MDI child should be maximized\n");
3124 ok(!(GetWindowLongA(mdi_child2
, GWL_STYLE
) & WS_VISIBLE
), "MDI child should be not visible\n");
3125 ok(!IsWindowVisible(mdi_child2
), "MDI child should be not visible\n");
3127 /* Win2k: MDI client still returns a just destroyed child as active
3128 * Win9x: MDI client returns 0
3130 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3131 ok(active_child
== mdi_child
|| /* win2k */
3132 !active_child
, /* win9x */
3133 "wrong active MDI child %p\n", active_child
);
3136 trace("call ShowWindow(mdi_child, SW_MAXIMIZE)\n");
3137 ShowWindow(mdi_child2
, SW_MAXIMIZE
);
3138 ok_sequence(WmMaximizeMDIchildInvisibleSeq2
, "ShowWindow(SW_MAXIMIZE):invisible maximized MDI child", FALSE
);
3139 ok(IsZoomed(mdi_child2
), "MDI child should be maximized\n");
3140 ok(GetWindowLongA(mdi_child2
, GWL_STYLE
) & WS_VISIBLE
, "MDI child should be visible\n");
3141 ok(IsWindowVisible(mdi_child2
), "MDI child should be visible\n");
3143 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3144 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
3145 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
3148 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child2
, 0);
3151 /* end of test for maximized MDI children */
3153 mdi_cs
.szClass
= "MDI_child_Class";
3154 mdi_cs
.szTitle
= "MDI child";
3155 mdi_cs
.hOwner
= GetModuleHandleA(0);
3158 mdi_cs
.cx
= CW_USEDEFAULT
;
3159 mdi_cs
.cy
= CW_USEDEFAULT
;
3160 mdi_cs
.style
= WS_CHILD
| WS_SYSMENU
| WS_VISIBLE
| WS_MAXIMIZEBOX
| WS_MAXIMIZE
;
3162 mdi_child
= (HWND
)SendMessageA(mdi_client
, WM_MDICREATE
, 0, (LPARAM
)&mdi_cs
);
3163 ok(mdi_child
!= 0, "MDI child creation failed\n");
3164 ok_sequence(WmCreateMDIchildVisibleMaxSeq3
, "WM_MDICREATE for maximized visible MDI child window", TRUE
);
3166 ok(GetMenuItemID(hMenu
, GetMenuItemCount(hMenu
) - 1) == SC_CLOSE
, "SC_CLOSE menu item not found\n");
3168 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3169 ok(active_child
== mdi_child
, "wrong active MDI child %p\n", active_child
);
3171 ok(IsZoomed(mdi_child
), "MDI child should be maximized\n");
3172 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3173 ok(GetFocus() == mdi_child
, "wrong focus window %p\n", GetFocus());
3175 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3176 ok(active_child
== mdi_child
, "wrong active MDI child %p\n", active_child
);
3177 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
3180 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
3181 ok_sequence(WmDestroyMDIchildVisibleMaxSeq1
, "Destroy visible maximized MDI child window", TRUE
);
3183 ok(!IsWindow(mdi_child
), "MDI child should be destroyed\n");
3184 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3185 ok(!active_child
, "wrong active MDI child %p\n", active_child
);
3190 DestroyWindow(mdi_client
);
3191 ok_sequence(WmDestroyMDIclientSeq
, "Destroy MDI client window", FALSE
);
3193 /* test maximization of MDI child with invisible parent */
3194 client_cs
.hWindowMenu
= 0;
3195 mdi_client
= CreateWindow("MDI_client_class",
3197 WS_CHILD
| WS_CLIPCHILDREN
| WS_VSCROLL
| WS_HSCROLL
| WS_VISIBLE
,
3199 mdi_frame
, 0, GetModuleHandleA(0), &client_cs
);
3200 ok_sequence(WmCreateMDIclientSeq
, "Create MDI client window", FALSE
);
3202 ShowWindow(mdi_client
, SW_HIDE
);
3203 ok_sequence(WmHideMDIclientSeq
, "Hide MDI client window", FALSE
);
3205 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3206 WS_CHILD
| WS_CLIPCHILDREN
| WS_VSCROLL
| WS_HSCROLL
,
3208 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3209 ok_sequence(WmCreateMDIchildInvisibleParentSeq
, "Create MDI child window with invisible parent", FALSE
);
3211 SendMessage(mdi_client
, WM_MDIMAXIMIZE
, (WPARAM
) mdi_child
, 0);
3212 ok_sequence(WmMaximizeMDIchildInvisibleParentSeq
, "Maximize MDI child window with invisible parent", TRUE
);
3213 zoomed
= IsZoomed(mdi_child
);
3214 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
3216 ShowWindow(mdi_client
, SW_SHOW
);
3217 ok_sequence(WmShowMDIclientSeq
, "Show MDI client window", FALSE
);
3219 DestroyWindow(mdi_child
);
3220 ok_sequence(WmDestroyMDIchildVisibleSeq
, "Destroy visible maximized MDI child window", TRUE
);
3222 /* end of test for maximization of MDI child with invisible parent */
3224 /* test for switch maximized MDI children */
3225 trace("creating maximized visible MDI child window 1(Switch test)\n");
3226 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3227 WS_CHILD
| WS_VISIBLE
| WS_MAXIMIZEBOX
| WS_MAXIMIZE
,
3228 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
3229 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3231 ok_sequence(WmCreateMDIchildVisibleMaxSeq1
, "Create maximized visible 1st MDI child window(Switch test)", TRUE
);
3232 ok(IsZoomed(mdi_child
), "1st MDI child should be maximized(Switch test)\n");
3234 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p(Switch test)\n", GetActiveWindow());
3235 ok(GetFocus() == mdi_child
|| /* win2k */
3236 GetFocus() == 0, /* win9x */
3237 "wrong focus window %p(Switch test)\n", GetFocus());
3239 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3240 ok(active_child
== mdi_child
, "wrong active MDI child %p(Switch test)\n", active_child
);
3241 ok(zoomed
, "wrong zoomed state %d(Switch test)\n", zoomed
);
3244 trace("creating maximized visible MDI child window 2(Switch test)\n");
3245 mdi_child2
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3246 WS_CHILD
| WS_VISIBLE
| WS_MAXIMIZEBOX
| WS_MAXIMIZE
,
3247 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
3248 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3250 ok_sequence(WmCreateMDIchildVisibleMaxSeq2
, "Create maximized visible 2nd MDI child 2 window(Switch test)\n", TRUE
);
3251 ok(IsZoomed(mdi_child2
), "2nd MDI child should be maximized(Switch test)\n");
3252 ok(!IsZoomed(mdi_child
), "1st MDI child should NOT be maximized(Switch test)\n");
3254 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p(Switch test)\n", GetActiveWindow());
3255 ok(GetFocus() == mdi_child2
, "wrong focus window %p(Switch test)\n", GetFocus());
3257 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3258 ok(active_child
== mdi_child2
, "wrong active MDI child %p(Switch test)\n", active_child
);
3259 ok(zoomed
, "wrong zoomed state %d(Switch test)\n", zoomed
);
3262 trace("Switch child window.\n");
3263 SendMessageA(mdi_client
, WM_MDIACTIVATE
, (WPARAM
)mdi_child
, 0);
3264 ok_sequence(WmSwitchChild
,"Child not switch correctly\n",TRUE
);
3266 trace("end of test for switch maximized MDI children\n");
3268 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
3271 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child2
, 0);
3274 /* end of test for switch maximized MDI children */
3276 DestroyWindow(mdi_client
);
3277 ok_sequence(WmDestroyMDIclientSeq
, "Destroy MDI client window", FALSE
);
3279 DestroyWindow(mdi_frame
);
3280 ok_sequence(WmDestroyMDIframeSeq
, "Destroy MDI frame window", FALSE
);
3282 /************************* End of MDI test **********************************/
3284 static void test_WM_SETREDRAW(HWND hwnd
)
3286 DWORD style
= GetWindowLongA(hwnd
, GWL_STYLE
);
3290 SendMessageA(hwnd
, WM_SETREDRAW
, FALSE
, 0);
3291 ok_sequence(WmSetRedrawFalseSeq
, "SetRedraw:FALSE", FALSE
);
3293 ok(!(GetWindowLongA(hwnd
, GWL_STYLE
) & WS_VISIBLE
), "WS_VISIBLE should NOT be set\n");
3294 ok(!IsWindowVisible(hwnd
), "IsWindowVisible() should return FALSE\n");
3297 SendMessageA(hwnd
, WM_SETREDRAW
, TRUE
, 0);
3298 ok_sequence(WmSetRedrawTrueSeq
, "SetRedraw:TRUE", FALSE
);
3300 ok(GetWindowLongA(hwnd
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
3301 ok(IsWindowVisible(hwnd
), "IsWindowVisible() should return TRUE\n");
3303 /* restore original WS_VISIBLE state */
3304 SetWindowLongA(hwnd
, GWL_STYLE
, style
);
3309 static INT_PTR CALLBACK
TestModalDlgProcA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
3313 trace("dialog: %p, %04x, %08lx, %08lx\n", hwnd
, message
, wParam
, lParam
);
3315 /* explicitly ignore WM_GETICON message */
3316 if (message
== WM_GETICON
) return 0;
3323 case WM_DEVICECHANGE
:
3328 case WM_WINDOWPOSCHANGING
:
3329 case WM_WINDOWPOSCHANGED
:
3331 WINDOWPOS
*winpos
= (WINDOWPOS
*)lParam
;
3333 trace("%s\n", (message
== WM_WINDOWPOSCHANGING
) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
3334 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
3335 winpos
->hwnd
, winpos
->hwndInsertAfter
,
3336 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
3337 dump_winpos_flags(winpos
->flags
);
3339 /* Log only documented flags, win2k uses 0x1000 and 0x2000
3340 * in the high word for internal purposes
3342 wParam
= winpos
->flags
& 0xffff;
3343 /* We are not interested in the flags that don't match under XP and Win9x */
3344 wParam
&= ~(SWP_NOZORDER
);
3349 msg
.message
= message
;
3350 msg
.flags
= sent
|wparam
|lparam
;
3351 msg
.wParam
= wParam
;
3352 msg
.lParam
= lParam
;
3355 if (message
== WM_INITDIALOG
) SetTimer( hwnd
, 1, 100, NULL
);
3356 if (message
== WM_TIMER
) EndDialog( hwnd
, 0 );
3360 static void test_hv_scroll_1(HWND hwnd
, INT ctl
, DWORD clear
, DWORD set
, INT min
, INT max
)
3362 DWORD style
, exstyle
;
3366 exstyle
= GetWindowLongA(hwnd
, GWL_EXSTYLE
);
3367 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
3368 /* do not be confused by WS_DLGFRAME set */
3369 if ((style
& WS_CAPTION
) == WS_CAPTION
) style
&= ~WS_CAPTION
;
3371 if (clear
) ok(style
& clear
, "style %08x should be set\n", clear
);
3372 if (set
) ok(!(style
& set
), "style %08x should not be set\n", set
);
3374 ret
= SetScrollRange(hwnd
, ctl
, min
, max
, FALSE
);
3375 ok( ret
, "SetScrollRange(%d) error %d\n", ctl
, GetLastError());
3376 if ((style
& (WS_DLGFRAME
| WS_BORDER
| WS_THICKFRAME
)) || (exstyle
& WS_EX_DLGMODALFRAME
))
3377 ok_sequence(WmSetScrollRangeHV_NC_Seq
, "SetScrollRange(SB_HORZ/SB_VERT) NC", FALSE
);
3379 ok_sequence(WmSetScrollRangeHVSeq
, "SetScrollRange(SB_HORZ/SB_VERT)", FALSE
);
3381 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
3382 if (set
) ok(style
& set
, "style %08x should be set\n", set
);
3383 if (clear
) ok(!(style
& clear
), "style %08x should not be set\n", clear
);
3385 /* a subsequent call should do nothing */
3386 ret
= SetScrollRange(hwnd
, ctl
, min
, max
, FALSE
);
3387 ok( ret
, "SetScrollRange(%d) error %d\n", ctl
, GetLastError());
3388 ok_sequence(WmEmptySeq
, "SetScrollRange(SB_HORZ/SB_VERT) empty sequence", FALSE
);
3392 trace("Ignore GetScrollRange error below if you are on Win9x\n");
3393 ret
= GetScrollRange(hwnd
, ctl
, &xmin
, &xmax
);
3394 ok( ret
, "GetScrollRange(%d) error %d\n", ctl
, GetLastError());
3395 ok_sequence(WmEmptySeq
, "GetScrollRange(SB_HORZ/SB_VERT) empty sequence", FALSE
);
3396 ok(xmin
== min
, "unexpected min scroll value %d\n", xmin
);
3397 ok(xmax
== max
, "unexpected max scroll value %d\n", xmax
);
3400 static void test_hv_scroll_2(HWND hwnd
, INT ctl
, DWORD clear
, DWORD set
, INT min
, INT max
)
3402 DWORD style
, exstyle
;
3406 exstyle
= GetWindowLongA(hwnd
, GWL_EXSTYLE
);
3407 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
3408 /* do not be confused by WS_DLGFRAME set */
3409 if ((style
& WS_CAPTION
) == WS_CAPTION
) style
&= ~WS_CAPTION
;
3411 if (clear
) ok(style
& clear
, "style %08x should be set\n", clear
);
3412 if (set
) ok(!(style
& set
), "style %08x should not be set\n", set
);
3414 si
.cbSize
= sizeof(si
);
3415 si
.fMask
= SIF_RANGE
;
3418 SetScrollInfo(hwnd
, ctl
, &si
, TRUE
);
3419 if ((style
& (WS_DLGFRAME
| WS_BORDER
| WS_THICKFRAME
)) || (exstyle
& WS_EX_DLGMODALFRAME
))
3420 ok_sequence(WmSetScrollRangeHV_NC_Seq
, "SetScrollInfo(SB_HORZ/SB_VERT) NC", FALSE
);
3422 ok_sequence(WmSetScrollRangeHVSeq
, "SetScrollInfo(SB_HORZ/SB_VERT)", FALSE
);
3424 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
3425 if (set
) ok(style
& set
, "style %08x should be set\n", set
);
3426 if (clear
) ok(!(style
& clear
), "style %08x should not be set\n", clear
);
3428 /* a subsequent call should do nothing */
3429 SetScrollInfo(hwnd
, ctl
, &si
, TRUE
);
3430 if (style
& WS_HSCROLL
)
3431 ok_sequence(WmSetScrollRangeHSeq_empty
, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE
);
3432 else if (style
& WS_VSCROLL
)
3433 ok_sequence(WmSetScrollRangeVSeq_empty
, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE
);
3435 ok_sequence(WmEmptySeq
, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE
);
3437 si
.fMask
= SIF_PAGE
;
3439 SetScrollInfo(hwnd
, ctl
, &si
, FALSE
);
3440 ok_sequence(WmEmptySeq
, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE
);
3444 SetScrollInfo(hwnd
, ctl
, &si
, FALSE
);
3445 ok_sequence(WmEmptySeq
, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE
);
3447 si
.fMask
= SIF_RANGE
;
3448 si
.nMin
= 0xdeadbeef;
3449 si
.nMax
= 0xdeadbeef;
3450 ret
= GetScrollInfo(hwnd
, ctl
, &si
);
3451 ok( ret
, "GetScrollInfo error %d\n", GetLastError());
3452 ok_sequence(WmEmptySeq
, "GetScrollRange(SB_HORZ/SB_VERT) empty sequence", FALSE
);
3453 ok(si
.nMin
== min
, "unexpected min scroll value %d\n", si
.nMin
);
3454 ok(si
.nMax
== max
, "unexpected max scroll value %d\n", si
.nMax
);
3457 /* Win9x sends WM_USER+xxx while and NT versions send SBM_xxx messages */
3458 static void test_scroll_messages(HWND hwnd
)
3466 ret
= GetScrollRange(hwnd
, SB_CTL
, &min
, &max
);
3467 ok( ret
, "GetScrollRange error %d\n", GetLastError());
3468 if (sequence
->message
!= WmGetScrollRangeSeq
[0].message
)
3469 trace("GetScrollRange(SB_CTL) generated unknown message %04x\n", sequence
->message
);
3470 /* values of min and max are undefined */
3473 ret
= SetScrollRange(hwnd
, SB_CTL
, 10, 150, FALSE
);
3474 ok( ret
, "SetScrollRange error %d\n", GetLastError());
3475 if (sequence
->message
!= WmSetScrollRangeSeq
[0].message
)
3476 trace("SetScrollRange(SB_CTL) generated unknown message %04x\n", sequence
->message
);
3481 ret
= GetScrollRange(hwnd
, SB_CTL
, &min
, &max
);
3482 ok( ret
, "GetScrollRange error %d\n", GetLastError());
3483 if (sequence
->message
!= WmGetScrollRangeSeq
[0].message
)
3484 trace("GetScrollRange(SB_CTL) generated unknown message %04x\n", sequence
->message
);
3485 /* values of min and max are undefined */
3488 si
.cbSize
= sizeof(si
);
3489 si
.fMask
= SIF_RANGE
;
3492 SetScrollInfo(hwnd
, SB_CTL
, &si
, FALSE
);
3493 if (sequence
->message
!= WmSetScrollRangeSeq
[0].message
)
3494 trace("SetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence
->message
);
3497 si
.fMask
= SIF_PAGE
;
3499 SetScrollInfo(hwnd
, SB_CTL
, &si
, FALSE
);
3500 if (sequence
->message
!= WmSetScrollRangeSeq
[0].message
)
3501 trace("SetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence
->message
);
3506 SetScrollInfo(hwnd
, SB_CTL
, &si
, FALSE
);
3507 if (sequence
->message
!= WmSetScrollRangeSeq
[0].message
)
3508 trace("SetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence
->message
);
3511 si
.fMask
= SIF_RANGE
;
3512 si
.nMin
= 0xdeadbeef;
3513 si
.nMax
= 0xdeadbeef;
3514 ret
= GetScrollInfo(hwnd
, SB_CTL
, &si
);
3515 ok( ret
, "GetScrollInfo error %d\n", GetLastError());
3516 if (sequence
->message
!= WmGetScrollInfoSeq
[0].message
)
3517 trace("GetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence
->message
);
3518 /* values of min and max are undefined */
3521 /* set WS_HSCROLL */
3522 test_hv_scroll_1(hwnd
, SB_HORZ
, 0, WS_HSCROLL
, 10, 150);
3523 /* clear WS_HSCROLL */
3524 test_hv_scroll_1(hwnd
, SB_HORZ
, WS_HSCROLL
, 0, 0, 0);
3526 /* set WS_HSCROLL */
3527 test_hv_scroll_2(hwnd
, SB_HORZ
, 0, WS_HSCROLL
, 10, 150);
3528 /* clear WS_HSCROLL */
3529 test_hv_scroll_2(hwnd
, SB_HORZ
, WS_HSCROLL
, 0, 0, 0);
3531 /* set WS_VSCROLL */
3532 test_hv_scroll_1(hwnd
, SB_VERT
, 0, WS_VSCROLL
, 10, 150);
3533 /* clear WS_VSCROLL */
3534 test_hv_scroll_1(hwnd
, SB_VERT
, WS_VSCROLL
, 0, 0, 0);
3536 /* set WS_VSCROLL */
3537 test_hv_scroll_2(hwnd
, SB_VERT
, 0, WS_VSCROLL
, 10, 150);
3538 /* clear WS_VSCROLL */
3539 test_hv_scroll_2(hwnd
, SB_VERT
, WS_VSCROLL
, 0, 0, 0);
3542 static void test_showwindow(void)
3547 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW
,
3548 100, 100, 200, 200, 0, 0, 0, NULL
);
3549 ok (hwnd
!= 0, "Failed to create overlapped window\n");
3550 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
3551 0, 0, 10, 10, hwnd
, 0, 0, NULL
);
3552 ok (hchild
!= 0, "Failed to create child\n");
3555 /* ShowWindow( SW_SHOWNA) for invisible top level window */
3556 trace("calling ShowWindow( SW_SHOWNA) for invisible top level window\n");
3557 ok( ShowWindow(hwnd
, SW_SHOWNA
) == FALSE
, "ShowWindow: window was visible\n" );
3558 ok_sequence(WmSHOWNATopInvisible
, "ShowWindow(SW_SHOWNA) on invisible top level window", TRUE
);
3561 /* ShowWindow( SW_SHOWNA) for now visible top level window */
3562 trace("calling ShowWindow( SW_SHOWNA) for now visible top level window\n");
3563 ok( ShowWindow(hwnd
, SW_SHOWNA
) != FALSE
, "ShowWindow: window was invisible\n" );
3564 ok_sequence(WmSHOWNATopVisible
, "ShowWindow(SW_SHOWNA) on visible top level window", FALSE
);
3566 /* back to invisible */
3567 ShowWindow(hchild
, SW_HIDE
);
3568 ShowWindow(hwnd
, SW_HIDE
);
3570 /* ShowWindow(SW_SHOWNA) with child and parent invisible */
3571 trace("calling ShowWindow( SW_SHOWNA) for invisible child with invisible parent\n");
3572 ok( ShowWindow(hchild
, SW_SHOWNA
) == FALSE
, "ShowWindow: window was visible\n" );
3573 ok_sequence(WmSHOWNAChildInvisParInvis
, "ShowWindow(SW_SHOWNA) invisible child and parent", FALSE
);
3575 /* ShowWindow(SW_SHOWNA) with child visible and parent invisible */
3576 ok( ShowWindow(hchild
, SW_SHOW
) != FALSE
, "ShowWindow: window was invisible\n" );
3578 trace("calling ShowWindow( SW_SHOWNA) for the visible child and invisible parent\n");
3579 ok( ShowWindow(hchild
, SW_SHOWNA
) != FALSE
, "ShowWindow: window was invisible\n" );
3580 ok_sequence(WmSHOWNAChildVisParInvis
, "ShowWindow(SW_SHOWNA) visible child and invisible parent", FALSE
);
3582 /* ShowWindow(SW_SHOWNA) with child visible and parent visible */
3583 ShowWindow( hwnd
, SW_SHOW
);
3585 trace("calling ShowWindow( SW_SHOWNA) for the visible child and parent\n");
3586 ok( ShowWindow(hchild
, SW_SHOWNA
) != FALSE
, "ShowWindow: window was invisible\n" );
3587 ok_sequence(WmSHOWNAChildVisParVis
, "ShowWindow(SW_SHOWNA) for the visible child and parent", FALSE
);
3590 /* ShowWindow(SW_SHOWNA) with child invisible and parent visible */
3591 ShowWindow( hchild
, SW_HIDE
);
3593 trace("calling ShowWindow( SW_SHOWNA) for the invisible child and visible parent\n");
3594 ok( ShowWindow(hchild
, SW_SHOWNA
) == FALSE
, "ShowWindow: window was visible\n" );
3595 ok_sequence(WmSHOWNAChildInvisParVis
, "ShowWindow(SW_SHOWNA) for the invisible child and visible parent", FALSE
);
3599 ok(GetCapture() == hchild
, "wrong capture window %p\n", GetCapture());
3600 DestroyWindow(hchild
);
3601 ok(!GetCapture(), "wrong capture window %p\n", GetCapture());
3603 DestroyWindow(hwnd
);
3608 * 1. Create invisible maximized popup window.
3609 * 2. Move and resize it.
3610 * 3. Show it maximized.
3612 trace("calling CreateWindowExA( WS_MAXIMIZE ) for invisible maximized popup window\n");
3613 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP
| WS_MAXIMIZE
,
3614 100, 100, 200, 200, 0, 0, 0, NULL
);
3615 ok (hwnd
!= 0, "Failed to create popup window\n");
3616 ok(IsZoomed(hwnd
), "window should be maximized\n");
3617 ok_sequence(WmCreateInvisibleMaxPopupSeq
, "CreateWindow(WS_MAXIMIZED):popup", FALSE
);
3620 GetWindowRect(hwnd
, &rc
);
3621 ok( rc
.right
-rc
.left
== GetSystemMetrics(SM_CXSCREEN
) &&
3622 rc
.bottom
-rc
.top
== GetSystemMetrics(SM_CYSCREEN
),
3623 "Invalid maximized size before ShowWindow (%d,%d)-(%d,%d)\n",
3624 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
3625 /* Reset window's size & position */
3626 SetWindowPos(hwnd
, 0, 10, 10, 200, 200, SWP_NOZORDER
| SWP_NOACTIVATE
);
3627 ok(IsZoomed(hwnd
), "window should be maximized\n");
3630 trace("calling ShowWindow( SW_SHOWMAXIMIZE ) for invisible maximized popup window\n");
3631 ShowWindow(hwnd
, SW_SHOWMAXIMIZED
);
3632 ok(IsZoomed(hwnd
), "window should be maximized\n");
3633 ok_sequence(WmShowMaxPopupResizedSeq
, "ShowWindow(SW_SHOWMAXIMIZED):invisible maximized and resized popup", FALSE
);
3636 GetWindowRect(hwnd
, &rc
);
3637 ok( rc
.right
-rc
.left
== GetSystemMetrics(SM_CXSCREEN
) &&
3638 rc
.bottom
-rc
.top
== GetSystemMetrics(SM_CYSCREEN
),
3639 "Invalid maximized size after ShowWindow (%d,%d)-(%d,%d)\n",
3640 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
3641 DestroyWindow(hwnd
);
3645 * 1. Create invisible maximized popup window.
3646 * 2. Show it maximized.
3648 trace("calling CreateWindowExA( WS_MAXIMIZE ) for invisible maximized popup window\n");
3649 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP
| WS_MAXIMIZE
,
3650 100, 100, 200, 200, 0, 0, 0, NULL
);
3651 ok (hwnd
!= 0, "Failed to create popup window\n");
3652 ok(IsZoomed(hwnd
), "window should be maximized\n");
3653 ok_sequence(WmCreateInvisibleMaxPopupSeq
, "CreateWindow(WS_MAXIMIZED):popup", FALSE
);
3656 trace("calling ShowWindow( SW_SHOWMAXIMIZE ) for invisible maximized popup window\n");
3657 ShowWindow(hwnd
, SW_SHOWMAXIMIZED
);
3658 ok(IsZoomed(hwnd
), "window should be maximized\n");
3659 ok_sequence(WmShowMaxPopupSeq
, "ShowWindow(SW_SHOWMAXIMIZED):invisible maximized popup", FALSE
);
3661 DestroyWindow(hwnd
);
3665 * 1. Create visible maximized popup window.
3667 trace("calling CreateWindowExA( WS_MAXIMIZE ) for maximized popup window\n");
3668 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP
| WS_MAXIMIZE
| WS_VISIBLE
,
3669 100, 100, 200, 200, 0, 0, 0, NULL
);
3670 ok (hwnd
!= 0, "Failed to create popup window\n");
3671 ok(IsZoomed(hwnd
), "window should be maximized\n");
3672 ok_sequence(WmCreateMaxPopupSeq
, "CreateWindow(WS_MAXIMIZED):popup", FALSE
);
3674 DestroyWindow(hwnd
);
3678 * 1. Create visible popup window.
3681 trace("calling CreateWindowExA( WS_VISIBLE ) for popup window\n");
3682 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP
| WS_VISIBLE
,
3683 100, 100, 200, 200, 0, 0, 0, NULL
);
3684 ok (hwnd
!= 0, "Failed to create popup window\n");
3685 ok(!IsZoomed(hwnd
), "window should NOT be maximized\n");
3686 ok_sequence(WmCreatePopupSeq
, "CreateWindow(WS_VISIBLE):popup", TRUE
);
3689 trace("calling ShowWindow( SW_SHOWMAXIMIZE ) for visible popup window\n");
3690 ShowWindow(hwnd
, SW_SHOWMAXIMIZED
);
3691 ok(IsZoomed(hwnd
), "window should be maximized\n");
3692 ok_sequence(WmShowVisMaxPopupSeq
, "ShowWindow(SW_SHOWMAXIMIZED):popup", FALSE
);
3694 DestroyWindow(hwnd
);
3698 static void test_sys_menu(void)
3704 hwnd
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
3705 100, 100, 200, 200, 0, 0, 0, NULL
);
3706 ok (hwnd
!= 0, "Failed to create overlapped window\n");
3710 /* test existing window without CS_NOCLOSE style */
3711 hmenu
= GetSystemMenu(hwnd
, FALSE
);
3712 ok(hmenu
!= 0, "GetSystemMenu error %d\n", GetLastError());
3714 state
= GetMenuState(hmenu
, SC_CLOSE
, MF_BYCOMMAND
);
3715 ok(state
!= 0xffffffff, "wrong SC_CLOSE state %x\n", state
);
3716 ok(!(state
& (MF_DISABLED
| MF_GRAYED
)), "wrong SC_CLOSE state %x\n", state
);
3718 EnableMenuItem(hmenu
, SC_CLOSE
, MF_BYCOMMAND
| MF_GRAYED
);
3719 ok_sequence(WmEmptySeq
, "WmEnableMenuItem", FALSE
);
3721 state
= GetMenuState(hmenu
, SC_CLOSE
, MF_BYCOMMAND
);
3722 ok(state
!= 0xffffffff, "wrong SC_CLOSE state %x\n", state
);
3723 ok((state
& (MF_DISABLED
| MF_GRAYED
)) == MF_GRAYED
, "wrong SC_CLOSE state %x\n", state
);
3725 EnableMenuItem(hmenu
, SC_CLOSE
, 0);
3726 ok_sequence(WmEmptySeq
, "WmEnableMenuItem", FALSE
);
3728 state
= GetMenuState(hmenu
, SC_CLOSE
, MF_BYCOMMAND
);
3729 ok(state
!= 0xffffffff, "wrong SC_CLOSE state %x\n", state
);
3730 ok(!(state
& (MF_DISABLED
| MF_GRAYED
)), "wrong SC_CLOSE state %x\n", state
);
3732 /* test whether removing WS_SYSMENU destroys a system menu */
3733 SetWindowLongW(hwnd
, GWL_STYLE
, WS_POPUP
);
3734 SetWindowPos(hwnd
, 0, 0, 0, 0, 0, SWP_NOZORDER
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_FRAMECHANGED
);
3736 hmenu
= GetSystemMenu(hwnd
, FALSE
);
3737 ok(hmenu
!= 0, "GetSystemMenu error %d\n", GetLastError());
3739 DestroyWindow(hwnd
);
3741 /* test new window with CS_NOCLOSE style */
3742 hwnd
= CreateWindowExA(0, "NoCloseWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
3743 100, 100, 200, 200, 0, 0, 0, NULL
);
3744 ok (hwnd
!= 0, "Failed to create overlapped window\n");
3746 hmenu
= GetSystemMenu(hwnd
, FALSE
);
3747 ok(hmenu
!= 0, "GetSystemMenu error %d\n", GetLastError());
3749 state
= GetMenuState(hmenu
, SC_CLOSE
, MF_BYCOMMAND
);
3750 ok(state
== 0xffffffff, "wrong SC_CLOSE state %x\n", state
);
3752 DestroyWindow(hwnd
);
3754 /* test new window without WS_SYSMENU style */
3755 hwnd
= CreateWindowExA(0, "NoCloseWindowClass", NULL
, WS_OVERLAPPEDWINDOW
& ~WS_SYSMENU
,
3756 100, 100, 200, 200, 0, 0, 0, NULL
);
3757 ok(hwnd
!= 0, "Failed to create overlapped window\n");
3759 hmenu
= GetSystemMenu(hwnd
, FALSE
);
3760 ok(!hmenu
, "GetSystemMenu error %d\n", GetLastError());
3762 DestroyWindow(hwnd
);
3765 /* For shown WS_OVERLAPPEDWINDOW */
3766 static const struct message WmSetIcon_1
[] = {
3767 { WM_SETICON
, sent
},
3768 { 0x00AE, sent
|defwinproc
|optional
}, /* XP */
3769 { WM_GETTEXT
, sent
|defwinproc
|optional
},
3770 { WM_GETTEXT
, sent
|defwinproc
|optional
}, /* XP sends a duplicate */
3774 /* For WS_POPUP and hidden WS_OVERLAPPEDWINDOW */
3775 static const struct message WmSetIcon_2
[] = {
3776 { WM_SETICON
, sent
},
3780 static void test_MsgWaitForMultipleObjects(HWND hwnd
)
3785 ret
= MsgWaitForMultipleObjects(0, NULL
, FALSE
, 0, QS_POSTMESSAGE
);
3786 ok(ret
== WAIT_TIMEOUT
, "MsgWaitForMultipleObjects returned %x\n", ret
);
3788 PostMessageA(hwnd
, WM_USER
, 0, 0);
3790 ret
= MsgWaitForMultipleObjects(0, NULL
, FALSE
, 0, QS_POSTMESSAGE
);
3791 ok(ret
== WAIT_OBJECT_0
, "MsgWaitForMultipleObjects returned %x\n", ret
);
3793 ok(PeekMessageW( &msg
, 0, 0, 0, PM_REMOVE
), "PeekMessage should succeed\n");
3794 ok(msg
.message
== WM_USER
, "got %04x instead of WM_USER\n", msg
.message
);
3796 ret
= MsgWaitForMultipleObjects(0, NULL
, FALSE
, 0, QS_POSTMESSAGE
);
3797 ok(ret
== WAIT_TIMEOUT
, "MsgWaitForMultipleObjects returned %x\n", ret
);
3799 PostMessageA(hwnd
, WM_USER
, 0, 0);
3801 ret
= MsgWaitForMultipleObjects(0, NULL
, FALSE
, 0, QS_POSTMESSAGE
);
3802 ok(ret
== WAIT_OBJECT_0
, "MsgWaitForMultipleObjects returned %x\n", ret
);
3804 ok(PeekMessageW( &msg
, 0, 0, 0, PM_NOREMOVE
), "PeekMessage should succeed\n");
3805 ok(msg
.message
== WM_USER
, "got %04x instead of WM_USER\n", msg
.message
);
3807 /* shows QS_POSTMESSAGE flag is cleared in the PeekMessage call */
3808 ret
= MsgWaitForMultipleObjects(0, NULL
, FALSE
, 0, QS_POSTMESSAGE
);
3809 ok(ret
== WAIT_TIMEOUT
, "MsgWaitForMultipleObjects returned %x\n", ret
);
3811 PostMessageA(hwnd
, WM_USER
, 0, 0);
3813 /* new incoming message causes it to become signaled again */
3814 ret
= MsgWaitForMultipleObjects(0, NULL
, FALSE
, 0, QS_POSTMESSAGE
);
3815 ok(ret
== WAIT_OBJECT_0
, "MsgWaitForMultipleObjects returned %x\n", ret
);
3817 ok(PeekMessageW( &msg
, 0, 0, 0, PM_REMOVE
), "PeekMessage should succeed\n");
3818 ok(msg
.message
== WM_USER
, "got %04x instead of WM_USER\n", msg
.message
);
3819 ok(PeekMessageW( &msg
, 0, 0, 0, PM_REMOVE
), "PeekMessage should succeed\n");
3820 ok(msg
.message
== WM_USER
, "got %04x instead of WM_USER\n", msg
.message
);
3823 /* test if we receive the right sequence of messages */
3824 static void test_messages(void)
3826 HWND hwnd
, hparent
, hchild
;
3827 HWND hchild2
, hbutton
;
3833 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW
,
3834 100, 100, 200, 200, 0, 0, 0, NULL
);
3835 ok (hwnd
!= 0, "Failed to create overlapped window\n");
3836 ok_sequence(WmCreateOverlappedSeq
, "CreateWindow:overlapped", FALSE
);
3838 /* test ShowWindow(SW_HIDE) on a newly created invisible window */
3839 ok( ShowWindow(hwnd
, SW_HIDE
) == FALSE
, "ShowWindow: window was visible\n" );
3840 ok_sequence(WmEmptySeq
, "ShowWindow(SW_HIDE):overlapped, invisible", FALSE
);
3842 /* test WM_SETREDRAW on a not visible top level window */
3843 test_WM_SETREDRAW(hwnd
);
3845 SetWindowPos(hwnd
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
);
3846 ok_sequence(WmSWP_ShowOverlappedSeq
, "SetWindowPos:SWP_SHOWWINDOW:overlapped", FALSE
);
3847 ok(IsWindowVisible(hwnd
), "window should be visible at this point\n");
3849 ok(GetActiveWindow() == hwnd
, "window should be active\n");
3850 ok(GetFocus() == hwnd
, "window should have input focus\n");
3851 ShowWindow(hwnd
, SW_HIDE
);
3852 ok_sequence(WmHideOverlappedSeq
, "ShowWindow(SW_HIDE):overlapped", TRUE
);
3854 ShowWindow(hwnd
, SW_SHOW
);
3855 ok_sequence(WmShowOverlappedSeq
, "ShowWindow(SW_SHOW):overlapped", TRUE
);
3857 ShowWindow(hwnd
, SW_HIDE
);
3858 ok_sequence(WmHideOverlappedSeq
, "ShowWindow(SW_HIDE):overlapped", FALSE
);
3860 ShowWindow(hwnd
, SW_SHOWMAXIMIZED
);
3861 ok_sequence(WmShowMaxOverlappedSeq
, "ShowWindow(SW_SHOWMAXIMIZED):overlapped", TRUE
);
3863 ShowWindow(hwnd
, SW_RESTORE
);
3864 /* FIXME: add ok_sequence() here */
3867 ShowWindow(hwnd
, SW_MINIMIZE
);
3868 ok_sequence(WmShowMinOverlappedSeq
, "ShowWindow(SW_SHOWMINIMIZED):overlapped", TRUE
);
3871 ShowWindow(hwnd
, SW_RESTORE
);
3872 /* FIXME: add ok_sequence() here */
3875 ShowWindow(hwnd
, SW_SHOW
);
3876 ok_sequence(WmEmptySeq
, "ShowWindow(SW_SHOW):overlapped already visible", FALSE
);
3878 ok(GetActiveWindow() == hwnd
, "window should be active\n");
3879 ok(GetFocus() == hwnd
, "window should have input focus\n");
3880 SetWindowPos(hwnd
, 0,0,0,0,0, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
);
3881 ok_sequence(WmSWP_HideOverlappedSeq
, "SetWindowPos:SWP_HIDEWINDOW:overlapped", FALSE
);
3882 ok(!IsWindowVisible(hwnd
), "window should not be visible at this point\n");
3883 ok(GetActiveWindow() == hwnd
, "window should still be active\n");
3885 /* test WM_SETREDRAW on a visible top level window */
3886 ShowWindow(hwnd
, SW_SHOW
);
3887 test_WM_SETREDRAW(hwnd
);
3889 trace("testing scroll APIs on a visible top level window %p\n", hwnd
);
3890 test_scroll_messages(hwnd
);
3892 /* test resizing and moving */
3893 SetWindowPos( hwnd
, 0, 0, 0, 300, 300, SWP_NOMOVE
|SWP_NOACTIVATE
);
3894 ok_sequence(WmSWP_ResizeSeq
, "SetWindowPos:Resize", FALSE
);
3897 SetWindowPos( hwnd
, 0, 200, 200, 0, 0, SWP_NOSIZE
|SWP_NOACTIVATE
);
3898 ok_sequence(WmSWP_MoveSeq
, "SetWindowPos:Move", FALSE
);
3901 SetWindowPos( hwnd
, 0, 200, 200, 250, 250, SWP_NOZORDER
);
3902 ok_sequence(WmSWP_ResizeNoZOrder
, "SetWindowPos:WmSWP_ResizeNoZOrder", FALSE
);
3906 /* popups don't get WM_GETMINMAXINFO */
3907 SetWindowLongW( hwnd
, GWL_STYLE
, WS_VISIBLE
|WS_POPUP
);
3908 SetWindowPos( hwnd
, 0, 0, 0, 0, 0, SWP_NOZORDER
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_FRAMECHANGED
);
3910 SetWindowPos( hwnd
, 0, 0, 0, 200, 200, SWP_NOMOVE
|SWP_NOACTIVATE
);
3911 ok_sequence(WmSWP_ResizePopupSeq
, "SetWindowPos:ResizePopup", FALSE
);
3913 DestroyWindow(hwnd
);
3914 ok_sequence(WmDestroyOverlappedSeq
, "DestroyWindow:overlapped", FALSE
);
3916 hparent
= CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
3917 100, 100, 200, 200, 0, 0, 0, NULL
);
3918 ok (hparent
!= 0, "Failed to create parent window\n");
3921 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
| WS_MAXIMIZE
,
3922 0, 0, 10, 10, hparent
, 0, 0, NULL
);
3923 ok (hchild
!= 0, "Failed to create child window\n");
3924 ok_sequence(WmCreateMaximizedChildSeq
, "CreateWindow:maximized child", FALSE
);
3925 DestroyWindow(hchild
);
3928 /* visible child window with a caption */
3929 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child",
3930 WS_CHILD
| WS_VISIBLE
| WS_CAPTION
,
3931 0, 0, 10, 10, hparent
, 0, 0, NULL
);
3932 ok (hchild
!= 0, "Failed to create child window\n");
3933 ok_sequence(WmCreateVisibleChildSeq
, "CreateWindow:visible child", FALSE
);
3935 trace("testing scroll APIs on a visible child window %p\n", hchild
);
3936 test_scroll_messages(hchild
);
3938 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
);
3939 ok_sequence(WmShowChildSeq_4
, "SetWindowPos(SWP_SHOWWINDOW):child with a caption", FALSE
);
3941 DestroyWindow(hchild
);
3944 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
3945 0, 0, 10, 10, hparent
, 0, 0, NULL
);
3946 ok (hchild
!= 0, "Failed to create child window\n");
3947 ok_sequence(WmCreateChildSeq
, "CreateWindow:child", FALSE
);
3949 hchild2
= CreateWindowExA(0, "SimpleWindowClass", "Test child2", WS_CHILD
,
3950 100, 100, 50, 50, hparent
, 0, 0, NULL
);
3951 ok (hchild2
!= 0, "Failed to create child2 window\n");
3954 hbutton
= CreateWindowExA(0, "TestWindowClass", "Test button", WS_CHILD
,
3955 0, 100, 50, 50, hchild
, 0, 0, NULL
);
3956 ok (hbutton
!= 0, "Failed to create button window\n");
3958 /* test WM_SETREDRAW on a not visible child window */
3959 test_WM_SETREDRAW(hchild
);
3961 ShowWindow(hchild
, SW_SHOW
);
3962 ok_sequence(WmShowChildSeq
, "ShowWindow(SW_SHOW):child", FALSE
);
3964 ShowWindow(hchild
, SW_HIDE
);
3965 ok_sequence(WmHideChildSeq
, "ShowWindow(SW_HIDE):child", FALSE
);
3967 ShowWindow(hchild
, SW_SHOW
);
3968 ok_sequence(WmShowChildSeq
, "ShowWindow(SW_SHOW):child", FALSE
);
3970 /* test WM_SETREDRAW on a visible child window */
3971 test_WM_SETREDRAW(hchild
);
3973 MoveWindow(hchild
, 10, 10, 20, 20, TRUE
);
3974 ok_sequence(WmResizingChildWithMoveWindowSeq
, "MoveWindow:child", FALSE
);
3976 ShowWindow(hchild
, SW_HIDE
);
3978 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
);
3979 ok_sequence(WmShowChildSeq_2
, "SetWindowPos:show_child_2", FALSE
);
3981 ShowWindow(hchild
, SW_HIDE
);
3983 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
);
3984 ok_sequence(WmShowChildSeq_3
, "SetWindowPos:show_child_3", FALSE
);
3986 /* DestroyWindow sequence below expects that a child has focus */
3990 DestroyWindow(hchild
);
3991 ok_sequence(WmDestroyChildSeq
, "DestroyWindow:child", FALSE
);
3992 DestroyWindow(hchild2
);
3993 DestroyWindow(hbutton
);
3996 hchild
= CreateWindowExA(0, "TestWindowClass", "Test Child Popup", WS_CHILD
| WS_POPUP
,
3997 0, 0, 100, 100, hparent
, 0, 0, NULL
);
3998 ok (hchild
!= 0, "Failed to create child popup window\n");
3999 ok_sequence(WmCreateChildPopupSeq
, "CreateWindow:child_popup", FALSE
);
4000 DestroyWindow(hchild
);
4002 /* test what happens to a window which sets WS_VISIBLE in WM_CREATE */
4004 hchild
= CreateWindowExA(0, "TestPopupClass", "Test Popup", WS_POPUP
,
4005 0, 0, 100, 100, hparent
, 0, 0, NULL
);
4006 ok (hchild
!= 0, "Failed to create popup window\n");
4007 ok_sequence(WmCreateInvisiblePopupSeq
, "CreateWindow:invisible_popup", FALSE
);
4008 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
4009 ok(IsWindowVisible(hchild
), "IsWindowVisible() should return TRUE\n");
4011 ShowWindow(hchild
, SW_SHOW
);
4012 ok_sequence(WmEmptySeq
, "ShowWindow:show_visible_popup", FALSE
);
4014 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOZORDER
);
4015 ok_sequence(WmShowVisiblePopupSeq_2
, "SetWindowPos:show_visible_popup_2", FALSE
);
4017 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
);
4018 ok_sequence(WmShowVisiblePopupSeq_3
, "SetWindowPos:show_visible_popup_3", FALSE
);
4019 DestroyWindow(hchild
);
4021 /* this time add WS_VISIBLE for CreateWindowEx, but this fact actually
4022 * changes nothing in message sequences.
4025 hchild
= CreateWindowExA(0, "TestPopupClass", "Test Popup", WS_POPUP
| WS_VISIBLE
,
4026 0, 0, 100, 100, hparent
, 0, 0, NULL
);
4027 ok (hchild
!= 0, "Failed to create popup window\n");
4028 ok_sequence(WmCreateInvisiblePopupSeq
, "CreateWindow:invisible_popup", FALSE
);
4029 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
4030 ok(IsWindowVisible(hchild
), "IsWindowVisible() should return TRUE\n");
4032 ShowWindow(hchild
, SW_SHOW
);
4033 ok_sequence(WmEmptySeq
, "ShowWindow:show_visible_popup", FALSE
);
4035 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOZORDER
);
4036 ok_sequence(WmShowVisiblePopupSeq_2
, "SetWindowPos:show_visible_popup_2", FALSE
);
4037 DestroyWindow(hchild
);
4040 hwnd
= CreateWindowExA(WS_EX_DLGMODALFRAME
, "TestDialogClass", NULL
, WS_VISIBLE
|WS_CAPTION
|WS_SYSMENU
|WS_DLGFRAME
,
4041 0, 0, 100, 100, hparent
, 0, 0, NULL
);
4042 ok(hwnd
!= 0, "Failed to create custom dialog window\n");
4043 ok_sequence(WmCreateCustomDialogSeq
, "CreateCustomDialog", TRUE
);
4046 trace("testing scroll APIs on a visible dialog %p\n", hwnd);
4047 test_scroll_messages(hwnd);
4053 SendMessage(hwnd
, WM_NULL
, 0, 0);
4056 after_end_dialog
= 1;
4057 EndDialog( hwnd
, 0 );
4058 ok_sequence(WmEndCustomDialogSeq
, "EndCustomDialog", FALSE
);
4060 DestroyWindow(hwnd
);
4061 after_end_dialog
= 0;
4064 hwnd
= CreateWindowExA(0, "TestDialogClass", NULL
, WS_POPUP
,
4065 0, 0, 100, 100, 0, 0, GetModuleHandleA(0), NULL
);
4066 ok(hwnd
!= 0, "Failed to create custom dialog window\n");
4068 trace("call ShowWindow(%p, SW_SHOW)\n", hwnd
);
4069 ShowWindow(hwnd
, SW_SHOW
);
4070 ok_sequence(WmShowCustomDialogSeq
, "ShowCustomDialog", TRUE
);
4071 DestroyWindow(hwnd
);
4074 DialogBoxA( 0, "TEST_DIALOG", hparent
, TestModalDlgProcA
);
4075 ok_sequence(WmModalDialogSeq
, "ModalDialog", TRUE
);
4077 DestroyWindow(hparent
);
4080 /* Message sequence for SetMenu */
4081 ok(!DrawMenuBar(hwnd
), "DrawMenuBar should return FALSE for a window without a menu\n");
4082 ok_sequence(WmEmptySeq
, "DrawMenuBar for a window without a menu", FALSE
);
4084 hmenu
= CreateMenu();
4085 ok (hmenu
!= 0, "Failed to create menu\n");
4086 ok (InsertMenuA(hmenu
, -1, MF_BYPOSITION
, 0x1000, "foo"), "InsertMenu failed\n");
4087 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW
,
4088 100, 100, 200, 200, 0, hmenu
, 0, NULL
);
4089 ok_sequence(WmCreateOverlappedSeq
, "CreateWindow:overlapped", FALSE
);
4090 ok (SetMenu(hwnd
, 0), "SetMenu\n");
4091 ok_sequence(WmSetMenuNonVisibleSizeChangeSeq
, "SetMenu:NonVisibleSizeChange", FALSE
);
4092 ok (SetMenu(hwnd
, 0), "SetMenu\n");
4093 ok_sequence(WmSetMenuNonVisibleNoSizeChangeSeq
, "SetMenu:NonVisibleNoSizeChange", FALSE
);
4094 ShowWindow(hwnd
, SW_SHOW
);
4095 UpdateWindow( hwnd
);
4096 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
4098 ok (SetMenu(hwnd
, 0), "SetMenu\n");
4099 ok_sequence(WmSetMenuVisibleNoSizeChangeSeq
, "SetMenu:VisibleNoSizeChange", FALSE
);
4100 ok (SetMenu(hwnd
, hmenu
), "SetMenu\n");
4101 ok_sequence(WmSetMenuVisibleSizeChangeSeq
, "SetMenu:VisibleSizeChange", FALSE
);
4103 UpdateWindow( hwnd
);
4104 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
4106 ok(DrawMenuBar(hwnd
), "DrawMenuBar\n");
4107 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
4108 ok_sequence(WmDrawMenuBarSeq
, "DrawMenuBar", FALSE
);
4110 DestroyWindow(hwnd
);
4113 /* Message sequence for EnableWindow */
4114 hparent
= CreateWindowExA(0, "TestWindowClass", "Test parent", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
4115 100, 100, 200, 200, 0, 0, 0, NULL
);
4116 ok (hparent
!= 0, "Failed to create parent window\n");
4117 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
| WS_VISIBLE
,
4118 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4119 ok (hchild
!= 0, "Failed to create child window\n");
4125 EnableWindow(hparent
, FALSE
);
4126 ok_sequence(WmEnableWindowSeq_1
, "EnableWindow(FALSE)", FALSE
);
4128 EnableWindow(hparent
, TRUE
);
4129 ok_sequence(WmEnableWindowSeq_2
, "EnableWindow(TRUE)", FALSE
);
4131 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
4134 test_MsgWaitForMultipleObjects(hparent
);
4136 /* the following test causes an exception in user.exe under win9x */
4137 if (!PostMessageW( hparent
, WM_USER
, 0, 0 ))
4139 DestroyWindow(hparent
);
4143 PostMessageW( hparent
, WM_USER
+1, 0, 0 );
4144 /* PeekMessage(NULL) fails, but still removes the message */
4145 SetLastError(0xdeadbeef);
4146 ok( !PeekMessageW( NULL
, 0, 0, 0, PM_REMOVE
), "PeekMessage(NULL) should fail\n" );
4147 ok( GetLastError() == ERROR_NOACCESS
|| /* Win2k */
4148 GetLastError() == 0xdeadbeef, /* NT4 */
4149 "last error is %d\n", GetLastError() );
4150 ok( PeekMessageW( &msg
, 0, 0, 0, PM_REMOVE
), "PeekMessage should succeed\n" );
4151 ok( msg
.message
== WM_USER
+1, "got %x instead of WM_USER+1\n", msg
.message
);
4153 DestroyWindow(hchild
);
4154 DestroyWindow(hparent
);
4157 /* Message sequences for WM_SETICON */
4158 trace("testing WM_SETICON\n");
4159 hwnd
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
4160 CW_USEDEFAULT
, CW_USEDEFAULT
, 300, 300, 0,
4162 ShowWindow(hwnd
, SW_SHOW
);
4164 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
4166 SendMessage(hwnd
, WM_SETICON
, ICON_SMALL
, (LPARAM
)LoadIcon(0, IDI_APPLICATION
));
4167 ok_sequence(WmSetIcon_1
, "WM_SETICON for shown window with caption", FALSE
);
4169 ShowWindow(hwnd
, SW_HIDE
);
4170 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
4172 SendMessage(hwnd
, WM_SETICON
, ICON_SMALL
, (LPARAM
)LoadIcon(0, IDI_APPLICATION
));
4173 ok_sequence(WmSetIcon_2
, "WM_SETICON for hidden window with caption", FALSE
);
4174 DestroyWindow(hwnd
);
4177 hwnd
= CreateWindowExA(0, "TestPopupClass", NULL
, WS_POPUP
,
4178 CW_USEDEFAULT
, CW_USEDEFAULT
, 300, 300, 0,
4180 ShowWindow(hwnd
, SW_SHOW
);
4182 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
4184 SendMessage(hwnd
, WM_SETICON
, ICON_SMALL
, (LPARAM
)LoadIcon(0, IDI_APPLICATION
));
4185 ok_sequence(WmSetIcon_2
, "WM_SETICON for shown window without caption", FALSE
);
4187 ShowWindow(hwnd
, SW_HIDE
);
4188 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
4190 SendMessage(hwnd
, WM_SETICON
, ICON_SMALL
, (LPARAM
)LoadIcon(0, IDI_APPLICATION
));
4191 ok_sequence(WmSetIcon_2
, "WM_SETICON for hidden window without caption", FALSE
);
4192 DestroyWindow(hwnd
);
4196 static void invisible_parent_tests(void)
4198 HWND hparent
, hchild
;
4200 hparent
= CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW
,
4201 100, 100, 200, 200, 0, 0, 0, NULL
);
4202 ok (hparent
!= 0, "Failed to create parent window\n");
4205 /* test showing child with hidden parent */
4207 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
4208 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4209 ok (hchild
!= 0, "Failed to create child window\n");
4210 ok_sequence(WmCreateChildSeq
, "CreateWindow:child", FALSE
);
4212 ShowWindow( hchild
, SW_MINIMIZE
);
4213 ok_sequence(WmShowChildInvisibleParentSeq_1
, "ShowWindow(SW_MINIMIZE) child with invisible parent", FALSE
);
4214 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
4215 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
4220 ShowWindow( hchild
, SW_MINIMIZE
);
4221 ok_sequence(WmShowChildInvisibleParentSeq_1r
, "ShowWindow(SW_MINIMIZE) child with invisible parent", FALSE
);
4223 DestroyWindow(hchild
);
4224 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
4225 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4228 ShowWindow( hchild
, SW_MAXIMIZE
);
4229 ok_sequence(WmShowChildInvisibleParentSeq_2
, "ShowWindow(SW_MAXIMIZE) child with invisible parent", FALSE
);
4230 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
4231 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
4236 ShowWindow( hchild
, SW_MAXIMIZE
);
4237 ok_sequence(WmShowChildInvisibleParentSeq_2r
, "ShowWindow(SW_MAXIMIZE) child with invisible parent", FALSE
);
4239 DestroyWindow(hchild
);
4240 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
4241 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4244 ShowWindow( hchild
, SW_RESTORE
);
4245 ok_sequence(WmShowChildInvisibleParentSeq_5
, "ShowWindow(SW_RESTORE) child with invisible parent", FALSE
);
4246 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
4247 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
4249 DestroyWindow(hchild
);
4250 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
4251 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4254 ShowWindow( hchild
, SW_SHOWMINIMIZED
);
4255 ok_sequence(WmShowChildInvisibleParentSeq_3
, "ShowWindow(SW_SHOWMINIMIZED) child with invisible parent", FALSE
);
4256 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
4257 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
4262 ShowWindow( hchild
, SW_SHOWMINIMIZED
);
4263 ok_sequence(WmShowChildInvisibleParentSeq_3r
, "ShowWindow(SW_SHOWMINIMIZED) child with invisible parent", FALSE
);
4265 DestroyWindow(hchild
);
4266 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
4267 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4270 /* same as ShowWindow( hchild, SW_MAXIMIZE ); */
4271 ShowWindow( hchild
, SW_SHOWMAXIMIZED
);
4272 ok_sequence(WmShowChildInvisibleParentSeq_2
, "ShowWindow(SW_SHOWMAXIMIZED) child with invisible parent", FALSE
);
4273 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
4274 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
4276 DestroyWindow(hchild
);
4277 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
4278 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4281 ShowWindow( hchild
, SW_SHOWMINNOACTIVE
);
4282 ok_sequence(WmShowChildInvisibleParentSeq_4
, "ShowWindow(SW_SHOWMINNOACTIVE) child with invisible parent", FALSE
);
4283 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
4284 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
4289 ShowWindow( hchild
, SW_SHOWMINNOACTIVE
);
4290 ok_sequence(WmShowChildInvisibleParentSeq_4r
, "ShowWindow(SW_SHOWMINNOACTIVE) child with invisible parent", FALSE
);
4292 DestroyWindow(hchild
);
4293 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
4294 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4297 /* FIXME: looks like XP SP2 doesn't know about SW_FORCEMINIMIZE at all */
4298 ShowWindow( hchild
, SW_FORCEMINIMIZE
);
4299 ok_sequence(WmEmptySeq
, "ShowWindow(SW_FORCEMINIMIZE) child with invisible parent", TRUE
);
4301 ok(!(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
), "WS_VISIBLE should be not set\n");
4303 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
4305 DestroyWindow(hchild
);
4306 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
4307 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4310 ShowWindow( hchild
, SW_SHOWNA
);
4311 ok_sequence(WmShowChildInvisibleParentSeq_5
, "ShowWindow(SW_SHOWNA) child with invisible parent", FALSE
);
4312 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
4313 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
4318 ShowWindow( hchild
, SW_SHOWNA
);
4319 ok_sequence(WmShowChildInvisibleParentSeq_5
, "ShowWindow(SW_SHOWNA) child with invisible parent", FALSE
);
4321 DestroyWindow(hchild
);
4322 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
4323 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4326 ShowWindow( hchild
, SW_SHOW
);
4327 ok_sequence(WmShowChildInvisibleParentSeq_5
, "ShowWindow(SW_SHOW) child with invisible parent", FALSE
);
4328 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
4329 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
4334 ShowWindow( hchild
, SW_SHOW
);
4335 ok_sequence(WmEmptySeq
, "ShowWindow(SW_SHOW) child with invisible parent", FALSE
);
4337 ShowWindow( hchild
, SW_HIDE
);
4338 ok_sequence(WmHideChildInvisibleParentSeq
, "ShowWindow:hide child with invisible parent", FALSE
);
4339 ok(!(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
), "WS_VISIBLE should be not set\n");
4340 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
4342 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOZORDER
);
4343 ok_sequence(WmShowChildInvisibleParentSeq_6
, "SetWindowPos:show child with invisible parent", FALSE
);
4344 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
4345 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
4347 SetWindowPos(hchild
, 0,0,0,0,0, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOZORDER
);
4348 ok_sequence(WmHideChildInvisibleParentSeq_2
, "SetWindowPos:hide child with invisible parent", FALSE
);
4349 ok(!(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
), "WS_VISIBLE should not be set\n");
4350 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
4352 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOZORDER
);
4354 DestroyWindow(hchild
);
4355 ok_sequence(WmDestroyInvisibleChildSeq
, "DestroyInvisibleChildSeq", FALSE
);
4357 DestroyWindow(hparent
);
4361 /****************** button message test *************************/
4362 static const struct message WmSetFocusButtonSeq
[] =
4364 { HCBT_SETFOCUS
, hook
},
4365 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
4366 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
4367 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
4368 { WM_SETFOCUS
, sent
|wparam
, 0 },
4369 { WM_CTLCOLORBTN
, sent
|defwinproc
},
4372 static const struct message WmKillFocusButtonSeq
[] =
4374 { HCBT_SETFOCUS
, hook
},
4375 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
4376 { WM_KILLFOCUS
, sent
|wparam
, 0 },
4377 { WM_CTLCOLORBTN
, sent
|defwinproc
},
4378 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
4379 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 1 },
4382 static const struct message WmSetFocusStaticSeq
[] =
4384 { HCBT_SETFOCUS
, hook
},
4385 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
4386 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
4387 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
4388 { WM_SETFOCUS
, sent
|wparam
, 0 },
4389 { WM_CTLCOLORSTATIC
, sent
|defwinproc
},
4392 static const struct message WmKillFocusStaticSeq
[] =
4394 { HCBT_SETFOCUS
, hook
},
4395 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
4396 { WM_KILLFOCUS
, sent
|wparam
, 0 },
4397 { WM_CTLCOLORSTATIC
, sent
|defwinproc
},
4398 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
4399 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 1 },
4402 static const struct message WmLButtonDownSeq
[] =
4404 { WM_LBUTTONDOWN
, sent
|wparam
|lparam
, 0, 0 },
4405 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
4406 { HCBT_SETFOCUS
, hook
},
4407 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
4408 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
4409 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
4410 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
4411 { WM_CTLCOLORBTN
, sent
|defwinproc
},
4412 { BM_SETSTATE
, sent
|wparam
|defwinproc
, TRUE
},
4413 { WM_CTLCOLORBTN
, sent
|defwinproc
},
4414 { EVENT_OBJECT_STATECHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
4417 static const struct message WmLButtonUpSeq
[] =
4419 { WM_LBUTTONUP
, sent
|wparam
|lparam
, 0, 0 },
4420 { BM_SETSTATE
, sent
|wparam
|defwinproc
, FALSE
},
4421 { WM_CTLCOLORBTN
, sent
|defwinproc
},
4422 { EVENT_OBJECT_STATECHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
4423 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, 0, 0 },
4424 { WM_CAPTURECHANGED
, sent
|wparam
|defwinproc
, 0 },
4427 static const struct message WmSetFontButtonSeq
[] =
4429 { WM_SETFONT
, sent
},
4431 { WM_ERASEBKGND
, sent
|defwinproc
|optional
},
4432 { WM_CTLCOLORBTN
, sent
|defwinproc
},
4436 static WNDPROC old_button_proc
;
4438 static LRESULT CALLBACK
button_hook_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
4440 static long defwndproc_counter
= 0;
4444 trace("button: %p, %04x, %08lx, %08lx\n", hwnd
, message
, wParam
, lParam
);
4446 /* explicitly ignore WM_GETICON message */
4447 if (message
== WM_GETICON
) return 0;
4449 msg
.message
= message
;
4450 msg
.flags
= sent
|wparam
|lparam
;
4451 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
4452 msg
.wParam
= wParam
;
4453 msg
.lParam
= lParam
;
4456 if (message
== BM_SETSTATE
)
4457 ok(GetCapture() == hwnd
, "GetCapture() = %p\n", GetCapture());
4459 defwndproc_counter
++;
4460 ret
= CallWindowProcA(old_button_proc
, hwnd
, message
, wParam
, lParam
);
4461 defwndproc_counter
--;
4466 static void subclass_button(void)
4470 if (!GetClassInfoA(0, "button", &cls
)) assert(0);
4472 old_button_proc
= cls
.lpfnWndProc
;
4474 cls
.hInstance
= GetModuleHandle(0);
4475 cls
.lpfnWndProc
= button_hook_proc
;
4476 cls
.lpszClassName
= "my_button_class";
4477 UnregisterClass(cls
.lpszClassName
, cls
.hInstance
);
4478 if (!RegisterClassA(&cls
)) assert(0);
4481 static void test_button_messages(void)
4487 const struct message
*setfocus
;
4488 const struct message
*killfocus
;
4490 { BS_PUSHBUTTON
, DLGC_BUTTON
| DLGC_UNDEFPUSHBUTTON
,
4491 WmSetFocusButtonSeq
, WmKillFocusButtonSeq
},
4492 { BS_DEFPUSHBUTTON
, DLGC_BUTTON
| DLGC_DEFPUSHBUTTON
,
4493 WmSetFocusButtonSeq
, WmKillFocusButtonSeq
},
4494 { BS_CHECKBOX
, DLGC_BUTTON
,
4495 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
},
4496 { BS_AUTOCHECKBOX
, DLGC_BUTTON
,
4497 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
},
4498 { BS_RADIOBUTTON
, DLGC_BUTTON
| DLGC_RADIOBUTTON
,
4499 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
},
4500 { BS_3STATE
, DLGC_BUTTON
,
4501 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
},
4502 { BS_AUTO3STATE
, DLGC_BUTTON
,
4503 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
},
4504 { BS_GROUPBOX
, DLGC_STATIC
,
4505 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
},
4506 { BS_USERBUTTON
, DLGC_BUTTON
| DLGC_UNDEFPUSHBUTTON
,
4507 WmSetFocusButtonSeq
, WmKillFocusButtonSeq
},
4508 { BS_AUTORADIOBUTTON
, DLGC_BUTTON
| DLGC_RADIOBUTTON
,
4509 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
},
4510 { BS_OWNERDRAW
, DLGC_BUTTON
,
4511 WmSetFocusButtonSeq
, WmKillFocusButtonSeq
}
4520 for (i
= 0; i
< sizeof(button
)/sizeof(button
[0]); i
++)
4522 hwnd
= CreateWindowExA(0, "my_button_class", "test", button
[i
].style
| WS_POPUP
,
4523 0, 0, 50, 14, 0, 0, 0, NULL
);
4524 ok(hwnd
!= 0, "Failed to create button window\n");
4526 dlg_code
= SendMessageA(hwnd
, WM_GETDLGCODE
, 0, 0);
4527 ok(dlg_code
== button
[i
].dlg_code
, "%u: wrong dlg_code %08x\n", i
, dlg_code
);
4529 ShowWindow(hwnd
, SW_SHOW
);
4534 trace("button style %08x\n", button
[i
].style
);
4536 ok_sequence(button
[i
].setfocus
, "SetFocus(hwnd) on a button", FALSE
);
4539 ok_sequence(button
[i
].killfocus
, "SetFocus(0) on a button", FALSE
);
4541 DestroyWindow(hwnd
);
4544 hwnd
= CreateWindowExA(0, "my_button_class", "test", BS_PUSHBUTTON
| WS_POPUP
| WS_VISIBLE
,
4545 0, 0, 50, 14, 0, 0, 0, NULL
);
4546 ok(hwnd
!= 0, "Failed to create button window\n");
4551 SendMessageA(hwnd
, WM_LBUTTONDOWN
, 0, 0);
4552 ok_sequence(WmLButtonDownSeq
, "WM_LBUTTONDOWN on a button", FALSE
);
4554 SendMessageA(hwnd
, WM_LBUTTONUP
, 0, 0);
4555 ok_sequence(WmLButtonUpSeq
, "WM_LBUTTONUP on a button", FALSE
);
4558 zfont
= (HFONT
)GetStockObject(SYSTEM_FONT
);
4559 SendMessageA(hwnd
, WM_SETFONT
, (WPARAM
)zfont
, TRUE
);
4561 ok_sequence(WmSetFontButtonSeq
, "WM_SETFONT on a button", FALSE
);
4563 DestroyWindow(hwnd
);
4566 /****************** static message test *************************/
4567 static const struct message WmSetFontStaticSeq
[] =
4569 { WM_SETFONT
, sent
},
4570 { WM_PAINT
, sent
|defwinproc
},
4571 { WM_ERASEBKGND
, sent
|defwinproc
|optional
},
4572 { WM_CTLCOLORSTATIC
, sent
|defwinproc
},
4576 static WNDPROC old_static_proc
;
4578 static LRESULT CALLBACK
static_hook_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
4580 static long defwndproc_counter
= 0;
4584 trace("static: %p, %04x, %08lx, %08lx\n", hwnd
, message
, wParam
, lParam
);
4586 /* explicitly ignore WM_GETICON message */
4587 if (message
== WM_GETICON
) return 0;
4589 msg
.message
= message
;
4590 msg
.flags
= sent
|wparam
|lparam
;
4591 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
4592 msg
.wParam
= wParam
;
4593 msg
.lParam
= lParam
;
4597 defwndproc_counter
++;
4598 ret
= CallWindowProcA(old_static_proc
, hwnd
, message
, wParam
, lParam
);
4599 defwndproc_counter
--;
4604 static void subclass_static(void)
4608 if (!GetClassInfoA(0, "static", &cls
)) assert(0);
4610 old_static_proc
= cls
.lpfnWndProc
;
4612 cls
.hInstance
= GetModuleHandle(0);
4613 cls
.lpfnWndProc
= static_hook_proc
;
4614 cls
.lpszClassName
= "my_static_class";
4615 UnregisterClass(cls
.lpszClassName
, cls
.hInstance
);
4616 if (!RegisterClassA(&cls
)) assert(0);
4619 static void test_static_messages(void)
4621 /* FIXME: make as comprehensive as the button message test */
4626 const struct message
*setfont
;
4628 { SS_LEFT
, DLGC_STATIC
,
4629 WmSetFontStaticSeq
}
4637 for (i
= 0; i
< sizeof(static_ctrl
)/sizeof(static_ctrl
[0]); i
++)
4639 hwnd
= CreateWindowExA(0, "my_static_class", "test", static_ctrl
[i
].style
| WS_POPUP
,
4640 0, 0, 50, 14, 0, 0, 0, NULL
);
4641 ok(hwnd
!= 0, "Failed to create static window\n");
4643 dlg_code
= SendMessageA(hwnd
, WM_GETDLGCODE
, 0, 0);
4644 ok(dlg_code
== static_ctrl
[i
].dlg_code
, "%u: wrong dlg_code %08x\n", i
, dlg_code
);
4646 ShowWindow(hwnd
, SW_SHOW
);
4651 trace("static style %08x\n", static_ctrl
[i
].style
);
4652 SendMessage(hwnd
, WM_SETFONT
, (WPARAM
)GetStockObject(DEFAULT_GUI_FONT
), TRUE
);
4653 ok_sequence(static_ctrl
[i
].setfont
, "WM_SETFONT on a static", FALSE
);
4655 DestroyWindow(hwnd
);
4659 /************* painting message test ********************/
4661 void dump_region(HRGN hrgn
)
4664 RGNDATA
*data
= NULL
;
4669 printf( "null region\n" );
4672 if (!(size
= GetRegionData( hrgn
, 0, NULL
))) return;
4673 if (!(data
= HeapAlloc( GetProcessHeap(), 0, size
))) return;
4674 GetRegionData( hrgn
, size
, data
);
4675 printf("%d rects:", data
->rdh
.nCount
);
4676 for (i
= 0, rect
= (RECT
*)data
->Buffer
; i
< data
->rdh
.nCount
; i
++, rect
++)
4677 printf( " (%d,%d)-(%d,%d)", rect
->left
, rect
->top
, rect
->right
, rect
->bottom
);
4679 HeapFree( GetProcessHeap(), 0, data
);
4682 static void check_update_rgn( HWND hwnd
, HRGN hrgn
)
4686 HRGN tmp
= CreateRectRgn( 0, 0, 0, 0 );
4687 HRGN update
= CreateRectRgn( 0, 0, 0, 0 );
4689 ret
= GetUpdateRgn( hwnd
, update
, FALSE
);
4690 ok( ret
!= ERROR
, "GetUpdateRgn failed\n" );
4691 if (ret
== NULLREGION
)
4693 ok( !hrgn
, "Update region shouldn't be empty\n" );
4697 if (CombineRgn( tmp
, hrgn
, update
, RGN_XOR
) != NULLREGION
)
4699 ok( 0, "Regions are different\n" );
4700 if (winetest_debug
> 0)
4702 printf( "Update region: " );
4703 dump_region( update
);
4704 printf( "Wanted region: " );
4705 dump_region( hrgn
);
4709 GetRgnBox( update
, &r1
);
4710 GetUpdateRect( hwnd
, &r2
, FALSE
);
4711 ok( r1
.left
== r2
.left
&& r1
.top
== r2
.top
&& r1
.right
== r2
.right
&& r1
.bottom
== r2
.bottom
,
4712 "Rectangles are different: %d,%d-%d,%d / %d,%d-%d,%d\n",
4713 r1
.left
, r1
.top
, r1
.right
, r1
.bottom
, r2
.left
, r2
.top
, r2
.right
, r2
.bottom
);
4715 DeleteObject( tmp
);
4716 DeleteObject( update
);
4719 static const struct message WmInvalidateRgn
[] = {
4720 { WM_NCPAINT
, sent
},
4721 { WM_GETTEXT
, sent
|defwinproc
|optional
},
4725 static const struct message WmGetUpdateRect
[] = {
4726 { WM_NCPAINT
, sent
},
4727 { WM_GETTEXT
, sent
|defwinproc
|optional
},
4732 static const struct message WmInvalidateFull
[] = {
4733 { WM_NCPAINT
, sent
|wparam
, 1 },
4734 { WM_GETTEXT
, sent
|defwinproc
|optional
},
4738 static const struct message WmInvalidateErase
[] = {
4739 { WM_NCPAINT
, sent
|wparam
, 1 },
4740 { WM_GETTEXT
, sent
|defwinproc
|optional
},
4741 { WM_ERASEBKGND
, sent
},
4745 static const struct message WmInvalidatePaint
[] = {
4747 { WM_NCPAINT
, sent
|wparam
|beginpaint
, 1 },
4748 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
4752 static const struct message WmInvalidateErasePaint
[] = {
4754 { WM_NCPAINT
, sent
|wparam
|beginpaint
, 1 },
4755 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
4756 { WM_ERASEBKGND
, sent
|beginpaint
},
4760 static const struct message WmInvalidateErasePaint2
[] = {
4762 { WM_NCPAINT
, sent
|beginpaint
},
4763 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
4764 { WM_ERASEBKGND
, sent
|beginpaint
},
4768 static const struct message WmErase
[] = {
4769 { WM_ERASEBKGND
, sent
},
4773 static const struct message WmPaint
[] = {
4778 static const struct message WmParentOnlyPaint
[] = {
4779 { WM_PAINT
, sent
|parent
},
4783 static const struct message WmInvalidateParent
[] = {
4784 { WM_NCPAINT
, sent
|parent
},
4785 { WM_GETTEXT
, sent
|defwinproc
|parent
|optional
},
4786 { WM_ERASEBKGND
, sent
|parent
},
4790 static const struct message WmInvalidateParentChild
[] = {
4791 { WM_NCPAINT
, sent
|parent
},
4792 { WM_GETTEXT
, sent
|defwinproc
|parent
|optional
},
4793 { WM_ERASEBKGND
, sent
|parent
},
4794 { WM_NCPAINT
, sent
},
4795 { WM_GETTEXT
, sent
|defwinproc
|optional
},
4796 { WM_ERASEBKGND
, sent
},
4800 static const struct message WmInvalidateParentChild2
[] = {
4801 { WM_ERASEBKGND
, sent
|parent
},
4802 { WM_NCPAINT
, sent
},
4803 { WM_GETTEXT
, sent
|defwinproc
|optional
},
4804 { WM_ERASEBKGND
, sent
},
4808 static const struct message WmParentPaint
[] = {
4809 { WM_PAINT
, sent
|parent
},
4814 static const struct message WmParentPaintNc
[] = {
4815 { WM_PAINT
, sent
|parent
},
4817 { WM_NCPAINT
, sent
|beginpaint
},
4818 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
4819 { WM_ERASEBKGND
, sent
|beginpaint
},
4823 static const struct message WmChildPaintNc
[] = {
4825 { WM_NCPAINT
, sent
|beginpaint
},
4826 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
4827 { WM_ERASEBKGND
, sent
|beginpaint
},
4831 static const struct message WmParentErasePaint
[] = {
4832 { WM_PAINT
, sent
|parent
},
4833 { WM_NCPAINT
, sent
|parent
|beginpaint
},
4834 { WM_GETTEXT
, sent
|parent
|beginpaint
|defwinproc
|optional
},
4835 { WM_ERASEBKGND
, sent
|parent
|beginpaint
},
4837 { WM_NCPAINT
, sent
|beginpaint
},
4838 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
4839 { WM_ERASEBKGND
, sent
|beginpaint
},
4843 static const struct message WmParentOnlyNcPaint
[] = {
4844 { WM_PAINT
, sent
|parent
},
4845 { WM_NCPAINT
, sent
|parent
|beginpaint
},
4846 { WM_GETTEXT
, sent
|parent
|beginpaint
|defwinproc
|optional
},
4850 static const struct message WmSetParentStyle
[] = {
4851 { WM_STYLECHANGING
, sent
|parent
},
4852 { WM_STYLECHANGED
, sent
|parent
},
4856 static void test_paint_messages(void)
4862 HWND hparent
, hchild
;
4863 HRGN hrgn
= CreateRectRgn( 0, 0, 0, 0 );
4864 HRGN hrgn2
= CreateRectRgn( 0, 0, 0, 0 );
4865 HWND hwnd
= CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW
,
4866 100, 100, 200, 200, 0, 0, 0, NULL
);
4867 ok (hwnd
!= 0, "Failed to create overlapped window\n");
4869 ShowWindow( hwnd
, SW_SHOW
);
4870 UpdateWindow( hwnd
);
4874 check_update_rgn( hwnd
, 0 );
4875 SetRectRgn( hrgn
, 10, 10, 20, 20 );
4876 ret
= RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
);
4877 ok(ret
, "RedrawWindow returned %d instead of TRUE\n", ret
);
4878 check_update_rgn( hwnd
, hrgn
);
4879 SetRectRgn( hrgn2
, 20, 20, 30, 30 );
4880 ret
= RedrawWindow( hwnd
, NULL
, hrgn2
, RDW_INVALIDATE
);
4881 ok(ret
, "RedrawWindow returned %d instead of TRUE\n", ret
);
4882 CombineRgn( hrgn
, hrgn
, hrgn2
, RGN_OR
);
4883 check_update_rgn( hwnd
, hrgn
);
4884 /* validate everything */
4885 ret
= RedrawWindow( hwnd
, NULL
, NULL
, RDW_VALIDATE
);
4886 ok(ret
, "RedrawWindow returned %d instead of TRUE\n", ret
);
4887 check_update_rgn( hwnd
, 0 );
4889 /* test empty region */
4890 SetRectRgn( hrgn
, 10, 10, 10, 15 );
4891 ret
= RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
);
4892 ok(ret
, "RedrawWindow returned %d instead of TRUE\n", ret
);
4893 check_update_rgn( hwnd
, 0 );
4894 /* test empty rect */
4895 SetRect( &rect
, 10, 10, 10, 15 );
4896 ret
= RedrawWindow( hwnd
, &rect
, NULL
, RDW_INVALIDATE
);
4897 ok(ret
, "RedrawWindow returned %d instead of TRUE\n", ret
);
4898 check_update_rgn( hwnd
, 0 );
4900 /* flush pending messages */
4901 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
4904 GetClientRect( hwnd
, &rect
);
4905 SetRectRgn( hrgn
, 0, 0, rect
.right
- rect
.left
, rect
.bottom
- rect
.top
);
4906 /* MSDN: if hwnd parameter is NULL, InvalidateRect invalidates and redraws
4907 * all windows and sends WM_ERASEBKGND and WM_NCPAINT.
4909 trace("testing InvalidateRect(0, NULL, FALSE)\n");
4910 SetRectEmpty( &rect
);
4911 ok(InvalidateRect(0, &rect
, FALSE
), "InvalidateRect(0, &rc, FALSE) should fail\n");
4912 check_update_rgn( hwnd
, hrgn
);
4913 ok_sequence( WmInvalidateErase
, "InvalidateErase", FALSE
);
4914 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
4915 ok_sequence( WmPaint
, "Paint", FALSE
);
4916 RedrawWindow( hwnd
, NULL
, NULL
, RDW_VALIDATE
);
4917 check_update_rgn( hwnd
, 0 );
4919 /* MSDN: if hwnd parameter is NULL, ValidateRect invalidates and redraws
4920 * all windows and sends WM_ERASEBKGND and WM_NCPAINT.
4922 trace("testing ValidateRect(0, NULL)\n");
4923 SetRectEmpty( &rect
);
4924 ok(ValidateRect(0, &rect
), "ValidateRect(0, &rc) should not fail\n");
4925 check_update_rgn( hwnd
, hrgn
);
4926 ok_sequence( WmInvalidateErase
, "InvalidateErase", FALSE
);
4927 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
4928 ok_sequence( WmPaint
, "Paint", FALSE
);
4929 RedrawWindow( hwnd
, NULL
, NULL
, RDW_VALIDATE
);
4930 check_update_rgn( hwnd
, 0 );
4932 trace("testing InvalidateRgn(0, NULL, FALSE)\n");
4933 SetLastError(0xdeadbeef);
4934 ok(!InvalidateRgn(0, NULL
, FALSE
), "InvalidateRgn(0, NULL, FALSE) should fail\n");
4935 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
, "wrong error code %d\n", GetLastError());
4936 check_update_rgn( hwnd
, 0 );
4937 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
4938 ok_sequence( WmEmptySeq
, "WmEmptySeq", FALSE
);
4940 trace("testing ValidateRgn(0, NULL)\n");
4941 SetLastError(0xdeadbeef);
4942 ok(!ValidateRgn(0, NULL
), "ValidateRgn(0, NULL) should fail\n");
4943 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
, "wrong error code %d\n", GetLastError());
4944 check_update_rgn( hwnd
, 0 );
4945 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
4946 ok_sequence( WmEmptySeq
, "WmEmptySeq", FALSE
);
4948 /* now with frame */
4949 SetRectRgn( hrgn
, -5, -5, 20, 20 );
4951 /* flush pending messages */
4952 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
4955 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_FRAME
);
4956 ok_sequence( WmEmptySeq
, "EmptySeq", FALSE
);
4958 SetRectRgn( hrgn
, 0, 0, 20, 20 ); /* GetUpdateRgn clips to client area */
4959 check_update_rgn( hwnd
, hrgn
);
4962 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASENOW
);
4963 ok_sequence( WmInvalidateRgn
, "InvalidateRgn", FALSE
);
4966 RedrawWindow( hwnd
, NULL
, NULL
, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASENOW
);
4967 ok_sequence( WmInvalidateFull
, "InvalidateFull", FALSE
);
4969 GetClientRect( hwnd
, &rect
);
4970 SetRectRgn( hrgn
, rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
4971 check_update_rgn( hwnd
, hrgn
);
4974 RedrawWindow( hwnd
, NULL
, NULL
, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASE
| RDW_ERASENOW
);
4975 ok_sequence( WmInvalidateErase
, "InvalidateErase", FALSE
);
4978 RedrawWindow( hwnd
, NULL
, NULL
, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASENOW
| RDW_UPDATENOW
);
4979 ok_sequence( WmInvalidatePaint
, "InvalidatePaint", FALSE
);
4980 check_update_rgn( hwnd
, 0 );
4983 RedrawWindow( hwnd
, NULL
, NULL
, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASE
| RDW_UPDATENOW
);
4984 ok_sequence( WmInvalidateErasePaint
, "InvalidateErasePaint", FALSE
);
4985 check_update_rgn( hwnd
, 0 );
4988 SetRectRgn( hrgn
, 0, 0, 100, 100 );
4989 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
);
4990 SetRectRgn( hrgn
, 0, 0, 50, 100 );
4991 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_VALIDATE
);
4992 SetRectRgn( hrgn
, 50, 0, 100, 100 );
4993 check_update_rgn( hwnd
, hrgn
);
4994 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_VALIDATE
| RDW_ERASENOW
);
4995 ok_sequence( WmEmptySeq
, "EmptySeq", FALSE
); /* must not generate messages, everything is valid */
4996 check_update_rgn( hwnd
, 0 );
4999 SetRectRgn( hrgn
, 0, 0, 100, 100 );
5000 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_ERASE
);
5001 SetRectRgn( hrgn
, 0, 0, 100, 50 );
5002 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_VALIDATE
| RDW_ERASENOW
);
5003 ok_sequence( WmErase
, "Erase", FALSE
);
5004 SetRectRgn( hrgn
, 0, 50, 100, 100 );
5005 check_update_rgn( hwnd
, hrgn
);
5008 SetRectRgn( hrgn
, 0, 0, 100, 100 );
5009 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_ERASE
);
5010 SetRectRgn( hrgn
, 0, 0, 50, 50 );
5011 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_VALIDATE
| RDW_NOERASE
| RDW_UPDATENOW
);
5012 ok_sequence( WmPaint
, "Paint", FALSE
);
5015 SetRectRgn( hrgn
, -4, -4, -2, -2 );
5016 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_FRAME
);
5017 SetRectRgn( hrgn
, -200, -200, -198, -198 );
5018 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_VALIDATE
| RDW_NOFRAME
| RDW_ERASENOW
);
5019 ok_sequence( WmEmptySeq
, "EmptySeq", FALSE
);
5022 SetRectRgn( hrgn
, -4, -4, -2, -2 );
5023 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_FRAME
);
5024 SetRectRgn( hrgn
, -4, -4, -3, -3 );
5025 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_VALIDATE
| RDW_NOFRAME
);
5026 SetRectRgn( hrgn
, 0, 0, 1, 1 );
5027 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_UPDATENOW
);
5028 ok_sequence( WmPaint
, "Paint", FALSE
);
5031 SetRectRgn( hrgn
, -4, -4, -1, -1 );
5032 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_FRAME
);
5033 RedrawWindow( hwnd
, NULL
, 0, RDW_ERASENOW
);
5034 /* make sure no WM_PAINT was generated */
5035 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
5036 ok_sequence( WmInvalidateRgn
, "InvalidateRgn", FALSE
);
5039 SetRectRgn( hrgn
, -4, -4, -1, -1 );
5040 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_FRAME
);
5041 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
))
5043 if (msg
.hwnd
== hwnd
&& msg
.message
== WM_PAINT
)
5045 /* GetUpdateRgn must return empty region since only nonclient area is invalidated */
5046 INT ret
= GetUpdateRgn( hwnd
, hrgn
, FALSE
);
5047 ok( ret
== NULLREGION
, "Invalid GetUpdateRgn result %d\n", ret
);
5048 ret
= GetUpdateRect( hwnd
, &rect
, FALSE
);
5049 ok( ret
, "Invalid GetUpdateRect result %d\n", ret
);
5050 /* this will send WM_NCPAINT and validate the non client area */
5051 ret
= GetUpdateRect( hwnd
, &rect
, TRUE
);
5052 ok( !ret
, "Invalid GetUpdateRect result %d\n", ret
);
5054 DispatchMessage( &msg
);
5056 ok_sequence( WmGetUpdateRect
, "GetUpdateRect", FALSE
);
5058 DestroyWindow( hwnd
);
5060 /* now test with a child window */
5062 hparent
= CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW
,
5063 100, 100, 200, 200, 0, 0, 0, NULL
);
5064 ok (hparent
!= 0, "Failed to create parent window\n");
5066 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
| WS_VISIBLE
| WS_BORDER
,
5067 10, 10, 100, 100, hparent
, 0, 0, NULL
);
5068 ok (hchild
!= 0, "Failed to create child window\n");
5070 ShowWindow( hparent
, SW_SHOW
);
5071 UpdateWindow( hparent
);
5072 UpdateWindow( hchild
);
5075 log_all_parent_messages
++;
5077 SetRect( &rect
, 0, 0, 50, 50 );
5078 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
5079 RedrawWindow( hparent
, NULL
, 0, RDW_ERASENOW
| RDW_ALLCHILDREN
);
5080 ok_sequence( WmInvalidateParentChild
, "InvalidateParentChild", FALSE
);
5082 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
5084 MapWindowPoints( hchild
, hparent
, &pt
, 1 );
5085 SetRectRgn( hrgn
, 0, 0, 50 - pt
.x
, 50 - pt
.y
);
5086 check_update_rgn( hchild
, hrgn
);
5087 SetRectRgn( hrgn
, 0, 0, 50, 50 );
5088 check_update_rgn( hparent
, hrgn
);
5089 RedrawWindow( hparent
, NULL
, 0, RDW_ERASENOW
);
5090 ok_sequence( WmInvalidateParent
, "InvalidateParent", FALSE
);
5091 RedrawWindow( hchild
, NULL
, 0, RDW_ERASENOW
);
5092 ok_sequence( WmEmptySeq
, "EraseNow child", FALSE
);
5094 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
5095 ok_sequence( WmParentPaintNc
, "WmParentPaintNc", FALSE
);
5097 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
| RDW_ALLCHILDREN
);
5098 RedrawWindow( hparent
, NULL
, 0, RDW_ERASENOW
);
5099 ok_sequence( WmInvalidateParent
, "InvalidateParent2", FALSE
);
5100 RedrawWindow( hchild
, NULL
, 0, RDW_ERASENOW
);
5101 ok_sequence( WmEmptySeq
, "EraseNow child", FALSE
);
5103 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
);
5104 RedrawWindow( hparent
, NULL
, 0, RDW_ERASENOW
| RDW_ALLCHILDREN
);
5105 ok_sequence( WmInvalidateParentChild2
, "InvalidateParentChild2", FALSE
);
5107 SetWindowLong( hparent
, GWL_STYLE
, GetWindowLong(hparent
,GWL_STYLE
) | WS_CLIPCHILDREN
);
5109 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
| RDW_ALLCHILDREN
);
5110 RedrawWindow( hparent
, NULL
, 0, RDW_ERASENOW
);
5111 ok_sequence( WmInvalidateParentChild
, "InvalidateParentChild3", FALSE
);
5113 /* flush all paint messages */
5114 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
5117 /* RDW_UPDATENOW on child with WS_CLIPCHILDREN doesn't change corresponding parent area */
5118 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
| RDW_ALLCHILDREN
);
5119 SetRectRgn( hrgn
, 0, 0, 50, 50 );
5120 check_update_rgn( hparent
, hrgn
);
5121 RedrawWindow( hchild
, NULL
, 0, RDW_UPDATENOW
);
5122 ok_sequence( WmInvalidateErasePaint2
, "WmInvalidateErasePaint2", FALSE
);
5123 SetRectRgn( hrgn
, 0, 0, 50, 50 );
5124 check_update_rgn( hparent
, hrgn
);
5126 /* flush all paint messages */
5127 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
5128 SetWindowLong( hparent
, GWL_STYLE
, GetWindowLong(hparent
,GWL_STYLE
) & ~WS_CLIPCHILDREN
);
5131 /* RDW_UPDATENOW on child without WS_CLIPCHILDREN will validate corresponding parent area */
5132 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
5133 SetRectRgn( hrgn
, 0, 0, 50, 50 );
5134 check_update_rgn( hparent
, hrgn
);
5135 RedrawWindow( hchild
, NULL
, 0, RDW_UPDATENOW
);
5136 ok_sequence( WmInvalidateErasePaint2
, "WmInvalidateErasePaint2", FALSE
);
5137 SetRectRgn( hrgn2
, 10, 10, 50, 50 );
5138 CombineRgn( hrgn
, hrgn
, hrgn2
, RGN_DIFF
);
5139 check_update_rgn( hparent
, hrgn
);
5140 /* flush all paint messages */
5141 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
5144 /* same as above but parent gets completely validated */
5145 SetRect( &rect
, 20, 20, 30, 30 );
5146 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
5147 SetRectRgn( hrgn
, 20, 20, 30, 30 );
5148 check_update_rgn( hparent
, hrgn
);
5149 RedrawWindow( hchild
, NULL
, 0, RDW_UPDATENOW
);
5150 ok_sequence( WmInvalidateErasePaint2
, "WmInvalidateErasePaint2", FALSE
);
5151 check_update_rgn( hparent
, 0 ); /* no update region */
5152 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
5153 ok_sequence( WmEmptySeq
, "WmEmpty", FALSE
); /* and no paint messages */
5155 /* make sure RDW_VALIDATE on child doesn't have the same effect */
5157 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
5158 SetRectRgn( hrgn
, 20, 20, 30, 30 );
5159 check_update_rgn( hparent
, hrgn
);
5160 RedrawWindow( hchild
, NULL
, 0, RDW_VALIDATE
| RDW_NOERASE
);
5161 SetRectRgn( hrgn
, 20, 20, 30, 30 );
5162 check_update_rgn( hparent
, hrgn
);
5164 /* same as above but normal WM_PAINT doesn't validate parent */
5166 SetRect( &rect
, 20, 20, 30, 30 );
5167 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
5168 SetRectRgn( hrgn
, 20, 20, 30, 30 );
5169 check_update_rgn( hparent
, hrgn
);
5170 /* no WM_PAINT in child while parent still pending */
5171 while (PeekMessage( &msg
, hchild
, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
5172 ok_sequence( WmEmptySeq
, "No WM_PAINT", FALSE
);
5173 while (PeekMessage( &msg
, hparent
, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
5174 ok_sequence( WmParentErasePaint
, "WmParentErasePaint", FALSE
);
5177 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
5178 /* no WM_PAINT in child while parent still pending */
5179 while (PeekMessage( &msg
, hchild
, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
5180 ok_sequence( WmEmptySeq
, "No WM_PAINT", FALSE
);
5181 RedrawWindow( hparent
, &rect
, 0, RDW_VALIDATE
| RDW_NOERASE
| RDW_NOCHILDREN
);
5182 /* now that parent is valid child should get WM_PAINT */
5183 while (PeekMessage( &msg
, hchild
, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
5184 ok_sequence( WmInvalidateErasePaint2
, "WmInvalidateErasePaint2", FALSE
);
5185 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
5186 ok_sequence( WmEmptySeq
, "No other message", FALSE
);
5188 /* same thing with WS_CLIPCHILDREN in parent */
5190 SetWindowLong( hparent
, GWL_STYLE
, GetWindowLong(hparent
,GWL_STYLE
) | WS_CLIPCHILDREN
);
5191 ok_sequence( WmSetParentStyle
, "WmSetParentStyle", FALSE
);
5192 /* changing style invalidates non client area, but we need to invalidate something else to see it */
5193 RedrawWindow( hparent
, &rect
, 0, RDW_UPDATENOW
);
5194 ok_sequence( WmEmptySeq
, "No message", FALSE
);
5195 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_UPDATENOW
);
5196 ok_sequence( WmParentOnlyNcPaint
, "WmParentOnlyNcPaint", FALSE
);
5199 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_ALLCHILDREN
);
5200 SetRectRgn( hrgn
, 20, 20, 30, 30 );
5201 check_update_rgn( hparent
, hrgn
);
5202 /* no WM_PAINT in child while parent still pending */
5203 while (PeekMessage( &msg
, hchild
, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
5204 ok_sequence( WmEmptySeq
, "No WM_PAINT", FALSE
);
5205 /* WM_PAINT in parent first */
5206 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
5207 ok_sequence( WmParentPaintNc
, "WmParentPaintNc2", FALSE
);
5209 /* no RDW_ERASE in parent still causes RDW_ERASE and RDW_FRAME in child */
5211 SetRect( &rect
, 0, 0, 30, 30 );
5212 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ALLCHILDREN
);
5213 SetRectRgn( hrgn
, 0, 0, 30, 30 );
5214 check_update_rgn( hparent
, hrgn
);
5215 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
5216 ok_sequence( WmParentPaintNc
, "WmParentPaintNc3", FALSE
);
5218 /* validate doesn't cause RDW_NOERASE or RDW_NOFRAME in child */
5220 SetRect( &rect
, -10, 0, 30, 30 );
5221 RedrawWindow( hchild
, &rect
, 0, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASE
);
5222 SetRect( &rect
, 0, 0, 20, 20 );
5223 RedrawWindow( hparent
, &rect
, 0, RDW_VALIDATE
| RDW_ALLCHILDREN
);
5224 RedrawWindow( hparent
, NULL
, 0, RDW_UPDATENOW
);
5225 ok_sequence( WmChildPaintNc
, "WmChildPaintNc", FALSE
);
5227 /* validate doesn't cause RDW_NOERASE or RDW_NOFRAME in child */
5229 SetRect( &rect
, -10, 0, 30, 30 );
5230 RedrawWindow( hchild
, &rect
, 0, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASE
);
5231 SetRect( &rect
, 0, 0, 100, 100 );
5232 RedrawWindow( hparent
, &rect
, 0, RDW_VALIDATE
| RDW_ALLCHILDREN
);
5233 RedrawWindow( hparent
, NULL
, 0, RDW_UPDATENOW
);
5234 ok_sequence( WmEmptySeq
, "WmChildPaintNc2", FALSE
);
5235 RedrawWindow( hparent
, NULL
, 0, RDW_ERASENOW
);
5236 ok_sequence( WmEmptySeq
, "WmChildPaintNc3", FALSE
);
5238 /* test RDW_INTERNALPAINT behavior */
5241 RedrawWindow( hparent
, NULL
, 0, RDW_INTERNALPAINT
| RDW_NOCHILDREN
);
5242 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
5243 ok_sequence( WmParentOnlyPaint
, "WmParentOnlyPaint", FALSE
);
5245 RedrawWindow( hparent
, NULL
, 0, RDW_INTERNALPAINT
| RDW_ALLCHILDREN
);
5246 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
5247 ok_sequence( WmParentPaint
, "WmParentPaint", FALSE
);
5249 RedrawWindow( hparent
, NULL
, 0, RDW_INTERNALPAINT
);
5250 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
5251 ok_sequence( WmParentOnlyPaint
, "WmParentOnlyPaint", FALSE
);
5253 assert( GetWindowLong(hparent
, GWL_STYLE
) & WS_CLIPCHILDREN
);
5254 UpdateWindow( hparent
);
5255 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
5257 trace("testing SWP_FRAMECHANGED on parent with WS_CLIPCHILDREN\n");
5258 RedrawWindow( hchild
, NULL
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
5259 SetWindowPos( hparent
, 0, 0, 0, 0, 0, SWP_NOSIZE
| SWP_NOMOVE
|
5260 SWP_NOACTIVATE
| SWP_NOZORDER
| SWP_FRAMECHANGED
);
5261 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
5262 ok_sequence(WmSWP_FrameChanged_clip
, "SetWindowPos:FrameChanged_clip", FALSE
);
5264 UpdateWindow( hparent
);
5265 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
5267 trace("testing SWP_FRAMECHANGED|SWP_DEFERERASE on parent with WS_CLIPCHILDREN\n");
5268 RedrawWindow( hchild
, NULL
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
5269 SetWindowPos( hparent
, 0, 0, 0, 0, 0, SWP_NOSIZE
| SWP_NOMOVE
| SWP_DEFERERASE
|
5270 SWP_NOACTIVATE
| SWP_NOZORDER
| SWP_FRAMECHANGED
);
5271 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
5272 ok_sequence(WmSWP_FrameChangedDeferErase
, "SetWindowPos:FrameChangedDeferErase", FALSE
);
5274 SetWindowLong( hparent
, GWL_STYLE
, GetWindowLong(hparent
,GWL_STYLE
) & ~WS_CLIPCHILDREN
);
5275 ok_sequence( WmSetParentStyle
, "WmSetParentStyle", FALSE
);
5276 RedrawWindow( hparent
, NULL
, 0, RDW_INTERNALPAINT
);
5277 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
5278 ok_sequence( WmParentPaint
, "WmParentPaint", FALSE
);
5280 assert( !(GetWindowLong(hparent
, GWL_STYLE
) & WS_CLIPCHILDREN
) );
5281 UpdateWindow( hparent
);
5282 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
5284 trace("testing SWP_FRAMECHANGED on parent without WS_CLIPCHILDREN\n");
5285 RedrawWindow( hchild
, NULL
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
5286 SetWindowPos( hparent
, 0, 0, 0, 0, 0, SWP_NOSIZE
| SWP_NOMOVE
|
5287 SWP_NOACTIVATE
| SWP_NOZORDER
| SWP_FRAMECHANGED
);
5288 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
5289 ok_sequence(WmSWP_FrameChanged_noclip
, "SetWindowPos:FrameChanged_noclip", FALSE
);
5291 UpdateWindow( hparent
);
5292 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
5294 trace("testing SWP_FRAMECHANGED|SWP_DEFERERASE on parent without WS_CLIPCHILDREN\n");
5295 RedrawWindow( hchild
, NULL
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
5296 SetWindowPos( hparent
, 0, 0, 0, 0, 0, SWP_NOSIZE
| SWP_NOMOVE
| SWP_DEFERERASE
|
5297 SWP_NOACTIVATE
| SWP_NOZORDER
| SWP_FRAMECHANGED
);
5298 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
5299 ok_sequence(WmSWP_FrameChangedDeferErase
, "SetWindowPos:FrameChangedDeferErase", FALSE
);
5301 log_all_parent_messages
--;
5302 DestroyWindow( hparent
);
5303 ok(!IsWindow(hchild
), "child must be destroyed with its parent\n");
5305 DeleteObject( hrgn
);
5306 DeleteObject( hrgn2
);
5315 static DWORD WINAPI
thread_proc(void *param
)
5318 struct wnd_event
*wnd_event
= (struct wnd_event
*)param
;
5320 wnd_event
->hwnd
= CreateWindowExA(0, "TestWindowClass", "window caption text", WS_OVERLAPPEDWINDOW
,
5321 100, 100, 200, 200, 0, 0, 0, NULL
);
5322 ok(wnd_event
->hwnd
!= 0, "Failed to create overlapped window\n");
5324 SetEvent(wnd_event
->event
);
5326 while (GetMessage(&msg
, 0, 0, 0))
5328 TranslateMessage(&msg
);
5329 DispatchMessage(&msg
);
5332 ok(IsWindow(wnd_event
->hwnd
), "window should still exist\n");
5337 static void test_interthread_messages(void)
5344 int len
, expected_len
;
5345 struct wnd_event wnd_event
;
5348 wnd_event
.event
= CreateEventW(NULL
, 0, 0, NULL
);
5349 if (!wnd_event
.event
)
5351 trace("skipping interthread message test under win9x\n");
5355 hThread
= CreateThread(NULL
, 0, thread_proc
, &wnd_event
, 0, &tid
);
5356 ok(hThread
!= NULL
, "CreateThread failed, error %d\n", GetLastError());
5358 ok(WaitForSingleObject(wnd_event
.event
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
5360 CloseHandle(wnd_event
.event
);
5362 SetLastError(0xdeadbeef);
5363 ok(!DestroyWindow(wnd_event
.hwnd
), "DestroyWindow succeded\n");
5364 ok(GetLastError() == ERROR_ACCESS_DENIED
, "wrong error code %d\n", GetLastError());
5366 proc
= (WNDPROC
)GetWindowLongPtrA(wnd_event
.hwnd
, GWLP_WNDPROC
);
5367 ok(proc
!= NULL
, "GetWindowLongPtrA(GWLP_WNDPROC) error %d\n", GetLastError());
5369 expected_len
= lstrlenA("window caption text");
5370 memset(buf
, 0, sizeof(buf
));
5371 SetLastError(0xdeadbeef);
5372 len
= CallWindowProcA(proc
, wnd_event
.hwnd
, WM_GETTEXT
, sizeof(buf
), (LPARAM
)buf
);
5373 ok(len
== expected_len
, "CallWindowProcA(WM_GETTEXT) error %d, len %d, expected len %d\n", GetLastError(), len
, expected_len
);
5374 ok(!lstrcmpA(buf
, "window caption text"), "window text mismatch\n");
5376 msg
.hwnd
= wnd_event
.hwnd
;
5377 msg
.message
= WM_GETTEXT
;
5378 msg
.wParam
= sizeof(buf
);
5379 msg
.lParam
= (LPARAM
)buf
;
5380 memset(buf
, 0, sizeof(buf
));
5381 SetLastError(0xdeadbeef);
5382 len
= DispatchMessageA(&msg
);
5383 ok(!len
&& GetLastError() == ERROR_MESSAGE_SYNC_ONLY
,
5384 "DispatchMessageA(WM_GETTEXT) succeded on another thread window: ret %d, error %d\n", len
, GetLastError());
5386 /* the following test causes an exception in user.exe under win9x */
5387 msg
.hwnd
= wnd_event
.hwnd
;
5388 msg
.message
= WM_TIMER
;
5390 msg
.lParam
= GetWindowLongPtrA(wnd_event
.hwnd
, GWLP_WNDPROC
);
5391 SetLastError(0xdeadbeef);
5392 len
= DispatchMessageA(&msg
);
5393 ok(!len
&& GetLastError() == 0xdeadbeef,
5394 "DispatchMessageA(WM_TIMER) failed on another thread window: ret %d, error %d\n", len
, GetLastError());
5396 ret
= PostMessageA(wnd_event
.hwnd
, WM_QUIT
, 0, 0);
5397 ok( ret
, "PostMessageA(WM_QUIT) error %d\n", GetLastError());
5399 ok(WaitForSingleObject(hThread
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
5400 CloseHandle(hThread
);
5402 ok(!IsWindow(wnd_event
.hwnd
), "window should be destroyed on thread exit\n");
5406 static const struct message WmVkN
[] = {
5407 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 1 }, /* XP */
5408 { WM_KEYDOWN
, wparam
|lparam
, 'N', 1 },
5409 { WM_KEYDOWN
, sent
|wparam
|lparam
, 'N', 1 },
5410 { WM_CHAR
, wparam
|lparam
, 'n', 1 },
5411 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1002,1), 0 },
5412 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xc0000001 }, /* XP */
5413 { WM_KEYUP
, wparam
|lparam
, 'N', 0xc0000001 },
5414 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xc0000001 },
5417 static const struct message WmShiftVkN
[] = {
5418 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 1 }, /* XP */
5419 { WM_KEYDOWN
, wparam
|lparam
, VK_SHIFT
, 1 },
5420 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_SHIFT
, 1 },
5421 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 1 }, /* XP */
5422 { WM_KEYDOWN
, wparam
|lparam
, 'N', 1 },
5423 { WM_KEYDOWN
, sent
|wparam
|lparam
, 'N', 1 },
5424 { WM_CHAR
, wparam
|lparam
, 'N', 1 },
5425 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1001,1), 0 },
5426 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xc0000001 }, /* XP */
5427 { WM_KEYUP
, wparam
|lparam
, 'N', 0xc0000001 },
5428 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xc0000001 },
5429 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 0xc0000001 }, /* XP */
5430 { WM_KEYUP
, wparam
|lparam
, VK_SHIFT
, 0xc0000001 },
5431 { WM_KEYUP
, sent
|wparam
|lparam
, VK_SHIFT
, 0xc0000001 },
5434 static const struct message WmCtrlVkN
[] = {
5435 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 1 }, /* XP */
5436 { WM_KEYDOWN
, wparam
|lparam
, VK_CONTROL
, 1 },
5437 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_CONTROL
, 1 },
5438 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 1 }, /* XP */
5439 { WM_KEYDOWN
, wparam
|lparam
, 'N', 1 },
5440 { WM_KEYDOWN
, sent
|wparam
|lparam
, 'N', 1 },
5441 { WM_CHAR
, wparam
|lparam
, 0x000e, 1 },
5442 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1000,1), 0 },
5443 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xc0000001 }, /* XP */
5444 { WM_KEYUP
, wparam
|lparam
, 'N', 0xc0000001 },
5445 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xc0000001 },
5446 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 0xc0000001 }, /* XP */
5447 { WM_KEYUP
, wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
5448 { WM_KEYUP
, sent
|wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
5451 static const struct message WmCtrlVkN_2
[] = {
5452 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 1 }, /* XP */
5453 { WM_KEYDOWN
, wparam
|lparam
, VK_CONTROL
, 1 },
5454 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_CONTROL
, 1 },
5455 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 1 }, /* XP */
5456 { WM_KEYDOWN
, wparam
|lparam
, 'N', 1 },
5457 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1000,1), 0 },
5458 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xc0000001 }, /* XP */
5459 { WM_KEYUP
, wparam
|lparam
, 'N', 0xc0000001 },
5460 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xc0000001 },
5461 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 0xc0000001 }, /* XP */
5462 { WM_KEYUP
, wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
5463 { WM_KEYUP
, sent
|wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
5466 static const struct message WmAltVkN
[] = {
5467 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 }, /* XP */
5468 { WM_SYSKEYDOWN
, wparam
|lparam
, VK_MENU
, 0x20000001 },
5469 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
5470 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0x20000001 }, /* XP */
5471 { WM_SYSKEYDOWN
, wparam
|lparam
, 'N', 0x20000001 },
5472 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, 'N', 0x20000001 },
5473 { WM_SYSCHAR
, wparam
|lparam
, 'n', 0x20000001 },
5474 { WM_SYSCHAR
, sent
|wparam
|lparam
, 'n', 0x20000001 },
5475 { WM_SYSCOMMAND
, sent
|defwinproc
|wparam
|lparam
, SC_KEYMENU
, 'n' },
5476 { HCBT_SYSCOMMAND
, hook
},
5477 { WM_ENTERMENULOOP
, sent
|defwinproc
|wparam
|lparam
, 0, 0 },
5478 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
5479 { 0x00AE, sent
|defwinproc
|optional
}, /* XP */
5480 { WM_GETTEXT
, sent
|defwinproc
|optional
}, /* XP */
5481 { WM_INITMENU
, sent
|defwinproc
},
5482 { EVENT_SYSTEM_MENUSTART
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 0 },
5483 { WM_MENUCHAR
, sent
|defwinproc
|wparam
, MAKEWPARAM('n',MF_SYSMENU
) },
5484 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, 0, 0 },
5485 { WM_CAPTURECHANGED
, sent
|defwinproc
},
5486 { WM_MENUSELECT
, sent
|defwinproc
|wparam
, MAKEWPARAM(0,0xffff) },
5487 { EVENT_SYSTEM_MENUEND
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 0 },
5488 { WM_EXITMENULOOP
, sent
|defwinproc
},
5489 { WM_MENUSELECT
, sent
|defwinproc
|wparam
|optional
, MAKEWPARAM(0,0xffff) }, /* Win95 bug */
5490 { WM_EXITMENULOOP
, sent
|defwinproc
|optional
}, /* Win95 bug */
5491 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xe0000001 }, /* XP */
5492 { WM_SYSKEYUP
, wparam
|lparam
, 'N', 0xe0000001 },
5493 { WM_SYSKEYUP
, sent
|wparam
|lparam
, 'N', 0xe0000001 },
5494 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xc0000001 }, /* XP */
5495 { WM_KEYUP
, wparam
|lparam
, VK_MENU
, 0xc0000001 },
5496 { WM_KEYUP
, sent
|wparam
|lparam
, VK_MENU
, 0xc0000001 },
5499 static const struct message WmAltVkN_2
[] = {
5500 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 }, /* XP */
5501 { WM_SYSKEYDOWN
, wparam
|lparam
, VK_MENU
, 0x20000001 },
5502 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
5503 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0x20000001 }, /* XP */
5504 { WM_SYSKEYDOWN
, wparam
|lparam
, 'N', 0x20000001 },
5505 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1003,1), 0 },
5506 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xe0000001 }, /* XP */
5507 { WM_SYSKEYUP
, wparam
|lparam
, 'N', 0xe0000001 },
5508 { WM_SYSKEYUP
, sent
|wparam
|lparam
, 'N', 0xe0000001 },
5509 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xc0000001 }, /* XP */
5510 { WM_KEYUP
, wparam
|lparam
, VK_MENU
, 0xc0000001 },
5511 { WM_KEYUP
, sent
|wparam
|lparam
, VK_MENU
, 0xc0000001 },
5514 static const struct message WmCtrlAltVkN
[] = {
5515 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 1 }, /* XP */
5516 { WM_KEYDOWN
, wparam
|lparam
, VK_CONTROL
, 1 },
5517 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_CONTROL
, 1 },
5518 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 }, /* XP */
5519 { WM_KEYDOWN
, wparam
|lparam
, VK_MENU
, 0x20000001 },
5520 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
5521 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0x20000001 }, /* XP */
5522 { WM_KEYDOWN
, wparam
|lparam
, 'N', 0x20000001 },
5523 { WM_KEYDOWN
, sent
|wparam
|lparam
, 'N', 0x20000001 },
5524 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xe0000001 }, /* XP */
5525 { WM_KEYUP
, wparam
|lparam
, 'N', 0xe0000001 },
5526 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xe0000001 },
5527 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xc0000001 }, /* XP */
5528 { WM_KEYUP
, wparam
|lparam
, VK_MENU
, 0xc0000001 },
5529 { WM_KEYUP
, sent
|wparam
|lparam
, VK_MENU
, 0xc0000001 },
5530 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 0xc0000001 }, /* XP */
5531 { WM_KEYUP
, wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
5532 { WM_KEYUP
, sent
|wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
5535 static const struct message WmCtrlShiftVkN
[] = {
5536 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 1 }, /* XP */
5537 { WM_KEYDOWN
, wparam
|lparam
, VK_CONTROL
, 1 },
5538 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_CONTROL
, 1 },
5539 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 1 }, /* XP */
5540 { WM_KEYDOWN
, wparam
|lparam
, VK_SHIFT
, 1 },
5541 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_SHIFT
, 1 },
5542 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 1 }, /* XP */
5543 { WM_KEYDOWN
, wparam
|lparam
, 'N', 1 },
5544 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1004,1), 0 },
5545 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xc0000001 }, /* XP */
5546 { WM_KEYUP
, wparam
|lparam
, 'N', 0xc0000001 },
5547 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xc0000001 },
5548 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 0xc0000001 }, /* XP */
5549 { WM_KEYUP
, wparam
|lparam
, VK_SHIFT
, 0xc0000001 },
5550 { WM_KEYUP
, sent
|wparam
|lparam
, VK_SHIFT
, 0xc0000001 },
5551 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 0xc0000001 }, /* XP */
5552 { WM_KEYUP
, wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
5553 { WM_KEYUP
, sent
|wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
5556 static const struct message WmCtrlAltShiftVkN
[] = {
5557 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 1 }, /* XP */
5558 { WM_KEYDOWN
, wparam
|lparam
, VK_CONTROL
, 1 },
5559 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_CONTROL
, 1 },
5560 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 }, /* XP */
5561 { WM_KEYDOWN
, wparam
|lparam
, VK_MENU
, 0x20000001 },
5562 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
5563 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 0x20000001 }, /* XP */
5564 { WM_KEYDOWN
, wparam
|lparam
, VK_SHIFT
, 0x20000001 },
5565 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_SHIFT
, 0x20000001 },
5566 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0x20000001 }, /* XP */
5567 { WM_KEYDOWN
, wparam
|lparam
, 'N', 0x20000001 },
5568 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1005,1), 0 },
5569 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xe0000001 }, /* XP */
5570 { WM_KEYUP
, wparam
|lparam
, 'N', 0xe0000001 },
5571 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xe0000001 },
5572 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 0xe0000001 }, /* XP */
5573 { WM_KEYUP
, wparam
|lparam
, VK_SHIFT
, 0xe0000001 },
5574 { WM_KEYUP
, sent
|wparam
|lparam
, VK_SHIFT
, 0xe0000001 },
5575 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xc0000001 }, /* XP */
5576 { WM_KEYUP
, wparam
|lparam
, VK_MENU
, 0xc0000001 },
5577 { WM_KEYUP
, sent
|wparam
|lparam
, VK_MENU
, 0xc0000001 },
5578 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 0xc0000001 }, /* XP */
5579 { WM_KEYUP
, wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
5580 { WM_KEYUP
, sent
|wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
5583 static const struct message WmAltPressRelease
[] = {
5584 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 }, /* XP */
5585 { WM_SYSKEYDOWN
, wparam
|lparam
, VK_MENU
, 0x20000001 },
5586 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
5587 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xc0000001 }, /* XP */
5588 { WM_SYSKEYUP
, wparam
|lparam
, VK_MENU
, 0xc0000001 },
5589 { WM_SYSKEYUP
, sent
|wparam
|lparam
, VK_MENU
, 0xc0000001 },
5590 { WM_SYSCOMMAND
, sent
|defwinproc
|wparam
|lparam
, SC_KEYMENU
, 0 },
5591 { HCBT_SYSCOMMAND
, hook
},
5592 { WM_ENTERMENULOOP
, sent
|defwinproc
|wparam
|lparam
, 0, 0 },
5593 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
5594 { WM_INITMENU
, sent
|defwinproc
},
5595 { EVENT_SYSTEM_MENUSTART
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 0 },
5596 { WM_MENUSELECT
, sent
|defwinproc
|wparam
, MAKEWPARAM(0,MF_SYSMENU
|MF_POPUP
|MF_HILITE
) },
5597 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 1 },
5599 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x30000001 }, /* XP */
5601 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 0 },
5602 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, 0, 0, },
5603 { WM_CAPTURECHANGED
, sent
|defwinproc
},
5604 { WM_MENUSELECT
, sent
|defwinproc
|wparam
|optional
, MAKEWPARAM(0,0xffff) },
5605 { EVENT_SYSTEM_MENUEND
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 0 },
5606 { WM_EXITMENULOOP
, sent
|defwinproc
},
5607 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xc0000001 }, /* XP */
5608 { WM_SYSKEYUP
, wparam
|lparam
, VK_MENU
, 0xc0000001 },
5609 { WM_SYSKEYUP
, sent
|wparam
|lparam
, VK_MENU
, 0xc0000001 },
5612 static const struct message WmAltMouseButton
[] = {
5613 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 }, /* XP */
5614 { WM_SYSKEYDOWN
, wparam
|lparam
, VK_MENU
, 0x20000001 },
5615 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
5616 { WM_MOUSEMOVE
, wparam
|optional
, 0, 0 },
5617 { WM_MOUSEMOVE
, sent
|wparam
|optional
, 0, 0 },
5618 { WM_LBUTTONDOWN
, wparam
, MK_LBUTTON
, 0 },
5619 { WM_LBUTTONDOWN
, sent
|wparam
, MK_LBUTTON
, 0 },
5620 { WM_LBUTTONUP
, wparam
, 0, 0 },
5621 { WM_LBUTTONUP
, sent
|wparam
, 0, 0 },
5622 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xc0000001 }, /* XP */
5623 { WM_SYSKEYUP
, wparam
|lparam
, VK_MENU
, 0xc0000001 },
5624 { WM_SYSKEYUP
, sent
|wparam
|lparam
, VK_MENU
, 0xc0000001 },
5627 static const struct message WmF1Seq
[] = {
5628 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_F1
, 1 }, /* XP */
5629 { WM_KEYDOWN
, wparam
|lparam
, VK_F1
, 1 },
5630 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_F1
, 0x00000001 },
5631 { 0x4d, wparam
|lparam
, 0, 0 },
5632 { 0x4d, sent
|wparam
|lparam
, 0, 0 },
5633 { WM_HELP
, sent
|defwinproc
},
5634 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_F1
, 0xc0000001 }, /* XP */
5635 { WM_KEYUP
, wparam
|lparam
, VK_F1
, 0xc0000001 },
5636 { WM_KEYUP
, sent
|wparam
|lparam
, VK_F1
, 0xc0000001 },
5639 static const struct message WmVkAppsSeq
[] = {
5640 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_APPS
, 1 }, /* XP */
5641 { WM_KEYDOWN
, wparam
|lparam
, VK_APPS
, 1 },
5642 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_APPS
, 0x00000001 },
5643 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_APPS
, 0xc0000001 }, /* XP */
5644 { WM_KEYUP
, wparam
|lparam
, VK_APPS
, 0xc0000001 },
5645 { WM_KEYUP
, sent
|wparam
|lparam
, VK_APPS
, 0xc0000001 },
5646 { WM_CONTEXTMENU
, lparam
, /*hwnd*/0, (LPARAM
)-1 },
5647 { WM_CONTEXTMENU
, sent
|lparam
, /*hwnd*/0, (LPARAM
)-1 },
5651 static void pump_msg_loop(HWND hwnd
, HACCEL hAccel
)
5655 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
))
5657 struct message log_msg
;
5659 trace("accel: %p, %04x, %08lx, %08lx\n", msg
.hwnd
, msg
.message
, msg
.wParam
, msg
.lParam
);
5661 /* ignore some unwanted messages */
5662 if (msg
.message
== WM_MOUSEMOVE
||
5663 msg
.message
== WM_GETICON
||
5664 msg
.message
== WM_DEVICECHANGE
)
5667 log_msg
.message
= msg
.message
;
5668 log_msg
.flags
= wparam
|lparam
;
5669 log_msg
.wParam
= msg
.wParam
;
5670 log_msg
.lParam
= msg
.lParam
;
5671 add_message(&log_msg
);
5673 if (!hAccel
|| !TranslateAccelerator(hwnd
, hAccel
, &msg
))
5675 TranslateMessage(&msg
);
5676 DispatchMessage(&msg
);
5681 static void test_accelerators(void)
5686 HWND hwnd
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
5687 100, 100, 200, 200, 0, 0, 0, NULL
);
5696 ok(GetFocus() == hwnd
, "wrong focus window %p\n", GetFocus());
5698 state
= GetKeyState(VK_SHIFT
);
5699 ok(!(state
& 0x8000), "wrong Shift state %04x\n", state
);
5700 state
= GetKeyState(VK_CAPITAL
);
5701 ok(state
== 0, "wrong CapsLock state %04x\n", state
);
5703 hAccel
= LoadAccelerators(GetModuleHandleA(0), MAKEINTRESOURCE(1));
5704 assert(hAccel
!= 0);
5706 pump_msg_loop(hwnd
, 0);
5709 trace("testing VK_N press/release\n");
5711 keybd_event('N', 0, 0, 0);
5712 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
5713 pump_msg_loop(hwnd
, hAccel
);
5714 ok_sequence(WmVkN
, "VK_N press/release", FALSE
);
5716 trace("testing Shift+VK_N press/release\n");
5718 keybd_event(VK_SHIFT
, 0, 0, 0);
5719 keybd_event('N', 0, 0, 0);
5720 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
5721 keybd_event(VK_SHIFT
, 0, KEYEVENTF_KEYUP
, 0);
5722 pump_msg_loop(hwnd
, hAccel
);
5723 ok_sequence(WmShiftVkN
, "Shift+VK_N press/release", FALSE
);
5725 trace("testing Ctrl+VK_N press/release\n");
5727 keybd_event(VK_CONTROL
, 0, 0, 0);
5728 keybd_event('N', 0, 0, 0);
5729 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
5730 keybd_event(VK_CONTROL
, 0, KEYEVENTF_KEYUP
, 0);
5731 pump_msg_loop(hwnd
, hAccel
);
5732 ok_sequence(WmCtrlVkN
, "Ctrl+VK_N press/release", FALSE
);
5734 trace("testing Alt+VK_N press/release\n");
5736 keybd_event(VK_MENU
, 0, 0, 0);
5737 keybd_event('N', 0, 0, 0);
5738 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
5739 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
5740 pump_msg_loop(hwnd
, hAccel
);
5741 ok_sequence(WmAltVkN
, "Alt+VK_N press/release", FALSE
);
5743 trace("testing Ctrl+Alt+VK_N press/release 1\n");
5745 keybd_event(VK_CONTROL
, 0, 0, 0);
5746 keybd_event(VK_MENU
, 0, 0, 0);
5747 keybd_event('N', 0, 0, 0);
5748 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
5749 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
5750 keybd_event(VK_CONTROL
, 0, KEYEVENTF_KEYUP
, 0);
5751 pump_msg_loop(hwnd
, hAccel
);
5752 ok_sequence(WmCtrlAltVkN
, "Ctrl+Alt+VK_N press/release 1", FALSE
);
5754 ret
= DestroyAcceleratorTable(hAccel
);
5755 ok( ret
, "DestroyAcceleratorTable error %d\n", GetLastError());
5757 hAccel
= LoadAccelerators(GetModuleHandleA(0), MAKEINTRESOURCE(2));
5758 assert(hAccel
!= 0);
5760 trace("testing VK_N press/release\n");
5762 keybd_event('N', 0, 0, 0);
5763 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
5764 pump_msg_loop(hwnd
, hAccel
);
5765 ok_sequence(WmVkN
, "VK_N press/release", FALSE
);
5767 trace("testing Shift+VK_N press/release\n");
5769 keybd_event(VK_SHIFT
, 0, 0, 0);
5770 keybd_event('N', 0, 0, 0);
5771 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
5772 keybd_event(VK_SHIFT
, 0, KEYEVENTF_KEYUP
, 0);
5773 pump_msg_loop(hwnd
, hAccel
);
5774 ok_sequence(WmShiftVkN
, "Shift+VK_N press/release", FALSE
);
5776 trace("testing Ctrl+VK_N press/release 2\n");
5778 keybd_event(VK_CONTROL
, 0, 0, 0);
5779 keybd_event('N', 0, 0, 0);
5780 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
5781 keybd_event(VK_CONTROL
, 0, KEYEVENTF_KEYUP
, 0);
5782 pump_msg_loop(hwnd
, hAccel
);
5783 ok_sequence(WmCtrlVkN_2
, "Ctrl+VK_N press/release 2", FALSE
);
5785 trace("testing Alt+VK_N press/release 2\n");
5787 keybd_event(VK_MENU
, 0, 0, 0);
5788 keybd_event('N', 0, 0, 0);
5789 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
5790 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
5791 pump_msg_loop(hwnd
, hAccel
);
5792 ok_sequence(WmAltVkN_2
, "Alt+VK_N press/release 2", FALSE
);
5794 trace("testing Ctrl+Alt+VK_N press/release 2\n");
5796 keybd_event(VK_CONTROL
, 0, 0, 0);
5797 keybd_event(VK_MENU
, 0, 0, 0);
5798 keybd_event('N', 0, 0, 0);
5799 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
5800 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
5801 keybd_event(VK_CONTROL
, 0, KEYEVENTF_KEYUP
, 0);
5802 pump_msg_loop(hwnd
, hAccel
);
5803 ok_sequence(WmCtrlAltVkN
, "Ctrl+Alt+VK_N press/release 2", FALSE
);
5805 trace("testing Ctrl+Shift+VK_N press/release\n");
5807 keybd_event(VK_CONTROL
, 0, 0, 0);
5808 keybd_event(VK_SHIFT
, 0, 0, 0);
5809 keybd_event('N', 0, 0, 0);
5810 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
5811 keybd_event(VK_SHIFT
, 0, KEYEVENTF_KEYUP
, 0);
5812 keybd_event(VK_CONTROL
, 0, KEYEVENTF_KEYUP
, 0);
5813 pump_msg_loop(hwnd
, hAccel
);
5814 ok_sequence(WmCtrlShiftVkN
, "Ctrl+Shift+VK_N press/release", FALSE
);
5816 trace("testing Ctrl+Alt+Shift+VK_N press/release\n");
5818 keybd_event(VK_CONTROL
, 0, 0, 0);
5819 keybd_event(VK_MENU
, 0, 0, 0);
5820 keybd_event(VK_SHIFT
, 0, 0, 0);
5821 keybd_event('N', 0, 0, 0);
5822 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
5823 keybd_event(VK_SHIFT
, 0, KEYEVENTF_KEYUP
, 0);
5824 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
5825 keybd_event(VK_CONTROL
, 0, KEYEVENTF_KEYUP
, 0);
5826 pump_msg_loop(hwnd
, hAccel
);
5827 ok_sequence(WmCtrlAltShiftVkN
, "Ctrl+Alt+Shift+VK_N press/release", FALSE
);
5829 ret
= DestroyAcceleratorTable(hAccel
);
5830 ok( ret
, "DestroyAcceleratorTable error %d\n", GetLastError());
5832 trace("testing Alt press/release\n");
5834 keybd_event(VK_MENU
, 0, 0, 0);
5835 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
5836 keybd_event(VK_MENU
, 0, 0, 0);
5837 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
5838 pump_msg_loop(hwnd
, 0);
5839 /* this test doesn't pass in Wine for managed windows */
5840 ok_sequence(WmAltPressRelease
, "Alt press/release", TRUE
);
5842 trace("testing Alt+MouseButton press/release\n");
5843 /* first, move mouse pointer inside of the window client area */
5844 GetClientRect(hwnd
, &rc
);
5845 MapWindowPoints(hwnd
, 0, (LPPOINT
)&rc
, 2);
5846 rc
.left
+= (rc
.right
- rc
.left
)/2;
5847 rc
.top
+= (rc
.bottom
- rc
.top
)/2;
5848 SetCursorPos(rc
.left
, rc
.top
);
5850 pump_msg_loop(hwnd
, 0);
5852 keybd_event(VK_MENU
, 0, 0, 0);
5853 mouse_event(MOUSEEVENTF_LEFTDOWN
, 0, 0, 0, 0);
5854 mouse_event(MOUSEEVENTF_LEFTUP
, 0, 0, 0, 0);
5855 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
5856 pump_msg_loop(hwnd
, 0);
5857 ok_sequence(WmAltMouseButton
, "Alt+MouseButton press/release", FALSE
);
5859 trace("testing VK_F1 press/release\n");
5860 keybd_event(VK_F1
, 0, 0, 0);
5861 keybd_event(VK_F1
, 0, KEYEVENTF_KEYUP
, 0);
5862 pump_msg_loop(hwnd
, 0);
5863 ok_sequence(WmF1Seq
, "F1 press/release", TRUE
);
5865 trace("testing VK_APPS press/release\n");
5866 keybd_event(VK_APPS
, 0, 0, 0);
5867 keybd_event(VK_APPS
, 0, KEYEVENTF_KEYUP
, 0);
5868 pump_msg_loop(hwnd
, 0);
5869 ok_sequence(WmVkAppsSeq
, "VK_APPS press/release", FALSE
);
5871 DestroyWindow(hwnd
);
5874 /************* window procedures ********************/
5876 static LRESULT
MsgCheckProc (BOOL unicode
, HWND hwnd
, UINT message
,
5877 WPARAM wParam
, LPARAM lParam
)
5879 static long defwndproc_counter
= 0;
5880 static long beginpaint_counter
= 0;
5884 trace("%p, %04x, %08lx, %08lx\n", hwnd
, message
, wParam
, lParam
);
5886 /* explicitly ignore WM_GETICON message */
5887 if (message
== WM_GETICON
) return 0;
5893 LONG style
= GetWindowLongA(hwnd
, GWL_STYLE
);
5894 ok((BOOL
)wParam
== !(style
& WS_DISABLED
),
5895 "wrong WS_DISABLED state: %ld != %d\n", wParam
, !(style
& WS_DISABLED
));
5899 case WM_CAPTURECHANGED
:
5900 if (test_DestroyWindow_flag
)
5902 DWORD style
= GetWindowLongA(hwnd
, GWL_STYLE
);
5903 if (style
& WS_CHILD
)
5904 lParam
= GetWindowLongPtrA(hwnd
, GWLP_ID
);
5905 else if (style
& WS_POPUP
)
5906 lParam
= WND_POPUP_ID
;
5908 lParam
= WND_PARENT_ID
;
5916 ok(!GetWindow(hwnd
, GW_CHILD
), "children should be unlinked at this point\n");
5917 capture
= GetCapture();
5920 ok(capture
== hwnd
, "capture should NOT be released at this point (capture %p)\n", capture
);
5921 trace("current capture %p, releasing...\n", capture
);
5928 ok(pGetAncestor(hwnd
, GA_PARENT
) != 0, "parent should NOT be unlinked at this point\n");
5929 if (test_DestroyWindow_flag
)
5931 DWORD style
= GetWindowLongA(hwnd
, GWL_STYLE
);
5932 if (style
& WS_CHILD
)
5933 lParam
= GetWindowLongPtrA(hwnd
, GWLP_ID
);
5934 else if (style
& WS_POPUP
)
5935 lParam
= WND_POPUP_ID
;
5937 lParam
= WND_PARENT_ID
;
5941 /* test_accelerators() depends on this */
5948 case WM_DEVICECHANGE
:
5951 case WM_WINDOWPOSCHANGING
:
5952 case WM_WINDOWPOSCHANGED
:
5954 WINDOWPOS
*winpos
= (WINDOWPOS
*)lParam
;
5956 trace("%s\n", (message
== WM_WINDOWPOSCHANGING
) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
5957 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
5958 winpos
->hwnd
, winpos
->hwndInsertAfter
,
5959 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
5960 dump_winpos_flags(winpos
->flags
);
5962 /* Log only documented flags, win2k uses 0x1000 and 0x2000
5963 * in the high word for internal purposes
5965 wParam
= winpos
->flags
& 0xffff;
5966 /* We are not interested in the flags that don't match under XP and Win9x */
5967 wParam
&= ~(SWP_NOZORDER
);
5972 msg
.message
= message
;
5973 msg
.flags
= sent
|wparam
|lparam
;
5974 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
5975 if (beginpaint_counter
) msg
.flags
|= beginpaint
;
5976 msg
.wParam
= wParam
;
5977 msg
.lParam
= lParam
;
5980 if (message
== WM_GETMINMAXINFO
&& (GetWindowLongA(hwnd
, GWL_STYLE
) & WS_CHILD
))
5982 HWND parent
= GetParent(hwnd
);
5984 MINMAXINFO
*minmax
= (MINMAXINFO
*)lParam
;
5986 GetClientRect(parent
, &rc
);
5987 trace("parent %p client size = (%d x %d)\n", parent
, rc
.right
, rc
.bottom
);
5989 trace("ptReserved = (%d,%d)\n"
5990 "ptMaxSize = (%d,%d)\n"
5991 "ptMaxPosition = (%d,%d)\n"
5992 "ptMinTrackSize = (%d,%d)\n"
5993 "ptMaxTrackSize = (%d,%d)\n",
5994 minmax
->ptReserved
.x
, minmax
->ptReserved
.y
,
5995 minmax
->ptMaxSize
.x
, minmax
->ptMaxSize
.y
,
5996 minmax
->ptMaxPosition
.x
, minmax
->ptMaxPosition
.y
,
5997 minmax
->ptMinTrackSize
.x
, minmax
->ptMinTrackSize
.y
,
5998 minmax
->ptMaxTrackSize
.x
, minmax
->ptMaxTrackSize
.y
);
6000 ok(minmax
->ptMaxSize
.x
== rc
.right
, "default width of maximized child %d != %d\n",
6001 minmax
->ptMaxSize
.x
, rc
.right
);
6002 ok(minmax
->ptMaxSize
.y
== rc
.bottom
, "default height of maximized child %d != %d\n",
6003 minmax
->ptMaxSize
.y
, rc
.bottom
);
6006 if (message
== WM_PAINT
)
6009 beginpaint_counter
++;
6010 BeginPaint( hwnd
, &ps
);
6011 beginpaint_counter
--;
6012 EndPaint( hwnd
, &ps
);
6016 defwndproc_counter
++;
6017 ret
= unicode
? DefWindowProcW(hwnd
, message
, wParam
, lParam
)
6018 : DefWindowProcA(hwnd
, message
, wParam
, lParam
);
6019 defwndproc_counter
--;
6024 static LRESULT WINAPI
MsgCheckProcA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
6026 return MsgCheckProc (FALSE
, hwnd
, message
, wParam
, lParam
);
6029 static LRESULT WINAPI
MsgCheckProcW(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
6031 return MsgCheckProc (TRUE
, hwnd
, message
, wParam
, lParam
);
6034 static LRESULT WINAPI
PopupMsgCheckProcA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
6036 static long defwndproc_counter
= 0;
6040 trace("popup: %p, %04x, %08lx, %08lx\n", hwnd
, message
, wParam
, lParam
);
6042 /* explicitly ignore WM_GETICON message */
6043 if (message
== WM_GETICON
) return 0;
6045 msg
.message
= message
;
6046 msg
.flags
= sent
|wparam
|lparam
;
6047 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
6048 msg
.wParam
= wParam
;
6049 msg
.lParam
= lParam
;
6052 if (message
== WM_CREATE
)
6054 DWORD style
= GetWindowLongA(hwnd
, GWL_STYLE
) | WS_VISIBLE
;
6055 SetWindowLongA(hwnd
, GWL_STYLE
, style
);
6058 defwndproc_counter
++;
6059 ret
= DefWindowProcA(hwnd
, message
, wParam
, lParam
);
6060 defwndproc_counter
--;
6065 static LRESULT WINAPI
ParentMsgCheckProcA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
6067 static long defwndproc_counter
= 0;
6068 static long beginpaint_counter
= 0;
6072 trace("parent: %p, %04x, %08lx, %08lx\n", hwnd
, message
, wParam
, lParam
);
6074 /* explicitly ignore WM_GETICON message */
6075 if (message
== WM_GETICON
) return 0;
6077 if (log_all_parent_messages
||
6078 message
== WM_PARENTNOTIFY
|| message
== WM_CANCELMODE
||
6079 message
== WM_SETFOCUS
|| message
== WM_KILLFOCUS
||
6080 message
== WM_ENABLE
|| message
== WM_ENTERIDLE
||
6081 message
== WM_IME_SETCONTEXT
)
6095 INT ret
= GetClipBox((HDC
)wParam
, &rc
);
6097 trace("WM_ERASEBKGND: GetClipBox()=%d, (%d,%d-%d,%d)\n",
6098 ret
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
6102 case WM_WINDOWPOSCHANGING
:
6103 case WM_WINDOWPOSCHANGED
:
6105 WINDOWPOS
*winpos
= (WINDOWPOS
*)lParam
;
6107 trace("%s\n", (message
== WM_WINDOWPOSCHANGING
) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
6108 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
6109 winpos
->hwnd
, winpos
->hwndInsertAfter
,
6110 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
6111 dump_winpos_flags(winpos
->flags
);
6113 /* Log only documented flags, win2k uses 0x1000 and 0x2000
6114 * in the high word for internal purposes
6116 wParam
= winpos
->flags
& 0xffff;
6117 /* We are not interested in the flags that don't match under XP and Win9x */
6118 wParam
&= ~(SWP_NOZORDER
);
6123 msg
.message
= message
;
6124 msg
.flags
= sent
|parent
|wparam
|lparam
;
6125 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
6126 if (beginpaint_counter
) msg
.flags
|= beginpaint
;
6127 msg
.wParam
= wParam
;
6128 msg
.lParam
= lParam
;
6132 if (message
== WM_PAINT
)
6135 beginpaint_counter
++;
6136 BeginPaint( hwnd
, &ps
);
6137 beginpaint_counter
--;
6138 EndPaint( hwnd
, &ps
);
6142 defwndproc_counter
++;
6143 ret
= DefWindowProcA(hwnd
, message
, wParam
, lParam
);
6144 defwndproc_counter
--;
6149 static LRESULT WINAPI
TestDlgProcA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
6151 static long defwndproc_counter
= 0;
6155 trace("dialog: %p, %04x, %08lx, %08lx\n", hwnd
, message
, wParam
, lParam
);
6157 /* explicitly ignore WM_GETICON message */
6158 if (message
== WM_GETICON
) return 0;
6162 DefDlgProcA(hwnd
, DM_SETDEFID
, 1, 0);
6163 ret
= DefDlgProcA(hwnd
, DM_GETDEFID
, 0, 0);
6164 if (after_end_dialog
)
6165 ok( ret
== 0, "DM_GETDEFID should return 0 after EndDialog, got %lx\n", ret
);
6167 ok(HIWORD(ret
) == DC_HASDEFID
, "DM_GETDEFID should return DC_HASDEFID, got %lx\n", ret
);
6172 case WM_WINDOWPOSCHANGING
:
6173 case WM_WINDOWPOSCHANGED
:
6175 WINDOWPOS
*winpos
= (WINDOWPOS
*)lParam
;
6177 trace("%s\n", (message
== WM_WINDOWPOSCHANGING
) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
6178 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
6179 winpos
->hwnd
, winpos
->hwndInsertAfter
,
6180 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
6181 dump_winpos_flags(winpos
->flags
);
6183 /* Log only documented flags, win2k uses 0x1000 and 0x2000
6184 * in the high word for internal purposes
6186 wParam
= winpos
->flags
& 0xffff;
6187 /* We are not interested in the flags that don't match under XP and Win9x */
6188 wParam
&= ~(SWP_NOZORDER
);
6193 msg
.message
= message
;
6194 msg
.flags
= sent
|wparam
|lparam
;
6195 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
6196 msg
.wParam
= wParam
;
6197 msg
.lParam
= lParam
;
6200 defwndproc_counter
++;
6201 ret
= DefDlgProcA(hwnd
, message
, wParam
, lParam
);
6202 defwndproc_counter
--;
6207 static void dump_winpos_flags(UINT flags
)
6209 if (!winetest_debug
) return;
6211 if (flags
& SWP_SHOWWINDOW
) printf("|SWP_SHOWWINDOW");
6212 if (flags
& SWP_HIDEWINDOW
) printf("|SWP_HIDEWINDOW");
6213 if (flags
& SWP_NOACTIVATE
) printf("|SWP_NOACTIVATE");
6214 if (flags
& SWP_FRAMECHANGED
) printf("|SWP_FRAMECHANGED");
6215 if (flags
& SWP_NOCOPYBITS
) printf("|SWP_NOCOPYBITS");
6216 if (flags
& SWP_NOOWNERZORDER
) printf("|SWP_NOOWNERZORDER");
6217 if (flags
& SWP_NOSENDCHANGING
) printf("|SWP_NOSENDCHANGING");
6218 if (flags
& SWP_DEFERERASE
) printf("|SWP_DEFERERASE");
6219 if (flags
& SWP_ASYNCWINDOWPOS
) printf("|SWP_ASYNCWINDOWPOS");
6220 if (flags
& SWP_NOZORDER
) printf("|SWP_NOZORDER");
6221 if (flags
& SWP_NOREDRAW
) printf("|SWP_NOREDRAW");
6222 if (flags
& SWP_NOSIZE
) printf("|SWP_NOSIZE");
6223 if (flags
& SWP_NOMOVE
) printf("|SWP_NOMOVE");
6224 if (flags
& SWP_NOCLIENTSIZE
) printf("|SWP_NOCLIENTSIZE");
6225 if (flags
& SWP_NOCLIENTMOVE
) printf("|SWP_NOCLIENTMOVE");
6227 #define DUMPED_FLAGS \
6233 SWP_FRAMECHANGED | \
6237 SWP_NOOWNERZORDER | \
6238 SWP_NOSENDCHANGING | \
6240 SWP_ASYNCWINDOWPOS | \
6241 SWP_NOCLIENTSIZE | \
6244 if(flags
& ~DUMPED_FLAGS
) printf("|0x%04x", flags
& ~DUMPED_FLAGS
);
6249 static LRESULT WINAPI
ShowWindowProcA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
6251 static long defwndproc_counter
= 0;
6255 /* log only specific messages we are interested in */
6258 #if 0 /* probably log these as well */
6264 trace("WM_SHOWWINDOW %ld\n", wParam
);
6267 trace("WM_SIZE %ld\n", wParam
);
6272 case WM_GETMINMAXINFO
:
6273 trace("WM_GETMINMAXINFO\n");
6276 case WM_WINDOWPOSCHANGING
:
6277 case WM_WINDOWPOSCHANGED
:
6279 WINDOWPOS
*winpos
= (WINDOWPOS
*)lParam
;
6281 trace("%s\n", (message
== WM_WINDOWPOSCHANGING
) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
6282 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
6283 winpos
->hwnd
, winpos
->hwndInsertAfter
,
6284 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
6286 dump_winpos_flags(winpos
->flags
);
6288 /* Log only documented flags, win2k uses 0x1000 and 0x2000
6289 * in the high word for internal purposes
6291 wParam
= winpos
->flags
& 0xffff;
6292 /* We are not interested in the flags that don't match under XP and Win9x */
6293 wParam
&= ~(SWP_NOZORDER
);
6297 default: /* ignore */
6298 /*trace("showwindow: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);*/
6299 return DefWindowProcA(hwnd
, message
, wParam
, lParam
);
6302 msg
.message
= message
;
6303 msg
.flags
= sent
|wparam
|lparam
;
6304 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
6305 msg
.wParam
= wParam
;
6306 msg
.lParam
= lParam
;
6309 defwndproc_counter
++;
6310 ret
= DefWindowProcA(hwnd
, message
, wParam
, lParam
);
6311 defwndproc_counter
--;
6316 static BOOL
RegisterWindowClasses(void)
6321 cls
.lpfnWndProc
= MsgCheckProcA
;
6324 cls
.hInstance
= GetModuleHandleA(0);
6326 cls
.hCursor
= LoadCursorA(0, (LPSTR
)IDC_ARROW
);
6327 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
6328 cls
.lpszMenuName
= NULL
;
6329 cls
.lpszClassName
= "TestWindowClass";
6330 if(!RegisterClassA(&cls
)) return FALSE
;
6332 cls
.lpfnWndProc
= ShowWindowProcA
;
6333 cls
.lpszClassName
= "ShowWindowClass";
6334 if(!RegisterClassA(&cls
)) return FALSE
;
6336 cls
.lpfnWndProc
= PopupMsgCheckProcA
;
6337 cls
.lpszClassName
= "TestPopupClass";
6338 if(!RegisterClassA(&cls
)) return FALSE
;
6340 cls
.lpfnWndProc
= ParentMsgCheckProcA
;
6341 cls
.lpszClassName
= "TestParentClass";
6342 if(!RegisterClassA(&cls
)) return FALSE
;
6344 cls
.lpfnWndProc
= DefWindowProcA
;
6345 cls
.lpszClassName
= "SimpleWindowClass";
6346 if(!RegisterClassA(&cls
)) return FALSE
;
6348 cls
.style
= CS_NOCLOSE
;
6349 cls
.lpszClassName
= "NoCloseWindowClass";
6350 if(!RegisterClassA(&cls
)) return FALSE
;
6352 ok(GetClassInfoA(0, "#32770", &cls
), "GetClassInfo failed\n");
6354 cls
.hInstance
= GetModuleHandleA(0);
6355 cls
.hbrBackground
= 0;
6356 cls
.lpfnWndProc
= TestDlgProcA
;
6357 cls
.lpszClassName
= "TestDialogClass";
6358 if(!RegisterClassA(&cls
)) return FALSE
;
6363 static HHOOK hCBT_hook
;
6364 static DWORD cbt_hook_thread_id
;
6366 static LRESULT CALLBACK
cbt_hook_proc(int nCode
, WPARAM wParam
, LPARAM lParam
)
6368 static const char * const CBT_code_name
[10] = {
6375 "HCBT_CLICKSKIPPED",
6379 const char *code_name
= (nCode
>= 0 && nCode
<= HCBT_SETFOCUS
) ? CBT_code_name
[nCode
] : "Unknown";
6383 trace("CBT: %d (%s), %08lx, %08lx\n", nCode
, code_name
, wParam
, lParam
);
6385 ok(cbt_hook_thread_id
== GetCurrentThreadId(), "we didn't ask for events from other threads\n");
6387 if (nCode
== HCBT_CLICKSKIPPED
)
6389 /* ignore this event, XP sends it a lot when switching focus between windows */
6390 return CallNextHookEx(hCBT_hook
, nCode
, wParam
, lParam
);
6393 if (nCode
== HCBT_SYSCOMMAND
|| nCode
== HCBT_KEYSKIPPED
)
6397 msg
.message
= nCode
;
6398 msg
.flags
= hook
|wparam
|lparam
;
6399 msg
.wParam
= wParam
;
6400 msg
.lParam
= lParam
;
6403 return CallNextHookEx(hCBT_hook
, nCode
, wParam
, lParam
);
6406 if (nCode
== HCBT_DESTROYWND
)
6408 if (test_DestroyWindow_flag
)
6410 DWORD style
= GetWindowLongA((HWND
)wParam
, GWL_STYLE
);
6411 if (style
& WS_CHILD
)
6412 lParam
= GetWindowLongPtrA((HWND
)wParam
, GWLP_ID
);
6413 else if (style
& WS_POPUP
)
6414 lParam
= WND_POPUP_ID
;
6416 lParam
= WND_PARENT_ID
;
6420 /* Log also SetFocus(0) calls */
6421 hwnd
= wParam
? (HWND
)wParam
: (HWND
)lParam
;
6423 if (GetClassNameA(hwnd
, buf
, sizeof(buf
)))
6425 if (!lstrcmpiA(buf
, "TestWindowClass") ||
6426 !lstrcmpiA(buf
, "ShowWindowClass") ||
6427 !lstrcmpiA(buf
, "TestParentClass") ||
6428 !lstrcmpiA(buf
, "TestPopupClass") ||
6429 !lstrcmpiA(buf
, "SimpleWindowClass") ||
6430 !lstrcmpiA(buf
, "TestDialogClass") ||
6431 !lstrcmpiA(buf
, "MDI_frame_class") ||
6432 !lstrcmpiA(buf
, "MDI_client_class") ||
6433 !lstrcmpiA(buf
, "MDI_child_class") ||
6434 !lstrcmpiA(buf
, "my_button_class") ||
6435 !lstrcmpiA(buf
, "my_edit_class") ||
6436 !lstrcmpiA(buf
, "static") ||
6437 !lstrcmpiA(buf
, "MyDialogClass") ||
6438 !lstrcmpiA(buf
, "#32770"))
6442 msg
.message
= nCode
;
6443 msg
.flags
= hook
|wparam
|lparam
;
6444 msg
.wParam
= wParam
;
6445 msg
.lParam
= lParam
;
6449 return CallNextHookEx(hCBT_hook
, nCode
, wParam
, lParam
);
6452 static void CALLBACK
win_event_proc(HWINEVENTHOOK hevent
,
6462 trace("WEH:%p,event %08x,hwnd %p,obj %08x,id %08x,thread %08x,time %08x\n",
6463 hevent
, event
, hwnd
, object_id
, child_id
, thread_id
, event_time
);
6465 ok(thread_id
== GetCurrentThreadId(), "we didn't ask for events from other threads\n");
6467 /* ignore mouse cursor events */
6468 if (object_id
== OBJID_CURSOR
) return;
6470 if (!hwnd
|| GetClassNameA(hwnd
, buf
, sizeof(buf
)))
6473 !lstrcmpiA(buf
, "TestWindowClass") ||
6474 !lstrcmpiA(buf
, "TestParentClass") ||
6475 !lstrcmpiA(buf
, "TestPopupClass") ||
6476 !lstrcmpiA(buf
, "SimpleWindowClass") ||
6477 !lstrcmpiA(buf
, "TestDialogClass") ||
6478 !lstrcmpiA(buf
, "MDI_frame_class") ||
6479 !lstrcmpiA(buf
, "MDI_client_class") ||
6480 !lstrcmpiA(buf
, "MDI_child_class") ||
6481 !lstrcmpiA(buf
, "my_button_class") ||
6482 !lstrcmpiA(buf
, "my_edit_class") ||
6483 !lstrcmpiA(buf
, "static") ||
6484 !lstrcmpiA(buf
, "MyDialogClass") ||
6485 !lstrcmpiA(buf
, "#32770"))
6489 msg
.message
= event
;
6490 msg
.flags
= winevent_hook
|wparam
|lparam
;
6491 msg
.wParam
= object_id
;
6492 msg
.lParam
= child_id
;
6498 static const WCHAR wszUnicode
[] = {'U','n','i','c','o','d','e',0};
6499 static const WCHAR wszAnsi
[] = {'U',0};
6501 static LRESULT CALLBACK
MsgConversionProcW(HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
6505 case CB_FINDSTRINGEXACT
:
6506 trace("String: %p\n", (LPCWSTR
)lParam
);
6507 if (!lstrcmpW((LPCWSTR
)lParam
, wszUnicode
))
6509 if (!lstrcmpW((LPCWSTR
)lParam
, wszAnsi
))
6513 return DefWindowProcW(hwnd
, uMsg
, wParam
, lParam
);
6516 static const struct message WmGetTextLengthAfromW
[] = {
6517 { WM_GETTEXTLENGTH
, sent
},
6518 { WM_GETTEXT
, sent
},
6522 static const WCHAR testWindowClassW
[] =
6523 { 'T','e','s','t','W','i','n','d','o','w','C','l','a','s','s','W',0 };
6525 static const WCHAR dummy_window_text
[] = {'d','u','m','m','y',' ','t','e','x','t',0};
6527 /* dummy window proc for WM_GETTEXTLENGTH test */
6528 static LRESULT CALLBACK
get_text_len_proc( HWND hwnd
, UINT msg
, WPARAM wp
, LPARAM lp
)
6532 case WM_GETTEXTLENGTH
:
6533 return lstrlenW(dummy_window_text
) + 37; /* some random length */
6535 lstrcpynW( (LPWSTR
)lp
, dummy_window_text
, wp
);
6536 return lstrlenW( (LPWSTR
)lp
);
6538 return DefWindowProcW( hwnd
, msg
, wp
, lp
);
6542 static void test_message_conversion(void)
6544 static const WCHAR wszMsgConversionClass
[] =
6545 {'M','s','g','C','o','n','v','e','r','s','i','o','n','C','l','a','s','s',0};
6549 WNDPROC wndproc
, newproc
;
6553 cls
.lpfnWndProc
= MsgConversionProcW
;
6556 cls
.hInstance
= GetModuleHandleW(NULL
);
6558 cls
.hCursor
= LoadCursorW(NULL
, (LPWSTR
)IDC_ARROW
);
6559 cls
.hbrBackground
= (HBRUSH
)(COLOR_BTNFACE
+1);
6560 cls
.lpszMenuName
= NULL
;
6561 cls
.lpszClassName
= wszMsgConversionClass
;
6562 /* this call will fail on Win9x, but that doesn't matter as this test is
6563 * meaningless on those platforms */
6564 if(!RegisterClassW(&cls
)) return;
6567 cls
.lpfnWndProc
= MsgCheckProcW
;
6570 cls
.hInstance
= GetModuleHandleW(0);
6572 cls
.hCursor
= LoadCursorW(0, (LPWSTR
)IDC_ARROW
);
6573 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
6574 cls
.lpszMenuName
= NULL
;
6575 cls
.lpszClassName
= testWindowClassW
;
6576 if(!RegisterClassW(&cls
)) return;
6578 hwnd
= CreateWindowExW(0, wszMsgConversionClass
, NULL
, WS_OVERLAPPED
,
6579 100, 100, 200, 200, 0, 0, 0, NULL
);
6580 ok(hwnd
!= NULL
, "Window creation failed\n");
6584 wndproc
= (WNDPROC
)GetWindowLongPtrA(hwnd
, GWLP_WNDPROC
);
6585 lRes
= CallWindowProcA(wndproc
, hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
6586 ok(lRes
== 0, "String should have been converted\n");
6587 lRes
= CallWindowProcW(wndproc
, hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
6588 ok(lRes
== 1, "String shouldn't have been converted\n");
6592 wndproc
= (WNDPROC
)GetWindowLongPtrW(hwnd
, GWLP_WNDPROC
);
6593 lRes
= CallWindowProcA(wndproc
, hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
6594 ok(lRes
== 1, "String shouldn't have been converted\n");
6595 lRes
= CallWindowProcW(wndproc
, hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
6596 ok(lRes
== 1, "String shouldn't have been converted\n");
6598 /* Synchronous messages */
6600 lRes
= SendMessageA(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
6601 ok(lRes
== 0, "String should have been converted\n");
6602 lRes
= SendMessageW(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
6603 ok(lRes
== 1, "String shouldn't have been converted\n");
6605 /* Asynchronous messages */
6608 lRes
= PostMessageA(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
6609 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
6610 "PostMessage on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
6612 lRes
= PostMessageW(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
6613 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
6614 "PostMessage on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
6616 lRes
= PostThreadMessageA(GetCurrentThreadId(), CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
6617 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
6618 "PosThreadtMessage on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
6620 lRes
= PostThreadMessageW(GetCurrentThreadId(), CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
6621 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
6622 "PosThreadtMessage on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
6624 lRes
= SendNotifyMessageA(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
6625 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
6626 "SendNotifyMessage on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
6628 lRes
= SendNotifyMessageW(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
6629 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
6630 "SendNotifyMessage on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
6632 lRes
= SendMessageCallbackA(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
, NULL
, 0);
6633 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
6634 "SendMessageCallback on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
6636 lRes
= SendMessageCallbackW(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
, NULL
, 0);
6637 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
6638 "SendMessageCallback on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
6640 /* Check WM_GETTEXTLENGTH A->W behaviour, whether WM_GETTEXT is also sent or not */
6642 hwnd
= CreateWindowW (testWindowClassW
, wszUnicode
,
6643 WS_OVERLAPPEDWINDOW
,
6644 100, 100, 200, 200, 0, 0, 0, NULL
);
6647 lRes
= SendMessageA (hwnd
, WM_GETTEXTLENGTH
, 0, 0);
6648 ok_sequence(WmGetTextLengthAfromW
, "ANSI WM_GETTEXTLENGTH to Unicode window", FALSE
);
6649 ok( lRes
== WideCharToMultiByte( CP_ACP
, 0, wszUnicode
, lstrlenW(wszUnicode
), NULL
, 0, NULL
, NULL
),
6650 "got bad length %ld\n", lRes
);
6653 lRes
= CallWindowProcA( (WNDPROC
)GetWindowLongPtrA( hwnd
, GWLP_WNDPROC
),
6654 hwnd
, WM_GETTEXTLENGTH
, 0, 0);
6655 ok_sequence(WmGetTextLengthAfromW
, "ANSI WM_GETTEXTLENGTH to Unicode window", FALSE
);
6656 ok( lRes
== WideCharToMultiByte( CP_ACP
, 0, wszUnicode
, lstrlenW(wszUnicode
), NULL
, 0, NULL
, NULL
),
6657 "got bad length %ld\n", lRes
);
6659 wndproc
= (WNDPROC
)SetWindowLongPtrW( hwnd
, GWLP_WNDPROC
, (LONG_PTR
)get_text_len_proc
);
6660 newproc
= (WNDPROC
)GetWindowLongPtrA( hwnd
, GWLP_WNDPROC
);
6661 lRes
= CallWindowProcA( newproc
, hwnd
, WM_GETTEXTLENGTH
, 0, 0 );
6662 ok( lRes
== WideCharToMultiByte( CP_ACP
, 0, dummy_window_text
, lstrlenW(dummy_window_text
),
6663 NULL
, 0, NULL
, NULL
),
6664 "got bad length %ld\n", lRes
);
6666 SetWindowLongPtrW( hwnd
, GWLP_WNDPROC
, (LONG_PTR
)wndproc
); /* restore old wnd proc */
6667 lRes
= CallWindowProcA( newproc
, hwnd
, WM_GETTEXTLENGTH
, 0, 0 );
6668 ok( lRes
== WideCharToMultiByte( CP_ACP
, 0, dummy_window_text
, lstrlenW(dummy_window_text
),
6669 NULL
, 0, NULL
, NULL
),
6670 "got bad length %ld\n", lRes
);
6672 ret
= DestroyWindow(hwnd
);
6673 ok( ret
, "DestroyWindow() error %d\n", GetLastError());
6683 static VOID CALLBACK
tfunc(HWND hwnd
, UINT uMsg
, UINT_PTR id
, DWORD dwTime
)
6687 #define TIMER_ID 0x19
6689 static DWORD WINAPI
timer_thread_proc(LPVOID x
)
6691 struct timer_info
*info
= x
;
6694 r
= KillTimer(info
->hWnd
, 0x19);
6695 ok(r
,"KillTimer failed in thread\n");
6696 r
= SetTimer(info
->hWnd
,TIMER_ID
,10000,tfunc
);
6697 ok(r
,"SetTimer failed in thread\n");
6698 ok(r
==TIMER_ID
,"SetTimer id different\n");
6699 r
= SetEvent(info
->handles
[0]);
6700 ok(r
,"SetEvent failed in thread\n");
6704 static void test_timers(void)
6706 struct timer_info info
;
6709 info
.hWnd
= CreateWindow ("TestWindowClass", NULL
,
6710 WS_OVERLAPPEDWINDOW
,
6711 CW_USEDEFAULT
, CW_USEDEFAULT
, 300, 300, 0,
6714 info
.id
= SetTimer(info
.hWnd
,TIMER_ID
,10000,tfunc
);
6715 ok(info
.id
, "SetTimer failed\n");
6716 ok(info
.id
==TIMER_ID
, "SetTimer timer ID different\n");
6717 info
.handles
[0] = CreateEvent(NULL
,0,0,NULL
);
6718 info
.handles
[1] = CreateThread(NULL
,0,timer_thread_proc
,&info
,0,&id
);
6720 WaitForMultipleObjects(2, info
.handles
, FALSE
, INFINITE
);
6722 WaitForSingleObject(info
.handles
[1], INFINITE
);
6724 CloseHandle(info
.handles
[0]);
6725 CloseHandle(info
.handles
[1]);
6727 ok( KillTimer(info
.hWnd
, TIMER_ID
), "KillTimer failed\n");
6729 ok(DestroyWindow(info
.hWnd
), "failed to destroy window\n");
6732 /* Various win events with arbitrary parameters */
6733 static const struct message WmWinEventsSeq
[] = {
6734 { EVENT_SYSTEM_SOUND
, winevent_hook
|wparam
|lparam
, OBJID_WINDOW
, 0 },
6735 { EVENT_SYSTEM_ALERT
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 1 },
6736 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, OBJID_TITLEBAR
, 2 },
6737 { EVENT_SYSTEM_MENUSTART
, winevent_hook
|wparam
|lparam
, OBJID_MENU
, 3 },
6738 { EVENT_SYSTEM_MENUEND
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 4 },
6739 { EVENT_SYSTEM_MENUPOPUPSTART
, winevent_hook
|wparam
|lparam
, OBJID_VSCROLL
, 5 },
6740 { EVENT_SYSTEM_MENUPOPUPEND
, winevent_hook
|wparam
|lparam
, OBJID_HSCROLL
, 6 },
6741 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, OBJID_SIZEGRIP
, 7 },
6742 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 8 },
6743 /* our win event hook ignores OBJID_CURSOR events */
6744 /*{ EVENT_SYSTEM_MOVESIZESTART, winevent_hook|wparam|lparam, OBJID_CURSOR, 9 },*/
6745 { EVENT_SYSTEM_MOVESIZEEND
, winevent_hook
|wparam
|lparam
, OBJID_ALERT
, 10 },
6746 { EVENT_SYSTEM_CONTEXTHELPSTART
, winevent_hook
|wparam
|lparam
, OBJID_SOUND
, 11 },
6747 { EVENT_SYSTEM_CONTEXTHELPEND
, winevent_hook
|wparam
|lparam
, OBJID_QUERYCLASSNAMEIDX
, 12 },
6748 { EVENT_SYSTEM_DRAGDROPSTART
, winevent_hook
|wparam
|lparam
, OBJID_NATIVEOM
, 13 },
6749 { EVENT_SYSTEM_DRAGDROPEND
, winevent_hook
|wparam
|lparam
, OBJID_WINDOW
, 0 },
6750 { EVENT_SYSTEM_DIALOGSTART
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 1 },
6751 { EVENT_SYSTEM_DIALOGEND
, winevent_hook
|wparam
|lparam
, OBJID_TITLEBAR
, 2 },
6752 { EVENT_SYSTEM_SCROLLINGSTART
, winevent_hook
|wparam
|lparam
, OBJID_MENU
, 3 },
6753 { EVENT_SYSTEM_SCROLLINGEND
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 4 },
6754 { EVENT_SYSTEM_SWITCHSTART
, winevent_hook
|wparam
|lparam
, OBJID_VSCROLL
, 5 },
6755 { EVENT_SYSTEM_SWITCHEND
, winevent_hook
|wparam
|lparam
, OBJID_HSCROLL
, 6 },
6756 { EVENT_SYSTEM_MINIMIZESTART
, winevent_hook
|wparam
|lparam
, OBJID_SIZEGRIP
, 7 },
6757 { EVENT_SYSTEM_MINIMIZEEND
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 8 },
6760 static const struct message WmWinEventCaretSeq
[] = {
6761 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 1 */
6762 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 1 */
6763 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 2 */
6764 { EVENT_OBJECT_NAMECHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 1 */
6767 static const struct message WmWinEventCaretSeq_2
[] = {
6768 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 1/2 */
6769 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 1/2 */
6770 { EVENT_OBJECT_NAMECHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 1/2 */
6773 static const struct message WmWinEventAlertSeq
[] = {
6774 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_ALERT
, 0 },
6777 static const struct message WmWinEventAlertSeq_2
[] = {
6778 /* create window in the thread proc */
6779 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_WINDOW
, 2 },
6780 /* our test event */
6781 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_ALERT
, 2 },
6784 static const struct message WmGlobalHookSeq_1
[] = {
6785 /* create window in the thread proc */
6786 { HCBT_CREATEWND
, hook
|lparam
, 0, 2 },
6787 /* our test events */
6788 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_PREVWINDOW
, 2 },
6789 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_NEXTWINDOW
, 2 },
6792 static const struct message WmGlobalHookSeq_2
[] = {
6793 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_NEXTWINDOW
, 0 }, /* old local hook */
6794 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_NEXTWINDOW
, 2 }, /* new global hook */
6795 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_PREVWINDOW
, 0 }, /* old local hook */
6796 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_PREVWINDOW
, 2 }, /* new global hook */
6800 static const struct message WmMouseLLHookSeq
[] = {
6801 { WM_MOUSEMOVE
, hook
},
6802 { WM_LBUTTONUP
, hook
},
6803 { WM_MOUSEMOVE
, hook
},
6807 static void CALLBACK
win_event_global_hook_proc(HWINEVENTHOOK hevent
,
6817 trace("WEH_2:%p,event %08x,hwnd %p,obj %08x,id %08x,thread %08x,time %08x\n",
6818 hevent
, event
, hwnd
, object_id
, child_id
, thread_id
, event_time
);
6820 if (GetClassNameA(hwnd
, buf
, sizeof(buf
)))
6822 if (!lstrcmpiA(buf
, "TestWindowClass") ||
6823 !lstrcmpiA(buf
, "static"))
6827 msg
.message
= event
;
6828 msg
.flags
= winevent_hook
|wparam
|lparam
;
6829 msg
.wParam
= object_id
;
6830 msg
.lParam
= (thread_id
== GetCurrentThreadId()) ? child_id
: (child_id
+ 2);
6836 static HHOOK hCBT_global_hook
;
6837 static DWORD cbt_global_hook_thread_id
;
6839 static LRESULT CALLBACK
cbt_global_hook_proc(int nCode
, WPARAM wParam
, LPARAM lParam
)
6844 trace("CBT_2: %d, %08lx, %08lx\n", nCode
, wParam
, lParam
);
6846 if (nCode
== HCBT_SYSCOMMAND
)
6850 msg
.message
= nCode
;
6851 msg
.flags
= hook
|wparam
|lparam
;
6852 msg
.wParam
= wParam
;
6853 msg
.lParam
= (cbt_global_hook_thread_id
== GetCurrentThreadId()) ? 1 : 2;
6856 return CallNextHookEx(hCBT_global_hook
, nCode
, wParam
, lParam
);
6858 /* WH_MOUSE_LL hook */
6859 if (nCode
== HC_ACTION
)
6862 MSLLHOOKSTRUCT
*mhll
= (MSLLHOOKSTRUCT
*)lParam
;
6864 /* we can't test for real mouse events */
6865 if (mhll
->flags
& LLMHF_INJECTED
)
6867 msg
.message
= wParam
;
6871 return CallNextHookEx(hCBT_global_hook
, nCode
, wParam
, lParam
);
6874 /* Log also SetFocus(0) calls */
6875 hwnd
= wParam
? (HWND
)wParam
: (HWND
)lParam
;
6877 if (GetClassNameA(hwnd
, buf
, sizeof(buf
)))
6879 if (!lstrcmpiA(buf
, "TestWindowClass") ||
6880 !lstrcmpiA(buf
, "static"))
6884 msg
.message
= nCode
;
6885 msg
.flags
= hook
|wparam
|lparam
;
6886 msg
.wParam
= wParam
;
6887 msg
.lParam
= (cbt_global_hook_thread_id
== GetCurrentThreadId()) ? 1 : 2;
6891 return CallNextHookEx(hCBT_global_hook
, nCode
, wParam
, lParam
);
6894 static DWORD WINAPI
win_event_global_thread_proc(void *param
)
6898 HANDLE hevent
= *(HANDLE
*)param
;
6899 HMODULE user32
= GetModuleHandleA("user32.dll");
6900 FARPROC pNotifyWinEvent
= GetProcAddress(user32
, "NotifyWinEvent");
6902 assert(pNotifyWinEvent
);
6904 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
, 0,0,0,0,0,0,0, NULL
);
6906 trace("created thread window %p\n", hwnd
);
6908 *(HWND
*)param
= hwnd
;
6911 /* this event should be received only by our new hook proc,
6912 * an old one does not expect an event from another thread.
6914 pNotifyWinEvent(EVENT_OBJECT_LOCATIONCHANGE
, hwnd
, OBJID_ALERT
, 0);
6917 while (GetMessage(&msg
, 0, 0, 0))
6919 TranslateMessage(&msg
);
6920 DispatchMessage(&msg
);
6925 static DWORD WINAPI
cbt_global_hook_thread_proc(void *param
)
6929 HANDLE hevent
= *(HANDLE
*)param
;
6932 /* these events should be received only by our new hook proc,
6933 * an old one does not expect an event from another thread.
6936 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
, 0,0,0,0,0,0,0, NULL
);
6938 trace("created thread window %p\n", hwnd
);
6940 *(HWND
*)param
= hwnd
;
6942 /* Windows doesn't like when a thread plays games with the focus,
6943 that leads to all kinds of misbehaviours and failures to activate
6944 a window. So, better keep next lines commented out.
6948 DefWindowProcA(hwnd
, WM_SYSCOMMAND
, SC_PREVWINDOW
, 0);
6949 DefWindowProcA(hwnd
, WM_SYSCOMMAND
, SC_NEXTWINDOW
, 0);
6953 while (GetMessage(&msg
, 0, 0, 0))
6955 TranslateMessage(&msg
);
6956 DispatchMessage(&msg
);
6961 static DWORD WINAPI
mouse_ll_global_thread_proc(void *param
)
6965 HANDLE hevent
= *(HANDLE
*)param
;
6967 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
, 0,0,0,0,0,0,0, NULL
);
6969 trace("created thread window %p\n", hwnd
);
6971 *(HWND
*)param
= hwnd
;
6975 /* Windows doesn't like when a thread plays games with the focus,
6976 * that leads to all kinds of misbehaviours and failures to activate
6977 * a window. So, better don't generate a mouse click message below.
6979 mouse_event(MOUSEEVENTF_MOVE
, -1, 0, 0, 0);
6980 mouse_event(MOUSEEVENTF_LEFTUP
, 0, 0, 0, 0);
6981 mouse_event(MOUSEEVENTF_MOVE
, 1, 0, 0, 0);
6984 while (GetMessage(&msg
, 0, 0, 0))
6986 TranslateMessage(&msg
);
6987 DispatchMessage(&msg
);
6992 static void test_winevents(void)
6998 HANDLE hthread
, hevent
;
7000 HWINEVENTHOOK hhook
;
7001 const struct message
*events
= WmWinEventsSeq
;
7002 HMODULE user32
= GetModuleHandleA("user32.dll");
7003 FARPROC pSetWinEventHook
= GetProcAddress(user32
, "SetWinEventHook");
7004 FARPROC pUnhookWinEvent
= GetProcAddress(user32
, "UnhookWinEvent");
7005 FARPROC pNotifyWinEvent
= GetProcAddress(user32
, "NotifyWinEvent");
7007 hwnd
= CreateWindowExA(0, "TestWindowClass", NULL
,
7008 WS_OVERLAPPEDWINDOW
,
7009 CW_USEDEFAULT
, CW_USEDEFAULT
, 300, 300, 0,
7013 /****** start of global hook test *************/
7014 hCBT_global_hook
= SetWindowsHookExA(WH_CBT
, cbt_global_hook_proc
, GetModuleHandleA(0), 0);
7015 assert(hCBT_global_hook
);
7017 hevent
= CreateEventA(NULL
, 0, 0, NULL
);
7019 hwnd2
= (HWND
)hevent
;
7021 hthread
= CreateThread(NULL
, 0, cbt_global_hook_thread_proc
, &hwnd2
, 0, &tid
);
7022 ok(hthread
!= NULL
, "CreateThread failed, error %d\n", GetLastError());
7024 ok(WaitForSingleObject(hevent
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
7026 ok_sequence(WmGlobalHookSeq_1
, "global hook 1", FALSE
);
7029 /* this one should be received only by old hook proc */
7030 DefWindowProcA(hwnd
, WM_SYSCOMMAND
, SC_NEXTWINDOW
, 0);
7031 /* this one should be received only by old hook proc */
7032 DefWindowProcA(hwnd
, WM_SYSCOMMAND
, SC_PREVWINDOW
, 0);
7034 ok_sequence(WmGlobalHookSeq_2
, "global hook 2", FALSE
);
7036 ret
= UnhookWindowsHookEx(hCBT_global_hook
);
7037 ok( ret
, "UnhookWindowsHookEx error %d\n", GetLastError());
7039 PostThreadMessageA(tid
, WM_QUIT
, 0, 0);
7040 ok(WaitForSingleObject(hthread
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
7041 CloseHandle(hthread
);
7042 CloseHandle(hevent
);
7043 ok(!IsWindow(hwnd2
), "window should be destroyed on thread exit\n");
7044 /****** end of global hook test *************/
7046 if (!pSetWinEventHook
|| !pNotifyWinEvent
|| !pUnhookWinEvent
)
7048 ok(DestroyWindow(hwnd
), "failed to destroy window\n");
7056 /* this test doesn't pass under Win9x */
7057 /* win2k ignores events with hwnd == 0 */
7058 SetLastError(0xdeadbeef);
7059 pNotifyWinEvent(events
[0].message
, 0, events
[0].wParam
, events
[0].lParam
);
7060 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
|| /* Win2k */
7061 GetLastError() == 0xdeadbeef, /* Win9x */
7062 "unexpected error %d\n", GetLastError());
7063 ok_sequence(WmEmptySeq
, "empty notify winevents", FALSE
);
7066 for (i
= 0; i
< sizeof(WmWinEventsSeq
)/sizeof(WmWinEventsSeq
[0]); i
++)
7067 pNotifyWinEvent(events
[i
].message
, hwnd
, events
[i
].wParam
, events
[i
].lParam
);
7069 ok_sequence(WmWinEventsSeq
, "notify winevents", FALSE
);
7071 /****** start of event filtering test *************/
7072 hhook
= (HWINEVENTHOOK
)pSetWinEventHook(
7073 EVENT_OBJECT_SHOW
, /* 0x8002 */
7074 EVENT_OBJECT_LOCATIONCHANGE
, /* 0x800B */
7075 GetModuleHandleA(0), win_event_global_hook_proc
,
7076 GetCurrentProcessId(), 0,
7077 WINEVENT_INCONTEXT
);
7078 ok(hhook
!= 0, "SetWinEventHook error %d\n", GetLastError());
7080 hevent
= CreateEventA(NULL
, 0, 0, NULL
);
7082 hwnd2
= (HWND
)hevent
;
7084 hthread
= CreateThread(NULL
, 0, win_event_global_thread_proc
, &hwnd2
, 0, &tid
);
7085 ok(hthread
!= NULL
, "CreateThread failed, error %d\n", GetLastError());
7087 ok(WaitForSingleObject(hevent
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
7089 ok_sequence(WmWinEventAlertSeq
, "alert winevent", FALSE
);
7092 /* this one should be received only by old hook proc */
7093 pNotifyWinEvent(EVENT_OBJECT_CREATE
, hwnd
, OBJID_CARET
, 0); /* 0x8000 */
7094 pNotifyWinEvent(EVENT_OBJECT_SHOW
, hwnd
, OBJID_CARET
, 0); /* 0x8002 */
7095 /* this one should be received only by old hook proc */
7096 pNotifyWinEvent(EVENT_OBJECT_NAMECHANGE
, hwnd
, OBJID_CARET
, 0); /* 0x800C */
7098 ok_sequence(WmWinEventCaretSeq
, "caret winevent", FALSE
);
7100 ret
= pUnhookWinEvent(hhook
);
7101 ok( ret
, "UnhookWinEvent error %d\n", GetLastError());
7103 PostThreadMessageA(tid
, WM_QUIT
, 0, 0);
7104 ok(WaitForSingleObject(hthread
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
7105 CloseHandle(hthread
);
7106 CloseHandle(hevent
);
7107 ok(!IsWindow(hwnd2
), "window should be destroyed on thread exit\n");
7108 /****** end of event filtering test *************/
7110 /****** start of out of context event test *************/
7111 hhook
= (HWINEVENTHOOK
)pSetWinEventHook(
7112 EVENT_MIN
, EVENT_MAX
,
7113 0, win_event_global_hook_proc
,
7114 GetCurrentProcessId(), 0,
7115 WINEVENT_OUTOFCONTEXT
);
7116 ok(hhook
!= 0, "SetWinEventHook error %d\n", GetLastError());
7118 hevent
= CreateEventA(NULL
, 0, 0, NULL
);
7120 hwnd2
= (HWND
)hevent
;
7124 hthread
= CreateThread(NULL
, 0, win_event_global_thread_proc
, &hwnd2
, 0, &tid
);
7125 ok(hthread
!= NULL
, "CreateThread failed, error %d\n", GetLastError());
7127 ok(WaitForSingleObject(hevent
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
7129 ok_sequence(WmEmptySeq
, "empty notify winevents", FALSE
);
7130 /* process pending winevent messages */
7131 ok(!PeekMessageA(&msg
, 0, 0, 0, PM_NOREMOVE
), "msg queue should be empty\n");
7132 ok_sequence(WmWinEventAlertSeq_2
, "alert winevent for out of context proc", FALSE
);
7135 /* this one should be received only by old hook proc */
7136 pNotifyWinEvent(EVENT_OBJECT_CREATE
, hwnd
, OBJID_CARET
, 0); /* 0x8000 */
7137 pNotifyWinEvent(EVENT_OBJECT_SHOW
, hwnd
, OBJID_CARET
, 0); /* 0x8002 */
7138 /* this one should be received only by old hook proc */
7139 pNotifyWinEvent(EVENT_OBJECT_NAMECHANGE
, hwnd
, OBJID_CARET
, 0); /* 0x800C */
7141 ok_sequence(WmWinEventCaretSeq_2
, "caret winevent for incontext proc", FALSE
);
7142 /* process pending winevent messages */
7143 ok(!PeekMessageA(&msg
, 0, 0, 0, PM_NOREMOVE
), "msg queue should be empty\n");
7144 ok_sequence(WmWinEventCaretSeq_2
, "caret winevent for out of context proc", FALSE
);
7146 ret
= pUnhookWinEvent(hhook
);
7147 ok( ret
, "UnhookWinEvent error %d\n", GetLastError());
7149 PostThreadMessageA(tid
, WM_QUIT
, 0, 0);
7150 ok(WaitForSingleObject(hthread
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
7151 CloseHandle(hthread
);
7152 CloseHandle(hevent
);
7153 ok(!IsWindow(hwnd2
), "window should be destroyed on thread exit\n");
7154 /****** end of out of context event test *************/
7156 /****** start of MOUSE_LL hook test *************/
7157 hCBT_global_hook
= SetWindowsHookExA(WH_MOUSE_LL
, cbt_global_hook_proc
, GetModuleHandleA(0), 0);
7158 /* WH_MOUSE_LL is not supported on Win9x platforms */
7159 if (!hCBT_global_hook
)
7161 trace("Skipping WH_MOUSE_LL test on this platform\n");
7162 goto skip_mouse_ll_hook_test
;
7165 hevent
= CreateEventA(NULL
, 0, 0, NULL
);
7167 hwnd2
= (HWND
)hevent
;
7169 hthread
= CreateThread(NULL
, 0, mouse_ll_global_thread_proc
, &hwnd2
, 0, &tid
);
7170 ok(hthread
!= NULL
, "CreateThread failed, error %d\n", GetLastError());
7172 while (WaitForSingleObject(hevent
, 100) == WAIT_TIMEOUT
)
7173 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
7175 ok_sequence(WmMouseLLHookSeq
, "MOUSE_LL hook other thread", FALSE
);
7178 mouse_event(MOUSEEVENTF_MOVE
, -1, 0, 0, 0);
7179 mouse_event(MOUSEEVENTF_LEFTUP
, 0, 0, 0, 0);
7180 mouse_event(MOUSEEVENTF_MOVE
, 1, 0, 0, 0);
7182 ok_sequence(WmMouseLLHookSeq
, "MOUSE_LL hook same thread", FALSE
);
7184 ret
= UnhookWindowsHookEx(hCBT_global_hook
);
7185 ok( ret
, "UnhookWindowsHookEx error %d\n", GetLastError());
7187 PostThreadMessageA(tid
, WM_QUIT
, 0, 0);
7188 ok(WaitForSingleObject(hthread
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
7189 CloseHandle(hthread
);
7190 CloseHandle(hevent
);
7191 ok(!IsWindow(hwnd2
), "window should be destroyed on thread exit\n");
7192 /****** end of MOUSE_LL hook test *************/
7193 skip_mouse_ll_hook_test
:
7195 ok(DestroyWindow(hwnd
), "failed to destroy window\n");
7198 static void test_set_hook(void)
7202 HWINEVENTHOOK hwinevent_hook
;
7203 HMODULE user32
= GetModuleHandleA("user32.dll");
7204 FARPROC pSetWinEventHook
= GetProcAddress(user32
, "SetWinEventHook");
7205 FARPROC pUnhookWinEvent
= GetProcAddress(user32
, "UnhookWinEvent");
7207 hhook
= SetWindowsHookExA(WH_CBT
, cbt_hook_proc
, GetModuleHandleA(0), GetCurrentThreadId());
7208 ok(hhook
!= 0, "local hook does not require hModule set to 0\n");
7209 UnhookWindowsHookEx(hhook
);
7213 /* this test doesn't pass under Win9x: BUG! */
7214 SetLastError(0xdeadbeef);
7215 hhook
= SetWindowsHookExA(WH_CBT
, cbt_hook_proc
, 0, 0);
7216 ok(!hhook
, "global hook requires hModule != 0\n");
7217 ok(GetLastError() == ERROR_HOOK_NEEDS_HMOD
, "unexpected error %d\n", GetLastError());
7220 SetLastError(0xdeadbeef);
7221 hhook
= SetWindowsHookExA(WH_CBT
, 0, GetModuleHandleA(0), GetCurrentThreadId());
7222 ok(!hhook
, "SetWinEventHook with invalid proc should fail\n");
7223 ok(GetLastError() == ERROR_INVALID_FILTER_PROC
|| /* Win2k */
7224 GetLastError() == 0xdeadbeef, /* Win9x */
7225 "unexpected error %d\n", GetLastError());
7227 SetLastError(0xdeadbeef);
7228 ok(!UnhookWindowsHookEx((HHOOK
)0xdeadbeef), "UnhookWindowsHookEx succeeded\n");
7229 ok(GetLastError() == ERROR_INVALID_HOOK_HANDLE
|| /* Win2k */
7230 GetLastError() == 0xdeadbeef, /* Win9x */
7231 "unexpected error %d\n", GetLastError());
7233 if (!pSetWinEventHook
|| !pUnhookWinEvent
) return;
7235 /* even process local incontext hooks require hmodule */
7236 SetLastError(0xdeadbeef);
7237 hwinevent_hook
= (HWINEVENTHOOK
)pSetWinEventHook(EVENT_MIN
, EVENT_MAX
,
7238 0, win_event_proc
, GetCurrentProcessId(), 0, WINEVENT_INCONTEXT
);
7239 ok(!hwinevent_hook
, "WINEVENT_INCONTEXT requires hModule != 0\n");
7240 ok(GetLastError() == ERROR_HOOK_NEEDS_HMOD
|| /* Win2k */
7241 GetLastError() == 0xdeadbeef, /* Win9x */
7242 "unexpected error %d\n", GetLastError());
7244 /* even thread local incontext hooks require hmodule */
7245 SetLastError(0xdeadbeef);
7246 hwinevent_hook
= (HWINEVENTHOOK
)pSetWinEventHook(EVENT_MIN
, EVENT_MAX
,
7247 0, win_event_proc
, GetCurrentProcessId(), GetCurrentThreadId(), WINEVENT_INCONTEXT
);
7248 ok(!hwinevent_hook
, "WINEVENT_INCONTEXT requires hModule != 0\n");
7249 ok(GetLastError() == ERROR_HOOK_NEEDS_HMOD
|| /* Win2k */
7250 GetLastError() == 0xdeadbeef, /* Win9x */
7251 "unexpected error %d\n", GetLastError());
7255 /* these 3 tests don't pass under Win9x */
7256 SetLastError(0xdeadbeef);
7257 hwinevent_hook
= (HWINEVENTHOOK
)pSetWinEventHook(1, 0,
7258 0, win_event_proc
, GetCurrentProcessId(), 0, WINEVENT_OUTOFCONTEXT
);
7259 ok(!hwinevent_hook
, "SetWinEventHook with invalid event range should fail\n");
7260 ok(GetLastError() == ERROR_INVALID_HOOK_FILTER
, "unexpected error %d\n", GetLastError());
7262 SetLastError(0xdeadbeef);
7263 hwinevent_hook
= (HWINEVENTHOOK
)pSetWinEventHook(-1, 1,
7264 0, win_event_proc
, GetCurrentProcessId(), 0, WINEVENT_OUTOFCONTEXT
);
7265 ok(!hwinevent_hook
, "SetWinEventHook with invalid event range should fail\n");
7266 ok(GetLastError() == ERROR_INVALID_HOOK_FILTER
, "unexpected error %d\n", GetLastError());
7268 SetLastError(0xdeadbeef);
7269 hwinevent_hook
= (HWINEVENTHOOK
)pSetWinEventHook(EVENT_MIN
, EVENT_MAX
,
7270 0, win_event_proc
, 0, 0xdeadbeef, WINEVENT_OUTOFCONTEXT
);
7271 ok(!hwinevent_hook
, "SetWinEventHook with invalid tid should fail\n");
7272 ok(GetLastError() == ERROR_INVALID_THREAD_ID
, "unexpected error %d\n", GetLastError());
7275 SetLastError(0xdeadbeef);
7276 hwinevent_hook
= (HWINEVENTHOOK
)pSetWinEventHook(0, 0,
7277 0, win_event_proc
, GetCurrentProcessId(), 0, WINEVENT_OUTOFCONTEXT
);
7278 ok(hwinevent_hook
!= 0, "SetWinEventHook error %d\n", GetLastError());
7279 ok(GetLastError() == 0xdeadbeef, "unexpected error %d\n", GetLastError());
7280 ret
= pUnhookWinEvent(hwinevent_hook
);
7281 ok( ret
, "UnhookWinEvent error %d\n", GetLastError());
7284 /* This call succeeds under win2k SP4, but fails under Wine.
7285 Does win2k test/use passed process id? */
7286 SetLastError(0xdeadbeef);
7287 hwinevent_hook
= (HWINEVENTHOOK
)pSetWinEventHook(EVENT_MIN
, EVENT_MAX
,
7288 0, win_event_proc
, 0xdeadbeef, 0, WINEVENT_OUTOFCONTEXT
);
7289 ok(hwinevent_hook
!= 0, "SetWinEventHook error %d\n", GetLastError());
7290 ok(GetLastError() == 0xdeadbeef, "unexpected error %d\n", GetLastError());
7291 ret
= pUnhookWinEvent(hwinevent_hook
);
7292 ok( ret
, "UnhookWinEvent error %d\n", GetLastError());
7295 SetLastError(0xdeadbeef);
7296 ok(!pUnhookWinEvent((HWINEVENTHOOK
)0xdeadbeef), "UnhookWinEvent succeeded\n");
7297 ok(GetLastError() == ERROR_INVALID_HANDLE
|| /* Win2k */
7298 GetLastError() == 0xdeadbeef, /* Win9x */
7299 "unexpected error %d\n", GetLastError());
7302 static const struct message ScrollWindowPaint1
[] = {
7304 { WM_ERASEBKGND
, sent
|beginpaint
},
7308 static const struct message ScrollWindowPaint2
[] = {
7313 static void test_scrollwindowex(void)
7316 RECT rect
={0,0,130,130};
7319 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test Scroll",
7320 WS_VISIBLE
|WS_OVERLAPPEDWINDOW
,
7321 100, 100, 200, 200, 0, 0, 0, NULL
);
7322 ok (hwnd
!= 0, "Failed to create overlapped window\n");
7323 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child",
7324 WS_VISIBLE
|WS_CAPTION
|WS_CHILD
,
7325 10, 10, 150, 150, hwnd
, 0, 0, NULL
);
7326 ok (hchild
!= 0, "Failed to create child\n");
7331 /* scroll without the child window */
7332 trace("start scroll\n");
7333 ScrollWindowEx( hwnd
, 10, 10, &rect
, NULL
, NULL
, NULL
,
7334 SW_ERASE
|SW_INVALIDATE
);
7335 ok_sequence(WmEmptySeq
, "ScrollWindowEx", 0);
7336 trace("end scroll\n");
7338 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
7339 ok_sequence(ScrollWindowPaint1
, "ScrollWindowEx", 0);
7343 /* Now without the SW_ERASE flag */
7344 trace("start scroll\n");
7345 ScrollWindowEx( hwnd
, 10, 10, &rect
, NULL
, NULL
, NULL
, SW_INVALIDATE
);
7346 ok_sequence(WmEmptySeq
, "ScrollWindowEx", 0);
7347 trace("end scroll\n");
7349 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
7350 ok_sequence(ScrollWindowPaint2
, "ScrollWindowEx", 0);
7354 /* now scroll the child window as well */
7355 trace("start scroll\n");
7356 ScrollWindowEx( hwnd
, 10, 10, &rect
, NULL
, NULL
, NULL
,
7357 SW_SCROLLCHILDREN
|SW_ERASE
|SW_INVALIDATE
);
7358 todo_wine
{ /* wine sends WM_POSCHANGING, WM_POSCHANGED messages */
7359 /* windows sometimes a WM_MOVE */
7360 ok_sequence(WmEmptySeq
, "ScrollWindowEx", 0);
7362 trace("end scroll\n");
7364 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
7365 ok_sequence(ScrollWindowPaint1
, "ScrollWindowEx", 0);
7369 /* now scroll with ScrollWindow() */
7370 trace("start scroll with ScrollWindow\n");
7371 ScrollWindow( hwnd
, 5, 5, NULL
, NULL
);
7372 trace("end scroll\n");
7374 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
7375 ok_sequence(ScrollWindowPaint1
, "ScrollWindow", 0);
7377 ok(DestroyWindow(hchild
), "failed to destroy window\n");
7378 ok(DestroyWindow(hwnd
), "failed to destroy window\n");
7382 static const struct message destroy_window_with_children
[] = {
7383 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* popup */
7384 { HCBT_DESTROYWND
, hook
|lparam
, 0, WND_PARENT_ID
}, /* parent */
7385 { HCBT_DESTROYWND
, hook
|lparam
, 0, WND_POPUP_ID
}, /* popup */
7386 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* popup */
7387 { WM_DESTROY
, sent
|wparam
|lparam
, 0, WND_POPUP_ID
}, /* popup */
7388 { WM_CAPTURECHANGED
, sent
|wparam
|lparam
, 0, WND_POPUP_ID
}, /* popup */
7389 { WM_NCDESTROY
, sent
|wparam
|lparam
, 0, WND_POPUP_ID
}, /* popup */
7390 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* parent */
7391 { WM_DESTROY
, sent
|wparam
|lparam
, 0, WND_PARENT_ID
}, /* parent */
7392 { WM_DESTROY
, sent
|wparam
|lparam
, 0, WND_CHILD_ID
+ 2 }, /* child2 */
7393 { WM_DESTROY
, sent
|wparam
|lparam
, 0, WND_CHILD_ID
+ 1 }, /* child1 */
7394 { WM_DESTROY
, sent
|wparam
|lparam
, 0, WND_CHILD_ID
+ 3 }, /* child3 */
7395 { WM_NCDESTROY
, sent
|wparam
|lparam
, 0, WND_CHILD_ID
+ 2 }, /* child2 */
7396 { WM_NCDESTROY
, sent
|wparam
|lparam
, 0, WND_CHILD_ID
+ 3 }, /* child3 */
7397 { WM_NCDESTROY
, sent
|wparam
|lparam
, 0, WND_CHILD_ID
+ 1 }, /* child1 */
7398 { WM_NCDESTROY
, sent
|wparam
|lparam
, 0, WND_PARENT_ID
}, /* parent */
7402 static void test_DestroyWindow(void)
7405 HWND parent
, child1
, child2
, child3
, child4
, test
;
7406 UINT child_id
= WND_CHILD_ID
+ 1;
7408 parent
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
7409 100, 100, 200, 200, 0, 0, 0, NULL
);
7410 assert(parent
!= 0);
7411 child1
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_CHILD
,
7412 0, 0, 50, 50, parent
, (HMENU
)child_id
++, 0, NULL
);
7413 assert(child1
!= 0);
7414 child2
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_CHILD
,
7415 0, 0, 50, 50, GetDesktopWindow(), (HMENU
)child_id
++, 0, NULL
);
7416 assert(child2
!= 0);
7417 child3
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_CHILD
,
7418 0, 0, 50, 50, child1
, (HMENU
)child_id
++, 0, NULL
);
7419 assert(child3
!= 0);
7420 child4
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_POPUP
,
7421 0, 0, 50, 50, parent
, 0, 0, NULL
);
7422 assert(child4
!= 0);
7424 /* test owner/parent of child2 */
7425 test
= GetParent(child2
);
7426 ok(test
== GetDesktopWindow(), "wrong parent %p\n", test
);
7427 ok(!IsChild(parent
, child2
), "wrong parent/child %p/%p\n", parent
, child2
);
7429 test
= pGetAncestor(child2
, GA_PARENT
);
7430 ok(test
== GetDesktopWindow(), "wrong parent %p\n", test
);
7432 test
= GetWindow(child2
, GW_OWNER
);
7433 ok(!test
, "wrong owner %p\n", test
);
7435 test
= SetParent(child2
, parent
);
7436 ok(test
== GetDesktopWindow(), "wrong old parent %p\n", test
);
7438 /* test owner/parent of the parent */
7439 test
= GetParent(parent
);
7440 ok(!test
, "wrong parent %p\n", test
);
7442 ok(!IsChild(GetDesktopWindow(), parent
), "wrong parent/child %p/%p\n", GetDesktopWindow(), parent
);
7445 test
= pGetAncestor(parent
, GA_PARENT
);
7446 ok(test
== GetDesktopWindow(), "wrong parent %p\n", test
);
7448 test
= GetWindow(parent
, GW_OWNER
);
7449 ok(!test
, "wrong owner %p\n", test
);
7451 /* test owner/parent of child1 */
7452 test
= GetParent(child1
);
7453 ok(test
== parent
, "wrong parent %p\n", test
);
7454 ok(IsChild(parent
, child1
), "wrong parent/child %p/%p\n", parent
, child1
);
7456 test
= pGetAncestor(child1
, GA_PARENT
);
7457 ok(test
== parent
, "wrong parent %p\n", test
);
7459 test
= GetWindow(child1
, GW_OWNER
);
7460 ok(!test
, "wrong owner %p\n", test
);
7462 /* test owner/parent of child2 */
7463 test
= GetParent(child2
);
7464 ok(test
== parent
, "wrong parent %p\n", test
);
7465 ok(IsChild(parent
, child2
), "wrong parent/child %p/%p\n", parent
, child2
);
7467 test
= pGetAncestor(child2
, GA_PARENT
);
7468 ok(test
== parent
, "wrong parent %p\n", test
);
7470 test
= GetWindow(child2
, GW_OWNER
);
7471 ok(!test
, "wrong owner %p\n", test
);
7473 /* test owner/parent of child3 */
7474 test
= GetParent(child3
);
7475 ok(test
== child1
, "wrong parent %p\n", test
);
7476 ok(IsChild(parent
, child3
), "wrong parent/child %p/%p\n", parent
, child3
);
7478 test
= pGetAncestor(child3
, GA_PARENT
);
7479 ok(test
== child1
, "wrong parent %p\n", test
);
7481 test
= GetWindow(child3
, GW_OWNER
);
7482 ok(!test
, "wrong owner %p\n", test
);
7484 /* test owner/parent of child4 */
7485 test
= GetParent(child4
);
7486 ok(test
== parent
, "wrong parent %p\n", test
);
7487 ok(!IsChild(parent
, child4
), "wrong parent/child %p/%p\n", parent
, child4
);
7489 test
= pGetAncestor(child4
, GA_PARENT
);
7490 ok(test
== GetDesktopWindow(), "wrong parent %p\n", test
);
7492 test
= GetWindow(child4
, GW_OWNER
);
7493 ok(test
== parent
, "wrong owner %p\n", test
);
7497 trace("parent %p, child1 %p, child2 %p, child3 %p, child4 %p\n",
7498 parent
, child1
, child2
, child3
, child4
);
7501 test
= GetCapture();
7502 ok(test
== child4
, "wrong capture window %p\n", test
);
7504 test_DestroyWindow_flag
= TRUE
;
7505 ret
= DestroyWindow(parent
);
7506 ok( ret
, "DestroyWindow() error %d\n", GetLastError());
7507 test_DestroyWindow_flag
= FALSE
;
7508 ok_sequence(destroy_window_with_children
, "destroy window with children", 0);
7510 ok(!IsWindow(parent
), "parent still exists\n");
7511 ok(!IsWindow(child1
), "child1 still exists\n");
7512 ok(!IsWindow(child2
), "child2 still exists\n");
7513 ok(!IsWindow(child3
), "child3 still exists\n");
7514 ok(!IsWindow(child4
), "child4 still exists\n");
7516 test
= GetCapture();
7517 ok(!test
, "wrong capture window %p\n", test
);
7521 static const struct message WmDispatchPaint
[] = {
7522 { WM_NCPAINT
, sent
},
7523 { WM_GETTEXT
, sent
|defwinproc
|optional
},
7524 { WM_GETTEXT
, sent
|defwinproc
|optional
},
7525 { WM_ERASEBKGND
, sent
},
7529 static LRESULT WINAPI
DispatchMessageCheckProc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
7531 if (message
== WM_PAINT
) return 0;
7532 return MsgCheckProcA( hwnd
, message
, wParam
, lParam
);
7535 static void test_DispatchMessage(void)
7540 HWND hwnd
= CreateWindowA( "TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
7541 100, 100, 200, 200, 0, 0, 0, NULL
);
7542 ShowWindow( hwnd
, SW_SHOW
);
7543 UpdateWindow( hwnd
);
7544 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
7546 SetWindowLongPtrA( hwnd
, GWLP_WNDPROC
, (LONG_PTR
)DispatchMessageCheckProc
);
7548 SetRect( &rect
, -5, -5, 5, 5 );
7549 RedrawWindow( hwnd
, &rect
, 0, RDW_INVALIDATE
|RDW_ERASE
|RDW_FRAME
);
7551 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
))
7553 if (msg
.message
!= WM_PAINT
) DispatchMessage( &msg
);
7557 DispatchMessage( &msg
);
7558 /* DispatchMessage will send WM_NCPAINT if non client area is still invalid after WM_PAINT */
7559 if (!count
) ok_sequence( WmDispatchPaint
, "WmDispatchPaint", FALSE
);
7560 else ok_sequence( WmEmptySeq
, "WmEmpty", FALSE
);
7561 if (++count
> 10) break;
7564 ok( msg
.message
== WM_PAINT
&& count
> 10, "WM_PAINT messages stopped\n" );
7566 trace("now without DispatchMessage\n");
7568 RedrawWindow( hwnd
, &rect
, 0, RDW_INVALIDATE
|RDW_ERASE
|RDW_FRAME
);
7570 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
))
7572 if (msg
.message
!= WM_PAINT
) DispatchMessage( &msg
);
7575 HRGN hrgn
= CreateRectRgn( 0, 0, 0, 0 );
7577 /* this will send WM_NCCPAINT just like DispatchMessage does */
7578 GetUpdateRgn( hwnd
, hrgn
, TRUE
);
7579 ok_sequence( WmDispatchPaint
, "WmDispatchPaint", FALSE
);
7580 DeleteObject( hrgn
);
7581 GetClientRect( hwnd
, &rect
);
7582 ValidateRect( hwnd
, &rect
); /* this will stop WM_PAINTs */
7583 ok( !count
, "Got multiple WM_PAINTs\n" );
7584 if (++count
> 10) break;
7587 DestroyWindow(hwnd
);
7591 static const struct message WmUser
[] = {
7603 static DWORD CALLBACK
send_msg_thread( LPVOID arg
)
7605 struct sendmsg_info
*info
= arg
;
7606 info
->ret
= SendMessageTimeoutA( info
->hwnd
, WM_USER
, 0, 0, 0, info
->timeout
, NULL
);
7607 if (!info
->ret
) ok( GetLastError() == ERROR_TIMEOUT
, "unexpected error %d\n", GetLastError());
7611 static void wait_for_thread( HANDLE thread
)
7613 while (MsgWaitForMultipleObjects(1, &thread
, FALSE
, INFINITE
, QS_SENDMESSAGE
) != WAIT_OBJECT_0
)
7616 while (PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage(&msg
);
7620 static LRESULT WINAPI
send_msg_delay_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
7622 if (message
== WM_USER
) Sleep(200);
7623 return MsgCheckProcA( hwnd
, message
, wParam
, lParam
);
7626 static void test_SendMessageTimeout(void)
7630 struct sendmsg_info info
;
7633 info
.hwnd
= CreateWindowA( "TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
7634 100, 100, 200, 200, 0, 0, 0, NULL
);
7635 while (PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
7638 info
.timeout
= 1000;
7639 info
.ret
= 0xdeadbeef;
7640 thread
= CreateThread( NULL
, 0, send_msg_thread
, &info
, 0, &tid
);
7641 wait_for_thread( thread
);
7642 CloseHandle( thread
);
7643 ok( info
.ret
== 1, "SendMessageTimeout failed\n" );
7644 ok_sequence( WmUser
, "WmUser", FALSE
);
7647 info
.ret
= 0xdeadbeef;
7648 thread
= CreateThread( NULL
, 0, send_msg_thread
, &info
, 0, &tid
);
7649 Sleep(100); /* SendMessageTimeout should timeout here */
7650 wait_for_thread( thread
);
7651 CloseHandle( thread
);
7652 ok( info
.ret
== 0, "SendMessageTimeout succeeded\n" );
7653 ok_sequence( WmEmptySeq
, "WmEmptySeq", FALSE
);
7655 /* 0 means infinite timeout */
7657 info
.ret
= 0xdeadbeef;
7658 thread
= CreateThread( NULL
, 0, send_msg_thread
, &info
, 0, &tid
);
7660 wait_for_thread( thread
);
7661 CloseHandle( thread
);
7662 ok( info
.ret
== 1, "SendMessageTimeout failed\n" );
7663 ok_sequence( WmUser
, "WmUser", FALSE
);
7665 /* timeout is treated as signed despite the prototype */
7666 info
.timeout
= 0x7fffffff;
7667 info
.ret
= 0xdeadbeef;
7668 thread
= CreateThread( NULL
, 0, send_msg_thread
, &info
, 0, &tid
);
7670 wait_for_thread( thread
);
7671 CloseHandle( thread
);
7672 ok( info
.ret
== 1, "SendMessageTimeout failed\n" );
7673 ok_sequence( WmUser
, "WmUser", FALSE
);
7675 info
.timeout
= 0x80000000;
7676 info
.ret
= 0xdeadbeef;
7677 thread
= CreateThread( NULL
, 0, send_msg_thread
, &info
, 0, &tid
);
7679 wait_for_thread( thread
);
7680 CloseHandle( thread
);
7681 ok( info
.ret
== 0, "SendMessageTimeout succeeded\n" );
7682 ok_sequence( WmEmptySeq
, "WmEmptySeq", FALSE
);
7684 /* now check for timeout during message processing */
7685 SetWindowLongPtrA( info
.hwnd
, GWLP_WNDPROC
, (LONG_PTR
)send_msg_delay_proc
);
7687 info
.ret
= 0xdeadbeef;
7688 thread
= CreateThread( NULL
, 0, send_msg_thread
, &info
, 0, &tid
);
7689 wait_for_thread( thread
);
7690 CloseHandle( thread
);
7691 /* we should timeout but still get the message */
7692 ok( info
.ret
== 0, "SendMessageTimeout failed\n" );
7693 ok_sequence( WmUser
, "WmUser", FALSE
);
7695 DestroyWindow( info
.hwnd
);
7699 /****************** edit message test *************************/
7700 #define ID_EDIT 0x1234
7701 static const struct message sl_edit_setfocus
[] =
7703 { HCBT_SETFOCUS
, hook
},
7704 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
7705 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
7706 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
7707 { WM_SETFOCUS
, sent
|wparam
, 0 },
7708 { WM_CTLCOLOREDIT
, sent
|parent
},
7709 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
7710 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
7711 { WM_COMMAND
, sent
|parent
|wparam
, MAKEWPARAM(ID_EDIT
, EN_SETFOCUS
) },
7714 static const struct message ml_edit_setfocus
[] =
7716 { HCBT_SETFOCUS
, hook
},
7717 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
7718 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
7719 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
7720 { WM_SETFOCUS
, sent
|wparam
, 0 },
7721 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
7722 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
7723 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
7724 { WM_COMMAND
, sent
|parent
|wparam
, MAKEWPARAM(ID_EDIT
, EN_SETFOCUS
) },
7727 static const struct message sl_edit_killfocus
[] =
7729 { HCBT_SETFOCUS
, hook
},
7730 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
7731 { WM_KILLFOCUS
, sent
|wparam
, 0 },
7732 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
7733 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
7734 { WM_COMMAND
, sent
|parent
|wparam
, MAKEWPARAM(ID_EDIT
, EN_KILLFOCUS
) },
7735 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
7736 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 1 },
7739 static const struct message sl_edit_lbutton_dblclk
[] =
7741 { WM_LBUTTONDBLCLK
, sent
},
7742 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
7745 static const struct message sl_edit_lbutton_down
[] =
7747 { WM_LBUTTONDOWN
, sent
|wparam
|lparam
, 0, 0 },
7748 { HCBT_SETFOCUS
, hook
},
7749 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
7750 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
7751 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
7752 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
7753 { WM_CTLCOLOREDIT
, sent
|parent
},
7754 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
7755 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
7756 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
7757 { WM_COMMAND
, sent
|parent
|wparam
, MAKEWPARAM(ID_EDIT
, EN_SETFOCUS
) },
7758 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
7759 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
7760 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
7761 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
7764 static const struct message ml_edit_lbutton_down
[] =
7766 { WM_LBUTTONDOWN
, sent
|wparam
|lparam
, 0, 0 },
7767 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
7768 { HCBT_SETFOCUS
, hook
},
7769 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
7770 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
7771 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
7772 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
7773 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
7774 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
7775 { WM_COMMAND
, sent
|parent
|wparam
, MAKEWPARAM(ID_EDIT
, EN_SETFOCUS
) },
7778 static const struct message sl_edit_lbutton_up
[] =
7780 { WM_LBUTTONUP
, sent
|wparam
|lparam
, 0, 0 },
7781 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
7782 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, 0, 0 },
7783 { WM_CAPTURECHANGED
, sent
|defwinproc
},
7784 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
7787 static const struct message ml_edit_lbutton_up
[] =
7789 { WM_LBUTTONUP
, sent
|wparam
|lparam
, 0, 0 },
7790 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, 0, 0 },
7791 { WM_CAPTURECHANGED
, sent
|defwinproc
},
7795 static WNDPROC old_edit_proc
;
7797 static LRESULT CALLBACK
edit_hook_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
7799 static long defwndproc_counter
= 0;
7803 trace("edit: %p, %04x, %08lx, %08lx\n", hwnd
, message
, wParam
, lParam
);
7805 /* explicitly ignore WM_GETICON message */
7806 if (message
== WM_GETICON
) return 0;
7808 msg
.message
= message
;
7809 msg
.flags
= sent
|wparam
|lparam
;
7810 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
7811 msg
.wParam
= wParam
;
7812 msg
.lParam
= lParam
;
7815 defwndproc_counter
++;
7816 ret
= CallWindowProcA(old_edit_proc
, hwnd
, message
, wParam
, lParam
);
7817 defwndproc_counter
--;
7822 static void subclass_edit(void)
7826 if (!GetClassInfoA(0, "edit", &cls
)) assert(0);
7828 old_edit_proc
= cls
.lpfnWndProc
;
7830 cls
.hInstance
= GetModuleHandle(0);
7831 cls
.lpfnWndProc
= edit_hook_proc
;
7832 cls
.lpszClassName
= "my_edit_class";
7833 UnregisterClass(cls
.lpszClassName
, cls
.hInstance
);
7834 if (!RegisterClassA(&cls
)) assert(0);
7837 static void test_edit_messages(void)
7843 log_all_parent_messages
++;
7845 parent
= CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
7846 100, 100, 200, 200, 0, 0, 0, NULL
);
7847 ok (parent
!= 0, "Failed to create parent window\n");
7849 /* test single line edit */
7850 hwnd
= CreateWindowExA(0, "my_edit_class", "test", WS_CHILD
,
7851 0, 0, 80, 20, parent
, (HMENU
)ID_EDIT
, 0, NULL
);
7852 ok(hwnd
!= 0, "Failed to create edit window\n");
7854 dlg_code
= SendMessageA(hwnd
, WM_GETDLGCODE
, 0, 0);
7855 ok(dlg_code
== (DLGC_WANTCHARS
|DLGC_HASSETSEL
|DLGC_WANTARROWS
), "wrong dlg_code %08x\n", dlg_code
);
7857 ShowWindow(hwnd
, SW_SHOW
);
7863 ok_sequence(sl_edit_setfocus
, "SetFocus(hwnd) on an edit", FALSE
);
7866 ok_sequence(sl_edit_killfocus
, "SetFocus(0) on an edit", FALSE
);
7872 SendMessageA(hwnd
, WM_LBUTTONDBLCLK
, 0, 0);
7873 ok_sequence(sl_edit_lbutton_dblclk
, "WM_LBUTTONDBLCLK on an edit", FALSE
);
7879 SendMessageA(hwnd
, WM_LBUTTONDOWN
, 0, 0);
7880 ok_sequence(sl_edit_lbutton_down
, "WM_LBUTTONDOWN on an edit", FALSE
);
7882 SendMessageA(hwnd
, WM_LBUTTONUP
, 0, 0);
7883 ok_sequence(sl_edit_lbutton_up
, "WM_LBUTTONUP on an edit", FALSE
);
7885 DestroyWindow(hwnd
);
7887 /* test multiline edit */
7888 hwnd
= CreateWindowExA(0, "my_edit_class", "test", WS_CHILD
| ES_MULTILINE
,
7889 0, 0, 80, 20, parent
, (HMENU
)ID_EDIT
, 0, NULL
);
7890 ok(hwnd
!= 0, "Failed to create edit window\n");
7892 dlg_code
= SendMessageA(hwnd
, WM_GETDLGCODE
, 0, 0);
7893 ok(dlg_code
== (DLGC_WANTCHARS
|DLGC_HASSETSEL
|DLGC_WANTARROWS
|DLGC_WANTALLKEYS
),
7894 "wrong dlg_code %08x\n", dlg_code
);
7896 ShowWindow(hwnd
, SW_SHOW
);
7902 ok_sequence(ml_edit_setfocus
, "SetFocus(hwnd) on multiline edit", FALSE
);
7905 ok_sequence(sl_edit_killfocus
, "SetFocus(0) on multiline edit", FALSE
);
7911 SendMessageA(hwnd
, WM_LBUTTONDBLCLK
, 0, 0);
7912 ok_sequence(sl_edit_lbutton_dblclk
, "WM_LBUTTONDBLCLK on multiline edit", FALSE
);
7918 SendMessageA(hwnd
, WM_LBUTTONDOWN
, 0, 0);
7919 ok_sequence(ml_edit_lbutton_down
, "WM_LBUTTONDOWN on multiline edit", FALSE
);
7921 SendMessageA(hwnd
, WM_LBUTTONUP
, 0, 0);
7922 ok_sequence(ml_edit_lbutton_up
, "WM_LBUTTONUP on multiline edit", FALSE
);
7924 DestroyWindow(hwnd
);
7925 DestroyWindow(parent
);
7927 log_all_parent_messages
--;
7930 /**************************** End of Edit test ******************************/
7932 static const struct message WmKeyDownSkippedSeq
[] =
7934 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 1 }, /* XP */
7937 static const struct message WmKeyUpSkippedSeq
[] =
7939 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xc0000001 }, /* XP */
7943 #define EV_START_STOP 0
7944 #define EV_SENDMSG 1
7950 HANDLE hevent
[3]; /* 0 - start/stop, 1 - SendMessage, 2 - ack */
7953 static DWORD CALLBACK
send_msg_thread_2(void *param
)
7956 struct peekmsg_info
*info
= param
;
7958 trace("thread: waiting for start\n");
7959 WaitForSingleObject(info
->hevent
[EV_START_STOP
], INFINITE
);
7960 trace("thread: looping\n");
7964 ret
= WaitForMultipleObjects(2, info
->hevent
, FALSE
, INFINITE
);
7968 case WAIT_OBJECT_0
+ EV_START_STOP
:
7969 trace("thread: exiting\n");
7972 case WAIT_OBJECT_0
+ EV_SENDMSG
:
7973 trace("thread: sending message\n");
7974 SendNotifyMessageA(info
->hwnd
, WM_USER
, 0, 0);
7975 SetEvent(info
->hevent
[EV_ACK
]);
7979 trace("unexpected return: %04x\n", ret
);
7987 static void test_PeekMessage(void)
7992 UINT qs_all_input
= QS_ALLINPUT
;
7993 UINT qs_input
= QS_INPUT
;
7995 struct peekmsg_info info
;
7997 info
.hwnd
= CreateWindowA("TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
7998 100, 100, 200, 200, 0, 0, 0, NULL
);
8000 ShowWindow(info
.hwnd
, SW_SHOW
);
8001 UpdateWindow(info
.hwnd
);
8002 SetFocus(info
.hwnd
);
8004 info
.hevent
[EV_START_STOP
] = CreateEventA(NULL
, 0, 0, NULL
);
8005 info
.hevent
[EV_SENDMSG
] = CreateEventA(NULL
, 0, 0, NULL
);
8006 info
.hevent
[EV_ACK
] = CreateEventA(NULL
, 0, 0, NULL
);
8008 hthread
= CreateThread(NULL
, 0, send_msg_thread_2
, &info
, 0, &tid
);
8011 trace("signalling to start looping\n");
8012 SetEvent(info
.hevent
[EV_START_STOP
]);
8014 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
8017 SetLastError(0xdeadbeef);
8018 qstatus
= GetQueueStatus(qs_all_input
);
8019 if (GetLastError() == ERROR_INVALID_FLAGS
)
8021 trace("QS_RAWINPUT not supported on this platform\n");
8022 qs_all_input
&= ~QS_RAWINPUT
;
8023 qs_input
&= ~QS_RAWINPUT
;
8025 ok(qstatus
== 0, "wrong qstatus %08x\n", qstatus
);
8027 trace("signalling to send message\n");
8028 SetEvent(info
.hevent
[EV_SENDMSG
]);
8029 WaitForSingleObject(info
.hevent
[EV_ACK
], INFINITE
);
8031 /* pass invalid QS_xxxx flags */
8032 SetLastError(0xdeadbeef);
8033 qstatus
= GetQueueStatus(0xffffffff);
8034 ok(qstatus
== 0, "GetQueueStatus should fail: %08x\n", qstatus
);
8035 ok(GetLastError() == ERROR_INVALID_FLAGS
, "wrong error %d\n", GetLastError());
8037 qstatus
= GetQueueStatus(qs_all_input
);
8038 ok(qstatus
== MAKELONG(QS_SENDMESSAGE
, QS_SENDMESSAGE
),
8039 "wrong qstatus %08x\n", qstatus
);
8042 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
8044 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8046 ok_sequence(WmUser
, "WmUser", FALSE
);
8048 qstatus
= GetQueueStatus(qs_all_input
);
8049 ok(qstatus
== 0, "wrong qstatus %08x\n", qstatus
);
8051 keybd_event('N', 0, 0, 0);
8052 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
8053 qstatus
= GetQueueStatus(qs_all_input
);
8054 ok(qstatus
== MAKELONG(QS_KEY
, QS_KEY
),
8055 "wrong qstatus %08x\n", qstatus
);
8057 PostMessageA(info
.hwnd
, WM_CHAR
, 'z', 0);
8058 qstatus
= GetQueueStatus(qs_all_input
);
8059 ok(qstatus
== MAKELONG(QS_POSTMESSAGE
, QS_POSTMESSAGE
|QS_KEY
),
8060 "wrong qstatus %08x\n", qstatus
);
8062 InvalidateRect(info
.hwnd
, NULL
, FALSE
);
8063 qstatus
= GetQueueStatus(qs_all_input
);
8064 ok(qstatus
== MAKELONG(QS_PAINT
, QS_PAINT
|QS_POSTMESSAGE
|QS_KEY
),
8065 "wrong qstatus %08x\n", qstatus
);
8067 trace("signalling to send message\n");
8068 SetEvent(info
.hevent
[EV_SENDMSG
]);
8069 WaitForSingleObject(info
.hevent
[EV_ACK
], INFINITE
);
8071 qstatus
= GetQueueStatus(qs_all_input
);
8072 ok(qstatus
== MAKELONG(QS_SENDMESSAGE
, QS_SENDMESSAGE
|QS_PAINT
|QS_POSTMESSAGE
|QS_KEY
),
8073 "wrong qstatus %08x\n", qstatus
);
8076 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| (qs_input
<< 16));
8078 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8080 ok_sequence(WmUser
, "WmUser", FALSE
);
8082 qstatus
= GetQueueStatus(qs_all_input
);
8083 ok(qstatus
== MAKELONG(0, QS_PAINT
|QS_POSTMESSAGE
|QS_KEY
),
8084 "wrong qstatus %08x\n", qstatus
);
8086 trace("signalling to send message\n");
8087 SetEvent(info
.hevent
[EV_SENDMSG
]);
8088 WaitForSingleObject(info
.hevent
[EV_ACK
], INFINITE
);
8090 qstatus
= GetQueueStatus(qs_all_input
);
8091 ok(qstatus
== MAKELONG(QS_SENDMESSAGE
, QS_SENDMESSAGE
|QS_PAINT
|QS_POSTMESSAGE
|QS_KEY
),
8092 "wrong qstatus %08x\n", qstatus
);
8095 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| PM_QS_POSTMESSAGE
);
8097 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8099 ok_sequence(WmUser
, "WmUser", FALSE
);
8101 qstatus
= GetQueueStatus(qs_all_input
);
8102 ok(qstatus
== MAKELONG(0, QS_PAINT
|QS_POSTMESSAGE
|QS_KEY
),
8103 "wrong qstatus %08x\n", qstatus
);
8106 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| PM_QS_POSTMESSAGE
);
8107 ok(ret
&& msg
.message
== WM_CHAR
&& msg
.wParam
== 'z',
8108 "got %d and %04x wParam %08lx instead of TRUE and WM_CHAR wParam 'z'\n",
8109 ret
, msg
.message
, msg
.wParam
);
8110 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
8112 qstatus
= GetQueueStatus(qs_all_input
);
8113 ok(qstatus
== MAKELONG(0, QS_PAINT
|QS_KEY
),
8114 "wrong qstatus %08x\n", qstatus
);
8117 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| PM_QS_POSTMESSAGE
);
8119 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8121 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
8123 qstatus
= GetQueueStatus(qs_all_input
);
8124 ok(qstatus
== MAKELONG(0, QS_PAINT
|QS_KEY
),
8125 "wrong qstatus %08x\n", qstatus
);
8128 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| PM_QS_PAINT
);
8129 ok(ret
&& msg
.message
== WM_PAINT
,
8130 "got %d and %04x instead of TRUE and WM_PAINT\n", ret
, msg
.message
);
8131 DispatchMessageA(&msg
);
8132 ok_sequence(WmPaint
, "WmPaint", FALSE
);
8134 qstatus
= GetQueueStatus(qs_all_input
);
8135 ok(qstatus
== MAKELONG(0, QS_KEY
),
8136 "wrong qstatus %08x\n", qstatus
);
8139 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| PM_QS_PAINT
);
8141 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8143 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
8145 qstatus
= GetQueueStatus(qs_all_input
);
8146 ok(qstatus
== MAKELONG(0, QS_KEY
),
8147 "wrong qstatus %08x\n", qstatus
);
8149 trace("signalling to send message\n");
8150 SetEvent(info
.hevent
[EV_SENDMSG
]);
8151 WaitForSingleObject(info
.hevent
[EV_ACK
], INFINITE
);
8153 qstatus
= GetQueueStatus(qs_all_input
);
8154 ok(qstatus
== MAKELONG(QS_SENDMESSAGE
, QS_SENDMESSAGE
|QS_KEY
),
8155 "wrong qstatus %08x\n", qstatus
);
8157 PostMessageA(info
.hwnd
, WM_CHAR
, 'z', 0);
8159 qstatus
= GetQueueStatus(qs_all_input
);
8160 ok(qstatus
== MAKELONG(QS_POSTMESSAGE
, QS_SENDMESSAGE
|QS_POSTMESSAGE
|QS_KEY
),
8161 "wrong qstatus %08x\n", qstatus
);
8164 ret
= PeekMessageA(&msg
, 0, WM_CHAR
, WM_CHAR
, PM_REMOVE
);
8165 ok(ret
&& msg
.message
== WM_CHAR
&& msg
.wParam
== 'z',
8166 "got %d and %04x wParam %08lx instead of TRUE and WM_CHAR wParam 'z'\n",
8167 ret
, msg
.message
, msg
.wParam
);
8168 ok_sequence(WmUser
, "WmUser", FALSE
);
8170 qstatus
= GetQueueStatus(qs_all_input
);
8171 ok(qstatus
== MAKELONG(0, QS_KEY
),
8172 "wrong qstatus %08x\n", qstatus
);
8175 ret
= PeekMessageA(&msg
, 0, WM_CHAR
, WM_CHAR
, PM_REMOVE
);
8177 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8179 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
8181 qstatus
= GetQueueStatus(qs_all_input
);
8182 ok(qstatus
== MAKELONG(0, QS_KEY
),
8183 "wrong qstatus %08x\n", qstatus
);
8185 PostMessageA(info
.hwnd
, WM_CHAR
, 'z', 0);
8187 qstatus
= GetQueueStatus(qs_all_input
);
8188 ok(qstatus
== MAKELONG(QS_POSTMESSAGE
, QS_POSTMESSAGE
|QS_KEY
),
8189 "wrong qstatus %08x\n", qstatus
);
8191 trace("signalling to send message\n");
8192 SetEvent(info
.hevent
[EV_SENDMSG
]);
8193 WaitForSingleObject(info
.hevent
[EV_ACK
], INFINITE
);
8195 qstatus
= GetQueueStatus(qs_all_input
);
8196 ok(qstatus
== MAKELONG(QS_SENDMESSAGE
, QS_SENDMESSAGE
|QS_POSTMESSAGE
|QS_KEY
),
8197 "wrong qstatus %08x\n", qstatus
);
8200 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| (QS_KEY
<< 16));
8202 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8204 ok_sequence(WmUser
, "WmUser", FALSE
);
8206 qstatus
= GetQueueStatus(qs_all_input
);
8207 ok(qstatus
== MAKELONG(0, QS_POSTMESSAGE
|QS_KEY
),
8208 "wrong qstatus %08x\n", qstatus
);
8211 if (qs_all_input
& QS_RAWINPUT
) /* use QS_RAWINPUT only if supported */
8212 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| (QS_RAWINPUT
<< 16));
8213 else /* workaround for a missing QS_RAWINPUT support */
8214 ret
= PeekMessageA(&msg
, 0, WM_KEYDOWN
, WM_KEYDOWN
, PM_REMOVE
);
8215 ok(ret
&& msg
.message
== WM_KEYDOWN
&& msg
.wParam
== 'N',
8216 "got %d and %04x wParam %08lx instead of TRUE and WM_KEYDOWN wParam 'N'\n",
8217 ret
, msg
.message
, msg
.wParam
);
8218 ok_sequence(WmKeyDownSkippedSeq
, "WmKeyDownSkippedSeq", FALSE
);
8220 qstatus
= GetQueueStatus(qs_all_input
);
8221 ok(qstatus
== MAKELONG(0, QS_POSTMESSAGE
|QS_KEY
),
8222 "wrong qstatus %08x\n", qstatus
);
8225 if (qs_all_input
& QS_RAWINPUT
) /* use QS_RAWINPUT only if supported */
8226 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| (QS_RAWINPUT
<< 16));
8227 else /* workaround for a missing QS_RAWINPUT support */
8228 ret
= PeekMessageA(&msg
, 0, WM_KEYUP
, WM_KEYUP
, PM_REMOVE
);
8229 ok(ret
&& msg
.message
== WM_KEYUP
&& msg
.wParam
== 'N',
8230 "got %d and %04x wParam %08lx instead of TRUE and WM_KEYUP wParam 'N'\n",
8231 ret
, msg
.message
, msg
.wParam
);
8232 ok_sequence(WmKeyUpSkippedSeq
, "WmKeyUpSkippedSeq", FALSE
);
8234 qstatus
= GetQueueStatus(qs_all_input
);
8235 ok(qstatus
== MAKELONG(0, QS_POSTMESSAGE
),
8236 "wrong qstatus %08x\n", qstatus
);
8239 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| PM_QS_SENDMESSAGE
);
8241 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8243 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
8245 qstatus
= GetQueueStatus(qs_all_input
);
8246 ok(qstatus
== MAKELONG(0, QS_POSTMESSAGE
),
8247 "wrong qstatus %08x\n", qstatus
);
8250 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
8251 ok(ret
&& msg
.message
== WM_CHAR
&& msg
.wParam
== 'z',
8252 "got %d and %04x wParam %08lx instead of TRUE and WM_CHAR wParam 'z'\n",
8253 ret
, msg
.message
, msg
.wParam
);
8254 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
8256 qstatus
= GetQueueStatus(qs_all_input
);
8258 "wrong qstatus %08x\n", qstatus
);
8261 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
8263 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8265 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
8267 qstatus
= GetQueueStatus(qs_all_input
);
8269 "wrong qstatus %08x\n", qstatus
);
8271 /* test whether presence of the quit flag in the queue affects
8274 PostQuitMessage(0x1234abcd);
8276 qstatus
= GetQueueStatus(qs_all_input
);
8277 ok(qstatus
== MAKELONG(QS_POSTMESSAGE
, QS_POSTMESSAGE
),
8278 "wrong qstatus %08x\n", qstatus
);
8280 PostMessageA(info
.hwnd
, WM_USER
, 0, 0);
8282 qstatus
= GetQueueStatus(qs_all_input
);
8283 ok(qstatus
== MAKELONG(QS_POSTMESSAGE
, QS_POSTMESSAGE
),
8284 "wrong qstatus %08x\n", qstatus
);
8287 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
8288 ok(ret
&& msg
.message
== WM_USER
,
8289 "got %d and %04x instead of TRUE and WM_USER\n", ret
, msg
.message
);
8290 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
8292 qstatus
= GetQueueStatus(qs_all_input
);
8293 ok(qstatus
== MAKELONG(0, QS_POSTMESSAGE
),
8294 "wrong qstatus %08x\n", qstatus
);
8297 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
8298 ok(ret
&& msg
.message
== WM_QUIT
,
8299 "got %d and %04x instead of TRUE and WM_QUIT\n", ret
, msg
.message
);
8300 ok(msg
.wParam
== 0x1234abcd, "got wParam %08lx instead of 0x1234abcd\n", msg
.wParam
);
8301 ok(msg
.lParam
== 0, "got lParam %08lx instead of 0\n", msg
.lParam
);
8302 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
8304 qstatus
= GetQueueStatus(qs_all_input
);
8306 ok(qstatus
== MAKELONG(0, QS_POSTMESSAGE
),
8307 "wrong qstatus %08x\n", qstatus
);
8311 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
8313 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8315 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
8317 qstatus
= GetQueueStatus(qs_all_input
);
8319 "wrong qstatus %08x\n", qstatus
);
8321 trace("signalling to exit\n");
8322 SetEvent(info
.hevent
[EV_START_STOP
]);
8324 WaitForSingleObject(hthread
, INFINITE
);
8326 CloseHandle(hthread
);
8327 CloseHandle(info
.hevent
[0]);
8328 CloseHandle(info
.hevent
[1]);
8329 CloseHandle(info
.hevent
[2]);
8331 DestroyWindow(info
.hwnd
);
8335 static void test_quit_message(void)
8340 /* test using PostQuitMessage */
8341 PostQuitMessage(0xbeef);
8343 ret
= PeekMessage(&msg
, NULL
, 0, 0, PM_NOREMOVE
);
8344 ok(ret
, "PeekMessage failed with error %d\n", GetLastError());
8345 ok(msg
.message
== WM_QUIT
, "Received message 0x%04x instead of WM_QUIT\n", msg
.message
);
8346 ok(msg
.wParam
== 0xbeef, "wParam was 0x%lx instead of 0xbeef\n", msg
.wParam
);
8348 ret
= PostThreadMessage(GetCurrentThreadId(), WM_USER
, 0, 0);
8349 ok(ret
, "PostMessage failed with error %d\n", GetLastError());
8351 ret
= GetMessage(&msg
, NULL
, 0, 0);
8352 ok(ret
> 0, "GetMessage failed with error %d\n", GetLastError());
8353 ok(msg
.message
== WM_USER
, "Received message 0x%04x instead of WM_USER\n", msg
.message
);
8355 /* note: WM_QUIT message received after WM_USER message */
8356 ret
= GetMessage(&msg
, NULL
, 0, 0);
8357 ok(!ret
, "GetMessage return %d with error %d instead of FALSE\n", ret
, GetLastError());
8358 ok(msg
.message
== WM_QUIT
, "Received message 0x%04x instead of WM_QUIT\n", msg
.message
);
8359 ok(msg
.wParam
== 0xbeef, "wParam was 0x%lx instead of 0xbeef\n", msg
.wParam
);
8361 ret
= PeekMessage(&msg
, NULL
, 0, 0, PM_REMOVE
);
8362 ok( !ret
|| msg
.message
!= WM_QUIT
, "Received WM_QUIT again\n" );
8364 /* now test with PostThreadMessage - different behaviour! */
8365 PostThreadMessage(GetCurrentThreadId(), WM_QUIT
, 0xdead, 0);
8367 ret
= PeekMessage(&msg
, NULL
, 0, 0, PM_NOREMOVE
);
8368 ok(ret
, "PeekMessage failed with error %d\n", GetLastError());
8369 ok(msg
.message
== WM_QUIT
, "Received message 0x%04x instead of WM_QUIT\n", msg
.message
);
8370 ok(msg
.wParam
== 0xdead, "wParam was 0x%lx instead of 0xdead\n", msg
.wParam
);
8372 ret
= PostThreadMessage(GetCurrentThreadId(), WM_USER
, 0, 0);
8373 ok(ret
, "PostMessage failed with error %d\n", GetLastError());
8375 /* note: we receive the WM_QUIT message first this time */
8376 ret
= GetMessage(&msg
, NULL
, 0, 0);
8377 ok(!ret
, "GetMessage return %d with error %d instead of FALSE\n", ret
, GetLastError());
8378 ok(msg
.message
== WM_QUIT
, "Received message 0x%04x instead of WM_QUIT\n", msg
.message
);
8379 ok(msg
.wParam
== 0xdead, "wParam was 0x%lx instead of 0xdead\n", msg
.wParam
);
8381 ret
= GetMessage(&msg
, NULL
, 0, 0);
8382 ok(ret
> 0, "GetMessage failed with error %d\n", GetLastError());
8383 ok(msg
.message
== WM_USER
, "Received message 0x%04x instead of WM_USER\n", msg
.message
);
8386 static const struct message WmMouseHoverSeq
[] = {
8387 { WM_TIMER
, sent
|optional
}, /* XP sends it */
8388 { WM_SYSTIMER
, sent
},
8389 { WM_MOUSEHOVER
, sent
|wparam
, 0 },
8393 static void pump_msg_loop_timeout(DWORD timeout
, BOOL inject_mouse_move
)
8396 DWORD start_ticks
, end_ticks
;
8398 start_ticks
= GetTickCount();
8399 /* add some deviation (5%) to cover not expected delays */
8400 start_ticks
+= timeout
/ 20;
8404 while (PeekMessage(&msg
, 0, 0, 0, PM_REMOVE
))
8406 /* Timer proc messages are not dispatched to the window proc,
8407 * and therefore not logged.
8409 if (msg
.message
== WM_TIMER
|| msg
.message
== WM_SYSTIMER
)
8411 struct message s_msg
;
8413 s_msg
.message
= msg
.message
;
8414 s_msg
.flags
= sent
|wparam
|lparam
;
8415 s_msg
.wParam
= msg
.wParam
;
8416 s_msg
.lParam
= msg
.lParam
;
8417 add_message(&s_msg
);
8419 DispatchMessage(&msg
);
8422 end_ticks
= GetTickCount();
8424 /* inject WM_MOUSEMOVE to see how it changes tracking */
8425 if (inject_mouse_move
&& start_ticks
+ timeout
/ 2 >= end_ticks
)
8427 mouse_event(MOUSEEVENTF_MOVE
, -1, 0, 0, 0);
8428 mouse_event(MOUSEEVENTF_MOVE
, 1, 0, 0, 0);
8430 inject_mouse_move
= FALSE
;
8432 } while (start_ticks
+ timeout
>= end_ticks
);
8435 static void test_TrackMouseEvent(void)
8438 TRACKMOUSEEVENT tme
;
8441 RECT rc_parent
, rc_child
;
8442 UINT default_hover_time
, hover_width
= 0, hover_height
= 0;
8444 #define track_hover(track_hwnd, track_hover_time) \
8445 tme.cbSize = sizeof(tme); \
8446 tme.dwFlags = TME_HOVER; \
8447 tme.hwndTrack = track_hwnd; \
8448 tme.dwHoverTime = track_hover_time; \
8449 SetLastError(0xdeadbeef); \
8450 ret = TrackMouseEvent(&tme); \
8451 ok(ret, "TrackMouseEvent(TME_HOVER) error %d\n", GetLastError())
8453 #define track_query(expected_track_flags, expected_track_hwnd, expected_hover_time) \
8454 tme.cbSize = sizeof(tme); \
8455 tme.dwFlags = TME_QUERY; \
8456 tme.hwndTrack = (HWND)0xdeadbeef; \
8457 tme.dwHoverTime = 0xdeadbeef; \
8458 SetLastError(0xdeadbeef); \
8459 ret = TrackMouseEvent(&tme); \
8460 ok(ret, "TrackMouseEvent(TME_QUERY) error %d\n", GetLastError());\
8461 ok(tme.cbSize == sizeof(tme), "wrong tme.cbSize %u\n", tme.cbSize); \
8462 ok(tme.dwFlags == (expected_track_flags), \
8463 "wrong tme.dwFlags %08x, expected %08x\n", tme.dwFlags, (expected_track_flags)); \
8464 ok(tme.hwndTrack == (expected_track_hwnd), \
8465 "wrong tme.hwndTrack %p, expected %p\n", tme.hwndTrack, (expected_track_hwnd)); \
8466 ok(tme.dwHoverTime == (expected_hover_time), \
8467 "wrong tme.dwHoverTime %u, expected %u\n", tme.dwHoverTime, (expected_hover_time))
8469 #define track_hover_cancel(track_hwnd) \
8470 tme.cbSize = sizeof(tme); \
8471 tme.dwFlags = TME_HOVER | TME_CANCEL; \
8472 tme.hwndTrack = track_hwnd; \
8473 tme.dwHoverTime = 0xdeadbeef; \
8474 SetLastError(0xdeadbeef); \
8475 ret = TrackMouseEvent(&tme); \
8476 ok(ret, "TrackMouseEvent(TME_HOVER | TME_CANCEL) error %d\n", GetLastError())
8478 default_hover_time
= 0xdeadbeef;
8479 SetLastError(0xdeadbeef);
8480 ret
= SystemParametersInfo(SPI_GETMOUSEHOVERTIME
, 0, &default_hover_time
, 0);
8481 ok(ret
, "SystemParametersInfo(SPI_GETMOUSEHOVERTIME) error %u\n", GetLastError());
8482 if (!ret
) default_hover_time
= 400;
8483 trace("SPI_GETMOUSEHOVERTIME returned %u ms\n", default_hover_time
);
8485 SetLastError(0xdeadbeef);
8486 ret
= SystemParametersInfo(SPI_GETMOUSEHOVERWIDTH
, 0, &hover_width
, 0);
8487 ok(ret
, "SystemParametersInfo(SPI_GETMOUSEHOVERWIDTH) error %u\n", GetLastError());
8488 if (!ret
) hover_width
= 4;
8489 SetLastError(0xdeadbeef);
8490 ret
= SystemParametersInfo(SPI_GETMOUSEHOVERHEIGHT
, 0, &hover_height
, 0);
8491 ok(ret
, "SystemParametersInfo(SPI_GETMOUSEHOVERHEIGHT) error %u\n", GetLastError());
8492 if (!ret
) hover_height
= 4;
8493 trace("hover rect is %u x %d\n", hover_width
, hover_height
);
8495 hwnd
= CreateWindowEx(0, "TestWindowClass", NULL
,
8496 WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
8497 CW_USEDEFAULT
, CW_USEDEFAULT
, 300, 300, 0,
8501 hchild
= CreateWindowEx(0, "TestWindowClass", NULL
,
8502 WS_CHILD
| WS_BORDER
| WS_VISIBLE
,
8503 50, 50, 200, 200, hwnd
,
8511 tme
.dwFlags
= TME_QUERY
;
8512 tme
.hwndTrack
= (HWND
)0xdeadbeef;
8513 tme
.dwHoverTime
= 0xdeadbeef;
8514 SetLastError(0xdeadbeef);
8515 ret
= TrackMouseEvent(&tme
);
8516 ok(!ret
, "TrackMouseEvent should fail\n");
8517 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "not expected error %d\n", GetLastError());
8519 tme
.cbSize
= sizeof(tme
);
8520 tme
.dwFlags
= TME_HOVER
;
8521 tme
.hwndTrack
= (HWND
)0xdeadbeef;
8522 tme
.dwHoverTime
= 0xdeadbeef;
8523 SetLastError(0xdeadbeef);
8524 ret
= TrackMouseEvent(&tme
);
8525 ok(!ret
, "TrackMouseEvent should fail\n");
8526 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
, "not expected error %d\n", GetLastError());
8528 tme
.cbSize
= sizeof(tme
);
8529 tme
.dwFlags
= TME_HOVER
| TME_CANCEL
;
8530 tme
.hwndTrack
= (HWND
)0xdeadbeef;
8531 tme
.dwHoverTime
= 0xdeadbeef;
8532 SetLastError(0xdeadbeef);
8533 ret
= TrackMouseEvent(&tme
);
8534 ok(!ret
, "TrackMouseEvent should fail\n");
8535 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
, "not expected error %d\n", GetLastError());
8537 GetWindowRect(hwnd
, &rc_parent
);
8538 GetWindowRect(hchild
, &rc_child
);
8539 SetCursorPos(rc_child
.left
- 10, rc_child
.top
- 10);
8541 /* Process messages so that the system updates its internal current
8542 * window and hittest, otherwise TrackMouseEvent calls don't have any
8545 while (PeekMessage(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage(&msg
);
8548 track_query(0, NULL
, 0);
8549 track_hover(hchild
, 0);
8550 track_query(0, NULL
, 0);
8552 while (PeekMessage(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage(&msg
);
8555 track_hover(hwnd
, 0);
8556 track_query(TME_HOVER
, hwnd
, default_hover_time
);
8558 pump_msg_loop_timeout(default_hover_time
, FALSE
);
8559 ok_sequence(WmMouseHoverSeq
, "WmMouseHoverSeq", FALSE
);
8561 track_query(0, NULL
, 0);
8563 track_hover(hwnd
, HOVER_DEFAULT
);
8564 track_query(TME_HOVER
, hwnd
, default_hover_time
);
8566 Sleep(default_hover_time
/ 2);
8567 mouse_event(MOUSEEVENTF_MOVE
, -1, 0, 0, 0);
8568 mouse_event(MOUSEEVENTF_MOVE
, 1, 0, 0, 0);
8570 track_query(TME_HOVER
, hwnd
, default_hover_time
);
8572 pump_msg_loop_timeout(default_hover_time
/ 2, FALSE
);
8573 ok_sequence(WmMouseHoverSeq
, "WmMouseHoverSeq", FALSE
);
8575 track_query(0, NULL
, 0);
8577 track_hover(hwnd
, HOVER_DEFAULT
);
8578 track_query(TME_HOVER
, hwnd
, default_hover_time
);
8580 pump_msg_loop_timeout(default_hover_time
, TRUE
);
8581 ok_sequence(WmMouseHoverSeq
, "WmMouseHoverSeq", FALSE
);
8583 track_query(0, NULL
, 0);
8585 track_hover(hwnd
, HOVER_DEFAULT
);
8586 track_query(TME_HOVER
, hwnd
, default_hover_time
);
8587 track_hover_cancel(hwnd
);
8589 DestroyWindow(hwnd
);
8593 #undef track_hover_cancel
8597 static const struct message WmSetWindowRgn
[] = {
8598 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
},
8599 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
8600 { WM_NCPAINT
, sent
}, /* wparam != 1 */
8601 { WM_GETTEXT
, sent
|defwinproc
|optional
},
8602 { WM_ERASEBKGND
, sent
|optional
}, /* FIXME: remove optional once Wine is fixed */
8603 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
},
8604 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
8608 static const struct message WmSetWindowRgn_no_redraw
[] = {
8609 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
},
8610 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
8611 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
},
8612 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
8616 static const struct message WmSetWindowRgn_clear
[] = {
8617 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
}, /* some versions of 2000/XP also has SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE in wparam */
8618 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
8619 { WM_NCPAINT
, sent
}, /* wparam != 1 */
8620 { WM_GETTEXT
, sent
|defwinproc
|optional
},
8621 { WM_ERASEBKGND
, sent
|optional
}, /* FIXME: remove optional once Wine is fixed */
8622 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
},
8623 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
8624 { WM_NCPAINT
, sent
|optional
}, /* wparam != 1 */
8625 { WM_GETTEXT
, sent
|defwinproc
|optional
},
8626 { WM_ERASEBKGND
, sent
|optional
},
8627 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
8628 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
8632 static void test_SetWindowRgn(void)
8635 HWND hwnd
= CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW
,
8636 100, 100, 200, 200, 0, 0, 0, NULL
);
8637 ok( hwnd
!= 0, "Failed to create overlapped window\n" );
8639 ShowWindow( hwnd
, SW_SHOW
);
8640 UpdateWindow( hwnd
);
8644 trace("testing SetWindowRgn\n");
8645 hrgn
= CreateRectRgn( 0, 0, 150, 150 );
8646 SetWindowRgn( hwnd
, hrgn
, TRUE
);
8647 ok_sequence( WmSetWindowRgn
, "WmSetWindowRgn", FALSE
);
8649 hrgn
= CreateRectRgn( 30, 30, 160, 160 );
8650 SetWindowRgn( hwnd
, hrgn
, FALSE
);
8651 ok_sequence( WmSetWindowRgn_no_redraw
, "WmSetWindowRgn_no_redraw", FALSE
);
8653 hrgn
= CreateRectRgn( 0, 0, 180, 180 );
8654 SetWindowRgn( hwnd
, hrgn
, TRUE
);
8655 ok_sequence( WmSetWindowRgn
, "WmSetWindowRgn2", FALSE
);
8657 SetWindowRgn( hwnd
, 0, TRUE
);
8658 ok_sequence( WmSetWindowRgn_clear
, "WmSetWindowRgn_clear", FALSE
);
8660 DestroyWindow( hwnd
);
8663 /*************************** ShowWindow() test ******************************/
8664 static const struct message WmShowNormal
[] = {
8665 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
8666 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
8667 { HCBT_ACTIVATE
, hook
},
8668 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2003 doesn't send it */
8669 { HCBT_SETFOCUS
, hook
},
8670 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
8673 static const struct message WmShow
[] = {
8674 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
8675 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
8676 { HCBT_ACTIVATE
, hook
|optional
}, /* win2000 doesn't send it */
8677 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2000 doesn't send it */
8678 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 doesn't send it */
8679 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
8682 static const struct message WmShowNoActivate_1
[] = {
8683 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWNOACTIVATE
},
8684 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|0x8000 },
8685 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|0x8000 },
8686 { WM_MOVE
, sent
|defwinproc
},
8687 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_RESTORED
},
8690 static const struct message WmShowNoActivate_2
[] = {
8691 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWNOACTIVATE
},
8692 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|0x8000 },
8693 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|0x8000 },
8694 { WM_MOVE
, sent
|defwinproc
},
8695 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_RESTORED
},
8696 { HCBT_SETFOCUS
, hook
},
8697 { HCBT_ACTIVATE
, hook
|optional
}, /* win2003 doesn't send it */
8698 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2003 doesn't send it */
8699 { HCBT_SETFOCUS
, hook
|optional
}, /* win2003 doesn't send it */
8702 static const struct message WmShowNA_1
[] = {
8703 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
8704 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
8705 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
8708 static const struct message WmShowNA_2
[] = {
8709 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
8710 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
8713 static const struct message WmRestore_1
[] = {
8714 { HCBT_MINMAX
, hook
|lparam
, 0, SW_RESTORE
},
8715 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|0x8000 },
8716 { HCBT_ACTIVATE
, hook
|optional
}, /* win2000 doesn't send it */
8717 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2000 doesn't send it */
8718 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 doesn't send it */
8719 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|0x8000 },
8720 { WM_MOVE
, sent
|defwinproc
},
8721 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_RESTORED
},
8722 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 sends it */
8725 static const struct message WmRestore_2
[] = {
8726 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
8727 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
8728 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
8731 static const struct message WmRestore_3
[] = {
8732 { HCBT_MINMAX
, hook
|lparam
, 0, SW_RESTORE
},
8733 { WM_GETMINMAXINFO
, sent
},
8734 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|0x8000 },
8735 { HCBT_ACTIVATE
, hook
|optional
}, /* win2003 doesn't send it */
8736 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2003 doesn't send it */
8737 { HCBT_SETFOCUS
, hook
|optional
}, /* win2003 doesn't send it */
8738 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|0x8000 },
8739 { WM_MOVE
, sent
|defwinproc
},
8740 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_MAXIMIZED
},
8741 { HCBT_SETFOCUS
, hook
|optional
}, /* win2003 sends it */
8744 static const struct message WmRestore_4
[] = {
8745 { HCBT_MINMAX
, hook
|lparam
, 0, SW_RESTORE
},
8746 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|0x8000 },
8747 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|0x8000 },
8748 { WM_MOVE
, sent
|defwinproc
},
8749 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_RESTORED
},
8752 static const struct message WmRestore_5
[] = {
8753 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWNORMAL
},
8754 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|0x8000 },
8755 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|0x8000 },
8756 { WM_MOVE
, sent
|defwinproc
},
8757 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_RESTORED
},
8760 static const struct message WmHide_1
[] = {
8761 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
8762 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
8763 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
8764 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 sends it */
8767 static const struct message WmHide_2
[] = {
8768 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
8769 { WM_WINDOWPOSCHANGING
, sent
/*|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE*/ }, /* win2000 doesn't add SWP_NOACTIVATE */
8770 { WM_WINDOWPOSCHANGED
, sent
/*|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE*/ }, /* win2000 doesn't add SWP_NOACTIVATE */
8773 static const struct message WmHide_3
[] = {
8774 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
8775 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
8776 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
8777 { HCBT_SETFOCUS
, hook
},
8780 static const struct message WmShowMinimized_1
[] = {
8781 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINIMIZED
},
8782 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|0x8000 },
8783 { HCBT_ACTIVATE
, hook
|optional
}, /* win2000 doesn't send it */
8784 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2000 doesn't send it */
8785 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|0x8000 },
8786 { WM_MOVE
, sent
|defwinproc
},
8787 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_MINIMIZED
},
8790 static const struct message WmMinimize_1
[] = {
8791 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
8792 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 doesn't send it */
8793 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|0x8000 },
8794 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|0x8000 },
8795 { WM_MOVE
, sent
|defwinproc
},
8796 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_MINIMIZED
},
8799 static const struct message WmMinimize_2
[] = {
8800 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
8801 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|0x8000 },
8802 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|0x8000 },
8803 { WM_MOVE
, sent
|defwinproc
},
8804 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_MINIMIZED
},
8807 static const struct message WmMinimize_3
[] = {
8808 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
8809 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|0x8000 },
8810 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|0x8000 },
8811 { WM_MOVE
, sent
|defwinproc
},
8812 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_MINIMIZED
},
8815 static const struct message WmShowMinNoActivate
[] = {
8816 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINNOACTIVE
},
8817 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
8818 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
8821 static const struct message WmMinMax_1
[] = {
8822 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINIMIZED
},
8825 static const struct message WmMinMax_2
[] = {
8826 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMAXIMIZED
},
8829 static const struct message WmMinMax_3
[] = {
8830 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
8833 static const struct message WmMinMax_4
[] = {
8834 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINNOACTIVE
},
8837 static const struct message WmShowMaximized_1
[] = {
8838 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMAXIMIZED
},
8839 { WM_GETMINMAXINFO
, sent
},
8840 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|0x8000 },
8841 { HCBT_ACTIVATE
, hook
|optional
}, /* win2000 doesn't send it */
8842 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2000 doesn't send it */
8843 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 doesn't send it */
8844 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|0x8000 },
8845 { WM_MOVE
, sent
|defwinproc
},
8846 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_MAXIMIZED
},
8847 { HCBT_SETFOCUS
, hook
|optional
}, /* win2003 sends it */
8850 static const struct message WmShowMaximized_2
[] = {
8851 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMAXIMIZED
},
8852 { WM_GETMINMAXINFO
, sent
},
8853 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
},
8854 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
8855 { WM_MOVE
, sent
|optional
}, /* Win9x doesn't send it */
8856 { WM_SIZE
, sent
|wparam
|optional
, SIZE_MAXIMIZED
}, /* Win9x doesn't send it */
8857 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|0x8000 },
8858 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|0x8000 },
8859 { WM_MOVE
, sent
|defwinproc
},
8860 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_MAXIMIZED
},
8861 { HCBT_SETFOCUS
, hook
},
8864 static const struct message WmShowMaximized_3
[] = {
8865 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMAXIMIZED
},
8866 { WM_GETMINMAXINFO
, sent
},
8867 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|0x8000 },
8868 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|0x8000 },
8869 { WM_MOVE
, sent
|defwinproc
},
8870 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_MAXIMIZED
},
8874 static void test_ShowWindow(void)
8876 /* ShowWindow commands in random order */
8879 INT cmd
; /* ShowWindow command */
8880 LPARAM ret
; /* ShowWindow return value */
8881 DWORD style
; /* window style after the command */
8882 const struct message
*msg
; /* message sequence the command produces */
8883 BOOL todo_msg
; /* message sequence doesn't match what Wine does */
8886 /* 1 */ { SW_SHOWNORMAL
, FALSE
, WS_VISIBLE
, WmShowNormal
, FALSE
},
8887 /* 2 */ { SW_SHOWNORMAL
, TRUE
, WS_VISIBLE
, WmEmptySeq
, FALSE
},
8888 /* 3 */ { SW_HIDE
, TRUE
, 0, WmHide_1
, FALSE
},
8889 /* 4 */ { SW_HIDE
, FALSE
, 0, WmEmptySeq
, FALSE
},
8890 /* 5 */ { SW_SHOWMINIMIZED
, FALSE
, WS_VISIBLE
|WS_MINIMIZE
, WmShowMinimized_1
, FALSE
},
8891 /* 6 */ { SW_SHOWMINIMIZED
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinMax_1
, FALSE
},
8892 /* 7 */ { SW_HIDE
, TRUE
, WS_MINIMIZE
, WmHide_1
, FALSE
},
8893 /* 8 */ { SW_HIDE
, FALSE
, WS_MINIMIZE
, WmEmptySeq
, FALSE
},
8894 /* 9 */ { SW_SHOWMAXIMIZED
, FALSE
, WS_VISIBLE
|WS_MAXIMIZE
, WmShowMaximized_1
, FALSE
},
8895 /* 10 */ { SW_SHOWMAXIMIZED
, TRUE
, WS_VISIBLE
|WS_MAXIMIZE
, WmMinMax_2
, FALSE
},
8896 /* 11 */ { SW_HIDE
, TRUE
, WS_MAXIMIZE
, WmHide_1
, FALSE
},
8897 /* 12 */ { SW_HIDE
, FALSE
, WS_MAXIMIZE
, WmEmptySeq
, FALSE
},
8898 /* 13 */ { SW_SHOWNOACTIVATE
, FALSE
, WS_VISIBLE
, WmShowNoActivate_1
, FALSE
},
8899 /* 14 */ { SW_SHOWNOACTIVATE
, TRUE
, WS_VISIBLE
, WmEmptySeq
, FALSE
},
8900 /* 15 */ { SW_HIDE
, TRUE
, 0, WmHide_2
, FALSE
},
8901 /* 16 */ { SW_HIDE
, FALSE
, 0, WmEmptySeq
, FALSE
},
8902 /* 17 */ { SW_SHOW
, FALSE
, WS_VISIBLE
, WmShow
, FALSE
},
8903 /* 18 */ { SW_SHOW
, TRUE
, WS_VISIBLE
, WmEmptySeq
, FALSE
},
8904 /* 19 */ { SW_MINIMIZE
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinimize_1
, TRUE
},
8905 /* 20 */ { SW_MINIMIZE
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinMax_3
, FALSE
},
8906 /* 21 */ { SW_HIDE
, TRUE
, WS_MINIMIZE
, WmHide_2
, FALSE
},
8907 /* 22 */ { SW_SHOWMINNOACTIVE
, FALSE
, WS_VISIBLE
|WS_MINIMIZE
, WmShowMinNoActivate
, TRUE
},
8908 /* 23 */ { SW_SHOWMINNOACTIVE
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinMax_4
, FALSE
},
8909 /* 24 */ { SW_HIDE
, TRUE
, WS_MINIMIZE
, WmHide_2
, FALSE
},
8910 /* 25 */ { SW_HIDE
, FALSE
, WS_MINIMIZE
, WmEmptySeq
, FALSE
},
8911 /* 26 */ { SW_SHOWNA
, FALSE
, WS_VISIBLE
|WS_MINIMIZE
, WmShowNA_1
, FALSE
},
8912 /* 27 */ { SW_SHOWNA
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmShowNA_2
, FALSE
},
8913 /* 28 */ { SW_HIDE
, TRUE
, WS_MINIMIZE
, WmHide_2
, FALSE
},
8914 /* 29 */ { SW_HIDE
, FALSE
, WS_MINIMIZE
, WmEmptySeq
, FALSE
},
8915 /* 30 */ { SW_RESTORE
, FALSE
, WS_VISIBLE
, WmRestore_1
, FALSE
},
8916 /* 31 */ { SW_RESTORE
, TRUE
, WS_VISIBLE
, WmEmptySeq
, FALSE
},
8917 /* 32 */ { SW_HIDE
, TRUE
, 0, WmHide_3
, TRUE
},
8918 /* 33 */ { SW_HIDE
, FALSE
, 0, WmEmptySeq
, FALSE
},
8919 /* 34 */ { SW_NORMALNA
, FALSE
, 0, WmEmptySeq
, TRUE
}, /* what does this mean?! */
8920 /* 35 */ { SW_NORMALNA
, FALSE
, 0, WmEmptySeq
, TRUE
},
8921 /* 36 */ { SW_HIDE
, FALSE
, 0, WmEmptySeq
, FALSE
},
8922 /* 37 */ { SW_RESTORE
, FALSE
, WS_VISIBLE
, WmRestore_2
, FALSE
},
8923 /* 38 */ { SW_RESTORE
, TRUE
, WS_VISIBLE
, WmEmptySeq
, FALSE
},
8924 /* 39 */ { SW_SHOWNOACTIVATE
, TRUE
, WS_VISIBLE
, WmEmptySeq
, FALSE
},
8925 /* 40 */ { SW_MINIMIZE
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinimize_2
, TRUE
},
8926 /* 41 */ { SW_MINIMIZE
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinMax_3
, FALSE
},
8927 /* 42 */ { SW_SHOWMAXIMIZED
, TRUE
, WS_VISIBLE
|WS_MAXIMIZE
, WmShowMaximized_2
, TRUE
},
8928 /* 43 */ { SW_SHOWMAXIMIZED
, TRUE
, WS_VISIBLE
|WS_MAXIMIZE
, WmMinMax_2
, FALSE
},
8929 /* 44 */ { SW_MINIMIZE
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinimize_1
, TRUE
},
8930 /* 45 */ { SW_MINIMIZE
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinMax_3
, FALSE
},
8931 /* 46 */ { SW_RESTORE
, TRUE
, WS_VISIBLE
|WS_MAXIMIZE
, WmRestore_3
, FALSE
},
8932 /* 47 */ { SW_RESTORE
, TRUE
, WS_VISIBLE
, WmRestore_4
, FALSE
},
8933 /* 48 */ { SW_SHOWMAXIMIZED
, TRUE
, WS_VISIBLE
|WS_MAXIMIZE
, WmShowMaximized_3
, FALSE
},
8934 /* 49 */ { SW_SHOW
, TRUE
, WS_VISIBLE
|WS_MAXIMIZE
, WmEmptySeq
, FALSE
},
8935 /* 50 */ { SW_SHOWNORMAL
, TRUE
, WS_VISIBLE
, WmRestore_5
, FALSE
},
8936 /* 51 */ { SW_SHOWNORMAL
, TRUE
, WS_VISIBLE
, WmEmptySeq
, FALSE
},
8937 /* 52 */ { SW_HIDE
, TRUE
, 0, WmHide_1
, FALSE
},
8938 /* 53 */ { SW_HIDE
, FALSE
, 0, WmEmptySeq
, FALSE
},
8939 /* 54 */ { SW_MINIMIZE
, FALSE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinimize_3
, TRUE
},
8940 /* 55 */ { SW_HIDE
, TRUE
, WS_MINIMIZE
, WmHide_2
, FALSE
},
8941 /* 56 */ { SW_SHOWNOACTIVATE
, FALSE
, WS_VISIBLE
, WmShowNoActivate_2
, FALSE
},
8942 /* 57 */ { SW_SHOW
, TRUE
, WS_VISIBLE
, WmEmptySeq
, FALSE
}
8949 #define WS_BASE (WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX|WS_MAXIMIZEBOX|WS_POPUP|WS_CLIPSIBLINGS)
8950 hwnd
= CreateWindowEx(0, "ShowWindowClass", NULL
, WS_BASE
,
8955 style
= GetWindowLong(hwnd
, GWL_STYLE
) & ~WS_BASE
;
8956 ok(style
== 0, "expected style 0, got %08x\n", style
);
8961 for (i
= 0; i
< sizeof(sw
)/sizeof(sw
[0]); i
++)
8963 static const char * const sw_cmd_name
[13] =
8965 "SW_HIDE", "SW_SHOWNORMAL", "SW_SHOWMINIMIZED", "SW_SHOWMAXIMIZED",
8966 "SW_SHOWNOACTIVATE", "SW_SHOW", "SW_MINIMIZE", "SW_SHOWMINNOACTIVE",
8967 "SW_SHOWNA", "SW_RESTORE", "SW_SHOWDEFAULT", "SW_FORCEMINIMIZE",
8968 "SW_NORMALNA" /* 0xCC */
8971 INT idx
; /* index into the above array of names */
8973 idx
= (sw
[i
].cmd
== SW_NORMALNA
) ? 12 : sw
[i
].cmd
;
8975 style
= GetWindowLong(hwnd
, GWL_STYLE
);
8976 trace("%d: sending %s, current window style %08x\n", i
+1, sw_cmd_name
[idx
], style
);
8977 ret
= ShowWindow(hwnd
, sw
[i
].cmd
);
8978 ok(!ret
== !sw
[i
].ret
, "%d: cmd %s: expected ret %lu, got %lu\n", i
+1, sw_cmd_name
[idx
], sw
[i
].ret
, ret
);
8979 style
= GetWindowLong(hwnd
, GWL_STYLE
) & ~WS_BASE
;
8980 ok(style
== sw
[i
].style
, "%d: expected style %08x, got %08x\n", i
+1, sw
[i
].style
, style
);
8982 sprintf(comment
, "%d: ShowWindow(%s)", i
+1, sw_cmd_name
[idx
]);
8983 ok_sequence(sw
[i
].msg
, comment
, sw
[i
].todo_msg
);
8989 DestroyWindow(hwnd
);
8992 static INT_PTR WINAPI
test_dlg_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
8996 trace("dialog: %p, %04x, %08lx, %08lx\n", hwnd
, message
, wParam
, lParam
);
9000 case WM_WINDOWPOSCHANGING
:
9001 case WM_WINDOWPOSCHANGED
:
9003 WINDOWPOS
*winpos
= (WINDOWPOS
*)lParam
;
9005 trace("%s\n", (message
== WM_WINDOWPOSCHANGING
) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
9006 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
9007 winpos
->hwnd
, winpos
->hwndInsertAfter
,
9008 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
9009 dump_winpos_flags(winpos
->flags
);
9011 /* Log only documented flags, win2k uses 0x1000 and 0x2000
9012 * in the high word for internal purposes
9014 wParam
= winpos
->flags
& 0xffff;
9015 /* We are not interested in the flags that don't match under XP and Win9x */
9016 wParam
&= ~(SWP_NOZORDER
);
9020 /* explicitly ignore WM_GETICON message */
9025 msg
.message
= message
;
9026 msg
.flags
= sent
|wparam
|lparam
;
9027 msg
.wParam
= wParam
;
9028 msg
.lParam
= lParam
;
9031 /* calling DefDlgProc leads to a recursion under XP */
9042 static const struct message WmDefDlgSetFocus_1
[] = {
9043 { WM_GETDLGCODE
, sent
|wparam
|lparam
, 0, 0 },
9044 { WM_GETTEXTLENGTH
, sent
|wparam
|lparam
|optional
, 0, 0 }, /* XP */
9045 { WM_GETTEXT
, sent
|wparam
|optional
, 6 }, /* XP */
9046 { WM_GETTEXT
, sent
|wparam
|optional
, 12 }, /* XP */
9047 { EM_SETSEL
, sent
|wparam
, 0 }, /* XP sets lparam to text length, Win9x to -2 */
9048 { HCBT_SETFOCUS
, hook
},
9049 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
9050 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
9051 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
9052 { WM_SETFOCUS
, sent
|wparam
, 0 },
9053 { WM_CTLCOLOREDIT
, sent
},
9054 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
9055 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
9056 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
9057 { WM_COMMAND
, sent
|wparam
, MAKEWPARAM(1, EN_SETFOCUS
) },
9060 static const struct message WmDefDlgSetFocus_2
[] = {
9061 { WM_GETDLGCODE
, sent
|wparam
|lparam
, 0, 0 },
9062 { WM_GETTEXTLENGTH
, sent
|wparam
|lparam
|optional
, 0, 0 }, /* XP */
9063 { WM_GETTEXT
, sent
|wparam
|optional
, 6 }, /* XP */
9064 { WM_GETTEXT
, sent
|wparam
|optional
, 12 }, /* XP */
9065 { EM_SETSEL
, sent
|wparam
, 0 }, /* XP sets lparam to text length, Win9x to -2 */
9066 { WM_CTLCOLOREDIT
, sent
|optional
}, /* XP */
9069 /* Creation of a dialog */
9070 static const struct message WmCreateDialogParamSeq_1
[] = {
9071 { HCBT_CREATEWND
, hook
},
9072 { WM_NCCREATE
, sent
},
9073 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
9074 { WM_CREATE
, sent
},
9075 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
9076 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
9078 { WM_SETFONT
, sent
},
9079 { WM_INITDIALOG
, sent
},
9080 { WM_CHANGEUISTATE
, sent
|optional
},
9083 /* Creation of a dialog */
9084 static const struct message WmCreateDialogParamSeq_2
[] = {
9085 { HCBT_CREATEWND
, hook
},
9086 { WM_NCCREATE
, sent
},
9087 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
9088 { WM_CREATE
, sent
},
9089 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
9090 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
9092 { WM_CHANGEUISTATE
, sent
|optional
},
9096 static void test_dialog_messages(void)
9099 HWND hdlg
, hedit1
, hedit2
, hfocus
;
9102 #define set_selection(hctl, start, end) \
9103 ret = SendMessage(hctl, EM_SETSEL, start, end); \
9104 ok(ret == 1, "EM_SETSEL returned %ld\n", ret);
9106 #define check_selection(hctl, start, end) \
9107 ret = SendMessage(hctl, EM_GETSEL, 0, 0); \
9108 ok(ret == MAKELRESULT(start, end), "wrong selection (%d - %d)\n", LOWORD(ret), HIWORD(ret));
9112 hdlg
= CreateWindowEx(WS_EX_DLGMODALFRAME
, "TestDialogClass", NULL
,
9113 WS_VISIBLE
|WS_CAPTION
|WS_SYSMENU
|WS_DLGFRAME
,
9114 0, 0, 100, 100, 0, 0, 0, NULL
);
9115 ok(hdlg
!= 0, "Failed to create custom dialog window\n");
9117 hedit1
= CreateWindowEx(0, "my_edit_class", NULL
,
9118 WS_CHILD
|WS_BORDER
|WS_VISIBLE
|WS_TABSTOP
,
9119 0, 0, 80, 20, hdlg
, (HMENU
)1, 0, NULL
);
9120 ok(hedit1
!= 0, "Failed to create edit control\n");
9121 hedit2
= CreateWindowEx(0, "my_edit_class", NULL
,
9122 WS_CHILD
|WS_BORDER
|WS_VISIBLE
|WS_TABSTOP
,
9123 0, 40, 80, 20, hdlg
, (HMENU
)2, 0, NULL
);
9124 ok(hedit2
!= 0, "Failed to create edit control\n");
9126 SendMessage(hedit1
, WM_SETTEXT
, 0, (LPARAM
)"hello");
9127 SendMessage(hedit2
, WM_SETTEXT
, 0, (LPARAM
)"bye");
9129 hfocus
= GetFocus();
9130 ok(hfocus
== hdlg
, "wrong focus %p\n", hfocus
);
9133 hfocus
= GetFocus();
9134 ok(hfocus
== hedit2
, "wrong focus %p\n", hfocus
);
9136 check_selection(hedit1
, 0, 0);
9137 check_selection(hedit2
, 0, 0);
9139 set_selection(hedit2
, 0, -1);
9140 check_selection(hedit2
, 0, 3);
9143 hfocus
= GetFocus();
9144 ok(hfocus
== 0, "wrong focus %p\n", hfocus
);
9147 ret
= DefDlgProc(hdlg
, WM_SETFOCUS
, 0, 0);
9148 ok(ret
== 0, "WM_SETFOCUS returned %ld\n", ret
);
9149 ok_sequence(WmDefDlgSetFocus_1
, "DefDlgProc(WM_SETFOCUS) 1", FALSE
);
9151 hfocus
= GetFocus();
9152 ok(hfocus
== hedit1
, "wrong focus %p\n", hfocus
);
9154 check_selection(hedit1
, 0, 5);
9155 check_selection(hedit2
, 0, 3);
9158 ret
= DefDlgProc(hdlg
, WM_SETFOCUS
, 0, 0);
9159 ok(ret
== 0, "WM_SETFOCUS returned %ld\n", ret
);
9160 ok_sequence(WmDefDlgSetFocus_2
, "DefDlgProc(WM_SETFOCUS) 2", FALSE
);
9162 hfocus
= GetFocus();
9163 ok(hfocus
== hedit1
, "wrong focus %p\n", hfocus
);
9165 check_selection(hedit1
, 0, 5);
9166 check_selection(hedit2
, 0, 3);
9171 #undef set_selection
9172 #undef check_selection
9174 ok(GetClassInfo(0, "#32770", &cls
), "GetClassInfo failed\n");
9175 cls
.lpszClassName
= "MyDialogClass";
9176 cls
.hInstance
= GetModuleHandle(0);
9177 /* need a cast since a dlgproc is used as a wndproc */
9178 cls
.lpfnWndProc
= (WNDPROC
)test_dlg_proc
;
9179 if (!RegisterClass(&cls
)) assert(0);
9181 hdlg
= CreateDialogParam(0, "CLASS_TEST_DIALOG_2", 0, test_dlg_proc
, 0);
9182 ok(IsWindow(hdlg
), "CreateDialogParam failed\n");
9183 ok_sequence(WmCreateDialogParamSeq_1
, "CreateDialogParam_1", FALSE
);
9187 hdlg
= CreateDialogParam(0, "CLASS_TEST_DIALOG_2", 0, NULL
, 0);
9188 ok(IsWindow(hdlg
), "CreateDialogParam failed\n");
9189 ok_sequence(WmCreateDialogParamSeq_2
, "CreateDialogParam_2", FALSE
);
9193 UnregisterClass(cls
.lpszClassName
, cls
.hInstance
);
9196 static void test_nullCallback(void)
9201 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW
,
9202 100, 100, 200, 200, 0, 0, 0, NULL
);
9203 ok (hwnd
!= 0, "Failed to create overlapped window\n");
9205 SendMessageCallbackA(hwnd
,WM_NULL
,0,0,NULL
,0);
9206 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
9207 DestroyWindow(hwnd
);
9210 static const struct message SetForegroundWindowSeq
[] =
9212 { WM_NCACTIVATE
, sent
|wparam
, 0 },
9213 { WM_GETTEXT
, sent
|defwinproc
|optional
},
9214 { WM_ACTIVATE
, sent
|wparam
, 0 },
9215 { WM_ACTIVATEAPP
, sent
|wparam
, 0 },
9216 { WM_KILLFOCUS
, sent
},
9220 static void test_SetForegroundWindow(void)
9224 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test SetForegroundWindow",
9225 WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
9226 100, 100, 200, 200, 0, 0, 0, NULL
);
9227 ok (hwnd
!= 0, "Failed to create overlapped window\n");
9230 trace("SetForegroundWindow( 0 )\n");
9231 SetForegroundWindow( 0 );
9232 ok_sequence(WmEmptySeq
, "SetForegroundWindow( 0 ) away from foreground top level window", FALSE
);
9233 trace("SetForegroundWindow( GetDesktopWindow() )\n");
9234 SetForegroundWindow( GetDesktopWindow() );
9235 ok_sequence(SetForegroundWindowSeq
, "SetForegroundWindow( desktop ) away from "
9236 "foreground top level window", TRUE
);
9239 DestroyWindow(hwnd
);
9245 HMODULE user32
= GetModuleHandleA("user32.dll");
9246 FARPROC pSetWinEventHook
= GetProcAddress(user32
, "SetWinEventHook");
9247 FARPROC pUnhookWinEvent
= GetProcAddress(user32
, "UnhookWinEvent");
9248 FARPROC pIsWinEventHookInstalled
= 0;/*GetProcAddress(user32, "IsWinEventHookInstalled");*/
9249 pGetAncestor
= (void*) GetProcAddress(user32
, "GetAncestor");
9251 if (!RegisterWindowClasses()) assert(0);
9253 if (pSetWinEventHook
)
9255 hEvent_hook
= (HWINEVENTHOOK
)pSetWinEventHook(EVENT_MIN
, EVENT_MAX
,
9256 GetModuleHandleA(0),
9259 GetCurrentThreadId(),
9260 WINEVENT_INCONTEXT
);
9261 assert(hEvent_hook
);
9263 if (pIsWinEventHookInstalled
)
9266 for (event
= EVENT_MIN
; event
<= EVENT_MAX
; event
++)
9267 ok(pIsWinEventHookInstalled(event
), "IsWinEventHookInstalled(%u) failed\n", event
);
9271 cbt_hook_thread_id
= GetCurrentThreadId();
9272 hCBT_hook
= SetWindowsHookExA(WH_CBT
, cbt_hook_proc
, 0, GetCurrentThreadId());
9277 /* Fix message sequences before removing 4 lines below */
9279 if (pUnhookWinEvent
&& hEvent_hook
)
9281 ret
= pUnhookWinEvent(hEvent_hook
);
9282 ok( ret
, "UnhookWinEvent error %d\n", GetLastError());
9283 pUnhookWinEvent
= 0;
9290 test_scrollwindowex();
9293 invisible_parent_tests();
9294 test_mdi_messages();
9295 test_button_messages();
9296 test_static_messages();
9297 test_paint_messages();
9298 test_interthread_messages();
9299 test_message_conversion();
9300 test_accelerators();
9303 test_DestroyWindow();
9304 test_DispatchMessage();
9305 test_SendMessageTimeout();
9306 test_edit_messages();
9307 test_quit_message();
9308 test_TrackMouseEvent();
9309 test_SetWindowRgn();
9311 test_dialog_messages();
9312 test_nullCallback();
9313 test_SetForegroundWindow();
9315 UnhookWindowsHookEx(hCBT_hook
);
9316 if (pUnhookWinEvent
)
9318 ret
= pUnhookWinEvent(hEvent_hook
);
9319 ok( ret
, "UnhookWinEvent error %d\n", GetLastError());
9320 SetLastError(0xdeadbeef);
9321 ok(!pUnhookWinEvent(hEvent_hook
), "UnhookWinEvent succeeded\n");
9322 ok(GetLastError() == ERROR_INVALID_HANDLE
|| /* Win2k */
9323 GetLastError() == 0xdeadbeef, /* Win9x */
9324 "unexpected error %d\n", GetLastError());