2 * Unit tests for window message handling
4 * Copyright 1999 Ove Kaaven
5 * Copyright 2003 Dimitrie O. Paun
6 * Copyright 2004, 2005 Dmitry Timoshkov
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
27 #define _WIN32_WINNT 0x0501 /* For WM_CHANGEUISTATE,QS_RAWINPUT */
35 #include "wine/test.h"
37 #define MDI_FIRST_CHILD_ID 2004
39 /* undocumented SWP flags - from SDK 3.1 */
40 #define SWP_NOCLIENTSIZE 0x0800
41 #define SWP_NOCLIENTMOVE 0x1000
42 #define SWP_STATECHANGED 0x8000
44 #define SW_NORMALNA 0xCC /* undoc. flag in MinMaximize */
47 #define WM_KEYF1 0x004d
51 #define WM_SYSTIMER 0x0118
54 #define WND_PARENT_ID 1
55 #define WND_POPUP_ID 2
56 #define WND_CHILD_ID 3
58 #ifndef WM_LBTRACKPOINT
59 #define WM_LBTRACKPOINT 0x0131
62 /* encoded DRAWITEMSTRUCT into an LPARAM */
69 UINT type
: 4; /* ODT_* flags */
70 UINT ctl_id
: 4; /* Control ID */
71 UINT item_id
: 4; /* Menu item ID */
72 UINT action
: 4; /* ODA_* flags */
73 UINT state
: 16; /* ODS_* flags */
79 static BOOL test_DestroyWindow_flag
;
80 static HWINEVENTHOOK hEvent_hook
;
82 static void dump_winpos_flags(UINT flags
);
84 static const WCHAR testWindowClassW
[] =
85 { 'T','e','s','t','W','i','n','d','o','w','C','l','a','s','s','W',0 };
88 FIXME: add tests for these
89 Window Edge Styles (Win31/Win95/98 look), in order of precedence:
90 WS_EX_DLGMODALFRAME: double border, WS_CAPTION allowed
91 WS_THICKFRAME: thick border
92 WS_DLGFRAME: double border, WS_CAPTION not allowed (but possibly shown anyway)
93 WS_BORDER (default for overlapped windows): single black border
94 none (default for child (and popup?) windows): no border
111 UINT message
; /* the WM_* code */
112 msg_flags_t flags
; /* message props */
113 WPARAM wParam
; /* expected value of wParam */
114 LPARAM lParam
; /* expected value of lParam */
117 /* Empty message sequence */
118 static const struct message WmEmptySeq
[] =
122 /* CreateWindow (for overlapped window, not initially visible) (16/32) */
123 static const struct message WmCreateOverlappedSeq
[] = {
124 { HCBT_CREATEWND
, hook
},
125 { WM_GETMINMAXINFO
, sent
},
126 { WM_NCCREATE
, sent
},
127 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
128 { 0x0093, sent
|defwinproc
|optional
},
129 { 0x0094, sent
|defwinproc
|optional
},
130 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
132 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
135 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
136 * for a not visible overlapped window.
138 static const struct message WmSWP_ShowOverlappedSeq
[] = {
139 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
140 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
141 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
142 { WM_GETTEXT
, sent
|defwinproc
|optional
},
143 { WM_ERASEBKGND
, sent
|optional
},
144 { HCBT_ACTIVATE
, hook
},
145 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
146 { WM_NOTIFYFORMAT
, sent
|optional
},
147 { WM_QUERYUISTATE
, sent
|optional
},
148 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
149 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* Win9x: SWP_NOSENDCHANGING */
150 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
151 { WM_NCACTIVATE
, sent
|wparam
, 1 },
152 { WM_GETTEXT
, sent
|defwinproc
|optional
},
153 { WM_ACTIVATE
, sent
|wparam
, 1 },
154 { HCBT_SETFOCUS
, hook
},
155 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
156 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
157 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
158 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
159 { WM_GETTEXT
, sent
|optional
},
160 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
161 { WM_GETTEXT
, sent
|defwinproc
|optional
},
162 { WM_ERASEBKGND
, sent
|optional
},
163 /* Win9x adds SWP_NOZORDER below */
164 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
165 { WM_GETTEXT
, sent
|optional
},
166 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
167 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
168 { WM_ERASEBKGND
, sent
|optional
},
169 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
170 { WM_PAINT
, sent
|optional
},
171 { WM_NCPAINT
, sent
|beginpaint
|optional
},
172 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
175 /* SetWindowPos(SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE)
176 * for a visible overlapped window.
178 static const struct message WmSWP_HideOverlappedSeq
[] = {
179 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
180 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
181 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
185 /* SetWindowPos(SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOMOVE)
186 * for a visible overlapped window.
188 static const struct message WmSWP_ResizeSeq
[] = {
189 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
},
190 { WM_GETMINMAXINFO
, sent
|defwinproc
},
191 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
192 { WM_NCPAINT
, sent
|optional
},
193 { WM_GETTEXT
, sent
|defwinproc
|optional
},
194 { WM_ERASEBKGND
, sent
|optional
},
195 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
},
196 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
197 { WM_NCCALCSIZE
, sent
|wparam
|optional
, TRUE
},
198 { WM_NCPAINT
, sent
|optional
},
199 { WM_GETTEXT
, sent
|defwinproc
|optional
},
200 { WM_ERASEBKGND
, sent
|optional
},
201 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
202 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* XP sends a duplicate */
206 /* SetWindowPos(SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOMOVE)
207 * for a visible popup window.
209 static const struct message WmSWP_ResizePopupSeq
[] = {
210 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
},
211 { WM_GETMINMAXINFO
, sent
|defwinproc
|optional
}, /* Win9x */
212 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
213 { WM_NCPAINT
, sent
|optional
},
214 { WM_GETTEXT
, sent
|defwinproc
|optional
},
215 { WM_ERASEBKGND
, sent
|optional
},
216 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
},
217 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
218 { WM_NCCALCSIZE
, sent
|wparam
|optional
, TRUE
},
219 { WM_NCPAINT
, sent
|optional
},
220 { WM_GETTEXT
, sent
|defwinproc
|optional
},
221 { WM_ERASEBKGND
, sent
|optional
},
222 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
226 /* SetWindowPos(SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOSIZE)
227 * for a visible overlapped window.
229 static const struct message WmSWP_MoveSeq
[] = {
230 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOSIZE
},
231 { WM_NCPAINT
, sent
|optional
},
232 { WM_GETTEXT
, sent
|defwinproc
|optional
},
233 { WM_ERASEBKGND
, sent
|optional
},
234 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOCLIENTSIZE
},
235 { WM_MOVE
, sent
|defwinproc
|wparam
, 0 },
236 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
239 /* Resize with SetWindowPos(SWP_NOZORDER)
240 * for a visible overlapped window
241 * SWP_NOZORDER is stripped by the logging code
243 static const struct message WmSWP_ResizeNoZOrder
[] = {
244 { WM_WINDOWPOSCHANGING
, sent
|wparam
, /*SWP_NOZORDER|*/SWP_NOACTIVATE
},
245 { WM_GETMINMAXINFO
, sent
|defwinproc
},
246 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
247 { WM_NCPAINT
, sent
},
248 { WM_GETTEXT
, sent
|defwinproc
|optional
},
249 { WM_ERASEBKGND
, sent
|optional
}, /* FIXME: remove optional once Wine is fixed */
250 { WM_WINDOWPOSCHANGED
, sent
|wparam
, /*SWP_NOZORDER|*/SWP_NOMOVE
|SWP_NOCLIENTMOVE
|SWP_NOACTIVATE
},
251 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
252 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 }, /* Win9x doesn't send it */
253 { WM_NCPAINT
, sent
|optional
}, /* Win9x doesn't send it */
254 { WM_GETTEXT
, sent
|defwinproc
|optional
}, /* Win9x doesn't send it */
255 { WM_ERASEBKGND
, sent
|optional
}, /* Win9x doesn't send it */
256 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
257 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
261 /* Switch visible mdi children */
262 static const struct message WmSwitchChild
[] = {
263 /* Switch MDI child */
264 { WM_MDIACTIVATE
, sent
},/* in the MDI client */
265 { WM_WINDOWPOSCHANGING
, sent
|wparam
,SWP_NOSIZE
|SWP_NOMOVE
},/* in the 1st MDI child */
266 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
267 { WM_CHILDACTIVATE
, sent
},/* in the 1st MDI child */
268 /* Deactivate 2nd MDI child */
269 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 0 }, /* in the 2nd MDI child */
270 { WM_MDIACTIVATE
, sent
|defwinproc
}, /* in the 2nd MDI child */
271 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
272 /* Preparing for maximize and maximaze the 1st MDI child */
273 { WM_GETMINMAXINFO
, sent
|defwinproc
}, /* in the 1st MDI child */
274 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_STATECHANGED
}, /* in the 1st MDI child */
275 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 }, /* in the 1st MDI child */
276 { WM_CHILDACTIVATE
, sent
|defwinproc
}, /* in the 1st MDI child */
277 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
}, /* in the 1st MDI child */
278 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
}, /* in the 1st MDI child */
279 /* Lock redraw 2nd MDI child */
280 { WM_SETREDRAW
, sent
|wparam
|defwinproc
, 0 }, /* in the 2nd MDI child */
281 { HCBT_MINMAX
, hook
|lparam
, 0, SW_NORMALNA
},
282 /* Restore 2nd MDI child */
283 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_STATECHANGED
},/* in the 2nd MDI child */
284 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 },/* in the 2nd MDI child */
285 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* in the 2nd MDI child */
286 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
}, /* in the 2nd MDI child */
287 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
}, /* in the 2nd MDI child */
288 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* in the 2nd MDI child */
289 /* Redraw 2nd MDI child */
290 { WM_SETREDRAW
, sent
|wparam
|defwinproc
, 1 },/* in the 2nd MDI child */
291 /* Redraw MDI frame */
292 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
},/* in MDI frame */
293 { WM_NCCALCSIZE
, sent
|wparam
, 1 },/* in MDI frame */
294 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
}, /* in MDI frame */
295 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* in MDI frame */
296 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* in the 1st MDI child */
297 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
}, /* in the 1st MDI child */
298 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 }, /* in the 1st MDI child */
299 { HCBT_SETFOCUS
, hook
},
300 { WM_KILLFOCUS
, sent
|defwinproc
}, /* in the 2nd MDI child */
301 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 0 },/* in the 1st MDI child */
302 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
303 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
304 { WM_SETFOCUS
, sent
},/* in the MDI client */
305 { HCBT_SETFOCUS
, hook
},
306 { WM_KILLFOCUS
, sent
},/* in the MDI client */
307 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
308 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 }, /* in the 1st MDI child */
309 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
310 { WM_SETFOCUS
, sent
|defwinproc
}, /* in the 1st MDI child */
311 { WM_MDIACTIVATE
, sent
|defwinproc
},/* in the 1st MDI child */
312 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
}, /* in the 1st MDI child */
316 /* Switch visible not maximized mdi children */
317 static const struct message WmSwitchNotMaximizedChild
[] = {
318 /* Switch not maximized MDI child */
319 { WM_MDIACTIVATE
, sent
},/* in the MDI client */
320 { WM_WINDOWPOSCHANGING
, sent
|wparam
,SWP_NOSIZE
|SWP_NOMOVE
},/* in the 2nd MDI child */
321 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
322 { WM_CHILDACTIVATE
, sent
},/* in the 2nd MDI child */
323 /* Deactivate 1st MDI child */
324 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 0 }, /* in the 1st MDI child */
325 { WM_MDIACTIVATE
, sent
|defwinproc
}, /* in the 1st MDI child */
326 /* Activate 2nd MDI child */
327 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
}, /* in the 2nd MDI child */
328 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 }, /* in the 2nd MDI child */
329 { HCBT_SETFOCUS
, hook
}, /* in the 1st MDI child */
330 { WM_KILLFOCUS
, sent
|defwinproc
}, /* in the 1st MDI child */
331 { WM_IME_SETCONTEXT
, sent
|defwinproc
|optional
}, /* in the 1st MDI child */
332 { WM_IME_SETCONTEXT
, sent
|optional
}, /* in the MDI client */
333 { WM_SETFOCUS
, sent
, 0 }, /* in the MDI client */
334 { HCBT_SETFOCUS
, hook
},
335 { WM_KILLFOCUS
, sent
}, /* in the MDI client */
336 { WM_IME_SETCONTEXT
, sent
|optional
}, /* in the MDI client */
337 { WM_IME_SETCONTEXT
, sent
|defwinproc
|optional
}, /* in the 1st MDI child */
338 { WM_SETFOCUS
, sent
|defwinproc
}, /* in the 2nd MDI child */
339 { WM_MDIACTIVATE
, sent
|defwinproc
}, /* in the 2nd MDI child */
340 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
}, /* in the 2nd MDI child */
345 /* SetWindowPos(SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|
346 SWP_NOZORDER|SWP_FRAMECHANGED)
347 * for a visible overlapped window with WS_CLIPCHILDREN style set.
349 static const struct message WmSWP_FrameChanged_clip
[] = {
350 { WM_WINDOWPOSCHANGING
, sent
|wparam
|parent
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
},
351 { WM_NCCALCSIZE
, sent
|wparam
|parent
, 1 },
352 { WM_NCPAINT
, sent
|parent
}, /* wparam != 1 */
353 { WM_GETTEXT
, sent
|parent
|defwinproc
|optional
},
354 { WM_ERASEBKGND
, sent
|parent
|optional
}, /* FIXME: remove optional once Wine is fixed */
355 { WM_NCPAINT
, sent
}, /* wparam != 1 */
356 { WM_ERASEBKGND
, sent
},
357 { WM_WINDOWPOSCHANGED
, sent
|wparam
|parent
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
358 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
362 /* SetWindowPos(SWP_NOSIZE|SWP_NOMOVE|SWP_DEFERERASE|SWP_NOACTIVATE|
363 SWP_NOZORDER|SWP_FRAMECHANGED)
364 * for a visible overlapped window.
366 static const struct message WmSWP_FrameChangedDeferErase
[] = {
367 { WM_WINDOWPOSCHANGING
, sent
|wparam
|parent
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_DEFERERASE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
},
368 { WM_NCCALCSIZE
, sent
|wparam
|parent
, 1 },
369 { WM_WINDOWPOSCHANGED
, sent
|wparam
|parent
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_DEFERERASE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
370 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
371 { WM_PAINT
, sent
|parent
},
372 { WM_NCPAINT
, sent
|beginpaint
|parent
}, /* wparam != 1 */
373 { WM_GETTEXT
, sent
|beginpaint
|parent
|defwinproc
|optional
},
375 { WM_NCPAINT
, sent
|beginpaint
}, /* wparam != 1 */
376 { WM_ERASEBKGND
, sent
|beginpaint
},
380 /* SetWindowPos(SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|
381 SWP_NOZORDER|SWP_FRAMECHANGED)
382 * for a visible overlapped window without WS_CLIPCHILDREN style set.
384 static const struct message WmSWP_FrameChanged_noclip
[] = {
385 { WM_WINDOWPOSCHANGING
, sent
|wparam
|parent
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
},
386 { WM_NCCALCSIZE
, sent
|wparam
|parent
, 1 },
387 { WM_NCPAINT
, sent
|parent
}, /* wparam != 1 */
388 { WM_GETTEXT
, sent
|parent
|defwinproc
|optional
},
389 { WM_ERASEBKGND
, sent
|parent
|optional
}, /* FIXME: remove optional once Wine is fixed */
390 { WM_WINDOWPOSCHANGED
, sent
|wparam
|parent
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
391 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
393 { WM_NCPAINT
, sent
|beginpaint
}, /* wparam != 1 */
394 { WM_ERASEBKGND
, sent
|beginpaint
},
398 /* ShowWindow(SW_SHOW) for a not visible overlapped window */
399 static const struct message WmShowOverlappedSeq
[] = {
400 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
401 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
402 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
403 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
404 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
405 { WM_GETTEXT
, sent
|defwinproc
|optional
},
406 { WM_ERASEBKGND
, sent
|optional
},
407 { HCBT_ACTIVATE
, hook
},
408 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
409 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
410 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
411 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
412 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
413 { WM_NCACTIVATE
, sent
|wparam
, 1 },
414 { WM_GETTEXT
, sent
|defwinproc
|optional
},
415 { WM_ACTIVATE
, sent
|wparam
, 1 },
416 { HCBT_SETFOCUS
, hook
},
417 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
418 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
419 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
420 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
421 { WM_GETTEXT
, sent
|optional
},
422 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
423 { WM_GETTEXT
, sent
|defwinproc
|optional
},
424 { WM_ERASEBKGND
, sent
|optional
},
425 /* Win9x adds SWP_NOZORDER below */
426 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
427 { WM_NCCALCSIZE
, sent
|optional
},
428 { WM_GETTEXT
, sent
|optional
},
429 { WM_NCPAINT
, sent
|optional
},
430 { WM_ERASEBKGND
, sent
|optional
},
431 #if 0 /* CreateWindow/ShowWindow(SW_SHOW) also generates WM_SIZE/WM_MOVE
432 * messages. Does that mean that CreateWindow doesn't set initial
433 * window dimensions for overlapped windows?
438 { WM_PAINT
, sent
|optional
},
439 { WM_NCPAINT
, sent
|beginpaint
|optional
},
442 /* ShowWindow(SW_SHOWMAXIMIZED) for a not visible overlapped window */
443 static const struct message WmShowMaxOverlappedSeq
[] = {
444 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
445 { WM_GETMINMAXINFO
, sent
},
446 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_STATECHANGED
},
447 { WM_GETMINMAXINFO
, sent
|defwinproc
},
448 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
449 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
450 { HCBT_ACTIVATE
, hook
},
451 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
452 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
453 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
454 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
455 { WM_NCACTIVATE
, sent
|wparam
, 1 },
456 { WM_GETTEXT
, sent
|defwinproc
|optional
},
457 { WM_ACTIVATE
, sent
|wparam
, 1 },
458 { HCBT_SETFOCUS
, hook
},
459 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
460 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
461 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
462 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
463 { WM_GETTEXT
, sent
|optional
},
464 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
465 { WM_GETTEXT
, sent
|defwinproc
|optional
},
466 { WM_ERASEBKGND
, sent
|optional
},
467 /* Win9x adds SWP_NOZORDER below */
468 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_STATECHANGED
},
469 { WM_MOVE
, sent
|defwinproc
},
470 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
471 { WM_GETTEXT
, sent
|optional
},
472 { WM_NCCALCSIZE
, sent
|optional
},
473 { WM_NCPAINT
, sent
|optional
},
474 { WM_ERASEBKGND
, sent
|optional
},
475 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
476 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
477 { WM_PAINT
, sent
|optional
},
478 { WM_NCPAINT
, sent
|beginpaint
|optional
},
479 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
482 /* ShowWindow(SW_RESTORE) for a not visible maximized overlapped window */
483 static const struct message WmShowRestoreMaxOverlappedSeq
[] = {
484 { HCBT_MINMAX
, hook
|lparam
, 0, SW_RESTORE
},
485 { WM_GETTEXT
, sent
|optional
},
486 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
487 { WM_GETMINMAXINFO
, sent
|defwinproc
},
488 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
489 { WM_NCPAINT
, sent
|optional
},
490 { WM_GETTEXT
, sent
|defwinproc
|optional
},
491 { WM_ERASEBKGND
, sent
|optional
},
492 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
493 { WM_MOVE
, sent
|defwinproc
|optional
},
494 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
495 { WM_NCCALCSIZE
, sent
|wparam
|optional
, TRUE
},
496 { WM_NCPAINT
, sent
|optional
},
497 { WM_ERASEBKGND
, sent
|optional
},
498 { WM_PAINT
, sent
|optional
},
499 { WM_NCPAINT
, sent
|beginpaint
|optional
},
500 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
503 /* ShowWindow(SW_RESTORE) for a not visible minimized overlapped window */
504 static const struct message WmShowRestoreMinOverlappedSeq
[] = {
505 { HCBT_MINMAX
, hook
|lparam
, 0, SW_RESTORE
},
506 { WM_QUERYOPEN
, sent
|optional
},
507 { WM_GETTEXT
, sent
|optional
},
508 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
|SWP_NOCOPYBITS
},
509 { WM_GETMINMAXINFO
, sent
|defwinproc
},
510 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
511 { HCBT_ACTIVATE
, hook
},
512 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
513 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
514 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
515 { WM_NCACTIVATE
, sent
|wparam
, 1 },
516 { WM_GETTEXT
, sent
|defwinproc
|optional
},
517 { WM_ACTIVATE
, sent
|wparam
, 1 },
518 { HCBT_SETFOCUS
, hook
},
519 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
520 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
521 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
522 { WM_GETTEXT
, sent
|optional
},
523 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
524 { WM_GETTEXT
, sent
|defwinproc
|optional
},
525 { WM_ERASEBKGND
, sent
},
526 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_STATECHANGED
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
},
527 { WM_MOVE
, sent
|defwinproc
},
528 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
529 { WM_NCCALCSIZE
, sent
|wparam
|optional
, TRUE
},
530 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
531 { WM_ERASEBKGND
, sent
|optional
},
532 { WM_ACTIVATE
, sent
|wparam
, 1 },
533 { WM_GETTEXT
, sent
|optional
},
534 { WM_PAINT
, sent
|optional
},
535 { WM_NCPAINT
, sent
|beginpaint
|optional
},
536 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
539 /* ShowWindow(SW_SHOWMINIMIZED) for a not visible overlapped window */
540 static const struct message WmShowMinOverlappedSeq
[] = {
541 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
542 { HCBT_SETFOCUS
, hook
},
543 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
544 { WM_KILLFOCUS
, sent
},
545 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
546 { WM_IME_NOTIFY
, sent
|wparam
|optional
|defwinproc
, 1 },
547 { WM_GETTEXT
, sent
|optional
},
548 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOCOPYBITS
|SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_STATECHANGED
},
549 { WM_GETMINMAXINFO
, sent
|defwinproc
},
550 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
551 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
552 { WM_NCPAINT
, sent
|optional
},
553 { WM_GETTEXT
, sent
|defwinproc
|optional
},
554 { WM_WINDOWPOSCHANGED
, sent
},
555 { WM_MOVE
, sent
|defwinproc
},
556 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MINIMIZED
},
557 { WM_NCCALCSIZE
, sent
|optional
},
558 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
559 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
560 { EVENT_SYSTEM_MINIMIZESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
561 { WM_NCACTIVATE
, sent
|wparam
, 0 },
562 { WM_GETTEXT
, sent
|defwinproc
|optional
},
563 { WM_ACTIVATE
, sent
},
564 { WM_ACTIVATEAPP
, sent
|wparam
, 0 },
565 { WM_PAINT
, sent
|optional
},
566 { WM_NCPAINT
, sent
|beginpaint
|optional
},
567 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
570 /* ShowWindow(SW_HIDE) for a visible overlapped window */
571 static const struct message WmHideOverlappedSeq
[] = {
572 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
573 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
574 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
575 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
576 { WM_SIZE
, sent
|optional
}, /* XP doesn't send it */
577 { WM_MOVE
, sent
|optional
}, /* XP doesn't send it */
578 { WM_NCACTIVATE
, sent
|wparam
, 0 },
579 { WM_ACTIVATE
, sent
|wparam
, 0 },
580 { WM_ACTIVATEAPP
, sent
|wparam
, 0 },
581 { WM_KILLFOCUS
, sent
|wparam
, 0 },
582 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
583 { WM_IME_NOTIFY
, sent
|wparam
|optional
|defwinproc
, 1 },
586 /* DestroyWindow for a visible overlapped window */
587 static const struct message WmDestroyOverlappedSeq
[] = {
588 { HCBT_DESTROYWND
, hook
},
589 { 0x0090, sent
|optional
},
590 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
591 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
592 { 0x0090, sent
|optional
},
593 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
594 { WM_NCACTIVATE
, sent
|optional
|wparam
, 0 },
595 { WM_ACTIVATE
, sent
|optional
|wparam
, 0 },
596 { WM_ACTIVATEAPP
, sent
|optional
|wparam
, 0 },
597 { WM_KILLFOCUS
, sent
|optional
|wparam
, 0 },
598 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
599 { WM_IME_NOTIFY
, sent
|wparam
|optional
|defwinproc
, 1 },
600 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
601 { WM_DESTROY
, sent
},
602 { WM_NCDESTROY
, sent
},
605 /* CreateWindow(WS_MAXIMIZE|WS_VISIBLE) for popup window */
606 static const struct message WmCreateMaxPopupSeq
[] = {
607 { HCBT_CREATEWND
, hook
},
608 { WM_NCCREATE
, sent
},
609 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
611 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
612 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
614 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
615 { WM_GETMINMAXINFO
, sent
},
616 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_STATECHANGED
},
617 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
618 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOREDRAW
|SWP_STATECHANGED
},
619 { WM_MOVE
, sent
|defwinproc
},
620 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
621 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
622 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
623 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
624 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
625 { HCBT_ACTIVATE
, hook
},
626 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
627 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
628 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
629 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
630 { WM_NCACTIVATE
, sent
|wparam
, 1 },
631 { WM_ACTIVATE
, sent
|wparam
, 1 },
632 { HCBT_SETFOCUS
, hook
},
633 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
634 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
635 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
636 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
637 { WM_GETTEXT
, sent
|optional
},
638 { WM_SYNCPAINT
, sent
|wparam
|optional
, 4 },
639 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
640 { WM_ERASEBKGND
, sent
|optional
},
641 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOCLIENTMOVE
|SWP_NOCLIENTSIZE
|SWP_SHOWWINDOW
|SWP_NOMOVE
|SWP_NOSIZE
},
644 /* CreateWindow(WS_MAXIMIZE) for popup window, not initially visible */
645 static const struct message WmCreateInvisibleMaxPopupSeq
[] = {
646 { HCBT_CREATEWND
, hook
},
647 { WM_NCCREATE
, sent
},
648 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
650 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
651 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
653 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
654 { WM_GETMINMAXINFO
, sent
},
655 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_STATECHANGED
},
656 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
657 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOREDRAW
|SWP_STATECHANGED
},
658 { WM_MOVE
, sent
|defwinproc
},
659 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
660 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
663 /* ShowWindow(SW_SHOWMAXIMIZED) for a resized not visible popup window */
664 static const struct message WmShowMaxPopupResizedSeq
[] = {
665 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
666 { WM_GETMINMAXINFO
, sent
},
667 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
},
668 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
669 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
670 { HCBT_ACTIVATE
, hook
},
671 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
672 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
673 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
674 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
675 { WM_NCACTIVATE
, sent
|wparam
, 1 },
676 { WM_ACTIVATE
, sent
|wparam
, 1 },
677 { HCBT_SETFOCUS
, hook
},
678 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
679 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
680 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
681 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
682 { WM_GETTEXT
, sent
|optional
},
683 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
684 { WM_ERASEBKGND
, sent
|optional
},
685 { WM_WINDOWPOSCHANGED
, sent
},
686 /* WinNT4.0 sends WM_MOVE */
687 { WM_MOVE
, sent
|defwinproc
|optional
},
688 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
689 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
692 /* ShowWindow(SW_SHOWMAXIMIZED) for a not visible popup window */
693 static const struct message WmShowMaxPopupSeq
[] = {
694 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
695 { WM_GETMINMAXINFO
, sent
},
696 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
},
697 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
698 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
699 { HCBT_ACTIVATE
, hook
},
700 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
701 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
702 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
703 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
704 { WM_NCACTIVATE
, sent
|wparam
, 1 },
705 { WM_ACTIVATE
, sent
|wparam
, 1 },
706 { HCBT_SETFOCUS
, hook
},
707 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
708 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
709 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
710 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
711 { WM_GETTEXT
, sent
|optional
},
712 { WM_SYNCPAINT
, sent
|wparam
|optional
, 4 },
713 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
714 { WM_ERASEBKGND
, sent
|optional
},
715 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOMOVE
|SWP_NOSIZE
},
716 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
719 /* CreateWindow(WS_VISIBLE) for popup window */
720 static const struct message WmCreatePopupSeq
[] = {
721 { HCBT_CREATEWND
, hook
},
722 { WM_NCCREATE
, sent
},
723 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
725 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
726 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
728 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
729 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
730 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
731 { HCBT_ACTIVATE
, hook
},
732 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
733 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
734 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
735 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
736 { WM_ERASEBKGND
, sent
|optional
},
737 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
738 { WM_NCACTIVATE
, sent
|wparam
, 1 },
739 { WM_ACTIVATE
, sent
|wparam
, 1 },
740 { HCBT_SETFOCUS
, hook
},
741 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
742 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
743 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
744 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
745 { WM_GETTEXT
, sent
|optional
},
746 { WM_SYNCPAINT
, sent
|wparam
|optional
, 4 },
747 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
748 { WM_ERASEBKGND
, sent
|optional
},
749 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOCLIENTMOVE
|SWP_NOCLIENTSIZE
|SWP_SHOWWINDOW
|SWP_NOMOVE
|SWP_NOSIZE
},
752 /* ShowWindow(SW_SHOWMAXIMIZED) for a visible popup window */
753 static const struct message WmShowVisMaxPopupSeq
[] = {
754 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
755 { WM_GETMINMAXINFO
, sent
},
756 { WM_GETTEXT
, sent
|optional
},
757 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
758 { WM_GETTEXT
, sent
|optional
},
759 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
760 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
761 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
762 { WM_ERASEBKGND
, sent
|optional
},
763 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
764 { WM_MOVE
, sent
|defwinproc
},
765 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
766 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
769 /* CreateWindow (for a child popup window, not initially visible) */
770 static const struct message WmCreateChildPopupSeq
[] = {
771 { HCBT_CREATEWND
, hook
},
772 { WM_NCCREATE
, sent
},
773 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
775 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
776 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
780 /* CreateWindow (for a popup window, not initially visible,
781 * which sets WS_VISIBLE in WM_CREATE handler)
783 static const struct message WmCreateInvisiblePopupSeq
[] = {
784 { HCBT_CREATEWND
, hook
},
785 { WM_NCCREATE
, sent
},
786 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
788 { WM_STYLECHANGING
, sent
},
789 { WM_STYLECHANGED
, sent
},
790 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
791 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
795 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER)
796 * for a popup window with WS_VISIBLE style set
798 static const struct message WmShowVisiblePopupSeq_2
[] = {
799 { WM_WINDOWPOSCHANGING
, sent
|wparam
, 0 },
802 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
803 * for a popup window with WS_VISIBLE style set
805 static const struct message WmShowVisiblePopupSeq_3
[] = {
806 { WM_WINDOWPOSCHANGING
, sent
|wparam
, 0 },
807 { HCBT_ACTIVATE
, hook
},
808 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
809 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
810 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, 0 },
811 { WM_NCACTIVATE
, sent
|wparam
, 1 },
812 { WM_ACTIVATE
, sent
|wparam
, 1 },
813 { HCBT_SETFOCUS
, hook
},
814 { WM_KILLFOCUS
, sent
|parent
},
815 { WM_IME_SETCONTEXT
, sent
|parent
|wparam
|optional
, 0 },
816 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
817 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
818 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
819 { WM_SETFOCUS
, sent
|defwinproc
},
820 { WM_GETTEXT
, sent
|optional
},
823 /* CreateWindow (for child window, not initially visible) */
824 static const struct message WmCreateChildSeq
[] = {
825 { HCBT_CREATEWND
, hook
},
826 { WM_NCCREATE
, sent
},
827 /* child is inserted into parent's child list after WM_NCCREATE returns */
828 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
830 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
831 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
833 { WM_PARENTNOTIFY
, sent
|parent
|wparam
, WM_CREATE
},
836 /* CreateWindow (for maximized child window, not initially visible) */
837 static const struct message WmCreateMaximizedChildSeq
[] = {
838 { HCBT_CREATEWND
, hook
},
839 { WM_NCCREATE
, sent
},
840 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
842 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
843 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
845 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
846 { WM_GETMINMAXINFO
, sent
},
847 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_STATECHANGED
},
848 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
849 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
850 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
851 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
852 { WM_PARENTNOTIFY
, sent
|parent
|wparam
, WM_CREATE
},
855 /* CreateWindow (for a child window, initially visible) */
856 static const struct message WmCreateVisibleChildSeq
[] = {
857 { HCBT_CREATEWND
, hook
},
858 { WM_NCCREATE
, sent
},
859 /* child is inserted into parent's child list after WM_NCCREATE returns */
860 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
861 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
863 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
864 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
866 { WM_PARENTNOTIFY
, sent
|parent
|wparam
, WM_CREATE
},
867 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
868 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
869 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
870 { WM_ERASEBKGND
, sent
|parent
|optional
},
871 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
872 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 }, /* WinXP */
873 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
876 /* ShowWindow(SW_SHOW) for a not visible child window */
877 static const struct message WmShowChildSeq
[] = {
878 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
879 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
880 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
881 { WM_ERASEBKGND
, sent
|parent
|optional
},
882 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
885 /* ShowWindow(SW_HIDE) for a visible child window */
886 static const struct message WmHideChildSeq
[] = {
887 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
888 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
889 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
890 { WM_ERASEBKGND
, sent
|parent
|optional
},
891 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
894 /* ShowWindow(SW_HIDE) for a visible child window checking all parent events*/
895 static const struct message WmHideChildSeq2
[] = {
896 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
897 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
898 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
899 { WM_ERASEBKGND
, sent
|parent
},
900 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
903 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
904 * for a not visible child window
906 static const struct message WmShowChildSeq_2
[] = {
907 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
908 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
909 { WM_CHILDACTIVATE
, sent
},
910 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
913 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE)
914 * for a not visible child window
916 static const struct message WmShowChildSeq_3
[] = {
917 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
918 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
919 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
922 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
923 * for a visible child window with a caption
925 static const struct message WmShowChildSeq_4
[] = {
926 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
927 { WM_CHILDACTIVATE
, sent
},
930 /* ShowWindow(SW_MINIMIZE) for child with invisible parent */
931 static const struct message WmShowChildInvisibleParentSeq_1
[] = {
932 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
933 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
934 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
935 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
936 { WM_CHILDACTIVATE
, sent
|optional
},
937 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOREDRAW
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
938 { WM_MOVE
, sent
|defwinproc
},
939 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MINIMIZED
},
940 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
941 { EVENT_SYSTEM_MINIMIZESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
942 /* FIXME: Wine creates an icon/title window while Windows doesn't */
943 { WM_PARENTNOTIFY
, sent
|parent
|wparam
|optional
, WM_CREATE
},
944 { WM_GETTEXT
, sent
|optional
},
947 /* repeated ShowWindow(SW_MINIMIZE) for child with invisible parent */
948 static const struct message WmShowChildInvisibleParentSeq_1r
[] = {
949 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
952 /* ShowWindow(SW_MAXIMIZE) for child with invisible parent */
953 static const struct message WmShowChildInvisibleParentSeq_2
[] = {
954 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
955 { WM_GETMINMAXINFO
, sent
},
956 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_STATECHANGED
},
957 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
958 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
959 { WM_CHILDACTIVATE
, sent
},
960 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
961 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
962 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
965 /* repeated ShowWindow(SW_MAXIMIZE) for child with invisible parent */
966 static const struct message WmShowChildInvisibleParentSeq_2r
[] = {
967 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
970 /* ShowWindow(SW_SHOWMINIMIZED) for child with invisible parent */
971 static const struct message WmShowChildInvisibleParentSeq_3
[] = {
972 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINIMIZED
},
973 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
974 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
975 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
976 { WM_CHILDACTIVATE
, sent
},
977 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOREDRAW
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
978 { WM_MOVE
, sent
|defwinproc
},
979 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MINIMIZED
},
980 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
981 { EVENT_SYSTEM_MINIMIZESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
982 /* FIXME: Wine creates an icon/title window while Windows doesn't */
983 { WM_PARENTNOTIFY
, sent
|parent
|wparam
|optional
, WM_CREATE
},
984 { WM_GETTEXT
, sent
|optional
},
987 /* repeated ShowWindow(SW_SHOWMINIMIZED) for child with invisible parent */
988 static const struct message WmShowChildInvisibleParentSeq_3r
[] = {
989 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINIMIZED
},
992 /* ShowWindow(SW_SHOWMINNOACTIVE) for child with invisible parent */
993 static const struct message WmShowChildInvisibleParentSeq_4
[] = {
994 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINNOACTIVE
},
995 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
996 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
997 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
998 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOREDRAW
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
999 { WM_MOVE
, sent
|defwinproc
},
1000 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MINIMIZED
},
1001 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1002 { EVENT_SYSTEM_MINIMIZESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
1003 /* FIXME: Wine creates an icon/title window while Windows doesn't */
1004 { WM_PARENTNOTIFY
, sent
|parent
|wparam
|optional
, WM_CREATE
},
1005 { WM_GETTEXT
, sent
|optional
},
1008 /* repeated ShowWindow(SW_SHOWMINNOACTIVE) for child with invisible parent */
1009 static const struct message WmShowChildInvisibleParentSeq_4r
[] = {
1010 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINNOACTIVE
},
1013 /* ShowWindow(SW_SHOW) for child with invisible parent */
1014 static const struct message WmShowChildInvisibleParentSeq_5
[] = {
1015 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1018 /* ShowWindow(SW_HIDE) for child with invisible parent */
1019 static const struct message WmHideChildInvisibleParentSeq
[] = {
1020 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
1023 /* SetWindowPos(SWP_SHOWWINDOW) for child with invisible parent */
1024 static const struct message WmShowChildInvisibleParentSeq_6
[] = {
1025 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
1026 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1027 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1030 /* SetWindowPos(SWP_HIDEWINDOW) for child with invisible parent */
1031 static const struct message WmHideChildInvisibleParentSeq_2
[] = {
1032 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1033 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1034 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1037 /* DestroyWindow for a visible child window */
1038 static const struct message WmDestroyChildSeq
[] = {
1039 { HCBT_DESTROYWND
, hook
},
1040 { 0x0090, sent
|optional
},
1041 { WM_PARENTNOTIFY
, sent
|parent
|wparam
, WM_DESTROY
},
1042 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
1043 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1044 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1045 { WM_ERASEBKGND
, sent
|parent
|optional
},
1046 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1047 { HCBT_SETFOCUS
, hook
}, /* set focus to a parent */
1048 { WM_KILLFOCUS
, sent
},
1049 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
1050 { WM_IME_SETCONTEXT
, sent
|wparam
|parent
|optional
, 1 },
1051 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1052 { WM_SETFOCUS
, sent
|parent
},
1053 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
1054 { WM_DESTROY
, sent
},
1055 { WM_DESTROY
, sent
|optional
}, /* some other (IME?) window */
1056 { WM_NCDESTROY
, sent
|optional
}, /* some other (IME?) window */
1057 { WM_NCDESTROY
, sent
},
1060 /* DestroyWindow for a visible child window with invisible parent */
1061 static const struct message WmDestroyInvisibleChildSeq
[] = {
1062 { HCBT_DESTROYWND
, hook
},
1063 { 0x0090, sent
|optional
},
1064 { WM_PARENTNOTIFY
, sent
|parent
|wparam
, WM_DESTROY
},
1065 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
1066 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
1067 { WM_DESTROY
, sent
},
1068 { WM_NCDESTROY
, sent
},
1071 /* Moving the mouse in nonclient area */
1072 static const struct message WmMouseMoveInNonClientAreaSeq
[] = { /* FIXME: add */
1073 { WM_NCHITTEST
, sent
},
1074 { WM_SETCURSOR
, sent
},
1075 { WM_NCMOUSEMOVE
, posted
},
1078 /* Moving the mouse in client area */
1079 static const struct message WmMouseMoveInClientAreaSeq
[] = { /* FIXME: add */
1080 { WM_NCHITTEST
, sent
},
1081 { WM_SETCURSOR
, sent
},
1082 { WM_MOUSEMOVE
, posted
},
1085 /* Moving by dragging the title bar (after WM_NCHITTEST and WM_SETCURSOR) (outline move) */
1086 static const struct message WmDragTitleBarSeq
[] = { /* FIXME: add */
1087 { WM_NCLBUTTONDOWN
, sent
|wparam
, HTCAPTION
},
1088 { WM_SYSCOMMAND
, sent
|defwinproc
|wparam
, SC_MOVE
+2 },
1089 { WM_GETMINMAXINFO
, sent
|defwinproc
},
1090 { WM_ENTERSIZEMOVE
, sent
|defwinproc
},
1091 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, 0 },
1092 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, 0 },
1093 { WM_MOVE
, sent
|defwinproc
},
1094 { WM_EXITSIZEMOVE
, sent
|defwinproc
},
1097 /* Sizing by dragging the thick borders (after WM_NCHITTEST and WM_SETCURSOR) (outline move) */
1098 static const struct message WmDragThickBordersBarSeq
[] = { /* FIXME: add */
1099 { WM_NCLBUTTONDOWN
, sent
|wparam
, 0xd },
1100 { WM_SYSCOMMAND
, sent
|defwinproc
|wparam
, 0xf004 },
1101 { WM_GETMINMAXINFO
, sent
|defwinproc
},
1102 { WM_ENTERSIZEMOVE
, sent
|defwinproc
},
1103 { WM_SIZING
, sent
|defwinproc
|wparam
, 4}, /* one for each mouse movement */
1104 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, 0 },
1105 { WM_GETMINMAXINFO
, sent
|defwinproc
},
1106 { WM_NCCALCSIZE
, sent
|defwinproc
|wparam
, 1 },
1107 { WM_NCPAINT
, sent
|defwinproc
|wparam
, 1 },
1108 { WM_GETTEXT
, sent
|defwinproc
},
1109 { WM_ERASEBKGND
, sent
|defwinproc
},
1110 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, 0 },
1111 { WM_MOVE
, sent
|defwinproc
},
1112 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
1113 { WM_EXITSIZEMOVE
, sent
|defwinproc
},
1116 /* Resizing child window with MoveWindow (32) */
1117 static const struct message WmResizingChildWithMoveWindowSeq
[] = {
1118 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
1119 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1120 { WM_ERASEBKGND
, sent
|parent
|optional
},
1121 { WM_ERASEBKGND
, sent
|optional
},
1122 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
},
1123 { WM_MOVE
, sent
|defwinproc
},
1124 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
1125 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1128 /* Clicking on inactive button */
1129 static const struct message WmClickInactiveButtonSeq
[] = { /* FIXME: add */
1130 { WM_NCHITTEST
, sent
},
1131 { WM_PARENTNOTIFY
, sent
|parent
|wparam
, WM_LBUTTONDOWN
},
1132 { WM_MOUSEACTIVATE
, sent
},
1133 { WM_MOUSEACTIVATE
, sent
|parent
|defwinproc
},
1134 { WM_SETCURSOR
, sent
},
1135 { WM_SETCURSOR
, sent
|parent
|defwinproc
},
1136 { WM_LBUTTONDOWN
, posted
},
1137 { WM_KILLFOCUS
, posted
|parent
},
1138 { WM_SETFOCUS
, posted
},
1139 { WM_CTLCOLORBTN
, posted
|parent
},
1140 { BM_SETSTATE
, posted
},
1141 { WM_CTLCOLORBTN
, posted
|parent
},
1142 { WM_LBUTTONUP
, posted
},
1143 { BM_SETSTATE
, posted
},
1144 { WM_CTLCOLORBTN
, posted
|parent
},
1145 { WM_COMMAND
, posted
|parent
},
1148 /* Reparenting a button (16/32) */
1149 /* The last child (button) reparented gets topmost for its new parent. */
1150 static const struct message WmReparentButtonSeq
[] = { /* FIXME: add */
1151 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
1152 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOSIZE
},
1153 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1154 { WM_ERASEBKGND
, sent
|parent
},
1155 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOSIZE
},
1156 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
},
1157 { WM_CHILDACTIVATE
, sent
},
1158 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOSIZE
|SWP_NOREDRAW
},
1159 { WM_MOVE
, sent
|defwinproc
},
1160 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1163 /* Creation of a custom dialog (32) */
1164 static const struct message WmCreateCustomDialogSeq
[] = {
1165 { HCBT_CREATEWND
, hook
},
1166 { WM_GETMINMAXINFO
, sent
},
1167 { WM_NCCREATE
, sent
},
1168 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
1169 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
1170 { WM_CREATE
, sent
},
1171 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1172 { WM_NOTIFYFORMAT
, sent
|optional
},
1173 { WM_QUERYUISTATE
, sent
|optional
},
1174 { WM_WINDOWPOSCHANGING
, sent
|optional
},
1175 { WM_GETMINMAXINFO
, sent
|optional
},
1176 { WM_NCCALCSIZE
, sent
|optional
},
1177 { WM_WINDOWPOSCHANGED
, sent
|optional
},
1178 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1179 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
1180 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1181 { HCBT_ACTIVATE
, hook
},
1182 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
1185 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
1187 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
1189 { WM_NCACTIVATE
, sent
|wparam
, 1 },
1190 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1191 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1192 { EVENT_OBJECT_DEFACTIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, OBJID_CLIENT
, 0 },
1193 { WM_ACTIVATE
, sent
|wparam
, 1 },
1194 { WM_GETTEXT
, sent
|optional
},
1195 { WM_KILLFOCUS
, sent
|parent
},
1196 { WM_IME_SETCONTEXT
, sent
|parent
|wparam
|optional
, 0 },
1197 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
1198 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
1199 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1200 { WM_SETFOCUS
, sent
},
1201 { WM_GETDLGCODE
, sent
|defwinproc
|wparam
, 0 },
1202 { WM_NCPAINT
, sent
|wparam
, 1 },
1203 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1204 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1205 { WM_ERASEBKGND
, sent
},
1206 { WM_CTLCOLORDLG
, sent
|defwinproc
},
1207 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1208 { WM_GETTEXT
, sent
|optional
},
1209 { WM_GETTEXT
, sent
|optional
},
1210 { WM_NCCALCSIZE
, sent
|optional
},
1211 { WM_NCPAINT
, sent
|optional
},
1212 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1213 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1214 { WM_ERASEBKGND
, sent
|optional
},
1215 { WM_CTLCOLORDLG
, sent
|optional
|defwinproc
},
1216 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1217 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
1221 /* Calling EndDialog for a custom dialog (32) */
1222 static const struct message WmEndCustomDialogSeq
[] = {
1223 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1224 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1225 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1226 { WM_GETTEXT
, sent
|optional
},
1227 { HCBT_ACTIVATE
, hook
},
1228 { WM_NCACTIVATE
, sent
|wparam
, 0 },
1229 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1230 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1231 { WM_ACTIVATE
, sent
|wparam
, 0 },
1232 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
1233 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1234 { HCBT_SETFOCUS
, hook
},
1235 { WM_KILLFOCUS
, sent
},
1236 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
1237 { WM_IME_SETCONTEXT
, sent
|parent
|wparam
|defwinproc
|optional
, 1 },
1238 { WM_IME_NOTIFY
, sent
|wparam
|optional
, 1 },
1239 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1240 { WM_SETFOCUS
, sent
|parent
|defwinproc
},
1243 /* ShowWindow(SW_SHOW) for a custom dialog (initially invisible) */
1244 static const struct message WmShowCustomDialogSeq
[] = {
1245 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1246 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
1247 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1248 { HCBT_ACTIVATE
, hook
},
1249 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
1251 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
1253 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
1254 { WM_ACTIVATEAPP
, sent
|wparam
|optional
, 1 },
1255 { WM_NCACTIVATE
, sent
|wparam
, 1 },
1256 { WM_ACTIVATE
, sent
|wparam
, 1 },
1257 { WM_GETTEXT
, sent
|optional
},
1259 { WM_KILLFOCUS
, sent
|parent
},
1260 { WM_IME_SETCONTEXT
, sent
|parent
|wparam
|optional
, 0 },
1261 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
1262 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
1263 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1264 { WM_SETFOCUS
, sent
},
1265 { WM_GETDLGCODE
, sent
|defwinproc
|wparam
, 0 },
1266 { WM_NCPAINT
, sent
|wparam
, 1 },
1267 { WM_ERASEBKGND
, sent
},
1268 { WM_CTLCOLORDLG
, sent
|defwinproc
},
1269 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1272 /* Creation and destruction of a modal dialog (32) */
1273 static const struct message WmModalDialogSeq
[] = {
1274 { WM_CANCELMODE
, sent
|parent
},
1275 { HCBT_SETFOCUS
, hook
},
1276 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1277 { WM_KILLFOCUS
, sent
|parent
},
1278 { WM_IME_SETCONTEXT
, sent
|parent
|wparam
|optional
, 0 },
1279 { EVENT_OBJECT_STATECHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1280 { WM_ENABLE
, sent
|parent
|wparam
, 0 },
1281 { HCBT_CREATEWND
, hook
},
1282 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
1283 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1284 { WM_SETFONT
, sent
},
1285 { WM_INITDIALOG
, sent
},
1286 { WM_CHANGEUISTATE
, sent
|optional
},
1287 { WM_UPDATEUISTATE
, sent
|optional
},
1288 { WM_SHOWWINDOW
, sent
},
1289 { HCBT_ACTIVATE
, hook
},
1290 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
1291 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
1292 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
},
1293 { WM_NCACTIVATE
, sent
|wparam
, 1 },
1294 { WM_GETTEXT
, sent
|optional
},
1295 { WM_ACTIVATE
, sent
|wparam
, 1 },
1296 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
1297 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1298 { WM_NCPAINT
, sent
},
1299 { WM_GETTEXT
, sent
|optional
},
1300 { WM_ERASEBKGND
, sent
},
1301 { WM_CTLCOLORDLG
, sent
},
1302 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1303 { WM_GETTEXT
, sent
|optional
},
1304 { WM_NCCALCSIZE
, sent
|optional
},
1305 { WM_NCPAINT
, sent
|optional
},
1306 { WM_GETTEXT
, sent
|optional
},
1307 { WM_ERASEBKGND
, sent
|optional
},
1308 { WM_CTLCOLORDLG
, sent
|optional
},
1309 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1310 { WM_PAINT
, sent
|optional
},
1311 { WM_CTLCOLORBTN
, sent
},
1312 { WM_ENTERIDLE
, sent
|parent
|optional
},
1313 { WM_ENTERIDLE
, sent
|parent
|optional
},
1314 { WM_ENTERIDLE
, sent
|parent
|optional
},
1315 { WM_ENTERIDLE
, sent
|parent
|optional
},
1316 { WM_ENTERIDLE
, sent
|parent
|optional
},
1317 { WM_ENTERIDLE
, sent
|parent
|optional
},
1318 { WM_ENTERIDLE
, sent
|parent
|optional
},
1319 { WM_ENTERIDLE
, sent
|parent
|optional
},
1320 { WM_ENTERIDLE
, sent
|parent
|optional
},
1321 { WM_ENTERIDLE
, sent
|parent
|optional
},
1322 { WM_ENTERIDLE
, sent
|parent
|optional
},
1323 { WM_ENTERIDLE
, sent
|parent
|optional
},
1324 { WM_ENTERIDLE
, sent
|parent
|optional
},
1325 { WM_ENTERIDLE
, sent
|parent
|optional
},
1326 { WM_ENTERIDLE
, sent
|parent
|optional
},
1327 { WM_ENTERIDLE
, sent
|parent
|optional
},
1328 { WM_ENTERIDLE
, sent
|parent
|optional
},
1329 { WM_ENTERIDLE
, sent
|parent
|optional
},
1330 { WM_ENTERIDLE
, sent
|parent
|optional
},
1331 { WM_ENTERIDLE
, sent
|parent
|optional
},
1333 { EVENT_OBJECT_STATECHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1334 { WM_ENABLE
, sent
|parent
|wparam
, 1 },
1335 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
1336 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1337 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1338 { WM_GETTEXT
, sent
|optional
},
1339 { HCBT_ACTIVATE
, hook
},
1340 { WM_NCACTIVATE
, sent
|wparam
, 0 },
1341 { WM_GETTEXT
, sent
|optional
},
1342 { WM_ACTIVATE
, sent
|wparam
, 0 },
1343 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
1344 { WM_WINDOWPOSCHANGING
, sent
|optional
},
1345 { WM_WINDOWPOSCHANGED
, sent
|optional
},
1346 { HCBT_SETFOCUS
, hook
},
1347 { WM_IME_SETCONTEXT
, sent
|parent
|wparam
|defwinproc
|optional
, 1 },
1348 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1349 { WM_SETFOCUS
, sent
|parent
|defwinproc
},
1350 { EVENT_SYSTEM_DIALOGEND
, winevent_hook
|wparam
|lparam
, 0, 0 },
1351 { HCBT_DESTROYWND
, hook
},
1352 { 0x0090, sent
|optional
},
1353 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
1354 { WM_DESTROY
, sent
},
1355 { WM_NCDESTROY
, sent
},
1358 /* Creation of a modal dialog that is resized inside WM_INITDIALOG (32) */
1359 static const struct message WmCreateModalDialogResizeSeq
[] = { /* FIXME: add */
1360 /* (inside dialog proc, handling WM_INITDIALOG) */
1361 { WM_WINDOWPOSCHANGING
, sent
|wparam
, 0 },
1362 { WM_NCCALCSIZE
, sent
},
1363 { WM_NCACTIVATE
, sent
|parent
|wparam
, 0 },
1364 { WM_GETTEXT
, sent
|defwinproc
},
1365 { WM_ACTIVATE
, sent
|parent
|wparam
, 0 },
1366 { WM_WINDOWPOSCHANGING
, sent
|wparam
, 0 },
1367 { WM_WINDOWPOSCHANGING
, sent
|parent
},
1368 { WM_NCACTIVATE
, sent
|wparam
, 1 },
1369 { WM_ACTIVATE
, sent
|wparam
, 1 },
1370 { WM_WINDOWPOSCHANGED
, sent
|wparam
, 0 },
1371 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
1372 /* (setting focus) */
1373 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1374 { WM_WINDOWPOSCHANGING
, sent
|wparam
, 0 },
1375 { WM_NCPAINT
, sent
},
1376 { WM_GETTEXT
, sent
|defwinproc
},
1377 { WM_ERASEBKGND
, sent
},
1378 { WM_CTLCOLORDLG
, sent
|defwinproc
},
1379 { WM_WINDOWPOSCHANGED
, sent
|wparam
, 0 },
1381 /* (bunch of WM_CTLCOLOR* for each control) */
1382 { WM_PAINT
, sent
|parent
},
1383 { WM_ENTERIDLE
, sent
|parent
|wparam
, 0 },
1384 { WM_SETCURSOR
, sent
|parent
},
1387 /* SetMenu for NonVisible windows with size change*/
1388 static const struct message WmSetMenuNonVisibleSizeChangeSeq
[] = {
1389 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1390 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1391 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
1392 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
},
1393 { WM_MOVE
, sent
|defwinproc
},
1394 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
1395 { WM_NCCALCSIZE
,sent
|wparam
|optional
, 1 }, /* XP */
1396 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1397 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* XP sends a duplicate */
1398 { WM_GETTEXT
, sent
|optional
},
1399 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
1402 /* SetMenu for NonVisible windows with no size change */
1403 static const struct message WmSetMenuNonVisibleNoSizeChangeSeq
[] = {
1404 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1405 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1406 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1407 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1410 /* SetMenu for Visible windows with size change */
1411 static const struct message WmSetMenuVisibleSizeChangeSeq
[] = {
1412 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1413 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1414 { 0x0093, sent
|defwinproc
|optional
},
1415 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
1416 { WM_NCPAINT
, sent
}, /* wparam != 1 */
1417 { 0x0093, sent
|defwinproc
|optional
},
1418 { 0x0093, sent
|defwinproc
|optional
},
1419 { 0x0091, sent
|defwinproc
|optional
},
1420 { 0x0092, sent
|defwinproc
|optional
},
1421 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1422 { WM_ERASEBKGND
, sent
|optional
},
1423 { WM_ACTIVATE
, sent
|optional
},
1424 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1425 { WM_MOVE
, sent
|defwinproc
},
1426 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
1427 { 0x0093, sent
|optional
},
1428 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
1429 { 0x0093, sent
|defwinproc
|optional
},
1430 { WM_NCPAINT
, sent
|optional
}, /* wparam != 1 */
1431 { 0x0093, sent
|defwinproc
|optional
},
1432 { 0x0093, sent
|defwinproc
|optional
},
1433 { 0x0091, sent
|defwinproc
|optional
},
1434 { 0x0092, sent
|defwinproc
|optional
},
1435 { WM_ERASEBKGND
, sent
|optional
},
1436 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1437 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* XP sends a duplicate */
1440 /* SetMenu for Visible windows with no size change */
1441 static const struct message WmSetMenuVisibleNoSizeChangeSeq
[] = {
1442 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1443 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1444 { WM_NCPAINT
, sent
}, /* wparam != 1 */
1445 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1446 { WM_ERASEBKGND
, sent
|optional
},
1447 { WM_ACTIVATE
, sent
|optional
},
1448 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1449 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1452 /* DrawMenuBar for a visible window */
1453 static const struct message WmDrawMenuBarSeq
[] =
1455 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1456 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1457 { 0x0093, sent
|defwinproc
|optional
},
1458 { WM_NCPAINT
, sent
}, /* wparam != 1 */
1459 { 0x0093, sent
|defwinproc
|optional
},
1460 { 0x0093, sent
|defwinproc
|optional
},
1461 { 0x0091, sent
|defwinproc
|optional
},
1462 { 0x0092, sent
|defwinproc
|optional
},
1463 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1464 { WM_ERASEBKGND
, sent
|optional
},
1465 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1466 { 0x0093, sent
|optional
},
1467 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1471 static const struct message WmSetRedrawFalseSeq
[] =
1473 { WM_SETREDRAW
, sent
|wparam
, 0 },
1477 static const struct message WmSetRedrawTrueSeq
[] =
1479 { WM_SETREDRAW
, sent
|wparam
, 1 },
1483 static const struct message WmEnableWindowSeq_1
[] =
1485 { WM_CANCELMODE
, sent
|wparam
|lparam
, 0, 0 },
1486 { EVENT_OBJECT_STATECHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1487 { WM_ENABLE
, sent
|wparam
|lparam
, FALSE
, 0 },
1491 static const struct message WmEnableWindowSeq_2
[] =
1493 { EVENT_OBJECT_STATECHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1494 { WM_ENABLE
, sent
|wparam
|lparam
, TRUE
, 0 },
1498 static const struct message WmGetScrollRangeSeq
[] =
1500 { SBM_GETRANGE
, sent
},
1503 static const struct message WmGetScrollInfoSeq
[] =
1505 { SBM_GETSCROLLINFO
, sent
},
1508 static const struct message WmSetScrollRangeSeq
[] =
1510 /* MSDN claims that Windows sends SBM_SETRANGE message, but win2k SP4
1511 sends SBM_SETSCROLLINFO.
1513 { SBM_SETSCROLLINFO
, sent
},
1516 /* SetScrollRange for a window without a non-client area */
1517 static const struct message WmSetScrollRangeHSeq_empty
[] =
1519 { EVENT_OBJECT_VALUECHANGE
, winevent_hook
|wparam
|lparam
, OBJID_HSCROLL
, 0 },
1522 static const struct message WmSetScrollRangeVSeq_empty
[] =
1524 { EVENT_OBJECT_VALUECHANGE
, winevent_hook
|wparam
|lparam
, OBJID_VSCROLL
, 0 },
1527 static const struct message WmSetScrollRangeHVSeq
[] =
1529 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOSIZE
},
1530 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1531 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1532 { WM_ERASEBKGND
, sent
|optional
},
1533 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1534 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1535 { EVENT_OBJECT_VALUECHANGE
, winevent_hook
|lparam
|optional
, 0/*OBJID_HSCROLL or OBJID_VSCROLL*/, 0 },
1538 /* SetScrollRange for a window with a non-client area */
1539 static const struct message WmSetScrollRangeHV_NC_Seq
[] =
1541 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOSIZE
},
1542 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1543 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
1544 { WM_NCPAINT
, sent
|optional
},
1545 { WM_STYLECHANGING
, sent
|defwinproc
|optional
},
1546 { WM_STYLECHANGED
, sent
|defwinproc
|optional
},
1547 { WM_STYLECHANGING
, sent
|defwinproc
|optional
},
1548 { WM_STYLECHANGED
, sent
|defwinproc
|optional
},
1549 { WM_STYLECHANGING
, sent
|defwinproc
|optional
},
1550 { WM_STYLECHANGED
, sent
|defwinproc
|optional
},
1551 { WM_STYLECHANGING
, sent
|defwinproc
|optional
},
1552 { WM_STYLECHANGED
, sent
|defwinproc
|optional
},
1553 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1554 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1555 { WM_ERASEBKGND
, sent
|optional
},
1556 { WM_CTLCOLORDLG
, sent
|defwinproc
|optional
}, /* sent to a parent of the dialog */
1557 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOCLIENTMOVE
},
1558 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
1559 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1560 { EVENT_OBJECT_VALUECHANGE
, winevent_hook
|lparam
|optional
, 0/*OBJID_HSCROLL or OBJID_VSCROLL*/, 0 },
1561 { WM_GETTEXT
, sent
|optional
},
1562 { WM_GETTEXT
, sent
|optional
},
1563 { WM_GETTEXT
, sent
|optional
},
1564 { WM_GETTEXT
, sent
|optional
},
1567 /* test if we receive the right sequence of messages */
1568 /* after calling ShowWindow( SW_SHOWNA) */
1569 static const struct message WmSHOWNAChildInvisParInvis
[] = {
1570 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1573 static const struct message WmSHOWNAChildVisParInvis
[] = {
1574 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1577 static const struct message WmSHOWNAChildVisParVis
[] = {
1578 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1579 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
1582 static const struct message WmSHOWNAChildInvisParVis
[] = {
1583 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1584 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1585 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1586 { WM_ERASEBKGND
, sent
|optional
},
1587 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOACTIVATE
|SWP_NOCLIENTMOVE
},
1590 static const struct message WmSHOWNATopVisible
[] = {
1591 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1592 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
1593 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
1594 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1595 { WM_ERASEBKGND
, sent
|optional
},
1596 { WM_WINDOWPOSCHANGED
, sent
|optional
},
1599 static const struct message WmSHOWNATopInvisible
[] = {
1600 { WM_NOTIFYFORMAT
, sent
|optional
},
1601 { WM_QUERYUISTATE
, sent
|optional
},
1602 { WM_WINDOWPOSCHANGING
, sent
|optional
},
1603 { WM_GETMINMAXINFO
, sent
|optional
},
1604 { WM_NCCALCSIZE
, sent
|optional
},
1605 { WM_WINDOWPOSCHANGED
, sent
|optional
},
1606 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1607 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1608 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1609 { WM_NCPAINT
, sent
|wparam
, 1 },
1610 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1611 { WM_ERASEBKGND
, sent
|optional
},
1612 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1613 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
1614 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
1615 { WM_ERASEBKGND
, sent
|optional
},
1616 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1617 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
1622 static int after_end_dialog
, test_def_id
;
1623 static int sequence_cnt
, sequence_size
;
1624 static struct message
* sequence
;
1625 static int log_all_parent_messages
;
1626 static int paint_loop_done
;
1628 /* user32 functions */
1629 static HWND (WINAPI
*pGetAncestor
)(HWND
,UINT
);
1630 static BOOL (WINAPI
*pGetMenuInfo
)(HMENU
,LPCMENUINFO
);
1631 static void (WINAPI
*pNotifyWinEvent
)(DWORD
, HWND
, LONG
, LONG
);
1632 static BOOL (WINAPI
*pSetMenuInfo
)(HMENU
,LPCMENUINFO
);
1633 static HWINEVENTHOOK (WINAPI
*pSetWinEventHook
)(DWORD
, DWORD
, HMODULE
, WINEVENTPROC
, DWORD
, DWORD
, DWORD
);
1634 static BOOL (WINAPI
*pTrackMouseEvent
)(TRACKMOUSEEVENT
*);
1635 static BOOL (WINAPI
*pUnhookWinEvent
)(HWINEVENTHOOK
);
1636 /* kernel32 functions */
1637 static BOOL (WINAPI
*pGetCPInfoExA
)(UINT
, DWORD
, LPCPINFOEXA
);
1639 static void init_procs(void)
1641 HMODULE user32
= GetModuleHandleA("user32.dll");
1642 HMODULE kernel32
= GetModuleHandleA("kernel32.dll");
1644 #define GET_PROC(dll, func) \
1645 p ## func = (void*)GetProcAddress(dll, #func); \
1647 trace("GetProcAddress(%s) failed\n", #func); \
1650 GET_PROC(user32
, GetAncestor
)
1651 GET_PROC(user32
, GetMenuInfo
)
1652 GET_PROC(user32
, NotifyWinEvent
)
1653 GET_PROC(user32
, SetMenuInfo
)
1654 GET_PROC(user32
, SetWinEventHook
)
1655 GET_PROC(user32
, TrackMouseEvent
)
1656 GET_PROC(user32
, UnhookWinEvent
)
1658 GET_PROC(kernel32
, GetCPInfoExA
)
1663 static void add_message(const struct message
*msg
)
1668 sequence
= HeapAlloc( GetProcessHeap(), 0, sequence_size
* sizeof (struct message
) );
1670 if (sequence_cnt
== sequence_size
)
1673 sequence
= HeapReAlloc( GetProcessHeap(), 0, sequence
, sequence_size
* sizeof (struct message
) );
1677 sequence
[sequence_cnt
].message
= msg
->message
;
1678 sequence
[sequence_cnt
].flags
= msg
->flags
;
1679 sequence
[sequence_cnt
].wParam
= msg
->wParam
;
1680 sequence
[sequence_cnt
].lParam
= msg
->lParam
;
1685 /* try to make sure pending X events have been processed before continuing */
1686 static void flush_events(void)
1690 int min_timeout
= 50;
1691 DWORD time
= GetTickCount() + diff
;
1695 if (MsgWaitForMultipleObjects( 0, NULL
, FALSE
, min_timeout
, QS_ALLINPUT
) == WAIT_TIMEOUT
) break;
1696 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
1697 diff
= time
- GetTickCount();
1702 static void flush_sequence(void)
1704 HeapFree(GetProcessHeap(), 0, sequence
);
1706 sequence_cnt
= sequence_size
= 0;
1709 #define ok_sequence( exp, contx, todo) \
1710 ok_sequence_( (exp), (contx), (todo), __FILE__, __LINE__)
1713 static void ok_sequence_(const struct message
*expected
, const char *context
, int todo
,
1714 const char *file
, int line
)
1716 static const struct message end_of_sequence
= { 0, 0, 0, 0 };
1717 const struct message
*actual
;
1720 add_message(&end_of_sequence
);
1724 while (expected
->message
&& actual
->message
)
1726 trace_( file
, line
)("expected %04x - actual %04x\n", expected
->message
, actual
->message
);
1728 if (expected
->message
== actual
->message
)
1730 if (expected
->flags
& wparam
)
1732 if (expected
->wParam
!= actual
->wParam
&& todo
)
1736 ok_( file
, line
) (FALSE
,
1737 "%s: in msg 0x%04x expecting wParam 0x%lx got 0x%lx\n",
1738 context
, expected
->message
, expected
->wParam
, actual
->wParam
);
1742 ok_( file
, line
) (expected
->wParam
== actual
->wParam
,
1743 "%s: in msg 0x%04x expecting wParam 0x%lx got 0x%lx\n",
1744 context
, expected
->message
, expected
->wParam
, actual
->wParam
);
1746 if (expected
->flags
& lparam
)
1748 if (expected
->lParam
!= actual
->lParam
&& todo
)
1752 ok_( file
, line
) (FALSE
,
1753 "%s: in msg 0x%04x expecting lParam 0x%lx got 0x%lx\n",
1754 context
, expected
->message
, expected
->lParam
, actual
->lParam
);
1758 ok_( file
, line
) (expected
->lParam
== actual
->lParam
,
1759 "%s: in msg 0x%04x expecting lParam 0x%lx got 0x%lx\n",
1760 context
, expected
->message
, expected
->lParam
, actual
->lParam
);
1762 if ((expected
->flags
& defwinproc
) != (actual
->flags
& defwinproc
) && todo
)
1766 ok_( file
, line
) (FALSE
,
1767 "%s: the msg 0x%04x should %shave been sent by DefWindowProc\n",
1768 context
, expected
->message
, (expected
->flags
& defwinproc
) ? "" : "NOT ");
1772 ok_( file
, line
) ((expected
->flags
& defwinproc
) == (actual
->flags
& defwinproc
),
1773 "%s: the msg 0x%04x should %shave been sent by DefWindowProc\n",
1774 context
, expected
->message
, (expected
->flags
& defwinproc
) ? "" : "NOT ");
1775 ok_( file
, line
) ((expected
->flags
& beginpaint
) == (actual
->flags
& beginpaint
),
1776 "%s: the msg 0x%04x should %shave been sent by BeginPaint\n",
1777 context
, expected
->message
, (expected
->flags
& beginpaint
) ? "" : "NOT ");
1778 ok_( file
, line
) ((expected
->flags
& (sent
|posted
)) == (actual
->flags
& (sent
|posted
)),
1779 "%s: the msg 0x%04x should have been %s\n",
1780 context
, expected
->message
, (expected
->flags
& posted
) ? "posted" : "sent");
1781 ok_( file
, line
) ((expected
->flags
& parent
) == (actual
->flags
& parent
),
1782 "%s: the msg 0x%04x was expected in %s\n",
1783 context
, expected
->message
, (expected
->flags
& parent
) ? "parent" : "child");
1784 ok_( file
, line
) ((expected
->flags
& hook
) == (actual
->flags
& hook
),
1785 "%s: the msg 0x%04x should have been sent by a hook\n",
1786 context
, expected
->message
);
1787 ok_( file
, line
) ((expected
->flags
& winevent_hook
) == (actual
->flags
& winevent_hook
),
1788 "%s: the msg 0x%04x should have been sent by a winevent hook\n",
1789 context
, expected
->message
);
1793 /* silently drop winevent messages if there is no support for them */
1794 else if ((expected
->flags
& optional
) || ((expected
->flags
& winevent_hook
) && !hEvent_hook
))
1800 ok_( file
, line
) (FALSE
, "%s: the msg 0x%04x was expected, but got msg 0x%04x instead\n",
1801 context
, expected
->message
, actual
->message
);
1808 ok_( file
, line
) (FALSE
, "%s: the msg 0x%04x was expected, but got msg 0x%04x instead\n",
1809 context
, expected
->message
, actual
->message
);
1815 /* skip all optional trailing messages */
1816 while (expected
->message
&& ((expected
->flags
& optional
) ||
1817 ((expected
->flags
& winevent_hook
) && !hEvent_hook
)))
1823 if (expected
->message
|| actual
->message
) {
1825 ok_( file
, line
) (FALSE
, "%s: the msg sequence is not complete: expected %04x - actual %04x\n",
1826 context
, expected
->message
, actual
->message
);
1832 if (expected
->message
|| actual
->message
)
1833 ok_( file
, line
) (FALSE
, "%s: the msg sequence is not complete: expected %04x - actual %04x\n",
1834 context
, expected
->message
, actual
->message
);
1836 if( todo
&& !failcount
) /* succeeded yet marked todo */
1838 ok_( file
, line
)( TRUE
, "%s: marked \"todo_wine\" but succeeds\n", context
);
1844 #define expect(EXPECTED,GOT) ok((GOT)==(EXPECTED), "Expected %d, got %d\n", (EXPECTED), (GOT))
1846 /******************************** MDI test **********************************/
1848 /* CreateWindow for MDI frame window, initially visible */
1849 static const struct message WmCreateMDIframeSeq
[] = {
1850 { HCBT_CREATEWND
, hook
},
1851 { WM_GETMINMAXINFO
, sent
},
1852 { WM_NCCREATE
, sent
},
1853 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
1854 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
1855 { WM_CREATE
, sent
},
1856 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1857 { WM_NOTIFYFORMAT
, sent
|optional
},
1858 { WM_QUERYUISTATE
, sent
|optional
},
1859 { WM_WINDOWPOSCHANGING
, sent
|optional
},
1860 { WM_GETMINMAXINFO
, sent
|optional
},
1861 { WM_NCCALCSIZE
, sent
|optional
},
1862 { WM_WINDOWPOSCHANGED
, sent
|optional
},
1863 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1864 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
1865 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1866 { HCBT_ACTIVATE
, hook
},
1867 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
1868 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
1869 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* XP */
1870 { WM_ACTIVATEAPP
, sent
|wparam
|optional
, 1 }, /* Win9x doesn't send it */
1871 { WM_NCACTIVATE
, sent
|wparam
, 1 },
1872 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1873 { WM_ACTIVATE
, sent
|wparam
, 1 },
1874 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* Win9x */
1875 { HCBT_SETFOCUS
, hook
},
1876 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
1877 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
1878 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1879 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
1880 /* Win9x adds SWP_NOZORDER below */
1881 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1882 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 }, /* XP */
1883 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1884 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
1888 /* DestroyWindow for MDI frame window, initially visible */
1889 static const struct message WmDestroyMDIframeSeq
[] = {
1890 { HCBT_DESTROYWND
, hook
},
1891 { 0x0090, sent
|optional
},
1892 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1893 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1894 { WM_NCACTIVATE
, sent
|wparam
|optional
, 0 }, /* Win9x */
1895 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1896 { WM_NCACTIVATE
, sent
|wparam
|optional
, 0 }, /* XP */
1897 { WM_ACTIVATE
, sent
|wparam
|optional
, 0 }, /* Win9x */
1898 { WM_ACTIVATEAPP
, sent
|wparam
|optional
, 0 }, /* Win9x */
1899 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
1900 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
1901 { WM_DESTROY
, sent
},
1902 { WM_NCDESTROY
, sent
},
1905 /* CreateWindow for MDI client window, initially visible */
1906 static const struct message WmCreateMDIclientSeq
[] = {
1907 { HCBT_CREATEWND
, hook
},
1908 { WM_NCCREATE
, sent
},
1909 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
1910 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 },
1911 { WM_CREATE
, sent
},
1912 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 },
1913 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1914 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
1916 { WM_PARENTNOTIFY
, sent
|wparam
, WM_CREATE
}, /* in MDI frame */
1917 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1918 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1919 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1920 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1923 /* ShowWindow(SW_SHOW) for MDI client window */
1924 static const struct message WmShowMDIclientSeq
[] = {
1925 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1926 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1927 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1928 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1931 /* ShowWindow(SW_HIDE) for MDI client window */
1932 static const struct message WmHideMDIclientSeq
[] = {
1933 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
1934 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1935 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* win2000 */
1936 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* XP */
1937 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1940 /* DestroyWindow for MDI client window, initially visible */
1941 static const struct message WmDestroyMDIclientSeq
[] = {
1942 { HCBT_DESTROYWND
, hook
},
1943 { 0x0090, sent
|optional
},
1944 { WM_PARENTNOTIFY
, sent
|wparam
, WM_DESTROY
}, /* in MDI frame */
1945 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
1946 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1947 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1948 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1949 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
1950 { WM_DESTROY
, sent
},
1951 { WM_NCDESTROY
, sent
},
1954 /* CreateWindow for MDI child window, initially visible */
1955 static const struct message WmCreateMDIchildVisibleSeq
[] = {
1956 { HCBT_CREATEWND
, hook
},
1957 { WM_NCCREATE
, sent
},
1958 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
1959 { WM_CREATE
, sent
},
1960 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1961 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
1963 /* Win2k sends wparam set to
1964 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
1965 * while Win9x doesn't bother to set child window id according to
1966 * CLIENTCREATESTRUCT.idFirstChild
1968 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
1969 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1970 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1971 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1972 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1973 { WM_MDIREFRESHMENU
, sent
/*|wparam|lparam, 0, 0*/ },
1974 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
1975 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
1976 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1978 /* Win9x: message sequence terminates here. */
1980 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 },
1981 { HCBT_SETFOCUS
, hook
}, /* in MDI client */
1982 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
1983 { WM_IME_NOTIFY
, sent
|wparam
|optional
, 2 }, /* in MDI client */
1984 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1985 { WM_SETFOCUS
, sent
}, /* in MDI client */
1986 { HCBT_SETFOCUS
, hook
},
1987 { WM_KILLFOCUS
, sent
}, /* in MDI client */
1988 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
1989 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
1990 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1991 { WM_SETFOCUS
, sent
|defwinproc
},
1992 { WM_MDIACTIVATE
, sent
|defwinproc
},
1995 /* CreateWindow for MDI child window with invisible parent */
1996 static const struct message WmCreateMDIchildInvisibleParentSeq
[] = {
1997 { HCBT_CREATEWND
, hook
},
1998 { WM_GETMINMAXINFO
, sent
},
1999 { WM_NCCREATE
, sent
},
2000 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
2001 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 },
2002 { WM_CREATE
, sent
},
2003 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2004 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2006 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
2007 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
2008 { WM_MDIREFRESHMENU
, sent
}, /* in MDI client */
2009 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
2010 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2011 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2013 /* Win9x: message sequence terminates here. */
2015 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 },
2016 { HCBT_SETFOCUS
, hook
}, /* in MDI client */
2017 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2018 { WM_IME_NOTIFY
, sent
|wparam
|optional
, 2 }, /* in MDI client */
2019 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2020 { WM_SETFOCUS
, sent
}, /* in MDI client */
2021 { HCBT_SETFOCUS
, hook
},
2022 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2023 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2024 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
2025 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2026 { WM_SETFOCUS
, sent
|defwinproc
},
2027 { WM_MDIACTIVATE
, sent
|defwinproc
},
2030 /* DestroyWindow for MDI child window, initially visible */
2031 static const struct message WmDestroyMDIchildVisibleSeq
[] = {
2032 { HCBT_DESTROYWND
, hook
},
2033 /* Win2k sends wparam set to
2034 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
2035 * while Win9x doesn't bother to set child window id according to
2036 * CLIENTCREATESTRUCT.idFirstChild
2038 { 0x0090, sent
|optional
},
2039 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_DESTROY*/ }, /* in MDI client */
2040 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
2041 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2042 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2043 { WM_ERASEBKGND
, sent
|parent
|optional
},
2044 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2046 /* { WM_DESTROY, sent }
2047 * Win9x: message sequence terminates here.
2050 { HCBT_SETFOCUS
, hook
}, /* set focus to MDI client */
2051 { WM_KILLFOCUS
, sent
},
2052 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
2053 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2054 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2055 { WM_SETFOCUS
, sent
}, /* in MDI client */
2057 { HCBT_SETFOCUS
, hook
}, /* MDI client sets focus back to MDI child */
2058 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2059 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2060 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
2061 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2062 { WM_SETFOCUS
, sent
}, /* in MDI client */
2064 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
2066 { HCBT_SETFOCUS
, hook
}, /* set focus to MDI client */
2067 { WM_KILLFOCUS
, sent
},
2068 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
2069 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2070 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2071 { WM_SETFOCUS
, sent
}, /* in MDI client */
2073 { HCBT_SETFOCUS
, hook
}, /* MDI client sets focus back to MDI child */
2074 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2075 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2076 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
2077 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2078 { WM_SETFOCUS
, sent
}, /* in MDI client */
2080 { WM_DESTROY
, sent
},
2082 { HCBT_SETFOCUS
, hook
}, /* set focus to MDI client */
2083 { WM_KILLFOCUS
, sent
},
2084 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
2085 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2086 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2087 { WM_SETFOCUS
, sent
}, /* in MDI client */
2089 { HCBT_SETFOCUS
, hook
}, /* MDI client sets focus back to MDI child */
2090 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2091 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2092 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
2093 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2094 { WM_SETFOCUS
, sent
}, /* in MDI client */
2096 { WM_NCDESTROY
, sent
},
2099 /* CreateWindow for MDI child window, initially invisible */
2100 static const struct message WmCreateMDIchildInvisibleSeq
[] = {
2101 { HCBT_CREATEWND
, hook
},
2102 { WM_NCCREATE
, sent
},
2103 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
2104 { WM_CREATE
, sent
},
2105 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2106 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2108 /* Win2k sends wparam set to
2109 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2110 * while Win9x doesn't bother to set child window id according to
2111 * CLIENTCREATESTRUCT.idFirstChild
2113 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
2116 /* DestroyWindow for MDI child window, initially invisible */
2117 static const struct message WmDestroyMDIchildInvisibleSeq
[] = {
2118 { HCBT_DESTROYWND
, hook
},
2119 /* Win2k sends wparam set to
2120 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
2121 * while Win9x doesn't bother to set child window id according to
2122 * CLIENTCREATESTRUCT.idFirstChild
2124 { 0x0090, sent
|optional
},
2125 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_DESTROY*/ }, /* in MDI client */
2126 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
2127 { WM_DESTROY
, sent
},
2128 { WM_NCDESTROY
, sent
},
2129 /* FIXME: Wine destroys an icon/title window while Windows doesn't */
2130 { WM_PARENTNOTIFY
, sent
|wparam
|optional
, WM_DESTROY
}, /* MDI client */
2133 /* CreateWindow for the 1st MDI child window, initially visible and maximized */
2134 static const struct message WmCreateMDIchildVisibleMaxSeq1
[] = {
2135 { HCBT_CREATEWND
, hook
},
2136 { WM_NCCREATE
, sent
},
2137 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
2138 { WM_CREATE
, sent
},
2139 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2140 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2142 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
2143 { WM_GETMINMAXINFO
, sent
},
2144 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_STATECHANGED
},
2145 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2146 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
2147 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2149 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2150 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2151 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2152 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2153 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2154 /* Win2k sends wparam set to
2155 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2156 * while Win9x doesn't bother to set child window id according to
2157 * CLIENTCREATESTRUCT.idFirstChild
2159 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
2160 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
2161 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2162 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2163 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2164 { WM_MDIREFRESHMENU
, sent
/*|wparam|lparam, 0, 0*/ },
2165 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
2166 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2167 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2169 /* Win9x: message sequence terminates here. */
2171 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 },
2172 { HCBT_SETFOCUS
, hook
}, /* in MDI client */
2173 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2174 { WM_IME_NOTIFY
, sent
|wparam
|optional
, 2 }, /* in MDI client */
2175 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2176 { WM_SETFOCUS
, sent
}, /* in MDI client */
2177 { HCBT_SETFOCUS
, hook
},
2178 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2179 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2180 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
2181 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2182 { WM_SETFOCUS
, sent
|defwinproc
},
2183 { WM_MDIACTIVATE
, sent
|defwinproc
},
2185 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2186 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2187 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2188 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2191 /* CreateWindow for the 2nd MDI child window, initially visible and maximized */
2192 static const struct message WmCreateMDIchildVisibleMaxSeq2
[] = {
2193 /* restore the 1st MDI child */
2194 { WM_SETREDRAW
, sent
|wparam
, 0 },
2195 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWNORMAL
},
2196 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
2197 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2198 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2199 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
2200 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2202 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2203 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2204 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2205 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2206 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2207 { WM_SETREDRAW
, sent
|wparam
, 1 }, /* in the 1st MDI child */
2208 /* create the 2nd MDI child */
2209 { HCBT_CREATEWND
, hook
},
2210 { WM_NCCREATE
, sent
},
2211 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
2212 { WM_CREATE
, sent
},
2213 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2214 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2216 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
2217 { WM_GETMINMAXINFO
, sent
},
2218 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_STATECHANGED
},
2219 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2220 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2221 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
2222 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2224 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2225 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2226 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2227 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2228 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2229 /* Win2k sends wparam set to
2230 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2231 * while Win9x doesn't bother to set child window id according to
2232 * CLIENTCREATESTRUCT.idFirstChild
2234 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
2235 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
2236 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2237 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2238 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2239 { WM_MDIREFRESHMENU
, sent
/*|wparam|lparam, 0, 0*/ },
2240 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
2241 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2243 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 0 }, /* in the 1st MDI child */
2244 { WM_MDIACTIVATE
, sent
|defwinproc
}, /* in the 1st MDI child */
2246 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2248 /* Win9x: message sequence terminates here. */
2250 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 },
2251 { HCBT_SETFOCUS
, hook
},
2252 { WM_KILLFOCUS
, sent
|defwinproc
|optional
}, /* in the 1st MDI child */
2253 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 0 }, /* in the 1st MDI child */
2254 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2255 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2256 { WM_SETFOCUS
, sent
}, /* in MDI client */
2257 { HCBT_SETFOCUS
, hook
},
2258 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2259 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2260 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
2261 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2262 { WM_SETFOCUS
, sent
|defwinproc
},
2264 { WM_MDIACTIVATE
, sent
|defwinproc
},
2266 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2267 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2268 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2269 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2272 /* WM_MDICREATE MDI child window, initially visible and maximized */
2273 static const struct message WmCreateMDIchildVisibleMaxSeq3
[] = {
2274 { WM_MDICREATE
, sent
},
2275 { HCBT_CREATEWND
, hook
},
2276 { WM_NCCREATE
, sent
},
2277 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
2278 { WM_CREATE
, sent
},
2279 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2280 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2282 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
2283 { WM_GETMINMAXINFO
, sent
},
2284 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_STATECHANGED
},
2285 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2286 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
2287 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
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 */
2294 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2296 /* Win2k sends wparam set to
2297 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2298 * while Win9x doesn't bother to set child window id according to
2299 * CLIENTCREATESTRUCT.idFirstChild
2301 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
2302 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
2303 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2305 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2307 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2308 { WM_MDIREFRESHMENU
, sent
/*|wparam|lparam, 0, 0*/ },
2309 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
2311 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2312 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2314 /* Win9x: message sequence terminates here. */
2316 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 },
2317 { WM_SETFOCUS
, sent
|optional
}, /* in MDI client */
2318 { HCBT_SETFOCUS
, hook
}, /* in MDI client */
2319 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2320 { WM_IME_NOTIFY
, sent
|wparam
|optional
, 2 },
2321 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
|optional
, OBJID_CLIENT
, 0 },
2322 { WM_SETFOCUS
, sent
|optional
}, /* in MDI client */
2323 { HCBT_SETFOCUS
, hook
|optional
},
2324 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2325 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2326 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
2327 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2328 { WM_SETFOCUS
, sent
|defwinproc
},
2330 { WM_MDIACTIVATE
, sent
|defwinproc
},
2333 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2334 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2335 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2336 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2339 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2340 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2341 { 0x0093, sent
|defwinproc
|optional
},
2342 { 0x0093, sent
|defwinproc
|optional
},
2343 { 0x0093, sent
|defwinproc
|optional
},
2344 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2345 { WM_MOVE
, sent
|defwinproc
},
2346 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2349 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
2350 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2351 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
},
2352 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2355 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
2356 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2357 { 0x0093, sent
|optional
},
2358 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
},
2359 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2361 { 0x0093, sent
|optional
},
2362 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2363 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI client */
2364 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 }, /* XP sends it to MDI frame */
2365 { 0x0093, sent
|defwinproc
|optional
},
2366 { 0x0093, sent
|defwinproc
|optional
},
2367 { 0x0093, sent
|defwinproc
|optional
},
2368 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2369 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* XP sends a duplicate */
2373 /* CreateWindow for the 1st MDI child window, initially invisible and maximized */
2374 static const struct message WmCreateMDIchildInvisibleMaxSeq4
[] = {
2375 { HCBT_CREATEWND
, hook
},
2376 { WM_GETMINMAXINFO
, sent
},
2377 { WM_NCCREATE
, sent
},
2378 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
2379 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
2380 { WM_CREATE
, sent
},
2381 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2382 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2383 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOZORDER
|SWP_NOSIZE
|SWP_NOMOVE
}, /* MDI frame */
2384 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 }, /* MDI frame */
2385 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOZORDER
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
}, /* MDI frame */
2387 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
2388 { WM_GETMINMAXINFO
, sent
},
2389 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_STATECHANGED
},
2390 { WM_GETMINMAXINFO
, sent
|defwinproc
},
2391 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2392 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_STATECHANGED
},
2393 { WM_MOVE
, sent
|defwinproc
},
2394 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2396 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2397 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2398 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2399 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2400 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 }, /* MDI child */
2401 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2402 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2403 /* Win2k sends wparam set to
2404 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2405 * while Win9x doesn't bother to set child window id according to
2406 * CLIENTCREATESTRUCT.idFirstChild
2408 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
2411 /* WM_SYSCOMMAND/SC_CLOSE for the 2nd MDI child window, initially visible and maximized */
2412 static const struct message WmDestroyMDIchildVisibleMaxSeq2
[] = {
2413 { WM_SYSCOMMAND
, sent
|wparam
, SC_CLOSE
},
2414 { HCBT_SYSCOMMAND
, hook
},
2415 { WM_CLOSE
, sent
|defwinproc
},
2416 { WM_MDIDESTROY
, sent
}, /* in MDI client */
2418 /* bring the 1st MDI child to top */
2419 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOSIZE
|SWP_NOMOVE
}, /* in the 1st MDI child */
2420 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
}, /* in the 2nd MDI child */
2422 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2424 { WM_CHILDACTIVATE
, sent
|defwinproc
|wparam
|lparam
, 0, 0 }, /* in the 1st MDI child */
2425 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 0 }, /* in the 1st MDI child */
2426 { WM_MDIACTIVATE
, sent
|defwinproc
}, /* in the 1st MDI child */
2428 /* maximize the 1st MDI child */
2429 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
2430 { WM_GETMINMAXINFO
, sent
|defwinproc
},
2431 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
2432 { WM_NCCALCSIZE
, sent
|defwinproc
|wparam
, 1 },
2433 { WM_CHILDACTIVATE
, sent
|defwinproc
|wparam
|lparam
, 0, 0 },
2434 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
2435 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2437 /* restore the 2nd MDI child */
2438 { WM_SETREDRAW
, sent
|defwinproc
|wparam
, 0 },
2439 { HCBT_MINMAX
, hook
|lparam
, 0, SW_NORMALNA
},
2440 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_SHOWWINDOW
|SWP_STATECHANGED
},
2441 { WM_NCCALCSIZE
, sent
|defwinproc
|wparam
, 1 },
2443 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2445 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
2446 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2448 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2450 { WM_SETREDRAW
, sent
|defwinproc
|wparam
, 1 },
2452 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2453 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2454 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2455 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2456 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2458 /* bring the 1st MDI child to top */
2459 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2460 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 },
2461 { HCBT_SETFOCUS
, hook
},
2462 { WM_KILLFOCUS
, sent
|defwinproc
},
2463 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 0 },
2464 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2465 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2466 { WM_SETFOCUS
, sent
}, /* in MDI client */
2467 { HCBT_SETFOCUS
, hook
},
2468 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2469 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2470 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
2471 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2472 { WM_SETFOCUS
, sent
|defwinproc
},
2473 { WM_MDIACTIVATE
, sent
|defwinproc
},
2474 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2476 /* apparently ShowWindow(SW_SHOW) on an MDI client */
2477 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
2478 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2479 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2480 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2481 { WM_MDIREFRESHMENU
, sent
},
2483 { HCBT_DESTROYWND
, hook
},
2484 /* Win2k sends wparam set to
2485 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
2486 * while Win9x doesn't bother to set child window id according to
2487 * CLIENTCREATESTRUCT.idFirstChild
2489 { 0x0090, sent
|defwinproc
|optional
},
2490 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_DESTROY*/ }, /* in MDI client */
2491 { WM_SHOWWINDOW
, sent
|defwinproc
|wparam
, 0 },
2492 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2493 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2494 { WM_ERASEBKGND
, sent
|parent
|optional
},
2495 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2497 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
2498 { WM_DESTROY
, sent
|defwinproc
},
2499 { WM_NCDESTROY
, sent
|defwinproc
},
2502 /* WM_MDIDESTROY for the single MDI child window, initially visible and maximized */
2503 static const struct message WmDestroyMDIchildVisibleMaxSeq1
[] = {
2504 { WM_MDIDESTROY
, sent
}, /* in MDI client */
2505 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
2506 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2507 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2508 { WM_ERASEBKGND
, sent
|parent
|optional
},
2509 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2511 { HCBT_SETFOCUS
, hook
},
2512 { WM_KILLFOCUS
, sent
},
2513 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
2514 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2515 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2516 { WM_SETFOCUS
, sent
}, /* in MDI client */
2517 { HCBT_SETFOCUS
, hook
},
2518 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2519 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2520 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
2521 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2522 { WM_SETFOCUS
, sent
},
2525 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2526 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2527 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2528 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2531 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2532 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2533 { 0x0093, sent
|defwinproc
|optional
},
2534 { 0x0093, sent
|defwinproc
|optional
},
2535 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2536 { WM_MOVE
, sent
|defwinproc
},
2537 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2540 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
2541 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2542 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
},
2543 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2546 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
2547 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2548 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
},
2549 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2552 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2553 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 },
2554 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2555 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2558 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2559 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 },
2560 { 0x0093, sent
|defwinproc
|optional
},
2561 { 0x0093, sent
|defwinproc
|optional
},
2562 { 0x0093, sent
|defwinproc
|optional
},
2563 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2564 { WM_MOVE
, sent
|defwinproc
},
2565 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2568 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
2569 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2570 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
},
2571 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2574 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
},
2575 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 },
2576 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
},
2577 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2578 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2579 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI client */
2581 { 0x0093, sent
|defwinproc
|optional
},
2582 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
|optional
, 1 }, /* XP sends it to MDI frame */
2583 { 0x0093, sent
|defwinproc
|optional
},
2584 { 0x0093, sent
|defwinproc
|optional
},
2585 { 0x0093, sent
|defwinproc
|optional
},
2586 { 0x0093, sent
|optional
},
2588 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2589 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2590 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI client */
2591 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2592 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* XP sends a duplicate */
2595 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2596 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
2597 { 0x0093, sent
|defwinproc
|optional
},
2598 { 0x0093, sent
|defwinproc
|optional
},
2599 { 0x0093, sent
|defwinproc
|optional
},
2600 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2601 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2602 { 0x0093, sent
|optional
},
2604 { WM_NCACTIVATE
, sent
|wparam
, 0 },
2605 { WM_MDIACTIVATE
, sent
},
2607 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWNORMAL
},
2608 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_SHOWWINDOW
|SWP_STATECHANGED
},
2609 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2611 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2613 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2614 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_SHOWWINDOW
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
2615 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2618 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2619 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 },
2620 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2621 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2624 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2625 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2626 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2627 { WM_MOVE
, sent
|defwinproc
},
2628 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2631 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
2632 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2633 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
},
2634 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2635 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2636 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 }, /* XP */
2637 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI client */
2638 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2639 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* XP sends a duplicate */
2641 { HCBT_SETFOCUS
, hook
},
2642 { WM_KILLFOCUS
, sent
},
2643 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
2644 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2645 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2646 { WM_SETFOCUS
, sent
}, /* in MDI client */
2648 { WM_MDIREFRESHMENU
, sent
}, /* in MDI client */
2650 { HCBT_DESTROYWND
, hook
},
2651 /* Win2k sends wparam set to
2652 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
2653 * while Win9x doesn't bother to set child window id according to
2654 * CLIENTCREATESTRUCT.idFirstChild
2656 { 0x0090, sent
|optional
},
2657 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_DESTROY*/ }, /* in MDI client */
2659 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
2660 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2661 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2662 { WM_ERASEBKGND
, sent
|parent
|optional
},
2663 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2665 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
2666 { WM_DESTROY
, sent
},
2667 { WM_NCDESTROY
, sent
},
2670 /* ShowWindow(SW_MAXIMIZE) for a not visible MDI child window */
2671 static const struct message WmMaximizeMDIchildInvisibleSeq
[] = {
2672 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
2673 { WM_GETMINMAXINFO
, sent
},
2674 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_STATECHANGED
},
2675 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2676 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2677 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2679 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2680 { WM_NCACTIVATE
, sent
|wparam
|optional
|defwinproc
, 1 },
2681 { HCBT_SETFOCUS
, hook
|optional
},
2682 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2683 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2684 { WM_SETFOCUS
, sent
|optional
}, /* in MDI client */
2685 { HCBT_SETFOCUS
, hook
|optional
},
2686 { WM_KILLFOCUS
, sent
|optional
}, /* in MDI client */
2687 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2688 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
2689 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2690 { WM_SETFOCUS
, sent
|optional
|defwinproc
},
2691 { WM_MDIACTIVATE
, sent
|optional
|defwinproc
},
2692 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
2693 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2695 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2696 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2697 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2698 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2699 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2702 /* ShowWindow(SW_MAXIMIZE) for a not visible maximized MDI child window */
2703 static const struct message WmMaximizeMDIchildInvisibleSeq2
[] = {
2704 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
2705 { WM_GETMINMAXINFO
, sent
},
2706 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
},
2707 { WM_GETMINMAXINFO
, sent
|defwinproc
},
2708 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2709 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2710 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2712 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
|optional
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2713 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
|optional
, 1 },
2714 { HCBT_SETFOCUS
, hook
|optional
},
2715 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2716 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2717 { WM_SETFOCUS
, sent
|optional
}, /* in MDI client */
2718 { HCBT_SETFOCUS
, hook
|optional
},
2719 { WM_KILLFOCUS
, sent
|optional
}, /* in MDI client */
2720 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2721 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
2722 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2723 { WM_SETFOCUS
, sent
|defwinproc
|optional
},
2724 { WM_MDIACTIVATE
, sent
|defwinproc
|optional
},
2725 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2726 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2729 /* WM_MDIMAXIMIZE for an MDI child window with invisible parent */
2730 static const struct message WmMaximizeMDIchildInvisibleParentSeq
[] = {
2731 { WM_MDIMAXIMIZE
, sent
}, /* in MDI client */
2732 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
2733 { WM_GETMINMAXINFO
, sent
},
2734 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
2735 { WM_GETMINMAXINFO
, sent
|defwinproc
},
2736 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2737 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* XP doesn't send it */
2738 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2739 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOREDRAW
|SWP_STATECHANGED
},
2740 { WM_MOVE
, sent
|defwinproc
},
2741 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2743 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2744 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 },
2745 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2746 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
|optional
, 1 },
2747 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI child XP */
2748 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI client XP */
2750 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2751 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2752 { 0x0093, sent
|defwinproc
|optional
},
2753 { 0x0094, sent
|defwinproc
|optional
},
2754 { 0x0094, sent
|defwinproc
|optional
},
2755 { 0x0094, sent
|defwinproc
|optional
},
2756 { 0x0094, sent
|defwinproc
|optional
},
2757 { 0x0093, sent
|defwinproc
|optional
},
2758 { 0x0093, sent
|defwinproc
|optional
},
2759 { 0x0091, sent
|defwinproc
|optional
},
2760 { 0x0092, sent
|defwinproc
|optional
},
2761 { 0x0092, sent
|defwinproc
|optional
},
2762 { 0x0092, sent
|defwinproc
|optional
},
2763 { 0x0092, sent
|defwinproc
|optional
},
2764 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2765 { WM_MOVE
, sent
|defwinproc
},
2766 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2767 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI frame win2000 */
2769 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
2770 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2771 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
},
2772 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2774 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
},
2775 { WM_GETMINMAXINFO
, sent
|defwinproc
},
2776 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 },
2777 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
},
2778 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2779 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI child win2000 */
2780 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
|optional
, 1 },
2781 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI child XP */
2782 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI child XP */
2783 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI client XP */
2785 { 0x0093, sent
|optional
},
2786 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
2787 { 0x0093, sent
|defwinproc
|optional
},
2788 { 0x0093, sent
|defwinproc
|optional
},
2789 { 0x0093, sent
|defwinproc
|optional
},
2790 { 0x0091, sent
|defwinproc
|optional
},
2791 { 0x0092, sent
|defwinproc
|optional
},
2792 { 0x0092, sent
|defwinproc
|optional
},
2793 { 0x0092, sent
|defwinproc
|optional
},
2794 { 0x0092, sent
|defwinproc
|optional
},
2795 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI frame XP */
2796 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI frame XP */
2797 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI child XP */
2800 /* ShowWindow(SW_MAXIMIZE) for a visible MDI child window */
2801 static const struct message WmMaximizeMDIchildVisibleSeq
[] = {
2802 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
2803 { WM_GETMINMAXINFO
, sent
},
2804 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
2805 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2806 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2807 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
2808 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2810 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2811 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2812 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2813 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2814 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2817 /* ShowWindow(SW_RESTORE) for a visible maximized MDI child window */
2818 static const struct message WmRestoreMDIchildVisibleSeq
[] = {
2819 { HCBT_MINMAX
, hook
|lparam
, 0, SW_RESTORE
},
2820 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
2821 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2822 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2823 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
2824 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2826 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2827 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2828 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2829 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2830 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2833 /* ShowWindow(SW_RESTORE) for a visible minimized MDI child window */
2834 static const struct message WmRestoreMDIchildVisibleSeq_2
[] = {
2835 { HCBT_MINMAX
, hook
|lparam
, 0, SW_RESTORE
},
2836 { WM_QUERYOPEN
, sent
|wparam
|lparam
, 0, 0 },
2837 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
2838 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2839 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2840 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_NOCLIENTSIZE
|SWP_STATECHANGED
},
2841 { WM_MOVE
, sent
|defwinproc
},
2842 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2843 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2844 { EVENT_SYSTEM_MINIMIZEEND
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2845 { HCBT_SETFOCUS
, hook
},
2846 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
2847 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
2848 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2849 { WM_SETFOCUS
, sent
},
2852 /* ShowWindow(SW_MINIMIZE) for a visible restored MDI child window */
2853 static const struct message WmMinimizeMDIchildVisibleSeq
[] = {
2854 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
2855 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
2856 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2857 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOCOPYBITS
|SWP_NOCLIENTSIZE
|SWP_STATECHANGED
},
2858 { WM_MOVE
, sent
|defwinproc
},
2859 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MINIMIZED
},
2860 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
|defwinproc
, 0, 0 },
2861 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2862 { EVENT_SYSTEM_MINIMIZESTART
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2863 /* FIXME: Wine creates an icon/title window while Windows doesn't */
2864 { WM_PARENTNOTIFY
, sent
|parent
|wparam
|optional
, WM_CREATE
}, /* MDI client */
2867 /* ShowWindow(SW_RESTORE) for a not visible MDI child window */
2868 static const struct message WmRestoreMDIchildInisibleSeq
[] = {
2869 { HCBT_MINMAX
, hook
|lparam
, 0, SW_RESTORE
},
2870 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_STATECHANGED
},
2871 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2872 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2873 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2874 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
2875 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2877 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2878 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2879 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2880 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2881 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2885 static HWND mdi_client
;
2886 static WNDPROC old_mdi_client_proc
;
2888 static LRESULT WINAPI
mdi_client_hook_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
2892 /* do not log painting messages */
2893 if (message
!= WM_PAINT
&&
2894 message
!= WM_NCPAINT
&&
2895 message
!= WM_SYNCPAINT
&&
2896 message
!= WM_ERASEBKGND
&&
2897 message
!= WM_NCHITTEST
&&
2898 message
!= WM_GETTEXT
&&
2899 message
!= WM_MDIGETACTIVE
&&
2900 message
!= WM_GETICON
&&
2901 message
!= WM_DEVICECHANGE
)
2903 trace("mdi client: %p, %04x, %08lx, %08lx\n", hwnd
, message
, wParam
, lParam
);
2907 case WM_WINDOWPOSCHANGING
:
2908 case WM_WINDOWPOSCHANGED
:
2910 WINDOWPOS
*winpos
= (WINDOWPOS
*)lParam
;
2912 trace("%s\n", (message
== WM_WINDOWPOSCHANGING
) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
2913 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x ",
2914 winpos
->hwnd
, winpos
->hwndInsertAfter
,
2915 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
2916 dump_winpos_flags(winpos
->flags
);
2918 /* Log only documented flags, win2k uses 0x1000 and 0x2000
2919 * in the high word for internal purposes
2921 wParam
= winpos
->flags
& 0xffff;
2922 /* We are not interested in the flags that don't match under XP and Win9x */
2923 wParam
&= ~(SWP_NOZORDER
);
2928 msg
.message
= message
;
2929 msg
.flags
= sent
|wparam
|lparam
;
2930 msg
.wParam
= wParam
;
2931 msg
.lParam
= lParam
;
2935 return CallWindowProcA(old_mdi_client_proc
, hwnd
, message
, wParam
, lParam
);
2938 static LRESULT WINAPI
mdi_child_wnd_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
2940 static long defwndproc_counter
= 0;
2944 /* do not log painting messages */
2945 if (message
!= WM_PAINT
&&
2946 message
!= WM_NCPAINT
&&
2947 message
!= WM_SYNCPAINT
&&
2948 message
!= WM_ERASEBKGND
&&
2949 message
!= WM_NCHITTEST
&&
2950 message
!= WM_GETTEXT
&&
2951 message
!= WM_GETICON
&&
2952 message
!= WM_DEVICECHANGE
)
2954 trace("mdi child: %p, %04x, %08lx, %08lx\n", hwnd
, message
, wParam
, lParam
);
2958 case WM_WINDOWPOSCHANGING
:
2959 case WM_WINDOWPOSCHANGED
:
2961 WINDOWPOS
*winpos
= (WINDOWPOS
*)lParam
;
2963 trace("%s\n", (message
== WM_WINDOWPOSCHANGING
) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
2964 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x ",
2965 winpos
->hwnd
, winpos
->hwndInsertAfter
,
2966 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
2967 dump_winpos_flags(winpos
->flags
);
2969 /* Log only documented flags, win2k uses 0x1000 and 0x2000
2970 * in the high word for internal purposes
2972 wParam
= winpos
->flags
& 0xffff;
2973 /* We are not interested in the flags that don't match under XP and Win9x */
2974 wParam
&= ~(SWP_NOZORDER
);
2978 case WM_MDIACTIVATE
:
2980 HWND active
, client
= GetParent(hwnd
);
2982 active
= (HWND
)SendMessageA(client
, WM_MDIGETACTIVE
, 0, 0);
2984 if (hwnd
== (HWND
)lParam
) /* if we are being activated */
2985 ok (active
== (HWND
)lParam
, "new active %p != active %p\n", (HWND
)lParam
, active
);
2987 ok (active
== (HWND
)wParam
, "old active %p != active %p\n", (HWND
)wParam
, active
);
2992 msg
.message
= message
;
2993 msg
.flags
= sent
|wparam
|lparam
;
2994 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
2995 msg
.wParam
= wParam
;
2996 msg
.lParam
= lParam
;
3000 defwndproc_counter
++;
3001 ret
= DefMDIChildProcA(hwnd
, message
, wParam
, lParam
);
3002 defwndproc_counter
--;
3007 static LRESULT WINAPI
mdi_frame_wnd_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
3009 static long defwndproc_counter
= 0;
3013 /* do not log painting messages */
3014 if (message
!= WM_PAINT
&&
3015 message
!= WM_NCPAINT
&&
3016 message
!= WM_SYNCPAINT
&&
3017 message
!= WM_ERASEBKGND
&&
3018 message
!= WM_NCHITTEST
&&
3019 message
!= WM_GETTEXT
&&
3020 message
!= WM_GETICON
&&
3021 message
!= WM_DEVICECHANGE
&&
3024 trace("mdi frame: %p, %04x, %08lx, %08lx\n", hwnd
, message
, wParam
, lParam
);
3028 case WM_WINDOWPOSCHANGING
:
3029 case WM_WINDOWPOSCHANGED
:
3031 WINDOWPOS
*winpos
= (WINDOWPOS
*)lParam
;
3033 trace("%s\n", (message
== WM_WINDOWPOSCHANGING
) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
3034 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x ",
3035 winpos
->hwnd
, winpos
->hwndInsertAfter
,
3036 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
3037 dump_winpos_flags(winpos
->flags
);
3039 /* Log only documented flags, win2k uses 0x1000 and 0x2000
3040 * in the high word for internal purposes
3042 wParam
= winpos
->flags
& 0xffff;
3043 /* We are not interested in the flags that don't match under XP and Win9x */
3044 wParam
&= ~(SWP_NOZORDER
);
3049 msg
.message
= message
;
3050 msg
.flags
= sent
|wparam
|lparam
;
3051 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
3052 msg
.wParam
= wParam
;
3053 msg
.lParam
= lParam
;
3057 defwndproc_counter
++;
3058 ret
= DefFrameProcA(hwnd
, mdi_client
, message
, wParam
, lParam
);
3059 defwndproc_counter
--;
3064 static BOOL
mdi_RegisterWindowClasses(void)
3069 cls
.lpfnWndProc
= mdi_frame_wnd_proc
;
3072 cls
.hInstance
= GetModuleHandleA(0);
3074 cls
.hCursor
= LoadCursorA(0, (LPSTR
)IDC_ARROW
);
3075 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
3076 cls
.lpszMenuName
= NULL
;
3077 cls
.lpszClassName
= "MDI_frame_class";
3078 if (!RegisterClassA(&cls
)) return FALSE
;
3080 cls
.lpfnWndProc
= mdi_child_wnd_proc
;
3081 cls
.lpszClassName
= "MDI_child_class";
3082 if (!RegisterClassA(&cls
)) return FALSE
;
3084 if (!GetClassInfoA(0, "MDIClient", &cls
)) assert(0);
3085 old_mdi_client_proc
= cls
.lpfnWndProc
;
3086 cls
.hInstance
= GetModuleHandleA(0);
3087 cls
.lpfnWndProc
= mdi_client_hook_proc
;
3088 cls
.lpszClassName
= "MDI_client_class";
3089 if (!RegisterClassA(&cls
)) assert(0);
3094 static void test_mdi_messages(void)
3096 MDICREATESTRUCTA mdi_cs
;
3097 CLIENTCREATESTRUCT client_cs
;
3098 HWND mdi_frame
, mdi_child
, mdi_child2
, active_child
;
3100 HMENU hMenu
= CreateMenu();
3102 assert(mdi_RegisterWindowClasses());
3106 trace("creating MDI frame window\n");
3107 mdi_frame
= CreateWindowExA(0, "MDI_frame_class", "MDI frame window",
3108 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
|
3109 WS_MAXIMIZEBOX
| WS_VISIBLE
,
3110 100, 100, CW_USEDEFAULT
, CW_USEDEFAULT
,
3111 GetDesktopWindow(), hMenu
,
3112 GetModuleHandleA(0), NULL
);
3114 ok_sequence(WmCreateMDIframeSeq
, "Create MDI frame window", FALSE
);
3116 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3117 ok(GetFocus() == mdi_frame
, "wrong focus window %p\n", GetFocus());
3119 trace("creating MDI client window\n");
3120 client_cs
.hWindowMenu
= 0;
3121 client_cs
.idFirstChild
= MDI_FIRST_CHILD_ID
;
3122 mdi_client
= CreateWindowExA(0, "MDI_client_class",
3124 WS_CHILD
| WS_VISIBLE
| MDIS_ALLCHILDSTYLES
,
3126 mdi_frame
, 0, GetModuleHandleA(0), &client_cs
);
3128 ok_sequence(WmCreateMDIclientSeq
, "Create visible MDI client window", FALSE
);
3130 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3131 ok(GetFocus() == mdi_frame
, "input focus should be on MDI frame not on %p\n", GetFocus());
3133 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3134 ok(!active_child
, "wrong active MDI child %p\n", active_child
);
3135 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
3140 trace("creating invisible MDI child window\n");
3141 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3143 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
3144 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3148 ShowWindow(mdi_child
, SW_SHOWNORMAL
);
3149 ok_sequence(WmShowChildSeq
, "ShowWindow(SW_SHOWNORMAL) MDI child window", FALSE
);
3151 ok(GetWindowLongA(mdi_child
, GWL_STYLE
) & WS_VISIBLE
, "MDI child should be visible\n");
3152 ok(IsWindowVisible(mdi_child
), "MDI child should be visible\n");
3154 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3155 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3157 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3158 ok(!active_child
, "wrong active MDI child %p\n", active_child
);
3159 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
3161 ShowWindow(mdi_child
, SW_HIDE
);
3162 ok_sequence(WmHideChildSeq
, "ShowWindow(SW_HIDE) MDI child window", FALSE
);
3165 ShowWindow(mdi_child
, SW_SHOW
);
3166 ok_sequence(WmShowChildSeq
, "ShowWindow(SW_SHOW) MDI child window", FALSE
);
3168 ok(GetWindowLongA(mdi_child
, GWL_STYLE
) & WS_VISIBLE
, "MDI child should be visible\n");
3169 ok(IsWindowVisible(mdi_child
), "MDI child should be visible\n");
3171 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3172 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3174 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3175 ok(!active_child
, "wrong active MDI child %p\n", active_child
);
3176 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
3178 DestroyWindow(mdi_child
);
3181 trace("creating visible MDI child window\n");
3182 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3183 WS_CHILD
| WS_VISIBLE
,
3184 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
3185 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3187 ok_sequence(WmCreateMDIchildVisibleSeq
, "Create visible MDI child window", FALSE
);
3189 ok(GetWindowLongA(mdi_child
, GWL_STYLE
) & WS_VISIBLE
, "MDI child should be visible\n");
3190 ok(IsWindowVisible(mdi_child
), "MDI child should be visible\n");
3192 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3193 ok(GetFocus() == mdi_child
, "wrong focus window %p\n", GetFocus());
3195 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3196 ok(active_child
== mdi_child
, "wrong active MDI child %p\n", active_child
);
3197 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
3200 DestroyWindow(mdi_child
);
3201 ok_sequence(WmDestroyMDIchildVisibleSeq
, "Destroy visible MDI child window", TRUE
);
3203 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3204 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3206 /* Win2k: MDI client still returns a just destroyed child as active
3207 * Win9x: MDI client returns 0
3209 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3210 ok(active_child
== mdi_child
|| /* win2k */
3211 !active_child
, /* win9x */
3212 "wrong active MDI child %p\n", active_child
);
3213 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
3217 trace("creating invisible MDI child window\n");
3218 mdi_child2
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3220 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
3221 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3223 ok_sequence(WmCreateMDIchildInvisibleSeq
, "Create invisible MDI child window", FALSE
);
3225 ok(!(GetWindowLongA(mdi_child2
, GWL_STYLE
) & WS_VISIBLE
), "MDI child should not be visible\n");
3226 ok(!IsWindowVisible(mdi_child2
), "MDI child should not be visible\n");
3228 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3229 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3231 /* Win2k: MDI client still returns a just destroyed child as active
3232 * Win9x: MDI client returns mdi_child2
3234 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3235 ok(active_child
== mdi_child
|| /* win2k */
3236 active_child
== mdi_child2
, /* win9x */
3237 "wrong active MDI child %p\n", active_child
);
3238 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
3241 ShowWindow(mdi_child2
, SW_MAXIMIZE
);
3242 ok_sequence(WmMaximizeMDIchildInvisibleSeq
, "ShowWindow(SW_MAXIMIZE):invisible MDI child", FALSE
);
3244 ok(GetWindowLongA(mdi_child2
, GWL_STYLE
) & WS_VISIBLE
, "MDI child should be visible\n");
3245 ok(IsWindowVisible(mdi_child2
), "MDI child should be visible\n");
3247 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3248 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
3249 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
3252 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3253 ok(GetFocus() == mdi_child2
|| /* win2k */
3254 GetFocus() == 0, /* win9x */
3255 "wrong focus window %p\n", GetFocus());
3260 ShowWindow(mdi_child2
, SW_HIDE
);
3261 ok_sequence(WmHideChildSeq
, "ShowWindow(SW_HIDE):MDI child", FALSE
);
3263 ShowWindow(mdi_child2
, SW_RESTORE
);
3264 ok_sequence(WmRestoreMDIchildInisibleSeq
, "ShowWindow(SW_RESTORE):invisible MDI child", FALSE
);
3267 ok(GetWindowLongA(mdi_child2
, GWL_STYLE
) & WS_VISIBLE
, "MDI child should be visible\n");
3268 ok(IsWindowVisible(mdi_child2
), "MDI child should be visible\n");
3270 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3271 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
3272 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
3278 ShowWindow(mdi_child2
, SW_HIDE
);
3279 ok_sequence(WmHideChildSeq
, "ShowWindow(SW_HIDE):MDI child", FALSE
);
3281 ShowWindow(mdi_child2
, SW_SHOW
);
3282 ok_sequence(WmShowChildSeq
, "ShowWindow(SW_SHOW):MDI child", FALSE
);
3284 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3285 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3287 ShowWindow(mdi_child2
, SW_MAXIMIZE
);
3288 ok_sequence(WmMaximizeMDIchildVisibleSeq
, "ShowWindow(SW_MAXIMIZE):MDI child", FALSE
);
3290 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3291 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3293 ShowWindow(mdi_child2
, SW_RESTORE
);
3294 ok_sequence(WmRestoreMDIchildVisibleSeq
, "ShowWindow(SW_RESTORE):maximized MDI child", FALSE
);
3296 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3297 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3299 ShowWindow(mdi_child2
, SW_MINIMIZE
);
3300 ok_sequence(WmMinimizeMDIchildVisibleSeq
, "ShowWindow(SW_MINIMIZE):MDI child", TRUE
);
3302 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3303 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3305 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3306 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
3307 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
3310 ShowWindow(mdi_child2
, SW_RESTORE
);
3311 ok_sequence(WmRestoreMDIchildVisibleSeq_2
, "ShowWindow(SW_RESTORE):minimized MDI child", TRUE
);
3313 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3314 ok(GetFocus() == mdi_child2
, "wrong focus window %p\n", GetFocus());
3316 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3317 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
3318 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
3324 ShowWindow(mdi_child2
, SW_HIDE
);
3325 ok_sequence(WmHideChildSeq
, "ShowWindow(SW_HIDE):MDI child", FALSE
);
3327 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3328 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3330 DestroyWindow(mdi_child2
);
3331 ok_sequence(WmDestroyMDIchildInvisibleSeq
, "Destroy invisible MDI child window", FALSE
);
3333 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3334 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3336 /* test for maximized MDI children */
3337 trace("creating maximized visible MDI child window 1\n");
3338 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3339 WS_CHILD
| WS_VISIBLE
| WS_MAXIMIZEBOX
| WS_MAXIMIZE
,
3340 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
3341 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3343 ok_sequence(WmCreateMDIchildVisibleMaxSeq1
, "Create maximized visible 1st MDI child window", TRUE
);
3344 ok(IsZoomed(mdi_child
), "1st MDI child should be maximized\n");
3346 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3347 ok(GetFocus() == mdi_child
|| /* win2k */
3348 GetFocus() == 0, /* win9x */
3349 "wrong focus window %p\n", GetFocus());
3351 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3352 ok(active_child
== mdi_child
, "wrong active MDI child %p\n", active_child
);
3353 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
3356 trace("creating maximized visible MDI child window 2\n");
3357 mdi_child2
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3358 WS_CHILD
| WS_VISIBLE
| WS_MAXIMIZEBOX
| WS_MAXIMIZE
,
3359 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
3360 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3362 ok_sequence(WmCreateMDIchildVisibleMaxSeq2
, "Create maximized visible 2nd MDI child 2 window", TRUE
);
3363 ok(IsZoomed(mdi_child2
), "2nd MDI child should be maximized\n");
3364 ok(!IsZoomed(mdi_child
), "1st MDI child should NOT be maximized\n");
3366 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3367 ok(GetFocus() == mdi_child2
, "wrong focus window %p\n", GetFocus());
3369 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3370 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
3371 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
3374 trace("destroying maximized visible MDI child window 2\n");
3375 DestroyWindow(mdi_child2
);
3376 ok_sequence(WmDestroyMDIchildVisibleSeq
, "Destroy visible MDI child window", TRUE
);
3378 ok(!IsZoomed(mdi_child
), "1st MDI child should NOT be maximized\n");
3380 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3381 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3383 /* Win2k: MDI client still returns a just destroyed child as active
3384 * Win9x: MDI client returns 0
3386 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3387 ok(active_child
== mdi_child2
|| /* win2k */
3388 !active_child
, /* win9x */
3389 "wrong active MDI child %p\n", active_child
);
3392 ShowWindow(mdi_child
, SW_MAXIMIZE
);
3393 ok(IsZoomed(mdi_child
), "1st MDI child should be maximized\n");
3396 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3397 ok(GetFocus() == mdi_child
, "wrong focus window %p\n", GetFocus());
3399 trace("re-creating maximized visible MDI child window 2\n");
3400 mdi_child2
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3401 WS_CHILD
| WS_VISIBLE
| WS_MAXIMIZEBOX
| WS_MAXIMIZE
,
3402 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
3403 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3405 ok_sequence(WmCreateMDIchildVisibleMaxSeq2
, "Create maximized visible 2nd MDI child 2 window", TRUE
);
3406 ok(IsZoomed(mdi_child2
), "2nd MDI child should be maximized\n");
3407 ok(!IsZoomed(mdi_child
), "1st MDI child should NOT be maximized\n");
3409 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3410 ok(GetFocus() == mdi_child2
, "wrong focus window %p\n", GetFocus());
3412 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3413 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
3414 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
3417 SendMessageA(mdi_child2
, WM_SYSCOMMAND
, SC_CLOSE
, 0);
3418 ok_sequence(WmDestroyMDIchildVisibleMaxSeq2
, "WM_SYSCOMMAND/SC_CLOSE on a visible maximized MDI child window", TRUE
);
3419 ok(!IsWindow(mdi_child2
), "MDI child 2 should be destroyed\n");
3421 ok(IsZoomed(mdi_child
), "1st MDI child should be maximized\n");
3422 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3423 ok(GetFocus() == mdi_child
, "wrong focus window %p\n", GetFocus());
3425 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3426 ok(active_child
== mdi_child
, "wrong active MDI child %p\n", active_child
);
3427 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
3430 DestroyWindow(mdi_child
);
3431 ok_sequence(WmDestroyMDIchildVisibleSeq
, "Destroy visible MDI child window", TRUE
);
3433 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3434 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3436 /* Win2k: MDI client still returns a just destroyed child as active
3437 * Win9x: MDI client returns 0
3439 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3440 ok(active_child
== mdi_child
|| /* win2k */
3441 !active_child
, /* win9x */
3442 "wrong active MDI child %p\n", active_child
);
3445 trace("creating maximized invisible MDI child window\n");
3446 mdi_child2
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3447 WS_CHILD
| WS_MAXIMIZE
| WS_CAPTION
| WS_THICKFRAME
,
3448 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
3449 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3451 ok_sequence(WmCreateMDIchildInvisibleMaxSeq4
, "Create maximized invisible MDI child window", FALSE
);
3452 ok(IsZoomed(mdi_child2
), "MDI child should be maximized\n");
3453 ok(!(GetWindowLongA(mdi_child2
, GWL_STYLE
) & WS_VISIBLE
), "MDI child should be not visible\n");
3454 ok(!IsWindowVisible(mdi_child2
), "MDI child should be not visible\n");
3456 /* Win2k: MDI client still returns a just destroyed child as active
3457 * Win9x: MDI client returns 0
3459 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3460 ok(active_child
== mdi_child
|| /* win2k */
3461 !active_child
, /* win9x */
3462 "wrong active MDI child %p\n", active_child
);
3465 trace("call ShowWindow(mdi_child, SW_MAXIMIZE)\n");
3466 ShowWindow(mdi_child2
, SW_MAXIMIZE
);
3467 ok_sequence(WmMaximizeMDIchildInvisibleSeq2
, "ShowWindow(SW_MAXIMIZE):invisible maximized MDI child", FALSE
);
3468 ok(IsZoomed(mdi_child2
), "MDI child should be maximized\n");
3469 ok(GetWindowLongA(mdi_child2
, GWL_STYLE
) & WS_VISIBLE
, "MDI child should be visible\n");
3470 ok(IsWindowVisible(mdi_child2
), "MDI child should be visible\n");
3472 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3473 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
3474 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
3477 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child2
, 0);
3480 /* end of test for maximized MDI children */
3483 trace("creating maximized visible MDI child window 1(Switch test)\n");
3484 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3485 WS_CHILD
| WS_VISIBLE
| WS_MAXIMIZEBOX
| WS_MAXIMIZE
,
3486 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
3487 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3489 ok_sequence(WmCreateMDIchildVisibleMaxSeq1
, "Create maximized visible 1st MDI child window(Switch test)", TRUE
);
3490 ok(IsZoomed(mdi_child
), "1st MDI child should be maximized(Switch test)\n");
3492 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p(Switch test)\n", GetActiveWindow());
3493 ok(GetFocus() == mdi_child
|| /* win2k */
3494 GetFocus() == 0, /* win9x */
3495 "wrong focus window %p(Switch test)\n", GetFocus());
3497 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3498 ok(active_child
== mdi_child
, "wrong active MDI child %p(Switch test)\n", active_child
);
3499 ok(zoomed
, "wrong zoomed state %d(Switch test)\n", zoomed
);
3502 trace("creating maximized visible MDI child window 2(Switch test)\n");
3503 mdi_child2
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3504 WS_CHILD
| WS_VISIBLE
| WS_MAXIMIZEBOX
| WS_MAXIMIZE
,
3505 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
3506 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3508 ok_sequence(WmCreateMDIchildVisibleMaxSeq2
, "Create maximized visible 2nd MDI child window (Switch test)", TRUE
);
3510 ok(IsZoomed(mdi_child2
), "2nd MDI child should be maximized(Switch test)\n");
3511 ok(!IsZoomed(mdi_child
), "1st MDI child should NOT be maximized(Switch test)\n");
3513 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p(Switch test)\n", GetActiveWindow());
3514 ok(GetFocus() == mdi_child2
, "wrong focus window %p(Switch test)\n", GetFocus());
3516 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3517 ok(active_child
== mdi_child2
, "wrong active MDI child %p(Switch test)\n", active_child
);
3518 ok(zoomed
, "wrong zoomed state %d(Switch test)\n", zoomed
);
3521 trace("Switch child window.\n");
3522 SendMessageA(mdi_client
, WM_MDIACTIVATE
, (WPARAM
)mdi_child
, 0);
3523 ok_sequence(WmSwitchChild
, "Child did not switch correctly", TRUE
);
3524 trace("end of test for switch maximized MDI children\n");
3527 /* Prepare for switching test of not maximized MDI children */
3528 ShowWindow( mdi_child
, SW_NORMAL
);
3529 ok(!IsZoomed(mdi_child
), "wrong zoomed state for %p(Switch test)\n", mdi_child
);
3530 ok(!IsZoomed(mdi_child2
), "wrong zoomed state for %p(Switch test)\n", mdi_child2
);
3531 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, 0);
3532 ok(active_child
== mdi_child
, "wrong active MDI child %p(Switch test)\n", active_child
);
3535 SendMessageA(mdi_client
, WM_MDIACTIVATE
, (WPARAM
)mdi_child2
, 0);
3536 ok_sequence(WmSwitchNotMaximizedChild
, "Not maximized child did not switch correctly", FALSE
);
3537 trace("end of test for switch not maximized MDI children\n");
3540 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
3543 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child2
, 0);
3548 /* end of tests for switch maximized/not maximized MDI children */
3550 mdi_cs
.szClass
= "MDI_child_Class";
3551 mdi_cs
.szTitle
= "MDI child";
3552 mdi_cs
.hOwner
= GetModuleHandleA(0);
3555 mdi_cs
.cx
= CW_USEDEFAULT
;
3556 mdi_cs
.cy
= CW_USEDEFAULT
;
3557 mdi_cs
.style
= WS_CHILD
| WS_SYSMENU
| WS_VISIBLE
| WS_MAXIMIZEBOX
| WS_MAXIMIZE
;
3559 mdi_child
= (HWND
)SendMessageA(mdi_client
, WM_MDICREATE
, 0, (LPARAM
)&mdi_cs
);
3560 ok(mdi_child
!= 0, "MDI child creation failed\n");
3561 ok_sequence(WmCreateMDIchildVisibleMaxSeq3
, "WM_MDICREATE for maximized visible MDI child window", TRUE
);
3563 ok(GetMenuItemID(hMenu
, GetMenuItemCount(hMenu
) - 1) == SC_CLOSE
, "SC_CLOSE menu item not found\n");
3565 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3566 ok(active_child
== mdi_child
, "wrong active MDI child %p\n", active_child
);
3568 ok(IsZoomed(mdi_child
), "MDI child should be maximized\n");
3569 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3570 ok(GetFocus() == mdi_child
, "wrong focus window %p\n", GetFocus());
3572 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3573 ok(active_child
== mdi_child
, "wrong active MDI child %p\n", active_child
);
3574 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
3577 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
3578 ok_sequence(WmDestroyMDIchildVisibleMaxSeq1
, "Destroy visible maximized MDI child window", TRUE
);
3580 ok(!IsWindow(mdi_child
), "MDI child should be destroyed\n");
3581 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3582 ok(!active_child
, "wrong active MDI child %p\n", active_child
);
3587 DestroyWindow(mdi_client
);
3588 ok_sequence(WmDestroyMDIclientSeq
, "Destroy MDI client window", FALSE
);
3590 /* test maximization of MDI child with invisible parent */
3591 client_cs
.hWindowMenu
= 0;
3592 mdi_client
= CreateWindow("MDI_client_class",
3594 WS_CHILD
| WS_CLIPCHILDREN
| WS_VSCROLL
| WS_HSCROLL
| WS_VISIBLE
,
3596 mdi_frame
, 0, GetModuleHandleA(0), &client_cs
);
3597 ok_sequence(WmCreateMDIclientSeq
, "Create MDI client window", FALSE
);
3599 ShowWindow(mdi_client
, SW_HIDE
);
3600 ok_sequence(WmHideMDIclientSeq
, "Hide MDI client window", FALSE
);
3602 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3603 WS_CHILD
| WS_CLIPCHILDREN
| WS_VSCROLL
| WS_HSCROLL
,
3605 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3606 ok_sequence(WmCreateMDIchildInvisibleParentSeq
, "Create MDI child window with invisible parent", FALSE
);
3608 SendMessage(mdi_client
, WM_MDIMAXIMIZE
, (WPARAM
) mdi_child
, 0);
3609 ok_sequence(WmMaximizeMDIchildInvisibleParentSeq
, "Maximize MDI child window with invisible parent", TRUE
);
3610 zoomed
= IsZoomed(mdi_child
);
3611 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
3613 ShowWindow(mdi_client
, SW_SHOW
);
3614 ok_sequence(WmShowMDIclientSeq
, "Show MDI client window", FALSE
);
3616 DestroyWindow(mdi_child
);
3617 ok_sequence(WmDestroyMDIchildVisibleSeq
, "Destroy visible maximized MDI child window", TRUE
);
3619 /* end of test for maximization of MDI child with invisible parent */
3621 DestroyWindow(mdi_client
);
3622 ok_sequence(WmDestroyMDIclientSeq
, "Destroy MDI client window", FALSE
);
3624 DestroyWindow(mdi_frame
);
3625 ok_sequence(WmDestroyMDIframeSeq
, "Destroy MDI frame window", FALSE
);
3627 /************************* End of MDI test **********************************/
3629 static void test_WM_SETREDRAW(HWND hwnd
)
3631 DWORD style
= GetWindowLongA(hwnd
, GWL_STYLE
);
3636 SendMessageA(hwnd
, WM_SETREDRAW
, FALSE
, 0);
3637 ok_sequence(WmSetRedrawFalseSeq
, "SetRedraw:FALSE", FALSE
);
3639 ok(!(GetWindowLongA(hwnd
, GWL_STYLE
) & WS_VISIBLE
), "WS_VISIBLE should NOT be set\n");
3640 ok(!IsWindowVisible(hwnd
), "IsWindowVisible() should return FALSE\n");
3643 SendMessageA(hwnd
, WM_SETREDRAW
, TRUE
, 0);
3644 ok_sequence(WmSetRedrawTrueSeq
, "SetRedraw:TRUE", FALSE
);
3646 ok(GetWindowLongA(hwnd
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
3647 ok(IsWindowVisible(hwnd
), "IsWindowVisible() should return TRUE\n");
3649 /* restore original WS_VISIBLE state */
3650 SetWindowLongA(hwnd
, GWL_STYLE
, style
);
3656 static INT_PTR CALLBACK
TestModalDlgProcA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
3660 trace("dialog: %p, %04x, %08lx, %08lx\n", hwnd
, message
, wParam
, lParam
);
3662 /* explicitly ignore WM_GETICON message */
3663 if (message
== WM_GETICON
) return 0;
3665 /* ignore registered messages */
3666 if (message
>= 0xc000) return 0;
3673 case WM_DEVICECHANGE
:
3678 case WM_WINDOWPOSCHANGING
:
3679 case WM_WINDOWPOSCHANGED
:
3681 WINDOWPOS
*winpos
= (WINDOWPOS
*)lParam
;
3683 trace("%s\n", (message
== WM_WINDOWPOSCHANGING
) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
3684 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x ",
3685 winpos
->hwnd
, winpos
->hwndInsertAfter
,
3686 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
3687 dump_winpos_flags(winpos
->flags
);
3689 /* Log only documented flags, win2k uses 0x1000 and 0x2000
3690 * in the high word for internal purposes
3692 wParam
= winpos
->flags
& 0xffff;
3693 /* We are not interested in the flags that don't match under XP and Win9x */
3694 wParam
&= ~(SWP_NOZORDER
);
3699 msg
.message
= message
;
3700 msg
.flags
= sent
|wparam
|lparam
;
3701 msg
.wParam
= wParam
;
3702 msg
.lParam
= lParam
;
3705 if (message
== WM_INITDIALOG
) SetTimer( hwnd
, 1, 100, NULL
);
3706 if (message
== WM_TIMER
) EndDialog( hwnd
, 0 );
3710 static void test_hv_scroll_1(HWND hwnd
, INT ctl
, DWORD clear
, DWORD set
, INT min
, INT max
)
3712 DWORD style
, exstyle
;
3716 exstyle
= GetWindowLongA(hwnd
, GWL_EXSTYLE
);
3717 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
3718 /* do not be confused by WS_DLGFRAME set */
3719 if ((style
& WS_CAPTION
) == WS_CAPTION
) style
&= ~WS_CAPTION
;
3721 if (clear
) ok(style
& clear
, "style %08x should be set\n", clear
);
3722 if (set
) ok(!(style
& set
), "style %08x should not be set\n", set
);
3724 ret
= SetScrollRange(hwnd
, ctl
, min
, max
, FALSE
);
3725 ok( ret
, "SetScrollRange(%d) error %d\n", ctl
, GetLastError());
3726 if ((style
& (WS_DLGFRAME
| WS_BORDER
| WS_THICKFRAME
)) || (exstyle
& WS_EX_DLGMODALFRAME
))
3727 ok_sequence(WmSetScrollRangeHV_NC_Seq
, "SetScrollRange(SB_HORZ/SB_VERT) NC", FALSE
);
3729 ok_sequence(WmSetScrollRangeHVSeq
, "SetScrollRange(SB_HORZ/SB_VERT)", FALSE
);
3731 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
3732 if (set
) ok(style
& set
, "style %08x should be set\n", set
);
3733 if (clear
) ok(!(style
& clear
), "style %08x should not be set\n", clear
);
3735 /* a subsequent call should do nothing */
3736 ret
= SetScrollRange(hwnd
, ctl
, min
, max
, FALSE
);
3737 ok( ret
, "SetScrollRange(%d) error %d\n", ctl
, GetLastError());
3738 ok_sequence(WmEmptySeq
, "SetScrollRange(SB_HORZ/SB_VERT) empty sequence", FALSE
);
3742 trace("Ignore GetScrollRange error below if you are on Win9x\n");
3743 ret
= GetScrollRange(hwnd
, ctl
, &xmin
, &xmax
);
3744 ok( ret
, "GetScrollRange(%d) error %d\n", ctl
, GetLastError());
3745 ok_sequence(WmEmptySeq
, "GetScrollRange(SB_HORZ/SB_VERT) empty sequence", FALSE
);
3746 ok(xmin
== min
, "unexpected min scroll value %d\n", xmin
);
3747 ok(xmax
== max
, "unexpected max scroll value %d\n", xmax
);
3750 static void test_hv_scroll_2(HWND hwnd
, INT ctl
, DWORD clear
, DWORD set
, INT min
, INT max
)
3752 DWORD style
, exstyle
;
3756 exstyle
= GetWindowLongA(hwnd
, GWL_EXSTYLE
);
3757 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
3758 /* do not be confused by WS_DLGFRAME set */
3759 if ((style
& WS_CAPTION
) == WS_CAPTION
) style
&= ~WS_CAPTION
;
3761 if (clear
) ok(style
& clear
, "style %08x should be set\n", clear
);
3762 if (set
) ok(!(style
& set
), "style %08x should not be set\n", set
);
3764 si
.cbSize
= sizeof(si
);
3765 si
.fMask
= SIF_RANGE
;
3768 SetScrollInfo(hwnd
, ctl
, &si
, TRUE
);
3769 if ((style
& (WS_DLGFRAME
| WS_BORDER
| WS_THICKFRAME
)) || (exstyle
& WS_EX_DLGMODALFRAME
))
3770 ok_sequence(WmSetScrollRangeHV_NC_Seq
, "SetScrollInfo(SB_HORZ/SB_VERT) NC", FALSE
);
3772 ok_sequence(WmSetScrollRangeHVSeq
, "SetScrollInfo(SB_HORZ/SB_VERT)", FALSE
);
3774 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
3775 if (set
) ok(style
& set
, "style %08x should be set\n", set
);
3776 if (clear
) ok(!(style
& clear
), "style %08x should not be set\n", clear
);
3778 /* a subsequent call should do nothing */
3779 SetScrollInfo(hwnd
, ctl
, &si
, TRUE
);
3780 if (style
& WS_HSCROLL
)
3781 ok_sequence(WmSetScrollRangeHSeq_empty
, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE
);
3782 else if (style
& WS_VSCROLL
)
3783 ok_sequence(WmSetScrollRangeVSeq_empty
, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE
);
3785 ok_sequence(WmEmptySeq
, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE
);
3787 si
.fMask
= SIF_PAGE
;
3789 SetScrollInfo(hwnd
, ctl
, &si
, FALSE
);
3790 ok_sequence(WmEmptySeq
, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE
);
3794 SetScrollInfo(hwnd
, ctl
, &si
, FALSE
);
3795 ok_sequence(WmEmptySeq
, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE
);
3797 si
.fMask
= SIF_RANGE
;
3798 si
.nMin
= 0xdeadbeef;
3799 si
.nMax
= 0xdeadbeef;
3800 ret
= GetScrollInfo(hwnd
, ctl
, &si
);
3801 ok( ret
, "GetScrollInfo error %d\n", GetLastError());
3802 ok_sequence(WmEmptySeq
, "GetScrollRange(SB_HORZ/SB_VERT) empty sequence", FALSE
);
3803 ok(si
.nMin
== min
, "unexpected min scroll value %d\n", si
.nMin
);
3804 ok(si
.nMax
== max
, "unexpected max scroll value %d\n", si
.nMax
);
3807 /* Win9x sends WM_USER+xxx while and NT versions send SBM_xxx messages */
3808 static void test_scroll_messages(HWND hwnd
)
3819 ret
= GetScrollRange(hwnd
, SB_CTL
, &min
, &max
);
3820 ok( ret
, "GetScrollRange error %d\n", GetLastError());
3821 if (sequence
->message
!= WmGetScrollRangeSeq
[0].message
)
3822 trace("GetScrollRange(SB_CTL) generated unknown message %04x\n", sequence
->message
);
3823 /* values of min and max are undefined */
3826 ret
= SetScrollRange(hwnd
, SB_CTL
, 10, 150, FALSE
);
3827 ok( ret
, "SetScrollRange error %d\n", GetLastError());
3828 if (sequence
->message
!= WmSetScrollRangeSeq
[0].message
)
3829 trace("SetScrollRange(SB_CTL) generated unknown message %04x\n", sequence
->message
);
3834 ret
= GetScrollRange(hwnd
, SB_CTL
, &min
, &max
);
3835 ok( ret
, "GetScrollRange error %d\n", GetLastError());
3836 if (sequence
->message
!= WmGetScrollRangeSeq
[0].message
)
3837 trace("GetScrollRange(SB_CTL) generated unknown message %04x\n", sequence
->message
);
3838 /* values of min and max are undefined */
3841 si
.cbSize
= sizeof(si
);
3842 si
.fMask
= SIF_RANGE
;
3845 SetScrollInfo(hwnd
, SB_CTL
, &si
, FALSE
);
3846 if (sequence
->message
!= WmSetScrollRangeSeq
[0].message
)
3847 trace("SetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence
->message
);
3850 si
.fMask
= SIF_PAGE
;
3852 SetScrollInfo(hwnd
, SB_CTL
, &si
, FALSE
);
3853 if (sequence
->message
!= WmSetScrollRangeSeq
[0].message
)
3854 trace("SetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence
->message
);
3859 SetScrollInfo(hwnd
, SB_CTL
, &si
, FALSE
);
3860 if (sequence
->message
!= WmSetScrollRangeSeq
[0].message
)
3861 trace("SetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence
->message
);
3864 si
.fMask
= SIF_RANGE
;
3865 si
.nMin
= 0xdeadbeef;
3866 si
.nMax
= 0xdeadbeef;
3867 ret
= GetScrollInfo(hwnd
, SB_CTL
, &si
);
3868 ok( ret
, "GetScrollInfo error %d\n", GetLastError());
3869 if (sequence
->message
!= WmGetScrollInfoSeq
[0].message
)
3870 trace("GetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence
->message
);
3871 /* values of min and max are undefined */
3874 /* set WS_HSCROLL */
3875 test_hv_scroll_1(hwnd
, SB_HORZ
, 0, WS_HSCROLL
, 10, 150);
3876 /* clear WS_HSCROLL */
3877 test_hv_scroll_1(hwnd
, SB_HORZ
, WS_HSCROLL
, 0, 0, 0);
3879 /* set WS_HSCROLL */
3880 test_hv_scroll_2(hwnd
, SB_HORZ
, 0, WS_HSCROLL
, 10, 150);
3881 /* clear WS_HSCROLL */
3882 test_hv_scroll_2(hwnd
, SB_HORZ
, WS_HSCROLL
, 0, 0, 0);
3884 /* set WS_VSCROLL */
3885 test_hv_scroll_1(hwnd
, SB_VERT
, 0, WS_VSCROLL
, 10, 150);
3886 /* clear WS_VSCROLL */
3887 test_hv_scroll_1(hwnd
, SB_VERT
, WS_VSCROLL
, 0, 0, 0);
3889 /* set WS_VSCROLL */
3890 test_hv_scroll_2(hwnd
, SB_VERT
, 0, WS_VSCROLL
, 10, 150);
3891 /* clear WS_VSCROLL */
3892 test_hv_scroll_2(hwnd
, SB_VERT
, WS_VSCROLL
, 0, 0, 0);
3895 static void test_showwindow(void)
3900 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW
,
3901 100, 100, 200, 200, 0, 0, 0, NULL
);
3902 ok (hwnd
!= 0, "Failed to create overlapped window\n");
3903 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
3904 0, 0, 10, 10, hwnd
, 0, 0, NULL
);
3905 ok (hchild
!= 0, "Failed to create child\n");
3908 /* ShowWindow( SW_SHOWNA) for invisible top level window */
3909 trace("calling ShowWindow( SW_SHOWNA) for invisible top level window\n");
3910 ok( ShowWindow(hwnd
, SW_SHOWNA
) == FALSE
, "ShowWindow: window was visible\n" );
3911 ok_sequence(WmSHOWNATopInvisible
, "ShowWindow(SW_SHOWNA) on invisible top level window", TRUE
);
3914 /* ShowWindow( SW_SHOWNA) for now visible top level window */
3915 trace("calling ShowWindow( SW_SHOWNA) for now visible top level window\n");
3916 ok( ShowWindow(hwnd
, SW_SHOWNA
) != FALSE
, "ShowWindow: window was invisible\n" );
3917 ok_sequence(WmSHOWNATopVisible
, "ShowWindow(SW_SHOWNA) on visible top level window", FALSE
);
3919 /* back to invisible */
3920 ShowWindow(hchild
, SW_HIDE
);
3921 ShowWindow(hwnd
, SW_HIDE
);
3923 /* ShowWindow(SW_SHOWNA) with child and parent invisible */
3924 trace("calling ShowWindow( SW_SHOWNA) for invisible child with invisible parent\n");
3925 ok( ShowWindow(hchild
, SW_SHOWNA
) == FALSE
, "ShowWindow: window was visible\n" );
3926 ok_sequence(WmSHOWNAChildInvisParInvis
, "ShowWindow(SW_SHOWNA) invisible child and parent", FALSE
);
3928 /* ShowWindow(SW_SHOWNA) with child visible and parent invisible */
3929 ok( ShowWindow(hchild
, SW_SHOW
) != FALSE
, "ShowWindow: window was invisible\n" );
3931 trace("calling ShowWindow( SW_SHOWNA) for the visible child and invisible parent\n");
3932 ok( ShowWindow(hchild
, SW_SHOWNA
) != FALSE
, "ShowWindow: window was invisible\n" );
3933 ok_sequence(WmSHOWNAChildVisParInvis
, "ShowWindow(SW_SHOWNA) visible child and invisible parent", FALSE
);
3935 /* ShowWindow(SW_SHOWNA) with child visible and parent visible */
3936 ShowWindow( hwnd
, SW_SHOW
);
3938 trace("calling ShowWindow( SW_SHOWNA) for the visible child and parent\n");
3939 ok( ShowWindow(hchild
, SW_SHOWNA
) != FALSE
, "ShowWindow: window was invisible\n" );
3940 ok_sequence(WmSHOWNAChildVisParVis
, "ShowWindow(SW_SHOWNA) for the visible child and parent", FALSE
);
3943 /* ShowWindow(SW_SHOWNA) with child invisible and parent visible */
3944 ShowWindow( hchild
, SW_HIDE
);
3946 trace("calling ShowWindow( SW_SHOWNA) for the invisible child and visible parent\n");
3947 ok( ShowWindow(hchild
, SW_SHOWNA
) == FALSE
, "ShowWindow: window was visible\n" );
3948 ok_sequence(WmSHOWNAChildInvisParVis
, "ShowWindow(SW_SHOWNA) for the invisible child and visible parent", FALSE
);
3952 ok(GetCapture() == hchild
, "wrong capture window %p\n", GetCapture());
3953 DestroyWindow(hchild
);
3954 ok(!GetCapture(), "wrong capture window %p\n", GetCapture());
3956 DestroyWindow(hwnd
);
3961 * 1. Create invisible maximized popup window.
3962 * 2. Move and resize it.
3963 * 3. Show it maximized.
3965 trace("calling CreateWindowExA( WS_MAXIMIZE ) for invisible maximized popup window\n");
3966 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP
| WS_MAXIMIZE
,
3967 100, 100, 200, 200, 0, 0, 0, NULL
);
3968 ok (hwnd
!= 0, "Failed to create popup window\n");
3969 ok(IsZoomed(hwnd
), "window should be maximized\n");
3970 ok_sequence(WmCreateInvisibleMaxPopupSeq
, "CreateWindow(WS_MAXIMIZED):popup", FALSE
);
3973 GetWindowRect(hwnd
, &rc
);
3974 ok( rc
.right
-rc
.left
== GetSystemMetrics(SM_CXSCREEN
) &&
3975 rc
.bottom
-rc
.top
== GetSystemMetrics(SM_CYSCREEN
),
3976 "Invalid maximized size before ShowWindow (%d,%d)-(%d,%d)\n",
3977 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
3978 /* Reset window's size & position */
3979 SetWindowPos(hwnd
, 0, 10, 10, 200, 200, SWP_NOZORDER
| SWP_NOACTIVATE
);
3980 ok(IsZoomed(hwnd
), "window should be maximized\n");
3983 trace("calling ShowWindow( SW_SHOWMAXIMIZE ) for invisible maximized popup window\n");
3984 ShowWindow(hwnd
, SW_SHOWMAXIMIZED
);
3985 ok(IsZoomed(hwnd
), "window should be maximized\n");
3986 ok_sequence(WmShowMaxPopupResizedSeq
, "ShowWindow(SW_SHOWMAXIMIZED):invisible maximized and resized popup", FALSE
);
3989 GetWindowRect(hwnd
, &rc
);
3990 ok( rc
.right
-rc
.left
== GetSystemMetrics(SM_CXSCREEN
) &&
3991 rc
.bottom
-rc
.top
== GetSystemMetrics(SM_CYSCREEN
),
3992 "Invalid maximized size after ShowWindow (%d,%d)-(%d,%d)\n",
3993 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
3994 DestroyWindow(hwnd
);
3998 * 1. Create invisible maximized popup window.
3999 * 2. Show it maximized.
4001 trace("calling CreateWindowExA( WS_MAXIMIZE ) for invisible maximized popup window\n");
4002 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP
| WS_MAXIMIZE
,
4003 100, 100, 200, 200, 0, 0, 0, NULL
);
4004 ok (hwnd
!= 0, "Failed to create popup window\n");
4005 ok(IsZoomed(hwnd
), "window should be maximized\n");
4006 ok_sequence(WmCreateInvisibleMaxPopupSeq
, "CreateWindow(WS_MAXIMIZED):popup", FALSE
);
4009 trace("calling ShowWindow( SW_SHOWMAXIMIZE ) for invisible maximized popup window\n");
4010 ShowWindow(hwnd
, SW_SHOWMAXIMIZED
);
4011 ok(IsZoomed(hwnd
), "window should be maximized\n");
4012 ok_sequence(WmShowMaxPopupSeq
, "ShowWindow(SW_SHOWMAXIMIZED):invisible maximized popup", FALSE
);
4014 DestroyWindow(hwnd
);
4018 * 1. Create visible maximized popup window.
4020 trace("calling CreateWindowExA( WS_MAXIMIZE ) for maximized popup window\n");
4021 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP
| WS_MAXIMIZE
| WS_VISIBLE
,
4022 100, 100, 200, 200, 0, 0, 0, NULL
);
4023 ok (hwnd
!= 0, "Failed to create popup window\n");
4024 ok(IsZoomed(hwnd
), "window should be maximized\n");
4025 ok_sequence(WmCreateMaxPopupSeq
, "CreateWindow(WS_MAXIMIZED):popup", FALSE
);
4027 DestroyWindow(hwnd
);
4031 * 1. Create visible popup window.
4034 trace("calling CreateWindowExA( WS_VISIBLE ) for popup window\n");
4035 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP
| WS_VISIBLE
,
4036 100, 100, 200, 200, 0, 0, 0, NULL
);
4037 ok (hwnd
!= 0, "Failed to create popup window\n");
4038 ok(!IsZoomed(hwnd
), "window should NOT be maximized\n");
4039 ok_sequence(WmCreatePopupSeq
, "CreateWindow(WS_VISIBLE):popup", FALSE
);
4042 trace("calling ShowWindow( SW_SHOWMAXIMIZE ) for visible popup window\n");
4043 ShowWindow(hwnd
, SW_SHOWMAXIMIZED
);
4044 ok(IsZoomed(hwnd
), "window should be maximized\n");
4045 ok_sequence(WmShowVisMaxPopupSeq
, "ShowWindow(SW_SHOWMAXIMIZED):popup", FALSE
);
4047 DestroyWindow(hwnd
);
4051 static void test_sys_menu(void)
4057 hwnd
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
4058 100, 100, 200, 200, 0, 0, 0, NULL
);
4059 ok (hwnd
!= 0, "Failed to create overlapped window\n");
4063 /* test existing window without CS_NOCLOSE style */
4064 hmenu
= GetSystemMenu(hwnd
, FALSE
);
4065 ok(hmenu
!= 0, "GetSystemMenu error %d\n", GetLastError());
4067 state
= GetMenuState(hmenu
, SC_CLOSE
, MF_BYCOMMAND
);
4068 ok(state
!= 0xffffffff, "wrong SC_CLOSE state %x\n", state
);
4069 ok(!(state
& (MF_DISABLED
| MF_GRAYED
)), "wrong SC_CLOSE state %x\n", state
);
4071 EnableMenuItem(hmenu
, SC_CLOSE
, MF_BYCOMMAND
| MF_GRAYED
);
4072 ok_sequence(WmEmptySeq
, "WmEnableMenuItem", FALSE
);
4074 state
= GetMenuState(hmenu
, SC_CLOSE
, MF_BYCOMMAND
);
4075 ok(state
!= 0xffffffff, "wrong SC_CLOSE state %x\n", state
);
4076 ok((state
& (MF_DISABLED
| MF_GRAYED
)) == MF_GRAYED
, "wrong SC_CLOSE state %x\n", state
);
4078 EnableMenuItem(hmenu
, SC_CLOSE
, 0);
4079 ok_sequence(WmEmptySeq
, "WmEnableMenuItem", FALSE
);
4081 state
= GetMenuState(hmenu
, SC_CLOSE
, MF_BYCOMMAND
);
4082 ok(state
!= 0xffffffff, "wrong SC_CLOSE state %x\n", state
);
4083 ok(!(state
& (MF_DISABLED
| MF_GRAYED
)), "wrong SC_CLOSE state %x\n", state
);
4085 /* test whether removing WS_SYSMENU destroys a system menu */
4086 SetWindowLongW(hwnd
, GWL_STYLE
, WS_POPUP
);
4087 SetWindowPos(hwnd
, 0, 0, 0, 0, 0, SWP_NOZORDER
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_FRAMECHANGED
);
4089 hmenu
= GetSystemMenu(hwnd
, FALSE
);
4090 ok(hmenu
!= 0, "GetSystemMenu error %d\n", GetLastError());
4092 DestroyWindow(hwnd
);
4094 /* test new window with CS_NOCLOSE style */
4095 hwnd
= CreateWindowExA(0, "NoCloseWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
4096 100, 100, 200, 200, 0, 0, 0, NULL
);
4097 ok (hwnd
!= 0, "Failed to create overlapped window\n");
4099 hmenu
= GetSystemMenu(hwnd
, FALSE
);
4100 ok(hmenu
!= 0, "GetSystemMenu error %d\n", GetLastError());
4102 state
= GetMenuState(hmenu
, SC_CLOSE
, MF_BYCOMMAND
);
4103 ok(state
== 0xffffffff, "wrong SC_CLOSE state %x\n", state
);
4105 DestroyWindow(hwnd
);
4107 /* test new window without WS_SYSMENU style */
4108 hwnd
= CreateWindowExA(0, "NoCloseWindowClass", NULL
, WS_OVERLAPPEDWINDOW
& ~WS_SYSMENU
,
4109 100, 100, 200, 200, 0, 0, 0, NULL
);
4110 ok(hwnd
!= 0, "Failed to create overlapped window\n");
4112 hmenu
= GetSystemMenu(hwnd
, FALSE
);
4113 ok(!hmenu
, "GetSystemMenu error %d\n", GetLastError());
4115 DestroyWindow(hwnd
);
4118 /* For shown WS_OVERLAPPEDWINDOW */
4119 static const struct message WmSetIcon_1
[] = {
4120 { WM_SETICON
, sent
},
4121 { 0x00AE, sent
|defwinproc
|optional
}, /* XP */
4122 { WM_GETTEXT
, sent
|defwinproc
|optional
},
4123 { WM_GETTEXT
, sent
|defwinproc
|optional
}, /* XP sends a duplicate */
4127 /* For WS_POPUP and hidden WS_OVERLAPPEDWINDOW */
4128 static const struct message WmSetIcon_2
[] = {
4129 { WM_SETICON
, sent
},
4133 /* Sending undocumented 0x3B message with wparam = 0x8000000b */
4134 static const struct message WmInitEndSession
[] = {
4136 { WM_QUERYENDSESSION
, sent
|defwinproc
|wparam
|lparam
, 0, ENDSESSION_LOGOFF
},
4140 /* Sending undocumented 0x3B message with wparam = 0x0000000b */
4141 static const struct message WmInitEndSession_2
[] = {
4143 { WM_QUERYENDSESSION
, sent
|defwinproc
|wparam
|lparam
, 0, 0 },
4147 /* Sending undocumented 0x3B message with wparam = 0x80000008 */
4148 static const struct message WmInitEndSession_3
[] = {
4150 { WM_ENDSESSION
, sent
|defwinproc
|wparam
|lparam
, 0, ENDSESSION_LOGOFF
},
4154 /* Sending undocumented 0x3B message with wparam = 0x00000008 */
4155 static const struct message WmInitEndSession_4
[] = {
4157 { WM_ENDSESSION
, sent
|defwinproc
|wparam
|lparam
, 0, 0 },
4161 /* Sending undocumented 0x3B message with wparam = 0x80000001 */
4162 static const struct message WmInitEndSession_5
[] = {
4164 { WM_ENDSESSION
, sent
|defwinproc
/*|wparam*/|lparam
, 1, ENDSESSION_LOGOFF
},
4168 static const struct message WmZOrder
[] = {
4169 { WM_WINDOWPOSCHANGING
, sent
|wparam
, 0, 0 },
4170 { WM_GETMINMAXINFO
, sent
|defwinproc
|wparam
, 0, 0 },
4171 { HCBT_ACTIVATE
, hook
},
4172 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
4173 { WM_WINDOWPOSCHANGING
, sent
|wparam
, 3, 0 },
4174 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOREDRAW
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
, 0 },
4175 { WM_GETTEXT
, sent
|optional
},
4176 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
4177 { WM_ACTIVATEAPP
, sent
|wparam
, 1, 0 },
4178 { WM_NCACTIVATE
, sent
|wparam
|lparam
, 1, 0 },
4179 { WM_GETTEXT
, sent
|defwinproc
|optional
},
4180 { WM_GETTEXT
, sent
|defwinproc
|optional
},
4181 { WM_ACTIVATE
, sent
|wparam
|lparam
, 1, 0 },
4182 { HCBT_SETFOCUS
, hook
},
4183 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
4184 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
4185 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
4186 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
4187 { WM_GETTEXT
, sent
|optional
},
4188 { WM_NCCALCSIZE
, sent
|optional
},
4192 static void test_MsgWaitForMultipleObjects(HWND hwnd
)
4197 ret
= MsgWaitForMultipleObjects(0, NULL
, FALSE
, 0, QS_POSTMESSAGE
);
4198 ok(ret
== WAIT_TIMEOUT
, "MsgWaitForMultipleObjects returned %x\n", ret
);
4200 PostMessageA(hwnd
, WM_USER
, 0, 0);
4202 ret
= MsgWaitForMultipleObjects(0, NULL
, FALSE
, 0, QS_POSTMESSAGE
);
4203 ok(ret
== WAIT_OBJECT_0
, "MsgWaitForMultipleObjects returned %x\n", ret
);
4205 ok(PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
), "PeekMessage should succeed\n");
4206 ok(msg
.message
== WM_USER
, "got %04x instead of WM_USER\n", msg
.message
);
4208 ret
= MsgWaitForMultipleObjects(0, NULL
, FALSE
, 0, QS_POSTMESSAGE
);
4209 ok(ret
== WAIT_TIMEOUT
, "MsgWaitForMultipleObjects returned %x\n", ret
);
4211 PostMessageA(hwnd
, WM_USER
, 0, 0);
4213 ret
= MsgWaitForMultipleObjects(0, NULL
, FALSE
, 0, QS_POSTMESSAGE
);
4214 ok(ret
== WAIT_OBJECT_0
, "MsgWaitForMultipleObjects returned %x\n", ret
);
4216 ok(PeekMessageA( &msg
, 0, 0, 0, PM_NOREMOVE
), "PeekMessage should succeed\n");
4217 ok(msg
.message
== WM_USER
, "got %04x instead of WM_USER\n", msg
.message
);
4219 /* shows QS_POSTMESSAGE flag is cleared in the PeekMessage call */
4220 ret
= MsgWaitForMultipleObjects(0, NULL
, FALSE
, 0, QS_POSTMESSAGE
);
4221 ok(ret
== WAIT_TIMEOUT
, "MsgWaitForMultipleObjects returned %x\n", ret
);
4223 PostMessageA(hwnd
, WM_USER
, 0, 0);
4225 /* new incoming message causes it to become signaled again */
4226 ret
= MsgWaitForMultipleObjects(0, NULL
, FALSE
, 0, QS_POSTMESSAGE
);
4227 ok(ret
== WAIT_OBJECT_0
, "MsgWaitForMultipleObjects returned %x\n", ret
);
4229 ok(PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
), "PeekMessage should succeed\n");
4230 ok(msg
.message
== WM_USER
, "got %04x instead of WM_USER\n", msg
.message
);
4231 ok(PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
), "PeekMessage should succeed\n");
4232 ok(msg
.message
== WM_USER
, "got %04x instead of WM_USER\n", msg
.message
);
4235 /* test if we receive the right sequence of messages */
4236 static void test_messages(void)
4238 HWND hwnd
, hparent
, hchild
;
4239 HWND hchild2
, hbutton
;
4246 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW
,
4247 100, 100, 200, 200, 0, 0, 0, NULL
);
4248 ok (hwnd
!= 0, "Failed to create overlapped window\n");
4249 ok_sequence(WmCreateOverlappedSeq
, "CreateWindow:overlapped", FALSE
);
4251 /* test ShowWindow(SW_HIDE) on a newly created invisible window */
4252 ok( ShowWindow(hwnd
, SW_HIDE
) == FALSE
, "ShowWindow: window was visible\n" );
4253 ok_sequence(WmEmptySeq
, "ShowWindow(SW_HIDE):overlapped, invisible", FALSE
);
4255 /* test WM_SETREDRAW on a not visible top level window */
4256 test_WM_SETREDRAW(hwnd
);
4258 SetWindowPos(hwnd
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
);
4260 ok_sequence(WmSWP_ShowOverlappedSeq
, "SetWindowPos:SWP_SHOWWINDOW:overlapped", FALSE
);
4261 ok(IsWindowVisible(hwnd
), "window should be visible at this point\n");
4263 ok(GetActiveWindow() == hwnd
, "window should be active\n");
4264 ok(GetFocus() == hwnd
, "window should have input focus\n");
4265 ShowWindow(hwnd
, SW_HIDE
);
4267 ok_sequence(WmHideOverlappedSeq
, "ShowWindow(SW_HIDE):overlapped", FALSE
);
4269 ShowWindow(hwnd
, SW_SHOW
);
4271 ok_sequence(WmShowOverlappedSeq
, "ShowWindow(SW_SHOW):overlapped", TRUE
);
4273 ShowWindow(hwnd
, SW_HIDE
);
4275 ok_sequence(WmHideOverlappedSeq
, "ShowWindow(SW_HIDE):overlapped", FALSE
);
4277 ShowWindow(hwnd
, SW_SHOWMAXIMIZED
);
4279 ok_sequence(WmShowMaxOverlappedSeq
, "ShowWindow(SW_SHOWMAXIMIZED):overlapped", TRUE
);
4281 ShowWindow(hwnd
, SW_RESTORE
);
4282 ok_sequence(WmShowRestoreMaxOverlappedSeq
, "ShowWindow(SW_RESTORE):overlapped", FALSE
);
4286 ShowWindow(hwnd
, SW_MINIMIZE
);
4288 ok_sequence(WmShowMinOverlappedSeq
, "ShowWindow(SW_SHOWMINIMIZED):overlapped", TRUE
);
4291 ShowWindow(hwnd
, SW_RESTORE
);
4293 ok_sequence(WmShowRestoreMinOverlappedSeq
, "ShowWindow(SW_RESTORE):overlapped", TRUE
);
4296 ShowWindow(hwnd
, SW_SHOW
);
4298 ok_sequence(WmEmptySeq
, "ShowWindow(SW_SHOW):overlapped already visible", FALSE
);
4300 ok(GetActiveWindow() == hwnd
, "window should be active\n");
4301 ok(GetFocus() == hwnd
, "window should have input focus\n");
4302 SetWindowPos(hwnd
, 0,0,0,0,0, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
);
4303 ok_sequence(WmSWP_HideOverlappedSeq
, "SetWindowPos:SWP_HIDEWINDOW:overlapped", FALSE
);
4304 ok(!IsWindowVisible(hwnd
), "window should not be visible at this point\n");
4305 ok(GetActiveWindow() == hwnd
, "window should still be active\n");
4307 /* test WM_SETREDRAW on a visible top level window */
4308 ShowWindow(hwnd
, SW_SHOW
);
4310 test_WM_SETREDRAW(hwnd
);
4312 trace("testing scroll APIs on a visible top level window %p\n", hwnd
);
4313 test_scroll_messages(hwnd
);
4315 /* test resizing and moving */
4316 SetWindowPos( hwnd
, 0, 0, 0, 300, 300, SWP_NOMOVE
|SWP_NOACTIVATE
);
4317 ok_sequence(WmSWP_ResizeSeq
, "SetWindowPos:Resize", FALSE
);
4320 SetWindowPos( hwnd
, 0, 200, 200, 0, 0, SWP_NOSIZE
|SWP_NOACTIVATE
);
4321 ok_sequence(WmSWP_MoveSeq
, "SetWindowPos:Move", FALSE
);
4324 SetWindowPos( hwnd
, 0, 200, 200, 250, 250, SWP_NOZORDER
|SWP_NOACTIVATE
);
4325 ok_sequence(WmSWP_ResizeNoZOrder
, "SetWindowPos:WmSWP_ResizeNoZOrder", FALSE
);
4329 /* popups don't get WM_GETMINMAXINFO */
4330 SetWindowLongW( hwnd
, GWL_STYLE
, WS_VISIBLE
|WS_POPUP
);
4331 SetWindowPos( hwnd
, 0, 0, 0, 0, 0, SWP_NOZORDER
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_FRAMECHANGED
);
4333 SetWindowPos( hwnd
, 0, 0, 0, 200, 200, SWP_NOMOVE
|SWP_NOACTIVATE
);
4334 ok_sequence(WmSWP_ResizePopupSeq
, "SetWindowPos:ResizePopup", FALSE
);
4336 DestroyWindow(hwnd
);
4337 ok_sequence(WmDestroyOverlappedSeq
, "DestroyWindow:overlapped", FALSE
);
4339 hparent
= CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
4340 100, 100, 200, 200, 0, 0, 0, NULL
);
4341 ok (hparent
!= 0, "Failed to create parent window\n");
4344 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
| WS_MAXIMIZE
,
4345 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4346 ok (hchild
!= 0, "Failed to create child window\n");
4347 ok_sequence(WmCreateMaximizedChildSeq
, "CreateWindow:maximized child", FALSE
);
4348 DestroyWindow(hchild
);
4351 /* visible child window with a caption */
4352 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child",
4353 WS_CHILD
| WS_VISIBLE
| WS_CAPTION
,
4354 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4355 ok (hchild
!= 0, "Failed to create child window\n");
4356 ok_sequence(WmCreateVisibleChildSeq
, "CreateWindow:visible child", FALSE
);
4358 trace("testing scroll APIs on a visible child window %p\n", hchild
);
4359 test_scroll_messages(hchild
);
4361 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
);
4362 ok_sequence(WmShowChildSeq_4
, "SetWindowPos(SWP_SHOWWINDOW):child with a caption", FALSE
);
4364 DestroyWindow(hchild
);
4367 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
4368 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4369 ok (hchild
!= 0, "Failed to create child window\n");
4370 ok_sequence(WmCreateChildSeq
, "CreateWindow:child", FALSE
);
4372 hchild2
= CreateWindowExA(0, "SimpleWindowClass", "Test child2", WS_CHILD
,
4373 100, 100, 50, 50, hparent
, 0, 0, NULL
);
4374 ok (hchild2
!= 0, "Failed to create child2 window\n");
4377 hbutton
= CreateWindowExA(0, "TestWindowClass", "Test button", WS_CHILD
,
4378 0, 100, 50, 50, hchild
, 0, 0, NULL
);
4379 ok (hbutton
!= 0, "Failed to create button window\n");
4381 /* test WM_SETREDRAW on a not visible child window */
4382 test_WM_SETREDRAW(hchild
);
4384 ShowWindow(hchild
, SW_SHOW
);
4385 ok_sequence(WmShowChildSeq
, "ShowWindow(SW_SHOW):child", FALSE
);
4387 /* check parent messages too */
4388 log_all_parent_messages
++;
4389 ShowWindow(hchild
, SW_HIDE
);
4390 ok_sequence(WmHideChildSeq2
, "ShowWindow(SW_HIDE):child", FALSE
);
4391 log_all_parent_messages
--;
4393 ShowWindow(hchild
, SW_SHOW
);
4394 ok_sequence(WmShowChildSeq
, "ShowWindow(SW_SHOW):child", FALSE
);
4396 ShowWindow(hchild
, SW_HIDE
);
4397 ok_sequence(WmHideChildSeq
, "ShowWindow(SW_HIDE):child", FALSE
);
4399 ShowWindow(hchild
, SW_SHOW
);
4400 ok_sequence(WmShowChildSeq
, "ShowWindow(SW_SHOW):child", FALSE
);
4402 /* test WM_SETREDRAW on a visible child window */
4403 test_WM_SETREDRAW(hchild
);
4405 log_all_parent_messages
++;
4406 MoveWindow(hchild
, 10, 10, 20, 20, TRUE
);
4407 ok_sequence(WmResizingChildWithMoveWindowSeq
, "MoveWindow:child", FALSE
);
4408 log_all_parent_messages
--;
4410 ShowWindow(hchild
, SW_HIDE
);
4412 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
);
4413 ok_sequence(WmShowChildSeq_2
, "SetWindowPos:show_child_2", FALSE
);
4415 ShowWindow(hchild
, SW_HIDE
);
4417 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
);
4418 ok_sequence(WmShowChildSeq_3
, "SetWindowPos:show_child_3", FALSE
);
4420 /* DestroyWindow sequence below expects that a child has focus */
4424 DestroyWindow(hchild
);
4425 ok_sequence(WmDestroyChildSeq
, "DestroyWindow:child", FALSE
);
4426 DestroyWindow(hchild2
);
4427 DestroyWindow(hbutton
);
4430 hchild
= CreateWindowExA(0, "TestWindowClass", "Test Child Popup", WS_CHILD
| WS_POPUP
,
4431 0, 0, 100, 100, hparent
, 0, 0, NULL
);
4432 ok (hchild
!= 0, "Failed to create child popup window\n");
4433 ok_sequence(WmCreateChildPopupSeq
, "CreateWindow:child_popup", FALSE
);
4434 DestroyWindow(hchild
);
4436 /* test what happens to a window which sets WS_VISIBLE in WM_CREATE */
4438 hchild
= CreateWindowExA(0, "TestPopupClass", "Test Popup", WS_POPUP
,
4439 0, 0, 100, 100, hparent
, 0, 0, NULL
);
4440 ok (hchild
!= 0, "Failed to create popup window\n");
4441 ok_sequence(WmCreateInvisiblePopupSeq
, "CreateWindow:invisible_popup", FALSE
);
4442 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
4443 ok(IsWindowVisible(hchild
), "IsWindowVisible() should return TRUE\n");
4445 ShowWindow(hchild
, SW_SHOW
);
4446 ok_sequence(WmEmptySeq
, "ShowWindow:show_visible_popup", FALSE
);
4448 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOZORDER
);
4449 ok_sequence(WmShowVisiblePopupSeq_2
, "SetWindowPos:show_visible_popup_2", FALSE
);
4451 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
);
4452 ok_sequence(WmShowVisiblePopupSeq_3
, "SetWindowPos:show_visible_popup_3", FALSE
);
4453 DestroyWindow(hchild
);
4455 /* this time add WS_VISIBLE for CreateWindowEx, but this fact actually
4456 * changes nothing in message sequences.
4459 hchild
= CreateWindowExA(0, "TestPopupClass", "Test Popup", WS_POPUP
| WS_VISIBLE
,
4460 0, 0, 100, 100, hparent
, 0, 0, NULL
);
4461 ok (hchild
!= 0, "Failed to create popup window\n");
4462 ok_sequence(WmCreateInvisiblePopupSeq
, "CreateWindow:invisible_popup", FALSE
);
4463 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
4464 ok(IsWindowVisible(hchild
), "IsWindowVisible() should return TRUE\n");
4466 ShowWindow(hchild
, SW_SHOW
);
4467 ok_sequence(WmEmptySeq
, "ShowWindow:show_visible_popup", FALSE
);
4469 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOZORDER
);
4470 ok_sequence(WmShowVisiblePopupSeq_2
, "SetWindowPos:show_visible_popup_2", FALSE
);
4471 DestroyWindow(hchild
);
4474 hwnd
= CreateWindowExA(WS_EX_DLGMODALFRAME
, "TestDialogClass", NULL
, WS_VISIBLE
|WS_CAPTION
|WS_SYSMENU
|WS_DLGFRAME
,
4475 0, 0, 100, 100, hparent
, 0, 0, NULL
);
4476 ok(hwnd
!= 0, "Failed to create custom dialog window\n");
4477 ok_sequence(WmCreateCustomDialogSeq
, "CreateCustomDialog", TRUE
);
4480 trace("testing scroll APIs on a visible dialog %p\n", hwnd);
4481 test_scroll_messages(hwnd);
4487 SendMessage(hwnd
, WM_NULL
, 0, 0);
4490 after_end_dialog
= 1;
4491 EndDialog( hwnd
, 0 );
4492 ok_sequence(WmEndCustomDialogSeq
, "EndCustomDialog", FALSE
);
4494 DestroyWindow(hwnd
);
4495 after_end_dialog
= 0;
4498 hwnd
= CreateWindowExA(0, "TestDialogClass", NULL
, WS_POPUP
,
4499 0, 0, 100, 100, 0, 0, GetModuleHandleA(0), NULL
);
4500 ok(hwnd
!= 0, "Failed to create custom dialog window\n");
4502 trace("call ShowWindow(%p, SW_SHOW)\n", hwnd
);
4503 ShowWindow(hwnd
, SW_SHOW
);
4504 ok_sequence(WmShowCustomDialogSeq
, "ShowCustomDialog", TRUE
);
4505 DestroyWindow(hwnd
);
4508 DialogBoxA( 0, "TEST_DIALOG", hparent
, TestModalDlgProcA
);
4509 ok_sequence(WmModalDialogSeq
, "ModalDialog", TRUE
);
4511 DestroyWindow(hparent
);
4514 /* Message sequence for SetMenu */
4515 ok(!DrawMenuBar(hwnd
), "DrawMenuBar should return FALSE for a window without a menu\n");
4516 ok_sequence(WmEmptySeq
, "DrawMenuBar for a window without a menu", FALSE
);
4518 hmenu
= CreateMenu();
4519 ok (hmenu
!= 0, "Failed to create menu\n");
4520 ok (InsertMenuA(hmenu
, -1, MF_BYPOSITION
, 0x1000, "foo"), "InsertMenu failed\n");
4521 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW
,
4522 100, 100, 200, 200, 0, hmenu
, 0, NULL
);
4523 ok_sequence(WmCreateOverlappedSeq
, "CreateWindow:overlapped", FALSE
);
4524 ok (SetMenu(hwnd
, 0), "SetMenu\n");
4525 ok_sequence(WmSetMenuNonVisibleSizeChangeSeq
, "SetMenu:NonVisibleSizeChange", FALSE
);
4526 ok (SetMenu(hwnd
, 0), "SetMenu\n");
4527 ok_sequence(WmSetMenuNonVisibleNoSizeChangeSeq
, "SetMenu:NonVisibleNoSizeChange", FALSE
);
4528 ShowWindow(hwnd
, SW_SHOW
);
4529 UpdateWindow( hwnd
);
4532 ok (SetMenu(hwnd
, 0), "SetMenu\n");
4533 ok_sequence(WmSetMenuVisibleNoSizeChangeSeq
, "SetMenu:VisibleNoSizeChange", FALSE
);
4534 ok (SetMenu(hwnd
, hmenu
), "SetMenu\n");
4535 ok_sequence(WmSetMenuVisibleSizeChangeSeq
, "SetMenu:VisibleSizeChange", FALSE
);
4537 UpdateWindow( hwnd
);
4540 ok(DrawMenuBar(hwnd
), "DrawMenuBar\n");
4542 ok_sequence(WmDrawMenuBarSeq
, "DrawMenuBar", FALSE
);
4544 DestroyWindow(hwnd
);
4547 /* Message sequence for EnableWindow */
4548 hparent
= CreateWindowExA(0, "TestWindowClass", "Test parent", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
4549 100, 100, 200, 200, 0, 0, 0, NULL
);
4550 ok (hparent
!= 0, "Failed to create parent window\n");
4551 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
| WS_VISIBLE
,
4552 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4553 ok (hchild
!= 0, "Failed to create child window\n");
4559 EnableWindow(hparent
, FALSE
);
4560 ok_sequence(WmEnableWindowSeq_1
, "EnableWindow(FALSE)", FALSE
);
4562 EnableWindow(hparent
, TRUE
);
4563 ok_sequence(WmEnableWindowSeq_2
, "EnableWindow(TRUE)", FALSE
);
4568 test_MsgWaitForMultipleObjects(hparent
);
4570 /* the following test causes an exception in user.exe under win9x */
4571 if (!PostMessageW( hparent
, WM_USER
, 0, 0 ))
4573 DestroyWindow(hparent
);
4577 PostMessageW( hparent
, WM_USER
+1, 0, 0 );
4578 /* PeekMessage(NULL) fails, but still removes the message */
4579 SetLastError(0xdeadbeef);
4580 ok( !PeekMessageW( NULL
, 0, 0, 0, PM_REMOVE
), "PeekMessage(NULL) should fail\n" );
4581 ok( GetLastError() == ERROR_NOACCESS
|| /* Win2k */
4582 GetLastError() == 0xdeadbeef, /* NT4 */
4583 "last error is %d\n", GetLastError() );
4584 ok( PeekMessageW( &msg
, 0, 0, 0, PM_REMOVE
), "PeekMessage should succeed\n" );
4585 ok( msg
.message
== WM_USER
+1, "got %x instead of WM_USER+1\n", msg
.message
);
4587 DestroyWindow(hchild
);
4588 DestroyWindow(hparent
);
4591 /* Message sequences for WM_SETICON */
4592 trace("testing WM_SETICON\n");
4593 hwnd
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
4594 CW_USEDEFAULT
, CW_USEDEFAULT
, 300, 300, 0,
4596 ShowWindow(hwnd
, SW_SHOW
);
4600 SendMessage(hwnd
, WM_SETICON
, ICON_SMALL
, (LPARAM
)LoadIcon(0, IDI_APPLICATION
));
4601 ok_sequence(WmSetIcon_1
, "WM_SETICON for shown window with caption", FALSE
);
4603 ShowWindow(hwnd
, SW_HIDE
);
4606 SendMessage(hwnd
, WM_SETICON
, ICON_SMALL
, (LPARAM
)LoadIcon(0, IDI_APPLICATION
));
4607 ok_sequence(WmSetIcon_2
, "WM_SETICON for hidden window with caption", FALSE
);
4608 DestroyWindow(hwnd
);
4611 hwnd
= CreateWindowExA(0, "TestPopupClass", NULL
, WS_POPUP
,
4612 CW_USEDEFAULT
, CW_USEDEFAULT
, 300, 300, 0,
4614 ShowWindow(hwnd
, SW_SHOW
);
4618 SendMessage(hwnd
, WM_SETICON
, ICON_SMALL
, (LPARAM
)LoadIcon(0, IDI_APPLICATION
));
4619 ok_sequence(WmSetIcon_2
, "WM_SETICON for shown window without caption", FALSE
);
4621 ShowWindow(hwnd
, SW_HIDE
);
4624 SendMessage(hwnd
, WM_SETICON
, ICON_SMALL
, (LPARAM
)LoadIcon(0, IDI_APPLICATION
));
4625 ok_sequence(WmSetIcon_2
, "WM_SETICON for hidden window without caption", FALSE
);
4628 res
= SendMessage(hwnd
, 0x3B, 0x8000000b, 0);
4631 todo_wine
win_skip( "Message 0x3b not supported\n" );
4634 ok_sequence(WmInitEndSession
, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x8000000b", TRUE
);
4635 ok(res
== 1, "SendMessage(hwnd, 0x3B, 0x8000000b, 0) should have returned 1 instead of %ld\n", res
);
4636 res
= SendMessage(hwnd
, 0x3B, 0x0000000b, 0);
4637 ok_sequence(WmInitEndSession_2
, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x0000000b", TRUE
);
4638 ok(res
== 1, "SendMessage(hwnd, 0x3B, 0x0000000b, 0) should have returned 1 instead of %ld\n", res
);
4639 res
= SendMessage(hwnd
, 0x3B, 0x0000000f, 0);
4640 ok_sequence(WmInitEndSession_2
, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x0000000f", TRUE
);
4641 ok(res
== 1, "SendMessage(hwnd, 0x3B, 0x0000000f, 0) should have returned 1 instead of %ld\n", res
);
4644 res
= SendMessage(hwnd
, 0x3B, 0x80000008, 0);
4645 ok_sequence(WmInitEndSession_3
, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x80000008", TRUE
);
4646 ok(res
== 2, "SendMessage(hwnd, 0x3B, 0x80000008, 0) should have returned 2 instead of %ld\n", res
);
4647 res
= SendMessage(hwnd
, 0x3B, 0x00000008, 0);
4648 ok_sequence(WmInitEndSession_4
, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x00000008", TRUE
);
4649 ok(res
== 2, "SendMessage(hwnd, 0x3B, 0x00000008, 0) should have returned 2 instead of %ld\n", res
);
4651 res
= SendMessage(hwnd
, 0x3B, 0x80000004, 0);
4652 ok_sequence(WmInitEndSession_3
, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x80000004", TRUE
);
4653 ok(res
== 2, "SendMessage(hwnd, 0x3B, 0x80000004, 0) should have returned 2 instead of %ld\n", res
);
4655 res
= SendMessage(hwnd
, 0x3B, 0x80000001, 0);
4656 ok_sequence(WmInitEndSession_5
, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x80000001", TRUE
);
4657 ok(res
== 2, "SendMessage(hwnd, 0x3B, 0x80000001, 0) should have returned 2 instead of %ld\n", res
);
4660 DestroyWindow(hwnd
);
4664 static void test_setwindowpos(void)
4669 const INT winX
= 100;
4670 const INT winY
= 100;
4671 const INT sysX
= GetSystemMetrics(SM_CXMINTRACK
);
4673 hwnd
= CreateWindowExA(0, "TestWindowClass", NULL
, 0,
4674 0, 0, winX
, winY
, 0,
4677 GetWindowRect(hwnd
, &rc
);
4678 expect(sysX
, rc
.right
);
4679 expect(winY
, rc
.bottom
);
4683 res
= SetWindowPos(hwnd
, HWND_TOPMOST
, 0, 0, winX
, winY
, 0);
4684 ok_sequence(WmZOrder
, "Z-Order", TRUE
);
4685 ok(res
== TRUE
, "SetWindowPos expected TRUE, got %ld\n", res
);
4687 GetWindowRect(hwnd
, &rc
);
4688 expect(sysX
, rc
.right
);
4689 expect(winY
, rc
.bottom
);
4690 DestroyWindow(hwnd
);
4693 static void invisible_parent_tests(void)
4695 HWND hparent
, hchild
;
4697 hparent
= CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW
,
4698 100, 100, 200, 200, 0, 0, 0, NULL
);
4699 ok (hparent
!= 0, "Failed to create parent window\n");
4702 /* test showing child with hidden parent */
4704 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
4705 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4706 ok (hchild
!= 0, "Failed to create child window\n");
4707 ok_sequence(WmCreateChildSeq
, "CreateWindow:child", FALSE
);
4709 ShowWindow( hchild
, SW_MINIMIZE
);
4710 ok_sequence(WmShowChildInvisibleParentSeq_1
, "ShowWindow(SW_MINIMIZE) child with invisible parent", FALSE
);
4711 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
4712 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
4717 ShowWindow( hchild
, SW_MINIMIZE
);
4718 ok_sequence(WmShowChildInvisibleParentSeq_1r
, "ShowWindow(SW_MINIMIZE) child with invisible parent", FALSE
);
4720 DestroyWindow(hchild
);
4721 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
4722 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4725 ShowWindow( hchild
, SW_MAXIMIZE
);
4726 ok_sequence(WmShowChildInvisibleParentSeq_2
, "ShowWindow(SW_MAXIMIZE) child with invisible parent", FALSE
);
4727 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
4728 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
4733 ShowWindow( hchild
, SW_MAXIMIZE
);
4734 ok_sequence(WmShowChildInvisibleParentSeq_2r
, "ShowWindow(SW_MAXIMIZE) child with invisible parent", FALSE
);
4736 DestroyWindow(hchild
);
4737 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
4738 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4741 ShowWindow( hchild
, SW_RESTORE
);
4742 ok_sequence(WmShowChildInvisibleParentSeq_5
, "ShowWindow(SW_RESTORE) child with invisible parent", FALSE
);
4743 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
4744 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
4746 DestroyWindow(hchild
);
4747 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
4748 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4751 ShowWindow( hchild
, SW_SHOWMINIMIZED
);
4752 ok_sequence(WmShowChildInvisibleParentSeq_3
, "ShowWindow(SW_SHOWMINIMIZED) child with invisible parent", FALSE
);
4753 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
4754 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
4759 ShowWindow( hchild
, SW_SHOWMINIMIZED
);
4760 ok_sequence(WmShowChildInvisibleParentSeq_3r
, "ShowWindow(SW_SHOWMINIMIZED) child with invisible parent", FALSE
);
4762 DestroyWindow(hchild
);
4763 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
4764 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4767 /* same as ShowWindow( hchild, SW_MAXIMIZE ); */
4768 ShowWindow( hchild
, SW_SHOWMAXIMIZED
);
4769 ok_sequence(WmShowChildInvisibleParentSeq_2
, "ShowWindow(SW_SHOWMAXIMIZED) child with invisible parent", FALSE
);
4770 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
4771 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
4773 DestroyWindow(hchild
);
4774 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
4775 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4778 ShowWindow( hchild
, SW_SHOWMINNOACTIVE
);
4779 ok_sequence(WmShowChildInvisibleParentSeq_4
, "ShowWindow(SW_SHOWMINNOACTIVE) child with invisible parent", FALSE
);
4780 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
4781 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
4786 ShowWindow( hchild
, SW_SHOWMINNOACTIVE
);
4787 ok_sequence(WmShowChildInvisibleParentSeq_4r
, "ShowWindow(SW_SHOWMINNOACTIVE) child with invisible parent", FALSE
);
4789 DestroyWindow(hchild
);
4790 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
4791 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4794 /* FIXME: looks like XP SP2 doesn't know about SW_FORCEMINIMIZE at all */
4795 ShowWindow( hchild
, SW_FORCEMINIMIZE
);
4796 ok_sequence(WmEmptySeq
, "ShowWindow(SW_FORCEMINIMIZE) child with invisible parent", TRUE
);
4798 ok(!(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
), "WS_VISIBLE should be not set\n");
4800 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
4802 DestroyWindow(hchild
);
4803 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
4804 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4807 ShowWindow( hchild
, SW_SHOWNA
);
4808 ok_sequence(WmShowChildInvisibleParentSeq_5
, "ShowWindow(SW_SHOWNA) child with invisible parent", FALSE
);
4809 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
4810 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
4815 ShowWindow( hchild
, SW_SHOWNA
);
4816 ok_sequence(WmShowChildInvisibleParentSeq_5
, "ShowWindow(SW_SHOWNA) child with invisible parent", FALSE
);
4818 DestroyWindow(hchild
);
4819 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
4820 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4823 ShowWindow( hchild
, SW_SHOW
);
4824 ok_sequence(WmShowChildInvisibleParentSeq_5
, "ShowWindow(SW_SHOW) child with invisible parent", FALSE
);
4825 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
4826 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
4831 ShowWindow( hchild
, SW_SHOW
);
4832 ok_sequence(WmEmptySeq
, "ShowWindow(SW_SHOW) child with invisible parent", FALSE
);
4834 ShowWindow( hchild
, SW_HIDE
);
4835 ok_sequence(WmHideChildInvisibleParentSeq
, "ShowWindow:hide child with invisible parent", FALSE
);
4836 ok(!(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
), "WS_VISIBLE should be not set\n");
4837 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
4839 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOZORDER
);
4840 ok_sequence(WmShowChildInvisibleParentSeq_6
, "SetWindowPos:show child with invisible parent", FALSE
);
4841 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
4842 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
4844 SetWindowPos(hchild
, 0,0,0,0,0, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOZORDER
);
4845 ok_sequence(WmHideChildInvisibleParentSeq_2
, "SetWindowPos:hide child with invisible parent", FALSE
);
4846 ok(!(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
), "WS_VISIBLE should not be set\n");
4847 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
4849 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOZORDER
);
4851 DestroyWindow(hchild
);
4852 ok_sequence(WmDestroyInvisibleChildSeq
, "DestroyInvisibleChildSeq", FALSE
);
4854 DestroyWindow(hparent
);
4858 /****************** button message test *************************/
4859 static const struct message WmSetFocusButtonSeq
[] =
4861 { HCBT_SETFOCUS
, hook
},
4862 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
4863 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
4864 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
4865 { WM_SETFOCUS
, sent
|wparam
, 0 },
4866 { WM_CTLCOLORBTN
, sent
|defwinproc
},
4869 static const struct message WmKillFocusButtonSeq
[] =
4871 { HCBT_SETFOCUS
, hook
},
4872 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
4873 { WM_KILLFOCUS
, sent
|wparam
, 0 },
4874 { WM_CTLCOLORBTN
, sent
|defwinproc
},
4875 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
4876 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 1 },
4879 static const struct message WmSetFocusStaticSeq
[] =
4881 { HCBT_SETFOCUS
, hook
},
4882 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
4883 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
4884 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
4885 { WM_SETFOCUS
, sent
|wparam
, 0 },
4886 { WM_CTLCOLORSTATIC
, sent
|defwinproc
},
4889 static const struct message WmKillFocusStaticSeq
[] =
4891 { HCBT_SETFOCUS
, hook
},
4892 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
4893 { WM_KILLFOCUS
, sent
|wparam
, 0 },
4894 { WM_CTLCOLORSTATIC
, sent
|defwinproc
},
4895 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
4896 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 1 },
4899 static const struct message WmLButtonDownSeq
[] =
4901 { WM_LBUTTONDOWN
, sent
|wparam
|lparam
, 0, 0 },
4902 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
4903 { HCBT_SETFOCUS
, hook
},
4904 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
4905 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
4906 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
4907 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
4908 { WM_CTLCOLORBTN
, sent
|defwinproc
},
4909 { BM_SETSTATE
, sent
|wparam
|defwinproc
, TRUE
},
4910 { WM_CTLCOLORBTN
, sent
|defwinproc
},
4911 { EVENT_OBJECT_STATECHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
4914 static const struct message WmLButtonUpSeq
[] =
4916 { WM_LBUTTONUP
, sent
|wparam
|lparam
, 0, 0 },
4917 { BM_SETSTATE
, sent
|wparam
|defwinproc
, FALSE
},
4918 { WM_CTLCOLORBTN
, sent
|defwinproc
},
4919 { EVENT_OBJECT_STATECHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
4920 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, 0, 0 },
4921 { WM_CAPTURECHANGED
, sent
|wparam
|defwinproc
, 0 },
4924 static const struct message WmSetFontButtonSeq
[] =
4926 { WM_SETFONT
, sent
},
4928 { WM_ERASEBKGND
, sent
|defwinproc
|optional
},
4929 { WM_CTLCOLORBTN
, sent
|defwinproc
},
4933 static WNDPROC old_button_proc
;
4935 static LRESULT CALLBACK
button_hook_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
4937 static long defwndproc_counter
= 0;
4941 trace("button: %p, %04x, %08lx, %08lx\n", hwnd
, message
, wParam
, lParam
);
4943 /* explicitly ignore WM_GETICON message */
4944 if (message
== WM_GETICON
) return 0;
4946 /* ignore registered messages */
4947 if (message
>= 0xc000) return 0;
4949 msg
.message
= message
;
4950 msg
.flags
= sent
|wparam
|lparam
;
4951 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
4952 msg
.wParam
= wParam
;
4953 msg
.lParam
= lParam
;
4956 if (message
== BM_SETSTATE
)
4957 ok(GetCapture() == hwnd
, "GetCapture() = %p\n", GetCapture());
4959 defwndproc_counter
++;
4960 ret
= CallWindowProcA(old_button_proc
, hwnd
, message
, wParam
, lParam
);
4961 defwndproc_counter
--;
4966 static void subclass_button(void)
4970 if (!GetClassInfoA(0, "button", &cls
)) assert(0);
4972 old_button_proc
= cls
.lpfnWndProc
;
4974 cls
.hInstance
= GetModuleHandle(0);
4975 cls
.lpfnWndProc
= button_hook_proc
;
4976 cls
.lpszClassName
= "my_button_class";
4977 UnregisterClass(cls
.lpszClassName
, cls
.hInstance
);
4978 if (!RegisterClassA(&cls
)) assert(0);
4981 static void test_button_messages(void)
4987 const struct message
*setfocus
;
4988 const struct message
*killfocus
;
4990 { BS_PUSHBUTTON
, DLGC_BUTTON
| DLGC_UNDEFPUSHBUTTON
,
4991 WmSetFocusButtonSeq
, WmKillFocusButtonSeq
},
4992 { BS_DEFPUSHBUTTON
, DLGC_BUTTON
| DLGC_DEFPUSHBUTTON
,
4993 WmSetFocusButtonSeq
, WmKillFocusButtonSeq
},
4994 { BS_CHECKBOX
, DLGC_BUTTON
,
4995 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
},
4996 { BS_AUTOCHECKBOX
, DLGC_BUTTON
,
4997 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
},
4998 { BS_RADIOBUTTON
, DLGC_BUTTON
| DLGC_RADIOBUTTON
,
4999 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
},
5000 { BS_3STATE
, DLGC_BUTTON
,
5001 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
},
5002 { BS_AUTO3STATE
, DLGC_BUTTON
,
5003 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
},
5004 { BS_GROUPBOX
, DLGC_STATIC
,
5005 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
},
5006 { BS_USERBUTTON
, DLGC_BUTTON
| DLGC_UNDEFPUSHBUTTON
,
5007 WmSetFocusButtonSeq
, WmKillFocusButtonSeq
},
5008 { BS_AUTORADIOBUTTON
, DLGC_BUTTON
| DLGC_RADIOBUTTON
,
5009 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
},
5010 { BS_OWNERDRAW
, DLGC_BUTTON
,
5011 WmSetFocusButtonSeq
, WmKillFocusButtonSeq
}
5020 for (i
= 0; i
< sizeof(button
)/sizeof(button
[0]); i
++)
5022 hwnd
= CreateWindowExA(0, "my_button_class", "test", button
[i
].style
| WS_POPUP
,
5023 0, 0, 50, 14, 0, 0, 0, NULL
);
5024 ok(hwnd
!= 0, "Failed to create button window\n");
5026 dlg_code
= SendMessageA(hwnd
, WM_GETDLGCODE
, 0, 0);
5027 ok(dlg_code
== button
[i
].dlg_code
, "%u: wrong dlg_code %08x\n", i
, dlg_code
);
5029 ShowWindow(hwnd
, SW_SHOW
);
5034 trace("button style %08x\n", button
[i
].style
);
5036 ok_sequence(button
[i
].setfocus
, "SetFocus(hwnd) on a button", FALSE
);
5039 ok_sequence(button
[i
].killfocus
, "SetFocus(0) on a button", FALSE
);
5041 DestroyWindow(hwnd
);
5044 hwnd
= CreateWindowExA(0, "my_button_class", "test", BS_PUSHBUTTON
| WS_POPUP
| WS_VISIBLE
,
5045 0, 0, 50, 14, 0, 0, 0, NULL
);
5046 ok(hwnd
!= 0, "Failed to create button window\n");
5052 SendMessageA(hwnd
, WM_LBUTTONDOWN
, 0, 0);
5053 ok_sequence(WmLButtonDownSeq
, "WM_LBUTTONDOWN on a button", FALSE
);
5055 SendMessageA(hwnd
, WM_LBUTTONUP
, 0, 0);
5056 ok_sequence(WmLButtonUpSeq
, "WM_LBUTTONUP on a button", FALSE
);
5059 zfont
= (HFONT
)GetStockObject(SYSTEM_FONT
);
5060 SendMessageA(hwnd
, WM_SETFONT
, (WPARAM
)zfont
, TRUE
);
5062 ok_sequence(WmSetFontButtonSeq
, "WM_SETFONT on a button", FALSE
);
5064 DestroyWindow(hwnd
);
5067 /****************** static message test *************************/
5068 static const struct message WmSetFontStaticSeq
[] =
5070 { WM_SETFONT
, sent
},
5071 { WM_PAINT
, sent
|defwinproc
},
5072 { WM_ERASEBKGND
, sent
|defwinproc
|optional
},
5073 { WM_CTLCOLORSTATIC
, sent
|defwinproc
},
5077 static WNDPROC old_static_proc
;
5079 static LRESULT CALLBACK
static_hook_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
5081 static long defwndproc_counter
= 0;
5085 trace("static: %p, %04x, %08lx, %08lx\n", hwnd
, message
, wParam
, lParam
);
5087 /* explicitly ignore WM_GETICON message */
5088 if (message
== WM_GETICON
) return 0;
5090 /* ignore registered messages */
5091 if (message
>= 0xc000) return 0;
5093 msg
.message
= message
;
5094 msg
.flags
= sent
|wparam
|lparam
;
5095 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
5096 msg
.wParam
= wParam
;
5097 msg
.lParam
= lParam
;
5100 defwndproc_counter
++;
5101 ret
= CallWindowProcA(old_static_proc
, hwnd
, message
, wParam
, lParam
);
5102 defwndproc_counter
--;
5107 static void subclass_static(void)
5111 if (!GetClassInfoA(0, "static", &cls
)) assert(0);
5113 old_static_proc
= cls
.lpfnWndProc
;
5115 cls
.hInstance
= GetModuleHandle(0);
5116 cls
.lpfnWndProc
= static_hook_proc
;
5117 cls
.lpszClassName
= "my_static_class";
5118 UnregisterClass(cls
.lpszClassName
, cls
.hInstance
);
5119 if (!RegisterClassA(&cls
)) assert(0);
5122 static void test_static_messages(void)
5124 /* FIXME: make as comprehensive as the button message test */
5129 const struct message
*setfont
;
5131 { SS_LEFT
, DLGC_STATIC
,
5132 WmSetFontStaticSeq
}
5140 for (i
= 0; i
< sizeof(static_ctrl
)/sizeof(static_ctrl
[0]); i
++)
5142 hwnd
= CreateWindowExA(0, "my_static_class", "test", static_ctrl
[i
].style
| WS_POPUP
,
5143 0, 0, 50, 14, 0, 0, 0, NULL
);
5144 ok(hwnd
!= 0, "Failed to create static window\n");
5146 dlg_code
= SendMessageA(hwnd
, WM_GETDLGCODE
, 0, 0);
5147 ok(dlg_code
== static_ctrl
[i
].dlg_code
, "%u: wrong dlg_code %08x\n", i
, dlg_code
);
5149 ShowWindow(hwnd
, SW_SHOW
);
5154 trace("static style %08x\n", static_ctrl
[i
].style
);
5155 SendMessage(hwnd
, WM_SETFONT
, (WPARAM
)GetStockObject(DEFAULT_GUI_FONT
), TRUE
);
5156 ok_sequence(static_ctrl
[i
].setfont
, "WM_SETFONT on a static", FALSE
);
5158 DestroyWindow(hwnd
);
5162 /****************** ComboBox message test *************************/
5163 #define ID_COMBOBOX 0x000f
5165 static const struct message WmKeyDownComboSeq
[] =
5167 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_DOWN
, 0 },
5168 { WM_COMMAND
, sent
|wparam
|defwinproc
, MAKEWPARAM(1000, LBN_SELCHANGE
) },
5169 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_COMBOBOX
, CBN_SELENDOK
) },
5170 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_COMBOBOX
, CBN_SELCHANGE
) },
5171 { WM_CTLCOLOREDIT
, sent
|parent
},
5172 { WM_KEYUP
, sent
|wparam
|lparam
, VK_DOWN
, 0 },
5176 static WNDPROC old_combobox_proc
;
5178 static LRESULT CALLBACK
combobox_hook_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
5180 static long defwndproc_counter
= 0;
5184 /* do not log painting messages */
5185 if (message
!= WM_PAINT
&&
5186 message
!= WM_NCPAINT
&&
5187 message
!= WM_SYNCPAINT
&&
5188 message
!= WM_ERASEBKGND
&&
5189 message
!= WM_NCHITTEST
&&
5190 message
!= WM_GETTEXT
&&
5191 message
!= WM_GETICON
&&
5192 message
!= WM_DEVICECHANGE
)
5194 trace("combo: %p, %04x, %08lx, %08lx\n", hwnd
, message
, wParam
, lParam
);
5196 msg
.message
= message
;
5197 msg
.flags
= sent
|wparam
|lparam
;
5198 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
5199 msg
.wParam
= wParam
;
5200 msg
.lParam
= lParam
;
5204 defwndproc_counter
++;
5205 ret
= CallWindowProcA(old_combobox_proc
, hwnd
, message
, wParam
, lParam
);
5206 defwndproc_counter
--;
5211 static void subclass_combobox(void)
5215 if (!GetClassInfoA(0, "ComboBox", &cls
)) assert(0);
5217 old_combobox_proc
= cls
.lpfnWndProc
;
5219 cls
.hInstance
= GetModuleHandle(0);
5220 cls
.lpfnWndProc
= combobox_hook_proc
;
5221 cls
.lpszClassName
= "my_combobox_class";
5222 UnregisterClass(cls
.lpszClassName
, cls
.hInstance
);
5223 if (!RegisterClassA(&cls
)) assert(0);
5226 static void test_combobox_messages(void)
5231 subclass_combobox();
5233 parent
= CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
5234 100, 100, 200, 200, 0, 0, 0, NULL
);
5235 ok(parent
!= 0, "Failed to create parent window\n");
5238 combo
= CreateWindowEx(0, "my_combobox_class", "test", WS_CHILD
| WS_VISIBLE
| CBS_DROPDOWNLIST
| CBS_HASSTRINGS
,
5239 0, 0, 100, 150, parent
, (HMENU
)ID_COMBOBOX
, 0, NULL
);
5240 ok(combo
!= 0, "Failed to create combobox window\n");
5242 UpdateWindow(combo
);
5244 ret
= SendMessage(combo
, WM_GETDLGCODE
, 0, 0);
5245 ok(ret
== (DLGC_WANTCHARS
| DLGC_WANTARROWS
), "wrong dlg_code %08lx\n", ret
);
5247 ret
= SendMessage(combo
, CB_ADDSTRING
, 0, (LPARAM
)"item 0");
5248 ok(ret
== 0, "expected 0, got %ld\n", ret
);
5249 ret
= SendMessage(combo
, CB_ADDSTRING
, 0, (LPARAM
)"item 1");
5250 ok(ret
== 1, "expected 1, got %ld\n", ret
);
5251 ret
= SendMessage(combo
, CB_ADDSTRING
, 0, (LPARAM
)"item 2");
5252 ok(ret
== 2, "expected 2, got %ld\n", ret
);
5254 SendMessage(combo
, CB_SETCURSEL
, 0, 0);
5258 log_all_parent_messages
++;
5259 SendMessage(combo
, WM_KEYDOWN
, VK_DOWN
, 0);
5260 SendMessage(combo
, WM_KEYUP
, VK_DOWN
, 0);
5261 log_all_parent_messages
--;
5262 ok_sequence(WmKeyDownComboSeq
, "WM_KEYDOWN/VK_DOWN on a ComboBox", FALSE
);
5264 DestroyWindow(combo
);
5265 DestroyWindow(parent
);
5268 /****************** WM_IME_KEYDOWN message test *******************/
5270 static const struct message WmImeKeydownMsgSeq_0
[] =
5272 { WM_IME_KEYDOWN
, wparam
, VK_RETURN
},
5273 { WM_CHAR
, wparam
, 'A' },
5277 static const struct message WmImeKeydownMsgSeq_1
[] =
5279 { WM_KEYDOWN
, optional
|wparam
, VK_RETURN
},
5280 { WM_CHAR
, optional
|wparam
, VK_RETURN
},
5284 static LRESULT WINAPI
wmime_keydown_procA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
5288 trace("wmime_keydown_procA: %p, %04x, %08lx, %08lx\n", hwnd
, message
, wParam
, lParam
);
5290 msg
.message
= message
;
5291 msg
.flags
= wparam
|lparam
;
5292 msg
.wParam
= wParam
;
5293 msg
.lParam
= lParam
;
5296 return DefWindowProcA(hwnd
, message
, wParam
, lParam
);
5299 static void register_wmime_keydown_class(void)
5303 ZeroMemory(&cls
, sizeof(WNDCLASSA
));
5304 cls
.lpfnWndProc
= wmime_keydown_procA
;
5305 cls
.hInstance
= GetModuleHandleA(0);
5306 cls
.lpszClassName
= "wmime_keydown_class";
5307 if (!RegisterClassA(&cls
)) assert(0);
5310 void test_wmime_keydown_message(void)
5315 trace("Message sequences by WM_IME_KEYDOWN\n");
5317 register_wmime_keydown_class();
5318 hwnd
= CreateWindowExA(0, "wmime_keydown_class", NULL
, WS_OVERLAPPEDWINDOW
,
5319 CW_USEDEFAULT
, CW_USEDEFAULT
, 300, 300, 0,
5324 SendMessage(hwnd
, WM_IME_KEYDOWN
, VK_RETURN
, 0x1c0001);
5325 SendMessage(hwnd
, WM_CHAR
, 'A', 1);
5326 ok_sequence(WmImeKeydownMsgSeq_0
, "WM_IME_KEYDOWN 0", FALSE
);
5328 while ( PeekMessage(&msg
, 0, 0, 0, PM_REMOVE
) )
5330 TranslateMessage(&msg
);
5331 DispatchMessage(&msg
);
5333 ok_sequence(WmImeKeydownMsgSeq_1
, "WM_IME_KEYDOWN 1", FALSE
);
5335 DestroyWindow(hwnd
);
5338 /************* painting message test ********************/
5340 void dump_region(HRGN hrgn
)
5343 RGNDATA
*data
= NULL
;
5348 printf( "null region\n" );
5351 if (!(size
= GetRegionData( hrgn
, 0, NULL
))) return;
5352 if (!(data
= HeapAlloc( GetProcessHeap(), 0, size
))) return;
5353 GetRegionData( hrgn
, size
, data
);
5354 printf("%d rects:", data
->rdh
.nCount
);
5355 for (i
= 0, rect
= (RECT
*)data
->Buffer
; i
< data
->rdh
.nCount
; i
++, rect
++)
5356 printf( " (%d,%d)-(%d,%d)", rect
->left
, rect
->top
, rect
->right
, rect
->bottom
);
5358 HeapFree( GetProcessHeap(), 0, data
);
5361 static void check_update_rgn( HWND hwnd
, HRGN hrgn
)
5365 HRGN tmp
= CreateRectRgn( 0, 0, 0, 0 );
5366 HRGN update
= CreateRectRgn( 0, 0, 0, 0 );
5368 ret
= GetUpdateRgn( hwnd
, update
, FALSE
);
5369 ok( ret
!= ERROR
, "GetUpdateRgn failed\n" );
5370 if (ret
== NULLREGION
)
5372 ok( !hrgn
, "Update region shouldn't be empty\n" );
5376 if (CombineRgn( tmp
, hrgn
, update
, RGN_XOR
) != NULLREGION
)
5378 ok( 0, "Regions are different\n" );
5379 if (winetest_debug
> 0)
5381 printf( "Update region: " );
5382 dump_region( update
);
5383 printf( "Wanted region: " );
5384 dump_region( hrgn
);
5388 GetRgnBox( update
, &r1
);
5389 GetUpdateRect( hwnd
, &r2
, FALSE
);
5390 ok( r1
.left
== r2
.left
&& r1
.top
== r2
.top
&& r1
.right
== r2
.right
&& r1
.bottom
== r2
.bottom
,
5391 "Rectangles are different: %d,%d-%d,%d / %d,%d-%d,%d\n",
5392 r1
.left
, r1
.top
, r1
.right
, r1
.bottom
, r2
.left
, r2
.top
, r2
.right
, r2
.bottom
);
5394 DeleteObject( tmp
);
5395 DeleteObject( update
);
5398 static const struct message WmInvalidateRgn
[] = {
5399 { WM_NCPAINT
, sent
},
5400 { WM_GETTEXT
, sent
|defwinproc
|optional
},
5404 static const struct message WmGetUpdateRect
[] = {
5405 { WM_NCPAINT
, sent
},
5406 { WM_GETTEXT
, sent
|defwinproc
|optional
},
5411 static const struct message WmInvalidateFull
[] = {
5412 { WM_NCPAINT
, sent
|wparam
, 1 },
5413 { WM_GETTEXT
, sent
|defwinproc
|optional
},
5417 static const struct message WmInvalidateErase
[] = {
5418 { WM_NCPAINT
, sent
|wparam
, 1 },
5419 { WM_GETTEXT
, sent
|defwinproc
|optional
},
5420 { WM_ERASEBKGND
, sent
},
5424 static const struct message WmInvalidatePaint
[] = {
5426 { WM_NCPAINT
, sent
|wparam
|beginpaint
, 1 },
5427 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
5431 static const struct message WmInvalidateErasePaint
[] = {
5433 { WM_NCPAINT
, sent
|wparam
|beginpaint
, 1 },
5434 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
5435 { WM_ERASEBKGND
, sent
|beginpaint
},
5439 static const struct message WmInvalidateErasePaint2
[] = {
5441 { WM_NCPAINT
, sent
|beginpaint
},
5442 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
5443 { WM_ERASEBKGND
, sent
|beginpaint
},
5447 static const struct message WmErase
[] = {
5448 { WM_ERASEBKGND
, sent
},
5452 static const struct message WmPaint
[] = {
5457 static const struct message WmParentOnlyPaint
[] = {
5458 { WM_PAINT
, sent
|parent
},
5462 static const struct message WmInvalidateParent
[] = {
5463 { WM_NCPAINT
, sent
|parent
},
5464 { WM_GETTEXT
, sent
|defwinproc
|parent
|optional
},
5465 { WM_ERASEBKGND
, sent
|parent
},
5469 static const struct message WmInvalidateParentChild
[] = {
5470 { WM_NCPAINT
, sent
|parent
},
5471 { WM_GETTEXT
, sent
|defwinproc
|parent
|optional
},
5472 { WM_ERASEBKGND
, sent
|parent
},
5473 { WM_NCPAINT
, sent
},
5474 { WM_GETTEXT
, sent
|defwinproc
|optional
},
5475 { WM_ERASEBKGND
, sent
},
5479 static const struct message WmInvalidateParentChild2
[] = {
5480 { WM_ERASEBKGND
, sent
|parent
},
5481 { WM_NCPAINT
, sent
},
5482 { WM_GETTEXT
, sent
|defwinproc
|optional
},
5483 { WM_ERASEBKGND
, sent
},
5487 static const struct message WmParentPaint
[] = {
5488 { WM_PAINT
, sent
|parent
},
5493 static const struct message WmParentPaintNc
[] = {
5494 { WM_PAINT
, sent
|parent
},
5496 { WM_NCPAINT
, sent
|beginpaint
},
5497 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
5498 { WM_ERASEBKGND
, sent
|beginpaint
},
5502 static const struct message WmChildPaintNc
[] = {
5504 { WM_NCPAINT
, sent
|beginpaint
},
5505 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
5506 { WM_ERASEBKGND
, sent
|beginpaint
},
5510 static const struct message WmParentErasePaint
[] = {
5511 { WM_PAINT
, sent
|parent
},
5512 { WM_NCPAINT
, sent
|parent
|beginpaint
},
5513 { WM_GETTEXT
, sent
|parent
|beginpaint
|defwinproc
|optional
},
5514 { WM_ERASEBKGND
, sent
|parent
|beginpaint
},
5516 { WM_NCPAINT
, sent
|beginpaint
},
5517 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
5518 { WM_ERASEBKGND
, sent
|beginpaint
},
5522 static const struct message WmParentOnlyNcPaint
[] = {
5523 { WM_PAINT
, sent
|parent
},
5524 { WM_NCPAINT
, sent
|parent
|beginpaint
},
5525 { WM_GETTEXT
, sent
|parent
|beginpaint
|defwinproc
|optional
},
5529 static const struct message WmSetParentStyle
[] = {
5530 { WM_STYLECHANGING
, sent
|parent
},
5531 { WM_STYLECHANGED
, sent
|parent
},
5535 static void test_paint_messages(void)
5541 HWND hparent
, hchild
;
5542 HRGN hrgn
= CreateRectRgn( 0, 0, 0, 0 );
5543 HRGN hrgn2
= CreateRectRgn( 0, 0, 0, 0 );
5544 HWND hwnd
= CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW
,
5545 100, 100, 200, 200, 0, 0, 0, NULL
);
5546 ok (hwnd
!= 0, "Failed to create overlapped window\n");
5548 ShowWindow( hwnd
, SW_SHOW
);
5549 UpdateWindow( hwnd
);
5553 check_update_rgn( hwnd
, 0 );
5554 SetRectRgn( hrgn
, 10, 10, 20, 20 );
5555 ret
= RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
);
5556 ok(ret
, "RedrawWindow returned %d instead of TRUE\n", ret
);
5557 check_update_rgn( hwnd
, hrgn
);
5558 SetRectRgn( hrgn2
, 20, 20, 30, 30 );
5559 ret
= RedrawWindow( hwnd
, NULL
, hrgn2
, RDW_INVALIDATE
);
5560 ok(ret
, "RedrawWindow returned %d instead of TRUE\n", ret
);
5561 CombineRgn( hrgn
, hrgn
, hrgn2
, RGN_OR
);
5562 check_update_rgn( hwnd
, hrgn
);
5563 /* validate everything */
5564 ret
= RedrawWindow( hwnd
, NULL
, NULL
, RDW_VALIDATE
);
5565 ok(ret
, "RedrawWindow returned %d instead of TRUE\n", ret
);
5566 check_update_rgn( hwnd
, 0 );
5568 /* test empty region */
5569 SetRectRgn( hrgn
, 10, 10, 10, 15 );
5570 ret
= RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
);
5571 ok(ret
, "RedrawWindow returned %d instead of TRUE\n", ret
);
5572 check_update_rgn( hwnd
, 0 );
5573 /* test empty rect */
5574 SetRect( &rect
, 10, 10, 10, 15 );
5575 ret
= RedrawWindow( hwnd
, &rect
, NULL
, RDW_INVALIDATE
);
5576 ok(ret
, "RedrawWindow returned %d instead of TRUE\n", ret
);
5577 check_update_rgn( hwnd
, 0 );
5579 /* flush pending messages */
5583 GetClientRect( hwnd
, &rect
);
5584 SetRectRgn( hrgn
, 0, 0, rect
.right
- rect
.left
, rect
.bottom
- rect
.top
);
5585 /* MSDN: if hwnd parameter is NULL, InvalidateRect invalidates and redraws
5586 * all windows and sends WM_ERASEBKGND and WM_NCPAINT.
5588 trace("testing InvalidateRect(0, NULL, FALSE)\n");
5589 SetRectEmpty( &rect
);
5590 ok(InvalidateRect(0, &rect
, FALSE
), "InvalidateRect(0, &rc, FALSE) should fail\n");
5591 check_update_rgn( hwnd
, hrgn
);
5592 ok_sequence( WmInvalidateErase
, "InvalidateErase", FALSE
);
5594 ok_sequence( WmPaint
, "Paint", FALSE
);
5595 RedrawWindow( hwnd
, NULL
, NULL
, RDW_VALIDATE
);
5596 check_update_rgn( hwnd
, 0 );
5598 /* MSDN: if hwnd parameter is NULL, ValidateRect invalidates and redraws
5599 * all windows and sends WM_ERASEBKGND and WM_NCPAINT.
5601 trace("testing ValidateRect(0, NULL)\n");
5602 SetRectEmpty( &rect
);
5603 ok(ValidateRect(0, &rect
), "ValidateRect(0, &rc) should not fail\n");
5604 check_update_rgn( hwnd
, hrgn
);
5605 ok_sequence( WmInvalidateErase
, "InvalidateErase", FALSE
);
5607 ok_sequence( WmPaint
, "Paint", FALSE
);
5608 RedrawWindow( hwnd
, NULL
, NULL
, RDW_VALIDATE
);
5609 check_update_rgn( hwnd
, 0 );
5611 trace("testing InvalidateRgn(0, NULL, FALSE)\n");
5612 SetLastError(0xdeadbeef);
5613 ok(!InvalidateRgn(0, NULL
, FALSE
), "InvalidateRgn(0, NULL, FALSE) should fail\n");
5614 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
|| GetLastError() == 0xdeadbeef,
5615 "wrong error code %d\n", GetLastError());
5616 check_update_rgn( hwnd
, 0 );
5618 ok_sequence( WmEmptySeq
, "WmEmptySeq", FALSE
);
5620 trace("testing ValidateRgn(0, NULL)\n");
5621 SetLastError(0xdeadbeef);
5622 ok(!ValidateRgn(0, NULL
), "ValidateRgn(0, NULL) should fail\n");
5623 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
, "wrong error code %d\n", GetLastError());
5624 check_update_rgn( hwnd
, 0 );
5626 ok_sequence( WmEmptySeq
, "WmEmptySeq", FALSE
);
5628 /* now with frame */
5629 SetRectRgn( hrgn
, -5, -5, 20, 20 );
5631 /* flush pending messages */
5634 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_FRAME
);
5635 ok_sequence( WmEmptySeq
, "EmptySeq", FALSE
);
5637 SetRectRgn( hrgn
, 0, 0, 20, 20 ); /* GetUpdateRgn clips to client area */
5638 check_update_rgn( hwnd
, hrgn
);
5641 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASENOW
);
5642 ok_sequence( WmInvalidateRgn
, "InvalidateRgn", FALSE
);
5645 RedrawWindow( hwnd
, NULL
, NULL
, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASENOW
);
5646 ok_sequence( WmInvalidateFull
, "InvalidateFull", FALSE
);
5648 GetClientRect( hwnd
, &rect
);
5649 SetRectRgn( hrgn
, rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
5650 check_update_rgn( hwnd
, hrgn
);
5653 RedrawWindow( hwnd
, NULL
, NULL
, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASE
| RDW_ERASENOW
);
5654 ok_sequence( WmInvalidateErase
, "InvalidateErase", FALSE
);
5657 RedrawWindow( hwnd
, NULL
, NULL
, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASENOW
| RDW_UPDATENOW
);
5658 ok_sequence( WmInvalidatePaint
, "InvalidatePaint", FALSE
);
5659 check_update_rgn( hwnd
, 0 );
5662 RedrawWindow( hwnd
, NULL
, NULL
, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASE
| RDW_UPDATENOW
);
5663 ok_sequence( WmInvalidateErasePaint
, "InvalidateErasePaint", FALSE
);
5664 check_update_rgn( hwnd
, 0 );
5667 SetRectRgn( hrgn
, 0, 0, 100, 100 );
5668 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
);
5669 SetRectRgn( hrgn
, 0, 0, 50, 100 );
5670 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_VALIDATE
);
5671 SetRectRgn( hrgn
, 50, 0, 100, 100 );
5672 check_update_rgn( hwnd
, hrgn
);
5673 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_VALIDATE
| RDW_ERASENOW
);
5674 ok_sequence( WmEmptySeq
, "EmptySeq", FALSE
); /* must not generate messages, everything is valid */
5675 check_update_rgn( hwnd
, 0 );
5678 SetRectRgn( hrgn
, 0, 0, 100, 100 );
5679 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_ERASE
);
5680 SetRectRgn( hrgn
, 0, 0, 100, 50 );
5681 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_VALIDATE
| RDW_ERASENOW
);
5682 ok_sequence( WmErase
, "Erase", FALSE
);
5683 SetRectRgn( hrgn
, 0, 50, 100, 100 );
5684 check_update_rgn( hwnd
, hrgn
);
5687 SetRectRgn( hrgn
, 0, 0, 100, 100 );
5688 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_ERASE
);
5689 SetRectRgn( hrgn
, 0, 0, 50, 50 );
5690 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_VALIDATE
| RDW_NOERASE
| RDW_UPDATENOW
);
5691 ok_sequence( WmPaint
, "Paint", FALSE
);
5694 SetRectRgn( hrgn
, -4, -4, -2, -2 );
5695 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_FRAME
);
5696 SetRectRgn( hrgn
, -200, -200, -198, -198 );
5697 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_VALIDATE
| RDW_NOFRAME
| RDW_ERASENOW
);
5698 ok_sequence( WmEmptySeq
, "EmptySeq", FALSE
);
5701 SetRectRgn( hrgn
, -4, -4, -2, -2 );
5702 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_FRAME
);
5703 SetRectRgn( hrgn
, -4, -4, -3, -3 );
5704 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_VALIDATE
| RDW_NOFRAME
);
5705 SetRectRgn( hrgn
, 0, 0, 1, 1 );
5706 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_UPDATENOW
);
5707 ok_sequence( WmPaint
, "Paint", FALSE
);
5710 SetRectRgn( hrgn
, -4, -4, -1, -1 );
5711 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_FRAME
);
5712 RedrawWindow( hwnd
, NULL
, 0, RDW_ERASENOW
);
5713 /* make sure no WM_PAINT was generated */
5715 ok_sequence( WmInvalidateRgn
, "InvalidateRgn", FALSE
);
5718 SetRectRgn( hrgn
, -4, -4, -1, -1 );
5719 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_FRAME
);
5720 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
))
5722 if (msg
.hwnd
== hwnd
&& msg
.message
== WM_PAINT
)
5724 /* GetUpdateRgn must return empty region since only nonclient area is invalidated */
5725 INT ret
= GetUpdateRgn( hwnd
, hrgn
, FALSE
);
5726 ok( ret
== NULLREGION
, "Invalid GetUpdateRgn result %d\n", ret
);
5727 ret
= GetUpdateRect( hwnd
, &rect
, FALSE
);
5728 ok( ret
, "Invalid GetUpdateRect result %d\n", ret
);
5729 /* this will send WM_NCPAINT and validate the non client area */
5730 ret
= GetUpdateRect( hwnd
, &rect
, TRUE
);
5731 ok( !ret
, "Invalid GetUpdateRect result %d\n", ret
);
5733 DispatchMessage( &msg
);
5735 ok_sequence( WmGetUpdateRect
, "GetUpdateRect", FALSE
);
5737 DestroyWindow( hwnd
);
5739 /* now test with a child window */
5741 hparent
= CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW
,
5742 100, 100, 200, 200, 0, 0, 0, NULL
);
5743 ok (hparent
!= 0, "Failed to create parent window\n");
5745 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
| WS_VISIBLE
| WS_BORDER
,
5746 10, 10, 100, 100, hparent
, 0, 0, NULL
);
5747 ok (hchild
!= 0, "Failed to create child window\n");
5749 ShowWindow( hparent
, SW_SHOW
);
5750 UpdateWindow( hparent
);
5751 UpdateWindow( hchild
);
5754 log_all_parent_messages
++;
5756 SetRect( &rect
, 0, 0, 50, 50 );
5757 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
5758 RedrawWindow( hparent
, NULL
, 0, RDW_ERASENOW
| RDW_ALLCHILDREN
);
5759 ok_sequence( WmInvalidateParentChild
, "InvalidateParentChild", FALSE
);
5761 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
5763 MapWindowPoints( hchild
, hparent
, &pt
, 1 );
5764 SetRectRgn( hrgn
, 0, 0, 50 - pt
.x
, 50 - pt
.y
);
5765 check_update_rgn( hchild
, hrgn
);
5766 SetRectRgn( hrgn
, 0, 0, 50, 50 );
5767 check_update_rgn( hparent
, hrgn
);
5768 RedrawWindow( hparent
, NULL
, 0, RDW_ERASENOW
);
5769 ok_sequence( WmInvalidateParent
, "InvalidateParent", FALSE
);
5770 RedrawWindow( hchild
, NULL
, 0, RDW_ERASENOW
);
5771 ok_sequence( WmEmptySeq
, "EraseNow child", FALSE
);
5774 ok_sequence( WmParentPaintNc
, "WmParentPaintNc", FALSE
);
5776 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
| RDW_ALLCHILDREN
);
5777 RedrawWindow( hparent
, NULL
, 0, RDW_ERASENOW
);
5778 ok_sequence( WmInvalidateParent
, "InvalidateParent2", FALSE
);
5779 RedrawWindow( hchild
, NULL
, 0, RDW_ERASENOW
);
5780 ok_sequence( WmEmptySeq
, "EraseNow child", FALSE
);
5782 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
);
5783 RedrawWindow( hparent
, NULL
, 0, RDW_ERASENOW
| RDW_ALLCHILDREN
);
5784 ok_sequence( WmInvalidateParentChild2
, "InvalidateParentChild2", FALSE
);
5786 SetWindowLong( hparent
, GWL_STYLE
, GetWindowLong(hparent
,GWL_STYLE
) | WS_CLIPCHILDREN
);
5788 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
| RDW_ALLCHILDREN
);
5789 RedrawWindow( hparent
, NULL
, 0, RDW_ERASENOW
);
5790 ok_sequence( WmInvalidateParentChild
, "InvalidateParentChild3", FALSE
);
5792 /* flush all paint messages */
5796 /* RDW_UPDATENOW on child with WS_CLIPCHILDREN doesn't change corresponding parent area */
5797 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
| RDW_ALLCHILDREN
);
5798 SetRectRgn( hrgn
, 0, 0, 50, 50 );
5799 check_update_rgn( hparent
, hrgn
);
5800 RedrawWindow( hchild
, NULL
, 0, RDW_UPDATENOW
);
5801 ok_sequence( WmInvalidateErasePaint2
, "WmInvalidateErasePaint2", FALSE
);
5802 SetRectRgn( hrgn
, 0, 0, 50, 50 );
5803 check_update_rgn( hparent
, hrgn
);
5805 /* flush all paint messages */
5807 SetWindowLong( hparent
, GWL_STYLE
, GetWindowLong(hparent
,GWL_STYLE
) & ~WS_CLIPCHILDREN
);
5810 /* RDW_UPDATENOW on child without WS_CLIPCHILDREN will validate corresponding parent area */
5811 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
5812 SetRectRgn( hrgn
, 0, 0, 50, 50 );
5813 check_update_rgn( hparent
, hrgn
);
5814 RedrawWindow( hchild
, NULL
, 0, RDW_UPDATENOW
);
5815 ok_sequence( WmInvalidateErasePaint2
, "WmInvalidateErasePaint2", FALSE
);
5816 SetRectRgn( hrgn2
, 10, 10, 50, 50 );
5817 CombineRgn( hrgn
, hrgn
, hrgn2
, RGN_DIFF
);
5818 check_update_rgn( hparent
, hrgn
);
5819 /* flush all paint messages */
5823 /* same as above but parent gets completely validated */
5824 SetRect( &rect
, 20, 20, 30, 30 );
5825 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
5826 SetRectRgn( hrgn
, 20, 20, 30, 30 );
5827 check_update_rgn( hparent
, hrgn
);
5828 RedrawWindow( hchild
, NULL
, 0, RDW_UPDATENOW
);
5829 ok_sequence( WmInvalidateErasePaint2
, "WmInvalidateErasePaint2", FALSE
);
5830 check_update_rgn( hparent
, 0 ); /* no update region */
5832 ok_sequence( WmEmptySeq
, "WmEmpty", FALSE
); /* and no paint messages */
5834 /* make sure RDW_VALIDATE on child doesn't have the same effect */
5836 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
5837 SetRectRgn( hrgn
, 20, 20, 30, 30 );
5838 check_update_rgn( hparent
, hrgn
);
5839 RedrawWindow( hchild
, NULL
, 0, RDW_VALIDATE
| RDW_NOERASE
);
5840 SetRectRgn( hrgn
, 20, 20, 30, 30 );
5841 check_update_rgn( hparent
, hrgn
);
5843 /* same as above but normal WM_PAINT doesn't validate parent */
5845 SetRect( &rect
, 20, 20, 30, 30 );
5846 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
5847 SetRectRgn( hrgn
, 20, 20, 30, 30 );
5848 check_update_rgn( hparent
, hrgn
);
5849 /* no WM_PAINT in child while parent still pending */
5850 while (PeekMessage( &msg
, hchild
, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
5851 ok_sequence( WmEmptySeq
, "No WM_PAINT", FALSE
);
5852 while (PeekMessage( &msg
, hparent
, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
5853 ok_sequence( WmParentErasePaint
, "WmParentErasePaint", FALSE
);
5856 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
5857 /* no WM_PAINT in child while parent still pending */
5858 while (PeekMessage( &msg
, hchild
, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
5859 ok_sequence( WmEmptySeq
, "No WM_PAINT", FALSE
);
5860 RedrawWindow( hparent
, &rect
, 0, RDW_VALIDATE
| RDW_NOERASE
| RDW_NOCHILDREN
);
5861 /* now that parent is valid child should get WM_PAINT */
5862 while (PeekMessage( &msg
, hchild
, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
5863 ok_sequence( WmInvalidateErasePaint2
, "WmInvalidateErasePaint2", FALSE
);
5864 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
5865 ok_sequence( WmEmptySeq
, "No other message", FALSE
);
5867 /* same thing with WS_CLIPCHILDREN in parent */
5869 SetWindowLong( hparent
, GWL_STYLE
, GetWindowLong(hparent
,GWL_STYLE
) | WS_CLIPCHILDREN
);
5870 ok_sequence( WmSetParentStyle
, "WmSetParentStyle", FALSE
);
5871 /* changing style invalidates non client area, but we need to invalidate something else to see it */
5872 RedrawWindow( hparent
, &rect
, 0, RDW_UPDATENOW
);
5873 ok_sequence( WmEmptySeq
, "No message", FALSE
);
5874 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_UPDATENOW
);
5875 ok_sequence( WmParentOnlyNcPaint
, "WmParentOnlyNcPaint", FALSE
);
5878 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_ALLCHILDREN
);
5879 SetRectRgn( hrgn
, 20, 20, 30, 30 );
5880 check_update_rgn( hparent
, hrgn
);
5881 /* no WM_PAINT in child while parent still pending */
5882 while (PeekMessage( &msg
, hchild
, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
5883 ok_sequence( WmEmptySeq
, "No WM_PAINT", FALSE
);
5884 /* WM_PAINT in parent first */
5885 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
5886 ok_sequence( WmParentPaintNc
, "WmParentPaintNc2", FALSE
);
5888 /* no RDW_ERASE in parent still causes RDW_ERASE and RDW_FRAME in child */
5890 SetRect( &rect
, 0, 0, 30, 30 );
5891 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ALLCHILDREN
);
5892 SetRectRgn( hrgn
, 0, 0, 30, 30 );
5893 check_update_rgn( hparent
, hrgn
);
5895 ok_sequence( WmParentPaintNc
, "WmParentPaintNc3", FALSE
);
5897 /* validate doesn't cause RDW_NOERASE or RDW_NOFRAME in child */
5899 SetRect( &rect
, -10, 0, 30, 30 );
5900 RedrawWindow( hchild
, &rect
, 0, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASE
);
5901 SetRect( &rect
, 0, 0, 20, 20 );
5902 RedrawWindow( hparent
, &rect
, 0, RDW_VALIDATE
| RDW_ALLCHILDREN
);
5903 RedrawWindow( hparent
, NULL
, 0, RDW_UPDATENOW
);
5904 ok_sequence( WmChildPaintNc
, "WmChildPaintNc", FALSE
);
5906 /* validate doesn't cause RDW_NOERASE or RDW_NOFRAME in child */
5908 SetRect( &rect
, -10, 0, 30, 30 );
5909 RedrawWindow( hchild
, &rect
, 0, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASE
);
5910 SetRect( &rect
, 0, 0, 100, 100 );
5911 RedrawWindow( hparent
, &rect
, 0, RDW_VALIDATE
| RDW_ALLCHILDREN
);
5912 RedrawWindow( hparent
, NULL
, 0, RDW_UPDATENOW
);
5913 ok_sequence( WmEmptySeq
, "WmChildPaintNc2", FALSE
);
5914 RedrawWindow( hparent
, NULL
, 0, RDW_ERASENOW
);
5915 ok_sequence( WmEmptySeq
, "WmChildPaintNc3", FALSE
);
5917 /* test RDW_INTERNALPAINT behavior */
5920 RedrawWindow( hparent
, NULL
, 0, RDW_INTERNALPAINT
| RDW_NOCHILDREN
);
5922 ok_sequence( WmParentOnlyPaint
, "WmParentOnlyPaint", FALSE
);
5924 RedrawWindow( hparent
, NULL
, 0, RDW_INTERNALPAINT
| RDW_ALLCHILDREN
);
5926 ok_sequence( WmParentPaint
, "WmParentPaint", FALSE
);
5928 RedrawWindow( hparent
, NULL
, 0, RDW_INTERNALPAINT
);
5930 ok_sequence( WmParentOnlyPaint
, "WmParentOnlyPaint", FALSE
);
5932 assert( GetWindowLong(hparent
, GWL_STYLE
) & WS_CLIPCHILDREN
);
5933 UpdateWindow( hparent
);
5936 trace("testing SWP_FRAMECHANGED on parent with WS_CLIPCHILDREN\n");
5937 RedrawWindow( hchild
, NULL
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
5938 SetWindowPos( hparent
, 0, 0, 0, 0, 0, SWP_NOSIZE
| SWP_NOMOVE
|
5939 SWP_NOACTIVATE
| SWP_NOZORDER
| SWP_FRAMECHANGED
);
5941 ok_sequence(WmSWP_FrameChanged_clip
, "SetWindowPos:FrameChanged_clip", FALSE
);
5943 UpdateWindow( hparent
);
5946 trace("testing SWP_FRAMECHANGED|SWP_DEFERERASE on parent with WS_CLIPCHILDREN\n");
5947 RedrawWindow( hchild
, NULL
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
5948 SetWindowPos( hparent
, 0, 0, 0, 0, 0, SWP_NOSIZE
| SWP_NOMOVE
| SWP_DEFERERASE
|
5949 SWP_NOACTIVATE
| SWP_NOZORDER
| SWP_FRAMECHANGED
);
5951 ok_sequence(WmSWP_FrameChangedDeferErase
, "SetWindowPos:FrameChangedDeferErase", FALSE
);
5953 SetWindowLong( hparent
, GWL_STYLE
, GetWindowLong(hparent
,GWL_STYLE
) & ~WS_CLIPCHILDREN
);
5954 ok_sequence( WmSetParentStyle
, "WmSetParentStyle", FALSE
);
5955 RedrawWindow( hparent
, NULL
, 0, RDW_INTERNALPAINT
);
5957 ok_sequence( WmParentPaint
, "WmParentPaint", FALSE
);
5959 assert( !(GetWindowLong(hparent
, GWL_STYLE
) & WS_CLIPCHILDREN
) );
5960 UpdateWindow( hparent
);
5963 trace("testing SWP_FRAMECHANGED on parent without WS_CLIPCHILDREN\n");
5964 RedrawWindow( hchild
, NULL
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
5965 SetWindowPos( hparent
, 0, 0, 0, 0, 0, SWP_NOSIZE
| SWP_NOMOVE
|
5966 SWP_NOACTIVATE
| SWP_NOZORDER
| SWP_FRAMECHANGED
);
5968 ok_sequence(WmSWP_FrameChanged_noclip
, "SetWindowPos:FrameChanged_noclip", FALSE
);
5970 UpdateWindow( hparent
);
5973 trace("testing SWP_FRAMECHANGED|SWP_DEFERERASE on parent without WS_CLIPCHILDREN\n");
5974 RedrawWindow( hchild
, NULL
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
5975 SetWindowPos( hparent
, 0, 0, 0, 0, 0, SWP_NOSIZE
| SWP_NOMOVE
| SWP_DEFERERASE
|
5976 SWP_NOACTIVATE
| SWP_NOZORDER
| SWP_FRAMECHANGED
);
5978 ok_sequence(WmSWP_FrameChangedDeferErase
, "SetWindowPos:FrameChangedDeferErase", FALSE
);
5980 ok(GetWindowLong( hparent
, GWL_STYLE
) & WS_VISIBLE
, "parent should be visible\n");
5981 ok(GetWindowLong( hchild
, GWL_STYLE
) & WS_VISIBLE
, "child should be visible\n");
5983 UpdateWindow( hparent
);
5986 trace("testing SetWindowPos(-10000, -10000) on child\n");
5987 SetWindowPos( hchild
, 0, -10000, -10000, 0, 0, SWP_NOSIZE
| SWP_NOACTIVATE
| SWP_NOZORDER
);
5988 check_update_rgn( hchild
, 0 );
5991 #if 0 /* this one doesn't pass under Wine yet */
5992 UpdateWindow( hparent
);
5995 trace("testing ShowWindow(SW_MINIMIZE) on child\n");
5996 ShowWindow( hchild
, SW_MINIMIZE
);
5997 check_update_rgn( hchild
, 0 );
6001 UpdateWindow( hparent
);
6004 trace("testing SetWindowPos(-10000, -10000) on parent\n");
6005 SetWindowPos( hparent
, 0, -10000, -10000, 0, 0, SWP_NOSIZE
| SWP_NOACTIVATE
| SWP_NOZORDER
);
6006 check_update_rgn( hparent
, 0 );
6009 log_all_parent_messages
--;
6010 DestroyWindow( hparent
);
6011 ok(!IsWindow(hchild
), "child must be destroyed with its parent\n");
6013 /* tests for moving windows off-screen (needs simple WS_POPUP windows) */
6015 hparent
= CreateWindowExA(0, "TestParentClass", "Test parent", WS_POPUP
| WS_VISIBLE
,
6016 100, 100, 200, 200, 0, 0, 0, NULL
);
6017 ok (hparent
!= 0, "Failed to create parent window\n");
6019 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
| WS_VISIBLE
,
6020 10, 10, 100, 100, hparent
, 0, 0, NULL
);
6021 ok (hchild
!= 0, "Failed to create child window\n");
6023 ShowWindow( hparent
, SW_SHOW
);
6024 UpdateWindow( hparent
);
6025 UpdateWindow( hchild
);
6029 /* moving child outside of parent boundaries changes update region */
6030 SetRect( &rect
, 0, 0, 40, 40 );
6031 RedrawWindow( hchild
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
);
6032 SetRectRgn( hrgn
, 0, 0, 40, 40 );
6033 check_update_rgn( hchild
, hrgn
);
6034 MoveWindow( hchild
, -10, 10, 100, 100, FALSE
);
6035 SetRectRgn( hrgn
, 10, 0, 40, 40 );
6036 check_update_rgn( hchild
, hrgn
);
6037 MoveWindow( hchild
, -10, -10, 100, 100, FALSE
);
6038 SetRectRgn( hrgn
, 10, 10, 40, 40 );
6039 check_update_rgn( hchild
, hrgn
);
6041 /* moving parent off-screen does too */
6042 SetRect( &rect
, 0, 0, 100, 100 );
6043 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_NOCHILDREN
);
6044 SetRectRgn( hrgn
, 0, 0, 100, 100 );
6045 check_update_rgn( hparent
, hrgn
);
6046 SetRectRgn( hrgn
, 10, 10, 40, 40 );
6047 check_update_rgn( hchild
, hrgn
);
6048 MoveWindow( hparent
, -20, -20, 200, 200, FALSE
);
6049 SetRectRgn( hrgn
, 20, 20, 100, 100 );
6050 check_update_rgn( hparent
, hrgn
);
6051 SetRectRgn( hrgn
, 30, 30, 40, 40 );
6052 check_update_rgn( hchild
, hrgn
);
6054 /* invalidated region is cropped by the parent rects */
6055 SetRect( &rect
, 0, 0, 50, 50 );
6056 RedrawWindow( hchild
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
);
6057 SetRectRgn( hrgn
, 30, 30, 50, 50 );
6058 check_update_rgn( hchild
, hrgn
);
6060 DestroyWindow( hparent
);
6061 ok(!IsWindow(hchild
), "child must be destroyed with its parent\n");
6064 DeleteObject( hrgn
);
6065 DeleteObject( hrgn2
);
6074 static DWORD WINAPI
thread_proc(void *param
)
6077 struct wnd_event
*wnd_event
= (struct wnd_event
*)param
;
6079 wnd_event
->hwnd
= CreateWindowExA(0, "TestWindowClass", "window caption text", WS_OVERLAPPEDWINDOW
,
6080 100, 100, 200, 200, 0, 0, 0, NULL
);
6081 ok(wnd_event
->hwnd
!= 0, "Failed to create overlapped window\n");
6083 SetEvent(wnd_event
->event
);
6085 while (GetMessage(&msg
, 0, 0, 0))
6087 TranslateMessage(&msg
);
6088 DispatchMessage(&msg
);
6091 ok(IsWindow(wnd_event
->hwnd
), "window should still exist\n");
6096 static void test_interthread_messages(void)
6103 int len
, expected_len
;
6104 struct wnd_event wnd_event
;
6107 wnd_event
.event
= CreateEventW(NULL
, 0, 0, NULL
);
6108 if (!wnd_event
.event
)
6110 trace("skipping interthread message test under win9x\n");
6114 hThread
= CreateThread(NULL
, 0, thread_proc
, &wnd_event
, 0, &tid
);
6115 ok(hThread
!= NULL
, "CreateThread failed, error %d\n", GetLastError());
6117 ok(WaitForSingleObject(wnd_event
.event
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
6119 CloseHandle(wnd_event
.event
);
6121 SetLastError(0xdeadbeef);
6122 ok(!DestroyWindow(wnd_event
.hwnd
), "DestroyWindow succeded\n");
6123 ok(GetLastError() == ERROR_ACCESS_DENIED
|| GetLastError() == 0xdeadbeef,
6124 "wrong error code %d\n", GetLastError());
6126 proc
= (WNDPROC
)GetWindowLongPtrA(wnd_event
.hwnd
, GWLP_WNDPROC
);
6127 ok(proc
!= NULL
, "GetWindowLongPtrA(GWLP_WNDPROC) error %d\n", GetLastError());
6129 expected_len
= lstrlenA("window caption text");
6130 memset(buf
, 0, sizeof(buf
));
6131 SetLastError(0xdeadbeef);
6132 len
= CallWindowProcA(proc
, wnd_event
.hwnd
, WM_GETTEXT
, sizeof(buf
), (LPARAM
)buf
);
6133 ok(len
== expected_len
, "CallWindowProcA(WM_GETTEXT) error %d, len %d, expected len %d\n", GetLastError(), len
, expected_len
);
6134 ok(!lstrcmpA(buf
, "window caption text"), "window text mismatch\n");
6136 msg
.hwnd
= wnd_event
.hwnd
;
6137 msg
.message
= WM_GETTEXT
;
6138 msg
.wParam
= sizeof(buf
);
6139 msg
.lParam
= (LPARAM
)buf
;
6140 memset(buf
, 0, sizeof(buf
));
6141 SetLastError(0xdeadbeef);
6142 len
= DispatchMessageA(&msg
);
6143 ok((!len
&& GetLastError() == ERROR_MESSAGE_SYNC_ONLY
) || broken(len
), /* nt4 */
6144 "DispatchMessageA(WM_GETTEXT) succeded on another thread window: ret %d, error %d\n", len
, GetLastError());
6146 /* the following test causes an exception in user.exe under win9x */
6147 msg
.hwnd
= wnd_event
.hwnd
;
6148 msg
.message
= WM_TIMER
;
6150 msg
.lParam
= GetWindowLongPtrA(wnd_event
.hwnd
, GWLP_WNDPROC
);
6151 SetLastError(0xdeadbeef);
6152 len
= DispatchMessageA(&msg
);
6153 ok(!len
&& GetLastError() == 0xdeadbeef,
6154 "DispatchMessageA(WM_TIMER) failed on another thread window: ret %d, error %d\n", len
, GetLastError());
6156 ret
= PostMessageA(wnd_event
.hwnd
, WM_QUIT
, 0, 0);
6157 ok( ret
, "PostMessageA(WM_QUIT) error %d\n", GetLastError());
6159 ok(WaitForSingleObject(hThread
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
6160 CloseHandle(hThread
);
6162 ok(!IsWindow(wnd_event
.hwnd
), "window should be destroyed on thread exit\n");
6166 static const struct message WmVkN
[] = {
6167 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 1 }, /* XP */
6168 { WM_KEYDOWN
, wparam
|lparam
, 'N', 1 },
6169 { WM_KEYDOWN
, sent
|wparam
|lparam
, 'N', 1 },
6170 { WM_CHAR
, wparam
|lparam
, 'n', 1 },
6171 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1002,1), 0 },
6172 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xc0000001 }, /* XP */
6173 { WM_KEYUP
, wparam
|lparam
, 'N', 0xc0000001 },
6174 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xc0000001 },
6177 static const struct message WmShiftVkN
[] = {
6178 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 1 }, /* XP */
6179 { WM_KEYDOWN
, wparam
|lparam
, VK_SHIFT
, 1 },
6180 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_SHIFT
, 1 },
6181 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 1 }, /* XP */
6182 { WM_KEYDOWN
, wparam
|lparam
, 'N', 1 },
6183 { WM_KEYDOWN
, sent
|wparam
|lparam
, 'N', 1 },
6184 { WM_CHAR
, wparam
|lparam
, 'N', 1 },
6185 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1001,1), 0 },
6186 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xc0000001 }, /* XP */
6187 { WM_KEYUP
, wparam
|lparam
, 'N', 0xc0000001 },
6188 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xc0000001 },
6189 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 0xc0000001 }, /* XP */
6190 { WM_KEYUP
, wparam
|lparam
, VK_SHIFT
, 0xc0000001 },
6191 { WM_KEYUP
, sent
|wparam
|lparam
, VK_SHIFT
, 0xc0000001 },
6194 static const struct message WmCtrlVkN
[] = {
6195 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 1 }, /* XP */
6196 { WM_KEYDOWN
, wparam
|lparam
, VK_CONTROL
, 1 },
6197 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_CONTROL
, 1 },
6198 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 1 }, /* XP */
6199 { WM_KEYDOWN
, wparam
|lparam
, 'N', 1 },
6200 { WM_KEYDOWN
, sent
|wparam
|lparam
, 'N', 1 },
6201 { WM_CHAR
, wparam
|lparam
, 0x000e, 1 },
6202 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1000,1), 0 },
6203 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xc0000001 }, /* XP */
6204 { WM_KEYUP
, wparam
|lparam
, 'N', 0xc0000001 },
6205 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xc0000001 },
6206 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 0xc0000001 }, /* XP */
6207 { WM_KEYUP
, wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
6208 { WM_KEYUP
, sent
|wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
6211 static const struct message WmCtrlVkN_2
[] = {
6212 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 1 }, /* XP */
6213 { WM_KEYDOWN
, wparam
|lparam
, VK_CONTROL
, 1 },
6214 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_CONTROL
, 1 },
6215 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 1 }, /* XP */
6216 { WM_KEYDOWN
, wparam
|lparam
, 'N', 1 },
6217 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1000,1), 0 },
6218 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xc0000001 }, /* XP */
6219 { WM_KEYUP
, wparam
|lparam
, 'N', 0xc0000001 },
6220 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xc0000001 },
6221 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 0xc0000001 }, /* XP */
6222 { WM_KEYUP
, wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
6223 { WM_KEYUP
, sent
|wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
6226 static const struct message WmAltVkN
[] = {
6227 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 }, /* XP */
6228 { WM_SYSKEYDOWN
, wparam
|lparam
, VK_MENU
, 0x20000001 },
6229 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
6230 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0x20000001 }, /* XP */
6231 { WM_SYSKEYDOWN
, wparam
|lparam
, 'N', 0x20000001 },
6232 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, 'N', 0x20000001 },
6233 { WM_SYSCHAR
, wparam
|lparam
, 'n', 0x20000001 },
6234 { WM_SYSCHAR
, sent
|wparam
|lparam
, 'n', 0x20000001 },
6235 { WM_SYSCOMMAND
, sent
|defwinproc
|wparam
|lparam
, SC_KEYMENU
, 'n' },
6236 { HCBT_SYSCOMMAND
, hook
},
6237 { WM_ENTERMENULOOP
, sent
|defwinproc
|wparam
|lparam
, 0, 0 },
6238 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
6239 { 0x00AE, sent
|defwinproc
|optional
}, /* XP */
6240 { WM_GETTEXT
, sent
|defwinproc
|optional
}, /* XP */
6241 { WM_INITMENU
, sent
|defwinproc
},
6242 { EVENT_SYSTEM_MENUSTART
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 0 },
6243 { WM_MENUCHAR
, sent
|defwinproc
|wparam
, MAKEWPARAM('n',MF_SYSMENU
) },
6244 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, 0, 0 },
6245 { WM_CAPTURECHANGED
, sent
|defwinproc
},
6246 { WM_MENUSELECT
, sent
|defwinproc
|wparam
, MAKEWPARAM(0,0xffff) },
6247 { EVENT_SYSTEM_MENUEND
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 0 },
6248 { WM_EXITMENULOOP
, sent
|defwinproc
},
6249 { WM_MENUSELECT
, sent
|defwinproc
|wparam
|optional
, MAKEWPARAM(0,0xffff) }, /* Win95 bug */
6250 { WM_EXITMENULOOP
, sent
|defwinproc
|optional
}, /* Win95 bug */
6251 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xe0000001 }, /* XP */
6252 { WM_SYSKEYUP
, wparam
|lparam
, 'N', 0xe0000001 },
6253 { WM_SYSKEYUP
, sent
|wparam
|lparam
, 'N', 0xe0000001 },
6254 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xc0000001 }, /* XP */
6255 { WM_KEYUP
, wparam
|lparam
, VK_MENU
, 0xc0000001 },
6256 { WM_KEYUP
, sent
|wparam
|lparam
, VK_MENU
, 0xc0000001 },
6259 static const struct message WmAltVkN_2
[] = {
6260 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 }, /* XP */
6261 { WM_SYSKEYDOWN
, wparam
|lparam
, VK_MENU
, 0x20000001 },
6262 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
6263 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0x20000001 }, /* XP */
6264 { WM_SYSKEYDOWN
, wparam
|lparam
, 'N', 0x20000001 },
6265 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1003,1), 0 },
6266 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xe0000001 }, /* XP */
6267 { WM_SYSKEYUP
, wparam
|lparam
, 'N', 0xe0000001 },
6268 { WM_SYSKEYUP
, sent
|wparam
|lparam
, 'N', 0xe0000001 },
6269 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xc0000001 }, /* XP */
6270 { WM_KEYUP
, wparam
|lparam
, VK_MENU
, 0xc0000001 },
6271 { WM_KEYUP
, sent
|wparam
|lparam
, VK_MENU
, 0xc0000001 },
6274 static const struct message WmCtrlAltVkN
[] = {
6275 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 1 }, /* XP */
6276 { WM_KEYDOWN
, wparam
|lparam
, VK_CONTROL
, 1 },
6277 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_CONTROL
, 1 },
6278 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 }, /* XP */
6279 { WM_KEYDOWN
, wparam
|lparam
, VK_MENU
, 0x20000001 },
6280 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
6281 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0x20000001 }, /* XP */
6282 { WM_KEYDOWN
, wparam
|lparam
, 'N', 0x20000001 },
6283 { WM_KEYDOWN
, sent
|wparam
|lparam
, 'N', 0x20000001 },
6284 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xe0000001 }, /* XP */
6285 { WM_KEYUP
, wparam
|lparam
, 'N', 0xe0000001 },
6286 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xe0000001 },
6287 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xc0000001 }, /* XP */
6288 { WM_KEYUP
, wparam
|lparam
, VK_MENU
, 0xc0000001 },
6289 { WM_KEYUP
, sent
|wparam
|lparam
, VK_MENU
, 0xc0000001 },
6290 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 0xc0000001 }, /* XP */
6291 { WM_KEYUP
, wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
6292 { WM_KEYUP
, sent
|wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
6295 static const struct message WmCtrlShiftVkN
[] = {
6296 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 1 }, /* XP */
6297 { WM_KEYDOWN
, wparam
|lparam
, VK_CONTROL
, 1 },
6298 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_CONTROL
, 1 },
6299 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 1 }, /* XP */
6300 { WM_KEYDOWN
, wparam
|lparam
, VK_SHIFT
, 1 },
6301 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_SHIFT
, 1 },
6302 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 1 }, /* XP */
6303 { WM_KEYDOWN
, wparam
|lparam
, 'N', 1 },
6304 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1004,1), 0 },
6305 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xc0000001 }, /* XP */
6306 { WM_KEYUP
, wparam
|lparam
, 'N', 0xc0000001 },
6307 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xc0000001 },
6308 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 0xc0000001 }, /* XP */
6309 { WM_KEYUP
, wparam
|lparam
, VK_SHIFT
, 0xc0000001 },
6310 { WM_KEYUP
, sent
|wparam
|lparam
, VK_SHIFT
, 0xc0000001 },
6311 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 0xc0000001 }, /* XP */
6312 { WM_KEYUP
, wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
6313 { WM_KEYUP
, sent
|wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
6316 static const struct message WmCtrlAltShiftVkN
[] = {
6317 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 1 }, /* XP */
6318 { WM_KEYDOWN
, wparam
|lparam
, VK_CONTROL
, 1 },
6319 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_CONTROL
, 1 },
6320 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 }, /* XP */
6321 { WM_KEYDOWN
, wparam
|lparam
, VK_MENU
, 0x20000001 },
6322 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
6323 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 0x20000001 }, /* XP */
6324 { WM_KEYDOWN
, wparam
|lparam
, VK_SHIFT
, 0x20000001 },
6325 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_SHIFT
, 0x20000001 },
6326 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0x20000001 }, /* XP */
6327 { WM_KEYDOWN
, wparam
|lparam
, 'N', 0x20000001 },
6328 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1005,1), 0 },
6329 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xe0000001 }, /* XP */
6330 { WM_KEYUP
, wparam
|lparam
, 'N', 0xe0000001 },
6331 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xe0000001 },
6332 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 0xe0000001 }, /* XP */
6333 { WM_KEYUP
, wparam
|lparam
, VK_SHIFT
, 0xe0000001 },
6334 { WM_KEYUP
, sent
|wparam
|lparam
, VK_SHIFT
, 0xe0000001 },
6335 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xc0000001 }, /* XP */
6336 { WM_KEYUP
, wparam
|lparam
, VK_MENU
, 0xc0000001 },
6337 { WM_KEYUP
, sent
|wparam
|lparam
, VK_MENU
, 0xc0000001 },
6338 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 0xc0000001 }, /* XP */
6339 { WM_KEYUP
, wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
6340 { WM_KEYUP
, sent
|wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
6343 static const struct message WmAltPressRelease
[] = {
6344 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 }, /* XP */
6345 { WM_SYSKEYDOWN
, wparam
|lparam
, VK_MENU
, 0x20000001 },
6346 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
6347 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xc0000001 }, /* XP */
6348 { WM_SYSKEYUP
, wparam
|lparam
, VK_MENU
, 0xc0000001 },
6349 { WM_SYSKEYUP
, sent
|wparam
|lparam
, VK_MENU
, 0xc0000001 },
6350 { WM_SYSCOMMAND
, sent
|defwinproc
|wparam
|lparam
, SC_KEYMENU
, 0 },
6351 { HCBT_SYSCOMMAND
, hook
},
6352 { WM_ENTERMENULOOP
, sent
|defwinproc
|wparam
|lparam
, 0, 0 },
6353 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
6354 { WM_INITMENU
, sent
|defwinproc
},
6355 { EVENT_SYSTEM_MENUSTART
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 0 },
6356 { WM_MENUSELECT
, sent
|defwinproc
|wparam
, MAKEWPARAM(0,MF_SYSMENU
|MF_POPUP
|MF_HILITE
) },
6357 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 1 },
6359 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x30000001 }, /* XP */
6361 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 0 },
6362 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, 0, 0, },
6363 { WM_CAPTURECHANGED
, sent
|defwinproc
},
6364 { WM_MENUSELECT
, sent
|defwinproc
|wparam
|optional
, MAKEWPARAM(0,0xffff) },
6365 { EVENT_SYSTEM_MENUEND
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 0 },
6366 { WM_EXITMENULOOP
, sent
|defwinproc
},
6367 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xc0000001 }, /* XP */
6368 { WM_SYSKEYUP
, wparam
|lparam
, VK_MENU
, 0xc0000001 },
6369 { WM_SYSKEYUP
, sent
|wparam
|lparam
, VK_MENU
, 0xc0000001 },
6372 static const struct message WmAltMouseButton
[] = {
6373 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 }, /* XP */
6374 { WM_SYSKEYDOWN
, wparam
|lparam
, VK_MENU
, 0x20000001 },
6375 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
6376 { WM_MOUSEMOVE
, wparam
|optional
, 0, 0 },
6377 { WM_MOUSEMOVE
, sent
|wparam
|optional
, 0, 0 },
6378 { WM_LBUTTONDOWN
, wparam
, MK_LBUTTON
, 0 },
6379 { WM_LBUTTONDOWN
, sent
|wparam
, MK_LBUTTON
, 0 },
6380 { WM_LBUTTONUP
, wparam
, 0, 0 },
6381 { WM_LBUTTONUP
, sent
|wparam
, 0, 0 },
6382 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xc0000001 }, /* XP */
6383 { WM_SYSKEYUP
, wparam
|lparam
, VK_MENU
, 0xc0000001 },
6384 { WM_SYSKEYUP
, sent
|wparam
|lparam
, VK_MENU
, 0xc0000001 },
6387 static const struct message WmF1Seq
[] = {
6388 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_F1
, 1 }, /* XP */
6389 { WM_KEYDOWN
, wparam
|lparam
, VK_F1
, 1 },
6390 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_F1
, 0x00000001 },
6391 { WM_KEYF1
, wparam
|lparam
, 0, 0 },
6392 { WM_KEYF1
, sent
|wparam
|lparam
, 0, 0 },
6393 { WM_HELP
, sent
|defwinproc
},
6394 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_F1
, 0xc0000001 }, /* XP */
6395 { WM_KEYUP
, wparam
|lparam
, VK_F1
, 0xc0000001 },
6396 { WM_KEYUP
, sent
|wparam
|lparam
, VK_F1
, 0xc0000001 },
6399 static const struct message WmVkAppsSeq
[] = {
6400 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_APPS
, 1 }, /* XP */
6401 { WM_KEYDOWN
, wparam
|lparam
, VK_APPS
, 1 },
6402 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_APPS
, 0x00000001 },
6403 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_APPS
, 0xc0000001 }, /* XP */
6404 { WM_KEYUP
, wparam
|lparam
, VK_APPS
, 0xc0000001 },
6405 { WM_KEYUP
, sent
|wparam
|lparam
, VK_APPS
, 0xc0000001 },
6406 { WM_CONTEXTMENU
, lparam
, /*hwnd*/0, (LPARAM
)-1 },
6407 { WM_CONTEXTMENU
, sent
|lparam
, /*hwnd*/0, (LPARAM
)-1 },
6411 static void pump_msg_loop(HWND hwnd
, HACCEL hAccel
)
6415 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
))
6417 struct message log_msg
;
6419 trace("accel: %p, %04x, %08lx, %08lx\n", msg
.hwnd
, msg
.message
, msg
.wParam
, msg
.lParam
);
6421 /* ignore some unwanted messages */
6422 if (msg
.message
== WM_MOUSEMOVE
||
6423 msg
.message
== WM_GETICON
||
6424 msg
.message
== WM_TIMER
||
6425 msg
.message
== WM_DEVICECHANGE
)
6428 log_msg
.message
= msg
.message
;
6429 log_msg
.flags
= wparam
|lparam
;
6430 log_msg
.wParam
= msg
.wParam
;
6431 log_msg
.lParam
= msg
.lParam
;
6432 add_message(&log_msg
);
6434 if (!hAccel
|| !TranslateAccelerator(hwnd
, hAccel
, &msg
))
6436 TranslateMessage(&msg
);
6437 DispatchMessage(&msg
);
6442 static void test_accelerators(void)
6447 HWND hwnd
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
6448 100, 100, 200, 200, 0, 0, 0, NULL
);
6457 ok(GetFocus() == hwnd
, "wrong focus window %p\n", GetFocus());
6459 state
= GetKeyState(VK_SHIFT
);
6460 ok(!(state
& 0x8000), "wrong Shift state %04x\n", state
);
6461 state
= GetKeyState(VK_CAPITAL
);
6462 ok(state
== 0, "wrong CapsLock state %04x\n", state
);
6464 hAccel
= LoadAccelerators(GetModuleHandleA(0), MAKEINTRESOURCE(1));
6465 assert(hAccel
!= 0);
6468 pump_msg_loop(hwnd
, 0);
6471 trace("testing VK_N press/release\n");
6473 keybd_event('N', 0, 0, 0);
6474 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
6475 pump_msg_loop(hwnd
, hAccel
);
6476 ok_sequence(WmVkN
, "VK_N press/release", FALSE
);
6478 trace("testing Shift+VK_N press/release\n");
6480 keybd_event(VK_SHIFT
, 0, 0, 0);
6481 keybd_event('N', 0, 0, 0);
6482 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
6483 keybd_event(VK_SHIFT
, 0, KEYEVENTF_KEYUP
, 0);
6484 pump_msg_loop(hwnd
, hAccel
);
6485 ok_sequence(WmShiftVkN
, "Shift+VK_N press/release", FALSE
);
6487 trace("testing Ctrl+VK_N press/release\n");
6489 keybd_event(VK_CONTROL
, 0, 0, 0);
6490 keybd_event('N', 0, 0, 0);
6491 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
6492 keybd_event(VK_CONTROL
, 0, KEYEVENTF_KEYUP
, 0);
6493 pump_msg_loop(hwnd
, hAccel
);
6494 ok_sequence(WmCtrlVkN
, "Ctrl+VK_N press/release", FALSE
);
6496 trace("testing Alt+VK_N press/release\n");
6498 keybd_event(VK_MENU
, 0, 0, 0);
6499 keybd_event('N', 0, 0, 0);
6500 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
6501 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
6502 pump_msg_loop(hwnd
, hAccel
);
6503 ok_sequence(WmAltVkN
, "Alt+VK_N press/release", FALSE
);
6505 trace("testing Ctrl+Alt+VK_N press/release 1\n");
6507 keybd_event(VK_CONTROL
, 0, 0, 0);
6508 keybd_event(VK_MENU
, 0, 0, 0);
6509 keybd_event('N', 0, 0, 0);
6510 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
6511 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
6512 keybd_event(VK_CONTROL
, 0, KEYEVENTF_KEYUP
, 0);
6513 pump_msg_loop(hwnd
, hAccel
);
6514 ok_sequence(WmCtrlAltVkN
, "Ctrl+Alt+VK_N press/release 1", FALSE
);
6516 ret
= DestroyAcceleratorTable(hAccel
);
6517 ok( ret
, "DestroyAcceleratorTable error %d\n", GetLastError());
6519 hAccel
= LoadAccelerators(GetModuleHandleA(0), MAKEINTRESOURCE(2));
6520 assert(hAccel
!= 0);
6522 trace("testing VK_N press/release\n");
6524 keybd_event('N', 0, 0, 0);
6525 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
6526 pump_msg_loop(hwnd
, hAccel
);
6527 ok_sequence(WmVkN
, "VK_N press/release", FALSE
);
6529 trace("testing Shift+VK_N press/release\n");
6531 keybd_event(VK_SHIFT
, 0, 0, 0);
6532 keybd_event('N', 0, 0, 0);
6533 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
6534 keybd_event(VK_SHIFT
, 0, KEYEVENTF_KEYUP
, 0);
6535 pump_msg_loop(hwnd
, hAccel
);
6536 ok_sequence(WmShiftVkN
, "Shift+VK_N press/release", FALSE
);
6538 trace("testing Ctrl+VK_N press/release 2\n");
6540 keybd_event(VK_CONTROL
, 0, 0, 0);
6541 keybd_event('N', 0, 0, 0);
6542 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
6543 keybd_event(VK_CONTROL
, 0, KEYEVENTF_KEYUP
, 0);
6544 pump_msg_loop(hwnd
, hAccel
);
6545 ok_sequence(WmCtrlVkN_2
, "Ctrl+VK_N press/release 2", FALSE
);
6547 trace("testing Alt+VK_N press/release 2\n");
6549 keybd_event(VK_MENU
, 0, 0, 0);
6550 keybd_event('N', 0, 0, 0);
6551 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
6552 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
6553 pump_msg_loop(hwnd
, hAccel
);
6554 ok_sequence(WmAltVkN_2
, "Alt+VK_N press/release 2", FALSE
);
6556 trace("testing Ctrl+Alt+VK_N press/release 2\n");
6558 keybd_event(VK_CONTROL
, 0, 0, 0);
6559 keybd_event(VK_MENU
, 0, 0, 0);
6560 keybd_event('N', 0, 0, 0);
6561 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
6562 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
6563 keybd_event(VK_CONTROL
, 0, KEYEVENTF_KEYUP
, 0);
6564 pump_msg_loop(hwnd
, hAccel
);
6565 ok_sequence(WmCtrlAltVkN
, "Ctrl+Alt+VK_N press/release 2", FALSE
);
6567 trace("testing Ctrl+Shift+VK_N press/release\n");
6569 keybd_event(VK_CONTROL
, 0, 0, 0);
6570 keybd_event(VK_SHIFT
, 0, 0, 0);
6571 keybd_event('N', 0, 0, 0);
6572 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
6573 keybd_event(VK_SHIFT
, 0, KEYEVENTF_KEYUP
, 0);
6574 keybd_event(VK_CONTROL
, 0, KEYEVENTF_KEYUP
, 0);
6575 pump_msg_loop(hwnd
, hAccel
);
6576 ok_sequence(WmCtrlShiftVkN
, "Ctrl+Shift+VK_N press/release", FALSE
);
6578 trace("testing Ctrl+Alt+Shift+VK_N press/release\n");
6580 keybd_event(VK_CONTROL
, 0, 0, 0);
6581 keybd_event(VK_MENU
, 0, 0, 0);
6582 keybd_event(VK_SHIFT
, 0, 0, 0);
6583 keybd_event('N', 0, 0, 0);
6584 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
6585 keybd_event(VK_SHIFT
, 0, KEYEVENTF_KEYUP
, 0);
6586 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
6587 keybd_event(VK_CONTROL
, 0, KEYEVENTF_KEYUP
, 0);
6588 pump_msg_loop(hwnd
, hAccel
);
6589 ok_sequence(WmCtrlAltShiftVkN
, "Ctrl+Alt+Shift+VK_N press/release", FALSE
);
6591 ret
= DestroyAcceleratorTable(hAccel
);
6592 ok( ret
, "DestroyAcceleratorTable error %d\n", GetLastError());
6594 trace("testing Alt press/release\n");
6596 keybd_event(VK_MENU
, 0, 0, 0);
6597 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
6598 keybd_event(VK_MENU
, 0, 0, 0);
6599 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
6600 pump_msg_loop(hwnd
, 0);
6601 /* this test doesn't pass in Wine for managed windows */
6602 ok_sequence(WmAltPressRelease
, "Alt press/release", TRUE
);
6604 trace("testing Alt+MouseButton press/release\n");
6605 /* first, move mouse pointer inside of the window client area */
6606 GetClientRect(hwnd
, &rc
);
6607 MapWindowPoints(hwnd
, 0, (LPPOINT
)&rc
, 2);
6608 rc
.left
+= (rc
.right
- rc
.left
)/2;
6609 rc
.top
+= (rc
.bottom
- rc
.top
)/2;
6610 SetCursorPos(rc
.left
, rc
.top
);
6614 keybd_event(VK_MENU
, 0, 0, 0);
6615 mouse_event(MOUSEEVENTF_LEFTDOWN
, 0, 0, 0, 0);
6616 mouse_event(MOUSEEVENTF_LEFTUP
, 0, 0, 0, 0);
6617 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
6618 pump_msg_loop(hwnd
, 0);
6619 ok_sequence(WmAltMouseButton
, "Alt+MouseButton press/release", FALSE
);
6621 trace("testing VK_F1 press/release\n");
6622 keybd_event(VK_F1
, 0, 0, 0);
6623 keybd_event(VK_F1
, 0, KEYEVENTF_KEYUP
, 0);
6624 pump_msg_loop(hwnd
, 0);
6625 ok_sequence(WmF1Seq
, "F1 press/release", FALSE
);
6627 trace("testing VK_APPS press/release\n");
6628 keybd_event(VK_APPS
, 0, 0, 0);
6629 keybd_event(VK_APPS
, 0, KEYEVENTF_KEYUP
, 0);
6630 pump_msg_loop(hwnd
, 0);
6631 ok_sequence(WmVkAppsSeq
, "VK_APPS press/release", FALSE
);
6633 DestroyWindow(hwnd
);
6636 /************* window procedures ********************/
6638 static LRESULT
MsgCheckProc (BOOL unicode
, HWND hwnd
, UINT message
,
6639 WPARAM wParam
, LPARAM lParam
)
6641 static long defwndproc_counter
= 0;
6642 static long beginpaint_counter
= 0;
6646 trace("%p, %04x, %08lx, %08lx\n", hwnd
, message
, wParam
, lParam
);
6648 /* explicitly ignore WM_GETICON message */
6649 if (message
== WM_GETICON
) return 0;
6651 /* ignore registered messages */
6652 if (message
>= 0xc000) return 0;
6658 LONG style
= GetWindowLongA(hwnd
, GWL_STYLE
);
6659 ok((BOOL
)wParam
== !(style
& WS_DISABLED
),
6660 "wrong WS_DISABLED state: %ld != %d\n", wParam
, !(style
& WS_DISABLED
));
6664 case WM_CAPTURECHANGED
:
6665 if (test_DestroyWindow_flag
)
6667 DWORD style
= GetWindowLongA(hwnd
, GWL_STYLE
);
6668 if (style
& WS_CHILD
)
6669 lParam
= GetWindowLongPtrA(hwnd
, GWLP_ID
);
6670 else if (style
& WS_POPUP
)
6671 lParam
= WND_POPUP_ID
;
6673 lParam
= WND_PARENT_ID
;
6681 ok(!GetWindow(hwnd
, GW_CHILD
), "children should be unlinked at this point\n");
6682 capture
= GetCapture();
6685 ok(capture
== hwnd
, "capture should NOT be released at this point (capture %p)\n", capture
);
6686 trace("current capture %p, releasing...\n", capture
);
6693 ok(pGetAncestor(hwnd
, GA_PARENT
) != 0, "parent should NOT be unlinked at this point\n");
6694 if (test_DestroyWindow_flag
)
6696 DWORD style
= GetWindowLongA(hwnd
, GWL_STYLE
);
6697 if (style
& WS_CHILD
)
6698 lParam
= GetWindowLongPtrA(hwnd
, GWLP_ID
);
6699 else if (style
& WS_POPUP
)
6700 lParam
= WND_POPUP_ID
;
6702 lParam
= WND_PARENT_ID
;
6706 /* test_accelerators() depends on this */
6713 case WM_DEVICECHANGE
:
6716 case WM_WINDOWPOSCHANGING
:
6717 case WM_WINDOWPOSCHANGED
:
6719 WINDOWPOS
*winpos
= (WINDOWPOS
*)lParam
;
6721 trace("%s\n", (message
== WM_WINDOWPOSCHANGING
) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
6722 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x ",
6723 winpos
->hwnd
, winpos
->hwndInsertAfter
,
6724 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
6725 dump_winpos_flags(winpos
->flags
);
6727 /* Log only documented flags, win2k uses 0x1000 and 0x2000
6728 * in the high word for internal purposes
6730 wParam
= winpos
->flags
& 0xffff;
6731 /* We are not interested in the flags that don't match under XP and Win9x */
6732 wParam
&= ~(SWP_NOZORDER
);
6737 msg
.message
= message
;
6738 msg
.flags
= sent
|wparam
|lparam
;
6739 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
6740 if (beginpaint_counter
) msg
.flags
|= beginpaint
;
6741 msg
.wParam
= wParam
;
6742 msg
.lParam
= lParam
;
6745 if (message
== WM_GETMINMAXINFO
&& (GetWindowLongA(hwnd
, GWL_STYLE
) & WS_CHILD
))
6747 HWND parent
= GetParent(hwnd
);
6749 MINMAXINFO
*minmax
= (MINMAXINFO
*)lParam
;
6751 GetClientRect(parent
, &rc
);
6752 trace("parent %p client size = (%d x %d)\n", parent
, rc
.right
, rc
.bottom
);
6753 trace("Reserved=%d,%d MaxSize=%d,%d MaxPos=%d,%d MinTrack=%d,%d MaxTrack=%d,%d\n",
6754 minmax
->ptReserved
.x
, minmax
->ptReserved
.y
,
6755 minmax
->ptMaxSize
.x
, minmax
->ptMaxSize
.y
,
6756 minmax
->ptMaxPosition
.x
, minmax
->ptMaxPosition
.y
,
6757 minmax
->ptMinTrackSize
.x
, minmax
->ptMinTrackSize
.y
,
6758 minmax
->ptMaxTrackSize
.x
, minmax
->ptMaxTrackSize
.y
);
6760 ok(minmax
->ptMaxSize
.x
== rc
.right
, "default width of maximized child %d != %d\n",
6761 minmax
->ptMaxSize
.x
, rc
.right
);
6762 ok(minmax
->ptMaxSize
.y
== rc
.bottom
, "default height of maximized child %d != %d\n",
6763 minmax
->ptMaxSize
.y
, rc
.bottom
);
6766 if (message
== WM_PAINT
)
6769 beginpaint_counter
++;
6770 BeginPaint( hwnd
, &ps
);
6771 beginpaint_counter
--;
6772 EndPaint( hwnd
, &ps
);
6776 defwndproc_counter
++;
6777 ret
= unicode
? DefWindowProcW(hwnd
, message
, wParam
, lParam
)
6778 : DefWindowProcA(hwnd
, message
, wParam
, lParam
);
6779 defwndproc_counter
--;
6784 static LRESULT WINAPI
MsgCheckProcA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
6786 return MsgCheckProc (FALSE
, hwnd
, message
, wParam
, lParam
);
6789 static LRESULT WINAPI
MsgCheckProcW(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
6791 return MsgCheckProc (TRUE
, hwnd
, message
, wParam
, lParam
);
6794 static LRESULT WINAPI
PopupMsgCheckProcA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
6796 static long defwndproc_counter
= 0;
6800 trace("popup: %p, %04x, %08lx, %08lx\n", hwnd
, message
, wParam
, lParam
);
6805 /* explicitly ignore WM_GETICON message */
6807 case WM_QUERYENDSESSION
:
6809 lParam
&= ~0x01; /* Vista adds a 0x01 flag */
6813 msg
.message
= message
;
6814 msg
.flags
= sent
|wparam
|lparam
;
6815 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
6816 msg
.wParam
= wParam
;
6817 msg
.lParam
= lParam
;
6820 if (message
== WM_CREATE
)
6822 DWORD style
= GetWindowLongA(hwnd
, GWL_STYLE
) | WS_VISIBLE
;
6823 SetWindowLongA(hwnd
, GWL_STYLE
, style
);
6826 defwndproc_counter
++;
6827 ret
= DefWindowProcA(hwnd
, message
, wParam
, lParam
);
6828 defwndproc_counter
--;
6833 static LRESULT WINAPI
ParentMsgCheckProcA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
6835 static long defwndproc_counter
= 0;
6836 static long beginpaint_counter
= 0;
6839 LPARAM logged_lParam
;
6841 trace("parent: %p, %04x, %08lx, %08lx\n", hwnd
, message
, wParam
, lParam
);
6843 /* explicitly ignore WM_GETICON message */
6844 if (message
== WM_GETICON
) return 0;
6846 /* ignore registered messages */
6847 if (message
>= 0xc000) return 0;
6849 logged_lParam
=lParam
;
6850 if (log_all_parent_messages
||
6851 message
== WM_PARENTNOTIFY
|| message
== WM_CANCELMODE
||
6852 message
== WM_SETFOCUS
|| message
== WM_KILLFOCUS
||
6853 message
== WM_ENABLE
|| message
== WM_ENTERIDLE
||
6854 message
== WM_DRAWITEM
||
6855 message
== WM_IME_SETCONTEXT
)
6869 INT ret
= GetClipBox((HDC
)wParam
, &rc
);
6871 trace("WM_ERASEBKGND: GetClipBox()=%d, (%d,%d-%d,%d)\n",
6872 ret
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
6876 case WM_WINDOWPOSCHANGING
:
6877 case WM_WINDOWPOSCHANGED
:
6879 WINDOWPOS
*winpos
= (WINDOWPOS
*)lParam
;
6881 trace("%s\n", (message
== WM_WINDOWPOSCHANGING
) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
6882 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x ",
6883 winpos
->hwnd
, winpos
->hwndInsertAfter
,
6884 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
6885 dump_winpos_flags(winpos
->flags
);
6887 /* Log only documented flags, win2k uses 0x1000 and 0x2000
6888 * in the high word for internal purposes
6890 wParam
= winpos
->flags
& 0xffff;
6891 /* We are not interested in the flags that don't match under XP and Win9x */
6892 wParam
&= ~(SWP_NOZORDER
);
6898 /* encode DRAWITEMSTRUCT into an LPARAM */
6899 DRAW_ITEM_STRUCT di
;
6900 DRAWITEMSTRUCT
*dis
= (DRAWITEMSTRUCT
*)lParam
;
6902 trace("WM_DRAWITEM: type %x, ctl_id %x, item_id %x, action %x, state %x\n",
6903 dis
->CtlType
, dis
->CtlID
, dis
->itemID
, dis
->itemAction
, dis
->itemState
);
6905 di
.u
.item
.type
= dis
->CtlType
;
6906 di
.u
.item
.ctl_id
= dis
->CtlID
;
6907 di
.u
.item
.item_id
= dis
->itemID
;
6908 di
.u
.item
.action
= dis
->itemAction
;
6909 di
.u
.item
.state
= dis
->itemState
;
6911 logged_lParam
= di
.u
.lp
;
6916 msg
.message
= message
;
6917 msg
.flags
= sent
|parent
|wparam
|lparam
;
6918 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
6919 if (beginpaint_counter
) msg
.flags
|= beginpaint
;
6920 msg
.wParam
= wParam
;
6921 msg
.lParam
= logged_lParam
;
6925 if (message
== WM_PAINT
)
6928 beginpaint_counter
++;
6929 BeginPaint( hwnd
, &ps
);
6930 beginpaint_counter
--;
6931 EndPaint( hwnd
, &ps
);
6935 defwndproc_counter
++;
6936 ret
= DefWindowProcA(hwnd
, message
, wParam
, lParam
);
6937 defwndproc_counter
--;
6942 static LRESULT WINAPI
TestDlgProcA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
6944 static long defwndproc_counter
= 0;
6948 trace("dialog: %p, %04x, %08lx, %08lx\n", hwnd
, message
, wParam
, lParam
);
6950 /* explicitly ignore WM_GETICON message */
6951 if (message
== WM_GETICON
) return 0;
6953 /* ignore registered messages */
6954 if (message
>= 0xc000) return 0;
6958 DefDlgProcA(hwnd
, DM_SETDEFID
, 1, 0);
6959 ret
= DefDlgProcA(hwnd
, DM_GETDEFID
, 0, 0);
6960 if (after_end_dialog
)
6961 ok( ret
== 0, "DM_GETDEFID should return 0 after EndDialog, got %lx\n", ret
);
6963 ok(HIWORD(ret
) == DC_HASDEFID
, "DM_GETDEFID should return DC_HASDEFID, got %lx\n", ret
);
6968 case WM_WINDOWPOSCHANGING
:
6969 case WM_WINDOWPOSCHANGED
:
6971 WINDOWPOS
*winpos
= (WINDOWPOS
*)lParam
;
6973 trace("%s\n", (message
== WM_WINDOWPOSCHANGING
) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
6974 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x ",
6975 winpos
->hwnd
, winpos
->hwndInsertAfter
,
6976 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
6977 dump_winpos_flags(winpos
->flags
);
6979 /* Log only documented flags, win2k uses 0x1000 and 0x2000
6980 * in the high word for internal purposes
6982 wParam
= winpos
->flags
& 0xffff;
6983 /* We are not interested in the flags that don't match under XP and Win9x */
6984 wParam
&= ~(SWP_NOZORDER
);
6989 msg
.message
= message
;
6990 msg
.flags
= sent
|wparam
|lparam
;
6991 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
6992 msg
.wParam
= wParam
;
6993 msg
.lParam
= lParam
;
6996 defwndproc_counter
++;
6997 ret
= DefDlgProcA(hwnd
, message
, wParam
, lParam
);
6998 defwndproc_counter
--;
7003 static void dump_winpos_flags(UINT flags
)
7005 if (!winetest_debug
) return;
7007 if (flags
& SWP_SHOWWINDOW
) printf("|SWP_SHOWWINDOW");
7008 if (flags
& SWP_HIDEWINDOW
) printf("|SWP_HIDEWINDOW");
7009 if (flags
& SWP_NOACTIVATE
) printf("|SWP_NOACTIVATE");
7010 if (flags
& SWP_FRAMECHANGED
) printf("|SWP_FRAMECHANGED");
7011 if (flags
& SWP_NOCOPYBITS
) printf("|SWP_NOCOPYBITS");
7012 if (flags
& SWP_NOOWNERZORDER
) printf("|SWP_NOOWNERZORDER");
7013 if (flags
& SWP_NOSENDCHANGING
) printf("|SWP_NOSENDCHANGING");
7014 if (flags
& SWP_DEFERERASE
) printf("|SWP_DEFERERASE");
7015 if (flags
& SWP_ASYNCWINDOWPOS
) printf("|SWP_ASYNCWINDOWPOS");
7016 if (flags
& SWP_NOZORDER
) printf("|SWP_NOZORDER");
7017 if (flags
& SWP_NOREDRAW
) printf("|SWP_NOREDRAW");
7018 if (flags
& SWP_NOSIZE
) printf("|SWP_NOSIZE");
7019 if (flags
& SWP_NOMOVE
) printf("|SWP_NOMOVE");
7020 if (flags
& SWP_NOCLIENTSIZE
) printf("|SWP_NOCLIENTSIZE");
7021 if (flags
& SWP_NOCLIENTMOVE
) printf("|SWP_NOCLIENTMOVE");
7023 #define DUMPED_FLAGS \
7029 SWP_FRAMECHANGED | \
7033 SWP_NOOWNERZORDER | \
7034 SWP_NOSENDCHANGING | \
7036 SWP_ASYNCWINDOWPOS | \
7037 SWP_NOCLIENTSIZE | \
7040 if(flags
& ~DUMPED_FLAGS
) printf("|0x%04x", flags
& ~DUMPED_FLAGS
);
7045 static LRESULT WINAPI
ShowWindowProcA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
7047 static long defwndproc_counter
= 0;
7051 /* log only specific messages we are interested in */
7054 #if 0 /* probably log these as well */
7060 trace("WM_SHOWWINDOW %ld\n", wParam
);
7063 trace("WM_SIZE %ld\n", wParam
);
7068 case WM_GETMINMAXINFO
:
7069 trace("WM_GETMINMAXINFO\n");
7072 case WM_WINDOWPOSCHANGING
:
7073 case WM_WINDOWPOSCHANGED
:
7075 WINDOWPOS
*winpos
= (WINDOWPOS
*)lParam
;
7077 trace("%s\n", (message
== WM_WINDOWPOSCHANGING
) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
7078 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
7079 winpos
->hwnd
, winpos
->hwndInsertAfter
,
7080 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
7082 dump_winpos_flags(winpos
->flags
);
7084 /* Log only documented flags, win2k uses 0x1000 and 0x2000
7085 * in the high word for internal purposes
7087 wParam
= winpos
->flags
& 0xffff;
7088 /* We are not interested in the flags that don't match under XP and Win9x */
7089 wParam
&= ~(SWP_NOZORDER
);
7093 default: /* ignore */
7094 /*trace("showwindow: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);*/
7095 return DefWindowProcA(hwnd
, message
, wParam
, lParam
);
7098 msg
.message
= message
;
7099 msg
.flags
= sent
|wparam
|lparam
;
7100 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
7101 msg
.wParam
= wParam
;
7102 msg
.lParam
= lParam
;
7105 defwndproc_counter
++;
7106 ret
= DefWindowProcA(hwnd
, message
, wParam
, lParam
);
7107 defwndproc_counter
--;
7112 LRESULT WINAPI
PaintLoopProcA(HWND hWnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
7116 case WM_CREATE
: return 0;
7125 if (PeekMessageA(&msg2
, 0, 0, 0, 1))
7127 TranslateMessage(&msg2
);
7128 DispatchMessage(&msg2
);
7132 else ok(broken(1), "infinite loop\n");
7134 paint_loop_done
= 1;
7135 return DefWindowProcA(hWnd
,msg
,wParam
,lParam
);
7138 return DefWindowProcA(hWnd
,msg
,wParam
,lParam
);
7141 static BOOL
RegisterWindowClasses(void)
7147 cls
.lpfnWndProc
= MsgCheckProcA
;
7150 cls
.hInstance
= GetModuleHandleA(0);
7152 cls
.hCursor
= LoadCursorA(0, (LPSTR
)IDC_ARROW
);
7153 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
7154 cls
.lpszMenuName
= NULL
;
7155 cls
.lpszClassName
= "TestWindowClass";
7156 if(!RegisterClassA(&cls
)) return FALSE
;
7158 cls
.lpfnWndProc
= ShowWindowProcA
;
7159 cls
.lpszClassName
= "ShowWindowClass";
7160 if(!RegisterClassA(&cls
)) return FALSE
;
7162 cls
.lpfnWndProc
= PopupMsgCheckProcA
;
7163 cls
.lpszClassName
= "TestPopupClass";
7164 if(!RegisterClassA(&cls
)) return FALSE
;
7166 cls
.lpfnWndProc
= ParentMsgCheckProcA
;
7167 cls
.lpszClassName
= "TestParentClass";
7168 if(!RegisterClassA(&cls
)) return FALSE
;
7170 cls
.lpfnWndProc
= DefWindowProcA
;
7171 cls
.lpszClassName
= "SimpleWindowClass";
7172 if(!RegisterClassA(&cls
)) return FALSE
;
7174 cls
.lpfnWndProc
= PaintLoopProcA
;
7175 cls
.lpszClassName
= "PaintLoopWindowClass";
7176 if(!RegisterClassA(&cls
)) return FALSE
;
7178 cls
.style
= CS_NOCLOSE
;
7179 cls
.lpszClassName
= "NoCloseWindowClass";
7180 if(!RegisterClassA(&cls
)) return FALSE
;
7182 ok(GetClassInfoA(0, "#32770", &cls
), "GetClassInfo failed\n");
7184 cls
.hInstance
= GetModuleHandleA(0);
7185 cls
.hbrBackground
= 0;
7186 cls
.lpfnWndProc
= TestDlgProcA
;
7187 cls
.lpszClassName
= "TestDialogClass";
7188 if(!RegisterClassA(&cls
)) return FALSE
;
7191 clsW
.lpfnWndProc
= MsgCheckProcW
;
7192 clsW
.cbClsExtra
= 0;
7193 clsW
.cbWndExtra
= 0;
7194 clsW
.hInstance
= GetModuleHandleW(0);
7196 clsW
.hCursor
= LoadCursorW(0, (LPWSTR
)IDC_ARROW
);
7197 clsW
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
7198 clsW
.lpszMenuName
= NULL
;
7199 clsW
.lpszClassName
= testWindowClassW
;
7200 RegisterClassW(&clsW
); /* ignore error, this fails on Win9x */
7205 static BOOL
is_our_logged_class(HWND hwnd
)
7209 if (GetClassNameA(hwnd
, buf
, sizeof(buf
)))
7211 if (!lstrcmpiA(buf
, "TestWindowClass") ||
7212 !lstrcmpiA(buf
, "ShowWindowClass") ||
7213 !lstrcmpiA(buf
, "TestParentClass") ||
7214 !lstrcmpiA(buf
, "TestPopupClass") ||
7215 !lstrcmpiA(buf
, "SimpleWindowClass") ||
7216 !lstrcmpiA(buf
, "TestDialogClass") ||
7217 !lstrcmpiA(buf
, "MDI_frame_class") ||
7218 !lstrcmpiA(buf
, "MDI_client_class") ||
7219 !lstrcmpiA(buf
, "MDI_child_class") ||
7220 !lstrcmpiA(buf
, "my_button_class") ||
7221 !lstrcmpiA(buf
, "my_edit_class") ||
7222 !lstrcmpiA(buf
, "static") ||
7223 !lstrcmpiA(buf
, "ListBox") ||
7224 !lstrcmpiA(buf
, "ComboBox") ||
7225 !lstrcmpiA(buf
, "MyDialogClass") ||
7226 !lstrcmpiA(buf
, "#32770") ||
7227 !lstrcmpiA(buf
, "#32768"))
7229 trace("ignoring window class %s\n", buf
);
7234 static HHOOK hCBT_hook
;
7235 static DWORD cbt_hook_thread_id
;
7237 static LRESULT CALLBACK
cbt_hook_proc(int nCode
, WPARAM wParam
, LPARAM lParam
)
7239 static const char * const CBT_code_name
[10] = {
7246 "HCBT_CLICKSKIPPED",
7250 const char *code_name
= (nCode
>= 0 && nCode
<= HCBT_SETFOCUS
) ? CBT_code_name
[nCode
] : "Unknown";
7253 trace("CBT: %d (%s), %08lx, %08lx\n", nCode
, code_name
, wParam
, lParam
);
7255 ok(cbt_hook_thread_id
== GetCurrentThreadId(), "we didn't ask for events from other threads\n");
7257 if (nCode
== HCBT_CLICKSKIPPED
)
7259 /* ignore this event, XP sends it a lot when switching focus between windows */
7260 return CallNextHookEx(hCBT_hook
, nCode
, wParam
, lParam
);
7263 if (nCode
== HCBT_SYSCOMMAND
|| nCode
== HCBT_KEYSKIPPED
)
7267 msg
.message
= nCode
;
7268 msg
.flags
= hook
|wparam
|lparam
;
7269 msg
.wParam
= wParam
;
7270 msg
.lParam
= lParam
;
7273 return CallNextHookEx(hCBT_hook
, nCode
, wParam
, lParam
);
7276 if (nCode
== HCBT_DESTROYWND
)
7278 if (test_DestroyWindow_flag
)
7280 DWORD style
= GetWindowLongA((HWND
)wParam
, GWL_STYLE
);
7281 if (style
& WS_CHILD
)
7282 lParam
= GetWindowLongPtrA((HWND
)wParam
, GWLP_ID
);
7283 else if (style
& WS_POPUP
)
7284 lParam
= WND_POPUP_ID
;
7286 lParam
= WND_PARENT_ID
;
7290 /* Log also SetFocus(0) calls */
7291 hwnd
= wParam
? (HWND
)wParam
: (HWND
)lParam
;
7293 if (is_our_logged_class(hwnd
))
7297 msg
.message
= nCode
;
7298 msg
.flags
= hook
|wparam
|lparam
;
7299 msg
.wParam
= wParam
;
7300 msg
.lParam
= lParam
;
7303 return CallNextHookEx(hCBT_hook
, nCode
, wParam
, lParam
);
7306 static void CALLBACK
win_event_proc(HWINEVENTHOOK hevent
,
7314 trace("WEH:%p,event %08x,hwnd %p,obj %08x,id %08x,thread %08x,time %08x\n",
7315 hevent
, event
, hwnd
, object_id
, child_id
, thread_id
, event_time
);
7317 ok(thread_id
== GetCurrentThreadId(), "we didn't ask for events from other threads\n");
7319 /* ignore mouse cursor events */
7320 if (object_id
== OBJID_CURSOR
) return;
7322 if (!hwnd
|| is_our_logged_class(hwnd
))
7326 msg
.message
= event
;
7327 msg
.flags
= winevent_hook
|wparam
|lparam
;
7328 msg
.wParam
= object_id
;
7329 msg
.lParam
= child_id
;
7334 static const WCHAR wszUnicode
[] = {'U','n','i','c','o','d','e',0};
7335 static const WCHAR wszAnsi
[] = {'U',0};
7337 static LRESULT CALLBACK
MsgConversionProcW(HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
7341 case CB_FINDSTRINGEXACT
:
7342 trace("String: %p\n", (LPCWSTR
)lParam
);
7343 if (!lstrcmpW((LPCWSTR
)lParam
, wszUnicode
))
7345 if (!lstrcmpW((LPCWSTR
)lParam
, wszAnsi
))
7349 return DefWindowProcW(hwnd
, uMsg
, wParam
, lParam
);
7352 static const struct message WmGetTextLengthAfromW
[] = {
7353 { WM_GETTEXTLENGTH
, sent
},
7354 { WM_GETTEXT
, sent
|optional
},
7358 static const WCHAR dummy_window_text
[] = {'d','u','m','m','y',' ','t','e','x','t',0};
7360 /* dummy window proc for WM_GETTEXTLENGTH test */
7361 static LRESULT CALLBACK
get_text_len_proc( HWND hwnd
, UINT msg
, WPARAM wp
, LPARAM lp
)
7365 case WM_GETTEXTLENGTH
:
7366 return lstrlenW(dummy_window_text
) + 37; /* some random length */
7368 lstrcpynW( (LPWSTR
)lp
, dummy_window_text
, wp
);
7369 return lstrlenW( (LPWSTR
)lp
);
7371 return DefWindowProcW( hwnd
, msg
, wp
, lp
);
7375 static void test_message_conversion(void)
7377 static const WCHAR wszMsgConversionClass
[] =
7378 {'M','s','g','C','o','n','v','e','r','s','i','o','n','C','l','a','s','s',0};
7382 WNDPROC wndproc
, newproc
;
7386 cls
.lpfnWndProc
= MsgConversionProcW
;
7389 cls
.hInstance
= GetModuleHandleW(NULL
);
7391 cls
.hCursor
= LoadCursorW(NULL
, (LPWSTR
)IDC_ARROW
);
7392 cls
.hbrBackground
= (HBRUSH
)(COLOR_BTNFACE
+1);
7393 cls
.lpszMenuName
= NULL
;
7394 cls
.lpszClassName
= wszMsgConversionClass
;
7395 /* this call will fail on Win9x, but that doesn't matter as this test is
7396 * meaningless on those platforms */
7397 if(!RegisterClassW(&cls
)) return;
7399 hwnd
= CreateWindowExW(0, wszMsgConversionClass
, NULL
, WS_OVERLAPPED
,
7400 100, 100, 200, 200, 0, 0, 0, NULL
);
7401 ok(hwnd
!= NULL
, "Window creation failed\n");
7405 wndproc
= (WNDPROC
)GetWindowLongPtrA(hwnd
, GWLP_WNDPROC
);
7406 lRes
= CallWindowProcA(wndproc
, hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
7407 ok(lRes
== 0, "String should have been converted\n");
7408 lRes
= CallWindowProcW(wndproc
, hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
7409 ok(lRes
== 1, "String shouldn't have been converted\n");
7413 wndproc
= (WNDPROC
)GetWindowLongPtrW(hwnd
, GWLP_WNDPROC
);
7414 lRes
= CallWindowProcA(wndproc
, hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
7415 ok(lRes
== 1, "String shouldn't have been converted\n");
7416 lRes
= CallWindowProcW(wndproc
, hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
7417 ok(lRes
== 1, "String shouldn't have been converted\n");
7419 /* Synchronous messages */
7421 lRes
= SendMessageA(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
7422 ok(lRes
== 0, "String should have been converted\n");
7423 lRes
= SendMessageW(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
7424 ok(lRes
== 1, "String shouldn't have been converted\n");
7426 /* Asynchronous messages */
7429 lRes
= PostMessageA(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
7430 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
7431 "PostMessage on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
7433 lRes
= PostMessageW(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
7434 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
7435 "PostMessage on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
7437 lRes
= PostThreadMessageA(GetCurrentThreadId(), CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
7438 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
7439 "PosThreadtMessage on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
7441 lRes
= PostThreadMessageW(GetCurrentThreadId(), CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
7442 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
7443 "PosThreadtMessage on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
7445 lRes
= SendNotifyMessageA(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
7446 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
7447 "SendNotifyMessage on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
7449 lRes
= SendNotifyMessageW(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
7450 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
7451 "SendNotifyMessage on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
7453 lRes
= SendMessageCallbackA(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
, NULL
, 0);
7454 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
7455 "SendMessageCallback on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
7457 lRes
= SendMessageCallbackW(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
, NULL
, 0);
7458 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
7459 "SendMessageCallback on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
7461 /* Check WM_GETTEXTLENGTH A->W behaviour, whether WM_GETTEXT is also sent or not */
7463 hwnd
= CreateWindowW (testWindowClassW
, wszUnicode
,
7464 WS_OVERLAPPEDWINDOW
,
7465 100, 100, 200, 200, 0, 0, 0, NULL
);
7468 lRes
= SendMessageA (hwnd
, WM_GETTEXTLENGTH
, 0, 0);
7469 ok_sequence(WmGetTextLengthAfromW
, "ANSI WM_GETTEXTLENGTH to Unicode window", FALSE
);
7470 ok( lRes
== WideCharToMultiByte( CP_ACP
, 0, wszUnicode
, lstrlenW(wszUnicode
), NULL
, 0, NULL
, NULL
),
7471 "got bad length %ld\n", lRes
);
7474 lRes
= CallWindowProcA( (WNDPROC
)GetWindowLongPtrA( hwnd
, GWLP_WNDPROC
),
7475 hwnd
, WM_GETTEXTLENGTH
, 0, 0);
7476 ok_sequence(WmGetTextLengthAfromW
, "ANSI WM_GETTEXTLENGTH to Unicode window", FALSE
);
7477 ok( lRes
== WideCharToMultiByte( CP_ACP
, 0, wszUnicode
, lstrlenW(wszUnicode
), NULL
, 0, NULL
, NULL
),
7478 "got bad length %ld\n", lRes
);
7480 wndproc
= (WNDPROC
)SetWindowLongPtrW( hwnd
, GWLP_WNDPROC
, (LONG_PTR
)get_text_len_proc
);
7481 newproc
= (WNDPROC
)GetWindowLongPtrA( hwnd
, GWLP_WNDPROC
);
7482 lRes
= CallWindowProcA( newproc
, hwnd
, WM_GETTEXTLENGTH
, 0, 0 );
7483 ok( lRes
== WideCharToMultiByte( CP_ACP
, 0, dummy_window_text
, lstrlenW(dummy_window_text
),
7484 NULL
, 0, NULL
, NULL
) ||
7485 broken(lRes
== lstrlenW(dummy_window_text
) + 37),
7486 "got bad length %ld\n", lRes
);
7488 SetWindowLongPtrW( hwnd
, GWLP_WNDPROC
, (LONG_PTR
)wndproc
); /* restore old wnd proc */
7489 lRes
= CallWindowProcA( newproc
, hwnd
, WM_GETTEXTLENGTH
, 0, 0 );
7490 ok( lRes
== WideCharToMultiByte( CP_ACP
, 0, dummy_window_text
, lstrlenW(dummy_window_text
),
7491 NULL
, 0, NULL
, NULL
) ||
7492 broken(lRes
== lstrlenW(dummy_window_text
) + 37),
7493 "got bad length %ld\n", lRes
);
7495 ret
= DestroyWindow(hwnd
);
7496 ok( ret
, "DestroyWindow() error %d\n", GetLastError());
7506 static VOID CALLBACK
tfunc(HWND hwnd
, UINT uMsg
, UINT_PTR id
, DWORD dwTime
)
7510 #define TIMER_ID 0x19
7512 static DWORD WINAPI
timer_thread_proc(LPVOID x
)
7514 struct timer_info
*info
= x
;
7517 r
= KillTimer(info
->hWnd
, 0x19);
7518 ok(r
,"KillTimer failed in thread\n");
7519 r
= SetTimer(info
->hWnd
,TIMER_ID
,10000,tfunc
);
7520 ok(r
,"SetTimer failed in thread\n");
7521 ok(r
==TIMER_ID
,"SetTimer id different\n");
7522 r
= SetEvent(info
->handles
[0]);
7523 ok(r
,"SetEvent failed in thread\n");
7527 static void test_timers(void)
7529 struct timer_info info
;
7532 info
.hWnd
= CreateWindow ("TestWindowClass", NULL
,
7533 WS_OVERLAPPEDWINDOW
,
7534 CW_USEDEFAULT
, CW_USEDEFAULT
, 300, 300, 0,
7537 info
.id
= SetTimer(info
.hWnd
,TIMER_ID
,10000,tfunc
);
7538 ok(info
.id
, "SetTimer failed\n");
7539 ok(info
.id
==TIMER_ID
, "SetTimer timer ID different\n");
7540 info
.handles
[0] = CreateEvent(NULL
,0,0,NULL
);
7541 info
.handles
[1] = CreateThread(NULL
,0,timer_thread_proc
,&info
,0,&id
);
7543 WaitForMultipleObjects(2, info
.handles
, FALSE
, INFINITE
);
7545 WaitForSingleObject(info
.handles
[1], INFINITE
);
7547 CloseHandle(info
.handles
[0]);
7548 CloseHandle(info
.handles
[1]);
7550 ok( KillTimer(info
.hWnd
, TIMER_ID
), "KillTimer failed\n");
7552 ok(DestroyWindow(info
.hWnd
), "failed to destroy window\n");
7555 static int count
= 0;
7556 static VOID CALLBACK
callback_count(
7566 static void test_timers_no_wnd(void)
7572 id
= SetTimer(NULL
, 0, 100, callback_count
);
7573 ok(id
!= 0, "did not get id from SetTimer.\n");
7574 id2
= SetTimer(NULL
, id
, 200, callback_count
);
7575 ok(id2
== id
, "did not get same id from SetTimer when replacing (%li expected %li).\n", id2
, id
);
7577 while (PeekMessage(&msg
, NULL
, 0, 0, PM_REMOVE
)) DispatchMessage(&msg
);
7578 ok(count
== 0, "did not get zero count as expected (%i).\n", count
);
7580 while (PeekMessage(&msg
, NULL
, 0, 0, PM_REMOVE
)) DispatchMessage(&msg
);
7581 ok(count
== 1, "did not get one count as expected (%i).\n", count
);
7582 KillTimer(NULL
, id
);
7584 while (PeekMessage(&msg
, NULL
, 0, 0, PM_REMOVE
)) DispatchMessage(&msg
);
7585 ok(count
== 1, "killing replaced timer did not work (%i).\n", count
);
7588 /* Various win events with arbitrary parameters */
7589 static const struct message WmWinEventsSeq
[] = {
7590 { EVENT_SYSTEM_SOUND
, winevent_hook
|wparam
|lparam
, OBJID_WINDOW
, 0 },
7591 { EVENT_SYSTEM_ALERT
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 1 },
7592 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, OBJID_TITLEBAR
, 2 },
7593 { EVENT_SYSTEM_MENUSTART
, winevent_hook
|wparam
|lparam
, OBJID_MENU
, 3 },
7594 { EVENT_SYSTEM_MENUEND
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 4 },
7595 { EVENT_SYSTEM_MENUPOPUPSTART
, winevent_hook
|wparam
|lparam
, OBJID_VSCROLL
, 5 },
7596 { EVENT_SYSTEM_MENUPOPUPEND
, winevent_hook
|wparam
|lparam
, OBJID_HSCROLL
, 6 },
7597 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, OBJID_SIZEGRIP
, 7 },
7598 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 8 },
7599 /* our win event hook ignores OBJID_CURSOR events */
7600 /*{ EVENT_SYSTEM_MOVESIZESTART, winevent_hook|wparam|lparam, OBJID_CURSOR, 9 },*/
7601 { EVENT_SYSTEM_MOVESIZEEND
, winevent_hook
|wparam
|lparam
, OBJID_ALERT
, 10 },
7602 { EVENT_SYSTEM_CONTEXTHELPSTART
, winevent_hook
|wparam
|lparam
, OBJID_SOUND
, 11 },
7603 { EVENT_SYSTEM_CONTEXTHELPEND
, winevent_hook
|wparam
|lparam
, OBJID_QUERYCLASSNAMEIDX
, 12 },
7604 { EVENT_SYSTEM_DRAGDROPSTART
, winevent_hook
|wparam
|lparam
, OBJID_NATIVEOM
, 13 },
7605 { EVENT_SYSTEM_DRAGDROPEND
, winevent_hook
|wparam
|lparam
, OBJID_WINDOW
, 0 },
7606 { EVENT_SYSTEM_DIALOGSTART
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 1 },
7607 { EVENT_SYSTEM_DIALOGEND
, winevent_hook
|wparam
|lparam
, OBJID_TITLEBAR
, 2 },
7608 { EVENT_SYSTEM_SCROLLINGSTART
, winevent_hook
|wparam
|lparam
, OBJID_MENU
, 3 },
7609 { EVENT_SYSTEM_SCROLLINGEND
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 4 },
7610 { EVENT_SYSTEM_SWITCHSTART
, winevent_hook
|wparam
|lparam
, OBJID_VSCROLL
, 5 },
7611 { EVENT_SYSTEM_SWITCHEND
, winevent_hook
|wparam
|lparam
, OBJID_HSCROLL
, 6 },
7612 { EVENT_SYSTEM_MINIMIZESTART
, winevent_hook
|wparam
|lparam
, OBJID_SIZEGRIP
, 7 },
7613 { EVENT_SYSTEM_MINIMIZEEND
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 8 },
7616 static const struct message WmWinEventCaretSeq
[] = {
7617 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 1 */
7618 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 1 */
7619 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 2 */
7620 { EVENT_OBJECT_NAMECHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 1 */
7623 static const struct message WmWinEventCaretSeq_2
[] = {
7624 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 1/2 */
7625 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 1/2 */
7626 { EVENT_OBJECT_NAMECHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 1/2 */
7629 static const struct message WmWinEventAlertSeq
[] = {
7630 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_ALERT
, 0 },
7633 static const struct message WmWinEventAlertSeq_2
[] = {
7634 /* create window in the thread proc */
7635 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_WINDOW
, 2 },
7636 /* our test event */
7637 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_ALERT
, 2 },
7640 static const struct message WmGlobalHookSeq_1
[] = {
7641 /* create window in the thread proc */
7642 { HCBT_CREATEWND
, hook
|lparam
, 0, 2 },
7643 /* our test events */
7644 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_PREVWINDOW
, 2 },
7645 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_NEXTWINDOW
, 2 },
7648 static const struct message WmGlobalHookSeq_2
[] = {
7649 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_NEXTWINDOW
, 0 }, /* old local hook */
7650 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_NEXTWINDOW
, 2 }, /* new global hook */
7651 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_PREVWINDOW
, 0 }, /* old local hook */
7652 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_PREVWINDOW
, 2 }, /* new global hook */
7656 static const struct message WmMouseLLHookSeq
[] = {
7657 { WM_MOUSEMOVE
, hook
},
7658 { WM_LBUTTONUP
, hook
},
7659 { WM_MOUSEMOVE
, hook
},
7663 static void CALLBACK
win_event_global_hook_proc(HWINEVENTHOOK hevent
,
7673 trace("WEH_2:%p,event %08x,hwnd %p,obj %08x,id %08x,thread %08x,time %08x\n",
7674 hevent
, event
, hwnd
, object_id
, child_id
, thread_id
, event_time
);
7676 if (GetClassNameA(hwnd
, buf
, sizeof(buf
)))
7678 if (!lstrcmpiA(buf
, "TestWindowClass") ||
7679 !lstrcmpiA(buf
, "static"))
7683 msg
.message
= event
;
7684 msg
.flags
= winevent_hook
|wparam
|lparam
;
7685 msg
.wParam
= object_id
;
7686 msg
.lParam
= (thread_id
== GetCurrentThreadId()) ? child_id
: (child_id
+ 2);
7692 static HHOOK hCBT_global_hook
;
7693 static DWORD cbt_global_hook_thread_id
;
7695 static LRESULT CALLBACK
cbt_global_hook_proc(int nCode
, WPARAM wParam
, LPARAM lParam
)
7700 trace("CBT_2: %d, %08lx, %08lx\n", nCode
, wParam
, lParam
);
7702 if (nCode
== HCBT_SYSCOMMAND
)
7706 msg
.message
= nCode
;
7707 msg
.flags
= hook
|wparam
|lparam
;
7708 msg
.wParam
= wParam
;
7709 msg
.lParam
= (cbt_global_hook_thread_id
== GetCurrentThreadId()) ? 1 : 2;
7712 return CallNextHookEx(hCBT_global_hook
, nCode
, wParam
, lParam
);
7714 /* WH_MOUSE_LL hook */
7715 if (nCode
== HC_ACTION
)
7717 MSLLHOOKSTRUCT
*mhll
= (MSLLHOOKSTRUCT
*)lParam
;
7719 /* we can't test for real mouse events */
7720 if (mhll
->flags
& LLMHF_INJECTED
)
7724 memset (&msg
, 0, sizeof (msg
));
7725 msg
.message
= wParam
;
7729 return CallNextHookEx(hCBT_global_hook
, nCode
, wParam
, lParam
);
7732 /* Log also SetFocus(0) calls */
7733 hwnd
= wParam
? (HWND
)wParam
: (HWND
)lParam
;
7735 if (GetClassNameA(hwnd
, buf
, sizeof(buf
)))
7737 if (!lstrcmpiA(buf
, "TestWindowClass") ||
7738 !lstrcmpiA(buf
, "static"))
7742 msg
.message
= nCode
;
7743 msg
.flags
= hook
|wparam
|lparam
;
7744 msg
.wParam
= wParam
;
7745 msg
.lParam
= (cbt_global_hook_thread_id
== GetCurrentThreadId()) ? 1 : 2;
7749 return CallNextHookEx(hCBT_global_hook
, nCode
, wParam
, lParam
);
7752 static DWORD WINAPI
win_event_global_thread_proc(void *param
)
7756 HANDLE hevent
= *(HANDLE
*)param
;
7758 assert(pNotifyWinEvent
);
7760 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
, 0,0,0,0,0,0,0, NULL
);
7762 trace("created thread window %p\n", hwnd
);
7764 *(HWND
*)param
= hwnd
;
7767 /* this event should be received only by our new hook proc,
7768 * an old one does not expect an event from another thread.
7770 pNotifyWinEvent(EVENT_OBJECT_LOCATIONCHANGE
, hwnd
, OBJID_ALERT
, 0);
7773 while (GetMessage(&msg
, 0, 0, 0))
7775 TranslateMessage(&msg
);
7776 DispatchMessage(&msg
);
7781 static DWORD WINAPI
cbt_global_hook_thread_proc(void *param
)
7785 HANDLE hevent
= *(HANDLE
*)param
;
7788 /* these events should be received only by our new hook proc,
7789 * an old one does not expect an event from another thread.
7792 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
, 0,0,0,0,0,0,0, NULL
);
7794 trace("created thread window %p\n", hwnd
);
7796 *(HWND
*)param
= hwnd
;
7798 /* Windows doesn't like when a thread plays games with the focus,
7799 that leads to all kinds of misbehaviours and failures to activate
7800 a window. So, better keep next lines commented out.
7804 DefWindowProcA(hwnd
, WM_SYSCOMMAND
, SC_PREVWINDOW
, 0);
7805 DefWindowProcA(hwnd
, WM_SYSCOMMAND
, SC_NEXTWINDOW
, 0);
7809 while (GetMessage(&msg
, 0, 0, 0))
7811 TranslateMessage(&msg
);
7812 DispatchMessage(&msg
);
7817 static DWORD WINAPI
mouse_ll_global_thread_proc(void *param
)
7821 HANDLE hevent
= *(HANDLE
*)param
;
7823 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
, 0,0,0,0,0,0,0, NULL
);
7825 trace("created thread window %p\n", hwnd
);
7827 *(HWND
*)param
= hwnd
;
7831 /* Windows doesn't like when a thread plays games with the focus,
7832 * that leads to all kinds of misbehaviours and failures to activate
7833 * a window. So, better don't generate a mouse click message below.
7835 mouse_event(MOUSEEVENTF_MOVE
, -1, 0, 0, 0);
7836 mouse_event(MOUSEEVENTF_LEFTUP
, 0, 0, 0, 0);
7837 mouse_event(MOUSEEVENTF_MOVE
, 1, 0, 0, 0);
7840 while (GetMessage(&msg
, 0, 0, 0))
7842 TranslateMessage(&msg
);
7843 DispatchMessage(&msg
);
7848 static void test_winevents(void)
7854 HANDLE hthread
, hevent
;
7856 HWINEVENTHOOK hhook
;
7857 const struct message
*events
= WmWinEventsSeq
;
7859 hwnd
= CreateWindowExA(0, "TestWindowClass", NULL
,
7860 WS_OVERLAPPEDWINDOW
,
7861 CW_USEDEFAULT
, CW_USEDEFAULT
, 300, 300, 0,
7865 /****** start of global hook test *************/
7866 hCBT_global_hook
= SetWindowsHookExA(WH_CBT
, cbt_global_hook_proc
, GetModuleHandleA(0), 0);
7867 if (!hCBT_global_hook
)
7869 ok(DestroyWindow(hwnd
), "failed to destroy window\n");
7870 skip( "cannot set global hook\n" );
7874 hevent
= CreateEventA(NULL
, 0, 0, NULL
);
7876 hwnd2
= (HWND
)hevent
;
7878 hthread
= CreateThread(NULL
, 0, cbt_global_hook_thread_proc
, &hwnd2
, 0, &tid
);
7879 ok(hthread
!= NULL
, "CreateThread failed, error %d\n", GetLastError());
7881 ok(WaitForSingleObject(hevent
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
7883 ok_sequence(WmGlobalHookSeq_1
, "global hook 1", FALSE
);
7886 /* this one should be received only by old hook proc */
7887 DefWindowProcA(hwnd
, WM_SYSCOMMAND
, SC_NEXTWINDOW
, 0);
7888 /* this one should be received only by old hook proc */
7889 DefWindowProcA(hwnd
, WM_SYSCOMMAND
, SC_PREVWINDOW
, 0);
7891 ok_sequence(WmGlobalHookSeq_2
, "global hook 2", FALSE
);
7893 ret
= UnhookWindowsHookEx(hCBT_global_hook
);
7894 ok( ret
, "UnhookWindowsHookEx error %d\n", GetLastError());
7896 PostThreadMessageA(tid
, WM_QUIT
, 0, 0);
7897 ok(WaitForSingleObject(hthread
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
7898 CloseHandle(hthread
);
7899 CloseHandle(hevent
);
7900 ok(!IsWindow(hwnd2
), "window should be destroyed on thread exit\n");
7901 /****** end of global hook test *************/
7903 if (!pSetWinEventHook
|| !pNotifyWinEvent
|| !pUnhookWinEvent
)
7905 ok(DestroyWindow(hwnd
), "failed to destroy window\n");
7913 /* this test doesn't pass under Win9x */
7914 /* win2k ignores events with hwnd == 0 */
7915 SetLastError(0xdeadbeef);
7916 pNotifyWinEvent(events
[0].message
, 0, events
[0].wParam
, events
[0].lParam
);
7917 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
|| /* Win2k */
7918 GetLastError() == 0xdeadbeef, /* Win9x */
7919 "unexpected error %d\n", GetLastError());
7920 ok_sequence(WmEmptySeq
, "empty notify winevents", FALSE
);
7923 for (i
= 0; i
< sizeof(WmWinEventsSeq
)/sizeof(WmWinEventsSeq
[0]); i
++)
7924 pNotifyWinEvent(events
[i
].message
, hwnd
, events
[i
].wParam
, events
[i
].lParam
);
7926 ok_sequence(WmWinEventsSeq
, "notify winevents", FALSE
);
7928 /****** start of event filtering test *************/
7929 hhook
= (HWINEVENTHOOK
)pSetWinEventHook(
7930 EVENT_OBJECT_SHOW
, /* 0x8002 */
7931 EVENT_OBJECT_LOCATIONCHANGE
, /* 0x800B */
7932 GetModuleHandleA(0), win_event_global_hook_proc
,
7933 GetCurrentProcessId(), 0,
7934 WINEVENT_INCONTEXT
);
7935 ok(hhook
!= 0, "SetWinEventHook error %d\n", GetLastError());
7937 hevent
= CreateEventA(NULL
, 0, 0, NULL
);
7939 hwnd2
= (HWND
)hevent
;
7941 hthread
= CreateThread(NULL
, 0, win_event_global_thread_proc
, &hwnd2
, 0, &tid
);
7942 ok(hthread
!= NULL
, "CreateThread failed, error %d\n", GetLastError());
7944 ok(WaitForSingleObject(hevent
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
7946 ok_sequence(WmWinEventAlertSeq
, "alert winevent", FALSE
);
7949 /* this one should be received only by old hook proc */
7950 pNotifyWinEvent(EVENT_OBJECT_CREATE
, hwnd
, OBJID_CARET
, 0); /* 0x8000 */
7951 pNotifyWinEvent(EVENT_OBJECT_SHOW
, hwnd
, OBJID_CARET
, 0); /* 0x8002 */
7952 /* this one should be received only by old hook proc */
7953 pNotifyWinEvent(EVENT_OBJECT_NAMECHANGE
, hwnd
, OBJID_CARET
, 0); /* 0x800C */
7955 ok_sequence(WmWinEventCaretSeq
, "caret winevent", FALSE
);
7957 ret
= pUnhookWinEvent(hhook
);
7958 ok( ret
, "UnhookWinEvent error %d\n", GetLastError());
7960 PostThreadMessageA(tid
, WM_QUIT
, 0, 0);
7961 ok(WaitForSingleObject(hthread
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
7962 CloseHandle(hthread
);
7963 CloseHandle(hevent
);
7964 ok(!IsWindow(hwnd2
), "window should be destroyed on thread exit\n");
7965 /****** end of event filtering test *************/
7967 /****** start of out of context event test *************/
7968 hhook
= (HWINEVENTHOOK
)pSetWinEventHook(
7969 EVENT_MIN
, EVENT_MAX
,
7970 0, win_event_global_hook_proc
,
7971 GetCurrentProcessId(), 0,
7972 WINEVENT_OUTOFCONTEXT
);
7973 ok(hhook
!= 0, "SetWinEventHook error %d\n", GetLastError());
7975 hevent
= CreateEventA(NULL
, 0, 0, NULL
);
7977 hwnd2
= (HWND
)hevent
;
7981 hthread
= CreateThread(NULL
, 0, win_event_global_thread_proc
, &hwnd2
, 0, &tid
);
7982 ok(hthread
!= NULL
, "CreateThread failed, error %d\n", GetLastError());
7984 ok(WaitForSingleObject(hevent
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
7986 ok_sequence(WmEmptySeq
, "empty notify winevents", FALSE
);
7987 /* process pending winevent messages */
7988 ok(!PeekMessageA(&msg
, 0, 0, 0, PM_NOREMOVE
), "msg queue should be empty\n");
7989 ok_sequence(WmWinEventAlertSeq_2
, "alert winevent for out of context proc", FALSE
);
7992 /* this one should be received only by old hook proc */
7993 pNotifyWinEvent(EVENT_OBJECT_CREATE
, hwnd
, OBJID_CARET
, 0); /* 0x8000 */
7994 pNotifyWinEvent(EVENT_OBJECT_SHOW
, hwnd
, OBJID_CARET
, 0); /* 0x8002 */
7995 /* this one should be received only by old hook proc */
7996 pNotifyWinEvent(EVENT_OBJECT_NAMECHANGE
, hwnd
, OBJID_CARET
, 0); /* 0x800C */
7998 ok_sequence(WmWinEventCaretSeq_2
, "caret winevent for incontext proc", FALSE
);
7999 /* process pending winevent messages */
8000 ok(!PeekMessageA(&msg
, 0, 0, 0, PM_NOREMOVE
), "msg queue should be empty\n");
8001 ok_sequence(WmWinEventCaretSeq_2
, "caret winevent for out of context proc", FALSE
);
8003 ret
= pUnhookWinEvent(hhook
);
8004 ok( ret
, "UnhookWinEvent error %d\n", GetLastError());
8006 PostThreadMessageA(tid
, WM_QUIT
, 0, 0);
8007 ok(WaitForSingleObject(hthread
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
8008 CloseHandle(hthread
);
8009 CloseHandle(hevent
);
8010 ok(!IsWindow(hwnd2
), "window should be destroyed on thread exit\n");
8011 /****** end of out of context event test *************/
8013 /****** start of MOUSE_LL hook test *************/
8014 hCBT_global_hook
= SetWindowsHookExA(WH_MOUSE_LL
, cbt_global_hook_proc
, GetModuleHandleA(0), 0);
8015 /* WH_MOUSE_LL is not supported on Win9x platforms */
8016 if (!hCBT_global_hook
)
8018 trace("Skipping WH_MOUSE_LL test on this platform\n");
8019 goto skip_mouse_ll_hook_test
;
8022 hevent
= CreateEventA(NULL
, 0, 0, NULL
);
8024 hwnd2
= (HWND
)hevent
;
8026 hthread
= CreateThread(NULL
, 0, mouse_ll_global_thread_proc
, &hwnd2
, 0, &tid
);
8027 ok(hthread
!= NULL
, "CreateThread failed, error %d\n", GetLastError());
8029 while (WaitForSingleObject(hevent
, 100) == WAIT_TIMEOUT
)
8030 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
8032 ok_sequence(WmMouseLLHookSeq
, "MOUSE_LL hook other thread", FALSE
);
8035 mouse_event(MOUSEEVENTF_MOVE
, -1, 0, 0, 0);
8036 mouse_event(MOUSEEVENTF_LEFTUP
, 0, 0, 0, 0);
8037 mouse_event(MOUSEEVENTF_MOVE
, 1, 0, 0, 0);
8039 ok_sequence(WmMouseLLHookSeq
, "MOUSE_LL hook same thread", FALSE
);
8041 ret
= UnhookWindowsHookEx(hCBT_global_hook
);
8042 ok( ret
, "UnhookWindowsHookEx error %d\n", GetLastError());
8044 PostThreadMessageA(tid
, WM_QUIT
, 0, 0);
8045 ok(WaitForSingleObject(hthread
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
8046 CloseHandle(hthread
);
8047 CloseHandle(hevent
);
8048 ok(!IsWindow(hwnd2
), "window should be destroyed on thread exit\n");
8049 /****** end of MOUSE_LL hook test *************/
8050 skip_mouse_ll_hook_test
:
8052 ok(DestroyWindow(hwnd
), "failed to destroy window\n");
8055 static void test_set_hook(void)
8059 HWINEVENTHOOK hwinevent_hook
;
8061 hhook
= SetWindowsHookExA(WH_CBT
, cbt_hook_proc
, GetModuleHandleA(0), GetCurrentThreadId());
8062 ok(hhook
!= 0, "local hook does not require hModule set to 0\n");
8063 UnhookWindowsHookEx(hhook
);
8067 /* this test doesn't pass under Win9x: BUG! */
8068 SetLastError(0xdeadbeef);
8069 hhook
= SetWindowsHookExA(WH_CBT
, cbt_hook_proc
, 0, 0);
8070 ok(!hhook
, "global hook requires hModule != 0\n");
8071 ok(GetLastError() == ERROR_HOOK_NEEDS_HMOD
, "unexpected error %d\n", GetLastError());
8074 SetLastError(0xdeadbeef);
8075 hhook
= SetWindowsHookExA(WH_CBT
, 0, GetModuleHandleA(0), GetCurrentThreadId());
8076 ok(!hhook
, "SetWinEventHook with invalid proc should fail\n");
8077 ok(GetLastError() == ERROR_INVALID_FILTER_PROC
|| /* Win2k */
8078 GetLastError() == 0xdeadbeef, /* Win9x */
8079 "unexpected error %d\n", GetLastError());
8081 SetLastError(0xdeadbeef);
8082 ok(!UnhookWindowsHookEx((HHOOK
)0xdeadbeef), "UnhookWindowsHookEx succeeded\n");
8083 ok(GetLastError() == ERROR_INVALID_HOOK_HANDLE
|| /* Win2k */
8084 GetLastError() == 0xdeadbeef, /* Win9x */
8085 "unexpected error %d\n", GetLastError());
8087 if (!pSetWinEventHook
|| !pUnhookWinEvent
) return;
8089 /* even process local incontext hooks require hmodule */
8090 SetLastError(0xdeadbeef);
8091 hwinevent_hook
= (HWINEVENTHOOK
)pSetWinEventHook(EVENT_MIN
, EVENT_MAX
,
8092 0, win_event_proc
, GetCurrentProcessId(), 0, WINEVENT_INCONTEXT
);
8093 ok(!hwinevent_hook
, "WINEVENT_INCONTEXT requires hModule != 0\n");
8094 ok(GetLastError() == ERROR_HOOK_NEEDS_HMOD
|| /* Win2k */
8095 GetLastError() == 0xdeadbeef, /* Win9x */
8096 "unexpected error %d\n", GetLastError());
8098 /* even thread local incontext hooks require hmodule */
8099 SetLastError(0xdeadbeef);
8100 hwinevent_hook
= (HWINEVENTHOOK
)pSetWinEventHook(EVENT_MIN
, EVENT_MAX
,
8101 0, win_event_proc
, GetCurrentProcessId(), GetCurrentThreadId(), WINEVENT_INCONTEXT
);
8102 ok(!hwinevent_hook
, "WINEVENT_INCONTEXT requires hModule != 0\n");
8103 ok(GetLastError() == ERROR_HOOK_NEEDS_HMOD
|| /* Win2k */
8104 GetLastError() == 0xdeadbeef, /* Win9x */
8105 "unexpected error %d\n", GetLastError());
8109 /* these 3 tests don't pass under Win9x */
8110 SetLastError(0xdeadbeef);
8111 hwinevent_hook
= (HWINEVENTHOOK
)pSetWinEventHook(1, 0,
8112 0, win_event_proc
, GetCurrentProcessId(), 0, WINEVENT_OUTOFCONTEXT
);
8113 ok(!hwinevent_hook
, "SetWinEventHook with invalid event range should fail\n");
8114 ok(GetLastError() == ERROR_INVALID_HOOK_FILTER
, "unexpected error %d\n", GetLastError());
8116 SetLastError(0xdeadbeef);
8117 hwinevent_hook
= (HWINEVENTHOOK
)pSetWinEventHook(-1, 1,
8118 0, win_event_proc
, GetCurrentProcessId(), 0, WINEVENT_OUTOFCONTEXT
);
8119 ok(!hwinevent_hook
, "SetWinEventHook with invalid event range should fail\n");
8120 ok(GetLastError() == ERROR_INVALID_HOOK_FILTER
, "unexpected error %d\n", GetLastError());
8122 SetLastError(0xdeadbeef);
8123 hwinevent_hook
= (HWINEVENTHOOK
)pSetWinEventHook(EVENT_MIN
, EVENT_MAX
,
8124 0, win_event_proc
, 0, 0xdeadbeef, WINEVENT_OUTOFCONTEXT
);
8125 ok(!hwinevent_hook
, "SetWinEventHook with invalid tid should fail\n");
8126 ok(GetLastError() == ERROR_INVALID_THREAD_ID
, "unexpected error %d\n", GetLastError());
8129 SetLastError(0xdeadbeef);
8130 hwinevent_hook
= (HWINEVENTHOOK
)pSetWinEventHook(0, 0,
8131 0, win_event_proc
, GetCurrentProcessId(), 0, WINEVENT_OUTOFCONTEXT
);
8132 ok(hwinevent_hook
!= 0, "SetWinEventHook error %d\n", GetLastError());
8133 ok(GetLastError() == 0xdeadbeef, "unexpected error %d\n", GetLastError());
8134 ret
= pUnhookWinEvent(hwinevent_hook
);
8135 ok( ret
, "UnhookWinEvent error %d\n", GetLastError());
8138 /* This call succeeds under win2k SP4, but fails under Wine.
8139 Does win2k test/use passed process id? */
8140 SetLastError(0xdeadbeef);
8141 hwinevent_hook
= (HWINEVENTHOOK
)pSetWinEventHook(EVENT_MIN
, EVENT_MAX
,
8142 0, win_event_proc
, 0xdeadbeef, 0, WINEVENT_OUTOFCONTEXT
);
8143 ok(hwinevent_hook
!= 0, "SetWinEventHook error %d\n", GetLastError());
8144 ok(GetLastError() == 0xdeadbeef, "unexpected error %d\n", GetLastError());
8145 ret
= pUnhookWinEvent(hwinevent_hook
);
8146 ok( ret
, "UnhookWinEvent error %d\n", GetLastError());
8149 SetLastError(0xdeadbeef);
8150 ok(!pUnhookWinEvent((HWINEVENTHOOK
)0xdeadbeef), "UnhookWinEvent succeeded\n");
8151 ok(GetLastError() == ERROR_INVALID_HANDLE
|| /* Win2k */
8152 GetLastError() == 0xdeadbeef, /* Win9x */
8153 "unexpected error %d\n", GetLastError());
8156 static const struct message ScrollWindowPaint1
[] = {
8158 { WM_ERASEBKGND
, sent
|beginpaint
},
8162 static const struct message ScrollWindowPaint2
[] = {
8167 static void test_scrollwindowex(void)
8170 RECT rect
={0,0,130,130};
8172 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test Scroll",
8173 WS_VISIBLE
|WS_OVERLAPPEDWINDOW
,
8174 100, 100, 200, 200, 0, 0, 0, NULL
);
8175 ok (hwnd
!= 0, "Failed to create overlapped window\n");
8176 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child",
8177 WS_VISIBLE
|WS_CAPTION
|WS_CHILD
,
8178 10, 10, 150, 150, hwnd
, 0, 0, NULL
);
8179 ok (hchild
!= 0, "Failed to create child\n");
8184 /* scroll without the child window */
8185 trace("start scroll\n");
8186 ScrollWindowEx( hwnd
, 10, 10, &rect
, NULL
, NULL
, NULL
,
8187 SW_ERASE
|SW_INVALIDATE
);
8188 ok_sequence(WmEmptySeq
, "ScrollWindowEx", 0);
8189 trace("end scroll\n");
8192 ok_sequence(ScrollWindowPaint1
, "ScrollWindowEx", 0);
8196 /* Now without the SW_ERASE flag */
8197 trace("start scroll\n");
8198 ScrollWindowEx( hwnd
, 10, 10, &rect
, NULL
, NULL
, NULL
, SW_INVALIDATE
);
8199 ok_sequence(WmEmptySeq
, "ScrollWindowEx", 0);
8200 trace("end scroll\n");
8203 ok_sequence(ScrollWindowPaint2
, "ScrollWindowEx", 0);
8207 /* now scroll the child window as well */
8208 trace("start scroll\n");
8209 ScrollWindowEx( hwnd
, 10, 10, &rect
, NULL
, NULL
, NULL
,
8210 SW_SCROLLCHILDREN
|SW_ERASE
|SW_INVALIDATE
);
8211 todo_wine
{ /* wine sends WM_POSCHANGING, WM_POSCHANGED messages */
8212 /* windows sometimes a WM_MOVE */
8213 ok_sequence(WmEmptySeq
, "ScrollWindowEx", 0);
8215 trace("end scroll\n");
8218 ok_sequence(ScrollWindowPaint1
, "ScrollWindowEx", 0);
8222 /* now scroll with ScrollWindow() */
8223 trace("start scroll with ScrollWindow\n");
8224 ScrollWindow( hwnd
, 5, 5, NULL
, NULL
);
8225 trace("end scroll\n");
8228 ok_sequence(ScrollWindowPaint1
, "ScrollWindow", 0);
8230 ok(DestroyWindow(hchild
), "failed to destroy window\n");
8231 ok(DestroyWindow(hwnd
), "failed to destroy window\n");
8235 static const struct message destroy_window_with_children
[] = {
8236 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* popup */
8237 { HCBT_DESTROYWND
, hook
|lparam
, 0, WND_PARENT_ID
}, /* parent */
8238 { 0x0090, sent
|optional
},
8239 { HCBT_DESTROYWND
, hook
|lparam
, 0, WND_POPUP_ID
}, /* popup */
8240 { 0x0090, sent
|optional
},
8241 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* popup */
8242 { WM_DESTROY
, sent
|wparam
|lparam
, 0, WND_POPUP_ID
}, /* popup */
8243 { WM_CAPTURECHANGED
, sent
|wparam
|lparam
, 0, WND_POPUP_ID
}, /* popup */
8244 { WM_NCDESTROY
, sent
|wparam
|lparam
, 0, WND_POPUP_ID
}, /* popup */
8245 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* parent */
8246 { WM_DESTROY
, sent
|wparam
|lparam
, 0, WND_PARENT_ID
}, /* parent */
8247 { WM_DESTROY
, sent
|wparam
|lparam
, 0, WND_CHILD_ID
+ 2 }, /* child2 */
8248 { WM_DESTROY
, sent
|wparam
|lparam
, 0, WND_CHILD_ID
+ 1 }, /* child1 */
8249 { WM_DESTROY
, sent
|wparam
|lparam
, 0, WND_CHILD_ID
+ 3 }, /* child3 */
8250 { WM_NCDESTROY
, sent
|wparam
|lparam
, 0, WND_CHILD_ID
+ 2 }, /* child2 */
8251 { WM_NCDESTROY
, sent
|wparam
|lparam
, 0, WND_CHILD_ID
+ 3 }, /* child3 */
8252 { WM_NCDESTROY
, sent
|wparam
|lparam
, 0, WND_CHILD_ID
+ 1 }, /* child1 */
8253 { WM_NCDESTROY
, sent
|wparam
|lparam
, 0, WND_PARENT_ID
}, /* parent */
8257 static void test_DestroyWindow(void)
8260 HWND parent
, child1
, child2
, child3
, child4
, test
;
8261 UINT child_id
= WND_CHILD_ID
+ 1;
8263 parent
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
8264 100, 100, 200, 200, 0, 0, 0, NULL
);
8265 assert(parent
!= 0);
8266 child1
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_CHILD
,
8267 0, 0, 50, 50, parent
, (HMENU
)child_id
++, 0, NULL
);
8268 assert(child1
!= 0);
8269 child2
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_CHILD
,
8270 0, 0, 50, 50, GetDesktopWindow(), (HMENU
)child_id
++, 0, NULL
);
8271 assert(child2
!= 0);
8272 child3
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_CHILD
,
8273 0, 0, 50, 50, child1
, (HMENU
)child_id
++, 0, NULL
);
8274 assert(child3
!= 0);
8275 child4
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_POPUP
,
8276 0, 0, 50, 50, parent
, 0, 0, NULL
);
8277 assert(child4
!= 0);
8279 /* test owner/parent of child2 */
8280 test
= GetParent(child2
);
8281 ok(test
== GetDesktopWindow(), "wrong parent %p\n", test
);
8282 ok(!IsChild(parent
, child2
), "wrong parent/child %p/%p\n", parent
, child2
);
8284 test
= pGetAncestor(child2
, GA_PARENT
);
8285 ok(test
== GetDesktopWindow(), "wrong parent %p\n", test
);
8287 test
= GetWindow(child2
, GW_OWNER
);
8288 ok(!test
, "wrong owner %p\n", test
);
8290 test
= SetParent(child2
, parent
);
8291 ok(test
== GetDesktopWindow(), "wrong old parent %p\n", test
);
8293 /* test owner/parent of the parent */
8294 test
= GetParent(parent
);
8295 ok(!test
, "wrong parent %p\n", test
);
8296 ok(!IsChild(GetDesktopWindow(), parent
), "wrong parent/child %p/%p\n", GetDesktopWindow(), parent
);
8298 test
= pGetAncestor(parent
, GA_PARENT
);
8299 ok(test
== GetDesktopWindow(), "wrong parent %p\n", test
);
8301 test
= GetWindow(parent
, GW_OWNER
);
8302 ok(!test
, "wrong owner %p\n", test
);
8304 /* test owner/parent of child1 */
8305 test
= GetParent(child1
);
8306 ok(test
== parent
, "wrong parent %p\n", test
);
8307 ok(IsChild(parent
, child1
), "wrong parent/child %p/%p\n", parent
, child1
);
8309 test
= pGetAncestor(child1
, GA_PARENT
);
8310 ok(test
== parent
, "wrong parent %p\n", test
);
8312 test
= GetWindow(child1
, GW_OWNER
);
8313 ok(!test
, "wrong owner %p\n", test
);
8315 /* test owner/parent of child2 */
8316 test
= GetParent(child2
);
8317 ok(test
== parent
, "wrong parent %p\n", test
);
8318 ok(IsChild(parent
, child2
), "wrong parent/child %p/%p\n", parent
, child2
);
8320 test
= pGetAncestor(child2
, GA_PARENT
);
8321 ok(test
== parent
, "wrong parent %p\n", test
);
8323 test
= GetWindow(child2
, GW_OWNER
);
8324 ok(!test
, "wrong owner %p\n", test
);
8326 /* test owner/parent of child3 */
8327 test
= GetParent(child3
);
8328 ok(test
== child1
, "wrong parent %p\n", test
);
8329 ok(IsChild(parent
, child3
), "wrong parent/child %p/%p\n", parent
, child3
);
8331 test
= pGetAncestor(child3
, GA_PARENT
);
8332 ok(test
== child1
, "wrong parent %p\n", test
);
8334 test
= GetWindow(child3
, GW_OWNER
);
8335 ok(!test
, "wrong owner %p\n", test
);
8337 /* test owner/parent of child4 */
8338 test
= GetParent(child4
);
8339 ok(test
== parent
, "wrong parent %p\n", test
);
8340 ok(!IsChild(parent
, child4
), "wrong parent/child %p/%p\n", parent
, child4
);
8342 test
= pGetAncestor(child4
, GA_PARENT
);
8343 ok(test
== GetDesktopWindow(), "wrong parent %p\n", test
);
8345 test
= GetWindow(child4
, GW_OWNER
);
8346 ok(test
== parent
, "wrong owner %p\n", test
);
8350 trace("parent %p, child1 %p, child2 %p, child3 %p, child4 %p\n",
8351 parent
, child1
, child2
, child3
, child4
);
8354 test
= GetCapture();
8355 ok(test
== child4
, "wrong capture window %p\n", test
);
8357 test_DestroyWindow_flag
= TRUE
;
8358 ret
= DestroyWindow(parent
);
8359 ok( ret
, "DestroyWindow() error %d\n", GetLastError());
8360 test_DestroyWindow_flag
= FALSE
;
8361 ok_sequence(destroy_window_with_children
, "destroy window with children", 0);
8363 ok(!IsWindow(parent
), "parent still exists\n");
8364 ok(!IsWindow(child1
), "child1 still exists\n");
8365 ok(!IsWindow(child2
), "child2 still exists\n");
8366 ok(!IsWindow(child3
), "child3 still exists\n");
8367 ok(!IsWindow(child4
), "child4 still exists\n");
8369 test
= GetCapture();
8370 ok(!test
, "wrong capture window %p\n", test
);
8374 static const struct message WmDispatchPaint
[] = {
8375 { WM_NCPAINT
, sent
},
8376 { WM_GETTEXT
, sent
|defwinproc
|optional
},
8377 { WM_GETTEXT
, sent
|defwinproc
|optional
},
8378 { WM_ERASEBKGND
, sent
},
8382 static LRESULT WINAPI
DispatchMessageCheckProc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
8384 if (message
== WM_PAINT
) return 0;
8385 return MsgCheckProcA( hwnd
, message
, wParam
, lParam
);
8388 static void test_DispatchMessage(void)
8393 HWND hwnd
= CreateWindowA( "TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
8394 100, 100, 200, 200, 0, 0, 0, NULL
);
8395 ShowWindow( hwnd
, SW_SHOW
);
8396 UpdateWindow( hwnd
);
8399 SetWindowLongPtrA( hwnd
, GWLP_WNDPROC
, (LONG_PTR
)DispatchMessageCheckProc
);
8401 SetRect( &rect
, -5, -5, 5, 5 );
8402 RedrawWindow( hwnd
, &rect
, 0, RDW_INVALIDATE
|RDW_ERASE
|RDW_FRAME
);
8404 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
))
8406 if (msg
.message
!= WM_PAINT
) DispatchMessage( &msg
);
8410 DispatchMessage( &msg
);
8411 /* DispatchMessage will send WM_NCPAINT if non client area is still invalid after WM_PAINT */
8412 if (!count
) ok_sequence( WmDispatchPaint
, "WmDispatchPaint", FALSE
);
8413 else ok_sequence( WmEmptySeq
, "WmEmpty", FALSE
);
8414 if (++count
> 10) break;
8417 ok( msg
.message
== WM_PAINT
&& count
> 10, "WM_PAINT messages stopped\n" );
8419 trace("now without DispatchMessage\n");
8421 RedrawWindow( hwnd
, &rect
, 0, RDW_INVALIDATE
|RDW_ERASE
|RDW_FRAME
);
8423 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
))
8425 if (msg
.message
!= WM_PAINT
) DispatchMessage( &msg
);
8428 HRGN hrgn
= CreateRectRgn( 0, 0, 0, 0 );
8430 /* this will send WM_NCCPAINT just like DispatchMessage does */
8431 GetUpdateRgn( hwnd
, hrgn
, TRUE
);
8432 ok_sequence( WmDispatchPaint
, "WmDispatchPaint", FALSE
);
8433 DeleteObject( hrgn
);
8434 GetClientRect( hwnd
, &rect
);
8435 ValidateRect( hwnd
, &rect
); /* this will stop WM_PAINTs */
8436 ok( !count
, "Got multiple WM_PAINTs\n" );
8437 if (++count
> 10) break;
8440 DestroyWindow(hwnd
);
8444 static const struct message WmUser
[] = {
8456 static DWORD CALLBACK
send_msg_thread( LPVOID arg
)
8458 struct sendmsg_info
*info
= arg
;
8459 SetLastError( 0xdeadbeef );
8460 info
->ret
= SendMessageTimeoutA( info
->hwnd
, WM_USER
, 0, 0, 0, info
->timeout
, NULL
);
8461 if (!info
->ret
) ok( GetLastError() == ERROR_TIMEOUT
||
8462 broken(GetLastError() == 0), /* win9x */
8463 "unexpected error %d\n", GetLastError());
8467 static void wait_for_thread( HANDLE thread
)
8469 while (MsgWaitForMultipleObjects(1, &thread
, FALSE
, INFINITE
, QS_SENDMESSAGE
) != WAIT_OBJECT_0
)
8472 while (PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage(&msg
);
8476 static LRESULT WINAPI
send_msg_delay_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
8478 if (message
== WM_USER
) Sleep(200);
8479 return MsgCheckProcA( hwnd
, message
, wParam
, lParam
);
8482 static void test_SendMessageTimeout(void)
8485 struct sendmsg_info info
;
8489 info
.hwnd
= CreateWindowA( "TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
8490 100, 100, 200, 200, 0, 0, 0, NULL
);
8494 info
.timeout
= 1000;
8495 info
.ret
= 0xdeadbeef;
8496 thread
= CreateThread( NULL
, 0, send_msg_thread
, &info
, 0, &tid
);
8497 wait_for_thread( thread
);
8498 CloseHandle( thread
);
8499 ok( info
.ret
== 1, "SendMessageTimeout failed\n" );
8500 ok_sequence( WmUser
, "WmUser", FALSE
);
8503 info
.ret
= 0xdeadbeef;
8504 thread
= CreateThread( NULL
, 0, send_msg_thread
, &info
, 0, &tid
);
8505 Sleep(100); /* SendMessageTimeout should time out here */
8506 wait_for_thread( thread
);
8507 CloseHandle( thread
);
8508 ok( info
.ret
== 0, "SendMessageTimeout succeeded\n" );
8509 ok_sequence( WmEmptySeq
, "WmEmptySeq", FALSE
);
8511 /* 0 means infinite timeout (but not on win9x) */
8513 info
.ret
= 0xdeadbeef;
8514 thread
= CreateThread( NULL
, 0, send_msg_thread
, &info
, 0, &tid
);
8516 wait_for_thread( thread
);
8517 CloseHandle( thread
);
8518 is_win9x
= !info
.ret
;
8519 if (is_win9x
) ok_sequence( WmEmptySeq
, "WmEmptySeq", FALSE
);
8520 else ok_sequence( WmUser
, "WmUser", FALSE
);
8522 /* timeout is treated as signed despite the prototype (but not on win9x) */
8523 info
.timeout
= 0x7fffffff;
8524 info
.ret
= 0xdeadbeef;
8525 thread
= CreateThread( NULL
, 0, send_msg_thread
, &info
, 0, &tid
);
8527 wait_for_thread( thread
);
8528 CloseHandle( thread
);
8529 ok( info
.ret
== 1, "SendMessageTimeout failed\n" );
8530 ok_sequence( WmUser
, "WmUser", FALSE
);
8532 info
.timeout
= 0x80000000;
8533 info
.ret
= 0xdeadbeef;
8534 thread
= CreateThread( NULL
, 0, send_msg_thread
, &info
, 0, &tid
);
8536 wait_for_thread( thread
);
8537 CloseHandle( thread
);
8540 ok( info
.ret
== 1, "SendMessageTimeout failed\n" );
8541 ok_sequence( WmUser
, "WmUser", FALSE
);
8545 ok( info
.ret
== 0, "SendMessageTimeout succeeded\n" );
8546 ok_sequence( WmEmptySeq
, "WmEmptySeq", FALSE
);
8549 /* now check for timeout during message processing */
8550 SetWindowLongPtrA( info
.hwnd
, GWLP_WNDPROC
, (LONG_PTR
)send_msg_delay_proc
);
8552 info
.ret
= 0xdeadbeef;
8553 thread
= CreateThread( NULL
, 0, send_msg_thread
, &info
, 0, &tid
);
8554 wait_for_thread( thread
);
8555 CloseHandle( thread
);
8556 /* we should time out but still get the message */
8557 ok( info
.ret
== 0, "SendMessageTimeout failed\n" );
8558 ok_sequence( WmUser
, "WmUser", FALSE
);
8560 DestroyWindow( info
.hwnd
);
8564 /****************** edit message test *************************/
8565 #define ID_EDIT 0x1234
8566 static const struct message sl_edit_setfocus
[] =
8568 { HCBT_SETFOCUS
, hook
},
8569 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
8570 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
8571 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
8572 { WM_SETFOCUS
, sent
|wparam
, 0 },
8573 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 10 },
8574 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 15 },
8575 { WM_CTLCOLOREDIT
, sent
|parent
},
8576 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 11 },
8577 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
8578 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
8579 { WM_COMMAND
, sent
|parent
|wparam
, MAKEWPARAM(ID_EDIT
, EN_SETFOCUS
) },
8582 static const struct message ml_edit_setfocus
[] =
8584 { HCBT_SETFOCUS
, hook
},
8585 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
8586 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
8587 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
8588 { WM_SETFOCUS
, sent
|wparam
, 0 },
8589 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 10 },
8590 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 11 },
8591 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
8592 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
8593 { WM_COMMAND
, sent
|parent
|wparam
, MAKEWPARAM(ID_EDIT
, EN_SETFOCUS
) },
8596 static const struct message sl_edit_killfocus
[] =
8598 { HCBT_SETFOCUS
, hook
},
8599 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
8600 { WM_KILLFOCUS
, sent
|wparam
, 0 },
8601 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
8602 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
8603 { WM_COMMAND
, sent
|parent
|wparam
, MAKEWPARAM(ID_EDIT
, EN_KILLFOCUS
) },
8604 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
8605 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 1 },
8608 static const struct message sl_edit_lbutton_dblclk
[] =
8610 { WM_LBUTTONDBLCLK
, sent
},
8611 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
8614 static const struct message sl_edit_lbutton_down
[] =
8616 { WM_LBUTTONDOWN
, sent
|wparam
|lparam
, 0, 0 },
8617 { HCBT_SETFOCUS
, hook
},
8618 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
8619 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
8620 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
8621 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
8622 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 10 },
8623 { WM_CTLCOLOREDIT
, sent
|parent
},
8624 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 11 },
8625 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
8626 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
8627 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
8628 { WM_COMMAND
, sent
|parent
|wparam
, MAKEWPARAM(ID_EDIT
, EN_SETFOCUS
) },
8629 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
8630 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
8631 { WM_CTLCOLOREDIT
, sent
|parent
|optional
},
8632 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 11 },
8633 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
8634 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
8637 static const struct message ml_edit_lbutton_down
[] =
8639 { WM_LBUTTONDOWN
, sent
|wparam
|lparam
, 0, 0 },
8640 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
8641 { HCBT_SETFOCUS
, hook
},
8642 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
8643 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
8644 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
8645 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
8646 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 10 },
8647 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 11 },
8648 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
8649 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
8650 { WM_COMMAND
, sent
|parent
|wparam
, MAKEWPARAM(ID_EDIT
, EN_SETFOCUS
) },
8653 static const struct message sl_edit_lbutton_up
[] =
8655 { WM_LBUTTONUP
, sent
|wparam
|lparam
, 0, 0 },
8656 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
8657 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, 0, 0 },
8658 { WM_CAPTURECHANGED
, sent
|defwinproc
},
8659 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
8662 static const struct message ml_edit_lbutton_up
[] =
8664 { WM_LBUTTONUP
, sent
|wparam
|lparam
, 0, 0 },
8665 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, 0, 0 },
8666 { WM_CAPTURECHANGED
, sent
|defwinproc
},
8670 static WNDPROC old_edit_proc
;
8672 static LRESULT CALLBACK
edit_hook_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
8674 static long defwndproc_counter
= 0;
8678 trace("edit: %p, %04x, %08lx, %08lx\n", hwnd
, message
, wParam
, lParam
);
8680 /* explicitly ignore WM_GETICON message */
8681 if (message
== WM_GETICON
) return 0;
8683 /* ignore registered messages */
8684 if (message
>= 0xc000) return 0;
8686 msg
.message
= message
;
8687 msg
.flags
= sent
|wparam
|lparam
;
8688 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
8689 msg
.wParam
= wParam
;
8690 msg
.lParam
= lParam
;
8693 defwndproc_counter
++;
8694 ret
= CallWindowProcA(old_edit_proc
, hwnd
, message
, wParam
, lParam
);
8695 defwndproc_counter
--;
8700 static void subclass_edit(void)
8704 if (!GetClassInfoA(0, "edit", &cls
)) assert(0);
8706 old_edit_proc
= cls
.lpfnWndProc
;
8708 cls
.hInstance
= GetModuleHandle(0);
8709 cls
.lpfnWndProc
= edit_hook_proc
;
8710 cls
.lpszClassName
= "my_edit_class";
8711 UnregisterClass(cls
.lpszClassName
, cls
.hInstance
);
8712 if (!RegisterClassA(&cls
)) assert(0);
8715 static void test_edit_messages(void)
8721 log_all_parent_messages
++;
8723 parent
= CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
8724 100, 100, 200, 200, 0, 0, 0, NULL
);
8725 ok (parent
!= 0, "Failed to create parent window\n");
8727 /* test single line edit */
8728 hwnd
= CreateWindowExA(0, "my_edit_class", "test", WS_CHILD
,
8729 0, 0, 80, 20, parent
, (HMENU
)ID_EDIT
, 0, NULL
);
8730 ok(hwnd
!= 0, "Failed to create edit window\n");
8732 dlg_code
= SendMessageA(hwnd
, WM_GETDLGCODE
, 0, 0);
8733 ok(dlg_code
== (DLGC_WANTCHARS
|DLGC_HASSETSEL
|DLGC_WANTARROWS
), "wrong dlg_code %08x\n", dlg_code
);
8735 ShowWindow(hwnd
, SW_SHOW
);
8741 ok_sequence(sl_edit_setfocus
, "SetFocus(hwnd) on an edit", FALSE
);
8744 ok_sequence(sl_edit_killfocus
, "SetFocus(0) on an edit", FALSE
);
8750 SendMessageA(hwnd
, WM_LBUTTONDBLCLK
, 0, 0);
8751 ok_sequence(sl_edit_lbutton_dblclk
, "WM_LBUTTONDBLCLK on an edit", FALSE
);
8757 SendMessageA(hwnd
, WM_LBUTTONDOWN
, 0, 0);
8758 ok_sequence(sl_edit_lbutton_down
, "WM_LBUTTONDOWN on an edit", FALSE
);
8760 SendMessageA(hwnd
, WM_LBUTTONUP
, 0, 0);
8761 ok_sequence(sl_edit_lbutton_up
, "WM_LBUTTONUP on an edit", FALSE
);
8763 DestroyWindow(hwnd
);
8765 /* test multiline edit */
8766 hwnd
= CreateWindowExA(0, "my_edit_class", "test", WS_CHILD
| ES_MULTILINE
,
8767 0, 0, 80, 20, parent
, (HMENU
)ID_EDIT
, 0, NULL
);
8768 ok(hwnd
!= 0, "Failed to create edit window\n");
8770 dlg_code
= SendMessageA(hwnd
, WM_GETDLGCODE
, 0, 0);
8771 ok(dlg_code
== (DLGC_WANTCHARS
|DLGC_HASSETSEL
|DLGC_WANTARROWS
|DLGC_WANTALLKEYS
),
8772 "wrong dlg_code %08x\n", dlg_code
);
8774 ShowWindow(hwnd
, SW_SHOW
);
8780 ok_sequence(ml_edit_setfocus
, "SetFocus(hwnd) on multiline edit", FALSE
);
8783 ok_sequence(sl_edit_killfocus
, "SetFocus(0) on multiline edit", FALSE
);
8789 SendMessageA(hwnd
, WM_LBUTTONDBLCLK
, 0, 0);
8790 ok_sequence(sl_edit_lbutton_dblclk
, "WM_LBUTTONDBLCLK on multiline edit", FALSE
);
8796 SendMessageA(hwnd
, WM_LBUTTONDOWN
, 0, 0);
8797 ok_sequence(ml_edit_lbutton_down
, "WM_LBUTTONDOWN on multiline edit", FALSE
);
8799 SendMessageA(hwnd
, WM_LBUTTONUP
, 0, 0);
8800 ok_sequence(ml_edit_lbutton_up
, "WM_LBUTTONUP on multiline edit", FALSE
);
8802 DestroyWindow(hwnd
);
8803 DestroyWindow(parent
);
8805 log_all_parent_messages
--;
8808 /**************************** End of Edit test ******************************/
8810 static const struct message WmKeyDownSkippedSeq
[] =
8812 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 1 }, /* XP */
8815 static const struct message WmKeyUpSkippedSeq
[] =
8817 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xc0000001 }, /* XP */
8822 #define EV_SENDMSG 1
8828 HANDLE hevent
[3]; /* 0 - start/stop, 1 - SendMessage, 2 - ack */
8831 static DWORD CALLBACK
send_msg_thread_2(void *param
)
8834 struct peekmsg_info
*info
= param
;
8836 trace("thread: looping\n");
8837 SetEvent(info
->hevent
[EV_ACK
]);
8841 ret
= WaitForMultipleObjects(2, info
->hevent
, FALSE
, INFINITE
);
8845 case WAIT_OBJECT_0
+ EV_STOP
:
8846 trace("thread: exiting\n");
8849 case WAIT_OBJECT_0
+ EV_SENDMSG
:
8850 trace("thread: sending message\n");
8851 ok( SendNotifyMessageA(info
->hwnd
, WM_USER
, 0, 0),
8852 "SendNotifyMessageA failed error %u\n", GetLastError());
8853 SetEvent(info
->hevent
[EV_ACK
]);
8857 trace("unexpected return: %04x\n", ret
);
8865 static void test_PeekMessage(void)
8870 UINT qs_all_input
= QS_ALLINPUT
;
8871 UINT qs_input
= QS_INPUT
;
8872 UINT qs_sendmessage
= 0;
8874 struct peekmsg_info info
;
8876 info
.hwnd
= CreateWindowA("TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
8877 100, 100, 200, 200, 0, 0, 0, NULL
);
8879 ShowWindow(info
.hwnd
, SW_SHOW
);
8880 UpdateWindow(info
.hwnd
);
8881 SetFocus(info
.hwnd
);
8883 info
.hevent
[EV_STOP
] = CreateEventA(NULL
, 0, 0, NULL
);
8884 info
.hevent
[EV_SENDMSG
] = CreateEventA(NULL
, 0, 0, NULL
);
8885 info
.hevent
[EV_ACK
] = CreateEventA(NULL
, 0, 0, NULL
);
8887 hthread
= CreateThread(NULL
, 0, send_msg_thread_2
, &info
, 0, &tid
);
8888 WaitForSingleObject(info
.hevent
[EV_ACK
], 10000);
8893 SetLastError(0xdeadbeef);
8894 qstatus
= GetQueueStatus(qs_all_input
);
8895 if (GetLastError() == ERROR_INVALID_FLAGS
)
8897 trace("QS_RAWINPUT not supported on this platform\n");
8898 qs_all_input
&= ~QS_RAWINPUT
;
8899 qs_input
&= ~QS_RAWINPUT
;
8901 ok(qstatus
== 0, "wrong qstatus %08x\n", qstatus
);
8903 trace("signalling to send message\n");
8904 SetEvent(info
.hevent
[EV_SENDMSG
]);
8905 WaitForSingleObject(info
.hevent
[EV_ACK
], INFINITE
);
8907 /* pass invalid QS_xxxx flags */
8908 SetLastError(0xdeadbeef);
8909 qstatus
= GetQueueStatus(0xffffffff);
8910 ok(qstatus
== 0, "GetQueueStatus should fail: %08x\n", qstatus
);
8911 ok(GetLastError() == ERROR_INVALID_FLAGS
, "wrong error %d\n", GetLastError());
8913 qstatus
= GetQueueStatus(qs_all_input
);
8914 ok(qstatus
== MAKELONG(QS_SENDMESSAGE
, QS_SENDMESSAGE
),
8915 "wrong qstatus %08x\n", qstatus
);
8918 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
8920 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8922 ok_sequence(WmUser
, "WmUser", FALSE
);
8924 qstatus
= GetQueueStatus(qs_all_input
);
8925 ok(qstatus
== 0, "wrong qstatus %08x\n", qstatus
);
8927 keybd_event('N', 0, 0, 0);
8928 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
8929 qstatus
= GetQueueStatus(qs_all_input
);
8930 ok(qstatus
== MAKELONG(QS_KEY
, QS_KEY
),
8931 "wrong qstatus %08x\n", qstatus
);
8933 PostMessageA(info
.hwnd
, WM_CHAR
, 'z', 0);
8934 qstatus
= GetQueueStatus(qs_all_input
);
8935 ok(qstatus
== MAKELONG(QS_POSTMESSAGE
, QS_POSTMESSAGE
|QS_KEY
),
8936 "wrong qstatus %08x\n", qstatus
);
8938 InvalidateRect(info
.hwnd
, NULL
, FALSE
);
8939 qstatus
= GetQueueStatus(qs_all_input
);
8940 ok(qstatus
== MAKELONG(QS_PAINT
, QS_PAINT
|QS_POSTMESSAGE
|QS_KEY
),
8941 "wrong qstatus %08x\n", qstatus
);
8943 trace("signalling to send message\n");
8944 SetEvent(info
.hevent
[EV_SENDMSG
]);
8945 WaitForSingleObject(info
.hevent
[EV_ACK
], INFINITE
);
8947 qstatus
= GetQueueStatus(qs_all_input
);
8948 ok(qstatus
== MAKELONG(QS_SENDMESSAGE
, QS_SENDMESSAGE
|QS_PAINT
|QS_POSTMESSAGE
|QS_KEY
),
8949 "wrong qstatus %08x\n", qstatus
);
8952 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| (qs_input
<< 16));
8954 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8956 if (!sequence_cnt
) /* nt4 needs explicit PM_QS_SENDMESSAGE to process sent messages */
8958 qs_sendmessage
= QS_SENDMESSAGE
;
8959 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| ((qs_input
|qs_sendmessage
) << 16));
8960 ok(!ret
, "PeekMessageA should have returned FALSE instead of msg %04x\n", msg
.message
);
8962 ok_sequence(WmUser
, "WmUser", FALSE
);
8964 qstatus
= GetQueueStatus(qs_all_input
);
8965 ok(qstatus
== MAKELONG(0, QS_PAINT
|QS_POSTMESSAGE
|QS_KEY
),
8966 "wrong qstatus %08x\n", qstatus
);
8968 trace("signalling to send message\n");
8969 SetEvent(info
.hevent
[EV_SENDMSG
]);
8970 WaitForSingleObject(info
.hevent
[EV_ACK
], INFINITE
);
8972 qstatus
= GetQueueStatus(qs_all_input
);
8973 ok(qstatus
== MAKELONG(QS_SENDMESSAGE
, QS_SENDMESSAGE
|QS_PAINT
|QS_POSTMESSAGE
|QS_KEY
),
8974 "wrong qstatus %08x\n", qstatus
);
8977 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| PM_QS_POSTMESSAGE
| (qs_sendmessage
<< 16) );
8979 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8981 ok_sequence(WmUser
, "WmUser", FALSE
);
8983 qstatus
= GetQueueStatus(qs_all_input
);
8984 ok(qstatus
== MAKELONG(0, QS_PAINT
|QS_POSTMESSAGE
|QS_KEY
),
8985 "wrong qstatus %08x\n", qstatus
);
8988 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| PM_QS_POSTMESSAGE
);
8989 ok(ret
&& msg
.message
== WM_CHAR
&& msg
.wParam
== 'z',
8990 "got %d and %04x wParam %08lx instead of TRUE and WM_CHAR wParam 'z'\n",
8991 ret
, msg
.message
, msg
.wParam
);
8992 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
8994 qstatus
= GetQueueStatus(qs_all_input
);
8995 ok(qstatus
== MAKELONG(0, QS_PAINT
|QS_KEY
),
8996 "wrong qstatus %08x\n", qstatus
);
8999 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| PM_QS_POSTMESSAGE
);
9001 "PeekMessageA should have returned FALSE instead of msg %04x\n",
9003 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
9005 qstatus
= GetQueueStatus(qs_all_input
);
9006 ok(qstatus
== MAKELONG(0, QS_PAINT
|QS_KEY
),
9007 "wrong qstatus %08x\n", qstatus
);
9010 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| PM_QS_PAINT
);
9011 ok(ret
&& msg
.message
== WM_PAINT
,
9012 "got %d and %04x instead of TRUE and WM_PAINT\n", ret
, msg
.message
);
9013 DispatchMessageA(&msg
);
9014 ok_sequence(WmPaint
, "WmPaint", FALSE
);
9016 qstatus
= GetQueueStatus(qs_all_input
);
9017 ok(qstatus
== MAKELONG(0, QS_KEY
),
9018 "wrong qstatus %08x\n", qstatus
);
9021 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| PM_QS_PAINT
);
9023 "PeekMessageA should have returned FALSE instead of msg %04x\n",
9025 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
9027 qstatus
= GetQueueStatus(qs_all_input
);
9028 ok(qstatus
== MAKELONG(0, QS_KEY
),
9029 "wrong qstatus %08x\n", qstatus
);
9031 trace("signalling to send message\n");
9032 SetEvent(info
.hevent
[EV_SENDMSG
]);
9033 WaitForSingleObject(info
.hevent
[EV_ACK
], INFINITE
);
9035 qstatus
= GetQueueStatus(qs_all_input
);
9036 ok(qstatus
== MAKELONG(QS_SENDMESSAGE
, QS_SENDMESSAGE
|QS_KEY
),
9037 "wrong qstatus %08x\n", qstatus
);
9039 PostMessageA(info
.hwnd
, WM_CHAR
, 'z', 0);
9041 qstatus
= GetQueueStatus(qs_all_input
);
9042 ok(qstatus
== MAKELONG(QS_POSTMESSAGE
, QS_SENDMESSAGE
|QS_POSTMESSAGE
|QS_KEY
),
9043 "wrong qstatus %08x\n", qstatus
);
9046 ret
= PeekMessageA(&msg
, 0, WM_CHAR
, WM_CHAR
, PM_REMOVE
);
9047 ok(ret
&& msg
.message
== WM_CHAR
&& msg
.wParam
== 'z',
9048 "got %d and %04x wParam %08lx instead of TRUE and WM_CHAR wParam 'z'\n",
9049 ret
, msg
.message
, msg
.wParam
);
9050 ok_sequence(WmUser
, "WmUser", FALSE
);
9052 qstatus
= GetQueueStatus(qs_all_input
);
9053 ok(qstatus
== MAKELONG(0, QS_KEY
),
9054 "wrong qstatus %08x\n", qstatus
);
9057 ret
= PeekMessageA(&msg
, 0, WM_CHAR
, WM_CHAR
, PM_REMOVE
);
9059 "PeekMessageA should have returned FALSE instead of msg %04x\n",
9061 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
9063 qstatus
= GetQueueStatus(qs_all_input
);
9064 ok(qstatus
== MAKELONG(0, QS_KEY
),
9065 "wrong qstatus %08x\n", qstatus
);
9067 PostMessageA(info
.hwnd
, WM_CHAR
, 'z', 0);
9069 qstatus
= GetQueueStatus(qs_all_input
);
9070 ok(qstatus
== MAKELONG(QS_POSTMESSAGE
, QS_POSTMESSAGE
|QS_KEY
),
9071 "wrong qstatus %08x\n", qstatus
);
9073 trace("signalling to send message\n");
9074 SetEvent(info
.hevent
[EV_SENDMSG
]);
9075 WaitForSingleObject(info
.hevent
[EV_ACK
], INFINITE
);
9077 qstatus
= GetQueueStatus(qs_all_input
);
9078 ok(qstatus
== MAKELONG(QS_SENDMESSAGE
, QS_SENDMESSAGE
|QS_POSTMESSAGE
|QS_KEY
),
9079 "wrong qstatus %08x\n", qstatus
);
9082 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| (QS_KEY
<< 16));
9084 "PeekMessageA should have returned FALSE instead of msg %04x\n",
9086 ok_sequence(WmUser
, "WmUser", FALSE
);
9088 qstatus
= GetQueueStatus(qs_all_input
);
9089 ok(qstatus
== MAKELONG(0, QS_POSTMESSAGE
|QS_KEY
),
9090 "wrong qstatus %08x\n", qstatus
);
9093 if (qs_all_input
& QS_RAWINPUT
) /* use QS_RAWINPUT only if supported */
9094 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| (QS_RAWINPUT
<< 16));
9095 else /* workaround for a missing QS_RAWINPUT support */
9096 ret
= PeekMessageA(&msg
, 0, WM_KEYDOWN
, WM_KEYDOWN
, PM_REMOVE
);
9097 ok(ret
&& msg
.message
== WM_KEYDOWN
&& msg
.wParam
== 'N',
9098 "got %d and %04x wParam %08lx instead of TRUE and WM_KEYDOWN wParam 'N'\n",
9099 ret
, msg
.message
, msg
.wParam
);
9100 ok_sequence(WmKeyDownSkippedSeq
, "WmKeyDownSkippedSeq", FALSE
);
9102 qstatus
= GetQueueStatus(qs_all_input
);
9103 ok(qstatus
== MAKELONG(0, QS_POSTMESSAGE
|QS_KEY
),
9104 "wrong qstatus %08x\n", qstatus
);
9107 if (qs_all_input
& QS_RAWINPUT
) /* use QS_RAWINPUT only if supported */
9108 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| (QS_RAWINPUT
<< 16));
9109 else /* workaround for a missing QS_RAWINPUT support */
9110 ret
= PeekMessageA(&msg
, 0, WM_KEYUP
, WM_KEYUP
, PM_REMOVE
);
9111 ok(ret
&& msg
.message
== WM_KEYUP
&& msg
.wParam
== 'N',
9112 "got %d and %04x wParam %08lx instead of TRUE and WM_KEYUP wParam 'N'\n",
9113 ret
, msg
.message
, msg
.wParam
);
9114 ok_sequence(WmKeyUpSkippedSeq
, "WmKeyUpSkippedSeq", FALSE
);
9116 qstatus
= GetQueueStatus(qs_all_input
);
9117 ok(qstatus
== MAKELONG(0, QS_POSTMESSAGE
),
9118 "wrong qstatus %08x\n", qstatus
);
9121 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| PM_QS_SENDMESSAGE
);
9123 "PeekMessageA should have returned FALSE instead of msg %04x\n",
9125 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
9127 qstatus
= GetQueueStatus(qs_all_input
);
9128 ok(qstatus
== MAKELONG(0, QS_POSTMESSAGE
),
9129 "wrong qstatus %08x\n", qstatus
);
9132 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
9133 ok(ret
&& msg
.message
== WM_CHAR
&& msg
.wParam
== 'z',
9134 "got %d and %04x wParam %08lx instead of TRUE and WM_CHAR wParam 'z'\n",
9135 ret
, msg
.message
, msg
.wParam
);
9136 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
9138 qstatus
= GetQueueStatus(qs_all_input
);
9140 "wrong qstatus %08x\n", qstatus
);
9143 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
9145 "PeekMessageA should have returned FALSE instead of msg %04x\n",
9147 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
9149 qstatus
= GetQueueStatus(qs_all_input
);
9151 "wrong qstatus %08x\n", qstatus
);
9153 /* test whether presence of the quit flag in the queue affects
9156 PostQuitMessage(0x1234abcd);
9158 qstatus
= GetQueueStatus(qs_all_input
);
9159 ok(qstatus
== MAKELONG(QS_POSTMESSAGE
, QS_POSTMESSAGE
),
9160 "wrong qstatus %08x\n", qstatus
);
9162 PostMessageA(info
.hwnd
, WM_USER
, 0, 0);
9164 qstatus
= GetQueueStatus(qs_all_input
);
9165 ok(qstatus
== MAKELONG(QS_POSTMESSAGE
, QS_POSTMESSAGE
),
9166 "wrong qstatus %08x\n", qstatus
);
9169 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
9170 ok(ret
&& msg
.message
== WM_USER
,
9171 "got %d and %04x instead of TRUE and WM_USER\n", ret
, msg
.message
);
9172 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
9174 qstatus
= GetQueueStatus(qs_all_input
);
9175 ok(qstatus
== MAKELONG(0, QS_POSTMESSAGE
),
9176 "wrong qstatus %08x\n", qstatus
);
9179 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
9180 ok(ret
&& msg
.message
== WM_QUIT
,
9181 "got %d and %04x instead of TRUE and WM_QUIT\n", ret
, msg
.message
);
9182 ok(msg
.wParam
== 0x1234abcd, "got wParam %08lx instead of 0x1234abcd\n", msg
.wParam
);
9183 ok(msg
.lParam
== 0, "got lParam %08lx instead of 0\n", msg
.lParam
);
9184 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
9186 qstatus
= GetQueueStatus(qs_all_input
);
9188 ok(qstatus
== MAKELONG(0, QS_POSTMESSAGE
),
9189 "wrong qstatus %08x\n", qstatus
);
9193 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
9195 "PeekMessageA should have returned FALSE instead of msg %04x\n",
9197 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
9199 qstatus
= GetQueueStatus(qs_all_input
);
9201 "wrong qstatus %08x\n", qstatus
);
9203 trace("signalling to exit\n");
9204 SetEvent(info
.hevent
[EV_STOP
]);
9206 WaitForSingleObject(hthread
, INFINITE
);
9208 CloseHandle(hthread
);
9209 CloseHandle(info
.hevent
[0]);
9210 CloseHandle(info
.hevent
[1]);
9211 CloseHandle(info
.hevent
[2]);
9213 DestroyWindow(info
.hwnd
);
9216 static void wait_move_event(HWND hwnd
, int x
, int y
)
9223 time
= GetTickCount();
9224 while (GetTickCount() - time
< 200 && !go
) {
9225 ret
= PeekMessageA(&msg
, hwnd
, WM_MOUSEMOVE
, WM_MOUSEMOVE
, PM_NOREMOVE
);
9226 go
= ret
&& msg
.pt
.x
> x
&& msg
.pt
.y
> y
;
9231 static void test_PeekMessage2(void)
9237 DWORD time1
, time2
, time3
;
9238 int x1
, y1
, x2
, y2
, x3
, y3
;
9241 time1
= time2
= time3
= 0;
9242 x1
= y1
= x2
= y2
= x3
= y3
= 0;
9244 /* Initialise window and make sure it is ready for events */
9245 hwnd
= CreateWindow("TestWindowClass", "PeekMessage2", WS_OVERLAPPEDWINDOW
,
9246 10, 10, 800, 800, NULL
, NULL
, NULL
, NULL
);
9248 trace("Window for test_PeekMessage2 %p\n", hwnd
);
9249 ShowWindow(hwnd
, SW_SHOW
);
9253 SetCursorPos(100, 100);
9254 mouse_event(MOUSEEVENTF_MOVE
, -STEP
, -STEP
, 0, 0);
9257 /* Do initial mousemove, wait until we can see it
9258 and then do our test peek with PM_NOREMOVE. */
9259 mouse_event(MOUSEEVENTF_MOVE
, STEP
, STEP
, 0, 0);
9260 wait_move_event(hwnd
, 80, 80);
9262 ret
= PeekMessageA(&msg
, hwnd
, WM_MOUSEMOVE
, WM_MOUSEMOVE
, PM_NOREMOVE
);
9263 ok(ret
, "no message available\n");
9265 trace("1st move event: %04x %x %d %d\n", msg
.message
, msg
.time
, msg
.pt
.x
, msg
.pt
.y
);
9266 message
= msg
.message
;
9270 ok(message
== WM_MOUSEMOVE
, "message not WM_MOUSEMOVE, %04x instead\n", message
);
9273 /* Allow time to advance a bit, and then simulate the user moving their
9274 * mouse around. After that we peek again with PM_NOREMOVE.
9275 * Although the previous mousemove message was never removed, the
9276 * mousemove we now peek should reflect the recent mouse movements
9277 * because the input queue will merge the move events. */
9279 mouse_event(MOUSEEVENTF_MOVE
, STEP
, STEP
, 0, 0);
9280 wait_move_event(hwnd
, x1
, y1
);
9282 ret
= PeekMessageA(&msg
, hwnd
, WM_MOUSEMOVE
, WM_MOUSEMOVE
, PM_NOREMOVE
);
9283 ok(ret
, "no message available\n");
9285 trace("2nd move event: %04x %x %d %d\n", msg
.message
, msg
.time
, msg
.pt
.x
, msg
.pt
.y
);
9286 message
= msg
.message
;
9290 ok(message
== WM_MOUSEMOVE
, "message not WM_MOUSEMOVE, %04x instead\n", message
);
9291 ok(time2
> time1
, "message time not advanced: %x %x\n", time1
, time2
);
9292 ok(x2
!= x1
&& y2
!= y1
, "coords not changed: (%d %d) (%d %d)\n", x1
, y1
, x2
, y2
);
9295 /* Have another go, to drive the point home */
9297 mouse_event(MOUSEEVENTF_MOVE
, STEP
, STEP
, 0, 0);
9298 wait_move_event(hwnd
, x2
, y2
);
9300 ret
= PeekMessageA(&msg
, hwnd
, WM_MOUSEMOVE
, WM_MOUSEMOVE
, PM_NOREMOVE
);
9301 ok(ret
, "no message available\n");
9303 trace("3rd move event: %04x %x %d %d\n", msg
.message
, msg
.time
, msg
.pt
.x
, msg
.pt
.y
);
9304 message
= msg
.message
;
9308 ok(message
== WM_MOUSEMOVE
, "message not WM_MOUSEMOVE, %04x instead\n", message
);
9309 ok(time3
> time2
, "message time not advanced: %x %x\n", time2
, time3
);
9310 ok(x3
!= x2
&& y3
!= y2
, "coords not changed: (%d %d) (%d %d)\n", x2
, y2
, x3
, y3
);
9313 DestroyWindow(hwnd
);
9314 SetCursorPos(pos
.x
, pos
.y
);
9318 static void test_quit_message(void)
9323 /* test using PostQuitMessage */
9325 PostQuitMessage(0xbeef);
9327 ret
= PeekMessage(&msg
, NULL
, 0, 0, PM_NOREMOVE
);
9328 ok(ret
, "PeekMessage failed with error %d\n", GetLastError());
9329 ok(msg
.message
== WM_QUIT
, "Received message 0x%04x instead of WM_QUIT\n", msg
.message
);
9330 ok(msg
.wParam
== 0xbeef, "wParam was 0x%lx instead of 0xbeef\n", msg
.wParam
);
9332 ret
= PostThreadMessage(GetCurrentThreadId(), WM_USER
, 0, 0);
9333 ok(ret
, "PostMessage failed with error %d\n", GetLastError());
9335 ret
= GetMessage(&msg
, NULL
, 0, 0);
9336 ok(ret
> 0, "GetMessage failed with error %d\n", GetLastError());
9337 ok(msg
.message
== WM_USER
, "Received message 0x%04x instead of WM_USER\n", msg
.message
);
9339 /* note: WM_QUIT message received after WM_USER message */
9340 ret
= GetMessage(&msg
, NULL
, 0, 0);
9341 ok(!ret
, "GetMessage return %d with error %d instead of FALSE\n", ret
, GetLastError());
9342 ok(msg
.message
== WM_QUIT
, "Received message 0x%04x instead of WM_QUIT\n", msg
.message
);
9343 ok(msg
.wParam
== 0xbeef, "wParam was 0x%lx instead of 0xbeef\n", msg
.wParam
);
9345 ret
= PeekMessage(&msg
, NULL
, 0, 0, PM_REMOVE
);
9346 ok( !ret
|| msg
.message
!= WM_QUIT
, "Received WM_QUIT again\n" );
9348 /* now test with PostThreadMessage - different behaviour! */
9349 PostThreadMessage(GetCurrentThreadId(), WM_QUIT
, 0xdead, 0);
9351 ret
= PeekMessage(&msg
, NULL
, 0, 0, PM_NOREMOVE
);
9352 ok(ret
, "PeekMessage failed with error %d\n", GetLastError());
9353 ok(msg
.message
== WM_QUIT
, "Received message 0x%04x instead of WM_QUIT\n", msg
.message
);
9354 ok(msg
.wParam
== 0xdead, "wParam was 0x%lx instead of 0xdead\n", msg
.wParam
);
9356 ret
= PostThreadMessage(GetCurrentThreadId(), WM_USER
, 0, 0);
9357 ok(ret
, "PostMessage failed with error %d\n", GetLastError());
9359 /* note: we receive the WM_QUIT message first this time */
9360 ret
= GetMessage(&msg
, NULL
, 0, 0);
9361 ok(!ret
, "GetMessage return %d with error %d instead of FALSE\n", ret
, GetLastError());
9362 ok(msg
.message
== WM_QUIT
, "Received message 0x%04x instead of WM_QUIT\n", msg
.message
);
9363 ok(msg
.wParam
== 0xdead, "wParam was 0x%lx instead of 0xdead\n", msg
.wParam
);
9365 ret
= GetMessage(&msg
, NULL
, 0, 0);
9366 ok(ret
> 0, "GetMessage failed with error %d\n", GetLastError());
9367 ok(msg
.message
== WM_USER
, "Received message 0x%04x instead of WM_USER\n", msg
.message
);
9370 static const struct message WmMouseHoverSeq
[] = {
9371 { WM_MOUSEACTIVATE
, sent
|optional
}, /* we can get those when moving the mouse in focus-follow-mouse mode under X11 */
9372 { WM_MOUSEACTIVATE
, sent
|optional
},
9373 { WM_TIMER
, sent
|optional
}, /* XP sends it */
9374 { WM_SYSTIMER
, sent
},
9375 { WM_MOUSEHOVER
, sent
|wparam
, 0 },
9379 static void pump_msg_loop_timeout(DWORD timeout
, BOOL inject_mouse_move
)
9382 DWORD start_ticks
, end_ticks
;
9384 start_ticks
= GetTickCount();
9385 /* add some deviation (50%) to cover not expected delays */
9386 start_ticks
+= timeout
/ 2;
9390 while (PeekMessage(&msg
, 0, 0, 0, PM_REMOVE
))
9392 /* Timer proc messages are not dispatched to the window proc,
9393 * and therefore not logged.
9395 if (msg
.message
== WM_TIMER
|| msg
.message
== WM_SYSTIMER
)
9397 struct message s_msg
;
9399 s_msg
.message
= msg
.message
;
9400 s_msg
.flags
= sent
|wparam
|lparam
;
9401 s_msg
.wParam
= msg
.wParam
;
9402 s_msg
.lParam
= msg
.lParam
;
9403 add_message(&s_msg
);
9405 DispatchMessage(&msg
);
9408 end_ticks
= GetTickCount();
9410 /* inject WM_MOUSEMOVE to see how it changes tracking */
9411 if (inject_mouse_move
&& start_ticks
+ timeout
/ 2 >= end_ticks
)
9413 mouse_event(MOUSEEVENTF_MOVE
, -1, 0, 0, 0);
9414 mouse_event(MOUSEEVENTF_MOVE
, 1, 0, 0, 0);
9416 inject_mouse_move
= FALSE
;
9418 } while (start_ticks
+ timeout
>= end_ticks
);
9421 static void test_TrackMouseEvent(void)
9423 TRACKMOUSEEVENT tme
;
9426 RECT rc_parent
, rc_child
;
9427 UINT default_hover_time
, hover_width
= 0, hover_height
= 0;
9429 #define track_hover(track_hwnd, track_hover_time) \
9430 tme.cbSize = sizeof(tme); \
9431 tme.dwFlags = TME_HOVER; \
9432 tme.hwndTrack = track_hwnd; \
9433 tme.dwHoverTime = track_hover_time; \
9434 SetLastError(0xdeadbeef); \
9435 ret = pTrackMouseEvent(&tme); \
9436 ok(ret, "TrackMouseEvent(TME_HOVER) error %d\n", GetLastError())
9438 #define track_query(expected_track_flags, expected_track_hwnd, expected_hover_time) \
9439 tme.cbSize = sizeof(tme); \
9440 tme.dwFlags = TME_QUERY; \
9441 tme.hwndTrack = (HWND)0xdeadbeef; \
9442 tme.dwHoverTime = 0xdeadbeef; \
9443 SetLastError(0xdeadbeef); \
9444 ret = pTrackMouseEvent(&tme); \
9445 ok(ret, "TrackMouseEvent(TME_QUERY) error %d\n", GetLastError());\
9446 ok(tme.cbSize == sizeof(tme), "wrong tme.cbSize %u\n", tme.cbSize); \
9447 ok(tme.dwFlags == (expected_track_flags), \
9448 "wrong tme.dwFlags %08x, expected %08x\n", tme.dwFlags, (expected_track_flags)); \
9449 ok(tme.hwndTrack == (expected_track_hwnd), \
9450 "wrong tme.hwndTrack %p, expected %p\n", tme.hwndTrack, (expected_track_hwnd)); \
9451 ok(tme.dwHoverTime == (expected_hover_time), \
9452 "wrong tme.dwHoverTime %u, expected %u\n", tme.dwHoverTime, (expected_hover_time))
9454 #define track_hover_cancel(track_hwnd) \
9455 tme.cbSize = sizeof(tme); \
9456 tme.dwFlags = TME_HOVER | TME_CANCEL; \
9457 tme.hwndTrack = track_hwnd; \
9458 tme.dwHoverTime = 0xdeadbeef; \
9459 SetLastError(0xdeadbeef); \
9460 ret = pTrackMouseEvent(&tme); \
9461 ok(ret, "TrackMouseEvent(TME_HOVER | TME_CANCEL) error %d\n", GetLastError())
9463 default_hover_time
= 0xdeadbeef;
9464 SetLastError(0xdeadbeef);
9465 ret
= SystemParametersInfo(SPI_GETMOUSEHOVERTIME
, 0, &default_hover_time
, 0);
9466 ok(ret
|| broken(GetLastError() == 0xdeadbeef), /* win9x */
9467 "SystemParametersInfo(SPI_GETMOUSEHOVERTIME) error %u\n", GetLastError());
9468 if (!ret
) default_hover_time
= 400;
9469 trace("SPI_GETMOUSEHOVERTIME returned %u ms\n", default_hover_time
);
9471 SetLastError(0xdeadbeef);
9472 ret
= SystemParametersInfo(SPI_GETMOUSEHOVERWIDTH
, 0, &hover_width
, 0);
9473 ok(ret
|| broken(GetLastError() == 0xdeadbeef), /* win9x */
9474 "SystemParametersInfo(SPI_GETMOUSEHOVERWIDTH) error %u\n", GetLastError());
9475 if (!ret
) hover_width
= 4;
9476 SetLastError(0xdeadbeef);
9477 ret
= SystemParametersInfo(SPI_GETMOUSEHOVERHEIGHT
, 0, &hover_height
, 0);
9478 ok(ret
|| broken(GetLastError() == 0xdeadbeef), /* win9x */
9479 "SystemParametersInfo(SPI_GETMOUSEHOVERHEIGHT) error %u\n", GetLastError());
9480 if (!ret
) hover_height
= 4;
9481 trace("hover rect is %u x %d\n", hover_width
, hover_height
);
9483 hwnd
= CreateWindowEx(0, "TestWindowClass", NULL
,
9484 WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
9485 CW_USEDEFAULT
, CW_USEDEFAULT
, 300, 300, 0,
9489 hchild
= CreateWindowEx(0, "TestWindowClass", NULL
,
9490 WS_CHILD
| WS_BORDER
| WS_VISIBLE
,
9491 50, 50, 200, 200, hwnd
,
9495 SetWindowPos( hwnd
, HWND_TOPMOST
, 0, 0, 0, 0, SWP_NOSIZE
|SWP_NOMOVE
);
9500 tme
.dwFlags
= TME_QUERY
;
9501 tme
.hwndTrack
= (HWND
)0xdeadbeef;
9502 tme
.dwHoverTime
= 0xdeadbeef;
9503 SetLastError(0xdeadbeef);
9504 ret
= pTrackMouseEvent(&tme
);
9505 ok(!ret
, "TrackMouseEvent should fail\n");
9506 ok(GetLastError() == ERROR_INVALID_PARAMETER
|| broken(GetLastError() == 0xdeadbeef),
9507 "not expected error %u\n", GetLastError());
9509 tme
.cbSize
= sizeof(tme
);
9510 tme
.dwFlags
= TME_HOVER
;
9511 tme
.hwndTrack
= (HWND
)0xdeadbeef;
9512 tme
.dwHoverTime
= 0xdeadbeef;
9513 SetLastError(0xdeadbeef);
9514 ret
= pTrackMouseEvent(&tme
);
9515 ok(!ret
, "TrackMouseEvent should fail\n");
9516 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
|| broken(GetLastError() == 0xdeadbeef),
9517 "not expected error %u\n", GetLastError());
9519 tme
.cbSize
= sizeof(tme
);
9520 tme
.dwFlags
= TME_HOVER
| TME_CANCEL
;
9521 tme
.hwndTrack
= (HWND
)0xdeadbeef;
9522 tme
.dwHoverTime
= 0xdeadbeef;
9523 SetLastError(0xdeadbeef);
9524 ret
= pTrackMouseEvent(&tme
);
9525 ok(!ret
, "TrackMouseEvent should fail\n");
9526 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
|| broken(GetLastError() == 0xdeadbeef),
9527 "not expected error %u\n", GetLastError());
9529 GetWindowRect(hwnd
, &rc_parent
);
9530 GetWindowRect(hchild
, &rc_child
);
9531 SetCursorPos(rc_child
.left
- 10, rc_child
.top
- 10);
9533 /* Process messages so that the system updates its internal current
9534 * window and hittest, otherwise TrackMouseEvent calls don't have any
9540 track_query(0, NULL
, 0);
9541 track_hover(hchild
, 0);
9542 track_query(0, NULL
, 0);
9547 track_hover(hwnd
, 0);
9548 track_query(TME_HOVER
, hwnd
, default_hover_time
);
9550 pump_msg_loop_timeout(default_hover_time
, FALSE
);
9551 ok_sequence(WmMouseHoverSeq
, "WmMouseHoverSeq", FALSE
);
9553 track_query(0, NULL
, 0);
9555 track_hover(hwnd
, HOVER_DEFAULT
);
9556 track_query(TME_HOVER
, hwnd
, default_hover_time
);
9558 Sleep(default_hover_time
/ 2);
9559 mouse_event(MOUSEEVENTF_MOVE
, -1, 0, 0, 0);
9560 mouse_event(MOUSEEVENTF_MOVE
, 1, 0, 0, 0);
9562 track_query(TME_HOVER
, hwnd
, default_hover_time
);
9564 pump_msg_loop_timeout(default_hover_time
/ 2, FALSE
);
9565 ok_sequence(WmMouseHoverSeq
, "WmMouseHoverSeq", FALSE
);
9567 track_query(0, NULL
, 0);
9569 track_hover(hwnd
, HOVER_DEFAULT
);
9570 track_query(TME_HOVER
, hwnd
, default_hover_time
);
9572 pump_msg_loop_timeout(default_hover_time
, TRUE
);
9573 ok_sequence(WmMouseHoverSeq
, "WmMouseHoverSeq", FALSE
);
9575 track_query(0, NULL
, 0);
9577 track_hover(hwnd
, HOVER_DEFAULT
);
9578 track_query(TME_HOVER
, hwnd
, default_hover_time
);
9579 track_hover_cancel(hwnd
);
9581 DestroyWindow(hwnd
);
9585 #undef track_hover_cancel
9589 static const struct message WmSetWindowRgn
[] = {
9590 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
},
9591 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
9592 { WM_NCPAINT
, sent
|optional
}, /* wparam != 1 */
9593 { WM_GETTEXT
, sent
|defwinproc
|optional
},
9594 { WM_ERASEBKGND
, sent
|optional
},
9595 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
},
9596 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
9600 static const struct message WmSetWindowRgn_no_redraw
[] = {
9601 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
},
9602 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
9603 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
},
9604 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
9608 static const struct message WmSetWindowRgn_clear
[] = {
9609 { WM_WINDOWPOSCHANGING
, sent
/*|wparam*/, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
/*|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE only on some Windows versions */ },
9610 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
9611 { WM_NCPAINT
, sent
|optional
},
9612 { WM_GETTEXT
, sent
|defwinproc
|optional
},
9613 { WM_ERASEBKGND
, sent
|optional
}, /* FIXME: remove optional once Wine is fixed */
9614 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
},
9615 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
9616 { WM_NCPAINT
, sent
|optional
},
9617 { WM_GETTEXT
, sent
|defwinproc
|optional
},
9618 { WM_ERASEBKGND
, sent
|optional
},
9619 { WM_WINDOWPOSCHANGING
, sent
|optional
},
9620 { WM_NCCALCSIZE
, sent
|optional
|wparam
, 1 },
9621 { WM_NCPAINT
, sent
|optional
},
9622 { WM_GETTEXT
, sent
|defwinproc
|optional
},
9623 { WM_ERASEBKGND
, sent
|optional
},
9624 { WM_WINDOWPOSCHANGED
, sent
|optional
|wparam
, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
},
9625 { WM_NCCALCSIZE
, sent
|optional
|wparam
, 1 },
9626 { WM_NCPAINT
, sent
|optional
},
9627 { WM_GETTEXT
, sent
|defwinproc
|optional
},
9628 { WM_ERASEBKGND
, sent
|optional
},
9629 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
9630 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
9634 static void test_SetWindowRgn(void)
9637 HWND hwnd
= CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW
,
9638 100, 100, 200, 200, 0, 0, 0, NULL
);
9639 ok( hwnd
!= 0, "Failed to create overlapped window\n" );
9641 ShowWindow( hwnd
, SW_SHOW
);
9642 UpdateWindow( hwnd
);
9646 trace("testing SetWindowRgn\n");
9647 hrgn
= CreateRectRgn( 0, 0, 150, 150 );
9648 SetWindowRgn( hwnd
, hrgn
, TRUE
);
9649 ok_sequence( WmSetWindowRgn
, "WmSetWindowRgn", FALSE
);
9651 hrgn
= CreateRectRgn( 30, 30, 160, 160 );
9652 SetWindowRgn( hwnd
, hrgn
, FALSE
);
9653 ok_sequence( WmSetWindowRgn_no_redraw
, "WmSetWindowRgn_no_redraw", FALSE
);
9655 hrgn
= CreateRectRgn( 0, 0, 180, 180 );
9656 SetWindowRgn( hwnd
, hrgn
, TRUE
);
9657 ok_sequence( WmSetWindowRgn
, "WmSetWindowRgn2", FALSE
);
9659 SetWindowRgn( hwnd
, 0, TRUE
);
9660 ok_sequence( WmSetWindowRgn_clear
, "WmSetWindowRgn_clear", FALSE
);
9662 DestroyWindow( hwnd
);
9665 /*************************** ShowWindow() test ******************************/
9666 static const struct message WmShowNormal
[] = {
9667 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
9668 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
9669 { HCBT_ACTIVATE
, hook
},
9670 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2003 doesn't send it */
9671 { HCBT_SETFOCUS
, hook
},
9672 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
9675 static const struct message WmShow
[] = {
9676 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
9677 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
9678 { HCBT_ACTIVATE
, hook
|optional
}, /* win2000 doesn't send it */
9679 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2000 doesn't send it */
9680 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 doesn't send it */
9681 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
9684 static const struct message WmShowNoActivate_1
[] = {
9685 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWNOACTIVATE
},
9686 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_STATECHANGED
},
9687 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_STATECHANGED
},
9688 { WM_MOVE
, sent
|defwinproc
},
9689 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_RESTORED
},
9692 static const struct message WmShowNoActivate_2
[] = {
9693 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWNOACTIVATE
},
9694 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
9695 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
9696 { WM_MOVE
, sent
|defwinproc
},
9697 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_RESTORED
},
9698 { HCBT_SETFOCUS
, hook
|optional
},
9699 { HCBT_ACTIVATE
, hook
|optional
}, /* win2003 doesn't send it */
9700 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2003 doesn't send it */
9701 { HCBT_SETFOCUS
, hook
|optional
}, /* win2003 doesn't send it */
9704 static const struct message WmShowNA_1
[] = {
9705 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
9706 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
9707 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
9710 static const struct message WmShowNA_2
[] = {
9711 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
9712 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
9715 static const struct message WmRestore_1
[] = {
9716 { HCBT_MINMAX
, hook
|lparam
, 0, SW_RESTORE
},
9717 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
9718 { HCBT_ACTIVATE
, hook
|optional
}, /* win2000 doesn't send it */
9719 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2000 doesn't send it */
9720 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 doesn't send it */
9721 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
9722 { WM_MOVE
, sent
|defwinproc
},
9723 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_RESTORED
},
9724 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 sends it */
9727 static const struct message WmRestore_2
[] = {
9728 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
9729 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
9730 { HCBT_ACTIVATE
, hook
|optional
}, /* win2000 doesn't send it */
9731 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2000 doesn't send it */
9732 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 doesn't send it */
9733 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
9736 static const struct message WmRestore_3
[] = {
9737 { HCBT_MINMAX
, hook
|lparam
, 0, SW_RESTORE
},
9738 { WM_GETMINMAXINFO
, sent
},
9739 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
9740 { HCBT_ACTIVATE
, hook
|optional
}, /* win2003 doesn't send it */
9741 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2003 doesn't send it */
9742 { HCBT_SETFOCUS
, hook
|optional
}, /* win2003 doesn't send it */
9743 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
9744 { WM_MOVE
, sent
|defwinproc
},
9745 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_MAXIMIZED
},
9746 { HCBT_SETFOCUS
, hook
|optional
}, /* win2003 sends it */
9749 static const struct message WmRestore_4
[] = {
9750 { HCBT_MINMAX
, hook
|lparam
, 0, SW_RESTORE
},
9751 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
9752 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
9753 { WM_MOVE
, sent
|defwinproc
},
9754 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_RESTORED
},
9757 static const struct message WmRestore_5
[] = {
9758 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWNORMAL
},
9759 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
9760 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
9761 { WM_MOVE
, sent
|defwinproc
},
9762 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_RESTORED
},
9765 static const struct message WmHide_1
[] = {
9766 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
9767 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
9768 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
9769 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 sends it */
9772 static const struct message WmHide_2
[] = {
9773 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
9774 { WM_WINDOWPOSCHANGING
, sent
/*|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE*/ }, /* win2000 doesn't add SWP_NOACTIVATE */
9775 { WM_WINDOWPOSCHANGED
, sent
/*|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE*/ }, /* win2000 doesn't add SWP_NOACTIVATE */
9778 static const struct message WmHide_3
[] = {
9779 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
9780 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
9781 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
9782 { HCBT_SETFOCUS
, hook
|optional
},
9783 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
9786 static const struct message WmShowMinimized_1
[] = {
9787 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINIMIZED
},
9788 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
9789 { HCBT_ACTIVATE
, hook
|optional
}, /* win2000 doesn't send it */
9790 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2000 doesn't send it */
9791 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
9792 { WM_MOVE
, sent
|defwinproc
},
9793 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_MINIMIZED
},
9796 static const struct message WmMinimize_1
[] = {
9797 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
9798 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 doesn't send it */
9799 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
9800 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
9801 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
9802 { WM_MOVE
, sent
|defwinproc
},
9803 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_MINIMIZED
},
9806 static const struct message WmMinimize_2
[] = {
9807 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
9808 { HCBT_SETFOCUS
, hook
|optional
},
9809 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
9810 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
9811 { WM_MOVE
, sent
|defwinproc
},
9812 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_MINIMIZED
},
9815 static const struct message WmMinimize_3
[] = {
9816 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
9817 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
9818 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
9819 { WM_MOVE
, sent
|defwinproc
},
9820 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_MINIMIZED
},
9823 static const struct message WmShowMinNoActivate
[] = {
9824 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINNOACTIVE
},
9825 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
9826 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
9829 static const struct message WmMinMax_1
[] = {
9830 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINIMIZED
},
9833 static const struct message WmMinMax_2
[] = {
9834 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMAXIMIZED
},
9837 static const struct message WmMinMax_3
[] = {
9838 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
9841 static const struct message WmMinMax_4
[] = {
9842 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINNOACTIVE
},
9845 static const struct message WmShowMaximized_1
[] = {
9846 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMAXIMIZED
},
9847 { WM_GETMINMAXINFO
, sent
},
9848 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
9849 { HCBT_ACTIVATE
, hook
|optional
}, /* win2000 doesn't send it */
9850 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2000 doesn't send it */
9851 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 doesn't send it */
9852 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
9853 { WM_MOVE
, sent
|defwinproc
},
9854 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_MAXIMIZED
},
9855 { HCBT_SETFOCUS
, hook
|optional
}, /* win2003 sends it */
9858 static const struct message WmShowMaximized_2
[] = {
9859 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMAXIMIZED
},
9860 { WM_GETMINMAXINFO
, sent
},
9861 { WM_WINDOWPOSCHANGING
, sent
|optional
},
9862 { HCBT_ACTIVATE
, hook
|optional
},
9863 { WM_WINDOWPOSCHANGED
, sent
|optional
},
9864 { WM_MOVE
, sent
|optional
}, /* Win9x doesn't send it */
9865 { WM_SIZE
, sent
|wparam
|optional
, SIZE_MAXIMIZED
}, /* Win9x doesn't send it */
9866 { WM_WINDOWPOSCHANGING
, sent
},
9867 { HCBT_SETFOCUS
, hook
|optional
},
9868 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
9869 { WM_MOVE
, sent
|defwinproc
},
9870 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_MAXIMIZED
},
9871 { HCBT_SETFOCUS
, hook
|optional
},
9874 static const struct message WmShowMaximized_3
[] = {
9875 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMAXIMIZED
},
9876 { WM_GETMINMAXINFO
, sent
},
9877 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
9878 { HCBT_ACTIVATE
, hook
|optional
}, /* win2000 doesn't send it */
9879 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2000 doesn't send it */
9880 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 doesn't send it */
9881 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
9882 { WM_MOVE
, sent
|defwinproc
},
9883 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_MAXIMIZED
},
9887 static void test_ShowWindow(void)
9889 /* ShowWindow commands in random order */
9892 INT cmd
; /* ShowWindow command */
9893 LPARAM ret
; /* ShowWindow return value */
9894 DWORD style
; /* window style after the command */
9895 const struct message
*msg
; /* message sequence the command produces */
9896 BOOL todo_msg
; /* message sequence doesn't match what Wine does */
9899 /* 1 */ { SW_SHOWNORMAL
, FALSE
, WS_VISIBLE
, WmShowNormal
, FALSE
},
9900 /* 2 */ { SW_SHOWNORMAL
, TRUE
, WS_VISIBLE
, WmEmptySeq
, FALSE
},
9901 /* 3 */ { SW_HIDE
, TRUE
, 0, WmHide_1
, FALSE
},
9902 /* 4 */ { SW_HIDE
, FALSE
, 0, WmEmptySeq
, FALSE
},
9903 /* 5 */ { SW_SHOWMINIMIZED
, FALSE
, WS_VISIBLE
|WS_MINIMIZE
, WmShowMinimized_1
, FALSE
},
9904 /* 6 */ { SW_SHOWMINIMIZED
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinMax_1
, FALSE
},
9905 /* 7 */ { SW_HIDE
, TRUE
, WS_MINIMIZE
, WmHide_1
, FALSE
},
9906 /* 8 */ { SW_HIDE
, FALSE
, WS_MINIMIZE
, WmEmptySeq
, FALSE
},
9907 /* 9 */ { SW_SHOWMAXIMIZED
, FALSE
, WS_VISIBLE
|WS_MAXIMIZE
, WmShowMaximized_1
, FALSE
},
9908 /* 10 */ { SW_SHOWMAXIMIZED
, TRUE
, WS_VISIBLE
|WS_MAXIMIZE
, WmMinMax_2
, FALSE
},
9909 /* 11 */ { SW_HIDE
, TRUE
, WS_MAXIMIZE
, WmHide_1
, FALSE
},
9910 /* 12 */ { SW_HIDE
, FALSE
, WS_MAXIMIZE
, WmEmptySeq
, FALSE
},
9911 /* 13 */ { SW_SHOWNOACTIVATE
, FALSE
, WS_VISIBLE
, WmShowNoActivate_1
, FALSE
},
9912 /* 14 */ { SW_SHOWNOACTIVATE
, TRUE
, WS_VISIBLE
, WmEmptySeq
, FALSE
},
9913 /* 15 */ { SW_HIDE
, TRUE
, 0, WmHide_2
, FALSE
},
9914 /* 16 */ { SW_HIDE
, FALSE
, 0, WmEmptySeq
, FALSE
},
9915 /* 17 */ { SW_SHOW
, FALSE
, WS_VISIBLE
, WmShow
, FALSE
},
9916 /* 18 */ { SW_SHOW
, TRUE
, WS_VISIBLE
, WmEmptySeq
, FALSE
},
9917 /* 19 */ { SW_MINIMIZE
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinimize_1
, FALSE
},
9918 /* 20 */ { SW_MINIMIZE
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinMax_3
, FALSE
},
9919 /* 21 */ { SW_HIDE
, TRUE
, WS_MINIMIZE
, WmHide_2
, FALSE
},
9920 /* 22 */ { SW_SHOWMINNOACTIVE
, FALSE
, WS_VISIBLE
|WS_MINIMIZE
, WmShowMinNoActivate
, TRUE
},
9921 /* 23 */ { SW_SHOWMINNOACTIVE
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinMax_4
, FALSE
},
9922 /* 24 */ { SW_HIDE
, TRUE
, WS_MINIMIZE
, WmHide_2
, FALSE
},
9923 /* 25 */ { SW_HIDE
, FALSE
, WS_MINIMIZE
, WmEmptySeq
, FALSE
},
9924 /* 26 */ { SW_SHOWNA
, FALSE
, WS_VISIBLE
|WS_MINIMIZE
, WmShowNA_1
, FALSE
},
9925 /* 27 */ { SW_SHOWNA
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmShowNA_2
, FALSE
},
9926 /* 28 */ { SW_HIDE
, TRUE
, WS_MINIMIZE
, WmHide_2
, FALSE
},
9927 /* 29 */ { SW_HIDE
, FALSE
, WS_MINIMIZE
, WmEmptySeq
, FALSE
},
9928 /* 30 */ { SW_RESTORE
, FALSE
, WS_VISIBLE
, WmRestore_1
, FALSE
},
9929 /* 31 */ { SW_RESTORE
, TRUE
, WS_VISIBLE
, WmEmptySeq
, FALSE
},
9930 /* 32 */ { SW_HIDE
, TRUE
, 0, WmHide_3
, FALSE
},
9931 /* 33 */ { SW_HIDE
, FALSE
, 0, WmEmptySeq
, FALSE
},
9932 /* 34 */ { SW_NORMALNA
, FALSE
, 0, WmEmptySeq
, FALSE
}, /* what does this mean?! */
9933 /* 35 */ { SW_NORMALNA
, FALSE
, 0, WmEmptySeq
, FALSE
},
9934 /* 36 */ { SW_HIDE
, FALSE
, 0, WmEmptySeq
, FALSE
},
9935 /* 37 */ { SW_RESTORE
, FALSE
, WS_VISIBLE
, WmRestore_2
, FALSE
},
9936 /* 38 */ { SW_RESTORE
, TRUE
, WS_VISIBLE
, WmEmptySeq
, FALSE
},
9937 /* 39 */ { SW_SHOWNOACTIVATE
, TRUE
, WS_VISIBLE
, WmEmptySeq
, FALSE
},
9938 /* 40 */ { SW_MINIMIZE
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinimize_2
, FALSE
},
9939 /* 41 */ { SW_MINIMIZE
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinMax_3
, FALSE
},
9940 /* 42 */ { SW_SHOWMAXIMIZED
, TRUE
, WS_VISIBLE
|WS_MAXIMIZE
, WmShowMaximized_2
, TRUE
},
9941 /* 43 */ { SW_SHOWMAXIMIZED
, TRUE
, WS_VISIBLE
|WS_MAXIMIZE
, WmMinMax_2
, FALSE
},
9942 /* 44 */ { SW_MINIMIZE
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinimize_1
, FALSE
},
9943 /* 45 */ { SW_MINIMIZE
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinMax_3
, FALSE
},
9944 /* 46 */ { SW_RESTORE
, TRUE
, WS_VISIBLE
|WS_MAXIMIZE
, WmRestore_3
, FALSE
},
9945 /* 47 */ { SW_RESTORE
, TRUE
, WS_VISIBLE
, WmRestore_4
, FALSE
},
9946 /* 48 */ { SW_SHOWMAXIMIZED
, TRUE
, WS_VISIBLE
|WS_MAXIMIZE
, WmShowMaximized_3
, FALSE
},
9947 /* 49 */ { SW_SHOW
, TRUE
, WS_VISIBLE
|WS_MAXIMIZE
, WmEmptySeq
, FALSE
},
9948 /* 50 */ { SW_SHOWNORMAL
, TRUE
, WS_VISIBLE
, WmRestore_5
, FALSE
},
9949 /* 51 */ { SW_SHOWNORMAL
, TRUE
, WS_VISIBLE
, WmEmptySeq
, FALSE
},
9950 /* 52 */ { SW_HIDE
, TRUE
, 0, WmHide_1
, FALSE
},
9951 /* 53 */ { SW_HIDE
, FALSE
, 0, WmEmptySeq
, FALSE
},
9952 /* 54 */ { SW_MINIMIZE
, FALSE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinimize_3
, FALSE
},
9953 /* 55 */ { SW_HIDE
, TRUE
, WS_MINIMIZE
, WmHide_2
, FALSE
},
9954 /* 56 */ { SW_SHOWNOACTIVATE
, FALSE
, WS_VISIBLE
, WmShowNoActivate_2
, FALSE
},
9955 /* 57 */ { SW_SHOW
, TRUE
, WS_VISIBLE
, WmEmptySeq
, FALSE
}
9962 #define WS_BASE (WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX|WS_MAXIMIZEBOX|WS_POPUP|WS_CLIPSIBLINGS)
9963 hwnd
= CreateWindowEx(0, "ShowWindowClass", NULL
, WS_BASE
,
9968 style
= GetWindowLong(hwnd
, GWL_STYLE
) & ~WS_BASE
;
9969 ok(style
== 0, "expected style 0, got %08x\n", style
);
9974 for (i
= 0; i
< sizeof(sw
)/sizeof(sw
[0]); i
++)
9976 static const char * const sw_cmd_name
[13] =
9978 "SW_HIDE", "SW_SHOWNORMAL", "SW_SHOWMINIMIZED", "SW_SHOWMAXIMIZED",
9979 "SW_SHOWNOACTIVATE", "SW_SHOW", "SW_MINIMIZE", "SW_SHOWMINNOACTIVE",
9980 "SW_SHOWNA", "SW_RESTORE", "SW_SHOWDEFAULT", "SW_FORCEMINIMIZE",
9981 "SW_NORMALNA" /* 0xCC */
9984 INT idx
; /* index into the above array of names */
9986 idx
= (sw
[i
].cmd
== SW_NORMALNA
) ? 12 : sw
[i
].cmd
;
9988 style
= GetWindowLong(hwnd
, GWL_STYLE
);
9989 trace("%d: sending %s, current window style %08x\n", i
+1, sw_cmd_name
[idx
], style
);
9990 ret
= ShowWindow(hwnd
, sw
[i
].cmd
);
9991 ok(!ret
== !sw
[i
].ret
, "%d: cmd %s: expected ret %lu, got %lu\n", i
+1, sw_cmd_name
[idx
], sw
[i
].ret
, ret
);
9992 style
= GetWindowLong(hwnd
, GWL_STYLE
) & ~WS_BASE
;
9993 ok(style
== sw
[i
].style
, "%d: expected style %08x, got %08x\n", i
+1, sw
[i
].style
, style
);
9995 sprintf(comment
, "%d: ShowWindow(%s)", i
+1, sw_cmd_name
[idx
]);
9996 ok_sequence(sw
[i
].msg
, comment
, sw
[i
].todo_msg
);
10002 DestroyWindow(hwnd
);
10005 static INT_PTR WINAPI
test_dlg_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
10007 struct message msg
;
10009 trace("dialog: %p, %04x, %08lx, %08lx\n", hwnd
, message
, wParam
, lParam
);
10013 case WM_WINDOWPOSCHANGING
:
10014 case WM_WINDOWPOSCHANGED
:
10016 WINDOWPOS
*winpos
= (WINDOWPOS
*)lParam
;
10018 trace("%s\n", (message
== WM_WINDOWPOSCHANGING
) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
10019 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x ",
10020 winpos
->hwnd
, winpos
->hwndInsertAfter
,
10021 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
10022 dump_winpos_flags(winpos
->flags
);
10024 /* Log only documented flags, win2k uses 0x1000 and 0x2000
10025 * in the high word for internal purposes
10027 wParam
= winpos
->flags
& 0xffff;
10028 /* We are not interested in the flags that don't match under XP and Win9x */
10029 wParam
&= ~(SWP_NOZORDER
);
10033 /* explicitly ignore WM_GETICON message */
10038 msg
.message
= message
;
10039 msg
.flags
= sent
|wparam
|lparam
;
10040 msg
.wParam
= wParam
;
10041 msg
.lParam
= lParam
;
10044 /* calling DefDlgProc leads to a recursion under XP */
10048 case WM_INITDIALOG
:
10049 case WM_GETDLGCODE
:
10055 static const struct message WmDefDlgSetFocus_1
[] = {
10056 { WM_GETDLGCODE
, sent
|wparam
|lparam
, 0, 0 },
10057 { WM_GETTEXTLENGTH
, sent
|wparam
|lparam
|optional
, 0, 0 }, /* XP */
10058 { WM_GETTEXT
, sent
|wparam
|optional
, 6 }, /* XP */
10059 { WM_GETTEXT
, sent
|wparam
|optional
, 12 }, /* XP */
10060 { EM_SETSEL
, sent
|wparam
, 0 }, /* XP sets lparam to text length, Win9x to -2 */
10061 { HCBT_SETFOCUS
, hook
},
10062 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
10063 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
10064 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
10065 { WM_SETFOCUS
, sent
|wparam
, 0 },
10066 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 10 },
10067 { WM_CTLCOLOREDIT
, sent
},
10068 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 11 },
10069 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
10070 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
10071 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
10072 { WM_COMMAND
, sent
|wparam
, MAKEWPARAM(1, EN_SETFOCUS
) },
10075 static const struct message WmDefDlgSetFocus_2
[] = {
10076 { WM_GETDLGCODE
, sent
|wparam
|lparam
, 0, 0 },
10077 { WM_GETTEXTLENGTH
, sent
|wparam
|lparam
|optional
, 0, 0 }, /* XP */
10078 { WM_GETTEXT
, sent
|wparam
|optional
, 6 }, /* XP */
10079 { WM_GETTEXT
, sent
|wparam
|optional
, 12 }, /* XP */
10080 { EM_SETSEL
, sent
|wparam
, 0 }, /* XP sets lparam to text length, Win9x to -2 */
10081 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
10082 { WM_CTLCOLOREDIT
, sent
|optional
}, /* XP */
10083 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
10086 /* Creation of a dialog */
10087 static const struct message WmCreateDialogParamSeq_1
[] = {
10088 { HCBT_CREATEWND
, hook
},
10089 { WM_NCCREATE
, sent
},
10090 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
10091 { WM_CREATE
, sent
},
10092 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
10093 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
10095 { WM_SETFONT
, sent
},
10096 { WM_INITDIALOG
, sent
},
10097 { WM_CHANGEUISTATE
, sent
|optional
},
10100 /* Creation of a dialog */
10101 static const struct message WmCreateDialogParamSeq_2
[] = {
10102 { HCBT_CREATEWND
, hook
},
10103 { WM_NCCREATE
, sent
},
10104 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
10105 { WM_CREATE
, sent
},
10106 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
10107 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
10109 { WM_CHANGEUISTATE
, sent
|optional
},
10113 static void test_dialog_messages(void)
10116 HWND hdlg
, hedit1
, hedit2
, hfocus
;
10119 #define set_selection(hctl, start, end) \
10120 ret = SendMessage(hctl, EM_SETSEL, start, end); \
10121 ok(ret == 1, "EM_SETSEL returned %ld\n", ret);
10123 #define check_selection(hctl, start, end) \
10124 ret = SendMessage(hctl, EM_GETSEL, 0, 0); \
10125 ok(ret == MAKELRESULT(start, end), "wrong selection (%d - %d)\n", LOWORD(ret), HIWORD(ret));
10129 hdlg
= CreateWindowEx(WS_EX_DLGMODALFRAME
, "TestDialogClass", NULL
,
10130 WS_VISIBLE
|WS_CAPTION
|WS_SYSMENU
|WS_DLGFRAME
,
10131 0, 0, 100, 100, 0, 0, 0, NULL
);
10132 ok(hdlg
!= 0, "Failed to create custom dialog window\n");
10134 hedit1
= CreateWindowEx(0, "my_edit_class", NULL
,
10135 WS_CHILD
|WS_BORDER
|WS_VISIBLE
|WS_TABSTOP
,
10136 0, 0, 80, 20, hdlg
, (HMENU
)1, 0, NULL
);
10137 ok(hedit1
!= 0, "Failed to create edit control\n");
10138 hedit2
= CreateWindowEx(0, "my_edit_class", NULL
,
10139 WS_CHILD
|WS_BORDER
|WS_VISIBLE
|WS_TABSTOP
,
10140 0, 40, 80, 20, hdlg
, (HMENU
)2, 0, NULL
);
10141 ok(hedit2
!= 0, "Failed to create edit control\n");
10143 SendMessage(hedit1
, WM_SETTEXT
, 0, (LPARAM
)"hello");
10144 SendMessage(hedit2
, WM_SETTEXT
, 0, (LPARAM
)"bye");
10146 hfocus
= GetFocus();
10147 ok(hfocus
== hdlg
, "wrong focus %p\n", hfocus
);
10150 hfocus
= GetFocus();
10151 ok(hfocus
== hedit2
, "wrong focus %p\n", hfocus
);
10153 check_selection(hedit1
, 0, 0);
10154 check_selection(hedit2
, 0, 0);
10156 set_selection(hedit2
, 0, -1);
10157 check_selection(hedit2
, 0, 3);
10160 hfocus
= GetFocus();
10161 ok(hfocus
== 0, "wrong focus %p\n", hfocus
);
10164 ret
= DefDlgProc(hdlg
, WM_SETFOCUS
, 0, 0);
10165 ok(ret
== 0, "WM_SETFOCUS returned %ld\n", ret
);
10166 ok_sequence(WmDefDlgSetFocus_1
, "DefDlgProc(WM_SETFOCUS) 1", FALSE
);
10168 hfocus
= GetFocus();
10169 ok(hfocus
== hedit1
, "wrong focus %p\n", hfocus
);
10171 check_selection(hedit1
, 0, 5);
10172 check_selection(hedit2
, 0, 3);
10175 ret
= DefDlgProc(hdlg
, WM_SETFOCUS
, 0, 0);
10176 ok(ret
== 0, "WM_SETFOCUS returned %ld\n", ret
);
10177 ok_sequence(WmDefDlgSetFocus_2
, "DefDlgProc(WM_SETFOCUS) 2", FALSE
);
10179 hfocus
= GetFocus();
10180 ok(hfocus
== hedit1
, "wrong focus %p\n", hfocus
);
10182 check_selection(hedit1
, 0, 5);
10183 check_selection(hedit2
, 0, 3);
10185 EndDialog(hdlg
, 0);
10186 DestroyWindow(hedit1
);
10187 DestroyWindow(hedit2
);
10188 DestroyWindow(hdlg
);
10191 #undef set_selection
10192 #undef check_selection
10194 ok(GetClassInfo(0, "#32770", &cls
), "GetClassInfo failed\n");
10195 cls
.lpszClassName
= "MyDialogClass";
10196 cls
.hInstance
= GetModuleHandle(0);
10197 /* need a cast since a dlgproc is used as a wndproc */
10198 cls
.lpfnWndProc
= (WNDPROC
)test_dlg_proc
;
10199 if (!RegisterClass(&cls
)) assert(0);
10201 hdlg
= CreateDialogParam(0, "CLASS_TEST_DIALOG_2", 0, test_dlg_proc
, 0);
10202 ok(IsWindow(hdlg
), "CreateDialogParam failed\n");
10203 ok_sequence(WmCreateDialogParamSeq_1
, "CreateDialogParam_1", FALSE
);
10204 EndDialog(hdlg
, 0);
10205 DestroyWindow(hdlg
);
10208 hdlg
= CreateDialogParam(0, "CLASS_TEST_DIALOG_2", 0, NULL
, 0);
10209 ok(IsWindow(hdlg
), "CreateDialogParam failed\n");
10210 ok_sequence(WmCreateDialogParamSeq_2
, "CreateDialogParam_2", FALSE
);
10211 EndDialog(hdlg
, 0);
10212 DestroyWindow(hdlg
);
10215 UnregisterClass(cls
.lpszClassName
, cls
.hInstance
);
10218 static void test_nullCallback(void)
10222 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW
,
10223 100, 100, 200, 200, 0, 0, 0, NULL
);
10224 ok (hwnd
!= 0, "Failed to create overlapped window\n");
10226 SendMessageCallbackA(hwnd
,WM_NULL
,0,0,NULL
,0);
10228 DestroyWindow(hwnd
);
10231 /* SetActiveWindow( 0 ) hwnd visible */
10232 static const struct message SetActiveWindowSeq0
[] =
10234 { HCBT_ACTIVATE
, hook
},
10235 { WM_NCACTIVATE
, sent
|wparam
, 0 },
10236 { WM_GETTEXT
, sent
|defwinproc
|optional
},
10237 { WM_ACTIVATE
, sent
|wparam
, 0 },
10238 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
10239 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
10240 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
},
10241 { WM_NCACTIVATE
, sent
|wparam
, 1 },
10242 { WM_GETTEXT
, sent
|defwinproc
|optional
},
10243 { WM_ACTIVATE
, sent
|wparam
, 1 },
10244 { HCBT_SETFOCUS
, hook
},
10245 { WM_KILLFOCUS
, sent
|defwinproc
},
10246 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 0 },
10247 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
10248 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 1 },
10249 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
10250 { WM_SETFOCUS
, sent
|defwinproc
},
10251 { WM_GETTEXT
, sent
|optional
},
10254 /* SetActiveWindow( hwnd ) hwnd visible */
10255 static const struct message SetActiveWindowSeq1
[] =
10257 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
10260 /* SetActiveWindow( popup ) hwnd visible, popup visible */
10261 static const struct message SetActiveWindowSeq2
[] =
10263 { HCBT_ACTIVATE
, hook
},
10264 { WM_NCACTIVATE
, sent
|wparam
, 0 },
10265 { WM_GETTEXT
, sent
|defwinproc
|optional
},
10266 { WM_ACTIVATE
, sent
|wparam
, 0 },
10267 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
10268 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
10269 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
10270 { WM_NCPAINT
, sent
|optional
},
10271 { WM_GETTEXT
, sent
|defwinproc
|optional
},
10272 { WM_ERASEBKGND
, sent
|optional
},
10273 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
10274 { WM_NCACTIVATE
, sent
|wparam
, 1 },
10275 { WM_GETTEXT
, sent
|defwinproc
|optional
},
10276 { WM_ACTIVATE
, sent
|wparam
, 1 },
10277 { HCBT_SETFOCUS
, hook
},
10278 { WM_KILLFOCUS
, sent
|defwinproc
},
10279 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 0 },
10280 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
10281 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 1 },
10282 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
10283 { WM_SETFOCUS
, sent
|defwinproc
},
10284 { WM_GETTEXT
, sent
|optional
},
10288 /* SetActiveWindow( hwnd ) hwnd not visible */
10289 static const struct message SetActiveWindowSeq3
[] =
10291 { HCBT_ACTIVATE
, hook
},
10292 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
10293 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
10294 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
},
10295 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOACTIVATE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
10296 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
10297 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
10298 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
10299 { WM_NCACTIVATE
, sent
|wparam
, 1 },
10300 { WM_ACTIVATE
, sent
|wparam
, 1 },
10301 { HCBT_SETFOCUS
, hook
},
10302 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
10303 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
10304 { WM_SETFOCUS
, sent
|defwinproc
},
10307 /* SetActiveWindow( popup ) hwnd not visible, popup not visible */
10308 static const struct message SetActiveWindowSeq4
[] =
10310 { HCBT_ACTIVATE
, hook
},
10311 { WM_NCACTIVATE
, sent
|wparam
, 0 },
10312 { WM_GETTEXT
, sent
|defwinproc
|optional
},
10313 { WM_ACTIVATE
, sent
|wparam
, 0 },
10314 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
10315 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
},
10316 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
10317 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
10318 { WM_NCACTIVATE
, sent
|wparam
, 1 },
10319 { WM_GETTEXT
, sent
|defwinproc
|optional
},
10320 { WM_ACTIVATE
, sent
|wparam
, 1 },
10321 { HCBT_SETFOCUS
, hook
},
10322 { WM_KILLFOCUS
, sent
|defwinproc
},
10323 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 0 },
10324 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
10325 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 1 },
10326 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
10327 { WM_SETFOCUS
, sent
|defwinproc
},
10332 static void test_SetActiveWindow(void)
10334 HWND hwnd
, popup
, ret
;
10336 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test SetActiveWindow",
10337 WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
10338 100, 100, 200, 200, 0, 0, 0, NULL
);
10340 popup
= CreateWindowExA(0, "TestWindowClass", "Test SetActiveWindow",
10341 WS_OVERLAPPEDWINDOW
| WS_VISIBLE
| WS_POPUP
,
10342 100, 100, 200, 200, hwnd
, 0, 0, NULL
);
10344 ok(hwnd
!= 0, "Failed to create overlapped window\n");
10347 ok(popup
!= 0, "Failed to create popup window\n");
10350 trace("SetActiveWindow(0)\n");
10351 ret
= SetActiveWindow(0);
10352 ok( ret
== popup
, "Failed to SetActiveWindow(0)\n");
10353 ok_sequence(SetActiveWindowSeq0
, "SetActiveWindow(0)", TRUE
);
10356 trace("SetActiveWindow(hwnd), hwnd visible\n");
10357 ret
= SetActiveWindow(hwnd
);
10360 ok( ret
== hwnd
, "Failed to SetActiveWindow(hwnd), hwnd visible\n");
10362 ok_sequence(SetActiveWindowSeq1
, "SetActiveWindow(hwnd), hwnd visible", TRUE
);
10365 trace("SetActiveWindow(popup), hwnd visible, popup visible\n");
10366 ret
= SetActiveWindow(popup
);
10367 ok( ret
== hwnd
, "Failed to SetActiveWindow(popup), popup visible\n");
10368 ok_sequence(SetActiveWindowSeq2
, "SetActiveWindow(popup), hwnd visible, popup visible", FALSE
);
10371 ShowWindow(hwnd
, SW_HIDE
);
10372 ShowWindow(popup
, SW_HIDE
);
10375 trace("SetActiveWindow(hwnd), hwnd not visible\n");
10376 ret
= SetActiveWindow(hwnd
);
10377 ok( ret
== NULL
, "Failed to SetActiveWindow(hwnd), hwnd not visible\n");
10378 ok_sequence(SetActiveWindowSeq3
, "SetActiveWindow(hwnd), hwnd not visible", TRUE
);
10381 trace("SetActiveWindow(popup), hwnd not visible, popup not visible\n");
10382 ret
= SetActiveWindow(popup
);
10383 ok( ret
== hwnd
, "Failed to SetActiveWindow(popup)\n");
10384 ok_sequence(SetActiveWindowSeq4
, "SetActiveWindow(popup), hwnd not visible, popup not visible", TRUE
);
10389 DestroyWindow(hwnd
);
10392 static const struct message SetForegroundWindowSeq
[] =
10394 { WM_NCACTIVATE
, sent
|wparam
, 0 },
10395 { WM_GETTEXT
, sent
|defwinproc
|optional
},
10396 { WM_ACTIVATE
, sent
|wparam
, 0 },
10397 { WM_ACTIVATEAPP
, sent
|wparam
, 0 },
10398 { WM_KILLFOCUS
, sent
},
10399 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
10400 { WM_IME_NOTIFY
, sent
|wparam
|optional
|defwinproc
, 1 },
10404 static void test_SetForegroundWindow(void)
10408 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test SetForegroundWindow",
10409 WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
10410 100, 100, 200, 200, 0, 0, 0, NULL
);
10411 ok (hwnd
!= 0, "Failed to create overlapped window\n");
10414 trace("SetForegroundWindow( 0 )\n");
10415 SetForegroundWindow( 0 );
10416 ok_sequence(WmEmptySeq
, "SetForegroundWindow( 0 ) away from foreground top level window", FALSE
);
10417 trace("SetForegroundWindow( GetDesktopWindow() )\n");
10418 SetForegroundWindow( GetDesktopWindow() );
10419 ok_sequence(SetForegroundWindowSeq
, "SetForegroundWindow( desktop ) away from "
10420 "foreground top level window", FALSE
);
10423 DestroyWindow(hwnd
);
10426 static void test_dbcs_wm_char(void)
10429 WCHAR wch
, bad_wch
;
10437 struct message wmCharSeq
[2];
10439 if (!pGetCPInfoExA
)
10441 skip("GetCPInfoExA is not available\n");
10445 pGetCPInfoExA( CP_ACP
, 0, &cpinfo
);
10446 if (cpinfo
.MaxCharSize
!= 2)
10448 skip( "Skipping DBCS WM_CHAR test in SBCS codepage '%s'\n", cpinfo
.CodePageName
);
10452 dbch
[0] = dbch
[1] = 0;
10454 bad_wch
= cpinfo
.UnicodeDefaultChar
;
10455 for (i
= 0; !wch
&& i
< MAX_LEADBYTES
&& cpinfo
.LeadByte
[i
]; i
+= 2)
10456 for (j
= cpinfo
.LeadByte
[i
]; !wch
&& j
<= cpinfo
.LeadByte
[i
+1]; j
++)
10457 for (k
= 128; k
<= 255; k
++)
10463 if (MultiByteToWideChar( CP_ACP
, 0, str
, 2, wstr
, 2 ) == 1 &&
10464 WideCharToMultiByte( CP_ACP
, 0, wstr
, 1, str
, 2, NULL
, NULL
) == 2 &&
10465 (BYTE
)str
[0] == j
&& (BYTE
)str
[1] == k
&&
10466 HIBYTE(wstr
[0]) && HIBYTE(wstr
[0]) != 0xff)
10477 skip( "Skipping DBCS WM_CHAR test, no appropriate char found\n" );
10480 trace( "using dbcs char %02x,%02x wchar %04x bad wchar %04x codepage '%s'\n",
10481 dbch
[0], dbch
[1], wch
, bad_wch
, cpinfo
.CodePageName
);
10483 hwnd
= CreateWindowExW(0, testWindowClassW
, NULL
,
10484 WS_OVERLAPPEDWINDOW
, 100, 100, 200, 200, 0, 0, 0, NULL
);
10485 hwnd2
= CreateWindowExW(0, testWindowClassW
, NULL
,
10486 WS_OVERLAPPEDWINDOW
, 100, 100, 200, 200, 0, 0, 0, NULL
);
10487 ok (hwnd
!= 0, "Failed to create overlapped window\n");
10488 ok (hwnd2
!= 0, "Failed to create overlapped window\n");
10491 memset( wmCharSeq
, 0, sizeof(wmCharSeq
) );
10492 wmCharSeq
[0].message
= WM_CHAR
;
10493 wmCharSeq
[0].flags
= sent
|wparam
;
10494 wmCharSeq
[0].wParam
= wch
;
10496 /* posted message */
10497 PostMessageA( hwnd
, WM_CHAR
, dbch
[0], 0 );
10498 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
10499 PostMessageA( hwnd
, WM_CHAR
, dbch
[1], 0 );
10500 ok( PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "no message\n" );
10501 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
10502 ok( msg
.wParam
== wch
, "bad wparam %lx/%x\n", msg
.wParam
, wch
);
10503 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
10505 /* posted thread message */
10506 PostThreadMessageA( GetCurrentThreadId(), WM_CHAR
, dbch
[0], 0 );
10507 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
10508 PostMessageA( hwnd
, WM_CHAR
, dbch
[1], 0 );
10509 ok( PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "no message\n" );
10510 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
10511 ok( msg
.wParam
== wch
, "bad wparam %lx/%x\n", msg
.wParam
, wch
);
10512 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
10516 SendMessageA( hwnd
, WM_CHAR
, dbch
[0], 0 );
10517 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
10518 SendMessageA( hwnd
, WM_CHAR
, dbch
[1], 0 );
10519 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
10520 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
10522 /* sent message with timeout */
10524 SendMessageTimeoutA( hwnd
, WM_CHAR
, dbch
[0], 0, SMTO_NORMAL
, 0, &res
);
10525 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
10526 SendMessageTimeoutA( hwnd
, WM_CHAR
, dbch
[1], 0, SMTO_NORMAL
, 0, &res
);
10527 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
10528 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
10530 /* sent message with timeout and callback */
10532 SendMessageTimeoutA( hwnd
, WM_CHAR
, dbch
[0], 0, SMTO_NORMAL
, 0, &res
);
10533 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
10534 SendMessageCallbackA( hwnd
, WM_CHAR
, dbch
[1], 0, NULL
, 0 );
10535 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
10536 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
10538 /* sent message with callback */
10540 SendNotifyMessageA( hwnd
, WM_CHAR
, dbch
[0], 0 );
10541 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
10542 SendMessageCallbackA( hwnd
, WM_CHAR
, dbch
[1], 0, NULL
, 0 );
10543 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
10544 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
10546 /* direct window proc call */
10548 CallWindowProcA( (WNDPROC
)GetWindowLongPtrA( hwnd
, GWLP_WNDPROC
), hwnd
, WM_CHAR
, dbch
[0], 0 );
10549 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
10550 CallWindowProcA( (WNDPROC
)GetWindowLongPtrA( hwnd
, GWLP_WNDPROC
), hwnd
, WM_CHAR
, dbch
[1], 0 );
10551 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
10553 /* dispatch message */
10555 msg
.message
= WM_CHAR
;
10556 msg
.wParam
= dbch
[0];
10558 DispatchMessageA( &msg
);
10559 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
10560 msg
.wParam
= dbch
[1];
10561 DispatchMessageA( &msg
);
10562 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
10564 /* window handle is irrelevant */
10566 SendMessageA( hwnd2
, WM_CHAR
, dbch
[0], 0 );
10567 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
10568 SendMessageA( hwnd
, WM_CHAR
, dbch
[1], 0 );
10569 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
10570 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
10572 /* interleaved post and send */
10574 PostMessageA( hwnd2
, WM_CHAR
, dbch
[0], 0 );
10575 SendMessageA( hwnd2
, WM_CHAR
, dbch
[0], 0 );
10576 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
10577 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
10578 PostMessageA( hwnd
, WM_CHAR
, dbch
[1], 0 );
10579 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
10580 ok( PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "no message\n" );
10581 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
10582 ok( msg
.wParam
== wch
, "bad wparam %lx/%x\n", msg
.wParam
, wch
);
10583 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
10584 SendMessageA( hwnd
, WM_CHAR
, dbch
[1], 0 );
10585 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
10586 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
10588 /* interleaved sent message and winproc */
10590 SendMessageA( hwnd
, WM_CHAR
, dbch
[0], 0 );
10591 CallWindowProcA( (WNDPROC
)GetWindowLongPtrA( hwnd
, GWLP_WNDPROC
), hwnd
, WM_CHAR
, dbch
[0], 0 );
10592 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
10593 SendMessageA( hwnd
, WM_CHAR
, dbch
[1], 0 );
10594 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
10595 CallWindowProcA( (WNDPROC
)GetWindowLongPtrA( hwnd
, GWLP_WNDPROC
), hwnd
, WM_CHAR
, dbch
[1], 0 );
10596 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
10598 /* interleaved winproc and dispatch */
10600 msg
.message
= WM_CHAR
;
10601 msg
.wParam
= dbch
[0];
10603 CallWindowProcA( (WNDPROC
)GetWindowLongPtrA( hwnd
, GWLP_WNDPROC
), hwnd
, WM_CHAR
, dbch
[0], 0 );
10604 DispatchMessageA( &msg
);
10605 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
10606 msg
.wParam
= dbch
[1];
10607 DispatchMessageA( &msg
);
10608 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
10609 CallWindowProcA( (WNDPROC
)GetWindowLongPtrA( hwnd
, GWLP_WNDPROC
), hwnd
, WM_CHAR
, dbch
[1], 0 );
10610 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
10612 /* interleaved sends */
10614 SendMessageA( hwnd
, WM_CHAR
, dbch
[0], 0 );
10615 SendMessageCallbackA( hwnd
, WM_CHAR
, dbch
[0], 0, NULL
, 0 );
10616 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
10617 SendMessageTimeoutA( hwnd
, WM_CHAR
, dbch
[1], 0, SMTO_NORMAL
, 0, &res
);
10618 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
10619 SendMessageA( hwnd
, WM_CHAR
, dbch
[1], 0 );
10620 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
10624 SendMessageA( hwnd2
, WM_CHAR
, (dbch
[1] << 8) | dbch
[0], 0 );
10625 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
10626 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
10628 /* other char messages are not magic */
10629 PostMessageA( hwnd
, WM_SYSCHAR
, dbch
[0], 0 );
10630 ok( PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "no message\n" );
10631 ok( msg
.message
== WM_SYSCHAR
, "unexpected message %x\n", msg
.message
);
10632 ok( msg
.wParam
== bad_wch
, "bad wparam %lx/%x\n", msg
.wParam
, bad_wch
);
10633 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
10634 PostMessageA( hwnd
, WM_DEADCHAR
, dbch
[0], 0 );
10635 ok( PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "no message\n" );
10636 ok( msg
.message
== WM_DEADCHAR
, "unexpected message %x\n", msg
.message
);
10637 ok( msg
.wParam
== bad_wch
, "bad wparam %lx/%x\n", msg
.wParam
, bad_wch
);
10638 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
10640 /* test retrieving messages */
10642 PostMessageW( hwnd
, WM_CHAR
, wch
, 0 );
10643 ok( PeekMessageA( &msg
, hwnd
, 0, 0, PM_REMOVE
), "no message\n" );
10644 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
10645 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
10646 ok( msg
.wParam
== dbch
[0], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
10647 ok( PeekMessageA( &msg
, hwnd
, 0, 0, PM_REMOVE
), "no message\n" );
10648 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
10649 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
10650 ok( msg
.wParam
== dbch
[1], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
10651 ok( !PeekMessageA( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
10653 /* message filters */
10654 PostMessageW( hwnd
, WM_CHAR
, wch
, 0 );
10655 ok( PeekMessageA( &msg
, hwnd
, 0, 0, PM_REMOVE
), "no message\n" );
10656 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
10657 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
10658 ok( msg
.wParam
== dbch
[0], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
10659 /* message id is filtered, hwnd is not */
10660 ok( !PeekMessageA( &msg
, hwnd
, WM_MOUSEFIRST
, WM_MOUSELAST
, PM_REMOVE
), "no message\n" );
10661 ok( PeekMessageA( &msg
, hwnd2
, 0, 0, PM_REMOVE
), "no message\n" );
10662 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
10663 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
10664 ok( msg
.wParam
== dbch
[1], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
10665 ok( !PeekMessageA( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
10667 /* mixing GetMessage and PostMessage */
10668 PostMessageW( hwnd
, WM_CHAR
, wch
, 0xbeef );
10669 ok( GetMessageA( &msg
, hwnd
, 0, 0 ), "no message\n" );
10670 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
10671 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
10672 ok( msg
.wParam
== dbch
[0], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
10673 ok( msg
.lParam
== 0xbeef, "bad lparam %lx\n", msg
.lParam
);
10676 ok( time
- GetTickCount() <= 100, "bad time %x\n", msg
.time
);
10677 ok( PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
), "no message\n" );
10678 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
10679 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
10680 ok( msg
.wParam
== dbch
[1], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
10681 ok( msg
.lParam
== 0xbeef, "bad lparam %lx\n", msg
.lParam
);
10682 ok( msg
.time
== time
, "bad time %x/%x\n", msg
.time
, time
);
10683 ok( msg
.pt
.x
== pt
.x
&& msg
.pt
.y
== pt
.y
, "bad point %u,%u/%u,%u\n", msg
.pt
.x
, msg
.pt
.y
, pt
.x
, pt
.y
);
10684 ok( !PeekMessageA( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
10686 /* without PM_REMOVE */
10687 PostMessageW( hwnd
, WM_CHAR
, wch
, 0 );
10688 ok( PeekMessageA( &msg
, 0, 0, 0, PM_NOREMOVE
), "no message\n" );
10689 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
10690 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
10691 ok( msg
.wParam
== dbch
[0], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
10692 ok( PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
), "no message\n" );
10693 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
10694 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
10695 ok( msg
.wParam
== dbch
[0], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
10696 ok( PeekMessageA( &msg
, 0, 0, 0, PM_NOREMOVE
), "no message\n" );
10697 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
10698 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
10699 ok( msg
.wParam
== dbch
[1], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
10700 ok( PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
), "no message\n" );
10701 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
10702 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
10703 ok( msg
.wParam
== dbch
[1], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
10704 ok( !PeekMessageA( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
10706 DestroyWindow(hwnd
);
10709 #define ID_LISTBOX 0x000f
10711 static const struct message wm_lb_setcursel_0
[] =
10713 { LB_SETCURSEL
, sent
|wparam
|lparam
, 0, 0 },
10714 { WM_CTLCOLORLISTBOX
, sent
|parent
},
10715 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x000120f2 },
10716 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 1 },
10717 { EVENT_OBJECT_SELECTION
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 1 },
10720 static const struct message wm_lb_setcursel_1
[] =
10722 { LB_SETCURSEL
, sent
|wparam
|lparam
, 1, 0 },
10723 { WM_CTLCOLORLISTBOX
, sent
|parent
},
10724 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x000020f2 },
10725 { WM_CTLCOLORLISTBOX
, sent
|parent
},
10726 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x000121f2 },
10727 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 2 },
10728 { EVENT_OBJECT_SELECTION
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 2 },
10731 static const struct message wm_lb_setcursel_2
[] =
10733 { LB_SETCURSEL
, sent
|wparam
|lparam
, 2, 0 },
10734 { WM_CTLCOLORLISTBOX
, sent
|parent
},
10735 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x000021f2 },
10736 { WM_CTLCOLORLISTBOX
, sent
|parent
},
10737 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x000122f2 },
10738 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 3 },
10739 { EVENT_OBJECT_SELECTION
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 3 },
10742 static const struct message wm_lb_click_0
[] =
10744 { WM_LBUTTONDOWN
, sent
|wparam
|lparam
, 0, MAKELPARAM(1,1) },
10745 { HCBT_SETFOCUS
, hook
},
10746 { WM_KILLFOCUS
, sent
|parent
},
10747 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
|parent
, 0 },
10748 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
10749 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
10750 { WM_SETFOCUS
, sent
|defwinproc
},
10752 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x001142f2 },
10753 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_LISTBOX
, LBN_SETFOCUS
) },
10754 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 3 },
10755 { WM_LBTRACKPOINT
, sent
|wparam
|lparam
|parent
, 0, MAKELPARAM(1,1) },
10756 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
10758 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x000142f2 },
10759 { WM_CTLCOLORLISTBOX
, sent
|parent
},
10760 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x000022f2 },
10761 { WM_CTLCOLORLISTBOX
, sent
|parent
},
10762 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x000120f2 },
10763 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x001140f2 },
10765 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 1 },
10766 { EVENT_OBJECT_SELECTION
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 1 },
10768 { WM_LBUTTONUP
, sent
|wparam
|lparam
, 0, 0 },
10769 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, 0, 0 },
10770 { WM_CAPTURECHANGED
, sent
|wparam
|lparam
|defwinproc
, 0, 0 },
10771 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_LISTBOX
, LBN_SELCHANGE
) },
10775 #define check_lb_state(a1, a2, a3, a4, a5) check_lb_state_dbg(a1, a2, a3, a4, a5, __LINE__)
10777 static LRESULT (WINAPI
*listbox_orig_proc
)(HWND
, UINT
, WPARAM
, LPARAM
);
10779 static LRESULT WINAPI
listbox_hook_proc(HWND hwnd
, UINT message
, WPARAM wp
, LPARAM lp
)
10781 static long defwndproc_counter
= 0;
10783 struct message msg
;
10785 /* do not log painting messages */
10786 if (message
!= WM_PAINT
&&
10787 message
!= WM_NCPAINT
&&
10788 message
!= WM_SYNCPAINT
&&
10789 message
!= WM_ERASEBKGND
&&
10790 message
!= WM_NCHITTEST
&&
10791 message
!= WM_GETTEXT
&&
10792 message
!= WM_GETICON
&&
10793 message
!= WM_DEVICECHANGE
)
10795 trace("listbox: %p, %04x, %08lx, %08lx\n", hwnd
, message
, wp
, lp
);
10797 msg
.message
= message
;
10798 msg
.flags
= sent
|wparam
|lparam
;
10799 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
10805 defwndproc_counter
++;
10806 ret
= CallWindowProcA(listbox_orig_proc
, hwnd
, message
, wp
, lp
);
10807 defwndproc_counter
--;
10812 static void check_lb_state_dbg(HWND listbox
, int count
, int cur_sel
,
10813 int caret_index
, int top_index
, int line
)
10817 /* calling an orig proc helps to avoid unnecessary message logging */
10818 ret
= CallWindowProcA(listbox_orig_proc
, listbox
, LB_GETCOUNT
, 0, 0);
10819 ok_(__FILE__
, line
)(ret
== count
, "expected count %d, got %ld\n", count
, ret
);
10820 ret
= CallWindowProcA(listbox_orig_proc
, listbox
, LB_GETCURSEL
, 0, 0);
10821 ok_(__FILE__
, line
)(ret
== cur_sel
, "expected cur sel %d, got %ld\n", cur_sel
, ret
);
10822 ret
= CallWindowProcA(listbox_orig_proc
, listbox
, LB_GETCARETINDEX
, 0, 0);
10823 ok_(__FILE__
, line
)(ret
== caret_index
, "expected caret index %d, got %ld\n", caret_index
, ret
);
10824 ret
= CallWindowProcA(listbox_orig_proc
, listbox
, LB_GETTOPINDEX
, 0, 0);
10825 ok_(__FILE__
, line
)(ret
== top_index
, "expected top index %d, got %ld\n", top_index
, ret
);
10828 static void test_listbox_messages(void)
10830 HWND parent
, listbox
;
10833 parent
= CreateWindowExA(0, "TestParentClass", NULL
, WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
10834 100, 100, 200, 200, 0, 0, 0, NULL
);
10835 listbox
= CreateWindowExA(WS_EX_NOPARENTNOTIFY
, "ListBox", NULL
,
10836 WS_CHILD
| LBS_NOTIFY
| LBS_OWNERDRAWVARIABLE
| LBS_HASSTRINGS
| WS_VISIBLE
,
10837 10, 10, 80, 80, parent
, (HMENU
)ID_LISTBOX
, 0, NULL
);
10838 listbox_orig_proc
= (WNDPROC
)SetWindowLongPtrA(listbox
, GWLP_WNDPROC
, (ULONG_PTR
)listbox_hook_proc
);
10840 check_lb_state(listbox
, 0, LB_ERR
, 0, 0);
10842 ret
= SendMessage(listbox
, LB_ADDSTRING
, 0, (LPARAM
)"item 0");
10843 ok(ret
== 0, "expected 0, got %ld\n", ret
);
10844 ret
= SendMessage(listbox
, LB_ADDSTRING
, 0, (LPARAM
)"item 1");
10845 ok(ret
== 1, "expected 1, got %ld\n", ret
);
10846 ret
= SendMessage(listbox
, LB_ADDSTRING
, 0, (LPARAM
)"item 2");
10847 ok(ret
== 2, "expected 2, got %ld\n", ret
);
10849 check_lb_state(listbox
, 3, LB_ERR
, 0, 0);
10853 log_all_parent_messages
++;
10855 trace("selecting item 0\n");
10856 ret
= SendMessage(listbox
, LB_SETCURSEL
, 0, 0);
10857 ok(ret
== 0, "expected 0, got %ld\n", ret
);
10858 ok_sequence(wm_lb_setcursel_0
, "LB_SETCURSEL 0", FALSE
);
10859 check_lb_state(listbox
, 3, 0, 0, 0);
10862 trace("selecting item 1\n");
10863 ret
= SendMessage(listbox
, LB_SETCURSEL
, 1, 0);
10864 ok(ret
== 1, "expected 1, got %ld\n", ret
);
10865 ok_sequence(wm_lb_setcursel_1
, "LB_SETCURSEL 1", FALSE
);
10866 check_lb_state(listbox
, 3, 1, 1, 0);
10868 trace("selecting item 2\n");
10869 ret
= SendMessage(listbox
, LB_SETCURSEL
, 2, 0);
10870 ok(ret
== 2, "expected 2, got %ld\n", ret
);
10871 ok_sequence(wm_lb_setcursel_2
, "LB_SETCURSEL 2", FALSE
);
10872 check_lb_state(listbox
, 3, 2, 2, 0);
10874 trace("clicking on item 0\n");
10875 ret
= SendMessage(listbox
, WM_LBUTTONDOWN
, 0, MAKELPARAM(1, 1));
10876 ok(ret
== LB_OKAY
, "expected LB_OKAY, got %ld\n", ret
);
10877 ret
= SendMessage(listbox
, WM_LBUTTONUP
, 0, 0);
10878 ok(ret
== LB_OKAY
, "expected LB_OKAY, got %ld\n", ret
);
10879 ok_sequence(wm_lb_click_0
, "WM_LBUTTONDOWN 0", FALSE
);
10880 check_lb_state(listbox
, 3, 0, 0, 0);
10883 log_all_parent_messages
--;
10885 DestroyWindow(listbox
);
10886 DestroyWindow(parent
);
10889 /*************************** Menu test ******************************/
10890 static const struct message wm_popup_menu_1
[] =
10892 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 },
10893 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
10894 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'E', 0x20000001 },
10895 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, 'E', 0x20000001 },
10896 { WM_SYSCHAR
, sent
|wparam
|lparam
, 'e', 0x20000001 },
10897 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_KEYMENU
, 'e' },
10898 { WM_ENTERMENULOOP
, sent
|wparam
|lparam
, 0, 0 },
10899 { WM_INITMENU
, sent
|lparam
, 0, 0 },
10900 { WM_MENUSELECT
, sent
|wparam
, MAKEWPARAM(1,MF_HILITE
|MF_POPUP
) },
10901 { WM_INITMENUPOPUP
, sent
|lparam
, 0, 1 },
10902 { HCBT_CREATEWND
, hook
|optional
}, /* Win9x doesn't create a window */
10903 { WM_MENUSELECT
, sent
|wparam
, MAKEWPARAM(200,MF_HILITE
) },
10904 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'E', 0xf0000001 },
10905 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xd0000001 },
10906 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_RETURN
, 0x10000001 },
10907 { HCBT_DESTROYWND
, hook
|optional
}, /* Win9x doesn't create a window */
10908 { WM_UNINITMENUPOPUP
, sent
|lparam
, 0, 0 },
10909 { WM_MENUSELECT
, sent
|wparam
|lparam
, MAKEWPARAM(0,0xffff), 0 },
10910 { WM_EXITMENULOOP
, sent
|wparam
|lparam
, 0, 0 },
10911 { WM_MENUCOMMAND
, sent
}, /* |wparam, 200 - Win9x */
10912 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_RETURN
, 0xc0000001 },
10913 { WM_KEYUP
, sent
|wparam
|lparam
, VK_RETURN
, 0xc0000001 },
10916 static const struct message wm_popup_menu_2
[] =
10918 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 },
10919 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
10920 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'F', 0x20000001 },
10921 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, 'F', 0x20000001 },
10922 { WM_SYSCHAR
, sent
|wparam
|lparam
, 'f', 0x20000001 },
10923 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_KEYMENU
, 'f' },
10924 { WM_ENTERMENULOOP
, sent
|wparam
|lparam
, 0, 0 },
10925 { WM_INITMENU
, sent
|lparam
, 0, 0 },
10926 { WM_MENUSELECT
, sent
|wparam
, MAKEWPARAM(0,MF_HILITE
|MF_POPUP
) },
10927 { WM_INITMENUPOPUP
, sent
|lparam
, 0, 0 },
10928 { WM_MENUSELECT
, sent
|wparam
|optional
, MAKEWPARAM(0,MF_HILITE
|MF_POPUP
) }, /* Win9x */
10929 { WM_INITMENUPOPUP
, sent
|lparam
|optional
, 0, 0 }, /* Win9x */
10930 { HCBT_CREATEWND
, hook
},
10931 { WM_MENUSELECT
, sent
}, /*|wparam, MAKEWPARAM(0,MF_HILITE|MF_POPUP) - XP
10932 |wparam, MAKEWPARAM(100,MF_HILITE) - Win9x */
10933 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'F', 0xf0000001 },
10934 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xd0000001 },
10935 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_RIGHT
, 0x10000001 },
10936 { WM_INITMENUPOPUP
, sent
|lparam
|optional
, 0, 0 }, /* Win9x doesn't send it */
10937 { HCBT_CREATEWND
, hook
|optional
}, /* Win9x doesn't send it */
10938 { WM_MENUSELECT
, sent
|wparam
|optional
, MAKEWPARAM(100,MF_HILITE
) },
10939 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_RIGHT
, 0xd0000001 },
10940 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_RETURN
, 0x10000001 },
10941 { HCBT_DESTROYWND
, hook
},
10942 { WM_UNINITMENUPOPUP
, sent
|lparam
, 0, 0 },
10943 { HCBT_DESTROYWND
, hook
|optional
}, /* Win9x doesn't send it */
10944 { WM_UNINITMENUPOPUP
, sent
|lparam
, 0, 0 },
10945 { WM_MENUSELECT
, sent
|wparam
|lparam
, MAKEWPARAM(0,0xffff), 0 },
10946 { WM_EXITMENULOOP
, sent
|wparam
|lparam
, 0, 0 },
10947 { WM_MENUCOMMAND
, sent
}, /* |wparam, 100 - Win9x */
10948 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_RETURN
, 0xc0000001 },
10949 { WM_KEYUP
, sent
|wparam
|lparam
, VK_RETURN
, 0xc0000001 },
10952 static const struct message wm_popup_menu_3
[] =
10954 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 },
10955 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
10956 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'F', 0x20000001 },
10957 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, 'F', 0x20000001 },
10958 { WM_SYSCHAR
, sent
|wparam
|lparam
, 'f', 0x20000001 },
10959 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_KEYMENU
, 'f' },
10960 { WM_ENTERMENULOOP
, sent
|wparam
|lparam
, 0, 0 },
10961 { WM_INITMENU
, sent
|lparam
, 0, 0 },
10962 { WM_MENUSELECT
, sent
|wparam
, MAKEWPARAM(0,MF_HILITE
|MF_POPUP
) },
10963 { WM_INITMENUPOPUP
, sent
|lparam
, 0, 0 },
10964 { WM_MENUSELECT
, sent
|wparam
|optional
, MAKEWPARAM(0,MF_HILITE
|MF_POPUP
) }, /* Win9x */
10965 { WM_INITMENUPOPUP
, sent
|lparam
|optional
, 0, 0 }, /* Win9x */
10966 { HCBT_CREATEWND
, hook
},
10967 { WM_MENUSELECT
, sent
}, /*|wparam, MAKEWPARAM(0,MF_HILITE|MF_POPUP) - XP
10968 |wparam, MAKEWPARAM(100,MF_HILITE) - Win9x */
10969 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'F', 0xf0000001 },
10970 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xd0000001 },
10971 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_RIGHT
, 0x10000001 },
10972 { WM_INITMENUPOPUP
, sent
|lparam
|optional
, 0, 0 }, /* Win9x doesn't send it */
10973 { HCBT_CREATEWND
, hook
|optional
}, /* Win9x doesn't send it */
10974 { WM_MENUSELECT
, sent
|wparam
|optional
, MAKEWPARAM(100,MF_HILITE
) },
10975 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_RIGHT
, 0xd0000001 },
10976 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_RETURN
, 0x10000001 },
10977 { HCBT_DESTROYWND
, hook
},
10978 { WM_UNINITMENUPOPUP
, sent
|lparam
, 0, 0 },
10979 { HCBT_DESTROYWND
, hook
|optional
}, /* Win9x doesn't send it */
10980 { WM_UNINITMENUPOPUP
, sent
|lparam
, 0, 0 },
10981 { WM_MENUSELECT
, sent
|wparam
|lparam
, MAKEWPARAM(0,0xffff), 0 },
10982 { WM_EXITMENULOOP
, sent
|wparam
|lparam
, 0, 0 },
10983 { WM_COMMAND
, sent
|wparam
|lparam
, 100, 0 },
10984 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_RETURN
, 0xc0000001 },
10985 { WM_KEYUP
, sent
|wparam
|lparam
, VK_RETURN
, 0xc0000001 },
10989 static LRESULT WINAPI
parent_menu_proc(HWND hwnd
, UINT message
, WPARAM wp
, LPARAM lp
)
10991 if (message
== WM_ENTERIDLE
||
10992 message
== WM_INITMENU
||
10993 message
== WM_INITMENUPOPUP
||
10994 message
== WM_MENUSELECT
||
10995 message
== WM_PARENTNOTIFY
||
10996 message
== WM_ENTERMENULOOP
||
10997 message
== WM_EXITMENULOOP
||
10998 message
== WM_UNINITMENUPOPUP
||
10999 message
== WM_KEYDOWN
||
11000 message
== WM_KEYUP
||
11001 message
== WM_CHAR
||
11002 message
== WM_SYSKEYDOWN
||
11003 message
== WM_SYSKEYUP
||
11004 message
== WM_SYSCHAR
||
11005 message
== WM_COMMAND
||
11006 message
== WM_MENUCOMMAND
)
11008 struct message msg
;
11010 trace("parent_menu_proc: %p, %04x, %08lx, %08lx\n", hwnd
, message
, wp
, lp
);
11012 msg
.message
= message
;
11013 msg
.flags
= sent
|wparam
|lparam
;
11019 return DefWindowProcA(hwnd
, message
, wp
, lp
);
11022 static void set_menu_style(HMENU hmenu
, DWORD style
)
11027 mi
.cbSize
= sizeof(mi
);
11028 mi
.fMask
= MIM_STYLE
;
11029 mi
.dwStyle
= style
;
11030 SetLastError(0xdeadbeef);
11031 ret
= pSetMenuInfo(hmenu
, &mi
);
11032 ok(ret
, "SetMenuInfo error %u\n", GetLastError());
11035 static DWORD
get_menu_style(HMENU hmenu
)
11040 mi
.cbSize
= sizeof(mi
);
11041 mi
.fMask
= MIM_STYLE
;
11043 SetLastError(0xdeadbeef);
11044 ret
= pGetMenuInfo(hmenu
, &mi
);
11045 ok(ret
, "GetMenuInfo error %u\n", GetLastError());
11050 static void test_menu_messages(void)
11054 HMENU hmenu
, hmenu_popup
;
11058 if (!pGetMenuInfo
|| !pSetMenuInfo
)
11060 skip("GetMenuInfo and/or SetMenuInfo are not available\n");
11064 cls
.lpfnWndProc
= parent_menu_proc
;
11065 cls
.cbClsExtra
= 0;
11066 cls
.cbWndExtra
= 0;
11067 cls
.hInstance
= GetModuleHandleA(0);
11069 cls
.hCursor
= LoadCursorA(0, (LPSTR
)IDC_ARROW
);
11070 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
11071 cls
.lpszMenuName
= NULL
;
11072 cls
.lpszClassName
= "TestMenuClass";
11073 UnregisterClass(cls
.lpszClassName
, cls
.hInstance
);
11074 if (!RegisterClassA(&cls
)) assert(0);
11076 SetLastError(0xdeadbeef);
11077 hwnd
= CreateWindowExA(0, "TestMenuClass", NULL
, WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
11078 100, 100, 200, 200, 0, 0, 0, NULL
);
11079 ok(hwnd
!= 0, "LoadMenuA error %u\n", GetLastError());
11081 SetLastError(0xdeadbeef);
11082 hmenu
= LoadMenuA(GetModuleHandle(0), MAKEINTRESOURCE(1));
11083 ok(hmenu
!= 0, "LoadMenuA error %u\n", GetLastError());
11085 SetMenu(hwnd
, hmenu
);
11086 SetForegroundWindow( hwnd
);
11088 set_menu_style(hmenu
, MNS_NOTIFYBYPOS
);
11089 style
= get_menu_style(hmenu
);
11090 ok(style
== MNS_NOTIFYBYPOS
, "expected MNS_NOTIFYBYPOS, got %u\n", style
);
11092 hmenu_popup
= GetSubMenu(hmenu
, 0);
11093 ok(hmenu_popup
!= 0, "GetSubMenu returned 0 for submenu 0\n");
11094 style
= get_menu_style(hmenu_popup
);
11095 ok(style
== 0, "expected 0, got %u\n", style
);
11097 hmenu_popup
= GetSubMenu(hmenu_popup
, 0);
11098 ok(hmenu_popup
!= 0, "GetSubMenu returned 0 for submenu 0\n");
11099 style
= get_menu_style(hmenu_popup
);
11100 ok(style
== 0, "expected 0, got %u\n", style
);
11103 trace("testing a popup menu command\n");
11105 keybd_event(VK_MENU
, 0, 0, 0);
11106 keybd_event('E', 0, 0, 0);
11107 keybd_event('E', 0, KEYEVENTF_KEYUP
, 0);
11108 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
11109 keybd_event(VK_RETURN
, 0, 0, 0);
11110 keybd_event(VK_RETURN
, 0, KEYEVENTF_KEYUP
, 0);
11111 while (PeekMessage(&msg
, 0, 0, 0, PM_REMOVE
))
11113 TranslateMessage(&msg
);
11114 DispatchMessage(&msg
);
11116 ok_sequence(wm_popup_menu_1
, "popup menu command", FALSE
);
11118 /* Alt+F, Right, Enter */
11119 trace("testing submenu of a popup menu command\n");
11121 keybd_event(VK_MENU
, 0, 0, 0);
11122 keybd_event('F', 0, 0, 0);
11123 keybd_event('F', 0, KEYEVENTF_KEYUP
, 0);
11124 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
11125 keybd_event(VK_RIGHT
, 0, 0, 0);
11126 keybd_event(VK_RIGHT
, 0, KEYEVENTF_KEYUP
, 0);
11127 keybd_event(VK_RETURN
, 0, 0, 0);
11128 keybd_event(VK_RETURN
, 0, KEYEVENTF_KEYUP
, 0);
11129 while (PeekMessage(&msg
, 0, 0, 0, PM_REMOVE
))
11131 TranslateMessage(&msg
);
11132 DispatchMessage(&msg
);
11134 ok_sequence(wm_popup_menu_2
, "submenu of a popup menu command", FALSE
);
11136 set_menu_style(hmenu
, 0);
11137 style
= get_menu_style(hmenu
);
11138 ok(style
== 0, "expected 0, got %u\n", style
);
11140 hmenu_popup
= GetSubMenu(hmenu
, 0);
11141 ok(hmenu_popup
!= 0, "GetSubMenu returned 0 for submenu 0\n");
11142 set_menu_style(hmenu_popup
, MNS_NOTIFYBYPOS
);
11143 style
= get_menu_style(hmenu_popup
);
11144 ok(style
== MNS_NOTIFYBYPOS
, "expected MNS_NOTIFYBYPOS, got %u\n", style
);
11146 hmenu_popup
= GetSubMenu(hmenu_popup
, 0);
11147 ok(hmenu_popup
!= 0, "GetSubMenu returned 0 for submenu 0\n");
11148 style
= get_menu_style(hmenu_popup
);
11149 ok(style
== 0, "expected 0, got %u\n", style
);
11151 /* Alt+F, Right, Enter */
11152 trace("testing submenu of a popup menu command\n");
11154 keybd_event(VK_MENU
, 0, 0, 0);
11155 keybd_event('F', 0, 0, 0);
11156 keybd_event('F', 0, KEYEVENTF_KEYUP
, 0);
11157 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
11158 keybd_event(VK_RIGHT
, 0, 0, 0);
11159 keybd_event(VK_RIGHT
, 0, KEYEVENTF_KEYUP
, 0);
11160 keybd_event(VK_RETURN
, 0, 0, 0);
11161 keybd_event(VK_RETURN
, 0, KEYEVENTF_KEYUP
, 0);
11162 while (PeekMessage(&msg
, 0, 0, 0, PM_REMOVE
))
11164 TranslateMessage(&msg
);
11165 DispatchMessage(&msg
);
11167 ok_sequence(wm_popup_menu_3
, "submenu of a popup menu command", FALSE
);
11169 DestroyWindow(hwnd
);
11170 DestroyMenu(hmenu
);
11174 static void test_paintingloop(void)
11178 paint_loop_done
= 0;
11179 hwnd
= CreateWindowExA(0x0,"PaintLoopWindowClass",
11180 "PaintLoopWindowClass",WS_OVERLAPPEDWINDOW
,
11181 100, 100, 100, 100, 0, 0, 0, NULL
);
11182 ok(hwnd
!= 0, "PaintLoop window error %u\n", GetLastError());
11183 ShowWindow(hwnd
,SW_NORMAL
);
11186 while (!paint_loop_done
)
11189 if (PeekMessageA(&msg
, 0, 0, 0, 1))
11191 TranslateMessage(&msg
);
11192 DispatchMessage(&msg
);
11195 DestroyWindow(hwnd
);
11201 FARPROC pIsWinEventHookInstalled
= 0;/*GetProcAddress(user32, "IsWinEventHookInstalled");*/
11205 if (!RegisterWindowClasses()) assert(0);
11207 if (pSetWinEventHook
)
11209 hEvent_hook
= (HWINEVENTHOOK
)pSetWinEventHook(EVENT_MIN
, EVENT_MAX
,
11210 GetModuleHandleA(0),
11213 GetCurrentThreadId(),
11214 WINEVENT_INCONTEXT
);
11215 assert(hEvent_hook
);
11217 if (pIsWinEventHookInstalled
)
11220 for (event
= EVENT_MIN
; event
<= EVENT_MAX
; event
++)
11221 ok(pIsWinEventHookInstalled(event
), "IsWinEventHookInstalled(%u) failed\n", event
);
11225 cbt_hook_thread_id
= GetCurrentThreadId();
11226 hCBT_hook
= SetWindowsHookExA(WH_CBT
, cbt_hook_proc
, 0, GetCurrentThreadId());
11231 /* Fix message sequences before removing 4 lines below */
11233 if (pUnhookWinEvent
&& hEvent_hook
)
11235 ret
= pUnhookWinEvent(hEvent_hook
);
11236 ok( ret
, "UnhookWinEvent error %d\n", GetLastError());
11237 pUnhookWinEvent
= 0;
11243 test_PeekMessage();
11244 test_PeekMessage2();
11245 test_scrollwindowex();
11247 test_setwindowpos();
11249 invisible_parent_tests();
11250 test_mdi_messages();
11251 test_button_messages();
11252 test_static_messages();
11253 test_listbox_messages();
11254 test_combobox_messages();
11255 test_wmime_keydown_message();
11256 test_paint_messages();
11257 test_interthread_messages();
11258 test_message_conversion();
11259 test_accelerators();
11261 test_timers_no_wnd();
11263 test_DestroyWindow();
11264 test_DispatchMessage();
11265 test_SendMessageTimeout();
11266 test_edit_messages();
11267 test_quit_message();
11268 test_SetActiveWindow();
11270 if (!pTrackMouseEvent
)
11271 skip("TrackMouseEvent is not available\n");
11273 test_TrackMouseEvent();
11275 test_SetWindowRgn();
11277 test_dialog_messages();
11278 test_nullCallback();
11279 test_dbcs_wm_char();
11280 test_menu_messages();
11281 test_paintingloop();
11282 /* keep it the last test, under Windows it tends to break the tests
11283 * which rely on active/foreground windows being correct.
11285 test_SetForegroundWindow();
11287 UnhookWindowsHookEx(hCBT_hook
);
11288 if (pUnhookWinEvent
)
11290 ret
= pUnhookWinEvent(hEvent_hook
);
11291 ok( ret
, "UnhookWinEvent error %d\n", GetLastError());
11292 SetLastError(0xdeadbeef);
11293 ok(!pUnhookWinEvent(hEvent_hook
), "UnhookWinEvent succeeded\n");
11294 ok(GetLastError() == ERROR_INVALID_HANDLE
|| /* Win2k */
11295 GetLastError() == 0xdeadbeef, /* Win9x */
11296 "unexpected error %d\n", GetLastError());
11299 skip("UnhookWinEvent is not available\n");