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 */
36 #include "wine/test.h"
38 #define MDI_FIRST_CHILD_ID 2004
40 /* undocumented SWP flags - from SDK 3.1 */
41 #define SWP_NOCLIENTSIZE 0x0800
42 #define SWP_NOCLIENTMOVE 0x1000
43 #define SWP_STATECHANGED 0x8000
45 #define SW_NORMALNA 0xCC /* undoc. flag in MinMaximize */
48 #define WM_KEYF1 0x004d
52 #define WM_SYSTIMER 0x0118
55 #define WND_PARENT_ID 1
56 #define WND_POPUP_ID 2
57 #define WND_CHILD_ID 3
59 #ifndef WM_LBTRACKPOINT
60 #define WM_LBTRACKPOINT 0x0131
65 #elif defined __x86_64__
69 #elif defined __aarch64__
75 static BOOL (WINAPI
*pActivateActCtx
)(HANDLE
,ULONG_PTR
*);
76 static HANDLE (WINAPI
*pCreateActCtxW
)(PCACTCTXW
);
77 static BOOL (WINAPI
*pDeactivateActCtx
)(DWORD
,ULONG_PTR
);
78 static BOOL (WINAPI
*pGetCurrentActCtx
)(HANDLE
*);
79 static void (WINAPI
*pReleaseActCtx
)(HANDLE
);
81 /* encoded DRAWITEMSTRUCT into an LPARAM */
88 UINT type
: 4; /* ODT_* flags */
89 UINT ctl_id
: 4; /* Control ID */
90 UINT item_id
: 4; /* Menu item ID */
91 UINT action
: 4; /* ODA_* flags */
92 UINT state
: 16; /* ODS_* flags */
98 static BOOL test_DestroyWindow_flag
;
99 static HWINEVENTHOOK hEvent_hook
;
100 static HHOOK hKBD_hook
;
101 static HHOOK hCBT_hook
;
102 static DWORD cbt_hook_thread_id
;
104 static const WCHAR testWindowClassW
[] =
105 { 'T','e','s','t','W','i','n','d','o','w','C','l','a','s','s','W',0 };
108 FIXME: add tests for these
109 Window Edge Styles (Win31/Win95/98 look), in order of precedence:
110 WS_EX_DLGMODALFRAME: double border, WS_CAPTION allowed
111 WS_THICKFRAME: thick border
112 WS_DLGFRAME: double border, WS_CAPTION not allowed (but possibly shown anyway)
113 WS_BORDER (default for overlapped windows): single black border
114 none (default for child (and popup?) windows): no border
132 UINT message
; /* the WM_* code */
133 msg_flags_t flags
; /* message props */
134 WPARAM wParam
; /* expected value of wParam */
135 LPARAM lParam
; /* expected value of lParam */
136 WPARAM wp_mask
; /* mask for wParam checks */
137 LPARAM lp_mask
; /* mask for lParam checks */
140 struct recvd_message
{
141 UINT message
; /* the WM_* code */
142 msg_flags_t flags
; /* message props */
143 HWND hwnd
; /* window that received the message */
144 WPARAM wParam
; /* expected value of wParam */
145 LPARAM lParam
; /* expected value of lParam */
146 int line
; /* source line where logged */
147 const char *descr
; /* description for trace output */
148 char output
[512]; /* trace output */
151 /* Empty message sequence */
152 static const struct message WmEmptySeq
[] =
156 /* CreateWindow (for overlapped window, not initially visible) (16/32) */
157 static const struct message WmCreateOverlappedSeq
[] = {
158 { HCBT_CREATEWND
, hook
},
159 { WM_GETMINMAXINFO
, sent
},
160 { WM_NCCREATE
, sent
},
161 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
162 { 0x0093, sent
|defwinproc
|optional
},
163 { 0x0094, sent
|defwinproc
|optional
},
164 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
166 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
169 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
170 * for a not visible overlapped window.
172 static const struct message WmSWP_ShowOverlappedSeq
[] = {
173 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
174 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
175 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
176 { WM_GETTEXT
, sent
|defwinproc
|optional
},
177 { WM_ERASEBKGND
, sent
|optional
},
178 { HCBT_ACTIVATE
, hook
},
179 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
180 { WM_NOTIFYFORMAT
, sent
|optional
},
181 { WM_QUERYUISTATE
, sent
|optional
},
182 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
183 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* Win9x: SWP_NOSENDCHANGING */
184 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
185 { WM_NCACTIVATE
, sent
},
186 { WM_GETTEXT
, sent
|defwinproc
|optional
},
187 { WM_ACTIVATE
, sent
|wparam
, 1 },
188 { HCBT_SETFOCUS
, hook
},
189 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
190 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
191 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
192 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
193 { WM_GETTEXT
, sent
|optional
},
194 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
195 { WM_GETTEXT
, sent
|defwinproc
|optional
},
196 { WM_ERASEBKGND
, sent
|optional
},
197 /* Win9x adds SWP_NOZORDER below */
198 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
199 { WM_GETTEXT
, sent
|optional
},
200 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
201 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
202 { WM_ERASEBKGND
, sent
|optional
},
203 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
204 { WM_SYNCPAINT
, sent
|optional
},
205 { WM_GETTITLEBARINFOEX
, sent
|optional
},
206 { WM_PAINT
, sent
|optional
},
207 { WM_NCPAINT
, sent
|beginpaint
|optional
},
208 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
209 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
212 /* SetWindowPos(SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE)
213 * for a visible overlapped window.
215 static const struct message WmSWP_HideOverlappedSeq
[] = {
216 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
217 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
218 { HCBT_ACTIVATE
, hook
|optional
},
219 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
220 { WM_ACTIVATEAPP
, sent
|wparam
|optional
, 1 },
221 { WM_NCACTIVATE
, sent
|optional
},
222 { WM_ACTIVATE
, sent
|optional
},
223 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
227 /* SetWindowPos(SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOMOVE)
228 * for a visible overlapped window.
230 static const struct message WmSWP_ResizeSeq
[] = {
231 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
},
232 { WM_GETMINMAXINFO
, sent
|defwinproc
},
233 { WM_NCCALCSIZE
, sent
|wparam
|optional
, TRUE
},
234 { WM_NCPAINT
, sent
|optional
},
235 { WM_GETTEXT
, sent
|defwinproc
|optional
},
236 { WM_ERASEBKGND
, sent
|optional
},
237 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
},
238 { WM_SIZE
, sent
|defwinproc
|optional
},
239 { WM_NCCALCSIZE
, sent
|wparam
|optional
, TRUE
},
240 { WM_NCPAINT
, sent
|optional
},
241 { WM_GETTEXT
, sent
|defwinproc
|optional
},
242 { WM_ERASEBKGND
, sent
|optional
},
243 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
244 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* XP sends a duplicate */
248 /* SetWindowPos(SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOMOVE)
249 * for a visible popup window.
251 static const struct message WmSWP_ResizePopupSeq
[] = {
252 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
},
253 { WM_GETMINMAXINFO
, sent
|defwinproc
|optional
}, /* Win9x */
254 { WM_NCCALCSIZE
, sent
|wparam
|optional
, TRUE
},
255 { WM_NCPAINT
, sent
|optional
},
256 { WM_GETTEXT
, sent
|defwinproc
|optional
},
257 { WM_ERASEBKGND
, sent
|optional
},
258 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
},
259 { WM_SIZE
, sent
|defwinproc
|wparam
|optional
, SIZE_RESTORED
},
260 { WM_NCCALCSIZE
, sent
|wparam
|optional
, TRUE
},
261 { WM_NCPAINT
, sent
|optional
},
262 { WM_GETTEXT
, sent
|defwinproc
|optional
},
263 { WM_ERASEBKGND
, sent
|optional
},
264 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
268 /* SetWindowPos(SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOSIZE)
269 * for a visible overlapped window.
271 static const struct message WmSWP_MoveSeq
[] = {
272 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOSIZE
},
273 { WM_NCPAINT
, sent
|optional
},
274 { WM_GETTEXT
, sent
|defwinproc
|optional
},
275 { WM_ERASEBKGND
, sent
|optional
},
276 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOCLIENTSIZE
},
277 { WM_MOVE
, sent
|defwinproc
|wparam
, 0 },
278 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
281 /* Resize with SetWindowPos(SWP_NOZORDER)
282 * for a visible overlapped window
283 * SWP_NOZORDER is stripped by the logging code
285 static const struct message WmSWP_ResizeNoZOrder
[] = {
286 { WM_WINDOWPOSCHANGING
, sent
|wparam
, /*SWP_NOZORDER|*/SWP_NOACTIVATE
},
287 { WM_GETMINMAXINFO
, sent
|defwinproc
},
288 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
289 { WM_NCPAINT
, sent
|optional
},
290 { WM_GETTEXT
, sent
|defwinproc
|optional
},
291 { WM_ERASEBKGND
, sent
|optional
},
292 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, /*SWP_NOZORDER|*/SWP_NOACTIVATE
, 0,
293 SWP_NOMOVE
|SWP_NOCLIENTMOVE
|SWP_NOSIZE
|SWP_NOCLIENTSIZE
},
294 { WM_MOVE
, sent
|defwinproc
|optional
},
295 { WM_SIZE
, sent
|defwinproc
|optional
},
296 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 }, /* Win9x doesn't send it */
297 { WM_NCPAINT
, sent
|optional
}, /* Win9x doesn't send it */
298 { WM_GETTEXT
, sent
|defwinproc
|optional
}, /* Win9x doesn't send it */
299 { WM_ERASEBKGND
, sent
|optional
}, /* Win9x doesn't send it */
300 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
301 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
305 /* Switch visible mdi children */
306 static const struct message WmSwitchChild
[] = {
307 /* Switch MDI child */
308 { WM_MDIACTIVATE
, sent
},/* in the MDI client */
309 { WM_WINDOWPOSCHANGING
, sent
|wparam
,SWP_NOSIZE
|SWP_NOMOVE
},/* in the 1st MDI child */
310 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
311 { WM_CHILDACTIVATE
, sent
},/* in the 1st MDI child */
312 /* Deactivate 2nd MDI child */
313 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 0 }, /* in the 2nd MDI child */
314 { WM_MDIACTIVATE
, sent
|defwinproc
}, /* in the 2nd MDI child */
315 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
316 /* Preparing for maximize and maximize the 1st MDI child */
317 { WM_GETMINMAXINFO
, sent
|defwinproc
}, /* in the 1st MDI child */
318 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_STATECHANGED
}, /* in the 1st MDI child */
319 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 }, /* in the 1st MDI child */
320 { WM_CHILDACTIVATE
, sent
|defwinproc
}, /* in the 1st MDI child */
321 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
}, /* in the 1st MDI child */
322 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
}, /* in the 1st MDI child */
323 /* Lock redraw 2nd MDI child */
324 { WM_SETREDRAW
, sent
|wparam
|defwinproc
, 0 }, /* in the 2nd MDI child */
325 { HCBT_MINMAX
, hook
|lparam
, 0, SW_NORMALNA
},
326 /* Restore 2nd MDI child */
327 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_STATECHANGED
},/* in the 2nd MDI child */
328 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 },/* in the 2nd MDI child */
329 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* in the 2nd MDI child */
330 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
}, /* in the 2nd MDI child */
331 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
}, /* in the 2nd MDI child */
332 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* in the 2nd MDI child */
333 /* Redraw 2nd MDI child */
334 { WM_SETREDRAW
, sent
|wparam
|defwinproc
, 1 },/* in the 2nd MDI child */
335 /* Redraw MDI frame */
336 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
},/* in MDI frame */
337 { WM_NCCALCSIZE
, sent
|wparam
, 1 },/* in MDI frame */
338 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
}, /* in MDI frame */
339 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* in MDI frame */
340 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* in the 1st MDI child */
341 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
}, /* in the 1st MDI child */
342 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 }, /* in the 1st MDI child */
343 { HCBT_SETFOCUS
, hook
},
344 { WM_KILLFOCUS
, sent
|defwinproc
}, /* in the 2nd MDI child */
345 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 0 },/* in the 1st MDI child */
346 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
347 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
348 { WM_SETFOCUS
, sent
},/* in the MDI client */
349 { HCBT_SETFOCUS
, hook
},
350 { WM_KILLFOCUS
, sent
},/* in the MDI client */
351 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
352 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 }, /* in the 1st MDI child */
353 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
354 { WM_SETFOCUS
, sent
|defwinproc
}, /* in the 1st MDI child */
355 { WM_MDIACTIVATE
, sent
|defwinproc
},/* in the 1st MDI child */
356 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
}, /* in the 1st MDI child */
360 /* Switch visible not maximized mdi children */
361 static const struct message WmSwitchNotMaximizedChild
[] = {
362 /* Switch not maximized MDI child */
363 { WM_MDIACTIVATE
, sent
},/* in the MDI client */
364 { WM_WINDOWPOSCHANGING
, sent
|wparam
,SWP_NOSIZE
|SWP_NOMOVE
},/* in the 2nd MDI child */
365 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
366 { WM_CHILDACTIVATE
, sent
},/* in the 2nd MDI child */
367 /* Deactivate 1st MDI child */
368 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 0 }, /* in the 1st MDI child */
369 { WM_MDIACTIVATE
, sent
|defwinproc
}, /* in the 1st MDI child */
370 /* Activate 2nd MDI child */
371 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
}, /* in the 2nd MDI child */
372 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 }, /* in the 2nd MDI child */
373 { HCBT_SETFOCUS
, hook
}, /* in the 1st MDI child */
374 { WM_KILLFOCUS
, sent
|defwinproc
}, /* in the 1st MDI child */
375 { WM_IME_SETCONTEXT
, sent
|defwinproc
|optional
}, /* in the 1st MDI child */
376 { WM_IME_SETCONTEXT
, sent
|optional
}, /* in the MDI client */
377 { WM_SETFOCUS
, sent
, 0 }, /* in the MDI client */
378 { HCBT_SETFOCUS
, hook
},
379 { WM_KILLFOCUS
, sent
}, /* in the MDI client */
380 { WM_IME_SETCONTEXT
, sent
|optional
}, /* in the MDI client */
381 { WM_IME_SETCONTEXT
, sent
|defwinproc
|optional
}, /* in the 1st MDI child */
382 { WM_SETFOCUS
, sent
|defwinproc
}, /* in the 2nd MDI child */
383 { WM_MDIACTIVATE
, sent
|defwinproc
}, /* in the 2nd MDI child */
384 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
}, /* in the 2nd MDI child */
389 /* SetWindowPos(SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|
390 SWP_NOZORDER|SWP_FRAMECHANGED)
391 * for a visible overlapped window with WS_CLIPCHILDREN style set.
393 static const struct message WmSWP_FrameChanged_clip
[] = {
394 { WM_WINDOWPOSCHANGING
, sent
|wparam
|parent
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
},
395 { WM_NCCALCSIZE
, sent
|wparam
|parent
, 1 },
396 { WM_NCPAINT
, sent
|parent
|optional
}, /* wparam != 1 */
397 { WM_GETTEXT
, sent
|parent
|defwinproc
|optional
},
398 { WM_ERASEBKGND
, sent
|parent
|optional
}, /* FIXME: remove optional once Wine is fixed */
399 { WM_NCPAINT
, sent
}, /* wparam != 1 */
400 { WM_ERASEBKGND
, sent
},
401 { WM_WINDOWPOSCHANGED
, sent
|wparam
|parent
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
402 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
406 /* SetWindowPos(SWP_NOSIZE|SWP_NOMOVE|SWP_DEFERERASE|SWP_NOACTIVATE|
407 SWP_NOZORDER|SWP_FRAMECHANGED)
408 * for a visible overlapped window.
410 static const struct message WmSWP_FrameChangedDeferErase
[] = {
411 { WM_WINDOWPOSCHANGING
, sent
|wparam
|parent
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_DEFERERASE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
},
412 { WM_NCCALCSIZE
, sent
|wparam
|parent
, 1 },
413 { WM_WINDOWPOSCHANGED
, sent
|wparam
|parent
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_DEFERERASE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
414 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
415 { WM_PAINT
, sent
|parent
|optional
},
416 { WM_NCPAINT
, sent
|beginpaint
|parent
|optional
}, /* wparam != 1 */
417 { WM_GETTEXT
, sent
|beginpaint
|parent
|defwinproc
|optional
},
419 { WM_NCPAINT
, sent
|beginpaint
}, /* wparam != 1 */
420 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
424 /* SetWindowPos(SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|
425 SWP_NOZORDER|SWP_FRAMECHANGED)
426 * for a visible overlapped window without WS_CLIPCHILDREN style set.
428 static const struct message WmSWP_FrameChanged_noclip
[] = {
429 { WM_WINDOWPOSCHANGING
, sent
|wparam
|parent
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
},
430 { WM_NCCALCSIZE
, sent
|wparam
|parent
, 1 },
431 { WM_NCPAINT
, sent
|parent
|optional
}, /* wparam != 1 */
432 { WM_GETTEXT
, sent
|parent
|defwinproc
|optional
},
433 { WM_ERASEBKGND
, sent
|parent
|optional
},
434 { WM_WINDOWPOSCHANGED
, sent
|wparam
|parent
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
435 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
437 { WM_NCPAINT
, sent
|beginpaint
}, /* wparam != 1 */
438 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
442 /* ShowWindow(SW_SHOW) for a not visible overlapped window */
443 static const struct message WmShowOverlappedSeq
[] = {
444 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
445 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
446 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
447 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
448 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
449 { WM_GETTEXT
, sent
|defwinproc
|optional
},
450 { WM_ERASEBKGND
, sent
|optional
},
451 { HCBT_ACTIVATE
, hook
|optional
},
452 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
453 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
454 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
455 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
456 { WM_ACTIVATEAPP
, sent
|wparam
|optional
, 1 },
457 { WM_NCACTIVATE
, sent
|wparam
|optional
, 1 },
458 { WM_GETTEXT
, sent
|defwinproc
|optional
},
459 { WM_ACTIVATE
, sent
|wparam
|optional
, 1 },
460 { HCBT_SETFOCUS
, hook
|optional
},
461 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
462 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
463 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
464 { WM_SETFOCUS
, sent
|wparam
|defwinproc
|optional
, 0 },
465 { WM_GETTEXT
, sent
|optional
},
466 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
467 { WM_GETTEXT
, sent
|defwinproc
|optional
},
468 { WM_ERASEBKGND
, sent
|optional
},
469 /* Win9x adds SWP_NOZORDER below */
470 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
471 { WM_NCCALCSIZE
, sent
|optional
},
472 { WM_GETTEXT
, sent
|optional
},
473 { WM_NCPAINT
, sent
|optional
},
474 { WM_ERASEBKGND
, sent
|optional
},
475 { WM_SYNCPAINT
, sent
|optional
},
476 #if 0 /* CreateWindow/ShowWindow(SW_SHOW) also generates WM_SIZE/WM_MOVE
477 * messages. Does that mean that CreateWindow doesn't set initial
478 * window dimensions for overlapped windows?
483 { WM_PAINT
, sent
|optional
},
484 { WM_NCPAINT
, sent
|beginpaint
|optional
},
487 /* ShowWindow(SW_SHOWMAXIMIZED) for a not visible overlapped window */
488 static const struct message WmShowMaxOverlappedSeq
[] = {
489 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
490 { WM_GETMINMAXINFO
, sent
},
491 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_STATECHANGED
},
492 { WM_GETMINMAXINFO
, sent
|defwinproc
},
493 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
494 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
495 { HCBT_ACTIVATE
, hook
|optional
},
496 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
497 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
498 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
499 { WM_ACTIVATEAPP
, sent
|wparam
|optional
, 1 },
500 { WM_NCACTIVATE
, sent
|wparam
|optional
, 1 },
501 { WM_GETTEXT
, sent
|defwinproc
|optional
},
502 { WM_ACTIVATE
, sent
|wparam
|optional
, 1 },
503 { HCBT_SETFOCUS
, hook
|optional
},
504 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
505 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
506 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
507 { WM_SETFOCUS
, sent
|wparam
|defwinproc
|optional
, 0 },
508 { WM_GETTEXT
, sent
|optional
},
509 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
510 { WM_GETTEXT
, sent
|defwinproc
|optional
},
511 { WM_ERASEBKGND
, sent
|optional
},
512 /* Win9x adds SWP_NOZORDER below */
513 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_STATECHANGED
},
514 { WM_MOVE
, sent
|defwinproc
},
515 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
516 { WM_GETTEXT
, sent
|optional
},
517 { WM_NCCALCSIZE
, sent
|optional
},
518 { WM_NCPAINT
, sent
|optional
},
519 { WM_ERASEBKGND
, sent
|optional
},
520 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
521 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
522 { WM_SYNCPAINT
, sent
|optional
},
523 { WM_GETTITLEBARINFOEX
, sent
|optional
},
524 { WM_PAINT
, sent
|optional
},
525 { WM_NCPAINT
, sent
|beginpaint
|optional
},
526 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
529 /* ShowWindow(SW_RESTORE) for a not visible maximized overlapped window */
530 static const struct message WmShowRestoreMaxOverlappedSeq
[] = {
531 { HCBT_MINMAX
, hook
|lparam
, 0, SW_RESTORE
},
532 { WM_GETTEXT
, sent
|optional
},
533 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
534 { WM_GETMINMAXINFO
, sent
|defwinproc
},
535 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
536 { WM_NCPAINT
, sent
|optional
},
537 { WM_GETTEXT
, sent
|defwinproc
|optional
},
538 { WM_ERASEBKGND
, sent
|optional
},
539 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
, 0, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOSIZE
|SWP_NOMOVE
},
540 { WM_MOVE
, sent
|defwinproc
|optional
},
541 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
542 { WM_NCCALCSIZE
, sent
|wparam
|optional
, TRUE
},
543 { WM_NCPAINT
, sent
|optional
},
544 { WM_ERASEBKGND
, sent
|optional
},
545 { WM_PAINT
, sent
|optional
},
546 { WM_GETTITLEBARINFOEX
, sent
|optional
},
547 { WM_NCPAINT
, sent
|beginpaint
|optional
},
548 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
551 /* ShowWindow(SW_RESTORE) for a not visible minimized overlapped window */
552 static const struct message WmShowRestoreMinOverlappedSeq
[] = {
553 { HCBT_MINMAX
, hook
|lparam
, 0, SW_RESTORE
},
554 { WM_QUERYOPEN
, sent
|optional
},
555 { WM_GETTEXT
, sent
|optional
},
556 { WM_NCACTIVATE
, sent
|wparam
|optional
, 1 },
557 { WM_WINDOWPOSCHANGING
, sent
|optional
}, /* SWP_NOSIZE|SWP_NOMOVE */
558 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
559 { WM_NCCALCSIZE
, sent
|wparam
|optional
, TRUE
},
560 { WM_MOVE
, sent
|optional
},
561 { WM_SIZE
, sent
|wparam
|optional
, SIZE_RESTORED
},
562 { WM_GETTEXT
, sent
|optional
},
563 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_FRAMECHANGED
|SWP_STATECHANGED
|SWP_NOCOPYBITS
},
564 { WM_GETMINMAXINFO
, sent
|defwinproc
|optional
},
565 { WM_NCCALCSIZE
, sent
|wparam
|optional
, TRUE
},
566 { HCBT_ACTIVATE
, hook
|optional
},
567 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
568 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
569 { WM_ACTIVATEAPP
, sent
|wparam
|optional
, 1 },
570 { WM_NCACTIVATE
, sent
|wparam
|optional
, 1 },
571 { WM_GETTEXT
, sent
|defwinproc
|optional
},
572 { WM_ACTIVATE
, sent
|wparam
|optional
, 1 },
573 { HCBT_SETFOCUS
, hook
|optional
},
574 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
575 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
576 { WM_SETFOCUS
, sent
|wparam
|defwinproc
|optional
, 0 },
577 { WM_GETTEXT
, sent
|optional
},
578 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
579 { WM_GETTEXT
, sent
|defwinproc
|optional
},
580 { WM_ERASEBKGND
, sent
},
581 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_STATECHANGED
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
},
582 { WM_MOVE
, sent
|defwinproc
},
583 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
584 { HCBT_SETFOCUS
, hook
|optional
},
585 { WM_SETFOCUS
, sent
|wparam
|optional
, 0 },
586 { WM_NCCALCSIZE
, sent
|wparam
|optional
, TRUE
},
587 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
588 { WM_ERASEBKGND
, sent
|optional
},
589 { HCBT_SETFOCUS
, hook
|optional
},
590 { WM_SETFOCUS
, sent
|wparam
|optional
, 0 },
591 { WM_ACTIVATE
, sent
|wparam
, 1 },
592 { WM_GETTEXT
, sent
|optional
},
593 { WM_PAINT
, sent
|optional
},
594 { WM_GETTITLEBARINFOEX
, sent
|optional
},
595 { WM_NCPAINT
, sent
|beginpaint
|optional
},
596 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
599 /* ShowWindow(SW_SHOWMINIMIZED) for a not visible overlapped window */
600 static const struct message WmShowMinOverlappedSeq
[] = {
601 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
602 { HCBT_SETFOCUS
, hook
|optional
},
603 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
604 { WM_KILLFOCUS
, sent
|optional
},
605 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
606 { WM_IME_NOTIFY
, sent
|wparam
|optional
|defwinproc
, 1 },
607 { WM_GETTEXT
, sent
|optional
},
608 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOCOPYBITS
|SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_STATECHANGED
},
609 { WM_GETMINMAXINFO
, sent
|defwinproc
},
610 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
611 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
612 { WM_NCPAINT
, sent
|optional
},
613 { WM_GETTEXT
, sent
|defwinproc
|optional
},
614 { WM_WINDOWPOSCHANGED
, sent
},
615 { WM_MOVE
, sent
|defwinproc
},
616 { WM_SIZE
, sent
|defwinproc
|wparam
|lparam
, SIZE_MINIMIZED
, 0 },
617 { WM_NCCALCSIZE
, sent
|optional
},
618 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
619 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
620 { EVENT_SYSTEM_MINIMIZESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
621 { WM_NCACTIVATE
, sent
|wparam
|optional
, 0 },
622 { WM_GETTEXT
, sent
|defwinproc
|optional
},
623 { WM_ACTIVATE
, sent
|optional
},
624 { WM_ACTIVATEAPP
, sent
|wparam
|optional
, 0 },
626 /* Vista sometimes restores the window right away... */
627 { WM_SYSCOMMAND
, sent
|optional
|wparam
, SC_RESTORE
},
628 { HCBT_SYSCOMMAND
, hook
|optional
|wparam
, SC_RESTORE
},
629 { HCBT_MINMAX
, hook
|optional
|lparam
, 0, SW_RESTORE
},
630 { WM_QUERYOPEN
, sent
|optional
},
631 { WM_WINDOWPOSCHANGING
, sent
|optional
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
632 { WM_GETMINMAXINFO
, sent
|optional
|defwinproc
},
633 { WM_NCCALCSIZE
, sent
|optional
|wparam
, TRUE
},
634 { HCBT_ACTIVATE
, hook
|optional
},
635 { WM_ACTIVATEAPP
, sent
|optional
|wparam
, 1 },
636 { WM_NCACTIVATE
, sent
|optional
},
637 { WM_GETTEXT
, sent
|optional
},
638 { WM_ACTIVATE
, sent
|optional
|wparam
, 1 },
639 { HCBT_SETFOCUS
, hook
|optional
},
640 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
641 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
642 { WM_SETFOCUS
, sent
|optional
},
643 { WM_NCPAINT
, sent
|optional
},
644 { WM_GETTEXT
, sent
|defwinproc
|optional
},
645 { WM_ERASEBKGND
, sent
|optional
},
646 { WM_WINDOWPOSCHANGED
, sent
|optional
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
647 { WM_MOVE
, sent
|defwinproc
|optional
},
648 { WM_SIZE
, sent
|defwinproc
|optional
|wparam
, SIZE_RESTORED
},
649 { WM_ACTIVATE
, sent
|optional
|wparam
, 1 },
650 { WM_SYSCOMMAND
, sent
|optional
|wparam
, SC_RESTORE
},
651 { HCBT_SYSCOMMAND
, hook
|optional
|wparam
, SC_RESTORE
},
653 { WM_PAINT
, sent
|optional
},
654 { WM_NCPAINT
, sent
|beginpaint
|optional
},
655 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
658 /* ShowWindow(SW_HIDE) for a visible overlapped window */
659 static const struct message WmHideOverlappedSeq
[] = {
660 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
661 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
662 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
663 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
664 { WM_SIZE
, sent
|optional
}, /* XP doesn't send it */
665 { WM_MOVE
, sent
|optional
}, /* XP doesn't send it */
666 { WM_NCACTIVATE
, sent
|wparam
|optional
, 0 },
667 { WM_ACTIVATE
, sent
|wparam
|optional
, 0 },
668 { WM_ACTIVATEAPP
, sent
|wparam
|optional
, 0 },
669 { HCBT_SETFOCUS
, hook
|optional
},
670 { WM_KILLFOCUS
, sent
|wparam
|optional
, 0 },
671 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
672 { WM_IME_NOTIFY
, sent
|wparam
|optional
|defwinproc
, 1 },
675 /* DestroyWindow for a visible overlapped window */
676 static const struct message WmDestroyOverlappedSeq
[] = {
677 { HCBT_DESTROYWND
, hook
},
678 { 0x0090, sent
|optional
},
679 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
680 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
681 { 0x0090, sent
|optional
},
682 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
683 { WM_NCACTIVATE
, sent
|optional
|wparam
, 0 },
684 { WM_ACTIVATE
, sent
|optional
},
685 { WM_ACTIVATEAPP
, sent
|optional
|wparam
, 0 },
686 { WM_KILLFOCUS
, sent
|optional
|wparam
, 0 },
687 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
688 { WM_IME_NOTIFY
, sent
|wparam
|optional
|defwinproc
, 1 },
689 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
690 { WM_DESTROY
, sent
},
691 { WM_NCDESTROY
, sent
},
694 /* CreateWindow(WS_MAXIMIZE|WS_VISIBLE) for popup window */
695 static const struct message WmCreateMaxPopupSeq
[] = {
696 { HCBT_CREATEWND
, hook
},
697 { WM_NCCREATE
, sent
},
698 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
700 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
701 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
703 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
704 { WM_GETMINMAXINFO
, sent
},
705 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_STATECHANGED
},
706 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
707 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOREDRAW
|SWP_STATECHANGED
},
708 { WM_MOVE
, sent
|defwinproc
},
709 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
710 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
711 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
712 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
713 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
714 { HCBT_ACTIVATE
, hook
},
715 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
716 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
717 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
718 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
719 { WM_ERASEBKGND
, sent
|optional
},
720 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOCLIENTMOVE
|SWP_NOCLIENTSIZE
|SWP_NOMOVE
|SWP_NOSIZE
},
721 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
722 { WM_NCACTIVATE
, sent
},
723 { WM_ACTIVATE
, sent
|wparam
, 1 },
724 { HCBT_SETFOCUS
, hook
},
725 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
726 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
727 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
728 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
729 { WM_GETTEXT
, sent
|optional
},
730 { WM_SYNCPAINT
, sent
|wparam
|optional
, 4 },
731 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
732 { WM_ERASEBKGND
, sent
|optional
},
733 { WM_NCPAINT
, sent
|wparam
|defwinproc
|optional
, 1 },
734 { WM_ERASEBKGND
, sent
|defwinproc
|optional
},
735 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOCLIENTMOVE
|SWP_NOCLIENTSIZE
|SWP_SHOWWINDOW
|SWP_NOMOVE
|SWP_NOSIZE
},
738 /* CreateWindow(WS_MAXIMIZE) for popup window, not initially visible */
739 static const struct message WmCreateInvisibleMaxPopupSeq
[] = {
740 { HCBT_CREATEWND
, hook
},
741 { WM_NCCREATE
, sent
},
742 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
744 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
745 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
747 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
748 { WM_GETMINMAXINFO
, sent
},
749 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_STATECHANGED
},
750 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
751 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOREDRAW
|SWP_STATECHANGED
},
752 { WM_MOVE
, sent
|defwinproc
},
753 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
754 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
757 /* ShowWindow(SW_SHOWMAXIMIZED) for a resized not visible popup window */
758 static const struct message WmShowMaxPopupResizedSeq
[] = {
759 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
760 { WM_GETMINMAXINFO
, sent
},
761 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
},
762 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
763 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
764 { HCBT_ACTIVATE
, hook
},
765 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
766 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
767 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
768 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
769 { WM_ERASEBKGND
, sent
|optional
},
770 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
771 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
772 { WM_NCACTIVATE
, sent
},
773 { WM_ACTIVATE
, sent
|wparam
, 1 },
774 { HCBT_SETFOCUS
, hook
},
775 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
776 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
777 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
778 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
779 { WM_GETTEXT
, sent
|optional
},
780 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
781 { WM_ERASEBKGND
, sent
|optional
},
782 { WM_WINDOWPOSCHANGED
, sent
},
783 /* WinNT4.0 sends WM_MOVE */
784 { WM_MOVE
, sent
|defwinproc
|optional
},
785 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
786 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
789 /* ShowWindow(SW_SHOWMAXIMIZED) for a not visible popup window */
790 static const struct message WmShowMaxPopupSeq
[] = {
791 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
792 { WM_GETMINMAXINFO
, sent
},
793 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
},
794 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
795 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
796 { HCBT_ACTIVATE
, hook
},
797 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
798 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
799 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
800 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
801 { WM_ERASEBKGND
, sent
|optional
},
802 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOMOVE
|SWP_NOSIZE
},
803 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
804 { WM_NCACTIVATE
, sent
},
805 { WM_ACTIVATE
, sent
|wparam
, 1 },
806 { HCBT_SETFOCUS
, hook
},
807 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
808 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
809 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
810 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
811 { WM_GETTEXT
, sent
|optional
},
812 { WM_SYNCPAINT
, sent
|wparam
|optional
, 4 },
813 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
814 { WM_ERASEBKGND
, sent
|optional
},
815 { WM_NCPAINT
, sent
|wparam
|defwinproc
|optional
, 1 },
816 { WM_ERASEBKGND
, sent
|defwinproc
|optional
},
817 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOMOVE
|SWP_NOSIZE
},
818 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
821 /* CreateWindow(WS_VISIBLE) for popup window */
822 static const struct message WmCreatePopupSeq
[] = {
823 { HCBT_CREATEWND
, hook
},
824 { WM_NCCREATE
, sent
},
825 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
827 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
828 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
830 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
831 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
832 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
833 { HCBT_ACTIVATE
, hook
},
834 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
835 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
836 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
837 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
838 { WM_ERASEBKGND
, sent
|optional
},
839 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
840 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
841 { WM_NCACTIVATE
, sent
},
842 { WM_ACTIVATE
, sent
|wparam
, 1 },
843 { HCBT_SETFOCUS
, hook
},
844 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
845 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
846 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
847 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
848 { WM_GETTEXT
, sent
|optional
},
849 { WM_SYNCPAINT
, sent
|wparam
|optional
, 4 },
850 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
851 { WM_ERASEBKGND
, sent
|optional
},
852 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOCLIENTMOVE
|SWP_NOCLIENTSIZE
|SWP_SHOWWINDOW
|SWP_NOMOVE
|SWP_NOSIZE
},
855 /* ShowWindow(SW_SHOWMAXIMIZED) for a visible popup window */
856 static const struct message WmShowVisMaxPopupSeq
[] = {
857 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
858 { WM_GETMINMAXINFO
, sent
},
859 { WM_GETTEXT
, sent
|optional
},
860 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
861 { WM_GETTEXT
, sent
|optional
},
862 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
863 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
864 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
865 { WM_ERASEBKGND
, sent
|optional
},
866 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
867 { WM_MOVE
, sent
|defwinproc
},
868 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
869 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
872 /* CreateWindow (for a child popup window, not initially visible) */
873 static const struct message WmCreateChildPopupSeq
[] = {
874 { HCBT_CREATEWND
, hook
},
875 { WM_NCCREATE
, sent
},
876 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
878 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
879 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
883 /* CreateWindow (for a popup window, not initially visible,
884 * which sets WS_VISIBLE in WM_CREATE handler)
886 static const struct message WmCreateInvisiblePopupSeq
[] = {
887 { HCBT_CREATEWND
, hook
},
888 { WM_NCCREATE
, sent
},
889 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
891 { WM_STYLECHANGING
, sent
},
892 { WM_STYLECHANGED
, sent
},
893 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
894 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
898 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER)
899 * for a popup window with WS_VISIBLE style set
901 static const struct message WmShowVisiblePopupSeq_2
[] = {
902 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
905 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
906 * for a popup window with WS_VISIBLE style set
908 static const struct message WmShowVisiblePopupSeq_3
[] = {
909 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
910 { HCBT_ACTIVATE
, hook
},
911 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
912 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
913 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
914 { WM_NCACTIVATE
, sent
},
915 { WM_ACTIVATE
, sent
|wparam
, 1 },
916 { HCBT_SETFOCUS
, hook
},
917 { WM_KILLFOCUS
, sent
|parent
},
918 { WM_IME_SETCONTEXT
, sent
|parent
|wparam
|optional
, 0 },
919 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
920 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
921 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
922 { WM_SETFOCUS
, sent
|defwinproc
},
923 { WM_GETTEXT
, sent
|optional
},
924 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
, 0, SWP_SHOWWINDOW
},
927 /* CreateWindow (for child window, not initially visible) */
928 static const struct message WmCreateChildSeq
[] = {
929 { HCBT_CREATEWND
, hook
},
930 { WM_NCCREATE
, sent
},
931 /* child is inserted into parent's child list after WM_NCCREATE returns */
932 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
934 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
935 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
937 { WM_PARENTNOTIFY
, sent
|parent
|wparam
, WM_CREATE
},
940 /* CreateWindow (for maximized child window, not initially visible) */
941 static const struct message WmCreateMaximizedChildSeq
[] = {
942 { HCBT_CREATEWND
, hook
},
943 { WM_NCCREATE
, sent
},
944 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
946 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
947 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
949 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
950 { WM_GETMINMAXINFO
, sent
},
951 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_STATECHANGED
},
952 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
953 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
954 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
955 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
956 { WM_PARENTNOTIFY
, sent
|parent
|wparam
, WM_CREATE
},
959 /* CreateWindow (for a child window, initially visible) */
960 static const struct message WmCreateVisibleChildSeq
[] = {
961 { HCBT_CREATEWND
, hook
},
962 { WM_NCCREATE
, sent
},
963 /* child is inserted into parent's child list after WM_NCCREATE returns */
964 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
965 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
967 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
968 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
970 { WM_PARENTNOTIFY
, sent
|parent
|wparam
, WM_CREATE
},
971 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
972 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
973 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
974 { WM_ERASEBKGND
, sent
|parent
|optional
},
975 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
976 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 }, /* WinXP */
977 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
980 /* ShowWindow(SW_SHOW) for a not visible child window */
981 static const struct message WmShowChildSeq
[] = {
982 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
983 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
984 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
985 { WM_ERASEBKGND
, sent
|parent
|optional
},
986 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
989 /* ShowWindow(SW_HIDE) for a visible child window */
990 static const struct message WmHideChildSeq
[] = {
991 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
992 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
993 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
994 { WM_ERASEBKGND
, sent
|parent
|optional
},
995 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
998 /* ShowWindow(SW_HIDE) for a visible child window checking all parent events*/
999 static const struct message WmHideChildSeq2
[] = {
1000 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
1001 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1002 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1003 { WM_ERASEBKGND
, sent
|parent
|optional
},
1004 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1007 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
1008 * for a not visible child window
1010 static const struct message WmShowChildSeq_2
[] = {
1011 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
1012 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1013 { WM_CHILDACTIVATE
, sent
},
1014 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1017 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE)
1018 * for a not visible child window
1020 static const struct message WmShowChildSeq_3
[] = {
1021 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
1022 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1023 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1026 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
1027 * for a visible child window with a caption
1029 static const struct message WmShowChildSeq_4
[] = {
1030 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
1031 { WM_CHILDACTIVATE
, sent
},
1034 /* ShowWindow(SW_MINIMIZE) for child with invisible parent */
1035 static const struct message WmShowChildInvisibleParentSeq_1
[] = {
1036 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
1037 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
, 0, SWP_NOACTIVATE
},
1038 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1039 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1040 { WM_CHILDACTIVATE
, sent
|optional
},
1041 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOREDRAW
|SWP_NOCOPYBITS
|SWP_STATECHANGED
, 0, SWP_NOACTIVATE
},
1042 { WM_MOVE
, sent
|defwinproc
},
1043 { WM_SIZE
, sent
|defwinproc
|wparam
|lparam
, SIZE_MINIMIZED
, 0 },
1044 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1045 { EVENT_SYSTEM_MINIMIZESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
1046 /* FIXME: Wine creates an icon/title window while Windows doesn't */
1047 { WM_PARENTNOTIFY
, sent
|parent
|wparam
|optional
, WM_CREATE
},
1048 { WM_GETTEXT
, sent
|optional
},
1051 /* repeated ShowWindow(SW_MINIMIZE) for child with invisible parent */
1052 static const struct message WmShowChildInvisibleParentSeq_1r
[] = {
1053 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
1056 /* ShowWindow(SW_MAXIMIZE) for child with invisible parent */
1057 static const struct message WmShowChildInvisibleParentSeq_2
[] = {
1058 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
1059 { WM_GETMINMAXINFO
, sent
},
1060 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_STATECHANGED
},
1061 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1062 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1063 { WM_CHILDACTIVATE
, sent
},
1064 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
1065 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
1066 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1069 /* repeated ShowWindow(SW_MAXIMIZE) for child with invisible parent */
1070 static const struct message WmShowChildInvisibleParentSeq_2r
[] = {
1071 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
1074 /* ShowWindow(SW_SHOWMINIMIZED) for child with invisible parent */
1075 static const struct message WmShowChildInvisibleParentSeq_3
[] = {
1076 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINIMIZED
},
1077 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
1078 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1079 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1080 { WM_CHILDACTIVATE
, sent
},
1081 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOREDRAW
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
1082 { WM_MOVE
, sent
|defwinproc
},
1083 { WM_SIZE
, sent
|defwinproc
|wparam
|lparam
, SIZE_MINIMIZED
, 0 },
1084 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1085 { EVENT_SYSTEM_MINIMIZESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
1086 /* FIXME: Wine creates an icon/title window while Windows doesn't */
1087 { WM_PARENTNOTIFY
, sent
|parent
|wparam
|optional
, WM_CREATE
},
1088 { WM_GETTEXT
, sent
|optional
},
1091 /* repeated ShowWindow(SW_SHOWMINIMIZED) for child with invisible parent */
1092 static const struct message WmShowChildInvisibleParentSeq_3r
[] = {
1093 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINIMIZED
},
1096 /* ShowWindow(SW_SHOWMINNOACTIVE) for child with invisible parent */
1097 static const struct message WmShowChildInvisibleParentSeq_4
[] = {
1098 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINNOACTIVE
},
1099 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
1100 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1101 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1102 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOREDRAW
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
1103 { WM_MOVE
, sent
|defwinproc
},
1104 { WM_SIZE
, sent
|defwinproc
|wparam
|lparam
, SIZE_MINIMIZED
, 0 },
1105 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1106 { EVENT_SYSTEM_MINIMIZESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
1107 /* FIXME: Wine creates an icon/title window while Windows doesn't */
1108 { WM_PARENTNOTIFY
, sent
|parent
|wparam
|optional
, WM_CREATE
},
1109 { WM_GETTEXT
, sent
|optional
},
1112 /* repeated ShowWindow(SW_SHOWMINNOACTIVE) for child with invisible parent */
1113 static const struct message WmShowChildInvisibleParentSeq_4r
[] = {
1114 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINNOACTIVE
},
1117 /* ShowWindow(SW_SHOW) for child with invisible parent */
1118 static const struct message WmShowChildInvisibleParentSeq_5
[] = {
1119 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1122 /* ShowWindow(SW_HIDE) for child with invisible parent */
1123 static const struct message WmHideChildInvisibleParentSeq
[] = {
1124 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
1127 /* SetWindowPos(SWP_SHOWWINDOW) for child with invisible parent */
1128 static const struct message WmShowChildInvisibleParentSeq_6
[] = {
1129 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
1130 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1131 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1134 /* SetWindowPos(SWP_HIDEWINDOW) for child with invisible parent */
1135 static const struct message WmHideChildInvisibleParentSeq_2
[] = {
1136 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1137 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1138 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1141 /* DestroyWindow for a visible child window */
1142 static const struct message WmDestroyChildSeq
[] = {
1143 { HCBT_DESTROYWND
, hook
},
1144 { 0x0090, sent
|optional
},
1145 { WM_PARENTNOTIFY
, sent
|parent
|wparam
, WM_DESTROY
},
1146 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
1147 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1148 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1149 { WM_ERASEBKGND
, sent
|parent
|optional
},
1150 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1151 { HCBT_SETFOCUS
, hook
}, /* set focus to a parent */
1152 { WM_KILLFOCUS
, sent
},
1153 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
1154 { WM_IME_SETCONTEXT
, sent
|wparam
|parent
|optional
, 1 },
1155 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1156 { WM_SETFOCUS
, sent
|parent
},
1157 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
1158 { WM_DESTROY
, sent
},
1159 { WM_DESTROY
, sent
|optional
}, /* some other (IME?) window */
1160 { WM_NCDESTROY
, sent
|optional
}, /* some other (IME?) window */
1161 { WM_NCDESTROY
, sent
},
1164 /* visible child window destroyed by thread exit */
1165 static const struct message WmExitThreadSeq
[] = {
1166 { WM_NCDESTROY
, sent
}, /* actually in grandchild */
1167 { WM_PAINT
, sent
|parent
},
1168 { WM_ERASEBKGND
, sent
|parent
|beginpaint
},
1171 /* DestroyWindow for a visible child window with invisible parent */
1172 static const struct message WmDestroyInvisibleChildSeq
[] = {
1173 { HCBT_DESTROYWND
, hook
},
1174 { 0x0090, sent
|optional
},
1175 { WM_PARENTNOTIFY
, sent
|parent
|wparam
, WM_DESTROY
},
1176 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
1177 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
1178 { WM_DESTROY
, sent
},
1179 { WM_NCDESTROY
, sent
},
1182 /* Resizing child window with MoveWindow (32) */
1183 static const struct message WmResizingChildWithMoveWindowSeq
[] = {
1184 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
1185 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1186 { WM_ERASEBKGND
, sent
|parent
|optional
},
1187 { WM_ERASEBKGND
, sent
|optional
},
1188 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
},
1189 { WM_MOVE
, sent
|defwinproc
},
1190 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
1191 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1194 /* Creation of a custom dialog (32) */
1195 static const struct message WmCreateCustomDialogSeq
[] = {
1196 { HCBT_CREATEWND
, hook
},
1197 { WM_GETMINMAXINFO
, sent
},
1198 { WM_NCCREATE
, sent
},
1199 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
1200 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
1201 { WM_CREATE
, sent
},
1202 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1203 { WM_NOTIFYFORMAT
, sent
|optional
},
1204 { WM_QUERYUISTATE
, sent
|optional
},
1205 { WM_WINDOWPOSCHANGING
, sent
|optional
},
1206 { WM_GETMINMAXINFO
, sent
|optional
},
1207 { WM_NCCALCSIZE
, sent
|optional
},
1208 { WM_WINDOWPOSCHANGED
, sent
|optional
},
1209 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1210 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
1211 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1212 { HCBT_ACTIVATE
, hook
},
1213 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
1216 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
1218 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
1220 { WM_NCACTIVATE
, sent
},
1221 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1222 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1223 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1224 { EVENT_OBJECT_DEFACTIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, OBJID_CLIENT
, 0 },
1225 { WM_ACTIVATE
, sent
|wparam
, 1 },
1226 { WM_GETTEXT
, sent
|optional
},
1227 { WM_KILLFOCUS
, sent
|parent
},
1228 { WM_IME_SETCONTEXT
, sent
|parent
|wparam
|optional
, 0 },
1229 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
1230 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
1231 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1232 { WM_SETFOCUS
, sent
},
1233 { WM_GETDLGCODE
, sent
|defwinproc
|wparam
, 0 },
1234 { WM_NCPAINT
, sent
|wparam
, 1 },
1235 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1236 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1237 { WM_ERASEBKGND
, sent
},
1238 { WM_CTLCOLORDLG
, sent
|optional
|defwinproc
},
1239 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1240 { WM_GETTEXT
, sent
|optional
},
1241 { WM_GETTEXT
, sent
|optional
},
1242 { WM_NCCALCSIZE
, sent
|optional
},
1243 { WM_NCPAINT
, sent
|optional
},
1244 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1245 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1246 { WM_ERASEBKGND
, sent
|optional
},
1247 { WM_CTLCOLORDLG
, sent
|optional
|defwinproc
},
1248 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1249 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
1253 /* Calling EndDialog for a custom dialog (32) */
1254 static const struct message WmEndCustomDialogSeq
[] = {
1255 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1256 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1257 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1258 { WM_GETTEXT
, sent
|optional
},
1259 { HCBT_ACTIVATE
, hook
},
1260 { WM_NCACTIVATE
, sent
|wparam
, 0 },
1261 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1262 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1263 { WM_ACTIVATE
, sent
|wparam
, 0 },
1264 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
1265 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1266 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOACTIVATE
|SWP_NOREDRAW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1267 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1268 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1269 { HCBT_SETFOCUS
, hook
},
1270 { WM_KILLFOCUS
, sent
},
1271 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
1272 { WM_IME_SETCONTEXT
, sent
|parent
|wparam
|defwinproc
|optional
, 1 },
1273 { WM_IME_NOTIFY
, sent
|wparam
|optional
, 1 },
1274 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1275 { WM_SETFOCUS
, sent
|parent
|defwinproc
},
1278 /* ShowWindow(SW_SHOW) for a custom dialog (initially invisible) */
1279 static const struct message WmShowCustomDialogSeq
[] = {
1280 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1281 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
1282 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1283 { HCBT_ACTIVATE
, hook
},
1284 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
1286 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
1288 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
1289 { WM_ACTIVATEAPP
, sent
|wparam
|optional
, 1 },
1290 { WM_NCACTIVATE
, sent
},
1291 { WM_ACTIVATE
, sent
|wparam
, 1 },
1292 { WM_GETTEXT
, sent
|optional
},
1294 { WM_KILLFOCUS
, sent
|parent
},
1295 { WM_IME_SETCONTEXT
, sent
|parent
|wparam
|optional
, 0 },
1296 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
1297 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
1298 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1299 { WM_SETFOCUS
, sent
},
1300 { WM_GETDLGCODE
, sent
|defwinproc
|wparam
, 0 },
1301 { WM_NCPAINT
, sent
|wparam
, 1 },
1302 { WM_ERASEBKGND
, sent
},
1303 { WM_CTLCOLORDLG
, sent
|defwinproc
},
1304 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1307 /* Creation and destruction of a modal dialog (32) */
1308 static const struct message WmModalDialogSeq
[] = {
1309 { WM_CANCELMODE
, sent
|parent
},
1310 { HCBT_SETFOCUS
, hook
},
1311 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1312 { WM_KILLFOCUS
, sent
|parent
},
1313 { WM_IME_SETCONTEXT
, sent
|parent
|wparam
|optional
, 0 },
1314 { EVENT_OBJECT_STATECHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1315 { WM_ENABLE
, sent
|parent
|wparam
, 0 },
1316 { HCBT_CREATEWND
, hook
},
1317 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
1318 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1319 { WM_SETFONT
, sent
},
1320 { WM_INITDIALOG
, sent
},
1321 { WM_CHANGEUISTATE
, sent
|optional
},
1322 { WM_UPDATEUISTATE
, sent
|optional
},
1323 { WM_SHOWWINDOW
, sent
},
1324 { HCBT_ACTIVATE
, hook
},
1325 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
1326 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
1327 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
},
1328 { WM_NCACTIVATE
, sent
},
1329 { WM_GETTEXT
, sent
|optional
},
1330 { WM_ACTIVATE
, sent
|wparam
, 1 },
1331 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
1332 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1333 { WM_NCPAINT
, sent
|optional
},
1334 { WM_GETTEXT
, sent
|optional
},
1335 { WM_ERASEBKGND
, sent
|optional
},
1336 { WM_CTLCOLORDLG
, sent
|optional
},
1337 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1338 { WM_GETTEXT
, sent
|optional
},
1339 { WM_NCCALCSIZE
, sent
|optional
},
1340 { WM_NCPAINT
, sent
|optional
},
1341 { WM_GETTEXT
, sent
|optional
},
1342 { WM_ERASEBKGND
, sent
|optional
},
1343 { WM_CTLCOLORDLG
, sent
|optional
},
1344 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1345 { WM_PAINT
, sent
|optional
},
1346 { WM_CTLCOLORBTN
, sent
|optional
},
1347 { WM_GETTITLEBARINFOEX
, sent
|optional
},
1348 { WM_ENTERIDLE
, sent
|parent
|optional
},
1349 { WM_ENTERIDLE
, sent
|parent
|optional
},
1350 { WM_ENTERIDLE
, sent
|parent
|optional
},
1351 { WM_ENTERIDLE
, sent
|parent
|optional
},
1352 { WM_ENTERIDLE
, sent
|parent
|optional
},
1353 { WM_ENTERIDLE
, sent
|parent
|optional
},
1354 { WM_ENTERIDLE
, sent
|parent
|optional
},
1355 { WM_ENTERIDLE
, sent
|parent
|optional
},
1356 { WM_ENTERIDLE
, sent
|parent
|optional
},
1357 { WM_ENTERIDLE
, sent
|parent
|optional
},
1358 { WM_ENTERIDLE
, sent
|parent
|optional
},
1359 { WM_ENTERIDLE
, sent
|parent
|optional
},
1360 { WM_ENTERIDLE
, sent
|parent
|optional
},
1361 { WM_ENTERIDLE
, sent
|parent
|optional
},
1362 { WM_ENTERIDLE
, sent
|parent
|optional
},
1363 { WM_ENTERIDLE
, sent
|parent
|optional
},
1364 { WM_ENTERIDLE
, sent
|parent
|optional
},
1365 { WM_ENTERIDLE
, sent
|parent
|optional
},
1366 { WM_ENTERIDLE
, sent
|parent
|optional
},
1367 { WM_ENTERIDLE
, sent
|parent
|optional
},
1369 { EVENT_OBJECT_STATECHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1370 { WM_ENABLE
, sent
|parent
|wparam
, 1 },
1371 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
1372 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1373 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1374 { WM_GETTEXT
, sent
|optional
},
1375 { HCBT_ACTIVATE
, hook
},
1376 { WM_NCACTIVATE
, sent
|wparam
, 0 },
1377 { WM_GETTEXT
, sent
|optional
},
1378 { WM_ACTIVATE
, sent
|wparam
, 0 },
1379 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
1380 { WM_WINDOWPOSCHANGING
, sent
|optional
},
1381 { WM_WINDOWPOSCHANGED
, sent
|optional
},
1382 { HCBT_SETFOCUS
, hook
},
1383 { WM_IME_SETCONTEXT
, sent
|parent
|wparam
|defwinproc
|optional
, 1 },
1384 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1385 { WM_SETFOCUS
, sent
|parent
|defwinproc
},
1386 { EVENT_SYSTEM_DIALOGEND
, winevent_hook
|wparam
|lparam
, 0, 0 },
1387 { HCBT_DESTROYWND
, hook
},
1388 { 0x0090, sent
|optional
},
1389 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
1390 { WM_DESTROY
, sent
},
1391 { WM_NCDESTROY
, sent
},
1394 /* SetMenu for NonVisible windows with size change*/
1395 static const struct message WmSetMenuNonVisibleSizeChangeSeq
[] = {
1396 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1397 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1398 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
1399 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
},
1400 { WM_MOVE
, sent
|defwinproc
},
1401 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
1402 { WM_NCCALCSIZE
,sent
|wparam
|optional
, 1 }, /* XP */
1403 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1404 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* XP sends a duplicate */
1405 { WM_GETTEXT
, sent
|optional
},
1406 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
1409 /* SetMenu for NonVisible windows with no size change */
1410 static const struct message WmSetMenuNonVisibleNoSizeChangeSeq
[] = {
1411 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1412 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1413 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1414 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1417 /* SetMenu for Visible windows with size change */
1418 static const struct message WmSetMenuVisibleSizeChangeSeq
[] = {
1419 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1420 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1421 { 0x0093, sent
|defwinproc
|optional
},
1422 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
1423 { WM_NCPAINT
, sent
|optional
}, /* wparam != 1 */
1424 { 0x0093, sent
|defwinproc
|optional
},
1425 { 0x0093, sent
|defwinproc
|optional
},
1426 { 0x0091, sent
|defwinproc
|optional
},
1427 { 0x0092, sent
|defwinproc
|optional
},
1428 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1429 { WM_ERASEBKGND
, sent
|optional
},
1430 { WM_ACTIVATE
, sent
|optional
},
1431 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1432 { WM_MOVE
, sent
|defwinproc
},
1433 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
1434 { 0x0093, sent
|optional
},
1435 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
1436 { 0x0093, sent
|defwinproc
|optional
},
1437 { WM_NCPAINT
, sent
|optional
}, /* wparam != 1 */
1438 { 0x0093, sent
|defwinproc
|optional
},
1439 { 0x0093, sent
|defwinproc
|optional
},
1440 { 0x0091, sent
|defwinproc
|optional
},
1441 { 0x0092, sent
|defwinproc
|optional
},
1442 { WM_ERASEBKGND
, sent
|optional
},
1443 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1444 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* XP sends a duplicate */
1447 /* SetMenu for Visible windows with no size change */
1448 static const struct message WmSetMenuVisibleNoSizeChangeSeq
[] = {
1449 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1450 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1451 { WM_NCPAINT
, sent
|optional
}, /* wparam != 1 */
1452 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1453 { WM_ERASEBKGND
, sent
|optional
},
1454 { WM_ACTIVATE
, sent
|optional
},
1455 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1456 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1459 /* DrawMenuBar for a visible window */
1460 static const struct message WmDrawMenuBarSeq
[] =
1462 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1463 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1464 { 0x0093, sent
|defwinproc
|optional
},
1465 { WM_NCPAINT
, sent
|optional
}, /* wparam != 1 */
1466 { 0x0093, sent
|defwinproc
|optional
},
1467 { 0x0093, sent
|defwinproc
|optional
},
1468 { 0x0091, sent
|defwinproc
|optional
},
1469 { 0x0092, sent
|defwinproc
|optional
},
1470 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1471 { WM_ERASEBKGND
, sent
|optional
},
1472 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1473 { 0x0093, sent
|optional
},
1474 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1478 static const struct message WmSetRedrawFalseSeq
[] =
1480 { WM_SETREDRAW
, sent
|wparam
, 0 },
1484 static const struct message WmSetRedrawTrueSeq
[] =
1486 { WM_SETREDRAW
, sent
|wparam
, 1 },
1490 static const struct message WmEnableWindowSeq_1
[] =
1492 { WM_CANCELMODE
, sent
|wparam
|lparam
, 0, 0 },
1493 { EVENT_OBJECT_STATECHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1494 { HCBT_SETFOCUS
, hook
|optional
},
1495 { WM_KILLFOCUS
, sent
|optional
},
1496 { WM_ENABLE
, sent
|wparam
|lparam
, FALSE
, 0 },
1500 static const struct message WmEnableWindowSeq_2
[] =
1502 { EVENT_OBJECT_STATECHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1503 { WM_ENABLE
, sent
|wparam
|lparam
, TRUE
, 0 },
1507 static const struct message WmGetScrollRangeSeq
[] =
1509 { SBM_GETRANGE
, sent
},
1512 static const struct message WmGetScrollInfoSeq
[] =
1514 { SBM_GETSCROLLINFO
, sent
},
1517 static const struct message WmSetScrollRangeSeq
[] =
1519 /* MSDN claims that Windows sends SBM_SETRANGE message, but win2k SP4
1520 sends SBM_SETSCROLLINFO.
1522 { SBM_SETSCROLLINFO
, sent
},
1525 /* SetScrollRange for a window without a non-client area */
1526 static const struct message WmSetScrollRangeHSeq_empty
[] =
1528 { EVENT_OBJECT_VALUECHANGE
, winevent_hook
|wparam
|lparam
, OBJID_HSCROLL
, 0 },
1531 static const struct message WmSetScrollRangeVSeq_empty
[] =
1533 { EVENT_OBJECT_VALUECHANGE
, winevent_hook
|wparam
|lparam
, OBJID_VSCROLL
, 0 },
1536 static const struct message WmSetScrollRangeHVSeq
[] =
1538 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOSIZE
},
1539 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1540 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1541 { WM_ERASEBKGND
, sent
|optional
},
1542 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1543 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1544 { EVENT_OBJECT_VALUECHANGE
, winevent_hook
|lparam
|optional
, 0/*OBJID_HSCROLL or OBJID_VSCROLL*/, 0 },
1547 /* SetScrollRange for a window with a non-client area */
1548 static const struct message WmSetScrollRangeHV_NC_Seq
[] =
1550 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOSIZE
},
1551 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1552 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
1553 { WM_NCPAINT
, sent
|optional
},
1554 { WM_STYLECHANGING
, sent
|defwinproc
|optional
},
1555 { WM_STYLECHANGED
, sent
|defwinproc
|optional
},
1556 { WM_STYLECHANGING
, sent
|defwinproc
|optional
},
1557 { WM_STYLECHANGED
, sent
|defwinproc
|optional
},
1558 { WM_STYLECHANGING
, sent
|defwinproc
|optional
},
1559 { WM_STYLECHANGED
, sent
|defwinproc
|optional
},
1560 { WM_STYLECHANGING
, sent
|defwinproc
|optional
},
1561 { WM_STYLECHANGED
, sent
|defwinproc
|optional
},
1562 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1563 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1564 { WM_ERASEBKGND
, sent
|optional
},
1565 { WM_CTLCOLORDLG
, sent
|defwinproc
|optional
}, /* sent to a parent of the dialog */
1566 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOCLIENTMOVE
, 0, SWP_NOCLIENTSIZE
},
1567 { WM_SIZE
, sent
|defwinproc
|optional
},
1568 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1569 { EVENT_OBJECT_VALUECHANGE
, winevent_hook
|lparam
|optional
, 0/*OBJID_HSCROLL or OBJID_VSCROLL*/, 0 },
1570 { WM_GETTEXT
, sent
|optional
},
1571 { WM_GETTEXT
, sent
|optional
},
1572 { WM_GETTEXT
, sent
|optional
},
1573 { WM_GETTEXT
, sent
|optional
},
1576 /* test if we receive the right sequence of messages */
1577 /* after calling ShowWindow( SW_SHOWNA) */
1578 static const struct message WmSHOWNAChildInvisParInvis
[] = {
1579 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1582 static const struct message WmSHOWNAChildVisParInvis
[] = {
1583 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1586 static const struct message WmSHOWNAChildVisParVis
[] = {
1587 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1588 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
1591 static const struct message WmSHOWNAChildInvisParVis
[] = {
1592 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1593 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1594 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1595 { WM_ERASEBKGND
, sent
|optional
},
1596 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOACTIVATE
|SWP_NOCLIENTMOVE
},
1599 static const struct message WmSHOWNATopVisible
[] = {
1600 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1601 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
1602 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
1603 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1604 { WM_ERASEBKGND
, sent
|optional
},
1605 { WM_WINDOWPOSCHANGED
, sent
|optional
},
1608 static const struct message WmSHOWNATopInvisible
[] = {
1609 { WM_NOTIFYFORMAT
, sent
|optional
},
1610 { WM_QUERYUISTATE
, sent
|optional
},
1611 { WM_WINDOWPOSCHANGING
, sent
|optional
},
1612 { WM_GETMINMAXINFO
, sent
|optional
},
1613 { WM_NCCALCSIZE
, sent
|optional
},
1614 { WM_WINDOWPOSCHANGED
, sent
|optional
},
1615 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1616 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1617 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1618 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
1619 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1620 { WM_ERASEBKGND
, sent
|optional
},
1621 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1622 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
1623 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
1624 { WM_ERASEBKGND
, sent
|optional
},
1625 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1626 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
1631 static const struct message WmTrackPopupMenu
[] = {
1632 { HCBT_CREATEWND
, hook
},
1633 { WM_ENTERMENULOOP
, sent
|wparam
|lparam
, TRUE
, 0 },
1634 { WM_INITMENU
, sent
|lparam
, 0, 0 },
1635 { WM_INITMENUPOPUP
, sent
|lparam
, 0, 0 },
1636 { 0x0093, sent
|optional
},
1637 { 0x0094, sent
|optional
},
1638 { 0x0094, sent
|optional
},
1639 { WM_ENTERIDLE
, sent
|wparam
, 2 },
1640 { WM_CAPTURECHANGED
, sent
},
1641 { HCBT_DESTROYWND
, hook
},
1642 { WM_UNINITMENUPOPUP
, sent
|lparam
, 0, 0 },
1643 { WM_MENUSELECT
, sent
|wparam
|lparam
, 0xffff0000, 0 },
1644 { WM_EXITMENULOOP
, sent
|wparam
|lparam
, 1, 0 },
1648 static const struct message WmTrackPopupMenuCapture
[] = {
1649 { HCBT_CREATEWND
, hook
},
1650 { WM_ENTERMENULOOP
, sent
|wparam
|lparam
, TRUE
, 0 },
1651 { WM_CAPTURECHANGED
, sent
},
1652 { WM_INITMENU
, sent
|lparam
, 0, 0 },
1653 { WM_INITMENUPOPUP
, sent
|lparam
, 0, 0 },
1654 { 0x0093, sent
|optional
},
1655 { 0x0094, sent
|optional
},
1656 { 0x0094, sent
|optional
},
1657 { WM_ENTERIDLE
, sent
|wparam
, 2 },
1658 { WM_CAPTURECHANGED
, sent
},
1659 { HCBT_DESTROYWND
, hook
},
1660 { WM_UNINITMENUPOPUP
, sent
|lparam
, 0, 0 },
1661 { WM_MENUSELECT
, sent
|wparam
|lparam
, 0xffff0000, 0 },
1662 { WM_EXITMENULOOP
, sent
|wparam
|lparam
, 1, 0 },
1666 static const struct message WmTrackPopupMenuEmpty
[] = {
1667 { HCBT_CREATEWND
, hook
},
1668 { WM_ENTERMENULOOP
, sent
|wparam
|lparam
, TRUE
, 0 },
1669 { WM_INITMENU
, sent
|lparam
, 0, 0 },
1670 { WM_INITMENUPOPUP
, sent
|lparam
, 0, 0 },
1671 { 0x0093, sent
|optional
},
1672 { 0x0094, sent
|optional
},
1673 { 0x0094, sent
|optional
},
1674 { WM_CAPTURECHANGED
, sent
},
1675 { WM_EXITMENULOOP
, sent
|wparam
|lparam
, 1, 0 },
1676 { HCBT_DESTROYWND
, hook
},
1677 { WM_UNINITMENUPOPUP
, sent
|lparam
, 0, 0 },
1681 static const struct message WmTrackPopupMenuAbort
[] = {
1682 { HCBT_CREATEWND
, hook
},
1683 { WM_ENTERMENULOOP
, sent
|wparam
|lparam
, TRUE
, 0 },
1684 { WM_INITMENU
, sent
|lparam
, 0, 0 },
1685 { WM_INITMENUPOPUP
, sent
|lparam
, 0, 0 },
1686 { 0x0093, sent
|optional
},
1687 { 0x0094, sent
|optional
},
1688 { 0x0094, sent
|optional
},
1689 { WM_CAPTURECHANGED
, sent
},
1690 { HCBT_DESTROYWND
, hook
},
1691 { WM_UNINITMENUPOPUP
, sent
|lparam
, 0, 0 },
1692 { WM_MENUSELECT
, sent
|wparam
|lparam
, 0xffff0000, 0 },
1693 { WM_EXITMENULOOP
, sent
|wparam
|lparam
, 1, 0 },
1697 static BOOL after_end_dialog
, test_def_id
, paint_loop_done
;
1698 static int sequence_cnt
, sequence_size
;
1699 static struct recvd_message
* sequence
;
1700 static int log_all_parent_messages
;
1701 static CRITICAL_SECTION sequence_cs
;
1703 /* user32 functions */
1704 static HWND (WINAPI
*pGetAncestor
)(HWND
,UINT
);
1705 static BOOL (WINAPI
*pGetMenuInfo
)(HMENU
,LPCMENUINFO
);
1706 static void (WINAPI
*pNotifyWinEvent
)(DWORD
, HWND
, LONG
, LONG
);
1707 static BOOL (WINAPI
*pSetMenuInfo
)(HMENU
,LPCMENUINFO
);
1708 static HWINEVENTHOOK (WINAPI
*pSetWinEventHook
)(DWORD
, DWORD
, HMODULE
, WINEVENTPROC
, DWORD
, DWORD
, DWORD
);
1709 static BOOL (WINAPI
*pTrackMouseEvent
)(TRACKMOUSEEVENT
*);
1710 static BOOL (WINAPI
*pUnhookWinEvent
)(HWINEVENTHOOK
);
1711 static BOOL (WINAPI
*pGetMonitorInfoA
)(HMONITOR
,LPMONITORINFO
);
1712 static HMONITOR (WINAPI
*pMonitorFromPoint
)(POINT
,DWORD
);
1713 static BOOL (WINAPI
*pUpdateLayeredWindow
)(HWND
,HDC
,POINT
*,SIZE
*,HDC
,POINT
*,COLORREF
,BLENDFUNCTION
*,DWORD
);
1714 static UINT_PTR (WINAPI
*pSetSystemTimer
)(HWND
, UINT_PTR
, UINT
, TIMERPROC
);
1715 static UINT_PTR (WINAPI
*pKillSystemTimer
)(HWND
, UINT_PTR
);
1716 /* kernel32 functions */
1717 static BOOL (WINAPI
*pGetCPInfoExA
)(UINT
, DWORD
, LPCPINFOEXA
);
1719 static void init_procs(void)
1721 HMODULE user32
= GetModuleHandleA("user32.dll");
1722 HMODULE kernel32
= GetModuleHandleA("kernel32.dll");
1724 #define GET_PROC(dll, func) \
1725 p ## func = (void*)GetProcAddress(dll, #func); \
1727 trace("GetProcAddress(%s) failed\n", #func); \
1730 GET_PROC(user32
, GetAncestor
)
1731 GET_PROC(user32
, GetMenuInfo
)
1732 GET_PROC(user32
, NotifyWinEvent
)
1733 GET_PROC(user32
, SetMenuInfo
)
1734 GET_PROC(user32
, SetWinEventHook
)
1735 GET_PROC(user32
, TrackMouseEvent
)
1736 GET_PROC(user32
, UnhookWinEvent
)
1737 GET_PROC(user32
, GetMonitorInfoA
)
1738 GET_PROC(user32
, MonitorFromPoint
)
1739 GET_PROC(user32
, UpdateLayeredWindow
)
1740 GET_PROC(user32
, SetSystemTimer
)
1741 GET_PROC(user32
, KillSystemTimer
)
1743 GET_PROC(kernel32
, GetCPInfoExA
)
1748 static const char *get_winpos_flags(UINT flags
)
1750 static char buffer
[300];
1753 #define DUMP(flag) do { if (flags & flag) { strcat( buffer, "|" #flag ); flags &= ~flag; } } while(0)
1754 DUMP( SWP_SHOWWINDOW
);
1755 DUMP( SWP_HIDEWINDOW
);
1756 DUMP( SWP_NOACTIVATE
);
1757 DUMP( SWP_FRAMECHANGED
);
1758 DUMP( SWP_NOCOPYBITS
);
1759 DUMP( SWP_NOOWNERZORDER
);
1760 DUMP( SWP_NOSENDCHANGING
);
1761 DUMP( SWP_DEFERERASE
);
1762 DUMP( SWP_ASYNCWINDOWPOS
);
1763 DUMP( SWP_NOZORDER
);
1764 DUMP( SWP_NOREDRAW
);
1767 DUMP( SWP_NOCLIENTSIZE
);
1768 DUMP( SWP_NOCLIENTMOVE
);
1769 if (flags
) sprintf(buffer
+ strlen(buffer
),"|0x%04x", flags
);
1774 static BOOL
ignore_message( UINT message
)
1776 /* these are always ignored */
1777 return (message
>= 0xc000 ||
1778 message
== WM_GETICON
||
1779 message
== WM_GETOBJECT
||
1780 message
== WM_TIMECHANGE
||
1781 message
== WM_DISPLAYCHANGE
||
1782 message
== WM_DEVICECHANGE
||
1783 message
== WM_DWMNCRENDERINGCHANGED
);
1787 #define add_message(msg) add_message_(__LINE__,msg);
1788 static void add_message_(int line
, const struct recvd_message
*msg
)
1790 struct recvd_message
*seq
;
1792 EnterCriticalSection( &sequence_cs
);
1796 sequence
= HeapAlloc( GetProcessHeap(), 0, sequence_size
* sizeof(*sequence
) );
1798 if (sequence_cnt
== sequence_size
)
1801 sequence
= HeapReAlloc( GetProcessHeap(), 0, sequence
, sequence_size
* sizeof(*sequence
) );
1805 seq
= &sequence
[sequence_cnt
++];
1806 seq
->hwnd
= msg
->hwnd
;
1807 seq
->message
= msg
->message
;
1808 seq
->flags
= msg
->flags
;
1809 seq
->wParam
= msg
->wParam
;
1810 seq
->lParam
= msg
->lParam
;
1812 seq
->descr
= msg
->descr
;
1814 LeaveCriticalSection( &sequence_cs
);
1818 if (msg
->flags
& hook
)
1820 static const char * const CBT_code_name
[10] =
1828 "HCBT_CLICKSKIPPED",
1833 const char *code_name
= (msg
->message
<= HCBT_SETFOCUS
) ? CBT_code_name
[msg
->message
] : "Unknown";
1835 sprintf( seq
->output
, "%s: hook %d (%s) wp %08lx lp %08lx",
1836 msg
->descr
, msg
->message
, code_name
, msg
->wParam
, msg
->lParam
);
1838 else if (msg
->flags
& winevent_hook
)
1840 sprintf( seq
->output
, "%s: winevent %p %08x %08lx %08lx",
1841 msg
->descr
, msg
->hwnd
, msg
->message
, msg
->wParam
, msg
->lParam
);
1845 switch (msg
->message
)
1847 case WM_WINDOWPOSCHANGING
:
1848 case WM_WINDOWPOSCHANGED
:
1850 WINDOWPOS
*winpos
= (WINDOWPOS
*)msg
->lParam
;
1852 sprintf( seq
->output
, "%s: %p WM_WINDOWPOS%s wp %08lx lp %08lx after %p x %d y %d cx %d cy %d flags %s",
1853 msg
->descr
, msg
->hwnd
,
1854 (msg
->message
== WM_WINDOWPOSCHANGING
) ? "CHANGING" : "CHANGED",
1855 msg
->wParam
, msg
->lParam
, winpos
->hwndInsertAfter
,
1856 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
,
1857 get_winpos_flags(winpos
->flags
) );
1859 /* Log only documented flags, win2k uses 0x1000 and 0x2000
1860 * in the high word for internal purposes
1862 seq
->wParam
= winpos
->flags
& 0xffff;
1863 /* We are not interested in the flags that don't match under XP and Win9x */
1864 seq
->wParam
&= ~SWP_NOZORDER
;
1870 DRAW_ITEM_STRUCT di
;
1871 DRAWITEMSTRUCT
*dis
= (DRAWITEMSTRUCT
*)msg
->lParam
;
1873 sprintf( seq
->output
, "%s: %p WM_DRAWITEM: type %x, ctl_id %x, item_id %x, action %x, state %x",
1874 msg
->descr
, msg
->hwnd
, dis
->CtlType
, dis
->CtlID
,
1875 dis
->itemID
, dis
->itemAction
, dis
->itemState
);
1878 di
.u
.item
.type
= dis
->CtlType
;
1879 di
.u
.item
.ctl_id
= dis
->CtlID
;
1880 if (dis
->CtlType
== ODT_LISTBOX
||
1881 dis
->CtlType
== ODT_COMBOBOX
||
1882 dis
->CtlType
== ODT_MENU
)
1883 di
.u
.item
.item_id
= dis
->itemID
;
1884 di
.u
.item
.action
= dis
->itemAction
;
1885 di
.u
.item
.state
= dis
->itemState
;
1887 seq
->lParam
= di
.u
.lp
;
1891 if (msg
->message
>= 0xc000) return; /* ignore registered messages */
1892 sprintf( seq
->output
, "%s: %p %04x wp %08lx lp %08lx",
1893 msg
->descr
, msg
->hwnd
, msg
->message
, msg
->wParam
, msg
->lParam
);
1895 if (msg
->flags
& (sent
|posted
|parent
|defwinproc
|beginpaint
))
1896 sprintf( seq
->output
+ strlen(seq
->output
), " (flags %x)", msg
->flags
);
1901 /* try to make sure pending X events have been processed before continuing */
1902 static void flush_events(void)
1906 int min_timeout
= 100;
1907 DWORD time
= GetTickCount() + diff
;
1911 if (MsgWaitForMultipleObjects( 0, NULL
, FALSE
, min_timeout
, QS_ALLINPUT
) == WAIT_TIMEOUT
) break;
1912 while (PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA( &msg
);
1913 diff
= time
- GetTickCount();
1917 static void flush_sequence(void)
1919 EnterCriticalSection( &sequence_cs
);
1920 HeapFree(GetProcessHeap(), 0, sequence
);
1922 sequence_cnt
= sequence_size
= 0;
1923 LeaveCriticalSection( &sequence_cs
);
1926 static void dump_sequence(const struct message
*expected
, const char *context
, const char *file
, int line
)
1928 const struct recvd_message
*actual
= sequence
;
1929 unsigned int count
= 0;
1931 trace_(file
, line
)("Failed sequence %s:\n", context
);
1932 while (expected
->message
&& actual
->message
)
1934 if (actual
->output
[0])
1936 if (expected
->flags
& hook
)
1938 trace_(file
, line
)( " %u: expected: hook %04x - actual: %s\n",
1939 count
, expected
->message
, actual
->output
);
1941 else if (expected
->flags
& winevent_hook
)
1943 trace_(file
, line
)( " %u: expected: winevent %04x - actual: %s\n",
1944 count
, expected
->message
, actual
->output
);
1946 else if (expected
->flags
& kbd_hook
)
1948 trace_(file
, line
)( " %u: expected: kbd %04x - actual: %s\n",
1949 count
, expected
->message
, actual
->output
);
1953 trace_(file
, line
)( " %u: expected: msg %04x - actual: %s\n",
1954 count
, expected
->message
, actual
->output
);
1958 if (expected
->message
== actual
->message
)
1960 if ((expected
->flags
& defwinproc
) != (actual
->flags
& defwinproc
) &&
1961 (expected
->flags
& optional
))
1963 /* don't match messages if their defwinproc status differs */
1972 /* silently drop winevent messages if there is no support for them */
1973 else if ((expected
->flags
& optional
) || ((expected
->flags
& winevent_hook
) && !hEvent_hook
))
1983 /* optional trailing messages */
1984 while (expected
->message
&& ((expected
->flags
& optional
) ||
1985 ((expected
->flags
& winevent_hook
) && !hEvent_hook
)))
1987 trace_(file
, line
)( " %u: expected: msg %04x - actual: nothing\n", count
, expected
->message
);
1992 if (expected
->message
)
1994 trace_(file
, line
)( " %u: expected: msg %04x - actual: nothing\n", count
, expected
->message
);
1998 while (actual
->message
&& actual
->output
[0])
2000 trace_(file
, line
)( " %u: expected: nothing - actual: %s\n", count
, actual
->output
);
2006 #define ok_sequence( exp, contx, todo) \
2007 ok_sequence_( (exp), (contx), (todo), __FILE__, __LINE__)
2010 static void ok_sequence_(const struct message
*expected_list
, const char *context
, BOOL todo
,
2011 const char *file
, int line
)
2013 static const struct recvd_message end_of_sequence
;
2014 const struct message
*expected
= expected_list
;
2015 const struct recvd_message
*actual
;
2016 int failcount
= 0, dump
= 0;
2017 unsigned int count
= 0;
2019 add_message(&end_of_sequence
);
2023 while (expected
->message
&& actual
->message
)
2025 if (expected
->message
== actual
->message
&&
2026 !((expected
->flags
^ actual
->flags
) & (hook
|winevent_hook
|kbd_hook
)))
2028 if (expected
->flags
& wparam
)
2030 if (((expected
->wParam
^ actual
->wParam
) & ~expected
->wp_mask
) && todo
)
2034 if (strcmp(winetest_platform
, "wine")) dump
++;
2035 ok_( file
, line
) (FALSE
,
2036 "%s: %u: in msg 0x%04x expecting wParam 0x%lx got 0x%lx\n",
2037 context
, count
, expected
->message
, expected
->wParam
, actual
->wParam
);
2042 ok_( file
, line
)( ((expected
->wParam
^ actual
->wParam
) & ~expected
->wp_mask
) == 0,
2043 "%s: %u: in msg 0x%04x expecting wParam 0x%lx got 0x%lx\n",
2044 context
, count
, expected
->message
, expected
->wParam
, actual
->wParam
);
2045 if ((expected
->wParam
^ actual
->wParam
) & ~expected
->wp_mask
) dump
++;
2049 if (expected
->flags
& lparam
)
2051 if (((expected
->lParam
^ actual
->lParam
) & ~expected
->lp_mask
) && todo
)
2055 if (strcmp(winetest_platform
, "wine")) dump
++;
2056 ok_( file
, line
) (FALSE
,
2057 "%s: %u: in msg 0x%04x expecting lParam 0x%lx got 0x%lx\n",
2058 context
, count
, expected
->message
, expected
->lParam
, actual
->lParam
);
2063 ok_( file
, line
)(((expected
->lParam
^ actual
->lParam
) & ~expected
->lp_mask
) == 0,
2064 "%s: %u: in msg 0x%04x expecting lParam 0x%lx got 0x%lx\n",
2065 context
, count
, expected
->message
, expected
->lParam
, actual
->lParam
);
2066 if ((expected
->lParam
^ actual
->lParam
) & ~expected
->lp_mask
) dump
++;
2069 if ((expected
->flags
& optional
) &&
2070 ((expected
->flags
^ actual
->flags
) & (defwinproc
|parent
)))
2072 /* don't match optional messages if their defwinproc or parent status differs */
2077 if ((expected
->flags
& defwinproc
) != (actual
->flags
& defwinproc
) && todo
)
2081 if (strcmp(winetest_platform
, "wine")) dump
++;
2082 ok_( file
, line
) (FALSE
,
2083 "%s: %u: the msg 0x%04x should %shave been sent by DefWindowProc\n",
2084 context
, count
, expected
->message
, (expected
->flags
& defwinproc
) ? "" : "NOT ");
2089 ok_( file
, line
) ((expected
->flags
& defwinproc
) == (actual
->flags
& defwinproc
),
2090 "%s: %u: the msg 0x%04x should %shave been sent by DefWindowProc\n",
2091 context
, count
, expected
->message
, (expected
->flags
& defwinproc
) ? "" : "NOT ");
2092 if ((expected
->flags
& defwinproc
) != (actual
->flags
& defwinproc
)) dump
++;
2095 ok_( file
, line
) ((expected
->flags
& beginpaint
) == (actual
->flags
& beginpaint
),
2096 "%s: %u: the msg 0x%04x should %shave been sent by BeginPaint\n",
2097 context
, count
, expected
->message
, (expected
->flags
& beginpaint
) ? "" : "NOT ");
2098 if ((expected
->flags
& beginpaint
) != (actual
->flags
& beginpaint
)) dump
++;
2100 ok_( file
, line
) ((expected
->flags
& (sent
|posted
)) == (actual
->flags
& (sent
|posted
)),
2101 "%s: %u: the msg 0x%04x should have been %s\n",
2102 context
, count
, expected
->message
, (expected
->flags
& posted
) ? "posted" : "sent");
2103 if ((expected
->flags
& (sent
|posted
)) != (actual
->flags
& (sent
|posted
))) dump
++;
2105 ok_( file
, line
) ((expected
->flags
& parent
) == (actual
->flags
& parent
),
2106 "%s: %u: the msg 0x%04x was expected in %s\n",
2107 context
, count
, expected
->message
, (expected
->flags
& parent
) ? "parent" : "child");
2108 if ((expected
->flags
& parent
) != (actual
->flags
& parent
)) dump
++;
2110 ok_( file
, line
) ((expected
->flags
& hook
) == (actual
->flags
& hook
),
2111 "%s: %u: the msg 0x%04x should have been sent by a hook\n",
2112 context
, count
, expected
->message
);
2113 if ((expected
->flags
& hook
) != (actual
->flags
& hook
)) dump
++;
2115 ok_( file
, line
) ((expected
->flags
& winevent_hook
) == (actual
->flags
& winevent_hook
),
2116 "%s: %u: the msg 0x%04x should have been sent by a winevent hook\n",
2117 context
, count
, expected
->message
);
2118 if ((expected
->flags
& winevent_hook
) != (actual
->flags
& winevent_hook
)) dump
++;
2120 ok_( file
, line
) ((expected
->flags
& kbd_hook
) == (actual
->flags
& kbd_hook
),
2121 "%s: %u: the msg 0x%04x should have been sent by a keyboard hook\n",
2122 context
, count
, expected
->message
);
2123 if ((expected
->flags
& kbd_hook
) != (actual
->flags
& kbd_hook
)) dump
++;
2128 /* silently drop hook messages if there is no support for them */
2129 else if ((expected
->flags
& optional
) ||
2130 ((expected
->flags
& hook
) && !hCBT_hook
) ||
2131 ((expected
->flags
& winevent_hook
) && !hEvent_hook
) ||
2132 ((expected
->flags
& kbd_hook
) && !hKBD_hook
))
2138 if (strcmp(winetest_platform
, "wine")) dump
++;
2139 ok_( file
, line
) (FALSE
, "%s: %u: the msg 0x%04x was expected, but got msg 0x%04x instead\n",
2140 context
, count
, expected
->message
, actual
->message
);
2146 ok_( file
, line
) (FALSE
, "%s: %u: the msg 0x%04x was expected, but got msg 0x%04x instead\n",
2147 context
, count
, expected
->message
, actual
->message
);
2155 /* skip all optional trailing messages */
2156 while (expected
->message
&& ((expected
->flags
& optional
) ||
2157 ((expected
->flags
& hook
) && !hCBT_hook
) ||
2158 ((expected
->flags
& winevent_hook
) && !hEvent_hook
)))
2164 if (expected
->message
|| actual
->message
) {
2166 if (strcmp(winetest_platform
, "wine")) dump
++;
2167 ok_( file
, line
) (FALSE
, "%s: %u: the msg sequence is not complete: expected %04x - actual %04x\n",
2168 context
, count
, expected
->message
, actual
->message
);
2174 if (expected
->message
|| actual
->message
)
2177 ok_( file
, line
) (FALSE
, "%s: %u: the msg sequence is not complete: expected %04x - actual %04x\n",
2178 context
, count
, expected
->message
, actual
->message
);
2181 if( todo
&& !failcount
) /* succeeded yet marked todo */
2183 if (!strcmp(winetest_platform
, "wine")) dump
++;
2184 ok_( file
, line
)( TRUE
, "%s: marked \"todo_wine\" but succeeds\n", context
);
2188 if (dump
) dump_sequence(expected_list
, context
, file
, line
);
2192 #define expect(EXPECTED,GOT) ok((GOT)==(EXPECTED), "Expected %d, got %d\n", (EXPECTED), (GOT))
2194 /******************************** MDI test **********************************/
2196 /* CreateWindow for MDI frame window, initially visible */
2197 static const struct message WmCreateMDIframeSeq
[] = {
2198 { HCBT_CREATEWND
, hook
},
2199 { WM_GETMINMAXINFO
, sent
},
2200 { WM_NCCREATE
, sent
},
2201 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
2202 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
2203 { WM_CREATE
, sent
},
2204 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2205 { WM_NOTIFYFORMAT
, sent
|optional
},
2206 { WM_QUERYUISTATE
, sent
|optional
},
2207 { WM_WINDOWPOSCHANGING
, sent
|optional
},
2208 { WM_GETMINMAXINFO
, sent
|optional
},
2209 { WM_NCCALCSIZE
, sent
|optional
},
2210 { WM_WINDOWPOSCHANGED
, sent
|optional
},
2211 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
2212 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
2213 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2214 { HCBT_ACTIVATE
, hook
},
2215 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
2216 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
2217 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* XP */
2218 { WM_ACTIVATEAPP
, sent
|wparam
|optional
, 1 }, /* Win9x doesn't send it */
2219 { WM_NCACTIVATE
, sent
},
2220 { WM_GETTEXT
, sent
|defwinproc
|optional
},
2221 { WM_ACTIVATE
, sent
|wparam
, 1 },
2222 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* Win9x */
2223 { HCBT_SETFOCUS
, hook
},
2224 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
2225 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
2226 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2227 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
2228 /* Win9x adds SWP_NOZORDER below */
2229 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2230 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 }, /* XP */
2231 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2232 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2236 /* DestroyWindow for MDI frame window, initially visible */
2237 static const struct message WmDestroyMDIframeSeq
[] = {
2238 { HCBT_DESTROYWND
, hook
},
2239 { 0x0090, sent
|optional
},
2240 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2241 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2242 { WM_NCACTIVATE
, sent
|wparam
|optional
, 0 }, /* Win9x */
2243 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2244 { WM_NCACTIVATE
, sent
|wparam
|optional
, 0 }, /* XP */
2245 { WM_ACTIVATE
, sent
|wparam
|optional
, 0 }, /* Win9x */
2246 { WM_ACTIVATEAPP
, sent
|wparam
|optional
, 0 }, /* Win9x */
2247 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
2248 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
2249 { WM_DESTROY
, sent
},
2250 { WM_NCDESTROY
, sent
},
2253 /* CreateWindow for MDI client window, initially visible */
2254 static const struct message WmCreateMDIclientSeq
[] = {
2255 { HCBT_CREATEWND
, hook
},
2256 { WM_NCCREATE
, sent
},
2257 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
2258 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 },
2259 { WM_CREATE
, sent
},
2260 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 },
2261 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2262 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2264 { WM_PARENTNOTIFY
, sent
|wparam
, WM_CREATE
}, /* in MDI frame */
2265 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
2266 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2267 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2268 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2271 /* ShowWindow(SW_SHOW) for MDI client window */
2272 static const struct message WmShowMDIclientSeq
[] = {
2273 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
2274 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2275 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2276 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2279 /* ShowWindow(SW_HIDE) for MDI client window */
2280 static const struct message WmHideMDIclientSeq
[] = {
2281 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
2282 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2283 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* win2000 */
2284 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* XP */
2285 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2288 /* DestroyWindow for MDI client window, initially visible */
2289 static const struct message WmDestroyMDIclientSeq
[] = {
2290 { HCBT_DESTROYWND
, hook
},
2291 { 0x0090, sent
|optional
},
2292 { WM_PARENTNOTIFY
, sent
|wparam
, WM_DESTROY
}, /* in MDI frame */
2293 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
2294 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2295 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2296 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2297 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
2298 { WM_DESTROY
, sent
},
2299 { WM_NCDESTROY
, sent
},
2302 /* CreateWindow for MDI child window, initially visible */
2303 static const struct message WmCreateMDIchildVisibleSeq
[] = {
2304 { HCBT_CREATEWND
, hook
},
2305 { WM_NCCREATE
, sent
},
2306 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
2307 { WM_CREATE
, sent
},
2308 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2309 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2311 /* Win2k sends wparam set to
2312 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2313 * while Win9x doesn't bother to set child window id according to
2314 * CLIENTCREATESTRUCT.idFirstChild
2316 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
2317 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
2318 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2319 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2320 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2321 { WM_MDIREFRESHMENU
, sent
/*|wparam|lparam, 0, 0*/ },
2322 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
2323 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2324 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2326 /* Win9x: message sequence terminates here. */
2328 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 },
2329 { HCBT_SETFOCUS
, hook
}, /* in MDI client */
2330 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2331 { WM_IME_NOTIFY
, sent
|wparam
|optional
, 2 }, /* in MDI client */
2332 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2333 { WM_SETFOCUS
, sent
}, /* in MDI client */
2334 { HCBT_SETFOCUS
, hook
},
2335 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2336 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2337 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
2338 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2339 { WM_SETFOCUS
, sent
|defwinproc
},
2340 { WM_MDIACTIVATE
, sent
|defwinproc
},
2343 /* CreateWindow for MDI child window with invisible parent */
2344 static const struct message WmCreateMDIchildInvisibleParentSeq
[] = {
2345 { HCBT_CREATEWND
, hook
},
2346 { WM_GETMINMAXINFO
, sent
},
2347 { WM_NCCREATE
, sent
},
2348 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
2349 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 },
2350 { WM_CREATE
, sent
},
2351 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2352 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2354 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
2355 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
2356 { WM_MDIREFRESHMENU
, sent
}, /* in MDI client */
2357 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
2358 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2359 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2361 /* Win9x: message sequence terminates here. */
2363 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 },
2364 { HCBT_SETFOCUS
, hook
}, /* in MDI client */
2365 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2366 { WM_IME_NOTIFY
, sent
|wparam
|optional
, 2 }, /* in MDI client */
2367 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2368 { WM_SETFOCUS
, sent
}, /* in MDI client */
2369 { HCBT_SETFOCUS
, hook
},
2370 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2371 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2372 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
2373 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2374 { WM_SETFOCUS
, sent
|defwinproc
},
2375 { WM_MDIACTIVATE
, sent
|defwinproc
},
2378 /* DestroyWindow for MDI child window, initially visible */
2379 static const struct message WmDestroyMDIchildVisibleSeq
[] = {
2380 { HCBT_DESTROYWND
, hook
},
2381 /* Win2k sends wparam set to
2382 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
2383 * while Win9x doesn't bother to set child window id according to
2384 * CLIENTCREATESTRUCT.idFirstChild
2386 { 0x0090, sent
|optional
},
2387 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_DESTROY*/ }, /* in MDI client */
2388 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
2389 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2390 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2391 { WM_ERASEBKGND
, sent
|parent
|optional
},
2392 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2394 /* { WM_DESTROY, sent }
2395 * Win9x: message sequence terminates here.
2398 { HCBT_SETFOCUS
, hook
}, /* set focus to MDI client */
2399 { WM_KILLFOCUS
, sent
},
2400 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
2401 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2402 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2403 { WM_SETFOCUS
, sent
}, /* in MDI client */
2405 { HCBT_SETFOCUS
, hook
}, /* MDI client sets focus back to MDI child */
2406 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2407 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2408 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
2409 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2410 { WM_SETFOCUS
, sent
}, /* in MDI client */
2412 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
2414 { HCBT_SETFOCUS
, hook
}, /* set focus to MDI client */
2415 { WM_KILLFOCUS
, sent
},
2416 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
2417 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2418 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2419 { WM_SETFOCUS
, sent
}, /* in MDI client */
2421 { HCBT_SETFOCUS
, hook
}, /* MDI client sets focus back to MDI child */
2422 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2423 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2424 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
2425 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2426 { WM_SETFOCUS
, sent
}, /* in MDI client */
2428 { WM_DESTROY
, sent
},
2430 { HCBT_SETFOCUS
, hook
}, /* set focus to MDI client */
2431 { WM_KILLFOCUS
, sent
},
2432 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
2433 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2434 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2435 { WM_SETFOCUS
, sent
}, /* in MDI client */
2437 { HCBT_SETFOCUS
, hook
}, /* MDI client sets focus back to MDI child */
2438 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2439 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2440 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
2441 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2442 { WM_SETFOCUS
, sent
}, /* in MDI client */
2444 { WM_NCDESTROY
, sent
},
2447 /* CreateWindow for MDI child window, initially invisible */
2448 static const struct message WmCreateMDIchildInvisibleSeq
[] = {
2449 { HCBT_CREATEWND
, hook
},
2450 { WM_NCCREATE
, sent
},
2451 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
2452 { WM_CREATE
, sent
},
2453 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2454 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2456 /* Win2k sends wparam set to
2457 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2458 * while Win9x doesn't bother to set child window id according to
2459 * CLIENTCREATESTRUCT.idFirstChild
2461 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
2464 /* DestroyWindow for MDI child window, initially invisible */
2465 static const struct message WmDestroyMDIchildInvisibleSeq
[] = {
2466 { HCBT_DESTROYWND
, hook
},
2467 /* Win2k sends wparam set to
2468 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
2469 * while Win9x doesn't bother to set child window id according to
2470 * CLIENTCREATESTRUCT.idFirstChild
2472 { 0x0090, sent
|optional
},
2473 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_DESTROY*/ }, /* in MDI client */
2474 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
2475 { WM_DESTROY
, sent
},
2476 { WM_NCDESTROY
, sent
},
2477 /* FIXME: Wine destroys an icon/title window while Windows doesn't */
2478 { WM_PARENTNOTIFY
, sent
|wparam
|optional
, WM_DESTROY
}, /* MDI client */
2481 /* CreateWindow for the 1st MDI child window, initially visible and maximized */
2482 static const struct message WmCreateMDIchildVisibleMaxSeq1
[] = {
2483 { HCBT_CREATEWND
, hook
},
2484 { WM_NCCREATE
, sent
},
2485 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
2486 { WM_CREATE
, sent
},
2487 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2488 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2490 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
2491 { WM_GETMINMAXINFO
, sent
},
2492 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_STATECHANGED
},
2493 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2494 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
2495 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2497 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2498 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2499 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2500 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2501 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2502 /* Win2k sends wparam set to
2503 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2504 * while Win9x doesn't bother to set child window id according to
2505 * CLIENTCREATESTRUCT.idFirstChild
2507 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
2508 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
2509 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2510 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2511 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2512 { WM_MDIREFRESHMENU
, sent
/*|wparam|lparam, 0, 0*/ },
2513 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
2514 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2515 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
|optional
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
, 0, SWP_FRAMECHANGED
},
2517 /* Win9x: message sequence terminates here. */
2519 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
|optional
, 1 },
2520 { HCBT_SETFOCUS
, hook
|optional
}, /* in MDI client */
2521 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2522 { WM_IME_NOTIFY
, sent
|wparam
|optional
, 2 }, /* in MDI client */
2523 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2524 { WM_SETFOCUS
, sent
|optional
}, /* in MDI client */
2525 { HCBT_SETFOCUS
, hook
|optional
},
2526 { WM_KILLFOCUS
, sent
|optional
}, /* in MDI client */
2527 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2528 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
2529 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2530 { WM_SETFOCUS
, sent
|defwinproc
|optional
},
2531 { WM_MDIACTIVATE
, sent
|defwinproc
|optional
},
2533 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2534 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2535 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2536 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2539 /* CreateWindow for the 2nd MDI child window, initially visible and maximized */
2540 static const struct message WmCreateMDIchildVisibleMaxSeq2
[] = {
2541 /* restore the 1st MDI child */
2542 { WM_SETREDRAW
, sent
|wparam
, 0 },
2543 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWNORMAL
},
2544 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
2545 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2546 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2547 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
2548 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2550 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2551 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2552 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2553 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2554 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2555 { WM_SETREDRAW
, sent
|wparam
, 1 }, /* in the 1st MDI child */
2556 /* create the 2nd MDI child */
2557 { HCBT_CREATEWND
, hook
},
2558 { WM_NCCREATE
, sent
},
2559 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
2560 { WM_CREATE
, sent
},
2561 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2562 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2564 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
2565 { WM_GETMINMAXINFO
, sent
},
2566 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_STATECHANGED
},
2567 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2568 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2569 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
2570 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2572 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2573 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2574 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2575 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2576 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2577 /* Win2k sends wparam set to
2578 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2579 * while Win9x doesn't bother to set child window id according to
2580 * CLIENTCREATESTRUCT.idFirstChild
2582 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
2583 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
2584 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2585 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2586 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2587 { WM_MDIREFRESHMENU
, sent
/*|wparam|lparam, 0, 0*/ },
2588 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
2589 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2591 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 0 }, /* in the 1st MDI child */
2592 { WM_MDIACTIVATE
, sent
|defwinproc
}, /* in the 1st MDI child */
2594 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2596 /* Win9x: message sequence terminates here. */
2598 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 },
2599 { HCBT_SETFOCUS
, hook
},
2600 { WM_KILLFOCUS
, sent
|defwinproc
|optional
}, /* in the 1st MDI child */
2601 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 0 }, /* in the 1st MDI child */
2602 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2603 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2604 { WM_SETFOCUS
, sent
}, /* in MDI client */
2605 { HCBT_SETFOCUS
, hook
},
2606 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2607 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2608 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
2609 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2610 { WM_SETFOCUS
, sent
|defwinproc
},
2612 { WM_MDIACTIVATE
, sent
|defwinproc
},
2614 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2615 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2616 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2617 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2620 /* WM_MDICREATE MDI child window, initially visible and maximized */
2621 static const struct message WmCreateMDIchildVisibleMaxSeq3
[] = {
2622 { WM_MDICREATE
, sent
},
2623 { HCBT_CREATEWND
, hook
},
2624 { WM_NCCREATE
, sent
},
2625 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
2626 { WM_CREATE
, sent
},
2627 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2628 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2630 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
2631 { WM_GETMINMAXINFO
, sent
},
2632 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_STATECHANGED
},
2633 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2634 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
2635 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2638 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2639 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2640 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2641 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2642 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2644 /* Win2k sends wparam set to
2645 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2646 * while Win9x doesn't bother to set child window id according to
2647 * CLIENTCREATESTRUCT.idFirstChild
2649 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
2650 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
2651 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2653 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2655 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2656 { WM_MDIREFRESHMENU
, sent
/*|wparam|lparam, 0, 0*/ },
2657 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
2659 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2660 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2662 /* Win9x: message sequence terminates here. */
2664 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 },
2665 { WM_SETFOCUS
, sent
|optional
}, /* in MDI client */
2666 { HCBT_SETFOCUS
, hook
}, /* in MDI client */
2667 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2668 { WM_IME_NOTIFY
, sent
|wparam
|optional
, 2 },
2669 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
|optional
, OBJID_CLIENT
, 0 },
2670 { WM_SETFOCUS
, sent
|optional
}, /* in MDI client */
2671 { HCBT_SETFOCUS
, hook
|optional
},
2672 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2673 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2674 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
2675 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2676 { WM_SETFOCUS
, sent
|defwinproc
},
2678 { WM_MDIACTIVATE
, sent
|defwinproc
},
2681 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2682 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2683 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2684 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2687 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2688 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2689 { 0x0093, sent
|defwinproc
|optional
},
2690 { 0x0093, sent
|defwinproc
|optional
},
2691 { 0x0093, sent
|defwinproc
|optional
},
2692 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2693 { WM_MOVE
, sent
|defwinproc
},
2694 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2697 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
2698 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2699 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
},
2700 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2703 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
2704 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2705 { 0x0093, sent
|optional
},
2706 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
},
2707 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2709 { 0x0093, sent
|optional
},
2710 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2711 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI client */
2712 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 }, /* XP sends it to MDI frame */
2713 { 0x0093, sent
|defwinproc
|optional
},
2714 { 0x0093, sent
|defwinproc
|optional
},
2715 { 0x0093, sent
|defwinproc
|optional
},
2716 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2717 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* XP sends a duplicate */
2721 /* CreateWindow for the 1st MDI child window, initially invisible and maximized */
2722 static const struct message WmCreateMDIchildInvisibleMaxSeq4
[] = {
2723 { HCBT_CREATEWND
, hook
},
2724 { WM_GETMINMAXINFO
, sent
},
2725 { WM_NCCREATE
, sent
},
2726 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
2727 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
2728 { WM_CREATE
, sent
},
2729 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2730 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2731 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
, 0, SWP_NOZORDER
}, /* MDI frame */
2732 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 }, /* MDI frame */
2733 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
, 0, SWP_NOZORDER
}, /* MDI frame */
2735 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
2736 { WM_GETMINMAXINFO
, sent
},
2737 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_STATECHANGED
},
2738 { WM_GETMINMAXINFO
, sent
|defwinproc
},
2739 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2740 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOREDRAW
|SWP_STATECHANGED
},
2741 { WM_MOVE
, sent
|defwinproc
},
2742 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2744 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2745 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2746 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2747 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2748 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 }, /* MDI child */
2749 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2750 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2751 /* Win2k sends wparam set to
2752 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2753 * while Win9x doesn't bother to set child window id according to
2754 * CLIENTCREATESTRUCT.idFirstChild
2756 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
2759 /* WM_SYSCOMMAND/SC_CLOSE for the 2nd MDI child window, initially visible and maximized */
2760 static const struct message WmDestroyMDIchildVisibleMaxSeq2
[] = {
2761 { WM_SYSCOMMAND
, sent
|wparam
, SC_CLOSE
},
2762 { HCBT_SYSCOMMAND
, hook
},
2763 { WM_CLOSE
, sent
|defwinproc
},
2764 { WM_MDIDESTROY
, sent
}, /* in MDI client */
2766 /* bring the 1st MDI child to top */
2767 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOSIZE
|SWP_NOMOVE
}, /* in the 1st MDI child */
2768 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
}, /* in the 2nd MDI child */
2770 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2772 { WM_CHILDACTIVATE
, sent
|defwinproc
|wparam
|lparam
, 0, 0 }, /* in the 1st MDI child */
2773 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 0 }, /* in the 1st MDI child */
2774 { WM_MDIACTIVATE
, sent
|defwinproc
}, /* in the 1st MDI child */
2776 /* maximize the 1st MDI child */
2777 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
2778 { WM_GETMINMAXINFO
, sent
|defwinproc
},
2779 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
2780 { WM_NCCALCSIZE
, sent
|defwinproc
|wparam
, 1 },
2781 { WM_CHILDACTIVATE
, sent
|defwinproc
|wparam
|lparam
, 0, 0 },
2782 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
2783 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2785 /* restore the 2nd MDI child */
2786 { WM_SETREDRAW
, sent
|defwinproc
|wparam
, 0 },
2787 { HCBT_MINMAX
, hook
|lparam
, 0, SW_NORMALNA
},
2788 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_SHOWWINDOW
|SWP_STATECHANGED
},
2789 { WM_NCCALCSIZE
, sent
|defwinproc
|wparam
, 1 },
2791 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2793 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_SHOWWINDOW
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
2794 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2796 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2798 { WM_SETREDRAW
, sent
|defwinproc
|wparam
, 1 },
2800 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2801 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2802 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2803 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2804 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2806 /* bring the 1st MDI child to top */
2807 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2808 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 },
2809 { HCBT_SETFOCUS
, hook
},
2810 { WM_KILLFOCUS
, sent
|defwinproc
},
2811 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 0 },
2812 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2813 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2814 { WM_SETFOCUS
, sent
}, /* in MDI client */
2815 { HCBT_SETFOCUS
, hook
},
2816 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2817 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2818 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
2819 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2820 { WM_SETFOCUS
, sent
|defwinproc
},
2821 { WM_MDIACTIVATE
, sent
|defwinproc
},
2822 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2824 /* apparently ShowWindow(SW_SHOW) on an MDI client */
2825 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
2826 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2827 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2828 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2829 { WM_MDIREFRESHMENU
, sent
},
2831 { HCBT_DESTROYWND
, hook
},
2832 /* Win2k sends wparam set to
2833 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
2834 * while Win9x doesn't bother to set child window id according to
2835 * CLIENTCREATESTRUCT.idFirstChild
2837 { 0x0090, sent
|defwinproc
|optional
},
2838 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_DESTROY*/ }, /* in MDI client */
2839 { WM_SHOWWINDOW
, sent
|defwinproc
|wparam
, 0 },
2840 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2841 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2842 { WM_ERASEBKGND
, sent
|parent
|optional
},
2843 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2845 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
2846 { WM_DESTROY
, sent
|defwinproc
},
2847 { WM_NCDESTROY
, sent
|defwinproc
},
2850 /* WM_MDIDESTROY for the single MDI child window, initially visible and maximized */
2851 static const struct message WmDestroyMDIchildVisibleMaxSeq1
[] = {
2852 { WM_MDIDESTROY
, sent
}, /* in MDI client */
2853 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
2854 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2855 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2856 { WM_ERASEBKGND
, sent
|parent
|optional
},
2857 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2859 { HCBT_SETFOCUS
, hook
},
2860 { WM_KILLFOCUS
, sent
},
2861 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
2862 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2863 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2864 { WM_SETFOCUS
, sent
}, /* in MDI client */
2865 { HCBT_SETFOCUS
, hook
},
2866 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2867 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2868 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
2869 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2870 { WM_SETFOCUS
, sent
},
2873 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2874 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2875 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2876 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2879 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2880 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2881 { 0x0093, sent
|defwinproc
|optional
},
2882 { 0x0093, sent
|defwinproc
|optional
},
2883 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2884 { WM_MOVE
, sent
|defwinproc
},
2885 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2888 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
2889 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2890 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
},
2891 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2894 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
2895 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2896 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
},
2897 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2900 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2901 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 },
2902 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2903 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2906 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2907 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 },
2908 { 0x0093, sent
|defwinproc
|optional
},
2909 { 0x0093, sent
|defwinproc
|optional
},
2910 { 0x0093, sent
|defwinproc
|optional
},
2911 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2912 { WM_MOVE
, sent
|defwinproc
},
2913 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2916 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
2917 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2918 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
},
2919 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2922 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
},
2923 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 },
2924 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
},
2925 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2926 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2927 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI client */
2929 { 0x0093, sent
|defwinproc
|optional
},
2930 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
|optional
, 1 }, /* XP sends it to MDI frame */
2931 { 0x0093, sent
|defwinproc
|optional
},
2932 { 0x0093, sent
|defwinproc
|optional
},
2933 { 0x0093, sent
|defwinproc
|optional
},
2934 { 0x0093, sent
|optional
},
2936 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2937 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2938 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI client */
2939 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2940 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* XP sends a duplicate */
2943 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2944 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
2945 { 0x0093, sent
|defwinproc
|optional
},
2946 { 0x0093, sent
|defwinproc
|optional
},
2947 { 0x0093, sent
|defwinproc
|optional
},
2948 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2949 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2950 { 0x0093, sent
|optional
},
2952 { WM_NCACTIVATE
, sent
|wparam
, 0 },
2953 { WM_MDIACTIVATE
, sent
},
2955 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWNORMAL
},
2956 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_SHOWWINDOW
|SWP_STATECHANGED
},
2957 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2959 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2961 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2962 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_SHOWWINDOW
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
2963 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2966 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2967 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 },
2968 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2969 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2972 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2973 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2974 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2975 { WM_MOVE
, sent
|defwinproc
},
2976 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2979 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
2980 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2981 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
},
2982 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2983 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2984 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 }, /* XP */
2985 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI client */
2986 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2987 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* XP sends a duplicate */
2989 { HCBT_SETFOCUS
, hook
},
2990 { WM_KILLFOCUS
, sent
},
2991 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
2992 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2993 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2994 { WM_SETFOCUS
, sent
}, /* in MDI client */
2996 { WM_MDIREFRESHMENU
, sent
}, /* in MDI client */
2998 { HCBT_DESTROYWND
, hook
},
2999 /* Win2k sends wparam set to
3000 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
3001 * while Win9x doesn't bother to set child window id according to
3002 * CLIENTCREATESTRUCT.idFirstChild
3004 { 0x0090, sent
|optional
},
3005 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_DESTROY*/ }, /* in MDI client */
3007 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
3008 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
3009 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
3010 { WM_ERASEBKGND
, sent
|parent
|optional
},
3011 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
3013 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
3014 { WM_DESTROY
, sent
},
3015 { WM_NCDESTROY
, sent
},
3018 /* ShowWindow(SW_MAXIMIZE) for a not visible MDI child window */
3019 static const struct message WmMaximizeMDIchildInvisibleSeq
[] = {
3020 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
3021 { WM_GETMINMAXINFO
, sent
},
3022 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_STATECHANGED
},
3023 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3024 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
3025 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
3027 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
3028 { WM_NCACTIVATE
, sent
|wparam
|optional
|defwinproc
, 1 },
3029 { HCBT_SETFOCUS
, hook
|optional
},
3030 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
3031 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
3032 { WM_SETFOCUS
, sent
|optional
}, /* in MDI client */
3033 { HCBT_SETFOCUS
, hook
|optional
},
3034 { WM_KILLFOCUS
, sent
|optional
}, /* in MDI client */
3035 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
3036 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
3037 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
3038 { WM_SETFOCUS
, sent
|optional
|defwinproc
},
3039 { WM_MDIACTIVATE
, sent
|optional
|defwinproc
},
3040 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
3041 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
3043 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
3044 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3045 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
3046 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
3047 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
3050 /* ShowWindow(SW_MAXIMIZE) for a not visible maximized MDI child window */
3051 static const struct message WmMaximizeMDIchildInvisibleSeq2
[] = {
3052 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
3053 { WM_GETMINMAXINFO
, sent
},
3054 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
},
3055 { WM_GETMINMAXINFO
, sent
|defwinproc
},
3056 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3057 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
3058 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
3060 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
|optional
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
3061 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
|optional
, 1 },
3062 { HCBT_SETFOCUS
, hook
|optional
},
3063 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
3064 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
3065 { WM_SETFOCUS
, sent
|optional
}, /* in MDI client */
3066 { HCBT_SETFOCUS
, hook
|optional
},
3067 { WM_KILLFOCUS
, sent
|optional
}, /* in MDI client */
3068 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
3069 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
3070 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
3071 { WM_SETFOCUS
, sent
|defwinproc
|optional
},
3072 { WM_MDIACTIVATE
, sent
|defwinproc
|optional
},
3073 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
3074 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
3077 /* WM_MDIMAXIMIZE for an MDI child window with invisible parent */
3078 static const struct message WmMaximizeMDIchildInvisibleParentSeq
[] = {
3079 { WM_MDIMAXIMIZE
, sent
}, /* in MDI client */
3080 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
3081 { WM_GETMINMAXINFO
, sent
},
3082 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
3083 { WM_GETMINMAXINFO
, sent
|defwinproc
},
3084 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3085 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* XP doesn't send it */
3086 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
3087 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOREDRAW
|SWP_STATECHANGED
},
3088 { WM_MOVE
, sent
|defwinproc
},
3089 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
3091 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
3092 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 },
3093 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
3094 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
|optional
, 1 },
3095 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI child XP */
3096 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI client XP */
3098 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
3099 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3100 { 0x0093, sent
|defwinproc
|optional
},
3101 { 0x0094, sent
|defwinproc
|optional
},
3102 { 0x0094, sent
|defwinproc
|optional
},
3103 { 0x0094, sent
|defwinproc
|optional
},
3104 { 0x0094, sent
|defwinproc
|optional
},
3105 { 0x0093, sent
|defwinproc
|optional
},
3106 { 0x0093, sent
|defwinproc
|optional
},
3107 { 0x0091, sent
|defwinproc
|optional
},
3108 { 0x0092, sent
|defwinproc
|optional
},
3109 { 0x0092, sent
|defwinproc
|optional
},
3110 { 0x0092, sent
|defwinproc
|optional
},
3111 { 0x0092, sent
|defwinproc
|optional
},
3112 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
3113 { WM_MOVE
, sent
|defwinproc
},
3114 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
3115 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI frame win2000 */
3117 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
3118 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3119 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
},
3120 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
3122 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
},
3123 { WM_GETMINMAXINFO
, sent
|defwinproc
},
3124 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 },
3125 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
},
3126 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
3127 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI child win2000 */
3128 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
|optional
, 1 },
3129 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI child XP */
3130 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI child XP */
3131 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI client XP */
3133 { 0x0093, sent
|optional
},
3134 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
3135 { 0x0093, sent
|defwinproc
|optional
},
3136 { 0x0093, sent
|defwinproc
|optional
},
3137 { 0x0093, sent
|defwinproc
|optional
},
3138 { 0x0091, sent
|defwinproc
|optional
},
3139 { 0x0092, sent
|defwinproc
|optional
},
3140 { 0x0092, sent
|defwinproc
|optional
},
3141 { 0x0092, sent
|defwinproc
|optional
},
3142 { 0x0092, sent
|defwinproc
|optional
},
3143 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI frame XP */
3144 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI frame XP */
3145 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI child XP */
3148 /* ShowWindow(SW_MAXIMIZE) for a visible MDI child window */
3149 static const struct message WmMaximizeMDIchildVisibleSeq
[] = {
3150 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
3151 { WM_GETMINMAXINFO
, sent
},
3152 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
3153 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3154 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
3155 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
3156 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
3158 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
3159 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3160 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
3161 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
3162 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
3165 /* ShowWindow(SW_RESTORE) for a visible maximized MDI child window */
3166 static const struct message WmRestoreMDIchildVisibleSeq
[] = {
3167 { HCBT_MINMAX
, hook
|lparam
, 0, SW_RESTORE
},
3168 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
3169 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3170 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
3171 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
3172 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
3174 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
3175 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3176 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
3177 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
3178 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
3181 /* ShowWindow(SW_RESTORE) for a visible minimized MDI child window */
3182 static const struct message WmRestoreMDIchildVisibleSeq_2
[] = {
3183 { HCBT_MINMAX
, hook
|lparam
, 0, SW_RESTORE
},
3184 { WM_QUERYOPEN
, sent
|wparam
|lparam
, 0, 0 },
3185 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
3186 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3187 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
3188 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
3189 { WM_MOVE
, sent
|defwinproc
},
3190 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
3191 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
3192 { EVENT_SYSTEM_MINIMIZEEND
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
3193 { HCBT_SETFOCUS
, hook
},
3194 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
3195 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
3196 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
3197 { WM_SETFOCUS
, sent
},
3200 /* ShowWindow(SW_MINIMIZE) for a visible restored MDI child window */
3201 static const struct message WmMinimizeMDIchildVisibleSeq
[] = {
3202 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
3203 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
3204 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3205 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
3206 { WM_MOVE
, sent
|defwinproc
},
3207 { WM_SIZE
, sent
|defwinproc
|wparam
|lparam
, SIZE_MINIMIZED
, 0 },
3208 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
|defwinproc
, 0, 0 },
3209 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
3210 { EVENT_SYSTEM_MINIMIZESTART
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
3211 /* FIXME: Wine creates an icon/title window while Windows doesn't */
3212 { WM_PARENTNOTIFY
, sent
|parent
|wparam
|optional
, WM_CREATE
}, /* MDI client */
3215 /* ShowWindow(SW_RESTORE) for a not visible MDI child window */
3216 static const struct message WmRestoreMDIchildInvisibleSeq
[] = {
3217 { HCBT_MINMAX
, hook
|lparam
, 0, SW_RESTORE
},
3218 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_STATECHANGED
},
3219 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3220 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
3221 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
3222 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
3223 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
3225 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
3226 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3227 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
3228 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
3229 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
3233 static HWND mdi_client
;
3234 static WNDPROC old_mdi_client_proc
;
3236 static LRESULT WINAPI
mdi_client_hook_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
3238 struct recvd_message msg
;
3240 /* do not log painting messages */
3241 if (message
!= WM_PAINT
&&
3242 message
!= WM_NCPAINT
&&
3243 message
!= WM_SYNCPAINT
&&
3244 message
!= WM_ERASEBKGND
&&
3245 message
!= WM_NCHITTEST
&&
3246 message
!= WM_GETTEXT
&&
3247 message
!= WM_MDIGETACTIVE
&&
3248 !ignore_message( message
))
3251 msg
.message
= message
;
3252 msg
.flags
= sent
|wparam
|lparam
;
3253 msg
.wParam
= wParam
;
3254 msg
.lParam
= lParam
;
3255 msg
.descr
= "mdi client";
3259 return CallWindowProcA(old_mdi_client_proc
, hwnd
, message
, wParam
, lParam
);
3262 static LRESULT WINAPI
mdi_child_wnd_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
3264 static LONG defwndproc_counter
= 0;
3266 struct recvd_message msg
;
3268 /* do not log painting messages */
3269 if (message
!= WM_PAINT
&&
3270 message
!= WM_NCPAINT
&&
3271 message
!= WM_SYNCPAINT
&&
3272 message
!= WM_ERASEBKGND
&&
3273 message
!= WM_NCHITTEST
&&
3274 message
!= WM_GETTEXT
&&
3275 !ignore_message( message
))
3279 case WM_MDIACTIVATE
:
3281 HWND active
, client
= GetParent(hwnd
);
3283 active
= (HWND
)SendMessageA(client
, WM_MDIGETACTIVE
, 0, 0);
3285 if (hwnd
== (HWND
)lParam
) /* if we are being activated */
3286 ok (active
== (HWND
)lParam
, "new active %p != active %p\n", (HWND
)lParam
, active
);
3288 ok (active
== (HWND
)wParam
, "old active %p != active %p\n", (HWND
)wParam
, active
);
3294 msg
.message
= message
;
3295 msg
.flags
= sent
|wparam
|lparam
;
3296 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
3297 msg
.wParam
= wParam
;
3298 msg
.lParam
= lParam
;
3299 msg
.descr
= "mdi child";
3303 defwndproc_counter
++;
3304 ret
= DefMDIChildProcA(hwnd
, message
, wParam
, lParam
);
3305 defwndproc_counter
--;
3310 static LRESULT WINAPI
mdi_frame_wnd_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
3312 static LONG defwndproc_counter
= 0;
3314 struct recvd_message msg
;
3316 /* do not log painting messages */
3317 if (message
!= WM_PAINT
&&
3318 message
!= WM_NCPAINT
&&
3319 message
!= WM_SYNCPAINT
&&
3320 message
!= WM_ERASEBKGND
&&
3321 message
!= WM_NCHITTEST
&&
3322 message
!= WM_GETTEXT
&&
3323 !ignore_message( message
))
3326 msg
.message
= message
;
3327 msg
.flags
= sent
|wparam
|lparam
;
3328 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
3329 msg
.wParam
= wParam
;
3330 msg
.lParam
= lParam
;
3331 msg
.descr
= "mdi frame";
3335 defwndproc_counter
++;
3336 ret
= DefFrameProcA(hwnd
, mdi_client
, message
, wParam
, lParam
);
3337 defwndproc_counter
--;
3342 static BOOL
mdi_RegisterWindowClasses(void)
3347 cls
.lpfnWndProc
= mdi_frame_wnd_proc
;
3350 cls
.hInstance
= GetModuleHandleA(0);
3352 cls
.hCursor
= LoadCursorA(0, (LPCSTR
)IDC_ARROW
);
3353 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
3354 cls
.lpszMenuName
= NULL
;
3355 cls
.lpszClassName
= "MDI_frame_class";
3356 if (!RegisterClassA(&cls
)) return FALSE
;
3358 cls
.lpfnWndProc
= mdi_child_wnd_proc
;
3359 cls
.lpszClassName
= "MDI_child_class";
3360 if (!RegisterClassA(&cls
)) return FALSE
;
3362 if (!GetClassInfoA(0, "MDIClient", &cls
)) assert(0);
3363 old_mdi_client_proc
= cls
.lpfnWndProc
;
3364 cls
.hInstance
= GetModuleHandleA(0);
3365 cls
.lpfnWndProc
= mdi_client_hook_proc
;
3366 cls
.lpszClassName
= "MDI_client_class";
3367 if (!RegisterClassA(&cls
)) assert(0);
3372 static void test_mdi_messages(void)
3374 MDICREATESTRUCTA mdi_cs
;
3375 CLIENTCREATESTRUCT client_cs
;
3376 HWND mdi_frame
, mdi_child
, mdi_child2
, active_child
;
3379 HMENU hMenu
= CreateMenu();
3381 if (!mdi_RegisterWindowClasses()) assert(0);
3385 trace("creating MDI frame window\n");
3386 mdi_frame
= CreateWindowExA(0, "MDI_frame_class", "MDI frame window",
3387 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
|
3388 WS_MAXIMIZEBOX
| WS_VISIBLE
,
3389 100, 100, CW_USEDEFAULT
, CW_USEDEFAULT
,
3390 GetDesktopWindow(), hMenu
,
3391 GetModuleHandleA(0), NULL
);
3393 ok_sequence(WmCreateMDIframeSeq
, "Create MDI frame window", FALSE
);
3395 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3396 ok(GetFocus() == mdi_frame
, "wrong focus window %p\n", GetFocus());
3398 trace("creating MDI client window\n");
3399 GetClientRect(mdi_frame
, &rc
);
3400 client_cs
.hWindowMenu
= 0;
3401 client_cs
.idFirstChild
= MDI_FIRST_CHILD_ID
;
3402 mdi_client
= CreateWindowExA(0, "MDI_client_class",
3404 WS_CHILD
| WS_VISIBLE
| MDIS_ALLCHILDSTYLES
,
3405 rc
.left
, rc
.top
, rc
.right
- rc
.left
, rc
.bottom
- rc
.top
,
3406 mdi_frame
, 0, GetModuleHandleA(0), &client_cs
);
3408 ok_sequence(WmCreateMDIclientSeq
, "Create visible MDI client window", FALSE
);
3410 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3411 ok(GetFocus() == mdi_frame
, "input focus should be on MDI frame not on %p\n", GetFocus());
3413 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3414 ok(!active_child
, "wrong active MDI child %p\n", active_child
);
3415 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
3420 trace("creating invisible MDI child window\n");
3421 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3423 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
3424 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3428 ShowWindow(mdi_child
, SW_SHOWNORMAL
);
3429 ok_sequence(WmShowChildSeq
, "ShowWindow(SW_SHOWNORMAL) MDI child window", FALSE
);
3431 ok(GetWindowLongA(mdi_child
, GWL_STYLE
) & WS_VISIBLE
, "MDI child should be visible\n");
3432 ok(IsWindowVisible(mdi_child
), "MDI child should be visible\n");
3434 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3435 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3437 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3438 ok(!active_child
, "wrong active MDI child %p\n", active_child
);
3439 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
3441 ShowWindow(mdi_child
, SW_HIDE
);
3442 ok_sequence(WmHideChildSeq
, "ShowWindow(SW_HIDE) MDI child window", FALSE
);
3445 ShowWindow(mdi_child
, SW_SHOW
);
3446 ok_sequence(WmShowChildSeq
, "ShowWindow(SW_SHOW) MDI child window", FALSE
);
3448 ok(GetWindowLongA(mdi_child
, GWL_STYLE
) & WS_VISIBLE
, "MDI child should be visible\n");
3449 ok(IsWindowVisible(mdi_child
), "MDI child should be visible\n");
3451 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3452 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3454 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3455 ok(!active_child
, "wrong active MDI child %p\n", active_child
);
3456 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
3458 DestroyWindow(mdi_child
);
3461 trace("creating visible MDI child window\n");
3462 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3463 WS_CHILD
| WS_VISIBLE
,
3464 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
3465 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3467 ok_sequence(WmCreateMDIchildVisibleSeq
, "Create visible MDI child window", FALSE
);
3469 ok(GetWindowLongA(mdi_child
, GWL_STYLE
) & WS_VISIBLE
, "MDI child should be visible\n");
3470 ok(IsWindowVisible(mdi_child
), "MDI child should be visible\n");
3472 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3473 ok(GetFocus() == mdi_child
, "wrong focus window %p\n", GetFocus());
3475 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3476 ok(active_child
== mdi_child
, "wrong active MDI child %p\n", active_child
);
3477 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
3480 DestroyWindow(mdi_child
);
3481 ok_sequence(WmDestroyMDIchildVisibleSeq
, "Destroy visible MDI child window", TRUE
);
3483 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3484 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3486 /* Win2k: MDI client still returns a just destroyed child as active
3487 * Win9x: MDI client returns 0
3489 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3490 ok(active_child
== mdi_child
|| /* win2k */
3491 !active_child
, /* win9x */
3492 "wrong active MDI child %p\n", active_child
);
3493 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
3497 trace("creating invisible MDI child window\n");
3498 mdi_child2
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3500 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
3501 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3503 ok_sequence(WmCreateMDIchildInvisibleSeq
, "Create invisible MDI child window", FALSE
);
3505 ok(!(GetWindowLongA(mdi_child2
, GWL_STYLE
) & WS_VISIBLE
), "MDI child should not be visible\n");
3506 ok(!IsWindowVisible(mdi_child2
), "MDI child should not be visible\n");
3508 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3509 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3511 /* Win2k: MDI client still returns a just destroyed child as active
3512 * Win9x: MDI client returns mdi_child2
3514 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3515 ok(active_child
== mdi_child
|| /* win2k */
3516 active_child
== mdi_child2
, /* win9x */
3517 "wrong active MDI child %p\n", active_child
);
3518 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
3521 ShowWindow(mdi_child2
, SW_MAXIMIZE
);
3522 ok_sequence(WmMaximizeMDIchildInvisibleSeq
, "ShowWindow(SW_MAXIMIZE):invisible MDI child", FALSE
);
3524 ok(GetWindowLongA(mdi_child2
, GWL_STYLE
) & WS_VISIBLE
, "MDI child should be visible\n");
3525 ok(IsWindowVisible(mdi_child2
), "MDI child should be visible\n");
3527 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3528 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
3529 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
3532 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3533 ok(GetFocus() == mdi_child2
|| /* win2k */
3534 GetFocus() == 0, /* win9x */
3535 "wrong focus window %p\n", GetFocus());
3540 ShowWindow(mdi_child2
, SW_HIDE
);
3541 ok_sequence(WmHideChildSeq
, "ShowWindow(SW_HIDE):MDI child", FALSE
);
3543 ShowWindow(mdi_child2
, SW_RESTORE
);
3544 ok_sequence(WmRestoreMDIchildInvisibleSeq
, "ShowWindow(SW_RESTORE):invisible MDI child", FALSE
);
3547 ok(GetWindowLongA(mdi_child2
, GWL_STYLE
) & WS_VISIBLE
, "MDI child should be visible\n");
3548 ok(IsWindowVisible(mdi_child2
), "MDI child should be visible\n");
3550 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3551 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
3552 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
3558 ShowWindow(mdi_child2
, SW_HIDE
);
3559 ok_sequence(WmHideChildSeq
, "ShowWindow(SW_HIDE):MDI child", FALSE
);
3561 ShowWindow(mdi_child2
, SW_SHOW
);
3562 ok_sequence(WmShowChildSeq
, "ShowWindow(SW_SHOW):MDI child", FALSE
);
3564 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3565 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3567 ShowWindow(mdi_child2
, SW_MAXIMIZE
);
3568 ok_sequence(WmMaximizeMDIchildVisibleSeq
, "ShowWindow(SW_MAXIMIZE):MDI child", FALSE
);
3570 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3571 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3573 ShowWindow(mdi_child2
, SW_RESTORE
);
3574 ok_sequence(WmRestoreMDIchildVisibleSeq
, "ShowWindow(SW_RESTORE):maximized MDI child", FALSE
);
3576 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3577 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3579 ShowWindow(mdi_child2
, SW_MINIMIZE
);
3580 ok_sequence(WmMinimizeMDIchildVisibleSeq
, "ShowWindow(SW_MINIMIZE):MDI child", TRUE
);
3582 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3583 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3585 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3586 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
3587 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
3590 ShowWindow(mdi_child2
, SW_RESTORE
);
3591 ok_sequence(WmRestoreMDIchildVisibleSeq_2
, "ShowWindow(SW_RESTORE):minimized MDI child", FALSE
);
3593 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3594 ok(GetFocus() == mdi_child2
, "wrong focus window %p\n", GetFocus());
3596 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3597 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
3598 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
3604 ShowWindow(mdi_child2
, SW_HIDE
);
3605 ok_sequence(WmHideChildSeq
, "ShowWindow(SW_HIDE):MDI child", FALSE
);
3607 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3608 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3610 DestroyWindow(mdi_child2
);
3611 ok_sequence(WmDestroyMDIchildInvisibleSeq
, "Destroy invisible MDI child window", FALSE
);
3613 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3614 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3616 /* test for maximized MDI children */
3617 trace("creating maximized visible MDI child window 1\n");
3618 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3619 WS_CHILD
| WS_VISIBLE
| WS_MAXIMIZEBOX
| WS_MAXIMIZE
,
3620 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
3621 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3623 ok_sequence(WmCreateMDIchildVisibleMaxSeq1
, "Create maximized visible 1st MDI child window", TRUE
);
3624 ok(IsZoomed(mdi_child
), "1st MDI child should be maximized\n");
3626 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3627 ok(GetFocus() == mdi_child
|| /* win2k */
3628 GetFocus() == 0, /* win9x */
3629 "wrong focus window %p\n", GetFocus());
3631 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3632 ok(active_child
== mdi_child
, "wrong active MDI child %p\n", active_child
);
3633 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
3636 trace("creating maximized visible MDI child window 2\n");
3637 mdi_child2
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3638 WS_CHILD
| WS_VISIBLE
| WS_MAXIMIZEBOX
| WS_MAXIMIZE
,
3639 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
3640 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3642 ok_sequence(WmCreateMDIchildVisibleMaxSeq2
, "Create maximized visible 2nd MDI child 2 window", TRUE
);
3643 ok(IsZoomed(mdi_child2
), "2nd MDI child should be maximized\n");
3644 ok(!IsZoomed(mdi_child
), "1st MDI child should NOT be maximized\n");
3646 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3647 ok(GetFocus() == mdi_child2
, "wrong focus window %p\n", GetFocus());
3649 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3650 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
3651 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
3654 trace("destroying maximized visible MDI child window 2\n");
3655 DestroyWindow(mdi_child2
);
3656 ok_sequence(WmDestroyMDIchildVisibleSeq
, "Destroy visible MDI child window", TRUE
);
3658 ok(!IsZoomed(mdi_child
), "1st MDI child should NOT be maximized\n");
3660 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3661 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3663 /* Win2k: MDI client still returns a just destroyed child as active
3664 * Win9x: MDI client returns 0
3666 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3667 ok(active_child
== mdi_child2
|| /* win2k */
3668 !active_child
, /* win9x */
3669 "wrong active MDI child %p\n", active_child
);
3672 ShowWindow(mdi_child
, SW_MAXIMIZE
);
3673 ok(IsZoomed(mdi_child
), "1st MDI child should be maximized\n");
3676 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3677 ok(GetFocus() == mdi_child
, "wrong focus window %p\n", GetFocus());
3679 trace("re-creating maximized visible MDI child window 2\n");
3680 mdi_child2
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3681 WS_CHILD
| WS_VISIBLE
| WS_MAXIMIZEBOX
| WS_MAXIMIZE
,
3682 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
3683 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3685 ok_sequence(WmCreateMDIchildVisibleMaxSeq2
, "Create maximized visible 2nd MDI child 2 window", TRUE
);
3686 ok(IsZoomed(mdi_child2
), "2nd MDI child should be maximized\n");
3687 ok(!IsZoomed(mdi_child
), "1st MDI child should NOT be maximized\n");
3689 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3690 ok(GetFocus() == mdi_child2
, "wrong focus window %p\n", GetFocus());
3692 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3693 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
3694 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
3697 SendMessageA(mdi_child2
, WM_SYSCOMMAND
, SC_CLOSE
, 0);
3698 ok_sequence(WmDestroyMDIchildVisibleMaxSeq2
, "WM_SYSCOMMAND/SC_CLOSE on a visible maximized MDI child window", TRUE
);
3699 ok(!IsWindow(mdi_child2
), "MDI child 2 should be destroyed\n");
3701 ok(IsZoomed(mdi_child
), "1st MDI child should be maximized\n");
3702 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3703 ok(GetFocus() == mdi_child
, "wrong focus window %p\n", GetFocus());
3705 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3706 ok(active_child
== mdi_child
, "wrong active MDI child %p\n", active_child
);
3707 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
3710 DestroyWindow(mdi_child
);
3711 ok_sequence(WmDestroyMDIchildVisibleSeq
, "Destroy visible MDI child window", TRUE
);
3713 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3714 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3716 /* Win2k: MDI client still returns a just destroyed child as active
3717 * Win9x: MDI client returns 0
3719 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3720 ok(active_child
== mdi_child
|| /* win2k */
3721 !active_child
, /* win9x */
3722 "wrong active MDI child %p\n", active_child
);
3725 trace("creating maximized invisible MDI child window\n");
3726 mdi_child2
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3727 WS_CHILD
| WS_MAXIMIZE
| WS_CAPTION
| WS_THICKFRAME
,
3728 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
3729 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3731 ok_sequence(WmCreateMDIchildInvisibleMaxSeq4
, "Create maximized invisible MDI child window", FALSE
);
3732 ok(IsZoomed(mdi_child2
), "MDI child should be maximized\n");
3733 ok(!(GetWindowLongA(mdi_child2
, GWL_STYLE
) & WS_VISIBLE
), "MDI child should be not visible\n");
3734 ok(!IsWindowVisible(mdi_child2
), "MDI child should be not visible\n");
3736 /* Win2k: MDI client still returns a just destroyed child as active
3737 * Win9x: MDI client returns 0
3739 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3740 ok(active_child
== mdi_child
|| /* win2k */
3741 !active_child
|| active_child
== mdi_child2
, /* win9x */
3742 "wrong active MDI child %p\n", active_child
);
3745 trace("call ShowWindow(mdi_child, SW_MAXIMIZE)\n");
3746 ShowWindow(mdi_child2
, SW_MAXIMIZE
);
3747 ok_sequence(WmMaximizeMDIchildInvisibleSeq2
, "ShowWindow(SW_MAXIMIZE):invisible maximized MDI child", FALSE
);
3748 ok(IsZoomed(mdi_child2
), "MDI child should be maximized\n");
3749 ok(GetWindowLongA(mdi_child2
, GWL_STYLE
) & WS_VISIBLE
, "MDI child should be visible\n");
3750 ok(IsWindowVisible(mdi_child2
), "MDI child should be visible\n");
3752 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3753 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
3754 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
3757 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child2
, 0);
3760 /* end of test for maximized MDI children */
3763 trace("creating maximized visible MDI child window 1(Switch test)\n");
3764 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3765 WS_CHILD
| WS_VISIBLE
| WS_MAXIMIZEBOX
| WS_MAXIMIZE
,
3766 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
3767 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3769 ok_sequence(WmCreateMDIchildVisibleMaxSeq1
, "Create maximized visible 1st MDI child window(Switch test)", TRUE
);
3770 ok(IsZoomed(mdi_child
), "1st MDI child should be maximized(Switch test)\n");
3772 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p(Switch test)\n", GetActiveWindow());
3773 ok(GetFocus() == mdi_child
|| /* win2k */
3774 GetFocus() == 0, /* win9x */
3775 "wrong focus window %p(Switch test)\n", GetFocus());
3777 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3778 ok(active_child
== mdi_child
, "wrong active MDI child %p(Switch test)\n", active_child
);
3779 ok(zoomed
, "wrong zoomed state %d(Switch test)\n", zoomed
);
3782 trace("creating maximized visible MDI child window 2(Switch test)\n");
3783 mdi_child2
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3784 WS_CHILD
| WS_VISIBLE
| WS_MAXIMIZEBOX
| WS_MAXIMIZE
,
3785 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
3786 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3788 ok_sequence(WmCreateMDIchildVisibleMaxSeq2
, "Create maximized visible 2nd MDI child window (Switch test)", TRUE
);
3790 ok(IsZoomed(mdi_child2
), "2nd MDI child should be maximized(Switch test)\n");
3791 ok(!IsZoomed(mdi_child
), "1st MDI child should NOT be maximized(Switch test)\n");
3793 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p(Switch test)\n", GetActiveWindow());
3794 ok(GetFocus() == mdi_child2
, "wrong focus window %p(Switch test)\n", GetFocus());
3796 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3797 ok(active_child
== mdi_child2
, "wrong active MDI child %p(Switch test)\n", active_child
);
3798 ok(zoomed
, "wrong zoomed state %d(Switch test)\n", zoomed
);
3801 trace("Switch child window.\n");
3802 SendMessageA(mdi_client
, WM_MDIACTIVATE
, (WPARAM
)mdi_child
, 0);
3803 ok_sequence(WmSwitchChild
, "Child did not switch correctly", TRUE
);
3804 trace("end of test for switch maximized MDI children\n");
3807 /* Prepare for switching test of not maximized MDI children */
3808 ShowWindow( mdi_child
, SW_NORMAL
);
3809 ok(!IsZoomed(mdi_child
), "wrong zoomed state for %p(Switch test)\n", mdi_child
);
3810 ok(!IsZoomed(mdi_child2
), "wrong zoomed state for %p(Switch test)\n", mdi_child2
);
3811 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, 0);
3812 ok(active_child
== mdi_child
, "wrong active MDI child %p(Switch test)\n", active_child
);
3815 SendMessageA(mdi_client
, WM_MDIACTIVATE
, (WPARAM
)mdi_child2
, 0);
3816 ok_sequence(WmSwitchNotMaximizedChild
, "Not maximized child did not switch correctly", FALSE
);
3817 trace("end of test for switch not maximized MDI children\n");
3820 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
3823 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child2
, 0);
3828 /* end of tests for switch maximized/not maximized MDI children */
3830 mdi_cs
.szClass
= "MDI_child_Class";
3831 mdi_cs
.szTitle
= "MDI child";
3832 mdi_cs
.hOwner
= GetModuleHandleA(0);
3835 mdi_cs
.cx
= CW_USEDEFAULT
;
3836 mdi_cs
.cy
= CW_USEDEFAULT
;
3837 mdi_cs
.style
= WS_CHILD
| WS_SYSMENU
| WS_VISIBLE
| WS_MAXIMIZEBOX
| WS_MAXIMIZE
;
3839 mdi_child
= (HWND
)SendMessageA(mdi_client
, WM_MDICREATE
, 0, (LPARAM
)&mdi_cs
);
3840 ok(mdi_child
!= 0, "MDI child creation failed\n");
3841 ok_sequence(WmCreateMDIchildVisibleMaxSeq3
, "WM_MDICREATE for maximized visible MDI child window", TRUE
);
3843 ok(GetMenuItemID(hMenu
, GetMenuItemCount(hMenu
) - 1) == SC_CLOSE
, "SC_CLOSE menu item not found\n");
3845 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3846 ok(active_child
== mdi_child
, "wrong active MDI child %p\n", active_child
);
3848 ok(IsZoomed(mdi_child
), "MDI child should be maximized\n");
3849 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3850 ok(GetFocus() == mdi_child
, "wrong focus window %p\n", GetFocus());
3852 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3853 ok(active_child
== mdi_child
, "wrong active MDI child %p\n", active_child
);
3854 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
3857 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
3858 ok_sequence(WmDestroyMDIchildVisibleMaxSeq1
, "Destroy visible maximized MDI child window", TRUE
);
3860 ok(!IsWindow(mdi_child
), "MDI child should be destroyed\n");
3861 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3862 ok(!active_child
, "wrong active MDI child %p\n", active_child
);
3867 DestroyWindow(mdi_client
);
3868 ok_sequence(WmDestroyMDIclientSeq
, "Destroy MDI client window", FALSE
);
3870 /* test maximization of MDI child with invisible parent */
3871 client_cs
.hWindowMenu
= 0;
3872 mdi_client
= CreateWindowA("MDI_client_class",
3874 WS_CHILD
| WS_CLIPCHILDREN
| WS_VSCROLL
| WS_HSCROLL
| WS_VISIBLE
,
3876 mdi_frame
, 0, GetModuleHandleA(0), &client_cs
);
3877 ok_sequence(WmCreateMDIclientSeq
, "Create MDI client window", FALSE
);
3879 ShowWindow(mdi_client
, SW_HIDE
);
3880 ok_sequence(WmHideMDIclientSeq
, "Hide MDI client window", FALSE
);
3882 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3883 WS_CHILD
| WS_CLIPCHILDREN
| WS_VSCROLL
| WS_HSCROLL
,
3885 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3886 ok_sequence(WmCreateMDIchildInvisibleParentSeq
, "Create MDI child window with invisible parent", FALSE
);
3888 SendMessageA(mdi_client
, WM_MDIMAXIMIZE
, (WPARAM
) mdi_child
, 0);
3889 ok_sequence(WmMaximizeMDIchildInvisibleParentSeq
, "Maximize MDI child window with invisible parent", TRUE
);
3890 zoomed
= IsZoomed(mdi_child
);
3891 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
3893 ShowWindow(mdi_client
, SW_SHOW
);
3894 ok_sequence(WmShowMDIclientSeq
, "Show MDI client window", FALSE
);
3896 DestroyWindow(mdi_child
);
3897 ok_sequence(WmDestroyMDIchildVisibleSeq
, "Destroy visible maximized MDI child window", TRUE
);
3899 /* end of test for maximization of MDI child with invisible parent */
3901 DestroyWindow(mdi_client
);
3902 ok_sequence(WmDestroyMDIclientSeq
, "Destroy MDI client window", FALSE
);
3904 DestroyWindow(mdi_frame
);
3905 ok_sequence(WmDestroyMDIframeSeq
, "Destroy MDI frame window", FALSE
);
3907 /************************* End of MDI test **********************************/
3909 static void test_WM_SETREDRAW(HWND hwnd
)
3911 DWORD style
= GetWindowLongA(hwnd
, GWL_STYLE
);
3916 SendMessageA(hwnd
, WM_SETREDRAW
, FALSE
, 0);
3917 ok_sequence(WmSetRedrawFalseSeq
, "SetRedraw:FALSE", FALSE
);
3919 ok(!(GetWindowLongA(hwnd
, GWL_STYLE
) & WS_VISIBLE
), "WS_VISIBLE should NOT be set\n");
3920 ok(!IsWindowVisible(hwnd
), "IsWindowVisible() should return FALSE\n");
3923 SendMessageA(hwnd
, WM_SETREDRAW
, TRUE
, 0);
3924 ok_sequence(WmSetRedrawTrueSeq
, "SetRedraw:TRUE", FALSE
);
3926 ok(GetWindowLongA(hwnd
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
3927 ok(IsWindowVisible(hwnd
), "IsWindowVisible() should return TRUE\n");
3929 /* restore original WS_VISIBLE state */
3930 SetWindowLongA(hwnd
, GWL_STYLE
, style
);
3936 static INT_PTR CALLBACK
TestModalDlgProcA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
3938 struct recvd_message msg
;
3940 if (ignore_message( message
)) return 0;
3946 case WM_NCMOUSEMOVE
:
3947 case WM_NCMOUSELEAVE
:
3955 msg
.message
= message
;
3956 msg
.flags
= sent
|wparam
|lparam
;
3957 msg
.wParam
= wParam
;
3958 msg
.lParam
= lParam
;
3959 msg
.descr
= "dialog";
3962 if (message
== WM_INITDIALOG
) SetTimer( hwnd
, 1, 100, NULL
);
3963 if (message
== WM_TIMER
) EndDialog( hwnd
, 0 );
3967 static void test_hv_scroll_1(HWND hwnd
, INT ctl
, DWORD clear
, DWORD set
, INT min
, INT max
)
3969 DWORD style
, exstyle
;
3973 exstyle
= GetWindowLongA(hwnd
, GWL_EXSTYLE
);
3974 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
3975 /* do not be confused by WS_DLGFRAME set */
3976 if ((style
& WS_CAPTION
) == WS_CAPTION
) style
&= ~WS_CAPTION
;
3978 if (clear
) ok(style
& clear
, "style %08x should be set\n", clear
);
3979 if (set
) ok(!(style
& set
), "style %08x should not be set\n", set
);
3981 ret
= SetScrollRange(hwnd
, ctl
, min
, max
, FALSE
);
3982 ok( ret
, "SetScrollRange(%d) error %d\n", ctl
, GetLastError());
3983 if ((style
& (WS_DLGFRAME
| WS_BORDER
| WS_THICKFRAME
)) || (exstyle
& WS_EX_DLGMODALFRAME
))
3984 ok_sequence(WmSetScrollRangeHV_NC_Seq
, "SetScrollRange(SB_HORZ/SB_VERT) NC", FALSE
);
3986 ok_sequence(WmSetScrollRangeHVSeq
, "SetScrollRange(SB_HORZ/SB_VERT)", FALSE
);
3988 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
3989 if (set
) ok(style
& set
, "style %08x should be set\n", set
);
3990 if (clear
) ok(!(style
& clear
), "style %08x should not be set\n", clear
);
3992 /* a subsequent call should do nothing */
3993 ret
= SetScrollRange(hwnd
, ctl
, min
, max
, FALSE
);
3994 ok( ret
, "SetScrollRange(%d) error %d\n", ctl
, GetLastError());
3995 ok_sequence(WmEmptySeq
, "SetScrollRange(SB_HORZ/SB_VERT) empty sequence", FALSE
);
3999 ret
= GetScrollRange(hwnd
, ctl
, &xmin
, &xmax
);
4000 ok( ret
, "GetScrollRange(%d) error %d\n", ctl
, GetLastError());
4001 ok_sequence(WmEmptySeq
, "GetScrollRange(SB_HORZ/SB_VERT) empty sequence", FALSE
);
4002 ok(xmin
== min
, "unexpected min scroll value %d\n", xmin
);
4003 ok(xmax
== max
, "unexpected max scroll value %d\n", xmax
);
4006 static void test_hv_scroll_2(HWND hwnd
, INT ctl
, DWORD clear
, DWORD set
, INT min
, INT max
)
4008 DWORD style
, exstyle
;
4012 exstyle
= GetWindowLongA(hwnd
, GWL_EXSTYLE
);
4013 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
4014 /* do not be confused by WS_DLGFRAME set */
4015 if ((style
& WS_CAPTION
) == WS_CAPTION
) style
&= ~WS_CAPTION
;
4017 if (clear
) ok(style
& clear
, "style %08x should be set\n", clear
);
4018 if (set
) ok(!(style
& set
), "style %08x should not be set\n", set
);
4020 si
.cbSize
= sizeof(si
);
4021 si
.fMask
= SIF_RANGE
;
4024 SetScrollInfo(hwnd
, ctl
, &si
, TRUE
);
4025 if ((style
& (WS_DLGFRAME
| WS_BORDER
| WS_THICKFRAME
)) || (exstyle
& WS_EX_DLGMODALFRAME
))
4026 ok_sequence(WmSetScrollRangeHV_NC_Seq
, "SetScrollInfo(SB_HORZ/SB_VERT) NC", FALSE
);
4028 ok_sequence(WmSetScrollRangeHVSeq
, "SetScrollInfo(SB_HORZ/SB_VERT)", FALSE
);
4030 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
4031 if (set
) ok(style
& set
, "style %08x should be set\n", set
);
4032 if (clear
) ok(!(style
& clear
), "style %08x should not be set\n", clear
);
4034 /* a subsequent call should do nothing */
4035 SetScrollInfo(hwnd
, ctl
, &si
, TRUE
);
4036 if (style
& WS_HSCROLL
)
4037 ok_sequence(WmSetScrollRangeHSeq_empty
, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE
);
4038 else if (style
& WS_VSCROLL
)
4039 ok_sequence(WmSetScrollRangeVSeq_empty
, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE
);
4041 ok_sequence(WmEmptySeq
, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE
);
4043 si
.fMask
= SIF_PAGE
;
4045 SetScrollInfo(hwnd
, ctl
, &si
, FALSE
);
4046 ok_sequence(WmEmptySeq
, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE
);
4050 SetScrollInfo(hwnd
, ctl
, &si
, FALSE
);
4051 ok_sequence(WmEmptySeq
, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE
);
4053 si
.fMask
= SIF_RANGE
;
4054 si
.nMin
= 0xdeadbeef;
4055 si
.nMax
= 0xdeadbeef;
4056 ret
= GetScrollInfo(hwnd
, ctl
, &si
);
4057 ok( ret
, "GetScrollInfo error %d\n", GetLastError());
4058 ok_sequence(WmEmptySeq
, "GetScrollRange(SB_HORZ/SB_VERT) empty sequence", FALSE
);
4059 ok(si
.nMin
== min
, "unexpected min scroll value %d\n", si
.nMin
);
4060 ok(si
.nMax
== max
, "unexpected max scroll value %d\n", si
.nMax
);
4063 /* Win9x sends WM_USER+xxx while and NT versions send SBM_xxx messages */
4064 static void test_scroll_messages(HWND hwnd
)
4075 ret
= GetScrollRange(hwnd
, SB_CTL
, &min
, &max
);
4076 ok( ret
, "GetScrollRange error %d\n", GetLastError());
4077 if (sequence
->message
!= WmGetScrollRangeSeq
[0].message
)
4078 trace("GetScrollRange(SB_CTL) generated unknown message %04x\n", sequence
->message
);
4079 /* values of min and max are undefined */
4082 ret
= SetScrollRange(hwnd
, SB_CTL
, 10, 150, FALSE
);
4083 ok( ret
, "SetScrollRange error %d\n", GetLastError());
4084 if (sequence
->message
!= WmSetScrollRangeSeq
[0].message
)
4085 trace("SetScrollRange(SB_CTL) generated unknown message %04x\n", sequence
->message
);
4090 ret
= GetScrollRange(hwnd
, SB_CTL
, &min
, &max
);
4091 ok( ret
, "GetScrollRange error %d\n", GetLastError());
4092 if (sequence
->message
!= WmGetScrollRangeSeq
[0].message
)
4093 trace("GetScrollRange(SB_CTL) generated unknown message %04x\n", sequence
->message
);
4094 /* values of min and max are undefined */
4097 si
.cbSize
= sizeof(si
);
4098 si
.fMask
= SIF_RANGE
;
4101 SetScrollInfo(hwnd
, SB_CTL
, &si
, FALSE
);
4102 if (sequence
->message
!= WmSetScrollRangeSeq
[0].message
)
4103 trace("SetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence
->message
);
4106 si
.fMask
= SIF_PAGE
;
4108 SetScrollInfo(hwnd
, SB_CTL
, &si
, FALSE
);
4109 if (sequence
->message
!= WmSetScrollRangeSeq
[0].message
)
4110 trace("SetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence
->message
);
4115 SetScrollInfo(hwnd
, SB_CTL
, &si
, FALSE
);
4116 if (sequence
->message
!= WmSetScrollRangeSeq
[0].message
)
4117 trace("SetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence
->message
);
4120 si
.fMask
= SIF_RANGE
;
4121 si
.nMin
= 0xdeadbeef;
4122 si
.nMax
= 0xdeadbeef;
4123 ret
= GetScrollInfo(hwnd
, SB_CTL
, &si
);
4124 ok( ret
, "GetScrollInfo error %d\n", GetLastError());
4125 if (sequence
->message
!= WmGetScrollInfoSeq
[0].message
)
4126 trace("GetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence
->message
);
4127 /* values of min and max are undefined */
4130 /* set WS_HSCROLL */
4131 test_hv_scroll_1(hwnd
, SB_HORZ
, 0, WS_HSCROLL
, 10, 150);
4132 /* clear WS_HSCROLL */
4133 test_hv_scroll_1(hwnd
, SB_HORZ
, WS_HSCROLL
, 0, 0, 0);
4135 /* set WS_HSCROLL */
4136 test_hv_scroll_2(hwnd
, SB_HORZ
, 0, WS_HSCROLL
, 10, 150);
4137 /* clear WS_HSCROLL */
4138 test_hv_scroll_2(hwnd
, SB_HORZ
, WS_HSCROLL
, 0, 0, 0);
4140 /* set WS_VSCROLL */
4141 test_hv_scroll_1(hwnd
, SB_VERT
, 0, WS_VSCROLL
, 10, 150);
4142 /* clear WS_VSCROLL */
4143 test_hv_scroll_1(hwnd
, SB_VERT
, WS_VSCROLL
, 0, 0, 0);
4145 /* set WS_VSCROLL */
4146 test_hv_scroll_2(hwnd
, SB_VERT
, 0, WS_VSCROLL
, 10, 150);
4147 /* clear WS_VSCROLL */
4148 test_hv_scroll_2(hwnd
, SB_VERT
, WS_VSCROLL
, 0, 0, 0);
4151 static void test_showwindow(void)
4156 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW
,
4157 100, 100, 200, 200, 0, 0, 0, NULL
);
4158 ok (hwnd
!= 0, "Failed to create overlapped window\n");
4159 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
4160 0, 0, 10, 10, hwnd
, 0, 0, NULL
);
4161 ok (hchild
!= 0, "Failed to create child\n");
4164 /* ShowWindow( SW_SHOWNA) for invisible top level window */
4165 trace("calling ShowWindow( SW_SHOWNA) for invisible top level window\n");
4166 ok( ShowWindow(hwnd
, SW_SHOWNA
) == FALSE
, "ShowWindow: window was visible\n" );
4167 ok_sequence(WmSHOWNATopInvisible
, "ShowWindow(SW_SHOWNA) on invisible top level window", FALSE
);
4169 /* ShowWindow( SW_SHOWNA) for now visible top level window */
4170 trace("calling ShowWindow( SW_SHOWNA) for now visible top level window\n");
4171 ok( ShowWindow(hwnd
, SW_SHOWNA
) != FALSE
, "ShowWindow: window was invisible\n" );
4172 ok_sequence(WmSHOWNATopVisible
, "ShowWindow(SW_SHOWNA) on visible top level window", FALSE
);
4173 /* back to invisible */
4174 ShowWindow(hchild
, SW_HIDE
);
4175 ShowWindow(hwnd
, SW_HIDE
);
4177 /* ShowWindow(SW_SHOWNA) with child and parent invisible */
4178 trace("calling ShowWindow( SW_SHOWNA) for invisible child with invisible parent\n");
4179 ok( ShowWindow(hchild
, SW_SHOWNA
) == FALSE
, "ShowWindow: window was visible\n" );
4180 ok_sequence(WmSHOWNAChildInvisParInvis
, "ShowWindow(SW_SHOWNA) invisible child and parent", FALSE
);
4181 /* ShowWindow(SW_SHOWNA) with child visible and parent invisible */
4182 ok( ShowWindow(hchild
, SW_SHOW
) != FALSE
, "ShowWindow: window was invisible\n" );
4184 trace("calling ShowWindow( SW_SHOWNA) for the visible child and invisible parent\n");
4185 ok( ShowWindow(hchild
, SW_SHOWNA
) != FALSE
, "ShowWindow: window was invisible\n" );
4186 ok_sequence(WmSHOWNAChildVisParInvis
, "ShowWindow(SW_SHOWNA) visible child and invisible parent", FALSE
);
4187 /* ShowWindow(SW_SHOWNA) with child visible and parent visible */
4188 ShowWindow( hwnd
, SW_SHOW
);
4190 trace("calling ShowWindow( SW_SHOWNA) for the visible child and parent\n");
4191 ok( ShowWindow(hchild
, SW_SHOWNA
) != FALSE
, "ShowWindow: window was invisible\n" );
4192 ok_sequence(WmSHOWNAChildVisParVis
, "ShowWindow(SW_SHOWNA) for the visible child and parent", FALSE
);
4194 /* ShowWindow(SW_SHOWNA) with child invisible and parent visible */
4195 ShowWindow( hchild
, SW_HIDE
);
4197 trace("calling ShowWindow( SW_SHOWNA) for the invisible child and visible parent\n");
4198 ok( ShowWindow(hchild
, SW_SHOWNA
) == FALSE
, "ShowWindow: window was visible\n" );
4199 ok_sequence(WmSHOWNAChildInvisParVis
, "ShowWindow(SW_SHOWNA) for the invisible child and visible parent", FALSE
);
4202 ok(GetCapture() == hchild
, "wrong capture window %p\n", GetCapture());
4203 DestroyWindow(hchild
);
4204 ok(!GetCapture(), "wrong capture window %p\n", GetCapture());
4206 DestroyWindow(hwnd
);
4211 * 1. Create invisible maximized popup window.
4212 * 2. Move and resize it.
4213 * 3. Show it maximized.
4215 trace("calling CreateWindowExA( WS_MAXIMIZE ) for invisible maximized popup window\n");
4216 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP
| WS_MAXIMIZE
,
4217 100, 100, 200, 200, 0, 0, 0, NULL
);
4218 ok (hwnd
!= 0, "Failed to create popup window\n");
4219 ok(IsZoomed(hwnd
), "window should be maximized\n");
4220 ok_sequence(WmCreateInvisibleMaxPopupSeq
, "CreateWindow(WS_MAXIMIZED):popup", FALSE
);
4222 GetWindowRect(hwnd
, &rc
);
4223 ok( rc
.right
-rc
.left
== GetSystemMetrics(SM_CXSCREEN
) &&
4224 rc
.bottom
-rc
.top
== GetSystemMetrics(SM_CYSCREEN
),
4225 "Invalid maximized size before ShowWindow (%d,%d)-(%d,%d)\n",
4226 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4227 /* Reset window's size & position */
4228 SetWindowPos(hwnd
, 0, 10, 10, 200, 200, SWP_NOZORDER
| SWP_NOACTIVATE
);
4229 ok(IsZoomed(hwnd
), "window should be maximized\n");
4232 trace("calling ShowWindow( SW_SHOWMAXIMIZE ) for invisible maximized popup window\n");
4233 ShowWindow(hwnd
, SW_SHOWMAXIMIZED
);
4234 ok(IsZoomed(hwnd
), "window should be maximized\n");
4235 ok_sequence(WmShowMaxPopupResizedSeq
, "ShowWindow(SW_SHOWMAXIMIZED):invisible maximized and resized popup", FALSE
);
4237 GetWindowRect(hwnd
, &rc
);
4238 ok( rc
.right
-rc
.left
== GetSystemMetrics(SM_CXSCREEN
) &&
4239 rc
.bottom
-rc
.top
== GetSystemMetrics(SM_CYSCREEN
),
4240 "Invalid maximized size after ShowWindow (%d,%d)-(%d,%d)\n",
4241 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4242 DestroyWindow(hwnd
);
4246 * 1. Create invisible maximized popup window.
4247 * 2. Show it maximized.
4249 trace("calling CreateWindowExA( WS_MAXIMIZE ) for invisible maximized popup window\n");
4250 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP
| WS_MAXIMIZE
,
4251 100, 100, 200, 200, 0, 0, 0, NULL
);
4252 ok (hwnd
!= 0, "Failed to create popup window\n");
4253 ok(IsZoomed(hwnd
), "window should be maximized\n");
4254 ok_sequence(WmCreateInvisibleMaxPopupSeq
, "CreateWindow(WS_MAXIMIZED):popup", FALSE
);
4256 trace("calling ShowWindow( SW_SHOWMAXIMIZE ) for invisible maximized popup window\n");
4257 ShowWindow(hwnd
, SW_SHOWMAXIMIZED
);
4258 ok(IsZoomed(hwnd
), "window should be maximized\n");
4259 ok_sequence(WmShowMaxPopupSeq
, "ShowWindow(SW_SHOWMAXIMIZED):invisible maximized popup", FALSE
);
4260 DestroyWindow(hwnd
);
4264 * 1. Create visible maximized popup window.
4266 trace("calling CreateWindowExA( WS_MAXIMIZE ) for maximized popup window\n");
4267 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP
| WS_MAXIMIZE
| WS_VISIBLE
,
4268 100, 100, 200, 200, 0, 0, 0, NULL
);
4269 ok (hwnd
!= 0, "Failed to create popup window\n");
4270 ok(IsZoomed(hwnd
), "window should be maximized\n");
4271 ok_sequence(WmCreateMaxPopupSeq
, "CreateWindow(WS_MAXIMIZED):popup", FALSE
);
4272 DestroyWindow(hwnd
);
4276 * 1. Create visible popup window.
4279 trace("calling CreateWindowExA( WS_VISIBLE ) for popup window\n");
4280 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP
| WS_VISIBLE
,
4281 100, 100, 200, 200, 0, 0, 0, NULL
);
4282 ok (hwnd
!= 0, "Failed to create popup window\n");
4283 ok(!IsZoomed(hwnd
), "window should NOT be maximized\n");
4284 ok_sequence(WmCreatePopupSeq
, "CreateWindow(WS_VISIBLE):popup", FALSE
);
4286 trace("calling ShowWindow( SW_SHOWMAXIMIZE ) for visible popup window\n");
4287 ShowWindow(hwnd
, SW_SHOWMAXIMIZED
);
4288 ok(IsZoomed(hwnd
), "window should be maximized\n");
4289 ok_sequence(WmShowVisMaxPopupSeq
, "ShowWindow(SW_SHOWMAXIMIZED):popup", FALSE
);
4290 DestroyWindow(hwnd
);
4294 static void test_sys_menu(void)
4300 hwnd
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
4301 100, 100, 200, 200, 0, 0, 0, NULL
);
4302 ok (hwnd
!= 0, "Failed to create overlapped window\n");
4306 /* test existing window without CS_NOCLOSE style */
4307 hmenu
= GetSystemMenu(hwnd
, FALSE
);
4308 ok(hmenu
!= 0, "GetSystemMenu error %d\n", GetLastError());
4310 state
= GetMenuState(hmenu
, SC_CLOSE
, MF_BYCOMMAND
);
4311 ok(state
!= 0xffffffff, "wrong SC_CLOSE state %x\n", state
);
4312 ok(!(state
& (MF_DISABLED
| MF_GRAYED
)), "wrong SC_CLOSE state %x\n", state
);
4314 EnableMenuItem(hmenu
, SC_CLOSE
, MF_BYCOMMAND
| MF_GRAYED
);
4315 ok_sequence(WmEmptySeq
, "WmEnableMenuItem", FALSE
);
4317 state
= GetMenuState(hmenu
, SC_CLOSE
, MF_BYCOMMAND
);
4318 ok(state
!= 0xffffffff, "wrong SC_CLOSE state %x\n", state
);
4319 ok((state
& (MF_DISABLED
| MF_GRAYED
)) == MF_GRAYED
, "wrong SC_CLOSE state %x\n", state
);
4321 EnableMenuItem(hmenu
, SC_CLOSE
, 0);
4322 ok_sequence(WmEmptySeq
, "WmEnableMenuItem", FALSE
);
4324 state
= GetMenuState(hmenu
, SC_CLOSE
, MF_BYCOMMAND
);
4325 ok(state
!= 0xffffffff, "wrong SC_CLOSE state %x\n", state
);
4326 ok(!(state
& (MF_DISABLED
| MF_GRAYED
)), "wrong SC_CLOSE state %x\n", state
);
4328 /* test whether removing WS_SYSMENU destroys a system menu */
4329 SetWindowLongW(hwnd
, GWL_STYLE
, WS_POPUP
);
4330 SetWindowPos(hwnd
, 0, 0, 0, 0, 0, SWP_NOZORDER
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_FRAMECHANGED
);
4332 hmenu
= GetSystemMenu(hwnd
, FALSE
);
4333 ok(hmenu
!= 0, "GetSystemMenu error %d\n", GetLastError());
4335 DestroyWindow(hwnd
);
4337 /* test new window with CS_NOCLOSE style */
4338 hwnd
= CreateWindowExA(0, "NoCloseWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
4339 100, 100, 200, 200, 0, 0, 0, NULL
);
4340 ok (hwnd
!= 0, "Failed to create overlapped window\n");
4342 hmenu
= GetSystemMenu(hwnd
, FALSE
);
4343 ok(hmenu
!= 0, "GetSystemMenu error %d\n", GetLastError());
4345 state
= GetMenuState(hmenu
, SC_CLOSE
, MF_BYCOMMAND
);
4346 ok(state
== 0xffffffff, "wrong SC_CLOSE state %x\n", state
);
4348 DestroyWindow(hwnd
);
4350 /* test new window without WS_SYSMENU style */
4351 hwnd
= CreateWindowExA(0, "NoCloseWindowClass", NULL
, WS_OVERLAPPEDWINDOW
& ~WS_SYSMENU
,
4352 100, 100, 200, 200, 0, 0, 0, NULL
);
4353 ok(hwnd
!= 0, "Failed to create overlapped window\n");
4355 hmenu
= GetSystemMenu(hwnd
, FALSE
);
4356 ok(!hmenu
, "GetSystemMenu error %d\n", GetLastError());
4358 DestroyWindow(hwnd
);
4361 /* For shown WS_OVERLAPPEDWINDOW */
4362 static const struct message WmSetIcon_1
[] = {
4363 { WM_SETICON
, sent
},
4364 { 0x00AE, sent
|defwinproc
|optional
}, /* XP */
4365 { WM_GETTEXT
, sent
|defwinproc
|optional
},
4366 { WM_GETTEXT
, sent
|defwinproc
|optional
}, /* XP sends a duplicate */
4370 /* For WS_POPUP and hidden WS_OVERLAPPEDWINDOW */
4371 static const struct message WmSetIcon_2
[] = {
4372 { WM_SETICON
, sent
},
4376 /* Sending undocumented 0x3B message with wparam = 0x8000000b */
4377 static const struct message WmInitEndSession
[] = {
4379 { WM_QUERYENDSESSION
, sent
|defwinproc
|wparam
|lparam
, 0, ENDSESSION_LOGOFF
},
4383 /* Sending undocumented 0x3B message with wparam = 0x0000000b */
4384 static const struct message WmInitEndSession_2
[] = {
4386 { WM_QUERYENDSESSION
, sent
|defwinproc
|wparam
|lparam
, 0, 0 },
4390 /* Sending undocumented 0x3B message with wparam = 0x80000008 */
4391 static const struct message WmInitEndSession_3
[] = {
4393 { WM_ENDSESSION
, sent
|defwinproc
|wparam
|lparam
, 0, ENDSESSION_LOGOFF
},
4397 /* Sending undocumented 0x3B message with wparam = 0x00000008 */
4398 static const struct message WmInitEndSession_4
[] = {
4400 { WM_ENDSESSION
, sent
|defwinproc
|wparam
|lparam
, 0, 0 },
4404 /* Sending undocumented 0x3B message with wparam = 0x80000001 */
4405 static const struct message WmInitEndSession_5
[] = {
4407 { WM_ENDSESSION
, sent
|defwinproc
/*|wparam*/|lparam
, 1, ENDSESSION_LOGOFF
},
4411 static const struct message WmOptionalPaint
[] = {
4412 { WM_PAINT
, sent
|optional
},
4413 { WM_NCPAINT
, sent
|beginpaint
|optional
},
4414 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
4415 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
4419 static const struct message WmZOrder
[] = {
4420 { WM_WINDOWPOSCHANGING
, sent
|wparam
, 0, 0 },
4421 { WM_GETMINMAXINFO
, sent
|defwinproc
|wparam
, 0, 0 },
4422 { HCBT_ACTIVATE
, hook
},
4423 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
4424 { WM_WINDOWPOSCHANGING
, sent
|wparam
, 3, 0 },
4425 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOREDRAW
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
, 0 },
4426 { WM_GETTEXT
, sent
|optional
},
4427 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
4428 { WM_ACTIVATEAPP
, sent
|wparam
, 1, 0 },
4429 { WM_NCACTIVATE
, sent
|lparam
, 1, 0 },
4430 { WM_GETTEXT
, sent
|defwinproc
|optional
},
4431 { WM_GETTEXT
, sent
|defwinproc
|optional
},
4432 { WM_ACTIVATE
, sent
|wparam
|lparam
, 1, 0 },
4433 { HCBT_SETFOCUS
, hook
},
4434 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
4435 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
4436 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
4437 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
4438 { WM_GETTEXT
, sent
|optional
},
4439 { WM_NCCALCSIZE
, sent
|optional
},
4443 static void CALLBACK
apc_test_proc(ULONG_PTR param
)
4448 static void test_MsgWaitForMultipleObjects(HWND hwnd
)
4453 ret
= MsgWaitForMultipleObjects(0, NULL
, FALSE
, 0, QS_POSTMESSAGE
);
4454 ok(ret
== WAIT_TIMEOUT
, "MsgWaitForMultipleObjects returned %x\n", ret
);
4456 PostMessageA(hwnd
, WM_USER
, 0, 0);
4458 ret
= MsgWaitForMultipleObjects(0, NULL
, FALSE
, 0, QS_POSTMESSAGE
);
4459 ok(ret
== WAIT_OBJECT_0
, "MsgWaitForMultipleObjects returned %x\n", ret
);
4461 ok(PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
), "PeekMessage should succeed\n");
4462 ok(msg
.message
== WM_USER
, "got %04x instead of WM_USER\n", msg
.message
);
4464 ret
= MsgWaitForMultipleObjects(0, NULL
, FALSE
, 0, QS_POSTMESSAGE
);
4465 ok(ret
== WAIT_TIMEOUT
, "MsgWaitForMultipleObjects returned %x\n", ret
);
4467 PostMessageA(hwnd
, WM_USER
, 0, 0);
4469 ret
= MsgWaitForMultipleObjects(0, NULL
, FALSE
, 0, QS_POSTMESSAGE
);
4470 ok(ret
== WAIT_OBJECT_0
, "MsgWaitForMultipleObjects returned %x\n", ret
);
4472 ok(PeekMessageA( &msg
, 0, 0, 0, PM_NOREMOVE
), "PeekMessage should succeed\n");
4473 ok(msg
.message
== WM_USER
, "got %04x instead of WM_USER\n", msg
.message
);
4475 /* shows QS_POSTMESSAGE flag is cleared in the PeekMessage call */
4476 ret
= MsgWaitForMultipleObjects(0, NULL
, FALSE
, 0, QS_POSTMESSAGE
);
4477 ok(ret
== WAIT_TIMEOUT
, "MsgWaitForMultipleObjects returned %x\n", ret
);
4479 PostMessageA(hwnd
, WM_USER
, 0, 0);
4481 /* new incoming message causes it to become signaled again */
4482 ret
= MsgWaitForMultipleObjects(0, NULL
, FALSE
, 0, QS_POSTMESSAGE
);
4483 ok(ret
== WAIT_OBJECT_0
, "MsgWaitForMultipleObjects returned %x\n", ret
);
4485 ok(PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
), "PeekMessage should succeed\n");
4486 ok(msg
.message
== WM_USER
, "got %04x instead of WM_USER\n", msg
.message
);
4487 ok(PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
), "PeekMessage should succeed\n");
4488 ok(msg
.message
== WM_USER
, "got %04x instead of WM_USER\n", msg
.message
);
4490 /* MWMO_INPUTAVAILABLE should succeed even if the message was already seen */
4491 PostMessageA( hwnd
, WM_USER
, 0, 0 );
4492 ok(PeekMessageA( &msg
, 0, 0, 0, PM_NOREMOVE
), "PeekMessage should succeed\n");
4493 ok(msg
.message
== WM_USER
, "got %04x instead of WM_USER\n", msg
.message
);
4495 ret
= MsgWaitForMultipleObjectsEx( 0, NULL
, 0, QS_POSTMESSAGE
, MWMO_INPUTAVAILABLE
);
4496 ok(ret
== WAIT_OBJECT_0
, "MsgWaitForMultipleObjectsEx returned %x\n", ret
);
4498 ok(PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
), "PeekMessage should succeed\n");
4499 ok(msg
.message
== WM_USER
, "got %04x instead of WM_USER\n", msg
.message
);
4501 /* without MWMO_ALERTABLE the result is never WAIT_IO_COMPLETION */
4502 ret
= QueueUserAPC( apc_test_proc
, GetCurrentThread(), 0 );
4503 ok(ret
, "QueueUserAPC failed %u\n", GetLastError());
4505 ret
= MsgWaitForMultipleObjectsEx( 0, NULL
, 0, QS_POSTMESSAGE
, 0 );
4506 ok(ret
== WAIT_TIMEOUT
, "MsgWaitForMultipleObjectsEx returned %x\n", ret
);
4508 /* but even with MWMO_ALERTABLE window events are preferred */
4509 PostMessageA( hwnd
, WM_USER
, 0, 0 );
4511 ret
= MsgWaitForMultipleObjectsEx( 0, NULL
, 0, QS_POSTMESSAGE
, MWMO_ALERTABLE
);
4512 ok(ret
== WAIT_OBJECT_0
, "MsgWaitForMultipleObjectsEx returned %x\n", ret
);
4514 ok(PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
), "PeekMessage should succeed\n");
4515 ok(msg
.message
== WM_USER
, "got %04x instead of WM_USER\n", msg
.message
);
4517 /* the APC call is still queued */
4518 ret
= MsgWaitForMultipleObjectsEx( 0, NULL
, 0, QS_POSTMESSAGE
, MWMO_ALERTABLE
);
4519 ok(ret
== WAIT_IO_COMPLETION
, "MsgWaitForMultipleObjectsEx returned %x\n", ret
);
4522 static DWORD CALLBACK
show_window_thread(LPVOID arg
)
4526 /* function will not return if ShowWindow(SW_HIDE) calls SendMessage() */
4527 ok(ShowWindow(hwnd
, SW_HIDE
) == FALSE
, "ShowWindow(SW_HIDE) expected FALSE\n");
4532 /* test if we receive the right sequence of messages */
4533 static void test_messages(void)
4537 HWND hwnd
, hparent
, hchild
;
4538 HWND hchild2
, hbutton
;
4547 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW
,
4548 100, 100, 200, 200, 0, 0, 0, NULL
);
4549 ok (hwnd
!= 0, "Failed to create overlapped window\n");
4550 ok_sequence(WmCreateOverlappedSeq
, "CreateWindow:overlapped", FALSE
);
4552 /* test ShowWindow(SW_HIDE) on a newly created invisible window */
4553 ok( ShowWindow(hwnd
, SW_HIDE
) == FALSE
, "ShowWindow: window was visible\n" );
4554 ok_sequence(WmEmptySeq
, "ShowWindow(SW_HIDE):overlapped, invisible", FALSE
);
4556 /* test WM_SETREDRAW on a not visible top level window */
4557 test_WM_SETREDRAW(hwnd
);
4559 SetWindowPos(hwnd
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
);
4561 ok_sequence(WmSWP_ShowOverlappedSeq
, "SetWindowPos:SWP_SHOWWINDOW:overlapped", FALSE
);
4562 ok(IsWindowVisible(hwnd
), "window should be visible at this point\n");
4564 ok(GetActiveWindow() == hwnd
, "window should be active\n");
4565 ok(GetFocus() == hwnd
, "window should have input focus\n");
4566 ShowWindow(hwnd
, SW_HIDE
);
4568 ok_sequence(WmHideOverlappedSeq
, "ShowWindow(SW_HIDE):overlapped", FALSE
);
4570 /* test ShowWindow(SW_HIDE) on a hidden window - single threaded */
4571 ok(ShowWindow(hwnd
, SW_HIDE
) == FALSE
, "ShowWindow(SW_HIDE) expected FALSE\n");
4573 ok_sequence(WmEmptySeq
, "ShowWindow(SW_HIDE):overlapped", FALSE
);
4575 /* test ShowWindow(SW_HIDE) on a hidden window - multi-threaded */
4576 hthread
= CreateThread(NULL
, 0, show_window_thread
, hwnd
, 0, &tid
);
4577 ok(hthread
!= NULL
, "CreateThread failed, error %d\n", GetLastError());
4578 ok(WaitForSingleObject(hthread
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
4579 CloseHandle(hthread
);
4581 ok_sequence(WmEmptySeq
, "ShowWindow(SW_HIDE):overlapped", FALSE
);
4583 ShowWindow(hwnd
, SW_SHOW
);
4585 ok_sequence(WmShowOverlappedSeq
, "ShowWindow(SW_SHOW):overlapped", TRUE
);
4587 ShowWindow(hwnd
, SW_HIDE
);
4589 ok_sequence(WmHideOverlappedSeq
, "ShowWindow(SW_HIDE):overlapped", FALSE
);
4591 ShowWindow(hwnd
, SW_SHOWMAXIMIZED
);
4593 ok_sequence(WmShowMaxOverlappedSeq
, "ShowWindow(SW_SHOWMAXIMIZED):overlapped", TRUE
);
4596 if (GetWindowLongW( hwnd
, GWL_STYLE
) & WS_MAXIMIZE
)
4598 ShowWindow(hwnd
, SW_RESTORE
);
4600 ok_sequence(WmShowRestoreMaxOverlappedSeq
, "ShowWindow(SW_RESTORE):overlapped", TRUE
);
4604 ShowWindow(hwnd
, SW_MINIMIZE
);
4606 ok_sequence(WmShowMinOverlappedSeq
, "ShowWindow(SW_SHOWMINIMIZED):overlapped", TRUE
);
4609 if (GetWindowLongW( hwnd
, GWL_STYLE
) & WS_MINIMIZE
)
4611 ShowWindow(hwnd
, SW_RESTORE
);
4613 ok_sequence(WmShowRestoreMinOverlappedSeq
, "ShowWindow(SW_RESTORE):overlapped", TRUE
);
4617 ShowWindow(hwnd
, SW_SHOW
);
4619 ok_sequence(WmOptionalPaint
, "ShowWindow(SW_SHOW):overlapped already visible", FALSE
);
4621 SetWindowPos(hwnd
, 0,0,0,0,0, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
);
4622 ok_sequence(WmSWP_HideOverlappedSeq
, "SetWindowPos:SWP_HIDEWINDOW:overlapped", FALSE
);
4623 ok(!IsWindowVisible(hwnd
), "window should not be visible at this point\n");
4624 ok(GetActiveWindow() == hwnd
, "window should still be active\n");
4626 /* test WM_SETREDRAW on a visible top level window */
4627 ShowWindow(hwnd
, SW_SHOW
);
4629 test_WM_SETREDRAW(hwnd
);
4631 trace("testing scroll APIs on a visible top level window %p\n", hwnd
);
4632 test_scroll_messages(hwnd
);
4634 /* test resizing and moving */
4635 SetWindowPos( hwnd
, 0, 0, 0, 300, 300, SWP_NOMOVE
|SWP_NOACTIVATE
);
4636 ok_sequence(WmSWP_ResizeSeq
, "SetWindowPos:Resize", FALSE
);
4639 SetWindowPos( hwnd
, 0, 200, 200, 0, 0, SWP_NOSIZE
|SWP_NOACTIVATE
);
4640 ok_sequence(WmSWP_MoveSeq
, "SetWindowPos:Move", FALSE
);
4643 SetWindowPos( hwnd
, 0, 200, 200, 250, 250, SWP_NOZORDER
|SWP_NOACTIVATE
);
4644 ok_sequence(WmSWP_ResizeNoZOrder
, "SetWindowPos:WmSWP_ResizeNoZOrder", FALSE
);
4648 /* popups don't get WM_GETMINMAXINFO */
4649 SetWindowLongW( hwnd
, GWL_STYLE
, WS_VISIBLE
|WS_POPUP
);
4650 SetWindowPos( hwnd
, 0, 0, 0, 0, 0, SWP_NOZORDER
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_FRAMECHANGED
);
4652 SetWindowPos( hwnd
, 0, 0, 0, 200, 200, SWP_NOMOVE
|SWP_NOACTIVATE
);
4653 ok_sequence(WmSWP_ResizePopupSeq
, "SetWindowPos:ResizePopup", FALSE
);
4655 DestroyWindow(hwnd
);
4656 ok_sequence(WmDestroyOverlappedSeq
, "DestroyWindow:overlapped", FALSE
);
4658 hparent
= CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
4659 100, 100, 200, 200, 0, 0, 0, NULL
);
4660 ok (hparent
!= 0, "Failed to create parent window\n");
4663 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
| WS_MAXIMIZE
,
4664 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4665 ok (hchild
!= 0, "Failed to create child window\n");
4666 ok_sequence(WmCreateMaximizedChildSeq
, "CreateWindow:maximized child", FALSE
);
4667 DestroyWindow(hchild
);
4670 /* visible child window with a caption */
4671 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child",
4672 WS_CHILD
| WS_VISIBLE
| WS_CAPTION
,
4673 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4674 ok (hchild
!= 0, "Failed to create child window\n");
4675 ok_sequence(WmCreateVisibleChildSeq
, "CreateWindow:visible child", FALSE
);
4677 trace("testing scroll APIs on a visible child window %p\n", hchild
);
4678 test_scroll_messages(hchild
);
4680 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
);
4681 ok_sequence(WmShowChildSeq_4
, "SetWindowPos(SWP_SHOWWINDOW):child with a caption", FALSE
);
4683 DestroyWindow(hchild
);
4686 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
4687 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4688 ok (hchild
!= 0, "Failed to create child window\n");
4689 ok_sequence(WmCreateChildSeq
, "CreateWindow:child", FALSE
);
4691 hchild2
= CreateWindowExA(0, "SimpleWindowClass", "Test child2", WS_CHILD
,
4692 100, 100, 50, 50, hparent
, 0, 0, NULL
);
4693 ok (hchild2
!= 0, "Failed to create child2 window\n");
4696 hbutton
= CreateWindowExA(0, "TestWindowClass", "Test button", WS_CHILD
,
4697 0, 100, 50, 50, hchild
, 0, 0, NULL
);
4698 ok (hbutton
!= 0, "Failed to create button window\n");
4700 /* test WM_SETREDRAW on a not visible child window */
4701 test_WM_SETREDRAW(hchild
);
4703 ShowWindow(hchild
, SW_SHOW
);
4704 ok_sequence(WmShowChildSeq
, "ShowWindow(SW_SHOW):child", FALSE
);
4706 /* check parent messages too */
4707 log_all_parent_messages
++;
4708 ShowWindow(hchild
, SW_HIDE
);
4709 ok_sequence(WmHideChildSeq2
, "ShowWindow(SW_HIDE):child", FALSE
);
4710 log_all_parent_messages
--;
4712 ShowWindow(hchild
, SW_SHOW
);
4713 ok_sequence(WmShowChildSeq
, "ShowWindow(SW_SHOW):child", FALSE
);
4715 ShowWindow(hchild
, SW_HIDE
);
4716 ok_sequence(WmHideChildSeq
, "ShowWindow(SW_HIDE):child", FALSE
);
4718 ShowWindow(hchild
, SW_SHOW
);
4719 ok_sequence(WmShowChildSeq
, "ShowWindow(SW_SHOW):child", FALSE
);
4721 /* test WM_SETREDRAW on a visible child window */
4722 test_WM_SETREDRAW(hchild
);
4724 log_all_parent_messages
++;
4725 MoveWindow(hchild
, 10, 10, 20, 20, TRUE
);
4726 ok_sequence(WmResizingChildWithMoveWindowSeq
, "MoveWindow:child", FALSE
);
4727 log_all_parent_messages
--;
4729 ShowWindow(hchild
, SW_HIDE
);
4731 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
);
4732 ok_sequence(WmShowChildSeq_2
, "SetWindowPos:show_child_2", FALSE
);
4734 ShowWindow(hchild
, SW_HIDE
);
4736 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
);
4737 ok_sequence(WmShowChildSeq_3
, "SetWindowPos:show_child_3", FALSE
);
4739 /* DestroyWindow sequence below expects that a child has focus */
4743 DestroyWindow(hchild
);
4744 ok_sequence(WmDestroyChildSeq
, "DestroyWindow:child", FALSE
);
4745 DestroyWindow(hchild2
);
4746 DestroyWindow(hbutton
);
4749 hchild
= CreateWindowExA(0, "TestWindowClass", "Test Child Popup", WS_CHILD
| WS_POPUP
,
4750 0, 0, 100, 100, hparent
, 0, 0, NULL
);
4751 ok (hchild
!= 0, "Failed to create child popup window\n");
4752 ok_sequence(WmCreateChildPopupSeq
, "CreateWindow:child_popup", FALSE
);
4753 DestroyWindow(hchild
);
4755 /* test what happens to a window which sets WS_VISIBLE in WM_CREATE */
4757 hchild
= CreateWindowExA(0, "TestPopupClass", "Test Popup", WS_POPUP
,
4758 0, 0, 100, 100, hparent
, 0, 0, NULL
);
4759 ok (hchild
!= 0, "Failed to create popup window\n");
4760 ok_sequence(WmCreateInvisiblePopupSeq
, "CreateWindow:invisible_popup", FALSE
);
4761 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
4762 ok(IsWindowVisible(hchild
), "IsWindowVisible() should return TRUE\n");
4764 ShowWindow(hchild
, SW_SHOW
);
4765 ok_sequence(WmEmptySeq
, "ShowWindow:show_visible_popup", FALSE
);
4767 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOZORDER
);
4768 ok_sequence(WmShowVisiblePopupSeq_2
, "SetWindowPos:show_visible_popup_2", FALSE
);
4770 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
);
4771 ok_sequence(WmShowVisiblePopupSeq_3
, "SetWindowPos:show_visible_popup_3", FALSE
);
4772 DestroyWindow(hchild
);
4774 /* this time add WS_VISIBLE for CreateWindowEx, but this fact actually
4775 * changes nothing in message sequences.
4778 hchild
= CreateWindowExA(0, "TestPopupClass", "Test Popup", WS_POPUP
| WS_VISIBLE
,
4779 0, 0, 100, 100, hparent
, 0, 0, NULL
);
4780 ok (hchild
!= 0, "Failed to create popup window\n");
4781 ok_sequence(WmCreateInvisiblePopupSeq
, "CreateWindow:invisible_popup", FALSE
);
4782 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
4783 ok(IsWindowVisible(hchild
), "IsWindowVisible() should return TRUE\n");
4785 ShowWindow(hchild
, SW_SHOW
);
4786 ok_sequence(WmEmptySeq
, "ShowWindow:show_visible_popup", FALSE
);
4788 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOZORDER
);
4789 ok_sequence(WmShowVisiblePopupSeq_2
, "SetWindowPos:show_visible_popup_2", FALSE
);
4790 DestroyWindow(hchild
);
4793 hwnd
= CreateWindowExA(WS_EX_DLGMODALFRAME
, "TestDialogClass", NULL
, WS_VISIBLE
|WS_CAPTION
|WS_SYSMENU
|WS_DLGFRAME
,
4794 0, 0, 100, 100, hparent
, 0, 0, NULL
);
4795 ok(hwnd
!= 0, "Failed to create custom dialog window\n");
4796 ok_sequence(WmCreateCustomDialogSeq
, "CreateCustomDialog", TRUE
);
4799 trace("testing scroll APIs on a visible dialog %p\n", hwnd
);
4800 test_scroll_messages(hwnd
);
4806 SendMessageA(hwnd
, WM_NULL
, 0, 0);
4809 after_end_dialog
= TRUE
;
4810 EndDialog( hwnd
, 0 );
4811 ok_sequence(WmEndCustomDialogSeq
, "EndCustomDialog", FALSE
);
4813 DestroyWindow(hwnd
);
4814 after_end_dialog
= FALSE
;
4815 test_def_id
= FALSE
;
4817 ok(GetCursorPos(&pos
), "GetCursorPos failed\n");
4818 ok(SetCursorPos(109, 109), "SetCursorPos failed\n");
4820 hwnd
= CreateWindowExA(0, "TestDialogClass", NULL
, WS_POPUP
|WS_CHILD
,
4821 0, 0, 100, 100, 0, 0, GetModuleHandleA(0), NULL
);
4822 ok(hwnd
!= 0, "Failed to create custom dialog window\n");
4824 trace("call ShowWindow(%p, SW_SHOW)\n", hwnd
);
4825 ShowWindow(hwnd
, SW_SHOW
);
4826 ok_sequence(WmShowCustomDialogSeq
, "ShowCustomDialog", TRUE
);
4830 ret
= DrawMenuBar(hwnd
);
4831 ok(ret
, "DrawMenuBar failed: %d\n", GetLastError());
4833 ok_sequence(WmDrawMenuBarSeq
, "DrawMenuBar", FALSE
);
4834 ok(SetCursorPos(pos
.x
, pos
.y
), "SetCursorPos failed\n");
4836 DestroyWindow(hwnd
);
4838 hwnd
= CreateWindowExA(0, "TestDialogClass", NULL
, WS_CHILD
|WS_VISIBLE
,
4839 0, 0, 100, 100, hparent
, 0, GetModuleHandleA(0), NULL
);
4840 ok(hwnd
!= 0, "Failed to create custom dialog window\n");
4843 ret
= DrawMenuBar(hwnd
);
4844 ok(ret
, "DrawMenuBar failed: %d\n", GetLastError());
4846 ok_sequence(WmEmptySeq
, "DrawMenuBar for a child window", FALSE
);
4848 DestroyWindow(hwnd
);
4851 DialogBoxA( 0, "TEST_DIALOG", hparent
, TestModalDlgProcA
);
4852 ok_sequence(WmModalDialogSeq
, "ModalDialog", TRUE
);
4854 DestroyWindow(hparent
);
4857 /* Message sequence for SetMenu */
4858 ok(!DrawMenuBar(hwnd
), "DrawMenuBar should return FALSE for a destroyed window\n");
4859 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
, "last error is %d\n", GetLastError());
4860 ok_sequence(WmEmptySeq
, "DrawMenuBar for a window without a menu", FALSE
);
4862 hmenu
= CreateMenu();
4863 ok (hmenu
!= 0, "Failed to create menu\n");
4864 ok (InsertMenuA(hmenu
, -1, MF_BYPOSITION
, 0x1000, "foo"), "InsertMenu failed\n");
4865 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW
,
4866 100, 100, 200, 200, 0, hmenu
, 0, NULL
);
4867 ok_sequence(WmCreateOverlappedSeq
, "CreateWindow:overlapped", FALSE
);
4868 ok (SetMenu(hwnd
, 0), "SetMenu\n");
4869 ok_sequence(WmSetMenuNonVisibleSizeChangeSeq
, "SetMenu:NonVisibleSizeChange", FALSE
);
4870 ok (SetMenu(hwnd
, 0), "SetMenu\n");
4871 ok_sequence(WmSetMenuNonVisibleNoSizeChangeSeq
, "SetMenu:NonVisibleNoSizeChange", FALSE
);
4872 ShowWindow(hwnd
, SW_SHOW
);
4873 UpdateWindow( hwnd
);
4876 ok (SetMenu(hwnd
, 0), "SetMenu\n");
4877 ok_sequence(WmSetMenuVisibleNoSizeChangeSeq
, "SetMenu:VisibleNoSizeChange", FALSE
);
4878 ok (SetMenu(hwnd
, hmenu
), "SetMenu\n");
4879 ok_sequence(WmSetMenuVisibleSizeChangeSeq
, "SetMenu:VisibleSizeChange", FALSE
);
4881 UpdateWindow( hwnd
);
4884 ok(DrawMenuBar(hwnd
), "DrawMenuBar\n");
4886 ok_sequence(WmDrawMenuBarSeq
, "DrawMenuBar", FALSE
);
4888 DestroyWindow(hwnd
);
4891 /* Message sequence for EnableWindow */
4892 hparent
= CreateWindowExA(0, "TestWindowClass", "Test parent", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
4893 100, 100, 200, 200, 0, 0, 0, NULL
);
4894 ok (hparent
!= 0, "Failed to create parent window\n");
4895 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
| WS_VISIBLE
,
4896 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4897 ok (hchild
!= 0, "Failed to create child window\n");
4903 EnableWindow(hparent
, FALSE
);
4904 ok_sequence(WmEnableWindowSeq_1
, "EnableWindow(FALSE)", FALSE
);
4906 EnableWindow(hparent
, TRUE
);
4907 ok_sequence(WmEnableWindowSeq_2
, "EnableWindow(TRUE)", FALSE
);
4912 test_MsgWaitForMultipleObjects(hparent
);
4914 /* the following test causes an exception in user.exe under win9x */
4915 if (!PostMessageW( hparent
, WM_USER
, 0, 0 ))
4917 DestroyWindow(hparent
);
4921 PostMessageW( hparent
, WM_USER
+1, 0, 0 );
4922 /* PeekMessage(NULL) fails, but still removes the message */
4923 SetLastError(0xdeadbeef);
4924 ok( !PeekMessageW( NULL
, 0, 0, 0, PM_REMOVE
), "PeekMessage(NULL) should fail\n" );
4925 ok( GetLastError() == ERROR_NOACCESS
|| /* Win2k */
4926 GetLastError() == 0xdeadbeef, /* NT4 */
4927 "last error is %d\n", GetLastError() );
4928 ok( PeekMessageW( &msg
, 0, 0, 0, PM_REMOVE
), "PeekMessage should succeed\n" );
4929 ok( msg
.message
== WM_USER
+1, "got %x instead of WM_USER+1\n", msg
.message
);
4931 DestroyWindow(hchild
);
4932 DestroyWindow(hparent
);
4935 /* Message sequences for WM_SETICON */
4936 trace("testing WM_SETICON\n");
4937 hwnd
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
4938 CW_USEDEFAULT
, CW_USEDEFAULT
, 300, 300, 0,
4940 ShowWindow(hwnd
, SW_SHOW
);
4944 SendMessageA(hwnd
, WM_SETICON
, ICON_SMALL
, (LPARAM
)LoadIconA(0, (LPCSTR
)IDI_APPLICATION
));
4945 ok_sequence(WmSetIcon_1
, "WM_SETICON for shown window with caption", FALSE
);
4947 ShowWindow(hwnd
, SW_HIDE
);
4950 SendMessageA(hwnd
, WM_SETICON
, ICON_SMALL
, (LPARAM
)LoadIconA(0, (LPCSTR
)IDI_APPLICATION
));
4951 ok_sequence(WmSetIcon_2
, "WM_SETICON for hidden window with caption", FALSE
);
4952 DestroyWindow(hwnd
);
4955 hwnd
= CreateWindowExA(0, "TestPopupClass", NULL
, WS_POPUP
,
4956 CW_USEDEFAULT
, CW_USEDEFAULT
, 300, 300, 0,
4958 ShowWindow(hwnd
, SW_SHOW
);
4962 SendMessageA(hwnd
, WM_SETICON
, ICON_SMALL
, (LPARAM
)LoadIconA(0, (LPCSTR
)IDI_APPLICATION
));
4963 ok_sequence(WmSetIcon_2
, "WM_SETICON for shown window without caption", FALSE
);
4965 ShowWindow(hwnd
, SW_HIDE
);
4968 SendMessageA(hwnd
, WM_SETICON
, ICON_SMALL
, (LPARAM
)LoadIconA(0, (LPCSTR
)IDI_APPLICATION
));
4969 ok_sequence(WmSetIcon_2
, "WM_SETICON for hidden window without caption", FALSE
);
4972 res
= SendMessageA(hwnd
, 0x3B, 0x8000000b, 0);
4975 todo_wine
win_skip( "Message 0x3b not supported\n" );
4978 ok_sequence(WmInitEndSession
, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x8000000b", TRUE
);
4979 ok(res
== 1, "SendMessage(hwnd, 0x3B, 0x8000000b, 0) should have returned 1 instead of %ld\n", res
);
4980 res
= SendMessageA(hwnd
, 0x3B, 0x0000000b, 0);
4981 ok_sequence(WmInitEndSession_2
, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x0000000b", TRUE
);
4982 ok(res
== 1, "SendMessage(hwnd, 0x3B, 0x0000000b, 0) should have returned 1 instead of %ld\n", res
);
4983 res
= SendMessageA(hwnd
, 0x3B, 0x0000000f, 0);
4984 ok_sequence(WmInitEndSession_2
, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x0000000f", TRUE
);
4985 ok(res
== 1, "SendMessage(hwnd, 0x3B, 0x0000000f, 0) should have returned 1 instead of %ld\n", res
);
4988 res
= SendMessageA(hwnd
, 0x3B, 0x80000008, 0);
4989 ok_sequence(WmInitEndSession_3
, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x80000008", TRUE
);
4990 ok(res
== 2, "SendMessage(hwnd, 0x3B, 0x80000008, 0) should have returned 2 instead of %ld\n", res
);
4991 res
= SendMessageA(hwnd
, 0x3B, 0x00000008, 0);
4992 ok_sequence(WmInitEndSession_4
, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x00000008", TRUE
);
4993 ok(res
== 2, "SendMessage(hwnd, 0x3B, 0x00000008, 0) should have returned 2 instead of %ld\n", res
);
4995 res
= SendMessageA(hwnd
, 0x3B, 0x80000004, 0);
4996 ok_sequence(WmInitEndSession_3
, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x80000004", TRUE
);
4997 ok(res
== 2, "SendMessage(hwnd, 0x3B, 0x80000004, 0) should have returned 2 instead of %ld\n", res
);
4999 res
= SendMessageA(hwnd
, 0x3B, 0x80000001, 0);
5000 ok_sequence(WmInitEndSession_5
, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x80000001", TRUE
);
5001 ok(res
== 2, "SendMessage(hwnd, 0x3B, 0x80000001, 0) should have returned 2 instead of %ld\n", res
);
5004 DestroyWindow(hwnd
);
5008 static void test_setwindowpos(void)
5013 const INT winX
= 100;
5014 const INT winY
= 100;
5015 const INT sysX
= GetSystemMetrics(SM_CXMINTRACK
);
5017 hwnd
= CreateWindowExA(0, "TestWindowClass", NULL
, 0,
5018 0, 0, winX
, winY
, 0,
5021 GetWindowRect(hwnd
, &rc
);
5022 expect(sysX
, rc
.right
);
5023 expect(winY
, rc
.bottom
);
5027 res
= SetWindowPos(hwnd
, HWND_TOPMOST
, 0, 0, winX
, winY
, 0);
5028 ok_sequence(WmZOrder
, "Z-Order", TRUE
);
5029 ok(res
== TRUE
, "SetWindowPos expected TRUE, got %ld\n", res
);
5031 GetWindowRect(hwnd
, &rc
);
5032 expect(sysX
, rc
.right
);
5033 expect(winY
, rc
.bottom
);
5034 DestroyWindow(hwnd
);
5037 static void invisible_parent_tests(void)
5039 HWND hparent
, hchild
;
5041 hparent
= CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW
,
5042 100, 100, 200, 200, 0, 0, 0, NULL
);
5043 ok (hparent
!= 0, "Failed to create parent window\n");
5046 /* test showing child with hidden parent */
5048 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
5049 0, 0, 10, 10, hparent
, 0, 0, NULL
);
5050 ok (hchild
!= 0, "Failed to create child window\n");
5051 ok_sequence(WmCreateChildSeq
, "CreateWindow:child", FALSE
);
5053 ShowWindow( hchild
, SW_MINIMIZE
);
5054 ok_sequence(WmShowChildInvisibleParentSeq_1
, "ShowWindow(SW_MINIMIZE) child with invisible parent", FALSE
);
5055 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
5056 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
5061 ShowWindow( hchild
, SW_MINIMIZE
);
5062 ok_sequence(WmShowChildInvisibleParentSeq_1r
, "ShowWindow(SW_MINIMIZE) child with invisible parent", FALSE
);
5064 DestroyWindow(hchild
);
5065 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
5066 0, 0, 10, 10, hparent
, 0, 0, NULL
);
5069 ShowWindow( hchild
, SW_MAXIMIZE
);
5070 ok_sequence(WmShowChildInvisibleParentSeq_2
, "ShowWindow(SW_MAXIMIZE) child with invisible parent", FALSE
);
5071 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
5072 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
5077 ShowWindow( hchild
, SW_MAXIMIZE
);
5078 ok_sequence(WmShowChildInvisibleParentSeq_2r
, "ShowWindow(SW_MAXIMIZE) child with invisible parent", FALSE
);
5080 DestroyWindow(hchild
);
5081 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
5082 0, 0, 10, 10, hparent
, 0, 0, NULL
);
5085 ShowWindow( hchild
, SW_RESTORE
);
5086 ok_sequence(WmShowChildInvisibleParentSeq_5
, "ShowWindow(SW_RESTORE) child with invisible parent", FALSE
);
5087 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
5088 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
5090 DestroyWindow(hchild
);
5091 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
5092 0, 0, 10, 10, hparent
, 0, 0, NULL
);
5095 ShowWindow( hchild
, SW_SHOWMINIMIZED
);
5096 ok_sequence(WmShowChildInvisibleParentSeq_3
, "ShowWindow(SW_SHOWMINIMIZED) child with invisible parent", FALSE
);
5097 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
5098 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
5103 ShowWindow( hchild
, SW_SHOWMINIMIZED
);
5104 ok_sequence(WmShowChildInvisibleParentSeq_3r
, "ShowWindow(SW_SHOWMINIMIZED) child with invisible parent", FALSE
);
5106 DestroyWindow(hchild
);
5107 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
5108 0, 0, 10, 10, hparent
, 0, 0, NULL
);
5111 /* same as ShowWindow( hchild, SW_MAXIMIZE ); */
5112 ShowWindow( hchild
, SW_SHOWMAXIMIZED
);
5113 ok_sequence(WmShowChildInvisibleParentSeq_2
, "ShowWindow(SW_SHOWMAXIMIZED) child with invisible parent", FALSE
);
5114 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
5115 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
5117 DestroyWindow(hchild
);
5118 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
5119 0, 0, 10, 10, hparent
, 0, 0, NULL
);
5122 ShowWindow( hchild
, SW_SHOWMINNOACTIVE
);
5123 ok_sequence(WmShowChildInvisibleParentSeq_4
, "ShowWindow(SW_SHOWMINNOACTIVE) child with invisible parent", FALSE
);
5124 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
5125 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
5130 ShowWindow( hchild
, SW_SHOWMINNOACTIVE
);
5131 ok_sequence(WmShowChildInvisibleParentSeq_4r
, "ShowWindow(SW_SHOWMINNOACTIVE) child with invisible parent", FALSE
);
5133 DestroyWindow(hchild
);
5134 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
5135 0, 0, 10, 10, hparent
, 0, 0, NULL
);
5138 /* FIXME: looks like XP SP2 doesn't know about SW_FORCEMINIMIZE at all */
5139 ShowWindow( hchild
, SW_FORCEMINIMIZE
);
5140 ok_sequence(WmEmptySeq
, "ShowWindow(SW_FORCEMINIMIZE) child with invisible parent", TRUE
);
5142 ok(!(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
), "WS_VISIBLE should be not set\n");
5144 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
5146 DestroyWindow(hchild
);
5147 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
5148 0, 0, 10, 10, hparent
, 0, 0, NULL
);
5151 ShowWindow( hchild
, SW_SHOWNA
);
5152 ok_sequence(WmShowChildInvisibleParentSeq_5
, "ShowWindow(SW_SHOWNA) child with invisible parent", FALSE
);
5153 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
5154 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
5159 ShowWindow( hchild
, SW_SHOWNA
);
5160 ok_sequence(WmShowChildInvisibleParentSeq_5
, "ShowWindow(SW_SHOWNA) child with invisible parent", FALSE
);
5162 DestroyWindow(hchild
);
5163 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
5164 0, 0, 10, 10, hparent
, 0, 0, NULL
);
5167 ShowWindow( hchild
, SW_SHOW
);
5168 ok_sequence(WmShowChildInvisibleParentSeq_5
, "ShowWindow(SW_SHOW) child with invisible parent", FALSE
);
5169 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
5170 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
5175 ShowWindow( hchild
, SW_SHOW
);
5176 ok_sequence(WmEmptySeq
, "ShowWindow(SW_SHOW) child with invisible parent", FALSE
);
5178 ShowWindow( hchild
, SW_HIDE
);
5179 ok_sequence(WmHideChildInvisibleParentSeq
, "ShowWindow:hide child with invisible parent", FALSE
);
5180 ok(!(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
), "WS_VISIBLE should be not set\n");
5181 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
5183 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOZORDER
);
5184 ok_sequence(WmShowChildInvisibleParentSeq_6
, "SetWindowPos:show child with invisible parent", FALSE
);
5185 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
5186 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
5188 SetWindowPos(hchild
, 0,0,0,0,0, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOZORDER
);
5189 ok_sequence(WmHideChildInvisibleParentSeq_2
, "SetWindowPos:hide child with invisible parent", FALSE
);
5190 ok(!(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
), "WS_VISIBLE should not be set\n");
5191 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
5193 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOZORDER
);
5195 DestroyWindow(hchild
);
5196 ok_sequence(WmDestroyInvisibleChildSeq
, "DestroyInvisibleChildSeq", FALSE
);
5198 DestroyWindow(hparent
);
5202 /****************** button message test *************************/
5203 #define ID_BUTTON 0x000e
5205 static const struct message WmSetFocusButtonSeq
[] =
5207 { HCBT_SETFOCUS
, hook
},
5208 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
5209 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
5210 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
5211 { WM_SETFOCUS
, sent
|wparam
, 0 },
5212 { WM_CTLCOLORBTN
, sent
|parent
},
5213 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_BUTTON
, BN_SETFOCUS
) },
5214 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5217 static const struct message WmKillFocusButtonSeq
[] =
5219 { HCBT_SETFOCUS
, hook
},
5220 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
5221 { WM_KILLFOCUS
, sent
|wparam
, 0 },
5222 { WM_CTLCOLORBTN
, sent
|parent
},
5223 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_BUTTON
, BN_KILLFOCUS
) },
5224 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
5225 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 1 },
5226 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5228 { WM_CTLCOLORBTN
, sent
|parent
},
5231 static const struct message WmSetFocusStaticSeq
[] =
5233 { HCBT_SETFOCUS
, hook
},
5234 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
5235 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
5236 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
5237 { WM_SETFOCUS
, sent
|wparam
, 0 },
5238 { WM_CTLCOLORSTATIC
, sent
|parent
},
5239 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_BUTTON
, BN_SETFOCUS
) },
5240 { WM_COMMAND
, sent
|wparam
|parent
|optional
, MAKEWPARAM(ID_BUTTON
, BN_CLICKED
) }, /* radio button */
5241 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5244 static const struct message WmKillFocusStaticSeq
[] =
5246 { HCBT_SETFOCUS
, hook
},
5247 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
5248 { WM_KILLFOCUS
, sent
|wparam
, 0 },
5249 { WM_CTLCOLORSTATIC
, sent
|parent
},
5250 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_BUTTON
, BN_KILLFOCUS
) },
5251 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
5252 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 1 },
5253 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5255 { WM_CTLCOLORSTATIC
, sent
|parent
},
5258 static const struct message WmSetFocusOwnerdrawSeq
[] =
5260 { HCBT_SETFOCUS
, hook
},
5261 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
5262 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
5263 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
5264 { WM_SETFOCUS
, sent
|wparam
, 0 },
5265 { WM_CTLCOLORBTN
, sent
|parent
},
5266 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_BUTTON
, 0x001040e4 },
5267 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_BUTTON
, BN_SETFOCUS
) },
5268 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5271 static const struct message WmKillFocusOwnerdrawSeq
[] =
5273 { HCBT_SETFOCUS
, hook
},
5274 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
5275 { WM_KILLFOCUS
, sent
|wparam
, 0 },
5276 { WM_CTLCOLORBTN
, sent
|parent
},
5277 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_BUTTON
, 0x000040e4 },
5278 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_BUTTON
, BN_KILLFOCUS
) },
5279 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
5280 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 1 },
5281 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5283 { WM_CTLCOLORBTN
, sent
|parent
},
5284 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_BUTTON
, 0x000010e4 },
5287 static const struct message WmLButtonDownSeq
[] =
5289 { WM_LBUTTONDOWN
, sent
|wparam
|lparam
, 0, 0 },
5290 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
5291 { HCBT_SETFOCUS
, hook
},
5292 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
5293 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
5294 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
5295 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
5296 { WM_CTLCOLORBTN
, sent
|defwinproc
},
5297 { BM_SETSTATE
, sent
|wparam
|defwinproc
, TRUE
},
5298 { WM_CTLCOLORBTN
, sent
|defwinproc
},
5299 { EVENT_OBJECT_STATECHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
5302 static const struct message WmLButtonDownStaticSeq
[] =
5304 { WM_LBUTTONDOWN
, sent
|wparam
|lparam
, 0, 0 },
5305 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
5306 { HCBT_SETFOCUS
, hook
},
5307 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
5308 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
5309 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
5310 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
5311 { WM_CTLCOLORSTATIC
, sent
|defwinproc
},
5312 { BM_SETSTATE
, sent
|wparam
|defwinproc
, TRUE
},
5313 { WM_CTLCOLORSTATIC
, sent
|defwinproc
},
5314 { EVENT_OBJECT_STATECHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
5317 static const struct message WmLButtonUpSeq
[] =
5319 { WM_LBUTTONUP
, sent
|wparam
|lparam
, 0, 0 },
5320 { BM_SETSTATE
, sent
|wparam
|defwinproc
, FALSE
},
5321 { WM_CTLCOLORBTN
, sent
|defwinproc
},
5322 { EVENT_OBJECT_STATECHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
5323 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, 0, 0 },
5324 { WM_CAPTURECHANGED
, sent
|wparam
|defwinproc
, 0 },
5327 static const struct message WmLButtonUpStaticSeq
[] =
5329 { WM_LBUTTONUP
, sent
|wparam
|lparam
, 0, 0 },
5330 { BM_SETSTATE
, sent
|wparam
|defwinproc
, FALSE
},
5331 { WM_CTLCOLORSTATIC
, sent
|defwinproc
},
5332 { EVENT_OBJECT_STATECHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
5333 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, 0, 0 },
5334 { WM_CAPTURECHANGED
, sent
|wparam
|defwinproc
, 0 },
5337 static const struct message WmLButtonUpAutoSeq
[] =
5339 { WM_LBUTTONUP
, sent
|wparam
|lparam
, 0, 0 },
5340 { BM_SETSTATE
, sent
|wparam
|defwinproc
, FALSE
},
5341 { WM_CTLCOLORSTATIC
, sent
|defwinproc
},
5342 { EVENT_OBJECT_STATECHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
5343 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, 0, 0 },
5344 { BM_SETCHECK
, sent
|defwinproc
},
5345 { WM_CTLCOLORSTATIC
, sent
|defwinproc
, 0, 0 },
5346 { WM_CAPTURECHANGED
, sent
|wparam
|defwinproc
, 0 },
5349 static const struct message WmLButtonUpBrokenSeq
[] =
5351 { WM_LBUTTONUP
, sent
|wparam
|lparam
, 0, 0 },
5354 static const struct message WmSetFontButtonSeq
[] =
5356 { WM_SETFONT
, sent
},
5358 { WM_ERASEBKGND
, sent
|defwinproc
|optional
},
5359 { WM_CTLCOLORBTN
, sent
|defwinproc
},
5360 { WM_CTLCOLORBTN
, sent
|defwinproc
|optional
}, /* FIXME: Wine sends it twice for BS_OWNERDRAW */
5363 static const struct message WmSetFontStaticSeq
[] =
5365 { WM_SETFONT
, sent
},
5367 { WM_ERASEBKGND
, sent
|defwinproc
|optional
},
5368 { WM_CTLCOLORSTATIC
, sent
|defwinproc
},
5371 static const struct message WmSetStyleButtonSeq
[] =
5373 { BM_SETSTYLE
, sent
},
5374 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5376 { WM_NCPAINT
, sent
|defwinproc
|optional
}, /* FIXME: Wine sends it */
5377 { WM_ERASEBKGND
, sent
|defwinproc
|optional
}, /* Win9x doesn't send it */
5378 { WM_CTLCOLORBTN
, sent
|parent
},
5381 static const struct message WmSetStyleStaticSeq
[] =
5383 { BM_SETSTYLE
, sent
},
5384 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5386 { WM_NCPAINT
, sent
|defwinproc
|optional
}, /* FIXME: Wine sends it */
5387 { WM_ERASEBKGND
, sent
|defwinproc
|optional
}, /* Win9x doesn't send it */
5388 { WM_CTLCOLORSTATIC
, sent
|parent
},
5391 static const struct message WmSetStyleUserSeq
[] =
5393 { BM_SETSTYLE
, sent
},
5394 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5396 { WM_NCPAINT
, sent
|defwinproc
|optional
}, /* FIXME: Wine sends it */
5397 { WM_ERASEBKGND
, sent
|defwinproc
|optional
}, /* Win9x doesn't send it */
5398 { WM_CTLCOLORBTN
, sent
|parent
},
5399 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_BUTTON
, BN_PAINT
) },
5402 static const struct message WmSetStyleOwnerdrawSeq
[] =
5404 { BM_SETSTYLE
, sent
},
5405 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5407 { WM_NCPAINT
, sent
|optional
}, /* FIXME: Wine sends it */
5408 { WM_ERASEBKGND
, sent
|defwinproc
|optional
}, /* Win9x doesn't send it */
5409 { WM_CTLCOLORBTN
, sent
|parent
},
5410 { WM_CTLCOLORBTN
, sent
|parent
|optional
}, /* Win9x doesn't send it */
5411 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_BUTTON
, 0x000010e4 },
5414 static const struct message WmSetStateButtonSeq
[] =
5416 { BM_SETSTATE
, sent
},
5417 { WM_CTLCOLORBTN
, sent
|parent
},
5418 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5421 static const struct message WmSetStateStaticSeq
[] =
5423 { BM_SETSTATE
, sent
},
5424 { WM_CTLCOLORSTATIC
, sent
|parent
},
5425 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5428 static const struct message WmSetStateUserSeq
[] =
5430 { BM_SETSTATE
, sent
},
5431 { WM_CTLCOLORBTN
, sent
|parent
},
5432 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_BUTTON
, BN_HILITE
) },
5433 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5436 static const struct message WmSetStateOwnerdrawSeq
[] =
5438 { BM_SETSTATE
, sent
},
5439 { WM_CTLCOLORBTN
, sent
|parent
},
5440 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_BUTTON
, 0x000120e4 },
5441 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5444 static const struct message WmClearStateButtonSeq
[] =
5446 { BM_SETSTATE
, sent
},
5447 { WM_CTLCOLORBTN
, sent
|parent
},
5448 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_BUTTON
, BN_UNHILITE
) },
5449 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5452 static const struct message WmClearStateOwnerdrawSeq
[] =
5454 { BM_SETSTATE
, sent
},
5455 { WM_CTLCOLORBTN
, sent
|parent
},
5456 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_BUTTON
, 0x000020e4 },
5457 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5460 static const struct message WmSetCheckIgnoredSeq
[] =
5462 { BM_SETCHECK
, sent
},
5463 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5466 static const struct message WmSetCheckStaticSeq
[] =
5468 { BM_SETCHECK
, sent
},
5469 { WM_CTLCOLORSTATIC
, sent
|parent
},
5470 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5474 static WNDPROC old_button_proc
;
5476 static LRESULT CALLBACK
button_hook_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
5478 static LONG defwndproc_counter
= 0;
5480 struct recvd_message msg
;
5482 if (ignore_message( message
)) return 0;
5490 ok(GetCapture() == hwnd
, "GetCapture() = %p\n", GetCapture());
5494 msg
.message
= message
;
5495 msg
.flags
= sent
|wparam
|lparam
;
5496 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
5497 msg
.wParam
= wParam
;
5498 msg
.lParam
= lParam
;
5499 msg
.descr
= "button";
5503 defwndproc_counter
++;
5504 ret
= CallWindowProcA(old_button_proc
, hwnd
, message
, wParam
, lParam
);
5505 defwndproc_counter
--;
5510 static void subclass_button(void)
5514 if (!GetClassInfoA(0, "button", &cls
)) assert(0);
5516 old_button_proc
= cls
.lpfnWndProc
;
5518 cls
.hInstance
= GetModuleHandleA(NULL
);
5519 cls
.lpfnWndProc
= button_hook_proc
;
5520 cls
.lpszClassName
= "my_button_class";
5521 UnregisterClassA(cls
.lpszClassName
, cls
.hInstance
);
5522 if (!RegisterClassA(&cls
)) assert(0);
5525 static void test_button_messages(void)
5531 const struct message
*setfocus
;
5532 const struct message
*killfocus
;
5533 const struct message
*setstyle
;
5534 const struct message
*setstate
;
5535 const struct message
*clearstate
;
5536 const struct message
*setcheck
;
5537 const struct message
*lbuttondown
;
5538 const struct message
*lbuttonup
;
5539 const struct message
*setfont
;
5541 { BS_PUSHBUTTON
, DLGC_BUTTON
| DLGC_UNDEFPUSHBUTTON
,
5542 WmSetFocusButtonSeq
, WmKillFocusButtonSeq
, WmSetStyleButtonSeq
,
5543 WmSetStateButtonSeq
, WmSetStateButtonSeq
, WmSetCheckIgnoredSeq
,
5544 WmLButtonDownSeq
, WmLButtonUpSeq
, WmSetFontButtonSeq
},
5545 { BS_DEFPUSHBUTTON
, DLGC_BUTTON
| DLGC_DEFPUSHBUTTON
,
5546 WmSetFocusButtonSeq
, WmKillFocusButtonSeq
, WmSetStyleButtonSeq
,
5547 WmSetStateButtonSeq
, WmSetStateButtonSeq
, WmSetCheckIgnoredSeq
,
5548 WmLButtonDownSeq
, WmLButtonUpSeq
, WmSetFontButtonSeq
},
5549 { BS_CHECKBOX
, DLGC_BUTTON
,
5550 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
, WmSetStyleStaticSeq
,
5551 WmSetStateStaticSeq
, WmSetStateStaticSeq
, WmSetCheckStaticSeq
,
5552 WmLButtonDownStaticSeq
, WmLButtonUpStaticSeq
, WmSetFontStaticSeq
},
5553 { BS_AUTOCHECKBOX
, DLGC_BUTTON
,
5554 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
, WmSetStyleStaticSeq
,
5555 WmSetStateStaticSeq
, WmSetStateStaticSeq
, WmSetCheckStaticSeq
,
5556 WmLButtonDownStaticSeq
, WmLButtonUpAutoSeq
, WmSetFontStaticSeq
},
5557 { BS_RADIOBUTTON
, DLGC_BUTTON
| DLGC_RADIOBUTTON
,
5558 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
, WmSetStyleStaticSeq
,
5559 WmSetStateStaticSeq
, WmSetStateStaticSeq
, WmSetCheckStaticSeq
,
5560 WmLButtonDownStaticSeq
, WmLButtonUpStaticSeq
, WmSetFontStaticSeq
},
5561 { BS_3STATE
, DLGC_BUTTON
,
5562 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
, WmSetStyleStaticSeq
,
5563 WmSetStateStaticSeq
, WmSetStateStaticSeq
, WmSetCheckStaticSeq
,
5564 WmLButtonDownStaticSeq
, WmLButtonUpStaticSeq
, WmSetFontStaticSeq
},
5565 { BS_AUTO3STATE
, DLGC_BUTTON
,
5566 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
, WmSetStyleStaticSeq
,
5567 WmSetStateStaticSeq
, WmSetStateStaticSeq
, WmSetCheckStaticSeq
,
5568 WmLButtonDownStaticSeq
, WmLButtonUpAutoSeq
, WmSetFontStaticSeq
},
5569 { BS_GROUPBOX
, DLGC_STATIC
,
5570 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
, WmSetStyleStaticSeq
,
5571 WmSetStateStaticSeq
, WmSetStateStaticSeq
, WmSetCheckIgnoredSeq
,
5572 WmLButtonDownStaticSeq
, WmLButtonUpStaticSeq
, WmSetFontStaticSeq
},
5573 { BS_USERBUTTON
, DLGC_BUTTON
| DLGC_UNDEFPUSHBUTTON
,
5574 WmSetFocusButtonSeq
, WmKillFocusButtonSeq
, WmSetStyleUserSeq
,
5575 WmSetStateUserSeq
, WmClearStateButtonSeq
, WmSetCheckIgnoredSeq
,
5576 WmLButtonDownSeq
, WmLButtonUpSeq
, WmSetFontButtonSeq
},
5577 { BS_AUTORADIOBUTTON
, DLGC_BUTTON
| DLGC_RADIOBUTTON
,
5578 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
, WmSetStyleStaticSeq
,
5579 WmSetStateStaticSeq
, WmSetStateStaticSeq
, WmSetCheckStaticSeq
,
5580 NULL
/* avoid infinite loop */, WmLButtonUpBrokenSeq
, WmSetFontStaticSeq
},
5581 { BS_OWNERDRAW
, DLGC_BUTTON
,
5582 WmSetFocusOwnerdrawSeq
, WmKillFocusOwnerdrawSeq
, WmSetStyleOwnerdrawSeq
,
5583 WmSetStateOwnerdrawSeq
, WmClearStateOwnerdrawSeq
, WmSetCheckIgnoredSeq
,
5584 WmLButtonDownSeq
, WmLButtonUpSeq
, WmSetFontButtonSeq
},
5591 /* selection with VK_SPACE should capture button window */
5592 hwnd
= CreateWindowExA(0, "button", "test", BS_CHECKBOX
| WS_VISIBLE
| WS_POPUP
,
5593 0, 0, 50, 14, 0, 0, 0, NULL
);
5594 ok(hwnd
!= 0, "Failed to create button window\n");
5597 SendMessageA(hwnd
, WM_KEYDOWN
, VK_SPACE
, 0);
5598 ok(GetCapture() == hwnd
, "Should be captured on VK_SPACE WM_KEYDOWN\n");
5599 SendMessageA(hwnd
, WM_KEYUP
, VK_SPACE
, 0);
5600 DestroyWindow(hwnd
);
5604 parent
= CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
5605 100, 100, 200, 200, 0, 0, 0, NULL
);
5606 ok(parent
!= 0, "Failed to create parent window\n");
5608 for (i
= 0; i
< sizeof(button
)/sizeof(button
[0]); i
++)
5614 trace("button style %08x\n", button
[i
].style
);
5616 hwnd
= CreateWindowExA(0, "my_button_class", "test", button
[i
].style
| WS_CHILD
| BS_NOTIFY
,
5617 0, 0, 50, 14, parent
, (HMENU
)ID_BUTTON
, 0, NULL
);
5618 ok(hwnd
!= 0, "Failed to create button window\n");
5620 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
5621 style
&= ~(WS_CHILD
| BS_NOTIFY
);
5622 /* XP turns a BS_USERBUTTON into BS_PUSHBUTTON */
5623 if (button
[i
].style
== BS_USERBUTTON
)
5624 ok(style
== BS_PUSHBUTTON
, "expected style BS_PUSHBUTTON got %x\n", style
);
5626 ok(style
== button
[i
].style
, "expected style %x got %x\n", button
[i
].style
, style
);
5628 dlg_code
= SendMessageA(hwnd
, WM_GETDLGCODE
, 0, 0);
5629 ok(dlg_code
== button
[i
].dlg_code
, "%u: wrong dlg_code %08x\n", i
, dlg_code
);
5631 ShowWindow(hwnd
, SW_SHOW
);
5638 log_all_parent_messages
++;
5640 ok(GetFocus() == 0, "expected focus 0, got %p\n", GetFocus());
5642 SendMessageA(hwnd
, WM_APP
, 0, 0); /* place a separator mark here */
5643 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
5644 ok_sequence(button
[i
].setfocus
, "SetFocus(hwnd) on a button", FALSE
);
5647 SendMessageA(hwnd
, WM_APP
, 0, 0); /* place a separator mark here */
5648 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
5649 ok_sequence(button
[i
].killfocus
, "SetFocus(0) on a button", FALSE
);
5651 ok(GetFocus() == 0, "expected focus 0, got %p\n", GetFocus());
5653 SendMessageA(hwnd
, BM_SETSTYLE
, button
[i
].style
| BS_BOTTOM
, TRUE
);
5654 SendMessageA(hwnd
, WM_APP
, 0, 0); /* place a separator mark here */
5655 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
5656 ok_sequence(button
[i
].setstyle
, "BM_SETSTYLE on a button", FALSE
);
5658 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
5659 style
&= ~(WS_VISIBLE
| WS_CHILD
| BS_NOTIFY
);
5660 /* XP doesn't turn a BS_USERBUTTON into BS_PUSHBUTTON here! */
5661 ok(style
== button
[i
].style
, "expected style %04x got %04x\n", button
[i
].style
, style
);
5663 state
= SendMessageA(hwnd
, BM_GETSTATE
, 0, 0);
5664 ok(state
== 0, "expected state 0, got %04x\n", state
);
5668 SendMessageA(hwnd
, BM_SETSTATE
, TRUE
, 0);
5669 SendMessageA(hwnd
, WM_APP
, 0, 0); /* place a separator mark here */
5670 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
5671 ok_sequence(button
[i
].setstate
, "BM_SETSTATE/TRUE on a button", FALSE
);
5673 state
= SendMessageA(hwnd
, BM_GETSTATE
, 0, 0);
5674 ok(state
== 0x0004, "expected state 0x0004, got %04x\n", state
);
5676 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
5677 style
&= ~(WS_CHILD
| BS_NOTIFY
| WS_VISIBLE
);
5678 ok(style
== button
[i
].style
, "expected style %04x got %04x\n", button
[i
].style
, style
);
5682 SendMessageA(hwnd
, BM_SETSTATE
, FALSE
, 0);
5683 SendMessageA(hwnd
, WM_APP
, 0, 0); /* place a separator mark here */
5684 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
5685 ok_sequence(button
[i
].clearstate
, "BM_SETSTATE/FALSE on a button", FALSE
);
5687 state
= SendMessageA(hwnd
, BM_GETSTATE
, 0, 0);
5688 ok(state
== 0, "expected state 0, got %04x\n", state
);
5690 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
5691 style
&= ~(WS_CHILD
| BS_NOTIFY
| WS_VISIBLE
);
5692 ok(style
== button
[i
].style
, "expected style %04x got %04x\n", button
[i
].style
, style
);
5694 state
= SendMessageA(hwnd
, BM_GETCHECK
, 0, 0);
5695 ok(state
== BST_UNCHECKED
, "expected BST_UNCHECKED, got %04x\n", state
);
5699 SendMessageA(hwnd
, BM_SETCHECK
, BST_UNCHECKED
, 0);
5700 SendMessageA(hwnd
, WM_APP
, 0, 0); /* place a separator mark here */
5701 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
5702 ok_sequence(WmSetCheckIgnoredSeq
, "BM_SETCHECK on a button", FALSE
);
5704 state
= SendMessageA(hwnd
, BM_GETCHECK
, 0, 0);
5705 ok(state
== BST_UNCHECKED
, "expected BST_UNCHECKED, got %04x\n", state
);
5707 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
5708 style
&= ~(WS_CHILD
| BS_NOTIFY
| WS_VISIBLE
);
5709 ok(style
== button
[i
].style
, "expected style %04x got %04x\n", button
[i
].style
, style
);
5713 SendMessageA(hwnd
, BM_SETCHECK
, BST_CHECKED
, 0);
5714 SendMessageA(hwnd
, WM_APP
, 0, 0); /* place a separator mark here */
5715 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
5716 ok_sequence(button
[i
].setcheck
, "BM_SETCHECK on a button", FALSE
);
5718 state
= SendMessageA(hwnd
, BM_GETCHECK
, 0, 0);
5719 if (button
[i
].style
== BS_PUSHBUTTON
||
5720 button
[i
].style
== BS_DEFPUSHBUTTON
||
5721 button
[i
].style
== BS_GROUPBOX
||
5722 button
[i
].style
== BS_USERBUTTON
||
5723 button
[i
].style
== BS_OWNERDRAW
)
5724 ok(state
== BST_UNCHECKED
, "expected check 0, got %04x\n", state
);
5726 ok(state
== BST_CHECKED
, "expected check 1, got %04x\n", state
);
5728 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
5729 style
&= ~(WS_CHILD
| BS_NOTIFY
| WS_VISIBLE
);
5730 if (button
[i
].style
== BS_RADIOBUTTON
||
5731 button
[i
].style
== BS_AUTORADIOBUTTON
)
5732 ok(style
== (button
[i
].style
| WS_TABSTOP
), "expected style %04x | WS_TABSTOP got %04x\n", button
[i
].style
, style
);
5734 ok(style
== button
[i
].style
, "expected style %04x got %04x\n", button
[i
].style
, style
);
5736 log_all_parent_messages
--;
5738 DestroyWindow(hwnd
);
5740 hwnd
= CreateWindowExA(0, "my_button_class", "test", button
[i
].style
| WS_POPUP
| WS_VISIBLE
,
5741 0, 0, 50, 14, 0, 0, 0, NULL
);
5742 ok(hwnd
!= 0, "Failed to create button window\n");
5744 SetForegroundWindow(hwnd
);
5747 SetActiveWindow(hwnd
);
5751 if (button
[i
].lbuttondown
)
5753 SendMessageA(hwnd
, WM_LBUTTONDOWN
, 0, 0);
5754 sprintf(desc
, "button[%i]: WM_LBUTTONDOWN on a button", i
);
5755 ok_sequence(button
[i
].lbuttondown
, desc
, FALSE
);
5758 SendMessageA(hwnd
, WM_LBUTTONUP
, 0, 0);
5759 sprintf(desc
, "button[%i]: WM_LBUTTONUP on a button", i
);
5760 ok_sequence(button
[i
].lbuttonup
, desc
, FALSE
);
5763 zfont
= GetStockObject(SYSTEM_FONT
);
5764 SendMessageA(hwnd
, WM_SETFONT
, (WPARAM
)zfont
, TRUE
);
5766 sprintf(desc
, "button[%i]: WM_SETFONT on a button", i
);
5767 ok_sequence(button
[i
].setfont
, desc
, FALSE
);
5769 DestroyWindow(hwnd
);
5772 DestroyWindow(parent
);
5775 /****************** static message test *************************/
5776 static const struct message WmSetFontStaticSeq2
[] =
5778 { WM_SETFONT
, sent
},
5779 { WM_PAINT
, sent
|defwinproc
|optional
},
5780 { WM_ERASEBKGND
, sent
|defwinproc
|optional
},
5781 { WM_CTLCOLORSTATIC
, sent
|defwinproc
|optional
},
5785 static WNDPROC old_static_proc
;
5787 static LRESULT CALLBACK
static_hook_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
5789 static LONG defwndproc_counter
= 0;
5791 struct recvd_message msg
;
5793 if (ignore_message( message
)) return 0;
5796 msg
.message
= message
;
5797 msg
.flags
= sent
|wparam
|lparam
;
5798 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
5799 msg
.wParam
= wParam
;
5800 msg
.lParam
= lParam
;
5801 msg
.descr
= "static";
5804 defwndproc_counter
++;
5805 ret
= CallWindowProcA(old_static_proc
, hwnd
, message
, wParam
, lParam
);
5806 defwndproc_counter
--;
5811 static void subclass_static(void)
5815 if (!GetClassInfoA(0, "static", &cls
)) assert(0);
5817 old_static_proc
= cls
.lpfnWndProc
;
5819 cls
.hInstance
= GetModuleHandleA(NULL
);
5820 cls
.lpfnWndProc
= static_hook_proc
;
5821 cls
.lpszClassName
= "my_static_class";
5822 UnregisterClassA(cls
.lpszClassName
, cls
.hInstance
);
5823 if (!RegisterClassA(&cls
)) assert(0);
5826 static void test_static_messages(void)
5828 /* FIXME: make as comprehensive as the button message test */
5833 const struct message
*setfont
;
5835 { SS_LEFT
, DLGC_STATIC
,
5836 WmSetFontStaticSeq2
}
5844 for (i
= 0; i
< sizeof(static_ctrl
)/sizeof(static_ctrl
[0]); i
++)
5846 hwnd
= CreateWindowExA(0, "my_static_class", "test", static_ctrl
[i
].style
| WS_POPUP
,
5847 0, 0, 50, 14, 0, 0, 0, NULL
);
5848 ok(hwnd
!= 0, "Failed to create static window\n");
5850 dlg_code
= SendMessageA(hwnd
, WM_GETDLGCODE
, 0, 0);
5851 ok(dlg_code
== static_ctrl
[i
].dlg_code
, "%u: wrong dlg_code %08x\n", i
, dlg_code
);
5853 ShowWindow(hwnd
, SW_SHOW
);
5858 trace("static style %08x\n", static_ctrl
[i
].style
);
5859 SendMessageA(hwnd
, WM_SETFONT
, (WPARAM
)GetStockObject(DEFAULT_GUI_FONT
), TRUE
);
5860 ok_sequence(static_ctrl
[i
].setfont
, "WM_SETFONT on a static", FALSE
);
5862 DestroyWindow(hwnd
);
5866 /****************** ComboBox message test *************************/
5867 #define ID_COMBOBOX 0x000f
5869 static const struct message WmKeyDownComboSeq
[] =
5871 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_DOWN
, 0 },
5872 { WM_COMMAND
, sent
|wparam
|defwinproc
, MAKEWPARAM(1000, LBN_SELCHANGE
) },
5873 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_COMBOBOX
, CBN_SELENDOK
) },
5874 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_COMBOBOX
, CBN_SELCHANGE
) },
5875 { WM_CTLCOLOREDIT
, sent
|parent
},
5876 { WM_KEYUP
, sent
|wparam
|lparam
, VK_DOWN
, 0 },
5880 static const struct message WmSetPosComboSeq
[] =
5882 { WM_WINDOWPOSCHANGING
, sent
},
5883 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
5884 { WM_CHILDACTIVATE
, sent
},
5885 { WM_WINDOWPOSCHANGED
, sent
},
5886 { WM_MOVE
, sent
|defwinproc
},
5887 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
5888 { WM_WINDOWPOSCHANGING
, sent
|defwinproc
},
5889 { WM_NCCALCSIZE
, sent
|defwinproc
|wparam
, TRUE
},
5890 { WM_WINDOWPOSCHANGED
, sent
|defwinproc
},
5891 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
5895 static WNDPROC old_combobox_proc
;
5897 static LRESULT CALLBACK
combobox_hook_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
5899 static LONG defwndproc_counter
= 0;
5901 struct recvd_message msg
;
5903 /* do not log painting messages */
5904 if (message
!= WM_PAINT
&&
5905 message
!= WM_NCPAINT
&&
5906 message
!= WM_SYNCPAINT
&&
5907 message
!= WM_ERASEBKGND
&&
5908 message
!= WM_NCHITTEST
&&
5909 message
!= WM_GETTEXT
&&
5910 !ignore_message( message
))
5913 msg
.message
= message
;
5914 msg
.flags
= sent
|wparam
|lparam
;
5915 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
5916 msg
.wParam
= wParam
;
5917 msg
.lParam
= lParam
;
5918 msg
.descr
= "combo";
5922 defwndproc_counter
++;
5923 ret
= CallWindowProcA(old_combobox_proc
, hwnd
, message
, wParam
, lParam
);
5924 defwndproc_counter
--;
5929 static void subclass_combobox(void)
5933 if (!GetClassInfoA(0, "ComboBox", &cls
)) assert(0);
5935 old_combobox_proc
= cls
.lpfnWndProc
;
5937 cls
.hInstance
= GetModuleHandleA(NULL
);
5938 cls
.lpfnWndProc
= combobox_hook_proc
;
5939 cls
.lpszClassName
= "my_combobox_class";
5940 UnregisterClassA(cls
.lpszClassName
, cls
.hInstance
);
5941 if (!RegisterClassA(&cls
)) assert(0);
5944 static void test_combobox_messages(void)
5949 subclass_combobox();
5951 parent
= CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
5952 100, 100, 200, 200, 0, 0, 0, NULL
);
5953 ok(parent
!= 0, "Failed to create parent window\n");
5956 combo
= CreateWindowExA(0, "my_combobox_class", "test", WS_CHILD
| WS_VISIBLE
| CBS_DROPDOWNLIST
| CBS_HASSTRINGS
,
5957 0, 0, 100, 150, parent
, (HMENU
)ID_COMBOBOX
, 0, NULL
);
5958 ok(combo
!= 0, "Failed to create combobox window\n");
5960 UpdateWindow(combo
);
5962 ret
= SendMessageA(combo
, WM_GETDLGCODE
, 0, 0);
5963 ok(ret
== (DLGC_WANTCHARS
| DLGC_WANTARROWS
), "wrong dlg_code %08lx\n", ret
);
5965 ret
= SendMessageA(combo
, CB_ADDSTRING
, 0, (LPARAM
)"item 0");
5966 ok(ret
== 0, "expected 0, got %ld\n", ret
);
5967 ret
= SendMessageA(combo
, CB_ADDSTRING
, 0, (LPARAM
)"item 1");
5968 ok(ret
== 1, "expected 1, got %ld\n", ret
);
5969 ret
= SendMessageA(combo
, CB_ADDSTRING
, 0, (LPARAM
)"item 2");
5970 ok(ret
== 2, "expected 2, got %ld\n", ret
);
5972 SendMessageA(combo
, CB_SETCURSEL
, 0, 0);
5976 log_all_parent_messages
++;
5977 SendMessageA(combo
, WM_KEYDOWN
, VK_DOWN
, 0);
5978 SendMessageA(combo
, WM_KEYUP
, VK_DOWN
, 0);
5979 log_all_parent_messages
--;
5980 ok_sequence(WmKeyDownComboSeq
, "WM_KEYDOWN/VK_DOWN on a ComboBox", FALSE
);
5983 SetWindowPos(combo
, 0, 10, 10, 120, 130, SWP_NOZORDER
);
5984 ok_sequence(WmSetPosComboSeq
, "repositioning messages on a ComboBox", FALSE
);
5986 DestroyWindow(combo
);
5987 DestroyWindow(parent
);
5990 /****************** WM_IME_KEYDOWN message test *******************/
5992 static const struct message WmImeKeydownMsgSeq_0
[] =
5994 { WM_IME_KEYDOWN
, wparam
, VK_RETURN
},
5995 { WM_CHAR
, wparam
, 'A' },
5999 static const struct message WmImeKeydownMsgSeq_1
[] =
6001 { WM_KEYDOWN
, optional
|wparam
, VK_RETURN
},
6002 { WM_CHAR
, optional
|wparam
, VK_RETURN
},
6006 static LRESULT WINAPI
wmime_keydown_procA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
6008 struct recvd_message msg
;
6011 msg
.message
= message
;
6012 msg
.flags
= wparam
|lparam
;
6013 msg
.wParam
= wParam
;
6014 msg
.lParam
= lParam
;
6015 msg
.descr
= "wmime_keydown";
6018 return DefWindowProcA(hwnd
, message
, wParam
, lParam
);
6021 static void register_wmime_keydown_class(void)
6025 ZeroMemory(&cls
, sizeof(WNDCLASSA
));
6026 cls
.lpfnWndProc
= wmime_keydown_procA
;
6027 cls
.hInstance
= GetModuleHandleA(0);
6028 cls
.lpszClassName
= "wmime_keydown_class";
6029 if (!RegisterClassA(&cls
)) assert(0);
6032 static void test_wmime_keydown_message(void)
6037 trace("Message sequences by WM_IME_KEYDOWN\n");
6039 register_wmime_keydown_class();
6040 hwnd
= CreateWindowExA(0, "wmime_keydown_class", NULL
, WS_OVERLAPPEDWINDOW
,
6041 CW_USEDEFAULT
, CW_USEDEFAULT
, 300, 300, 0,
6046 SendMessageA(hwnd
, WM_IME_KEYDOWN
, VK_RETURN
, 0x1c0001);
6047 SendMessageA(hwnd
, WM_CHAR
, 'A', 1);
6048 ok_sequence(WmImeKeydownMsgSeq_0
, "WM_IME_KEYDOWN 0", FALSE
);
6050 while ( PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
) )
6052 TranslateMessage(&msg
);
6053 DispatchMessageA(&msg
);
6055 ok_sequence(WmImeKeydownMsgSeq_1
, "WM_IME_KEYDOWN 1", FALSE
);
6057 DestroyWindow(hwnd
);
6060 /************* painting message test ********************/
6062 void dump_region(HRGN hrgn
)
6065 RGNDATA
*data
= NULL
;
6070 printf( "null region\n" );
6073 if (!(size
= GetRegionData( hrgn
, 0, NULL
))) return;
6074 if (!(data
= HeapAlloc( GetProcessHeap(), 0, size
))) return;
6075 GetRegionData( hrgn
, size
, data
);
6076 printf("%d rects:", data
->rdh
.nCount
);
6077 for (i
= 0, rect
= (RECT
*)data
->Buffer
; i
< data
->rdh
.nCount
; i
++, rect
++)
6078 printf( " (%d,%d)-(%d,%d)", rect
->left
, rect
->top
, rect
->right
, rect
->bottom
);
6080 HeapFree( GetProcessHeap(), 0, data
);
6083 static void check_update_rgn( HWND hwnd
, HRGN hrgn
)
6087 HRGN tmp
= CreateRectRgn( 0, 0, 0, 0 );
6088 HRGN update
= CreateRectRgn( 0, 0, 0, 0 );
6090 ret
= GetUpdateRgn( hwnd
, update
, FALSE
);
6091 ok( ret
!= ERROR
, "GetUpdateRgn failed\n" );
6092 if (ret
== NULLREGION
)
6094 ok( !hrgn
, "Update region shouldn't be empty\n" );
6098 if (CombineRgn( tmp
, hrgn
, update
, RGN_XOR
) != NULLREGION
)
6100 ok( 0, "Regions are different\n" );
6101 if (winetest_debug
> 0)
6103 printf( "Update region: " );
6104 dump_region( update
);
6105 printf( "Wanted region: " );
6106 dump_region( hrgn
);
6110 GetRgnBox( update
, &r1
);
6111 GetUpdateRect( hwnd
, &r2
, FALSE
);
6112 ok( r1
.left
== r2
.left
&& r1
.top
== r2
.top
&& r1
.right
== r2
.right
&& r1
.bottom
== r2
.bottom
,
6113 "Rectangles are different: %d,%d-%d,%d / %d,%d-%d,%d\n",
6114 r1
.left
, r1
.top
, r1
.right
, r1
.bottom
, r2
.left
, r2
.top
, r2
.right
, r2
.bottom
);
6116 DeleteObject( tmp
);
6117 DeleteObject( update
);
6120 static const struct message WmInvalidateRgn
[] = {
6121 { WM_NCPAINT
, sent
},
6122 { WM_GETTEXT
, sent
|defwinproc
|optional
},
6126 static const struct message WmGetUpdateRect
[] = {
6127 { WM_NCPAINT
, sent
},
6128 { WM_GETTEXT
, sent
|defwinproc
|optional
},
6133 static const struct message WmInvalidateFull
[] = {
6134 { WM_NCPAINT
, sent
|wparam
, 1 },
6135 { WM_GETTEXT
, sent
|defwinproc
|optional
},
6139 static const struct message WmInvalidateErase
[] = {
6140 { WM_NCPAINT
, sent
|wparam
, 1 },
6141 { WM_GETTEXT
, sent
|defwinproc
|optional
},
6142 { WM_ERASEBKGND
, sent
},
6146 static const struct message WmInvalidatePaint
[] = {
6148 { WM_NCPAINT
, sent
|wparam
|beginpaint
, 1 },
6149 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
6153 static const struct message WmInvalidateErasePaint
[] = {
6155 { WM_NCPAINT
, sent
|wparam
|beginpaint
, 1 },
6156 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
6157 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
6161 static const struct message WmInvalidateErasePaint2
[] = {
6163 { WM_NCPAINT
, sent
|beginpaint
},
6164 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
6165 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
6169 static const struct message WmErase
[] = {
6170 { WM_ERASEBKGND
, sent
},
6174 static const struct message WmPaint
[] = {
6179 static const struct message WmParentOnlyPaint
[] = {
6180 { WM_PAINT
, sent
|parent
},
6184 static const struct message WmInvalidateParent
[] = {
6185 { WM_NCPAINT
, sent
|parent
},
6186 { WM_GETTEXT
, sent
|defwinproc
|parent
|optional
},
6187 { WM_ERASEBKGND
, sent
|parent
},
6191 static const struct message WmInvalidateParentChild
[] = {
6192 { WM_NCPAINT
, sent
|parent
},
6193 { WM_GETTEXT
, sent
|defwinproc
|parent
|optional
},
6194 { WM_ERASEBKGND
, sent
|parent
},
6195 { WM_NCPAINT
, sent
},
6196 { WM_GETTEXT
, sent
|defwinproc
|optional
},
6197 { WM_ERASEBKGND
, sent
},
6201 static const struct message WmInvalidateParentChild2
[] = {
6202 { WM_ERASEBKGND
, sent
|parent
},
6203 { WM_NCPAINT
, sent
},
6204 { WM_GETTEXT
, sent
|defwinproc
|optional
},
6205 { WM_ERASEBKGND
, sent
},
6209 static const struct message WmParentPaint
[] = {
6210 { WM_PAINT
, sent
|parent
},
6215 static const struct message WmParentPaintNc
[] = {
6216 { WM_PAINT
, sent
|parent
},
6218 { WM_NCPAINT
, sent
|beginpaint
},
6219 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
6220 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
6224 static const struct message WmChildPaintNc
[] = {
6226 { WM_NCPAINT
, sent
|beginpaint
},
6227 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
6228 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
6232 static const struct message WmParentErasePaint
[] = {
6233 { WM_PAINT
, sent
|parent
},
6234 { WM_NCPAINT
, sent
|parent
|beginpaint
},
6235 { WM_GETTEXT
, sent
|parent
|beginpaint
|defwinproc
|optional
},
6236 { WM_ERASEBKGND
, sent
|parent
|beginpaint
|optional
},
6238 { WM_NCPAINT
, sent
|beginpaint
},
6239 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
6240 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
6244 static const struct message WmParentOnlyNcPaint
[] = {
6245 { WM_PAINT
, sent
|parent
},
6246 { WM_NCPAINT
, sent
|parent
|beginpaint
},
6247 { WM_GETTEXT
, sent
|parent
|beginpaint
|defwinproc
|optional
},
6251 static const struct message WmSetParentStyle
[] = {
6252 { WM_STYLECHANGING
, sent
|parent
},
6253 { WM_STYLECHANGED
, sent
|parent
},
6257 static void test_paint_messages(void)
6263 HWND hparent
, hchild
;
6264 HRGN hrgn
= CreateRectRgn( 0, 0, 0, 0 );
6265 HRGN hrgn2
= CreateRectRgn( 0, 0, 0, 0 );
6266 HWND hwnd
= CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW
,
6267 100, 100, 200, 200, 0, 0, 0, NULL
);
6268 ok (hwnd
!= 0, "Failed to create overlapped window\n");
6270 ShowWindow( hwnd
, SW_SHOW
);
6271 UpdateWindow( hwnd
);
6275 check_update_rgn( hwnd
, 0 );
6276 SetRectRgn( hrgn
, 10, 10, 20, 20 );
6277 ret
= RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
);
6278 ok(ret
, "RedrawWindow returned %d instead of TRUE\n", ret
);
6279 check_update_rgn( hwnd
, hrgn
);
6280 SetRectRgn( hrgn2
, 20, 20, 30, 30 );
6281 ret
= RedrawWindow( hwnd
, NULL
, hrgn2
, RDW_INVALIDATE
);
6282 ok(ret
, "RedrawWindow returned %d instead of TRUE\n", ret
);
6283 CombineRgn( hrgn
, hrgn
, hrgn2
, RGN_OR
);
6284 check_update_rgn( hwnd
, hrgn
);
6285 /* validate everything */
6286 ret
= RedrawWindow( hwnd
, NULL
, NULL
, RDW_VALIDATE
);
6287 ok(ret
, "RedrawWindow returned %d instead of TRUE\n", ret
);
6288 check_update_rgn( hwnd
, 0 );
6290 /* test empty region */
6291 SetRectRgn( hrgn
, 10, 10, 10, 15 );
6292 ret
= RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
);
6293 ok(ret
, "RedrawWindow returned %d instead of TRUE\n", ret
);
6294 check_update_rgn( hwnd
, 0 );
6295 /* test empty rect */
6296 SetRect( &rect
, 10, 10, 10, 15 );
6297 ret
= RedrawWindow( hwnd
, &rect
, NULL
, RDW_INVALIDATE
);
6298 ok(ret
, "RedrawWindow returned %d instead of TRUE\n", ret
);
6299 check_update_rgn( hwnd
, 0 );
6301 /* flush pending messages */
6305 GetClientRect( hwnd
, &rect
);
6306 SetRectRgn( hrgn
, 0, 0, rect
.right
- rect
.left
, rect
.bottom
- rect
.top
);
6307 /* MSDN: if hwnd parameter is NULL, InvalidateRect invalidates and redraws
6308 * all windows and sends WM_ERASEBKGND and WM_NCPAINT.
6310 trace("testing InvalidateRect(0, NULL, FALSE)\n");
6311 SetRectEmpty( &rect
);
6312 ok(InvalidateRect(0, &rect
, FALSE
), "InvalidateRect(0, &rc, FALSE) should fail\n");
6313 check_update_rgn( hwnd
, hrgn
);
6314 ok_sequence( WmInvalidateErase
, "InvalidateErase", FALSE
);
6316 ok_sequence( WmPaint
, "Paint", FALSE
);
6317 RedrawWindow( hwnd
, NULL
, NULL
, RDW_VALIDATE
);
6318 check_update_rgn( hwnd
, 0 );
6320 /* MSDN: if hwnd parameter is NULL, ValidateRect invalidates and redraws
6321 * all windows and sends WM_ERASEBKGND and WM_NCPAINT.
6323 trace("testing ValidateRect(0, NULL)\n");
6324 SetRectEmpty( &rect
);
6325 if (ValidateRect(0, &rect
)) /* not supported on Win9x */
6327 check_update_rgn( hwnd
, hrgn
);
6328 ok_sequence( WmInvalidateErase
, "InvalidateErase", FALSE
);
6330 ok_sequence( WmPaint
, "Paint", FALSE
);
6331 RedrawWindow( hwnd
, NULL
, NULL
, RDW_VALIDATE
);
6332 check_update_rgn( hwnd
, 0 );
6335 trace("testing InvalidateRgn(0, NULL, FALSE)\n");
6336 SetLastError(0xdeadbeef);
6337 ok(!InvalidateRgn(0, NULL
, FALSE
), "InvalidateRgn(0, NULL, FALSE) should fail\n");
6338 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
|| GetLastError() == 0xdeadbeef,
6339 "wrong error code %d\n", GetLastError());
6340 check_update_rgn( hwnd
, 0 );
6342 ok_sequence( WmEmptySeq
, "WmEmptySeq", FALSE
);
6344 trace("testing ValidateRgn(0, NULL)\n");
6345 SetLastError(0xdeadbeef);
6346 ok(!ValidateRgn(0, NULL
), "ValidateRgn(0, NULL) should fail\n");
6347 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
||
6348 broken( GetLastError() == 0xdeadbeef ) /* win9x */,
6349 "wrong error code %d\n", GetLastError());
6350 check_update_rgn( hwnd
, 0 );
6352 ok_sequence( WmEmptySeq
, "WmEmptySeq", FALSE
);
6354 trace("testing UpdateWindow(NULL)\n");
6355 SetLastError(0xdeadbeef);
6356 ok(!UpdateWindow(NULL
), "UpdateWindow(NULL) should fail\n");
6357 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
||
6358 broken( GetLastError() == 0xdeadbeef ) /* win9x */,
6359 "wrong error code %d\n", GetLastError());
6360 check_update_rgn( hwnd
, 0 );
6362 ok_sequence( WmEmptySeq
, "WmEmptySeq", FALSE
);
6364 /* now with frame */
6365 SetRectRgn( hrgn
, -5, -5, 20, 20 );
6367 /* flush pending messages */
6370 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_FRAME
);
6371 ok_sequence( WmEmptySeq
, "EmptySeq", FALSE
);
6373 SetRectRgn( hrgn
, 0, 0, 20, 20 ); /* GetUpdateRgn clips to client area */
6374 check_update_rgn( hwnd
, hrgn
);
6377 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASENOW
);
6378 ok_sequence( WmInvalidateRgn
, "InvalidateRgn", FALSE
);
6381 RedrawWindow( hwnd
, NULL
, NULL
, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASENOW
);
6382 ok_sequence( WmInvalidateFull
, "InvalidateFull", FALSE
);
6384 GetClientRect( hwnd
, &rect
);
6385 SetRectRgn( hrgn
, rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
6386 check_update_rgn( hwnd
, hrgn
);
6389 RedrawWindow( hwnd
, NULL
, NULL
, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASE
| RDW_ERASENOW
);
6390 ok_sequence( WmInvalidateErase
, "InvalidateErase", FALSE
);
6393 RedrawWindow( hwnd
, NULL
, NULL
, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASENOW
| RDW_UPDATENOW
);
6394 ok_sequence( WmInvalidatePaint
, "InvalidatePaint", FALSE
);
6395 check_update_rgn( hwnd
, 0 );
6398 RedrawWindow( hwnd
, NULL
, NULL
, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASE
| RDW_UPDATENOW
);
6399 ok_sequence( WmInvalidateErasePaint
, "InvalidateErasePaint", FALSE
);
6400 check_update_rgn( hwnd
, 0 );
6403 SetRectRgn( hrgn
, 0, 0, 100, 100 );
6404 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
);
6405 SetRectRgn( hrgn
, 0, 0, 50, 100 );
6406 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_VALIDATE
);
6407 SetRectRgn( hrgn
, 50, 0, 100, 100 );
6408 check_update_rgn( hwnd
, hrgn
);
6409 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_VALIDATE
| RDW_ERASENOW
);
6410 ok_sequence( WmEmptySeq
, "EmptySeq", FALSE
); /* must not generate messages, everything is valid */
6411 check_update_rgn( hwnd
, 0 );
6414 SetRectRgn( hrgn
, 0, 0, 100, 100 );
6415 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_ERASE
);
6416 SetRectRgn( hrgn
, 0, 0, 100, 50 );
6417 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_VALIDATE
| RDW_ERASENOW
);
6418 ok_sequence( WmErase
, "Erase", FALSE
);
6419 SetRectRgn( hrgn
, 0, 50, 100, 100 );
6420 check_update_rgn( hwnd
, hrgn
);
6423 SetRectRgn( hrgn
, 0, 0, 100, 100 );
6424 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_ERASE
);
6425 SetRectRgn( hrgn
, 0, 0, 50, 50 );
6426 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_VALIDATE
| RDW_NOERASE
| RDW_UPDATENOW
);
6427 ok_sequence( WmPaint
, "Paint", FALSE
);
6430 SetRectRgn( hrgn
, -4, -4, -2, -2 );
6431 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_FRAME
);
6432 SetRectRgn( hrgn
, -200, -200, -198, -198 );
6433 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_VALIDATE
| RDW_NOFRAME
| RDW_ERASENOW
);
6434 ok_sequence( WmEmptySeq
, "EmptySeq", FALSE
);
6437 SetRectRgn( hrgn
, -4, -4, -2, -2 );
6438 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_FRAME
);
6439 SetRectRgn( hrgn
, -4, -4, -3, -3 );
6440 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_VALIDATE
| RDW_NOFRAME
);
6441 SetRectRgn( hrgn
, 0, 0, 1, 1 );
6442 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_UPDATENOW
);
6443 ok_sequence( WmPaint
, "Paint", FALSE
);
6446 SetRectRgn( hrgn
, -4, -4, -1, -1 );
6447 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_FRAME
);
6448 RedrawWindow( hwnd
, NULL
, 0, RDW_ERASENOW
);
6449 /* make sure no WM_PAINT was generated */
6451 ok_sequence( WmInvalidateRgn
, "InvalidateRgn", FALSE
);
6454 SetRectRgn( hrgn
, -4, -4, -1, -1 );
6455 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_FRAME
);
6456 while (PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
))
6458 if (msg
.hwnd
== hwnd
&& msg
.message
== WM_PAINT
)
6460 /* GetUpdateRgn must return empty region since only nonclient area is invalidated */
6461 INT ret
= GetUpdateRgn( hwnd
, hrgn
, FALSE
);
6462 ok( ret
== NULLREGION
, "Invalid GetUpdateRgn result %d\n", ret
);
6463 ret
= GetUpdateRect( hwnd
, &rect
, FALSE
);
6464 ok( ret
, "Invalid GetUpdateRect result %d\n", ret
);
6465 /* this will send WM_NCPAINT and validate the non client area */
6466 ret
= GetUpdateRect( hwnd
, &rect
, TRUE
);
6467 ok( !ret
, "Invalid GetUpdateRect result %d\n", ret
);
6469 DispatchMessageA( &msg
);
6471 ok_sequence( WmGetUpdateRect
, "GetUpdateRect", FALSE
);
6473 DestroyWindow( hwnd
);
6475 /* now test with a child window */
6477 hparent
= CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW
,
6478 100, 100, 200, 200, 0, 0, 0, NULL
);
6479 ok (hparent
!= 0, "Failed to create parent window\n");
6481 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
| WS_VISIBLE
| WS_BORDER
,
6482 10, 10, 100, 100, hparent
, 0, 0, NULL
);
6483 ok (hchild
!= 0, "Failed to create child window\n");
6485 ShowWindow( hparent
, SW_SHOW
);
6486 UpdateWindow( hparent
);
6487 UpdateWindow( hchild
);
6490 log_all_parent_messages
++;
6492 SetRect( &rect
, 0, 0, 50, 50 );
6493 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
6494 RedrawWindow( hparent
, NULL
, 0, RDW_ERASENOW
| RDW_ALLCHILDREN
);
6495 ok_sequence( WmInvalidateParentChild
, "InvalidateParentChild", FALSE
);
6497 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
6499 MapWindowPoints( hchild
, hparent
, &pt
, 1 );
6500 SetRectRgn( hrgn
, 0, 0, 50 - pt
.x
, 50 - pt
.y
);
6501 check_update_rgn( hchild
, hrgn
);
6502 SetRectRgn( hrgn
, 0, 0, 50, 50 );
6503 check_update_rgn( hparent
, hrgn
);
6504 RedrawWindow( hparent
, NULL
, 0, RDW_ERASENOW
);
6505 ok_sequence( WmInvalidateParent
, "InvalidateParent", FALSE
);
6506 RedrawWindow( hchild
, NULL
, 0, RDW_ERASENOW
);
6507 ok_sequence( WmEmptySeq
, "EraseNow child", FALSE
);
6510 ok_sequence( WmParentPaintNc
, "WmParentPaintNc", FALSE
);
6512 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
| RDW_ALLCHILDREN
);
6513 RedrawWindow( hparent
, NULL
, 0, RDW_ERASENOW
);
6514 ok_sequence( WmInvalidateParent
, "InvalidateParent2", FALSE
);
6515 RedrawWindow( hchild
, NULL
, 0, RDW_ERASENOW
);
6516 ok_sequence( WmEmptySeq
, "EraseNow child", FALSE
);
6518 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
);
6519 RedrawWindow( hparent
, NULL
, 0, RDW_ERASENOW
| RDW_ALLCHILDREN
);
6520 ok_sequence( WmInvalidateParentChild2
, "InvalidateParentChild2", FALSE
);
6522 SetWindowLongA( hparent
, GWL_STYLE
, GetWindowLongA(hparent
,GWL_STYLE
) | WS_CLIPCHILDREN
);
6524 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
| RDW_ALLCHILDREN
);
6525 RedrawWindow( hparent
, NULL
, 0, RDW_ERASENOW
);
6526 ok_sequence( WmInvalidateParentChild
, "InvalidateParentChild3", FALSE
);
6528 /* flush all paint messages */
6532 /* RDW_UPDATENOW on child with WS_CLIPCHILDREN doesn't change corresponding parent area */
6533 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
| RDW_ALLCHILDREN
);
6534 SetRectRgn( hrgn
, 0, 0, 50, 50 );
6535 check_update_rgn( hparent
, hrgn
);
6536 RedrawWindow( hchild
, NULL
, 0, RDW_UPDATENOW
);
6537 ok_sequence( WmInvalidateErasePaint2
, "WmInvalidateErasePaint2", FALSE
);
6538 SetRectRgn( hrgn
, 0, 0, 50, 50 );
6539 check_update_rgn( hparent
, hrgn
);
6541 /* flush all paint messages */
6543 SetWindowLongA( hparent
, GWL_STYLE
, GetWindowLongA(hparent
,GWL_STYLE
) & ~WS_CLIPCHILDREN
);
6546 /* RDW_UPDATENOW on child without WS_CLIPCHILDREN will validate corresponding parent area */
6547 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
6548 SetRectRgn( hrgn
, 0, 0, 50, 50 );
6549 check_update_rgn( hparent
, hrgn
);
6550 RedrawWindow( hchild
, NULL
, 0, RDW_UPDATENOW
);
6551 ok_sequence( WmInvalidateErasePaint2
, "WmInvalidateErasePaint2", FALSE
);
6552 SetRectRgn( hrgn2
, 10, 10, 50, 50 );
6553 CombineRgn( hrgn
, hrgn
, hrgn2
, RGN_DIFF
);
6554 check_update_rgn( hparent
, hrgn
);
6555 /* flush all paint messages */
6559 /* same as above but parent gets completely validated */
6560 SetRect( &rect
, 20, 20, 30, 30 );
6561 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
6562 SetRectRgn( hrgn
, 20, 20, 30, 30 );
6563 check_update_rgn( hparent
, hrgn
);
6564 RedrawWindow( hchild
, NULL
, 0, RDW_UPDATENOW
);
6565 ok_sequence( WmInvalidateErasePaint2
, "WmInvalidateErasePaint2", FALSE
);
6566 check_update_rgn( hparent
, 0 ); /* no update region */
6568 ok_sequence( WmEmptySeq
, "WmEmpty", FALSE
); /* and no paint messages */
6570 /* make sure RDW_VALIDATE on child doesn't have the same effect */
6572 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
6573 SetRectRgn( hrgn
, 20, 20, 30, 30 );
6574 check_update_rgn( hparent
, hrgn
);
6575 RedrawWindow( hchild
, NULL
, 0, RDW_VALIDATE
| RDW_NOERASE
);
6576 SetRectRgn( hrgn
, 20, 20, 30, 30 );
6577 check_update_rgn( hparent
, hrgn
);
6579 /* same as above but normal WM_PAINT doesn't validate parent */
6581 SetRect( &rect
, 20, 20, 30, 30 );
6582 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
6583 SetRectRgn( hrgn
, 20, 20, 30, 30 );
6584 check_update_rgn( hparent
, hrgn
);
6585 /* no WM_PAINT in child while parent still pending */
6586 while (PeekMessageA( &msg
, hchild
, 0, 0, PM_REMOVE
)) DispatchMessageA( &msg
);
6587 ok_sequence( WmEmptySeq
, "No WM_PAINT", FALSE
);
6588 while (PeekMessageA( &msg
, hparent
, 0, 0, PM_REMOVE
)) DispatchMessageA( &msg
);
6589 ok_sequence( WmParentErasePaint
, "WmParentErasePaint", FALSE
);
6592 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
6593 /* no WM_PAINT in child while parent still pending */
6594 while (PeekMessageA( &msg
, hchild
, 0, 0, PM_REMOVE
)) DispatchMessageA( &msg
);
6595 ok_sequence( WmEmptySeq
, "No WM_PAINT", FALSE
);
6596 RedrawWindow( hparent
, &rect
, 0, RDW_VALIDATE
| RDW_NOERASE
| RDW_NOCHILDREN
);
6597 /* now that parent is valid child should get WM_PAINT */
6598 while (PeekMessageA( &msg
, hchild
, 0, 0, PM_REMOVE
)) DispatchMessageA( &msg
);
6599 ok_sequence( WmInvalidateErasePaint2
, "WmInvalidateErasePaint2", FALSE
);
6600 while (PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA( &msg
);
6601 ok_sequence( WmEmptySeq
, "No other message", FALSE
);
6603 /* same thing with WS_CLIPCHILDREN in parent */
6605 SetWindowLongA( hparent
, GWL_STYLE
, GetWindowLongA(hparent
,GWL_STYLE
) | WS_CLIPCHILDREN
);
6606 ok_sequence( WmSetParentStyle
, "WmSetParentStyle", FALSE
);
6607 /* changing style invalidates non client area, but we need to invalidate something else to see it */
6608 RedrawWindow( hparent
, &rect
, 0, RDW_UPDATENOW
);
6609 ok_sequence( WmEmptySeq
, "No message", FALSE
);
6610 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_UPDATENOW
);
6611 ok_sequence( WmParentOnlyNcPaint
, "WmParentOnlyNcPaint", FALSE
);
6614 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_ALLCHILDREN
);
6615 SetRectRgn( hrgn
, 20, 20, 30, 30 );
6616 check_update_rgn( hparent
, hrgn
);
6617 /* no WM_PAINT in child while parent still pending */
6618 while (PeekMessageA( &msg
, hchild
, 0, 0, PM_REMOVE
)) DispatchMessageA( &msg
);
6619 ok_sequence( WmEmptySeq
, "No WM_PAINT", FALSE
);
6620 /* WM_PAINT in parent first */
6621 while (PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA( &msg
);
6622 ok_sequence( WmParentPaintNc
, "WmParentPaintNc2", FALSE
);
6624 /* no RDW_ERASE in parent still causes RDW_ERASE and RDW_FRAME in child */
6626 SetRect( &rect
, 0, 0, 30, 30 );
6627 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ALLCHILDREN
);
6628 SetRectRgn( hrgn
, 0, 0, 30, 30 );
6629 check_update_rgn( hparent
, hrgn
);
6631 ok_sequence( WmParentPaintNc
, "WmParentPaintNc3", FALSE
);
6633 /* validate doesn't cause RDW_NOERASE or RDW_NOFRAME in child */
6635 SetRect( &rect
, -10, 0, 30, 30 );
6636 RedrawWindow( hchild
, &rect
, 0, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASE
);
6637 SetRect( &rect
, 0, 0, 20, 20 );
6638 RedrawWindow( hparent
, &rect
, 0, RDW_VALIDATE
| RDW_ALLCHILDREN
);
6639 RedrawWindow( hparent
, NULL
, 0, RDW_UPDATENOW
);
6640 ok_sequence( WmChildPaintNc
, "WmChildPaintNc", FALSE
);
6642 /* validate doesn't cause RDW_NOERASE or RDW_NOFRAME in child */
6644 SetRect( &rect
, -10, 0, 30, 30 );
6645 RedrawWindow( hchild
, &rect
, 0, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASE
);
6646 SetRect( &rect
, 0, 0, 100, 100 );
6647 RedrawWindow( hparent
, &rect
, 0, RDW_VALIDATE
| RDW_ALLCHILDREN
);
6648 RedrawWindow( hparent
, NULL
, 0, RDW_UPDATENOW
);
6649 ok_sequence( WmEmptySeq
, "WmChildPaintNc2", FALSE
);
6650 RedrawWindow( hparent
, NULL
, 0, RDW_ERASENOW
);
6651 ok_sequence( WmEmptySeq
, "WmChildPaintNc3", FALSE
);
6653 /* WS_CLIPCHILDREN doesn't exclude children from update region */
6655 RedrawWindow( hparent
, NULL
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_NOCHILDREN
);
6656 GetClientRect( hparent
, &rect
);
6657 SetRectRgn( hrgn
, rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
6658 check_update_rgn( hparent
, hrgn
);
6661 RedrawWindow( hparent
, NULL
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_ALLCHILDREN
);
6662 GetClientRect( hparent
, &rect
);
6663 SetRectRgn( hrgn
, rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
6664 check_update_rgn( hparent
, hrgn
);
6667 /* test RDW_INTERNALPAINT behavior */
6670 RedrawWindow( hparent
, NULL
, 0, RDW_INTERNALPAINT
| RDW_NOCHILDREN
);
6672 ok_sequence( WmParentOnlyPaint
, "WmParentOnlyPaint", FALSE
);
6674 RedrawWindow( hparent
, NULL
, 0, RDW_INTERNALPAINT
| RDW_ALLCHILDREN
);
6676 ok_sequence( WmParentPaint
, "WmParentPaint", FALSE
);
6678 RedrawWindow( hparent
, NULL
, 0, RDW_INTERNALPAINT
);
6680 ok_sequence( WmParentOnlyPaint
, "WmParentOnlyPaint", FALSE
);
6682 assert( GetWindowLongA(hparent
, GWL_STYLE
) & WS_CLIPCHILDREN
);
6683 UpdateWindow( hparent
);
6686 trace("testing SWP_FRAMECHANGED on parent with WS_CLIPCHILDREN\n");
6687 RedrawWindow( hchild
, NULL
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
6688 SetWindowPos( hparent
, 0, 0, 0, 0, 0, SWP_NOSIZE
| SWP_NOMOVE
|
6689 SWP_NOACTIVATE
| SWP_NOZORDER
| SWP_FRAMECHANGED
);
6691 ok_sequence(WmSWP_FrameChanged_clip
, "SetWindowPos:FrameChanged_clip", FALSE
);
6693 UpdateWindow( hparent
);
6696 trace("testing SWP_FRAMECHANGED|SWP_DEFERERASE on parent with WS_CLIPCHILDREN\n");
6697 RedrawWindow( hchild
, NULL
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
6698 SetWindowPos( hparent
, 0, 0, 0, 0, 0, SWP_NOSIZE
| SWP_NOMOVE
| SWP_DEFERERASE
|
6699 SWP_NOACTIVATE
| SWP_NOZORDER
| SWP_FRAMECHANGED
);
6701 ok_sequence(WmSWP_FrameChangedDeferErase
, "SetWindowPos:FrameChangedDeferErase", FALSE
);
6703 SetWindowLongA( hparent
, GWL_STYLE
, GetWindowLongA(hparent
,GWL_STYLE
) & ~WS_CLIPCHILDREN
);
6704 ok_sequence( WmSetParentStyle
, "WmSetParentStyle", FALSE
);
6705 RedrawWindow( hparent
, NULL
, 0, RDW_INTERNALPAINT
);
6707 ok_sequence( WmParentPaint
, "WmParentPaint", FALSE
);
6709 assert( !(GetWindowLongA(hparent
, GWL_STYLE
) & WS_CLIPCHILDREN
) );
6710 UpdateWindow( hparent
);
6713 trace("testing SWP_FRAMECHANGED on parent without WS_CLIPCHILDREN\n");
6714 RedrawWindow( hchild
, NULL
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
6715 SetWindowPos( hparent
, 0, 0, 0, 0, 0, SWP_NOSIZE
| SWP_NOMOVE
|
6716 SWP_NOACTIVATE
| SWP_NOZORDER
| SWP_FRAMECHANGED
);
6718 ok_sequence(WmSWP_FrameChanged_noclip
, "SetWindowPos:FrameChanged_noclip", FALSE
);
6720 UpdateWindow( hparent
);
6723 trace("testing SWP_FRAMECHANGED|SWP_DEFERERASE on parent without WS_CLIPCHILDREN\n");
6724 RedrawWindow( hchild
, NULL
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
6725 SetWindowPos( hparent
, 0, 0, 0, 0, 0, SWP_NOSIZE
| SWP_NOMOVE
| SWP_DEFERERASE
|
6726 SWP_NOACTIVATE
| SWP_NOZORDER
| SWP_FRAMECHANGED
);
6728 ok_sequence(WmSWP_FrameChangedDeferErase
, "SetWindowPos:FrameChangedDeferErase", FALSE
);
6730 ok(GetWindowLongA( hparent
, GWL_STYLE
) & WS_VISIBLE
, "parent should be visible\n");
6731 ok(GetWindowLongA( hchild
, GWL_STYLE
) & WS_VISIBLE
, "child should be visible\n");
6733 UpdateWindow( hparent
);
6736 trace("testing SetWindowPos(-10000, -10000) on child\n");
6737 SetWindowPos( hchild
, 0, -10000, -10000, 0, 0, SWP_NOSIZE
| SWP_NOACTIVATE
| SWP_NOZORDER
);
6738 check_update_rgn( hchild
, 0 );
6741 #if 0 /* this one doesn't pass under Wine yet */
6742 UpdateWindow( hparent
);
6745 trace("testing ShowWindow(SW_MINIMIZE) on child\n");
6746 ShowWindow( hchild
, SW_MINIMIZE
);
6747 check_update_rgn( hchild
, 0 );
6751 UpdateWindow( hparent
);
6754 trace("testing SetWindowPos(-10000, -10000) on parent\n");
6755 SetWindowPos( hparent
, 0, -10000, -10000, 0, 0, SWP_NOSIZE
| SWP_NOACTIVATE
| SWP_NOZORDER
);
6756 check_update_rgn( hparent
, 0 );
6759 log_all_parent_messages
--;
6760 DestroyWindow( hparent
);
6761 ok(!IsWindow(hchild
), "child must be destroyed with its parent\n");
6763 /* tests for moving windows off-screen (needs simple WS_POPUP windows) */
6765 hparent
= CreateWindowExA(0, "TestParentClass", "Test parent", WS_POPUP
| WS_VISIBLE
,
6766 100, 100, 200, 200, 0, 0, 0, NULL
);
6767 ok (hparent
!= 0, "Failed to create parent window\n");
6769 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
| WS_VISIBLE
,
6770 10, 10, 100, 100, hparent
, 0, 0, NULL
);
6771 ok (hchild
!= 0, "Failed to create child window\n");
6773 ShowWindow( hparent
, SW_SHOW
);
6774 UpdateWindow( hparent
);
6775 UpdateWindow( hchild
);
6779 /* moving child outside of parent boundaries changes update region */
6780 SetRect( &rect
, 0, 0, 40, 40 );
6781 RedrawWindow( hchild
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
);
6782 SetRectRgn( hrgn
, 0, 0, 40, 40 );
6783 check_update_rgn( hchild
, hrgn
);
6784 MoveWindow( hchild
, -10, 10, 100, 100, FALSE
);
6785 SetRectRgn( hrgn
, 10, 0, 40, 40 );
6786 check_update_rgn( hchild
, hrgn
);
6787 MoveWindow( hchild
, -10, -10, 100, 100, FALSE
);
6788 SetRectRgn( hrgn
, 10, 10, 40, 40 );
6789 check_update_rgn( hchild
, hrgn
);
6791 /* moving parent off-screen does too */
6792 SetRect( &rect
, 0, 0, 100, 100 );
6793 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_NOCHILDREN
);
6794 SetRectRgn( hrgn
, 0, 0, 100, 100 );
6795 check_update_rgn( hparent
, hrgn
);
6796 SetRectRgn( hrgn
, 10, 10, 40, 40 );
6797 check_update_rgn( hchild
, hrgn
);
6798 MoveWindow( hparent
, -20, -20, 200, 200, FALSE
);
6799 SetRectRgn( hrgn
, 20, 20, 100, 100 );
6800 check_update_rgn( hparent
, hrgn
);
6801 SetRectRgn( hrgn
, 30, 30, 40, 40 );
6802 check_update_rgn( hchild
, hrgn
);
6804 /* invalidated region is cropped by the parent rects */
6805 SetRect( &rect
, 0, 0, 50, 50 );
6806 RedrawWindow( hchild
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
);
6807 SetRectRgn( hrgn
, 30, 30, 50, 50 );
6808 check_update_rgn( hchild
, hrgn
);
6810 DestroyWindow( hparent
);
6811 ok(!IsWindow(hchild
), "child must be destroyed with its parent\n");
6814 DeleteObject( hrgn
);
6815 DeleteObject( hrgn2
);
6826 static DWORD WINAPI
thread_proc(void *param
)
6829 struct wnd_event
*wnd_event
= param
;
6831 wnd_event
->hwnd
= CreateWindowExA(0, "TestWindowClass", "window caption text", WS_OVERLAPPEDWINDOW
,
6832 100, 100, 200, 200, 0, 0, 0, NULL
);
6833 ok(wnd_event
->hwnd
!= 0, "Failed to create overlapped window\n");
6835 SetEvent(wnd_event
->start_event
);
6837 while (GetMessageA(&msg
, 0, 0, 0))
6839 TranslateMessage(&msg
);
6840 DispatchMessageA(&msg
);
6843 ok(IsWindow(wnd_event
->hwnd
), "window should still exist\n");
6848 static DWORD CALLBACK
create_grand_child_thread( void *param
)
6850 struct wnd_event
*wnd_event
= param
;
6854 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child",
6855 WS_CHILD
| WS_VISIBLE
, 0, 0, 10, 10, wnd_event
->hwnd
, 0, 0, NULL
);
6856 ok (hchild
!= 0, "Failed to create child window\n");
6859 SetEvent( wnd_event
->start_event
);
6863 MsgWaitForMultipleObjects(0, NULL
, FALSE
, 1000, QS_ALLINPUT
);
6864 if (!IsWindow( hchild
)) break; /* will be destroyed when parent thread exits */
6865 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
6870 static DWORD CALLBACK
create_child_thread( void *param
)
6872 struct wnd_event
*wnd_event
= param
;
6873 struct wnd_event child_event
;
6877 child_event
.hwnd
= CreateWindowExA(0, "TestWindowClass", "Test child",
6878 WS_CHILD
| WS_VISIBLE
, 0, 0, 10, 10, wnd_event
->hwnd
, 0, 0, NULL
);
6879 ok (child_event
.hwnd
!= 0, "Failed to create child window\n");
6880 SetFocus( child_event
.hwnd
);
6883 child_event
.start_event
= wnd_event
->start_event
;
6884 wnd_event
->grand_child
= CreateThread(NULL
, 0, create_grand_child_thread
, &child_event
, 0, &tid
);
6887 DWORD ret
= MsgWaitForMultipleObjects(1, &child_event
.start_event
, FALSE
, 1000, QS_SENDMESSAGE
);
6888 if (ret
!= 1) break;
6889 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
6891 ret
= WaitForSingleObject( wnd_event
->stop_event
, 5000 );
6892 ok( !ret
, "WaitForSingleObject failed %x\n", ret
);
6896 static const char manifest_dep
[] =
6897 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
6898 "<assemblyIdentity version=\"1.2.3.4\" name=\"testdep1\" type=\"win32\" processorArchitecture=\"" ARCH
"\"/>"
6899 " <file name=\"testdep.dll\" />"
6902 static const char manifest_main
[] =
6903 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
6904 "<assemblyIdentity version=\"1.2.3.4\" name=\"Wine.Test\" type=\"win32\" />"
6906 " <dependentAssembly>"
6907 " <assemblyIdentity type=\"win32\" name=\"testdep1\" version=\"1.2.3.4\" processorArchitecture=\"" ARCH
"\" />"
6908 " </dependentAssembly>"
6912 static void create_manifest_file(const char *filename
, const char *manifest
)
6914 WCHAR path
[MAX_PATH
];
6918 MultiByteToWideChar( CP_ACP
, 0, filename
, -1, path
, MAX_PATH
);
6919 file
= CreateFileW(path
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
, FILE_ATTRIBUTE_NORMAL
, NULL
);
6920 ok(file
!= INVALID_HANDLE_VALUE
, "CreateFile failed: %u\n", GetLastError());
6921 WriteFile(file
, manifest
, strlen(manifest
), &size
, NULL
);
6925 static HANDLE
test_create(const char *file
)
6927 WCHAR path
[MAX_PATH
];
6931 MultiByteToWideChar(CP_ACP
, 0, file
, -1, path
, MAX_PATH
);
6932 memset(&actctx
, 0, sizeof(ACTCTXW
));
6933 actctx
.cbSize
= sizeof(ACTCTXW
);
6934 actctx
.lpSource
= path
;
6936 handle
= pCreateActCtxW(&actctx
);
6937 ok(handle
!= INVALID_HANDLE_VALUE
, "failed to create context, error %u\n", GetLastError());
6939 ok(actctx
.cbSize
== sizeof(actctx
), "cbSize=%d\n", actctx
.cbSize
);
6940 ok(actctx
.dwFlags
== 0, "dwFlags=%d\n", actctx
.dwFlags
);
6941 ok(actctx
.lpSource
== path
, "lpSource=%p\n", actctx
.lpSource
);
6942 ok(actctx
.wProcessorArchitecture
== 0, "wProcessorArchitecture=%d\n", actctx
.wProcessorArchitecture
);
6943 ok(actctx
.wLangId
== 0, "wLangId=%d\n", actctx
.wLangId
);
6944 ok(actctx
.lpAssemblyDirectory
== NULL
, "lpAssemblyDirectory=%p\n", actctx
.lpAssemblyDirectory
);
6945 ok(actctx
.lpResourceName
== NULL
, "lpResourceName=%p\n", actctx
.lpResourceName
);
6946 ok(actctx
.lpApplicationName
== NULL
, "lpApplicationName=%p\n", actctx
.lpApplicationName
);
6947 ok(actctx
.hModule
== NULL
, "hModule=%p\n", actctx
.hModule
);
6952 static void test_interthread_messages(void)
6954 HANDLE hThread
, context
, handle
, event
;
6960 int len
, expected_len
;
6961 struct wnd_event wnd_event
;
6964 wnd_event
.start_event
= CreateEventW(NULL
, 0, 0, NULL
);
6965 if (!wnd_event
.start_event
)
6967 win_skip("skipping interthread message test under win9x\n");
6971 hThread
= CreateThread(NULL
, 0, thread_proc
, &wnd_event
, 0, &tid
);
6972 ok(hThread
!= NULL
, "CreateThread failed, error %d\n", GetLastError());
6974 ok(WaitForSingleObject(wnd_event
.start_event
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
6976 CloseHandle(wnd_event
.start_event
);
6978 SetLastError(0xdeadbeef);
6979 ok(!DestroyWindow(wnd_event
.hwnd
), "DestroyWindow succeeded\n");
6980 ok(GetLastError() == ERROR_ACCESS_DENIED
|| GetLastError() == 0xdeadbeef,
6981 "wrong error code %d\n", GetLastError());
6983 proc
= (WNDPROC
)GetWindowLongPtrA(wnd_event
.hwnd
, GWLP_WNDPROC
);
6984 ok(proc
!= NULL
, "GetWindowLongPtrA(GWLP_WNDPROC) error %d\n", GetLastError());
6986 expected_len
= lstrlenA("window caption text");
6987 memset(buf
, 0, sizeof(buf
));
6988 SetLastError(0xdeadbeef);
6989 len
= CallWindowProcA(proc
, wnd_event
.hwnd
, WM_GETTEXT
, sizeof(buf
), (LPARAM
)buf
);
6990 ok(len
== expected_len
, "CallWindowProcA(WM_GETTEXT) error %d, len %d, expected len %d\n", GetLastError(), len
, expected_len
);
6991 ok(!lstrcmpA(buf
, "window caption text"), "window text mismatch\n");
6993 msg
.hwnd
= wnd_event
.hwnd
;
6994 msg
.message
= WM_GETTEXT
;
6995 msg
.wParam
= sizeof(buf
);
6996 msg
.lParam
= (LPARAM
)buf
;
6997 memset(buf
, 0, sizeof(buf
));
6998 SetLastError(0xdeadbeef);
6999 len
= DispatchMessageA(&msg
);
7000 ok((!len
&& GetLastError() == ERROR_MESSAGE_SYNC_ONLY
) || broken(len
), /* nt4 */
7001 "DispatchMessageA(WM_GETTEXT) succeeded on another thread window: ret %d, error %d\n", len
, GetLastError());
7003 /* the following test causes an exception in user.exe under win9x */
7004 msg
.hwnd
= wnd_event
.hwnd
;
7005 msg
.message
= WM_TIMER
;
7007 msg
.lParam
= GetWindowLongPtrA(wnd_event
.hwnd
, GWLP_WNDPROC
);
7008 SetLastError(0xdeadbeef);
7009 len
= DispatchMessageA(&msg
);
7010 ok(!len
&& GetLastError() == 0xdeadbeef,
7011 "DispatchMessageA(WM_TIMER) failed on another thread window: ret %d, error %d\n", len
, GetLastError());
7013 ret
= PostMessageA(wnd_event
.hwnd
, WM_QUIT
, 0, 0);
7014 ok( ret
, "PostMessageA(WM_QUIT) error %d\n", GetLastError());
7016 ok(WaitForSingleObject(hThread
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
7017 CloseHandle(hThread
);
7019 ok(!IsWindow(wnd_event
.hwnd
), "window should be destroyed on thread exit\n");
7021 wnd_event
.hwnd
= CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
7022 100, 100, 200, 200, 0, 0, 0, NULL
);
7023 ok (wnd_event
.hwnd
!= 0, "Failed to create parent window\n");
7026 log_all_parent_messages
++;
7027 wnd_event
.start_event
= CreateEventA( NULL
, TRUE
, FALSE
, NULL
);
7028 wnd_event
.stop_event
= CreateEventA( NULL
, TRUE
, FALSE
, NULL
);
7029 hThread
= CreateThread( NULL
, 0, create_child_thread
, &wnd_event
, 0, &tid
);
7032 ret
= MsgWaitForMultipleObjects(1, &wnd_event
.start_event
, FALSE
, 1000, QS_SENDMESSAGE
);
7033 if (ret
!= 1) break;
7034 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
7036 ok( !ret
, "MsgWaitForMultipleObjects failed %x\n", ret
);
7037 /* now wait for the thread without processing messages; this shouldn't deadlock */
7038 SetEvent( wnd_event
.stop_event
);
7039 ret
= WaitForSingleObject( hThread
, 5000 );
7040 ok( !ret
, "WaitForSingleObject failed %x\n", ret
);
7041 CloseHandle( hThread
);
7043 ret
= WaitForSingleObject( wnd_event
.grand_child
, 5000 );
7044 ok( !ret
, "WaitForSingleObject failed %x\n", ret
);
7045 CloseHandle( wnd_event
.grand_child
);
7047 CloseHandle( wnd_event
.start_event
);
7048 CloseHandle( wnd_event
.stop_event
);
7050 ok_sequence(WmExitThreadSeq
, "destroy child on thread exit", FALSE
);
7051 log_all_parent_messages
--;
7052 DestroyWindow( wnd_event
.hwnd
);
7054 /* activation context tests */
7055 if (!pActivateActCtx
)
7057 win_skip("Activation contexts are not supported, skipping\n");
7061 create_manifest_file("testdep1.manifest", manifest_dep
);
7062 create_manifest_file("main.manifest", manifest_main
);
7064 context
= test_create("main.manifest");
7065 DeleteFileA("testdep1.manifest");
7066 DeleteFileA("main.manifest");
7068 handle
= (void*)0xdeadbeef;
7069 ret
= pGetCurrentActCtx(&handle
);
7070 ok(ret
, "GetCurentActCtx failed: %u\n", GetLastError());
7071 ok(handle
== 0, "active context %p\n", handle
);
7073 wnd_event
.start_event
= CreateEventW(NULL
, 0, 0, NULL
);
7074 hThread
= CreateThread(NULL
, 0, thread_proc
, &wnd_event
, 0, &tid
);
7075 ok(hThread
!= NULL
, "CreateThread failed, error %d\n", GetLastError());
7076 ok(WaitForSingleObject(wnd_event
.start_event
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
7077 CloseHandle(wnd_event
.start_event
);
7079 /* context is activated after thread creation, so it doesn't inherit it by default */
7080 ret
= pActivateActCtx(context
, &cookie
);
7081 ok(ret
, "activation failed: %u\n", GetLastError());
7084 ret
= pGetCurrentActCtx(&handle
);
7085 ok(ret
, "GetCurentActCtx failed: %u\n", GetLastError());
7086 ok(handle
!= 0, "active context %p\n", handle
);
7087 pReleaseActCtx(handle
);
7089 /* destination window will test for active context */
7090 ret
= SendMessageA(wnd_event
.hwnd
, WM_USER
+10, 0, 0);
7091 ok(ret
, "thread window returned %d\n", ret
);
7093 event
= CreateEventW(NULL
, 0, 0, NULL
);
7094 ret
= PostMessageA(wnd_event
.hwnd
, WM_USER
+10, 0, (LPARAM
)event
);
7095 ok(ret
, "thread window returned %d\n", ret
);
7096 ok(WaitForSingleObject(event
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
7099 ret
= PostMessageA(wnd_event
.hwnd
, WM_QUIT
, 0, 0);
7100 ok(ret
, "PostMessageA(WM_QUIT) error %d\n", GetLastError());
7102 ok(WaitForSingleObject(hThread
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
7103 CloseHandle(hThread
);
7105 ret
= pDeactivateActCtx(0, cookie
);
7106 ok(ret
, "DeactivateActCtx failed: %u\n", GetLastError());
7107 pReleaseActCtx(context
);
7111 static const struct message WmVkN
[] = {
7112 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 1 }, /* XP */
7113 { WM_KEYDOWN
, wparam
|lparam
, 'N', 1 },
7114 { WM_KEYDOWN
, sent
|wparam
|lparam
, 'N', 1 },
7115 { WM_CHAR
, wparam
|lparam
, 'n', 1 },
7116 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1002,1), 0 },
7117 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xc0000001 }, /* XP */
7118 { WM_KEYUP
, wparam
|lparam
, 'N', 0xc0000001 },
7119 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xc0000001 },
7122 static const struct message WmShiftVkN
[] = {
7123 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 1 }, /* XP */
7124 { WM_KEYDOWN
, wparam
|lparam
, VK_SHIFT
, 1 },
7125 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_SHIFT
, 1 },
7126 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 1 }, /* XP */
7127 { WM_KEYDOWN
, wparam
|lparam
, 'N', 1 },
7128 { WM_KEYDOWN
, sent
|wparam
|lparam
, 'N', 1 },
7129 { WM_CHAR
, wparam
|lparam
, 'N', 1 },
7130 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1001,1), 0 },
7131 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xc0000001 }, /* XP */
7132 { WM_KEYUP
, wparam
|lparam
, 'N', 0xc0000001 },
7133 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xc0000001 },
7134 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 0xc0000001 }, /* XP */
7135 { WM_KEYUP
, wparam
|lparam
, VK_SHIFT
, 0xc0000001 },
7136 { WM_KEYUP
, sent
|wparam
|lparam
, VK_SHIFT
, 0xc0000001 },
7139 static const struct message WmCtrlVkN
[] = {
7140 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 1 }, /* XP */
7141 { WM_KEYDOWN
, wparam
|lparam
, VK_CONTROL
, 1 },
7142 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_CONTROL
, 1 },
7143 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 1 }, /* XP */
7144 { WM_KEYDOWN
, wparam
|lparam
, 'N', 1 },
7145 { WM_KEYDOWN
, sent
|wparam
|lparam
, 'N', 1 },
7146 { WM_CHAR
, wparam
|lparam
, 0x000e, 1 },
7147 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1000,1), 0 },
7148 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xc0000001 }, /* XP */
7149 { WM_KEYUP
, wparam
|lparam
, 'N', 0xc0000001 },
7150 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xc0000001 },
7151 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 0xc0000001 }, /* XP */
7152 { WM_KEYUP
, wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
7153 { WM_KEYUP
, sent
|wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
7156 static const struct message WmCtrlVkN_2
[] = {
7157 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 1 }, /* XP */
7158 { WM_KEYDOWN
, wparam
|lparam
, VK_CONTROL
, 1 },
7159 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_CONTROL
, 1 },
7160 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 1 }, /* XP */
7161 { WM_KEYDOWN
, wparam
|lparam
, 'N', 1 },
7162 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1000,1), 0 },
7163 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xc0000001 }, /* XP */
7164 { WM_KEYUP
, wparam
|lparam
, 'N', 0xc0000001 },
7165 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xc0000001 },
7166 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 0xc0000001 }, /* XP */
7167 { WM_KEYUP
, wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
7168 { WM_KEYUP
, sent
|wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
7171 static const struct message WmAltVkN
[] = {
7172 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 }, /* XP */
7173 { WM_SYSKEYDOWN
, wparam
|lparam
, VK_MENU
, 0x20000001 },
7174 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
7175 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0x20000001 }, /* XP */
7176 { WM_SYSKEYDOWN
, wparam
|lparam
, 'N', 0x20000001 },
7177 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, 'N', 0x20000001 },
7178 { WM_SYSCHAR
, wparam
|lparam
, 'n', 0x20000001 },
7179 { WM_SYSCHAR
, sent
|wparam
|lparam
, 'n', 0x20000001 },
7180 { WM_SYSCOMMAND
, sent
|defwinproc
|wparam
|lparam
, SC_KEYMENU
, 'n' },
7181 { HCBT_SYSCOMMAND
, hook
},
7182 { WM_ENTERMENULOOP
, sent
|defwinproc
|wparam
|lparam
, 0, 0 },
7183 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
7184 { 0x00AE, sent
|defwinproc
|optional
}, /* XP */
7185 { WM_GETTEXT
, sent
|defwinproc
|optional
}, /* XP */
7186 { WM_INITMENU
, sent
|defwinproc
},
7187 { EVENT_SYSTEM_MENUSTART
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 0 },
7188 { WM_MENUCHAR
, sent
|defwinproc
|wparam
, MAKEWPARAM('n',MF_SYSMENU
) },
7189 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, 0, 0 },
7190 { WM_CAPTURECHANGED
, sent
|defwinproc
},
7191 { WM_MENUSELECT
, sent
|defwinproc
|wparam
, MAKEWPARAM(0,0xffff) },
7192 { EVENT_SYSTEM_MENUEND
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 0 },
7193 { WM_EXITMENULOOP
, sent
|defwinproc
},
7194 { WM_MENUSELECT
, sent
|defwinproc
|wparam
|optional
, MAKEWPARAM(0,0xffff) }, /* Win95 bug */
7195 { WM_EXITMENULOOP
, sent
|defwinproc
|optional
}, /* Win95 bug */
7196 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xe0000001 }, /* XP */
7197 { WM_SYSKEYUP
, wparam
|lparam
, 'N', 0xe0000001 },
7198 { WM_SYSKEYUP
, sent
|wparam
|lparam
, 'N', 0xe0000001 },
7199 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xc0000001 }, /* XP */
7200 { WM_KEYUP
, wparam
|lparam
, VK_MENU
, 0xc0000001 },
7201 { WM_KEYUP
, sent
|wparam
|lparam
, VK_MENU
, 0xc0000001 },
7204 static const struct message WmAltVkN_2
[] = {
7205 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 }, /* XP */
7206 { WM_SYSKEYDOWN
, wparam
|lparam
, VK_MENU
, 0x20000001 },
7207 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
7208 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0x20000001 }, /* XP */
7209 { WM_SYSKEYDOWN
, wparam
|lparam
, 'N', 0x20000001 },
7210 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1003,1), 0 },
7211 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xe0000001 }, /* XP */
7212 { WM_SYSKEYUP
, wparam
|lparam
, 'N', 0xe0000001 },
7213 { WM_SYSKEYUP
, sent
|wparam
|lparam
, 'N', 0xe0000001 },
7214 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xc0000001 }, /* XP */
7215 { WM_KEYUP
, wparam
|lparam
, VK_MENU
, 0xc0000001 },
7216 { WM_KEYUP
, sent
|wparam
|lparam
, VK_MENU
, 0xc0000001 },
7219 static const struct message WmCtrlAltVkN
[] = {
7220 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 1 }, /* XP */
7221 { WM_KEYDOWN
, wparam
|lparam
, VK_CONTROL
, 1 },
7222 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_CONTROL
, 1 },
7223 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 }, /* XP */
7224 { WM_KEYDOWN
, wparam
|lparam
, VK_MENU
, 0x20000001 },
7225 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
7226 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0x20000001 }, /* XP */
7227 { WM_KEYDOWN
, wparam
|lparam
, 'N', 0x20000001 },
7228 { WM_KEYDOWN
, sent
|wparam
|lparam
, 'N', 0x20000001 },
7229 { WM_CHAR
, optional
},
7230 { WM_CHAR
, sent
|optional
},
7231 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xe0000001 }, /* XP */
7232 { WM_KEYUP
, wparam
|lparam
, 'N', 0xe0000001 },
7233 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xe0000001 },
7234 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xc0000001 }, /* XP */
7235 { WM_KEYUP
, wparam
|lparam
, VK_MENU
, 0xc0000001 },
7236 { WM_KEYUP
, sent
|wparam
|lparam
, VK_MENU
, 0xc0000001 },
7237 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 0xc0000001 }, /* XP */
7238 { WM_KEYUP
, wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
7239 { WM_KEYUP
, sent
|wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
7242 static const struct message WmCtrlShiftVkN
[] = {
7243 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 1 }, /* XP */
7244 { WM_KEYDOWN
, wparam
|lparam
, VK_CONTROL
, 1 },
7245 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_CONTROL
, 1 },
7246 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 1 }, /* XP */
7247 { WM_KEYDOWN
, wparam
|lparam
, VK_SHIFT
, 1 },
7248 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_SHIFT
, 1 },
7249 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 1 }, /* XP */
7250 { WM_KEYDOWN
, wparam
|lparam
, 'N', 1 },
7251 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1004,1), 0 },
7252 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xc0000001 }, /* XP */
7253 { WM_KEYUP
, wparam
|lparam
, 'N', 0xc0000001 },
7254 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xc0000001 },
7255 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 0xc0000001 }, /* XP */
7256 { WM_KEYUP
, wparam
|lparam
, VK_SHIFT
, 0xc0000001 },
7257 { WM_KEYUP
, sent
|wparam
|lparam
, VK_SHIFT
, 0xc0000001 },
7258 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 0xc0000001 }, /* XP */
7259 { WM_KEYUP
, wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
7260 { WM_KEYUP
, sent
|wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
7263 static const struct message WmCtrlAltShiftVkN
[] = {
7264 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 1 }, /* XP */
7265 { WM_KEYDOWN
, wparam
|lparam
, VK_CONTROL
, 1 },
7266 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_CONTROL
, 1 },
7267 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 }, /* XP */
7268 { WM_KEYDOWN
, wparam
|lparam
, VK_MENU
, 0x20000001 },
7269 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
7270 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 0x20000001 }, /* XP */
7271 { WM_KEYDOWN
, wparam
|lparam
, VK_SHIFT
, 0x20000001 },
7272 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_SHIFT
, 0x20000001 },
7273 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0x20000001 }, /* XP */
7274 { WM_KEYDOWN
, wparam
|lparam
, 'N', 0x20000001 },
7275 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1005,1), 0 },
7276 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xe0000001 }, /* XP */
7277 { WM_KEYUP
, wparam
|lparam
, 'N', 0xe0000001 },
7278 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xe0000001 },
7279 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 0xe0000001 }, /* XP */
7280 { WM_KEYUP
, wparam
|lparam
, VK_SHIFT
, 0xe0000001 },
7281 { WM_KEYUP
, sent
|wparam
|lparam
, VK_SHIFT
, 0xe0000001 },
7282 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xc0000001 }, /* XP */
7283 { WM_KEYUP
, wparam
|lparam
, VK_MENU
, 0xc0000001 },
7284 { WM_KEYUP
, sent
|wparam
|lparam
, VK_MENU
, 0xc0000001 },
7285 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 0xc0000001 }, /* XP */
7286 { WM_KEYUP
, wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
7287 { WM_KEYUP
, sent
|wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
7290 static const struct message WmAltPressRelease
[] = {
7291 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 }, /* XP */
7292 { WM_SYSKEYDOWN
, wparam
|lparam
, VK_MENU
, 0x20000001 },
7293 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
7294 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xc0000001 }, /* XP */
7295 { WM_SYSKEYUP
, wparam
|lparam
, VK_MENU
, 0xc0000001 },
7296 { WM_SYSKEYUP
, sent
|wparam
|lparam
, VK_MENU
, 0xc0000001 },
7297 { WM_SYSCOMMAND
, sent
|defwinproc
|wparam
|lparam
, SC_KEYMENU
, 0 },
7298 { HCBT_SYSCOMMAND
, hook
},
7299 { WM_ENTERMENULOOP
, sent
|defwinproc
|wparam
|lparam
, 0, 0 },
7300 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
7301 { WM_INITMENU
, sent
|defwinproc
},
7302 { EVENT_SYSTEM_MENUSTART
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 0 },
7303 { WM_MENUSELECT
, sent
|defwinproc
|wparam
, MAKEWPARAM(0,MF_SYSMENU
|MF_POPUP
|MF_HILITE
) },
7304 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 1 },
7306 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x30000001 }, /* XP */
7308 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 0 },
7309 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, 0, 0, },
7310 { WM_CAPTURECHANGED
, sent
|defwinproc
},
7311 { WM_MENUSELECT
, sent
|defwinproc
|wparam
|optional
, MAKEWPARAM(0,0xffff) },
7312 { EVENT_SYSTEM_MENUEND
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 0 },
7313 { WM_EXITMENULOOP
, sent
|defwinproc
},
7314 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xc0000001 }, /* XP */
7315 { WM_SYSKEYUP
, wparam
|lparam
, VK_MENU
, 0xc0000001 },
7316 { WM_SYSKEYUP
, sent
|wparam
|lparam
, VK_MENU
, 0xc0000001 },
7319 static const struct message WmShiftMouseButton
[] = {
7320 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 1 }, /* XP */
7321 { WM_KEYDOWN
, wparam
|lparam
, VK_SHIFT
, 1 },
7322 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_SHIFT
, 1 },
7323 { WM_MOUSEMOVE
, wparam
|optional
, 0, 0 },
7324 { WM_MOUSEMOVE
, sent
|wparam
|optional
, 0, 0 },
7325 { WM_LBUTTONDOWN
, wparam
, MK_LBUTTON
|MK_SHIFT
, 0 },
7326 { WM_LBUTTONDOWN
, sent
|wparam
, MK_LBUTTON
|MK_SHIFT
, 0 },
7327 { WM_LBUTTONUP
, wparam
, MK_SHIFT
, 0 },
7328 { WM_LBUTTONUP
, sent
|wparam
, MK_SHIFT
, 0 },
7329 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 0xc0000001 }, /* XP */
7330 { WM_KEYUP
, wparam
|lparam
, VK_SHIFT
, 0xc0000001 },
7331 { WM_KEYUP
, sent
|wparam
|lparam
, VK_SHIFT
, 0xc0000001 },
7334 static const struct message WmF1Seq
[] = {
7335 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_F1
, 1 }, /* XP */
7336 { WM_KEYDOWN
, wparam
|lparam
, VK_F1
, 1 },
7337 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_F1
, 0x00000001 },
7338 { WM_KEYF1
, wparam
|lparam
, 0, 0 },
7339 { WM_KEYF1
, sent
|wparam
|lparam
, 0, 0 },
7340 { WM_HELP
, sent
|defwinproc
},
7341 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_F1
, 0xc0000001 }, /* XP */
7342 { WM_KEYUP
, wparam
|lparam
, VK_F1
, 0xc0000001 },
7343 { WM_KEYUP
, sent
|wparam
|lparam
, VK_F1
, 0xc0000001 },
7346 static const struct message WmVkAppsSeq
[] = {
7347 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_APPS
, 1 }, /* XP */
7348 { WM_KEYDOWN
, wparam
|lparam
, VK_APPS
, 1 },
7349 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_APPS
, 0x00000001 },
7350 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_APPS
, 0xc0000001 }, /* XP */
7351 { WM_KEYUP
, wparam
|lparam
, VK_APPS
, 0xc0000001 },
7352 { WM_KEYUP
, sent
|wparam
|lparam
, VK_APPS
, 0xc0000001 },
7353 { WM_CONTEXTMENU
, lparam
, /*hwnd*/0, -1 },
7354 { WM_CONTEXTMENU
, sent
|lparam
, /*hwnd*/0, -1 },
7357 static const struct message WmVkF10Seq
[] = {
7358 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_F10
, 1 }, /* XP */
7359 { WM_SYSKEYDOWN
, wparam
|lparam
, VK_F10
, 1 },
7360 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, VK_F10
, 0x00000001 },
7361 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_F10
, 0xc0000001 }, /* XP */
7362 { WM_SYSKEYUP
, wparam
|lparam
, VK_F10
, 0xc0000001 },
7363 { WM_SYSKEYUP
, sent
|wparam
|lparam
, VK_F10
, 0xc0000001 },
7364 { WM_SYSCOMMAND
, sent
|defwinproc
|wparam
, SC_KEYMENU
},
7365 { HCBT_SYSCOMMAND
, hook
},
7366 { WM_ENTERMENULOOP
, sent
|defwinproc
|wparam
|lparam
, 0, 0 },
7367 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
7368 { WM_INITMENU
, sent
|defwinproc
},
7369 { EVENT_SYSTEM_MENUSTART
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 0 },
7370 { WM_MENUSELECT
, sent
|defwinproc
|wparam
, MAKEWPARAM(0,MF_SYSMENU
|MF_POPUP
|MF_HILITE
) },
7371 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 1 },
7373 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_F10
, 0x10000001 }, /* XP */
7375 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_F10
, 1 }, /* XP */
7376 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 0 },
7377 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, 0, 0, },
7378 { WM_CAPTURECHANGED
, sent
|defwinproc
},
7379 { WM_MENUSELECT
, sent
|defwinproc
|wparam
|optional
, MAKEWPARAM(0,0xffff) },
7380 { EVENT_SYSTEM_MENUEND
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 0 },
7381 { WM_EXITMENULOOP
, sent
|defwinproc
},
7382 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_F10
, 0xc0000001 }, /* XP */
7383 { WM_SYSKEYUP
, wparam
|lparam
, VK_F10
, 0xc0000001 },
7384 { WM_SYSKEYUP
, sent
|wparam
|lparam
, VK_F10
, 0xc0000001 },
7387 static const struct message WmShiftF10Seq
[] = {
7388 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 1 }, /* XP */
7389 { WM_KEYDOWN
, wparam
|lparam
, VK_SHIFT
, 1 },
7390 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_SHIFT
, 0x00000001 },
7391 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_F10
, 1 }, /* XP */
7392 { WM_SYSKEYDOWN
, wparam
|lparam
, VK_F10
, 1 },
7393 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, VK_F10
, 0x00000001 },
7394 { WM_CONTEXTMENU
, sent
|defwinproc
|lparam
, /*hwnd*/0, -1 },
7395 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_F10
, 0xc0000001 }, /* XP */
7396 { WM_SYSKEYUP
, wparam
|lparam
, VK_F10
, 0xc0000001 },
7397 { WM_SYSKEYUP
, sent
|wparam
|lparam
, VK_F10
, 0xc0000001 },
7398 { WM_SYSCOMMAND
, sent
|defwinproc
|wparam
, SC_KEYMENU
},
7399 { HCBT_SYSCOMMAND
, hook
},
7400 { WM_ENTERMENULOOP
, sent
|defwinproc
|wparam
|lparam
, 0, 0 },
7401 { WM_INITMENU
, sent
|defwinproc
},
7402 { WM_MENUSELECT
, sent
|defwinproc
|wparam
, MAKEWPARAM(0,MF_SYSMENU
|MF_POPUP
|MF_HILITE
) },
7403 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 0xd0000001 }, /* XP */
7404 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_ESCAPE
, 0x10000001 }, /* XP */
7405 { WM_CAPTURECHANGED
, sent
|defwinproc
|wparam
|lparam
, 0, 0 },
7406 { WM_MENUSELECT
, sent
|defwinproc
|wparam
|lparam
, 0xffff0000, 0 },
7407 { WM_EXITMENULOOP
, sent
|defwinproc
|wparam
|lparam
, 0, 0 },
7408 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_ESCAPE
, 0xc0000001 }, /* XP */
7409 { WM_KEYUP
, wparam
|lparam
, VK_ESCAPE
, 0xc0000001 },
7410 { WM_KEYUP
, sent
|wparam
|lparam
, VK_ESCAPE
, 0xc0000001 },
7414 static void pump_msg_loop(HWND hwnd
, HACCEL hAccel
)
7418 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
))
7420 struct recvd_message log_msg
;
7422 /* ignore some unwanted messages */
7423 if (msg
.message
== WM_MOUSEMOVE
||
7424 msg
.message
== WM_TIMER
||
7425 ignore_message( msg
.message
))
7428 log_msg
.hwnd
= msg
.hwnd
;
7429 log_msg
.message
= msg
.message
;
7430 log_msg
.flags
= wparam
|lparam
;
7431 log_msg
.wParam
= msg
.wParam
;
7432 log_msg
.lParam
= msg
.lParam
;
7433 log_msg
.descr
= "accel";
7434 add_message(&log_msg
);
7436 if (!hAccel
|| !TranslateAcceleratorA(hwnd
, hAccel
, &msg
))
7438 TranslateMessage(&msg
);
7439 DispatchMessageA(&msg
);
7444 static void test_accelerators(void)
7450 HWND hwnd
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
7451 100, 100, 200, 200, 0, 0, 0, NULL
);
7460 ok(GetFocus() == hwnd
, "wrong focus window %p\n", GetFocus());
7462 state
= GetKeyState(VK_SHIFT
);
7463 ok(!(state
& 0x8000), "wrong Shift state %04x\n", state
);
7464 state
= GetKeyState(VK_CAPITAL
);
7465 ok(state
== 0, "wrong CapsLock state %04x\n", state
);
7467 hAccel
= LoadAcceleratorsA(GetModuleHandleA(NULL
), MAKEINTRESOURCEA(1));
7468 assert(hAccel
!= 0);
7471 pump_msg_loop(hwnd
, 0);
7474 trace("testing VK_N press/release\n");
7476 keybd_event('N', 0, 0, 0);
7477 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
7478 pump_msg_loop(hwnd
, hAccel
);
7479 if (!sequence_cnt
) /* we didn't get any message */
7481 skip( "queuing key events not supported\n" );
7484 ok_sequence(WmVkN
, "VK_N press/release", FALSE
);
7486 trace("testing Shift+VK_N press/release\n");
7488 keybd_event(VK_SHIFT
, 0, 0, 0);
7489 keybd_event('N', 0, 0, 0);
7490 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
7491 keybd_event(VK_SHIFT
, 0, KEYEVENTF_KEYUP
, 0);
7492 pump_msg_loop(hwnd
, hAccel
);
7493 ok_sequence(WmShiftVkN
, "Shift+VK_N press/release", FALSE
);
7495 trace("testing Ctrl+VK_N press/release\n");
7497 keybd_event(VK_CONTROL
, 0, 0, 0);
7498 keybd_event('N', 0, 0, 0);
7499 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
7500 keybd_event(VK_CONTROL
, 0, KEYEVENTF_KEYUP
, 0);
7501 pump_msg_loop(hwnd
, hAccel
);
7502 ok_sequence(WmCtrlVkN
, "Ctrl+VK_N press/release", FALSE
);
7504 trace("testing Alt+VK_N press/release\n");
7506 keybd_event(VK_MENU
, 0, 0, 0);
7507 keybd_event('N', 0, 0, 0);
7508 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
7509 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
7510 pump_msg_loop(hwnd
, hAccel
);
7511 ok_sequence(WmAltVkN
, "Alt+VK_N press/release", FALSE
);
7513 trace("testing Ctrl+Alt+VK_N press/release 1\n");
7515 keybd_event(VK_CONTROL
, 0, 0, 0);
7516 keybd_event(VK_MENU
, 0, 0, 0);
7517 keybd_event('N', 0, 0, 0);
7518 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
7519 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
7520 keybd_event(VK_CONTROL
, 0, KEYEVENTF_KEYUP
, 0);
7521 pump_msg_loop(hwnd
, hAccel
);
7522 ok_sequence(WmCtrlAltVkN
, "Ctrl+Alt+VK_N press/release 1", FALSE
);
7524 ret
= DestroyAcceleratorTable(hAccel
);
7525 ok( ret
, "DestroyAcceleratorTable error %d\n", GetLastError());
7527 hAccel
= LoadAcceleratorsA(GetModuleHandleA(NULL
), MAKEINTRESOURCEA(2));
7528 assert(hAccel
!= 0);
7530 trace("testing VK_N press/release\n");
7532 keybd_event('N', 0, 0, 0);
7533 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
7534 pump_msg_loop(hwnd
, hAccel
);
7535 ok_sequence(WmVkN
, "VK_N press/release", FALSE
);
7537 trace("testing Shift+VK_N press/release\n");
7539 keybd_event(VK_SHIFT
, 0, 0, 0);
7540 keybd_event('N', 0, 0, 0);
7541 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
7542 keybd_event(VK_SHIFT
, 0, KEYEVENTF_KEYUP
, 0);
7543 pump_msg_loop(hwnd
, hAccel
);
7544 ok_sequence(WmShiftVkN
, "Shift+VK_N press/release", FALSE
);
7546 trace("testing Ctrl+VK_N press/release 2\n");
7548 keybd_event(VK_CONTROL
, 0, 0, 0);
7549 keybd_event('N', 0, 0, 0);
7550 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
7551 keybd_event(VK_CONTROL
, 0, KEYEVENTF_KEYUP
, 0);
7552 pump_msg_loop(hwnd
, hAccel
);
7553 ok_sequence(WmCtrlVkN_2
, "Ctrl+VK_N press/release 2", FALSE
);
7555 trace("testing Alt+VK_N press/release 2\n");
7557 keybd_event(VK_MENU
, 0, 0, 0);
7558 keybd_event('N', 0, 0, 0);
7559 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
7560 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
7561 pump_msg_loop(hwnd
, hAccel
);
7562 ok_sequence(WmAltVkN_2
, "Alt+VK_N press/release 2", FALSE
);
7564 trace("testing Ctrl+Alt+VK_N press/release 2\n");
7566 keybd_event(VK_CONTROL
, 0, 0, 0);
7567 keybd_event(VK_MENU
, 0, 0, 0);
7568 keybd_event('N', 0, 0, 0);
7569 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
7570 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
7571 keybd_event(VK_CONTROL
, 0, KEYEVENTF_KEYUP
, 0);
7572 pump_msg_loop(hwnd
, hAccel
);
7573 ok_sequence(WmCtrlAltVkN
, "Ctrl+Alt+VK_N press/release 2", FALSE
);
7575 trace("testing Ctrl+Shift+VK_N press/release\n");
7577 keybd_event(VK_CONTROL
, 0, 0, 0);
7578 keybd_event(VK_SHIFT
, 0, 0, 0);
7579 keybd_event('N', 0, 0, 0);
7580 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
7581 keybd_event(VK_SHIFT
, 0, KEYEVENTF_KEYUP
, 0);
7582 keybd_event(VK_CONTROL
, 0, KEYEVENTF_KEYUP
, 0);
7583 pump_msg_loop(hwnd
, hAccel
);
7584 ok_sequence(WmCtrlShiftVkN
, "Ctrl+Shift+VK_N press/release", FALSE
);
7586 trace("testing Ctrl+Alt+Shift+VK_N press/release\n");
7588 keybd_event(VK_CONTROL
, 0, 0, 0);
7589 keybd_event(VK_MENU
, 0, 0, 0);
7590 keybd_event(VK_SHIFT
, 0, 0, 0);
7591 keybd_event('N', 0, 0, 0);
7592 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
7593 keybd_event(VK_SHIFT
, 0, KEYEVENTF_KEYUP
, 0);
7594 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
7595 keybd_event(VK_CONTROL
, 0, KEYEVENTF_KEYUP
, 0);
7596 pump_msg_loop(hwnd
, hAccel
);
7597 ok_sequence(WmCtrlAltShiftVkN
, "Ctrl+Alt+Shift+VK_N press/release", FALSE
);
7599 ret
= DestroyAcceleratorTable(hAccel
);
7600 ok( ret
, "DestroyAcceleratorTable error %d\n", GetLastError());
7603 trace("testing Alt press/release\n");
7605 keybd_event(VK_MENU
, 0, 0, 0);
7606 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
7607 keybd_event(VK_MENU
, 0, 0, 0);
7608 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
7609 pump_msg_loop(hwnd
, 0);
7610 /* this test doesn't pass in Wine for managed windows */
7611 ok_sequence(WmAltPressRelease
, "Alt press/release", TRUE
);
7613 trace("testing VK_F1 press/release\n");
7614 keybd_event(VK_F1
, 0, 0, 0);
7615 keybd_event(VK_F1
, 0, KEYEVENTF_KEYUP
, 0);
7616 pump_msg_loop(hwnd
, 0);
7617 ok_sequence(WmF1Seq
, "F1 press/release", FALSE
);
7619 trace("testing VK_APPS press/release\n");
7620 keybd_event(VK_APPS
, 0, 0, 0);
7621 keybd_event(VK_APPS
, 0, KEYEVENTF_KEYUP
, 0);
7622 pump_msg_loop(hwnd
, 0);
7623 ok_sequence(WmVkAppsSeq
, "VK_APPS press/release", FALSE
);
7625 trace("testing VK_F10 press/release\n");
7626 keybd_event(VK_F10
, 0, 0, 0);
7627 keybd_event(VK_F10
, 0, KEYEVENTF_KEYUP
, 0);
7628 keybd_event(VK_F10
, 0, 0, 0);
7629 keybd_event(VK_F10
, 0, KEYEVENTF_KEYUP
, 0);
7630 pump_msg_loop(hwnd
, 0);
7631 ok_sequence(WmVkF10Seq
, "VK_F10 press/release", TRUE
);
7633 trace("testing SHIFT+F10 press/release\n");
7634 keybd_event(VK_SHIFT
, 0, 0, 0);
7635 keybd_event(VK_F10
, 0, 0, 0);
7636 keybd_event(VK_F10
, 0, KEYEVENTF_KEYUP
, 0);
7637 keybd_event(VK_SHIFT
, 0, KEYEVENTF_KEYUP
, 0);
7638 keybd_event(VK_ESCAPE
, 0, 0, 0);
7639 keybd_event(VK_ESCAPE
, 0, KEYEVENTF_KEYUP
, 0);
7640 pump_msg_loop(hwnd
, 0);
7641 ok_sequence(WmShiftF10Seq
, "SHIFT+F10 press/release", TRUE
);
7643 trace("testing Shift+MouseButton press/release\n");
7644 /* first, move mouse pointer inside of the window client area */
7645 GetClientRect(hwnd
, &rc
);
7646 MapWindowPoints(hwnd
, 0, (LPPOINT
)&rc
, 2);
7647 rc
.left
+= (rc
.right
- rc
.left
)/2;
7648 rc
.top
+= (rc
.bottom
- rc
.top
)/2;
7649 SetCursorPos(rc
.left
, rc
.top
);
7650 SetActiveWindow(hwnd
);
7655 if (pt
.x
== rc
.left
&& pt
.y
== rc
.top
)
7658 keybd_event(VK_SHIFT
, 0, 0, 0);
7659 mouse_event(MOUSEEVENTF_LEFTDOWN
, 0, 0, 0, 0);
7660 mouse_event(MOUSEEVENTF_LEFTUP
, 0, 0, 0, 0);
7661 keybd_event(VK_SHIFT
, 0, KEYEVENTF_KEYUP
, 0);
7662 pump_msg_loop(hwnd
, 0);
7663 for (i
= 0; i
< sequence_cnt
; i
++) if (sequence
[i
].message
== WM_LBUTTONDOWN
) break;
7664 if (i
< sequence_cnt
)
7665 ok_sequence(WmShiftMouseButton
, "Shift+MouseButton press/release", FALSE
);
7667 skip( "Shift+MouseButton event didn't get to the window\n" );
7671 if (hAccel
) DestroyAcceleratorTable(hAccel
);
7672 DestroyWindow(hwnd
);
7675 /************* window procedures ********************/
7677 static LRESULT
MsgCheckProc (BOOL unicode
, HWND hwnd
, UINT message
,
7678 WPARAM wParam
, LPARAM lParam
)
7680 static LONG defwndproc_counter
= 0;
7681 static LONG beginpaint_counter
= 0;
7683 struct recvd_message msg
;
7685 if (ignore_message( message
)) return 0;
7691 LONG style
= GetWindowLongA(hwnd
, GWL_STYLE
);
7692 ok((BOOL
)wParam
== !(style
& WS_DISABLED
),
7693 "wrong WS_DISABLED state: %ld != %d\n", wParam
, !(style
& WS_DISABLED
));
7697 case WM_CAPTURECHANGED
:
7698 if (test_DestroyWindow_flag
)
7700 DWORD style
= GetWindowLongA(hwnd
, GWL_STYLE
);
7701 if (style
& WS_CHILD
)
7702 lParam
= GetWindowLongPtrA(hwnd
, GWLP_ID
);
7703 else if (style
& WS_POPUP
)
7704 lParam
= WND_POPUP_ID
;
7706 lParam
= WND_PARENT_ID
;
7714 ok(!GetWindow(hwnd
, GW_CHILD
), "children should be unlinked at this point\n");
7715 capture
= GetCapture();
7718 ok(capture
== hwnd
, "capture should NOT be released at this point (capture %p)\n", capture
);
7719 trace("current capture %p, releasing...\n", capture
);
7726 ok(pGetAncestor(hwnd
, GA_PARENT
) != 0, "parent should NOT be unlinked at this point\n");
7727 if (test_DestroyWindow_flag
)
7729 DWORD style
= GetWindowLongA(hwnd
, GWL_STYLE
);
7730 if (style
& WS_CHILD
)
7731 lParam
= GetWindowLongPtrA(hwnd
, GWLP_ID
);
7732 else if (style
& WS_POPUP
)
7733 lParam
= WND_POPUP_ID
;
7735 lParam
= WND_PARENT_ID
;
7739 /* test_accelerators() depends on this */
7745 HANDLE handle
, event
= (HANDLE
)lParam
;
7748 handle
= (void*)0xdeadbeef;
7749 ret
= pGetCurrentActCtx(&handle
);
7750 ok(ret
, "failed to get current context, %u\n", GetLastError());
7751 ok(handle
== 0, "got active context %p\n", handle
);
7752 if (event
) SetEvent(event
);
7758 case WM_MOUSEACTIVATE
:
7759 case WM_NCMOUSEMOVE
:
7766 msg
.message
= message
;
7767 msg
.flags
= sent
|wparam
|lparam
;
7768 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
7769 if (beginpaint_counter
) msg
.flags
|= beginpaint
;
7770 msg
.wParam
= wParam
;
7771 msg
.lParam
= lParam
;
7772 msg
.descr
= "MsgCheckProc";
7775 if (message
== WM_GETMINMAXINFO
&& (GetWindowLongA(hwnd
, GWL_STYLE
) & WS_CHILD
))
7777 HWND parent
= GetParent(hwnd
);
7779 MINMAXINFO
*minmax
= (MINMAXINFO
*)lParam
;
7781 GetClientRect(parent
, &rc
);
7782 trace("parent %p client size = (%d x %d)\n", parent
, rc
.right
, rc
.bottom
);
7783 trace("Reserved=%d,%d MaxSize=%d,%d MaxPos=%d,%d MinTrack=%d,%d MaxTrack=%d,%d\n",
7784 minmax
->ptReserved
.x
, minmax
->ptReserved
.y
,
7785 minmax
->ptMaxSize
.x
, minmax
->ptMaxSize
.y
,
7786 minmax
->ptMaxPosition
.x
, minmax
->ptMaxPosition
.y
,
7787 minmax
->ptMinTrackSize
.x
, minmax
->ptMinTrackSize
.y
,
7788 minmax
->ptMaxTrackSize
.x
, minmax
->ptMaxTrackSize
.y
);
7790 ok(minmax
->ptMaxSize
.x
== rc
.right
, "default width of maximized child %d != %d\n",
7791 minmax
->ptMaxSize
.x
, rc
.right
);
7792 ok(minmax
->ptMaxSize
.y
== rc
.bottom
, "default height of maximized child %d != %d\n",
7793 minmax
->ptMaxSize
.y
, rc
.bottom
);
7796 if (message
== WM_PAINT
)
7799 beginpaint_counter
++;
7800 BeginPaint( hwnd
, &ps
);
7801 beginpaint_counter
--;
7802 EndPaint( hwnd
, &ps
);
7806 defwndproc_counter
++;
7807 ret
= unicode
? DefWindowProcW(hwnd
, message
, wParam
, lParam
)
7808 : DefWindowProcA(hwnd
, message
, wParam
, lParam
);
7809 defwndproc_counter
--;
7814 static LRESULT WINAPI
MsgCheckProcA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
7816 return MsgCheckProc (FALSE
, hwnd
, message
, wParam
, lParam
);
7819 static LRESULT WINAPI
MsgCheckProcW(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
7821 return MsgCheckProc (TRUE
, hwnd
, message
, wParam
, lParam
);
7824 static LRESULT WINAPI
PopupMsgCheckProcA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
7826 static LONG defwndproc_counter
= 0;
7828 struct recvd_message msg
;
7830 if (ignore_message( message
)) return 0;
7834 case WM_QUERYENDSESSION
:
7836 lParam
&= ~0x01; /* Vista adds a 0x01 flag */
7841 msg
.message
= message
;
7842 msg
.flags
= sent
|wparam
|lparam
;
7843 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
7844 msg
.wParam
= wParam
;
7845 msg
.lParam
= lParam
;
7846 msg
.descr
= "popup";
7849 if (message
== WM_CREATE
)
7851 DWORD style
= GetWindowLongA(hwnd
, GWL_STYLE
) | WS_VISIBLE
;
7852 SetWindowLongA(hwnd
, GWL_STYLE
, style
);
7855 defwndproc_counter
++;
7856 ret
= DefWindowProcA(hwnd
, message
, wParam
, lParam
);
7857 defwndproc_counter
--;
7862 static LRESULT WINAPI
ParentMsgCheckProcA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
7864 static LONG defwndproc_counter
= 0;
7865 static LONG beginpaint_counter
= 0;
7867 struct recvd_message msg
;
7869 if (ignore_message( message
)) return 0;
7871 if (log_all_parent_messages
||
7872 message
== WM_PARENTNOTIFY
|| message
== WM_CANCELMODE
||
7873 message
== WM_SETFOCUS
|| message
== WM_KILLFOCUS
||
7874 message
== WM_ENABLE
|| message
== WM_ENTERIDLE
||
7875 message
== WM_DRAWITEM
|| message
== WM_COMMAND
||
7876 message
== WM_IME_SETCONTEXT
)
7885 case WM_NCMOUSEMOVE
:
7891 INT ret
= GetClipBox((HDC
)wParam
, &rc
);
7893 trace("WM_ERASEBKGND: GetClipBox()=%d, (%d,%d-%d,%d)\n",
7894 ret
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
7900 msg
.message
= message
;
7901 msg
.flags
= sent
|parent
|wparam
|lparam
;
7902 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
7903 if (beginpaint_counter
) msg
.flags
|= beginpaint
;
7904 msg
.wParam
= wParam
;
7905 msg
.lParam
= lParam
;
7906 msg
.descr
= "parent";
7910 if (message
== WM_PAINT
)
7913 beginpaint_counter
++;
7914 BeginPaint( hwnd
, &ps
);
7915 beginpaint_counter
--;
7916 EndPaint( hwnd
, &ps
);
7920 defwndproc_counter
++;
7921 ret
= DefWindowProcA(hwnd
, message
, wParam
, lParam
);
7922 defwndproc_counter
--;
7927 static INT_PTR CALLBACK
StopQuitMsgCheckProcA(HWND hwnd
, UINT message
, WPARAM wp
, LPARAM lp
)
7929 if (message
== WM_CREATE
)
7930 PostMessageA(hwnd
, WM_CLOSE
, 0, 0);
7931 else if (message
== WM_CLOSE
)
7933 /* Only the first WM_QUIT will survive the window destruction */
7934 PostMessageA(hwnd
, WM_USER
, 0x1234, 0x5678);
7935 PostMessageA(hwnd
, WM_QUIT
, 0x1234, 0x5678);
7936 PostMessageA(hwnd
, WM_QUIT
, 0x4321, 0x8765);
7939 return DefWindowProcA(hwnd
, message
, wp
, lp
);
7942 static LRESULT WINAPI
TestDlgProcA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
7944 static LONG defwndproc_counter
= 0;
7946 struct recvd_message msg
;
7948 if (ignore_message( message
)) return 0;
7952 DefDlgProcA(hwnd
, DM_SETDEFID
, 1, 0);
7953 ret
= DefDlgProcA(hwnd
, DM_GETDEFID
, 0, 0);
7954 if (after_end_dialog
)
7955 ok( ret
== 0, "DM_GETDEFID should return 0 after EndDialog, got %lx\n", ret
);
7957 ok(HIWORD(ret
) == DC_HASDEFID
, "DM_GETDEFID should return DC_HASDEFID, got %lx\n", ret
);
7961 msg
.message
= message
;
7962 msg
.flags
= sent
|wparam
|lparam
;
7963 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
7964 msg
.wParam
= wParam
;
7965 msg
.lParam
= lParam
;
7966 msg
.descr
= "dialog";
7969 defwndproc_counter
++;
7970 ret
= DefDlgProcA(hwnd
, message
, wParam
, lParam
);
7971 defwndproc_counter
--;
7976 static LRESULT WINAPI
ShowWindowProcA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
7978 static LONG defwndproc_counter
= 0;
7980 struct recvd_message msg
;
7982 /* log only specific messages we are interested in */
7985 #if 0 /* probably log these as well */
7993 case WM_GETMINMAXINFO
:
7994 case WM_WINDOWPOSCHANGING
:
7995 case WM_WINDOWPOSCHANGED
:
7998 default: /* ignore */
7999 /*trace("showwindow: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);*/
8000 return DefWindowProcA(hwnd
, message
, wParam
, lParam
);
8004 msg
.message
= message
;
8005 msg
.flags
= sent
|wparam
|lparam
;
8006 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
8007 msg
.wParam
= wParam
;
8008 msg
.lParam
= lParam
;
8012 defwndproc_counter
++;
8013 ret
= DefWindowProcA(hwnd
, message
, wParam
, lParam
);
8014 defwndproc_counter
--;
8019 static LRESULT WINAPI
PaintLoopProcA(HWND hWnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
8023 case WM_CREATE
: return 0;
8032 if (PeekMessageA(&msg2
, 0, 0, 0, 1))
8034 TranslateMessage(&msg2
);
8035 DispatchMessageA(&msg2
);
8039 else ok(broken(1), "infinite loop\n");
8041 paint_loop_done
= TRUE
;
8042 return DefWindowProcA(hWnd
,msg
,wParam
,lParam
);
8045 return DefWindowProcA(hWnd
,msg
,wParam
,lParam
);
8048 static LRESULT WINAPI
HotkeyMsgCheckProcA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
8050 static LONG defwndproc_counter
= 0;
8052 struct recvd_message msg
;
8055 if (ignore_message( message
)) return 0;
8057 if ((message
>= WM_KEYFIRST
&& message
<= WM_KEYLAST
) ||
8058 message
== WM_HOTKEY
|| message
>= WM_APP
)
8061 msg
.message
= message
;
8062 msg
.flags
= sent
|wparam
|lparam
;
8063 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
8064 msg
.wParam
= wParam
;
8065 msg
.lParam
= lParam
;
8066 msg
.descr
= "HotkeyMsgCheckProcA";
8070 defwndproc_counter
++;
8071 ret
= DefWindowProcA(hwnd
, message
, wParam
, lParam
);
8072 defwndproc_counter
--;
8074 if (message
== WM_APP
)
8076 queue_status
= GetQueueStatus(QS_HOTKEY
);
8077 ok((queue_status
& (QS_HOTKEY
<< 16)) == QS_HOTKEY
<< 16, "expected QS_HOTKEY << 16 set, got %x\n", queue_status
);
8078 queue_status
= GetQueueStatus(QS_POSTMESSAGE
);
8079 ok((queue_status
& (QS_POSTMESSAGE
<< 16)) == QS_POSTMESSAGE
<< 16, "expected QS_POSTMESSAGE << 16 set, got %x\n", queue_status
);
8080 PostMessageA(hwnd
, WM_APP
+1, 0, 0);
8082 else if (message
== WM_APP
+1)
8084 queue_status
= GetQueueStatus(QS_HOTKEY
);
8085 ok((queue_status
& (QS_HOTKEY
<< 16)) == 0, "expected QS_HOTKEY << 16 cleared, got %x\n", queue_status
);
8091 static BOOL
RegisterWindowClasses(void)
8097 cls
.lpfnWndProc
= MsgCheckProcA
;
8100 cls
.hInstance
= GetModuleHandleA(0);
8102 cls
.hCursor
= LoadCursorA(0, (LPCSTR
)IDC_ARROW
);
8103 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
8104 cls
.lpszMenuName
= NULL
;
8105 cls
.lpszClassName
= "TestWindowClass";
8106 if(!RegisterClassA(&cls
)) return FALSE
;
8108 cls
.lpfnWndProc
= HotkeyMsgCheckProcA
;
8109 cls
.lpszClassName
= "HotkeyWindowClass";
8110 if(!RegisterClassA(&cls
)) return FALSE
;
8112 cls
.lpfnWndProc
= ShowWindowProcA
;
8113 cls
.lpszClassName
= "ShowWindowClass";
8114 if(!RegisterClassA(&cls
)) return FALSE
;
8116 cls
.lpfnWndProc
= PopupMsgCheckProcA
;
8117 cls
.lpszClassName
= "TestPopupClass";
8118 if(!RegisterClassA(&cls
)) return FALSE
;
8120 cls
.lpfnWndProc
= ParentMsgCheckProcA
;
8121 cls
.lpszClassName
= "TestParentClass";
8122 if(!RegisterClassA(&cls
)) return FALSE
;
8124 cls
.lpfnWndProc
= StopQuitMsgCheckProcA
;
8125 cls
.lpszClassName
= "StopQuitClass";
8126 if(!RegisterClassA(&cls
)) return FALSE
;
8128 cls
.lpfnWndProc
= DefWindowProcA
;
8129 cls
.lpszClassName
= "SimpleWindowClass";
8130 if(!RegisterClassA(&cls
)) return FALSE
;
8132 cls
.lpfnWndProc
= PaintLoopProcA
;
8133 cls
.lpszClassName
= "PaintLoopWindowClass";
8134 if(!RegisterClassA(&cls
)) return FALSE
;
8136 cls
.style
= CS_NOCLOSE
;
8137 cls
.lpszClassName
= "NoCloseWindowClass";
8138 if(!RegisterClassA(&cls
)) return FALSE
;
8140 ok(GetClassInfoA(0, "#32770", &cls
), "GetClassInfo failed\n");
8142 cls
.hInstance
= GetModuleHandleA(0);
8143 cls
.hbrBackground
= 0;
8144 cls
.lpfnWndProc
= TestDlgProcA
;
8145 cls
.lpszClassName
= "TestDialogClass";
8146 if(!RegisterClassA(&cls
)) return FALSE
;
8149 clsW
.lpfnWndProc
= MsgCheckProcW
;
8150 clsW
.cbClsExtra
= 0;
8151 clsW
.cbWndExtra
= 0;
8152 clsW
.hInstance
= GetModuleHandleW(0);
8154 clsW
.hCursor
= LoadCursorW(0, (LPWSTR
)IDC_ARROW
);
8155 clsW
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
8156 clsW
.lpszMenuName
= NULL
;
8157 clsW
.lpszClassName
= testWindowClassW
;
8158 RegisterClassW(&clsW
); /* ignore error, this fails on Win9x */
8163 static BOOL
is_our_logged_class(HWND hwnd
)
8167 if (GetClassNameA(hwnd
, buf
, sizeof(buf
)))
8169 if (!lstrcmpiA(buf
, "TestWindowClass") ||
8170 !lstrcmpiA(buf
, "ShowWindowClass") ||
8171 !lstrcmpiA(buf
, "TestParentClass") ||
8172 !lstrcmpiA(buf
, "TestPopupClass") ||
8173 !lstrcmpiA(buf
, "SimpleWindowClass") ||
8174 !lstrcmpiA(buf
, "TestDialogClass") ||
8175 !lstrcmpiA(buf
, "MDI_frame_class") ||
8176 !lstrcmpiA(buf
, "MDI_client_class") ||
8177 !lstrcmpiA(buf
, "MDI_child_class") ||
8178 !lstrcmpiA(buf
, "my_button_class") ||
8179 !lstrcmpiA(buf
, "my_edit_class") ||
8180 !lstrcmpiA(buf
, "static") ||
8181 !lstrcmpiA(buf
, "ListBox") ||
8182 !lstrcmpiA(buf
, "ComboBox") ||
8183 !lstrcmpiA(buf
, "MyDialogClass") ||
8184 !lstrcmpiA(buf
, "#32770") ||
8185 !lstrcmpiA(buf
, "#32768"))
8191 static LRESULT CALLBACK
cbt_hook_proc(int nCode
, WPARAM wParam
, LPARAM lParam
)
8195 ok(cbt_hook_thread_id
== GetCurrentThreadId(), "we didn't ask for events from other threads\n");
8197 if (nCode
== HCBT_CLICKSKIPPED
)
8199 /* ignore this event, XP sends it a lot when switching focus between windows */
8200 return CallNextHookEx(hCBT_hook
, nCode
, wParam
, lParam
);
8203 if (nCode
== HCBT_SYSCOMMAND
|| nCode
== HCBT_KEYSKIPPED
)
8205 struct recvd_message msg
;
8208 msg
.message
= nCode
;
8209 msg
.flags
= hook
|wparam
|lparam
;
8210 msg
.wParam
= wParam
;
8211 msg
.lParam
= lParam
;
8215 return CallNextHookEx(hCBT_hook
, nCode
, wParam
, lParam
);
8218 if (nCode
== HCBT_DESTROYWND
)
8220 if (test_DestroyWindow_flag
)
8222 DWORD style
= GetWindowLongA((HWND
)wParam
, GWL_STYLE
);
8223 if (style
& WS_CHILD
)
8224 lParam
= GetWindowLongPtrA((HWND
)wParam
, GWLP_ID
);
8225 else if (style
& WS_POPUP
)
8226 lParam
= WND_POPUP_ID
;
8228 lParam
= WND_PARENT_ID
;
8232 /* Log also SetFocus(0) calls */
8233 hwnd
= wParam
? (HWND
)wParam
: (HWND
)lParam
;
8235 if (is_our_logged_class(hwnd
))
8237 struct recvd_message msg
;
8240 msg
.message
= nCode
;
8241 msg
.flags
= hook
|wparam
|lparam
;
8242 msg
.wParam
= wParam
;
8243 msg
.lParam
= lParam
;
8247 return CallNextHookEx(hCBT_hook
, nCode
, wParam
, lParam
);
8250 static void CALLBACK
win_event_proc(HWINEVENTHOOK hevent
,
8258 ok(thread_id
== GetCurrentThreadId(), "we didn't ask for events from other threads\n");
8260 /* ignore mouse cursor events */
8261 if (object_id
== OBJID_CURSOR
) return;
8263 if (!hwnd
|| is_our_logged_class(hwnd
))
8265 struct recvd_message msg
;
8268 msg
.message
= event
;
8269 msg
.flags
= winevent_hook
|wparam
|lparam
;
8270 msg
.wParam
= object_id
;
8271 msg
.lParam
= child_id
;
8277 static const WCHAR wszUnicode
[] = {'U','n','i','c','o','d','e',0};
8278 static const WCHAR wszAnsi
[] = {'U',0};
8280 static LRESULT CALLBACK
MsgConversionProcW(HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
8284 case CB_FINDSTRINGEXACT
:
8285 trace("String: %p\n", (LPCWSTR
)lParam
);
8286 if (!lstrcmpW((LPCWSTR
)lParam
, wszUnicode
))
8288 if (!lstrcmpW((LPCWSTR
)lParam
, wszAnsi
))
8292 return DefWindowProcW(hwnd
, uMsg
, wParam
, lParam
);
8295 static const struct message WmGetTextLengthAfromW
[] = {
8296 { WM_GETTEXTLENGTH
, sent
},
8297 { WM_GETTEXT
, sent
|optional
},
8301 static const WCHAR dummy_window_text
[] = {'d','u','m','m','y',' ','t','e','x','t',0};
8303 /* dummy window proc for WM_GETTEXTLENGTH test */
8304 static LRESULT CALLBACK
get_text_len_proc( HWND hwnd
, UINT msg
, WPARAM wp
, LPARAM lp
)
8308 case WM_GETTEXTLENGTH
:
8309 return lstrlenW(dummy_window_text
) + 37; /* some random length */
8311 lstrcpynW( (LPWSTR
)lp
, dummy_window_text
, wp
);
8312 return lstrlenW( (LPWSTR
)lp
);
8314 return DefWindowProcW( hwnd
, msg
, wp
, lp
);
8318 static void test_message_conversion(void)
8320 static const WCHAR wszMsgConversionClass
[] =
8321 {'M','s','g','C','o','n','v','e','r','s','i','o','n','C','l','a','s','s',0};
8325 WNDPROC wndproc
, newproc
;
8329 cls
.lpfnWndProc
= MsgConversionProcW
;
8332 cls
.hInstance
= GetModuleHandleW(NULL
);
8334 cls
.hCursor
= LoadCursorW(NULL
, (LPWSTR
)IDC_ARROW
);
8335 cls
.hbrBackground
= (HBRUSH
)(COLOR_BTNFACE
+1);
8336 cls
.lpszMenuName
= NULL
;
8337 cls
.lpszClassName
= wszMsgConversionClass
;
8338 /* this call will fail on Win9x, but that doesn't matter as this test is
8339 * meaningless on those platforms */
8340 if(!RegisterClassW(&cls
)) return;
8342 hwnd
= CreateWindowExW(0, wszMsgConversionClass
, NULL
, WS_OVERLAPPED
,
8343 100, 100, 200, 200, 0, 0, 0, NULL
);
8344 ok(hwnd
!= NULL
, "Window creation failed\n");
8348 wndproc
= (WNDPROC
)GetWindowLongPtrA(hwnd
, GWLP_WNDPROC
);
8349 lRes
= CallWindowProcA(wndproc
, hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
8350 ok(lRes
== 0, "String should have been converted\n");
8351 lRes
= CallWindowProcW(wndproc
, hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
8352 ok(lRes
== 1, "String shouldn't have been converted\n");
8356 wndproc
= (WNDPROC
)GetWindowLongPtrW(hwnd
, GWLP_WNDPROC
);
8357 lRes
= CallWindowProcA(wndproc
, hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
8358 ok(lRes
== 1, "String shouldn't have been converted\n");
8359 lRes
= CallWindowProcW(wndproc
, hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
8360 ok(lRes
== 1, "String shouldn't have been converted\n");
8362 /* Synchronous messages */
8364 lRes
= SendMessageA(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
8365 ok(lRes
== 0, "String should have been converted\n");
8366 lRes
= SendMessageW(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
8367 ok(lRes
== 1, "String shouldn't have been converted\n");
8369 /* Asynchronous messages */
8372 lRes
= PostMessageA(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
8373 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
8374 "PostMessage on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
8376 lRes
= PostMessageW(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
8377 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
8378 "PostMessage on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
8380 lRes
= PostThreadMessageA(GetCurrentThreadId(), CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
8381 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
8382 "PosThreadtMessage on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
8384 lRes
= PostThreadMessageW(GetCurrentThreadId(), CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
8385 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
8386 "PosThreadtMessage on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
8388 lRes
= SendNotifyMessageA(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
8389 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
8390 "SendNotifyMessage on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
8392 lRes
= SendNotifyMessageW(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
8393 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
8394 "SendNotifyMessage on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
8396 lRes
= SendMessageCallbackA(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
, NULL
, 0);
8397 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
8398 "SendMessageCallback on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
8400 lRes
= SendMessageCallbackW(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
, NULL
, 0);
8401 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
8402 "SendMessageCallback on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
8404 /* Check WM_GETTEXTLENGTH A->W behaviour, whether WM_GETTEXT is also sent or not */
8406 hwnd
= CreateWindowW (testWindowClassW
, wszUnicode
,
8407 WS_OVERLAPPEDWINDOW
,
8408 100, 100, 200, 200, 0, 0, 0, NULL
);
8411 lRes
= SendMessageA (hwnd
, WM_GETTEXTLENGTH
, 0, 0);
8412 ok_sequence(WmGetTextLengthAfromW
, "ANSI WM_GETTEXTLENGTH to Unicode window", FALSE
);
8413 ok( lRes
== WideCharToMultiByte( CP_ACP
, 0, wszUnicode
, lstrlenW(wszUnicode
), NULL
, 0, NULL
, NULL
),
8414 "got bad length %ld\n", lRes
);
8417 lRes
= CallWindowProcA( (WNDPROC
)GetWindowLongPtrA( hwnd
, GWLP_WNDPROC
),
8418 hwnd
, WM_GETTEXTLENGTH
, 0, 0);
8419 ok_sequence(WmGetTextLengthAfromW
, "ANSI WM_GETTEXTLENGTH to Unicode window", FALSE
);
8420 ok( lRes
== WideCharToMultiByte( CP_ACP
, 0, wszUnicode
, lstrlenW(wszUnicode
), NULL
, 0, NULL
, NULL
),
8421 "got bad length %ld\n", lRes
);
8423 wndproc
= (WNDPROC
)SetWindowLongPtrW( hwnd
, GWLP_WNDPROC
, (LONG_PTR
)get_text_len_proc
);
8424 newproc
= (WNDPROC
)GetWindowLongPtrA( hwnd
, GWLP_WNDPROC
);
8425 lRes
= CallWindowProcA( newproc
, hwnd
, WM_GETTEXTLENGTH
, 0, 0 );
8426 ok( lRes
== WideCharToMultiByte( CP_ACP
, 0, dummy_window_text
, lstrlenW(dummy_window_text
),
8427 NULL
, 0, NULL
, NULL
) ||
8428 broken(lRes
== lstrlenW(dummy_window_text
) + 37),
8429 "got bad length %ld\n", lRes
);
8431 SetWindowLongPtrW( hwnd
, GWLP_WNDPROC
, (LONG_PTR
)wndproc
); /* restore old wnd proc */
8432 lRes
= CallWindowProcA( newproc
, hwnd
, WM_GETTEXTLENGTH
, 0, 0 );
8433 ok( lRes
== WideCharToMultiByte( CP_ACP
, 0, dummy_window_text
, lstrlenW(dummy_window_text
),
8434 NULL
, 0, NULL
, NULL
) ||
8435 broken(lRes
== lstrlenW(dummy_window_text
) + 37),
8436 "got bad length %ld\n", lRes
);
8438 ret
= DestroyWindow(hwnd
);
8439 ok( ret
, "DestroyWindow() error %d\n", GetLastError());
8449 static VOID CALLBACK
tfunc(HWND hwnd
, UINT uMsg
, UINT_PTR id
, DWORD dwTime
)
8453 #define TIMER_ID 0x19
8454 #define TIMER_COUNT_EXPECTED 100
8455 #define TIMER_COUNT_TOLERANCE 10
8457 static int count
= 0;
8458 static void CALLBACK
callback_count(HWND hwnd
, UINT uMsg
, UINT_PTR idEvent
, DWORD dwTime
)
8463 static DWORD exception
;
8464 static void CALLBACK
callback_exception(HWND hwnd
, UINT uMsg
, UINT_PTR idEvent
, DWORD dwTime
)
8467 RaiseException(exception
, 0, 0, NULL
);
8470 static DWORD WINAPI
timer_thread_proc(LPVOID x
)
8472 struct timer_info
*info
= x
;
8475 r
= KillTimer(info
->hWnd
, 0x19);
8476 ok(r
,"KillTimer failed in thread\n");
8477 r
= SetTimer(info
->hWnd
,TIMER_ID
,10000,tfunc
);
8478 ok(r
,"SetTimer failed in thread\n");
8479 ok(r
==TIMER_ID
,"SetTimer id different\n");
8480 r
= SetEvent(info
->handles
[0]);
8481 ok(r
,"SetEvent failed in thread\n");
8485 static void test_timers(void)
8487 struct timer_info info
;
8492 info
.hWnd
= CreateWindowA("TestWindowClass", NULL
,
8493 WS_OVERLAPPEDWINDOW
,
8494 CW_USEDEFAULT
, CW_USEDEFAULT
, 300, 300, 0,
8497 info
.id
= SetTimer(info
.hWnd
,TIMER_ID
,10000,tfunc
);
8498 ok(info
.id
, "SetTimer failed\n");
8499 ok(info
.id
==TIMER_ID
, "SetTimer timer ID different\n");
8500 info
.handles
[0] = CreateEventW(NULL
,0,0,NULL
);
8501 info
.handles
[1] = CreateThread(NULL
,0,timer_thread_proc
,&info
,0,&id
);
8503 WaitForMultipleObjects(2, info
.handles
, FALSE
, INFINITE
);
8505 WaitForSingleObject(info
.handles
[1], INFINITE
);
8507 CloseHandle(info
.handles
[0]);
8508 CloseHandle(info
.handles
[1]);
8510 ok( KillTimer(info
.hWnd
, TIMER_ID
), "KillTimer failed\n");
8512 /* Check the minimum allowed timeout for a timer. MSDN indicates that it should be 10.0 ms,
8513 * which occurs sometimes, but most testing on the VMs indicates a minimum timeout closer to
8514 * 15.6 ms. Since there is some measurement error between test runs we are allowing for
8515 * ±9 counts (~4 ms) around the expected value.
8518 id
= SetTimer(info
.hWnd
, TIMER_ID
, 0, callback_count
);
8519 ok(id
!= 0, "did not get id from SetTimer.\n");
8520 ok(id
==TIMER_ID
, "SetTimer timer ID different\n");
8521 start
= GetTickCount();
8522 while (GetTickCount()-start
< 1001 && GetMessageA(&msg
, info
.hWnd
, 0, 0))
8523 DispatchMessageA(&msg
);
8524 ok(abs(count
-TIMER_COUNT_EXPECTED
) < TIMER_COUNT_TOLERANCE
/* xp */
8525 || broken(abs(count
-64) < TIMER_COUNT_TOLERANCE
) /* most common */
8526 || broken(abs(count
-43) < TIMER_COUNT_TOLERANCE
) /* w2k3, win8 */,
8527 "did not get expected count for minimum timeout (%d != ~%d).\n",
8528 count
, TIMER_COUNT_EXPECTED
);
8529 ok(KillTimer(info
.hWnd
, id
), "KillTimer failed\n");
8530 /* Perform the same check on SetSystemTimer (only available on w2k3 and older) */
8531 if (pSetSystemTimer
)
8536 id
= pSetSystemTimer(info
.hWnd
, TIMER_ID
, 0, callback_count
);
8537 ok(id
!= 0, "did not get id from SetSystemTimer.\n");
8538 ok(id
==TIMER_ID
, "SetTimer timer ID different\n");
8539 start
= GetTickCount();
8540 while (GetTickCount()-start
< 1001 && GetMessageA(&msg
, info
.hWnd
, 0, 0))
8542 if (msg
.message
== WM_SYSTIMER
)
8544 DispatchMessageA(&msg
);
8546 ok(abs(syscount
-TIMER_COUNT_EXPECTED
) < TIMER_COUNT_TOLERANCE
8547 || broken(abs(syscount
-64) < TIMER_COUNT_TOLERANCE
) /* most common */
8548 || broken(syscount
> 4000 && syscount
< 12000) /* win2k3sp0 */,
8549 "did not get expected count for minimum timeout (%d != ~%d).\n",
8550 syscount
, TIMER_COUNT_EXPECTED
);
8551 todo_wine
ok(count
== 0, "did not get expected count for callback timeout (%d != 0).\n",
8553 ok(pKillSystemTimer(info
.hWnd
, id
), "KillSystemTimer failed\n");
8556 ok(DestroyWindow(info
.hWnd
), "failed to destroy window\n");
8559 static void test_timers_no_wnd(void)
8566 id
= SetTimer(NULL
, 0, 100, callback_count
);
8567 ok(id
!= 0, "did not get id from SetTimer.\n");
8568 id2
= SetTimer(NULL
, id
, 200, callback_count
);
8569 ok(id2
== id
, "did not get same id from SetTimer when replacing (%li expected %li).\n", id2
, id
);
8571 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
8572 ok(count
== 0, "did not get zero count as expected (%i).\n", count
);
8574 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
8575 ok(count
== 1, "did not get one count as expected (%i).\n", count
);
8576 KillTimer(NULL
, id
);
8578 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
8579 ok(count
== 1, "killing replaced timer did not work (%i).\n", count
);
8581 /* Check the minimum allowed timeout for a timer. MSDN indicates that it should be 10.0 ms,
8582 * which occurs sometimes, but most testing on the VMs indicates a minimum timeout closer to
8583 * 15.6 ms. Since there is some measurement error between test runs we are allowing for
8584 * ±9 counts (~4 ms) around the expected value.
8587 id
= SetTimer(NULL
, 0, 0, callback_count
);
8588 ok(id
!= 0, "did not get id from SetTimer.\n");
8589 start
= GetTickCount();
8590 while (GetTickCount()-start
< 1001 && GetMessageA(&msg
, NULL
, 0, 0))
8591 DispatchMessageA(&msg
);
8592 ok(abs(count
-TIMER_COUNT_EXPECTED
) < TIMER_COUNT_TOLERANCE
/* xp */
8593 || broken(abs(count
-64) < TIMER_COUNT_TOLERANCE
) /* most common */,
8594 "did not get expected count for minimum timeout (%d != ~%d).\n",
8595 count
, TIMER_COUNT_EXPECTED
);
8596 KillTimer(NULL
, id
);
8597 /* Note: SetSystemTimer doesn't support a NULL window, see test_timers */
8600 static void test_timers_exception(DWORD code
)
8606 id
= SetTimer(NULL
, 0, 1000, callback_exception
);
8607 ok(id
!= 0, "did not get id from SetTimer.\n");
8609 memset(&msg
, 0, sizeof(msg
));
8610 msg
.message
= WM_TIMER
;
8612 msg
.lParam
= (LPARAM
)callback_exception
;
8615 DispatchMessageA(&msg
);
8616 ok(count
== 1, "did not get one count as expected (%i).\n", count
);
8618 KillTimer(NULL
, id
);
8621 static void test_timers_exceptions(void)
8623 test_timers_exception(EXCEPTION_ACCESS_VIOLATION
);
8624 test_timers_exception(EXCEPTION_DATATYPE_MISALIGNMENT
);
8625 test_timers_exception(EXCEPTION_BREAKPOINT
);
8626 test_timers_exception(EXCEPTION_SINGLE_STEP
);
8627 test_timers_exception(EXCEPTION_ARRAY_BOUNDS_EXCEEDED
);
8628 test_timers_exception(EXCEPTION_FLT_DENORMAL_OPERAND
);
8629 test_timers_exception(EXCEPTION_FLT_DIVIDE_BY_ZERO
);
8630 test_timers_exception(EXCEPTION_FLT_INEXACT_RESULT
);
8631 test_timers_exception(EXCEPTION_ILLEGAL_INSTRUCTION
);
8632 test_timers_exception(0xE000BEEF); /* customer exception */
8635 /* Various win events with arbitrary parameters */
8636 static const struct message WmWinEventsSeq
[] = {
8637 { EVENT_SYSTEM_SOUND
, winevent_hook
|wparam
|lparam
, OBJID_WINDOW
, 0 },
8638 { EVENT_SYSTEM_ALERT
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 1 },
8639 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, OBJID_TITLEBAR
, 2 },
8640 { EVENT_SYSTEM_MENUSTART
, winevent_hook
|wparam
|lparam
, OBJID_MENU
, 3 },
8641 { EVENT_SYSTEM_MENUEND
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 4 },
8642 { EVENT_SYSTEM_MENUPOPUPSTART
, winevent_hook
|wparam
|lparam
, OBJID_VSCROLL
, 5 },
8643 { EVENT_SYSTEM_MENUPOPUPEND
, winevent_hook
|wparam
|lparam
, OBJID_HSCROLL
, 6 },
8644 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, OBJID_SIZEGRIP
, 7 },
8645 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 8 },
8646 /* our win event hook ignores OBJID_CURSOR events */
8647 /*{ EVENT_SYSTEM_MOVESIZESTART, winevent_hook|wparam|lparam, OBJID_CURSOR, 9 },*/
8648 { EVENT_SYSTEM_MOVESIZEEND
, winevent_hook
|wparam
|lparam
, OBJID_ALERT
, 10 },
8649 { EVENT_SYSTEM_CONTEXTHELPSTART
, winevent_hook
|wparam
|lparam
, OBJID_SOUND
, 11 },
8650 { EVENT_SYSTEM_CONTEXTHELPEND
, winevent_hook
|wparam
|lparam
, OBJID_QUERYCLASSNAMEIDX
, 12 },
8651 { EVENT_SYSTEM_DRAGDROPSTART
, winevent_hook
|wparam
|lparam
, OBJID_NATIVEOM
, 13 },
8652 { EVENT_SYSTEM_DRAGDROPEND
, winevent_hook
|wparam
|lparam
, OBJID_WINDOW
, 0 },
8653 { EVENT_SYSTEM_DIALOGSTART
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 1 },
8654 { EVENT_SYSTEM_DIALOGEND
, winevent_hook
|wparam
|lparam
, OBJID_TITLEBAR
, 2 },
8655 { EVENT_SYSTEM_SCROLLINGSTART
, winevent_hook
|wparam
|lparam
, OBJID_MENU
, 3 },
8656 { EVENT_SYSTEM_SCROLLINGEND
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 4 },
8657 { EVENT_SYSTEM_SWITCHSTART
, winevent_hook
|wparam
|lparam
, OBJID_VSCROLL
, 5 },
8658 { EVENT_SYSTEM_SWITCHEND
, winevent_hook
|wparam
|lparam
, OBJID_HSCROLL
, 6 },
8659 { EVENT_SYSTEM_MINIMIZESTART
, winevent_hook
|wparam
|lparam
, OBJID_SIZEGRIP
, 7 },
8660 { EVENT_SYSTEM_MINIMIZEEND
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 8 },
8663 static const struct message WmWinEventCaretSeq
[] = {
8664 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 1 */
8665 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 1 */
8666 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 2 */
8667 { EVENT_OBJECT_NAMECHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 1 */
8670 static const struct message WmWinEventCaretSeq_2
[] = {
8671 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 1/2 */
8672 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 1/2 */
8673 { EVENT_OBJECT_NAMECHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 1/2 */
8676 static const struct message WmWinEventAlertSeq
[] = {
8677 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_ALERT
, 0 },
8680 static const struct message WmWinEventAlertSeq_2
[] = {
8681 /* create window in the thread proc */
8682 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_WINDOW
, 2 },
8683 /* our test event */
8684 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_ALERT
, 2 },
8687 static const struct message WmGlobalHookSeq_1
[] = {
8688 /* create window in the thread proc */
8689 { HCBT_CREATEWND
, hook
|lparam
, 0, 2 },
8690 /* our test events */
8691 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_PREVWINDOW
, 2 },
8692 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_NEXTWINDOW
, 2 },
8695 static const struct message WmGlobalHookSeq_2
[] = {
8696 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_NEXTWINDOW
, 0 }, /* old local hook */
8697 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_NEXTWINDOW
, 2 }, /* new global hook */
8698 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_PREVWINDOW
, 0 }, /* old local hook */
8699 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_PREVWINDOW
, 2 }, /* new global hook */
8703 static const struct message WmMouseLLHookSeq
[] = {
8704 { WM_MOUSEMOVE
, hook
},
8705 { WM_LBUTTONUP
, hook
},
8706 { WM_MOUSEMOVE
, hook
},
8710 static void CALLBACK
win_event_global_hook_proc(HWINEVENTHOOK hevent
,
8720 if (GetClassNameA(hwnd
, buf
, sizeof(buf
)))
8722 if (!lstrcmpiA(buf
, "TestWindowClass") ||
8723 !lstrcmpiA(buf
, "static"))
8725 struct recvd_message msg
;
8728 msg
.message
= event
;
8729 msg
.flags
= winevent_hook
|wparam
|lparam
;
8730 msg
.wParam
= object_id
;
8731 msg
.lParam
= (thread_id
== GetCurrentThreadId()) ? child_id
: (child_id
+ 2);
8732 msg
.descr
= "WEH_2";
8738 static HHOOK hCBT_global_hook
;
8739 static DWORD cbt_global_hook_thread_id
;
8741 static LRESULT CALLBACK
cbt_global_hook_proc(int nCode
, WPARAM wParam
, LPARAM lParam
)
8746 if (nCode
== HCBT_SYSCOMMAND
)
8748 struct recvd_message msg
;
8751 msg
.message
= nCode
;
8752 msg
.flags
= hook
|wparam
|lparam
;
8753 msg
.wParam
= wParam
;
8754 msg
.lParam
= (cbt_global_hook_thread_id
== GetCurrentThreadId()) ? 1 : 2;
8755 msg
.descr
= "CBT_2";
8758 return CallNextHookEx(hCBT_global_hook
, nCode
, wParam
, lParam
);
8760 /* WH_MOUSE_LL hook */
8761 if (nCode
== HC_ACTION
)
8763 MSLLHOOKSTRUCT
*mhll
= (MSLLHOOKSTRUCT
*)lParam
;
8765 /* we can't test for real mouse events */
8766 if (mhll
->flags
& LLMHF_INJECTED
)
8768 struct recvd_message msg
;
8770 memset (&msg
, 0, sizeof (msg
));
8771 msg
.message
= wParam
;
8773 msg
.descr
= "CBT_2";
8776 return CallNextHookEx(hCBT_global_hook
, nCode
, wParam
, lParam
);
8779 /* Log also SetFocus(0) calls */
8780 hwnd
= wParam
? (HWND
)wParam
: (HWND
)lParam
;
8782 if (GetClassNameA(hwnd
, buf
, sizeof(buf
)))
8784 if (!lstrcmpiA(buf
, "TestWindowClass") ||
8785 !lstrcmpiA(buf
, "static"))
8787 struct recvd_message msg
;
8790 msg
.message
= nCode
;
8791 msg
.flags
= hook
|wparam
|lparam
;
8792 msg
.wParam
= wParam
;
8793 msg
.lParam
= (cbt_global_hook_thread_id
== GetCurrentThreadId()) ? 1 : 2;
8794 msg
.descr
= "CBT_2";
8798 return CallNextHookEx(hCBT_global_hook
, nCode
, wParam
, lParam
);
8801 static DWORD WINAPI
win_event_global_thread_proc(void *param
)
8805 HANDLE hevent
= *(HANDLE
*)param
;
8807 assert(pNotifyWinEvent
);
8809 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
, 0,0,0,0,0,0,0, NULL
);
8811 trace("created thread window %p\n", hwnd
);
8813 *(HWND
*)param
= hwnd
;
8816 /* this event should be received only by our new hook proc,
8817 * an old one does not expect an event from another thread.
8819 pNotifyWinEvent(EVENT_OBJECT_LOCATIONCHANGE
, hwnd
, OBJID_ALERT
, 0);
8822 while (GetMessageA(&msg
, 0, 0, 0))
8824 TranslateMessage(&msg
);
8825 DispatchMessageA(&msg
);
8830 static DWORD WINAPI
cbt_global_hook_thread_proc(void *param
)
8834 HANDLE hevent
= *(HANDLE
*)param
;
8837 /* these events should be received only by our new hook proc,
8838 * an old one does not expect an event from another thread.
8841 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
, 0,0,0,0,0,0,0, NULL
);
8843 trace("created thread window %p\n", hwnd
);
8845 *(HWND
*)param
= hwnd
;
8847 /* Windows doesn't like when a thread plays games with the focus,
8848 that leads to all kinds of misbehaviours and failures to activate
8849 a window. So, better keep next lines commented out.
8853 DefWindowProcA(hwnd
, WM_SYSCOMMAND
, SC_PREVWINDOW
, 0);
8854 DefWindowProcA(hwnd
, WM_SYSCOMMAND
, SC_NEXTWINDOW
, 0);
8858 while (GetMessageA(&msg
, 0, 0, 0))
8860 TranslateMessage(&msg
);
8861 DispatchMessageA(&msg
);
8866 static DWORD WINAPI
mouse_ll_global_thread_proc(void *param
)
8870 HANDLE hevent
= *(HANDLE
*)param
;
8872 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
, 0,0,0,0,0,0,0, NULL
);
8874 trace("created thread window %p\n", hwnd
);
8876 *(HWND
*)param
= hwnd
;
8880 /* Windows doesn't like when a thread plays games with the focus,
8881 * that leads to all kinds of misbehaviours and failures to activate
8882 * a window. So, better don't generate a mouse click message below.
8884 mouse_event(MOUSEEVENTF_MOVE
, -1, 0, 0, 0);
8885 mouse_event(MOUSEEVENTF_LEFTUP
, 0, 0, 0, 0);
8886 mouse_event(MOUSEEVENTF_MOVE
, 1, 0, 0, 0);
8889 while (GetMessageA(&msg
, 0, 0, 0))
8891 TranslateMessage(&msg
);
8892 DispatchMessageA(&msg
);
8897 static void test_winevents(void)
8903 HANDLE hthread
, hevent
;
8905 HWINEVENTHOOK hhook
;
8906 const struct message
*events
= WmWinEventsSeq
;
8908 hwnd
= CreateWindowExA(0, "TestWindowClass", NULL
,
8909 WS_OVERLAPPEDWINDOW
,
8910 CW_USEDEFAULT
, CW_USEDEFAULT
, 300, 300, 0,
8914 /****** start of global hook test *************/
8915 hCBT_global_hook
= SetWindowsHookExA(WH_CBT
, cbt_global_hook_proc
, GetModuleHandleA(0), 0);
8916 if (!hCBT_global_hook
)
8918 ok(DestroyWindow(hwnd
), "failed to destroy window\n");
8919 skip( "cannot set global hook\n" );
8923 hevent
= CreateEventA(NULL
, 0, 0, NULL
);
8927 hthread
= CreateThread(NULL
, 0, cbt_global_hook_thread_proc
, &hwnd2
, 0, &tid
);
8928 ok(hthread
!= NULL
, "CreateThread failed, error %d\n", GetLastError());
8930 ok(WaitForSingleObject(hevent
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
8932 ok_sequence(WmGlobalHookSeq_1
, "global hook 1", FALSE
);
8935 /* this one should be received only by old hook proc */
8936 DefWindowProcA(hwnd
, WM_SYSCOMMAND
, SC_NEXTWINDOW
, 0);
8937 /* this one should be received only by old hook proc */
8938 DefWindowProcA(hwnd
, WM_SYSCOMMAND
, SC_PREVWINDOW
, 0);
8940 ok_sequence(WmGlobalHookSeq_2
, "global hook 2", FALSE
);
8942 ret
= UnhookWindowsHookEx(hCBT_global_hook
);
8943 ok( ret
, "UnhookWindowsHookEx error %d\n", GetLastError());
8945 PostThreadMessageA(tid
, WM_QUIT
, 0, 0);
8946 ok(WaitForSingleObject(hthread
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
8947 CloseHandle(hthread
);
8948 CloseHandle(hevent
);
8949 ok(!IsWindow(hwnd2
), "window should be destroyed on thread exit\n");
8950 /****** end of global hook test *************/
8952 if (!pSetWinEventHook
|| !pNotifyWinEvent
|| !pUnhookWinEvent
)
8954 ok(DestroyWindow(hwnd
), "failed to destroy window\n");
8962 /* this test doesn't pass under Win9x */
8963 /* win2k ignores events with hwnd == 0 */
8964 SetLastError(0xdeadbeef);
8965 pNotifyWinEvent(events
[0].message
, 0, events
[0].wParam
, events
[0].lParam
);
8966 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
|| /* Win2k */
8967 GetLastError() == 0xdeadbeef, /* Win9x */
8968 "unexpected error %d\n", GetLastError());
8969 ok_sequence(WmEmptySeq
, "empty notify winevents", FALSE
);
8972 for (i
= 0; i
< sizeof(WmWinEventsSeq
)/sizeof(WmWinEventsSeq
[0]); i
++)
8973 pNotifyWinEvent(events
[i
].message
, hwnd
, events
[i
].wParam
, events
[i
].lParam
);
8975 ok_sequence(WmWinEventsSeq
, "notify winevents", FALSE
);
8977 /****** start of event filtering test *************/
8978 hhook
= pSetWinEventHook(
8979 EVENT_OBJECT_SHOW
, /* 0x8002 */
8980 EVENT_OBJECT_LOCATIONCHANGE
, /* 0x800B */
8981 GetModuleHandleA(0), win_event_global_hook_proc
,
8982 GetCurrentProcessId(), 0,
8983 WINEVENT_INCONTEXT
);
8984 ok(hhook
!= 0, "SetWinEventHook error %d\n", GetLastError());
8986 hevent
= CreateEventA(NULL
, 0, 0, NULL
);
8990 hthread
= CreateThread(NULL
, 0, win_event_global_thread_proc
, &hwnd2
, 0, &tid
);
8991 ok(hthread
!= NULL
, "CreateThread failed, error %d\n", GetLastError());
8993 ok(WaitForSingleObject(hevent
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
8995 ok_sequence(WmWinEventAlertSeq
, "alert winevent", FALSE
);
8998 /* this one should be received only by old hook proc */
8999 pNotifyWinEvent(EVENT_OBJECT_CREATE
, hwnd
, OBJID_CARET
, 0); /* 0x8000 */
9000 pNotifyWinEvent(EVENT_OBJECT_SHOW
, hwnd
, OBJID_CARET
, 0); /* 0x8002 */
9001 /* this one should be received only by old hook proc */
9002 pNotifyWinEvent(EVENT_OBJECT_NAMECHANGE
, hwnd
, OBJID_CARET
, 0); /* 0x800C */
9004 ok_sequence(WmWinEventCaretSeq
, "caret winevent", FALSE
);
9006 ret
= pUnhookWinEvent(hhook
);
9007 ok( ret
, "UnhookWinEvent error %d\n", GetLastError());
9009 PostThreadMessageA(tid
, WM_QUIT
, 0, 0);
9010 ok(WaitForSingleObject(hthread
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
9011 CloseHandle(hthread
);
9012 CloseHandle(hevent
);
9013 ok(!IsWindow(hwnd2
), "window should be destroyed on thread exit\n");
9014 /****** end of event filtering test *************/
9016 /****** start of out of context event test *************/
9017 hhook
= pSetWinEventHook(EVENT_MIN
, EVENT_MAX
, 0,
9018 win_event_global_hook_proc
, GetCurrentProcessId(), 0,
9019 WINEVENT_OUTOFCONTEXT
);
9020 ok(hhook
!= 0, "SetWinEventHook error %d\n", GetLastError());
9022 hevent
= CreateEventA(NULL
, 0, 0, NULL
);
9028 hthread
= CreateThread(NULL
, 0, win_event_global_thread_proc
, &hwnd2
, 0, &tid
);
9029 ok(hthread
!= NULL
, "CreateThread failed, error %d\n", GetLastError());
9031 ok(WaitForSingleObject(hevent
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
9033 ok_sequence(WmEmptySeq
, "empty notify winevents", FALSE
);
9034 /* process pending winevent messages */
9035 ok(!PeekMessageA(&msg
, 0, 0, 0, PM_NOREMOVE
), "msg queue should be empty\n");
9036 ok_sequence(WmWinEventAlertSeq_2
, "alert winevent for out of context proc", FALSE
);
9039 /* this one should be received only by old hook proc */
9040 pNotifyWinEvent(EVENT_OBJECT_CREATE
, hwnd
, OBJID_CARET
, 0); /* 0x8000 */
9041 pNotifyWinEvent(EVENT_OBJECT_SHOW
, hwnd
, OBJID_CARET
, 0); /* 0x8002 */
9042 /* this one should be received only by old hook proc */
9043 pNotifyWinEvent(EVENT_OBJECT_NAMECHANGE
, hwnd
, OBJID_CARET
, 0); /* 0x800C */
9045 ok_sequence(WmWinEventCaretSeq_2
, "caret winevent for incontext proc", FALSE
);
9046 /* process pending winevent messages */
9047 ok(!PeekMessageA(&msg
, 0, 0, 0, PM_NOREMOVE
), "msg queue should be empty\n");
9048 ok_sequence(WmWinEventCaretSeq_2
, "caret winevent for out of context proc", FALSE
);
9050 ret
= pUnhookWinEvent(hhook
);
9051 ok( ret
, "UnhookWinEvent error %d\n", GetLastError());
9053 PostThreadMessageA(tid
, WM_QUIT
, 0, 0);
9054 ok(WaitForSingleObject(hthread
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
9055 CloseHandle(hthread
);
9056 CloseHandle(hevent
);
9057 ok(!IsWindow(hwnd2
), "window should be destroyed on thread exit\n");
9058 /****** end of out of context event test *************/
9060 /****** start of MOUSE_LL hook test *************/
9061 hCBT_global_hook
= SetWindowsHookExA(WH_MOUSE_LL
, cbt_global_hook_proc
, GetModuleHandleA(0), 0);
9062 /* WH_MOUSE_LL is not supported on Win9x platforms */
9063 if (!hCBT_global_hook
)
9065 win_skip("Skipping WH_MOUSE_LL test on this platform\n");
9066 goto skip_mouse_ll_hook_test
;
9069 hevent
= CreateEventA(NULL
, 0, 0, NULL
);
9073 hthread
= CreateThread(NULL
, 0, mouse_ll_global_thread_proc
, &hwnd2
, 0, &tid
);
9074 ok(hthread
!= NULL
, "CreateThread failed, error %d\n", GetLastError());
9076 while (WaitForSingleObject(hevent
, 100) == WAIT_TIMEOUT
)
9077 while (PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA( &msg
);
9079 ok_sequence(WmMouseLLHookSeq
, "MOUSE_LL hook other thread", FALSE
);
9082 mouse_event(MOUSEEVENTF_MOVE
, -1, 0, 0, 0);
9083 mouse_event(MOUSEEVENTF_LEFTUP
, 0, 0, 0, 0);
9084 mouse_event(MOUSEEVENTF_MOVE
, 1, 0, 0, 0);
9086 ok_sequence(WmMouseLLHookSeq
, "MOUSE_LL hook same thread", FALSE
);
9088 ret
= UnhookWindowsHookEx(hCBT_global_hook
);
9089 ok( ret
, "UnhookWindowsHookEx error %d\n", GetLastError());
9091 PostThreadMessageA(tid
, WM_QUIT
, 0, 0);
9092 ok(WaitForSingleObject(hthread
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
9093 CloseHandle(hthread
);
9094 CloseHandle(hevent
);
9095 ok(!IsWindow(hwnd2
), "window should be destroyed on thread exit\n");
9096 /****** end of MOUSE_LL hook test *************/
9097 skip_mouse_ll_hook_test
:
9099 ok(DestroyWindow(hwnd
), "failed to destroy window\n");
9102 static void test_set_hook(void)
9106 HWINEVENTHOOK hwinevent_hook
;
9108 hhook
= SetWindowsHookExA(WH_CBT
, cbt_hook_proc
, GetModuleHandleA(0), GetCurrentThreadId());
9109 ok(hhook
!= 0, "local hook does not require hModule set to 0\n");
9110 UnhookWindowsHookEx(hhook
);
9114 /* this test doesn't pass under Win9x: BUG! */
9115 SetLastError(0xdeadbeef);
9116 hhook
= SetWindowsHookExA(WH_CBT
, cbt_hook_proc
, 0, 0);
9117 ok(!hhook
, "global hook requires hModule != 0\n");
9118 ok(GetLastError() == ERROR_HOOK_NEEDS_HMOD
, "unexpected error %d\n", GetLastError());
9121 SetLastError(0xdeadbeef);
9122 hhook
= SetWindowsHookExA(WH_CBT
, 0, GetModuleHandleA(0), GetCurrentThreadId());
9123 ok(!hhook
, "SetWinEventHook with invalid proc should fail\n");
9124 ok(GetLastError() == ERROR_INVALID_FILTER_PROC
|| /* Win2k */
9125 GetLastError() == 0xdeadbeef, /* Win9x */
9126 "unexpected error %d\n", GetLastError());
9128 SetLastError(0xdeadbeef);
9129 ok(!UnhookWindowsHookEx((HHOOK
)0xdeadbeef), "UnhookWindowsHookEx succeeded\n");
9130 ok(GetLastError() == ERROR_INVALID_HOOK_HANDLE
|| /* Win2k */
9131 GetLastError() == 0xdeadbeef, /* Win9x */
9132 "unexpected error %d\n", GetLastError());
9134 if (!pSetWinEventHook
|| !pUnhookWinEvent
) return;
9136 /* even process local incontext hooks require hmodule */
9137 SetLastError(0xdeadbeef);
9138 hwinevent_hook
= pSetWinEventHook(EVENT_MIN
, EVENT_MAX
, 0, win_event_proc
,
9139 GetCurrentProcessId(), 0, WINEVENT_INCONTEXT
);
9140 ok(!hwinevent_hook
, "WINEVENT_INCONTEXT requires hModule != 0\n");
9141 ok(GetLastError() == ERROR_HOOK_NEEDS_HMOD
|| /* Win2k */
9142 GetLastError() == 0xdeadbeef, /* Win9x */
9143 "unexpected error %d\n", GetLastError());
9145 /* even thread local incontext hooks require hmodule */
9146 SetLastError(0xdeadbeef);
9147 hwinevent_hook
= pSetWinEventHook(EVENT_MIN
, EVENT_MAX
, 0, win_event_proc
,
9148 GetCurrentProcessId(), GetCurrentThreadId(), WINEVENT_INCONTEXT
);
9149 ok(!hwinevent_hook
, "WINEVENT_INCONTEXT requires hModule != 0\n");
9150 ok(GetLastError() == ERROR_HOOK_NEEDS_HMOD
|| /* Win2k */
9151 GetLastError() == 0xdeadbeef, /* Win9x */
9152 "unexpected error %d\n", GetLastError());
9156 /* these 3 tests don't pass under Win9x */
9157 SetLastError(0xdeadbeef);
9158 hwinevent_hook
= pSetWinEventHook(1, 0, 0, win_event_proc
,
9159 GetCurrentProcessId(), 0, WINEVENT_OUTOFCONTEXT
);
9160 ok(!hwinevent_hook
, "SetWinEventHook with invalid event range should fail\n");
9161 ok(GetLastError() == ERROR_INVALID_HOOK_FILTER
, "unexpected error %d\n", GetLastError());
9163 SetLastError(0xdeadbeef);
9164 hwinevent_hook
= pSetWinEventHook(-1, 1, 0, win_event_proc
,
9165 GetCurrentProcessId(), 0, WINEVENT_OUTOFCONTEXT
);
9166 ok(!hwinevent_hook
, "SetWinEventHook with invalid event range should fail\n");
9167 ok(GetLastError() == ERROR_INVALID_HOOK_FILTER
, "unexpected error %d\n", GetLastError());
9169 SetLastError(0xdeadbeef);
9170 hwinevent_hook
= pSetWinEventHook(EVENT_MIN
, EVENT_MAX
, 0, win_event_proc
,
9171 0, 0xdeadbeef, WINEVENT_OUTOFCONTEXT
);
9172 ok(!hwinevent_hook
, "SetWinEventHook with invalid tid should fail\n");
9173 ok(GetLastError() == ERROR_INVALID_THREAD_ID
, "unexpected error %d\n", GetLastError());
9176 SetLastError(0xdeadbeef);
9177 hwinevent_hook
= pSetWinEventHook(0, 0, 0, win_event_proc
,
9178 GetCurrentProcessId(), 0, WINEVENT_OUTOFCONTEXT
);
9179 ok(hwinevent_hook
!= 0, "SetWinEventHook error %d\n", GetLastError());
9180 ok(GetLastError() == 0xdeadbeef, "unexpected error %d\n", GetLastError());
9181 ret
= pUnhookWinEvent(hwinevent_hook
);
9182 ok( ret
, "UnhookWinEvent error %d\n", GetLastError());
9185 /* This call succeeds under win2k SP4, but fails under Wine.
9186 Does win2k test/use passed process id? */
9187 SetLastError(0xdeadbeef);
9188 hwinevent_hook
= pSetWinEventHook(EVENT_MIN
, EVENT_MAX
, 0, win_event_proc
,
9189 0xdeadbeef, 0, WINEVENT_OUTOFCONTEXT
);
9190 ok(hwinevent_hook
!= 0, "SetWinEventHook error %d\n", GetLastError());
9191 ok(GetLastError() == 0xdeadbeef, "unexpected error %d\n", GetLastError());
9192 ret
= pUnhookWinEvent(hwinevent_hook
);
9193 ok( ret
, "UnhookWinEvent error %d\n", GetLastError());
9196 SetLastError(0xdeadbeef);
9197 ok(!pUnhookWinEvent((HWINEVENTHOOK
)0xdeadbeef), "UnhookWinEvent succeeded\n");
9198 ok(GetLastError() == ERROR_INVALID_HANDLE
|| /* Win2k */
9199 GetLastError() == 0xdeadbeef, /* Win9x */
9200 "unexpected error %d\n", GetLastError());
9203 static HWND hook_hwnd
;
9204 static HHOOK recursive_hook
;
9205 static int hook_depth
, max_hook_depth
;
9207 static LRESULT WINAPI
rec_get_message_hook(int code
, WPARAM w
, LPARAM l
)
9214 if(hook_depth
> max_hook_depth
)
9215 max_hook_depth
= hook_depth
;
9217 b
= PeekMessageW(&msg
, hook_hwnd
, 0, 0, PM_NOREMOVE
);
9218 ok(b
, "PeekMessage failed\n");
9220 res
= CallNextHookEx(recursive_hook
, code
, w
, l
);
9226 static void test_recursive_hook(void)
9231 hook_hwnd
= CreateWindowA("Static", NULL
, WS_POPUP
, 0, 0, 200, 60, NULL
, NULL
, NULL
, NULL
);
9232 ok(hook_hwnd
!= NULL
, "CreateWindow failed\n");
9234 recursive_hook
= SetWindowsHookExW(WH_GETMESSAGE
, rec_get_message_hook
, NULL
, GetCurrentThreadId());
9235 ok(recursive_hook
!= NULL
, "SetWindowsHookEx failed\n");
9237 PostMessageW(hook_hwnd
, WM_USER
, 0, 0);
9238 PostMessageW(hook_hwnd
, WM_USER
+1, 0, 0);
9241 GetMessageW(&msg
, hook_hwnd
, 0, 0);
9242 ok(15 < max_hook_depth
&& max_hook_depth
< 45, "max_hook_depth = %d\n", max_hook_depth
);
9243 trace("max_hook_depth = %d\n", max_hook_depth
);
9245 b
= UnhookWindowsHookEx(recursive_hook
);
9246 ok(b
, "UnhokWindowsHookEx failed\n");
9248 DestroyWindow(hook_hwnd
);
9251 static const struct message ScrollWindowPaint1
[] = {
9253 { WM_ERASEBKGND
, sent
|beginpaint
},
9254 { WM_GETTEXTLENGTH
, sent
|optional
},
9255 { WM_PAINT
, sent
|optional
},
9256 { WM_NCPAINT
, sent
|beginpaint
|optional
},
9257 { WM_GETTEXT
, sent
|beginpaint
|optional
},
9258 { WM_GETTEXT
, sent
|beginpaint
|optional
},
9259 { WM_GETTEXT
, sent
|beginpaint
|optional
},
9260 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
9261 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
9265 static const struct message ScrollWindowPaint2
[] = {
9270 static void test_scrollwindowex(void)
9273 RECT rect
={0,0,130,130};
9275 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test Scroll",
9276 WS_VISIBLE
|WS_OVERLAPPEDWINDOW
,
9277 100, 100, 200, 200, 0, 0, 0, NULL
);
9278 ok (hwnd
!= 0, "Failed to create overlapped window\n");
9279 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child",
9280 WS_VISIBLE
|WS_CAPTION
|WS_CHILD
,
9281 10, 10, 150, 150, hwnd
, 0, 0, NULL
);
9282 ok (hchild
!= 0, "Failed to create child\n");
9287 /* scroll without the child window */
9288 trace("start scroll\n");
9289 ScrollWindowEx( hwnd
, 10, 10, &rect
, NULL
, NULL
, NULL
,
9290 SW_ERASE
|SW_INVALIDATE
);
9291 ok_sequence(WmEmptySeq
, "ScrollWindowEx", FALSE
);
9292 trace("end scroll\n");
9295 ok_sequence(ScrollWindowPaint1
, "ScrollWindowEx", FALSE
);
9299 /* Now without the SW_ERASE flag */
9300 trace("start scroll\n");
9301 ScrollWindowEx( hwnd
, 10, 10, &rect
, NULL
, NULL
, NULL
, SW_INVALIDATE
);
9302 ok_sequence(WmEmptySeq
, "ScrollWindowEx", FALSE
);
9303 trace("end scroll\n");
9306 ok_sequence(ScrollWindowPaint2
, "ScrollWindowEx", FALSE
);
9310 /* now scroll the child window as well */
9311 trace("start scroll\n");
9312 ScrollWindowEx( hwnd
, 10, 10, &rect
, NULL
, NULL
, NULL
,
9313 SW_SCROLLCHILDREN
|SW_ERASE
|SW_INVALIDATE
);
9314 /* wine sends WM_POSCHANGING, WM_POSCHANGED messages */
9315 /* windows sometimes a WM_MOVE */
9316 ok_sequence(WmEmptySeq
, "ScrollWindowEx", TRUE
);
9317 trace("end scroll\n");
9320 ok_sequence(ScrollWindowPaint1
, "ScrollWindowEx", FALSE
);
9324 /* now scroll with ScrollWindow() */
9325 trace("start scroll with ScrollWindow\n");
9326 ScrollWindow( hwnd
, 5, 5, NULL
, NULL
);
9327 trace("end scroll\n");
9330 ok_sequence(ScrollWindowPaint1
, "ScrollWindow", FALSE
);
9332 ok(DestroyWindow(hchild
), "failed to destroy window\n");
9333 ok(DestroyWindow(hwnd
), "failed to destroy window\n");
9337 static const struct message destroy_window_with_children
[] = {
9338 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* popup */
9339 { HCBT_DESTROYWND
, hook
|lparam
, 0, WND_PARENT_ID
}, /* parent */
9340 { 0x0090, sent
|optional
},
9341 { HCBT_DESTROYWND
, hook
|lparam
, 0, WND_POPUP_ID
}, /* popup */
9342 { 0x0090, sent
|optional
},
9343 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* popup */
9344 { WM_DESTROY
, sent
|wparam
|lparam
, 0, WND_POPUP_ID
}, /* popup */
9345 { WM_CAPTURECHANGED
, sent
|wparam
|lparam
, 0, WND_POPUP_ID
}, /* popup */
9346 { WM_NCDESTROY
, sent
|wparam
|lparam
, 0, WND_POPUP_ID
}, /* popup */
9347 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* parent */
9348 { WM_DESTROY
, sent
|wparam
|lparam
, 0, WND_PARENT_ID
}, /* parent */
9349 { WM_DESTROY
, sent
|wparam
|lparam
, 0, WND_CHILD_ID
+ 2 }, /* child2 */
9350 { WM_DESTROY
, sent
|wparam
|lparam
, 0, WND_CHILD_ID
+ 1 }, /* child1 */
9351 { WM_DESTROY
, sent
|wparam
|lparam
, 0, WND_CHILD_ID
+ 3 }, /* child3 */
9352 { WM_NCDESTROY
, sent
|wparam
|lparam
, 0, WND_CHILD_ID
+ 2 }, /* child2 */
9353 { WM_NCDESTROY
, sent
|wparam
|lparam
, 0, WND_CHILD_ID
+ 3 }, /* child3 */
9354 { WM_NCDESTROY
, sent
|wparam
|lparam
, 0, WND_CHILD_ID
+ 1 }, /* child1 */
9355 { WM_NCDESTROY
, sent
|wparam
|lparam
, 0, WND_PARENT_ID
}, /* parent */
9359 static void test_DestroyWindow(void)
9362 HWND parent
, child1
, child2
, child3
, child4
, test
;
9363 UINT_PTR child_id
= WND_CHILD_ID
+ 1;
9365 parent
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
9366 100, 100, 200, 200, 0, 0, 0, NULL
);
9367 assert(parent
!= 0);
9368 child1
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_CHILD
,
9369 0, 0, 50, 50, parent
, (HMENU
)child_id
++, 0, NULL
);
9370 assert(child1
!= 0);
9371 child2
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_CHILD
,
9372 0, 0, 50, 50, GetDesktopWindow(), (HMENU
)child_id
++, 0, NULL
);
9373 assert(child2
!= 0);
9374 child3
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_CHILD
,
9375 0, 0, 50, 50, child1
, (HMENU
)child_id
++, 0, NULL
);
9376 assert(child3
!= 0);
9377 child4
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_POPUP
,
9378 0, 0, 50, 50, parent
, 0, 0, NULL
);
9379 assert(child4
!= 0);
9381 /* test owner/parent of child2 */
9382 test
= GetParent(child2
);
9383 ok(test
== GetDesktopWindow(), "wrong parent %p\n", test
);
9384 ok(!IsChild(parent
, child2
), "wrong parent/child %p/%p\n", parent
, child2
);
9386 test
= pGetAncestor(child2
, GA_PARENT
);
9387 ok(test
== GetDesktopWindow(), "wrong parent %p\n", test
);
9389 test
= GetWindow(child2
, GW_OWNER
);
9390 ok(!test
, "wrong owner %p\n", test
);
9392 test
= SetParent(child2
, parent
);
9393 ok(test
== GetDesktopWindow(), "wrong old parent %p\n", test
);
9395 /* test owner/parent of the parent */
9396 test
= GetParent(parent
);
9397 ok(!test
, "wrong parent %p\n", test
);
9398 ok(!IsChild(GetDesktopWindow(), parent
), "wrong parent/child %p/%p\n", GetDesktopWindow(), parent
);
9400 test
= pGetAncestor(parent
, GA_PARENT
);
9401 ok(test
== GetDesktopWindow(), "wrong parent %p\n", test
);
9403 test
= GetWindow(parent
, GW_OWNER
);
9404 ok(!test
, "wrong owner %p\n", test
);
9406 /* test owner/parent of child1 */
9407 test
= GetParent(child1
);
9408 ok(test
== parent
, "wrong parent %p\n", test
);
9409 ok(IsChild(parent
, child1
), "wrong parent/child %p/%p\n", parent
, child1
);
9411 test
= pGetAncestor(child1
, GA_PARENT
);
9412 ok(test
== parent
, "wrong parent %p\n", test
);
9414 test
= GetWindow(child1
, GW_OWNER
);
9415 ok(!test
, "wrong owner %p\n", test
);
9417 /* test owner/parent of child2 */
9418 test
= GetParent(child2
);
9419 ok(test
== parent
, "wrong parent %p\n", test
);
9420 ok(IsChild(parent
, child2
), "wrong parent/child %p/%p\n", parent
, child2
);
9422 test
= pGetAncestor(child2
, GA_PARENT
);
9423 ok(test
== parent
, "wrong parent %p\n", test
);
9425 test
= GetWindow(child2
, GW_OWNER
);
9426 ok(!test
, "wrong owner %p\n", test
);
9428 /* test owner/parent of child3 */
9429 test
= GetParent(child3
);
9430 ok(test
== child1
, "wrong parent %p\n", test
);
9431 ok(IsChild(parent
, child3
), "wrong parent/child %p/%p\n", parent
, child3
);
9433 test
= pGetAncestor(child3
, GA_PARENT
);
9434 ok(test
== child1
, "wrong parent %p\n", test
);
9436 test
= GetWindow(child3
, GW_OWNER
);
9437 ok(!test
, "wrong owner %p\n", test
);
9439 /* test owner/parent of child4 */
9440 test
= GetParent(child4
);
9441 ok(test
== parent
, "wrong parent %p\n", test
);
9442 ok(!IsChild(parent
, child4
), "wrong parent/child %p/%p\n", parent
, child4
);
9444 test
= pGetAncestor(child4
, GA_PARENT
);
9445 ok(test
== GetDesktopWindow(), "wrong parent %p\n", test
);
9447 test
= GetWindow(child4
, GW_OWNER
);
9448 ok(test
== parent
, "wrong owner %p\n", test
);
9452 trace("parent %p, child1 %p, child2 %p, child3 %p, child4 %p\n",
9453 parent
, child1
, child2
, child3
, child4
);
9456 test
= GetCapture();
9457 ok(test
== child4
, "wrong capture window %p\n", test
);
9459 test_DestroyWindow_flag
= TRUE
;
9460 ret
= DestroyWindow(parent
);
9461 ok( ret
, "DestroyWindow() error %d\n", GetLastError());
9462 test_DestroyWindow_flag
= FALSE
;
9463 ok_sequence(destroy_window_with_children
, "destroy window with children", FALSE
);
9465 ok(!IsWindow(parent
), "parent still exists\n");
9466 ok(!IsWindow(child1
), "child1 still exists\n");
9467 ok(!IsWindow(child2
), "child2 still exists\n");
9468 ok(!IsWindow(child3
), "child3 still exists\n");
9469 ok(!IsWindow(child4
), "child4 still exists\n");
9471 test
= GetCapture();
9472 ok(!test
, "wrong capture window %p\n", test
);
9476 static const struct message WmDispatchPaint
[] = {
9477 { WM_NCPAINT
, sent
},
9478 { WM_GETTEXT
, sent
|defwinproc
|optional
},
9479 { WM_GETTEXT
, sent
|defwinproc
|optional
},
9480 { WM_ERASEBKGND
, sent
},
9484 static LRESULT WINAPI
DispatchMessageCheckProc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
9486 if (message
== WM_PAINT
) return 0;
9487 return MsgCheckProcA( hwnd
, message
, wParam
, lParam
);
9490 static void test_DispatchMessage(void)
9495 HWND hwnd
= CreateWindowA( "TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
9496 100, 100, 200, 200, 0, 0, 0, NULL
);
9497 ShowWindow( hwnd
, SW_SHOW
);
9498 UpdateWindow( hwnd
);
9501 SetWindowLongPtrA( hwnd
, GWLP_WNDPROC
, (LONG_PTR
)DispatchMessageCheckProc
);
9503 SetRect( &rect
, -5, -5, 5, 5 );
9504 RedrawWindow( hwnd
, &rect
, 0, RDW_INVALIDATE
|RDW_ERASE
|RDW_FRAME
);
9506 while (PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
))
9508 if (msg
.message
!= WM_PAINT
) DispatchMessageA( &msg
);
9512 DispatchMessageA( &msg
);
9513 /* DispatchMessage will send WM_NCPAINT if non client area is still invalid after WM_PAINT */
9514 if (!count
) ok_sequence( WmDispatchPaint
, "WmDispatchPaint", FALSE
);
9515 else ok_sequence( WmEmptySeq
, "WmEmpty", FALSE
);
9516 if (++count
> 10) break;
9519 ok( msg
.message
== WM_PAINT
&& count
> 10, "WM_PAINT messages stopped\n" );
9521 trace("now without DispatchMessage\n");
9523 RedrawWindow( hwnd
, &rect
, 0, RDW_INVALIDATE
|RDW_ERASE
|RDW_FRAME
);
9525 while (PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
))
9527 if (msg
.message
!= WM_PAINT
) DispatchMessageA( &msg
);
9530 HRGN hrgn
= CreateRectRgn( 0, 0, 0, 0 );
9532 /* this will send WM_NCCPAINT just like DispatchMessage does */
9533 GetUpdateRgn( hwnd
, hrgn
, TRUE
);
9534 ok_sequence( WmDispatchPaint
, "WmDispatchPaint", FALSE
);
9535 DeleteObject( hrgn
);
9536 GetClientRect( hwnd
, &rect
);
9537 ValidateRect( hwnd
, &rect
); /* this will stop WM_PAINTs */
9538 ok( !count
, "Got multiple WM_PAINTs\n" );
9539 if (++count
> 10) break;
9544 RedrawWindow( hwnd
, &rect
, 0, RDW_INVALIDATE
|RDW_ERASE
|RDW_FRAME
);
9546 while (PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
))
9548 if (msg
.message
!= WM_PAINT
) DispatchMessageA( &msg
);
9554 hdc
= BeginPaint( hwnd
, NULL
);
9555 ok( !hdc
, "got valid hdc %p from BeginPaint\n", hdc
);
9556 ok( !EndPaint( hwnd
, NULL
), "EndPaint succeeded\n" );
9557 ok_sequence( WmDispatchPaint
, "WmDispatchPaint", FALSE
);
9558 ok( !count
, "Got multiple WM_PAINTs\n" );
9559 if (++count
> 10) break;
9562 DestroyWindow(hwnd
);
9566 static const struct message WmUser
[] = {
9578 static DWORD CALLBACK
send_msg_thread( LPVOID arg
)
9580 struct sendmsg_info
*info
= arg
;
9581 SetLastError( 0xdeadbeef );
9582 info
->ret
= SendMessageTimeoutA( info
->hwnd
, WM_USER
, 0, 0, 0, info
->timeout
, NULL
);
9583 if (!info
->ret
) ok( GetLastError() == ERROR_TIMEOUT
||
9584 broken(GetLastError() == 0), /* win9x */
9585 "unexpected error %d\n", GetLastError());
9589 static void wait_for_thread( HANDLE thread
)
9591 while (MsgWaitForMultipleObjects(1, &thread
, FALSE
, INFINITE
, QS_SENDMESSAGE
) != WAIT_OBJECT_0
)
9594 while (PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
9598 static LRESULT WINAPI
send_msg_delay_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
9600 if (message
== WM_USER
) Sleep(200);
9601 return MsgCheckProcA( hwnd
, message
, wParam
, lParam
);
9604 static void test_SendMessageTimeout(void)
9607 struct sendmsg_info info
;
9611 info
.hwnd
= CreateWindowA( "TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
9612 100, 100, 200, 200, 0, 0, 0, NULL
);
9616 info
.timeout
= 1000;
9617 info
.ret
= 0xdeadbeef;
9618 thread
= CreateThread( NULL
, 0, send_msg_thread
, &info
, 0, &tid
);
9619 wait_for_thread( thread
);
9620 CloseHandle( thread
);
9621 ok( info
.ret
== 1, "SendMessageTimeout failed\n" );
9622 ok_sequence( WmUser
, "WmUser", FALSE
);
9625 info
.ret
= 0xdeadbeef;
9626 thread
= CreateThread( NULL
, 0, send_msg_thread
, &info
, 0, &tid
);
9627 Sleep(100); /* SendMessageTimeout should time out here */
9628 wait_for_thread( thread
);
9629 CloseHandle( thread
);
9630 ok( info
.ret
== 0, "SendMessageTimeout succeeded\n" );
9631 ok_sequence( WmEmptySeq
, "WmEmptySeq", FALSE
);
9633 /* 0 means infinite timeout (but not on win9x) */
9635 info
.ret
= 0xdeadbeef;
9636 thread
= CreateThread( NULL
, 0, send_msg_thread
, &info
, 0, &tid
);
9638 wait_for_thread( thread
);
9639 CloseHandle( thread
);
9640 is_win9x
= !info
.ret
;
9641 if (is_win9x
) ok_sequence( WmEmptySeq
, "WmEmptySeq", FALSE
);
9642 else ok_sequence( WmUser
, "WmUser", FALSE
);
9644 /* timeout is treated as signed despite the prototype (but not on win9x) */
9645 info
.timeout
= 0x7fffffff;
9646 info
.ret
= 0xdeadbeef;
9647 thread
= CreateThread( NULL
, 0, send_msg_thread
, &info
, 0, &tid
);
9649 wait_for_thread( thread
);
9650 CloseHandle( thread
);
9651 ok( info
.ret
== 1, "SendMessageTimeout failed\n" );
9652 ok_sequence( WmUser
, "WmUser", FALSE
);
9654 info
.timeout
= 0x80000000;
9655 info
.ret
= 0xdeadbeef;
9656 thread
= CreateThread( NULL
, 0, send_msg_thread
, &info
, 0, &tid
);
9658 wait_for_thread( thread
);
9659 CloseHandle( thread
);
9662 ok( info
.ret
== 1, "SendMessageTimeout failed\n" );
9663 ok_sequence( WmUser
, "WmUser", FALSE
);
9667 ok( info
.ret
== 0, "SendMessageTimeout succeeded\n" );
9668 ok_sequence( WmEmptySeq
, "WmEmptySeq", FALSE
);
9671 /* now check for timeout during message processing */
9672 SetWindowLongPtrA( info
.hwnd
, GWLP_WNDPROC
, (LONG_PTR
)send_msg_delay_proc
);
9674 info
.ret
= 0xdeadbeef;
9675 thread
= CreateThread( NULL
, 0, send_msg_thread
, &info
, 0, &tid
);
9676 wait_for_thread( thread
);
9677 CloseHandle( thread
);
9678 /* we should time out but still get the message */
9679 ok( info
.ret
== 0, "SendMessageTimeout failed\n" );
9680 ok_sequence( WmUser
, "WmUser", FALSE
);
9682 DestroyWindow( info
.hwnd
);
9686 /****************** edit message test *************************/
9687 #define ID_EDIT 0x1234
9688 static const struct message sl_edit_setfocus
[] =
9690 { HCBT_SETFOCUS
, hook
},
9691 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
9692 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
9693 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
9694 { WM_SETFOCUS
, sent
|wparam
, 0 },
9695 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 10 },
9696 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 15 },
9697 { WM_CTLCOLOREDIT
, sent
|parent
},
9698 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 11 },
9699 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
9700 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
9701 { WM_COMMAND
, sent
|parent
|wparam
, MAKEWPARAM(ID_EDIT
, EN_SETFOCUS
) },
9704 static const struct message sl_edit_invisible
[] =
9706 { HCBT_SETFOCUS
, hook
},
9707 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
9708 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
9709 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
9710 { WM_KILLFOCUS
, sent
|parent
},
9711 { WM_SETFOCUS
, sent
},
9712 { WM_COMMAND
, sent
|parent
|wparam
, MAKEWPARAM(ID_EDIT
, EN_SETFOCUS
) },
9715 static const struct message ml_edit_setfocus
[] =
9717 { HCBT_SETFOCUS
, hook
},
9718 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
9719 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
9720 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
9721 { WM_SETFOCUS
, sent
|wparam
, 0 },
9722 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 10 },
9723 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 11 },
9724 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
9725 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
9726 { WM_COMMAND
, sent
|parent
|wparam
, MAKEWPARAM(ID_EDIT
, EN_SETFOCUS
) },
9729 static const struct message sl_edit_killfocus
[] =
9731 { HCBT_SETFOCUS
, hook
},
9732 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
9733 { WM_KILLFOCUS
, sent
|wparam
, 0 },
9734 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
9735 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
9736 { WM_COMMAND
, sent
|parent
|wparam
, MAKEWPARAM(ID_EDIT
, EN_KILLFOCUS
) },
9737 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
9738 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 1 },
9741 static const struct message sl_edit_lbutton_dblclk
[] =
9743 { WM_LBUTTONDBLCLK
, sent
},
9744 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
9747 static const struct message sl_edit_lbutton_down
[] =
9749 { WM_LBUTTONDOWN
, sent
|wparam
|lparam
, 0, 0 },
9750 { HCBT_SETFOCUS
, hook
},
9751 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
9752 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
9753 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
9754 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
9755 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 10 },
9756 { WM_CTLCOLOREDIT
, sent
|parent
},
9757 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 11 },
9758 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
9759 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
9760 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
9761 { WM_COMMAND
, sent
|parent
|wparam
, MAKEWPARAM(ID_EDIT
, EN_SETFOCUS
) },
9762 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
9763 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
9764 { WM_CTLCOLOREDIT
, sent
|parent
|optional
},
9765 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 11 },
9766 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
9767 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
9770 static const struct message ml_edit_lbutton_down
[] =
9772 { WM_LBUTTONDOWN
, sent
|wparam
|lparam
, 0, 0 },
9773 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
9774 { HCBT_SETFOCUS
, hook
},
9775 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
9776 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
9777 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
9778 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
9779 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 10 },
9780 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 11 },
9781 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
9782 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
9783 { WM_COMMAND
, sent
|parent
|wparam
, MAKEWPARAM(ID_EDIT
, EN_SETFOCUS
) },
9786 static const struct message sl_edit_lbutton_up
[] =
9788 { WM_LBUTTONUP
, sent
|wparam
|lparam
, 0, 0 },
9789 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
9790 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, 0, 0 },
9791 { WM_CAPTURECHANGED
, sent
|defwinproc
},
9792 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
9795 static const struct message ml_edit_lbutton_up
[] =
9797 { WM_LBUTTONUP
, sent
|wparam
|lparam
, 0, 0 },
9798 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, 0, 0 },
9799 { WM_CAPTURECHANGED
, sent
|defwinproc
},
9803 static WNDPROC old_edit_proc
;
9805 static LRESULT CALLBACK
edit_hook_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
9807 static LONG defwndproc_counter
= 0;
9809 struct recvd_message msg
;
9811 if (ignore_message( message
)) return 0;
9814 msg
.message
= message
;
9815 msg
.flags
= sent
|wparam
|lparam
;
9816 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
9817 msg
.wParam
= wParam
;
9818 msg
.lParam
= lParam
;
9822 defwndproc_counter
++;
9823 ret
= CallWindowProcA(old_edit_proc
, hwnd
, message
, wParam
, lParam
);
9824 defwndproc_counter
--;
9829 static void subclass_edit(void)
9833 if (!GetClassInfoA(0, "edit", &cls
)) assert(0);
9835 old_edit_proc
= cls
.lpfnWndProc
;
9837 cls
.hInstance
= GetModuleHandleA(NULL
);
9838 cls
.lpfnWndProc
= edit_hook_proc
;
9839 cls
.lpszClassName
= "my_edit_class";
9840 UnregisterClassA(cls
.lpszClassName
, cls
.hInstance
);
9841 if (!RegisterClassA(&cls
)) assert(0);
9844 static void test_edit_messages(void)
9850 log_all_parent_messages
++;
9852 parent
= CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
9853 100, 100, 200, 200, 0, 0, 0, NULL
);
9854 ok (parent
!= 0, "Failed to create parent window\n");
9856 /* test single line edit */
9857 hwnd
= CreateWindowExA(0, "my_edit_class", "test", WS_CHILD
,
9858 0, 0, 80, 20, parent
, (HMENU
)ID_EDIT
, 0, NULL
);
9859 ok(hwnd
!= 0, "Failed to create edit window\n");
9861 dlg_code
= SendMessageA(hwnd
, WM_GETDLGCODE
, 0, 0);
9862 ok(dlg_code
== (DLGC_WANTCHARS
|DLGC_HASSETSEL
|DLGC_WANTARROWS
), "wrong dlg_code %08x\n", dlg_code
);
9866 ok_sequence(sl_edit_invisible
, "SetFocus(hwnd) on an invisible edit", FALSE
);
9868 ShowWindow(hwnd
, SW_SHOW
);
9874 ok_sequence(sl_edit_setfocus
, "SetFocus(hwnd) on an edit", FALSE
);
9877 ok_sequence(sl_edit_killfocus
, "SetFocus(0) on an edit", FALSE
);
9883 SendMessageA(hwnd
, WM_LBUTTONDBLCLK
, 0, 0);
9884 ok_sequence(sl_edit_lbutton_dblclk
, "WM_LBUTTONDBLCLK on an edit", FALSE
);
9890 SendMessageA(hwnd
, WM_LBUTTONDOWN
, 0, 0);
9891 ok_sequence(sl_edit_lbutton_down
, "WM_LBUTTONDOWN on an edit", FALSE
);
9893 SendMessageA(hwnd
, WM_LBUTTONUP
, 0, 0);
9894 ok_sequence(sl_edit_lbutton_up
, "WM_LBUTTONUP on an edit", FALSE
);
9896 DestroyWindow(hwnd
);
9898 /* test multiline edit */
9899 hwnd
= CreateWindowExA(0, "my_edit_class", "test", WS_CHILD
| ES_MULTILINE
,
9900 0, 0, 80, 20, parent
, (HMENU
)ID_EDIT
, 0, NULL
);
9901 ok(hwnd
!= 0, "Failed to create edit window\n");
9903 dlg_code
= SendMessageA(hwnd
, WM_GETDLGCODE
, 0, 0);
9904 ok(dlg_code
== (DLGC_WANTCHARS
|DLGC_HASSETSEL
|DLGC_WANTARROWS
|DLGC_WANTALLKEYS
),
9905 "wrong dlg_code %08x\n", dlg_code
);
9907 ShowWindow(hwnd
, SW_SHOW
);
9913 ok_sequence(ml_edit_setfocus
, "SetFocus(hwnd) on multiline edit", FALSE
);
9916 ok_sequence(sl_edit_killfocus
, "SetFocus(0) on multiline edit", FALSE
);
9922 SendMessageA(hwnd
, WM_LBUTTONDBLCLK
, 0, 0);
9923 ok_sequence(sl_edit_lbutton_dblclk
, "WM_LBUTTONDBLCLK on multiline edit", FALSE
);
9929 SendMessageA(hwnd
, WM_LBUTTONDOWN
, 0, 0);
9930 ok_sequence(ml_edit_lbutton_down
, "WM_LBUTTONDOWN on multiline edit", FALSE
);
9932 SendMessageA(hwnd
, WM_LBUTTONUP
, 0, 0);
9933 ok_sequence(ml_edit_lbutton_up
, "WM_LBUTTONUP on multiline edit", FALSE
);
9935 DestroyWindow(hwnd
);
9936 DestroyWindow(parent
);
9938 log_all_parent_messages
--;
9941 /**************************** End of Edit test ******************************/
9943 static const struct message WmKeyDownSkippedSeq
[] =
9945 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 1 }, /* XP */
9948 static const struct message WmKeyDownWasDownSkippedSeq
[] =
9950 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0x40000001 }, /* XP */
9953 static const struct message WmKeyUpSkippedSeq
[] =
9955 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xc0000001 }, /* XP */
9958 static const struct message WmUserKeyUpSkippedSeq
[] =
9961 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xc0000001 }, /* XP */
9966 #define EV_SENDMSG 1
9972 HANDLE hevent
[3]; /* 0 - start/stop, 1 - SendMessage, 2 - ack */
9975 static DWORD CALLBACK
send_msg_thread_2(void *param
)
9978 struct peekmsg_info
*info
= param
;
9980 trace("thread: looping\n");
9981 SetEvent(info
->hevent
[EV_ACK
]);
9985 ret
= WaitForMultipleObjects(2, info
->hevent
, FALSE
, INFINITE
);
9989 case WAIT_OBJECT_0
+ EV_STOP
:
9990 trace("thread: exiting\n");
9993 case WAIT_OBJECT_0
+ EV_SENDMSG
:
9994 trace("thread: sending message\n");
9995 ret
= SendNotifyMessageA(info
->hwnd
, WM_USER
, 0, 0);
9996 ok(ret
, "SendNotifyMessageA failed error %u\n", GetLastError());
9997 SetEvent(info
->hevent
[EV_ACK
]);
10001 trace("unexpected return: %04x\n", ret
);
10009 static void test_PeekMessage(void)
10013 DWORD tid
, qstatus
;
10014 UINT qs_all_input
= QS_ALLINPUT
;
10015 UINT qs_input
= QS_INPUT
;
10017 struct peekmsg_info info
;
10019 info
.hwnd
= CreateWindowA("TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
10020 100, 100, 200, 200, 0, 0, 0, NULL
);
10022 ShowWindow(info
.hwnd
, SW_SHOW
);
10023 UpdateWindow(info
.hwnd
);
10024 SetFocus(info
.hwnd
);
10026 info
.hevent
[EV_STOP
] = CreateEventA(NULL
, 0, 0, NULL
);
10027 info
.hevent
[EV_SENDMSG
] = CreateEventA(NULL
, 0, 0, NULL
);
10028 info
.hevent
[EV_ACK
] = CreateEventA(NULL
, 0, 0, NULL
);
10030 hthread
= CreateThread(NULL
, 0, send_msg_thread_2
, &info
, 0, &tid
);
10031 WaitForSingleObject(info
.hevent
[EV_ACK
], 10000);
10036 SetLastError(0xdeadbeef);
10037 qstatus
= GetQueueStatus(qs_all_input
);
10038 if (GetLastError() == ERROR_INVALID_FLAGS
)
10040 trace("QS_RAWINPUT not supported on this platform\n");
10041 qs_all_input
&= ~QS_RAWINPUT
;
10042 qs_input
&= ~QS_RAWINPUT
;
10044 if (qstatus
& QS_POSTMESSAGE
)
10046 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) /* nothing */ ;
10047 qstatus
= GetQueueStatus(qs_all_input
);
10049 ok(qstatus
== 0, "wrong qstatus %08x\n", qstatus
);
10051 trace("signalling to send message\n");
10052 SetEvent(info
.hevent
[EV_SENDMSG
]);
10053 WaitForSingleObject(info
.hevent
[EV_ACK
], INFINITE
);
10055 /* pass invalid QS_xxxx flags */
10056 SetLastError(0xdeadbeef);
10057 qstatus
= GetQueueStatus(0xffffffff);
10058 ok(qstatus
== 0 || broken(qstatus
) /* win9x */, "GetQueueStatus should fail: %08x\n", qstatus
);
10061 ok(GetLastError() == ERROR_INVALID_FLAGS
, "wrong error %d\n", GetLastError());
10062 qstatus
= GetQueueStatus(qs_all_input
);
10064 qstatus
&= ~MAKELONG( 0x4000, 0x4000 ); /* sometimes set on Win95 */
10065 ok(qstatus
== MAKELONG(QS_SENDMESSAGE
, QS_SENDMESSAGE
),
10066 "wrong qstatus %08x\n", qstatus
);
10069 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
10071 "PeekMessageA should have returned FALSE instead of msg %04x\n",
10073 ok_sequence(WmUser
, "WmUser", FALSE
);
10075 qstatus
= GetQueueStatus(qs_all_input
);
10076 ok(qstatus
== 0, "wrong qstatus %08x\n", qstatus
);
10078 keybd_event('N', 0, 0, 0);
10079 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
10080 qstatus
= GetQueueStatus(qs_all_input
);
10081 if (!(qstatus
& MAKELONG(QS_KEY
, QS_KEY
)))
10083 skip( "queuing key events not supported\n" );
10086 ok(qstatus
== MAKELONG(QS_KEY
, QS_KEY
) ||
10087 /* keybd_event seems to trigger a sent message on NT4 */
10088 qstatus
== MAKELONG(QS_KEY
|QS_SENDMESSAGE
, QS_KEY
|QS_SENDMESSAGE
),
10089 "wrong qstatus %08x\n", qstatus
);
10091 PostMessageA(info
.hwnd
, WM_CHAR
, 'z', 0);
10092 qstatus
= GetQueueStatus(qs_all_input
);
10093 ok(qstatus
== MAKELONG(QS_POSTMESSAGE
, QS_POSTMESSAGE
|QS_KEY
) ||
10094 qstatus
== MAKELONG(QS_POSTMESSAGE
, QS_POSTMESSAGE
|QS_KEY
|QS_SENDMESSAGE
),
10095 "wrong qstatus %08x\n", qstatus
);
10097 InvalidateRect(info
.hwnd
, NULL
, FALSE
);
10098 qstatus
= GetQueueStatus(qs_all_input
);
10099 ok(qstatus
== MAKELONG(QS_PAINT
, QS_PAINT
|QS_POSTMESSAGE
|QS_KEY
) ||
10100 qstatus
== MAKELONG(QS_PAINT
, QS_PAINT
|QS_POSTMESSAGE
|QS_KEY
|QS_SENDMESSAGE
),
10101 "wrong qstatus %08x\n", qstatus
);
10103 trace("signalling to send message\n");
10104 SetEvent(info
.hevent
[EV_SENDMSG
]);
10105 WaitForSingleObject(info
.hevent
[EV_ACK
], INFINITE
);
10107 qstatus
= GetQueueStatus(qs_all_input
);
10108 ok(qstatus
== MAKELONG(QS_SENDMESSAGE
, QS_SENDMESSAGE
|QS_PAINT
|QS_POSTMESSAGE
|QS_KEY
),
10109 "wrong qstatus %08x\n", qstatus
);
10112 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| (qs_input
<< 16));
10113 if (ret
&& msg
.message
== WM_CHAR
)
10115 win_skip( "PM_QS_* flags not supported in PeekMessage\n" );
10119 "PeekMessageA should have returned FALSE instead of msg %04x\n",
10121 if (!sequence_cnt
) /* nt4 doesn't fetch anything with PM_QS_* flags */
10123 win_skip( "PM_QS_* flags not supported in PeekMessage\n" );
10126 ok_sequence(WmUser
, "WmUser", FALSE
);
10128 qstatus
= GetQueueStatus(qs_all_input
);
10129 ok(qstatus
== MAKELONG(0, QS_PAINT
|QS_POSTMESSAGE
|QS_KEY
),
10130 "wrong qstatus %08x\n", qstatus
);
10132 trace("signalling to send message\n");
10133 SetEvent(info
.hevent
[EV_SENDMSG
]);
10134 WaitForSingleObject(info
.hevent
[EV_ACK
], INFINITE
);
10136 qstatus
= GetQueueStatus(qs_all_input
);
10137 ok(qstatus
== MAKELONG(QS_SENDMESSAGE
, QS_SENDMESSAGE
|QS_PAINT
|QS_POSTMESSAGE
|QS_KEY
),
10138 "wrong qstatus %08x\n", qstatus
);
10141 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| PM_QS_POSTMESSAGE
);
10143 "PeekMessageA should have returned FALSE instead of msg %04x\n",
10145 ok_sequence(WmUser
, "WmUser", FALSE
);
10147 qstatus
= GetQueueStatus(qs_all_input
);
10148 ok(qstatus
== MAKELONG(0, QS_PAINT
|QS_POSTMESSAGE
|QS_KEY
),
10149 "wrong qstatus %08x\n", qstatus
);
10152 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| PM_QS_POSTMESSAGE
);
10153 ok(ret
&& msg
.message
== WM_CHAR
&& msg
.wParam
== 'z',
10154 "got %d and %04x wParam %08lx instead of TRUE and WM_CHAR wParam 'z'\n",
10155 ret
, msg
.message
, msg
.wParam
);
10156 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
10158 qstatus
= GetQueueStatus(qs_all_input
);
10159 ok(qstatus
== MAKELONG(0, QS_PAINT
|QS_KEY
),
10160 "wrong qstatus %08x\n", qstatus
);
10163 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| PM_QS_POSTMESSAGE
);
10165 "PeekMessageA should have returned FALSE instead of msg %04x\n",
10167 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
10169 qstatus
= GetQueueStatus(qs_all_input
);
10170 ok(qstatus
== MAKELONG(0, QS_PAINT
|QS_KEY
),
10171 "wrong qstatus %08x\n", qstatus
);
10174 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| PM_QS_PAINT
);
10175 ok(ret
&& msg
.message
== WM_PAINT
,
10176 "got %d and %04x instead of TRUE and WM_PAINT\n", ret
, msg
.message
);
10177 DispatchMessageA(&msg
);
10178 ok_sequence(WmPaint
, "WmPaint", FALSE
);
10180 qstatus
= GetQueueStatus(qs_all_input
);
10181 ok(qstatus
== MAKELONG(0, QS_KEY
),
10182 "wrong qstatus %08x\n", qstatus
);
10185 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| PM_QS_PAINT
);
10187 "PeekMessageA should have returned FALSE instead of msg %04x\n",
10189 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
10191 qstatus
= GetQueueStatus(qs_all_input
);
10192 ok(qstatus
== MAKELONG(0, QS_KEY
),
10193 "wrong qstatus %08x\n", qstatus
);
10195 trace("signalling to send message\n");
10196 SetEvent(info
.hevent
[EV_SENDMSG
]);
10197 WaitForSingleObject(info
.hevent
[EV_ACK
], INFINITE
);
10199 qstatus
= GetQueueStatus(qs_all_input
);
10200 ok(qstatus
== MAKELONG(QS_SENDMESSAGE
, QS_SENDMESSAGE
|QS_KEY
),
10201 "wrong qstatus %08x\n", qstatus
);
10203 PostMessageA(info
.hwnd
, WM_CHAR
, 'z', 0);
10205 qstatus
= GetQueueStatus(qs_all_input
);
10206 ok(qstatus
== MAKELONG(QS_POSTMESSAGE
, QS_SENDMESSAGE
|QS_POSTMESSAGE
|QS_KEY
),
10207 "wrong qstatus %08x\n", qstatus
);
10210 ret
= PeekMessageA(&msg
, 0, WM_CHAR
, WM_CHAR
, PM_REMOVE
);
10211 ok(ret
&& msg
.message
== WM_CHAR
&& msg
.wParam
== 'z',
10212 "got %d and %04x wParam %08lx instead of TRUE and WM_CHAR wParam 'z'\n",
10213 ret
, msg
.message
, msg
.wParam
);
10214 ok_sequence(WmUser
, "WmUser", FALSE
);
10216 qstatus
= GetQueueStatus(qs_all_input
);
10217 ok(qstatus
== MAKELONG(0, QS_KEY
),
10218 "wrong qstatus %08x\n", qstatus
);
10221 ret
= PeekMessageA(&msg
, 0, WM_CHAR
, WM_CHAR
, PM_REMOVE
);
10223 "PeekMessageA should have returned FALSE instead of msg %04x\n",
10225 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
10227 qstatus
= GetQueueStatus(qs_all_input
);
10228 ok(qstatus
== MAKELONG(0, QS_KEY
),
10229 "wrong qstatus %08x\n", qstatus
);
10231 PostMessageA(info
.hwnd
, WM_CHAR
, 'z', 0);
10233 qstatus
= GetQueueStatus(qs_all_input
);
10234 ok(qstatus
== MAKELONG(QS_POSTMESSAGE
, QS_POSTMESSAGE
|QS_KEY
),
10235 "wrong qstatus %08x\n", qstatus
);
10237 trace("signalling to send message\n");
10238 SetEvent(info
.hevent
[EV_SENDMSG
]);
10239 WaitForSingleObject(info
.hevent
[EV_ACK
], INFINITE
);
10241 qstatus
= GetQueueStatus(qs_all_input
);
10242 ok(qstatus
== MAKELONG(QS_SENDMESSAGE
, QS_SENDMESSAGE
|QS_POSTMESSAGE
|QS_KEY
),
10243 "wrong qstatus %08x\n", qstatus
);
10246 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| (QS_KEY
<< 16));
10248 "PeekMessageA should have returned FALSE instead of msg %04x\n",
10250 ok_sequence(WmUser
, "WmUser", FALSE
);
10252 qstatus
= GetQueueStatus(qs_all_input
);
10253 ok(qstatus
== MAKELONG(0, QS_POSTMESSAGE
|QS_KEY
),
10254 "wrong qstatus %08x\n", qstatus
);
10257 if (qs_all_input
& QS_RAWINPUT
) /* use QS_RAWINPUT only if supported */
10258 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| (QS_RAWINPUT
<< 16));
10259 else /* workaround for a missing QS_RAWINPUT support */
10260 ret
= PeekMessageA(&msg
, 0, WM_KEYDOWN
, WM_KEYDOWN
, PM_REMOVE
);
10261 ok(ret
&& msg
.message
== WM_KEYDOWN
&& msg
.wParam
== 'N',
10262 "got %d and %04x wParam %08lx instead of TRUE and WM_KEYDOWN wParam 'N'\n",
10263 ret
, msg
.message
, msg
.wParam
);
10264 ok_sequence(WmKeyDownSkippedSeq
, "WmKeyDownSkippedSeq", FALSE
);
10266 qstatus
= GetQueueStatus(qs_all_input
);
10267 ok(qstatus
== MAKELONG(0, QS_POSTMESSAGE
|QS_KEY
),
10268 "wrong qstatus %08x\n", qstatus
);
10271 if (qs_all_input
& QS_RAWINPUT
) /* use QS_RAWINPUT only if supported */
10272 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| (QS_RAWINPUT
<< 16));
10273 else /* workaround for a missing QS_RAWINPUT support */
10274 ret
= PeekMessageA(&msg
, 0, WM_KEYUP
, WM_KEYUP
, PM_REMOVE
);
10275 ok(ret
&& msg
.message
== WM_KEYUP
&& msg
.wParam
== 'N',
10276 "got %d and %04x wParam %08lx instead of TRUE and WM_KEYUP wParam 'N'\n",
10277 ret
, msg
.message
, msg
.wParam
);
10278 ok_sequence(WmKeyUpSkippedSeq
, "WmKeyUpSkippedSeq", FALSE
);
10280 qstatus
= GetQueueStatus(qs_all_input
);
10281 ok(qstatus
== MAKELONG(0, QS_POSTMESSAGE
),
10282 "wrong qstatus %08x\n", qstatus
);
10285 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| PM_QS_SENDMESSAGE
);
10287 "PeekMessageA should have returned FALSE instead of msg %04x\n",
10289 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
10291 qstatus
= GetQueueStatus(qs_all_input
);
10292 ok(qstatus
== MAKELONG(0, QS_POSTMESSAGE
),
10293 "wrong qstatus %08x\n", qstatus
);
10296 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
10297 ok(ret
&& msg
.message
== WM_CHAR
&& msg
.wParam
== 'z',
10298 "got %d and %04x wParam %08lx instead of TRUE and WM_CHAR wParam 'z'\n",
10299 ret
, msg
.message
, msg
.wParam
);
10300 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
10302 qstatus
= GetQueueStatus(qs_all_input
);
10304 "wrong qstatus %08x\n", qstatus
);
10307 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
10309 "PeekMessageA should have returned FALSE instead of msg %04x\n",
10311 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
10313 qstatus
= GetQueueStatus(qs_all_input
);
10315 "wrong qstatus %08x\n", qstatus
);
10317 /* test whether presence of the quit flag in the queue affects
10320 PostQuitMessage(0x1234abcd);
10322 qstatus
= GetQueueStatus(qs_all_input
);
10323 ok(qstatus
== MAKELONG(QS_POSTMESSAGE
, QS_POSTMESSAGE
),
10324 "wrong qstatus %08x\n", qstatus
);
10326 PostMessageA(info
.hwnd
, WM_USER
, 0, 0);
10328 qstatus
= GetQueueStatus(qs_all_input
);
10329 ok(qstatus
== MAKELONG(QS_POSTMESSAGE
, QS_POSTMESSAGE
),
10330 "wrong qstatus %08x\n", qstatus
);
10333 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
10334 ok(ret
&& msg
.message
== WM_USER
,
10335 "got %d and %04x instead of TRUE and WM_USER\n", ret
, msg
.message
);
10336 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
10338 qstatus
= GetQueueStatus(qs_all_input
);
10339 ok(qstatus
== MAKELONG(0, QS_POSTMESSAGE
),
10340 "wrong qstatus %08x\n", qstatus
);
10343 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
10344 ok(ret
&& msg
.message
== WM_QUIT
,
10345 "got %d and %04x instead of TRUE and WM_QUIT\n", ret
, msg
.message
);
10346 ok(msg
.wParam
== 0x1234abcd, "got wParam %08lx instead of 0x1234abcd\n", msg
.wParam
);
10347 ok(msg
.lParam
== 0, "got lParam %08lx instead of 0\n", msg
.lParam
);
10348 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
10350 qstatus
= GetQueueStatus(qs_all_input
);
10352 ok(qstatus
== MAKELONG(0, QS_POSTMESSAGE
),
10353 "wrong qstatus %08x\n", qstatus
);
10357 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
10359 "PeekMessageA should have returned FALSE instead of msg %04x\n",
10361 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
10363 qstatus
= GetQueueStatus(qs_all_input
);
10365 "wrong qstatus %08x\n", qstatus
);
10367 /* some GetMessage tests */
10369 keybd_event('N', 0, 0, 0);
10370 qstatus
= GetQueueStatus(qs_all_input
);
10371 ok(qstatus
== MAKELONG(QS_KEY
, QS_KEY
), "wrong qstatus %08x\n", qstatus
);
10373 PostMessageA(info
.hwnd
, WM_CHAR
, 'z', 0);
10374 qstatus
= GetQueueStatus(qs_all_input
);
10375 ok(qstatus
== MAKELONG(QS_POSTMESSAGE
, QS_POSTMESSAGE
|QS_KEY
), "wrong qstatus %08x\n", qstatus
);
10379 ret
= GetMessageA( &msg
, 0, 0, 0 );
10380 ok(ret
&& msg
.message
== WM_CHAR
&& msg
.wParam
== 'z',
10381 "got %d and %04x wParam %08lx instead of TRUE and WM_CHAR wParam 'z'\n",
10382 ret
, msg
.message
, msg
.wParam
);
10383 qstatus
= GetQueueStatus(qs_all_input
);
10384 ok(qstatus
== MAKELONG(0, QS_KEY
), "wrong qstatus %08x\n", qstatus
);
10389 ret
= GetMessageA( &msg
, 0, 0, 0 );
10390 ok(ret
&& msg
.message
== WM_KEYDOWN
&& msg
.wParam
== 'N',
10391 "got %d and %04x wParam %08lx instead of TRUE and WM_KEYDOWN wParam 'N'\n",
10392 ret
, msg
.message
, msg
.wParam
);
10393 ok_sequence(WmKeyDownSkippedSeq
, "WmKeyDownSkippedSeq", FALSE
);
10394 qstatus
= GetQueueStatus(qs_all_input
);
10395 ok(qstatus
== 0, "wrong qstatus %08x\n", qstatus
);
10398 keybd_event('N', 0, 0, 0);
10399 qstatus
= GetQueueStatus(qs_all_input
);
10400 ok(qstatus
== MAKELONG(QS_KEY
, QS_KEY
), "wrong qstatus %08x\n", qstatus
);
10402 PostMessageA(info
.hwnd
, WM_CHAR
, 'z', 0);
10403 qstatus
= GetQueueStatus(qs_all_input
);
10404 ok(qstatus
== MAKELONG(QS_POSTMESSAGE
, QS_POSTMESSAGE
|QS_KEY
), "wrong qstatus %08x\n", qstatus
);
10406 if (qstatus
& (QS_KEY
<< 16))
10408 ret
= GetMessageA( &msg
, 0, WM_KEYDOWN
, WM_KEYUP
);
10409 ok(ret
&& msg
.message
== WM_KEYDOWN
&& msg
.wParam
== 'N',
10410 "got %d and %04x wParam %08lx instead of TRUE and WM_KEYDOWN wParam 'N'\n",
10411 ret
, msg
.message
, msg
.wParam
);
10412 ok_sequence(WmKeyDownWasDownSkippedSeq
, "WmKeyDownWasDownSkippedSeq", FALSE
);
10413 qstatus
= GetQueueStatus(qs_all_input
);
10414 ok(qstatus
== MAKELONG(0, QS_POSTMESSAGE
), "wrong qstatus %08x\n", qstatus
);
10419 ret
= GetMessageA( &msg
, 0, WM_CHAR
, WM_CHAR
);
10420 ok(ret
&& msg
.message
== WM_CHAR
&& msg
.wParam
== 'z',
10421 "got %d and %04x wParam %08lx instead of TRUE and WM_CHAR wParam 'z'\n",
10422 ret
, msg
.message
, msg
.wParam
);
10423 qstatus
= GetQueueStatus(qs_all_input
);
10424 ok(qstatus
== 0, "wrong qstatus %08x\n", qstatus
);
10427 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
10428 qstatus
= GetQueueStatus(qs_all_input
);
10429 ok(qstatus
== MAKELONG(QS_KEY
, QS_KEY
), "wrong qstatus %08x\n", qstatus
);
10431 PostMessageA(info
.hwnd
, WM_CHAR
, 'z', 0);
10432 qstatus
= GetQueueStatus(qs_all_input
);
10433 ok(qstatus
== MAKELONG(QS_POSTMESSAGE
, QS_POSTMESSAGE
|QS_KEY
), "wrong qstatus %08x\n", qstatus
);
10435 trace("signalling to send message\n");
10436 SetEvent(info
.hevent
[EV_SENDMSG
]);
10437 WaitForSingleObject(info
.hevent
[EV_ACK
], INFINITE
);
10438 qstatus
= GetQueueStatus(qs_all_input
);
10439 ok(qstatus
== MAKELONG(QS_SENDMESSAGE
, QS_SENDMESSAGE
|QS_POSTMESSAGE
|QS_KEY
),
10440 "wrong qstatus %08x\n", qstatus
);
10442 if (qstatus
& (QS_KEY
<< 16))
10444 ret
= GetMessageA( &msg
, 0, WM_KEYDOWN
, WM_KEYUP
);
10445 ok(ret
&& msg
.message
== WM_KEYUP
&& msg
.wParam
== 'N',
10446 "got %d and %04x wParam %08lx instead of TRUE and WM_KEYDOWN wParam 'N'\n",
10447 ret
, msg
.message
, msg
.wParam
);
10448 ok_sequence(WmUserKeyUpSkippedSeq
, "WmUserKeyUpSkippedSeq", FALSE
);
10449 qstatus
= GetQueueStatus(qs_all_input
);
10450 ok(qstatus
== MAKELONG(0, QS_POSTMESSAGE
), "wrong qstatus %08x\n", qstatus
);
10455 ret
= GetMessageA( &msg
, 0, WM_CHAR
, WM_CHAR
);
10456 ok(ret
&& msg
.message
== WM_CHAR
&& msg
.wParam
== 'z',
10457 "got %d and %04x wParam %08lx instead of TRUE and WM_CHAR wParam 'z'\n",
10458 ret
, msg
.message
, msg
.wParam
);
10459 qstatus
= GetQueueStatus(qs_all_input
);
10460 ok(qstatus
== 0, "wrong qstatus %08x\n", qstatus
);
10463 trace("signalling to exit\n");
10464 SetEvent(info
.hevent
[EV_STOP
]);
10466 WaitForSingleObject(hthread
, INFINITE
);
10468 CloseHandle(hthread
);
10469 CloseHandle(info
.hevent
[0]);
10470 CloseHandle(info
.hevent
[1]);
10471 CloseHandle(info
.hevent
[2]);
10473 DestroyWindow(info
.hwnd
);
10476 static void wait_move_event(HWND hwnd
, int x
, int y
)
10482 time
= GetTickCount();
10483 while (GetTickCount() - time
< 200) {
10484 ret
= PeekMessageA(&msg
, hwnd
, WM_MOUSEMOVE
, WM_MOUSEMOVE
, PM_NOREMOVE
);
10485 if (ret
&& msg
.pt
.x
> x
&& msg
.pt
.y
> y
) break;
10486 if (!ret
) MsgWaitForMultipleObjects( 0, NULL
, FALSE
, GetTickCount() - time
, QS_ALLINPUT
);
10487 else Sleep( GetTickCount() - time
);
10492 static void test_PeekMessage2(void)
10498 DWORD time1
, time2
, time3
;
10499 int x1
, y1
, x2
, y2
, x3
, y3
;
10502 time1
= time2
= time3
= 0;
10503 x1
= y1
= x2
= y2
= x3
= y3
= 0;
10505 /* Initialise window and make sure it is ready for events */
10506 hwnd
= CreateWindowA("TestWindowClass", "PeekMessage2", WS_OVERLAPPEDWINDOW
,
10507 10, 10, 800, 800, NULL
, NULL
, NULL
, NULL
);
10509 trace("Window for test_PeekMessage2 %p\n", hwnd
);
10510 ShowWindow(hwnd
, SW_SHOW
);
10511 UpdateWindow(hwnd
);
10513 GetCursorPos(&pos
);
10514 SetCursorPos(100, 100);
10515 mouse_event(MOUSEEVENTF_MOVE
, -STEP
, -STEP
, 0, 0);
10518 /* Do initial mousemove, wait until we can see it
10519 and then do our test peek with PM_NOREMOVE. */
10520 mouse_event(MOUSEEVENTF_MOVE
, STEP
, STEP
, 0, 0);
10521 wait_move_event(hwnd
, 100-STEP
, 100-STEP
);
10523 ret
= PeekMessageA(&msg
, hwnd
, WM_MOUSEMOVE
, WM_MOUSEMOVE
, PM_NOREMOVE
);
10526 skip( "queuing mouse events not supported\n" );
10531 trace("1st move event: %04x %x %d %d\n", msg
.message
, msg
.time
, msg
.pt
.x
, msg
.pt
.y
);
10532 message
= msg
.message
;
10536 ok(message
== WM_MOUSEMOVE
, "message not WM_MOUSEMOVE, %04x instead\n", message
);
10539 /* Allow time to advance a bit, and then simulate the user moving their
10540 * mouse around. After that we peek again with PM_NOREMOVE.
10541 * Although the previous mousemove message was never removed, the
10542 * mousemove we now peek should reflect the recent mouse movements
10543 * because the input queue will merge the move events. */
10545 mouse_event(MOUSEEVENTF_MOVE
, STEP
, STEP
, 0, 0);
10546 wait_move_event(hwnd
, x1
, y1
);
10548 ret
= PeekMessageA(&msg
, hwnd
, WM_MOUSEMOVE
, WM_MOUSEMOVE
, PM_NOREMOVE
);
10549 ok(ret
, "no message available\n");
10551 trace("2nd move event: %04x %x %d %d\n", msg
.message
, msg
.time
, msg
.pt
.x
, msg
.pt
.y
);
10552 message
= msg
.message
;
10556 ok(message
== WM_MOUSEMOVE
, "message not WM_MOUSEMOVE, %04x instead\n", message
);
10557 ok(time2
> time1
, "message time not advanced: %x %x\n", time1
, time2
);
10558 ok(x2
!= x1
&& y2
!= y1
, "coords not changed: (%d %d) (%d %d)\n", x1
, y1
, x2
, y2
);
10561 /* Have another go, to drive the point home */
10563 mouse_event(MOUSEEVENTF_MOVE
, STEP
, STEP
, 0, 0);
10564 wait_move_event(hwnd
, x2
, y2
);
10566 ret
= PeekMessageA(&msg
, hwnd
, WM_MOUSEMOVE
, WM_MOUSEMOVE
, PM_NOREMOVE
);
10567 ok(ret
, "no message available\n");
10569 trace("3rd move event: %04x %x %d %d\n", msg
.message
, msg
.time
, msg
.pt
.x
, msg
.pt
.y
);
10570 message
= msg
.message
;
10574 ok(message
== WM_MOUSEMOVE
, "message not WM_MOUSEMOVE, %04x instead\n", message
);
10575 ok(time3
> time2
, "message time not advanced: %x %x\n", time2
, time3
);
10576 ok(x3
!= x2
&& y3
!= y2
, "coords not changed: (%d %d) (%d %d)\n", x2
, y2
, x3
, y3
);
10580 DestroyWindow(hwnd
);
10581 SetCursorPos(pos
.x
, pos
.y
);
10585 static void test_PeekMessage3(void)
10591 hwnd
= CreateWindowA("TestWindowClass", "PeekMessage3", WS_OVERLAPPEDWINDOW
,
10592 10, 10, 800, 800, NULL
, NULL
, NULL
, NULL
);
10593 ok(hwnd
!= NULL
, "expected hwnd != NULL\n");
10596 /* GetMessage() and PeekMessage(..., PM_REMOVE) should prefer messages which
10597 * were already seen. */
10599 SetTimer(hwnd
, 1, 0, NULL
);
10600 while (!PeekMessageA(&msg
, NULL
, 0, 0, PM_NOREMOVE
));
10601 ok(msg
.message
== WM_TIMER
, "msg.message = %u instead of WM_TIMER\n", msg
.message
);
10602 PostMessageA(hwnd
, WM_USER
, 0, 0);
10603 ret
= PeekMessageA(&msg
, NULL
, 0, 0, PM_NOREMOVE
);
10605 ok(ret
&& msg
.message
== WM_TIMER
, "msg.message = %u instead of WM_TIMER\n", msg
.message
);
10606 ret
= GetMessageA(&msg
, NULL
, 0, 0);
10608 ok(ret
&& msg
.message
== WM_TIMER
, "msg.message = %u instead of WM_TIMER\n", msg
.message
);
10609 ret
= GetMessageA(&msg
, NULL
, 0, 0);
10611 ok(ret
&& msg
.message
== WM_USER
, "msg.message = %u instead of WM_USER\n", msg
.message
);
10612 ret
= PeekMessageA(&msg
, NULL
, 0, 0, 0);
10613 ok(!ret
, "expected PeekMessage to return FALSE, got %u\n", ret
);
10615 SetTimer(hwnd
, 1, 0, NULL
);
10616 while (!PeekMessageA(&msg
, NULL
, 0, 0, PM_NOREMOVE
));
10617 ok(msg
.message
== WM_TIMER
, "msg.message = %u instead of WM_TIMER\n", msg
.message
);
10618 PostMessageA(hwnd
, WM_USER
, 0, 0);
10619 ret
= PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
);
10621 ok(ret
&& msg
.message
== WM_TIMER
, "msg.message = %u instead of WM_TIMER\n", msg
.message
);
10622 ret
= PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
);
10624 ok(ret
&& msg
.message
== WM_USER
, "msg.message = %u instead of WM_USER\n", msg
.message
);
10625 ret
= PeekMessageA(&msg
, NULL
, 0, 0, 0);
10626 ok(!ret
, "expected PeekMessage to return FALSE, got %u\n", ret
);
10628 /* It doesn't matter if a message range is specified or not. */
10630 SetTimer(hwnd
, 1, 0, NULL
);
10631 while (!PeekMessageA(&msg
, NULL
, WM_TIMER
, WM_TIMER
, PM_NOREMOVE
));
10632 ok(msg
.message
== WM_TIMER
, "msg.message = %u instead of WM_TIMER\n", msg
.message
);
10633 PostMessageA(hwnd
, WM_USER
, 0, 0);
10634 ret
= GetMessageA(&msg
, NULL
, 0, 0);
10636 ok(ret
&& msg
.message
== WM_TIMER
, "msg.message = %u instead of WM_TIMER\n", msg
.message
);
10637 ret
= GetMessageA(&msg
, NULL
, 0, 0);
10639 ok(ret
&& msg
.message
== WM_USER
, "msg.message = %u instead of WM_USER\n", msg
.message
);
10640 ret
= PeekMessageA(&msg
, NULL
, 0, 0, 0);
10641 ok(!ret
, "expected PeekMessage to return FALSE, got %u\n", ret
);
10643 /* But not if the post messages were added before the PeekMessage() call. */
10645 PostMessageA(hwnd
, WM_USER
, 0, 0);
10646 SetTimer(hwnd
, 1, 0, NULL
);
10647 while (!PeekMessageA(&msg
, NULL
, WM_TIMER
, WM_TIMER
, PM_NOREMOVE
));
10648 ok(msg
.message
== WM_TIMER
, "msg.message = %u instead of WM_TIMER\n", msg
.message
);
10649 ret
= GetMessageA(&msg
, NULL
, 0, 0);
10650 ok(ret
&& msg
.message
== WM_USER
, "msg.message = %u instead of WM_USER\n", msg
.message
);
10651 ret
= GetMessageA(&msg
, NULL
, 0, 0);
10652 ok(ret
&& msg
.message
== WM_TIMER
, "msg.message = %u instead of WM_TIMER\n", msg
.message
);
10653 ret
= PeekMessageA(&msg
, NULL
, 0, 0, 0);
10654 ok(!ret
, "expected PeekMessage to return FALSE, got %u\n", ret
);
10656 /* More complicated test with multiple messages. */
10658 PostMessageA(hwnd
, WM_USER
, 0, 0);
10659 SetTimer(hwnd
, 1, 0, NULL
);
10660 while (!PeekMessageA(&msg
, NULL
, WM_TIMER
, WM_TIMER
, PM_NOREMOVE
));
10661 ok(msg
.message
== WM_TIMER
, "msg.message = %u instead of WM_TIMER\n", msg
.message
);
10662 PostMessageA(hwnd
, WM_USER
+ 1, 0, 0);
10663 ret
= GetMessageA(&msg
, NULL
, 0, 0);
10664 ok(ret
&& msg
.message
== WM_USER
, "msg.message = %u instead of WM_USER\n", msg
.message
);
10665 ret
= GetMessageA(&msg
, NULL
, 0, 0);
10667 ok(ret
&& msg
.message
== WM_TIMER
, "msg.message = %u instead of WM_TIMER\n", msg
.message
);
10668 ret
= GetMessageA(&msg
, NULL
, 0, 0);
10670 ok(ret
&& msg
.message
== WM_USER
+ 1, "msg.message = %u instead of WM_USER + 1\n", msg
.message
);
10671 ret
= PeekMessageA(&msg
, NULL
, 0, 0, 0);
10672 ok(!ret
, "expected PeekMessage to return FALSE, got %u\n", ret
);
10674 /* Also works for posted messages, but the situation is a bit different,
10675 * because both messages are in the same queue. */
10677 PostMessageA(hwnd
, WM_TIMER
, 0, 0);
10678 while (!PeekMessageA(&msg
, NULL
, WM_TIMER
, WM_TIMER
, PM_NOREMOVE
));
10679 ok(msg
.message
== WM_TIMER
, "msg.message = %u instead of WM_TIMER\n", msg
.message
);
10680 PostMessageA(hwnd
, WM_USER
, 0, 0);
10681 ret
= GetMessageA(&msg
, NULL
, 0, 0);
10682 ok(ret
&& msg
.message
== WM_TIMER
, "msg.message = %u instead of WM_TIMER\n", msg
.message
);
10683 ret
= GetMessageA(&msg
, NULL
, 0, 0);
10684 ok(ret
&& msg
.message
== WM_USER
, "msg.message = %u instead of WM_USER\n", msg
.message
);
10685 ret
= PeekMessageA(&msg
, NULL
, 0, 0, 0);
10686 ok(!ret
, "expected PeekMessage to return FALSE, got %u\n", ret
);
10688 PostMessageA(hwnd
, WM_USER
, 0, 0);
10689 PostMessageA(hwnd
, WM_TIMER
, 0, 0);
10690 while (!PeekMessageA(&msg
, NULL
, WM_TIMER
, WM_TIMER
, PM_NOREMOVE
));
10691 ok(msg
.message
== WM_TIMER
, "msg.message = %u instead of WM_TIMER\n", msg
.message
);
10692 ret
= GetMessageA(&msg
, NULL
, 0, 0);
10693 ok(ret
&& msg
.message
== WM_USER
, "msg.message = %u instead of WM_USER\n", msg
.message
);
10694 ret
= GetMessageA(&msg
, NULL
, 0, 0);
10695 ok(ret
&& msg
.message
== WM_TIMER
, "msg.message = %u instead of WM_TIMER\n", msg
.message
);
10696 ret
= PeekMessageA(&msg
, NULL
, 0, 0, 0);
10697 ok(!ret
, "expected PeekMessage to return FALSE, got %u\n", ret
);
10699 DestroyWindow(hwnd
);
10703 static INT_PTR CALLBACK
wm_quit_dlg_proc(HWND hwnd
, UINT message
, WPARAM wp
, LPARAM lp
)
10705 struct recvd_message msg
;
10707 if (ignore_message( message
)) return 0;
10710 msg
.message
= message
;
10711 msg
.flags
= sent
|wparam
|lparam
;
10714 msg
.descr
= "dialog";
10719 case WM_INITDIALOG
:
10720 PostMessageA(hwnd
, WM_QUIT
, 0x1234, 0x5678);
10721 PostMessageA(hwnd
, WM_USER
, 0xdead, 0xbeef);
10724 case WM_GETDLGCODE
:
10728 EndDialog(hwnd
, 0);
10735 static const struct message WmQuitDialogSeq
[] = {
10736 { HCBT_CREATEWND
, hook
},
10737 { WM_SETFONT
, sent
},
10738 { WM_INITDIALOG
, sent
},
10739 { WM_CHANGEUISTATE
, sent
|optional
},
10740 { HCBT_DESTROYWND
, hook
},
10741 { 0x0090, sent
|optional
}, /* Vista */
10742 { WM_DESTROY
, sent
},
10743 { WM_NCDESTROY
, sent
},
10747 static const struct message WmStopQuitSeq
[] = {
10748 { WM_DWMNCRENDERINGCHANGED
, posted
|optional
},
10749 { WM_CLOSE
, posted
},
10750 { WM_QUIT
, posted
|wparam
|lparam
, 0x1234, 0 },
10754 static void test_quit_message(void)
10759 /* test using PostQuitMessage */
10761 PostQuitMessage(0xbeef);
10764 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_QS_SENDMESSAGE
);
10765 ok(!ret
, "got %x message\n", msg
.message
);
10767 ret
= PeekMessageA(&msg
, NULL
, 0, 0, PM_NOREMOVE
);
10768 ok(ret
, "PeekMessage failed with error %d\n", GetLastError());
10769 ok(msg
.message
== WM_QUIT
, "Received message 0x%04x instead of WM_QUIT\n", msg
.message
);
10770 ok(msg
.wParam
== 0xbeef, "wParam was 0x%lx instead of 0xbeef\n", msg
.wParam
);
10772 ret
= PostThreadMessageA(GetCurrentThreadId(), WM_USER
, 0, 0);
10773 ok(ret
, "PostMessage failed with error %d\n", GetLastError());
10775 ret
= GetMessageA(&msg
, NULL
, 0, 0);
10776 ok(ret
> 0, "GetMessage failed with error %d\n", GetLastError());
10777 ok(msg
.message
== WM_USER
, "Received message 0x%04x instead of WM_USER\n", msg
.message
);
10779 /* note: WM_QUIT message received after WM_USER message */
10780 ret
= GetMessageA(&msg
, NULL
, 0, 0);
10781 ok(!ret
, "GetMessage return %d with error %d instead of FALSE\n", ret
, GetLastError());
10782 ok(msg
.message
== WM_QUIT
, "Received message 0x%04x instead of WM_QUIT\n", msg
.message
);
10783 ok(msg
.wParam
== 0xbeef, "wParam was 0x%lx instead of 0xbeef\n", msg
.wParam
);
10785 ret
= PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
);
10786 ok( !ret
|| msg
.message
!= WM_QUIT
, "Received WM_QUIT again\n" );
10788 /* now test with PostThreadMessage - different behaviour! */
10789 PostThreadMessageA(GetCurrentThreadId(), WM_QUIT
, 0xdead, 0);
10791 ret
= PeekMessageA(&msg
, NULL
, 0, 0, PM_NOREMOVE
);
10792 ok(ret
, "PeekMessage failed with error %d\n", GetLastError());
10793 ok(msg
.message
== WM_QUIT
, "Received message 0x%04x instead of WM_QUIT\n", msg
.message
);
10794 ok(msg
.wParam
== 0xdead, "wParam was 0x%lx instead of 0xdead\n", msg
.wParam
);
10796 ret
= PostThreadMessageA(GetCurrentThreadId(), WM_USER
, 0, 0);
10797 ok(ret
, "PostMessage failed with error %d\n", GetLastError());
10799 /* note: we receive the WM_QUIT message first this time */
10800 ret
= GetMessageA(&msg
, NULL
, 0, 0);
10801 ok(!ret
, "GetMessage return %d with error %d instead of FALSE\n", ret
, GetLastError());
10802 ok(msg
.message
== WM_QUIT
, "Received message 0x%04x instead of WM_QUIT\n", msg
.message
);
10803 ok(msg
.wParam
== 0xdead, "wParam was 0x%lx instead of 0xdead\n", msg
.wParam
);
10805 ret
= GetMessageA(&msg
, NULL
, 0, 0);
10806 ok(ret
> 0, "GetMessage failed with error %d\n", GetLastError());
10807 ok(msg
.message
== WM_USER
, "Received message 0x%04x instead of WM_USER\n", msg
.message
);
10811 ret
= DialogBoxParamA(GetModuleHandleA(NULL
), "TEST_EMPTY_DIALOG", 0, wm_quit_dlg_proc
, 0);
10812 ok(ret
== 1, "expected 1, got %d\n", ret
);
10813 ok_sequence(WmQuitDialogSeq
, "WmQuitDialogSeq", FALSE
);
10814 memset(&msg
, 0xab, sizeof(msg
));
10815 ret
= PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
);
10816 ok(ret
, "PeekMessage failed\n");
10817 ok(msg
.message
== WM_QUIT
, "Received message 0x%04x instead of WM_QUIT\n", msg
.message
);
10818 ok(msg
.wParam
== 0x1234, "wParam was 0x%lx instead of 0x1234\n", msg
.wParam
);
10819 ok(msg
.lParam
== 0, "lParam was 0x%lx instead of 0\n", msg
.lParam
);
10821 /* Check what happens to a WM_QUIT message posted to a window that gets
10824 CreateWindowExA(0, "StopQuitClass", "Stop Quit Test", WS_OVERLAPPEDWINDOW
,
10825 0, 0, 100, 100, NULL
, NULL
, NULL
, NULL
);
10827 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
))
10829 struct recvd_message rmsg
;
10830 rmsg
.hwnd
= msg
.hwnd
;
10831 rmsg
.message
= msg
.message
;
10832 rmsg
.flags
= posted
|wparam
|lparam
;
10833 rmsg
.wParam
= msg
.wParam
;
10834 rmsg
.lParam
= msg
.lParam
;
10835 rmsg
.descr
= "stop/quit";
10836 if (msg
.message
== WM_QUIT
)
10837 /* The hwnd can only be checked here */
10838 ok(!msg
.hwnd
, "The WM_QUIT hwnd was %p instead of NULL\n", msg
.hwnd
);
10839 add_message(&rmsg
);
10840 DispatchMessageA(&msg
);
10842 ok_sequence(WmStopQuitSeq
, "WmStopQuitSeq", FALSE
);
10845 static const struct message WmMouseHoverSeq
[] = {
10846 { WM_MOUSEACTIVATE
, sent
|optional
}, /* we can get those when moving the mouse in focus-follow-mouse mode under X11 */
10847 { WM_MOUSEACTIVATE
, sent
|optional
},
10848 { WM_TIMER
, sent
|optional
}, /* XP sends it */
10849 { WM_SYSTIMER
, sent
},
10850 { WM_MOUSEHOVER
, sent
|wparam
, 0 },
10854 static void pump_msg_loop_timeout(DWORD timeout
, BOOL inject_mouse_move
)
10857 DWORD start_ticks
, end_ticks
;
10859 start_ticks
= GetTickCount();
10860 /* add some deviation (50%) to cover not expected delays */
10861 start_ticks
+= timeout
/ 2;
10865 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
))
10867 /* Timer proc messages are not dispatched to the window proc,
10868 * and therefore not logged.
10870 if ((msg
.message
== WM_TIMER
|| msg
.message
== WM_SYSTIMER
) && msg
.hwnd
)
10872 struct recvd_message s_msg
;
10874 s_msg
.hwnd
= msg
.hwnd
;
10875 s_msg
.message
= msg
.message
;
10876 s_msg
.flags
= sent
|wparam
|lparam
;
10877 s_msg
.wParam
= msg
.wParam
;
10878 s_msg
.lParam
= msg
.lParam
;
10879 s_msg
.descr
= "msg_loop";
10880 add_message(&s_msg
);
10882 DispatchMessageA(&msg
);
10885 end_ticks
= GetTickCount();
10887 /* inject WM_MOUSEMOVE to see how it changes tracking */
10888 if (inject_mouse_move
&& start_ticks
+ timeout
/ 2 >= end_ticks
)
10890 mouse_event(MOUSEEVENTF_MOVE
, -1, 0, 0, 0);
10891 mouse_event(MOUSEEVENTF_MOVE
, 1, 0, 0, 0);
10893 inject_mouse_move
= FALSE
;
10895 } while (start_ticks
+ timeout
>= end_ticks
);
10898 static void test_TrackMouseEvent(void)
10900 TRACKMOUSEEVENT tme
;
10903 RECT rc_parent
, rc_child
;
10904 UINT default_hover_time
, hover_width
= 0, hover_height
= 0;
10906 #define track_hover(track_hwnd, track_hover_time) \
10907 tme.cbSize = sizeof(tme); \
10908 tme.dwFlags = TME_HOVER; \
10909 tme.hwndTrack = track_hwnd; \
10910 tme.dwHoverTime = track_hover_time; \
10911 SetLastError(0xdeadbeef); \
10912 ret = pTrackMouseEvent(&tme); \
10913 ok(ret, "TrackMouseEvent(TME_HOVER) error %d\n", GetLastError())
10915 #define track_query(expected_track_flags, expected_track_hwnd, expected_hover_time) \
10916 tme.cbSize = sizeof(tme); \
10917 tme.dwFlags = TME_QUERY; \
10918 tme.hwndTrack = (HWND)0xdeadbeef; \
10919 tme.dwHoverTime = 0xdeadbeef; \
10920 SetLastError(0xdeadbeef); \
10921 ret = pTrackMouseEvent(&tme); \
10922 ok(ret, "TrackMouseEvent(TME_QUERY) error %d\n", GetLastError());\
10923 ok(tme.cbSize == sizeof(tme), "wrong tme.cbSize %u\n", tme.cbSize); \
10924 ok(tme.dwFlags == (expected_track_flags), \
10925 "wrong tme.dwFlags %08x, expected %08x\n", tme.dwFlags, (expected_track_flags)); \
10926 ok(tme.hwndTrack == (expected_track_hwnd), \
10927 "wrong tme.hwndTrack %p, expected %p\n", tme.hwndTrack, (expected_track_hwnd)); \
10928 ok(tme.dwHoverTime == (expected_hover_time), \
10929 "wrong tme.dwHoverTime %u, expected %u\n", tme.dwHoverTime, (expected_hover_time))
10931 #define track_hover_cancel(track_hwnd) \
10932 tme.cbSize = sizeof(tme); \
10933 tme.dwFlags = TME_HOVER | TME_CANCEL; \
10934 tme.hwndTrack = track_hwnd; \
10935 tme.dwHoverTime = 0xdeadbeef; \
10936 SetLastError(0xdeadbeef); \
10937 ret = pTrackMouseEvent(&tme); \
10938 ok(ret, "TrackMouseEvent(TME_HOVER | TME_CANCEL) error %d\n", GetLastError())
10940 default_hover_time
= 0xdeadbeef;
10941 SetLastError(0xdeadbeef);
10942 ret
= SystemParametersInfoA(SPI_GETMOUSEHOVERTIME
, 0, &default_hover_time
, 0);
10943 ok(ret
|| broken(GetLastError() == 0xdeadbeef), /* win9x */
10944 "SystemParametersInfo(SPI_GETMOUSEHOVERTIME) error %u\n", GetLastError());
10945 if (!ret
) default_hover_time
= 400;
10946 trace("SPI_GETMOUSEHOVERTIME returned %u ms\n", default_hover_time
);
10948 SetLastError(0xdeadbeef);
10949 ret
= SystemParametersInfoA(SPI_GETMOUSEHOVERWIDTH
, 0, &hover_width
, 0);
10950 ok(ret
|| broken(GetLastError() == 0xdeadbeef), /* win9x */
10951 "SystemParametersInfo(SPI_GETMOUSEHOVERWIDTH) error %u\n", GetLastError());
10952 if (!ret
) hover_width
= 4;
10953 SetLastError(0xdeadbeef);
10954 ret
= SystemParametersInfoA(SPI_GETMOUSEHOVERHEIGHT
, 0, &hover_height
, 0);
10955 ok(ret
|| broken(GetLastError() == 0xdeadbeef), /* win9x */
10956 "SystemParametersInfo(SPI_GETMOUSEHOVERHEIGHT) error %u\n", GetLastError());
10957 if (!ret
) hover_height
= 4;
10958 trace("hover rect is %u x %d\n", hover_width
, hover_height
);
10960 hwnd
= CreateWindowExA(0, "TestWindowClass", NULL
,
10961 WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
10962 CW_USEDEFAULT
, CW_USEDEFAULT
, 300, 300, 0,
10966 hchild
= CreateWindowExA(0, "TestWindowClass", NULL
,
10967 WS_CHILD
| WS_BORDER
| WS_VISIBLE
,
10968 50, 50, 200, 200, hwnd
,
10972 SetWindowPos( hwnd
, HWND_TOPMOST
, 0, 0, 0, 0, SWP_NOSIZE
|SWP_NOMOVE
);
10977 tme
.dwFlags
= TME_QUERY
;
10978 tme
.hwndTrack
= (HWND
)0xdeadbeef;
10979 tme
.dwHoverTime
= 0xdeadbeef;
10980 SetLastError(0xdeadbeef);
10981 ret
= pTrackMouseEvent(&tme
);
10982 ok(!ret
, "TrackMouseEvent should fail\n");
10983 ok(GetLastError() == ERROR_INVALID_PARAMETER
|| broken(GetLastError() == 0xdeadbeef),
10984 "not expected error %u\n", GetLastError());
10986 tme
.cbSize
= sizeof(tme
);
10987 tme
.dwFlags
= TME_HOVER
;
10988 tme
.hwndTrack
= (HWND
)0xdeadbeef;
10989 tme
.dwHoverTime
= 0xdeadbeef;
10990 SetLastError(0xdeadbeef);
10991 ret
= pTrackMouseEvent(&tme
);
10992 ok(!ret
, "TrackMouseEvent should fail\n");
10993 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
|| broken(GetLastError() == 0xdeadbeef),
10994 "not expected error %u\n", GetLastError());
10996 tme
.cbSize
= sizeof(tme
);
10997 tme
.dwFlags
= TME_HOVER
| TME_CANCEL
;
10998 tme
.hwndTrack
= (HWND
)0xdeadbeef;
10999 tme
.dwHoverTime
= 0xdeadbeef;
11000 SetLastError(0xdeadbeef);
11001 ret
= pTrackMouseEvent(&tme
);
11002 ok(!ret
, "TrackMouseEvent should fail\n");
11003 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
|| broken(GetLastError() == 0xdeadbeef),
11004 "not expected error %u\n", GetLastError());
11006 GetWindowRect(hwnd
, &rc_parent
);
11007 GetWindowRect(hchild
, &rc_child
);
11008 SetCursorPos(rc_child
.left
- 10, rc_child
.top
- 10);
11010 /* Process messages so that the system updates its internal current
11011 * window and hittest, otherwise TrackMouseEvent calls don't have any
11017 track_query(0, NULL
, 0);
11018 track_hover(hchild
, 0);
11019 track_query(0, NULL
, 0);
11024 track_hover(hwnd
, 0);
11025 tme
.cbSize
= sizeof(tme
);
11026 tme
.dwFlags
= TME_QUERY
;
11027 tme
.hwndTrack
= (HWND
)0xdeadbeef;
11028 tme
.dwHoverTime
= 0xdeadbeef;
11029 SetLastError(0xdeadbeef);
11030 ret
= pTrackMouseEvent(&tme
);
11031 ok(ret
, "TrackMouseEvent(TME_QUERY) error %d\n", GetLastError());
11032 ok(tme
.cbSize
== sizeof(tme
), "wrong tme.cbSize %u\n", tme
.cbSize
);
11035 skip( "Cursor not inside window, skipping TrackMouseEvent tests\n" );
11036 DestroyWindow( hwnd
);
11039 ok(tme
.dwFlags
== TME_HOVER
, "wrong tme.dwFlags %08x, expected TME_HOVER\n", tme
.dwFlags
);
11040 ok(tme
.hwndTrack
== hwnd
, "wrong tme.hwndTrack %p, expected %p\n", tme
.hwndTrack
, hwnd
);
11041 ok(tme
.dwHoverTime
== default_hover_time
, "wrong tme.dwHoverTime %u, expected %u\n",
11042 tme
.dwHoverTime
, default_hover_time
);
11044 pump_msg_loop_timeout(default_hover_time
, FALSE
);
11045 ok_sequence(WmMouseHoverSeq
, "WmMouseHoverSeq", FALSE
);
11047 track_query(0, NULL
, 0);
11049 track_hover(hwnd
, HOVER_DEFAULT
);
11050 track_query(TME_HOVER
, hwnd
, default_hover_time
);
11052 Sleep(default_hover_time
/ 2);
11053 mouse_event(MOUSEEVENTF_MOVE
, -1, 0, 0, 0);
11054 mouse_event(MOUSEEVENTF_MOVE
, 1, 0, 0, 0);
11056 track_query(TME_HOVER
, hwnd
, default_hover_time
);
11058 pump_msg_loop_timeout(default_hover_time
, FALSE
);
11059 ok_sequence(WmMouseHoverSeq
, "WmMouseHoverSeq", FALSE
);
11061 track_query(0, NULL
, 0);
11063 track_hover(hwnd
, HOVER_DEFAULT
);
11064 track_query(TME_HOVER
, hwnd
, default_hover_time
);
11066 pump_msg_loop_timeout(default_hover_time
, TRUE
);
11067 ok_sequence(WmMouseHoverSeq
, "WmMouseHoverSeq", FALSE
);
11069 track_query(0, NULL
, 0);
11071 track_hover(hwnd
, HOVER_DEFAULT
);
11072 track_query(TME_HOVER
, hwnd
, default_hover_time
);
11073 track_hover_cancel(hwnd
);
11075 DestroyWindow(hwnd
);
11079 #undef track_hover_cancel
11083 static const struct message WmSetWindowRgn
[] = {
11084 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
},
11085 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
11086 { WM_NCPAINT
, sent
|optional
}, /* wparam != 1 */
11087 { WM_GETTEXT
, sent
|defwinproc
|optional
},
11088 { WM_ERASEBKGND
, sent
|optional
},
11089 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
},
11090 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
11094 static const struct message WmSetWindowRgn_no_redraw
[] = {
11095 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
},
11096 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
11097 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
},
11098 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
11102 static const struct message WmSetWindowRgn_clear
[] = {
11103 { WM_WINDOWPOSCHANGING
, sent
/*|wparam*/, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
/*|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE only on some Windows versions */ },
11104 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
11105 { WM_NCPAINT
, sent
|optional
},
11106 { WM_GETTEXT
, sent
|defwinproc
|optional
},
11107 { WM_ERASEBKGND
, sent
|optional
}, /* FIXME: remove optional once Wine is fixed */
11108 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
},
11109 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
11110 { WM_NCPAINT
, sent
|optional
},
11111 { WM_GETTEXT
, sent
|defwinproc
|optional
},
11112 { WM_ERASEBKGND
, sent
|optional
},
11113 { WM_WINDOWPOSCHANGING
, sent
|optional
},
11114 { WM_NCCALCSIZE
, sent
|optional
|wparam
, 1 },
11115 { WM_NCPAINT
, sent
|optional
},
11116 { WM_GETTEXT
, sent
|defwinproc
|optional
},
11117 { WM_ERASEBKGND
, sent
|optional
},
11118 { WM_WINDOWPOSCHANGED
, sent
|optional
|wparam
, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
},
11119 { WM_NCCALCSIZE
, sent
|optional
|wparam
, 1 },
11120 { WM_NCPAINT
, sent
|optional
},
11121 { WM_GETTEXT
, sent
|defwinproc
|optional
},
11122 { WM_ERASEBKGND
, sent
|optional
},
11123 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
11124 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
11128 static void test_SetWindowRgn(void)
11131 HWND hwnd
= CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW
,
11132 100, 100, 200, 200, 0, 0, 0, NULL
);
11133 ok( hwnd
!= 0, "Failed to create overlapped window\n" );
11135 ShowWindow( hwnd
, SW_SHOW
);
11136 UpdateWindow( hwnd
);
11140 trace("testing SetWindowRgn\n");
11141 hrgn
= CreateRectRgn( 0, 0, 150, 150 );
11142 SetWindowRgn( hwnd
, hrgn
, TRUE
);
11143 ok_sequence( WmSetWindowRgn
, "WmSetWindowRgn", FALSE
);
11145 hrgn
= CreateRectRgn( 30, 30, 160, 160 );
11146 SetWindowRgn( hwnd
, hrgn
, FALSE
);
11147 ok_sequence( WmSetWindowRgn_no_redraw
, "WmSetWindowRgn_no_redraw", FALSE
);
11149 hrgn
= CreateRectRgn( 0, 0, 180, 180 );
11150 SetWindowRgn( hwnd
, hrgn
, TRUE
);
11151 ok_sequence( WmSetWindowRgn
, "WmSetWindowRgn2", FALSE
);
11153 SetWindowRgn( hwnd
, 0, TRUE
);
11154 ok_sequence( WmSetWindowRgn_clear
, "WmSetWindowRgn_clear", FALSE
);
11156 DestroyWindow( hwnd
);
11159 /*************************** ShowWindow() test ******************************/
11160 static const struct message WmShowNormal
[] = {
11161 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
11162 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
11163 { HCBT_ACTIVATE
, hook
},
11164 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2003 doesn't send it */
11165 { HCBT_SETFOCUS
, hook
},
11166 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
11169 static const struct message WmShow
[] = {
11170 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
11171 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
11172 { HCBT_ACTIVATE
, hook
|optional
}, /* win2000 doesn't send it */
11173 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2000 doesn't send it */
11174 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 doesn't send it */
11175 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
11178 static const struct message WmShowNoActivate_1
[] = {
11179 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWNOACTIVATE
},
11180 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_STATECHANGED
, 0, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOSIZE
|SWP_NOMOVE
},
11181 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_STATECHANGED
, 0, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOSIZE
|SWP_NOMOVE
},
11182 { WM_MOVE
, sent
|defwinproc
|optional
},
11183 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_RESTORED
},
11186 static const struct message WmShowNoActivate_2
[] = {
11187 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWNOACTIVATE
},
11188 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
, 0, SWP_NOACTIVATE
},
11189 { HCBT_ACTIVATE
, hook
|optional
},
11190 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
11191 { HCBT_SETFOCUS
, hook
|optional
},
11192 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
, 0, SWP_NOACTIVATE
},
11193 { WM_MOVE
, sent
|defwinproc
},
11194 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_RESTORED
},
11195 { HCBT_SETFOCUS
, hook
|optional
},
11196 { HCBT_ACTIVATE
, hook
|optional
}, /* win2003 doesn't send it */
11197 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2003 doesn't send it */
11198 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
11199 { HCBT_SETFOCUS
, hook
|optional
}, /* win2003 doesn't send it */
11202 static const struct message WmShowNA_1
[] = {
11203 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
11204 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
11205 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
11208 static const struct message WmShowNA_2
[] = {
11209 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
11210 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
11211 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
11214 static const struct message WmRestore_1
[] = {
11215 { HCBT_MINMAX
, hook
|lparam
, 0, SW_RESTORE
},
11216 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
11217 { HCBT_ACTIVATE
, hook
|optional
}, /* win2000 doesn't send it */
11218 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2000 doesn't send it */
11219 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 doesn't send it */
11220 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
11221 { WM_MOVE
, sent
|defwinproc
},
11222 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_RESTORED
},
11223 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 sends it */
11226 static const struct message WmRestore_2
[] = {
11227 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
11228 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
11229 { HCBT_ACTIVATE
, hook
|optional
}, /* win2000 doesn't send it */
11230 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2000 doesn't send it */
11231 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 doesn't send it */
11232 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
11235 static const struct message WmRestore_3
[] = {
11236 { HCBT_MINMAX
, hook
|lparam
, 0, SW_RESTORE
},
11237 { WM_GETMINMAXINFO
, sent
},
11238 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
11239 { HCBT_ACTIVATE
, hook
|optional
}, /* win2003 doesn't send it */
11240 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2003 doesn't send it */
11241 { HCBT_SETFOCUS
, hook
|optional
}, /* win2003 doesn't send it */
11242 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
11243 { WM_MOVE
, sent
|defwinproc
},
11244 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_MAXIMIZED
},
11245 { HCBT_SETFOCUS
, hook
|optional
}, /* win2003 sends it */
11248 static const struct message WmRestore_4
[] = {
11249 { HCBT_MINMAX
, hook
|lparam
|optional
, 0, SW_RESTORE
},
11250 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_FRAMECHANGED
|SWP_STATECHANGED
, 0, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOSIZE
|SWP_NOMOVE
},
11251 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_FRAMECHANGED
|SWP_STATECHANGED
, 0, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOSIZE
|SWP_NOMOVE
},
11252 { WM_MOVE
, sent
|defwinproc
|optional
},
11253 { WM_SIZE
, sent
|wparam
|defwinproc
|optional
, SIZE_RESTORED
},
11256 static const struct message WmRestore_5
[] = {
11257 { HCBT_MINMAX
, hook
|lparam
|optional
, 0, SW_SHOWNORMAL
},
11258 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_FRAMECHANGED
|SWP_STATECHANGED
, 0, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOSIZE
|SWP_NOMOVE
},
11259 { HCBT_ACTIVATE
, hook
|optional
},
11260 { HCBT_SETFOCUS
, hook
|optional
},
11261 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_FRAMECHANGED
|SWP_STATECHANGED
, 0, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOSIZE
|SWP_NOMOVE
},
11262 { WM_MOVE
, sent
|defwinproc
|optional
},
11263 { WM_SIZE
, sent
|wparam
|defwinproc
|optional
, SIZE_RESTORED
},
11266 static const struct message WmHide_1
[] = {
11267 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
11268 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
, 0, SWP_NOACTIVATE
},
11269 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
, 0, SWP_NOACTIVATE
},
11270 { HCBT_ACTIVATE
, hook
|optional
},
11271 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 sends it */
11274 static const struct message WmHide_2
[] = {
11275 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
11276 { WM_WINDOWPOSCHANGING
, sent
/*|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE*/ }, /* win2000 doesn't add SWP_NOACTIVATE */
11277 { WM_WINDOWPOSCHANGED
, sent
/*|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE*/ }, /* win2000 doesn't add SWP_NOACTIVATE */
11278 { HCBT_ACTIVATE
, hook
|optional
},
11281 static const struct message WmHide_3
[] = {
11282 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
11283 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
11284 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
11285 { HCBT_SETFOCUS
, hook
|optional
},
11286 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
11289 static const struct message WmShowMinimized_1
[] = {
11290 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINIMIZED
},
11291 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
11292 { HCBT_ACTIVATE
, hook
|optional
}, /* win2000 doesn't send it */
11293 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2000 doesn't send it */
11294 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
11295 { WM_MOVE
, sent
|defwinproc
},
11296 { WM_SIZE
, sent
|wparam
|lparam
|defwinproc
, SIZE_MINIMIZED
, 0 },
11299 static const struct message WmMinimize_1
[] = {
11300 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
11301 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 doesn't send it */
11302 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
11303 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
11304 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
11305 { WM_MOVE
, sent
|defwinproc
},
11306 { WM_SIZE
, sent
|wparam
|lparam
|defwinproc
, SIZE_MINIMIZED
, 0 },
11309 static const struct message WmMinimize_2
[] = {
11310 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
11311 { HCBT_SETFOCUS
, hook
|optional
},
11312 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
, 0, SWP_NOACTIVATE
},
11313 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
, 0, SWP_NOACTIVATE
},
11314 { WM_MOVE
, sent
|defwinproc
},
11315 { WM_SIZE
, sent
|wparam
|lparam
|defwinproc
, SIZE_MINIMIZED
, 0 },
11318 static const struct message WmMinimize_3
[] = {
11319 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
11320 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
, 0, SWP_NOACTIVATE
},
11321 { HCBT_ACTIVATE
, hook
|optional
},
11322 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
11323 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
, 0, SWP_NOACTIVATE
},
11324 { WM_MOVE
, sent
|defwinproc
},
11325 { WM_SIZE
, sent
|wparam
|lparam
|defwinproc
, SIZE_MINIMIZED
, 0 },
11328 static const struct message WmShowMinNoActivate
[] = {
11329 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINNOACTIVE
},
11330 { WM_WINDOWPOSCHANGING
, sent
},
11331 { WM_WINDOWPOSCHANGED
, sent
},
11332 { WM_MOVE
, sent
|defwinproc
|optional
},
11333 { WM_SIZE
, sent
|wparam
|lparam
|defwinproc
|optional
, SIZE_MINIMIZED
, 0 },
11336 static const struct message WmMinMax_1
[] = {
11337 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINIMIZED
},
11340 static const struct message WmMinMax_2
[] = {
11341 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMAXIMIZED
},
11342 { WM_GETMINMAXINFO
, sent
|optional
},
11343 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
11344 { HCBT_ACTIVATE
, hook
|optional
},
11345 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
11346 { HCBT_SETFOCUS
, hook
|optional
},
11347 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_FRAMECHANGED
|SWP_STATECHANGED
, 0, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
11348 { WM_MOVE
, sent
|defwinproc
|optional
},
11349 { WM_SIZE
, sent
|wparam
|defwinproc
|optional
, SIZE_MAXIMIZED
},
11350 { HCBT_SETFOCUS
, hook
|optional
},
11353 static const struct message WmMinMax_3
[] = {
11354 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
11355 { HCBT_SETFOCUS
, hook
|optional
},
11356 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
11357 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
11358 { WM_MOVE
, sent
|defwinproc
|optional
},
11359 { WM_SIZE
, sent
|wparam
|lparam
|defwinproc
|optional
, SIZE_MINIMIZED
, 0 },
11362 static const struct message WmMinMax_4
[] = {
11363 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINNOACTIVE
},
11366 static const struct message WmShowMaximized_1
[] = {
11367 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMAXIMIZED
},
11368 { WM_GETMINMAXINFO
, sent
},
11369 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
11370 { HCBT_ACTIVATE
, hook
|optional
}, /* win2000 doesn't send it */
11371 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2000 doesn't send it */
11372 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 doesn't send it */
11373 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
11374 { WM_MOVE
, sent
|defwinproc
},
11375 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_MAXIMIZED
},
11376 { HCBT_SETFOCUS
, hook
|optional
}, /* win2003 sends it */
11379 static const struct message WmShowMaximized_2
[] = {
11380 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMAXIMIZED
},
11381 { WM_GETMINMAXINFO
, sent
},
11382 { WM_WINDOWPOSCHANGING
, sent
|optional
},
11383 { HCBT_ACTIVATE
, hook
|optional
},
11384 { WM_WINDOWPOSCHANGED
, sent
|optional
},
11385 { WM_MOVE
, sent
|optional
}, /* Win9x doesn't send it */
11386 { WM_SIZE
, sent
|wparam
|optional
, SIZE_MAXIMIZED
}, /* Win9x doesn't send it */
11387 { WM_WINDOWPOSCHANGING
, sent
|optional
},
11388 { HCBT_SETFOCUS
, hook
|optional
},
11389 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
11390 { WM_MOVE
, sent
|defwinproc
},
11391 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_MAXIMIZED
},
11392 { HCBT_SETFOCUS
, hook
|optional
},
11395 static const struct message WmShowMaximized_3
[] = {
11396 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMAXIMIZED
},
11397 { WM_GETMINMAXINFO
, sent
|optional
},
11398 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
, 0, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOSIZE
|SWP_NOMOVE
},
11399 { HCBT_ACTIVATE
, hook
|optional
}, /* win2000 doesn't send it */
11400 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2000 doesn't send it */
11401 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 doesn't send it */
11402 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
, 0, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOSIZE
|SWP_NOMOVE
},
11403 { WM_MOVE
, sent
|defwinproc
|optional
},
11404 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_MAXIMIZED
},
11408 static void test_ShowWindow(void)
11410 /* ShowWindow commands in random order */
11411 static const struct
11413 INT cmd
; /* ShowWindow command */
11414 LPARAM ret
; /* ShowWindow return value */
11415 DWORD style
; /* window style after the command */
11416 const struct message
*msg
; /* message sequence the command produces */
11417 INT wp_cmd
, wp_flags
; /* window placement after the command */
11418 POINT wp_min
, wp_max
; /* window placement after the command */
11419 BOOL todo_msg
; /* message sequence doesn't match what Wine does */
11422 /* 1 */ { SW_SHOWNORMAL
, FALSE
, WS_VISIBLE
, WmShowNormal
,
11423 SW_SHOWNORMAL
, 0, {-1,-1}, {-1,-1}, FALSE
},
11424 /* 2 */ { SW_SHOWNORMAL
, TRUE
, WS_VISIBLE
, WmEmptySeq
,
11425 SW_SHOWNORMAL
, 0, {-1,-1}, {-1,-1}, FALSE
},
11426 /* 3 */ { SW_HIDE
, TRUE
, 0, WmHide_1
,
11427 SW_SHOWNORMAL
, 0, {-1,-1}, {-1,-1}, FALSE
},
11428 /* 4 */ { SW_HIDE
, FALSE
, 0, WmEmptySeq
,
11429 SW_SHOWNORMAL
, 0, {-1,-1}, {-1,-1}, FALSE
},
11430 /* 5 */ { SW_SHOWMINIMIZED
, FALSE
, WS_VISIBLE
|WS_MINIMIZE
, WmShowMinimized_1
,
11431 SW_SHOWMINIMIZED
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
11432 /* 6 */ { SW_SHOWMINIMIZED
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinMax_1
,
11433 SW_SHOWMINIMIZED
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
11434 /* 7 */ { SW_HIDE
, TRUE
, WS_MINIMIZE
, WmHide_1
,
11435 SW_SHOWMINIMIZED
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
11436 /* 8 */ { SW_HIDE
, FALSE
, WS_MINIMIZE
, WmEmptySeq
,
11437 SW_SHOWMINIMIZED
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
11438 /* 9 */ { SW_SHOWMAXIMIZED
, FALSE
, WS_VISIBLE
|WS_MAXIMIZE
, WmShowMaximized_1
,
11439 SW_SHOWMAXIMIZED
, WPF_RESTORETOMAXIMIZED
, {-32000,-32000}, {-1,-1}, FALSE
},
11440 /* 10 */ { SW_SHOWMAXIMIZED
, TRUE
, WS_VISIBLE
|WS_MAXIMIZE
, WmMinMax_2
,
11441 SW_SHOWMAXIMIZED
, WPF_RESTORETOMAXIMIZED
, {-32000,-32000}, {-1,-1}, FALSE
},
11442 /* 11 */ { SW_HIDE
, TRUE
, WS_MAXIMIZE
, WmHide_1
,
11443 SW_SHOWMAXIMIZED
, WPF_RESTORETOMAXIMIZED
, {-32000,-32000}, {-1,-1}, FALSE
},
11444 /* 12 */ { SW_HIDE
, FALSE
, WS_MAXIMIZE
, WmEmptySeq
,
11445 SW_SHOWMAXIMIZED
, WPF_RESTORETOMAXIMIZED
, {-32000,-32000}, {-1,-1}, FALSE
},
11446 /* 13 */ { SW_SHOWNOACTIVATE
, FALSE
, WS_VISIBLE
, WmShowNoActivate_1
,
11447 SW_SHOWNORMAL
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
11448 /* 14 */ { SW_SHOWNOACTIVATE
, TRUE
, WS_VISIBLE
, WmEmptySeq
,
11449 SW_SHOWNORMAL
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
11450 /* 15 */ { SW_HIDE
, TRUE
, 0, WmHide_2
,
11451 SW_SHOWNORMAL
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
11452 /* 16 */ { SW_HIDE
, FALSE
, 0, WmEmptySeq
,
11453 SW_SHOWNORMAL
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
11454 /* 17 */ { SW_SHOW
, FALSE
, WS_VISIBLE
, WmShow
,
11455 SW_SHOWNORMAL
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
11456 /* 18 */ { SW_SHOW
, TRUE
, WS_VISIBLE
, WmEmptySeq
,
11457 SW_SHOWNORMAL
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
11458 /* 19 */ { SW_MINIMIZE
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinimize_1
,
11459 SW_SHOWMINIMIZED
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
11460 /* 20 */ { SW_MINIMIZE
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinMax_3
,
11461 SW_SHOWMINIMIZED
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
11462 /* 21 */ { SW_HIDE
, TRUE
, WS_MINIMIZE
, WmHide_2
,
11463 SW_SHOWMINIMIZED
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
11464 /* 22 */ { SW_SHOWMINNOACTIVE
, FALSE
, WS_VISIBLE
|WS_MINIMIZE
, WmShowMinNoActivate
,
11465 SW_SHOWMINIMIZED
, 0, {-32000,-32000}, {-1,-1}, TRUE
},
11466 /* 23 */ { SW_SHOWMINNOACTIVE
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinMax_4
,
11467 SW_SHOWMINIMIZED
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
11468 /* 24 */ { SW_HIDE
, TRUE
, WS_MINIMIZE
, WmHide_2
,
11469 SW_SHOWMINIMIZED
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
11470 /* 25 */ { SW_HIDE
, FALSE
, WS_MINIMIZE
, WmEmptySeq
,
11471 SW_SHOWMINIMIZED
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
11472 /* 26 */ { SW_SHOWNA
, FALSE
, WS_VISIBLE
|WS_MINIMIZE
, WmShowNA_1
,
11473 SW_SHOWMINIMIZED
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
11474 /* 27 */ { SW_SHOWNA
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmShowNA_2
,
11475 SW_SHOWMINIMIZED
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
11476 /* 28 */ { SW_HIDE
, TRUE
, WS_MINIMIZE
, WmHide_2
,
11477 SW_SHOWMINIMIZED
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
11478 /* 29 */ { SW_HIDE
, FALSE
, WS_MINIMIZE
, WmEmptySeq
,
11479 SW_SHOWMINIMIZED
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
11480 /* 30 */ { SW_RESTORE
, FALSE
, WS_VISIBLE
, WmRestore_1
,
11481 SW_SHOWNORMAL
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
11482 /* 31 */ { SW_RESTORE
, TRUE
, WS_VISIBLE
, WmEmptySeq
,
11483 SW_SHOWNORMAL
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
11484 /* 32 */ { SW_HIDE
, TRUE
, 0, WmHide_3
,
11485 SW_SHOWNORMAL
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
11486 /* 33 */ { SW_HIDE
, FALSE
, 0, WmEmptySeq
,
11487 SW_SHOWNORMAL
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
11488 /* 34 */ { SW_NORMALNA
, FALSE
, 0, WmEmptySeq
, /* what does this mean?! */
11489 SW_SHOWNORMAL
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
11490 /* 35 */ { SW_NORMALNA
, FALSE
, 0, WmEmptySeq
,
11491 SW_SHOWNORMAL
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
11492 /* 36 */ { SW_HIDE
, FALSE
, 0, WmEmptySeq
,
11493 SW_SHOWNORMAL
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
11494 /* 37 */ { SW_RESTORE
, FALSE
, WS_VISIBLE
, WmRestore_2
,
11495 SW_SHOWNORMAL
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
11496 /* 38 */ { SW_RESTORE
, TRUE
, WS_VISIBLE
, WmEmptySeq
,
11497 SW_SHOWNORMAL
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
11498 /* 39 */ { SW_SHOWNOACTIVATE
, TRUE
, WS_VISIBLE
, WmEmptySeq
,
11499 SW_SHOWNORMAL
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
11500 /* 40 */ { SW_MINIMIZE
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinimize_2
,
11501 SW_SHOWMINIMIZED
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
11502 /* 41 */ { SW_MINIMIZE
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinMax_3
,
11503 SW_SHOWMINIMIZED
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
11504 /* 42 */ { SW_SHOWMAXIMIZED
, TRUE
, WS_VISIBLE
|WS_MAXIMIZE
, WmShowMaximized_2
,
11505 SW_SHOWMAXIMIZED
, WPF_RESTORETOMAXIMIZED
, {-32000,-32000}, {-1,-1}, FALSE
},
11506 /* 43 */ { SW_SHOWMAXIMIZED
, TRUE
, WS_VISIBLE
|WS_MAXIMIZE
, WmMinMax_2
,
11507 SW_SHOWMAXIMIZED
, WPF_RESTORETOMAXIMIZED
, {-32000,-32000}, {-1,-1}, FALSE
},
11508 /* 44 */ { SW_MINIMIZE
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinimize_1
,
11509 SW_SHOWMINIMIZED
, WPF_RESTORETOMAXIMIZED
, {-32000,-32000}, {-1,-1}, FALSE
},
11510 /* 45 */ { SW_MINIMIZE
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinMax_3
,
11511 SW_SHOWMINIMIZED
, WPF_RESTORETOMAXIMIZED
, {-32000,-32000}, {-1,-1}, FALSE
},
11512 /* 46 */ { SW_RESTORE
, TRUE
, WS_VISIBLE
|WS_MAXIMIZE
, WmRestore_3
,
11513 SW_SHOWMAXIMIZED
, WPF_RESTORETOMAXIMIZED
, {-32000,-32000}, {-1,-1}, FALSE
},
11514 /* 47 */ { SW_RESTORE
, TRUE
, WS_VISIBLE
, WmRestore_4
,
11515 SW_SHOWNORMAL
, WPF_RESTORETOMAXIMIZED
, {-32000,-32000}, {-1,-1}, FALSE
},
11516 /* 48 */ { SW_SHOWMAXIMIZED
, TRUE
, WS_VISIBLE
|WS_MAXIMIZE
, WmShowMaximized_3
,
11517 SW_SHOWMAXIMIZED
, WPF_RESTORETOMAXIMIZED
, {-32000,-32000}, {-1,-1}, FALSE
},
11518 /* 49 */ { SW_SHOW
, TRUE
, WS_VISIBLE
|WS_MAXIMIZE
, WmEmptySeq
,
11519 SW_SHOWMAXIMIZED
, WPF_RESTORETOMAXIMIZED
, {-32000,-32000}, {-1,-1}, FALSE
},
11520 /* 50 */ { SW_SHOWNORMAL
, TRUE
, WS_VISIBLE
, WmRestore_5
,
11521 SW_SHOWNORMAL
, WPF_RESTORETOMAXIMIZED
, {-32000,-32000}, {-1,-1}, FALSE
},
11522 /* 51 */ { SW_SHOWNORMAL
, TRUE
, WS_VISIBLE
, WmRestore_5
,
11523 SW_SHOWNORMAL
, WPF_RESTORETOMAXIMIZED
, {-32000,-32000}, {-1,-1}, FALSE
},
11524 /* 52 */ { SW_HIDE
, TRUE
, 0, WmHide_1
,
11525 SW_SHOWNORMAL
, WPF_RESTORETOMAXIMIZED
, {-32000,-32000}, {-1,-1}, FALSE
},
11526 /* 53 */ { SW_HIDE
, FALSE
, 0, WmEmptySeq
,
11527 SW_SHOWNORMAL
, WPF_RESTORETOMAXIMIZED
, {-32000,-32000}, {-1,-1}, FALSE
},
11528 /* 54 */ { SW_MINIMIZE
, FALSE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinimize_3
,
11529 SW_SHOWMINIMIZED
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
11530 /* 55 */ { SW_HIDE
, TRUE
, WS_MINIMIZE
, WmHide_2
,
11531 SW_SHOWMINIMIZED
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
11532 /* 56 */ { SW_SHOWNOACTIVATE
, FALSE
, WS_VISIBLE
, WmShowNoActivate_2
,
11533 SW_SHOWNORMAL
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
11534 /* 57 */ { SW_SHOW
, TRUE
, WS_VISIBLE
, WmEmptySeq
,
11535 SW_SHOWNORMAL
, 0, {-32000,-32000}, {-1,-1}, FALSE
}
11541 WINDOWPLACEMENT wp
;
11542 RECT win_rc
, work_rc
= {0, 0, 0, 0};
11544 #define WS_BASE (WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX|WS_MAXIMIZEBOX|WS_POPUP|WS_CLIPSIBLINGS)
11545 hwnd
= CreateWindowExA(0, "ShowWindowClass", NULL
, WS_BASE
,
11550 style
= GetWindowLongA(hwnd
, GWL_STYLE
) & ~WS_BASE
;
11551 ok(style
== 0, "expected style 0, got %08x\n", style
);
11556 if (pGetMonitorInfoA
&& pMonitorFromPoint
)
11562 SetLastError(0xdeadbeef);
11563 hmon
= pMonitorFromPoint(pt
, MONITOR_DEFAULTTOPRIMARY
);
11564 ok(hmon
!= 0, "MonitorFromPoint error %u\n", GetLastError());
11566 mi
.cbSize
= sizeof(mi
);
11567 SetLastError(0xdeadbeef);
11568 ret
= pGetMonitorInfoA(hmon
, &mi
);
11569 ok(ret
, "GetMonitorInfo error %u\n", GetLastError());
11570 trace("monitor (%d,%d-%d,%d), work (%d,%d-%d,%d)\n",
11571 mi
.rcMonitor
.left
, mi
.rcMonitor
.top
, mi
.rcMonitor
.right
, mi
.rcMonitor
.bottom
,
11572 mi
.rcWork
.left
, mi
.rcWork
.top
, mi
.rcWork
.right
, mi
.rcWork
.bottom
);
11573 work_rc
= mi
.rcWork
;
11576 GetWindowRect(hwnd
, &win_rc
);
11577 OffsetRect(&win_rc
, -work_rc
.left
, -work_rc
.top
);
11579 wp
.length
= sizeof(wp
);
11580 SetLastError(0xdeadbeaf);
11581 ret
= GetWindowPlacement(hwnd
, &wp
);
11582 ok(ret
, "GetWindowPlacement error %u\n", GetLastError());
11583 ok(wp
.flags
== 0, "expected 0, got %#x\n", wp
.flags
);
11584 ok(wp
.showCmd
== SW_SHOWNORMAL
, "expected SW_SHOWNORMAL, got %d\n", wp
.showCmd
);
11585 ok(wp
.ptMinPosition
.x
== -1 && wp
.ptMinPosition
.y
== -1,
11586 "expected -1,-1 got %d,%d\n", wp
.ptMinPosition
.x
, wp
.ptMinPosition
.y
);
11587 ok(wp
.ptMaxPosition
.x
== -1 && wp
.ptMaxPosition
.y
== -1,
11588 "expected -1,-1 got %d,%d\n", wp
.ptMaxPosition
.x
, wp
.ptMaxPosition
.y
);
11589 if (work_rc
.left
|| work_rc
.top
) todo_wine
/* FIXME: remove once Wine is fixed */
11590 ok(EqualRect(&win_rc
, &wp
.rcNormalPosition
),
11591 "expected %d,%d-%d,%d got %d,%d-%d,%d\n",
11592 win_rc
.left
, win_rc
.top
, win_rc
.right
, win_rc
.bottom
,
11593 wp
.rcNormalPosition
.left
, wp
.rcNormalPosition
.top
,
11594 wp
.rcNormalPosition
.right
, wp
.rcNormalPosition
.bottom
);
11596 ok(EqualRect(&win_rc
, &wp
.rcNormalPosition
),
11597 "expected %d,%d-%d,%d got %d,%d-%d,%d\n",
11598 win_rc
.left
, win_rc
.top
, win_rc
.right
, win_rc
.bottom
,
11599 wp
.rcNormalPosition
.left
, wp
.rcNormalPosition
.top
,
11600 wp
.rcNormalPosition
.right
, wp
.rcNormalPosition
.bottom
);
11602 for (i
= 0; i
< sizeof(sw
)/sizeof(sw
[0]); i
++)
11604 static const char * const sw_cmd_name
[13] =
11606 "SW_HIDE", "SW_SHOWNORMAL", "SW_SHOWMINIMIZED", "SW_SHOWMAXIMIZED",
11607 "SW_SHOWNOACTIVATE", "SW_SHOW", "SW_MINIMIZE", "SW_SHOWMINNOACTIVE",
11608 "SW_SHOWNA", "SW_RESTORE", "SW_SHOWDEFAULT", "SW_FORCEMINIMIZE",
11609 "SW_NORMALNA" /* 0xCC */
11612 INT idx
; /* index into the above array of names */
11614 idx
= (sw
[i
].cmd
== SW_NORMALNA
) ? 12 : sw
[i
].cmd
;
11616 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
11617 trace("%d: sending %s, current window style %08x\n", i
+1, sw_cmd_name
[idx
], style
);
11618 ret
= ShowWindow(hwnd
, sw
[i
].cmd
);
11619 ok(!ret
== !sw
[i
].ret
, "%d: cmd %s: expected ret %lu, got %lu\n", i
+1, sw_cmd_name
[idx
], sw
[i
].ret
, ret
);
11620 style
= GetWindowLongA(hwnd
, GWL_STYLE
) & ~WS_BASE
;
11621 ok(style
== sw
[i
].style
, "%d: expected style %08x, got %08x\n", i
+1, sw
[i
].style
, style
);
11623 sprintf(comment
, "%d: ShowWindow(%s)", i
+1, sw_cmd_name
[idx
]);
11624 ok_sequence(sw
[i
].msg
, comment
, sw
[i
].todo_msg
);
11626 wp
.length
= sizeof(wp
);
11627 SetLastError(0xdeadbeaf);
11628 ret
= GetWindowPlacement(hwnd
, &wp
);
11629 ok(ret
, "GetWindowPlacement error %u\n", GetLastError());
11630 ok(wp
.flags
== sw
[i
].wp_flags
, "expected %#x, got %#x\n", sw
[i
].wp_flags
, wp
.flags
);
11631 ok(wp
.showCmd
== sw
[i
].wp_cmd
, "expected %d, got %d\n", sw
[i
].wp_cmd
, wp
.showCmd
);
11633 /* NT moves the minimized window to -32000,-32000, win9x to 3000,3000 */
11634 if ((wp
.ptMinPosition
.x
+ work_rc
.left
== -32000 && wp
.ptMinPosition
.y
+ work_rc
.top
== -32000) ||
11635 (wp
.ptMinPosition
.x
+ work_rc
.left
== 3000 && wp
.ptMinPosition
.y
+ work_rc
.top
== 3000))
11637 ok((wp
.ptMinPosition
.x
+ work_rc
.left
== sw
[i
].wp_min
.x
&& wp
.ptMinPosition
.y
+ work_rc
.top
== sw
[i
].wp_min
.y
) ||
11638 (wp
.ptMinPosition
.x
+ work_rc
.left
== 3000 && wp
.ptMinPosition
.y
+ work_rc
.top
== 3000),
11639 "expected %d,%d got %d,%d\n", sw
[i
].wp_min
.x
, sw
[i
].wp_min
.y
, wp
.ptMinPosition
.x
, wp
.ptMinPosition
.y
);
11643 ok(wp
.ptMinPosition
.x
== sw
[i
].wp_min
.x
&& wp
.ptMinPosition
.y
== sw
[i
].wp_min
.y
,
11644 "expected %d,%d got %d,%d\n", sw
[i
].wp_min
.x
, sw
[i
].wp_min
.y
, wp
.ptMinPosition
.x
, wp
.ptMinPosition
.y
);
11647 if (wp
.ptMaxPosition
.x
!= sw
[i
].wp_max
.x
|| wp
.ptMaxPosition
.y
!= sw
[i
].wp_max
.y
)
11649 ok(wp
.ptMaxPosition
.x
== sw
[i
].wp_max
.x
&& wp
.ptMaxPosition
.y
== sw
[i
].wp_max
.y
,
11650 "expected %d,%d got %d,%d\n", sw
[i
].wp_max
.x
, sw
[i
].wp_max
.y
, wp
.ptMaxPosition
.x
, wp
.ptMaxPosition
.y
);
11652 ok(wp
.ptMaxPosition
.x
== sw
[i
].wp_max
.x
&& wp
.ptMaxPosition
.y
== sw
[i
].wp_max
.y
,
11653 "expected %d,%d got %d,%d\n", sw
[i
].wp_max
.x
, sw
[i
].wp_max
.y
, wp
.ptMaxPosition
.x
, wp
.ptMaxPosition
.y
);
11655 if (0) /* FIXME: Wine behaves completely different here */
11656 ok(EqualRect(&win_rc
, &wp
.rcNormalPosition
),
11657 "expected %d,%d-%d,%d got %d,%d-%d,%d\n",
11658 win_rc
.left
, win_rc
.top
, win_rc
.right
, win_rc
.bottom
,
11659 wp
.rcNormalPosition
.left
, wp
.rcNormalPosition
.top
,
11660 wp
.rcNormalPosition
.right
, wp
.rcNormalPosition
.bottom
);
11662 DestroyWindow(hwnd
);
11666 static INT_PTR WINAPI
test_dlg_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
11668 struct recvd_message msg
;
11670 if (ignore_message( message
)) return 0;
11673 msg
.message
= message
;
11674 msg
.flags
= sent
|wparam
|lparam
;
11675 msg
.wParam
= wParam
;
11676 msg
.lParam
= lParam
;
11677 msg
.descr
= "dialog";
11680 /* calling DefDlgProc leads to a recursion under XP */
11684 case WM_INITDIALOG
:
11685 case WM_GETDLGCODE
:
11691 static const struct message WmDefDlgSetFocus_1
[] = {
11692 { WM_GETDLGCODE
, sent
|wparam
|lparam
, 0, 0 },
11693 { WM_GETTEXTLENGTH
, sent
|wparam
|lparam
|optional
, 0, 0 }, /* XP */
11694 { WM_GETTEXT
, sent
|wparam
|optional
, 6 }, /* XP */
11695 { WM_GETTEXT
, sent
|wparam
|optional
, 12 }, /* XP */
11696 { EM_SETSEL
, sent
|wparam
, 0 }, /* XP sets lparam to text length, Win9x to -2 */
11697 { HCBT_SETFOCUS
, hook
},
11698 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
11699 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
11700 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
11701 { WM_SETFOCUS
, sent
|wparam
, 0 },
11702 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 10 },
11703 { WM_CTLCOLOREDIT
, sent
},
11704 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 11 },
11705 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
11706 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
11707 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
11708 { WM_COMMAND
, sent
|wparam
, MAKEWPARAM(1, EN_SETFOCUS
) },
11711 static const struct message WmDefDlgSetFocus_2
[] = {
11712 { WM_GETDLGCODE
, sent
|wparam
|lparam
, 0, 0 },
11713 { WM_GETTEXTLENGTH
, sent
|wparam
|lparam
|optional
, 0, 0 }, /* XP */
11714 { WM_GETTEXT
, sent
|wparam
|optional
, 6 }, /* XP */
11715 { WM_GETTEXT
, sent
|wparam
|optional
, 12 }, /* XP */
11716 { EM_SETSEL
, sent
|wparam
, 0 }, /* XP sets lparam to text length, Win9x to -2 */
11717 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
11718 { WM_CTLCOLOREDIT
, sent
|optional
}, /* XP */
11719 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
11722 /* Creation of a dialog */
11723 static const struct message WmCreateDialogParamSeq_1
[] = {
11724 { HCBT_CREATEWND
, hook
},
11725 { WM_NCCREATE
, sent
},
11726 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
11727 { WM_CREATE
, sent
},
11728 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
11729 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
11731 { WM_SETFONT
, sent
},
11732 { WM_INITDIALOG
, sent
},
11733 { WM_CHANGEUISTATE
, sent
|optional
},
11736 /* Creation of a dialog */
11737 static const struct message WmCreateDialogParamSeq_2
[] = {
11738 { HCBT_CREATEWND
, hook
},
11739 { WM_NCCREATE
, sent
},
11740 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
11741 { WM_CREATE
, sent
},
11742 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
11743 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
11745 { WM_CHANGEUISTATE
, sent
|optional
},
11749 static void test_dialog_messages(void)
11752 HWND hdlg
, hedit1
, hedit2
, hfocus
;
11755 #define set_selection(hctl, start, end) \
11756 ret = SendMessageA(hctl, EM_SETSEL, start, end); \
11757 ok(ret == 1, "EM_SETSEL returned %ld\n", ret);
11759 #define check_selection(hctl, start, end) \
11760 ret = SendMessageA(hctl, EM_GETSEL, 0, 0); \
11761 ok(ret == MAKELRESULT(start, end), "wrong selection (%d - %d)\n", LOWORD(ret), HIWORD(ret));
11765 hdlg
= CreateWindowExA(WS_EX_DLGMODALFRAME
, "TestDialogClass", NULL
,
11766 WS_VISIBLE
|WS_CAPTION
|WS_SYSMENU
|WS_DLGFRAME
,
11767 0, 0, 100, 100, 0, 0, 0, NULL
);
11768 ok(hdlg
!= 0, "Failed to create custom dialog window\n");
11770 hedit1
= CreateWindowExA(0, "my_edit_class", NULL
,
11771 WS_CHILD
|WS_BORDER
|WS_VISIBLE
|WS_TABSTOP
,
11772 0, 0, 80, 20, hdlg
, (HMENU
)1, 0, NULL
);
11773 ok(hedit1
!= 0, "Failed to create edit control\n");
11774 hedit2
= CreateWindowExA(0, "my_edit_class", NULL
,
11775 WS_CHILD
|WS_BORDER
|WS_VISIBLE
|WS_TABSTOP
,
11776 0, 40, 80, 20, hdlg
, (HMENU
)2, 0, NULL
);
11777 ok(hedit2
!= 0, "Failed to create edit control\n");
11779 SendMessageA(hedit1
, WM_SETTEXT
, 0, (LPARAM
)"hello");
11780 SendMessageA(hedit2
, WM_SETTEXT
, 0, (LPARAM
)"bye");
11782 hfocus
= GetFocus();
11783 ok(hfocus
== hdlg
, "wrong focus %p\n", hfocus
);
11786 hfocus
= GetFocus();
11787 ok(hfocus
== hedit2
, "wrong focus %p\n", hfocus
);
11789 check_selection(hedit1
, 0, 0);
11790 check_selection(hedit2
, 0, 0);
11792 set_selection(hedit2
, 0, -1);
11793 check_selection(hedit2
, 0, 3);
11796 hfocus
= GetFocus();
11797 ok(hfocus
== 0, "wrong focus %p\n", hfocus
);
11800 ret
= DefDlgProcA(hdlg
, WM_SETFOCUS
, 0, 0);
11801 ok(ret
== 0, "WM_SETFOCUS returned %ld\n", ret
);
11802 ok_sequence(WmDefDlgSetFocus_1
, "DefDlgProc(WM_SETFOCUS) 1", FALSE
);
11804 hfocus
= GetFocus();
11805 ok(hfocus
== hedit1
, "wrong focus %p\n", hfocus
);
11807 check_selection(hedit1
, 0, 5);
11808 check_selection(hedit2
, 0, 3);
11811 ret
= DefDlgProcA(hdlg
, WM_SETFOCUS
, 0, 0);
11812 ok(ret
== 0, "WM_SETFOCUS returned %ld\n", ret
);
11813 ok_sequence(WmDefDlgSetFocus_2
, "DefDlgProc(WM_SETFOCUS) 2", FALSE
);
11815 hfocus
= GetFocus();
11816 ok(hfocus
== hedit1
, "wrong focus %p\n", hfocus
);
11818 check_selection(hedit1
, 0, 5);
11819 check_selection(hedit2
, 0, 3);
11821 EndDialog(hdlg
, 0);
11822 DestroyWindow(hedit1
);
11823 DestroyWindow(hedit2
);
11824 DestroyWindow(hdlg
);
11827 #undef set_selection
11828 #undef check_selection
11830 ok(GetClassInfoA(0, "#32770", &cls
), "GetClassInfo failed\n");
11831 cls
.lpszClassName
= "MyDialogClass";
11832 cls
.hInstance
= GetModuleHandleA(NULL
);
11833 /* need a cast since a dlgproc is used as a wndproc */
11834 cls
.lpfnWndProc
= test_dlg_proc
;
11835 if (!RegisterClassA(&cls
)) assert(0);
11837 hdlg
= CreateDialogParamA(0, "CLASS_TEST_DIALOG_2", 0, test_dlg_proc
, 0);
11838 ok(IsWindow(hdlg
), "CreateDialogParam failed\n");
11839 ok_sequence(WmCreateDialogParamSeq_1
, "CreateDialogParam_1", FALSE
);
11840 EndDialog(hdlg
, 0);
11841 DestroyWindow(hdlg
);
11844 hdlg
= CreateDialogParamA(0, "CLASS_TEST_DIALOG_2", 0, NULL
, 0);
11845 ok(IsWindow(hdlg
), "CreateDialogParam failed\n");
11846 ok_sequence(WmCreateDialogParamSeq_2
, "CreateDialogParam_2", FALSE
);
11847 EndDialog(hdlg
, 0);
11848 DestroyWindow(hdlg
);
11851 UnregisterClassA(cls
.lpszClassName
, cls
.hInstance
);
11854 static void test_EndDialog(void)
11856 HWND hparent
, hother
, hactive
, hdlg
;
11859 hparent
= CreateWindowExA(0, "TestParentClass", "Test parent",
11860 WS_OVERLAPPEDWINDOW
| WS_VISIBLE
| WS_DISABLED
,
11861 100, 100, 200, 200, 0, 0, 0, NULL
);
11862 ok (hparent
!= 0, "Failed to create parent window\n");
11864 hother
= CreateWindowExA(0, "TestParentClass", "Test parent 2",
11865 WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
11866 100, 100, 200, 200, 0, 0, 0, NULL
);
11867 ok (hother
!= 0, "Failed to create parent window\n");
11869 ok(GetClassInfoA(0, "#32770", &cls
), "GetClassInfo failed\n");
11870 cls
.lpszClassName
= "MyDialogClass";
11871 cls
.hInstance
= GetModuleHandleA(NULL
);
11872 cls
.lpfnWndProc
= test_dlg_proc
;
11873 if (!RegisterClassA(&cls
)) assert(0);
11876 SetForegroundWindow(hother
);
11877 hactive
= GetForegroundWindow();
11878 ok(hother
== hactive
, "Wrong window has focus (%p != %p)\n", hother
, hactive
);
11880 /* create a dialog where the parent is disabled, this parent should still
11881 receive the focus when the dialog exits (even though "normally" a
11882 disabled window should not receive the focus) */
11883 hdlg
= CreateDialogParamA(0, "CLASS_TEST_DIALOG_2", hparent
, test_dlg_proc
, 0);
11884 ok(IsWindow(hdlg
), "CreateDialogParam failed\n");
11885 SetForegroundWindow(hdlg
);
11886 hactive
= GetForegroundWindow();
11887 ok(hdlg
== hactive
, "Wrong window has focus (%p != %p)\n", hdlg
, hactive
);
11888 EndDialog(hdlg
, 0);
11889 hactive
= GetForegroundWindow();
11890 ok(hparent
== hactive
, "Wrong window has focus (parent != active) (active: %p, parent: %p, dlg: %p, other: %p)\n", hactive
, hparent
, hdlg
, hother
);
11891 DestroyWindow(hdlg
);
11894 DestroyWindow( hother
);
11895 DestroyWindow( hparent
);
11896 UnregisterClassA(cls
.lpszClassName
, cls
.hInstance
);
11899 static void test_nullCallback(void)
11903 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW
,
11904 100, 100, 200, 200, 0, 0, 0, NULL
);
11905 ok (hwnd
!= 0, "Failed to create overlapped window\n");
11907 SendMessageCallbackA(hwnd
,WM_NULL
,0,0,NULL
,0);
11909 DestroyWindow(hwnd
);
11912 /* SetActiveWindow( 0 ) hwnd visible */
11913 static const struct message SetActiveWindowSeq0
[] =
11915 { HCBT_ACTIVATE
, hook
|optional
},
11916 { WM_NCACTIVATE
, sent
|wparam
, 0 },
11917 { WM_GETTEXT
, sent
|defwinproc
|optional
},
11918 { WM_ACTIVATE
, sent
|wparam
, 0 },
11919 { WM_ACTIVATEAPP
, sent
|wparam
|optional
, 0 },
11920 { WM_ACTIVATEAPP
, sent
|wparam
|optional
, 0 },
11921 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
11922 { WM_KILLFOCUS
, sent
|optional
},
11923 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
11924 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
11925 { WM_NCACTIVATE
, sent
|wparam
|optional
, 1 },
11926 { WM_GETTEXT
, sent
|defwinproc
|optional
},
11927 { WM_ACTIVATE
, sent
|wparam
|optional
, 1 },
11928 { HCBT_SETFOCUS
, hook
|optional
},
11929 { WM_KILLFOCUS
, sent
|defwinproc
|optional
},
11930 { WM_IME_SETCONTEXT
, sent
|defwinproc
|optional
},
11931 { WM_IME_SETCONTEXT
, sent
|defwinproc
|optional
},
11932 { WM_IME_SETCONTEXT
, sent
|optional
},
11933 { WM_IME_SETCONTEXT
, sent
|optional
},
11934 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 1 },
11935 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
11936 { WM_SETFOCUS
, sent
|defwinproc
|optional
},
11937 { WM_GETTEXT
, sent
|optional
},
11940 /* SetActiveWindow( hwnd ) hwnd visible */
11941 static const struct message SetActiveWindowSeq1
[] =
11943 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
11946 /* SetActiveWindow( popup ) hwnd visible, popup visible */
11947 static const struct message SetActiveWindowSeq2
[] =
11949 { HCBT_ACTIVATE
, hook
},
11950 { WM_NCACTIVATE
, sent
|wparam
, 0 },
11951 { WM_GETTEXT
, sent
|defwinproc
|optional
},
11952 { WM_ACTIVATE
, sent
|wparam
, 0 },
11953 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
11954 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
11955 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
11956 { WM_NCPAINT
, sent
|optional
},
11957 { WM_GETTEXT
, sent
|defwinproc
|optional
},
11958 { WM_ERASEBKGND
, sent
|optional
},
11959 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
11960 { WM_NCACTIVATE
, sent
|wparam
, 1 },
11961 { WM_GETTEXT
, sent
|defwinproc
|optional
},
11962 { WM_ACTIVATE
, sent
|wparam
, 1 },
11963 { HCBT_SETFOCUS
, hook
},
11964 { WM_KILLFOCUS
, sent
|defwinproc
},
11965 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 0 },
11966 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
11967 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 1 },
11968 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
11969 { WM_SETFOCUS
, sent
|defwinproc
},
11970 { WM_GETTEXT
, sent
|optional
},
11974 /* SetActiveWindow( hwnd ) hwnd not visible */
11975 static const struct message SetActiveWindowSeq3
[] =
11977 { HCBT_ACTIVATE
, hook
},
11978 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
11979 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
11980 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
},
11981 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOACTIVATE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
11982 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
11983 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
11984 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
11985 { WM_NCACTIVATE
, sent
|wparam
, 1 },
11986 { WM_ACTIVATE
, sent
|wparam
, 1 },
11987 { HCBT_SETFOCUS
, hook
},
11988 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
11989 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
11990 { WM_SETFOCUS
, sent
|defwinproc
},
11993 /* SetActiveWindow( popup ) hwnd not visible, popup not visible */
11994 static const struct message SetActiveWindowSeq4
[] =
11996 { HCBT_ACTIVATE
, hook
},
11997 { WM_NCACTIVATE
, sent
|wparam
, 0 },
11998 { WM_GETTEXT
, sent
|defwinproc
|optional
},
11999 { WM_ACTIVATE
, sent
|wparam
, 0 },
12000 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
12001 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
},
12002 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
12003 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
12004 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
12005 { WM_NCACTIVATE
, sent
|wparam
, 1 },
12006 { WM_GETTEXT
, sent
|defwinproc
|optional
},
12007 { WM_ACTIVATE
, sent
|wparam
, 1 },
12008 { HCBT_SETFOCUS
, hook
},
12009 { WM_KILLFOCUS
, sent
|defwinproc
},
12010 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 0 },
12011 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
12012 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 1 },
12013 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
12014 { WM_SETFOCUS
, sent
|defwinproc
},
12019 static void test_SetActiveWindow(void)
12021 HWND hwnd
, popup
, ret
;
12023 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test SetActiveWindow",
12024 WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
12025 100, 100, 200, 200, 0, 0, 0, NULL
);
12027 popup
= CreateWindowExA(0, "TestWindowClass", "Test SetActiveWindow",
12028 WS_OVERLAPPEDWINDOW
| WS_VISIBLE
| WS_POPUP
,
12029 100, 100, 200, 200, hwnd
, 0, 0, NULL
);
12031 ok(hwnd
!= 0, "Failed to create overlapped window\n");
12032 ok(popup
!= 0, "Failed to create popup window\n");
12033 SetForegroundWindow( popup
);
12036 trace("SetActiveWindow(0)\n");
12037 ret
= SetActiveWindow(0);
12038 ok( ret
== popup
, "Failed to SetActiveWindow(0)\n");
12039 ok_sequence(SetActiveWindowSeq0
, "SetActiveWindow(0)", FALSE
);
12042 trace("SetActiveWindow(hwnd), hwnd visible\n");
12043 ret
= SetActiveWindow(hwnd
);
12044 if (ret
== hwnd
) ok_sequence(SetActiveWindowSeq1
, "SetActiveWindow(hwnd), hwnd visible", TRUE
);
12047 trace("SetActiveWindow(popup), hwnd visible, popup visible\n");
12048 ret
= SetActiveWindow(popup
);
12049 ok( ret
== hwnd
, "Failed to SetActiveWindow(popup), popup visible\n");
12050 ok_sequence(SetActiveWindowSeq2
, "SetActiveWindow(popup), hwnd visible, popup visible", FALSE
);
12053 ShowWindow(hwnd
, SW_HIDE
);
12054 ShowWindow(popup
, SW_HIDE
);
12057 trace("SetActiveWindow(hwnd), hwnd not visible\n");
12058 ret
= SetActiveWindow(hwnd
);
12059 ok( ret
== NULL
, "SetActiveWindow(hwnd), hwnd not visible, previous is %p\n", ret
);
12060 ok_sequence(SetActiveWindowSeq3
, "SetActiveWindow(hwnd), hwnd not visible", TRUE
);
12063 trace("SetActiveWindow(popup), hwnd not visible, popup not visible\n");
12064 ret
= SetActiveWindow(popup
);
12065 ok( ret
== hwnd
, "Failed to SetActiveWindow(popup)\n");
12066 ok_sequence(SetActiveWindowSeq4
, "SetActiveWindow(popup), hwnd not visible, popup not visible", TRUE
);
12071 DestroyWindow(hwnd
);
12074 static const struct message SetForegroundWindowSeq
[] =
12076 { WM_NCACTIVATE
, sent
|wparam
, 0 },
12077 { WM_GETTEXT
, sent
|defwinproc
|optional
},
12078 { WM_ACTIVATE
, sent
|wparam
, 0 },
12079 { WM_ACTIVATEAPP
, sent
|wparam
, 0 },
12080 { WM_KILLFOCUS
, sent
},
12081 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
12082 { WM_IME_NOTIFY
, sent
|wparam
|optional
|defwinproc
, 1 },
12086 static void test_SetForegroundWindow(void)
12090 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test SetForegroundWindow",
12091 WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
12092 100, 100, 200, 200, 0, 0, 0, NULL
);
12093 ok (hwnd
!= 0, "Failed to create overlapped window\n");
12094 SetForegroundWindow( hwnd
);
12097 trace("SetForegroundWindow( 0 )\n");
12098 SetForegroundWindow( 0 );
12099 ok_sequence(WmEmptySeq
, "SetForegroundWindow( 0 ) away from foreground top level window", FALSE
);
12100 trace("SetForegroundWindow( GetDesktopWindow() )\n");
12101 SetForegroundWindow( GetDesktopWindow() );
12102 ok_sequence(SetForegroundWindowSeq
, "SetForegroundWindow( desktop ) away from "
12103 "foreground top level window", FALSE
);
12106 DestroyWindow(hwnd
);
12109 static DWORD
get_input_codepage( void )
12113 HKL hkl
= GetKeyboardLayout( 0 );
12115 ret
= GetLocaleInfoW( LOWORD(hkl
), LOCALE_IDEFAULTANSICODEPAGE
| LOCALE_RETURN_NUMBER
,
12116 (WCHAR
*)&cp
, sizeof(cp
) / sizeof(WCHAR
) );
12117 if (!ret
) cp
= CP_ACP
;
12121 static void test_dbcs_wm_char(void)
12124 WCHAR wch
, bad_wch
;
12132 struct message wmCharSeq
[2];
12134 DWORD cp
= get_input_codepage();
12136 if (!pGetCPInfoExA
)
12138 win_skip("GetCPInfoExA is not available\n");
12142 pGetCPInfoExA( cp
, 0, &cpinfo
);
12143 if (cpinfo
.MaxCharSize
!= 2)
12145 skip( "Skipping DBCS WM_CHAR test in SBCS codepage '%s'\n", cpinfo
.CodePageName
);
12149 dbch
[0] = dbch
[1] = 0;
12151 bad_wch
= cpinfo
.UnicodeDefaultChar
;
12152 for (i
= 0; !wch
&& i
< MAX_LEADBYTES
&& cpinfo
.LeadByte
[i
]; i
+= 2)
12153 for (j
= cpinfo
.LeadByte
[i
]; !wch
&& j
<= cpinfo
.LeadByte
[i
+1]; j
++)
12154 for (k
= 128; k
<= 255; k
++)
12160 if (MultiByteToWideChar( cp
, 0, str
, 2, wstr
, 2 ) == 1 &&
12161 WideCharToMultiByte( cp
, 0, wstr
, 1, str
, 2, NULL
, NULL
) == 2 &&
12162 (BYTE
)str
[0] == j
&& (BYTE
)str
[1] == k
&&
12163 HIBYTE(wstr
[0]) && HIBYTE(wstr
[0]) != 0xff)
12174 skip( "Skipping DBCS WM_CHAR test, no appropriate char found\n" );
12177 trace( "using dbcs char %02x,%02x wchar %04x bad wchar %04x codepage '%s'\n",
12178 dbch
[0], dbch
[1], wch
, bad_wch
, cpinfo
.CodePageName
);
12180 hwnd
= CreateWindowExW(0, testWindowClassW
, NULL
,
12181 WS_OVERLAPPEDWINDOW
, 100, 100, 200, 200, 0, 0, 0, NULL
);
12182 hwnd2
= CreateWindowExW(0, testWindowClassW
, NULL
,
12183 WS_OVERLAPPEDWINDOW
, 100, 100, 200, 200, 0, 0, 0, NULL
);
12184 ok (hwnd
!= 0, "Failed to create overlapped window\n");
12185 ok (hwnd2
!= 0, "Failed to create overlapped window\n");
12188 memset( wmCharSeq
, 0, sizeof(wmCharSeq
) );
12189 wmCharSeq
[0].message
= WM_CHAR
;
12190 wmCharSeq
[0].flags
= sent
|wparam
;
12191 wmCharSeq
[0].wParam
= wch
;
12193 /* posted message */
12194 PostMessageA( hwnd
, WM_CHAR
, dbch
[0], 0 );
12195 ret
= PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
);
12196 ok( !ret
, "got message %x\n", msg
.message
);
12197 PostMessageA( hwnd
, WM_CHAR
, dbch
[1], 0 );
12198 ret
= PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
);
12199 ok( ret
, "no message\n" );
12200 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
12201 ok( msg
.wParam
== wch
, "bad wparam %lx/%x\n", msg
.wParam
, wch
);
12202 ret
= PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
);
12203 ok( !ret
, "got message %x\n", msg
.message
);
12205 /* posted thread message */
12206 PostThreadMessageA( GetCurrentThreadId(), WM_CHAR
, dbch
[0], 0 );
12207 ret
= PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
);
12208 ok( !ret
, "got message %x\n", msg
.message
);
12209 PostMessageA( hwnd
, WM_CHAR
, dbch
[1], 0 );
12210 ret
= PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
);
12211 ok( ret
, "no message\n" );
12212 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
12213 ok( msg
.wParam
== wch
, "bad wparam %lx/%x\n", msg
.wParam
, wch
);
12214 ret
= PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
);
12215 ok( !ret
, "got message %x\n", msg
.message
);
12219 SendMessageA( hwnd
, WM_CHAR
, dbch
[0], 0 );
12220 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
12221 SendMessageA( hwnd
, WM_CHAR
, dbch
[1], 0 );
12222 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
12223 ret
= PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
);
12224 ok( !ret
, "got message %x\n", msg
.message
);
12226 /* sent message with timeout */
12228 SendMessageTimeoutA( hwnd
, WM_CHAR
, dbch
[0], 0, SMTO_NORMAL
, 0, &res
);
12229 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
12230 SendMessageTimeoutA( hwnd
, WM_CHAR
, dbch
[1], 0, SMTO_NORMAL
, 0, &res
);
12231 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
12232 ret
= PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
);
12233 ok( !ret
, "got message %x\n", msg
.message
);
12235 /* sent message with timeout and callback */
12237 SendMessageTimeoutA( hwnd
, WM_CHAR
, dbch
[0], 0, SMTO_NORMAL
, 0, &res
);
12238 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
12239 SendMessageCallbackA( hwnd
, WM_CHAR
, dbch
[1], 0, NULL
, 0 );
12240 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
12241 ret
= PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
);
12242 ok( !ret
, "got message %x\n", msg
.message
);
12244 /* sent message with callback */
12246 SendNotifyMessageA( hwnd
, WM_CHAR
, dbch
[0], 0 );
12247 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
12248 SendMessageCallbackA( hwnd
, WM_CHAR
, dbch
[1], 0, NULL
, 0 );
12249 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
12250 ret
= PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
);
12251 ok( !ret
, "got message %x\n", msg
.message
);
12253 /* direct window proc call */
12255 CallWindowProcA( (WNDPROC
)GetWindowLongPtrA( hwnd
, GWLP_WNDPROC
), hwnd
, WM_CHAR
, dbch
[0], 0 );
12256 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
12257 CallWindowProcA( (WNDPROC
)GetWindowLongPtrA( hwnd
, GWLP_WNDPROC
), hwnd
, WM_CHAR
, dbch
[1], 0 );
12258 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
12260 /* dispatch message */
12262 msg
.message
= WM_CHAR
;
12263 msg
.wParam
= dbch
[0];
12265 DispatchMessageA( &msg
);
12266 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
12267 msg
.wParam
= dbch
[1];
12268 DispatchMessageA( &msg
);
12269 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
12271 /* window handle is irrelevant */
12273 SendMessageA( hwnd2
, WM_CHAR
, dbch
[0], 0 );
12274 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
12275 SendMessageA( hwnd
, WM_CHAR
, dbch
[1], 0 );
12276 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
12277 ret
= PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
);
12278 ok( !ret
, "got message %x\n", msg
.message
);
12280 /* interleaved post and send */
12282 PostMessageA( hwnd2
, WM_CHAR
, dbch
[0], 0 );
12283 SendMessageA( hwnd2
, WM_CHAR
, dbch
[0], 0 );
12284 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
12285 ret
= PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
);
12286 ok( !ret
, "got message %x\n", msg
.message
);
12287 PostMessageA( hwnd
, WM_CHAR
, dbch
[1], 0 );
12288 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
12289 ret
= PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
);
12290 ok( ret
, "no message\n" );
12291 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
12292 ok( msg
.wParam
== wch
, "bad wparam %lx/%x\n", msg
.wParam
, wch
);
12293 ret
= PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
);
12294 ok( !ret
, "got message %x\n", msg
.message
);
12295 SendMessageA( hwnd
, WM_CHAR
, dbch
[1], 0 );
12296 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
12297 ret
= PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
);
12298 ok( !ret
, "got message %x\n", msg
.message
);
12300 /* interleaved sent message and winproc */
12302 SendMessageA( hwnd
, WM_CHAR
, dbch
[0], 0 );
12303 CallWindowProcA( (WNDPROC
)GetWindowLongPtrA( hwnd
, GWLP_WNDPROC
), hwnd
, WM_CHAR
, dbch
[0], 0 );
12304 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
12305 SendMessageA( hwnd
, WM_CHAR
, dbch
[1], 0 );
12306 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
12307 CallWindowProcA( (WNDPROC
)GetWindowLongPtrA( hwnd
, GWLP_WNDPROC
), hwnd
, WM_CHAR
, dbch
[1], 0 );
12308 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
12310 /* interleaved winproc and dispatch */
12312 msg
.message
= WM_CHAR
;
12313 msg
.wParam
= dbch
[0];
12315 CallWindowProcA( (WNDPROC
)GetWindowLongPtrA( hwnd
, GWLP_WNDPROC
), hwnd
, WM_CHAR
, dbch
[0], 0 );
12316 DispatchMessageA( &msg
);
12317 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
12318 msg
.wParam
= dbch
[1];
12319 DispatchMessageA( &msg
);
12320 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
12321 CallWindowProcA( (WNDPROC
)GetWindowLongPtrA( hwnd
, GWLP_WNDPROC
), hwnd
, WM_CHAR
, dbch
[1], 0 );
12322 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
12324 /* interleaved sends */
12326 SendMessageA( hwnd
, WM_CHAR
, dbch
[0], 0 );
12327 SendMessageCallbackA( hwnd
, WM_CHAR
, dbch
[0], 0, NULL
, 0 );
12328 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
12329 SendMessageTimeoutA( hwnd
, WM_CHAR
, dbch
[1], 0, SMTO_NORMAL
, 0, &res
);
12330 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
12331 SendMessageA( hwnd
, WM_CHAR
, dbch
[1], 0 );
12332 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
12336 SendMessageA( hwnd2
, WM_CHAR
, (dbch
[1] << 8) | dbch
[0], 0 );
12337 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
12338 ret
= PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
);
12339 ok( !ret
, "got message %x\n", msg
.message
);
12341 /* other char messages are not magic */
12342 PostMessageA( hwnd
, WM_SYSCHAR
, dbch
[0], 0 );
12343 ret
= PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
);
12344 ok( ret
, "no message\n" );
12345 ok( msg
.message
== WM_SYSCHAR
, "unexpected message %x\n", msg
.message
);
12346 ok( msg
.wParam
== bad_wch
, "bad wparam %lx/%x\n", msg
.wParam
, bad_wch
);
12347 ret
= PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
);
12348 ok( !ret
, "got message %x\n", msg
.message
);
12349 PostMessageA( hwnd
, WM_DEADCHAR
, dbch
[0], 0 );
12350 ret
= PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
);
12351 ok( ret
, "no message\n" );
12352 ok( msg
.message
== WM_DEADCHAR
, "unexpected message %x\n", msg
.message
);
12353 ok( msg
.wParam
== bad_wch
, "bad wparam %lx/%x\n", msg
.wParam
, bad_wch
);
12354 ret
= PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
);
12355 ok( !ret
, "got message %x\n", msg
.message
);
12357 /* test retrieving messages */
12359 PostMessageW( hwnd
, WM_CHAR
, wch
, 0 );
12360 ret
= PeekMessageA( &msg
, hwnd
, 0, 0, PM_REMOVE
);
12361 ok( ret
, "no message\n" );
12362 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
12363 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
12364 ok( msg
.wParam
== dbch
[0], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
12365 ret
= PeekMessageA( &msg
, hwnd
, 0, 0, PM_REMOVE
);
12366 ok( ret
, "no message\n" );
12367 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
12368 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
12369 ok( msg
.wParam
== dbch
[1], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
12370 ret
= PeekMessageA( &msg
, hwnd
, 0, 0, PM_REMOVE
);
12371 ok( !ret
, "got message %x\n", msg
.message
);
12373 /* message filters */
12374 PostMessageW( hwnd
, WM_CHAR
, wch
, 0 );
12375 ret
= PeekMessageA( &msg
, hwnd
, 0, 0, PM_REMOVE
);
12376 ok( ret
, "no message\n" );
12377 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
12378 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
12379 ok( msg
.wParam
== dbch
[0], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
12380 /* message id is filtered, hwnd is not */
12381 ret
= PeekMessageA( &msg
, hwnd
, WM_MOUSEFIRST
, WM_MOUSELAST
, PM_REMOVE
);
12382 ok( !ret
, "no message\n" );
12383 ret
= PeekMessageA( &msg
, hwnd2
, 0, 0, PM_REMOVE
);
12384 ok( ret
, "no message\n" );
12385 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
12386 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
12387 ok( msg
.wParam
== dbch
[1], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
12388 ret
= PeekMessageA( &msg
, hwnd
, 0, 0, PM_REMOVE
);
12389 ok( !ret
, "got message %x\n", msg
.message
);
12391 /* mixing GetMessage and PostMessage */
12392 PostMessageW( hwnd
, WM_CHAR
, wch
, 0xbeef );
12393 ok( GetMessageA( &msg
, hwnd
, 0, 0 ), "no message\n" );
12394 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
12395 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
12396 ok( msg
.wParam
== dbch
[0], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
12397 ok( msg
.lParam
== 0xbeef, "bad lparam %lx\n", msg
.lParam
);
12400 ok( time
- GetTickCount() <= 100, "bad time %x\n", msg
.time
);
12401 ret
= PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
);
12402 ok( ret
, "no message\n" );
12403 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
12404 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
12405 ok( msg
.wParam
== dbch
[1], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
12406 ok( msg
.lParam
== 0xbeef, "bad lparam %lx\n", msg
.lParam
);
12407 ok( msg
.time
== time
, "bad time %x/%x\n", msg
.time
, time
);
12408 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
);
12409 ret
= PeekMessageA( &msg
, hwnd
, 0, 0, PM_REMOVE
);
12410 ok( !ret
, "got message %x\n", msg
.message
);
12412 /* without PM_REMOVE */
12413 PostMessageW( hwnd
, WM_CHAR
, wch
, 0 );
12414 ret
= PeekMessageA( &msg
, 0, 0, 0, PM_NOREMOVE
);
12415 ok( ret
, "no message\n" );
12416 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
12417 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
12418 ok( msg
.wParam
== dbch
[0], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
12419 ret
= PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
);
12420 ok( ret
, "no message\n" );
12421 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
12422 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
12423 ok( msg
.wParam
== dbch
[0], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
12424 ret
= PeekMessageA( &msg
, 0, 0, 0, PM_NOREMOVE
);
12425 ok( ret
, "no message\n" );
12426 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
12427 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
12428 ok( msg
.wParam
== dbch
[1], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
12429 ret
= PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
);
12430 ok( ret
, "no message\n" );
12431 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
12432 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
12433 ok( msg
.wParam
== dbch
[1], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
12434 ret
= PeekMessageA( &msg
, hwnd
, 0, 0, PM_REMOVE
);
12435 ok( !ret
, "got message %x\n", msg
.message
);
12437 DestroyWindow(hwnd
);
12438 DestroyWindow(hwnd2
);
12441 static void test_unicode_wm_char(void)
12445 struct message seq
[2];
12446 HKL hkl_orig
, hkl_greek
;
12448 LCID thread_locale
;
12450 hkl_orig
= GetKeyboardLayout( 0 );
12451 GetLocaleInfoW( LOWORD( hkl_orig
), LOCALE_IDEFAULTANSICODEPAGE
| LOCALE_RETURN_NUMBER
, (WCHAR
*)&cp
, sizeof(cp
) / sizeof(WCHAR
) );
12454 skip( "Default codepage %d\n", cp
);
12458 hkl_greek
= LoadKeyboardLayoutA( "00000408", 0 );
12459 if (!hkl_greek
|| hkl_greek
== hkl_orig
/* win2k */)
12461 skip( "Unable to load Greek keyboard layout\n" );
12465 hwnd
= CreateWindowExW( 0, testWindowClassW
, NULL
, WS_OVERLAPPEDWINDOW
,
12466 100, 100, 200, 200, 0, 0, 0, NULL
);
12469 PostMessageW( hwnd
, WM_CHAR
, 0x3b1, 0 );
12471 while (GetMessageW( &msg
, hwnd
, 0, 0 ))
12473 if (!ignore_message( msg
.message
)) break;
12476 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
12477 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
12478 ok( msg
.wParam
== 0x3b1, "bad wparam %lx\n", msg
.wParam
);
12479 ok( msg
.lParam
== 0, "bad lparam %lx\n", msg
.lParam
);
12481 DispatchMessageW( &msg
);
12483 memset( seq
, 0, sizeof(seq
) );
12484 seq
[0].message
= WM_CHAR
;
12485 seq
[0].flags
= sent
|wparam
;
12486 seq
[0].wParam
= 0x3b1;
12488 ok_sequence( seq
, "unicode WM_CHAR", FALSE
);
12492 /* greek alpha -> 'a' in cp1252 */
12493 PostMessageW( hwnd
, WM_CHAR
, 0x3b1, 0 );
12495 ok( GetMessageA( &msg
, hwnd
, 0, 0 ), "no message\n" );
12496 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
12497 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
12498 ok( msg
.wParam
== 0x61, "bad wparam %lx\n", msg
.wParam
);
12499 ok( msg
.lParam
== 0, "bad lparam %lx\n", msg
.lParam
);
12501 DispatchMessageA( &msg
);
12503 seq
[0].wParam
= 0x61;
12504 ok_sequence( seq
, "unicode WM_CHAR", FALSE
);
12506 thread_locale
= GetThreadLocale();
12507 ActivateKeyboardLayout( hkl_greek
, 0 );
12508 ok( GetThreadLocale() == thread_locale
, "locale changed from %08x to %08x\n",
12509 thread_locale
, GetThreadLocale() );
12513 /* greek alpha -> 0xe1 in cp1253 */
12514 PostMessageW( hwnd
, WM_CHAR
, 0x3b1, 0 );
12516 ok( GetMessageA( &msg
, hwnd
, 0, 0 ), "no message\n" );
12517 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
12518 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
12519 ok( msg
.wParam
== 0xe1, "bad wparam %lx\n", msg
.wParam
);
12520 ok( msg
.lParam
== 0, "bad lparam %lx\n", msg
.lParam
);
12522 DispatchMessageA( &msg
);
12524 seq
[0].wParam
= 0x3b1;
12525 ok_sequence( seq
, "unicode WM_CHAR", FALSE
);
12527 DestroyWindow( hwnd
);
12528 ActivateKeyboardLayout( hkl_orig
, 0 );
12529 UnloadKeyboardLayout( hkl_greek
);
12532 #define ID_LISTBOX 0x000f
12534 static const struct message wm_lb_setcursel_0
[] =
12536 { LB_SETCURSEL
, sent
|wparam
|lparam
, 0, 0 },
12537 { WM_CTLCOLORLISTBOX
, sent
|parent
},
12538 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x000120f2 },
12539 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 1 },
12540 { EVENT_OBJECT_SELECTION
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 1 },
12543 static const struct message wm_lb_setcursel_1
[] =
12545 { LB_SETCURSEL
, sent
|wparam
|lparam
, 1, 0 },
12546 { WM_CTLCOLORLISTBOX
, sent
|parent
},
12547 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x000020f2 },
12548 { WM_CTLCOLORLISTBOX
, sent
|parent
},
12549 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x000121f2 },
12550 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 2 },
12551 { EVENT_OBJECT_SELECTION
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 2 },
12554 static const struct message wm_lb_setcursel_2
[] =
12556 { LB_SETCURSEL
, sent
|wparam
|lparam
, 2, 0 },
12557 { WM_CTLCOLORLISTBOX
, sent
|parent
},
12558 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x000021f2 },
12559 { WM_CTLCOLORLISTBOX
, sent
|parent
},
12560 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x000122f2 },
12561 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 3 },
12562 { EVENT_OBJECT_SELECTION
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 3 },
12565 static const struct message wm_lb_click_0
[] =
12567 { WM_LBUTTONDOWN
, sent
|wparam
|lparam
, 0, MAKELPARAM(1,1) },
12568 { HCBT_SETFOCUS
, hook
},
12569 { WM_KILLFOCUS
, sent
|parent
},
12570 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
|parent
, 0 },
12571 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
12572 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
12573 { WM_SETFOCUS
, sent
|defwinproc
},
12575 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x001142f2 },
12576 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_LISTBOX
, LBN_SETFOCUS
) },
12577 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 3 },
12578 { WM_LBTRACKPOINT
, sent
|wparam
|lparam
|parent
, 0, MAKELPARAM(1,1) },
12579 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
12581 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x000142f2 },
12582 { WM_CTLCOLORLISTBOX
, sent
|parent
},
12583 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x000022f2 },
12584 { WM_CTLCOLORLISTBOX
, sent
|parent
},
12585 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x000120f2 },
12586 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x001140f2 },
12588 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 1 },
12589 { EVENT_OBJECT_SELECTION
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 1 },
12591 { WM_LBUTTONUP
, sent
|wparam
|lparam
, 0, 0 },
12592 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, 0, 0 },
12593 { WM_CAPTURECHANGED
, sent
|wparam
|lparam
|defwinproc
, 0, 0 },
12594 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_LISTBOX
, LBN_SELCHANGE
) },
12597 static const struct message wm_lb_deletestring
[] =
12599 { LB_DELETESTRING
, sent
|wparam
|lparam
, 0, 0 },
12600 { WM_DELETEITEM
, sent
|wparam
|parent
|optional
, ID_LISTBOX
, 0 },
12601 { WM_DRAWITEM
, sent
|wparam
|parent
|optional
, ID_LISTBOX
},
12602 { WM_DRAWITEM
, sent
|wparam
|parent
|optional
, ID_LISTBOX
},
12605 static const struct message wm_lb_deletestring_reset
[] =
12607 { LB_DELETESTRING
, sent
|wparam
|lparam
, 0, 0 },
12608 { LB_RESETCONTENT
, sent
|wparam
|lparam
|defwinproc
|optional
, 0, 0 },
12609 { WM_DELETEITEM
, sent
|wparam
|parent
|optional
, ID_LISTBOX
, 0 },
12610 { WM_DRAWITEM
, sent
|wparam
|parent
|optional
, ID_LISTBOX
},
12611 { WM_DRAWITEM
, sent
|wparam
|parent
|optional
, ID_LISTBOX
},
12615 #define check_lb_state(a1, a2, a3, a4, a5) check_lb_state_dbg(a1, a2, a3, a4, a5, __LINE__)
12617 static LRESULT (WINAPI
*listbox_orig_proc
)(HWND
, UINT
, WPARAM
, LPARAM
);
12619 static LRESULT WINAPI
listbox_hook_proc(HWND hwnd
, UINT message
, WPARAM wp
, LPARAM lp
)
12621 static LONG defwndproc_counter
= 0;
12623 struct recvd_message msg
;
12625 /* do not log painting messages */
12626 if (message
!= WM_PAINT
&&
12627 message
!= WM_NCPAINT
&&
12628 message
!= WM_SYNCPAINT
&&
12629 message
!= WM_ERASEBKGND
&&
12630 message
!= WM_NCHITTEST
&&
12631 message
!= WM_GETTEXT
&&
12632 !ignore_message( message
))
12635 msg
.message
= message
;
12636 msg
.flags
= sent
|wparam
|lparam
;
12637 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
12640 msg
.descr
= "listbox";
12644 defwndproc_counter
++;
12645 ret
= CallWindowProcA(listbox_orig_proc
, hwnd
, message
, wp
, lp
);
12646 defwndproc_counter
--;
12651 static void check_lb_state_dbg(HWND listbox
, int count
, int cur_sel
,
12652 int caret_index
, int top_index
, int line
)
12656 /* calling an orig proc helps to avoid unnecessary message logging */
12657 ret
= CallWindowProcA(listbox_orig_proc
, listbox
, LB_GETCOUNT
, 0, 0);
12658 ok_(__FILE__
, line
)(ret
== count
, "expected count %d, got %ld\n", count
, ret
);
12659 ret
= CallWindowProcA(listbox_orig_proc
, listbox
, LB_GETCURSEL
, 0, 0);
12660 ok_(__FILE__
, line
)(ret
== cur_sel
, "expected cur sel %d, got %ld\n", cur_sel
, ret
);
12661 ret
= CallWindowProcA(listbox_orig_proc
, listbox
, LB_GETCARETINDEX
, 0, 0);
12662 ok_(__FILE__
, line
)(ret
== caret_index
||
12663 broken(cur_sel
== -1 && caret_index
== 0 && ret
== -1), /* nt4 */
12664 "expected caret index %d, got %ld\n", caret_index
, ret
);
12665 ret
= CallWindowProcA(listbox_orig_proc
, listbox
, LB_GETTOPINDEX
, 0, 0);
12666 ok_(__FILE__
, line
)(ret
== top_index
, "expected top index %d, got %ld\n", top_index
, ret
);
12669 static void test_listbox_messages(void)
12671 HWND parent
, listbox
;
12674 parent
= CreateWindowExA(0, "TestParentClass", NULL
, WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
12675 100, 100, 200, 200, 0, 0, 0, NULL
);
12676 listbox
= CreateWindowExA(WS_EX_NOPARENTNOTIFY
, "ListBox", NULL
,
12677 WS_CHILD
| LBS_NOTIFY
| LBS_OWNERDRAWVARIABLE
| LBS_HASSTRINGS
| WS_VISIBLE
,
12678 10, 10, 80, 80, parent
, (HMENU
)ID_LISTBOX
, 0, NULL
);
12679 listbox_orig_proc
= (WNDPROC
)SetWindowLongPtrA(listbox
, GWLP_WNDPROC
, (ULONG_PTR
)listbox_hook_proc
);
12681 check_lb_state(listbox
, 0, LB_ERR
, 0, 0);
12683 ret
= SendMessageA(listbox
, LB_ADDSTRING
, 0, (LPARAM
)"item 0");
12684 ok(ret
== 0, "expected 0, got %ld\n", ret
);
12685 ret
= SendMessageA(listbox
, LB_ADDSTRING
, 0, (LPARAM
)"item 1");
12686 ok(ret
== 1, "expected 1, got %ld\n", ret
);
12687 ret
= SendMessageA(listbox
, LB_ADDSTRING
, 0, (LPARAM
)"item 2");
12688 ok(ret
== 2, "expected 2, got %ld\n", ret
);
12690 check_lb_state(listbox
, 3, LB_ERR
, 0, 0);
12694 log_all_parent_messages
++;
12696 trace("selecting item 0\n");
12697 ret
= SendMessageA(listbox
, LB_SETCURSEL
, 0, 0);
12698 ok(ret
== 0, "expected 0, got %ld\n", ret
);
12699 ok_sequence(wm_lb_setcursel_0
, "LB_SETCURSEL 0", FALSE
);
12700 check_lb_state(listbox
, 3, 0, 0, 0);
12703 trace("selecting item 1\n");
12704 ret
= SendMessageA(listbox
, LB_SETCURSEL
, 1, 0);
12705 ok(ret
== 1, "expected 1, got %ld\n", ret
);
12706 ok_sequence(wm_lb_setcursel_1
, "LB_SETCURSEL 1", FALSE
);
12707 check_lb_state(listbox
, 3, 1, 1, 0);
12709 trace("selecting item 2\n");
12710 ret
= SendMessageA(listbox
, LB_SETCURSEL
, 2, 0);
12711 ok(ret
== 2, "expected 2, got %ld\n", ret
);
12712 ok_sequence(wm_lb_setcursel_2
, "LB_SETCURSEL 2", FALSE
);
12713 check_lb_state(listbox
, 3, 2, 2, 0);
12715 trace("clicking on item 0\n");
12716 ret
= SendMessageA(listbox
, WM_LBUTTONDOWN
, 0, MAKELPARAM(1, 1));
12717 ok(ret
== LB_OKAY
, "expected LB_OKAY, got %ld\n", ret
);
12718 ret
= SendMessageA(listbox
, WM_LBUTTONUP
, 0, 0);
12719 ok(ret
== LB_OKAY
, "expected LB_OKAY, got %ld\n", ret
);
12720 ok_sequence(wm_lb_click_0
, "WM_LBUTTONDOWN 0", FALSE
);
12721 check_lb_state(listbox
, 3, 0, 0, 0);
12724 trace("deleting item 0\n");
12725 ret
= SendMessageA(listbox
, LB_DELETESTRING
, 0, 0);
12726 ok(ret
== 2, "expected 2, got %ld\n", ret
);
12727 ok_sequence(wm_lb_deletestring
, "LB_DELETESTRING 0", FALSE
);
12728 check_lb_state(listbox
, 2, -1, 0, 0);
12731 trace("deleting item 0\n");
12732 ret
= SendMessageA(listbox
, LB_DELETESTRING
, 0, 0);
12733 ok(ret
== 1, "expected 1, got %ld\n", ret
);
12734 ok_sequence(wm_lb_deletestring
, "LB_DELETESTRING 0", FALSE
);
12735 check_lb_state(listbox
, 1, -1, 0, 0);
12738 trace("deleting item 0\n");
12739 ret
= SendMessageA(listbox
, LB_DELETESTRING
, 0, 0);
12740 ok(ret
== 0, "expected 0, got %ld\n", ret
);
12741 ok_sequence(wm_lb_deletestring_reset
, "LB_DELETESTRING 0", FALSE
);
12742 check_lb_state(listbox
, 0, -1, 0, 0);
12745 trace("deleting item 0\n");
12746 ret
= SendMessageA(listbox
, LB_DELETESTRING
, 0, 0);
12747 ok(ret
== LB_ERR
, "expected LB_ERR, got %ld\n", ret
);
12748 check_lb_state(listbox
, 0, -1, 0, 0);
12751 log_all_parent_messages
--;
12753 DestroyWindow(listbox
);
12754 DestroyWindow(parent
);
12757 /*************************** Menu test ******************************/
12758 static const struct message wm_popup_menu_1
[] =
12760 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 },
12761 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
12762 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'E', 0x20000001 },
12763 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, 'E', 0x20000001 },
12764 { WM_SYSCHAR
, sent
|wparam
|lparam
, 'e', 0x20000001 },
12765 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_KEYMENU
, 'e' },
12766 { WM_ENTERMENULOOP
, sent
|wparam
|lparam
, 0, 0 },
12767 { WM_INITMENU
, sent
|lparam
, 0, 0 },
12768 { WM_MENUSELECT
, sent
|wparam
, MAKEWPARAM(1,MF_HILITE
|MF_POPUP
) },
12769 { WM_INITMENUPOPUP
, sent
|lparam
, 0, 1 },
12770 { HCBT_CREATEWND
, hook
|optional
}, /* Win9x doesn't create a window */
12771 { WM_MENUSELECT
, sent
|wparam
, MAKEWPARAM(200,MF_HILITE
) },
12772 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'E', 0xf0000001 },
12773 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xd0000001 },
12774 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_RETURN
, 0x10000001, 0, 0x40000000 },
12775 { HCBT_DESTROYWND
, hook
|optional
}, /* Win9x doesn't create a window */
12776 { WM_UNINITMENUPOPUP
, sent
|lparam
, 0, 0 },
12777 { WM_MENUSELECT
, sent
|wparam
|lparam
, MAKEWPARAM(0,0xffff), 0 },
12778 { WM_EXITMENULOOP
, sent
|wparam
|lparam
, 0, 0 },
12779 { WM_MENUCOMMAND
, sent
}, /* |wparam, 200 - Win9x */
12780 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_RETURN
, 0xc0000001 },
12781 { WM_KEYUP
, sent
|wparam
|lparam
, VK_RETURN
, 0xc0000001 },
12784 static const struct message wm_popup_menu_2
[] =
12786 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 },
12787 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
12788 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'F', 0x20000001 },
12789 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, 'F', 0x20000001 },
12790 { WM_SYSCHAR
, sent
|wparam
|lparam
, 'f', 0x20000001 },
12791 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_KEYMENU
, 'f' },
12792 { WM_ENTERMENULOOP
, sent
|wparam
|lparam
, 0, 0 },
12793 { WM_INITMENU
, sent
|lparam
, 0, 0 },
12794 { WM_MENUSELECT
, sent
|wparam
, MAKEWPARAM(0,MF_HILITE
|MF_POPUP
) },
12795 { WM_INITMENUPOPUP
, sent
|lparam
, 0, 0 },
12796 { WM_MENUSELECT
, sent
|wparam
|optional
, MAKEWPARAM(0,MF_HILITE
|MF_POPUP
) }, /* Win9x */
12797 { WM_INITMENUPOPUP
, sent
|lparam
|optional
, 0, 0 }, /* Win9x */
12798 { HCBT_CREATEWND
, hook
},
12799 { WM_MENUSELECT
, sent
}, /*|wparam, MAKEWPARAM(0,MF_HILITE|MF_POPUP) - XP
12800 |wparam, MAKEWPARAM(100,MF_HILITE) - Win9x */
12801 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'F', 0xf0000001 },
12802 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xd0000001 },
12803 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_RIGHT
, 0x10000001 },
12804 { WM_INITMENUPOPUP
, sent
|lparam
|optional
, 0, 0 }, /* Win9x doesn't send it */
12805 { HCBT_CREATEWND
, hook
|optional
}, /* Win9x doesn't send it */
12806 { WM_MENUSELECT
, sent
|wparam
|optional
, MAKEWPARAM(100,MF_HILITE
) },
12807 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_RIGHT
, 0xd0000001 },
12808 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_RETURN
, 0x10000001 },
12809 { HCBT_DESTROYWND
, hook
},
12810 { WM_UNINITMENUPOPUP
, sent
|lparam
, 0, 0 },
12811 { HCBT_DESTROYWND
, hook
|optional
}, /* Win9x doesn't send it */
12812 { WM_UNINITMENUPOPUP
, sent
|lparam
, 0, 0 },
12813 { WM_MENUSELECT
, sent
|wparam
|lparam
, MAKEWPARAM(0,0xffff), 0 },
12814 { WM_EXITMENULOOP
, sent
|wparam
|lparam
, 0, 0 },
12815 { WM_MENUCOMMAND
, sent
}, /* |wparam, 100 - Win9x */
12816 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_RETURN
, 0xc0000001 },
12817 { WM_KEYUP
, sent
|wparam
|lparam
, VK_RETURN
, 0xc0000001 },
12820 static const struct message wm_popup_menu_3
[] =
12822 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 },
12823 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
12824 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'F', 0x20000001 },
12825 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, 'F', 0x20000001 },
12826 { WM_SYSCHAR
, sent
|wparam
|lparam
, 'f', 0x20000001 },
12827 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_KEYMENU
, 'f' },
12828 { WM_ENTERMENULOOP
, sent
|wparam
|lparam
, 0, 0 },
12829 { WM_INITMENU
, sent
|lparam
, 0, 0 },
12830 { WM_MENUSELECT
, sent
|wparam
, MAKEWPARAM(0,MF_HILITE
|MF_POPUP
) },
12831 { WM_INITMENUPOPUP
, sent
|lparam
, 0, 0 },
12832 { WM_MENUSELECT
, sent
|wparam
|optional
, MAKEWPARAM(0,MF_HILITE
|MF_POPUP
) }, /* Win9x */
12833 { WM_INITMENUPOPUP
, sent
|lparam
|optional
, 0, 0 }, /* Win9x */
12834 { HCBT_CREATEWND
, hook
},
12835 { WM_MENUSELECT
, sent
}, /*|wparam, MAKEWPARAM(0,MF_HILITE|MF_POPUP) - XP
12836 |wparam, MAKEWPARAM(100,MF_HILITE) - Win9x */
12837 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'F', 0xf0000001 },
12838 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xd0000001 },
12839 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_RIGHT
, 0x10000001 },
12840 { WM_INITMENUPOPUP
, sent
|lparam
|optional
, 0, 0 }, /* Win9x doesn't send it */
12841 { HCBT_CREATEWND
, hook
|optional
}, /* Win9x doesn't send it */
12842 { WM_MENUSELECT
, sent
|wparam
|optional
, MAKEWPARAM(100,MF_HILITE
) },
12843 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_RIGHT
, 0xd0000001 },
12844 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_RETURN
, 0x10000001 },
12845 { HCBT_DESTROYWND
, hook
},
12846 { WM_UNINITMENUPOPUP
, sent
|lparam
, 0, 0 },
12847 { HCBT_DESTROYWND
, hook
|optional
}, /* Win9x doesn't send it */
12848 { WM_UNINITMENUPOPUP
, sent
|lparam
, 0, 0 },
12849 { WM_MENUSELECT
, sent
|wparam
|lparam
, MAKEWPARAM(0,0xffff), 0 },
12850 { WM_EXITMENULOOP
, sent
|wparam
|lparam
, 0, 0 },
12851 { WM_COMMAND
, sent
|wparam
|lparam
, 100, 0 },
12852 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_RETURN
, 0xc0000001 },
12853 { WM_KEYUP
, sent
|wparam
|lparam
, VK_RETURN
, 0xc0000001 },
12857 static const struct message wm_single_menu_item
[] =
12859 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 },
12860 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
12861 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'Q', 0x20000001 },
12862 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, 'Q', 0x20000001 },
12863 { WM_SYSCHAR
, sent
|wparam
|lparam
, 'q', 0x20000001 },
12864 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_KEYMENU
, 'q' },
12865 { WM_ENTERMENULOOP
, sent
|wparam
|lparam
, 0, 0 },
12866 { WM_INITMENU
, sent
|lparam
, 0, 0 },
12867 { WM_MENUSELECT
, sent
|wparam
|optional
, MAKEWPARAM(300,MF_HILITE
) },
12868 { WM_MENUSELECT
, sent
|wparam
|lparam
, MAKEWPARAM(0,0xffff), 0 },
12869 { WM_EXITMENULOOP
, sent
|wparam
|lparam
, 0, 0 },
12870 { WM_MENUCOMMAND
, sent
},
12871 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'Q', 0xe0000001 },
12872 { WM_SYSKEYUP
, sent
|wparam
|lparam
, 'Q', 0xe0000001 },
12873 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xc0000001 },
12874 { WM_KEYUP
, sent
|wparam
|lparam
, VK_MENU
, 0xc0000001 },
12876 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_ESCAPE
, 1 },
12877 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_ESCAPE
, 1 },
12878 { WM_CHAR
, sent
|wparam
|lparam
, VK_ESCAPE
, 0x00000001 },
12879 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_ESCAPE
, 0xc0000001 },
12880 { WM_KEYUP
, sent
|wparam
|lparam
, VK_ESCAPE
, 0xc0000001 },
12884 static LRESULT WINAPI
parent_menu_proc(HWND hwnd
, UINT message
, WPARAM wp
, LPARAM lp
)
12886 if (message
== WM_ENTERIDLE
||
12887 message
== WM_INITMENU
||
12888 message
== WM_INITMENUPOPUP
||
12889 message
== WM_MENUSELECT
||
12890 message
== WM_PARENTNOTIFY
||
12891 message
== WM_ENTERMENULOOP
||
12892 message
== WM_EXITMENULOOP
||
12893 message
== WM_UNINITMENUPOPUP
||
12894 message
== WM_KEYDOWN
||
12895 message
== WM_KEYUP
||
12896 message
== WM_CHAR
||
12897 message
== WM_SYSKEYDOWN
||
12898 message
== WM_SYSKEYUP
||
12899 message
== WM_SYSCHAR
||
12900 message
== WM_COMMAND
||
12901 message
== WM_MENUCOMMAND
)
12903 struct recvd_message msg
;
12906 msg
.message
= message
;
12907 msg
.flags
= sent
|wparam
|lparam
;
12910 msg
.descr
= "parent_menu_proc";
12914 return DefWindowProcA(hwnd
, message
, wp
, lp
);
12917 static void set_menu_style(HMENU hmenu
, DWORD style
)
12922 mi
.cbSize
= sizeof(mi
);
12923 mi
.fMask
= MIM_STYLE
;
12924 mi
.dwStyle
= style
;
12925 SetLastError(0xdeadbeef);
12926 ret
= pSetMenuInfo(hmenu
, &mi
);
12927 ok(ret
, "SetMenuInfo error %u\n", GetLastError());
12930 static DWORD
get_menu_style(HMENU hmenu
)
12935 mi
.cbSize
= sizeof(mi
);
12936 mi
.fMask
= MIM_STYLE
;
12938 SetLastError(0xdeadbeef);
12939 ret
= pGetMenuInfo(hmenu
, &mi
);
12940 ok(ret
, "GetMenuInfo error %u\n", GetLastError());
12945 static void test_menu_messages(void)
12949 HMENU hmenu
, hmenu_popup
;
12953 if (!pGetMenuInfo
|| !pSetMenuInfo
)
12955 win_skip("GetMenuInfo and/or SetMenuInfo are not available\n");
12959 cls
.lpfnWndProc
= parent_menu_proc
;
12960 cls
.cbClsExtra
= 0;
12961 cls
.cbWndExtra
= 0;
12962 cls
.hInstance
= GetModuleHandleA(0);
12964 cls
.hCursor
= LoadCursorA(0, (LPCSTR
)IDC_ARROW
);
12965 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
12966 cls
.lpszMenuName
= NULL
;
12967 cls
.lpszClassName
= "TestMenuClass";
12968 UnregisterClassA(cls
.lpszClassName
, cls
.hInstance
);
12969 if (!RegisterClassA(&cls
)) assert(0);
12971 SetLastError(0xdeadbeef);
12972 hwnd
= CreateWindowExA(0, "TestMenuClass", NULL
, WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
12973 100, 100, 200, 200, 0, 0, 0, NULL
);
12974 ok(hwnd
!= 0, "LoadMenuA error %u\n", GetLastError());
12976 SetLastError(0xdeadbeef);
12977 hmenu
= LoadMenuA(GetModuleHandleA(NULL
), MAKEINTRESOURCEA(1));
12978 ok(hmenu
!= 0, "LoadMenuA error %u\n", GetLastError());
12980 SetMenu(hwnd
, hmenu
);
12981 SetForegroundWindow( hwnd
);
12984 set_menu_style(hmenu
, MNS_NOTIFYBYPOS
);
12985 style
= get_menu_style(hmenu
);
12986 ok(style
== MNS_NOTIFYBYPOS
, "expected MNS_NOTIFYBYPOS, got %u\n", style
);
12988 hmenu_popup
= GetSubMenu(hmenu
, 0);
12989 ok(hmenu_popup
!= 0, "GetSubMenu returned 0 for submenu 0\n");
12990 style
= get_menu_style(hmenu_popup
);
12991 ok(style
== 0, "expected 0, got %u\n", style
);
12993 hmenu_popup
= GetSubMenu(hmenu_popup
, 0);
12994 ok(hmenu_popup
!= 0, "GetSubMenu returned 0 for submenu 0\n");
12995 style
= get_menu_style(hmenu_popup
);
12996 ok(style
== 0, "expected 0, got %u\n", style
);
12999 trace("testing a popup menu command\n");
13001 keybd_event(VK_MENU
, 0, 0, 0);
13002 keybd_event('E', 0, 0, 0);
13003 keybd_event('E', 0, KEYEVENTF_KEYUP
, 0);
13004 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
13005 keybd_event(VK_RETURN
, 0, 0, 0);
13006 keybd_event(VK_RETURN
, 0, KEYEVENTF_KEYUP
, 0);
13007 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
))
13009 TranslateMessage(&msg
);
13010 DispatchMessageA(&msg
);
13012 if (!sequence_cnt
) /* we didn't get any message */
13014 skip( "queuing key events not supported\n" );
13017 /* win98 queues only a WM_KEYUP and doesn't start menu tracking */
13018 if (sequence
[0].message
== WM_KEYUP
&& sequence
[0].wParam
== VK_MENU
)
13020 win_skip( "menu tracking through VK_MENU not supported\n" );
13023 ok_sequence(wm_popup_menu_1
, "popup menu command", FALSE
);
13025 /* Alt+F, Right, Enter */
13026 trace("testing submenu of a popup menu command\n");
13028 keybd_event(VK_MENU
, 0, 0, 0);
13029 keybd_event('F', 0, 0, 0);
13030 keybd_event('F', 0, KEYEVENTF_KEYUP
, 0);
13031 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
13032 keybd_event(VK_RIGHT
, 0, 0, 0);
13033 keybd_event(VK_RIGHT
, 0, KEYEVENTF_KEYUP
, 0);
13034 keybd_event(VK_RETURN
, 0, 0, 0);
13035 keybd_event(VK_RETURN
, 0, KEYEVENTF_KEYUP
, 0);
13036 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
))
13038 TranslateMessage(&msg
);
13039 DispatchMessageA(&msg
);
13041 ok_sequence(wm_popup_menu_2
, "submenu of a popup menu command", FALSE
);
13043 trace("testing single menu item command\n");
13045 keybd_event(VK_MENU
, 0, 0, 0);
13046 keybd_event('Q', 0, 0, 0);
13047 keybd_event('Q', 0, KEYEVENTF_KEYUP
, 0);
13048 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
13049 keybd_event(VK_ESCAPE
, 0, 0, 0);
13050 keybd_event(VK_ESCAPE
, 0, KEYEVENTF_KEYUP
, 0);
13051 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
))
13053 TranslateMessage(&msg
);
13054 DispatchMessageA(&msg
);
13056 ok_sequence(wm_single_menu_item
, "single menu item command", FALSE
);
13058 set_menu_style(hmenu
, 0);
13059 style
= get_menu_style(hmenu
);
13060 ok(style
== 0, "expected 0, got %u\n", style
);
13062 hmenu_popup
= GetSubMenu(hmenu
, 0);
13063 ok(hmenu_popup
!= 0, "GetSubMenu returned 0 for submenu 0\n");
13064 set_menu_style(hmenu_popup
, MNS_NOTIFYBYPOS
);
13065 style
= get_menu_style(hmenu_popup
);
13066 ok(style
== MNS_NOTIFYBYPOS
, "expected MNS_NOTIFYBYPOS, got %u\n", style
);
13068 hmenu_popup
= GetSubMenu(hmenu_popup
, 0);
13069 ok(hmenu_popup
!= 0, "GetSubMenu returned 0 for submenu 0\n");
13070 style
= get_menu_style(hmenu_popup
);
13071 ok(style
== 0, "expected 0, got %u\n", style
);
13073 /* Alt+F, Right, Enter */
13074 trace("testing submenu of a popup menu command\n");
13076 keybd_event(VK_MENU
, 0, 0, 0);
13077 keybd_event('F', 0, 0, 0);
13078 keybd_event('F', 0, KEYEVENTF_KEYUP
, 0);
13079 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
13080 keybd_event(VK_RIGHT
, 0, 0, 0);
13081 keybd_event(VK_RIGHT
, 0, KEYEVENTF_KEYUP
, 0);
13082 keybd_event(VK_RETURN
, 0, 0, 0);
13083 keybd_event(VK_RETURN
, 0, KEYEVENTF_KEYUP
, 0);
13084 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
))
13086 TranslateMessage(&msg
);
13087 DispatchMessageA(&msg
);
13089 ok_sequence(wm_popup_menu_3
, "submenu of a popup menu command", FALSE
);
13092 DestroyWindow(hwnd
);
13093 DestroyMenu(hmenu
);
13097 static void test_paintingloop(void)
13101 paint_loop_done
= FALSE
;
13102 hwnd
= CreateWindowExA(0x0,"PaintLoopWindowClass",
13103 "PaintLoopWindowClass",WS_OVERLAPPEDWINDOW
,
13104 100, 100, 100, 100, 0, 0, 0, NULL
);
13105 ok(hwnd
!= 0, "PaintLoop window error %u\n", GetLastError());
13106 ShowWindow(hwnd
,SW_NORMAL
);
13109 while (!paint_loop_done
)
13112 if (PeekMessageA(&msg
, 0, 0, 0, 1))
13114 TranslateMessage(&msg
);
13115 DispatchMessageA(&msg
);
13118 DestroyWindow(hwnd
);
13121 static void test_defwinproc(void)
13125 BOOL gotwmquit
= FALSE
;
13126 hwnd
= CreateWindowExA(0, "static", "test_defwndproc", WS_POPUP
, 0,0,0,0,0,0,0, NULL
);
13128 DefWindowProcA( hwnd
, WM_ENDSESSION
, 1, 0);
13129 while (PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
)) {
13130 if( msg
.message
== WM_QUIT
) gotwmquit
= TRUE
;
13131 DispatchMessageA( &msg
);
13133 ok(!gotwmquit
, "Unexpected WM_QUIT message!\n");
13134 DestroyWindow( hwnd
);
13137 #define clear_clipboard(hwnd) clear_clipboard_(__LINE__, (hwnd))
13138 static void clear_clipboard_(int line
, HWND hWnd
)
13141 succ
= OpenClipboard(hWnd
);
13142 ok_(__FILE__
, line
)(succ
, "OpenClipboard failed, err=%u\n", GetLastError());
13143 succ
= EmptyClipboard();
13144 ok_(__FILE__
, line
)(succ
, "EmptyClipboard failed, err=%u\n", GetLastError());
13145 succ
= CloseClipboard();
13146 ok_(__FILE__
, line
)(succ
, "CloseClipboard failed, err=%u\n", GetLastError());
13149 #define expect_HWND(expected, got) expect_HWND_(__LINE__, (expected), (got))
13150 static void expect_HWND_(int line
, HWND expected
, HWND got
)
13152 ok_(__FILE__
, line
)(got
==expected
, "Expected %p, got %p\n", expected
, got
);
13155 static WNDPROC pOldViewerProc
;
13157 static LRESULT CALLBACK
recursive_viewer_proc(HWND hWnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
13159 static BOOL recursion_guard
;
13161 if (message
== WM_DRAWCLIPBOARD
&& !recursion_guard
)
13163 recursion_guard
= TRUE
;
13164 clear_clipboard(hWnd
);
13165 recursion_guard
= FALSE
;
13167 return CallWindowProcA(pOldViewerProc
, hWnd
, message
, wParam
, lParam
);
13170 static void test_clipboard_viewers(void)
13172 static struct message wm_change_cb_chain
[] =
13174 { WM_CHANGECBCHAIN
, sent
|wparam
|lparam
, 0, 0 },
13177 static const struct message wm_clipboard_destroyed
[] =
13179 { WM_DESTROYCLIPBOARD
, sent
|wparam
|lparam
, 0, 0 },
13182 static struct message wm_clipboard_changed
[] =
13184 { WM_DRAWCLIPBOARD
, sent
|wparam
|lparam
, 0, 0 },
13187 static struct message wm_clipboard_changed_and_owned
[] =
13189 { WM_DESTROYCLIPBOARD
, sent
|wparam
|lparam
, 0, 0 },
13190 { WM_DRAWCLIPBOARD
, sent
|wparam
|lparam
, 0, 0 },
13194 HINSTANCE hInst
= GetModuleHandleA(NULL
);
13195 HWND hWnd1
, hWnd2
, hWnd3
;
13199 hWnd1
= CreateWindowExA(0, "TestWindowClass", "Clipboard viewer test wnd 1",
13200 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
| WS_MAXIMIZEBOX
,
13201 CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
,
13202 GetDesktopWindow(), NULL
, hInst
, NULL
);
13203 hWnd2
= CreateWindowExA(0, "SimpleWindowClass", "Clipboard viewer test wnd 2",
13204 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
| WS_MAXIMIZEBOX
,
13205 CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
,
13206 GetDesktopWindow(), NULL
, hInst
, NULL
);
13207 hWnd3
= CreateWindowExA(0, "SimpleWindowClass", "Clipboard viewer test wnd 3",
13208 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
| WS_MAXIMIZEBOX
,
13209 CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
,
13210 GetDesktopWindow(), NULL
, hInst
, NULL
);
13211 trace("clipbd viewers: hWnd1=%p, hWnd2=%p, hWnd3=%p\n", hWnd1
, hWnd2
, hWnd3
);
13212 assert(hWnd1
&& hWnd2
&& hWnd3
);
13216 /* Test getting the clipboard viewer and setting the viewer to NULL. */
13217 hOrigViewer
= GetClipboardViewer();
13218 hRet
= SetClipboardViewer(NULL
);
13219 ok_sequence(WmEmptySeq
, "set viewer to NULL", FALSE
);
13220 expect_HWND(hOrigViewer
, hRet
);
13221 expect_HWND(NULL
, GetClipboardViewer());
13223 /* Test registering hWnd1 as a viewer. */
13224 hRet
= SetClipboardViewer(hWnd1
);
13225 wm_clipboard_changed
[0].wParam
= (WPARAM
) GetClipboardOwner();
13226 ok_sequence(wm_clipboard_changed
, "set viewer NULL->1", FALSE
);
13227 expect_HWND(NULL
, hRet
);
13228 expect_HWND(hWnd1
, GetClipboardViewer());
13230 /* Test that changing the clipboard actually refreshes the registered viewer. */
13231 clear_clipboard(hWnd1
);
13232 wm_clipboard_changed
[0].wParam
= (WPARAM
) GetClipboardOwner();
13233 ok_sequence(wm_clipboard_changed
, "clear clipbd (viewer=owner=1)", FALSE
);
13235 /* Again, but with different owner. */
13236 clear_clipboard(hWnd2
);
13237 wm_clipboard_changed_and_owned
[1].wParam
= (WPARAM
) GetClipboardOwner();
13238 ok_sequence(wm_clipboard_changed_and_owned
, "clear clipbd (viewer=1, owner=2)", FALSE
);
13240 /* Test re-registering same window. */
13241 hRet
= SetClipboardViewer(hWnd1
);
13242 wm_clipboard_changed
[0].wParam
= (WPARAM
) GetClipboardOwner();
13243 ok_sequence(wm_clipboard_changed
, "set viewer 1->1", FALSE
);
13244 expect_HWND(hWnd1
, hRet
);
13245 expect_HWND(hWnd1
, GetClipboardViewer());
13247 /* Test ChangeClipboardChain. */
13248 ChangeClipboardChain(hWnd2
, hWnd3
);
13249 wm_change_cb_chain
[0].wParam
= (WPARAM
) hWnd2
;
13250 wm_change_cb_chain
[0].lParam
= (LPARAM
) hWnd3
;
13251 ok_sequence(wm_change_cb_chain
, "change chain (viewer=1, remove=2, next=3)", FALSE
);
13252 expect_HWND(hWnd1
, GetClipboardViewer());
13254 ChangeClipboardChain(hWnd2
, NULL
);
13255 wm_change_cb_chain
[0].wParam
= (WPARAM
) hWnd2
;
13256 wm_change_cb_chain
[0].lParam
= 0;
13257 ok_sequence(wm_change_cb_chain
, "change chain (viewer=1, remove=2, next=NULL)", FALSE
);
13258 expect_HWND(hWnd1
, GetClipboardViewer());
13260 ChangeClipboardChain(NULL
, hWnd2
);
13261 ok_sequence(WmEmptySeq
, "change chain (viewer=1, remove=NULL, next=2)", TRUE
);
13262 expect_HWND(hWnd1
, GetClipboardViewer());
13264 /* Actually change clipboard viewer with ChangeClipboardChain. */
13265 ChangeClipboardChain(hWnd1
, hWnd2
);
13266 ok_sequence(WmEmptySeq
, "change chain (viewer=remove=1, next=2)", FALSE
);
13267 expect_HWND(hWnd2
, GetClipboardViewer());
13269 /* Test that no refresh messages are sent when viewer has unregistered. */
13270 clear_clipboard(hWnd2
);
13271 ok_sequence(WmEmptySeq
, "clear clipd (viewer=2, owner=1)", FALSE
);
13273 /* Register hWnd1 again. */
13274 ChangeClipboardChain(hWnd2
, hWnd1
);
13275 ok_sequence(WmEmptySeq
, "change chain (viewer=remove=2, next=1)", FALSE
);
13276 expect_HWND(hWnd1
, GetClipboardViewer());
13278 /* Subclass hWnd1 so that when it receives a WM_DRAWCLIPBOARD message, it
13279 * changes the clipboard. When this happens, the system shouldn't send
13280 * another WM_DRAWCLIPBOARD (as this could cause an infinite loop).
13282 pOldViewerProc
= (WNDPROC
) SetWindowLongPtrA(hWnd1
, GWLP_WNDPROC
, (LONG_PTR
) recursive_viewer_proc
);
13283 clear_clipboard(hWnd2
);
13284 /* The clipboard owner is changed in recursive_viewer_proc: */
13285 wm_clipboard_changed
[0].wParam
= (WPARAM
) hWnd2
;
13286 ok_sequence(wm_clipboard_changed
, "recursive clear clipbd (viewer=1, owner=2)", TRUE
);
13288 /* Test unregistering. */
13289 ChangeClipboardChain(hWnd1
, NULL
);
13290 ok_sequence(WmEmptySeq
, "change chain (viewer=remove=1, next=NULL)", FALSE
);
13291 expect_HWND(NULL
, GetClipboardViewer());
13293 clear_clipboard(hWnd1
);
13294 ok_sequence(wm_clipboard_destroyed
, "clear clipbd (no viewer, owner=1)", FALSE
);
13296 DestroyWindow(hWnd1
);
13297 DestroyWindow(hWnd2
);
13298 DestroyWindow(hWnd3
);
13299 SetClipboardViewer(hOrigViewer
);
13302 static void test_PostMessage(void)
13304 static const struct
13310 { HWND_TOP
/* 0 */, TRUE
},
13311 { HWND_BROADCAST
, TRUE
},
13312 { HWND_BOTTOM
, TRUE
},
13313 { HWND_TOPMOST
, TRUE
},
13314 { HWND_NOTOPMOST
, FALSE
},
13315 { HWND_MESSAGE
, FALSE
},
13316 { (HWND
)0xdeadbeef, FALSE
}
13322 static const WCHAR staticW
[] = {'s','t','a','t','i','c',0};
13324 SetLastError(0xdeadbeef);
13325 hwnd
= CreateWindowExW(0, staticW
, NULL
, WS_POPUP
, 0,0,0,0,0,0,0, NULL
);
13326 if (!hwnd
&& GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
)
13328 win_skip("Skipping some PostMessage tests on Win9x/WinMe\n");
13335 PostMessageA(hwnd
, WM_USER
+1, 0x1234, 0x5678);
13336 PostMessageA(0, WM_USER
+2, 0x5678, 0x1234);
13338 for (i
= 0; i
< sizeof(data
)/sizeof(data
[0]); i
++)
13340 memset(&msg
, 0xab, sizeof(msg
));
13341 ret
= PeekMessageA(&msg
, data
[i
].hwnd
, 0, 0, PM_NOREMOVE
);
13342 ok(ret
== data
[i
].ret
, "%d: hwnd %p expected %d, got %d\n", i
, data
[i
].hwnd
, data
[i
].ret
, ret
);
13346 ok(ret
&& msg
.hwnd
== 0 && msg
.message
== WM_USER
+2 &&
13347 msg
.wParam
== 0x5678 && msg
.lParam
== 0x1234,
13348 "%d: got ret %d hwnd %p msg %04x wParam %08lx lParam %08lx instead of TRUE/0/WM_USER+2/0x5678/0x1234\n",
13349 i
, ret
, msg
.hwnd
, msg
.message
, msg
.wParam
, msg
.lParam
);
13351 ok(ret
&& msg
.hwnd
== hwnd
&& msg
.message
== WM_USER
+1 &&
13352 msg
.wParam
== 0x1234 && msg
.lParam
== 0x5678,
13353 "%d: got ret %d hwnd %p msg %04x wParam %08lx lParam %08lx instead of TRUE/%p/WM_USER+1/0x1234/0x5678\n",
13354 i
, ret
, msg
.hwnd
, msg
.message
, msg
.wParam
, msg
.lParam
, msg
.hwnd
);
13358 DestroyWindow(hwnd
);
13362 static const struct
13366 } wait_idle_expect
[] =
13368 /* 0 */ { WAIT_TIMEOUT
, WAIT_TIMEOUT
, FALSE
},
13369 { WAIT_TIMEOUT
, 0, FALSE
},
13370 { WAIT_TIMEOUT
, 0, FALSE
},
13371 { WAIT_TIMEOUT
, WAIT_TIMEOUT
, FALSE
},
13372 { WAIT_TIMEOUT
, WAIT_TIMEOUT
, FALSE
},
13373 /* 5 */ { WAIT_TIMEOUT
, 0, FALSE
},
13374 { WAIT_TIMEOUT
, 0, FALSE
},
13375 { WAIT_TIMEOUT
, WAIT_TIMEOUT
, FALSE
},
13378 /* 10 */ { 0, 0, FALSE
},
13380 { 0, WAIT_TIMEOUT
, FALSE
},
13383 /* 15 */ { 0, 0, FALSE
},
13384 { WAIT_TIMEOUT
, 0, FALSE
},
13385 { WAIT_TIMEOUT
, 0, FALSE
},
13386 { WAIT_TIMEOUT
, 0, FALSE
},
13387 { WAIT_TIMEOUT
, 0, FALSE
},
13388 /* 20 */ { WAIT_TIMEOUT
, 0, FALSE
},
13391 static DWORD CALLBACK
do_wait_idle_child_thread( void *arg
)
13395 PeekMessageA( &msg
, 0, 0, 0, PM_NOREMOVE
);
13397 MsgWaitForMultipleObjects( 0, NULL
, FALSE
, 100, QS_ALLINPUT
);
13401 static void do_wait_idle_child( int arg
)
13408 HANDLE start_event
= OpenEventA( EVENT_ALL_ACCESS
, FALSE
, "test_WaitForInputIdle_start" );
13409 HANDLE end_event
= OpenEventA( EVENT_ALL_ACCESS
, FALSE
, "test_WaitForInputIdle_end" );
13411 memset( &cls
, 0, sizeof(cls
) );
13412 cls
.lpfnWndProc
= DefWindowProcA
;
13413 cls
.hbrBackground
= (HBRUSH
)(COLOR_WINDOW
+ 1);
13414 cls
.hCursor
= LoadCursorA(0, (LPCSTR
)IDC_ARROW
);
13415 cls
.lpszClassName
= "TestClass";
13416 RegisterClassA( &cls
);
13418 PeekMessageA( &msg
, 0, 0, 0, PM_NOREMOVE
); /* create the msg queue */
13420 ok( start_event
!= 0, "failed to create start event, error %u\n", GetLastError() );
13421 ok( end_event
!= 0, "failed to create end event, error %u\n", GetLastError() );
13426 SetEvent( start_event
);
13429 SetEvent( start_event
);
13431 PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
);
13434 SetEvent( start_event
);
13436 PeekMessageA( &msg
, 0, 0, 0, PM_NOREMOVE
);
13437 PostThreadMessageA( GetCurrentThreadId(), WM_COMMAND
, 0x1234, 0xabcd );
13438 PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
);
13441 SetEvent( start_event
);
13443 SendMessageA( HWND_BROADCAST
, WM_WININICHANGE
, 0, 0 );
13446 SetEvent( start_event
);
13448 hwnd
= CreateWindowExA(0, "TestClass", NULL
, WS_POPUP
|WS_VISIBLE
, 0, 0, 10, 10, 0, 0, 0, NULL
);
13449 while (PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
|PM_NOYIELD
)) DispatchMessageA( &msg
);
13452 SetEvent( start_event
);
13454 hwnd
= CreateWindowExA(0, "TestClass", NULL
, WS_POPUP
|WS_VISIBLE
, 0, 0, 10, 10, 0, 0, 0, NULL
);
13455 while (PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA( &msg
);
13458 SetEvent( start_event
);
13460 hwnd
= CreateWindowExA(0, "TestClass", NULL
, WS_POPUP
|WS_VISIBLE
, 0, 0, 10, 10, 0, 0, 0, NULL
);
13461 while (PeekMessageA( &msg
, 0, 0, 0, PM_NOREMOVE
))
13463 GetMessageA( &msg
, 0, 0, 0 );
13464 DispatchMessageA( &msg
);
13468 SetEvent( start_event
);
13470 hwnd
= CreateWindowExA(0, "TestClass", NULL
, WS_POPUP
|WS_VISIBLE
, 0, 0, 10, 10, 0, 0, 0, NULL
);
13471 SetTimer( hwnd
, 3, 1, NULL
);
13473 while (PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
|PM_NOYIELD
)) DispatchMessageA( &msg
);
13476 SetEvent( start_event
);
13478 PeekMessageA( &msg
, 0, 0, 0, PM_NOREMOVE
);
13479 MsgWaitForMultipleObjects( 0, NULL
, FALSE
, 100, QS_ALLINPUT
);
13482 SetEvent( start_event
);
13484 hwnd
= CreateWindowExA(0, "TestClass", NULL
, WS_POPUP
|WS_VISIBLE
, 0, 0, 10, 10, 0, 0, 0, NULL
);
13485 while (PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA( &msg
);
13486 for (;;) GetMessageA( &msg
, 0, 0, 0 );
13489 SetEvent( start_event
);
13491 hwnd
= CreateWindowExA(0, "TestClass", NULL
, WS_POPUP
|WS_VISIBLE
, 0, 0, 10, 10, 0, 0, 0, NULL
);
13492 SetTimer( hwnd
, 3, 1, NULL
);
13494 while (PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA( &msg
);
13497 SetEvent( start_event
);
13499 return; /* exiting the process makes WaitForInputIdle return success too */
13501 PeekMessageA( &msg
, 0, 0, 0, PM_NOREMOVE
);
13503 MsgWaitForMultipleObjects( 0, NULL
, FALSE
, 100, QS_ALLINPUT
);
13504 SetEvent( start_event
);
13507 SetEvent( start_event
);
13508 PeekMessageA( &msg
, 0, 0, 0, PM_NOREMOVE
);
13510 thread
= CreateThread( NULL
, 0, do_wait_idle_child_thread
, NULL
, 0, &id
);
13511 WaitForSingleObject( thread
, 10000 );
13512 CloseHandle( thread
);
13515 SetEvent( start_event
);
13517 PeekMessageA( &msg
, HWND_TOPMOST
, 0, 0, PM_NOREMOVE
);
13520 SetEvent( start_event
);
13522 PeekMessageA( &msg
, HWND_BROADCAST
, 0, 0, PM_NOREMOVE
);
13525 SetEvent( start_event
);
13527 PeekMessageA( &msg
, HWND_BOTTOM
, 0, 0, PM_NOREMOVE
);
13530 SetEvent( start_event
);
13532 PeekMessageA( &msg
, (HWND
)0xdeadbeef, 0, 0, PM_NOREMOVE
);
13535 SetEvent( start_event
);
13537 PeekMessageA( &msg
, HWND_NOTOPMOST
, 0, 0, PM_NOREMOVE
);
13540 SetEvent( start_event
);
13542 PeekMessageA( &msg
, HWND_MESSAGE
, 0, 0, PM_NOREMOVE
);
13545 SetEvent( start_event
);
13547 PeekMessageA( &msg
, GetDesktopWindow(), 0, 0, PM_NOREMOVE
);
13550 WaitForSingleObject( end_event
, 2000 );
13551 CloseHandle( start_event
);
13552 CloseHandle( end_event
);
13553 if (hwnd
) DestroyWindow( hwnd
);
13556 static LRESULT CALLBACK
wait_idle_proc( HWND hwnd
, UINT msg
, WPARAM wp
, LPARAM lp
)
13558 if (msg
== WM_WININICHANGE
) Sleep( 200 ); /* make sure the child waits */
13559 return DefWindowProcA( hwnd
, msg
, wp
, lp
);
13562 static DWORD CALLBACK
wait_idle_thread( void *arg
)
13568 memset( &cls
, 0, sizeof(cls
) );
13569 cls
.lpfnWndProc
= wait_idle_proc
;
13570 cls
.hbrBackground
= (HBRUSH
)(COLOR_WINDOW
+ 1);
13571 cls
.hCursor
= LoadCursorA(0, (LPCSTR
)IDC_ARROW
);
13572 cls
.lpszClassName
= "TestClass";
13573 RegisterClassA( &cls
);
13575 hwnd
= CreateWindowExA(0, "TestClass", NULL
, WS_POPUP
, 0, 0, 10, 10, 0, 0, 0, NULL
);
13576 while (GetMessageA( &msg
, 0, 0, 0 )) DispatchMessageA( &msg
);
13577 DestroyWindow(hwnd
);
13581 static void test_WaitForInputIdle( char *argv0
)
13583 char path
[MAX_PATH
];
13584 PROCESS_INFORMATION pi
;
13585 STARTUPINFOA startup
;
13587 HANDLE start_event
, end_event
, thread
;
13590 const IMAGE_DOS_HEADER
*dos
= (const IMAGE_DOS_HEADER
*)GetModuleHandleA(0);
13591 const IMAGE_NT_HEADERS
*nt
= (const IMAGE_NT_HEADERS
*)((const char *)dos
+ dos
->e_lfanew
);
13592 BOOL console_app
= (nt
->OptionalHeader
.Subsystem
!= IMAGE_SUBSYSTEM_WINDOWS_GUI
);
13594 if (console_app
) /* build the test with -mwindows for better coverage */
13595 trace( "not built as a GUI app, WaitForInputIdle may not be fully tested\n" );
13597 start_event
= CreateEventA(NULL
, 0, 0, "test_WaitForInputIdle_start");
13598 end_event
= CreateEventA(NULL
, 0, 0, "test_WaitForInputIdle_end");
13599 ok(start_event
!= 0, "failed to create start event, error %u\n", GetLastError());
13600 ok(end_event
!= 0, "failed to create end event, error %u\n", GetLastError());
13602 memset( &startup
, 0, sizeof(startup
) );
13603 startup
.cb
= sizeof(startup
);
13604 startup
.dwFlags
= STARTF_USESHOWWINDOW
;
13605 startup
.wShowWindow
= SW_SHOWNORMAL
;
13607 thread
= CreateThread( NULL
, 0, wait_idle_thread
, NULL
, 0, &id
);
13609 for (i
= 0; i
< sizeof(wait_idle_expect
)/sizeof(wait_idle_expect
[0]); i
++)
13611 ResetEvent( start_event
);
13612 ResetEvent( end_event
);
13613 sprintf( path
, "%s msg %u", argv0
, i
);
13614 ret
= CreateProcessA( NULL
, path
, NULL
, NULL
, TRUE
, 0, NULL
, NULL
, &startup
, &pi
);
13615 ok( ret
, "CreateProcess '%s' failed err %u.\n", path
, GetLastError() );
13618 ret
= WaitForSingleObject( start_event
, 5000 );
13619 ok( ret
== WAIT_OBJECT_0
, "%u: WaitForSingleObject failed\n", i
);
13620 if (ret
== WAIT_OBJECT_0
)
13622 ret
= WaitForInputIdle( pi
.hProcess
, 1000 );
13623 if (ret
== WAIT_FAILED
)
13625 ret
== wait_idle_expect
[i
].exp
||
13626 broken(ret
== wait_idle_expect
[i
].broken
),
13627 "%u: WaitForInputIdle error %08x expected %08x\n",
13628 i
, ret
, wait_idle_expect
[i
].exp
);
13629 else if (wait_idle_expect
[i
].todo
)
13631 ok( ret
== wait_idle_expect
[i
].exp
|| broken(ret
== wait_idle_expect
[i
].broken
),
13632 "%u: WaitForInputIdle error %08x expected %08x\n",
13633 i
, ret
, wait_idle_expect
[i
].exp
);
13635 ok( ret
== wait_idle_expect
[i
].exp
|| broken(ret
== wait_idle_expect
[i
].broken
),
13636 "%u: WaitForInputIdle error %08x expected %08x\n",
13637 i
, ret
, wait_idle_expect
[i
].exp
);
13638 SetEvent( end_event
);
13639 WaitForSingleObject( pi
.hProcess
, 1000 ); /* give it a chance to exit on its own */
13641 TerminateProcess( pi
.hProcess
, 0 ); /* just in case */
13642 winetest_wait_child_process( pi
.hProcess
);
13643 ret
= WaitForInputIdle( pi
.hProcess
, 100 );
13644 ok( ret
== WAIT_FAILED
, "%u: WaitForInputIdle after exit error %08x\n", i
, ret
);
13645 CloseHandle( pi
.hProcess
);
13646 CloseHandle( pi
.hThread
);
13649 CloseHandle( start_event
);
13650 PostThreadMessageA( id
, WM_QUIT
, 0, 0 );
13651 WaitForSingleObject( thread
, 10000 );
13652 CloseHandle( thread
);
13655 static const struct message WmSetParentSeq_1
[] = {
13656 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
13657 { EVENT_OBJECT_PARENTCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
13658 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
},
13659 { WM_CHILDACTIVATE
, sent
},
13660 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOSIZE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
},
13661 { WM_MOVE
, sent
|defwinproc
|wparam
, 0 },
13662 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
13663 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
13667 static const struct message WmSetParentSeq_2
[] = {
13668 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
13669 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
13670 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
13671 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
13672 { HCBT_SETFOCUS
, hook
|optional
},
13673 { WM_NCACTIVATE
, sent
|wparam
|optional
, 0 },
13674 { WM_ACTIVATE
, sent
|wparam
|optional
, 0 },
13675 { WM_ACTIVATEAPP
, sent
|wparam
|optional
, 0 },
13676 { WM_KILLFOCUS
, sent
|wparam
, 0 },
13677 { EVENT_OBJECT_PARENTCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
13678 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
},
13679 { HCBT_ACTIVATE
, hook
|optional
},
13680 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
13681 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
13682 { WM_NCACTIVATE
, sent
|wparam
|optional
, 1 },
13683 { WM_ACTIVATE
, sent
|wparam
|optional
, 1 },
13684 { HCBT_SETFOCUS
, hook
|optional
},
13685 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
13686 { WM_SETFOCUS
, sent
|optional
|defwinproc
},
13687 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOREDRAW
|SWP_NOSIZE
|SWP_NOCLIENTSIZE
},
13688 { WM_MOVE
, sent
|defwinproc
|wparam
, 0 },
13689 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
13690 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
13691 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
13692 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
13693 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
13698 static void test_SetParent(void)
13700 HWND parent1
, parent2
, child
, popup
;
13703 parent1
= CreateWindowExA(0, "TestParentClass", NULL
, WS_OVERLAPPEDWINDOW
,
13704 100, 100, 200, 200, 0, 0, 0, NULL
);
13705 ok(parent1
!= 0, "Failed to create parent1 window\n");
13707 parent2
= CreateWindowExA(0, "TestParentClass", NULL
, WS_OVERLAPPEDWINDOW
,
13708 400, 100, 200, 200, 0, 0, 0, NULL
);
13709 ok(parent2
!= 0, "Failed to create parent2 window\n");
13711 /* WS_CHILD window */
13712 child
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_CHILD
| WS_VISIBLE
,
13713 10, 10, 150, 150, parent1
, 0, 0, NULL
);
13714 ok(child
!= 0, "Failed to create child window\n");
13716 GetWindowRect(parent1
, &rc
);
13717 trace("parent1 (%d,%d)-(%d,%d)\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
13718 GetWindowRect(child
, &rc_old
);
13719 MapWindowPoints(0, parent1
, (POINT
*)&rc_old
, 2);
13720 trace("child (%d,%d)-(%d,%d)\n", rc_old
.left
, rc_old
.top
, rc_old
.right
, rc_old
.bottom
);
13724 SetParent(child
, parent2
);
13726 ok_sequence(WmSetParentSeq_1
, "SetParent() visible WS_CHILD", TRUE
);
13728 ok(GetWindowLongA(child
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
13729 ok(!IsWindowVisible(child
), "IsWindowVisible() should return FALSE\n");
13731 GetWindowRect(parent2
, &rc
);
13732 trace("parent2 (%d,%d)-(%d,%d)\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
13733 GetWindowRect(child
, &rc
);
13734 MapWindowPoints(0, parent2
, (POINT
*)&rc
, 2);
13735 trace("child (%d,%d)-(%d,%d)\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
13737 ok(EqualRect(&rc_old
, &rc
), "rects do not match (%d,%d-%d,%d) / (%d,%d-%d,%d)\n",
13738 rc_old
.left
, rc_old
.top
, rc_old
.right
, rc_old
.bottom
,
13739 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
13741 /* WS_POPUP window */
13742 popup
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_POPUP
| WS_VISIBLE
,
13743 20, 20, 100, 100, 0, 0, 0, NULL
);
13744 ok(popup
!= 0, "Failed to create popup window\n");
13746 GetWindowRect(popup
, &rc_old
);
13747 trace("popup (%d,%d)-(%d,%d)\n", rc_old
.left
, rc_old
.top
, rc_old
.right
, rc_old
.bottom
);
13751 SetParent(popup
, child
);
13753 ok_sequence(WmSetParentSeq_2
, "SetParent() visible WS_POPUP", TRUE
);
13755 ok(GetWindowLongA(popup
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
13756 ok(!IsWindowVisible(popup
), "IsWindowVisible() should return FALSE\n");
13758 GetWindowRect(child
, &rc
);
13759 trace("parent2 (%d,%d)-(%d,%d)\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
13760 GetWindowRect(popup
, &rc
);
13761 MapWindowPoints(0, child
, (POINT
*)&rc
, 2);
13762 trace("popup (%d,%d)-(%d,%d)\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
13764 ok(EqualRect(&rc_old
, &rc
), "rects do not match (%d,%d-%d,%d) / (%d,%d-%d,%d)\n",
13765 rc_old
.left
, rc_old
.top
, rc_old
.right
, rc_old
.bottom
,
13766 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
13768 DestroyWindow(popup
);
13769 DestroyWindow(child
);
13770 DestroyWindow(parent1
);
13771 DestroyWindow(parent2
);
13776 static const struct message WmKeyReleaseOnly
[] = {
13777 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 0x41, 0x80000001 },
13778 { WM_KEYUP
, sent
|wparam
|lparam
, 0x41, 0x80000001 },
13781 static const struct message WmKeyPressNormal
[] = {
13782 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 0x41, 0x1 },
13783 { WM_KEYDOWN
, sent
|wparam
|lparam
, 0x41, 0x1 },
13786 static const struct message WmKeyPressRepeat
[] = {
13787 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 0x41, 0x40000001 },
13788 { WM_KEYDOWN
, sent
|wparam
|lparam
, 0x41, 0x40000001 },
13791 static const struct message WmKeyReleaseNormal
[] = {
13792 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 0x41, 0xc0000001 },
13793 { WM_KEYUP
, sent
|wparam
|lparam
, 0x41, 0xc0000001 },
13797 static void test_keyflags(void)
13801 BYTE keyboard_state
[256];
13804 test_window
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
13805 100, 100, 200, 200, 0, 0, 0, NULL
);
13810 /* keyup without a keydown */
13811 keybd_event(0x41, 0, KEYEVENTF_KEYUP
, 0);
13812 while (PeekMessageA(&msg
, NULL
, WM_KEYFIRST
, WM_KEYLAST
, PM_REMOVE
))
13813 DispatchMessageA(&msg
);
13814 ok_sequence(WmKeyReleaseOnly
, "key release only", TRUE
);
13816 key_state
= GetAsyncKeyState(0x41);
13817 ok((key_state
& 0x8000) == 0, "unexpected key state %x\n", key_state
);
13819 key_state
= GetKeyState(0x41);
13820 ok((key_state
& 0x8000) == 0, "unexpected key state %x\n", key_state
);
13823 keybd_event(0x41, 0, 0, 0);
13824 while (PeekMessageA(&msg
, NULL
, WM_KEYFIRST
, WM_KEYLAST
, PM_REMOVE
))
13825 DispatchMessageA(&msg
);
13826 ok_sequence(WmKeyPressNormal
, "key press only", FALSE
);
13828 key_state
= GetAsyncKeyState(0x41);
13829 ok((key_state
& 0x8000) == 0x8000, "unexpected key state %x\n", key_state
);
13831 key_state
= GetKeyState(0x41);
13832 ok((key_state
& 0x8000) == 0x8000, "unexpected key state %x\n", key_state
);
13834 /* keydown repeat */
13835 keybd_event(0x41, 0, 0, 0);
13836 while (PeekMessageA(&msg
, NULL
, WM_KEYFIRST
, WM_KEYLAST
, PM_REMOVE
))
13837 DispatchMessageA(&msg
);
13838 ok_sequence(WmKeyPressRepeat
, "key press repeat", FALSE
);
13840 key_state
= GetAsyncKeyState(0x41);
13841 ok((key_state
& 0x8000) == 0x8000, "unexpected key state %x\n", key_state
);
13843 key_state
= GetKeyState(0x41);
13844 ok((key_state
& 0x8000) == 0x8000, "unexpected key state %x\n", key_state
);
13847 keybd_event(0x41, 0, KEYEVENTF_KEYUP
, 0);
13848 while (PeekMessageA(&msg
, NULL
, WM_KEYFIRST
, WM_KEYLAST
, PM_REMOVE
))
13849 DispatchMessageA(&msg
);
13850 ok_sequence(WmKeyReleaseNormal
, "key release repeat", FALSE
);
13852 key_state
= GetAsyncKeyState(0x41);
13853 ok((key_state
& 0x8000) == 0, "unexpected key state %x\n", key_state
);
13855 key_state
= GetKeyState(0x41);
13856 ok((key_state
& 0x8000) == 0, "unexpected key state %x\n", key_state
);
13858 /* set the key state in this thread */
13859 GetKeyboardState(keyboard_state
);
13860 keyboard_state
[0x41] = 0x80;
13861 SetKeyboardState(keyboard_state
);
13863 key_state
= GetAsyncKeyState(0x41);
13864 ok((key_state
& 0x8000) == 0, "unexpected key state %x\n", key_state
);
13867 keybd_event(0x41, 0, 0, 0);
13868 while (PeekMessageA(&msg
, NULL
, WM_KEYFIRST
, WM_KEYLAST
, PM_REMOVE
))
13869 DispatchMessageA(&msg
);
13870 ok_sequence(WmKeyPressRepeat
, "key press after setkeyboardstate", TRUE
);
13872 key_state
= GetAsyncKeyState(0x41);
13873 ok((key_state
& 0x8000) == 0x8000, "unexpected key state %x\n", key_state
);
13875 key_state
= GetKeyState(0x41);
13876 ok((key_state
& 0x8000) == 0x8000, "unexpected key state %x\n", key_state
);
13878 /* clear the key state in this thread */
13879 GetKeyboardState(keyboard_state
);
13880 keyboard_state
[0x41] = 0;
13881 SetKeyboardState(keyboard_state
);
13883 key_state
= GetAsyncKeyState(0x41);
13884 ok((key_state
& 0x8000) == 0x8000, "unexpected key state %x\n", key_state
);
13887 keybd_event(0x41, 0, KEYEVENTF_KEYUP
, 0);
13888 while (PeekMessageA(&msg
, NULL
, WM_KEYFIRST
, WM_KEYLAST
, PM_REMOVE
))
13889 DispatchMessageA(&msg
);
13890 ok_sequence(WmKeyReleaseOnly
, "key release after setkeyboardstate", TRUE
);
13892 key_state
= GetAsyncKeyState(0x41);
13893 ok((key_state
& 0x8000) == 0, "unexpected key state %x\n", key_state
);
13895 key_state
= GetKeyState(0x41);
13896 ok((key_state
& 0x8000) == 0, "unexpected key state %x\n", key_state
);
13898 DestroyWindow(test_window
);
13902 static const struct message WmHotkeyPressLWIN
[] = {
13903 { WM_KEYDOWN
, kbd_hook
|wparam
|lparam
, VK_LWIN
, LLKHF_INJECTED
},
13904 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_LWIN
, 1 },
13905 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_LWIN
, 1 },
13908 static const struct message WmHotkeyPress
[] = {
13909 { WM_KEYDOWN
, kbd_hook
|lparam
, 0, LLKHF_INJECTED
},
13910 { WM_HOTKEY
, sent
|wparam
, 5 },
13913 static const struct message WmHotkeyRelease
[] = {
13914 { WM_KEYUP
, kbd_hook
|lparam
, 0, LLKHF_INJECTED
|LLKHF_UP
},
13915 { HCBT_KEYSKIPPED
, hook
|lparam
|optional
, 0, 0x80000001 },
13916 { WM_KEYUP
, sent
|lparam
, 0, 0x80000001 },
13919 static const struct message WmHotkeyReleaseLWIN
[] = {
13920 { WM_KEYUP
, kbd_hook
|wparam
|lparam
, VK_LWIN
, LLKHF_INJECTED
|LLKHF_UP
},
13921 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_LWIN
, 0xc0000001 },
13922 { WM_KEYUP
, sent
|wparam
|lparam
, VK_LWIN
, 0xc0000001 },
13925 static const struct message WmHotkeyCombined
[] = {
13926 { WM_KEYDOWN
, kbd_hook
|wparam
|lparam
, VK_LWIN
, LLKHF_INJECTED
},
13927 { WM_KEYDOWN
, kbd_hook
|lparam
, 0, LLKHF_INJECTED
},
13928 { WM_KEYUP
, kbd_hook
|lparam
, 0, LLKHF_INJECTED
|LLKHF_UP
},
13929 { WM_KEYUP
, kbd_hook
|wparam
|lparam
, VK_LWIN
, LLKHF_INJECTED
|LLKHF_UP
},
13930 { WM_APP
, sent
, 0, 0 },
13931 { WM_HOTKEY
, sent
|wparam
, 5 },
13932 { WM_APP
+1, sent
, 0, 0 },
13933 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_LWIN
, 1 },
13934 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_LWIN
, 1 },
13935 { HCBT_KEYSKIPPED
, hook
|optional
, 0, 0x80000001 },
13936 { WM_KEYUP
, sent
, 0, 0x80000001 }, /* lparam not checked so the sequence isn't a todo */
13937 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_LWIN
, 0xc0000001 },
13938 { WM_KEYUP
, sent
|wparam
|lparam
, VK_LWIN
, 0xc0000001 },
13941 static const struct message WmHotkeyPrevious
[] = {
13942 { WM_KEYDOWN
, kbd_hook
|wparam
|lparam
, VK_LWIN
, LLKHF_INJECTED
},
13943 { WM_KEYDOWN
, kbd_hook
|lparam
, 0, LLKHF_INJECTED
},
13944 { WM_KEYUP
, kbd_hook
|lparam
, 0, LLKHF_INJECTED
|LLKHF_UP
},
13945 { WM_KEYUP
, kbd_hook
|wparam
|lparam
, VK_LWIN
, LLKHF_INJECTED
|LLKHF_UP
},
13946 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_LWIN
, 1 },
13947 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_LWIN
, 1 },
13948 { HCBT_KEYSKIPPED
, hook
|lparam
|optional
, 0, 1 },
13949 { WM_KEYDOWN
, sent
|lparam
, 0, 1 },
13950 { HCBT_KEYSKIPPED
, hook
|optional
|lparam
, 0, 0xc0000001 },
13951 { WM_KEYUP
, sent
|lparam
, 0, 0xc0000001 },
13952 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_LWIN
, 0xc0000001 },
13953 { WM_KEYUP
, sent
|wparam
|lparam
, VK_LWIN
, 0xc0000001 },
13956 static const struct message WmHotkeyNew
[] = {
13957 { WM_KEYDOWN
, kbd_hook
|lparam
, 0, LLKHF_INJECTED
},
13958 { WM_KEYUP
, kbd_hook
|lparam
, 0, LLKHF_INJECTED
|LLKHF_UP
},
13959 { WM_HOTKEY
, sent
|wparam
, 5 },
13960 { HCBT_KEYSKIPPED
, hook
|optional
, 0, 0x80000001 },
13961 { WM_KEYUP
, sent
, 0, 0x80000001 }, /* lparam not checked so the sequence isn't a todo */
13965 static int hotkey_letter
;
13967 static LRESULT CALLBACK
KeyboardHookProc(int nCode
, WPARAM wParam
, LPARAM lParam
)
13969 struct recvd_message msg
;
13971 if (nCode
== HC_ACTION
)
13973 KBDLLHOOKSTRUCT
*kdbhookstruct
= (KBDLLHOOKSTRUCT
*)lParam
;
13976 msg
.message
= wParam
;
13977 msg
.flags
= kbd_hook
|wparam
|lparam
;
13978 msg
.wParam
= kdbhookstruct
->vkCode
;
13979 msg
.lParam
= kdbhookstruct
->flags
;
13980 msg
.descr
= "KeyboardHookProc";
13983 if (wParam
== WM_KEYUP
|| wParam
== WM_KEYDOWN
)
13985 ok(kdbhookstruct
->vkCode
== VK_LWIN
|| kdbhookstruct
->vkCode
== hotkey_letter
,
13986 "unexpected keycode %x\n", kdbhookstruct
->vkCode
);
13990 return CallNextHookEx(hKBD_hook
, nCode
, wParam
, lParam
);
13993 static void test_hotkey(void)
13995 HWND test_window
, taskbar_window
;
13998 DWORD queue_status
;
14001 SetLastError(0xdeadbeef);
14002 ret
= UnregisterHotKey(NULL
, 0);
14003 ok(ret
== FALSE
, "expected FALSE, got %i\n", ret
);
14004 ok(GetLastError() == ERROR_HOTKEY_NOT_REGISTERED
|| broken(GetLastError() == 0xdeadbeef),
14005 "unexpected error %d\n", GetLastError());
14009 skip("hotkeys not supported\n");
14013 test_window
= CreateWindowExA(0, "HotkeyWindowClass", NULL
, WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
14014 100, 100, 200, 200, 0, 0, 0, NULL
);
14018 SetLastError(0xdeadbeef);
14019 ret
= UnregisterHotKey(test_window
, 0);
14020 ok(ret
== FALSE
, "expected FALSE, got %i\n", ret
);
14021 ok(GetLastError() == ERROR_HOTKEY_NOT_REGISTERED
|| broken(GetLastError() == 0xdeadbeef),
14022 "unexpected error %d\n", GetLastError());
14024 /* Search for a Windows Key + letter combination that hasn't been registered */
14025 for (hotkey_letter
= 0x41; hotkey_letter
<= 0x51; hotkey_letter
++)
14027 SetLastError(0xdeadbeef);
14028 ret
= RegisterHotKey(test_window
, 5, MOD_WIN
, hotkey_letter
);
14036 ok(GetLastError() == ERROR_HOTKEY_ALREADY_REGISTERED
|| broken(GetLastError() == 0xdeadbeef),
14037 "unexpected error %d\n", GetLastError());
14041 if (hotkey_letter
== 0x52)
14043 ok(0, "Couldn't find any free Windows Key + letter combination\n");
14047 hKBD_hook
= SetWindowsHookExA(WH_KEYBOARD_LL
, KeyboardHookProc
, GetModuleHandleA(NULL
), 0);
14048 if (!hKBD_hook
) win_skip("WH_KEYBOARD_LL is not supported\n");
14050 /* Same key combination, different id */
14051 SetLastError(0xdeadbeef);
14052 ret
= RegisterHotKey(test_window
, 4, MOD_WIN
, hotkey_letter
);
14053 ok(ret
== FALSE
, "expected FALSE, got %i\n", ret
);
14054 ok(GetLastError() == ERROR_HOTKEY_ALREADY_REGISTERED
|| broken(GetLastError() == 0xdeadbeef),
14055 "unexpected error %d\n", GetLastError());
14057 /* Same key combination, different window */
14058 SetLastError(0xdeadbeef);
14059 ret
= RegisterHotKey(NULL
, 5, MOD_WIN
, hotkey_letter
);
14060 ok(ret
== FALSE
, "expected FALSE, got %i\n", ret
);
14061 ok(GetLastError() == ERROR_HOTKEY_ALREADY_REGISTERED
|| broken(GetLastError() == 0xdeadbeef),
14062 "unexpected error %d\n", GetLastError());
14064 /* Register the same hotkey twice */
14065 SetLastError(0xdeadbeef);
14066 ret
= RegisterHotKey(test_window
, 5, MOD_WIN
, hotkey_letter
);
14067 ok(ret
== FALSE
, "expected FALSE, got %i\n", ret
);
14068 ok(GetLastError() == ERROR_HOTKEY_ALREADY_REGISTERED
|| broken(GetLastError() == 0xdeadbeef),
14069 "unexpected error %d\n", GetLastError());
14071 /* Window on another thread */
14072 taskbar_window
= FindWindowA("Shell_TrayWnd", NULL
);
14073 if (!taskbar_window
)
14075 skip("no taskbar?\n");
14079 SetLastError(0xdeadbeef);
14080 ret
= RegisterHotKey(taskbar_window
, 5, 0, hotkey_letter
);
14081 ok(ret
== FALSE
, "expected FALSE, got %i\n", ret
);
14082 ok(GetLastError() == ERROR_WINDOW_OF_OTHER_THREAD
|| broken(GetLastError() == 0xdeadbeef),
14083 "unexpected error %d\n", GetLastError());
14086 /* Inject the appropriate key sequence */
14087 keybd_event(VK_LWIN
, 0, 0, 0);
14088 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
))
14089 DispatchMessageA(&msg
);
14090 ok_sequence(WmHotkeyPressLWIN
, "window hotkey press LWIN", FALSE
);
14092 keybd_event(hotkey_letter
, 0, 0, 0);
14093 queue_status
= GetQueueStatus(QS_HOTKEY
);
14094 ok((queue_status
& (QS_HOTKEY
<< 16)) == QS_HOTKEY
<< 16, "expected QS_HOTKEY << 16 set, got %x\n", queue_status
);
14095 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
))
14097 if (msg
.message
== WM_HOTKEY
)
14099 ok(msg
.hwnd
== test_window
, "unexpected hwnd %p\n", msg
.hwnd
);
14100 ok(msg
.lParam
== MAKELPARAM(MOD_WIN
, hotkey_letter
), "unexpected WM_HOTKEY lparam %lx\n", msg
.lParam
);
14102 DispatchMessageA(&msg
);
14104 ok_sequence(WmHotkeyPress
, "window hotkey press", FALSE
);
14106 queue_status
= GetQueueStatus(QS_HOTKEY
);
14107 ok((queue_status
& (QS_HOTKEY
<< 16)) == 0, "expected QS_HOTKEY << 16 cleared, got %x\n", queue_status
);
14109 key_state
= GetAsyncKeyState(hotkey_letter
);
14110 ok((key_state
& 0x8000) == 0x8000, "unexpected key state %x\n", key_state
);
14112 keybd_event(hotkey_letter
, 0, KEYEVENTF_KEYUP
, 0);
14113 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
))
14114 DispatchMessageA(&msg
);
14115 ok_sequence(WmHotkeyRelease
, "window hotkey release", TRUE
);
14117 keybd_event(VK_LWIN
, 0, KEYEVENTF_KEYUP
, 0);
14118 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
))
14119 DispatchMessageA(&msg
);
14120 ok_sequence(WmHotkeyReleaseLWIN
, "window hotkey release LWIN", FALSE
);
14122 /* normal posted WM_HOTKEY messages set QS_HOTKEY */
14123 PostMessageA(test_window
, WM_HOTKEY
, 0, 0);
14124 queue_status
= GetQueueStatus(QS_HOTKEY
);
14125 ok((queue_status
& (QS_HOTKEY
<< 16)) == QS_HOTKEY
<< 16, "expected QS_HOTKEY << 16 set, got %x\n", queue_status
);
14126 queue_status
= GetQueueStatus(QS_POSTMESSAGE
);
14127 ok((queue_status
& (QS_POSTMESSAGE
<< 16)) == QS_POSTMESSAGE
<< 16, "expected QS_POSTMESSAGE << 16 set, got %x\n", queue_status
);
14128 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
))
14129 DispatchMessageA(&msg
);
14132 /* Send and process all messages at once */
14133 PostMessageA(test_window
, WM_APP
, 0, 0);
14134 keybd_event(VK_LWIN
, 0, 0, 0);
14135 keybd_event(hotkey_letter
, 0, 0, 0);
14136 keybd_event(hotkey_letter
, 0, KEYEVENTF_KEYUP
, 0);
14137 keybd_event(VK_LWIN
, 0, KEYEVENTF_KEYUP
, 0);
14139 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
))
14141 if (msg
.message
== WM_HOTKEY
)
14143 ok(msg
.hwnd
== test_window
, "unexpected hwnd %p\n", msg
.hwnd
);
14144 ok(msg
.lParam
== MAKELPARAM(MOD_WIN
, hotkey_letter
), "unexpected WM_HOTKEY lparam %lx\n", msg
.lParam
);
14146 DispatchMessageA(&msg
);
14148 ok_sequence(WmHotkeyCombined
, "window hotkey combined", FALSE
);
14150 /* Register same hwnd/id with different key combination */
14151 ret
= RegisterHotKey(test_window
, 5, 0, hotkey_letter
);
14152 ok(ret
== TRUE
, "expected TRUE, got %i, err=%d\n", ret
, GetLastError());
14154 /* Previous key combination does not work */
14155 keybd_event(VK_LWIN
, 0, 0, 0);
14156 keybd_event(hotkey_letter
, 0, 0, 0);
14157 keybd_event(hotkey_letter
, 0, KEYEVENTF_KEYUP
, 0);
14158 keybd_event(VK_LWIN
, 0, KEYEVENTF_KEYUP
, 0);
14160 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
))
14161 DispatchMessageA(&msg
);
14162 ok_sequence(WmHotkeyPrevious
, "window hotkey previous", FALSE
);
14164 /* New key combination works */
14165 keybd_event(hotkey_letter
, 0, 0, 0);
14166 keybd_event(hotkey_letter
, 0, KEYEVENTF_KEYUP
, 0);
14168 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
))
14170 if (msg
.message
== WM_HOTKEY
)
14172 ok(msg
.hwnd
== test_window
, "unexpected hwnd %p\n", msg
.hwnd
);
14173 ok(msg
.lParam
== MAKELPARAM(0, hotkey_letter
), "unexpected WM_HOTKEY lparam %lx\n", msg
.lParam
);
14175 DispatchMessageA(&msg
);
14177 ok_sequence(WmHotkeyNew
, "window hotkey new", FALSE
);
14179 /* Unregister hotkey properly */
14180 ret
= UnregisterHotKey(test_window
, 5);
14181 ok(ret
== TRUE
, "expected TRUE, got %i, err=%d\n", ret
, GetLastError());
14183 /* Unregister hotkey again */
14184 SetLastError(0xdeadbeef);
14185 ret
= UnregisterHotKey(test_window
, 5);
14186 ok(ret
== FALSE
, "expected FALSE, got %i\n", ret
);
14187 ok(GetLastError() == ERROR_HOTKEY_NOT_REGISTERED
|| broken(GetLastError() == 0xdeadbeef),
14188 "unexpected error %d\n", GetLastError());
14190 /* Register thread hotkey */
14191 ret
= RegisterHotKey(NULL
, 5, MOD_WIN
, hotkey_letter
);
14192 ok(ret
== TRUE
, "expected TRUE, got %i, err=%d\n", ret
, GetLastError());
14194 /* Inject the appropriate key sequence */
14195 keybd_event(VK_LWIN
, 0, 0, 0);
14196 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
))
14198 ok(msg
.hwnd
!= NULL
, "unexpected thread message %x\n", msg
.message
);
14199 DispatchMessageA(&msg
);
14201 ok_sequence(WmHotkeyPressLWIN
, "thread hotkey press LWIN", FALSE
);
14203 keybd_event(hotkey_letter
, 0, 0, 0);
14204 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
))
14206 if (msg
.message
== WM_HOTKEY
)
14208 struct recvd_message message
;
14209 ok(msg
.hwnd
== NULL
, "unexpected hwnd %p\n", msg
.hwnd
);
14210 ok(msg
.lParam
== MAKELPARAM(MOD_WIN
, hotkey_letter
), "unexpected WM_HOTKEY lparam %lx\n", msg
.lParam
);
14211 message
.message
= msg
.message
;
14212 message
.flags
= sent
|wparam
|lparam
;
14213 message
.wParam
= msg
.wParam
;
14214 message
.lParam
= msg
.lParam
;
14215 message
.descr
= "test_hotkey thread message";
14216 add_message(&message
);
14219 ok(msg
.hwnd
!= NULL
, "unexpected thread message %x\n", msg
.message
);
14220 DispatchMessageA(&msg
);
14222 ok_sequence(WmHotkeyPress
, "thread hotkey press", FALSE
);
14224 keybd_event(hotkey_letter
, 0, KEYEVENTF_KEYUP
, 0);
14225 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
))
14227 ok(msg
.hwnd
!= NULL
, "unexpected thread message %x\n", msg
.message
);
14228 DispatchMessageA(&msg
);
14230 ok_sequence(WmHotkeyRelease
, "thread hotkey release", TRUE
);
14232 keybd_event(VK_LWIN
, 0, KEYEVENTF_KEYUP
, 0);
14233 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
))
14235 ok(msg
.hwnd
!= NULL
, "unexpected thread message %x\n", msg
.message
);
14236 DispatchMessageA(&msg
);
14238 ok_sequence(WmHotkeyReleaseLWIN
, "thread hotkey release LWIN", FALSE
);
14240 /* Unregister thread hotkey */
14241 ret
= UnregisterHotKey(NULL
, 5);
14242 ok(ret
== TRUE
, "expected TRUE, got %i, err=%d\n", ret
, GetLastError());
14244 if (hKBD_hook
) UnhookWindowsHookEx(hKBD_hook
);
14248 UnregisterHotKey(NULL
, 5);
14249 UnregisterHotKey(test_window
, 5);
14250 DestroyWindow(test_window
);
14255 static const struct message WmSetFocus_1
[] = {
14256 { HCBT_SETFOCUS
, hook
}, /* child */
14257 { HCBT_ACTIVATE
, hook
}, /* parent */
14258 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|parent
|optional
, 0, 0 },
14259 { WM_WINDOWPOSCHANGING
, sent
|parent
, 0, SWP_NOSIZE
|SWP_NOMOVE
},
14260 { WM_ACTIVATEAPP
, sent
|wparam
|parent
, 1 },
14261 { WM_NCACTIVATE
, sent
|parent
},
14262 { WM_GETTEXT
, sent
|defwinproc
|parent
|optional
},
14263 { WM_GETTEXT
, sent
|defwinproc
|parent
|optional
},
14264 { WM_ACTIVATE
, sent
|wparam
|parent
, 1 },
14265 { HCBT_SETFOCUS
, hook
}, /* parent */
14266 { WM_SETFOCUS
, sent
|defwinproc
|parent
},
14267 { WM_KILLFOCUS
, sent
|parent
},
14268 { WM_SETFOCUS
, sent
},
14271 static const struct message WmSetFocus_2
[] = {
14272 { HCBT_SETFOCUS
, hook
}, /* parent */
14273 { WM_KILLFOCUS
, sent
},
14274 { WM_SETFOCUS
, sent
|parent
},
14277 static const struct message WmSetFocus_3
[] = {
14278 { HCBT_SETFOCUS
, hook
}, /* child */
14282 static void test_SetFocus(void)
14284 HWND parent
, old_parent
, child
, old_focus
, old_active
;
14286 struct wnd_event wnd_event
;
14290 wnd_event
.start_event
= CreateEventW(NULL
, 0, 0, NULL
);
14291 ok(wnd_event
.start_event
!= 0, "CreateEvent error %d\n", GetLastError());
14292 hthread
= CreateThread(NULL
, 0, thread_proc
, &wnd_event
, 0, &tid
);
14293 ok(hthread
!= 0, "CreateThread error %d\n", GetLastError());
14294 ret
= WaitForSingleObject(wnd_event
.start_event
, INFINITE
);
14295 ok(ret
== WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
14296 CloseHandle(wnd_event
.start_event
);
14298 parent
= CreateWindowExA(0, "TestParentClass", NULL
, WS_OVERLAPPEDWINDOW
,
14299 0, 0, 0, 0, 0, 0, 0, NULL
);
14300 ok(parent
!= 0, "failed to create parent window\n");
14301 child
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_CHILD
,
14302 0, 0, 0, 0, parent
, 0, 0, NULL
);
14303 ok(child
!= 0, "failed to create child window\n");
14305 trace("parent %p, child %p, thread window %p\n", parent
, child
, wnd_event
.hwnd
);
14308 SetActiveWindow(0);
14313 ok(GetActiveWindow() == 0, "expected active 0, got %p\n", GetActiveWindow());
14314 ok(GetFocus() == 0, "expected focus 0, got %p\n", GetFocus());
14316 log_all_parent_messages
++;
14318 old_focus
= SetFocus(child
);
14319 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
14320 ok_sequence(WmSetFocus_1
, "SetFocus on a child window", TRUE
);
14321 ok(old_focus
== parent
, "expected old focus %p, got %p\n", parent
, old_focus
);
14322 ok(GetActiveWindow() == parent
, "expected active %p, got %p\n", parent
, GetActiveWindow());
14323 ok(GetFocus() == child
, "expected focus %p, got %p\n", child
, GetFocus());
14325 old_focus
= SetFocus(parent
);
14326 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
14327 ok_sequence(WmSetFocus_2
, "SetFocus on a parent window", FALSE
);
14328 ok(old_focus
== child
, "expected old focus %p, got %p\n", child
, old_focus
);
14329 ok(GetActiveWindow() == parent
, "expected active %p, got %p\n", parent
, GetActiveWindow());
14330 ok(GetFocus() == parent
, "expected focus %p, got %p\n", parent
, GetFocus());
14332 SetLastError(0xdeadbeef);
14333 old_focus
= SetFocus((HWND
)0xdeadbeef);
14334 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
|| broken(GetLastError() == 0xdeadbeef),
14335 "expected ERROR_INVALID_WINDOW_HANDLE, got %d\n", GetLastError());
14336 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
14337 ok_sequence(WmEmptySeq
, "SetFocus on an invalid window", FALSE
);
14338 ok(old_focus
== 0, "expected old focus 0, got %p\n", old_focus
);
14339 ok(GetActiveWindow() == parent
, "expected active %p, got %p\n", parent
, GetActiveWindow());
14340 ok(GetFocus() == parent
, "expected focus %p, got %p\n", parent
, GetFocus());
14342 SetLastError(0xdeadbeef);
14343 old_focus
= SetFocus(GetDesktopWindow());
14344 ok(GetLastError() == ERROR_ACCESS_DENIED
/* Vista+ */ ||
14345 broken(GetLastError() == 0xdeadbeef), "expected ERROR_ACCESS_DENIED, got %d\n", GetLastError());
14346 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
14347 ok_sequence(WmEmptySeq
, "SetFocus on a desktop window", TRUE
);
14348 ok(old_focus
== 0, "expected old focus 0, got %p\n", old_focus
);
14349 ok(GetActiveWindow() == parent
, "expected active %p, got %p\n", parent
, GetActiveWindow());
14350 ok(GetFocus() == parent
, "expected focus %p, got %p\n", parent
, GetFocus());
14352 SetLastError(0xdeadbeef);
14353 old_focus
= SetFocus(wnd_event
.hwnd
);
14354 ok(GetLastError() == ERROR_ACCESS_DENIED
/* Vista+ */ ||
14355 broken(GetLastError() == 0xdeadbeef), "expected ERROR_ACCESS_DENIED, got %d\n", GetLastError());
14356 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
14357 ok_sequence(WmEmptySeq
, "SetFocus on another thread window", TRUE
);
14358 ok(old_focus
== 0, "expected old focus 0, got %p\n", old_focus
);
14359 ok(GetActiveWindow() == parent
, "expected active %p, got %p\n", parent
, GetActiveWindow());
14360 ok(GetFocus() == parent
, "expected focus %p, got %p\n", parent
, GetFocus());
14362 SetLastError(0xdeadbeef);
14363 old_active
= SetActiveWindow((HWND
)0xdeadbeef);
14364 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
|| broken(GetLastError() == 0xdeadbeef),
14365 "expected ERROR_INVALID_WINDOW_HANDLE, got %d\n", GetLastError());
14366 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
14367 ok_sequence(WmEmptySeq
, "SetActiveWindow on an invalid window", FALSE
);
14368 ok(old_active
== 0, "expected old focus 0, got %p\n", old_active
);
14369 ok(GetActiveWindow() == parent
, "expected active %p, got %p\n", parent
, GetActiveWindow());
14370 ok(GetFocus() == parent
, "expected focus %p, got %p\n", parent
, GetFocus());
14372 SetLastError(0xdeadbeef);
14373 old_active
= SetActiveWindow(GetDesktopWindow());
14375 ok(GetLastError() == 0xdeadbeef, "expected 0xdeadbeef, got %d\n", GetLastError());
14376 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
14377 ok_sequence(WmEmptySeq
, "SetActiveWindow on a desktop window", TRUE
);
14378 ok(old_active
== 0, "expected old focus 0, got %p\n", old_focus
);
14379 ok(GetActiveWindow() == parent
, "expected active %p, got %p\n", parent
, GetActiveWindow());
14380 ok(GetFocus() == parent
, "expected focus %p, got %p\n", parent
, GetFocus());
14382 SetLastError(0xdeadbeef);
14383 old_active
= SetActiveWindow(wnd_event
.hwnd
);
14385 ok(GetLastError() == 0xdeadbeef, "expected 0xdeadbeef, got %d\n", GetLastError());
14386 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
14387 ok_sequence(WmEmptySeq
, "SetActiveWindow on another thread window", TRUE
);
14388 ok(old_active
== 0, "expected old focus 0, got %p\n", old_active
);
14389 ok(GetActiveWindow() == parent
, "expected active %p, got %p\n", parent
, GetActiveWindow());
14390 ok(GetFocus() == parent
, "expected focus %p, got %p\n", parent
, GetFocus());
14392 SetLastError(0xdeadbeef);
14393 ret
= AttachThreadInput(GetCurrentThreadId(), tid
, TRUE
);
14394 ok(ret
, "AttachThreadInput error %d\n", GetLastError());
14396 ok(GetActiveWindow() == parent
, "expected active %p, got %p\n", parent
, GetActiveWindow());
14397 ok(GetFocus() == parent
, "expected focus %p, got %p\n", parent
, GetFocus());
14402 old_focus
= SetFocus(wnd_event
.hwnd
);
14403 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
14404 ok(old_focus
== wnd_event
.hwnd
, "expected old focus %p, got %p\n", wnd_event
.hwnd
, old_focus
);
14405 ok(GetActiveWindow() == wnd_event
.hwnd
, "expected active %p, got %p\n", wnd_event
.hwnd
, GetActiveWindow());
14406 ok(GetFocus() == wnd_event
.hwnd
, "expected focus %p, got %p\n", wnd_event
.hwnd
, GetFocus());
14408 old_focus
= SetFocus(parent
);
14409 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
14410 ok(old_focus
== parent
, "expected old focus %p, got %p\n", parent
, old_focus
);
14411 ok(GetActiveWindow() == parent
, "expected active %p, got %p\n", parent
, GetActiveWindow());
14412 ok(GetFocus() == parent
, "expected focus %p, got %p\n", parent
, GetFocus());
14417 old_active
= SetActiveWindow(wnd_event
.hwnd
);
14418 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
14419 ok(old_active
== parent
, "expected old focus %p, got %p\n", parent
, old_active
);
14420 ok(GetActiveWindow() == wnd_event
.hwnd
, "expected active %p, got %p\n", wnd_event
.hwnd
, GetActiveWindow());
14421 ok(GetFocus() == wnd_event
.hwnd
, "expected focus %p, got %p\n", wnd_event
.hwnd
, GetFocus());
14423 SetLastError(0xdeadbeef);
14424 ret
= AttachThreadInput(GetCurrentThreadId(), tid
, FALSE
);
14425 ok(ret
, "AttachThreadInput error %d\n", GetLastError());
14427 ok(GetActiveWindow() == 0, "expected active 0, got %p\n", GetActiveWindow());
14428 ok(GetFocus() == 0, "expected focus 0, got %p\n", GetFocus());
14430 old_parent
= SetParent(child
, GetDesktopWindow());
14431 ok(old_parent
== parent
, "expected old parent %p, got %p\n", parent
, old_parent
);
14433 ok(GetActiveWindow() == 0, "expected active 0, got %p\n", GetActiveWindow());
14434 ok(GetFocus() == 0, "expected focus 0, got %p\n", GetFocus());
14436 old_focus
= SetFocus(parent
);
14437 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
14438 ok(old_focus
== parent
, "expected old focus %p, got %p\n", parent
, old_focus
);
14439 ok(GetActiveWindow() == parent
, "expected active %p, got %p\n", parent
, GetActiveWindow());
14440 ok(GetFocus() == parent
, "expected focus %p, got %p\n", parent
, GetFocus());
14445 SetLastError(0xdeadbeef);
14446 old_focus
= SetFocus(child
);
14448 ok(GetLastError() == ERROR_INVALID_PARAMETER
/* Vista+ */ ||
14449 broken(GetLastError() == 0) /* XP */ ||
14450 broken(GetLastError() == 0xdeadbeef), "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
14451 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
14452 ok_sequence(WmSetFocus_3
, "SetFocus on a child window", TRUE
);
14453 ok(old_focus
== 0, "expected old focus 0, got %p\n", old_focus
);
14454 ok(GetActiveWindow() == parent
, "expected active %p, got %p\n", parent
, GetActiveWindow());
14455 ok(GetFocus() == parent
, "expected focus %p, got %p\n", parent
, GetFocus());
14457 SetLastError(0xdeadbeef);
14458 old_active
= SetActiveWindow(child
);
14459 ok(GetLastError() == 0xdeadbeef, "expected 0xdeadbeef, got %d\n", GetLastError());
14460 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
14461 ok_sequence(WmEmptySeq
, "SetActiveWindow on a child window", FALSE
);
14462 ok(old_active
== parent
, "expected old active %p, got %p\n", parent
, old_active
);
14463 ok(GetActiveWindow() == parent
, "expected active %p, got %p\n", parent
, GetActiveWindow());
14464 ok(GetFocus() == parent
, "expected focus %p, got %p\n", parent
, GetFocus());
14466 log_all_parent_messages
--;
14468 DestroyWindow(child
);
14469 DestroyWindow(parent
);
14471 ret
= PostMessageA(wnd_event
.hwnd
, WM_QUIT
, 0, 0);
14472 ok(ret
, "PostMessage(WM_QUIT) error %d\n", GetLastError());
14473 ret
= WaitForSingleObject(hthread
, INFINITE
);
14474 ok(ret
== WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
14475 CloseHandle(hthread
);
14478 static const struct message WmSetLayeredStyle
[] = {
14479 { WM_STYLECHANGING
, sent
},
14480 { WM_STYLECHANGED
, sent
},
14481 { WM_GETTEXT
, sent
|defwinproc
|optional
},
14485 static const struct message WmSetLayeredStyle2
[] = {
14486 { WM_STYLECHANGING
, sent
},
14487 { WM_STYLECHANGED
, sent
},
14488 { WM_WINDOWPOSCHANGING
, sent
|optional
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
14489 { WM_NCCALCSIZE
, sent
|optional
|wparam
|defwinproc
, 1 },
14490 { WM_WINDOWPOSCHANGED
, sent
|optional
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
14491 { WM_MOVE
, sent
|optional
|defwinproc
|wparam
, 0 },
14492 { WM_SIZE
, sent
|optional
|defwinproc
|wparam
, SIZE_RESTORED
},
14496 struct layered_window_info
14505 static DWORD CALLBACK
update_layered_proc( void *param
)
14507 struct layered_window_info
*info
= param
;
14508 POINT src
= { 0, 0 };
14510 info
->ret
= pUpdateLayeredWindow( info
->hwnd
, 0, NULL
, &info
->size
,
14511 info
->hdc
, &src
, 0, NULL
, ULW_OPAQUE
);
14512 ok( info
->ret
, "failed\n");
14513 SetEvent( info
->event
);
14517 static void test_layered_window(void)
14528 struct layered_window_info info
;
14530 if (!pUpdateLayeredWindow
)
14532 win_skip( "UpdateLayeredWindow not supported\n" );
14536 hdc
= CreateCompatibleDC( 0 );
14537 bmp
= CreateCompatibleBitmap( hdc
, 300, 300 );
14538 SelectObject( hdc
, bmp
);
14540 hwnd
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_CAPTION
| WS_THICKFRAME
| WS_SYSMENU
,
14541 100, 100, 300, 300, 0, 0, 0, NULL
);
14542 ok( hwnd
!= 0, "failed to create window\n" );
14543 ShowWindow( hwnd
, SW_SHOWNORMAL
);
14544 UpdateWindow( hwnd
);
14548 GetWindowRect( hwnd
, &rect
);
14549 GetClientRect( hwnd
, &client
);
14550 ok( client
.right
< rect
.right
- rect
.left
, "wrong client area\n" );
14551 ok( client
.bottom
< rect
.bottom
- rect
.top
, "wrong client area\n" );
14554 pos
.x
= pos
.y
= 300;
14555 size
.cx
= size
.cy
= 250;
14556 ret
= pUpdateLayeredWindow( hwnd
, 0, &pos
, &size
, hdc
, &src
, 0, NULL
, ULW_OPAQUE
);
14557 ok( !ret
, "UpdateLayeredWindow should fail on non-layered window\n" );
14558 ok( GetLastError() == ERROR_INVALID_PARAMETER
, "wrong error %u\n", GetLastError() );
14559 SetWindowLongA( hwnd
, GWL_EXSTYLE
, GetWindowLongA(hwnd
, GWL_EXSTYLE
) | WS_EX_LAYERED
);
14560 ok_sequence( WmSetLayeredStyle
, "WmSetLayeredStyle", FALSE
);
14562 ret
= pUpdateLayeredWindow( hwnd
, 0, &pos
, &size
, hdc
, &src
, 0, NULL
, ULW_OPAQUE
);
14563 ok( ret
, "UpdateLayeredWindow failed err %u\n", GetLastError() );
14564 ok_sequence( WmEmptySeq
, "UpdateLayeredWindow", FALSE
);
14565 GetWindowRect( hwnd
, &rect
);
14566 ok( rect
.left
== 300 && rect
.top
== 300 && rect
.right
== 550 && rect
.bottom
== 550,
14567 "wrong window rect %d,%d,%d,%d\n", rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
14568 GetClientRect( hwnd
, &rect
);
14569 ok( rect
.right
== client
.right
- 50 && rect
.bottom
== client
.bottom
- 50,
14570 "wrong client rect %d,%d,%d,%d\n", rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
14574 ret
= pUpdateLayeredWindow( hwnd
, 0, &pos
, &size
, hdc
, &src
, 0, NULL
, ULW_OPAQUE
);
14575 ok( ret
, "UpdateLayeredWindow failed err %u\n", GetLastError() );
14576 ok_sequence( WmEmptySeq
, "UpdateLayeredWindow", FALSE
);
14577 GetWindowRect( hwnd
, &rect
);
14578 ok( rect
.left
== 300 && rect
.top
== 200 && rect
.right
== 450 && rect
.bottom
== 450,
14579 "wrong window rect %d,%d,%d,%d\n", rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
14580 GetClientRect( hwnd
, &rect
);
14581 ok( rect
.right
== client
.right
- 150 && rect
.bottom
== client
.bottom
- 50,
14582 "wrong client rect %d,%d,%d,%d\n", rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
14584 SetWindowLongA( hwnd
, GWL_STYLE
,
14585 GetWindowLongA(hwnd
, GWL_STYLE
) & ~(WS_CAPTION
| WS_THICKFRAME
| WS_SYSMENU
) );
14586 ok_sequence( WmSetLayeredStyle2
, "WmSetLayeredStyle2", FALSE
);
14590 ret
= pUpdateLayeredWindow( hwnd
, 0, &pos
, &size
, hdc
, &src
, 0, NULL
, ULW_OPAQUE
);
14591 ok( ret
, "UpdateLayeredWindow failed err %u\n", GetLastError() );
14592 ok_sequence( WmEmptySeq
, "UpdateLayeredWindow", FALSE
);
14593 GetWindowRect( hwnd
, &rect
);
14594 ok( rect
.left
== 200 && rect
.top
== 200 && rect
.right
== 400 && rect
.bottom
== 450,
14595 "wrong window rect %d,%d,%d,%d\n", rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
14596 GetClientRect( hwnd
, &rect
);
14597 ok( (rect
.right
== 200 && rect
.bottom
== 250) ||
14598 broken(rect
.right
== client
.right
- 100 && rect
.bottom
== client
.bottom
- 50),
14599 "wrong client rect %d,%d,%d,%d\n", rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
14602 ret
= pUpdateLayeredWindow( hwnd
, 0, &pos
, &size
, hdc
, &src
, 0, NULL
, ULW_OPAQUE
);
14603 ok( !ret
, "UpdateLayeredWindow should fail on non-layered window\n" );
14604 ok( GetLastError() == ERROR_INVALID_PARAMETER
|| broken(ERROR_MR_MID_NOT_FOUND
) /* win7 */,
14605 "wrong error %u\n", GetLastError() );
14608 ret
= pUpdateLayeredWindow( hwnd
, 0, &pos
, &size
, hdc
, &src
, 0, NULL
, ULW_OPAQUE
);
14609 ok( !ret
, "UpdateLayeredWindow should fail on non-layered window\n" );
14610 ok( GetLastError() == ERROR_INVALID_PARAMETER
, "wrong error %u\n", GetLastError() );
14612 SetWindowLongA( hwnd
, GWL_EXSTYLE
, GetWindowLongA(hwnd
, GWL_EXSTYLE
) & ~WS_EX_LAYERED
);
14613 ok_sequence( WmSetLayeredStyle
, "WmSetLayeredStyle", FALSE
);
14614 GetWindowRect( hwnd
, &rect
);
14615 ok( rect
.left
== 200 && rect
.top
== 200 && rect
.right
== 400 && rect
.bottom
== 450,
14616 "wrong window rect %d,%d,%d,%d\n", rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
14617 GetClientRect( hwnd
, &rect
);
14618 ok( (rect
.right
== 200 && rect
.bottom
== 250) ||
14619 broken(rect
.right
== client
.right
- 100 && rect
.bottom
== client
.bottom
- 50),
14620 "wrong client rect %d,%d,%d,%d\n", rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
14622 SetWindowLongA( hwnd
, GWL_EXSTYLE
, GetWindowLongA(hwnd
, GWL_EXSTYLE
) | WS_EX_LAYERED
);
14625 info
.size
.cx
= 250;
14626 info
.size
.cy
= 300;
14627 info
.event
= CreateEventA( NULL
, TRUE
, FALSE
, NULL
);
14629 thread
= CreateThread( NULL
, 0, update_layered_proc
, &info
, 0, &tid
);
14630 ok( WaitForSingleObject( info
.event
, 1000 ) == 0, "wait failed\n" );
14631 ok( info
.ret
, "UpdateLayeredWindow failed in other thread\n" );
14632 WaitForSingleObject( thread
, 1000 );
14633 CloseHandle( thread
);
14634 GetWindowRect( hwnd
, &rect
);
14635 ok( rect
.left
== 200 && rect
.top
== 200 && rect
.right
== 450 && rect
.bottom
== 500,
14636 "wrong window rect %d,%d,%d,%d\n", rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
14637 GetClientRect( hwnd
, &rect
);
14638 ok( (rect
.right
== 250 && rect
.bottom
== 300) ||
14639 broken(rect
.right
== client
.right
- 50 && rect
.bottom
== client
.bottom
),
14640 "wrong client rect %d,%d,%d,%d\n", rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
14642 DestroyWindow( hwnd
);
14644 DeleteObject( bmp
);
14647 static HMENU hpopupmenu
;
14649 static LRESULT WINAPI
cancel_popup_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
14651 if (ignore_message( message
)) return 0;
14655 todo_wine
ok(GetCapture() == hwnd
, "expected %p, got %p\n", hwnd
, GetCapture());
14659 case WM_INITMENUPOPUP
:
14660 case WM_UNINITMENUPOPUP
:
14661 ok((HMENU
)wParam
== hpopupmenu
, "expected %p, got %lx\n", hpopupmenu
, wParam
);
14663 case WM_CAPTURECHANGED
:
14664 todo_wine
ok(!lParam
|| (HWND
)lParam
== hwnd
, "lost capture to %lx\n", lParam
);
14668 return MsgCheckProc (FALSE
, hwnd
, message
, wParam
, lParam
);
14671 static LRESULT WINAPI
cancel_init_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
14673 if (ignore_message( message
)) return 0;
14676 case WM_ENTERMENULOOP
:
14677 ok(EndMenu() == TRUE
, "EndMenu() failed\n");
14681 return MsgCheckProc (FALSE
, hwnd
, message
, wParam
, lParam
);
14684 static void test_TrackPopupMenu(void)
14689 hwnd
= CreateWindowExA(0, "TestWindowClass", NULL
, 0,
14692 ok(hwnd
!= NULL
, "CreateWindowEx failed with error %d\n", GetLastError());
14694 SetWindowLongPtrA( hwnd
, GWLP_WNDPROC
, (LONG_PTR
)cancel_popup_proc
);
14696 hpopupmenu
= CreatePopupMenu();
14697 ok(hpopupmenu
!= NULL
, "CreateMenu failed with error %d\n", GetLastError());
14699 AppendMenuA(hpopupmenu
, MF_STRING
, 100, "item 1");
14700 AppendMenuA(hpopupmenu
, MF_STRING
, 100, "item 2");
14704 ret
= TrackPopupMenu(hpopupmenu
, 0, 100,100, 0, hwnd
, NULL
);
14705 ok_sequence(WmTrackPopupMenu
, "TrackPopupMenu", TRUE
);
14706 ok(ret
== 1, "TrackPopupMenu failed with error %i\n", GetLastError());
14708 SetWindowLongPtrA( hwnd
, GWLP_WNDPROC
, (LONG_PTR
)cancel_init_proc
);
14712 ret
= TrackPopupMenu(hpopupmenu
, 0, 100,100, 0, hwnd
, NULL
);
14713 ok_sequence(WmTrackPopupMenuAbort
, "WmTrackPopupMenuAbort", TRUE
);
14714 ok(ret
== TRUE
, "TrackPopupMenu failed\n");
14716 SetWindowLongPtrA( hwnd
, GWLP_WNDPROC
, (LONG_PTR
)cancel_popup_proc
);
14722 ret
= TrackPopupMenu(hpopupmenu
, 0, 100,100, 0, hwnd
, NULL
);
14723 ok_sequence(WmTrackPopupMenuCapture
, "TrackPopupMenuCapture", TRUE
);
14724 ok(ret
== 1, "TrackPopupMenuCapture failed with error %i\n", GetLastError());
14726 DestroyMenu(hpopupmenu
);
14727 DestroyWindow(hwnd
);
14730 static void test_TrackPopupMenuEmpty(void)
14735 hwnd
= CreateWindowExA(0, "TestWindowClass", NULL
, 0,
14738 ok(hwnd
!= NULL
, "CreateWindowEx failed with error %d\n", GetLastError());
14740 SetWindowLongPtrA( hwnd
, GWLP_WNDPROC
, (LONG_PTR
)cancel_popup_proc
);
14742 hpopupmenu
= CreatePopupMenu();
14743 ok(hpopupmenu
!= NULL
, "CreateMenu failed with error %d\n", GetLastError());
14747 ret
= TrackPopupMenu(hpopupmenu
, 0, 100,100, 0, hwnd
, NULL
);
14748 ok_sequence(WmTrackPopupMenuEmpty
, "TrackPopupMenuEmpty", TRUE
);
14749 todo_wine
ok(ret
== 0, "TrackPopupMenu succeeded\n");
14751 DestroyMenu(hpopupmenu
);
14752 DestroyWindow(hwnd
);
14755 static const struct message send_message_1
[] = {
14756 { WM_USER
+2, sent
|wparam
|lparam
, 0, 0 },
14757 { WM_USER
, sent
|wparam
|lparam
, 0, 0 },
14760 static const struct message send_message_2
[] = {
14761 { WM_USER
+4, sent
|wparam
|lparam
, 0, 0 },
14764 static const struct message send_message_3
[] = {
14765 { WM_USER
+3, sent
|wparam
|lparam
, 0, 0 },
14768 static const struct message send_message_4
[] = {
14769 { WM_USER
+1, sent
|wparam
|lparam
, 0, 0 },
14773 static DWORD WINAPI
SendMessage_thread_1(void *param
)
14775 struct wnd_event
*wnd_event
= param
;
14777 trace("thread: starting\n");
14778 WaitForSingleObject(wnd_event
->start_event
, INFINITE
);
14780 trace("thread: call PostMessage\n");
14781 PostMessageA(wnd_event
->hwnd
, WM_USER
, 0, 0);
14783 trace("thread: call PostMessage\n");
14784 PostMessageA(wnd_event
->hwnd
, WM_USER
+1, 0, 0);
14786 trace("thread: call SendMessage\n");
14787 SendMessageA(wnd_event
->hwnd
, WM_USER
+2, 0, 0);
14789 trace("thread: call SendMessage\n");
14790 SendMessageA(wnd_event
->hwnd
, WM_USER
+3, 0, 0);
14795 static DWORD WINAPI
SendMessage_thread_2(void *param
)
14797 struct wnd_event
*wnd_event
= param
;
14799 trace("thread: starting\n");
14800 WaitForSingleObject(wnd_event
->start_event
, INFINITE
);
14802 trace("thread: call PostMessage\n");
14803 PostMessageA(wnd_event
->hwnd
, WM_USER
, 0, 0);
14805 trace("thread: call PostMessage\n");
14806 PostMessageA(wnd_event
->hwnd
, WM_USER
+1, 0, 0);
14808 /* this leads to sending an internal message under Wine */
14809 trace("thread: call EnableWindow\n");
14810 EnableWindow(wnd_event
->hwnd
, TRUE
);
14812 trace("thread: call SendMessage\n");
14813 SendMessageA(wnd_event
->hwnd
, WM_USER
+2, 0, 0);
14815 trace("thread: call SendMessage\n");
14816 SendMessageA(wnd_event
->hwnd
, WM_USER
+3, 0, 0);
14821 static void test_SendMessage_other_thread(int thread_n
)
14823 DWORD qs_all_input
= QS_ALLINPUT
& ~QS_RAWINPUT
;
14825 struct wnd_event wnd_event
;
14829 wnd_event
.start_event
= CreateEventA(NULL
, 0, 0, NULL
);
14831 wnd_event
.hwnd
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
14832 100, 100, 200, 200, 0, 0, 0, NULL
);
14833 ok(wnd_event
.hwnd
!= 0, "CreateWindowEx failed\n");
14835 hthread
= CreateThread(NULL
, 0, thread_n
== 1 ? SendMessage_thread_1
: SendMessage_thread_2
, &wnd_event
, 0, &tid
);
14836 ok(hthread
!= NULL
, "CreateThread failed, error %d\n", GetLastError());
14837 CloseHandle(hthread
);
14842 ret
= GetQueueStatus(QS_SENDMESSAGE
);
14843 ok(ret
== 0, "wrong status %08x\n", ret
);
14845 SetEvent(wnd_event
.start_event
);
14847 /* wait for other thread's SendMessage */
14850 ret
= GetQueueStatus(QS_SENDMESSAGE
);
14851 if (ret
== MAKELONG(QS_SENDMESSAGE
, QS_SENDMESSAGE
)) break;
14855 ret
= GetQueueStatus(QS_SENDMESSAGE
|QS_POSTMESSAGE
);
14856 ok(ret
== MAKELONG(QS_POSTMESSAGE
, QS_SENDMESSAGE
|QS_POSTMESSAGE
), "wrong status %08x\n", ret
);
14858 trace("main: call GetMessage\n");
14859 GetMessageA(&msg
, 0, 0, 0);
14860 ok(msg
.message
== WM_USER
, "expected WM_USER, got %04x\n", msg
.message
);
14861 DispatchMessageA(&msg
);
14862 ok_sequence(send_message_1
, "SendMessage from other thread 1", thread_n
== 2);
14864 /* intentionally yield */
14865 MsgWaitForMultipleObjects(0, NULL
, FALSE
, 100, qs_all_input
);
14867 trace("main: call SendMessage\n");
14868 SendMessageA(wnd_event
.hwnd
, WM_USER
+4, 0, 0);
14869 ok_sequence(send_message_2
, "SendMessage from other thread 2", FALSE
);
14871 ret
= GetQueueStatus(QS_SENDMESSAGE
|QS_POSTMESSAGE
);
14872 ok(ret
== MAKELONG(QS_SENDMESSAGE
, QS_SENDMESSAGE
|QS_POSTMESSAGE
), "wrong status %08x\n", ret
);
14874 trace("main: call PeekMessage\n");
14875 ok(PeekMessageA(&msg
, 0, 0, 0, PM_NOREMOVE
), "PeekMessage should not fail\n");
14876 ok(msg
.message
== WM_USER
+1, "expected WM_USER+1, got %04x\n", msg
.message
);
14877 ok_sequence(send_message_3
, "SendMessage from other thread 3", thread_n
== 2);
14879 trace("main: call PeekMessage\n");
14880 ok(PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
), "PeekMessage should not fail\n");
14881 ok(msg
.message
== WM_USER
+1, "expected WM_USER+1, got %04x\n", msg
.message
);
14882 DispatchMessageA(&msg
);
14883 ok_sequence(send_message_4
, "SendMessage from other thread 4", FALSE
);
14885 /* intentionally yield */
14886 MsgWaitForMultipleObjects(0, NULL
, FALSE
, 100, qs_all_input
);
14888 ret
= GetQueueStatus(QS_SENDMESSAGE
|QS_POSTMESSAGE
);
14889 /* FIXME: remove once Wine is fixed */
14890 if (thread_n
== 2) todo_wine
14891 ok(ret
== 0, "wrong status %08x\n", ret
);
14893 ok(ret
== 0, "wrong status %08x\n", ret
);
14895 trace("main: call PeekMessage\n");
14896 ok(!PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
), "PeekMessage should fail\n");
14897 ok_sequence(WmEmptySeq
, "SendMessage from other thread 5", thread_n
== 2);
14899 ret
= GetQueueStatus(QS_SENDMESSAGE
|QS_POSTMESSAGE
);
14900 ok(ret
== 0, "wrong status %08x\n", ret
);
14902 trace("main: call DestroyWindow\n");
14903 DestroyWindow(msg
.hwnd
);
14909 static void init_funcs(void)
14911 HMODULE hKernel32
= GetModuleHandleA("kernel32.dll");
14913 #define X(f) p##f = (void*)GetProcAddress(hKernel32, #f)
14916 X(DeactivateActCtx
);
14917 X(GetCurrentActCtx
);
14926 BOOL (WINAPI
*pIsWinEventHookInstalled
)(DWORD
)= 0;/*GetProcAddress(user32, "IsWinEventHookInstalled");*/
14927 HMODULE hModuleImm32
;
14928 BOOL (WINAPI
*pImmDisableIME
)(DWORD
);
14933 argc
= winetest_get_mainargs( &test_argv
);
14937 /* Child process. */
14938 sscanf (test_argv
[2], "%d", (unsigned int *) &arg
);
14939 do_wait_idle_child( arg
);
14943 InitializeCriticalSection( &sequence_cs
);
14946 hModuleImm32
= LoadLibraryA("imm32.dll");
14947 if (hModuleImm32
) {
14948 pImmDisableIME
= (void *)GetProcAddress(hModuleImm32
, "ImmDisableIME");
14949 if (pImmDisableIME
)
14952 pImmDisableIME
= NULL
;
14953 FreeLibrary(hModuleImm32
);
14955 if (!RegisterWindowClasses()) assert(0);
14957 if (pSetWinEventHook
)
14959 hEvent_hook
= pSetWinEventHook(EVENT_MIN
, EVENT_MAX
,
14960 GetModuleHandleA(0), win_event_proc
,
14961 0, GetCurrentThreadId(),
14962 WINEVENT_INCONTEXT
);
14963 if (pIsWinEventHookInstalled
&& hEvent_hook
)
14966 for (event
= EVENT_MIN
; event
<= EVENT_MAX
; event
++)
14967 ok(pIsWinEventHookInstalled(event
), "IsWinEventHookInstalled(%u) failed\n", event
);
14970 if (!hEvent_hook
) win_skip( "no win event hook support\n" );
14972 cbt_hook_thread_id
= GetCurrentThreadId();
14973 hCBT_hook
= SetWindowsHookExA(WH_CBT
, cbt_hook_proc
, 0, GetCurrentThreadId());
14974 if (!hCBT_hook
) win_skip( "cannot set global hook, will skip hook tests\n" );
14978 /* Fix message sequences before removing 4 lines below */
14979 if (pUnhookWinEvent
&& hEvent_hook
)
14981 ret
= pUnhookWinEvent(hEvent_hook
);
14982 ok( ret
, "UnhookWinEvent error %d\n", GetLastError());
14983 pUnhookWinEvent
= 0;
14987 test_SendMessage_other_thread(1);
14988 test_SendMessage_other_thread(2);
14991 test_PostMessage();
14993 test_PeekMessage();
14994 test_PeekMessage2();
14995 test_PeekMessage3();
14996 test_WaitForInputIdle( test_argv
[0] );
14997 test_scrollwindowex();
14999 test_setwindowpos();
15001 invisible_parent_tests();
15002 test_mdi_messages();
15003 test_button_messages();
15004 test_static_messages();
15005 test_listbox_messages();
15006 test_combobox_messages();
15007 test_wmime_keydown_message();
15008 test_paint_messages();
15009 test_interthread_messages();
15010 test_message_conversion();
15011 test_accelerators();
15013 test_timers_no_wnd();
15014 test_timers_exceptions();
15018 test_recursive_hook();
15020 test_DestroyWindow();
15021 test_DispatchMessage();
15022 test_SendMessageTimeout();
15023 test_edit_messages();
15024 test_quit_message();
15025 test_SetActiveWindow();
15027 if (!pTrackMouseEvent
)
15028 win_skip("TrackMouseEvent is not available\n");
15030 test_TrackMouseEvent();
15032 test_SetWindowRgn();
15034 test_dialog_messages();
15036 test_nullCallback();
15037 test_dbcs_wm_char();
15038 test_unicode_wm_char();
15039 test_menu_messages();
15040 test_paintingloop();
15042 test_clipboard_viewers();
15045 test_layered_window();
15046 test_TrackPopupMenu();
15047 test_TrackPopupMenuEmpty();
15048 /* keep it the last test, under Windows it tends to break the tests
15049 * which rely on active/foreground windows being correct.
15051 test_SetForegroundWindow();
15053 UnhookWindowsHookEx(hCBT_hook
);
15054 if (pUnhookWinEvent
&& hEvent_hook
)
15056 ret
= pUnhookWinEvent(hEvent_hook
);
15057 ok( ret
, "UnhookWinEvent error %d\n", GetLastError());
15058 SetLastError(0xdeadbeef);
15059 ok(!pUnhookWinEvent(hEvent_hook
), "UnhookWinEvent succeeded\n");
15060 ok(GetLastError() == ERROR_INVALID_HANDLE
|| /* Win2k */
15061 GetLastError() == 0xdeadbeef, /* Win9x */
15062 "unexpected error %d\n", GetLastError());
15064 DeleteCriticalSection( &sequence_cs
);