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
23 #define _WIN32_WINNT 0x0600 /* For WM_CHANGEUISTATE,QS_RAWINPUT,WM_DWMxxxx */
24 #define WINVER 0x0600 /* for WM_GETTITLEBARINFOEX */
38 #include "wine/test.h"
40 #define MDI_FIRST_CHILD_ID 2004
42 /* undocumented SWP flags - from SDK 3.1 */
43 #define SWP_NOCLIENTSIZE 0x0800
44 #define SWP_NOCLIENTMOVE 0x1000
45 #define SWP_STATECHANGED 0x8000
47 #define SW_NORMALNA 0xCC /* undoc. flag in MinMaximize */
50 #define WM_KEYF1 0x004d
54 #define WM_SYSTIMER 0x0118
57 #define WND_PARENT_ID 1
58 #define WND_POPUP_ID 2
59 #define WND_CHILD_ID 3
61 #ifndef WM_LBTRACKPOINT
62 #define WM_LBTRACKPOINT 0x0131
67 #elif defined __x86_64__
71 #elif defined __aarch64__
77 static BOOL (WINAPI
*pActivateActCtx
)(HANDLE
,ULONG_PTR
*);
78 static HANDLE (WINAPI
*pCreateActCtxW
)(PCACTCTXW
);
79 static BOOL (WINAPI
*pDeactivateActCtx
)(DWORD
,ULONG_PTR
);
80 static BOOL (WINAPI
*pGetCurrentActCtx
)(HANDLE
*);
81 static BOOL (WINAPI
*pQueryActCtxW
)(DWORD
,HANDLE
,void*,ULONG
,void*,SIZE_T
,SIZE_T
*);
82 static void (WINAPI
*pReleaseActCtx
)(HANDLE
);
84 /* encoded DRAWITEMSTRUCT into an LPARAM */
91 UINT type
: 4; /* ODT_* flags */
92 UINT ctl_id
: 4; /* Control ID */
93 UINT item_id
: 4; /* Menu item ID */
94 UINT action
: 4; /* ODA_* flags */
95 UINT state
: 16; /* ODS_* flags */
101 static BOOL test_DestroyWindow_flag
;
102 static HWINEVENTHOOK hEvent_hook
;
103 static HHOOK hKBD_hook
;
104 static HHOOK hCBT_hook
;
105 static DWORD cbt_hook_thread_id
;
107 static const WCHAR testWindowClassW
[] =
108 { 'T','e','s','t','W','i','n','d','o','w','C','l','a','s','s','W',0 };
111 FIXME: add tests for these
112 Window Edge Styles (Win31/Win95/98 look), in order of precedence:
113 WS_EX_DLGMODALFRAME: double border, WS_CAPTION allowed
114 WS_THICKFRAME: thick border
115 WS_DLGFRAME: double border, WS_CAPTION not allowed (but possibly shown anyway)
116 WS_BORDER (default for overlapped windows): single black border
117 none (default for child (and popup?) windows): no border
135 UINT message
; /* the WM_* code */
136 msg_flags_t flags
; /* message props */
137 WPARAM wParam
; /* expected value of wParam */
138 LPARAM lParam
; /* expected value of lParam */
139 WPARAM wp_mask
; /* mask for wParam checks */
140 LPARAM lp_mask
; /* mask for lParam checks */
143 struct recvd_message
{
144 UINT message
; /* the WM_* code */
145 msg_flags_t flags
; /* message props */
146 HWND hwnd
; /* window that received the message */
147 WPARAM wParam
; /* expected value of wParam */
148 LPARAM lParam
; /* expected value of lParam */
149 int line
; /* source line where logged */
150 const char *descr
; /* description for trace output */
151 char output
[512]; /* trace output */
154 /* Empty message sequence */
155 static const struct message WmEmptySeq
[] =
159 /* CreateWindow (for overlapped window, not initially visible) (16/32) */
160 static const struct message WmCreateOverlappedSeq
[] = {
161 { HCBT_CREATEWND
, hook
},
162 { WM_GETMINMAXINFO
, sent
},
163 { WM_NCCREATE
, sent
},
164 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
165 { 0x0093, sent
|defwinproc
|optional
},
166 { 0x0094, sent
|defwinproc
|optional
},
167 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
169 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
172 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
173 * for a not visible overlapped window.
175 static const struct message WmSWP_ShowOverlappedSeq
[] = {
176 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
177 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
178 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
179 { WM_GETTEXT
, sent
|defwinproc
|optional
},
180 { WM_ERASEBKGND
, sent
|optional
},
181 { HCBT_ACTIVATE
, hook
},
182 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
183 { WM_NOTIFYFORMAT
, sent
|optional
},
184 { WM_QUERYUISTATE
, sent
|optional
},
185 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
186 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* Win9x: SWP_NOSENDCHANGING */
187 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
188 { WM_NCACTIVATE
, sent
},
189 { WM_GETTEXT
, sent
|defwinproc
|optional
},
190 { WM_ACTIVATE
, sent
|wparam
, 1 },
191 { HCBT_SETFOCUS
, hook
},
192 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
193 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
194 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
195 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
196 { WM_GETTEXT
, sent
|optional
},
197 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
198 { WM_GETTEXT
, sent
|defwinproc
|optional
},
199 { WM_ERASEBKGND
, sent
|optional
},
200 /* Win9x adds SWP_NOZORDER below */
201 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
202 { WM_GETTEXT
, sent
|optional
},
203 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
204 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
205 { WM_ERASEBKGND
, sent
|optional
},
206 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
207 { WM_SYNCPAINT
, sent
|optional
},
208 { WM_GETTITLEBARINFOEX
, sent
|optional
},
209 { WM_PAINT
, sent
|optional
},
210 { WM_NCPAINT
, sent
|beginpaint
|optional
},
211 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
212 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
215 /* SetWindowPos(SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE)
216 * for a visible overlapped window.
218 static const struct message WmSWP_HideOverlappedSeq
[] = {
219 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
220 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
221 { HCBT_ACTIVATE
, hook
|optional
},
222 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
223 { WM_ACTIVATEAPP
, sent
|wparam
|optional
, 1 },
224 { WM_NCACTIVATE
, sent
|optional
},
225 { WM_ACTIVATE
, sent
|optional
},
226 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
230 /* SetWindowPos(SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOMOVE)
231 * for a visible overlapped window.
233 static const struct message WmSWP_ResizeSeq
[] = {
234 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
},
235 { WM_GETMINMAXINFO
, sent
|defwinproc
},
236 { WM_NCCALCSIZE
, sent
|wparam
|optional
, TRUE
},
237 { WM_NCPAINT
, sent
|optional
},
238 { WM_GETTEXT
, sent
|defwinproc
|optional
},
239 { WM_ERASEBKGND
, sent
|optional
},
240 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
},
241 { WM_SIZE
, sent
|defwinproc
|optional
},
242 { WM_NCCALCSIZE
, sent
|wparam
|optional
, TRUE
},
243 { WM_NCPAINT
, sent
|optional
},
244 { WM_GETTEXT
, sent
|defwinproc
|optional
},
245 { WM_ERASEBKGND
, sent
|optional
},
246 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
247 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* XP sends a duplicate */
251 /* SetWindowPos(SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOMOVE)
252 * for a visible popup window.
254 static const struct message WmSWP_ResizePopupSeq
[] = {
255 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
},
256 { WM_GETMINMAXINFO
, sent
|defwinproc
|optional
}, /* Win9x */
257 { WM_NCCALCSIZE
, sent
|wparam
|optional
, TRUE
},
258 { WM_NCPAINT
, sent
|optional
},
259 { WM_GETTEXT
, sent
|defwinproc
|optional
},
260 { WM_ERASEBKGND
, sent
|optional
},
261 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
},
262 { WM_SIZE
, sent
|defwinproc
|wparam
|optional
, SIZE_RESTORED
},
263 { WM_NCCALCSIZE
, sent
|wparam
|optional
, TRUE
},
264 { WM_NCPAINT
, sent
|optional
},
265 { WM_GETTEXT
, sent
|defwinproc
|optional
},
266 { WM_ERASEBKGND
, sent
|optional
},
267 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
271 /* SetWindowPos(SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOSIZE)
272 * for a visible overlapped window.
274 static const struct message WmSWP_MoveSeq
[] = {
275 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOSIZE
},
276 { WM_NCPAINT
, sent
|optional
},
277 { WM_GETTEXT
, sent
|defwinproc
|optional
},
278 { WM_ERASEBKGND
, sent
|optional
},
279 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOCLIENTSIZE
},
280 { WM_MOVE
, sent
|defwinproc
|wparam
, 0 },
281 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
284 /* Resize with SetWindowPos(SWP_NOZORDER)
285 * for a visible overlapped window
286 * SWP_NOZORDER is stripped by the logging code
288 static const struct message WmSWP_ResizeNoZOrder
[] = {
289 { WM_WINDOWPOSCHANGING
, sent
|wparam
, /*SWP_NOZORDER|*/SWP_NOACTIVATE
},
290 { WM_GETMINMAXINFO
, sent
|defwinproc
},
291 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
292 { WM_NCPAINT
, sent
|optional
},
293 { WM_GETTEXT
, sent
|defwinproc
|optional
},
294 { WM_ERASEBKGND
, sent
|optional
},
295 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, /*SWP_NOZORDER|*/SWP_NOACTIVATE
, 0,
296 SWP_NOMOVE
|SWP_NOCLIENTMOVE
|SWP_NOSIZE
|SWP_NOCLIENTSIZE
},
297 { WM_MOVE
, sent
|defwinproc
|optional
},
298 { WM_SIZE
, sent
|defwinproc
|optional
},
299 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 }, /* Win9x doesn't send it */
300 { WM_NCPAINT
, sent
|optional
}, /* Win9x doesn't send it */
301 { WM_GETTEXT
, sent
|defwinproc
|optional
}, /* Win9x doesn't send it */
302 { WM_ERASEBKGND
, sent
|optional
}, /* Win9x doesn't send it */
303 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
304 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
308 /* Switch visible mdi children */
309 static const struct message WmSwitchChild
[] = {
310 /* Switch MDI child */
311 { WM_MDIACTIVATE
, sent
},/* in the MDI client */
312 { WM_WINDOWPOSCHANGING
, sent
|wparam
,SWP_NOSIZE
|SWP_NOMOVE
},/* in the 1st MDI child */
313 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
314 { WM_CHILDACTIVATE
, sent
},/* in the 1st MDI child */
315 /* Deactivate 2nd MDI child */
316 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 0 }, /* in the 2nd MDI child */
317 { WM_MDIACTIVATE
, sent
|defwinproc
}, /* in the 2nd MDI child */
318 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
319 /* Preparing for maximize and maximize the 1st MDI child */
320 { WM_GETMINMAXINFO
, sent
|defwinproc
}, /* in the 1st MDI child */
321 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_STATECHANGED
}, /* in the 1st MDI child */
322 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 }, /* in the 1st MDI child */
323 { WM_CHILDACTIVATE
, sent
|defwinproc
}, /* in the 1st MDI child */
324 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
}, /* in the 1st MDI child */
325 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
}, /* in the 1st MDI child */
326 /* Lock redraw 2nd MDI child */
327 { WM_SETREDRAW
, sent
|wparam
|defwinproc
, 0 }, /* in the 2nd MDI child */
328 { HCBT_MINMAX
, hook
|lparam
, 0, SW_NORMALNA
},
329 /* Restore 2nd MDI child */
330 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_STATECHANGED
},/* in the 2nd MDI child */
331 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 },/* in the 2nd MDI child */
332 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* in the 2nd MDI child */
333 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
}, /* in the 2nd MDI child */
334 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
}, /* in the 2nd MDI child */
335 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* in the 2nd MDI child */
336 /* Redraw 2nd MDI child */
337 { WM_SETREDRAW
, sent
|wparam
|defwinproc
, 1 },/* in the 2nd MDI child */
338 /* Redraw MDI frame */
339 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
},/* in MDI frame */
340 { WM_NCCALCSIZE
, sent
|wparam
, 1 },/* in MDI frame */
341 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
}, /* in MDI frame */
342 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* in MDI frame */
343 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* in the 1st MDI child */
344 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
}, /* in the 1st MDI child */
345 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 }, /* in the 1st MDI child */
346 { HCBT_SETFOCUS
, hook
},
347 { WM_KILLFOCUS
, sent
|defwinproc
}, /* in the 2nd MDI child */
348 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 0 },/* in the 1st MDI child */
349 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
350 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
351 { WM_SETFOCUS
, sent
},/* in the MDI client */
352 { HCBT_SETFOCUS
, hook
},
353 { WM_KILLFOCUS
, sent
},/* in the MDI client */
354 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
355 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 }, /* in the 1st MDI child */
356 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
357 { WM_SETFOCUS
, sent
|defwinproc
}, /* in the 1st MDI child */
358 { WM_MDIACTIVATE
, sent
|defwinproc
},/* in the 1st MDI child */
359 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
}, /* in the 1st MDI child */
363 /* Switch visible not maximized mdi children */
364 static const struct message WmSwitchNotMaximizedChild
[] = {
365 /* Switch not maximized MDI child */
366 { WM_MDIACTIVATE
, sent
},/* in the MDI client */
367 { WM_WINDOWPOSCHANGING
, sent
|wparam
,SWP_NOSIZE
|SWP_NOMOVE
},/* in the 2nd MDI child */
368 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
369 { WM_CHILDACTIVATE
, sent
},/* in the 2nd MDI child */
370 /* Deactivate 1st MDI child */
371 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 0 }, /* in the 1st MDI child */
372 { WM_MDIACTIVATE
, sent
|defwinproc
}, /* in the 1st MDI child */
373 /* Activate 2nd MDI child */
374 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
}, /* in the 2nd MDI child */
375 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 }, /* in the 2nd MDI child */
376 { HCBT_SETFOCUS
, hook
}, /* in the 1st MDI child */
377 { WM_KILLFOCUS
, sent
|defwinproc
}, /* in the 1st MDI child */
378 { WM_IME_SETCONTEXT
, sent
|defwinproc
|optional
}, /* in the 1st MDI child */
379 { WM_IME_SETCONTEXT
, sent
|optional
}, /* in the MDI client */
380 { WM_SETFOCUS
, sent
, 0 }, /* in the MDI client */
381 { HCBT_SETFOCUS
, hook
},
382 { WM_KILLFOCUS
, sent
}, /* in the MDI client */
383 { WM_IME_SETCONTEXT
, sent
|optional
}, /* in the MDI client */
384 { WM_IME_SETCONTEXT
, sent
|defwinproc
|optional
}, /* in the 1st MDI child */
385 { WM_SETFOCUS
, sent
|defwinproc
}, /* in the 2nd MDI child */
386 { WM_MDIACTIVATE
, sent
|defwinproc
}, /* in the 2nd MDI child */
387 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
}, /* in the 2nd MDI child */
392 /* SetWindowPos(SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|
393 SWP_NOZORDER|SWP_FRAMECHANGED)
394 * for a visible overlapped window with WS_CLIPCHILDREN style set.
396 static const struct message WmSWP_FrameChanged_clip
[] = {
397 { WM_WINDOWPOSCHANGING
, sent
|wparam
|parent
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
},
398 { WM_NCCALCSIZE
, sent
|wparam
|parent
, 1 },
399 { WM_NCPAINT
, sent
|parent
|optional
}, /* wparam != 1 */
400 { WM_GETTEXT
, sent
|parent
|defwinproc
|optional
},
401 { WM_ERASEBKGND
, sent
|parent
|optional
}, /* FIXME: remove optional once Wine is fixed */
402 { WM_NCPAINT
, sent
}, /* wparam != 1 */
403 { WM_ERASEBKGND
, sent
},
404 { WM_WINDOWPOSCHANGED
, sent
|wparam
|parent
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
405 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
409 /* SetWindowPos(SWP_NOSIZE|SWP_NOMOVE|SWP_DEFERERASE|SWP_NOACTIVATE|
410 SWP_NOZORDER|SWP_FRAMECHANGED)
411 * for a visible overlapped window.
413 static const struct message WmSWP_FrameChangedDeferErase
[] = {
414 { WM_WINDOWPOSCHANGING
, sent
|wparam
|parent
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_DEFERERASE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
},
415 { WM_NCCALCSIZE
, sent
|wparam
|parent
, 1 },
416 { WM_WINDOWPOSCHANGED
, sent
|wparam
|parent
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_DEFERERASE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
417 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
418 { WM_PAINT
, sent
|parent
|optional
},
419 { WM_NCPAINT
, sent
|beginpaint
|parent
|optional
}, /* wparam != 1 */
420 { WM_GETTEXT
, sent
|beginpaint
|parent
|defwinproc
|optional
},
422 { WM_NCPAINT
, sent
|beginpaint
}, /* wparam != 1 */
423 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
427 /* SetWindowPos(SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|
428 SWP_NOZORDER|SWP_FRAMECHANGED)
429 * for a visible overlapped window without WS_CLIPCHILDREN style set.
431 static const struct message WmSWP_FrameChanged_noclip
[] = {
432 { WM_WINDOWPOSCHANGING
, sent
|wparam
|parent
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
},
433 { WM_NCCALCSIZE
, sent
|wparam
|parent
, 1 },
434 { WM_NCPAINT
, sent
|parent
|optional
}, /* wparam != 1 */
435 { WM_GETTEXT
, sent
|parent
|defwinproc
|optional
},
436 { WM_ERASEBKGND
, sent
|parent
|optional
},
437 { WM_WINDOWPOSCHANGED
, sent
|wparam
|parent
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
438 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
440 { WM_NCPAINT
, sent
|beginpaint
}, /* wparam != 1 */
441 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
445 /* ShowWindow(SW_SHOW) for a not visible overlapped window */
446 static const struct message WmShowOverlappedSeq
[] = {
447 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
448 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
449 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
450 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
451 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
452 { WM_GETTEXT
, sent
|defwinproc
|optional
},
453 { WM_ERASEBKGND
, sent
|optional
},
454 { HCBT_ACTIVATE
, hook
|optional
},
455 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
456 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
457 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
458 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
459 { WM_ACTIVATEAPP
, sent
|wparam
|optional
, 1 },
460 { WM_NCACTIVATE
, sent
|wparam
|optional
, 1 },
461 { WM_GETTEXT
, sent
|defwinproc
|optional
},
462 { WM_ACTIVATE
, sent
|wparam
|optional
, 1 },
463 { HCBT_SETFOCUS
, hook
|optional
},
464 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
465 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
466 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
467 { WM_SETFOCUS
, sent
|wparam
|defwinproc
|optional
, 0 },
468 { WM_GETTEXT
, sent
|optional
},
469 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
470 { WM_GETTEXT
, sent
|defwinproc
|optional
},
471 { WM_ERASEBKGND
, sent
|optional
},
472 /* Win9x adds SWP_NOZORDER below */
473 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
474 { WM_NCCALCSIZE
, sent
|optional
},
475 { WM_GETTEXT
, sent
|optional
},
476 { WM_NCPAINT
, sent
|optional
},
477 { WM_ERASEBKGND
, sent
|optional
},
478 { WM_SYNCPAINT
, sent
|optional
},
479 #if 0 /* CreateWindow/ShowWindow(SW_SHOW) also generates WM_SIZE/WM_MOVE
480 * messages. Does that mean that CreateWindow doesn't set initial
481 * window dimensions for overlapped windows?
486 { WM_PAINT
, sent
|optional
},
487 { WM_NCPAINT
, sent
|beginpaint
|optional
},
490 /* ShowWindow(SW_SHOWMAXIMIZED) for a not visible overlapped window */
491 static const struct message WmShowMaxOverlappedSeq
[] = {
492 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
493 { WM_GETMINMAXINFO
, sent
},
494 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_STATECHANGED
},
495 { WM_GETMINMAXINFO
, sent
|defwinproc
},
496 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
497 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
498 { HCBT_ACTIVATE
, hook
|optional
},
499 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
500 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
501 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
502 { WM_ACTIVATEAPP
, sent
|wparam
|optional
, 1 },
503 { WM_NCACTIVATE
, sent
|wparam
|optional
, 1 },
504 { WM_GETTEXT
, sent
|defwinproc
|optional
},
505 { WM_ACTIVATE
, sent
|wparam
|optional
, 1 },
506 { HCBT_SETFOCUS
, hook
|optional
},
507 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
508 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
509 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
510 { WM_SETFOCUS
, sent
|wparam
|defwinproc
|optional
, 0 },
511 { WM_GETTEXT
, sent
|optional
},
512 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
513 { WM_GETTEXT
, sent
|defwinproc
|optional
},
514 { WM_ERASEBKGND
, sent
|optional
},
515 /* Win9x adds SWP_NOZORDER below */
516 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_STATECHANGED
},
517 { WM_MOVE
, sent
|defwinproc
},
518 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
519 { WM_GETTEXT
, sent
|optional
},
520 { WM_NCCALCSIZE
, sent
|optional
},
521 { WM_NCPAINT
, sent
|optional
},
522 { WM_ERASEBKGND
, sent
|optional
},
523 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
524 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
525 { WM_SYNCPAINT
, sent
|optional
},
526 { WM_GETTITLEBARINFOEX
, sent
|optional
},
527 { WM_PAINT
, sent
|optional
},
528 { WM_NCPAINT
, sent
|beginpaint
|optional
},
529 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
532 /* ShowWindow(SW_RESTORE) for a not visible maximized overlapped window */
533 static const struct message WmShowRestoreMaxOverlappedSeq
[] = {
534 { HCBT_MINMAX
, hook
|lparam
, 0, SW_RESTORE
},
535 { WM_GETTEXT
, sent
|optional
},
536 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
537 { WM_GETMINMAXINFO
, sent
|defwinproc
},
538 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
539 { WM_NCPAINT
, sent
|optional
},
540 { WM_GETTEXT
, sent
|defwinproc
|optional
},
541 { WM_ERASEBKGND
, sent
|optional
},
542 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
, 0, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOSIZE
|SWP_NOMOVE
},
543 { WM_MOVE
, sent
|defwinproc
|optional
},
544 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
545 { WM_NCCALCSIZE
, sent
|wparam
|optional
, TRUE
},
546 { WM_NCPAINT
, sent
|optional
},
547 { WM_ERASEBKGND
, sent
|optional
},
548 { WM_PAINT
, sent
|optional
},
549 { WM_GETTITLEBARINFOEX
, sent
|optional
},
550 { WM_NCPAINT
, sent
|beginpaint
|optional
},
551 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
554 /* ShowWindow(SW_RESTORE) for a not visible minimized overlapped window */
555 static const struct message WmShowRestoreMinOverlappedSeq
[] = {
556 { HCBT_MINMAX
, hook
|lparam
, 0, SW_RESTORE
},
557 { WM_QUERYOPEN
, sent
|optional
},
558 { WM_GETTEXT
, sent
|optional
},
559 { WM_NCACTIVATE
, sent
|wparam
|optional
, 1 },
560 { WM_WINDOWPOSCHANGING
, sent
|optional
}, /* SWP_NOSIZE|SWP_NOMOVE */
561 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
562 { WM_NCCALCSIZE
, sent
|wparam
|optional
, TRUE
},
563 { WM_MOVE
, sent
|optional
},
564 { WM_SIZE
, sent
|wparam
|optional
, SIZE_RESTORED
},
565 { WM_GETTEXT
, sent
|optional
},
566 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_FRAMECHANGED
|SWP_STATECHANGED
|SWP_NOCOPYBITS
},
567 { WM_GETMINMAXINFO
, sent
|defwinproc
|optional
},
568 { WM_NCCALCSIZE
, sent
|wparam
|optional
, TRUE
},
569 { HCBT_ACTIVATE
, hook
|optional
},
570 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
571 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
572 { WM_ACTIVATEAPP
, sent
|wparam
|optional
, 1 },
573 { WM_NCACTIVATE
, sent
|wparam
|optional
, 1 },
574 { WM_GETTEXT
, sent
|defwinproc
|optional
},
575 { WM_ACTIVATE
, sent
|wparam
|optional
, 1 },
576 { HCBT_SETFOCUS
, hook
|optional
},
577 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
578 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
579 { WM_SETFOCUS
, sent
|wparam
|defwinproc
|optional
, 0 },
580 { WM_GETTEXT
, sent
|optional
},
581 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
582 { WM_GETTEXT
, sent
|defwinproc
|optional
},
583 { WM_ERASEBKGND
, sent
},
584 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_STATECHANGED
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
},
585 { WM_MOVE
, sent
|defwinproc
},
586 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
587 { HCBT_SETFOCUS
, hook
|optional
},
588 { WM_SETFOCUS
, sent
|wparam
|optional
, 0 },
589 { WM_NCCALCSIZE
, sent
|wparam
|optional
, TRUE
},
590 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
591 { WM_ERASEBKGND
, sent
|optional
},
592 { HCBT_SETFOCUS
, hook
|optional
},
593 { WM_SETFOCUS
, sent
|wparam
|optional
, 0 },
594 { WM_ACTIVATE
, sent
|wparam
, 1 },
595 { WM_GETTEXT
, sent
|optional
},
596 { WM_PAINT
, sent
|optional
},
597 { WM_GETTITLEBARINFOEX
, sent
|optional
},
598 { WM_NCPAINT
, sent
|beginpaint
|optional
},
599 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
602 /* ShowWindow(SW_SHOWMINIMIZED) for a not visible overlapped window */
603 static const struct message WmShowMinOverlappedSeq
[] = {
604 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
605 { HCBT_SETFOCUS
, hook
|optional
},
606 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
607 { WM_KILLFOCUS
, sent
|optional
},
608 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
609 { WM_IME_NOTIFY
, sent
|wparam
|optional
|defwinproc
, 1 },
610 { WM_GETTEXT
, sent
|optional
},
611 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOCOPYBITS
|SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_STATECHANGED
},
612 { WM_GETMINMAXINFO
, sent
|defwinproc
},
613 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
614 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
615 { WM_NCPAINT
, sent
|optional
},
616 { WM_GETTEXT
, sent
|defwinproc
|optional
},
617 { WM_WINDOWPOSCHANGED
, sent
},
618 { WM_MOVE
, sent
|defwinproc
},
619 { WM_SIZE
, sent
|defwinproc
|wparam
|lparam
, SIZE_MINIMIZED
, 0 },
620 { WM_NCCALCSIZE
, sent
|optional
},
621 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
622 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
623 { EVENT_SYSTEM_MINIMIZESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
624 { WM_NCACTIVATE
, sent
|wparam
|optional
, 0 },
625 { WM_GETTEXT
, sent
|defwinproc
|optional
},
626 { WM_ACTIVATE
, sent
|optional
},
627 { WM_ACTIVATEAPP
, sent
|wparam
|optional
, 0 },
629 /* Vista sometimes restores the window right away... */
630 { WM_SYSCOMMAND
, sent
|optional
|wparam
, SC_RESTORE
},
631 { HCBT_SYSCOMMAND
, hook
|optional
|wparam
, SC_RESTORE
},
632 { HCBT_MINMAX
, hook
|optional
|lparam
, 0, SW_RESTORE
},
633 { WM_QUERYOPEN
, sent
|optional
},
634 { WM_WINDOWPOSCHANGING
, sent
|optional
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
635 { WM_GETMINMAXINFO
, sent
|optional
|defwinproc
},
636 { WM_NCCALCSIZE
, sent
|optional
|wparam
, TRUE
},
637 { HCBT_ACTIVATE
, hook
|optional
},
638 { WM_ACTIVATEAPP
, sent
|optional
|wparam
, 1 },
639 { WM_NCACTIVATE
, sent
|optional
},
640 { WM_GETTEXT
, sent
|optional
},
641 { WM_ACTIVATE
, sent
|optional
|wparam
, 1 },
642 { HCBT_SETFOCUS
, hook
|optional
},
643 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
644 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
645 { WM_SETFOCUS
, sent
|optional
},
646 { WM_NCPAINT
, sent
|optional
},
647 { WM_GETTEXT
, sent
|defwinproc
|optional
},
648 { WM_ERASEBKGND
, sent
|optional
},
649 { WM_WINDOWPOSCHANGED
, sent
|optional
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
650 { WM_MOVE
, sent
|defwinproc
|optional
},
651 { WM_SIZE
, sent
|defwinproc
|optional
|wparam
, SIZE_RESTORED
},
652 { WM_ACTIVATE
, sent
|optional
|wparam
, 1 },
653 { WM_SYSCOMMAND
, sent
|optional
|wparam
, SC_RESTORE
},
654 { HCBT_SYSCOMMAND
, hook
|optional
|wparam
, SC_RESTORE
},
656 { WM_PAINT
, sent
|optional
},
657 { WM_NCPAINT
, sent
|beginpaint
|optional
},
658 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
661 /* ShowWindow(SW_HIDE) for a visible overlapped window */
662 static const struct message WmHideOverlappedSeq
[] = {
663 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
664 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
665 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
666 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
667 { WM_SIZE
, sent
|optional
}, /* XP doesn't send it */
668 { WM_MOVE
, sent
|optional
}, /* XP doesn't send it */
669 { WM_NCACTIVATE
, sent
|wparam
|optional
, 0 },
670 { WM_ACTIVATE
, sent
|wparam
|optional
, 0 },
671 { WM_ACTIVATEAPP
, sent
|wparam
|optional
, 0 },
672 { HCBT_SETFOCUS
, hook
|optional
},
673 { WM_KILLFOCUS
, sent
|wparam
|optional
, 0 },
674 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
675 { WM_IME_NOTIFY
, sent
|wparam
|optional
|defwinproc
, 1 },
678 /* DestroyWindow for a visible overlapped window */
679 static const struct message WmDestroyOverlappedSeq
[] = {
680 { HCBT_DESTROYWND
, hook
},
681 { 0x0090, sent
|optional
},
682 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
683 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
684 { 0x0090, sent
|optional
},
685 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
686 { WM_NCACTIVATE
, sent
|optional
|wparam
, 0 },
687 { WM_ACTIVATE
, sent
|optional
},
688 { WM_ACTIVATEAPP
, sent
|optional
|wparam
, 0 },
689 { WM_KILLFOCUS
, sent
|optional
|wparam
, 0 },
690 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
691 { WM_IME_NOTIFY
, sent
|wparam
|optional
|defwinproc
, 1 },
692 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
693 { WM_DESTROY
, sent
},
694 { WM_NCDESTROY
, sent
},
697 /* CreateWindow(WS_MAXIMIZE|WS_VISIBLE) for popup window */
698 static const struct message WmCreateMaxPopupSeq
[] = {
699 { HCBT_CREATEWND
, hook
},
700 { WM_NCCREATE
, sent
},
701 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
703 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
704 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
706 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
707 { WM_GETMINMAXINFO
, sent
},
708 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_STATECHANGED
},
709 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
710 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOREDRAW
|SWP_STATECHANGED
},
711 { WM_MOVE
, sent
|defwinproc
},
712 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
713 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
714 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
715 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
716 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
717 { HCBT_ACTIVATE
, hook
},
718 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
719 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
720 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
721 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
722 { WM_ERASEBKGND
, sent
|optional
},
723 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOCLIENTMOVE
|SWP_NOCLIENTSIZE
|SWP_NOMOVE
|SWP_NOSIZE
},
724 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
725 { WM_NCACTIVATE
, sent
},
726 { WM_ACTIVATE
, sent
|wparam
, 1 },
727 { HCBT_SETFOCUS
, hook
},
728 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
729 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
730 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
731 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
732 { WM_GETTEXT
, sent
|optional
},
733 { WM_SYNCPAINT
, sent
|wparam
|optional
, 4 },
734 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
735 { WM_ERASEBKGND
, sent
|optional
},
736 { WM_NCPAINT
, sent
|wparam
|defwinproc
|optional
, 1 },
737 { WM_ERASEBKGND
, sent
|defwinproc
|optional
},
738 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOCLIENTMOVE
|SWP_NOCLIENTSIZE
|SWP_SHOWWINDOW
|SWP_NOMOVE
|SWP_NOSIZE
},
741 /* CreateWindow(WS_MAXIMIZE) for popup window, not initially visible */
742 static const struct message WmCreateInvisibleMaxPopupSeq
[] = {
743 { HCBT_CREATEWND
, hook
},
744 { WM_NCCREATE
, sent
},
745 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
747 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
748 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
750 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
751 { WM_GETMINMAXINFO
, sent
},
752 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_STATECHANGED
},
753 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
754 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOREDRAW
|SWP_STATECHANGED
},
755 { WM_MOVE
, sent
|defwinproc
},
756 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
757 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
760 /* ShowWindow(SW_SHOWMAXIMIZED) for a resized not visible popup window */
761 static const struct message WmShowMaxPopupResizedSeq_todo
[] = {
762 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
763 { WM_GETMINMAXINFO
, sent
},
764 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
},
765 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
766 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
767 { HCBT_ACTIVATE
, hook
},
768 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
769 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
770 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
771 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
772 { WM_ERASEBKGND
, sent
|optional
},
773 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
774 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
775 { WM_NCACTIVATE
, sent
},
776 { WM_ACTIVATE
, sent
|wparam
, 1 },
777 { HCBT_SETFOCUS
, hook
},
778 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
779 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
780 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
781 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
782 { WM_GETTEXT
, sent
|optional
},
783 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
784 { WM_ERASEBKGND
, sent
|optional
},
785 { WM_WINDOWPOSCHANGED
, sent
},
786 /* WinNT4.0 sends WM_MOVE */
787 { WM_MOVE
, sent
|defwinproc
|optional
},
788 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
789 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
792 static const struct message WmShowMaxPopupResizedSeq
[] = {
793 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
794 { WM_GETMINMAXINFO
, sent
},
795 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
},
796 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
797 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
798 { HCBT_ACTIVATE
, hook
},
799 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
800 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
801 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
802 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
803 { WM_ERASEBKGND
, sent
|optional
},
804 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
805 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
806 { WM_NCACTIVATE
, sent
},
807 { WM_ACTIVATE
, sent
|wparam
, 1 },
808 { HCBT_SETFOCUS
, hook
},
809 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
810 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
811 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
812 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
813 { WM_GETTEXT
, sent
|optional
},
814 { WM_NCPAINT
, sent
|optional
}, /* We'll check WM_NCPAINT behaviour in another test */
815 { WM_ERASEBKGND
, sent
|optional
},
816 { WM_WINDOWPOSCHANGED
, sent
},
817 /* WinNT4.0 sends WM_MOVE */
818 { WM_MOVE
, sent
|defwinproc
|optional
},
819 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
820 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
823 /* ShowWindow(SW_SHOWMAXIMIZED) for a not visible popup window */
824 static const struct message WmShowMaxPopupSeq
[] = {
825 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
826 { WM_GETMINMAXINFO
, sent
},
827 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
},
828 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
829 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
830 { HCBT_ACTIVATE
, hook
},
831 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
832 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
833 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
834 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
835 { WM_ERASEBKGND
, sent
|optional
},
836 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOMOVE
|SWP_NOSIZE
},
837 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
838 { WM_NCACTIVATE
, sent
},
839 { WM_ACTIVATE
, sent
|wparam
, 1 },
840 { HCBT_SETFOCUS
, hook
},
841 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
842 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
843 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
844 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
845 { WM_GETTEXT
, sent
|optional
},
846 { WM_SYNCPAINT
, sent
|wparam
|optional
, 4 },
847 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
848 { WM_ERASEBKGND
, sent
|optional
},
849 { WM_NCPAINT
, sent
|wparam
|defwinproc
|optional
, 1 },
850 { WM_ERASEBKGND
, sent
|defwinproc
|optional
},
851 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOMOVE
|SWP_NOSIZE
},
852 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
855 /* CreateWindow(WS_VISIBLE) for popup window */
856 static const struct message WmCreatePopupSeq
[] = {
857 { HCBT_CREATEWND
, hook
},
858 { WM_NCCREATE
, sent
},
859 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
861 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
862 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
864 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
865 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
866 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
867 { HCBT_ACTIVATE
, hook
},
868 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
869 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
870 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
871 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
872 { WM_ERASEBKGND
, sent
|optional
},
873 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
874 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
875 { WM_NCACTIVATE
, sent
},
876 { WM_ACTIVATE
, sent
|wparam
, 1 },
877 { HCBT_SETFOCUS
, hook
},
878 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
879 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
880 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
881 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
882 { WM_GETTEXT
, sent
|optional
},
883 { WM_SYNCPAINT
, sent
|wparam
|optional
, 4 },
884 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
885 { WM_ERASEBKGND
, sent
|optional
},
886 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOCLIENTMOVE
|SWP_NOCLIENTSIZE
|SWP_SHOWWINDOW
|SWP_NOMOVE
|SWP_NOSIZE
},
889 /* ShowWindow(SW_SHOWMAXIMIZED) for a visible popup window */
890 static const struct message WmShowVisMaxPopupSeq
[] = {
891 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
892 { WM_GETMINMAXINFO
, sent
},
893 { WM_GETTEXT
, sent
|optional
},
894 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
895 { WM_GETTEXT
, sent
|optional
},
896 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
897 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
898 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
899 { WM_ERASEBKGND
, sent
|optional
},
900 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
901 { WM_MOVE
, sent
|defwinproc
},
902 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
903 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
906 /* CreateWindow (for a child popup window, not initially visible) */
907 static const struct message WmCreateChildPopupSeq
[] = {
908 { HCBT_CREATEWND
, hook
},
909 { WM_NCCREATE
, sent
},
910 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
912 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
913 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
917 /* CreateWindow (for a popup window, not initially visible,
918 * which sets WS_VISIBLE in WM_CREATE handler)
920 static const struct message WmCreateInvisiblePopupSeq
[] = {
921 { HCBT_CREATEWND
, hook
},
922 { WM_NCCREATE
, sent
},
923 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
925 { WM_STYLECHANGING
, sent
},
926 { WM_STYLECHANGED
, sent
},
927 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
928 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
932 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER)
933 * for a popup window with WS_VISIBLE style set
935 static const struct message WmShowVisiblePopupSeq_2
[] = {
936 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
939 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
940 * for a popup window with WS_VISIBLE style set
942 static const struct message WmShowVisiblePopupSeq_3
[] = {
943 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
944 { HCBT_ACTIVATE
, hook
},
945 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
946 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
947 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
948 { WM_NCACTIVATE
, sent
},
949 { WM_ACTIVATE
, sent
|wparam
, 1 },
950 { HCBT_SETFOCUS
, hook
},
951 { WM_KILLFOCUS
, sent
|parent
},
952 { WM_IME_SETCONTEXT
, sent
|parent
|wparam
|optional
, 0 },
953 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
954 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
955 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
956 { WM_SETFOCUS
, sent
|defwinproc
},
957 { WM_GETTEXT
, sent
|optional
},
958 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
, 0, SWP_SHOWWINDOW
},
961 /* CreateWindow (for a popup window with WS_VISIBLE style set and extreme location)
963 static const struct message WmShowPopupExtremeLocationSeq
[] = {
964 { HCBT_CREATEWND
, hook
},
965 { WM_NCCREATE
, sent
},
966 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
968 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
969 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
971 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
972 { WM_WINDOWPOSCHANGING
, sent
},
973 { HCBT_ACTIVATE
, hook
},
974 { WM_WINDOWPOSCHANGING
, sent
|optional
},
975 { WM_QUERYNEWPALETTE
, sent
|optional
},
976 { WM_ACTIVATEAPP
, sent
},
977 { WM_NCACTIVATE
, sent
},
978 { WM_ACTIVATE
, sent
},
979 { WM_IME_SETCONTEXT
, sent
|parent
|wparam
|optional
, 0 },
980 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
981 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
982 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
983 { HCBT_SETFOCUS
, hook
},
984 { WM_SETFOCUS
, sent
|defwinproc
},
985 { WM_NCPAINT
, sent
|wparam
, 1 },
986 { WM_ERASEBKGND
, sent
},
987 { WM_WINDOWPOSCHANGED
, sent
},
988 /* occasionally received on test machines */
989 { WM_NCPAINT
, sent
|optional
},
990 { WM_ERASEBKGND
, sent
|optional
},
993 /* CreateWindow (for a popup window with WS_VISIBLE style set)
995 static const struct message WmShowPopupFirstDrawSeq_1
[] = {
996 { HCBT_CREATEWND
, hook
},
997 { WM_NCCREATE
, sent
},
998 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
1000 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1001 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
1003 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1004 { WM_WINDOWPOSCHANGING
, sent
},
1005 { HCBT_ACTIVATE
, hook
},
1006 { WM_WINDOWPOSCHANGING
, sent
|optional
},
1007 { WM_QUERYNEWPALETTE
, sent
|optional
},
1008 { WM_ACTIVATEAPP
, sent
},
1009 { WM_NCACTIVATE
, sent
},
1010 { WM_ACTIVATE
, sent
},
1011 { WM_IME_SETCONTEXT
, sent
|parent
|wparam
|optional
, 0 },
1012 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
1013 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
1014 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1015 { HCBT_SETFOCUS
, hook
},
1016 { WM_SETFOCUS
, sent
|defwinproc
},
1017 { WM_NCPAINT
, sent
|wparam
, 1 },
1018 { WM_ERASEBKGND
, sent
},
1019 { WM_WINDOWPOSCHANGED
, sent
},
1021 /* occasionally received on test machines */
1022 { WM_NCPAINT
, sent
|beginpaint
|optional
},
1023 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
1026 /* CreateWindow (for a popup window that is shown with ShowWindow(SW_SHOWMAXIMIZED))
1028 static const struct message WmShowPopupFirstDrawSeq_2
[] = {
1029 { HCBT_CREATEWND
, hook
},
1030 { WM_NCCREATE
, sent
},
1031 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
1032 { WM_CREATE
, sent
},
1033 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1034 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
1036 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
1037 { WM_GETMINMAXINFO
, sent
},
1038 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_STATECHANGED
|SWP_SHOWWINDOW
|SWP_FRAMECHANGED
},
1039 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
1040 { HCBT_ACTIVATE
, hook
},
1041 { WM_WINDOWPOSCHANGING
, sent
|optional
},
1042 { WM_NCPAINT
, sent
|optional
|wparam
, 1 },
1043 { WM_ERASEBKGND
, sent
|optional
},
1044 { WM_WINDOWPOSCHANGED
, sent
|optional
},
1045 { WM_QUERYNEWPALETTE
, sent
|optional
},
1046 { WM_ACTIVATEAPP
, sent
},
1047 { WM_NCACTIVATE
, sent
},
1048 { WM_ACTIVATE
, sent
},
1049 { WM_IME_SETCONTEXT
, sent
|parent
|wparam
|optional
, 0 },
1050 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
1051 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
1052 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1053 { HCBT_SETFOCUS
, hook
},
1054 { WM_SETFOCUS
, sent
|defwinproc
},
1055 { WM_NCPAINT
, sent
|wparam
, 1 },
1056 { WM_ERASEBKGND
, sent
},
1057 { WM_WINDOWPOSCHANGED
, sent
|optional
},
1058 { WM_MOVE
, sent
|defwinproc
},
1059 { WM_SIZE
, sent
|defwinproc
, 0 },
1061 /* occasionally received on test machines */
1062 { WM_NCPAINT
, sent
|beginpaint
|optional
},
1063 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
1066 static const struct message WmFirstDrawSetWindowPosSeq1
[] = {
1067 { HCBT_CREATEWND
, hook
},
1068 { WM_NCCREATE
, sent
},
1069 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
1070 { WM_CREATE
, sent
},
1071 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1072 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
1074 { WM_WINDOWPOSCHANGING
, sent
},
1075 { HCBT_ACTIVATE
, hook
},
1076 { WM_WINDOWPOSCHANGING
, sent
|optional
},
1077 { WM_QUERYNEWPALETTE
, sent
|optional
},
1078 { WM_ACTIVATEAPP
, sent
},
1079 { WM_NCACTIVATE
, sent
},
1080 { WM_ACTIVATE
, sent
},
1081 { WM_IME_SETCONTEXT
, sent
|parent
|wparam
|optional
, 0 },
1082 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
1083 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
1084 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1085 { HCBT_SETFOCUS
, hook
},
1086 { WM_SETFOCUS
, sent
|defwinproc
},
1087 { WM_NCPAINT
, sent
|wparam
, 1 },
1088 { WM_ERASEBKGND
, sent
},
1089 { WM_WINDOWPOSCHANGED
, sent
},
1090 { WM_MOVE
, sent
|defwinproc
},
1093 static const struct message WmFirstDrawSetWindowPosSeq2
[] = {
1094 { HCBT_CREATEWND
, hook
},
1095 { WM_NCCREATE
, sent
},
1096 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
1097 { WM_CREATE
, sent
},
1098 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1099 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
1101 { WM_WINDOWPOSCHANGING
, sent
},
1102 { HCBT_ACTIVATE
, hook
},
1103 { WM_QUERYNEWPALETTE
, sent
|optional
},
1104 { WM_WINDOWPOSCHANGING
, sent
|optional
},
1105 { WM_ACTIVATEAPP
, sent
},
1106 { WM_NCACTIVATE
, sent
},
1107 { WM_ACTIVATE
, sent
},
1108 { WM_IME_SETCONTEXT
, sent
|parent
|wparam
|optional
, 0 },
1109 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
1110 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
1111 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1112 { HCBT_SETFOCUS
, hook
},
1113 { WM_SETFOCUS
, sent
|defwinproc
},
1114 { WM_WINDOWPOSCHANGED
, sent
},
1115 { WM_MOVE
, sent
|defwinproc
},
1118 static const struct message WmFirstDrawSetWindowPosSeq3
[] = {
1119 { HCBT_CREATEWND
, hook
},
1120 { WM_NCCREATE
, sent
},
1121 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
1122 { WM_CREATE
, sent
},
1123 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1124 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
1126 { HCBT_ACTIVATE
, hook
|optional
},
1127 /* Probably shouldn't happen, but not part of this test */
1128 { WM_QUERYNEWPALETTE
, sent
|optional
},
1129 { WM_ACTIVATEAPP
, sent
|optional
},
1130 { WM_NCACTIVATE
, sent
|optional
},
1131 { WM_ACTIVATE
, sent
|optional
},
1132 { HCBT_SETFOCUS
, hook
|optional
},
1133 { WM_SETFOCUS
, sent
|defwinproc
|optional
},
1136 static const struct message WmFirstDrawSetWindowPosSeq4
[] = {
1137 { HCBT_CREATEWND
, hook
},
1138 { WM_NCCREATE
, sent
},
1139 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
1140 { WM_CREATE
, sent
},
1141 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1142 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
1144 { WM_WINDOWPOSCHANGING
, sent
},
1145 { HCBT_ACTIVATE
, hook
},
1146 { WM_WINDOWPOSCHANGING
, sent
|optional
},
1147 { WM_QUERYNEWPALETTE
, sent
|optional
},
1148 { WM_ACTIVATEAPP
, sent
},
1149 { WM_NCACTIVATE
, sent
},
1150 { WM_ACTIVATE
, sent
},
1151 { WM_IME_SETCONTEXT
, sent
|parent
|wparam
|optional
, 0 },
1152 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
1153 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
1154 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1155 { HCBT_SETFOCUS
, hook
},
1156 { WM_SETFOCUS
, sent
|defwinproc
},
1157 { WM_NCPAINT
, sent
|wparam
, 1 },
1158 { WM_ERASEBKGND
, sent
},
1159 { WM_WINDOWPOSCHANGED
, sent
},
1162 static const struct message WmFirstDrawSetWindowPosSeq5
[] = {
1163 { HCBT_CREATEWND
, hook
},
1164 { WM_NCCREATE
, sent
},
1165 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
1166 { WM_CREATE
, sent
},
1167 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1168 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
1170 { WM_WINDOWPOSCHANGING
, sent
},
1171 { HCBT_ACTIVATE
, hook
},
1172 { WM_WINDOWPOSCHANGING
, sent
|optional
},
1173 { WM_QUERYNEWPALETTE
, sent
|optional
},
1174 { WM_ACTIVATEAPP
, sent
},
1175 { WM_NCACTIVATE
, sent
},
1176 { WM_ACTIVATE
, sent
},
1177 { WM_IME_SETCONTEXT
, sent
|parent
|wparam
|optional
, 0 },
1178 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
1179 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
1180 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1181 { HCBT_SETFOCUS
, hook
},
1182 { WM_SETFOCUS
, sent
|defwinproc
},
1183 { WM_WINDOWPOSCHANGED
, sent
},
1186 static const struct message WmFirstDrawChildSeq1
[] = {
1189 static const struct message WmFirstDrawChildSeq2
[] = {
1190 { WM_NCPAINT
, sent
|wparam
, 1 },
1191 { WM_ERASEBKGND
, sent
},
1192 /* occasionally received on test machines */
1193 { WM_NCPAINT
, sent
|optional
},
1194 { WM_ERASEBKGND
, sent
|optional
},
1197 /* CreateWindow (for child window, not initially visible) */
1198 static const struct message WmCreateChildSeq
[] = {
1199 { HCBT_CREATEWND
, hook
},
1200 { WM_NCCREATE
, sent
},
1201 /* child is inserted into parent's child list after WM_NCCREATE returns */
1202 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
1203 { WM_CREATE
, sent
},
1204 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1205 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
1207 { WM_PARENTNOTIFY
, sent
|parent
|wparam
, WM_CREATE
},
1210 /* CreateWindow (for maximized child window, not initially visible) */
1211 static const struct message WmCreateMaximizedChildSeq
[] = {
1212 { HCBT_CREATEWND
, hook
},
1213 { WM_NCCREATE
, sent
},
1214 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
1215 { WM_CREATE
, sent
},
1216 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1217 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
1219 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
1220 { WM_GETMINMAXINFO
, sent
},
1221 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_STATECHANGED
},
1222 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1223 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
1224 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
1225 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1226 { WM_PARENTNOTIFY
, sent
|parent
|wparam
, WM_CREATE
},
1229 /* CreateWindow (for a child window, initially visible) */
1230 static const struct message WmCreateVisibleChildSeq
[] = {
1231 { HCBT_CREATEWND
, hook
},
1232 { WM_NCCREATE
, sent
},
1233 /* child is inserted into parent's child list after WM_NCCREATE returns */
1234 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
1235 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
1236 { WM_CREATE
, sent
},
1237 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1238 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
1240 { WM_PARENTNOTIFY
, sent
|parent
|wparam
, WM_CREATE
},
1241 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1242 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
1243 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1244 { WM_ERASEBKGND
, sent
|parent
|optional
},
1245 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1246 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 }, /* WinXP */
1247 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1250 /* ShowWindow(SW_SHOW) for a not visible child window */
1251 static const struct message WmShowChildSeq
[] = {
1252 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1253 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1254 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1255 { WM_ERASEBKGND
, sent
|parent
|optional
},
1256 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1259 /* ShowWindow(SW_HIDE) for a visible child window */
1260 static const struct message WmHideChildSeq
[] = {
1261 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
1262 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1263 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1264 { WM_ERASEBKGND
, sent
|parent
|optional
},
1265 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1268 /* ShowWindow(SW_HIDE) for a visible child window checking all parent events*/
1269 static const struct message WmHideChildSeq2
[] = {
1270 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
1271 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1272 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1273 { WM_ERASEBKGND
, sent
|parent
|optional
},
1274 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1277 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
1278 * for a not visible child window
1280 static const struct message WmShowChildSeq_2
[] = {
1281 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
1282 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1283 { WM_CHILDACTIVATE
, sent
},
1284 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1287 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE)
1288 * for a not visible child window
1290 static const struct message WmShowChildSeq_3
[] = {
1291 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
1292 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1293 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1296 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
1297 * for a visible child window with a caption
1299 static const struct message WmShowChildSeq_4
[] = {
1300 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
1301 { WM_CHILDACTIVATE
, sent
},
1304 /* ShowWindow(SW_MINIMIZE) for child with invisible parent */
1305 static const struct message WmShowChildInvisibleParentSeq_1
[] = {
1306 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
1307 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
, 0, SWP_NOACTIVATE
},
1308 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1309 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1310 { WM_CHILDACTIVATE
, sent
|optional
},
1311 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOREDRAW
|SWP_NOCOPYBITS
|SWP_STATECHANGED
, 0, SWP_NOACTIVATE
},
1312 { WM_MOVE
, sent
|defwinproc
},
1313 { WM_SIZE
, sent
|defwinproc
|wparam
|lparam
, SIZE_MINIMIZED
, 0 },
1314 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1315 { EVENT_SYSTEM_MINIMIZESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
1316 /* FIXME: Wine creates an icon/title window while Windows doesn't */
1317 { WM_PARENTNOTIFY
, sent
|parent
|wparam
|optional
, WM_CREATE
},
1318 { WM_GETTEXT
, sent
|optional
},
1321 /* repeated ShowWindow(SW_MINIMIZE) for child with invisible parent */
1322 static const struct message WmShowChildInvisibleParentSeq_1r
[] = {
1323 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
1326 /* ShowWindow(SW_MAXIMIZE) for child with invisible parent */
1327 static const struct message WmShowChildInvisibleParentSeq_2
[] = {
1328 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
1329 { WM_GETMINMAXINFO
, sent
},
1330 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_STATECHANGED
},
1331 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1332 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1333 { WM_CHILDACTIVATE
, sent
},
1334 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
1335 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
1336 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1339 /* repeated ShowWindow(SW_MAXIMIZE) for child with invisible parent */
1340 static const struct message WmShowChildInvisibleParentSeq_2r
[] = {
1341 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
1344 /* ShowWindow(SW_SHOWMINIMIZED) for child with invisible parent */
1345 static const struct message WmShowChildInvisibleParentSeq_3
[] = {
1346 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINIMIZED
},
1347 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
1348 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1349 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1350 { WM_CHILDACTIVATE
, sent
},
1351 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOREDRAW
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
1352 { WM_MOVE
, sent
|defwinproc
},
1353 { WM_SIZE
, sent
|defwinproc
|wparam
|lparam
, SIZE_MINIMIZED
, 0 },
1354 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1355 { EVENT_SYSTEM_MINIMIZESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
1356 /* FIXME: Wine creates an icon/title window while Windows doesn't */
1357 { WM_PARENTNOTIFY
, sent
|parent
|wparam
|optional
, WM_CREATE
},
1358 { WM_GETTEXT
, sent
|optional
},
1361 /* repeated ShowWindow(SW_SHOWMINIMIZED) for child with invisible parent */
1362 static const struct message WmShowChildInvisibleParentSeq_3r
[] = {
1363 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINIMIZED
},
1366 /* ShowWindow(SW_SHOWMINNOACTIVE) for child with invisible parent */
1367 static const struct message WmShowChildInvisibleParentSeq_4
[] = {
1368 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINNOACTIVE
},
1369 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
1370 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1371 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1372 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOREDRAW
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
1373 { WM_MOVE
, sent
|defwinproc
},
1374 { WM_SIZE
, sent
|defwinproc
|wparam
|lparam
, SIZE_MINIMIZED
, 0 },
1375 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1376 { EVENT_SYSTEM_MINIMIZESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
1377 /* FIXME: Wine creates an icon/title window while Windows doesn't */
1378 { WM_PARENTNOTIFY
, sent
|parent
|wparam
|optional
, WM_CREATE
},
1379 { WM_GETTEXT
, sent
|optional
},
1382 /* repeated ShowWindow(SW_SHOWMINNOACTIVE) for child with invisible parent */
1383 static const struct message WmShowChildInvisibleParentSeq_4r
[] = {
1384 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINNOACTIVE
},
1387 /* ShowWindow(SW_SHOW) for child with invisible parent */
1388 static const struct message WmShowChildInvisibleParentSeq_5
[] = {
1389 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1392 /* ShowWindow(SW_HIDE) for child with invisible parent */
1393 static const struct message WmHideChildInvisibleParentSeq
[] = {
1394 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
1397 /* SetWindowPos(SWP_SHOWWINDOW) for child with invisible parent */
1398 static const struct message WmShowChildInvisibleParentSeq_6
[] = {
1399 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
1400 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1401 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1404 /* SetWindowPos(SWP_HIDEWINDOW) for child with invisible parent */
1405 static const struct message WmHideChildInvisibleParentSeq_2
[] = {
1406 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1407 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1408 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1411 /* DestroyWindow for a visible child window */
1412 static const struct message WmDestroyChildSeq
[] = {
1413 { HCBT_DESTROYWND
, hook
},
1414 { 0x0090, sent
|optional
},
1415 { WM_PARENTNOTIFY
, sent
|parent
|wparam
, WM_DESTROY
},
1416 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
1417 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1418 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1419 { WM_ERASEBKGND
, sent
|parent
|optional
},
1420 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1421 { HCBT_SETFOCUS
, hook
}, /* set focus to a parent */
1422 { WM_KILLFOCUS
, sent
},
1423 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
1424 { WM_IME_SETCONTEXT
, sent
|wparam
|parent
|optional
, 1 },
1425 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1426 { WM_SETFOCUS
, sent
|parent
},
1427 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
1428 { WM_DESTROY
, sent
},
1429 { WM_DESTROY
, sent
|optional
}, /* some other (IME?) window */
1430 { WM_NCDESTROY
, sent
|optional
}, /* some other (IME?) window */
1431 { WM_NCDESTROY
, sent
},
1434 /* visible child window destroyed by thread exit */
1435 static const struct message WmExitThreadSeq
[] = {
1436 { WM_NCDESTROY
, sent
}, /* actually in grandchild */
1437 { WM_PAINT
, sent
|parent
},
1438 { WM_ERASEBKGND
, sent
|parent
|beginpaint
},
1441 /* DestroyWindow for a visible child window with invisible parent */
1442 static const struct message WmDestroyInvisibleChildSeq
[] = {
1443 { HCBT_DESTROYWND
, hook
},
1444 { 0x0090, sent
|optional
},
1445 { WM_PARENTNOTIFY
, sent
|parent
|wparam
, WM_DESTROY
},
1446 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
1447 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
1448 { WM_DESTROY
, sent
},
1449 { WM_NCDESTROY
, sent
},
1452 /* Resizing child window with MoveWindow (32) */
1453 static const struct message WmResizingChildWithMoveWindowSeq
[] = {
1454 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
1455 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1456 { WM_ERASEBKGND
, sent
|parent
|optional
},
1457 { WM_ERASEBKGND
, sent
|optional
},
1458 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
},
1459 { WM_MOVE
, sent
|defwinproc
},
1460 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
1461 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1464 /* Creation of a custom dialog (32) */
1465 static const struct message WmCreateCustomDialogSeq
[] = {
1466 { HCBT_CREATEWND
, hook
},
1467 { WM_GETMINMAXINFO
, sent
},
1468 { WM_NCCREATE
, sent
},
1469 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
1470 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
1471 { WM_CREATE
, sent
},
1472 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1473 { WM_NOTIFYFORMAT
, sent
|optional
},
1474 { WM_QUERYUISTATE
, sent
|optional
},
1475 { WM_WINDOWPOSCHANGING
, sent
|optional
},
1476 { WM_GETMINMAXINFO
, sent
|optional
},
1477 { WM_NCCALCSIZE
, sent
|optional
},
1478 { WM_WINDOWPOSCHANGED
, sent
|optional
},
1479 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1480 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
1481 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1482 { HCBT_ACTIVATE
, hook
},
1483 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
1486 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
1488 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
1490 { WM_NCACTIVATE
, sent
},
1491 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1492 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1493 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1494 { EVENT_OBJECT_DEFACTIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, OBJID_CLIENT
, 0 },
1495 { WM_ACTIVATE
, sent
|wparam
, 1 },
1496 { WM_GETTEXT
, sent
|optional
},
1497 { WM_KILLFOCUS
, sent
|parent
},
1498 { WM_IME_SETCONTEXT
, sent
|parent
|wparam
|optional
, 0 },
1499 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
1500 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
1501 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1502 { WM_SETFOCUS
, sent
},
1503 { WM_GETDLGCODE
, sent
|defwinproc
|wparam
, 0 },
1504 { WM_NCPAINT
, sent
|wparam
, 1 },
1505 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1506 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1507 { WM_ERASEBKGND
, sent
},
1508 { WM_CTLCOLORDLG
, sent
|optional
|defwinproc
},
1509 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1510 { WM_GETTEXT
, sent
|optional
},
1511 { WM_GETTEXT
, sent
|optional
},
1512 { WM_NCCALCSIZE
, sent
|optional
},
1513 { WM_NCPAINT
, sent
|optional
},
1514 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1515 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1516 { WM_ERASEBKGND
, sent
|optional
},
1517 { WM_CTLCOLORDLG
, sent
|optional
|defwinproc
},
1518 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1519 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
1523 /* Calling EndDialog for a custom dialog (32) */
1524 static const struct message WmEndCustomDialogSeq
[] = {
1525 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1526 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1527 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1528 { WM_GETTEXT
, sent
|optional
},
1529 { HCBT_ACTIVATE
, hook
},
1530 { WM_NCACTIVATE
, sent
|wparam
, 0 },
1531 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1532 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1533 { WM_ACTIVATE
, sent
|wparam
, 0 },
1534 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
1535 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1536 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOACTIVATE
|SWP_NOREDRAW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1537 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1538 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1539 { HCBT_SETFOCUS
, hook
},
1540 { WM_KILLFOCUS
, sent
},
1541 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
1542 { WM_IME_SETCONTEXT
, sent
|parent
|wparam
|defwinproc
|optional
, 1 },
1543 { WM_IME_NOTIFY
, sent
|wparam
|optional
, 1 },
1544 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1545 { WM_SETFOCUS
, sent
|parent
|defwinproc
},
1548 /* ShowWindow(SW_SHOW) for a custom dialog (initially invisible) */
1549 static const struct message WmShowCustomDialogSeq
[] = {
1550 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1551 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
1552 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1553 { HCBT_ACTIVATE
, hook
},
1554 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
1556 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
1558 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
1559 { WM_ACTIVATEAPP
, sent
|wparam
|optional
, 1 },
1560 { WM_NCACTIVATE
, sent
},
1561 { WM_ACTIVATE
, sent
|wparam
, 1 },
1562 { WM_GETTEXT
, sent
|optional
},
1564 { WM_KILLFOCUS
, sent
|parent
},
1565 { WM_IME_SETCONTEXT
, sent
|parent
|wparam
|optional
, 0 },
1566 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
1567 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
1568 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1569 { WM_SETFOCUS
, sent
},
1570 { WM_GETDLGCODE
, sent
|defwinproc
|wparam
, 0 },
1571 { WM_NCPAINT
, sent
|wparam
, 1 },
1572 { WM_ERASEBKGND
, sent
},
1573 { WM_CTLCOLORDLG
, sent
|defwinproc
},
1574 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1577 /* Creation and destruction of a modal dialog (32) */
1578 static const struct message WmModalDialogSeq
[] = {
1579 { WM_CANCELMODE
, sent
|parent
},
1580 { HCBT_SETFOCUS
, hook
},
1581 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1582 { WM_KILLFOCUS
, sent
|parent
},
1583 { WM_IME_SETCONTEXT
, sent
|parent
|wparam
|optional
, 0 },
1584 { EVENT_OBJECT_STATECHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1585 { WM_ENABLE
, sent
|parent
|wparam
, 0 },
1586 { HCBT_CREATEWND
, hook
},
1587 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
1588 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1589 { WM_SETFONT
, sent
},
1590 { WM_INITDIALOG
, sent
},
1591 { WM_CHANGEUISTATE
, sent
|optional
},
1592 { WM_UPDATEUISTATE
, sent
|optional
},
1593 { WM_SHOWWINDOW
, sent
},
1594 { HCBT_ACTIVATE
, hook
},
1595 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
1596 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
1597 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
},
1598 { WM_NCACTIVATE
, sent
},
1599 { WM_GETTEXT
, sent
|optional
},
1600 { WM_ACTIVATE
, sent
|wparam
, 1 },
1601 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
1602 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1603 { WM_NCPAINT
, sent
|optional
},
1604 { WM_GETTEXT
, sent
|optional
},
1605 { WM_ERASEBKGND
, sent
|optional
},
1606 { WM_CTLCOLORDLG
, sent
|optional
},
1607 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1608 { WM_GETTEXT
, sent
|optional
},
1609 { WM_NCCALCSIZE
, sent
|optional
},
1610 { WM_NCPAINT
, sent
|optional
},
1611 { WM_GETTEXT
, sent
|optional
},
1612 { WM_ERASEBKGND
, sent
|optional
},
1613 { WM_CTLCOLORDLG
, sent
|optional
},
1614 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1615 { WM_PAINT
, sent
|optional
},
1616 { WM_CTLCOLORBTN
, sent
|optional
},
1617 { WM_GETTITLEBARINFOEX
, sent
|optional
},
1618 { WM_ENTERIDLE
, sent
|parent
|optional
},
1619 { WM_ENTERIDLE
, sent
|parent
|optional
},
1620 { WM_ENTERIDLE
, sent
|parent
|optional
},
1621 { WM_ENTERIDLE
, sent
|parent
|optional
},
1622 { WM_ENTERIDLE
, sent
|parent
|optional
},
1623 { WM_ENTERIDLE
, sent
|parent
|optional
},
1624 { WM_ENTERIDLE
, sent
|parent
|optional
},
1625 { WM_ENTERIDLE
, sent
|parent
|optional
},
1626 { WM_ENTERIDLE
, sent
|parent
|optional
},
1627 { WM_ENTERIDLE
, sent
|parent
|optional
},
1628 { WM_ENTERIDLE
, sent
|parent
|optional
},
1629 { WM_ENTERIDLE
, sent
|parent
|optional
},
1630 { WM_ENTERIDLE
, sent
|parent
|optional
},
1631 { WM_ENTERIDLE
, sent
|parent
|optional
},
1632 { WM_ENTERIDLE
, sent
|parent
|optional
},
1633 { WM_ENTERIDLE
, sent
|parent
|optional
},
1634 { WM_ENTERIDLE
, sent
|parent
|optional
},
1635 { WM_ENTERIDLE
, sent
|parent
|optional
},
1636 { WM_ENTERIDLE
, sent
|parent
|optional
},
1637 { WM_ENTERIDLE
, sent
|parent
|optional
},
1639 { EVENT_OBJECT_STATECHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1640 { WM_ENABLE
, sent
|parent
|wparam
, 1 },
1641 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
1642 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1643 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1644 { WM_GETTEXT
, sent
|optional
},
1645 { HCBT_ACTIVATE
, hook
},
1646 { WM_NCACTIVATE
, sent
|wparam
, 0 },
1647 { WM_GETTEXT
, sent
|optional
},
1648 { WM_ACTIVATE
, sent
|wparam
, 0 },
1649 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
1650 { WM_WINDOWPOSCHANGING
, sent
|optional
},
1651 { WM_WINDOWPOSCHANGED
, sent
|optional
},
1652 { HCBT_SETFOCUS
, hook
},
1653 { WM_IME_SETCONTEXT
, sent
|parent
|wparam
|defwinproc
|optional
, 1 },
1654 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1655 { WM_SETFOCUS
, sent
|parent
|defwinproc
},
1656 { EVENT_SYSTEM_DIALOGEND
, winevent_hook
|wparam
|lparam
, 0, 0 },
1657 { HCBT_DESTROYWND
, hook
},
1658 { 0x0090, sent
|optional
},
1659 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
1660 { WM_DESTROY
, sent
},
1661 { WM_NCDESTROY
, sent
},
1664 static const struct message WmModalDialogSeq_2
[] = {
1665 { WM_CANCELMODE
, sent
},
1666 { HCBT_SETFOCUS
, hook
},
1667 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1668 { WM_KILLFOCUS
, sent
},
1669 { WM_IME_SETCONTEXT
, sent
|parent
|wparam
|optional
, 0 },
1670 { EVENT_OBJECT_STATECHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1671 { WM_ENABLE
, sent
|wparam
, 0 },
1672 { HCBT_CREATEWND
, hook
},
1673 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
1674 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1675 { WM_SETFONT
, sent
},
1676 { WM_INITDIALOG
, sent
},
1677 { WM_CHANGEUISTATE
, sent
|optional
},
1678 { WM_UPDATEUISTATE
, sent
|optional
},
1679 { WM_ENABLE
, sent
|wparam
, 1 },
1680 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
1681 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1682 { WM_CHANGEUISTATE
, sent
|optional
},
1683 { WM_UPDATEUISTATE
, sent
|optional
},
1684 { HCBT_DESTROYWND
, hook
},
1685 { 0x0090, sent
|optional
},
1686 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
1687 { WM_DESTROY
, sent
},
1688 { WM_NCDESTROY
, sent
},
1691 /* SetMenu for NonVisible windows with size change*/
1692 static const struct message WmSetMenuNonVisibleSizeChangeSeq
[] = {
1693 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1694 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1695 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
1696 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
},
1697 { WM_MOVE
, sent
|defwinproc
},
1698 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
1699 { WM_NCCALCSIZE
,sent
|wparam
|optional
, 1 }, /* XP */
1700 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1701 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* XP sends a duplicate */
1702 { WM_GETTEXT
, sent
|optional
},
1703 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
1706 /* SetMenu for NonVisible windows with no size change */
1707 static const struct message WmSetMenuNonVisibleNoSizeChangeSeq
[] = {
1708 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1709 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1710 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1711 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1714 /* SetMenu for Visible windows with size change */
1715 static const struct message WmSetMenuVisibleSizeChangeSeq
[] = {
1716 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1717 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1718 { 0x0093, sent
|defwinproc
|optional
},
1719 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
1720 { WM_NCPAINT
, sent
|optional
}, /* wparam != 1 */
1721 { 0x0093, sent
|defwinproc
|optional
},
1722 { 0x0093, sent
|defwinproc
|optional
},
1723 { 0x0091, sent
|defwinproc
|optional
},
1724 { 0x0092, sent
|defwinproc
|optional
},
1725 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1726 { WM_ERASEBKGND
, sent
|optional
},
1727 { WM_ACTIVATE
, sent
|optional
},
1728 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1729 { WM_MOVE
, sent
|defwinproc
},
1730 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
1731 { 0x0093, sent
|optional
},
1732 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
1733 { 0x0093, sent
|defwinproc
|optional
},
1734 { WM_NCPAINT
, sent
|optional
}, /* wparam != 1 */
1735 { 0x0093, sent
|defwinproc
|optional
},
1736 { 0x0093, sent
|defwinproc
|optional
},
1737 { 0x0091, sent
|defwinproc
|optional
},
1738 { 0x0092, sent
|defwinproc
|optional
},
1739 { WM_ERASEBKGND
, sent
|optional
},
1740 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1741 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* XP sends a duplicate */
1744 /* SetMenu for Visible windows with no size change */
1745 static const struct message WmSetMenuVisibleNoSizeChangeSeq
[] = {
1746 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1747 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1748 { WM_NCPAINT
, sent
|optional
}, /* wparam != 1 */
1749 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1750 { WM_ERASEBKGND
, sent
|optional
},
1751 { WM_ACTIVATE
, sent
|optional
},
1752 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1753 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1756 /* DrawMenuBar for a visible window */
1757 static const struct message WmDrawMenuBarSeq
[] =
1759 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1760 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1761 { 0x0093, sent
|defwinproc
|optional
},
1762 { WM_NCPAINT
, sent
|optional
}, /* wparam != 1 */
1763 { 0x0093, sent
|defwinproc
|optional
},
1764 { 0x0093, sent
|defwinproc
|optional
},
1765 { 0x0091, sent
|defwinproc
|optional
},
1766 { 0x0092, sent
|defwinproc
|optional
},
1767 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1768 { WM_ERASEBKGND
, sent
|optional
},
1769 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1770 { 0x0093, sent
|optional
},
1771 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1775 static const struct message WmSetRedrawFalseSeq
[] =
1777 { WM_SETREDRAW
, sent
|wparam
, 0 },
1781 static const struct message WmSetRedrawTrueSeq
[] =
1783 { WM_SETREDRAW
, sent
|wparam
, 1 },
1787 static const struct message WmEnableWindowSeq_1
[] =
1789 { WM_CANCELMODE
, sent
|wparam
|lparam
, 0, 0 },
1790 { EVENT_OBJECT_STATECHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1791 { HCBT_SETFOCUS
, hook
|optional
},
1792 { WM_KILLFOCUS
, sent
|optional
},
1793 { WM_ENABLE
, sent
|wparam
|lparam
, FALSE
, 0 },
1797 static const struct message WmEnableWindowSeq_2
[] =
1799 { WM_CANCELMODE
, sent
|wparam
|lparam
, 0, 0 },
1800 { EVENT_OBJECT_STATECHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1804 static const struct message WmEnableWindowSeq_3
[] =
1806 { EVENT_OBJECT_STATECHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1807 { WM_ENABLE
, sent
|wparam
|lparam
, TRUE
, 0 },
1811 static const struct message WmEnableWindowSeq_4
[] =
1813 { EVENT_OBJECT_STATECHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1817 static const struct message WmGetScrollRangeSeq
[] =
1819 { SBM_GETRANGE
, sent
},
1822 static const struct message WmGetScrollInfoSeq
[] =
1824 { SBM_GETSCROLLINFO
, sent
},
1827 static const struct message WmSetScrollRangeSeq
[] =
1829 /* MSDN claims that Windows sends SBM_SETRANGE message, but win2k SP4
1830 sends SBM_SETSCROLLINFO.
1832 { SBM_SETSCROLLINFO
, sent
},
1835 /* SetScrollRange for a window without a non-client area */
1836 static const struct message WmSetScrollRangeHSeq_empty
[] =
1838 { EVENT_OBJECT_VALUECHANGE
, winevent_hook
|wparam
|lparam
, OBJID_HSCROLL
, 0 },
1841 static const struct message WmSetScrollRangeVSeq_empty
[] =
1843 { EVENT_OBJECT_VALUECHANGE
, winevent_hook
|wparam
|lparam
, OBJID_VSCROLL
, 0 },
1846 static const struct message WmSetScrollRangeHVSeq
[] =
1848 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOSIZE
},
1849 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1850 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1851 { WM_ERASEBKGND
, sent
|optional
},
1852 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1853 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1854 { EVENT_OBJECT_VALUECHANGE
, winevent_hook
|lparam
|optional
, 0/*OBJID_HSCROLL or OBJID_VSCROLL*/, 0 },
1857 /* SetScrollRange for a window with a non-client area */
1858 static const struct message WmSetScrollRangeHV_NC_Seq
[] =
1860 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOSIZE
},
1861 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1862 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
1863 { WM_NCPAINT
, sent
|optional
},
1864 { WM_STYLECHANGING
, sent
|defwinproc
|optional
},
1865 { WM_STYLECHANGED
, sent
|defwinproc
|optional
},
1866 { WM_STYLECHANGING
, sent
|defwinproc
|optional
},
1867 { WM_STYLECHANGED
, sent
|defwinproc
|optional
},
1868 { WM_STYLECHANGING
, sent
|defwinproc
|optional
},
1869 { WM_STYLECHANGED
, sent
|defwinproc
|optional
},
1870 { WM_STYLECHANGING
, sent
|defwinproc
|optional
},
1871 { WM_STYLECHANGED
, sent
|defwinproc
|optional
},
1872 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1873 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1874 { WM_ERASEBKGND
, sent
|optional
},
1875 { WM_CTLCOLORDLG
, sent
|defwinproc
|optional
}, /* sent to a parent of the dialog */
1876 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOCLIENTMOVE
, 0, SWP_NOCLIENTSIZE
},
1877 { WM_SIZE
, sent
|defwinproc
|optional
},
1878 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1879 { EVENT_OBJECT_VALUECHANGE
, winevent_hook
|lparam
|optional
, 0/*OBJID_HSCROLL or OBJID_VSCROLL*/, 0 },
1880 { WM_GETTEXT
, sent
|optional
},
1881 { WM_GETTEXT
, sent
|optional
},
1882 { WM_GETTEXT
, sent
|optional
},
1883 { WM_GETTEXT
, sent
|optional
},
1886 /* test if we receive the right sequence of messages */
1887 /* after calling ShowWindow( SW_SHOWNA) */
1888 static const struct message WmSHOWNAChildInvisParInvis
[] = {
1889 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1892 static const struct message WmSHOWNAChildVisParInvis
[] = {
1893 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1896 static const struct message WmSHOWNAChildVisParVis
[] = {
1897 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1898 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
1901 static const struct message WmSHOWNAChildInvisParVis
[] = {
1902 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1903 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1904 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1905 { WM_ERASEBKGND
, sent
|optional
},
1906 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOACTIVATE
|SWP_NOCLIENTMOVE
},
1909 static const struct message WmSHOWNATopVisible
[] = {
1910 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1911 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
1912 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
1913 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1914 { WM_ERASEBKGND
, sent
|optional
},
1915 { WM_WINDOWPOSCHANGED
, sent
|optional
},
1918 static const struct message WmSHOWNATopInvisible
[] = {
1919 { WM_NOTIFYFORMAT
, sent
|optional
},
1920 { WM_QUERYUISTATE
, sent
|optional
},
1921 { WM_WINDOWPOSCHANGING
, sent
|optional
},
1922 { WM_GETMINMAXINFO
, sent
|optional
},
1923 { WM_NCCALCSIZE
, sent
|optional
},
1924 { WM_WINDOWPOSCHANGED
, sent
|optional
},
1925 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1926 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1927 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1928 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
1929 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1930 { WM_ERASEBKGND
, sent
|optional
},
1931 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1932 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
1933 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
1934 { WM_ERASEBKGND
, sent
|optional
},
1935 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1936 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
1941 static const struct message WmTrackPopupMenu
[] = {
1942 { HCBT_CREATEWND
, hook
},
1943 { WM_ENTERMENULOOP
, sent
|wparam
|lparam
, TRUE
, 0 },
1944 { WM_INITMENU
, sent
|lparam
, 0, 0 },
1945 { WM_INITMENUPOPUP
, sent
|lparam
, 0, 0 },
1946 { 0x0093, sent
|optional
},
1947 { 0x0094, sent
|optional
},
1948 { 0x0094, sent
|optional
},
1949 { WM_ENTERIDLE
, sent
|wparam
, 2 },
1950 { WM_CAPTURECHANGED
, sent
},
1951 { HCBT_DESTROYWND
, hook
},
1952 { WM_UNINITMENUPOPUP
, sent
|lparam
, 0, 0 },
1953 { WM_MENUSELECT
, sent
|wparam
|lparam
, 0xffff0000, 0 },
1954 { WM_EXITMENULOOP
, sent
|wparam
|lparam
, 1, 0 },
1958 static const struct message WmTrackPopupMenuEsc
[] = {
1962 static const struct message WmTrackPopupMenuCapture
[] = {
1963 { HCBT_CREATEWND
, hook
},
1964 { WM_ENTERMENULOOP
, sent
|wparam
|lparam
, TRUE
, 0 },
1965 { WM_CAPTURECHANGED
, sent
},
1966 { WM_INITMENU
, sent
|lparam
, 0, 0 },
1967 { WM_INITMENUPOPUP
, sent
|lparam
, 0, 0 },
1968 { 0x0093, sent
|optional
},
1969 { 0x0094, sent
|optional
},
1970 { 0x0094, sent
|optional
},
1971 { WM_ENTERIDLE
, sent
|wparam
, 2 },
1972 { WM_CAPTURECHANGED
, sent
},
1973 { HCBT_DESTROYWND
, hook
},
1974 { WM_UNINITMENUPOPUP
, sent
|lparam
, 0, 0 },
1975 { WM_MENUSELECT
, sent
|wparam
|lparam
, 0xffff0000, 0 },
1976 { WM_EXITMENULOOP
, sent
|wparam
|lparam
, 1, 0 },
1980 static const struct message WmTrackPopupMenuEmpty
[] = {
1981 { HCBT_CREATEWND
, hook
},
1982 { WM_ENTERMENULOOP
, sent
|wparam
|lparam
, TRUE
, 0 },
1983 { WM_INITMENU
, sent
|lparam
, 0, 0 },
1984 { WM_INITMENUPOPUP
, sent
|lparam
, 0, 0 },
1985 { 0x0093, sent
|optional
},
1986 { 0x0094, sent
|optional
},
1987 { 0x0094, sent
|optional
},
1988 { WM_CAPTURECHANGED
, sent
},
1989 { WM_EXITMENULOOP
, sent
|wparam
|lparam
, 1, 0 },
1990 { HCBT_DESTROYWND
, hook
},
1991 { WM_UNINITMENUPOPUP
, sent
|lparam
, 0, 0 },
1995 static const struct message WmTrackPopupMenuAbort
[] = {
1996 { HCBT_CREATEWND
, hook
},
1997 { WM_ENTERMENULOOP
, sent
|wparam
|lparam
, TRUE
, 0 },
1998 { WM_INITMENU
, sent
|lparam
, 0, 0 },
1999 { WM_INITMENUPOPUP
, sent
|lparam
, 0, 0 },
2000 { 0x0093, sent
|optional
},
2001 { 0x0094, sent
|optional
},
2002 { 0x0094, sent
|optional
},
2003 { WM_CAPTURECHANGED
, sent
},
2004 { HCBT_DESTROYWND
, hook
},
2005 { WM_UNINITMENUPOPUP
, sent
|lparam
, 0, 0 },
2006 { WM_MENUSELECT
, sent
|wparam
|lparam
, 0xffff0000, 0 },
2007 { WM_EXITMENULOOP
, sent
|wparam
|lparam
, 1, 0 },
2011 static BOOL after_end_dialog
, test_def_id
, paint_loop_done
;
2012 static int sequence_cnt
, sequence_size
;
2013 static struct recvd_message
* sequence
;
2014 static int log_all_parent_messages
;
2015 static CRITICAL_SECTION sequence_cs
;
2017 /* user32 functions */
2018 static HWND (WINAPI
*pGetAncestor
)(HWND
,UINT
);
2019 static BOOL (WINAPI
*pGetMenuInfo
)(HMENU
,LPCMENUINFO
);
2020 static void (WINAPI
*pNotifyWinEvent
)(DWORD
, HWND
, LONG
, LONG
);
2021 static BOOL (WINAPI
*pSetMenuInfo
)(HMENU
,LPCMENUINFO
);
2022 static HWINEVENTHOOK (WINAPI
*pSetWinEventHook
)(DWORD
, DWORD
, HMODULE
, WINEVENTPROC
, DWORD
, DWORD
, DWORD
);
2023 static BOOL (WINAPI
*pTrackMouseEvent
)(TRACKMOUSEEVENT
*);
2024 static BOOL (WINAPI
*pUnhookWinEvent
)(HWINEVENTHOOK
);
2025 static BOOL (WINAPI
*pGetMonitorInfoA
)(HMONITOR
,LPMONITORINFO
);
2026 static HMONITOR (WINAPI
*pMonitorFromPoint
)(POINT
,DWORD
);
2027 static BOOL (WINAPI
*pUpdateLayeredWindow
)(HWND
,HDC
,POINT
*,SIZE
*,HDC
,POINT
*,COLORREF
,BLENDFUNCTION
*,DWORD
);
2028 static UINT_PTR (WINAPI
*pSetSystemTimer
)(HWND
, UINT_PTR
, UINT
, TIMERPROC
);
2029 static UINT_PTR (WINAPI
*pKillSystemTimer
)(HWND
, UINT_PTR
);
2030 static UINT_PTR (WINAPI
*pSetCoalescableTimer
)(HWND
, UINT_PTR
, UINT
, TIMERPROC
, ULONG
);
2031 /* kernel32 functions */
2032 static BOOL (WINAPI
*pGetCPInfoExA
)(UINT
, DWORD
, LPCPINFOEXA
);
2034 static void init_procs(void)
2036 HMODULE user32
= GetModuleHandleA("user32.dll");
2037 HMODULE kernel32
= GetModuleHandleA("kernel32.dll");
2039 #define GET_PROC(dll, func) \
2040 p ## func = (void*)GetProcAddress(dll, #func); \
2042 trace("GetProcAddress(%s) failed\n", #func); \
2045 GET_PROC(user32
, GetAncestor
)
2046 GET_PROC(user32
, GetMenuInfo
)
2047 GET_PROC(user32
, NotifyWinEvent
)
2048 GET_PROC(user32
, SetMenuInfo
)
2049 GET_PROC(user32
, SetWinEventHook
)
2050 GET_PROC(user32
, TrackMouseEvent
)
2051 GET_PROC(user32
, UnhookWinEvent
)
2052 GET_PROC(user32
, GetMonitorInfoA
)
2053 GET_PROC(user32
, MonitorFromPoint
)
2054 GET_PROC(user32
, UpdateLayeredWindow
)
2055 GET_PROC(user32
, SetSystemTimer
)
2056 GET_PROC(user32
, KillSystemTimer
)
2057 GET_PROC(user32
, SetCoalescableTimer
)
2059 GET_PROC(kernel32
, GetCPInfoExA
)
2064 static const char *get_winpos_flags(UINT flags
)
2066 static char buffer
[300];
2069 #define DUMP(flag) do { if (flags & flag) { strcat( buffer, "|" #flag ); flags &= ~flag; } } while(0)
2070 DUMP( SWP_SHOWWINDOW
);
2071 DUMP( SWP_HIDEWINDOW
);
2072 DUMP( SWP_NOACTIVATE
);
2073 DUMP( SWP_FRAMECHANGED
);
2074 DUMP( SWP_NOCOPYBITS
);
2075 DUMP( SWP_NOOWNERZORDER
);
2076 DUMP( SWP_NOSENDCHANGING
);
2077 DUMP( SWP_DEFERERASE
);
2078 DUMP( SWP_ASYNCWINDOWPOS
);
2079 DUMP( SWP_NOZORDER
);
2080 DUMP( SWP_NOREDRAW
);
2083 DUMP( SWP_NOCLIENTSIZE
);
2084 DUMP( SWP_NOCLIENTMOVE
);
2085 if (flags
) sprintf(buffer
+ strlen(buffer
),"|0x%04x", flags
);
2090 static BOOL
ignore_message( UINT message
)
2092 /* these are always ignored */
2093 return (message
>= 0xc000 ||
2094 message
== WM_GETICON
||
2095 message
== WM_GETOBJECT
||
2096 message
== WM_TIMECHANGE
||
2097 message
== WM_DISPLAYCHANGE
||
2098 message
== WM_DEVICECHANGE
||
2099 message
== WM_DWMNCRENDERINGCHANGED
);
2103 #define add_message(msg) add_message_(__LINE__,msg);
2104 static void add_message_(int line
, const struct recvd_message
*msg
)
2106 struct recvd_message
*seq
;
2108 EnterCriticalSection( &sequence_cs
);
2112 sequence
= HeapAlloc( GetProcessHeap(), 0, sequence_size
* sizeof(*sequence
) );
2114 if (sequence_cnt
== sequence_size
)
2117 sequence
= HeapReAlloc( GetProcessHeap(), 0, sequence
, sequence_size
* sizeof(*sequence
) );
2121 seq
= &sequence
[sequence_cnt
++];
2122 seq
->hwnd
= msg
->hwnd
;
2123 seq
->message
= msg
->message
;
2124 seq
->flags
= msg
->flags
;
2125 seq
->wParam
= msg
->wParam
;
2126 seq
->lParam
= msg
->lParam
;
2128 seq
->descr
= msg
->descr
;
2130 LeaveCriticalSection( &sequence_cs
);
2134 if (msg
->flags
& hook
)
2136 static const char * const CBT_code_name
[10] =
2144 "HCBT_CLICKSKIPPED",
2149 const char *code_name
= (msg
->message
<= HCBT_SETFOCUS
) ? CBT_code_name
[msg
->message
] : "Unknown";
2151 sprintf( seq
->output
, "%s: hook %d (%s) wp %08lx lp %08lx",
2152 msg
->descr
, msg
->message
, code_name
, msg
->wParam
, msg
->lParam
);
2154 else if (msg
->flags
& winevent_hook
)
2156 sprintf( seq
->output
, "%s: winevent %p %08x %08lx %08lx",
2157 msg
->descr
, msg
->hwnd
, msg
->message
, msg
->wParam
, msg
->lParam
);
2161 switch (msg
->message
)
2163 case WM_WINDOWPOSCHANGING
:
2164 case WM_WINDOWPOSCHANGED
:
2166 WINDOWPOS
*winpos
= (WINDOWPOS
*)msg
->lParam
;
2168 sprintf( seq
->output
, "%s: %p WM_WINDOWPOS%s wp %08lx lp %08lx after %p x %d y %d cx %d cy %d flags %s",
2169 msg
->descr
, msg
->hwnd
,
2170 (msg
->message
== WM_WINDOWPOSCHANGING
) ? "CHANGING" : "CHANGED",
2171 msg
->wParam
, msg
->lParam
, winpos
->hwndInsertAfter
,
2172 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
,
2173 get_winpos_flags(winpos
->flags
) );
2175 /* Log only documented flags, win2k uses 0x1000 and 0x2000
2176 * in the high word for internal purposes
2178 seq
->wParam
= winpos
->flags
& 0xffff;
2179 /* We are not interested in the flags that don't match under XP and Win9x */
2180 seq
->wParam
&= ~SWP_NOZORDER
;
2186 DRAW_ITEM_STRUCT di
;
2187 DRAWITEMSTRUCT
*dis
= (DRAWITEMSTRUCT
*)msg
->lParam
;
2189 sprintf( seq
->output
, "%s: %p WM_DRAWITEM: type %x, ctl_id %x, item_id %x, action %x, state %x",
2190 msg
->descr
, msg
->hwnd
, dis
->CtlType
, dis
->CtlID
,
2191 dis
->itemID
, dis
->itemAction
, dis
->itemState
);
2194 di
.u
.item
.type
= dis
->CtlType
;
2195 di
.u
.item
.ctl_id
= dis
->CtlID
;
2196 if (dis
->CtlType
== ODT_LISTBOX
||
2197 dis
->CtlType
== ODT_COMBOBOX
||
2198 dis
->CtlType
== ODT_MENU
)
2199 di
.u
.item
.item_id
= dis
->itemID
;
2200 di
.u
.item
.action
= dis
->itemAction
;
2201 di
.u
.item
.state
= dis
->itemState
;
2203 seq
->lParam
= di
.u
.lp
;
2207 if (msg
->message
>= 0xc000) return; /* ignore registered messages */
2208 sprintf( seq
->output
, "%s: %p %04x wp %08lx lp %08lx",
2209 msg
->descr
, msg
->hwnd
, msg
->message
, msg
->wParam
, msg
->lParam
);
2211 if (msg
->flags
& (sent
|posted
|parent
|defwinproc
|beginpaint
))
2212 sprintf( seq
->output
+ strlen(seq
->output
), " (flags %x)", msg
->flags
);
2217 /* try to make sure pending X events have been processed before continuing */
2218 static void flush_events(void)
2222 int min_timeout
= 100;
2223 DWORD time
= GetTickCount() + diff
;
2227 if (MsgWaitForMultipleObjects( 0, NULL
, FALSE
, min_timeout
, QS_ALLINPUT
) == WAIT_TIMEOUT
) break;
2228 while (PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA( &msg
);
2229 diff
= time
- GetTickCount();
2233 static void flush_sequence(void)
2235 EnterCriticalSection( &sequence_cs
);
2236 HeapFree(GetProcessHeap(), 0, sequence
);
2238 sequence_cnt
= sequence_size
= 0;
2239 LeaveCriticalSection( &sequence_cs
);
2242 static void dump_sequence(const struct message
*expected
, const char *context
, const char *file
, int line
)
2244 const struct recvd_message
*actual
= sequence
;
2245 unsigned int count
= 0;
2247 trace_(file
, line
)("Failed sequence %s:\n", context
);
2248 while (expected
->message
&& actual
->message
)
2250 if (actual
->output
[0])
2252 if (expected
->flags
& hook
)
2254 trace_(file
, line
)( " %u: expected: hook %04x - actual: %s\n",
2255 count
, expected
->message
, actual
->output
);
2257 else if (expected
->flags
& winevent_hook
)
2259 trace_(file
, line
)( " %u: expected: winevent %04x - actual: %s\n",
2260 count
, expected
->message
, actual
->output
);
2262 else if (expected
->flags
& kbd_hook
)
2264 trace_(file
, line
)( " %u: expected: kbd %04x - actual: %s\n",
2265 count
, expected
->message
, actual
->output
);
2269 trace_(file
, line
)( " %u: expected: msg %04x - actual: %s\n",
2270 count
, expected
->message
, actual
->output
);
2274 if (expected
->message
== actual
->message
)
2276 if ((expected
->flags
& defwinproc
) != (actual
->flags
& defwinproc
) &&
2277 (expected
->flags
& optional
))
2279 /* don't match messages if their defwinproc status differs */
2288 /* silently drop winevent messages if there is no support for them */
2289 else if ((expected
->flags
& optional
) || ((expected
->flags
& winevent_hook
) && !hEvent_hook
))
2299 /* optional trailing messages */
2300 while (expected
->message
&& ((expected
->flags
& optional
) ||
2301 ((expected
->flags
& winevent_hook
) && !hEvent_hook
)))
2303 trace_(file
, line
)( " %u: expected: msg %04x - actual: nothing\n", count
, expected
->message
);
2308 if (expected
->message
)
2310 trace_(file
, line
)( " %u: expected: msg %04x - actual: nothing\n", count
, expected
->message
);
2314 while (actual
->message
&& actual
->output
[0])
2316 trace_(file
, line
)( " %u: expected: nothing - actual: %s\n", count
, actual
->output
);
2322 #define ok_sequence( exp, contx, todo) \
2323 ok_sequence_( (exp), (contx), (todo), __FILE__, __LINE__)
2326 static void ok_sequence_(const struct message
*expected_list
, const char *context
, BOOL todo
,
2327 const char *file
, int line
)
2329 static const struct recvd_message end_of_sequence
;
2330 const struct message
*expected
= expected_list
;
2331 const struct recvd_message
*actual
;
2332 int failcount
= 0, dump
= 0;
2333 unsigned int count
= 0;
2335 add_message(&end_of_sequence
);
2339 while (expected
->message
&& actual
->message
)
2341 if (expected
->message
== actual
->message
&&
2342 !((expected
->flags
^ actual
->flags
) & (hook
|winevent_hook
|kbd_hook
)))
2344 if (expected
->flags
& wparam
)
2346 if (((expected
->wParam
^ actual
->wParam
) & ~expected
->wp_mask
) && todo
)
2350 if (strcmp(winetest_platform
, "wine")) dump
++;
2351 ok_( file
, line
) (FALSE
,
2352 "%s: %u: in msg 0x%04x expecting wParam 0x%lx got 0x%lx\n",
2353 context
, count
, expected
->message
, expected
->wParam
, actual
->wParam
);
2358 ok_( file
, line
)( ((expected
->wParam
^ actual
->wParam
) & ~expected
->wp_mask
) == 0,
2359 "%s: %u: in msg 0x%04x expecting wParam 0x%lx got 0x%lx\n",
2360 context
, count
, expected
->message
, expected
->wParam
, actual
->wParam
);
2361 if ((expected
->wParam
^ actual
->wParam
) & ~expected
->wp_mask
) dump
++;
2365 if (expected
->flags
& lparam
)
2367 if (((expected
->lParam
^ actual
->lParam
) & ~expected
->lp_mask
) && todo
)
2371 if (strcmp(winetest_platform
, "wine")) dump
++;
2372 ok_( file
, line
) (FALSE
,
2373 "%s: %u: in msg 0x%04x expecting lParam 0x%lx got 0x%lx\n",
2374 context
, count
, expected
->message
, expected
->lParam
, actual
->lParam
);
2379 ok_( file
, line
)(((expected
->lParam
^ actual
->lParam
) & ~expected
->lp_mask
) == 0,
2380 "%s: %u: in msg 0x%04x expecting lParam 0x%lx got 0x%lx\n",
2381 context
, count
, expected
->message
, expected
->lParam
, actual
->lParam
);
2382 if ((expected
->lParam
^ actual
->lParam
) & ~expected
->lp_mask
) dump
++;
2385 if ((expected
->flags
& optional
) &&
2386 ((expected
->flags
^ actual
->flags
) & (defwinproc
|parent
)))
2388 /* don't match optional messages if their defwinproc or parent status differs */
2393 if ((expected
->flags
& defwinproc
) != (actual
->flags
& defwinproc
) && todo
)
2397 if (strcmp(winetest_platform
, "wine")) dump
++;
2398 ok_( file
, line
) (FALSE
,
2399 "%s: %u: the msg 0x%04x should %shave been sent by DefWindowProc\n",
2400 context
, count
, expected
->message
, (expected
->flags
& defwinproc
) ? "" : "NOT ");
2405 ok_( file
, line
) ((expected
->flags
& defwinproc
) == (actual
->flags
& defwinproc
),
2406 "%s: %u: the msg 0x%04x should %shave been sent by DefWindowProc\n",
2407 context
, count
, expected
->message
, (expected
->flags
& defwinproc
) ? "" : "NOT ");
2408 if ((expected
->flags
& defwinproc
) != (actual
->flags
& defwinproc
)) dump
++;
2411 ok_( file
, line
) ((expected
->flags
& beginpaint
) == (actual
->flags
& beginpaint
),
2412 "%s: %u: the msg 0x%04x should %shave been sent by BeginPaint\n",
2413 context
, count
, expected
->message
, (expected
->flags
& beginpaint
) ? "" : "NOT ");
2414 if ((expected
->flags
& beginpaint
) != (actual
->flags
& beginpaint
)) dump
++;
2416 ok_( file
, line
) ((expected
->flags
& (sent
|posted
)) == (actual
->flags
& (sent
|posted
)),
2417 "%s: %u: the msg 0x%04x should have been %s\n",
2418 context
, count
, expected
->message
, (expected
->flags
& posted
) ? "posted" : "sent");
2419 if ((expected
->flags
& (sent
|posted
)) != (actual
->flags
& (sent
|posted
))) dump
++;
2421 ok_( file
, line
) ((expected
->flags
& parent
) == (actual
->flags
& parent
),
2422 "%s: %u: the msg 0x%04x was expected in %s\n",
2423 context
, count
, expected
->message
, (expected
->flags
& parent
) ? "parent" : "child");
2424 if ((expected
->flags
& parent
) != (actual
->flags
& parent
)) dump
++;
2426 ok_( file
, line
) ((expected
->flags
& hook
) == (actual
->flags
& hook
),
2427 "%s: %u: the msg 0x%04x should have been sent by a hook\n",
2428 context
, count
, expected
->message
);
2429 if ((expected
->flags
& hook
) != (actual
->flags
& hook
)) dump
++;
2431 ok_( file
, line
) ((expected
->flags
& winevent_hook
) == (actual
->flags
& winevent_hook
),
2432 "%s: %u: the msg 0x%04x should have been sent by a winevent hook\n",
2433 context
, count
, expected
->message
);
2434 if ((expected
->flags
& winevent_hook
) != (actual
->flags
& winevent_hook
)) dump
++;
2436 ok_( file
, line
) ((expected
->flags
& kbd_hook
) == (actual
->flags
& kbd_hook
),
2437 "%s: %u: the msg 0x%04x should have been sent by a keyboard hook\n",
2438 context
, count
, expected
->message
);
2439 if ((expected
->flags
& kbd_hook
) != (actual
->flags
& kbd_hook
)) dump
++;
2444 /* silently drop hook messages if there is no support for them */
2445 else if ((expected
->flags
& optional
) ||
2446 ((expected
->flags
& hook
) && !hCBT_hook
) ||
2447 ((expected
->flags
& winevent_hook
) && !hEvent_hook
) ||
2448 ((expected
->flags
& kbd_hook
) && !hKBD_hook
))
2454 if (strcmp(winetest_platform
, "wine")) dump
++;
2455 ok_( file
, line
) (FALSE
, "%s: %u: the msg 0x%04x was expected, but got msg 0x%04x instead\n",
2456 context
, count
, expected
->message
, actual
->message
);
2462 ok_( file
, line
) (FALSE
, "%s: %u: the msg 0x%04x was expected, but got msg 0x%04x instead\n",
2463 context
, count
, expected
->message
, actual
->message
);
2471 /* skip all optional trailing messages */
2472 while (expected
->message
&& ((expected
->flags
& optional
) ||
2473 ((expected
->flags
& hook
) && !hCBT_hook
) ||
2474 ((expected
->flags
& winevent_hook
) && !hEvent_hook
)))
2480 if (expected
->message
|| actual
->message
) {
2482 if (strcmp(winetest_platform
, "wine")) dump
++;
2483 ok_( file
, line
) (FALSE
, "%s: %u: the msg sequence is not complete: expected %04x - actual %04x\n",
2484 context
, count
, expected
->message
, actual
->message
);
2490 if (expected
->message
|| actual
->message
)
2493 ok_( file
, line
) (FALSE
, "%s: %u: the msg sequence is not complete: expected %04x - actual %04x\n",
2494 context
, count
, expected
->message
, actual
->message
);
2497 if( todo
&& !failcount
) /* succeeded yet marked todo */
2499 if (!strcmp(winetest_platform
, "wine")) dump
++;
2500 ok_( file
, line
)( TRUE
, "%s: marked \"todo_wine\" but succeeds\n", context
);
2504 if (dump
) dump_sequence(expected_list
, context
, file
, line
);
2508 #define expect(EXPECTED,GOT) ok((GOT)==(EXPECTED), "Expected %d, got %d\n", (EXPECTED), (GOT))
2510 /******************************** MDI test **********************************/
2512 /* CreateWindow for MDI frame window, initially visible */
2513 static const struct message WmCreateMDIframeSeq
[] = {
2514 { HCBT_CREATEWND
, hook
},
2515 { WM_GETMINMAXINFO
, sent
},
2516 { WM_NCCREATE
, sent
},
2517 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
2518 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
2519 { WM_CREATE
, sent
},
2520 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2521 { WM_NOTIFYFORMAT
, sent
|optional
},
2522 { WM_QUERYUISTATE
, sent
|optional
},
2523 { WM_WINDOWPOSCHANGING
, sent
|optional
},
2524 { WM_GETMINMAXINFO
, sent
|optional
},
2525 { WM_NCCALCSIZE
, sent
|optional
},
2526 { WM_WINDOWPOSCHANGED
, sent
|optional
},
2527 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
2528 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
2529 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2530 { HCBT_ACTIVATE
, hook
},
2531 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
2532 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
2533 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* XP */
2534 { WM_ACTIVATEAPP
, sent
|wparam
|optional
, 1 }, /* Win9x doesn't send it */
2535 { WM_NCACTIVATE
, sent
},
2536 { WM_GETTEXT
, sent
|defwinproc
|optional
},
2537 { WM_ACTIVATE
, sent
|wparam
, 1 },
2538 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* Win9x */
2539 { HCBT_SETFOCUS
, hook
},
2540 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
2541 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
2542 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2543 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
2544 /* Win9x adds SWP_NOZORDER below */
2545 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2546 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 }, /* XP */
2547 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2548 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2552 /* DestroyWindow for MDI frame window, initially visible */
2553 static const struct message WmDestroyMDIframeSeq
[] = {
2554 { HCBT_DESTROYWND
, hook
},
2555 { 0x0090, sent
|optional
},
2556 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2557 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2558 { WM_NCACTIVATE
, sent
|wparam
|optional
, 0 }, /* Win9x */
2559 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2560 { WM_NCACTIVATE
, sent
|wparam
|optional
, 0 }, /* XP */
2561 { WM_ACTIVATE
, sent
|wparam
|optional
, 0 }, /* Win9x */
2562 { WM_ACTIVATEAPP
, sent
|wparam
|optional
, 0 }, /* Win9x */
2563 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
2564 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
2565 { WM_DESTROY
, sent
},
2566 { WM_NCDESTROY
, sent
},
2569 /* CreateWindow for MDI client window, initially visible */
2570 static const struct message WmCreateMDIclientSeq
[] = {
2571 { HCBT_CREATEWND
, hook
},
2572 { WM_NCCREATE
, sent
},
2573 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
2574 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 },
2575 { WM_CREATE
, sent
},
2576 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 },
2577 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2578 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2580 { WM_PARENTNOTIFY
, sent
|wparam
, WM_CREATE
}, /* in MDI frame */
2581 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
2582 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2583 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2584 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2587 /* ShowWindow(SW_SHOW) for MDI client window */
2588 static const struct message WmShowMDIclientSeq
[] = {
2589 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
2590 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2591 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2592 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2595 /* ShowWindow(SW_HIDE) for MDI client window */
2596 static const struct message WmHideMDIclientSeq
[] = {
2597 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
2598 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2599 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* win2000 */
2600 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* XP */
2601 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2604 /* DestroyWindow for MDI client window, initially visible */
2605 static const struct message WmDestroyMDIclientSeq
[] = {
2606 { HCBT_DESTROYWND
, hook
},
2607 { 0x0090, sent
|optional
},
2608 { WM_PARENTNOTIFY
, sent
|wparam
, WM_DESTROY
}, /* in MDI frame */
2609 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
2610 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2611 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2612 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2613 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
2614 { WM_DESTROY
, sent
},
2615 { WM_NCDESTROY
, sent
},
2618 /* CreateWindow for MDI child window, initially visible */
2619 static const struct message WmCreateMDIchildVisibleSeq
[] = {
2620 { HCBT_CREATEWND
, hook
},
2621 { WM_NCCREATE
, sent
},
2622 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
2623 { WM_CREATE
, sent
},
2624 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2625 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2627 /* Win2k sends wparam set to
2628 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2629 * while Win9x doesn't bother to set child window id according to
2630 * CLIENTCREATESTRUCT.idFirstChild
2632 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
2633 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
2634 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2635 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2636 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2637 { WM_MDIREFRESHMENU
, sent
/*|wparam|lparam, 0, 0*/ },
2638 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
2639 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2640 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2642 /* Win9x: message sequence terminates here. */
2644 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 },
2645 { HCBT_SETFOCUS
, hook
}, /* in MDI client */
2646 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2647 { WM_IME_NOTIFY
, sent
|wparam
|optional
, 2 }, /* in MDI client */
2648 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2649 { WM_SETFOCUS
, sent
}, /* in MDI client */
2650 { HCBT_SETFOCUS
, hook
},
2651 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2652 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2653 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
2654 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2655 { WM_SETFOCUS
, sent
|defwinproc
},
2656 { WM_MDIACTIVATE
, sent
|defwinproc
},
2659 /* WM_CHILDACTIVATE sent to disabled window */
2660 static const struct message WmChildActivateDisabledWindowSeq
[] = {
2661 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2664 /* WM_CHILDACTIVATE sent to enabled window */
2665 static const struct message WmChildActivateWindowSeq
[] = {
2666 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2667 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 0 },
2668 { WM_MDIACTIVATE
, sent
|defwinproc
},
2669 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2670 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2671 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 },
2672 { HCBT_SETFOCUS
, hook
},
2673 { WM_KILLFOCUS
, sent
|defwinproc
},
2674 { WM_SETFOCUS
, sent
},
2675 { HCBT_SETFOCUS
, hook
},
2676 { WM_KILLFOCUS
, sent
},
2677 { WM_SETFOCUS
, sent
|defwinproc
},
2678 { WM_MDIACTIVATE
, sent
|defwinproc
},
2681 /* CreateWindow for MDI child window with invisible parent */
2682 static const struct message WmCreateMDIchildInvisibleParentSeq
[] = {
2683 { HCBT_CREATEWND
, hook
},
2684 { WM_GETMINMAXINFO
, sent
},
2685 { WM_NCCREATE
, sent
},
2686 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
2687 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 },
2688 { WM_CREATE
, sent
},
2689 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2690 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2692 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
2693 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
2694 { WM_MDIREFRESHMENU
, sent
}, /* in MDI client */
2695 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
2696 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2697 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2699 /* Win9x: message sequence terminates here. */
2701 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 },
2702 { HCBT_SETFOCUS
, hook
}, /* in MDI client */
2703 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2704 { WM_IME_NOTIFY
, sent
|wparam
|optional
, 2 }, /* in MDI client */
2705 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2706 { WM_SETFOCUS
, sent
}, /* in MDI client */
2707 { HCBT_SETFOCUS
, hook
},
2708 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2709 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2710 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
2711 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2712 { WM_SETFOCUS
, sent
|defwinproc
},
2713 { WM_MDIACTIVATE
, sent
|defwinproc
},
2716 /* DestroyWindow for MDI child window, initially visible */
2717 static const struct message WmDestroyMDIchildVisibleSeq
[] = {
2718 { HCBT_DESTROYWND
, hook
},
2719 /* Win2k sends wparam set to
2720 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
2721 * while Win9x doesn't bother to set child window id according to
2722 * CLIENTCREATESTRUCT.idFirstChild
2724 { 0x0090, sent
|optional
},
2725 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_DESTROY*/ }, /* in MDI client */
2726 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
2727 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2728 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2729 { WM_ERASEBKGND
, sent
|parent
|optional
},
2730 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2732 /* { WM_DESTROY, sent }
2733 * Win9x: message sequence terminates here.
2736 { HCBT_SETFOCUS
, hook
}, /* set focus to MDI client */
2737 { WM_KILLFOCUS
, sent
},
2738 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
2739 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2740 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2741 { WM_SETFOCUS
, sent
}, /* in MDI client */
2743 { HCBT_SETFOCUS
, hook
}, /* MDI client sets focus back to MDI child */
2744 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2745 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2746 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
2747 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2748 { WM_SETFOCUS
, sent
}, /* in MDI client */
2750 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
2752 { HCBT_SETFOCUS
, hook
}, /* set focus to MDI client */
2753 { WM_KILLFOCUS
, sent
},
2754 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
2755 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2756 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2757 { WM_SETFOCUS
, sent
}, /* in MDI client */
2759 { HCBT_SETFOCUS
, hook
}, /* MDI client sets focus back to MDI child */
2760 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2761 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2762 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
2763 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2764 { WM_SETFOCUS
, sent
}, /* in MDI client */
2766 { WM_DESTROY
, sent
},
2768 { HCBT_SETFOCUS
, hook
}, /* set focus to MDI client */
2769 { WM_KILLFOCUS
, sent
},
2770 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
2771 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2772 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2773 { WM_SETFOCUS
, sent
}, /* in MDI client */
2775 { HCBT_SETFOCUS
, hook
}, /* MDI client sets focus back to MDI child */
2776 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2777 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2778 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
2779 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2780 { WM_SETFOCUS
, sent
}, /* in MDI client */
2782 { WM_NCDESTROY
, sent
},
2785 /* CreateWindow for MDI child window, initially invisible */
2786 static const struct message WmCreateMDIchildInvisibleSeq
[] = {
2787 { HCBT_CREATEWND
, hook
},
2788 { WM_NCCREATE
, sent
},
2789 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
2790 { WM_CREATE
, sent
},
2791 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2792 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2794 /* Win2k sends wparam set to
2795 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2796 * while Win9x doesn't bother to set child window id according to
2797 * CLIENTCREATESTRUCT.idFirstChild
2799 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
2802 /* DestroyWindow for MDI child window, initially invisible */
2803 static const struct message WmDestroyMDIchildInvisibleSeq
[] = {
2804 { HCBT_DESTROYWND
, hook
},
2805 /* Win2k sends wparam set to
2806 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
2807 * while Win9x doesn't bother to set child window id according to
2808 * CLIENTCREATESTRUCT.idFirstChild
2810 { 0x0090, sent
|optional
},
2811 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_DESTROY*/ }, /* in MDI client */
2812 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
2813 { WM_DESTROY
, sent
},
2814 { WM_NCDESTROY
, sent
},
2815 /* FIXME: Wine destroys an icon/title window while Windows doesn't */
2816 { WM_PARENTNOTIFY
, sent
|wparam
|optional
, WM_DESTROY
}, /* MDI client */
2819 /* CreateWindow for the 1st MDI child window, initially visible and maximized */
2820 static const struct message WmCreateMDIchildVisibleMaxSeq1
[] = {
2821 { HCBT_CREATEWND
, hook
},
2822 { WM_NCCREATE
, sent
},
2823 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
2824 { WM_CREATE
, sent
},
2825 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2826 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2828 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
2829 { WM_GETMINMAXINFO
, sent
},
2830 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_STATECHANGED
},
2831 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2832 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
2833 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2835 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2836 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2837 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2838 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2839 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2840 /* Win2k sends wparam set to
2841 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2842 * while Win9x doesn't bother to set child window id according to
2843 * CLIENTCREATESTRUCT.idFirstChild
2845 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
2846 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
2847 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2848 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2849 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2850 { WM_MDIREFRESHMENU
, sent
/*|wparam|lparam, 0, 0*/ },
2851 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
2852 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2853 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
|optional
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
, 0, SWP_FRAMECHANGED
},
2855 /* Win9x: message sequence terminates here. */
2857 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
|optional
, 1 },
2858 { HCBT_SETFOCUS
, hook
|optional
}, /* in MDI client */
2859 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2860 { WM_IME_NOTIFY
, sent
|wparam
|optional
, 2 }, /* in MDI client */
2861 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2862 { WM_SETFOCUS
, sent
|optional
}, /* in MDI client */
2863 { HCBT_SETFOCUS
, hook
|optional
},
2864 { WM_KILLFOCUS
, sent
|optional
}, /* in MDI client */
2865 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2866 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
2867 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2868 { WM_SETFOCUS
, sent
|defwinproc
|optional
},
2869 { WM_MDIACTIVATE
, sent
|defwinproc
|optional
},
2871 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2872 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2873 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2874 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2877 /* CreateWindow for the 2nd MDI child window, initially visible and maximized */
2878 static const struct message WmCreateMDIchildVisibleMaxSeq2
[] = {
2879 /* restore the 1st MDI child */
2880 { WM_SETREDRAW
, sent
|wparam
, 0 },
2881 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWNORMAL
},
2882 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
2883 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2884 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2885 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
2886 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2888 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2889 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2890 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2891 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2892 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2893 { WM_SETREDRAW
, sent
|wparam
, 1 }, /* in the 1st MDI child */
2894 /* create the 2nd MDI child */
2895 { HCBT_CREATEWND
, hook
},
2896 { WM_NCCREATE
, sent
},
2897 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
2898 { WM_CREATE
, sent
},
2899 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2900 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2902 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
2903 { WM_GETMINMAXINFO
, sent
},
2904 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_STATECHANGED
},
2905 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2906 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2907 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
2908 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2910 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2911 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2912 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2913 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2914 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2915 /* Win2k sends wparam set to
2916 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2917 * while Win9x doesn't bother to set child window id according to
2918 * CLIENTCREATESTRUCT.idFirstChild
2920 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
2921 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
2922 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2923 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2924 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2925 { WM_MDIREFRESHMENU
, sent
/*|wparam|lparam, 0, 0*/ },
2926 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
2927 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2929 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 0 }, /* in the 1st MDI child */
2930 { WM_MDIACTIVATE
, sent
|defwinproc
}, /* in the 1st MDI child */
2932 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2934 /* Win9x: message sequence terminates here. */
2936 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 },
2937 { HCBT_SETFOCUS
, hook
},
2938 { WM_KILLFOCUS
, sent
|defwinproc
|optional
}, /* in the 1st MDI child */
2939 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 0 }, /* in the 1st MDI child */
2940 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2941 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2942 { WM_SETFOCUS
, sent
}, /* in MDI client */
2943 { HCBT_SETFOCUS
, hook
},
2944 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2945 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2946 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
2947 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2948 { WM_SETFOCUS
, sent
|defwinproc
},
2950 { WM_MDIACTIVATE
, sent
|defwinproc
},
2952 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2953 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2954 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2955 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2958 /* WM_MDICREATE MDI child window, initially visible and maximized */
2959 static const struct message WmCreateMDIchildVisibleMaxSeq3
[] = {
2960 { WM_MDICREATE
, sent
},
2961 { HCBT_CREATEWND
, hook
},
2962 { WM_NCCREATE
, sent
},
2963 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
2964 { WM_CREATE
, sent
},
2965 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2966 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2968 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
2969 { WM_GETMINMAXINFO
, sent
},
2970 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_STATECHANGED
},
2971 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2972 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
2973 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2976 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2977 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2978 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2979 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2980 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2982 /* Win2k sends wparam set to
2983 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2984 * while Win9x doesn't bother to set child window id according to
2985 * CLIENTCREATESTRUCT.idFirstChild
2987 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
2988 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
2989 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2991 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2993 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2994 { WM_MDIREFRESHMENU
, sent
/*|wparam|lparam, 0, 0*/ },
2995 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
2997 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2998 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
3000 /* Win9x: message sequence terminates here. */
3002 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 },
3003 { WM_SETFOCUS
, sent
|optional
}, /* in MDI client */
3004 { HCBT_SETFOCUS
, hook
}, /* in MDI client */
3005 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
3006 { WM_IME_NOTIFY
, sent
|wparam
|optional
, 2 },
3007 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
|optional
, OBJID_CLIENT
, 0 },
3008 { WM_SETFOCUS
, sent
|optional
}, /* in MDI client */
3009 { HCBT_SETFOCUS
, hook
|optional
},
3010 { WM_KILLFOCUS
, sent
}, /* in MDI client */
3011 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
3012 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
3013 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
3014 { WM_SETFOCUS
, sent
|defwinproc
},
3016 { WM_MDIACTIVATE
, sent
|defwinproc
},
3019 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
3020 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3021 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
3022 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
3025 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
3026 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3027 { 0x0093, sent
|defwinproc
|optional
},
3028 { 0x0093, sent
|defwinproc
|optional
},
3029 { 0x0093, sent
|defwinproc
|optional
},
3030 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
3031 { WM_MOVE
, sent
|defwinproc
},
3032 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
3035 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
3036 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3037 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
},
3038 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
3041 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
3042 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3043 { 0x0093, sent
|optional
},
3044 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
},
3045 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
3047 { 0x0093, sent
|optional
},
3048 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
3049 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI client */
3050 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 }, /* XP sends it to MDI frame */
3051 { 0x0093, sent
|defwinproc
|optional
},
3052 { 0x0093, sent
|defwinproc
|optional
},
3053 { 0x0093, sent
|defwinproc
|optional
},
3054 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
3055 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* XP sends a duplicate */
3059 /* CreateWindow for the 1st MDI child window, initially invisible and maximized */
3060 static const struct message WmCreateMDIchildInvisibleMaxSeq4
[] = {
3061 { HCBT_CREATEWND
, hook
},
3062 { WM_GETMINMAXINFO
, sent
},
3063 { WM_NCCREATE
, sent
},
3064 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
3065 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
3066 { WM_CREATE
, sent
},
3067 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
3068 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
3069 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
, 0, SWP_NOZORDER
}, /* MDI frame */
3070 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 }, /* MDI frame */
3071 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
, 0, SWP_NOZORDER
}, /* MDI frame */
3073 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
3074 { WM_GETMINMAXINFO
, sent
},
3075 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_STATECHANGED
},
3076 { WM_GETMINMAXINFO
, sent
|defwinproc
},
3077 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3078 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOREDRAW
|SWP_STATECHANGED
},
3079 { WM_MOVE
, sent
|defwinproc
},
3080 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
3082 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
3083 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3084 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
3085 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
3086 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 }, /* MDI child */
3087 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
3088 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
3089 /* Win2k sends wparam set to
3090 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
3091 * while Win9x doesn't bother to set child window id according to
3092 * CLIENTCREATESTRUCT.idFirstChild
3094 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
3097 /* WM_SYSCOMMAND/SC_CLOSE for the 2nd MDI child window, initially visible and maximized */
3098 static const struct message WmDestroyMDIchildVisibleMaxSeq2
[] = {
3099 { WM_SYSCOMMAND
, sent
|wparam
, SC_CLOSE
},
3100 { HCBT_SYSCOMMAND
, hook
},
3101 { WM_CLOSE
, sent
|defwinproc
},
3102 { WM_MDIDESTROY
, sent
}, /* in MDI client */
3104 /* bring the 1st MDI child to top */
3105 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOSIZE
|SWP_NOMOVE
}, /* in the 1st MDI child */
3106 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
}, /* in the 2nd MDI child */
3108 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
3110 { WM_CHILDACTIVATE
, sent
|defwinproc
|wparam
|lparam
, 0, 0 }, /* in the 1st MDI child */
3111 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 0 }, /* in the 1st MDI child */
3112 { WM_MDIACTIVATE
, sent
|defwinproc
}, /* in the 1st MDI child */
3114 /* maximize the 1st MDI child */
3115 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
3116 { WM_GETMINMAXINFO
, sent
|defwinproc
},
3117 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
3118 { WM_NCCALCSIZE
, sent
|defwinproc
|wparam
, 1 },
3119 { WM_CHILDACTIVATE
, sent
|defwinproc
|wparam
|lparam
, 0, 0 },
3120 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
3121 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
3123 /* restore the 2nd MDI child */
3124 { WM_SETREDRAW
, sent
|defwinproc
|wparam
, 0 },
3125 { HCBT_MINMAX
, hook
|lparam
, 0, SW_NORMALNA
},
3126 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_SHOWWINDOW
|SWP_STATECHANGED
},
3127 { WM_NCCALCSIZE
, sent
|defwinproc
|wparam
, 1 },
3129 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
3131 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_SHOWWINDOW
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
3132 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
3134 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
3136 { WM_SETREDRAW
, sent
|defwinproc
|wparam
, 1 },
3138 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
3139 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3140 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
3141 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
3142 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
3144 /* bring the 1st MDI child to top */
3145 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
3146 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 },
3147 { HCBT_SETFOCUS
, hook
},
3148 { WM_KILLFOCUS
, sent
|defwinproc
},
3149 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 0 },
3150 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
3151 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
3152 { WM_SETFOCUS
, sent
}, /* in MDI client */
3153 { HCBT_SETFOCUS
, hook
},
3154 { WM_KILLFOCUS
, sent
}, /* in MDI client */
3155 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
3156 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
3157 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
3158 { WM_SETFOCUS
, sent
|defwinproc
},
3159 { WM_MDIACTIVATE
, sent
|defwinproc
},
3160 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
3162 /* apparently ShowWindow(SW_SHOW) on an MDI client */
3163 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
3164 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
3165 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
3166 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
3167 { WM_MDIREFRESHMENU
, sent
},
3169 { HCBT_DESTROYWND
, hook
},
3170 /* Win2k sends wparam set to
3171 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
3172 * while Win9x doesn't bother to set child window id according to
3173 * CLIENTCREATESTRUCT.idFirstChild
3175 { 0x0090, sent
|defwinproc
|optional
},
3176 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_DESTROY*/ }, /* in MDI client */
3177 { WM_SHOWWINDOW
, sent
|defwinproc
|wparam
, 0 },
3178 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
3179 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
3180 { WM_ERASEBKGND
, sent
|parent
|optional
},
3181 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
3183 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
3184 { WM_DESTROY
, sent
|defwinproc
},
3185 { WM_NCDESTROY
, sent
|defwinproc
},
3188 /* WM_MDIDESTROY for the single MDI child window, initially visible and maximized */
3189 static const struct message WmDestroyMDIchildVisibleMaxSeq1
[] = {
3190 { WM_MDIDESTROY
, sent
}, /* in MDI client */
3191 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
3192 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
3193 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
3194 { WM_ERASEBKGND
, sent
|parent
|optional
},
3195 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
3197 { HCBT_SETFOCUS
, hook
},
3198 { WM_KILLFOCUS
, sent
},
3199 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
3200 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
3201 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
3202 { WM_SETFOCUS
, sent
}, /* in MDI client */
3203 { HCBT_SETFOCUS
, hook
},
3204 { WM_KILLFOCUS
, sent
}, /* in MDI client */
3205 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
3206 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
3207 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
3208 { WM_SETFOCUS
, sent
},
3211 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
3212 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3213 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
3214 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
3217 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
3218 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3219 { 0x0093, sent
|defwinproc
|optional
},
3220 { 0x0093, sent
|defwinproc
|optional
},
3221 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
3222 { WM_MOVE
, sent
|defwinproc
},
3223 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
3226 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
3227 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3228 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
},
3229 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
3232 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
3233 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3234 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
},
3235 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
3238 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
3239 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 },
3240 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
3241 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
3244 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
3245 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 },
3246 { 0x0093, sent
|defwinproc
|optional
},
3247 { 0x0093, sent
|defwinproc
|optional
},
3248 { 0x0093, sent
|defwinproc
|optional
},
3249 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
3250 { WM_MOVE
, sent
|defwinproc
},
3251 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
3254 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
3255 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3256 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
},
3257 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
3260 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
},
3261 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 },
3262 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
},
3263 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
3264 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
3265 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI client */
3267 { 0x0093, sent
|defwinproc
|optional
},
3268 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
|optional
, 1 }, /* XP sends it to MDI frame */
3269 { 0x0093, sent
|defwinproc
|optional
},
3270 { 0x0093, sent
|defwinproc
|optional
},
3271 { 0x0093, sent
|defwinproc
|optional
},
3272 { 0x0093, sent
|optional
},
3274 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
3275 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
3276 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI client */
3277 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
3278 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* XP sends a duplicate */
3281 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
3282 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
3283 { 0x0093, sent
|defwinproc
|optional
},
3284 { 0x0093, sent
|defwinproc
|optional
},
3285 { 0x0093, sent
|defwinproc
|optional
},
3286 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
3287 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
3288 { 0x0093, sent
|optional
},
3290 { WM_NCACTIVATE
, sent
|wparam
, 0 },
3291 { WM_MDIACTIVATE
, sent
},
3293 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWNORMAL
},
3294 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_SHOWWINDOW
|SWP_STATECHANGED
},
3295 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3297 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
3299 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
3300 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_SHOWWINDOW
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
3301 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
3304 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
3305 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 },
3306 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
3307 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
3310 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
3311 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3312 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
3313 { WM_MOVE
, sent
|defwinproc
},
3314 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
3317 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
3318 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3319 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
},
3320 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
3321 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
3322 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 }, /* XP */
3323 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI client */
3324 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
3325 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* XP sends a duplicate */
3327 { HCBT_SETFOCUS
, hook
},
3328 { WM_KILLFOCUS
, sent
},
3329 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
3330 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
3331 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
3332 { WM_SETFOCUS
, sent
}, /* in MDI client */
3334 { WM_MDIREFRESHMENU
, sent
}, /* in MDI client */
3336 { HCBT_DESTROYWND
, hook
},
3337 /* Win2k sends wparam set to
3338 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
3339 * while Win9x doesn't bother to set child window id according to
3340 * CLIENTCREATESTRUCT.idFirstChild
3342 { 0x0090, sent
|optional
},
3343 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_DESTROY*/ }, /* in MDI client */
3345 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
3346 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
3347 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
3348 { WM_ERASEBKGND
, sent
|parent
|optional
},
3349 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
3351 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
3352 { WM_DESTROY
, sent
},
3353 { WM_NCDESTROY
, sent
},
3356 /* ShowWindow(SW_MAXIMIZE) for a not visible MDI child window */
3357 static const struct message WmMaximizeMDIchildInvisibleSeq
[] = {
3358 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
3359 { WM_GETMINMAXINFO
, sent
},
3360 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_STATECHANGED
},
3361 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3362 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
3363 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
3365 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
3366 { WM_NCACTIVATE
, sent
|wparam
|optional
|defwinproc
, 1 },
3367 { HCBT_SETFOCUS
, hook
|optional
},
3368 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
3369 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
3370 { WM_SETFOCUS
, sent
|optional
}, /* in MDI client */
3371 { HCBT_SETFOCUS
, hook
|optional
},
3372 { WM_KILLFOCUS
, sent
|optional
}, /* in MDI client */
3373 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
3374 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
3375 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
3376 { WM_SETFOCUS
, sent
|optional
|defwinproc
},
3377 { WM_MDIACTIVATE
, sent
|optional
|defwinproc
},
3378 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
3379 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
3381 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
3382 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3383 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
3384 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
3385 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
3388 /* ShowWindow(SW_MAXIMIZE) for a not visible maximized MDI child window */
3389 static const struct message WmMaximizeMDIchildInvisibleSeq2
[] = {
3390 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
3391 { WM_GETMINMAXINFO
, sent
},
3392 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
},
3393 { WM_GETMINMAXINFO
, sent
|defwinproc
},
3394 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3395 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
3396 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
3398 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
|optional
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
3399 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
|optional
, 1 },
3400 { HCBT_SETFOCUS
, hook
|optional
},
3401 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
3402 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
3403 { WM_SETFOCUS
, sent
|optional
}, /* in MDI client */
3404 { HCBT_SETFOCUS
, hook
|optional
},
3405 { WM_KILLFOCUS
, sent
|optional
}, /* in MDI client */
3406 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
3407 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
3408 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
3409 { WM_SETFOCUS
, sent
|defwinproc
|optional
},
3410 { WM_MDIACTIVATE
, sent
|defwinproc
|optional
},
3411 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
3412 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
3415 /* WM_MDIMAXIMIZE for an MDI child window with invisible parent */
3416 static const struct message WmMaximizeMDIchildInvisibleParentSeq
[] = {
3417 { WM_MDIMAXIMIZE
, sent
}, /* in MDI client */
3418 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
3419 { WM_GETMINMAXINFO
, sent
},
3420 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
3421 { WM_GETMINMAXINFO
, sent
|defwinproc
},
3422 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3423 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* XP doesn't send it */
3424 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
3425 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOREDRAW
|SWP_STATECHANGED
},
3426 { WM_MOVE
, sent
|defwinproc
},
3427 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
3429 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
3430 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 },
3431 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
3432 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
|optional
, 1 },
3433 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI child XP */
3434 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI client XP */
3436 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
3437 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3438 { 0x0093, sent
|defwinproc
|optional
},
3439 { 0x0094, sent
|defwinproc
|optional
},
3440 { 0x0094, sent
|defwinproc
|optional
},
3441 { 0x0094, sent
|defwinproc
|optional
},
3442 { 0x0094, sent
|defwinproc
|optional
},
3443 { 0x0093, sent
|defwinproc
|optional
},
3444 { 0x0093, sent
|defwinproc
|optional
},
3445 { 0x0091, sent
|defwinproc
|optional
},
3446 { 0x0092, sent
|defwinproc
|optional
},
3447 { 0x0092, sent
|defwinproc
|optional
},
3448 { 0x0092, sent
|defwinproc
|optional
},
3449 { 0x0092, sent
|defwinproc
|optional
},
3450 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
3451 { WM_MOVE
, sent
|defwinproc
},
3452 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
3453 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI frame win2000 */
3455 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
3456 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3457 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
},
3458 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
3460 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
},
3461 { WM_GETMINMAXINFO
, sent
|defwinproc
},
3462 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 },
3463 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
},
3464 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
3465 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI child win2000 */
3466 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
|optional
, 1 },
3467 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI child XP */
3468 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI child XP */
3469 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI client XP */
3471 { 0x0093, sent
|optional
},
3472 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
3473 { 0x0093, sent
|defwinproc
|optional
},
3474 { 0x0093, sent
|defwinproc
|optional
},
3475 { 0x0093, sent
|defwinproc
|optional
},
3476 { 0x0091, sent
|defwinproc
|optional
},
3477 { 0x0092, sent
|defwinproc
|optional
},
3478 { 0x0092, sent
|defwinproc
|optional
},
3479 { 0x0092, sent
|defwinproc
|optional
},
3480 { 0x0092, sent
|defwinproc
|optional
},
3481 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI frame XP */
3482 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI frame XP */
3483 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI child XP */
3486 /* ShowWindow(SW_MAXIMIZE) for a visible MDI child window */
3487 static const struct message WmMaximizeMDIchildVisibleSeq
[] = {
3488 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
3489 { WM_GETMINMAXINFO
, sent
},
3490 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
3491 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3492 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
3493 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
3494 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
3496 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
3497 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3498 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
3499 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
3500 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
3503 /* ShowWindow(SW_RESTORE) for a visible maximized MDI child window */
3504 static const struct message WmRestoreMDIchildVisibleSeq
[] = {
3505 { HCBT_MINMAX
, hook
|lparam
, 0, SW_RESTORE
},
3506 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
3507 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3508 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
3509 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
3510 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
3512 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
3513 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3514 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
3515 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
3516 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
3519 /* ShowWindow(SW_RESTORE) for a visible minimized MDI child window */
3520 static const struct message WmRestoreMDIchildVisibleSeq_2
[] = {
3521 { HCBT_MINMAX
, hook
|lparam
, 0, SW_RESTORE
},
3522 { WM_QUERYOPEN
, sent
|wparam
|lparam
, 0, 0 },
3523 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
3524 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3525 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
3526 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
3527 { WM_MOVE
, sent
|defwinproc
},
3528 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
3529 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
3530 { EVENT_SYSTEM_MINIMIZEEND
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
3531 { HCBT_SETFOCUS
, hook
},
3532 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
3533 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
3534 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
3535 { WM_SETFOCUS
, sent
},
3538 /* ShowWindow(SW_MINIMIZE) for a visible restored MDI child window */
3539 static const struct message WmMinimizeMDIchildVisibleSeq
[] = {
3540 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
3541 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
3542 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3543 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
3544 { WM_MOVE
, sent
|defwinproc
},
3545 { WM_SIZE
, sent
|defwinproc
|wparam
|lparam
, SIZE_MINIMIZED
, 0 },
3546 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
|defwinproc
, 0, 0 },
3547 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
3548 { EVENT_SYSTEM_MINIMIZESTART
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
3549 /* FIXME: Wine creates an icon/title window while Windows doesn't */
3550 { WM_PARENTNOTIFY
, sent
|parent
|wparam
|optional
, WM_CREATE
}, /* MDI client */
3553 /* ShowWindow(SW_RESTORE) for a not visible MDI child window */
3554 static const struct message WmRestoreMDIchildInvisibleSeq
[] = {
3555 { HCBT_MINMAX
, hook
|lparam
, 0, SW_RESTORE
},
3556 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_STATECHANGED
},
3557 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3558 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
3559 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
3560 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
3561 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
3563 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
3564 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3565 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
3566 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
3567 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
3571 static HWND mdi_client
;
3572 static WNDPROC old_mdi_client_proc
;
3574 static LRESULT WINAPI
mdi_client_hook_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
3576 struct recvd_message msg
;
3578 /* do not log painting messages */
3579 if (message
!= WM_PAINT
&&
3580 message
!= WM_NCPAINT
&&
3581 message
!= WM_SYNCPAINT
&&
3582 message
!= WM_ERASEBKGND
&&
3583 message
!= WM_NCHITTEST
&&
3584 message
!= WM_GETTEXT
&&
3585 message
!= WM_MDIGETACTIVE
&&
3586 !ignore_message( message
))
3589 msg
.message
= message
;
3590 msg
.flags
= sent
|wparam
|lparam
;
3591 msg
.wParam
= wParam
;
3592 msg
.lParam
= lParam
;
3593 msg
.descr
= "mdi client";
3597 return CallWindowProcA(old_mdi_client_proc
, hwnd
, message
, wParam
, lParam
);
3600 static LRESULT WINAPI
mdi_child_wnd_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
3602 static LONG defwndproc_counter
= 0;
3604 struct recvd_message msg
;
3606 /* do not log painting messages */
3607 if (message
!= WM_PAINT
&&
3608 message
!= WM_NCPAINT
&&
3609 message
!= WM_SYNCPAINT
&&
3610 message
!= WM_ERASEBKGND
&&
3611 message
!= WM_NCHITTEST
&&
3612 message
!= WM_GETTEXT
&&
3613 !ignore_message( message
))
3617 case WM_MDIACTIVATE
:
3619 HWND active
, client
= GetParent(hwnd
);
3621 active
= (HWND
)SendMessageA(client
, WM_MDIGETACTIVE
, 0, 0);
3623 if (hwnd
== (HWND
)lParam
) /* if we are being activated */
3624 ok (active
== (HWND
)lParam
, "new active %p != active %p\n", (HWND
)lParam
, active
);
3626 ok (active
== (HWND
)wParam
, "old active %p != active %p\n", (HWND
)wParam
, active
);
3632 msg
.message
= message
;
3633 msg
.flags
= sent
|wparam
|lparam
;
3634 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
3635 msg
.wParam
= wParam
;
3636 msg
.lParam
= lParam
;
3637 msg
.descr
= "mdi child";
3641 defwndproc_counter
++;
3642 ret
= DefMDIChildProcA(hwnd
, message
, wParam
, lParam
);
3643 defwndproc_counter
--;
3648 static LRESULT WINAPI
mdi_frame_wnd_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
3650 static LONG defwndproc_counter
= 0;
3652 struct recvd_message msg
;
3654 /* do not log painting messages */
3655 if (message
!= WM_PAINT
&&
3656 message
!= WM_NCPAINT
&&
3657 message
!= WM_SYNCPAINT
&&
3658 message
!= WM_ERASEBKGND
&&
3659 message
!= WM_NCHITTEST
&&
3660 message
!= WM_GETTEXT
&&
3661 !ignore_message( message
))
3664 msg
.message
= message
;
3665 msg
.flags
= sent
|wparam
|lparam
;
3666 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
3667 msg
.wParam
= wParam
;
3668 msg
.lParam
= lParam
;
3669 msg
.descr
= "mdi frame";
3673 defwndproc_counter
++;
3674 ret
= DefFrameProcA(hwnd
, mdi_client
, message
, wParam
, lParam
);
3675 defwndproc_counter
--;
3680 static BOOL
mdi_RegisterWindowClasses(void)
3685 cls
.lpfnWndProc
= mdi_frame_wnd_proc
;
3688 cls
.hInstance
= GetModuleHandleA(0);
3690 cls
.hCursor
= LoadCursorA(0, (LPCSTR
)IDC_ARROW
);
3691 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
3692 cls
.lpszMenuName
= NULL
;
3693 cls
.lpszClassName
= "MDI_frame_class";
3694 if (!RegisterClassA(&cls
)) return FALSE
;
3696 cls
.lpfnWndProc
= mdi_child_wnd_proc
;
3697 cls
.lpszClassName
= "MDI_child_class";
3698 if (!RegisterClassA(&cls
)) return FALSE
;
3700 if (!GetClassInfoA(0, "MDIClient", &cls
)) assert(0);
3701 old_mdi_client_proc
= cls
.lpfnWndProc
;
3702 cls
.hInstance
= GetModuleHandleA(0);
3703 cls
.lpfnWndProc
= mdi_client_hook_proc
;
3704 cls
.lpszClassName
= "MDI_client_class";
3705 if (!RegisterClassA(&cls
)) assert(0);
3710 static void test_mdi_messages(void)
3712 MDICREATESTRUCTA mdi_cs
;
3713 CLIENTCREATESTRUCT client_cs
;
3714 HWND mdi_frame
, mdi_child
, mdi_child2
, active_child
;
3717 HMENU hMenu
= CreateMenu();
3720 if (!mdi_RegisterWindowClasses()) assert(0);
3724 trace("creating MDI frame window\n");
3725 mdi_frame
= CreateWindowExA(0, "MDI_frame_class", "MDI frame window",
3726 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
|
3727 WS_MAXIMIZEBOX
| WS_VISIBLE
,
3728 100, 100, CW_USEDEFAULT
, CW_USEDEFAULT
,
3729 GetDesktopWindow(), hMenu
,
3730 GetModuleHandleA(0), NULL
);
3732 ok_sequence(WmCreateMDIframeSeq
, "Create MDI frame window", FALSE
);
3734 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3735 ok(GetFocus() == mdi_frame
, "wrong focus window %p\n", GetFocus());
3737 trace("creating MDI client window\n");
3738 GetClientRect(mdi_frame
, &rc
);
3739 client_cs
.hWindowMenu
= 0;
3740 client_cs
.idFirstChild
= MDI_FIRST_CHILD_ID
;
3741 mdi_client
= CreateWindowExA(0, "MDI_client_class",
3743 WS_CHILD
| WS_VISIBLE
| MDIS_ALLCHILDSTYLES
,
3744 rc
.left
, rc
.top
, rc
.right
- rc
.left
, rc
.bottom
- rc
.top
,
3745 mdi_frame
, 0, GetModuleHandleA(0), &client_cs
);
3747 SetWindowLongA(mdi_client
, 0, 0xdeadbeef);
3749 ok_sequence(WmCreateMDIclientSeq
, "Create visible MDI client window", FALSE
);
3750 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3751 ok(GetFocus() == mdi_frame
, "input focus should be on MDI frame not on %p\n", GetFocus());
3753 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3754 ok(!active_child
, "wrong active MDI child %p\n", active_child
);
3755 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
3760 trace("creating invisible MDI child window\n");
3761 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3763 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
3764 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3768 ShowWindow(mdi_child
, SW_SHOWNORMAL
);
3769 ok_sequence(WmShowChildSeq
, "ShowWindow(SW_SHOWNORMAL) MDI child window", FALSE
);
3771 ok(GetWindowLongA(mdi_child
, GWL_STYLE
) & WS_VISIBLE
, "MDI child should be visible\n");
3772 ok(IsWindowVisible(mdi_child
), "MDI child should be visible\n");
3774 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3775 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3777 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3778 ok(!active_child
, "wrong active MDI child %p\n", active_child
);
3779 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
3781 ShowWindow(mdi_child
, SW_HIDE
);
3782 ok_sequence(WmHideChildSeq
, "ShowWindow(SW_HIDE) MDI child window", FALSE
);
3785 ShowWindow(mdi_child
, SW_SHOW
);
3786 ok_sequence(WmShowChildSeq
, "ShowWindow(SW_SHOW) MDI child window", FALSE
);
3788 ok(GetWindowLongA(mdi_child
, GWL_STYLE
) & WS_VISIBLE
, "MDI child should be visible\n");
3789 ok(IsWindowVisible(mdi_child
), "MDI child should be visible\n");
3791 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3792 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3794 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3795 ok(!active_child
, "wrong active MDI child %p\n", active_child
);
3796 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
3798 DestroyWindow(mdi_child
);
3801 trace("creating visible MDI child window\n");
3802 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3803 WS_CHILD
| WS_VISIBLE
,
3804 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
3805 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3807 ok_sequence(WmCreateMDIchildVisibleSeq
, "Create visible MDI child window", FALSE
);
3809 ok(GetWindowLongA(mdi_child
, GWL_STYLE
) & WS_VISIBLE
, "MDI child should be visible\n");
3810 ok(IsWindowVisible(mdi_child
), "MDI child should be visible\n");
3812 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3813 ok(GetFocus() == mdi_child
, "wrong focus window %p\n", GetFocus());
3815 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3816 ok(active_child
== mdi_child
, "wrong active MDI child %p\n", active_child
);
3817 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
3820 DestroyWindow(mdi_child
);
3821 ok_sequence(WmDestroyMDIchildVisibleSeq
, "Destroy visible MDI child window", TRUE
);
3823 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3824 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3826 /* Win2k: MDI client still returns a just destroyed child as active
3827 * Win9x: MDI client returns 0
3829 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3830 ok(active_child
== mdi_child
|| /* win2k */
3831 !active_child
, /* win9x */
3832 "wrong active MDI child %p\n", active_child
);
3833 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
3837 trace("creating invisible MDI child window\n");
3838 mdi_child2
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3840 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
3841 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3843 ok_sequence(WmCreateMDIchildInvisibleSeq
, "Create invisible MDI child window", FALSE
);
3845 ok(!(GetWindowLongA(mdi_child2
, GWL_STYLE
) & WS_VISIBLE
), "MDI child should not be visible\n");
3846 ok(!IsWindowVisible(mdi_child2
), "MDI child should not be visible\n");
3848 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3849 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3851 /* Win2k: MDI client still returns a just destroyed child as active
3852 * Win9x: MDI client returns mdi_child2
3854 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3855 ok(active_child
== mdi_child
|| /* win2k */
3856 active_child
== mdi_child2
, /* win9x */
3857 "wrong active MDI child %p\n", active_child
);
3858 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
3861 ShowWindow(mdi_child2
, SW_MAXIMIZE
);
3862 ok_sequence(WmMaximizeMDIchildInvisibleSeq
, "ShowWindow(SW_MAXIMIZE):invisible MDI child", FALSE
);
3864 ok(GetWindowLongA(mdi_child2
, GWL_STYLE
) & WS_VISIBLE
, "MDI child should be visible\n");
3865 ok(IsWindowVisible(mdi_child2
), "MDI child should be visible\n");
3867 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3868 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
3869 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
3872 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3873 ok(GetFocus() == mdi_child2
|| /* win2k */
3874 GetFocus() == 0, /* win9x */
3875 "wrong focus window %p\n", GetFocus());
3880 ShowWindow(mdi_child2
, SW_HIDE
);
3881 ok_sequence(WmHideChildSeq
, "ShowWindow(SW_HIDE):MDI child", FALSE
);
3883 ShowWindow(mdi_child2
, SW_RESTORE
);
3884 ok_sequence(WmRestoreMDIchildInvisibleSeq
, "ShowWindow(SW_RESTORE):invisible MDI child", FALSE
);
3887 ok(GetWindowLongA(mdi_child2
, GWL_STYLE
) & WS_VISIBLE
, "MDI child should be visible\n");
3888 ok(IsWindowVisible(mdi_child2
), "MDI child should be visible\n");
3890 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3891 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
3892 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
3898 ShowWindow(mdi_child2
, SW_HIDE
);
3899 ok_sequence(WmHideChildSeq
, "ShowWindow(SW_HIDE):MDI child", FALSE
);
3901 ShowWindow(mdi_child2
, SW_SHOW
);
3902 ok_sequence(WmShowChildSeq
, "ShowWindow(SW_SHOW):MDI child", FALSE
);
3904 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3905 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3907 ShowWindow(mdi_child2
, SW_MAXIMIZE
);
3908 ok_sequence(WmMaximizeMDIchildVisibleSeq
, "ShowWindow(SW_MAXIMIZE):MDI child", FALSE
);
3910 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3911 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3913 ShowWindow(mdi_child2
, SW_RESTORE
);
3914 ok_sequence(WmRestoreMDIchildVisibleSeq
, "ShowWindow(SW_RESTORE):maximized MDI child", FALSE
);
3916 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3917 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3919 ShowWindow(mdi_child2
, SW_MINIMIZE
);
3920 ok_sequence(WmMinimizeMDIchildVisibleSeq
, "ShowWindow(SW_MINIMIZE):MDI child", TRUE
);
3922 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3923 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3925 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3926 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
3927 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
3930 ShowWindow(mdi_child2
, SW_RESTORE
);
3931 ok_sequence(WmRestoreMDIchildVisibleSeq_2
, "ShowWindow(SW_RESTORE):minimized MDI child", FALSE
);
3933 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3934 ok(GetFocus() == mdi_child2
, "wrong focus window %p\n", GetFocus());
3936 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3937 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
3938 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
3944 ShowWindow(mdi_child2
, SW_HIDE
);
3945 ok_sequence(WmHideChildSeq
, "ShowWindow(SW_HIDE):MDI child", FALSE
);
3947 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3948 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3950 DestroyWindow(mdi_child2
);
3951 ok_sequence(WmDestroyMDIchildInvisibleSeq
, "Destroy invisible MDI child window", FALSE
);
3953 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3954 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3956 trace("Testing WM_CHILDACTIVATE\n");
3958 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3959 WS_CHILD
| WS_VISIBLE
| WS_MAXIMIZEBOX
| WS_DISABLED
,
3960 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
3961 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3963 mdi_child2
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3964 WS_CHILD
| WS_VISIBLE
| WS_MAXIMIZEBOX
,
3965 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
3966 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3968 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3969 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
3970 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
3973 SendMessageW(mdi_child
, WM_CHILDACTIVATE
, 0, 0);
3974 ok_sequence(WmChildActivateDisabledWindowSeq
, "WM_CHILDACTIVATE sent to disabled window", FALSE
);
3976 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3977 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
3978 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
3981 EnableWindow(mdi_child
, TRUE
);
3983 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3984 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
3985 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
3988 SendMessageW(mdi_child
, WM_CHILDACTIVATE
, 0, 0);
3989 ok_sequence(WmChildActivateWindowSeq
, "WM_CHILDACTIVATE sent to enabled window", FALSE
);
3991 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3992 ok(active_child
== mdi_child
, "wrong active MDI child %p\n", active_child
);
3993 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
3996 DestroyWindow(mdi_child
);
3997 DestroyWindow(mdi_child2
);
4000 /* test for maximized MDI children */
4001 trace("creating maximized visible MDI child window 1\n");
4002 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
4003 WS_CHILD
| WS_VISIBLE
| WS_MAXIMIZEBOX
| WS_MAXIMIZE
,
4004 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
4005 mdi_client
, 0, GetModuleHandleA(0), NULL
);
4007 ok_sequence(WmCreateMDIchildVisibleMaxSeq1
, "Create maximized visible 1st MDI child window", TRUE
);
4008 ok(IsZoomed(mdi_child
), "1st MDI child should be maximized\n");
4010 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
4011 ok(GetFocus() == mdi_child
|| /* win2k */
4012 GetFocus() == 0, /* win9x */
4013 "wrong focus window %p\n", GetFocus());
4015 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
4016 ok(active_child
== mdi_child
, "wrong active MDI child %p\n", active_child
);
4017 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
4020 trace("creating maximized visible MDI child window 2\n");
4021 mdi_child2
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
4022 WS_CHILD
| WS_VISIBLE
| WS_MAXIMIZEBOX
| WS_MAXIMIZE
,
4023 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
4024 mdi_client
, 0, GetModuleHandleA(0), NULL
);
4026 ok_sequence(WmCreateMDIchildVisibleMaxSeq2
, "Create maximized visible 2nd MDI child 2 window", TRUE
);
4027 ok(IsZoomed(mdi_child2
), "2nd MDI child should be maximized\n");
4028 ok(!IsZoomed(mdi_child
), "1st MDI child should NOT be maximized\n");
4030 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
4031 ok(GetFocus() == mdi_child2
, "wrong focus window %p\n", GetFocus());
4033 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
4034 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
4035 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
4038 trace("destroying maximized visible MDI child window 2\n");
4039 DestroyWindow(mdi_child2
);
4040 ok_sequence(WmDestroyMDIchildVisibleSeq
, "Destroy visible MDI child window", TRUE
);
4042 ok(!IsZoomed(mdi_child
), "1st MDI child should NOT be maximized\n");
4044 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
4045 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
4047 /* Win2k: MDI client still returns a just destroyed child as active
4048 * Win9x: MDI client returns 0
4050 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
4051 ok(active_child
== mdi_child2
|| /* win2k */
4052 !active_child
, /* win9x */
4053 "wrong active MDI child %p\n", active_child
);
4056 ShowWindow(mdi_child
, SW_MAXIMIZE
);
4057 ok(IsZoomed(mdi_child
), "1st MDI child should be maximized\n");
4060 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
4061 ok(GetFocus() == mdi_child
, "wrong focus window %p\n", GetFocus());
4063 trace("re-creating maximized visible MDI child window 2\n");
4064 mdi_child2
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
4065 WS_CHILD
| WS_VISIBLE
| WS_MAXIMIZEBOX
| WS_MAXIMIZE
,
4066 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
4067 mdi_client
, 0, GetModuleHandleA(0), NULL
);
4069 ok_sequence(WmCreateMDIchildVisibleMaxSeq2
, "Create maximized visible 2nd MDI child 2 window", TRUE
);
4070 ok(IsZoomed(mdi_child2
), "2nd MDI child should be maximized\n");
4071 ok(!IsZoomed(mdi_child
), "1st MDI child should NOT be maximized\n");
4073 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
4074 ok(GetFocus() == mdi_child2
, "wrong focus window %p\n", GetFocus());
4076 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
4077 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
4078 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
4081 SendMessageA(mdi_child2
, WM_SYSCOMMAND
, SC_CLOSE
, 0);
4082 ok_sequence(WmDestroyMDIchildVisibleMaxSeq2
, "WM_SYSCOMMAND/SC_CLOSE on a visible maximized MDI child window", TRUE
);
4083 ok(!IsWindow(mdi_child2
), "MDI child 2 should be destroyed\n");
4085 ok(IsZoomed(mdi_child
), "1st MDI child should be maximized\n");
4086 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
4087 ok(GetFocus() == mdi_child
, "wrong focus window %p\n", GetFocus());
4089 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
4090 ok(active_child
== mdi_child
, "wrong active MDI child %p\n", active_child
);
4091 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
4094 DestroyWindow(mdi_child
);
4095 ok_sequence(WmDestroyMDIchildVisibleSeq
, "Destroy visible MDI child window", TRUE
);
4097 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
4098 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
4100 /* Win2k: MDI client still returns a just destroyed child as active
4101 * Win9x: MDI client returns 0
4103 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
4104 ok(active_child
== mdi_child
|| /* win2k */
4105 !active_child
, /* win9x */
4106 "wrong active MDI child %p\n", active_child
);
4109 trace("creating maximized invisible MDI child window\n");
4110 mdi_child2
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
4111 WS_CHILD
| WS_MAXIMIZE
| WS_CAPTION
| WS_THICKFRAME
,
4112 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
4113 mdi_client
, 0, GetModuleHandleA(0), NULL
);
4115 ok_sequence(WmCreateMDIchildInvisibleMaxSeq4
, "Create maximized invisible MDI child window", FALSE
);
4116 ok(IsZoomed(mdi_child2
), "MDI child should be maximized\n");
4117 ok(!(GetWindowLongA(mdi_child2
, GWL_STYLE
) & WS_VISIBLE
), "MDI child should be not visible\n");
4118 ok(!IsWindowVisible(mdi_child2
), "MDI child should be not visible\n");
4120 /* Win2k: MDI client still returns a just destroyed child as active
4121 * Win9x: MDI client returns 0
4123 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
4124 ok(active_child
== mdi_child
|| /* win2k */
4125 !active_child
|| active_child
== mdi_child2
, /* win9x */
4126 "wrong active MDI child %p\n", active_child
);
4129 trace("call ShowWindow(mdi_child, SW_MAXIMIZE)\n");
4130 ShowWindow(mdi_child2
, SW_MAXIMIZE
);
4131 ok_sequence(WmMaximizeMDIchildInvisibleSeq2
, "ShowWindow(SW_MAXIMIZE):invisible maximized MDI child", FALSE
);
4132 ok(IsZoomed(mdi_child2
), "MDI child should be maximized\n");
4133 ok(GetWindowLongA(mdi_child2
, GWL_STYLE
) & WS_VISIBLE
, "MDI child should be visible\n");
4134 ok(IsWindowVisible(mdi_child2
), "MDI child should be visible\n");
4136 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
4137 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
4138 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
4141 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child2
, 0);
4144 /* end of test for maximized MDI children */
4147 trace("creating maximized visible MDI child window 1(Switch test)\n");
4148 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
4149 WS_CHILD
| WS_VISIBLE
| WS_MAXIMIZEBOX
| WS_MAXIMIZE
,
4150 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
4151 mdi_client
, 0, GetModuleHandleA(0), NULL
);
4153 ok_sequence(WmCreateMDIchildVisibleMaxSeq1
, "Create maximized visible 1st MDI child window(Switch test)", TRUE
);
4154 ok(IsZoomed(mdi_child
), "1st MDI child should be maximized(Switch test)\n");
4156 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p(Switch test)\n", GetActiveWindow());
4157 ok(GetFocus() == mdi_child
|| /* win2k */
4158 GetFocus() == 0, /* win9x */
4159 "wrong focus window %p(Switch test)\n", GetFocus());
4161 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
4162 ok(active_child
== mdi_child
, "wrong active MDI child %p(Switch test)\n", active_child
);
4163 ok(zoomed
, "wrong zoomed state %d(Switch test)\n", zoomed
);
4166 trace("creating maximized visible MDI child window 2(Switch test)\n");
4167 mdi_child2
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
4168 WS_CHILD
| WS_VISIBLE
| WS_MAXIMIZEBOX
| WS_MAXIMIZE
,
4169 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
4170 mdi_client
, 0, GetModuleHandleA(0), NULL
);
4172 ok_sequence(WmCreateMDIchildVisibleMaxSeq2
, "Create maximized visible 2nd MDI child window (Switch test)", TRUE
);
4174 ok(IsZoomed(mdi_child2
), "2nd MDI child should be maximized(Switch test)\n");
4175 ok(!IsZoomed(mdi_child
), "1st MDI child should NOT be maximized(Switch test)\n");
4177 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p(Switch test)\n", GetActiveWindow());
4178 ok(GetFocus() == mdi_child2
, "wrong focus window %p(Switch test)\n", GetFocus());
4180 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
4181 ok(active_child
== mdi_child2
, "wrong active MDI child %p(Switch test)\n", active_child
);
4182 ok(zoomed
, "wrong zoomed state %d(Switch test)\n", zoomed
);
4185 trace("Switch child window.\n");
4186 SendMessageA(mdi_client
, WM_MDIACTIVATE
, (WPARAM
)mdi_child
, 0);
4187 ok_sequence(WmSwitchChild
, "Child did not switch correctly", TRUE
);
4188 trace("end of test for switch maximized MDI children\n");
4191 /* Prepare for switching test of not maximized MDI children */
4192 ShowWindow( mdi_child
, SW_NORMAL
);
4193 ok(!IsZoomed(mdi_child
), "wrong zoomed state for %p(Switch test)\n", mdi_child
);
4194 ok(!IsZoomed(mdi_child2
), "wrong zoomed state for %p(Switch test)\n", mdi_child2
);
4195 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, 0);
4196 ok(active_child
== mdi_child
, "wrong active MDI child %p(Switch test)\n", active_child
);
4199 SendMessageA(mdi_client
, WM_MDIACTIVATE
, (WPARAM
)mdi_child2
, 0);
4200 ok_sequence(WmSwitchNotMaximizedChild
, "Not maximized child did not switch correctly", FALSE
);
4201 trace("end of test for switch not maximized MDI children\n");
4204 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
4207 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child2
, 0);
4212 /* end of tests for switch maximized/not maximized MDI children */
4214 mdi_cs
.szClass
= "MDI_child_Class";
4215 mdi_cs
.szTitle
= "MDI child";
4216 mdi_cs
.hOwner
= GetModuleHandleA(0);
4219 mdi_cs
.cx
= CW_USEDEFAULT
;
4220 mdi_cs
.cy
= CW_USEDEFAULT
;
4221 mdi_cs
.style
= WS_CHILD
| WS_SYSMENU
| WS_VISIBLE
| WS_MAXIMIZEBOX
| WS_MAXIMIZE
;
4223 mdi_child
= (HWND
)SendMessageA(mdi_client
, WM_MDICREATE
, 0, (LPARAM
)&mdi_cs
);
4224 ok(mdi_child
!= 0, "MDI child creation failed\n");
4225 ok_sequence(WmCreateMDIchildVisibleMaxSeq3
, "WM_MDICREATE for maximized visible MDI child window", TRUE
);
4227 ok(GetMenuItemID(hMenu
, GetMenuItemCount(hMenu
) - 1) == SC_CLOSE
, "SC_CLOSE menu item not found\n");
4229 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
4230 ok(active_child
== mdi_child
, "wrong active MDI child %p\n", active_child
);
4232 ok(IsZoomed(mdi_child
), "MDI child should be maximized\n");
4233 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
4234 ok(GetFocus() == mdi_child
, "wrong focus window %p\n", GetFocus());
4236 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
4237 ok(active_child
== mdi_child
, "wrong active MDI child %p\n", active_child
);
4238 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
4241 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
4242 ok_sequence(WmDestroyMDIchildVisibleMaxSeq1
, "Destroy visible maximized MDI child window", TRUE
);
4244 ok(!IsWindow(mdi_child
), "MDI child should be destroyed\n");
4245 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
4246 ok(!active_child
, "wrong active MDI child %p\n", active_child
);
4251 val
= GetWindowLongA(mdi_client
, 0);
4252 ok(val
== 0xdeadbeef || broken(val
== 0) /* >= Win Vista */, "Expected 0xdeadbeef, got 0x%x\n", val
);
4253 DestroyWindow(mdi_client
);
4254 ok_sequence(WmDestroyMDIclientSeq
, "Destroy MDI client window", FALSE
);
4256 /* test maximization of MDI child with invisible parent */
4257 client_cs
.hWindowMenu
= 0;
4258 mdi_client
= CreateWindowA("MDI_client_class",
4260 WS_CHILD
| WS_CLIPCHILDREN
| WS_VSCROLL
| WS_HSCROLL
| WS_VISIBLE
,
4262 mdi_frame
, 0, GetModuleHandleA(0), &client_cs
);
4263 ok_sequence(WmCreateMDIclientSeq
, "Create MDI client window", FALSE
);
4265 ShowWindow(mdi_client
, SW_HIDE
);
4266 ok_sequence(WmHideMDIclientSeq
, "Hide MDI client window", FALSE
);
4268 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
4269 WS_CHILD
| WS_CLIPCHILDREN
| WS_VSCROLL
| WS_HSCROLL
,
4271 mdi_client
, 0, GetModuleHandleA(0), NULL
);
4272 ok_sequence(WmCreateMDIchildInvisibleParentSeq
, "Create MDI child window with invisible parent", FALSE
);
4274 SendMessageA(mdi_client
, WM_MDIMAXIMIZE
, (WPARAM
) mdi_child
, 0);
4275 ok_sequence(WmMaximizeMDIchildInvisibleParentSeq
, "Maximize MDI child window with invisible parent", TRUE
);
4276 zoomed
= IsZoomed(mdi_child
);
4277 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
4279 ShowWindow(mdi_client
, SW_SHOW
);
4280 ok_sequence(WmShowMDIclientSeq
, "Show MDI client window", FALSE
);
4282 DestroyWindow(mdi_child
);
4283 ok_sequence(WmDestroyMDIchildVisibleSeq
, "Destroy visible maximized MDI child window", TRUE
);
4285 /* end of test for maximization of MDI child with invisible parent */
4287 DestroyWindow(mdi_client
);
4288 ok_sequence(WmDestroyMDIclientSeq
, "Destroy MDI client window", FALSE
);
4290 DestroyWindow(mdi_frame
);
4291 ok_sequence(WmDestroyMDIframeSeq
, "Destroy MDI frame window", FALSE
);
4293 /************************* End of MDI test **********************************/
4295 static void test_WM_SETREDRAW(HWND hwnd
)
4297 DWORD style
= GetWindowLongA(hwnd
, GWL_STYLE
);
4302 SendMessageA(hwnd
, WM_SETREDRAW
, FALSE
, 0);
4303 ok_sequence(WmSetRedrawFalseSeq
, "SetRedraw:FALSE", FALSE
);
4305 ok(!(GetWindowLongA(hwnd
, GWL_STYLE
) & WS_VISIBLE
), "WS_VISIBLE should NOT be set\n");
4306 ok(!IsWindowVisible(hwnd
), "IsWindowVisible() should return FALSE\n");
4309 SendMessageA(hwnd
, WM_SETREDRAW
, TRUE
, 0);
4310 ok_sequence(WmSetRedrawTrueSeq
, "SetRedraw:TRUE", FALSE
);
4312 ok(GetWindowLongA(hwnd
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
4313 ok(IsWindowVisible(hwnd
), "IsWindowVisible() should return TRUE\n");
4315 /* restore original WS_VISIBLE state */
4316 SetWindowLongA(hwnd
, GWL_STYLE
, style
);
4322 static INT_PTR CALLBACK
TestModalDlgProcA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
4324 struct recvd_message msg
;
4326 if (ignore_message( message
)) return 0;
4332 case WM_NCMOUSEMOVE
:
4333 case WM_NCMOUSELEAVE
:
4341 msg
.message
= message
;
4342 msg
.flags
= sent
|wparam
|lparam
;
4343 msg
.wParam
= wParam
;
4344 msg
.lParam
= lParam
;
4345 msg
.descr
= "dialog";
4348 if (message
== WM_INITDIALOG
) SetTimer( hwnd
, 1, 100, NULL
);
4349 if (message
== WM_TIMER
) EndDialog( hwnd
, 0 );
4353 static INT_PTR CALLBACK
TestModalDlgProc2(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
4355 struct recvd_message msg
;
4357 if (ignore_message( message
)) return 0;
4363 case WM_NCMOUSEMOVE
:
4364 case WM_NCMOUSELEAVE
:
4372 msg
.message
= message
;
4373 msg
.flags
= sent
|wparam
|lparam
;
4374 msg
.wParam
= wParam
;
4375 msg
.lParam
= lParam
;
4376 msg
.descr
= "dialog";
4379 if (message
== WM_INITDIALOG
) EndDialog( hwnd
, 0 );
4383 static void test_hv_scroll_1(HWND hwnd
, INT ctl
, DWORD clear
, DWORD set
, INT min
, INT max
)
4385 DWORD style
, exstyle
;
4389 exstyle
= GetWindowLongA(hwnd
, GWL_EXSTYLE
);
4390 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
4391 /* do not be confused by WS_DLGFRAME set */
4392 if ((style
& WS_CAPTION
) == WS_CAPTION
) style
&= ~WS_CAPTION
;
4394 if (clear
) ok(style
& clear
, "style %08x should be set\n", clear
);
4395 if (set
) ok(!(style
& set
), "style %08x should not be set\n", set
);
4397 ret
= SetScrollRange(hwnd
, ctl
, min
, max
, FALSE
);
4398 ok( ret
, "SetScrollRange(%d) error %d\n", ctl
, GetLastError());
4399 if ((style
& (WS_DLGFRAME
| WS_BORDER
| WS_THICKFRAME
)) || (exstyle
& WS_EX_DLGMODALFRAME
))
4400 ok_sequence(WmSetScrollRangeHV_NC_Seq
, "SetScrollRange(SB_HORZ/SB_VERT) NC", FALSE
);
4402 ok_sequence(WmSetScrollRangeHVSeq
, "SetScrollRange(SB_HORZ/SB_VERT)", FALSE
);
4404 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
4405 if (set
) ok(style
& set
, "style %08x should be set\n", set
);
4406 if (clear
) ok(!(style
& clear
), "style %08x should not be set\n", clear
);
4408 /* a subsequent call should do nothing */
4409 ret
= SetScrollRange(hwnd
, ctl
, min
, max
, FALSE
);
4410 ok( ret
, "SetScrollRange(%d) error %d\n", ctl
, GetLastError());
4411 ok_sequence(WmEmptySeq
, "SetScrollRange(SB_HORZ/SB_VERT) empty sequence", FALSE
);
4415 ret
= GetScrollRange(hwnd
, ctl
, &xmin
, &xmax
);
4416 ok( ret
, "GetScrollRange(%d) error %d\n", ctl
, GetLastError());
4417 ok_sequence(WmEmptySeq
, "GetScrollRange(SB_HORZ/SB_VERT) empty sequence", FALSE
);
4418 ok(xmin
== min
, "unexpected min scroll value %d\n", xmin
);
4419 ok(xmax
== max
, "unexpected max scroll value %d\n", xmax
);
4422 static void test_hv_scroll_2(HWND hwnd
, INT ctl
, DWORD clear
, DWORD set
, INT min
, INT max
)
4424 DWORD style
, exstyle
;
4428 exstyle
= GetWindowLongA(hwnd
, GWL_EXSTYLE
);
4429 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
4430 /* do not be confused by WS_DLGFRAME set */
4431 if ((style
& WS_CAPTION
) == WS_CAPTION
) style
&= ~WS_CAPTION
;
4433 if (clear
) ok(style
& clear
, "style %08x should be set\n", clear
);
4434 if (set
) ok(!(style
& set
), "style %08x should not be set\n", set
);
4436 si
.cbSize
= sizeof(si
);
4437 si
.fMask
= SIF_RANGE
;
4440 SetScrollInfo(hwnd
, ctl
, &si
, TRUE
);
4441 if ((style
& (WS_DLGFRAME
| WS_BORDER
| WS_THICKFRAME
)) || (exstyle
& WS_EX_DLGMODALFRAME
))
4442 ok_sequence(WmSetScrollRangeHV_NC_Seq
, "SetScrollInfo(SB_HORZ/SB_VERT) NC", FALSE
);
4444 ok_sequence(WmSetScrollRangeHVSeq
, "SetScrollInfo(SB_HORZ/SB_VERT)", FALSE
);
4446 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
4447 if (set
) ok(style
& set
, "style %08x should be set\n", set
);
4448 if (clear
) ok(!(style
& clear
), "style %08x should not be set\n", clear
);
4450 /* a subsequent call should do nothing */
4451 SetScrollInfo(hwnd
, ctl
, &si
, TRUE
);
4452 if (style
& WS_HSCROLL
)
4453 ok_sequence(WmSetScrollRangeHSeq_empty
, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE
);
4454 else if (style
& WS_VSCROLL
)
4455 ok_sequence(WmSetScrollRangeVSeq_empty
, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE
);
4457 ok_sequence(WmEmptySeq
, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE
);
4459 si
.fMask
= SIF_PAGE
;
4461 SetScrollInfo(hwnd
, ctl
, &si
, FALSE
);
4462 ok_sequence(WmEmptySeq
, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE
);
4466 SetScrollInfo(hwnd
, ctl
, &si
, FALSE
);
4467 ok_sequence(WmEmptySeq
, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE
);
4469 si
.fMask
= SIF_RANGE
;
4470 si
.nMin
= 0xdeadbeef;
4471 si
.nMax
= 0xdeadbeef;
4472 ret
= GetScrollInfo(hwnd
, ctl
, &si
);
4473 ok( ret
, "GetScrollInfo error %d\n", GetLastError());
4474 ok_sequence(WmEmptySeq
, "GetScrollRange(SB_HORZ/SB_VERT) empty sequence", FALSE
);
4475 ok(si
.nMin
== min
, "unexpected min scroll value %d\n", si
.nMin
);
4476 ok(si
.nMax
== max
, "unexpected max scroll value %d\n", si
.nMax
);
4479 /* Win9x sends WM_USER+xxx while and NT versions send SBM_xxx messages */
4480 static void test_scroll_messages(HWND hwnd
)
4491 ret
= GetScrollRange(hwnd
, SB_CTL
, &min
, &max
);
4492 ok( ret
, "GetScrollRange error %d\n", GetLastError());
4493 if (sequence
->message
!= WmGetScrollRangeSeq
[0].message
)
4494 trace("GetScrollRange(SB_CTL) generated unknown message %04x\n", sequence
->message
);
4495 /* values of min and max are undefined */
4498 ret
= SetScrollRange(hwnd
, SB_CTL
, 10, 150, FALSE
);
4499 ok( ret
, "SetScrollRange error %d\n", GetLastError());
4500 if (sequence
->message
!= WmSetScrollRangeSeq
[0].message
)
4501 trace("SetScrollRange(SB_CTL) generated unknown message %04x\n", sequence
->message
);
4506 ret
= GetScrollRange(hwnd
, SB_CTL
, &min
, &max
);
4507 ok( ret
, "GetScrollRange error %d\n", GetLastError());
4508 if (sequence
->message
!= WmGetScrollRangeSeq
[0].message
)
4509 trace("GetScrollRange(SB_CTL) generated unknown message %04x\n", sequence
->message
);
4510 /* values of min and max are undefined */
4513 si
.cbSize
= sizeof(si
);
4514 si
.fMask
= SIF_RANGE
;
4517 SetScrollInfo(hwnd
, SB_CTL
, &si
, FALSE
);
4518 if (sequence
->message
!= WmSetScrollRangeSeq
[0].message
)
4519 trace("SetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence
->message
);
4522 si
.fMask
= SIF_PAGE
;
4524 SetScrollInfo(hwnd
, SB_CTL
, &si
, FALSE
);
4525 if (sequence
->message
!= WmSetScrollRangeSeq
[0].message
)
4526 trace("SetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence
->message
);
4531 SetScrollInfo(hwnd
, SB_CTL
, &si
, FALSE
);
4532 if (sequence
->message
!= WmSetScrollRangeSeq
[0].message
)
4533 trace("SetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence
->message
);
4536 si
.fMask
= SIF_RANGE
;
4537 si
.nMin
= 0xdeadbeef;
4538 si
.nMax
= 0xdeadbeef;
4539 ret
= GetScrollInfo(hwnd
, SB_CTL
, &si
);
4540 ok( ret
, "GetScrollInfo error %d\n", GetLastError());
4541 if (sequence
->message
!= WmGetScrollInfoSeq
[0].message
)
4542 trace("GetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence
->message
);
4543 /* values of min and max are undefined */
4546 /* set WS_HSCROLL */
4547 test_hv_scroll_1(hwnd
, SB_HORZ
, 0, WS_HSCROLL
, 10, 150);
4548 /* clear WS_HSCROLL */
4549 test_hv_scroll_1(hwnd
, SB_HORZ
, WS_HSCROLL
, 0, 0, 0);
4551 /* set WS_HSCROLL */
4552 test_hv_scroll_2(hwnd
, SB_HORZ
, 0, WS_HSCROLL
, 10, 150);
4553 /* clear WS_HSCROLL */
4554 test_hv_scroll_2(hwnd
, SB_HORZ
, WS_HSCROLL
, 0, 0, 0);
4556 /* set WS_VSCROLL */
4557 test_hv_scroll_1(hwnd
, SB_VERT
, 0, WS_VSCROLL
, 10, 150);
4558 /* clear WS_VSCROLL */
4559 test_hv_scroll_1(hwnd
, SB_VERT
, WS_VSCROLL
, 0, 0, 0);
4561 /* set WS_VSCROLL */
4562 test_hv_scroll_2(hwnd
, SB_VERT
, 0, WS_VSCROLL
, 10, 150);
4563 /* clear WS_VSCROLL */
4564 test_hv_scroll_2(hwnd
, SB_VERT
, WS_VSCROLL
, 0, 0, 0);
4567 static void test_showwindow(void)
4572 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW
,
4573 100, 100, 200, 200, 0, 0, 0, NULL
);
4574 ok (hwnd
!= 0, "Failed to create overlapped window\n");
4575 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
4576 0, 0, 10, 10, hwnd
, 0, 0, NULL
);
4577 ok (hchild
!= 0, "Failed to create child\n");
4580 /* ShowWindow( SW_SHOWNA) for invisible top level window */
4581 trace("calling ShowWindow( SW_SHOWNA) for invisible top level window\n");
4582 ok( ShowWindow(hwnd
, SW_SHOWNA
) == FALSE
, "ShowWindow: window was visible\n" );
4583 ok_sequence(WmSHOWNATopInvisible
, "ShowWindow(SW_SHOWNA) on invisible top level window", FALSE
);
4585 /* ShowWindow( SW_SHOWNA) for now visible top level window */
4586 trace("calling ShowWindow( SW_SHOWNA) for now visible top level window\n");
4587 ok( ShowWindow(hwnd
, SW_SHOWNA
) != FALSE
, "ShowWindow: window was invisible\n" );
4588 ok_sequence(WmSHOWNATopVisible
, "ShowWindow(SW_SHOWNA) on visible top level window", FALSE
);
4589 /* back to invisible */
4590 ShowWindow(hchild
, SW_HIDE
);
4591 ShowWindow(hwnd
, SW_HIDE
);
4593 /* ShowWindow(SW_SHOWNA) with child and parent invisible */
4594 trace("calling ShowWindow( SW_SHOWNA) for invisible child with invisible parent\n");
4595 ok( ShowWindow(hchild
, SW_SHOWNA
) == FALSE
, "ShowWindow: window was visible\n" );
4596 ok_sequence(WmSHOWNAChildInvisParInvis
, "ShowWindow(SW_SHOWNA) invisible child and parent", FALSE
);
4597 /* ShowWindow(SW_SHOWNA) with child visible and parent invisible */
4598 ok( ShowWindow(hchild
, SW_SHOW
) != FALSE
, "ShowWindow: window was invisible\n" );
4600 trace("calling ShowWindow( SW_SHOWNA) for the visible child and invisible parent\n");
4601 ok( ShowWindow(hchild
, SW_SHOWNA
) != FALSE
, "ShowWindow: window was invisible\n" );
4602 ok_sequence(WmSHOWNAChildVisParInvis
, "ShowWindow(SW_SHOWNA) visible child and invisible parent", FALSE
);
4603 /* ShowWindow(SW_SHOWNA) with child visible and parent visible */
4604 ShowWindow( hwnd
, SW_SHOW
);
4606 trace("calling ShowWindow( SW_SHOWNA) for the visible child and parent\n");
4607 ok( ShowWindow(hchild
, SW_SHOWNA
) != FALSE
, "ShowWindow: window was invisible\n" );
4608 ok_sequence(WmSHOWNAChildVisParVis
, "ShowWindow(SW_SHOWNA) for the visible child and parent", FALSE
);
4610 /* ShowWindow(SW_SHOWNA) with child invisible and parent visible */
4611 ShowWindow( hchild
, SW_HIDE
);
4613 trace("calling ShowWindow( SW_SHOWNA) for the invisible child and visible parent\n");
4614 ok( ShowWindow(hchild
, SW_SHOWNA
) == FALSE
, "ShowWindow: window was visible\n" );
4615 ok_sequence(WmSHOWNAChildInvisParVis
, "ShowWindow(SW_SHOWNA) for the invisible child and visible parent", FALSE
);
4618 ok(GetCapture() == hchild
, "wrong capture window %p\n", GetCapture());
4619 DestroyWindow(hchild
);
4620 ok(!GetCapture(), "wrong capture window %p\n", GetCapture());
4622 DestroyWindow(hwnd
);
4627 * 1. Create invisible maximized popup window.
4628 * 2. Move and resize it.
4629 * 3. Show it maximized.
4631 trace("calling CreateWindowExA( WS_MAXIMIZE ) for invisible maximized popup window\n");
4632 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP
| WS_MAXIMIZE
,
4633 100, 100, 200, 200, 0, 0, 0, NULL
);
4634 ok (hwnd
!= 0, "Failed to create popup window\n");
4635 ok(IsZoomed(hwnd
), "window should be maximized\n");
4636 ok_sequence(WmCreateInvisibleMaxPopupSeq
, "CreateWindow(WS_MAXIMIZED):popup", FALSE
);
4638 GetWindowRect(hwnd
, &rc
);
4639 ok( rc
.right
-rc
.left
== GetSystemMetrics(SM_CXSCREEN
) &&
4640 rc
.bottom
-rc
.top
== GetSystemMetrics(SM_CYSCREEN
),
4641 "Invalid maximized size before ShowWindow %s\n", wine_dbgstr_rect( &rc
));
4642 /* Reset window's size & position */
4643 SetWindowPos(hwnd
, 0, 10, 10, 200, 200, SWP_NOZORDER
| SWP_NOACTIVATE
);
4644 ok(IsZoomed(hwnd
), "window should be maximized\n");
4647 trace("calling ShowWindow( SW_SHOWMAXIMIZE ) for invisible maximized popup window\n");
4648 ShowWindow(hwnd
, SW_SHOWMAXIMIZED
);
4649 ok(IsZoomed(hwnd
), "window should be maximized\n");
4650 ok_sequence(WmShowMaxPopupResizedSeq
, "ShowWindow(SW_SHOWMAXIMIZED):invisible maximized and resized popup", FALSE
);
4652 GetWindowRect(hwnd
, &rc
);
4653 ok( rc
.right
-rc
.left
== GetSystemMetrics(SM_CXSCREEN
) &&
4654 rc
.bottom
-rc
.top
== GetSystemMetrics(SM_CYSCREEN
),
4655 "Invalid maximized size after ShowWindow %s\n", wine_dbgstr_rect( &rc
));
4656 DestroyWindow(hwnd
);
4659 /* Test again, this time the NC_PAINT message */
4660 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP
| WS_MAXIMIZE
,
4661 100, 100, 200, 200, 0, 0, 0, NULL
);
4662 ok (hwnd
!= 0, "Failed to create popup window\n");
4663 SetWindowPos(hwnd
, 0, 10, 10, 200, 200, SWP_NOZORDER
| SWP_NOACTIVATE
);
4665 ShowWindow(hwnd
, SW_SHOWMAXIMIZED
);
4666 ok_sequence(WmShowMaxPopupResizedSeq_todo
,
4667 "ShowWindow(SW_SHOWMAXIMIZED):invisible maximized and resized popup TODO", TRUE
);
4668 DestroyWindow(hwnd
);
4672 * 1. Create invisible maximized popup window.
4673 * 2. Show it maximized.
4675 trace("calling CreateWindowExA( WS_MAXIMIZE ) for invisible maximized popup window\n");
4676 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP
| WS_MAXIMIZE
,
4677 100, 100, 200, 200, 0, 0, 0, NULL
);
4678 ok (hwnd
!= 0, "Failed to create popup window\n");
4679 ok(IsZoomed(hwnd
), "window should be maximized\n");
4680 ok_sequence(WmCreateInvisibleMaxPopupSeq
, "CreateWindow(WS_MAXIMIZED):popup", FALSE
);
4682 trace("calling ShowWindow( SW_SHOWMAXIMIZE ) for invisible maximized popup window\n");
4683 ShowWindow(hwnd
, SW_SHOWMAXIMIZED
);
4684 ok(IsZoomed(hwnd
), "window should be maximized\n");
4685 ok_sequence(WmShowMaxPopupSeq
, "ShowWindow(SW_SHOWMAXIMIZED):invisible maximized popup", FALSE
);
4686 DestroyWindow(hwnd
);
4690 * 1. Create visible maximized popup window.
4692 trace("calling CreateWindowExA( WS_MAXIMIZE ) for maximized popup window\n");
4693 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP
| WS_MAXIMIZE
| WS_VISIBLE
,
4694 100, 100, 200, 200, 0, 0, 0, NULL
);
4695 ok (hwnd
!= 0, "Failed to create popup window\n");
4696 ok(IsZoomed(hwnd
), "window should be maximized\n");
4697 ok_sequence(WmCreateMaxPopupSeq
, "CreateWindow(WS_MAXIMIZED):popup", FALSE
);
4698 DestroyWindow(hwnd
);
4702 * 1. Create visible popup window.
4705 trace("calling CreateWindowExA( WS_VISIBLE ) for popup window\n");
4706 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP
| WS_VISIBLE
,
4707 100, 100, 200, 200, 0, 0, 0, NULL
);
4708 ok (hwnd
!= 0, "Failed to create popup window\n");
4709 ok(!IsZoomed(hwnd
), "window should NOT be maximized\n");
4710 ok_sequence(WmCreatePopupSeq
, "CreateWindow(WS_VISIBLE):popup", FALSE
);
4712 trace("calling ShowWindow( SW_SHOWMAXIMIZE ) for visible popup window\n");
4713 ShowWindow(hwnd
, SW_SHOWMAXIMIZED
);
4714 ok(IsZoomed(hwnd
), "window should be maximized\n");
4715 ok_sequence(WmShowVisMaxPopupSeq
, "ShowWindow(SW_SHOWMAXIMIZED):popup", FALSE
);
4716 DestroyWindow(hwnd
);
4720 static void test_sys_menu(void)
4726 hwnd
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
4727 100, 100, 200, 200, 0, 0, 0, NULL
);
4728 ok (hwnd
!= 0, "Failed to create overlapped window\n");
4732 /* test existing window without CS_NOCLOSE style */
4733 hmenu
= GetSystemMenu(hwnd
, FALSE
);
4734 ok(hmenu
!= 0, "GetSystemMenu error %d\n", GetLastError());
4736 state
= GetMenuState(hmenu
, SC_CLOSE
, MF_BYCOMMAND
);
4737 ok(state
!= 0xffffffff, "wrong SC_CLOSE state %x\n", state
);
4738 ok(!(state
& (MF_DISABLED
| MF_GRAYED
)), "wrong SC_CLOSE state %x\n", state
);
4740 EnableMenuItem(hmenu
, SC_CLOSE
, MF_BYCOMMAND
| MF_GRAYED
);
4741 ok_sequence(WmEmptySeq
, "WmEnableMenuItem", FALSE
);
4743 state
= GetMenuState(hmenu
, SC_CLOSE
, MF_BYCOMMAND
);
4744 ok(state
!= 0xffffffff, "wrong SC_CLOSE state %x\n", state
);
4745 ok((state
& (MF_DISABLED
| MF_GRAYED
)) == MF_GRAYED
, "wrong SC_CLOSE state %x\n", state
);
4747 EnableMenuItem(hmenu
, SC_CLOSE
, 0);
4748 ok_sequence(WmEmptySeq
, "WmEnableMenuItem", FALSE
);
4750 state
= GetMenuState(hmenu
, SC_CLOSE
, MF_BYCOMMAND
);
4751 ok(state
!= 0xffffffff, "wrong SC_CLOSE state %x\n", state
);
4752 ok(!(state
& (MF_DISABLED
| MF_GRAYED
)), "wrong SC_CLOSE state %x\n", state
);
4754 /* test whether removing WS_SYSMENU destroys a system menu */
4755 SetWindowLongW(hwnd
, GWL_STYLE
, WS_POPUP
);
4756 SetWindowPos(hwnd
, 0, 0, 0, 0, 0, SWP_NOZORDER
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_FRAMECHANGED
);
4758 hmenu
= GetSystemMenu(hwnd
, FALSE
);
4759 ok(hmenu
!= 0, "GetSystemMenu error %d\n", GetLastError());
4761 DestroyWindow(hwnd
);
4763 /* test new window with CS_NOCLOSE style */
4764 hwnd
= CreateWindowExA(0, "NoCloseWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
4765 100, 100, 200, 200, 0, 0, 0, NULL
);
4766 ok (hwnd
!= 0, "Failed to create overlapped window\n");
4768 hmenu
= GetSystemMenu(hwnd
, FALSE
);
4769 ok(hmenu
!= 0, "GetSystemMenu error %d\n", GetLastError());
4771 state
= GetMenuState(hmenu
, SC_CLOSE
, MF_BYCOMMAND
);
4772 ok(state
== 0xffffffff, "wrong SC_CLOSE state %x\n", state
);
4774 DestroyWindow(hwnd
);
4776 /* test new window without WS_SYSMENU style */
4777 hwnd
= CreateWindowExA(0, "NoCloseWindowClass", NULL
, WS_OVERLAPPEDWINDOW
& ~WS_SYSMENU
,
4778 100, 100, 200, 200, 0, 0, 0, NULL
);
4779 ok(hwnd
!= 0, "Failed to create overlapped window\n");
4781 hmenu
= GetSystemMenu(hwnd
, FALSE
);
4782 ok(!hmenu
, "GetSystemMenu error %d\n", GetLastError());
4784 DestroyWindow(hwnd
);
4787 /* For shown WS_OVERLAPPEDWINDOW */
4788 static const struct message WmSetIcon_1
[] = {
4789 { WM_SETICON
, sent
},
4790 { 0x00AE, sent
|defwinproc
|optional
}, /* XP */
4791 { WM_GETTEXT
, sent
|defwinproc
|optional
},
4792 { WM_GETTEXT
, sent
|defwinproc
|optional
}, /* XP sends a duplicate */
4796 /* For WS_POPUP and hidden WS_OVERLAPPEDWINDOW */
4797 static const struct message WmSetIcon_2
[] = {
4798 { WM_SETICON
, sent
},
4802 /* Sending undocumented 0x3B message with wparam = 0x8000000b */
4803 static const struct message WmInitEndSession
[] = {
4805 { WM_QUERYENDSESSION
, sent
|defwinproc
|wparam
|lparam
, 0, ENDSESSION_LOGOFF
},
4809 /* Sending undocumented 0x3B message with wparam = 0x0000000b */
4810 static const struct message WmInitEndSession_2
[] = {
4812 { WM_QUERYENDSESSION
, sent
|defwinproc
|wparam
|lparam
, 0, 0 },
4816 /* Sending undocumented 0x3B message with wparam = 0x80000008 */
4817 static const struct message WmInitEndSession_3
[] = {
4819 { WM_ENDSESSION
, sent
|defwinproc
|wparam
|lparam
, 0, ENDSESSION_LOGOFF
},
4823 /* Sending undocumented 0x3B message with wparam = 0x00000008 */
4824 static const struct message WmInitEndSession_4
[] = {
4826 { WM_ENDSESSION
, sent
|defwinproc
|wparam
|lparam
, 0, 0 },
4830 /* Sending undocumented 0x3B message with wparam = 0x80000001 */
4831 static const struct message WmInitEndSession_5
[] = {
4833 { WM_ENDSESSION
, sent
|defwinproc
/*|wparam*/|lparam
, 1, ENDSESSION_LOGOFF
},
4837 static const struct message WmOptionalPaint
[] = {
4838 { WM_PAINT
, sent
|optional
},
4839 { WM_NCPAINT
, sent
|beginpaint
|optional
},
4840 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
4841 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
4845 static const struct message WmZOrder
[] = {
4846 { WM_WINDOWPOSCHANGING
, sent
|wparam
, 0, 0 },
4847 { WM_GETMINMAXINFO
, sent
|defwinproc
|wparam
, 0, 0 },
4848 { HCBT_ACTIVATE
, hook
},
4849 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
4850 { WM_WINDOWPOSCHANGING
, sent
|wparam
, 3, 0 },
4851 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOREDRAW
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
, 0 },
4852 { WM_GETTEXT
, sent
|optional
},
4853 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
4854 { WM_ACTIVATEAPP
, sent
|wparam
, 1, 0 },
4855 { WM_NCACTIVATE
, sent
|lparam
, 1, 0 },
4856 { WM_GETTEXT
, sent
|defwinproc
|optional
},
4857 { WM_GETTEXT
, sent
|defwinproc
|optional
},
4858 { WM_ACTIVATE
, sent
|wparam
|lparam
, 1, 0 },
4859 { HCBT_SETFOCUS
, hook
},
4860 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
4861 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
4862 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
4863 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
4864 { WM_GETTEXT
, sent
|optional
},
4865 { WM_NCCALCSIZE
, sent
|optional
},
4869 static void CALLBACK
apc_test_proc(ULONG_PTR param
)
4874 static void test_MsgWaitForMultipleObjects(HWND hwnd
)
4879 ret
= MsgWaitForMultipleObjects(0, NULL
, FALSE
, 0, QS_POSTMESSAGE
);
4880 ok(ret
== WAIT_TIMEOUT
, "MsgWaitForMultipleObjects returned %x\n", ret
);
4882 PostMessageA(hwnd
, WM_USER
, 0, 0);
4884 ret
= MsgWaitForMultipleObjects(0, NULL
, FALSE
, 0, QS_POSTMESSAGE
);
4885 ok(ret
== WAIT_OBJECT_0
, "MsgWaitForMultipleObjects returned %x\n", ret
);
4887 ok(PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
), "PeekMessage should succeed\n");
4888 ok(msg
.message
== WM_USER
, "got %04x instead of WM_USER\n", msg
.message
);
4890 ret
= MsgWaitForMultipleObjects(0, NULL
, FALSE
, 0, QS_POSTMESSAGE
);
4891 ok(ret
== WAIT_TIMEOUT
, "MsgWaitForMultipleObjects returned %x\n", ret
);
4893 PostMessageA(hwnd
, WM_USER
, 0, 0);
4895 ret
= MsgWaitForMultipleObjects(0, NULL
, FALSE
, 0, QS_POSTMESSAGE
);
4896 ok(ret
== WAIT_OBJECT_0
, "MsgWaitForMultipleObjects returned %x\n", ret
);
4898 ok(PeekMessageA( &msg
, 0, 0, 0, PM_NOREMOVE
), "PeekMessage should succeed\n");
4899 ok(msg
.message
== WM_USER
, "got %04x instead of WM_USER\n", msg
.message
);
4901 /* shows QS_POSTMESSAGE flag is cleared in the PeekMessage call */
4902 ret
= MsgWaitForMultipleObjects(0, NULL
, FALSE
, 0, QS_POSTMESSAGE
);
4903 ok(ret
== WAIT_TIMEOUT
, "MsgWaitForMultipleObjects returned %x\n", ret
);
4905 PostMessageA(hwnd
, WM_USER
, 0, 0);
4907 /* new incoming message causes it to become signaled again */
4908 ret
= MsgWaitForMultipleObjects(0, NULL
, FALSE
, 0, QS_POSTMESSAGE
);
4909 ok(ret
== WAIT_OBJECT_0
, "MsgWaitForMultipleObjects returned %x\n", ret
);
4911 ok(PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
), "PeekMessage should succeed\n");
4912 ok(msg
.message
== WM_USER
, "got %04x instead of WM_USER\n", msg
.message
);
4913 ok(PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
), "PeekMessage should succeed\n");
4914 ok(msg
.message
== WM_USER
, "got %04x instead of WM_USER\n", msg
.message
);
4916 /* MWMO_INPUTAVAILABLE should succeed even if the message was already seen */
4917 PostMessageA( hwnd
, WM_USER
, 0, 0 );
4918 ok(PeekMessageA( &msg
, 0, 0, 0, PM_NOREMOVE
), "PeekMessage should succeed\n");
4919 ok(msg
.message
== WM_USER
, "got %04x instead of WM_USER\n", msg
.message
);
4921 ret
= MsgWaitForMultipleObjectsEx( 0, NULL
, 0, QS_POSTMESSAGE
, MWMO_INPUTAVAILABLE
);
4922 ok(ret
== WAIT_OBJECT_0
, "MsgWaitForMultipleObjectsEx returned %x\n", ret
);
4924 ok(PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
), "PeekMessage should succeed\n");
4925 ok(msg
.message
== WM_USER
, "got %04x instead of WM_USER\n", msg
.message
);
4927 /* without MWMO_ALERTABLE the result is never WAIT_IO_COMPLETION */
4928 ret
= QueueUserAPC( apc_test_proc
, GetCurrentThread(), 0 );
4929 ok(ret
, "QueueUserAPC failed %u\n", GetLastError());
4931 ret
= MsgWaitForMultipleObjectsEx( 0, NULL
, 0, QS_POSTMESSAGE
, 0 );
4932 ok(ret
== WAIT_TIMEOUT
, "MsgWaitForMultipleObjectsEx returned %x\n", ret
);
4934 /* but even with MWMO_ALERTABLE window events are preferred */
4935 PostMessageA( hwnd
, WM_USER
, 0, 0 );
4937 ret
= MsgWaitForMultipleObjectsEx( 0, NULL
, 0, QS_POSTMESSAGE
, MWMO_ALERTABLE
);
4938 ok(ret
== WAIT_OBJECT_0
, "MsgWaitForMultipleObjectsEx returned %x\n", ret
);
4940 ok(PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
), "PeekMessage should succeed\n");
4941 ok(msg
.message
== WM_USER
, "got %04x instead of WM_USER\n", msg
.message
);
4943 /* the APC call is still queued */
4944 ret
= MsgWaitForMultipleObjectsEx( 0, NULL
, 0, QS_POSTMESSAGE
, MWMO_ALERTABLE
);
4945 ok(ret
== WAIT_IO_COMPLETION
, "MsgWaitForMultipleObjectsEx returned %x\n", ret
);
4948 static void test_WM_DEVICECHANGE(HWND hwnd
)
4953 static const WPARAM wparams
[] = {0,
4954 DBT_DEVNODES_CHANGED
,
4955 DBT_QUERYCHANGECONFIG
,
4957 DBT_CONFIGCHANGECANCELED
,
4960 DBT_CONFIGMGPRIVATE
, /* 0x7fff */
4961 DBT_DEVICEARRIVAL
, /* 0x8000 */
4962 DBT_DEVICEQUERYREMOVE
,
4963 DBT_DEVICEQUERYREMOVEFAILED
,
4964 DBT_DEVICEREMOVEPENDING
,
4965 DBT_DEVICEREMOVECOMPLETE
,
4966 DBT_DEVICETYPESPECIFIC
,
4969 for (i
= 0; i
< sizeof(wparams
)/sizeof(wparams
[0]); i
++)
4971 SetLastError(0xdeadbeef);
4972 ret
= PostMessageA(hwnd
, WM_DEVICECHANGE
, wparams
[i
], 0);
4973 if (wparams
[i
] & 0x8000)
4975 ok(ret
== FALSE
, "PostMessage should returned %d\n", ret
);
4976 ok(GetLastError() == ERROR_MESSAGE_SYNC_ONLY
, "PostMessage error %08x\n", GetLastError());
4980 ret
= MsgWaitForMultipleObjects(0, NULL
, FALSE
, 0, QS_POSTMESSAGE
);
4981 ok(ret
== WAIT_OBJECT_0
, "MsgWaitForMultipleObjects returned %x\n", ret
);
4982 memset(&msg
, 0, sizeof(msg
));
4983 ok(PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
), "PeekMessage should succeed\n");
4984 ok(msg
.message
== WM_DEVICECHANGE
, "got %04x instead of WM_DEVICECHANGE\n", msg
.message
);
4989 static DWORD CALLBACK
show_window_thread(LPVOID arg
)
4993 /* function will not return if ShowWindow(SW_HIDE) calls SendMessage() */
4994 ok(ShowWindow(hwnd
, SW_HIDE
) == FALSE
, "ShowWindow(SW_HIDE) expected FALSE\n");
4999 /* Helper function to easier test SetWindowPos messages */
5000 #define test_msg_setpos( expected_list, flags, todo ) \
5001 test_msg_setpos_( (expected_list), (flags), (todo), __FILE__, __LINE__)
5002 static void test_msg_setpos_(const struct message
*expected_list
, UINT flags
, BOOL todo
, const char *file
, int line
)
5008 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test Popup", WS_POPUP
,
5009 10, 10, 100, 100, NULL
, 0, 0, NULL
);
5010 ok (hwnd
!= 0, "Failed to create popup window\n");
5011 SetWindowPos(hwnd
, NULL
, 0, 0, 100, 100, flags
);
5012 ok_sequence_(expected_list
, "SetWindowPos:show_popup_first_show_window", todo
, file
, line
);
5013 DestroyWindow(hwnd
);
5016 /* test if we receive the right sequence of messages */
5017 static void test_messages(void)
5021 HWND hwnd
, hparent
, hchild
;
5022 HWND hchild2
, hbutton
;
5031 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW
,
5032 100, 100, 200, 200, 0, 0, 0, NULL
);
5033 ok (hwnd
!= 0, "Failed to create overlapped window\n");
5034 ok_sequence(WmCreateOverlappedSeq
, "CreateWindow:overlapped", FALSE
);
5036 /* test ShowWindow(SW_HIDE) on a newly created invisible window */
5037 ok( ShowWindow(hwnd
, SW_HIDE
) == FALSE
, "ShowWindow: window was visible\n" );
5038 ok_sequence(WmEmptySeq
, "ShowWindow(SW_HIDE):overlapped, invisible", FALSE
);
5040 /* test WM_SETREDRAW on a not visible top level window */
5041 test_WM_SETREDRAW(hwnd
);
5043 SetWindowPos(hwnd
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
);
5045 ok_sequence(WmSWP_ShowOverlappedSeq
, "SetWindowPos:SWP_SHOWWINDOW:overlapped", FALSE
);
5046 ok(IsWindowVisible(hwnd
), "window should be visible at this point\n");
5048 ok(GetActiveWindow() == hwnd
, "window should be active\n");
5049 ok(GetFocus() == hwnd
, "window should have input focus\n");
5050 ShowWindow(hwnd
, SW_HIDE
);
5052 ok_sequence(WmHideOverlappedSeq
, "ShowWindow(SW_HIDE):overlapped", FALSE
);
5054 /* test ShowWindow(SW_HIDE) on a hidden window - single threaded */
5055 ok(ShowWindow(hwnd
, SW_HIDE
) == FALSE
, "ShowWindow(SW_HIDE) expected FALSE\n");
5057 ok_sequence(WmEmptySeq
, "ShowWindow(SW_HIDE):overlapped", FALSE
);
5059 /* test ShowWindow(SW_HIDE) on a hidden window - multi-threaded */
5060 hthread
= CreateThread(NULL
, 0, show_window_thread
, hwnd
, 0, &tid
);
5061 ok(hthread
!= NULL
, "CreateThread failed, error %d\n", GetLastError());
5062 ok(WaitForSingleObject(hthread
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
5063 CloseHandle(hthread
);
5065 ok_sequence(WmEmptySeq
, "ShowWindow(SW_HIDE):overlapped", FALSE
);
5067 ShowWindow(hwnd
, SW_SHOW
);
5069 ok_sequence(WmShowOverlappedSeq
, "ShowWindow(SW_SHOW):overlapped", TRUE
);
5071 ShowWindow(hwnd
, SW_HIDE
);
5073 ok_sequence(WmHideOverlappedSeq
, "ShowWindow(SW_HIDE):overlapped", FALSE
);
5075 ShowWindow(hwnd
, SW_SHOWMAXIMIZED
);
5077 ok_sequence(WmShowMaxOverlappedSeq
, "ShowWindow(SW_SHOWMAXIMIZED):overlapped", TRUE
);
5080 if (GetWindowLongW( hwnd
, GWL_STYLE
) & WS_MAXIMIZE
)
5082 ShowWindow(hwnd
, SW_RESTORE
);
5084 ok_sequence(WmShowRestoreMaxOverlappedSeq
, "ShowWindow(SW_RESTORE):overlapped", TRUE
);
5088 ShowWindow(hwnd
, SW_MINIMIZE
);
5090 ok_sequence(WmShowMinOverlappedSeq
, "ShowWindow(SW_SHOWMINIMIZED):overlapped", TRUE
);
5093 if (GetWindowLongW( hwnd
, GWL_STYLE
) & WS_MINIMIZE
)
5095 ShowWindow(hwnd
, SW_RESTORE
);
5097 ok_sequence(WmShowRestoreMinOverlappedSeq
, "ShowWindow(SW_RESTORE):overlapped", TRUE
);
5101 ShowWindow(hwnd
, SW_SHOW
);
5103 ok_sequence(WmOptionalPaint
, "ShowWindow(SW_SHOW):overlapped already visible", FALSE
);
5105 SetWindowPos(hwnd
, 0,0,0,0,0, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
);
5106 ok_sequence(WmSWP_HideOverlappedSeq
, "SetWindowPos:SWP_HIDEWINDOW:overlapped", FALSE
);
5107 ok(!IsWindowVisible(hwnd
), "window should not be visible at this point\n");
5108 ok(GetActiveWindow() == hwnd
, "window should still be active\n");
5110 /* test WM_SETREDRAW on a visible top level window */
5111 ShowWindow(hwnd
, SW_SHOW
);
5113 test_WM_SETREDRAW(hwnd
);
5115 trace("testing scroll APIs on a visible top level window %p\n", hwnd
);
5116 test_scroll_messages(hwnd
);
5118 /* test resizing and moving */
5119 SetWindowPos( hwnd
, 0, 0, 0, 300, 300, SWP_NOMOVE
|SWP_NOACTIVATE
);
5120 ok_sequence(WmSWP_ResizeSeq
, "SetWindowPos:Resize", FALSE
);
5123 SetWindowPos( hwnd
, 0, 200, 200, 0, 0, SWP_NOSIZE
|SWP_NOACTIVATE
);
5124 ok_sequence(WmSWP_MoveSeq
, "SetWindowPos:Move", FALSE
);
5127 SetWindowPos( hwnd
, 0, 200, 200, 250, 250, SWP_NOZORDER
|SWP_NOACTIVATE
);
5128 ok_sequence(WmSWP_ResizeNoZOrder
, "SetWindowPos:WmSWP_ResizeNoZOrder", FALSE
);
5132 /* popups don't get WM_GETMINMAXINFO */
5133 SetWindowLongW( hwnd
, GWL_STYLE
, WS_VISIBLE
|WS_POPUP
);
5134 SetWindowPos( hwnd
, 0, 0, 0, 0, 0, SWP_NOZORDER
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_FRAMECHANGED
);
5136 SetWindowPos( hwnd
, 0, 0, 0, 200, 200, SWP_NOMOVE
|SWP_NOACTIVATE
);
5137 ok_sequence(WmSWP_ResizePopupSeq
, "SetWindowPos:ResizePopup", FALSE
);
5139 DestroyWindow(hwnd
);
5140 ok_sequence(WmDestroyOverlappedSeq
, "DestroyWindow:overlapped", FALSE
);
5142 /* Test if windows are correctly drawn when first shown */
5144 /* Visible, redraw */
5147 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test Popup", WS_POPUP
| WS_VISIBLE
,
5148 10, 10, 100, 100, NULL
, 0, 0, NULL
);
5149 ok (hwnd
!= 0, "Failed to create popup window\n");
5150 RedrawWindow(hwnd
, NULL
, NULL
, RDW_UPDATENOW
);
5151 ok_sequence(WmShowPopupFirstDrawSeq_1
, "RedrawWindow:show_popup_first_draw_visible", FALSE
);
5152 DestroyWindow(hwnd
);
5154 /* Invisible, show, message */
5157 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test Popup", WS_POPUP
,
5158 10, 10, 100, 100, NULL
, 0, 0, NULL
);
5159 ok (hwnd
!= 0, "Failed to create popup window\n");
5160 ShowWindow(hwnd
, SW_SHOW
);
5161 SendMessageW(hwnd
, WM_PAINT
, 0, 0);
5162 ok_sequence(WmShowPopupFirstDrawSeq_1
, "RedrawWindow:show_popup_first_draw_show", FALSE
);
5163 DestroyWindow(hwnd
);
5165 /* Invisible, show maximized, redraw */
5168 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test Popup", WS_POPUP
,
5169 10, 10, 100, 100, NULL
, 0, 0, NULL
);
5170 ok (hwnd
!= 0, "Failed to create popup window\n");
5171 ShowWindow(hwnd
, SW_SHOWMAXIMIZED
);
5172 RedrawWindow(hwnd
, NULL
, NULL
, RDW_UPDATENOW
);
5173 ok_sequence(WmShowPopupFirstDrawSeq_2
, "RedrawWindow:show_popup_first_draw_show_maximized", FALSE
);
5174 DestroyWindow(hwnd
);
5176 /* Test SetWindowPos */
5177 test_msg_setpos(WmFirstDrawSetWindowPosSeq1
, SWP_SHOWWINDOW
, FALSE
);
5178 test_msg_setpos(WmFirstDrawSetWindowPosSeq2
, 0, FALSE
);
5179 test_msg_setpos(WmFirstDrawSetWindowPosSeq3
,
5180 SWP_SHOWWINDOW
| SWP_NOSIZE
| SWP_NOMOVE
| SWP_NOCLIENTSIZE
| SWP_NOCLIENTMOVE
| SWP_NOZORDER
, FALSE
);
5182 test_msg_setpos(WmFirstDrawSetWindowPosSeq1
, SWP_SHOWWINDOW
| SWP_NOSIZE
, FALSE
);
5183 test_msg_setpos(WmFirstDrawSetWindowPosSeq4
, SWP_SHOWWINDOW
| SWP_NOMOVE
, FALSE
);
5184 test_msg_setpos(WmFirstDrawSetWindowPosSeq3
, SWP_SHOWWINDOW
| SWP_NOCLIENTSIZE
, FALSE
);
5185 test_msg_setpos(WmFirstDrawSetWindowPosSeq3
, SWP_SHOWWINDOW
| SWP_NOCLIENTMOVE
, FALSE
);
5186 test_msg_setpos(WmFirstDrawSetWindowPosSeq1
, SWP_SHOWWINDOW
| SWP_NOZORDER
, FALSE
);
5188 test_msg_setpos(WmFirstDrawSetWindowPosSeq2
, SWP_SHOWWINDOW
| SWP_DEFERERASE
, FALSE
);
5189 test_msg_setpos(WmFirstDrawSetWindowPosSeq3
, SWP_SHOWWINDOW
| SWP_DEFERERASE
| SWP_NOCLIENTMOVE
, FALSE
);
5190 test_msg_setpos(WmFirstDrawSetWindowPosSeq3
, SWP_SHOWWINDOW
| SWP_DEFERERASE
| SWP_NOCLIENTSIZE
, FALSE
);
5191 test_msg_setpos(WmFirstDrawSetWindowPosSeq5
, SWP_SHOWWINDOW
| SWP_DEFERERASE
| SWP_NOMOVE
, FALSE
);
5192 test_msg_setpos(WmFirstDrawSetWindowPosSeq2
, SWP_SHOWWINDOW
| SWP_DEFERERASE
| SWP_NOSIZE
, FALSE
);
5193 test_msg_setpos(WmFirstDrawSetWindowPosSeq2
, SWP_SHOWWINDOW
| SWP_DEFERERASE
| SWP_NOZORDER
, FALSE
);
5195 test_msg_setpos(WmFirstDrawSetWindowPosSeq1
, SWP_SHOWWINDOW
| SWP_NOCOPYBITS
, FALSE
);
5196 test_msg_setpos(WmFirstDrawSetWindowPosSeq3
, SWP_SHOWWINDOW
| SWP_NOCOPYBITS
| SWP_NOCLIENTMOVE
, FALSE
);
5197 test_msg_setpos(WmFirstDrawSetWindowPosSeq3
, SWP_SHOWWINDOW
| SWP_NOCOPYBITS
| SWP_NOCLIENTSIZE
, FALSE
);
5198 test_msg_setpos(WmFirstDrawSetWindowPosSeq4
, SWP_SHOWWINDOW
| SWP_NOCOPYBITS
| SWP_NOMOVE
, FALSE
);
5199 test_msg_setpos(WmFirstDrawSetWindowPosSeq1
, SWP_SHOWWINDOW
| SWP_NOCOPYBITS
| SWP_NOSIZE
, FALSE
);
5200 test_msg_setpos(WmFirstDrawSetWindowPosSeq1
, SWP_SHOWWINDOW
| SWP_NOCOPYBITS
| SWP_NOZORDER
, FALSE
);
5202 test_msg_setpos(WmFirstDrawSetWindowPosSeq2
, SWP_SHOWWINDOW
| SWP_NOREDRAW
, FALSE
);
5203 test_msg_setpos(WmFirstDrawSetWindowPosSeq3
, SWP_SHOWWINDOW
| SWP_NOREDRAW
| SWP_NOCLIENTMOVE
, FALSE
);
5204 test_msg_setpos(WmFirstDrawSetWindowPosSeq3
, SWP_SHOWWINDOW
| SWP_NOREDRAW
| SWP_NOCLIENTSIZE
, FALSE
);
5205 test_msg_setpos(WmFirstDrawSetWindowPosSeq5
, SWP_SHOWWINDOW
| SWP_NOREDRAW
| SWP_NOMOVE
, FALSE
);
5206 test_msg_setpos(WmFirstDrawSetWindowPosSeq2
, SWP_SHOWWINDOW
| SWP_NOREDRAW
| SWP_NOSIZE
, FALSE
);
5207 test_msg_setpos(WmFirstDrawSetWindowPosSeq2
, SWP_SHOWWINDOW
| SWP_NOREDRAW
| SWP_NOZORDER
, FALSE
);
5209 /* Test SetWindowPos with child windows */
5211 hparent
= CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
5212 100, 100, 200, 200, 0, 0, 0, NULL
);
5213 ok (hparent
!= 0, "Failed to create parent window\n");
5215 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
| WS_VISIBLE
,
5216 0, 0, 10, 10, hparent
, 0, 0, NULL
);
5217 ok (hchild
!= 0, "Failed to create child window\n");
5219 SetWindowPos(hparent
, NULL
, 0, 0, 100, 100, SWP_SHOWWINDOW
);
5220 ok_sequence(WmFirstDrawChildSeq1
, /* Expect no messages for the child */
5221 "SetWindowPos:show_popup_first_show_window_child1", FALSE
);
5222 DestroyWindow(hchild
);
5223 DestroyWindow(hparent
);
5226 hparent
= CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
| WS_CLIPCHILDREN
,
5227 100, 100, 200, 200, 0, 0, 0, NULL
);
5228 ok (hparent
!= 0, "Failed to create parent window\n");
5230 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
| WS_VISIBLE
,
5231 0, 0, 10, 10, hparent
, 0, 0, NULL
);
5232 ok (hchild
!= 0, "Failed to create child window\n");
5234 SetWindowPos(hparent
, NULL
, 0, 0, 100, 100, SWP_SHOWWINDOW
);
5235 ok_sequence(WmFirstDrawChildSeq2
, /* Expect child to be redrawn */
5236 "SetWindowPos:show_popup_first_show_window_child2", FALSE
);
5237 DestroyWindow(hchild
);
5238 DestroyWindow(hparent
);
5240 /* Test message sequence for extreme position and size */
5243 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test Popup", WS_POPUP
| WS_VISIBLE
,
5244 -10, -10, 10000, 10000, NULL
, 0, 0, NULL
);
5245 ok (hwnd
!= 0, "Failed to create popup window\n");
5246 ok_sequence(WmShowPopupExtremeLocationSeq
, "RedrawWindow:show_popup_extreme_location", TRUE
);
5247 DestroyWindow(hwnd
);
5250 /* Test child windows */
5252 hparent
= CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
5253 100, 100, 200, 200, 0, 0, 0, NULL
);
5254 ok (hparent
!= 0, "Failed to create parent window\n");
5257 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
| WS_MAXIMIZE
,
5258 0, 0, 10, 10, hparent
, 0, 0, NULL
);
5259 ok (hchild
!= 0, "Failed to create child window\n");
5260 ok_sequence(WmCreateMaximizedChildSeq
, "CreateWindow:maximized child", FALSE
);
5261 DestroyWindow(hchild
);
5264 /* visible child window with a caption */
5265 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child",
5266 WS_CHILD
| WS_VISIBLE
| WS_CAPTION
,
5267 0, 0, 10, 10, hparent
, 0, 0, NULL
);
5268 ok (hchild
!= 0, "Failed to create child window\n");
5269 ok_sequence(WmCreateVisibleChildSeq
, "CreateWindow:visible child", FALSE
);
5271 trace("testing scroll APIs on a visible child window %p\n", hchild
);
5272 test_scroll_messages(hchild
);
5274 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
);
5275 ok_sequence(WmShowChildSeq_4
, "SetWindowPos(SWP_SHOWWINDOW):child with a caption", FALSE
);
5277 DestroyWindow(hchild
);
5280 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
5281 0, 0, 10, 10, hparent
, 0, 0, NULL
);
5282 ok (hchild
!= 0, "Failed to create child window\n");
5283 ok_sequence(WmCreateChildSeq
, "CreateWindow:child", FALSE
);
5285 hchild2
= CreateWindowExA(0, "SimpleWindowClass", "Test child2", WS_CHILD
,
5286 100, 100, 50, 50, hparent
, 0, 0, NULL
);
5287 ok (hchild2
!= 0, "Failed to create child2 window\n");
5290 hbutton
= CreateWindowExA(0, "TestWindowClass", "Test button", WS_CHILD
,
5291 0, 100, 50, 50, hchild
, 0, 0, NULL
);
5292 ok (hbutton
!= 0, "Failed to create button window\n");
5294 /* test WM_SETREDRAW on a not visible child window */
5295 test_WM_SETREDRAW(hchild
);
5297 ShowWindow(hchild
, SW_SHOW
);
5298 ok_sequence(WmShowChildSeq
, "ShowWindow(SW_SHOW):child", FALSE
);
5300 /* check parent messages too */
5301 log_all_parent_messages
++;
5302 ShowWindow(hchild
, SW_HIDE
);
5303 ok_sequence(WmHideChildSeq2
, "ShowWindow(SW_HIDE):child", FALSE
);
5304 log_all_parent_messages
--;
5306 ShowWindow(hchild
, SW_SHOW
);
5307 ok_sequence(WmShowChildSeq
, "ShowWindow(SW_SHOW):child", FALSE
);
5309 ShowWindow(hchild
, SW_HIDE
);
5310 ok_sequence(WmHideChildSeq
, "ShowWindow(SW_HIDE):child", FALSE
);
5312 ShowWindow(hchild
, SW_SHOW
);
5313 ok_sequence(WmShowChildSeq
, "ShowWindow(SW_SHOW):child", FALSE
);
5315 /* test WM_SETREDRAW on a visible child window */
5316 test_WM_SETREDRAW(hchild
);
5318 log_all_parent_messages
++;
5319 MoveWindow(hchild
, 10, 10, 20, 20, TRUE
);
5320 ok_sequence(WmResizingChildWithMoveWindowSeq
, "MoveWindow:child", FALSE
);
5321 log_all_parent_messages
--;
5323 ShowWindow(hchild
, SW_HIDE
);
5325 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
);
5326 ok_sequence(WmShowChildSeq_2
, "SetWindowPos:show_child_2", FALSE
);
5328 ShowWindow(hchild
, SW_HIDE
);
5330 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
);
5331 ok_sequence(WmShowChildSeq_3
, "SetWindowPos:show_child_3", FALSE
);
5333 /* DestroyWindow sequence below expects that a child has focus */
5337 DestroyWindow(hchild
);
5338 ok_sequence(WmDestroyChildSeq
, "DestroyWindow:child", FALSE
);
5339 DestroyWindow(hchild2
);
5340 DestroyWindow(hbutton
);
5343 hchild
= CreateWindowExA(0, "TestWindowClass", "Test Child Popup", WS_CHILD
| WS_POPUP
,
5344 0, 0, 100, 100, hparent
, 0, 0, NULL
);
5345 ok (hchild
!= 0, "Failed to create child popup window\n");
5346 ok_sequence(WmCreateChildPopupSeq
, "CreateWindow:child_popup", FALSE
);
5347 DestroyWindow(hchild
);
5349 /* test what happens to a window which sets WS_VISIBLE in WM_CREATE */
5351 hchild
= CreateWindowExA(0, "TestPopupClass", "Test Popup", WS_POPUP
,
5352 0, 0, 100, 100, hparent
, 0, 0, NULL
);
5353 ok (hchild
!= 0, "Failed to create popup window\n");
5354 ok_sequence(WmCreateInvisiblePopupSeq
, "CreateWindow:invisible_popup", FALSE
);
5355 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
5356 ok(IsWindowVisible(hchild
), "IsWindowVisible() should return TRUE\n");
5358 ShowWindow(hchild
, SW_SHOW
);
5359 ok_sequence(WmEmptySeq
, "ShowWindow:show_visible_popup", FALSE
);
5361 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOZORDER
);
5362 ok_sequence(WmShowVisiblePopupSeq_2
, "SetWindowPos:show_visible_popup_2", FALSE
);
5364 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
);
5365 ok_sequence(WmShowVisiblePopupSeq_3
, "SetWindowPos:show_visible_popup_3", FALSE
);
5366 DestroyWindow(hchild
);
5368 /* this time add WS_VISIBLE for CreateWindowEx, but this fact actually
5369 * changes nothing in message sequences.
5372 hchild
= CreateWindowExA(0, "TestPopupClass", "Test Popup", WS_POPUP
| WS_VISIBLE
,
5373 0, 0, 100, 100, hparent
, 0, 0, NULL
);
5374 ok (hchild
!= 0, "Failed to create popup window\n");
5375 ok_sequence(WmCreateInvisiblePopupSeq
, "CreateWindow:invisible_popup", FALSE
);
5376 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
5377 ok(IsWindowVisible(hchild
), "IsWindowVisible() should return TRUE\n");
5379 ShowWindow(hchild
, SW_SHOW
);
5380 ok_sequence(WmEmptySeq
, "ShowWindow:show_visible_popup", FALSE
);
5382 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOZORDER
);
5383 ok_sequence(WmShowVisiblePopupSeq_2
, "SetWindowPos:show_visible_popup_2", FALSE
);
5384 DestroyWindow(hchild
);
5387 hwnd
= CreateWindowExA(WS_EX_DLGMODALFRAME
, "TestDialogClass", NULL
, WS_VISIBLE
|WS_CAPTION
|WS_SYSMENU
|WS_DLGFRAME
,
5388 0, 0, 100, 100, hparent
, 0, 0, NULL
);
5389 ok(hwnd
!= 0, "Failed to create custom dialog window\n");
5390 ok_sequence(WmCreateCustomDialogSeq
, "CreateCustomDialog", TRUE
);
5393 trace("testing scroll APIs on a visible dialog %p\n", hwnd
);
5394 test_scroll_messages(hwnd
);
5400 SendMessageA(hwnd
, WM_NULL
, 0, 0);
5403 after_end_dialog
= TRUE
;
5404 EndDialog( hwnd
, 0 );
5405 ok_sequence(WmEndCustomDialogSeq
, "EndCustomDialog", FALSE
);
5407 DestroyWindow(hwnd
);
5408 after_end_dialog
= FALSE
;
5409 test_def_id
= FALSE
;
5411 ok(GetCursorPos(&pos
), "GetCursorPos failed\n");
5412 ok(SetCursorPos(109, 109), "SetCursorPos failed\n");
5414 hwnd
= CreateWindowExA(0, "TestDialogClass", NULL
, WS_POPUP
|WS_CHILD
,
5415 0, 0, 100, 100, 0, 0, GetModuleHandleA(0), NULL
);
5416 ok(hwnd
!= 0, "Failed to create custom dialog window\n");
5418 trace("call ShowWindow(%p, SW_SHOW)\n", hwnd
);
5419 ShowWindow(hwnd
, SW_SHOW
);
5420 ok_sequence(WmShowCustomDialogSeq
, "ShowCustomDialog", TRUE
);
5424 ret
= DrawMenuBar(hwnd
);
5425 ok(ret
, "DrawMenuBar failed: %d\n", GetLastError());
5427 ok_sequence(WmDrawMenuBarSeq
, "DrawMenuBar", FALSE
);
5428 ok(SetCursorPos(pos
.x
, pos
.y
), "SetCursorPos failed\n");
5430 DestroyWindow(hwnd
);
5432 hwnd
= CreateWindowExA(0, "TestDialogClass", NULL
, WS_CHILD
|WS_VISIBLE
,
5433 0, 0, 100, 100, hparent
, 0, GetModuleHandleA(0), NULL
);
5434 ok(hwnd
!= 0, "Failed to create custom dialog window\n");
5437 ret
= DrawMenuBar(hwnd
);
5438 ok(ret
, "DrawMenuBar failed: %d\n", GetLastError());
5440 ok_sequence(WmEmptySeq
, "DrawMenuBar for a child window", FALSE
);
5442 DestroyWindow(hwnd
);
5445 DialogBoxA( 0, "TEST_DIALOG", hparent
, TestModalDlgProcA
);
5446 ok_sequence(WmModalDialogSeq
, "ModalDialog", TRUE
);
5448 DestroyWindow(hparent
);
5451 /* Message sequence for SetMenu */
5452 ok(!DrawMenuBar(hwnd
), "DrawMenuBar should return FALSE for a destroyed window\n");
5453 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
, "last error is %d\n", GetLastError());
5454 ok_sequence(WmEmptySeq
, "DrawMenuBar for a window without a menu", FALSE
);
5456 hmenu
= CreateMenu();
5457 ok (hmenu
!= 0, "Failed to create menu\n");
5458 ok (InsertMenuA(hmenu
, -1, MF_BYPOSITION
, 0x1000, "foo"), "InsertMenu failed\n");
5459 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW
,
5460 100, 100, 200, 200, 0, hmenu
, 0, NULL
);
5461 ok_sequence(WmCreateOverlappedSeq
, "CreateWindow:overlapped", FALSE
);
5462 ok (SetMenu(hwnd
, 0), "SetMenu\n");
5463 ok_sequence(WmSetMenuNonVisibleSizeChangeSeq
, "SetMenu:NonVisibleSizeChange", FALSE
);
5464 ok (SetMenu(hwnd
, 0), "SetMenu\n");
5465 ok_sequence(WmSetMenuNonVisibleNoSizeChangeSeq
, "SetMenu:NonVisibleNoSizeChange", FALSE
);
5466 ShowWindow(hwnd
, SW_SHOW
);
5467 UpdateWindow( hwnd
);
5470 ok (SetMenu(hwnd
, 0), "SetMenu\n");
5471 ok_sequence(WmSetMenuVisibleNoSizeChangeSeq
, "SetMenu:VisibleNoSizeChange", FALSE
);
5472 ok (SetMenu(hwnd
, hmenu
), "SetMenu\n");
5473 ok_sequence(WmSetMenuVisibleSizeChangeSeq
, "SetMenu:VisibleSizeChange", FALSE
);
5475 UpdateWindow( hwnd
);
5478 ok(DrawMenuBar(hwnd
), "DrawMenuBar\n");
5480 ok_sequence(WmDrawMenuBarSeq
, "DrawMenuBar", FALSE
);
5482 DestroyWindow(hwnd
);
5485 /* Message sequence for EnableWindow */
5486 hparent
= CreateWindowExA(0, "TestWindowClass", "Test parent", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
5487 100, 100, 200, 200, 0, 0, 0, NULL
);
5488 ok (hparent
!= 0, "Failed to create parent window\n");
5489 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
| WS_VISIBLE
,
5490 0, 0, 10, 10, hparent
, 0, 0, NULL
);
5491 ok (hchild
!= 0, "Failed to create child window\n");
5497 EnableWindow(hparent
, FALSE
);
5498 ok_sequence(WmEnableWindowSeq_1
, "EnableWindow(FALSE)", FALSE
);
5500 EnableWindow(hparent
, FALSE
);
5501 ok_sequence(WmEnableWindowSeq_2
, "EnableWindow(FALSE)", FALSE
);
5503 EnableWindow(hparent
, TRUE
);
5504 ok_sequence(WmEnableWindowSeq_3
, "EnableWindow(TRUE)", FALSE
);
5506 EnableWindow(hparent
, TRUE
);
5507 ok_sequence(WmEnableWindowSeq_4
, "EnableWindow(TRUE)", FALSE
);
5512 test_MsgWaitForMultipleObjects(hparent
);
5513 test_WM_DEVICECHANGE(hparent
);
5515 /* the following test causes an exception in user.exe under win9x */
5516 if (!PostMessageW( hparent
, WM_USER
, 0, 0 ))
5518 DestroyWindow(hparent
);
5522 PostMessageW( hparent
, WM_USER
+1, 0, 0 );
5523 /* PeekMessage(NULL) fails, but still removes the message */
5524 SetLastError(0xdeadbeef);
5525 ok( !PeekMessageW( NULL
, 0, 0, 0, PM_REMOVE
), "PeekMessage(NULL) should fail\n" );
5526 ok( GetLastError() == ERROR_NOACCESS
|| /* Win2k */
5527 GetLastError() == 0xdeadbeef, /* NT4 */
5528 "last error is %d\n", GetLastError() );
5529 ok( PeekMessageW( &msg
, 0, 0, 0, PM_REMOVE
), "PeekMessage should succeed\n" );
5530 ok( msg
.message
== WM_USER
+1, "got %x instead of WM_USER+1\n", msg
.message
);
5532 DestroyWindow(hchild
);
5533 DestroyWindow(hparent
);
5536 /* Message sequences for WM_SETICON */
5537 trace("testing WM_SETICON\n");
5538 hwnd
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
5539 CW_USEDEFAULT
, CW_USEDEFAULT
, 300, 300, 0,
5541 ShowWindow(hwnd
, SW_SHOW
);
5545 SendMessageA(hwnd
, WM_SETICON
, ICON_SMALL
, (LPARAM
)LoadIconA(0, (LPCSTR
)IDI_APPLICATION
));
5546 ok_sequence(WmSetIcon_1
, "WM_SETICON for shown window with caption", FALSE
);
5548 ShowWindow(hwnd
, SW_HIDE
);
5551 SendMessageA(hwnd
, WM_SETICON
, ICON_SMALL
, (LPARAM
)LoadIconA(0, (LPCSTR
)IDI_APPLICATION
));
5552 ok_sequence(WmSetIcon_2
, "WM_SETICON for hidden window with caption", FALSE
);
5553 DestroyWindow(hwnd
);
5556 hwnd
= CreateWindowExA(0, "TestPopupClass", NULL
, WS_POPUP
,
5557 CW_USEDEFAULT
, CW_USEDEFAULT
, 300, 300, 0,
5559 ShowWindow(hwnd
, SW_SHOW
);
5563 SendMessageA(hwnd
, WM_SETICON
, ICON_SMALL
, (LPARAM
)LoadIconA(0, (LPCSTR
)IDI_APPLICATION
));
5564 ok_sequence(WmSetIcon_2
, "WM_SETICON for shown window without caption", FALSE
);
5566 ShowWindow(hwnd
, SW_HIDE
);
5569 SendMessageA(hwnd
, WM_SETICON
, ICON_SMALL
, (LPARAM
)LoadIconA(0, (LPCSTR
)IDI_APPLICATION
));
5570 ok_sequence(WmSetIcon_2
, "WM_SETICON for hidden window without caption", FALSE
);
5573 res
= SendMessageA(hwnd
, 0x3B, 0x8000000b, 0);
5576 todo_wine
win_skip( "Message 0x3b not supported\n" );
5579 ok_sequence(WmInitEndSession
, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x8000000b", TRUE
);
5580 ok(res
== 1, "SendMessage(hwnd, 0x3B, 0x8000000b, 0) should have returned 1 instead of %ld\n", res
);
5581 res
= SendMessageA(hwnd
, 0x3B, 0x0000000b, 0);
5582 ok_sequence(WmInitEndSession_2
, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x0000000b", TRUE
);
5583 ok(res
== 1, "SendMessage(hwnd, 0x3B, 0x0000000b, 0) should have returned 1 instead of %ld\n", res
);
5584 res
= SendMessageA(hwnd
, 0x3B, 0x0000000f, 0);
5585 ok_sequence(WmInitEndSession_2
, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x0000000f", TRUE
);
5586 ok(res
== 1, "SendMessage(hwnd, 0x3B, 0x0000000f, 0) should have returned 1 instead of %ld\n", res
);
5589 res
= SendMessageA(hwnd
, 0x3B, 0x80000008, 0);
5590 ok_sequence(WmInitEndSession_3
, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x80000008", TRUE
);
5591 ok(res
== 2, "SendMessage(hwnd, 0x3B, 0x80000008, 0) should have returned 2 instead of %ld\n", res
);
5592 res
= SendMessageA(hwnd
, 0x3B, 0x00000008, 0);
5593 ok_sequence(WmInitEndSession_4
, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x00000008", TRUE
);
5594 ok(res
== 2, "SendMessage(hwnd, 0x3B, 0x00000008, 0) should have returned 2 instead of %ld\n", res
);
5596 res
= SendMessageA(hwnd
, 0x3B, 0x80000004, 0);
5597 ok_sequence(WmInitEndSession_3
, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x80000004", TRUE
);
5598 ok(res
== 2, "SendMessage(hwnd, 0x3B, 0x80000004, 0) should have returned 2 instead of %ld\n", res
);
5600 res
= SendMessageA(hwnd
, 0x3B, 0x80000001, 0);
5601 ok_sequence(WmInitEndSession_5
, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x80000001", TRUE
);
5602 ok(res
== 2, "SendMessage(hwnd, 0x3B, 0x80000001, 0) should have returned 2 instead of %ld\n", res
);
5605 DestroyWindow(hwnd
);
5609 static void test_setwindowpos(void)
5614 const INT winX
= 100;
5615 const INT winY
= 100;
5616 const INT sysX
= GetSystemMetrics(SM_CXMINTRACK
);
5618 hwnd
= CreateWindowExA(0, "TestWindowClass", NULL
, 0,
5619 0, 0, winX
, winY
, 0,
5622 GetWindowRect(hwnd
, &rc
);
5623 expect(sysX
, rc
.right
);
5624 expect(winY
, rc
.bottom
);
5628 res
= SetWindowPos(hwnd
, HWND_TOPMOST
, 0, 0, winX
, winY
, 0);
5629 ok_sequence(WmZOrder
, "Z-Order", TRUE
);
5630 ok(res
== TRUE
, "SetWindowPos expected TRUE, got %ld\n", res
);
5632 GetWindowRect(hwnd
, &rc
);
5633 expect(sysX
, rc
.right
);
5634 expect(winY
, rc
.bottom
);
5635 DestroyWindow(hwnd
);
5638 static void invisible_parent_tests(void)
5640 HWND hparent
, hchild
;
5642 hparent
= CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW
,
5643 100, 100, 200, 200, 0, 0, 0, NULL
);
5644 ok (hparent
!= 0, "Failed to create parent window\n");
5647 /* test showing child with hidden parent */
5649 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
5650 0, 0, 10, 10, hparent
, 0, 0, NULL
);
5651 ok (hchild
!= 0, "Failed to create child window\n");
5652 ok_sequence(WmCreateChildSeq
, "CreateWindow:child", FALSE
);
5654 ShowWindow( hchild
, SW_MINIMIZE
);
5655 ok_sequence(WmShowChildInvisibleParentSeq_1
, "ShowWindow(SW_MINIMIZE) child with invisible parent", FALSE
);
5656 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
5657 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
5662 ShowWindow( hchild
, SW_MINIMIZE
);
5663 ok_sequence(WmShowChildInvisibleParentSeq_1r
, "ShowWindow(SW_MINIMIZE) child with invisible parent", FALSE
);
5665 DestroyWindow(hchild
);
5666 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
5667 0, 0, 10, 10, hparent
, 0, 0, NULL
);
5670 ShowWindow( hchild
, SW_MAXIMIZE
);
5671 ok_sequence(WmShowChildInvisibleParentSeq_2
, "ShowWindow(SW_MAXIMIZE) child with invisible parent", FALSE
);
5672 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
5673 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
5678 ShowWindow( hchild
, SW_MAXIMIZE
);
5679 ok_sequence(WmShowChildInvisibleParentSeq_2r
, "ShowWindow(SW_MAXIMIZE) child with invisible parent", FALSE
);
5681 DestroyWindow(hchild
);
5682 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
5683 0, 0, 10, 10, hparent
, 0, 0, NULL
);
5686 ShowWindow( hchild
, SW_RESTORE
);
5687 ok_sequence(WmShowChildInvisibleParentSeq_5
, "ShowWindow(SW_RESTORE) child with invisible parent", FALSE
);
5688 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
5689 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
5691 DestroyWindow(hchild
);
5692 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
5693 0, 0, 10, 10, hparent
, 0, 0, NULL
);
5696 ShowWindow( hchild
, SW_SHOWMINIMIZED
);
5697 ok_sequence(WmShowChildInvisibleParentSeq_3
, "ShowWindow(SW_SHOWMINIMIZED) child with invisible parent", FALSE
);
5698 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
5699 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
5704 ShowWindow( hchild
, SW_SHOWMINIMIZED
);
5705 ok_sequence(WmShowChildInvisibleParentSeq_3r
, "ShowWindow(SW_SHOWMINIMIZED) child with invisible parent", FALSE
);
5707 DestroyWindow(hchild
);
5708 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
5709 0, 0, 10, 10, hparent
, 0, 0, NULL
);
5712 /* same as ShowWindow( hchild, SW_MAXIMIZE ); */
5713 ShowWindow( hchild
, SW_SHOWMAXIMIZED
);
5714 ok_sequence(WmShowChildInvisibleParentSeq_2
, "ShowWindow(SW_SHOWMAXIMIZED) child with invisible parent", FALSE
);
5715 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
5716 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
5718 DestroyWindow(hchild
);
5719 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
5720 0, 0, 10, 10, hparent
, 0, 0, NULL
);
5723 ShowWindow( hchild
, SW_SHOWMINNOACTIVE
);
5724 ok_sequence(WmShowChildInvisibleParentSeq_4
, "ShowWindow(SW_SHOWMINNOACTIVE) child with invisible parent", FALSE
);
5725 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
5726 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
5731 ShowWindow( hchild
, SW_SHOWMINNOACTIVE
);
5732 ok_sequence(WmShowChildInvisibleParentSeq_4r
, "ShowWindow(SW_SHOWMINNOACTIVE) child with invisible parent", FALSE
);
5734 DestroyWindow(hchild
);
5735 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
5736 0, 0, 10, 10, hparent
, 0, 0, NULL
);
5739 /* FIXME: looks like XP SP2 doesn't know about SW_FORCEMINIMIZE at all */
5740 ShowWindow( hchild
, SW_FORCEMINIMIZE
);
5741 ok_sequence(WmEmptySeq
, "ShowWindow(SW_FORCEMINIMIZE) child with invisible parent", TRUE
);
5743 ok(!(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
), "WS_VISIBLE should be not set\n");
5745 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
5747 DestroyWindow(hchild
);
5748 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
5749 0, 0, 10, 10, hparent
, 0, 0, NULL
);
5752 ShowWindow( hchild
, SW_SHOWNA
);
5753 ok_sequence(WmShowChildInvisibleParentSeq_5
, "ShowWindow(SW_SHOWNA) child with invisible parent", FALSE
);
5754 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
5755 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
5760 ShowWindow( hchild
, SW_SHOWNA
);
5761 ok_sequence(WmShowChildInvisibleParentSeq_5
, "ShowWindow(SW_SHOWNA) child with invisible parent", FALSE
);
5763 DestroyWindow(hchild
);
5764 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
5765 0, 0, 10, 10, hparent
, 0, 0, NULL
);
5768 ShowWindow( hchild
, SW_SHOW
);
5769 ok_sequence(WmShowChildInvisibleParentSeq_5
, "ShowWindow(SW_SHOW) child with invisible parent", FALSE
);
5770 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
5771 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
5776 ShowWindow( hchild
, SW_SHOW
);
5777 ok_sequence(WmEmptySeq
, "ShowWindow(SW_SHOW) child with invisible parent", FALSE
);
5779 ShowWindow( hchild
, SW_HIDE
);
5780 ok_sequence(WmHideChildInvisibleParentSeq
, "ShowWindow:hide child with invisible parent", FALSE
);
5781 ok(!(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
), "WS_VISIBLE should be not set\n");
5782 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
5784 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOZORDER
);
5785 ok_sequence(WmShowChildInvisibleParentSeq_6
, "SetWindowPos:show child with invisible parent", FALSE
);
5786 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
5787 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
5789 SetWindowPos(hchild
, 0,0,0,0,0, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOZORDER
);
5790 ok_sequence(WmHideChildInvisibleParentSeq_2
, "SetWindowPos:hide child with invisible parent", FALSE
);
5791 ok(!(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
), "WS_VISIBLE should not be set\n");
5792 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
5794 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOZORDER
);
5796 DestroyWindow(hchild
);
5797 ok_sequence(WmDestroyInvisibleChildSeq
, "DestroyInvisibleChildSeq", FALSE
);
5799 DestroyWindow(hparent
);
5803 /****************** button message test *************************/
5804 #define ID_BUTTON 0x000e
5806 static const struct message WmSetFocusButtonSeq
[] =
5808 { HCBT_SETFOCUS
, hook
},
5809 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
5810 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
5811 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
5812 { WM_SETFOCUS
, sent
|wparam
, 0 },
5813 { WM_CTLCOLORBTN
, sent
|parent
},
5814 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_BUTTON
, BN_SETFOCUS
) },
5815 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5818 static const struct message WmKillFocusButtonSeq
[] =
5820 { HCBT_SETFOCUS
, hook
},
5821 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
5822 { WM_KILLFOCUS
, sent
|wparam
, 0 },
5823 { WM_CTLCOLORBTN
, sent
|parent
},
5824 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_BUTTON
, BN_KILLFOCUS
) },
5825 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
5826 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 1 },
5827 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5829 { WM_CTLCOLORBTN
, sent
|parent
},
5832 static const struct message WmSetFocusStaticSeq
[] =
5834 { HCBT_SETFOCUS
, hook
},
5835 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
5836 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
5837 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
5838 { WM_SETFOCUS
, sent
|wparam
, 0 },
5839 { WM_CTLCOLORSTATIC
, sent
|parent
},
5840 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_BUTTON
, BN_SETFOCUS
) },
5841 { WM_COMMAND
, sent
|wparam
|parent
|optional
, MAKEWPARAM(ID_BUTTON
, BN_CLICKED
) }, /* radio button */
5842 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5845 static const struct message WmKillFocusStaticSeq
[] =
5847 { HCBT_SETFOCUS
, hook
},
5848 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
5849 { WM_KILLFOCUS
, sent
|wparam
, 0 },
5850 { WM_CTLCOLORSTATIC
, sent
|parent
},
5851 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_BUTTON
, BN_KILLFOCUS
) },
5852 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
5853 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 1 },
5854 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5856 { WM_CTLCOLORSTATIC
, sent
|parent
},
5859 static const struct message WmSetFocusOwnerdrawSeq
[] =
5861 { HCBT_SETFOCUS
, hook
},
5862 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
5863 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
5864 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
5865 { WM_SETFOCUS
, sent
|wparam
, 0 },
5866 { WM_CTLCOLORBTN
, sent
|parent
},
5867 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_BUTTON
, 0x001040e4 },
5868 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_BUTTON
, BN_SETFOCUS
) },
5869 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5872 static const struct message WmKillFocusOwnerdrawSeq
[] =
5874 { HCBT_SETFOCUS
, hook
},
5875 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
5876 { WM_KILLFOCUS
, sent
|wparam
, 0 },
5877 { WM_CTLCOLORBTN
, sent
|parent
},
5878 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_BUTTON
, 0x000040e4 },
5879 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_BUTTON
, BN_KILLFOCUS
) },
5880 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
5881 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 1 },
5882 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5884 { WM_CTLCOLORBTN
, sent
|parent
},
5885 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_BUTTON
, 0x000010e4 },
5888 static const struct message WmLButtonDownSeq
[] =
5890 { WM_LBUTTONDOWN
, sent
|wparam
|lparam
, 0, 0 },
5891 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
5892 { HCBT_SETFOCUS
, hook
},
5893 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
5894 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
5895 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
5896 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
5897 { WM_CTLCOLORBTN
, sent
|defwinproc
},
5898 { BM_SETSTATE
, sent
|wparam
|defwinproc
, TRUE
},
5899 { WM_CTLCOLORBTN
, sent
|defwinproc
},
5900 { EVENT_OBJECT_STATECHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
5903 static const struct message WmLButtonDownStaticSeq
[] =
5905 { WM_LBUTTONDOWN
, sent
|wparam
|lparam
, 0, 0 },
5906 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
5907 { HCBT_SETFOCUS
, hook
},
5908 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
5909 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
5910 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
5911 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
5912 { WM_CTLCOLORSTATIC
, sent
|defwinproc
},
5913 { BM_SETSTATE
, sent
|wparam
|defwinproc
, TRUE
},
5914 { WM_CTLCOLORSTATIC
, sent
|defwinproc
},
5915 { EVENT_OBJECT_STATECHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
5918 static const struct message WmLButtonUpSeq
[] =
5920 { WM_LBUTTONUP
, sent
|wparam
|lparam
, 0, 0 },
5921 { BM_SETSTATE
, sent
|wparam
|defwinproc
, FALSE
},
5922 { WM_CTLCOLORBTN
, sent
|defwinproc
},
5923 { EVENT_OBJECT_STATECHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
5924 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, 0, 0 },
5925 { WM_CAPTURECHANGED
, sent
|wparam
|defwinproc
, 0 },
5928 static const struct message WmLButtonUpStaticSeq
[] =
5930 { WM_LBUTTONUP
, sent
|wparam
|lparam
, 0, 0 },
5931 { BM_SETSTATE
, sent
|wparam
|defwinproc
, FALSE
},
5932 { WM_CTLCOLORSTATIC
, sent
|defwinproc
},
5933 { EVENT_OBJECT_STATECHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
5934 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, 0, 0 },
5935 { WM_CAPTURECHANGED
, sent
|wparam
|defwinproc
, 0 },
5938 static const struct message WmLButtonUpAutoSeq
[] =
5940 { WM_LBUTTONUP
, sent
|wparam
|lparam
, 0, 0 },
5941 { BM_SETSTATE
, sent
|wparam
|defwinproc
, FALSE
},
5942 { WM_CTLCOLORSTATIC
, sent
|defwinproc
},
5943 { EVENT_OBJECT_STATECHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
5944 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, 0, 0 },
5945 { BM_SETCHECK
, sent
|defwinproc
},
5946 { WM_CTLCOLORSTATIC
, sent
|defwinproc
, 0, 0 },
5947 { WM_CAPTURECHANGED
, sent
|wparam
|defwinproc
, 0 },
5950 static const struct message WmLButtonUpBrokenSeq
[] =
5952 { WM_LBUTTONUP
, sent
|wparam
|lparam
, 0, 0 },
5955 static const struct message WmSetFontButtonSeq
[] =
5957 { WM_SETFONT
, sent
},
5959 { WM_ERASEBKGND
, sent
|defwinproc
|optional
},
5960 { WM_CTLCOLORBTN
, sent
|defwinproc
},
5961 { WM_CTLCOLORBTN
, sent
|defwinproc
|optional
}, /* FIXME: Wine sends it twice for BS_OWNERDRAW */
5964 static const struct message WmSetFontStaticSeq
[] =
5966 { WM_SETFONT
, sent
},
5968 { WM_ERASEBKGND
, sent
|defwinproc
|optional
},
5969 { WM_CTLCOLORSTATIC
, sent
|defwinproc
},
5972 static const struct message WmSetTextButtonSeq
[] =
5974 { WM_SETTEXT
, sent
},
5975 { WM_CTLCOLORBTN
, sent
|parent
},
5976 { WM_CTLCOLORBTN
, sent
|parent
},
5977 { WM_COMMAND
, sent
|parent
|optional
},
5978 { WM_DRAWITEM
, sent
|parent
|optional
},
5981 static const struct message WmSetTextStaticSeq
[] =
5983 { WM_SETTEXT
, sent
},
5984 { WM_CTLCOLORSTATIC
, sent
|parent
},
5985 { WM_CTLCOLORSTATIC
, sent
|parent
},
5988 static const struct message WmSetTextGroupSeq
[] =
5990 { WM_SETTEXT
, sent
},
5991 { WM_CTLCOLORSTATIC
, sent
|parent
},
5992 { WM_CTLCOLORSTATIC
, sent
|parent
|optional
}, /* FIXME: Missing in Wine */
5993 { WM_CTLCOLORSTATIC
, sent
|parent
|optional
}, /* FIXME: Missing in Wine */
5996 static const struct message WmSetTextInvisibleSeq
[] =
5998 { WM_SETTEXT
, sent
},
6001 static const struct message WmSetStyleButtonSeq
[] =
6003 { BM_SETSTYLE
, sent
},
6004 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
6006 { WM_NCPAINT
, sent
|defwinproc
|optional
}, /* FIXME: Wine sends it */
6007 { WM_ERASEBKGND
, sent
|defwinproc
|optional
}, /* Win9x doesn't send it */
6008 { WM_CTLCOLORBTN
, sent
|parent
},
6011 static const struct message WmSetStyleStaticSeq
[] =
6013 { BM_SETSTYLE
, sent
},
6014 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
6016 { WM_NCPAINT
, sent
|defwinproc
|optional
}, /* FIXME: Wine sends it */
6017 { WM_ERASEBKGND
, sent
|defwinproc
|optional
}, /* Win9x doesn't send it */
6018 { WM_CTLCOLORSTATIC
, sent
|parent
},
6021 static const struct message WmSetStyleUserSeq
[] =
6023 { BM_SETSTYLE
, sent
},
6024 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
6026 { WM_NCPAINT
, sent
|defwinproc
|optional
}, /* FIXME: Wine sends it */
6027 { WM_ERASEBKGND
, sent
|defwinproc
|optional
}, /* Win9x doesn't send it */
6028 { WM_CTLCOLORBTN
, sent
|parent
},
6029 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_BUTTON
, BN_PAINT
) },
6032 static const struct message WmSetStyleOwnerdrawSeq
[] =
6034 { BM_SETSTYLE
, sent
},
6035 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
6037 { WM_NCPAINT
, sent
|optional
}, /* FIXME: Wine sends it */
6038 { WM_ERASEBKGND
, sent
|defwinproc
|optional
}, /* Win9x doesn't send it */
6039 { WM_CTLCOLORBTN
, sent
|parent
},
6040 { WM_CTLCOLORBTN
, sent
|parent
|optional
}, /* Win9x doesn't send it */
6041 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_BUTTON
, 0x000010e4 },
6044 static const struct message WmSetStateButtonSeq
[] =
6046 { BM_SETSTATE
, sent
},
6047 { WM_CTLCOLORBTN
, sent
|parent
},
6048 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
6051 static const struct message WmSetStateStaticSeq
[] =
6053 { BM_SETSTATE
, sent
},
6054 { WM_CTLCOLORSTATIC
, sent
|parent
},
6055 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
6058 static const struct message WmSetStateUserSeq
[] =
6060 { BM_SETSTATE
, sent
},
6061 { WM_CTLCOLORBTN
, sent
|parent
},
6062 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_BUTTON
, BN_HILITE
) },
6063 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
6066 static const struct message WmSetStateOwnerdrawSeq
[] =
6068 { BM_SETSTATE
, sent
},
6069 { WM_CTLCOLORBTN
, sent
|parent
},
6070 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_BUTTON
, 0x000120e4 },
6071 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
6074 static const struct message WmClearStateButtonSeq
[] =
6076 { BM_SETSTATE
, sent
},
6077 { WM_CTLCOLORBTN
, sent
|parent
},
6078 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_BUTTON
, BN_UNHILITE
) },
6079 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
6082 static const struct message WmDisableButtonSeq
[] =
6084 { WM_LBUTTONDOWN
, sent
},
6085 { BM_SETSTATE
, sent
|defwinproc
},
6086 { WM_CTLCOLORSTATIC
, sent
|defwinproc
|optional
},
6087 { WM_CTLCOLORBTN
, sent
|optional
},
6088 { WM_LBUTTONUP
, sent
},
6089 { BM_SETSTATE
, sent
|defwinproc
},
6090 { WM_CTLCOLORBTN
, sent
|defwinproc
|optional
},
6091 { WM_CTLCOLORSTATIC
, sent
|defwinproc
|optional
},
6092 { BM_SETCHECK
, sent
|defwinproc
|optional
},
6093 { WM_CTLCOLORBTN
, sent
|optional
},
6094 { WM_CTLCOLORSTATIC
, sent
|defwinproc
|optional
},
6095 { WM_CAPTURECHANGED
, sent
|defwinproc
},
6096 { WM_COMMAND
, sent
},
6099 static const struct message WmClearStateOwnerdrawSeq
[] =
6101 { BM_SETSTATE
, sent
},
6102 { WM_CTLCOLORBTN
, sent
|parent
},
6103 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_BUTTON
, 0x000020e4 },
6104 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
6107 static const struct message WmSetCheckIgnoredSeq
[] =
6109 { BM_SETCHECK
, sent
},
6110 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
6113 static const struct message WmSetCheckStaticSeq
[] =
6115 { BM_SETCHECK
, sent
},
6116 { WM_CTLCOLORSTATIC
, sent
|parent
},
6117 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
6121 static WNDPROC old_button_proc
;
6123 static LRESULT CALLBACK
button_hook_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
6125 static LONG defwndproc_counter
= 0;
6127 struct recvd_message msg
;
6129 if (ignore_message( message
)) return 0;
6137 ok(GetCapture() == hwnd
, "GetCapture() = %p\n", GetCapture());
6141 msg
.message
= message
;
6142 msg
.flags
= sent
|wparam
|lparam
;
6143 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
6144 msg
.wParam
= wParam
;
6145 msg
.lParam
= lParam
;
6146 msg
.descr
= "button";
6150 defwndproc_counter
++;
6151 ret
= CallWindowProcA(old_button_proc
, hwnd
, message
, wParam
, lParam
);
6152 defwndproc_counter
--;
6157 static void subclass_button(void)
6161 if (!GetClassInfoA(0, "button", &cls
)) assert(0);
6163 old_button_proc
= cls
.lpfnWndProc
;
6165 cls
.hInstance
= GetModuleHandleA(NULL
);
6166 cls
.lpfnWndProc
= button_hook_proc
;
6167 cls
.lpszClassName
= "my_button_class";
6168 UnregisterClassA(cls
.lpszClassName
, cls
.hInstance
);
6169 if (!RegisterClassA(&cls
)) assert(0);
6172 static void test_button_messages(void)
6178 const struct message
*setfocus
;
6179 const struct message
*killfocus
;
6180 const struct message
*setstyle
;
6181 const struct message
*setstate
;
6182 const struct message
*clearstate
;
6183 const struct message
*setcheck
;
6184 const struct message
*lbuttondown
;
6185 const struct message
*lbuttonup
;
6186 const struct message
*setfont
;
6187 const struct message
*settext
;
6189 { BS_PUSHBUTTON
, DLGC_BUTTON
| DLGC_UNDEFPUSHBUTTON
,
6190 WmSetFocusButtonSeq
, WmKillFocusButtonSeq
, WmSetStyleButtonSeq
,
6191 WmSetStateButtonSeq
, WmSetStateButtonSeq
, WmSetCheckIgnoredSeq
,
6192 WmLButtonDownSeq
, WmLButtonUpSeq
, WmSetFontButtonSeq
,
6193 WmSetTextButtonSeq
},
6194 { BS_DEFPUSHBUTTON
, DLGC_BUTTON
| DLGC_DEFPUSHBUTTON
,
6195 WmSetFocusButtonSeq
, WmKillFocusButtonSeq
, WmSetStyleButtonSeq
,
6196 WmSetStateButtonSeq
, WmSetStateButtonSeq
, WmSetCheckIgnoredSeq
,
6197 WmLButtonDownSeq
, WmLButtonUpSeq
, WmSetFontButtonSeq
,
6198 WmSetTextButtonSeq
},
6199 { BS_CHECKBOX
, DLGC_BUTTON
,
6200 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
, WmSetStyleStaticSeq
,
6201 WmSetStateStaticSeq
, WmSetStateStaticSeq
, WmSetCheckStaticSeq
,
6202 WmLButtonDownStaticSeq
, WmLButtonUpStaticSeq
, WmSetFontStaticSeq
,
6203 WmSetTextStaticSeq
},
6204 { BS_AUTOCHECKBOX
, DLGC_BUTTON
,
6205 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
, WmSetStyleStaticSeq
,
6206 WmSetStateStaticSeq
, WmSetStateStaticSeq
, WmSetCheckStaticSeq
,
6207 WmLButtonDownStaticSeq
, WmLButtonUpAutoSeq
, WmSetFontStaticSeq
,
6208 WmSetTextStaticSeq
},
6209 { BS_RADIOBUTTON
, DLGC_BUTTON
| DLGC_RADIOBUTTON
,
6210 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
, WmSetStyleStaticSeq
,
6211 WmSetStateStaticSeq
, WmSetStateStaticSeq
, WmSetCheckStaticSeq
,
6212 WmLButtonDownStaticSeq
, WmLButtonUpStaticSeq
, WmSetFontStaticSeq
,
6213 WmSetTextStaticSeq
},
6214 { BS_3STATE
, DLGC_BUTTON
,
6215 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
, WmSetStyleStaticSeq
,
6216 WmSetStateStaticSeq
, WmSetStateStaticSeq
, WmSetCheckStaticSeq
,
6217 WmLButtonDownStaticSeq
, WmLButtonUpStaticSeq
, WmSetFontStaticSeq
,
6218 WmSetTextStaticSeq
},
6219 { BS_AUTO3STATE
, DLGC_BUTTON
,
6220 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
, WmSetStyleStaticSeq
,
6221 WmSetStateStaticSeq
, WmSetStateStaticSeq
, WmSetCheckStaticSeq
,
6222 WmLButtonDownStaticSeq
, WmLButtonUpAutoSeq
, WmSetFontStaticSeq
,
6223 WmSetTextStaticSeq
},
6224 { BS_GROUPBOX
, DLGC_STATIC
,
6225 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
, WmSetStyleStaticSeq
,
6226 WmSetStateStaticSeq
, WmSetStateStaticSeq
, WmSetCheckIgnoredSeq
,
6227 WmLButtonDownStaticSeq
, WmLButtonUpStaticSeq
, WmSetFontStaticSeq
,
6228 WmSetTextGroupSeq
},
6229 { BS_USERBUTTON
, DLGC_BUTTON
| DLGC_UNDEFPUSHBUTTON
,
6230 WmSetFocusButtonSeq
, WmKillFocusButtonSeq
, WmSetStyleUserSeq
,
6231 WmSetStateUserSeq
, WmClearStateButtonSeq
, WmSetCheckIgnoredSeq
,
6232 WmLButtonDownSeq
, WmLButtonUpSeq
, WmSetFontButtonSeq
,
6233 WmSetTextButtonSeq
},
6234 { BS_AUTORADIOBUTTON
, DLGC_BUTTON
| DLGC_RADIOBUTTON
,
6235 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
, WmSetStyleStaticSeq
,
6236 WmSetStateStaticSeq
, WmSetStateStaticSeq
, WmSetCheckStaticSeq
,
6237 NULL
/* avoid infinite loop */, WmLButtonUpBrokenSeq
, WmSetFontStaticSeq
,
6238 WmSetTextStaticSeq
},
6239 { BS_OWNERDRAW
, DLGC_BUTTON
,
6240 WmSetFocusOwnerdrawSeq
, WmKillFocusOwnerdrawSeq
, WmSetStyleOwnerdrawSeq
,
6241 WmSetStateOwnerdrawSeq
, WmClearStateOwnerdrawSeq
, WmSetCheckIgnoredSeq
,
6242 WmLButtonDownSeq
, WmLButtonUpSeq
, WmSetFontButtonSeq
,
6243 WmSetTextButtonSeq
},
6245 LOGFONTA logfont
= { 0 };
6246 HFONT zfont
, hfont2
;
6251 /* selection with VK_SPACE should capture button window */
6252 hwnd
= CreateWindowExA(0, "button", "test", BS_CHECKBOX
| WS_VISIBLE
| WS_POPUP
,
6253 0, 0, 50, 14, 0, 0, 0, NULL
);
6254 ok(hwnd
!= 0, "Failed to create button window\n");
6257 SendMessageA(hwnd
, WM_KEYDOWN
, VK_SPACE
, 0);
6258 ok(GetCapture() == hwnd
, "Should be captured on VK_SPACE WM_KEYDOWN\n");
6259 SendMessageA(hwnd
, WM_KEYUP
, VK_SPACE
, 0);
6260 DestroyWindow(hwnd
);
6264 parent
= CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
6265 100, 100, 200, 200, 0, 0, 0, NULL
);
6266 ok(parent
!= 0, "Failed to create parent window\n");
6268 memset(&logfont
, 0, sizeof(logfont
));
6269 logfont
.lfHeight
= -12;
6270 logfont
.lfWeight
= FW_NORMAL
;
6271 strcpy(logfont
.lfFaceName
, "Tahoma");
6273 hfont2
= CreateFontIndirectA(&logfont
);
6274 ok(hfont2
!= NULL
, "Failed to create Tahoma font\n");
6276 for (i
= 0; i
< sizeof(button
)/sizeof(button
[0]); i
++)
6284 trace("button style %08x\n", button
[i
].style
);
6286 hwnd
= CreateWindowExA(0, "my_button_class", "test", button
[i
].style
| WS_CHILD
| BS_NOTIFY
,
6287 0, 0, 50, 14, parent
, (HMENU
)ID_BUTTON
, 0, NULL
);
6288 ok(hwnd
!= 0, "Failed to create button window\n");
6290 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
6291 style
&= ~(WS_CHILD
| BS_NOTIFY
);
6292 /* XP turns a BS_USERBUTTON into BS_PUSHBUTTON */
6293 if (button
[i
].style
== BS_USERBUTTON
)
6294 ok(style
== BS_PUSHBUTTON
, "expected style BS_PUSHBUTTON got %x\n", style
);
6296 ok(style
== button
[i
].style
, "expected style %x got %x\n", button
[i
].style
, style
);
6298 dlg_code
= SendMessageA(hwnd
, WM_GETDLGCODE
, 0, 0);
6299 ok(dlg_code
== button
[i
].dlg_code
, "%u: wrong dlg_code %08x\n", i
, dlg_code
);
6301 ShowWindow(hwnd
, SW_SHOW
);
6308 log_all_parent_messages
++;
6310 ok(GetFocus() == 0, "expected focus 0, got %p\n", GetFocus());
6312 SendMessageA(hwnd
, WM_APP
, 0, 0); /* place a separator mark here */
6313 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
6314 ok_sequence(button
[i
].setfocus
, "SetFocus(hwnd) on a button", FALSE
);
6317 SendMessageA(hwnd
, WM_APP
, 0, 0); /* place a separator mark here */
6318 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
6319 ok_sequence(button
[i
].killfocus
, "SetFocus(0) on a button", FALSE
);
6321 ok(GetFocus() == 0, "expected focus 0, got %p\n", GetFocus());
6323 SendMessageA(hwnd
, BM_SETSTYLE
, button
[i
].style
| BS_BOTTOM
, TRUE
);
6324 SendMessageA(hwnd
, WM_APP
, 0, 0); /* place a separator mark here */
6325 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
6326 ok_sequence(button
[i
].setstyle
, "BM_SETSTYLE on a button", FALSE
);
6328 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
6329 style
&= ~(WS_VISIBLE
| WS_CHILD
| BS_NOTIFY
);
6330 /* XP doesn't turn a BS_USERBUTTON into BS_PUSHBUTTON here! */
6331 ok(style
== button
[i
].style
, "expected style %04x got %04x\n", button
[i
].style
, style
);
6333 state
= SendMessageA(hwnd
, BM_GETSTATE
, 0, 0);
6334 ok(state
== 0, "expected state 0, got %04x\n", state
);
6338 SendMessageA(hwnd
, BM_SETSTATE
, TRUE
, 0);
6339 SendMessageA(hwnd
, WM_APP
, 0, 0); /* place a separator mark here */
6340 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
6341 ok_sequence(button
[i
].setstate
, "BM_SETSTATE/TRUE on a button", FALSE
);
6343 state
= SendMessageA(hwnd
, BM_GETSTATE
, 0, 0);
6344 ok(state
== 0x0004, "expected state 0x0004, got %04x\n", state
);
6346 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
6347 style
&= ~(WS_CHILD
| BS_NOTIFY
| WS_VISIBLE
);
6348 ok(style
== button
[i
].style
, "expected style %04x got %04x\n", button
[i
].style
, style
);
6352 SendMessageA(hwnd
, BM_SETSTATE
, FALSE
, 0);
6353 SendMessageA(hwnd
, WM_APP
, 0, 0); /* place a separator mark here */
6354 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
6355 ok_sequence(button
[i
].clearstate
, "BM_SETSTATE/FALSE on a button", FALSE
);
6357 state
= SendMessageA(hwnd
, BM_GETSTATE
, 0, 0);
6358 ok(state
== 0, "expected state 0, got %04x\n", state
);
6360 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
6361 style
&= ~(WS_CHILD
| BS_NOTIFY
| WS_VISIBLE
);
6362 ok(style
== button
[i
].style
, "expected style %04x got %04x\n", button
[i
].style
, style
);
6364 state
= SendMessageA(hwnd
, BM_GETCHECK
, 0, 0);
6365 ok(state
== BST_UNCHECKED
, "expected BST_UNCHECKED, got %04x\n", state
);
6369 SendMessageA(hwnd
, BM_SETCHECK
, BST_UNCHECKED
, 0);
6370 SendMessageA(hwnd
, WM_APP
, 0, 0); /* place a separator mark here */
6371 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
6372 ok_sequence(WmSetCheckIgnoredSeq
, "BM_SETCHECK on a button", FALSE
);
6374 state
= SendMessageA(hwnd
, BM_GETCHECK
, 0, 0);
6375 ok(state
== BST_UNCHECKED
, "expected BST_UNCHECKED, got %04x\n", state
);
6377 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
6378 style
&= ~(WS_CHILD
| BS_NOTIFY
| WS_VISIBLE
);
6379 ok(style
== button
[i
].style
, "expected style %04x got %04x\n", button
[i
].style
, style
);
6383 SendMessageA(hwnd
, BM_SETCHECK
, BST_CHECKED
, 0);
6384 SendMessageA(hwnd
, WM_APP
, 0, 0); /* place a separator mark here */
6385 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
6386 ok_sequence(button
[i
].setcheck
, "BM_SETCHECK on a button", FALSE
);
6388 SendMessageA(hwnd
, WM_SETTEXT
, 0, (LPARAM
)"Text 1");
6389 sprintf(desc
, "button[%i]: WM_SETTEXT on a visible button", i
);
6390 ok_sequence(button
[i
].settext
, desc
, FALSE
);
6392 ShowWindow(hwnd
, SW_HIDE
);
6396 SendMessageA(hwnd
, WM_SETTEXT
, 0, (LPARAM
)"Text 2");
6397 sprintf(desc
, "button[%i]: WM_SETTEXT on an invisible button", i
);
6398 ok_sequence(WmSetTextInvisibleSeq
, desc
, FALSE
);
6400 ShowWindow(hwnd
, SW_SHOW
);
6401 ShowWindow(parent
, SW_HIDE
);
6405 SendMessageA(hwnd
, WM_SETTEXT
, 0, (LPARAM
)"Text 3");
6406 sprintf(desc
, "button[%i]: WM_SETTEXT on an invisible button", i
);
6407 ok_sequence(WmSetTextInvisibleSeq
, desc
, FALSE
);
6409 ShowWindow(parent
, SW_SHOW
);
6412 state
= SendMessageA(hwnd
, BM_GETCHECK
, 0, 0);
6413 if (button
[i
].style
== BS_PUSHBUTTON
||
6414 button
[i
].style
== BS_DEFPUSHBUTTON
||
6415 button
[i
].style
== BS_GROUPBOX
||
6416 button
[i
].style
== BS_USERBUTTON
||
6417 button
[i
].style
== BS_OWNERDRAW
)
6418 ok(state
== BST_UNCHECKED
, "expected check 0, got %04x\n", state
);
6420 ok(state
== BST_CHECKED
, "expected check 1, got %04x\n", state
);
6422 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
6423 style
&= ~(WS_CHILD
| BS_NOTIFY
| WS_VISIBLE
);
6424 if (button
[i
].style
== BS_RADIOBUTTON
||
6425 button
[i
].style
== BS_AUTORADIOBUTTON
)
6426 ok(style
== (button
[i
].style
| WS_TABSTOP
), "expected style %04x | WS_TABSTOP got %04x\n", button
[i
].style
, style
);
6428 ok(style
== button
[i
].style
, "expected style %04x got %04x\n", button
[i
].style
, style
);
6430 log_all_parent_messages
--;
6432 DestroyWindow(hwnd
);
6434 hwnd
= CreateWindowExA(0, "my_button_class", "test", button
[i
].style
| WS_POPUP
| WS_VISIBLE
,
6435 0, 0, 50, 14, 0, 0, 0, NULL
);
6436 ok(hwnd
!= 0, "Failed to create button window\n");
6438 SetForegroundWindow(hwnd
);
6441 SetActiveWindow(hwnd
);
6445 if (button
[i
].lbuttondown
)
6447 SendMessageA(hwnd
, WM_LBUTTONDOWN
, 0, 0);
6448 sprintf(desc
, "button[%i]: WM_LBUTTONDOWN on a button", i
);
6449 ok_sequence(button
[i
].lbuttondown
, desc
, FALSE
);
6452 SendMessageA(hwnd
, WM_LBUTTONUP
, 0, 0);
6453 sprintf(desc
, "button[%i]: WM_LBUTTONUP on a button", i
);
6454 ok_sequence(button
[i
].lbuttonup
, desc
, FALSE
);
6457 zfont
= GetStockObject(DEFAULT_GUI_FONT
);
6458 SendMessageA(hwnd
, WM_SETFONT
, (WPARAM
)zfont
, TRUE
);
6460 sprintf(desc
, "button[%i]: WM_SETFONT on a button", i
);
6461 ok_sequence(button
[i
].setfont
, desc
, FALSE
);
6463 /* Test that original font is not selected back after painting */
6464 hdc
= CreateCompatibleDC(0);
6466 prevfont
= SelectObject(hdc
, hfont2
);
6467 ok(prevfont
== GetStockObject(SYSTEM_FONT
), "Unexpected default font\n");
6468 SendMessageA(hwnd
, WM_PRINTCLIENT
, (WPARAM
)hdc
, 0);
6469 ok(hfont2
!= GetCurrentObject(hdc
, OBJ_FONT
), "button[%u]: unexpected font selected after WM_PRINTCLIENT\n", i
);
6470 SelectObject(hdc
, prevfont
);
6472 prevfont
= SelectObject(hdc
, hfont2
);
6473 ok(prevfont
== GetStockObject(SYSTEM_FONT
), "Unexpected default font\n");
6474 SendMessageA(hwnd
, WM_PAINT
, (WPARAM
)hdc
, 0);
6475 ok(hfont2
!= GetCurrentObject(hdc
, OBJ_FONT
), "button[%u]: unexpected font selected after WM_PAINT\n", i
);
6476 SelectObject(hdc
, prevfont
);
6480 DestroyWindow(hwnd
);
6483 DeleteObject(hfont2
);
6484 DestroyWindow(parent
);
6486 /* Test if WM_LBUTTONDOWN and WM_LBUTTONUP to a disabled button leads to a WM_COMMAND for the parent */
6488 parent
= CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
6489 100, 100, 200, 200, 0, 0, 0, NULL
);
6490 ok (hwnd
!= 0, "Failed to create overlapped window\n");
6492 hwnd
= CreateWindowExA(0, "my_button_class", "test", BS_DEFPUSHBUTTON
| WS_VISIBLE
| WS_CHILD
,
6493 0, 0, 50, 14, parent
, 0, 0, NULL
);
6495 EnableWindow(hwnd
, FALSE
);
6497 SendMessageA(hwnd
, WM_LBUTTONDOWN
, MK_LBUTTON
, 0);
6498 SendMessageA(hwnd
, WM_LBUTTONUP
, 0, 0);
6499 ok_sequence(WmDisableButtonSeq
, "Mouseclick on a disabled button", FALSE
);
6501 DestroyWindow(hwnd
);
6502 DestroyWindow(parent
);
6505 static void test_button_bm_get_set_image(void)
6512 ICONINFO icon_info2x2
;
6518 DWORD default_style
= BS_PUSHBUTTON
| WS_TABSTOP
| WS_POPUP
| WS_VISIBLE
;
6522 hbmp1x1
= CreateCompatibleBitmap(hdc
, 1, 1);
6523 hbmp2x2
= CreateCompatibleBitmap(hdc
, 2, 2);
6524 ZeroMemory(&bm
, sizeof(bm
));
6525 ok(GetObjectW(hbmp1x1
, sizeof(bm
), &bm
), "Expect GetObjectW() success\n");
6526 ok(bm
.bmWidth
== 1 && bm
.bmHeight
== 1, "Expect bitmap size: %d,%d, got: %d,%d\n", 1, 1,
6527 bm
.bmWidth
, bm
.bmHeight
);
6528 ZeroMemory(&bm
, sizeof(bm
));
6529 ok(GetObjectW(hbmp2x2
, sizeof(bm
), &bm
), "Expect GetObjectW() success\n");
6530 ok(bm
.bmWidth
== 2 && bm
.bmHeight
== 2, "Expect bitmap size: %d,%d, got: %d,%d\n", 2, 2,
6531 bm
.bmWidth
, bm
.bmHeight
);
6533 hmask2x2
= CreateCompatibleBitmap(hdc
, 2, 2);
6534 ZeroMemory(&icon_info2x2
, sizeof(icon_info2x2
));
6535 icon_info2x2
.fIcon
= TRUE
;
6536 icon_info2x2
.hbmMask
= hmask2x2
;
6537 icon_info2x2
.hbmColor
= hbmp2x2
;
6538 hicon2x2
= CreateIconIndirect(&icon_info2x2
);
6540 ZeroMemory(&icon_info
, sizeof(icon_info
));
6541 ok(GetIconInfo(hicon2x2
, &icon_info
), "Expect GetIconInfo() success\n");
6542 ZeroMemory(&bm
, sizeof(bm
));
6543 ok(GetObjectW(icon_info
.hbmColor
, sizeof(bm
), &bm
), "Expect GetObjectW() success\n");
6544 ok(bm
.bmWidth
== 2 && bm
.bmHeight
== 2, "Expect bitmap size: %d,%d, got: %d,%d\n", 2, 2,
6545 bm
.bmWidth
, bm
.bmHeight
);
6546 DeleteObject(icon_info
.hbmColor
);
6547 DeleteObject(icon_info
.hbmMask
);
6549 /* Set bitmap with BS_BITMAP */
6550 hwnd
= CreateWindowA("Button", "test", default_style
| BS_BITMAP
, 0, 0, 100, 100, 0, 0, 0, 0);
6551 ok(hwnd
!= NULL
, "Expect hwnd not NULL\n");
6552 SendMessageA(hwnd
, BM_SETIMAGE
, (WPARAM
)IMAGE_BITMAP
, (LPARAM
)hbmp1x1
);
6553 hbmp
= (HBITMAP
)SendMessageA(hwnd
, BM_GETIMAGE
, (WPARAM
)IMAGE_BITMAP
, 0);
6554 ok(hbmp
!= 0, "Expect hbmp not 0\n");
6555 ZeroMemory(&bm
, sizeof(bm
));
6556 ok(GetObjectW(hbmp
, sizeof(bm
), &bm
), "Expect GetObjectW() success\n");
6557 ok(bm
.bmWidth
== 1 && bm
.bmHeight
== 1, "Expect bitmap size: %d,%d, got: %d,%d\n", 1, 1,
6558 bm
.bmWidth
, bm
.bmHeight
);
6559 DestroyWindow(hwnd
);
6561 /* Set bitmap without BS_BITMAP */
6562 hwnd
= CreateWindowA("Button", "test", default_style
, 0, 0, 100, 100, 0, 0, 0, 0);
6563 ok(hwnd
!= NULL
, "Expect hwnd not NULL\n");
6564 ret
= SendMessageA(hwnd
, BM_SETIMAGE
, (WPARAM
)IMAGE_BITMAP
, (LPARAM
)hbmp1x1
);
6565 ok(ret
== 0, "Expect ret to be 0\n");
6566 hbmp
= (HBITMAP
)SendMessageA(hwnd
, BM_GETIMAGE
, (WPARAM
)IMAGE_BITMAP
, 0);
6567 ok(hbmp
== NULL
, "Expect hbmp to be NULL\n");
6568 DestroyWindow(hwnd
);
6570 /* Set icon with BS_ICON */
6571 hwnd
= CreateWindowA("Button", "test", default_style
| BS_ICON
, 0, 0, 100, 100, 0, 0, 0, 0);
6572 ok(hwnd
!= NULL
, "Expect hwnd not NULL\n");
6573 SendMessageA(hwnd
, BM_SETIMAGE
, (WPARAM
)IMAGE_ICON
, (LPARAM
)hicon2x2
);
6574 hicon
= (HICON
)SendMessageA(hwnd
, BM_GETIMAGE
, (WPARAM
)IMAGE_ICON
, 0);
6575 ok(hicon
!= NULL
, "Expect hicon not NULL\n");
6576 ZeroMemory(&icon_info
, sizeof(icon_info
));
6577 ok(GetIconInfo(hicon
, &icon_info
), "Expect GetIconInfo() success\n");
6578 ZeroMemory(&bm
, sizeof(bm
));
6579 ok(GetObjectW(icon_info
.hbmColor
, sizeof(bm
), &bm
), "Expect GetObjectW() success\n");
6580 ok(bm
.bmWidth
== 2 && bm
.bmHeight
== 2, "Expect bitmap size: %d,%d, got: %d,%d\n", 2, 2,
6581 bm
.bmWidth
, bm
.bmHeight
);
6582 DeleteObject(icon_info
.hbmColor
);
6583 DeleteObject(icon_info
.hbmMask
);
6584 DestroyWindow(hwnd
);
6586 /* Set icon without BS_ICON */
6587 hwnd
= CreateWindowA("Button", "test", default_style
, 0, 0, 100, 100, 0, 0, 0, 0);
6588 ok(hwnd
!= NULL
, "Expect hwnd not NULL\n");
6589 ret
= SendMessageA(hwnd
, BM_SETIMAGE
, (WPARAM
)IMAGE_ICON
, (LPARAM
)hicon2x2
);
6590 ok(ret
== 0, "Expect ret to be 0\n");
6591 hicon
= (HICON
)SendMessageA(hwnd
, BM_GETIMAGE
, (WPARAM
)IMAGE_ICON
, 0);
6592 ok(hicon
== NULL
, "Expect hicon to be NULL\n");
6593 DestroyWindow(hwnd
);
6595 /* Set icon with BS_BITMAP */
6596 hwnd
= CreateWindowA("Button", "test", default_style
| BS_BITMAP
, 0, 0, 100, 100, 0, 0, 0, 0);
6597 ok(hwnd
!= NULL
, "Expect hwnd to be not NULL\n");
6598 ret
= SendMessageA(hwnd
, BM_SETIMAGE
, (WPARAM
)IMAGE_ICON
, (LPARAM
)hicon2x2
);
6599 ok(ret
== 0, "Expect ret to be 0\n");
6600 hicon
= (HICON
)SendMessageA(hwnd
, BM_GETIMAGE
, (WPARAM
)IMAGE_ICON
, 0);
6601 ok(hicon
== NULL
, "Expect hicon to be NULL\n");
6602 DestroyWindow(hwnd
);
6604 /* Set bitmap with BS_ICON */
6605 hwnd
= CreateWindowA("Button", "test", default_style
| BS_ICON
, 0, 0, 100, 100, 0, 0, 0, 0);
6606 ok(hwnd
!= NULL
, "Expect hwnd to be not NULL\n");
6607 ret
= SendMessageA(hwnd
, BM_SETIMAGE
, (WPARAM
)IMAGE_BITMAP
, (LPARAM
)hbmp1x1
);
6608 ok(ret
== 0, "Expect ret to be 0\n");
6609 hbmp
= (HBITMAP
)SendMessageA(hwnd
, BM_GETIMAGE
, (WPARAM
)IMAGE_BITMAP
, 0);
6610 ok(hbmp
== NULL
, "Expect hbmp to be NULL\n");
6611 DestroyWindow(hwnd
);
6613 DestroyIcon(hicon2x2
);
6614 DeleteObject(hmask2x2
);
6615 DeleteObject(hbmp2x2
);
6616 DeleteObject(hbmp1x1
);
6620 /****************** static message test *************************/
6621 static const struct message WmSetFontStaticSeq2
[] =
6623 { WM_SETFONT
, sent
},
6624 { WM_PAINT
, sent
|defwinproc
|optional
},
6625 { WM_ERASEBKGND
, sent
|defwinproc
|optional
},
6626 { WM_CTLCOLORSTATIC
, sent
|defwinproc
|optional
},
6630 static WNDPROC old_static_proc
;
6632 static LRESULT CALLBACK
static_hook_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
6634 static LONG defwndproc_counter
= 0;
6636 struct recvd_message msg
;
6638 if (ignore_message( message
)) return 0;
6641 msg
.message
= message
;
6642 msg
.flags
= sent
|wparam
|lparam
;
6643 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
6644 msg
.wParam
= wParam
;
6645 msg
.lParam
= lParam
;
6646 msg
.descr
= "static";
6649 defwndproc_counter
++;
6650 ret
= CallWindowProcA(old_static_proc
, hwnd
, message
, wParam
, lParam
);
6651 defwndproc_counter
--;
6656 static void subclass_static(void)
6660 if (!GetClassInfoA(0, "static", &cls
)) assert(0);
6662 old_static_proc
= cls
.lpfnWndProc
;
6664 cls
.hInstance
= GetModuleHandleA(NULL
);
6665 cls
.lpfnWndProc
= static_hook_proc
;
6666 cls
.lpszClassName
= "my_static_class";
6667 UnregisterClassA(cls
.lpszClassName
, cls
.hInstance
);
6668 if (!RegisterClassA(&cls
)) assert(0);
6671 static void test_static_messages(void)
6673 /* FIXME: make as comprehensive as the button message test */
6678 const struct message
*setfont
;
6680 { SS_LEFT
, DLGC_STATIC
,
6681 WmSetFontStaticSeq2
}
6689 for (i
= 0; i
< sizeof(static_ctrl
)/sizeof(static_ctrl
[0]); i
++)
6691 hwnd
= CreateWindowExA(0, "my_static_class", "test", static_ctrl
[i
].style
| WS_POPUP
,
6692 0, 0, 50, 14, 0, 0, 0, NULL
);
6693 ok(hwnd
!= 0, "Failed to create static window\n");
6695 dlg_code
= SendMessageA(hwnd
, WM_GETDLGCODE
, 0, 0);
6696 ok(dlg_code
== static_ctrl
[i
].dlg_code
, "%u: wrong dlg_code %08x\n", i
, dlg_code
);
6698 ShowWindow(hwnd
, SW_SHOW
);
6703 trace("static style %08x\n", static_ctrl
[i
].style
);
6704 SendMessageA(hwnd
, WM_SETFONT
, (WPARAM
)GetStockObject(DEFAULT_GUI_FONT
), TRUE
);
6705 ok_sequence(static_ctrl
[i
].setfont
, "WM_SETFONT on a static", FALSE
);
6707 DestroyWindow(hwnd
);
6711 /****************** ComboBox message test *************************/
6712 #define ID_COMBOBOX 0x000f
6714 static const struct message SetCurSelComboSeq
[] =
6716 { CB_SETCURSEL
, sent
|wparam
|lparam
, 0, 0 },
6717 { LB_SETCURSEL
, sent
|wparam
|lparam
, 0, 0 },
6718 { LB_SETTOPINDEX
, sent
|wparam
|lparam
, 0, 0 },
6719 { LB_GETCURSEL
, sent
|wparam
|lparam
, 0, 0 },
6720 { LB_GETTEXTLEN
, sent
|wparam
|lparam
, 0, 0 },
6721 { LB_GETTEXTLEN
, sent
|wparam
|lparam
|optional
, 0, 0 }, /* TODO: it's sent on all Windows versions */
6722 { LB_GETTEXT
, sent
|wparam
, 0 },
6723 { WM_CTLCOLOREDIT
, sent
|parent
},
6724 { LB_GETITEMDATA
, sent
|wparam
|lparam
, 0, 0 },
6725 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_COMBOBOX
, 0x100010f3 },
6729 static const struct message SetCurSelComboSeq2
[] =
6731 { CB_SETCURSEL
, sent
|wparam
|lparam
, 0, 0 },
6732 { LB_SETCURSEL
, sent
|wparam
|lparam
, 0, 0 },
6733 { LB_SETTOPINDEX
, sent
|wparam
|lparam
, 0, 0 },
6734 { LB_GETCURSEL
, sent
|wparam
|lparam
, 0, 0 },
6735 { LB_GETTEXTLEN
, sent
|wparam
|lparam
, 0, 0 },
6736 { LB_GETTEXTLEN
, sent
|wparam
|lparam
|optional
, 0, 0 }, /* TODO: it's sent on all Windows versions */
6737 { LB_GETTEXT
, sent
|wparam
, 0 },
6741 static const struct message SetCurSelComboSeq_edit
[] =
6743 { CB_SETCURSEL
, sent
|wparam
|lparam
, 0, 0 },
6744 { WM_SETTEXT
, sent
|wparam
, 0 },
6745 { EM_SETSEL
, sent
|wparam
|lparam
, 0, INT_MAX
},
6749 static const struct message WmKeyDownComboSeq
[] =
6751 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_DOWN
, 0 },
6752 { WM_COMMAND
, sent
|wparam
|defwinproc
, MAKEWPARAM(1000, LBN_SELCHANGE
) },
6753 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_COMBOBOX
, CBN_SELENDOK
) },
6754 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_COMBOBOX
, CBN_SELCHANGE
) },
6755 { WM_CTLCOLOREDIT
, sent
|parent
},
6756 { WM_KEYUP
, sent
|wparam
|lparam
, VK_DOWN
, 0 },
6760 static const struct message WmSetPosComboSeq
[] =
6762 { WM_WINDOWPOSCHANGING
, sent
},
6763 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
6764 { WM_CHILDACTIVATE
, sent
},
6765 { WM_WINDOWPOSCHANGED
, sent
},
6766 { WM_MOVE
, sent
|defwinproc
},
6767 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
6768 { WM_WINDOWPOSCHANGING
, sent
|defwinproc
},
6769 { WM_NCCALCSIZE
, sent
|defwinproc
|wparam
, TRUE
},
6770 { WM_WINDOWPOSCHANGED
, sent
|defwinproc
},
6771 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
6775 static const struct message WMSetFocusComboBoxSeq
[] =
6777 { WM_SETFOCUS
, sent
},
6778 { WM_KILLFOCUS
, sent
|parent
},
6779 { WM_SETFOCUS
, sent
},
6780 { WM_COMMAND
, sent
|defwinproc
|wparam
, MAKEWPARAM(1001, EN_SETFOCUS
) },
6781 { EM_SETSEL
, sent
|defwinproc
|wparam
|lparam
, 0, INT_MAX
},
6782 { WM_CTLCOLOREDIT
, sent
|defwinproc
|optional
},/* Not sent on W2000, XP or Server 2003 */
6783 { WM_CTLCOLOREDIT
, sent
|parent
|optional
},/* Not sent on W2000, XP or Server 2003 */
6784 { WM_COMMAND
, sent
|parent
|wparam
, MAKEWPARAM(ID_COMBOBOX
, CBN_SETFOCUS
) },
6788 static const struct message SetFocusButtonSeq
[] =
6790 { WM_KILLFOCUS
, sent
},
6791 { CB_GETCOMBOBOXINFO
, sent
|optional
},/* Windows 2000 */
6792 { 0x0167, sent
|optional
},/* Undocumented message. Sent on all versions except Windows 2000 */
6793 { WM_LBUTTONUP
, sent
|defwinproc
},
6794 { WM_COMMAND
, sent
|parent
|wparam
, MAKEWPARAM(ID_COMBOBOX
, CBN_SELENDCANCEL
) },
6795 { EM_SETSEL
, sent
|defwinproc
|wparam
|lparam
, 0, 0 },
6796 { WM_CTLCOLOREDIT
, sent
|defwinproc
|optional
},/* Not sent on W2000, XP or Server 2003 */
6797 { WM_CTLCOLOREDIT
, sent
|parent
|optional
},/* Not sent on W2000, XP or Server 2003 */
6798 { WM_COMMAND
, sent
|parent
|wparam
, MAKEWPARAM(ID_COMBOBOX
, CBN_KILLFOCUS
) },
6799 { WM_CTLCOLORBTN
, sent
|parent
},
6803 static const struct message SetFocusComboBoxSeq
[] =
6805 { WM_CTLCOLORBTN
, sent
|parent
},
6806 { WM_SETFOCUS
, sent
},
6807 { WM_KILLFOCUS
, sent
|defwinproc
},
6808 { WM_SETFOCUS
, sent
},
6809 { WM_COMMAND
, sent
|defwinproc
|wparam
, MAKEWPARAM(1001, EN_SETFOCUS
) },
6810 { EM_SETSEL
, sent
|defwinproc
|wparam
|lparam
, 0, INT_MAX
},
6811 { WM_CTLCOLOREDIT
, sent
|defwinproc
|optional
},/* Not sent on W2000, XP or Server 2003 */
6812 { WM_CTLCOLOREDIT
, sent
|parent
|optional
},/* Not sent on W2000, XP or Server 2003 */
6813 { WM_COMMAND
, sent
|parent
|wparam
, MAKEWPARAM(ID_COMBOBOX
, CBN_SETFOCUS
) },
6817 static const struct message SetFocusButtonSeq2
[] =
6819 { WM_KILLFOCUS
, sent
},
6820 { CB_GETCOMBOBOXINFO
, sent
|optional
},/* Windows 2000 */
6821 { 0x0167, sent
|optional
},/* Undocumented message. Sent on all versions except Windows 2000 */
6822 { WM_LBUTTONUP
, sent
|defwinproc
},
6823 { WM_COMMAND
, sent
|parent
|wparam
, MAKEWPARAM(ID_COMBOBOX
, CBN_SELENDCANCEL
) },
6824 { EM_SETSEL
, sent
|defwinproc
|wparam
|lparam
, 0, 0 },
6825 { WM_CTLCOLOREDIT
, sent
|defwinproc
},
6826 { WM_CTLCOLOREDIT
, sent
|parent
},
6827 { WM_COMMAND
, sent
|parent
|wparam
, MAKEWPARAM(ID_COMBOBOX
, CBN_KILLFOCUS
) },
6828 { WM_CTLCOLORBTN
, sent
|parent
},
6832 static WNDPROC old_combobox_proc
, edit_window_proc
, lbox_window_proc
;
6834 static LRESULT CALLBACK
combobox_edit_subclass_proc(HWND hwnd
, UINT message
,
6835 WPARAM wParam
, LPARAM lParam
)
6837 static LONG defwndproc_counter
= 0;
6839 struct recvd_message msg
;
6841 /* do not log painting messages */
6842 if (message
!= WM_PAINT
&&
6843 message
!= WM_NCPAINT
&&
6844 message
!= WM_SYNCPAINT
&&
6845 message
!= WM_ERASEBKGND
&&
6846 message
!= WM_NCHITTEST
&&
6847 message
!= WM_GETTEXT
&&
6848 !ignore_message( message
))
6851 msg
.message
= message
;
6852 msg
.flags
= sent
|wparam
|lparam
;
6853 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
6854 msg
.wParam
= wParam
;
6855 msg
.lParam
= lParam
;
6856 msg
.descr
= "combo edit";
6860 defwndproc_counter
++;
6861 ret
= CallWindowProcA(edit_window_proc
, hwnd
, message
, wParam
, lParam
);
6862 defwndproc_counter
--;
6867 static LRESULT CALLBACK
combobox_lbox_subclass_proc(HWND hwnd
, UINT message
,
6868 WPARAM wParam
, LPARAM lParam
)
6870 static LONG defwndproc_counter
= 0;
6872 struct recvd_message msg
;
6874 /* do not log painting messages */
6875 if (message
!= WM_PAINT
&&
6876 message
!= WM_NCPAINT
&&
6877 message
!= WM_SYNCPAINT
&&
6878 message
!= WM_ERASEBKGND
&&
6879 message
!= WM_NCHITTEST
&&
6880 !ignore_message( message
))
6883 msg
.message
= message
;
6884 msg
.flags
= sent
|wparam
|lparam
;
6885 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
6886 msg
.wParam
= wParam
;
6887 msg
.lParam
= lParam
;
6888 msg
.descr
= "combo lbox";
6892 defwndproc_counter
++;
6893 ret
= CallWindowProcA(lbox_window_proc
, hwnd
, message
, wParam
, lParam
);
6894 defwndproc_counter
--;
6899 static LRESULT CALLBACK
combobox_hook_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
6901 static LONG defwndproc_counter
= 0;
6903 struct recvd_message msg
;
6905 /* do not log painting messages */
6906 if (message
!= WM_PAINT
&&
6907 message
!= WM_NCPAINT
&&
6908 message
!= WM_SYNCPAINT
&&
6909 message
!= WM_ERASEBKGND
&&
6910 message
!= WM_NCHITTEST
&&
6911 message
!= WM_GETTEXT
&&
6912 !ignore_message( message
))
6915 msg
.message
= message
;
6916 msg
.flags
= sent
|wparam
|lparam
;
6917 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
6918 msg
.wParam
= wParam
;
6919 msg
.lParam
= lParam
;
6920 msg
.descr
= "combo";
6924 defwndproc_counter
++;
6925 ret
= CallWindowProcA(old_combobox_proc
, hwnd
, message
, wParam
, lParam
);
6926 defwndproc_counter
--;
6931 static void subclass_combobox(void)
6935 if (!GetClassInfoA(0, "ComboBox", &cls
)) assert(0);
6937 old_combobox_proc
= cls
.lpfnWndProc
;
6939 cls
.hInstance
= GetModuleHandleA(NULL
);
6940 cls
.lpfnWndProc
= combobox_hook_proc
;
6941 cls
.lpszClassName
= "my_combobox_class";
6942 UnregisterClassA(cls
.lpszClassName
, cls
.hInstance
);
6943 if (!RegisterClassA(&cls
)) assert(0);
6946 static void test_combobox_messages(void)
6948 HWND parent
, combo
, button
, edit
, lbox
;
6950 COMBOBOXINFO cbInfo
;
6953 subclass_combobox();
6955 parent
= CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
6956 100, 100, 200, 200, 0, 0, 0, NULL
);
6957 ok(parent
!= 0, "Failed to create parent window\n");
6960 combo
= CreateWindowExA(0, "my_combobox_class", "test", WS_CHILD
| WS_VISIBLE
| CBS_DROPDOWNLIST
| CBS_HASSTRINGS
,
6961 0, 0, 100, 150, parent
, (HMENU
)ID_COMBOBOX
, 0, NULL
);
6962 ok(combo
!= 0, "Failed to create combobox window\n");
6964 UpdateWindow(combo
);
6966 ret
= SendMessageA(combo
, WM_GETDLGCODE
, 0, 0);
6967 ok(ret
== (DLGC_WANTCHARS
| DLGC_WANTARROWS
), "wrong dlg_code %08lx\n", ret
);
6969 ret
= SendMessageA(combo
, CB_ADDSTRING
, 0, (LPARAM
)"item 0");
6970 ok(ret
== 0, "expected 0, got %ld\n", ret
);
6971 ret
= SendMessageA(combo
, CB_ADDSTRING
, 0, (LPARAM
)"item 1");
6972 ok(ret
== 1, "expected 1, got %ld\n", ret
);
6973 ret
= SendMessageA(combo
, CB_ADDSTRING
, 0, (LPARAM
)"item 2");
6974 ok(ret
== 2, "expected 2, got %ld\n", ret
);
6976 SendMessageA(combo
, CB_SETCURSEL
, 0, 0);
6980 log_all_parent_messages
++;
6981 SendMessageA(combo
, WM_KEYDOWN
, VK_DOWN
, 0);
6982 SendMessageA(combo
, WM_KEYUP
, VK_DOWN
, 0);
6983 log_all_parent_messages
--;
6984 ok_sequence(WmKeyDownComboSeq
, "WM_KEYDOWN/VK_DOWN on a ComboBox", FALSE
);
6987 SetWindowPos(combo
, 0, 10, 10, 120, 130, SWP_NOZORDER
);
6988 ok_sequence(WmSetPosComboSeq
, "repositioning messages on a ComboBox", FALSE
);
6990 DestroyWindow(combo
);
6991 DestroyWindow(parent
);
6993 /* Start again. Test combobox text selection when getting and losing focus */
6994 parent
= CreateWindowExA(0, "TestParentClass", "Parent", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
6995 10, 10, 300, 300, NULL
, NULL
, NULL
, NULL
);
6996 ok(parent
!= 0, "Failed to create parent window\n");
6998 combo
= CreateWindowExA(0, "my_combobox_class", "test", WS_CHILD
| WS_VISIBLE
| CBS_DROPDOWN
,
6999 5, 5, 100, 100, parent
, (HMENU
)ID_COMBOBOX
, NULL
, NULL
);
7000 ok(combo
!= 0, "Failed to create combobox window\n");
7002 cbInfo
.cbSize
= sizeof(COMBOBOXINFO
);
7003 SetLastError(0xdeadbeef);
7004 res
= GetComboBoxInfo(combo
, &cbInfo
);
7005 ok(res
, "Failed to get COMBOBOXINFO structure; LastError: %u\n", GetLastError());
7006 edit
= cbInfo
.hwndItem
;
7008 edit_window_proc
= (WNDPROC
)SetWindowLongPtrA(edit
, GWLP_WNDPROC
,
7009 (ULONG_PTR
)combobox_edit_subclass_proc
);
7011 button
= CreateWindowExA(0, "Button", "OK", WS_CHILD
| WS_VISIBLE
| BS_DEFPUSHBUTTON
,
7012 5, 50, 100, 20, parent
, NULL
,
7013 (HINSTANCE
)GetWindowLongPtrA(parent
, GWLP_HINSTANCE
), NULL
);
7014 ok(button
!= 0, "Failed to create button window\n");
7017 log_all_parent_messages
++;
7018 SendMessageA(combo
, WM_SETFOCUS
, 0, (LPARAM
)edit
);
7019 log_all_parent_messages
--;
7020 ok_sequence(WMSetFocusComboBoxSeq
, "WM_SETFOCUS on a ComboBox", TRUE
);
7023 log_all_parent_messages
++;
7025 log_all_parent_messages
--;
7026 ok_sequence(SetFocusButtonSeq
, "SetFocus on a Button", TRUE
);
7028 SendMessageA(combo
, WM_SETTEXT
, 0, (LPARAM
)"Wine Test");
7031 log_all_parent_messages
++;
7033 log_all_parent_messages
--;
7034 ok_sequence(SetFocusComboBoxSeq
, "SetFocus on a ComboBox", TRUE
);
7037 log_all_parent_messages
++;
7039 log_all_parent_messages
--;
7040 ok_sequence(SetFocusButtonSeq2
, "SetFocus on a Button (2)", TRUE
);
7043 SendMessageA(combo
, WM_SETREDRAW
, FALSE
, 0);
7045 log_all_parent_messages
++;
7046 SendMessageA(combo
, CB_SETCURSEL
, 0, 0);
7047 log_all_parent_messages
--;
7048 ok_sequence(SetCurSelComboSeq_edit
, "CB_SETCURSEL on a ComboBox with edit control", FALSE
);
7050 DestroyWindow(button
);
7051 DestroyWindow(combo
);
7053 combo
= CreateWindowExA(0, "my_combobox_class", "test",
7054 WS_CHILD
| WS_VISIBLE
| CBS_OWNERDRAWFIXED
| CBS_DROPDOWNLIST
,
7055 5, 5, 100, 100, parent
, (HMENU
)ID_COMBOBOX
, NULL
, NULL
);
7056 ok(combo
!= 0, "Failed to create combobox window\n");
7058 ret
= SendMessageA(combo
, CB_ADDSTRING
, 0, (LPARAM
)"item 0");
7059 ok(ret
== 0, "expected 0, got %ld\n", ret
);
7061 cbInfo
.cbSize
= sizeof(COMBOBOXINFO
);
7062 SetLastError(0xdeadbeef);
7063 res
= GetComboBoxInfo(combo
, &cbInfo
);
7064 ok(res
, "Failed to get COMBOBOXINFO structure; LastError: %u\n", GetLastError());
7065 lbox
= cbInfo
.hwndList
;
7066 lbox_window_proc
= (WNDPROC
)SetWindowLongPtrA(lbox
, GWLP_WNDPROC
,
7067 (ULONG_PTR
)combobox_lbox_subclass_proc
);
7070 log_all_parent_messages
++;
7071 SendMessageA(combo
, CB_SETCURSEL
, 0, 0);
7072 log_all_parent_messages
--;
7073 ok_sequence(SetCurSelComboSeq
, "CB_SETCURSEL on a ComboBox", FALSE
);
7075 ShowWindow(combo
, SW_HIDE
);
7077 log_all_parent_messages
++;
7078 SendMessageA(combo
, CB_SETCURSEL
, 0, 0);
7079 log_all_parent_messages
--;
7080 ok_sequence(SetCurSelComboSeq2
, "CB_SETCURSEL on a ComboBox", FALSE
);
7082 DestroyWindow(combo
);
7083 DestroyWindow(parent
);
7086 /****************** WM_IME_KEYDOWN message test *******************/
7088 static const struct message WmImeKeydownMsgSeq_0
[] =
7090 { WM_IME_KEYDOWN
, wparam
, VK_RETURN
},
7091 { WM_CHAR
, wparam
, 'A' },
7095 static const struct message WmImeKeydownMsgSeq_1
[] =
7097 { WM_KEYDOWN
, optional
|wparam
, VK_RETURN
},
7098 { WM_CHAR
, optional
|wparam
, VK_RETURN
},
7102 static LRESULT WINAPI
wmime_keydown_procA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
7104 struct recvd_message msg
;
7107 msg
.message
= message
;
7108 msg
.flags
= wparam
|lparam
;
7109 msg
.wParam
= wParam
;
7110 msg
.lParam
= lParam
;
7111 msg
.descr
= "wmime_keydown";
7114 return DefWindowProcA(hwnd
, message
, wParam
, lParam
);
7117 static void register_wmime_keydown_class(void)
7121 ZeroMemory(&cls
, sizeof(WNDCLASSA
));
7122 cls
.lpfnWndProc
= wmime_keydown_procA
;
7123 cls
.hInstance
= GetModuleHandleA(0);
7124 cls
.lpszClassName
= "wmime_keydown_class";
7125 if (!RegisterClassA(&cls
)) assert(0);
7128 static void test_wmime_keydown_message(void)
7133 trace("Message sequences by WM_IME_KEYDOWN\n");
7135 register_wmime_keydown_class();
7136 hwnd
= CreateWindowExA(0, "wmime_keydown_class", NULL
, WS_OVERLAPPEDWINDOW
,
7137 CW_USEDEFAULT
, CW_USEDEFAULT
, 300, 300, 0,
7142 SendMessageA(hwnd
, WM_IME_KEYDOWN
, VK_RETURN
, 0x1c0001);
7143 SendMessageA(hwnd
, WM_CHAR
, 'A', 1);
7144 ok_sequence(WmImeKeydownMsgSeq_0
, "WM_IME_KEYDOWN 0", FALSE
);
7146 while ( PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
) )
7148 TranslateMessage(&msg
);
7149 DispatchMessageA(&msg
);
7151 ok_sequence(WmImeKeydownMsgSeq_1
, "WM_IME_KEYDOWN 1", FALSE
);
7153 DestroyWindow(hwnd
);
7156 /************* painting message test ********************/
7158 void dump_region(HRGN hrgn
)
7161 RGNDATA
*data
= NULL
;
7166 printf( "null region\n" );
7169 if (!(size
= GetRegionData( hrgn
, 0, NULL
))) return;
7170 if (!(data
= HeapAlloc( GetProcessHeap(), 0, size
))) return;
7171 GetRegionData( hrgn
, size
, data
);
7172 printf("%d rects:", data
->rdh
.nCount
);
7173 for (i
= 0, rect
= (RECT
*)data
->Buffer
; i
< data
->rdh
.nCount
; i
++, rect
++)
7174 printf( " %s", wine_dbgstr_rect( rect
));
7176 HeapFree( GetProcessHeap(), 0, data
);
7179 static void check_update_rgn( HWND hwnd
, HRGN hrgn
)
7183 HRGN tmp
= CreateRectRgn( 0, 0, 0, 0 );
7184 HRGN update
= CreateRectRgn( 0, 0, 0, 0 );
7186 ret
= GetUpdateRgn( hwnd
, update
, FALSE
);
7187 ok( ret
!= ERROR
, "GetUpdateRgn failed\n" );
7188 if (ret
== NULLREGION
)
7190 ok( !hrgn
, "Update region shouldn't be empty\n" );
7194 if (CombineRgn( tmp
, hrgn
, update
, RGN_XOR
) != NULLREGION
)
7196 ok( 0, "Regions are different\n" );
7197 if (winetest_debug
> 0)
7199 printf( "Update region: " );
7200 dump_region( update
);
7201 printf( "Wanted region: " );
7202 dump_region( hrgn
);
7206 GetRgnBox( update
, &r1
);
7207 GetUpdateRect( hwnd
, &r2
, FALSE
);
7208 ok( EqualRect( &r1
, &r2
), "Rectangles are different: %s / %s\n", wine_dbgstr_rect( &r1
),
7209 wine_dbgstr_rect( &r2
));
7211 DeleteObject( tmp
);
7212 DeleteObject( update
);
7215 static const struct message WmInvalidateRgn
[] = {
7216 { WM_NCPAINT
, sent
},
7217 { WM_GETTEXT
, sent
|defwinproc
|optional
},
7221 static const struct message WmGetUpdateRect
[] = {
7222 { WM_NCPAINT
, sent
},
7223 { WM_GETTEXT
, sent
|defwinproc
|optional
},
7228 static const struct message WmInvalidateFull
[] = {
7229 { WM_NCPAINT
, sent
|wparam
, 1 },
7230 { WM_GETTEXT
, sent
|defwinproc
|optional
},
7234 static const struct message WmInvalidateErase
[] = {
7235 { WM_NCPAINT
, sent
|wparam
, 1 },
7236 { WM_GETTEXT
, sent
|defwinproc
|optional
},
7237 { WM_ERASEBKGND
, sent
},
7241 static const struct message WmInvalidatePaint
[] = {
7243 { WM_NCPAINT
, sent
|wparam
|beginpaint
, 1 },
7244 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
7248 static const struct message WmInvalidateErasePaint
[] = {
7250 { WM_NCPAINT
, sent
|wparam
|beginpaint
, 1 },
7251 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
7252 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
7256 static const struct message WmInvalidateErasePaint2
[] = {
7258 { WM_NCPAINT
, sent
|beginpaint
},
7259 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
7260 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
7264 static const struct message WmErase
[] = {
7265 { WM_ERASEBKGND
, sent
},
7269 static const struct message WmPaint
[] = {
7274 static const struct message WmParentOnlyPaint
[] = {
7275 { WM_PAINT
, sent
|parent
},
7279 static const struct message WmInvalidateParent
[] = {
7280 { WM_NCPAINT
, sent
|parent
},
7281 { WM_GETTEXT
, sent
|defwinproc
|parent
|optional
},
7282 { WM_ERASEBKGND
, sent
|parent
},
7286 static const struct message WmInvalidateParentChild
[] = {
7287 { WM_NCPAINT
, sent
|parent
},
7288 { WM_GETTEXT
, sent
|defwinproc
|parent
|optional
},
7289 { WM_ERASEBKGND
, sent
|parent
},
7290 { WM_NCPAINT
, sent
},
7291 { WM_GETTEXT
, sent
|defwinproc
|optional
},
7292 { WM_ERASEBKGND
, sent
},
7296 static const struct message WmInvalidateParentChild2
[] = {
7297 { WM_ERASEBKGND
, sent
|parent
},
7298 { WM_NCPAINT
, sent
},
7299 { WM_GETTEXT
, sent
|defwinproc
|optional
},
7300 { WM_ERASEBKGND
, sent
},
7304 static const struct message WmParentPaint
[] = {
7305 { WM_PAINT
, sent
|parent
},
7310 static const struct message WmParentPaintNc
[] = {
7311 { WM_PAINT
, sent
|parent
},
7313 { WM_NCPAINT
, sent
|beginpaint
},
7314 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
7315 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
7319 static const struct message WmChildPaintNc
[] = {
7321 { WM_NCPAINT
, sent
|beginpaint
},
7322 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
7323 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
7327 static const struct message WmParentErasePaint
[] = {
7328 { WM_PAINT
, sent
|parent
},
7329 { WM_NCPAINT
, sent
|parent
|beginpaint
},
7330 { WM_GETTEXT
, sent
|parent
|beginpaint
|defwinproc
|optional
},
7331 { WM_ERASEBKGND
, sent
|parent
|beginpaint
|optional
},
7333 { WM_NCPAINT
, sent
|beginpaint
},
7334 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
7335 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
7339 static const struct message WmParentOnlyNcPaint
[] = {
7340 { WM_PAINT
, sent
|parent
},
7341 { WM_NCPAINT
, sent
|parent
|beginpaint
},
7342 { WM_GETTEXT
, sent
|parent
|beginpaint
|defwinproc
|optional
},
7346 static const struct message WmSetParentStyle
[] = {
7347 { WM_STYLECHANGING
, sent
|parent
},
7348 { WM_STYLECHANGED
, sent
|parent
},
7352 static void test_paint_messages(void)
7358 HWND hparent
, hchild
;
7359 HRGN hrgn
= CreateRectRgn( 0, 0, 0, 0 );
7360 HRGN hrgn2
= CreateRectRgn( 0, 0, 0, 0 );
7361 HWND hwnd
= CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW
,
7362 100, 100, 200, 200, 0, 0, 0, NULL
);
7363 ok (hwnd
!= 0, "Failed to create overlapped window\n");
7365 ShowWindow( hwnd
, SW_SHOW
);
7366 UpdateWindow( hwnd
);
7370 check_update_rgn( hwnd
, 0 );
7371 SetRectRgn( hrgn
, 10, 10, 20, 20 );
7372 ret
= RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
);
7373 ok(ret
, "RedrawWindow returned %d instead of TRUE\n", ret
);
7374 check_update_rgn( hwnd
, hrgn
);
7375 SetRectRgn( hrgn2
, 20, 20, 30, 30 );
7376 ret
= RedrawWindow( hwnd
, NULL
, hrgn2
, RDW_INVALIDATE
);
7377 ok(ret
, "RedrawWindow returned %d instead of TRUE\n", ret
);
7378 CombineRgn( hrgn
, hrgn
, hrgn2
, RGN_OR
);
7379 check_update_rgn( hwnd
, hrgn
);
7380 /* validate everything */
7381 ret
= RedrawWindow( hwnd
, NULL
, NULL
, RDW_VALIDATE
);
7382 ok(ret
, "RedrawWindow returned %d instead of TRUE\n", ret
);
7383 check_update_rgn( hwnd
, 0 );
7385 /* test empty region */
7386 SetRectRgn( hrgn
, 10, 10, 10, 15 );
7387 ret
= RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
);
7388 ok(ret
, "RedrawWindow returned %d instead of TRUE\n", ret
);
7389 check_update_rgn( hwnd
, 0 );
7390 /* test empty rect */
7391 SetRect( &rect
, 10, 10, 10, 15 );
7392 ret
= RedrawWindow( hwnd
, &rect
, NULL
, RDW_INVALIDATE
);
7393 ok(ret
, "RedrawWindow returned %d instead of TRUE\n", ret
);
7394 check_update_rgn( hwnd
, 0 );
7396 /* flush pending messages */
7400 GetClientRect( hwnd
, &rect
);
7401 SetRectRgn( hrgn
, 0, 0, rect
.right
- rect
.left
, rect
.bottom
- rect
.top
);
7402 /* MSDN: if hwnd parameter is NULL, InvalidateRect invalidates and redraws
7403 * all windows and sends WM_ERASEBKGND and WM_NCPAINT.
7405 trace("testing InvalidateRect(0, NULL, FALSE)\n");
7406 SetRectEmpty( &rect
);
7407 ok(InvalidateRect(0, &rect
, FALSE
), "InvalidateRect(0, &rc, FALSE) should fail\n");
7408 check_update_rgn( hwnd
, hrgn
);
7409 ok_sequence( WmInvalidateErase
, "InvalidateErase", FALSE
);
7411 ok_sequence( WmPaint
, "Paint", FALSE
);
7412 RedrawWindow( hwnd
, NULL
, NULL
, RDW_VALIDATE
);
7413 check_update_rgn( hwnd
, 0 );
7415 /* MSDN: if hwnd parameter is NULL, ValidateRect invalidates and redraws
7416 * all windows and sends WM_ERASEBKGND and WM_NCPAINT.
7418 trace("testing ValidateRect(0, NULL)\n");
7419 SetRectEmpty( &rect
);
7420 if (ValidateRect(0, &rect
) && /* not supported on Win9x */
7421 GetUpdateRect(hwnd
, NULL
, FALSE
)) /* or >= Win 8 */
7423 check_update_rgn( hwnd
, hrgn
);
7424 ok_sequence( WmInvalidateErase
, "InvalidateErase", FALSE
);
7426 ok_sequence( WmPaint
, "Paint", FALSE
);
7427 RedrawWindow( hwnd
, NULL
, NULL
, RDW_VALIDATE
);
7428 check_update_rgn( hwnd
, 0 );
7431 trace("testing InvalidateRgn(0, NULL, FALSE)\n");
7432 SetLastError(0xdeadbeef);
7433 ok(!InvalidateRgn(0, NULL
, FALSE
), "InvalidateRgn(0, NULL, FALSE) should fail\n");
7434 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
|| GetLastError() == 0xdeadbeef,
7435 "wrong error code %d\n", GetLastError());
7436 check_update_rgn( hwnd
, 0 );
7438 ok_sequence( WmEmptySeq
, "WmEmptySeq", FALSE
);
7440 trace("testing ValidateRgn(0, NULL)\n");
7441 SetLastError(0xdeadbeef);
7442 ok(!ValidateRgn(0, NULL
), "ValidateRgn(0, NULL) should fail\n");
7443 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
||
7444 broken( GetLastError() == 0xdeadbeef ) /* win9x */,
7445 "wrong error code %d\n", GetLastError());
7446 check_update_rgn( hwnd
, 0 );
7448 ok_sequence( WmEmptySeq
, "WmEmptySeq", FALSE
);
7450 trace("testing UpdateWindow(NULL)\n");
7451 SetLastError(0xdeadbeef);
7452 ok(!UpdateWindow(NULL
), "UpdateWindow(NULL) should fail\n");
7453 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
||
7454 broken( GetLastError() == 0xdeadbeef ) /* win9x */,
7455 "wrong error code %d\n", GetLastError());
7456 check_update_rgn( hwnd
, 0 );
7458 ok_sequence( WmEmptySeq
, "WmEmptySeq", FALSE
);
7460 /* now with frame */
7461 SetRectRgn( hrgn
, -5, -5, 20, 20 );
7463 /* flush pending messages */
7466 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_FRAME
);
7467 ok_sequence( WmEmptySeq
, "EmptySeq", FALSE
);
7469 SetRectRgn( hrgn
, 0, 0, 20, 20 ); /* GetUpdateRgn clips to client area */
7470 check_update_rgn( hwnd
, hrgn
);
7473 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASENOW
);
7474 ok_sequence( WmInvalidateRgn
, "InvalidateRgn", FALSE
);
7477 RedrawWindow( hwnd
, NULL
, NULL
, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASENOW
);
7478 ok_sequence( WmInvalidateFull
, "InvalidateFull", FALSE
);
7480 GetClientRect( hwnd
, &rect
);
7481 SetRectRgn( hrgn
, rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
7482 check_update_rgn( hwnd
, hrgn
);
7485 RedrawWindow( hwnd
, NULL
, NULL
, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASE
| RDW_ERASENOW
);
7486 ok_sequence( WmInvalidateErase
, "InvalidateErase", FALSE
);
7489 RedrawWindow( hwnd
, NULL
, NULL
, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASENOW
| RDW_UPDATENOW
);
7490 ok_sequence( WmInvalidatePaint
, "InvalidatePaint", FALSE
);
7491 check_update_rgn( hwnd
, 0 );
7494 RedrawWindow( hwnd
, NULL
, NULL
, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASE
| RDW_UPDATENOW
);
7495 ok_sequence( WmInvalidateErasePaint
, "InvalidateErasePaint", FALSE
);
7496 check_update_rgn( hwnd
, 0 );
7499 SetRectRgn( hrgn
, 0, 0, 100, 100 );
7500 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
);
7501 SetRectRgn( hrgn
, 0, 0, 50, 100 );
7502 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_VALIDATE
);
7503 SetRectRgn( hrgn
, 50, 0, 100, 100 );
7504 check_update_rgn( hwnd
, hrgn
);
7505 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_VALIDATE
| RDW_ERASENOW
);
7506 ok_sequence( WmEmptySeq
, "EmptySeq", FALSE
); /* must not generate messages, everything is valid */
7507 check_update_rgn( hwnd
, 0 );
7510 SetRectRgn( hrgn
, 0, 0, 100, 100 );
7511 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_ERASE
);
7512 SetRectRgn( hrgn
, 0, 0, 100, 50 );
7513 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_VALIDATE
| RDW_ERASENOW
);
7514 ok_sequence( WmErase
, "Erase", FALSE
);
7515 SetRectRgn( hrgn
, 0, 50, 100, 100 );
7516 check_update_rgn( hwnd
, hrgn
);
7519 SetRectRgn( hrgn
, 0, 0, 100, 100 );
7520 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_ERASE
);
7521 SetRectRgn( hrgn
, 0, 0, 50, 50 );
7522 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_VALIDATE
| RDW_NOERASE
| RDW_UPDATENOW
);
7523 ok_sequence( WmPaint
, "Paint", FALSE
);
7526 SetRectRgn( hrgn
, -4, -4, -2, -2 );
7527 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_FRAME
);
7528 SetRectRgn( hrgn
, -200, -200, -198, -198 );
7529 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_VALIDATE
| RDW_NOFRAME
| RDW_ERASENOW
);
7530 ok_sequence( WmEmptySeq
, "EmptySeq", FALSE
);
7533 SetRectRgn( hrgn
, -4, -4, -2, -2 );
7534 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_FRAME
);
7535 SetRectRgn( hrgn
, -4, -4, -3, -3 );
7536 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_VALIDATE
| RDW_NOFRAME
);
7537 SetRectRgn( hrgn
, 0, 0, 1, 1 );
7538 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_UPDATENOW
);
7539 ok_sequence( WmPaint
, "Paint", FALSE
);
7542 SetRectRgn( hrgn
, -4, -4, -1, -1 );
7543 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_FRAME
);
7544 RedrawWindow( hwnd
, NULL
, 0, RDW_ERASENOW
);
7545 /* make sure no WM_PAINT was generated */
7547 ok_sequence( WmInvalidateRgn
, "InvalidateRgn", FALSE
);
7550 SetRectRgn( hrgn
, -4, -4, -1, -1 );
7551 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_FRAME
);
7552 while (PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
))
7554 if (msg
.hwnd
== hwnd
&& msg
.message
== WM_PAINT
)
7556 /* GetUpdateRgn must return empty region since only nonclient area is invalidated */
7557 INT ret
= GetUpdateRgn( hwnd
, hrgn
, FALSE
);
7558 ok( ret
== NULLREGION
, "Invalid GetUpdateRgn result %d\n", ret
);
7559 ret
= GetUpdateRect( hwnd
, &rect
, FALSE
);
7560 ok( ret
, "Invalid GetUpdateRect result %d\n", ret
);
7561 /* this will send WM_NCPAINT and validate the non client area */
7562 ret
= GetUpdateRect( hwnd
, &rect
, TRUE
);
7563 ok( !ret
, "Invalid GetUpdateRect result %d\n", ret
);
7565 DispatchMessageA( &msg
);
7567 ok_sequence( WmGetUpdateRect
, "GetUpdateRect", FALSE
);
7569 DestroyWindow( hwnd
);
7571 /* now test with a child window */
7573 hparent
= CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW
,
7574 100, 100, 200, 200, 0, 0, 0, NULL
);
7575 ok (hparent
!= 0, "Failed to create parent window\n");
7577 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
| WS_VISIBLE
| WS_BORDER
,
7578 10, 10, 100, 100, hparent
, 0, 0, NULL
);
7579 ok (hchild
!= 0, "Failed to create child window\n");
7581 ShowWindow( hparent
, SW_SHOW
);
7582 UpdateWindow( hparent
);
7583 UpdateWindow( hchild
);
7586 log_all_parent_messages
++;
7588 SetRect( &rect
, 0, 0, 50, 50 );
7589 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
7590 RedrawWindow( hparent
, NULL
, 0, RDW_ERASENOW
| RDW_ALLCHILDREN
);
7591 ok_sequence( WmInvalidateParentChild
, "InvalidateParentChild", FALSE
);
7593 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
7595 MapWindowPoints( hchild
, hparent
, &pt
, 1 );
7596 SetRectRgn( hrgn
, 0, 0, 50 - pt
.x
, 50 - pt
.y
);
7597 check_update_rgn( hchild
, hrgn
);
7598 SetRectRgn( hrgn
, 0, 0, 50, 50 );
7599 check_update_rgn( hparent
, hrgn
);
7600 RedrawWindow( hparent
, NULL
, 0, RDW_ERASENOW
);
7601 ok_sequence( WmInvalidateParent
, "InvalidateParent", FALSE
);
7602 RedrawWindow( hchild
, NULL
, 0, RDW_ERASENOW
);
7603 ok_sequence( WmEmptySeq
, "EraseNow child", FALSE
);
7606 ok_sequence( WmParentPaintNc
, "WmParentPaintNc", FALSE
);
7608 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
| RDW_ALLCHILDREN
);
7609 RedrawWindow( hparent
, NULL
, 0, RDW_ERASENOW
);
7610 ok_sequence( WmInvalidateParent
, "InvalidateParent2", FALSE
);
7611 RedrawWindow( hchild
, NULL
, 0, RDW_ERASENOW
);
7612 ok_sequence( WmEmptySeq
, "EraseNow child", FALSE
);
7614 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
);
7615 RedrawWindow( hparent
, NULL
, 0, RDW_ERASENOW
| RDW_ALLCHILDREN
);
7616 ok_sequence( WmInvalidateParentChild2
, "InvalidateParentChild2", FALSE
);
7618 SetWindowLongA( hparent
, GWL_STYLE
, GetWindowLongA(hparent
,GWL_STYLE
) | WS_CLIPCHILDREN
);
7620 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
| RDW_ALLCHILDREN
);
7621 RedrawWindow( hparent
, NULL
, 0, RDW_ERASENOW
);
7622 ok_sequence( WmInvalidateParentChild
, "InvalidateParentChild3", FALSE
);
7624 /* flush all paint messages */
7628 /* RDW_UPDATENOW on child with WS_CLIPCHILDREN doesn't change corresponding parent area */
7629 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
| RDW_ALLCHILDREN
);
7630 SetRectRgn( hrgn
, 0, 0, 50, 50 );
7631 check_update_rgn( hparent
, hrgn
);
7632 RedrawWindow( hchild
, NULL
, 0, RDW_UPDATENOW
);
7633 ok_sequence( WmInvalidateErasePaint2
, "WmInvalidateErasePaint2", FALSE
);
7634 SetRectRgn( hrgn
, 0, 0, 50, 50 );
7635 check_update_rgn( hparent
, hrgn
);
7637 /* flush all paint messages */
7639 SetWindowLongA( hparent
, GWL_STYLE
, GetWindowLongA(hparent
,GWL_STYLE
) & ~WS_CLIPCHILDREN
);
7642 /* RDW_UPDATENOW on child without WS_CLIPCHILDREN will validate corresponding parent area */
7643 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
7644 SetRectRgn( hrgn
, 0, 0, 50, 50 );
7645 check_update_rgn( hparent
, hrgn
);
7646 RedrawWindow( hchild
, NULL
, 0, RDW_UPDATENOW
);
7647 ok_sequence( WmInvalidateErasePaint2
, "WmInvalidateErasePaint2", FALSE
);
7648 SetRectRgn( hrgn2
, 10, 10, 50, 50 );
7649 CombineRgn( hrgn
, hrgn
, hrgn2
, RGN_DIFF
);
7650 check_update_rgn( hparent
, hrgn
);
7651 /* flush all paint messages */
7655 /* same as above but parent gets completely validated */
7656 SetRect( &rect
, 20, 20, 30, 30 );
7657 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
7658 SetRectRgn( hrgn
, 20, 20, 30, 30 );
7659 check_update_rgn( hparent
, hrgn
);
7660 RedrawWindow( hchild
, NULL
, 0, RDW_UPDATENOW
);
7661 ok_sequence( WmInvalidateErasePaint2
, "WmInvalidateErasePaint2", FALSE
);
7662 check_update_rgn( hparent
, 0 ); /* no update region */
7664 ok_sequence( WmEmptySeq
, "WmEmpty", FALSE
); /* and no paint messages */
7666 /* make sure RDW_VALIDATE on child doesn't have the same effect */
7668 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
7669 SetRectRgn( hrgn
, 20, 20, 30, 30 );
7670 check_update_rgn( hparent
, hrgn
);
7671 RedrawWindow( hchild
, NULL
, 0, RDW_VALIDATE
| RDW_NOERASE
);
7672 SetRectRgn( hrgn
, 20, 20, 30, 30 );
7673 check_update_rgn( hparent
, hrgn
);
7675 /* same as above but normal WM_PAINT doesn't validate parent */
7677 SetRect( &rect
, 20, 20, 30, 30 );
7678 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
7679 SetRectRgn( hrgn
, 20, 20, 30, 30 );
7680 check_update_rgn( hparent
, hrgn
);
7681 /* no WM_PAINT in child while parent still pending */
7682 while (PeekMessageA( &msg
, hchild
, 0, 0, PM_REMOVE
)) DispatchMessageA( &msg
);
7683 ok_sequence( WmEmptySeq
, "No WM_PAINT", FALSE
);
7684 while (PeekMessageA( &msg
, hparent
, 0, 0, PM_REMOVE
)) DispatchMessageA( &msg
);
7685 ok_sequence( WmParentErasePaint
, "WmParentErasePaint", FALSE
);
7688 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
7689 /* no WM_PAINT in child while parent still pending */
7690 while (PeekMessageA( &msg
, hchild
, 0, 0, PM_REMOVE
)) DispatchMessageA( &msg
);
7691 ok_sequence( WmEmptySeq
, "No WM_PAINT", FALSE
);
7692 RedrawWindow( hparent
, &rect
, 0, RDW_VALIDATE
| RDW_NOERASE
| RDW_NOCHILDREN
);
7693 /* now that parent is valid child should get WM_PAINT */
7694 while (PeekMessageA( &msg
, hchild
, 0, 0, PM_REMOVE
)) DispatchMessageA( &msg
);
7695 ok_sequence( WmInvalidateErasePaint2
, "WmInvalidateErasePaint2", FALSE
);
7696 while (PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA( &msg
);
7697 ok_sequence( WmEmptySeq
, "No other message", FALSE
);
7699 /* same thing with WS_CLIPCHILDREN in parent */
7701 SetWindowLongA( hparent
, GWL_STYLE
, GetWindowLongA(hparent
,GWL_STYLE
) | WS_CLIPCHILDREN
);
7702 ok_sequence( WmSetParentStyle
, "WmSetParentStyle", FALSE
);
7703 /* changing style invalidates non client area, but we need to invalidate something else to see it */
7704 RedrawWindow( hparent
, &rect
, 0, RDW_UPDATENOW
);
7705 ok_sequence( WmEmptySeq
, "No message", FALSE
);
7706 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_UPDATENOW
);
7707 ok_sequence( WmParentOnlyNcPaint
, "WmParentOnlyNcPaint", FALSE
);
7710 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_ALLCHILDREN
);
7711 SetRectRgn( hrgn
, 20, 20, 30, 30 );
7712 check_update_rgn( hparent
, hrgn
);
7713 /* no WM_PAINT in child while parent still pending */
7714 while (PeekMessageA( &msg
, hchild
, 0, 0, PM_REMOVE
)) DispatchMessageA( &msg
);
7715 ok_sequence( WmEmptySeq
, "No WM_PAINT", FALSE
);
7716 /* WM_PAINT in parent first */
7717 while (PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA( &msg
);
7718 ok_sequence( WmParentPaintNc
, "WmParentPaintNc2", FALSE
);
7720 /* no RDW_ERASE in parent still causes RDW_ERASE and RDW_FRAME in child */
7722 SetRect( &rect
, 0, 0, 30, 30 );
7723 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ALLCHILDREN
);
7724 SetRectRgn( hrgn
, 0, 0, 30, 30 );
7725 check_update_rgn( hparent
, hrgn
);
7727 ok_sequence( WmParentPaintNc
, "WmParentPaintNc3", FALSE
);
7729 /* validate doesn't cause RDW_NOERASE or RDW_NOFRAME in child */
7731 SetRect( &rect
, -10, 0, 30, 30 );
7732 RedrawWindow( hchild
, &rect
, 0, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASE
);
7733 SetRect( &rect
, 0, 0, 20, 20 );
7734 RedrawWindow( hparent
, &rect
, 0, RDW_VALIDATE
| RDW_ALLCHILDREN
);
7735 RedrawWindow( hparent
, NULL
, 0, RDW_UPDATENOW
);
7736 ok_sequence( WmChildPaintNc
, "WmChildPaintNc", FALSE
);
7738 /* validate doesn't cause RDW_NOERASE or RDW_NOFRAME in child */
7740 SetRect( &rect
, -10, 0, 30, 30 );
7741 RedrawWindow( hchild
, &rect
, 0, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASE
);
7742 SetRect( &rect
, 0, 0, 100, 100 );
7743 RedrawWindow( hparent
, &rect
, 0, RDW_VALIDATE
| RDW_ALLCHILDREN
);
7744 RedrawWindow( hparent
, NULL
, 0, RDW_UPDATENOW
);
7745 ok_sequence( WmEmptySeq
, "WmChildPaintNc2", FALSE
);
7746 RedrawWindow( hparent
, NULL
, 0, RDW_ERASENOW
);
7747 ok_sequence( WmEmptySeq
, "WmChildPaintNc3", FALSE
);
7749 /* WS_CLIPCHILDREN doesn't exclude children from update region */
7751 RedrawWindow( hparent
, NULL
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_NOCHILDREN
);
7752 GetClientRect( hparent
, &rect
);
7753 SetRectRgn( hrgn
, rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
7754 check_update_rgn( hparent
, hrgn
);
7757 RedrawWindow( hparent
, NULL
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_ALLCHILDREN
);
7758 GetClientRect( hparent
, &rect
);
7759 SetRectRgn( hrgn
, rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
7760 check_update_rgn( hparent
, hrgn
);
7763 /* test RDW_INTERNALPAINT behavior */
7766 RedrawWindow( hparent
, NULL
, 0, RDW_INTERNALPAINT
| RDW_NOCHILDREN
);
7768 ok_sequence( WmParentOnlyPaint
, "WmParentOnlyPaint", FALSE
);
7770 RedrawWindow( hparent
, NULL
, 0, RDW_INTERNALPAINT
| RDW_ALLCHILDREN
);
7772 ok_sequence( WmParentPaint
, "WmParentPaint", FALSE
);
7774 RedrawWindow( hparent
, NULL
, 0, RDW_INTERNALPAINT
);
7776 ok_sequence( WmParentOnlyPaint
, "WmParentOnlyPaint", FALSE
);
7778 assert( GetWindowLongA(hparent
, GWL_STYLE
) & WS_CLIPCHILDREN
);
7779 UpdateWindow( hparent
);
7782 trace("testing SWP_FRAMECHANGED on parent with WS_CLIPCHILDREN\n");
7783 RedrawWindow( hchild
, NULL
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
7784 SetWindowPos( hparent
, 0, 0, 0, 0, 0, SWP_NOSIZE
| SWP_NOMOVE
|
7785 SWP_NOACTIVATE
| SWP_NOZORDER
| SWP_FRAMECHANGED
);
7787 ok_sequence(WmSWP_FrameChanged_clip
, "SetWindowPos:FrameChanged_clip", FALSE
);
7789 UpdateWindow( hparent
);
7792 trace("testing SWP_FRAMECHANGED|SWP_DEFERERASE on parent with WS_CLIPCHILDREN\n");
7793 RedrawWindow( hchild
, NULL
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
7794 SetWindowPos( hparent
, 0, 0, 0, 0, 0, SWP_NOSIZE
| SWP_NOMOVE
| SWP_DEFERERASE
|
7795 SWP_NOACTIVATE
| SWP_NOZORDER
| SWP_FRAMECHANGED
);
7797 ok_sequence(WmSWP_FrameChangedDeferErase
, "SetWindowPos:FrameChangedDeferErase", FALSE
);
7799 SetWindowLongA( hparent
, GWL_STYLE
, GetWindowLongA(hparent
,GWL_STYLE
) & ~WS_CLIPCHILDREN
);
7800 ok_sequence( WmSetParentStyle
, "WmSetParentStyle", FALSE
);
7801 RedrawWindow( hparent
, NULL
, 0, RDW_INTERNALPAINT
);
7803 ok_sequence( WmParentPaint
, "WmParentPaint", FALSE
);
7805 assert( !(GetWindowLongA(hparent
, GWL_STYLE
) & WS_CLIPCHILDREN
) );
7806 UpdateWindow( hparent
);
7809 trace("testing SWP_FRAMECHANGED on parent without WS_CLIPCHILDREN\n");
7810 RedrawWindow( hchild
, NULL
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
7811 SetWindowPos( hparent
, 0, 0, 0, 0, 0, SWP_NOSIZE
| SWP_NOMOVE
|
7812 SWP_NOACTIVATE
| SWP_NOZORDER
| SWP_FRAMECHANGED
);
7814 ok_sequence(WmSWP_FrameChanged_noclip
, "SetWindowPos:FrameChanged_noclip", FALSE
);
7816 UpdateWindow( hparent
);
7819 trace("testing SWP_FRAMECHANGED|SWP_DEFERERASE on parent without WS_CLIPCHILDREN\n");
7820 RedrawWindow( hchild
, NULL
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
7821 SetWindowPos( hparent
, 0, 0, 0, 0, 0, SWP_NOSIZE
| SWP_NOMOVE
| SWP_DEFERERASE
|
7822 SWP_NOACTIVATE
| SWP_NOZORDER
| SWP_FRAMECHANGED
);
7824 ok_sequence(WmSWP_FrameChangedDeferErase
, "SetWindowPos:FrameChangedDeferErase", FALSE
);
7826 ok(GetWindowLongA( hparent
, GWL_STYLE
) & WS_VISIBLE
, "parent should be visible\n");
7827 ok(GetWindowLongA( hchild
, GWL_STYLE
) & WS_VISIBLE
, "child should be visible\n");
7829 UpdateWindow( hparent
);
7832 trace("testing SetWindowPos(-10000, -10000) on child\n");
7833 SetWindowPos( hchild
, 0, -10000, -10000, 0, 0, SWP_NOSIZE
| SWP_NOACTIVATE
| SWP_NOZORDER
);
7834 check_update_rgn( hchild
, 0 );
7837 #if 0 /* this one doesn't pass under Wine yet */
7838 UpdateWindow( hparent
);
7841 trace("testing ShowWindow(SW_MINIMIZE) on child\n");
7842 ShowWindow( hchild
, SW_MINIMIZE
);
7843 check_update_rgn( hchild
, 0 );
7847 UpdateWindow( hparent
);
7850 trace("testing SetWindowPos(-10000, -10000) on parent\n");
7851 SetWindowPos( hparent
, 0, -10000, -10000, 0, 0, SWP_NOSIZE
| SWP_NOACTIVATE
| SWP_NOZORDER
);
7852 check_update_rgn( hparent
, 0 );
7855 log_all_parent_messages
--;
7856 DestroyWindow( hparent
);
7857 ok(!IsWindow(hchild
), "child must be destroyed with its parent\n");
7859 /* tests for moving windows off-screen (needs simple WS_POPUP windows) */
7861 hparent
= CreateWindowExA(0, "TestParentClass", "Test parent", WS_POPUP
| WS_VISIBLE
,
7862 100, 100, 200, 200, 0, 0, 0, NULL
);
7863 ok (hparent
!= 0, "Failed to create parent window\n");
7865 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
| WS_VISIBLE
,
7866 10, 10, 100, 100, hparent
, 0, 0, NULL
);
7867 ok (hchild
!= 0, "Failed to create child window\n");
7869 ShowWindow( hparent
, SW_SHOW
);
7870 UpdateWindow( hparent
);
7871 UpdateWindow( hchild
);
7875 /* moving child outside of parent boundaries changes update region */
7876 SetRect( &rect
, 0, 0, 40, 40 );
7877 RedrawWindow( hchild
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
);
7878 SetRectRgn( hrgn
, 0, 0, 40, 40 );
7879 check_update_rgn( hchild
, hrgn
);
7880 MoveWindow( hchild
, -10, 10, 100, 100, FALSE
);
7881 SetRectRgn( hrgn
, 10, 0, 40, 40 );
7882 check_update_rgn( hchild
, hrgn
);
7883 MoveWindow( hchild
, -10, -10, 100, 100, FALSE
);
7884 SetRectRgn( hrgn
, 10, 10, 40, 40 );
7885 check_update_rgn( hchild
, hrgn
);
7887 /* moving parent off-screen does too */
7888 SetRect( &rect
, 0, 0, 100, 100 );
7889 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_NOCHILDREN
);
7890 SetRectRgn( hrgn
, 0, 0, 100, 100 );
7891 check_update_rgn( hparent
, hrgn
);
7892 SetRectRgn( hrgn
, 10, 10, 40, 40 );
7893 check_update_rgn( hchild
, hrgn
);
7894 MoveWindow( hparent
, -20, -20, 200, 200, FALSE
);
7895 GetUpdateRect( hparent
, &rect2
, FALSE
);
7896 if (!EqualRect( &rect2
, &rect
)) /* Win 8 and later don't crop update to screen */
7901 SetRectRgn( hrgn
, rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
7902 check_update_rgn( hparent
, hrgn
);
7903 SetRectRgn( hrgn
, rect
.left
+ 10, rect
.top
+ 10, 40, 40 );
7904 check_update_rgn( hchild
, hrgn
);
7906 /* invalidated region is cropped by the parent rects */
7907 SetRect( &rect
, 0, 0, 50, 50 );
7908 RedrawWindow( hchild
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
);
7909 SetRectRgn( hrgn
, rect2
.left
+ 10, rect2
.top
+ 10, 50, 50 );
7910 check_update_rgn( hchild
, hrgn
);
7912 DestroyWindow( hparent
);
7913 ok(!IsWindow(hchild
), "child must be destroyed with its parent\n");
7916 DeleteObject( hrgn
);
7917 DeleteObject( hrgn2
);
7928 static DWORD WINAPI
thread_proc(void *param
)
7931 struct wnd_event
*wnd_event
= param
;
7933 wnd_event
->hwnd
= CreateWindowExA(0, "TestWindowClass", "window caption text", WS_OVERLAPPEDWINDOW
,
7934 100, 100, 200, 200, 0, 0, 0, NULL
);
7935 ok(wnd_event
->hwnd
!= 0, "Failed to create overlapped window\n");
7937 SetEvent(wnd_event
->start_event
);
7939 while (GetMessageA(&msg
, 0, 0, 0))
7941 TranslateMessage(&msg
);
7942 DispatchMessageA(&msg
);
7945 ok(IsWindow(wnd_event
->hwnd
), "window should still exist\n");
7950 static DWORD CALLBACK
create_grand_child_thread( void *param
)
7952 struct wnd_event
*wnd_event
= param
;
7956 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child",
7957 WS_CHILD
| WS_VISIBLE
, 0, 0, 10, 10, wnd_event
->hwnd
, 0, 0, NULL
);
7958 ok (hchild
!= 0, "Failed to create child window\n");
7961 SetEvent( wnd_event
->start_event
);
7965 MsgWaitForMultipleObjects(0, NULL
, FALSE
, 1000, QS_ALLINPUT
);
7966 if (!IsWindow( hchild
)) break; /* will be destroyed when parent thread exits */
7967 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
7972 static DWORD CALLBACK
create_child_thread( void *param
)
7974 struct wnd_event
*wnd_event
= param
;
7975 struct wnd_event child_event
;
7979 child_event
.hwnd
= CreateWindowExA(0, "TestWindowClass", "Test child",
7980 WS_CHILD
| WS_VISIBLE
, 0, 0, 10, 10, wnd_event
->hwnd
, 0, 0, NULL
);
7981 ok (child_event
.hwnd
!= 0, "Failed to create child window\n");
7982 SetFocus( child_event
.hwnd
);
7985 child_event
.start_event
= wnd_event
->start_event
;
7986 wnd_event
->grand_child
= CreateThread(NULL
, 0, create_grand_child_thread
, &child_event
, 0, &tid
);
7989 DWORD ret
= MsgWaitForMultipleObjects(1, &child_event
.start_event
, FALSE
, 1000, QS_SENDMESSAGE
);
7990 if (ret
!= 1) break;
7991 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
7993 ret
= WaitForSingleObject( wnd_event
->stop_event
, 5000 );
7994 ok( !ret
, "WaitForSingleObject failed %x\n", ret
);
7998 static const char manifest_dep
[] =
7999 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
8000 "<assemblyIdentity version=\"1.2.3.4\" name=\"testdep1\" type=\"win32\" processorArchitecture=\"" ARCH
"\"/>"
8001 " <file name=\"testdep.dll\" />"
8004 static const char manifest_main
[] =
8005 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
8006 "<assemblyIdentity version=\"1.2.3.4\" name=\"Wine.Test\" type=\"win32\" />"
8008 " <dependentAssembly>"
8009 " <assemblyIdentity type=\"win32\" name=\"testdep1\" version=\"1.2.3.4\" processorArchitecture=\"" ARCH
"\" />"
8010 " </dependentAssembly>"
8014 static void create_manifest_file(const char *filename
, const char *manifest
)
8016 WCHAR path
[MAX_PATH
];
8020 MultiByteToWideChar( CP_ACP
, 0, filename
, -1, path
, MAX_PATH
);
8021 file
= CreateFileW(path
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
, FILE_ATTRIBUTE_NORMAL
, NULL
);
8022 ok(file
!= INVALID_HANDLE_VALUE
, "CreateFile failed: %u\n", GetLastError());
8023 WriteFile(file
, manifest
, strlen(manifest
), &size
, NULL
);
8027 static HANDLE
test_create(const char *file
)
8029 WCHAR path
[MAX_PATH
];
8033 MultiByteToWideChar(CP_ACP
, 0, file
, -1, path
, MAX_PATH
);
8034 memset(&actctx
, 0, sizeof(ACTCTXW
));
8035 actctx
.cbSize
= sizeof(ACTCTXW
);
8036 actctx
.lpSource
= path
;
8038 handle
= pCreateActCtxW(&actctx
);
8039 ok(handle
!= INVALID_HANDLE_VALUE
, "failed to create context, error %u\n", GetLastError());
8041 ok(actctx
.cbSize
== sizeof(actctx
), "cbSize=%d\n", actctx
.cbSize
);
8042 ok(actctx
.dwFlags
== 0, "dwFlags=%d\n", actctx
.dwFlags
);
8043 ok(actctx
.lpSource
== path
, "lpSource=%p\n", actctx
.lpSource
);
8044 ok(actctx
.wProcessorArchitecture
== 0, "wProcessorArchitecture=%d\n", actctx
.wProcessorArchitecture
);
8045 ok(actctx
.wLangId
== 0, "wLangId=%d\n", actctx
.wLangId
);
8046 ok(actctx
.lpAssemblyDirectory
== NULL
, "lpAssemblyDirectory=%p\n", actctx
.lpAssemblyDirectory
);
8047 ok(actctx
.lpResourceName
== NULL
, "lpResourceName=%p\n", actctx
.lpResourceName
);
8048 ok(actctx
.lpApplicationName
== NULL
, "lpApplicationName=%p\n", actctx
.lpApplicationName
);
8049 ok(actctx
.hModule
== NULL
, "hModule=%p\n", actctx
.hModule
);
8054 static void test_interthread_messages(void)
8056 HANDLE hThread
, context
, handle
, event
;
8062 int len
, expected_len
;
8063 struct wnd_event wnd_event
;
8066 wnd_event
.start_event
= CreateEventW(NULL
, 0, 0, NULL
);
8067 if (!wnd_event
.start_event
)
8069 win_skip("skipping interthread message test under win9x\n");
8073 hThread
= CreateThread(NULL
, 0, thread_proc
, &wnd_event
, 0, &tid
);
8074 ok(hThread
!= NULL
, "CreateThread failed, error %d\n", GetLastError());
8076 ok(WaitForSingleObject(wnd_event
.start_event
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
8078 CloseHandle(wnd_event
.start_event
);
8080 SetLastError(0xdeadbeef);
8081 ok(!DestroyWindow(wnd_event
.hwnd
), "DestroyWindow succeeded\n");
8082 ok(GetLastError() == ERROR_ACCESS_DENIED
|| GetLastError() == 0xdeadbeef,
8083 "wrong error code %d\n", GetLastError());
8085 proc
= (WNDPROC
)GetWindowLongPtrA(wnd_event
.hwnd
, GWLP_WNDPROC
);
8086 ok(proc
!= NULL
, "GetWindowLongPtrA(GWLP_WNDPROC) error %d\n", GetLastError());
8088 expected_len
= lstrlenA("window caption text");
8089 memset(buf
, 0, sizeof(buf
));
8090 SetLastError(0xdeadbeef);
8091 len
= CallWindowProcA(proc
, wnd_event
.hwnd
, WM_GETTEXT
, sizeof(buf
), (LPARAM
)buf
);
8092 ok(len
== expected_len
, "CallWindowProcA(WM_GETTEXT) error %d, len %d, expected len %d\n", GetLastError(), len
, expected_len
);
8093 ok(!lstrcmpA(buf
, "window caption text"), "window text mismatch\n");
8095 msg
.hwnd
= wnd_event
.hwnd
;
8096 msg
.message
= WM_GETTEXT
;
8097 msg
.wParam
= sizeof(buf
);
8098 msg
.lParam
= (LPARAM
)buf
;
8099 memset(buf
, 0, sizeof(buf
));
8100 SetLastError(0xdeadbeef);
8101 len
= DispatchMessageA(&msg
);
8102 ok((!len
&& GetLastError() == ERROR_MESSAGE_SYNC_ONLY
) || broken(len
), /* nt4 */
8103 "DispatchMessageA(WM_GETTEXT) succeeded on another thread window: ret %d, error %d\n", len
, GetLastError());
8105 /* the following test causes an exception in user.exe under win9x */
8106 msg
.hwnd
= wnd_event
.hwnd
;
8107 msg
.message
= WM_TIMER
;
8109 msg
.lParam
= GetWindowLongPtrA(wnd_event
.hwnd
, GWLP_WNDPROC
);
8110 SetLastError(0xdeadbeef);
8111 len
= DispatchMessageA(&msg
);
8112 ok(!len
&& GetLastError() == 0xdeadbeef,
8113 "DispatchMessageA(WM_TIMER) failed on another thread window: ret %d, error %d\n", len
, GetLastError());
8115 ret
= PostMessageA(wnd_event
.hwnd
, WM_QUIT
, 0, 0);
8116 ok( ret
, "PostMessageA(WM_QUIT) error %d\n", GetLastError());
8118 ok(WaitForSingleObject(hThread
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
8119 CloseHandle(hThread
);
8121 ok(!IsWindow(wnd_event
.hwnd
), "window should be destroyed on thread exit\n");
8123 wnd_event
.hwnd
= CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
8124 100, 100, 200, 200, 0, 0, 0, NULL
);
8125 ok (wnd_event
.hwnd
!= 0, "Failed to create parent window\n");
8128 log_all_parent_messages
++;
8129 wnd_event
.start_event
= CreateEventA( NULL
, TRUE
, FALSE
, NULL
);
8130 wnd_event
.stop_event
= CreateEventA( NULL
, TRUE
, FALSE
, NULL
);
8131 hThread
= CreateThread( NULL
, 0, create_child_thread
, &wnd_event
, 0, &tid
);
8134 ret
= MsgWaitForMultipleObjects(1, &wnd_event
.start_event
, FALSE
, 1000, QS_SENDMESSAGE
);
8135 if (ret
!= 1) break;
8136 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
8138 ok( !ret
, "MsgWaitForMultipleObjects failed %x\n", ret
);
8139 /* now wait for the thread without processing messages; this shouldn't deadlock */
8140 SetEvent( wnd_event
.stop_event
);
8141 ret
= WaitForSingleObject( hThread
, 5000 );
8142 ok( !ret
, "WaitForSingleObject failed %x\n", ret
);
8143 CloseHandle( hThread
);
8145 ret
= WaitForSingleObject( wnd_event
.grand_child
, 5000 );
8146 ok( !ret
, "WaitForSingleObject failed %x\n", ret
);
8147 CloseHandle( wnd_event
.grand_child
);
8149 CloseHandle( wnd_event
.start_event
);
8150 CloseHandle( wnd_event
.stop_event
);
8152 ok_sequence(WmExitThreadSeq
, "destroy child on thread exit", FALSE
);
8153 log_all_parent_messages
--;
8154 DestroyWindow( wnd_event
.hwnd
);
8156 /* activation context tests */
8157 if (!pActivateActCtx
)
8159 win_skip("Activation contexts are not supported, skipping\n");
8163 create_manifest_file("testdep1.manifest", manifest_dep
);
8164 create_manifest_file("main.manifest", manifest_main
);
8166 context
= test_create("main.manifest");
8167 DeleteFileA("testdep1.manifest");
8168 DeleteFileA("main.manifest");
8170 handle
= (void*)0xdeadbeef;
8171 ret
= pGetCurrentActCtx(&handle
);
8172 ok(ret
, "GetCurrentActCtx failed: %u\n", GetLastError());
8173 ok(handle
== 0, "active context %p\n", handle
);
8175 wnd_event
.start_event
= CreateEventW(NULL
, 0, 0, NULL
);
8176 hThread
= CreateThread(NULL
, 0, thread_proc
, &wnd_event
, 0, &tid
);
8177 ok(hThread
!= NULL
, "CreateThread failed, error %d\n", GetLastError());
8178 ok(WaitForSingleObject(wnd_event
.start_event
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
8179 CloseHandle(wnd_event
.start_event
);
8181 /* context is activated after thread creation, so it doesn't inherit it by default */
8182 ret
= pActivateActCtx(context
, &cookie
);
8183 ok(ret
, "activation failed: %u\n", GetLastError());
8186 ret
= pGetCurrentActCtx(&handle
);
8187 ok(ret
, "GetCurrentActCtx failed: %u\n", GetLastError());
8188 ok(handle
!= 0, "active context %p\n", handle
);
8189 pReleaseActCtx(handle
);
8191 /* destination window will test for active context */
8192 ret
= SendMessageA(wnd_event
.hwnd
, WM_USER
+10, 0, 0);
8193 ok(ret
, "thread window returned %d\n", ret
);
8195 event
= CreateEventW(NULL
, 0, 0, NULL
);
8196 ret
= PostMessageA(wnd_event
.hwnd
, WM_USER
+10, 0, (LPARAM
)event
);
8197 ok(ret
, "thread window returned %d\n", ret
);
8198 ok(WaitForSingleObject(event
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
8201 ret
= PostMessageA(wnd_event
.hwnd
, WM_QUIT
, 0, 0);
8202 ok(ret
, "PostMessageA(WM_QUIT) error %d\n", GetLastError());
8204 ok(WaitForSingleObject(hThread
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
8205 CloseHandle(hThread
);
8207 ret
= pDeactivateActCtx(0, cookie
);
8208 ok(ret
, "DeactivateActCtx failed: %u\n", GetLastError());
8209 pReleaseActCtx(context
);
8213 static const struct message WmVkN
[] = {
8214 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 1 }, /* XP */
8215 { WM_KEYDOWN
, wparam
|lparam
, 'N', 1 },
8216 { WM_KEYDOWN
, sent
|wparam
|lparam
, 'N', 1 },
8217 { WM_CHAR
, wparam
|lparam
, 'n', 1 },
8218 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1002,1), 0 },
8219 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xc0000001 }, /* XP */
8220 { WM_KEYUP
, wparam
|lparam
, 'N', 0xc0000001 },
8221 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xc0000001 },
8224 static const struct message WmShiftVkN
[] = {
8225 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 1 }, /* XP */
8226 { WM_KEYDOWN
, wparam
|lparam
, VK_SHIFT
, 1 },
8227 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_SHIFT
, 1 },
8228 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 1 }, /* XP */
8229 { WM_KEYDOWN
, wparam
|lparam
, 'N', 1 },
8230 { WM_KEYDOWN
, sent
|wparam
|lparam
, 'N', 1 },
8231 { WM_CHAR
, wparam
|lparam
, 'N', 1 },
8232 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1001,1), 0 },
8233 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xc0000001 }, /* XP */
8234 { WM_KEYUP
, wparam
|lparam
, 'N', 0xc0000001 },
8235 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xc0000001 },
8236 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 0xc0000001 }, /* XP */
8237 { WM_KEYUP
, wparam
|lparam
, VK_SHIFT
, 0xc0000001 },
8238 { WM_KEYUP
, sent
|wparam
|lparam
, VK_SHIFT
, 0xc0000001 },
8241 static const struct message WmCtrlVkN
[] = {
8242 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 1 }, /* XP */
8243 { WM_KEYDOWN
, wparam
|lparam
, VK_CONTROL
, 1 },
8244 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_CONTROL
, 1 },
8245 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 1 }, /* XP */
8246 { WM_KEYDOWN
, wparam
|lparam
, 'N', 1 },
8247 { WM_KEYDOWN
, sent
|wparam
|lparam
, 'N', 1 },
8248 { WM_CHAR
, wparam
|lparam
, 0x000e, 1 },
8249 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1000,1), 0 },
8250 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xc0000001 }, /* XP */
8251 { WM_KEYUP
, wparam
|lparam
, 'N', 0xc0000001 },
8252 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xc0000001 },
8253 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 0xc0000001 }, /* XP */
8254 { WM_KEYUP
, wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
8255 { WM_KEYUP
, sent
|wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
8258 static const struct message WmCtrlVkN_2
[] = {
8259 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 1 }, /* XP */
8260 { WM_KEYDOWN
, wparam
|lparam
, VK_CONTROL
, 1 },
8261 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_CONTROL
, 1 },
8262 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 1 }, /* XP */
8263 { WM_KEYDOWN
, wparam
|lparam
, 'N', 1 },
8264 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1000,1), 0 },
8265 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xc0000001 }, /* XP */
8266 { WM_KEYUP
, wparam
|lparam
, 'N', 0xc0000001 },
8267 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xc0000001 },
8268 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 0xc0000001 }, /* XP */
8269 { WM_KEYUP
, wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
8270 { WM_KEYUP
, sent
|wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
8273 static const struct message WmAltVkN
[] = {
8274 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 }, /* XP */
8275 { WM_SYSKEYDOWN
, wparam
|lparam
, VK_MENU
, 0x20000001 },
8276 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
8277 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0x20000001 }, /* XP */
8278 { WM_SYSKEYDOWN
, wparam
|lparam
, 'N', 0x20000001 },
8279 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, 'N', 0x20000001 },
8280 { WM_SYSCHAR
, wparam
|lparam
, 'n', 0x20000001 },
8281 { WM_SYSCHAR
, sent
|wparam
|lparam
, 'n', 0x20000001 },
8282 { WM_SYSCOMMAND
, sent
|defwinproc
|wparam
|lparam
, SC_KEYMENU
, 'n' },
8283 { HCBT_SYSCOMMAND
, hook
},
8284 { WM_ENTERMENULOOP
, sent
|defwinproc
|wparam
|lparam
, 0, 0 },
8285 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
8286 { 0x00AE, sent
|defwinproc
|optional
}, /* XP */
8287 { WM_GETTEXT
, sent
|defwinproc
|optional
}, /* XP */
8288 { WM_INITMENU
, sent
|defwinproc
},
8289 { EVENT_SYSTEM_MENUSTART
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 0 },
8290 { WM_MENUCHAR
, sent
|defwinproc
|wparam
, MAKEWPARAM('n',MF_SYSMENU
) },
8291 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, 0, 0 },
8292 { WM_CAPTURECHANGED
, sent
|defwinproc
},
8293 { WM_MENUSELECT
, sent
|defwinproc
|wparam
, MAKEWPARAM(0,0xffff) },
8294 { EVENT_SYSTEM_MENUEND
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 0 },
8295 { WM_EXITMENULOOP
, sent
|defwinproc
},
8296 { WM_MENUSELECT
, sent
|defwinproc
|wparam
|optional
, MAKEWPARAM(0,0xffff) }, /* Win95 bug */
8297 { WM_EXITMENULOOP
, sent
|defwinproc
|optional
}, /* Win95 bug */
8298 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xe0000001 }, /* XP */
8299 { WM_SYSKEYUP
, wparam
|lparam
, 'N', 0xe0000001 },
8300 { WM_SYSKEYUP
, sent
|wparam
|lparam
, 'N', 0xe0000001 },
8301 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xc0000001 }, /* XP */
8302 { WM_KEYUP
, wparam
|lparam
, VK_MENU
, 0xc0000001 },
8303 { WM_KEYUP
, sent
|wparam
|lparam
, VK_MENU
, 0xc0000001 },
8306 static const struct message WmAltVkN_2
[] = {
8307 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 }, /* XP */
8308 { WM_SYSKEYDOWN
, wparam
|lparam
, VK_MENU
, 0x20000001 },
8309 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
8310 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0x20000001 }, /* XP */
8311 { WM_SYSKEYDOWN
, wparam
|lparam
, 'N', 0x20000001 },
8312 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1003,1), 0 },
8313 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xe0000001 }, /* XP */
8314 { WM_SYSKEYUP
, wparam
|lparam
, 'N', 0xe0000001 },
8315 { WM_SYSKEYUP
, sent
|wparam
|lparam
, 'N', 0xe0000001 },
8316 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xc0000001 }, /* XP */
8317 { WM_KEYUP
, wparam
|lparam
, VK_MENU
, 0xc0000001 },
8318 { WM_KEYUP
, sent
|wparam
|lparam
, VK_MENU
, 0xc0000001 },
8321 static const struct message WmCtrlAltVkN
[] = {
8322 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 1 }, /* XP */
8323 { WM_KEYDOWN
, wparam
|lparam
, VK_CONTROL
, 1 },
8324 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_CONTROL
, 1 },
8325 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 }, /* XP */
8326 { WM_KEYDOWN
, wparam
|lparam
, VK_MENU
, 0x20000001 },
8327 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
8328 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0x20000001 }, /* XP */
8329 { WM_KEYDOWN
, wparam
|lparam
, 'N', 0x20000001 },
8330 { WM_KEYDOWN
, sent
|wparam
|lparam
, 'N', 0x20000001 },
8331 { WM_CHAR
, optional
},
8332 { WM_CHAR
, sent
|optional
},
8333 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xe0000001 }, /* XP */
8334 { WM_KEYUP
, wparam
|lparam
, 'N', 0xe0000001 },
8335 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xe0000001 },
8336 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xc0000001 }, /* XP */
8337 { WM_KEYUP
, wparam
|lparam
, VK_MENU
, 0xc0000001 },
8338 { WM_KEYUP
, sent
|wparam
|lparam
, VK_MENU
, 0xc0000001 },
8339 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 0xc0000001 }, /* XP */
8340 { WM_KEYUP
, wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
8341 { WM_KEYUP
, sent
|wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
8344 static const struct message WmCtrlShiftVkN
[] = {
8345 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 1 }, /* XP */
8346 { WM_KEYDOWN
, wparam
|lparam
, VK_CONTROL
, 1 },
8347 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_CONTROL
, 1 },
8348 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 1 }, /* XP */
8349 { WM_KEYDOWN
, wparam
|lparam
, VK_SHIFT
, 1 },
8350 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_SHIFT
, 1 },
8351 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 1 }, /* XP */
8352 { WM_KEYDOWN
, wparam
|lparam
, 'N', 1 },
8353 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1004,1), 0 },
8354 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xc0000001 }, /* XP */
8355 { WM_KEYUP
, wparam
|lparam
, 'N', 0xc0000001 },
8356 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xc0000001 },
8357 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 0xc0000001 }, /* XP */
8358 { WM_KEYUP
, wparam
|lparam
, VK_SHIFT
, 0xc0000001 },
8359 { WM_KEYUP
, sent
|wparam
|lparam
, VK_SHIFT
, 0xc0000001 },
8360 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 0xc0000001 }, /* XP */
8361 { WM_KEYUP
, wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
8362 { WM_KEYUP
, sent
|wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
8365 static const struct message WmCtrlAltShiftVkN
[] = {
8366 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 1 }, /* XP */
8367 { WM_KEYDOWN
, wparam
|lparam
, VK_CONTROL
, 1 },
8368 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_CONTROL
, 1 },
8369 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 }, /* XP */
8370 { WM_KEYDOWN
, wparam
|lparam
, VK_MENU
, 0x20000001 },
8371 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
8372 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 0x20000001 }, /* XP */
8373 { WM_KEYDOWN
, wparam
|lparam
, VK_SHIFT
, 0x20000001 },
8374 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_SHIFT
, 0x20000001 },
8375 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0x20000001 }, /* XP */
8376 { WM_KEYDOWN
, wparam
|lparam
, 'N', 0x20000001 },
8377 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1005,1), 0 },
8378 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xe0000001 }, /* XP */
8379 { WM_KEYUP
, wparam
|lparam
, 'N', 0xe0000001 },
8380 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xe0000001 },
8381 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 0xe0000001 }, /* XP */
8382 { WM_KEYUP
, wparam
|lparam
, VK_SHIFT
, 0xe0000001 },
8383 { WM_KEYUP
, sent
|wparam
|lparam
, VK_SHIFT
, 0xe0000001 },
8384 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xc0000001 }, /* XP */
8385 { WM_KEYUP
, wparam
|lparam
, VK_MENU
, 0xc0000001 },
8386 { WM_KEYUP
, sent
|wparam
|lparam
, VK_MENU
, 0xc0000001 },
8387 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 0xc0000001 }, /* XP */
8388 { WM_KEYUP
, wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
8389 { WM_KEYUP
, sent
|wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
8392 static const struct message WmAltPressRelease
[] = {
8393 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 }, /* XP */
8394 { WM_SYSKEYDOWN
, wparam
|lparam
, VK_MENU
, 0x20000001 },
8395 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
8396 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xc0000001 }, /* XP */
8397 { WM_SYSKEYUP
, wparam
|lparam
, VK_MENU
, 0xc0000001 },
8398 { WM_SYSKEYUP
, sent
|wparam
|lparam
, VK_MENU
, 0xc0000001 },
8399 { WM_SYSCOMMAND
, sent
|defwinproc
|wparam
|lparam
, SC_KEYMENU
, 0 },
8400 { HCBT_SYSCOMMAND
, hook
},
8401 { WM_ENTERMENULOOP
, sent
|defwinproc
|wparam
|lparam
, 0, 0 },
8402 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
8403 { WM_INITMENU
, sent
|defwinproc
},
8404 { EVENT_SYSTEM_MENUSTART
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 0 },
8405 { WM_MENUSELECT
, sent
|defwinproc
|wparam
, MAKEWPARAM(0,MF_SYSMENU
|MF_POPUP
|MF_HILITE
), 0, MAKEWPARAM(0,MF_RIGHTJUSTIFY
) },
8406 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 1 },
8408 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x30000001 }, /* XP */
8410 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 0 },
8411 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, 0, 0, },
8412 { WM_CAPTURECHANGED
, sent
|defwinproc
},
8413 { WM_MENUSELECT
, sent
|defwinproc
|wparam
|optional
, MAKEWPARAM(0,0xffff) },
8414 { EVENT_SYSTEM_MENUEND
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 0 },
8415 { WM_EXITMENULOOP
, sent
|defwinproc
},
8416 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xc0000001 }, /* XP */
8417 { WM_SYSKEYUP
, wparam
|lparam
, VK_MENU
, 0xc0000001 },
8418 { WM_SYSKEYUP
, sent
|wparam
|lparam
, VK_MENU
, 0xc0000001 },
8421 static const struct message WmShiftMouseButton
[] = {
8422 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 1 }, /* XP */
8423 { WM_KEYDOWN
, wparam
|lparam
, VK_SHIFT
, 1 },
8424 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_SHIFT
, 1 },
8425 { WM_MOUSEMOVE
, wparam
|optional
, 0, 0 },
8426 { WM_MOUSEMOVE
, sent
|wparam
|optional
, 0, 0 },
8427 { WM_LBUTTONDOWN
, wparam
, MK_LBUTTON
|MK_SHIFT
, 0 },
8428 { WM_LBUTTONDOWN
, sent
|wparam
, MK_LBUTTON
|MK_SHIFT
, 0 },
8429 { WM_LBUTTONUP
, wparam
, MK_SHIFT
, 0 },
8430 { WM_LBUTTONUP
, sent
|wparam
, MK_SHIFT
, 0 },
8431 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 0xc0000001 }, /* XP */
8432 { WM_KEYUP
, wparam
|lparam
, VK_SHIFT
, 0xc0000001 },
8433 { WM_KEYUP
, sent
|wparam
|lparam
, VK_SHIFT
, 0xc0000001 },
8436 static const struct message WmF1Seq
[] = {
8437 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_F1
, 1 }, /* XP */
8438 { WM_KEYDOWN
, wparam
|lparam
, VK_F1
, 1 },
8439 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_F1
, 0x00000001 },
8440 { WM_KEYF1
, wparam
|lparam
, 0, 0 },
8441 { WM_KEYF1
, sent
|wparam
|lparam
, 0, 0 },
8442 { WM_HELP
, sent
|defwinproc
},
8443 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_F1
, 0xc0000001 }, /* XP */
8444 { WM_KEYUP
, wparam
|lparam
, VK_F1
, 0xc0000001 },
8445 { WM_KEYUP
, sent
|wparam
|lparam
, VK_F1
, 0xc0000001 },
8448 static const struct message WmVkAppsSeq
[] = {
8449 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_APPS
, 1 }, /* XP */
8450 { WM_KEYDOWN
, wparam
|lparam
, VK_APPS
, 1 },
8451 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_APPS
, 0x00000001 },
8452 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_APPS
, 0xc0000001 }, /* XP */
8453 { WM_KEYUP
, wparam
|lparam
, VK_APPS
, 0xc0000001 },
8454 { WM_KEYUP
, sent
|wparam
|lparam
, VK_APPS
, 0xc0000001 },
8455 { WM_CONTEXTMENU
, lparam
, /*hwnd*/0, -1 },
8456 { WM_CONTEXTMENU
, sent
|lparam
, /*hwnd*/0, -1 },
8459 static const struct message WmVkF10Seq
[] = {
8460 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_F10
, 1 }, /* XP */
8461 { WM_SYSKEYDOWN
, wparam
|lparam
, VK_F10
, 1 },
8462 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, VK_F10
, 0x00000001 },
8463 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_F10
, 0xc0000001 }, /* XP */
8464 { WM_SYSKEYUP
, wparam
|lparam
, VK_F10
, 0xc0000001 },
8465 { WM_SYSKEYUP
, sent
|wparam
|lparam
, VK_F10
, 0xc0000001 },
8466 { WM_SYSCOMMAND
, sent
|defwinproc
|wparam
, SC_KEYMENU
},
8467 { HCBT_SYSCOMMAND
, hook
},
8468 { WM_ENTERMENULOOP
, sent
|defwinproc
|wparam
|lparam
, 0, 0 },
8469 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
8470 { WM_INITMENU
, sent
|defwinproc
},
8471 { EVENT_SYSTEM_MENUSTART
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 0 },
8472 { WM_MENUSELECT
, sent
|defwinproc
|wparam
, MAKEWPARAM(0,MF_SYSMENU
|MF_POPUP
|MF_HILITE
), 0, MAKEWPARAM(0,MF_RIGHTJUSTIFY
) },
8473 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 1 },
8475 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_F10
, 0x10000001 }, /* XP */
8477 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_F10
, 1 }, /* XP */
8478 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 0 },
8479 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, 0, 0, },
8480 { WM_CAPTURECHANGED
, sent
|defwinproc
},
8481 { WM_MENUSELECT
, sent
|defwinproc
|wparam
|optional
, MAKEWPARAM(0,0xffff) },
8482 { EVENT_SYSTEM_MENUEND
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 0 },
8483 { WM_EXITMENULOOP
, sent
|defwinproc
},
8484 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_F10
, 0xc0000001 }, /* XP */
8485 { WM_SYSKEYUP
, wparam
|lparam
, VK_F10
, 0xc0000001 },
8486 { WM_SYSKEYUP
, sent
|wparam
|lparam
, VK_F10
, 0xc0000001 },
8489 static const struct message WmShiftF10Seq
[] = {
8490 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 1 }, /* XP */
8491 { WM_KEYDOWN
, wparam
|lparam
, VK_SHIFT
, 1 },
8492 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_SHIFT
, 0x00000001 },
8493 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_F10
, 1 }, /* XP */
8494 { WM_SYSKEYDOWN
, wparam
|lparam
, VK_F10
, 1 },
8495 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, VK_F10
, 0x00000001 },
8496 { WM_CONTEXTMENU
, sent
|defwinproc
|lparam
, /*hwnd*/0, -1 },
8497 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_F10
, 0xc0000001 }, /* XP */
8498 { WM_SYSKEYUP
, wparam
|lparam
, VK_F10
, 0xc0000001 },
8499 { WM_SYSKEYUP
, sent
|wparam
|lparam
, VK_F10
, 0xc0000001 },
8500 { WM_SYSCOMMAND
, sent
|defwinproc
|wparam
, SC_KEYMENU
},
8501 { HCBT_SYSCOMMAND
, hook
},
8502 { WM_ENTERMENULOOP
, sent
|defwinproc
|wparam
|lparam
, 0, 0 },
8503 { WM_INITMENU
, sent
|defwinproc
},
8504 { WM_MENUSELECT
, sent
|defwinproc
|wparam
, MAKEWPARAM(0,MF_SYSMENU
|MF_POPUP
|MF_HILITE
), 0, MAKEWPARAM(0,MF_RIGHTJUSTIFY
) },
8505 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 0xd0000001 }, /* XP */
8506 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_ESCAPE
, 0x10000001 }, /* XP */
8507 { WM_CAPTURECHANGED
, sent
|defwinproc
|wparam
|lparam
, 0, 0 },
8508 { WM_MENUSELECT
, sent
|defwinproc
|wparam
|lparam
, 0xffff0000, 0 },
8509 { WM_EXITMENULOOP
, sent
|defwinproc
|wparam
|lparam
, 0, 0 },
8510 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_ESCAPE
, 0xc0000001 }, /* XP */
8511 { WM_KEYUP
, wparam
|lparam
, VK_ESCAPE
, 0xc0000001 },
8512 { WM_KEYUP
, sent
|wparam
|lparam
, VK_ESCAPE
, 0xc0000001 },
8516 static void pump_msg_loop(HWND hwnd
, HACCEL hAccel
)
8520 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
))
8522 struct recvd_message log_msg
;
8524 /* ignore some unwanted messages */
8525 if (msg
.message
== WM_MOUSEMOVE
||
8526 msg
.message
== WM_TIMER
||
8527 ignore_message( msg
.message
))
8530 log_msg
.hwnd
= msg
.hwnd
;
8531 log_msg
.message
= msg
.message
;
8532 log_msg
.flags
= wparam
|lparam
;
8533 log_msg
.wParam
= msg
.wParam
;
8534 log_msg
.lParam
= msg
.lParam
;
8535 log_msg
.descr
= "accel";
8536 add_message(&log_msg
);
8538 if (!hAccel
|| !TranslateAcceleratorA(hwnd
, hAccel
, &msg
))
8540 TranslateMessage(&msg
);
8541 DispatchMessageA(&msg
);
8546 static void test_accelerators(void)
8552 HWND hwnd
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
8553 100, 100, 200, 200, 0, 0, 0, NULL
);
8562 ok(GetFocus() == hwnd
, "wrong focus window %p\n", GetFocus());
8564 state
= GetKeyState(VK_SHIFT
);
8565 ok(!(state
& 0x8000), "wrong Shift state %04x\n", state
);
8566 state
= GetKeyState(VK_CAPITAL
);
8567 ok(state
== 0, "wrong CapsLock state %04x\n", state
);
8569 hAccel
= LoadAcceleratorsA(GetModuleHandleA(NULL
), MAKEINTRESOURCEA(1));
8570 assert(hAccel
!= 0);
8573 pump_msg_loop(hwnd
, 0);
8576 trace("testing VK_N press/release\n");
8578 keybd_event('N', 0, 0, 0);
8579 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
8580 pump_msg_loop(hwnd
, hAccel
);
8581 if (!sequence_cnt
) /* we didn't get any message */
8583 skip( "queuing key events not supported\n" );
8586 ok_sequence(WmVkN
, "VK_N press/release", FALSE
);
8588 trace("testing Shift+VK_N press/release\n");
8590 keybd_event(VK_SHIFT
, 0, 0, 0);
8591 keybd_event('N', 0, 0, 0);
8592 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
8593 keybd_event(VK_SHIFT
, 0, KEYEVENTF_KEYUP
, 0);
8594 pump_msg_loop(hwnd
, hAccel
);
8595 ok_sequence(WmShiftVkN
, "Shift+VK_N press/release", FALSE
);
8597 trace("testing Ctrl+VK_N press/release\n");
8599 keybd_event(VK_CONTROL
, 0, 0, 0);
8600 keybd_event('N', 0, 0, 0);
8601 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
8602 keybd_event(VK_CONTROL
, 0, KEYEVENTF_KEYUP
, 0);
8603 pump_msg_loop(hwnd
, hAccel
);
8604 ok_sequence(WmCtrlVkN
, "Ctrl+VK_N press/release", FALSE
);
8606 trace("testing Alt+VK_N press/release\n");
8608 keybd_event(VK_MENU
, 0, 0, 0);
8609 keybd_event('N', 0, 0, 0);
8610 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
8611 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
8612 pump_msg_loop(hwnd
, hAccel
);
8613 ok_sequence(WmAltVkN
, "Alt+VK_N press/release", FALSE
);
8615 trace("testing Ctrl+Alt+VK_N press/release 1\n");
8617 keybd_event(VK_CONTROL
, 0, 0, 0);
8618 keybd_event(VK_MENU
, 0, 0, 0);
8619 keybd_event('N', 0, 0, 0);
8620 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
8621 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
8622 keybd_event(VK_CONTROL
, 0, KEYEVENTF_KEYUP
, 0);
8623 pump_msg_loop(hwnd
, hAccel
);
8624 ok_sequence(WmCtrlAltVkN
, "Ctrl+Alt+VK_N press/release 1", FALSE
);
8626 ret
= DestroyAcceleratorTable(hAccel
);
8627 ok( ret
, "DestroyAcceleratorTable error %d\n", GetLastError());
8629 hAccel
= LoadAcceleratorsA(GetModuleHandleA(NULL
), MAKEINTRESOURCEA(2));
8630 assert(hAccel
!= 0);
8632 trace("testing VK_N press/release\n");
8634 keybd_event('N', 0, 0, 0);
8635 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
8636 pump_msg_loop(hwnd
, hAccel
);
8637 ok_sequence(WmVkN
, "VK_N press/release", FALSE
);
8639 trace("testing Shift+VK_N press/release\n");
8641 keybd_event(VK_SHIFT
, 0, 0, 0);
8642 keybd_event('N', 0, 0, 0);
8643 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
8644 keybd_event(VK_SHIFT
, 0, KEYEVENTF_KEYUP
, 0);
8645 pump_msg_loop(hwnd
, hAccel
);
8646 ok_sequence(WmShiftVkN
, "Shift+VK_N press/release", FALSE
);
8648 trace("testing Ctrl+VK_N press/release 2\n");
8650 keybd_event(VK_CONTROL
, 0, 0, 0);
8651 keybd_event('N', 0, 0, 0);
8652 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
8653 keybd_event(VK_CONTROL
, 0, KEYEVENTF_KEYUP
, 0);
8654 pump_msg_loop(hwnd
, hAccel
);
8655 ok_sequence(WmCtrlVkN_2
, "Ctrl+VK_N press/release 2", FALSE
);
8657 trace("testing Alt+VK_N press/release 2\n");
8659 keybd_event(VK_MENU
, 0, 0, 0);
8660 keybd_event('N', 0, 0, 0);
8661 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
8662 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
8663 pump_msg_loop(hwnd
, hAccel
);
8664 ok_sequence(WmAltVkN_2
, "Alt+VK_N press/release 2", FALSE
);
8666 trace("testing Ctrl+Alt+VK_N press/release 2\n");
8668 keybd_event(VK_CONTROL
, 0, 0, 0);
8669 keybd_event(VK_MENU
, 0, 0, 0);
8670 keybd_event('N', 0, 0, 0);
8671 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
8672 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
8673 keybd_event(VK_CONTROL
, 0, KEYEVENTF_KEYUP
, 0);
8674 pump_msg_loop(hwnd
, hAccel
);
8675 ok_sequence(WmCtrlAltVkN
, "Ctrl+Alt+VK_N press/release 2", FALSE
);
8677 trace("testing Ctrl+Shift+VK_N press/release\n");
8679 keybd_event(VK_CONTROL
, 0, 0, 0);
8680 keybd_event(VK_SHIFT
, 0, 0, 0);
8681 keybd_event('N', 0, 0, 0);
8682 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
8683 keybd_event(VK_SHIFT
, 0, KEYEVENTF_KEYUP
, 0);
8684 keybd_event(VK_CONTROL
, 0, KEYEVENTF_KEYUP
, 0);
8685 pump_msg_loop(hwnd
, hAccel
);
8686 ok_sequence(WmCtrlShiftVkN
, "Ctrl+Shift+VK_N press/release", FALSE
);
8688 trace("testing Ctrl+Alt+Shift+VK_N press/release\n");
8690 keybd_event(VK_CONTROL
, 0, 0, 0);
8691 keybd_event(VK_MENU
, 0, 0, 0);
8692 keybd_event(VK_SHIFT
, 0, 0, 0);
8693 keybd_event('N', 0, 0, 0);
8694 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
8695 keybd_event(VK_SHIFT
, 0, KEYEVENTF_KEYUP
, 0);
8696 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
8697 keybd_event(VK_CONTROL
, 0, KEYEVENTF_KEYUP
, 0);
8698 pump_msg_loop(hwnd
, hAccel
);
8699 ok_sequence(WmCtrlAltShiftVkN
, "Ctrl+Alt+Shift+VK_N press/release", FALSE
);
8701 ret
= DestroyAcceleratorTable(hAccel
);
8702 ok( ret
, "DestroyAcceleratorTable error %d\n", GetLastError());
8705 trace("testing Alt press/release\n");
8707 keybd_event(VK_MENU
, 0, 0, 0);
8708 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
8709 keybd_event(VK_MENU
, 0, 0, 0);
8710 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
8711 pump_msg_loop(hwnd
, 0);
8712 /* this test doesn't pass in Wine for managed windows */
8713 ok_sequence(WmAltPressRelease
, "Alt press/release", TRUE
);
8715 trace("testing VK_F1 press/release\n");
8716 keybd_event(VK_F1
, 0, 0, 0);
8717 keybd_event(VK_F1
, 0, KEYEVENTF_KEYUP
, 0);
8718 pump_msg_loop(hwnd
, 0);
8719 ok_sequence(WmF1Seq
, "F1 press/release", FALSE
);
8721 trace("testing VK_APPS press/release\n");
8722 keybd_event(VK_APPS
, 0, 0, 0);
8723 keybd_event(VK_APPS
, 0, KEYEVENTF_KEYUP
, 0);
8724 pump_msg_loop(hwnd
, 0);
8725 ok_sequence(WmVkAppsSeq
, "VK_APPS press/release", FALSE
);
8727 trace("testing VK_F10 press/release\n");
8728 keybd_event(VK_F10
, 0, 0, 0);
8729 keybd_event(VK_F10
, 0, KEYEVENTF_KEYUP
, 0);
8730 keybd_event(VK_F10
, 0, 0, 0);
8731 keybd_event(VK_F10
, 0, KEYEVENTF_KEYUP
, 0);
8732 pump_msg_loop(hwnd
, 0);
8733 ok_sequence(WmVkF10Seq
, "VK_F10 press/release", TRUE
);
8735 trace("testing SHIFT+F10 press/release\n");
8736 keybd_event(VK_SHIFT
, 0, 0, 0);
8737 keybd_event(VK_F10
, 0, 0, 0);
8738 keybd_event(VK_F10
, 0, KEYEVENTF_KEYUP
, 0);
8739 keybd_event(VK_SHIFT
, 0, KEYEVENTF_KEYUP
, 0);
8740 keybd_event(VK_ESCAPE
, 0, 0, 0);
8741 keybd_event(VK_ESCAPE
, 0, KEYEVENTF_KEYUP
, 0);
8742 pump_msg_loop(hwnd
, 0);
8743 ok_sequence(WmShiftF10Seq
, "SHIFT+F10 press/release", TRUE
);
8745 trace("testing Shift+MouseButton press/release\n");
8746 /* first, move mouse pointer inside of the window client area */
8747 GetClientRect(hwnd
, &rc
);
8748 MapWindowPoints(hwnd
, 0, (LPPOINT
)&rc
, 2);
8749 rc
.left
+= (rc
.right
- rc
.left
)/2;
8750 rc
.top
+= (rc
.bottom
- rc
.top
)/2;
8751 SetCursorPos(rc
.left
, rc
.top
);
8752 SetActiveWindow(hwnd
);
8757 if (pt
.x
== rc
.left
&& pt
.y
== rc
.top
)
8760 keybd_event(VK_SHIFT
, 0, 0, 0);
8761 mouse_event(MOUSEEVENTF_LEFTDOWN
, 0, 0, 0, 0);
8762 mouse_event(MOUSEEVENTF_LEFTUP
, 0, 0, 0, 0);
8763 keybd_event(VK_SHIFT
, 0, KEYEVENTF_KEYUP
, 0);
8764 pump_msg_loop(hwnd
, 0);
8765 for (i
= 0; i
< sequence_cnt
; i
++) if (sequence
[i
].message
== WM_LBUTTONDOWN
) break;
8766 if (i
< sequence_cnt
)
8767 ok_sequence(WmShiftMouseButton
, "Shift+MouseButton press/release", FALSE
);
8769 skip( "Shift+MouseButton event didn't get to the window\n" );
8773 if (hAccel
) DestroyAcceleratorTable(hAccel
);
8774 DestroyWindow(hwnd
);
8777 /************* window procedures ********************/
8779 static LRESULT
MsgCheckProc (BOOL unicode
, HWND hwnd
, UINT message
,
8780 WPARAM wParam
, LPARAM lParam
)
8782 static LONG defwndproc_counter
= 0;
8783 static LONG beginpaint_counter
= 0;
8785 struct recvd_message msg
;
8787 if (ignore_message( message
)) return 0;
8793 LONG style
= GetWindowLongA(hwnd
, GWL_STYLE
);
8794 ok((BOOL
)wParam
== !(style
& WS_DISABLED
),
8795 "wrong WS_DISABLED state: %ld != %d\n", wParam
, !(style
& WS_DISABLED
));
8799 case WM_CAPTURECHANGED
:
8800 if (test_DestroyWindow_flag
)
8802 DWORD style
= GetWindowLongA(hwnd
, GWL_STYLE
);
8803 if (style
& WS_CHILD
)
8804 lParam
= GetWindowLongPtrA(hwnd
, GWLP_ID
);
8805 else if (style
& WS_POPUP
)
8806 lParam
= WND_POPUP_ID
;
8808 lParam
= WND_PARENT_ID
;
8816 ok(!GetWindow(hwnd
, GW_CHILD
), "children should be unlinked at this point\n");
8817 capture
= GetCapture();
8820 ok(capture
== hwnd
, "capture should NOT be released at this point (capture %p)\n", capture
);
8821 trace("current capture %p, releasing...\n", capture
);
8828 ok(pGetAncestor(hwnd
, GA_PARENT
) != 0, "parent should NOT be unlinked at this point\n");
8829 if (test_DestroyWindow_flag
)
8831 DWORD style
= GetWindowLongA(hwnd
, GWL_STYLE
);
8832 if (style
& WS_CHILD
)
8833 lParam
= GetWindowLongPtrA(hwnd
, GWLP_ID
);
8834 else if (style
& WS_POPUP
)
8835 lParam
= WND_POPUP_ID
;
8837 lParam
= WND_PARENT_ID
;
8841 /* test_accelerators() depends on this */
8847 ACTIVATION_CONTEXT_BASIC_INFORMATION basicinfo
;
8848 HANDLE handle
, event
= (HANDLE
)lParam
;
8851 handle
= (void*)0xdeadbeef;
8852 ret
= pGetCurrentActCtx(&handle
);
8853 ok(ret
, "failed to get current context, %u\n", GetLastError());
8854 ok(handle
== 0, "got active context %p\n", handle
);
8856 memset(&basicinfo
, 0xff, sizeof(basicinfo
));
8857 ret
= pQueryActCtxW(QUERY_ACTCTX_FLAG_USE_ACTIVE_ACTCTX
, handle
, 0, ActivationContextBasicInformation
,
8858 &basicinfo
, sizeof(basicinfo
), NULL
);
8859 ok(ret
, "got %d, error %d\n", ret
, GetLastError());
8860 ok(basicinfo
.hActCtx
== NULL
, "got %p\n", basicinfo
.hActCtx
);
8861 ok(basicinfo
.dwFlags
== 0, "got %x\n", basicinfo
.dwFlags
);
8863 if (event
) SetEvent(event
);
8869 case WM_MOUSEACTIVATE
:
8870 case WM_NCMOUSEMOVE
:
8877 msg
.message
= message
;
8878 msg
.flags
= sent
|wparam
|lparam
;
8879 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
8880 if (beginpaint_counter
) msg
.flags
|= beginpaint
;
8881 msg
.wParam
= wParam
;
8882 msg
.lParam
= lParam
;
8883 msg
.descr
= "MsgCheckProc";
8886 if (message
== WM_GETMINMAXINFO
&& (GetWindowLongA(hwnd
, GWL_STYLE
) & WS_CHILD
))
8888 HWND parent
= GetParent(hwnd
);
8890 MINMAXINFO
*minmax
= (MINMAXINFO
*)lParam
;
8892 GetClientRect(parent
, &rc
);
8893 trace("parent %p client size = (%d x %d)\n", parent
, rc
.right
, rc
.bottom
);
8894 trace("Reserved=%d,%d MaxSize=%d,%d MaxPos=%d,%d MinTrack=%d,%d MaxTrack=%d,%d\n",
8895 minmax
->ptReserved
.x
, minmax
->ptReserved
.y
,
8896 minmax
->ptMaxSize
.x
, minmax
->ptMaxSize
.y
,
8897 minmax
->ptMaxPosition
.x
, minmax
->ptMaxPosition
.y
,
8898 minmax
->ptMinTrackSize
.x
, minmax
->ptMinTrackSize
.y
,
8899 minmax
->ptMaxTrackSize
.x
, minmax
->ptMaxTrackSize
.y
);
8901 ok(minmax
->ptMaxSize
.x
== rc
.right
, "default width of maximized child %d != %d\n",
8902 minmax
->ptMaxSize
.x
, rc
.right
);
8903 ok(minmax
->ptMaxSize
.y
== rc
.bottom
, "default height of maximized child %d != %d\n",
8904 minmax
->ptMaxSize
.y
, rc
.bottom
);
8907 if (message
== WM_PAINT
)
8910 beginpaint_counter
++;
8911 BeginPaint( hwnd
, &ps
);
8912 beginpaint_counter
--;
8913 EndPaint( hwnd
, &ps
);
8917 if (message
== WM_CONTEXTMENU
)
8919 /* don't create context menu */
8923 defwndproc_counter
++;
8924 ret
= unicode
? DefWindowProcW(hwnd
, message
, wParam
, lParam
)
8925 : DefWindowProcA(hwnd
, message
, wParam
, lParam
);
8926 defwndproc_counter
--;
8931 static LRESULT WINAPI
MsgCheckProcA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
8933 return MsgCheckProc (FALSE
, hwnd
, message
, wParam
, lParam
);
8936 static LRESULT WINAPI
MsgCheckProcW(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
8938 return MsgCheckProc (TRUE
, hwnd
, message
, wParam
, lParam
);
8941 static LRESULT WINAPI
PopupMsgCheckProcA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
8943 static LONG defwndproc_counter
= 0;
8945 struct recvd_message msg
;
8947 if (ignore_message( message
)) return 0;
8951 case WM_QUERYENDSESSION
:
8953 lParam
&= ~0x01; /* Vista adds a 0x01 flag */
8958 msg
.message
= message
;
8959 msg
.flags
= sent
|wparam
|lparam
;
8960 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
8961 msg
.wParam
= wParam
;
8962 msg
.lParam
= lParam
;
8963 msg
.descr
= "popup";
8966 if (message
== WM_CREATE
)
8968 DWORD style
= GetWindowLongA(hwnd
, GWL_STYLE
) | WS_VISIBLE
;
8969 SetWindowLongA(hwnd
, GWL_STYLE
, style
);
8972 defwndproc_counter
++;
8973 ret
= DefWindowProcA(hwnd
, message
, wParam
, lParam
);
8974 defwndproc_counter
--;
8979 static LRESULT WINAPI
ParentMsgCheckProcA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
8981 static LONG defwndproc_counter
= 0;
8982 static LONG beginpaint_counter
= 0;
8984 struct recvd_message msg
;
8986 if (ignore_message( message
)) return 0;
8988 if (log_all_parent_messages
||
8989 message
== WM_PARENTNOTIFY
|| message
== WM_CANCELMODE
||
8990 message
== WM_SETFOCUS
|| message
== WM_KILLFOCUS
||
8991 message
== WM_ENABLE
|| message
== WM_ENTERIDLE
||
8992 message
== WM_DRAWITEM
|| message
== WM_COMMAND
||
8993 message
== WM_IME_SETCONTEXT
)
9002 case WM_NCMOUSEMOVE
:
9008 INT ret
= GetClipBox((HDC
)wParam
, &rc
);
9010 trace("WM_ERASEBKGND: GetClipBox()=%d, %s\n", ret
, wine_dbgstr_rect(&rc
));
9016 msg
.message
= message
;
9017 msg
.flags
= sent
|parent
|wparam
|lparam
;
9018 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
9019 if (beginpaint_counter
) msg
.flags
|= beginpaint
;
9020 msg
.wParam
= wParam
;
9021 msg
.lParam
= lParam
;
9022 msg
.descr
= "parent";
9026 if (message
== WM_PAINT
)
9029 beginpaint_counter
++;
9030 BeginPaint( hwnd
, &ps
);
9031 beginpaint_counter
--;
9032 EndPaint( hwnd
, &ps
);
9036 defwndproc_counter
++;
9037 ret
= DefWindowProcA(hwnd
, message
, wParam
, lParam
);
9038 defwndproc_counter
--;
9043 static INT_PTR CALLBACK
StopQuitMsgCheckProcA(HWND hwnd
, UINT message
, WPARAM wp
, LPARAM lp
)
9045 if (message
== WM_CREATE
)
9046 PostMessageA(hwnd
, WM_CLOSE
, 0, 0);
9047 else if (message
== WM_CLOSE
)
9049 /* Only the first WM_QUIT will survive the window destruction */
9050 PostMessageA(hwnd
, WM_USER
, 0x1234, 0x5678);
9051 PostMessageA(hwnd
, WM_QUIT
, 0x1234, 0x5678);
9052 PostMessageA(hwnd
, WM_QUIT
, 0x4321, 0x8765);
9055 return DefWindowProcA(hwnd
, message
, wp
, lp
);
9058 static LRESULT WINAPI
TestDlgProcA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
9060 static LONG defwndproc_counter
= 0;
9062 struct recvd_message msg
;
9064 if (ignore_message( message
)) return 0;
9068 DefDlgProcA(hwnd
, DM_SETDEFID
, 1, 0);
9069 ret
= DefDlgProcA(hwnd
, DM_GETDEFID
, 0, 0);
9070 if (after_end_dialog
)
9071 ok( ret
== 0, "DM_GETDEFID should return 0 after EndDialog, got %lx\n", ret
);
9073 ok(HIWORD(ret
) == DC_HASDEFID
, "DM_GETDEFID should return DC_HASDEFID, got %lx\n", ret
);
9077 msg
.message
= message
;
9078 msg
.flags
= sent
|wparam
|lparam
;
9079 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
9080 msg
.wParam
= wParam
;
9081 msg
.lParam
= lParam
;
9082 msg
.descr
= "dialog";
9085 defwndproc_counter
++;
9086 ret
= DefDlgProcA(hwnd
, message
, wParam
, lParam
);
9087 defwndproc_counter
--;
9092 static LRESULT WINAPI
ShowWindowProcA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
9094 static LONG defwndproc_counter
= 0;
9096 struct recvd_message msg
;
9098 /* log only specific messages we are interested in */
9101 #if 0 /* probably log these as well */
9109 case WM_GETMINMAXINFO
:
9110 case WM_WINDOWPOSCHANGING
:
9111 case WM_WINDOWPOSCHANGED
:
9114 default: /* ignore */
9115 /*trace("showwindow: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);*/
9116 return DefWindowProcA(hwnd
, message
, wParam
, lParam
);
9120 msg
.message
= message
;
9121 msg
.flags
= sent
|wparam
|lparam
;
9122 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
9123 msg
.wParam
= wParam
;
9124 msg
.lParam
= lParam
;
9128 defwndproc_counter
++;
9129 ret
= DefWindowProcA(hwnd
, message
, wParam
, lParam
);
9130 defwndproc_counter
--;
9135 static LRESULT WINAPI
PaintLoopProcA(HWND hWnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
9139 case WM_CREATE
: return 0;
9148 if (PeekMessageA(&msg2
, 0, 0, 0, 1))
9150 TranslateMessage(&msg2
);
9151 DispatchMessageA(&msg2
);
9155 else ok(broken(1), "infinite loop\n");
9157 paint_loop_done
= TRUE
;
9158 return DefWindowProcA(hWnd
,msg
,wParam
,lParam
);
9161 return DefWindowProcA(hWnd
,msg
,wParam
,lParam
);
9164 static LRESULT WINAPI
HotkeyMsgCheckProcA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
9166 static LONG defwndproc_counter
= 0;
9168 struct recvd_message msg
;
9171 if (ignore_message( message
)) return 0;
9173 if ((message
>= WM_KEYFIRST
&& message
<= WM_KEYLAST
) ||
9174 message
== WM_HOTKEY
|| message
>= WM_APP
)
9177 msg
.message
= message
;
9178 msg
.flags
= sent
|wparam
|lparam
;
9179 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
9180 msg
.wParam
= wParam
;
9181 msg
.lParam
= lParam
;
9182 msg
.descr
= "HotkeyMsgCheckProcA";
9186 defwndproc_counter
++;
9187 ret
= DefWindowProcA(hwnd
, message
, wParam
, lParam
);
9188 defwndproc_counter
--;
9190 if (message
== WM_APP
)
9192 queue_status
= GetQueueStatus(QS_HOTKEY
);
9193 ok((queue_status
& (QS_HOTKEY
<< 16)) == QS_HOTKEY
<< 16, "expected QS_HOTKEY << 16 set, got %x\n", queue_status
);
9194 queue_status
= GetQueueStatus(QS_POSTMESSAGE
);
9195 ok((queue_status
& (QS_POSTMESSAGE
<< 16)) == QS_POSTMESSAGE
<< 16, "expected QS_POSTMESSAGE << 16 set, got %x\n", queue_status
);
9196 PostMessageA(hwnd
, WM_APP
+1, 0, 0);
9198 else if (message
== WM_APP
+1)
9200 queue_status
= GetQueueStatus(QS_HOTKEY
);
9201 ok((queue_status
& (QS_HOTKEY
<< 16)) == 0, "expected QS_HOTKEY << 16 cleared, got %x\n", queue_status
);
9207 static BOOL
RegisterWindowClasses(void)
9213 cls
.lpfnWndProc
= MsgCheckProcA
;
9216 cls
.hInstance
= GetModuleHandleA(0);
9218 cls
.hCursor
= LoadCursorA(0, (LPCSTR
)IDC_ARROW
);
9219 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
9220 cls
.lpszMenuName
= NULL
;
9221 cls
.lpszClassName
= "TestWindowClass";
9222 if(!RegisterClassA(&cls
)) return FALSE
;
9224 cls
.lpfnWndProc
= HotkeyMsgCheckProcA
;
9225 cls
.lpszClassName
= "HotkeyWindowClass";
9226 if(!RegisterClassA(&cls
)) return FALSE
;
9228 cls
.lpfnWndProc
= ShowWindowProcA
;
9229 cls
.lpszClassName
= "ShowWindowClass";
9230 if(!RegisterClassA(&cls
)) return FALSE
;
9232 cls
.lpfnWndProc
= PopupMsgCheckProcA
;
9233 cls
.lpszClassName
= "TestPopupClass";
9234 if(!RegisterClassA(&cls
)) return FALSE
;
9236 cls
.lpfnWndProc
= ParentMsgCheckProcA
;
9237 cls
.lpszClassName
= "TestParentClass";
9238 if(!RegisterClassA(&cls
)) return FALSE
;
9240 cls
.lpfnWndProc
= StopQuitMsgCheckProcA
;
9241 cls
.lpszClassName
= "StopQuitClass";
9242 if(!RegisterClassA(&cls
)) return FALSE
;
9244 cls
.lpfnWndProc
= DefWindowProcA
;
9245 cls
.lpszClassName
= "SimpleWindowClass";
9246 if(!RegisterClassA(&cls
)) return FALSE
;
9248 cls
.lpfnWndProc
= PaintLoopProcA
;
9249 cls
.lpszClassName
= "PaintLoopWindowClass";
9250 if(!RegisterClassA(&cls
)) return FALSE
;
9252 cls
.style
= CS_NOCLOSE
;
9253 cls
.lpszClassName
= "NoCloseWindowClass";
9254 if(!RegisterClassA(&cls
)) return FALSE
;
9256 ok(GetClassInfoA(0, "#32770", &cls
), "GetClassInfo failed\n");
9258 cls
.hInstance
= GetModuleHandleA(0);
9259 cls
.hbrBackground
= 0;
9260 cls
.lpfnWndProc
= TestDlgProcA
;
9261 cls
.lpszClassName
= "TestDialogClass";
9262 if(!RegisterClassA(&cls
)) return FALSE
;
9265 clsW
.lpfnWndProc
= MsgCheckProcW
;
9266 clsW
.cbClsExtra
= 0;
9267 clsW
.cbWndExtra
= 0;
9268 clsW
.hInstance
= GetModuleHandleW(0);
9270 clsW
.hCursor
= LoadCursorW(0, (LPWSTR
)IDC_ARROW
);
9271 clsW
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
9272 clsW
.lpszMenuName
= NULL
;
9273 clsW
.lpszClassName
= testWindowClassW
;
9274 RegisterClassW(&clsW
); /* ignore error, this fails on Win9x */
9279 static BOOL
is_our_logged_class(HWND hwnd
)
9283 if (GetClassNameA(hwnd
, buf
, sizeof(buf
)))
9285 if (!lstrcmpiA(buf
, "TestWindowClass") ||
9286 !lstrcmpiA(buf
, "ShowWindowClass") ||
9287 !lstrcmpiA(buf
, "TestParentClass") ||
9288 !lstrcmpiA(buf
, "TestPopupClass") ||
9289 !lstrcmpiA(buf
, "SimpleWindowClass") ||
9290 !lstrcmpiA(buf
, "TestDialogClass") ||
9291 !lstrcmpiA(buf
, "MDI_frame_class") ||
9292 !lstrcmpiA(buf
, "MDI_client_class") ||
9293 !lstrcmpiA(buf
, "MDI_child_class") ||
9294 !lstrcmpiA(buf
, "my_button_class") ||
9295 !lstrcmpiA(buf
, "my_edit_class") ||
9296 !lstrcmpiA(buf
, "static") ||
9297 !lstrcmpiA(buf
, "ListBox") ||
9298 !lstrcmpiA(buf
, "ComboBox") ||
9299 !lstrcmpiA(buf
, "MyDialogClass") ||
9300 !lstrcmpiA(buf
, "#32770") ||
9301 !lstrcmpiA(buf
, "#32768"))
9307 static LRESULT CALLBACK
cbt_hook_proc(int nCode
, WPARAM wParam
, LPARAM lParam
)
9311 ok(cbt_hook_thread_id
== GetCurrentThreadId(), "we didn't ask for events from other threads\n");
9313 if (nCode
== HCBT_CLICKSKIPPED
)
9315 /* ignore this event, XP sends it a lot when switching focus between windows */
9316 return CallNextHookEx(hCBT_hook
, nCode
, wParam
, lParam
);
9319 if (nCode
== HCBT_SYSCOMMAND
|| nCode
== HCBT_KEYSKIPPED
)
9321 struct recvd_message msg
;
9324 msg
.message
= nCode
;
9325 msg
.flags
= hook
|wparam
|lparam
;
9326 msg
.wParam
= wParam
;
9327 msg
.lParam
= lParam
;
9331 return CallNextHookEx(hCBT_hook
, nCode
, wParam
, lParam
);
9334 if (nCode
== HCBT_DESTROYWND
)
9336 if (test_DestroyWindow_flag
)
9338 DWORD style
= GetWindowLongA((HWND
)wParam
, GWL_STYLE
);
9339 if (style
& WS_CHILD
)
9340 lParam
= GetWindowLongPtrA((HWND
)wParam
, GWLP_ID
);
9341 else if (style
& WS_POPUP
)
9342 lParam
= WND_POPUP_ID
;
9344 lParam
= WND_PARENT_ID
;
9348 /* Log also SetFocus(0) calls */
9349 hwnd
= wParam
? (HWND
)wParam
: (HWND
)lParam
;
9351 if (is_our_logged_class(hwnd
))
9353 struct recvd_message msg
;
9356 msg
.message
= nCode
;
9357 msg
.flags
= hook
|wparam
|lparam
;
9358 msg
.wParam
= wParam
;
9359 msg
.lParam
= lParam
;
9363 return CallNextHookEx(hCBT_hook
, nCode
, wParam
, lParam
);
9366 static void CALLBACK
win_event_proc(HWINEVENTHOOK hevent
,
9374 ok(thread_id
== GetCurrentThreadId(), "we didn't ask for events from other threads\n");
9376 /* ignore mouse cursor events */
9377 if (object_id
== OBJID_CURSOR
) return;
9379 if (!hwnd
|| is_our_logged_class(hwnd
))
9381 struct recvd_message msg
;
9384 msg
.message
= event
;
9385 msg
.flags
= winevent_hook
|wparam
|lparam
;
9386 msg
.wParam
= object_id
;
9387 msg
.lParam
= child_id
;
9393 static const WCHAR wszUnicode
[] = {'U','n','i','c','o','d','e',0};
9394 static const WCHAR wszAnsi
[] = {'U',0};
9396 static LRESULT CALLBACK
MsgConversionProcW(HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
9400 case CB_FINDSTRINGEXACT
:
9401 trace("String: %p\n", (LPCWSTR
)lParam
);
9402 if (!lstrcmpW((LPCWSTR
)lParam
, wszUnicode
))
9404 if (!lstrcmpW((LPCWSTR
)lParam
, wszAnsi
))
9408 return DefWindowProcW(hwnd
, uMsg
, wParam
, lParam
);
9411 static const struct message WmGetTextLengthAfromW
[] = {
9412 { WM_GETTEXTLENGTH
, sent
},
9413 { WM_GETTEXT
, sent
|optional
},
9417 static const WCHAR dummy_window_text
[] = {'d','u','m','m','y',' ','t','e','x','t',0};
9419 /* dummy window proc for WM_GETTEXTLENGTH test */
9420 static LRESULT CALLBACK
get_text_len_proc( HWND hwnd
, UINT msg
, WPARAM wp
, LPARAM lp
)
9424 case WM_GETTEXTLENGTH
:
9425 return lstrlenW(dummy_window_text
) + 37; /* some random length */
9427 lstrcpynW( (LPWSTR
)lp
, dummy_window_text
, wp
);
9428 return lstrlenW( (LPWSTR
)lp
);
9430 return DefWindowProcW( hwnd
, msg
, wp
, lp
);
9434 static void test_message_conversion(void)
9436 static const WCHAR wszMsgConversionClass
[] =
9437 {'M','s','g','C','o','n','v','e','r','s','i','o','n','C','l','a','s','s',0};
9441 WNDPROC wndproc
, newproc
;
9445 cls
.lpfnWndProc
= MsgConversionProcW
;
9448 cls
.hInstance
= GetModuleHandleW(NULL
);
9450 cls
.hCursor
= LoadCursorW(NULL
, (LPWSTR
)IDC_ARROW
);
9451 cls
.hbrBackground
= (HBRUSH
)(COLOR_BTNFACE
+1);
9452 cls
.lpszMenuName
= NULL
;
9453 cls
.lpszClassName
= wszMsgConversionClass
;
9454 /* this call will fail on Win9x, but that doesn't matter as this test is
9455 * meaningless on those platforms */
9456 if(!RegisterClassW(&cls
)) return;
9458 hwnd
= CreateWindowExW(0, wszMsgConversionClass
, NULL
, WS_OVERLAPPED
,
9459 100, 100, 200, 200, 0, 0, 0, NULL
);
9460 ok(hwnd
!= NULL
, "Window creation failed\n");
9464 wndproc
= (WNDPROC
)GetWindowLongPtrA(hwnd
, GWLP_WNDPROC
);
9465 lRes
= CallWindowProcA(wndproc
, hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
9466 ok(lRes
== 0, "String should have been converted\n");
9467 lRes
= CallWindowProcW(wndproc
, hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
9468 ok(lRes
== 1, "String shouldn't have been converted\n");
9472 wndproc
= (WNDPROC
)GetWindowLongPtrW(hwnd
, GWLP_WNDPROC
);
9473 lRes
= CallWindowProcA(wndproc
, hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
9474 ok(lRes
== 1, "String shouldn't have been converted\n");
9475 lRes
= CallWindowProcW(wndproc
, hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
9476 ok(lRes
== 1, "String shouldn't have been converted\n");
9478 /* Synchronous messages */
9480 lRes
= SendMessageA(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
9481 ok(lRes
== 0, "String should have been converted\n");
9482 lRes
= SendMessageW(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
9483 ok(lRes
== 1, "String shouldn't have been converted\n");
9485 /* Asynchronous messages */
9488 lRes
= PostMessageA(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
9489 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
9490 "PostMessage on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
9492 lRes
= PostMessageW(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
9493 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
9494 "PostMessage on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
9496 lRes
= PostThreadMessageA(GetCurrentThreadId(), CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
9497 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
9498 "PosThreadtMessage on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
9500 lRes
= PostThreadMessageW(GetCurrentThreadId(), CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
9501 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
9502 "PosThreadtMessage on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
9504 lRes
= SendNotifyMessageA(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
9505 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
9506 "SendNotifyMessage on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
9508 lRes
= SendNotifyMessageW(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
9509 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
9510 "SendNotifyMessage on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
9512 lRes
= SendMessageCallbackA(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
, NULL
, 0);
9513 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
9514 "SendMessageCallback on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
9516 lRes
= SendMessageCallbackW(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
, NULL
, 0);
9517 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
9518 "SendMessageCallback on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
9520 /* Check WM_GETTEXTLENGTH A->W behaviour, whether WM_GETTEXT is also sent or not */
9522 hwnd
= CreateWindowW (testWindowClassW
, wszUnicode
,
9523 WS_OVERLAPPEDWINDOW
,
9524 100, 100, 200, 200, 0, 0, 0, NULL
);
9527 lRes
= SendMessageA (hwnd
, WM_GETTEXTLENGTH
, 0, 0);
9528 ok_sequence(WmGetTextLengthAfromW
, "ANSI WM_GETTEXTLENGTH to Unicode window", FALSE
);
9529 ok( lRes
== WideCharToMultiByte( CP_ACP
, 0, wszUnicode
, lstrlenW(wszUnicode
), NULL
, 0, NULL
, NULL
),
9530 "got bad length %ld\n", lRes
);
9533 lRes
= CallWindowProcA( (WNDPROC
)GetWindowLongPtrA( hwnd
, GWLP_WNDPROC
),
9534 hwnd
, WM_GETTEXTLENGTH
, 0, 0);
9535 ok_sequence(WmGetTextLengthAfromW
, "ANSI WM_GETTEXTLENGTH to Unicode window", FALSE
);
9536 ok( lRes
== WideCharToMultiByte( CP_ACP
, 0, wszUnicode
, lstrlenW(wszUnicode
), NULL
, 0, NULL
, NULL
),
9537 "got bad length %ld\n", lRes
);
9539 wndproc
= (WNDPROC
)SetWindowLongPtrW( hwnd
, GWLP_WNDPROC
, (LONG_PTR
)get_text_len_proc
);
9540 newproc
= (WNDPROC
)GetWindowLongPtrA( hwnd
, GWLP_WNDPROC
);
9541 lRes
= CallWindowProcA( newproc
, hwnd
, WM_GETTEXTLENGTH
, 0, 0 );
9542 ok( lRes
== WideCharToMultiByte( CP_ACP
, 0, dummy_window_text
, lstrlenW(dummy_window_text
),
9543 NULL
, 0, NULL
, NULL
) ||
9544 broken(lRes
== lstrlenW(dummy_window_text
) + 37),
9545 "got bad length %ld\n", lRes
);
9547 SetWindowLongPtrW( hwnd
, GWLP_WNDPROC
, (LONG_PTR
)wndproc
); /* restore old wnd proc */
9548 lRes
= CallWindowProcA( newproc
, hwnd
, WM_GETTEXTLENGTH
, 0, 0 );
9549 ok( lRes
== WideCharToMultiByte( CP_ACP
, 0, dummy_window_text
, lstrlenW(dummy_window_text
),
9550 NULL
, 0, NULL
, NULL
) ||
9551 broken(lRes
== lstrlenW(dummy_window_text
) + 37),
9552 "got bad length %ld\n", lRes
);
9554 ret
= DestroyWindow(hwnd
);
9555 ok( ret
, "DestroyWindow() error %d\n", GetLastError());
9565 static VOID CALLBACK
tfunc(HWND hwnd
, UINT uMsg
, UINT_PTR id
, DWORD dwTime
)
9569 #define TIMER_ID 0x19
9570 #define TIMER_COUNT_EXPECTED 100
9571 #define TIMER_COUNT_TOLERANCE 10
9573 static int count
= 0;
9574 static void CALLBACK
callback_count(HWND hwnd
, UINT uMsg
, UINT_PTR idEvent
, DWORD dwTime
)
9579 static DWORD exception
;
9580 static void CALLBACK
callback_exception(HWND hwnd
, UINT uMsg
, UINT_PTR idEvent
, DWORD dwTime
)
9583 RaiseException(exception
, 0, 0, NULL
);
9586 static DWORD WINAPI
timer_thread_proc(LPVOID x
)
9588 struct timer_info
*info
= x
;
9591 r
= KillTimer(info
->hWnd
, 0x19);
9592 ok(r
,"KillTimer failed in thread\n");
9593 r
= SetTimer(info
->hWnd
,TIMER_ID
,10000,tfunc
);
9594 ok(r
,"SetTimer failed in thread\n");
9595 ok(r
==TIMER_ID
,"SetTimer id different\n");
9596 r
= SetEvent(info
->handles
[0]);
9597 ok(r
,"SetEvent failed in thread\n");
9601 static void test_timers(void)
9603 struct timer_info info
;
9608 info
.hWnd
= CreateWindowA("TestWindowClass", NULL
,
9609 WS_OVERLAPPEDWINDOW
,
9610 CW_USEDEFAULT
, CW_USEDEFAULT
, 300, 300, 0,
9613 info
.id
= SetTimer(info
.hWnd
,TIMER_ID
,10000,tfunc
);
9614 ok(info
.id
, "SetTimer failed\n");
9615 ok(info
.id
==TIMER_ID
, "SetTimer timer ID different\n");
9616 info
.handles
[0] = CreateEventW(NULL
,0,0,NULL
);
9617 info
.handles
[1] = CreateThread(NULL
,0,timer_thread_proc
,&info
,0,&id
);
9619 WaitForMultipleObjects(2, info
.handles
, FALSE
, INFINITE
);
9621 WaitForSingleObject(info
.handles
[1], INFINITE
);
9623 CloseHandle(info
.handles
[0]);
9624 CloseHandle(info
.handles
[1]);
9626 ok( KillTimer(info
.hWnd
, TIMER_ID
), "KillTimer failed\n");
9628 /* Check the minimum allowed timeout for a timer. MSDN indicates that it should be 10.0 ms,
9629 * which occurs sometimes, but most testing on the VMs indicates a minimum timeout closer to
9630 * 15.6 ms. Since there is some measurement error between test runs we are allowing for
9631 * ±9 counts (~4 ms) around the expected value.
9634 id
= SetTimer(info
.hWnd
, TIMER_ID
, 0, callback_count
);
9635 ok(id
!= 0, "did not get id from SetTimer.\n");
9636 ok(id
==TIMER_ID
, "SetTimer timer ID different\n");
9637 start
= GetTickCount();
9638 while (GetTickCount()-start
< 1001 && GetMessageA(&msg
, info
.hWnd
, 0, 0))
9639 DispatchMessageA(&msg
);
9640 ok(abs(count
-TIMER_COUNT_EXPECTED
) < TIMER_COUNT_TOLERANCE
/* xp */
9641 || broken(abs(count
-64) < TIMER_COUNT_TOLERANCE
) /* most common */
9642 || broken(abs(count
-43) < TIMER_COUNT_TOLERANCE
) /* w2k3, win8 */,
9643 "did not get expected count for minimum timeout (%d != ~%d).\n",
9644 count
, TIMER_COUNT_EXPECTED
);
9645 ok(KillTimer(info
.hWnd
, id
), "KillTimer failed\n");
9646 /* Perform the same check on SetSystemTimer (only available on w2k3 and older) */
9647 if (pSetSystemTimer
)
9652 id
= pSetSystemTimer(info
.hWnd
, TIMER_ID
, 0, callback_count
);
9653 ok(id
!= 0, "did not get id from SetSystemTimer.\n");
9654 ok(id
==TIMER_ID
, "SetTimer timer ID different\n");
9655 start
= GetTickCount();
9656 while (GetTickCount()-start
< 1001 && GetMessageA(&msg
, info
.hWnd
, 0, 0))
9658 if (msg
.message
== WM_SYSTIMER
)
9660 DispatchMessageA(&msg
);
9662 ok(abs(syscount
-TIMER_COUNT_EXPECTED
) < TIMER_COUNT_TOLERANCE
9663 || broken(abs(syscount
-64) < TIMER_COUNT_TOLERANCE
) /* most common */
9664 || broken(syscount
> 4000 && syscount
< 12000) /* win2k3sp0 */,
9665 "did not get expected count for minimum timeout (%d != ~%d).\n",
9666 syscount
, TIMER_COUNT_EXPECTED
);
9667 todo_wine
ok(count
== 0, "did not get expected count for callback timeout (%d != 0).\n",
9669 ok(pKillSystemTimer(info
.hWnd
, id
), "KillSystemTimer failed\n");
9672 ok(DestroyWindow(info
.hWnd
), "failed to destroy window\n");
9675 static void test_timers_no_wnd(void)
9677 static UINT_PTR ids
[0xffff];
9684 id
= SetTimer(NULL
, 0, 100, callback_count
);
9685 ok(id
!= 0, "did not get id from SetTimer.\n");
9686 id2
= SetTimer(NULL
, id
, 200, callback_count
);
9687 ok(id2
== id
, "did not get same id from SetTimer when replacing (%li expected %li).\n", id2
, id
);
9689 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
9690 ok(count
== 0, "did not get zero count as expected (%i).\n", count
);
9692 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
9693 ok(count
== 1, "did not get one count as expected (%i).\n", count
);
9694 KillTimer(NULL
, id
);
9696 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
9697 ok(count
== 1, "killing replaced timer did not work (%i).\n", count
);
9699 /* Check the minimum allowed timeout for a timer. MSDN indicates that it should be 10.0 ms,
9700 * which occurs sometimes, but most testing on the VMs indicates a minimum timeout closer to
9701 * 15.6 ms. Since there is some measurement error between test runs we are allowing for
9702 * ±9 counts (~4 ms) around the expected value.
9705 id
= SetTimer(NULL
, 0, 0, callback_count
);
9706 ok(id
!= 0, "did not get id from SetTimer.\n");
9707 start
= GetTickCount();
9708 while (GetTickCount()-start
< 1001 && GetMessageA(&msg
, NULL
, 0, 0))
9709 DispatchMessageA(&msg
);
9710 ok(abs(count
-TIMER_COUNT_EXPECTED
) < TIMER_COUNT_TOLERANCE
/* xp */
9711 || broken(abs(count
-64) < TIMER_COUNT_TOLERANCE
) /* most common */,
9712 "did not get expected count for minimum timeout (%d != ~%d).\n",
9713 count
, TIMER_COUNT_EXPECTED
);
9714 KillTimer(NULL
, id
);
9715 /* Note: SetSystemTimer doesn't support a NULL window, see test_timers */
9717 if (pSetCoalescableTimer
)
9720 id
= pSetCoalescableTimer(NULL
, 0, 0, callback_count
, 0);
9721 ok(id
!= 0, "SetCoalescableTimer failed with %u.\n", GetLastError());
9722 start
= GetTickCount();
9723 while (GetTickCount()-start
< 100 && GetMessageA(&msg
, NULL
, 0, 0))
9724 DispatchMessageA(&msg
);
9725 ok(count
> 1, "expected count > 1, got %d.\n", count
);
9726 KillTimer(NULL
, id
);
9729 win_skip("SetCoalescableTimer not available.\n");
9731 /* Check what happens when we're running out of timers */
9732 for (i
=0; i
<sizeof(ids
)/sizeof(ids
[0]); i
++)
9734 SetLastError(0xdeadbeef);
9735 ids
[i
] = SetTimer(NULL
, 0, USER_TIMER_MAXIMUM
, tfunc
);
9738 ok(i
!= sizeof(ids
)/sizeof(ids
[0]), "all timers were created successfully\n");
9739 ok(GetLastError()==ERROR_NO_MORE_USER_HANDLES
|| broken(GetLastError()==0xdeadbeef),
9740 "GetLastError() = %d\n", GetLastError());
9741 while (i
> 0) KillTimer(NULL
, ids
[--i
]);
9744 static void test_timers_exception(DWORD code
)
9750 id
= SetTimer(NULL
, 0, 1000, callback_exception
);
9751 ok(id
!= 0, "did not get id from SetTimer.\n");
9753 memset(&msg
, 0, sizeof(msg
));
9754 msg
.message
= WM_TIMER
;
9756 msg
.lParam
= (LPARAM
)callback_exception
;
9759 DispatchMessageA(&msg
);
9760 ok(count
== 1, "did not get one count as expected (%i).\n", count
);
9762 KillTimer(NULL
, id
);
9765 static void test_timers_exceptions(void)
9767 test_timers_exception(EXCEPTION_ACCESS_VIOLATION
);
9768 test_timers_exception(EXCEPTION_DATATYPE_MISALIGNMENT
);
9769 test_timers_exception(EXCEPTION_BREAKPOINT
);
9770 test_timers_exception(EXCEPTION_SINGLE_STEP
);
9771 test_timers_exception(EXCEPTION_ARRAY_BOUNDS_EXCEEDED
);
9772 test_timers_exception(EXCEPTION_FLT_DENORMAL_OPERAND
);
9773 test_timers_exception(EXCEPTION_FLT_DIVIDE_BY_ZERO
);
9774 test_timers_exception(EXCEPTION_FLT_INEXACT_RESULT
);
9775 test_timers_exception(EXCEPTION_ILLEGAL_INSTRUCTION
);
9776 test_timers_exception(0xE000BEEF); /* customer exception */
9779 /* Various win events with arbitrary parameters */
9780 static const struct message WmWinEventsSeq
[] = {
9781 { EVENT_SYSTEM_SOUND
, winevent_hook
|wparam
|lparam
, OBJID_WINDOW
, 0 },
9782 { EVENT_SYSTEM_ALERT
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 1 },
9783 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, OBJID_TITLEBAR
, 2 },
9784 { EVENT_SYSTEM_MENUSTART
, winevent_hook
|wparam
|lparam
, OBJID_MENU
, 3 },
9785 { EVENT_SYSTEM_MENUEND
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 4 },
9786 { EVENT_SYSTEM_MENUPOPUPSTART
, winevent_hook
|wparam
|lparam
, OBJID_VSCROLL
, 5 },
9787 { EVENT_SYSTEM_MENUPOPUPEND
, winevent_hook
|wparam
|lparam
, OBJID_HSCROLL
, 6 },
9788 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, OBJID_SIZEGRIP
, 7 },
9789 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 8 },
9790 /* our win event hook ignores OBJID_CURSOR events */
9791 /*{ EVENT_SYSTEM_MOVESIZESTART, winevent_hook|wparam|lparam, OBJID_CURSOR, 9 },*/
9792 { EVENT_SYSTEM_MOVESIZEEND
, winevent_hook
|wparam
|lparam
, OBJID_ALERT
, 10 },
9793 { EVENT_SYSTEM_CONTEXTHELPSTART
, winevent_hook
|wparam
|lparam
, OBJID_SOUND
, 11 },
9794 { EVENT_SYSTEM_CONTEXTHELPEND
, winevent_hook
|wparam
|lparam
, OBJID_QUERYCLASSNAMEIDX
, 12 },
9795 { EVENT_SYSTEM_DRAGDROPSTART
, winevent_hook
|wparam
|lparam
, OBJID_NATIVEOM
, 13 },
9796 { EVENT_SYSTEM_DRAGDROPEND
, winevent_hook
|wparam
|lparam
, OBJID_WINDOW
, 0 },
9797 { EVENT_SYSTEM_DIALOGSTART
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 1 },
9798 { EVENT_SYSTEM_DIALOGEND
, winevent_hook
|wparam
|lparam
, OBJID_TITLEBAR
, 2 },
9799 { EVENT_SYSTEM_SCROLLINGSTART
, winevent_hook
|wparam
|lparam
, OBJID_MENU
, 3 },
9800 { EVENT_SYSTEM_SCROLLINGEND
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 4 },
9801 { EVENT_SYSTEM_SWITCHSTART
, winevent_hook
|wparam
|lparam
, OBJID_VSCROLL
, 5 },
9802 { EVENT_SYSTEM_SWITCHEND
, winevent_hook
|wparam
|lparam
, OBJID_HSCROLL
, 6 },
9803 { EVENT_SYSTEM_MINIMIZESTART
, winevent_hook
|wparam
|lparam
, OBJID_SIZEGRIP
, 7 },
9804 { EVENT_SYSTEM_MINIMIZEEND
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 8 },
9807 static const struct message WmWinEventCaretSeq
[] = {
9808 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 1 */
9809 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 1 */
9810 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 2 */
9811 { EVENT_OBJECT_NAMECHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 1 */
9814 static const struct message WmWinEventCaretSeq_2
[] = {
9815 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 1/2 */
9816 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 1/2 */
9817 { EVENT_OBJECT_NAMECHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 1/2 */
9820 static const struct message WmWinEventAlertSeq
[] = {
9821 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_ALERT
, 0 },
9824 static const struct message WmWinEventAlertSeq_2
[] = {
9825 /* create window in the thread proc */
9826 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_WINDOW
, 2 },
9827 /* our test event */
9828 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_ALERT
, 2 },
9831 static const struct message WmGlobalHookSeq_1
[] = {
9832 /* create window in the thread proc */
9833 { HCBT_CREATEWND
, hook
|lparam
, 0, 2 },
9834 /* our test events */
9835 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_PREVWINDOW
, 2 },
9836 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_NEXTWINDOW
, 2 },
9839 static const struct message WmGlobalHookSeq_2
[] = {
9840 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_NEXTWINDOW
, 0 }, /* old local hook */
9841 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_NEXTWINDOW
, 2 }, /* new global hook */
9842 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_PREVWINDOW
, 0 }, /* old local hook */
9843 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_PREVWINDOW
, 2 }, /* new global hook */
9847 static const struct message WmMouseLLHookSeq
[] = {
9848 { WM_MOUSEMOVE
, hook
},
9849 { WM_LBUTTONUP
, hook
},
9850 { WM_MOUSEMOVE
, hook
},
9854 static void CALLBACK
win_event_global_hook_proc(HWINEVENTHOOK hevent
,
9864 if (GetClassNameA(hwnd
, buf
, sizeof(buf
)))
9866 if (!lstrcmpiA(buf
, "TestWindowClass") ||
9867 !lstrcmpiA(buf
, "static"))
9869 struct recvd_message msg
;
9872 msg
.message
= event
;
9873 msg
.flags
= winevent_hook
|wparam
|lparam
;
9874 msg
.wParam
= object_id
;
9875 msg
.lParam
= (thread_id
== GetCurrentThreadId()) ? child_id
: (child_id
+ 2);
9876 msg
.descr
= "WEH_2";
9882 static HHOOK hCBT_global_hook
;
9883 static DWORD cbt_global_hook_thread_id
;
9885 static LRESULT CALLBACK
cbt_global_hook_proc(int nCode
, WPARAM wParam
, LPARAM lParam
)
9890 if (nCode
== HCBT_SYSCOMMAND
)
9892 struct recvd_message msg
;
9895 msg
.message
= nCode
;
9896 msg
.flags
= hook
|wparam
|lparam
;
9897 msg
.wParam
= wParam
;
9898 msg
.lParam
= (cbt_global_hook_thread_id
== GetCurrentThreadId()) ? 1 : 2;
9899 msg
.descr
= "CBT_2";
9902 return CallNextHookEx(hCBT_global_hook
, nCode
, wParam
, lParam
);
9904 /* WH_MOUSE_LL hook */
9905 if (nCode
== HC_ACTION
)
9907 MSLLHOOKSTRUCT
*mhll
= (MSLLHOOKSTRUCT
*)lParam
;
9909 /* we can't test for real mouse events */
9910 if (mhll
->flags
& LLMHF_INJECTED
)
9912 struct recvd_message msg
;
9914 memset (&msg
, 0, sizeof (msg
));
9915 msg
.message
= wParam
;
9917 msg
.descr
= "CBT_2";
9920 return CallNextHookEx(hCBT_global_hook
, nCode
, wParam
, lParam
);
9923 /* Log also SetFocus(0) calls */
9924 hwnd
= wParam
? (HWND
)wParam
: (HWND
)lParam
;
9926 if (GetClassNameA(hwnd
, buf
, sizeof(buf
)))
9928 if (!lstrcmpiA(buf
, "TestWindowClass") ||
9929 !lstrcmpiA(buf
, "static"))
9931 struct recvd_message msg
;
9934 msg
.message
= nCode
;
9935 msg
.flags
= hook
|wparam
|lparam
;
9936 msg
.wParam
= wParam
;
9937 msg
.lParam
= (cbt_global_hook_thread_id
== GetCurrentThreadId()) ? 1 : 2;
9938 msg
.descr
= "CBT_2";
9942 return CallNextHookEx(hCBT_global_hook
, nCode
, wParam
, lParam
);
9945 static DWORD WINAPI
win_event_global_thread_proc(void *param
)
9949 HANDLE hevent
= *(HANDLE
*)param
;
9951 assert(pNotifyWinEvent
);
9953 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
, 0,0,0,0,0,0,0, NULL
);
9955 trace("created thread window %p\n", hwnd
);
9957 *(HWND
*)param
= hwnd
;
9960 /* this event should be received only by our new hook proc,
9961 * an old one does not expect an event from another thread.
9963 pNotifyWinEvent(EVENT_OBJECT_LOCATIONCHANGE
, hwnd
, OBJID_ALERT
, 0);
9966 while (GetMessageA(&msg
, 0, 0, 0))
9968 TranslateMessage(&msg
);
9969 DispatchMessageA(&msg
);
9974 static DWORD WINAPI
cbt_global_hook_thread_proc(void *param
)
9978 HANDLE hevent
= *(HANDLE
*)param
;
9981 /* these events should be received only by our new hook proc,
9982 * an old one does not expect an event from another thread.
9985 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
, 0,0,0,0,0,0,0, NULL
);
9987 trace("created thread window %p\n", hwnd
);
9989 *(HWND
*)param
= hwnd
;
9991 /* Windows doesn't like when a thread plays games with the focus,
9992 that leads to all kinds of misbehaviours and failures to activate
9993 a window. So, better keep next lines commented out.
9997 DefWindowProcA(hwnd
, WM_SYSCOMMAND
, SC_PREVWINDOW
, 0);
9998 DefWindowProcA(hwnd
, WM_SYSCOMMAND
, SC_NEXTWINDOW
, 0);
10002 while (GetMessageA(&msg
, 0, 0, 0))
10004 TranslateMessage(&msg
);
10005 DispatchMessageA(&msg
);
10010 static DWORD WINAPI
mouse_ll_global_thread_proc(void *param
)
10014 HANDLE hevent
= *(HANDLE
*)param
;
10016 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
, 0,0,0,0,0,0,0, NULL
);
10018 trace("created thread window %p\n", hwnd
);
10020 *(HWND
*)param
= hwnd
;
10024 /* Windows doesn't like when a thread plays games with the focus,
10025 * that leads to all kinds of misbehaviours and failures to activate
10026 * a window. So, better don't generate a mouse click message below.
10028 mouse_event(MOUSEEVENTF_MOVE
, -1, 0, 0, 0);
10029 mouse_event(MOUSEEVENTF_LEFTUP
, 0, 0, 0, 0);
10030 mouse_event(MOUSEEVENTF_MOVE
, 1, 0, 0, 0);
10033 while (GetMessageA(&msg
, 0, 0, 0))
10035 TranslateMessage(&msg
);
10036 DispatchMessageA(&msg
);
10041 static void test_winevents(void)
10047 HANDLE hthread
, hevent
;
10049 HWINEVENTHOOK hhook
;
10050 const struct message
*events
= WmWinEventsSeq
;
10052 hwnd
= CreateWindowExA(0, "TestWindowClass", NULL
,
10053 WS_OVERLAPPEDWINDOW
,
10054 CW_USEDEFAULT
, CW_USEDEFAULT
, 300, 300, 0,
10058 /****** start of global hook test *************/
10059 hCBT_global_hook
= SetWindowsHookExA(WH_CBT
, cbt_global_hook_proc
, GetModuleHandleA(0), 0);
10060 if (!hCBT_global_hook
)
10062 ok(DestroyWindow(hwnd
), "failed to destroy window\n");
10063 skip( "cannot set global hook\n" );
10067 hevent
= CreateEventA(NULL
, 0, 0, NULL
);
10071 hthread
= CreateThread(NULL
, 0, cbt_global_hook_thread_proc
, &hwnd2
, 0, &tid
);
10072 ok(hthread
!= NULL
, "CreateThread failed, error %d\n", GetLastError());
10074 ok(WaitForSingleObject(hevent
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
10076 ok_sequence(WmGlobalHookSeq_1
, "global hook 1", FALSE
);
10079 /* this one should be received only by old hook proc */
10080 DefWindowProcA(hwnd
, WM_SYSCOMMAND
, SC_NEXTWINDOW
, 0);
10081 /* this one should be received only by old hook proc */
10082 DefWindowProcA(hwnd
, WM_SYSCOMMAND
, SC_PREVWINDOW
, 0);
10084 ok_sequence(WmGlobalHookSeq_2
, "global hook 2", FALSE
);
10086 ret
= UnhookWindowsHookEx(hCBT_global_hook
);
10087 ok( ret
, "UnhookWindowsHookEx error %d\n", GetLastError());
10089 PostThreadMessageA(tid
, WM_QUIT
, 0, 0);
10090 ok(WaitForSingleObject(hthread
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
10091 CloseHandle(hthread
);
10092 CloseHandle(hevent
);
10093 ok(!IsWindow(hwnd2
), "window should be destroyed on thread exit\n");
10094 /****** end of global hook test *************/
10096 if (!pSetWinEventHook
|| !pNotifyWinEvent
|| !pUnhookWinEvent
)
10098 ok(DestroyWindow(hwnd
), "failed to destroy window\n");
10106 /* this test doesn't pass under Win9x */
10107 /* win2k ignores events with hwnd == 0 */
10108 SetLastError(0xdeadbeef);
10109 pNotifyWinEvent(events
[0].message
, 0, events
[0].wParam
, events
[0].lParam
);
10110 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
|| /* Win2k */
10111 GetLastError() == 0xdeadbeef, /* Win9x */
10112 "unexpected error %d\n", GetLastError());
10113 ok_sequence(WmEmptySeq
, "empty notify winevents", FALSE
);
10116 for (i
= 0; i
< sizeof(WmWinEventsSeq
)/sizeof(WmWinEventsSeq
[0]); i
++)
10117 pNotifyWinEvent(events
[i
].message
, hwnd
, events
[i
].wParam
, events
[i
].lParam
);
10119 ok_sequence(WmWinEventsSeq
, "notify winevents", FALSE
);
10121 /****** start of event filtering test *************/
10122 hhook
= pSetWinEventHook(
10123 EVENT_OBJECT_SHOW
, /* 0x8002 */
10124 EVENT_OBJECT_LOCATIONCHANGE
, /* 0x800B */
10125 GetModuleHandleA(0), win_event_global_hook_proc
,
10126 GetCurrentProcessId(), 0,
10127 WINEVENT_INCONTEXT
);
10128 ok(hhook
!= 0, "SetWinEventHook error %d\n", GetLastError());
10130 hevent
= CreateEventA(NULL
, 0, 0, NULL
);
10134 hthread
= CreateThread(NULL
, 0, win_event_global_thread_proc
, &hwnd2
, 0, &tid
);
10135 ok(hthread
!= NULL
, "CreateThread failed, error %d\n", GetLastError());
10137 ok(WaitForSingleObject(hevent
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
10139 ok_sequence(WmWinEventAlertSeq
, "alert winevent", FALSE
);
10142 /* this one should be received only by old hook proc */
10143 pNotifyWinEvent(EVENT_OBJECT_CREATE
, hwnd
, OBJID_CARET
, 0); /* 0x8000 */
10144 pNotifyWinEvent(EVENT_OBJECT_SHOW
, hwnd
, OBJID_CARET
, 0); /* 0x8002 */
10145 /* this one should be received only by old hook proc */
10146 pNotifyWinEvent(EVENT_OBJECT_NAMECHANGE
, hwnd
, OBJID_CARET
, 0); /* 0x800C */
10148 ok_sequence(WmWinEventCaretSeq
, "caret winevent", FALSE
);
10150 ret
= pUnhookWinEvent(hhook
);
10151 ok( ret
, "UnhookWinEvent error %d\n", GetLastError());
10153 PostThreadMessageA(tid
, WM_QUIT
, 0, 0);
10154 ok(WaitForSingleObject(hthread
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
10155 CloseHandle(hthread
);
10156 CloseHandle(hevent
);
10157 ok(!IsWindow(hwnd2
), "window should be destroyed on thread exit\n");
10158 /****** end of event filtering test *************/
10160 /****** start of out of context event test *************/
10161 hhook
= pSetWinEventHook(EVENT_MIN
, EVENT_MAX
, 0,
10162 win_event_global_hook_proc
, GetCurrentProcessId(), 0,
10163 WINEVENT_OUTOFCONTEXT
);
10164 ok(hhook
!= 0, "SetWinEventHook error %d\n", GetLastError());
10166 hevent
= CreateEventA(NULL
, 0, 0, NULL
);
10172 hthread
= CreateThread(NULL
, 0, win_event_global_thread_proc
, &hwnd2
, 0, &tid
);
10173 ok(hthread
!= NULL
, "CreateThread failed, error %d\n", GetLastError());
10175 ok(WaitForSingleObject(hevent
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
10177 ok_sequence(WmEmptySeq
, "empty notify winevents", FALSE
);
10178 /* process pending winevent messages */
10179 ok(!PeekMessageA(&msg
, 0, 0, 0, PM_NOREMOVE
), "msg queue should be empty\n");
10180 ok_sequence(WmWinEventAlertSeq_2
, "alert winevent for out of context proc", FALSE
);
10183 /* this one should be received only by old hook proc */
10184 pNotifyWinEvent(EVENT_OBJECT_CREATE
, hwnd
, OBJID_CARET
, 0); /* 0x8000 */
10185 pNotifyWinEvent(EVENT_OBJECT_SHOW
, hwnd
, OBJID_CARET
, 0); /* 0x8002 */
10186 /* this one should be received only by old hook proc */
10187 pNotifyWinEvent(EVENT_OBJECT_NAMECHANGE
, hwnd
, OBJID_CARET
, 0); /* 0x800C */
10189 ok_sequence(WmWinEventCaretSeq_2
, "caret winevent for incontext proc", FALSE
);
10190 /* process pending winevent messages */
10191 ok(!PeekMessageA(&msg
, 0, 0, 0, PM_NOREMOVE
), "msg queue should be empty\n");
10192 ok_sequence(WmWinEventCaretSeq_2
, "caret winevent for out of context proc", FALSE
);
10194 ret
= pUnhookWinEvent(hhook
);
10195 ok( ret
, "UnhookWinEvent error %d\n", GetLastError());
10197 PostThreadMessageA(tid
, WM_QUIT
, 0, 0);
10198 ok(WaitForSingleObject(hthread
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
10199 CloseHandle(hthread
);
10200 CloseHandle(hevent
);
10201 ok(!IsWindow(hwnd2
), "window should be destroyed on thread exit\n");
10202 /****** end of out of context event test *************/
10204 /****** start of MOUSE_LL hook test *************/
10205 hCBT_global_hook
= SetWindowsHookExA(WH_MOUSE_LL
, cbt_global_hook_proc
, GetModuleHandleA(0), 0);
10206 /* WH_MOUSE_LL is not supported on Win9x platforms */
10207 if (!hCBT_global_hook
)
10209 win_skip("Skipping WH_MOUSE_LL test on this platform\n");
10210 goto skip_mouse_ll_hook_test
;
10213 hevent
= CreateEventA(NULL
, 0, 0, NULL
);
10217 hthread
= CreateThread(NULL
, 0, mouse_ll_global_thread_proc
, &hwnd2
, 0, &tid
);
10218 ok(hthread
!= NULL
, "CreateThread failed, error %d\n", GetLastError());
10220 while (WaitForSingleObject(hevent
, 100) == WAIT_TIMEOUT
)
10221 while (PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA( &msg
);
10223 ok_sequence(WmMouseLLHookSeq
, "MOUSE_LL hook other thread", FALSE
);
10226 mouse_event(MOUSEEVENTF_MOVE
, -1, 0, 0, 0);
10227 mouse_event(MOUSEEVENTF_LEFTUP
, 0, 0, 0, 0);
10228 mouse_event(MOUSEEVENTF_MOVE
, 1, 0, 0, 0);
10230 ok_sequence(WmMouseLLHookSeq
, "MOUSE_LL hook same thread", FALSE
);
10232 ret
= UnhookWindowsHookEx(hCBT_global_hook
);
10233 ok( ret
, "UnhookWindowsHookEx error %d\n", GetLastError());
10235 PostThreadMessageA(tid
, WM_QUIT
, 0, 0);
10236 ok(WaitForSingleObject(hthread
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
10237 CloseHandle(hthread
);
10238 CloseHandle(hevent
);
10239 ok(!IsWindow(hwnd2
), "window should be destroyed on thread exit\n");
10240 /****** end of MOUSE_LL hook test *************/
10241 skip_mouse_ll_hook_test
:
10243 ok(DestroyWindow(hwnd
), "failed to destroy window\n");
10246 static void test_set_hook(void)
10250 HWINEVENTHOOK hwinevent_hook
;
10252 hhook
= SetWindowsHookExA(WH_CBT
, cbt_hook_proc
, GetModuleHandleA(0), GetCurrentThreadId());
10253 ok(hhook
!= 0, "local hook does not require hModule set to 0\n");
10254 UnhookWindowsHookEx(hhook
);
10258 /* this test doesn't pass under Win9x: BUG! */
10259 SetLastError(0xdeadbeef);
10260 hhook
= SetWindowsHookExA(WH_CBT
, cbt_hook_proc
, 0, 0);
10261 ok(!hhook
, "global hook requires hModule != 0\n");
10262 ok(GetLastError() == ERROR_HOOK_NEEDS_HMOD
, "unexpected error %d\n", GetLastError());
10265 SetLastError(0xdeadbeef);
10266 hhook
= SetWindowsHookExA(WH_CBT
, 0, GetModuleHandleA(0), GetCurrentThreadId());
10267 ok(!hhook
, "SetWinEventHook with invalid proc should fail\n");
10268 ok(GetLastError() == ERROR_INVALID_FILTER_PROC
|| /* Win2k */
10269 GetLastError() == 0xdeadbeef, /* Win9x */
10270 "unexpected error %d\n", GetLastError());
10272 SetLastError(0xdeadbeef);
10273 ok(!UnhookWindowsHookEx((HHOOK
)0xdeadbeef), "UnhookWindowsHookEx succeeded\n");
10274 ok(GetLastError() == ERROR_INVALID_HOOK_HANDLE
|| /* Win2k */
10275 GetLastError() == 0xdeadbeef, /* Win9x */
10276 "unexpected error %d\n", GetLastError());
10278 if (!pSetWinEventHook
|| !pUnhookWinEvent
) return;
10280 /* even process local incontext hooks require hmodule */
10281 SetLastError(0xdeadbeef);
10282 hwinevent_hook
= pSetWinEventHook(EVENT_MIN
, EVENT_MAX
, 0, win_event_proc
,
10283 GetCurrentProcessId(), 0, WINEVENT_INCONTEXT
);
10284 ok(!hwinevent_hook
, "WINEVENT_INCONTEXT requires hModule != 0\n");
10285 ok(GetLastError() == ERROR_HOOK_NEEDS_HMOD
|| /* Win2k */
10286 GetLastError() == 0xdeadbeef, /* Win9x */
10287 "unexpected error %d\n", GetLastError());
10289 /* even thread local incontext hooks require hmodule */
10290 SetLastError(0xdeadbeef);
10291 hwinevent_hook
= pSetWinEventHook(EVENT_MIN
, EVENT_MAX
, 0, win_event_proc
,
10292 GetCurrentProcessId(), GetCurrentThreadId(), WINEVENT_INCONTEXT
);
10293 ok(!hwinevent_hook
, "WINEVENT_INCONTEXT requires hModule != 0\n");
10294 ok(GetLastError() == ERROR_HOOK_NEEDS_HMOD
|| /* Win2k */
10295 GetLastError() == 0xdeadbeef, /* Win9x */
10296 "unexpected error %d\n", GetLastError());
10300 /* these 3 tests don't pass under Win9x */
10301 SetLastError(0xdeadbeef);
10302 hwinevent_hook
= pSetWinEventHook(1, 0, 0, win_event_proc
,
10303 GetCurrentProcessId(), 0, WINEVENT_OUTOFCONTEXT
);
10304 ok(!hwinevent_hook
, "SetWinEventHook with invalid event range should fail\n");
10305 ok(GetLastError() == ERROR_INVALID_HOOK_FILTER
, "unexpected error %d\n", GetLastError());
10307 SetLastError(0xdeadbeef);
10308 hwinevent_hook
= pSetWinEventHook(-1, 1, 0, win_event_proc
,
10309 GetCurrentProcessId(), 0, WINEVENT_OUTOFCONTEXT
);
10310 ok(!hwinevent_hook
, "SetWinEventHook with invalid event range should fail\n");
10311 ok(GetLastError() == ERROR_INVALID_HOOK_FILTER
, "unexpected error %d\n", GetLastError());
10313 SetLastError(0xdeadbeef);
10314 hwinevent_hook
= pSetWinEventHook(EVENT_MIN
, EVENT_MAX
, 0, win_event_proc
,
10315 0, 0xdeadbeef, WINEVENT_OUTOFCONTEXT
);
10316 ok(!hwinevent_hook
, "SetWinEventHook with invalid tid should fail\n");
10317 ok(GetLastError() == ERROR_INVALID_THREAD_ID
, "unexpected error %d\n", GetLastError());
10320 SetLastError(0xdeadbeef);
10321 hwinevent_hook
= pSetWinEventHook(0, 0, 0, win_event_proc
,
10322 GetCurrentProcessId(), 0, WINEVENT_OUTOFCONTEXT
);
10323 ok(hwinevent_hook
!= 0, "SetWinEventHook error %d\n", GetLastError());
10324 ok(GetLastError() == 0xdeadbeef, "unexpected error %d\n", GetLastError());
10325 ret
= pUnhookWinEvent(hwinevent_hook
);
10326 ok( ret
, "UnhookWinEvent error %d\n", GetLastError());
10329 /* This call succeeds under win2k SP4, but fails under Wine.
10330 Does win2k test/use passed process id? */
10331 SetLastError(0xdeadbeef);
10332 hwinevent_hook
= pSetWinEventHook(EVENT_MIN
, EVENT_MAX
, 0, win_event_proc
,
10333 0xdeadbeef, 0, WINEVENT_OUTOFCONTEXT
);
10334 ok(hwinevent_hook
!= 0, "SetWinEventHook error %d\n", GetLastError());
10335 ok(GetLastError() == 0xdeadbeef, "unexpected error %d\n", GetLastError());
10336 ret
= pUnhookWinEvent(hwinevent_hook
);
10337 ok( ret
, "UnhookWinEvent error %d\n", GetLastError());
10340 SetLastError(0xdeadbeef);
10341 ok(!pUnhookWinEvent((HWINEVENTHOOK
)0xdeadbeef), "UnhookWinEvent succeeded\n");
10342 ok(GetLastError() == ERROR_INVALID_HANDLE
|| /* Win2k */
10343 GetLastError() == 0xdeadbeef, /* Win9x */
10344 "unexpected error %d\n", GetLastError());
10347 static HWND hook_hwnd
;
10348 static HHOOK recursive_hook
;
10349 static int hook_depth
, max_hook_depth
;
10351 static LRESULT WINAPI
rec_get_message_hook(int code
, WPARAM w
, LPARAM l
)
10358 if(hook_depth
> max_hook_depth
)
10359 max_hook_depth
= hook_depth
;
10361 b
= PeekMessageW(&msg
, hook_hwnd
, 0, 0, PM_NOREMOVE
);
10362 ok(b
, "PeekMessage failed\n");
10364 res
= CallNextHookEx(recursive_hook
, code
, w
, l
);
10370 static void test_recursive_hook(void)
10375 hook_hwnd
= CreateWindowA("Static", NULL
, WS_POPUP
, 0, 0, 200, 60, NULL
, NULL
, NULL
, NULL
);
10376 ok(hook_hwnd
!= NULL
, "CreateWindow failed\n");
10378 recursive_hook
= SetWindowsHookExW(WH_GETMESSAGE
, rec_get_message_hook
, NULL
, GetCurrentThreadId());
10379 ok(recursive_hook
!= NULL
, "SetWindowsHookEx failed\n");
10381 PostMessageW(hook_hwnd
, WM_USER
, 0, 0);
10382 PostMessageW(hook_hwnd
, WM_USER
+1, 0, 0);
10385 GetMessageW(&msg
, hook_hwnd
, 0, 0);
10386 ok(15 <= max_hook_depth
&& max_hook_depth
< 45, "max_hook_depth = %d\n", max_hook_depth
);
10387 trace("max_hook_depth = %d\n", max_hook_depth
);
10389 b
= UnhookWindowsHookEx(recursive_hook
);
10390 ok(b
, "UnhokWindowsHookEx failed\n");
10392 DestroyWindow(hook_hwnd
);
10395 static const struct message ScrollWindowPaint1
[] = {
10396 { WM_PAINT
, sent
},
10397 { WM_ERASEBKGND
, sent
|beginpaint
},
10398 { WM_GETTEXTLENGTH
, sent
|optional
},
10399 { WM_PAINT
, sent
|optional
},
10400 { WM_NCPAINT
, sent
|beginpaint
|optional
},
10401 { WM_GETTEXT
, sent
|beginpaint
|optional
},
10402 { WM_GETTEXT
, sent
|beginpaint
|optional
},
10403 { WM_GETTEXT
, sent
|beginpaint
|optional
},
10404 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
10405 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
10409 static const struct message ScrollWindowPaint2
[] = {
10410 { WM_PAINT
, sent
},
10414 static void test_scrollwindowex(void)
10417 RECT rect
={0,0,130,130};
10419 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test Scroll",
10420 WS_VISIBLE
|WS_OVERLAPPEDWINDOW
,
10421 100, 100, 200, 200, 0, 0, 0, NULL
);
10422 ok (hwnd
!= 0, "Failed to create overlapped window\n");
10423 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child",
10424 WS_VISIBLE
|WS_CAPTION
|WS_CHILD
,
10425 10, 10, 150, 150, hwnd
, 0, 0, NULL
);
10426 ok (hchild
!= 0, "Failed to create child\n");
10427 UpdateWindow(hwnd
);
10431 /* scroll without the child window */
10432 trace("start scroll\n");
10433 ScrollWindowEx( hwnd
, 10, 10, &rect
, NULL
, NULL
, NULL
,
10434 SW_ERASE
|SW_INVALIDATE
);
10435 ok_sequence(WmEmptySeq
, "ScrollWindowEx", FALSE
);
10436 trace("end scroll\n");
10439 ok_sequence(ScrollWindowPaint1
, "ScrollWindowEx", FALSE
);
10443 /* Now without the SW_ERASE flag */
10444 trace("start scroll\n");
10445 ScrollWindowEx( hwnd
, 10, 10, &rect
, NULL
, NULL
, NULL
, SW_INVALIDATE
);
10446 ok_sequence(WmEmptySeq
, "ScrollWindowEx", FALSE
);
10447 trace("end scroll\n");
10450 ok_sequence(ScrollWindowPaint2
, "ScrollWindowEx", FALSE
);
10454 /* now scroll the child window as well */
10455 trace("start scroll\n");
10456 ScrollWindowEx( hwnd
, 10, 10, &rect
, NULL
, NULL
, NULL
,
10457 SW_SCROLLCHILDREN
|SW_ERASE
|SW_INVALIDATE
);
10458 /* wine sends WM_POSCHANGING, WM_POSCHANGED messages */
10459 /* windows sometimes a WM_MOVE */
10460 ok_sequence(WmEmptySeq
, "ScrollWindowEx", TRUE
);
10461 trace("end scroll\n");
10464 ok_sequence(ScrollWindowPaint1
, "ScrollWindowEx", FALSE
);
10468 /* now scroll with ScrollWindow() */
10469 trace("start scroll with ScrollWindow\n");
10470 ScrollWindow( hwnd
, 5, 5, NULL
, NULL
);
10471 trace("end scroll\n");
10474 ok_sequence(ScrollWindowPaint1
, "ScrollWindow", FALSE
);
10476 ok(DestroyWindow(hchild
), "failed to destroy window\n");
10477 ok(DestroyWindow(hwnd
), "failed to destroy window\n");
10481 static const struct message destroy_window_with_children
[] = {
10482 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* popup */
10483 { HCBT_DESTROYWND
, hook
|lparam
, 0, WND_PARENT_ID
}, /* parent */
10484 { 0x0090, sent
|optional
},
10485 { HCBT_DESTROYWND
, hook
|lparam
, 0, WND_POPUP_ID
}, /* popup */
10486 { 0x0090, sent
|optional
},
10487 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* popup */
10488 { WM_DESTROY
, sent
|wparam
|lparam
, 0, WND_POPUP_ID
}, /* popup */
10489 { WM_CAPTURECHANGED
, sent
|wparam
|lparam
, 0, WND_POPUP_ID
}, /* popup */
10490 { WM_NCDESTROY
, sent
|wparam
|lparam
, 0, WND_POPUP_ID
}, /* popup */
10491 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* parent */
10492 { WM_DESTROY
, sent
|wparam
|lparam
, 0, WND_PARENT_ID
}, /* parent */
10493 { WM_DESTROY
, sent
|wparam
|lparam
, 0, WND_CHILD_ID
+ 2 }, /* child2 */
10494 { WM_DESTROY
, sent
|wparam
|lparam
, 0, WND_CHILD_ID
+ 1 }, /* child1 */
10495 { WM_DESTROY
, sent
|wparam
|lparam
, 0, WND_CHILD_ID
+ 3 }, /* child3 */
10496 { WM_NCDESTROY
, sent
|wparam
|lparam
, 0, WND_CHILD_ID
+ 2 }, /* child2 */
10497 { WM_NCDESTROY
, sent
|wparam
|lparam
, 0, WND_CHILD_ID
+ 3 }, /* child3 */
10498 { WM_NCDESTROY
, sent
|wparam
|lparam
, 0, WND_CHILD_ID
+ 1 }, /* child1 */
10499 { WM_NCDESTROY
, sent
|wparam
|lparam
, 0, WND_PARENT_ID
}, /* parent */
10503 static void test_DestroyWindow(void)
10506 HWND parent
, child1
, child2
, child3
, child4
, test
;
10507 UINT_PTR child_id
= WND_CHILD_ID
+ 1;
10509 parent
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
10510 100, 100, 200, 200, 0, 0, 0, NULL
);
10511 assert(parent
!= 0);
10512 child1
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_CHILD
,
10513 0, 0, 50, 50, parent
, (HMENU
)child_id
++, 0, NULL
);
10514 assert(child1
!= 0);
10515 child2
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_CHILD
,
10516 0, 0, 50, 50, GetDesktopWindow(), (HMENU
)child_id
++, 0, NULL
);
10517 assert(child2
!= 0);
10518 child3
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_CHILD
,
10519 0, 0, 50, 50, child1
, (HMENU
)child_id
++, 0, NULL
);
10520 assert(child3
!= 0);
10521 child4
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_POPUP
,
10522 0, 0, 50, 50, parent
, 0, 0, NULL
);
10523 assert(child4
!= 0);
10525 /* test owner/parent of child2 */
10526 test
= GetParent(child2
);
10527 ok(test
== GetDesktopWindow(), "wrong parent %p\n", test
);
10528 ok(!IsChild(parent
, child2
), "wrong parent/child %p/%p\n", parent
, child2
);
10530 test
= pGetAncestor(child2
, GA_PARENT
);
10531 ok(test
== GetDesktopWindow(), "wrong parent %p\n", test
);
10533 test
= GetWindow(child2
, GW_OWNER
);
10534 ok(!test
, "wrong owner %p\n", test
);
10536 test
= SetParent(child2
, parent
);
10537 ok(test
== GetDesktopWindow(), "wrong old parent %p\n", test
);
10539 /* test owner/parent of the parent */
10540 test
= GetParent(parent
);
10541 ok(!test
, "wrong parent %p\n", test
);
10542 ok(!IsChild(GetDesktopWindow(), parent
), "wrong parent/child %p/%p\n", GetDesktopWindow(), parent
);
10544 test
= pGetAncestor(parent
, GA_PARENT
);
10545 ok(test
== GetDesktopWindow(), "wrong parent %p\n", test
);
10547 test
= GetWindow(parent
, GW_OWNER
);
10548 ok(!test
, "wrong owner %p\n", test
);
10550 /* test owner/parent of child1 */
10551 test
= GetParent(child1
);
10552 ok(test
== parent
, "wrong parent %p\n", test
);
10553 ok(IsChild(parent
, child1
), "wrong parent/child %p/%p\n", parent
, child1
);
10555 test
= pGetAncestor(child1
, GA_PARENT
);
10556 ok(test
== parent
, "wrong parent %p\n", test
);
10558 test
= GetWindow(child1
, GW_OWNER
);
10559 ok(!test
, "wrong owner %p\n", test
);
10561 /* test owner/parent of child2 */
10562 test
= GetParent(child2
);
10563 ok(test
== parent
, "wrong parent %p\n", test
);
10564 ok(IsChild(parent
, child2
), "wrong parent/child %p/%p\n", parent
, child2
);
10566 test
= pGetAncestor(child2
, GA_PARENT
);
10567 ok(test
== parent
, "wrong parent %p\n", test
);
10569 test
= GetWindow(child2
, GW_OWNER
);
10570 ok(!test
, "wrong owner %p\n", test
);
10572 /* test owner/parent of child3 */
10573 test
= GetParent(child3
);
10574 ok(test
== child1
, "wrong parent %p\n", test
);
10575 ok(IsChild(parent
, child3
), "wrong parent/child %p/%p\n", parent
, child3
);
10577 test
= pGetAncestor(child3
, GA_PARENT
);
10578 ok(test
== child1
, "wrong parent %p\n", test
);
10580 test
= GetWindow(child3
, GW_OWNER
);
10581 ok(!test
, "wrong owner %p\n", test
);
10583 /* test owner/parent of child4 */
10584 test
= GetParent(child4
);
10585 ok(test
== parent
, "wrong parent %p\n", test
);
10586 ok(!IsChild(parent
, child4
), "wrong parent/child %p/%p\n", parent
, child4
);
10588 test
= pGetAncestor(child4
, GA_PARENT
);
10589 ok(test
== GetDesktopWindow(), "wrong parent %p\n", test
);
10591 test
= GetWindow(child4
, GW_OWNER
);
10592 ok(test
== parent
, "wrong owner %p\n", test
);
10596 trace("parent %p, child1 %p, child2 %p, child3 %p, child4 %p\n",
10597 parent
, child1
, child2
, child3
, child4
);
10599 SetCapture(child4
);
10600 test
= GetCapture();
10601 ok(test
== child4
, "wrong capture window %p\n", test
);
10603 test_DestroyWindow_flag
= TRUE
;
10604 ret
= DestroyWindow(parent
);
10605 ok( ret
, "DestroyWindow() error %d\n", GetLastError());
10606 test_DestroyWindow_flag
= FALSE
;
10607 ok_sequence(destroy_window_with_children
, "destroy window with children", FALSE
);
10609 ok(!IsWindow(parent
), "parent still exists\n");
10610 ok(!IsWindow(child1
), "child1 still exists\n");
10611 ok(!IsWindow(child2
), "child2 still exists\n");
10612 ok(!IsWindow(child3
), "child3 still exists\n");
10613 ok(!IsWindow(child4
), "child4 still exists\n");
10615 test
= GetCapture();
10616 ok(!test
, "wrong capture window %p\n", test
);
10620 static const struct message WmDispatchPaint
[] = {
10621 { WM_NCPAINT
, sent
},
10622 { WM_GETTEXT
, sent
|defwinproc
|optional
},
10623 { WM_GETTEXT
, sent
|defwinproc
|optional
},
10624 { WM_ERASEBKGND
, sent
},
10628 static LRESULT WINAPI
DispatchMessageCheckProc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
10630 if (message
== WM_PAINT
) return 0;
10631 return MsgCheckProcA( hwnd
, message
, wParam
, lParam
);
10634 static void test_DispatchMessage(void)
10639 HWND hwnd
= CreateWindowA( "TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
10640 100, 100, 200, 200, 0, 0, 0, NULL
);
10641 ShowWindow( hwnd
, SW_SHOW
);
10642 UpdateWindow( hwnd
);
10645 SetWindowLongPtrA( hwnd
, GWLP_WNDPROC
, (LONG_PTR
)DispatchMessageCheckProc
);
10647 SetRect( &rect
, -5, -5, 5, 5 );
10648 RedrawWindow( hwnd
, &rect
, 0, RDW_INVALIDATE
|RDW_ERASE
|RDW_FRAME
);
10650 while (PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
))
10652 if (msg
.message
!= WM_PAINT
) DispatchMessageA( &msg
);
10656 DispatchMessageA( &msg
);
10657 /* DispatchMessage will send WM_NCPAINT if non client area is still invalid after WM_PAINT */
10658 if (!count
) ok_sequence( WmDispatchPaint
, "WmDispatchPaint", FALSE
);
10659 else ok_sequence( WmEmptySeq
, "WmEmpty", FALSE
);
10660 if (++count
> 10) break;
10663 ok( msg
.message
== WM_PAINT
&& count
> 10, "WM_PAINT messages stopped\n" );
10665 trace("now without DispatchMessage\n");
10667 RedrawWindow( hwnd
, &rect
, 0, RDW_INVALIDATE
|RDW_ERASE
|RDW_FRAME
);
10669 while (PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
))
10671 if (msg
.message
!= WM_PAINT
) DispatchMessageA( &msg
);
10674 HRGN hrgn
= CreateRectRgn( 0, 0, 0, 0 );
10676 /* this will send WM_NCCPAINT just like DispatchMessage does */
10677 GetUpdateRgn( hwnd
, hrgn
, TRUE
);
10678 ok_sequence( WmDispatchPaint
, "WmDispatchPaint", FALSE
);
10679 DeleteObject( hrgn
);
10680 GetClientRect( hwnd
, &rect
);
10681 ValidateRect( hwnd
, &rect
); /* this will stop WM_PAINTs */
10682 ok( !count
, "Got multiple WM_PAINTs\n" );
10683 if (++count
> 10) break;
10688 RedrawWindow( hwnd
, &rect
, 0, RDW_INVALIDATE
|RDW_ERASE
|RDW_FRAME
);
10690 while (PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
))
10692 if (msg
.message
!= WM_PAINT
) DispatchMessageA( &msg
);
10698 hdc
= BeginPaint( hwnd
, NULL
);
10699 ok( !hdc
, "got valid hdc %p from BeginPaint\n", hdc
);
10700 ok( !EndPaint( hwnd
, NULL
), "EndPaint succeeded\n" );
10701 ok_sequence( WmDispatchPaint
, "WmDispatchPaint", FALSE
);
10702 ok( !count
, "Got multiple WM_PAINTs\n" );
10703 if (++count
> 10) break;
10706 DestroyWindow(hwnd
);
10710 static const struct message WmUser
[] = {
10715 struct sendmsg_info
10722 static DWORD CALLBACK
send_msg_thread( LPVOID arg
)
10724 struct sendmsg_info
*info
= arg
;
10725 SetLastError( 0xdeadbeef );
10726 info
->ret
= SendMessageTimeoutA( info
->hwnd
, WM_USER
, 0, 0, 0, info
->timeout
, NULL
);
10727 if (!info
->ret
) ok( GetLastError() == ERROR_TIMEOUT
||
10728 broken(GetLastError() == 0), /* win9x */
10729 "unexpected error %d\n", GetLastError());
10733 static void wait_for_thread( HANDLE thread
)
10735 while (MsgWaitForMultipleObjects(1, &thread
, FALSE
, INFINITE
, QS_SENDMESSAGE
) != WAIT_OBJECT_0
)
10738 while (PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
10742 static LRESULT WINAPI
send_msg_delay_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
10744 if (message
== WM_USER
) Sleep(200);
10745 return MsgCheckProcA( hwnd
, message
, wParam
, lParam
);
10748 static void test_SendMessageTimeout(void)
10751 struct sendmsg_info info
;
10755 info
.hwnd
= CreateWindowA( "TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
10756 100, 100, 200, 200, 0, 0, 0, NULL
);
10760 info
.timeout
= 1000;
10761 info
.ret
= 0xdeadbeef;
10762 thread
= CreateThread( NULL
, 0, send_msg_thread
, &info
, 0, &tid
);
10763 wait_for_thread( thread
);
10764 CloseHandle( thread
);
10765 ok( info
.ret
== 1, "SendMessageTimeout failed\n" );
10766 ok_sequence( WmUser
, "WmUser", FALSE
);
10769 info
.ret
= 0xdeadbeef;
10770 thread
= CreateThread( NULL
, 0, send_msg_thread
, &info
, 0, &tid
);
10771 Sleep(100); /* SendMessageTimeout should time out here */
10772 wait_for_thread( thread
);
10773 CloseHandle( thread
);
10774 ok( info
.ret
== 0, "SendMessageTimeout succeeded\n" );
10775 ok_sequence( WmEmptySeq
, "WmEmptySeq", FALSE
);
10777 /* 0 means infinite timeout (but not on win9x) */
10779 info
.ret
= 0xdeadbeef;
10780 thread
= CreateThread( NULL
, 0, send_msg_thread
, &info
, 0, &tid
);
10782 wait_for_thread( thread
);
10783 CloseHandle( thread
);
10784 is_win9x
= !info
.ret
;
10785 if (is_win9x
) ok_sequence( WmEmptySeq
, "WmEmptySeq", FALSE
);
10786 else ok_sequence( WmUser
, "WmUser", FALSE
);
10788 /* timeout is treated as signed despite the prototype (but not on win9x) */
10789 info
.timeout
= 0x7fffffff;
10790 info
.ret
= 0xdeadbeef;
10791 thread
= CreateThread( NULL
, 0, send_msg_thread
, &info
, 0, &tid
);
10793 wait_for_thread( thread
);
10794 CloseHandle( thread
);
10795 ok( info
.ret
== 1, "SendMessageTimeout failed\n" );
10796 ok_sequence( WmUser
, "WmUser", FALSE
);
10798 info
.timeout
= 0x80000000;
10799 info
.ret
= 0xdeadbeef;
10800 thread
= CreateThread( NULL
, 0, send_msg_thread
, &info
, 0, &tid
);
10802 wait_for_thread( thread
);
10803 CloseHandle( thread
);
10806 ok( info
.ret
== 1, "SendMessageTimeout failed\n" );
10807 ok_sequence( WmUser
, "WmUser", FALSE
);
10811 ok( info
.ret
== 0, "SendMessageTimeout succeeded\n" );
10812 ok_sequence( WmEmptySeq
, "WmEmptySeq", FALSE
);
10815 /* now check for timeout during message processing */
10816 SetWindowLongPtrA( info
.hwnd
, GWLP_WNDPROC
, (LONG_PTR
)send_msg_delay_proc
);
10817 info
.timeout
= 100;
10818 info
.ret
= 0xdeadbeef;
10819 thread
= CreateThread( NULL
, 0, send_msg_thread
, &info
, 0, &tid
);
10820 wait_for_thread( thread
);
10821 CloseHandle( thread
);
10822 /* we should time out but still get the message */
10823 ok( info
.ret
== 0, "SendMessageTimeout failed\n" );
10824 ok_sequence( WmUser
, "WmUser", FALSE
);
10826 DestroyWindow( info
.hwnd
);
10830 /****************** edit message test *************************/
10831 #define ID_EDIT 0x1234
10832 static const struct message sl_edit_setfocus
[] =
10834 { HCBT_SETFOCUS
, hook
},
10835 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
10836 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
10837 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
10838 { WM_SETFOCUS
, sent
|wparam
, 0 },
10839 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 10 },
10840 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 15 },
10841 { WM_CTLCOLOREDIT
, sent
|parent
},
10842 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 11 },
10843 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
10844 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
10845 { WM_COMMAND
, sent
|parent
|wparam
, MAKEWPARAM(ID_EDIT
, EN_SETFOCUS
) },
10848 static const struct message sl_edit_invisible
[] =
10850 { HCBT_SETFOCUS
, hook
},
10851 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
10852 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
10853 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
10854 { WM_KILLFOCUS
, sent
|parent
},
10855 { WM_SETFOCUS
, sent
},
10856 { WM_COMMAND
, sent
|parent
|wparam
, MAKEWPARAM(ID_EDIT
, EN_SETFOCUS
) },
10859 static const struct message ml_edit_setfocus
[] =
10861 { HCBT_SETFOCUS
, hook
},
10862 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
10863 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
10864 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
10865 { WM_SETFOCUS
, sent
|wparam
, 0 },
10866 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 10 },
10867 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 11 },
10868 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
10869 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
10870 { WM_COMMAND
, sent
|parent
|wparam
, MAKEWPARAM(ID_EDIT
, EN_SETFOCUS
) },
10873 static const struct message sl_edit_killfocus
[] =
10875 { HCBT_SETFOCUS
, hook
},
10876 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
10877 { WM_KILLFOCUS
, sent
|wparam
, 0 },
10878 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
10879 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
10880 { WM_COMMAND
, sent
|parent
|wparam
, MAKEWPARAM(ID_EDIT
, EN_KILLFOCUS
) },
10881 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
10882 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 1 },
10885 static const struct message sl_edit_lbutton_dblclk
[] =
10887 { WM_LBUTTONDBLCLK
, sent
},
10888 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
10891 static const struct message sl_edit_lbutton_down
[] =
10893 { WM_LBUTTONDOWN
, sent
|wparam
|lparam
, 0, 0 },
10894 { HCBT_SETFOCUS
, hook
},
10895 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
10896 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
10897 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
10898 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
10899 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 10 },
10900 { WM_CTLCOLOREDIT
, sent
|parent
},
10901 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 11 },
10902 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
10903 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
10904 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
10905 { WM_COMMAND
, sent
|parent
|wparam
, MAKEWPARAM(ID_EDIT
, EN_SETFOCUS
) },
10906 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
10907 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
10908 { WM_CTLCOLOREDIT
, sent
|parent
|optional
},
10909 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 11 },
10910 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
10911 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
10914 static const struct message ml_edit_lbutton_down
[] =
10916 { WM_LBUTTONDOWN
, sent
|wparam
|lparam
, 0, 0 },
10917 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
10918 { HCBT_SETFOCUS
, hook
},
10919 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
10920 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
10921 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
10922 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
10923 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 10 },
10924 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 11 },
10925 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
10926 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
10927 { WM_COMMAND
, sent
|parent
|wparam
, MAKEWPARAM(ID_EDIT
, EN_SETFOCUS
) },
10930 static const struct message sl_edit_lbutton_up
[] =
10932 { WM_LBUTTONUP
, sent
|wparam
|lparam
, 0, 0 },
10933 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
10934 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, 0, 0 },
10935 { WM_CAPTURECHANGED
, sent
|defwinproc
},
10936 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
10939 static const struct message ml_edit_lbutton_up
[] =
10941 { WM_LBUTTONUP
, sent
|wparam
|lparam
, 0, 0 },
10942 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, 0, 0 },
10943 { WM_CAPTURECHANGED
, sent
|defwinproc
},
10947 static WNDPROC old_edit_proc
;
10949 static LRESULT CALLBACK
edit_hook_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
10951 static LONG defwndproc_counter
= 0;
10953 struct recvd_message msg
;
10955 if (ignore_message( message
)) return 0;
10958 msg
.message
= message
;
10959 msg
.flags
= sent
|wparam
|lparam
;
10960 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
10961 msg
.wParam
= wParam
;
10962 msg
.lParam
= lParam
;
10963 msg
.descr
= "edit";
10966 defwndproc_counter
++;
10967 ret
= CallWindowProcA(old_edit_proc
, hwnd
, message
, wParam
, lParam
);
10968 defwndproc_counter
--;
10973 static void subclass_edit(void)
10977 if (!GetClassInfoA(0, "edit", &cls
)) assert(0);
10979 old_edit_proc
= cls
.lpfnWndProc
;
10981 cls
.hInstance
= GetModuleHandleA(NULL
);
10982 cls
.lpfnWndProc
= edit_hook_proc
;
10983 cls
.lpszClassName
= "my_edit_class";
10984 UnregisterClassA(cls
.lpszClassName
, cls
.hInstance
);
10985 if (!RegisterClassA(&cls
)) assert(0);
10988 static void test_edit_messages(void)
10994 log_all_parent_messages
++;
10996 parent
= CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
10997 100, 100, 200, 200, 0, 0, 0, NULL
);
10998 ok (parent
!= 0, "Failed to create parent window\n");
11000 /* test single line edit */
11001 hwnd
= CreateWindowExA(0, "my_edit_class", "test", WS_CHILD
,
11002 0, 0, 80, 20, parent
, (HMENU
)ID_EDIT
, 0, NULL
);
11003 ok(hwnd
!= 0, "Failed to create edit window\n");
11005 dlg_code
= SendMessageA(hwnd
, WM_GETDLGCODE
, 0, 0);
11006 ok(dlg_code
== (DLGC_WANTCHARS
|DLGC_HASSETSEL
|DLGC_WANTARROWS
), "wrong dlg_code %08x\n", dlg_code
);
11010 ok_sequence(sl_edit_invisible
, "SetFocus(hwnd) on an invisible edit", FALSE
);
11012 ShowWindow(hwnd
, SW_SHOW
);
11013 UpdateWindow(hwnd
);
11018 ok_sequence(sl_edit_setfocus
, "SetFocus(hwnd) on an edit", FALSE
);
11021 ok_sequence(sl_edit_killfocus
, "SetFocus(0) on an edit", FALSE
);
11027 SendMessageA(hwnd
, WM_LBUTTONDBLCLK
, 0, 0);
11028 ok_sequence(sl_edit_lbutton_dblclk
, "WM_LBUTTONDBLCLK on an edit", FALSE
);
11034 SendMessageA(hwnd
, WM_LBUTTONDOWN
, 0, 0);
11035 ok_sequence(sl_edit_lbutton_down
, "WM_LBUTTONDOWN on an edit", FALSE
);
11037 SendMessageA(hwnd
, WM_LBUTTONUP
, 0, 0);
11038 ok_sequence(sl_edit_lbutton_up
, "WM_LBUTTONUP on an edit", FALSE
);
11040 DestroyWindow(hwnd
);
11042 /* test multiline edit */
11043 hwnd
= CreateWindowExA(0, "my_edit_class", "test", WS_CHILD
| ES_MULTILINE
,
11044 0, 0, 80, 20, parent
, (HMENU
)ID_EDIT
, 0, NULL
);
11045 ok(hwnd
!= 0, "Failed to create edit window\n");
11047 dlg_code
= SendMessageA(hwnd
, WM_GETDLGCODE
, 0, 0);
11048 ok(dlg_code
== (DLGC_WANTCHARS
|DLGC_HASSETSEL
|DLGC_WANTARROWS
|DLGC_WANTALLKEYS
),
11049 "wrong dlg_code %08x\n", dlg_code
);
11051 ShowWindow(hwnd
, SW_SHOW
);
11052 UpdateWindow(hwnd
);
11057 ok_sequence(ml_edit_setfocus
, "SetFocus(hwnd) on multiline edit", FALSE
);
11060 ok_sequence(sl_edit_killfocus
, "SetFocus(0) on multiline edit", FALSE
);
11066 SendMessageA(hwnd
, WM_LBUTTONDBLCLK
, 0, 0);
11067 ok_sequence(sl_edit_lbutton_dblclk
, "WM_LBUTTONDBLCLK on multiline edit", FALSE
);
11073 SendMessageA(hwnd
, WM_LBUTTONDOWN
, 0, 0);
11074 ok_sequence(ml_edit_lbutton_down
, "WM_LBUTTONDOWN on multiline edit", FALSE
);
11076 SendMessageA(hwnd
, WM_LBUTTONUP
, 0, 0);
11077 ok_sequence(ml_edit_lbutton_up
, "WM_LBUTTONUP on multiline edit", FALSE
);
11079 DestroyWindow(hwnd
);
11080 DestroyWindow(parent
);
11082 log_all_parent_messages
--;
11085 /**************************** End of Edit test ******************************/
11087 static const struct message WmKeyDownSkippedSeq
[] =
11089 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 1 }, /* XP */
11092 static const struct message WmKeyDownWasDownSkippedSeq
[] =
11094 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0x40000001 }, /* XP */
11097 static const struct message WmKeyUpSkippedSeq
[] =
11099 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xc0000001 }, /* XP */
11102 static const struct message WmUserKeyUpSkippedSeq
[] =
11105 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xc0000001 }, /* XP */
11110 #define EV_SENDMSG 1
11113 struct peekmsg_info
11116 HANDLE hevent
[3]; /* 0 - start/stop, 1 - SendMessage, 2 - ack */
11119 static DWORD CALLBACK
send_msg_thread_2(void *param
)
11122 struct peekmsg_info
*info
= param
;
11124 trace("thread: looping\n");
11125 SetEvent(info
->hevent
[EV_ACK
]);
11129 ret
= WaitForMultipleObjects(2, info
->hevent
, FALSE
, INFINITE
);
11133 case WAIT_OBJECT_0
+ EV_STOP
:
11134 trace("thread: exiting\n");
11137 case WAIT_OBJECT_0
+ EV_SENDMSG
:
11138 trace("thread: sending message\n");
11139 ret
= SendNotifyMessageA(info
->hwnd
, WM_USER
, 0, 0);
11140 ok(ret
, "SendNotifyMessageA failed error %u\n", GetLastError());
11141 SetEvent(info
->hevent
[EV_ACK
]);
11145 trace("unexpected return: %04x\n", ret
);
11153 static void test_PeekMessage(void)
11157 DWORD tid
, qstatus
;
11158 UINT qs_all_input
= QS_ALLINPUT
;
11159 UINT qs_input
= QS_INPUT
;
11161 struct peekmsg_info info
;
11163 info
.hwnd
= CreateWindowA("TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
11164 100, 100, 200, 200, 0, 0, 0, NULL
);
11166 ShowWindow(info
.hwnd
, SW_SHOW
);
11167 UpdateWindow(info
.hwnd
);
11168 SetFocus(info
.hwnd
);
11170 info
.hevent
[EV_STOP
] = CreateEventA(NULL
, 0, 0, NULL
);
11171 info
.hevent
[EV_SENDMSG
] = CreateEventA(NULL
, 0, 0, NULL
);
11172 info
.hevent
[EV_ACK
] = CreateEventA(NULL
, 0, 0, NULL
);
11174 hthread
= CreateThread(NULL
, 0, send_msg_thread_2
, &info
, 0, &tid
);
11175 WaitForSingleObject(info
.hevent
[EV_ACK
], 10000);
11180 SetLastError(0xdeadbeef);
11181 qstatus
= GetQueueStatus(qs_all_input
);
11182 if (GetLastError() == ERROR_INVALID_FLAGS
)
11184 trace("QS_RAWINPUT not supported on this platform\n");
11185 qs_all_input
&= ~QS_RAWINPUT
;
11186 qs_input
&= ~QS_RAWINPUT
;
11188 if (qstatus
& QS_POSTMESSAGE
)
11190 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) /* nothing */ ;
11191 qstatus
= GetQueueStatus(qs_all_input
);
11193 ok(qstatus
== 0, "wrong qstatus %08x\n", qstatus
);
11195 trace("signalling to send message\n");
11196 SetEvent(info
.hevent
[EV_SENDMSG
]);
11197 WaitForSingleObject(info
.hevent
[EV_ACK
], INFINITE
);
11199 /* pass invalid QS_xxxx flags */
11200 SetLastError(0xdeadbeef);
11201 qstatus
= GetQueueStatus(0xffffffff);
11202 ok(qstatus
== 0 || broken(qstatus
) /* win9x */, "GetQueueStatus should fail: %08x\n", qstatus
);
11205 ok(GetLastError() == ERROR_INVALID_FLAGS
, "wrong error %d\n", GetLastError());
11206 qstatus
= GetQueueStatus(qs_all_input
);
11208 qstatus
&= ~MAKELONG( 0x4000, 0x4000 ); /* sometimes set on Win95 */
11209 ok(qstatus
== MAKELONG(QS_SENDMESSAGE
, QS_SENDMESSAGE
),
11210 "wrong qstatus %08x\n", qstatus
);
11213 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
11215 "PeekMessageA should have returned FALSE instead of msg %04x\n",
11217 ok_sequence(WmUser
, "WmUser", FALSE
);
11219 qstatus
= GetQueueStatus(qs_all_input
);
11220 ok(qstatus
== 0, "wrong qstatus %08x\n", qstatus
);
11222 keybd_event('N', 0, 0, 0);
11223 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
11224 qstatus
= GetQueueStatus(qs_all_input
);
11225 if (!(qstatus
& MAKELONG(QS_KEY
, QS_KEY
)))
11227 skip( "queuing key events not supported\n" );
11230 ok(qstatus
== MAKELONG(QS_KEY
, QS_KEY
) ||
11231 /* keybd_event seems to trigger a sent message on NT4 */
11232 qstatus
== MAKELONG(QS_KEY
|QS_SENDMESSAGE
, QS_KEY
|QS_SENDMESSAGE
),
11233 "wrong qstatus %08x\n", qstatus
);
11235 PostMessageA(info
.hwnd
, WM_CHAR
, 'z', 0);
11236 qstatus
= GetQueueStatus(qs_all_input
);
11237 ok(qstatus
== MAKELONG(QS_POSTMESSAGE
, QS_POSTMESSAGE
|QS_KEY
) ||
11238 qstatus
== MAKELONG(QS_POSTMESSAGE
, QS_POSTMESSAGE
|QS_KEY
|QS_SENDMESSAGE
),
11239 "wrong qstatus %08x\n", qstatus
);
11241 InvalidateRect(info
.hwnd
, NULL
, FALSE
);
11242 qstatus
= GetQueueStatus(qs_all_input
);
11243 ok(qstatus
== MAKELONG(QS_PAINT
, QS_PAINT
|QS_POSTMESSAGE
|QS_KEY
) ||
11244 qstatus
== MAKELONG(QS_PAINT
, QS_PAINT
|QS_POSTMESSAGE
|QS_KEY
|QS_SENDMESSAGE
),
11245 "wrong qstatus %08x\n", qstatus
);
11247 trace("signalling to send message\n");
11248 SetEvent(info
.hevent
[EV_SENDMSG
]);
11249 WaitForSingleObject(info
.hevent
[EV_ACK
], INFINITE
);
11251 qstatus
= GetQueueStatus(qs_all_input
);
11252 ok(qstatus
== MAKELONG(QS_SENDMESSAGE
, QS_SENDMESSAGE
|QS_PAINT
|QS_POSTMESSAGE
|QS_KEY
),
11253 "wrong qstatus %08x\n", qstatus
);
11256 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| (qs_input
<< 16));
11257 if (ret
&& msg
.message
== WM_CHAR
)
11259 win_skip( "PM_QS_* flags not supported in PeekMessage\n" );
11263 "PeekMessageA should have returned FALSE instead of msg %04x\n",
11265 if (!sequence_cnt
) /* nt4 doesn't fetch anything with PM_QS_* flags */
11267 win_skip( "PM_QS_* flags not supported in PeekMessage\n" );
11270 ok_sequence(WmUser
, "WmUser", FALSE
);
11272 qstatus
= GetQueueStatus(qs_all_input
);
11273 ok(qstatus
== MAKELONG(0, QS_PAINT
|QS_POSTMESSAGE
|QS_KEY
),
11274 "wrong qstatus %08x\n", qstatus
);
11276 trace("signalling to send message\n");
11277 SetEvent(info
.hevent
[EV_SENDMSG
]);
11278 WaitForSingleObject(info
.hevent
[EV_ACK
], INFINITE
);
11280 qstatus
= GetQueueStatus(qs_all_input
);
11281 ok(qstatus
== MAKELONG(QS_SENDMESSAGE
, QS_SENDMESSAGE
|QS_PAINT
|QS_POSTMESSAGE
|QS_KEY
),
11282 "wrong qstatus %08x\n", qstatus
);
11285 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| PM_QS_POSTMESSAGE
);
11287 "PeekMessageA should have returned FALSE instead of msg %04x\n",
11289 ok_sequence(WmUser
, "WmUser", FALSE
);
11291 qstatus
= GetQueueStatus(qs_all_input
);
11292 ok(qstatus
== MAKELONG(0, QS_PAINT
|QS_POSTMESSAGE
|QS_KEY
),
11293 "wrong qstatus %08x\n", qstatus
);
11296 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| PM_QS_POSTMESSAGE
);
11297 ok(ret
&& msg
.message
== WM_CHAR
&& msg
.wParam
== 'z',
11298 "got %d and %04x wParam %08lx instead of TRUE and WM_CHAR wParam 'z'\n",
11299 ret
, msg
.message
, msg
.wParam
);
11300 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
11302 qstatus
= GetQueueStatus(qs_all_input
);
11303 ok(qstatus
== MAKELONG(0, QS_PAINT
|QS_KEY
),
11304 "wrong qstatus %08x\n", qstatus
);
11307 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| PM_QS_POSTMESSAGE
);
11309 "PeekMessageA should have returned FALSE instead of msg %04x\n",
11311 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
11313 qstatus
= GetQueueStatus(qs_all_input
);
11314 ok(qstatus
== MAKELONG(0, QS_PAINT
|QS_KEY
),
11315 "wrong qstatus %08x\n", qstatus
);
11318 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| PM_QS_PAINT
);
11319 ok(ret
&& msg
.message
== WM_PAINT
,
11320 "got %d and %04x instead of TRUE and WM_PAINT\n", ret
, msg
.message
);
11321 DispatchMessageA(&msg
);
11322 ok_sequence(WmPaint
, "WmPaint", FALSE
);
11324 qstatus
= GetQueueStatus(qs_all_input
);
11325 ok(qstatus
== MAKELONG(0, QS_KEY
),
11326 "wrong qstatus %08x\n", qstatus
);
11329 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| PM_QS_PAINT
);
11331 "PeekMessageA should have returned FALSE instead of msg %04x\n",
11333 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
11335 qstatus
= GetQueueStatus(qs_all_input
);
11336 ok(qstatus
== MAKELONG(0, QS_KEY
),
11337 "wrong qstatus %08x\n", qstatus
);
11339 trace("signalling to send message\n");
11340 SetEvent(info
.hevent
[EV_SENDMSG
]);
11341 WaitForSingleObject(info
.hevent
[EV_ACK
], INFINITE
);
11343 qstatus
= GetQueueStatus(qs_all_input
);
11344 ok(qstatus
== MAKELONG(QS_SENDMESSAGE
, QS_SENDMESSAGE
|QS_KEY
),
11345 "wrong qstatus %08x\n", qstatus
);
11347 PostMessageA(info
.hwnd
, WM_CHAR
, 'z', 0);
11349 qstatus
= GetQueueStatus(qs_all_input
);
11350 ok(qstatus
== MAKELONG(QS_POSTMESSAGE
, QS_SENDMESSAGE
|QS_POSTMESSAGE
|QS_KEY
),
11351 "wrong qstatus %08x\n", qstatus
);
11354 ret
= PeekMessageA(&msg
, 0, WM_CHAR
, WM_CHAR
, PM_REMOVE
);
11355 ok(ret
&& msg
.message
== WM_CHAR
&& msg
.wParam
== 'z',
11356 "got %d and %04x wParam %08lx instead of TRUE and WM_CHAR wParam 'z'\n",
11357 ret
, msg
.message
, msg
.wParam
);
11358 ok_sequence(WmUser
, "WmUser", FALSE
);
11360 qstatus
= GetQueueStatus(qs_all_input
);
11361 ok(qstatus
== MAKELONG(0, QS_KEY
),
11362 "wrong qstatus %08x\n", qstatus
);
11365 ret
= PeekMessageA(&msg
, 0, WM_CHAR
, WM_CHAR
, PM_REMOVE
);
11367 "PeekMessageA should have returned FALSE instead of msg %04x\n",
11369 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
11371 qstatus
= GetQueueStatus(qs_all_input
);
11372 ok(qstatus
== MAKELONG(0, QS_KEY
),
11373 "wrong qstatus %08x\n", qstatus
);
11375 PostMessageA(info
.hwnd
, WM_CHAR
, 'z', 0);
11377 qstatus
= GetQueueStatus(qs_all_input
);
11378 ok(qstatus
== MAKELONG(QS_POSTMESSAGE
, QS_POSTMESSAGE
|QS_KEY
),
11379 "wrong qstatus %08x\n", qstatus
);
11381 trace("signalling to send message\n");
11382 SetEvent(info
.hevent
[EV_SENDMSG
]);
11383 WaitForSingleObject(info
.hevent
[EV_ACK
], INFINITE
);
11385 qstatus
= GetQueueStatus(qs_all_input
);
11386 ok(qstatus
== MAKELONG(QS_SENDMESSAGE
, QS_SENDMESSAGE
|QS_POSTMESSAGE
|QS_KEY
),
11387 "wrong qstatus %08x\n", qstatus
);
11390 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| (QS_KEY
<< 16));
11392 "PeekMessageA should have returned FALSE instead of msg %04x\n",
11394 ok_sequence(WmUser
, "WmUser", FALSE
);
11396 qstatus
= GetQueueStatus(qs_all_input
);
11397 ok(qstatus
== MAKELONG(0, QS_POSTMESSAGE
|QS_KEY
),
11398 "wrong qstatus %08x\n", qstatus
);
11401 if (qs_all_input
& QS_RAWINPUT
) /* use QS_RAWINPUT only if supported */
11402 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| (QS_RAWINPUT
<< 16));
11403 else /* workaround for a missing QS_RAWINPUT support */
11404 ret
= PeekMessageA(&msg
, 0, WM_KEYDOWN
, WM_KEYDOWN
, PM_REMOVE
);
11405 ok(ret
&& msg
.message
== WM_KEYDOWN
&& msg
.wParam
== 'N',
11406 "got %d and %04x wParam %08lx instead of TRUE and WM_KEYDOWN wParam 'N'\n",
11407 ret
, msg
.message
, msg
.wParam
);
11408 ok_sequence(WmKeyDownSkippedSeq
, "WmKeyDownSkippedSeq", FALSE
);
11410 qstatus
= GetQueueStatus(qs_all_input
);
11411 ok(qstatus
== MAKELONG(0, QS_POSTMESSAGE
|QS_KEY
),
11412 "wrong qstatus %08x\n", qstatus
);
11415 if (qs_all_input
& QS_RAWINPUT
) /* use QS_RAWINPUT only if supported */
11416 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| (QS_RAWINPUT
<< 16));
11417 else /* workaround for a missing QS_RAWINPUT support */
11418 ret
= PeekMessageA(&msg
, 0, WM_KEYUP
, WM_KEYUP
, PM_REMOVE
);
11419 ok(ret
&& msg
.message
== WM_KEYUP
&& msg
.wParam
== 'N',
11420 "got %d and %04x wParam %08lx instead of TRUE and WM_KEYUP wParam 'N'\n",
11421 ret
, msg
.message
, msg
.wParam
);
11422 ok_sequence(WmKeyUpSkippedSeq
, "WmKeyUpSkippedSeq", FALSE
);
11424 qstatus
= GetQueueStatus(qs_all_input
);
11425 ok(qstatus
== MAKELONG(0, QS_POSTMESSAGE
),
11426 "wrong qstatus %08x\n", qstatus
);
11429 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| PM_QS_SENDMESSAGE
);
11431 "PeekMessageA should have returned FALSE instead of msg %04x\n",
11433 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
11435 qstatus
= GetQueueStatus(qs_all_input
);
11436 ok(qstatus
== MAKELONG(0, QS_POSTMESSAGE
),
11437 "wrong qstatus %08x\n", qstatus
);
11440 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
11441 ok(ret
&& msg
.message
== WM_CHAR
&& msg
.wParam
== 'z',
11442 "got %d and %04x wParam %08lx instead of TRUE and WM_CHAR wParam 'z'\n",
11443 ret
, msg
.message
, msg
.wParam
);
11444 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
11446 qstatus
= GetQueueStatus(qs_all_input
);
11448 "wrong qstatus %08x\n", qstatus
);
11451 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
11453 "PeekMessageA should have returned FALSE instead of msg %04x\n",
11455 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
11457 qstatus
= GetQueueStatus(qs_all_input
);
11459 "wrong qstatus %08x\n", qstatus
);
11461 /* test whether presence of the quit flag in the queue affects
11464 PostQuitMessage(0x1234abcd);
11466 qstatus
= GetQueueStatus(qs_all_input
);
11467 ok(qstatus
== MAKELONG(QS_POSTMESSAGE
, QS_POSTMESSAGE
),
11468 "wrong qstatus %08x\n", qstatus
);
11470 PostMessageA(info
.hwnd
, WM_USER
, 0, 0);
11472 qstatus
= GetQueueStatus(qs_all_input
);
11473 ok(qstatus
== MAKELONG(QS_POSTMESSAGE
, QS_POSTMESSAGE
),
11474 "wrong qstatus %08x\n", qstatus
);
11477 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
11478 ok(ret
&& msg
.message
== WM_USER
,
11479 "got %d and %04x instead of TRUE and WM_USER\n", ret
, msg
.message
);
11480 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
11482 qstatus
= GetQueueStatus(qs_all_input
);
11483 ok(qstatus
== MAKELONG(0, QS_POSTMESSAGE
),
11484 "wrong qstatus %08x\n", qstatus
);
11487 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
11488 ok(ret
&& msg
.message
== WM_QUIT
,
11489 "got %d and %04x instead of TRUE and WM_QUIT\n", ret
, msg
.message
);
11490 ok(msg
.wParam
== 0x1234abcd, "got wParam %08lx instead of 0x1234abcd\n", msg
.wParam
);
11491 ok(msg
.lParam
== 0, "got lParam %08lx instead of 0\n", msg
.lParam
);
11492 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
11494 qstatus
= GetQueueStatus(qs_all_input
);
11496 ok(qstatus
== MAKELONG(0, QS_POSTMESSAGE
),
11497 "wrong qstatus %08x\n", qstatus
);
11501 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
11503 "PeekMessageA should have returned FALSE instead of msg %04x\n",
11505 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
11507 qstatus
= GetQueueStatus(qs_all_input
);
11509 "wrong qstatus %08x\n", qstatus
);
11511 /* some GetMessage tests */
11513 keybd_event('N', 0, 0, 0);
11514 qstatus
= GetQueueStatus(qs_all_input
);
11515 ok(qstatus
== MAKELONG(QS_KEY
, QS_KEY
), "wrong qstatus %08x\n", qstatus
);
11517 PostMessageA(info
.hwnd
, WM_CHAR
, 'z', 0);
11518 qstatus
= GetQueueStatus(qs_all_input
);
11519 ok(qstatus
== MAKELONG(QS_POSTMESSAGE
, QS_POSTMESSAGE
|QS_KEY
), "wrong qstatus %08x\n", qstatus
);
11523 ret
= GetMessageA( &msg
, 0, 0, 0 );
11524 ok(ret
&& msg
.message
== WM_CHAR
&& msg
.wParam
== 'z',
11525 "got %d and %04x wParam %08lx instead of TRUE and WM_CHAR wParam 'z'\n",
11526 ret
, msg
.message
, msg
.wParam
);
11527 qstatus
= GetQueueStatus(qs_all_input
);
11528 ok(qstatus
== MAKELONG(0, QS_KEY
), "wrong qstatus %08x\n", qstatus
);
11533 ret
= GetMessageA( &msg
, 0, 0, 0 );
11534 ok(ret
&& msg
.message
== WM_KEYDOWN
&& msg
.wParam
== 'N',
11535 "got %d and %04x wParam %08lx instead of TRUE and WM_KEYDOWN wParam 'N'\n",
11536 ret
, msg
.message
, msg
.wParam
);
11537 ok_sequence(WmKeyDownSkippedSeq
, "WmKeyDownSkippedSeq", FALSE
);
11538 qstatus
= GetQueueStatus(qs_all_input
);
11539 ok(qstatus
== 0, "wrong qstatus %08x\n", qstatus
);
11542 keybd_event('N', 0, 0, 0);
11543 qstatus
= GetQueueStatus(qs_all_input
);
11544 ok(qstatus
== MAKELONG(QS_KEY
, QS_KEY
), "wrong qstatus %08x\n", qstatus
);
11546 PostMessageA(info
.hwnd
, WM_CHAR
, 'z', 0);
11547 qstatus
= GetQueueStatus(qs_all_input
);
11548 ok(qstatus
== MAKELONG(QS_POSTMESSAGE
, QS_POSTMESSAGE
|QS_KEY
), "wrong qstatus %08x\n", qstatus
);
11550 if (qstatus
& (QS_KEY
<< 16))
11552 ret
= GetMessageA( &msg
, 0, WM_KEYDOWN
, WM_KEYUP
);
11553 ok(ret
&& msg
.message
== WM_KEYDOWN
&& msg
.wParam
== 'N',
11554 "got %d and %04x wParam %08lx instead of TRUE and WM_KEYDOWN wParam 'N'\n",
11555 ret
, msg
.message
, msg
.wParam
);
11556 ok_sequence(WmKeyDownWasDownSkippedSeq
, "WmKeyDownWasDownSkippedSeq", FALSE
);
11557 qstatus
= GetQueueStatus(qs_all_input
);
11558 ok(qstatus
== MAKELONG(0, QS_POSTMESSAGE
), "wrong qstatus %08x\n", qstatus
);
11563 ret
= GetMessageA( &msg
, 0, WM_CHAR
, WM_CHAR
);
11564 ok(ret
&& msg
.message
== WM_CHAR
&& msg
.wParam
== 'z',
11565 "got %d and %04x wParam %08lx instead of TRUE and WM_CHAR wParam 'z'\n",
11566 ret
, msg
.message
, msg
.wParam
);
11567 qstatus
= GetQueueStatus(qs_all_input
);
11568 ok(qstatus
== 0, "wrong qstatus %08x\n", qstatus
);
11571 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
11572 qstatus
= GetQueueStatus(qs_all_input
);
11573 ok(qstatus
== MAKELONG(QS_KEY
, QS_KEY
), "wrong qstatus %08x\n", qstatus
);
11575 PostMessageA(info
.hwnd
, WM_CHAR
, 'z', 0);
11576 qstatus
= GetQueueStatus(qs_all_input
);
11577 ok(qstatus
== MAKELONG(QS_POSTMESSAGE
, QS_POSTMESSAGE
|QS_KEY
), "wrong qstatus %08x\n", qstatus
);
11579 trace("signalling to send message\n");
11580 SetEvent(info
.hevent
[EV_SENDMSG
]);
11581 WaitForSingleObject(info
.hevent
[EV_ACK
], INFINITE
);
11582 qstatus
= GetQueueStatus(qs_all_input
);
11583 ok(qstatus
== MAKELONG(QS_SENDMESSAGE
, QS_SENDMESSAGE
|QS_POSTMESSAGE
|QS_KEY
),
11584 "wrong qstatus %08x\n", qstatus
);
11586 if (qstatus
& (QS_KEY
<< 16))
11588 ret
= GetMessageA( &msg
, 0, WM_KEYDOWN
, WM_KEYUP
);
11589 ok(ret
&& msg
.message
== WM_KEYUP
&& msg
.wParam
== 'N',
11590 "got %d and %04x wParam %08lx instead of TRUE and WM_KEYDOWN wParam 'N'\n",
11591 ret
, msg
.message
, msg
.wParam
);
11592 ok_sequence(WmUserKeyUpSkippedSeq
, "WmUserKeyUpSkippedSeq", FALSE
);
11593 qstatus
= GetQueueStatus(qs_all_input
);
11594 ok(qstatus
== MAKELONG(0, QS_POSTMESSAGE
), "wrong qstatus %08x\n", qstatus
);
11599 ret
= GetMessageA( &msg
, 0, WM_CHAR
, WM_CHAR
);
11600 ok(ret
&& msg
.message
== WM_CHAR
&& msg
.wParam
== 'z',
11601 "got %d and %04x wParam %08lx instead of TRUE and WM_CHAR wParam 'z'\n",
11602 ret
, msg
.message
, msg
.wParam
);
11603 qstatus
= GetQueueStatus(qs_all_input
);
11604 ok(qstatus
== 0, "wrong qstatus %08x\n", qstatus
);
11607 trace("signalling to exit\n");
11608 SetEvent(info
.hevent
[EV_STOP
]);
11610 WaitForSingleObject(hthread
, INFINITE
);
11612 CloseHandle(hthread
);
11613 CloseHandle(info
.hevent
[0]);
11614 CloseHandle(info
.hevent
[1]);
11615 CloseHandle(info
.hevent
[2]);
11617 DestroyWindow(info
.hwnd
);
11620 static void wait_move_event(HWND hwnd
, int x
, int y
)
11626 time
= GetTickCount();
11627 while (GetTickCount() - time
< 200) {
11628 ret
= PeekMessageA(&msg
, hwnd
, WM_MOUSEMOVE
, WM_MOUSEMOVE
, PM_NOREMOVE
);
11629 if (ret
&& msg
.pt
.x
> x
&& msg
.pt
.y
> y
) break;
11630 if (!ret
) MsgWaitForMultipleObjects( 0, NULL
, FALSE
, GetTickCount() - time
, QS_ALLINPUT
);
11631 else Sleep( GetTickCount() - time
);
11636 static void test_PeekMessage2(void)
11642 DWORD time1
, time2
, time3
;
11643 int x1
, y1
, x2
, y2
, x3
, y3
;
11646 time1
= time2
= time3
= 0;
11647 x1
= y1
= x2
= y2
= x3
= y3
= 0;
11649 /* Initialise window and make sure it is ready for events */
11650 hwnd
= CreateWindowA("TestWindowClass", "PeekMessage2", WS_OVERLAPPEDWINDOW
,
11651 10, 10, 800, 800, NULL
, NULL
, NULL
, NULL
);
11653 trace("Window for test_PeekMessage2 %p\n", hwnd
);
11654 ShowWindow(hwnd
, SW_SHOW
);
11655 UpdateWindow(hwnd
);
11657 GetCursorPos(&pos
);
11658 SetCursorPos(100, 100);
11659 mouse_event(MOUSEEVENTF_MOVE
, -STEP
, -STEP
, 0, 0);
11662 /* Do initial mousemove, wait until we can see it
11663 and then do our test peek with PM_NOREMOVE. */
11664 mouse_event(MOUSEEVENTF_MOVE
, STEP
, STEP
, 0, 0);
11665 wait_move_event(hwnd
, 100-STEP
, 100-STEP
);
11667 ret
= PeekMessageA(&msg
, hwnd
, WM_MOUSEMOVE
, WM_MOUSEMOVE
, PM_NOREMOVE
);
11670 skip( "queuing mouse events not supported\n" );
11675 trace("1st move event: %04x %x %d %d\n", msg
.message
, msg
.time
, msg
.pt
.x
, msg
.pt
.y
);
11676 message
= msg
.message
;
11680 ok(message
== WM_MOUSEMOVE
, "message not WM_MOUSEMOVE, %04x instead\n", message
);
11683 /* Allow time to advance a bit, and then simulate the user moving their
11684 * mouse around. After that we peek again with PM_NOREMOVE.
11685 * Although the previous mousemove message was never removed, the
11686 * mousemove we now peek should reflect the recent mouse movements
11687 * because the input queue will merge the move events. */
11689 mouse_event(MOUSEEVENTF_MOVE
, STEP
, STEP
, 0, 0);
11690 wait_move_event(hwnd
, x1
, y1
);
11692 ret
= PeekMessageA(&msg
, hwnd
, WM_MOUSEMOVE
, WM_MOUSEMOVE
, PM_NOREMOVE
);
11693 ok(ret
, "no message available\n");
11695 trace("2nd move event: %04x %x %d %d\n", msg
.message
, msg
.time
, msg
.pt
.x
, msg
.pt
.y
);
11696 message
= msg
.message
;
11700 ok(message
== WM_MOUSEMOVE
, "message not WM_MOUSEMOVE, %04x instead\n", message
);
11701 ok(time2
> time1
, "message time not advanced: %x %x\n", time1
, time2
);
11702 ok(x2
!= x1
&& y2
!= y1
, "coords not changed: (%d %d) (%d %d)\n", x1
, y1
, x2
, y2
);
11705 /* Have another go, to drive the point home */
11707 mouse_event(MOUSEEVENTF_MOVE
, STEP
, STEP
, 0, 0);
11708 wait_move_event(hwnd
, x2
, y2
);
11710 ret
= PeekMessageA(&msg
, hwnd
, WM_MOUSEMOVE
, WM_MOUSEMOVE
, PM_NOREMOVE
);
11711 ok(ret
, "no message available\n");
11713 trace("3rd move event: %04x %x %d %d\n", msg
.message
, msg
.time
, msg
.pt
.x
, msg
.pt
.y
);
11714 message
= msg
.message
;
11718 ok(message
== WM_MOUSEMOVE
, "message not WM_MOUSEMOVE, %04x instead\n", message
);
11719 ok(time3
> time2
, "message time not advanced: %x %x\n", time2
, time3
);
11720 ok(x3
!= x2
&& y3
!= y2
, "coords not changed: (%d %d) (%d %d)\n", x2
, y2
, x3
, y3
);
11724 DestroyWindow(hwnd
);
11725 SetCursorPos(pos
.x
, pos
.y
);
11729 static void test_PeekMessage3(void)
11735 hwnd
= CreateWindowA("TestWindowClass", "PeekMessage3", WS_OVERLAPPEDWINDOW
,
11736 10, 10, 800, 800, NULL
, NULL
, NULL
, NULL
);
11737 ok(hwnd
!= NULL
, "expected hwnd != NULL\n");
11740 /* GetMessage() and PeekMessage(..., PM_REMOVE) should prefer messages which
11741 * were already seen. */
11743 SetTimer(hwnd
, 1, 0, NULL
);
11744 while (!PeekMessageA(&msg
, NULL
, 0, 0, PM_NOREMOVE
));
11745 ok(msg
.message
== WM_TIMER
, "msg.message = %u instead of WM_TIMER\n", msg
.message
);
11746 PostMessageA(hwnd
, WM_USER
, 0, 0);
11747 ret
= PeekMessageA(&msg
, NULL
, 0, 0, PM_NOREMOVE
);
11749 ok(ret
&& msg
.message
== WM_TIMER
, "msg.message = %u instead of WM_TIMER\n", msg
.message
);
11750 ret
= GetMessageA(&msg
, NULL
, 0, 0);
11752 ok(ret
&& msg
.message
== WM_TIMER
, "msg.message = %u instead of WM_TIMER\n", msg
.message
);
11753 ret
= GetMessageA(&msg
, NULL
, 0, 0);
11755 ok(ret
&& msg
.message
== WM_USER
, "msg.message = %u instead of WM_USER\n", msg
.message
);
11756 ret
= PeekMessageA(&msg
, NULL
, 0, 0, 0);
11757 ok(!ret
, "expected PeekMessage to return FALSE, got %u\n", ret
);
11759 SetTimer(hwnd
, 1, 0, NULL
);
11760 while (!PeekMessageA(&msg
, NULL
, 0, 0, PM_NOREMOVE
));
11761 ok(msg
.message
== WM_TIMER
, "msg.message = %u instead of WM_TIMER\n", msg
.message
);
11762 PostMessageA(hwnd
, WM_USER
, 0, 0);
11763 ret
= PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
);
11765 ok(ret
&& msg
.message
== WM_TIMER
, "msg.message = %u instead of WM_TIMER\n", msg
.message
);
11766 ret
= PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
);
11768 ok(ret
&& msg
.message
== WM_USER
, "msg.message = %u instead of WM_USER\n", msg
.message
);
11769 ret
= PeekMessageA(&msg
, NULL
, 0, 0, 0);
11770 ok(!ret
, "expected PeekMessage to return FALSE, got %u\n", ret
);
11772 /* It doesn't matter if a message range is specified or not. */
11774 SetTimer(hwnd
, 1, 0, NULL
);
11775 while (!PeekMessageA(&msg
, NULL
, WM_TIMER
, WM_TIMER
, PM_NOREMOVE
));
11776 ok(msg
.message
== WM_TIMER
, "msg.message = %u instead of WM_TIMER\n", msg
.message
);
11777 PostMessageA(hwnd
, WM_USER
, 0, 0);
11778 ret
= GetMessageA(&msg
, NULL
, 0, 0);
11780 ok(ret
&& msg
.message
== WM_TIMER
, "msg.message = %u instead of WM_TIMER\n", msg
.message
);
11781 ret
= GetMessageA(&msg
, NULL
, 0, 0);
11783 ok(ret
&& msg
.message
== WM_USER
, "msg.message = %u instead of WM_USER\n", msg
.message
);
11784 ret
= PeekMessageA(&msg
, NULL
, 0, 0, 0);
11785 ok(!ret
, "expected PeekMessage to return FALSE, got %u\n", ret
);
11787 /* But not if the post messages were added before the PeekMessage() call. */
11789 PostMessageA(hwnd
, WM_USER
, 0, 0);
11790 SetTimer(hwnd
, 1, 0, NULL
);
11791 while (!PeekMessageA(&msg
, NULL
, WM_TIMER
, WM_TIMER
, PM_NOREMOVE
));
11792 ok(msg
.message
== WM_TIMER
, "msg.message = %u instead of WM_TIMER\n", msg
.message
);
11793 ret
= GetMessageA(&msg
, NULL
, 0, 0);
11794 ok(ret
&& msg
.message
== WM_USER
, "msg.message = %u instead of WM_USER\n", msg
.message
);
11795 ret
= GetMessageA(&msg
, NULL
, 0, 0);
11796 ok(ret
&& msg
.message
== WM_TIMER
, "msg.message = %u instead of WM_TIMER\n", msg
.message
);
11797 ret
= PeekMessageA(&msg
, NULL
, 0, 0, 0);
11798 ok(!ret
, "expected PeekMessage to return FALSE, got %u\n", ret
);
11800 /* More complicated test with multiple messages. */
11802 PostMessageA(hwnd
, WM_USER
, 0, 0);
11803 SetTimer(hwnd
, 1, 0, NULL
);
11804 while (!PeekMessageA(&msg
, NULL
, WM_TIMER
, WM_TIMER
, PM_NOREMOVE
));
11805 ok(msg
.message
== WM_TIMER
, "msg.message = %u instead of WM_TIMER\n", msg
.message
);
11806 PostMessageA(hwnd
, WM_USER
+ 1, 0, 0);
11807 ret
= GetMessageA(&msg
, NULL
, 0, 0);
11808 ok(ret
&& msg
.message
== WM_USER
, "msg.message = %u instead of WM_USER\n", msg
.message
);
11809 ret
= GetMessageA(&msg
, NULL
, 0, 0);
11811 ok(ret
&& msg
.message
== WM_TIMER
, "msg.message = %u instead of WM_TIMER\n", msg
.message
);
11812 ret
= GetMessageA(&msg
, NULL
, 0, 0);
11814 ok(ret
&& msg
.message
== WM_USER
+ 1, "msg.message = %u instead of WM_USER + 1\n", msg
.message
);
11815 ret
= PeekMessageA(&msg
, NULL
, 0, 0, 0);
11816 ok(!ret
, "expected PeekMessage to return FALSE, got %u\n", ret
);
11818 /* Also works for posted messages, but the situation is a bit different,
11819 * because both messages are in the same queue. */
11821 PostMessageA(hwnd
, WM_TIMER
, 0, 0);
11822 while (!PeekMessageA(&msg
, NULL
, WM_TIMER
, WM_TIMER
, PM_NOREMOVE
));
11823 ok(msg
.message
== WM_TIMER
, "msg.message = %u instead of WM_TIMER\n", msg
.message
);
11824 PostMessageA(hwnd
, WM_USER
, 0, 0);
11825 ret
= GetMessageA(&msg
, NULL
, 0, 0);
11826 ok(ret
&& msg
.message
== WM_TIMER
, "msg.message = %u instead of WM_TIMER\n", msg
.message
);
11827 ret
= GetMessageA(&msg
, NULL
, 0, 0);
11828 ok(ret
&& msg
.message
== WM_USER
, "msg.message = %u instead of WM_USER\n", msg
.message
);
11829 ret
= PeekMessageA(&msg
, NULL
, 0, 0, 0);
11830 ok(!ret
, "expected PeekMessage to return FALSE, got %u\n", ret
);
11832 PostMessageA(hwnd
, WM_USER
, 0, 0);
11833 PostMessageA(hwnd
, WM_TIMER
, 0, 0);
11834 while (!PeekMessageA(&msg
, NULL
, WM_TIMER
, WM_TIMER
, PM_NOREMOVE
));
11835 ok(msg
.message
== WM_TIMER
, "msg.message = %u instead of WM_TIMER\n", msg
.message
);
11836 ret
= GetMessageA(&msg
, NULL
, 0, 0);
11837 ok(ret
&& msg
.message
== WM_USER
, "msg.message = %u instead of WM_USER\n", msg
.message
);
11838 ret
= GetMessageA(&msg
, NULL
, 0, 0);
11839 ok(ret
&& msg
.message
== WM_TIMER
, "msg.message = %u instead of WM_TIMER\n", msg
.message
);
11840 ret
= PeekMessageA(&msg
, NULL
, 0, 0, 0);
11841 ok(!ret
, "expected PeekMessage to return FALSE, got %u\n", ret
);
11843 DestroyWindow(hwnd
);
11847 static INT_PTR CALLBACK
wm_quit_dlg_proc(HWND hwnd
, UINT message
, WPARAM wp
, LPARAM lp
)
11849 struct recvd_message msg
;
11851 if (ignore_message( message
)) return 0;
11854 msg
.message
= message
;
11855 msg
.flags
= sent
|wparam
|lparam
;
11858 msg
.descr
= "dialog";
11863 case WM_INITDIALOG
:
11864 PostMessageA(hwnd
, WM_QUIT
, 0x1234, 0x5678);
11865 PostMessageA(hwnd
, WM_USER
, 0xdead, 0xbeef);
11868 case WM_GETDLGCODE
:
11872 EndDialog(hwnd
, 0);
11879 static const struct message WmQuitDialogSeq
[] = {
11880 { HCBT_CREATEWND
, hook
},
11881 { WM_SETFONT
, sent
},
11882 { WM_INITDIALOG
, sent
},
11883 { WM_CHANGEUISTATE
, sent
|optional
},
11884 { HCBT_DESTROYWND
, hook
},
11885 { 0x0090, sent
|optional
}, /* Vista */
11886 { WM_DESTROY
, sent
},
11887 { WM_NCDESTROY
, sent
},
11891 static const struct message WmStopQuitSeq
[] = {
11892 { WM_DWMNCRENDERINGCHANGED
, posted
|optional
},
11893 { WM_CLOSE
, posted
},
11894 { WM_QUIT
, posted
|wparam
|lparam
, 0x1234, 0 },
11898 static void test_quit_message(void)
11903 /* test using PostQuitMessage */
11905 PostQuitMessage(0xbeef);
11908 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_QS_SENDMESSAGE
);
11909 ok(!ret
, "got %x message\n", msg
.message
);
11911 ret
= PeekMessageA(&msg
, NULL
, 0, 0, PM_NOREMOVE
);
11912 ok(ret
, "PeekMessage failed with error %d\n", GetLastError());
11913 ok(msg
.message
== WM_QUIT
, "Received message 0x%04x instead of WM_QUIT\n", msg
.message
);
11914 ok(msg
.wParam
== 0xbeef, "wParam was 0x%lx instead of 0xbeef\n", msg
.wParam
);
11916 ret
= PostThreadMessageA(GetCurrentThreadId(), WM_USER
, 0, 0);
11917 ok(ret
, "PostMessage failed with error %d\n", GetLastError());
11919 ret
= GetMessageA(&msg
, NULL
, 0, 0);
11920 ok(ret
> 0, "GetMessage failed with error %d\n", GetLastError());
11921 ok(msg
.message
== WM_USER
, "Received message 0x%04x instead of WM_USER\n", msg
.message
);
11923 /* note: WM_QUIT message received after WM_USER message */
11924 ret
= GetMessageA(&msg
, NULL
, 0, 0);
11925 ok(!ret
, "GetMessage return %d with error %d instead of FALSE\n", ret
, GetLastError());
11926 ok(msg
.message
== WM_QUIT
, "Received message 0x%04x instead of WM_QUIT\n", msg
.message
);
11927 ok(msg
.wParam
== 0xbeef, "wParam was 0x%lx instead of 0xbeef\n", msg
.wParam
);
11929 ret
= PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
);
11930 ok( !ret
|| msg
.message
!= WM_QUIT
, "Received WM_QUIT again\n" );
11932 /* now test with PostThreadMessage - different behaviour! */
11933 PostThreadMessageA(GetCurrentThreadId(), WM_QUIT
, 0xdead, 0);
11935 ret
= PeekMessageA(&msg
, NULL
, 0, 0, PM_NOREMOVE
);
11936 ok(ret
, "PeekMessage failed with error %d\n", GetLastError());
11937 ok(msg
.message
== WM_QUIT
, "Received message 0x%04x instead of WM_QUIT\n", msg
.message
);
11938 ok(msg
.wParam
== 0xdead, "wParam was 0x%lx instead of 0xdead\n", msg
.wParam
);
11940 ret
= PostThreadMessageA(GetCurrentThreadId(), WM_USER
, 0, 0);
11941 ok(ret
, "PostMessage failed with error %d\n", GetLastError());
11943 /* note: we receive the WM_QUIT message first this time */
11944 ret
= GetMessageA(&msg
, NULL
, 0, 0);
11945 ok(!ret
, "GetMessage return %d with error %d instead of FALSE\n", ret
, GetLastError());
11946 ok(msg
.message
== WM_QUIT
, "Received message 0x%04x instead of WM_QUIT\n", msg
.message
);
11947 ok(msg
.wParam
== 0xdead, "wParam was 0x%lx instead of 0xdead\n", msg
.wParam
);
11949 ret
= GetMessageA(&msg
, NULL
, 0, 0);
11950 ok(ret
> 0, "GetMessage failed with error %d\n", GetLastError());
11951 ok(msg
.message
== WM_USER
, "Received message 0x%04x instead of WM_USER\n", msg
.message
);
11955 ret
= DialogBoxParamA(GetModuleHandleA(NULL
), "TEST_EMPTY_DIALOG", 0, wm_quit_dlg_proc
, 0);
11956 ok(ret
== 1, "expected 1, got %d\n", ret
);
11957 ok_sequence(WmQuitDialogSeq
, "WmQuitDialogSeq", FALSE
);
11958 memset(&msg
, 0xab, sizeof(msg
));
11959 ret
= PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
);
11960 ok(ret
, "PeekMessage failed\n");
11961 ok(msg
.message
== WM_QUIT
, "Received message 0x%04x instead of WM_QUIT\n", msg
.message
);
11962 ok(msg
.wParam
== 0x1234, "wParam was 0x%lx instead of 0x1234\n", msg
.wParam
);
11963 ok(msg
.lParam
== 0, "lParam was 0x%lx instead of 0\n", msg
.lParam
);
11965 /* Check what happens to a WM_QUIT message posted to a window that gets
11968 CreateWindowExA(0, "StopQuitClass", "Stop Quit Test", WS_OVERLAPPEDWINDOW
,
11969 0, 0, 100, 100, NULL
, NULL
, NULL
, NULL
);
11971 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
))
11973 struct recvd_message rmsg
;
11974 rmsg
.hwnd
= msg
.hwnd
;
11975 rmsg
.message
= msg
.message
;
11976 rmsg
.flags
= posted
|wparam
|lparam
;
11977 rmsg
.wParam
= msg
.wParam
;
11978 rmsg
.lParam
= msg
.lParam
;
11979 rmsg
.descr
= "stop/quit";
11980 if (msg
.message
== WM_QUIT
)
11981 /* The hwnd can only be checked here */
11982 ok(!msg
.hwnd
, "The WM_QUIT hwnd was %p instead of NULL\n", msg
.hwnd
);
11983 add_message(&rmsg
);
11984 DispatchMessageA(&msg
);
11986 ok_sequence(WmStopQuitSeq
, "WmStopQuitSeq", FALSE
);
11989 static const struct message WmNotifySeq
[] = {
11990 { WM_NOTIFY
, sent
|wparam
|lparam
, 0x1234, 0xdeadbeef },
11994 static void test_notify_message(void)
12000 hwnd
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
12001 CW_USEDEFAULT
, CW_USEDEFAULT
, 300, 300, 0, NULL
, NULL
, 0);
12002 ok(hwnd
!= 0, "Failed to create window\n");
12006 ret
= SendNotifyMessageA(hwnd
, WM_NOTIFY
, 0x1234, 0xdeadbeef);
12007 ok(ret
== TRUE
, "SendNotifyMessageA failed with error %u\n", GetLastError());
12008 ok_sequence(WmNotifySeq
, "WmNotifySeq", FALSE
);
12010 ret
= SendNotifyMessageW(hwnd
, WM_NOTIFY
, 0x1234, 0xdeadbeef);
12011 ok(ret
== TRUE
, "SendNotifyMessageW failed with error %u\n", GetLastError());
12012 ok_sequence(WmNotifySeq
, "WmNotifySeq", FALSE
);
12014 ret
= SendMessageCallbackA(hwnd
, WM_NOTIFY
, 0x1234, 0xdeadbeef, NULL
, 0);
12015 ok(ret
== TRUE
, "SendMessageCallbackA failed with error %u\n", GetLastError());
12016 ok_sequence(WmNotifySeq
, "WmNotifySeq", FALSE
);
12018 ret
= SendMessageCallbackW(hwnd
, WM_NOTIFY
, 0x1234, 0xdeadbeef, NULL
, 0);
12019 ok(ret
== TRUE
, "SendMessageCallbackW failed with error %u\n", GetLastError());
12020 ok_sequence(WmNotifySeq
, "WmNotifySeq", FALSE
);
12022 ret
= PostMessageA(hwnd
, WM_NOTIFY
, 0x1234, 0xdeadbeef);
12023 ok(ret
== TRUE
, "PostMessageA failed with error %u\n", GetLastError());
12025 ok_sequence(WmNotifySeq
, "WmNotifySeq", FALSE
);
12027 ret
= PostMessageW(hwnd
, WM_NOTIFY
, 0x1234, 0xdeadbeef);
12028 ok(ret
== TRUE
, "PostMessageW failed with error %u\n", GetLastError());
12030 ok_sequence(WmNotifySeq
, "WmNotifySeq", FALSE
);
12032 ret
= PostThreadMessageA(GetCurrentThreadId(), WM_NOTIFY
, 0x1234, 0xdeadbeef);
12033 ok(ret
== TRUE
, "PostThreadMessageA failed with error %u\n", GetLastError());
12034 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
))
12037 DispatchMessageA(&msg
);
12039 ok_sequence(WmNotifySeq
, "WmNotifySeq", FALSE
);
12041 ret
= PostThreadMessageW(GetCurrentThreadId(), WM_NOTIFY
, 0x1234, 0xdeadbeef);
12042 ok(ret
== TRUE
, "PostThreadMessageW failed with error %u\n", GetLastError());
12043 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
))
12046 DispatchMessageA(&msg
);
12048 ok_sequence(WmNotifySeq
, "WmNotifySeq", FALSE
);
12050 DestroyWindow(hwnd
);
12053 static const struct message WmMouseHoverSeq
[] = {
12054 { WM_MOUSEACTIVATE
, sent
|optional
}, /* we can get those when moving the mouse in focus-follow-mouse mode under X11 */
12055 { WM_MOUSEACTIVATE
, sent
|optional
},
12056 { WM_TIMER
, sent
|optional
}, /* XP sends it */
12057 { WM_SYSTIMER
, sent
},
12058 { WM_MOUSEHOVER
, sent
|wparam
, 0 },
12062 static void pump_msg_loop_timeout(DWORD timeout
, BOOL inject_mouse_move
)
12065 DWORD start_ticks
, end_ticks
;
12067 start_ticks
= GetTickCount();
12068 /* add some deviation (50%) to cover not expected delays */
12069 start_ticks
+= timeout
/ 2;
12073 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
))
12075 /* Timer proc messages are not dispatched to the window proc,
12076 * and therefore not logged.
12078 if ((msg
.message
== WM_TIMER
|| msg
.message
== WM_SYSTIMER
) && msg
.hwnd
)
12080 struct recvd_message s_msg
;
12082 s_msg
.hwnd
= msg
.hwnd
;
12083 s_msg
.message
= msg
.message
;
12084 s_msg
.flags
= sent
|wparam
|lparam
;
12085 s_msg
.wParam
= msg
.wParam
;
12086 s_msg
.lParam
= msg
.lParam
;
12087 s_msg
.descr
= "msg_loop";
12088 add_message(&s_msg
);
12090 DispatchMessageA(&msg
);
12093 end_ticks
= GetTickCount();
12095 /* inject WM_MOUSEMOVE to see how it changes tracking */
12096 if (inject_mouse_move
&& start_ticks
+ timeout
/ 2 >= end_ticks
)
12098 mouse_event(MOUSEEVENTF_MOVE
, -1, 0, 0, 0);
12099 mouse_event(MOUSEEVENTF_MOVE
, 1, 0, 0, 0);
12101 inject_mouse_move
= FALSE
;
12103 } while (start_ticks
+ timeout
>= end_ticks
);
12106 static void test_TrackMouseEvent(void)
12108 TRACKMOUSEEVENT tme
;
12111 RECT rc_parent
, rc_child
;
12112 UINT default_hover_time
, hover_width
= 0, hover_height
= 0;
12114 #define track_hover(track_hwnd, track_hover_time) \
12115 tme.cbSize = sizeof(tme); \
12116 tme.dwFlags = TME_HOVER; \
12117 tme.hwndTrack = track_hwnd; \
12118 tme.dwHoverTime = track_hover_time; \
12119 SetLastError(0xdeadbeef); \
12120 ret = pTrackMouseEvent(&tme); \
12121 ok(ret, "TrackMouseEvent(TME_HOVER) error %d\n", GetLastError())
12123 #define track_query(expected_track_flags, expected_track_hwnd, expected_hover_time) \
12124 tme.cbSize = sizeof(tme); \
12125 tme.dwFlags = TME_QUERY; \
12126 tme.hwndTrack = (HWND)0xdeadbeef; \
12127 tme.dwHoverTime = 0xdeadbeef; \
12128 SetLastError(0xdeadbeef); \
12129 ret = pTrackMouseEvent(&tme); \
12130 ok(ret, "TrackMouseEvent(TME_QUERY) error %d\n", GetLastError());\
12131 ok(tme.cbSize == sizeof(tme), "wrong tme.cbSize %u\n", tme.cbSize); \
12132 ok(tme.dwFlags == (expected_track_flags), \
12133 "wrong tme.dwFlags %08x, expected %08x\n", tme.dwFlags, (expected_track_flags)); \
12134 ok(tme.hwndTrack == (expected_track_hwnd), \
12135 "wrong tme.hwndTrack %p, expected %p\n", tme.hwndTrack, (expected_track_hwnd)); \
12136 ok(tme.dwHoverTime == (expected_hover_time), \
12137 "wrong tme.dwHoverTime %u, expected %u\n", tme.dwHoverTime, (expected_hover_time))
12139 #define track_hover_cancel(track_hwnd) \
12140 tme.cbSize = sizeof(tme); \
12141 tme.dwFlags = TME_HOVER | TME_CANCEL; \
12142 tme.hwndTrack = track_hwnd; \
12143 tme.dwHoverTime = 0xdeadbeef; \
12144 SetLastError(0xdeadbeef); \
12145 ret = pTrackMouseEvent(&tme); \
12146 ok(ret, "TrackMouseEvent(TME_HOVER | TME_CANCEL) error %d\n", GetLastError())
12148 default_hover_time
= 0xdeadbeef;
12149 SetLastError(0xdeadbeef);
12150 ret
= SystemParametersInfoA(SPI_GETMOUSEHOVERTIME
, 0, &default_hover_time
, 0);
12151 ok(ret
|| broken(GetLastError() == 0xdeadbeef), /* win9x */
12152 "SystemParametersInfo(SPI_GETMOUSEHOVERTIME) error %u\n", GetLastError());
12153 if (!ret
) default_hover_time
= 400;
12154 trace("SPI_GETMOUSEHOVERTIME returned %u ms\n", default_hover_time
);
12156 SetLastError(0xdeadbeef);
12157 ret
= SystemParametersInfoA(SPI_GETMOUSEHOVERWIDTH
, 0, &hover_width
, 0);
12158 ok(ret
|| broken(GetLastError() == 0xdeadbeef), /* win9x */
12159 "SystemParametersInfo(SPI_GETMOUSEHOVERWIDTH) error %u\n", GetLastError());
12160 if (!ret
) hover_width
= 4;
12161 SetLastError(0xdeadbeef);
12162 ret
= SystemParametersInfoA(SPI_GETMOUSEHOVERHEIGHT
, 0, &hover_height
, 0);
12163 ok(ret
|| broken(GetLastError() == 0xdeadbeef), /* win9x */
12164 "SystemParametersInfo(SPI_GETMOUSEHOVERHEIGHT) error %u\n", GetLastError());
12165 if (!ret
) hover_height
= 4;
12166 trace("hover rect is %u x %d\n", hover_width
, hover_height
);
12168 hwnd
= CreateWindowExA(0, "TestWindowClass", NULL
,
12169 WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
12170 CW_USEDEFAULT
, CW_USEDEFAULT
, 300, 300, 0,
12174 hchild
= CreateWindowExA(0, "TestWindowClass", NULL
,
12175 WS_CHILD
| WS_BORDER
| WS_VISIBLE
,
12176 50, 50, 200, 200, hwnd
,
12180 SetWindowPos( hwnd
, HWND_TOPMOST
, 0, 0, 0, 0, SWP_NOSIZE
|SWP_NOMOVE
);
12185 tme
.dwFlags
= TME_QUERY
;
12186 tme
.hwndTrack
= (HWND
)0xdeadbeef;
12187 tme
.dwHoverTime
= 0xdeadbeef;
12188 SetLastError(0xdeadbeef);
12189 ret
= pTrackMouseEvent(&tme
);
12190 ok(!ret
, "TrackMouseEvent should fail\n");
12191 ok(GetLastError() == ERROR_INVALID_PARAMETER
|| broken(GetLastError() == 0xdeadbeef),
12192 "not expected error %u\n", GetLastError());
12194 tme
.cbSize
= sizeof(tme
);
12195 tme
.dwFlags
= TME_HOVER
;
12196 tme
.hwndTrack
= (HWND
)0xdeadbeef;
12197 tme
.dwHoverTime
= 0xdeadbeef;
12198 SetLastError(0xdeadbeef);
12199 ret
= pTrackMouseEvent(&tme
);
12200 ok(!ret
, "TrackMouseEvent should fail\n");
12201 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
|| broken(GetLastError() == 0xdeadbeef),
12202 "not expected error %u\n", GetLastError());
12204 tme
.cbSize
= sizeof(tme
);
12205 tme
.dwFlags
= TME_HOVER
| TME_CANCEL
;
12206 tme
.hwndTrack
= (HWND
)0xdeadbeef;
12207 tme
.dwHoverTime
= 0xdeadbeef;
12208 SetLastError(0xdeadbeef);
12209 ret
= pTrackMouseEvent(&tme
);
12210 ok(!ret
, "TrackMouseEvent should fail\n");
12211 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
|| broken(GetLastError() == 0xdeadbeef),
12212 "not expected error %u\n", GetLastError());
12214 GetWindowRect(hwnd
, &rc_parent
);
12215 GetWindowRect(hchild
, &rc_child
);
12216 SetCursorPos(rc_child
.left
- 10, rc_child
.top
- 10);
12218 /* Process messages so that the system updates its internal current
12219 * window and hittest, otherwise TrackMouseEvent calls don't have any
12225 track_query(0, NULL
, 0);
12226 track_hover(hchild
, 0);
12227 track_query(0, NULL
, 0);
12232 track_hover(hwnd
, 0);
12233 tme
.cbSize
= sizeof(tme
);
12234 tme
.dwFlags
= TME_QUERY
;
12235 tme
.hwndTrack
= (HWND
)0xdeadbeef;
12236 tme
.dwHoverTime
= 0xdeadbeef;
12237 SetLastError(0xdeadbeef);
12238 ret
= pTrackMouseEvent(&tme
);
12239 ok(ret
, "TrackMouseEvent(TME_QUERY) error %d\n", GetLastError());
12240 ok(tme
.cbSize
== sizeof(tme
), "wrong tme.cbSize %u\n", tme
.cbSize
);
12243 skip( "Cursor not inside window, skipping TrackMouseEvent tests\n" );
12244 DestroyWindow( hwnd
);
12247 ok(tme
.dwFlags
== TME_HOVER
, "wrong tme.dwFlags %08x, expected TME_HOVER\n", tme
.dwFlags
);
12248 ok(tme
.hwndTrack
== hwnd
, "wrong tme.hwndTrack %p, expected %p\n", tme
.hwndTrack
, hwnd
);
12249 ok(tme
.dwHoverTime
== default_hover_time
, "wrong tme.dwHoverTime %u, expected %u\n",
12250 tme
.dwHoverTime
, default_hover_time
);
12252 pump_msg_loop_timeout(default_hover_time
, FALSE
);
12253 ok_sequence(WmMouseHoverSeq
, "WmMouseHoverSeq", FALSE
);
12255 track_query(0, NULL
, 0);
12257 track_hover(hwnd
, HOVER_DEFAULT
);
12258 track_query(TME_HOVER
, hwnd
, default_hover_time
);
12260 Sleep(default_hover_time
/ 2);
12261 mouse_event(MOUSEEVENTF_MOVE
, -1, 0, 0, 0);
12262 mouse_event(MOUSEEVENTF_MOVE
, 1, 0, 0, 0);
12264 track_query(TME_HOVER
, hwnd
, default_hover_time
);
12266 pump_msg_loop_timeout(default_hover_time
, FALSE
);
12267 ok_sequence(WmMouseHoverSeq
, "WmMouseHoverSeq", FALSE
);
12269 track_query(0, NULL
, 0);
12271 track_hover(hwnd
, HOVER_DEFAULT
);
12272 track_query(TME_HOVER
, hwnd
, default_hover_time
);
12274 pump_msg_loop_timeout(default_hover_time
, TRUE
);
12275 ok_sequence(WmMouseHoverSeq
, "WmMouseHoverSeq", FALSE
);
12277 track_query(0, NULL
, 0);
12279 track_hover(hwnd
, HOVER_DEFAULT
);
12280 track_query(TME_HOVER
, hwnd
, default_hover_time
);
12281 track_hover_cancel(hwnd
);
12283 DestroyWindow(hwnd
);
12287 #undef track_hover_cancel
12291 static const struct message WmSetWindowRgn
[] = {
12292 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
},
12293 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
12294 { WM_NCPAINT
, sent
|optional
}, /* wparam != 1 */
12295 { WM_GETTEXT
, sent
|defwinproc
|optional
},
12296 { WM_ERASEBKGND
, sent
|optional
},
12297 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
},
12298 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
12302 static const struct message WmSetWindowRgn_no_redraw
[] = {
12303 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
},
12304 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
12305 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
},
12306 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
12310 static const struct message WmSetWindowRgn_clear
[] = {
12311 { WM_WINDOWPOSCHANGING
, sent
/*|wparam*/, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
/*|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE only on some Windows versions */ },
12312 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
12313 { WM_NCPAINT
, sent
|optional
},
12314 { WM_GETTEXT
, sent
|defwinproc
|optional
},
12315 { WM_ERASEBKGND
, sent
|optional
}, /* FIXME: remove optional once Wine is fixed */
12316 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
},
12317 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
12318 { WM_NCPAINT
, sent
|optional
},
12319 { WM_GETTEXT
, sent
|defwinproc
|optional
},
12320 { WM_ERASEBKGND
, sent
|optional
},
12321 { WM_WINDOWPOSCHANGING
, sent
|optional
},
12322 { WM_NCCALCSIZE
, sent
|optional
|wparam
, 1 },
12323 { WM_NCPAINT
, sent
|optional
},
12324 { WM_GETTEXT
, sent
|defwinproc
|optional
},
12325 { WM_ERASEBKGND
, sent
|optional
},
12326 { WM_WINDOWPOSCHANGED
, sent
|optional
|wparam
, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
},
12327 { WM_NCCALCSIZE
, sent
|optional
|wparam
, 1 },
12328 { WM_NCPAINT
, sent
|optional
},
12329 { WM_GETTEXT
, sent
|defwinproc
|optional
},
12330 { WM_ERASEBKGND
, sent
|optional
},
12331 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
12332 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
12336 static void test_SetWindowRgn(void)
12339 HWND hwnd
= CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW
,
12340 100, 100, 200, 200, 0, 0, 0, NULL
);
12341 ok( hwnd
!= 0, "Failed to create overlapped window\n" );
12343 ShowWindow( hwnd
, SW_SHOW
);
12344 UpdateWindow( hwnd
);
12348 trace("testing SetWindowRgn\n");
12349 hrgn
= CreateRectRgn( 0, 0, 150, 150 );
12350 SetWindowRgn( hwnd
, hrgn
, TRUE
);
12351 ok_sequence( WmSetWindowRgn
, "WmSetWindowRgn", FALSE
);
12353 hrgn
= CreateRectRgn( 30, 30, 160, 160 );
12354 SetWindowRgn( hwnd
, hrgn
, FALSE
);
12355 ok_sequence( WmSetWindowRgn_no_redraw
, "WmSetWindowRgn_no_redraw", FALSE
);
12357 hrgn
= CreateRectRgn( 0, 0, 180, 180 );
12358 SetWindowRgn( hwnd
, hrgn
, TRUE
);
12359 ok_sequence( WmSetWindowRgn
, "WmSetWindowRgn2", FALSE
);
12361 SetWindowRgn( hwnd
, 0, TRUE
);
12362 ok_sequence( WmSetWindowRgn_clear
, "WmSetWindowRgn_clear", FALSE
);
12364 DestroyWindow( hwnd
);
12367 /*************************** ShowWindow() test ******************************/
12368 static const struct message WmShowNormal
[] = {
12369 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
12370 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
12371 { HCBT_ACTIVATE
, hook
},
12372 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2003 doesn't send it */
12373 { HCBT_SETFOCUS
, hook
},
12374 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
12377 static const struct message WmShow
[] = {
12378 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
12379 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
12380 { HCBT_ACTIVATE
, hook
|optional
}, /* win2000 doesn't send it */
12381 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2000 doesn't send it */
12382 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 doesn't send it */
12383 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
12386 static const struct message WmShowNoActivate_1
[] = {
12387 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWNOACTIVATE
},
12388 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_STATECHANGED
, 0, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOSIZE
|SWP_NOMOVE
},
12389 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_STATECHANGED
, 0, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOSIZE
|SWP_NOMOVE
},
12390 { WM_MOVE
, sent
|defwinproc
|optional
},
12391 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_RESTORED
},
12394 static const struct message WmShowNoActivate_2
[] = {
12395 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWNOACTIVATE
},
12396 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
, 0, SWP_NOACTIVATE
},
12397 { HCBT_ACTIVATE
, hook
|optional
},
12398 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
12399 { HCBT_SETFOCUS
, hook
|optional
},
12400 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
, 0, SWP_NOACTIVATE
},
12401 { WM_MOVE
, sent
|defwinproc
},
12402 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_RESTORED
},
12403 { HCBT_SETFOCUS
, hook
|optional
},
12404 { HCBT_ACTIVATE
, hook
|optional
}, /* win2003 doesn't send it */
12405 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2003 doesn't send it */
12406 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
12407 { HCBT_SETFOCUS
, hook
|optional
}, /* win2003 doesn't send it */
12410 static const struct message WmShowNA_1
[] = {
12411 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
12412 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
12413 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
12416 static const struct message WmShowNA_2
[] = {
12417 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
12418 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
12419 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
12422 static const struct message WmRestore_1
[] = {
12423 { HCBT_MINMAX
, hook
|lparam
, 0, SW_RESTORE
},
12424 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
12425 { HCBT_ACTIVATE
, hook
|optional
}, /* win2000 doesn't send it */
12426 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2000 doesn't send it */
12427 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 doesn't send it */
12428 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
12429 { WM_MOVE
, sent
|defwinproc
},
12430 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_RESTORED
},
12431 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 sends it */
12434 static const struct message WmRestore_2
[] = {
12435 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
12436 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
12437 { HCBT_ACTIVATE
, hook
|optional
}, /* win2000 doesn't send it */
12438 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2000 doesn't send it */
12439 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 doesn't send it */
12440 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
12443 static const struct message WmRestore_3
[] = {
12444 { HCBT_MINMAX
, hook
|lparam
, 0, SW_RESTORE
},
12445 { WM_GETMINMAXINFO
, sent
},
12446 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
12447 { HCBT_ACTIVATE
, hook
|optional
}, /* win2003 doesn't send it */
12448 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2003 doesn't send it */
12449 { HCBT_SETFOCUS
, hook
|optional
}, /* win2003 doesn't send it */
12450 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
12451 { WM_MOVE
, sent
|defwinproc
},
12452 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_MAXIMIZED
},
12453 { HCBT_SETFOCUS
, hook
|optional
}, /* win2003 sends it */
12456 static const struct message WmRestore_4
[] = {
12457 { HCBT_MINMAX
, hook
|lparam
|optional
, 0, SW_RESTORE
},
12458 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_FRAMECHANGED
|SWP_STATECHANGED
, 0, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOSIZE
|SWP_NOMOVE
},
12459 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_FRAMECHANGED
|SWP_STATECHANGED
, 0, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOSIZE
|SWP_NOMOVE
},
12460 { WM_MOVE
, sent
|defwinproc
|optional
},
12461 { WM_SIZE
, sent
|wparam
|defwinproc
|optional
, SIZE_RESTORED
},
12464 static const struct message WmRestore_5
[] = {
12465 { HCBT_MINMAX
, hook
|lparam
|optional
, 0, SW_SHOWNORMAL
},
12466 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_FRAMECHANGED
|SWP_STATECHANGED
, 0, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOSIZE
|SWP_NOMOVE
},
12467 { HCBT_ACTIVATE
, hook
|optional
},
12468 { HCBT_SETFOCUS
, hook
|optional
},
12469 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_FRAMECHANGED
|SWP_STATECHANGED
, 0, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOSIZE
|SWP_NOMOVE
},
12470 { WM_MOVE
, sent
|defwinproc
|optional
},
12471 { WM_SIZE
, sent
|wparam
|defwinproc
|optional
, SIZE_RESTORED
},
12474 static const struct message WmHide_1
[] = {
12475 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
12476 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
, 0, SWP_NOACTIVATE
},
12477 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
, 0, SWP_NOACTIVATE
},
12478 { HCBT_ACTIVATE
, hook
|optional
},
12479 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 sends it */
12482 static const struct message WmHide_2
[] = {
12483 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
12484 { WM_WINDOWPOSCHANGING
, sent
/*|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE*/ }, /* win2000 doesn't add SWP_NOACTIVATE */
12485 { WM_WINDOWPOSCHANGED
, sent
/*|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE*/ }, /* win2000 doesn't add SWP_NOACTIVATE */
12486 { HCBT_ACTIVATE
, hook
|optional
},
12489 static const struct message WmHide_3
[] = {
12490 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
12491 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
12492 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
12493 { HCBT_SETFOCUS
, hook
|optional
},
12494 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
12497 static const struct message WmShowMinimized_1
[] = {
12498 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINIMIZED
},
12499 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
12500 { HCBT_ACTIVATE
, hook
|optional
}, /* win2000 doesn't send it */
12501 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2000 doesn't send it */
12502 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
12503 { WM_MOVE
, sent
|defwinproc
},
12504 { WM_SIZE
, sent
|wparam
|lparam
|defwinproc
, SIZE_MINIMIZED
, 0 },
12507 static const struct message WmMinimize_1
[] = {
12508 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
12509 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 doesn't send it */
12510 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
12511 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
12512 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
12513 { WM_MOVE
, sent
|defwinproc
},
12514 { WM_SIZE
, sent
|wparam
|lparam
|defwinproc
, SIZE_MINIMIZED
, 0 },
12517 static const struct message WmMinimize_2
[] = {
12518 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
12519 { HCBT_SETFOCUS
, hook
|optional
},
12520 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
, 0, SWP_NOACTIVATE
},
12521 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
, 0, SWP_NOACTIVATE
},
12522 { WM_MOVE
, sent
|defwinproc
},
12523 { WM_SIZE
, sent
|wparam
|lparam
|defwinproc
, SIZE_MINIMIZED
, 0 },
12526 static const struct message WmMinimize_3
[] = {
12527 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
12528 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
, 0, SWP_NOACTIVATE
},
12529 { HCBT_ACTIVATE
, hook
|optional
},
12530 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
12531 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
, 0, SWP_NOACTIVATE
},
12532 { WM_MOVE
, sent
|defwinproc
},
12533 { WM_SIZE
, sent
|wparam
|lparam
|defwinproc
, SIZE_MINIMIZED
, 0 },
12536 static const struct message WmShowMinNoActivate
[] = {
12537 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINNOACTIVE
},
12538 { WM_WINDOWPOSCHANGING
, sent
},
12539 { WM_WINDOWPOSCHANGED
, sent
},
12540 { WM_MOVE
, sent
|defwinproc
|optional
},
12541 { WM_SIZE
, sent
|wparam
|lparam
|defwinproc
|optional
, SIZE_MINIMIZED
, 0 },
12544 static const struct message WmMinMax_1
[] = {
12545 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINIMIZED
},
12548 static const struct message WmMinMax_2
[] = {
12549 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMAXIMIZED
},
12550 { WM_GETMINMAXINFO
, sent
|optional
},
12551 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
12552 { HCBT_ACTIVATE
, hook
|optional
},
12553 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
12554 { HCBT_SETFOCUS
, hook
|optional
},
12555 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_FRAMECHANGED
|SWP_STATECHANGED
, 0, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
12556 { WM_MOVE
, sent
|defwinproc
|optional
},
12557 { WM_SIZE
, sent
|wparam
|defwinproc
|optional
, SIZE_MAXIMIZED
},
12558 { HCBT_SETFOCUS
, hook
|optional
},
12561 static const struct message WmMinMax_3
[] = {
12562 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
12563 { HCBT_SETFOCUS
, hook
|optional
},
12564 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
12565 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
12566 { WM_MOVE
, sent
|defwinproc
|optional
},
12567 { WM_SIZE
, sent
|wparam
|lparam
|defwinproc
|optional
, SIZE_MINIMIZED
, 0 },
12570 static const struct message WmMinMax_4
[] = {
12571 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINNOACTIVE
},
12574 static const struct message WmShowMaximized_1
[] = {
12575 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMAXIMIZED
},
12576 { WM_GETMINMAXINFO
, sent
},
12577 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
12578 { HCBT_ACTIVATE
, hook
|optional
}, /* win2000 doesn't send it */
12579 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2000 doesn't send it */
12580 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 doesn't send it */
12581 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
12582 { WM_MOVE
, sent
|defwinproc
},
12583 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_MAXIMIZED
},
12584 { HCBT_SETFOCUS
, hook
|optional
}, /* win2003 sends it */
12587 static const struct message WmShowMaximized_2
[] = {
12588 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMAXIMIZED
},
12589 { WM_GETMINMAXINFO
, sent
},
12590 { WM_WINDOWPOSCHANGING
, sent
|optional
},
12591 { HCBT_ACTIVATE
, hook
|optional
},
12592 { WM_WINDOWPOSCHANGED
, sent
|optional
},
12593 { WM_MOVE
, sent
|optional
}, /* Win9x doesn't send it */
12594 { WM_SIZE
, sent
|wparam
|optional
, SIZE_MAXIMIZED
}, /* Win9x doesn't send it */
12595 { WM_WINDOWPOSCHANGING
, sent
|optional
},
12596 { HCBT_SETFOCUS
, hook
|optional
},
12597 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
12598 { WM_MOVE
, sent
|defwinproc
},
12599 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_MAXIMIZED
},
12600 { HCBT_SETFOCUS
, hook
|optional
},
12603 static const struct message WmShowMaximized_3
[] = {
12604 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMAXIMIZED
},
12605 { WM_GETMINMAXINFO
, sent
|optional
},
12606 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
, 0, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOSIZE
|SWP_NOMOVE
},
12607 { HCBT_ACTIVATE
, hook
|optional
}, /* win2000 doesn't send it */
12608 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2000 doesn't send it */
12609 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 doesn't send it */
12610 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
, 0, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOSIZE
|SWP_NOMOVE
},
12611 { WM_MOVE
, sent
|defwinproc
|optional
},
12612 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_MAXIMIZED
},
12616 static void test_ShowWindow(void)
12618 /* ShowWindow commands in random order */
12619 static const struct
12621 INT cmd
; /* ShowWindow command */
12622 LPARAM ret
; /* ShowWindow return value */
12623 DWORD style
; /* window style after the command */
12624 const struct message
*msg
; /* message sequence the command produces */
12625 INT wp_cmd
, wp_flags
; /* window placement after the command */
12626 POINT wp_min
, wp_max
; /* window placement after the command */
12627 BOOL todo_msg
; /* message sequence doesn't match what Wine does */
12630 /* 1 */ { SW_SHOWNORMAL
, FALSE
, WS_VISIBLE
, WmShowNormal
,
12631 SW_SHOWNORMAL
, 0, {-1,-1}, {-1,-1}, FALSE
},
12632 /* 2 */ { SW_SHOWNORMAL
, TRUE
, WS_VISIBLE
, WmEmptySeq
,
12633 SW_SHOWNORMAL
, 0, {-1,-1}, {-1,-1}, FALSE
},
12634 /* 3 */ { SW_HIDE
, TRUE
, 0, WmHide_1
,
12635 SW_SHOWNORMAL
, 0, {-1,-1}, {-1,-1}, FALSE
},
12636 /* 4 */ { SW_HIDE
, FALSE
, 0, WmEmptySeq
,
12637 SW_SHOWNORMAL
, 0, {-1,-1}, {-1,-1}, FALSE
},
12638 /* 5 */ { SW_SHOWMINIMIZED
, FALSE
, WS_VISIBLE
|WS_MINIMIZE
, WmShowMinimized_1
,
12639 SW_SHOWMINIMIZED
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
12640 /* 6 */ { SW_SHOWMINIMIZED
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinMax_1
,
12641 SW_SHOWMINIMIZED
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
12642 /* 7 */ { SW_HIDE
, TRUE
, WS_MINIMIZE
, WmHide_1
,
12643 SW_SHOWMINIMIZED
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
12644 /* 8 */ { SW_HIDE
, FALSE
, WS_MINIMIZE
, WmEmptySeq
,
12645 SW_SHOWMINIMIZED
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
12646 /* 9 */ { SW_SHOWMAXIMIZED
, FALSE
, WS_VISIBLE
|WS_MAXIMIZE
, WmShowMaximized_1
,
12647 SW_SHOWMAXIMIZED
, WPF_RESTORETOMAXIMIZED
, {-32000,-32000}, {-1,-1}, FALSE
},
12648 /* 10 */ { SW_SHOWMAXIMIZED
, TRUE
, WS_VISIBLE
|WS_MAXIMIZE
, WmMinMax_2
,
12649 SW_SHOWMAXIMIZED
, WPF_RESTORETOMAXIMIZED
, {-32000,-32000}, {-1,-1}, FALSE
},
12650 /* 11 */ { SW_HIDE
, TRUE
, WS_MAXIMIZE
, WmHide_1
,
12651 SW_SHOWMAXIMIZED
, WPF_RESTORETOMAXIMIZED
, {-32000,-32000}, {-1,-1}, FALSE
},
12652 /* 12 */ { SW_HIDE
, FALSE
, WS_MAXIMIZE
, WmEmptySeq
,
12653 SW_SHOWMAXIMIZED
, WPF_RESTORETOMAXIMIZED
, {-32000,-32000}, {-1,-1}, FALSE
},
12654 /* 13 */ { SW_SHOWNOACTIVATE
, FALSE
, WS_VISIBLE
, WmShowNoActivate_1
,
12655 SW_SHOWNORMAL
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
12656 /* 14 */ { SW_SHOWNOACTIVATE
, TRUE
, WS_VISIBLE
, WmEmptySeq
,
12657 SW_SHOWNORMAL
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
12658 /* 15 */ { SW_HIDE
, TRUE
, 0, WmHide_2
,
12659 SW_SHOWNORMAL
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
12660 /* 16 */ { SW_HIDE
, FALSE
, 0, WmEmptySeq
,
12661 SW_SHOWNORMAL
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
12662 /* 17 */ { SW_SHOW
, FALSE
, WS_VISIBLE
, WmShow
,
12663 SW_SHOWNORMAL
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
12664 /* 18 */ { SW_SHOW
, TRUE
, WS_VISIBLE
, WmEmptySeq
,
12665 SW_SHOWNORMAL
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
12666 /* 19 */ { SW_MINIMIZE
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinimize_1
,
12667 SW_SHOWMINIMIZED
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
12668 /* 20 */ { SW_MINIMIZE
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinMax_3
,
12669 SW_SHOWMINIMIZED
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
12670 /* 21 */ { SW_HIDE
, TRUE
, WS_MINIMIZE
, WmHide_2
,
12671 SW_SHOWMINIMIZED
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
12672 /* 22 */ { SW_SHOWMINNOACTIVE
, FALSE
, WS_VISIBLE
|WS_MINIMIZE
, WmShowMinNoActivate
,
12673 SW_SHOWMINIMIZED
, 0, {-32000,-32000}, {-1,-1}, TRUE
},
12674 /* 23 */ { SW_SHOWMINNOACTIVE
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinMax_4
,
12675 SW_SHOWMINIMIZED
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
12676 /* 24 */ { SW_HIDE
, TRUE
, WS_MINIMIZE
, WmHide_2
,
12677 SW_SHOWMINIMIZED
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
12678 /* 25 */ { SW_HIDE
, FALSE
, WS_MINIMIZE
, WmEmptySeq
,
12679 SW_SHOWMINIMIZED
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
12680 /* 26 */ { SW_SHOWNA
, FALSE
, WS_VISIBLE
|WS_MINIMIZE
, WmShowNA_1
,
12681 SW_SHOWMINIMIZED
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
12682 /* 27 */ { SW_SHOWNA
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmShowNA_2
,
12683 SW_SHOWMINIMIZED
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
12684 /* 28 */ { SW_HIDE
, TRUE
, WS_MINIMIZE
, WmHide_2
,
12685 SW_SHOWMINIMIZED
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
12686 /* 29 */ { SW_HIDE
, FALSE
, WS_MINIMIZE
, WmEmptySeq
,
12687 SW_SHOWMINIMIZED
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
12688 /* 30 */ { SW_RESTORE
, FALSE
, WS_VISIBLE
, WmRestore_1
,
12689 SW_SHOWNORMAL
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
12690 /* 31 */ { SW_RESTORE
, TRUE
, WS_VISIBLE
, WmEmptySeq
,
12691 SW_SHOWNORMAL
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
12692 /* 32 */ { SW_HIDE
, TRUE
, 0, WmHide_3
,
12693 SW_SHOWNORMAL
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
12694 /* 33 */ { SW_HIDE
, FALSE
, 0, WmEmptySeq
,
12695 SW_SHOWNORMAL
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
12696 /* 34 */ { SW_NORMALNA
, FALSE
, 0, WmEmptySeq
, /* what does this mean?! */
12697 SW_SHOWNORMAL
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
12698 /* 35 */ { SW_NORMALNA
, FALSE
, 0, WmEmptySeq
,
12699 SW_SHOWNORMAL
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
12700 /* 36 */ { SW_HIDE
, FALSE
, 0, WmEmptySeq
,
12701 SW_SHOWNORMAL
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
12702 /* 37 */ { SW_RESTORE
, FALSE
, WS_VISIBLE
, WmRestore_2
,
12703 SW_SHOWNORMAL
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
12704 /* 38 */ { SW_RESTORE
, TRUE
, WS_VISIBLE
, WmEmptySeq
,
12705 SW_SHOWNORMAL
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
12706 /* 39 */ { SW_SHOWNOACTIVATE
, TRUE
, WS_VISIBLE
, WmEmptySeq
,
12707 SW_SHOWNORMAL
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
12708 /* 40 */ { SW_MINIMIZE
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinimize_2
,
12709 SW_SHOWMINIMIZED
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
12710 /* 41 */ { SW_MINIMIZE
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinMax_3
,
12711 SW_SHOWMINIMIZED
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
12712 /* 42 */ { SW_SHOWMAXIMIZED
, TRUE
, WS_VISIBLE
|WS_MAXIMIZE
, WmShowMaximized_2
,
12713 SW_SHOWMAXIMIZED
, WPF_RESTORETOMAXIMIZED
, {-32000,-32000}, {-1,-1}, FALSE
},
12714 /* 43 */ { SW_SHOWMAXIMIZED
, TRUE
, WS_VISIBLE
|WS_MAXIMIZE
, WmMinMax_2
,
12715 SW_SHOWMAXIMIZED
, WPF_RESTORETOMAXIMIZED
, {-32000,-32000}, {-1,-1}, FALSE
},
12716 /* 44 */ { SW_MINIMIZE
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinimize_1
,
12717 SW_SHOWMINIMIZED
, WPF_RESTORETOMAXIMIZED
, {-32000,-32000}, {-1,-1}, FALSE
},
12718 /* 45 */ { SW_MINIMIZE
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinMax_3
,
12719 SW_SHOWMINIMIZED
, WPF_RESTORETOMAXIMIZED
, {-32000,-32000}, {-1,-1}, FALSE
},
12720 /* 46 */ { SW_RESTORE
, TRUE
, WS_VISIBLE
|WS_MAXIMIZE
, WmRestore_3
,
12721 SW_SHOWMAXIMIZED
, WPF_RESTORETOMAXIMIZED
, {-32000,-32000}, {-1,-1}, FALSE
},
12722 /* 47 */ { SW_RESTORE
, TRUE
, WS_VISIBLE
, WmRestore_4
,
12723 SW_SHOWNORMAL
, WPF_RESTORETOMAXIMIZED
, {-32000,-32000}, {-1,-1}, FALSE
},
12724 /* 48 */ { SW_SHOWMAXIMIZED
, TRUE
, WS_VISIBLE
|WS_MAXIMIZE
, WmShowMaximized_3
,
12725 SW_SHOWMAXIMIZED
, WPF_RESTORETOMAXIMIZED
, {-32000,-32000}, {-1,-1}, FALSE
},
12726 /* 49 */ { SW_SHOW
, TRUE
, WS_VISIBLE
|WS_MAXIMIZE
, WmEmptySeq
,
12727 SW_SHOWMAXIMIZED
, WPF_RESTORETOMAXIMIZED
, {-32000,-32000}, {-1,-1}, FALSE
},
12728 /* 50 */ { SW_SHOWNORMAL
, TRUE
, WS_VISIBLE
, WmRestore_5
,
12729 SW_SHOWNORMAL
, WPF_RESTORETOMAXIMIZED
, {-32000,-32000}, {-1,-1}, FALSE
},
12730 /* 51 */ { SW_SHOWNORMAL
, TRUE
, WS_VISIBLE
, WmRestore_5
,
12731 SW_SHOWNORMAL
, WPF_RESTORETOMAXIMIZED
, {-32000,-32000}, {-1,-1}, FALSE
},
12732 /* 52 */ { SW_HIDE
, TRUE
, 0, WmHide_1
,
12733 SW_SHOWNORMAL
, WPF_RESTORETOMAXIMIZED
, {-32000,-32000}, {-1,-1}, FALSE
},
12734 /* 53 */ { SW_HIDE
, FALSE
, 0, WmEmptySeq
,
12735 SW_SHOWNORMAL
, WPF_RESTORETOMAXIMIZED
, {-32000,-32000}, {-1,-1}, FALSE
},
12736 /* 54 */ { SW_MINIMIZE
, FALSE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinimize_3
,
12737 SW_SHOWMINIMIZED
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
12738 /* 55 */ { SW_HIDE
, TRUE
, WS_MINIMIZE
, WmHide_2
,
12739 SW_SHOWMINIMIZED
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
12740 /* 56 */ { SW_SHOWNOACTIVATE
, FALSE
, WS_VISIBLE
, WmShowNoActivate_2
,
12741 SW_SHOWNORMAL
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
12742 /* 57 */ { SW_SHOW
, TRUE
, WS_VISIBLE
, WmEmptySeq
,
12743 SW_SHOWNORMAL
, 0, {-32000,-32000}, {-1,-1}, FALSE
}
12749 WINDOWPLACEMENT wp
;
12750 RECT win_rc
, work_rc
= {0, 0, 0, 0};
12752 #define WS_BASE (WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX|WS_MAXIMIZEBOX|WS_POPUP|WS_CLIPSIBLINGS)
12753 hwnd
= CreateWindowExA(0, "ShowWindowClass", NULL
, WS_BASE
,
12758 style
= GetWindowLongA(hwnd
, GWL_STYLE
) & ~WS_BASE
;
12759 ok(style
== 0, "expected style 0, got %08x\n", style
);
12764 if (pGetMonitorInfoA
&& pMonitorFromPoint
)
12770 SetLastError(0xdeadbeef);
12771 hmon
= pMonitorFromPoint(pt
, MONITOR_DEFAULTTOPRIMARY
);
12772 ok(hmon
!= 0, "MonitorFromPoint error %u\n", GetLastError());
12774 mi
.cbSize
= sizeof(mi
);
12775 SetLastError(0xdeadbeef);
12776 ret
= pGetMonitorInfoA(hmon
, &mi
);
12777 ok(ret
, "GetMonitorInfo error %u\n", GetLastError());
12778 trace("monitor %s, work %s\n", wine_dbgstr_rect(&mi
.rcMonitor
),
12779 wine_dbgstr_rect(&mi
.rcWork
));
12780 work_rc
= mi
.rcWork
;
12783 GetWindowRect(hwnd
, &win_rc
);
12784 OffsetRect(&win_rc
, -work_rc
.left
, -work_rc
.top
);
12786 wp
.length
= sizeof(wp
);
12787 SetLastError(0xdeadbeaf);
12788 ret
= GetWindowPlacement(hwnd
, &wp
);
12789 ok(ret
, "GetWindowPlacement error %u\n", GetLastError());
12790 ok(wp
.flags
== 0, "expected 0, got %#x\n", wp
.flags
);
12791 ok(wp
.showCmd
== SW_SHOWNORMAL
, "expected SW_SHOWNORMAL, got %d\n", wp
.showCmd
);
12792 ok(wp
.ptMinPosition
.x
== -1 && wp
.ptMinPosition
.y
== -1,
12793 "expected -1,-1 got %d,%d\n", wp
.ptMinPosition
.x
, wp
.ptMinPosition
.y
);
12794 ok(wp
.ptMaxPosition
.x
== -1 && wp
.ptMaxPosition
.y
== -1,
12795 "expected -1,-1 got %d,%d\n", wp
.ptMaxPosition
.x
, wp
.ptMaxPosition
.y
);
12796 todo_wine_if (work_rc
.left
|| work_rc
.top
) /* FIXME: remove once Wine is fixed */
12797 ok(EqualRect(&win_rc
, &wp
.rcNormalPosition
), "expected %s got %s\n", wine_dbgstr_rect(&win_rc
),
12798 wine_dbgstr_rect(&wp
.rcNormalPosition
));
12800 for (i
= 0; i
< sizeof(sw
)/sizeof(sw
[0]); i
++)
12802 static const char * const sw_cmd_name
[13] =
12804 "SW_HIDE", "SW_SHOWNORMAL", "SW_SHOWMINIMIZED", "SW_SHOWMAXIMIZED",
12805 "SW_SHOWNOACTIVATE", "SW_SHOW", "SW_MINIMIZE", "SW_SHOWMINNOACTIVE",
12806 "SW_SHOWNA", "SW_RESTORE", "SW_SHOWDEFAULT", "SW_FORCEMINIMIZE",
12807 "SW_NORMALNA" /* 0xCC */
12810 INT idx
; /* index into the above array of names */
12812 idx
= (sw
[i
].cmd
== SW_NORMALNA
) ? 12 : sw
[i
].cmd
;
12814 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
12815 trace("%d: sending %s, current window style %08x\n", i
+1, sw_cmd_name
[idx
], style
);
12816 ret
= ShowWindow(hwnd
, sw
[i
].cmd
);
12817 ok(!ret
== !sw
[i
].ret
, "%d: cmd %s: expected ret %lu, got %lu\n", i
+1, sw_cmd_name
[idx
], sw
[i
].ret
, ret
);
12818 style
= GetWindowLongA(hwnd
, GWL_STYLE
) & ~WS_BASE
;
12819 ok(style
== sw
[i
].style
, "%d: expected style %08x, got %08x\n", i
+1, sw
[i
].style
, style
);
12821 sprintf(comment
, "%d: ShowWindow(%s)", i
+1, sw_cmd_name
[idx
]);
12822 ok_sequence(sw
[i
].msg
, comment
, sw
[i
].todo_msg
);
12824 wp
.length
= sizeof(wp
);
12825 SetLastError(0xdeadbeaf);
12826 ret
= GetWindowPlacement(hwnd
, &wp
);
12827 ok(ret
, "GetWindowPlacement error %u\n", GetLastError());
12828 ok(wp
.flags
== sw
[i
].wp_flags
, "expected %#x, got %#x\n", sw
[i
].wp_flags
, wp
.flags
);
12829 ok(wp
.showCmd
== sw
[i
].wp_cmd
, "expected %d, got %d\n", sw
[i
].wp_cmd
, wp
.showCmd
);
12831 /* NT moves the minimized window to -32000,-32000, win9x to 3000,3000 */
12832 if ((wp
.ptMinPosition
.x
+ work_rc
.left
== -32000 && wp
.ptMinPosition
.y
+ work_rc
.top
== -32000) ||
12833 (wp
.ptMinPosition
.x
+ work_rc
.left
== 3000 && wp
.ptMinPosition
.y
+ work_rc
.top
== 3000))
12835 ok((wp
.ptMinPosition
.x
+ work_rc
.left
== sw
[i
].wp_min
.x
&& wp
.ptMinPosition
.y
+ work_rc
.top
== sw
[i
].wp_min
.y
) ||
12836 (wp
.ptMinPosition
.x
+ work_rc
.left
== 3000 && wp
.ptMinPosition
.y
+ work_rc
.top
== 3000),
12837 "expected %d,%d got %d,%d\n", sw
[i
].wp_min
.x
, sw
[i
].wp_min
.y
, wp
.ptMinPosition
.x
, wp
.ptMinPosition
.y
);
12841 ok(wp
.ptMinPosition
.x
== sw
[i
].wp_min
.x
&& wp
.ptMinPosition
.y
== sw
[i
].wp_min
.y
,
12842 "expected %d,%d got %d,%d\n", sw
[i
].wp_min
.x
, sw
[i
].wp_min
.y
, wp
.ptMinPosition
.x
, wp
.ptMinPosition
.y
);
12845 todo_wine_if(wp
.ptMaxPosition
.x
!= sw
[i
].wp_max
.x
|| wp
.ptMaxPosition
.y
!= sw
[i
].wp_max
.y
)
12846 ok(wp
.ptMaxPosition
.x
== sw
[i
].wp_max
.x
&& wp
.ptMaxPosition
.y
== sw
[i
].wp_max
.y
,
12847 "expected %d,%d got %d,%d\n", sw
[i
].wp_max
.x
, sw
[i
].wp_max
.y
, wp
.ptMaxPosition
.x
, wp
.ptMaxPosition
.y
);
12849 if (0) /* FIXME: Wine behaves completely different here */
12850 ok(EqualRect(&win_rc
, &wp
.rcNormalPosition
), "expected %s got %s\n",
12851 wine_dbgstr_rect(&win_rc
), wine_dbgstr_rect(&wp
.rcNormalPosition
));
12853 DestroyWindow(hwnd
);
12857 static INT_PTR WINAPI
test_dlg_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
12859 struct recvd_message msg
;
12861 if (ignore_message( message
)) return 0;
12864 msg
.message
= message
;
12865 msg
.flags
= sent
|wparam
|lparam
;
12866 msg
.wParam
= wParam
;
12867 msg
.lParam
= lParam
;
12868 msg
.descr
= "dialog";
12871 /* calling DefDlgProc leads to a recursion under XP */
12875 case WM_INITDIALOG
:
12876 case WM_GETDLGCODE
:
12882 static WNDPROC orig_edit_proc
;
12883 static LRESULT WINAPI
dlg_creation_edit_proc(HWND hwnd
, UINT message
, WPARAM wp
, LPARAM lp
)
12885 struct recvd_message msg
;
12887 if (ignore_message( message
)) return 0;
12890 msg
.message
= message
;
12891 msg
.flags
= sent
|wparam
|lparam
;
12894 msg
.descr
= "edit";
12897 return CallWindowProcW(orig_edit_proc
, hwnd
, message
, wp
, lp
);
12900 static INT_PTR WINAPI
test_dlg_proc2(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
12902 struct recvd_message msg
;
12904 if (ignore_message( message
)) return 0;
12907 msg
.message
= message
;
12908 msg
.flags
= sent
|wparam
|lparam
|parent
;
12909 msg
.wParam
= wParam
;
12910 msg
.lParam
= lParam
;
12911 msg
.descr
= "dialog";
12914 if (message
== WM_INITDIALOG
)
12916 orig_edit_proc
= (WNDPROC
)SetWindowLongPtrW(GetDlgItem(hwnd
, 200),
12917 GWLP_WNDPROC
, (LONG_PTR
)dlg_creation_edit_proc
);
12923 static INT_PTR WINAPI
test_dlg_proc3(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
12925 ok( 0, "should not be called since DefDlgProc is not used\n" );
12929 static LRESULT WINAPI
test_dlg_proc4(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
12931 struct recvd_message msg
;
12933 if (!ignore_message( message
))
12936 msg
.message
= message
;
12937 msg
.flags
= sent
|wparam
|lparam
|parent
;
12938 msg
.wParam
= wParam
;
12939 msg
.lParam
= lParam
;
12940 msg
.descr
= "dialog";
12943 if (message
== WM_INITDIALOG
)
12945 orig_edit_proc
= (WNDPROC
)SetWindowLongPtrW(GetDlgItem(hwnd
, 200),
12946 GWLP_WNDPROC
, (LONG_PTR
)dlg_creation_edit_proc
);
12949 return DefWindowProcW( hwnd
, message
, wParam
, lParam
);
12952 static const struct message WmDefDlgSetFocus_1
[] = {
12953 { WM_GETDLGCODE
, sent
|wparam
|lparam
, 0, 0 },
12954 { WM_GETTEXTLENGTH
, sent
|wparam
|lparam
|optional
, 0, 0 }, /* XP */
12955 { WM_GETTEXT
, sent
|wparam
|optional
, 6 }, /* XP */
12956 { WM_GETTEXT
, sent
|wparam
|optional
, 12 }, /* XP */
12957 { EM_SETSEL
, sent
|wparam
, 0 }, /* XP sets lparam to text length, Win9x to -2 */
12958 { HCBT_SETFOCUS
, hook
},
12959 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
12960 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
12961 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
12962 { WM_SETFOCUS
, sent
|wparam
, 0 },
12963 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 10 },
12964 { WM_CTLCOLOREDIT
, sent
},
12965 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 11 },
12966 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
12967 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
12968 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
12969 { WM_COMMAND
, sent
|wparam
, MAKEWPARAM(1, EN_SETFOCUS
) },
12972 static const struct message WmDefDlgSetFocus_2
[] = {
12973 { WM_GETDLGCODE
, sent
|wparam
|lparam
, 0, 0 },
12974 { WM_GETTEXTLENGTH
, sent
|wparam
|lparam
|optional
, 0, 0 }, /* XP */
12975 { WM_GETTEXT
, sent
|wparam
|optional
, 6 }, /* XP */
12976 { WM_GETTEXT
, sent
|wparam
|optional
, 12 }, /* XP */
12977 { EM_SETSEL
, sent
|wparam
, 0 }, /* XP sets lparam to text length, Win9x to -2 */
12978 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
12979 { WM_CTLCOLOREDIT
, sent
|optional
}, /* XP */
12980 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
12983 /* Creation of a dialog */
12984 static const struct message WmCreateDialogParamSeq_1
[] = {
12985 { HCBT_CREATEWND
, hook
},
12986 { WM_NCCREATE
, sent
},
12987 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
12988 { WM_CREATE
, sent
},
12989 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
12990 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
12992 { WM_SETFONT
, sent
},
12993 { WM_INITDIALOG
, sent
},
12994 { WM_CHANGEUISTATE
, sent
|optional
},
12997 /* Creation of a dialog */
12998 static const struct message WmCreateDialogParamSeq_2
[] = {
12999 { HCBT_CREATEWND
, hook
},
13000 { WM_NCCREATE
, sent
},
13001 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
13002 { WM_CREATE
, sent
},
13003 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
13004 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
13006 { WM_CHANGEUISTATE
, sent
|optional
},
13010 static const struct message WmCreateDialogParamSeq_3
[] = {
13011 { HCBT_CREATEWND
, hook
},
13012 { WM_SETFONT
, sent
|parent
},
13013 { WM_INITDIALOG
, sent
|parent
},
13014 { WM_GETDLGCODE
, sent
|wparam
|lparam
, 0, 0 },
13015 { EM_SETSEL
, sent
|wparam
|lparam
, 0, INT_MAX
},
13016 { EM_SETSEL
, sent
|wparam
|lparam
|optional
, 0, INT_MAX
},
13017 { EM_SETSEL
, sent
|wparam
|lparam
|optional
, 0, INT_MAX
},
13018 { EM_SETSEL
, sent
|wparam
|lparam
|optional
, 0, INT_MAX
},
13019 { HCBT_ACTIVATE
, hook
},
13020 { WM_QUERYNEWPALETTE
, sent
|parent
|optional
}, /* TODO: this message should not be sent */
13021 { WM_WINDOWPOSCHANGING
, sent
|parent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
13022 { WM_WINDOWPOSCHANGING
, sent
|parent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
13023 { WM_ACTIVATEAPP
, sent
|parent
|wparam
, 1 },
13024 { WM_NCACTIVATE
, sent
|parent
},
13025 { WM_ACTIVATE
, sent
|parent
|wparam
, 1 },
13026 { WM_SETFOCUS
, sent
},
13027 { WM_COMMAND
, sent
|parent
|wparam
, MAKELONG(200, EN_SETFOCUS
) },
13028 { WM_GETDLGCODE
, sent
|wparam
|lparam
, 0, 0 },
13029 { WM_USER
, sent
|parent
},
13030 { WM_CHANGEUISTATE
, sent
|parent
|optional
},
13034 static const struct message WmCreateDialogParamSeq_4
[] = {
13035 { HCBT_CREATEWND
, hook
},
13036 { WM_NCCREATE
, sent
|parent
},
13037 { WM_NCCALCSIZE
, sent
|parent
|wparam
, 0 },
13038 { WM_CREATE
, sent
|parent
},
13039 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
13040 { WM_SIZE
, sent
|parent
|wparam
, SIZE_RESTORED
},
13041 { WM_MOVE
, sent
|parent
},
13042 { WM_SETFONT
, sent
|parent
},
13043 { WM_INITDIALOG
, sent
|parent
},
13044 { WM_GETDLGCODE
, sent
|wparam
|lparam
, 0, 0 },
13045 { EM_SETSEL
, sent
|wparam
|lparam
, 0, INT_MAX
},
13046 { EM_SETSEL
, sent
|wparam
|lparam
|optional
, 0, INT_MAX
},
13047 { EM_SETSEL
, sent
|wparam
|lparam
|optional
, 0, INT_MAX
},
13048 { EM_SETSEL
, sent
|wparam
|lparam
|optional
, 0, INT_MAX
},
13049 { HCBT_ACTIVATE
, hook
},
13050 { WM_QUERYNEWPALETTE
, sent
|parent
|optional
}, /* TODO: this message should not be sent */
13051 { WM_WINDOWPOSCHANGING
, sent
|parent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
13052 { WM_WINDOWPOSCHANGING
, sent
|parent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
13053 { WM_ACTIVATEAPP
, sent
|parent
|wparam
, 1 },
13054 { WM_NCACTIVATE
, sent
|parent
},
13055 { WM_ACTIVATE
, sent
|parent
|wparam
, 1 },
13056 { HCBT_SETFOCUS
, hook
},
13057 { WM_SETFOCUS
, sent
|parent
},
13058 { WM_KILLFOCUS
, sent
|parent
},
13059 { WM_SETFOCUS
, sent
},
13060 { WM_COMMAND
, sent
|parent
|wparam
, MAKELONG(200, EN_SETFOCUS
) },
13061 { WM_GETDLGCODE
, sent
|wparam
|lparam
, 0, 0 },
13062 { WM_USER
, sent
|parent
},
13063 { WM_CHANGEUISTATE
, sent
|parent
|optional
},
13064 { WM_UPDATEUISTATE
, sent
|parent
|optional
},
13065 { WM_UPDATEUISTATE
, sent
|optional
},
13069 static void test_dialog_messages(void)
13072 HWND hdlg
, hedit1
, hedit2
, hfocus
, parent
, child
, child2
;
13075 #define set_selection(hctl, start, end) \
13076 ret = SendMessageA(hctl, EM_SETSEL, start, end); \
13077 ok(ret == 1, "EM_SETSEL returned %ld\n", ret);
13079 #define check_selection(hctl, start, end) \
13080 ret = SendMessageA(hctl, EM_GETSEL, 0, 0); \
13081 ok(ret == MAKELRESULT(start, end), "wrong selection (%d - %d)\n", LOWORD(ret), HIWORD(ret));
13085 hdlg
= CreateWindowExA(WS_EX_DLGMODALFRAME
, "TestDialogClass", NULL
,
13086 WS_VISIBLE
|WS_CAPTION
|WS_SYSMENU
|WS_DLGFRAME
,
13087 0, 0, 100, 100, 0, 0, 0, NULL
);
13088 ok(hdlg
!= 0, "Failed to create custom dialog window\n");
13090 hedit1
= CreateWindowExA(0, "my_edit_class", NULL
,
13091 WS_CHILD
|WS_BORDER
|WS_VISIBLE
|WS_TABSTOP
,
13092 0, 0, 80, 20, hdlg
, (HMENU
)1, 0, NULL
);
13093 ok(hedit1
!= 0, "Failed to create edit control\n");
13094 hedit2
= CreateWindowExA(0, "my_edit_class", NULL
,
13095 WS_CHILD
|WS_BORDER
|WS_VISIBLE
|WS_TABSTOP
,
13096 0, 40, 80, 20, hdlg
, (HMENU
)2, 0, NULL
);
13097 ok(hedit2
!= 0, "Failed to create edit control\n");
13099 SendMessageA(hedit1
, WM_SETTEXT
, 0, (LPARAM
)"hello");
13100 SendMessageA(hedit2
, WM_SETTEXT
, 0, (LPARAM
)"bye");
13102 hfocus
= GetFocus();
13103 ok(hfocus
== hdlg
, "wrong focus %p\n", hfocus
);
13106 hfocus
= GetFocus();
13107 ok(hfocus
== hedit2
, "wrong focus %p\n", hfocus
);
13109 check_selection(hedit1
, 0, 0);
13110 check_selection(hedit2
, 0, 0);
13112 set_selection(hedit2
, 0, -1);
13113 check_selection(hedit2
, 0, 3);
13116 hfocus
= GetFocus();
13117 ok(hfocus
== 0, "wrong focus %p\n", hfocus
);
13120 ret
= DefDlgProcA(hdlg
, WM_SETFOCUS
, 0, 0);
13121 ok(ret
== 0, "WM_SETFOCUS returned %ld\n", ret
);
13122 ok_sequence(WmDefDlgSetFocus_1
, "DefDlgProc(WM_SETFOCUS) 1", FALSE
);
13124 hfocus
= GetFocus();
13125 ok(hfocus
== hedit1
, "wrong focus %p\n", hfocus
);
13127 check_selection(hedit1
, 0, 5);
13128 check_selection(hedit2
, 0, 3);
13131 ret
= DefDlgProcA(hdlg
, WM_SETFOCUS
, 0, 0);
13132 ok(ret
== 0, "WM_SETFOCUS returned %ld\n", ret
);
13133 ok_sequence(WmDefDlgSetFocus_2
, "DefDlgProc(WM_SETFOCUS) 2", FALSE
);
13135 hfocus
= GetFocus();
13136 ok(hfocus
== hedit1
, "wrong focus %p\n", hfocus
);
13138 check_selection(hedit1
, 0, 5);
13139 check_selection(hedit2
, 0, 3);
13141 EndDialog(hdlg
, 0);
13142 DestroyWindow(hedit1
);
13143 DestroyWindow(hedit2
);
13144 DestroyWindow(hdlg
);
13147 #undef set_selection
13148 #undef check_selection
13150 ok(GetClassInfoA(0, "#32770", &cls
), "GetClassInfo failed\n");
13151 cls
.lpszClassName
= "MyDialogClass";
13152 cls
.hInstance
= GetModuleHandleA(NULL
);
13153 /* need a cast since a dlgproc is used as a wndproc */
13154 cls
.lpfnWndProc
= test_dlg_proc
;
13155 if (!RegisterClassA(&cls
)) assert(0);
13157 hdlg
= CreateDialogParamA(0, "CLASS_TEST_DIALOG_2", 0, test_dlg_proc
, 0);
13158 ok(IsWindow(hdlg
), "CreateDialogParam failed\n");
13159 ok_sequence(WmCreateDialogParamSeq_1
, "CreateDialogParam_1", FALSE
);
13160 EndDialog(hdlg
, 0);
13161 DestroyWindow(hdlg
);
13164 hdlg
= CreateDialogParamA(0, "CLASS_TEST_DIALOG_2", 0, NULL
, 0);
13165 ok(IsWindow(hdlg
), "CreateDialogParam failed\n");
13166 ok_sequence(WmCreateDialogParamSeq_2
, "CreateDialogParam_2", FALSE
);
13167 EndDialog(hdlg
, 0);
13168 DestroyWindow(hdlg
);
13171 hdlg
= CreateDialogParamA(0, "FOCUS_TEST_DIALOG_3", 0, test_dlg_proc2
, 0);
13172 ok(IsWindow(hdlg
), "CreateDialogParam failed\n");
13173 ok_sequence(WmCreateDialogParamSeq_3
, "CreateDialogParam_3", TRUE
);
13174 EndDialog(hdlg
, 0);
13175 DestroyWindow(hdlg
);
13178 UnregisterClassA( cls
.lpszClassName
, cls
.hInstance
);
13179 cls
.lpfnWndProc
= test_dlg_proc4
;
13180 ok( RegisterClassA(&cls
), "failed to register class again\n" );
13181 hdlg
= CreateDialogParamA(0, "FOCUS_TEST_DIALOG_4", 0, test_dlg_proc3
, 0);
13182 ok(IsWindow(hdlg
), "CreateDialogParam failed\n");
13183 ok_sequence(WmCreateDialogParamSeq_4
, "CreateDialogParam_4", TRUE
);
13184 EndDialog(hdlg
, 0);
13185 DestroyWindow(hdlg
);
13188 UnregisterClassA(cls
.lpszClassName
, cls
.hInstance
);
13190 parent
= CreateWindowExA(0, "TestParentClass", "Test parent",
13191 WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
13192 100, 100, 200, 200, 0, 0, 0, NULL
);
13193 ok (parent
!= 0, "Failed to create parent window\n");
13195 /* This child has no parent set. We will later call SetParent on it,
13196 * so that it will have a parent set, but no WS_CHILD style. */
13197 child
= CreateWindowExA(0, "TestWindowClass", "Test child",
13198 WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
13199 100, 100, 200, 200, 0, 0, 0, NULL
);
13200 ok (child
!= 0, "Failed to create child window\n");
13202 /* This is a regular child window. When used as an owner, the other
13203 * child window will be used. */
13204 child2
= CreateWindowExA(0, "SimpleWindowClass", "Test child2",
13205 WS_OVERLAPPEDWINDOW
| WS_VISIBLE
| WS_CHILD
,
13206 100, 100, 200, 200, child
, 0, 0, NULL
);
13207 ok (child2
!= 0, "Failed to create child window\n");
13209 SetParent(child
, parent
);
13213 DialogBoxA( 0, "TEST_DIALOG", child2
, TestModalDlgProc2
);
13214 ok_sequence(WmModalDialogSeq_2
, "ModalDialog2", TRUE
);
13216 DestroyWindow(child2
);
13217 DestroyWindow(child
);
13218 DestroyWindow(parent
);
13222 static void test_enddialog_seq(HWND dialog
, HWND owner
)
13224 const struct message seq
[] = {
13225 { WM_ENABLE
, sent
},
13226 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
13227 { HCBT_ACTIVATE
, hook
|wparam
, (WPARAM
)owner
},
13228 { WM_NCACTIVATE
, sent
|wparam
|lparam
, WA_INACTIVE
, (LPARAM
)owner
},
13229 { WM_ACTIVATE
, sent
|wparam
|lparam
, WA_INACTIVE
, (LPARAM
)owner
},
13230 /* FIXME: Following two are optional because Wine sends WM_QUERYNEWPALETTE instead of WM_WINDOWPOSCHANGING */
13231 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
13232 { WM_QUERYNEWPALETTE
, sent
|optional
},
13233 { WM_NCACTIVATE
, sent
|wparam
|lparam
, WA_ACTIVE
, (LPARAM
)dialog
},
13234 { WM_GETTEXT
, sent
|optional
|defwinproc
},
13235 { WM_ACTIVATE
, sent
|wparam
|lparam
, WA_ACTIVE
, (LPARAM
)dialog
},
13236 { HCBT_SETFOCUS
, hook
|wparam
, (WPARAM
)owner
},
13237 { WM_KILLFOCUS
, sent
|wparam
, (WPARAM
)owner
},
13238 { WM_SETFOCUS
, sent
|defwinproc
|wparam
, (WPARAM
)dialog
},
13243 EndDialog(dialog
, 0);
13244 ok_sequence(seq
, "EndDialog", FALSE
);
13247 static void test_enddialog_seq2(HWND dialog
, HWND owner
)
13249 const struct message seq
[] = {
13250 { WM_ENABLE
, parent
|sent
},
13251 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
13252 { HCBT_ACTIVATE
, hook
|wparam
, (WPARAM
)owner
},
13253 { WM_NCACTIVATE
, sent
|wparam
|lparam
, WA_INACTIVE
, (LPARAM
)owner
},
13254 { WM_ACTIVATE
, sent
|wparam
|lparam
, WA_INACTIVE
, (LPARAM
)owner
},
13255 { WM_WINDOWPOSCHANGING
, sent
|optional
|wparam
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
13256 { WM_WINDOWPOSCHANGING
, sent
|optional
|wparam
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
13257 { HCBT_SETFOCUS
, hook
|wparam
, (WPARAM
)owner
},
13258 { WM_KILLFOCUS
, sent
|wparam
, (WPARAM
)owner
},
13259 { WM_SETFOCUS
, sent
|parent
|defwinproc
|wparam
, (WPARAM
)dialog
},
13264 EndDialog(dialog
, 0);
13265 ok_sequence(seq
, "EndDialog2", FALSE
);
13268 static void test_EndDialog(void)
13270 HWND hparent
, hother
, hactive
, hdlg
, hchild
;
13273 hparent
= CreateWindowExA(0, "TestParentClass", "Test parent",
13274 WS_OVERLAPPEDWINDOW
| WS_VISIBLE
| WS_DISABLED
,
13275 100, 100, 200, 200, 0, 0, 0, NULL
);
13276 ok (hparent
!= 0, "Failed to create parent window\n");
13278 hother
= CreateWindowExA(0, "TestParentClass", "Test parent 2",
13279 WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
13280 200, 100, 200, 200, 0, 0, 0, NULL
);
13281 ok (hother
!= 0, "Failed to create parent window\n");
13283 ok(GetClassInfoA(0, "#32770", &cls
), "GetClassInfo failed\n");
13284 cls
.lpszClassName
= "MyDialogClass";
13285 cls
.hInstance
= GetModuleHandleA(NULL
);
13286 cls
.lpfnWndProc
= test_dlg_proc
;
13287 if (!RegisterClassA(&cls
)) assert(0);
13290 SetForegroundWindow(hother
);
13291 hactive
= GetForegroundWindow();
13292 ok(hother
== hactive
, "Wrong window has focus (%p != %p)\n", hother
, hactive
);
13294 /* create a dialog where the parent is disabled, this parent should be
13295 * enabled and receive focus when dialog exits */
13296 hdlg
= CreateDialogParamA(0, "CLASS_TEST_DIALOG_2", hparent
, test_dlg_proc
, 0);
13297 ok(IsWindow(hdlg
), "CreateDialogParam failed\n");
13298 SetForegroundWindow(hdlg
);
13299 hactive
= GetForegroundWindow();
13300 ok(hdlg
== hactive
, "Wrong window has focus (%p != %p)\n", hdlg
, hactive
);
13301 EndDialog(hdlg
, 0);
13302 ok(IsWindowEnabled(hparent
), "parent is not enabled\n");
13303 hactive
= GetForegroundWindow();
13304 ok(hparent
== hactive
, "Wrong window has focus (parent != active) (active: %p, parent: %p, dlg: %p, other: %p)\n", hactive
, hparent
, hdlg
, hother
);
13305 DestroyWindow(hdlg
);
13308 /* create a dialog where the parent is disabled and set active window to other window before calling EndDialog */
13309 EnableWindow(hparent
, FALSE
);
13310 hdlg
= CreateWindowExA(0, "TestDialogClass", NULL
,
13311 WS_VISIBLE
|WS_CAPTION
|WS_SYSMENU
|WS_DLGFRAME
,
13312 0, 0, 100, 100, hparent
, 0, 0, NULL
);
13313 ok(IsWindow(hdlg
), "CreateDialogParam failed\n");
13315 SetForegroundWindow(hother
);
13317 hactive
= GetForegroundWindow();
13318 ok(hactive
== hother
, "Wrong foreground (%p != %p)\n", hactive
, hother
);
13319 hactive
= GetActiveWindow();
13320 ok(hactive
== hother
, "Wrong active window (%p != %p)\n", hactive
, hother
);
13321 EndDialog(hdlg
, 0);
13322 ok(IsWindowEnabled(hparent
), "parent is not enabled\n");
13323 hactive
= GetForegroundWindow();
13324 ok(hother
== hactive
, "Wrong window has focus (other != active) (active: %p, parent: %p, dlg: %p, other: %p)\n", hactive
, hparent
, hdlg
, hother
);
13325 DestroyWindow(hdlg
);
13328 DestroyWindow( hparent
);
13330 hparent
= CreateWindowExA(0, "TestParentClass", "Test parent",
13331 WS_POPUP
| WS_VISIBLE
| WS_DISABLED
,
13332 100, 100, 200, 200, 0, 0, 0, NULL
);
13333 ok (hparent
!= 0, "Failed to create parent window\n");
13335 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child",
13336 WS_OVERLAPPEDWINDOW
| WS_VISIBLE
| WS_DISABLED
,
13337 0, 0, 0, 0, 0, 0, 0, NULL
);
13338 ok (hchild
!= 0, "Failed to create child window\n");
13340 SetParent(hchild
, hparent
);
13343 SetForegroundWindow(hother
);
13344 hactive
= GetForegroundWindow();
13345 ok(hother
== hactive
, "Wrong foreground window (%p != %p)\n", hother
, hactive
);
13347 hdlg
= CreateDialogParamA(0, "CLASS_TEST_DIALOG_2", hchild
, test_dlg_proc
, 0);
13348 ok(IsWindow(hdlg
), "CreateDialogParam failed\n");
13350 SetForegroundWindow(hdlg
);
13351 test_enddialog_seq(hdlg
, hchild
);
13353 hactive
= GetForegroundWindow();
13354 ok(hactive
== hchild
, "Wrong foreground window (active: %p, parent: %p, dlg: %p, other: %p child: %p)\n", hactive
, hparent
, hdlg
, hother
, hchild
);
13356 DestroyWindow(hdlg
);
13358 /* Now set WS_CHILD style flag so that it's a real child and its parent will be dialog's owner. */
13359 SetWindowLongW(hchild
, GWL_STYLE
, GetWindowLongW(hchild
, GWL_STYLE
) | WS_CHILD
);
13361 SetForegroundWindow(hother
);
13362 hactive
= GetForegroundWindow();
13363 ok(hother
== hactive
, "Wrong foreground window (%p != %p)\n", hother
, hactive
);
13365 hdlg
= CreateDialogParamA(0, "CLASS_TEST_DIALOG_2", hchild
, test_dlg_proc
, 0);
13366 ok(IsWindow(hdlg
), "CreateDialogParam failed\n");
13368 SetForegroundWindow(hdlg
);
13369 test_enddialog_seq2(hdlg
, hparent
);
13371 hactive
= GetForegroundWindow();
13372 ok(hactive
== hparent
, "Wrong foreground window (active: %p, parent: %p, dlg: %p, other: %p child: %p)\n", hactive
, hparent
, hdlg
, hother
, hchild
);
13373 DestroyWindow(hdlg
);
13374 DestroyWindow(hchild
);
13375 DestroyWindow(hparent
);
13376 DestroyWindow(hother
);
13379 UnregisterClassA(cls
.lpszClassName
, cls
.hInstance
);
13382 static void test_nullCallback(void)
13386 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW
,
13387 100, 100, 200, 200, 0, 0, 0, NULL
);
13388 ok (hwnd
!= 0, "Failed to create overlapped window\n");
13390 SendMessageCallbackA(hwnd
,WM_NULL
,0,0,NULL
,0);
13392 DestroyWindow(hwnd
);
13395 /* SetActiveWindow( 0 ) hwnd visible */
13396 static const struct message SetActiveWindowSeq0
[] =
13398 { HCBT_ACTIVATE
, hook
|optional
},
13399 { WM_NCACTIVATE
, sent
|wparam
, 0 },
13400 { WM_GETTEXT
, sent
|defwinproc
|optional
},
13401 { WM_ACTIVATE
, sent
|wparam
, 0 },
13402 { WM_ACTIVATEAPP
, sent
|wparam
|optional
, 0 },
13403 { WM_ACTIVATEAPP
, sent
|wparam
|optional
, 0 },
13404 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
13405 { WM_KILLFOCUS
, sent
|optional
},
13406 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
13407 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
13408 { WM_NCACTIVATE
, sent
|wparam
|optional
, 1 },
13409 { WM_GETTEXT
, sent
|defwinproc
|optional
},
13410 { WM_ACTIVATE
, sent
|wparam
|optional
, 1 },
13411 { HCBT_SETFOCUS
, hook
|optional
},
13412 { WM_KILLFOCUS
, sent
|defwinproc
|optional
},
13413 { WM_IME_SETCONTEXT
, sent
|defwinproc
|optional
},
13414 { WM_IME_SETCONTEXT
, sent
|defwinproc
|optional
},
13415 { WM_IME_SETCONTEXT
, sent
|optional
},
13416 { WM_IME_SETCONTEXT
, sent
|optional
},
13417 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 1 },
13418 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
13419 { WM_SETFOCUS
, sent
|defwinproc
|optional
},
13420 { WM_GETTEXT
, sent
|optional
},
13423 /* SetActiveWindow( hwnd ) hwnd visible */
13424 static const struct message SetActiveWindowSeq1
[] =
13426 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
13429 /* SetActiveWindow( popup ) hwnd visible, popup visible */
13430 static const struct message SetActiveWindowSeq2
[] =
13432 { HCBT_ACTIVATE
, hook
},
13433 { WM_NCACTIVATE
, sent
|wparam
, 0 },
13434 { WM_GETTEXT
, sent
|defwinproc
|optional
},
13435 { WM_ACTIVATE
, sent
|wparam
, 0 },
13436 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
13437 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
13438 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
13439 { WM_NCPAINT
, sent
|optional
},
13440 { WM_GETTEXT
, sent
|defwinproc
|optional
},
13441 { WM_ERASEBKGND
, sent
|optional
},
13442 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
13443 { WM_NCACTIVATE
, sent
|wparam
, 1 },
13444 { WM_GETTEXT
, sent
|defwinproc
|optional
},
13445 { WM_ACTIVATE
, sent
|wparam
, 1 },
13446 { HCBT_SETFOCUS
, hook
},
13447 { WM_KILLFOCUS
, sent
|defwinproc
},
13448 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 0 },
13449 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
13450 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 1 },
13451 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
13452 { WM_SETFOCUS
, sent
|defwinproc
},
13453 { WM_GETTEXT
, sent
|optional
},
13457 /* SetActiveWindow( hwnd ) hwnd not visible */
13458 static const struct message SetActiveWindowSeq3
[] =
13460 { HCBT_ACTIVATE
, hook
},
13461 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
13462 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
13463 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
},
13464 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOACTIVATE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
13465 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
13466 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
13467 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
13468 { WM_NCACTIVATE
, sent
|wparam
, 1 },
13469 { WM_ACTIVATE
, sent
|wparam
, 1 },
13470 { HCBT_SETFOCUS
, hook
},
13471 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
13472 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
13473 { WM_SETFOCUS
, sent
|defwinproc
},
13476 /* SetActiveWindow( popup ) hwnd not visible, popup not visible */
13477 static const struct message SetActiveWindowSeq4
[] =
13479 { HCBT_ACTIVATE
, hook
},
13480 { WM_NCACTIVATE
, sent
|wparam
, 0 },
13481 { WM_GETTEXT
, sent
|defwinproc
|optional
},
13482 { WM_ACTIVATE
, sent
|wparam
, 0 },
13483 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
13484 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
},
13485 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
13486 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
13487 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
13488 { WM_NCACTIVATE
, sent
|wparam
, 1 },
13489 { WM_GETTEXT
, sent
|defwinproc
|optional
},
13490 { WM_ACTIVATE
, sent
|wparam
, 1 },
13491 { HCBT_SETFOCUS
, hook
},
13492 { WM_KILLFOCUS
, sent
|defwinproc
},
13493 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 0 },
13494 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
13495 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 1 },
13496 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
13497 { WM_SETFOCUS
, sent
|defwinproc
},
13502 static void test_SetActiveWindow(void)
13504 HWND hwnd
, popup
, ret
;
13506 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test SetActiveWindow",
13507 WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
13508 100, 100, 200, 200, 0, 0, 0, NULL
);
13510 popup
= CreateWindowExA(0, "TestWindowClass", "Test SetActiveWindow",
13511 WS_OVERLAPPEDWINDOW
| WS_VISIBLE
| WS_POPUP
,
13512 100, 100, 200, 200, hwnd
, 0, 0, NULL
);
13514 ok(hwnd
!= 0, "Failed to create overlapped window\n");
13515 ok(popup
!= 0, "Failed to create popup window\n");
13516 SetForegroundWindow( popup
);
13519 trace("SetActiveWindow(0)\n");
13520 ret
= SetActiveWindow(0);
13521 ok( ret
== popup
, "Failed to SetActiveWindow(0)\n");
13522 ok_sequence(SetActiveWindowSeq0
, "SetActiveWindow(0)", FALSE
);
13525 trace("SetActiveWindow(hwnd), hwnd visible\n");
13526 ret
= SetActiveWindow(hwnd
);
13527 if (ret
== hwnd
) ok_sequence(SetActiveWindowSeq1
, "SetActiveWindow(hwnd), hwnd visible", TRUE
);
13530 trace("SetActiveWindow(popup), hwnd visible, popup visible\n");
13531 ret
= SetActiveWindow(popup
);
13532 ok( ret
== hwnd
, "Failed to SetActiveWindow(popup), popup visible\n");
13533 ok_sequence(SetActiveWindowSeq2
, "SetActiveWindow(popup), hwnd visible, popup visible", FALSE
);
13536 ShowWindow(hwnd
, SW_HIDE
);
13537 ShowWindow(popup
, SW_HIDE
);
13540 trace("SetActiveWindow(hwnd), hwnd not visible\n");
13541 ret
= SetActiveWindow(hwnd
);
13542 ok( ret
== NULL
, "SetActiveWindow(hwnd), hwnd not visible, previous is %p\n", ret
);
13543 ok_sequence(SetActiveWindowSeq3
, "SetActiveWindow(hwnd), hwnd not visible", TRUE
);
13546 trace("SetActiveWindow(popup), hwnd not visible, popup not visible\n");
13547 ret
= SetActiveWindow(popup
);
13548 ok( ret
== hwnd
, "Failed to SetActiveWindow(popup)\n");
13549 ok_sequence(SetActiveWindowSeq4
, "SetActiveWindow(popup), hwnd not visible, popup not visible", TRUE
);
13554 DestroyWindow(hwnd
);
13557 static const struct message SetForegroundWindowSeq
[] =
13559 { WM_NCACTIVATE
, sent
|wparam
, 0 },
13560 { WM_GETTEXT
, sent
|defwinproc
|optional
},
13561 { WM_ACTIVATE
, sent
|wparam
, 0 },
13562 { WM_ACTIVATEAPP
, sent
|wparam
, 0 },
13563 { WM_KILLFOCUS
, sent
},
13564 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
13565 { WM_IME_NOTIFY
, sent
|wparam
|optional
|defwinproc
, 1 },
13569 static void test_SetForegroundWindow(void)
13573 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test SetForegroundWindow",
13574 WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
13575 100, 100, 200, 200, 0, 0, 0, NULL
);
13576 ok (hwnd
!= 0, "Failed to create overlapped window\n");
13577 SetForegroundWindow( hwnd
);
13580 trace("SetForegroundWindow( 0 )\n");
13581 SetForegroundWindow( 0 );
13582 ok_sequence(WmEmptySeq
, "SetForegroundWindow( 0 ) away from foreground top level window", FALSE
);
13583 trace("SetForegroundWindow( GetDesktopWindow() )\n");
13584 SetForegroundWindow( GetDesktopWindow() );
13585 ok_sequence(SetForegroundWindowSeq
, "SetForegroundWindow( desktop ) away from "
13586 "foreground top level window", FALSE
);
13589 DestroyWindow(hwnd
);
13592 static DWORD
get_input_codepage( void )
13596 HKL hkl
= GetKeyboardLayout( 0 );
13598 ret
= GetLocaleInfoW( LOWORD(hkl
), LOCALE_IDEFAULTANSICODEPAGE
| LOCALE_RETURN_NUMBER
,
13599 (WCHAR
*)&cp
, sizeof(cp
) / sizeof(WCHAR
) );
13600 if (!ret
) cp
= CP_ACP
;
13604 static void test_dbcs_wm_char(void)
13607 WCHAR wch
, bad_wch
;
13615 struct message wmCharSeq
[2];
13617 DWORD cp
= get_input_codepage();
13619 if (!pGetCPInfoExA
)
13621 win_skip("GetCPInfoExA is not available\n");
13625 pGetCPInfoExA( cp
, 0, &cpinfo
);
13626 if (cpinfo
.MaxCharSize
!= 2)
13628 skip( "Skipping DBCS WM_CHAR test in SBCS codepage '%s'\n", cpinfo
.CodePageName
);
13632 dbch
[0] = dbch
[1] = 0;
13634 bad_wch
= cpinfo
.UnicodeDefaultChar
;
13635 for (i
= 0; !wch
&& i
< MAX_LEADBYTES
&& cpinfo
.LeadByte
[i
]; i
+= 2)
13636 for (j
= cpinfo
.LeadByte
[i
]; !wch
&& j
<= cpinfo
.LeadByte
[i
+1]; j
++)
13637 for (k
= 128; k
<= 255; k
++)
13643 if (MultiByteToWideChar( cp
, 0, str
, 2, wstr
, 2 ) == 1 &&
13644 WideCharToMultiByte( cp
, 0, wstr
, 1, str
, 2, NULL
, NULL
) == 2 &&
13645 (BYTE
)str
[0] == j
&& (BYTE
)str
[1] == k
&&
13646 HIBYTE(wstr
[0]) && HIBYTE(wstr
[0]) != 0xff)
13657 skip( "Skipping DBCS WM_CHAR test, no appropriate char found\n" );
13660 trace( "using dbcs char %02x,%02x wchar %04x bad wchar %04x codepage '%s'\n",
13661 dbch
[0], dbch
[1], wch
, bad_wch
, cpinfo
.CodePageName
);
13663 hwnd
= CreateWindowExW(0, testWindowClassW
, NULL
,
13664 WS_OVERLAPPEDWINDOW
, 100, 100, 200, 200, 0, 0, 0, NULL
);
13665 hwnd2
= CreateWindowExW(0, testWindowClassW
, NULL
,
13666 WS_OVERLAPPEDWINDOW
, 100, 100, 200, 200, 0, 0, 0, NULL
);
13667 ok (hwnd
!= 0, "Failed to create overlapped window\n");
13668 ok (hwnd2
!= 0, "Failed to create overlapped window\n");
13671 memset( wmCharSeq
, 0, sizeof(wmCharSeq
) );
13672 wmCharSeq
[0].message
= WM_CHAR
;
13673 wmCharSeq
[0].flags
= sent
|wparam
;
13674 wmCharSeq
[0].wParam
= wch
;
13676 /* posted message */
13677 PostMessageA( hwnd
, WM_CHAR
, dbch
[0], 0 );
13678 ret
= PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
);
13679 ok( !ret
, "got message %x\n", msg
.message
);
13680 PostMessageA( hwnd
, WM_CHAR
, dbch
[1], 0 );
13681 ret
= PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
);
13682 ok( ret
, "no message\n" );
13683 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
13684 ok( msg
.wParam
== wch
, "bad wparam %lx/%x\n", msg
.wParam
, wch
);
13685 ret
= PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
);
13686 ok( !ret
, "got message %x\n", msg
.message
);
13688 /* posted thread message */
13689 PostThreadMessageA( GetCurrentThreadId(), WM_CHAR
, dbch
[0], 0 );
13690 ret
= PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
);
13691 ok( !ret
, "got message %x\n", msg
.message
);
13692 PostMessageA( hwnd
, WM_CHAR
, dbch
[1], 0 );
13693 ret
= PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
);
13694 ok( ret
, "no message\n" );
13695 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
13696 ok( msg
.wParam
== wch
, "bad wparam %lx/%x\n", msg
.wParam
, wch
);
13697 ret
= PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
);
13698 ok( !ret
, "got message %x\n", msg
.message
);
13702 SendMessageA( hwnd
, WM_CHAR
, dbch
[0], 0 );
13703 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
13704 SendMessageA( hwnd
, WM_CHAR
, dbch
[1], 0 );
13705 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
13706 ret
= PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
);
13707 ok( !ret
, "got message %x\n", msg
.message
);
13709 /* sent message with timeout */
13711 SendMessageTimeoutA( hwnd
, WM_CHAR
, dbch
[0], 0, SMTO_NORMAL
, 0, &res
);
13712 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
13713 SendMessageTimeoutA( hwnd
, WM_CHAR
, dbch
[1], 0, SMTO_NORMAL
, 0, &res
);
13714 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
13715 ret
= PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
);
13716 ok( !ret
, "got message %x\n", msg
.message
);
13718 /* sent message with timeout and callback */
13720 SendMessageTimeoutA( hwnd
, WM_CHAR
, dbch
[0], 0, SMTO_NORMAL
, 0, &res
);
13721 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
13722 SendMessageCallbackA( hwnd
, WM_CHAR
, dbch
[1], 0, NULL
, 0 );
13723 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
13724 ret
= PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
);
13725 ok( !ret
, "got message %x\n", msg
.message
);
13727 /* sent message with callback */
13729 SendNotifyMessageA( hwnd
, WM_CHAR
, dbch
[0], 0 );
13730 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
13731 SendMessageCallbackA( hwnd
, WM_CHAR
, dbch
[1], 0, NULL
, 0 );
13732 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
13733 ret
= PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
);
13734 ok( !ret
, "got message %x\n", msg
.message
);
13736 /* direct window proc call */
13738 CallWindowProcA( (WNDPROC
)GetWindowLongPtrA( hwnd
, GWLP_WNDPROC
), hwnd
, WM_CHAR
, dbch
[0], 0 );
13739 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
13740 CallWindowProcA( (WNDPROC
)GetWindowLongPtrA( hwnd
, GWLP_WNDPROC
), hwnd
, WM_CHAR
, dbch
[1], 0 );
13741 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
13743 /* dispatch message */
13745 msg
.message
= WM_CHAR
;
13746 msg
.wParam
= dbch
[0];
13748 DispatchMessageA( &msg
);
13749 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
13750 msg
.wParam
= dbch
[1];
13751 DispatchMessageA( &msg
);
13752 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
13754 /* window handle is irrelevant */
13756 SendMessageA( hwnd2
, WM_CHAR
, dbch
[0], 0 );
13757 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
13758 SendMessageA( hwnd
, WM_CHAR
, dbch
[1], 0 );
13759 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
13760 ret
= PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
);
13761 ok( !ret
, "got message %x\n", msg
.message
);
13763 /* interleaved post and send */
13765 PostMessageA( hwnd2
, WM_CHAR
, dbch
[0], 0 );
13766 SendMessageA( hwnd2
, WM_CHAR
, dbch
[0], 0 );
13767 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
13768 ret
= PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
);
13769 ok( !ret
, "got message %x\n", msg
.message
);
13770 PostMessageA( hwnd
, WM_CHAR
, dbch
[1], 0 );
13771 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
13772 ret
= PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
);
13773 ok( ret
, "no message\n" );
13774 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
13775 ok( msg
.wParam
== wch
, "bad wparam %lx/%x\n", msg
.wParam
, wch
);
13776 ret
= PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
);
13777 ok( !ret
, "got message %x\n", msg
.message
);
13778 SendMessageA( hwnd
, WM_CHAR
, dbch
[1], 0 );
13779 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
13780 ret
= PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
);
13781 ok( !ret
, "got message %x\n", msg
.message
);
13783 /* interleaved sent message and winproc */
13785 SendMessageA( hwnd
, WM_CHAR
, dbch
[0], 0 );
13786 CallWindowProcA( (WNDPROC
)GetWindowLongPtrA( hwnd
, GWLP_WNDPROC
), hwnd
, WM_CHAR
, dbch
[0], 0 );
13787 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
13788 SendMessageA( hwnd
, WM_CHAR
, dbch
[1], 0 );
13789 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
13790 CallWindowProcA( (WNDPROC
)GetWindowLongPtrA( hwnd
, GWLP_WNDPROC
), hwnd
, WM_CHAR
, dbch
[1], 0 );
13791 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
13793 /* interleaved winproc and dispatch */
13795 msg
.message
= WM_CHAR
;
13796 msg
.wParam
= dbch
[0];
13798 CallWindowProcA( (WNDPROC
)GetWindowLongPtrA( hwnd
, GWLP_WNDPROC
), hwnd
, WM_CHAR
, dbch
[0], 0 );
13799 DispatchMessageA( &msg
);
13800 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
13801 msg
.wParam
= dbch
[1];
13802 DispatchMessageA( &msg
);
13803 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
13804 CallWindowProcA( (WNDPROC
)GetWindowLongPtrA( hwnd
, GWLP_WNDPROC
), hwnd
, WM_CHAR
, dbch
[1], 0 );
13805 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
13807 /* interleaved sends */
13809 SendMessageA( hwnd
, WM_CHAR
, dbch
[0], 0 );
13810 SendMessageCallbackA( hwnd
, WM_CHAR
, dbch
[0], 0, NULL
, 0 );
13811 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
13812 SendMessageTimeoutA( hwnd
, WM_CHAR
, dbch
[1], 0, SMTO_NORMAL
, 0, &res
);
13813 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
13814 SendMessageA( hwnd
, WM_CHAR
, dbch
[1], 0 );
13815 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
13819 SendMessageA( hwnd2
, WM_CHAR
, (dbch
[1] << 8) | dbch
[0], 0 );
13820 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
13821 ret
= PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
);
13822 ok( !ret
, "got message %x\n", msg
.message
);
13824 /* other char messages are not magic */
13825 PostMessageA( hwnd
, WM_SYSCHAR
, dbch
[0], 0 );
13826 ret
= PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
);
13827 ok( ret
, "no message\n" );
13828 ok( msg
.message
== WM_SYSCHAR
, "unexpected message %x\n", msg
.message
);
13829 ok( msg
.wParam
== bad_wch
, "bad wparam %lx/%x\n", msg
.wParam
, bad_wch
);
13830 ret
= PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
);
13831 ok( !ret
, "got message %x\n", msg
.message
);
13832 PostMessageA( hwnd
, WM_DEADCHAR
, dbch
[0], 0 );
13833 ret
= PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
);
13834 ok( ret
, "no message\n" );
13835 ok( msg
.message
== WM_DEADCHAR
, "unexpected message %x\n", msg
.message
);
13836 ok( msg
.wParam
== bad_wch
, "bad wparam %lx/%x\n", msg
.wParam
, bad_wch
);
13837 ret
= PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
);
13838 ok( !ret
, "got message %x\n", msg
.message
);
13840 /* test retrieving messages */
13842 PostMessageW( hwnd
, WM_CHAR
, wch
, 0 );
13843 ret
= PeekMessageA( &msg
, hwnd
, 0, 0, PM_REMOVE
);
13844 ok( ret
, "no message\n" );
13845 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
13846 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
13847 ok( msg
.wParam
== dbch
[0], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
13848 ret
= PeekMessageA( &msg
, hwnd
, 0, 0, PM_REMOVE
);
13849 ok( ret
, "no message\n" );
13850 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
13851 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
13852 ok( msg
.wParam
== dbch
[1], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
13853 ret
= PeekMessageA( &msg
, hwnd
, 0, 0, PM_REMOVE
);
13854 ok( !ret
, "got message %x\n", msg
.message
);
13856 /* message filters */
13857 PostMessageW( hwnd
, WM_CHAR
, wch
, 0 );
13858 ret
= PeekMessageA( &msg
, hwnd
, 0, 0, PM_REMOVE
);
13859 ok( ret
, "no message\n" );
13860 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
13861 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
13862 ok( msg
.wParam
== dbch
[0], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
13863 /* message id is filtered, hwnd is not */
13864 ret
= PeekMessageA( &msg
, hwnd
, WM_MOUSEFIRST
, WM_MOUSELAST
, PM_REMOVE
);
13865 ok( !ret
, "no message\n" );
13866 ret
= PeekMessageA( &msg
, hwnd2
, 0, 0, PM_REMOVE
);
13867 ok( ret
, "no message\n" );
13868 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
13869 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
13870 ok( msg
.wParam
== dbch
[1], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
13871 ret
= PeekMessageA( &msg
, hwnd
, 0, 0, PM_REMOVE
);
13872 ok( !ret
, "got message %x\n", msg
.message
);
13874 /* mixing GetMessage and PostMessage */
13875 PostMessageW( hwnd
, WM_CHAR
, wch
, 0xbeef );
13876 ok( GetMessageA( &msg
, hwnd
, 0, 0 ), "no message\n" );
13877 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
13878 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
13879 ok( msg
.wParam
== dbch
[0], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
13880 ok( msg
.lParam
== 0xbeef, "bad lparam %lx\n", msg
.lParam
);
13883 ok( time
- GetTickCount() <= 100, "bad time %x\n", msg
.time
);
13884 ret
= PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
);
13885 ok( ret
, "no message\n" );
13886 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
13887 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
13888 ok( msg
.wParam
== dbch
[1], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
13889 ok( msg
.lParam
== 0xbeef, "bad lparam %lx\n", msg
.lParam
);
13890 ok( msg
.time
== time
, "bad time %x/%x\n", msg
.time
, time
);
13891 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
);
13892 ret
= PeekMessageA( &msg
, hwnd
, 0, 0, PM_REMOVE
);
13893 ok( !ret
, "got message %x\n", msg
.message
);
13895 /* without PM_REMOVE */
13896 PostMessageW( hwnd
, WM_CHAR
, wch
, 0 );
13897 ret
= PeekMessageA( &msg
, 0, 0, 0, PM_NOREMOVE
);
13898 ok( ret
, "no message\n" );
13899 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
13900 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
13901 ok( msg
.wParam
== dbch
[0], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
13902 ret
= PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
);
13903 ok( ret
, "no message\n" );
13904 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
13905 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
13906 ok( msg
.wParam
== dbch
[0], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
13907 ret
= PeekMessageA( &msg
, 0, 0, 0, PM_NOREMOVE
);
13908 ok( ret
, "no message\n" );
13909 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
13910 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
13911 ok( msg
.wParam
== dbch
[1], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
13912 ret
= PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
);
13913 ok( ret
, "no message\n" );
13914 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
13915 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
13916 ok( msg
.wParam
== dbch
[1], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
13917 ret
= PeekMessageA( &msg
, hwnd
, 0, 0, PM_REMOVE
);
13918 ok( !ret
, "got message %x\n", msg
.message
);
13920 DestroyWindow(hwnd
);
13921 DestroyWindow(hwnd2
);
13924 static void test_unicode_wm_char(void)
13928 struct message seq
[2];
13929 HKL hkl_orig
, hkl_greek
;
13931 LCID thread_locale
;
13933 hkl_orig
= GetKeyboardLayout( 0 );
13934 GetLocaleInfoW( LOWORD( hkl_orig
), LOCALE_IDEFAULTANSICODEPAGE
| LOCALE_RETURN_NUMBER
, (WCHAR
*)&cp
, sizeof(cp
) / sizeof(WCHAR
) );
13937 skip( "Default codepage %d\n", cp
);
13941 hkl_greek
= LoadKeyboardLayoutA( "00000408", 0 );
13942 if (!hkl_greek
|| hkl_greek
== hkl_orig
/* win2k */)
13944 skip( "Unable to load Greek keyboard layout\n" );
13948 hwnd
= CreateWindowExW( 0, testWindowClassW
, NULL
, WS_OVERLAPPEDWINDOW
,
13949 100, 100, 200, 200, 0, 0, 0, NULL
);
13952 PostMessageW( hwnd
, WM_CHAR
, 0x3b1, 0 );
13954 while (GetMessageW( &msg
, hwnd
, 0, 0 ))
13956 if (!ignore_message( msg
.message
)) break;
13959 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
13960 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
13961 ok( msg
.wParam
== 0x3b1, "bad wparam %lx\n", msg
.wParam
);
13962 ok( msg
.lParam
== 0, "bad lparam %lx\n", msg
.lParam
);
13964 DispatchMessageW( &msg
);
13966 memset( seq
, 0, sizeof(seq
) );
13967 seq
[0].message
= WM_CHAR
;
13968 seq
[0].flags
= sent
|wparam
;
13969 seq
[0].wParam
= 0x3b1;
13971 ok_sequence( seq
, "unicode WM_CHAR", FALSE
);
13975 /* greek alpha -> 'a' in cp1252 */
13976 PostMessageW( hwnd
, WM_CHAR
, 0x3b1, 0 );
13978 ok( GetMessageA( &msg
, hwnd
, 0, 0 ), "no message\n" );
13979 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
13980 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
13981 ok( msg
.wParam
== 0x61, "bad wparam %lx\n", msg
.wParam
);
13982 ok( msg
.lParam
== 0, "bad lparam %lx\n", msg
.lParam
);
13984 DispatchMessageA( &msg
);
13986 seq
[0].wParam
= 0x61;
13987 ok_sequence( seq
, "unicode WM_CHAR", FALSE
);
13989 thread_locale
= GetThreadLocale();
13990 ActivateKeyboardLayout( hkl_greek
, 0 );
13991 ok( GetThreadLocale() == thread_locale
, "locale changed from %08x to %08x\n",
13992 thread_locale
, GetThreadLocale() );
13996 /* greek alpha -> 0xe1 in cp1253 */
13997 PostMessageW( hwnd
, WM_CHAR
, 0x3b1, 0 );
13999 ok( GetMessageA( &msg
, hwnd
, 0, 0 ), "no message\n" );
14000 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
14001 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
14002 ok( msg
.wParam
== 0xe1, "bad wparam %lx\n", msg
.wParam
);
14003 ok( msg
.lParam
== 0, "bad lparam %lx\n", msg
.lParam
);
14005 DispatchMessageA( &msg
);
14007 seq
[0].wParam
= 0x3b1;
14008 ok_sequence( seq
, "unicode WM_CHAR", FALSE
);
14010 DestroyWindow( hwnd
);
14011 ActivateKeyboardLayout( hkl_orig
, 0 );
14012 UnloadKeyboardLayout( hkl_greek
);
14015 #define ID_LISTBOX 0x000f
14017 static const struct message wm_lb_setcursel_0
[] =
14019 { LB_SETCURSEL
, sent
|wparam
|lparam
, 0, 0 },
14020 { WM_CTLCOLORLISTBOX
, sent
|parent
},
14021 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x000120f2 },
14022 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 1 },
14023 { EVENT_OBJECT_SELECTION
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 1 },
14026 static const struct message wm_lb_setcursel_1
[] =
14028 { LB_SETCURSEL
, sent
|wparam
|lparam
, 1, 0 },
14029 { WM_CTLCOLORLISTBOX
, sent
|parent
},
14030 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x000020f2 },
14031 { WM_CTLCOLORLISTBOX
, sent
|parent
},
14032 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x000121f2 },
14033 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 2 },
14034 { EVENT_OBJECT_SELECTION
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 2 },
14037 static const struct message wm_lb_setcursel_2
[] =
14039 { LB_SETCURSEL
, sent
|wparam
|lparam
, 2, 0 },
14040 { WM_CTLCOLORLISTBOX
, sent
|parent
},
14041 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x000021f2 },
14042 { WM_CTLCOLORLISTBOX
, sent
|parent
},
14043 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x000122f2 },
14044 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 3 },
14045 { EVENT_OBJECT_SELECTION
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 3 },
14048 static const struct message wm_lb_click_0
[] =
14050 { WM_LBUTTONDOWN
, sent
|wparam
|lparam
, 0, MAKELPARAM(1,1) },
14051 { HCBT_SETFOCUS
, hook
},
14052 { WM_KILLFOCUS
, sent
|parent
},
14053 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
|parent
, 0 },
14054 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
14055 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
14056 { WM_SETFOCUS
, sent
|defwinproc
},
14058 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x001142f2 },
14059 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_LISTBOX
, LBN_SETFOCUS
) },
14060 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 3 },
14061 { WM_LBTRACKPOINT
, sent
|wparam
|lparam
|parent
, 0, MAKELPARAM(1,1) },
14062 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
14064 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x000142f2 },
14065 { WM_CTLCOLORLISTBOX
, sent
|parent
},
14066 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x000022f2 },
14067 { WM_CTLCOLORLISTBOX
, sent
|parent
},
14068 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x000120f2 },
14069 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x001140f2 },
14071 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 1 },
14072 { EVENT_OBJECT_SELECTION
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 1 },
14074 { WM_LBUTTONUP
, sent
|wparam
|lparam
, 0, 0 },
14075 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, 0, 0 },
14076 { WM_CAPTURECHANGED
, sent
|wparam
|lparam
|defwinproc
, 0, 0 },
14077 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_LISTBOX
, LBN_SELCHANGE
) },
14080 static const struct message wm_lb_deletestring
[] =
14082 { LB_DELETESTRING
, sent
|wparam
|lparam
, 0, 0 },
14083 { WM_DELETEITEM
, sent
|wparam
|parent
|optional
, ID_LISTBOX
, 0 },
14084 { WM_DRAWITEM
, sent
|wparam
|parent
|optional
, ID_LISTBOX
},
14085 { WM_DRAWITEM
, sent
|wparam
|parent
|optional
, ID_LISTBOX
},
14088 static const struct message wm_lb_deletestring_reset
[] =
14090 { LB_DELETESTRING
, sent
|wparam
|lparam
, 0, 0 },
14091 { LB_RESETCONTENT
, sent
|wparam
|lparam
|defwinproc
|optional
, 0, 0 },
14092 { WM_DELETEITEM
, sent
|wparam
|parent
|optional
, ID_LISTBOX
, 0 },
14093 { WM_DRAWITEM
, sent
|wparam
|parent
|optional
, ID_LISTBOX
},
14094 { WM_DRAWITEM
, sent
|wparam
|parent
|optional
, ID_LISTBOX
},
14098 #define check_lb_state(a1, a2, a3, a4, a5) check_lb_state_dbg(a1, a2, a3, a4, a5, __LINE__)
14100 static LRESULT (WINAPI
*listbox_orig_proc
)(HWND
, UINT
, WPARAM
, LPARAM
);
14102 static LRESULT WINAPI
listbox_hook_proc(HWND hwnd
, UINT message
, WPARAM wp
, LPARAM lp
)
14104 static LONG defwndproc_counter
= 0;
14106 struct recvd_message msg
;
14108 /* do not log painting messages */
14109 if (message
!= WM_PAINT
&&
14110 message
!= WM_NCPAINT
&&
14111 message
!= WM_SYNCPAINT
&&
14112 message
!= WM_ERASEBKGND
&&
14113 message
!= WM_NCHITTEST
&&
14114 message
!= WM_GETTEXT
&&
14115 !ignore_message( message
))
14118 msg
.message
= message
;
14119 msg
.flags
= sent
|wparam
|lparam
;
14120 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
14123 msg
.descr
= "listbox";
14127 defwndproc_counter
++;
14128 ret
= CallWindowProcA(listbox_orig_proc
, hwnd
, message
, wp
, lp
);
14129 defwndproc_counter
--;
14134 static void check_lb_state_dbg(HWND listbox
, int count
, int cur_sel
,
14135 int caret_index
, int top_index
, int line
)
14139 /* calling an orig proc helps to avoid unnecessary message logging */
14140 ret
= CallWindowProcA(listbox_orig_proc
, listbox
, LB_GETCOUNT
, 0, 0);
14141 ok_(__FILE__
, line
)(ret
== count
, "expected count %d, got %ld\n", count
, ret
);
14142 ret
= CallWindowProcA(listbox_orig_proc
, listbox
, LB_GETCURSEL
, 0, 0);
14143 ok_(__FILE__
, line
)(ret
== cur_sel
, "expected cur sel %d, got %ld\n", cur_sel
, ret
);
14144 ret
= CallWindowProcA(listbox_orig_proc
, listbox
, LB_GETCARETINDEX
, 0, 0);
14145 ok_(__FILE__
, line
)(ret
== caret_index
||
14146 broken(cur_sel
== -1 && caret_index
== 0 && ret
== -1), /* nt4 */
14147 "expected caret index %d, got %ld\n", caret_index
, ret
);
14148 ret
= CallWindowProcA(listbox_orig_proc
, listbox
, LB_GETTOPINDEX
, 0, 0);
14149 ok_(__FILE__
, line
)(ret
== top_index
, "expected top index %d, got %ld\n", top_index
, ret
);
14152 static void test_listbox_messages(void)
14154 HWND parent
, listbox
;
14157 parent
= CreateWindowExA(0, "TestParentClass", NULL
, WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
14158 100, 100, 200, 200, 0, 0, 0, NULL
);
14159 listbox
= CreateWindowExA(WS_EX_NOPARENTNOTIFY
, "ListBox", NULL
,
14160 WS_CHILD
| LBS_NOTIFY
| LBS_OWNERDRAWVARIABLE
| LBS_HASSTRINGS
| WS_VISIBLE
,
14161 10, 10, 80, 80, parent
, (HMENU
)ID_LISTBOX
, 0, NULL
);
14162 listbox_orig_proc
= (WNDPROC
)SetWindowLongPtrA(listbox
, GWLP_WNDPROC
, (ULONG_PTR
)listbox_hook_proc
);
14164 check_lb_state(listbox
, 0, LB_ERR
, 0, 0);
14166 ret
= SendMessageA(listbox
, LB_ADDSTRING
, 0, (LPARAM
)"item 0");
14167 ok(ret
== 0, "expected 0, got %ld\n", ret
);
14168 ret
= SendMessageA(listbox
, LB_ADDSTRING
, 0, (LPARAM
)"item 1");
14169 ok(ret
== 1, "expected 1, got %ld\n", ret
);
14170 ret
= SendMessageA(listbox
, LB_ADDSTRING
, 0, (LPARAM
)"item 2");
14171 ok(ret
== 2, "expected 2, got %ld\n", ret
);
14173 check_lb_state(listbox
, 3, LB_ERR
, 0, 0);
14177 log_all_parent_messages
++;
14179 trace("selecting item 0\n");
14180 ret
= SendMessageA(listbox
, LB_SETCURSEL
, 0, 0);
14181 ok(ret
== 0, "expected 0, got %ld\n", ret
);
14182 ok_sequence(wm_lb_setcursel_0
, "LB_SETCURSEL 0", FALSE
);
14183 check_lb_state(listbox
, 3, 0, 0, 0);
14186 trace("selecting item 1\n");
14187 ret
= SendMessageA(listbox
, LB_SETCURSEL
, 1, 0);
14188 ok(ret
== 1, "expected 1, got %ld\n", ret
);
14189 ok_sequence(wm_lb_setcursel_1
, "LB_SETCURSEL 1", FALSE
);
14190 check_lb_state(listbox
, 3, 1, 1, 0);
14192 trace("selecting item 2\n");
14193 ret
= SendMessageA(listbox
, LB_SETCURSEL
, 2, 0);
14194 ok(ret
== 2, "expected 2, got %ld\n", ret
);
14195 ok_sequence(wm_lb_setcursel_2
, "LB_SETCURSEL 2", FALSE
);
14196 check_lb_state(listbox
, 3, 2, 2, 0);
14198 trace("clicking on item 0\n");
14199 ret
= SendMessageA(listbox
, WM_LBUTTONDOWN
, 0, MAKELPARAM(1, 1));
14200 ok(ret
== LB_OKAY
, "expected LB_OKAY, got %ld\n", ret
);
14201 ret
= SendMessageA(listbox
, WM_LBUTTONUP
, 0, 0);
14202 ok(ret
== LB_OKAY
, "expected LB_OKAY, got %ld\n", ret
);
14203 ok_sequence(wm_lb_click_0
, "WM_LBUTTONDOWN 0", FALSE
);
14204 check_lb_state(listbox
, 3, 0, 0, 0);
14207 trace("deleting item 0\n");
14208 ret
= SendMessageA(listbox
, LB_DELETESTRING
, 0, 0);
14209 ok(ret
== 2, "expected 2, got %ld\n", ret
);
14210 ok_sequence(wm_lb_deletestring
, "LB_DELETESTRING 0", FALSE
);
14211 check_lb_state(listbox
, 2, -1, 0, 0);
14214 trace("deleting item 0\n");
14215 ret
= SendMessageA(listbox
, LB_DELETESTRING
, 0, 0);
14216 ok(ret
== 1, "expected 1, got %ld\n", ret
);
14217 ok_sequence(wm_lb_deletestring
, "LB_DELETESTRING 0", FALSE
);
14218 check_lb_state(listbox
, 1, -1, 0, 0);
14221 trace("deleting item 0\n");
14222 ret
= SendMessageA(listbox
, LB_DELETESTRING
, 0, 0);
14223 ok(ret
== 0, "expected 0, got %ld\n", ret
);
14224 ok_sequence(wm_lb_deletestring_reset
, "LB_DELETESTRING 0", FALSE
);
14225 check_lb_state(listbox
, 0, -1, 0, 0);
14228 trace("deleting item 0\n");
14229 ret
= SendMessageA(listbox
, LB_DELETESTRING
, 0, 0);
14230 ok(ret
== LB_ERR
, "expected LB_ERR, got %ld\n", ret
);
14231 check_lb_state(listbox
, 0, -1, 0, 0);
14234 log_all_parent_messages
--;
14236 DestroyWindow(listbox
);
14237 DestroyWindow(parent
);
14240 /*************************** Menu test ******************************/
14241 static const struct message wm_popup_menu_1
[] =
14243 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 },
14244 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
14245 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'E', 0x20000001 },
14246 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, 'E', 0x20000001 },
14247 { WM_SYSCHAR
, sent
|wparam
|lparam
, 'e', 0x20000001 },
14248 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_KEYMENU
, 'e' },
14249 { WM_ENTERMENULOOP
, sent
|wparam
|lparam
, 0, 0 },
14250 { WM_INITMENU
, sent
|lparam
, 0, 0 },
14251 { WM_MENUSELECT
, sent
|wparam
, MAKEWPARAM(1,MF_HILITE
|MF_POPUP
) },
14252 { WM_INITMENUPOPUP
, sent
|lparam
, 0, 1 },
14253 { HCBT_CREATEWND
, hook
|optional
}, /* Win9x doesn't create a window */
14254 { WM_MENUSELECT
, sent
|wparam
, MAKEWPARAM(200,MF_HILITE
) },
14255 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'E', 0xf0000001 },
14256 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xd0000001 },
14257 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_RETURN
, 0x10000001, 0, 0x40000000 },
14258 { HCBT_DESTROYWND
, hook
|optional
}, /* Win9x doesn't create a window */
14259 { WM_UNINITMENUPOPUP
, sent
|lparam
, 0, 0 },
14260 { WM_MENUSELECT
, sent
|wparam
|lparam
, MAKEWPARAM(0,0xffff), 0 },
14261 { WM_EXITMENULOOP
, sent
|wparam
|lparam
, 0, 0 },
14262 { WM_MENUCOMMAND
, sent
}, /* |wparam, 200 - Win9x */
14263 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_RETURN
, 0xc0000001 },
14264 { WM_KEYUP
, sent
|wparam
|lparam
, VK_RETURN
, 0xc0000001 },
14267 static const struct message wm_popup_menu_2
[] =
14269 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 },
14270 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
14271 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'F', 0x20000001 },
14272 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, 'F', 0x20000001 },
14273 { WM_SYSCHAR
, sent
|wparam
|lparam
, 'f', 0x20000001 },
14274 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_KEYMENU
, 'f' },
14275 { WM_ENTERMENULOOP
, sent
|wparam
|lparam
, 0, 0 },
14276 { WM_INITMENU
, sent
|lparam
, 0, 0 },
14277 { WM_MENUSELECT
, sent
|wparam
, MAKEWPARAM(0,MF_HILITE
|MF_POPUP
) },
14278 { WM_INITMENUPOPUP
, sent
|lparam
, 0, 0 },
14279 { WM_MENUSELECT
, sent
|wparam
|optional
, MAKEWPARAM(0,MF_HILITE
|MF_POPUP
) }, /* Win9x */
14280 { WM_INITMENUPOPUP
, sent
|lparam
|optional
, 0, 0 }, /* Win9x */
14281 { HCBT_CREATEWND
, hook
},
14282 { WM_MENUSELECT
, sent
}, /*|wparam, MAKEWPARAM(0,MF_HILITE|MF_POPUP) - XP
14283 |wparam, MAKEWPARAM(100,MF_HILITE) - Win9x */
14284 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'F', 0xf0000001 },
14285 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xd0000001 },
14286 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_RIGHT
, 0x10000001 },
14287 { WM_INITMENUPOPUP
, sent
|lparam
|optional
, 0, 0 }, /* Win9x doesn't send it */
14288 { HCBT_CREATEWND
, hook
|optional
}, /* Win9x doesn't send it */
14289 { WM_MENUSELECT
, sent
|wparam
|optional
, MAKEWPARAM(100,MF_HILITE
) },
14290 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_RIGHT
, 0xd0000001 },
14291 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_RETURN
, 0x10000001 },
14292 { HCBT_DESTROYWND
, hook
},
14293 { WM_UNINITMENUPOPUP
, sent
|lparam
, 0, 0 },
14294 { HCBT_DESTROYWND
, hook
|optional
}, /* Win9x doesn't send it */
14295 { WM_UNINITMENUPOPUP
, sent
|lparam
, 0, 0 },
14296 { WM_MENUSELECT
, sent
|wparam
|lparam
, MAKEWPARAM(0,0xffff), 0 },
14297 { WM_EXITMENULOOP
, sent
|wparam
|lparam
, 0, 0 },
14298 { WM_MENUCOMMAND
, sent
}, /* |wparam, 100 - Win9x */
14299 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_RETURN
, 0xc0000001 },
14300 { WM_KEYUP
, sent
|wparam
|lparam
, VK_RETURN
, 0xc0000001 },
14303 static const struct message wm_popup_menu_3
[] =
14305 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 },
14306 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
14307 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'F', 0x20000001 },
14308 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, 'F', 0x20000001 },
14309 { WM_SYSCHAR
, sent
|wparam
|lparam
, 'f', 0x20000001 },
14310 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_KEYMENU
, 'f' },
14311 { WM_ENTERMENULOOP
, sent
|wparam
|lparam
, 0, 0 },
14312 { WM_INITMENU
, sent
|lparam
, 0, 0 },
14313 { WM_MENUSELECT
, sent
|wparam
, MAKEWPARAM(0,MF_HILITE
|MF_POPUP
) },
14314 { WM_INITMENUPOPUP
, sent
|lparam
, 0, 0 },
14315 { WM_MENUSELECT
, sent
|wparam
|optional
, MAKEWPARAM(0,MF_HILITE
|MF_POPUP
) }, /* Win9x */
14316 { WM_INITMENUPOPUP
, sent
|lparam
|optional
, 0, 0 }, /* Win9x */
14317 { HCBT_CREATEWND
, hook
},
14318 { WM_MENUSELECT
, sent
}, /*|wparam, MAKEWPARAM(0,MF_HILITE|MF_POPUP) - XP
14319 |wparam, MAKEWPARAM(100,MF_HILITE) - Win9x */
14320 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'F', 0xf0000001 },
14321 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xd0000001 },
14322 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_RIGHT
, 0x10000001 },
14323 { WM_INITMENUPOPUP
, sent
|lparam
|optional
, 0, 0 }, /* Win9x doesn't send it */
14324 { HCBT_CREATEWND
, hook
|optional
}, /* Win9x doesn't send it */
14325 { WM_MENUSELECT
, sent
|wparam
|optional
, MAKEWPARAM(100,MF_HILITE
) },
14326 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_RIGHT
, 0xd0000001 },
14327 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_RETURN
, 0x10000001 },
14328 { HCBT_DESTROYWND
, hook
},
14329 { WM_UNINITMENUPOPUP
, sent
|lparam
, 0, 0 },
14330 { HCBT_DESTROYWND
, hook
|optional
}, /* Win9x doesn't send it */
14331 { WM_UNINITMENUPOPUP
, sent
|lparam
, 0, 0 },
14332 { WM_MENUSELECT
, sent
|wparam
|lparam
, MAKEWPARAM(0,0xffff), 0 },
14333 { WM_EXITMENULOOP
, sent
|wparam
|lparam
, 0, 0 },
14334 { WM_COMMAND
, sent
|wparam
|lparam
, 100, 0 },
14335 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_RETURN
, 0xc0000001 },
14336 { WM_KEYUP
, sent
|wparam
|lparam
, VK_RETURN
, 0xc0000001 },
14340 static const struct message wm_single_menu_item
[] =
14342 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 },
14343 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
14344 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'Q', 0x20000001 },
14345 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, 'Q', 0x20000001 },
14346 { WM_SYSCHAR
, sent
|wparam
|lparam
, 'q', 0x20000001 },
14347 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_KEYMENU
, 'q' },
14348 { WM_ENTERMENULOOP
, sent
|wparam
|lparam
, 0, 0 },
14349 { WM_INITMENU
, sent
|lparam
, 0, 0 },
14350 { WM_MENUSELECT
, sent
|wparam
|optional
, MAKEWPARAM(300,MF_HILITE
) },
14351 { WM_MENUSELECT
, sent
|wparam
|lparam
, MAKEWPARAM(0,0xffff), 0 },
14352 { WM_EXITMENULOOP
, sent
|wparam
|lparam
, 0, 0 },
14353 { WM_MENUCOMMAND
, sent
},
14354 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'Q', 0xe0000001 },
14355 { WM_SYSKEYUP
, sent
|wparam
|lparam
, 'Q', 0xe0000001 },
14356 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xc0000001 },
14357 { WM_KEYUP
, sent
|wparam
|lparam
, VK_MENU
, 0xc0000001 },
14359 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_ESCAPE
, 1 },
14360 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_ESCAPE
, 1 },
14361 { WM_CHAR
, sent
|wparam
|lparam
, VK_ESCAPE
, 0x00000001 },
14362 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_ESCAPE
, 0xc0000001 },
14363 { WM_KEYUP
, sent
|wparam
|lparam
, VK_ESCAPE
, 0xc0000001 },
14367 static LRESULT WINAPI
parent_menu_proc(HWND hwnd
, UINT message
, WPARAM wp
, LPARAM lp
)
14369 if (message
== WM_ENTERIDLE
||
14370 message
== WM_INITMENU
||
14371 message
== WM_INITMENUPOPUP
||
14372 message
== WM_MENUSELECT
||
14373 message
== WM_PARENTNOTIFY
||
14374 message
== WM_ENTERMENULOOP
||
14375 message
== WM_EXITMENULOOP
||
14376 message
== WM_UNINITMENUPOPUP
||
14377 message
== WM_KEYDOWN
||
14378 message
== WM_KEYUP
||
14379 message
== WM_CHAR
||
14380 message
== WM_SYSKEYDOWN
||
14381 message
== WM_SYSKEYUP
||
14382 message
== WM_SYSCHAR
||
14383 message
== WM_COMMAND
||
14384 message
== WM_MENUCOMMAND
)
14386 struct recvd_message msg
;
14389 msg
.message
= message
;
14390 msg
.flags
= sent
|wparam
|lparam
;
14393 msg
.descr
= "parent_menu_proc";
14397 return DefWindowProcA(hwnd
, message
, wp
, lp
);
14400 static void set_menu_style(HMENU hmenu
, DWORD style
)
14405 mi
.cbSize
= sizeof(mi
);
14406 mi
.fMask
= MIM_STYLE
;
14407 mi
.dwStyle
= style
;
14408 SetLastError(0xdeadbeef);
14409 ret
= pSetMenuInfo(hmenu
, &mi
);
14410 ok(ret
, "SetMenuInfo error %u\n", GetLastError());
14413 static DWORD
get_menu_style(HMENU hmenu
)
14418 mi
.cbSize
= sizeof(mi
);
14419 mi
.fMask
= MIM_STYLE
;
14421 SetLastError(0xdeadbeef);
14422 ret
= pGetMenuInfo(hmenu
, &mi
);
14423 ok(ret
, "GetMenuInfo error %u\n", GetLastError());
14428 static void test_menu_messages(void)
14432 HMENU hmenu
, hmenu_popup
;
14436 if (!pGetMenuInfo
|| !pSetMenuInfo
)
14438 win_skip("GetMenuInfo and/or SetMenuInfo are not available\n");
14442 cls
.lpfnWndProc
= parent_menu_proc
;
14443 cls
.cbClsExtra
= 0;
14444 cls
.cbWndExtra
= 0;
14445 cls
.hInstance
= GetModuleHandleA(0);
14447 cls
.hCursor
= LoadCursorA(0, (LPCSTR
)IDC_ARROW
);
14448 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
14449 cls
.lpszMenuName
= NULL
;
14450 cls
.lpszClassName
= "TestMenuClass";
14451 UnregisterClassA(cls
.lpszClassName
, cls
.hInstance
);
14452 if (!RegisterClassA(&cls
)) assert(0);
14454 SetLastError(0xdeadbeef);
14455 hwnd
= CreateWindowExA(0, "TestMenuClass", NULL
, WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
14456 100, 100, 200, 200, 0, 0, 0, NULL
);
14457 ok(hwnd
!= 0, "LoadMenuA error %u\n", GetLastError());
14459 SetLastError(0xdeadbeef);
14460 hmenu
= LoadMenuA(GetModuleHandleA(NULL
), MAKEINTRESOURCEA(1));
14461 ok(hmenu
!= 0, "LoadMenuA error %u\n", GetLastError());
14463 SetMenu(hwnd
, hmenu
);
14464 SetForegroundWindow( hwnd
);
14467 set_menu_style(hmenu
, MNS_NOTIFYBYPOS
);
14468 style
= get_menu_style(hmenu
);
14469 ok(style
== MNS_NOTIFYBYPOS
, "expected MNS_NOTIFYBYPOS, got %u\n", style
);
14471 hmenu_popup
= GetSubMenu(hmenu
, 0);
14472 ok(hmenu_popup
!= 0, "GetSubMenu returned 0 for submenu 0\n");
14473 style
= get_menu_style(hmenu_popup
);
14474 ok(style
== 0, "expected 0, got %u\n", style
);
14476 hmenu_popup
= GetSubMenu(hmenu_popup
, 0);
14477 ok(hmenu_popup
!= 0, "GetSubMenu returned 0 for submenu 0\n");
14478 style
= get_menu_style(hmenu_popup
);
14479 ok(style
== 0, "expected 0, got %u\n", style
);
14482 trace("testing a popup menu command\n");
14484 keybd_event(VK_MENU
, 0, 0, 0);
14485 keybd_event('E', 0, 0, 0);
14486 keybd_event('E', 0, KEYEVENTF_KEYUP
, 0);
14487 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
14488 keybd_event(VK_RETURN
, 0, 0, 0);
14489 keybd_event(VK_RETURN
, 0, KEYEVENTF_KEYUP
, 0);
14490 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
))
14492 TranslateMessage(&msg
);
14493 DispatchMessageA(&msg
);
14495 if (!sequence_cnt
) /* we didn't get any message */
14497 skip( "queuing key events not supported\n" );
14500 /* win98 queues only a WM_KEYUP and doesn't start menu tracking */
14501 if (sequence
[0].message
== WM_KEYUP
&& sequence
[0].wParam
== VK_MENU
)
14503 win_skip( "menu tracking through VK_MENU not supported\n" );
14506 ok_sequence(wm_popup_menu_1
, "popup menu command", FALSE
);
14508 /* Alt+F, Right, Enter */
14509 trace("testing submenu of a popup menu command\n");
14511 keybd_event(VK_MENU
, 0, 0, 0);
14512 keybd_event('F', 0, 0, 0);
14513 keybd_event('F', 0, KEYEVENTF_KEYUP
, 0);
14514 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
14515 keybd_event(VK_RIGHT
, 0, 0, 0);
14516 keybd_event(VK_RIGHT
, 0, KEYEVENTF_KEYUP
, 0);
14517 keybd_event(VK_RETURN
, 0, 0, 0);
14518 keybd_event(VK_RETURN
, 0, KEYEVENTF_KEYUP
, 0);
14519 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
))
14521 TranslateMessage(&msg
);
14522 DispatchMessageA(&msg
);
14524 ok_sequence(wm_popup_menu_2
, "submenu of a popup menu command", FALSE
);
14526 trace("testing single menu item command\n");
14528 keybd_event(VK_MENU
, 0, 0, 0);
14529 keybd_event('Q', 0, 0, 0);
14530 keybd_event('Q', 0, KEYEVENTF_KEYUP
, 0);
14531 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
14532 keybd_event(VK_ESCAPE
, 0, 0, 0);
14533 keybd_event(VK_ESCAPE
, 0, KEYEVENTF_KEYUP
, 0);
14534 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
))
14536 TranslateMessage(&msg
);
14537 DispatchMessageA(&msg
);
14539 ok_sequence(wm_single_menu_item
, "single menu item command", FALSE
);
14541 set_menu_style(hmenu
, 0);
14542 style
= get_menu_style(hmenu
);
14543 ok(style
== 0, "expected 0, got %u\n", style
);
14545 hmenu_popup
= GetSubMenu(hmenu
, 0);
14546 ok(hmenu_popup
!= 0, "GetSubMenu returned 0 for submenu 0\n");
14547 set_menu_style(hmenu_popup
, MNS_NOTIFYBYPOS
);
14548 style
= get_menu_style(hmenu_popup
);
14549 ok(style
== MNS_NOTIFYBYPOS
, "expected MNS_NOTIFYBYPOS, got %u\n", style
);
14551 hmenu_popup
= GetSubMenu(hmenu_popup
, 0);
14552 ok(hmenu_popup
!= 0, "GetSubMenu returned 0 for submenu 0\n");
14553 style
= get_menu_style(hmenu_popup
);
14554 ok(style
== 0, "expected 0, got %u\n", style
);
14556 /* Alt+F, Right, Enter */
14557 trace("testing submenu of a popup menu command\n");
14559 keybd_event(VK_MENU
, 0, 0, 0);
14560 keybd_event('F', 0, 0, 0);
14561 keybd_event('F', 0, KEYEVENTF_KEYUP
, 0);
14562 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
14563 keybd_event(VK_RIGHT
, 0, 0, 0);
14564 keybd_event(VK_RIGHT
, 0, KEYEVENTF_KEYUP
, 0);
14565 keybd_event(VK_RETURN
, 0, 0, 0);
14566 keybd_event(VK_RETURN
, 0, KEYEVENTF_KEYUP
, 0);
14567 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
))
14569 TranslateMessage(&msg
);
14570 DispatchMessageA(&msg
);
14572 ok_sequence(wm_popup_menu_3
, "submenu of a popup menu command", FALSE
);
14575 DestroyWindow(hwnd
);
14576 DestroyMenu(hmenu
);
14580 static void test_paintingloop(void)
14584 paint_loop_done
= FALSE
;
14585 hwnd
= CreateWindowExA(0x0,"PaintLoopWindowClass",
14586 "PaintLoopWindowClass",WS_OVERLAPPEDWINDOW
,
14587 100, 100, 100, 100, 0, 0, 0, NULL
);
14588 ok(hwnd
!= 0, "PaintLoop window error %u\n", GetLastError());
14589 ShowWindow(hwnd
,SW_NORMAL
);
14592 while (!paint_loop_done
)
14595 if (PeekMessageA(&msg
, 0, 0, 0, 1))
14597 TranslateMessage(&msg
);
14598 DispatchMessageA(&msg
);
14601 DestroyWindow(hwnd
);
14604 static const struct message NCRBUTTONDOWNSeq
[] =
14606 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
14607 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, 0, 0 },
14608 { WM_CAPTURECHANGED
, sent
},
14609 { WM_CONTEXTMENU
, sent
, /*hwnd*/0, -1 },
14613 static const struct message NCXBUTTONUPSeq1
[] =
14615 { WM_APPCOMMAND
, sent
|lparam
, /*hwnd*/0, MAKELPARAM(0, FAPPCOMMAND_MOUSE
| APPCOMMAND_BROWSER_BACKWARD
) },
14619 static const struct message NCXBUTTONUPSeq2
[] =
14621 { WM_APPCOMMAND
, sent
|lparam
, /*hwnd*/0, MAKELPARAM(0, FAPPCOMMAND_MOUSE
| APPCOMMAND_BROWSER_FORWARD
) },
14625 struct rbuttonup_thread_data
14628 HANDLE wndproc_finished
;
14631 static DWORD CALLBACK
post_rbuttonup_msg( void *arg
)
14633 struct rbuttonup_thread_data
*data
= arg
;
14636 ret
= WaitForSingleObject( data
->wndproc_finished
, 500 );
14637 todo_wine
ok( ret
== WAIT_OBJECT_0
, "WaitForSingleObject returned %x\n", ret
);
14638 if( ret
== WAIT_OBJECT_0
) return 0;
14640 PostMessageA( data
->hwnd
, WM_RBUTTONUP
, 0, 0 );
14644 static void test_defwinproc(void)
14648 BOOL gotwmquit
= FALSE
;
14653 struct rbuttonup_thread_data data
;
14657 hwnd
= CreateWindowExA(0, "TestWindowClass", "test_defwndproc",
14658 WS_VISIBLE
| WS_CAPTION
| WS_OVERLAPPEDWINDOW
, 0,0,500,100,0,0,0, NULL
);
14663 GetWindowTextA(hwnd
, buffA
, sizeof(buffA
)/sizeof(*buffA
));
14664 ok(!strcmp(buffA
, "test_defwndproc"), "unexpected window text, %s\n", buffA
);
14666 /* Zero high word of the lParam */
14667 res
= DefWindowProcA(hwnd
, WM_SETTEXT
, 0, 0x1234);
14668 ok(res
== 0, "WM_SETTEXT was expected to fail, %ld\n", res
);
14670 GetWindowTextA(hwnd
, buffA
, sizeof(buffA
)/sizeof(*buffA
));
14671 ok(!strcmp(buffA
, "test_defwndproc"), "unexpected window text, %s\n", buffA
);
14673 res
= DefWindowProcW(hwnd
, WM_SETTEXT
, 0, 0x1234);
14674 ok(res
== 0, "WM_SETTEXT was expected to fail, %ld\n", res
);
14676 GetWindowTextA(hwnd
, buffA
, sizeof(buffA
)/sizeof(*buffA
));
14677 ok(!strcmp(buffA
, "test_defwndproc"), "unexpected window text, %s\n", buffA
);
14679 GetCursorPos(&pos
);
14680 GetWindowRect(hwnd
, &rect
);
14681 x
= (rect
.left
+rect
.right
) / 2;
14682 y
= rect
.top
+ GetSystemMetrics(SM_CYFRAME
) + 1;
14683 SetCursorPos(x
, y
);
14685 res
= DefWindowProcA( hwnd
, WM_NCHITTEST
, 0, MAKELPARAM(x
, y
));
14686 ok(res
== HTCAPTION
, "WM_NCHITTEST returned %ld\n", res
);
14688 mouse_event( MOUSEEVENTF_LEFTDOWN
, 0, 0, 0, 0 );
14689 mouse_event( MOUSEEVENTF_LEFTUP
, 0, 0, 0, 0 );
14693 mouse_event( MOUSEEVENTF_RIGHTUP
, 0, 0, 0, 0 );
14694 /* workaround for missing support for clicking on window frame */
14696 data
.wndproc_finished
= CreateEventA( NULL
, FALSE
, FALSE
, NULL
);
14697 thread
= CreateThread( NULL
, 0, post_rbuttonup_msg
, (void*)&data
, 0, NULL
);
14699 DefWindowProcA( hwnd
, WM_NCRBUTTONDOWN
, HTCAPTION
, MAKELPARAM(x
, y
));
14700 ok_sequence(NCRBUTTONDOWNSeq
, "WM_NCRBUTTONDOWN on caption", FALSE
);
14702 res
= DefWindowProcA(hwnd
, WM_NCXBUTTONUP
, 0, MAKELPARAM(x
, y
));
14703 ok(!res
, "WM_NCXBUTTONUP returned %ld\n", res
);
14704 ok_sequence(WmEmptySeq
, "WM_NCXBUTTONUP without button", FALSE
);
14706 res
= DefWindowProcA(hwnd
, WM_NCXBUTTONUP
, MAKEWPARAM(0, XBUTTON1
), MAKELPARAM(x
, y
));
14707 ok(!res
, "WM_NCXBUTTONUP returned %ld\n", res
);
14708 ok_sequence(NCXBUTTONUPSeq1
, "WM_NCXBUTTONUP with XBUTTON1", FALSE
);
14710 res
= DefWindowProcA(hwnd
, WM_NCXBUTTONUP
, MAKEWPARAM(0, XBUTTON2
), MAKELPARAM(x
, y
));
14711 ok(!res
, "WM_NCXBUTTONUP returned %ld\n", res
);
14712 ok_sequence(NCXBUTTONUPSeq2
, "WM_NCXBUTTONUP with XBUTTON2", FALSE
);
14714 res
= DefWindowProcA(hwnd
, WM_NCXBUTTONUP
, MAKEWPARAM(0, 3), MAKELPARAM(x
, y
));
14715 ok(!res
, "WM_NCXBUTTONUP returned %ld\n", res
);
14716 ok_sequence(WmEmptySeq
, "WM_NCXBUTTONUP with invalid button", FALSE
);
14718 SetEvent( data
.wndproc_finished
);
14719 WaitForSingleObject( thread
, 1000 );
14720 CloseHandle( data
.wndproc_finished
);
14721 CloseHandle( thread
);
14723 SetCursorPos(pos
.x
, pos
.y
);
14725 DefWindowProcA( hwnd
, WM_ENDSESSION
, 1, 0);
14726 while (PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
)) {
14727 if( msg
.message
== WM_QUIT
) gotwmquit
= TRUE
;
14728 DispatchMessageA( &msg
);
14730 ok(!gotwmquit
, "Unexpected WM_QUIT message!\n");
14731 DestroyWindow( hwnd
);
14734 #define clear_clipboard(hwnd) clear_clipboard_(__LINE__, (hwnd))
14735 static void clear_clipboard_(int line
, HWND hWnd
)
14738 succ
= OpenClipboard(hWnd
);
14739 ok_(__FILE__
, line
)(succ
, "OpenClipboard failed, err=%u\n", GetLastError());
14740 succ
= EmptyClipboard();
14741 ok_(__FILE__
, line
)(succ
, "EmptyClipboard failed, err=%u\n", GetLastError());
14742 succ
= CloseClipboard();
14743 ok_(__FILE__
, line
)(succ
, "CloseClipboard failed, err=%u\n", GetLastError());
14746 #define expect_HWND(expected, got) expect_HWND_(__LINE__, (expected), (got))
14747 static void expect_HWND_(int line
, HWND expected
, HWND got
)
14749 ok_(__FILE__
, line
)(got
==expected
, "Expected %p, got %p\n", expected
, got
);
14752 static WNDPROC pOldViewerProc
;
14754 static LRESULT CALLBACK
recursive_viewer_proc(HWND hWnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
14756 static BOOL recursion_guard
;
14758 if (message
== WM_DRAWCLIPBOARD
&& !recursion_guard
)
14760 recursion_guard
= TRUE
;
14761 clear_clipboard(hWnd
);
14762 recursion_guard
= FALSE
;
14764 return CallWindowProcA(pOldViewerProc
, hWnd
, message
, wParam
, lParam
);
14767 static void test_clipboard_viewers(void)
14769 static struct message wm_change_cb_chain
[] =
14771 { WM_CHANGECBCHAIN
, sent
|wparam
|lparam
, 0, 0 },
14774 static const struct message wm_clipboard_destroyed
[] =
14776 { WM_DESTROYCLIPBOARD
, sent
|wparam
|lparam
, 0, 0 },
14779 static struct message wm_clipboard_changed
[] =
14781 { WM_DRAWCLIPBOARD
, sent
|wparam
|lparam
, 0, 0 },
14784 static struct message wm_clipboard_changed_and_owned
[] =
14786 { WM_DESTROYCLIPBOARD
, sent
|wparam
|lparam
, 0, 0 },
14787 { WM_DRAWCLIPBOARD
, sent
|wparam
|lparam
, 0, 0 },
14791 HINSTANCE hInst
= GetModuleHandleA(NULL
);
14792 HWND hWnd1
, hWnd2
, hWnd3
;
14796 hWnd1
= CreateWindowExA(0, "TestWindowClass", "Clipboard viewer test wnd 1",
14797 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
| WS_MAXIMIZEBOX
,
14798 CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
,
14799 GetDesktopWindow(), NULL
, hInst
, NULL
);
14800 hWnd2
= CreateWindowExA(0, "SimpleWindowClass", "Clipboard viewer test wnd 2",
14801 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
| WS_MAXIMIZEBOX
,
14802 CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
,
14803 GetDesktopWindow(), NULL
, hInst
, NULL
);
14804 hWnd3
= CreateWindowExA(0, "SimpleWindowClass", "Clipboard viewer test wnd 3",
14805 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
| WS_MAXIMIZEBOX
,
14806 CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
,
14807 GetDesktopWindow(), NULL
, hInst
, NULL
);
14808 trace("clipbd viewers: hWnd1=%p, hWnd2=%p, hWnd3=%p\n", hWnd1
, hWnd2
, hWnd3
);
14809 assert(hWnd1
&& hWnd2
&& hWnd3
);
14811 CountClipboardFormats(); /* Ensure that we do not have an X11 update to the clipboard */
14814 /* Test getting the clipboard viewer and setting the viewer to NULL. */
14815 hOrigViewer
= GetClipboardViewer();
14816 hRet
= SetClipboardViewer(NULL
);
14817 ok_sequence(WmEmptySeq
, "set viewer to NULL", FALSE
);
14818 expect_HWND(hOrigViewer
, hRet
);
14819 expect_HWND(NULL
, GetClipboardViewer());
14821 /* Test registering hWnd1 as a viewer. */
14822 hRet
= SetClipboardViewer(hWnd1
);
14823 wm_clipboard_changed
[0].wParam
= (WPARAM
) GetClipboardOwner();
14824 ok_sequence(wm_clipboard_changed
, "set viewer NULL->1", FALSE
);
14825 expect_HWND(NULL
, hRet
);
14826 expect_HWND(hWnd1
, GetClipboardViewer());
14828 /* Test that changing the clipboard actually refreshes the registered viewer. */
14829 clear_clipboard(hWnd1
);
14830 wm_clipboard_changed
[0].wParam
= (WPARAM
) GetClipboardOwner();
14831 ok_sequence(wm_clipboard_changed
, "clear clipbd (viewer=owner=1)", FALSE
);
14833 /* Again, but with different owner. */
14834 clear_clipboard(hWnd2
);
14835 wm_clipboard_changed_and_owned
[1].wParam
= (WPARAM
) GetClipboardOwner();
14836 ok_sequence(wm_clipboard_changed_and_owned
, "clear clipbd (viewer=1, owner=2)", FALSE
);
14838 /* Test re-registering same window. */
14839 hRet
= SetClipboardViewer(hWnd1
);
14840 wm_clipboard_changed
[0].wParam
= (WPARAM
) GetClipboardOwner();
14841 ok_sequence(wm_clipboard_changed
, "set viewer 1->1", FALSE
);
14842 expect_HWND(hWnd1
, hRet
);
14843 expect_HWND(hWnd1
, GetClipboardViewer());
14845 /* Test ChangeClipboardChain. */
14846 ChangeClipboardChain(hWnd2
, hWnd3
);
14847 wm_change_cb_chain
[0].wParam
= (WPARAM
) hWnd2
;
14848 wm_change_cb_chain
[0].lParam
= (LPARAM
) hWnd3
;
14849 ok_sequence(wm_change_cb_chain
, "change chain (viewer=1, remove=2, next=3)", FALSE
);
14850 expect_HWND(hWnd1
, GetClipboardViewer());
14852 ChangeClipboardChain(hWnd2
, NULL
);
14853 wm_change_cb_chain
[0].wParam
= (WPARAM
) hWnd2
;
14854 wm_change_cb_chain
[0].lParam
= 0;
14855 ok_sequence(wm_change_cb_chain
, "change chain (viewer=1, remove=2, next=NULL)", FALSE
);
14856 expect_HWND(hWnd1
, GetClipboardViewer());
14858 ChangeClipboardChain(NULL
, hWnd2
);
14859 ok_sequence(WmEmptySeq
, "change chain (viewer=1, remove=NULL, next=2)", FALSE
);
14860 expect_HWND(hWnd1
, GetClipboardViewer());
14862 /* Actually change clipboard viewer with ChangeClipboardChain. */
14863 ChangeClipboardChain(hWnd1
, hWnd2
);
14864 ok_sequence(WmEmptySeq
, "change chain (viewer=remove=1, next=2)", FALSE
);
14865 expect_HWND(hWnd2
, GetClipboardViewer());
14867 /* Test that no refresh messages are sent when viewer has unregistered. */
14868 clear_clipboard(hWnd2
);
14869 ok_sequence(WmEmptySeq
, "clear clipd (viewer=2, owner=1)", FALSE
);
14871 /* Register hWnd1 again. */
14872 ChangeClipboardChain(hWnd2
, hWnd1
);
14873 ok_sequence(WmEmptySeq
, "change chain (viewer=remove=2, next=1)", FALSE
);
14874 expect_HWND(hWnd1
, GetClipboardViewer());
14876 /* Subclass hWnd1 so that when it receives a WM_DRAWCLIPBOARD message, it
14877 * changes the clipboard. When this happens, the system shouldn't send
14878 * another WM_DRAWCLIPBOARD (as this could cause an infinite loop).
14880 pOldViewerProc
= (WNDPROC
) SetWindowLongPtrA(hWnd1
, GWLP_WNDPROC
, (LONG_PTR
) recursive_viewer_proc
);
14881 clear_clipboard(hWnd2
);
14882 /* The clipboard owner is changed in recursive_viewer_proc: */
14883 wm_clipboard_changed
[0].wParam
= (WPARAM
) hWnd2
;
14884 ok_sequence(wm_clipboard_changed
, "recursive clear clipbd (viewer=1, owner=2)", TRUE
);
14886 /* Test unregistering. */
14887 ChangeClipboardChain(hWnd1
, NULL
);
14888 ok_sequence(WmEmptySeq
, "change chain (viewer=remove=1, next=NULL)", FALSE
);
14889 expect_HWND(NULL
, GetClipboardViewer());
14891 clear_clipboard(hWnd1
);
14892 ok_sequence(wm_clipboard_destroyed
, "clear clipbd (no viewer, owner=1)", FALSE
);
14894 DestroyWindow(hWnd1
);
14895 DestroyWindow(hWnd2
);
14896 DestroyWindow(hWnd3
);
14897 SetClipboardViewer(hOrigViewer
);
14900 static void test_PostMessage(void)
14902 static const struct
14908 { HWND_TOP
/* 0 */, TRUE
},
14909 { HWND_BROADCAST
, TRUE
},
14910 { HWND_BOTTOM
, TRUE
},
14911 { HWND_TOPMOST
, TRUE
},
14912 { HWND_NOTOPMOST
, FALSE
},
14913 { HWND_MESSAGE
, FALSE
},
14914 { (HWND
)0xdeadbeef, FALSE
}
14920 static const WCHAR staticW
[] = {'s','t','a','t','i','c',0};
14922 SetLastError(0xdeadbeef);
14923 hwnd
= CreateWindowExW(0, staticW
, NULL
, WS_POPUP
, 0,0,0,0,0,0,0, NULL
);
14924 if (!hwnd
&& GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
)
14926 win_skip("Skipping some PostMessage tests on Win9x/WinMe\n");
14933 PostMessageA(hwnd
, WM_USER
+1, 0x1234, 0x5678);
14934 PostMessageA(0, WM_USER
+2, 0x5678, 0x1234);
14936 for (i
= 0; i
< sizeof(data
)/sizeof(data
[0]); i
++)
14938 memset(&msg
, 0xab, sizeof(msg
));
14939 ret
= PeekMessageA(&msg
, data
[i
].hwnd
, 0, 0, PM_NOREMOVE
);
14940 ok(ret
== data
[i
].ret
, "%d: hwnd %p expected %d, got %d\n", i
, data
[i
].hwnd
, data
[i
].ret
, ret
);
14944 ok(ret
&& msg
.hwnd
== 0 && msg
.message
== WM_USER
+2 &&
14945 msg
.wParam
== 0x5678 && msg
.lParam
== 0x1234,
14946 "%d: got ret %d hwnd %p msg %04x wParam %08lx lParam %08lx instead of TRUE/0/WM_USER+2/0x5678/0x1234\n",
14947 i
, ret
, msg
.hwnd
, msg
.message
, msg
.wParam
, msg
.lParam
);
14949 ok(ret
&& msg
.hwnd
== hwnd
&& msg
.message
== WM_USER
+1 &&
14950 msg
.wParam
== 0x1234 && msg
.lParam
== 0x5678,
14951 "%d: got ret %d hwnd %p msg %04x wParam %08lx lParam %08lx instead of TRUE/%p/WM_USER+1/0x1234/0x5678\n",
14952 i
, ret
, msg
.hwnd
, msg
.message
, msg
.wParam
, msg
.lParam
, msg
.hwnd
);
14956 DestroyWindow(hwnd
);
14960 static LPARAM g_broadcast_lparam
;
14961 static LRESULT WINAPI
broadcast_test_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
14963 WNDPROC oldproc
= (WNDPROC
)GetWindowLongPtrA(hwnd
, GWLP_USERDATA
);
14965 if (wParam
== 0xbaadbeef)
14966 g_broadcast_lparam
= wParam
;
14968 g_broadcast_lparam
= 0;
14970 return CallWindowProcA(oldproc
, hwnd
, message
, wParam
, lParam
);
14973 static void test_broadcast(void)
14975 static const UINT messages
[] =
14981 0xc000, /* lowest possible atom returned by RegisterWindowMessage */
14988 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
, 0, 0, 0, 0, 0, 0, 0, NULL
);
14989 ok(hwnd
!= NULL
, "got %p\n", hwnd
);
14991 oldproc
= (WNDPROC
)SetWindowLongPtrA(hwnd
, GWLP_WNDPROC
, (LONG_PTR
)broadcast_test_proc
);
14992 SetWindowLongPtrA(hwnd
, GWLP_USERDATA
, (LONG_PTR
)oldproc
);
14994 for (i
= 0; i
< sizeof(messages
)/sizeof(messages
[0]); i
++)
15000 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
))
15003 /* post, broadcast */
15004 ret
= PostMessageA(HWND_BROADCAST
, messages
[i
], 0, 0);
15005 ok(ret
, "%d: got %d, error %d\n", i
, ret
, GetLastError());
15007 memset(&msg
, 0xab, sizeof(msg
));
15008 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
15009 if (messages
[i
] < WM_USER
|| messages
[i
] >= 0xc000)
15011 ok(ret
, "%d: message %04x, got %d, error %d\n", i
, messages
[i
], ret
, GetLastError());
15012 ok(msg
.hwnd
== hwnd
, "%d: got %p\n", i
, msg
.hwnd
);
15016 ok(!ret
, "%d: message %04x, got %d, error %d\n", i
, messages
[i
], ret
, GetLastError());
15019 /* post, topmost */
15020 ret
= PostMessageA(HWND_TOPMOST
, messages
[i
], 0, 0);
15021 ok(ret
, "%d: got %d, error %d\n", i
, ret
, GetLastError());
15023 memset(&msg
, 0xab, sizeof(msg
));
15024 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
15025 if (messages
[i
] < WM_USER
|| messages
[i
] >= 0xc000)
15027 ok(ret
, "%d: message %04x, got %d, error %d\n", i
, messages
[i
], ret
, GetLastError());
15028 ok(msg
.hwnd
== hwnd
, "%d: got %p\n", i
, msg
.hwnd
);
15032 ok(!ret
, "%d: got %d, error %d\n", i
, ret
, GetLastError());
15035 /* send, broadcast */
15036 g_broadcast_lparam
= 0xdead;
15037 ret
= SendMessageTimeoutA(HWND_BROADCAST
, messages
[i
], 0xbaadbeef, 0, SMTO_NORMAL
, 2000, NULL
);
15038 if (!ret
&& GetLastError() == ERROR_TIMEOUT
)
15039 win_skip("broadcasting test %d, timeout\n", i
);
15042 if (messages
[i
] < WM_USER
|| messages
[i
] >= 0xc000)
15044 ok(g_broadcast_lparam
== 0xbaadbeef, "%d: message %04x, got %#lx, error %d\n", i
, messages
[i
],
15045 g_broadcast_lparam
, GetLastError());
15049 ok(g_broadcast_lparam
== 0xdead, "%d: message %04x, got %#lx, error %d\n", i
, messages
[i
],
15050 g_broadcast_lparam
, GetLastError());
15054 /* send, topmost */
15055 g_broadcast_lparam
= 0xdead;
15056 ret
= SendMessageTimeoutA(HWND_TOPMOST
, messages
[i
], 0xbaadbeef, 0, SMTO_NORMAL
, 2000, NULL
);
15057 if (!ret
&& GetLastError() == ERROR_TIMEOUT
)
15058 win_skip("broadcasting test %d, timeout\n", i
);
15061 if (messages
[i
] < WM_USER
|| messages
[i
] >= 0xc000)
15063 ok(g_broadcast_lparam
== 0xbaadbeef, "%d: message %04x, got %#lx, error %d\n", i
, messages
[i
],
15064 g_broadcast_lparam
, GetLastError());
15068 ok(g_broadcast_lparam
== 0xdead, "%d: message %04x, got %#lx, error %d\n", i
, messages
[i
],
15069 g_broadcast_lparam
, GetLastError());
15074 DestroyWindow(hwnd
);
15077 static const struct
15081 } wait_idle_expect
[] =
15083 /* 0 */ { WAIT_TIMEOUT
, WAIT_TIMEOUT
, FALSE
},
15084 { WAIT_TIMEOUT
, 0, FALSE
},
15085 { WAIT_TIMEOUT
, 0, FALSE
},
15086 { WAIT_TIMEOUT
, WAIT_TIMEOUT
, FALSE
},
15087 { WAIT_TIMEOUT
, WAIT_TIMEOUT
, FALSE
},
15088 /* 5 */ { WAIT_TIMEOUT
, 0, FALSE
},
15089 { WAIT_TIMEOUT
, 0, FALSE
},
15090 { WAIT_TIMEOUT
, WAIT_TIMEOUT
, FALSE
},
15093 /* 10 */ { 0, 0, FALSE
},
15095 { 0, WAIT_TIMEOUT
, FALSE
},
15098 /* 15 */ { 0, 0, FALSE
},
15099 { WAIT_TIMEOUT
, 0, FALSE
},
15100 { WAIT_TIMEOUT
, 0, FALSE
},
15101 { WAIT_TIMEOUT
, 0, FALSE
},
15102 { WAIT_TIMEOUT
, 0, FALSE
},
15103 /* 20 */ { WAIT_TIMEOUT
, 0, FALSE
},
15106 static DWORD CALLBACK
do_wait_idle_child_thread( void *arg
)
15110 PeekMessageA( &msg
, 0, 0, 0, PM_NOREMOVE
);
15112 MsgWaitForMultipleObjects( 0, NULL
, FALSE
, 100, QS_ALLINPUT
);
15116 static void do_wait_idle_child( int arg
)
15123 HANDLE start_event
= OpenEventA( EVENT_ALL_ACCESS
, FALSE
, "test_WaitForInputIdle_start" );
15124 HANDLE end_event
= OpenEventA( EVENT_ALL_ACCESS
, FALSE
, "test_WaitForInputIdle_end" );
15126 memset( &cls
, 0, sizeof(cls
) );
15127 cls
.lpfnWndProc
= DefWindowProcA
;
15128 cls
.hbrBackground
= (HBRUSH
)(COLOR_WINDOW
+ 1);
15129 cls
.hCursor
= LoadCursorA(0, (LPCSTR
)IDC_ARROW
);
15130 cls
.lpszClassName
= "TestClass";
15131 RegisterClassA( &cls
);
15133 PeekMessageA( &msg
, 0, 0, 0, PM_NOREMOVE
); /* create the msg queue */
15135 ok( start_event
!= 0, "failed to create start event, error %u\n", GetLastError() );
15136 ok( end_event
!= 0, "failed to create end event, error %u\n", GetLastError() );
15141 SetEvent( start_event
);
15144 SetEvent( start_event
);
15146 PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
);
15149 SetEvent( start_event
);
15151 PeekMessageA( &msg
, 0, 0, 0, PM_NOREMOVE
);
15152 PostThreadMessageA( GetCurrentThreadId(), WM_COMMAND
, 0x1234, 0xabcd );
15153 PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
);
15156 SetEvent( start_event
);
15158 SendMessageA( HWND_BROADCAST
, WM_WININICHANGE
, 0, 0 );
15161 SetEvent( start_event
);
15163 hwnd
= CreateWindowExA(0, "TestClass", NULL
, WS_POPUP
|WS_VISIBLE
, 0, 0, 10, 10, 0, 0, 0, NULL
);
15164 while (PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
|PM_NOYIELD
)) DispatchMessageA( &msg
);
15167 SetEvent( start_event
);
15169 hwnd
= CreateWindowExA(0, "TestClass", NULL
, WS_POPUP
|WS_VISIBLE
, 0, 0, 10, 10, 0, 0, 0, NULL
);
15170 while (PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA( &msg
);
15173 SetEvent( start_event
);
15175 hwnd
= CreateWindowExA(0, "TestClass", NULL
, WS_POPUP
|WS_VISIBLE
, 0, 0, 10, 10, 0, 0, 0, NULL
);
15176 while (PeekMessageA( &msg
, 0, 0, 0, PM_NOREMOVE
))
15178 GetMessageA( &msg
, 0, 0, 0 );
15179 DispatchMessageA( &msg
);
15183 SetEvent( start_event
);
15185 hwnd
= CreateWindowExA(0, "TestClass", NULL
, WS_POPUP
|WS_VISIBLE
, 0, 0, 10, 10, 0, 0, 0, NULL
);
15186 SetTimer( hwnd
, 3, 1, NULL
);
15188 while (PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
|PM_NOYIELD
)) DispatchMessageA( &msg
);
15191 SetEvent( start_event
);
15193 PeekMessageA( &msg
, 0, 0, 0, PM_NOREMOVE
);
15194 MsgWaitForMultipleObjects( 0, NULL
, FALSE
, 100, QS_ALLINPUT
);
15197 SetEvent( start_event
);
15199 hwnd
= CreateWindowExA(0, "TestClass", NULL
, WS_POPUP
|WS_VISIBLE
, 0, 0, 10, 10, 0, 0, 0, NULL
);
15200 while (PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA( &msg
);
15201 for (;;) GetMessageA( &msg
, 0, 0, 0 );
15204 SetEvent( start_event
);
15206 hwnd
= CreateWindowExA(0, "TestClass", NULL
, WS_POPUP
|WS_VISIBLE
, 0, 0, 10, 10, 0, 0, 0, NULL
);
15207 SetTimer( hwnd
, 3, 1, NULL
);
15209 while (PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA( &msg
);
15212 SetEvent( start_event
);
15214 return; /* exiting the process makes WaitForInputIdle return success too */
15216 PeekMessageA( &msg
, 0, 0, 0, PM_NOREMOVE
);
15218 MsgWaitForMultipleObjects( 0, NULL
, FALSE
, 100, QS_ALLINPUT
);
15219 SetEvent( start_event
);
15222 SetEvent( start_event
);
15223 PeekMessageA( &msg
, 0, 0, 0, PM_NOREMOVE
);
15225 thread
= CreateThread( NULL
, 0, do_wait_idle_child_thread
, NULL
, 0, &id
);
15226 WaitForSingleObject( thread
, 10000 );
15227 CloseHandle( thread
);
15230 SetEvent( start_event
);
15232 PeekMessageA( &msg
, HWND_TOPMOST
, 0, 0, PM_NOREMOVE
);
15235 SetEvent( start_event
);
15237 PeekMessageA( &msg
, HWND_BROADCAST
, 0, 0, PM_NOREMOVE
);
15240 SetEvent( start_event
);
15242 PeekMessageA( &msg
, HWND_BOTTOM
, 0, 0, PM_NOREMOVE
);
15245 SetEvent( start_event
);
15247 PeekMessageA( &msg
, (HWND
)0xdeadbeef, 0, 0, PM_NOREMOVE
);
15250 SetEvent( start_event
);
15252 PeekMessageA( &msg
, HWND_NOTOPMOST
, 0, 0, PM_NOREMOVE
);
15255 SetEvent( start_event
);
15257 PeekMessageA( &msg
, HWND_MESSAGE
, 0, 0, PM_NOREMOVE
);
15260 SetEvent( start_event
);
15262 PeekMessageA( &msg
, GetDesktopWindow(), 0, 0, PM_NOREMOVE
);
15265 WaitForSingleObject( end_event
, 2000 );
15266 CloseHandle( start_event
);
15267 CloseHandle( end_event
);
15268 if (hwnd
) DestroyWindow( hwnd
);
15271 static LRESULT CALLBACK
wait_idle_proc( HWND hwnd
, UINT msg
, WPARAM wp
, LPARAM lp
)
15273 if (msg
== WM_WININICHANGE
) Sleep( 200 ); /* make sure the child waits */
15274 return DefWindowProcA( hwnd
, msg
, wp
, lp
);
15277 static DWORD CALLBACK
wait_idle_thread( void *arg
)
15283 memset( &cls
, 0, sizeof(cls
) );
15284 cls
.lpfnWndProc
= wait_idle_proc
;
15285 cls
.hbrBackground
= (HBRUSH
)(COLOR_WINDOW
+ 1);
15286 cls
.hCursor
= LoadCursorA(0, (LPCSTR
)IDC_ARROW
);
15287 cls
.lpszClassName
= "TestClass";
15288 RegisterClassA( &cls
);
15290 hwnd
= CreateWindowExA(0, "TestClass", NULL
, WS_POPUP
, 0, 0, 10, 10, 0, 0, 0, NULL
);
15291 while (GetMessageA( &msg
, 0, 0, 0 )) DispatchMessageA( &msg
);
15292 DestroyWindow(hwnd
);
15296 static void test_WaitForInputIdle( char *argv0
)
15298 char path
[MAX_PATH
];
15299 PROCESS_INFORMATION pi
;
15300 STARTUPINFOA startup
;
15302 HANDLE start_event
, end_event
, thread
;
15305 const IMAGE_DOS_HEADER
*dos
= (const IMAGE_DOS_HEADER
*)GetModuleHandleA(0);
15306 const IMAGE_NT_HEADERS
*nt
= (const IMAGE_NT_HEADERS
*)((const char *)dos
+ dos
->e_lfanew
);
15307 BOOL console_app
= (nt
->OptionalHeader
.Subsystem
!= IMAGE_SUBSYSTEM_WINDOWS_GUI
);
15309 if (console_app
) /* build the test with -mwindows for better coverage */
15310 trace( "not built as a GUI app, WaitForInputIdle may not be fully tested\n" );
15312 start_event
= CreateEventA(NULL
, 0, 0, "test_WaitForInputIdle_start");
15313 end_event
= CreateEventA(NULL
, 0, 0, "test_WaitForInputIdle_end");
15314 ok(start_event
!= 0, "failed to create start event, error %u\n", GetLastError());
15315 ok(end_event
!= 0, "failed to create end event, error %u\n", GetLastError());
15317 memset( &startup
, 0, sizeof(startup
) );
15318 startup
.cb
= sizeof(startup
);
15319 startup
.dwFlags
= STARTF_USESHOWWINDOW
;
15320 startup
.wShowWindow
= SW_SHOWNORMAL
;
15322 thread
= CreateThread( NULL
, 0, wait_idle_thread
, NULL
, 0, &id
);
15324 for (i
= 0; i
< sizeof(wait_idle_expect
)/sizeof(wait_idle_expect
[0]); i
++)
15326 ResetEvent( start_event
);
15327 ResetEvent( end_event
);
15328 sprintf( path
, "%s msg %u", argv0
, i
);
15329 ret
= CreateProcessA( NULL
, path
, NULL
, NULL
, TRUE
, 0, NULL
, NULL
, &startup
, &pi
);
15330 ok( ret
, "CreateProcess '%s' failed err %u.\n", path
, GetLastError() );
15333 ret
= WaitForSingleObject( start_event
, 5000 );
15334 ok( ret
== WAIT_OBJECT_0
, "%u: WaitForSingleObject failed\n", i
);
15335 if (ret
== WAIT_OBJECT_0
)
15337 ret
= WaitForInputIdle( pi
.hProcess
, 1000 );
15338 if (ret
== WAIT_FAILED
)
15340 ret
== wait_idle_expect
[i
].exp
||
15341 broken(ret
== wait_idle_expect
[i
].broken
),
15342 "%u: WaitForInputIdle error %08x expected %08x\n",
15343 i
, ret
, wait_idle_expect
[i
].exp
);
15344 else todo_wine_if (wait_idle_expect
[i
].todo
)
15345 ok( ret
== wait_idle_expect
[i
].exp
|| broken(ret
== wait_idle_expect
[i
].broken
),
15346 "%u: WaitForInputIdle error %08x expected %08x\n",
15347 i
, ret
, wait_idle_expect
[i
].exp
);
15348 SetEvent( end_event
);
15349 WaitForSingleObject( pi
.hProcess
, 1000 ); /* give it a chance to exit on its own */
15351 TerminateProcess( pi
.hProcess
, 0 ); /* just in case */
15352 winetest_wait_child_process( pi
.hProcess
);
15353 ret
= WaitForInputIdle( pi
.hProcess
, 100 );
15354 ok( ret
== WAIT_FAILED
, "%u: WaitForInputIdle after exit error %08x\n", i
, ret
);
15355 CloseHandle( pi
.hProcess
);
15356 CloseHandle( pi
.hThread
);
15359 CloseHandle( start_event
);
15360 PostThreadMessageA( id
, WM_QUIT
, 0, 0 );
15361 WaitForSingleObject( thread
, 10000 );
15362 CloseHandle( thread
);
15365 static const struct message WmSetParentSeq_1
[] = {
15366 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
15367 { EVENT_OBJECT_PARENTCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
15368 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
},
15369 { WM_CHILDACTIVATE
, sent
},
15370 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOSIZE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
},
15371 { WM_MOVE
, sent
|defwinproc
|wparam
, 0 },
15372 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
15373 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
15377 static const struct message WmSetParentSeq_2
[] = {
15378 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
15379 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
15380 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
15381 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
15382 { HCBT_SETFOCUS
, hook
|optional
},
15383 { WM_NCACTIVATE
, sent
|wparam
|optional
, 0 },
15384 { WM_ACTIVATE
, sent
|wparam
|optional
, 0 },
15385 { WM_ACTIVATEAPP
, sent
|wparam
|optional
, 0 },
15386 { WM_KILLFOCUS
, sent
|wparam
, 0 },
15387 { EVENT_OBJECT_PARENTCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
15388 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
},
15389 { HCBT_ACTIVATE
, hook
|optional
},
15390 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
15391 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
15392 { WM_NCACTIVATE
, sent
|wparam
|optional
, 1 },
15393 { WM_ACTIVATE
, sent
|wparam
|optional
, 1 },
15394 { HCBT_SETFOCUS
, hook
|optional
},
15395 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
15396 { WM_SETFOCUS
, sent
|optional
|defwinproc
},
15397 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOREDRAW
|SWP_NOSIZE
|SWP_NOCLIENTSIZE
},
15398 { WM_MOVE
, sent
|defwinproc
|wparam
, 0 },
15399 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
15400 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
15401 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
15402 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
15403 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
15408 static void test_SetParent(void)
15410 HWND parent1
, parent2
, child
, popup
;
15413 parent1
= CreateWindowExA(0, "TestParentClass", NULL
, WS_OVERLAPPEDWINDOW
,
15414 100, 100, 200, 200, 0, 0, 0, NULL
);
15415 ok(parent1
!= 0, "Failed to create parent1 window\n");
15417 parent2
= CreateWindowExA(0, "TestParentClass", NULL
, WS_OVERLAPPEDWINDOW
,
15418 400, 100, 200, 200, 0, 0, 0, NULL
);
15419 ok(parent2
!= 0, "Failed to create parent2 window\n");
15421 /* WS_CHILD window */
15422 child
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_CHILD
| WS_VISIBLE
,
15423 10, 10, 150, 150, parent1
, 0, 0, NULL
);
15424 ok(child
!= 0, "Failed to create child window\n");
15426 GetWindowRect(parent1
, &rc
);
15427 trace("parent1 %s\n", wine_dbgstr_rect(&rc
));
15428 GetWindowRect(child
, &rc_old
);
15429 MapWindowPoints(0, parent1
, (POINT
*)&rc_old
, 2);
15430 trace("child %s\n", wine_dbgstr_rect(&rc_old
));
15434 SetParent(child
, parent2
);
15436 ok_sequence(WmSetParentSeq_1
, "SetParent() visible WS_CHILD", TRUE
);
15438 ok(GetWindowLongA(child
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
15439 ok(!IsWindowVisible(child
), "IsWindowVisible() should return FALSE\n");
15441 GetWindowRect(parent2
, &rc
);
15442 trace("parent2 %s\n", wine_dbgstr_rect(&rc
));
15443 GetWindowRect(child
, &rc
);
15444 MapWindowPoints(0, parent2
, (POINT
*)&rc
, 2);
15445 trace("child %s\n", wine_dbgstr_rect(&rc
));
15447 ok(EqualRect(&rc_old
, &rc
), "rects do not match %s / %s\n", wine_dbgstr_rect(&rc_old
),
15448 wine_dbgstr_rect(&rc
));
15450 /* WS_POPUP window */
15451 popup
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_POPUP
| WS_VISIBLE
,
15452 20, 20, 100, 100, 0, 0, 0, NULL
);
15453 ok(popup
!= 0, "Failed to create popup window\n");
15455 GetWindowRect(popup
, &rc_old
);
15456 trace("popup %s\n", wine_dbgstr_rect(&rc_old
));
15460 SetParent(popup
, child
);
15462 ok_sequence(WmSetParentSeq_2
, "SetParent() visible WS_POPUP", TRUE
);
15464 ok(GetWindowLongA(popup
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
15465 ok(!IsWindowVisible(popup
), "IsWindowVisible() should return FALSE\n");
15467 GetWindowRect(child
, &rc
);
15468 trace("parent2 %s\n", wine_dbgstr_rect(&rc
));
15469 GetWindowRect(popup
, &rc
);
15470 MapWindowPoints(0, child
, (POINT
*)&rc
, 2);
15471 trace("popup %s\n", wine_dbgstr_rect(&rc
));
15473 ok(EqualRect(&rc_old
, &rc
), "rects do not match %s / %s\n", wine_dbgstr_rect(&rc_old
),
15474 wine_dbgstr_rect(&rc
));
15476 DestroyWindow(popup
);
15477 DestroyWindow(child
);
15478 DestroyWindow(parent1
);
15479 DestroyWindow(parent2
);
15484 static const struct message WmKeyReleaseOnly
[] = {
15485 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 0x41, 0x80000001 },
15486 { WM_KEYUP
, sent
|wparam
|lparam
, 0x41, 0x80000001 },
15489 static const struct message WmKeyPressNormal
[] = {
15490 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 0x41, 0x1 },
15491 { WM_KEYDOWN
, sent
|wparam
|lparam
, 0x41, 0x1 },
15494 static const struct message WmKeyPressRepeat
[] = {
15495 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 0x41, 0x40000001 },
15496 { WM_KEYDOWN
, sent
|wparam
|lparam
, 0x41, 0x40000001 },
15499 static const struct message WmKeyReleaseNormal
[] = {
15500 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 0x41, 0xc0000001 },
15501 { WM_KEYUP
, sent
|wparam
|lparam
, 0x41, 0xc0000001 },
15505 static void test_keyflags(void)
15509 BYTE keyboard_state
[256];
15512 test_window
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
15513 100, 100, 200, 200, 0, 0, 0, NULL
);
15518 /* keyup without a keydown */
15519 keybd_event(0x41, 0, KEYEVENTF_KEYUP
, 0);
15520 while (PeekMessageA(&msg
, NULL
, WM_KEYFIRST
, WM_KEYLAST
, PM_REMOVE
))
15521 DispatchMessageA(&msg
);
15522 ok_sequence(WmKeyReleaseOnly
, "key release only", TRUE
);
15524 key_state
= GetAsyncKeyState(0x41);
15525 ok((key_state
& 0x8000) == 0, "unexpected key state %x\n", key_state
);
15527 key_state
= GetKeyState(0x41);
15528 ok((key_state
& 0x8000) == 0, "unexpected key state %x\n", key_state
);
15531 keybd_event(0x41, 0, 0, 0);
15532 while (PeekMessageA(&msg
, NULL
, WM_KEYFIRST
, WM_KEYLAST
, PM_REMOVE
))
15533 DispatchMessageA(&msg
);
15534 ok_sequence(WmKeyPressNormal
, "key press only", FALSE
);
15536 key_state
= GetAsyncKeyState(0x41);
15537 ok((key_state
& 0x8000) == 0x8000, "unexpected key state %x\n", key_state
);
15539 key_state
= GetKeyState(0x41);
15540 ok((key_state
& 0x8000) == 0x8000, "unexpected key state %x\n", key_state
);
15542 /* keydown repeat */
15543 keybd_event(0x41, 0, 0, 0);
15544 while (PeekMessageA(&msg
, NULL
, WM_KEYFIRST
, WM_KEYLAST
, PM_REMOVE
))
15545 DispatchMessageA(&msg
);
15546 ok_sequence(WmKeyPressRepeat
, "key press repeat", FALSE
);
15548 key_state
= GetAsyncKeyState(0x41);
15549 ok((key_state
& 0x8000) == 0x8000, "unexpected key state %x\n", key_state
);
15551 key_state
= GetKeyState(0x41);
15552 ok((key_state
& 0x8000) == 0x8000, "unexpected key state %x\n", key_state
);
15555 keybd_event(0x41, 0, KEYEVENTF_KEYUP
, 0);
15556 while (PeekMessageA(&msg
, NULL
, WM_KEYFIRST
, WM_KEYLAST
, PM_REMOVE
))
15557 DispatchMessageA(&msg
);
15558 ok_sequence(WmKeyReleaseNormal
, "key release repeat", FALSE
);
15560 key_state
= GetAsyncKeyState(0x41);
15561 ok((key_state
& 0x8000) == 0, "unexpected key state %x\n", key_state
);
15563 key_state
= GetKeyState(0x41);
15564 ok((key_state
& 0x8000) == 0, "unexpected key state %x\n", key_state
);
15566 /* set the key state in this thread */
15567 GetKeyboardState(keyboard_state
);
15568 keyboard_state
[0x41] = 0x80;
15569 SetKeyboardState(keyboard_state
);
15571 key_state
= GetAsyncKeyState(0x41);
15572 ok((key_state
& 0x8000) == 0, "unexpected key state %x\n", key_state
);
15575 keybd_event(0x41, 0, 0, 0);
15576 while (PeekMessageA(&msg
, NULL
, WM_KEYFIRST
, WM_KEYLAST
, PM_REMOVE
))
15577 DispatchMessageA(&msg
);
15578 ok_sequence(WmKeyPressRepeat
, "key press after setkeyboardstate", TRUE
);
15580 key_state
= GetAsyncKeyState(0x41);
15581 ok((key_state
& 0x8000) == 0x8000, "unexpected key state %x\n", key_state
);
15583 key_state
= GetKeyState(0x41);
15584 ok((key_state
& 0x8000) == 0x8000, "unexpected key state %x\n", key_state
);
15586 /* clear the key state in this thread */
15587 GetKeyboardState(keyboard_state
);
15588 keyboard_state
[0x41] = 0;
15589 SetKeyboardState(keyboard_state
);
15591 key_state
= GetAsyncKeyState(0x41);
15592 ok((key_state
& 0x8000) == 0x8000, "unexpected key state %x\n", key_state
);
15595 keybd_event(0x41, 0, KEYEVENTF_KEYUP
, 0);
15596 while (PeekMessageA(&msg
, NULL
, WM_KEYFIRST
, WM_KEYLAST
, PM_REMOVE
))
15597 DispatchMessageA(&msg
);
15598 ok_sequence(WmKeyReleaseOnly
, "key release after setkeyboardstate", TRUE
);
15600 key_state
= GetAsyncKeyState(0x41);
15601 ok((key_state
& 0x8000) == 0, "unexpected key state %x\n", key_state
);
15603 key_state
= GetKeyState(0x41);
15604 ok((key_state
& 0x8000) == 0, "unexpected key state %x\n", key_state
);
15606 DestroyWindow(test_window
);
15610 static const struct message WmHotkeyPressLWIN
[] = {
15611 { WM_KEYDOWN
, kbd_hook
|wparam
|lparam
, VK_LWIN
, LLKHF_INJECTED
},
15612 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_LWIN
, 1 },
15613 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_LWIN
, 1 },
15616 static const struct message WmHotkeyPress
[] = {
15617 { WM_KEYDOWN
, kbd_hook
|lparam
, 0, LLKHF_INJECTED
},
15618 { WM_HOTKEY
, sent
|wparam
, 5 },
15621 static const struct message WmHotkeyRelease
[] = {
15622 { WM_KEYUP
, kbd_hook
|lparam
, 0, LLKHF_INJECTED
|LLKHF_UP
},
15623 { HCBT_KEYSKIPPED
, hook
|lparam
|optional
, 0, 0x80000001 },
15624 { WM_KEYUP
, sent
|lparam
, 0, 0x80000001 },
15627 static const struct message WmHotkeyReleaseLWIN
[] = {
15628 { WM_KEYUP
, kbd_hook
|wparam
|lparam
, VK_LWIN
, LLKHF_INJECTED
|LLKHF_UP
},
15629 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_LWIN
, 0xc0000001 },
15630 { WM_KEYUP
, sent
|wparam
|lparam
, VK_LWIN
, 0xc0000001 },
15633 static const struct message WmHotkeyCombined
[] = {
15634 { WM_KEYDOWN
, kbd_hook
|wparam
|lparam
, VK_LWIN
, LLKHF_INJECTED
},
15635 { WM_KEYDOWN
, kbd_hook
|lparam
, 0, LLKHF_INJECTED
},
15636 { WM_KEYUP
, kbd_hook
|lparam
, 0, LLKHF_INJECTED
|LLKHF_UP
},
15637 { WM_KEYUP
, kbd_hook
|wparam
|lparam
, VK_LWIN
, LLKHF_INJECTED
|LLKHF_UP
},
15638 { WM_APP
, sent
, 0, 0 },
15639 { WM_HOTKEY
, sent
|wparam
, 5 },
15640 { WM_APP
+1, sent
, 0, 0 },
15641 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_LWIN
, 1 },
15642 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_LWIN
, 1 },
15643 { HCBT_KEYSKIPPED
, hook
|optional
, 0, 0x80000001 },
15644 { WM_KEYUP
, sent
, 0, 0x80000001 }, /* lparam not checked so the sequence isn't a todo */
15645 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_LWIN
, 0xc0000001 },
15646 { WM_KEYUP
, sent
|wparam
|lparam
, VK_LWIN
, 0xc0000001 },
15649 static const struct message WmHotkeyPrevious
[] = {
15650 { WM_KEYDOWN
, kbd_hook
|wparam
|lparam
, VK_LWIN
, LLKHF_INJECTED
},
15651 { WM_KEYDOWN
, kbd_hook
|lparam
, 0, LLKHF_INJECTED
},
15652 { WM_KEYUP
, kbd_hook
|lparam
, 0, LLKHF_INJECTED
|LLKHF_UP
},
15653 { WM_KEYUP
, kbd_hook
|wparam
|lparam
, VK_LWIN
, LLKHF_INJECTED
|LLKHF_UP
},
15654 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_LWIN
, 1 },
15655 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_LWIN
, 1 },
15656 { HCBT_KEYSKIPPED
, hook
|lparam
|optional
, 0, 1 },
15657 { WM_KEYDOWN
, sent
|lparam
, 0, 1 },
15658 { HCBT_KEYSKIPPED
, hook
|optional
|lparam
, 0, 0xc0000001 },
15659 { WM_KEYUP
, sent
|lparam
, 0, 0xc0000001 },
15660 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_LWIN
, 0xc0000001 },
15661 { WM_KEYUP
, sent
|wparam
|lparam
, VK_LWIN
, 0xc0000001 },
15664 static const struct message WmHotkeyNew
[] = {
15665 { WM_KEYDOWN
, kbd_hook
|lparam
, 0, LLKHF_INJECTED
},
15666 { WM_KEYUP
, kbd_hook
|lparam
, 0, LLKHF_INJECTED
|LLKHF_UP
},
15667 { WM_HOTKEY
, sent
|wparam
, 5 },
15668 { HCBT_KEYSKIPPED
, hook
|optional
, 0, 0x80000001 },
15669 { WM_KEYUP
, sent
, 0, 0x80000001 }, /* lparam not checked so the sequence isn't a todo */
15673 static int hotkey_letter
;
15675 static LRESULT CALLBACK
KeyboardHookProc(int nCode
, WPARAM wParam
, LPARAM lParam
)
15677 struct recvd_message msg
;
15679 if (nCode
== HC_ACTION
)
15681 KBDLLHOOKSTRUCT
*kdbhookstruct
= (KBDLLHOOKSTRUCT
*)lParam
;
15684 msg
.message
= wParam
;
15685 msg
.flags
= kbd_hook
|wparam
|lparam
;
15686 msg
.wParam
= kdbhookstruct
->vkCode
;
15687 msg
.lParam
= kdbhookstruct
->flags
;
15688 msg
.descr
= "KeyboardHookProc";
15691 if (wParam
== WM_KEYUP
|| wParam
== WM_KEYDOWN
)
15693 ok(kdbhookstruct
->vkCode
== VK_LWIN
|| kdbhookstruct
->vkCode
== hotkey_letter
,
15694 "unexpected keycode %x\n", kdbhookstruct
->vkCode
);
15698 return CallNextHookEx(hKBD_hook
, nCode
, wParam
, lParam
);
15701 static void test_hotkey(void)
15703 HWND test_window
, taskbar_window
;
15706 DWORD queue_status
;
15709 SetLastError(0xdeadbeef);
15710 ret
= UnregisterHotKey(NULL
, 0);
15711 ok(ret
== FALSE
, "expected FALSE, got %i\n", ret
);
15712 ok(GetLastError() == ERROR_HOTKEY_NOT_REGISTERED
|| broken(GetLastError() == 0xdeadbeef),
15713 "unexpected error %d\n", GetLastError());
15717 skip("hotkeys not supported\n");
15721 test_window
= CreateWindowExA(0, "HotkeyWindowClass", NULL
, WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
15722 100, 100, 200, 200, 0, 0, 0, NULL
);
15726 SetLastError(0xdeadbeef);
15727 ret
= UnregisterHotKey(test_window
, 0);
15728 ok(ret
== FALSE
, "expected FALSE, got %i\n", ret
);
15729 ok(GetLastError() == ERROR_HOTKEY_NOT_REGISTERED
|| broken(GetLastError() == 0xdeadbeef),
15730 "unexpected error %d\n", GetLastError());
15732 /* Search for a Windows Key + letter combination that hasn't been registered */
15733 for (hotkey_letter
= 0x41; hotkey_letter
<= 0x51; hotkey_letter
++)
15735 SetLastError(0xdeadbeef);
15736 ret
= RegisterHotKey(test_window
, 5, MOD_WIN
, hotkey_letter
);
15744 ok(GetLastError() == ERROR_HOTKEY_ALREADY_REGISTERED
|| broken(GetLastError() == 0xdeadbeef),
15745 "unexpected error %d\n", GetLastError());
15749 if (hotkey_letter
== 0x52)
15751 ok(0, "Couldn't find any free Windows Key + letter combination\n");
15755 hKBD_hook
= SetWindowsHookExA(WH_KEYBOARD_LL
, KeyboardHookProc
, GetModuleHandleA(NULL
), 0);
15756 if (!hKBD_hook
) win_skip("WH_KEYBOARD_LL is not supported\n");
15758 /* Same key combination, different id */
15759 SetLastError(0xdeadbeef);
15760 ret
= RegisterHotKey(test_window
, 4, MOD_WIN
, hotkey_letter
);
15761 ok(ret
== FALSE
, "expected FALSE, got %i\n", ret
);
15762 ok(GetLastError() == ERROR_HOTKEY_ALREADY_REGISTERED
|| broken(GetLastError() == 0xdeadbeef),
15763 "unexpected error %d\n", GetLastError());
15765 /* Same key combination, different window */
15766 SetLastError(0xdeadbeef);
15767 ret
= RegisterHotKey(NULL
, 5, MOD_WIN
, hotkey_letter
);
15768 ok(ret
== FALSE
, "expected FALSE, got %i\n", ret
);
15769 ok(GetLastError() == ERROR_HOTKEY_ALREADY_REGISTERED
|| broken(GetLastError() == 0xdeadbeef),
15770 "unexpected error %d\n", GetLastError());
15772 /* Register the same hotkey twice */
15773 SetLastError(0xdeadbeef);
15774 ret
= RegisterHotKey(test_window
, 5, MOD_WIN
, hotkey_letter
);
15775 ok(ret
== FALSE
, "expected FALSE, got %i\n", ret
);
15776 ok(GetLastError() == ERROR_HOTKEY_ALREADY_REGISTERED
|| broken(GetLastError() == 0xdeadbeef),
15777 "unexpected error %d\n", GetLastError());
15779 /* Window on another thread */
15780 taskbar_window
= FindWindowA("Shell_TrayWnd", NULL
);
15781 if (!taskbar_window
)
15783 skip("no taskbar?\n");
15787 SetLastError(0xdeadbeef);
15788 ret
= RegisterHotKey(taskbar_window
, 5, 0, hotkey_letter
);
15789 ok(ret
== FALSE
, "expected FALSE, got %i\n", ret
);
15790 ok(GetLastError() == ERROR_WINDOW_OF_OTHER_THREAD
|| broken(GetLastError() == 0xdeadbeef),
15791 "unexpected error %d\n", GetLastError());
15794 /* Inject the appropriate key sequence */
15795 keybd_event(VK_LWIN
, 0, 0, 0);
15796 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
))
15797 DispatchMessageA(&msg
);
15798 ok_sequence(WmHotkeyPressLWIN
, "window hotkey press LWIN", FALSE
);
15800 keybd_event(hotkey_letter
, 0, 0, 0);
15801 queue_status
= GetQueueStatus(QS_HOTKEY
);
15802 ok((queue_status
& (QS_HOTKEY
<< 16)) == QS_HOTKEY
<< 16, "expected QS_HOTKEY << 16 set, got %x\n", queue_status
);
15803 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
))
15805 if (msg
.message
== WM_HOTKEY
)
15807 ok(msg
.hwnd
== test_window
, "unexpected hwnd %p\n", msg
.hwnd
);
15808 ok(msg
.lParam
== MAKELPARAM(MOD_WIN
, hotkey_letter
), "unexpected WM_HOTKEY lparam %lx\n", msg
.lParam
);
15810 DispatchMessageA(&msg
);
15812 ok_sequence(WmHotkeyPress
, "window hotkey press", FALSE
);
15814 queue_status
= GetQueueStatus(QS_HOTKEY
);
15815 ok((queue_status
& (QS_HOTKEY
<< 16)) == 0, "expected QS_HOTKEY << 16 cleared, got %x\n", queue_status
);
15817 key_state
= GetAsyncKeyState(hotkey_letter
);
15818 ok((key_state
& 0x8000) == 0x8000, "unexpected key state %x\n", key_state
);
15820 keybd_event(hotkey_letter
, 0, KEYEVENTF_KEYUP
, 0);
15821 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
))
15822 DispatchMessageA(&msg
);
15823 ok_sequence(WmHotkeyRelease
, "window hotkey release", TRUE
);
15825 keybd_event(VK_LWIN
, 0, KEYEVENTF_KEYUP
, 0);
15826 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
))
15827 DispatchMessageA(&msg
);
15828 ok_sequence(WmHotkeyReleaseLWIN
, "window hotkey release LWIN", FALSE
);
15830 /* normal posted WM_HOTKEY messages set QS_HOTKEY */
15831 PostMessageA(test_window
, WM_HOTKEY
, 0, 0);
15832 queue_status
= GetQueueStatus(QS_HOTKEY
);
15833 ok((queue_status
& (QS_HOTKEY
<< 16)) == QS_HOTKEY
<< 16, "expected QS_HOTKEY << 16 set, got %x\n", queue_status
);
15834 queue_status
= GetQueueStatus(QS_POSTMESSAGE
);
15835 ok((queue_status
& (QS_POSTMESSAGE
<< 16)) == QS_POSTMESSAGE
<< 16, "expected QS_POSTMESSAGE << 16 set, got %x\n", queue_status
);
15836 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
))
15837 DispatchMessageA(&msg
);
15840 /* Send and process all messages at once */
15841 PostMessageA(test_window
, WM_APP
, 0, 0);
15842 keybd_event(VK_LWIN
, 0, 0, 0);
15843 keybd_event(hotkey_letter
, 0, 0, 0);
15844 keybd_event(hotkey_letter
, 0, KEYEVENTF_KEYUP
, 0);
15845 keybd_event(VK_LWIN
, 0, KEYEVENTF_KEYUP
, 0);
15847 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
))
15849 if (msg
.message
== WM_HOTKEY
)
15851 ok(msg
.hwnd
== test_window
, "unexpected hwnd %p\n", msg
.hwnd
);
15852 ok(msg
.lParam
== MAKELPARAM(MOD_WIN
, hotkey_letter
), "unexpected WM_HOTKEY lparam %lx\n", msg
.lParam
);
15854 DispatchMessageA(&msg
);
15856 ok_sequence(WmHotkeyCombined
, "window hotkey combined", FALSE
);
15858 /* Register same hwnd/id with different key combination */
15859 ret
= RegisterHotKey(test_window
, 5, 0, hotkey_letter
);
15860 ok(ret
== TRUE
, "expected TRUE, got %i, err=%d\n", ret
, GetLastError());
15862 /* Previous key combination does not work */
15863 keybd_event(VK_LWIN
, 0, 0, 0);
15864 keybd_event(hotkey_letter
, 0, 0, 0);
15865 keybd_event(hotkey_letter
, 0, KEYEVENTF_KEYUP
, 0);
15866 keybd_event(VK_LWIN
, 0, KEYEVENTF_KEYUP
, 0);
15868 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
))
15869 DispatchMessageA(&msg
);
15870 ok_sequence(WmHotkeyPrevious
, "window hotkey previous", FALSE
);
15872 /* New key combination works */
15873 keybd_event(hotkey_letter
, 0, 0, 0);
15874 keybd_event(hotkey_letter
, 0, KEYEVENTF_KEYUP
, 0);
15876 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
))
15878 if (msg
.message
== WM_HOTKEY
)
15880 ok(msg
.hwnd
== test_window
, "unexpected hwnd %p\n", msg
.hwnd
);
15881 ok(msg
.lParam
== MAKELPARAM(0, hotkey_letter
), "unexpected WM_HOTKEY lparam %lx\n", msg
.lParam
);
15883 DispatchMessageA(&msg
);
15885 ok_sequence(WmHotkeyNew
, "window hotkey new", FALSE
);
15887 /* Unregister hotkey properly */
15888 ret
= UnregisterHotKey(test_window
, 5);
15889 ok(ret
== TRUE
, "expected TRUE, got %i, err=%d\n", ret
, GetLastError());
15891 /* Unregister hotkey again */
15892 SetLastError(0xdeadbeef);
15893 ret
= UnregisterHotKey(test_window
, 5);
15894 ok(ret
== FALSE
, "expected FALSE, got %i\n", ret
);
15895 ok(GetLastError() == ERROR_HOTKEY_NOT_REGISTERED
|| broken(GetLastError() == 0xdeadbeef),
15896 "unexpected error %d\n", GetLastError());
15898 /* Register thread hotkey */
15899 ret
= RegisterHotKey(NULL
, 5, MOD_WIN
, hotkey_letter
);
15900 ok(ret
== TRUE
, "expected TRUE, got %i, err=%d\n", ret
, GetLastError());
15902 /* Inject the appropriate key sequence */
15903 keybd_event(VK_LWIN
, 0, 0, 0);
15904 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
))
15906 ok(msg
.hwnd
!= NULL
, "unexpected thread message %x\n", msg
.message
);
15907 DispatchMessageA(&msg
);
15909 ok_sequence(WmHotkeyPressLWIN
, "thread hotkey press LWIN", FALSE
);
15911 keybd_event(hotkey_letter
, 0, 0, 0);
15912 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
))
15914 if (msg
.message
== WM_HOTKEY
)
15916 struct recvd_message message
;
15917 ok(msg
.hwnd
== NULL
, "unexpected hwnd %p\n", msg
.hwnd
);
15918 ok(msg
.lParam
== MAKELPARAM(MOD_WIN
, hotkey_letter
), "unexpected WM_HOTKEY lparam %lx\n", msg
.lParam
);
15919 message
.message
= msg
.message
;
15920 message
.flags
= sent
|wparam
|lparam
;
15921 message
.wParam
= msg
.wParam
;
15922 message
.lParam
= msg
.lParam
;
15923 message
.descr
= "test_hotkey thread message";
15924 add_message(&message
);
15927 ok(msg
.hwnd
!= NULL
, "unexpected thread message %x\n", msg
.message
);
15928 DispatchMessageA(&msg
);
15930 ok_sequence(WmHotkeyPress
, "thread hotkey press", FALSE
);
15932 keybd_event(hotkey_letter
, 0, KEYEVENTF_KEYUP
, 0);
15933 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
))
15935 ok(msg
.hwnd
!= NULL
, "unexpected thread message %x\n", msg
.message
);
15936 DispatchMessageA(&msg
);
15938 ok_sequence(WmHotkeyRelease
, "thread hotkey release", TRUE
);
15940 keybd_event(VK_LWIN
, 0, KEYEVENTF_KEYUP
, 0);
15941 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
))
15943 ok(msg
.hwnd
!= NULL
, "unexpected thread message %x\n", msg
.message
);
15944 DispatchMessageA(&msg
);
15946 ok_sequence(WmHotkeyReleaseLWIN
, "thread hotkey release LWIN", FALSE
);
15948 /* Unregister thread hotkey */
15949 ret
= UnregisterHotKey(NULL
, 5);
15950 ok(ret
== TRUE
, "expected TRUE, got %i, err=%d\n", ret
, GetLastError());
15952 if (hKBD_hook
) UnhookWindowsHookEx(hKBD_hook
);
15956 UnregisterHotKey(NULL
, 5);
15957 UnregisterHotKey(test_window
, 5);
15958 DestroyWindow(test_window
);
15963 static const struct message WmSetFocus_1
[] = {
15964 { HCBT_SETFOCUS
, hook
}, /* child */
15965 { HCBT_ACTIVATE
, hook
}, /* parent */
15966 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|parent
|optional
, 0, 0 },
15967 { WM_WINDOWPOSCHANGING
, sent
|parent
, 0, SWP_NOSIZE
|SWP_NOMOVE
},
15968 { WM_ACTIVATEAPP
, sent
|wparam
|parent
, 1 },
15969 { WM_NCACTIVATE
, sent
|parent
},
15970 { WM_GETTEXT
, sent
|defwinproc
|parent
|optional
},
15971 { WM_GETTEXT
, sent
|defwinproc
|parent
|optional
},
15972 { WM_ACTIVATE
, sent
|wparam
|parent
, 1 },
15973 { HCBT_SETFOCUS
, hook
}, /* parent */
15974 { WM_SETFOCUS
, sent
|defwinproc
|parent
},
15975 { WM_KILLFOCUS
, sent
|parent
},
15976 { WM_SETFOCUS
, sent
},
15979 static const struct message WmSetFocus_2
[] = {
15980 { HCBT_SETFOCUS
, hook
}, /* parent */
15981 { WM_KILLFOCUS
, sent
},
15982 { WM_SETFOCUS
, sent
|parent
},
15985 static const struct message WmSetFocus_3
[] = {
15986 { HCBT_SETFOCUS
, hook
}, /* child */
15990 static void test_SetFocus(void)
15992 HWND parent
, old_parent
, child
, old_focus
, old_active
;
15994 struct wnd_event wnd_event
;
15998 wnd_event
.start_event
= CreateEventW(NULL
, 0, 0, NULL
);
15999 ok(wnd_event
.start_event
!= 0, "CreateEvent error %d\n", GetLastError());
16000 hthread
= CreateThread(NULL
, 0, thread_proc
, &wnd_event
, 0, &tid
);
16001 ok(hthread
!= 0, "CreateThread error %d\n", GetLastError());
16002 ret
= WaitForSingleObject(wnd_event
.start_event
, INFINITE
);
16003 ok(ret
== WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
16004 CloseHandle(wnd_event
.start_event
);
16006 parent
= CreateWindowExA(0, "TestParentClass", NULL
, WS_OVERLAPPEDWINDOW
,
16007 0, 0, 0, 0, 0, 0, 0, NULL
);
16008 ok(parent
!= 0, "failed to create parent window\n");
16009 child
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_CHILD
,
16010 0, 0, 0, 0, parent
, 0, 0, NULL
);
16011 ok(child
!= 0, "failed to create child window\n");
16013 trace("parent %p, child %p, thread window %p\n", parent
, child
, wnd_event
.hwnd
);
16016 SetActiveWindow(0);
16021 ok(GetActiveWindow() == 0, "expected active 0, got %p\n", GetActiveWindow());
16022 ok(GetFocus() == 0, "expected focus 0, got %p\n", GetFocus());
16024 log_all_parent_messages
++;
16026 old_focus
= SetFocus(child
);
16027 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
16028 ok_sequence(WmSetFocus_1
, "SetFocus on a child window", TRUE
);
16029 ok(old_focus
== parent
, "expected old focus %p, got %p\n", parent
, old_focus
);
16030 ok(GetActiveWindow() == parent
, "expected active %p, got %p\n", parent
, GetActiveWindow());
16031 ok(GetFocus() == child
, "expected focus %p, got %p\n", child
, GetFocus());
16033 old_focus
= SetFocus(parent
);
16034 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
16035 ok_sequence(WmSetFocus_2
, "SetFocus on a parent window", FALSE
);
16036 ok(old_focus
== child
, "expected old focus %p, got %p\n", child
, old_focus
);
16037 ok(GetActiveWindow() == parent
, "expected active %p, got %p\n", parent
, GetActiveWindow());
16038 ok(GetFocus() == parent
, "expected focus %p, got %p\n", parent
, GetFocus());
16040 SetLastError(0xdeadbeef);
16041 old_focus
= SetFocus((HWND
)0xdeadbeef);
16042 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
|| broken(GetLastError() == 0xdeadbeef),
16043 "expected ERROR_INVALID_WINDOW_HANDLE, got %d\n", GetLastError());
16044 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
16045 ok_sequence(WmEmptySeq
, "SetFocus on an invalid window", FALSE
);
16046 ok(old_focus
== 0, "expected old focus 0, got %p\n", old_focus
);
16047 ok(GetActiveWindow() == parent
, "expected active %p, got %p\n", parent
, GetActiveWindow());
16048 ok(GetFocus() == parent
, "expected focus %p, got %p\n", parent
, GetFocus());
16050 SetLastError(0xdeadbeef);
16051 old_focus
= SetFocus(GetDesktopWindow());
16052 ok(GetLastError() == ERROR_ACCESS_DENIED
/* Vista+ */ ||
16053 broken(GetLastError() == 0xdeadbeef), "expected ERROR_ACCESS_DENIED, got %d\n", GetLastError());
16054 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
16055 ok_sequence(WmEmptySeq
, "SetFocus on a desktop window", TRUE
);
16056 ok(old_focus
== 0, "expected old focus 0, got %p\n", old_focus
);
16057 ok(GetActiveWindow() == parent
, "expected active %p, got %p\n", parent
, GetActiveWindow());
16058 ok(GetFocus() == parent
, "expected focus %p, got %p\n", parent
, GetFocus());
16060 SetLastError(0xdeadbeef);
16061 old_focus
= SetFocus(wnd_event
.hwnd
);
16062 ok(GetLastError() == ERROR_ACCESS_DENIED
/* Vista+ */ ||
16063 broken(GetLastError() == 0xdeadbeef), "expected ERROR_ACCESS_DENIED, got %d\n", GetLastError());
16064 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
16065 ok_sequence(WmEmptySeq
, "SetFocus on another thread window", TRUE
);
16066 ok(old_focus
== 0, "expected old focus 0, got %p\n", old_focus
);
16067 ok(GetActiveWindow() == parent
, "expected active %p, got %p\n", parent
, GetActiveWindow());
16068 ok(GetFocus() == parent
, "expected focus %p, got %p\n", parent
, GetFocus());
16070 SetLastError(0xdeadbeef);
16071 old_active
= SetActiveWindow((HWND
)0xdeadbeef);
16072 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
|| broken(GetLastError() == 0xdeadbeef),
16073 "expected ERROR_INVALID_WINDOW_HANDLE, got %d\n", GetLastError());
16074 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
16075 ok_sequence(WmEmptySeq
, "SetActiveWindow on an invalid window", FALSE
);
16076 ok(old_active
== 0, "expected old focus 0, got %p\n", old_active
);
16077 ok(GetActiveWindow() == parent
, "expected active %p, got %p\n", parent
, GetActiveWindow());
16078 ok(GetFocus() == parent
, "expected focus %p, got %p\n", parent
, GetFocus());
16080 SetLastError(0xdeadbeef);
16081 old_active
= SetActiveWindow(GetDesktopWindow());
16083 ok(GetLastError() == 0xdeadbeef, "expected 0xdeadbeef, got %d\n", GetLastError());
16084 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
16085 ok_sequence(WmEmptySeq
, "SetActiveWindow on a desktop window", TRUE
);
16086 ok(old_active
== 0, "expected old focus 0, got %p\n", old_focus
);
16087 ok(GetActiveWindow() == parent
, "expected active %p, got %p\n", parent
, GetActiveWindow());
16088 ok(GetFocus() == parent
, "expected focus %p, got %p\n", parent
, GetFocus());
16090 SetLastError(0xdeadbeef);
16091 old_active
= SetActiveWindow(wnd_event
.hwnd
);
16093 ok(GetLastError() == 0xdeadbeef, "expected 0xdeadbeef, got %d\n", GetLastError());
16094 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
16095 ok_sequence(WmEmptySeq
, "SetActiveWindow on another thread window", TRUE
);
16096 ok(old_active
== 0, "expected old focus 0, got %p\n", old_active
);
16097 ok(GetActiveWindow() == parent
, "expected active %p, got %p\n", parent
, GetActiveWindow());
16098 ok(GetFocus() == parent
, "expected focus %p, got %p\n", parent
, GetFocus());
16100 SetLastError(0xdeadbeef);
16101 ret
= AttachThreadInput(GetCurrentThreadId(), tid
, TRUE
);
16102 ok(ret
, "AttachThreadInput error %d\n", GetLastError());
16104 ok(GetActiveWindow() == parent
, "expected active %p, got %p\n", parent
, GetActiveWindow());
16105 ok(GetFocus() == parent
, "expected focus %p, got %p\n", parent
, GetFocus());
16110 old_focus
= SetFocus(wnd_event
.hwnd
);
16111 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
16112 ok(old_focus
== wnd_event
.hwnd
, "expected old focus %p, got %p\n", wnd_event
.hwnd
, old_focus
);
16113 ok(GetActiveWindow() == wnd_event
.hwnd
, "expected active %p, got %p\n", wnd_event
.hwnd
, GetActiveWindow());
16114 ok(GetFocus() == wnd_event
.hwnd
, "expected focus %p, got %p\n", wnd_event
.hwnd
, GetFocus());
16116 old_focus
= SetFocus(parent
);
16117 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
16118 ok(old_focus
== parent
, "expected old focus %p, got %p\n", parent
, old_focus
);
16119 ok(GetActiveWindow() == parent
, "expected active %p, got %p\n", parent
, GetActiveWindow());
16120 ok(GetFocus() == parent
, "expected focus %p, got %p\n", parent
, GetFocus());
16125 old_active
= SetActiveWindow(wnd_event
.hwnd
);
16126 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
16127 ok(old_active
== parent
, "expected old focus %p, got %p\n", parent
, old_active
);
16128 ok(GetActiveWindow() == wnd_event
.hwnd
, "expected active %p, got %p\n", wnd_event
.hwnd
, GetActiveWindow());
16129 ok(GetFocus() == wnd_event
.hwnd
, "expected focus %p, got %p\n", wnd_event
.hwnd
, GetFocus());
16131 SetLastError(0xdeadbeef);
16132 ret
= AttachThreadInput(GetCurrentThreadId(), tid
, FALSE
);
16133 ok(ret
, "AttachThreadInput error %d\n", GetLastError());
16135 ok(GetActiveWindow() == 0, "expected active 0, got %p\n", GetActiveWindow());
16136 ok(GetFocus() == 0, "expected focus 0, got %p\n", GetFocus());
16138 old_parent
= SetParent(child
, GetDesktopWindow());
16139 ok(old_parent
== parent
, "expected old parent %p, got %p\n", parent
, old_parent
);
16141 ok(GetActiveWindow() == 0, "expected active 0, got %p\n", GetActiveWindow());
16142 ok(GetFocus() == 0, "expected focus 0, got %p\n", GetFocus());
16144 old_focus
= SetFocus(parent
);
16145 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
16146 ok(old_focus
== parent
, "expected old focus %p, got %p\n", parent
, old_focus
);
16147 ok(GetActiveWindow() == parent
, "expected active %p, got %p\n", parent
, GetActiveWindow());
16148 ok(GetFocus() == parent
, "expected focus %p, got %p\n", parent
, GetFocus());
16153 SetLastError(0xdeadbeef);
16154 old_focus
= SetFocus(child
);
16156 ok(GetLastError() == ERROR_INVALID_PARAMETER
/* Vista+ */ ||
16157 broken(GetLastError() == 0) /* XP */ ||
16158 broken(GetLastError() == 0xdeadbeef), "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
16159 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
16160 ok_sequence(WmSetFocus_3
, "SetFocus on a child window", TRUE
);
16161 ok(old_focus
== 0, "expected old focus 0, got %p\n", old_focus
);
16162 ok(GetActiveWindow() == parent
, "expected active %p, got %p\n", parent
, GetActiveWindow());
16163 ok(GetFocus() == parent
, "expected focus %p, got %p\n", parent
, GetFocus());
16165 SetLastError(0xdeadbeef);
16166 old_active
= SetActiveWindow(child
);
16167 ok(GetLastError() == 0xdeadbeef, "expected 0xdeadbeef, got %d\n", GetLastError());
16168 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
16169 ok_sequence(WmEmptySeq
, "SetActiveWindow on a child window", FALSE
);
16170 ok(old_active
== parent
, "expected old active %p, got %p\n", parent
, old_active
);
16171 ok(GetActiveWindow() == parent
, "expected active %p, got %p\n", parent
, GetActiveWindow());
16172 ok(GetFocus() == parent
, "expected focus %p, got %p\n", parent
, GetFocus());
16174 log_all_parent_messages
--;
16176 DestroyWindow(child
);
16177 DestroyWindow(parent
);
16179 ret
= PostMessageA(wnd_event
.hwnd
, WM_QUIT
, 0, 0);
16180 ok(ret
, "PostMessage(WM_QUIT) error %d\n", GetLastError());
16181 ret
= WaitForSingleObject(hthread
, INFINITE
);
16182 ok(ret
== WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
16183 CloseHandle(hthread
);
16186 static const struct message WmSetLayeredStyle
[] = {
16187 { WM_STYLECHANGING
, sent
},
16188 { WM_STYLECHANGED
, sent
},
16189 { WM_GETTEXT
, sent
|defwinproc
|optional
},
16193 static const struct message WmSetLayeredStyle2
[] = {
16194 { WM_STYLECHANGING
, sent
},
16195 { WM_STYLECHANGED
, sent
},
16196 { WM_WINDOWPOSCHANGING
, sent
|optional
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
16197 { WM_NCCALCSIZE
, sent
|optional
|wparam
|defwinproc
, 1 },
16198 { WM_WINDOWPOSCHANGED
, sent
|optional
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
16199 { WM_MOVE
, sent
|optional
|defwinproc
|wparam
, 0 },
16200 { WM_SIZE
, sent
|optional
|defwinproc
|wparam
, SIZE_RESTORED
},
16204 struct layered_window_info
16213 static DWORD CALLBACK
update_layered_proc( void *param
)
16215 struct layered_window_info
*info
= param
;
16216 POINT src
= { 0, 0 };
16218 info
->ret
= pUpdateLayeredWindow( info
->hwnd
, 0, NULL
, &info
->size
,
16219 info
->hdc
, &src
, 0, NULL
, ULW_OPAQUE
);
16220 ok( info
->ret
, "failed\n");
16221 SetEvent( info
->event
);
16225 static void test_layered_window(void)
16236 struct layered_window_info info
;
16238 if (!pUpdateLayeredWindow
)
16240 win_skip( "UpdateLayeredWindow not supported\n" );
16244 hdc
= CreateCompatibleDC( 0 );
16245 bmp
= CreateCompatibleBitmap( hdc
, 300, 300 );
16246 SelectObject( hdc
, bmp
);
16248 hwnd
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_CAPTION
| WS_THICKFRAME
| WS_SYSMENU
,
16249 100, 100, 300, 300, 0, 0, 0, NULL
);
16250 ok( hwnd
!= 0, "failed to create window\n" );
16251 ShowWindow( hwnd
, SW_SHOWNORMAL
);
16252 UpdateWindow( hwnd
);
16256 GetWindowRect( hwnd
, &rect
);
16257 GetClientRect( hwnd
, &client
);
16258 ok( client
.right
< rect
.right
- rect
.left
, "wrong client area\n" );
16259 ok( client
.bottom
< rect
.bottom
- rect
.top
, "wrong client area\n" );
16262 pos
.x
= pos
.y
= 300;
16263 size
.cx
= size
.cy
= 250;
16264 ret
= pUpdateLayeredWindow( hwnd
, 0, &pos
, &size
, hdc
, &src
, 0, NULL
, ULW_OPAQUE
);
16265 ok( !ret
, "UpdateLayeredWindow should fail on non-layered window\n" );
16266 ok( GetLastError() == ERROR_INVALID_PARAMETER
, "wrong error %u\n", GetLastError() );
16267 SetWindowLongA( hwnd
, GWL_EXSTYLE
, GetWindowLongA(hwnd
, GWL_EXSTYLE
) | WS_EX_LAYERED
);
16268 ok_sequence( WmSetLayeredStyle
, "WmSetLayeredStyle", FALSE
);
16270 ret
= pUpdateLayeredWindow( hwnd
, 0, &pos
, &size
, hdc
, &src
, 0, NULL
, ULW_OPAQUE
);
16271 ok( ret
, "UpdateLayeredWindow failed err %u\n", GetLastError() );
16272 ok_sequence( WmEmptySeq
, "UpdateLayeredWindow", FALSE
);
16273 GetWindowRect( hwnd
, &rect
);
16274 ok( rect
.left
== 300 && rect
.top
== 300 && rect
.right
== 550 && rect
.bottom
== 550,
16275 "wrong window rect %s\n", wine_dbgstr_rect( &rect
));
16276 GetClientRect( hwnd
, &rect
);
16277 ok( rect
.right
== client
.right
- 50 && rect
.bottom
== client
.bottom
- 50,
16278 "wrong client rect %s\n", wine_dbgstr_rect( &rect
));
16282 ret
= pUpdateLayeredWindow( hwnd
, 0, &pos
, &size
, hdc
, &src
, 0, NULL
, ULW_OPAQUE
);
16283 ok( ret
, "UpdateLayeredWindow failed err %u\n", GetLastError() );
16284 ok_sequence( WmEmptySeq
, "UpdateLayeredWindow", FALSE
);
16285 GetWindowRect( hwnd
, &rect
);
16286 ok( rect
.left
== 300 && rect
.top
== 200 && rect
.right
== 450 && rect
.bottom
== 450,
16287 "wrong window rect %s\n", wine_dbgstr_rect( &rect
));
16288 GetClientRect( hwnd
, &rect
);
16289 ok( rect
.right
== client
.right
- 150 && rect
.bottom
== client
.bottom
- 50,
16290 "wrong client rect %s\n", wine_dbgstr_rect( &rect
));
16292 SetWindowLongA( hwnd
, GWL_STYLE
,
16293 GetWindowLongA(hwnd
, GWL_STYLE
) & ~(WS_CAPTION
| WS_THICKFRAME
| WS_SYSMENU
) );
16294 ok_sequence( WmSetLayeredStyle2
, "WmSetLayeredStyle2", FALSE
);
16298 ret
= pUpdateLayeredWindow( hwnd
, 0, &pos
, &size
, hdc
, &src
, 0, NULL
, ULW_OPAQUE
);
16299 ok( ret
, "UpdateLayeredWindow failed err %u\n", GetLastError() );
16300 ok_sequence( WmEmptySeq
, "UpdateLayeredWindow", FALSE
);
16301 GetWindowRect( hwnd
, &rect
);
16302 ok( rect
.left
== 200 && rect
.top
== 200 && rect
.right
== 400 && rect
.bottom
== 450,
16303 "wrong window rect %s\n", wine_dbgstr_rect( &rect
));
16304 GetClientRect( hwnd
, &rect
);
16305 ok( (rect
.right
== 200 && rect
.bottom
== 250) ||
16306 broken(rect
.right
== client
.right
- 100 && rect
.bottom
== client
.bottom
- 50),
16307 "wrong client rect %s\n", wine_dbgstr_rect( &rect
));
16310 ret
= pUpdateLayeredWindow( hwnd
, 0, &pos
, &size
, hdc
, &src
, 0, NULL
, ULW_OPAQUE
);
16311 ok( !ret
, "UpdateLayeredWindow should fail on non-layered window\n" );
16312 ok( GetLastError() == ERROR_INVALID_PARAMETER
|| broken(GetLastError() == ERROR_MR_MID_NOT_FOUND
) ||
16313 broken(GetLastError() == ERROR_GEN_FAILURE
) /* win7 */, "wrong error %u\n", GetLastError() );
16316 ret
= pUpdateLayeredWindow( hwnd
, 0, &pos
, &size
, hdc
, &src
, 0, NULL
, ULW_OPAQUE
);
16317 ok( !ret
, "UpdateLayeredWindow should fail on non-layered window\n" );
16318 ok( GetLastError() == ERROR_INVALID_PARAMETER
, "wrong error %u\n", GetLastError() );
16320 SetWindowLongA( hwnd
, GWL_EXSTYLE
, GetWindowLongA(hwnd
, GWL_EXSTYLE
) & ~WS_EX_LAYERED
);
16321 ok_sequence( WmSetLayeredStyle
, "WmSetLayeredStyle", FALSE
);
16322 GetWindowRect( hwnd
, &rect
);
16323 ok( rect
.left
== 200 && rect
.top
== 200 && rect
.right
== 400 && rect
.bottom
== 450,
16324 "wrong window rect %s\n", wine_dbgstr_rect( &rect
));
16325 GetClientRect( hwnd
, &rect
);
16326 ok( (rect
.right
== 200 && rect
.bottom
== 250) ||
16327 broken(rect
.right
== client
.right
- 100 && rect
.bottom
== client
.bottom
- 50),
16328 "wrong client rect %s\n", wine_dbgstr_rect( &rect
));
16330 SetWindowLongA( hwnd
, GWL_EXSTYLE
, GetWindowLongA(hwnd
, GWL_EXSTYLE
) | WS_EX_LAYERED
);
16333 info
.size
.cx
= 250;
16334 info
.size
.cy
= 300;
16335 info
.event
= CreateEventA( NULL
, TRUE
, FALSE
, NULL
);
16337 thread
= CreateThread( NULL
, 0, update_layered_proc
, &info
, 0, &tid
);
16338 ok( WaitForSingleObject( info
.event
, 1000 ) == 0, "wait failed\n" );
16339 ok( info
.ret
, "UpdateLayeredWindow failed in other thread\n" );
16340 WaitForSingleObject( thread
, 1000 );
16341 CloseHandle( thread
);
16342 GetWindowRect( hwnd
, &rect
);
16343 ok( rect
.left
== 200 && rect
.top
== 200 && rect
.right
== 450 && rect
.bottom
== 500,
16344 "wrong window rect %s\n", wine_dbgstr_rect( &rect
));
16345 GetClientRect( hwnd
, &rect
);
16346 ok( (rect
.right
== 250 && rect
.bottom
== 300) ||
16347 broken(rect
.right
== client
.right
- 50 && rect
.bottom
== client
.bottom
),
16348 "wrong client rect %s\n", wine_dbgstr_rect( &rect
));
16350 DestroyWindow( hwnd
);
16352 DeleteObject( bmp
);
16355 static HMENU hpopupmenu
;
16357 static LRESULT WINAPI
cancel_popup_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
16359 if (ignore_message( message
)) return 0;
16363 todo_wine
ok(GetCapture() == hwnd
, "expected %p, got %p\n", hwnd
, GetCapture());
16367 case WM_INITMENUPOPUP
:
16368 case WM_UNINITMENUPOPUP
:
16369 ok((HMENU
)wParam
== hpopupmenu
, "expected %p, got %lx\n", hpopupmenu
, wParam
);
16371 case WM_CAPTURECHANGED
:
16372 todo_wine
ok(!lParam
|| (HWND
)lParam
== hwnd
, "lost capture to %lx\n", lParam
);
16376 return MsgCheckProc (FALSE
, hwnd
, message
, wParam
, lParam
);
16379 static LRESULT WINAPI
cancel_init_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
16381 if (ignore_message( message
)) return 0;
16384 case WM_ENTERMENULOOP
:
16385 ok(EndMenu() == TRUE
, "EndMenu() failed\n");
16389 return MsgCheckProc (FALSE
, hwnd
, message
, wParam
, lParam
);
16392 static void test_TrackPopupMenu(void)
16398 hwnd
= CreateWindowExA(0, "TestWindowClass", NULL
, 0,
16401 ok(hwnd
!= NULL
, "CreateWindowEx failed with error %d\n", GetLastError());
16403 SetWindowLongPtrA( hwnd
, GWLP_WNDPROC
, (LONG_PTR
)cancel_popup_proc
);
16405 hpopupmenu
= CreatePopupMenu();
16406 ok(hpopupmenu
!= NULL
, "CreateMenu failed with error %d\n", GetLastError());
16408 AppendMenuA(hpopupmenu
, MF_STRING
, 100, "item 1");
16409 AppendMenuA(hpopupmenu
, MF_STRING
, 100, "item 2");
16413 ret
= TrackPopupMenu(hpopupmenu
, 0, 100,100, 0, hwnd
, NULL
);
16414 ok_sequence(WmTrackPopupMenu
, "TrackPopupMenu", TRUE
);
16415 ok(ret
== 1, "TrackPopupMenu failed with error %i\n", GetLastError());
16417 /* Test popup closing with an ESC-press */
16419 PostMessageW(hwnd
, WM_KEYDOWN
, VK_ESCAPE
, 0);
16420 ret
= TrackPopupMenu(hpopupmenu
, 0, 100,100, 0, hwnd
, NULL
);
16421 ok(ret
== 1, "TrackPopupMenu failed with error %i\n", GetLastError());
16422 PostQuitMessage(0);
16424 while ( PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
) )
16426 TranslateMessage(&msg
);
16427 DispatchMessageA(&msg
);
16429 ok_sequence(WmTrackPopupMenuEsc
, "TrackPopupMenuEsc", FALSE
); /* Shouldn't get any message */
16431 SetWindowLongPtrA( hwnd
, GWLP_WNDPROC
, (LONG_PTR
)cancel_init_proc
);
16435 ret
= TrackPopupMenu(hpopupmenu
, 0, 100,100, 0, hwnd
, NULL
);
16436 ok_sequence(WmTrackPopupMenuAbort
, "WmTrackPopupMenuAbort", TRUE
);
16437 ok(ret
== TRUE
, "TrackPopupMenu failed\n");
16439 SetWindowLongPtrA( hwnd
, GWLP_WNDPROC
, (LONG_PTR
)cancel_popup_proc
);
16445 ret
= TrackPopupMenu(hpopupmenu
, 0, 100,100, 0, hwnd
, NULL
);
16446 ok_sequence(WmTrackPopupMenuCapture
, "TrackPopupMenuCapture", TRUE
);
16447 ok(ret
== 1, "TrackPopupMenuCapture failed with error %i\n", GetLastError());
16449 DestroyMenu(hpopupmenu
);
16450 DestroyWindow(hwnd
);
16453 static void test_TrackPopupMenuEmpty(void)
16458 hwnd
= CreateWindowExA(0, "TestWindowClass", NULL
, 0,
16461 ok(hwnd
!= NULL
, "CreateWindowEx failed with error %d\n", GetLastError());
16463 SetWindowLongPtrA( hwnd
, GWLP_WNDPROC
, (LONG_PTR
)cancel_popup_proc
);
16465 hpopupmenu
= CreatePopupMenu();
16466 ok(hpopupmenu
!= NULL
, "CreateMenu failed with error %d\n", GetLastError());
16470 ret
= TrackPopupMenu(hpopupmenu
, 0, 100,100, 0, hwnd
, NULL
);
16471 ok_sequence(WmTrackPopupMenuEmpty
, "TrackPopupMenuEmpty", TRUE
);
16472 ok(ret
== 0, "TrackPopupMenu succeeded\n");
16474 DestroyMenu(hpopupmenu
);
16475 DestroyWindow(hwnd
);
16478 static const struct message send_message_1
[] = {
16479 { WM_USER
+2, sent
|wparam
|lparam
, 0, 0 },
16480 { WM_USER
, sent
|wparam
|lparam
, 0, 0 },
16483 static const struct message send_message_2
[] = {
16484 { WM_USER
+4, sent
|wparam
|lparam
, 0, 0 },
16487 static const struct message send_message_3
[] = {
16488 { WM_USER
+3, sent
|wparam
|lparam
, 0, 0 },
16489 { WM_USER
+1, sent
|wparam
|lparam
, 0, 0 },
16493 static DWORD WINAPI
SendMessage_thread_1(void *param
)
16495 struct wnd_event
*wnd_event
= param
;
16497 trace("thread: starting\n");
16498 WaitForSingleObject(wnd_event
->start_event
, INFINITE
);
16500 trace("thread: call PostMessage\n");
16501 PostMessageA(wnd_event
->hwnd
, WM_USER
, 0, 0);
16503 trace("thread: call PostMessage\n");
16504 PostMessageA(wnd_event
->hwnd
, WM_USER
+1, 0, 0);
16506 trace("thread: call SendMessage\n");
16507 SendMessageA(wnd_event
->hwnd
, WM_USER
+2, 0, 0);
16509 trace("thread: call SendMessage\n");
16510 SendMessageA(wnd_event
->hwnd
, WM_USER
+3, 0, 0);
16515 static DWORD WINAPI
SendMessage_thread_2(void *param
)
16517 struct wnd_event
*wnd_event
= param
;
16519 trace("thread: starting\n");
16520 WaitForSingleObject(wnd_event
->start_event
, INFINITE
);
16522 trace("thread: call PostMessage\n");
16523 PostMessageA(wnd_event
->hwnd
, WM_USER
, 0, 0);
16525 trace("thread: call PostMessage\n");
16526 PostMessageA(wnd_event
->hwnd
, WM_USER
+1, 0, 0);
16528 /* this leads to sending an internal message under Wine */
16529 trace("thread: call SetParent\n");
16530 SetParent(wnd_event
->hwnd
, wnd_event
->hwnd
);
16532 trace("thread: call SendMessage\n");
16533 SendMessageA(wnd_event
->hwnd
, WM_USER
+2, 0, 0);
16535 trace("thread: call SendMessage\n");
16536 SendMessageA(wnd_event
->hwnd
, WM_USER
+3, 0, 0);
16541 static void test_SendMessage_other_thread(int thread_n
)
16543 DWORD qs_all_input
= QS_ALLINPUT
& ~QS_RAWINPUT
;
16545 struct wnd_event wnd_event
;
16549 wnd_event
.start_event
= CreateEventA(NULL
, 0, 0, NULL
);
16551 wnd_event
.hwnd
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
16552 100, 100, 200, 200, 0, 0, 0, NULL
);
16553 ok(wnd_event
.hwnd
!= 0, "CreateWindowEx failed\n");
16555 hthread
= CreateThread(NULL
, 0, thread_n
== 1 ? SendMessage_thread_1
: SendMessage_thread_2
, &wnd_event
, 0, &tid
);
16556 ok(hthread
!= NULL
, "CreateThread failed, error %d\n", GetLastError());
16557 CloseHandle(hthread
);
16562 ret
= GetQueueStatus(QS_SENDMESSAGE
);
16563 ok(ret
== 0, "wrong status %08x\n", ret
);
16565 SetEvent(wnd_event
.start_event
);
16567 /* wait for other thread's SendMessage */
16570 ret
= GetQueueStatus(QS_SENDMESSAGE
);
16571 if (ret
== MAKELONG(QS_SENDMESSAGE
, QS_SENDMESSAGE
)) break;
16575 ret
= GetQueueStatus(QS_SENDMESSAGE
|QS_POSTMESSAGE
);
16576 ok(ret
== MAKELONG(QS_POSTMESSAGE
, QS_SENDMESSAGE
|QS_POSTMESSAGE
), "wrong status %08x\n", ret
);
16578 trace("main: call GetMessage\n");
16579 GetMessageA(&msg
, 0, 0, 0);
16580 ok(msg
.message
== WM_USER
, "expected WM_USER, got %04x\n", msg
.message
);
16581 DispatchMessageA(&msg
);
16582 ok_sequence(send_message_1
, "SendMessage from other thread 1", thread_n
== 2);
16584 /* intentionally yield */
16585 MsgWaitForMultipleObjects(0, NULL
, FALSE
, 100, qs_all_input
);
16587 trace("main: call SendMessage\n");
16588 SendMessageA(wnd_event
.hwnd
, WM_USER
+4, 0, 0);
16589 ok_sequence(send_message_2
, "SendMessage from other thread 2", FALSE
);
16591 ret
= GetQueueStatus(QS_SENDMESSAGE
|QS_POSTMESSAGE
);
16592 ok(ret
== MAKELONG(QS_SENDMESSAGE
, QS_SENDMESSAGE
|QS_POSTMESSAGE
), "wrong status %08x\n", ret
);
16594 trace("main: call PeekMessage\n");
16595 ok(PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
), "PeekMessage should not fail\n");
16596 ok(msg
.message
== WM_USER
+1, "expected WM_USER+1, got %04x\n", msg
.message
);
16597 DispatchMessageA(&msg
);
16598 ok_sequence(send_message_3
, "SendMessage from other thread 3", thread_n
== 2);
16600 /* intentionally yield */
16601 MsgWaitForMultipleObjects(0, NULL
, FALSE
, 100, qs_all_input
);
16603 ret
= GetQueueStatus(QS_SENDMESSAGE
|QS_POSTMESSAGE
);
16604 /* FIXME: remove once Wine is fixed */
16605 todo_wine_if (thread_n
== 2)
16606 ok(ret
== 0, "wrong status %08x\n", ret
);
16608 trace("main: call PeekMessage\n");
16609 ok(!PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
), "PeekMessage should fail\n");
16610 ok_sequence(WmEmptySeq
, "SendMessage from other thread 5", thread_n
== 2);
16612 ret
= GetQueueStatus(QS_SENDMESSAGE
|QS_POSTMESSAGE
);
16613 ok(ret
== 0, "wrong status %08x\n", ret
);
16615 trace("main: call DestroyWindow\n");
16616 DestroyWindow(msg
.hwnd
);
16622 static LRESULT CALLBACK
insendmessage_wnd_proc( HWND hwnd
, UINT msg
, WPARAM wp
, LPARAM lp
)
16624 DWORD flags
= InSendMessageEx( NULL
);
16630 ok( flags
== ISMEX_SEND
, "wrong flags %x\n", flags
);
16631 ok( InSendMessage(), "InSendMessage returned false\n" );
16632 ret
= ReplyMessage( msg
);
16633 ok( ret
, "ReplyMessage failed err %u\n", GetLastError() );
16634 flags
= InSendMessageEx( NULL
);
16635 ok( flags
== (ISMEX_SEND
| ISMEX_REPLIED
), "wrong flags %x\n", flags
);
16636 ok( InSendMessage(), "InSendMessage returned false\n" );
16639 ok( flags
== ISMEX_NOTIFY
, "wrong flags %x\n", flags
);
16640 ok( InSendMessage(), "InSendMessage returned false\n" );
16641 ret
= ReplyMessage( msg
);
16642 ok( ret
, "ReplyMessage failed err %u\n", GetLastError() );
16643 flags
= InSendMessageEx( NULL
);
16644 ok( flags
== ISMEX_NOTIFY
, "wrong flags %x\n", flags
);
16645 ok( InSendMessage(), "InSendMessage returned false\n" );
16648 ok( flags
== ISMEX_CALLBACK
, "wrong flags %x\n", flags
);
16649 ok( InSendMessage(), "InSendMessage returned false\n" );
16650 ret
= ReplyMessage( msg
);
16651 ok( ret
, "ReplyMessage failed err %u\n", GetLastError() );
16652 flags
= InSendMessageEx( NULL
);
16653 ok( flags
== (ISMEX_CALLBACK
| ISMEX_REPLIED
) || flags
== ISMEX_SEND
, "wrong flags %x\n", flags
);
16654 ok( InSendMessage(), "InSendMessage returned false\n" );
16657 ok( flags
== ISMEX_NOSEND
, "wrong flags %x\n", flags
);
16658 ok( !InSendMessage(), "InSendMessage returned true\n" );
16659 ret
= ReplyMessage( msg
);
16660 ok( !ret
, "ReplyMessage succeeded\n" );
16664 return DefWindowProcA( hwnd
, msg
, wp
, lp
);
16667 static void CALLBACK
msg_callback( HWND hwnd
, UINT msg
, ULONG_PTR arg
, LRESULT result
)
16669 ok( msg
== WM_USER
+ 2, "wrong msg %x\n", msg
);
16670 ok( result
== WM_USER
+ 2, "wrong result %lx\n", result
);
16673 static DWORD WINAPI
send_message_thread( void *arg
)
16677 SendMessageA( win
, WM_USER
, 0, 0 );
16678 SendNotifyMessageA( win
, WM_USER
+ 1, 0, 0 );
16679 SendMessageCallbackA( win
, WM_USER
+ 2, 0, 0, msg_callback
, 0 );
16680 PostMessageA( win
, WM_USER
+ 3, 0, 0 );
16681 PostMessageA( win
, WM_QUIT
, 0, 0 );
16685 static void test_InSendMessage(void)
16693 memset(&cls
, 0, sizeof(cls
));
16694 cls
.lpfnWndProc
= insendmessage_wnd_proc
;
16695 cls
.hInstance
= GetModuleHandleA(NULL
);
16696 cls
.lpszClassName
= "InSendMessage_test";
16697 RegisterClassA(&cls
);
16699 win
= CreateWindowA( "InSendMessage_test", NULL
, 0, 0, 0, 0, 0, NULL
, 0, NULL
, 0 );
16700 ok( win
!= NULL
, "CreateWindow failed: %d\n", GetLastError() );
16702 thread
= CreateThread( NULL
, 0, send_message_thread
, win
, 0, &tid
);
16703 ok( thread
!= NULL
, "CreateThread failed: %d\n", GetLastError() );
16705 while (GetMessageA(&msg
, NULL
, 0, 0)) DispatchMessageA( &msg
);
16707 ok( WaitForSingleObject( thread
, 30000 ) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n" );
16708 CloseHandle( thread
);
16710 DestroyWindow( win
);
16711 UnregisterClassA( "InSendMessage_test", GetModuleHandleA(NULL
) );
16714 static const struct message DoubleSetCaptureSeq
[] =
16716 { WM_CAPTURECHANGED
, sent
},
16720 static void test_DoubleSetCapture(void)
16724 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test DoubleSetCapture",
16725 WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
16726 100, 100, 200, 200, 0, 0, 0, NULL
);
16727 ok (hwnd
!= 0, "Failed to create overlapped window\n");
16729 ShowWindow( hwnd
, SW_SHOW
);
16730 UpdateWindow( hwnd
);
16734 SetCapture( hwnd
);
16735 SetCapture( hwnd
);
16736 ok_sequence(DoubleSetCaptureSeq
, "SetCapture( hwnd ) twice", FALSE
);
16738 DestroyWindow(hwnd
);
16741 static void init_funcs(void)
16743 HMODULE hKernel32
= GetModuleHandleA("kernel32.dll");
16745 #define X(f) p##f = (void*)GetProcAddress(hKernel32, #f)
16748 X(DeactivateActCtx
);
16749 X(GetCurrentActCtx
);
16759 BOOL (WINAPI
*pIsWinEventHookInstalled
)(DWORD
)= 0;/*GetProcAddress(user32, "IsWinEventHookInstalled");*/
16760 HMODULE hModuleImm32
;
16761 BOOL (WINAPI
*pImmDisableIME
)(DWORD
);
16766 argc
= winetest_get_mainargs( &test_argv
);
16770 /* Child process. */
16771 sscanf (test_argv
[2], "%d", (unsigned int *) &arg
);
16772 do_wait_idle_child( arg
);
16776 InitializeCriticalSection( &sequence_cs
);
16779 hModuleImm32
= LoadLibraryA("imm32.dll");
16780 if (hModuleImm32
) {
16781 pImmDisableIME
= (void *)GetProcAddress(hModuleImm32
, "ImmDisableIME");
16782 if (pImmDisableIME
)
16785 pImmDisableIME
= NULL
;
16786 FreeLibrary(hModuleImm32
);
16788 if (!RegisterWindowClasses()) assert(0);
16790 if (pSetWinEventHook
)
16792 hEvent_hook
= pSetWinEventHook(EVENT_MIN
, EVENT_MAX
,
16793 GetModuleHandleA(0), win_event_proc
,
16794 0, GetCurrentThreadId(),
16795 WINEVENT_INCONTEXT
);
16796 if (pIsWinEventHookInstalled
&& hEvent_hook
)
16799 for (event
= EVENT_MIN
; event
<= EVENT_MAX
; event
++)
16800 ok(pIsWinEventHookInstalled(event
), "IsWinEventHookInstalled(%u) failed\n", event
);
16803 if (!hEvent_hook
) win_skip( "no win event hook support\n" );
16805 cbt_hook_thread_id
= GetCurrentThreadId();
16806 hCBT_hook
= SetWindowsHookExA(WH_CBT
, cbt_hook_proc
, 0, GetCurrentThreadId());
16807 if (!hCBT_hook
) win_skip( "cannot set global hook, will skip hook tests\n" );
16811 /* Fix message sequences before removing 4 lines below */
16812 if (pUnhookWinEvent
&& hEvent_hook
)
16814 ret
= pUnhookWinEvent(hEvent_hook
);
16815 ok( ret
, "UnhookWinEvent error %d\n", GetLastError());
16816 pUnhookWinEvent
= 0;
16820 test_SendMessage_other_thread(1);
16821 test_SendMessage_other_thread(2);
16822 test_InSendMessage();
16825 test_PostMessage();
16828 test_PeekMessage();
16829 test_PeekMessage2();
16830 test_PeekMessage3();
16831 test_WaitForInputIdle( test_argv
[0] );
16832 test_scrollwindowex();
16834 test_setwindowpos();
16836 invisible_parent_tests();
16837 test_mdi_messages();
16838 test_button_messages();
16839 test_button_bm_get_set_image();
16840 test_static_messages();
16841 test_listbox_messages();
16842 test_combobox_messages();
16843 test_wmime_keydown_message();
16844 test_paint_messages();
16845 test_interthread_messages();
16846 test_message_conversion();
16847 test_accelerators();
16849 test_timers_no_wnd();
16850 test_timers_exceptions();
16854 test_recursive_hook();
16856 test_DestroyWindow();
16857 test_DispatchMessage();
16858 test_SendMessageTimeout();
16859 test_edit_messages();
16860 test_quit_message();
16861 test_notify_message();
16862 test_SetActiveWindow();
16864 if (!pTrackMouseEvent
)
16865 win_skip("TrackMouseEvent is not available\n");
16867 test_TrackMouseEvent();
16869 test_SetWindowRgn();
16871 test_dialog_messages();
16873 test_nullCallback();
16874 test_dbcs_wm_char();
16875 test_unicode_wm_char();
16876 test_menu_messages();
16877 test_paintingloop();
16879 test_clipboard_viewers();
16882 test_layered_window();
16883 test_TrackPopupMenu();
16884 test_TrackPopupMenuEmpty();
16885 test_DoubleSetCapture();
16886 /* keep it the last test, under Windows it tends to break the tests
16887 * which rely on active/foreground windows being correct.
16889 test_SetForegroundWindow();
16891 UnhookWindowsHookEx(hCBT_hook
);
16892 if (pUnhookWinEvent
&& hEvent_hook
)
16894 ret
= pUnhookWinEvent(hEvent_hook
);
16895 ok( ret
, "UnhookWinEvent error %d\n", GetLastError());
16896 SetLastError(0xdeadbeef);
16897 ok(!pUnhookWinEvent(hEvent_hook
), "UnhookWinEvent succeeded\n");
16898 ok(GetLastError() == ERROR_INVALID_HANDLE
|| /* Win2k */
16899 GetLastError() == 0xdeadbeef, /* Win9x */
16900 "unexpected error %d\n", GetLastError());
16902 DeleteCriticalSection( &sequence_cs
);