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_NCPAINT
, sent
|wparam
|optional
, 1 },
160 { WM_GETTEXT
, sent
|defwinproc
|optional
},
161 { WM_ERASEBKGND
, sent
|optional
},
162 /* Win9x adds SWP_NOZORDER below */
163 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
164 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
165 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
166 { WM_ERASEBKGND
, sent
|optional
},
167 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
168 { WM_PAINT
, sent
|optional
},
169 { WM_NCPAINT
, sent
|beginpaint
|optional
},
170 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
173 /* SetWindowPos(SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE)
174 * for a visible overlapped window.
176 static const struct message WmSWP_HideOverlappedSeq
[] = {
177 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
178 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
179 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
183 /* SetWindowPos(SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOMOVE)
184 * for a visible overlapped window.
186 static const struct message WmSWP_ResizeSeq
[] = {
187 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
},
188 { WM_GETMINMAXINFO
, sent
|defwinproc
},
189 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
190 { WM_NCPAINT
, sent
|optional
},
191 { WM_GETTEXT
, sent
|defwinproc
|optional
},
192 { WM_ERASEBKGND
, sent
|optional
},
193 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
},
194 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
195 { WM_NCCALCSIZE
, sent
|wparam
|optional
, TRUE
},
196 { WM_NCPAINT
, sent
|optional
},
197 { WM_GETTEXT
, sent
|defwinproc
|optional
},
198 { WM_ERASEBKGND
, sent
|optional
},
199 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
200 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* XP sends a duplicate */
204 /* SetWindowPos(SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOMOVE)
205 * for a visible popup window.
207 static const struct message WmSWP_ResizePopupSeq
[] = {
208 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
},
209 { WM_GETMINMAXINFO
, sent
|defwinproc
|optional
}, /* Win9x */
210 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
211 { WM_NCPAINT
, sent
|optional
},
212 { WM_GETTEXT
, sent
|defwinproc
|optional
},
213 { WM_ERASEBKGND
, sent
|optional
},
214 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
},
215 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
216 { WM_NCCALCSIZE
, sent
|wparam
|optional
, TRUE
},
217 { WM_NCPAINT
, sent
|optional
},
218 { WM_GETTEXT
, sent
|defwinproc
|optional
},
219 { WM_ERASEBKGND
, sent
|optional
},
220 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
224 /* SetWindowPos(SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOSIZE)
225 * for a visible overlapped window.
227 static const struct message WmSWP_MoveSeq
[] = {
228 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOSIZE
},
229 { WM_NCPAINT
, sent
|optional
},
230 { WM_GETTEXT
, sent
|defwinproc
|optional
},
231 { WM_ERASEBKGND
, sent
|optional
},
232 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOCLIENTSIZE
},
233 { WM_MOVE
, sent
|defwinproc
|wparam
, 0 },
234 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
237 /* Resize with SetWindowPos(SWP_NOZORDER)
238 * for a visible overlapped window
239 * SWP_NOZORDER is stripped by the logging code
241 static const struct message WmSWP_ResizeNoZOrder
[] = {
242 { WM_WINDOWPOSCHANGING
, sent
|wparam
, /*SWP_NOZORDER|*/SWP_NOACTIVATE
},
243 { WM_GETMINMAXINFO
, sent
|defwinproc
},
244 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
245 { WM_NCPAINT
, sent
},
246 { WM_GETTEXT
, sent
|defwinproc
|optional
},
247 { WM_ERASEBKGND
, sent
|optional
}, /* FIXME: remove optional once Wine is fixed */
248 { WM_WINDOWPOSCHANGED
, sent
|wparam
, /*SWP_NOZORDER|*/SWP_NOMOVE
|SWP_NOCLIENTMOVE
|SWP_NOACTIVATE
},
249 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
250 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 }, /* Win9x doesn't send it */
251 { WM_NCPAINT
, sent
|optional
}, /* Win9x doesn't send it */
252 { WM_GETTEXT
, sent
|defwinproc
|optional
}, /* Win9x doesn't send it */
253 { WM_ERASEBKGND
, sent
|optional
}, /* Win9x doesn't send it */
254 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
255 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
259 /* Switch visible mdi children */
260 static const struct message WmSwitchChild
[] = {
261 /* Switch MDI child */
262 { WM_MDIACTIVATE
, sent
},/* in the MDI client */
263 { WM_WINDOWPOSCHANGING
, sent
|wparam
,SWP_NOSIZE
|SWP_NOMOVE
},/* in the 1st MDI child */
264 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
265 { WM_CHILDACTIVATE
, sent
},/* in the 1st MDI child */
266 /* Deactivate 2nd MDI child */
267 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 0 }, /* in the 2nd MDI child */
268 { WM_MDIACTIVATE
, sent
|defwinproc
}, /* in the 2nd MDI child */
269 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
270 /* Preparing for maximize and maximaze the 1st MDI child */
271 { WM_GETMINMAXINFO
, sent
|defwinproc
}, /* in the 1st MDI child */
272 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_STATECHANGED
}, /* in the 1st MDI child */
273 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 }, /* in the 1st MDI child */
274 { WM_CHILDACTIVATE
, sent
|defwinproc
}, /* in the 1st MDI child */
275 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
}, /* in the 1st MDI child */
276 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
}, /* in the 1st MDI child */
277 /* Lock redraw 2nd MDI child */
278 { WM_SETREDRAW
, sent
|wparam
|defwinproc
, 0 }, /* in the 2nd MDI child */
279 { HCBT_MINMAX
, hook
|lparam
, 0, SW_NORMALNA
},
280 /* Restore 2nd MDI child */
281 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_STATECHANGED
},/* in the 2nd MDI child */
282 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 },/* in the 2nd MDI child */
283 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* in the 2nd MDI child */
284 { 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 */
285 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
}, /* in the 2nd MDI child */
286 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* in the 2nd MDI child */
287 /* Redraw 2nd MDI child */
288 { WM_SETREDRAW
, sent
|wparam
|defwinproc
, 1 },/* in the 2nd MDI child */
289 /* Redraw MDI frame */
290 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
},/* in MDI frame */
291 { WM_NCCALCSIZE
, sent
|wparam
, 1 },/* in MDI frame */
292 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
}, /* in MDI frame */
293 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* in MDI frame */
294 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* in the 1st MDI child */
295 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
}, /* in the 1st MDI child */
296 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 }, /* in the 1st MDI child */
297 { HCBT_SETFOCUS
, hook
},
298 { WM_KILLFOCUS
, sent
|defwinproc
}, /* in the 2nd MDI child */
299 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 0 },/* in the 1st MDI child */
300 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
301 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
302 { WM_SETFOCUS
, sent
},/* in the MDI client */
303 { HCBT_SETFOCUS
, hook
},
304 { WM_KILLFOCUS
, sent
},/* in the MDI client */
305 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
306 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 }, /* in the 1st MDI child */
307 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
308 { WM_SETFOCUS
, sent
|defwinproc
}, /* in the 1st MDI child */
309 { WM_MDIACTIVATE
, sent
|defwinproc
},/* in the 1st MDI child */
310 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
}, /* in the 1st MDI child */
314 /* Switch visible not maximized mdi children */
315 static const struct message WmSwitchNotMaximizedChild
[] = {
316 /* Switch not maximized MDI child */
317 { WM_MDIACTIVATE
, sent
},/* in the MDI client */
318 { WM_WINDOWPOSCHANGING
, sent
|wparam
,SWP_NOSIZE
|SWP_NOMOVE
},/* in the 2nd MDI child */
319 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
320 { WM_CHILDACTIVATE
, sent
},/* in the 2nd MDI child */
321 /* Deactivate 1st MDI child */
322 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 0 }, /* in the 1st MDI child */
323 { WM_MDIACTIVATE
, sent
|defwinproc
}, /* in the 1st MDI child */
324 /* Activate 2nd MDI child */
325 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
}, /* in the 2nd MDI child */
326 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 }, /* in the 2nd MDI child */
327 { HCBT_SETFOCUS
, hook
}, /* in the 1st MDI child */
328 { WM_KILLFOCUS
, sent
|defwinproc
}, /* in the 1st MDI child */
329 { WM_IME_SETCONTEXT
, sent
|defwinproc
|optional
}, /* in the 1st MDI child */
330 { WM_IME_SETCONTEXT
, sent
|optional
}, /* in the MDI client */
331 { WM_SETFOCUS
, sent
, 0 }, /* in the MDI client */
332 { HCBT_SETFOCUS
, hook
},
333 { WM_KILLFOCUS
, sent
}, /* in the MDI client */
334 { WM_IME_SETCONTEXT
, sent
|optional
}, /* in the MDI client */
335 { WM_IME_SETCONTEXT
, sent
|defwinproc
|optional
}, /* in the 1st MDI child */
336 { WM_SETFOCUS
, sent
|defwinproc
}, /* in the 2nd MDI child */
337 { WM_MDIACTIVATE
, sent
|defwinproc
}, /* in the 2nd MDI child */
338 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
}, /* in the 2nd MDI child */
343 /* SetWindowPos(SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|
344 SWP_NOZORDER|SWP_FRAMECHANGED)
345 * for a visible overlapped window with WS_CLIPCHILDREN style set.
347 static const struct message WmSWP_FrameChanged_clip
[] = {
348 { WM_WINDOWPOSCHANGING
, sent
|wparam
|parent
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
},
349 { WM_NCCALCSIZE
, sent
|wparam
|parent
, 1 },
350 { WM_NCPAINT
, sent
|parent
}, /* wparam != 1 */
351 { WM_GETTEXT
, sent
|parent
|defwinproc
|optional
},
352 { WM_ERASEBKGND
, sent
|parent
|optional
}, /* FIXME: remove optional once Wine is fixed */
353 { WM_NCPAINT
, sent
}, /* wparam != 1 */
354 { WM_ERASEBKGND
, sent
},
355 { WM_WINDOWPOSCHANGED
, sent
|wparam
|parent
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
356 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
360 /* SetWindowPos(SWP_NOSIZE|SWP_NOMOVE|SWP_DEFERERASE|SWP_NOACTIVATE|
361 SWP_NOZORDER|SWP_FRAMECHANGED)
362 * for a visible overlapped window.
364 static const struct message WmSWP_FrameChangedDeferErase
[] = {
365 { WM_WINDOWPOSCHANGING
, sent
|wparam
|parent
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_DEFERERASE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
},
366 { WM_NCCALCSIZE
, sent
|wparam
|parent
, 1 },
367 { WM_WINDOWPOSCHANGED
, sent
|wparam
|parent
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_DEFERERASE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
368 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
369 { WM_PAINT
, sent
|parent
},
370 { WM_NCPAINT
, sent
|beginpaint
|parent
}, /* wparam != 1 */
371 { WM_GETTEXT
, sent
|beginpaint
|parent
|defwinproc
|optional
},
373 { WM_NCPAINT
, sent
|beginpaint
}, /* wparam != 1 */
374 { WM_ERASEBKGND
, sent
|beginpaint
},
378 /* SetWindowPos(SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|
379 SWP_NOZORDER|SWP_FRAMECHANGED)
380 * for a visible overlapped window without WS_CLIPCHILDREN style set.
382 static const struct message WmSWP_FrameChanged_noclip
[] = {
383 { WM_WINDOWPOSCHANGING
, sent
|wparam
|parent
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
},
384 { WM_NCCALCSIZE
, sent
|wparam
|parent
, 1 },
385 { WM_NCPAINT
, sent
|parent
}, /* wparam != 1 */
386 { WM_GETTEXT
, sent
|parent
|defwinproc
|optional
},
387 { WM_ERASEBKGND
, sent
|parent
|optional
}, /* FIXME: remove optional once Wine is fixed */
388 { WM_WINDOWPOSCHANGED
, sent
|wparam
|parent
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
389 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
391 { WM_NCPAINT
, sent
|beginpaint
}, /* wparam != 1 */
392 { WM_ERASEBKGND
, sent
|beginpaint
},
396 /* ShowWindow(SW_SHOW) for a not visible overlapped window */
397 static const struct message WmShowOverlappedSeq
[] = {
398 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
399 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
400 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
401 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
402 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
403 { WM_GETTEXT
, sent
|defwinproc
|optional
},
404 { WM_ERASEBKGND
, sent
|optional
},
405 { HCBT_ACTIVATE
, hook
},
406 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
407 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
408 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
409 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
410 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
411 { WM_NCACTIVATE
, sent
|wparam
, 1 },
412 { WM_GETTEXT
, sent
|defwinproc
|optional
},
413 { WM_ACTIVATE
, sent
|wparam
, 1 },
414 { HCBT_SETFOCUS
, hook
},
415 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
416 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
417 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
418 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
419 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
420 { WM_GETTEXT
, sent
|defwinproc
|optional
},
421 { WM_ERASEBKGND
, sent
|optional
},
422 /* Win9x adds SWP_NOZORDER below */
423 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
424 { WM_NCCALCSIZE
, sent
|optional
},
425 { WM_NCPAINT
, sent
|optional
},
426 { WM_ERASEBKGND
, sent
|optional
},
427 #if 0 /* CreateWindow/ShowWindow(SW_SHOW) also generates WM_SIZE/WM_MOVE
428 * messages. Does that mean that CreateWindow doesn't set initial
429 * window dimensions for overlapped windows?
434 { WM_PAINT
, sent
|optional
},
435 { WM_NCPAINT
, sent
|beginpaint
|optional
},
438 /* ShowWindow(SW_SHOWMAXIMIZED) for a not visible overlapped window */
439 static const struct message WmShowMaxOverlappedSeq
[] = {
440 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
441 { WM_GETMINMAXINFO
, sent
},
442 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_STATECHANGED
},
443 { WM_GETMINMAXINFO
, sent
|defwinproc
},
444 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
445 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
446 { HCBT_ACTIVATE
, hook
},
447 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
448 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
449 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
450 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
451 { WM_NCACTIVATE
, sent
|wparam
, 1 },
452 { WM_GETTEXT
, sent
|defwinproc
|optional
},
453 { WM_ACTIVATE
, sent
|wparam
, 1 },
454 { HCBT_SETFOCUS
, hook
},
455 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
456 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
457 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
458 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
459 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
460 { WM_GETTEXT
, sent
|defwinproc
|optional
},
461 { WM_ERASEBKGND
, sent
|optional
},
462 /* Win9x adds SWP_NOZORDER below */
463 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_STATECHANGED
},
464 { WM_MOVE
, sent
|defwinproc
},
465 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
466 { WM_NCCALCSIZE
, sent
|optional
},
467 { WM_NCPAINT
, sent
|optional
},
468 { WM_ERASEBKGND
, sent
|optional
},
469 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
470 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
471 { WM_PAINT
, sent
|optional
},
472 { WM_NCPAINT
, sent
|beginpaint
|optional
},
473 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
476 /* ShowWindow(SW_RESTORE) for a not visible maximized overlapped window */
477 static const struct message WmShowRestoreMaxOverlappedSeq
[] = {
478 { HCBT_MINMAX
, hook
|lparam
, 0, SW_RESTORE
},
479 { WM_GETTEXT
, sent
|optional
},
480 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
481 { WM_GETMINMAXINFO
, sent
|defwinproc
},
482 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
483 { WM_NCPAINT
, sent
|optional
},
484 { WM_GETTEXT
, sent
|defwinproc
|optional
},
485 { WM_ERASEBKGND
, sent
|optional
},
486 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
487 { WM_MOVE
, sent
|defwinproc
|optional
},
488 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
489 { WM_NCCALCSIZE
, sent
|wparam
|optional
, TRUE
},
490 { WM_NCPAINT
, sent
|optional
},
491 { WM_ERASEBKGND
, sent
|optional
},
492 { WM_PAINT
, sent
|optional
},
493 { WM_NCPAINT
, sent
|beginpaint
|optional
},
494 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
497 /* ShowWindow(SW_RESTORE) for a not visible minimized overlapped window */
498 static const struct message WmShowRestoreMinOverlappedSeq
[] = {
499 { HCBT_MINMAX
, hook
|lparam
, 0, SW_RESTORE
},
500 { WM_QUERYOPEN
, sent
|optional
},
501 { WM_GETTEXT
, sent
|optional
},
502 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
|SWP_NOCOPYBITS
},
503 { WM_GETMINMAXINFO
, sent
|defwinproc
},
504 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
505 { HCBT_ACTIVATE
, hook
},
506 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
507 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
508 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
509 { WM_NCACTIVATE
, sent
|wparam
, 1 },
510 { WM_GETTEXT
, sent
|defwinproc
|optional
},
511 { WM_ACTIVATE
, sent
|wparam
, 1 },
512 { HCBT_SETFOCUS
, hook
},
513 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
514 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
515 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
516 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
517 { WM_GETTEXT
, sent
|defwinproc
|optional
},
518 { WM_ERASEBKGND
, sent
},
519 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_STATECHANGED
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
},
520 { WM_MOVE
, sent
|defwinproc
},
521 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
522 { WM_NCCALCSIZE
, sent
|wparam
|optional
, TRUE
},
523 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
524 { WM_ERASEBKGND
, sent
|optional
},
525 { WM_ACTIVATE
, sent
|wparam
, 1 },
526 { WM_PAINT
, sent
|optional
},
527 { WM_NCPAINT
, sent
|beginpaint
|optional
},
528 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
531 /* ShowWindow(SW_SHOWMINIMIZED) for a not visible overlapped window */
532 static const struct message WmShowMinOverlappedSeq
[] = {
533 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
534 { HCBT_SETFOCUS
, hook
},
535 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
536 { WM_KILLFOCUS
, sent
},
537 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
538 { WM_IME_NOTIFY
, sent
|wparam
|optional
|defwinproc
, 1 },
539 { WM_GETTEXT
, sent
|optional
},
540 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOCOPYBITS
|SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_STATECHANGED
},
541 { WM_GETMINMAXINFO
, sent
|defwinproc
},
542 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
543 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
544 { WM_NCPAINT
, sent
|optional
},
545 { WM_GETTEXT
, sent
|defwinproc
|optional
},
546 { WM_WINDOWPOSCHANGED
, sent
},
547 { WM_MOVE
, sent
|defwinproc
},
548 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MINIMIZED
},
549 { WM_NCCALCSIZE
, sent
|optional
},
550 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
551 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
552 { EVENT_SYSTEM_MINIMIZESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
553 { WM_NCACTIVATE
, sent
|wparam
, 0 },
554 { WM_GETTEXT
, sent
|defwinproc
|optional
},
555 { WM_ACTIVATE
, sent
},
556 { WM_ACTIVATEAPP
, sent
|wparam
, 0 },
557 { WM_PAINT
, sent
|optional
},
558 { WM_NCPAINT
, sent
|beginpaint
|optional
},
559 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
562 /* ShowWindow(SW_HIDE) for a visible overlapped window */
563 static const struct message WmHideOverlappedSeq
[] = {
564 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
565 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
566 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
567 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
568 { WM_SIZE
, sent
|optional
}, /* XP doesn't send it */
569 { WM_MOVE
, sent
|optional
}, /* XP doesn't send it */
570 { WM_NCACTIVATE
, sent
|wparam
, 0 },
571 { WM_ACTIVATE
, sent
|wparam
, 0 },
572 { WM_ACTIVATEAPP
, sent
|wparam
, 0 },
573 { WM_KILLFOCUS
, sent
|wparam
, 0 },
574 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
575 { WM_IME_NOTIFY
, sent
|wparam
|optional
|defwinproc
, 1 },
578 /* DestroyWindow for a visible overlapped window */
579 static const struct message WmDestroyOverlappedSeq
[] = {
580 { HCBT_DESTROYWND
, hook
},
581 { 0x0090, sent
|optional
},
582 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
583 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
584 { 0x0090, sent
|optional
},
585 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
586 { WM_NCACTIVATE
, sent
|optional
|wparam
, 0 },
587 { WM_ACTIVATE
, sent
|optional
|wparam
, 0 },
588 { WM_ACTIVATEAPP
, sent
|optional
|wparam
, 0 },
589 { WM_KILLFOCUS
, sent
|optional
|wparam
, 0 },
590 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
591 { WM_IME_NOTIFY
, sent
|wparam
|optional
|defwinproc
, 1 },
592 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
593 { WM_DESTROY
, sent
},
594 { WM_NCDESTROY
, sent
},
597 /* CreateWindow(WS_MAXIMIZE|WS_VISIBLE) for popup window */
598 static const struct message WmCreateMaxPopupSeq
[] = {
599 { HCBT_CREATEWND
, hook
},
600 { WM_NCCREATE
, sent
},
601 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
603 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
604 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
606 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
607 { WM_GETMINMAXINFO
, sent
},
608 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_STATECHANGED
},
609 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
610 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOREDRAW
|SWP_STATECHANGED
},
611 { WM_MOVE
, sent
|defwinproc
},
612 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
613 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
614 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
615 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
616 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
617 { HCBT_ACTIVATE
, hook
},
618 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
619 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
620 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
621 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
622 { WM_NCACTIVATE
, sent
|wparam
, 1 },
623 { WM_ACTIVATE
, sent
|wparam
, 1 },
624 { HCBT_SETFOCUS
, hook
},
625 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
626 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
627 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
628 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
629 { WM_SYNCPAINT
, sent
|wparam
|optional
, 4 },
630 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
631 { WM_ERASEBKGND
, sent
|optional
},
632 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOCLIENTMOVE
|SWP_NOCLIENTSIZE
|SWP_SHOWWINDOW
|SWP_NOMOVE
|SWP_NOSIZE
},
635 /* CreateWindow(WS_MAXIMIZE) for popup window, not initially visible */
636 static const struct message WmCreateInvisibleMaxPopupSeq
[] = {
637 { HCBT_CREATEWND
, hook
},
638 { WM_NCCREATE
, sent
},
639 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
641 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
642 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
644 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
645 { WM_GETMINMAXINFO
, sent
},
646 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_STATECHANGED
},
647 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
648 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOREDRAW
|SWP_STATECHANGED
},
649 { WM_MOVE
, sent
|defwinproc
},
650 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
651 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
654 /* ShowWindow(SW_SHOWMAXIMIZED) for a resized not visible popup window */
655 static const struct message WmShowMaxPopupResizedSeq
[] = {
656 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
657 { WM_GETMINMAXINFO
, sent
},
658 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
},
659 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
660 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
661 { HCBT_ACTIVATE
, hook
},
662 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
663 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
664 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
665 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
666 { WM_NCACTIVATE
, sent
|wparam
, 1 },
667 { WM_ACTIVATE
, sent
|wparam
, 1 },
668 { HCBT_SETFOCUS
, hook
},
669 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
670 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
671 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
672 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
673 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
674 { WM_ERASEBKGND
, sent
|optional
},
675 { WM_WINDOWPOSCHANGED
, sent
},
676 /* WinNT4.0 sends WM_MOVE */
677 { WM_MOVE
, sent
|defwinproc
|optional
},
678 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
679 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
682 /* ShowWindow(SW_SHOWMAXIMIZED) for a not visible popup window */
683 static const struct message WmShowMaxPopupSeq
[] = {
684 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
685 { WM_GETMINMAXINFO
, sent
},
686 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
},
687 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
688 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
689 { HCBT_ACTIVATE
, hook
},
690 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
691 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
692 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
693 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
694 { WM_NCACTIVATE
, sent
|wparam
, 1 },
695 { WM_ACTIVATE
, sent
|wparam
, 1 },
696 { HCBT_SETFOCUS
, hook
},
697 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
698 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
699 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
700 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
701 { WM_SYNCPAINT
, sent
|wparam
|optional
, 4 },
702 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
703 { WM_ERASEBKGND
, sent
|optional
},
704 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOMOVE
|SWP_NOSIZE
},
705 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
708 /* CreateWindow(WS_VISIBLE) for popup window */
709 static const struct message WmCreatePopupSeq
[] = {
710 { HCBT_CREATEWND
, hook
},
711 { WM_NCCREATE
, sent
},
712 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
714 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
715 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
717 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
718 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
719 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
720 { HCBT_ACTIVATE
, hook
},
721 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
722 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
723 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
724 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
725 { WM_ERASEBKGND
, sent
|optional
},
726 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
727 { WM_NCACTIVATE
, sent
|wparam
, 1 },
728 { WM_ACTIVATE
, sent
|wparam
, 1 },
729 { HCBT_SETFOCUS
, hook
},
730 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
731 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
732 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
733 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
734 { WM_SYNCPAINT
, sent
|wparam
|optional
, 4 },
735 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
736 { WM_ERASEBKGND
, sent
|optional
},
737 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOCLIENTMOVE
|SWP_NOCLIENTSIZE
|SWP_SHOWWINDOW
|SWP_NOMOVE
|SWP_NOSIZE
},
740 /* ShowWindow(SW_SHOWMAXIMIZED) for a visible popup window */
741 static const struct message WmShowVisMaxPopupSeq
[] = {
742 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
743 { WM_GETMINMAXINFO
, sent
},
744 { WM_GETTEXT
, sent
|optional
},
745 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
746 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
747 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
748 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
749 { WM_ERASEBKGND
, sent
|optional
},
750 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
751 { WM_MOVE
, sent
|defwinproc
},
752 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
753 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
756 /* CreateWindow (for a child popup window, not initially visible) */
757 static const struct message WmCreateChildPopupSeq
[] = {
758 { HCBT_CREATEWND
, hook
},
759 { WM_NCCREATE
, sent
},
760 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
762 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
763 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
767 /* CreateWindow (for a popup window, not initially visible,
768 * which sets WS_VISIBLE in WM_CREATE handler)
770 static const struct message WmCreateInvisiblePopupSeq
[] = {
771 { HCBT_CREATEWND
, hook
},
772 { WM_NCCREATE
, sent
},
773 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
775 { WM_STYLECHANGING
, sent
},
776 { WM_STYLECHANGED
, sent
},
777 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
778 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
782 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER)
783 * for a popup window with WS_VISIBLE style set
785 static const struct message WmShowVisiblePopupSeq_2
[] = {
786 { WM_WINDOWPOSCHANGING
, sent
|wparam
, 0 },
789 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
790 * for a popup window with WS_VISIBLE style set
792 static const struct message WmShowVisiblePopupSeq_3
[] = {
793 { WM_WINDOWPOSCHANGING
, sent
|wparam
, 0 },
794 { HCBT_ACTIVATE
, hook
},
795 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
796 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
797 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, 0 },
798 { WM_NCACTIVATE
, sent
|wparam
, 1 },
799 { WM_ACTIVATE
, sent
|wparam
, 1 },
800 { HCBT_SETFOCUS
, hook
},
801 { WM_KILLFOCUS
, sent
|parent
},
802 { WM_IME_SETCONTEXT
, sent
|parent
|wparam
|optional
, 0 },
803 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
804 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
805 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
806 { WM_SETFOCUS
, sent
|defwinproc
},
809 /* CreateWindow (for child window, not initially visible) */
810 static const struct message WmCreateChildSeq
[] = {
811 { HCBT_CREATEWND
, hook
},
812 { WM_NCCREATE
, sent
},
813 /* child is inserted into parent's child list after WM_NCCREATE returns */
814 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
816 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
817 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
819 { WM_PARENTNOTIFY
, sent
|parent
|wparam
, WM_CREATE
},
822 /* CreateWindow (for maximized child window, not initially visible) */
823 static const struct message WmCreateMaximizedChildSeq
[] = {
824 { HCBT_CREATEWND
, hook
},
825 { WM_NCCREATE
, sent
},
826 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
828 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
829 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
831 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
832 { WM_GETMINMAXINFO
, sent
},
833 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_STATECHANGED
},
834 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
835 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
836 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
837 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
838 { WM_PARENTNOTIFY
, sent
|parent
|wparam
, WM_CREATE
},
841 /* CreateWindow (for a child window, initially visible) */
842 static const struct message WmCreateVisibleChildSeq
[] = {
843 { HCBT_CREATEWND
, hook
},
844 { WM_NCCREATE
, sent
},
845 /* child is inserted into parent's child list after WM_NCCREATE returns */
846 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
847 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
849 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
850 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
852 { WM_PARENTNOTIFY
, sent
|parent
|wparam
, WM_CREATE
},
853 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
854 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
855 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
856 { WM_ERASEBKGND
, sent
|parent
|optional
},
857 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
858 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 }, /* WinXP */
859 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
862 /* ShowWindow(SW_SHOW) for a not visible child window */
863 static const struct message WmShowChildSeq
[] = {
864 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
865 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
866 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
867 { WM_ERASEBKGND
, sent
|parent
|optional
},
868 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
871 /* ShowWindow(SW_HIDE) for a visible child window */
872 static const struct message WmHideChildSeq
[] = {
873 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
874 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
875 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
876 { WM_ERASEBKGND
, sent
|parent
|optional
},
877 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
880 /* ShowWindow(SW_HIDE) for a visible child window checking all parent events*/
881 static const struct message WmHideChildSeq2
[] = {
882 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
883 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
884 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
885 { WM_ERASEBKGND
, sent
|parent
},
886 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
889 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
890 * for a not visible child window
892 static const struct message WmShowChildSeq_2
[] = {
893 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
894 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
895 { WM_CHILDACTIVATE
, sent
},
896 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
899 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE)
900 * for a not visible child window
902 static const struct message WmShowChildSeq_3
[] = {
903 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
904 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
905 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
908 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
909 * for a visible child window with a caption
911 static const struct message WmShowChildSeq_4
[] = {
912 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
913 { WM_CHILDACTIVATE
, sent
},
916 /* ShowWindow(SW_MINIMIZE) for child with invisible parent */
917 static const struct message WmShowChildInvisibleParentSeq_1
[] = {
918 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
919 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
920 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
921 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
922 { WM_CHILDACTIVATE
, sent
|optional
},
923 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOREDRAW
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
924 { WM_MOVE
, sent
|defwinproc
},
925 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MINIMIZED
},
926 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
927 { EVENT_SYSTEM_MINIMIZESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
928 /* FIXME: Wine creates an icon/title window while Windows doesn't */
929 { WM_PARENTNOTIFY
, sent
|parent
|wparam
|optional
, WM_CREATE
},
930 { WM_GETTEXT
, sent
|optional
},
933 /* repeated ShowWindow(SW_MINIMIZE) for child with invisible parent */
934 static const struct message WmShowChildInvisibleParentSeq_1r
[] = {
935 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
938 /* ShowWindow(SW_MAXIMIZE) for child with invisible parent */
939 static const struct message WmShowChildInvisibleParentSeq_2
[] = {
940 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
941 { WM_GETMINMAXINFO
, sent
},
942 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_STATECHANGED
},
943 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
944 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
945 { WM_CHILDACTIVATE
, sent
},
946 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
947 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
948 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
951 /* repeated ShowWindow(SW_MAXIMIZE) for child with invisible parent */
952 static const struct message WmShowChildInvisibleParentSeq_2r
[] = {
953 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
956 /* ShowWindow(SW_SHOWMINIMIZED) for child with invisible parent */
957 static const struct message WmShowChildInvisibleParentSeq_3
[] = {
958 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINIMIZED
},
959 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
960 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
961 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
962 { WM_CHILDACTIVATE
, sent
},
963 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOREDRAW
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
964 { WM_MOVE
, sent
|defwinproc
},
965 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MINIMIZED
},
966 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
967 { EVENT_SYSTEM_MINIMIZESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
968 /* FIXME: Wine creates an icon/title window while Windows doesn't */
969 { WM_PARENTNOTIFY
, sent
|parent
|wparam
|optional
, WM_CREATE
},
970 { WM_GETTEXT
, sent
|optional
},
973 /* repeated ShowWindow(SW_SHOWMINIMIZED) for child with invisible parent */
974 static const struct message WmShowChildInvisibleParentSeq_3r
[] = {
975 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINIMIZED
},
978 /* ShowWindow(SW_SHOWMINNOACTIVE) for child with invisible parent */
979 static const struct message WmShowChildInvisibleParentSeq_4
[] = {
980 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINNOACTIVE
},
981 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
982 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
983 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
984 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOREDRAW
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
985 { WM_MOVE
, sent
|defwinproc
},
986 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MINIMIZED
},
987 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
988 { EVENT_SYSTEM_MINIMIZESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
989 /* FIXME: Wine creates an icon/title window while Windows doesn't */
990 { WM_PARENTNOTIFY
, sent
|parent
|wparam
|optional
, WM_CREATE
},
991 { WM_GETTEXT
, sent
|optional
},
994 /* repeated ShowWindow(SW_SHOWMINNOACTIVE) for child with invisible parent */
995 static const struct message WmShowChildInvisibleParentSeq_4r
[] = {
996 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINNOACTIVE
},
999 /* ShowWindow(SW_SHOW) for child with invisible parent */
1000 static const struct message WmShowChildInvisibleParentSeq_5
[] = {
1001 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1004 /* ShowWindow(SW_HIDE) for child with invisible parent */
1005 static const struct message WmHideChildInvisibleParentSeq
[] = {
1006 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
1009 /* SetWindowPos(SWP_SHOWWINDOW) for child with invisible parent */
1010 static const struct message WmShowChildInvisibleParentSeq_6
[] = {
1011 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
1012 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1013 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1016 /* SetWindowPos(SWP_HIDEWINDOW) for child with invisible parent */
1017 static const struct message WmHideChildInvisibleParentSeq_2
[] = {
1018 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1019 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1020 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1023 /* DestroyWindow for a visible child window */
1024 static const struct message WmDestroyChildSeq
[] = {
1025 { HCBT_DESTROYWND
, hook
},
1026 { 0x0090, sent
|optional
},
1027 { WM_PARENTNOTIFY
, sent
|parent
|wparam
, WM_DESTROY
},
1028 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
1029 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1030 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1031 { WM_ERASEBKGND
, sent
|parent
|optional
},
1032 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1033 { HCBT_SETFOCUS
, hook
}, /* set focus to a parent */
1034 { WM_KILLFOCUS
, sent
},
1035 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
1036 { WM_IME_SETCONTEXT
, sent
|wparam
|parent
|optional
, 1 },
1037 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1038 { WM_SETFOCUS
, sent
|parent
},
1039 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
1040 { WM_DESTROY
, sent
},
1041 { WM_DESTROY
, sent
|optional
}, /* some other (IME?) window */
1042 { WM_NCDESTROY
, sent
|optional
}, /* some other (IME?) window */
1043 { WM_NCDESTROY
, sent
},
1046 /* DestroyWindow for a visible child window with invisible parent */
1047 static const struct message WmDestroyInvisibleChildSeq
[] = {
1048 { HCBT_DESTROYWND
, hook
},
1049 { 0x0090, sent
|optional
},
1050 { WM_PARENTNOTIFY
, sent
|parent
|wparam
, WM_DESTROY
},
1051 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
1052 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
1053 { WM_DESTROY
, sent
},
1054 { WM_NCDESTROY
, sent
},
1057 /* Moving the mouse in nonclient area */
1058 static const struct message WmMouseMoveInNonClientAreaSeq
[] = { /* FIXME: add */
1059 { WM_NCHITTEST
, sent
},
1060 { WM_SETCURSOR
, sent
},
1061 { WM_NCMOUSEMOVE
, posted
},
1064 /* Moving the mouse in client area */
1065 static const struct message WmMouseMoveInClientAreaSeq
[] = { /* FIXME: add */
1066 { WM_NCHITTEST
, sent
},
1067 { WM_SETCURSOR
, sent
},
1068 { WM_MOUSEMOVE
, posted
},
1071 /* Moving by dragging the title bar (after WM_NCHITTEST and WM_SETCURSOR) (outline move) */
1072 static const struct message WmDragTitleBarSeq
[] = { /* FIXME: add */
1073 { WM_NCLBUTTONDOWN
, sent
|wparam
, HTCAPTION
},
1074 { WM_SYSCOMMAND
, sent
|defwinproc
|wparam
, SC_MOVE
+2 },
1075 { WM_GETMINMAXINFO
, sent
|defwinproc
},
1076 { WM_ENTERSIZEMOVE
, sent
|defwinproc
},
1077 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, 0 },
1078 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, 0 },
1079 { WM_MOVE
, sent
|defwinproc
},
1080 { WM_EXITSIZEMOVE
, sent
|defwinproc
},
1083 /* Sizing by dragging the thick borders (after WM_NCHITTEST and WM_SETCURSOR) (outline move) */
1084 static const struct message WmDragThickBordersBarSeq
[] = { /* FIXME: add */
1085 { WM_NCLBUTTONDOWN
, sent
|wparam
, 0xd },
1086 { WM_SYSCOMMAND
, sent
|defwinproc
|wparam
, 0xf004 },
1087 { WM_GETMINMAXINFO
, sent
|defwinproc
},
1088 { WM_ENTERSIZEMOVE
, sent
|defwinproc
},
1089 { WM_SIZING
, sent
|defwinproc
|wparam
, 4}, /* one for each mouse movement */
1090 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, 0 },
1091 { WM_GETMINMAXINFO
, sent
|defwinproc
},
1092 { WM_NCCALCSIZE
, sent
|defwinproc
|wparam
, 1 },
1093 { WM_NCPAINT
, sent
|defwinproc
|wparam
, 1 },
1094 { WM_GETTEXT
, sent
|defwinproc
},
1095 { WM_ERASEBKGND
, sent
|defwinproc
},
1096 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, 0 },
1097 { WM_MOVE
, sent
|defwinproc
},
1098 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
1099 { WM_EXITSIZEMOVE
, sent
|defwinproc
},
1102 /* Resizing child window with MoveWindow (32) */
1103 static const struct message WmResizingChildWithMoveWindowSeq
[] = {
1104 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
1105 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1106 { WM_ERASEBKGND
, sent
|parent
|optional
},
1107 { WM_ERASEBKGND
, sent
|optional
},
1108 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
},
1109 { WM_MOVE
, sent
|defwinproc
},
1110 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
1111 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1114 /* Clicking on inactive button */
1115 static const struct message WmClickInactiveButtonSeq
[] = { /* FIXME: add */
1116 { WM_NCHITTEST
, sent
},
1117 { WM_PARENTNOTIFY
, sent
|parent
|wparam
, WM_LBUTTONDOWN
},
1118 { WM_MOUSEACTIVATE
, sent
},
1119 { WM_MOUSEACTIVATE
, sent
|parent
|defwinproc
},
1120 { WM_SETCURSOR
, sent
},
1121 { WM_SETCURSOR
, sent
|parent
|defwinproc
},
1122 { WM_LBUTTONDOWN
, posted
},
1123 { WM_KILLFOCUS
, posted
|parent
},
1124 { WM_SETFOCUS
, posted
},
1125 { WM_CTLCOLORBTN
, posted
|parent
},
1126 { BM_SETSTATE
, posted
},
1127 { WM_CTLCOLORBTN
, posted
|parent
},
1128 { WM_LBUTTONUP
, posted
},
1129 { BM_SETSTATE
, posted
},
1130 { WM_CTLCOLORBTN
, posted
|parent
},
1131 { WM_COMMAND
, posted
|parent
},
1134 /* Reparenting a button (16/32) */
1135 /* The last child (button) reparented gets topmost for its new parent. */
1136 static const struct message WmReparentButtonSeq
[] = { /* FIXME: add */
1137 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
1138 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOSIZE
},
1139 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1140 { WM_ERASEBKGND
, sent
|parent
},
1141 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOSIZE
},
1142 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
},
1143 { WM_CHILDACTIVATE
, sent
},
1144 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOSIZE
|SWP_NOREDRAW
},
1145 { WM_MOVE
, sent
|defwinproc
},
1146 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1149 /* Creation of a custom dialog (32) */
1150 static const struct message WmCreateCustomDialogSeq
[] = {
1151 { HCBT_CREATEWND
, hook
},
1152 { WM_GETMINMAXINFO
, sent
},
1153 { WM_NCCREATE
, sent
},
1154 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
1155 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
1156 { WM_CREATE
, sent
},
1157 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1158 { WM_NOTIFYFORMAT
, sent
|optional
},
1159 { WM_QUERYUISTATE
, sent
|optional
},
1160 { WM_WINDOWPOSCHANGING
, sent
|optional
},
1161 { WM_GETMINMAXINFO
, sent
|optional
},
1162 { WM_NCCALCSIZE
, sent
|optional
},
1163 { WM_WINDOWPOSCHANGED
, sent
|optional
},
1164 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1165 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
1166 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1167 { HCBT_ACTIVATE
, hook
},
1168 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
1171 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
1173 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
1175 { WM_NCACTIVATE
, sent
|wparam
, 1 },
1176 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1177 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1178 { EVENT_OBJECT_DEFACTIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, OBJID_CLIENT
, 0 },
1179 { WM_ACTIVATE
, sent
|wparam
, 1 },
1180 { WM_KILLFOCUS
, sent
|parent
},
1181 { WM_IME_SETCONTEXT
, sent
|parent
|wparam
|optional
, 0 },
1182 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
1183 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
1184 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1185 { WM_SETFOCUS
, sent
},
1186 { WM_GETDLGCODE
, sent
|defwinproc
|wparam
, 0 },
1187 { WM_NCPAINT
, sent
|wparam
, 1 },
1188 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1189 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1190 { WM_ERASEBKGND
, sent
},
1191 { WM_CTLCOLORDLG
, sent
|defwinproc
},
1192 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1193 { WM_GETTEXT
, sent
|optional
},
1194 { WM_GETTEXT
, sent
|optional
},
1195 { WM_NCCALCSIZE
, sent
|optional
},
1196 { WM_NCPAINT
, sent
|optional
},
1197 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1198 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1199 { WM_ERASEBKGND
, sent
|optional
},
1200 { WM_CTLCOLORDLG
, sent
|optional
|defwinproc
},
1201 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1202 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
1206 /* Calling EndDialog for a custom dialog (32) */
1207 static const struct message WmEndCustomDialogSeq
[] = {
1208 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1209 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1210 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1211 { WM_GETTEXT
, sent
|optional
},
1212 { HCBT_ACTIVATE
, hook
},
1213 { WM_NCACTIVATE
, sent
|wparam
, 0 },
1214 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1215 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1216 { WM_ACTIVATE
, sent
|wparam
, 0 },
1217 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
1218 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1219 { HCBT_SETFOCUS
, hook
},
1220 { WM_KILLFOCUS
, sent
},
1221 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
1222 { WM_IME_SETCONTEXT
, sent
|parent
|wparam
|defwinproc
|optional
, 1 },
1223 { WM_IME_NOTIFY
, sent
|wparam
|optional
, 1 },
1224 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1225 { WM_SETFOCUS
, sent
|parent
|defwinproc
},
1228 /* ShowWindow(SW_SHOW) for a custom dialog (initially invisible) */
1229 static const struct message WmShowCustomDialogSeq
[] = {
1230 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1231 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
1232 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1233 { HCBT_ACTIVATE
, hook
},
1234 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
1236 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
1238 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
1239 { WM_ACTIVATEAPP
, sent
|wparam
|optional
, 1 },
1240 { WM_NCACTIVATE
, sent
|wparam
, 1 },
1241 { WM_ACTIVATE
, sent
|wparam
, 1 },
1243 { WM_KILLFOCUS
, sent
|parent
},
1244 { WM_IME_SETCONTEXT
, sent
|parent
|wparam
|optional
, 0 },
1245 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
1246 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
1247 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1248 { WM_SETFOCUS
, sent
},
1249 { WM_GETDLGCODE
, sent
|defwinproc
|wparam
, 0 },
1250 { WM_NCPAINT
, sent
|wparam
, 1 },
1251 { WM_ERASEBKGND
, sent
},
1252 { WM_CTLCOLORDLG
, sent
|defwinproc
},
1253 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1256 /* Creation and destruction of a modal dialog (32) */
1257 static const struct message WmModalDialogSeq
[] = {
1258 { WM_CANCELMODE
, sent
|parent
},
1259 { HCBT_SETFOCUS
, hook
},
1260 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1261 { WM_KILLFOCUS
, sent
|parent
},
1262 { WM_IME_SETCONTEXT
, sent
|parent
|wparam
|optional
, 0 },
1263 { EVENT_OBJECT_STATECHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1264 { WM_ENABLE
, sent
|parent
|wparam
, 0 },
1265 { HCBT_CREATEWND
, hook
},
1266 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
1267 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1268 { WM_SETFONT
, sent
},
1269 { WM_INITDIALOG
, sent
},
1270 { WM_CHANGEUISTATE
, sent
|optional
},
1271 { WM_UPDATEUISTATE
, sent
|optional
},
1272 { WM_SHOWWINDOW
, sent
},
1273 { HCBT_ACTIVATE
, hook
},
1274 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
1275 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
1276 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
},
1277 { WM_NCACTIVATE
, sent
|wparam
, 1 },
1278 { WM_GETTEXT
, sent
|optional
},
1279 { WM_ACTIVATE
, sent
|wparam
, 1 },
1280 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
1281 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1282 { WM_NCPAINT
, sent
},
1283 { WM_GETTEXT
, sent
|optional
},
1284 { WM_ERASEBKGND
, sent
},
1285 { WM_CTLCOLORDLG
, sent
},
1286 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1287 { WM_GETTEXT
, sent
|optional
},
1288 { WM_NCCALCSIZE
, sent
|optional
},
1289 { WM_NCPAINT
, sent
|optional
},
1290 { WM_GETTEXT
, sent
|optional
},
1291 { WM_ERASEBKGND
, sent
|optional
},
1292 { WM_CTLCOLORDLG
, sent
|optional
},
1293 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1294 { WM_PAINT
, sent
|optional
},
1295 { WM_CTLCOLORBTN
, sent
},
1296 { WM_ENTERIDLE
, sent
|parent
|optional
},
1297 { WM_ENTERIDLE
, sent
|parent
|optional
},
1298 { WM_ENTERIDLE
, sent
|parent
|optional
},
1299 { WM_ENTERIDLE
, sent
|parent
|optional
},
1300 { WM_ENTERIDLE
, sent
|parent
|optional
},
1301 { WM_ENTERIDLE
, sent
|parent
|optional
},
1302 { WM_ENTERIDLE
, sent
|parent
|optional
},
1303 { WM_ENTERIDLE
, sent
|parent
|optional
},
1304 { WM_ENTERIDLE
, sent
|parent
|optional
},
1305 { WM_ENTERIDLE
, sent
|parent
|optional
},
1306 { WM_ENTERIDLE
, sent
|parent
|optional
},
1307 { WM_ENTERIDLE
, sent
|parent
|optional
},
1308 { WM_ENTERIDLE
, sent
|parent
|optional
},
1309 { WM_ENTERIDLE
, sent
|parent
|optional
},
1310 { WM_ENTERIDLE
, sent
|parent
|optional
},
1311 { WM_ENTERIDLE
, sent
|parent
|optional
},
1312 { WM_ENTERIDLE
, sent
|parent
|optional
},
1313 { WM_ENTERIDLE
, sent
|parent
|optional
},
1314 { WM_ENTERIDLE
, sent
|parent
|optional
},
1315 { WM_ENTERIDLE
, sent
|parent
|optional
},
1317 { EVENT_OBJECT_STATECHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1318 { WM_ENABLE
, sent
|parent
|wparam
, 1 },
1319 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
1320 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1321 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1322 { WM_GETTEXT
, sent
|optional
},
1323 { HCBT_ACTIVATE
, hook
},
1324 { WM_NCACTIVATE
, sent
|wparam
, 0 },
1325 { WM_GETTEXT
, sent
|optional
},
1326 { WM_ACTIVATE
, sent
|wparam
, 0 },
1327 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
1328 { WM_WINDOWPOSCHANGING
, sent
|optional
},
1329 { WM_WINDOWPOSCHANGED
, sent
|optional
},
1330 { HCBT_SETFOCUS
, hook
},
1331 { WM_IME_SETCONTEXT
, sent
|parent
|wparam
|defwinproc
|optional
, 1 },
1332 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1333 { WM_SETFOCUS
, sent
|parent
|defwinproc
},
1334 { EVENT_SYSTEM_DIALOGEND
, winevent_hook
|wparam
|lparam
, 0, 0 },
1335 { HCBT_DESTROYWND
, hook
},
1336 { 0x0090, sent
|optional
},
1337 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
1338 { WM_DESTROY
, sent
},
1339 { WM_NCDESTROY
, sent
},
1342 /* Creation of a modal dialog that is resized inside WM_INITDIALOG (32) */
1343 static const struct message WmCreateModalDialogResizeSeq
[] = { /* FIXME: add */
1344 /* (inside dialog proc, handling WM_INITDIALOG) */
1345 { WM_WINDOWPOSCHANGING
, sent
|wparam
, 0 },
1346 { WM_NCCALCSIZE
, sent
},
1347 { WM_NCACTIVATE
, sent
|parent
|wparam
, 0 },
1348 { WM_GETTEXT
, sent
|defwinproc
},
1349 { WM_ACTIVATE
, sent
|parent
|wparam
, 0 },
1350 { WM_WINDOWPOSCHANGING
, sent
|wparam
, 0 },
1351 { WM_WINDOWPOSCHANGING
, sent
|parent
},
1352 { WM_NCACTIVATE
, sent
|wparam
, 1 },
1353 { WM_ACTIVATE
, sent
|wparam
, 1 },
1354 { WM_WINDOWPOSCHANGED
, sent
|wparam
, 0 },
1355 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
1356 /* (setting focus) */
1357 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1358 { WM_WINDOWPOSCHANGING
, sent
|wparam
, 0 },
1359 { WM_NCPAINT
, sent
},
1360 { WM_GETTEXT
, sent
|defwinproc
},
1361 { WM_ERASEBKGND
, sent
},
1362 { WM_CTLCOLORDLG
, sent
|defwinproc
},
1363 { WM_WINDOWPOSCHANGED
, sent
|wparam
, 0 },
1365 /* (bunch of WM_CTLCOLOR* for each control) */
1366 { WM_PAINT
, sent
|parent
},
1367 { WM_ENTERIDLE
, sent
|parent
|wparam
, 0 },
1368 { WM_SETCURSOR
, sent
|parent
},
1371 /* SetMenu for NonVisible windows with size change*/
1372 static const struct message WmSetMenuNonVisibleSizeChangeSeq
[] = {
1373 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1374 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1375 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
1376 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
},
1377 { WM_MOVE
, sent
|defwinproc
},
1378 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
1379 { WM_NCCALCSIZE
,sent
|wparam
|optional
, 1 }, /* XP */
1380 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1381 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* XP sends a duplicate */
1382 { WM_GETTEXT
, sent
|optional
},
1383 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
1386 /* SetMenu for NonVisible windows with no size change */
1387 static const struct message WmSetMenuNonVisibleNoSizeChangeSeq
[] = {
1388 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1389 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1390 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1391 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1394 /* SetMenu for Visible windows with size change */
1395 static const struct message WmSetMenuVisibleSizeChangeSeq
[] = {
1396 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1397 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1398 { 0x0093, sent
|defwinproc
|optional
},
1399 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
1400 { WM_NCPAINT
, sent
}, /* wparam != 1 */
1401 { 0x0093, sent
|defwinproc
|optional
},
1402 { 0x0093, sent
|defwinproc
|optional
},
1403 { 0x0091, sent
|defwinproc
|optional
},
1404 { 0x0092, sent
|defwinproc
|optional
},
1405 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1406 { WM_ERASEBKGND
, sent
|optional
},
1407 { WM_ACTIVATE
, sent
|optional
},
1408 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1409 { WM_MOVE
, sent
|defwinproc
},
1410 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
1411 { 0x0093, sent
|optional
},
1412 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
1413 { 0x0093, sent
|defwinproc
|optional
},
1414 { WM_NCPAINT
, sent
|optional
}, /* wparam != 1 */
1415 { 0x0093, sent
|defwinproc
|optional
},
1416 { 0x0093, sent
|defwinproc
|optional
},
1417 { 0x0091, sent
|defwinproc
|optional
},
1418 { 0x0092, sent
|defwinproc
|optional
},
1419 { WM_ERASEBKGND
, sent
|optional
},
1420 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1421 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* XP sends a duplicate */
1424 /* SetMenu for Visible windows with no size change */
1425 static const struct message WmSetMenuVisibleNoSizeChangeSeq
[] = {
1426 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1427 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1428 { WM_NCPAINT
, sent
}, /* wparam != 1 */
1429 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1430 { WM_ERASEBKGND
, sent
|optional
},
1431 { WM_ACTIVATE
, sent
|optional
},
1432 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1433 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1436 /* DrawMenuBar for a visible window */
1437 static const struct message WmDrawMenuBarSeq
[] =
1439 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1440 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1441 { 0x0093, sent
|defwinproc
|optional
},
1442 { WM_NCPAINT
, sent
}, /* wparam != 1 */
1443 { 0x0093, sent
|defwinproc
|optional
},
1444 { 0x0093, sent
|defwinproc
|optional
},
1445 { 0x0091, sent
|defwinproc
|optional
},
1446 { 0x0092, sent
|defwinproc
|optional
},
1447 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1448 { WM_ERASEBKGND
, sent
|optional
},
1449 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1450 { 0x0093, sent
|optional
},
1451 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1455 static const struct message WmSetRedrawFalseSeq
[] =
1457 { WM_SETREDRAW
, sent
|wparam
, 0 },
1461 static const struct message WmSetRedrawTrueSeq
[] =
1463 { WM_SETREDRAW
, sent
|wparam
, 1 },
1467 static const struct message WmEnableWindowSeq_1
[] =
1469 { WM_CANCELMODE
, sent
|wparam
|lparam
, 0, 0 },
1470 { EVENT_OBJECT_STATECHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1471 { WM_ENABLE
, sent
|wparam
|lparam
, FALSE
, 0 },
1475 static const struct message WmEnableWindowSeq_2
[] =
1477 { EVENT_OBJECT_STATECHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1478 { WM_ENABLE
, sent
|wparam
|lparam
, TRUE
, 0 },
1482 static const struct message WmGetScrollRangeSeq
[] =
1484 { SBM_GETRANGE
, sent
},
1487 static const struct message WmGetScrollInfoSeq
[] =
1489 { SBM_GETSCROLLINFO
, sent
},
1492 static const struct message WmSetScrollRangeSeq
[] =
1494 /* MSDN claims that Windows sends SBM_SETRANGE message, but win2k SP4
1495 sends SBM_SETSCROLLINFO.
1497 { SBM_SETSCROLLINFO
, sent
},
1500 /* SetScrollRange for a window without a non-client area */
1501 static const struct message WmSetScrollRangeHSeq_empty
[] =
1503 { EVENT_OBJECT_VALUECHANGE
, winevent_hook
|wparam
|lparam
, OBJID_HSCROLL
, 0 },
1506 static const struct message WmSetScrollRangeVSeq_empty
[] =
1508 { EVENT_OBJECT_VALUECHANGE
, winevent_hook
|wparam
|lparam
, OBJID_VSCROLL
, 0 },
1511 static const struct message WmSetScrollRangeHVSeq
[] =
1513 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOSIZE
},
1514 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1515 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1516 { WM_ERASEBKGND
, sent
|optional
},
1517 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1518 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1519 { EVENT_OBJECT_VALUECHANGE
, winevent_hook
|lparam
|optional
, 0/*OBJID_HSCROLL or OBJID_VSCROLL*/, 0 },
1522 /* SetScrollRange for a window with a non-client area */
1523 static const struct message WmSetScrollRangeHV_NC_Seq
[] =
1525 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOSIZE
},
1526 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1527 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
1528 { WM_NCPAINT
, sent
|optional
},
1529 { WM_STYLECHANGING
, sent
|defwinproc
|optional
},
1530 { WM_STYLECHANGED
, sent
|defwinproc
|optional
},
1531 { WM_STYLECHANGING
, sent
|defwinproc
|optional
},
1532 { WM_STYLECHANGED
, sent
|defwinproc
|optional
},
1533 { WM_STYLECHANGING
, sent
|defwinproc
|optional
},
1534 { WM_STYLECHANGED
, sent
|defwinproc
|optional
},
1535 { WM_STYLECHANGING
, sent
|defwinproc
|optional
},
1536 { WM_STYLECHANGED
, sent
|defwinproc
|optional
},
1537 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1538 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1539 { WM_ERASEBKGND
, sent
|optional
},
1540 { WM_CTLCOLORDLG
, sent
|defwinproc
|optional
}, /* sent to a parent of the dialog */
1541 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOCLIENTMOVE
},
1542 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
1543 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1544 { EVENT_OBJECT_VALUECHANGE
, winevent_hook
|lparam
|optional
, 0/*OBJID_HSCROLL or OBJID_VSCROLL*/, 0 },
1545 { WM_GETTEXT
, sent
|optional
},
1546 { WM_GETTEXT
, sent
|optional
},
1547 { WM_GETTEXT
, sent
|optional
},
1548 { WM_GETTEXT
, sent
|optional
},
1551 /* test if we receive the right sequence of messages */
1552 /* after calling ShowWindow( SW_SHOWNA) */
1553 static const struct message WmSHOWNAChildInvisParInvis
[] = {
1554 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1557 static const struct message WmSHOWNAChildVisParInvis
[] = {
1558 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1561 static const struct message WmSHOWNAChildVisParVis
[] = {
1562 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1563 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
1566 static const struct message WmSHOWNAChildInvisParVis
[] = {
1567 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1568 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1569 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1570 { WM_ERASEBKGND
, sent
|optional
},
1571 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOACTIVATE
|SWP_NOCLIENTMOVE
},
1574 static const struct message WmSHOWNATopVisible
[] = {
1575 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1576 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
1579 static const struct message WmSHOWNATopInvisible
[] = {
1580 { WM_NOTIFYFORMAT
, sent
|optional
},
1581 { WM_QUERYUISTATE
, sent
|optional
},
1582 { WM_WINDOWPOSCHANGING
, sent
|optional
},
1583 { WM_GETMINMAXINFO
, sent
|optional
},
1584 { WM_NCCALCSIZE
, sent
|optional
},
1585 { WM_WINDOWPOSCHANGED
, sent
|optional
},
1586 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1587 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1588 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1589 { WM_NCPAINT
, sent
|wparam
, 1 },
1590 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1591 { WM_ERASEBKGND
, sent
|optional
},
1592 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1593 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
1594 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
1595 { WM_ERASEBKGND
, sent
|optional
},
1596 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1597 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
1602 static int after_end_dialog
, test_def_id
;
1603 static int sequence_cnt
, sequence_size
;
1604 static struct message
* sequence
;
1605 static int log_all_parent_messages
;
1606 static int paint_loop_done
;
1608 /* user32 functions */
1609 static HWND (WINAPI
*pGetAncestor
)(HWND
,UINT
);
1610 static BOOL (WINAPI
*pGetMenuInfo
)(HMENU
,LPCMENUINFO
);
1611 static void (WINAPI
*pNotifyWinEvent
)(DWORD
, HWND
, LONG
, LONG
);
1612 static BOOL (WINAPI
*pSetMenuInfo
)(HMENU
,LPCMENUINFO
);
1613 static HWINEVENTHOOK (WINAPI
*pSetWinEventHook
)(DWORD
, DWORD
, HMODULE
, WINEVENTPROC
, DWORD
, DWORD
, DWORD
);
1614 static BOOL (WINAPI
*pTrackMouseEvent
)(TRACKMOUSEEVENT
*);
1615 static BOOL (WINAPI
*pUnhookWinEvent
)(HWINEVENTHOOK
);
1616 /* kernel32 functions */
1617 static BOOL (WINAPI
*pGetCPInfoExA
)(UINT
, DWORD
, LPCPINFOEXA
);
1619 static void init_procs(void)
1621 HMODULE user32
= GetModuleHandleA("user32.dll");
1622 HMODULE kernel32
= GetModuleHandleA("kernel32.dll");
1624 #define GET_PROC(dll, func) \
1625 p ## func = (void*)GetProcAddress(dll, #func); \
1627 trace("GetProcAddress(%s) failed\n", #func); \
1630 GET_PROC(user32
, GetAncestor
)
1631 GET_PROC(user32
, GetMenuInfo
)
1632 GET_PROC(user32
, NotifyWinEvent
)
1633 GET_PROC(user32
, SetMenuInfo
)
1634 GET_PROC(user32
, SetWinEventHook
)
1635 GET_PROC(user32
, TrackMouseEvent
)
1636 GET_PROC(user32
, UnhookWinEvent
)
1638 GET_PROC(kernel32
, GetCPInfoExA
)
1643 static void add_message(const struct message
*msg
)
1648 sequence
= HeapAlloc( GetProcessHeap(), 0, sequence_size
* sizeof (struct message
) );
1650 if (sequence_cnt
== sequence_size
)
1653 sequence
= HeapReAlloc( GetProcessHeap(), 0, sequence
, sequence_size
* sizeof (struct message
) );
1657 sequence
[sequence_cnt
].message
= msg
->message
;
1658 sequence
[sequence_cnt
].flags
= msg
->flags
;
1659 sequence
[sequence_cnt
].wParam
= msg
->wParam
;
1660 sequence
[sequence_cnt
].lParam
= msg
->lParam
;
1665 /* try to make sure pending X events have been processed before continuing */
1666 static void flush_events(void)
1670 int min_timeout
= 50;
1671 DWORD time
= GetTickCount() + diff
;
1675 if (MsgWaitForMultipleObjects( 0, NULL
, FALSE
, min_timeout
, QS_ALLINPUT
) == WAIT_TIMEOUT
) break;
1676 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
1677 diff
= time
- GetTickCount();
1682 static void flush_sequence(void)
1684 HeapFree(GetProcessHeap(), 0, sequence
);
1686 sequence_cnt
= sequence_size
= 0;
1689 #define ok_sequence( exp, contx, todo) \
1690 ok_sequence_( (exp), (contx), (todo), __FILE__, __LINE__)
1693 static void ok_sequence_(const struct message
*expected
, const char *context
, int todo
,
1694 const char *file
, int line
)
1696 static const struct message end_of_sequence
= { 0, 0, 0, 0 };
1697 const struct message
*actual
;
1700 add_message(&end_of_sequence
);
1704 while (expected
->message
&& actual
->message
)
1706 trace_( file
, line
)("expected %04x - actual %04x\n", expected
->message
, actual
->message
);
1708 if (expected
->message
== actual
->message
)
1710 if (expected
->flags
& wparam
)
1712 if (expected
->wParam
!= actual
->wParam
&& todo
)
1716 ok_( file
, line
) (FALSE
,
1717 "%s: in msg 0x%04x expecting wParam 0x%lx got 0x%lx\n",
1718 context
, expected
->message
, expected
->wParam
, actual
->wParam
);
1722 ok_( file
, line
) (expected
->wParam
== actual
->wParam
,
1723 "%s: in msg 0x%04x expecting wParam 0x%lx got 0x%lx\n",
1724 context
, expected
->message
, expected
->wParam
, actual
->wParam
);
1726 if (expected
->flags
& lparam
)
1728 if (expected
->lParam
!= actual
->lParam
&& todo
)
1732 ok_( file
, line
) (FALSE
,
1733 "%s: in msg 0x%04x expecting lParam 0x%lx got 0x%lx\n",
1734 context
, expected
->message
, expected
->lParam
, actual
->lParam
);
1738 ok_( file
, line
) (expected
->lParam
== actual
->lParam
,
1739 "%s: in msg 0x%04x expecting lParam 0x%lx got 0x%lx\n",
1740 context
, expected
->message
, expected
->lParam
, actual
->lParam
);
1742 if ((expected
->flags
& defwinproc
) != (actual
->flags
& defwinproc
) && todo
)
1746 ok_( file
, line
) (FALSE
,
1747 "%s: the msg 0x%04x should %shave been sent by DefWindowProc\n",
1748 context
, expected
->message
, (expected
->flags
& defwinproc
) ? "" : "NOT ");
1752 ok_( file
, line
) ((expected
->flags
& defwinproc
) == (actual
->flags
& defwinproc
),
1753 "%s: the msg 0x%04x should %shave been sent by DefWindowProc\n",
1754 context
, expected
->message
, (expected
->flags
& defwinproc
) ? "" : "NOT ");
1755 ok_( file
, line
) ((expected
->flags
& beginpaint
) == (actual
->flags
& beginpaint
),
1756 "%s: the msg 0x%04x should %shave been sent by BeginPaint\n",
1757 context
, expected
->message
, (expected
->flags
& beginpaint
) ? "" : "NOT ");
1758 ok_( file
, line
) ((expected
->flags
& (sent
|posted
)) == (actual
->flags
& (sent
|posted
)),
1759 "%s: the msg 0x%04x should have been %s\n",
1760 context
, expected
->message
, (expected
->flags
& posted
) ? "posted" : "sent");
1761 ok_( file
, line
) ((expected
->flags
& parent
) == (actual
->flags
& parent
),
1762 "%s: the msg 0x%04x was expected in %s\n",
1763 context
, expected
->message
, (expected
->flags
& parent
) ? "parent" : "child");
1764 ok_( file
, line
) ((expected
->flags
& hook
) == (actual
->flags
& hook
),
1765 "%s: the msg 0x%04x should have been sent by a hook\n",
1766 context
, expected
->message
);
1767 ok_( file
, line
) ((expected
->flags
& winevent_hook
) == (actual
->flags
& winevent_hook
),
1768 "%s: the msg 0x%04x should have been sent by a winevent hook\n",
1769 context
, expected
->message
);
1773 /* silently drop winevent messages if there is no support for them */
1774 else if ((expected
->flags
& optional
) || ((expected
->flags
& winevent_hook
) && !hEvent_hook
))
1780 ok_( file
, line
) (FALSE
, "%s: the msg 0x%04x was expected, but got msg 0x%04x instead\n",
1781 context
, expected
->message
, actual
->message
);
1788 ok_( file
, line
) (FALSE
, "%s: the msg 0x%04x was expected, but got msg 0x%04x instead\n",
1789 context
, expected
->message
, actual
->message
);
1795 /* skip all optional trailing messages */
1796 while (expected
->message
&& ((expected
->flags
& optional
) ||
1797 ((expected
->flags
& winevent_hook
) && !hEvent_hook
)))
1803 if (expected
->message
|| actual
->message
) {
1805 ok_( file
, line
) (FALSE
, "%s: the msg sequence is not complete: expected %04x - actual %04x\n",
1806 context
, expected
->message
, actual
->message
);
1812 if (expected
->message
|| actual
->message
)
1813 ok_( file
, line
) (FALSE
, "%s: the msg sequence is not complete: expected %04x - actual %04x\n",
1814 context
, expected
->message
, actual
->message
);
1816 if( todo
&& !failcount
) /* succeeded yet marked todo */
1818 ok_( file
, line
)( TRUE
, "%s: marked \"todo_wine\" but succeeds\n", context
);
1824 #define expect(EXPECTED,GOT) ok((GOT)==(EXPECTED), "Expected %d, got %d\n", (EXPECTED), (GOT))
1826 /******************************** MDI test **********************************/
1828 /* CreateWindow for MDI frame window, initially visible */
1829 static const struct message WmCreateMDIframeSeq
[] = {
1830 { HCBT_CREATEWND
, hook
},
1831 { WM_GETMINMAXINFO
, sent
},
1832 { WM_NCCREATE
, sent
},
1833 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
1834 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
1835 { WM_CREATE
, sent
},
1836 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1837 { WM_NOTIFYFORMAT
, sent
|optional
},
1838 { WM_QUERYUISTATE
, sent
|optional
},
1839 { WM_WINDOWPOSCHANGING
, sent
|optional
},
1840 { WM_GETMINMAXINFO
, sent
|optional
},
1841 { WM_NCCALCSIZE
, sent
|optional
},
1842 { WM_WINDOWPOSCHANGED
, sent
|optional
},
1843 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1844 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
1845 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1846 { HCBT_ACTIVATE
, hook
},
1847 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
1848 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
1849 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* XP */
1850 { WM_ACTIVATEAPP
, sent
|wparam
|optional
, 1 }, /* Win9x doesn't send it */
1851 { WM_NCACTIVATE
, sent
|wparam
, 1 },
1852 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1853 { WM_ACTIVATE
, sent
|wparam
, 1 },
1854 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* Win9x */
1855 { HCBT_SETFOCUS
, hook
},
1856 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
1857 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
1858 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1859 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
1860 /* Win9x adds SWP_NOZORDER below */
1861 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1862 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 }, /* XP */
1863 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1864 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
1868 /* DestroyWindow for MDI frame window, initially visible */
1869 static const struct message WmDestroyMDIframeSeq
[] = {
1870 { HCBT_DESTROYWND
, hook
},
1871 { 0x0090, sent
|optional
},
1872 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1873 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1874 { WM_NCACTIVATE
, sent
|wparam
|optional
, 0 }, /* Win9x */
1875 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1876 { WM_NCACTIVATE
, sent
|wparam
|optional
, 0 }, /* XP */
1877 { WM_ACTIVATE
, sent
|wparam
|optional
, 0 }, /* Win9x */
1878 { WM_ACTIVATEAPP
, sent
|wparam
|optional
, 0 }, /* Win9x */
1879 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
1880 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
1881 { WM_DESTROY
, sent
},
1882 { WM_NCDESTROY
, sent
},
1885 /* CreateWindow for MDI client window, initially visible */
1886 static const struct message WmCreateMDIclientSeq
[] = {
1887 { HCBT_CREATEWND
, hook
},
1888 { WM_NCCREATE
, sent
},
1889 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
1890 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 },
1891 { WM_CREATE
, sent
},
1892 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 },
1893 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1894 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
1896 { WM_PARENTNOTIFY
, sent
|wparam
, WM_CREATE
}, /* in MDI frame */
1897 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1898 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1899 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1900 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1903 /* ShowWindow(SW_SHOW) for MDI client window */
1904 static const struct message WmShowMDIclientSeq
[] = {
1905 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1906 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1907 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1908 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1911 /* ShowWindow(SW_HIDE) for MDI client window */
1912 static const struct message WmHideMDIclientSeq
[] = {
1913 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
1914 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1915 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* win2000 */
1916 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* XP */
1917 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1920 /* DestroyWindow for MDI client window, initially visible */
1921 static const struct message WmDestroyMDIclientSeq
[] = {
1922 { HCBT_DESTROYWND
, hook
},
1923 { 0x0090, sent
|optional
},
1924 { WM_PARENTNOTIFY
, sent
|wparam
, WM_DESTROY
}, /* in MDI frame */
1925 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
1926 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1927 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1928 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1929 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
1930 { WM_DESTROY
, sent
},
1931 { WM_NCDESTROY
, sent
},
1934 /* CreateWindow for MDI child window, initially visible */
1935 static const struct message WmCreateMDIchildVisibleSeq
[] = {
1936 { HCBT_CREATEWND
, hook
},
1937 { WM_NCCREATE
, sent
},
1938 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
1939 { WM_CREATE
, sent
},
1940 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1941 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
1943 /* Win2k sends wparam set to
1944 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
1945 * while Win9x doesn't bother to set child window id according to
1946 * CLIENTCREATESTRUCT.idFirstChild
1948 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
1949 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1950 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1951 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1952 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1953 { WM_MDIREFRESHMENU
, sent
/*|wparam|lparam, 0, 0*/ },
1954 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
1955 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
1956 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1958 /* Win9x: message sequence terminates here. */
1960 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 },
1961 { HCBT_SETFOCUS
, hook
}, /* in MDI client */
1962 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
1963 { WM_IME_NOTIFY
, sent
|wparam
|optional
, 2 }, /* in MDI client */
1964 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1965 { WM_SETFOCUS
, sent
}, /* in MDI client */
1966 { HCBT_SETFOCUS
, hook
},
1967 { WM_KILLFOCUS
, sent
}, /* in MDI client */
1968 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
1969 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
1970 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1971 { WM_SETFOCUS
, sent
|defwinproc
},
1972 { WM_MDIACTIVATE
, sent
|defwinproc
},
1975 /* CreateWindow for MDI child window with invisible parent */
1976 static const struct message WmCreateMDIchildInvisibleParentSeq
[] = {
1977 { HCBT_CREATEWND
, hook
},
1978 { WM_GETMINMAXINFO
, sent
},
1979 { WM_NCCREATE
, sent
},
1980 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
1981 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 },
1982 { WM_CREATE
, sent
},
1983 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1984 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
1986 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
1987 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1988 { WM_MDIREFRESHMENU
, sent
}, /* in MDI client */
1989 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
1990 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
1991 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1993 /* Win9x: message sequence terminates here. */
1995 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 },
1996 { HCBT_SETFOCUS
, hook
}, /* in MDI client */
1997 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
1998 { WM_IME_NOTIFY
, sent
|wparam
|optional
, 2 }, /* in MDI client */
1999 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2000 { WM_SETFOCUS
, sent
}, /* in MDI client */
2001 { HCBT_SETFOCUS
, hook
},
2002 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2003 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2004 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
2005 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2006 { WM_SETFOCUS
, sent
|defwinproc
},
2007 { WM_MDIACTIVATE
, sent
|defwinproc
},
2010 /* DestroyWindow for MDI child window, initially visible */
2011 static const struct message WmDestroyMDIchildVisibleSeq
[] = {
2012 { HCBT_DESTROYWND
, hook
},
2013 /* Win2k sends wparam set to
2014 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
2015 * while Win9x doesn't bother to set child window id according to
2016 * CLIENTCREATESTRUCT.idFirstChild
2018 { 0x0090, sent
|optional
},
2019 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_DESTROY*/ }, /* in MDI client */
2020 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
2021 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2022 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2023 { WM_ERASEBKGND
, sent
|parent
|optional
},
2024 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2026 /* { WM_DESTROY, sent }
2027 * Win9x: message sequence terminates here.
2030 { HCBT_SETFOCUS
, hook
}, /* set focus to MDI client */
2031 { WM_KILLFOCUS
, sent
},
2032 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
2033 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2034 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2035 { WM_SETFOCUS
, sent
}, /* in MDI client */
2037 { HCBT_SETFOCUS
, hook
}, /* MDI client sets focus back to MDI child */
2038 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2039 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2040 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
2041 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2042 { WM_SETFOCUS
, sent
}, /* in MDI client */
2044 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
2046 { HCBT_SETFOCUS
, hook
}, /* set focus to MDI client */
2047 { WM_KILLFOCUS
, sent
},
2048 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
2049 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2050 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2051 { WM_SETFOCUS
, sent
}, /* in MDI client */
2053 { HCBT_SETFOCUS
, hook
}, /* MDI client sets focus back to MDI child */
2054 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2055 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2056 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
2057 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2058 { WM_SETFOCUS
, sent
}, /* in MDI client */
2060 { WM_DESTROY
, sent
},
2062 { HCBT_SETFOCUS
, hook
}, /* set focus to MDI client */
2063 { WM_KILLFOCUS
, sent
},
2064 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
2065 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2066 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2067 { WM_SETFOCUS
, sent
}, /* in MDI client */
2069 { HCBT_SETFOCUS
, hook
}, /* MDI client sets focus back to MDI child */
2070 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2071 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2072 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
2073 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2074 { WM_SETFOCUS
, sent
}, /* in MDI client */
2076 { WM_NCDESTROY
, sent
},
2079 /* CreateWindow for MDI child window, initially invisible */
2080 static const struct message WmCreateMDIchildInvisibleSeq
[] = {
2081 { HCBT_CREATEWND
, hook
},
2082 { WM_NCCREATE
, sent
},
2083 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
2084 { WM_CREATE
, sent
},
2085 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2086 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2088 /* Win2k sends wparam set to
2089 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2090 * while Win9x doesn't bother to set child window id according to
2091 * CLIENTCREATESTRUCT.idFirstChild
2093 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
2096 /* DestroyWindow for MDI child window, initially invisible */
2097 static const struct message WmDestroyMDIchildInvisibleSeq
[] = {
2098 { HCBT_DESTROYWND
, hook
},
2099 /* Win2k sends wparam set to
2100 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
2101 * while Win9x doesn't bother to set child window id according to
2102 * CLIENTCREATESTRUCT.idFirstChild
2104 { 0x0090, sent
|optional
},
2105 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_DESTROY*/ }, /* in MDI client */
2106 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
2107 { WM_DESTROY
, sent
},
2108 { WM_NCDESTROY
, sent
},
2109 /* FIXME: Wine destroys an icon/title window while Windows doesn't */
2110 { WM_PARENTNOTIFY
, sent
|wparam
|optional
, WM_DESTROY
}, /* MDI client */
2113 /* CreateWindow for the 1st MDI child window, initially visible and maximized */
2114 static const struct message WmCreateMDIchildVisibleMaxSeq1
[] = {
2115 { HCBT_CREATEWND
, hook
},
2116 { WM_NCCREATE
, sent
},
2117 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
2118 { WM_CREATE
, sent
},
2119 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2120 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2122 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
2123 { WM_GETMINMAXINFO
, sent
},
2124 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_STATECHANGED
},
2125 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2126 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
2127 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2129 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2130 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2131 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2132 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2133 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2134 /* Win2k sends wparam set to
2135 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2136 * while Win9x doesn't bother to set child window id according to
2137 * CLIENTCREATESTRUCT.idFirstChild
2139 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
2140 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
2141 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2142 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2143 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2144 { WM_MDIREFRESHMENU
, sent
/*|wparam|lparam, 0, 0*/ },
2145 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
2146 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2147 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2149 /* Win9x: message sequence terminates here. */
2151 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 },
2152 { HCBT_SETFOCUS
, hook
}, /* in MDI client */
2153 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2154 { WM_IME_NOTIFY
, sent
|wparam
|optional
, 2 }, /* in MDI client */
2155 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2156 { WM_SETFOCUS
, sent
}, /* in MDI client */
2157 { HCBT_SETFOCUS
, hook
},
2158 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2159 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2160 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
2161 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2162 { WM_SETFOCUS
, sent
|defwinproc
},
2163 { WM_MDIACTIVATE
, sent
|defwinproc
},
2165 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2166 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2167 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2168 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2171 /* CreateWindow for the 2nd MDI child window, initially visible and maximized */
2172 static const struct message WmCreateMDIchildVisibleMaxSeq2
[] = {
2173 /* restore the 1st MDI child */
2174 { WM_SETREDRAW
, sent
|wparam
, 0 },
2175 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWNORMAL
},
2176 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
2177 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2178 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2179 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
2180 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2182 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2183 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2184 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2185 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2186 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2187 { WM_SETREDRAW
, sent
|wparam
, 1 }, /* in the 1st MDI child */
2188 /* create the 2nd MDI child */
2189 { HCBT_CREATEWND
, hook
},
2190 { WM_NCCREATE
, sent
},
2191 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
2192 { WM_CREATE
, sent
},
2193 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2194 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2196 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
2197 { WM_GETMINMAXINFO
, sent
},
2198 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_STATECHANGED
},
2199 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2200 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2201 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
2202 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2204 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2205 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2206 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2207 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2208 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2209 /* Win2k sends wparam set to
2210 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2211 * while Win9x doesn't bother to set child window id according to
2212 * CLIENTCREATESTRUCT.idFirstChild
2214 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
2215 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
2216 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2217 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2218 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2219 { WM_MDIREFRESHMENU
, sent
/*|wparam|lparam, 0, 0*/ },
2220 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
2221 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2223 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 0 }, /* in the 1st MDI child */
2224 { WM_MDIACTIVATE
, sent
|defwinproc
}, /* in the 1st MDI child */
2226 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2228 /* Win9x: message sequence terminates here. */
2230 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 },
2231 { HCBT_SETFOCUS
, hook
},
2232 { WM_KILLFOCUS
, sent
|defwinproc
|optional
}, /* in the 1st MDI child */
2233 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 0 }, /* in the 1st MDI child */
2234 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2235 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2236 { WM_SETFOCUS
, sent
}, /* in MDI client */
2237 { HCBT_SETFOCUS
, hook
},
2238 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2239 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2240 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
2241 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2242 { WM_SETFOCUS
, sent
|defwinproc
},
2244 { WM_MDIACTIVATE
, sent
|defwinproc
},
2246 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2247 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2248 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2249 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2252 /* WM_MDICREATE MDI child window, initially visible and maximized */
2253 static const struct message WmCreateMDIchildVisibleMaxSeq3
[] = {
2254 { WM_MDICREATE
, sent
},
2255 { HCBT_CREATEWND
, hook
},
2256 { WM_NCCREATE
, sent
},
2257 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
2258 { WM_CREATE
, sent
},
2259 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2260 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2262 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
2263 { WM_GETMINMAXINFO
, sent
},
2264 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_STATECHANGED
},
2265 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2266 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
2267 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2270 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2271 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2272 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2273 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2274 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2276 /* Win2k sends wparam set to
2277 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2278 * while Win9x doesn't bother to set child window id according to
2279 * CLIENTCREATESTRUCT.idFirstChild
2281 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
2282 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
2283 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2285 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2287 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2288 { WM_MDIREFRESHMENU
, sent
/*|wparam|lparam, 0, 0*/ },
2289 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
2291 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2292 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2294 /* Win9x: message sequence terminates here. */
2296 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 },
2297 { WM_SETFOCUS
, sent
|optional
}, /* in MDI client */
2298 { HCBT_SETFOCUS
, hook
}, /* in MDI client */
2299 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2300 { WM_IME_NOTIFY
, sent
|wparam
|optional
, 2 },
2301 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
|optional
, OBJID_CLIENT
, 0 },
2302 { WM_SETFOCUS
, sent
|optional
}, /* in MDI client */
2303 { HCBT_SETFOCUS
, hook
|optional
},
2304 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2305 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2306 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
2307 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2308 { WM_SETFOCUS
, sent
|defwinproc
},
2310 { WM_MDIACTIVATE
, sent
|defwinproc
},
2313 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2314 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2315 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2316 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2319 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2320 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2321 { 0x0093, sent
|defwinproc
|optional
},
2322 { 0x0093, sent
|defwinproc
|optional
},
2323 { 0x0093, sent
|defwinproc
|optional
},
2324 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2325 { WM_MOVE
, sent
|defwinproc
},
2326 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2329 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
2330 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2331 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
},
2332 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2335 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
2336 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2337 { 0x0093, sent
|optional
},
2338 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
},
2339 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2341 { 0x0093, sent
|optional
},
2342 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2343 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI client */
2344 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 }, /* XP sends it to MDI frame */
2345 { 0x0093, sent
|defwinproc
|optional
},
2346 { 0x0093, sent
|defwinproc
|optional
},
2347 { 0x0093, sent
|defwinproc
|optional
},
2348 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2349 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* XP sends a duplicate */
2353 /* CreateWindow for the 1st MDI child window, initially invisible and maximized */
2354 static const struct message WmCreateMDIchildInvisibleMaxSeq4
[] = {
2355 { HCBT_CREATEWND
, hook
},
2356 { WM_GETMINMAXINFO
, sent
},
2357 { WM_NCCREATE
, sent
},
2358 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
2359 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
2360 { WM_CREATE
, sent
},
2361 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2362 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2363 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOZORDER
|SWP_NOSIZE
|SWP_NOMOVE
}, /* MDI frame */
2364 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 }, /* MDI frame */
2365 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOZORDER
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
}, /* MDI frame */
2367 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
2368 { WM_GETMINMAXINFO
, sent
},
2369 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_STATECHANGED
},
2370 { WM_GETMINMAXINFO
, sent
|defwinproc
},
2371 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2372 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_STATECHANGED
},
2373 { WM_MOVE
, sent
|defwinproc
},
2374 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2376 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2377 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2378 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2379 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2380 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 }, /* MDI child */
2381 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2382 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2383 /* Win2k sends wparam set to
2384 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2385 * while Win9x doesn't bother to set child window id according to
2386 * CLIENTCREATESTRUCT.idFirstChild
2388 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
2391 /* WM_SYSCOMMAND/SC_CLOSE for the 2nd MDI child window, initially visible and maximized */
2392 static const struct message WmDestroyMDIchildVisibleMaxSeq2
[] = {
2393 { WM_SYSCOMMAND
, sent
|wparam
, SC_CLOSE
},
2394 { HCBT_SYSCOMMAND
, hook
},
2395 { WM_CLOSE
, sent
|defwinproc
},
2396 { WM_MDIDESTROY
, sent
}, /* in MDI client */
2398 /* bring the 1st MDI child to top */
2399 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOSIZE
|SWP_NOMOVE
}, /* in the 1st MDI child */
2400 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
}, /* in the 2nd MDI child */
2402 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2404 { WM_CHILDACTIVATE
, sent
|defwinproc
|wparam
|lparam
, 0, 0 }, /* in the 1st MDI child */
2405 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 0 }, /* in the 1st MDI child */
2406 { WM_MDIACTIVATE
, sent
|defwinproc
}, /* in the 1st MDI child */
2408 /* maximize the 1st MDI child */
2409 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
2410 { WM_GETMINMAXINFO
, sent
|defwinproc
},
2411 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
2412 { WM_NCCALCSIZE
, sent
|defwinproc
|wparam
, 1 },
2413 { WM_CHILDACTIVATE
, sent
|defwinproc
|wparam
|lparam
, 0, 0 },
2414 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
2415 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2417 /* restore the 2nd MDI child */
2418 { WM_SETREDRAW
, sent
|defwinproc
|wparam
, 0 },
2419 { HCBT_MINMAX
, hook
|lparam
, 0, SW_NORMALNA
},
2420 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_SHOWWINDOW
|SWP_STATECHANGED
},
2421 { WM_NCCALCSIZE
, sent
|defwinproc
|wparam
, 1 },
2423 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2425 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
2426 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2428 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2430 { WM_SETREDRAW
, sent
|defwinproc
|wparam
, 1 },
2432 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2433 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2434 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2435 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2436 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2438 /* bring the 1st MDI child to top */
2439 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2440 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 },
2441 { HCBT_SETFOCUS
, hook
},
2442 { WM_KILLFOCUS
, sent
|defwinproc
},
2443 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 0 },
2444 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2445 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2446 { WM_SETFOCUS
, sent
}, /* in MDI client */
2447 { HCBT_SETFOCUS
, hook
},
2448 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2449 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2450 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
2451 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2452 { WM_SETFOCUS
, sent
|defwinproc
},
2453 { WM_MDIACTIVATE
, sent
|defwinproc
},
2454 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2456 /* apparently ShowWindow(SW_SHOW) on an MDI client */
2457 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
2458 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2459 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2460 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2461 { WM_MDIREFRESHMENU
, sent
},
2463 { HCBT_DESTROYWND
, hook
},
2464 /* Win2k sends wparam set to
2465 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
2466 * while Win9x doesn't bother to set child window id according to
2467 * CLIENTCREATESTRUCT.idFirstChild
2469 { 0x0090, sent
|defwinproc
|optional
},
2470 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_DESTROY*/ }, /* in MDI client */
2471 { WM_SHOWWINDOW
, sent
|defwinproc
|wparam
, 0 },
2472 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2473 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2474 { WM_ERASEBKGND
, sent
|parent
|optional
},
2475 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2477 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
2478 { WM_DESTROY
, sent
|defwinproc
},
2479 { WM_NCDESTROY
, sent
|defwinproc
},
2482 /* WM_MDIDESTROY for the single MDI child window, initially visible and maximized */
2483 static const struct message WmDestroyMDIchildVisibleMaxSeq1
[] = {
2484 { WM_MDIDESTROY
, sent
}, /* in MDI client */
2485 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
2486 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2487 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2488 { WM_ERASEBKGND
, sent
|parent
|optional
},
2489 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2491 { HCBT_SETFOCUS
, hook
},
2492 { WM_KILLFOCUS
, sent
},
2493 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
2494 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2495 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2496 { WM_SETFOCUS
, sent
}, /* in MDI client */
2497 { HCBT_SETFOCUS
, hook
},
2498 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2499 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2500 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
2501 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2502 { WM_SETFOCUS
, sent
},
2505 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2506 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2507 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2508 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2511 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2512 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2513 { 0x0093, sent
|defwinproc
|optional
},
2514 { 0x0093, sent
|defwinproc
|optional
},
2515 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2516 { WM_MOVE
, sent
|defwinproc
},
2517 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2520 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
2521 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2522 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
},
2523 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2526 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
2527 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2528 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
},
2529 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2532 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2533 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 },
2534 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2535 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2538 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2539 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 },
2540 { 0x0093, sent
|defwinproc
|optional
},
2541 { 0x0093, sent
|defwinproc
|optional
},
2542 { 0x0093, sent
|defwinproc
|optional
},
2543 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2544 { WM_MOVE
, sent
|defwinproc
},
2545 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2548 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
2549 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2550 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
},
2551 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2554 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
},
2555 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 },
2556 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
},
2557 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2558 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2559 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI client */
2561 { 0x0093, sent
|defwinproc
|optional
},
2562 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
|optional
, 1 }, /* XP sends it to MDI frame */
2563 { 0x0093, sent
|defwinproc
|optional
},
2564 { 0x0093, sent
|defwinproc
|optional
},
2565 { 0x0093, sent
|defwinproc
|optional
},
2566 { 0x0093, sent
|optional
},
2568 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2569 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2570 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI client */
2571 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2572 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* XP sends a duplicate */
2575 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2576 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
2577 { 0x0093, sent
|defwinproc
|optional
},
2578 { 0x0093, sent
|defwinproc
|optional
},
2579 { 0x0093, sent
|defwinproc
|optional
},
2580 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2581 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2582 { 0x0093, sent
|optional
},
2584 { WM_NCACTIVATE
, sent
|wparam
, 0 },
2585 { WM_MDIACTIVATE
, sent
},
2587 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWNORMAL
},
2588 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_SHOWWINDOW
|SWP_STATECHANGED
},
2589 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2591 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2593 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2594 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_SHOWWINDOW
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
2595 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2598 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2599 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 },
2600 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2601 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2604 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2605 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2606 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2607 { WM_MOVE
, sent
|defwinproc
},
2608 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2611 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
2612 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2613 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
},
2614 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2615 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2616 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 }, /* XP */
2617 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI client */
2618 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2619 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* XP sends a duplicate */
2621 { HCBT_SETFOCUS
, hook
},
2622 { WM_KILLFOCUS
, sent
},
2623 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
2624 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2625 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2626 { WM_SETFOCUS
, sent
}, /* in MDI client */
2628 { WM_MDIREFRESHMENU
, sent
}, /* in MDI client */
2630 { HCBT_DESTROYWND
, hook
},
2631 /* Win2k sends wparam set to
2632 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
2633 * while Win9x doesn't bother to set child window id according to
2634 * CLIENTCREATESTRUCT.idFirstChild
2636 { 0x0090, sent
|optional
},
2637 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_DESTROY*/ }, /* in MDI client */
2639 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
2640 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2641 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2642 { WM_ERASEBKGND
, sent
|parent
|optional
},
2643 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2645 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
2646 { WM_DESTROY
, sent
},
2647 { WM_NCDESTROY
, sent
},
2650 /* ShowWindow(SW_MAXIMIZE) for a not visible MDI child window */
2651 static const struct message WmMaximizeMDIchildInvisibleSeq
[] = {
2652 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
2653 { WM_GETMINMAXINFO
, sent
},
2654 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_STATECHANGED
},
2655 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2656 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2657 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2659 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2660 { WM_NCACTIVATE
, sent
|wparam
|optional
|defwinproc
, 1 },
2661 { HCBT_SETFOCUS
, hook
|optional
},
2662 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2663 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2664 { WM_SETFOCUS
, sent
|optional
}, /* in MDI client */
2665 { HCBT_SETFOCUS
, hook
|optional
},
2666 { WM_KILLFOCUS
, sent
|optional
}, /* in MDI client */
2667 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2668 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
2669 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2670 { WM_SETFOCUS
, sent
|optional
|defwinproc
},
2671 { WM_MDIACTIVATE
, sent
|optional
|defwinproc
},
2672 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
2673 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2675 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2676 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2677 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2678 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2679 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2682 /* ShowWindow(SW_MAXIMIZE) for a not visible maximized MDI child window */
2683 static const struct message WmMaximizeMDIchildInvisibleSeq2
[] = {
2684 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
2685 { WM_GETMINMAXINFO
, sent
},
2686 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
},
2687 { WM_GETMINMAXINFO
, sent
|defwinproc
},
2688 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2689 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2690 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2692 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
|optional
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2693 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
|optional
, 1 },
2694 { HCBT_SETFOCUS
, hook
|optional
},
2695 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2696 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2697 { WM_SETFOCUS
, sent
|optional
}, /* in MDI client */
2698 { HCBT_SETFOCUS
, hook
|optional
},
2699 { WM_KILLFOCUS
, sent
|optional
}, /* in MDI client */
2700 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2701 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
2702 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2703 { WM_SETFOCUS
, sent
|defwinproc
|optional
},
2704 { WM_MDIACTIVATE
, sent
|defwinproc
|optional
},
2705 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2706 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2709 /* WM_MDIMAXIMIZE for an MDI child window with invisible parent */
2710 static const struct message WmMaximizeMDIchildInvisibleParentSeq
[] = {
2711 { WM_MDIMAXIMIZE
, sent
}, /* in MDI client */
2712 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
2713 { WM_GETMINMAXINFO
, sent
},
2714 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
2715 { WM_GETMINMAXINFO
, sent
|defwinproc
},
2716 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2717 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* XP doesn't send it */
2718 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2719 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOREDRAW
|SWP_STATECHANGED
},
2720 { WM_MOVE
, sent
|defwinproc
},
2721 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2723 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2724 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 },
2725 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2726 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
|optional
, 1 },
2727 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI child XP */
2728 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI client XP */
2730 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2731 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2732 { 0x0093, sent
|defwinproc
|optional
},
2733 { 0x0094, sent
|defwinproc
|optional
},
2734 { 0x0094, sent
|defwinproc
|optional
},
2735 { 0x0094, sent
|defwinproc
|optional
},
2736 { 0x0094, sent
|defwinproc
|optional
},
2737 { 0x0093, sent
|defwinproc
|optional
},
2738 { 0x0093, sent
|defwinproc
|optional
},
2739 { 0x0091, sent
|defwinproc
|optional
},
2740 { 0x0092, sent
|defwinproc
|optional
},
2741 { 0x0092, sent
|defwinproc
|optional
},
2742 { 0x0092, sent
|defwinproc
|optional
},
2743 { 0x0092, sent
|defwinproc
|optional
},
2744 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2745 { WM_MOVE
, sent
|defwinproc
},
2746 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2747 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI frame win2000 */
2749 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
2750 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2751 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
},
2752 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2754 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
},
2755 { WM_GETMINMAXINFO
, sent
|defwinproc
},
2756 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 },
2757 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
},
2758 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2759 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI child win2000 */
2760 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
|optional
, 1 },
2761 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI child XP */
2762 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI child XP */
2763 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI client XP */
2765 { 0x0093, sent
|optional
},
2766 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
2767 { 0x0093, sent
|defwinproc
|optional
},
2768 { 0x0093, sent
|defwinproc
|optional
},
2769 { 0x0093, sent
|defwinproc
|optional
},
2770 { 0x0091, sent
|defwinproc
|optional
},
2771 { 0x0092, sent
|defwinproc
|optional
},
2772 { 0x0092, sent
|defwinproc
|optional
},
2773 { 0x0092, sent
|defwinproc
|optional
},
2774 { 0x0092, sent
|defwinproc
|optional
},
2775 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI frame XP */
2776 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI frame XP */
2777 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI child XP */
2780 /* ShowWindow(SW_MAXIMIZE) for a visible MDI child window */
2781 static const struct message WmMaximizeMDIchildVisibleSeq
[] = {
2782 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
2783 { WM_GETMINMAXINFO
, sent
},
2784 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
2785 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2786 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2787 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
2788 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2790 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2791 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2792 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2793 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2794 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2797 /* ShowWindow(SW_RESTORE) for a visible maximized MDI child window */
2798 static const struct message WmRestoreMDIchildVisibleSeq
[] = {
2799 { HCBT_MINMAX
, hook
|lparam
, 0, SW_RESTORE
},
2800 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
2801 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2802 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2803 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
2804 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2806 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2807 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2808 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2809 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2810 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2813 /* ShowWindow(SW_RESTORE) for a visible minimized MDI child window */
2814 static const struct message WmRestoreMDIchildVisibleSeq_2
[] = {
2815 { HCBT_MINMAX
, hook
|lparam
, 0, SW_RESTORE
},
2816 { WM_QUERYOPEN
, sent
|wparam
|lparam
, 0, 0 },
2817 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
2818 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2819 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2820 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_NOCLIENTSIZE
|SWP_STATECHANGED
},
2821 { WM_MOVE
, sent
|defwinproc
},
2822 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2823 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2824 { EVENT_SYSTEM_MINIMIZEEND
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2825 { HCBT_SETFOCUS
, hook
},
2826 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
2827 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
2828 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2829 { WM_SETFOCUS
, sent
},
2832 /* ShowWindow(SW_MINIMIZE) for a visible restored MDI child window */
2833 static const struct message WmMinimizeMDIchildVisibleSeq
[] = {
2834 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
2835 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
2836 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2837 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOCOPYBITS
|SWP_NOCLIENTSIZE
|SWP_STATECHANGED
},
2838 { WM_MOVE
, sent
|defwinproc
},
2839 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MINIMIZED
},
2840 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
|defwinproc
, 0, 0 },
2841 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2842 { EVENT_SYSTEM_MINIMIZESTART
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2843 /* FIXME: Wine creates an icon/title window while Windows doesn't */
2844 { WM_PARENTNOTIFY
, sent
|parent
|wparam
|optional
, WM_CREATE
}, /* MDI client */
2847 /* ShowWindow(SW_RESTORE) for a not visible MDI child window */
2848 static const struct message WmRestoreMDIchildInisibleSeq
[] = {
2849 { HCBT_MINMAX
, hook
|lparam
, 0, SW_RESTORE
},
2850 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_STATECHANGED
},
2851 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2852 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2853 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2854 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
2855 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2857 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2858 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2859 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2860 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2861 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2865 static HWND mdi_client
;
2866 static WNDPROC old_mdi_client_proc
;
2868 static LRESULT WINAPI
mdi_client_hook_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
2872 /* do not log painting messages */
2873 if (message
!= WM_PAINT
&&
2874 message
!= WM_NCPAINT
&&
2875 message
!= WM_SYNCPAINT
&&
2876 message
!= WM_ERASEBKGND
&&
2877 message
!= WM_NCHITTEST
&&
2878 message
!= WM_GETTEXT
&&
2879 message
!= WM_MDIGETACTIVE
&&
2880 message
!= WM_GETICON
&&
2881 message
!= WM_DEVICECHANGE
)
2883 trace("mdi client: %p, %04x, %08lx, %08lx\n", hwnd
, message
, wParam
, lParam
);
2887 case WM_WINDOWPOSCHANGING
:
2888 case WM_WINDOWPOSCHANGED
:
2890 WINDOWPOS
*winpos
= (WINDOWPOS
*)lParam
;
2892 trace("%s\n", (message
== WM_WINDOWPOSCHANGING
) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
2893 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x ",
2894 winpos
->hwnd
, winpos
->hwndInsertAfter
,
2895 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
2896 dump_winpos_flags(winpos
->flags
);
2898 /* Log only documented flags, win2k uses 0x1000 and 0x2000
2899 * in the high word for internal purposes
2901 wParam
= winpos
->flags
& 0xffff;
2902 /* We are not interested in the flags that don't match under XP and Win9x */
2903 wParam
&= ~(SWP_NOZORDER
);
2908 msg
.message
= message
;
2909 msg
.flags
= sent
|wparam
|lparam
;
2910 msg
.wParam
= wParam
;
2911 msg
.lParam
= lParam
;
2915 return CallWindowProcA(old_mdi_client_proc
, hwnd
, message
, wParam
, lParam
);
2918 static LRESULT WINAPI
mdi_child_wnd_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
2920 static long defwndproc_counter
= 0;
2924 /* do not log painting messages */
2925 if (message
!= WM_PAINT
&&
2926 message
!= WM_NCPAINT
&&
2927 message
!= WM_SYNCPAINT
&&
2928 message
!= WM_ERASEBKGND
&&
2929 message
!= WM_NCHITTEST
&&
2930 message
!= WM_GETTEXT
&&
2931 message
!= WM_GETICON
&&
2932 message
!= WM_DEVICECHANGE
)
2934 trace("mdi child: %p, %04x, %08lx, %08lx\n", hwnd
, message
, wParam
, lParam
);
2938 case WM_WINDOWPOSCHANGING
:
2939 case WM_WINDOWPOSCHANGED
:
2941 WINDOWPOS
*winpos
= (WINDOWPOS
*)lParam
;
2943 trace("%s\n", (message
== WM_WINDOWPOSCHANGING
) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
2944 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x ",
2945 winpos
->hwnd
, winpos
->hwndInsertAfter
,
2946 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
2947 dump_winpos_flags(winpos
->flags
);
2949 /* Log only documented flags, win2k uses 0x1000 and 0x2000
2950 * in the high word for internal purposes
2952 wParam
= winpos
->flags
& 0xffff;
2953 /* We are not interested in the flags that don't match under XP and Win9x */
2954 wParam
&= ~(SWP_NOZORDER
);
2958 case WM_MDIACTIVATE
:
2960 HWND active
, client
= GetParent(hwnd
);
2962 active
= (HWND
)SendMessageA(client
, WM_MDIGETACTIVE
, 0, 0);
2964 if (hwnd
== (HWND
)lParam
) /* if we are being activated */
2965 ok (active
== (HWND
)lParam
, "new active %p != active %p\n", (HWND
)lParam
, active
);
2967 ok (active
== (HWND
)wParam
, "old active %p != active %p\n", (HWND
)wParam
, active
);
2972 msg
.message
= message
;
2973 msg
.flags
= sent
|wparam
|lparam
;
2974 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
2975 msg
.wParam
= wParam
;
2976 msg
.lParam
= lParam
;
2980 defwndproc_counter
++;
2981 ret
= DefMDIChildProcA(hwnd
, message
, wParam
, lParam
);
2982 defwndproc_counter
--;
2987 static LRESULT WINAPI
mdi_frame_wnd_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
2989 static long defwndproc_counter
= 0;
2993 /* do not log painting messages */
2994 if (message
!= WM_PAINT
&&
2995 message
!= WM_NCPAINT
&&
2996 message
!= WM_SYNCPAINT
&&
2997 message
!= WM_ERASEBKGND
&&
2998 message
!= WM_NCHITTEST
&&
2999 message
!= WM_GETTEXT
&&
3000 message
!= WM_GETICON
&&
3001 message
!= WM_DEVICECHANGE
&&
3004 trace("mdi frame: %p, %04x, %08lx, %08lx\n", hwnd
, message
, wParam
, lParam
);
3008 case WM_WINDOWPOSCHANGING
:
3009 case WM_WINDOWPOSCHANGED
:
3011 WINDOWPOS
*winpos
= (WINDOWPOS
*)lParam
;
3013 trace("%s\n", (message
== WM_WINDOWPOSCHANGING
) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
3014 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x ",
3015 winpos
->hwnd
, winpos
->hwndInsertAfter
,
3016 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
3017 dump_winpos_flags(winpos
->flags
);
3019 /* Log only documented flags, win2k uses 0x1000 and 0x2000
3020 * in the high word for internal purposes
3022 wParam
= winpos
->flags
& 0xffff;
3023 /* We are not interested in the flags that don't match under XP and Win9x */
3024 wParam
&= ~(SWP_NOZORDER
);
3029 msg
.message
= message
;
3030 msg
.flags
= sent
|wparam
|lparam
;
3031 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
3032 msg
.wParam
= wParam
;
3033 msg
.lParam
= lParam
;
3037 defwndproc_counter
++;
3038 ret
= DefFrameProcA(hwnd
, mdi_client
, message
, wParam
, lParam
);
3039 defwndproc_counter
--;
3044 static BOOL
mdi_RegisterWindowClasses(void)
3049 cls
.lpfnWndProc
= mdi_frame_wnd_proc
;
3052 cls
.hInstance
= GetModuleHandleA(0);
3054 cls
.hCursor
= LoadCursorA(0, (LPSTR
)IDC_ARROW
);
3055 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
3056 cls
.lpszMenuName
= NULL
;
3057 cls
.lpszClassName
= "MDI_frame_class";
3058 if (!RegisterClassA(&cls
)) return FALSE
;
3060 cls
.lpfnWndProc
= mdi_child_wnd_proc
;
3061 cls
.lpszClassName
= "MDI_child_class";
3062 if (!RegisterClassA(&cls
)) return FALSE
;
3064 if (!GetClassInfoA(0, "MDIClient", &cls
)) assert(0);
3065 old_mdi_client_proc
= cls
.lpfnWndProc
;
3066 cls
.hInstance
= GetModuleHandleA(0);
3067 cls
.lpfnWndProc
= mdi_client_hook_proc
;
3068 cls
.lpszClassName
= "MDI_client_class";
3069 if (!RegisterClassA(&cls
)) assert(0);
3074 static void test_mdi_messages(void)
3076 MDICREATESTRUCTA mdi_cs
;
3077 CLIENTCREATESTRUCT client_cs
;
3078 HWND mdi_frame
, mdi_child
, mdi_child2
, active_child
;
3080 HMENU hMenu
= CreateMenu();
3082 assert(mdi_RegisterWindowClasses());
3086 trace("creating MDI frame window\n");
3087 mdi_frame
= CreateWindowExA(0, "MDI_frame_class", "MDI frame window",
3088 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
|
3089 WS_MAXIMIZEBOX
| WS_VISIBLE
,
3090 100, 100, CW_USEDEFAULT
, CW_USEDEFAULT
,
3091 GetDesktopWindow(), hMenu
,
3092 GetModuleHandleA(0), NULL
);
3094 ok_sequence(WmCreateMDIframeSeq
, "Create MDI frame window", FALSE
);
3096 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3097 ok(GetFocus() == mdi_frame
, "wrong focus window %p\n", GetFocus());
3099 trace("creating MDI client window\n");
3100 client_cs
.hWindowMenu
= 0;
3101 client_cs
.idFirstChild
= MDI_FIRST_CHILD_ID
;
3102 mdi_client
= CreateWindowExA(0, "MDI_client_class",
3104 WS_CHILD
| WS_VISIBLE
| MDIS_ALLCHILDSTYLES
,
3106 mdi_frame
, 0, GetModuleHandleA(0), &client_cs
);
3108 ok_sequence(WmCreateMDIclientSeq
, "Create visible MDI client window", FALSE
);
3110 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3111 ok(GetFocus() == mdi_frame
, "input focus should be on MDI frame not on %p\n", GetFocus());
3113 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3114 ok(!active_child
, "wrong active MDI child %p\n", active_child
);
3115 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
3120 trace("creating invisible MDI child window\n");
3121 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3123 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
3124 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3128 ShowWindow(mdi_child
, SW_SHOWNORMAL
);
3129 ok_sequence(WmShowChildSeq
, "ShowWindow(SW_SHOWNORMAL) MDI child window", FALSE
);
3131 ok(GetWindowLongA(mdi_child
, GWL_STYLE
) & WS_VISIBLE
, "MDI child should be visible\n");
3132 ok(IsWindowVisible(mdi_child
), "MDI child should be visible\n");
3134 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3135 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3137 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3138 ok(!active_child
, "wrong active MDI child %p\n", active_child
);
3139 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
3141 ShowWindow(mdi_child
, SW_HIDE
);
3142 ok_sequence(WmHideChildSeq
, "ShowWindow(SW_HIDE) MDI child window", FALSE
);
3145 ShowWindow(mdi_child
, SW_SHOW
);
3146 ok_sequence(WmShowChildSeq
, "ShowWindow(SW_SHOW) MDI child window", FALSE
);
3148 ok(GetWindowLongA(mdi_child
, GWL_STYLE
) & WS_VISIBLE
, "MDI child should be visible\n");
3149 ok(IsWindowVisible(mdi_child
), "MDI child should be visible\n");
3151 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3152 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3154 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3155 ok(!active_child
, "wrong active MDI child %p\n", active_child
);
3156 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
3158 DestroyWindow(mdi_child
);
3161 trace("creating visible MDI child window\n");
3162 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3163 WS_CHILD
| WS_VISIBLE
,
3164 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
3165 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3167 ok_sequence(WmCreateMDIchildVisibleSeq
, "Create visible MDI child window", FALSE
);
3169 ok(GetWindowLongA(mdi_child
, GWL_STYLE
) & WS_VISIBLE
, "MDI child should be visible\n");
3170 ok(IsWindowVisible(mdi_child
), "MDI child should be visible\n");
3172 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3173 ok(GetFocus() == mdi_child
, "wrong focus window %p\n", GetFocus());
3175 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3176 ok(active_child
== mdi_child
, "wrong active MDI child %p\n", active_child
);
3177 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
3180 DestroyWindow(mdi_child
);
3181 ok_sequence(WmDestroyMDIchildVisibleSeq
, "Destroy visible MDI child window", TRUE
);
3183 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3184 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3186 /* Win2k: MDI client still returns a just destroyed child as active
3187 * Win9x: MDI client returns 0
3189 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3190 ok(active_child
== mdi_child
|| /* win2k */
3191 !active_child
, /* win9x */
3192 "wrong active MDI child %p\n", active_child
);
3193 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
3197 trace("creating invisible MDI child window\n");
3198 mdi_child2
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3200 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
3201 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3203 ok_sequence(WmCreateMDIchildInvisibleSeq
, "Create invisible MDI child window", FALSE
);
3205 ok(!(GetWindowLongA(mdi_child2
, GWL_STYLE
) & WS_VISIBLE
), "MDI child should not be visible\n");
3206 ok(!IsWindowVisible(mdi_child2
), "MDI child should not be visible\n");
3208 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3209 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3211 /* Win2k: MDI client still returns a just destroyed child as active
3212 * Win9x: MDI client returns mdi_child2
3214 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3215 ok(active_child
== mdi_child
|| /* win2k */
3216 active_child
== mdi_child2
, /* win9x */
3217 "wrong active MDI child %p\n", active_child
);
3218 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
3221 ShowWindow(mdi_child2
, SW_MAXIMIZE
);
3222 ok_sequence(WmMaximizeMDIchildInvisibleSeq
, "ShowWindow(SW_MAXIMIZE):invisible MDI child", FALSE
);
3224 ok(GetWindowLongA(mdi_child2
, GWL_STYLE
) & WS_VISIBLE
, "MDI child should be visible\n");
3225 ok(IsWindowVisible(mdi_child2
), "MDI child should be visible\n");
3227 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3228 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
3229 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
3232 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3233 ok(GetFocus() == mdi_child2
|| /* win2k */
3234 GetFocus() == 0, /* win9x */
3235 "wrong focus window %p\n", GetFocus());
3240 ShowWindow(mdi_child2
, SW_HIDE
);
3241 ok_sequence(WmHideChildSeq
, "ShowWindow(SW_HIDE):MDI child", FALSE
);
3243 ShowWindow(mdi_child2
, SW_RESTORE
);
3244 ok_sequence(WmRestoreMDIchildInisibleSeq
, "ShowWindow(SW_RESTORE):invisible MDI child", FALSE
);
3247 ok(GetWindowLongA(mdi_child2
, GWL_STYLE
) & WS_VISIBLE
, "MDI child should be visible\n");
3248 ok(IsWindowVisible(mdi_child2
), "MDI child should be visible\n");
3250 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3251 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
3252 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
3258 ShowWindow(mdi_child2
, SW_HIDE
);
3259 ok_sequence(WmHideChildSeq
, "ShowWindow(SW_HIDE):MDI child", FALSE
);
3261 ShowWindow(mdi_child2
, SW_SHOW
);
3262 ok_sequence(WmShowChildSeq
, "ShowWindow(SW_SHOW):MDI child", FALSE
);
3264 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3265 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3267 ShowWindow(mdi_child2
, SW_MAXIMIZE
);
3268 ok_sequence(WmMaximizeMDIchildVisibleSeq
, "ShowWindow(SW_MAXIMIZE):MDI child", FALSE
);
3270 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3271 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3273 ShowWindow(mdi_child2
, SW_RESTORE
);
3274 ok_sequence(WmRestoreMDIchildVisibleSeq
, "ShowWindow(SW_RESTORE):maximized MDI child", FALSE
);
3276 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3277 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3279 ShowWindow(mdi_child2
, SW_MINIMIZE
);
3280 ok_sequence(WmMinimizeMDIchildVisibleSeq
, "ShowWindow(SW_MINIMIZE):MDI child", TRUE
);
3282 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3283 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3285 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3286 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
3287 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
3290 ShowWindow(mdi_child2
, SW_RESTORE
);
3291 ok_sequence(WmRestoreMDIchildVisibleSeq_2
, "ShowWindow(SW_RESTORE):minimized MDI child", TRUE
);
3293 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3294 ok(GetFocus() == mdi_child2
, "wrong focus window %p\n", GetFocus());
3296 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3297 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
3298 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
3304 ShowWindow(mdi_child2
, SW_HIDE
);
3305 ok_sequence(WmHideChildSeq
, "ShowWindow(SW_HIDE):MDI child", FALSE
);
3307 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3308 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3310 DestroyWindow(mdi_child2
);
3311 ok_sequence(WmDestroyMDIchildInvisibleSeq
, "Destroy invisible MDI child window", FALSE
);
3313 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3314 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3316 /* test for maximized MDI children */
3317 trace("creating maximized visible MDI child window 1\n");
3318 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3319 WS_CHILD
| WS_VISIBLE
| WS_MAXIMIZEBOX
| WS_MAXIMIZE
,
3320 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
3321 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3323 ok_sequence(WmCreateMDIchildVisibleMaxSeq1
, "Create maximized visible 1st MDI child window", TRUE
);
3324 ok(IsZoomed(mdi_child
), "1st MDI child should be maximized\n");
3326 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3327 ok(GetFocus() == mdi_child
|| /* win2k */
3328 GetFocus() == 0, /* win9x */
3329 "wrong focus window %p\n", GetFocus());
3331 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3332 ok(active_child
== mdi_child
, "wrong active MDI child %p\n", active_child
);
3333 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
3336 trace("creating maximized visible MDI child window 2\n");
3337 mdi_child2
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3338 WS_CHILD
| WS_VISIBLE
| WS_MAXIMIZEBOX
| WS_MAXIMIZE
,
3339 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
3340 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3342 ok_sequence(WmCreateMDIchildVisibleMaxSeq2
, "Create maximized visible 2nd MDI child 2 window", TRUE
);
3343 ok(IsZoomed(mdi_child2
), "2nd MDI child should be maximized\n");
3344 ok(!IsZoomed(mdi_child
), "1st MDI child should NOT be maximized\n");
3346 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3347 ok(GetFocus() == mdi_child2
, "wrong focus window %p\n", GetFocus());
3349 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3350 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
3351 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
3354 trace("destroying maximized visible MDI child window 2\n");
3355 DestroyWindow(mdi_child2
);
3356 ok_sequence(WmDestroyMDIchildVisibleSeq
, "Destroy visible MDI child window", TRUE
);
3358 ok(!IsZoomed(mdi_child
), "1st MDI child should NOT be maximized\n");
3360 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3361 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3363 /* Win2k: MDI client still returns a just destroyed child as active
3364 * Win9x: MDI client returns 0
3366 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3367 ok(active_child
== mdi_child2
|| /* win2k */
3368 !active_child
, /* win9x */
3369 "wrong active MDI child %p\n", active_child
);
3372 ShowWindow(mdi_child
, SW_MAXIMIZE
);
3373 ok(IsZoomed(mdi_child
), "1st MDI child should be maximized\n");
3376 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3377 ok(GetFocus() == mdi_child
, "wrong focus window %p\n", GetFocus());
3379 trace("re-creating maximized visible MDI child window 2\n");
3380 mdi_child2
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3381 WS_CHILD
| WS_VISIBLE
| WS_MAXIMIZEBOX
| WS_MAXIMIZE
,
3382 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
3383 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3385 ok_sequence(WmCreateMDIchildVisibleMaxSeq2
, "Create maximized visible 2nd MDI child 2 window", TRUE
);
3386 ok(IsZoomed(mdi_child2
), "2nd MDI child should be maximized\n");
3387 ok(!IsZoomed(mdi_child
), "1st MDI child should NOT be maximized\n");
3389 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3390 ok(GetFocus() == mdi_child2
, "wrong focus window %p\n", GetFocus());
3392 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3393 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
3394 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
3397 SendMessageA(mdi_child2
, WM_SYSCOMMAND
, SC_CLOSE
, 0);
3398 ok_sequence(WmDestroyMDIchildVisibleMaxSeq2
, "WM_SYSCOMMAND/SC_CLOSE on a visible maximized MDI child window", TRUE
);
3399 ok(!IsWindow(mdi_child2
), "MDI child 2 should be destroyed\n");
3401 ok(IsZoomed(mdi_child
), "1st MDI child should be maximized\n");
3402 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3403 ok(GetFocus() == mdi_child
, "wrong focus window %p\n", GetFocus());
3405 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3406 ok(active_child
== mdi_child
, "wrong active MDI child %p\n", active_child
);
3407 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
3410 DestroyWindow(mdi_child
);
3411 ok_sequence(WmDestroyMDIchildVisibleSeq
, "Destroy visible MDI child window", TRUE
);
3413 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3414 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3416 /* Win2k: MDI client still returns a just destroyed child as active
3417 * Win9x: MDI client returns 0
3419 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3420 ok(active_child
== mdi_child
|| /* win2k */
3421 !active_child
, /* win9x */
3422 "wrong active MDI child %p\n", active_child
);
3425 trace("creating maximized invisible MDI child window\n");
3426 mdi_child2
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3427 WS_CHILD
| WS_MAXIMIZE
| WS_CAPTION
| WS_THICKFRAME
,
3428 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
3429 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3431 ok_sequence(WmCreateMDIchildInvisibleMaxSeq4
, "Create maximized invisible MDI child window", FALSE
);
3432 ok(IsZoomed(mdi_child2
), "MDI child should be maximized\n");
3433 ok(!(GetWindowLongA(mdi_child2
, GWL_STYLE
) & WS_VISIBLE
), "MDI child should be not visible\n");
3434 ok(!IsWindowVisible(mdi_child2
), "MDI child should be not visible\n");
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("call ShowWindow(mdi_child, SW_MAXIMIZE)\n");
3446 ShowWindow(mdi_child2
, SW_MAXIMIZE
);
3447 ok_sequence(WmMaximizeMDIchildInvisibleSeq2
, "ShowWindow(SW_MAXIMIZE):invisible maximized MDI child", FALSE
);
3448 ok(IsZoomed(mdi_child2
), "MDI child should be maximized\n");
3449 ok(GetWindowLongA(mdi_child2
, GWL_STYLE
) & WS_VISIBLE
, "MDI child should be visible\n");
3450 ok(IsWindowVisible(mdi_child2
), "MDI child should be visible\n");
3452 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3453 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
3454 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
3457 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child2
, 0);
3460 /* end of test for maximized MDI children */
3463 trace("creating maximized visible MDI child window 1(Switch test)\n");
3464 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3465 WS_CHILD
| WS_VISIBLE
| WS_MAXIMIZEBOX
| WS_MAXIMIZE
,
3466 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
3467 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3469 ok_sequence(WmCreateMDIchildVisibleMaxSeq1
, "Create maximized visible 1st MDI child window(Switch test)", TRUE
);
3470 ok(IsZoomed(mdi_child
), "1st MDI child should be maximized(Switch test)\n");
3472 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p(Switch test)\n", GetActiveWindow());
3473 ok(GetFocus() == mdi_child
|| /* win2k */
3474 GetFocus() == 0, /* win9x */
3475 "wrong focus window %p(Switch test)\n", GetFocus());
3477 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3478 ok(active_child
== mdi_child
, "wrong active MDI child %p(Switch test)\n", active_child
);
3479 ok(zoomed
, "wrong zoomed state %d(Switch test)\n", zoomed
);
3482 trace("creating maximized visible MDI child window 2(Switch test)\n");
3483 mdi_child2
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3484 WS_CHILD
| WS_VISIBLE
| WS_MAXIMIZEBOX
| WS_MAXIMIZE
,
3485 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
3486 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3488 ok_sequence(WmCreateMDIchildVisibleMaxSeq2
, "Create maximized visible 2nd MDI child window (Switch test)", TRUE
);
3490 ok(IsZoomed(mdi_child2
), "2nd MDI child should be maximized(Switch test)\n");
3491 ok(!IsZoomed(mdi_child
), "1st MDI child should NOT be maximized(Switch test)\n");
3493 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p(Switch test)\n", GetActiveWindow());
3494 ok(GetFocus() == mdi_child2
, "wrong focus window %p(Switch test)\n", GetFocus());
3496 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3497 ok(active_child
== mdi_child2
, "wrong active MDI child %p(Switch test)\n", active_child
);
3498 ok(zoomed
, "wrong zoomed state %d(Switch test)\n", zoomed
);
3501 trace("Switch child window.\n");
3502 SendMessageA(mdi_client
, WM_MDIACTIVATE
, (WPARAM
)mdi_child
, 0);
3503 ok_sequence(WmSwitchChild
, "Child did not switch correctly", TRUE
);
3504 trace("end of test for switch maximized MDI children\n");
3507 /* Prepare for switching test of not maximized MDI children */
3508 ShowWindow( mdi_child
, SW_NORMAL
);
3509 ok(!IsZoomed(mdi_child
), "wrong zoomed state for %p(Switch test)\n", mdi_child
);
3510 ok(!IsZoomed(mdi_child2
), "wrong zoomed state for %p(Switch test)\n", mdi_child2
);
3511 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, 0);
3512 ok(active_child
== mdi_child
, "wrong active MDI child %p(Switch test)\n", active_child
);
3515 SendMessageA(mdi_client
, WM_MDIACTIVATE
, (WPARAM
)mdi_child2
, 0);
3516 ok_sequence(WmSwitchNotMaximizedChild
, "Not maximized child did not switch correctly", FALSE
);
3517 trace("end of test for switch not maximized MDI children\n");
3520 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
3523 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child2
, 0);
3528 /* end of tests for switch maximized/not maximized MDI children */
3530 mdi_cs
.szClass
= "MDI_child_Class";
3531 mdi_cs
.szTitle
= "MDI child";
3532 mdi_cs
.hOwner
= GetModuleHandleA(0);
3535 mdi_cs
.cx
= CW_USEDEFAULT
;
3536 mdi_cs
.cy
= CW_USEDEFAULT
;
3537 mdi_cs
.style
= WS_CHILD
| WS_SYSMENU
| WS_VISIBLE
| WS_MAXIMIZEBOX
| WS_MAXIMIZE
;
3539 mdi_child
= (HWND
)SendMessageA(mdi_client
, WM_MDICREATE
, 0, (LPARAM
)&mdi_cs
);
3540 ok(mdi_child
!= 0, "MDI child creation failed\n");
3541 ok_sequence(WmCreateMDIchildVisibleMaxSeq3
, "WM_MDICREATE for maximized visible MDI child window", TRUE
);
3543 ok(GetMenuItemID(hMenu
, GetMenuItemCount(hMenu
) - 1) == SC_CLOSE
, "SC_CLOSE menu item not found\n");
3545 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3546 ok(active_child
== mdi_child
, "wrong active MDI child %p\n", active_child
);
3548 ok(IsZoomed(mdi_child
), "MDI child should be maximized\n");
3549 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3550 ok(GetFocus() == mdi_child
, "wrong focus window %p\n", GetFocus());
3552 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3553 ok(active_child
== mdi_child
, "wrong active MDI child %p\n", active_child
);
3554 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
3557 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
3558 ok_sequence(WmDestroyMDIchildVisibleMaxSeq1
, "Destroy visible maximized MDI child window", TRUE
);
3560 ok(!IsWindow(mdi_child
), "MDI child should be destroyed\n");
3561 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3562 ok(!active_child
, "wrong active MDI child %p\n", active_child
);
3567 DestroyWindow(mdi_client
);
3568 ok_sequence(WmDestroyMDIclientSeq
, "Destroy MDI client window", FALSE
);
3570 /* test maximization of MDI child with invisible parent */
3571 client_cs
.hWindowMenu
= 0;
3572 mdi_client
= CreateWindow("MDI_client_class",
3574 WS_CHILD
| WS_CLIPCHILDREN
| WS_VSCROLL
| WS_HSCROLL
| WS_VISIBLE
,
3576 mdi_frame
, 0, GetModuleHandleA(0), &client_cs
);
3577 ok_sequence(WmCreateMDIclientSeq
, "Create MDI client window", FALSE
);
3579 ShowWindow(mdi_client
, SW_HIDE
);
3580 ok_sequence(WmHideMDIclientSeq
, "Hide MDI client window", FALSE
);
3582 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3583 WS_CHILD
| WS_CLIPCHILDREN
| WS_VSCROLL
| WS_HSCROLL
,
3585 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3586 ok_sequence(WmCreateMDIchildInvisibleParentSeq
, "Create MDI child window with invisible parent", FALSE
);
3588 SendMessage(mdi_client
, WM_MDIMAXIMIZE
, (WPARAM
) mdi_child
, 0);
3589 ok_sequence(WmMaximizeMDIchildInvisibleParentSeq
, "Maximize MDI child window with invisible parent", TRUE
);
3590 zoomed
= IsZoomed(mdi_child
);
3591 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
3593 ShowWindow(mdi_client
, SW_SHOW
);
3594 ok_sequence(WmShowMDIclientSeq
, "Show MDI client window", FALSE
);
3596 DestroyWindow(mdi_child
);
3597 ok_sequence(WmDestroyMDIchildVisibleSeq
, "Destroy visible maximized MDI child window", TRUE
);
3599 /* end of test for maximization of MDI child with invisible parent */
3601 DestroyWindow(mdi_client
);
3602 ok_sequence(WmDestroyMDIclientSeq
, "Destroy MDI client window", FALSE
);
3604 DestroyWindow(mdi_frame
);
3605 ok_sequence(WmDestroyMDIframeSeq
, "Destroy MDI frame window", FALSE
);
3607 /************************* End of MDI test **********************************/
3609 static void test_WM_SETREDRAW(HWND hwnd
)
3611 DWORD style
= GetWindowLongA(hwnd
, GWL_STYLE
);
3616 SendMessageA(hwnd
, WM_SETREDRAW
, FALSE
, 0);
3617 ok_sequence(WmSetRedrawFalseSeq
, "SetRedraw:FALSE", FALSE
);
3619 ok(!(GetWindowLongA(hwnd
, GWL_STYLE
) & WS_VISIBLE
), "WS_VISIBLE should NOT be set\n");
3620 ok(!IsWindowVisible(hwnd
), "IsWindowVisible() should return FALSE\n");
3623 SendMessageA(hwnd
, WM_SETREDRAW
, TRUE
, 0);
3624 ok_sequence(WmSetRedrawTrueSeq
, "SetRedraw:TRUE", FALSE
);
3626 ok(GetWindowLongA(hwnd
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
3627 ok(IsWindowVisible(hwnd
), "IsWindowVisible() should return TRUE\n");
3629 /* restore original WS_VISIBLE state */
3630 SetWindowLongA(hwnd
, GWL_STYLE
, style
);
3636 static INT_PTR CALLBACK
TestModalDlgProcA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
3640 trace("dialog: %p, %04x, %08lx, %08lx\n", hwnd
, message
, wParam
, lParam
);
3642 /* explicitly ignore WM_GETICON message */
3643 if (message
== WM_GETICON
) return 0;
3645 /* ignore registered messages */
3646 if (message
>= 0xc000) return 0;
3653 case WM_DEVICECHANGE
:
3658 case WM_WINDOWPOSCHANGING
:
3659 case WM_WINDOWPOSCHANGED
:
3661 WINDOWPOS
*winpos
= (WINDOWPOS
*)lParam
;
3663 trace("%s\n", (message
== WM_WINDOWPOSCHANGING
) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
3664 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x ",
3665 winpos
->hwnd
, winpos
->hwndInsertAfter
,
3666 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
3667 dump_winpos_flags(winpos
->flags
);
3669 /* Log only documented flags, win2k uses 0x1000 and 0x2000
3670 * in the high word for internal purposes
3672 wParam
= winpos
->flags
& 0xffff;
3673 /* We are not interested in the flags that don't match under XP and Win9x */
3674 wParam
&= ~(SWP_NOZORDER
);
3679 msg
.message
= message
;
3680 msg
.flags
= sent
|wparam
|lparam
;
3681 msg
.wParam
= wParam
;
3682 msg
.lParam
= lParam
;
3685 if (message
== WM_INITDIALOG
) SetTimer( hwnd
, 1, 100, NULL
);
3686 if (message
== WM_TIMER
) EndDialog( hwnd
, 0 );
3690 static void test_hv_scroll_1(HWND hwnd
, INT ctl
, DWORD clear
, DWORD set
, INT min
, INT max
)
3692 DWORD style
, exstyle
;
3696 exstyle
= GetWindowLongA(hwnd
, GWL_EXSTYLE
);
3697 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
3698 /* do not be confused by WS_DLGFRAME set */
3699 if ((style
& WS_CAPTION
) == WS_CAPTION
) style
&= ~WS_CAPTION
;
3701 if (clear
) ok(style
& clear
, "style %08x should be set\n", clear
);
3702 if (set
) ok(!(style
& set
), "style %08x should not be set\n", set
);
3704 ret
= SetScrollRange(hwnd
, ctl
, min
, max
, FALSE
);
3705 ok( ret
, "SetScrollRange(%d) error %d\n", ctl
, GetLastError());
3706 if ((style
& (WS_DLGFRAME
| WS_BORDER
| WS_THICKFRAME
)) || (exstyle
& WS_EX_DLGMODALFRAME
))
3707 ok_sequence(WmSetScrollRangeHV_NC_Seq
, "SetScrollRange(SB_HORZ/SB_VERT) NC", FALSE
);
3709 ok_sequence(WmSetScrollRangeHVSeq
, "SetScrollRange(SB_HORZ/SB_VERT)", FALSE
);
3711 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
3712 if (set
) ok(style
& set
, "style %08x should be set\n", set
);
3713 if (clear
) ok(!(style
& clear
), "style %08x should not be set\n", clear
);
3715 /* a subsequent call should do nothing */
3716 ret
= SetScrollRange(hwnd
, ctl
, min
, max
, FALSE
);
3717 ok( ret
, "SetScrollRange(%d) error %d\n", ctl
, GetLastError());
3718 ok_sequence(WmEmptySeq
, "SetScrollRange(SB_HORZ/SB_VERT) empty sequence", FALSE
);
3722 trace("Ignore GetScrollRange error below if you are on Win9x\n");
3723 ret
= GetScrollRange(hwnd
, ctl
, &xmin
, &xmax
);
3724 ok( ret
, "GetScrollRange(%d) error %d\n", ctl
, GetLastError());
3725 ok_sequence(WmEmptySeq
, "GetScrollRange(SB_HORZ/SB_VERT) empty sequence", FALSE
);
3726 ok(xmin
== min
, "unexpected min scroll value %d\n", xmin
);
3727 ok(xmax
== max
, "unexpected max scroll value %d\n", xmax
);
3730 static void test_hv_scroll_2(HWND hwnd
, INT ctl
, DWORD clear
, DWORD set
, INT min
, INT max
)
3732 DWORD style
, exstyle
;
3736 exstyle
= GetWindowLongA(hwnd
, GWL_EXSTYLE
);
3737 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
3738 /* do not be confused by WS_DLGFRAME set */
3739 if ((style
& WS_CAPTION
) == WS_CAPTION
) style
&= ~WS_CAPTION
;
3741 if (clear
) ok(style
& clear
, "style %08x should be set\n", clear
);
3742 if (set
) ok(!(style
& set
), "style %08x should not be set\n", set
);
3744 si
.cbSize
= sizeof(si
);
3745 si
.fMask
= SIF_RANGE
;
3748 SetScrollInfo(hwnd
, ctl
, &si
, TRUE
);
3749 if ((style
& (WS_DLGFRAME
| WS_BORDER
| WS_THICKFRAME
)) || (exstyle
& WS_EX_DLGMODALFRAME
))
3750 ok_sequence(WmSetScrollRangeHV_NC_Seq
, "SetScrollInfo(SB_HORZ/SB_VERT) NC", FALSE
);
3752 ok_sequence(WmSetScrollRangeHVSeq
, "SetScrollInfo(SB_HORZ/SB_VERT)", FALSE
);
3754 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
3755 if (set
) ok(style
& set
, "style %08x should be set\n", set
);
3756 if (clear
) ok(!(style
& clear
), "style %08x should not be set\n", clear
);
3758 /* a subsequent call should do nothing */
3759 SetScrollInfo(hwnd
, ctl
, &si
, TRUE
);
3760 if (style
& WS_HSCROLL
)
3761 ok_sequence(WmSetScrollRangeHSeq_empty
, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE
);
3762 else if (style
& WS_VSCROLL
)
3763 ok_sequence(WmSetScrollRangeVSeq_empty
, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE
);
3765 ok_sequence(WmEmptySeq
, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE
);
3767 si
.fMask
= SIF_PAGE
;
3769 SetScrollInfo(hwnd
, ctl
, &si
, FALSE
);
3770 ok_sequence(WmEmptySeq
, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE
);
3774 SetScrollInfo(hwnd
, ctl
, &si
, FALSE
);
3775 ok_sequence(WmEmptySeq
, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE
);
3777 si
.fMask
= SIF_RANGE
;
3778 si
.nMin
= 0xdeadbeef;
3779 si
.nMax
= 0xdeadbeef;
3780 ret
= GetScrollInfo(hwnd
, ctl
, &si
);
3781 ok( ret
, "GetScrollInfo error %d\n", GetLastError());
3782 ok_sequence(WmEmptySeq
, "GetScrollRange(SB_HORZ/SB_VERT) empty sequence", FALSE
);
3783 ok(si
.nMin
== min
, "unexpected min scroll value %d\n", si
.nMin
);
3784 ok(si
.nMax
== max
, "unexpected max scroll value %d\n", si
.nMax
);
3787 /* Win9x sends WM_USER+xxx while and NT versions send SBM_xxx messages */
3788 static void test_scroll_messages(HWND hwnd
)
3799 ret
= GetScrollRange(hwnd
, SB_CTL
, &min
, &max
);
3800 ok( ret
, "GetScrollRange error %d\n", GetLastError());
3801 if (sequence
->message
!= WmGetScrollRangeSeq
[0].message
)
3802 trace("GetScrollRange(SB_CTL) generated unknown message %04x\n", sequence
->message
);
3803 /* values of min and max are undefined */
3806 ret
= SetScrollRange(hwnd
, SB_CTL
, 10, 150, FALSE
);
3807 ok( ret
, "SetScrollRange error %d\n", GetLastError());
3808 if (sequence
->message
!= WmSetScrollRangeSeq
[0].message
)
3809 trace("SetScrollRange(SB_CTL) generated unknown message %04x\n", sequence
->message
);
3814 ret
= GetScrollRange(hwnd
, SB_CTL
, &min
, &max
);
3815 ok( ret
, "GetScrollRange error %d\n", GetLastError());
3816 if (sequence
->message
!= WmGetScrollRangeSeq
[0].message
)
3817 trace("GetScrollRange(SB_CTL) generated unknown message %04x\n", sequence
->message
);
3818 /* values of min and max are undefined */
3821 si
.cbSize
= sizeof(si
);
3822 si
.fMask
= SIF_RANGE
;
3825 SetScrollInfo(hwnd
, SB_CTL
, &si
, FALSE
);
3826 if (sequence
->message
!= WmSetScrollRangeSeq
[0].message
)
3827 trace("SetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence
->message
);
3830 si
.fMask
= SIF_PAGE
;
3832 SetScrollInfo(hwnd
, SB_CTL
, &si
, FALSE
);
3833 if (sequence
->message
!= WmSetScrollRangeSeq
[0].message
)
3834 trace("SetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence
->message
);
3839 SetScrollInfo(hwnd
, SB_CTL
, &si
, FALSE
);
3840 if (sequence
->message
!= WmSetScrollRangeSeq
[0].message
)
3841 trace("SetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence
->message
);
3844 si
.fMask
= SIF_RANGE
;
3845 si
.nMin
= 0xdeadbeef;
3846 si
.nMax
= 0xdeadbeef;
3847 ret
= GetScrollInfo(hwnd
, SB_CTL
, &si
);
3848 ok( ret
, "GetScrollInfo error %d\n", GetLastError());
3849 if (sequence
->message
!= WmGetScrollInfoSeq
[0].message
)
3850 trace("GetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence
->message
);
3851 /* values of min and max are undefined */
3854 /* set WS_HSCROLL */
3855 test_hv_scroll_1(hwnd
, SB_HORZ
, 0, WS_HSCROLL
, 10, 150);
3856 /* clear WS_HSCROLL */
3857 test_hv_scroll_1(hwnd
, SB_HORZ
, WS_HSCROLL
, 0, 0, 0);
3859 /* set WS_HSCROLL */
3860 test_hv_scroll_2(hwnd
, SB_HORZ
, 0, WS_HSCROLL
, 10, 150);
3861 /* clear WS_HSCROLL */
3862 test_hv_scroll_2(hwnd
, SB_HORZ
, WS_HSCROLL
, 0, 0, 0);
3864 /* set WS_VSCROLL */
3865 test_hv_scroll_1(hwnd
, SB_VERT
, 0, WS_VSCROLL
, 10, 150);
3866 /* clear WS_VSCROLL */
3867 test_hv_scroll_1(hwnd
, SB_VERT
, WS_VSCROLL
, 0, 0, 0);
3869 /* set WS_VSCROLL */
3870 test_hv_scroll_2(hwnd
, SB_VERT
, 0, WS_VSCROLL
, 10, 150);
3871 /* clear WS_VSCROLL */
3872 test_hv_scroll_2(hwnd
, SB_VERT
, WS_VSCROLL
, 0, 0, 0);
3875 static void test_showwindow(void)
3880 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW
,
3881 100, 100, 200, 200, 0, 0, 0, NULL
);
3882 ok (hwnd
!= 0, "Failed to create overlapped window\n");
3883 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
3884 0, 0, 10, 10, hwnd
, 0, 0, NULL
);
3885 ok (hchild
!= 0, "Failed to create child\n");
3888 /* ShowWindow( SW_SHOWNA) for invisible top level window */
3889 trace("calling ShowWindow( SW_SHOWNA) for invisible top level window\n");
3890 ok( ShowWindow(hwnd
, SW_SHOWNA
) == FALSE
, "ShowWindow: window was visible\n" );
3891 ok_sequence(WmSHOWNATopInvisible
, "ShowWindow(SW_SHOWNA) on invisible top level window", TRUE
);
3894 /* ShowWindow( SW_SHOWNA) for now visible top level window */
3895 trace("calling ShowWindow( SW_SHOWNA) for now visible top level window\n");
3896 ok( ShowWindow(hwnd
, SW_SHOWNA
) != FALSE
, "ShowWindow: window was invisible\n" );
3897 ok_sequence(WmSHOWNATopVisible
, "ShowWindow(SW_SHOWNA) on visible top level window", FALSE
);
3899 /* back to invisible */
3900 ShowWindow(hchild
, SW_HIDE
);
3901 ShowWindow(hwnd
, SW_HIDE
);
3903 /* ShowWindow(SW_SHOWNA) with child and parent invisible */
3904 trace("calling ShowWindow( SW_SHOWNA) for invisible child with invisible parent\n");
3905 ok( ShowWindow(hchild
, SW_SHOWNA
) == FALSE
, "ShowWindow: window was visible\n" );
3906 ok_sequence(WmSHOWNAChildInvisParInvis
, "ShowWindow(SW_SHOWNA) invisible child and parent", FALSE
);
3908 /* ShowWindow(SW_SHOWNA) with child visible and parent invisible */
3909 ok( ShowWindow(hchild
, SW_SHOW
) != FALSE
, "ShowWindow: window was invisible\n" );
3911 trace("calling ShowWindow( SW_SHOWNA) for the visible child and invisible parent\n");
3912 ok( ShowWindow(hchild
, SW_SHOWNA
) != FALSE
, "ShowWindow: window was invisible\n" );
3913 ok_sequence(WmSHOWNAChildVisParInvis
, "ShowWindow(SW_SHOWNA) visible child and invisible parent", FALSE
);
3915 /* ShowWindow(SW_SHOWNA) with child visible and parent visible */
3916 ShowWindow( hwnd
, SW_SHOW
);
3918 trace("calling ShowWindow( SW_SHOWNA) for the visible child and parent\n");
3919 ok( ShowWindow(hchild
, SW_SHOWNA
) != FALSE
, "ShowWindow: window was invisible\n" );
3920 ok_sequence(WmSHOWNAChildVisParVis
, "ShowWindow(SW_SHOWNA) for the visible child and parent", FALSE
);
3923 /* ShowWindow(SW_SHOWNA) with child invisible and parent visible */
3924 ShowWindow( hchild
, SW_HIDE
);
3926 trace("calling ShowWindow( SW_SHOWNA) for the invisible child and visible parent\n");
3927 ok( ShowWindow(hchild
, SW_SHOWNA
) == FALSE
, "ShowWindow: window was visible\n" );
3928 ok_sequence(WmSHOWNAChildInvisParVis
, "ShowWindow(SW_SHOWNA) for the invisible child and visible parent", FALSE
);
3932 ok(GetCapture() == hchild
, "wrong capture window %p\n", GetCapture());
3933 DestroyWindow(hchild
);
3934 ok(!GetCapture(), "wrong capture window %p\n", GetCapture());
3936 DestroyWindow(hwnd
);
3941 * 1. Create invisible maximized popup window.
3942 * 2. Move and resize it.
3943 * 3. Show it maximized.
3945 trace("calling CreateWindowExA( WS_MAXIMIZE ) for invisible maximized popup window\n");
3946 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP
| WS_MAXIMIZE
,
3947 100, 100, 200, 200, 0, 0, 0, NULL
);
3948 ok (hwnd
!= 0, "Failed to create popup window\n");
3949 ok(IsZoomed(hwnd
), "window should be maximized\n");
3950 ok_sequence(WmCreateInvisibleMaxPopupSeq
, "CreateWindow(WS_MAXIMIZED):popup", FALSE
);
3953 GetWindowRect(hwnd
, &rc
);
3954 ok( rc
.right
-rc
.left
== GetSystemMetrics(SM_CXSCREEN
) &&
3955 rc
.bottom
-rc
.top
== GetSystemMetrics(SM_CYSCREEN
),
3956 "Invalid maximized size before ShowWindow (%d,%d)-(%d,%d)\n",
3957 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
3958 /* Reset window's size & position */
3959 SetWindowPos(hwnd
, 0, 10, 10, 200, 200, SWP_NOZORDER
| SWP_NOACTIVATE
);
3960 ok(IsZoomed(hwnd
), "window should be maximized\n");
3963 trace("calling ShowWindow( SW_SHOWMAXIMIZE ) for invisible maximized popup window\n");
3964 ShowWindow(hwnd
, SW_SHOWMAXIMIZED
);
3965 ok(IsZoomed(hwnd
), "window should be maximized\n");
3966 ok_sequence(WmShowMaxPopupResizedSeq
, "ShowWindow(SW_SHOWMAXIMIZED):invisible maximized and resized popup", FALSE
);
3969 GetWindowRect(hwnd
, &rc
);
3970 ok( rc
.right
-rc
.left
== GetSystemMetrics(SM_CXSCREEN
) &&
3971 rc
.bottom
-rc
.top
== GetSystemMetrics(SM_CYSCREEN
),
3972 "Invalid maximized size after ShowWindow (%d,%d)-(%d,%d)\n",
3973 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
3974 DestroyWindow(hwnd
);
3978 * 1. Create invisible maximized popup window.
3979 * 2. Show it maximized.
3981 trace("calling CreateWindowExA( WS_MAXIMIZE ) for invisible maximized popup window\n");
3982 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP
| WS_MAXIMIZE
,
3983 100, 100, 200, 200, 0, 0, 0, NULL
);
3984 ok (hwnd
!= 0, "Failed to create popup window\n");
3985 ok(IsZoomed(hwnd
), "window should be maximized\n");
3986 ok_sequence(WmCreateInvisibleMaxPopupSeq
, "CreateWindow(WS_MAXIMIZED):popup", FALSE
);
3989 trace("calling ShowWindow( SW_SHOWMAXIMIZE ) for invisible maximized popup window\n");
3990 ShowWindow(hwnd
, SW_SHOWMAXIMIZED
);
3991 ok(IsZoomed(hwnd
), "window should be maximized\n");
3992 ok_sequence(WmShowMaxPopupSeq
, "ShowWindow(SW_SHOWMAXIMIZED):invisible maximized popup", FALSE
);
3994 DestroyWindow(hwnd
);
3998 * 1. Create visible maximized popup window.
4000 trace("calling CreateWindowExA( WS_MAXIMIZE ) for maximized popup window\n");
4001 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP
| WS_MAXIMIZE
| WS_VISIBLE
,
4002 100, 100, 200, 200, 0, 0, 0, NULL
);
4003 ok (hwnd
!= 0, "Failed to create popup window\n");
4004 ok(IsZoomed(hwnd
), "window should be maximized\n");
4005 ok_sequence(WmCreateMaxPopupSeq
, "CreateWindow(WS_MAXIMIZED):popup", FALSE
);
4007 DestroyWindow(hwnd
);
4011 * 1. Create visible popup window.
4014 trace("calling CreateWindowExA( WS_VISIBLE ) for popup window\n");
4015 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP
| WS_VISIBLE
,
4016 100, 100, 200, 200, 0, 0, 0, NULL
);
4017 ok (hwnd
!= 0, "Failed to create popup window\n");
4018 ok(!IsZoomed(hwnd
), "window should NOT be maximized\n");
4019 ok_sequence(WmCreatePopupSeq
, "CreateWindow(WS_VISIBLE):popup", FALSE
);
4022 trace("calling ShowWindow( SW_SHOWMAXIMIZE ) for visible popup window\n");
4023 ShowWindow(hwnd
, SW_SHOWMAXIMIZED
);
4024 ok(IsZoomed(hwnd
), "window should be maximized\n");
4025 ok_sequence(WmShowVisMaxPopupSeq
, "ShowWindow(SW_SHOWMAXIMIZED):popup", FALSE
);
4027 DestroyWindow(hwnd
);
4031 static void test_sys_menu(void)
4037 hwnd
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
4038 100, 100, 200, 200, 0, 0, 0, NULL
);
4039 ok (hwnd
!= 0, "Failed to create overlapped window\n");
4043 /* test existing window without CS_NOCLOSE style */
4044 hmenu
= GetSystemMenu(hwnd
, FALSE
);
4045 ok(hmenu
!= 0, "GetSystemMenu error %d\n", GetLastError());
4047 state
= GetMenuState(hmenu
, SC_CLOSE
, MF_BYCOMMAND
);
4048 ok(state
!= 0xffffffff, "wrong SC_CLOSE state %x\n", state
);
4049 ok(!(state
& (MF_DISABLED
| MF_GRAYED
)), "wrong SC_CLOSE state %x\n", state
);
4051 EnableMenuItem(hmenu
, SC_CLOSE
, MF_BYCOMMAND
| MF_GRAYED
);
4052 ok_sequence(WmEmptySeq
, "WmEnableMenuItem", FALSE
);
4054 state
= GetMenuState(hmenu
, SC_CLOSE
, MF_BYCOMMAND
);
4055 ok(state
!= 0xffffffff, "wrong SC_CLOSE state %x\n", state
);
4056 ok((state
& (MF_DISABLED
| MF_GRAYED
)) == MF_GRAYED
, "wrong SC_CLOSE state %x\n", state
);
4058 EnableMenuItem(hmenu
, SC_CLOSE
, 0);
4059 ok_sequence(WmEmptySeq
, "WmEnableMenuItem", FALSE
);
4061 state
= GetMenuState(hmenu
, SC_CLOSE
, MF_BYCOMMAND
);
4062 ok(state
!= 0xffffffff, "wrong SC_CLOSE state %x\n", state
);
4063 ok(!(state
& (MF_DISABLED
| MF_GRAYED
)), "wrong SC_CLOSE state %x\n", state
);
4065 /* test whether removing WS_SYSMENU destroys a system menu */
4066 SetWindowLongW(hwnd
, GWL_STYLE
, WS_POPUP
);
4067 SetWindowPos(hwnd
, 0, 0, 0, 0, 0, SWP_NOZORDER
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_FRAMECHANGED
);
4069 hmenu
= GetSystemMenu(hwnd
, FALSE
);
4070 ok(hmenu
!= 0, "GetSystemMenu error %d\n", GetLastError());
4072 DestroyWindow(hwnd
);
4074 /* test new window with CS_NOCLOSE style */
4075 hwnd
= CreateWindowExA(0, "NoCloseWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
4076 100, 100, 200, 200, 0, 0, 0, NULL
);
4077 ok (hwnd
!= 0, "Failed to create overlapped window\n");
4079 hmenu
= GetSystemMenu(hwnd
, FALSE
);
4080 ok(hmenu
!= 0, "GetSystemMenu error %d\n", GetLastError());
4082 state
= GetMenuState(hmenu
, SC_CLOSE
, MF_BYCOMMAND
);
4083 ok(state
== 0xffffffff, "wrong SC_CLOSE state %x\n", state
);
4085 DestroyWindow(hwnd
);
4087 /* test new window without WS_SYSMENU style */
4088 hwnd
= CreateWindowExA(0, "NoCloseWindowClass", NULL
, WS_OVERLAPPEDWINDOW
& ~WS_SYSMENU
,
4089 100, 100, 200, 200, 0, 0, 0, NULL
);
4090 ok(hwnd
!= 0, "Failed to create overlapped window\n");
4092 hmenu
= GetSystemMenu(hwnd
, FALSE
);
4093 ok(!hmenu
, "GetSystemMenu error %d\n", GetLastError());
4095 DestroyWindow(hwnd
);
4098 /* For shown WS_OVERLAPPEDWINDOW */
4099 static const struct message WmSetIcon_1
[] = {
4100 { WM_SETICON
, sent
},
4101 { 0x00AE, sent
|defwinproc
|optional
}, /* XP */
4102 { WM_GETTEXT
, sent
|defwinproc
|optional
},
4103 { WM_GETTEXT
, sent
|defwinproc
|optional
}, /* XP sends a duplicate */
4107 /* For WS_POPUP and hidden WS_OVERLAPPEDWINDOW */
4108 static const struct message WmSetIcon_2
[] = {
4109 { WM_SETICON
, sent
},
4113 /* Sending undocumented 0x3B message with wparam = 0x8000000b */
4114 static const struct message WmInitEndSession
[] = {
4116 { WM_QUERYENDSESSION
, sent
|defwinproc
|wparam
|lparam
, 0, ENDSESSION_LOGOFF
},
4120 /* Sending undocumented 0x3B message with wparam = 0x0000000b */
4121 static const struct message WmInitEndSession_2
[] = {
4123 { WM_QUERYENDSESSION
, sent
|defwinproc
|wparam
|lparam
, 0, 0 },
4127 /* Sending undocumented 0x3B message with wparam = 0x80000008 */
4128 static const struct message WmInitEndSession_3
[] = {
4130 { WM_ENDSESSION
, sent
|defwinproc
|wparam
|lparam
, 0, ENDSESSION_LOGOFF
},
4134 /* Sending undocumented 0x3B message with wparam = 0x00000008 */
4135 static const struct message WmInitEndSession_4
[] = {
4137 { WM_ENDSESSION
, sent
|defwinproc
|wparam
|lparam
, 0, 0 },
4141 /* Sending undocumented 0x3B message with wparam = 0x80000001 */
4142 static const struct message WmInitEndSession_5
[] = {
4144 { WM_ENDSESSION
, sent
|defwinproc
/*|wparam*/|lparam
, 1, ENDSESSION_LOGOFF
},
4148 static const struct message WmZOrder
[] = {
4149 { WM_WINDOWPOSCHANGING
, sent
|wparam
, 0, 0 },
4150 { WM_GETMINMAXINFO
, sent
|defwinproc
|wparam
, 0, 0 },
4151 { HCBT_ACTIVATE
, hook
},
4152 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
4153 { WM_WINDOWPOSCHANGING
, sent
|wparam
, 3, 0 },
4154 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOREDRAW
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
, 0 },
4155 { WM_GETTEXT
, sent
|optional
},
4156 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
4157 { WM_ACTIVATEAPP
, sent
|wparam
, 1, 0 },
4158 { WM_NCACTIVATE
, sent
|wparam
|lparam
, 1, 0 },
4159 { WM_GETTEXT
, sent
|defwinproc
|optional
},
4160 { WM_GETTEXT
, sent
|defwinproc
|optional
},
4161 { WM_ACTIVATE
, sent
|wparam
|lparam
, 1, 0 },
4162 { HCBT_SETFOCUS
, hook
},
4163 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
4164 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
4165 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
4166 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
4167 { WM_GETTEXT
, sent
|optional
},
4168 { WM_NCCALCSIZE
, sent
|optional
},
4172 static void test_MsgWaitForMultipleObjects(HWND hwnd
)
4177 ret
= MsgWaitForMultipleObjects(0, NULL
, FALSE
, 0, QS_POSTMESSAGE
);
4178 ok(ret
== WAIT_TIMEOUT
, "MsgWaitForMultipleObjects returned %x\n", ret
);
4180 PostMessageA(hwnd
, WM_USER
, 0, 0);
4182 ret
= MsgWaitForMultipleObjects(0, NULL
, FALSE
, 0, QS_POSTMESSAGE
);
4183 ok(ret
== WAIT_OBJECT_0
, "MsgWaitForMultipleObjects returned %x\n", ret
);
4185 ok(PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
), "PeekMessage should succeed\n");
4186 ok(msg
.message
== WM_USER
, "got %04x instead of WM_USER\n", msg
.message
);
4188 ret
= MsgWaitForMultipleObjects(0, NULL
, FALSE
, 0, QS_POSTMESSAGE
);
4189 ok(ret
== WAIT_TIMEOUT
, "MsgWaitForMultipleObjects returned %x\n", ret
);
4191 PostMessageA(hwnd
, WM_USER
, 0, 0);
4193 ret
= MsgWaitForMultipleObjects(0, NULL
, FALSE
, 0, QS_POSTMESSAGE
);
4194 ok(ret
== WAIT_OBJECT_0
, "MsgWaitForMultipleObjects returned %x\n", ret
);
4196 ok(PeekMessageA( &msg
, 0, 0, 0, PM_NOREMOVE
), "PeekMessage should succeed\n");
4197 ok(msg
.message
== WM_USER
, "got %04x instead of WM_USER\n", msg
.message
);
4199 /* shows QS_POSTMESSAGE flag is cleared in the PeekMessage call */
4200 ret
= MsgWaitForMultipleObjects(0, NULL
, FALSE
, 0, QS_POSTMESSAGE
);
4201 ok(ret
== WAIT_TIMEOUT
, "MsgWaitForMultipleObjects returned %x\n", ret
);
4203 PostMessageA(hwnd
, WM_USER
, 0, 0);
4205 /* new incoming message causes it to become signaled again */
4206 ret
= MsgWaitForMultipleObjects(0, NULL
, FALSE
, 0, QS_POSTMESSAGE
);
4207 ok(ret
== WAIT_OBJECT_0
, "MsgWaitForMultipleObjects returned %x\n", ret
);
4209 ok(PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
), "PeekMessage should succeed\n");
4210 ok(msg
.message
== WM_USER
, "got %04x instead of WM_USER\n", msg
.message
);
4211 ok(PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
), "PeekMessage should succeed\n");
4212 ok(msg
.message
== WM_USER
, "got %04x instead of WM_USER\n", msg
.message
);
4215 /* test if we receive the right sequence of messages */
4216 static void test_messages(void)
4218 HWND hwnd
, hparent
, hchild
;
4219 HWND hchild2
, hbutton
;
4226 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW
,
4227 100, 100, 200, 200, 0, 0, 0, NULL
);
4228 ok (hwnd
!= 0, "Failed to create overlapped window\n");
4229 ok_sequence(WmCreateOverlappedSeq
, "CreateWindow:overlapped", FALSE
);
4231 /* test ShowWindow(SW_HIDE) on a newly created invisible window */
4232 ok( ShowWindow(hwnd
, SW_HIDE
) == FALSE
, "ShowWindow: window was visible\n" );
4233 ok_sequence(WmEmptySeq
, "ShowWindow(SW_HIDE):overlapped, invisible", FALSE
);
4235 /* test WM_SETREDRAW on a not visible top level window */
4236 test_WM_SETREDRAW(hwnd
);
4238 SetWindowPos(hwnd
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
);
4240 ok_sequence(WmSWP_ShowOverlappedSeq
, "SetWindowPos:SWP_SHOWWINDOW:overlapped", FALSE
);
4241 ok(IsWindowVisible(hwnd
), "window should be visible at this point\n");
4243 ok(GetActiveWindow() == hwnd
, "window should be active\n");
4244 ok(GetFocus() == hwnd
, "window should have input focus\n");
4245 ShowWindow(hwnd
, SW_HIDE
);
4247 ok_sequence(WmHideOverlappedSeq
, "ShowWindow(SW_HIDE):overlapped", FALSE
);
4249 ShowWindow(hwnd
, SW_SHOW
);
4251 ok_sequence(WmShowOverlappedSeq
, "ShowWindow(SW_SHOW):overlapped", TRUE
);
4253 ShowWindow(hwnd
, SW_HIDE
);
4255 ok_sequence(WmHideOverlappedSeq
, "ShowWindow(SW_HIDE):overlapped", FALSE
);
4257 ShowWindow(hwnd
, SW_SHOWMAXIMIZED
);
4259 ok_sequence(WmShowMaxOverlappedSeq
, "ShowWindow(SW_SHOWMAXIMIZED):overlapped", TRUE
);
4261 ShowWindow(hwnd
, SW_RESTORE
);
4262 ok_sequence(WmShowRestoreMaxOverlappedSeq
, "ShowWindow(SW_RESTORE):overlapped", FALSE
);
4266 ShowWindow(hwnd
, SW_MINIMIZE
);
4268 ok_sequence(WmShowMinOverlappedSeq
, "ShowWindow(SW_SHOWMINIMIZED):overlapped", TRUE
);
4271 ShowWindow(hwnd
, SW_RESTORE
);
4273 ok_sequence(WmShowRestoreMinOverlappedSeq
, "ShowWindow(SW_RESTORE):overlapped", TRUE
);
4276 ShowWindow(hwnd
, SW_SHOW
);
4278 ok_sequence(WmEmptySeq
, "ShowWindow(SW_SHOW):overlapped already visible", FALSE
);
4280 ok(GetActiveWindow() == hwnd
, "window should be active\n");
4281 ok(GetFocus() == hwnd
, "window should have input focus\n");
4282 SetWindowPos(hwnd
, 0,0,0,0,0, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
);
4283 ok_sequence(WmSWP_HideOverlappedSeq
, "SetWindowPos:SWP_HIDEWINDOW:overlapped", FALSE
);
4284 ok(!IsWindowVisible(hwnd
), "window should not be visible at this point\n");
4285 ok(GetActiveWindow() == hwnd
, "window should still be active\n");
4287 /* test WM_SETREDRAW on a visible top level window */
4288 ShowWindow(hwnd
, SW_SHOW
);
4290 test_WM_SETREDRAW(hwnd
);
4292 trace("testing scroll APIs on a visible top level window %p\n", hwnd
);
4293 test_scroll_messages(hwnd
);
4295 /* test resizing and moving */
4296 SetWindowPos( hwnd
, 0, 0, 0, 300, 300, SWP_NOMOVE
|SWP_NOACTIVATE
);
4297 ok_sequence(WmSWP_ResizeSeq
, "SetWindowPos:Resize", FALSE
);
4300 SetWindowPos( hwnd
, 0, 200, 200, 0, 0, SWP_NOSIZE
|SWP_NOACTIVATE
);
4301 ok_sequence(WmSWP_MoveSeq
, "SetWindowPos:Move", FALSE
);
4304 SetWindowPos( hwnd
, 0, 200, 200, 250, 250, SWP_NOZORDER
|SWP_NOACTIVATE
);
4305 ok_sequence(WmSWP_ResizeNoZOrder
, "SetWindowPos:WmSWP_ResizeNoZOrder", FALSE
);
4309 /* popups don't get WM_GETMINMAXINFO */
4310 SetWindowLongW( hwnd
, GWL_STYLE
, WS_VISIBLE
|WS_POPUP
);
4311 SetWindowPos( hwnd
, 0, 0, 0, 0, 0, SWP_NOZORDER
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_FRAMECHANGED
);
4313 SetWindowPos( hwnd
, 0, 0, 0, 200, 200, SWP_NOMOVE
|SWP_NOACTIVATE
);
4314 ok_sequence(WmSWP_ResizePopupSeq
, "SetWindowPos:ResizePopup", FALSE
);
4316 DestroyWindow(hwnd
);
4317 ok_sequence(WmDestroyOverlappedSeq
, "DestroyWindow:overlapped", FALSE
);
4319 hparent
= CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
4320 100, 100, 200, 200, 0, 0, 0, NULL
);
4321 ok (hparent
!= 0, "Failed to create parent window\n");
4324 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
| WS_MAXIMIZE
,
4325 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4326 ok (hchild
!= 0, "Failed to create child window\n");
4327 ok_sequence(WmCreateMaximizedChildSeq
, "CreateWindow:maximized child", FALSE
);
4328 DestroyWindow(hchild
);
4331 /* visible child window with a caption */
4332 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child",
4333 WS_CHILD
| WS_VISIBLE
| WS_CAPTION
,
4334 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4335 ok (hchild
!= 0, "Failed to create child window\n");
4336 ok_sequence(WmCreateVisibleChildSeq
, "CreateWindow:visible child", FALSE
);
4338 trace("testing scroll APIs on a visible child window %p\n", hchild
);
4339 test_scroll_messages(hchild
);
4341 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
);
4342 ok_sequence(WmShowChildSeq_4
, "SetWindowPos(SWP_SHOWWINDOW):child with a caption", FALSE
);
4344 DestroyWindow(hchild
);
4347 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
4348 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4349 ok (hchild
!= 0, "Failed to create child window\n");
4350 ok_sequence(WmCreateChildSeq
, "CreateWindow:child", FALSE
);
4352 hchild2
= CreateWindowExA(0, "SimpleWindowClass", "Test child2", WS_CHILD
,
4353 100, 100, 50, 50, hparent
, 0, 0, NULL
);
4354 ok (hchild2
!= 0, "Failed to create child2 window\n");
4357 hbutton
= CreateWindowExA(0, "TestWindowClass", "Test button", WS_CHILD
,
4358 0, 100, 50, 50, hchild
, 0, 0, NULL
);
4359 ok (hbutton
!= 0, "Failed to create button window\n");
4361 /* test WM_SETREDRAW on a not visible child window */
4362 test_WM_SETREDRAW(hchild
);
4364 ShowWindow(hchild
, SW_SHOW
);
4365 ok_sequence(WmShowChildSeq
, "ShowWindow(SW_SHOW):child", FALSE
);
4367 /* check parent messages too */
4368 log_all_parent_messages
++;
4369 ShowWindow(hchild
, SW_HIDE
);
4370 ok_sequence(WmHideChildSeq2
, "ShowWindow(SW_HIDE):child", FALSE
);
4371 log_all_parent_messages
--;
4373 ShowWindow(hchild
, SW_SHOW
);
4374 ok_sequence(WmShowChildSeq
, "ShowWindow(SW_SHOW):child", FALSE
);
4376 ShowWindow(hchild
, SW_HIDE
);
4377 ok_sequence(WmHideChildSeq
, "ShowWindow(SW_HIDE):child", FALSE
);
4379 ShowWindow(hchild
, SW_SHOW
);
4380 ok_sequence(WmShowChildSeq
, "ShowWindow(SW_SHOW):child", FALSE
);
4382 /* test WM_SETREDRAW on a visible child window */
4383 test_WM_SETREDRAW(hchild
);
4385 log_all_parent_messages
++;
4386 MoveWindow(hchild
, 10, 10, 20, 20, TRUE
);
4387 ok_sequence(WmResizingChildWithMoveWindowSeq
, "MoveWindow:child", FALSE
);
4388 log_all_parent_messages
--;
4390 ShowWindow(hchild
, SW_HIDE
);
4392 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
);
4393 ok_sequence(WmShowChildSeq_2
, "SetWindowPos:show_child_2", FALSE
);
4395 ShowWindow(hchild
, SW_HIDE
);
4397 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
);
4398 ok_sequence(WmShowChildSeq_3
, "SetWindowPos:show_child_3", FALSE
);
4400 /* DestroyWindow sequence below expects that a child has focus */
4404 DestroyWindow(hchild
);
4405 ok_sequence(WmDestroyChildSeq
, "DestroyWindow:child", FALSE
);
4406 DestroyWindow(hchild2
);
4407 DestroyWindow(hbutton
);
4410 hchild
= CreateWindowExA(0, "TestWindowClass", "Test Child Popup", WS_CHILD
| WS_POPUP
,
4411 0, 0, 100, 100, hparent
, 0, 0, NULL
);
4412 ok (hchild
!= 0, "Failed to create child popup window\n");
4413 ok_sequence(WmCreateChildPopupSeq
, "CreateWindow:child_popup", FALSE
);
4414 DestroyWindow(hchild
);
4416 /* test what happens to a window which sets WS_VISIBLE in WM_CREATE */
4418 hchild
= CreateWindowExA(0, "TestPopupClass", "Test Popup", WS_POPUP
,
4419 0, 0, 100, 100, hparent
, 0, 0, NULL
);
4420 ok (hchild
!= 0, "Failed to create popup window\n");
4421 ok_sequence(WmCreateInvisiblePopupSeq
, "CreateWindow:invisible_popup", FALSE
);
4422 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
4423 ok(IsWindowVisible(hchild
), "IsWindowVisible() should return TRUE\n");
4425 ShowWindow(hchild
, SW_SHOW
);
4426 ok_sequence(WmEmptySeq
, "ShowWindow:show_visible_popup", FALSE
);
4428 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOZORDER
);
4429 ok_sequence(WmShowVisiblePopupSeq_2
, "SetWindowPos:show_visible_popup_2", FALSE
);
4431 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
);
4432 ok_sequence(WmShowVisiblePopupSeq_3
, "SetWindowPos:show_visible_popup_3", FALSE
);
4433 DestroyWindow(hchild
);
4435 /* this time add WS_VISIBLE for CreateWindowEx, but this fact actually
4436 * changes nothing in message sequences.
4439 hchild
= CreateWindowExA(0, "TestPopupClass", "Test Popup", WS_POPUP
| WS_VISIBLE
,
4440 0, 0, 100, 100, hparent
, 0, 0, NULL
);
4441 ok (hchild
!= 0, "Failed to create popup window\n");
4442 ok_sequence(WmCreateInvisiblePopupSeq
, "CreateWindow:invisible_popup", FALSE
);
4443 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
4444 ok(IsWindowVisible(hchild
), "IsWindowVisible() should return TRUE\n");
4446 ShowWindow(hchild
, SW_SHOW
);
4447 ok_sequence(WmEmptySeq
, "ShowWindow:show_visible_popup", FALSE
);
4449 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOZORDER
);
4450 ok_sequence(WmShowVisiblePopupSeq_2
, "SetWindowPos:show_visible_popup_2", FALSE
);
4451 DestroyWindow(hchild
);
4454 hwnd
= CreateWindowExA(WS_EX_DLGMODALFRAME
, "TestDialogClass", NULL
, WS_VISIBLE
|WS_CAPTION
|WS_SYSMENU
|WS_DLGFRAME
,
4455 0, 0, 100, 100, hparent
, 0, 0, NULL
);
4456 ok(hwnd
!= 0, "Failed to create custom dialog window\n");
4457 ok_sequence(WmCreateCustomDialogSeq
, "CreateCustomDialog", TRUE
);
4460 trace("testing scroll APIs on a visible dialog %p\n", hwnd);
4461 test_scroll_messages(hwnd);
4467 SendMessage(hwnd
, WM_NULL
, 0, 0);
4470 after_end_dialog
= 1;
4471 EndDialog( hwnd
, 0 );
4472 ok_sequence(WmEndCustomDialogSeq
, "EndCustomDialog", FALSE
);
4474 DestroyWindow(hwnd
);
4475 after_end_dialog
= 0;
4478 hwnd
= CreateWindowExA(0, "TestDialogClass", NULL
, WS_POPUP
,
4479 0, 0, 100, 100, 0, 0, GetModuleHandleA(0), NULL
);
4480 ok(hwnd
!= 0, "Failed to create custom dialog window\n");
4482 trace("call ShowWindow(%p, SW_SHOW)\n", hwnd
);
4483 ShowWindow(hwnd
, SW_SHOW
);
4484 ok_sequence(WmShowCustomDialogSeq
, "ShowCustomDialog", TRUE
);
4485 DestroyWindow(hwnd
);
4488 DialogBoxA( 0, "TEST_DIALOG", hparent
, TestModalDlgProcA
);
4489 ok_sequence(WmModalDialogSeq
, "ModalDialog", TRUE
);
4491 DestroyWindow(hparent
);
4494 /* Message sequence for SetMenu */
4495 ok(!DrawMenuBar(hwnd
), "DrawMenuBar should return FALSE for a window without a menu\n");
4496 ok_sequence(WmEmptySeq
, "DrawMenuBar for a window without a menu", FALSE
);
4498 hmenu
= CreateMenu();
4499 ok (hmenu
!= 0, "Failed to create menu\n");
4500 ok (InsertMenuA(hmenu
, -1, MF_BYPOSITION
, 0x1000, "foo"), "InsertMenu failed\n");
4501 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW
,
4502 100, 100, 200, 200, 0, hmenu
, 0, NULL
);
4503 ok_sequence(WmCreateOverlappedSeq
, "CreateWindow:overlapped", FALSE
);
4504 ok (SetMenu(hwnd
, 0), "SetMenu\n");
4505 ok_sequence(WmSetMenuNonVisibleSizeChangeSeq
, "SetMenu:NonVisibleSizeChange", FALSE
);
4506 ok (SetMenu(hwnd
, 0), "SetMenu\n");
4507 ok_sequence(WmSetMenuNonVisibleNoSizeChangeSeq
, "SetMenu:NonVisibleNoSizeChange", FALSE
);
4508 ShowWindow(hwnd
, SW_SHOW
);
4509 UpdateWindow( hwnd
);
4512 ok (SetMenu(hwnd
, 0), "SetMenu\n");
4513 ok_sequence(WmSetMenuVisibleNoSizeChangeSeq
, "SetMenu:VisibleNoSizeChange", FALSE
);
4514 ok (SetMenu(hwnd
, hmenu
), "SetMenu\n");
4515 ok_sequence(WmSetMenuVisibleSizeChangeSeq
, "SetMenu:VisibleSizeChange", FALSE
);
4517 UpdateWindow( hwnd
);
4520 ok(DrawMenuBar(hwnd
), "DrawMenuBar\n");
4522 ok_sequence(WmDrawMenuBarSeq
, "DrawMenuBar", FALSE
);
4524 DestroyWindow(hwnd
);
4527 /* Message sequence for EnableWindow */
4528 hparent
= CreateWindowExA(0, "TestWindowClass", "Test parent", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
4529 100, 100, 200, 200, 0, 0, 0, NULL
);
4530 ok (hparent
!= 0, "Failed to create parent window\n");
4531 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
| WS_VISIBLE
,
4532 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4533 ok (hchild
!= 0, "Failed to create child window\n");
4539 EnableWindow(hparent
, FALSE
);
4540 ok_sequence(WmEnableWindowSeq_1
, "EnableWindow(FALSE)", FALSE
);
4542 EnableWindow(hparent
, TRUE
);
4543 ok_sequence(WmEnableWindowSeq_2
, "EnableWindow(TRUE)", FALSE
);
4548 test_MsgWaitForMultipleObjects(hparent
);
4550 /* the following test causes an exception in user.exe under win9x */
4551 if (!PostMessageW( hparent
, WM_USER
, 0, 0 ))
4553 DestroyWindow(hparent
);
4557 PostMessageW( hparent
, WM_USER
+1, 0, 0 );
4558 /* PeekMessage(NULL) fails, but still removes the message */
4559 SetLastError(0xdeadbeef);
4560 ok( !PeekMessageW( NULL
, 0, 0, 0, PM_REMOVE
), "PeekMessage(NULL) should fail\n" );
4561 ok( GetLastError() == ERROR_NOACCESS
|| /* Win2k */
4562 GetLastError() == 0xdeadbeef, /* NT4 */
4563 "last error is %d\n", GetLastError() );
4564 ok( PeekMessageW( &msg
, 0, 0, 0, PM_REMOVE
), "PeekMessage should succeed\n" );
4565 ok( msg
.message
== WM_USER
+1, "got %x instead of WM_USER+1\n", msg
.message
);
4567 DestroyWindow(hchild
);
4568 DestroyWindow(hparent
);
4571 /* Message sequences for WM_SETICON */
4572 trace("testing WM_SETICON\n");
4573 hwnd
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
4574 CW_USEDEFAULT
, CW_USEDEFAULT
, 300, 300, 0,
4576 ShowWindow(hwnd
, SW_SHOW
);
4580 SendMessage(hwnd
, WM_SETICON
, ICON_SMALL
, (LPARAM
)LoadIcon(0, IDI_APPLICATION
));
4581 ok_sequence(WmSetIcon_1
, "WM_SETICON for shown window with caption", FALSE
);
4583 ShowWindow(hwnd
, SW_HIDE
);
4586 SendMessage(hwnd
, WM_SETICON
, ICON_SMALL
, (LPARAM
)LoadIcon(0, IDI_APPLICATION
));
4587 ok_sequence(WmSetIcon_2
, "WM_SETICON for hidden window with caption", FALSE
);
4588 DestroyWindow(hwnd
);
4591 hwnd
= CreateWindowExA(0, "TestPopupClass", NULL
, WS_POPUP
,
4592 CW_USEDEFAULT
, CW_USEDEFAULT
, 300, 300, 0,
4594 ShowWindow(hwnd
, SW_SHOW
);
4598 SendMessage(hwnd
, WM_SETICON
, ICON_SMALL
, (LPARAM
)LoadIcon(0, IDI_APPLICATION
));
4599 ok_sequence(WmSetIcon_2
, "WM_SETICON for shown window without caption", FALSE
);
4601 ShowWindow(hwnd
, SW_HIDE
);
4604 SendMessage(hwnd
, WM_SETICON
, ICON_SMALL
, (LPARAM
)LoadIcon(0, IDI_APPLICATION
));
4605 ok_sequence(WmSetIcon_2
, "WM_SETICON for hidden window without caption", FALSE
);
4608 res
= SendMessage(hwnd
, 0x3B, 0x8000000b, 0);
4611 todo_wine
win_skip( "Message 0x3b not supported\n" );
4614 ok_sequence(WmInitEndSession
, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x8000000b", TRUE
);
4615 ok(res
== 1, "SendMessage(hwnd, 0x3B, 0x8000000b, 0) should have returned 1 instead of %ld\n", res
);
4616 res
= SendMessage(hwnd
, 0x3B, 0x0000000b, 0);
4617 ok_sequence(WmInitEndSession_2
, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x0000000b", TRUE
);
4618 ok(res
== 1, "SendMessage(hwnd, 0x3B, 0x0000000b, 0) should have returned 1 instead of %ld\n", res
);
4619 res
= SendMessage(hwnd
, 0x3B, 0x0000000f, 0);
4620 ok_sequence(WmInitEndSession_2
, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x0000000f", TRUE
);
4621 ok(res
== 1, "SendMessage(hwnd, 0x3B, 0x0000000f, 0) should have returned 1 instead of %ld\n", res
);
4624 res
= SendMessage(hwnd
, 0x3B, 0x80000008, 0);
4625 ok_sequence(WmInitEndSession_3
, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x80000008", TRUE
);
4626 ok(res
== 2, "SendMessage(hwnd, 0x3B, 0x80000008, 0) should have returned 2 instead of %ld\n", res
);
4627 res
= SendMessage(hwnd
, 0x3B, 0x00000008, 0);
4628 ok_sequence(WmInitEndSession_4
, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x00000008", TRUE
);
4629 ok(res
== 2, "SendMessage(hwnd, 0x3B, 0x00000008, 0) should have returned 2 instead of %ld\n", res
);
4631 res
= SendMessage(hwnd
, 0x3B, 0x80000004, 0);
4632 ok_sequence(WmInitEndSession_3
, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x80000004", TRUE
);
4633 ok(res
== 2, "SendMessage(hwnd, 0x3B, 0x80000004, 0) should have returned 2 instead of %ld\n", res
);
4635 res
= SendMessage(hwnd
, 0x3B, 0x80000001, 0);
4636 ok_sequence(WmInitEndSession_5
, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x80000001", TRUE
);
4637 ok(res
== 2, "SendMessage(hwnd, 0x3B, 0x80000001, 0) should have returned 2 instead of %ld\n", res
);
4640 DestroyWindow(hwnd
);
4644 static void test_setwindowpos(void)
4649 const INT winX
= 100;
4650 const INT winY
= 100;
4651 const INT sysX
= GetSystemMetrics(SM_CXMINTRACK
);
4653 hwnd
= CreateWindowExA(0, "TestWindowClass", NULL
, 0,
4654 0, 0, winX
, winY
, 0,
4657 GetWindowRect(hwnd
, &rc
);
4658 expect(sysX
, rc
.right
);
4659 expect(winY
, rc
.bottom
);
4663 res
= SetWindowPos(hwnd
, HWND_TOPMOST
, 0, 0, winX
, winY
, 0);
4664 ok_sequence(WmZOrder
, "Z-Order", TRUE
);
4665 ok(res
== TRUE
, "SetWindowPos expected TRUE, got %ld\n", res
);
4667 GetWindowRect(hwnd
, &rc
);
4668 expect(sysX
, rc
.right
);
4669 expect(winY
, rc
.bottom
);
4670 DestroyWindow(hwnd
);
4673 static void invisible_parent_tests(void)
4675 HWND hparent
, hchild
;
4677 hparent
= CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW
,
4678 100, 100, 200, 200, 0, 0, 0, NULL
);
4679 ok (hparent
!= 0, "Failed to create parent window\n");
4682 /* test showing child with hidden parent */
4684 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
4685 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4686 ok (hchild
!= 0, "Failed to create child window\n");
4687 ok_sequence(WmCreateChildSeq
, "CreateWindow:child", FALSE
);
4689 ShowWindow( hchild
, SW_MINIMIZE
);
4690 ok_sequence(WmShowChildInvisibleParentSeq_1
, "ShowWindow(SW_MINIMIZE) child with invisible parent", FALSE
);
4691 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
4692 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
4697 ShowWindow( hchild
, SW_MINIMIZE
);
4698 ok_sequence(WmShowChildInvisibleParentSeq_1r
, "ShowWindow(SW_MINIMIZE) child with invisible parent", FALSE
);
4700 DestroyWindow(hchild
);
4701 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
4702 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4705 ShowWindow( hchild
, SW_MAXIMIZE
);
4706 ok_sequence(WmShowChildInvisibleParentSeq_2
, "ShowWindow(SW_MAXIMIZE) child with invisible parent", FALSE
);
4707 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
4708 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
4713 ShowWindow( hchild
, SW_MAXIMIZE
);
4714 ok_sequence(WmShowChildInvisibleParentSeq_2r
, "ShowWindow(SW_MAXIMIZE) child with invisible parent", FALSE
);
4716 DestroyWindow(hchild
);
4717 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
4718 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4721 ShowWindow( hchild
, SW_RESTORE
);
4722 ok_sequence(WmShowChildInvisibleParentSeq_5
, "ShowWindow(SW_RESTORE) child with invisible parent", FALSE
);
4723 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
4724 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
4726 DestroyWindow(hchild
);
4727 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
4728 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4731 ShowWindow( hchild
, SW_SHOWMINIMIZED
);
4732 ok_sequence(WmShowChildInvisibleParentSeq_3
, "ShowWindow(SW_SHOWMINIMIZED) child with invisible parent", FALSE
);
4733 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
4734 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
4739 ShowWindow( hchild
, SW_SHOWMINIMIZED
);
4740 ok_sequence(WmShowChildInvisibleParentSeq_3r
, "ShowWindow(SW_SHOWMINIMIZED) child with invisible parent", FALSE
);
4742 DestroyWindow(hchild
);
4743 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
4744 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4747 /* same as ShowWindow( hchild, SW_MAXIMIZE ); */
4748 ShowWindow( hchild
, SW_SHOWMAXIMIZED
);
4749 ok_sequence(WmShowChildInvisibleParentSeq_2
, "ShowWindow(SW_SHOWMAXIMIZED) child with invisible parent", FALSE
);
4750 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
4751 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
4753 DestroyWindow(hchild
);
4754 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
4755 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4758 ShowWindow( hchild
, SW_SHOWMINNOACTIVE
);
4759 ok_sequence(WmShowChildInvisibleParentSeq_4
, "ShowWindow(SW_SHOWMINNOACTIVE) child with invisible parent", FALSE
);
4760 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
4761 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
4766 ShowWindow( hchild
, SW_SHOWMINNOACTIVE
);
4767 ok_sequence(WmShowChildInvisibleParentSeq_4r
, "ShowWindow(SW_SHOWMINNOACTIVE) child with invisible parent", FALSE
);
4769 DestroyWindow(hchild
);
4770 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
4771 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4774 /* FIXME: looks like XP SP2 doesn't know about SW_FORCEMINIMIZE at all */
4775 ShowWindow( hchild
, SW_FORCEMINIMIZE
);
4776 ok_sequence(WmEmptySeq
, "ShowWindow(SW_FORCEMINIMIZE) child with invisible parent", TRUE
);
4778 ok(!(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
), "WS_VISIBLE should be not set\n");
4780 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
4782 DestroyWindow(hchild
);
4783 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
4784 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4787 ShowWindow( hchild
, SW_SHOWNA
);
4788 ok_sequence(WmShowChildInvisibleParentSeq_5
, "ShowWindow(SW_SHOWNA) child with invisible parent", FALSE
);
4789 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
4790 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
4795 ShowWindow( hchild
, SW_SHOWNA
);
4796 ok_sequence(WmShowChildInvisibleParentSeq_5
, "ShowWindow(SW_SHOWNA) child with invisible parent", FALSE
);
4798 DestroyWindow(hchild
);
4799 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
4800 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4803 ShowWindow( hchild
, SW_SHOW
);
4804 ok_sequence(WmShowChildInvisibleParentSeq_5
, "ShowWindow(SW_SHOW) child with invisible parent", FALSE
);
4805 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
4806 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
4811 ShowWindow( hchild
, SW_SHOW
);
4812 ok_sequence(WmEmptySeq
, "ShowWindow(SW_SHOW) child with invisible parent", FALSE
);
4814 ShowWindow( hchild
, SW_HIDE
);
4815 ok_sequence(WmHideChildInvisibleParentSeq
, "ShowWindow:hide child with invisible parent", FALSE
);
4816 ok(!(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
), "WS_VISIBLE should be not set\n");
4817 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
4819 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOZORDER
);
4820 ok_sequence(WmShowChildInvisibleParentSeq_6
, "SetWindowPos:show child with invisible parent", FALSE
);
4821 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
4822 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
4824 SetWindowPos(hchild
, 0,0,0,0,0, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOZORDER
);
4825 ok_sequence(WmHideChildInvisibleParentSeq_2
, "SetWindowPos:hide child with invisible parent", FALSE
);
4826 ok(!(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
), "WS_VISIBLE should not be set\n");
4827 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
4829 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOZORDER
);
4831 DestroyWindow(hchild
);
4832 ok_sequence(WmDestroyInvisibleChildSeq
, "DestroyInvisibleChildSeq", FALSE
);
4834 DestroyWindow(hparent
);
4838 /****************** button message test *************************/
4839 static const struct message WmSetFocusButtonSeq
[] =
4841 { HCBT_SETFOCUS
, hook
},
4842 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
4843 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
4844 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
4845 { WM_SETFOCUS
, sent
|wparam
, 0 },
4846 { WM_CTLCOLORBTN
, sent
|defwinproc
},
4849 static const struct message WmKillFocusButtonSeq
[] =
4851 { HCBT_SETFOCUS
, hook
},
4852 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
4853 { WM_KILLFOCUS
, sent
|wparam
, 0 },
4854 { WM_CTLCOLORBTN
, sent
|defwinproc
},
4855 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
4856 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 1 },
4859 static const struct message WmSetFocusStaticSeq
[] =
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_CTLCOLORSTATIC
, sent
|defwinproc
},
4869 static const struct message WmKillFocusStaticSeq
[] =
4871 { HCBT_SETFOCUS
, hook
},
4872 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
4873 { WM_KILLFOCUS
, sent
|wparam
, 0 },
4874 { WM_CTLCOLORSTATIC
, sent
|defwinproc
},
4875 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
4876 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 1 },
4879 static const struct message WmLButtonDownSeq
[] =
4881 { WM_LBUTTONDOWN
, sent
|wparam
|lparam
, 0, 0 },
4882 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
4883 { HCBT_SETFOCUS
, hook
},
4884 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
4885 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
4886 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
4887 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
4888 { WM_CTLCOLORBTN
, sent
|defwinproc
},
4889 { BM_SETSTATE
, sent
|wparam
|defwinproc
, TRUE
},
4890 { WM_CTLCOLORBTN
, sent
|defwinproc
},
4891 { EVENT_OBJECT_STATECHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
4894 static const struct message WmLButtonUpSeq
[] =
4896 { WM_LBUTTONUP
, sent
|wparam
|lparam
, 0, 0 },
4897 { BM_SETSTATE
, sent
|wparam
|defwinproc
, FALSE
},
4898 { WM_CTLCOLORBTN
, sent
|defwinproc
},
4899 { EVENT_OBJECT_STATECHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
4900 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, 0, 0 },
4901 { WM_CAPTURECHANGED
, sent
|wparam
|defwinproc
, 0 },
4904 static const struct message WmSetFontButtonSeq
[] =
4906 { WM_SETFONT
, sent
},
4908 { WM_ERASEBKGND
, sent
|defwinproc
|optional
},
4909 { WM_CTLCOLORBTN
, sent
|defwinproc
},
4913 static WNDPROC old_button_proc
;
4915 static LRESULT CALLBACK
button_hook_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
4917 static long defwndproc_counter
= 0;
4921 trace("button: %p, %04x, %08lx, %08lx\n", hwnd
, message
, wParam
, lParam
);
4923 /* explicitly ignore WM_GETICON message */
4924 if (message
== WM_GETICON
) return 0;
4926 /* ignore registered messages */
4927 if (message
>= 0xc000) return 0;
4929 msg
.message
= message
;
4930 msg
.flags
= sent
|wparam
|lparam
;
4931 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
4932 msg
.wParam
= wParam
;
4933 msg
.lParam
= lParam
;
4936 if (message
== BM_SETSTATE
)
4937 ok(GetCapture() == hwnd
, "GetCapture() = %p\n", GetCapture());
4939 defwndproc_counter
++;
4940 ret
= CallWindowProcA(old_button_proc
, hwnd
, message
, wParam
, lParam
);
4941 defwndproc_counter
--;
4946 static void subclass_button(void)
4950 if (!GetClassInfoA(0, "button", &cls
)) assert(0);
4952 old_button_proc
= cls
.lpfnWndProc
;
4954 cls
.hInstance
= GetModuleHandle(0);
4955 cls
.lpfnWndProc
= button_hook_proc
;
4956 cls
.lpszClassName
= "my_button_class";
4957 UnregisterClass(cls
.lpszClassName
, cls
.hInstance
);
4958 if (!RegisterClassA(&cls
)) assert(0);
4961 static void test_button_messages(void)
4967 const struct message
*setfocus
;
4968 const struct message
*killfocus
;
4970 { BS_PUSHBUTTON
, DLGC_BUTTON
| DLGC_UNDEFPUSHBUTTON
,
4971 WmSetFocusButtonSeq
, WmKillFocusButtonSeq
},
4972 { BS_DEFPUSHBUTTON
, DLGC_BUTTON
| DLGC_DEFPUSHBUTTON
,
4973 WmSetFocusButtonSeq
, WmKillFocusButtonSeq
},
4974 { BS_CHECKBOX
, DLGC_BUTTON
,
4975 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
},
4976 { BS_AUTOCHECKBOX
, DLGC_BUTTON
,
4977 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
},
4978 { BS_RADIOBUTTON
, DLGC_BUTTON
| DLGC_RADIOBUTTON
,
4979 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
},
4980 { BS_3STATE
, DLGC_BUTTON
,
4981 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
},
4982 { BS_AUTO3STATE
, DLGC_BUTTON
,
4983 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
},
4984 { BS_GROUPBOX
, DLGC_STATIC
,
4985 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
},
4986 { BS_USERBUTTON
, DLGC_BUTTON
| DLGC_UNDEFPUSHBUTTON
,
4987 WmSetFocusButtonSeq
, WmKillFocusButtonSeq
},
4988 { BS_AUTORADIOBUTTON
, DLGC_BUTTON
| DLGC_RADIOBUTTON
,
4989 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
},
4990 { BS_OWNERDRAW
, DLGC_BUTTON
,
4991 WmSetFocusButtonSeq
, WmKillFocusButtonSeq
}
5000 for (i
= 0; i
< sizeof(button
)/sizeof(button
[0]); i
++)
5002 hwnd
= CreateWindowExA(0, "my_button_class", "test", button
[i
].style
| WS_POPUP
,
5003 0, 0, 50, 14, 0, 0, 0, NULL
);
5004 ok(hwnd
!= 0, "Failed to create button window\n");
5006 dlg_code
= SendMessageA(hwnd
, WM_GETDLGCODE
, 0, 0);
5007 ok(dlg_code
== button
[i
].dlg_code
, "%u: wrong dlg_code %08x\n", i
, dlg_code
);
5009 ShowWindow(hwnd
, SW_SHOW
);
5014 trace("button style %08x\n", button
[i
].style
);
5016 ok_sequence(button
[i
].setfocus
, "SetFocus(hwnd) on a button", FALSE
);
5019 ok_sequence(button
[i
].killfocus
, "SetFocus(0) on a button", FALSE
);
5021 DestroyWindow(hwnd
);
5024 hwnd
= CreateWindowExA(0, "my_button_class", "test", BS_PUSHBUTTON
| WS_POPUP
| WS_VISIBLE
,
5025 0, 0, 50, 14, 0, 0, 0, NULL
);
5026 ok(hwnd
!= 0, "Failed to create button window\n");
5032 SendMessageA(hwnd
, WM_LBUTTONDOWN
, 0, 0);
5033 ok_sequence(WmLButtonDownSeq
, "WM_LBUTTONDOWN on a button", FALSE
);
5035 SendMessageA(hwnd
, WM_LBUTTONUP
, 0, 0);
5036 ok_sequence(WmLButtonUpSeq
, "WM_LBUTTONUP on a button", FALSE
);
5039 zfont
= (HFONT
)GetStockObject(SYSTEM_FONT
);
5040 SendMessageA(hwnd
, WM_SETFONT
, (WPARAM
)zfont
, TRUE
);
5042 ok_sequence(WmSetFontButtonSeq
, "WM_SETFONT on a button", FALSE
);
5044 DestroyWindow(hwnd
);
5047 /****************** static message test *************************/
5048 static const struct message WmSetFontStaticSeq
[] =
5050 { WM_SETFONT
, sent
},
5051 { WM_PAINT
, sent
|defwinproc
},
5052 { WM_ERASEBKGND
, sent
|defwinproc
|optional
},
5053 { WM_CTLCOLORSTATIC
, sent
|defwinproc
},
5057 static WNDPROC old_static_proc
;
5059 static LRESULT CALLBACK
static_hook_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
5061 static long defwndproc_counter
= 0;
5065 trace("static: %p, %04x, %08lx, %08lx\n", hwnd
, message
, wParam
, lParam
);
5067 /* explicitly ignore WM_GETICON message */
5068 if (message
== WM_GETICON
) return 0;
5070 /* ignore registered messages */
5071 if (message
>= 0xc000) return 0;
5073 msg
.message
= message
;
5074 msg
.flags
= sent
|wparam
|lparam
;
5075 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
5076 msg
.wParam
= wParam
;
5077 msg
.lParam
= lParam
;
5080 defwndproc_counter
++;
5081 ret
= CallWindowProcA(old_static_proc
, hwnd
, message
, wParam
, lParam
);
5082 defwndproc_counter
--;
5087 static void subclass_static(void)
5091 if (!GetClassInfoA(0, "static", &cls
)) assert(0);
5093 old_static_proc
= cls
.lpfnWndProc
;
5095 cls
.hInstance
= GetModuleHandle(0);
5096 cls
.lpfnWndProc
= static_hook_proc
;
5097 cls
.lpszClassName
= "my_static_class";
5098 UnregisterClass(cls
.lpszClassName
, cls
.hInstance
);
5099 if (!RegisterClassA(&cls
)) assert(0);
5102 static void test_static_messages(void)
5104 /* FIXME: make as comprehensive as the button message test */
5109 const struct message
*setfont
;
5111 { SS_LEFT
, DLGC_STATIC
,
5112 WmSetFontStaticSeq
}
5120 for (i
= 0; i
< sizeof(static_ctrl
)/sizeof(static_ctrl
[0]); i
++)
5122 hwnd
= CreateWindowExA(0, "my_static_class", "test", static_ctrl
[i
].style
| WS_POPUP
,
5123 0, 0, 50, 14, 0, 0, 0, NULL
);
5124 ok(hwnd
!= 0, "Failed to create static window\n");
5126 dlg_code
= SendMessageA(hwnd
, WM_GETDLGCODE
, 0, 0);
5127 ok(dlg_code
== static_ctrl
[i
].dlg_code
, "%u: wrong dlg_code %08x\n", i
, dlg_code
);
5129 ShowWindow(hwnd
, SW_SHOW
);
5134 trace("static style %08x\n", static_ctrl
[i
].style
);
5135 SendMessage(hwnd
, WM_SETFONT
, (WPARAM
)GetStockObject(DEFAULT_GUI_FONT
), TRUE
);
5136 ok_sequence(static_ctrl
[i
].setfont
, "WM_SETFONT on a static", FALSE
);
5138 DestroyWindow(hwnd
);
5142 /****************** ComboBox message test *************************/
5143 #define ID_COMBOBOX 0x000f
5145 static const struct message WmKeyDownComboSeq
[] =
5147 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_DOWN
, 0 },
5148 { WM_COMMAND
, sent
|wparam
|defwinproc
, MAKEWPARAM(1000, LBN_SELCHANGE
) },
5149 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_COMBOBOX
, CBN_SELENDOK
) },
5150 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_COMBOBOX
, CBN_SELCHANGE
) },
5151 { WM_CTLCOLOREDIT
, sent
|parent
},
5152 { WM_KEYUP
, sent
|wparam
|lparam
, VK_DOWN
, 0 },
5156 static WNDPROC old_combobox_proc
;
5158 static LRESULT CALLBACK
combobox_hook_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
5160 static long defwndproc_counter
= 0;
5164 /* do not log painting messages */
5165 if (message
!= WM_PAINT
&&
5166 message
!= WM_NCPAINT
&&
5167 message
!= WM_SYNCPAINT
&&
5168 message
!= WM_ERASEBKGND
&&
5169 message
!= WM_NCHITTEST
&&
5170 message
!= WM_GETTEXT
&&
5171 message
!= WM_GETICON
&&
5172 message
!= WM_DEVICECHANGE
)
5174 trace("combo: %p, %04x, %08lx, %08lx\n", hwnd
, message
, wParam
, lParam
);
5176 msg
.message
= message
;
5177 msg
.flags
= sent
|wparam
|lparam
;
5178 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
5179 msg
.wParam
= wParam
;
5180 msg
.lParam
= lParam
;
5184 defwndproc_counter
++;
5185 ret
= CallWindowProcA(old_combobox_proc
, hwnd
, message
, wParam
, lParam
);
5186 defwndproc_counter
--;
5191 static void subclass_combobox(void)
5195 if (!GetClassInfoA(0, "ComboBox", &cls
)) assert(0);
5197 old_combobox_proc
= cls
.lpfnWndProc
;
5199 cls
.hInstance
= GetModuleHandle(0);
5200 cls
.lpfnWndProc
= combobox_hook_proc
;
5201 cls
.lpszClassName
= "my_combobox_class";
5202 UnregisterClass(cls
.lpszClassName
, cls
.hInstance
);
5203 if (!RegisterClassA(&cls
)) assert(0);
5206 static void test_combobox_messages(void)
5211 subclass_combobox();
5213 parent
= CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
5214 100, 100, 200, 200, 0, 0, 0, NULL
);
5215 ok(parent
!= 0, "Failed to create parent window\n");
5218 combo
= CreateWindowEx(0, "my_combobox_class", "test", WS_CHILD
| WS_VISIBLE
| CBS_DROPDOWNLIST
| CBS_HASSTRINGS
,
5219 0, 0, 100, 150, parent
, (HMENU
)ID_COMBOBOX
, 0, NULL
);
5220 ok(combo
!= 0, "Failed to create combobox window\n");
5222 UpdateWindow(combo
);
5224 ret
= SendMessage(combo
, WM_GETDLGCODE
, 0, 0);
5225 ok(ret
== (DLGC_WANTCHARS
| DLGC_WANTARROWS
), "wrong dlg_code %08lx\n", ret
);
5227 ret
= SendMessage(combo
, CB_ADDSTRING
, 0, (LPARAM
)"item 0");
5228 ok(ret
== 0, "expected 0, got %ld\n", ret
);
5229 ret
= SendMessage(combo
, CB_ADDSTRING
, 0, (LPARAM
)"item 1");
5230 ok(ret
== 1, "expected 1, got %ld\n", ret
);
5231 ret
= SendMessage(combo
, CB_ADDSTRING
, 0, (LPARAM
)"item 2");
5232 ok(ret
== 2, "expected 2, got %ld\n", ret
);
5234 SendMessage(combo
, CB_SETCURSEL
, 0, 0);
5238 log_all_parent_messages
++;
5239 SendMessage(combo
, WM_KEYDOWN
, VK_DOWN
, 0);
5240 SendMessage(combo
, WM_KEYUP
, VK_DOWN
, 0);
5241 log_all_parent_messages
--;
5242 ok_sequence(WmKeyDownComboSeq
, "WM_KEYDOWN/VK_DOWN on a ComboBox", FALSE
);
5244 DestroyWindow(combo
);
5245 DestroyWindow(parent
);
5248 /****************** WM_IME_KEYDOWN message test *******************/
5250 static const struct message WmImeKeydownMsgSeq_0
[] =
5252 { WM_IME_KEYDOWN
, wparam
, VK_RETURN
},
5253 { WM_CHAR
, wparam
, 'A' },
5257 static const struct message WmImeKeydownMsgSeq_1
[] =
5259 { WM_KEYDOWN
, optional
|wparam
, VK_RETURN
},
5260 { WM_CHAR
, optional
|wparam
, VK_RETURN
},
5264 static LRESULT WINAPI
wmime_keydown_procA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
5268 trace("wmime_keydown_procA: %p, %04x, %08lx, %08lx\n", hwnd
, message
, wParam
, lParam
);
5270 msg
.message
= message
;
5271 msg
.flags
= wparam
|lparam
;
5272 msg
.wParam
= wParam
;
5273 msg
.lParam
= lParam
;
5276 return DefWindowProcA(hwnd
, message
, wParam
, lParam
);
5279 static void register_wmime_keydown_class(void)
5283 ZeroMemory(&cls
, sizeof(WNDCLASSA
));
5284 cls
.lpfnWndProc
= wmime_keydown_procA
;
5285 cls
.hInstance
= GetModuleHandleA(0);
5286 cls
.lpszClassName
= "wmime_keydown_class";
5287 if (!RegisterClassA(&cls
)) assert(0);
5290 void test_wmime_keydown_message(void)
5295 trace("Message sequences by WM_IME_KEYDOWN\n");
5297 register_wmime_keydown_class();
5298 hwnd
= CreateWindowExA(0, "wmime_keydown_class", NULL
, WS_OVERLAPPEDWINDOW
,
5299 CW_USEDEFAULT
, CW_USEDEFAULT
, 300, 300, 0,
5304 SendMessage(hwnd
, WM_IME_KEYDOWN
, VK_RETURN
, 0x1c0001);
5305 SendMessage(hwnd
, WM_CHAR
, 'A', 1);
5306 ok_sequence(WmImeKeydownMsgSeq_0
, "WM_IME_KEYDOWN 0", FALSE
);
5308 while ( PeekMessage(&msg
, 0, 0, 0, PM_REMOVE
) )
5310 TranslateMessage(&msg
);
5311 DispatchMessage(&msg
);
5313 ok_sequence(WmImeKeydownMsgSeq_1
, "WM_IME_KEYDOWN 1", FALSE
);
5315 DestroyWindow(hwnd
);
5318 /************* painting message test ********************/
5320 void dump_region(HRGN hrgn
)
5323 RGNDATA
*data
= NULL
;
5328 printf( "null region\n" );
5331 if (!(size
= GetRegionData( hrgn
, 0, NULL
))) return;
5332 if (!(data
= HeapAlloc( GetProcessHeap(), 0, size
))) return;
5333 GetRegionData( hrgn
, size
, data
);
5334 printf("%d rects:", data
->rdh
.nCount
);
5335 for (i
= 0, rect
= (RECT
*)data
->Buffer
; i
< data
->rdh
.nCount
; i
++, rect
++)
5336 printf( " (%d,%d)-(%d,%d)", rect
->left
, rect
->top
, rect
->right
, rect
->bottom
);
5338 HeapFree( GetProcessHeap(), 0, data
);
5341 static void check_update_rgn( HWND hwnd
, HRGN hrgn
)
5345 HRGN tmp
= CreateRectRgn( 0, 0, 0, 0 );
5346 HRGN update
= CreateRectRgn( 0, 0, 0, 0 );
5348 ret
= GetUpdateRgn( hwnd
, update
, FALSE
);
5349 ok( ret
!= ERROR
, "GetUpdateRgn failed\n" );
5350 if (ret
== NULLREGION
)
5352 ok( !hrgn
, "Update region shouldn't be empty\n" );
5356 if (CombineRgn( tmp
, hrgn
, update
, RGN_XOR
) != NULLREGION
)
5358 ok( 0, "Regions are different\n" );
5359 if (winetest_debug
> 0)
5361 printf( "Update region: " );
5362 dump_region( update
);
5363 printf( "Wanted region: " );
5364 dump_region( hrgn
);
5368 GetRgnBox( update
, &r1
);
5369 GetUpdateRect( hwnd
, &r2
, FALSE
);
5370 ok( r1
.left
== r2
.left
&& r1
.top
== r2
.top
&& r1
.right
== r2
.right
&& r1
.bottom
== r2
.bottom
,
5371 "Rectangles are different: %d,%d-%d,%d / %d,%d-%d,%d\n",
5372 r1
.left
, r1
.top
, r1
.right
, r1
.bottom
, r2
.left
, r2
.top
, r2
.right
, r2
.bottom
);
5374 DeleteObject( tmp
);
5375 DeleteObject( update
);
5378 static const struct message WmInvalidateRgn
[] = {
5379 { WM_NCPAINT
, sent
},
5380 { WM_GETTEXT
, sent
|defwinproc
|optional
},
5384 static const struct message WmGetUpdateRect
[] = {
5385 { WM_NCPAINT
, sent
},
5386 { WM_GETTEXT
, sent
|defwinproc
|optional
},
5391 static const struct message WmInvalidateFull
[] = {
5392 { WM_NCPAINT
, sent
|wparam
, 1 },
5393 { WM_GETTEXT
, sent
|defwinproc
|optional
},
5397 static const struct message WmInvalidateErase
[] = {
5398 { WM_NCPAINT
, sent
|wparam
, 1 },
5399 { WM_GETTEXT
, sent
|defwinproc
|optional
},
5400 { WM_ERASEBKGND
, sent
},
5404 static const struct message WmInvalidatePaint
[] = {
5406 { WM_NCPAINT
, sent
|wparam
|beginpaint
, 1 },
5407 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
5411 static const struct message WmInvalidateErasePaint
[] = {
5413 { WM_NCPAINT
, sent
|wparam
|beginpaint
, 1 },
5414 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
5415 { WM_ERASEBKGND
, sent
|beginpaint
},
5419 static const struct message WmInvalidateErasePaint2
[] = {
5421 { WM_NCPAINT
, sent
|beginpaint
},
5422 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
5423 { WM_ERASEBKGND
, sent
|beginpaint
},
5427 static const struct message WmErase
[] = {
5428 { WM_ERASEBKGND
, sent
},
5432 static const struct message WmPaint
[] = {
5437 static const struct message WmParentOnlyPaint
[] = {
5438 { WM_PAINT
, sent
|parent
},
5442 static const struct message WmInvalidateParent
[] = {
5443 { WM_NCPAINT
, sent
|parent
},
5444 { WM_GETTEXT
, sent
|defwinproc
|parent
|optional
},
5445 { WM_ERASEBKGND
, sent
|parent
},
5449 static const struct message WmInvalidateParentChild
[] = {
5450 { WM_NCPAINT
, sent
|parent
},
5451 { WM_GETTEXT
, sent
|defwinproc
|parent
|optional
},
5452 { WM_ERASEBKGND
, sent
|parent
},
5453 { WM_NCPAINT
, sent
},
5454 { WM_GETTEXT
, sent
|defwinproc
|optional
},
5455 { WM_ERASEBKGND
, sent
},
5459 static const struct message WmInvalidateParentChild2
[] = {
5460 { WM_ERASEBKGND
, sent
|parent
},
5461 { WM_NCPAINT
, sent
},
5462 { WM_GETTEXT
, sent
|defwinproc
|optional
},
5463 { WM_ERASEBKGND
, sent
},
5467 static const struct message WmParentPaint
[] = {
5468 { WM_PAINT
, sent
|parent
},
5473 static const struct message WmParentPaintNc
[] = {
5474 { WM_PAINT
, sent
|parent
},
5476 { WM_NCPAINT
, sent
|beginpaint
},
5477 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
5478 { WM_ERASEBKGND
, sent
|beginpaint
},
5482 static const struct message WmChildPaintNc
[] = {
5484 { WM_NCPAINT
, sent
|beginpaint
},
5485 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
5486 { WM_ERASEBKGND
, sent
|beginpaint
},
5490 static const struct message WmParentErasePaint
[] = {
5491 { WM_PAINT
, sent
|parent
},
5492 { WM_NCPAINT
, sent
|parent
|beginpaint
},
5493 { WM_GETTEXT
, sent
|parent
|beginpaint
|defwinproc
|optional
},
5494 { WM_ERASEBKGND
, sent
|parent
|beginpaint
},
5496 { WM_NCPAINT
, sent
|beginpaint
},
5497 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
5498 { WM_ERASEBKGND
, sent
|beginpaint
},
5502 static const struct message WmParentOnlyNcPaint
[] = {
5503 { WM_PAINT
, sent
|parent
},
5504 { WM_NCPAINT
, sent
|parent
|beginpaint
},
5505 { WM_GETTEXT
, sent
|parent
|beginpaint
|defwinproc
|optional
},
5509 static const struct message WmSetParentStyle
[] = {
5510 { WM_STYLECHANGING
, sent
|parent
},
5511 { WM_STYLECHANGED
, sent
|parent
},
5515 static void test_paint_messages(void)
5521 HWND hparent
, hchild
;
5522 HRGN hrgn
= CreateRectRgn( 0, 0, 0, 0 );
5523 HRGN hrgn2
= CreateRectRgn( 0, 0, 0, 0 );
5524 HWND hwnd
= CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW
,
5525 100, 100, 200, 200, 0, 0, 0, NULL
);
5526 ok (hwnd
!= 0, "Failed to create overlapped window\n");
5528 ShowWindow( hwnd
, SW_SHOW
);
5529 UpdateWindow( hwnd
);
5533 check_update_rgn( hwnd
, 0 );
5534 SetRectRgn( hrgn
, 10, 10, 20, 20 );
5535 ret
= RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
);
5536 ok(ret
, "RedrawWindow returned %d instead of TRUE\n", ret
);
5537 check_update_rgn( hwnd
, hrgn
);
5538 SetRectRgn( hrgn2
, 20, 20, 30, 30 );
5539 ret
= RedrawWindow( hwnd
, NULL
, hrgn2
, RDW_INVALIDATE
);
5540 ok(ret
, "RedrawWindow returned %d instead of TRUE\n", ret
);
5541 CombineRgn( hrgn
, hrgn
, hrgn2
, RGN_OR
);
5542 check_update_rgn( hwnd
, hrgn
);
5543 /* validate everything */
5544 ret
= RedrawWindow( hwnd
, NULL
, NULL
, RDW_VALIDATE
);
5545 ok(ret
, "RedrawWindow returned %d instead of TRUE\n", ret
);
5546 check_update_rgn( hwnd
, 0 );
5548 /* test empty region */
5549 SetRectRgn( hrgn
, 10, 10, 10, 15 );
5550 ret
= RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
);
5551 ok(ret
, "RedrawWindow returned %d instead of TRUE\n", ret
);
5552 check_update_rgn( hwnd
, 0 );
5553 /* test empty rect */
5554 SetRect( &rect
, 10, 10, 10, 15 );
5555 ret
= RedrawWindow( hwnd
, &rect
, NULL
, RDW_INVALIDATE
);
5556 ok(ret
, "RedrawWindow returned %d instead of TRUE\n", ret
);
5557 check_update_rgn( hwnd
, 0 );
5559 /* flush pending messages */
5563 GetClientRect( hwnd
, &rect
);
5564 SetRectRgn( hrgn
, 0, 0, rect
.right
- rect
.left
, rect
.bottom
- rect
.top
);
5565 /* MSDN: if hwnd parameter is NULL, InvalidateRect invalidates and redraws
5566 * all windows and sends WM_ERASEBKGND and WM_NCPAINT.
5568 trace("testing InvalidateRect(0, NULL, FALSE)\n");
5569 SetRectEmpty( &rect
);
5570 ok(InvalidateRect(0, &rect
, FALSE
), "InvalidateRect(0, &rc, FALSE) should fail\n");
5571 check_update_rgn( hwnd
, hrgn
);
5572 ok_sequence( WmInvalidateErase
, "InvalidateErase", FALSE
);
5574 ok_sequence( WmPaint
, "Paint", FALSE
);
5575 RedrawWindow( hwnd
, NULL
, NULL
, RDW_VALIDATE
);
5576 check_update_rgn( hwnd
, 0 );
5578 /* MSDN: if hwnd parameter is NULL, ValidateRect invalidates and redraws
5579 * all windows and sends WM_ERASEBKGND and WM_NCPAINT.
5581 trace("testing ValidateRect(0, NULL)\n");
5582 SetRectEmpty( &rect
);
5583 ok(ValidateRect(0, &rect
), "ValidateRect(0, &rc) should not fail\n");
5584 check_update_rgn( hwnd
, hrgn
);
5585 ok_sequence( WmInvalidateErase
, "InvalidateErase", FALSE
);
5587 ok_sequence( WmPaint
, "Paint", FALSE
);
5588 RedrawWindow( hwnd
, NULL
, NULL
, RDW_VALIDATE
);
5589 check_update_rgn( hwnd
, 0 );
5591 trace("testing InvalidateRgn(0, NULL, FALSE)\n");
5592 SetLastError(0xdeadbeef);
5593 ok(!InvalidateRgn(0, NULL
, FALSE
), "InvalidateRgn(0, NULL, FALSE) should fail\n");
5594 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
|| GetLastError() == 0xdeadbeef,
5595 "wrong error code %d\n", GetLastError());
5596 check_update_rgn( hwnd
, 0 );
5598 ok_sequence( WmEmptySeq
, "WmEmptySeq", FALSE
);
5600 trace("testing ValidateRgn(0, NULL)\n");
5601 SetLastError(0xdeadbeef);
5602 ok(!ValidateRgn(0, NULL
), "ValidateRgn(0, NULL) should fail\n");
5603 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
, "wrong error code %d\n", GetLastError());
5604 check_update_rgn( hwnd
, 0 );
5606 ok_sequence( WmEmptySeq
, "WmEmptySeq", FALSE
);
5608 /* now with frame */
5609 SetRectRgn( hrgn
, -5, -5, 20, 20 );
5611 /* flush pending messages */
5614 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_FRAME
);
5615 ok_sequence( WmEmptySeq
, "EmptySeq", FALSE
);
5617 SetRectRgn( hrgn
, 0, 0, 20, 20 ); /* GetUpdateRgn clips to client area */
5618 check_update_rgn( hwnd
, hrgn
);
5621 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASENOW
);
5622 ok_sequence( WmInvalidateRgn
, "InvalidateRgn", FALSE
);
5625 RedrawWindow( hwnd
, NULL
, NULL
, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASENOW
);
5626 ok_sequence( WmInvalidateFull
, "InvalidateFull", FALSE
);
5628 GetClientRect( hwnd
, &rect
);
5629 SetRectRgn( hrgn
, rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
5630 check_update_rgn( hwnd
, hrgn
);
5633 RedrawWindow( hwnd
, NULL
, NULL
, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASE
| RDW_ERASENOW
);
5634 ok_sequence( WmInvalidateErase
, "InvalidateErase", FALSE
);
5637 RedrawWindow( hwnd
, NULL
, NULL
, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASENOW
| RDW_UPDATENOW
);
5638 ok_sequence( WmInvalidatePaint
, "InvalidatePaint", FALSE
);
5639 check_update_rgn( hwnd
, 0 );
5642 RedrawWindow( hwnd
, NULL
, NULL
, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASE
| RDW_UPDATENOW
);
5643 ok_sequence( WmInvalidateErasePaint
, "InvalidateErasePaint", FALSE
);
5644 check_update_rgn( hwnd
, 0 );
5647 SetRectRgn( hrgn
, 0, 0, 100, 100 );
5648 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
);
5649 SetRectRgn( hrgn
, 0, 0, 50, 100 );
5650 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_VALIDATE
);
5651 SetRectRgn( hrgn
, 50, 0, 100, 100 );
5652 check_update_rgn( hwnd
, hrgn
);
5653 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_VALIDATE
| RDW_ERASENOW
);
5654 ok_sequence( WmEmptySeq
, "EmptySeq", FALSE
); /* must not generate messages, everything is valid */
5655 check_update_rgn( hwnd
, 0 );
5658 SetRectRgn( hrgn
, 0, 0, 100, 100 );
5659 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_ERASE
);
5660 SetRectRgn( hrgn
, 0, 0, 100, 50 );
5661 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_VALIDATE
| RDW_ERASENOW
);
5662 ok_sequence( WmErase
, "Erase", FALSE
);
5663 SetRectRgn( hrgn
, 0, 50, 100, 100 );
5664 check_update_rgn( hwnd
, hrgn
);
5667 SetRectRgn( hrgn
, 0, 0, 100, 100 );
5668 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_ERASE
);
5669 SetRectRgn( hrgn
, 0, 0, 50, 50 );
5670 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_VALIDATE
| RDW_NOERASE
| RDW_UPDATENOW
);
5671 ok_sequence( WmPaint
, "Paint", FALSE
);
5674 SetRectRgn( hrgn
, -4, -4, -2, -2 );
5675 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_FRAME
);
5676 SetRectRgn( hrgn
, -200, -200, -198, -198 );
5677 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_VALIDATE
| RDW_NOFRAME
| RDW_ERASENOW
);
5678 ok_sequence( WmEmptySeq
, "EmptySeq", FALSE
);
5681 SetRectRgn( hrgn
, -4, -4, -2, -2 );
5682 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_FRAME
);
5683 SetRectRgn( hrgn
, -4, -4, -3, -3 );
5684 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_VALIDATE
| RDW_NOFRAME
);
5685 SetRectRgn( hrgn
, 0, 0, 1, 1 );
5686 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_UPDATENOW
);
5687 ok_sequence( WmPaint
, "Paint", FALSE
);
5690 SetRectRgn( hrgn
, -4, -4, -1, -1 );
5691 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_FRAME
);
5692 RedrawWindow( hwnd
, NULL
, 0, RDW_ERASENOW
);
5693 /* make sure no WM_PAINT was generated */
5695 ok_sequence( WmInvalidateRgn
, "InvalidateRgn", FALSE
);
5698 SetRectRgn( hrgn
, -4, -4, -1, -1 );
5699 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_FRAME
);
5700 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
))
5702 if (msg
.hwnd
== hwnd
&& msg
.message
== WM_PAINT
)
5704 /* GetUpdateRgn must return empty region since only nonclient area is invalidated */
5705 INT ret
= GetUpdateRgn( hwnd
, hrgn
, FALSE
);
5706 ok( ret
== NULLREGION
, "Invalid GetUpdateRgn result %d\n", ret
);
5707 ret
= GetUpdateRect( hwnd
, &rect
, FALSE
);
5708 ok( ret
, "Invalid GetUpdateRect result %d\n", ret
);
5709 /* this will send WM_NCPAINT and validate the non client area */
5710 ret
= GetUpdateRect( hwnd
, &rect
, TRUE
);
5711 ok( !ret
, "Invalid GetUpdateRect result %d\n", ret
);
5713 DispatchMessage( &msg
);
5715 ok_sequence( WmGetUpdateRect
, "GetUpdateRect", FALSE
);
5717 DestroyWindow( hwnd
);
5719 /* now test with a child window */
5721 hparent
= CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW
,
5722 100, 100, 200, 200, 0, 0, 0, NULL
);
5723 ok (hparent
!= 0, "Failed to create parent window\n");
5725 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
| WS_VISIBLE
| WS_BORDER
,
5726 10, 10, 100, 100, hparent
, 0, 0, NULL
);
5727 ok (hchild
!= 0, "Failed to create child window\n");
5729 ShowWindow( hparent
, SW_SHOW
);
5730 UpdateWindow( hparent
);
5731 UpdateWindow( hchild
);
5734 log_all_parent_messages
++;
5736 SetRect( &rect
, 0, 0, 50, 50 );
5737 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
5738 RedrawWindow( hparent
, NULL
, 0, RDW_ERASENOW
| RDW_ALLCHILDREN
);
5739 ok_sequence( WmInvalidateParentChild
, "InvalidateParentChild", FALSE
);
5741 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
5743 MapWindowPoints( hchild
, hparent
, &pt
, 1 );
5744 SetRectRgn( hrgn
, 0, 0, 50 - pt
.x
, 50 - pt
.y
);
5745 check_update_rgn( hchild
, hrgn
);
5746 SetRectRgn( hrgn
, 0, 0, 50, 50 );
5747 check_update_rgn( hparent
, hrgn
);
5748 RedrawWindow( hparent
, NULL
, 0, RDW_ERASENOW
);
5749 ok_sequence( WmInvalidateParent
, "InvalidateParent", FALSE
);
5750 RedrawWindow( hchild
, NULL
, 0, RDW_ERASENOW
);
5751 ok_sequence( WmEmptySeq
, "EraseNow child", FALSE
);
5754 ok_sequence( WmParentPaintNc
, "WmParentPaintNc", FALSE
);
5756 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
| RDW_ALLCHILDREN
);
5757 RedrawWindow( hparent
, NULL
, 0, RDW_ERASENOW
);
5758 ok_sequence( WmInvalidateParent
, "InvalidateParent2", FALSE
);
5759 RedrawWindow( hchild
, NULL
, 0, RDW_ERASENOW
);
5760 ok_sequence( WmEmptySeq
, "EraseNow child", FALSE
);
5762 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
);
5763 RedrawWindow( hparent
, NULL
, 0, RDW_ERASENOW
| RDW_ALLCHILDREN
);
5764 ok_sequence( WmInvalidateParentChild2
, "InvalidateParentChild2", FALSE
);
5766 SetWindowLong( hparent
, GWL_STYLE
, GetWindowLong(hparent
,GWL_STYLE
) | WS_CLIPCHILDREN
);
5768 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
| RDW_ALLCHILDREN
);
5769 RedrawWindow( hparent
, NULL
, 0, RDW_ERASENOW
);
5770 ok_sequence( WmInvalidateParentChild
, "InvalidateParentChild3", FALSE
);
5772 /* flush all paint messages */
5776 /* RDW_UPDATENOW on child with WS_CLIPCHILDREN doesn't change corresponding parent area */
5777 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
| RDW_ALLCHILDREN
);
5778 SetRectRgn( hrgn
, 0, 0, 50, 50 );
5779 check_update_rgn( hparent
, hrgn
);
5780 RedrawWindow( hchild
, NULL
, 0, RDW_UPDATENOW
);
5781 ok_sequence( WmInvalidateErasePaint2
, "WmInvalidateErasePaint2", FALSE
);
5782 SetRectRgn( hrgn
, 0, 0, 50, 50 );
5783 check_update_rgn( hparent
, hrgn
);
5785 /* flush all paint messages */
5787 SetWindowLong( hparent
, GWL_STYLE
, GetWindowLong(hparent
,GWL_STYLE
) & ~WS_CLIPCHILDREN
);
5790 /* RDW_UPDATENOW on child without WS_CLIPCHILDREN will validate corresponding parent area */
5791 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
5792 SetRectRgn( hrgn
, 0, 0, 50, 50 );
5793 check_update_rgn( hparent
, hrgn
);
5794 RedrawWindow( hchild
, NULL
, 0, RDW_UPDATENOW
);
5795 ok_sequence( WmInvalidateErasePaint2
, "WmInvalidateErasePaint2", FALSE
);
5796 SetRectRgn( hrgn2
, 10, 10, 50, 50 );
5797 CombineRgn( hrgn
, hrgn
, hrgn2
, RGN_DIFF
);
5798 check_update_rgn( hparent
, hrgn
);
5799 /* flush all paint messages */
5803 /* same as above but parent gets completely validated */
5804 SetRect( &rect
, 20, 20, 30, 30 );
5805 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
5806 SetRectRgn( hrgn
, 20, 20, 30, 30 );
5807 check_update_rgn( hparent
, hrgn
);
5808 RedrawWindow( hchild
, NULL
, 0, RDW_UPDATENOW
);
5809 ok_sequence( WmInvalidateErasePaint2
, "WmInvalidateErasePaint2", FALSE
);
5810 check_update_rgn( hparent
, 0 ); /* no update region */
5812 ok_sequence( WmEmptySeq
, "WmEmpty", FALSE
); /* and no paint messages */
5814 /* make sure RDW_VALIDATE on child doesn't have the same effect */
5816 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
5817 SetRectRgn( hrgn
, 20, 20, 30, 30 );
5818 check_update_rgn( hparent
, hrgn
);
5819 RedrawWindow( hchild
, NULL
, 0, RDW_VALIDATE
| RDW_NOERASE
);
5820 SetRectRgn( hrgn
, 20, 20, 30, 30 );
5821 check_update_rgn( hparent
, hrgn
);
5823 /* same as above but normal WM_PAINT doesn't validate parent */
5825 SetRect( &rect
, 20, 20, 30, 30 );
5826 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
5827 SetRectRgn( hrgn
, 20, 20, 30, 30 );
5828 check_update_rgn( hparent
, hrgn
);
5829 /* no WM_PAINT in child while parent still pending */
5830 while (PeekMessage( &msg
, hchild
, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
5831 ok_sequence( WmEmptySeq
, "No WM_PAINT", FALSE
);
5832 while (PeekMessage( &msg
, hparent
, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
5833 ok_sequence( WmParentErasePaint
, "WmParentErasePaint", FALSE
);
5836 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
5837 /* no WM_PAINT in child while parent still pending */
5838 while (PeekMessage( &msg
, hchild
, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
5839 ok_sequence( WmEmptySeq
, "No WM_PAINT", FALSE
);
5840 RedrawWindow( hparent
, &rect
, 0, RDW_VALIDATE
| RDW_NOERASE
| RDW_NOCHILDREN
);
5841 /* now that parent is valid child should get WM_PAINT */
5842 while (PeekMessage( &msg
, hchild
, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
5843 ok_sequence( WmInvalidateErasePaint2
, "WmInvalidateErasePaint2", FALSE
);
5844 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
5845 ok_sequence( WmEmptySeq
, "No other message", FALSE
);
5847 /* same thing with WS_CLIPCHILDREN in parent */
5849 SetWindowLong( hparent
, GWL_STYLE
, GetWindowLong(hparent
,GWL_STYLE
) | WS_CLIPCHILDREN
);
5850 ok_sequence( WmSetParentStyle
, "WmSetParentStyle", FALSE
);
5851 /* changing style invalidates non client area, but we need to invalidate something else to see it */
5852 RedrawWindow( hparent
, &rect
, 0, RDW_UPDATENOW
);
5853 ok_sequence( WmEmptySeq
, "No message", FALSE
);
5854 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_UPDATENOW
);
5855 ok_sequence( WmParentOnlyNcPaint
, "WmParentOnlyNcPaint", FALSE
);
5858 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_ALLCHILDREN
);
5859 SetRectRgn( hrgn
, 20, 20, 30, 30 );
5860 check_update_rgn( hparent
, hrgn
);
5861 /* no WM_PAINT in child while parent still pending */
5862 while (PeekMessage( &msg
, hchild
, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
5863 ok_sequence( WmEmptySeq
, "No WM_PAINT", FALSE
);
5864 /* WM_PAINT in parent first */
5865 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
5866 ok_sequence( WmParentPaintNc
, "WmParentPaintNc2", FALSE
);
5868 /* no RDW_ERASE in parent still causes RDW_ERASE and RDW_FRAME in child */
5870 SetRect( &rect
, 0, 0, 30, 30 );
5871 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ALLCHILDREN
);
5872 SetRectRgn( hrgn
, 0, 0, 30, 30 );
5873 check_update_rgn( hparent
, hrgn
);
5875 ok_sequence( WmParentPaintNc
, "WmParentPaintNc3", FALSE
);
5877 /* validate doesn't cause RDW_NOERASE or RDW_NOFRAME in child */
5879 SetRect( &rect
, -10, 0, 30, 30 );
5880 RedrawWindow( hchild
, &rect
, 0, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASE
);
5881 SetRect( &rect
, 0, 0, 20, 20 );
5882 RedrawWindow( hparent
, &rect
, 0, RDW_VALIDATE
| RDW_ALLCHILDREN
);
5883 RedrawWindow( hparent
, NULL
, 0, RDW_UPDATENOW
);
5884 ok_sequence( WmChildPaintNc
, "WmChildPaintNc", FALSE
);
5886 /* validate doesn't cause RDW_NOERASE or RDW_NOFRAME in child */
5888 SetRect( &rect
, -10, 0, 30, 30 );
5889 RedrawWindow( hchild
, &rect
, 0, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASE
);
5890 SetRect( &rect
, 0, 0, 100, 100 );
5891 RedrawWindow( hparent
, &rect
, 0, RDW_VALIDATE
| RDW_ALLCHILDREN
);
5892 RedrawWindow( hparent
, NULL
, 0, RDW_UPDATENOW
);
5893 ok_sequence( WmEmptySeq
, "WmChildPaintNc2", FALSE
);
5894 RedrawWindow( hparent
, NULL
, 0, RDW_ERASENOW
);
5895 ok_sequence( WmEmptySeq
, "WmChildPaintNc3", FALSE
);
5897 /* test RDW_INTERNALPAINT behavior */
5900 RedrawWindow( hparent
, NULL
, 0, RDW_INTERNALPAINT
| RDW_NOCHILDREN
);
5902 ok_sequence( WmParentOnlyPaint
, "WmParentOnlyPaint", FALSE
);
5904 RedrawWindow( hparent
, NULL
, 0, RDW_INTERNALPAINT
| RDW_ALLCHILDREN
);
5906 ok_sequence( WmParentPaint
, "WmParentPaint", FALSE
);
5908 RedrawWindow( hparent
, NULL
, 0, RDW_INTERNALPAINT
);
5910 ok_sequence( WmParentOnlyPaint
, "WmParentOnlyPaint", FALSE
);
5912 assert( GetWindowLong(hparent
, GWL_STYLE
) & WS_CLIPCHILDREN
);
5913 UpdateWindow( hparent
);
5916 trace("testing SWP_FRAMECHANGED on parent with WS_CLIPCHILDREN\n");
5917 RedrawWindow( hchild
, NULL
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
5918 SetWindowPos( hparent
, 0, 0, 0, 0, 0, SWP_NOSIZE
| SWP_NOMOVE
|
5919 SWP_NOACTIVATE
| SWP_NOZORDER
| SWP_FRAMECHANGED
);
5921 ok_sequence(WmSWP_FrameChanged_clip
, "SetWindowPos:FrameChanged_clip", FALSE
);
5923 UpdateWindow( hparent
);
5926 trace("testing SWP_FRAMECHANGED|SWP_DEFERERASE on parent with WS_CLIPCHILDREN\n");
5927 RedrawWindow( hchild
, NULL
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
5928 SetWindowPos( hparent
, 0, 0, 0, 0, 0, SWP_NOSIZE
| SWP_NOMOVE
| SWP_DEFERERASE
|
5929 SWP_NOACTIVATE
| SWP_NOZORDER
| SWP_FRAMECHANGED
);
5931 ok_sequence(WmSWP_FrameChangedDeferErase
, "SetWindowPos:FrameChangedDeferErase", FALSE
);
5933 SetWindowLong( hparent
, GWL_STYLE
, GetWindowLong(hparent
,GWL_STYLE
) & ~WS_CLIPCHILDREN
);
5934 ok_sequence( WmSetParentStyle
, "WmSetParentStyle", FALSE
);
5935 RedrawWindow( hparent
, NULL
, 0, RDW_INTERNALPAINT
);
5937 ok_sequence( WmParentPaint
, "WmParentPaint", FALSE
);
5939 assert( !(GetWindowLong(hparent
, GWL_STYLE
) & WS_CLIPCHILDREN
) );
5940 UpdateWindow( hparent
);
5943 trace("testing SWP_FRAMECHANGED on parent without WS_CLIPCHILDREN\n");
5944 RedrawWindow( hchild
, NULL
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
5945 SetWindowPos( hparent
, 0, 0, 0, 0, 0, SWP_NOSIZE
| SWP_NOMOVE
|
5946 SWP_NOACTIVATE
| SWP_NOZORDER
| SWP_FRAMECHANGED
);
5948 ok_sequence(WmSWP_FrameChanged_noclip
, "SetWindowPos:FrameChanged_noclip", FALSE
);
5950 UpdateWindow( hparent
);
5953 trace("testing SWP_FRAMECHANGED|SWP_DEFERERASE on parent without WS_CLIPCHILDREN\n");
5954 RedrawWindow( hchild
, NULL
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
5955 SetWindowPos( hparent
, 0, 0, 0, 0, 0, SWP_NOSIZE
| SWP_NOMOVE
| SWP_DEFERERASE
|
5956 SWP_NOACTIVATE
| SWP_NOZORDER
| SWP_FRAMECHANGED
);
5958 ok_sequence(WmSWP_FrameChangedDeferErase
, "SetWindowPos:FrameChangedDeferErase", FALSE
);
5960 ok(GetWindowLong( hparent
, GWL_STYLE
) & WS_VISIBLE
, "parent should be visible\n");
5961 ok(GetWindowLong( hchild
, GWL_STYLE
) & WS_VISIBLE
, "child should be visible\n");
5963 UpdateWindow( hparent
);
5966 trace("testing SetWindowPos(-10000, -10000) on child\n");
5967 SetWindowPos( hchild
, 0, -10000, -10000, 0, 0, SWP_NOSIZE
| SWP_NOACTIVATE
| SWP_NOZORDER
);
5968 check_update_rgn( hchild
, 0 );
5971 #if 0 /* this one doesn't pass under Wine yet */
5972 UpdateWindow( hparent
);
5975 trace("testing ShowWindow(SW_MINIMIZE) on child\n");
5976 ShowWindow( hchild
, SW_MINIMIZE
);
5977 check_update_rgn( hchild
, 0 );
5981 UpdateWindow( hparent
);
5984 trace("testing SetWindowPos(-10000, -10000) on parent\n");
5985 SetWindowPos( hparent
, 0, -10000, -10000, 0, 0, SWP_NOSIZE
| SWP_NOACTIVATE
| SWP_NOZORDER
);
5986 check_update_rgn( hparent
, 0 );
5989 log_all_parent_messages
--;
5990 DestroyWindow( hparent
);
5991 ok(!IsWindow(hchild
), "child must be destroyed with its parent\n");
5993 /* tests for moving windows off-screen (needs simple WS_POPUP windows) */
5995 hparent
= CreateWindowExA(0, "TestParentClass", "Test parent", WS_POPUP
| WS_VISIBLE
,
5996 100, 100, 200, 200, 0, 0, 0, NULL
);
5997 ok (hparent
!= 0, "Failed to create parent window\n");
5999 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
| WS_VISIBLE
,
6000 10, 10, 100, 100, hparent
, 0, 0, NULL
);
6001 ok (hchild
!= 0, "Failed to create child window\n");
6003 ShowWindow( hparent
, SW_SHOW
);
6004 UpdateWindow( hparent
);
6005 UpdateWindow( hchild
);
6009 /* moving child outside of parent boundaries changes update region */
6010 SetRect( &rect
, 0, 0, 40, 40 );
6011 RedrawWindow( hchild
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
);
6012 SetRectRgn( hrgn
, 0, 0, 40, 40 );
6013 check_update_rgn( hchild
, hrgn
);
6014 MoveWindow( hchild
, -10, 10, 100, 100, FALSE
);
6015 SetRectRgn( hrgn
, 10, 0, 40, 40 );
6016 check_update_rgn( hchild
, hrgn
);
6017 MoveWindow( hchild
, -10, -10, 100, 100, FALSE
);
6018 SetRectRgn( hrgn
, 10, 10, 40, 40 );
6019 check_update_rgn( hchild
, hrgn
);
6021 /* moving parent off-screen does too */
6022 SetRect( &rect
, 0, 0, 100, 100 );
6023 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_NOCHILDREN
);
6024 SetRectRgn( hrgn
, 0, 0, 100, 100 );
6025 check_update_rgn( hparent
, hrgn
);
6026 SetRectRgn( hrgn
, 10, 10, 40, 40 );
6027 check_update_rgn( hchild
, hrgn
);
6028 MoveWindow( hparent
, -20, -20, 200, 200, FALSE
);
6029 SetRectRgn( hrgn
, 20, 20, 100, 100 );
6030 check_update_rgn( hparent
, hrgn
);
6031 SetRectRgn( hrgn
, 30, 30, 40, 40 );
6032 check_update_rgn( hchild
, hrgn
);
6034 /* invalidated region is cropped by the parent rects */
6035 SetRect( &rect
, 0, 0, 50, 50 );
6036 RedrawWindow( hchild
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
);
6037 SetRectRgn( hrgn
, 30, 30, 50, 50 );
6038 check_update_rgn( hchild
, hrgn
);
6040 DestroyWindow( hparent
);
6041 ok(!IsWindow(hchild
), "child must be destroyed with its parent\n");
6044 DeleteObject( hrgn
);
6045 DeleteObject( hrgn2
);
6054 static DWORD WINAPI
thread_proc(void *param
)
6057 struct wnd_event
*wnd_event
= (struct wnd_event
*)param
;
6059 wnd_event
->hwnd
= CreateWindowExA(0, "TestWindowClass", "window caption text", WS_OVERLAPPEDWINDOW
,
6060 100, 100, 200, 200, 0, 0, 0, NULL
);
6061 ok(wnd_event
->hwnd
!= 0, "Failed to create overlapped window\n");
6063 SetEvent(wnd_event
->event
);
6065 while (GetMessage(&msg
, 0, 0, 0))
6067 TranslateMessage(&msg
);
6068 DispatchMessage(&msg
);
6071 ok(IsWindow(wnd_event
->hwnd
), "window should still exist\n");
6076 static void test_interthread_messages(void)
6083 int len
, expected_len
;
6084 struct wnd_event wnd_event
;
6087 wnd_event
.event
= CreateEventW(NULL
, 0, 0, NULL
);
6088 if (!wnd_event
.event
)
6090 trace("skipping interthread message test under win9x\n");
6094 hThread
= CreateThread(NULL
, 0, thread_proc
, &wnd_event
, 0, &tid
);
6095 ok(hThread
!= NULL
, "CreateThread failed, error %d\n", GetLastError());
6097 ok(WaitForSingleObject(wnd_event
.event
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
6099 CloseHandle(wnd_event
.event
);
6101 SetLastError(0xdeadbeef);
6102 ok(!DestroyWindow(wnd_event
.hwnd
), "DestroyWindow succeded\n");
6103 ok(GetLastError() == ERROR_ACCESS_DENIED
|| GetLastError() == 0xdeadbeef,
6104 "wrong error code %d\n", GetLastError());
6106 proc
= (WNDPROC
)GetWindowLongPtrA(wnd_event
.hwnd
, GWLP_WNDPROC
);
6107 ok(proc
!= NULL
, "GetWindowLongPtrA(GWLP_WNDPROC) error %d\n", GetLastError());
6109 expected_len
= lstrlenA("window caption text");
6110 memset(buf
, 0, sizeof(buf
));
6111 SetLastError(0xdeadbeef);
6112 len
= CallWindowProcA(proc
, wnd_event
.hwnd
, WM_GETTEXT
, sizeof(buf
), (LPARAM
)buf
);
6113 ok(len
== expected_len
, "CallWindowProcA(WM_GETTEXT) error %d, len %d, expected len %d\n", GetLastError(), len
, expected_len
);
6114 ok(!lstrcmpA(buf
, "window caption text"), "window text mismatch\n");
6116 msg
.hwnd
= wnd_event
.hwnd
;
6117 msg
.message
= WM_GETTEXT
;
6118 msg
.wParam
= sizeof(buf
);
6119 msg
.lParam
= (LPARAM
)buf
;
6120 memset(buf
, 0, sizeof(buf
));
6121 SetLastError(0xdeadbeef);
6122 len
= DispatchMessageA(&msg
);
6123 ok((!len
&& GetLastError() == ERROR_MESSAGE_SYNC_ONLY
) || broken(len
), /* nt4 */
6124 "DispatchMessageA(WM_GETTEXT) succeded on another thread window: ret %d, error %d\n", len
, GetLastError());
6126 /* the following test causes an exception in user.exe under win9x */
6127 msg
.hwnd
= wnd_event
.hwnd
;
6128 msg
.message
= WM_TIMER
;
6130 msg
.lParam
= GetWindowLongPtrA(wnd_event
.hwnd
, GWLP_WNDPROC
);
6131 SetLastError(0xdeadbeef);
6132 len
= DispatchMessageA(&msg
);
6133 ok(!len
&& GetLastError() == 0xdeadbeef,
6134 "DispatchMessageA(WM_TIMER) failed on another thread window: ret %d, error %d\n", len
, GetLastError());
6136 ret
= PostMessageA(wnd_event
.hwnd
, WM_QUIT
, 0, 0);
6137 ok( ret
, "PostMessageA(WM_QUIT) error %d\n", GetLastError());
6139 ok(WaitForSingleObject(hThread
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
6140 CloseHandle(hThread
);
6142 ok(!IsWindow(wnd_event
.hwnd
), "window should be destroyed on thread exit\n");
6146 static const struct message WmVkN
[] = {
6147 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 1 }, /* XP */
6148 { WM_KEYDOWN
, wparam
|lparam
, 'N', 1 },
6149 { WM_KEYDOWN
, sent
|wparam
|lparam
, 'N', 1 },
6150 { WM_CHAR
, wparam
|lparam
, 'n', 1 },
6151 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1002,1), 0 },
6152 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xc0000001 }, /* XP */
6153 { WM_KEYUP
, wparam
|lparam
, 'N', 0xc0000001 },
6154 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xc0000001 },
6157 static const struct message WmShiftVkN
[] = {
6158 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 1 }, /* XP */
6159 { WM_KEYDOWN
, wparam
|lparam
, VK_SHIFT
, 1 },
6160 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_SHIFT
, 1 },
6161 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 1 }, /* XP */
6162 { WM_KEYDOWN
, wparam
|lparam
, 'N', 1 },
6163 { WM_KEYDOWN
, sent
|wparam
|lparam
, 'N', 1 },
6164 { WM_CHAR
, wparam
|lparam
, 'N', 1 },
6165 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1001,1), 0 },
6166 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xc0000001 }, /* XP */
6167 { WM_KEYUP
, wparam
|lparam
, 'N', 0xc0000001 },
6168 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xc0000001 },
6169 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 0xc0000001 }, /* XP */
6170 { WM_KEYUP
, wparam
|lparam
, VK_SHIFT
, 0xc0000001 },
6171 { WM_KEYUP
, sent
|wparam
|lparam
, VK_SHIFT
, 0xc0000001 },
6174 static const struct message WmCtrlVkN
[] = {
6175 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 1 }, /* XP */
6176 { WM_KEYDOWN
, wparam
|lparam
, VK_CONTROL
, 1 },
6177 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_CONTROL
, 1 },
6178 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 1 }, /* XP */
6179 { WM_KEYDOWN
, wparam
|lparam
, 'N', 1 },
6180 { WM_KEYDOWN
, sent
|wparam
|lparam
, 'N', 1 },
6181 { WM_CHAR
, wparam
|lparam
, 0x000e, 1 },
6182 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1000,1), 0 },
6183 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xc0000001 }, /* XP */
6184 { WM_KEYUP
, wparam
|lparam
, 'N', 0xc0000001 },
6185 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xc0000001 },
6186 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 0xc0000001 }, /* XP */
6187 { WM_KEYUP
, wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
6188 { WM_KEYUP
, sent
|wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
6191 static const struct message WmCtrlVkN_2
[] = {
6192 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 1 }, /* XP */
6193 { WM_KEYDOWN
, wparam
|lparam
, VK_CONTROL
, 1 },
6194 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_CONTROL
, 1 },
6195 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 1 }, /* XP */
6196 { WM_KEYDOWN
, wparam
|lparam
, 'N', 1 },
6197 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1000,1), 0 },
6198 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xc0000001 }, /* XP */
6199 { WM_KEYUP
, wparam
|lparam
, 'N', 0xc0000001 },
6200 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xc0000001 },
6201 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 0xc0000001 }, /* XP */
6202 { WM_KEYUP
, wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
6203 { WM_KEYUP
, sent
|wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
6206 static const struct message WmAltVkN
[] = {
6207 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 }, /* XP */
6208 { WM_SYSKEYDOWN
, wparam
|lparam
, VK_MENU
, 0x20000001 },
6209 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
6210 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0x20000001 }, /* XP */
6211 { WM_SYSKEYDOWN
, wparam
|lparam
, 'N', 0x20000001 },
6212 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, 'N', 0x20000001 },
6213 { WM_SYSCHAR
, wparam
|lparam
, 'n', 0x20000001 },
6214 { WM_SYSCHAR
, sent
|wparam
|lparam
, 'n', 0x20000001 },
6215 { WM_SYSCOMMAND
, sent
|defwinproc
|wparam
|lparam
, SC_KEYMENU
, 'n' },
6216 { HCBT_SYSCOMMAND
, hook
},
6217 { WM_ENTERMENULOOP
, sent
|defwinproc
|wparam
|lparam
, 0, 0 },
6218 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
6219 { 0x00AE, sent
|defwinproc
|optional
}, /* XP */
6220 { WM_GETTEXT
, sent
|defwinproc
|optional
}, /* XP */
6221 { WM_INITMENU
, sent
|defwinproc
},
6222 { EVENT_SYSTEM_MENUSTART
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 0 },
6223 { WM_MENUCHAR
, sent
|defwinproc
|wparam
, MAKEWPARAM('n',MF_SYSMENU
) },
6224 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, 0, 0 },
6225 { WM_CAPTURECHANGED
, sent
|defwinproc
},
6226 { WM_MENUSELECT
, sent
|defwinproc
|wparam
, MAKEWPARAM(0,0xffff) },
6227 { EVENT_SYSTEM_MENUEND
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 0 },
6228 { WM_EXITMENULOOP
, sent
|defwinproc
},
6229 { WM_MENUSELECT
, sent
|defwinproc
|wparam
|optional
, MAKEWPARAM(0,0xffff) }, /* Win95 bug */
6230 { WM_EXITMENULOOP
, sent
|defwinproc
|optional
}, /* Win95 bug */
6231 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xe0000001 }, /* XP */
6232 { WM_SYSKEYUP
, wparam
|lparam
, 'N', 0xe0000001 },
6233 { WM_SYSKEYUP
, sent
|wparam
|lparam
, 'N', 0xe0000001 },
6234 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xc0000001 }, /* XP */
6235 { WM_KEYUP
, wparam
|lparam
, VK_MENU
, 0xc0000001 },
6236 { WM_KEYUP
, sent
|wparam
|lparam
, VK_MENU
, 0xc0000001 },
6239 static const struct message WmAltVkN_2
[] = {
6240 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 }, /* XP */
6241 { WM_SYSKEYDOWN
, wparam
|lparam
, VK_MENU
, 0x20000001 },
6242 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
6243 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0x20000001 }, /* XP */
6244 { WM_SYSKEYDOWN
, wparam
|lparam
, 'N', 0x20000001 },
6245 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1003,1), 0 },
6246 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xe0000001 }, /* XP */
6247 { WM_SYSKEYUP
, wparam
|lparam
, 'N', 0xe0000001 },
6248 { WM_SYSKEYUP
, sent
|wparam
|lparam
, 'N', 0xe0000001 },
6249 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xc0000001 }, /* XP */
6250 { WM_KEYUP
, wparam
|lparam
, VK_MENU
, 0xc0000001 },
6251 { WM_KEYUP
, sent
|wparam
|lparam
, VK_MENU
, 0xc0000001 },
6254 static const struct message WmCtrlAltVkN
[] = {
6255 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 1 }, /* XP */
6256 { WM_KEYDOWN
, wparam
|lparam
, VK_CONTROL
, 1 },
6257 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_CONTROL
, 1 },
6258 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 }, /* XP */
6259 { WM_KEYDOWN
, wparam
|lparam
, VK_MENU
, 0x20000001 },
6260 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
6261 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0x20000001 }, /* XP */
6262 { WM_KEYDOWN
, wparam
|lparam
, 'N', 0x20000001 },
6263 { WM_KEYDOWN
, sent
|wparam
|lparam
, 'N', 0x20000001 },
6264 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xe0000001 }, /* XP */
6265 { WM_KEYUP
, wparam
|lparam
, 'N', 0xe0000001 },
6266 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xe0000001 },
6267 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xc0000001 }, /* XP */
6268 { WM_KEYUP
, wparam
|lparam
, VK_MENU
, 0xc0000001 },
6269 { WM_KEYUP
, sent
|wparam
|lparam
, VK_MENU
, 0xc0000001 },
6270 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 0xc0000001 }, /* XP */
6271 { WM_KEYUP
, wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
6272 { WM_KEYUP
, sent
|wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
6275 static const struct message WmCtrlShiftVkN
[] = {
6276 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 1 }, /* XP */
6277 { WM_KEYDOWN
, wparam
|lparam
, VK_CONTROL
, 1 },
6278 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_CONTROL
, 1 },
6279 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 1 }, /* XP */
6280 { WM_KEYDOWN
, wparam
|lparam
, VK_SHIFT
, 1 },
6281 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_SHIFT
, 1 },
6282 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 1 }, /* XP */
6283 { WM_KEYDOWN
, wparam
|lparam
, 'N', 1 },
6284 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1004,1), 0 },
6285 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xc0000001 }, /* XP */
6286 { WM_KEYUP
, wparam
|lparam
, 'N', 0xc0000001 },
6287 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xc0000001 },
6288 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 0xc0000001 }, /* XP */
6289 { WM_KEYUP
, wparam
|lparam
, VK_SHIFT
, 0xc0000001 },
6290 { WM_KEYUP
, sent
|wparam
|lparam
, VK_SHIFT
, 0xc0000001 },
6291 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 0xc0000001 }, /* XP */
6292 { WM_KEYUP
, wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
6293 { WM_KEYUP
, sent
|wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
6296 static const struct message WmCtrlAltShiftVkN
[] = {
6297 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 1 }, /* XP */
6298 { WM_KEYDOWN
, wparam
|lparam
, VK_CONTROL
, 1 },
6299 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_CONTROL
, 1 },
6300 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 }, /* XP */
6301 { WM_KEYDOWN
, wparam
|lparam
, VK_MENU
, 0x20000001 },
6302 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
6303 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 0x20000001 }, /* XP */
6304 { WM_KEYDOWN
, wparam
|lparam
, VK_SHIFT
, 0x20000001 },
6305 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_SHIFT
, 0x20000001 },
6306 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0x20000001 }, /* XP */
6307 { WM_KEYDOWN
, wparam
|lparam
, 'N', 0x20000001 },
6308 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1005,1), 0 },
6309 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xe0000001 }, /* XP */
6310 { WM_KEYUP
, wparam
|lparam
, 'N', 0xe0000001 },
6311 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xe0000001 },
6312 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 0xe0000001 }, /* XP */
6313 { WM_KEYUP
, wparam
|lparam
, VK_SHIFT
, 0xe0000001 },
6314 { WM_KEYUP
, sent
|wparam
|lparam
, VK_SHIFT
, 0xe0000001 },
6315 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xc0000001 }, /* XP */
6316 { WM_KEYUP
, wparam
|lparam
, VK_MENU
, 0xc0000001 },
6317 { WM_KEYUP
, sent
|wparam
|lparam
, VK_MENU
, 0xc0000001 },
6318 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 0xc0000001 }, /* XP */
6319 { WM_KEYUP
, wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
6320 { WM_KEYUP
, sent
|wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
6323 static const struct message WmAltPressRelease
[] = {
6324 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 }, /* XP */
6325 { WM_SYSKEYDOWN
, wparam
|lparam
, VK_MENU
, 0x20000001 },
6326 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
6327 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xc0000001 }, /* XP */
6328 { WM_SYSKEYUP
, wparam
|lparam
, VK_MENU
, 0xc0000001 },
6329 { WM_SYSKEYUP
, sent
|wparam
|lparam
, VK_MENU
, 0xc0000001 },
6330 { WM_SYSCOMMAND
, sent
|defwinproc
|wparam
|lparam
, SC_KEYMENU
, 0 },
6331 { HCBT_SYSCOMMAND
, hook
},
6332 { WM_ENTERMENULOOP
, sent
|defwinproc
|wparam
|lparam
, 0, 0 },
6333 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
6334 { WM_INITMENU
, sent
|defwinproc
},
6335 { EVENT_SYSTEM_MENUSTART
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 0 },
6336 { WM_MENUSELECT
, sent
|defwinproc
|wparam
, MAKEWPARAM(0,MF_SYSMENU
|MF_POPUP
|MF_HILITE
) },
6337 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 1 },
6339 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x30000001 }, /* XP */
6341 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 0 },
6342 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, 0, 0, },
6343 { WM_CAPTURECHANGED
, sent
|defwinproc
},
6344 { WM_MENUSELECT
, sent
|defwinproc
|wparam
|optional
, MAKEWPARAM(0,0xffff) },
6345 { EVENT_SYSTEM_MENUEND
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 0 },
6346 { WM_EXITMENULOOP
, sent
|defwinproc
},
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 },
6352 static const struct message WmAltMouseButton
[] = {
6353 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 }, /* XP */
6354 { WM_SYSKEYDOWN
, wparam
|lparam
, VK_MENU
, 0x20000001 },
6355 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
6356 { WM_MOUSEMOVE
, wparam
|optional
, 0, 0 },
6357 { WM_MOUSEMOVE
, sent
|wparam
|optional
, 0, 0 },
6358 { WM_LBUTTONDOWN
, wparam
, MK_LBUTTON
, 0 },
6359 { WM_LBUTTONDOWN
, sent
|wparam
, MK_LBUTTON
, 0 },
6360 { WM_LBUTTONUP
, wparam
, 0, 0 },
6361 { WM_LBUTTONUP
, sent
|wparam
, 0, 0 },
6362 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xc0000001 }, /* XP */
6363 { WM_SYSKEYUP
, wparam
|lparam
, VK_MENU
, 0xc0000001 },
6364 { WM_SYSKEYUP
, sent
|wparam
|lparam
, VK_MENU
, 0xc0000001 },
6367 static const struct message WmF1Seq
[] = {
6368 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_F1
, 1 }, /* XP */
6369 { WM_KEYDOWN
, wparam
|lparam
, VK_F1
, 1 },
6370 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_F1
, 0x00000001 },
6371 { WM_KEYF1
, wparam
|lparam
, 0, 0 },
6372 { WM_KEYF1
, sent
|wparam
|lparam
, 0, 0 },
6373 { WM_HELP
, sent
|defwinproc
},
6374 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_F1
, 0xc0000001 }, /* XP */
6375 { WM_KEYUP
, wparam
|lparam
, VK_F1
, 0xc0000001 },
6376 { WM_KEYUP
, sent
|wparam
|lparam
, VK_F1
, 0xc0000001 },
6379 static const struct message WmVkAppsSeq
[] = {
6380 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_APPS
, 1 }, /* XP */
6381 { WM_KEYDOWN
, wparam
|lparam
, VK_APPS
, 1 },
6382 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_APPS
, 0x00000001 },
6383 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_APPS
, 0xc0000001 }, /* XP */
6384 { WM_KEYUP
, wparam
|lparam
, VK_APPS
, 0xc0000001 },
6385 { WM_KEYUP
, sent
|wparam
|lparam
, VK_APPS
, 0xc0000001 },
6386 { WM_CONTEXTMENU
, lparam
, /*hwnd*/0, (LPARAM
)-1 },
6387 { WM_CONTEXTMENU
, sent
|lparam
, /*hwnd*/0, (LPARAM
)-1 },
6391 static void pump_msg_loop(HWND hwnd
, HACCEL hAccel
)
6395 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
))
6397 struct message log_msg
;
6399 trace("accel: %p, %04x, %08lx, %08lx\n", msg
.hwnd
, msg
.message
, msg
.wParam
, msg
.lParam
);
6401 /* ignore some unwanted messages */
6402 if (msg
.message
== WM_MOUSEMOVE
||
6403 msg
.message
== WM_GETICON
||
6404 msg
.message
== WM_TIMER
||
6405 msg
.message
== WM_DEVICECHANGE
)
6408 log_msg
.message
= msg
.message
;
6409 log_msg
.flags
= wparam
|lparam
;
6410 log_msg
.wParam
= msg
.wParam
;
6411 log_msg
.lParam
= msg
.lParam
;
6412 add_message(&log_msg
);
6414 if (!hAccel
|| !TranslateAccelerator(hwnd
, hAccel
, &msg
))
6416 TranslateMessage(&msg
);
6417 DispatchMessage(&msg
);
6422 static void test_accelerators(void)
6427 HWND hwnd
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
6428 100, 100, 200, 200, 0, 0, 0, NULL
);
6437 ok(GetFocus() == hwnd
, "wrong focus window %p\n", GetFocus());
6439 state
= GetKeyState(VK_SHIFT
);
6440 ok(!(state
& 0x8000), "wrong Shift state %04x\n", state
);
6441 state
= GetKeyState(VK_CAPITAL
);
6442 ok(state
== 0, "wrong CapsLock state %04x\n", state
);
6444 hAccel
= LoadAccelerators(GetModuleHandleA(0), MAKEINTRESOURCE(1));
6445 assert(hAccel
!= 0);
6448 pump_msg_loop(hwnd
, 0);
6451 trace("testing VK_N press/release\n");
6453 keybd_event('N', 0, 0, 0);
6454 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
6455 pump_msg_loop(hwnd
, hAccel
);
6456 ok_sequence(WmVkN
, "VK_N press/release", FALSE
);
6458 trace("testing Shift+VK_N press/release\n");
6460 keybd_event(VK_SHIFT
, 0, 0, 0);
6461 keybd_event('N', 0, 0, 0);
6462 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
6463 keybd_event(VK_SHIFT
, 0, KEYEVENTF_KEYUP
, 0);
6464 pump_msg_loop(hwnd
, hAccel
);
6465 ok_sequence(WmShiftVkN
, "Shift+VK_N press/release", FALSE
);
6467 trace("testing Ctrl+VK_N press/release\n");
6469 keybd_event(VK_CONTROL
, 0, 0, 0);
6470 keybd_event('N', 0, 0, 0);
6471 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
6472 keybd_event(VK_CONTROL
, 0, KEYEVENTF_KEYUP
, 0);
6473 pump_msg_loop(hwnd
, hAccel
);
6474 ok_sequence(WmCtrlVkN
, "Ctrl+VK_N press/release", FALSE
);
6476 trace("testing Alt+VK_N press/release\n");
6478 keybd_event(VK_MENU
, 0, 0, 0);
6479 keybd_event('N', 0, 0, 0);
6480 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
6481 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
6482 pump_msg_loop(hwnd
, hAccel
);
6483 ok_sequence(WmAltVkN
, "Alt+VK_N press/release", FALSE
);
6485 trace("testing Ctrl+Alt+VK_N press/release 1\n");
6487 keybd_event(VK_CONTROL
, 0, 0, 0);
6488 keybd_event(VK_MENU
, 0, 0, 0);
6489 keybd_event('N', 0, 0, 0);
6490 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
6491 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
6492 keybd_event(VK_CONTROL
, 0, KEYEVENTF_KEYUP
, 0);
6493 pump_msg_loop(hwnd
, hAccel
);
6494 ok_sequence(WmCtrlAltVkN
, "Ctrl+Alt+VK_N press/release 1", FALSE
);
6496 ret
= DestroyAcceleratorTable(hAccel
);
6497 ok( ret
, "DestroyAcceleratorTable error %d\n", GetLastError());
6499 hAccel
= LoadAccelerators(GetModuleHandleA(0), MAKEINTRESOURCE(2));
6500 assert(hAccel
!= 0);
6502 trace("testing VK_N press/release\n");
6504 keybd_event('N', 0, 0, 0);
6505 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
6506 pump_msg_loop(hwnd
, hAccel
);
6507 ok_sequence(WmVkN
, "VK_N press/release", FALSE
);
6509 trace("testing Shift+VK_N press/release\n");
6511 keybd_event(VK_SHIFT
, 0, 0, 0);
6512 keybd_event('N', 0, 0, 0);
6513 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
6514 keybd_event(VK_SHIFT
, 0, KEYEVENTF_KEYUP
, 0);
6515 pump_msg_loop(hwnd
, hAccel
);
6516 ok_sequence(WmShiftVkN
, "Shift+VK_N press/release", FALSE
);
6518 trace("testing Ctrl+VK_N press/release 2\n");
6520 keybd_event(VK_CONTROL
, 0, 0, 0);
6521 keybd_event('N', 0, 0, 0);
6522 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
6523 keybd_event(VK_CONTROL
, 0, KEYEVENTF_KEYUP
, 0);
6524 pump_msg_loop(hwnd
, hAccel
);
6525 ok_sequence(WmCtrlVkN_2
, "Ctrl+VK_N press/release 2", FALSE
);
6527 trace("testing Alt+VK_N press/release 2\n");
6529 keybd_event(VK_MENU
, 0, 0, 0);
6530 keybd_event('N', 0, 0, 0);
6531 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
6532 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
6533 pump_msg_loop(hwnd
, hAccel
);
6534 ok_sequence(WmAltVkN_2
, "Alt+VK_N press/release 2", FALSE
);
6536 trace("testing Ctrl+Alt+VK_N press/release 2\n");
6538 keybd_event(VK_CONTROL
, 0, 0, 0);
6539 keybd_event(VK_MENU
, 0, 0, 0);
6540 keybd_event('N', 0, 0, 0);
6541 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
6542 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
6543 keybd_event(VK_CONTROL
, 0, KEYEVENTF_KEYUP
, 0);
6544 pump_msg_loop(hwnd
, hAccel
);
6545 ok_sequence(WmCtrlAltVkN
, "Ctrl+Alt+VK_N press/release 2", FALSE
);
6547 trace("testing Ctrl+Shift+VK_N press/release\n");
6549 keybd_event(VK_CONTROL
, 0, 0, 0);
6550 keybd_event(VK_SHIFT
, 0, 0, 0);
6551 keybd_event('N', 0, 0, 0);
6552 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
6553 keybd_event(VK_SHIFT
, 0, KEYEVENTF_KEYUP
, 0);
6554 keybd_event(VK_CONTROL
, 0, KEYEVENTF_KEYUP
, 0);
6555 pump_msg_loop(hwnd
, hAccel
);
6556 ok_sequence(WmCtrlShiftVkN
, "Ctrl+Shift+VK_N press/release", FALSE
);
6558 trace("testing Ctrl+Alt+Shift+VK_N press/release\n");
6560 keybd_event(VK_CONTROL
, 0, 0, 0);
6561 keybd_event(VK_MENU
, 0, 0, 0);
6562 keybd_event(VK_SHIFT
, 0, 0, 0);
6563 keybd_event('N', 0, 0, 0);
6564 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
6565 keybd_event(VK_SHIFT
, 0, KEYEVENTF_KEYUP
, 0);
6566 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
6567 keybd_event(VK_CONTROL
, 0, KEYEVENTF_KEYUP
, 0);
6568 pump_msg_loop(hwnd
, hAccel
);
6569 ok_sequence(WmCtrlAltShiftVkN
, "Ctrl+Alt+Shift+VK_N press/release", FALSE
);
6571 ret
= DestroyAcceleratorTable(hAccel
);
6572 ok( ret
, "DestroyAcceleratorTable error %d\n", GetLastError());
6574 trace("testing Alt press/release\n");
6576 keybd_event(VK_MENU
, 0, 0, 0);
6577 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
6578 keybd_event(VK_MENU
, 0, 0, 0);
6579 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
6580 pump_msg_loop(hwnd
, 0);
6581 /* this test doesn't pass in Wine for managed windows */
6582 ok_sequence(WmAltPressRelease
, "Alt press/release", TRUE
);
6584 trace("testing Alt+MouseButton press/release\n");
6585 /* first, move mouse pointer inside of the window client area */
6586 GetClientRect(hwnd
, &rc
);
6587 MapWindowPoints(hwnd
, 0, (LPPOINT
)&rc
, 2);
6588 rc
.left
+= (rc
.right
- rc
.left
)/2;
6589 rc
.top
+= (rc
.bottom
- rc
.top
)/2;
6590 SetCursorPos(rc
.left
, rc
.top
);
6594 keybd_event(VK_MENU
, 0, 0, 0);
6595 mouse_event(MOUSEEVENTF_LEFTDOWN
, 0, 0, 0, 0);
6596 mouse_event(MOUSEEVENTF_LEFTUP
, 0, 0, 0, 0);
6597 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
6598 pump_msg_loop(hwnd
, 0);
6599 ok_sequence(WmAltMouseButton
, "Alt+MouseButton press/release", FALSE
);
6601 trace("testing VK_F1 press/release\n");
6602 keybd_event(VK_F1
, 0, 0, 0);
6603 keybd_event(VK_F1
, 0, KEYEVENTF_KEYUP
, 0);
6604 pump_msg_loop(hwnd
, 0);
6605 ok_sequence(WmF1Seq
, "F1 press/release", FALSE
);
6607 trace("testing VK_APPS press/release\n");
6608 keybd_event(VK_APPS
, 0, 0, 0);
6609 keybd_event(VK_APPS
, 0, KEYEVENTF_KEYUP
, 0);
6610 pump_msg_loop(hwnd
, 0);
6611 ok_sequence(WmVkAppsSeq
, "VK_APPS press/release", FALSE
);
6613 DestroyWindow(hwnd
);
6616 /************* window procedures ********************/
6618 static LRESULT
MsgCheckProc (BOOL unicode
, HWND hwnd
, UINT message
,
6619 WPARAM wParam
, LPARAM lParam
)
6621 static long defwndproc_counter
= 0;
6622 static long beginpaint_counter
= 0;
6626 trace("%p, %04x, %08lx, %08lx\n", hwnd
, message
, wParam
, lParam
);
6628 /* explicitly ignore WM_GETICON message */
6629 if (message
== WM_GETICON
) return 0;
6631 /* ignore registered messages */
6632 if (message
>= 0xc000) return 0;
6638 LONG style
= GetWindowLongA(hwnd
, GWL_STYLE
);
6639 ok((BOOL
)wParam
== !(style
& WS_DISABLED
),
6640 "wrong WS_DISABLED state: %ld != %d\n", wParam
, !(style
& WS_DISABLED
));
6644 case WM_CAPTURECHANGED
:
6645 if (test_DestroyWindow_flag
)
6647 DWORD style
= GetWindowLongA(hwnd
, GWL_STYLE
);
6648 if (style
& WS_CHILD
)
6649 lParam
= GetWindowLongPtrA(hwnd
, GWLP_ID
);
6650 else if (style
& WS_POPUP
)
6651 lParam
= WND_POPUP_ID
;
6653 lParam
= WND_PARENT_ID
;
6661 ok(!GetWindow(hwnd
, GW_CHILD
), "children should be unlinked at this point\n");
6662 capture
= GetCapture();
6665 ok(capture
== hwnd
, "capture should NOT be released at this point (capture %p)\n", capture
);
6666 trace("current capture %p, releasing...\n", capture
);
6673 ok(pGetAncestor(hwnd
, GA_PARENT
) != 0, "parent should NOT be unlinked at this point\n");
6674 if (test_DestroyWindow_flag
)
6676 DWORD style
= GetWindowLongA(hwnd
, GWL_STYLE
);
6677 if (style
& WS_CHILD
)
6678 lParam
= GetWindowLongPtrA(hwnd
, GWLP_ID
);
6679 else if (style
& WS_POPUP
)
6680 lParam
= WND_POPUP_ID
;
6682 lParam
= WND_PARENT_ID
;
6686 /* test_accelerators() depends on this */
6693 case WM_DEVICECHANGE
:
6696 case WM_WINDOWPOSCHANGING
:
6697 case WM_WINDOWPOSCHANGED
:
6699 WINDOWPOS
*winpos
= (WINDOWPOS
*)lParam
;
6701 trace("%s\n", (message
== WM_WINDOWPOSCHANGING
) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
6702 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x ",
6703 winpos
->hwnd
, winpos
->hwndInsertAfter
,
6704 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
6705 dump_winpos_flags(winpos
->flags
);
6707 /* Log only documented flags, win2k uses 0x1000 and 0x2000
6708 * in the high word for internal purposes
6710 wParam
= winpos
->flags
& 0xffff;
6711 /* We are not interested in the flags that don't match under XP and Win9x */
6712 wParam
&= ~(SWP_NOZORDER
);
6717 msg
.message
= message
;
6718 msg
.flags
= sent
|wparam
|lparam
;
6719 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
6720 if (beginpaint_counter
) msg
.flags
|= beginpaint
;
6721 msg
.wParam
= wParam
;
6722 msg
.lParam
= lParam
;
6725 if (message
== WM_GETMINMAXINFO
&& (GetWindowLongA(hwnd
, GWL_STYLE
) & WS_CHILD
))
6727 HWND parent
= GetParent(hwnd
);
6729 MINMAXINFO
*minmax
= (MINMAXINFO
*)lParam
;
6731 GetClientRect(parent
, &rc
);
6732 trace("parent %p client size = (%d x %d)\n", parent
, rc
.right
, rc
.bottom
);
6733 trace("Reserved=%d,%d MaxSize=%d,%d MaxPos=%d,%d MinTrack=%d,%d MaxTrack=%d,%d\n",
6734 minmax
->ptReserved
.x
, minmax
->ptReserved
.y
,
6735 minmax
->ptMaxSize
.x
, minmax
->ptMaxSize
.y
,
6736 minmax
->ptMaxPosition
.x
, minmax
->ptMaxPosition
.y
,
6737 minmax
->ptMinTrackSize
.x
, minmax
->ptMinTrackSize
.y
,
6738 minmax
->ptMaxTrackSize
.x
, minmax
->ptMaxTrackSize
.y
);
6740 ok(minmax
->ptMaxSize
.x
== rc
.right
, "default width of maximized child %d != %d\n",
6741 minmax
->ptMaxSize
.x
, rc
.right
);
6742 ok(minmax
->ptMaxSize
.y
== rc
.bottom
, "default height of maximized child %d != %d\n",
6743 minmax
->ptMaxSize
.y
, rc
.bottom
);
6746 if (message
== WM_PAINT
)
6749 beginpaint_counter
++;
6750 BeginPaint( hwnd
, &ps
);
6751 beginpaint_counter
--;
6752 EndPaint( hwnd
, &ps
);
6756 defwndproc_counter
++;
6757 ret
= unicode
? DefWindowProcW(hwnd
, message
, wParam
, lParam
)
6758 : DefWindowProcA(hwnd
, message
, wParam
, lParam
);
6759 defwndproc_counter
--;
6764 static LRESULT WINAPI
MsgCheckProcA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
6766 return MsgCheckProc (FALSE
, hwnd
, message
, wParam
, lParam
);
6769 static LRESULT WINAPI
MsgCheckProcW(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
6771 return MsgCheckProc (TRUE
, hwnd
, message
, wParam
, lParam
);
6774 static LRESULT WINAPI
PopupMsgCheckProcA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
6776 static long defwndproc_counter
= 0;
6780 trace("popup: %p, %04x, %08lx, %08lx\n", hwnd
, message
, wParam
, lParam
);
6785 /* explicitly ignore WM_GETICON message */
6787 case WM_QUERYENDSESSION
:
6789 lParam
&= ~0x01; /* Vista adds a 0x01 flag */
6793 msg
.message
= message
;
6794 msg
.flags
= sent
|wparam
|lparam
;
6795 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
6796 msg
.wParam
= wParam
;
6797 msg
.lParam
= lParam
;
6800 if (message
== WM_CREATE
)
6802 DWORD style
= GetWindowLongA(hwnd
, GWL_STYLE
) | WS_VISIBLE
;
6803 SetWindowLongA(hwnd
, GWL_STYLE
, style
);
6806 defwndproc_counter
++;
6807 ret
= DefWindowProcA(hwnd
, message
, wParam
, lParam
);
6808 defwndproc_counter
--;
6813 static LRESULT WINAPI
ParentMsgCheckProcA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
6815 static long defwndproc_counter
= 0;
6816 static long beginpaint_counter
= 0;
6819 LPARAM logged_lParam
;
6821 trace("parent: %p, %04x, %08lx, %08lx\n", hwnd
, message
, wParam
, lParam
);
6823 /* explicitly ignore WM_GETICON message */
6824 if (message
== WM_GETICON
) return 0;
6826 /* ignore registered messages */
6827 if (message
>= 0xc000) return 0;
6829 logged_lParam
=lParam
;
6830 if (log_all_parent_messages
||
6831 message
== WM_PARENTNOTIFY
|| message
== WM_CANCELMODE
||
6832 message
== WM_SETFOCUS
|| message
== WM_KILLFOCUS
||
6833 message
== WM_ENABLE
|| message
== WM_ENTERIDLE
||
6834 message
== WM_DRAWITEM
||
6835 message
== WM_IME_SETCONTEXT
)
6849 INT ret
= GetClipBox((HDC
)wParam
, &rc
);
6851 trace("WM_ERASEBKGND: GetClipBox()=%d, (%d,%d-%d,%d)\n",
6852 ret
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
6856 case WM_WINDOWPOSCHANGING
:
6857 case WM_WINDOWPOSCHANGED
:
6859 WINDOWPOS
*winpos
= (WINDOWPOS
*)lParam
;
6861 trace("%s\n", (message
== WM_WINDOWPOSCHANGING
) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
6862 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x ",
6863 winpos
->hwnd
, winpos
->hwndInsertAfter
,
6864 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
6865 dump_winpos_flags(winpos
->flags
);
6867 /* Log only documented flags, win2k uses 0x1000 and 0x2000
6868 * in the high word for internal purposes
6870 wParam
= winpos
->flags
& 0xffff;
6871 /* We are not interested in the flags that don't match under XP and Win9x */
6872 wParam
&= ~(SWP_NOZORDER
);
6878 /* encode DRAWITEMSTRUCT into an LPARAM */
6879 DRAW_ITEM_STRUCT di
;
6880 DRAWITEMSTRUCT
*dis
= (DRAWITEMSTRUCT
*)lParam
;
6882 trace("WM_DRAWITEM: type %x, ctl_id %x, item_id %x, action %x, state %x\n",
6883 dis
->CtlType
, dis
->CtlID
, dis
->itemID
, dis
->itemAction
, dis
->itemState
);
6885 di
.u
.item
.type
= dis
->CtlType
;
6886 di
.u
.item
.ctl_id
= dis
->CtlID
;
6887 di
.u
.item
.item_id
= dis
->itemID
;
6888 di
.u
.item
.action
= dis
->itemAction
;
6889 di
.u
.item
.state
= dis
->itemState
;
6891 logged_lParam
= di
.u
.lp
;
6896 msg
.message
= message
;
6897 msg
.flags
= sent
|parent
|wparam
|lparam
;
6898 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
6899 if (beginpaint_counter
) msg
.flags
|= beginpaint
;
6900 msg
.wParam
= wParam
;
6901 msg
.lParam
= logged_lParam
;
6905 if (message
== WM_PAINT
)
6908 beginpaint_counter
++;
6909 BeginPaint( hwnd
, &ps
);
6910 beginpaint_counter
--;
6911 EndPaint( hwnd
, &ps
);
6915 defwndproc_counter
++;
6916 ret
= DefWindowProcA(hwnd
, message
, wParam
, lParam
);
6917 defwndproc_counter
--;
6922 static LRESULT WINAPI
TestDlgProcA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
6924 static long defwndproc_counter
= 0;
6928 trace("dialog: %p, %04x, %08lx, %08lx\n", hwnd
, message
, wParam
, lParam
);
6930 /* explicitly ignore WM_GETICON message */
6931 if (message
== WM_GETICON
) return 0;
6933 /* ignore registered messages */
6934 if (message
>= 0xc000) return 0;
6938 DefDlgProcA(hwnd
, DM_SETDEFID
, 1, 0);
6939 ret
= DefDlgProcA(hwnd
, DM_GETDEFID
, 0, 0);
6940 if (after_end_dialog
)
6941 ok( ret
== 0, "DM_GETDEFID should return 0 after EndDialog, got %lx\n", ret
);
6943 ok(HIWORD(ret
) == DC_HASDEFID
, "DM_GETDEFID should return DC_HASDEFID, got %lx\n", ret
);
6948 case WM_WINDOWPOSCHANGING
:
6949 case WM_WINDOWPOSCHANGED
:
6951 WINDOWPOS
*winpos
= (WINDOWPOS
*)lParam
;
6953 trace("%s\n", (message
== WM_WINDOWPOSCHANGING
) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
6954 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x ",
6955 winpos
->hwnd
, winpos
->hwndInsertAfter
,
6956 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
6957 dump_winpos_flags(winpos
->flags
);
6959 /* Log only documented flags, win2k uses 0x1000 and 0x2000
6960 * in the high word for internal purposes
6962 wParam
= winpos
->flags
& 0xffff;
6963 /* We are not interested in the flags that don't match under XP and Win9x */
6964 wParam
&= ~(SWP_NOZORDER
);
6969 msg
.message
= message
;
6970 msg
.flags
= sent
|wparam
|lparam
;
6971 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
6972 msg
.wParam
= wParam
;
6973 msg
.lParam
= lParam
;
6976 defwndproc_counter
++;
6977 ret
= DefDlgProcA(hwnd
, message
, wParam
, lParam
);
6978 defwndproc_counter
--;
6983 static void dump_winpos_flags(UINT flags
)
6985 if (!winetest_debug
) return;
6987 if (flags
& SWP_SHOWWINDOW
) printf("|SWP_SHOWWINDOW");
6988 if (flags
& SWP_HIDEWINDOW
) printf("|SWP_HIDEWINDOW");
6989 if (flags
& SWP_NOACTIVATE
) printf("|SWP_NOACTIVATE");
6990 if (flags
& SWP_FRAMECHANGED
) printf("|SWP_FRAMECHANGED");
6991 if (flags
& SWP_NOCOPYBITS
) printf("|SWP_NOCOPYBITS");
6992 if (flags
& SWP_NOOWNERZORDER
) printf("|SWP_NOOWNERZORDER");
6993 if (flags
& SWP_NOSENDCHANGING
) printf("|SWP_NOSENDCHANGING");
6994 if (flags
& SWP_DEFERERASE
) printf("|SWP_DEFERERASE");
6995 if (flags
& SWP_ASYNCWINDOWPOS
) printf("|SWP_ASYNCWINDOWPOS");
6996 if (flags
& SWP_NOZORDER
) printf("|SWP_NOZORDER");
6997 if (flags
& SWP_NOREDRAW
) printf("|SWP_NOREDRAW");
6998 if (flags
& SWP_NOSIZE
) printf("|SWP_NOSIZE");
6999 if (flags
& SWP_NOMOVE
) printf("|SWP_NOMOVE");
7000 if (flags
& SWP_NOCLIENTSIZE
) printf("|SWP_NOCLIENTSIZE");
7001 if (flags
& SWP_NOCLIENTMOVE
) printf("|SWP_NOCLIENTMOVE");
7003 #define DUMPED_FLAGS \
7009 SWP_FRAMECHANGED | \
7013 SWP_NOOWNERZORDER | \
7014 SWP_NOSENDCHANGING | \
7016 SWP_ASYNCWINDOWPOS | \
7017 SWP_NOCLIENTSIZE | \
7020 if(flags
& ~DUMPED_FLAGS
) printf("|0x%04x", flags
& ~DUMPED_FLAGS
);
7025 static LRESULT WINAPI
ShowWindowProcA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
7027 static long defwndproc_counter
= 0;
7031 /* log only specific messages we are interested in */
7034 #if 0 /* probably log these as well */
7040 trace("WM_SHOWWINDOW %ld\n", wParam
);
7043 trace("WM_SIZE %ld\n", wParam
);
7048 case WM_GETMINMAXINFO
:
7049 trace("WM_GETMINMAXINFO\n");
7052 case WM_WINDOWPOSCHANGING
:
7053 case WM_WINDOWPOSCHANGED
:
7055 WINDOWPOS
*winpos
= (WINDOWPOS
*)lParam
;
7057 trace("%s\n", (message
== WM_WINDOWPOSCHANGING
) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
7058 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
7059 winpos
->hwnd
, winpos
->hwndInsertAfter
,
7060 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
7062 dump_winpos_flags(winpos
->flags
);
7064 /* Log only documented flags, win2k uses 0x1000 and 0x2000
7065 * in the high word for internal purposes
7067 wParam
= winpos
->flags
& 0xffff;
7068 /* We are not interested in the flags that don't match under XP and Win9x */
7069 wParam
&= ~(SWP_NOZORDER
);
7073 default: /* ignore */
7074 /*trace("showwindow: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);*/
7075 return DefWindowProcA(hwnd
, message
, wParam
, lParam
);
7078 msg
.message
= message
;
7079 msg
.flags
= sent
|wparam
|lparam
;
7080 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
7081 msg
.wParam
= wParam
;
7082 msg
.lParam
= lParam
;
7085 defwndproc_counter
++;
7086 ret
= DefWindowProcA(hwnd
, message
, wParam
, lParam
);
7087 defwndproc_counter
--;
7092 LRESULT WINAPI
PaintLoopProcA(HWND hWnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
7096 case WM_CREATE
: return 0;
7105 if (PeekMessageA(&msg2
, 0, 0, 0, 1))
7107 TranslateMessage(&msg2
);
7108 DispatchMessage(&msg2
);
7112 else ok(broken(1), "infinite loop\n");
7114 paint_loop_done
= 1;
7115 return DefWindowProcA(hWnd
,msg
,wParam
,lParam
);
7118 return DefWindowProcA(hWnd
,msg
,wParam
,lParam
);
7121 static BOOL
RegisterWindowClasses(void)
7127 cls
.lpfnWndProc
= MsgCheckProcA
;
7130 cls
.hInstance
= GetModuleHandleA(0);
7132 cls
.hCursor
= LoadCursorA(0, (LPSTR
)IDC_ARROW
);
7133 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
7134 cls
.lpszMenuName
= NULL
;
7135 cls
.lpszClassName
= "TestWindowClass";
7136 if(!RegisterClassA(&cls
)) return FALSE
;
7138 cls
.lpfnWndProc
= ShowWindowProcA
;
7139 cls
.lpszClassName
= "ShowWindowClass";
7140 if(!RegisterClassA(&cls
)) return FALSE
;
7142 cls
.lpfnWndProc
= PopupMsgCheckProcA
;
7143 cls
.lpszClassName
= "TestPopupClass";
7144 if(!RegisterClassA(&cls
)) return FALSE
;
7146 cls
.lpfnWndProc
= ParentMsgCheckProcA
;
7147 cls
.lpszClassName
= "TestParentClass";
7148 if(!RegisterClassA(&cls
)) return FALSE
;
7150 cls
.lpfnWndProc
= DefWindowProcA
;
7151 cls
.lpszClassName
= "SimpleWindowClass";
7152 if(!RegisterClassA(&cls
)) return FALSE
;
7154 cls
.lpfnWndProc
= PaintLoopProcA
;
7155 cls
.lpszClassName
= "PaintLoopWindowClass";
7156 if(!RegisterClassA(&cls
)) return FALSE
;
7158 cls
.style
= CS_NOCLOSE
;
7159 cls
.lpszClassName
= "NoCloseWindowClass";
7160 if(!RegisterClassA(&cls
)) return FALSE
;
7162 ok(GetClassInfoA(0, "#32770", &cls
), "GetClassInfo failed\n");
7164 cls
.hInstance
= GetModuleHandleA(0);
7165 cls
.hbrBackground
= 0;
7166 cls
.lpfnWndProc
= TestDlgProcA
;
7167 cls
.lpszClassName
= "TestDialogClass";
7168 if(!RegisterClassA(&cls
)) return FALSE
;
7171 clsW
.lpfnWndProc
= MsgCheckProcW
;
7172 clsW
.cbClsExtra
= 0;
7173 clsW
.cbWndExtra
= 0;
7174 clsW
.hInstance
= GetModuleHandleW(0);
7176 clsW
.hCursor
= LoadCursorW(0, (LPWSTR
)IDC_ARROW
);
7177 clsW
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
7178 clsW
.lpszMenuName
= NULL
;
7179 clsW
.lpszClassName
= testWindowClassW
;
7180 RegisterClassW(&clsW
); /* ignore error, this fails on Win9x */
7185 static BOOL
is_our_logged_class(HWND hwnd
)
7189 if (GetClassNameA(hwnd
, buf
, sizeof(buf
)))
7191 if (!lstrcmpiA(buf
, "TestWindowClass") ||
7192 !lstrcmpiA(buf
, "ShowWindowClass") ||
7193 !lstrcmpiA(buf
, "TestParentClass") ||
7194 !lstrcmpiA(buf
, "TestPopupClass") ||
7195 !lstrcmpiA(buf
, "SimpleWindowClass") ||
7196 !lstrcmpiA(buf
, "TestDialogClass") ||
7197 !lstrcmpiA(buf
, "MDI_frame_class") ||
7198 !lstrcmpiA(buf
, "MDI_client_class") ||
7199 !lstrcmpiA(buf
, "MDI_child_class") ||
7200 !lstrcmpiA(buf
, "my_button_class") ||
7201 !lstrcmpiA(buf
, "my_edit_class") ||
7202 !lstrcmpiA(buf
, "static") ||
7203 !lstrcmpiA(buf
, "ListBox") ||
7204 !lstrcmpiA(buf
, "ComboBox") ||
7205 !lstrcmpiA(buf
, "MyDialogClass") ||
7206 !lstrcmpiA(buf
, "#32770") ||
7207 !lstrcmpiA(buf
, "#32768"))
7209 trace("ignoring window class %s\n", buf
);
7214 static HHOOK hCBT_hook
;
7215 static DWORD cbt_hook_thread_id
;
7217 static LRESULT CALLBACK
cbt_hook_proc(int nCode
, WPARAM wParam
, LPARAM lParam
)
7219 static const char * const CBT_code_name
[10] = {
7226 "HCBT_CLICKSKIPPED",
7230 const char *code_name
= (nCode
>= 0 && nCode
<= HCBT_SETFOCUS
) ? CBT_code_name
[nCode
] : "Unknown";
7233 trace("CBT: %d (%s), %08lx, %08lx\n", nCode
, code_name
, wParam
, lParam
);
7235 ok(cbt_hook_thread_id
== GetCurrentThreadId(), "we didn't ask for events from other threads\n");
7237 if (nCode
== HCBT_CLICKSKIPPED
)
7239 /* ignore this event, XP sends it a lot when switching focus between windows */
7240 return CallNextHookEx(hCBT_hook
, nCode
, wParam
, lParam
);
7243 if (nCode
== HCBT_SYSCOMMAND
|| nCode
== HCBT_KEYSKIPPED
)
7247 msg
.message
= nCode
;
7248 msg
.flags
= hook
|wparam
|lparam
;
7249 msg
.wParam
= wParam
;
7250 msg
.lParam
= lParam
;
7253 return CallNextHookEx(hCBT_hook
, nCode
, wParam
, lParam
);
7256 if (nCode
== HCBT_DESTROYWND
)
7258 if (test_DestroyWindow_flag
)
7260 DWORD style
= GetWindowLongA((HWND
)wParam
, GWL_STYLE
);
7261 if (style
& WS_CHILD
)
7262 lParam
= GetWindowLongPtrA((HWND
)wParam
, GWLP_ID
);
7263 else if (style
& WS_POPUP
)
7264 lParam
= WND_POPUP_ID
;
7266 lParam
= WND_PARENT_ID
;
7270 /* Log also SetFocus(0) calls */
7271 hwnd
= wParam
? (HWND
)wParam
: (HWND
)lParam
;
7273 if (is_our_logged_class(hwnd
))
7277 msg
.message
= nCode
;
7278 msg
.flags
= hook
|wparam
|lparam
;
7279 msg
.wParam
= wParam
;
7280 msg
.lParam
= lParam
;
7283 return CallNextHookEx(hCBT_hook
, nCode
, wParam
, lParam
);
7286 static void CALLBACK
win_event_proc(HWINEVENTHOOK hevent
,
7294 trace("WEH:%p,event %08x,hwnd %p,obj %08x,id %08x,thread %08x,time %08x\n",
7295 hevent
, event
, hwnd
, object_id
, child_id
, thread_id
, event_time
);
7297 ok(thread_id
== GetCurrentThreadId(), "we didn't ask for events from other threads\n");
7299 /* ignore mouse cursor events */
7300 if (object_id
== OBJID_CURSOR
) return;
7302 if (!hwnd
|| is_our_logged_class(hwnd
))
7306 msg
.message
= event
;
7307 msg
.flags
= winevent_hook
|wparam
|lparam
;
7308 msg
.wParam
= object_id
;
7309 msg
.lParam
= child_id
;
7314 static const WCHAR wszUnicode
[] = {'U','n','i','c','o','d','e',0};
7315 static const WCHAR wszAnsi
[] = {'U',0};
7317 static LRESULT CALLBACK
MsgConversionProcW(HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
7321 case CB_FINDSTRINGEXACT
:
7322 trace("String: %p\n", (LPCWSTR
)lParam
);
7323 if (!lstrcmpW((LPCWSTR
)lParam
, wszUnicode
))
7325 if (!lstrcmpW((LPCWSTR
)lParam
, wszAnsi
))
7329 return DefWindowProcW(hwnd
, uMsg
, wParam
, lParam
);
7332 static const struct message WmGetTextLengthAfromW
[] = {
7333 { WM_GETTEXTLENGTH
, sent
},
7334 { WM_GETTEXT
, sent
|optional
},
7338 static const WCHAR dummy_window_text
[] = {'d','u','m','m','y',' ','t','e','x','t',0};
7340 /* dummy window proc for WM_GETTEXTLENGTH test */
7341 static LRESULT CALLBACK
get_text_len_proc( HWND hwnd
, UINT msg
, WPARAM wp
, LPARAM lp
)
7345 case WM_GETTEXTLENGTH
:
7346 return lstrlenW(dummy_window_text
) + 37; /* some random length */
7348 lstrcpynW( (LPWSTR
)lp
, dummy_window_text
, wp
);
7349 return lstrlenW( (LPWSTR
)lp
);
7351 return DefWindowProcW( hwnd
, msg
, wp
, lp
);
7355 static void test_message_conversion(void)
7357 static const WCHAR wszMsgConversionClass
[] =
7358 {'M','s','g','C','o','n','v','e','r','s','i','o','n','C','l','a','s','s',0};
7362 WNDPROC wndproc
, newproc
;
7366 cls
.lpfnWndProc
= MsgConversionProcW
;
7369 cls
.hInstance
= GetModuleHandleW(NULL
);
7371 cls
.hCursor
= LoadCursorW(NULL
, (LPWSTR
)IDC_ARROW
);
7372 cls
.hbrBackground
= (HBRUSH
)(COLOR_BTNFACE
+1);
7373 cls
.lpszMenuName
= NULL
;
7374 cls
.lpszClassName
= wszMsgConversionClass
;
7375 /* this call will fail on Win9x, but that doesn't matter as this test is
7376 * meaningless on those platforms */
7377 if(!RegisterClassW(&cls
)) return;
7379 hwnd
= CreateWindowExW(0, wszMsgConversionClass
, NULL
, WS_OVERLAPPED
,
7380 100, 100, 200, 200, 0, 0, 0, NULL
);
7381 ok(hwnd
!= NULL
, "Window creation failed\n");
7385 wndproc
= (WNDPROC
)GetWindowLongPtrA(hwnd
, GWLP_WNDPROC
);
7386 lRes
= CallWindowProcA(wndproc
, hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
7387 ok(lRes
== 0, "String should have been converted\n");
7388 lRes
= CallWindowProcW(wndproc
, hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
7389 ok(lRes
== 1, "String shouldn't have been converted\n");
7393 wndproc
= (WNDPROC
)GetWindowLongPtrW(hwnd
, GWLP_WNDPROC
);
7394 lRes
= CallWindowProcA(wndproc
, hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
7395 ok(lRes
== 1, "String shouldn't have been converted\n");
7396 lRes
= CallWindowProcW(wndproc
, hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
7397 ok(lRes
== 1, "String shouldn't have been converted\n");
7399 /* Synchronous messages */
7401 lRes
= SendMessageA(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
7402 ok(lRes
== 0, "String should have been converted\n");
7403 lRes
= SendMessageW(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
7404 ok(lRes
== 1, "String shouldn't have been converted\n");
7406 /* Asynchronous messages */
7409 lRes
= PostMessageA(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
7410 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
7411 "PostMessage on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
7413 lRes
= PostMessageW(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
7414 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
7415 "PostMessage on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
7417 lRes
= PostThreadMessageA(GetCurrentThreadId(), CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
7418 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
7419 "PosThreadtMessage on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
7421 lRes
= PostThreadMessageW(GetCurrentThreadId(), CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
7422 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
7423 "PosThreadtMessage on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
7425 lRes
= SendNotifyMessageA(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
7426 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
7427 "SendNotifyMessage on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
7429 lRes
= SendNotifyMessageW(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
7430 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
7431 "SendNotifyMessage on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
7433 lRes
= SendMessageCallbackA(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
, NULL
, 0);
7434 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
7435 "SendMessageCallback on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
7437 lRes
= SendMessageCallbackW(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
, NULL
, 0);
7438 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
7439 "SendMessageCallback on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
7441 /* Check WM_GETTEXTLENGTH A->W behaviour, whether WM_GETTEXT is also sent or not */
7443 hwnd
= CreateWindowW (testWindowClassW
, wszUnicode
,
7444 WS_OVERLAPPEDWINDOW
,
7445 100, 100, 200, 200, 0, 0, 0, NULL
);
7448 lRes
= SendMessageA (hwnd
, WM_GETTEXTLENGTH
, 0, 0);
7449 ok_sequence(WmGetTextLengthAfromW
, "ANSI WM_GETTEXTLENGTH to Unicode window", FALSE
);
7450 ok( lRes
== WideCharToMultiByte( CP_ACP
, 0, wszUnicode
, lstrlenW(wszUnicode
), NULL
, 0, NULL
, NULL
),
7451 "got bad length %ld\n", lRes
);
7454 lRes
= CallWindowProcA( (WNDPROC
)GetWindowLongPtrA( hwnd
, GWLP_WNDPROC
),
7455 hwnd
, WM_GETTEXTLENGTH
, 0, 0);
7456 ok_sequence(WmGetTextLengthAfromW
, "ANSI WM_GETTEXTLENGTH to Unicode window", FALSE
);
7457 ok( lRes
== WideCharToMultiByte( CP_ACP
, 0, wszUnicode
, lstrlenW(wszUnicode
), NULL
, 0, NULL
, NULL
),
7458 "got bad length %ld\n", lRes
);
7460 wndproc
= (WNDPROC
)SetWindowLongPtrW( hwnd
, GWLP_WNDPROC
, (LONG_PTR
)get_text_len_proc
);
7461 newproc
= (WNDPROC
)GetWindowLongPtrA( hwnd
, GWLP_WNDPROC
);
7462 lRes
= CallWindowProcA( newproc
, hwnd
, WM_GETTEXTLENGTH
, 0, 0 );
7463 ok( lRes
== WideCharToMultiByte( CP_ACP
, 0, dummy_window_text
, lstrlenW(dummy_window_text
),
7464 NULL
, 0, NULL
, NULL
) ||
7465 broken(lRes
== lstrlenW(dummy_window_text
) + 37),
7466 "got bad length %ld\n", lRes
);
7468 SetWindowLongPtrW( hwnd
, GWLP_WNDPROC
, (LONG_PTR
)wndproc
); /* restore old wnd proc */
7469 lRes
= CallWindowProcA( newproc
, hwnd
, WM_GETTEXTLENGTH
, 0, 0 );
7470 ok( lRes
== WideCharToMultiByte( CP_ACP
, 0, dummy_window_text
, lstrlenW(dummy_window_text
),
7471 NULL
, 0, NULL
, NULL
) ||
7472 broken(lRes
== lstrlenW(dummy_window_text
) + 37),
7473 "got bad length %ld\n", lRes
);
7475 ret
= DestroyWindow(hwnd
);
7476 ok( ret
, "DestroyWindow() error %d\n", GetLastError());
7486 static VOID CALLBACK
tfunc(HWND hwnd
, UINT uMsg
, UINT_PTR id
, DWORD dwTime
)
7490 #define TIMER_ID 0x19
7492 static DWORD WINAPI
timer_thread_proc(LPVOID x
)
7494 struct timer_info
*info
= x
;
7497 r
= KillTimer(info
->hWnd
, 0x19);
7498 ok(r
,"KillTimer failed in thread\n");
7499 r
= SetTimer(info
->hWnd
,TIMER_ID
,10000,tfunc
);
7500 ok(r
,"SetTimer failed in thread\n");
7501 ok(r
==TIMER_ID
,"SetTimer id different\n");
7502 r
= SetEvent(info
->handles
[0]);
7503 ok(r
,"SetEvent failed in thread\n");
7507 static void test_timers(void)
7509 struct timer_info info
;
7512 info
.hWnd
= CreateWindow ("TestWindowClass", NULL
,
7513 WS_OVERLAPPEDWINDOW
,
7514 CW_USEDEFAULT
, CW_USEDEFAULT
, 300, 300, 0,
7517 info
.id
= SetTimer(info
.hWnd
,TIMER_ID
,10000,tfunc
);
7518 ok(info
.id
, "SetTimer failed\n");
7519 ok(info
.id
==TIMER_ID
, "SetTimer timer ID different\n");
7520 info
.handles
[0] = CreateEvent(NULL
,0,0,NULL
);
7521 info
.handles
[1] = CreateThread(NULL
,0,timer_thread_proc
,&info
,0,&id
);
7523 WaitForMultipleObjects(2, info
.handles
, FALSE
, INFINITE
);
7525 WaitForSingleObject(info
.handles
[1], INFINITE
);
7527 CloseHandle(info
.handles
[0]);
7528 CloseHandle(info
.handles
[1]);
7530 ok( KillTimer(info
.hWnd
, TIMER_ID
), "KillTimer failed\n");
7532 ok(DestroyWindow(info
.hWnd
), "failed to destroy window\n");
7535 static int count
= 0;
7536 static VOID CALLBACK
callback_count(
7546 static void test_timers_no_wnd(void)
7552 id
= SetTimer(NULL
, 0, 100, callback_count
);
7553 ok(id
!= 0, "did not get id from SetTimer.\n");
7554 id2
= SetTimer(NULL
, id
, 200, callback_count
);
7555 ok(id2
== id
, "did not get same id from SetTimer when replacing (%li expected %li).\n", id2
, id
);
7557 while (PeekMessage(&msg
, NULL
, 0, 0, PM_REMOVE
)) DispatchMessage(&msg
);
7558 ok(count
== 0, "did not get zero count as expected (%i).\n", count
);
7560 while (PeekMessage(&msg
, NULL
, 0, 0, PM_REMOVE
)) DispatchMessage(&msg
);
7561 ok(count
== 1, "did not get one count as expected (%i).\n", count
);
7562 KillTimer(NULL
, id
);
7564 while (PeekMessage(&msg
, NULL
, 0, 0, PM_REMOVE
)) DispatchMessage(&msg
);
7565 ok(count
== 1, "killing replaced timer did not work (%i).\n", count
);
7568 /* Various win events with arbitrary parameters */
7569 static const struct message WmWinEventsSeq
[] = {
7570 { EVENT_SYSTEM_SOUND
, winevent_hook
|wparam
|lparam
, OBJID_WINDOW
, 0 },
7571 { EVENT_SYSTEM_ALERT
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 1 },
7572 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, OBJID_TITLEBAR
, 2 },
7573 { EVENT_SYSTEM_MENUSTART
, winevent_hook
|wparam
|lparam
, OBJID_MENU
, 3 },
7574 { EVENT_SYSTEM_MENUEND
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 4 },
7575 { EVENT_SYSTEM_MENUPOPUPSTART
, winevent_hook
|wparam
|lparam
, OBJID_VSCROLL
, 5 },
7576 { EVENT_SYSTEM_MENUPOPUPEND
, winevent_hook
|wparam
|lparam
, OBJID_HSCROLL
, 6 },
7577 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, OBJID_SIZEGRIP
, 7 },
7578 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 8 },
7579 /* our win event hook ignores OBJID_CURSOR events */
7580 /*{ EVENT_SYSTEM_MOVESIZESTART, winevent_hook|wparam|lparam, OBJID_CURSOR, 9 },*/
7581 { EVENT_SYSTEM_MOVESIZEEND
, winevent_hook
|wparam
|lparam
, OBJID_ALERT
, 10 },
7582 { EVENT_SYSTEM_CONTEXTHELPSTART
, winevent_hook
|wparam
|lparam
, OBJID_SOUND
, 11 },
7583 { EVENT_SYSTEM_CONTEXTHELPEND
, winevent_hook
|wparam
|lparam
, OBJID_QUERYCLASSNAMEIDX
, 12 },
7584 { EVENT_SYSTEM_DRAGDROPSTART
, winevent_hook
|wparam
|lparam
, OBJID_NATIVEOM
, 13 },
7585 { EVENT_SYSTEM_DRAGDROPEND
, winevent_hook
|wparam
|lparam
, OBJID_WINDOW
, 0 },
7586 { EVENT_SYSTEM_DIALOGSTART
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 1 },
7587 { EVENT_SYSTEM_DIALOGEND
, winevent_hook
|wparam
|lparam
, OBJID_TITLEBAR
, 2 },
7588 { EVENT_SYSTEM_SCROLLINGSTART
, winevent_hook
|wparam
|lparam
, OBJID_MENU
, 3 },
7589 { EVENT_SYSTEM_SCROLLINGEND
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 4 },
7590 { EVENT_SYSTEM_SWITCHSTART
, winevent_hook
|wparam
|lparam
, OBJID_VSCROLL
, 5 },
7591 { EVENT_SYSTEM_SWITCHEND
, winevent_hook
|wparam
|lparam
, OBJID_HSCROLL
, 6 },
7592 { EVENT_SYSTEM_MINIMIZESTART
, winevent_hook
|wparam
|lparam
, OBJID_SIZEGRIP
, 7 },
7593 { EVENT_SYSTEM_MINIMIZEEND
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 8 },
7596 static const struct message WmWinEventCaretSeq
[] = {
7597 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 1 */
7598 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 1 */
7599 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 2 */
7600 { EVENT_OBJECT_NAMECHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 1 */
7603 static const struct message WmWinEventCaretSeq_2
[] = {
7604 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 1/2 */
7605 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 1/2 */
7606 { EVENT_OBJECT_NAMECHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 1/2 */
7609 static const struct message WmWinEventAlertSeq
[] = {
7610 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_ALERT
, 0 },
7613 static const struct message WmWinEventAlertSeq_2
[] = {
7614 /* create window in the thread proc */
7615 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_WINDOW
, 2 },
7616 /* our test event */
7617 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_ALERT
, 2 },
7620 static const struct message WmGlobalHookSeq_1
[] = {
7621 /* create window in the thread proc */
7622 { HCBT_CREATEWND
, hook
|lparam
, 0, 2 },
7623 /* our test events */
7624 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_PREVWINDOW
, 2 },
7625 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_NEXTWINDOW
, 2 },
7628 static const struct message WmGlobalHookSeq_2
[] = {
7629 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_NEXTWINDOW
, 0 }, /* old local hook */
7630 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_NEXTWINDOW
, 2 }, /* new global hook */
7631 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_PREVWINDOW
, 0 }, /* old local hook */
7632 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_PREVWINDOW
, 2 }, /* new global hook */
7636 static const struct message WmMouseLLHookSeq
[] = {
7637 { WM_MOUSEMOVE
, hook
},
7638 { WM_LBUTTONUP
, hook
},
7639 { WM_MOUSEMOVE
, hook
},
7643 static void CALLBACK
win_event_global_hook_proc(HWINEVENTHOOK hevent
,
7653 trace("WEH_2:%p,event %08x,hwnd %p,obj %08x,id %08x,thread %08x,time %08x\n",
7654 hevent
, event
, hwnd
, object_id
, child_id
, thread_id
, event_time
);
7656 if (GetClassNameA(hwnd
, buf
, sizeof(buf
)))
7658 if (!lstrcmpiA(buf
, "TestWindowClass") ||
7659 !lstrcmpiA(buf
, "static"))
7663 msg
.message
= event
;
7664 msg
.flags
= winevent_hook
|wparam
|lparam
;
7665 msg
.wParam
= object_id
;
7666 msg
.lParam
= (thread_id
== GetCurrentThreadId()) ? child_id
: (child_id
+ 2);
7672 static HHOOK hCBT_global_hook
;
7673 static DWORD cbt_global_hook_thread_id
;
7675 static LRESULT CALLBACK
cbt_global_hook_proc(int nCode
, WPARAM wParam
, LPARAM lParam
)
7680 trace("CBT_2: %d, %08lx, %08lx\n", nCode
, wParam
, lParam
);
7682 if (nCode
== HCBT_SYSCOMMAND
)
7686 msg
.message
= nCode
;
7687 msg
.flags
= hook
|wparam
|lparam
;
7688 msg
.wParam
= wParam
;
7689 msg
.lParam
= (cbt_global_hook_thread_id
== GetCurrentThreadId()) ? 1 : 2;
7692 return CallNextHookEx(hCBT_global_hook
, nCode
, wParam
, lParam
);
7694 /* WH_MOUSE_LL hook */
7695 if (nCode
== HC_ACTION
)
7697 MSLLHOOKSTRUCT
*mhll
= (MSLLHOOKSTRUCT
*)lParam
;
7699 /* we can't test for real mouse events */
7700 if (mhll
->flags
& LLMHF_INJECTED
)
7704 memset (&msg
, 0, sizeof (msg
));
7705 msg
.message
= wParam
;
7709 return CallNextHookEx(hCBT_global_hook
, nCode
, wParam
, lParam
);
7712 /* Log also SetFocus(0) calls */
7713 hwnd
= wParam
? (HWND
)wParam
: (HWND
)lParam
;
7715 if (GetClassNameA(hwnd
, buf
, sizeof(buf
)))
7717 if (!lstrcmpiA(buf
, "TestWindowClass") ||
7718 !lstrcmpiA(buf
, "static"))
7722 msg
.message
= nCode
;
7723 msg
.flags
= hook
|wparam
|lparam
;
7724 msg
.wParam
= wParam
;
7725 msg
.lParam
= (cbt_global_hook_thread_id
== GetCurrentThreadId()) ? 1 : 2;
7729 return CallNextHookEx(hCBT_global_hook
, nCode
, wParam
, lParam
);
7732 static DWORD WINAPI
win_event_global_thread_proc(void *param
)
7736 HANDLE hevent
= *(HANDLE
*)param
;
7738 assert(pNotifyWinEvent
);
7740 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
, 0,0,0,0,0,0,0, NULL
);
7742 trace("created thread window %p\n", hwnd
);
7744 *(HWND
*)param
= hwnd
;
7747 /* this event should be received only by our new hook proc,
7748 * an old one does not expect an event from another thread.
7750 pNotifyWinEvent(EVENT_OBJECT_LOCATIONCHANGE
, hwnd
, OBJID_ALERT
, 0);
7753 while (GetMessage(&msg
, 0, 0, 0))
7755 TranslateMessage(&msg
);
7756 DispatchMessage(&msg
);
7761 static DWORD WINAPI
cbt_global_hook_thread_proc(void *param
)
7765 HANDLE hevent
= *(HANDLE
*)param
;
7768 /* these events should be received only by our new hook proc,
7769 * an old one does not expect an event from another thread.
7772 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
, 0,0,0,0,0,0,0, NULL
);
7774 trace("created thread window %p\n", hwnd
);
7776 *(HWND
*)param
= hwnd
;
7778 /* Windows doesn't like when a thread plays games with the focus,
7779 that leads to all kinds of misbehaviours and failures to activate
7780 a window. So, better keep next lines commented out.
7784 DefWindowProcA(hwnd
, WM_SYSCOMMAND
, SC_PREVWINDOW
, 0);
7785 DefWindowProcA(hwnd
, WM_SYSCOMMAND
, SC_NEXTWINDOW
, 0);
7789 while (GetMessage(&msg
, 0, 0, 0))
7791 TranslateMessage(&msg
);
7792 DispatchMessage(&msg
);
7797 static DWORD WINAPI
mouse_ll_global_thread_proc(void *param
)
7801 HANDLE hevent
= *(HANDLE
*)param
;
7803 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
, 0,0,0,0,0,0,0, NULL
);
7805 trace("created thread window %p\n", hwnd
);
7807 *(HWND
*)param
= hwnd
;
7811 /* Windows doesn't like when a thread plays games with the focus,
7812 * that leads to all kinds of misbehaviours and failures to activate
7813 * a window. So, better don't generate a mouse click message below.
7815 mouse_event(MOUSEEVENTF_MOVE
, -1, 0, 0, 0);
7816 mouse_event(MOUSEEVENTF_LEFTUP
, 0, 0, 0, 0);
7817 mouse_event(MOUSEEVENTF_MOVE
, 1, 0, 0, 0);
7820 while (GetMessage(&msg
, 0, 0, 0))
7822 TranslateMessage(&msg
);
7823 DispatchMessage(&msg
);
7828 static void test_winevents(void)
7834 HANDLE hthread
, hevent
;
7836 HWINEVENTHOOK hhook
;
7837 const struct message
*events
= WmWinEventsSeq
;
7839 hwnd
= CreateWindowExA(0, "TestWindowClass", NULL
,
7840 WS_OVERLAPPEDWINDOW
,
7841 CW_USEDEFAULT
, CW_USEDEFAULT
, 300, 300, 0,
7845 /****** start of global hook test *************/
7846 hCBT_global_hook
= SetWindowsHookExA(WH_CBT
, cbt_global_hook_proc
, GetModuleHandleA(0), 0);
7847 if (!hCBT_global_hook
)
7849 ok(DestroyWindow(hwnd
), "failed to destroy window\n");
7850 skip( "cannot set global hook\n" );
7854 hevent
= CreateEventA(NULL
, 0, 0, NULL
);
7856 hwnd2
= (HWND
)hevent
;
7858 hthread
= CreateThread(NULL
, 0, cbt_global_hook_thread_proc
, &hwnd2
, 0, &tid
);
7859 ok(hthread
!= NULL
, "CreateThread failed, error %d\n", GetLastError());
7861 ok(WaitForSingleObject(hevent
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
7863 ok_sequence(WmGlobalHookSeq_1
, "global hook 1", FALSE
);
7866 /* this one should be received only by old hook proc */
7867 DefWindowProcA(hwnd
, WM_SYSCOMMAND
, SC_NEXTWINDOW
, 0);
7868 /* this one should be received only by old hook proc */
7869 DefWindowProcA(hwnd
, WM_SYSCOMMAND
, SC_PREVWINDOW
, 0);
7871 ok_sequence(WmGlobalHookSeq_2
, "global hook 2", FALSE
);
7873 ret
= UnhookWindowsHookEx(hCBT_global_hook
);
7874 ok( ret
, "UnhookWindowsHookEx error %d\n", GetLastError());
7876 PostThreadMessageA(tid
, WM_QUIT
, 0, 0);
7877 ok(WaitForSingleObject(hthread
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
7878 CloseHandle(hthread
);
7879 CloseHandle(hevent
);
7880 ok(!IsWindow(hwnd2
), "window should be destroyed on thread exit\n");
7881 /****** end of global hook test *************/
7883 if (!pSetWinEventHook
|| !pNotifyWinEvent
|| !pUnhookWinEvent
)
7885 ok(DestroyWindow(hwnd
), "failed to destroy window\n");
7893 /* this test doesn't pass under Win9x */
7894 /* win2k ignores events with hwnd == 0 */
7895 SetLastError(0xdeadbeef);
7896 pNotifyWinEvent(events
[0].message
, 0, events
[0].wParam
, events
[0].lParam
);
7897 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
|| /* Win2k */
7898 GetLastError() == 0xdeadbeef, /* Win9x */
7899 "unexpected error %d\n", GetLastError());
7900 ok_sequence(WmEmptySeq
, "empty notify winevents", FALSE
);
7903 for (i
= 0; i
< sizeof(WmWinEventsSeq
)/sizeof(WmWinEventsSeq
[0]); i
++)
7904 pNotifyWinEvent(events
[i
].message
, hwnd
, events
[i
].wParam
, events
[i
].lParam
);
7906 ok_sequence(WmWinEventsSeq
, "notify winevents", FALSE
);
7908 /****** start of event filtering test *************/
7909 hhook
= (HWINEVENTHOOK
)pSetWinEventHook(
7910 EVENT_OBJECT_SHOW
, /* 0x8002 */
7911 EVENT_OBJECT_LOCATIONCHANGE
, /* 0x800B */
7912 GetModuleHandleA(0), win_event_global_hook_proc
,
7913 GetCurrentProcessId(), 0,
7914 WINEVENT_INCONTEXT
);
7915 ok(hhook
!= 0, "SetWinEventHook error %d\n", GetLastError());
7917 hevent
= CreateEventA(NULL
, 0, 0, NULL
);
7919 hwnd2
= (HWND
)hevent
;
7921 hthread
= CreateThread(NULL
, 0, win_event_global_thread_proc
, &hwnd2
, 0, &tid
);
7922 ok(hthread
!= NULL
, "CreateThread failed, error %d\n", GetLastError());
7924 ok(WaitForSingleObject(hevent
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
7926 ok_sequence(WmWinEventAlertSeq
, "alert winevent", FALSE
);
7929 /* this one should be received only by old hook proc */
7930 pNotifyWinEvent(EVENT_OBJECT_CREATE
, hwnd
, OBJID_CARET
, 0); /* 0x8000 */
7931 pNotifyWinEvent(EVENT_OBJECT_SHOW
, hwnd
, OBJID_CARET
, 0); /* 0x8002 */
7932 /* this one should be received only by old hook proc */
7933 pNotifyWinEvent(EVENT_OBJECT_NAMECHANGE
, hwnd
, OBJID_CARET
, 0); /* 0x800C */
7935 ok_sequence(WmWinEventCaretSeq
, "caret winevent", FALSE
);
7937 ret
= pUnhookWinEvent(hhook
);
7938 ok( ret
, "UnhookWinEvent error %d\n", GetLastError());
7940 PostThreadMessageA(tid
, WM_QUIT
, 0, 0);
7941 ok(WaitForSingleObject(hthread
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
7942 CloseHandle(hthread
);
7943 CloseHandle(hevent
);
7944 ok(!IsWindow(hwnd2
), "window should be destroyed on thread exit\n");
7945 /****** end of event filtering test *************/
7947 /****** start of out of context event test *************/
7948 hhook
= (HWINEVENTHOOK
)pSetWinEventHook(
7949 EVENT_MIN
, EVENT_MAX
,
7950 0, win_event_global_hook_proc
,
7951 GetCurrentProcessId(), 0,
7952 WINEVENT_OUTOFCONTEXT
);
7953 ok(hhook
!= 0, "SetWinEventHook error %d\n", GetLastError());
7955 hevent
= CreateEventA(NULL
, 0, 0, NULL
);
7957 hwnd2
= (HWND
)hevent
;
7961 hthread
= CreateThread(NULL
, 0, win_event_global_thread_proc
, &hwnd2
, 0, &tid
);
7962 ok(hthread
!= NULL
, "CreateThread failed, error %d\n", GetLastError());
7964 ok(WaitForSingleObject(hevent
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
7966 ok_sequence(WmEmptySeq
, "empty notify winevents", FALSE
);
7967 /* process pending winevent messages */
7968 ok(!PeekMessageA(&msg
, 0, 0, 0, PM_NOREMOVE
), "msg queue should be empty\n");
7969 ok_sequence(WmWinEventAlertSeq_2
, "alert winevent for out of context proc", FALSE
);
7972 /* this one should be received only by old hook proc */
7973 pNotifyWinEvent(EVENT_OBJECT_CREATE
, hwnd
, OBJID_CARET
, 0); /* 0x8000 */
7974 pNotifyWinEvent(EVENT_OBJECT_SHOW
, hwnd
, OBJID_CARET
, 0); /* 0x8002 */
7975 /* this one should be received only by old hook proc */
7976 pNotifyWinEvent(EVENT_OBJECT_NAMECHANGE
, hwnd
, OBJID_CARET
, 0); /* 0x800C */
7978 ok_sequence(WmWinEventCaretSeq_2
, "caret winevent for incontext proc", FALSE
);
7979 /* process pending winevent messages */
7980 ok(!PeekMessageA(&msg
, 0, 0, 0, PM_NOREMOVE
), "msg queue should be empty\n");
7981 ok_sequence(WmWinEventCaretSeq_2
, "caret winevent for out of context proc", FALSE
);
7983 ret
= pUnhookWinEvent(hhook
);
7984 ok( ret
, "UnhookWinEvent error %d\n", GetLastError());
7986 PostThreadMessageA(tid
, WM_QUIT
, 0, 0);
7987 ok(WaitForSingleObject(hthread
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
7988 CloseHandle(hthread
);
7989 CloseHandle(hevent
);
7990 ok(!IsWindow(hwnd2
), "window should be destroyed on thread exit\n");
7991 /****** end of out of context event test *************/
7993 /****** start of MOUSE_LL hook test *************/
7994 hCBT_global_hook
= SetWindowsHookExA(WH_MOUSE_LL
, cbt_global_hook_proc
, GetModuleHandleA(0), 0);
7995 /* WH_MOUSE_LL is not supported on Win9x platforms */
7996 if (!hCBT_global_hook
)
7998 trace("Skipping WH_MOUSE_LL test on this platform\n");
7999 goto skip_mouse_ll_hook_test
;
8002 hevent
= CreateEventA(NULL
, 0, 0, NULL
);
8004 hwnd2
= (HWND
)hevent
;
8006 hthread
= CreateThread(NULL
, 0, mouse_ll_global_thread_proc
, &hwnd2
, 0, &tid
);
8007 ok(hthread
!= NULL
, "CreateThread failed, error %d\n", GetLastError());
8009 while (WaitForSingleObject(hevent
, 100) == WAIT_TIMEOUT
)
8010 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
8012 ok_sequence(WmMouseLLHookSeq
, "MOUSE_LL hook other thread", FALSE
);
8015 mouse_event(MOUSEEVENTF_MOVE
, -1, 0, 0, 0);
8016 mouse_event(MOUSEEVENTF_LEFTUP
, 0, 0, 0, 0);
8017 mouse_event(MOUSEEVENTF_MOVE
, 1, 0, 0, 0);
8019 ok_sequence(WmMouseLLHookSeq
, "MOUSE_LL hook same thread", FALSE
);
8021 ret
= UnhookWindowsHookEx(hCBT_global_hook
);
8022 ok( ret
, "UnhookWindowsHookEx error %d\n", GetLastError());
8024 PostThreadMessageA(tid
, WM_QUIT
, 0, 0);
8025 ok(WaitForSingleObject(hthread
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
8026 CloseHandle(hthread
);
8027 CloseHandle(hevent
);
8028 ok(!IsWindow(hwnd2
), "window should be destroyed on thread exit\n");
8029 /****** end of MOUSE_LL hook test *************/
8030 skip_mouse_ll_hook_test
:
8032 ok(DestroyWindow(hwnd
), "failed to destroy window\n");
8035 static void test_set_hook(void)
8039 HWINEVENTHOOK hwinevent_hook
;
8041 hhook
= SetWindowsHookExA(WH_CBT
, cbt_hook_proc
, GetModuleHandleA(0), GetCurrentThreadId());
8042 ok(hhook
!= 0, "local hook does not require hModule set to 0\n");
8043 UnhookWindowsHookEx(hhook
);
8047 /* this test doesn't pass under Win9x: BUG! */
8048 SetLastError(0xdeadbeef);
8049 hhook
= SetWindowsHookExA(WH_CBT
, cbt_hook_proc
, 0, 0);
8050 ok(!hhook
, "global hook requires hModule != 0\n");
8051 ok(GetLastError() == ERROR_HOOK_NEEDS_HMOD
, "unexpected error %d\n", GetLastError());
8054 SetLastError(0xdeadbeef);
8055 hhook
= SetWindowsHookExA(WH_CBT
, 0, GetModuleHandleA(0), GetCurrentThreadId());
8056 ok(!hhook
, "SetWinEventHook with invalid proc should fail\n");
8057 ok(GetLastError() == ERROR_INVALID_FILTER_PROC
|| /* Win2k */
8058 GetLastError() == 0xdeadbeef, /* Win9x */
8059 "unexpected error %d\n", GetLastError());
8061 SetLastError(0xdeadbeef);
8062 ok(!UnhookWindowsHookEx((HHOOK
)0xdeadbeef), "UnhookWindowsHookEx succeeded\n");
8063 ok(GetLastError() == ERROR_INVALID_HOOK_HANDLE
|| /* Win2k */
8064 GetLastError() == 0xdeadbeef, /* Win9x */
8065 "unexpected error %d\n", GetLastError());
8067 if (!pSetWinEventHook
|| !pUnhookWinEvent
) return;
8069 /* even process local incontext hooks require hmodule */
8070 SetLastError(0xdeadbeef);
8071 hwinevent_hook
= (HWINEVENTHOOK
)pSetWinEventHook(EVENT_MIN
, EVENT_MAX
,
8072 0, win_event_proc
, GetCurrentProcessId(), 0, WINEVENT_INCONTEXT
);
8073 ok(!hwinevent_hook
, "WINEVENT_INCONTEXT requires hModule != 0\n");
8074 ok(GetLastError() == ERROR_HOOK_NEEDS_HMOD
|| /* Win2k */
8075 GetLastError() == 0xdeadbeef, /* Win9x */
8076 "unexpected error %d\n", GetLastError());
8078 /* even thread local incontext hooks require hmodule */
8079 SetLastError(0xdeadbeef);
8080 hwinevent_hook
= (HWINEVENTHOOK
)pSetWinEventHook(EVENT_MIN
, EVENT_MAX
,
8081 0, win_event_proc
, GetCurrentProcessId(), GetCurrentThreadId(), WINEVENT_INCONTEXT
);
8082 ok(!hwinevent_hook
, "WINEVENT_INCONTEXT requires hModule != 0\n");
8083 ok(GetLastError() == ERROR_HOOK_NEEDS_HMOD
|| /* Win2k */
8084 GetLastError() == 0xdeadbeef, /* Win9x */
8085 "unexpected error %d\n", GetLastError());
8089 /* these 3 tests don't pass under Win9x */
8090 SetLastError(0xdeadbeef);
8091 hwinevent_hook
= (HWINEVENTHOOK
)pSetWinEventHook(1, 0,
8092 0, win_event_proc
, GetCurrentProcessId(), 0, WINEVENT_OUTOFCONTEXT
);
8093 ok(!hwinevent_hook
, "SetWinEventHook with invalid event range should fail\n");
8094 ok(GetLastError() == ERROR_INVALID_HOOK_FILTER
, "unexpected error %d\n", GetLastError());
8096 SetLastError(0xdeadbeef);
8097 hwinevent_hook
= (HWINEVENTHOOK
)pSetWinEventHook(-1, 1,
8098 0, win_event_proc
, GetCurrentProcessId(), 0, WINEVENT_OUTOFCONTEXT
);
8099 ok(!hwinevent_hook
, "SetWinEventHook with invalid event range should fail\n");
8100 ok(GetLastError() == ERROR_INVALID_HOOK_FILTER
, "unexpected error %d\n", GetLastError());
8102 SetLastError(0xdeadbeef);
8103 hwinevent_hook
= (HWINEVENTHOOK
)pSetWinEventHook(EVENT_MIN
, EVENT_MAX
,
8104 0, win_event_proc
, 0, 0xdeadbeef, WINEVENT_OUTOFCONTEXT
);
8105 ok(!hwinevent_hook
, "SetWinEventHook with invalid tid should fail\n");
8106 ok(GetLastError() == ERROR_INVALID_THREAD_ID
, "unexpected error %d\n", GetLastError());
8109 SetLastError(0xdeadbeef);
8110 hwinevent_hook
= (HWINEVENTHOOK
)pSetWinEventHook(0, 0,
8111 0, win_event_proc
, GetCurrentProcessId(), 0, WINEVENT_OUTOFCONTEXT
);
8112 ok(hwinevent_hook
!= 0, "SetWinEventHook error %d\n", GetLastError());
8113 ok(GetLastError() == 0xdeadbeef, "unexpected error %d\n", GetLastError());
8114 ret
= pUnhookWinEvent(hwinevent_hook
);
8115 ok( ret
, "UnhookWinEvent error %d\n", GetLastError());
8118 /* This call succeeds under win2k SP4, but fails under Wine.
8119 Does win2k test/use passed process id? */
8120 SetLastError(0xdeadbeef);
8121 hwinevent_hook
= (HWINEVENTHOOK
)pSetWinEventHook(EVENT_MIN
, EVENT_MAX
,
8122 0, win_event_proc
, 0xdeadbeef, 0, WINEVENT_OUTOFCONTEXT
);
8123 ok(hwinevent_hook
!= 0, "SetWinEventHook error %d\n", GetLastError());
8124 ok(GetLastError() == 0xdeadbeef, "unexpected error %d\n", GetLastError());
8125 ret
= pUnhookWinEvent(hwinevent_hook
);
8126 ok( ret
, "UnhookWinEvent error %d\n", GetLastError());
8129 SetLastError(0xdeadbeef);
8130 ok(!pUnhookWinEvent((HWINEVENTHOOK
)0xdeadbeef), "UnhookWinEvent succeeded\n");
8131 ok(GetLastError() == ERROR_INVALID_HANDLE
|| /* Win2k */
8132 GetLastError() == 0xdeadbeef, /* Win9x */
8133 "unexpected error %d\n", GetLastError());
8136 static const struct message ScrollWindowPaint1
[] = {
8138 { WM_ERASEBKGND
, sent
|beginpaint
},
8142 static const struct message ScrollWindowPaint2
[] = {
8147 static void test_scrollwindowex(void)
8150 RECT rect
={0,0,130,130};
8152 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test Scroll",
8153 WS_VISIBLE
|WS_OVERLAPPEDWINDOW
,
8154 100, 100, 200, 200, 0, 0, 0, NULL
);
8155 ok (hwnd
!= 0, "Failed to create overlapped window\n");
8156 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child",
8157 WS_VISIBLE
|WS_CAPTION
|WS_CHILD
,
8158 10, 10, 150, 150, hwnd
, 0, 0, NULL
);
8159 ok (hchild
!= 0, "Failed to create child\n");
8164 /* scroll without the child window */
8165 trace("start scroll\n");
8166 ScrollWindowEx( hwnd
, 10, 10, &rect
, NULL
, NULL
, NULL
,
8167 SW_ERASE
|SW_INVALIDATE
);
8168 ok_sequence(WmEmptySeq
, "ScrollWindowEx", 0);
8169 trace("end scroll\n");
8172 ok_sequence(ScrollWindowPaint1
, "ScrollWindowEx", 0);
8176 /* Now without the SW_ERASE flag */
8177 trace("start scroll\n");
8178 ScrollWindowEx( hwnd
, 10, 10, &rect
, NULL
, NULL
, NULL
, SW_INVALIDATE
);
8179 ok_sequence(WmEmptySeq
, "ScrollWindowEx", 0);
8180 trace("end scroll\n");
8183 ok_sequence(ScrollWindowPaint2
, "ScrollWindowEx", 0);
8187 /* now scroll the child window as well */
8188 trace("start scroll\n");
8189 ScrollWindowEx( hwnd
, 10, 10, &rect
, NULL
, NULL
, NULL
,
8190 SW_SCROLLCHILDREN
|SW_ERASE
|SW_INVALIDATE
);
8191 todo_wine
{ /* wine sends WM_POSCHANGING, WM_POSCHANGED messages */
8192 /* windows sometimes a WM_MOVE */
8193 ok_sequence(WmEmptySeq
, "ScrollWindowEx", 0);
8195 trace("end scroll\n");
8198 ok_sequence(ScrollWindowPaint1
, "ScrollWindowEx", 0);
8202 /* now scroll with ScrollWindow() */
8203 trace("start scroll with ScrollWindow\n");
8204 ScrollWindow( hwnd
, 5, 5, NULL
, NULL
);
8205 trace("end scroll\n");
8208 ok_sequence(ScrollWindowPaint1
, "ScrollWindow", 0);
8210 ok(DestroyWindow(hchild
), "failed to destroy window\n");
8211 ok(DestroyWindow(hwnd
), "failed to destroy window\n");
8215 static const struct message destroy_window_with_children
[] = {
8216 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* popup */
8217 { HCBT_DESTROYWND
, hook
|lparam
, 0, WND_PARENT_ID
}, /* parent */
8218 { 0x0090, sent
|optional
},
8219 { HCBT_DESTROYWND
, hook
|lparam
, 0, WND_POPUP_ID
}, /* popup */
8220 { 0x0090, sent
|optional
},
8221 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* popup */
8222 { WM_DESTROY
, sent
|wparam
|lparam
, 0, WND_POPUP_ID
}, /* popup */
8223 { WM_CAPTURECHANGED
, sent
|wparam
|lparam
, 0, WND_POPUP_ID
}, /* popup */
8224 { WM_NCDESTROY
, sent
|wparam
|lparam
, 0, WND_POPUP_ID
}, /* popup */
8225 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* parent */
8226 { WM_DESTROY
, sent
|wparam
|lparam
, 0, WND_PARENT_ID
}, /* parent */
8227 { WM_DESTROY
, sent
|wparam
|lparam
, 0, WND_CHILD_ID
+ 2 }, /* child2 */
8228 { WM_DESTROY
, sent
|wparam
|lparam
, 0, WND_CHILD_ID
+ 1 }, /* child1 */
8229 { WM_DESTROY
, sent
|wparam
|lparam
, 0, WND_CHILD_ID
+ 3 }, /* child3 */
8230 { WM_NCDESTROY
, sent
|wparam
|lparam
, 0, WND_CHILD_ID
+ 2 }, /* child2 */
8231 { WM_NCDESTROY
, sent
|wparam
|lparam
, 0, WND_CHILD_ID
+ 3 }, /* child3 */
8232 { WM_NCDESTROY
, sent
|wparam
|lparam
, 0, WND_CHILD_ID
+ 1 }, /* child1 */
8233 { WM_NCDESTROY
, sent
|wparam
|lparam
, 0, WND_PARENT_ID
}, /* parent */
8237 static void test_DestroyWindow(void)
8240 HWND parent
, child1
, child2
, child3
, child4
, test
;
8241 UINT child_id
= WND_CHILD_ID
+ 1;
8243 parent
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
8244 100, 100, 200, 200, 0, 0, 0, NULL
);
8245 assert(parent
!= 0);
8246 child1
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_CHILD
,
8247 0, 0, 50, 50, parent
, (HMENU
)child_id
++, 0, NULL
);
8248 assert(child1
!= 0);
8249 child2
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_CHILD
,
8250 0, 0, 50, 50, GetDesktopWindow(), (HMENU
)child_id
++, 0, NULL
);
8251 assert(child2
!= 0);
8252 child3
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_CHILD
,
8253 0, 0, 50, 50, child1
, (HMENU
)child_id
++, 0, NULL
);
8254 assert(child3
!= 0);
8255 child4
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_POPUP
,
8256 0, 0, 50, 50, parent
, 0, 0, NULL
);
8257 assert(child4
!= 0);
8259 /* test owner/parent of child2 */
8260 test
= GetParent(child2
);
8261 ok(test
== GetDesktopWindow(), "wrong parent %p\n", test
);
8262 ok(!IsChild(parent
, child2
), "wrong parent/child %p/%p\n", parent
, child2
);
8264 test
= pGetAncestor(child2
, GA_PARENT
);
8265 ok(test
== GetDesktopWindow(), "wrong parent %p\n", test
);
8267 test
= GetWindow(child2
, GW_OWNER
);
8268 ok(!test
, "wrong owner %p\n", test
);
8270 test
= SetParent(child2
, parent
);
8271 ok(test
== GetDesktopWindow(), "wrong old parent %p\n", test
);
8273 /* test owner/parent of the parent */
8274 test
= GetParent(parent
);
8275 ok(!test
, "wrong parent %p\n", test
);
8276 ok(!IsChild(GetDesktopWindow(), parent
), "wrong parent/child %p/%p\n", GetDesktopWindow(), parent
);
8278 test
= pGetAncestor(parent
, GA_PARENT
);
8279 ok(test
== GetDesktopWindow(), "wrong parent %p\n", test
);
8281 test
= GetWindow(parent
, GW_OWNER
);
8282 ok(!test
, "wrong owner %p\n", test
);
8284 /* test owner/parent of child1 */
8285 test
= GetParent(child1
);
8286 ok(test
== parent
, "wrong parent %p\n", test
);
8287 ok(IsChild(parent
, child1
), "wrong parent/child %p/%p\n", parent
, child1
);
8289 test
= pGetAncestor(child1
, GA_PARENT
);
8290 ok(test
== parent
, "wrong parent %p\n", test
);
8292 test
= GetWindow(child1
, GW_OWNER
);
8293 ok(!test
, "wrong owner %p\n", test
);
8295 /* test owner/parent of child2 */
8296 test
= GetParent(child2
);
8297 ok(test
== parent
, "wrong parent %p\n", test
);
8298 ok(IsChild(parent
, child2
), "wrong parent/child %p/%p\n", parent
, child2
);
8300 test
= pGetAncestor(child2
, GA_PARENT
);
8301 ok(test
== parent
, "wrong parent %p\n", test
);
8303 test
= GetWindow(child2
, GW_OWNER
);
8304 ok(!test
, "wrong owner %p\n", test
);
8306 /* test owner/parent of child3 */
8307 test
= GetParent(child3
);
8308 ok(test
== child1
, "wrong parent %p\n", test
);
8309 ok(IsChild(parent
, child3
), "wrong parent/child %p/%p\n", parent
, child3
);
8311 test
= pGetAncestor(child3
, GA_PARENT
);
8312 ok(test
== child1
, "wrong parent %p\n", test
);
8314 test
= GetWindow(child3
, GW_OWNER
);
8315 ok(!test
, "wrong owner %p\n", test
);
8317 /* test owner/parent of child4 */
8318 test
= GetParent(child4
);
8319 ok(test
== parent
, "wrong parent %p\n", test
);
8320 ok(!IsChild(parent
, child4
), "wrong parent/child %p/%p\n", parent
, child4
);
8322 test
= pGetAncestor(child4
, GA_PARENT
);
8323 ok(test
== GetDesktopWindow(), "wrong parent %p\n", test
);
8325 test
= GetWindow(child4
, GW_OWNER
);
8326 ok(test
== parent
, "wrong owner %p\n", test
);
8330 trace("parent %p, child1 %p, child2 %p, child3 %p, child4 %p\n",
8331 parent
, child1
, child2
, child3
, child4
);
8334 test
= GetCapture();
8335 ok(test
== child4
, "wrong capture window %p\n", test
);
8337 test_DestroyWindow_flag
= TRUE
;
8338 ret
= DestroyWindow(parent
);
8339 ok( ret
, "DestroyWindow() error %d\n", GetLastError());
8340 test_DestroyWindow_flag
= FALSE
;
8341 ok_sequence(destroy_window_with_children
, "destroy window with children", 0);
8343 ok(!IsWindow(parent
), "parent still exists\n");
8344 ok(!IsWindow(child1
), "child1 still exists\n");
8345 ok(!IsWindow(child2
), "child2 still exists\n");
8346 ok(!IsWindow(child3
), "child3 still exists\n");
8347 ok(!IsWindow(child4
), "child4 still exists\n");
8349 test
= GetCapture();
8350 ok(!test
, "wrong capture window %p\n", test
);
8354 static const struct message WmDispatchPaint
[] = {
8355 { WM_NCPAINT
, sent
},
8356 { WM_GETTEXT
, sent
|defwinproc
|optional
},
8357 { WM_GETTEXT
, sent
|defwinproc
|optional
},
8358 { WM_ERASEBKGND
, sent
},
8362 static LRESULT WINAPI
DispatchMessageCheckProc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
8364 if (message
== WM_PAINT
) return 0;
8365 return MsgCheckProcA( hwnd
, message
, wParam
, lParam
);
8368 static void test_DispatchMessage(void)
8373 HWND hwnd
= CreateWindowA( "TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
8374 100, 100, 200, 200, 0, 0, 0, NULL
);
8375 ShowWindow( hwnd
, SW_SHOW
);
8376 UpdateWindow( hwnd
);
8379 SetWindowLongPtrA( hwnd
, GWLP_WNDPROC
, (LONG_PTR
)DispatchMessageCheckProc
);
8381 SetRect( &rect
, -5, -5, 5, 5 );
8382 RedrawWindow( hwnd
, &rect
, 0, RDW_INVALIDATE
|RDW_ERASE
|RDW_FRAME
);
8384 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
))
8386 if (msg
.message
!= WM_PAINT
) DispatchMessage( &msg
);
8390 DispatchMessage( &msg
);
8391 /* DispatchMessage will send WM_NCPAINT if non client area is still invalid after WM_PAINT */
8392 if (!count
) ok_sequence( WmDispatchPaint
, "WmDispatchPaint", FALSE
);
8393 else ok_sequence( WmEmptySeq
, "WmEmpty", FALSE
);
8394 if (++count
> 10) break;
8397 ok( msg
.message
== WM_PAINT
&& count
> 10, "WM_PAINT messages stopped\n" );
8399 trace("now without DispatchMessage\n");
8401 RedrawWindow( hwnd
, &rect
, 0, RDW_INVALIDATE
|RDW_ERASE
|RDW_FRAME
);
8403 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
))
8405 if (msg
.message
!= WM_PAINT
) DispatchMessage( &msg
);
8408 HRGN hrgn
= CreateRectRgn( 0, 0, 0, 0 );
8410 /* this will send WM_NCCPAINT just like DispatchMessage does */
8411 GetUpdateRgn( hwnd
, hrgn
, TRUE
);
8412 ok_sequence( WmDispatchPaint
, "WmDispatchPaint", FALSE
);
8413 DeleteObject( hrgn
);
8414 GetClientRect( hwnd
, &rect
);
8415 ValidateRect( hwnd
, &rect
); /* this will stop WM_PAINTs */
8416 ok( !count
, "Got multiple WM_PAINTs\n" );
8417 if (++count
> 10) break;
8420 DestroyWindow(hwnd
);
8424 static const struct message WmUser
[] = {
8436 static DWORD CALLBACK
send_msg_thread( LPVOID arg
)
8438 struct sendmsg_info
*info
= arg
;
8439 SetLastError( 0xdeadbeef );
8440 info
->ret
= SendMessageTimeoutA( info
->hwnd
, WM_USER
, 0, 0, 0, info
->timeout
, NULL
);
8441 if (!info
->ret
) ok( GetLastError() == ERROR_TIMEOUT
, "unexpected error %d\n", GetLastError());
8445 static void wait_for_thread( HANDLE thread
)
8447 while (MsgWaitForMultipleObjects(1, &thread
, FALSE
, INFINITE
, QS_SENDMESSAGE
) != WAIT_OBJECT_0
)
8450 while (PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage(&msg
);
8454 static LRESULT WINAPI
send_msg_delay_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
8456 if (message
== WM_USER
) Sleep(200);
8457 return MsgCheckProcA( hwnd
, message
, wParam
, lParam
);
8460 static void test_SendMessageTimeout(void)
8463 struct sendmsg_info info
;
8466 info
.hwnd
= CreateWindowA( "TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
8467 100, 100, 200, 200, 0, 0, 0, NULL
);
8471 info
.timeout
= 1000;
8472 info
.ret
= 0xdeadbeef;
8473 thread
= CreateThread( NULL
, 0, send_msg_thread
, &info
, 0, &tid
);
8474 wait_for_thread( thread
);
8475 CloseHandle( thread
);
8476 ok( info
.ret
== 1, "SendMessageTimeout failed\n" );
8477 ok_sequence( WmUser
, "WmUser", FALSE
);
8480 info
.ret
= 0xdeadbeef;
8481 thread
= CreateThread( NULL
, 0, send_msg_thread
, &info
, 0, &tid
);
8482 Sleep(100); /* SendMessageTimeout should time out here */
8483 wait_for_thread( thread
);
8484 CloseHandle( thread
);
8485 ok( info
.ret
== 0, "SendMessageTimeout succeeded\n" );
8486 ok_sequence( WmEmptySeq
, "WmEmptySeq", FALSE
);
8488 /* 0 means infinite timeout */
8490 info
.ret
= 0xdeadbeef;
8491 thread
= CreateThread( NULL
, 0, send_msg_thread
, &info
, 0, &tid
);
8493 wait_for_thread( thread
);
8494 CloseHandle( thread
);
8495 ok( info
.ret
== 1, "SendMessageTimeout failed\n" );
8496 ok_sequence( WmUser
, "WmUser", FALSE
);
8498 /* timeout is treated as signed despite the prototype */
8499 info
.timeout
= 0x7fffffff;
8500 info
.ret
= 0xdeadbeef;
8501 thread
= CreateThread( NULL
, 0, send_msg_thread
, &info
, 0, &tid
);
8503 wait_for_thread( thread
);
8504 CloseHandle( thread
);
8505 ok( info
.ret
== 1, "SendMessageTimeout failed\n" );
8506 ok_sequence( WmUser
, "WmUser", FALSE
);
8508 info
.timeout
= 0x80000000;
8509 info
.ret
= 0xdeadbeef;
8510 thread
= CreateThread( NULL
, 0, send_msg_thread
, &info
, 0, &tid
);
8512 wait_for_thread( thread
);
8513 CloseHandle( thread
);
8514 ok( info
.ret
== 0, "SendMessageTimeout succeeded\n" );
8515 ok_sequence( WmEmptySeq
, "WmEmptySeq", FALSE
);
8517 /* now check for timeout during message processing */
8518 SetWindowLongPtrA( info
.hwnd
, GWLP_WNDPROC
, (LONG_PTR
)send_msg_delay_proc
);
8520 info
.ret
= 0xdeadbeef;
8521 thread
= CreateThread( NULL
, 0, send_msg_thread
, &info
, 0, &tid
);
8522 wait_for_thread( thread
);
8523 CloseHandle( thread
);
8524 /* we should time out but still get the message */
8525 ok( info
.ret
== 0, "SendMessageTimeout failed\n" );
8526 ok_sequence( WmUser
, "WmUser", FALSE
);
8528 DestroyWindow( info
.hwnd
);
8532 /****************** edit message test *************************/
8533 #define ID_EDIT 0x1234
8534 static const struct message sl_edit_setfocus
[] =
8536 { HCBT_SETFOCUS
, hook
},
8537 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
8538 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
8539 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
8540 { WM_SETFOCUS
, sent
|wparam
, 0 },
8541 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 10 },
8542 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 15 },
8543 { WM_CTLCOLOREDIT
, sent
|parent
},
8544 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 11 },
8545 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
8546 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
8547 { WM_COMMAND
, sent
|parent
|wparam
, MAKEWPARAM(ID_EDIT
, EN_SETFOCUS
) },
8550 static const struct message ml_edit_setfocus
[] =
8552 { HCBT_SETFOCUS
, hook
},
8553 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
8554 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
8555 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
8556 { WM_SETFOCUS
, sent
|wparam
, 0 },
8557 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 10 },
8558 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 11 },
8559 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
8560 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
8561 { WM_COMMAND
, sent
|parent
|wparam
, MAKEWPARAM(ID_EDIT
, EN_SETFOCUS
) },
8564 static const struct message sl_edit_killfocus
[] =
8566 { HCBT_SETFOCUS
, hook
},
8567 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
8568 { WM_KILLFOCUS
, sent
|wparam
, 0 },
8569 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
8570 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
8571 { WM_COMMAND
, sent
|parent
|wparam
, MAKEWPARAM(ID_EDIT
, EN_KILLFOCUS
) },
8572 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
8573 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 1 },
8576 static const struct message sl_edit_lbutton_dblclk
[] =
8578 { WM_LBUTTONDBLCLK
, sent
},
8579 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
8582 static const struct message sl_edit_lbutton_down
[] =
8584 { WM_LBUTTONDOWN
, sent
|wparam
|lparam
, 0, 0 },
8585 { HCBT_SETFOCUS
, hook
},
8586 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
8587 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
8588 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
8589 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
8590 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 10 },
8591 { WM_CTLCOLOREDIT
, sent
|parent
},
8592 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 11 },
8593 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
8594 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
8595 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
8596 { WM_COMMAND
, sent
|parent
|wparam
, MAKEWPARAM(ID_EDIT
, EN_SETFOCUS
) },
8597 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
8598 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
8599 { WM_CTLCOLOREDIT
, sent
|parent
|optional
},
8600 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 11 },
8601 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
8602 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
8605 static const struct message ml_edit_lbutton_down
[] =
8607 { WM_LBUTTONDOWN
, sent
|wparam
|lparam
, 0, 0 },
8608 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
8609 { HCBT_SETFOCUS
, hook
},
8610 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
8611 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
8612 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
8613 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
8614 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 10 },
8615 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 11 },
8616 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
8617 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
8618 { WM_COMMAND
, sent
|parent
|wparam
, MAKEWPARAM(ID_EDIT
, EN_SETFOCUS
) },
8621 static const struct message sl_edit_lbutton_up
[] =
8623 { WM_LBUTTONUP
, sent
|wparam
|lparam
, 0, 0 },
8624 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
8625 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, 0, 0 },
8626 { WM_CAPTURECHANGED
, sent
|defwinproc
},
8627 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
8630 static const struct message ml_edit_lbutton_up
[] =
8632 { WM_LBUTTONUP
, sent
|wparam
|lparam
, 0, 0 },
8633 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, 0, 0 },
8634 { WM_CAPTURECHANGED
, sent
|defwinproc
},
8638 static WNDPROC old_edit_proc
;
8640 static LRESULT CALLBACK
edit_hook_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
8642 static long defwndproc_counter
= 0;
8646 trace("edit: %p, %04x, %08lx, %08lx\n", hwnd
, message
, wParam
, lParam
);
8648 /* explicitly ignore WM_GETICON message */
8649 if (message
== WM_GETICON
) return 0;
8651 /* ignore registered messages */
8652 if (message
>= 0xc000) return 0;
8654 msg
.message
= message
;
8655 msg
.flags
= sent
|wparam
|lparam
;
8656 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
8657 msg
.wParam
= wParam
;
8658 msg
.lParam
= lParam
;
8661 defwndproc_counter
++;
8662 ret
= CallWindowProcA(old_edit_proc
, hwnd
, message
, wParam
, lParam
);
8663 defwndproc_counter
--;
8668 static void subclass_edit(void)
8672 if (!GetClassInfoA(0, "edit", &cls
)) assert(0);
8674 old_edit_proc
= cls
.lpfnWndProc
;
8676 cls
.hInstance
= GetModuleHandle(0);
8677 cls
.lpfnWndProc
= edit_hook_proc
;
8678 cls
.lpszClassName
= "my_edit_class";
8679 UnregisterClass(cls
.lpszClassName
, cls
.hInstance
);
8680 if (!RegisterClassA(&cls
)) assert(0);
8683 static void test_edit_messages(void)
8689 log_all_parent_messages
++;
8691 parent
= CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
8692 100, 100, 200, 200, 0, 0, 0, NULL
);
8693 ok (parent
!= 0, "Failed to create parent window\n");
8695 /* test single line edit */
8696 hwnd
= CreateWindowExA(0, "my_edit_class", "test", WS_CHILD
,
8697 0, 0, 80, 20, parent
, (HMENU
)ID_EDIT
, 0, NULL
);
8698 ok(hwnd
!= 0, "Failed to create edit window\n");
8700 dlg_code
= SendMessageA(hwnd
, WM_GETDLGCODE
, 0, 0);
8701 ok(dlg_code
== (DLGC_WANTCHARS
|DLGC_HASSETSEL
|DLGC_WANTARROWS
), "wrong dlg_code %08x\n", dlg_code
);
8703 ShowWindow(hwnd
, SW_SHOW
);
8709 ok_sequence(sl_edit_setfocus
, "SetFocus(hwnd) on an edit", FALSE
);
8712 ok_sequence(sl_edit_killfocus
, "SetFocus(0) on an edit", FALSE
);
8718 SendMessageA(hwnd
, WM_LBUTTONDBLCLK
, 0, 0);
8719 ok_sequence(sl_edit_lbutton_dblclk
, "WM_LBUTTONDBLCLK on an edit", FALSE
);
8725 SendMessageA(hwnd
, WM_LBUTTONDOWN
, 0, 0);
8726 ok_sequence(sl_edit_lbutton_down
, "WM_LBUTTONDOWN on an edit", FALSE
);
8728 SendMessageA(hwnd
, WM_LBUTTONUP
, 0, 0);
8729 ok_sequence(sl_edit_lbutton_up
, "WM_LBUTTONUP on an edit", FALSE
);
8731 DestroyWindow(hwnd
);
8733 /* test multiline edit */
8734 hwnd
= CreateWindowExA(0, "my_edit_class", "test", WS_CHILD
| ES_MULTILINE
,
8735 0, 0, 80, 20, parent
, (HMENU
)ID_EDIT
, 0, NULL
);
8736 ok(hwnd
!= 0, "Failed to create edit window\n");
8738 dlg_code
= SendMessageA(hwnd
, WM_GETDLGCODE
, 0, 0);
8739 ok(dlg_code
== (DLGC_WANTCHARS
|DLGC_HASSETSEL
|DLGC_WANTARROWS
|DLGC_WANTALLKEYS
),
8740 "wrong dlg_code %08x\n", dlg_code
);
8742 ShowWindow(hwnd
, SW_SHOW
);
8748 ok_sequence(ml_edit_setfocus
, "SetFocus(hwnd) on multiline edit", FALSE
);
8751 ok_sequence(sl_edit_killfocus
, "SetFocus(0) on multiline edit", FALSE
);
8757 SendMessageA(hwnd
, WM_LBUTTONDBLCLK
, 0, 0);
8758 ok_sequence(sl_edit_lbutton_dblclk
, "WM_LBUTTONDBLCLK on multiline edit", FALSE
);
8764 SendMessageA(hwnd
, WM_LBUTTONDOWN
, 0, 0);
8765 ok_sequence(ml_edit_lbutton_down
, "WM_LBUTTONDOWN on multiline edit", FALSE
);
8767 SendMessageA(hwnd
, WM_LBUTTONUP
, 0, 0);
8768 ok_sequence(ml_edit_lbutton_up
, "WM_LBUTTONUP on multiline edit", FALSE
);
8770 DestroyWindow(hwnd
);
8771 DestroyWindow(parent
);
8773 log_all_parent_messages
--;
8776 /**************************** End of Edit test ******************************/
8778 static const struct message WmKeyDownSkippedSeq
[] =
8780 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 1 }, /* XP */
8783 static const struct message WmKeyUpSkippedSeq
[] =
8785 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xc0000001 }, /* XP */
8790 #define EV_SENDMSG 1
8796 HANDLE hevent
[3]; /* 0 - start/stop, 1 - SendMessage, 2 - ack */
8799 static DWORD CALLBACK
send_msg_thread_2(void *param
)
8802 struct peekmsg_info
*info
= param
;
8804 trace("thread: looping\n");
8805 SetEvent(info
->hevent
[EV_ACK
]);
8809 ret
= WaitForMultipleObjects(2, info
->hevent
, FALSE
, INFINITE
);
8813 case WAIT_OBJECT_0
+ EV_STOP
:
8814 trace("thread: exiting\n");
8817 case WAIT_OBJECT_0
+ EV_SENDMSG
:
8818 trace("thread: sending message\n");
8819 ok( SendNotifyMessageA(info
->hwnd
, WM_USER
, 0, 0),
8820 "SendNotifyMessageA failed error %u\n", GetLastError());
8821 SetEvent(info
->hevent
[EV_ACK
]);
8825 trace("unexpected return: %04x\n", ret
);
8833 static void test_PeekMessage(void)
8838 UINT qs_all_input
= QS_ALLINPUT
;
8839 UINT qs_input
= QS_INPUT
;
8841 struct peekmsg_info info
;
8843 info
.hwnd
= CreateWindowA("TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
8844 100, 100, 200, 200, 0, 0, 0, NULL
);
8846 ShowWindow(info
.hwnd
, SW_SHOW
);
8847 UpdateWindow(info
.hwnd
);
8848 SetFocus(info
.hwnd
);
8850 info
.hevent
[EV_STOP
] = CreateEventA(NULL
, 0, 0, NULL
);
8851 info
.hevent
[EV_SENDMSG
] = CreateEventA(NULL
, 0, 0, NULL
);
8852 info
.hevent
[EV_ACK
] = CreateEventA(NULL
, 0, 0, NULL
);
8854 hthread
= CreateThread(NULL
, 0, send_msg_thread_2
, &info
, 0, &tid
);
8855 WaitForSingleObject(info
.hevent
[EV_ACK
], 10000);
8860 SetLastError(0xdeadbeef);
8861 qstatus
= GetQueueStatus(qs_all_input
);
8862 if (GetLastError() == ERROR_INVALID_FLAGS
)
8864 trace("QS_RAWINPUT not supported on this platform\n");
8865 qs_all_input
&= ~QS_RAWINPUT
;
8866 qs_input
&= ~QS_RAWINPUT
;
8868 ok(qstatus
== 0, "wrong qstatus %08x\n", qstatus
);
8870 trace("signalling to send message\n");
8871 SetEvent(info
.hevent
[EV_SENDMSG
]);
8872 WaitForSingleObject(info
.hevent
[EV_ACK
], INFINITE
);
8874 /* pass invalid QS_xxxx flags */
8875 SetLastError(0xdeadbeef);
8876 qstatus
= GetQueueStatus(0xffffffff);
8877 ok(qstatus
== 0, "GetQueueStatus should fail: %08x\n", qstatus
);
8878 ok(GetLastError() == ERROR_INVALID_FLAGS
, "wrong error %d\n", GetLastError());
8880 qstatus
= GetQueueStatus(qs_all_input
);
8881 ok(qstatus
== MAKELONG(QS_SENDMESSAGE
, QS_SENDMESSAGE
),
8882 "wrong qstatus %08x\n", qstatus
);
8885 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
8887 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8889 ok_sequence(WmUser
, "WmUser", FALSE
);
8891 qstatus
= GetQueueStatus(qs_all_input
);
8892 ok(qstatus
== 0, "wrong qstatus %08x\n", qstatus
);
8894 keybd_event('N', 0, 0, 0);
8895 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
8896 qstatus
= GetQueueStatus(qs_all_input
);
8897 ok(qstatus
== MAKELONG(QS_KEY
, QS_KEY
),
8898 "wrong qstatus %08x\n", qstatus
);
8900 PostMessageA(info
.hwnd
, WM_CHAR
, 'z', 0);
8901 qstatus
= GetQueueStatus(qs_all_input
);
8902 ok(qstatus
== MAKELONG(QS_POSTMESSAGE
, QS_POSTMESSAGE
|QS_KEY
),
8903 "wrong qstatus %08x\n", qstatus
);
8905 InvalidateRect(info
.hwnd
, NULL
, FALSE
);
8906 qstatus
= GetQueueStatus(qs_all_input
);
8907 ok(qstatus
== MAKELONG(QS_PAINT
, QS_PAINT
|QS_POSTMESSAGE
|QS_KEY
),
8908 "wrong qstatus %08x\n", qstatus
);
8910 trace("signalling to send message\n");
8911 SetEvent(info
.hevent
[EV_SENDMSG
]);
8912 WaitForSingleObject(info
.hevent
[EV_ACK
], INFINITE
);
8914 qstatus
= GetQueueStatus(qs_all_input
);
8915 ok(qstatus
== MAKELONG(QS_SENDMESSAGE
, QS_SENDMESSAGE
|QS_PAINT
|QS_POSTMESSAGE
|QS_KEY
),
8916 "wrong qstatus %08x\n", qstatus
);
8919 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| (qs_input
<< 16));
8921 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8923 ok_sequence(WmUser
, "WmUser", FALSE
);
8925 qstatus
= GetQueueStatus(qs_all_input
);
8926 ok(qstatus
== MAKELONG(0, QS_PAINT
|QS_POSTMESSAGE
|QS_KEY
),
8927 "wrong qstatus %08x\n", qstatus
);
8929 trace("signalling to send message\n");
8930 SetEvent(info
.hevent
[EV_SENDMSG
]);
8931 WaitForSingleObject(info
.hevent
[EV_ACK
], INFINITE
);
8933 qstatus
= GetQueueStatus(qs_all_input
);
8934 ok(qstatus
== MAKELONG(QS_SENDMESSAGE
, QS_SENDMESSAGE
|QS_PAINT
|QS_POSTMESSAGE
|QS_KEY
),
8935 "wrong qstatus %08x\n", qstatus
);
8938 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| PM_QS_POSTMESSAGE
);
8940 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8942 ok_sequence(WmUser
, "WmUser", FALSE
);
8944 qstatus
= GetQueueStatus(qs_all_input
);
8945 ok(qstatus
== MAKELONG(0, QS_PAINT
|QS_POSTMESSAGE
|QS_KEY
),
8946 "wrong qstatus %08x\n", qstatus
);
8949 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| PM_QS_POSTMESSAGE
);
8950 ok(ret
&& msg
.message
== WM_CHAR
&& msg
.wParam
== 'z',
8951 "got %d and %04x wParam %08lx instead of TRUE and WM_CHAR wParam 'z'\n",
8952 ret
, msg
.message
, msg
.wParam
);
8953 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
8955 qstatus
= GetQueueStatus(qs_all_input
);
8956 ok(qstatus
== MAKELONG(0, QS_PAINT
|QS_KEY
),
8957 "wrong qstatus %08x\n", qstatus
);
8960 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| PM_QS_POSTMESSAGE
);
8962 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8964 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
8966 qstatus
= GetQueueStatus(qs_all_input
);
8967 ok(qstatus
== MAKELONG(0, QS_PAINT
|QS_KEY
),
8968 "wrong qstatus %08x\n", qstatus
);
8971 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| PM_QS_PAINT
);
8972 ok(ret
&& msg
.message
== WM_PAINT
,
8973 "got %d and %04x instead of TRUE and WM_PAINT\n", ret
, msg
.message
);
8974 DispatchMessageA(&msg
);
8975 ok_sequence(WmPaint
, "WmPaint", FALSE
);
8977 qstatus
= GetQueueStatus(qs_all_input
);
8978 ok(qstatus
== MAKELONG(0, QS_KEY
),
8979 "wrong qstatus %08x\n", qstatus
);
8982 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| PM_QS_PAINT
);
8984 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8986 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
8988 qstatus
= GetQueueStatus(qs_all_input
);
8989 ok(qstatus
== MAKELONG(0, QS_KEY
),
8990 "wrong qstatus %08x\n", qstatus
);
8992 trace("signalling to send message\n");
8993 SetEvent(info
.hevent
[EV_SENDMSG
]);
8994 WaitForSingleObject(info
.hevent
[EV_ACK
], INFINITE
);
8996 qstatus
= GetQueueStatus(qs_all_input
);
8997 ok(qstatus
== MAKELONG(QS_SENDMESSAGE
, QS_SENDMESSAGE
|QS_KEY
),
8998 "wrong qstatus %08x\n", qstatus
);
9000 PostMessageA(info
.hwnd
, WM_CHAR
, 'z', 0);
9002 qstatus
= GetQueueStatus(qs_all_input
);
9003 ok(qstatus
== MAKELONG(QS_POSTMESSAGE
, QS_SENDMESSAGE
|QS_POSTMESSAGE
|QS_KEY
),
9004 "wrong qstatus %08x\n", qstatus
);
9007 ret
= PeekMessageA(&msg
, 0, WM_CHAR
, WM_CHAR
, PM_REMOVE
);
9008 ok(ret
&& msg
.message
== WM_CHAR
&& msg
.wParam
== 'z',
9009 "got %d and %04x wParam %08lx instead of TRUE and WM_CHAR wParam 'z'\n",
9010 ret
, msg
.message
, msg
.wParam
);
9011 ok_sequence(WmUser
, "WmUser", FALSE
);
9013 qstatus
= GetQueueStatus(qs_all_input
);
9014 ok(qstatus
== MAKELONG(0, QS_KEY
),
9015 "wrong qstatus %08x\n", qstatus
);
9018 ret
= PeekMessageA(&msg
, 0, WM_CHAR
, WM_CHAR
, PM_REMOVE
);
9020 "PeekMessageA should have returned FALSE instead of msg %04x\n",
9022 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
9024 qstatus
= GetQueueStatus(qs_all_input
);
9025 ok(qstatus
== MAKELONG(0, QS_KEY
),
9026 "wrong qstatus %08x\n", qstatus
);
9028 PostMessageA(info
.hwnd
, WM_CHAR
, 'z', 0);
9030 qstatus
= GetQueueStatus(qs_all_input
);
9031 ok(qstatus
== MAKELONG(QS_POSTMESSAGE
, QS_POSTMESSAGE
|QS_KEY
),
9032 "wrong qstatus %08x\n", qstatus
);
9034 trace("signalling to send message\n");
9035 SetEvent(info
.hevent
[EV_SENDMSG
]);
9036 WaitForSingleObject(info
.hevent
[EV_ACK
], INFINITE
);
9038 qstatus
= GetQueueStatus(qs_all_input
);
9039 ok(qstatus
== MAKELONG(QS_SENDMESSAGE
, QS_SENDMESSAGE
|QS_POSTMESSAGE
|QS_KEY
),
9040 "wrong qstatus %08x\n", qstatus
);
9043 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| (QS_KEY
<< 16));
9045 "PeekMessageA should have returned FALSE instead of msg %04x\n",
9047 ok_sequence(WmUser
, "WmUser", FALSE
);
9049 qstatus
= GetQueueStatus(qs_all_input
);
9050 ok(qstatus
== MAKELONG(0, QS_POSTMESSAGE
|QS_KEY
),
9051 "wrong qstatus %08x\n", qstatus
);
9054 if (qs_all_input
& QS_RAWINPUT
) /* use QS_RAWINPUT only if supported */
9055 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| (QS_RAWINPUT
<< 16));
9056 else /* workaround for a missing QS_RAWINPUT support */
9057 ret
= PeekMessageA(&msg
, 0, WM_KEYDOWN
, WM_KEYDOWN
, PM_REMOVE
);
9058 ok(ret
&& msg
.message
== WM_KEYDOWN
&& msg
.wParam
== 'N',
9059 "got %d and %04x wParam %08lx instead of TRUE and WM_KEYDOWN wParam 'N'\n",
9060 ret
, msg
.message
, msg
.wParam
);
9061 ok_sequence(WmKeyDownSkippedSeq
, "WmKeyDownSkippedSeq", FALSE
);
9063 qstatus
= GetQueueStatus(qs_all_input
);
9064 ok(qstatus
== MAKELONG(0, QS_POSTMESSAGE
|QS_KEY
),
9065 "wrong qstatus %08x\n", qstatus
);
9068 if (qs_all_input
& QS_RAWINPUT
) /* use QS_RAWINPUT only if supported */
9069 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| (QS_RAWINPUT
<< 16));
9070 else /* workaround for a missing QS_RAWINPUT support */
9071 ret
= PeekMessageA(&msg
, 0, WM_KEYUP
, WM_KEYUP
, PM_REMOVE
);
9072 ok(ret
&& msg
.message
== WM_KEYUP
&& msg
.wParam
== 'N',
9073 "got %d and %04x wParam %08lx instead of TRUE and WM_KEYUP wParam 'N'\n",
9074 ret
, msg
.message
, msg
.wParam
);
9075 ok_sequence(WmKeyUpSkippedSeq
, "WmKeyUpSkippedSeq", FALSE
);
9077 qstatus
= GetQueueStatus(qs_all_input
);
9078 ok(qstatus
== MAKELONG(0, QS_POSTMESSAGE
),
9079 "wrong qstatus %08x\n", qstatus
);
9082 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| PM_QS_SENDMESSAGE
);
9084 "PeekMessageA should have returned FALSE instead of msg %04x\n",
9086 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
9088 qstatus
= GetQueueStatus(qs_all_input
);
9089 ok(qstatus
== MAKELONG(0, QS_POSTMESSAGE
),
9090 "wrong qstatus %08x\n", qstatus
);
9093 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
9094 ok(ret
&& msg
.message
== WM_CHAR
&& msg
.wParam
== 'z',
9095 "got %d and %04x wParam %08lx instead of TRUE and WM_CHAR wParam 'z'\n",
9096 ret
, msg
.message
, msg
.wParam
);
9097 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
9099 qstatus
= GetQueueStatus(qs_all_input
);
9101 "wrong qstatus %08x\n", qstatus
);
9104 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
9106 "PeekMessageA should have returned FALSE instead of msg %04x\n",
9108 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
9110 qstatus
= GetQueueStatus(qs_all_input
);
9112 "wrong qstatus %08x\n", qstatus
);
9114 /* test whether presence of the quit flag in the queue affects
9117 PostQuitMessage(0x1234abcd);
9119 qstatus
= GetQueueStatus(qs_all_input
);
9120 ok(qstatus
== MAKELONG(QS_POSTMESSAGE
, QS_POSTMESSAGE
),
9121 "wrong qstatus %08x\n", qstatus
);
9123 PostMessageA(info
.hwnd
, WM_USER
, 0, 0);
9125 qstatus
= GetQueueStatus(qs_all_input
);
9126 ok(qstatus
== MAKELONG(QS_POSTMESSAGE
, QS_POSTMESSAGE
),
9127 "wrong qstatus %08x\n", qstatus
);
9130 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
9131 ok(ret
&& msg
.message
== WM_USER
,
9132 "got %d and %04x instead of TRUE and WM_USER\n", ret
, msg
.message
);
9133 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
9135 qstatus
= GetQueueStatus(qs_all_input
);
9136 ok(qstatus
== MAKELONG(0, QS_POSTMESSAGE
),
9137 "wrong qstatus %08x\n", qstatus
);
9140 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
9141 ok(ret
&& msg
.message
== WM_QUIT
,
9142 "got %d and %04x instead of TRUE and WM_QUIT\n", ret
, msg
.message
);
9143 ok(msg
.wParam
== 0x1234abcd, "got wParam %08lx instead of 0x1234abcd\n", msg
.wParam
);
9144 ok(msg
.lParam
== 0, "got lParam %08lx instead of 0\n", msg
.lParam
);
9145 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
9147 qstatus
= GetQueueStatus(qs_all_input
);
9149 ok(qstatus
== MAKELONG(0, QS_POSTMESSAGE
),
9150 "wrong qstatus %08x\n", qstatus
);
9154 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
9156 "PeekMessageA should have returned FALSE instead of msg %04x\n",
9158 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
9160 qstatus
= GetQueueStatus(qs_all_input
);
9162 "wrong qstatus %08x\n", qstatus
);
9164 trace("signalling to exit\n");
9165 SetEvent(info
.hevent
[EV_STOP
]);
9167 WaitForSingleObject(hthread
, INFINITE
);
9169 CloseHandle(hthread
);
9170 CloseHandle(info
.hevent
[0]);
9171 CloseHandle(info
.hevent
[1]);
9172 CloseHandle(info
.hevent
[2]);
9174 DestroyWindow(info
.hwnd
);
9177 static void wait_move_event(HWND hwnd
, int x
, int y
)
9184 time
= GetTickCount();
9185 while (GetTickCount() - time
< 200 && !go
) {
9186 ret
= PeekMessageA(&msg
, hwnd
, WM_MOUSEMOVE
, WM_MOUSEMOVE
, PM_NOREMOVE
);
9187 go
= ret
&& msg
.pt
.x
> x
&& msg
.pt
.y
> y
;
9192 static void test_PeekMessage2(void)
9198 DWORD time1
, time2
, time3
;
9199 int x1
, y1
, x2
, y2
, x3
, y3
;
9202 time1
= time2
= time3
= 0;
9203 x1
= y1
= x2
= y2
= x3
= y3
= 0;
9205 /* Initialise window and make sure it is ready for events */
9206 hwnd
= CreateWindow("TestWindowClass", "PeekMessage2", WS_OVERLAPPEDWINDOW
,
9207 10, 10, 800, 800, NULL
, NULL
, NULL
, NULL
);
9209 trace("Window for test_PeekMessage2 %p\n", hwnd
);
9210 ShowWindow(hwnd
, SW_SHOW
);
9214 SetCursorPos(100, 100);
9215 mouse_event(MOUSEEVENTF_MOVE
, -STEP
, -STEP
, 0, 0);
9218 /* Do initial mousemove, wait until we can see it
9219 and then do our test peek with PM_NOREMOVE. */
9220 mouse_event(MOUSEEVENTF_MOVE
, STEP
, STEP
, 0, 0);
9221 wait_move_event(hwnd
, 80, 80);
9223 ret
= PeekMessageA(&msg
, hwnd
, WM_MOUSEMOVE
, WM_MOUSEMOVE
, PM_NOREMOVE
);
9224 ok(ret
, "no message available\n");
9226 trace("1st move event: %04x %x %d %d\n", msg
.message
, msg
.time
, msg
.pt
.x
, msg
.pt
.y
);
9227 message
= msg
.message
;
9231 ok(message
== WM_MOUSEMOVE
, "message not WM_MOUSEMOVE, %04x instead\n", message
);
9234 /* Allow time to advance a bit, and then simulate the user moving their
9235 * mouse around. After that we peek again with PM_NOREMOVE.
9236 * Although the previous mousemove message was never removed, the
9237 * mousemove we now peek should reflect the recent mouse movements
9238 * because the input queue will merge the move events. */
9240 mouse_event(MOUSEEVENTF_MOVE
, STEP
, STEP
, 0, 0);
9241 wait_move_event(hwnd
, x1
, y1
);
9243 ret
= PeekMessageA(&msg
, hwnd
, WM_MOUSEMOVE
, WM_MOUSEMOVE
, PM_NOREMOVE
);
9244 ok(ret
, "no message available\n");
9246 trace("2nd move event: %04x %x %d %d\n", msg
.message
, msg
.time
, msg
.pt
.x
, msg
.pt
.y
);
9247 message
= msg
.message
;
9251 ok(message
== WM_MOUSEMOVE
, "message not WM_MOUSEMOVE, %04x instead\n", message
);
9252 ok(time2
> time1
, "message time not advanced: %x %x\n", time1
, time2
);
9253 ok(x2
!= x1
&& y2
!= y1
, "coords not changed: (%d %d) (%d %d)\n", x1
, y1
, x2
, y2
);
9256 /* Have another go, to drive the point home */
9258 mouse_event(MOUSEEVENTF_MOVE
, STEP
, STEP
, 0, 0);
9259 wait_move_event(hwnd
, x2
, y2
);
9261 ret
= PeekMessageA(&msg
, hwnd
, WM_MOUSEMOVE
, WM_MOUSEMOVE
, PM_NOREMOVE
);
9262 ok(ret
, "no message available\n");
9264 trace("3rd move event: %04x %x %d %d\n", msg
.message
, msg
.time
, msg
.pt
.x
, msg
.pt
.y
);
9265 message
= msg
.message
;
9269 ok(message
== WM_MOUSEMOVE
, "message not WM_MOUSEMOVE, %04x instead\n", message
);
9270 ok(time3
> time2
, "message time not advanced: %x %x\n", time2
, time3
);
9271 ok(x3
!= x2
&& y3
!= y2
, "coords not changed: (%d %d) (%d %d)\n", x2
, y2
, x3
, y3
);
9274 DestroyWindow(hwnd
);
9275 SetCursorPos(pos
.x
, pos
.y
);
9279 static void test_quit_message(void)
9284 /* test using PostQuitMessage */
9286 PostQuitMessage(0xbeef);
9288 ret
= PeekMessage(&msg
, NULL
, 0, 0, PM_NOREMOVE
);
9289 ok(ret
, "PeekMessage failed with error %d\n", GetLastError());
9290 ok(msg
.message
== WM_QUIT
, "Received message 0x%04x instead of WM_QUIT\n", msg
.message
);
9291 ok(msg
.wParam
== 0xbeef, "wParam was 0x%lx instead of 0xbeef\n", msg
.wParam
);
9293 ret
= PostThreadMessage(GetCurrentThreadId(), WM_USER
, 0, 0);
9294 ok(ret
, "PostMessage failed with error %d\n", GetLastError());
9296 ret
= GetMessage(&msg
, NULL
, 0, 0);
9297 ok(ret
> 0, "GetMessage failed with error %d\n", GetLastError());
9298 ok(msg
.message
== WM_USER
, "Received message 0x%04x instead of WM_USER\n", msg
.message
);
9300 /* note: WM_QUIT message received after WM_USER message */
9301 ret
= GetMessage(&msg
, NULL
, 0, 0);
9302 ok(!ret
, "GetMessage return %d with error %d instead of FALSE\n", ret
, GetLastError());
9303 ok(msg
.message
== WM_QUIT
, "Received message 0x%04x instead of WM_QUIT\n", msg
.message
);
9304 ok(msg
.wParam
== 0xbeef, "wParam was 0x%lx instead of 0xbeef\n", msg
.wParam
);
9306 ret
= PeekMessage(&msg
, NULL
, 0, 0, PM_REMOVE
);
9307 ok( !ret
|| msg
.message
!= WM_QUIT
, "Received WM_QUIT again\n" );
9309 /* now test with PostThreadMessage - different behaviour! */
9310 PostThreadMessage(GetCurrentThreadId(), WM_QUIT
, 0xdead, 0);
9312 ret
= PeekMessage(&msg
, NULL
, 0, 0, PM_NOREMOVE
);
9313 ok(ret
, "PeekMessage failed with error %d\n", GetLastError());
9314 ok(msg
.message
== WM_QUIT
, "Received message 0x%04x instead of WM_QUIT\n", msg
.message
);
9315 ok(msg
.wParam
== 0xdead, "wParam was 0x%lx instead of 0xdead\n", msg
.wParam
);
9317 ret
= PostThreadMessage(GetCurrentThreadId(), WM_USER
, 0, 0);
9318 ok(ret
, "PostMessage failed with error %d\n", GetLastError());
9320 /* note: we receive the WM_QUIT message first this time */
9321 ret
= GetMessage(&msg
, NULL
, 0, 0);
9322 ok(!ret
, "GetMessage return %d with error %d instead of FALSE\n", ret
, GetLastError());
9323 ok(msg
.message
== WM_QUIT
, "Received message 0x%04x instead of WM_QUIT\n", msg
.message
);
9324 ok(msg
.wParam
== 0xdead, "wParam was 0x%lx instead of 0xdead\n", msg
.wParam
);
9326 ret
= GetMessage(&msg
, NULL
, 0, 0);
9327 ok(ret
> 0, "GetMessage failed with error %d\n", GetLastError());
9328 ok(msg
.message
== WM_USER
, "Received message 0x%04x instead of WM_USER\n", msg
.message
);
9331 static const struct message WmMouseHoverSeq
[] = {
9332 { WM_MOUSEACTIVATE
, sent
|optional
}, /* we can get those when moving the mouse in focus-follow-mouse mode under X11 */
9333 { WM_MOUSEACTIVATE
, sent
|optional
},
9334 { WM_TIMER
, sent
|optional
}, /* XP sends it */
9335 { WM_SYSTIMER
, sent
},
9336 { WM_MOUSEHOVER
, sent
|wparam
, 0 },
9340 static void pump_msg_loop_timeout(DWORD timeout
, BOOL inject_mouse_move
)
9343 DWORD start_ticks
, end_ticks
;
9345 start_ticks
= GetTickCount();
9346 /* add some deviation (50%) to cover not expected delays */
9347 start_ticks
+= timeout
/ 2;
9351 while (PeekMessage(&msg
, 0, 0, 0, PM_REMOVE
))
9353 /* Timer proc messages are not dispatched to the window proc,
9354 * and therefore not logged.
9356 if (msg
.message
== WM_TIMER
|| msg
.message
== WM_SYSTIMER
)
9358 struct message s_msg
;
9360 s_msg
.message
= msg
.message
;
9361 s_msg
.flags
= sent
|wparam
|lparam
;
9362 s_msg
.wParam
= msg
.wParam
;
9363 s_msg
.lParam
= msg
.lParam
;
9364 add_message(&s_msg
);
9366 DispatchMessage(&msg
);
9369 end_ticks
= GetTickCount();
9371 /* inject WM_MOUSEMOVE to see how it changes tracking */
9372 if (inject_mouse_move
&& start_ticks
+ timeout
/ 2 >= end_ticks
)
9374 mouse_event(MOUSEEVENTF_MOVE
, -1, 0, 0, 0);
9375 mouse_event(MOUSEEVENTF_MOVE
, 1, 0, 0, 0);
9377 inject_mouse_move
= FALSE
;
9379 } while (start_ticks
+ timeout
>= end_ticks
);
9382 static void test_TrackMouseEvent(void)
9384 TRACKMOUSEEVENT tme
;
9387 RECT rc_parent
, rc_child
;
9388 UINT default_hover_time
, hover_width
= 0, hover_height
= 0;
9390 #define track_hover(track_hwnd, track_hover_time) \
9391 tme.cbSize = sizeof(tme); \
9392 tme.dwFlags = TME_HOVER; \
9393 tme.hwndTrack = track_hwnd; \
9394 tme.dwHoverTime = track_hover_time; \
9395 SetLastError(0xdeadbeef); \
9396 ret = pTrackMouseEvent(&tme); \
9397 ok(ret, "TrackMouseEvent(TME_HOVER) error %d\n", GetLastError())
9399 #define track_query(expected_track_flags, expected_track_hwnd, expected_hover_time) \
9400 tme.cbSize = sizeof(tme); \
9401 tme.dwFlags = TME_QUERY; \
9402 tme.hwndTrack = (HWND)0xdeadbeef; \
9403 tme.dwHoverTime = 0xdeadbeef; \
9404 SetLastError(0xdeadbeef); \
9405 ret = pTrackMouseEvent(&tme); \
9406 ok(ret, "TrackMouseEvent(TME_QUERY) error %d\n", GetLastError());\
9407 ok(tme.cbSize == sizeof(tme), "wrong tme.cbSize %u\n", tme.cbSize); \
9408 ok(tme.dwFlags == (expected_track_flags), \
9409 "wrong tme.dwFlags %08x, expected %08x\n", tme.dwFlags, (expected_track_flags)); \
9410 ok(tme.hwndTrack == (expected_track_hwnd), \
9411 "wrong tme.hwndTrack %p, expected %p\n", tme.hwndTrack, (expected_track_hwnd)); \
9412 ok(tme.dwHoverTime == (expected_hover_time), \
9413 "wrong tme.dwHoverTime %u, expected %u\n", tme.dwHoverTime, (expected_hover_time))
9415 #define track_hover_cancel(track_hwnd) \
9416 tme.cbSize = sizeof(tme); \
9417 tme.dwFlags = TME_HOVER | TME_CANCEL; \
9418 tme.hwndTrack = track_hwnd; \
9419 tme.dwHoverTime = 0xdeadbeef; \
9420 SetLastError(0xdeadbeef); \
9421 ret = pTrackMouseEvent(&tme); \
9422 ok(ret, "TrackMouseEvent(TME_HOVER | TME_CANCEL) error %d\n", GetLastError())
9424 default_hover_time
= 0xdeadbeef;
9425 SetLastError(0xdeadbeef);
9426 ret
= SystemParametersInfo(SPI_GETMOUSEHOVERTIME
, 0, &default_hover_time
, 0);
9427 ok(ret
, "SystemParametersInfo(SPI_GETMOUSEHOVERTIME) error %u\n", GetLastError());
9428 if (!ret
) default_hover_time
= 400;
9429 trace("SPI_GETMOUSEHOVERTIME returned %u ms\n", default_hover_time
);
9431 SetLastError(0xdeadbeef);
9432 ret
= SystemParametersInfo(SPI_GETMOUSEHOVERWIDTH
, 0, &hover_width
, 0);
9433 ok(ret
, "SystemParametersInfo(SPI_GETMOUSEHOVERWIDTH) error %u\n", GetLastError());
9434 if (!ret
) hover_width
= 4;
9435 SetLastError(0xdeadbeef);
9436 ret
= SystemParametersInfo(SPI_GETMOUSEHOVERHEIGHT
, 0, &hover_height
, 0);
9437 ok(ret
, "SystemParametersInfo(SPI_GETMOUSEHOVERHEIGHT) error %u\n", GetLastError());
9438 if (!ret
) hover_height
= 4;
9439 trace("hover rect is %u x %d\n", hover_width
, hover_height
);
9441 hwnd
= CreateWindowEx(0, "TestWindowClass", NULL
,
9442 WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
9443 CW_USEDEFAULT
, CW_USEDEFAULT
, 300, 300, 0,
9447 hchild
= CreateWindowEx(0, "TestWindowClass", NULL
,
9448 WS_CHILD
| WS_BORDER
| WS_VISIBLE
,
9449 50, 50, 200, 200, hwnd
,
9453 SetWindowPos( hwnd
, HWND_TOPMOST
, 0, 0, 0, 0, SWP_NOSIZE
|SWP_NOMOVE
);
9458 tme
.dwFlags
= TME_QUERY
;
9459 tme
.hwndTrack
= (HWND
)0xdeadbeef;
9460 tme
.dwHoverTime
= 0xdeadbeef;
9461 SetLastError(0xdeadbeef);
9462 ret
= pTrackMouseEvent(&tme
);
9463 ok(!ret
, "TrackMouseEvent should fail\n");
9464 ok(GetLastError() == ERROR_INVALID_PARAMETER
|| broken(GetLastError() == 0xdeadbeef),
9465 "not expected error %u\n", GetLastError());
9467 tme
.cbSize
= sizeof(tme
);
9468 tme
.dwFlags
= TME_HOVER
;
9469 tme
.hwndTrack
= (HWND
)0xdeadbeef;
9470 tme
.dwHoverTime
= 0xdeadbeef;
9471 SetLastError(0xdeadbeef);
9472 ret
= pTrackMouseEvent(&tme
);
9473 ok(!ret
, "TrackMouseEvent should fail\n");
9474 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
|| broken(GetLastError() == 0xdeadbeef),
9475 "not expected error %u\n", GetLastError());
9477 tme
.cbSize
= sizeof(tme
);
9478 tme
.dwFlags
= TME_HOVER
| TME_CANCEL
;
9479 tme
.hwndTrack
= (HWND
)0xdeadbeef;
9480 tme
.dwHoverTime
= 0xdeadbeef;
9481 SetLastError(0xdeadbeef);
9482 ret
= pTrackMouseEvent(&tme
);
9483 ok(!ret
, "TrackMouseEvent should fail\n");
9484 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
|| broken(GetLastError() == 0xdeadbeef),
9485 "not expected error %u\n", GetLastError());
9487 GetWindowRect(hwnd
, &rc_parent
);
9488 GetWindowRect(hchild
, &rc_child
);
9489 SetCursorPos(rc_child
.left
- 10, rc_child
.top
- 10);
9491 /* Process messages so that the system updates its internal current
9492 * window and hittest, otherwise TrackMouseEvent calls don't have any
9498 track_query(0, NULL
, 0);
9499 track_hover(hchild
, 0);
9500 track_query(0, NULL
, 0);
9505 track_hover(hwnd
, 0);
9506 track_query(TME_HOVER
, hwnd
, default_hover_time
);
9508 pump_msg_loop_timeout(default_hover_time
, FALSE
);
9509 ok_sequence(WmMouseHoverSeq
, "WmMouseHoverSeq", FALSE
);
9511 track_query(0, NULL
, 0);
9513 track_hover(hwnd
, HOVER_DEFAULT
);
9514 track_query(TME_HOVER
, hwnd
, default_hover_time
);
9516 Sleep(default_hover_time
/ 2);
9517 mouse_event(MOUSEEVENTF_MOVE
, -1, 0, 0, 0);
9518 mouse_event(MOUSEEVENTF_MOVE
, 1, 0, 0, 0);
9520 track_query(TME_HOVER
, hwnd
, default_hover_time
);
9522 pump_msg_loop_timeout(default_hover_time
/ 2, FALSE
);
9523 ok_sequence(WmMouseHoverSeq
, "WmMouseHoverSeq", FALSE
);
9525 track_query(0, NULL
, 0);
9527 track_hover(hwnd
, HOVER_DEFAULT
);
9528 track_query(TME_HOVER
, hwnd
, default_hover_time
);
9530 pump_msg_loop_timeout(default_hover_time
, TRUE
);
9531 ok_sequence(WmMouseHoverSeq
, "WmMouseHoverSeq", FALSE
);
9533 track_query(0, NULL
, 0);
9535 track_hover(hwnd
, HOVER_DEFAULT
);
9536 track_query(TME_HOVER
, hwnd
, default_hover_time
);
9537 track_hover_cancel(hwnd
);
9539 DestroyWindow(hwnd
);
9543 #undef track_hover_cancel
9547 static const struct message WmSetWindowRgn
[] = {
9548 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
},
9549 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
9550 { WM_NCPAINT
, sent
|optional
}, /* wparam != 1 */
9551 { WM_GETTEXT
, sent
|defwinproc
|optional
},
9552 { WM_ERASEBKGND
, sent
|optional
},
9553 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
},
9554 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
9558 static const struct message WmSetWindowRgn_no_redraw
[] = {
9559 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
},
9560 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
9561 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
},
9562 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
9566 static const struct message WmSetWindowRgn_clear
[] = {
9567 { WM_WINDOWPOSCHANGING
, sent
/*|wparam*/, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
/*|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE only on some Windows versions */ },
9568 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
9569 { WM_NCPAINT
, sent
|optional
},
9570 { WM_GETTEXT
, sent
|defwinproc
|optional
},
9571 { WM_ERASEBKGND
, sent
|optional
}, /* FIXME: remove optional once Wine is fixed */
9572 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
},
9573 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
9574 { WM_NCPAINT
, sent
|optional
},
9575 { WM_GETTEXT
, sent
|defwinproc
|optional
},
9576 { WM_ERASEBKGND
, sent
|optional
},
9577 { WM_WINDOWPOSCHANGING
, sent
|optional
},
9578 { WM_NCCALCSIZE
, sent
|optional
|wparam
, 1 },
9579 { WM_NCPAINT
, sent
|optional
},
9580 { WM_GETTEXT
, sent
|defwinproc
|optional
},
9581 { WM_ERASEBKGND
, sent
|optional
},
9582 { WM_WINDOWPOSCHANGED
, sent
|optional
|wparam
, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
},
9583 { WM_NCCALCSIZE
, sent
|optional
|wparam
, 1 },
9584 { WM_NCPAINT
, sent
|optional
},
9585 { WM_GETTEXT
, sent
|defwinproc
|optional
},
9586 { WM_ERASEBKGND
, sent
|optional
},
9587 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
9588 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
9592 static void test_SetWindowRgn(void)
9595 HWND hwnd
= CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW
,
9596 100, 100, 200, 200, 0, 0, 0, NULL
);
9597 ok( hwnd
!= 0, "Failed to create overlapped window\n" );
9599 ShowWindow( hwnd
, SW_SHOW
);
9600 UpdateWindow( hwnd
);
9604 trace("testing SetWindowRgn\n");
9605 hrgn
= CreateRectRgn( 0, 0, 150, 150 );
9606 SetWindowRgn( hwnd
, hrgn
, TRUE
);
9607 ok_sequence( WmSetWindowRgn
, "WmSetWindowRgn", FALSE
);
9609 hrgn
= CreateRectRgn( 30, 30, 160, 160 );
9610 SetWindowRgn( hwnd
, hrgn
, FALSE
);
9611 ok_sequence( WmSetWindowRgn_no_redraw
, "WmSetWindowRgn_no_redraw", FALSE
);
9613 hrgn
= CreateRectRgn( 0, 0, 180, 180 );
9614 SetWindowRgn( hwnd
, hrgn
, TRUE
);
9615 ok_sequence( WmSetWindowRgn
, "WmSetWindowRgn2", FALSE
);
9617 SetWindowRgn( hwnd
, 0, TRUE
);
9618 ok_sequence( WmSetWindowRgn_clear
, "WmSetWindowRgn_clear", FALSE
);
9620 DestroyWindow( hwnd
);
9623 /*************************** ShowWindow() test ******************************/
9624 static const struct message WmShowNormal
[] = {
9625 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
9626 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
9627 { HCBT_ACTIVATE
, hook
},
9628 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2003 doesn't send it */
9629 { HCBT_SETFOCUS
, hook
},
9630 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
9633 static const struct message WmShow
[] = {
9634 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
9635 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
9636 { HCBT_ACTIVATE
, hook
|optional
}, /* win2000 doesn't send it */
9637 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2000 doesn't send it */
9638 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 doesn't send it */
9639 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
9642 static const struct message WmShowNoActivate_1
[] = {
9643 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWNOACTIVATE
},
9644 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_STATECHANGED
},
9645 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_STATECHANGED
},
9646 { WM_MOVE
, sent
|defwinproc
},
9647 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_RESTORED
},
9650 static const struct message WmShowNoActivate_2
[] = {
9651 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWNOACTIVATE
},
9652 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
9653 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
9654 { WM_MOVE
, sent
|defwinproc
},
9655 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_RESTORED
},
9656 { HCBT_SETFOCUS
, hook
|optional
},
9657 { HCBT_ACTIVATE
, hook
|optional
}, /* win2003 doesn't send it */
9658 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2003 doesn't send it */
9659 { HCBT_SETFOCUS
, hook
|optional
}, /* win2003 doesn't send it */
9662 static const struct message WmShowNA_1
[] = {
9663 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
9664 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
9665 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
9668 static const struct message WmShowNA_2
[] = {
9669 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
9670 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
9673 static const struct message WmRestore_1
[] = {
9674 { HCBT_MINMAX
, hook
|lparam
, 0, SW_RESTORE
},
9675 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
9676 { HCBT_ACTIVATE
, hook
|optional
}, /* win2000 doesn't send it */
9677 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2000 doesn't send it */
9678 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 doesn't send it */
9679 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
9680 { WM_MOVE
, sent
|defwinproc
},
9681 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_RESTORED
},
9682 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 sends it */
9685 static const struct message WmRestore_2
[] = {
9686 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
9687 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
9688 { HCBT_ACTIVATE
, hook
|optional
}, /* win2000 doesn't send it */
9689 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2000 doesn't send it */
9690 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 doesn't send it */
9691 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
9694 static const struct message WmRestore_3
[] = {
9695 { HCBT_MINMAX
, hook
|lparam
, 0, SW_RESTORE
},
9696 { WM_GETMINMAXINFO
, sent
},
9697 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
9698 { HCBT_ACTIVATE
, hook
|optional
}, /* win2003 doesn't send it */
9699 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2003 doesn't send it */
9700 { HCBT_SETFOCUS
, hook
|optional
}, /* win2003 doesn't send it */
9701 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
9702 { WM_MOVE
, sent
|defwinproc
},
9703 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_MAXIMIZED
},
9704 { HCBT_SETFOCUS
, hook
|optional
}, /* win2003 sends it */
9707 static const struct message WmRestore_4
[] = {
9708 { HCBT_MINMAX
, hook
|lparam
, 0, SW_RESTORE
},
9709 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
9710 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
9711 { WM_MOVE
, sent
|defwinproc
},
9712 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_RESTORED
},
9715 static const struct message WmRestore_5
[] = {
9716 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWNORMAL
},
9717 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
9718 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
9719 { WM_MOVE
, sent
|defwinproc
},
9720 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_RESTORED
},
9723 static const struct message WmHide_1
[] = {
9724 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
9725 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
9726 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
9727 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 sends it */
9730 static const struct message WmHide_2
[] = {
9731 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
9732 { WM_WINDOWPOSCHANGING
, sent
/*|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE*/ }, /* win2000 doesn't add SWP_NOACTIVATE */
9733 { WM_WINDOWPOSCHANGED
, sent
/*|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE*/ }, /* win2000 doesn't add SWP_NOACTIVATE */
9736 static const struct message WmHide_3
[] = {
9737 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
9738 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
9739 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
9740 { HCBT_SETFOCUS
, hook
|optional
},
9741 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
9744 static const struct message WmShowMinimized_1
[] = {
9745 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINIMIZED
},
9746 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
9747 { HCBT_ACTIVATE
, hook
|optional
}, /* win2000 doesn't send it */
9748 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2000 doesn't send it */
9749 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
9750 { WM_MOVE
, sent
|defwinproc
},
9751 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_MINIMIZED
},
9754 static const struct message WmMinimize_1
[] = {
9755 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
9756 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 doesn't send it */
9757 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
9758 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
9759 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
9760 { WM_MOVE
, sent
|defwinproc
},
9761 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_MINIMIZED
},
9764 static const struct message WmMinimize_2
[] = {
9765 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
9766 { HCBT_SETFOCUS
, hook
|optional
},
9767 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
9768 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
9769 { WM_MOVE
, sent
|defwinproc
},
9770 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_MINIMIZED
},
9773 static const struct message WmMinimize_3
[] = {
9774 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
9775 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
9776 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
9777 { WM_MOVE
, sent
|defwinproc
},
9778 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_MINIMIZED
},
9781 static const struct message WmShowMinNoActivate
[] = {
9782 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINNOACTIVE
},
9783 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
9784 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
9787 static const struct message WmMinMax_1
[] = {
9788 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINIMIZED
},
9791 static const struct message WmMinMax_2
[] = {
9792 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMAXIMIZED
},
9795 static const struct message WmMinMax_3
[] = {
9796 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
9799 static const struct message WmMinMax_4
[] = {
9800 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINNOACTIVE
},
9803 static const struct message WmShowMaximized_1
[] = {
9804 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMAXIMIZED
},
9805 { WM_GETMINMAXINFO
, sent
},
9806 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
9807 { HCBT_ACTIVATE
, hook
|optional
}, /* win2000 doesn't send it */
9808 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2000 doesn't send it */
9809 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 doesn't send it */
9810 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
9811 { WM_MOVE
, sent
|defwinproc
},
9812 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_MAXIMIZED
},
9813 { HCBT_SETFOCUS
, hook
|optional
}, /* win2003 sends it */
9816 static const struct message WmShowMaximized_2
[] = {
9817 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMAXIMIZED
},
9818 { WM_GETMINMAXINFO
, sent
},
9819 { WM_WINDOWPOSCHANGING
, sent
|optional
},
9820 { HCBT_ACTIVATE
, hook
|optional
},
9821 { WM_WINDOWPOSCHANGED
, sent
|optional
},
9822 { WM_MOVE
, sent
|optional
}, /* Win9x doesn't send it */
9823 { WM_SIZE
, sent
|wparam
|optional
, SIZE_MAXIMIZED
}, /* Win9x doesn't send it */
9824 { WM_WINDOWPOSCHANGING
, sent
},
9825 { HCBT_SETFOCUS
, hook
|optional
},
9826 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
9827 { WM_MOVE
, sent
|defwinproc
},
9828 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_MAXIMIZED
},
9829 { HCBT_SETFOCUS
, hook
|optional
},
9832 static const struct message WmShowMaximized_3
[] = {
9833 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMAXIMIZED
},
9834 { WM_GETMINMAXINFO
, sent
},
9835 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
9836 { HCBT_ACTIVATE
, hook
|optional
}, /* win2000 doesn't send it */
9837 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2000 doesn't send it */
9838 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 doesn't send it */
9839 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
9840 { WM_MOVE
, sent
|defwinproc
},
9841 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_MAXIMIZED
},
9845 static void test_ShowWindow(void)
9847 /* ShowWindow commands in random order */
9850 INT cmd
; /* ShowWindow command */
9851 LPARAM ret
; /* ShowWindow return value */
9852 DWORD style
; /* window style after the command */
9853 const struct message
*msg
; /* message sequence the command produces */
9854 BOOL todo_msg
; /* message sequence doesn't match what Wine does */
9857 /* 1 */ { SW_SHOWNORMAL
, FALSE
, WS_VISIBLE
, WmShowNormal
, FALSE
},
9858 /* 2 */ { SW_SHOWNORMAL
, TRUE
, WS_VISIBLE
, WmEmptySeq
, FALSE
},
9859 /* 3 */ { SW_HIDE
, TRUE
, 0, WmHide_1
, FALSE
},
9860 /* 4 */ { SW_HIDE
, FALSE
, 0, WmEmptySeq
, FALSE
},
9861 /* 5 */ { SW_SHOWMINIMIZED
, FALSE
, WS_VISIBLE
|WS_MINIMIZE
, WmShowMinimized_1
, FALSE
},
9862 /* 6 */ { SW_SHOWMINIMIZED
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinMax_1
, FALSE
},
9863 /* 7 */ { SW_HIDE
, TRUE
, WS_MINIMIZE
, WmHide_1
, FALSE
},
9864 /* 8 */ { SW_HIDE
, FALSE
, WS_MINIMIZE
, WmEmptySeq
, FALSE
},
9865 /* 9 */ { SW_SHOWMAXIMIZED
, FALSE
, WS_VISIBLE
|WS_MAXIMIZE
, WmShowMaximized_1
, FALSE
},
9866 /* 10 */ { SW_SHOWMAXIMIZED
, TRUE
, WS_VISIBLE
|WS_MAXIMIZE
, WmMinMax_2
, FALSE
},
9867 /* 11 */ { SW_HIDE
, TRUE
, WS_MAXIMIZE
, WmHide_1
, FALSE
},
9868 /* 12 */ { SW_HIDE
, FALSE
, WS_MAXIMIZE
, WmEmptySeq
, FALSE
},
9869 /* 13 */ { SW_SHOWNOACTIVATE
, FALSE
, WS_VISIBLE
, WmShowNoActivate_1
, FALSE
},
9870 /* 14 */ { SW_SHOWNOACTIVATE
, TRUE
, WS_VISIBLE
, WmEmptySeq
, FALSE
},
9871 /* 15 */ { SW_HIDE
, TRUE
, 0, WmHide_2
, FALSE
},
9872 /* 16 */ { SW_HIDE
, FALSE
, 0, WmEmptySeq
, FALSE
},
9873 /* 17 */ { SW_SHOW
, FALSE
, WS_VISIBLE
, WmShow
, FALSE
},
9874 /* 18 */ { SW_SHOW
, TRUE
, WS_VISIBLE
, WmEmptySeq
, FALSE
},
9875 /* 19 */ { SW_MINIMIZE
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinimize_1
, FALSE
},
9876 /* 20 */ { SW_MINIMIZE
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinMax_3
, FALSE
},
9877 /* 21 */ { SW_HIDE
, TRUE
, WS_MINIMIZE
, WmHide_2
, FALSE
},
9878 /* 22 */ { SW_SHOWMINNOACTIVE
, FALSE
, WS_VISIBLE
|WS_MINIMIZE
, WmShowMinNoActivate
, TRUE
},
9879 /* 23 */ { SW_SHOWMINNOACTIVE
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinMax_4
, FALSE
},
9880 /* 24 */ { SW_HIDE
, TRUE
, WS_MINIMIZE
, WmHide_2
, FALSE
},
9881 /* 25 */ { SW_HIDE
, FALSE
, WS_MINIMIZE
, WmEmptySeq
, FALSE
},
9882 /* 26 */ { SW_SHOWNA
, FALSE
, WS_VISIBLE
|WS_MINIMIZE
, WmShowNA_1
, FALSE
},
9883 /* 27 */ { SW_SHOWNA
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmShowNA_2
, FALSE
},
9884 /* 28 */ { SW_HIDE
, TRUE
, WS_MINIMIZE
, WmHide_2
, FALSE
},
9885 /* 29 */ { SW_HIDE
, FALSE
, WS_MINIMIZE
, WmEmptySeq
, FALSE
},
9886 /* 30 */ { SW_RESTORE
, FALSE
, WS_VISIBLE
, WmRestore_1
, FALSE
},
9887 /* 31 */ { SW_RESTORE
, TRUE
, WS_VISIBLE
, WmEmptySeq
, FALSE
},
9888 /* 32 */ { SW_HIDE
, TRUE
, 0, WmHide_3
, FALSE
},
9889 /* 33 */ { SW_HIDE
, FALSE
, 0, WmEmptySeq
, FALSE
},
9890 /* 34 */ { SW_NORMALNA
, FALSE
, 0, WmEmptySeq
, FALSE
}, /* what does this mean?! */
9891 /* 35 */ { SW_NORMALNA
, FALSE
, 0, WmEmptySeq
, FALSE
},
9892 /* 36 */ { SW_HIDE
, FALSE
, 0, WmEmptySeq
, FALSE
},
9893 /* 37 */ { SW_RESTORE
, FALSE
, WS_VISIBLE
, WmRestore_2
, FALSE
},
9894 /* 38 */ { SW_RESTORE
, TRUE
, WS_VISIBLE
, WmEmptySeq
, FALSE
},
9895 /* 39 */ { SW_SHOWNOACTIVATE
, TRUE
, WS_VISIBLE
, WmEmptySeq
, FALSE
},
9896 /* 40 */ { SW_MINIMIZE
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinimize_2
, FALSE
},
9897 /* 41 */ { SW_MINIMIZE
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinMax_3
, FALSE
},
9898 /* 42 */ { SW_SHOWMAXIMIZED
, TRUE
, WS_VISIBLE
|WS_MAXIMIZE
, WmShowMaximized_2
, TRUE
},
9899 /* 43 */ { SW_SHOWMAXIMIZED
, TRUE
, WS_VISIBLE
|WS_MAXIMIZE
, WmMinMax_2
, FALSE
},
9900 /* 44 */ { SW_MINIMIZE
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinimize_1
, FALSE
},
9901 /* 45 */ { SW_MINIMIZE
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinMax_3
, FALSE
},
9902 /* 46 */ { SW_RESTORE
, TRUE
, WS_VISIBLE
|WS_MAXIMIZE
, WmRestore_3
, FALSE
},
9903 /* 47 */ { SW_RESTORE
, TRUE
, WS_VISIBLE
, WmRestore_4
, FALSE
},
9904 /* 48 */ { SW_SHOWMAXIMIZED
, TRUE
, WS_VISIBLE
|WS_MAXIMIZE
, WmShowMaximized_3
, FALSE
},
9905 /* 49 */ { SW_SHOW
, TRUE
, WS_VISIBLE
|WS_MAXIMIZE
, WmEmptySeq
, FALSE
},
9906 /* 50 */ { SW_SHOWNORMAL
, TRUE
, WS_VISIBLE
, WmRestore_5
, FALSE
},
9907 /* 51 */ { SW_SHOWNORMAL
, TRUE
, WS_VISIBLE
, WmEmptySeq
, FALSE
},
9908 /* 52 */ { SW_HIDE
, TRUE
, 0, WmHide_1
, FALSE
},
9909 /* 53 */ { SW_HIDE
, FALSE
, 0, WmEmptySeq
, FALSE
},
9910 /* 54 */ { SW_MINIMIZE
, FALSE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinimize_3
, FALSE
},
9911 /* 55 */ { SW_HIDE
, TRUE
, WS_MINIMIZE
, WmHide_2
, FALSE
},
9912 /* 56 */ { SW_SHOWNOACTIVATE
, FALSE
, WS_VISIBLE
, WmShowNoActivate_2
, FALSE
},
9913 /* 57 */ { SW_SHOW
, TRUE
, WS_VISIBLE
, WmEmptySeq
, FALSE
}
9920 #define WS_BASE (WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX|WS_MAXIMIZEBOX|WS_POPUP|WS_CLIPSIBLINGS)
9921 hwnd
= CreateWindowEx(0, "ShowWindowClass", NULL
, WS_BASE
,
9926 style
= GetWindowLong(hwnd
, GWL_STYLE
) & ~WS_BASE
;
9927 ok(style
== 0, "expected style 0, got %08x\n", style
);
9932 for (i
= 0; i
< sizeof(sw
)/sizeof(sw
[0]); i
++)
9934 static const char * const sw_cmd_name
[13] =
9936 "SW_HIDE", "SW_SHOWNORMAL", "SW_SHOWMINIMIZED", "SW_SHOWMAXIMIZED",
9937 "SW_SHOWNOACTIVATE", "SW_SHOW", "SW_MINIMIZE", "SW_SHOWMINNOACTIVE",
9938 "SW_SHOWNA", "SW_RESTORE", "SW_SHOWDEFAULT", "SW_FORCEMINIMIZE",
9939 "SW_NORMALNA" /* 0xCC */
9942 INT idx
; /* index into the above array of names */
9944 idx
= (sw
[i
].cmd
== SW_NORMALNA
) ? 12 : sw
[i
].cmd
;
9946 style
= GetWindowLong(hwnd
, GWL_STYLE
);
9947 trace("%d: sending %s, current window style %08x\n", i
+1, sw_cmd_name
[idx
], style
);
9948 ret
= ShowWindow(hwnd
, sw
[i
].cmd
);
9949 ok(!ret
== !sw
[i
].ret
, "%d: cmd %s: expected ret %lu, got %lu\n", i
+1, sw_cmd_name
[idx
], sw
[i
].ret
, ret
);
9950 style
= GetWindowLong(hwnd
, GWL_STYLE
) & ~WS_BASE
;
9951 ok(style
== sw
[i
].style
, "%d: expected style %08x, got %08x\n", i
+1, sw
[i
].style
, style
);
9953 sprintf(comment
, "%d: ShowWindow(%s)", i
+1, sw_cmd_name
[idx
]);
9954 ok_sequence(sw
[i
].msg
, comment
, sw
[i
].todo_msg
);
9960 DestroyWindow(hwnd
);
9963 static INT_PTR WINAPI
test_dlg_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
9967 trace("dialog: %p, %04x, %08lx, %08lx\n", hwnd
, message
, wParam
, lParam
);
9971 case WM_WINDOWPOSCHANGING
:
9972 case WM_WINDOWPOSCHANGED
:
9974 WINDOWPOS
*winpos
= (WINDOWPOS
*)lParam
;
9976 trace("%s\n", (message
== WM_WINDOWPOSCHANGING
) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
9977 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x ",
9978 winpos
->hwnd
, winpos
->hwndInsertAfter
,
9979 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
9980 dump_winpos_flags(winpos
->flags
);
9982 /* Log only documented flags, win2k uses 0x1000 and 0x2000
9983 * in the high word for internal purposes
9985 wParam
= winpos
->flags
& 0xffff;
9986 /* We are not interested in the flags that don't match under XP and Win9x */
9987 wParam
&= ~(SWP_NOZORDER
);
9991 /* explicitly ignore WM_GETICON message */
9996 msg
.message
= message
;
9997 msg
.flags
= sent
|wparam
|lparam
;
9998 msg
.wParam
= wParam
;
9999 msg
.lParam
= lParam
;
10002 /* calling DefDlgProc leads to a recursion under XP */
10006 case WM_INITDIALOG
:
10007 case WM_GETDLGCODE
:
10013 static const struct message WmDefDlgSetFocus_1
[] = {
10014 { WM_GETDLGCODE
, sent
|wparam
|lparam
, 0, 0 },
10015 { WM_GETTEXTLENGTH
, sent
|wparam
|lparam
|optional
, 0, 0 }, /* XP */
10016 { WM_GETTEXT
, sent
|wparam
|optional
, 6 }, /* XP */
10017 { WM_GETTEXT
, sent
|wparam
|optional
, 12 }, /* XP */
10018 { EM_SETSEL
, sent
|wparam
, 0 }, /* XP sets lparam to text length, Win9x to -2 */
10019 { HCBT_SETFOCUS
, hook
},
10020 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
10021 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
10022 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
10023 { WM_SETFOCUS
, sent
|wparam
, 0 },
10024 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 10 },
10025 { WM_CTLCOLOREDIT
, sent
},
10026 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 11 },
10027 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
10028 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
10029 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
10030 { WM_COMMAND
, sent
|wparam
, MAKEWPARAM(1, EN_SETFOCUS
) },
10033 static const struct message WmDefDlgSetFocus_2
[] = {
10034 { WM_GETDLGCODE
, sent
|wparam
|lparam
, 0, 0 },
10035 { WM_GETTEXTLENGTH
, sent
|wparam
|lparam
|optional
, 0, 0 }, /* XP */
10036 { WM_GETTEXT
, sent
|wparam
|optional
, 6 }, /* XP */
10037 { WM_GETTEXT
, sent
|wparam
|optional
, 12 }, /* XP */
10038 { EM_SETSEL
, sent
|wparam
, 0 }, /* XP sets lparam to text length, Win9x to -2 */
10039 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
10040 { WM_CTLCOLOREDIT
, sent
|optional
}, /* XP */
10041 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
10044 /* Creation of a dialog */
10045 static const struct message WmCreateDialogParamSeq_1
[] = {
10046 { HCBT_CREATEWND
, hook
},
10047 { WM_NCCREATE
, sent
},
10048 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
10049 { WM_CREATE
, sent
},
10050 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
10051 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
10053 { WM_SETFONT
, sent
},
10054 { WM_INITDIALOG
, sent
},
10055 { WM_CHANGEUISTATE
, sent
|optional
},
10058 /* Creation of a dialog */
10059 static const struct message WmCreateDialogParamSeq_2
[] = {
10060 { HCBT_CREATEWND
, hook
},
10061 { WM_NCCREATE
, sent
},
10062 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
10063 { WM_CREATE
, sent
},
10064 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
10065 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
10067 { WM_CHANGEUISTATE
, sent
|optional
},
10071 static void test_dialog_messages(void)
10074 HWND hdlg
, hedit1
, hedit2
, hfocus
;
10077 #define set_selection(hctl, start, end) \
10078 ret = SendMessage(hctl, EM_SETSEL, start, end); \
10079 ok(ret == 1, "EM_SETSEL returned %ld\n", ret);
10081 #define check_selection(hctl, start, end) \
10082 ret = SendMessage(hctl, EM_GETSEL, 0, 0); \
10083 ok(ret == MAKELRESULT(start, end), "wrong selection (%d - %d)\n", LOWORD(ret), HIWORD(ret));
10087 hdlg
= CreateWindowEx(WS_EX_DLGMODALFRAME
, "TestDialogClass", NULL
,
10088 WS_VISIBLE
|WS_CAPTION
|WS_SYSMENU
|WS_DLGFRAME
,
10089 0, 0, 100, 100, 0, 0, 0, NULL
);
10090 ok(hdlg
!= 0, "Failed to create custom dialog window\n");
10092 hedit1
= CreateWindowEx(0, "my_edit_class", NULL
,
10093 WS_CHILD
|WS_BORDER
|WS_VISIBLE
|WS_TABSTOP
,
10094 0, 0, 80, 20, hdlg
, (HMENU
)1, 0, NULL
);
10095 ok(hedit1
!= 0, "Failed to create edit control\n");
10096 hedit2
= CreateWindowEx(0, "my_edit_class", NULL
,
10097 WS_CHILD
|WS_BORDER
|WS_VISIBLE
|WS_TABSTOP
,
10098 0, 40, 80, 20, hdlg
, (HMENU
)2, 0, NULL
);
10099 ok(hedit2
!= 0, "Failed to create edit control\n");
10101 SendMessage(hedit1
, WM_SETTEXT
, 0, (LPARAM
)"hello");
10102 SendMessage(hedit2
, WM_SETTEXT
, 0, (LPARAM
)"bye");
10104 hfocus
= GetFocus();
10105 ok(hfocus
== hdlg
, "wrong focus %p\n", hfocus
);
10108 hfocus
= GetFocus();
10109 ok(hfocus
== hedit2
, "wrong focus %p\n", hfocus
);
10111 check_selection(hedit1
, 0, 0);
10112 check_selection(hedit2
, 0, 0);
10114 set_selection(hedit2
, 0, -1);
10115 check_selection(hedit2
, 0, 3);
10118 hfocus
= GetFocus();
10119 ok(hfocus
== 0, "wrong focus %p\n", hfocus
);
10122 ret
= DefDlgProc(hdlg
, WM_SETFOCUS
, 0, 0);
10123 ok(ret
== 0, "WM_SETFOCUS returned %ld\n", ret
);
10124 ok_sequence(WmDefDlgSetFocus_1
, "DefDlgProc(WM_SETFOCUS) 1", FALSE
);
10126 hfocus
= GetFocus();
10127 ok(hfocus
== hedit1
, "wrong focus %p\n", hfocus
);
10129 check_selection(hedit1
, 0, 5);
10130 check_selection(hedit2
, 0, 3);
10133 ret
= DefDlgProc(hdlg
, WM_SETFOCUS
, 0, 0);
10134 ok(ret
== 0, "WM_SETFOCUS returned %ld\n", ret
);
10135 ok_sequence(WmDefDlgSetFocus_2
, "DefDlgProc(WM_SETFOCUS) 2", FALSE
);
10137 hfocus
= GetFocus();
10138 ok(hfocus
== hedit1
, "wrong focus %p\n", hfocus
);
10140 check_selection(hedit1
, 0, 5);
10141 check_selection(hedit2
, 0, 3);
10143 EndDialog(hdlg
, 0);
10144 DestroyWindow(hedit1
);
10145 DestroyWindow(hedit2
);
10146 DestroyWindow(hdlg
);
10149 #undef set_selection
10150 #undef check_selection
10152 ok(GetClassInfo(0, "#32770", &cls
), "GetClassInfo failed\n");
10153 cls
.lpszClassName
= "MyDialogClass";
10154 cls
.hInstance
= GetModuleHandle(0);
10155 /* need a cast since a dlgproc is used as a wndproc */
10156 cls
.lpfnWndProc
= (WNDPROC
)test_dlg_proc
;
10157 if (!RegisterClass(&cls
)) assert(0);
10159 hdlg
= CreateDialogParam(0, "CLASS_TEST_DIALOG_2", 0, test_dlg_proc
, 0);
10160 ok(IsWindow(hdlg
), "CreateDialogParam failed\n");
10161 ok_sequence(WmCreateDialogParamSeq_1
, "CreateDialogParam_1", FALSE
);
10162 EndDialog(hdlg
, 0);
10163 DestroyWindow(hdlg
);
10166 hdlg
= CreateDialogParam(0, "CLASS_TEST_DIALOG_2", 0, NULL
, 0);
10167 ok(IsWindow(hdlg
), "CreateDialogParam failed\n");
10168 ok_sequence(WmCreateDialogParamSeq_2
, "CreateDialogParam_2", FALSE
);
10169 EndDialog(hdlg
, 0);
10170 DestroyWindow(hdlg
);
10173 UnregisterClass(cls
.lpszClassName
, cls
.hInstance
);
10176 static void test_nullCallback(void)
10180 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW
,
10181 100, 100, 200, 200, 0, 0, 0, NULL
);
10182 ok (hwnd
!= 0, "Failed to create overlapped window\n");
10184 SendMessageCallbackA(hwnd
,WM_NULL
,0,0,NULL
,0);
10186 DestroyWindow(hwnd
);
10189 /* SetActiveWindow( 0 ) hwnd visible */
10190 static const struct message SetActiveWindowSeq0
[] =
10192 { HCBT_ACTIVATE
, hook
},
10193 { WM_NCACTIVATE
, sent
|wparam
, 0 },
10194 { WM_GETTEXT
, sent
|defwinproc
|optional
},
10195 { WM_ACTIVATE
, sent
|wparam
, 0 },
10196 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
10197 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
10198 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
},
10199 { WM_NCACTIVATE
, sent
|wparam
, 1 },
10200 { WM_GETTEXT
, sent
|defwinproc
|optional
},
10201 { WM_ACTIVATE
, sent
|wparam
, 1 },
10202 { HCBT_SETFOCUS
, hook
},
10203 { WM_KILLFOCUS
, sent
|defwinproc
},
10204 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 0 },
10205 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
10206 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 1 },
10207 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
10208 { WM_SETFOCUS
, sent
|defwinproc
},
10211 /* SetActiveWindow( hwnd ) hwnd visible */
10212 static const struct message SetActiveWindowSeq1
[] =
10214 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
10217 /* SetActiveWindow( popup ) hwnd visible, popup visible */
10218 static const struct message SetActiveWindowSeq2
[] =
10220 { HCBT_ACTIVATE
, hook
},
10221 { WM_NCACTIVATE
, sent
|wparam
, 0 },
10222 { WM_GETTEXT
, sent
|defwinproc
|optional
},
10223 { WM_ACTIVATE
, sent
|wparam
, 0 },
10224 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
10225 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
10226 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
10227 { WM_NCPAINT
, sent
|optional
},
10228 { WM_GETTEXT
, sent
|defwinproc
|optional
},
10229 { WM_ERASEBKGND
, sent
|optional
},
10230 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
10231 { WM_NCACTIVATE
, sent
|wparam
, 1 },
10232 { WM_GETTEXT
, sent
|defwinproc
|optional
},
10233 { WM_ACTIVATE
, sent
|wparam
, 1 },
10234 { HCBT_SETFOCUS
, hook
},
10235 { WM_KILLFOCUS
, sent
|defwinproc
},
10236 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 0 },
10237 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
10238 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 1 },
10239 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
10240 { WM_SETFOCUS
, sent
|defwinproc
},
10244 /* SetActiveWindow( hwnd ) hwnd not visible */
10245 static const struct message SetActiveWindowSeq3
[] =
10247 { HCBT_ACTIVATE
, hook
},
10248 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
10249 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
10250 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
},
10251 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOACTIVATE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
10252 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
10253 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
10254 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
10255 { WM_NCACTIVATE
, sent
|wparam
, 1 },
10256 { WM_ACTIVATE
, sent
|wparam
, 1 },
10257 { HCBT_SETFOCUS
, hook
},
10258 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
10259 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
10260 { WM_SETFOCUS
, sent
|defwinproc
},
10263 /* SetActiveWindow( popup ) hwnd not visible, popup not visible */
10264 static const struct message SetActiveWindowSeq4
[] =
10266 { HCBT_ACTIVATE
, hook
},
10267 { WM_NCACTIVATE
, sent
|wparam
, 0 },
10268 { WM_GETTEXT
, sent
|defwinproc
|optional
},
10269 { WM_ACTIVATE
, sent
|wparam
, 0 },
10270 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
10271 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
},
10272 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
10273 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|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
},
10288 static void test_SetActiveWindow(void)
10290 HWND hwnd
, popup
, ret
;
10292 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test SetActiveWindow",
10293 WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
10294 100, 100, 200, 200, 0, 0, 0, NULL
);
10296 popup
= CreateWindowExA(0, "TestWindowClass", "Test SetActiveWindow",
10297 WS_OVERLAPPEDWINDOW
| WS_VISIBLE
| WS_POPUP
,
10298 100, 100, 200, 200, hwnd
, 0, 0, NULL
);
10300 ok(hwnd
!= 0, "Failed to create overlapped window\n");
10303 ok(popup
!= 0, "Failed to create popup window\n");
10306 trace("SetActiveWindow(0)\n");
10307 ret
= SetActiveWindow(0);
10308 ok( ret
== popup
, "Failed to SetActiveWindow(0)\n");
10309 ok_sequence(SetActiveWindowSeq0
, "SetActiveWindow(0)", TRUE
);
10312 trace("SetActiveWindow(hwnd), hwnd visible\n");
10313 ret
= SetActiveWindow(hwnd
);
10316 ok( ret
== hwnd
, "Failed to SetActiveWindow(hwnd), hwnd visible\n");
10318 ok_sequence(SetActiveWindowSeq1
, "SetActiveWindow(hwnd), hwnd visible", TRUE
);
10321 trace("SetActiveWindow(popup), hwnd visible, popup visible\n");
10322 ret
= SetActiveWindow(popup
);
10323 ok( ret
== hwnd
, "Failed to SetActiveWindow(popup), popup visible\n");
10324 ok_sequence(SetActiveWindowSeq2
, "SetActiveWindow(popup), hwnd visible, popup visible", FALSE
);
10327 ShowWindow(hwnd
, SW_HIDE
);
10328 ShowWindow(popup
, SW_HIDE
);
10331 trace("SetActiveWindow(hwnd), hwnd not visible\n");
10332 ret
= SetActiveWindow(hwnd
);
10333 ok( ret
== NULL
, "Failed to SetActiveWindow(hwnd), hwnd not visible\n");
10334 ok_sequence(SetActiveWindowSeq3
, "SetActiveWindow(hwnd), hwnd not visible", TRUE
);
10337 trace("SetActiveWindow(popup), hwnd not visible, popup not visible\n");
10338 ret
= SetActiveWindow(popup
);
10339 ok( ret
== hwnd
, "Failed to SetActiveWindow(popup)\n");
10340 ok_sequence(SetActiveWindowSeq4
, "SetActiveWindow(popup), hwnd not visible, popup not visible", TRUE
);
10345 DestroyWindow(hwnd
);
10348 static const struct message SetForegroundWindowSeq
[] =
10350 { WM_NCACTIVATE
, sent
|wparam
, 0 },
10351 { WM_GETTEXT
, sent
|defwinproc
|optional
},
10352 { WM_ACTIVATE
, sent
|wparam
, 0 },
10353 { WM_ACTIVATEAPP
, sent
|wparam
, 0 },
10354 { WM_KILLFOCUS
, sent
},
10355 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
10356 { WM_IME_NOTIFY
, sent
|wparam
|optional
|defwinproc
, 1 },
10360 static void test_SetForegroundWindow(void)
10364 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test SetForegroundWindow",
10365 WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
10366 100, 100, 200, 200, 0, 0, 0, NULL
);
10367 ok (hwnd
!= 0, "Failed to create overlapped window\n");
10370 trace("SetForegroundWindow( 0 )\n");
10371 SetForegroundWindow( 0 );
10372 ok_sequence(WmEmptySeq
, "SetForegroundWindow( 0 ) away from foreground top level window", FALSE
);
10373 trace("SetForegroundWindow( GetDesktopWindow() )\n");
10374 SetForegroundWindow( GetDesktopWindow() );
10375 ok_sequence(SetForegroundWindowSeq
, "SetForegroundWindow( desktop ) away from "
10376 "foreground top level window", FALSE
);
10379 DestroyWindow(hwnd
);
10382 static void test_dbcs_wm_char(void)
10385 WCHAR wch
, bad_wch
;
10393 struct message wmCharSeq
[2];
10395 if (!pGetCPInfoExA
)
10397 skip("GetCPInfoExA is not available\n");
10401 pGetCPInfoExA( CP_ACP
, 0, &cpinfo
);
10402 if (cpinfo
.MaxCharSize
!= 2)
10404 skip( "Skipping DBCS WM_CHAR test in SBCS codepage '%s'\n", cpinfo
.CodePageName
);
10408 dbch
[0] = dbch
[1] = 0;
10410 bad_wch
= cpinfo
.UnicodeDefaultChar
;
10411 for (i
= 0; !wch
&& i
< MAX_LEADBYTES
&& cpinfo
.LeadByte
[i
]; i
+= 2)
10412 for (j
= cpinfo
.LeadByte
[i
]; !wch
&& j
<= cpinfo
.LeadByte
[i
+1]; j
++)
10413 for (k
= 128; k
<= 255; k
++)
10419 if (MultiByteToWideChar( CP_ACP
, 0, str
, 2, wstr
, 2 ) == 1 &&
10420 WideCharToMultiByte( CP_ACP
, 0, wstr
, 1, str
, 2, NULL
, NULL
) == 2 &&
10421 (BYTE
)str
[0] == j
&& (BYTE
)str
[1] == k
&&
10422 HIBYTE(wstr
[0]) && HIBYTE(wstr
[0]) != 0xff)
10433 skip( "Skipping DBCS WM_CHAR test, no appropriate char found\n" );
10436 trace( "using dbcs char %02x,%02x wchar %04x bad wchar %04x codepage '%s'\n",
10437 dbch
[0], dbch
[1], wch
, bad_wch
, cpinfo
.CodePageName
);
10439 hwnd
= CreateWindowExW(0, testWindowClassW
, NULL
,
10440 WS_OVERLAPPEDWINDOW
, 100, 100, 200, 200, 0, 0, 0, NULL
);
10441 hwnd2
= CreateWindowExW(0, testWindowClassW
, NULL
,
10442 WS_OVERLAPPEDWINDOW
, 100, 100, 200, 200, 0, 0, 0, NULL
);
10443 ok (hwnd
!= 0, "Failed to create overlapped window\n");
10444 ok (hwnd2
!= 0, "Failed to create overlapped window\n");
10447 memset( wmCharSeq
, 0, sizeof(wmCharSeq
) );
10448 wmCharSeq
[0].message
= WM_CHAR
;
10449 wmCharSeq
[0].flags
= sent
|wparam
;
10450 wmCharSeq
[0].wParam
= wch
;
10452 /* posted message */
10453 PostMessageA( hwnd
, WM_CHAR
, dbch
[0], 0 );
10454 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
10455 PostMessageA( hwnd
, WM_CHAR
, dbch
[1], 0 );
10456 ok( PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "no message\n" );
10457 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
10458 ok( msg
.wParam
== wch
, "bad wparam %lx/%x\n", msg
.wParam
, wch
);
10459 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
10461 /* posted thread message */
10462 PostThreadMessageA( GetCurrentThreadId(), WM_CHAR
, dbch
[0], 0 );
10463 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
10464 PostMessageA( hwnd
, WM_CHAR
, dbch
[1], 0 );
10465 ok( PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "no message\n" );
10466 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
10467 ok( msg
.wParam
== wch
, "bad wparam %lx/%x\n", msg
.wParam
, wch
);
10468 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
10472 SendMessageA( hwnd
, WM_CHAR
, dbch
[0], 0 );
10473 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
10474 SendMessageA( hwnd
, WM_CHAR
, dbch
[1], 0 );
10475 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
10476 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
10478 /* sent message with timeout */
10480 SendMessageTimeoutA( hwnd
, WM_CHAR
, dbch
[0], 0, SMTO_NORMAL
, 0, &res
);
10481 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
10482 SendMessageTimeoutA( hwnd
, WM_CHAR
, dbch
[1], 0, SMTO_NORMAL
, 0, &res
);
10483 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
10484 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
10486 /* sent message with timeout and callback */
10488 SendMessageTimeoutA( hwnd
, WM_CHAR
, dbch
[0], 0, SMTO_NORMAL
, 0, &res
);
10489 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
10490 SendMessageCallbackA( hwnd
, WM_CHAR
, dbch
[1], 0, NULL
, 0 );
10491 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
10492 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
10494 /* sent message with callback */
10496 SendNotifyMessageA( hwnd
, WM_CHAR
, dbch
[0], 0 );
10497 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
10498 SendMessageCallbackA( hwnd
, WM_CHAR
, dbch
[1], 0, NULL
, 0 );
10499 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
10500 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
10502 /* direct window proc call */
10504 CallWindowProcA( (WNDPROC
)GetWindowLongPtrA( hwnd
, GWLP_WNDPROC
), hwnd
, WM_CHAR
, dbch
[0], 0 );
10505 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
10506 CallWindowProcA( (WNDPROC
)GetWindowLongPtrA( hwnd
, GWLP_WNDPROC
), hwnd
, WM_CHAR
, dbch
[1], 0 );
10507 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
10509 /* dispatch message */
10511 msg
.message
= WM_CHAR
;
10512 msg
.wParam
= dbch
[0];
10514 DispatchMessageA( &msg
);
10515 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
10516 msg
.wParam
= dbch
[1];
10517 DispatchMessageA( &msg
);
10518 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
10520 /* window handle is irrelevant */
10522 SendMessageA( hwnd2
, WM_CHAR
, dbch
[0], 0 );
10523 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
10524 SendMessageA( hwnd
, WM_CHAR
, dbch
[1], 0 );
10525 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
10526 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
10528 /* interleaved post and send */
10530 PostMessageA( hwnd2
, WM_CHAR
, dbch
[0], 0 );
10531 SendMessageA( hwnd2
, WM_CHAR
, dbch
[0], 0 );
10532 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
10533 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
10534 PostMessageA( hwnd
, WM_CHAR
, dbch
[1], 0 );
10535 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
10536 ok( PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "no message\n" );
10537 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
10538 ok( msg
.wParam
== wch
, "bad wparam %lx/%x\n", msg
.wParam
, wch
);
10539 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
10540 SendMessageA( hwnd
, WM_CHAR
, dbch
[1], 0 );
10541 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
10542 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
10544 /* interleaved sent message and winproc */
10546 SendMessageA( hwnd
, WM_CHAR
, dbch
[0], 0 );
10547 CallWindowProcA( (WNDPROC
)GetWindowLongPtrA( hwnd
, GWLP_WNDPROC
), hwnd
, WM_CHAR
, dbch
[0], 0 );
10548 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
10549 SendMessageA( hwnd
, WM_CHAR
, dbch
[1], 0 );
10550 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
10551 CallWindowProcA( (WNDPROC
)GetWindowLongPtrA( hwnd
, GWLP_WNDPROC
), hwnd
, WM_CHAR
, dbch
[1], 0 );
10552 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
10554 /* interleaved winproc and dispatch */
10556 msg
.message
= WM_CHAR
;
10557 msg
.wParam
= dbch
[0];
10559 CallWindowProcA( (WNDPROC
)GetWindowLongPtrA( hwnd
, GWLP_WNDPROC
), hwnd
, WM_CHAR
, dbch
[0], 0 );
10560 DispatchMessageA( &msg
);
10561 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
10562 msg
.wParam
= dbch
[1];
10563 DispatchMessageA( &msg
);
10564 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
10565 CallWindowProcA( (WNDPROC
)GetWindowLongPtrA( hwnd
, GWLP_WNDPROC
), hwnd
, WM_CHAR
, dbch
[1], 0 );
10566 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
10568 /* interleaved sends */
10570 SendMessageA( hwnd
, WM_CHAR
, dbch
[0], 0 );
10571 SendMessageCallbackA( hwnd
, WM_CHAR
, dbch
[0], 0, NULL
, 0 );
10572 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
10573 SendMessageTimeoutA( hwnd
, WM_CHAR
, dbch
[1], 0, SMTO_NORMAL
, 0, &res
);
10574 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
10575 SendMessageA( hwnd
, WM_CHAR
, dbch
[1], 0 );
10576 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
10580 SendMessageA( hwnd2
, WM_CHAR
, (dbch
[1] << 8) | dbch
[0], 0 );
10581 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
10582 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
10584 /* other char messages are not magic */
10585 PostMessageA( hwnd
, WM_SYSCHAR
, dbch
[0], 0 );
10586 ok( PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "no message\n" );
10587 ok( msg
.message
== WM_SYSCHAR
, "unexpected message %x\n", msg
.message
);
10588 ok( msg
.wParam
== bad_wch
, "bad wparam %lx/%x\n", msg
.wParam
, bad_wch
);
10589 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
10590 PostMessageA( hwnd
, WM_DEADCHAR
, dbch
[0], 0 );
10591 ok( PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "no message\n" );
10592 ok( msg
.message
== WM_DEADCHAR
, "unexpected message %x\n", msg
.message
);
10593 ok( msg
.wParam
== bad_wch
, "bad wparam %lx/%x\n", msg
.wParam
, bad_wch
);
10594 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
10596 /* test retrieving messages */
10598 PostMessageW( hwnd
, WM_CHAR
, wch
, 0 );
10599 ok( PeekMessageA( &msg
, hwnd
, 0, 0, PM_REMOVE
), "no message\n" );
10600 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
10601 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
10602 ok( msg
.wParam
== dbch
[0], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
10603 ok( PeekMessageA( &msg
, hwnd
, 0, 0, PM_REMOVE
), "no message\n" );
10604 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
10605 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
10606 ok( msg
.wParam
== dbch
[1], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
10607 ok( !PeekMessageA( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
10609 /* message filters */
10610 PostMessageW( hwnd
, WM_CHAR
, wch
, 0 );
10611 ok( PeekMessageA( &msg
, hwnd
, 0, 0, PM_REMOVE
), "no message\n" );
10612 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
10613 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
10614 ok( msg
.wParam
== dbch
[0], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
10615 /* message id is filtered, hwnd is not */
10616 ok( !PeekMessageA( &msg
, hwnd
, WM_MOUSEFIRST
, WM_MOUSELAST
, PM_REMOVE
), "no message\n" );
10617 ok( PeekMessageA( &msg
, hwnd2
, 0, 0, PM_REMOVE
), "no message\n" );
10618 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
10619 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
10620 ok( msg
.wParam
== dbch
[1], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
10621 ok( !PeekMessageA( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
10623 /* mixing GetMessage and PostMessage */
10624 PostMessageW( hwnd
, WM_CHAR
, wch
, 0xbeef );
10625 ok( GetMessageA( &msg
, hwnd
, 0, 0 ), "no message\n" );
10626 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
10627 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
10628 ok( msg
.wParam
== dbch
[0], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
10629 ok( msg
.lParam
== 0xbeef, "bad lparam %lx\n", msg
.lParam
);
10632 ok( time
- GetTickCount() <= 100, "bad time %x\n", msg
.time
);
10633 ok( PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
), "no message\n" );
10634 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
10635 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
10636 ok( msg
.wParam
== dbch
[1], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
10637 ok( msg
.lParam
== 0xbeef, "bad lparam %lx\n", msg
.lParam
);
10638 ok( msg
.time
== time
, "bad time %x/%x\n", msg
.time
, time
);
10639 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
);
10640 ok( !PeekMessageA( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
10642 /* without PM_REMOVE */
10643 PostMessageW( hwnd
, WM_CHAR
, wch
, 0 );
10644 ok( PeekMessageA( &msg
, 0, 0, 0, PM_NOREMOVE
), "no message\n" );
10645 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
10646 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
10647 ok( msg
.wParam
== dbch
[0], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
10648 ok( PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
), "no message\n" );
10649 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
10650 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
10651 ok( msg
.wParam
== dbch
[0], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
10652 ok( PeekMessageA( &msg
, 0, 0, 0, PM_NOREMOVE
), "no message\n" );
10653 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
10654 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
10655 ok( msg
.wParam
== dbch
[1], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
10656 ok( PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
), "no message\n" );
10657 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
10658 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
10659 ok( msg
.wParam
== dbch
[1], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
10660 ok( !PeekMessageA( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
10662 DestroyWindow(hwnd
);
10665 #define ID_LISTBOX 0x000f
10667 static const struct message wm_lb_setcursel_0
[] =
10669 { LB_SETCURSEL
, sent
|wparam
|lparam
, 0, 0 },
10670 { WM_CTLCOLORLISTBOX
, sent
|parent
},
10671 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x000120f2 },
10672 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 1 },
10673 { EVENT_OBJECT_SELECTION
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 1 },
10676 static const struct message wm_lb_setcursel_1
[] =
10678 { LB_SETCURSEL
, sent
|wparam
|lparam
, 1, 0 },
10679 { WM_CTLCOLORLISTBOX
, sent
|parent
},
10680 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x000020f2 },
10681 { WM_CTLCOLORLISTBOX
, sent
|parent
},
10682 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x000121f2 },
10683 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 2 },
10684 { EVENT_OBJECT_SELECTION
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 2 },
10687 static const struct message wm_lb_setcursel_2
[] =
10689 { LB_SETCURSEL
, sent
|wparam
|lparam
, 2, 0 },
10690 { WM_CTLCOLORLISTBOX
, sent
|parent
},
10691 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x000021f2 },
10692 { WM_CTLCOLORLISTBOX
, sent
|parent
},
10693 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x000122f2 },
10694 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 3 },
10695 { EVENT_OBJECT_SELECTION
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 3 },
10698 static const struct message wm_lb_click_0
[] =
10700 { WM_LBUTTONDOWN
, sent
|wparam
|lparam
, 0, MAKELPARAM(1,1) },
10701 { HCBT_SETFOCUS
, hook
},
10702 { WM_KILLFOCUS
, sent
|parent
},
10703 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
|parent
, 0 },
10704 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
10705 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
10706 { WM_SETFOCUS
, sent
|defwinproc
},
10708 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x001142f2 },
10709 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_LISTBOX
, LBN_SETFOCUS
) },
10710 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 3 },
10711 { WM_LBTRACKPOINT
, sent
|wparam
|lparam
|parent
, 0, MAKELPARAM(1,1) },
10712 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
10714 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x000142f2 },
10715 { WM_CTLCOLORLISTBOX
, sent
|parent
},
10716 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x000022f2 },
10717 { WM_CTLCOLORLISTBOX
, sent
|parent
},
10718 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x000120f2 },
10719 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x001140f2 },
10721 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 1 },
10722 { EVENT_OBJECT_SELECTION
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 1 },
10724 { WM_LBUTTONUP
, sent
|wparam
|lparam
, 0, 0 },
10725 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, 0, 0 },
10726 { WM_CAPTURECHANGED
, sent
|wparam
|lparam
|defwinproc
, 0, 0 },
10727 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_LISTBOX
, LBN_SELCHANGE
) },
10731 #define check_lb_state(a1, a2, a3, a4, a5) check_lb_state_dbg(a1, a2, a3, a4, a5, __LINE__)
10733 static LRESULT (WINAPI
*listbox_orig_proc
)(HWND
, UINT
, WPARAM
, LPARAM
);
10735 static LRESULT WINAPI
listbox_hook_proc(HWND hwnd
, UINT message
, WPARAM wp
, LPARAM lp
)
10737 static long defwndproc_counter
= 0;
10739 struct message msg
;
10741 /* do not log painting messages */
10742 if (message
!= WM_PAINT
&&
10743 message
!= WM_NCPAINT
&&
10744 message
!= WM_SYNCPAINT
&&
10745 message
!= WM_ERASEBKGND
&&
10746 message
!= WM_NCHITTEST
&&
10747 message
!= WM_GETTEXT
&&
10748 message
!= WM_GETICON
&&
10749 message
!= WM_DEVICECHANGE
)
10751 trace("listbox: %p, %04x, %08lx, %08lx\n", hwnd
, message
, wp
, lp
);
10753 msg
.message
= message
;
10754 msg
.flags
= sent
|wparam
|lparam
;
10755 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
10761 defwndproc_counter
++;
10762 ret
= CallWindowProcA(listbox_orig_proc
, hwnd
, message
, wp
, lp
);
10763 defwndproc_counter
--;
10768 static void check_lb_state_dbg(HWND listbox
, int count
, int cur_sel
,
10769 int caret_index
, int top_index
, int line
)
10773 /* calling an orig proc helps to avoid unnecessary message logging */
10774 ret
= CallWindowProcA(listbox_orig_proc
, listbox
, LB_GETCOUNT
, 0, 0);
10775 ok_(__FILE__
, line
)(ret
== count
, "expected count %d, got %ld\n", count
, ret
);
10776 ret
= CallWindowProcA(listbox_orig_proc
, listbox
, LB_GETCURSEL
, 0, 0);
10777 ok_(__FILE__
, line
)(ret
== cur_sel
, "expected cur sel %d, got %ld\n", cur_sel
, ret
);
10778 ret
= CallWindowProcA(listbox_orig_proc
, listbox
, LB_GETCARETINDEX
, 0, 0);
10779 ok_(__FILE__
, line
)(ret
== caret_index
, "expected caret index %d, got %ld\n", caret_index
, ret
);
10780 ret
= CallWindowProcA(listbox_orig_proc
, listbox
, LB_GETTOPINDEX
, 0, 0);
10781 ok_(__FILE__
, line
)(ret
== top_index
, "expected top index %d, got %ld\n", top_index
, ret
);
10784 static void test_listbox_messages(void)
10786 HWND parent
, listbox
;
10789 parent
= CreateWindowExA(0, "TestParentClass", NULL
, WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
10790 100, 100, 200, 200, 0, 0, 0, NULL
);
10791 listbox
= CreateWindowExA(WS_EX_NOPARENTNOTIFY
, "ListBox", NULL
,
10792 WS_CHILD
| LBS_NOTIFY
| LBS_OWNERDRAWVARIABLE
| LBS_HASSTRINGS
| WS_VISIBLE
,
10793 10, 10, 80, 80, parent
, (HMENU
)ID_LISTBOX
, 0, NULL
);
10794 listbox_orig_proc
= (WNDPROC
)SetWindowLongPtrA(listbox
, GWLP_WNDPROC
, (ULONG_PTR
)listbox_hook_proc
);
10796 check_lb_state(listbox
, 0, LB_ERR
, 0, 0);
10798 ret
= SendMessage(listbox
, LB_ADDSTRING
, 0, (LPARAM
)"item 0");
10799 ok(ret
== 0, "expected 0, got %ld\n", ret
);
10800 ret
= SendMessage(listbox
, LB_ADDSTRING
, 0, (LPARAM
)"item 1");
10801 ok(ret
== 1, "expected 1, got %ld\n", ret
);
10802 ret
= SendMessage(listbox
, LB_ADDSTRING
, 0, (LPARAM
)"item 2");
10803 ok(ret
== 2, "expected 2, got %ld\n", ret
);
10805 check_lb_state(listbox
, 3, LB_ERR
, 0, 0);
10809 log_all_parent_messages
++;
10811 trace("selecting item 0\n");
10812 ret
= SendMessage(listbox
, LB_SETCURSEL
, 0, 0);
10813 ok(ret
== 0, "expected 0, got %ld\n", ret
);
10814 ok_sequence(wm_lb_setcursel_0
, "LB_SETCURSEL 0", FALSE
);
10815 check_lb_state(listbox
, 3, 0, 0, 0);
10818 trace("selecting item 1\n");
10819 ret
= SendMessage(listbox
, LB_SETCURSEL
, 1, 0);
10820 ok(ret
== 1, "expected 1, got %ld\n", ret
);
10821 ok_sequence(wm_lb_setcursel_1
, "LB_SETCURSEL 1", FALSE
);
10822 check_lb_state(listbox
, 3, 1, 1, 0);
10824 trace("selecting item 2\n");
10825 ret
= SendMessage(listbox
, LB_SETCURSEL
, 2, 0);
10826 ok(ret
== 2, "expected 2, got %ld\n", ret
);
10827 ok_sequence(wm_lb_setcursel_2
, "LB_SETCURSEL 2", FALSE
);
10828 check_lb_state(listbox
, 3, 2, 2, 0);
10830 trace("clicking on item 0\n");
10831 ret
= SendMessage(listbox
, WM_LBUTTONDOWN
, 0, MAKELPARAM(1, 1));
10832 ok(ret
== LB_OKAY
, "expected LB_OKAY, got %ld\n", ret
);
10833 ret
= SendMessage(listbox
, WM_LBUTTONUP
, 0, 0);
10834 ok(ret
== LB_OKAY
, "expected LB_OKAY, got %ld\n", ret
);
10835 ok_sequence(wm_lb_click_0
, "WM_LBUTTONDOWN 0", FALSE
);
10836 check_lb_state(listbox
, 3, 0, 0, 0);
10839 log_all_parent_messages
--;
10841 DestroyWindow(listbox
);
10842 DestroyWindow(parent
);
10845 /*************************** Menu test ******************************/
10846 static const struct message wm_popup_menu_1
[] =
10848 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 },
10849 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
10850 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'E', 0x20000001 },
10851 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, 'E', 0x20000001 },
10852 { WM_SYSCHAR
, sent
|wparam
|lparam
, 'e', 0x20000001 },
10853 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_KEYMENU
, 'e' },
10854 { WM_ENTERMENULOOP
, sent
|wparam
|lparam
, 0, 0 },
10855 { WM_INITMENU
, sent
|lparam
, 0, 0 },
10856 { WM_MENUSELECT
, sent
|wparam
, MAKEWPARAM(1,MF_HILITE
|MF_POPUP
) },
10857 { WM_INITMENUPOPUP
, sent
|lparam
, 0, 1 },
10858 { HCBT_CREATEWND
, hook
|optional
}, /* Win9x doesn't create a window */
10859 { WM_MENUSELECT
, sent
|wparam
, MAKEWPARAM(200,MF_HILITE
) },
10860 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'E', 0xf0000001 },
10861 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xd0000001 },
10862 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_RETURN
, 0x10000001 },
10863 { HCBT_DESTROYWND
, hook
|optional
}, /* Win9x doesn't create a window */
10864 { WM_UNINITMENUPOPUP
, sent
|lparam
, 0, 0 },
10865 { WM_MENUSELECT
, sent
|wparam
|lparam
, MAKEWPARAM(0,0xffff), 0 },
10866 { WM_EXITMENULOOP
, sent
|wparam
|lparam
, 0, 0 },
10867 { WM_MENUCOMMAND
, sent
}, /* |wparam, 200 - Win9x */
10868 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_RETURN
, 0xc0000001 },
10869 { WM_KEYUP
, sent
|wparam
|lparam
, VK_RETURN
, 0xc0000001 },
10872 static const struct message wm_popup_menu_2
[] =
10874 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 },
10875 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
10876 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'F', 0x20000001 },
10877 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, 'F', 0x20000001 },
10878 { WM_SYSCHAR
, sent
|wparam
|lparam
, 'f', 0x20000001 },
10879 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_KEYMENU
, 'f' },
10880 { WM_ENTERMENULOOP
, sent
|wparam
|lparam
, 0, 0 },
10881 { WM_INITMENU
, sent
|lparam
, 0, 0 },
10882 { WM_MENUSELECT
, sent
|wparam
, MAKEWPARAM(0,MF_HILITE
|MF_POPUP
) },
10883 { WM_INITMENUPOPUP
, sent
|lparam
, 0, 0 },
10884 { WM_MENUSELECT
, sent
|wparam
|optional
, MAKEWPARAM(0,MF_HILITE
|MF_POPUP
) }, /* Win9x */
10885 { WM_INITMENUPOPUP
, sent
|lparam
|optional
, 0, 0 }, /* Win9x */
10886 { HCBT_CREATEWND
, hook
},
10887 { WM_MENUSELECT
, sent
}, /*|wparam, MAKEWPARAM(0,MF_HILITE|MF_POPUP) - XP
10888 |wparam, MAKEWPARAM(100,MF_HILITE) - Win9x */
10889 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'F', 0xf0000001 },
10890 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xd0000001 },
10891 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_RIGHT
, 0x10000001 },
10892 { WM_INITMENUPOPUP
, sent
|lparam
|optional
, 0, 0 }, /* Win9x doesn't send it */
10893 { HCBT_CREATEWND
, hook
|optional
}, /* Win9x doesn't send it */
10894 { WM_MENUSELECT
, sent
|wparam
|optional
, MAKEWPARAM(100,MF_HILITE
) },
10895 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_RIGHT
, 0xd0000001 },
10896 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_RETURN
, 0x10000001 },
10897 { HCBT_DESTROYWND
, hook
},
10898 { WM_UNINITMENUPOPUP
, sent
|lparam
, 0, 0 },
10899 { HCBT_DESTROYWND
, hook
|optional
}, /* Win9x doesn't send it */
10900 { WM_UNINITMENUPOPUP
, sent
|lparam
, 0, 0 },
10901 { WM_MENUSELECT
, sent
|wparam
|lparam
, MAKEWPARAM(0,0xffff), 0 },
10902 { WM_EXITMENULOOP
, sent
|wparam
|lparam
, 0, 0 },
10903 { WM_MENUCOMMAND
, sent
}, /* |wparam, 100 - Win9x */
10904 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_RETURN
, 0xc0000001 },
10905 { WM_KEYUP
, sent
|wparam
|lparam
, VK_RETURN
, 0xc0000001 },
10908 static const struct message wm_popup_menu_3
[] =
10910 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 },
10911 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
10912 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'F', 0x20000001 },
10913 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, 'F', 0x20000001 },
10914 { WM_SYSCHAR
, sent
|wparam
|lparam
, 'f', 0x20000001 },
10915 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_KEYMENU
, 'f' },
10916 { WM_ENTERMENULOOP
, sent
|wparam
|lparam
, 0, 0 },
10917 { WM_INITMENU
, sent
|lparam
, 0, 0 },
10918 { WM_MENUSELECT
, sent
|wparam
, MAKEWPARAM(0,MF_HILITE
|MF_POPUP
) },
10919 { WM_INITMENUPOPUP
, sent
|lparam
, 0, 0 },
10920 { WM_MENUSELECT
, sent
|wparam
|optional
, MAKEWPARAM(0,MF_HILITE
|MF_POPUP
) }, /* Win9x */
10921 { WM_INITMENUPOPUP
, sent
|lparam
|optional
, 0, 0 }, /* Win9x */
10922 { HCBT_CREATEWND
, hook
},
10923 { WM_MENUSELECT
, sent
}, /*|wparam, MAKEWPARAM(0,MF_HILITE|MF_POPUP) - XP
10924 |wparam, MAKEWPARAM(100,MF_HILITE) - Win9x */
10925 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'F', 0xf0000001 },
10926 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xd0000001 },
10927 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_RIGHT
, 0x10000001 },
10928 { WM_INITMENUPOPUP
, sent
|lparam
|optional
, 0, 0 }, /* Win9x doesn't send it */
10929 { HCBT_CREATEWND
, hook
|optional
}, /* Win9x doesn't send it */
10930 { WM_MENUSELECT
, sent
|wparam
|optional
, MAKEWPARAM(100,MF_HILITE
) },
10931 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_RIGHT
, 0xd0000001 },
10932 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_RETURN
, 0x10000001 },
10933 { HCBT_DESTROYWND
, hook
},
10934 { WM_UNINITMENUPOPUP
, sent
|lparam
, 0, 0 },
10935 { HCBT_DESTROYWND
, hook
|optional
}, /* Win9x doesn't send it */
10936 { WM_UNINITMENUPOPUP
, sent
|lparam
, 0, 0 },
10937 { WM_MENUSELECT
, sent
|wparam
|lparam
, MAKEWPARAM(0,0xffff), 0 },
10938 { WM_EXITMENULOOP
, sent
|wparam
|lparam
, 0, 0 },
10939 { WM_COMMAND
, sent
|wparam
|lparam
, 100, 0 },
10940 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_RETURN
, 0xc0000001 },
10941 { WM_KEYUP
, sent
|wparam
|lparam
, VK_RETURN
, 0xc0000001 },
10945 static LRESULT WINAPI
parent_menu_proc(HWND hwnd
, UINT message
, WPARAM wp
, LPARAM lp
)
10947 if (message
== WM_ENTERIDLE
||
10948 message
== WM_INITMENU
||
10949 message
== WM_INITMENUPOPUP
||
10950 message
== WM_MENUSELECT
||
10951 message
== WM_PARENTNOTIFY
||
10952 message
== WM_ENTERMENULOOP
||
10953 message
== WM_EXITMENULOOP
||
10954 message
== WM_UNINITMENUPOPUP
||
10955 message
== WM_KEYDOWN
||
10956 message
== WM_KEYUP
||
10957 message
== WM_CHAR
||
10958 message
== WM_SYSKEYDOWN
||
10959 message
== WM_SYSKEYUP
||
10960 message
== WM_SYSCHAR
||
10961 message
== WM_COMMAND
||
10962 message
== WM_MENUCOMMAND
)
10964 struct message msg
;
10966 trace("parent_menu_proc: %p, %04x, %08lx, %08lx\n", hwnd
, message
, wp
, lp
);
10968 msg
.message
= message
;
10969 msg
.flags
= sent
|wparam
|lparam
;
10975 return DefWindowProcA(hwnd
, message
, wp
, lp
);
10978 static void set_menu_style(HMENU hmenu
, DWORD style
)
10983 mi
.cbSize
= sizeof(mi
);
10984 mi
.fMask
= MIM_STYLE
;
10985 mi
.dwStyle
= style
;
10986 SetLastError(0xdeadbeef);
10987 ret
= pSetMenuInfo(hmenu
, &mi
);
10988 ok(ret
, "SetMenuInfo error %u\n", GetLastError());
10991 static DWORD
get_menu_style(HMENU hmenu
)
10996 mi
.cbSize
= sizeof(mi
);
10997 mi
.fMask
= MIM_STYLE
;
10999 SetLastError(0xdeadbeef);
11000 ret
= pGetMenuInfo(hmenu
, &mi
);
11001 ok(ret
, "GetMenuInfo error %u\n", GetLastError());
11006 static void test_menu_messages(void)
11010 HMENU hmenu
, hmenu_popup
;
11014 if (!pGetMenuInfo
|| !pSetMenuInfo
)
11016 skip("GetMenuInfo and/or SetMenuInfo are not available\n");
11020 cls
.lpfnWndProc
= parent_menu_proc
;
11021 cls
.cbClsExtra
= 0;
11022 cls
.cbWndExtra
= 0;
11023 cls
.hInstance
= GetModuleHandleA(0);
11025 cls
.hCursor
= LoadCursorA(0, (LPSTR
)IDC_ARROW
);
11026 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
11027 cls
.lpszMenuName
= NULL
;
11028 cls
.lpszClassName
= "TestMenuClass";
11029 UnregisterClass(cls
.lpszClassName
, cls
.hInstance
);
11030 if (!RegisterClassA(&cls
)) assert(0);
11032 SetLastError(0xdeadbeef);
11033 hwnd
= CreateWindowExA(0, "TestMenuClass", NULL
, WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
11034 100, 100, 200, 200, 0, 0, 0, NULL
);
11035 ok(hwnd
!= 0, "LoadMenuA error %u\n", GetLastError());
11037 SetLastError(0xdeadbeef);
11038 hmenu
= LoadMenuA(GetModuleHandle(0), MAKEINTRESOURCE(1));
11039 ok(hmenu
!= 0, "LoadMenuA error %u\n", GetLastError());
11041 SetMenu(hwnd
, hmenu
);
11042 SetForegroundWindow( hwnd
);
11044 set_menu_style(hmenu
, MNS_NOTIFYBYPOS
);
11045 style
= get_menu_style(hmenu
);
11046 ok(style
== MNS_NOTIFYBYPOS
, "expected MNS_NOTIFYBYPOS, got %u\n", style
);
11048 hmenu_popup
= GetSubMenu(hmenu
, 0);
11049 ok(hmenu_popup
!= 0, "GetSubMenu returned 0 for submenu 0\n");
11050 style
= get_menu_style(hmenu_popup
);
11051 ok(style
== 0, "expected 0, got %u\n", style
);
11053 hmenu_popup
= GetSubMenu(hmenu_popup
, 0);
11054 ok(hmenu_popup
!= 0, "GetSubMenu returned 0 for submenu 0\n");
11055 style
= get_menu_style(hmenu_popup
);
11056 ok(style
== 0, "expected 0, got %u\n", style
);
11059 trace("testing a popup menu command\n");
11061 keybd_event(VK_MENU
, 0, 0, 0);
11062 keybd_event('E', 0, 0, 0);
11063 keybd_event('E', 0, KEYEVENTF_KEYUP
, 0);
11064 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
11065 keybd_event(VK_RETURN
, 0, 0, 0);
11066 keybd_event(VK_RETURN
, 0, KEYEVENTF_KEYUP
, 0);
11067 while (PeekMessage(&msg
, 0, 0, 0, PM_REMOVE
))
11069 TranslateMessage(&msg
);
11070 DispatchMessage(&msg
);
11072 ok_sequence(wm_popup_menu_1
, "popup menu command", FALSE
);
11074 /* Alt+F, Right, Enter */
11075 trace("testing submenu of a popup menu command\n");
11077 keybd_event(VK_MENU
, 0, 0, 0);
11078 keybd_event('F', 0, 0, 0);
11079 keybd_event('F', 0, KEYEVENTF_KEYUP
, 0);
11080 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
11081 keybd_event(VK_RIGHT
, 0, 0, 0);
11082 keybd_event(VK_RIGHT
, 0, KEYEVENTF_KEYUP
, 0);
11083 keybd_event(VK_RETURN
, 0, 0, 0);
11084 keybd_event(VK_RETURN
, 0, KEYEVENTF_KEYUP
, 0);
11085 while (PeekMessage(&msg
, 0, 0, 0, PM_REMOVE
))
11087 TranslateMessage(&msg
);
11088 DispatchMessage(&msg
);
11090 ok_sequence(wm_popup_menu_2
, "submenu of a popup menu command", FALSE
);
11092 set_menu_style(hmenu
, 0);
11093 style
= get_menu_style(hmenu
);
11094 ok(style
== 0, "expected 0, got %u\n", style
);
11096 hmenu_popup
= GetSubMenu(hmenu
, 0);
11097 ok(hmenu_popup
!= 0, "GetSubMenu returned 0 for submenu 0\n");
11098 set_menu_style(hmenu_popup
, MNS_NOTIFYBYPOS
);
11099 style
= get_menu_style(hmenu_popup
);
11100 ok(style
== MNS_NOTIFYBYPOS
, "expected MNS_NOTIFYBYPOS, got %u\n", style
);
11102 hmenu_popup
= GetSubMenu(hmenu_popup
, 0);
11103 ok(hmenu_popup
!= 0, "GetSubMenu returned 0 for submenu 0\n");
11104 style
= get_menu_style(hmenu_popup
);
11105 ok(style
== 0, "expected 0, got %u\n", style
);
11107 /* Alt+F, Right, Enter */
11108 trace("testing submenu of a popup menu command\n");
11110 keybd_event(VK_MENU
, 0, 0, 0);
11111 keybd_event('F', 0, 0, 0);
11112 keybd_event('F', 0, KEYEVENTF_KEYUP
, 0);
11113 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
11114 keybd_event(VK_RIGHT
, 0, 0, 0);
11115 keybd_event(VK_RIGHT
, 0, KEYEVENTF_KEYUP
, 0);
11116 keybd_event(VK_RETURN
, 0, 0, 0);
11117 keybd_event(VK_RETURN
, 0, KEYEVENTF_KEYUP
, 0);
11118 while (PeekMessage(&msg
, 0, 0, 0, PM_REMOVE
))
11120 TranslateMessage(&msg
);
11121 DispatchMessage(&msg
);
11123 ok_sequence(wm_popup_menu_3
, "submenu of a popup menu command", FALSE
);
11125 DestroyWindow(hwnd
);
11126 DestroyMenu(hmenu
);
11130 static void test_paintingloop(void)
11134 paint_loop_done
= 0;
11135 hwnd
= CreateWindowExA(0x0,"PaintLoopWindowClass",
11136 "PaintLoopWindowClass",WS_OVERLAPPEDWINDOW
,
11137 100, 100, 100, 100, 0, 0, 0, NULL
);
11138 ok(hwnd
!= 0, "PaintLoop window error %u\n", GetLastError());
11139 ShowWindow(hwnd
,SW_NORMAL
);
11142 while (!paint_loop_done
)
11145 if (PeekMessageA(&msg
, 0, 0, 0, 1))
11147 TranslateMessage(&msg
);
11148 DispatchMessage(&msg
);
11151 DestroyWindow(hwnd
);
11157 FARPROC pIsWinEventHookInstalled
= 0;/*GetProcAddress(user32, "IsWinEventHookInstalled");*/
11161 if (!RegisterWindowClasses()) assert(0);
11163 if (pSetWinEventHook
)
11165 hEvent_hook
= (HWINEVENTHOOK
)pSetWinEventHook(EVENT_MIN
, EVENT_MAX
,
11166 GetModuleHandleA(0),
11169 GetCurrentThreadId(),
11170 WINEVENT_INCONTEXT
);
11171 assert(hEvent_hook
);
11173 if (pIsWinEventHookInstalled
)
11176 for (event
= EVENT_MIN
; event
<= EVENT_MAX
; event
++)
11177 ok(pIsWinEventHookInstalled(event
), "IsWinEventHookInstalled(%u) failed\n", event
);
11181 cbt_hook_thread_id
= GetCurrentThreadId();
11182 hCBT_hook
= SetWindowsHookExA(WH_CBT
, cbt_hook_proc
, 0, GetCurrentThreadId());
11187 /* Fix message sequences before removing 4 lines below */
11189 if (pUnhookWinEvent
&& hEvent_hook
)
11191 ret
= pUnhookWinEvent(hEvent_hook
);
11192 ok( ret
, "UnhookWinEvent error %d\n", GetLastError());
11193 pUnhookWinEvent
= 0;
11199 test_PeekMessage();
11200 test_PeekMessage2();
11201 test_scrollwindowex();
11203 test_setwindowpos();
11205 invisible_parent_tests();
11206 test_mdi_messages();
11207 test_button_messages();
11208 test_static_messages();
11209 test_listbox_messages();
11210 test_combobox_messages();
11211 test_wmime_keydown_message();
11212 test_paint_messages();
11213 test_interthread_messages();
11214 test_message_conversion();
11215 test_accelerators();
11217 test_timers_no_wnd();
11219 test_DestroyWindow();
11220 test_DispatchMessage();
11221 test_SendMessageTimeout();
11222 test_edit_messages();
11223 test_quit_message();
11224 test_SetActiveWindow();
11226 if (!pTrackMouseEvent
)
11227 skip("TrackMouseEvent is not available\n");
11229 test_TrackMouseEvent();
11231 test_SetWindowRgn();
11233 test_dialog_messages();
11234 test_nullCallback();
11235 test_dbcs_wm_char();
11236 test_menu_messages();
11237 test_paintingloop();
11238 /* keep it the last test, under Windows it tends to break the tests
11239 * which rely on active/foreground windows being correct.
11241 test_SetForegroundWindow();
11243 UnhookWindowsHookEx(hCBT_hook
);
11244 if (pUnhookWinEvent
)
11246 ret
= pUnhookWinEvent(hEvent_hook
);
11247 ok( ret
, "UnhookWinEvent error %d\n", GetLastError());
11248 SetLastError(0xdeadbeef);
11249 ok(!pUnhookWinEvent(hEvent_hook
), "UnhookWinEvent succeeded\n");
11250 ok(GetLastError() == ERROR_INVALID_HANDLE
|| /* Win2k */
11251 GetLastError() == 0xdeadbeef, /* Win9x */
11252 "unexpected error %d\n", GetLastError());
11255 skip("UnhookWinEvent is not available\n");