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__
71 static BOOL (WINAPI
*pActivateActCtx
)(HANDLE
,ULONG_PTR
*);
72 static HANDLE (WINAPI
*pCreateActCtxW
)(PCACTCTXW
);
73 static BOOL (WINAPI
*pDeactivateActCtx
)(DWORD
,ULONG_PTR
);
74 static BOOL (WINAPI
*pGetCurrentActCtx
)(HANDLE
*);
75 static void (WINAPI
*pReleaseActCtx
)(HANDLE
);
77 /* encoded DRAWITEMSTRUCT into an LPARAM */
84 UINT type
: 4; /* ODT_* flags */
85 UINT ctl_id
: 4; /* Control ID */
86 UINT item_id
: 4; /* Menu item ID */
87 UINT action
: 4; /* ODA_* flags */
88 UINT state
: 16; /* ODS_* flags */
94 static BOOL test_DestroyWindow_flag
;
95 static HWINEVENTHOOK hEvent_hook
;
96 static HHOOK hKBD_hook
;
97 static HHOOK hCBT_hook
;
98 static DWORD cbt_hook_thread_id
;
100 static const WCHAR testWindowClassW
[] =
101 { 'T','e','s','t','W','i','n','d','o','w','C','l','a','s','s','W',0 };
104 FIXME: add tests for these
105 Window Edge Styles (Win31/Win95/98 look), in order of precedence:
106 WS_EX_DLGMODALFRAME: double border, WS_CAPTION allowed
107 WS_THICKFRAME: thick border
108 WS_DLGFRAME: double border, WS_CAPTION not allowed (but possibly shown anyway)
109 WS_BORDER (default for overlapped windows): single black border
110 none (default for child (and popup?) windows): no border
128 UINT message
; /* the WM_* code */
129 msg_flags_t flags
; /* message props */
130 WPARAM wParam
; /* expected value of wParam */
131 LPARAM lParam
; /* expected value of lParam */
132 WPARAM wp_mask
; /* mask for wParam checks */
133 LPARAM lp_mask
; /* mask for lParam checks */
136 struct recvd_message
{
137 UINT message
; /* the WM_* code */
138 msg_flags_t flags
; /* message props */
139 HWND hwnd
; /* window that received the message */
140 WPARAM wParam
; /* expected value of wParam */
141 LPARAM lParam
; /* expected value of lParam */
142 int line
; /* source line where logged */
143 const char *descr
; /* description for trace output */
144 char output
[512]; /* trace output */
147 /* Empty message sequence */
148 static const struct message WmEmptySeq
[] =
152 /* CreateWindow (for overlapped window, not initially visible) (16/32) */
153 static const struct message WmCreateOverlappedSeq
[] = {
154 { HCBT_CREATEWND
, hook
},
155 { WM_GETMINMAXINFO
, sent
},
156 { WM_NCCREATE
, sent
},
157 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
158 { 0x0093, sent
|defwinproc
|optional
},
159 { 0x0094, sent
|defwinproc
|optional
},
160 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
162 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
165 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
166 * for a not visible overlapped window.
168 static const struct message WmSWP_ShowOverlappedSeq
[] = {
169 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
170 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
171 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
172 { WM_GETTEXT
, sent
|defwinproc
|optional
},
173 { WM_ERASEBKGND
, sent
|optional
},
174 { HCBT_ACTIVATE
, hook
},
175 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
176 { WM_NOTIFYFORMAT
, sent
|optional
},
177 { WM_QUERYUISTATE
, sent
|optional
},
178 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
179 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* Win9x: SWP_NOSENDCHANGING */
180 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
181 { WM_NCACTIVATE
, sent
},
182 { WM_GETTEXT
, sent
|defwinproc
|optional
},
183 { WM_ACTIVATE
, sent
|wparam
, 1 },
184 { HCBT_SETFOCUS
, hook
},
185 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
186 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
187 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
188 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
189 { WM_GETTEXT
, sent
|optional
},
190 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
191 { WM_GETTEXT
, sent
|defwinproc
|optional
},
192 { WM_ERASEBKGND
, sent
|optional
},
193 /* Win9x adds SWP_NOZORDER below */
194 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
195 { WM_GETTEXT
, sent
|optional
},
196 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
197 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
198 { WM_ERASEBKGND
, sent
|optional
},
199 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
200 { WM_SYNCPAINT
, sent
|optional
},
201 { WM_GETTITLEBARINFOEX
, sent
|optional
},
202 { WM_PAINT
, sent
|optional
},
203 { WM_NCPAINT
, sent
|beginpaint
|optional
},
204 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
205 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
208 /* SetWindowPos(SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE)
209 * for a visible overlapped window.
211 static const struct message WmSWP_HideOverlappedSeq
[] = {
212 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
213 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
214 { HCBT_ACTIVATE
, hook
|optional
},
215 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
216 { WM_ACTIVATEAPP
, sent
|wparam
|optional
, 1 },
217 { WM_NCACTIVATE
, sent
|optional
},
218 { WM_ACTIVATE
, sent
|optional
},
219 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
223 /* SetWindowPos(SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOMOVE)
224 * for a visible overlapped window.
226 static const struct message WmSWP_ResizeSeq
[] = {
227 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
},
228 { WM_GETMINMAXINFO
, sent
|defwinproc
},
229 { WM_NCCALCSIZE
, sent
|wparam
|optional
, TRUE
},
230 { WM_NCPAINT
, sent
|optional
},
231 { WM_GETTEXT
, sent
|defwinproc
|optional
},
232 { WM_ERASEBKGND
, sent
|optional
},
233 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
},
234 { WM_SIZE
, sent
|defwinproc
|optional
},
235 { WM_NCCALCSIZE
, sent
|wparam
|optional
, TRUE
},
236 { WM_NCPAINT
, sent
|optional
},
237 { WM_GETTEXT
, sent
|defwinproc
|optional
},
238 { WM_ERASEBKGND
, sent
|optional
},
239 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
240 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* XP sends a duplicate */
244 /* SetWindowPos(SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOMOVE)
245 * for a visible popup window.
247 static const struct message WmSWP_ResizePopupSeq
[] = {
248 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
},
249 { WM_GETMINMAXINFO
, sent
|defwinproc
|optional
}, /* Win9x */
250 { WM_NCCALCSIZE
, sent
|wparam
|optional
, TRUE
},
251 { WM_NCPAINT
, sent
|optional
},
252 { WM_GETTEXT
, sent
|defwinproc
|optional
},
253 { WM_ERASEBKGND
, sent
|optional
},
254 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
},
255 { WM_SIZE
, sent
|defwinproc
|wparam
|optional
, SIZE_RESTORED
},
256 { WM_NCCALCSIZE
, sent
|wparam
|optional
, TRUE
},
257 { WM_NCPAINT
, sent
|optional
},
258 { WM_GETTEXT
, sent
|defwinproc
|optional
},
259 { WM_ERASEBKGND
, sent
|optional
},
260 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
264 /* SetWindowPos(SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOSIZE)
265 * for a visible overlapped window.
267 static const struct message WmSWP_MoveSeq
[] = {
268 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOSIZE
},
269 { WM_NCPAINT
, sent
|optional
},
270 { WM_GETTEXT
, sent
|defwinproc
|optional
},
271 { WM_ERASEBKGND
, sent
|optional
},
272 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOCLIENTSIZE
},
273 { WM_MOVE
, sent
|defwinproc
|wparam
, 0 },
274 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
277 /* Resize with SetWindowPos(SWP_NOZORDER)
278 * for a visible overlapped window
279 * SWP_NOZORDER is stripped by the logging code
281 static const struct message WmSWP_ResizeNoZOrder
[] = {
282 { WM_WINDOWPOSCHANGING
, sent
|wparam
, /*SWP_NOZORDER|*/SWP_NOACTIVATE
},
283 { WM_GETMINMAXINFO
, sent
|defwinproc
},
284 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
285 { WM_NCPAINT
, sent
|optional
},
286 { WM_GETTEXT
, sent
|defwinproc
|optional
},
287 { WM_ERASEBKGND
, sent
|optional
},
288 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, /*SWP_NOZORDER|*/SWP_NOACTIVATE
, 0,
289 SWP_NOMOVE
|SWP_NOCLIENTMOVE
|SWP_NOSIZE
|SWP_NOCLIENTSIZE
},
290 { WM_MOVE
, sent
|defwinproc
|optional
},
291 { WM_SIZE
, sent
|defwinproc
|optional
},
292 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 }, /* Win9x doesn't send it */
293 { WM_NCPAINT
, sent
|optional
}, /* Win9x doesn't send it */
294 { WM_GETTEXT
, sent
|defwinproc
|optional
}, /* Win9x doesn't send it */
295 { WM_ERASEBKGND
, sent
|optional
}, /* Win9x doesn't send it */
296 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
297 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
301 /* Switch visible mdi children */
302 static const struct message WmSwitchChild
[] = {
303 /* Switch MDI child */
304 { WM_MDIACTIVATE
, sent
},/* in the MDI client */
305 { WM_WINDOWPOSCHANGING
, sent
|wparam
,SWP_NOSIZE
|SWP_NOMOVE
},/* in the 1st MDI child */
306 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
307 { WM_CHILDACTIVATE
, sent
},/* in the 1st MDI child */
308 /* Deactivate 2nd MDI child */
309 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 0 }, /* in the 2nd MDI child */
310 { WM_MDIACTIVATE
, sent
|defwinproc
}, /* in the 2nd MDI child */
311 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
312 /* Preparing for maximize and maximize the 1st MDI child */
313 { WM_GETMINMAXINFO
, sent
|defwinproc
}, /* in the 1st MDI child */
314 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_STATECHANGED
}, /* in the 1st MDI child */
315 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 }, /* in the 1st MDI child */
316 { WM_CHILDACTIVATE
, sent
|defwinproc
}, /* in the 1st MDI child */
317 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
}, /* in the 1st MDI child */
318 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
}, /* in the 1st MDI child */
319 /* Lock redraw 2nd MDI child */
320 { WM_SETREDRAW
, sent
|wparam
|defwinproc
, 0 }, /* in the 2nd MDI child */
321 { HCBT_MINMAX
, hook
|lparam
, 0, SW_NORMALNA
},
322 /* Restore 2nd MDI child */
323 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_STATECHANGED
},/* in the 2nd MDI child */
324 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 },/* in the 2nd MDI child */
325 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* in the 2nd MDI child */
326 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
}, /* in the 2nd MDI child */
327 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
}, /* in the 2nd MDI child */
328 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* in the 2nd MDI child */
329 /* Redraw 2nd MDI child */
330 { WM_SETREDRAW
, sent
|wparam
|defwinproc
, 1 },/* in the 2nd MDI child */
331 /* Redraw MDI frame */
332 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
},/* in MDI frame */
333 { WM_NCCALCSIZE
, sent
|wparam
, 1 },/* in MDI frame */
334 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
}, /* in MDI frame */
335 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* in MDI frame */
336 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* in the 1st MDI child */
337 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
}, /* in the 1st MDI child */
338 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 }, /* in the 1st MDI child */
339 { HCBT_SETFOCUS
, hook
},
340 { WM_KILLFOCUS
, sent
|defwinproc
}, /* in the 2nd MDI child */
341 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 0 },/* in the 1st MDI child */
342 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
343 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
344 { WM_SETFOCUS
, sent
},/* in the MDI client */
345 { HCBT_SETFOCUS
, hook
},
346 { WM_KILLFOCUS
, sent
},/* in the MDI client */
347 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
348 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 }, /* in the 1st MDI child */
349 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
350 { WM_SETFOCUS
, sent
|defwinproc
}, /* in the 1st MDI child */
351 { WM_MDIACTIVATE
, sent
|defwinproc
},/* in the 1st MDI child */
352 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
}, /* in the 1st MDI child */
356 /* Switch visible not maximized mdi children */
357 static const struct message WmSwitchNotMaximizedChild
[] = {
358 /* Switch not maximized MDI child */
359 { WM_MDIACTIVATE
, sent
},/* in the MDI client */
360 { WM_WINDOWPOSCHANGING
, sent
|wparam
,SWP_NOSIZE
|SWP_NOMOVE
},/* in the 2nd MDI child */
361 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
362 { WM_CHILDACTIVATE
, sent
},/* in the 2nd MDI child */
363 /* Deactivate 1st MDI child */
364 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 0 }, /* in the 1st MDI child */
365 { WM_MDIACTIVATE
, sent
|defwinproc
}, /* in the 1st MDI child */
366 /* Activate 2nd MDI child */
367 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
}, /* in the 2nd MDI child */
368 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 }, /* in the 2nd MDI child */
369 { HCBT_SETFOCUS
, hook
}, /* in the 1st MDI child */
370 { WM_KILLFOCUS
, sent
|defwinproc
}, /* in the 1st MDI child */
371 { WM_IME_SETCONTEXT
, sent
|defwinproc
|optional
}, /* in the 1st MDI child */
372 { WM_IME_SETCONTEXT
, sent
|optional
}, /* in the MDI client */
373 { WM_SETFOCUS
, sent
, 0 }, /* in the MDI client */
374 { HCBT_SETFOCUS
, hook
},
375 { WM_KILLFOCUS
, sent
}, /* in the MDI client */
376 { WM_IME_SETCONTEXT
, sent
|optional
}, /* in the MDI client */
377 { WM_IME_SETCONTEXT
, sent
|defwinproc
|optional
}, /* in the 1st MDI child */
378 { WM_SETFOCUS
, sent
|defwinproc
}, /* in the 2nd MDI child */
379 { WM_MDIACTIVATE
, sent
|defwinproc
}, /* in the 2nd MDI child */
380 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
}, /* in the 2nd MDI child */
385 /* SetWindowPos(SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|
386 SWP_NOZORDER|SWP_FRAMECHANGED)
387 * for a visible overlapped window with WS_CLIPCHILDREN style set.
389 static const struct message WmSWP_FrameChanged_clip
[] = {
390 { WM_WINDOWPOSCHANGING
, sent
|wparam
|parent
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
},
391 { WM_NCCALCSIZE
, sent
|wparam
|parent
, 1 },
392 { WM_NCPAINT
, sent
|parent
|optional
}, /* wparam != 1 */
393 { WM_GETTEXT
, sent
|parent
|defwinproc
|optional
},
394 { WM_ERASEBKGND
, sent
|parent
|optional
}, /* FIXME: remove optional once Wine is fixed */
395 { WM_NCPAINT
, sent
}, /* wparam != 1 */
396 { WM_ERASEBKGND
, sent
},
397 { WM_WINDOWPOSCHANGED
, sent
|wparam
|parent
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
398 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
402 /* SetWindowPos(SWP_NOSIZE|SWP_NOMOVE|SWP_DEFERERASE|SWP_NOACTIVATE|
403 SWP_NOZORDER|SWP_FRAMECHANGED)
404 * for a visible overlapped window.
406 static const struct message WmSWP_FrameChangedDeferErase
[] = {
407 { WM_WINDOWPOSCHANGING
, sent
|wparam
|parent
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_DEFERERASE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
},
408 { WM_NCCALCSIZE
, sent
|wparam
|parent
, 1 },
409 { WM_WINDOWPOSCHANGED
, sent
|wparam
|parent
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_DEFERERASE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
410 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
411 { WM_PAINT
, sent
|parent
|optional
},
412 { WM_NCPAINT
, sent
|beginpaint
|parent
|optional
}, /* wparam != 1 */
413 { WM_GETTEXT
, sent
|beginpaint
|parent
|defwinproc
|optional
},
415 { WM_NCPAINT
, sent
|beginpaint
}, /* wparam != 1 */
416 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
420 /* SetWindowPos(SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|
421 SWP_NOZORDER|SWP_FRAMECHANGED)
422 * for a visible overlapped window without WS_CLIPCHILDREN style set.
424 static const struct message WmSWP_FrameChanged_noclip
[] = {
425 { WM_WINDOWPOSCHANGING
, sent
|wparam
|parent
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
},
426 { WM_NCCALCSIZE
, sent
|wparam
|parent
, 1 },
427 { WM_NCPAINT
, sent
|parent
|optional
}, /* wparam != 1 */
428 { WM_GETTEXT
, sent
|parent
|defwinproc
|optional
},
429 { WM_ERASEBKGND
, sent
|parent
|optional
},
430 { WM_WINDOWPOSCHANGED
, sent
|wparam
|parent
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
431 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
433 { WM_NCPAINT
, sent
|beginpaint
}, /* wparam != 1 */
434 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
438 /* ShowWindow(SW_SHOW) for a not visible overlapped window */
439 static const struct message WmShowOverlappedSeq
[] = {
440 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
441 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
442 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
443 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
444 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
445 { WM_GETTEXT
, sent
|defwinproc
|optional
},
446 { WM_ERASEBKGND
, sent
|optional
},
447 { HCBT_ACTIVATE
, hook
},
448 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
449 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
450 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
451 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
452 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
453 { WM_NCACTIVATE
, sent
|wparam
, 1 },
454 { WM_GETTEXT
, sent
|defwinproc
|optional
},
455 { WM_ACTIVATE
, sent
|wparam
, 1 },
456 { HCBT_SETFOCUS
, hook
},
457 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
458 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
459 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
460 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
461 { WM_GETTEXT
, sent
|optional
},
462 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
463 { WM_GETTEXT
, sent
|defwinproc
|optional
},
464 { WM_ERASEBKGND
, sent
|optional
},
465 /* Win9x adds SWP_NOZORDER below */
466 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
467 { WM_NCCALCSIZE
, sent
|optional
},
468 { WM_GETTEXT
, sent
|optional
},
469 { WM_NCPAINT
, sent
|optional
},
470 { WM_ERASEBKGND
, sent
|optional
},
471 { WM_SYNCPAINT
, sent
|optional
},
472 #if 0 /* CreateWindow/ShowWindow(SW_SHOW) also generates WM_SIZE/WM_MOVE
473 * messages. Does that mean that CreateWindow doesn't set initial
474 * window dimensions for overlapped windows?
479 { WM_PAINT
, sent
|optional
},
480 { WM_NCPAINT
, sent
|beginpaint
|optional
},
483 /* ShowWindow(SW_SHOWMAXIMIZED) for a not visible overlapped window */
484 static const struct message WmShowMaxOverlappedSeq
[] = {
485 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
486 { WM_GETMINMAXINFO
, sent
},
487 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_STATECHANGED
},
488 { WM_GETMINMAXINFO
, sent
|defwinproc
},
489 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
490 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
491 { HCBT_ACTIVATE
, hook
},
492 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
493 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
494 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
495 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
496 { WM_NCACTIVATE
, sent
|wparam
, 1 },
497 { WM_GETTEXT
, sent
|defwinproc
|optional
},
498 { WM_ACTIVATE
, sent
|wparam
, 1 },
499 { HCBT_SETFOCUS
, hook
},
500 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
501 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
502 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
503 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
504 { WM_GETTEXT
, sent
|optional
},
505 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
506 { WM_GETTEXT
, sent
|defwinproc
|optional
},
507 { WM_ERASEBKGND
, sent
|optional
},
508 /* Win9x adds SWP_NOZORDER below */
509 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_STATECHANGED
},
510 { WM_MOVE
, sent
|defwinproc
},
511 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
512 { WM_GETTEXT
, sent
|optional
},
513 { WM_NCCALCSIZE
, sent
|optional
},
514 { WM_NCPAINT
, sent
|optional
},
515 { WM_ERASEBKGND
, sent
|optional
},
516 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
517 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
518 { WM_SYNCPAINT
, sent
|optional
},
519 { WM_GETTITLEBARINFOEX
, sent
|optional
},
520 { WM_PAINT
, sent
|optional
},
521 { WM_NCPAINT
, sent
|beginpaint
|optional
},
522 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
525 /* ShowWindow(SW_RESTORE) for a not visible maximized overlapped window */
526 static const struct message WmShowRestoreMaxOverlappedSeq
[] = {
527 { HCBT_MINMAX
, hook
|lparam
, 0, SW_RESTORE
},
528 { WM_GETTEXT
, sent
|optional
},
529 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
530 { WM_GETMINMAXINFO
, sent
|defwinproc
},
531 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
532 { WM_NCPAINT
, sent
|optional
},
533 { WM_GETTEXT
, sent
|defwinproc
|optional
},
534 { WM_ERASEBKGND
, sent
|optional
},
535 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
, 0, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOSIZE
|SWP_NOMOVE
},
536 { WM_MOVE
, sent
|defwinproc
|optional
},
537 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
538 { WM_NCCALCSIZE
, sent
|wparam
|optional
, TRUE
},
539 { WM_NCPAINT
, sent
|optional
},
540 { WM_ERASEBKGND
, sent
|optional
},
541 { WM_PAINT
, sent
|optional
},
542 { WM_GETTITLEBARINFOEX
, sent
|optional
},
543 { WM_NCPAINT
, sent
|beginpaint
|optional
},
544 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
547 /* ShowWindow(SW_RESTORE) for a not visible minimized overlapped window */
548 static const struct message WmShowRestoreMinOverlappedSeq
[] = {
549 { HCBT_MINMAX
, hook
|lparam
, 0, SW_RESTORE
},
550 { WM_QUERYOPEN
, sent
|optional
},
551 { WM_GETTEXT
, sent
|optional
},
552 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
|SWP_NOCOPYBITS
},
553 { WM_GETMINMAXINFO
, sent
|defwinproc
},
554 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
555 { HCBT_ACTIVATE
, hook
},
556 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
557 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
558 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
559 { WM_NCACTIVATE
, sent
|wparam
, 1 },
560 { WM_GETTEXT
, sent
|defwinproc
|optional
},
561 { WM_ACTIVATE
, sent
|wparam
, 1 },
562 { HCBT_SETFOCUS
, hook
},
563 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
564 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
565 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
566 { WM_GETTEXT
, sent
|optional
},
567 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
568 { WM_GETTEXT
, sent
|defwinproc
|optional
},
569 { WM_ERASEBKGND
, sent
},
570 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_STATECHANGED
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
},
571 { WM_MOVE
, sent
|defwinproc
},
572 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
573 { WM_NCCALCSIZE
, sent
|wparam
|optional
, TRUE
},
574 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
575 { WM_ERASEBKGND
, sent
|optional
},
576 { WM_ACTIVATE
, sent
|wparam
, 1 },
577 { WM_GETTEXT
, sent
|optional
},
578 { WM_PAINT
, sent
|optional
},
579 { WM_GETTITLEBARINFOEX
, sent
|optional
},
580 { WM_NCPAINT
, sent
|beginpaint
|optional
},
581 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
584 /* ShowWindow(SW_SHOWMINIMIZED) for a not visible overlapped window */
585 static const struct message WmShowMinOverlappedSeq
[] = {
586 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
587 { HCBT_SETFOCUS
, hook
},
588 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
589 { WM_KILLFOCUS
, sent
},
590 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
591 { WM_IME_NOTIFY
, sent
|wparam
|optional
|defwinproc
, 1 },
592 { WM_GETTEXT
, sent
|optional
},
593 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOCOPYBITS
|SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_STATECHANGED
},
594 { WM_GETMINMAXINFO
, sent
|defwinproc
},
595 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
596 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
597 { WM_NCPAINT
, sent
|optional
},
598 { WM_GETTEXT
, sent
|defwinproc
|optional
},
599 { WM_WINDOWPOSCHANGED
, sent
},
600 { WM_MOVE
, sent
|defwinproc
},
601 { WM_SIZE
, sent
|defwinproc
|wparam
|lparam
, SIZE_MINIMIZED
, 0 },
602 { WM_NCCALCSIZE
, sent
|optional
},
603 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
604 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
605 { EVENT_SYSTEM_MINIMIZESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
606 { WM_NCACTIVATE
, sent
|wparam
, 0 },
607 { WM_GETTEXT
, sent
|defwinproc
|optional
},
608 { WM_ACTIVATE
, sent
},
609 { WM_ACTIVATEAPP
, sent
|wparam
, 0 },
611 /* Vista sometimes restores the window right away... */
612 { WM_SYSCOMMAND
, sent
|optional
|wparam
, SC_RESTORE
},
613 { HCBT_SYSCOMMAND
, hook
|optional
|wparam
, SC_RESTORE
},
614 { HCBT_MINMAX
, hook
|optional
|lparam
, 0, SW_RESTORE
},
615 { WM_QUERYOPEN
, sent
|optional
},
616 { WM_WINDOWPOSCHANGING
, sent
|optional
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
617 { WM_GETMINMAXINFO
, sent
|optional
|defwinproc
},
618 { WM_NCCALCSIZE
, sent
|optional
|wparam
, TRUE
},
619 { HCBT_ACTIVATE
, hook
|optional
},
620 { WM_ACTIVATEAPP
, sent
|optional
|wparam
, 1 },
621 { WM_NCACTIVATE
, sent
|optional
},
622 { WM_GETTEXT
, sent
|optional
},
623 { WM_ACTIVATE
, sent
|optional
|wparam
, 1 },
624 { HCBT_SETFOCUS
, hook
|optional
},
625 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
626 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
627 { WM_SETFOCUS
, sent
|optional
},
628 { WM_NCPAINT
, sent
|optional
},
629 { WM_GETTEXT
, sent
|defwinproc
|optional
},
630 { WM_ERASEBKGND
, sent
|optional
},
631 { WM_WINDOWPOSCHANGED
, sent
|optional
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
632 { WM_MOVE
, sent
|defwinproc
|optional
},
633 { WM_SIZE
, sent
|defwinproc
|optional
|wparam
, SIZE_RESTORED
},
634 { WM_ACTIVATE
, sent
|optional
|wparam
, 1 },
635 { WM_SYSCOMMAND
, sent
|optional
|wparam
, SC_RESTORE
},
636 { HCBT_SYSCOMMAND
, hook
|optional
|wparam
, SC_RESTORE
},
638 { WM_PAINT
, sent
|optional
},
639 { WM_NCPAINT
, sent
|beginpaint
|optional
},
640 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
643 /* ShowWindow(SW_HIDE) for a visible overlapped window */
644 static const struct message WmHideOverlappedSeq
[] = {
645 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
646 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
647 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
648 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
649 { WM_SIZE
, sent
|optional
}, /* XP doesn't send it */
650 { WM_MOVE
, sent
|optional
}, /* XP doesn't send it */
651 { WM_NCACTIVATE
, sent
|wparam
|optional
, 0 },
652 { WM_ACTIVATE
, sent
|wparam
|optional
, 0 },
653 { WM_ACTIVATEAPP
, sent
|wparam
|optional
, 0 },
654 { HCBT_SETFOCUS
, hook
|optional
},
655 { WM_KILLFOCUS
, sent
|wparam
, 0 },
656 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
657 { WM_IME_NOTIFY
, sent
|wparam
|optional
|defwinproc
, 1 },
660 /* DestroyWindow for a visible overlapped window */
661 static const struct message WmDestroyOverlappedSeq
[] = {
662 { HCBT_DESTROYWND
, hook
},
663 { 0x0090, sent
|optional
},
664 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
665 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
666 { 0x0090, sent
|optional
},
667 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
668 { WM_NCACTIVATE
, sent
|optional
|wparam
, 0 },
669 { WM_ACTIVATE
, sent
|optional
},
670 { WM_ACTIVATEAPP
, sent
|optional
|wparam
, 0 },
671 { WM_KILLFOCUS
, sent
|optional
|wparam
, 0 },
672 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
673 { WM_IME_NOTIFY
, sent
|wparam
|optional
|defwinproc
, 1 },
674 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
675 { WM_DESTROY
, sent
},
676 { WM_NCDESTROY
, sent
},
679 /* CreateWindow(WS_MAXIMIZE|WS_VISIBLE) for popup window */
680 static const struct message WmCreateMaxPopupSeq
[] = {
681 { HCBT_CREATEWND
, hook
},
682 { WM_NCCREATE
, sent
},
683 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
685 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
686 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
688 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
689 { WM_GETMINMAXINFO
, sent
},
690 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_STATECHANGED
},
691 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
692 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOREDRAW
|SWP_STATECHANGED
},
693 { WM_MOVE
, sent
|defwinproc
},
694 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
695 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
696 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
697 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
698 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
699 { HCBT_ACTIVATE
, hook
},
700 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
701 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
702 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
703 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
704 { WM_ERASEBKGND
, sent
|optional
},
705 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOCLIENTMOVE
|SWP_NOCLIENTSIZE
|SWP_NOMOVE
|SWP_NOSIZE
},
706 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
707 { WM_NCACTIVATE
, sent
},
708 { WM_ACTIVATE
, sent
|wparam
, 1 },
709 { HCBT_SETFOCUS
, hook
},
710 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
711 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
712 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
713 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
714 { WM_GETTEXT
, sent
|optional
},
715 { WM_SYNCPAINT
, sent
|wparam
|optional
, 4 },
716 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
717 { WM_ERASEBKGND
, sent
|optional
},
718 { WM_NCPAINT
, sent
|wparam
|defwinproc
|optional
, 1 },
719 { WM_ERASEBKGND
, sent
|defwinproc
|optional
},
720 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOCLIENTMOVE
|SWP_NOCLIENTSIZE
|SWP_SHOWWINDOW
|SWP_NOMOVE
|SWP_NOSIZE
},
723 /* CreateWindow(WS_MAXIMIZE) for popup window, not initially visible */
724 static const struct message WmCreateInvisibleMaxPopupSeq
[] = {
725 { HCBT_CREATEWND
, hook
},
726 { WM_NCCREATE
, sent
},
727 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
729 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
730 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
732 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
733 { WM_GETMINMAXINFO
, sent
},
734 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_STATECHANGED
},
735 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
736 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOREDRAW
|SWP_STATECHANGED
},
737 { WM_MOVE
, sent
|defwinproc
},
738 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
739 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
742 /* ShowWindow(SW_SHOWMAXIMIZED) for a resized not visible popup window */
743 static const struct message WmShowMaxPopupResizedSeq
[] = {
744 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
745 { WM_GETMINMAXINFO
, sent
},
746 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
},
747 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
748 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
749 { HCBT_ACTIVATE
, hook
},
750 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
751 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
752 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
753 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
754 { WM_ERASEBKGND
, sent
|optional
},
755 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
756 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
757 { WM_NCACTIVATE
, sent
},
758 { WM_ACTIVATE
, sent
|wparam
, 1 },
759 { HCBT_SETFOCUS
, hook
},
760 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
761 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
762 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
763 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
764 { WM_GETTEXT
, sent
|optional
},
765 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
766 { WM_ERASEBKGND
, sent
|optional
},
767 { WM_WINDOWPOSCHANGED
, sent
},
768 /* WinNT4.0 sends WM_MOVE */
769 { WM_MOVE
, sent
|defwinproc
|optional
},
770 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
771 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
774 /* ShowWindow(SW_SHOWMAXIMIZED) for a not visible popup window */
775 static const struct message WmShowMaxPopupSeq
[] = {
776 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
777 { WM_GETMINMAXINFO
, sent
},
778 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
},
779 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
780 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
781 { HCBT_ACTIVATE
, hook
},
782 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
783 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
784 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
785 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
786 { WM_NCACTIVATE
, sent
},
787 { WM_ACTIVATE
, sent
|wparam
, 1 },
788 { HCBT_SETFOCUS
, hook
},
789 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
790 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
791 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
792 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
793 { WM_GETTEXT
, sent
|optional
},
794 { WM_SYNCPAINT
, sent
|wparam
|optional
, 4 },
795 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
796 { WM_ERASEBKGND
, sent
|optional
},
797 { WM_NCPAINT
, sent
|wparam
|defwinproc
|optional
, 1 },
798 { WM_ERASEBKGND
, sent
|defwinproc
|optional
},
799 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOMOVE
|SWP_NOSIZE
},
800 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
803 /* CreateWindow(WS_VISIBLE) for popup window */
804 static const struct message WmCreatePopupSeq
[] = {
805 { HCBT_CREATEWND
, hook
},
806 { WM_NCCREATE
, sent
},
807 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
809 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
810 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
812 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
813 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
814 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
815 { HCBT_ACTIVATE
, hook
},
816 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
817 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
818 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
819 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
820 { WM_ERASEBKGND
, sent
|optional
},
821 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
822 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
823 { WM_NCACTIVATE
, sent
},
824 { WM_ACTIVATE
, sent
|wparam
, 1 },
825 { HCBT_SETFOCUS
, hook
},
826 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
827 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
828 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
829 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
830 { WM_GETTEXT
, sent
|optional
},
831 { WM_SYNCPAINT
, sent
|wparam
|optional
, 4 },
832 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
833 { WM_ERASEBKGND
, sent
|optional
},
834 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOCLIENTMOVE
|SWP_NOCLIENTSIZE
|SWP_SHOWWINDOW
|SWP_NOMOVE
|SWP_NOSIZE
},
837 /* ShowWindow(SW_SHOWMAXIMIZED) for a visible popup window */
838 static const struct message WmShowVisMaxPopupSeq
[] = {
839 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
840 { WM_GETMINMAXINFO
, sent
},
841 { WM_GETTEXT
, sent
|optional
},
842 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
843 { WM_GETTEXT
, sent
|optional
},
844 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
845 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
846 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
847 { WM_ERASEBKGND
, sent
|optional
},
848 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
849 { WM_MOVE
, sent
|defwinproc
},
850 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
851 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
854 /* CreateWindow (for a child popup window, not initially visible) */
855 static const struct message WmCreateChildPopupSeq
[] = {
856 { HCBT_CREATEWND
, hook
},
857 { WM_NCCREATE
, sent
},
858 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
860 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
861 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
865 /* CreateWindow (for a popup window, not initially visible,
866 * which sets WS_VISIBLE in WM_CREATE handler)
868 static const struct message WmCreateInvisiblePopupSeq
[] = {
869 { HCBT_CREATEWND
, hook
},
870 { WM_NCCREATE
, sent
},
871 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
873 { WM_STYLECHANGING
, sent
},
874 { WM_STYLECHANGED
, sent
},
875 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
876 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
880 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER)
881 * for a popup window with WS_VISIBLE style set
883 static const struct message WmShowVisiblePopupSeq_2
[] = {
884 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
887 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
888 * for a popup window with WS_VISIBLE style set
890 static const struct message WmShowVisiblePopupSeq_3
[] = {
891 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
892 { HCBT_ACTIVATE
, hook
},
893 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
894 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
895 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
896 { WM_NCACTIVATE
, sent
},
897 { WM_ACTIVATE
, sent
|wparam
, 1 },
898 { HCBT_SETFOCUS
, hook
},
899 { WM_KILLFOCUS
, sent
|parent
},
900 { WM_IME_SETCONTEXT
, sent
|parent
|wparam
|optional
, 0 },
901 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
902 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
903 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
904 { WM_SETFOCUS
, sent
|defwinproc
},
905 { WM_GETTEXT
, sent
|optional
},
906 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
, 0, SWP_SHOWWINDOW
},
909 /* CreateWindow (for child window, not initially visible) */
910 static const struct message WmCreateChildSeq
[] = {
911 { HCBT_CREATEWND
, hook
},
912 { WM_NCCREATE
, sent
},
913 /* child is inserted into parent's child list after WM_NCCREATE returns */
914 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
916 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
917 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
919 { WM_PARENTNOTIFY
, sent
|parent
|wparam
, WM_CREATE
},
922 /* CreateWindow (for maximized child window, not initially visible) */
923 static const struct message WmCreateMaximizedChildSeq
[] = {
924 { HCBT_CREATEWND
, hook
},
925 { WM_NCCREATE
, sent
},
926 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
928 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
929 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
931 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
932 { WM_GETMINMAXINFO
, sent
},
933 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_STATECHANGED
},
934 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
935 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
936 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
937 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
938 { WM_PARENTNOTIFY
, sent
|parent
|wparam
, WM_CREATE
},
941 /* CreateWindow (for a child window, initially visible) */
942 static const struct message WmCreateVisibleChildSeq
[] = {
943 { HCBT_CREATEWND
, hook
},
944 { WM_NCCREATE
, sent
},
945 /* child is inserted into parent's child list after WM_NCCREATE returns */
946 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
947 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
949 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
950 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
952 { WM_PARENTNOTIFY
, sent
|parent
|wparam
, WM_CREATE
},
953 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
954 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
955 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
956 { WM_ERASEBKGND
, sent
|parent
|optional
},
957 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
958 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 }, /* WinXP */
959 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
962 /* ShowWindow(SW_SHOW) for a not visible child window */
963 static const struct message WmShowChildSeq
[] = {
964 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
965 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
966 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
967 { WM_ERASEBKGND
, sent
|parent
|optional
},
968 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
971 /* ShowWindow(SW_HIDE) for a visible child window */
972 static const struct message WmHideChildSeq
[] = {
973 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
974 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
975 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
976 { WM_ERASEBKGND
, sent
|parent
|optional
},
977 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
980 /* ShowWindow(SW_HIDE) for a visible child window checking all parent events*/
981 static const struct message WmHideChildSeq2
[] = {
982 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
983 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
984 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
985 { WM_ERASEBKGND
, sent
|parent
|optional
},
986 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
989 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
990 * for a not visible child window
992 static const struct message WmShowChildSeq_2
[] = {
993 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
994 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
995 { WM_CHILDACTIVATE
, sent
},
996 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
999 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE)
1000 * for a not visible child window
1002 static const struct message WmShowChildSeq_3
[] = {
1003 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
1004 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1005 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1008 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
1009 * for a visible child window with a caption
1011 static const struct message WmShowChildSeq_4
[] = {
1012 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
1013 { WM_CHILDACTIVATE
, sent
},
1016 /* ShowWindow(SW_MINIMIZE) for child with invisible parent */
1017 static const struct message WmShowChildInvisibleParentSeq_1
[] = {
1018 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
1019 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
, 0, SWP_NOACTIVATE
},
1020 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1021 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1022 { WM_CHILDACTIVATE
, sent
|optional
},
1023 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOREDRAW
|SWP_NOCOPYBITS
|SWP_STATECHANGED
, 0, SWP_NOACTIVATE
},
1024 { WM_MOVE
, sent
|defwinproc
},
1025 { WM_SIZE
, sent
|defwinproc
|wparam
|lparam
, SIZE_MINIMIZED
, 0 },
1026 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1027 { EVENT_SYSTEM_MINIMIZESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
1028 /* FIXME: Wine creates an icon/title window while Windows doesn't */
1029 { WM_PARENTNOTIFY
, sent
|parent
|wparam
|optional
, WM_CREATE
},
1030 { WM_GETTEXT
, sent
|optional
},
1033 /* repeated ShowWindow(SW_MINIMIZE) for child with invisible parent */
1034 static const struct message WmShowChildInvisibleParentSeq_1r
[] = {
1035 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
1038 /* ShowWindow(SW_MAXIMIZE) for child with invisible parent */
1039 static const struct message WmShowChildInvisibleParentSeq_2
[] = {
1040 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
1041 { WM_GETMINMAXINFO
, sent
},
1042 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_STATECHANGED
},
1043 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1044 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1045 { WM_CHILDACTIVATE
, sent
},
1046 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
1047 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
1048 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1051 /* repeated ShowWindow(SW_MAXIMIZE) for child with invisible parent */
1052 static const struct message WmShowChildInvisibleParentSeq_2r
[] = {
1053 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
1056 /* ShowWindow(SW_SHOWMINIMIZED) for child with invisible parent */
1057 static const struct message WmShowChildInvisibleParentSeq_3
[] = {
1058 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINIMIZED
},
1059 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
1060 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1061 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1062 { WM_CHILDACTIVATE
, sent
},
1063 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOREDRAW
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
1064 { WM_MOVE
, sent
|defwinproc
},
1065 { WM_SIZE
, sent
|defwinproc
|wparam
|lparam
, SIZE_MINIMIZED
, 0 },
1066 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1067 { EVENT_SYSTEM_MINIMIZESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
1068 /* FIXME: Wine creates an icon/title window while Windows doesn't */
1069 { WM_PARENTNOTIFY
, sent
|parent
|wparam
|optional
, WM_CREATE
},
1070 { WM_GETTEXT
, sent
|optional
},
1073 /* repeated ShowWindow(SW_SHOWMINIMIZED) for child with invisible parent */
1074 static const struct message WmShowChildInvisibleParentSeq_3r
[] = {
1075 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINIMIZED
},
1078 /* ShowWindow(SW_SHOWMINNOACTIVE) for child with invisible parent */
1079 static const struct message WmShowChildInvisibleParentSeq_4
[] = {
1080 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINNOACTIVE
},
1081 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
1082 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1083 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1084 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOREDRAW
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
1085 { WM_MOVE
, sent
|defwinproc
},
1086 { WM_SIZE
, sent
|defwinproc
|wparam
|lparam
, SIZE_MINIMIZED
, 0 },
1087 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1088 { EVENT_SYSTEM_MINIMIZESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
1089 /* FIXME: Wine creates an icon/title window while Windows doesn't */
1090 { WM_PARENTNOTIFY
, sent
|parent
|wparam
|optional
, WM_CREATE
},
1091 { WM_GETTEXT
, sent
|optional
},
1094 /* repeated ShowWindow(SW_SHOWMINNOACTIVE) for child with invisible parent */
1095 static const struct message WmShowChildInvisibleParentSeq_4r
[] = {
1096 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINNOACTIVE
},
1099 /* ShowWindow(SW_SHOW) for child with invisible parent */
1100 static const struct message WmShowChildInvisibleParentSeq_5
[] = {
1101 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1104 /* ShowWindow(SW_HIDE) for child with invisible parent */
1105 static const struct message WmHideChildInvisibleParentSeq
[] = {
1106 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
1109 /* SetWindowPos(SWP_SHOWWINDOW) for child with invisible parent */
1110 static const struct message WmShowChildInvisibleParentSeq_6
[] = {
1111 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
1112 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1113 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1116 /* SetWindowPos(SWP_HIDEWINDOW) for child with invisible parent */
1117 static const struct message WmHideChildInvisibleParentSeq_2
[] = {
1118 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1119 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1120 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1123 /* DestroyWindow for a visible child window */
1124 static const struct message WmDestroyChildSeq
[] = {
1125 { HCBT_DESTROYWND
, hook
},
1126 { 0x0090, sent
|optional
},
1127 { WM_PARENTNOTIFY
, sent
|parent
|wparam
, WM_DESTROY
},
1128 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
1129 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1130 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1131 { WM_ERASEBKGND
, sent
|parent
|optional
},
1132 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1133 { HCBT_SETFOCUS
, hook
}, /* set focus to a parent */
1134 { WM_KILLFOCUS
, sent
},
1135 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
1136 { WM_IME_SETCONTEXT
, sent
|wparam
|parent
|optional
, 1 },
1137 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1138 { WM_SETFOCUS
, sent
|parent
},
1139 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
1140 { WM_DESTROY
, sent
},
1141 { WM_DESTROY
, sent
|optional
}, /* some other (IME?) window */
1142 { WM_NCDESTROY
, sent
|optional
}, /* some other (IME?) window */
1143 { WM_NCDESTROY
, sent
},
1146 /* visible child window destroyed by thread exit */
1147 static const struct message WmExitThreadSeq
[] = {
1148 { WM_NCDESTROY
, sent
}, /* actually in grandchild */
1149 { WM_PAINT
, sent
|parent
},
1150 { WM_ERASEBKGND
, sent
|parent
|beginpaint
},
1153 /* DestroyWindow for a visible child window with invisible parent */
1154 static const struct message WmDestroyInvisibleChildSeq
[] = {
1155 { HCBT_DESTROYWND
, hook
},
1156 { 0x0090, sent
|optional
},
1157 { WM_PARENTNOTIFY
, sent
|parent
|wparam
, WM_DESTROY
},
1158 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
1159 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
1160 { WM_DESTROY
, sent
},
1161 { WM_NCDESTROY
, sent
},
1164 /* Moving the mouse in nonclient area */
1165 static const struct message WmMouseMoveInNonClientAreaSeq
[] = { /* FIXME: add */
1166 { WM_NCHITTEST
, sent
},
1167 { WM_SETCURSOR
, sent
},
1168 { WM_NCMOUSEMOVE
, posted
},
1171 /* Moving the mouse in client area */
1172 static const struct message WmMouseMoveInClientAreaSeq
[] = { /* FIXME: add */
1173 { WM_NCHITTEST
, sent
},
1174 { WM_SETCURSOR
, sent
},
1175 { WM_MOUSEMOVE
, posted
},
1178 /* Moving by dragging the title bar (after WM_NCHITTEST and WM_SETCURSOR) (outline move) */
1179 static const struct message WmDragTitleBarSeq
[] = { /* FIXME: add */
1180 { WM_NCLBUTTONDOWN
, sent
|wparam
, HTCAPTION
},
1181 { WM_SYSCOMMAND
, sent
|defwinproc
|wparam
, SC_MOVE
+2 },
1182 { WM_GETMINMAXINFO
, sent
|defwinproc
},
1183 { WM_ENTERSIZEMOVE
, sent
|defwinproc
},
1184 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, 0 },
1185 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, 0 },
1186 { WM_MOVE
, sent
|defwinproc
},
1187 { WM_EXITSIZEMOVE
, sent
|defwinproc
},
1190 /* Sizing by dragging the thick borders (after WM_NCHITTEST and WM_SETCURSOR) (outline move) */
1191 static const struct message WmDragThickBordersBarSeq
[] = { /* FIXME: add */
1192 { WM_NCLBUTTONDOWN
, sent
|wparam
, 0xd },
1193 { WM_SYSCOMMAND
, sent
|defwinproc
|wparam
, 0xf004 },
1194 { WM_GETMINMAXINFO
, sent
|defwinproc
},
1195 { WM_ENTERSIZEMOVE
, sent
|defwinproc
},
1196 { WM_SIZING
, sent
|defwinproc
|wparam
, 4}, /* one for each mouse movement */
1197 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, 0 },
1198 { WM_GETMINMAXINFO
, sent
|defwinproc
},
1199 { WM_NCCALCSIZE
, sent
|defwinproc
|wparam
, 1 },
1200 { WM_NCPAINT
, sent
|defwinproc
|wparam
, 1 },
1201 { WM_GETTEXT
, sent
|defwinproc
},
1202 { WM_ERASEBKGND
, sent
|defwinproc
},
1203 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, 0 },
1204 { WM_MOVE
, sent
|defwinproc
},
1205 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
1206 { WM_EXITSIZEMOVE
, sent
|defwinproc
},
1209 /* Resizing child window with MoveWindow (32) */
1210 static const struct message WmResizingChildWithMoveWindowSeq
[] = {
1211 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
1212 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1213 { WM_ERASEBKGND
, sent
|parent
|optional
},
1214 { WM_ERASEBKGND
, sent
|optional
},
1215 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
},
1216 { WM_MOVE
, sent
|defwinproc
},
1217 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
1218 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1221 /* Clicking on inactive button */
1222 static const struct message WmClickInactiveButtonSeq
[] = { /* FIXME: add */
1223 { WM_NCHITTEST
, sent
},
1224 { WM_PARENTNOTIFY
, sent
|parent
|wparam
, WM_LBUTTONDOWN
},
1225 { WM_MOUSEACTIVATE
, sent
},
1226 { WM_MOUSEACTIVATE
, sent
|parent
|defwinproc
},
1227 { WM_SETCURSOR
, sent
},
1228 { WM_SETCURSOR
, sent
|parent
|defwinproc
},
1229 { WM_LBUTTONDOWN
, posted
},
1230 { WM_KILLFOCUS
, posted
|parent
},
1231 { WM_SETFOCUS
, posted
},
1232 { WM_CTLCOLORBTN
, posted
|parent
},
1233 { BM_SETSTATE
, posted
},
1234 { WM_CTLCOLORBTN
, posted
|parent
},
1235 { WM_LBUTTONUP
, posted
},
1236 { BM_SETSTATE
, posted
},
1237 { WM_CTLCOLORBTN
, posted
|parent
},
1238 { WM_COMMAND
, posted
|parent
},
1241 /* Reparenting a button (16/32) */
1242 /* The last child (button) reparented gets topmost for its new parent. */
1243 static const struct message WmReparentButtonSeq
[] = { /* FIXME: add */
1244 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
1245 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOSIZE
},
1246 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1247 { WM_ERASEBKGND
, sent
|parent
},
1248 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOSIZE
},
1249 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
},
1250 { WM_CHILDACTIVATE
, sent
},
1251 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOSIZE
|SWP_NOREDRAW
},
1252 { WM_MOVE
, sent
|defwinproc
},
1253 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1256 /* Creation of a custom dialog (32) */
1257 static const struct message WmCreateCustomDialogSeq
[] = {
1258 { HCBT_CREATEWND
, hook
},
1259 { WM_GETMINMAXINFO
, sent
},
1260 { WM_NCCREATE
, sent
},
1261 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
1262 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
1263 { WM_CREATE
, sent
},
1264 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1265 { WM_NOTIFYFORMAT
, sent
|optional
},
1266 { WM_QUERYUISTATE
, sent
|optional
},
1267 { WM_WINDOWPOSCHANGING
, sent
|optional
},
1268 { WM_GETMINMAXINFO
, sent
|optional
},
1269 { WM_NCCALCSIZE
, sent
|optional
},
1270 { WM_WINDOWPOSCHANGED
, sent
|optional
},
1271 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1272 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
1273 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1274 { HCBT_ACTIVATE
, hook
},
1275 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
1278 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
1280 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
1282 { WM_NCACTIVATE
, sent
},
1283 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1284 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1285 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1286 { EVENT_OBJECT_DEFACTIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, OBJID_CLIENT
, 0 },
1287 { WM_ACTIVATE
, sent
|wparam
, 1 },
1288 { WM_GETTEXT
, sent
|optional
},
1289 { WM_KILLFOCUS
, sent
|parent
},
1290 { WM_IME_SETCONTEXT
, sent
|parent
|wparam
|optional
, 0 },
1291 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
1292 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
1293 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1294 { WM_SETFOCUS
, sent
},
1295 { WM_GETDLGCODE
, sent
|defwinproc
|wparam
, 0 },
1296 { WM_NCPAINT
, sent
|wparam
, 1 },
1297 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1298 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1299 { WM_ERASEBKGND
, sent
},
1300 { WM_CTLCOLORDLG
, sent
|optional
|defwinproc
},
1301 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1302 { WM_GETTEXT
, sent
|optional
},
1303 { WM_GETTEXT
, sent
|optional
},
1304 { WM_NCCALCSIZE
, sent
|optional
},
1305 { WM_NCPAINT
, sent
|optional
},
1306 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1307 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1308 { WM_ERASEBKGND
, sent
|optional
},
1309 { WM_CTLCOLORDLG
, sent
|optional
|defwinproc
},
1310 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1311 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
1315 /* Calling EndDialog for a custom dialog (32) */
1316 static const struct message WmEndCustomDialogSeq
[] = {
1317 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1318 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1319 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1320 { WM_GETTEXT
, sent
|optional
},
1321 { HCBT_ACTIVATE
, hook
},
1322 { WM_NCACTIVATE
, sent
|wparam
, 0 },
1323 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1324 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1325 { WM_ACTIVATE
, sent
|wparam
, 0 },
1326 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
1327 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1328 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOACTIVATE
|SWP_NOREDRAW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1329 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1330 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1331 { HCBT_SETFOCUS
, hook
},
1332 { WM_KILLFOCUS
, sent
},
1333 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
1334 { WM_IME_SETCONTEXT
, sent
|parent
|wparam
|defwinproc
|optional
, 1 },
1335 { WM_IME_NOTIFY
, sent
|wparam
|optional
, 1 },
1336 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1337 { WM_SETFOCUS
, sent
|parent
|defwinproc
},
1340 /* ShowWindow(SW_SHOW) for a custom dialog (initially invisible) */
1341 static const struct message WmShowCustomDialogSeq
[] = {
1342 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1343 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
1344 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1345 { HCBT_ACTIVATE
, hook
},
1346 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
1348 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
1350 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
1351 { WM_ACTIVATEAPP
, sent
|wparam
|optional
, 1 },
1352 { WM_NCACTIVATE
, sent
},
1353 { WM_ACTIVATE
, sent
|wparam
, 1 },
1354 { WM_GETTEXT
, sent
|optional
},
1356 { WM_KILLFOCUS
, sent
|parent
},
1357 { WM_IME_SETCONTEXT
, sent
|parent
|wparam
|optional
, 0 },
1358 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
1359 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
1360 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1361 { WM_SETFOCUS
, sent
},
1362 { WM_GETDLGCODE
, sent
|defwinproc
|wparam
, 0 },
1363 { WM_NCPAINT
, sent
|wparam
, 1 },
1364 { WM_ERASEBKGND
, sent
},
1365 { WM_CTLCOLORDLG
, sent
|defwinproc
},
1366 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1369 /* Creation and destruction of a modal dialog (32) */
1370 static const struct message WmModalDialogSeq
[] = {
1371 { WM_CANCELMODE
, sent
|parent
},
1372 { HCBT_SETFOCUS
, hook
},
1373 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1374 { WM_KILLFOCUS
, sent
|parent
},
1375 { WM_IME_SETCONTEXT
, sent
|parent
|wparam
|optional
, 0 },
1376 { EVENT_OBJECT_STATECHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1377 { WM_ENABLE
, sent
|parent
|wparam
, 0 },
1378 { HCBT_CREATEWND
, hook
},
1379 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
1380 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1381 { WM_SETFONT
, sent
},
1382 { WM_INITDIALOG
, sent
},
1383 { WM_CHANGEUISTATE
, sent
|optional
},
1384 { WM_UPDATEUISTATE
, sent
|optional
},
1385 { WM_SHOWWINDOW
, sent
},
1386 { HCBT_ACTIVATE
, hook
},
1387 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
1388 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
1389 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
},
1390 { WM_NCACTIVATE
, sent
},
1391 { WM_GETTEXT
, sent
|optional
},
1392 { WM_ACTIVATE
, sent
|wparam
, 1 },
1393 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
1394 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1395 { WM_NCPAINT
, sent
|optional
},
1396 { WM_GETTEXT
, sent
|optional
},
1397 { WM_ERASEBKGND
, sent
|optional
},
1398 { WM_CTLCOLORDLG
, sent
|optional
},
1399 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1400 { WM_GETTEXT
, sent
|optional
},
1401 { WM_NCCALCSIZE
, sent
|optional
},
1402 { WM_NCPAINT
, sent
|optional
},
1403 { WM_GETTEXT
, sent
|optional
},
1404 { WM_ERASEBKGND
, sent
|optional
},
1405 { WM_CTLCOLORDLG
, sent
|optional
},
1406 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1407 { WM_PAINT
, sent
|optional
},
1408 { WM_CTLCOLORBTN
, sent
|optional
},
1409 { WM_GETTITLEBARINFOEX
, sent
|optional
},
1410 { WM_ENTERIDLE
, sent
|parent
|optional
},
1411 { WM_ENTERIDLE
, sent
|parent
|optional
},
1412 { WM_ENTERIDLE
, sent
|parent
|optional
},
1413 { WM_ENTERIDLE
, sent
|parent
|optional
},
1414 { WM_ENTERIDLE
, sent
|parent
|optional
},
1415 { WM_ENTERIDLE
, sent
|parent
|optional
},
1416 { WM_ENTERIDLE
, sent
|parent
|optional
},
1417 { WM_ENTERIDLE
, sent
|parent
|optional
},
1418 { WM_ENTERIDLE
, sent
|parent
|optional
},
1419 { WM_ENTERIDLE
, sent
|parent
|optional
},
1420 { WM_ENTERIDLE
, sent
|parent
|optional
},
1421 { WM_ENTERIDLE
, sent
|parent
|optional
},
1422 { WM_ENTERIDLE
, sent
|parent
|optional
},
1423 { WM_ENTERIDLE
, sent
|parent
|optional
},
1424 { WM_ENTERIDLE
, sent
|parent
|optional
},
1425 { WM_ENTERIDLE
, sent
|parent
|optional
},
1426 { WM_ENTERIDLE
, sent
|parent
|optional
},
1427 { WM_ENTERIDLE
, sent
|parent
|optional
},
1428 { WM_ENTERIDLE
, sent
|parent
|optional
},
1429 { WM_ENTERIDLE
, sent
|parent
|optional
},
1431 { EVENT_OBJECT_STATECHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1432 { WM_ENABLE
, sent
|parent
|wparam
, 1 },
1433 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
1434 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1435 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1436 { WM_GETTEXT
, sent
|optional
},
1437 { HCBT_ACTIVATE
, hook
},
1438 { WM_NCACTIVATE
, sent
|wparam
, 0 },
1439 { WM_GETTEXT
, sent
|optional
},
1440 { WM_ACTIVATE
, sent
|wparam
, 0 },
1441 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
1442 { WM_WINDOWPOSCHANGING
, sent
|optional
},
1443 { WM_WINDOWPOSCHANGED
, sent
|optional
},
1444 { HCBT_SETFOCUS
, hook
},
1445 { WM_IME_SETCONTEXT
, sent
|parent
|wparam
|defwinproc
|optional
, 1 },
1446 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1447 { WM_SETFOCUS
, sent
|parent
|defwinproc
},
1448 { EVENT_SYSTEM_DIALOGEND
, winevent_hook
|wparam
|lparam
, 0, 0 },
1449 { HCBT_DESTROYWND
, hook
},
1450 { 0x0090, sent
|optional
},
1451 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
1452 { WM_DESTROY
, sent
},
1453 { WM_NCDESTROY
, sent
},
1456 /* Creation of a modal dialog that is resized inside WM_INITDIALOG (32) */
1457 static const struct message WmCreateModalDialogResizeSeq
[] = { /* FIXME: add */
1458 /* (inside dialog proc, handling WM_INITDIALOG) */
1459 { WM_WINDOWPOSCHANGING
, sent
|wparam
, 0 },
1460 { WM_NCCALCSIZE
, sent
},
1461 { WM_NCACTIVATE
, sent
|parent
|wparam
, 0 },
1462 { WM_GETTEXT
, sent
|defwinproc
},
1463 { WM_ACTIVATE
, sent
|parent
|wparam
, 0 },
1464 { WM_WINDOWPOSCHANGING
, sent
|wparam
, 0 },
1465 { WM_WINDOWPOSCHANGING
, sent
|parent
},
1466 { WM_NCACTIVATE
, sent
|wparam
, 1 },
1467 { WM_ACTIVATE
, sent
|wparam
, 1 },
1468 { WM_WINDOWPOSCHANGED
, sent
|wparam
, 0 },
1469 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
1470 /* (setting focus) */
1471 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1472 { WM_WINDOWPOSCHANGING
, sent
|wparam
, 0 },
1473 { WM_NCPAINT
, sent
},
1474 { WM_GETTEXT
, sent
|defwinproc
},
1475 { WM_ERASEBKGND
, sent
},
1476 { WM_CTLCOLORDLG
, sent
|defwinproc
},
1477 { WM_WINDOWPOSCHANGED
, sent
|wparam
, 0 },
1479 /* (bunch of WM_CTLCOLOR* for each control) */
1480 { WM_PAINT
, sent
|parent
},
1481 { WM_ENTERIDLE
, sent
|parent
|wparam
, 0 },
1482 { WM_SETCURSOR
, sent
|parent
},
1485 /* SetMenu for NonVisible windows with size change*/
1486 static const struct message WmSetMenuNonVisibleSizeChangeSeq
[] = {
1487 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1488 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1489 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
1490 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
},
1491 { WM_MOVE
, sent
|defwinproc
},
1492 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
1493 { WM_NCCALCSIZE
,sent
|wparam
|optional
, 1 }, /* XP */
1494 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1495 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* XP sends a duplicate */
1496 { WM_GETTEXT
, sent
|optional
},
1497 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
1500 /* SetMenu for NonVisible windows with no size change */
1501 static const struct message WmSetMenuNonVisibleNoSizeChangeSeq
[] = {
1502 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1503 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1504 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1505 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1508 /* SetMenu for Visible windows with size change */
1509 static const struct message WmSetMenuVisibleSizeChangeSeq
[] = {
1510 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1511 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1512 { 0x0093, sent
|defwinproc
|optional
},
1513 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
1514 { WM_NCPAINT
, sent
|optional
}, /* wparam != 1 */
1515 { 0x0093, sent
|defwinproc
|optional
},
1516 { 0x0093, sent
|defwinproc
|optional
},
1517 { 0x0091, sent
|defwinproc
|optional
},
1518 { 0x0092, sent
|defwinproc
|optional
},
1519 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1520 { WM_ERASEBKGND
, sent
|optional
},
1521 { WM_ACTIVATE
, sent
|optional
},
1522 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1523 { WM_MOVE
, sent
|defwinproc
},
1524 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
1525 { 0x0093, sent
|optional
},
1526 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
1527 { 0x0093, sent
|defwinproc
|optional
},
1528 { WM_NCPAINT
, sent
|optional
}, /* wparam != 1 */
1529 { 0x0093, sent
|defwinproc
|optional
},
1530 { 0x0093, sent
|defwinproc
|optional
},
1531 { 0x0091, sent
|defwinproc
|optional
},
1532 { 0x0092, sent
|defwinproc
|optional
},
1533 { WM_ERASEBKGND
, sent
|optional
},
1534 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1535 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* XP sends a duplicate */
1538 /* SetMenu for Visible windows with no size change */
1539 static const struct message WmSetMenuVisibleNoSizeChangeSeq
[] = {
1540 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1541 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1542 { WM_NCPAINT
, sent
|optional
}, /* wparam != 1 */
1543 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1544 { WM_ERASEBKGND
, sent
|optional
},
1545 { WM_ACTIVATE
, sent
|optional
},
1546 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1547 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1550 /* DrawMenuBar for a visible window */
1551 static const struct message WmDrawMenuBarSeq
[] =
1553 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1554 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1555 { 0x0093, sent
|defwinproc
|optional
},
1556 { WM_NCPAINT
, sent
|optional
}, /* wparam != 1 */
1557 { 0x0093, sent
|defwinproc
|optional
},
1558 { 0x0093, sent
|defwinproc
|optional
},
1559 { 0x0091, sent
|defwinproc
|optional
},
1560 { 0x0092, sent
|defwinproc
|optional
},
1561 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1562 { WM_ERASEBKGND
, sent
|optional
},
1563 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1564 { 0x0093, sent
|optional
},
1565 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1569 static const struct message WmSetRedrawFalseSeq
[] =
1571 { WM_SETREDRAW
, sent
|wparam
, 0 },
1575 static const struct message WmSetRedrawTrueSeq
[] =
1577 { WM_SETREDRAW
, sent
|wparam
, 1 },
1581 static const struct message WmEnableWindowSeq_1
[] =
1583 { WM_CANCELMODE
, sent
|wparam
|lparam
, 0, 0 },
1584 { EVENT_OBJECT_STATECHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1585 { HCBT_SETFOCUS
, hook
|optional
},
1586 { WM_KILLFOCUS
, sent
|optional
},
1587 { WM_ENABLE
, sent
|wparam
|lparam
, FALSE
, 0 },
1591 static const struct message WmEnableWindowSeq_2
[] =
1593 { EVENT_OBJECT_STATECHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1594 { WM_ENABLE
, sent
|wparam
|lparam
, TRUE
, 0 },
1598 static const struct message WmGetScrollRangeSeq
[] =
1600 { SBM_GETRANGE
, sent
},
1603 static const struct message WmGetScrollInfoSeq
[] =
1605 { SBM_GETSCROLLINFO
, sent
},
1608 static const struct message WmSetScrollRangeSeq
[] =
1610 /* MSDN claims that Windows sends SBM_SETRANGE message, but win2k SP4
1611 sends SBM_SETSCROLLINFO.
1613 { SBM_SETSCROLLINFO
, sent
},
1616 /* SetScrollRange for a window without a non-client area */
1617 static const struct message WmSetScrollRangeHSeq_empty
[] =
1619 { EVENT_OBJECT_VALUECHANGE
, winevent_hook
|wparam
|lparam
, OBJID_HSCROLL
, 0 },
1622 static const struct message WmSetScrollRangeVSeq_empty
[] =
1624 { EVENT_OBJECT_VALUECHANGE
, winevent_hook
|wparam
|lparam
, OBJID_VSCROLL
, 0 },
1627 static const struct message WmSetScrollRangeHVSeq
[] =
1629 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOSIZE
},
1630 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1631 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1632 { WM_ERASEBKGND
, sent
|optional
},
1633 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1634 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1635 { EVENT_OBJECT_VALUECHANGE
, winevent_hook
|lparam
|optional
, 0/*OBJID_HSCROLL or OBJID_VSCROLL*/, 0 },
1638 /* SetScrollRange for a window with a non-client area */
1639 static const struct message WmSetScrollRangeHV_NC_Seq
[] =
1641 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOSIZE
},
1642 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1643 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
1644 { WM_NCPAINT
, sent
|optional
},
1645 { WM_STYLECHANGING
, sent
|defwinproc
|optional
},
1646 { WM_STYLECHANGED
, sent
|defwinproc
|optional
},
1647 { WM_STYLECHANGING
, sent
|defwinproc
|optional
},
1648 { WM_STYLECHANGED
, sent
|defwinproc
|optional
},
1649 { WM_STYLECHANGING
, sent
|defwinproc
|optional
},
1650 { WM_STYLECHANGED
, sent
|defwinproc
|optional
},
1651 { WM_STYLECHANGING
, sent
|defwinproc
|optional
},
1652 { WM_STYLECHANGED
, sent
|defwinproc
|optional
},
1653 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1654 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1655 { WM_ERASEBKGND
, sent
|optional
},
1656 { WM_CTLCOLORDLG
, sent
|defwinproc
|optional
}, /* sent to a parent of the dialog */
1657 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOCLIENTMOVE
, 0, SWP_NOCLIENTSIZE
},
1658 { WM_SIZE
, sent
|defwinproc
|optional
},
1659 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1660 { EVENT_OBJECT_VALUECHANGE
, winevent_hook
|lparam
|optional
, 0/*OBJID_HSCROLL or OBJID_VSCROLL*/, 0 },
1661 { WM_GETTEXT
, sent
|optional
},
1662 { WM_GETTEXT
, sent
|optional
},
1663 { WM_GETTEXT
, sent
|optional
},
1664 { WM_GETTEXT
, sent
|optional
},
1667 /* test if we receive the right sequence of messages */
1668 /* after calling ShowWindow( SW_SHOWNA) */
1669 static const struct message WmSHOWNAChildInvisParInvis
[] = {
1670 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1673 static const struct message WmSHOWNAChildVisParInvis
[] = {
1674 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1677 static const struct message WmSHOWNAChildVisParVis
[] = {
1678 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1679 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
1682 static const struct message WmSHOWNAChildInvisParVis
[] = {
1683 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1684 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1685 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1686 { WM_ERASEBKGND
, sent
|optional
},
1687 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOACTIVATE
|SWP_NOCLIENTMOVE
},
1690 static const struct message WmSHOWNATopVisible
[] = {
1691 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1692 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
1693 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
1694 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1695 { WM_ERASEBKGND
, sent
|optional
},
1696 { WM_WINDOWPOSCHANGED
, sent
|optional
},
1699 static const struct message WmSHOWNATopInvisible
[] = {
1700 { WM_NOTIFYFORMAT
, sent
|optional
},
1701 { WM_QUERYUISTATE
, sent
|optional
},
1702 { WM_WINDOWPOSCHANGING
, sent
|optional
},
1703 { WM_GETMINMAXINFO
, sent
|optional
},
1704 { WM_NCCALCSIZE
, sent
|optional
},
1705 { WM_WINDOWPOSCHANGED
, sent
|optional
},
1706 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1707 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1708 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1709 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
1710 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1711 { WM_ERASEBKGND
, sent
|optional
},
1712 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1713 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
1714 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
1715 { WM_ERASEBKGND
, sent
|optional
},
1716 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1717 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
1722 static BOOL after_end_dialog
, test_def_id
, paint_loop_done
;
1723 static int sequence_cnt
, sequence_size
;
1724 static struct recvd_message
* sequence
;
1725 static int log_all_parent_messages
;
1726 static CRITICAL_SECTION sequence_cs
;
1728 /* user32 functions */
1729 static HWND (WINAPI
*pGetAncestor
)(HWND
,UINT
);
1730 static BOOL (WINAPI
*pGetMenuInfo
)(HMENU
,LPCMENUINFO
);
1731 static void (WINAPI
*pNotifyWinEvent
)(DWORD
, HWND
, LONG
, LONG
);
1732 static BOOL (WINAPI
*pSetMenuInfo
)(HMENU
,LPCMENUINFO
);
1733 static HWINEVENTHOOK (WINAPI
*pSetWinEventHook
)(DWORD
, DWORD
, HMODULE
, WINEVENTPROC
, DWORD
, DWORD
, DWORD
);
1734 static BOOL (WINAPI
*pTrackMouseEvent
)(TRACKMOUSEEVENT
*);
1735 static BOOL (WINAPI
*pUnhookWinEvent
)(HWINEVENTHOOK
);
1736 static BOOL (WINAPI
*pGetMonitorInfoA
)(HMONITOR
,LPMONITORINFO
);
1737 static HMONITOR (WINAPI
*pMonitorFromPoint
)(POINT
,DWORD
);
1738 static BOOL (WINAPI
*pUpdateLayeredWindow
)(HWND
,HDC
,POINT
*,SIZE
*,HDC
,POINT
*,COLORREF
,BLENDFUNCTION
*,DWORD
);
1739 static UINT_PTR (WINAPI
*pSetSystemTimer
)(HWND
, UINT_PTR
, UINT
, TIMERPROC
);
1740 static UINT_PTR (WINAPI
*pKillSystemTimer
)(HWND
, UINT_PTR
);
1741 /* kernel32 functions */
1742 static BOOL (WINAPI
*pGetCPInfoExA
)(UINT
, DWORD
, LPCPINFOEXA
);
1744 static void init_procs(void)
1746 HMODULE user32
= GetModuleHandleA("user32.dll");
1747 HMODULE kernel32
= GetModuleHandleA("kernel32.dll");
1749 #define GET_PROC(dll, func) \
1750 p ## func = (void*)GetProcAddress(dll, #func); \
1752 trace("GetProcAddress(%s) failed\n", #func); \
1755 GET_PROC(user32
, GetAncestor
)
1756 GET_PROC(user32
, GetMenuInfo
)
1757 GET_PROC(user32
, NotifyWinEvent
)
1758 GET_PROC(user32
, SetMenuInfo
)
1759 GET_PROC(user32
, SetWinEventHook
)
1760 GET_PROC(user32
, TrackMouseEvent
)
1761 GET_PROC(user32
, UnhookWinEvent
)
1762 GET_PROC(user32
, GetMonitorInfoA
)
1763 GET_PROC(user32
, MonitorFromPoint
)
1764 GET_PROC(user32
, UpdateLayeredWindow
)
1765 GET_PROC(user32
, SetSystemTimer
)
1766 GET_PROC(user32
, KillSystemTimer
)
1768 GET_PROC(kernel32
, GetCPInfoExA
)
1773 static const char *get_winpos_flags(UINT flags
)
1775 static char buffer
[300];
1778 #define DUMP(flag) do { if (flags & flag) { strcat( buffer, "|" #flag ); flags &= ~flag; } } while(0)
1779 DUMP( SWP_SHOWWINDOW
);
1780 DUMP( SWP_HIDEWINDOW
);
1781 DUMP( SWP_NOACTIVATE
);
1782 DUMP( SWP_FRAMECHANGED
);
1783 DUMP( SWP_NOCOPYBITS
);
1784 DUMP( SWP_NOOWNERZORDER
);
1785 DUMP( SWP_NOSENDCHANGING
);
1786 DUMP( SWP_DEFERERASE
);
1787 DUMP( SWP_ASYNCWINDOWPOS
);
1788 DUMP( SWP_NOZORDER
);
1789 DUMP( SWP_NOREDRAW
);
1792 DUMP( SWP_NOCLIENTSIZE
);
1793 DUMP( SWP_NOCLIENTMOVE
);
1794 if (flags
) sprintf(buffer
+ strlen(buffer
),"|0x%04x", flags
);
1799 static BOOL
ignore_message( UINT message
)
1801 /* these are always ignored */
1802 return (message
>= 0xc000 ||
1803 message
== WM_GETICON
||
1804 message
== WM_GETOBJECT
||
1805 message
== WM_TIMECHANGE
||
1806 message
== WM_DISPLAYCHANGE
||
1807 message
== WM_DEVICECHANGE
||
1808 message
== WM_DWMNCRENDERINGCHANGED
);
1812 #define add_message(msg) add_message_(__LINE__,msg);
1813 static void add_message_(int line
, const struct recvd_message
*msg
)
1815 struct recvd_message
*seq
;
1817 EnterCriticalSection( &sequence_cs
);
1821 sequence
= HeapAlloc( GetProcessHeap(), 0, sequence_size
* sizeof(*sequence
) );
1823 if (sequence_cnt
== sequence_size
)
1826 sequence
= HeapReAlloc( GetProcessHeap(), 0, sequence
, sequence_size
* sizeof(*sequence
) );
1830 seq
= &sequence
[sequence_cnt
++];
1831 seq
->hwnd
= msg
->hwnd
;
1832 seq
->message
= msg
->message
;
1833 seq
->flags
= msg
->flags
;
1834 seq
->wParam
= msg
->wParam
;
1835 seq
->lParam
= msg
->lParam
;
1837 seq
->descr
= msg
->descr
;
1839 LeaveCriticalSection( &sequence_cs
);
1843 if (msg
->flags
& hook
)
1845 static const char * const CBT_code_name
[10] =
1853 "HCBT_CLICKSKIPPED",
1858 const char *code_name
= (msg
->message
<= HCBT_SETFOCUS
) ? CBT_code_name
[msg
->message
] : "Unknown";
1860 sprintf( seq
->output
, "%s: hook %d (%s) wp %08lx lp %08lx",
1861 msg
->descr
, msg
->message
, code_name
, msg
->wParam
, msg
->lParam
);
1863 else if (msg
->flags
& winevent_hook
)
1865 sprintf( seq
->output
, "%s: winevent %p %08x %08lx %08lx",
1866 msg
->descr
, msg
->hwnd
, msg
->message
, msg
->wParam
, msg
->lParam
);
1870 switch (msg
->message
)
1872 case WM_WINDOWPOSCHANGING
:
1873 case WM_WINDOWPOSCHANGED
:
1875 WINDOWPOS
*winpos
= (WINDOWPOS
*)msg
->lParam
;
1877 sprintf( seq
->output
, "%s: %p WM_WINDOWPOS%s wp %08lx lp %08lx after %p x %d y %d cx %d cy %d flags %s",
1878 msg
->descr
, msg
->hwnd
,
1879 (msg
->message
== WM_WINDOWPOSCHANGING
) ? "CHANGING" : "CHANGED",
1880 msg
->wParam
, msg
->lParam
, winpos
->hwndInsertAfter
,
1881 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
,
1882 get_winpos_flags(winpos
->flags
) );
1884 /* Log only documented flags, win2k uses 0x1000 and 0x2000
1885 * in the high word for internal purposes
1887 seq
->wParam
= winpos
->flags
& 0xffff;
1888 /* We are not interested in the flags that don't match under XP and Win9x */
1889 seq
->wParam
&= ~SWP_NOZORDER
;
1895 DRAW_ITEM_STRUCT di
;
1896 DRAWITEMSTRUCT
*dis
= (DRAWITEMSTRUCT
*)msg
->lParam
;
1898 sprintf( seq
->output
, "%s: %p WM_DRAWITEM: type %x, ctl_id %x, item_id %x, action %x, state %x",
1899 msg
->descr
, msg
->hwnd
, dis
->CtlType
, dis
->CtlID
,
1900 dis
->itemID
, dis
->itemAction
, dis
->itemState
);
1903 di
.u
.item
.type
= dis
->CtlType
;
1904 di
.u
.item
.ctl_id
= dis
->CtlID
;
1905 if (dis
->CtlType
== ODT_LISTBOX
||
1906 dis
->CtlType
== ODT_COMBOBOX
||
1907 dis
->CtlType
== ODT_MENU
)
1908 di
.u
.item
.item_id
= dis
->itemID
;
1909 di
.u
.item
.action
= dis
->itemAction
;
1910 di
.u
.item
.state
= dis
->itemState
;
1912 seq
->lParam
= di
.u
.lp
;
1916 if (msg
->message
>= 0xc000) return; /* ignore registered messages */
1917 sprintf( seq
->output
, "%s: %p %04x wp %08lx lp %08lx",
1918 msg
->descr
, msg
->hwnd
, msg
->message
, msg
->wParam
, msg
->lParam
);
1920 if (msg
->flags
& (sent
|posted
|parent
|defwinproc
|beginpaint
))
1921 sprintf( seq
->output
+ strlen(seq
->output
), " (flags %x)", msg
->flags
);
1926 /* try to make sure pending X events have been processed before continuing */
1927 static void flush_events(void)
1931 int min_timeout
= 100;
1932 DWORD time
= GetTickCount() + diff
;
1936 if (MsgWaitForMultipleObjects( 0, NULL
, FALSE
, min_timeout
, QS_ALLINPUT
) == WAIT_TIMEOUT
) break;
1937 while (PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA( &msg
);
1938 diff
= time
- GetTickCount();
1942 static void flush_sequence(void)
1944 EnterCriticalSection( &sequence_cs
);
1945 HeapFree(GetProcessHeap(), 0, sequence
);
1947 sequence_cnt
= sequence_size
= 0;
1948 LeaveCriticalSection( &sequence_cs
);
1951 static void dump_sequence(const struct message
*expected
, const char *context
, const char *file
, int line
)
1953 const struct recvd_message
*actual
= sequence
;
1954 unsigned int count
= 0;
1956 trace_(file
, line
)("Failed sequence %s:\n", context
);
1957 while (expected
->message
&& actual
->message
)
1959 if (actual
->output
[0])
1961 if (expected
->flags
& hook
)
1963 trace_(file
, line
)( " %u: expected: hook %04x - actual: %s\n",
1964 count
, expected
->message
, actual
->output
);
1966 else if (expected
->flags
& winevent_hook
)
1968 trace_(file
, line
)( " %u: expected: winevent %04x - actual: %s\n",
1969 count
, expected
->message
, actual
->output
);
1971 else if (expected
->flags
& kbd_hook
)
1973 trace_(file
, line
)( " %u: expected: kbd %04x - actual: %s\n",
1974 count
, expected
->message
, actual
->output
);
1978 trace_(file
, line
)( " %u: expected: msg %04x - actual: %s\n",
1979 count
, expected
->message
, actual
->output
);
1983 if (expected
->message
== actual
->message
)
1985 if ((expected
->flags
& defwinproc
) != (actual
->flags
& defwinproc
) &&
1986 (expected
->flags
& optional
))
1988 /* don't match messages if their defwinproc status differs */
1997 /* silently drop winevent messages if there is no support for them */
1998 else if ((expected
->flags
& optional
) || ((expected
->flags
& winevent_hook
) && !hEvent_hook
))
2008 /* optional trailing messages */
2009 while (expected
->message
&& ((expected
->flags
& optional
) ||
2010 ((expected
->flags
& winevent_hook
) && !hEvent_hook
)))
2012 trace_(file
, line
)( " %u: expected: msg %04x - actual: nothing\n", count
, expected
->message
);
2017 if (expected
->message
)
2019 trace_(file
, line
)( " %u: expected: msg %04x - actual: nothing\n", count
, expected
->message
);
2023 while (actual
->message
&& actual
->output
[0])
2025 trace_(file
, line
)( " %u: expected: nothing - actual: %s\n", count
, actual
->output
);
2031 #define ok_sequence( exp, contx, todo) \
2032 ok_sequence_( (exp), (contx), (todo), __FILE__, __LINE__)
2035 static void ok_sequence_(const struct message
*expected_list
, const char *context
, BOOL todo
,
2036 const char *file
, int line
)
2038 static const struct recvd_message end_of_sequence
;
2039 const struct message
*expected
= expected_list
;
2040 const struct recvd_message
*actual
;
2041 int failcount
= 0, dump
= 0;
2042 unsigned int count
= 0;
2044 add_message(&end_of_sequence
);
2048 while (expected
->message
&& actual
->message
)
2050 if (expected
->message
== actual
->message
&&
2051 !((expected
->flags
^ actual
->flags
) & (hook
|winevent_hook
|kbd_hook
)))
2053 if (expected
->flags
& wparam
)
2055 if (((expected
->wParam
^ actual
->wParam
) & ~expected
->wp_mask
) && todo
)
2059 if (strcmp(winetest_platform
, "wine")) dump
++;
2060 ok_( file
, line
) (FALSE
,
2061 "%s: %u: in msg 0x%04x expecting wParam 0x%lx got 0x%lx\n",
2062 context
, count
, expected
->message
, expected
->wParam
, actual
->wParam
);
2067 ok_( file
, line
)( ((expected
->wParam
^ actual
->wParam
) & ~expected
->wp_mask
) == 0,
2068 "%s: %u: in msg 0x%04x expecting wParam 0x%lx got 0x%lx\n",
2069 context
, count
, expected
->message
, expected
->wParam
, actual
->wParam
);
2070 if ((expected
->wParam
^ actual
->wParam
) & ~expected
->wp_mask
) dump
++;
2074 if (expected
->flags
& lparam
)
2076 if (((expected
->lParam
^ actual
->lParam
) & ~expected
->lp_mask
) && todo
)
2080 if (strcmp(winetest_platform
, "wine")) dump
++;
2081 ok_( file
, line
) (FALSE
,
2082 "%s: %u: in msg 0x%04x expecting lParam 0x%lx got 0x%lx\n",
2083 context
, count
, expected
->message
, expected
->lParam
, actual
->lParam
);
2088 ok_( file
, line
)(((expected
->lParam
^ actual
->lParam
) & ~expected
->lp_mask
) == 0,
2089 "%s: %u: in msg 0x%04x expecting lParam 0x%lx got 0x%lx\n",
2090 context
, count
, expected
->message
, expected
->lParam
, actual
->lParam
);
2091 if ((expected
->lParam
^ actual
->lParam
) & ~expected
->lp_mask
) dump
++;
2094 if ((expected
->flags
& optional
) &&
2095 ((expected
->flags
^ actual
->flags
) & (defwinproc
|parent
)))
2097 /* don't match optional messages if their defwinproc or parent status differs */
2102 if ((expected
->flags
& defwinproc
) != (actual
->flags
& defwinproc
) && todo
)
2106 if (strcmp(winetest_platform
, "wine")) dump
++;
2107 ok_( file
, line
) (FALSE
,
2108 "%s: %u: the msg 0x%04x should %shave been sent by DefWindowProc\n",
2109 context
, count
, expected
->message
, (expected
->flags
& defwinproc
) ? "" : "NOT ");
2114 ok_( file
, line
) ((expected
->flags
& defwinproc
) == (actual
->flags
& defwinproc
),
2115 "%s: %u: the msg 0x%04x should %shave been sent by DefWindowProc\n",
2116 context
, count
, expected
->message
, (expected
->flags
& defwinproc
) ? "" : "NOT ");
2117 if ((expected
->flags
& defwinproc
) != (actual
->flags
& defwinproc
)) dump
++;
2120 ok_( file
, line
) ((expected
->flags
& beginpaint
) == (actual
->flags
& beginpaint
),
2121 "%s: %u: the msg 0x%04x should %shave been sent by BeginPaint\n",
2122 context
, count
, expected
->message
, (expected
->flags
& beginpaint
) ? "" : "NOT ");
2123 if ((expected
->flags
& beginpaint
) != (actual
->flags
& beginpaint
)) dump
++;
2125 ok_( file
, line
) ((expected
->flags
& (sent
|posted
)) == (actual
->flags
& (sent
|posted
)),
2126 "%s: %u: the msg 0x%04x should have been %s\n",
2127 context
, count
, expected
->message
, (expected
->flags
& posted
) ? "posted" : "sent");
2128 if ((expected
->flags
& (sent
|posted
)) != (actual
->flags
& (sent
|posted
))) dump
++;
2130 ok_( file
, line
) ((expected
->flags
& parent
) == (actual
->flags
& parent
),
2131 "%s: %u: the msg 0x%04x was expected in %s\n",
2132 context
, count
, expected
->message
, (expected
->flags
& parent
) ? "parent" : "child");
2133 if ((expected
->flags
& parent
) != (actual
->flags
& parent
)) dump
++;
2135 ok_( file
, line
) ((expected
->flags
& hook
) == (actual
->flags
& hook
),
2136 "%s: %u: the msg 0x%04x should have been sent by a hook\n",
2137 context
, count
, expected
->message
);
2138 if ((expected
->flags
& hook
) != (actual
->flags
& hook
)) dump
++;
2140 ok_( file
, line
) ((expected
->flags
& winevent_hook
) == (actual
->flags
& winevent_hook
),
2141 "%s: %u: the msg 0x%04x should have been sent by a winevent hook\n",
2142 context
, count
, expected
->message
);
2143 if ((expected
->flags
& winevent_hook
) != (actual
->flags
& winevent_hook
)) dump
++;
2145 ok_( file
, line
) ((expected
->flags
& kbd_hook
) == (actual
->flags
& kbd_hook
),
2146 "%s: %u: the msg 0x%04x should have been sent by a keyboard hook\n",
2147 context
, count
, expected
->message
);
2148 if ((expected
->flags
& kbd_hook
) != (actual
->flags
& kbd_hook
)) dump
++;
2153 /* silently drop hook messages if there is no support for them */
2154 else if ((expected
->flags
& optional
) ||
2155 ((expected
->flags
& hook
) && !hCBT_hook
) ||
2156 ((expected
->flags
& winevent_hook
) && !hEvent_hook
) ||
2157 ((expected
->flags
& kbd_hook
) && !hKBD_hook
))
2163 if (strcmp(winetest_platform
, "wine")) dump
++;
2164 ok_( file
, line
) (FALSE
, "%s: %u: the msg 0x%04x was expected, but got msg 0x%04x instead\n",
2165 context
, count
, expected
->message
, actual
->message
);
2171 ok_( file
, line
) (FALSE
, "%s: %u: the msg 0x%04x was expected, but got msg 0x%04x instead\n",
2172 context
, count
, expected
->message
, actual
->message
);
2180 /* skip all optional trailing messages */
2181 while (expected
->message
&& ((expected
->flags
& optional
) ||
2182 ((expected
->flags
& hook
) && !hCBT_hook
) ||
2183 ((expected
->flags
& winevent_hook
) && !hEvent_hook
)))
2189 if (expected
->message
|| actual
->message
) {
2191 if (strcmp(winetest_platform
, "wine")) dump
++;
2192 ok_( file
, line
) (FALSE
, "%s: %u: the msg sequence is not complete: expected %04x - actual %04x\n",
2193 context
, count
, expected
->message
, actual
->message
);
2199 if (expected
->message
|| actual
->message
)
2202 ok_( file
, line
) (FALSE
, "%s: %u: the msg sequence is not complete: expected %04x - actual %04x\n",
2203 context
, count
, expected
->message
, actual
->message
);
2206 if( todo
&& !failcount
) /* succeeded yet marked todo */
2208 if (!strcmp(winetest_platform
, "wine")) dump
++;
2209 ok_( file
, line
)( TRUE
, "%s: marked \"todo_wine\" but succeeds\n", context
);
2213 if (dump
) dump_sequence(expected_list
, context
, file
, line
);
2217 #define expect(EXPECTED,GOT) ok((GOT)==(EXPECTED), "Expected %d, got %d\n", (EXPECTED), (GOT))
2219 /******************************** MDI test **********************************/
2221 /* CreateWindow for MDI frame window, initially visible */
2222 static const struct message WmCreateMDIframeSeq
[] = {
2223 { HCBT_CREATEWND
, hook
},
2224 { WM_GETMINMAXINFO
, sent
},
2225 { WM_NCCREATE
, sent
},
2226 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
2227 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
2228 { WM_CREATE
, sent
},
2229 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2230 { WM_NOTIFYFORMAT
, sent
|optional
},
2231 { WM_QUERYUISTATE
, sent
|optional
},
2232 { WM_WINDOWPOSCHANGING
, sent
|optional
},
2233 { WM_GETMINMAXINFO
, sent
|optional
},
2234 { WM_NCCALCSIZE
, sent
|optional
},
2235 { WM_WINDOWPOSCHANGED
, sent
|optional
},
2236 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
2237 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
2238 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2239 { HCBT_ACTIVATE
, hook
},
2240 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
2241 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
2242 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* XP */
2243 { WM_ACTIVATEAPP
, sent
|wparam
|optional
, 1 }, /* Win9x doesn't send it */
2244 { WM_NCACTIVATE
, sent
},
2245 { WM_GETTEXT
, sent
|defwinproc
|optional
},
2246 { WM_ACTIVATE
, sent
|wparam
, 1 },
2247 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* Win9x */
2248 { HCBT_SETFOCUS
, hook
},
2249 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
2250 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
2251 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2252 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
2253 /* Win9x adds SWP_NOZORDER below */
2254 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2255 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 }, /* XP */
2256 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2257 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2261 /* DestroyWindow for MDI frame window, initially visible */
2262 static const struct message WmDestroyMDIframeSeq
[] = {
2263 { HCBT_DESTROYWND
, hook
},
2264 { 0x0090, sent
|optional
},
2265 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2266 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2267 { WM_NCACTIVATE
, sent
|wparam
|optional
, 0 }, /* Win9x */
2268 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2269 { WM_NCACTIVATE
, sent
|wparam
|optional
, 0 }, /* XP */
2270 { WM_ACTIVATE
, sent
|wparam
|optional
, 0 }, /* Win9x */
2271 { WM_ACTIVATEAPP
, sent
|wparam
|optional
, 0 }, /* Win9x */
2272 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
2273 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
2274 { WM_DESTROY
, sent
},
2275 { WM_NCDESTROY
, sent
},
2278 /* CreateWindow for MDI client window, initially visible */
2279 static const struct message WmCreateMDIclientSeq
[] = {
2280 { HCBT_CREATEWND
, hook
},
2281 { WM_NCCREATE
, sent
},
2282 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
2283 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 },
2284 { WM_CREATE
, sent
},
2285 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 },
2286 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2287 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2289 { WM_PARENTNOTIFY
, sent
|wparam
, WM_CREATE
}, /* in MDI frame */
2290 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
2291 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2292 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2293 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2296 /* ShowWindow(SW_SHOW) for MDI client window */
2297 static const struct message WmShowMDIclientSeq
[] = {
2298 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
2299 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2300 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2301 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2304 /* ShowWindow(SW_HIDE) for MDI client window */
2305 static const struct message WmHideMDIclientSeq
[] = {
2306 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
2307 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2308 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* win2000 */
2309 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* XP */
2310 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2313 /* DestroyWindow for MDI client window, initially visible */
2314 static const struct message WmDestroyMDIclientSeq
[] = {
2315 { HCBT_DESTROYWND
, hook
},
2316 { 0x0090, sent
|optional
},
2317 { WM_PARENTNOTIFY
, sent
|wparam
, WM_DESTROY
}, /* in MDI frame */
2318 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
2319 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2320 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2321 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2322 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
2323 { WM_DESTROY
, sent
},
2324 { WM_NCDESTROY
, sent
},
2327 /* CreateWindow for MDI child window, initially visible */
2328 static const struct message WmCreateMDIchildVisibleSeq
[] = {
2329 { HCBT_CREATEWND
, hook
},
2330 { WM_NCCREATE
, sent
},
2331 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
2332 { WM_CREATE
, sent
},
2333 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2334 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2336 /* Win2k sends wparam set to
2337 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2338 * while Win9x doesn't bother to set child window id according to
2339 * CLIENTCREATESTRUCT.idFirstChild
2341 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
2342 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
2343 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2344 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2345 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2346 { WM_MDIREFRESHMENU
, sent
/*|wparam|lparam, 0, 0*/ },
2347 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
2348 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2349 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2351 /* Win9x: message sequence terminates here. */
2353 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 },
2354 { HCBT_SETFOCUS
, hook
}, /* in MDI client */
2355 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2356 { WM_IME_NOTIFY
, sent
|wparam
|optional
, 2 }, /* in MDI client */
2357 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2358 { WM_SETFOCUS
, sent
}, /* in MDI client */
2359 { HCBT_SETFOCUS
, hook
},
2360 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2361 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2362 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
2363 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2364 { WM_SETFOCUS
, sent
|defwinproc
},
2365 { WM_MDIACTIVATE
, sent
|defwinproc
},
2368 /* CreateWindow for MDI child window with invisible parent */
2369 static const struct message WmCreateMDIchildInvisibleParentSeq
[] = {
2370 { HCBT_CREATEWND
, hook
},
2371 { WM_GETMINMAXINFO
, sent
},
2372 { WM_NCCREATE
, sent
},
2373 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
2374 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 },
2375 { WM_CREATE
, sent
},
2376 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2377 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2379 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
2380 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
2381 { WM_MDIREFRESHMENU
, sent
}, /* in MDI client */
2382 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
2383 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2384 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2386 /* Win9x: message sequence terminates here. */
2388 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 },
2389 { HCBT_SETFOCUS
, hook
}, /* in MDI client */
2390 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2391 { WM_IME_NOTIFY
, sent
|wparam
|optional
, 2 }, /* in MDI client */
2392 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2393 { WM_SETFOCUS
, sent
}, /* in MDI client */
2394 { HCBT_SETFOCUS
, hook
},
2395 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2396 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2397 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
2398 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2399 { WM_SETFOCUS
, sent
|defwinproc
},
2400 { WM_MDIACTIVATE
, sent
|defwinproc
},
2403 /* DestroyWindow for MDI child window, initially visible */
2404 static const struct message WmDestroyMDIchildVisibleSeq
[] = {
2405 { HCBT_DESTROYWND
, hook
},
2406 /* Win2k sends wparam set to
2407 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
2408 * while Win9x doesn't bother to set child window id according to
2409 * CLIENTCREATESTRUCT.idFirstChild
2411 { 0x0090, sent
|optional
},
2412 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_DESTROY*/ }, /* in MDI client */
2413 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
2414 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2415 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2416 { WM_ERASEBKGND
, sent
|parent
|optional
},
2417 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2419 /* { WM_DESTROY, sent }
2420 * Win9x: message sequence terminates here.
2423 { HCBT_SETFOCUS
, hook
}, /* set focus to MDI client */
2424 { WM_KILLFOCUS
, sent
},
2425 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
2426 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2427 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2428 { WM_SETFOCUS
, sent
}, /* in MDI client */
2430 { HCBT_SETFOCUS
, hook
}, /* MDI client sets focus back to MDI child */
2431 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2432 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2433 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
2434 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2435 { WM_SETFOCUS
, sent
}, /* in MDI client */
2437 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
2439 { HCBT_SETFOCUS
, hook
}, /* set focus to MDI client */
2440 { WM_KILLFOCUS
, sent
},
2441 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
2442 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2443 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2444 { WM_SETFOCUS
, sent
}, /* in MDI client */
2446 { HCBT_SETFOCUS
, hook
}, /* MDI client sets focus back to MDI child */
2447 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2448 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2449 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
2450 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2451 { WM_SETFOCUS
, sent
}, /* in MDI client */
2453 { WM_DESTROY
, sent
},
2455 { HCBT_SETFOCUS
, hook
}, /* set focus to MDI client */
2456 { WM_KILLFOCUS
, sent
},
2457 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
2458 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2459 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2460 { WM_SETFOCUS
, sent
}, /* in MDI client */
2462 { HCBT_SETFOCUS
, hook
}, /* MDI client sets focus back to MDI child */
2463 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2464 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2465 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
2466 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2467 { WM_SETFOCUS
, sent
}, /* in MDI client */
2469 { WM_NCDESTROY
, sent
},
2472 /* CreateWindow for MDI child window, initially invisible */
2473 static const struct message WmCreateMDIchildInvisibleSeq
[] = {
2474 { HCBT_CREATEWND
, hook
},
2475 { WM_NCCREATE
, sent
},
2476 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
2477 { WM_CREATE
, sent
},
2478 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2479 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2481 /* Win2k sends wparam set to
2482 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2483 * while Win9x doesn't bother to set child window id according to
2484 * CLIENTCREATESTRUCT.idFirstChild
2486 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
2489 /* DestroyWindow for MDI child window, initially invisible */
2490 static const struct message WmDestroyMDIchildInvisibleSeq
[] = {
2491 { HCBT_DESTROYWND
, hook
},
2492 /* Win2k sends wparam set to
2493 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
2494 * while Win9x doesn't bother to set child window id according to
2495 * CLIENTCREATESTRUCT.idFirstChild
2497 { 0x0090, sent
|optional
},
2498 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_DESTROY*/ }, /* in MDI client */
2499 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
2500 { WM_DESTROY
, sent
},
2501 { WM_NCDESTROY
, sent
},
2502 /* FIXME: Wine destroys an icon/title window while Windows doesn't */
2503 { WM_PARENTNOTIFY
, sent
|wparam
|optional
, WM_DESTROY
}, /* MDI client */
2506 /* CreateWindow for the 1st MDI child window, initially visible and maximized */
2507 static const struct message WmCreateMDIchildVisibleMaxSeq1
[] = {
2508 { HCBT_CREATEWND
, hook
},
2509 { WM_NCCREATE
, sent
},
2510 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
2511 { WM_CREATE
, sent
},
2512 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2513 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2515 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
2516 { WM_GETMINMAXINFO
, sent
},
2517 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_STATECHANGED
},
2518 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2519 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
2520 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2522 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2523 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2524 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2525 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2526 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2527 /* Win2k sends wparam set to
2528 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2529 * while Win9x doesn't bother to set child window id according to
2530 * CLIENTCREATESTRUCT.idFirstChild
2532 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
2533 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
2534 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2535 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2536 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2537 { WM_MDIREFRESHMENU
, sent
/*|wparam|lparam, 0, 0*/ },
2538 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
2539 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2540 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
|optional
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
, 0, SWP_FRAMECHANGED
},
2542 /* Win9x: message sequence terminates here. */
2544 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
|optional
, 1 },
2545 { HCBT_SETFOCUS
, hook
|optional
}, /* in MDI client */
2546 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2547 { WM_IME_NOTIFY
, sent
|wparam
|optional
, 2 }, /* in MDI client */
2548 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2549 { WM_SETFOCUS
, sent
|optional
}, /* in MDI client */
2550 { HCBT_SETFOCUS
, hook
|optional
},
2551 { WM_KILLFOCUS
, sent
|optional
}, /* in MDI client */
2552 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2553 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
2554 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2555 { WM_SETFOCUS
, sent
|defwinproc
|optional
},
2556 { WM_MDIACTIVATE
, sent
|defwinproc
|optional
},
2558 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2559 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2560 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2561 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2564 /* CreateWindow for the 2nd MDI child window, initially visible and maximized */
2565 static const struct message WmCreateMDIchildVisibleMaxSeq2
[] = {
2566 /* restore the 1st MDI child */
2567 { WM_SETREDRAW
, sent
|wparam
, 0 },
2568 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWNORMAL
},
2569 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
2570 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2571 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2572 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
2573 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2575 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2576 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2577 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2578 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2579 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2580 { WM_SETREDRAW
, sent
|wparam
, 1 }, /* in the 1st MDI child */
2581 /* create the 2nd MDI child */
2582 { HCBT_CREATEWND
, hook
},
2583 { WM_NCCREATE
, sent
},
2584 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
2585 { WM_CREATE
, sent
},
2586 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2587 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2589 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
2590 { WM_GETMINMAXINFO
, sent
},
2591 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_STATECHANGED
},
2592 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2593 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2594 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
2595 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2597 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2598 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2599 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2600 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2601 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2602 /* Win2k sends wparam set to
2603 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2604 * while Win9x doesn't bother to set child window id according to
2605 * CLIENTCREATESTRUCT.idFirstChild
2607 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
2608 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
2609 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2610 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2611 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2612 { WM_MDIREFRESHMENU
, sent
/*|wparam|lparam, 0, 0*/ },
2613 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
2614 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2616 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 0 }, /* in the 1st MDI child */
2617 { WM_MDIACTIVATE
, sent
|defwinproc
}, /* in the 1st MDI child */
2619 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2621 /* Win9x: message sequence terminates here. */
2623 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 },
2624 { HCBT_SETFOCUS
, hook
},
2625 { WM_KILLFOCUS
, sent
|defwinproc
|optional
}, /* in the 1st MDI child */
2626 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 0 }, /* in the 1st MDI child */
2627 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2628 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2629 { WM_SETFOCUS
, sent
}, /* in MDI client */
2630 { HCBT_SETFOCUS
, hook
},
2631 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2632 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2633 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
2634 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2635 { WM_SETFOCUS
, sent
|defwinproc
},
2637 { WM_MDIACTIVATE
, sent
|defwinproc
},
2639 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2640 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2641 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2642 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2645 /* WM_MDICREATE MDI child window, initially visible and maximized */
2646 static const struct message WmCreateMDIchildVisibleMaxSeq3
[] = {
2647 { WM_MDICREATE
, sent
},
2648 { HCBT_CREATEWND
, hook
},
2649 { WM_NCCREATE
, sent
},
2650 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
2651 { WM_CREATE
, sent
},
2652 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2653 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2655 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
2656 { WM_GETMINMAXINFO
, sent
},
2657 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_STATECHANGED
},
2658 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2659 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
2660 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2663 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2664 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2665 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2666 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2667 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2669 /* Win2k sends wparam set to
2670 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2671 * while Win9x doesn't bother to set child window id according to
2672 * CLIENTCREATESTRUCT.idFirstChild
2674 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
2675 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
2676 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2678 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2680 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2681 { WM_MDIREFRESHMENU
, sent
/*|wparam|lparam, 0, 0*/ },
2682 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
2684 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2685 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2687 /* Win9x: message sequence terminates here. */
2689 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 },
2690 { WM_SETFOCUS
, sent
|optional
}, /* in MDI client */
2691 { HCBT_SETFOCUS
, hook
}, /* in MDI client */
2692 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2693 { WM_IME_NOTIFY
, sent
|wparam
|optional
, 2 },
2694 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
|optional
, OBJID_CLIENT
, 0 },
2695 { WM_SETFOCUS
, sent
|optional
}, /* in MDI client */
2696 { HCBT_SETFOCUS
, hook
|optional
},
2697 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2698 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2699 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
2700 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2701 { WM_SETFOCUS
, sent
|defwinproc
},
2703 { WM_MDIACTIVATE
, sent
|defwinproc
},
2706 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2707 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2708 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2709 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2712 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2713 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2714 { 0x0093, sent
|defwinproc
|optional
},
2715 { 0x0093, sent
|defwinproc
|optional
},
2716 { 0x0093, sent
|defwinproc
|optional
},
2717 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2718 { WM_MOVE
, sent
|defwinproc
},
2719 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2722 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
2723 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2724 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
},
2725 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2728 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
2729 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2730 { 0x0093, sent
|optional
},
2731 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
},
2732 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2734 { 0x0093, sent
|optional
},
2735 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2736 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI client */
2737 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 }, /* XP sends it to MDI frame */
2738 { 0x0093, sent
|defwinproc
|optional
},
2739 { 0x0093, sent
|defwinproc
|optional
},
2740 { 0x0093, sent
|defwinproc
|optional
},
2741 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2742 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* XP sends a duplicate */
2746 /* CreateWindow for the 1st MDI child window, initially invisible and maximized */
2747 static const struct message WmCreateMDIchildInvisibleMaxSeq4
[] = {
2748 { HCBT_CREATEWND
, hook
},
2749 { WM_GETMINMAXINFO
, sent
},
2750 { WM_NCCREATE
, sent
},
2751 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
2752 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
2753 { WM_CREATE
, sent
},
2754 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2755 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2756 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
, 0, SWP_NOZORDER
}, /* MDI frame */
2757 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 }, /* MDI frame */
2758 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
, 0, SWP_NOZORDER
}, /* MDI frame */
2760 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
2761 { WM_GETMINMAXINFO
, sent
},
2762 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_STATECHANGED
},
2763 { WM_GETMINMAXINFO
, sent
|defwinproc
},
2764 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2765 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOREDRAW
|SWP_STATECHANGED
},
2766 { WM_MOVE
, sent
|defwinproc
},
2767 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2769 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2770 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2771 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2772 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2773 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 }, /* MDI child */
2774 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2775 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2776 /* Win2k sends wparam set to
2777 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2778 * while Win9x doesn't bother to set child window id according to
2779 * CLIENTCREATESTRUCT.idFirstChild
2781 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
2784 /* WM_SYSCOMMAND/SC_CLOSE for the 2nd MDI child window, initially visible and maximized */
2785 static const struct message WmDestroyMDIchildVisibleMaxSeq2
[] = {
2786 { WM_SYSCOMMAND
, sent
|wparam
, SC_CLOSE
},
2787 { HCBT_SYSCOMMAND
, hook
},
2788 { WM_CLOSE
, sent
|defwinproc
},
2789 { WM_MDIDESTROY
, sent
}, /* in MDI client */
2791 /* bring the 1st MDI child to top */
2792 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOSIZE
|SWP_NOMOVE
}, /* in the 1st MDI child */
2793 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
}, /* in the 2nd MDI child */
2795 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2797 { WM_CHILDACTIVATE
, sent
|defwinproc
|wparam
|lparam
, 0, 0 }, /* in the 1st MDI child */
2798 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 0 }, /* in the 1st MDI child */
2799 { WM_MDIACTIVATE
, sent
|defwinproc
}, /* in the 1st MDI child */
2801 /* maximize the 1st MDI child */
2802 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
2803 { WM_GETMINMAXINFO
, sent
|defwinproc
},
2804 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
2805 { WM_NCCALCSIZE
, sent
|defwinproc
|wparam
, 1 },
2806 { WM_CHILDACTIVATE
, sent
|defwinproc
|wparam
|lparam
, 0, 0 },
2807 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
2808 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2810 /* restore the 2nd MDI child */
2811 { WM_SETREDRAW
, sent
|defwinproc
|wparam
, 0 },
2812 { HCBT_MINMAX
, hook
|lparam
, 0, SW_NORMALNA
},
2813 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_SHOWWINDOW
|SWP_STATECHANGED
},
2814 { WM_NCCALCSIZE
, sent
|defwinproc
|wparam
, 1 },
2816 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2818 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_SHOWWINDOW
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
2819 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2821 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2823 { WM_SETREDRAW
, sent
|defwinproc
|wparam
, 1 },
2825 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2826 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2827 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2828 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2829 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2831 /* bring the 1st MDI child to top */
2832 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2833 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 },
2834 { HCBT_SETFOCUS
, hook
},
2835 { WM_KILLFOCUS
, sent
|defwinproc
},
2836 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 0 },
2837 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2838 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2839 { WM_SETFOCUS
, sent
}, /* in MDI client */
2840 { HCBT_SETFOCUS
, hook
},
2841 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2842 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2843 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
2844 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2845 { WM_SETFOCUS
, sent
|defwinproc
},
2846 { WM_MDIACTIVATE
, sent
|defwinproc
},
2847 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2849 /* apparently ShowWindow(SW_SHOW) on an MDI client */
2850 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
2851 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2852 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2853 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2854 { WM_MDIREFRESHMENU
, sent
},
2856 { HCBT_DESTROYWND
, hook
},
2857 /* Win2k sends wparam set to
2858 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
2859 * while Win9x doesn't bother to set child window id according to
2860 * CLIENTCREATESTRUCT.idFirstChild
2862 { 0x0090, sent
|defwinproc
|optional
},
2863 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_DESTROY*/ }, /* in MDI client */
2864 { WM_SHOWWINDOW
, sent
|defwinproc
|wparam
, 0 },
2865 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2866 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2867 { WM_ERASEBKGND
, sent
|parent
|optional
},
2868 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2870 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
2871 { WM_DESTROY
, sent
|defwinproc
},
2872 { WM_NCDESTROY
, sent
|defwinproc
},
2875 /* WM_MDIDESTROY for the single MDI child window, initially visible and maximized */
2876 static const struct message WmDestroyMDIchildVisibleMaxSeq1
[] = {
2877 { WM_MDIDESTROY
, sent
}, /* in MDI client */
2878 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
2879 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2880 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2881 { WM_ERASEBKGND
, sent
|parent
|optional
},
2882 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2884 { HCBT_SETFOCUS
, hook
},
2885 { WM_KILLFOCUS
, sent
},
2886 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
2887 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2888 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2889 { WM_SETFOCUS
, sent
}, /* in MDI client */
2890 { HCBT_SETFOCUS
, hook
},
2891 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2892 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2893 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
2894 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2895 { WM_SETFOCUS
, sent
},
2898 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2899 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2900 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2901 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2904 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2905 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2906 { 0x0093, sent
|defwinproc
|optional
},
2907 { 0x0093, sent
|defwinproc
|optional
},
2908 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2909 { WM_MOVE
, sent
|defwinproc
},
2910 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2913 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
2914 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2915 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
},
2916 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2919 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
2920 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2921 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
},
2922 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2925 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2926 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 },
2927 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2928 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2931 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2932 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 },
2933 { 0x0093, sent
|defwinproc
|optional
},
2934 { 0x0093, sent
|defwinproc
|optional
},
2935 { 0x0093, sent
|defwinproc
|optional
},
2936 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2937 { WM_MOVE
, sent
|defwinproc
},
2938 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2941 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
2942 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2943 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
},
2944 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2947 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
},
2948 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 },
2949 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
},
2950 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2951 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2952 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI client */
2954 { 0x0093, sent
|defwinproc
|optional
},
2955 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
|optional
, 1 }, /* XP sends it to MDI frame */
2956 { 0x0093, sent
|defwinproc
|optional
},
2957 { 0x0093, sent
|defwinproc
|optional
},
2958 { 0x0093, sent
|defwinproc
|optional
},
2959 { 0x0093, sent
|optional
},
2961 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2962 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2963 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI client */
2964 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2965 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* XP sends a duplicate */
2968 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2969 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
2970 { 0x0093, sent
|defwinproc
|optional
},
2971 { 0x0093, sent
|defwinproc
|optional
},
2972 { 0x0093, sent
|defwinproc
|optional
},
2973 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2974 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2975 { 0x0093, sent
|optional
},
2977 { WM_NCACTIVATE
, sent
|wparam
, 0 },
2978 { WM_MDIACTIVATE
, sent
},
2980 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWNORMAL
},
2981 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_SHOWWINDOW
|SWP_STATECHANGED
},
2982 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2984 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2986 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2987 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_SHOWWINDOW
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
2988 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2991 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2992 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 },
2993 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2994 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2997 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2998 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2999 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
3000 { WM_MOVE
, sent
|defwinproc
},
3001 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
3004 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
3005 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3006 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
},
3007 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
3008 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
3009 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 }, /* XP */
3010 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI client */
3011 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
3012 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* XP sends a duplicate */
3014 { HCBT_SETFOCUS
, hook
},
3015 { WM_KILLFOCUS
, sent
},
3016 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
3017 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
3018 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
3019 { WM_SETFOCUS
, sent
}, /* in MDI client */
3021 { WM_MDIREFRESHMENU
, sent
}, /* in MDI client */
3023 { HCBT_DESTROYWND
, hook
},
3024 /* Win2k sends wparam set to
3025 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
3026 * while Win9x doesn't bother to set child window id according to
3027 * CLIENTCREATESTRUCT.idFirstChild
3029 { 0x0090, sent
|optional
},
3030 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_DESTROY*/ }, /* in MDI client */
3032 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
3033 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
3034 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
3035 { WM_ERASEBKGND
, sent
|parent
|optional
},
3036 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
3038 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
3039 { WM_DESTROY
, sent
},
3040 { WM_NCDESTROY
, sent
},
3043 /* ShowWindow(SW_MAXIMIZE) for a not visible MDI child window */
3044 static const struct message WmMaximizeMDIchildInvisibleSeq
[] = {
3045 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
3046 { WM_GETMINMAXINFO
, sent
},
3047 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_STATECHANGED
},
3048 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3049 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
3050 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
3052 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
3053 { WM_NCACTIVATE
, sent
|wparam
|optional
|defwinproc
, 1 },
3054 { HCBT_SETFOCUS
, hook
|optional
},
3055 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
3056 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
3057 { WM_SETFOCUS
, sent
|optional
}, /* in MDI client */
3058 { HCBT_SETFOCUS
, hook
|optional
},
3059 { WM_KILLFOCUS
, sent
|optional
}, /* in MDI client */
3060 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
3061 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
3062 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
3063 { WM_SETFOCUS
, sent
|optional
|defwinproc
},
3064 { WM_MDIACTIVATE
, sent
|optional
|defwinproc
},
3065 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
3066 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
3068 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
3069 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3070 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
3071 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
3072 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
3075 /* ShowWindow(SW_MAXIMIZE) for a not visible maximized MDI child window */
3076 static const struct message WmMaximizeMDIchildInvisibleSeq2
[] = {
3077 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
3078 { WM_GETMINMAXINFO
, sent
},
3079 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
},
3080 { WM_GETMINMAXINFO
, sent
|defwinproc
},
3081 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3082 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
3083 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
3085 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
|optional
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
3086 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
|optional
, 1 },
3087 { HCBT_SETFOCUS
, hook
|optional
},
3088 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
3089 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
3090 { WM_SETFOCUS
, sent
|optional
}, /* in MDI client */
3091 { HCBT_SETFOCUS
, hook
|optional
},
3092 { WM_KILLFOCUS
, sent
|optional
}, /* in MDI client */
3093 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
3094 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
3095 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
3096 { WM_SETFOCUS
, sent
|defwinproc
|optional
},
3097 { WM_MDIACTIVATE
, sent
|defwinproc
|optional
},
3098 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
3099 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
3102 /* WM_MDIMAXIMIZE for an MDI child window with invisible parent */
3103 static const struct message WmMaximizeMDIchildInvisibleParentSeq
[] = {
3104 { WM_MDIMAXIMIZE
, sent
}, /* in MDI client */
3105 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
3106 { WM_GETMINMAXINFO
, sent
},
3107 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
3108 { WM_GETMINMAXINFO
, sent
|defwinproc
},
3109 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3110 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* XP doesn't send it */
3111 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
3112 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOREDRAW
|SWP_STATECHANGED
},
3113 { WM_MOVE
, sent
|defwinproc
},
3114 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
3116 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
3117 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 },
3118 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
3119 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
|optional
, 1 },
3120 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI child XP */
3121 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI client XP */
3123 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
3124 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3125 { 0x0093, sent
|defwinproc
|optional
},
3126 { 0x0094, sent
|defwinproc
|optional
},
3127 { 0x0094, sent
|defwinproc
|optional
},
3128 { 0x0094, sent
|defwinproc
|optional
},
3129 { 0x0094, sent
|defwinproc
|optional
},
3130 { 0x0093, sent
|defwinproc
|optional
},
3131 { 0x0093, sent
|defwinproc
|optional
},
3132 { 0x0091, sent
|defwinproc
|optional
},
3133 { 0x0092, sent
|defwinproc
|optional
},
3134 { 0x0092, sent
|defwinproc
|optional
},
3135 { 0x0092, sent
|defwinproc
|optional
},
3136 { 0x0092, sent
|defwinproc
|optional
},
3137 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
3138 { WM_MOVE
, sent
|defwinproc
},
3139 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
3140 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI frame win2000 */
3142 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
3143 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3144 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
},
3145 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
3147 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
},
3148 { WM_GETMINMAXINFO
, sent
|defwinproc
},
3149 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 },
3150 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
},
3151 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
3152 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI child win2000 */
3153 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
|optional
, 1 },
3154 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI child XP */
3155 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI child XP */
3156 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI client XP */
3158 { 0x0093, sent
|optional
},
3159 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
3160 { 0x0093, sent
|defwinproc
|optional
},
3161 { 0x0093, sent
|defwinproc
|optional
},
3162 { 0x0093, sent
|defwinproc
|optional
},
3163 { 0x0091, sent
|defwinproc
|optional
},
3164 { 0x0092, sent
|defwinproc
|optional
},
3165 { 0x0092, sent
|defwinproc
|optional
},
3166 { 0x0092, sent
|defwinproc
|optional
},
3167 { 0x0092, sent
|defwinproc
|optional
},
3168 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI frame XP */
3169 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI frame XP */
3170 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI child XP */
3173 /* ShowWindow(SW_MAXIMIZE) for a visible MDI child window */
3174 static const struct message WmMaximizeMDIchildVisibleSeq
[] = {
3175 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
3176 { WM_GETMINMAXINFO
, sent
},
3177 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
3178 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3179 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
3180 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
3181 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
3183 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
3184 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3185 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
3186 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
3187 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
3190 /* ShowWindow(SW_RESTORE) for a visible maximized MDI child window */
3191 static const struct message WmRestoreMDIchildVisibleSeq
[] = {
3192 { HCBT_MINMAX
, hook
|lparam
, 0, SW_RESTORE
},
3193 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
3194 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3195 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
3196 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
3197 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
3199 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
3200 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3201 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
3202 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
3203 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
3206 /* ShowWindow(SW_RESTORE) for a visible minimized MDI child window */
3207 static const struct message WmRestoreMDIchildVisibleSeq_2
[] = {
3208 { HCBT_MINMAX
, hook
|lparam
, 0, SW_RESTORE
},
3209 { WM_QUERYOPEN
, sent
|wparam
|lparam
, 0, 0 },
3210 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
3211 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3212 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
3213 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
3214 { WM_MOVE
, sent
|defwinproc
},
3215 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
3216 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
3217 { EVENT_SYSTEM_MINIMIZEEND
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
3218 { HCBT_SETFOCUS
, hook
},
3219 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
3220 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
3221 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
3222 { WM_SETFOCUS
, sent
},
3225 /* ShowWindow(SW_MINIMIZE) for a visible restored MDI child window */
3226 static const struct message WmMinimizeMDIchildVisibleSeq
[] = {
3227 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
3228 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
3229 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3230 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
3231 { WM_MOVE
, sent
|defwinproc
},
3232 { WM_SIZE
, sent
|defwinproc
|wparam
|lparam
, SIZE_MINIMIZED
, 0 },
3233 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
|defwinproc
, 0, 0 },
3234 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
3235 { EVENT_SYSTEM_MINIMIZESTART
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
3236 /* FIXME: Wine creates an icon/title window while Windows doesn't */
3237 { WM_PARENTNOTIFY
, sent
|parent
|wparam
|optional
, WM_CREATE
}, /* MDI client */
3240 /* ShowWindow(SW_RESTORE) for a not visible MDI child window */
3241 static const struct message WmRestoreMDIchildInisibleSeq
[] = {
3242 { HCBT_MINMAX
, hook
|lparam
, 0, SW_RESTORE
},
3243 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_STATECHANGED
},
3244 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3245 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
3246 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
3247 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
3248 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
3250 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
3251 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3252 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
3253 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
3254 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
3258 static HWND mdi_client
;
3259 static WNDPROC old_mdi_client_proc
;
3261 static LRESULT WINAPI
mdi_client_hook_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
3263 struct recvd_message msg
;
3265 /* do not log painting messages */
3266 if (message
!= WM_PAINT
&&
3267 message
!= WM_NCPAINT
&&
3268 message
!= WM_SYNCPAINT
&&
3269 message
!= WM_ERASEBKGND
&&
3270 message
!= WM_NCHITTEST
&&
3271 message
!= WM_GETTEXT
&&
3272 message
!= WM_MDIGETACTIVE
&&
3273 !ignore_message( message
))
3276 msg
.message
= message
;
3277 msg
.flags
= sent
|wparam
|lparam
;
3278 msg
.wParam
= wParam
;
3279 msg
.lParam
= lParam
;
3280 msg
.descr
= "mdi client";
3284 return CallWindowProcA(old_mdi_client_proc
, hwnd
, message
, wParam
, lParam
);
3287 static LRESULT WINAPI
mdi_child_wnd_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
3289 static LONG defwndproc_counter
= 0;
3291 struct recvd_message msg
;
3293 /* do not log painting messages */
3294 if (message
!= WM_PAINT
&&
3295 message
!= WM_NCPAINT
&&
3296 message
!= WM_SYNCPAINT
&&
3297 message
!= WM_ERASEBKGND
&&
3298 message
!= WM_NCHITTEST
&&
3299 message
!= WM_GETTEXT
&&
3300 !ignore_message( message
))
3304 case WM_MDIACTIVATE
:
3306 HWND active
, client
= GetParent(hwnd
);
3308 active
= (HWND
)SendMessageA(client
, WM_MDIGETACTIVE
, 0, 0);
3310 if (hwnd
== (HWND
)lParam
) /* if we are being activated */
3311 ok (active
== (HWND
)lParam
, "new active %p != active %p\n", (HWND
)lParam
, active
);
3313 ok (active
== (HWND
)wParam
, "old active %p != active %p\n", (HWND
)wParam
, active
);
3319 msg
.message
= message
;
3320 msg
.flags
= sent
|wparam
|lparam
;
3321 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
3322 msg
.wParam
= wParam
;
3323 msg
.lParam
= lParam
;
3324 msg
.descr
= "mdi child";
3328 defwndproc_counter
++;
3329 ret
= DefMDIChildProcA(hwnd
, message
, wParam
, lParam
);
3330 defwndproc_counter
--;
3335 static LRESULT WINAPI
mdi_frame_wnd_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
3337 static LONG defwndproc_counter
= 0;
3339 struct recvd_message msg
;
3341 /* do not log painting messages */
3342 if (message
!= WM_PAINT
&&
3343 message
!= WM_NCPAINT
&&
3344 message
!= WM_SYNCPAINT
&&
3345 message
!= WM_ERASEBKGND
&&
3346 message
!= WM_NCHITTEST
&&
3347 message
!= WM_GETTEXT
&&
3348 !ignore_message( message
))
3351 msg
.message
= message
;
3352 msg
.flags
= sent
|wparam
|lparam
;
3353 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
3354 msg
.wParam
= wParam
;
3355 msg
.lParam
= lParam
;
3356 msg
.descr
= "mdi frame";
3360 defwndproc_counter
++;
3361 ret
= DefFrameProcA(hwnd
, mdi_client
, message
, wParam
, lParam
);
3362 defwndproc_counter
--;
3367 static BOOL
mdi_RegisterWindowClasses(void)
3372 cls
.lpfnWndProc
= mdi_frame_wnd_proc
;
3375 cls
.hInstance
= GetModuleHandleA(0);
3377 cls
.hCursor
= LoadCursorA(0, (LPCSTR
)IDC_ARROW
);
3378 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
3379 cls
.lpszMenuName
= NULL
;
3380 cls
.lpszClassName
= "MDI_frame_class";
3381 if (!RegisterClassA(&cls
)) return FALSE
;
3383 cls
.lpfnWndProc
= mdi_child_wnd_proc
;
3384 cls
.lpszClassName
= "MDI_child_class";
3385 if (!RegisterClassA(&cls
)) return FALSE
;
3387 if (!GetClassInfoA(0, "MDIClient", &cls
)) assert(0);
3388 old_mdi_client_proc
= cls
.lpfnWndProc
;
3389 cls
.hInstance
= GetModuleHandleA(0);
3390 cls
.lpfnWndProc
= mdi_client_hook_proc
;
3391 cls
.lpszClassName
= "MDI_client_class";
3392 if (!RegisterClassA(&cls
)) assert(0);
3397 static void test_mdi_messages(void)
3399 MDICREATESTRUCTA mdi_cs
;
3400 CLIENTCREATESTRUCT client_cs
;
3401 HWND mdi_frame
, mdi_child
, mdi_child2
, active_child
;
3404 HMENU hMenu
= CreateMenu();
3406 if (!mdi_RegisterWindowClasses()) assert(0);
3410 trace("creating MDI frame window\n");
3411 mdi_frame
= CreateWindowExA(0, "MDI_frame_class", "MDI frame window",
3412 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
|
3413 WS_MAXIMIZEBOX
| WS_VISIBLE
,
3414 100, 100, CW_USEDEFAULT
, CW_USEDEFAULT
,
3415 GetDesktopWindow(), hMenu
,
3416 GetModuleHandleA(0), NULL
);
3418 ok_sequence(WmCreateMDIframeSeq
, "Create MDI frame window", FALSE
);
3420 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3421 ok(GetFocus() == mdi_frame
, "wrong focus window %p\n", GetFocus());
3423 trace("creating MDI client window\n");
3424 GetClientRect(mdi_frame
, &rc
);
3425 client_cs
.hWindowMenu
= 0;
3426 client_cs
.idFirstChild
= MDI_FIRST_CHILD_ID
;
3427 mdi_client
= CreateWindowExA(0, "MDI_client_class",
3429 WS_CHILD
| WS_VISIBLE
| MDIS_ALLCHILDSTYLES
,
3430 rc
.left
, rc
.top
, rc
.right
- rc
.left
, rc
.bottom
- rc
.top
,
3431 mdi_frame
, 0, GetModuleHandleA(0), &client_cs
);
3433 ok_sequence(WmCreateMDIclientSeq
, "Create visible MDI client window", FALSE
);
3435 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3436 ok(GetFocus() == mdi_frame
, "input focus should be on MDI frame not on %p\n", GetFocus());
3438 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3439 ok(!active_child
, "wrong active MDI child %p\n", active_child
);
3440 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
3445 trace("creating invisible MDI child window\n");
3446 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3448 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
3449 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3453 ShowWindow(mdi_child
, SW_SHOWNORMAL
);
3454 ok_sequence(WmShowChildSeq
, "ShowWindow(SW_SHOWNORMAL) MDI child window", FALSE
);
3456 ok(GetWindowLongA(mdi_child
, GWL_STYLE
) & WS_VISIBLE
, "MDI child should be visible\n");
3457 ok(IsWindowVisible(mdi_child
), "MDI child should be visible\n");
3459 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3460 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3462 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3463 ok(!active_child
, "wrong active MDI child %p\n", active_child
);
3464 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
3466 ShowWindow(mdi_child
, SW_HIDE
);
3467 ok_sequence(WmHideChildSeq
, "ShowWindow(SW_HIDE) MDI child window", FALSE
);
3470 ShowWindow(mdi_child
, SW_SHOW
);
3471 ok_sequence(WmShowChildSeq
, "ShowWindow(SW_SHOW) MDI child window", FALSE
);
3473 ok(GetWindowLongA(mdi_child
, GWL_STYLE
) & WS_VISIBLE
, "MDI child should be visible\n");
3474 ok(IsWindowVisible(mdi_child
), "MDI child should be visible\n");
3476 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3477 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3479 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3480 ok(!active_child
, "wrong active MDI child %p\n", active_child
);
3481 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
3483 DestroyWindow(mdi_child
);
3486 trace("creating visible MDI child window\n");
3487 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3488 WS_CHILD
| WS_VISIBLE
,
3489 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
3490 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3492 ok_sequence(WmCreateMDIchildVisibleSeq
, "Create visible MDI child window", FALSE
);
3494 ok(GetWindowLongA(mdi_child
, GWL_STYLE
) & WS_VISIBLE
, "MDI child should be visible\n");
3495 ok(IsWindowVisible(mdi_child
), "MDI child should be visible\n");
3497 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3498 ok(GetFocus() == mdi_child
, "wrong focus window %p\n", GetFocus());
3500 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3501 ok(active_child
== mdi_child
, "wrong active MDI child %p\n", active_child
);
3502 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
3505 DestroyWindow(mdi_child
);
3506 ok_sequence(WmDestroyMDIchildVisibleSeq
, "Destroy visible MDI child window", TRUE
);
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 0
3514 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3515 ok(active_child
== mdi_child
|| /* win2k */
3516 !active_child
, /* win9x */
3517 "wrong active MDI child %p\n", active_child
);
3518 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
3522 trace("creating invisible MDI child window\n");
3523 mdi_child2
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3525 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
3526 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3528 ok_sequence(WmCreateMDIchildInvisibleSeq
, "Create invisible MDI child window", FALSE
);
3530 ok(!(GetWindowLongA(mdi_child2
, GWL_STYLE
) & WS_VISIBLE
), "MDI child should not be visible\n");
3531 ok(!IsWindowVisible(mdi_child2
), "MDI child should not be visible\n");
3533 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3534 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3536 /* Win2k: MDI client still returns a just destroyed child as active
3537 * Win9x: MDI client returns mdi_child2
3539 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3540 ok(active_child
== mdi_child
|| /* win2k */
3541 active_child
== mdi_child2
, /* win9x */
3542 "wrong active MDI child %p\n", active_child
);
3543 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
3546 ShowWindow(mdi_child2
, SW_MAXIMIZE
);
3547 ok_sequence(WmMaximizeMDIchildInvisibleSeq
, "ShowWindow(SW_MAXIMIZE):invisible MDI child", FALSE
);
3549 ok(GetWindowLongA(mdi_child2
, GWL_STYLE
) & WS_VISIBLE
, "MDI child should be visible\n");
3550 ok(IsWindowVisible(mdi_child2
), "MDI child should be visible\n");
3552 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3553 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
3554 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
3557 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3558 ok(GetFocus() == mdi_child2
|| /* win2k */
3559 GetFocus() == 0, /* win9x */
3560 "wrong focus window %p\n", GetFocus());
3565 ShowWindow(mdi_child2
, SW_HIDE
);
3566 ok_sequence(WmHideChildSeq
, "ShowWindow(SW_HIDE):MDI child", FALSE
);
3568 ShowWindow(mdi_child2
, SW_RESTORE
);
3569 ok_sequence(WmRestoreMDIchildInisibleSeq
, "ShowWindow(SW_RESTORE):invisible MDI child", FALSE
);
3572 ok(GetWindowLongA(mdi_child2
, GWL_STYLE
) & WS_VISIBLE
, "MDI child should be visible\n");
3573 ok(IsWindowVisible(mdi_child2
), "MDI child should be visible\n");
3575 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3576 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
3577 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
3583 ShowWindow(mdi_child2
, SW_HIDE
);
3584 ok_sequence(WmHideChildSeq
, "ShowWindow(SW_HIDE):MDI child", FALSE
);
3586 ShowWindow(mdi_child2
, SW_SHOW
);
3587 ok_sequence(WmShowChildSeq
, "ShowWindow(SW_SHOW):MDI child", FALSE
);
3589 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3590 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3592 ShowWindow(mdi_child2
, SW_MAXIMIZE
);
3593 ok_sequence(WmMaximizeMDIchildVisibleSeq
, "ShowWindow(SW_MAXIMIZE):MDI child", FALSE
);
3595 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3596 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3598 ShowWindow(mdi_child2
, SW_RESTORE
);
3599 ok_sequence(WmRestoreMDIchildVisibleSeq
, "ShowWindow(SW_RESTORE):maximized MDI child", FALSE
);
3601 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3602 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3604 ShowWindow(mdi_child2
, SW_MINIMIZE
);
3605 ok_sequence(WmMinimizeMDIchildVisibleSeq
, "ShowWindow(SW_MINIMIZE):MDI child", TRUE
);
3607 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3608 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3610 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3611 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
3612 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
3615 ShowWindow(mdi_child2
, SW_RESTORE
);
3616 ok_sequence(WmRestoreMDIchildVisibleSeq_2
, "ShowWindow(SW_RESTORE):minimized MDI child", FALSE
);
3618 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3619 ok(GetFocus() == mdi_child2
, "wrong focus window %p\n", GetFocus());
3621 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3622 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
3623 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
3629 ShowWindow(mdi_child2
, SW_HIDE
);
3630 ok_sequence(WmHideChildSeq
, "ShowWindow(SW_HIDE):MDI child", FALSE
);
3632 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3633 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3635 DestroyWindow(mdi_child2
);
3636 ok_sequence(WmDestroyMDIchildInvisibleSeq
, "Destroy invisible MDI child window", FALSE
);
3638 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3639 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3641 /* test for maximized MDI children */
3642 trace("creating maximized visible MDI child window 1\n");
3643 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3644 WS_CHILD
| WS_VISIBLE
| WS_MAXIMIZEBOX
| WS_MAXIMIZE
,
3645 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
3646 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3648 ok_sequence(WmCreateMDIchildVisibleMaxSeq1
, "Create maximized visible 1st MDI child window", TRUE
);
3649 ok(IsZoomed(mdi_child
), "1st MDI child should be maximized\n");
3651 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3652 ok(GetFocus() == mdi_child
|| /* win2k */
3653 GetFocus() == 0, /* win9x */
3654 "wrong focus window %p\n", GetFocus());
3656 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3657 ok(active_child
== mdi_child
, "wrong active MDI child %p\n", active_child
);
3658 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
3661 trace("creating maximized visible MDI child window 2\n");
3662 mdi_child2
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3663 WS_CHILD
| WS_VISIBLE
| WS_MAXIMIZEBOX
| WS_MAXIMIZE
,
3664 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
3665 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3667 ok_sequence(WmCreateMDIchildVisibleMaxSeq2
, "Create maximized visible 2nd MDI child 2 window", TRUE
);
3668 ok(IsZoomed(mdi_child2
), "2nd MDI child should be maximized\n");
3669 ok(!IsZoomed(mdi_child
), "1st MDI child should NOT be maximized\n");
3671 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3672 ok(GetFocus() == mdi_child2
, "wrong focus window %p\n", GetFocus());
3674 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3675 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
3676 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
3679 trace("destroying maximized visible MDI child window 2\n");
3680 DestroyWindow(mdi_child2
);
3681 ok_sequence(WmDestroyMDIchildVisibleSeq
, "Destroy visible MDI child window", TRUE
);
3683 ok(!IsZoomed(mdi_child
), "1st MDI child should NOT be maximized\n");
3685 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3686 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3688 /* Win2k: MDI client still returns a just destroyed child as active
3689 * Win9x: MDI client returns 0
3691 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3692 ok(active_child
== mdi_child2
|| /* win2k */
3693 !active_child
, /* win9x */
3694 "wrong active MDI child %p\n", active_child
);
3697 ShowWindow(mdi_child
, SW_MAXIMIZE
);
3698 ok(IsZoomed(mdi_child
), "1st MDI child should be maximized\n");
3701 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3702 ok(GetFocus() == mdi_child
, "wrong focus window %p\n", GetFocus());
3704 trace("re-creating maximized visible MDI child window 2\n");
3705 mdi_child2
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3706 WS_CHILD
| WS_VISIBLE
| WS_MAXIMIZEBOX
| WS_MAXIMIZE
,
3707 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
3708 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3710 ok_sequence(WmCreateMDIchildVisibleMaxSeq2
, "Create maximized visible 2nd MDI child 2 window", TRUE
);
3711 ok(IsZoomed(mdi_child2
), "2nd MDI child should be maximized\n");
3712 ok(!IsZoomed(mdi_child
), "1st MDI child should NOT be maximized\n");
3714 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3715 ok(GetFocus() == mdi_child2
, "wrong focus window %p\n", GetFocus());
3717 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3718 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
3719 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
3722 SendMessageA(mdi_child2
, WM_SYSCOMMAND
, SC_CLOSE
, 0);
3723 ok_sequence(WmDestroyMDIchildVisibleMaxSeq2
, "WM_SYSCOMMAND/SC_CLOSE on a visible maximized MDI child window", TRUE
);
3724 ok(!IsWindow(mdi_child2
), "MDI child 2 should be destroyed\n");
3726 ok(IsZoomed(mdi_child
), "1st MDI child should be maximized\n");
3727 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3728 ok(GetFocus() == mdi_child
, "wrong focus window %p\n", GetFocus());
3730 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3731 ok(active_child
== mdi_child
, "wrong active MDI child %p\n", active_child
);
3732 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
3735 DestroyWindow(mdi_child
);
3736 ok_sequence(WmDestroyMDIchildVisibleSeq
, "Destroy visible MDI child window", TRUE
);
3738 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3739 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3741 /* Win2k: MDI client still returns a just destroyed child as active
3742 * Win9x: MDI client returns 0
3744 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3745 ok(active_child
== mdi_child
|| /* win2k */
3746 !active_child
, /* win9x */
3747 "wrong active MDI child %p\n", active_child
);
3750 trace("creating maximized invisible MDI child window\n");
3751 mdi_child2
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3752 WS_CHILD
| WS_MAXIMIZE
| WS_CAPTION
| WS_THICKFRAME
,
3753 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
3754 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3756 ok_sequence(WmCreateMDIchildInvisibleMaxSeq4
, "Create maximized invisible MDI child window", FALSE
);
3757 ok(IsZoomed(mdi_child2
), "MDI child should be maximized\n");
3758 ok(!(GetWindowLongA(mdi_child2
, GWL_STYLE
) & WS_VISIBLE
), "MDI child should be not visible\n");
3759 ok(!IsWindowVisible(mdi_child2
), "MDI child should be not visible\n");
3761 /* Win2k: MDI client still returns a just destroyed child as active
3762 * Win9x: MDI client returns 0
3764 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3765 ok(active_child
== mdi_child
|| /* win2k */
3766 !active_child
|| active_child
== mdi_child2
, /* win9x */
3767 "wrong active MDI child %p\n", active_child
);
3770 trace("call ShowWindow(mdi_child, SW_MAXIMIZE)\n");
3771 ShowWindow(mdi_child2
, SW_MAXIMIZE
);
3772 ok_sequence(WmMaximizeMDIchildInvisibleSeq2
, "ShowWindow(SW_MAXIMIZE):invisible maximized MDI child", FALSE
);
3773 ok(IsZoomed(mdi_child2
), "MDI child should be maximized\n");
3774 ok(GetWindowLongA(mdi_child2
, GWL_STYLE
) & WS_VISIBLE
, "MDI child should be visible\n");
3775 ok(IsWindowVisible(mdi_child2
), "MDI child should be visible\n");
3777 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3778 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
3779 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
3782 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child2
, 0);
3785 /* end of test for maximized MDI children */
3788 trace("creating maximized visible MDI child window 1(Switch test)\n");
3789 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3790 WS_CHILD
| WS_VISIBLE
| WS_MAXIMIZEBOX
| WS_MAXIMIZE
,
3791 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
3792 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3794 ok_sequence(WmCreateMDIchildVisibleMaxSeq1
, "Create maximized visible 1st MDI child window(Switch test)", TRUE
);
3795 ok(IsZoomed(mdi_child
), "1st MDI child should be maximized(Switch test)\n");
3797 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p(Switch test)\n", GetActiveWindow());
3798 ok(GetFocus() == mdi_child
|| /* win2k */
3799 GetFocus() == 0, /* win9x */
3800 "wrong focus window %p(Switch test)\n", GetFocus());
3802 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3803 ok(active_child
== mdi_child
, "wrong active MDI child %p(Switch test)\n", active_child
);
3804 ok(zoomed
, "wrong zoomed state %d(Switch test)\n", zoomed
);
3807 trace("creating maximized visible MDI child window 2(Switch test)\n");
3808 mdi_child2
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3809 WS_CHILD
| WS_VISIBLE
| WS_MAXIMIZEBOX
| WS_MAXIMIZE
,
3810 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
3811 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3813 ok_sequence(WmCreateMDIchildVisibleMaxSeq2
, "Create maximized visible 2nd MDI child window (Switch test)", TRUE
);
3815 ok(IsZoomed(mdi_child2
), "2nd MDI child should be maximized(Switch test)\n");
3816 ok(!IsZoomed(mdi_child
), "1st MDI child should NOT be maximized(Switch test)\n");
3818 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p(Switch test)\n", GetActiveWindow());
3819 ok(GetFocus() == mdi_child2
, "wrong focus window %p(Switch test)\n", GetFocus());
3821 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3822 ok(active_child
== mdi_child2
, "wrong active MDI child %p(Switch test)\n", active_child
);
3823 ok(zoomed
, "wrong zoomed state %d(Switch test)\n", zoomed
);
3826 trace("Switch child window.\n");
3827 SendMessageA(mdi_client
, WM_MDIACTIVATE
, (WPARAM
)mdi_child
, 0);
3828 ok_sequence(WmSwitchChild
, "Child did not switch correctly", TRUE
);
3829 trace("end of test for switch maximized MDI children\n");
3832 /* Prepare for switching test of not maximized MDI children */
3833 ShowWindow( mdi_child
, SW_NORMAL
);
3834 ok(!IsZoomed(mdi_child
), "wrong zoomed state for %p(Switch test)\n", mdi_child
);
3835 ok(!IsZoomed(mdi_child2
), "wrong zoomed state for %p(Switch test)\n", mdi_child2
);
3836 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, 0);
3837 ok(active_child
== mdi_child
, "wrong active MDI child %p(Switch test)\n", active_child
);
3840 SendMessageA(mdi_client
, WM_MDIACTIVATE
, (WPARAM
)mdi_child2
, 0);
3841 ok_sequence(WmSwitchNotMaximizedChild
, "Not maximized child did not switch correctly", FALSE
);
3842 trace("end of test for switch not maximized MDI children\n");
3845 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
3848 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child2
, 0);
3853 /* end of tests for switch maximized/not maximized MDI children */
3855 mdi_cs
.szClass
= "MDI_child_Class";
3856 mdi_cs
.szTitle
= "MDI child";
3857 mdi_cs
.hOwner
= GetModuleHandleA(0);
3860 mdi_cs
.cx
= CW_USEDEFAULT
;
3861 mdi_cs
.cy
= CW_USEDEFAULT
;
3862 mdi_cs
.style
= WS_CHILD
| WS_SYSMENU
| WS_VISIBLE
| WS_MAXIMIZEBOX
| WS_MAXIMIZE
;
3864 mdi_child
= (HWND
)SendMessageA(mdi_client
, WM_MDICREATE
, 0, (LPARAM
)&mdi_cs
);
3865 ok(mdi_child
!= 0, "MDI child creation failed\n");
3866 ok_sequence(WmCreateMDIchildVisibleMaxSeq3
, "WM_MDICREATE for maximized visible MDI child window", TRUE
);
3868 ok(GetMenuItemID(hMenu
, GetMenuItemCount(hMenu
) - 1) == SC_CLOSE
, "SC_CLOSE menu item not found\n");
3870 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3871 ok(active_child
== mdi_child
, "wrong active MDI child %p\n", active_child
);
3873 ok(IsZoomed(mdi_child
), "MDI child should be maximized\n");
3874 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3875 ok(GetFocus() == mdi_child
, "wrong focus window %p\n", GetFocus());
3877 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3878 ok(active_child
== mdi_child
, "wrong active MDI child %p\n", active_child
);
3879 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
3882 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
3883 ok_sequence(WmDestroyMDIchildVisibleMaxSeq1
, "Destroy visible maximized MDI child window", TRUE
);
3885 ok(!IsWindow(mdi_child
), "MDI child should be destroyed\n");
3886 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3887 ok(!active_child
, "wrong active MDI child %p\n", active_child
);
3892 DestroyWindow(mdi_client
);
3893 ok_sequence(WmDestroyMDIclientSeq
, "Destroy MDI client window", FALSE
);
3895 /* test maximization of MDI child with invisible parent */
3896 client_cs
.hWindowMenu
= 0;
3897 mdi_client
= CreateWindowA("MDI_client_class",
3899 WS_CHILD
| WS_CLIPCHILDREN
| WS_VSCROLL
| WS_HSCROLL
| WS_VISIBLE
,
3901 mdi_frame
, 0, GetModuleHandleA(0), &client_cs
);
3902 ok_sequence(WmCreateMDIclientSeq
, "Create MDI client window", FALSE
);
3904 ShowWindow(mdi_client
, SW_HIDE
);
3905 ok_sequence(WmHideMDIclientSeq
, "Hide MDI client window", FALSE
);
3907 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3908 WS_CHILD
| WS_CLIPCHILDREN
| WS_VSCROLL
| WS_HSCROLL
,
3910 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3911 ok_sequence(WmCreateMDIchildInvisibleParentSeq
, "Create MDI child window with invisible parent", FALSE
);
3913 SendMessageA(mdi_client
, WM_MDIMAXIMIZE
, (WPARAM
) mdi_child
, 0);
3914 ok_sequence(WmMaximizeMDIchildInvisibleParentSeq
, "Maximize MDI child window with invisible parent", TRUE
);
3915 zoomed
= IsZoomed(mdi_child
);
3916 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
3918 ShowWindow(mdi_client
, SW_SHOW
);
3919 ok_sequence(WmShowMDIclientSeq
, "Show MDI client window", FALSE
);
3921 DestroyWindow(mdi_child
);
3922 ok_sequence(WmDestroyMDIchildVisibleSeq
, "Destroy visible maximized MDI child window", TRUE
);
3924 /* end of test for maximization of MDI child with invisible parent */
3926 DestroyWindow(mdi_client
);
3927 ok_sequence(WmDestroyMDIclientSeq
, "Destroy MDI client window", FALSE
);
3929 DestroyWindow(mdi_frame
);
3930 ok_sequence(WmDestroyMDIframeSeq
, "Destroy MDI frame window", FALSE
);
3932 /************************* End of MDI test **********************************/
3934 static void test_WM_SETREDRAW(HWND hwnd
)
3936 DWORD style
= GetWindowLongA(hwnd
, GWL_STYLE
);
3941 SendMessageA(hwnd
, WM_SETREDRAW
, FALSE
, 0);
3942 ok_sequence(WmSetRedrawFalseSeq
, "SetRedraw:FALSE", FALSE
);
3944 ok(!(GetWindowLongA(hwnd
, GWL_STYLE
) & WS_VISIBLE
), "WS_VISIBLE should NOT be set\n");
3945 ok(!IsWindowVisible(hwnd
), "IsWindowVisible() should return FALSE\n");
3948 SendMessageA(hwnd
, WM_SETREDRAW
, TRUE
, 0);
3949 ok_sequence(WmSetRedrawTrueSeq
, "SetRedraw:TRUE", FALSE
);
3951 ok(GetWindowLongA(hwnd
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
3952 ok(IsWindowVisible(hwnd
), "IsWindowVisible() should return TRUE\n");
3954 /* restore original WS_VISIBLE state */
3955 SetWindowLongA(hwnd
, GWL_STYLE
, style
);
3961 static INT_PTR CALLBACK
TestModalDlgProcA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
3963 struct recvd_message msg
;
3965 if (ignore_message( message
)) return 0;
3971 case WM_NCMOUSEMOVE
:
3972 case WM_NCMOUSELEAVE
:
3980 msg
.message
= message
;
3981 msg
.flags
= sent
|wparam
|lparam
;
3982 msg
.wParam
= wParam
;
3983 msg
.lParam
= lParam
;
3984 msg
.descr
= "dialog";
3987 if (message
== WM_INITDIALOG
) SetTimer( hwnd
, 1, 100, NULL
);
3988 if (message
== WM_TIMER
) EndDialog( hwnd
, 0 );
3992 static void test_hv_scroll_1(HWND hwnd
, INT ctl
, DWORD clear
, DWORD set
, INT min
, INT max
)
3994 DWORD style
, exstyle
;
3998 exstyle
= GetWindowLongA(hwnd
, GWL_EXSTYLE
);
3999 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
4000 /* do not be confused by WS_DLGFRAME set */
4001 if ((style
& WS_CAPTION
) == WS_CAPTION
) style
&= ~WS_CAPTION
;
4003 if (clear
) ok(style
& clear
, "style %08x should be set\n", clear
);
4004 if (set
) ok(!(style
& set
), "style %08x should not be set\n", set
);
4006 ret
= SetScrollRange(hwnd
, ctl
, min
, max
, FALSE
);
4007 ok( ret
, "SetScrollRange(%d) error %d\n", ctl
, GetLastError());
4008 if ((style
& (WS_DLGFRAME
| WS_BORDER
| WS_THICKFRAME
)) || (exstyle
& WS_EX_DLGMODALFRAME
))
4009 ok_sequence(WmSetScrollRangeHV_NC_Seq
, "SetScrollRange(SB_HORZ/SB_VERT) NC", FALSE
);
4011 ok_sequence(WmSetScrollRangeHVSeq
, "SetScrollRange(SB_HORZ/SB_VERT)", FALSE
);
4013 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
4014 if (set
) ok(style
& set
, "style %08x should be set\n", set
);
4015 if (clear
) ok(!(style
& clear
), "style %08x should not be set\n", clear
);
4017 /* a subsequent call should do nothing */
4018 ret
= SetScrollRange(hwnd
, ctl
, min
, max
, FALSE
);
4019 ok( ret
, "SetScrollRange(%d) error %d\n", ctl
, GetLastError());
4020 ok_sequence(WmEmptySeq
, "SetScrollRange(SB_HORZ/SB_VERT) empty sequence", FALSE
);
4024 ret
= GetScrollRange(hwnd
, ctl
, &xmin
, &xmax
);
4025 ok( ret
, "GetScrollRange(%d) error %d\n", ctl
, GetLastError());
4026 ok_sequence(WmEmptySeq
, "GetScrollRange(SB_HORZ/SB_VERT) empty sequence", FALSE
);
4027 ok(xmin
== min
, "unexpected min scroll value %d\n", xmin
);
4028 ok(xmax
== max
, "unexpected max scroll value %d\n", xmax
);
4031 static void test_hv_scroll_2(HWND hwnd
, INT ctl
, DWORD clear
, DWORD set
, INT min
, INT max
)
4033 DWORD style
, exstyle
;
4037 exstyle
= GetWindowLongA(hwnd
, GWL_EXSTYLE
);
4038 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
4039 /* do not be confused by WS_DLGFRAME set */
4040 if ((style
& WS_CAPTION
) == WS_CAPTION
) style
&= ~WS_CAPTION
;
4042 if (clear
) ok(style
& clear
, "style %08x should be set\n", clear
);
4043 if (set
) ok(!(style
& set
), "style %08x should not be set\n", set
);
4045 si
.cbSize
= sizeof(si
);
4046 si
.fMask
= SIF_RANGE
;
4049 SetScrollInfo(hwnd
, ctl
, &si
, TRUE
);
4050 if ((style
& (WS_DLGFRAME
| WS_BORDER
| WS_THICKFRAME
)) || (exstyle
& WS_EX_DLGMODALFRAME
))
4051 ok_sequence(WmSetScrollRangeHV_NC_Seq
, "SetScrollInfo(SB_HORZ/SB_VERT) NC", FALSE
);
4053 ok_sequence(WmSetScrollRangeHVSeq
, "SetScrollInfo(SB_HORZ/SB_VERT)", FALSE
);
4055 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
4056 if (set
) ok(style
& set
, "style %08x should be set\n", set
);
4057 if (clear
) ok(!(style
& clear
), "style %08x should not be set\n", clear
);
4059 /* a subsequent call should do nothing */
4060 SetScrollInfo(hwnd
, ctl
, &si
, TRUE
);
4061 if (style
& WS_HSCROLL
)
4062 ok_sequence(WmSetScrollRangeHSeq_empty
, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE
);
4063 else if (style
& WS_VSCROLL
)
4064 ok_sequence(WmSetScrollRangeVSeq_empty
, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE
);
4066 ok_sequence(WmEmptySeq
, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE
);
4068 si
.fMask
= SIF_PAGE
;
4070 SetScrollInfo(hwnd
, ctl
, &si
, FALSE
);
4071 ok_sequence(WmEmptySeq
, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE
);
4075 SetScrollInfo(hwnd
, ctl
, &si
, FALSE
);
4076 ok_sequence(WmEmptySeq
, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE
);
4078 si
.fMask
= SIF_RANGE
;
4079 si
.nMin
= 0xdeadbeef;
4080 si
.nMax
= 0xdeadbeef;
4081 ret
= GetScrollInfo(hwnd
, ctl
, &si
);
4082 ok( ret
, "GetScrollInfo error %d\n", GetLastError());
4083 ok_sequence(WmEmptySeq
, "GetScrollRange(SB_HORZ/SB_VERT) empty sequence", FALSE
);
4084 ok(si
.nMin
== min
, "unexpected min scroll value %d\n", si
.nMin
);
4085 ok(si
.nMax
== max
, "unexpected max scroll value %d\n", si
.nMax
);
4088 /* Win9x sends WM_USER+xxx while and NT versions send SBM_xxx messages */
4089 static void test_scroll_messages(HWND hwnd
)
4100 ret
= GetScrollRange(hwnd
, SB_CTL
, &min
, &max
);
4101 ok( ret
, "GetScrollRange error %d\n", GetLastError());
4102 if (sequence
->message
!= WmGetScrollRangeSeq
[0].message
)
4103 trace("GetScrollRange(SB_CTL) generated unknown message %04x\n", sequence
->message
);
4104 /* values of min and max are undefined */
4107 ret
= SetScrollRange(hwnd
, SB_CTL
, 10, 150, FALSE
);
4108 ok( ret
, "SetScrollRange error %d\n", GetLastError());
4109 if (sequence
->message
!= WmSetScrollRangeSeq
[0].message
)
4110 trace("SetScrollRange(SB_CTL) generated unknown message %04x\n", sequence
->message
);
4115 ret
= GetScrollRange(hwnd
, SB_CTL
, &min
, &max
);
4116 ok( ret
, "GetScrollRange error %d\n", GetLastError());
4117 if (sequence
->message
!= WmGetScrollRangeSeq
[0].message
)
4118 trace("GetScrollRange(SB_CTL) generated unknown message %04x\n", sequence
->message
);
4119 /* values of min and max are undefined */
4122 si
.cbSize
= sizeof(si
);
4123 si
.fMask
= SIF_RANGE
;
4126 SetScrollInfo(hwnd
, SB_CTL
, &si
, FALSE
);
4127 if (sequence
->message
!= WmSetScrollRangeSeq
[0].message
)
4128 trace("SetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence
->message
);
4131 si
.fMask
= SIF_PAGE
;
4133 SetScrollInfo(hwnd
, SB_CTL
, &si
, FALSE
);
4134 if (sequence
->message
!= WmSetScrollRangeSeq
[0].message
)
4135 trace("SetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence
->message
);
4140 SetScrollInfo(hwnd
, SB_CTL
, &si
, FALSE
);
4141 if (sequence
->message
!= WmSetScrollRangeSeq
[0].message
)
4142 trace("SetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence
->message
);
4145 si
.fMask
= SIF_RANGE
;
4146 si
.nMin
= 0xdeadbeef;
4147 si
.nMax
= 0xdeadbeef;
4148 ret
= GetScrollInfo(hwnd
, SB_CTL
, &si
);
4149 ok( ret
, "GetScrollInfo error %d\n", GetLastError());
4150 if (sequence
->message
!= WmGetScrollInfoSeq
[0].message
)
4151 trace("GetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence
->message
);
4152 /* values of min and max are undefined */
4155 /* set WS_HSCROLL */
4156 test_hv_scroll_1(hwnd
, SB_HORZ
, 0, WS_HSCROLL
, 10, 150);
4157 /* clear WS_HSCROLL */
4158 test_hv_scroll_1(hwnd
, SB_HORZ
, WS_HSCROLL
, 0, 0, 0);
4160 /* set WS_HSCROLL */
4161 test_hv_scroll_2(hwnd
, SB_HORZ
, 0, WS_HSCROLL
, 10, 150);
4162 /* clear WS_HSCROLL */
4163 test_hv_scroll_2(hwnd
, SB_HORZ
, WS_HSCROLL
, 0, 0, 0);
4165 /* set WS_VSCROLL */
4166 test_hv_scroll_1(hwnd
, SB_VERT
, 0, WS_VSCROLL
, 10, 150);
4167 /* clear WS_VSCROLL */
4168 test_hv_scroll_1(hwnd
, SB_VERT
, WS_VSCROLL
, 0, 0, 0);
4170 /* set WS_VSCROLL */
4171 test_hv_scroll_2(hwnd
, SB_VERT
, 0, WS_VSCROLL
, 10, 150);
4172 /* clear WS_VSCROLL */
4173 test_hv_scroll_2(hwnd
, SB_VERT
, WS_VSCROLL
, 0, 0, 0);
4176 static void test_showwindow(void)
4181 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW
,
4182 100, 100, 200, 200, 0, 0, 0, NULL
);
4183 ok (hwnd
!= 0, "Failed to create overlapped window\n");
4184 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
4185 0, 0, 10, 10, hwnd
, 0, 0, NULL
);
4186 ok (hchild
!= 0, "Failed to create child\n");
4189 /* ShowWindow( SW_SHOWNA) for invisible top level window */
4190 trace("calling ShowWindow( SW_SHOWNA) for invisible top level window\n");
4191 ok( ShowWindow(hwnd
, SW_SHOWNA
) == FALSE
, "ShowWindow: window was visible\n" );
4192 ok_sequence(WmSHOWNATopInvisible
, "ShowWindow(SW_SHOWNA) on invisible top level window", FALSE
);
4194 /* ShowWindow( SW_SHOWNA) for now visible top level window */
4195 trace("calling ShowWindow( SW_SHOWNA) for now visible top level window\n");
4196 ok( ShowWindow(hwnd
, SW_SHOWNA
) != FALSE
, "ShowWindow: window was invisible\n" );
4197 ok_sequence(WmSHOWNATopVisible
, "ShowWindow(SW_SHOWNA) on visible top level window", FALSE
);
4198 /* back to invisible */
4199 ShowWindow(hchild
, SW_HIDE
);
4200 ShowWindow(hwnd
, SW_HIDE
);
4202 /* ShowWindow(SW_SHOWNA) with child and parent invisible */
4203 trace("calling ShowWindow( SW_SHOWNA) for invisible child with invisible parent\n");
4204 ok( ShowWindow(hchild
, SW_SHOWNA
) == FALSE
, "ShowWindow: window was visible\n" );
4205 ok_sequence(WmSHOWNAChildInvisParInvis
, "ShowWindow(SW_SHOWNA) invisible child and parent", FALSE
);
4206 /* ShowWindow(SW_SHOWNA) with child visible and parent invisible */
4207 ok( ShowWindow(hchild
, SW_SHOW
) != FALSE
, "ShowWindow: window was invisible\n" );
4209 trace("calling ShowWindow( SW_SHOWNA) for the visible child and invisible parent\n");
4210 ok( ShowWindow(hchild
, SW_SHOWNA
) != FALSE
, "ShowWindow: window was invisible\n" );
4211 ok_sequence(WmSHOWNAChildVisParInvis
, "ShowWindow(SW_SHOWNA) visible child and invisible parent", FALSE
);
4212 /* ShowWindow(SW_SHOWNA) with child visible and parent visible */
4213 ShowWindow( hwnd
, SW_SHOW
);
4215 trace("calling ShowWindow( SW_SHOWNA) for the visible child and parent\n");
4216 ok( ShowWindow(hchild
, SW_SHOWNA
) != FALSE
, "ShowWindow: window was invisible\n" );
4217 ok_sequence(WmSHOWNAChildVisParVis
, "ShowWindow(SW_SHOWNA) for the visible child and parent", FALSE
);
4219 /* ShowWindow(SW_SHOWNA) with child invisible and parent visible */
4220 ShowWindow( hchild
, SW_HIDE
);
4222 trace("calling ShowWindow( SW_SHOWNA) for the invisible child and visible parent\n");
4223 ok( ShowWindow(hchild
, SW_SHOWNA
) == FALSE
, "ShowWindow: window was visible\n" );
4224 ok_sequence(WmSHOWNAChildInvisParVis
, "ShowWindow(SW_SHOWNA) for the invisible child and visible parent", FALSE
);
4227 ok(GetCapture() == hchild
, "wrong capture window %p\n", GetCapture());
4228 DestroyWindow(hchild
);
4229 ok(!GetCapture(), "wrong capture window %p\n", GetCapture());
4231 DestroyWindow(hwnd
);
4236 * 1. Create invisible maximized popup window.
4237 * 2. Move and resize it.
4238 * 3. Show it maximized.
4240 trace("calling CreateWindowExA( WS_MAXIMIZE ) for invisible maximized popup window\n");
4241 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP
| WS_MAXIMIZE
,
4242 100, 100, 200, 200, 0, 0, 0, NULL
);
4243 ok (hwnd
!= 0, "Failed to create popup window\n");
4244 ok(IsZoomed(hwnd
), "window should be maximized\n");
4245 ok_sequence(WmCreateInvisibleMaxPopupSeq
, "CreateWindow(WS_MAXIMIZED):popup", FALSE
);
4247 GetWindowRect(hwnd
, &rc
);
4248 ok( rc
.right
-rc
.left
== GetSystemMetrics(SM_CXSCREEN
) &&
4249 rc
.bottom
-rc
.top
== GetSystemMetrics(SM_CYSCREEN
),
4250 "Invalid maximized size before ShowWindow (%d,%d)-(%d,%d)\n",
4251 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4252 /* Reset window's size & position */
4253 SetWindowPos(hwnd
, 0, 10, 10, 200, 200, SWP_NOZORDER
| SWP_NOACTIVATE
);
4254 ok(IsZoomed(hwnd
), "window should be maximized\n");
4257 trace("calling ShowWindow( SW_SHOWMAXIMIZE ) for invisible maximized popup window\n");
4258 ShowWindow(hwnd
, SW_SHOWMAXIMIZED
);
4259 ok(IsZoomed(hwnd
), "window should be maximized\n");
4260 ok_sequence(WmShowMaxPopupResizedSeq
, "ShowWindow(SW_SHOWMAXIMIZED):invisible maximized and resized popup", FALSE
);
4262 GetWindowRect(hwnd
, &rc
);
4263 ok( rc
.right
-rc
.left
== GetSystemMetrics(SM_CXSCREEN
) &&
4264 rc
.bottom
-rc
.top
== GetSystemMetrics(SM_CYSCREEN
),
4265 "Invalid maximized size after ShowWindow (%d,%d)-(%d,%d)\n",
4266 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4267 DestroyWindow(hwnd
);
4271 * 1. Create invisible maximized popup window.
4272 * 2. Show it maximized.
4274 trace("calling CreateWindowExA( WS_MAXIMIZE ) for invisible maximized popup window\n");
4275 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP
| WS_MAXIMIZE
,
4276 100, 100, 200, 200, 0, 0, 0, NULL
);
4277 ok (hwnd
!= 0, "Failed to create popup window\n");
4278 ok(IsZoomed(hwnd
), "window should be maximized\n");
4279 ok_sequence(WmCreateInvisibleMaxPopupSeq
, "CreateWindow(WS_MAXIMIZED):popup", FALSE
);
4281 trace("calling ShowWindow( SW_SHOWMAXIMIZE ) for invisible maximized popup window\n");
4282 ShowWindow(hwnd
, SW_SHOWMAXIMIZED
);
4283 ok(IsZoomed(hwnd
), "window should be maximized\n");
4284 ok_sequence(WmShowMaxPopupSeq
, "ShowWindow(SW_SHOWMAXIMIZED):invisible maximized popup", FALSE
);
4285 DestroyWindow(hwnd
);
4289 * 1. Create visible maximized popup window.
4291 trace("calling CreateWindowExA( WS_MAXIMIZE ) for maximized popup window\n");
4292 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP
| WS_MAXIMIZE
| WS_VISIBLE
,
4293 100, 100, 200, 200, 0, 0, 0, NULL
);
4294 ok (hwnd
!= 0, "Failed to create popup window\n");
4295 ok(IsZoomed(hwnd
), "window should be maximized\n");
4296 ok_sequence(WmCreateMaxPopupSeq
, "CreateWindow(WS_MAXIMIZED):popup", FALSE
);
4297 DestroyWindow(hwnd
);
4301 * 1. Create visible popup window.
4304 trace("calling CreateWindowExA( WS_VISIBLE ) for popup window\n");
4305 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP
| WS_VISIBLE
,
4306 100, 100, 200, 200, 0, 0, 0, NULL
);
4307 ok (hwnd
!= 0, "Failed to create popup window\n");
4308 ok(!IsZoomed(hwnd
), "window should NOT be maximized\n");
4309 ok_sequence(WmCreatePopupSeq
, "CreateWindow(WS_VISIBLE):popup", FALSE
);
4311 trace("calling ShowWindow( SW_SHOWMAXIMIZE ) for visible popup window\n");
4312 ShowWindow(hwnd
, SW_SHOWMAXIMIZED
);
4313 ok(IsZoomed(hwnd
), "window should be maximized\n");
4314 ok_sequence(WmShowVisMaxPopupSeq
, "ShowWindow(SW_SHOWMAXIMIZED):popup", FALSE
);
4315 DestroyWindow(hwnd
);
4319 static void test_sys_menu(void)
4325 hwnd
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
4326 100, 100, 200, 200, 0, 0, 0, NULL
);
4327 ok (hwnd
!= 0, "Failed to create overlapped window\n");
4331 /* test existing window without CS_NOCLOSE style */
4332 hmenu
= GetSystemMenu(hwnd
, FALSE
);
4333 ok(hmenu
!= 0, "GetSystemMenu error %d\n", GetLastError());
4335 state
= GetMenuState(hmenu
, SC_CLOSE
, MF_BYCOMMAND
);
4336 ok(state
!= 0xffffffff, "wrong SC_CLOSE state %x\n", state
);
4337 ok(!(state
& (MF_DISABLED
| MF_GRAYED
)), "wrong SC_CLOSE state %x\n", state
);
4339 EnableMenuItem(hmenu
, SC_CLOSE
, MF_BYCOMMAND
| MF_GRAYED
);
4340 ok_sequence(WmEmptySeq
, "WmEnableMenuItem", FALSE
);
4342 state
= GetMenuState(hmenu
, SC_CLOSE
, MF_BYCOMMAND
);
4343 ok(state
!= 0xffffffff, "wrong SC_CLOSE state %x\n", state
);
4344 ok((state
& (MF_DISABLED
| MF_GRAYED
)) == MF_GRAYED
, "wrong SC_CLOSE state %x\n", state
);
4346 EnableMenuItem(hmenu
, SC_CLOSE
, 0);
4347 ok_sequence(WmEmptySeq
, "WmEnableMenuItem", FALSE
);
4349 state
= GetMenuState(hmenu
, SC_CLOSE
, MF_BYCOMMAND
);
4350 ok(state
!= 0xffffffff, "wrong SC_CLOSE state %x\n", state
);
4351 ok(!(state
& (MF_DISABLED
| MF_GRAYED
)), "wrong SC_CLOSE state %x\n", state
);
4353 /* test whether removing WS_SYSMENU destroys a system menu */
4354 SetWindowLongW(hwnd
, GWL_STYLE
, WS_POPUP
);
4355 SetWindowPos(hwnd
, 0, 0, 0, 0, 0, SWP_NOZORDER
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_FRAMECHANGED
);
4357 hmenu
= GetSystemMenu(hwnd
, FALSE
);
4358 ok(hmenu
!= 0, "GetSystemMenu error %d\n", GetLastError());
4360 DestroyWindow(hwnd
);
4362 /* test new window with CS_NOCLOSE style */
4363 hwnd
= CreateWindowExA(0, "NoCloseWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
4364 100, 100, 200, 200, 0, 0, 0, NULL
);
4365 ok (hwnd
!= 0, "Failed to create overlapped window\n");
4367 hmenu
= GetSystemMenu(hwnd
, FALSE
);
4368 ok(hmenu
!= 0, "GetSystemMenu error %d\n", GetLastError());
4370 state
= GetMenuState(hmenu
, SC_CLOSE
, MF_BYCOMMAND
);
4371 ok(state
== 0xffffffff, "wrong SC_CLOSE state %x\n", state
);
4373 DestroyWindow(hwnd
);
4375 /* test new window without WS_SYSMENU style */
4376 hwnd
= CreateWindowExA(0, "NoCloseWindowClass", NULL
, WS_OVERLAPPEDWINDOW
& ~WS_SYSMENU
,
4377 100, 100, 200, 200, 0, 0, 0, NULL
);
4378 ok(hwnd
!= 0, "Failed to create overlapped window\n");
4380 hmenu
= GetSystemMenu(hwnd
, FALSE
);
4381 ok(!hmenu
, "GetSystemMenu error %d\n", GetLastError());
4383 DestroyWindow(hwnd
);
4386 /* For shown WS_OVERLAPPEDWINDOW */
4387 static const struct message WmSetIcon_1
[] = {
4388 { WM_SETICON
, sent
},
4389 { 0x00AE, sent
|defwinproc
|optional
}, /* XP */
4390 { WM_GETTEXT
, sent
|defwinproc
|optional
},
4391 { WM_GETTEXT
, sent
|defwinproc
|optional
}, /* XP sends a duplicate */
4395 /* For WS_POPUP and hidden WS_OVERLAPPEDWINDOW */
4396 static const struct message WmSetIcon_2
[] = {
4397 { WM_SETICON
, sent
},
4401 /* Sending undocumented 0x3B message with wparam = 0x8000000b */
4402 static const struct message WmInitEndSession
[] = {
4404 { WM_QUERYENDSESSION
, sent
|defwinproc
|wparam
|lparam
, 0, ENDSESSION_LOGOFF
},
4408 /* Sending undocumented 0x3B message with wparam = 0x0000000b */
4409 static const struct message WmInitEndSession_2
[] = {
4411 { WM_QUERYENDSESSION
, sent
|defwinproc
|wparam
|lparam
, 0, 0 },
4415 /* Sending undocumented 0x3B message with wparam = 0x80000008 */
4416 static const struct message WmInitEndSession_3
[] = {
4418 { WM_ENDSESSION
, sent
|defwinproc
|wparam
|lparam
, 0, ENDSESSION_LOGOFF
},
4422 /* Sending undocumented 0x3B message with wparam = 0x00000008 */
4423 static const struct message WmInitEndSession_4
[] = {
4425 { WM_ENDSESSION
, sent
|defwinproc
|wparam
|lparam
, 0, 0 },
4429 /* Sending undocumented 0x3B message with wparam = 0x80000001 */
4430 static const struct message WmInitEndSession_5
[] = {
4432 { WM_ENDSESSION
, sent
|defwinproc
/*|wparam*/|lparam
, 1, ENDSESSION_LOGOFF
},
4436 static const struct message WmOptionalPaint
[] = {
4437 { WM_PAINT
, sent
|optional
},
4438 { WM_NCPAINT
, sent
|beginpaint
|optional
},
4439 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
4440 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
4444 static const struct message WmZOrder
[] = {
4445 { WM_WINDOWPOSCHANGING
, sent
|wparam
, 0, 0 },
4446 { WM_GETMINMAXINFO
, sent
|defwinproc
|wparam
, 0, 0 },
4447 { HCBT_ACTIVATE
, hook
},
4448 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
4449 { WM_WINDOWPOSCHANGING
, sent
|wparam
, 3, 0 },
4450 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOREDRAW
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
, 0 },
4451 { WM_GETTEXT
, sent
|optional
},
4452 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
4453 { WM_ACTIVATEAPP
, sent
|wparam
, 1, 0 },
4454 { WM_NCACTIVATE
, sent
|lparam
, 1, 0 },
4455 { WM_GETTEXT
, sent
|defwinproc
|optional
},
4456 { WM_GETTEXT
, sent
|defwinproc
|optional
},
4457 { WM_ACTIVATE
, sent
|wparam
|lparam
, 1, 0 },
4458 { HCBT_SETFOCUS
, hook
},
4459 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
4460 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
4461 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
4462 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
4463 { WM_GETTEXT
, sent
|optional
},
4464 { WM_NCCALCSIZE
, sent
|optional
},
4468 static void test_MsgWaitForMultipleObjects(HWND hwnd
)
4473 ret
= MsgWaitForMultipleObjects(0, NULL
, FALSE
, 0, QS_POSTMESSAGE
);
4474 ok(ret
== WAIT_TIMEOUT
, "MsgWaitForMultipleObjects returned %x\n", ret
);
4476 PostMessageA(hwnd
, WM_USER
, 0, 0);
4478 ret
= MsgWaitForMultipleObjects(0, NULL
, FALSE
, 0, QS_POSTMESSAGE
);
4479 ok(ret
== WAIT_OBJECT_0
, "MsgWaitForMultipleObjects returned %x\n", ret
);
4481 ok(PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
), "PeekMessage should succeed\n");
4482 ok(msg
.message
== WM_USER
, "got %04x instead of WM_USER\n", msg
.message
);
4484 ret
= MsgWaitForMultipleObjects(0, NULL
, FALSE
, 0, QS_POSTMESSAGE
);
4485 ok(ret
== WAIT_TIMEOUT
, "MsgWaitForMultipleObjects returned %x\n", ret
);
4487 PostMessageA(hwnd
, WM_USER
, 0, 0);
4489 ret
= MsgWaitForMultipleObjects(0, NULL
, FALSE
, 0, QS_POSTMESSAGE
);
4490 ok(ret
== WAIT_OBJECT_0
, "MsgWaitForMultipleObjects returned %x\n", ret
);
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 /* shows QS_POSTMESSAGE flag is cleared in the PeekMessage call */
4496 ret
= MsgWaitForMultipleObjects(0, NULL
, FALSE
, 0, QS_POSTMESSAGE
);
4497 ok(ret
== WAIT_TIMEOUT
, "MsgWaitForMultipleObjects returned %x\n", ret
);
4499 PostMessageA(hwnd
, WM_USER
, 0, 0);
4501 /* new incoming message causes it to become signaled again */
4502 ret
= MsgWaitForMultipleObjects(0, NULL
, FALSE
, 0, QS_POSTMESSAGE
);
4503 ok(ret
== WAIT_OBJECT_0
, "MsgWaitForMultipleObjects returned %x\n", ret
);
4505 ok(PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
), "PeekMessage should succeed\n");
4506 ok(msg
.message
== WM_USER
, "got %04x instead of WM_USER\n", msg
.message
);
4507 ok(PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
), "PeekMessage should succeed\n");
4508 ok(msg
.message
== WM_USER
, "got %04x instead of WM_USER\n", msg
.message
);
4511 /* test if we receive the right sequence of messages */
4512 static void test_messages(void)
4514 HWND hwnd
, hparent
, hchild
;
4515 HWND hchild2
, hbutton
;
4522 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW
,
4523 100, 100, 200, 200, 0, 0, 0, NULL
);
4524 ok (hwnd
!= 0, "Failed to create overlapped window\n");
4525 ok_sequence(WmCreateOverlappedSeq
, "CreateWindow:overlapped", FALSE
);
4527 /* test ShowWindow(SW_HIDE) on a newly created invisible window */
4528 ok( ShowWindow(hwnd
, SW_HIDE
) == FALSE
, "ShowWindow: window was visible\n" );
4529 ok_sequence(WmEmptySeq
, "ShowWindow(SW_HIDE):overlapped, invisible", FALSE
);
4531 /* test WM_SETREDRAW on a not visible top level window */
4532 test_WM_SETREDRAW(hwnd
);
4534 SetWindowPos(hwnd
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
);
4536 ok_sequence(WmSWP_ShowOverlappedSeq
, "SetWindowPos:SWP_SHOWWINDOW:overlapped", FALSE
);
4537 ok(IsWindowVisible(hwnd
), "window should be visible at this point\n");
4539 ok(GetActiveWindow() == hwnd
, "window should be active\n");
4540 ok(GetFocus() == hwnd
, "window should have input focus\n");
4541 ShowWindow(hwnd
, SW_HIDE
);
4543 ok_sequence(WmHideOverlappedSeq
, "ShowWindow(SW_HIDE):overlapped", FALSE
);
4545 ShowWindow(hwnd
, SW_SHOW
);
4547 ok_sequence(WmShowOverlappedSeq
, "ShowWindow(SW_SHOW):overlapped", TRUE
);
4549 ShowWindow(hwnd
, SW_HIDE
);
4551 ok_sequence(WmHideOverlappedSeq
, "ShowWindow(SW_HIDE):overlapped", FALSE
);
4553 ShowWindow(hwnd
, SW_SHOWMAXIMIZED
);
4555 ok_sequence(WmShowMaxOverlappedSeq
, "ShowWindow(SW_SHOWMAXIMIZED):overlapped", TRUE
);
4558 if (GetWindowLongW( hwnd
, GWL_STYLE
) & WS_MAXIMIZE
)
4560 ShowWindow(hwnd
, SW_RESTORE
);
4562 ok_sequence(WmShowRestoreMaxOverlappedSeq
, "ShowWindow(SW_RESTORE):overlapped", TRUE
);
4566 ShowWindow(hwnd
, SW_MINIMIZE
);
4568 ok_sequence(WmShowMinOverlappedSeq
, "ShowWindow(SW_SHOWMINIMIZED):overlapped", TRUE
);
4571 if (GetWindowLongW( hwnd
, GWL_STYLE
) & WS_MINIMIZE
)
4573 ShowWindow(hwnd
, SW_RESTORE
);
4575 ok_sequence(WmShowRestoreMinOverlappedSeq
, "ShowWindow(SW_RESTORE):overlapped", TRUE
);
4579 ShowWindow(hwnd
, SW_SHOW
);
4581 ok_sequence(WmOptionalPaint
, "ShowWindow(SW_SHOW):overlapped already visible", FALSE
);
4583 SetWindowPos(hwnd
, 0,0,0,0,0, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
);
4584 ok_sequence(WmSWP_HideOverlappedSeq
, "SetWindowPos:SWP_HIDEWINDOW:overlapped", FALSE
);
4585 ok(!IsWindowVisible(hwnd
), "window should not be visible at this point\n");
4586 ok(GetActiveWindow() == hwnd
, "window should still be active\n");
4588 /* test WM_SETREDRAW on a visible top level window */
4589 ShowWindow(hwnd
, SW_SHOW
);
4591 test_WM_SETREDRAW(hwnd
);
4593 trace("testing scroll APIs on a visible top level window %p\n", hwnd
);
4594 test_scroll_messages(hwnd
);
4596 /* test resizing and moving */
4597 SetWindowPos( hwnd
, 0, 0, 0, 300, 300, SWP_NOMOVE
|SWP_NOACTIVATE
);
4598 ok_sequence(WmSWP_ResizeSeq
, "SetWindowPos:Resize", FALSE
);
4601 SetWindowPos( hwnd
, 0, 200, 200, 0, 0, SWP_NOSIZE
|SWP_NOACTIVATE
);
4602 ok_sequence(WmSWP_MoveSeq
, "SetWindowPos:Move", FALSE
);
4605 SetWindowPos( hwnd
, 0, 200, 200, 250, 250, SWP_NOZORDER
|SWP_NOACTIVATE
);
4606 ok_sequence(WmSWP_ResizeNoZOrder
, "SetWindowPos:WmSWP_ResizeNoZOrder", FALSE
);
4610 /* popups don't get WM_GETMINMAXINFO */
4611 SetWindowLongW( hwnd
, GWL_STYLE
, WS_VISIBLE
|WS_POPUP
);
4612 SetWindowPos( hwnd
, 0, 0, 0, 0, 0, SWP_NOZORDER
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_FRAMECHANGED
);
4614 SetWindowPos( hwnd
, 0, 0, 0, 200, 200, SWP_NOMOVE
|SWP_NOACTIVATE
);
4615 ok_sequence(WmSWP_ResizePopupSeq
, "SetWindowPos:ResizePopup", FALSE
);
4617 DestroyWindow(hwnd
);
4618 ok_sequence(WmDestroyOverlappedSeq
, "DestroyWindow:overlapped", FALSE
);
4620 hparent
= CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
4621 100, 100, 200, 200, 0, 0, 0, NULL
);
4622 ok (hparent
!= 0, "Failed to create parent window\n");
4625 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
| WS_MAXIMIZE
,
4626 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4627 ok (hchild
!= 0, "Failed to create child window\n");
4628 ok_sequence(WmCreateMaximizedChildSeq
, "CreateWindow:maximized child", FALSE
);
4629 DestroyWindow(hchild
);
4632 /* visible child window with a caption */
4633 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child",
4634 WS_CHILD
| WS_VISIBLE
| WS_CAPTION
,
4635 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4636 ok (hchild
!= 0, "Failed to create child window\n");
4637 ok_sequence(WmCreateVisibleChildSeq
, "CreateWindow:visible child", FALSE
);
4639 trace("testing scroll APIs on a visible child window %p\n", hchild
);
4640 test_scroll_messages(hchild
);
4642 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
);
4643 ok_sequence(WmShowChildSeq_4
, "SetWindowPos(SWP_SHOWWINDOW):child with a caption", FALSE
);
4645 DestroyWindow(hchild
);
4648 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
4649 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4650 ok (hchild
!= 0, "Failed to create child window\n");
4651 ok_sequence(WmCreateChildSeq
, "CreateWindow:child", FALSE
);
4653 hchild2
= CreateWindowExA(0, "SimpleWindowClass", "Test child2", WS_CHILD
,
4654 100, 100, 50, 50, hparent
, 0, 0, NULL
);
4655 ok (hchild2
!= 0, "Failed to create child2 window\n");
4658 hbutton
= CreateWindowExA(0, "TestWindowClass", "Test button", WS_CHILD
,
4659 0, 100, 50, 50, hchild
, 0, 0, NULL
);
4660 ok (hbutton
!= 0, "Failed to create button window\n");
4662 /* test WM_SETREDRAW on a not visible child window */
4663 test_WM_SETREDRAW(hchild
);
4665 ShowWindow(hchild
, SW_SHOW
);
4666 ok_sequence(WmShowChildSeq
, "ShowWindow(SW_SHOW):child", FALSE
);
4668 /* check parent messages too */
4669 log_all_parent_messages
++;
4670 ShowWindow(hchild
, SW_HIDE
);
4671 ok_sequence(WmHideChildSeq2
, "ShowWindow(SW_HIDE):child", FALSE
);
4672 log_all_parent_messages
--;
4674 ShowWindow(hchild
, SW_SHOW
);
4675 ok_sequence(WmShowChildSeq
, "ShowWindow(SW_SHOW):child", FALSE
);
4677 ShowWindow(hchild
, SW_HIDE
);
4678 ok_sequence(WmHideChildSeq
, "ShowWindow(SW_HIDE):child", FALSE
);
4680 ShowWindow(hchild
, SW_SHOW
);
4681 ok_sequence(WmShowChildSeq
, "ShowWindow(SW_SHOW):child", FALSE
);
4683 /* test WM_SETREDRAW on a visible child window */
4684 test_WM_SETREDRAW(hchild
);
4686 log_all_parent_messages
++;
4687 MoveWindow(hchild
, 10, 10, 20, 20, TRUE
);
4688 ok_sequence(WmResizingChildWithMoveWindowSeq
, "MoveWindow:child", FALSE
);
4689 log_all_parent_messages
--;
4691 ShowWindow(hchild
, SW_HIDE
);
4693 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
);
4694 ok_sequence(WmShowChildSeq_2
, "SetWindowPos:show_child_2", FALSE
);
4696 ShowWindow(hchild
, SW_HIDE
);
4698 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
);
4699 ok_sequence(WmShowChildSeq_3
, "SetWindowPos:show_child_3", FALSE
);
4701 /* DestroyWindow sequence below expects that a child has focus */
4705 DestroyWindow(hchild
);
4706 ok_sequence(WmDestroyChildSeq
, "DestroyWindow:child", FALSE
);
4707 DestroyWindow(hchild2
);
4708 DestroyWindow(hbutton
);
4711 hchild
= CreateWindowExA(0, "TestWindowClass", "Test Child Popup", WS_CHILD
| WS_POPUP
,
4712 0, 0, 100, 100, hparent
, 0, 0, NULL
);
4713 ok (hchild
!= 0, "Failed to create child popup window\n");
4714 ok_sequence(WmCreateChildPopupSeq
, "CreateWindow:child_popup", FALSE
);
4715 DestroyWindow(hchild
);
4717 /* test what happens to a window which sets WS_VISIBLE in WM_CREATE */
4719 hchild
= CreateWindowExA(0, "TestPopupClass", "Test Popup", WS_POPUP
,
4720 0, 0, 100, 100, hparent
, 0, 0, NULL
);
4721 ok (hchild
!= 0, "Failed to create popup window\n");
4722 ok_sequence(WmCreateInvisiblePopupSeq
, "CreateWindow:invisible_popup", FALSE
);
4723 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
4724 ok(IsWindowVisible(hchild
), "IsWindowVisible() should return TRUE\n");
4726 ShowWindow(hchild
, SW_SHOW
);
4727 ok_sequence(WmEmptySeq
, "ShowWindow:show_visible_popup", FALSE
);
4729 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOZORDER
);
4730 ok_sequence(WmShowVisiblePopupSeq_2
, "SetWindowPos:show_visible_popup_2", FALSE
);
4732 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
);
4733 ok_sequence(WmShowVisiblePopupSeq_3
, "SetWindowPos:show_visible_popup_3", FALSE
);
4734 DestroyWindow(hchild
);
4736 /* this time add WS_VISIBLE for CreateWindowEx, but this fact actually
4737 * changes nothing in message sequences.
4740 hchild
= CreateWindowExA(0, "TestPopupClass", "Test Popup", WS_POPUP
| WS_VISIBLE
,
4741 0, 0, 100, 100, hparent
, 0, 0, NULL
);
4742 ok (hchild
!= 0, "Failed to create popup window\n");
4743 ok_sequence(WmCreateInvisiblePopupSeq
, "CreateWindow:invisible_popup", FALSE
);
4744 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
4745 ok(IsWindowVisible(hchild
), "IsWindowVisible() should return TRUE\n");
4747 ShowWindow(hchild
, SW_SHOW
);
4748 ok_sequence(WmEmptySeq
, "ShowWindow:show_visible_popup", FALSE
);
4750 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOZORDER
);
4751 ok_sequence(WmShowVisiblePopupSeq_2
, "SetWindowPos:show_visible_popup_2", FALSE
);
4752 DestroyWindow(hchild
);
4755 hwnd
= CreateWindowExA(WS_EX_DLGMODALFRAME
, "TestDialogClass", NULL
, WS_VISIBLE
|WS_CAPTION
|WS_SYSMENU
|WS_DLGFRAME
,
4756 0, 0, 100, 100, hparent
, 0, 0, NULL
);
4757 ok(hwnd
!= 0, "Failed to create custom dialog window\n");
4758 ok_sequence(WmCreateCustomDialogSeq
, "CreateCustomDialog", TRUE
);
4761 trace("testing scroll APIs on a visible dialog %p\n", hwnd
);
4762 test_scroll_messages(hwnd
);
4768 SendMessageA(hwnd
, WM_NULL
, 0, 0);
4771 after_end_dialog
= TRUE
;
4772 EndDialog( hwnd
, 0 );
4773 ok_sequence(WmEndCustomDialogSeq
, "EndCustomDialog", FALSE
);
4775 DestroyWindow(hwnd
);
4776 after_end_dialog
= FALSE
;
4777 test_def_id
= FALSE
;
4779 hwnd
= CreateWindowExA(0, "TestDialogClass", NULL
, WS_POPUP
,
4780 0, 0, 100, 100, 0, 0, GetModuleHandleA(0), NULL
);
4781 ok(hwnd
!= 0, "Failed to create custom dialog window\n");
4783 trace("call ShowWindow(%p, SW_SHOW)\n", hwnd
);
4784 ShowWindow(hwnd
, SW_SHOW
);
4785 ok_sequence(WmShowCustomDialogSeq
, "ShowCustomDialog", TRUE
);
4786 DestroyWindow(hwnd
);
4789 DialogBoxA( 0, "TEST_DIALOG", hparent
, TestModalDlgProcA
);
4790 ok_sequence(WmModalDialogSeq
, "ModalDialog", TRUE
);
4792 DestroyWindow(hparent
);
4795 /* Message sequence for SetMenu */
4796 ok(!DrawMenuBar(hwnd
), "DrawMenuBar should return FALSE for a window without a menu\n");
4797 ok_sequence(WmEmptySeq
, "DrawMenuBar for a window without a menu", FALSE
);
4799 hmenu
= CreateMenu();
4800 ok (hmenu
!= 0, "Failed to create menu\n");
4801 ok (InsertMenuA(hmenu
, -1, MF_BYPOSITION
, 0x1000, "foo"), "InsertMenu failed\n");
4802 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW
,
4803 100, 100, 200, 200, 0, hmenu
, 0, NULL
);
4804 ok_sequence(WmCreateOverlappedSeq
, "CreateWindow:overlapped", FALSE
);
4805 ok (SetMenu(hwnd
, 0), "SetMenu\n");
4806 ok_sequence(WmSetMenuNonVisibleSizeChangeSeq
, "SetMenu:NonVisibleSizeChange", FALSE
);
4807 ok (SetMenu(hwnd
, 0), "SetMenu\n");
4808 ok_sequence(WmSetMenuNonVisibleNoSizeChangeSeq
, "SetMenu:NonVisibleNoSizeChange", FALSE
);
4809 ShowWindow(hwnd
, SW_SHOW
);
4810 UpdateWindow( hwnd
);
4813 ok (SetMenu(hwnd
, 0), "SetMenu\n");
4814 ok_sequence(WmSetMenuVisibleNoSizeChangeSeq
, "SetMenu:VisibleNoSizeChange", FALSE
);
4815 ok (SetMenu(hwnd
, hmenu
), "SetMenu\n");
4816 ok_sequence(WmSetMenuVisibleSizeChangeSeq
, "SetMenu:VisibleSizeChange", FALSE
);
4818 UpdateWindow( hwnd
);
4821 ok(DrawMenuBar(hwnd
), "DrawMenuBar\n");
4823 ok_sequence(WmDrawMenuBarSeq
, "DrawMenuBar", FALSE
);
4825 DestroyWindow(hwnd
);
4828 /* Message sequence for EnableWindow */
4829 hparent
= CreateWindowExA(0, "TestWindowClass", "Test parent", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
4830 100, 100, 200, 200, 0, 0, 0, NULL
);
4831 ok (hparent
!= 0, "Failed to create parent window\n");
4832 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
| WS_VISIBLE
,
4833 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4834 ok (hchild
!= 0, "Failed to create child window\n");
4840 EnableWindow(hparent
, FALSE
);
4841 ok_sequence(WmEnableWindowSeq_1
, "EnableWindow(FALSE)", FALSE
);
4843 EnableWindow(hparent
, TRUE
);
4844 ok_sequence(WmEnableWindowSeq_2
, "EnableWindow(TRUE)", FALSE
);
4849 test_MsgWaitForMultipleObjects(hparent
);
4851 /* the following test causes an exception in user.exe under win9x */
4852 if (!PostMessageW( hparent
, WM_USER
, 0, 0 ))
4854 DestroyWindow(hparent
);
4858 PostMessageW( hparent
, WM_USER
+1, 0, 0 );
4859 /* PeekMessage(NULL) fails, but still removes the message */
4860 SetLastError(0xdeadbeef);
4861 ok( !PeekMessageW( NULL
, 0, 0, 0, PM_REMOVE
), "PeekMessage(NULL) should fail\n" );
4862 ok( GetLastError() == ERROR_NOACCESS
|| /* Win2k */
4863 GetLastError() == 0xdeadbeef, /* NT4 */
4864 "last error is %d\n", GetLastError() );
4865 ok( PeekMessageW( &msg
, 0, 0, 0, PM_REMOVE
), "PeekMessage should succeed\n" );
4866 ok( msg
.message
== WM_USER
+1, "got %x instead of WM_USER+1\n", msg
.message
);
4868 DestroyWindow(hchild
);
4869 DestroyWindow(hparent
);
4872 /* Message sequences for WM_SETICON */
4873 trace("testing WM_SETICON\n");
4874 hwnd
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
4875 CW_USEDEFAULT
, CW_USEDEFAULT
, 300, 300, 0,
4877 ShowWindow(hwnd
, SW_SHOW
);
4881 SendMessageA(hwnd
, WM_SETICON
, ICON_SMALL
, (LPARAM
)LoadIconA(0, (LPCSTR
)IDI_APPLICATION
));
4882 ok_sequence(WmSetIcon_1
, "WM_SETICON for shown window with caption", FALSE
);
4884 ShowWindow(hwnd
, SW_HIDE
);
4887 SendMessageA(hwnd
, WM_SETICON
, ICON_SMALL
, (LPARAM
)LoadIconA(0, (LPCSTR
)IDI_APPLICATION
));
4888 ok_sequence(WmSetIcon_2
, "WM_SETICON for hidden window with caption", FALSE
);
4889 DestroyWindow(hwnd
);
4892 hwnd
= CreateWindowExA(0, "TestPopupClass", NULL
, WS_POPUP
,
4893 CW_USEDEFAULT
, CW_USEDEFAULT
, 300, 300, 0,
4895 ShowWindow(hwnd
, SW_SHOW
);
4899 SendMessageA(hwnd
, WM_SETICON
, ICON_SMALL
, (LPARAM
)LoadIconA(0, (LPCSTR
)IDI_APPLICATION
));
4900 ok_sequence(WmSetIcon_2
, "WM_SETICON for shown window without caption", FALSE
);
4902 ShowWindow(hwnd
, SW_HIDE
);
4905 SendMessageA(hwnd
, WM_SETICON
, ICON_SMALL
, (LPARAM
)LoadIconA(0, (LPCSTR
)IDI_APPLICATION
));
4906 ok_sequence(WmSetIcon_2
, "WM_SETICON for hidden window without caption", FALSE
);
4909 res
= SendMessageA(hwnd
, 0x3B, 0x8000000b, 0);
4912 todo_wine
win_skip( "Message 0x3b not supported\n" );
4915 ok_sequence(WmInitEndSession
, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x8000000b", TRUE
);
4916 ok(res
== 1, "SendMessage(hwnd, 0x3B, 0x8000000b, 0) should have returned 1 instead of %ld\n", res
);
4917 res
= SendMessageA(hwnd
, 0x3B, 0x0000000b, 0);
4918 ok_sequence(WmInitEndSession_2
, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x0000000b", TRUE
);
4919 ok(res
== 1, "SendMessage(hwnd, 0x3B, 0x0000000b, 0) should have returned 1 instead of %ld\n", res
);
4920 res
= SendMessageA(hwnd
, 0x3B, 0x0000000f, 0);
4921 ok_sequence(WmInitEndSession_2
, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x0000000f", TRUE
);
4922 ok(res
== 1, "SendMessage(hwnd, 0x3B, 0x0000000f, 0) should have returned 1 instead of %ld\n", res
);
4925 res
= SendMessageA(hwnd
, 0x3B, 0x80000008, 0);
4926 ok_sequence(WmInitEndSession_3
, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x80000008", TRUE
);
4927 ok(res
== 2, "SendMessage(hwnd, 0x3B, 0x80000008, 0) should have returned 2 instead of %ld\n", res
);
4928 res
= SendMessageA(hwnd
, 0x3B, 0x00000008, 0);
4929 ok_sequence(WmInitEndSession_4
, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x00000008", TRUE
);
4930 ok(res
== 2, "SendMessage(hwnd, 0x3B, 0x00000008, 0) should have returned 2 instead of %ld\n", res
);
4932 res
= SendMessageA(hwnd
, 0x3B, 0x80000004, 0);
4933 ok_sequence(WmInitEndSession_3
, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x80000004", TRUE
);
4934 ok(res
== 2, "SendMessage(hwnd, 0x3B, 0x80000004, 0) should have returned 2 instead of %ld\n", res
);
4936 res
= SendMessageA(hwnd
, 0x3B, 0x80000001, 0);
4937 ok_sequence(WmInitEndSession_5
, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x80000001", TRUE
);
4938 ok(res
== 2, "SendMessage(hwnd, 0x3B, 0x80000001, 0) should have returned 2 instead of %ld\n", res
);
4941 DestroyWindow(hwnd
);
4945 static void test_setwindowpos(void)
4950 const INT winX
= 100;
4951 const INT winY
= 100;
4952 const INT sysX
= GetSystemMetrics(SM_CXMINTRACK
);
4954 hwnd
= CreateWindowExA(0, "TestWindowClass", NULL
, 0,
4955 0, 0, winX
, winY
, 0,
4958 GetWindowRect(hwnd
, &rc
);
4959 expect(sysX
, rc
.right
);
4960 expect(winY
, rc
.bottom
);
4964 res
= SetWindowPos(hwnd
, HWND_TOPMOST
, 0, 0, winX
, winY
, 0);
4965 ok_sequence(WmZOrder
, "Z-Order", TRUE
);
4966 ok(res
== TRUE
, "SetWindowPos expected TRUE, got %ld\n", res
);
4968 GetWindowRect(hwnd
, &rc
);
4969 expect(sysX
, rc
.right
);
4970 expect(winY
, rc
.bottom
);
4971 DestroyWindow(hwnd
);
4974 static void invisible_parent_tests(void)
4976 HWND hparent
, hchild
;
4978 hparent
= CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW
,
4979 100, 100, 200, 200, 0, 0, 0, NULL
);
4980 ok (hparent
!= 0, "Failed to create parent window\n");
4983 /* test showing child with hidden parent */
4985 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
4986 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4987 ok (hchild
!= 0, "Failed to create child window\n");
4988 ok_sequence(WmCreateChildSeq
, "CreateWindow:child", FALSE
);
4990 ShowWindow( hchild
, SW_MINIMIZE
);
4991 ok_sequence(WmShowChildInvisibleParentSeq_1
, "ShowWindow(SW_MINIMIZE) child with invisible parent", FALSE
);
4992 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
4993 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
4998 ShowWindow( hchild
, SW_MINIMIZE
);
4999 ok_sequence(WmShowChildInvisibleParentSeq_1r
, "ShowWindow(SW_MINIMIZE) child with invisible parent", FALSE
);
5001 DestroyWindow(hchild
);
5002 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
5003 0, 0, 10, 10, hparent
, 0, 0, NULL
);
5006 ShowWindow( hchild
, SW_MAXIMIZE
);
5007 ok_sequence(WmShowChildInvisibleParentSeq_2
, "ShowWindow(SW_MAXIMIZE) child with invisible parent", FALSE
);
5008 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
5009 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
5014 ShowWindow( hchild
, SW_MAXIMIZE
);
5015 ok_sequence(WmShowChildInvisibleParentSeq_2r
, "ShowWindow(SW_MAXIMIZE) child with invisible parent", FALSE
);
5017 DestroyWindow(hchild
);
5018 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
5019 0, 0, 10, 10, hparent
, 0, 0, NULL
);
5022 ShowWindow( hchild
, SW_RESTORE
);
5023 ok_sequence(WmShowChildInvisibleParentSeq_5
, "ShowWindow(SW_RESTORE) child with invisible parent", FALSE
);
5024 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
5025 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
5027 DestroyWindow(hchild
);
5028 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
5029 0, 0, 10, 10, hparent
, 0, 0, NULL
);
5032 ShowWindow( hchild
, SW_SHOWMINIMIZED
);
5033 ok_sequence(WmShowChildInvisibleParentSeq_3
, "ShowWindow(SW_SHOWMINIMIZED) child with invisible parent", FALSE
);
5034 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
5035 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
5040 ShowWindow( hchild
, SW_SHOWMINIMIZED
);
5041 ok_sequence(WmShowChildInvisibleParentSeq_3r
, "ShowWindow(SW_SHOWMINIMIZED) child with invisible parent", FALSE
);
5043 DestroyWindow(hchild
);
5044 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
5045 0, 0, 10, 10, hparent
, 0, 0, NULL
);
5048 /* same as ShowWindow( hchild, SW_MAXIMIZE ); */
5049 ShowWindow( hchild
, SW_SHOWMAXIMIZED
);
5050 ok_sequence(WmShowChildInvisibleParentSeq_2
, "ShowWindow(SW_SHOWMAXIMIZED) child with invisible parent", FALSE
);
5051 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
5052 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
5054 DestroyWindow(hchild
);
5055 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
5056 0, 0, 10, 10, hparent
, 0, 0, NULL
);
5059 ShowWindow( hchild
, SW_SHOWMINNOACTIVE
);
5060 ok_sequence(WmShowChildInvisibleParentSeq_4
, "ShowWindow(SW_SHOWMINNOACTIVE) child with invisible parent", FALSE
);
5061 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
5062 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
5067 ShowWindow( hchild
, SW_SHOWMINNOACTIVE
);
5068 ok_sequence(WmShowChildInvisibleParentSeq_4r
, "ShowWindow(SW_SHOWMINNOACTIVE) child with invisible parent", FALSE
);
5070 DestroyWindow(hchild
);
5071 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
5072 0, 0, 10, 10, hparent
, 0, 0, NULL
);
5075 /* FIXME: looks like XP SP2 doesn't know about SW_FORCEMINIMIZE at all */
5076 ShowWindow( hchild
, SW_FORCEMINIMIZE
);
5077 ok_sequence(WmEmptySeq
, "ShowWindow(SW_FORCEMINIMIZE) child with invisible parent", TRUE
);
5079 ok(!(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
), "WS_VISIBLE should be not set\n");
5081 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
5083 DestroyWindow(hchild
);
5084 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
5085 0, 0, 10, 10, hparent
, 0, 0, NULL
);
5088 ShowWindow( hchild
, SW_SHOWNA
);
5089 ok_sequence(WmShowChildInvisibleParentSeq_5
, "ShowWindow(SW_SHOWNA) child with invisible parent", FALSE
);
5090 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
5091 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
5096 ShowWindow( hchild
, SW_SHOWNA
);
5097 ok_sequence(WmShowChildInvisibleParentSeq_5
, "ShowWindow(SW_SHOWNA) child with invisible parent", FALSE
);
5099 DestroyWindow(hchild
);
5100 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
5101 0, 0, 10, 10, hparent
, 0, 0, NULL
);
5104 ShowWindow( hchild
, SW_SHOW
);
5105 ok_sequence(WmShowChildInvisibleParentSeq_5
, "ShowWindow(SW_SHOW) child with invisible parent", FALSE
);
5106 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
5107 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
5112 ShowWindow( hchild
, SW_SHOW
);
5113 ok_sequence(WmEmptySeq
, "ShowWindow(SW_SHOW) child with invisible parent", FALSE
);
5115 ShowWindow( hchild
, SW_HIDE
);
5116 ok_sequence(WmHideChildInvisibleParentSeq
, "ShowWindow:hide child with invisible parent", FALSE
);
5117 ok(!(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
), "WS_VISIBLE should be not set\n");
5118 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
5120 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOZORDER
);
5121 ok_sequence(WmShowChildInvisibleParentSeq_6
, "SetWindowPos:show child with invisible parent", FALSE
);
5122 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
5123 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
5125 SetWindowPos(hchild
, 0,0,0,0,0, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOZORDER
);
5126 ok_sequence(WmHideChildInvisibleParentSeq_2
, "SetWindowPos:hide child with invisible parent", FALSE
);
5127 ok(!(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
), "WS_VISIBLE should not be set\n");
5128 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
5130 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOZORDER
);
5132 DestroyWindow(hchild
);
5133 ok_sequence(WmDestroyInvisibleChildSeq
, "DestroyInvisibleChildSeq", FALSE
);
5135 DestroyWindow(hparent
);
5139 /****************** button message test *************************/
5140 #define ID_BUTTON 0x000e
5142 static const struct message WmSetFocusButtonSeq
[] =
5144 { HCBT_SETFOCUS
, hook
},
5145 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
5146 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
5147 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
5148 { WM_SETFOCUS
, sent
|wparam
, 0 },
5149 { WM_CTLCOLORBTN
, sent
|parent
},
5150 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_BUTTON
, BN_SETFOCUS
) },
5151 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5154 static const struct message WmKillFocusButtonSeq
[] =
5156 { HCBT_SETFOCUS
, hook
},
5157 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
5158 { WM_KILLFOCUS
, sent
|wparam
, 0 },
5159 { WM_CTLCOLORBTN
, sent
|parent
},
5160 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_BUTTON
, BN_KILLFOCUS
) },
5161 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
5162 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 1 },
5163 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5165 { WM_CTLCOLORBTN
, sent
|parent
},
5168 static const struct message WmSetFocusStaticSeq
[] =
5170 { HCBT_SETFOCUS
, hook
},
5171 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
5172 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
5173 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
5174 { WM_SETFOCUS
, sent
|wparam
, 0 },
5175 { WM_CTLCOLORSTATIC
, sent
|parent
},
5176 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_BUTTON
, BN_SETFOCUS
) },
5177 { WM_COMMAND
, sent
|wparam
|parent
|optional
, MAKEWPARAM(ID_BUTTON
, BN_CLICKED
) }, /* radio button */
5178 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5181 static const struct message WmKillFocusStaticSeq
[] =
5183 { HCBT_SETFOCUS
, hook
},
5184 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
5185 { WM_KILLFOCUS
, sent
|wparam
, 0 },
5186 { WM_CTLCOLORSTATIC
, sent
|parent
},
5187 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_BUTTON
, BN_KILLFOCUS
) },
5188 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
5189 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 1 },
5190 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5192 { WM_CTLCOLORSTATIC
, sent
|parent
},
5195 static const struct message WmSetFocusOwnerdrawSeq
[] =
5197 { HCBT_SETFOCUS
, hook
},
5198 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
5199 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
5200 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
5201 { WM_SETFOCUS
, sent
|wparam
, 0 },
5202 { WM_CTLCOLORBTN
, sent
|parent
},
5203 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_BUTTON
, 0x001040e4 },
5204 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_BUTTON
, BN_SETFOCUS
) },
5205 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5208 static const struct message WmKillFocusOwnerdrawSeq
[] =
5210 { HCBT_SETFOCUS
, hook
},
5211 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
5212 { WM_KILLFOCUS
, sent
|wparam
, 0 },
5213 { WM_CTLCOLORBTN
, sent
|parent
},
5214 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_BUTTON
, 0x000040e4 },
5215 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_BUTTON
, BN_KILLFOCUS
) },
5216 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
5217 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 1 },
5218 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5220 { WM_CTLCOLORBTN
, sent
|parent
},
5221 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_BUTTON
, 0x000010e4 },
5224 static const struct message WmLButtonDownSeq
[] =
5226 { WM_LBUTTONDOWN
, sent
|wparam
|lparam
, 0, 0 },
5227 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
5228 { HCBT_SETFOCUS
, hook
},
5229 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
5230 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
5231 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
5232 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
5233 { WM_CTLCOLORBTN
, sent
|defwinproc
},
5234 { BM_SETSTATE
, sent
|wparam
|defwinproc
, TRUE
},
5235 { WM_CTLCOLORBTN
, sent
|defwinproc
},
5236 { EVENT_OBJECT_STATECHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
5239 static const struct message WmLButtonUpSeq
[] =
5241 { WM_LBUTTONUP
, sent
|wparam
|lparam
, 0, 0 },
5242 { BM_SETSTATE
, sent
|wparam
|defwinproc
, FALSE
},
5243 { WM_CTLCOLORBTN
, sent
|defwinproc
},
5244 { EVENT_OBJECT_STATECHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
5245 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, 0, 0 },
5246 { WM_CAPTURECHANGED
, sent
|wparam
|defwinproc
, 0 },
5249 static const struct message WmSetFontButtonSeq
[] =
5251 { WM_SETFONT
, sent
},
5253 { WM_ERASEBKGND
, sent
|defwinproc
|optional
},
5254 { WM_CTLCOLORBTN
, sent
|defwinproc
},
5257 static const struct message WmSetStyleButtonSeq
[] =
5259 { BM_SETSTYLE
, sent
},
5260 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5262 { WM_NCPAINT
, sent
|defwinproc
|optional
}, /* FIXME: Wine sends it */
5263 { WM_ERASEBKGND
, sent
|defwinproc
|optional
}, /* Win9x doesn't send it */
5264 { WM_CTLCOLORBTN
, sent
|parent
},
5267 static const struct message WmSetStyleStaticSeq
[] =
5269 { BM_SETSTYLE
, sent
},
5270 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5272 { WM_NCPAINT
, sent
|defwinproc
|optional
}, /* FIXME: Wine sends it */
5273 { WM_ERASEBKGND
, sent
|defwinproc
|optional
}, /* Win9x doesn't send it */
5274 { WM_CTLCOLORSTATIC
, sent
|parent
},
5277 static const struct message WmSetStyleUserSeq
[] =
5279 { BM_SETSTYLE
, sent
},
5280 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5282 { WM_NCPAINT
, sent
|defwinproc
|optional
}, /* FIXME: Wine sends it */
5283 { WM_ERASEBKGND
, sent
|defwinproc
|optional
}, /* Win9x doesn't send it */
5284 { WM_CTLCOLORBTN
, sent
|parent
},
5285 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_BUTTON
, BN_PAINT
) },
5288 static const struct message WmSetStyleOwnerdrawSeq
[] =
5290 { BM_SETSTYLE
, sent
},
5291 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5293 { WM_NCPAINT
, sent
|optional
}, /* FIXME: Wine sends it */
5294 { WM_ERASEBKGND
, sent
|defwinproc
|optional
}, /* Win9x doesn't send it */
5295 { WM_CTLCOLORBTN
, sent
|parent
},
5296 { WM_CTLCOLORBTN
, sent
|parent
|optional
}, /* Win9x doesn't send it */
5297 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_BUTTON
, 0x000010e4 },
5300 static const struct message WmSetStateButtonSeq
[] =
5302 { BM_SETSTATE
, sent
},
5303 { WM_CTLCOLORBTN
, sent
|parent
},
5304 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5307 static const struct message WmSetStateStaticSeq
[] =
5309 { BM_SETSTATE
, sent
},
5310 { WM_CTLCOLORSTATIC
, sent
|parent
},
5311 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5314 static const struct message WmSetStateUserSeq
[] =
5316 { BM_SETSTATE
, sent
},
5317 { WM_CTLCOLORBTN
, sent
|parent
},
5318 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_BUTTON
, BN_HILITE
) },
5319 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5322 static const struct message WmSetStateOwnerdrawSeq
[] =
5324 { BM_SETSTATE
, sent
},
5325 { WM_CTLCOLORBTN
, sent
|parent
},
5326 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_BUTTON
, 0x000120e4 },
5327 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5330 static const struct message WmClearStateButtonSeq
[] =
5332 { BM_SETSTATE
, sent
},
5333 { WM_CTLCOLORBTN
, sent
|parent
},
5334 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_BUTTON
, BN_UNHILITE
) },
5335 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5338 static const struct message WmClearStateOwnerdrawSeq
[] =
5340 { BM_SETSTATE
, sent
},
5341 { WM_CTLCOLORBTN
, sent
|parent
},
5342 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_BUTTON
, 0x000020e4 },
5343 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5346 static const struct message WmSetCheckIgnoredSeq
[] =
5348 { BM_SETCHECK
, sent
},
5349 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5352 static const struct message WmSetCheckStaticSeq
[] =
5354 { BM_SETCHECK
, sent
},
5355 { WM_CTLCOLORSTATIC
, sent
|parent
},
5356 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5360 static WNDPROC old_button_proc
;
5362 static LRESULT CALLBACK
button_hook_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
5364 static LONG defwndproc_counter
= 0;
5366 struct recvd_message msg
;
5368 if (ignore_message( message
)) return 0;
5376 ok(GetCapture() == hwnd
, "GetCapture() = %p\n", GetCapture());
5380 msg
.message
= message
;
5381 msg
.flags
= sent
|wparam
|lparam
;
5382 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
5383 msg
.wParam
= wParam
;
5384 msg
.lParam
= lParam
;
5385 msg
.descr
= "button";
5389 defwndproc_counter
++;
5390 ret
= CallWindowProcA(old_button_proc
, hwnd
, message
, wParam
, lParam
);
5391 defwndproc_counter
--;
5396 static void subclass_button(void)
5400 if (!GetClassInfoA(0, "button", &cls
)) assert(0);
5402 old_button_proc
= cls
.lpfnWndProc
;
5404 cls
.hInstance
= GetModuleHandleA(NULL
);
5405 cls
.lpfnWndProc
= button_hook_proc
;
5406 cls
.lpszClassName
= "my_button_class";
5407 UnregisterClassA(cls
.lpszClassName
, cls
.hInstance
);
5408 if (!RegisterClassA(&cls
)) assert(0);
5411 static void test_button_messages(void)
5417 const struct message
*setfocus
;
5418 const struct message
*killfocus
;
5419 const struct message
*setstyle
;
5420 const struct message
*setstate
;
5421 const struct message
*clearstate
;
5422 const struct message
*setcheck
;
5424 { BS_PUSHBUTTON
, DLGC_BUTTON
| DLGC_UNDEFPUSHBUTTON
,
5425 WmSetFocusButtonSeq
, WmKillFocusButtonSeq
, WmSetStyleButtonSeq
,
5426 WmSetStateButtonSeq
, WmSetStateButtonSeq
, WmSetCheckIgnoredSeq
},
5427 { BS_DEFPUSHBUTTON
, DLGC_BUTTON
| DLGC_DEFPUSHBUTTON
,
5428 WmSetFocusButtonSeq
, WmKillFocusButtonSeq
, WmSetStyleButtonSeq
,
5429 WmSetStateButtonSeq
, WmSetStateButtonSeq
, WmSetCheckIgnoredSeq
},
5430 { BS_CHECKBOX
, DLGC_BUTTON
,
5431 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
, WmSetStyleStaticSeq
,
5432 WmSetStateStaticSeq
, WmSetStateStaticSeq
, WmSetCheckStaticSeq
},
5433 { BS_AUTOCHECKBOX
, DLGC_BUTTON
,
5434 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
, WmSetStyleStaticSeq
,
5435 WmSetStateStaticSeq
, WmSetStateStaticSeq
, WmSetCheckStaticSeq
},
5436 { BS_RADIOBUTTON
, DLGC_BUTTON
| DLGC_RADIOBUTTON
,
5437 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
, WmSetStyleStaticSeq
,
5438 WmSetStateStaticSeq
, WmSetStateStaticSeq
, WmSetCheckStaticSeq
},
5439 { BS_3STATE
, DLGC_BUTTON
,
5440 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
, WmSetStyleStaticSeq
,
5441 WmSetStateStaticSeq
, WmSetStateStaticSeq
, WmSetCheckStaticSeq
},
5442 { BS_AUTO3STATE
, DLGC_BUTTON
,
5443 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
, WmSetStyleStaticSeq
,
5444 WmSetStateStaticSeq
, WmSetStateStaticSeq
, WmSetCheckStaticSeq
},
5445 { BS_GROUPBOX
, DLGC_STATIC
,
5446 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
, WmSetStyleStaticSeq
,
5447 WmSetStateStaticSeq
, WmSetStateStaticSeq
, WmSetCheckIgnoredSeq
},
5448 { BS_USERBUTTON
, DLGC_BUTTON
| DLGC_UNDEFPUSHBUTTON
,
5449 WmSetFocusButtonSeq
, WmKillFocusButtonSeq
, WmSetStyleUserSeq
,
5450 WmSetStateUserSeq
, WmClearStateButtonSeq
, WmSetCheckIgnoredSeq
},
5451 { BS_AUTORADIOBUTTON
, DLGC_BUTTON
| DLGC_RADIOBUTTON
,
5452 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
, WmSetStyleStaticSeq
,
5453 WmSetStateStaticSeq
, WmSetStateStaticSeq
, WmSetCheckStaticSeq
},
5454 { BS_OWNERDRAW
, DLGC_BUTTON
,
5455 WmSetFocusOwnerdrawSeq
, WmKillFocusOwnerdrawSeq
, WmSetStyleOwnerdrawSeq
,
5456 WmSetStateOwnerdrawSeq
, WmClearStateOwnerdrawSeq
, WmSetCheckIgnoredSeq
},
5463 /* selection with VK_SPACE should capture button window */
5464 hwnd
= CreateWindowExA(0, "button", "test", BS_CHECKBOX
| WS_VISIBLE
| WS_POPUP
,
5465 0, 0, 50, 14, 0, 0, 0, NULL
);
5466 ok(hwnd
!= 0, "Failed to create button window\n");
5469 SendMessageA(hwnd
, WM_KEYDOWN
, VK_SPACE
, 0);
5470 ok(GetCapture() == hwnd
, "Should be captured on VK_SPACE WM_KEYDOWN\n");
5471 SendMessageA(hwnd
, WM_KEYUP
, VK_SPACE
, 0);
5472 DestroyWindow(hwnd
);
5476 parent
= CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
5477 100, 100, 200, 200, 0, 0, 0, NULL
);
5478 ok(parent
!= 0, "Failed to create parent window\n");
5480 for (i
= 0; i
< sizeof(button
)/sizeof(button
[0]); i
++)
5485 trace("button style %08x\n", button
[i
].style
);
5487 hwnd
= CreateWindowExA(0, "my_button_class", "test", button
[i
].style
| WS_CHILD
| BS_NOTIFY
,
5488 0, 0, 50, 14, parent
, (HMENU
)ID_BUTTON
, 0, NULL
);
5489 ok(hwnd
!= 0, "Failed to create button window\n");
5491 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
5492 style
&= ~(WS_CHILD
| BS_NOTIFY
);
5493 /* XP turns a BS_USERBUTTON into BS_PUSHBUTTON */
5494 if (button
[i
].style
== BS_USERBUTTON
)
5495 ok(style
== BS_PUSHBUTTON
, "expected style BS_PUSHBUTTON got %x\n", style
);
5497 ok(style
== button
[i
].style
, "expected style %x got %x\n", button
[i
].style
, style
);
5499 dlg_code
= SendMessageA(hwnd
, WM_GETDLGCODE
, 0, 0);
5500 ok(dlg_code
== button
[i
].dlg_code
, "%u: wrong dlg_code %08x\n", i
, dlg_code
);
5502 ShowWindow(hwnd
, SW_SHOW
);
5509 log_all_parent_messages
++;
5511 ok(GetFocus() == 0, "expected focus 0, got %p\n", GetFocus());
5513 SendMessageA(hwnd
, WM_APP
, 0, 0); /* place a separator mark here */
5514 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
5515 ok_sequence(button
[i
].setfocus
, "SetFocus(hwnd) on a button", FALSE
);
5518 SendMessageA(hwnd
, WM_APP
, 0, 0); /* place a separator mark here */
5519 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
5520 ok_sequence(button
[i
].killfocus
, "SetFocus(0) on a button", FALSE
);
5522 ok(GetFocus() == 0, "expected focus 0, got %p\n", GetFocus());
5524 SendMessageA(hwnd
, BM_SETSTYLE
, button
[i
].style
| BS_BOTTOM
, TRUE
);
5525 SendMessageA(hwnd
, WM_APP
, 0, 0); /* place a separator mark here */
5526 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
5527 ok_sequence(button
[i
].setstyle
, "BM_SETSTYLE on a button", FALSE
);
5529 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
5530 style
&= ~(WS_VISIBLE
| WS_CHILD
| BS_NOTIFY
);
5531 /* XP doesn't turn a BS_USERBUTTON into BS_PUSHBUTTON here! */
5532 ok(style
== button
[i
].style
, "expected style %04x got %04x\n", button
[i
].style
, style
);
5534 state
= SendMessageA(hwnd
, BM_GETSTATE
, 0, 0);
5535 ok(state
== 0, "expected state 0, got %04x\n", state
);
5539 SendMessageA(hwnd
, BM_SETSTATE
, TRUE
, 0);
5540 SendMessageA(hwnd
, WM_APP
, 0, 0); /* place a separator mark here */
5541 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
5542 ok_sequence(button
[i
].setstate
, "BM_SETSTATE/TRUE on a button", FALSE
);
5544 state
= SendMessageA(hwnd
, BM_GETSTATE
, 0, 0);
5545 ok(state
== 0x0004, "expected state 0x0004, got %04x\n", state
);
5547 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
5548 style
&= ~(WS_CHILD
| BS_NOTIFY
| WS_VISIBLE
);
5549 ok(style
== button
[i
].style
, "expected style %04x got %04x\n", button
[i
].style
, style
);
5553 SendMessageA(hwnd
, BM_SETSTATE
, FALSE
, 0);
5554 SendMessageA(hwnd
, WM_APP
, 0, 0); /* place a separator mark here */
5555 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
5556 ok_sequence(button
[i
].clearstate
, "BM_SETSTATE/FALSE on a button", FALSE
);
5558 state
= SendMessageA(hwnd
, BM_GETSTATE
, 0, 0);
5559 ok(state
== 0, "expected state 0, got %04x\n", state
);
5561 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
5562 style
&= ~(WS_CHILD
| BS_NOTIFY
| WS_VISIBLE
);
5563 ok(style
== button
[i
].style
, "expected style %04x got %04x\n", button
[i
].style
, style
);
5565 state
= SendMessageA(hwnd
, BM_GETCHECK
, 0, 0);
5566 ok(state
== BST_UNCHECKED
, "expected BST_UNCHECKED, got %04x\n", state
);
5570 SendMessageA(hwnd
, BM_SETCHECK
, BST_UNCHECKED
, 0);
5571 SendMessageA(hwnd
, WM_APP
, 0, 0); /* place a separator mark here */
5572 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
5573 ok_sequence(WmSetCheckIgnoredSeq
, "BM_SETCHECK on a button", FALSE
);
5575 state
= SendMessageA(hwnd
, BM_GETCHECK
, 0, 0);
5576 ok(state
== BST_UNCHECKED
, "expected BST_UNCHECKED, got %04x\n", state
);
5578 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
5579 style
&= ~(WS_CHILD
| BS_NOTIFY
| WS_VISIBLE
);
5580 ok(style
== button
[i
].style
, "expected style %04x got %04x\n", button
[i
].style
, style
);
5584 SendMessageA(hwnd
, BM_SETCHECK
, BST_CHECKED
, 0);
5585 SendMessageA(hwnd
, WM_APP
, 0, 0); /* place a separator mark here */
5586 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
5587 ok_sequence(button
[i
].setcheck
, "BM_SETCHECK on a button", FALSE
);
5589 state
= SendMessageA(hwnd
, BM_GETCHECK
, 0, 0);
5590 if (button
[i
].style
== BS_PUSHBUTTON
||
5591 button
[i
].style
== BS_DEFPUSHBUTTON
||
5592 button
[i
].style
== BS_GROUPBOX
||
5593 button
[i
].style
== BS_USERBUTTON
||
5594 button
[i
].style
== BS_OWNERDRAW
)
5595 ok(state
== BST_UNCHECKED
, "expected check 0, got %04x\n", state
);
5597 ok(state
== BST_CHECKED
, "expected check 1, got %04x\n", state
);
5599 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
5600 style
&= ~(WS_CHILD
| BS_NOTIFY
| WS_VISIBLE
);
5601 if (button
[i
].style
== BS_RADIOBUTTON
||
5602 button
[i
].style
== BS_AUTORADIOBUTTON
)
5603 ok(style
== (button
[i
].style
| WS_TABSTOP
), "expected style %04x | WS_TABSTOP got %04x\n", button
[i
].style
, style
);
5605 ok(style
== button
[i
].style
, "expected style %04x got %04x\n", button
[i
].style
, style
);
5607 log_all_parent_messages
--;
5609 DestroyWindow(hwnd
);
5612 DestroyWindow(parent
);
5614 hwnd
= CreateWindowExA(0, "my_button_class", "test", BS_PUSHBUTTON
| WS_POPUP
| WS_VISIBLE
,
5615 0, 0, 50, 14, 0, 0, 0, NULL
);
5616 ok(hwnd
!= 0, "Failed to create button window\n");
5618 SetForegroundWindow(hwnd
);
5621 SetActiveWindow(hwnd
);
5625 SendMessageA(hwnd
, WM_LBUTTONDOWN
, 0, 0);
5626 ok_sequence(WmLButtonDownSeq
, "WM_LBUTTONDOWN on a button", FALSE
);
5628 SendMessageA(hwnd
, WM_LBUTTONUP
, 0, 0);
5629 ok_sequence(WmLButtonUpSeq
, "WM_LBUTTONUP on a button", FALSE
);
5632 zfont
= GetStockObject(SYSTEM_FONT
);
5633 SendMessageA(hwnd
, WM_SETFONT
, (WPARAM
)zfont
, TRUE
);
5635 ok_sequence(WmSetFontButtonSeq
, "WM_SETFONT on a button", FALSE
);
5637 DestroyWindow(hwnd
);
5640 /****************** static message test *************************/
5641 static const struct message WmSetFontStaticSeq
[] =
5643 { WM_SETFONT
, sent
},
5644 { WM_PAINT
, sent
|defwinproc
|optional
},
5645 { WM_ERASEBKGND
, sent
|defwinproc
|optional
},
5646 { WM_CTLCOLORSTATIC
, sent
|defwinproc
|optional
},
5650 static WNDPROC old_static_proc
;
5652 static LRESULT CALLBACK
static_hook_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
5654 static LONG defwndproc_counter
= 0;
5656 struct recvd_message msg
;
5658 if (ignore_message( message
)) return 0;
5661 msg
.message
= message
;
5662 msg
.flags
= sent
|wparam
|lparam
;
5663 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
5664 msg
.wParam
= wParam
;
5665 msg
.lParam
= lParam
;
5666 msg
.descr
= "static";
5669 defwndproc_counter
++;
5670 ret
= CallWindowProcA(old_static_proc
, hwnd
, message
, wParam
, lParam
);
5671 defwndproc_counter
--;
5676 static void subclass_static(void)
5680 if (!GetClassInfoA(0, "static", &cls
)) assert(0);
5682 old_static_proc
= cls
.lpfnWndProc
;
5684 cls
.hInstance
= GetModuleHandleA(NULL
);
5685 cls
.lpfnWndProc
= static_hook_proc
;
5686 cls
.lpszClassName
= "my_static_class";
5687 UnregisterClassA(cls
.lpszClassName
, cls
.hInstance
);
5688 if (!RegisterClassA(&cls
)) assert(0);
5691 static void test_static_messages(void)
5693 /* FIXME: make as comprehensive as the button message test */
5698 const struct message
*setfont
;
5700 { SS_LEFT
, DLGC_STATIC
,
5701 WmSetFontStaticSeq
}
5709 for (i
= 0; i
< sizeof(static_ctrl
)/sizeof(static_ctrl
[0]); i
++)
5711 hwnd
= CreateWindowExA(0, "my_static_class", "test", static_ctrl
[i
].style
| WS_POPUP
,
5712 0, 0, 50, 14, 0, 0, 0, NULL
);
5713 ok(hwnd
!= 0, "Failed to create static window\n");
5715 dlg_code
= SendMessageA(hwnd
, WM_GETDLGCODE
, 0, 0);
5716 ok(dlg_code
== static_ctrl
[i
].dlg_code
, "%u: wrong dlg_code %08x\n", i
, dlg_code
);
5718 ShowWindow(hwnd
, SW_SHOW
);
5723 trace("static style %08x\n", static_ctrl
[i
].style
);
5724 SendMessageA(hwnd
, WM_SETFONT
, (WPARAM
)GetStockObject(DEFAULT_GUI_FONT
), TRUE
);
5725 ok_sequence(static_ctrl
[i
].setfont
, "WM_SETFONT on a static", FALSE
);
5727 DestroyWindow(hwnd
);
5731 /****************** ComboBox message test *************************/
5732 #define ID_COMBOBOX 0x000f
5734 static const struct message WmKeyDownComboSeq
[] =
5736 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_DOWN
, 0 },
5737 { WM_COMMAND
, sent
|wparam
|defwinproc
, MAKEWPARAM(1000, LBN_SELCHANGE
) },
5738 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_COMBOBOX
, CBN_SELENDOK
) },
5739 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_COMBOBOX
, CBN_SELCHANGE
) },
5740 { WM_CTLCOLOREDIT
, sent
|parent
},
5741 { WM_KEYUP
, sent
|wparam
|lparam
, VK_DOWN
, 0 },
5745 static const struct message WmSetPosComboSeq
[] =
5747 { WM_WINDOWPOSCHANGING
, sent
},
5748 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
5749 { WM_CHILDACTIVATE
, sent
},
5750 { WM_WINDOWPOSCHANGED
, sent
},
5751 { WM_MOVE
, sent
|defwinproc
},
5752 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
5753 { WM_WINDOWPOSCHANGING
, sent
|defwinproc
},
5754 { WM_NCCALCSIZE
, sent
|defwinproc
|wparam
, TRUE
},
5755 { WM_WINDOWPOSCHANGED
, sent
|defwinproc
},
5756 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
5760 static WNDPROC old_combobox_proc
;
5762 static LRESULT CALLBACK
combobox_hook_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
5764 static LONG defwndproc_counter
= 0;
5766 struct recvd_message msg
;
5768 /* do not log painting messages */
5769 if (message
!= WM_PAINT
&&
5770 message
!= WM_NCPAINT
&&
5771 message
!= WM_SYNCPAINT
&&
5772 message
!= WM_ERASEBKGND
&&
5773 message
!= WM_NCHITTEST
&&
5774 message
!= WM_GETTEXT
&&
5775 !ignore_message( message
))
5778 msg
.message
= message
;
5779 msg
.flags
= sent
|wparam
|lparam
;
5780 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
5781 msg
.wParam
= wParam
;
5782 msg
.lParam
= lParam
;
5783 msg
.descr
= "combo";
5787 defwndproc_counter
++;
5788 ret
= CallWindowProcA(old_combobox_proc
, hwnd
, message
, wParam
, lParam
);
5789 defwndproc_counter
--;
5794 static void subclass_combobox(void)
5798 if (!GetClassInfoA(0, "ComboBox", &cls
)) assert(0);
5800 old_combobox_proc
= cls
.lpfnWndProc
;
5802 cls
.hInstance
= GetModuleHandleA(NULL
);
5803 cls
.lpfnWndProc
= combobox_hook_proc
;
5804 cls
.lpszClassName
= "my_combobox_class";
5805 UnregisterClassA(cls
.lpszClassName
, cls
.hInstance
);
5806 if (!RegisterClassA(&cls
)) assert(0);
5809 static void test_combobox_messages(void)
5814 subclass_combobox();
5816 parent
= CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
5817 100, 100, 200, 200, 0, 0, 0, NULL
);
5818 ok(parent
!= 0, "Failed to create parent window\n");
5821 combo
= CreateWindowExA(0, "my_combobox_class", "test", WS_CHILD
| WS_VISIBLE
| CBS_DROPDOWNLIST
| CBS_HASSTRINGS
,
5822 0, 0, 100, 150, parent
, (HMENU
)ID_COMBOBOX
, 0, NULL
);
5823 ok(combo
!= 0, "Failed to create combobox window\n");
5825 UpdateWindow(combo
);
5827 ret
= SendMessageA(combo
, WM_GETDLGCODE
, 0, 0);
5828 ok(ret
== (DLGC_WANTCHARS
| DLGC_WANTARROWS
), "wrong dlg_code %08lx\n", ret
);
5830 ret
= SendMessageA(combo
, CB_ADDSTRING
, 0, (LPARAM
)"item 0");
5831 ok(ret
== 0, "expected 0, got %ld\n", ret
);
5832 ret
= SendMessageA(combo
, CB_ADDSTRING
, 0, (LPARAM
)"item 1");
5833 ok(ret
== 1, "expected 1, got %ld\n", ret
);
5834 ret
= SendMessageA(combo
, CB_ADDSTRING
, 0, (LPARAM
)"item 2");
5835 ok(ret
== 2, "expected 2, got %ld\n", ret
);
5837 SendMessageA(combo
, CB_SETCURSEL
, 0, 0);
5841 log_all_parent_messages
++;
5842 SendMessageA(combo
, WM_KEYDOWN
, VK_DOWN
, 0);
5843 SendMessageA(combo
, WM_KEYUP
, VK_DOWN
, 0);
5844 log_all_parent_messages
--;
5845 ok_sequence(WmKeyDownComboSeq
, "WM_KEYDOWN/VK_DOWN on a ComboBox", FALSE
);
5848 SetWindowPos(combo
, 0, 10, 10, 120, 130, SWP_NOZORDER
);
5849 ok_sequence(WmSetPosComboSeq
, "repositioning messages on a ComboBox", FALSE
);
5851 DestroyWindow(combo
);
5852 DestroyWindow(parent
);
5855 /****************** WM_IME_KEYDOWN message test *******************/
5857 static const struct message WmImeKeydownMsgSeq_0
[] =
5859 { WM_IME_KEYDOWN
, wparam
, VK_RETURN
},
5860 { WM_CHAR
, wparam
, 'A' },
5864 static const struct message WmImeKeydownMsgSeq_1
[] =
5866 { WM_KEYDOWN
, optional
|wparam
, VK_RETURN
},
5867 { WM_CHAR
, optional
|wparam
, VK_RETURN
},
5871 static LRESULT WINAPI
wmime_keydown_procA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
5873 struct recvd_message msg
;
5876 msg
.message
= message
;
5877 msg
.flags
= wparam
|lparam
;
5878 msg
.wParam
= wParam
;
5879 msg
.lParam
= lParam
;
5880 msg
.descr
= "wmime_keydown";
5883 return DefWindowProcA(hwnd
, message
, wParam
, lParam
);
5886 static void register_wmime_keydown_class(void)
5890 ZeroMemory(&cls
, sizeof(WNDCLASSA
));
5891 cls
.lpfnWndProc
= wmime_keydown_procA
;
5892 cls
.hInstance
= GetModuleHandleA(0);
5893 cls
.lpszClassName
= "wmime_keydown_class";
5894 if (!RegisterClassA(&cls
)) assert(0);
5897 static void test_wmime_keydown_message(void)
5902 trace("Message sequences by WM_IME_KEYDOWN\n");
5904 register_wmime_keydown_class();
5905 hwnd
= CreateWindowExA(0, "wmime_keydown_class", NULL
, WS_OVERLAPPEDWINDOW
,
5906 CW_USEDEFAULT
, CW_USEDEFAULT
, 300, 300, 0,
5911 SendMessageA(hwnd
, WM_IME_KEYDOWN
, VK_RETURN
, 0x1c0001);
5912 SendMessageA(hwnd
, WM_CHAR
, 'A', 1);
5913 ok_sequence(WmImeKeydownMsgSeq_0
, "WM_IME_KEYDOWN 0", FALSE
);
5915 while ( PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
) )
5917 TranslateMessage(&msg
);
5918 DispatchMessageA(&msg
);
5920 ok_sequence(WmImeKeydownMsgSeq_1
, "WM_IME_KEYDOWN 1", FALSE
);
5922 DestroyWindow(hwnd
);
5925 /************* painting message test ********************/
5927 void dump_region(HRGN hrgn
)
5930 RGNDATA
*data
= NULL
;
5935 printf( "null region\n" );
5938 if (!(size
= GetRegionData( hrgn
, 0, NULL
))) return;
5939 if (!(data
= HeapAlloc( GetProcessHeap(), 0, size
))) return;
5940 GetRegionData( hrgn
, size
, data
);
5941 printf("%d rects:", data
->rdh
.nCount
);
5942 for (i
= 0, rect
= (RECT
*)data
->Buffer
; i
< data
->rdh
.nCount
; i
++, rect
++)
5943 printf( " (%d,%d)-(%d,%d)", rect
->left
, rect
->top
, rect
->right
, rect
->bottom
);
5945 HeapFree( GetProcessHeap(), 0, data
);
5948 static void check_update_rgn( HWND hwnd
, HRGN hrgn
)
5952 HRGN tmp
= CreateRectRgn( 0, 0, 0, 0 );
5953 HRGN update
= CreateRectRgn( 0, 0, 0, 0 );
5955 ret
= GetUpdateRgn( hwnd
, update
, FALSE
);
5956 ok( ret
!= ERROR
, "GetUpdateRgn failed\n" );
5957 if (ret
== NULLREGION
)
5959 ok( !hrgn
, "Update region shouldn't be empty\n" );
5963 if (CombineRgn( tmp
, hrgn
, update
, RGN_XOR
) != NULLREGION
)
5965 ok( 0, "Regions are different\n" );
5966 if (winetest_debug
> 0)
5968 printf( "Update region: " );
5969 dump_region( update
);
5970 printf( "Wanted region: " );
5971 dump_region( hrgn
);
5975 GetRgnBox( update
, &r1
);
5976 GetUpdateRect( hwnd
, &r2
, FALSE
);
5977 ok( r1
.left
== r2
.left
&& r1
.top
== r2
.top
&& r1
.right
== r2
.right
&& r1
.bottom
== r2
.bottom
,
5978 "Rectangles are different: %d,%d-%d,%d / %d,%d-%d,%d\n",
5979 r1
.left
, r1
.top
, r1
.right
, r1
.bottom
, r2
.left
, r2
.top
, r2
.right
, r2
.bottom
);
5981 DeleteObject( tmp
);
5982 DeleteObject( update
);
5985 static const struct message WmInvalidateRgn
[] = {
5986 { WM_NCPAINT
, sent
},
5987 { WM_GETTEXT
, sent
|defwinproc
|optional
},
5991 static const struct message WmGetUpdateRect
[] = {
5992 { WM_NCPAINT
, sent
},
5993 { WM_GETTEXT
, sent
|defwinproc
|optional
},
5998 static const struct message WmInvalidateFull
[] = {
5999 { WM_NCPAINT
, sent
|wparam
, 1 },
6000 { WM_GETTEXT
, sent
|defwinproc
|optional
},
6004 static const struct message WmInvalidateErase
[] = {
6005 { WM_NCPAINT
, sent
|wparam
, 1 },
6006 { WM_GETTEXT
, sent
|defwinproc
|optional
},
6007 { WM_ERASEBKGND
, sent
},
6011 static const struct message WmInvalidatePaint
[] = {
6013 { WM_NCPAINT
, sent
|wparam
|beginpaint
, 1 },
6014 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
6018 static const struct message WmInvalidateErasePaint
[] = {
6020 { WM_NCPAINT
, sent
|wparam
|beginpaint
, 1 },
6021 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
6022 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
6026 static const struct message WmInvalidateErasePaint2
[] = {
6028 { WM_NCPAINT
, sent
|beginpaint
},
6029 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
6030 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
6034 static const struct message WmErase
[] = {
6035 { WM_ERASEBKGND
, sent
},
6039 static const struct message WmPaint
[] = {
6044 static const struct message WmParentOnlyPaint
[] = {
6045 { WM_PAINT
, sent
|parent
},
6049 static const struct message WmInvalidateParent
[] = {
6050 { WM_NCPAINT
, sent
|parent
},
6051 { WM_GETTEXT
, sent
|defwinproc
|parent
|optional
},
6052 { WM_ERASEBKGND
, sent
|parent
},
6056 static const struct message WmInvalidateParentChild
[] = {
6057 { WM_NCPAINT
, sent
|parent
},
6058 { WM_GETTEXT
, sent
|defwinproc
|parent
|optional
},
6059 { WM_ERASEBKGND
, sent
|parent
},
6060 { WM_NCPAINT
, sent
},
6061 { WM_GETTEXT
, sent
|defwinproc
|optional
},
6062 { WM_ERASEBKGND
, sent
},
6066 static const struct message WmInvalidateParentChild2
[] = {
6067 { WM_ERASEBKGND
, sent
|parent
},
6068 { WM_NCPAINT
, sent
},
6069 { WM_GETTEXT
, sent
|defwinproc
|optional
},
6070 { WM_ERASEBKGND
, sent
},
6074 static const struct message WmParentPaint
[] = {
6075 { WM_PAINT
, sent
|parent
},
6080 static const struct message WmParentPaintNc
[] = {
6081 { WM_PAINT
, sent
|parent
},
6083 { WM_NCPAINT
, sent
|beginpaint
},
6084 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
6085 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
6089 static const struct message WmChildPaintNc
[] = {
6091 { WM_NCPAINT
, sent
|beginpaint
},
6092 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
6093 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
6097 static const struct message WmParentErasePaint
[] = {
6098 { WM_PAINT
, sent
|parent
},
6099 { WM_NCPAINT
, sent
|parent
|beginpaint
},
6100 { WM_GETTEXT
, sent
|parent
|beginpaint
|defwinproc
|optional
},
6101 { WM_ERASEBKGND
, sent
|parent
|beginpaint
|optional
},
6103 { WM_NCPAINT
, sent
|beginpaint
},
6104 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
6105 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
6109 static const struct message WmParentOnlyNcPaint
[] = {
6110 { WM_PAINT
, sent
|parent
},
6111 { WM_NCPAINT
, sent
|parent
|beginpaint
},
6112 { WM_GETTEXT
, sent
|parent
|beginpaint
|defwinproc
|optional
},
6116 static const struct message WmSetParentStyle
[] = {
6117 { WM_STYLECHANGING
, sent
|parent
},
6118 { WM_STYLECHANGED
, sent
|parent
},
6122 static void test_paint_messages(void)
6128 HWND hparent
, hchild
;
6129 HRGN hrgn
= CreateRectRgn( 0, 0, 0, 0 );
6130 HRGN hrgn2
= CreateRectRgn( 0, 0, 0, 0 );
6131 HWND hwnd
= CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW
,
6132 100, 100, 200, 200, 0, 0, 0, NULL
);
6133 ok (hwnd
!= 0, "Failed to create overlapped window\n");
6135 ShowWindow( hwnd
, SW_SHOW
);
6136 UpdateWindow( hwnd
);
6140 check_update_rgn( hwnd
, 0 );
6141 SetRectRgn( hrgn
, 10, 10, 20, 20 );
6142 ret
= RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
);
6143 ok(ret
, "RedrawWindow returned %d instead of TRUE\n", ret
);
6144 check_update_rgn( hwnd
, hrgn
);
6145 SetRectRgn( hrgn2
, 20, 20, 30, 30 );
6146 ret
= RedrawWindow( hwnd
, NULL
, hrgn2
, RDW_INVALIDATE
);
6147 ok(ret
, "RedrawWindow returned %d instead of TRUE\n", ret
);
6148 CombineRgn( hrgn
, hrgn
, hrgn2
, RGN_OR
);
6149 check_update_rgn( hwnd
, hrgn
);
6150 /* validate everything */
6151 ret
= RedrawWindow( hwnd
, NULL
, NULL
, RDW_VALIDATE
);
6152 ok(ret
, "RedrawWindow returned %d instead of TRUE\n", ret
);
6153 check_update_rgn( hwnd
, 0 );
6155 /* test empty region */
6156 SetRectRgn( hrgn
, 10, 10, 10, 15 );
6157 ret
= RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
);
6158 ok(ret
, "RedrawWindow returned %d instead of TRUE\n", ret
);
6159 check_update_rgn( hwnd
, 0 );
6160 /* test empty rect */
6161 SetRect( &rect
, 10, 10, 10, 15 );
6162 ret
= RedrawWindow( hwnd
, &rect
, NULL
, RDW_INVALIDATE
);
6163 ok(ret
, "RedrawWindow returned %d instead of TRUE\n", ret
);
6164 check_update_rgn( hwnd
, 0 );
6166 /* flush pending messages */
6170 GetClientRect( hwnd
, &rect
);
6171 SetRectRgn( hrgn
, 0, 0, rect
.right
- rect
.left
, rect
.bottom
- rect
.top
);
6172 /* MSDN: if hwnd parameter is NULL, InvalidateRect invalidates and redraws
6173 * all windows and sends WM_ERASEBKGND and WM_NCPAINT.
6175 trace("testing InvalidateRect(0, NULL, FALSE)\n");
6176 SetRectEmpty( &rect
);
6177 ok(InvalidateRect(0, &rect
, FALSE
), "InvalidateRect(0, &rc, FALSE) should fail\n");
6178 check_update_rgn( hwnd
, hrgn
);
6179 ok_sequence( WmInvalidateErase
, "InvalidateErase", FALSE
);
6181 ok_sequence( WmPaint
, "Paint", FALSE
);
6182 RedrawWindow( hwnd
, NULL
, NULL
, RDW_VALIDATE
);
6183 check_update_rgn( hwnd
, 0 );
6185 /* MSDN: if hwnd parameter is NULL, ValidateRect invalidates and redraws
6186 * all windows and sends WM_ERASEBKGND and WM_NCPAINT.
6188 trace("testing ValidateRect(0, NULL)\n");
6189 SetRectEmpty( &rect
);
6190 if (ValidateRect(0, &rect
)) /* not supported on Win9x */
6192 check_update_rgn( hwnd
, hrgn
);
6193 ok_sequence( WmInvalidateErase
, "InvalidateErase", FALSE
);
6195 ok_sequence( WmPaint
, "Paint", FALSE
);
6196 RedrawWindow( hwnd
, NULL
, NULL
, RDW_VALIDATE
);
6197 check_update_rgn( hwnd
, 0 );
6200 trace("testing InvalidateRgn(0, NULL, FALSE)\n");
6201 SetLastError(0xdeadbeef);
6202 ok(!InvalidateRgn(0, NULL
, FALSE
), "InvalidateRgn(0, NULL, FALSE) should fail\n");
6203 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
|| GetLastError() == 0xdeadbeef,
6204 "wrong error code %d\n", GetLastError());
6205 check_update_rgn( hwnd
, 0 );
6207 ok_sequence( WmEmptySeq
, "WmEmptySeq", FALSE
);
6209 trace("testing ValidateRgn(0, NULL)\n");
6210 SetLastError(0xdeadbeef);
6211 ok(!ValidateRgn(0, NULL
), "ValidateRgn(0, NULL) should fail\n");
6212 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
||
6213 broken( GetLastError() == 0xdeadbeef ) /* win9x */,
6214 "wrong error code %d\n", GetLastError());
6215 check_update_rgn( hwnd
, 0 );
6217 ok_sequence( WmEmptySeq
, "WmEmptySeq", FALSE
);
6219 trace("testing UpdateWindow(NULL)\n");
6220 SetLastError(0xdeadbeef);
6221 ok(!UpdateWindow(NULL
), "UpdateWindow(NULL) should fail\n");
6222 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
||
6223 broken( GetLastError() == 0xdeadbeef ) /* win9x */,
6224 "wrong error code %d\n", GetLastError());
6225 check_update_rgn( hwnd
, 0 );
6227 ok_sequence( WmEmptySeq
, "WmEmptySeq", FALSE
);
6229 /* now with frame */
6230 SetRectRgn( hrgn
, -5, -5, 20, 20 );
6232 /* flush pending messages */
6235 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_FRAME
);
6236 ok_sequence( WmEmptySeq
, "EmptySeq", FALSE
);
6238 SetRectRgn( hrgn
, 0, 0, 20, 20 ); /* GetUpdateRgn clips to client area */
6239 check_update_rgn( hwnd
, hrgn
);
6242 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASENOW
);
6243 ok_sequence( WmInvalidateRgn
, "InvalidateRgn", FALSE
);
6246 RedrawWindow( hwnd
, NULL
, NULL
, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASENOW
);
6247 ok_sequence( WmInvalidateFull
, "InvalidateFull", FALSE
);
6249 GetClientRect( hwnd
, &rect
);
6250 SetRectRgn( hrgn
, rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
6251 check_update_rgn( hwnd
, hrgn
);
6254 RedrawWindow( hwnd
, NULL
, NULL
, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASE
| RDW_ERASENOW
);
6255 ok_sequence( WmInvalidateErase
, "InvalidateErase", FALSE
);
6258 RedrawWindow( hwnd
, NULL
, NULL
, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASENOW
| RDW_UPDATENOW
);
6259 ok_sequence( WmInvalidatePaint
, "InvalidatePaint", FALSE
);
6260 check_update_rgn( hwnd
, 0 );
6263 RedrawWindow( hwnd
, NULL
, NULL
, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASE
| RDW_UPDATENOW
);
6264 ok_sequence( WmInvalidateErasePaint
, "InvalidateErasePaint", FALSE
);
6265 check_update_rgn( hwnd
, 0 );
6268 SetRectRgn( hrgn
, 0, 0, 100, 100 );
6269 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
);
6270 SetRectRgn( hrgn
, 0, 0, 50, 100 );
6271 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_VALIDATE
);
6272 SetRectRgn( hrgn
, 50, 0, 100, 100 );
6273 check_update_rgn( hwnd
, hrgn
);
6274 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_VALIDATE
| RDW_ERASENOW
);
6275 ok_sequence( WmEmptySeq
, "EmptySeq", FALSE
); /* must not generate messages, everything is valid */
6276 check_update_rgn( hwnd
, 0 );
6279 SetRectRgn( hrgn
, 0, 0, 100, 100 );
6280 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_ERASE
);
6281 SetRectRgn( hrgn
, 0, 0, 100, 50 );
6282 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_VALIDATE
| RDW_ERASENOW
);
6283 ok_sequence( WmErase
, "Erase", FALSE
);
6284 SetRectRgn( hrgn
, 0, 50, 100, 100 );
6285 check_update_rgn( hwnd
, hrgn
);
6288 SetRectRgn( hrgn
, 0, 0, 100, 100 );
6289 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_ERASE
);
6290 SetRectRgn( hrgn
, 0, 0, 50, 50 );
6291 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_VALIDATE
| RDW_NOERASE
| RDW_UPDATENOW
);
6292 ok_sequence( WmPaint
, "Paint", FALSE
);
6295 SetRectRgn( hrgn
, -4, -4, -2, -2 );
6296 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_FRAME
);
6297 SetRectRgn( hrgn
, -200, -200, -198, -198 );
6298 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_VALIDATE
| RDW_NOFRAME
| RDW_ERASENOW
);
6299 ok_sequence( WmEmptySeq
, "EmptySeq", FALSE
);
6302 SetRectRgn( hrgn
, -4, -4, -2, -2 );
6303 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_FRAME
);
6304 SetRectRgn( hrgn
, -4, -4, -3, -3 );
6305 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_VALIDATE
| RDW_NOFRAME
);
6306 SetRectRgn( hrgn
, 0, 0, 1, 1 );
6307 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_UPDATENOW
);
6308 ok_sequence( WmPaint
, "Paint", FALSE
);
6311 SetRectRgn( hrgn
, -4, -4, -1, -1 );
6312 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_FRAME
);
6313 RedrawWindow( hwnd
, NULL
, 0, RDW_ERASENOW
);
6314 /* make sure no WM_PAINT was generated */
6316 ok_sequence( WmInvalidateRgn
, "InvalidateRgn", FALSE
);
6319 SetRectRgn( hrgn
, -4, -4, -1, -1 );
6320 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_FRAME
);
6321 while (PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
))
6323 if (msg
.hwnd
== hwnd
&& msg
.message
== WM_PAINT
)
6325 /* GetUpdateRgn must return empty region since only nonclient area is invalidated */
6326 INT ret
= GetUpdateRgn( hwnd
, hrgn
, FALSE
);
6327 ok( ret
== NULLREGION
, "Invalid GetUpdateRgn result %d\n", ret
);
6328 ret
= GetUpdateRect( hwnd
, &rect
, FALSE
);
6329 ok( ret
, "Invalid GetUpdateRect result %d\n", ret
);
6330 /* this will send WM_NCPAINT and validate the non client area */
6331 ret
= GetUpdateRect( hwnd
, &rect
, TRUE
);
6332 ok( !ret
, "Invalid GetUpdateRect result %d\n", ret
);
6334 DispatchMessageA( &msg
);
6336 ok_sequence( WmGetUpdateRect
, "GetUpdateRect", FALSE
);
6338 DestroyWindow( hwnd
);
6340 /* now test with a child window */
6342 hparent
= CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW
,
6343 100, 100, 200, 200, 0, 0, 0, NULL
);
6344 ok (hparent
!= 0, "Failed to create parent window\n");
6346 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
| WS_VISIBLE
| WS_BORDER
,
6347 10, 10, 100, 100, hparent
, 0, 0, NULL
);
6348 ok (hchild
!= 0, "Failed to create child window\n");
6350 ShowWindow( hparent
, SW_SHOW
);
6351 UpdateWindow( hparent
);
6352 UpdateWindow( hchild
);
6355 log_all_parent_messages
++;
6357 SetRect( &rect
, 0, 0, 50, 50 );
6358 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
6359 RedrawWindow( hparent
, NULL
, 0, RDW_ERASENOW
| RDW_ALLCHILDREN
);
6360 ok_sequence( WmInvalidateParentChild
, "InvalidateParentChild", FALSE
);
6362 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
6364 MapWindowPoints( hchild
, hparent
, &pt
, 1 );
6365 SetRectRgn( hrgn
, 0, 0, 50 - pt
.x
, 50 - pt
.y
);
6366 check_update_rgn( hchild
, hrgn
);
6367 SetRectRgn( hrgn
, 0, 0, 50, 50 );
6368 check_update_rgn( hparent
, hrgn
);
6369 RedrawWindow( hparent
, NULL
, 0, RDW_ERASENOW
);
6370 ok_sequence( WmInvalidateParent
, "InvalidateParent", FALSE
);
6371 RedrawWindow( hchild
, NULL
, 0, RDW_ERASENOW
);
6372 ok_sequence( WmEmptySeq
, "EraseNow child", FALSE
);
6375 ok_sequence( WmParentPaintNc
, "WmParentPaintNc", FALSE
);
6377 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
| RDW_ALLCHILDREN
);
6378 RedrawWindow( hparent
, NULL
, 0, RDW_ERASENOW
);
6379 ok_sequence( WmInvalidateParent
, "InvalidateParent2", FALSE
);
6380 RedrawWindow( hchild
, NULL
, 0, RDW_ERASENOW
);
6381 ok_sequence( WmEmptySeq
, "EraseNow child", FALSE
);
6383 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
);
6384 RedrawWindow( hparent
, NULL
, 0, RDW_ERASENOW
| RDW_ALLCHILDREN
);
6385 ok_sequence( WmInvalidateParentChild2
, "InvalidateParentChild2", FALSE
);
6387 SetWindowLongA( hparent
, GWL_STYLE
, GetWindowLongA(hparent
,GWL_STYLE
) | WS_CLIPCHILDREN
);
6389 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
| RDW_ALLCHILDREN
);
6390 RedrawWindow( hparent
, NULL
, 0, RDW_ERASENOW
);
6391 ok_sequence( WmInvalidateParentChild
, "InvalidateParentChild3", FALSE
);
6393 /* flush all paint messages */
6397 /* RDW_UPDATENOW on child with WS_CLIPCHILDREN doesn't change corresponding parent area */
6398 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
| RDW_ALLCHILDREN
);
6399 SetRectRgn( hrgn
, 0, 0, 50, 50 );
6400 check_update_rgn( hparent
, hrgn
);
6401 RedrawWindow( hchild
, NULL
, 0, RDW_UPDATENOW
);
6402 ok_sequence( WmInvalidateErasePaint2
, "WmInvalidateErasePaint2", FALSE
);
6403 SetRectRgn( hrgn
, 0, 0, 50, 50 );
6404 check_update_rgn( hparent
, hrgn
);
6406 /* flush all paint messages */
6408 SetWindowLongA( hparent
, GWL_STYLE
, GetWindowLongA(hparent
,GWL_STYLE
) & ~WS_CLIPCHILDREN
);
6411 /* RDW_UPDATENOW on child without WS_CLIPCHILDREN will validate corresponding parent area */
6412 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
6413 SetRectRgn( hrgn
, 0, 0, 50, 50 );
6414 check_update_rgn( hparent
, hrgn
);
6415 RedrawWindow( hchild
, NULL
, 0, RDW_UPDATENOW
);
6416 ok_sequence( WmInvalidateErasePaint2
, "WmInvalidateErasePaint2", FALSE
);
6417 SetRectRgn( hrgn2
, 10, 10, 50, 50 );
6418 CombineRgn( hrgn
, hrgn
, hrgn2
, RGN_DIFF
);
6419 check_update_rgn( hparent
, hrgn
);
6420 /* flush all paint messages */
6424 /* same as above but parent gets completely validated */
6425 SetRect( &rect
, 20, 20, 30, 30 );
6426 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
6427 SetRectRgn( hrgn
, 20, 20, 30, 30 );
6428 check_update_rgn( hparent
, hrgn
);
6429 RedrawWindow( hchild
, NULL
, 0, RDW_UPDATENOW
);
6430 ok_sequence( WmInvalidateErasePaint2
, "WmInvalidateErasePaint2", FALSE
);
6431 check_update_rgn( hparent
, 0 ); /* no update region */
6433 ok_sequence( WmEmptySeq
, "WmEmpty", FALSE
); /* and no paint messages */
6435 /* make sure RDW_VALIDATE on child doesn't have the same effect */
6437 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
6438 SetRectRgn( hrgn
, 20, 20, 30, 30 );
6439 check_update_rgn( hparent
, hrgn
);
6440 RedrawWindow( hchild
, NULL
, 0, RDW_VALIDATE
| RDW_NOERASE
);
6441 SetRectRgn( hrgn
, 20, 20, 30, 30 );
6442 check_update_rgn( hparent
, hrgn
);
6444 /* same as above but normal WM_PAINT doesn't validate parent */
6446 SetRect( &rect
, 20, 20, 30, 30 );
6447 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
6448 SetRectRgn( hrgn
, 20, 20, 30, 30 );
6449 check_update_rgn( hparent
, hrgn
);
6450 /* no WM_PAINT in child while parent still pending */
6451 while (PeekMessageA( &msg
, hchild
, 0, 0, PM_REMOVE
)) DispatchMessageA( &msg
);
6452 ok_sequence( WmEmptySeq
, "No WM_PAINT", FALSE
);
6453 while (PeekMessageA( &msg
, hparent
, 0, 0, PM_REMOVE
)) DispatchMessageA( &msg
);
6454 ok_sequence( WmParentErasePaint
, "WmParentErasePaint", FALSE
);
6457 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
6458 /* no WM_PAINT in child while parent still pending */
6459 while (PeekMessageA( &msg
, hchild
, 0, 0, PM_REMOVE
)) DispatchMessageA( &msg
);
6460 ok_sequence( WmEmptySeq
, "No WM_PAINT", FALSE
);
6461 RedrawWindow( hparent
, &rect
, 0, RDW_VALIDATE
| RDW_NOERASE
| RDW_NOCHILDREN
);
6462 /* now that parent is valid child should get WM_PAINT */
6463 while (PeekMessageA( &msg
, hchild
, 0, 0, PM_REMOVE
)) DispatchMessageA( &msg
);
6464 ok_sequence( WmInvalidateErasePaint2
, "WmInvalidateErasePaint2", FALSE
);
6465 while (PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA( &msg
);
6466 ok_sequence( WmEmptySeq
, "No other message", FALSE
);
6468 /* same thing with WS_CLIPCHILDREN in parent */
6470 SetWindowLongA( hparent
, GWL_STYLE
, GetWindowLongA(hparent
,GWL_STYLE
) | WS_CLIPCHILDREN
);
6471 ok_sequence( WmSetParentStyle
, "WmSetParentStyle", FALSE
);
6472 /* changing style invalidates non client area, but we need to invalidate something else to see it */
6473 RedrawWindow( hparent
, &rect
, 0, RDW_UPDATENOW
);
6474 ok_sequence( WmEmptySeq
, "No message", FALSE
);
6475 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_UPDATENOW
);
6476 ok_sequence( WmParentOnlyNcPaint
, "WmParentOnlyNcPaint", FALSE
);
6479 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_ALLCHILDREN
);
6480 SetRectRgn( hrgn
, 20, 20, 30, 30 );
6481 check_update_rgn( hparent
, hrgn
);
6482 /* no WM_PAINT in child while parent still pending */
6483 while (PeekMessageA( &msg
, hchild
, 0, 0, PM_REMOVE
)) DispatchMessageA( &msg
);
6484 ok_sequence( WmEmptySeq
, "No WM_PAINT", FALSE
);
6485 /* WM_PAINT in parent first */
6486 while (PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA( &msg
);
6487 ok_sequence( WmParentPaintNc
, "WmParentPaintNc2", FALSE
);
6489 /* no RDW_ERASE in parent still causes RDW_ERASE and RDW_FRAME in child */
6491 SetRect( &rect
, 0, 0, 30, 30 );
6492 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ALLCHILDREN
);
6493 SetRectRgn( hrgn
, 0, 0, 30, 30 );
6494 check_update_rgn( hparent
, hrgn
);
6496 ok_sequence( WmParentPaintNc
, "WmParentPaintNc3", FALSE
);
6498 /* validate doesn't cause RDW_NOERASE or RDW_NOFRAME in child */
6500 SetRect( &rect
, -10, 0, 30, 30 );
6501 RedrawWindow( hchild
, &rect
, 0, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASE
);
6502 SetRect( &rect
, 0, 0, 20, 20 );
6503 RedrawWindow( hparent
, &rect
, 0, RDW_VALIDATE
| RDW_ALLCHILDREN
);
6504 RedrawWindow( hparent
, NULL
, 0, RDW_UPDATENOW
);
6505 ok_sequence( WmChildPaintNc
, "WmChildPaintNc", FALSE
);
6507 /* validate doesn't cause RDW_NOERASE or RDW_NOFRAME in child */
6509 SetRect( &rect
, -10, 0, 30, 30 );
6510 RedrawWindow( hchild
, &rect
, 0, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASE
);
6511 SetRect( &rect
, 0, 0, 100, 100 );
6512 RedrawWindow( hparent
, &rect
, 0, RDW_VALIDATE
| RDW_ALLCHILDREN
);
6513 RedrawWindow( hparent
, NULL
, 0, RDW_UPDATENOW
);
6514 ok_sequence( WmEmptySeq
, "WmChildPaintNc2", FALSE
);
6515 RedrawWindow( hparent
, NULL
, 0, RDW_ERASENOW
);
6516 ok_sequence( WmEmptySeq
, "WmChildPaintNc3", FALSE
);
6518 /* test RDW_INTERNALPAINT behavior */
6521 RedrawWindow( hparent
, NULL
, 0, RDW_INTERNALPAINT
| RDW_NOCHILDREN
);
6523 ok_sequence( WmParentOnlyPaint
, "WmParentOnlyPaint", FALSE
);
6525 RedrawWindow( hparent
, NULL
, 0, RDW_INTERNALPAINT
| RDW_ALLCHILDREN
);
6527 ok_sequence( WmParentPaint
, "WmParentPaint", FALSE
);
6529 RedrawWindow( hparent
, NULL
, 0, RDW_INTERNALPAINT
);
6531 ok_sequence( WmParentOnlyPaint
, "WmParentOnlyPaint", FALSE
);
6533 assert( GetWindowLongA(hparent
, GWL_STYLE
) & WS_CLIPCHILDREN
);
6534 UpdateWindow( hparent
);
6537 trace("testing SWP_FRAMECHANGED on parent with WS_CLIPCHILDREN\n");
6538 RedrawWindow( hchild
, NULL
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
6539 SetWindowPos( hparent
, 0, 0, 0, 0, 0, SWP_NOSIZE
| SWP_NOMOVE
|
6540 SWP_NOACTIVATE
| SWP_NOZORDER
| SWP_FRAMECHANGED
);
6542 ok_sequence(WmSWP_FrameChanged_clip
, "SetWindowPos:FrameChanged_clip", FALSE
);
6544 UpdateWindow( hparent
);
6547 trace("testing SWP_FRAMECHANGED|SWP_DEFERERASE on parent with WS_CLIPCHILDREN\n");
6548 RedrawWindow( hchild
, NULL
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
6549 SetWindowPos( hparent
, 0, 0, 0, 0, 0, SWP_NOSIZE
| SWP_NOMOVE
| SWP_DEFERERASE
|
6550 SWP_NOACTIVATE
| SWP_NOZORDER
| SWP_FRAMECHANGED
);
6552 ok_sequence(WmSWP_FrameChangedDeferErase
, "SetWindowPos:FrameChangedDeferErase", FALSE
);
6554 SetWindowLongA( hparent
, GWL_STYLE
, GetWindowLongA(hparent
,GWL_STYLE
) & ~WS_CLIPCHILDREN
);
6555 ok_sequence( WmSetParentStyle
, "WmSetParentStyle", FALSE
);
6556 RedrawWindow( hparent
, NULL
, 0, RDW_INTERNALPAINT
);
6558 ok_sequence( WmParentPaint
, "WmParentPaint", FALSE
);
6560 assert( !(GetWindowLongA(hparent
, GWL_STYLE
) & WS_CLIPCHILDREN
) );
6561 UpdateWindow( hparent
);
6564 trace("testing SWP_FRAMECHANGED on parent without WS_CLIPCHILDREN\n");
6565 RedrawWindow( hchild
, NULL
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
6566 SetWindowPos( hparent
, 0, 0, 0, 0, 0, SWP_NOSIZE
| SWP_NOMOVE
|
6567 SWP_NOACTIVATE
| SWP_NOZORDER
| SWP_FRAMECHANGED
);
6569 ok_sequence(WmSWP_FrameChanged_noclip
, "SetWindowPos:FrameChanged_noclip", FALSE
);
6571 UpdateWindow( hparent
);
6574 trace("testing SWP_FRAMECHANGED|SWP_DEFERERASE on parent without WS_CLIPCHILDREN\n");
6575 RedrawWindow( hchild
, NULL
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
6576 SetWindowPos( hparent
, 0, 0, 0, 0, 0, SWP_NOSIZE
| SWP_NOMOVE
| SWP_DEFERERASE
|
6577 SWP_NOACTIVATE
| SWP_NOZORDER
| SWP_FRAMECHANGED
);
6579 ok_sequence(WmSWP_FrameChangedDeferErase
, "SetWindowPos:FrameChangedDeferErase", FALSE
);
6581 ok(GetWindowLongA( hparent
, GWL_STYLE
) & WS_VISIBLE
, "parent should be visible\n");
6582 ok(GetWindowLongA( hchild
, GWL_STYLE
) & WS_VISIBLE
, "child should be visible\n");
6584 UpdateWindow( hparent
);
6587 trace("testing SetWindowPos(-10000, -10000) on child\n");
6588 SetWindowPos( hchild
, 0, -10000, -10000, 0, 0, SWP_NOSIZE
| SWP_NOACTIVATE
| SWP_NOZORDER
);
6589 check_update_rgn( hchild
, 0 );
6592 #if 0 /* this one doesn't pass under Wine yet */
6593 UpdateWindow( hparent
);
6596 trace("testing ShowWindow(SW_MINIMIZE) on child\n");
6597 ShowWindow( hchild
, SW_MINIMIZE
);
6598 check_update_rgn( hchild
, 0 );
6602 UpdateWindow( hparent
);
6605 trace("testing SetWindowPos(-10000, -10000) on parent\n");
6606 SetWindowPos( hparent
, 0, -10000, -10000, 0, 0, SWP_NOSIZE
| SWP_NOACTIVATE
| SWP_NOZORDER
);
6607 check_update_rgn( hparent
, 0 );
6610 log_all_parent_messages
--;
6611 DestroyWindow( hparent
);
6612 ok(!IsWindow(hchild
), "child must be destroyed with its parent\n");
6614 /* tests for moving windows off-screen (needs simple WS_POPUP windows) */
6616 hparent
= CreateWindowExA(0, "TestParentClass", "Test parent", WS_POPUP
| WS_VISIBLE
,
6617 100, 100, 200, 200, 0, 0, 0, NULL
);
6618 ok (hparent
!= 0, "Failed to create parent window\n");
6620 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
| WS_VISIBLE
,
6621 10, 10, 100, 100, hparent
, 0, 0, NULL
);
6622 ok (hchild
!= 0, "Failed to create child window\n");
6624 ShowWindow( hparent
, SW_SHOW
);
6625 UpdateWindow( hparent
);
6626 UpdateWindow( hchild
);
6630 /* moving child outside of parent boundaries changes update region */
6631 SetRect( &rect
, 0, 0, 40, 40 );
6632 RedrawWindow( hchild
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
);
6633 SetRectRgn( hrgn
, 0, 0, 40, 40 );
6634 check_update_rgn( hchild
, hrgn
);
6635 MoveWindow( hchild
, -10, 10, 100, 100, FALSE
);
6636 SetRectRgn( hrgn
, 10, 0, 40, 40 );
6637 check_update_rgn( hchild
, hrgn
);
6638 MoveWindow( hchild
, -10, -10, 100, 100, FALSE
);
6639 SetRectRgn( hrgn
, 10, 10, 40, 40 );
6640 check_update_rgn( hchild
, hrgn
);
6642 /* moving parent off-screen does too */
6643 SetRect( &rect
, 0, 0, 100, 100 );
6644 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_NOCHILDREN
);
6645 SetRectRgn( hrgn
, 0, 0, 100, 100 );
6646 check_update_rgn( hparent
, hrgn
);
6647 SetRectRgn( hrgn
, 10, 10, 40, 40 );
6648 check_update_rgn( hchild
, hrgn
);
6649 MoveWindow( hparent
, -20, -20, 200, 200, FALSE
);
6650 SetRectRgn( hrgn
, 20, 20, 100, 100 );
6651 check_update_rgn( hparent
, hrgn
);
6652 SetRectRgn( hrgn
, 30, 30, 40, 40 );
6653 check_update_rgn( hchild
, hrgn
);
6655 /* invalidated region is cropped by the parent rects */
6656 SetRect( &rect
, 0, 0, 50, 50 );
6657 RedrawWindow( hchild
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
);
6658 SetRectRgn( hrgn
, 30, 30, 50, 50 );
6659 check_update_rgn( hchild
, hrgn
);
6661 DestroyWindow( hparent
);
6662 ok(!IsWindow(hchild
), "child must be destroyed with its parent\n");
6665 DeleteObject( hrgn
);
6666 DeleteObject( hrgn2
);
6677 static DWORD WINAPI
thread_proc(void *param
)
6680 struct wnd_event
*wnd_event
= param
;
6682 wnd_event
->hwnd
= CreateWindowExA(0, "TestWindowClass", "window caption text", WS_OVERLAPPEDWINDOW
,
6683 100, 100, 200, 200, 0, 0, 0, NULL
);
6684 ok(wnd_event
->hwnd
!= 0, "Failed to create overlapped window\n");
6686 SetEvent(wnd_event
->start_event
);
6688 while (GetMessageA(&msg
, 0, 0, 0))
6690 TranslateMessage(&msg
);
6691 DispatchMessageA(&msg
);
6694 ok(IsWindow(wnd_event
->hwnd
), "window should still exist\n");
6699 static DWORD CALLBACK
create_grand_child_thread( void *param
)
6701 struct wnd_event
*wnd_event
= param
;
6705 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child",
6706 WS_CHILD
| WS_VISIBLE
, 0, 0, 10, 10, wnd_event
->hwnd
, 0, 0, NULL
);
6707 ok (hchild
!= 0, "Failed to create child window\n");
6710 SetEvent( wnd_event
->start_event
);
6714 MsgWaitForMultipleObjects(0, NULL
, FALSE
, 1000, QS_ALLINPUT
);
6715 if (!IsWindow( hchild
)) break; /* will be destroyed when parent thread exits */
6716 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
6721 static DWORD CALLBACK
create_child_thread( void *param
)
6723 struct wnd_event
*wnd_event
= param
;
6724 struct wnd_event child_event
;
6728 child_event
.hwnd
= CreateWindowExA(0, "TestWindowClass", "Test child",
6729 WS_CHILD
| WS_VISIBLE
, 0, 0, 10, 10, wnd_event
->hwnd
, 0, 0, NULL
);
6730 ok (child_event
.hwnd
!= 0, "Failed to create child window\n");
6731 SetFocus( child_event
.hwnd
);
6734 child_event
.start_event
= wnd_event
->start_event
;
6735 wnd_event
->grand_child
= CreateThread(NULL
, 0, create_grand_child_thread
, &child_event
, 0, &tid
);
6738 DWORD ret
= MsgWaitForMultipleObjects(1, &child_event
.start_event
, FALSE
, 1000, QS_SENDMESSAGE
);
6739 if (ret
!= 1) break;
6740 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
6742 ret
= WaitForSingleObject( wnd_event
->stop_event
, 5000 );
6743 ok( !ret
, "WaitForSingleObject failed %x\n", ret
);
6747 static const char manifest_dep
[] =
6748 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
6749 "<assemblyIdentity version=\"1.2.3.4\" name=\"testdep1\" type=\"win32\" processorArchitecture=\"" ARCH
"\"/>"
6750 " <file name=\"testdep.dll\" />"
6753 static const char manifest_main
[] =
6754 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
6755 "<assemblyIdentity version=\"1.2.3.4\" name=\"Wine.Test\" type=\"win32\" />"
6757 " <dependentAssembly>"
6758 " <assemblyIdentity type=\"win32\" name=\"testdep1\" version=\"1.2.3.4\" processorArchitecture=\"" ARCH
"\" />"
6759 " </dependentAssembly>"
6763 static void create_manifest_file(const char *filename
, const char *manifest
)
6765 WCHAR path
[MAX_PATH
];
6769 MultiByteToWideChar( CP_ACP
, 0, filename
, -1, path
, MAX_PATH
);
6770 file
= CreateFileW(path
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
, FILE_ATTRIBUTE_NORMAL
, NULL
);
6771 ok(file
!= INVALID_HANDLE_VALUE
, "CreateFile failed: %u\n", GetLastError());
6772 WriteFile(file
, manifest
, strlen(manifest
), &size
, NULL
);
6776 static HANDLE
test_create(const char *file
)
6778 WCHAR path
[MAX_PATH
];
6782 MultiByteToWideChar(CP_ACP
, 0, file
, -1, path
, MAX_PATH
);
6783 memset(&actctx
, 0, sizeof(ACTCTXW
));
6784 actctx
.cbSize
= sizeof(ACTCTXW
);
6785 actctx
.lpSource
= path
;
6787 handle
= pCreateActCtxW(&actctx
);
6788 ok(handle
!= INVALID_HANDLE_VALUE
, "failed to create context, error %u\n", GetLastError());
6790 ok(actctx
.cbSize
== sizeof(actctx
), "cbSize=%d\n", actctx
.cbSize
);
6791 ok(actctx
.dwFlags
== 0, "dwFlags=%d\n", actctx
.dwFlags
);
6792 ok(actctx
.lpSource
== path
, "lpSource=%p\n", actctx
.lpSource
);
6793 ok(actctx
.wProcessorArchitecture
== 0, "wProcessorArchitecture=%d\n", actctx
.wProcessorArchitecture
);
6794 ok(actctx
.wLangId
== 0, "wLangId=%d\n", actctx
.wLangId
);
6795 ok(actctx
.lpAssemblyDirectory
== NULL
, "lpAssemblyDirectory=%p\n", actctx
.lpAssemblyDirectory
);
6796 ok(actctx
.lpResourceName
== NULL
, "lpResourceName=%p\n", actctx
.lpResourceName
);
6797 ok(actctx
.lpApplicationName
== NULL
, "lpApplicationName=%p\n", actctx
.lpApplicationName
);
6798 ok(actctx
.hModule
== NULL
, "hModule=%p\n", actctx
.hModule
);
6803 static void test_interthread_messages(void)
6805 HANDLE hThread
, context
, handle
, event
;
6811 int len
, expected_len
;
6812 struct wnd_event wnd_event
;
6815 wnd_event
.start_event
= CreateEventW(NULL
, 0, 0, NULL
);
6816 if (!wnd_event
.start_event
)
6818 win_skip("skipping interthread message test under win9x\n");
6822 hThread
= CreateThread(NULL
, 0, thread_proc
, &wnd_event
, 0, &tid
);
6823 ok(hThread
!= NULL
, "CreateThread failed, error %d\n", GetLastError());
6825 ok(WaitForSingleObject(wnd_event
.start_event
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
6827 CloseHandle(wnd_event
.start_event
);
6829 SetLastError(0xdeadbeef);
6830 ok(!DestroyWindow(wnd_event
.hwnd
), "DestroyWindow succeeded\n");
6831 ok(GetLastError() == ERROR_ACCESS_DENIED
|| GetLastError() == 0xdeadbeef,
6832 "wrong error code %d\n", GetLastError());
6834 proc
= (WNDPROC
)GetWindowLongPtrA(wnd_event
.hwnd
, GWLP_WNDPROC
);
6835 ok(proc
!= NULL
, "GetWindowLongPtrA(GWLP_WNDPROC) error %d\n", GetLastError());
6837 expected_len
= lstrlenA("window caption text");
6838 memset(buf
, 0, sizeof(buf
));
6839 SetLastError(0xdeadbeef);
6840 len
= CallWindowProcA(proc
, wnd_event
.hwnd
, WM_GETTEXT
, sizeof(buf
), (LPARAM
)buf
);
6841 ok(len
== expected_len
, "CallWindowProcA(WM_GETTEXT) error %d, len %d, expected len %d\n", GetLastError(), len
, expected_len
);
6842 ok(!lstrcmpA(buf
, "window caption text"), "window text mismatch\n");
6844 msg
.hwnd
= wnd_event
.hwnd
;
6845 msg
.message
= WM_GETTEXT
;
6846 msg
.wParam
= sizeof(buf
);
6847 msg
.lParam
= (LPARAM
)buf
;
6848 memset(buf
, 0, sizeof(buf
));
6849 SetLastError(0xdeadbeef);
6850 len
= DispatchMessageA(&msg
);
6851 ok((!len
&& GetLastError() == ERROR_MESSAGE_SYNC_ONLY
) || broken(len
), /* nt4 */
6852 "DispatchMessageA(WM_GETTEXT) succeeded on another thread window: ret %d, error %d\n", len
, GetLastError());
6854 /* the following test causes an exception in user.exe under win9x */
6855 msg
.hwnd
= wnd_event
.hwnd
;
6856 msg
.message
= WM_TIMER
;
6858 msg
.lParam
= GetWindowLongPtrA(wnd_event
.hwnd
, GWLP_WNDPROC
);
6859 SetLastError(0xdeadbeef);
6860 len
= DispatchMessageA(&msg
);
6861 ok(!len
&& GetLastError() == 0xdeadbeef,
6862 "DispatchMessageA(WM_TIMER) failed on another thread window: ret %d, error %d\n", len
, GetLastError());
6864 ret
= PostMessageA(wnd_event
.hwnd
, WM_QUIT
, 0, 0);
6865 ok( ret
, "PostMessageA(WM_QUIT) error %d\n", GetLastError());
6867 ok(WaitForSingleObject(hThread
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
6868 CloseHandle(hThread
);
6870 ok(!IsWindow(wnd_event
.hwnd
), "window should be destroyed on thread exit\n");
6872 wnd_event
.hwnd
= CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
6873 100, 100, 200, 200, 0, 0, 0, NULL
);
6874 ok (wnd_event
.hwnd
!= 0, "Failed to create parent window\n");
6877 log_all_parent_messages
++;
6878 wnd_event
.start_event
= CreateEventA( NULL
, TRUE
, FALSE
, NULL
);
6879 wnd_event
.stop_event
= CreateEventA( NULL
, TRUE
, FALSE
, NULL
);
6880 hThread
= CreateThread( NULL
, 0, create_child_thread
, &wnd_event
, 0, &tid
);
6883 ret
= MsgWaitForMultipleObjects(1, &wnd_event
.start_event
, FALSE
, 1000, QS_SENDMESSAGE
);
6884 if (ret
!= 1) break;
6885 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
6887 ok( !ret
, "MsgWaitForMultipleObjects failed %x\n", ret
);
6888 /* now wait for the thread without processing messages; this shouldn't deadlock */
6889 SetEvent( wnd_event
.stop_event
);
6890 ret
= WaitForSingleObject( hThread
, 5000 );
6891 ok( !ret
, "WaitForSingleObject failed %x\n", ret
);
6892 CloseHandle( hThread
);
6894 ret
= WaitForSingleObject( wnd_event
.grand_child
, 5000 );
6895 ok( !ret
, "WaitForSingleObject failed %x\n", ret
);
6896 CloseHandle( wnd_event
.grand_child
);
6898 CloseHandle( wnd_event
.start_event
);
6899 CloseHandle( wnd_event
.stop_event
);
6901 ok_sequence(WmExitThreadSeq
, "destroy child on thread exit", FALSE
);
6902 log_all_parent_messages
--;
6903 DestroyWindow( wnd_event
.hwnd
);
6905 /* activation context tests */
6906 if (!pActivateActCtx
)
6908 win_skip("Activation contexts are not supported, skipping\n");
6912 create_manifest_file("testdep1.manifest", manifest_dep
);
6913 create_manifest_file("main.manifest", manifest_main
);
6915 context
= test_create("main.manifest");
6916 DeleteFileA("testdep1.manifest");
6917 DeleteFileA("main.manifest");
6919 handle
= (void*)0xdeadbeef;
6920 ret
= pGetCurrentActCtx(&handle
);
6921 ok(ret
, "GetCurentActCtx failed: %u\n", GetLastError());
6922 ok(handle
== 0, "active context %p\n", handle
);
6924 wnd_event
.start_event
= CreateEventW(NULL
, 0, 0, NULL
);
6925 hThread
= CreateThread(NULL
, 0, thread_proc
, &wnd_event
, 0, &tid
);
6926 ok(hThread
!= NULL
, "CreateThread failed, error %d\n", GetLastError());
6927 ok(WaitForSingleObject(wnd_event
.start_event
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
6928 CloseHandle(wnd_event
.start_event
);
6930 /* context is activated after thread creation, so it doesn't inherit it by default */
6931 ret
= pActivateActCtx(context
, &cookie
);
6932 ok(ret
, "activation failed: %u\n", GetLastError());
6935 ret
= pGetCurrentActCtx(&handle
);
6936 ok(ret
, "GetCurentActCtx failed: %u\n", GetLastError());
6937 ok(handle
!= 0, "active context %p\n", handle
);
6939 /* destination window will test for active context */
6940 ret
= SendMessageA(wnd_event
.hwnd
, WM_USER
+10, 0, 0);
6941 ok(ret
, "thread window returned %d\n", ret
);
6943 event
= CreateEventW(NULL
, 0, 0, NULL
);
6944 ret
= PostMessageA(wnd_event
.hwnd
, WM_USER
+10, 0, (LPARAM
)event
);
6945 ok(ret
, "thread window returned %d\n", ret
);
6946 ok(WaitForSingleObject(event
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
6949 ret
= PostMessageA(wnd_event
.hwnd
, WM_QUIT
, 0, 0);
6950 ok(ret
, "PostMessageA(WM_QUIT) error %d\n", GetLastError());
6952 ok(WaitForSingleObject(hThread
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
6953 CloseHandle(hThread
);
6955 ret
= pDeactivateActCtx(0, cookie
);
6956 ok(ret
, "DeactivateActCtx failed: %u\n", GetLastError());
6957 pReleaseActCtx(context
);
6961 static const struct message WmVkN
[] = {
6962 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 1 }, /* XP */
6963 { WM_KEYDOWN
, wparam
|lparam
, 'N', 1 },
6964 { WM_KEYDOWN
, sent
|wparam
|lparam
, 'N', 1 },
6965 { WM_CHAR
, wparam
|lparam
, 'n', 1 },
6966 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1002,1), 0 },
6967 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xc0000001 }, /* XP */
6968 { WM_KEYUP
, wparam
|lparam
, 'N', 0xc0000001 },
6969 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xc0000001 },
6972 static const struct message WmShiftVkN
[] = {
6973 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 1 }, /* XP */
6974 { WM_KEYDOWN
, wparam
|lparam
, VK_SHIFT
, 1 },
6975 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_SHIFT
, 1 },
6976 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 1 }, /* XP */
6977 { WM_KEYDOWN
, wparam
|lparam
, 'N', 1 },
6978 { WM_KEYDOWN
, sent
|wparam
|lparam
, 'N', 1 },
6979 { WM_CHAR
, wparam
|lparam
, 'N', 1 },
6980 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1001,1), 0 },
6981 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xc0000001 }, /* XP */
6982 { WM_KEYUP
, wparam
|lparam
, 'N', 0xc0000001 },
6983 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xc0000001 },
6984 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 0xc0000001 }, /* XP */
6985 { WM_KEYUP
, wparam
|lparam
, VK_SHIFT
, 0xc0000001 },
6986 { WM_KEYUP
, sent
|wparam
|lparam
, VK_SHIFT
, 0xc0000001 },
6989 static const struct message WmCtrlVkN
[] = {
6990 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 1 }, /* XP */
6991 { WM_KEYDOWN
, wparam
|lparam
, VK_CONTROL
, 1 },
6992 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_CONTROL
, 1 },
6993 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 1 }, /* XP */
6994 { WM_KEYDOWN
, wparam
|lparam
, 'N', 1 },
6995 { WM_KEYDOWN
, sent
|wparam
|lparam
, 'N', 1 },
6996 { WM_CHAR
, wparam
|lparam
, 0x000e, 1 },
6997 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1000,1), 0 },
6998 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xc0000001 }, /* XP */
6999 { WM_KEYUP
, wparam
|lparam
, 'N', 0xc0000001 },
7000 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xc0000001 },
7001 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 0xc0000001 }, /* XP */
7002 { WM_KEYUP
, wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
7003 { WM_KEYUP
, sent
|wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
7006 static const struct message WmCtrlVkN_2
[] = {
7007 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 1 }, /* XP */
7008 { WM_KEYDOWN
, wparam
|lparam
, VK_CONTROL
, 1 },
7009 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_CONTROL
, 1 },
7010 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 1 }, /* XP */
7011 { WM_KEYDOWN
, wparam
|lparam
, 'N', 1 },
7012 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1000,1), 0 },
7013 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xc0000001 }, /* XP */
7014 { WM_KEYUP
, wparam
|lparam
, 'N', 0xc0000001 },
7015 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xc0000001 },
7016 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 0xc0000001 }, /* XP */
7017 { WM_KEYUP
, wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
7018 { WM_KEYUP
, sent
|wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
7021 static const struct message WmAltVkN
[] = {
7022 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 }, /* XP */
7023 { WM_SYSKEYDOWN
, wparam
|lparam
, VK_MENU
, 0x20000001 },
7024 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
7025 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0x20000001 }, /* XP */
7026 { WM_SYSKEYDOWN
, wparam
|lparam
, 'N', 0x20000001 },
7027 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, 'N', 0x20000001 },
7028 { WM_SYSCHAR
, wparam
|lparam
, 'n', 0x20000001 },
7029 { WM_SYSCHAR
, sent
|wparam
|lparam
, 'n', 0x20000001 },
7030 { WM_SYSCOMMAND
, sent
|defwinproc
|wparam
|lparam
, SC_KEYMENU
, 'n' },
7031 { HCBT_SYSCOMMAND
, hook
},
7032 { WM_ENTERMENULOOP
, sent
|defwinproc
|wparam
|lparam
, 0, 0 },
7033 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
7034 { 0x00AE, sent
|defwinproc
|optional
}, /* XP */
7035 { WM_GETTEXT
, sent
|defwinproc
|optional
}, /* XP */
7036 { WM_INITMENU
, sent
|defwinproc
},
7037 { EVENT_SYSTEM_MENUSTART
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 0 },
7038 { WM_MENUCHAR
, sent
|defwinproc
|wparam
, MAKEWPARAM('n',MF_SYSMENU
) },
7039 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, 0, 0 },
7040 { WM_CAPTURECHANGED
, sent
|defwinproc
},
7041 { WM_MENUSELECT
, sent
|defwinproc
|wparam
, MAKEWPARAM(0,0xffff) },
7042 { EVENT_SYSTEM_MENUEND
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 0 },
7043 { WM_EXITMENULOOP
, sent
|defwinproc
},
7044 { WM_MENUSELECT
, sent
|defwinproc
|wparam
|optional
, MAKEWPARAM(0,0xffff) }, /* Win95 bug */
7045 { WM_EXITMENULOOP
, sent
|defwinproc
|optional
}, /* Win95 bug */
7046 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xe0000001 }, /* XP */
7047 { WM_SYSKEYUP
, wparam
|lparam
, 'N', 0xe0000001 },
7048 { WM_SYSKEYUP
, sent
|wparam
|lparam
, 'N', 0xe0000001 },
7049 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xc0000001 }, /* XP */
7050 { WM_KEYUP
, wparam
|lparam
, VK_MENU
, 0xc0000001 },
7051 { WM_KEYUP
, sent
|wparam
|lparam
, VK_MENU
, 0xc0000001 },
7054 static const struct message WmAltVkN_2
[] = {
7055 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 }, /* XP */
7056 { WM_SYSKEYDOWN
, wparam
|lparam
, VK_MENU
, 0x20000001 },
7057 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
7058 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0x20000001 }, /* XP */
7059 { WM_SYSKEYDOWN
, wparam
|lparam
, 'N', 0x20000001 },
7060 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1003,1), 0 },
7061 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xe0000001 }, /* XP */
7062 { WM_SYSKEYUP
, wparam
|lparam
, 'N', 0xe0000001 },
7063 { WM_SYSKEYUP
, sent
|wparam
|lparam
, 'N', 0xe0000001 },
7064 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xc0000001 }, /* XP */
7065 { WM_KEYUP
, wparam
|lparam
, VK_MENU
, 0xc0000001 },
7066 { WM_KEYUP
, sent
|wparam
|lparam
, VK_MENU
, 0xc0000001 },
7069 static const struct message WmCtrlAltVkN
[] = {
7070 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 1 }, /* XP */
7071 { WM_KEYDOWN
, wparam
|lparam
, VK_CONTROL
, 1 },
7072 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_CONTROL
, 1 },
7073 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 }, /* XP */
7074 { WM_KEYDOWN
, wparam
|lparam
, VK_MENU
, 0x20000001 },
7075 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
7076 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0x20000001 }, /* XP */
7077 { WM_KEYDOWN
, wparam
|lparam
, 'N', 0x20000001 },
7078 { WM_KEYDOWN
, sent
|wparam
|lparam
, 'N', 0x20000001 },
7079 { WM_CHAR
, optional
},
7080 { WM_CHAR
, sent
|optional
},
7081 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xe0000001 }, /* XP */
7082 { WM_KEYUP
, wparam
|lparam
, 'N', 0xe0000001 },
7083 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xe0000001 },
7084 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xc0000001 }, /* XP */
7085 { WM_KEYUP
, wparam
|lparam
, VK_MENU
, 0xc0000001 },
7086 { WM_KEYUP
, sent
|wparam
|lparam
, VK_MENU
, 0xc0000001 },
7087 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 0xc0000001 }, /* XP */
7088 { WM_KEYUP
, wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
7089 { WM_KEYUP
, sent
|wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
7092 static const struct message WmCtrlShiftVkN
[] = {
7093 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 1 }, /* XP */
7094 { WM_KEYDOWN
, wparam
|lparam
, VK_CONTROL
, 1 },
7095 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_CONTROL
, 1 },
7096 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 1 }, /* XP */
7097 { WM_KEYDOWN
, wparam
|lparam
, VK_SHIFT
, 1 },
7098 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_SHIFT
, 1 },
7099 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 1 }, /* XP */
7100 { WM_KEYDOWN
, wparam
|lparam
, 'N', 1 },
7101 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1004,1), 0 },
7102 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xc0000001 }, /* XP */
7103 { WM_KEYUP
, wparam
|lparam
, 'N', 0xc0000001 },
7104 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xc0000001 },
7105 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 0xc0000001 }, /* XP */
7106 { WM_KEYUP
, wparam
|lparam
, VK_SHIFT
, 0xc0000001 },
7107 { WM_KEYUP
, sent
|wparam
|lparam
, VK_SHIFT
, 0xc0000001 },
7108 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 0xc0000001 }, /* XP */
7109 { WM_KEYUP
, wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
7110 { WM_KEYUP
, sent
|wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
7113 static const struct message WmCtrlAltShiftVkN
[] = {
7114 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 1 }, /* XP */
7115 { WM_KEYDOWN
, wparam
|lparam
, VK_CONTROL
, 1 },
7116 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_CONTROL
, 1 },
7117 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 }, /* XP */
7118 { WM_KEYDOWN
, wparam
|lparam
, VK_MENU
, 0x20000001 },
7119 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
7120 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 0x20000001 }, /* XP */
7121 { WM_KEYDOWN
, wparam
|lparam
, VK_SHIFT
, 0x20000001 },
7122 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_SHIFT
, 0x20000001 },
7123 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0x20000001 }, /* XP */
7124 { WM_KEYDOWN
, wparam
|lparam
, 'N', 0x20000001 },
7125 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1005,1), 0 },
7126 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xe0000001 }, /* XP */
7127 { WM_KEYUP
, wparam
|lparam
, 'N', 0xe0000001 },
7128 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xe0000001 },
7129 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 0xe0000001 }, /* XP */
7130 { WM_KEYUP
, wparam
|lparam
, VK_SHIFT
, 0xe0000001 },
7131 { WM_KEYUP
, sent
|wparam
|lparam
, VK_SHIFT
, 0xe0000001 },
7132 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xc0000001 }, /* XP */
7133 { WM_KEYUP
, wparam
|lparam
, VK_MENU
, 0xc0000001 },
7134 { WM_KEYUP
, sent
|wparam
|lparam
, VK_MENU
, 0xc0000001 },
7135 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 0xc0000001 }, /* XP */
7136 { WM_KEYUP
, wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
7137 { WM_KEYUP
, sent
|wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
7140 static const struct message WmAltPressRelease
[] = {
7141 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 }, /* XP */
7142 { WM_SYSKEYDOWN
, wparam
|lparam
, VK_MENU
, 0x20000001 },
7143 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
7144 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xc0000001 }, /* XP */
7145 { WM_SYSKEYUP
, wparam
|lparam
, VK_MENU
, 0xc0000001 },
7146 { WM_SYSKEYUP
, sent
|wparam
|lparam
, VK_MENU
, 0xc0000001 },
7147 { WM_SYSCOMMAND
, sent
|defwinproc
|wparam
|lparam
, SC_KEYMENU
, 0 },
7148 { HCBT_SYSCOMMAND
, hook
},
7149 { WM_ENTERMENULOOP
, sent
|defwinproc
|wparam
|lparam
, 0, 0 },
7150 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
7151 { WM_INITMENU
, sent
|defwinproc
},
7152 { EVENT_SYSTEM_MENUSTART
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 0 },
7153 { WM_MENUSELECT
, sent
|defwinproc
|wparam
, MAKEWPARAM(0,MF_SYSMENU
|MF_POPUP
|MF_HILITE
) },
7154 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 1 },
7156 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x30000001 }, /* XP */
7158 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 0 },
7159 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, 0, 0, },
7160 { WM_CAPTURECHANGED
, sent
|defwinproc
},
7161 { WM_MENUSELECT
, sent
|defwinproc
|wparam
|optional
, MAKEWPARAM(0,0xffff) },
7162 { EVENT_SYSTEM_MENUEND
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 0 },
7163 { WM_EXITMENULOOP
, sent
|defwinproc
},
7164 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xc0000001 }, /* XP */
7165 { WM_SYSKEYUP
, wparam
|lparam
, VK_MENU
, 0xc0000001 },
7166 { WM_SYSKEYUP
, sent
|wparam
|lparam
, VK_MENU
, 0xc0000001 },
7169 static const struct message WmShiftMouseButton
[] = {
7170 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 1 }, /* XP */
7171 { WM_KEYDOWN
, wparam
|lparam
, VK_SHIFT
, 1 },
7172 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_SHIFT
, 1 },
7173 { WM_MOUSEMOVE
, wparam
|optional
, 0, 0 },
7174 { WM_MOUSEMOVE
, sent
|wparam
|optional
, 0, 0 },
7175 { WM_LBUTTONDOWN
, wparam
, MK_LBUTTON
|MK_SHIFT
, 0 },
7176 { WM_LBUTTONDOWN
, sent
|wparam
, MK_LBUTTON
|MK_SHIFT
, 0 },
7177 { WM_LBUTTONUP
, wparam
, MK_SHIFT
, 0 },
7178 { WM_LBUTTONUP
, sent
|wparam
, MK_SHIFT
, 0 },
7179 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 0xc0000001 }, /* XP */
7180 { WM_KEYUP
, wparam
|lparam
, VK_SHIFT
, 0xc0000001 },
7181 { WM_KEYUP
, sent
|wparam
|lparam
, VK_SHIFT
, 0xc0000001 },
7184 static const struct message WmF1Seq
[] = {
7185 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_F1
, 1 }, /* XP */
7186 { WM_KEYDOWN
, wparam
|lparam
, VK_F1
, 1 },
7187 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_F1
, 0x00000001 },
7188 { WM_KEYF1
, wparam
|lparam
, 0, 0 },
7189 { WM_KEYF1
, sent
|wparam
|lparam
, 0, 0 },
7190 { WM_HELP
, sent
|defwinproc
},
7191 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_F1
, 0xc0000001 }, /* XP */
7192 { WM_KEYUP
, wparam
|lparam
, VK_F1
, 0xc0000001 },
7193 { WM_KEYUP
, sent
|wparam
|lparam
, VK_F1
, 0xc0000001 },
7196 static const struct message WmVkAppsSeq
[] = {
7197 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_APPS
, 1 }, /* XP */
7198 { WM_KEYDOWN
, wparam
|lparam
, VK_APPS
, 1 },
7199 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_APPS
, 0x00000001 },
7200 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_APPS
, 0xc0000001 }, /* XP */
7201 { WM_KEYUP
, wparam
|lparam
, VK_APPS
, 0xc0000001 },
7202 { WM_KEYUP
, sent
|wparam
|lparam
, VK_APPS
, 0xc0000001 },
7203 { WM_CONTEXTMENU
, lparam
, /*hwnd*/0, -1 },
7204 { WM_CONTEXTMENU
, sent
|lparam
, /*hwnd*/0, -1 },
7207 static const struct message WmVkF10Seq
[] = {
7208 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_F10
, 1 }, /* XP */
7209 { WM_SYSKEYDOWN
, wparam
|lparam
, VK_F10
, 1 },
7210 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, VK_F10
, 0x00000001 },
7211 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_F10
, 0xc0000001 }, /* XP */
7212 { WM_SYSKEYUP
, wparam
|lparam
, VK_F10
, 0xc0000001 },
7213 { WM_SYSKEYUP
, sent
|wparam
|lparam
, VK_F10
, 0xc0000001 },
7214 { WM_SYSCOMMAND
, sent
|defwinproc
|wparam
, SC_KEYMENU
},
7215 { HCBT_SYSCOMMAND
, hook
},
7216 { WM_ENTERMENULOOP
, sent
|defwinproc
|wparam
|lparam
, 0, 0 },
7217 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
7218 { WM_INITMENU
, sent
|defwinproc
},
7219 { EVENT_SYSTEM_MENUSTART
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 0 },
7220 { WM_MENUSELECT
, sent
|defwinproc
|wparam
, MAKEWPARAM(0,MF_SYSMENU
|MF_POPUP
|MF_HILITE
) },
7221 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 1 },
7223 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_F10
, 0x10000001 }, /* XP */
7225 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_F10
, 1 }, /* XP */
7226 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 0 },
7227 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, 0, 0, },
7228 { WM_CAPTURECHANGED
, sent
|defwinproc
},
7229 { WM_MENUSELECT
, sent
|defwinproc
|wparam
|optional
, MAKEWPARAM(0,0xffff) },
7230 { EVENT_SYSTEM_MENUEND
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 0 },
7231 { WM_EXITMENULOOP
, sent
|defwinproc
},
7232 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_F10
, 0xc0000001 }, /* XP */
7233 { WM_SYSKEYUP
, wparam
|lparam
, VK_F10
, 0xc0000001 },
7234 { WM_SYSKEYUP
, sent
|wparam
|lparam
, VK_F10
, 0xc0000001 },
7237 static const struct message WmShiftF10Seq
[] = {
7238 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 1 }, /* XP */
7239 { WM_KEYDOWN
, wparam
|lparam
, VK_SHIFT
, 1 },
7240 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_SHIFT
, 0x00000001 },
7241 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_F10
, 1 }, /* XP */
7242 { WM_SYSKEYDOWN
, wparam
|lparam
, VK_F10
, 1 },
7243 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, VK_F10
, 0x00000001 },
7244 { WM_CONTEXTMENU
, sent
|defwinproc
|lparam
, /*hwnd*/0, -1 },
7245 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_F10
, 0xc0000001 }, /* XP */
7246 { WM_SYSKEYUP
, wparam
|lparam
, VK_F10
, 0xc0000001 },
7247 { WM_SYSKEYUP
, sent
|wparam
|lparam
, VK_F10
, 0xc0000001 },
7248 { WM_SYSCOMMAND
, sent
|defwinproc
|wparam
, SC_KEYMENU
},
7249 { HCBT_SYSCOMMAND
, hook
},
7250 { WM_ENTERMENULOOP
, sent
|defwinproc
|wparam
|lparam
, 0, 0 },
7251 { WM_INITMENU
, sent
|defwinproc
},
7252 { WM_MENUSELECT
, sent
|defwinproc
|wparam
, MAKEWPARAM(0,MF_SYSMENU
|MF_POPUP
|MF_HILITE
) },
7253 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 0xd0000001 }, /* XP */
7254 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_ESCAPE
, 0x10000001 }, /* XP */
7255 { WM_CAPTURECHANGED
, sent
|defwinproc
|wparam
|lparam
, 0, 0 },
7256 { WM_MENUSELECT
, sent
|defwinproc
|wparam
|lparam
, 0xffff0000, 0 },
7257 { WM_EXITMENULOOP
, sent
|defwinproc
|wparam
|lparam
, 0, 0 },
7258 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_ESCAPE
, 0xc0000001 }, /* XP */
7259 { WM_KEYUP
, wparam
|lparam
, VK_ESCAPE
, 0xc0000001 },
7260 { WM_KEYUP
, sent
|wparam
|lparam
, VK_ESCAPE
, 0xc0000001 },
7264 static void pump_msg_loop(HWND hwnd
, HACCEL hAccel
)
7268 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
))
7270 struct recvd_message log_msg
;
7272 /* ignore some unwanted messages */
7273 if (msg
.message
== WM_MOUSEMOVE
||
7274 msg
.message
== WM_TIMER
||
7275 ignore_message( msg
.message
))
7278 log_msg
.hwnd
= msg
.hwnd
;
7279 log_msg
.message
= msg
.message
;
7280 log_msg
.flags
= wparam
|lparam
;
7281 log_msg
.wParam
= msg
.wParam
;
7282 log_msg
.lParam
= msg
.lParam
;
7283 log_msg
.descr
= "accel";
7284 add_message(&log_msg
);
7286 if (!hAccel
|| !TranslateAcceleratorA(hwnd
, hAccel
, &msg
))
7288 TranslateMessage(&msg
);
7289 DispatchMessageA(&msg
);
7294 static void test_accelerators(void)
7300 HWND hwnd
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
7301 100, 100, 200, 200, 0, 0, 0, NULL
);
7310 ok(GetFocus() == hwnd
, "wrong focus window %p\n", GetFocus());
7312 state
= GetKeyState(VK_SHIFT
);
7313 ok(!(state
& 0x8000), "wrong Shift state %04x\n", state
);
7314 state
= GetKeyState(VK_CAPITAL
);
7315 ok(state
== 0, "wrong CapsLock state %04x\n", state
);
7317 hAccel
= LoadAcceleratorsA(GetModuleHandleA(NULL
), MAKEINTRESOURCEA(1));
7318 assert(hAccel
!= 0);
7321 pump_msg_loop(hwnd
, 0);
7324 trace("testing VK_N press/release\n");
7326 keybd_event('N', 0, 0, 0);
7327 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
7328 pump_msg_loop(hwnd
, hAccel
);
7329 if (!sequence_cnt
) /* we didn't get any message */
7331 skip( "queuing key events not supported\n" );
7334 ok_sequence(WmVkN
, "VK_N press/release", FALSE
);
7336 trace("testing Shift+VK_N press/release\n");
7338 keybd_event(VK_SHIFT
, 0, 0, 0);
7339 keybd_event('N', 0, 0, 0);
7340 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
7341 keybd_event(VK_SHIFT
, 0, KEYEVENTF_KEYUP
, 0);
7342 pump_msg_loop(hwnd
, hAccel
);
7343 ok_sequence(WmShiftVkN
, "Shift+VK_N press/release", FALSE
);
7345 trace("testing Ctrl+VK_N press/release\n");
7347 keybd_event(VK_CONTROL
, 0, 0, 0);
7348 keybd_event('N', 0, 0, 0);
7349 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
7350 keybd_event(VK_CONTROL
, 0, KEYEVENTF_KEYUP
, 0);
7351 pump_msg_loop(hwnd
, hAccel
);
7352 ok_sequence(WmCtrlVkN
, "Ctrl+VK_N press/release", FALSE
);
7354 trace("testing Alt+VK_N press/release\n");
7356 keybd_event(VK_MENU
, 0, 0, 0);
7357 keybd_event('N', 0, 0, 0);
7358 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
7359 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
7360 pump_msg_loop(hwnd
, hAccel
);
7361 ok_sequence(WmAltVkN
, "Alt+VK_N press/release", FALSE
);
7363 trace("testing Ctrl+Alt+VK_N press/release 1\n");
7365 keybd_event(VK_CONTROL
, 0, 0, 0);
7366 keybd_event(VK_MENU
, 0, 0, 0);
7367 keybd_event('N', 0, 0, 0);
7368 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
7369 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
7370 keybd_event(VK_CONTROL
, 0, KEYEVENTF_KEYUP
, 0);
7371 pump_msg_loop(hwnd
, hAccel
);
7372 ok_sequence(WmCtrlAltVkN
, "Ctrl+Alt+VK_N press/release 1", FALSE
);
7374 ret
= DestroyAcceleratorTable(hAccel
);
7375 ok( ret
, "DestroyAcceleratorTable error %d\n", GetLastError());
7377 hAccel
= LoadAcceleratorsA(GetModuleHandleA(NULL
), MAKEINTRESOURCEA(2));
7378 assert(hAccel
!= 0);
7380 trace("testing VK_N press/release\n");
7382 keybd_event('N', 0, 0, 0);
7383 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
7384 pump_msg_loop(hwnd
, hAccel
);
7385 ok_sequence(WmVkN
, "VK_N press/release", FALSE
);
7387 trace("testing Shift+VK_N press/release\n");
7389 keybd_event(VK_SHIFT
, 0, 0, 0);
7390 keybd_event('N', 0, 0, 0);
7391 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
7392 keybd_event(VK_SHIFT
, 0, KEYEVENTF_KEYUP
, 0);
7393 pump_msg_loop(hwnd
, hAccel
);
7394 ok_sequence(WmShiftVkN
, "Shift+VK_N press/release", FALSE
);
7396 trace("testing Ctrl+VK_N press/release 2\n");
7398 keybd_event(VK_CONTROL
, 0, 0, 0);
7399 keybd_event('N', 0, 0, 0);
7400 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
7401 keybd_event(VK_CONTROL
, 0, KEYEVENTF_KEYUP
, 0);
7402 pump_msg_loop(hwnd
, hAccel
);
7403 ok_sequence(WmCtrlVkN_2
, "Ctrl+VK_N press/release 2", FALSE
);
7405 trace("testing Alt+VK_N press/release 2\n");
7407 keybd_event(VK_MENU
, 0, 0, 0);
7408 keybd_event('N', 0, 0, 0);
7409 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
7410 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
7411 pump_msg_loop(hwnd
, hAccel
);
7412 ok_sequence(WmAltVkN_2
, "Alt+VK_N press/release 2", FALSE
);
7414 trace("testing Ctrl+Alt+VK_N press/release 2\n");
7416 keybd_event(VK_CONTROL
, 0, 0, 0);
7417 keybd_event(VK_MENU
, 0, 0, 0);
7418 keybd_event('N', 0, 0, 0);
7419 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
7420 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
7421 keybd_event(VK_CONTROL
, 0, KEYEVENTF_KEYUP
, 0);
7422 pump_msg_loop(hwnd
, hAccel
);
7423 ok_sequence(WmCtrlAltVkN
, "Ctrl+Alt+VK_N press/release 2", FALSE
);
7425 trace("testing Ctrl+Shift+VK_N press/release\n");
7427 keybd_event(VK_CONTROL
, 0, 0, 0);
7428 keybd_event(VK_SHIFT
, 0, 0, 0);
7429 keybd_event('N', 0, 0, 0);
7430 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
7431 keybd_event(VK_SHIFT
, 0, KEYEVENTF_KEYUP
, 0);
7432 keybd_event(VK_CONTROL
, 0, KEYEVENTF_KEYUP
, 0);
7433 pump_msg_loop(hwnd
, hAccel
);
7434 ok_sequence(WmCtrlShiftVkN
, "Ctrl+Shift+VK_N press/release", FALSE
);
7436 trace("testing Ctrl+Alt+Shift+VK_N press/release\n");
7438 keybd_event(VK_CONTROL
, 0, 0, 0);
7439 keybd_event(VK_MENU
, 0, 0, 0);
7440 keybd_event(VK_SHIFT
, 0, 0, 0);
7441 keybd_event('N', 0, 0, 0);
7442 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
7443 keybd_event(VK_SHIFT
, 0, KEYEVENTF_KEYUP
, 0);
7444 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
7445 keybd_event(VK_CONTROL
, 0, KEYEVENTF_KEYUP
, 0);
7446 pump_msg_loop(hwnd
, hAccel
);
7447 ok_sequence(WmCtrlAltShiftVkN
, "Ctrl+Alt+Shift+VK_N press/release", FALSE
);
7449 ret
= DestroyAcceleratorTable(hAccel
);
7450 ok( ret
, "DestroyAcceleratorTable error %d\n", GetLastError());
7453 trace("testing Alt press/release\n");
7455 keybd_event(VK_MENU
, 0, 0, 0);
7456 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
7457 keybd_event(VK_MENU
, 0, 0, 0);
7458 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
7459 pump_msg_loop(hwnd
, 0);
7460 /* this test doesn't pass in Wine for managed windows */
7461 ok_sequence(WmAltPressRelease
, "Alt press/release", TRUE
);
7463 trace("testing VK_F1 press/release\n");
7464 keybd_event(VK_F1
, 0, 0, 0);
7465 keybd_event(VK_F1
, 0, KEYEVENTF_KEYUP
, 0);
7466 pump_msg_loop(hwnd
, 0);
7467 ok_sequence(WmF1Seq
, "F1 press/release", FALSE
);
7469 trace("testing VK_APPS press/release\n");
7470 keybd_event(VK_APPS
, 0, 0, 0);
7471 keybd_event(VK_APPS
, 0, KEYEVENTF_KEYUP
, 0);
7472 pump_msg_loop(hwnd
, 0);
7473 ok_sequence(WmVkAppsSeq
, "VK_APPS press/release", FALSE
);
7475 trace("testing VK_F10 press/release\n");
7476 keybd_event(VK_F10
, 0, 0, 0);
7477 keybd_event(VK_F10
, 0, KEYEVENTF_KEYUP
, 0);
7478 keybd_event(VK_F10
, 0, 0, 0);
7479 keybd_event(VK_F10
, 0, KEYEVENTF_KEYUP
, 0);
7480 pump_msg_loop(hwnd
, 0);
7481 ok_sequence(WmVkF10Seq
, "VK_F10 press/release", TRUE
);
7483 trace("testing SHIFT+F10 press/release\n");
7484 keybd_event(VK_SHIFT
, 0, 0, 0);
7485 keybd_event(VK_F10
, 0, 0, 0);
7486 keybd_event(VK_F10
, 0, KEYEVENTF_KEYUP
, 0);
7487 keybd_event(VK_SHIFT
, 0, KEYEVENTF_KEYUP
, 0);
7488 keybd_event(VK_ESCAPE
, 0, 0, 0);
7489 keybd_event(VK_ESCAPE
, 0, KEYEVENTF_KEYUP
, 0);
7490 pump_msg_loop(hwnd
, 0);
7491 ok_sequence(WmShiftF10Seq
, "SHIFT+F10 press/release", TRUE
);
7493 trace("testing Shift+MouseButton press/release\n");
7494 /* first, move mouse pointer inside of the window client area */
7495 GetClientRect(hwnd
, &rc
);
7496 MapWindowPoints(hwnd
, 0, (LPPOINT
)&rc
, 2);
7497 rc
.left
+= (rc
.right
- rc
.left
)/2;
7498 rc
.top
+= (rc
.bottom
- rc
.top
)/2;
7499 SetCursorPos(rc
.left
, rc
.top
);
7500 SetActiveWindow(hwnd
);
7505 if (pt
.x
== rc
.left
&& pt
.y
== rc
.top
)
7508 keybd_event(VK_SHIFT
, 0, 0, 0);
7509 mouse_event(MOUSEEVENTF_LEFTDOWN
, 0, 0, 0, 0);
7510 mouse_event(MOUSEEVENTF_LEFTUP
, 0, 0, 0, 0);
7511 keybd_event(VK_SHIFT
, 0, KEYEVENTF_KEYUP
, 0);
7512 pump_msg_loop(hwnd
, 0);
7513 for (i
= 0; i
< sequence_cnt
; i
++) if (sequence
[i
].message
== WM_LBUTTONDOWN
) break;
7514 if (i
< sequence_cnt
)
7515 ok_sequence(WmShiftMouseButton
, "Shift+MouseButton press/release", FALSE
);
7517 skip( "Shift+MouseButton event didn't get to the window\n" );
7521 if (hAccel
) DestroyAcceleratorTable(hAccel
);
7522 DestroyWindow(hwnd
);
7525 /************* window procedures ********************/
7527 static LRESULT
MsgCheckProc (BOOL unicode
, HWND hwnd
, UINT message
,
7528 WPARAM wParam
, LPARAM lParam
)
7530 static LONG defwndproc_counter
= 0;
7531 static LONG beginpaint_counter
= 0;
7533 struct recvd_message msg
;
7535 if (ignore_message( message
)) return 0;
7541 LONG style
= GetWindowLongA(hwnd
, GWL_STYLE
);
7542 ok((BOOL
)wParam
== !(style
& WS_DISABLED
),
7543 "wrong WS_DISABLED state: %ld != %d\n", wParam
, !(style
& WS_DISABLED
));
7547 case WM_CAPTURECHANGED
:
7548 if (test_DestroyWindow_flag
)
7550 DWORD style
= GetWindowLongA(hwnd
, GWL_STYLE
);
7551 if (style
& WS_CHILD
)
7552 lParam
= GetWindowLongPtrA(hwnd
, GWLP_ID
);
7553 else if (style
& WS_POPUP
)
7554 lParam
= WND_POPUP_ID
;
7556 lParam
= WND_PARENT_ID
;
7564 ok(!GetWindow(hwnd
, GW_CHILD
), "children should be unlinked at this point\n");
7565 capture
= GetCapture();
7568 ok(capture
== hwnd
, "capture should NOT be released at this point (capture %p)\n", capture
);
7569 trace("current capture %p, releasing...\n", capture
);
7576 ok(pGetAncestor(hwnd
, GA_PARENT
) != 0, "parent should NOT be unlinked at this point\n");
7577 if (test_DestroyWindow_flag
)
7579 DWORD style
= GetWindowLongA(hwnd
, GWL_STYLE
);
7580 if (style
& WS_CHILD
)
7581 lParam
= GetWindowLongPtrA(hwnd
, GWLP_ID
);
7582 else if (style
& WS_POPUP
)
7583 lParam
= WND_POPUP_ID
;
7585 lParam
= WND_PARENT_ID
;
7589 /* test_accelerators() depends on this */
7595 HANDLE handle
, event
= (HANDLE
)lParam
;
7598 handle
= (void*)0xdeadbeef;
7599 ret
= pGetCurrentActCtx(&handle
);
7600 ok(ret
, "failed to get current context, %u\n", GetLastError());
7601 ok(handle
== 0, "got active context %p\n", handle
);
7602 if (event
) SetEvent(event
);
7608 case WM_MOUSEACTIVATE
:
7609 case WM_NCMOUSEMOVE
:
7616 msg
.message
= message
;
7617 msg
.flags
= sent
|wparam
|lparam
;
7618 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
7619 if (beginpaint_counter
) msg
.flags
|= beginpaint
;
7620 msg
.wParam
= wParam
;
7621 msg
.lParam
= lParam
;
7622 msg
.descr
= "MsgCheckProc";
7625 if (message
== WM_GETMINMAXINFO
&& (GetWindowLongA(hwnd
, GWL_STYLE
) & WS_CHILD
))
7627 HWND parent
= GetParent(hwnd
);
7629 MINMAXINFO
*minmax
= (MINMAXINFO
*)lParam
;
7631 GetClientRect(parent
, &rc
);
7632 trace("parent %p client size = (%d x %d)\n", parent
, rc
.right
, rc
.bottom
);
7633 trace("Reserved=%d,%d MaxSize=%d,%d MaxPos=%d,%d MinTrack=%d,%d MaxTrack=%d,%d\n",
7634 minmax
->ptReserved
.x
, minmax
->ptReserved
.y
,
7635 minmax
->ptMaxSize
.x
, minmax
->ptMaxSize
.y
,
7636 minmax
->ptMaxPosition
.x
, minmax
->ptMaxPosition
.y
,
7637 minmax
->ptMinTrackSize
.x
, minmax
->ptMinTrackSize
.y
,
7638 minmax
->ptMaxTrackSize
.x
, minmax
->ptMaxTrackSize
.y
);
7640 ok(minmax
->ptMaxSize
.x
== rc
.right
, "default width of maximized child %d != %d\n",
7641 minmax
->ptMaxSize
.x
, rc
.right
);
7642 ok(minmax
->ptMaxSize
.y
== rc
.bottom
, "default height of maximized child %d != %d\n",
7643 minmax
->ptMaxSize
.y
, rc
.bottom
);
7646 if (message
== WM_PAINT
)
7649 beginpaint_counter
++;
7650 BeginPaint( hwnd
, &ps
);
7651 beginpaint_counter
--;
7652 EndPaint( hwnd
, &ps
);
7656 defwndproc_counter
++;
7657 ret
= unicode
? DefWindowProcW(hwnd
, message
, wParam
, lParam
)
7658 : DefWindowProcA(hwnd
, message
, wParam
, lParam
);
7659 defwndproc_counter
--;
7664 static LRESULT WINAPI
MsgCheckProcA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
7666 return MsgCheckProc (FALSE
, hwnd
, message
, wParam
, lParam
);
7669 static LRESULT WINAPI
MsgCheckProcW(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
7671 return MsgCheckProc (TRUE
, hwnd
, message
, wParam
, lParam
);
7674 static LRESULT WINAPI
PopupMsgCheckProcA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
7676 static LONG defwndproc_counter
= 0;
7678 struct recvd_message msg
;
7680 if (ignore_message( message
)) return 0;
7684 case WM_QUERYENDSESSION
:
7686 lParam
&= ~0x01; /* Vista adds a 0x01 flag */
7691 msg
.message
= message
;
7692 msg
.flags
= sent
|wparam
|lparam
;
7693 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
7694 msg
.wParam
= wParam
;
7695 msg
.lParam
= lParam
;
7696 msg
.descr
= "popup";
7699 if (message
== WM_CREATE
)
7701 DWORD style
= GetWindowLongA(hwnd
, GWL_STYLE
) | WS_VISIBLE
;
7702 SetWindowLongA(hwnd
, GWL_STYLE
, style
);
7705 defwndproc_counter
++;
7706 ret
= DefWindowProcA(hwnd
, message
, wParam
, lParam
);
7707 defwndproc_counter
--;
7712 static LRESULT WINAPI
ParentMsgCheckProcA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
7714 static LONG defwndproc_counter
= 0;
7715 static LONG beginpaint_counter
= 0;
7717 struct recvd_message msg
;
7719 if (ignore_message( message
)) return 0;
7721 if (log_all_parent_messages
||
7722 message
== WM_PARENTNOTIFY
|| message
== WM_CANCELMODE
||
7723 message
== WM_SETFOCUS
|| message
== WM_KILLFOCUS
||
7724 message
== WM_ENABLE
|| message
== WM_ENTERIDLE
||
7725 message
== WM_DRAWITEM
|| message
== WM_COMMAND
||
7726 message
== WM_IME_SETCONTEXT
)
7735 case WM_NCMOUSEMOVE
:
7741 INT ret
= GetClipBox((HDC
)wParam
, &rc
);
7743 trace("WM_ERASEBKGND: GetClipBox()=%d, (%d,%d-%d,%d)\n",
7744 ret
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
7750 msg
.message
= message
;
7751 msg
.flags
= sent
|parent
|wparam
|lparam
;
7752 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
7753 if (beginpaint_counter
) msg
.flags
|= beginpaint
;
7754 msg
.wParam
= wParam
;
7755 msg
.lParam
= lParam
;
7756 msg
.descr
= "parent";
7760 if (message
== WM_PAINT
)
7763 beginpaint_counter
++;
7764 BeginPaint( hwnd
, &ps
);
7765 beginpaint_counter
--;
7766 EndPaint( hwnd
, &ps
);
7770 defwndproc_counter
++;
7771 ret
= DefWindowProcA(hwnd
, message
, wParam
, lParam
);
7772 defwndproc_counter
--;
7777 static INT_PTR CALLBACK
StopQuitMsgCheckProcA(HWND hwnd
, UINT message
, WPARAM wp
, LPARAM lp
)
7779 if (message
== WM_CREATE
)
7780 PostMessageA(hwnd
, WM_CLOSE
, 0, 0);
7781 else if (message
== WM_CLOSE
)
7783 /* Only the first WM_QUIT will survive the window destruction */
7784 PostMessageA(hwnd
, WM_USER
, 0x1234, 0x5678);
7785 PostMessageA(hwnd
, WM_QUIT
, 0x1234, 0x5678);
7786 PostMessageA(hwnd
, WM_QUIT
, 0x4321, 0x8765);
7789 return DefWindowProcA(hwnd
, message
, wp
, lp
);
7792 static LRESULT WINAPI
TestDlgProcA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
7794 static LONG defwndproc_counter
= 0;
7796 struct recvd_message msg
;
7798 if (ignore_message( message
)) return 0;
7802 DefDlgProcA(hwnd
, DM_SETDEFID
, 1, 0);
7803 ret
= DefDlgProcA(hwnd
, DM_GETDEFID
, 0, 0);
7804 if (after_end_dialog
)
7805 ok( ret
== 0, "DM_GETDEFID should return 0 after EndDialog, got %lx\n", ret
);
7807 ok(HIWORD(ret
) == DC_HASDEFID
, "DM_GETDEFID should return DC_HASDEFID, got %lx\n", ret
);
7811 msg
.message
= message
;
7812 msg
.flags
= sent
|wparam
|lparam
;
7813 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
7814 msg
.wParam
= wParam
;
7815 msg
.lParam
= lParam
;
7816 msg
.descr
= "dialog";
7819 defwndproc_counter
++;
7820 ret
= DefDlgProcA(hwnd
, message
, wParam
, lParam
);
7821 defwndproc_counter
--;
7826 static LRESULT WINAPI
ShowWindowProcA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
7828 static LONG defwndproc_counter
= 0;
7830 struct recvd_message msg
;
7832 /* log only specific messages we are interested in */
7835 #if 0 /* probably log these as well */
7843 case WM_GETMINMAXINFO
:
7844 case WM_WINDOWPOSCHANGING
:
7845 case WM_WINDOWPOSCHANGED
:
7848 default: /* ignore */
7849 /*trace("showwindow: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);*/
7850 return DefWindowProcA(hwnd
, message
, wParam
, lParam
);
7854 msg
.message
= message
;
7855 msg
.flags
= sent
|wparam
|lparam
;
7856 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
7857 msg
.wParam
= wParam
;
7858 msg
.lParam
= lParam
;
7862 defwndproc_counter
++;
7863 ret
= DefWindowProcA(hwnd
, message
, wParam
, lParam
);
7864 defwndproc_counter
--;
7869 static LRESULT WINAPI
PaintLoopProcA(HWND hWnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
7873 case WM_CREATE
: return 0;
7882 if (PeekMessageA(&msg2
, 0, 0, 0, 1))
7884 TranslateMessage(&msg2
);
7885 DispatchMessageA(&msg2
);
7889 else ok(broken(1), "infinite loop\n");
7891 paint_loop_done
= TRUE
;
7892 return DefWindowProcA(hWnd
,msg
,wParam
,lParam
);
7895 return DefWindowProcA(hWnd
,msg
,wParam
,lParam
);
7898 static LRESULT WINAPI
HotkeyMsgCheckProcA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
7900 static LONG defwndproc_counter
= 0;
7902 struct recvd_message msg
;
7905 if (ignore_message( message
)) return 0;
7907 if ((message
>= WM_KEYFIRST
&& message
<= WM_KEYLAST
) ||
7908 message
== WM_HOTKEY
|| message
>= WM_APP
)
7911 msg
.message
= message
;
7912 msg
.flags
= sent
|wparam
|lparam
;
7913 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
7914 msg
.wParam
= wParam
;
7915 msg
.lParam
= lParam
;
7916 msg
.descr
= "HotkeyMsgCheckProcA";
7920 defwndproc_counter
++;
7921 ret
= DefWindowProcA(hwnd
, message
, wParam
, lParam
);
7922 defwndproc_counter
--;
7924 if (message
== WM_APP
)
7926 queue_status
= GetQueueStatus(QS_HOTKEY
);
7927 ok((queue_status
& (QS_HOTKEY
<< 16)) == QS_HOTKEY
<< 16, "expected QS_HOTKEY << 16 set, got %x\n", queue_status
);
7928 queue_status
= GetQueueStatus(QS_POSTMESSAGE
);
7929 ok((queue_status
& (QS_POSTMESSAGE
<< 16)) == QS_POSTMESSAGE
<< 16, "expected QS_POSTMESSAGE << 16 set, got %x\n", queue_status
);
7930 PostMessageA(hwnd
, WM_APP
+1, 0, 0);
7932 else if (message
== WM_APP
+1)
7934 queue_status
= GetQueueStatus(QS_HOTKEY
);
7935 ok((queue_status
& (QS_HOTKEY
<< 16)) == 0, "expected QS_HOTKEY << 16 cleared, got %x\n", queue_status
);
7941 static BOOL
RegisterWindowClasses(void)
7947 cls
.lpfnWndProc
= MsgCheckProcA
;
7950 cls
.hInstance
= GetModuleHandleA(0);
7952 cls
.hCursor
= LoadCursorA(0, (LPCSTR
)IDC_ARROW
);
7953 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
7954 cls
.lpszMenuName
= NULL
;
7955 cls
.lpszClassName
= "TestWindowClass";
7956 if(!RegisterClassA(&cls
)) return FALSE
;
7958 cls
.lpfnWndProc
= HotkeyMsgCheckProcA
;
7959 cls
.lpszClassName
= "HotkeyWindowClass";
7960 if(!RegisterClassA(&cls
)) return FALSE
;
7962 cls
.lpfnWndProc
= ShowWindowProcA
;
7963 cls
.lpszClassName
= "ShowWindowClass";
7964 if(!RegisterClassA(&cls
)) return FALSE
;
7966 cls
.lpfnWndProc
= PopupMsgCheckProcA
;
7967 cls
.lpszClassName
= "TestPopupClass";
7968 if(!RegisterClassA(&cls
)) return FALSE
;
7970 cls
.lpfnWndProc
= ParentMsgCheckProcA
;
7971 cls
.lpszClassName
= "TestParentClass";
7972 if(!RegisterClassA(&cls
)) return FALSE
;
7974 cls
.lpfnWndProc
= StopQuitMsgCheckProcA
;
7975 cls
.lpszClassName
= "StopQuitClass";
7976 if(!RegisterClassA(&cls
)) return FALSE
;
7978 cls
.lpfnWndProc
= DefWindowProcA
;
7979 cls
.lpszClassName
= "SimpleWindowClass";
7980 if(!RegisterClassA(&cls
)) return FALSE
;
7982 cls
.lpfnWndProc
= PaintLoopProcA
;
7983 cls
.lpszClassName
= "PaintLoopWindowClass";
7984 if(!RegisterClassA(&cls
)) return FALSE
;
7986 cls
.style
= CS_NOCLOSE
;
7987 cls
.lpszClassName
= "NoCloseWindowClass";
7988 if(!RegisterClassA(&cls
)) return FALSE
;
7990 ok(GetClassInfoA(0, "#32770", &cls
), "GetClassInfo failed\n");
7992 cls
.hInstance
= GetModuleHandleA(0);
7993 cls
.hbrBackground
= 0;
7994 cls
.lpfnWndProc
= TestDlgProcA
;
7995 cls
.lpszClassName
= "TestDialogClass";
7996 if(!RegisterClassA(&cls
)) return FALSE
;
7999 clsW
.lpfnWndProc
= MsgCheckProcW
;
8000 clsW
.cbClsExtra
= 0;
8001 clsW
.cbWndExtra
= 0;
8002 clsW
.hInstance
= GetModuleHandleW(0);
8004 clsW
.hCursor
= LoadCursorW(0, (LPWSTR
)IDC_ARROW
);
8005 clsW
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
8006 clsW
.lpszMenuName
= NULL
;
8007 clsW
.lpszClassName
= testWindowClassW
;
8008 RegisterClassW(&clsW
); /* ignore error, this fails on Win9x */
8013 static BOOL
is_our_logged_class(HWND hwnd
)
8017 if (GetClassNameA(hwnd
, buf
, sizeof(buf
)))
8019 if (!lstrcmpiA(buf
, "TestWindowClass") ||
8020 !lstrcmpiA(buf
, "ShowWindowClass") ||
8021 !lstrcmpiA(buf
, "TestParentClass") ||
8022 !lstrcmpiA(buf
, "TestPopupClass") ||
8023 !lstrcmpiA(buf
, "SimpleWindowClass") ||
8024 !lstrcmpiA(buf
, "TestDialogClass") ||
8025 !lstrcmpiA(buf
, "MDI_frame_class") ||
8026 !lstrcmpiA(buf
, "MDI_client_class") ||
8027 !lstrcmpiA(buf
, "MDI_child_class") ||
8028 !lstrcmpiA(buf
, "my_button_class") ||
8029 !lstrcmpiA(buf
, "my_edit_class") ||
8030 !lstrcmpiA(buf
, "static") ||
8031 !lstrcmpiA(buf
, "ListBox") ||
8032 !lstrcmpiA(buf
, "ComboBox") ||
8033 !lstrcmpiA(buf
, "MyDialogClass") ||
8034 !lstrcmpiA(buf
, "#32770") ||
8035 !lstrcmpiA(buf
, "#32768"))
8041 static LRESULT CALLBACK
cbt_hook_proc(int nCode
, WPARAM wParam
, LPARAM lParam
)
8045 ok(cbt_hook_thread_id
== GetCurrentThreadId(), "we didn't ask for events from other threads\n");
8047 if (nCode
== HCBT_CLICKSKIPPED
)
8049 /* ignore this event, XP sends it a lot when switching focus between windows */
8050 return CallNextHookEx(hCBT_hook
, nCode
, wParam
, lParam
);
8053 if (nCode
== HCBT_SYSCOMMAND
|| nCode
== HCBT_KEYSKIPPED
)
8055 struct recvd_message msg
;
8058 msg
.message
= nCode
;
8059 msg
.flags
= hook
|wparam
|lparam
;
8060 msg
.wParam
= wParam
;
8061 msg
.lParam
= lParam
;
8065 return CallNextHookEx(hCBT_hook
, nCode
, wParam
, lParam
);
8068 if (nCode
== HCBT_DESTROYWND
)
8070 if (test_DestroyWindow_flag
)
8072 DWORD style
= GetWindowLongA((HWND
)wParam
, GWL_STYLE
);
8073 if (style
& WS_CHILD
)
8074 lParam
= GetWindowLongPtrA((HWND
)wParam
, GWLP_ID
);
8075 else if (style
& WS_POPUP
)
8076 lParam
= WND_POPUP_ID
;
8078 lParam
= WND_PARENT_ID
;
8082 /* Log also SetFocus(0) calls */
8083 hwnd
= wParam
? (HWND
)wParam
: (HWND
)lParam
;
8085 if (is_our_logged_class(hwnd
))
8087 struct recvd_message msg
;
8090 msg
.message
= nCode
;
8091 msg
.flags
= hook
|wparam
|lparam
;
8092 msg
.wParam
= wParam
;
8093 msg
.lParam
= lParam
;
8097 return CallNextHookEx(hCBT_hook
, nCode
, wParam
, lParam
);
8100 static void CALLBACK
win_event_proc(HWINEVENTHOOK hevent
,
8108 ok(thread_id
== GetCurrentThreadId(), "we didn't ask for events from other threads\n");
8110 /* ignore mouse cursor events */
8111 if (object_id
== OBJID_CURSOR
) return;
8113 if (!hwnd
|| is_our_logged_class(hwnd
))
8115 struct recvd_message msg
;
8118 msg
.message
= event
;
8119 msg
.flags
= winevent_hook
|wparam
|lparam
;
8120 msg
.wParam
= object_id
;
8121 msg
.lParam
= child_id
;
8127 static const WCHAR wszUnicode
[] = {'U','n','i','c','o','d','e',0};
8128 static const WCHAR wszAnsi
[] = {'U',0};
8130 static LRESULT CALLBACK
MsgConversionProcW(HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
8134 case CB_FINDSTRINGEXACT
:
8135 trace("String: %p\n", (LPCWSTR
)lParam
);
8136 if (!lstrcmpW((LPCWSTR
)lParam
, wszUnicode
))
8138 if (!lstrcmpW((LPCWSTR
)lParam
, wszAnsi
))
8142 return DefWindowProcW(hwnd
, uMsg
, wParam
, lParam
);
8145 static const struct message WmGetTextLengthAfromW
[] = {
8146 { WM_GETTEXTLENGTH
, sent
},
8147 { WM_GETTEXT
, sent
|optional
},
8151 static const WCHAR dummy_window_text
[] = {'d','u','m','m','y',' ','t','e','x','t',0};
8153 /* dummy window proc for WM_GETTEXTLENGTH test */
8154 static LRESULT CALLBACK
get_text_len_proc( HWND hwnd
, UINT msg
, WPARAM wp
, LPARAM lp
)
8158 case WM_GETTEXTLENGTH
:
8159 return lstrlenW(dummy_window_text
) + 37; /* some random length */
8161 lstrcpynW( (LPWSTR
)lp
, dummy_window_text
, wp
);
8162 return lstrlenW( (LPWSTR
)lp
);
8164 return DefWindowProcW( hwnd
, msg
, wp
, lp
);
8168 static void test_message_conversion(void)
8170 static const WCHAR wszMsgConversionClass
[] =
8171 {'M','s','g','C','o','n','v','e','r','s','i','o','n','C','l','a','s','s',0};
8175 WNDPROC wndproc
, newproc
;
8179 cls
.lpfnWndProc
= MsgConversionProcW
;
8182 cls
.hInstance
= GetModuleHandleW(NULL
);
8184 cls
.hCursor
= LoadCursorW(NULL
, (LPWSTR
)IDC_ARROW
);
8185 cls
.hbrBackground
= (HBRUSH
)(COLOR_BTNFACE
+1);
8186 cls
.lpszMenuName
= NULL
;
8187 cls
.lpszClassName
= wszMsgConversionClass
;
8188 /* this call will fail on Win9x, but that doesn't matter as this test is
8189 * meaningless on those platforms */
8190 if(!RegisterClassW(&cls
)) return;
8192 hwnd
= CreateWindowExW(0, wszMsgConversionClass
, NULL
, WS_OVERLAPPED
,
8193 100, 100, 200, 200, 0, 0, 0, NULL
);
8194 ok(hwnd
!= NULL
, "Window creation failed\n");
8198 wndproc
= (WNDPROC
)GetWindowLongPtrA(hwnd
, GWLP_WNDPROC
);
8199 lRes
= CallWindowProcA(wndproc
, hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
8200 ok(lRes
== 0, "String should have been converted\n");
8201 lRes
= CallWindowProcW(wndproc
, hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
8202 ok(lRes
== 1, "String shouldn't have been converted\n");
8206 wndproc
= (WNDPROC
)GetWindowLongPtrW(hwnd
, GWLP_WNDPROC
);
8207 lRes
= CallWindowProcA(wndproc
, hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
8208 ok(lRes
== 1, "String shouldn't have been converted\n");
8209 lRes
= CallWindowProcW(wndproc
, hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
8210 ok(lRes
== 1, "String shouldn't have been converted\n");
8212 /* Synchronous messages */
8214 lRes
= SendMessageA(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
8215 ok(lRes
== 0, "String should have been converted\n");
8216 lRes
= SendMessageW(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
8217 ok(lRes
== 1, "String shouldn't have been converted\n");
8219 /* Asynchronous messages */
8222 lRes
= PostMessageA(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
8223 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
8224 "PostMessage on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
8226 lRes
= PostMessageW(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
8227 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
8228 "PostMessage on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
8230 lRes
= PostThreadMessageA(GetCurrentThreadId(), CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
8231 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
8232 "PosThreadtMessage on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
8234 lRes
= PostThreadMessageW(GetCurrentThreadId(), CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
8235 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
8236 "PosThreadtMessage on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
8238 lRes
= SendNotifyMessageA(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
8239 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
8240 "SendNotifyMessage on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
8242 lRes
= SendNotifyMessageW(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
8243 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
8244 "SendNotifyMessage on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
8246 lRes
= SendMessageCallbackA(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
, NULL
, 0);
8247 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
8248 "SendMessageCallback on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
8250 lRes
= SendMessageCallbackW(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
, NULL
, 0);
8251 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
8252 "SendMessageCallback on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
8254 /* Check WM_GETTEXTLENGTH A->W behaviour, whether WM_GETTEXT is also sent or not */
8256 hwnd
= CreateWindowW (testWindowClassW
, wszUnicode
,
8257 WS_OVERLAPPEDWINDOW
,
8258 100, 100, 200, 200, 0, 0, 0, NULL
);
8261 lRes
= SendMessageA (hwnd
, WM_GETTEXTLENGTH
, 0, 0);
8262 ok_sequence(WmGetTextLengthAfromW
, "ANSI WM_GETTEXTLENGTH to Unicode window", FALSE
);
8263 ok( lRes
== WideCharToMultiByte( CP_ACP
, 0, wszUnicode
, lstrlenW(wszUnicode
), NULL
, 0, NULL
, NULL
),
8264 "got bad length %ld\n", lRes
);
8267 lRes
= CallWindowProcA( (WNDPROC
)GetWindowLongPtrA( hwnd
, GWLP_WNDPROC
),
8268 hwnd
, WM_GETTEXTLENGTH
, 0, 0);
8269 ok_sequence(WmGetTextLengthAfromW
, "ANSI WM_GETTEXTLENGTH to Unicode window", FALSE
);
8270 ok( lRes
== WideCharToMultiByte( CP_ACP
, 0, wszUnicode
, lstrlenW(wszUnicode
), NULL
, 0, NULL
, NULL
),
8271 "got bad length %ld\n", lRes
);
8273 wndproc
= (WNDPROC
)SetWindowLongPtrW( hwnd
, GWLP_WNDPROC
, (LONG_PTR
)get_text_len_proc
);
8274 newproc
= (WNDPROC
)GetWindowLongPtrA( hwnd
, GWLP_WNDPROC
);
8275 lRes
= CallWindowProcA( newproc
, hwnd
, WM_GETTEXTLENGTH
, 0, 0 );
8276 ok( lRes
== WideCharToMultiByte( CP_ACP
, 0, dummy_window_text
, lstrlenW(dummy_window_text
),
8277 NULL
, 0, NULL
, NULL
) ||
8278 broken(lRes
== lstrlenW(dummy_window_text
) + 37),
8279 "got bad length %ld\n", lRes
);
8281 SetWindowLongPtrW( hwnd
, GWLP_WNDPROC
, (LONG_PTR
)wndproc
); /* restore old wnd proc */
8282 lRes
= CallWindowProcA( newproc
, hwnd
, WM_GETTEXTLENGTH
, 0, 0 );
8283 ok( lRes
== WideCharToMultiByte( CP_ACP
, 0, dummy_window_text
, lstrlenW(dummy_window_text
),
8284 NULL
, 0, NULL
, NULL
) ||
8285 broken(lRes
== lstrlenW(dummy_window_text
) + 37),
8286 "got bad length %ld\n", lRes
);
8288 ret
= DestroyWindow(hwnd
);
8289 ok( ret
, "DestroyWindow() error %d\n", GetLastError());
8299 static VOID CALLBACK
tfunc(HWND hwnd
, UINT uMsg
, UINT_PTR id
, DWORD dwTime
)
8303 #define TIMER_ID 0x19
8304 #define TIMER_COUNT_EXPECTED 64
8305 #define TIMER_COUNT_TOLERANCE 9
8307 static int count
= 0;
8308 static void CALLBACK
callback_count(HWND hwnd
, UINT uMsg
, UINT_PTR idEvent
, DWORD dwTime
)
8313 static DWORD WINAPI
timer_thread_proc(LPVOID x
)
8315 struct timer_info
*info
= x
;
8318 r
= KillTimer(info
->hWnd
, 0x19);
8319 ok(r
,"KillTimer failed in thread\n");
8320 r
= SetTimer(info
->hWnd
,TIMER_ID
,10000,tfunc
);
8321 ok(r
,"SetTimer failed in thread\n");
8322 ok(r
==TIMER_ID
,"SetTimer id different\n");
8323 r
= SetEvent(info
->handles
[0]);
8324 ok(r
,"SetEvent failed in thread\n");
8328 static void test_timers(void)
8330 struct timer_info info
;
8335 info
.hWnd
= CreateWindowA("TestWindowClass", NULL
,
8336 WS_OVERLAPPEDWINDOW
,
8337 CW_USEDEFAULT
, CW_USEDEFAULT
, 300, 300, 0,
8340 info
.id
= SetTimer(info
.hWnd
,TIMER_ID
,10000,tfunc
);
8341 ok(info
.id
, "SetTimer failed\n");
8342 ok(info
.id
==TIMER_ID
, "SetTimer timer ID different\n");
8343 info
.handles
[0] = CreateEventW(NULL
,0,0,NULL
);
8344 info
.handles
[1] = CreateThread(NULL
,0,timer_thread_proc
,&info
,0,&id
);
8346 WaitForMultipleObjects(2, info
.handles
, FALSE
, INFINITE
);
8348 WaitForSingleObject(info
.handles
[1], INFINITE
);
8350 CloseHandle(info
.handles
[0]);
8351 CloseHandle(info
.handles
[1]);
8353 ok( KillTimer(info
.hWnd
, TIMER_ID
), "KillTimer failed\n");
8355 /* Check the minimum allowed timeout for a timer. MSDN indicates that it should be 10.0 ms,
8356 * but testing indicates that the minimum timeout is actually about 15.6 ms. Since there is
8357 * some measurement error between test runs we're allowing for ±8 counts (~2 ms).
8360 id
= SetTimer(info
.hWnd
, TIMER_ID
, 0, callback_count
);
8361 ok(id
!= 0, "did not get id from SetTimer.\n");
8362 ok(id
==TIMER_ID
, "SetTimer timer ID different\n");
8363 start
= GetTickCount();
8364 while (GetTickCount()-start
< 1001 && GetMessageA(&msg
, info
.hWnd
, 0, 0))
8365 DispatchMessageA(&msg
);
8366 ok(abs(count
-TIMER_COUNT_EXPECTED
) < TIMER_COUNT_TOLERANCE
8367 || broken(abs(count
-43) < TIMER_COUNT_TOLERANCE
) /* w2k3 */,
8368 "did not get expected count for minimum timeout (%d != ~%d).\n",
8369 count
, TIMER_COUNT_EXPECTED
);
8370 ok(KillTimer(info
.hWnd
, id
), "KillTimer failed\n");
8371 /* Perform the same check on SetSystemTimer (only available on w2k3 and older) */
8372 if (pSetSystemTimer
)
8377 id
= pSetSystemTimer(info
.hWnd
, TIMER_ID
, 0, callback_count
);
8378 ok(id
!= 0, "did not get id from SetSystemTimer.\n");
8379 ok(id
==TIMER_ID
, "SetTimer timer ID different\n");
8380 start
= GetTickCount();
8381 while (GetTickCount()-start
< 1001 && GetMessageA(&msg
, info
.hWnd
, 0, 0))
8383 if (msg
.message
== WM_SYSTIMER
)
8385 DispatchMessageA(&msg
);
8387 ok(abs(syscount
-TIMER_COUNT_EXPECTED
) < TIMER_COUNT_TOLERANCE
,
8388 "did not get expected count for minimum timeout (%d != ~%d).\n",
8389 syscount
, TIMER_COUNT_EXPECTED
);
8390 todo_wine
ok(count
== 0, "did not get expected count for callback timeout (%d != 0).\n",
8392 ok(pKillSystemTimer(info
.hWnd
, id
), "KillSystemTimer failed\n");
8395 ok(DestroyWindow(info
.hWnd
), "failed to destroy window\n");
8398 static void test_timers_no_wnd(void)
8405 id
= SetTimer(NULL
, 0, 100, callback_count
);
8406 ok(id
!= 0, "did not get id from SetTimer.\n");
8407 id2
= SetTimer(NULL
, id
, 200, callback_count
);
8408 ok(id2
== id
, "did not get same id from SetTimer when replacing (%li expected %li).\n", id2
, id
);
8410 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
8411 ok(count
== 0, "did not get zero count as expected (%i).\n", count
);
8413 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
8414 ok(count
== 1, "did not get one count as expected (%i).\n", count
);
8415 KillTimer(NULL
, id
);
8417 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
8418 ok(count
== 1, "killing replaced timer did not work (%i).\n", count
);
8420 /* Check the minimum allowed timeout for a timer. MSDN indicates that it should be 10.0 ms,
8421 * but testing indicates that the minimum timeout is actually about 15.6 ms. Since there is
8422 * some measurement error between test runs we're allowing for ±8 counts (~2 ms).
8425 id
= SetTimer(NULL
, 0, 0, callback_count
);
8426 ok(id
!= 0, "did not get id from SetTimer.\n");
8427 start
= GetTickCount();
8428 while (GetTickCount()-start
< 1001 && GetMessageA(&msg
, NULL
, 0, 0))
8429 DispatchMessageA(&msg
);
8430 ok(abs(count
-TIMER_COUNT_EXPECTED
) < TIMER_COUNT_TOLERANCE
,
8431 "did not get expected count for minimum timeout (%d != ~%d).\n",
8432 count
, TIMER_COUNT_EXPECTED
);
8433 KillTimer(NULL
, id
);
8434 /* Note: SetSystemTimer doesn't support a NULL window, see test_timers */
8437 /* Various win events with arbitrary parameters */
8438 static const struct message WmWinEventsSeq
[] = {
8439 { EVENT_SYSTEM_SOUND
, winevent_hook
|wparam
|lparam
, OBJID_WINDOW
, 0 },
8440 { EVENT_SYSTEM_ALERT
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 1 },
8441 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, OBJID_TITLEBAR
, 2 },
8442 { EVENT_SYSTEM_MENUSTART
, winevent_hook
|wparam
|lparam
, OBJID_MENU
, 3 },
8443 { EVENT_SYSTEM_MENUEND
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 4 },
8444 { EVENT_SYSTEM_MENUPOPUPSTART
, winevent_hook
|wparam
|lparam
, OBJID_VSCROLL
, 5 },
8445 { EVENT_SYSTEM_MENUPOPUPEND
, winevent_hook
|wparam
|lparam
, OBJID_HSCROLL
, 6 },
8446 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, OBJID_SIZEGRIP
, 7 },
8447 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 8 },
8448 /* our win event hook ignores OBJID_CURSOR events */
8449 /*{ EVENT_SYSTEM_MOVESIZESTART, winevent_hook|wparam|lparam, OBJID_CURSOR, 9 },*/
8450 { EVENT_SYSTEM_MOVESIZEEND
, winevent_hook
|wparam
|lparam
, OBJID_ALERT
, 10 },
8451 { EVENT_SYSTEM_CONTEXTHELPSTART
, winevent_hook
|wparam
|lparam
, OBJID_SOUND
, 11 },
8452 { EVENT_SYSTEM_CONTEXTHELPEND
, winevent_hook
|wparam
|lparam
, OBJID_QUERYCLASSNAMEIDX
, 12 },
8453 { EVENT_SYSTEM_DRAGDROPSTART
, winevent_hook
|wparam
|lparam
, OBJID_NATIVEOM
, 13 },
8454 { EVENT_SYSTEM_DRAGDROPEND
, winevent_hook
|wparam
|lparam
, OBJID_WINDOW
, 0 },
8455 { EVENT_SYSTEM_DIALOGSTART
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 1 },
8456 { EVENT_SYSTEM_DIALOGEND
, winevent_hook
|wparam
|lparam
, OBJID_TITLEBAR
, 2 },
8457 { EVENT_SYSTEM_SCROLLINGSTART
, winevent_hook
|wparam
|lparam
, OBJID_MENU
, 3 },
8458 { EVENT_SYSTEM_SCROLLINGEND
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 4 },
8459 { EVENT_SYSTEM_SWITCHSTART
, winevent_hook
|wparam
|lparam
, OBJID_VSCROLL
, 5 },
8460 { EVENT_SYSTEM_SWITCHEND
, winevent_hook
|wparam
|lparam
, OBJID_HSCROLL
, 6 },
8461 { EVENT_SYSTEM_MINIMIZESTART
, winevent_hook
|wparam
|lparam
, OBJID_SIZEGRIP
, 7 },
8462 { EVENT_SYSTEM_MINIMIZEEND
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 8 },
8465 static const struct message WmWinEventCaretSeq
[] = {
8466 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 1 */
8467 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 1 */
8468 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 2 */
8469 { EVENT_OBJECT_NAMECHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 1 */
8472 static const struct message WmWinEventCaretSeq_2
[] = {
8473 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 1/2 */
8474 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 1/2 */
8475 { EVENT_OBJECT_NAMECHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 1/2 */
8478 static const struct message WmWinEventAlertSeq
[] = {
8479 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_ALERT
, 0 },
8482 static const struct message WmWinEventAlertSeq_2
[] = {
8483 /* create window in the thread proc */
8484 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_WINDOW
, 2 },
8485 /* our test event */
8486 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_ALERT
, 2 },
8489 static const struct message WmGlobalHookSeq_1
[] = {
8490 /* create window in the thread proc */
8491 { HCBT_CREATEWND
, hook
|lparam
, 0, 2 },
8492 /* our test events */
8493 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_PREVWINDOW
, 2 },
8494 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_NEXTWINDOW
, 2 },
8497 static const struct message WmGlobalHookSeq_2
[] = {
8498 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_NEXTWINDOW
, 0 }, /* old local hook */
8499 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_NEXTWINDOW
, 2 }, /* new global hook */
8500 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_PREVWINDOW
, 0 }, /* old local hook */
8501 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_PREVWINDOW
, 2 }, /* new global hook */
8505 static const struct message WmMouseLLHookSeq
[] = {
8506 { WM_MOUSEMOVE
, hook
},
8507 { WM_LBUTTONUP
, hook
},
8508 { WM_MOUSEMOVE
, hook
},
8512 static void CALLBACK
win_event_global_hook_proc(HWINEVENTHOOK hevent
,
8522 if (GetClassNameA(hwnd
, buf
, sizeof(buf
)))
8524 if (!lstrcmpiA(buf
, "TestWindowClass") ||
8525 !lstrcmpiA(buf
, "static"))
8527 struct recvd_message msg
;
8530 msg
.message
= event
;
8531 msg
.flags
= winevent_hook
|wparam
|lparam
;
8532 msg
.wParam
= object_id
;
8533 msg
.lParam
= (thread_id
== GetCurrentThreadId()) ? child_id
: (child_id
+ 2);
8534 msg
.descr
= "WEH_2";
8540 static HHOOK hCBT_global_hook
;
8541 static DWORD cbt_global_hook_thread_id
;
8543 static LRESULT CALLBACK
cbt_global_hook_proc(int nCode
, WPARAM wParam
, LPARAM lParam
)
8548 if (nCode
== HCBT_SYSCOMMAND
)
8550 struct recvd_message msg
;
8553 msg
.message
= nCode
;
8554 msg
.flags
= hook
|wparam
|lparam
;
8555 msg
.wParam
= wParam
;
8556 msg
.lParam
= (cbt_global_hook_thread_id
== GetCurrentThreadId()) ? 1 : 2;
8557 msg
.descr
= "CBT_2";
8560 return CallNextHookEx(hCBT_global_hook
, nCode
, wParam
, lParam
);
8562 /* WH_MOUSE_LL hook */
8563 if (nCode
== HC_ACTION
)
8565 MSLLHOOKSTRUCT
*mhll
= (MSLLHOOKSTRUCT
*)lParam
;
8567 /* we can't test for real mouse events */
8568 if (mhll
->flags
& LLMHF_INJECTED
)
8570 struct recvd_message msg
;
8572 memset (&msg
, 0, sizeof (msg
));
8573 msg
.message
= wParam
;
8575 msg
.descr
= "CBT_2";
8578 return CallNextHookEx(hCBT_global_hook
, nCode
, wParam
, lParam
);
8581 /* Log also SetFocus(0) calls */
8582 hwnd
= wParam
? (HWND
)wParam
: (HWND
)lParam
;
8584 if (GetClassNameA(hwnd
, buf
, sizeof(buf
)))
8586 if (!lstrcmpiA(buf
, "TestWindowClass") ||
8587 !lstrcmpiA(buf
, "static"))
8589 struct recvd_message msg
;
8592 msg
.message
= nCode
;
8593 msg
.flags
= hook
|wparam
|lparam
;
8594 msg
.wParam
= wParam
;
8595 msg
.lParam
= (cbt_global_hook_thread_id
== GetCurrentThreadId()) ? 1 : 2;
8596 msg
.descr
= "CBT_2";
8600 return CallNextHookEx(hCBT_global_hook
, nCode
, wParam
, lParam
);
8603 static DWORD WINAPI
win_event_global_thread_proc(void *param
)
8607 HANDLE hevent
= *(HANDLE
*)param
;
8609 assert(pNotifyWinEvent
);
8611 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
, 0,0,0,0,0,0,0, NULL
);
8613 trace("created thread window %p\n", hwnd
);
8615 *(HWND
*)param
= hwnd
;
8618 /* this event should be received only by our new hook proc,
8619 * an old one does not expect an event from another thread.
8621 pNotifyWinEvent(EVENT_OBJECT_LOCATIONCHANGE
, hwnd
, OBJID_ALERT
, 0);
8624 while (GetMessageA(&msg
, 0, 0, 0))
8626 TranslateMessage(&msg
);
8627 DispatchMessageA(&msg
);
8632 static DWORD WINAPI
cbt_global_hook_thread_proc(void *param
)
8636 HANDLE hevent
= *(HANDLE
*)param
;
8639 /* these events should be received only by our new hook proc,
8640 * an old one does not expect an event from another thread.
8643 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
, 0,0,0,0,0,0,0, NULL
);
8645 trace("created thread window %p\n", hwnd
);
8647 *(HWND
*)param
= hwnd
;
8649 /* Windows doesn't like when a thread plays games with the focus,
8650 that leads to all kinds of misbehaviours and failures to activate
8651 a window. So, better keep next lines commented out.
8655 DefWindowProcA(hwnd
, WM_SYSCOMMAND
, SC_PREVWINDOW
, 0);
8656 DefWindowProcA(hwnd
, WM_SYSCOMMAND
, SC_NEXTWINDOW
, 0);
8660 while (GetMessageA(&msg
, 0, 0, 0))
8662 TranslateMessage(&msg
);
8663 DispatchMessageA(&msg
);
8668 static DWORD WINAPI
mouse_ll_global_thread_proc(void *param
)
8672 HANDLE hevent
= *(HANDLE
*)param
;
8674 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
, 0,0,0,0,0,0,0, NULL
);
8676 trace("created thread window %p\n", hwnd
);
8678 *(HWND
*)param
= hwnd
;
8682 /* Windows doesn't like when a thread plays games with the focus,
8683 * that leads to all kinds of misbehaviours and failures to activate
8684 * a window. So, better don't generate a mouse click message below.
8686 mouse_event(MOUSEEVENTF_MOVE
, -1, 0, 0, 0);
8687 mouse_event(MOUSEEVENTF_LEFTUP
, 0, 0, 0, 0);
8688 mouse_event(MOUSEEVENTF_MOVE
, 1, 0, 0, 0);
8691 while (GetMessageA(&msg
, 0, 0, 0))
8693 TranslateMessage(&msg
);
8694 DispatchMessageA(&msg
);
8699 static void test_winevents(void)
8705 HANDLE hthread
, hevent
;
8707 HWINEVENTHOOK hhook
;
8708 const struct message
*events
= WmWinEventsSeq
;
8710 hwnd
= CreateWindowExA(0, "TestWindowClass", NULL
,
8711 WS_OVERLAPPEDWINDOW
,
8712 CW_USEDEFAULT
, CW_USEDEFAULT
, 300, 300, 0,
8716 /****** start of global hook test *************/
8717 hCBT_global_hook
= SetWindowsHookExA(WH_CBT
, cbt_global_hook_proc
, GetModuleHandleA(0), 0);
8718 if (!hCBT_global_hook
)
8720 ok(DestroyWindow(hwnd
), "failed to destroy window\n");
8721 skip( "cannot set global hook\n" );
8725 hevent
= CreateEventA(NULL
, 0, 0, NULL
);
8729 hthread
= CreateThread(NULL
, 0, cbt_global_hook_thread_proc
, &hwnd2
, 0, &tid
);
8730 ok(hthread
!= NULL
, "CreateThread failed, error %d\n", GetLastError());
8732 ok(WaitForSingleObject(hevent
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
8734 ok_sequence(WmGlobalHookSeq_1
, "global hook 1", FALSE
);
8737 /* this one should be received only by old hook proc */
8738 DefWindowProcA(hwnd
, WM_SYSCOMMAND
, SC_NEXTWINDOW
, 0);
8739 /* this one should be received only by old hook proc */
8740 DefWindowProcA(hwnd
, WM_SYSCOMMAND
, SC_PREVWINDOW
, 0);
8742 ok_sequence(WmGlobalHookSeq_2
, "global hook 2", FALSE
);
8744 ret
= UnhookWindowsHookEx(hCBT_global_hook
);
8745 ok( ret
, "UnhookWindowsHookEx error %d\n", GetLastError());
8747 PostThreadMessageA(tid
, WM_QUIT
, 0, 0);
8748 ok(WaitForSingleObject(hthread
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
8749 CloseHandle(hthread
);
8750 CloseHandle(hevent
);
8751 ok(!IsWindow(hwnd2
), "window should be destroyed on thread exit\n");
8752 /****** end of global hook test *************/
8754 if (!pSetWinEventHook
|| !pNotifyWinEvent
|| !pUnhookWinEvent
)
8756 ok(DestroyWindow(hwnd
), "failed to destroy window\n");
8764 /* this test doesn't pass under Win9x */
8765 /* win2k ignores events with hwnd == 0 */
8766 SetLastError(0xdeadbeef);
8767 pNotifyWinEvent(events
[0].message
, 0, events
[0].wParam
, events
[0].lParam
);
8768 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
|| /* Win2k */
8769 GetLastError() == 0xdeadbeef, /* Win9x */
8770 "unexpected error %d\n", GetLastError());
8771 ok_sequence(WmEmptySeq
, "empty notify winevents", FALSE
);
8774 for (i
= 0; i
< sizeof(WmWinEventsSeq
)/sizeof(WmWinEventsSeq
[0]); i
++)
8775 pNotifyWinEvent(events
[i
].message
, hwnd
, events
[i
].wParam
, events
[i
].lParam
);
8777 ok_sequence(WmWinEventsSeq
, "notify winevents", FALSE
);
8779 /****** start of event filtering test *************/
8780 hhook
= pSetWinEventHook(
8781 EVENT_OBJECT_SHOW
, /* 0x8002 */
8782 EVENT_OBJECT_LOCATIONCHANGE
, /* 0x800B */
8783 GetModuleHandleA(0), win_event_global_hook_proc
,
8784 GetCurrentProcessId(), 0,
8785 WINEVENT_INCONTEXT
);
8786 ok(hhook
!= 0, "SetWinEventHook error %d\n", GetLastError());
8788 hevent
= CreateEventA(NULL
, 0, 0, NULL
);
8792 hthread
= CreateThread(NULL
, 0, win_event_global_thread_proc
, &hwnd2
, 0, &tid
);
8793 ok(hthread
!= NULL
, "CreateThread failed, error %d\n", GetLastError());
8795 ok(WaitForSingleObject(hevent
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
8797 ok_sequence(WmWinEventAlertSeq
, "alert winevent", FALSE
);
8800 /* this one should be received only by old hook proc */
8801 pNotifyWinEvent(EVENT_OBJECT_CREATE
, hwnd
, OBJID_CARET
, 0); /* 0x8000 */
8802 pNotifyWinEvent(EVENT_OBJECT_SHOW
, hwnd
, OBJID_CARET
, 0); /* 0x8002 */
8803 /* this one should be received only by old hook proc */
8804 pNotifyWinEvent(EVENT_OBJECT_NAMECHANGE
, hwnd
, OBJID_CARET
, 0); /* 0x800C */
8806 ok_sequence(WmWinEventCaretSeq
, "caret winevent", FALSE
);
8808 ret
= pUnhookWinEvent(hhook
);
8809 ok( ret
, "UnhookWinEvent error %d\n", GetLastError());
8811 PostThreadMessageA(tid
, WM_QUIT
, 0, 0);
8812 ok(WaitForSingleObject(hthread
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
8813 CloseHandle(hthread
);
8814 CloseHandle(hevent
);
8815 ok(!IsWindow(hwnd2
), "window should be destroyed on thread exit\n");
8816 /****** end of event filtering test *************/
8818 /****** start of out of context event test *************/
8819 hhook
= pSetWinEventHook(EVENT_MIN
, EVENT_MAX
, 0,
8820 win_event_global_hook_proc
, GetCurrentProcessId(), 0,
8821 WINEVENT_OUTOFCONTEXT
);
8822 ok(hhook
!= 0, "SetWinEventHook error %d\n", GetLastError());
8824 hevent
= CreateEventA(NULL
, 0, 0, NULL
);
8830 hthread
= CreateThread(NULL
, 0, win_event_global_thread_proc
, &hwnd2
, 0, &tid
);
8831 ok(hthread
!= NULL
, "CreateThread failed, error %d\n", GetLastError());
8833 ok(WaitForSingleObject(hevent
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
8835 ok_sequence(WmEmptySeq
, "empty notify winevents", FALSE
);
8836 /* process pending winevent messages */
8837 ok(!PeekMessageA(&msg
, 0, 0, 0, PM_NOREMOVE
), "msg queue should be empty\n");
8838 ok_sequence(WmWinEventAlertSeq_2
, "alert winevent for out of context proc", FALSE
);
8841 /* this one should be received only by old hook proc */
8842 pNotifyWinEvent(EVENT_OBJECT_CREATE
, hwnd
, OBJID_CARET
, 0); /* 0x8000 */
8843 pNotifyWinEvent(EVENT_OBJECT_SHOW
, hwnd
, OBJID_CARET
, 0); /* 0x8002 */
8844 /* this one should be received only by old hook proc */
8845 pNotifyWinEvent(EVENT_OBJECT_NAMECHANGE
, hwnd
, OBJID_CARET
, 0); /* 0x800C */
8847 ok_sequence(WmWinEventCaretSeq_2
, "caret winevent for incontext proc", FALSE
);
8848 /* process pending winevent messages */
8849 ok(!PeekMessageA(&msg
, 0, 0, 0, PM_NOREMOVE
), "msg queue should be empty\n");
8850 ok_sequence(WmWinEventCaretSeq_2
, "caret winevent for out of context proc", FALSE
);
8852 ret
= pUnhookWinEvent(hhook
);
8853 ok( ret
, "UnhookWinEvent error %d\n", GetLastError());
8855 PostThreadMessageA(tid
, WM_QUIT
, 0, 0);
8856 ok(WaitForSingleObject(hthread
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
8857 CloseHandle(hthread
);
8858 CloseHandle(hevent
);
8859 ok(!IsWindow(hwnd2
), "window should be destroyed on thread exit\n");
8860 /****** end of out of context event test *************/
8862 /****** start of MOUSE_LL hook test *************/
8863 hCBT_global_hook
= SetWindowsHookExA(WH_MOUSE_LL
, cbt_global_hook_proc
, GetModuleHandleA(0), 0);
8864 /* WH_MOUSE_LL is not supported on Win9x platforms */
8865 if (!hCBT_global_hook
)
8867 win_skip("Skipping WH_MOUSE_LL test on this platform\n");
8868 goto skip_mouse_ll_hook_test
;
8871 hevent
= CreateEventA(NULL
, 0, 0, NULL
);
8875 hthread
= CreateThread(NULL
, 0, mouse_ll_global_thread_proc
, &hwnd2
, 0, &tid
);
8876 ok(hthread
!= NULL
, "CreateThread failed, error %d\n", GetLastError());
8878 while (WaitForSingleObject(hevent
, 100) == WAIT_TIMEOUT
)
8879 while (PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA( &msg
);
8881 ok_sequence(WmMouseLLHookSeq
, "MOUSE_LL hook other thread", FALSE
);
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);
8888 ok_sequence(WmMouseLLHookSeq
, "MOUSE_LL hook same thread", FALSE
);
8890 ret
= UnhookWindowsHookEx(hCBT_global_hook
);
8891 ok( ret
, "UnhookWindowsHookEx error %d\n", GetLastError());
8893 PostThreadMessageA(tid
, WM_QUIT
, 0, 0);
8894 ok(WaitForSingleObject(hthread
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
8895 CloseHandle(hthread
);
8896 CloseHandle(hevent
);
8897 ok(!IsWindow(hwnd2
), "window should be destroyed on thread exit\n");
8898 /****** end of MOUSE_LL hook test *************/
8899 skip_mouse_ll_hook_test
:
8901 ok(DestroyWindow(hwnd
), "failed to destroy window\n");
8904 static void test_set_hook(void)
8908 HWINEVENTHOOK hwinevent_hook
;
8910 hhook
= SetWindowsHookExA(WH_CBT
, cbt_hook_proc
, GetModuleHandleA(0), GetCurrentThreadId());
8911 ok(hhook
!= 0, "local hook does not require hModule set to 0\n");
8912 UnhookWindowsHookEx(hhook
);
8916 /* this test doesn't pass under Win9x: BUG! */
8917 SetLastError(0xdeadbeef);
8918 hhook
= SetWindowsHookExA(WH_CBT
, cbt_hook_proc
, 0, 0);
8919 ok(!hhook
, "global hook requires hModule != 0\n");
8920 ok(GetLastError() == ERROR_HOOK_NEEDS_HMOD
, "unexpected error %d\n", GetLastError());
8923 SetLastError(0xdeadbeef);
8924 hhook
= SetWindowsHookExA(WH_CBT
, 0, GetModuleHandleA(0), GetCurrentThreadId());
8925 ok(!hhook
, "SetWinEventHook with invalid proc should fail\n");
8926 ok(GetLastError() == ERROR_INVALID_FILTER_PROC
|| /* Win2k */
8927 GetLastError() == 0xdeadbeef, /* Win9x */
8928 "unexpected error %d\n", GetLastError());
8930 SetLastError(0xdeadbeef);
8931 ok(!UnhookWindowsHookEx((HHOOK
)0xdeadbeef), "UnhookWindowsHookEx succeeded\n");
8932 ok(GetLastError() == ERROR_INVALID_HOOK_HANDLE
|| /* Win2k */
8933 GetLastError() == 0xdeadbeef, /* Win9x */
8934 "unexpected error %d\n", GetLastError());
8936 if (!pSetWinEventHook
|| !pUnhookWinEvent
) return;
8938 /* even process local incontext hooks require hmodule */
8939 SetLastError(0xdeadbeef);
8940 hwinevent_hook
= pSetWinEventHook(EVENT_MIN
, EVENT_MAX
, 0, win_event_proc
,
8941 GetCurrentProcessId(), 0, WINEVENT_INCONTEXT
);
8942 ok(!hwinevent_hook
, "WINEVENT_INCONTEXT requires hModule != 0\n");
8943 ok(GetLastError() == ERROR_HOOK_NEEDS_HMOD
|| /* Win2k */
8944 GetLastError() == 0xdeadbeef, /* Win9x */
8945 "unexpected error %d\n", GetLastError());
8947 /* even thread local incontext hooks require hmodule */
8948 SetLastError(0xdeadbeef);
8949 hwinevent_hook
= pSetWinEventHook(EVENT_MIN
, EVENT_MAX
, 0, win_event_proc
,
8950 GetCurrentProcessId(), GetCurrentThreadId(), WINEVENT_INCONTEXT
);
8951 ok(!hwinevent_hook
, "WINEVENT_INCONTEXT requires hModule != 0\n");
8952 ok(GetLastError() == ERROR_HOOK_NEEDS_HMOD
|| /* Win2k */
8953 GetLastError() == 0xdeadbeef, /* Win9x */
8954 "unexpected error %d\n", GetLastError());
8958 /* these 3 tests don't pass under Win9x */
8959 SetLastError(0xdeadbeef);
8960 hwinevent_hook
= pSetWinEventHook(1, 0, 0, win_event_proc
,
8961 GetCurrentProcessId(), 0, WINEVENT_OUTOFCONTEXT
);
8962 ok(!hwinevent_hook
, "SetWinEventHook with invalid event range should fail\n");
8963 ok(GetLastError() == ERROR_INVALID_HOOK_FILTER
, "unexpected error %d\n", GetLastError());
8965 SetLastError(0xdeadbeef);
8966 hwinevent_hook
= pSetWinEventHook(-1, 1, 0, win_event_proc
,
8967 GetCurrentProcessId(), 0, WINEVENT_OUTOFCONTEXT
);
8968 ok(!hwinevent_hook
, "SetWinEventHook with invalid event range should fail\n");
8969 ok(GetLastError() == ERROR_INVALID_HOOK_FILTER
, "unexpected error %d\n", GetLastError());
8971 SetLastError(0xdeadbeef);
8972 hwinevent_hook
= pSetWinEventHook(EVENT_MIN
, EVENT_MAX
, 0, win_event_proc
,
8973 0, 0xdeadbeef, WINEVENT_OUTOFCONTEXT
);
8974 ok(!hwinevent_hook
, "SetWinEventHook with invalid tid should fail\n");
8975 ok(GetLastError() == ERROR_INVALID_THREAD_ID
, "unexpected error %d\n", GetLastError());
8978 SetLastError(0xdeadbeef);
8979 hwinevent_hook
= pSetWinEventHook(0, 0, 0, win_event_proc
,
8980 GetCurrentProcessId(), 0, WINEVENT_OUTOFCONTEXT
);
8981 ok(hwinevent_hook
!= 0, "SetWinEventHook error %d\n", GetLastError());
8982 ok(GetLastError() == 0xdeadbeef, "unexpected error %d\n", GetLastError());
8983 ret
= pUnhookWinEvent(hwinevent_hook
);
8984 ok( ret
, "UnhookWinEvent error %d\n", GetLastError());
8987 /* This call succeeds under win2k SP4, but fails under Wine.
8988 Does win2k test/use passed process id? */
8989 SetLastError(0xdeadbeef);
8990 hwinevent_hook
= pSetWinEventHook(EVENT_MIN
, EVENT_MAX
, 0, win_event_proc
,
8991 0xdeadbeef, 0, WINEVENT_OUTOFCONTEXT
);
8992 ok(hwinevent_hook
!= 0, "SetWinEventHook error %d\n", GetLastError());
8993 ok(GetLastError() == 0xdeadbeef, "unexpected error %d\n", GetLastError());
8994 ret
= pUnhookWinEvent(hwinevent_hook
);
8995 ok( ret
, "UnhookWinEvent error %d\n", GetLastError());
8998 SetLastError(0xdeadbeef);
8999 ok(!pUnhookWinEvent((HWINEVENTHOOK
)0xdeadbeef), "UnhookWinEvent succeeded\n");
9000 ok(GetLastError() == ERROR_INVALID_HANDLE
|| /* Win2k */
9001 GetLastError() == 0xdeadbeef, /* Win9x */
9002 "unexpected error %d\n", GetLastError());
9005 static const struct message ScrollWindowPaint1
[] = {
9007 { WM_ERASEBKGND
, sent
|beginpaint
},
9008 { WM_GETTEXTLENGTH
, sent
|optional
},
9009 { WM_PAINT
, sent
|optional
},
9010 { WM_NCPAINT
, sent
|beginpaint
|optional
},
9011 { WM_GETTEXT
, sent
|beginpaint
|optional
},
9012 { WM_GETTEXT
, sent
|beginpaint
|optional
},
9013 { WM_GETTEXT
, sent
|beginpaint
|optional
},
9014 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
9015 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
9019 static const struct message ScrollWindowPaint2
[] = {
9024 static void test_scrollwindowex(void)
9027 RECT rect
={0,0,130,130};
9029 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test Scroll",
9030 WS_VISIBLE
|WS_OVERLAPPEDWINDOW
,
9031 100, 100, 200, 200, 0, 0, 0, NULL
);
9032 ok (hwnd
!= 0, "Failed to create overlapped window\n");
9033 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child",
9034 WS_VISIBLE
|WS_CAPTION
|WS_CHILD
,
9035 10, 10, 150, 150, hwnd
, 0, 0, NULL
);
9036 ok (hchild
!= 0, "Failed to create child\n");
9041 /* scroll without the child window */
9042 trace("start scroll\n");
9043 ScrollWindowEx( hwnd
, 10, 10, &rect
, NULL
, NULL
, NULL
,
9044 SW_ERASE
|SW_INVALIDATE
);
9045 ok_sequence(WmEmptySeq
, "ScrollWindowEx", FALSE
);
9046 trace("end scroll\n");
9049 ok_sequence(ScrollWindowPaint1
, "ScrollWindowEx", FALSE
);
9053 /* Now without the SW_ERASE flag */
9054 trace("start scroll\n");
9055 ScrollWindowEx( hwnd
, 10, 10, &rect
, NULL
, NULL
, NULL
, SW_INVALIDATE
);
9056 ok_sequence(WmEmptySeq
, "ScrollWindowEx", FALSE
);
9057 trace("end scroll\n");
9060 ok_sequence(ScrollWindowPaint2
, "ScrollWindowEx", FALSE
);
9064 /* now scroll the child window as well */
9065 trace("start scroll\n");
9066 ScrollWindowEx( hwnd
, 10, 10, &rect
, NULL
, NULL
, NULL
,
9067 SW_SCROLLCHILDREN
|SW_ERASE
|SW_INVALIDATE
);
9068 /* wine sends WM_POSCHANGING, WM_POSCHANGED messages */
9069 /* windows sometimes a WM_MOVE */
9070 ok_sequence(WmEmptySeq
, "ScrollWindowEx", TRUE
);
9071 trace("end scroll\n");
9074 ok_sequence(ScrollWindowPaint1
, "ScrollWindowEx", FALSE
);
9078 /* now scroll with ScrollWindow() */
9079 trace("start scroll with ScrollWindow\n");
9080 ScrollWindow( hwnd
, 5, 5, NULL
, NULL
);
9081 trace("end scroll\n");
9084 ok_sequence(ScrollWindowPaint1
, "ScrollWindow", FALSE
);
9086 ok(DestroyWindow(hchild
), "failed to destroy window\n");
9087 ok(DestroyWindow(hwnd
), "failed to destroy window\n");
9091 static const struct message destroy_window_with_children
[] = {
9092 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* popup */
9093 { HCBT_DESTROYWND
, hook
|lparam
, 0, WND_PARENT_ID
}, /* parent */
9094 { 0x0090, sent
|optional
},
9095 { HCBT_DESTROYWND
, hook
|lparam
, 0, WND_POPUP_ID
}, /* popup */
9096 { 0x0090, sent
|optional
},
9097 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* popup */
9098 { WM_DESTROY
, sent
|wparam
|lparam
, 0, WND_POPUP_ID
}, /* popup */
9099 { WM_CAPTURECHANGED
, sent
|wparam
|lparam
, 0, WND_POPUP_ID
}, /* popup */
9100 { WM_NCDESTROY
, sent
|wparam
|lparam
, 0, WND_POPUP_ID
}, /* popup */
9101 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* parent */
9102 { WM_DESTROY
, sent
|wparam
|lparam
, 0, WND_PARENT_ID
}, /* parent */
9103 { WM_DESTROY
, sent
|wparam
|lparam
, 0, WND_CHILD_ID
+ 2 }, /* child2 */
9104 { WM_DESTROY
, sent
|wparam
|lparam
, 0, WND_CHILD_ID
+ 1 }, /* child1 */
9105 { WM_DESTROY
, sent
|wparam
|lparam
, 0, WND_CHILD_ID
+ 3 }, /* child3 */
9106 { WM_NCDESTROY
, sent
|wparam
|lparam
, 0, WND_CHILD_ID
+ 2 }, /* child2 */
9107 { WM_NCDESTROY
, sent
|wparam
|lparam
, 0, WND_CHILD_ID
+ 3 }, /* child3 */
9108 { WM_NCDESTROY
, sent
|wparam
|lparam
, 0, WND_CHILD_ID
+ 1 }, /* child1 */
9109 { WM_NCDESTROY
, sent
|wparam
|lparam
, 0, WND_PARENT_ID
}, /* parent */
9113 static void test_DestroyWindow(void)
9116 HWND parent
, child1
, child2
, child3
, child4
, test
;
9117 UINT_PTR child_id
= WND_CHILD_ID
+ 1;
9119 parent
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
9120 100, 100, 200, 200, 0, 0, 0, NULL
);
9121 assert(parent
!= 0);
9122 child1
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_CHILD
,
9123 0, 0, 50, 50, parent
, (HMENU
)child_id
++, 0, NULL
);
9124 assert(child1
!= 0);
9125 child2
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_CHILD
,
9126 0, 0, 50, 50, GetDesktopWindow(), (HMENU
)child_id
++, 0, NULL
);
9127 assert(child2
!= 0);
9128 child3
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_CHILD
,
9129 0, 0, 50, 50, child1
, (HMENU
)child_id
++, 0, NULL
);
9130 assert(child3
!= 0);
9131 child4
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_POPUP
,
9132 0, 0, 50, 50, parent
, 0, 0, NULL
);
9133 assert(child4
!= 0);
9135 /* test owner/parent of child2 */
9136 test
= GetParent(child2
);
9137 ok(test
== GetDesktopWindow(), "wrong parent %p\n", test
);
9138 ok(!IsChild(parent
, child2
), "wrong parent/child %p/%p\n", parent
, child2
);
9140 test
= pGetAncestor(child2
, GA_PARENT
);
9141 ok(test
== GetDesktopWindow(), "wrong parent %p\n", test
);
9143 test
= GetWindow(child2
, GW_OWNER
);
9144 ok(!test
, "wrong owner %p\n", test
);
9146 test
= SetParent(child2
, parent
);
9147 ok(test
== GetDesktopWindow(), "wrong old parent %p\n", test
);
9149 /* test owner/parent of the parent */
9150 test
= GetParent(parent
);
9151 ok(!test
, "wrong parent %p\n", test
);
9152 ok(!IsChild(GetDesktopWindow(), parent
), "wrong parent/child %p/%p\n", GetDesktopWindow(), parent
);
9154 test
= pGetAncestor(parent
, GA_PARENT
);
9155 ok(test
== GetDesktopWindow(), "wrong parent %p\n", test
);
9157 test
= GetWindow(parent
, GW_OWNER
);
9158 ok(!test
, "wrong owner %p\n", test
);
9160 /* test owner/parent of child1 */
9161 test
= GetParent(child1
);
9162 ok(test
== parent
, "wrong parent %p\n", test
);
9163 ok(IsChild(parent
, child1
), "wrong parent/child %p/%p\n", parent
, child1
);
9165 test
= pGetAncestor(child1
, GA_PARENT
);
9166 ok(test
== parent
, "wrong parent %p\n", test
);
9168 test
= GetWindow(child1
, GW_OWNER
);
9169 ok(!test
, "wrong owner %p\n", test
);
9171 /* test owner/parent of child2 */
9172 test
= GetParent(child2
);
9173 ok(test
== parent
, "wrong parent %p\n", test
);
9174 ok(IsChild(parent
, child2
), "wrong parent/child %p/%p\n", parent
, child2
);
9176 test
= pGetAncestor(child2
, GA_PARENT
);
9177 ok(test
== parent
, "wrong parent %p\n", test
);
9179 test
= GetWindow(child2
, GW_OWNER
);
9180 ok(!test
, "wrong owner %p\n", test
);
9182 /* test owner/parent of child3 */
9183 test
= GetParent(child3
);
9184 ok(test
== child1
, "wrong parent %p\n", test
);
9185 ok(IsChild(parent
, child3
), "wrong parent/child %p/%p\n", parent
, child3
);
9187 test
= pGetAncestor(child3
, GA_PARENT
);
9188 ok(test
== child1
, "wrong parent %p\n", test
);
9190 test
= GetWindow(child3
, GW_OWNER
);
9191 ok(!test
, "wrong owner %p\n", test
);
9193 /* test owner/parent of child4 */
9194 test
= GetParent(child4
);
9195 ok(test
== parent
, "wrong parent %p\n", test
);
9196 ok(!IsChild(parent
, child4
), "wrong parent/child %p/%p\n", parent
, child4
);
9198 test
= pGetAncestor(child4
, GA_PARENT
);
9199 ok(test
== GetDesktopWindow(), "wrong parent %p\n", test
);
9201 test
= GetWindow(child4
, GW_OWNER
);
9202 ok(test
== parent
, "wrong owner %p\n", test
);
9206 trace("parent %p, child1 %p, child2 %p, child3 %p, child4 %p\n",
9207 parent
, child1
, child2
, child3
, child4
);
9210 test
= GetCapture();
9211 ok(test
== child4
, "wrong capture window %p\n", test
);
9213 test_DestroyWindow_flag
= TRUE
;
9214 ret
= DestroyWindow(parent
);
9215 ok( ret
, "DestroyWindow() error %d\n", GetLastError());
9216 test_DestroyWindow_flag
= FALSE
;
9217 ok_sequence(destroy_window_with_children
, "destroy window with children", FALSE
);
9219 ok(!IsWindow(parent
), "parent still exists\n");
9220 ok(!IsWindow(child1
), "child1 still exists\n");
9221 ok(!IsWindow(child2
), "child2 still exists\n");
9222 ok(!IsWindow(child3
), "child3 still exists\n");
9223 ok(!IsWindow(child4
), "child4 still exists\n");
9225 test
= GetCapture();
9226 ok(!test
, "wrong capture window %p\n", test
);
9230 static const struct message WmDispatchPaint
[] = {
9231 { WM_NCPAINT
, sent
},
9232 { WM_GETTEXT
, sent
|defwinproc
|optional
},
9233 { WM_GETTEXT
, sent
|defwinproc
|optional
},
9234 { WM_ERASEBKGND
, sent
},
9238 static LRESULT WINAPI
DispatchMessageCheckProc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
9240 if (message
== WM_PAINT
) return 0;
9241 return MsgCheckProcA( hwnd
, message
, wParam
, lParam
);
9244 static void test_DispatchMessage(void)
9249 HWND hwnd
= CreateWindowA( "TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
9250 100, 100, 200, 200, 0, 0, 0, NULL
);
9251 ShowWindow( hwnd
, SW_SHOW
);
9252 UpdateWindow( hwnd
);
9255 SetWindowLongPtrA( hwnd
, GWLP_WNDPROC
, (LONG_PTR
)DispatchMessageCheckProc
);
9257 SetRect( &rect
, -5, -5, 5, 5 );
9258 RedrawWindow( hwnd
, &rect
, 0, RDW_INVALIDATE
|RDW_ERASE
|RDW_FRAME
);
9260 while (PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
))
9262 if (msg
.message
!= WM_PAINT
) DispatchMessageA( &msg
);
9266 DispatchMessageA( &msg
);
9267 /* DispatchMessage will send WM_NCPAINT if non client area is still invalid after WM_PAINT */
9268 if (!count
) ok_sequence( WmDispatchPaint
, "WmDispatchPaint", FALSE
);
9269 else ok_sequence( WmEmptySeq
, "WmEmpty", FALSE
);
9270 if (++count
> 10) break;
9273 ok( msg
.message
== WM_PAINT
&& count
> 10, "WM_PAINT messages stopped\n" );
9275 trace("now without DispatchMessage\n");
9277 RedrawWindow( hwnd
, &rect
, 0, RDW_INVALIDATE
|RDW_ERASE
|RDW_FRAME
);
9279 while (PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
))
9281 if (msg
.message
!= WM_PAINT
) DispatchMessageA( &msg
);
9284 HRGN hrgn
= CreateRectRgn( 0, 0, 0, 0 );
9286 /* this will send WM_NCCPAINT just like DispatchMessage does */
9287 GetUpdateRgn( hwnd
, hrgn
, TRUE
);
9288 ok_sequence( WmDispatchPaint
, "WmDispatchPaint", FALSE
);
9289 DeleteObject( hrgn
);
9290 GetClientRect( hwnd
, &rect
);
9291 ValidateRect( hwnd
, &rect
); /* this will stop WM_PAINTs */
9292 ok( !count
, "Got multiple WM_PAINTs\n" );
9293 if (++count
> 10) break;
9298 RedrawWindow( hwnd
, &rect
, 0, RDW_INVALIDATE
|RDW_ERASE
|RDW_FRAME
);
9300 while (PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
))
9302 if (msg
.message
!= WM_PAINT
) DispatchMessageA( &msg
);
9308 hdc
= BeginPaint( hwnd
, NULL
);
9309 ok( !hdc
, "got valid hdc %p from BeginPaint\n", hdc
);
9310 ok( !EndPaint( hwnd
, NULL
), "EndPaint succeeded\n" );
9311 ok_sequence( WmDispatchPaint
, "WmDispatchPaint", FALSE
);
9312 ok( !count
, "Got multiple WM_PAINTs\n" );
9313 if (++count
> 10) break;
9316 DestroyWindow(hwnd
);
9320 static const struct message WmUser
[] = {
9332 static DWORD CALLBACK
send_msg_thread( LPVOID arg
)
9334 struct sendmsg_info
*info
= arg
;
9335 SetLastError( 0xdeadbeef );
9336 info
->ret
= SendMessageTimeoutA( info
->hwnd
, WM_USER
, 0, 0, 0, info
->timeout
, NULL
);
9337 if (!info
->ret
) ok( GetLastError() == ERROR_TIMEOUT
||
9338 broken(GetLastError() == 0), /* win9x */
9339 "unexpected error %d\n", GetLastError());
9343 static void wait_for_thread( HANDLE thread
)
9345 while (MsgWaitForMultipleObjects(1, &thread
, FALSE
, INFINITE
, QS_SENDMESSAGE
) != WAIT_OBJECT_0
)
9348 while (PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
9352 static LRESULT WINAPI
send_msg_delay_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
9354 if (message
== WM_USER
) Sleep(200);
9355 return MsgCheckProcA( hwnd
, message
, wParam
, lParam
);
9358 static void test_SendMessageTimeout(void)
9361 struct sendmsg_info info
;
9365 info
.hwnd
= CreateWindowA( "TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
9366 100, 100, 200, 200, 0, 0, 0, NULL
);
9370 info
.timeout
= 1000;
9371 info
.ret
= 0xdeadbeef;
9372 thread
= CreateThread( NULL
, 0, send_msg_thread
, &info
, 0, &tid
);
9373 wait_for_thread( thread
);
9374 CloseHandle( thread
);
9375 ok( info
.ret
== 1, "SendMessageTimeout failed\n" );
9376 ok_sequence( WmUser
, "WmUser", FALSE
);
9379 info
.ret
= 0xdeadbeef;
9380 thread
= CreateThread( NULL
, 0, send_msg_thread
, &info
, 0, &tid
);
9381 Sleep(100); /* SendMessageTimeout should time out here */
9382 wait_for_thread( thread
);
9383 CloseHandle( thread
);
9384 ok( info
.ret
== 0, "SendMessageTimeout succeeded\n" );
9385 ok_sequence( WmEmptySeq
, "WmEmptySeq", FALSE
);
9387 /* 0 means infinite timeout (but not on win9x) */
9389 info
.ret
= 0xdeadbeef;
9390 thread
= CreateThread( NULL
, 0, send_msg_thread
, &info
, 0, &tid
);
9392 wait_for_thread( thread
);
9393 CloseHandle( thread
);
9394 is_win9x
= !info
.ret
;
9395 if (is_win9x
) ok_sequence( WmEmptySeq
, "WmEmptySeq", FALSE
);
9396 else ok_sequence( WmUser
, "WmUser", FALSE
);
9398 /* timeout is treated as signed despite the prototype (but not on win9x) */
9399 info
.timeout
= 0x7fffffff;
9400 info
.ret
= 0xdeadbeef;
9401 thread
= CreateThread( NULL
, 0, send_msg_thread
, &info
, 0, &tid
);
9403 wait_for_thread( thread
);
9404 CloseHandle( thread
);
9405 ok( info
.ret
== 1, "SendMessageTimeout failed\n" );
9406 ok_sequence( WmUser
, "WmUser", FALSE
);
9408 info
.timeout
= 0x80000000;
9409 info
.ret
= 0xdeadbeef;
9410 thread
= CreateThread( NULL
, 0, send_msg_thread
, &info
, 0, &tid
);
9412 wait_for_thread( thread
);
9413 CloseHandle( thread
);
9416 ok( info
.ret
== 1, "SendMessageTimeout failed\n" );
9417 ok_sequence( WmUser
, "WmUser", FALSE
);
9421 ok( info
.ret
== 0, "SendMessageTimeout succeeded\n" );
9422 ok_sequence( WmEmptySeq
, "WmEmptySeq", FALSE
);
9425 /* now check for timeout during message processing */
9426 SetWindowLongPtrA( info
.hwnd
, GWLP_WNDPROC
, (LONG_PTR
)send_msg_delay_proc
);
9428 info
.ret
= 0xdeadbeef;
9429 thread
= CreateThread( NULL
, 0, send_msg_thread
, &info
, 0, &tid
);
9430 wait_for_thread( thread
);
9431 CloseHandle( thread
);
9432 /* we should time out but still get the message */
9433 ok( info
.ret
== 0, "SendMessageTimeout failed\n" );
9434 ok_sequence( WmUser
, "WmUser", FALSE
);
9436 DestroyWindow( info
.hwnd
);
9440 /****************** edit message test *************************/
9441 #define ID_EDIT 0x1234
9442 static const struct message sl_edit_setfocus
[] =
9444 { HCBT_SETFOCUS
, hook
},
9445 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
9446 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
9447 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
9448 { WM_SETFOCUS
, sent
|wparam
, 0 },
9449 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 10 },
9450 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 15 },
9451 { WM_CTLCOLOREDIT
, sent
|parent
},
9452 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 11 },
9453 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
9454 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
9455 { WM_COMMAND
, sent
|parent
|wparam
, MAKEWPARAM(ID_EDIT
, EN_SETFOCUS
) },
9458 static const struct message sl_edit_invisible
[] =
9460 { HCBT_SETFOCUS
, hook
},
9461 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
9462 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
9463 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
9464 { WM_KILLFOCUS
, sent
|parent
},
9465 { WM_SETFOCUS
, sent
},
9466 { WM_COMMAND
, sent
|parent
|wparam
, MAKEWPARAM(ID_EDIT
, EN_SETFOCUS
) },
9469 static const struct message ml_edit_setfocus
[] =
9471 { HCBT_SETFOCUS
, hook
},
9472 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
9473 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
9474 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
9475 { WM_SETFOCUS
, sent
|wparam
, 0 },
9476 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 10 },
9477 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 11 },
9478 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
9479 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
9480 { WM_COMMAND
, sent
|parent
|wparam
, MAKEWPARAM(ID_EDIT
, EN_SETFOCUS
) },
9483 static const struct message sl_edit_killfocus
[] =
9485 { HCBT_SETFOCUS
, hook
},
9486 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
9487 { WM_KILLFOCUS
, sent
|wparam
, 0 },
9488 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
9489 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
9490 { WM_COMMAND
, sent
|parent
|wparam
, MAKEWPARAM(ID_EDIT
, EN_KILLFOCUS
) },
9491 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
9492 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 1 },
9495 static const struct message sl_edit_lbutton_dblclk
[] =
9497 { WM_LBUTTONDBLCLK
, sent
},
9498 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
9501 static const struct message sl_edit_lbutton_down
[] =
9503 { WM_LBUTTONDOWN
, sent
|wparam
|lparam
, 0, 0 },
9504 { HCBT_SETFOCUS
, hook
},
9505 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
9506 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
9507 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
9508 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
9509 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 10 },
9510 { WM_CTLCOLOREDIT
, sent
|parent
},
9511 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 11 },
9512 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
9513 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
9514 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
9515 { WM_COMMAND
, sent
|parent
|wparam
, MAKEWPARAM(ID_EDIT
, EN_SETFOCUS
) },
9516 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
9517 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
9518 { WM_CTLCOLOREDIT
, sent
|parent
|optional
},
9519 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 11 },
9520 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
9521 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
9524 static const struct message ml_edit_lbutton_down
[] =
9526 { WM_LBUTTONDOWN
, sent
|wparam
|lparam
, 0, 0 },
9527 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
9528 { HCBT_SETFOCUS
, hook
},
9529 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
9530 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
9531 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
9532 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
9533 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 10 },
9534 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 11 },
9535 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
9536 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
9537 { WM_COMMAND
, sent
|parent
|wparam
, MAKEWPARAM(ID_EDIT
, EN_SETFOCUS
) },
9540 static const struct message sl_edit_lbutton_up
[] =
9542 { WM_LBUTTONUP
, sent
|wparam
|lparam
, 0, 0 },
9543 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
9544 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, 0, 0 },
9545 { WM_CAPTURECHANGED
, sent
|defwinproc
},
9546 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
9549 static const struct message ml_edit_lbutton_up
[] =
9551 { WM_LBUTTONUP
, sent
|wparam
|lparam
, 0, 0 },
9552 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, 0, 0 },
9553 { WM_CAPTURECHANGED
, sent
|defwinproc
},
9557 static WNDPROC old_edit_proc
;
9559 static LRESULT CALLBACK
edit_hook_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
9561 static LONG defwndproc_counter
= 0;
9563 struct recvd_message msg
;
9565 if (ignore_message( message
)) return 0;
9568 msg
.message
= message
;
9569 msg
.flags
= sent
|wparam
|lparam
;
9570 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
9571 msg
.wParam
= wParam
;
9572 msg
.lParam
= lParam
;
9576 defwndproc_counter
++;
9577 ret
= CallWindowProcA(old_edit_proc
, hwnd
, message
, wParam
, lParam
);
9578 defwndproc_counter
--;
9583 static void subclass_edit(void)
9587 if (!GetClassInfoA(0, "edit", &cls
)) assert(0);
9589 old_edit_proc
= cls
.lpfnWndProc
;
9591 cls
.hInstance
= GetModuleHandleA(NULL
);
9592 cls
.lpfnWndProc
= edit_hook_proc
;
9593 cls
.lpszClassName
= "my_edit_class";
9594 UnregisterClassA(cls
.lpszClassName
, cls
.hInstance
);
9595 if (!RegisterClassA(&cls
)) assert(0);
9598 static void test_edit_messages(void)
9604 log_all_parent_messages
++;
9606 parent
= CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
9607 100, 100, 200, 200, 0, 0, 0, NULL
);
9608 ok (parent
!= 0, "Failed to create parent window\n");
9610 /* test single line edit */
9611 hwnd
= CreateWindowExA(0, "my_edit_class", "test", WS_CHILD
,
9612 0, 0, 80, 20, parent
, (HMENU
)ID_EDIT
, 0, NULL
);
9613 ok(hwnd
!= 0, "Failed to create edit window\n");
9615 dlg_code
= SendMessageA(hwnd
, WM_GETDLGCODE
, 0, 0);
9616 ok(dlg_code
== (DLGC_WANTCHARS
|DLGC_HASSETSEL
|DLGC_WANTARROWS
), "wrong dlg_code %08x\n", dlg_code
);
9620 ok_sequence(sl_edit_invisible
, "SetFocus(hwnd) on an invisible edit", FALSE
);
9622 ShowWindow(hwnd
, SW_SHOW
);
9628 ok_sequence(sl_edit_setfocus
, "SetFocus(hwnd) on an edit", FALSE
);
9631 ok_sequence(sl_edit_killfocus
, "SetFocus(0) on an edit", FALSE
);
9637 SendMessageA(hwnd
, WM_LBUTTONDBLCLK
, 0, 0);
9638 ok_sequence(sl_edit_lbutton_dblclk
, "WM_LBUTTONDBLCLK on an edit", FALSE
);
9644 SendMessageA(hwnd
, WM_LBUTTONDOWN
, 0, 0);
9645 ok_sequence(sl_edit_lbutton_down
, "WM_LBUTTONDOWN on an edit", FALSE
);
9647 SendMessageA(hwnd
, WM_LBUTTONUP
, 0, 0);
9648 ok_sequence(sl_edit_lbutton_up
, "WM_LBUTTONUP on an edit", FALSE
);
9650 DestroyWindow(hwnd
);
9652 /* test multiline edit */
9653 hwnd
= CreateWindowExA(0, "my_edit_class", "test", WS_CHILD
| ES_MULTILINE
,
9654 0, 0, 80, 20, parent
, (HMENU
)ID_EDIT
, 0, NULL
);
9655 ok(hwnd
!= 0, "Failed to create edit window\n");
9657 dlg_code
= SendMessageA(hwnd
, WM_GETDLGCODE
, 0, 0);
9658 ok(dlg_code
== (DLGC_WANTCHARS
|DLGC_HASSETSEL
|DLGC_WANTARROWS
|DLGC_WANTALLKEYS
),
9659 "wrong dlg_code %08x\n", dlg_code
);
9661 ShowWindow(hwnd
, SW_SHOW
);
9667 ok_sequence(ml_edit_setfocus
, "SetFocus(hwnd) on multiline edit", FALSE
);
9670 ok_sequence(sl_edit_killfocus
, "SetFocus(0) on multiline edit", FALSE
);
9676 SendMessageA(hwnd
, WM_LBUTTONDBLCLK
, 0, 0);
9677 ok_sequence(sl_edit_lbutton_dblclk
, "WM_LBUTTONDBLCLK on multiline edit", FALSE
);
9683 SendMessageA(hwnd
, WM_LBUTTONDOWN
, 0, 0);
9684 ok_sequence(ml_edit_lbutton_down
, "WM_LBUTTONDOWN on multiline edit", FALSE
);
9686 SendMessageA(hwnd
, WM_LBUTTONUP
, 0, 0);
9687 ok_sequence(ml_edit_lbutton_up
, "WM_LBUTTONUP on multiline edit", FALSE
);
9689 DestroyWindow(hwnd
);
9690 DestroyWindow(parent
);
9692 log_all_parent_messages
--;
9695 /**************************** End of Edit test ******************************/
9697 static const struct message WmKeyDownSkippedSeq
[] =
9699 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 1 }, /* XP */
9702 static const struct message WmKeyDownWasDownSkippedSeq
[] =
9704 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0x40000001 }, /* XP */
9707 static const struct message WmKeyUpSkippedSeq
[] =
9709 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xc0000001 }, /* XP */
9712 static const struct message WmUserKeyUpSkippedSeq
[] =
9715 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xc0000001 }, /* XP */
9720 #define EV_SENDMSG 1
9726 HANDLE hevent
[3]; /* 0 - start/stop, 1 - SendMessage, 2 - ack */
9729 static DWORD CALLBACK
send_msg_thread_2(void *param
)
9732 struct peekmsg_info
*info
= param
;
9734 trace("thread: looping\n");
9735 SetEvent(info
->hevent
[EV_ACK
]);
9739 ret
= WaitForMultipleObjects(2, info
->hevent
, FALSE
, INFINITE
);
9743 case WAIT_OBJECT_0
+ EV_STOP
:
9744 trace("thread: exiting\n");
9747 case WAIT_OBJECT_0
+ EV_SENDMSG
:
9748 trace("thread: sending message\n");
9749 ret
= SendNotifyMessageA(info
->hwnd
, WM_USER
, 0, 0);
9750 ok(ret
, "SendNotifyMessageA failed error %u\n", GetLastError());
9751 SetEvent(info
->hevent
[EV_ACK
]);
9755 trace("unexpected return: %04x\n", ret
);
9763 static void test_PeekMessage(void)
9768 UINT qs_all_input
= QS_ALLINPUT
;
9769 UINT qs_input
= QS_INPUT
;
9771 struct peekmsg_info info
;
9773 info
.hwnd
= CreateWindowA("TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
9774 100, 100, 200, 200, 0, 0, 0, NULL
);
9776 ShowWindow(info
.hwnd
, SW_SHOW
);
9777 UpdateWindow(info
.hwnd
);
9778 SetFocus(info
.hwnd
);
9780 info
.hevent
[EV_STOP
] = CreateEventA(NULL
, 0, 0, NULL
);
9781 info
.hevent
[EV_SENDMSG
] = CreateEventA(NULL
, 0, 0, NULL
);
9782 info
.hevent
[EV_ACK
] = CreateEventA(NULL
, 0, 0, NULL
);
9784 hthread
= CreateThread(NULL
, 0, send_msg_thread_2
, &info
, 0, &tid
);
9785 WaitForSingleObject(info
.hevent
[EV_ACK
], 10000);
9790 SetLastError(0xdeadbeef);
9791 qstatus
= GetQueueStatus(qs_all_input
);
9792 if (GetLastError() == ERROR_INVALID_FLAGS
)
9794 trace("QS_RAWINPUT not supported on this platform\n");
9795 qs_all_input
&= ~QS_RAWINPUT
;
9796 qs_input
&= ~QS_RAWINPUT
;
9798 if (qstatus
& QS_POSTMESSAGE
)
9800 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) /* nothing */ ;
9801 qstatus
= GetQueueStatus(qs_all_input
);
9803 ok(qstatus
== 0, "wrong qstatus %08x\n", qstatus
);
9805 trace("signalling to send message\n");
9806 SetEvent(info
.hevent
[EV_SENDMSG
]);
9807 WaitForSingleObject(info
.hevent
[EV_ACK
], INFINITE
);
9809 /* pass invalid QS_xxxx flags */
9810 SetLastError(0xdeadbeef);
9811 qstatus
= GetQueueStatus(0xffffffff);
9812 ok(qstatus
== 0 || broken(qstatus
) /* win9x */, "GetQueueStatus should fail: %08x\n", qstatus
);
9815 ok(GetLastError() == ERROR_INVALID_FLAGS
, "wrong error %d\n", GetLastError());
9816 qstatus
= GetQueueStatus(qs_all_input
);
9818 qstatus
&= ~MAKELONG( 0x4000, 0x4000 ); /* sometimes set on Win95 */
9819 ok(qstatus
== MAKELONG(QS_SENDMESSAGE
, QS_SENDMESSAGE
),
9820 "wrong qstatus %08x\n", qstatus
);
9823 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
9825 "PeekMessageA should have returned FALSE instead of msg %04x\n",
9827 ok_sequence(WmUser
, "WmUser", FALSE
);
9829 qstatus
= GetQueueStatus(qs_all_input
);
9830 ok(qstatus
== 0, "wrong qstatus %08x\n", qstatus
);
9832 keybd_event('N', 0, 0, 0);
9833 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
9834 qstatus
= GetQueueStatus(qs_all_input
);
9835 if (!(qstatus
& MAKELONG(QS_KEY
, QS_KEY
)))
9837 skip( "queuing key events not supported\n" );
9840 ok(qstatus
== MAKELONG(QS_KEY
, QS_KEY
) ||
9841 /* keybd_event seems to trigger a sent message on NT4 */
9842 qstatus
== MAKELONG(QS_KEY
|QS_SENDMESSAGE
, QS_KEY
|QS_SENDMESSAGE
),
9843 "wrong qstatus %08x\n", qstatus
);
9845 PostMessageA(info
.hwnd
, WM_CHAR
, 'z', 0);
9846 qstatus
= GetQueueStatus(qs_all_input
);
9847 ok(qstatus
== MAKELONG(QS_POSTMESSAGE
, QS_POSTMESSAGE
|QS_KEY
) ||
9848 qstatus
== MAKELONG(QS_POSTMESSAGE
, QS_POSTMESSAGE
|QS_KEY
|QS_SENDMESSAGE
),
9849 "wrong qstatus %08x\n", qstatus
);
9851 InvalidateRect(info
.hwnd
, NULL
, FALSE
);
9852 qstatus
= GetQueueStatus(qs_all_input
);
9853 ok(qstatus
== MAKELONG(QS_PAINT
, QS_PAINT
|QS_POSTMESSAGE
|QS_KEY
) ||
9854 qstatus
== MAKELONG(QS_PAINT
, QS_PAINT
|QS_POSTMESSAGE
|QS_KEY
|QS_SENDMESSAGE
),
9855 "wrong qstatus %08x\n", qstatus
);
9857 trace("signalling to send message\n");
9858 SetEvent(info
.hevent
[EV_SENDMSG
]);
9859 WaitForSingleObject(info
.hevent
[EV_ACK
], INFINITE
);
9861 qstatus
= GetQueueStatus(qs_all_input
);
9862 ok(qstatus
== MAKELONG(QS_SENDMESSAGE
, QS_SENDMESSAGE
|QS_PAINT
|QS_POSTMESSAGE
|QS_KEY
),
9863 "wrong qstatus %08x\n", qstatus
);
9866 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| (qs_input
<< 16));
9867 if (ret
&& msg
.message
== WM_CHAR
)
9869 win_skip( "PM_QS_* flags not supported in PeekMessage\n" );
9873 "PeekMessageA should have returned FALSE instead of msg %04x\n",
9875 if (!sequence_cnt
) /* nt4 doesn't fetch anything with PM_QS_* flags */
9877 win_skip( "PM_QS_* flags not supported in PeekMessage\n" );
9880 ok_sequence(WmUser
, "WmUser", FALSE
);
9882 qstatus
= GetQueueStatus(qs_all_input
);
9883 ok(qstatus
== MAKELONG(0, QS_PAINT
|QS_POSTMESSAGE
|QS_KEY
),
9884 "wrong qstatus %08x\n", qstatus
);
9886 trace("signalling to send message\n");
9887 SetEvent(info
.hevent
[EV_SENDMSG
]);
9888 WaitForSingleObject(info
.hevent
[EV_ACK
], INFINITE
);
9890 qstatus
= GetQueueStatus(qs_all_input
);
9891 ok(qstatus
== MAKELONG(QS_SENDMESSAGE
, QS_SENDMESSAGE
|QS_PAINT
|QS_POSTMESSAGE
|QS_KEY
),
9892 "wrong qstatus %08x\n", qstatus
);
9895 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| PM_QS_POSTMESSAGE
);
9897 "PeekMessageA should have returned FALSE instead of msg %04x\n",
9899 ok_sequence(WmUser
, "WmUser", FALSE
);
9901 qstatus
= GetQueueStatus(qs_all_input
);
9902 ok(qstatus
== MAKELONG(0, QS_PAINT
|QS_POSTMESSAGE
|QS_KEY
),
9903 "wrong qstatus %08x\n", qstatus
);
9906 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| PM_QS_POSTMESSAGE
);
9907 ok(ret
&& msg
.message
== WM_CHAR
&& msg
.wParam
== 'z',
9908 "got %d and %04x wParam %08lx instead of TRUE and WM_CHAR wParam 'z'\n",
9909 ret
, msg
.message
, msg
.wParam
);
9910 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
9912 qstatus
= GetQueueStatus(qs_all_input
);
9913 ok(qstatus
== MAKELONG(0, QS_PAINT
|QS_KEY
),
9914 "wrong qstatus %08x\n", qstatus
);
9917 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| PM_QS_POSTMESSAGE
);
9919 "PeekMessageA should have returned FALSE instead of msg %04x\n",
9921 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
9923 qstatus
= GetQueueStatus(qs_all_input
);
9924 ok(qstatus
== MAKELONG(0, QS_PAINT
|QS_KEY
),
9925 "wrong qstatus %08x\n", qstatus
);
9928 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| PM_QS_PAINT
);
9929 ok(ret
&& msg
.message
== WM_PAINT
,
9930 "got %d and %04x instead of TRUE and WM_PAINT\n", ret
, msg
.message
);
9931 DispatchMessageA(&msg
);
9932 ok_sequence(WmPaint
, "WmPaint", FALSE
);
9934 qstatus
= GetQueueStatus(qs_all_input
);
9935 ok(qstatus
== MAKELONG(0, QS_KEY
),
9936 "wrong qstatus %08x\n", qstatus
);
9939 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| PM_QS_PAINT
);
9941 "PeekMessageA should have returned FALSE instead of msg %04x\n",
9943 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
9945 qstatus
= GetQueueStatus(qs_all_input
);
9946 ok(qstatus
== MAKELONG(0, QS_KEY
),
9947 "wrong qstatus %08x\n", qstatus
);
9949 trace("signalling to send message\n");
9950 SetEvent(info
.hevent
[EV_SENDMSG
]);
9951 WaitForSingleObject(info
.hevent
[EV_ACK
], INFINITE
);
9953 qstatus
= GetQueueStatus(qs_all_input
);
9954 ok(qstatus
== MAKELONG(QS_SENDMESSAGE
, QS_SENDMESSAGE
|QS_KEY
),
9955 "wrong qstatus %08x\n", qstatus
);
9957 PostMessageA(info
.hwnd
, WM_CHAR
, 'z', 0);
9959 qstatus
= GetQueueStatus(qs_all_input
);
9960 ok(qstatus
== MAKELONG(QS_POSTMESSAGE
, QS_SENDMESSAGE
|QS_POSTMESSAGE
|QS_KEY
),
9961 "wrong qstatus %08x\n", qstatus
);
9964 ret
= PeekMessageA(&msg
, 0, WM_CHAR
, WM_CHAR
, PM_REMOVE
);
9965 ok(ret
&& msg
.message
== WM_CHAR
&& msg
.wParam
== 'z',
9966 "got %d and %04x wParam %08lx instead of TRUE and WM_CHAR wParam 'z'\n",
9967 ret
, msg
.message
, msg
.wParam
);
9968 ok_sequence(WmUser
, "WmUser", FALSE
);
9970 qstatus
= GetQueueStatus(qs_all_input
);
9971 ok(qstatus
== MAKELONG(0, QS_KEY
),
9972 "wrong qstatus %08x\n", qstatus
);
9975 ret
= PeekMessageA(&msg
, 0, WM_CHAR
, WM_CHAR
, PM_REMOVE
);
9977 "PeekMessageA should have returned FALSE instead of msg %04x\n",
9979 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
9981 qstatus
= GetQueueStatus(qs_all_input
);
9982 ok(qstatus
== MAKELONG(0, QS_KEY
),
9983 "wrong qstatus %08x\n", qstatus
);
9985 PostMessageA(info
.hwnd
, WM_CHAR
, 'z', 0);
9987 qstatus
= GetQueueStatus(qs_all_input
);
9988 ok(qstatus
== MAKELONG(QS_POSTMESSAGE
, QS_POSTMESSAGE
|QS_KEY
),
9989 "wrong qstatus %08x\n", qstatus
);
9991 trace("signalling to send message\n");
9992 SetEvent(info
.hevent
[EV_SENDMSG
]);
9993 WaitForSingleObject(info
.hevent
[EV_ACK
], INFINITE
);
9995 qstatus
= GetQueueStatus(qs_all_input
);
9996 ok(qstatus
== MAKELONG(QS_SENDMESSAGE
, QS_SENDMESSAGE
|QS_POSTMESSAGE
|QS_KEY
),
9997 "wrong qstatus %08x\n", qstatus
);
10000 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| (QS_KEY
<< 16));
10002 "PeekMessageA should have returned FALSE instead of msg %04x\n",
10004 ok_sequence(WmUser
, "WmUser", FALSE
);
10006 qstatus
= GetQueueStatus(qs_all_input
);
10007 ok(qstatus
== MAKELONG(0, QS_POSTMESSAGE
|QS_KEY
),
10008 "wrong qstatus %08x\n", qstatus
);
10011 if (qs_all_input
& QS_RAWINPUT
) /* use QS_RAWINPUT only if supported */
10012 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| (QS_RAWINPUT
<< 16));
10013 else /* workaround for a missing QS_RAWINPUT support */
10014 ret
= PeekMessageA(&msg
, 0, WM_KEYDOWN
, WM_KEYDOWN
, PM_REMOVE
);
10015 ok(ret
&& msg
.message
== WM_KEYDOWN
&& msg
.wParam
== 'N',
10016 "got %d and %04x wParam %08lx instead of TRUE and WM_KEYDOWN wParam 'N'\n",
10017 ret
, msg
.message
, msg
.wParam
);
10018 ok_sequence(WmKeyDownSkippedSeq
, "WmKeyDownSkippedSeq", FALSE
);
10020 qstatus
= GetQueueStatus(qs_all_input
);
10021 ok(qstatus
== MAKELONG(0, QS_POSTMESSAGE
|QS_KEY
),
10022 "wrong qstatus %08x\n", qstatus
);
10025 if (qs_all_input
& QS_RAWINPUT
) /* use QS_RAWINPUT only if supported */
10026 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| (QS_RAWINPUT
<< 16));
10027 else /* workaround for a missing QS_RAWINPUT support */
10028 ret
= PeekMessageA(&msg
, 0, WM_KEYUP
, WM_KEYUP
, PM_REMOVE
);
10029 ok(ret
&& msg
.message
== WM_KEYUP
&& msg
.wParam
== 'N',
10030 "got %d and %04x wParam %08lx instead of TRUE and WM_KEYUP wParam 'N'\n",
10031 ret
, msg
.message
, msg
.wParam
);
10032 ok_sequence(WmKeyUpSkippedSeq
, "WmKeyUpSkippedSeq", FALSE
);
10034 qstatus
= GetQueueStatus(qs_all_input
);
10035 ok(qstatus
== MAKELONG(0, QS_POSTMESSAGE
),
10036 "wrong qstatus %08x\n", qstatus
);
10039 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| PM_QS_SENDMESSAGE
);
10041 "PeekMessageA should have returned FALSE instead of msg %04x\n",
10043 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
10045 qstatus
= GetQueueStatus(qs_all_input
);
10046 ok(qstatus
== MAKELONG(0, QS_POSTMESSAGE
),
10047 "wrong qstatus %08x\n", qstatus
);
10050 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
10051 ok(ret
&& msg
.message
== WM_CHAR
&& msg
.wParam
== 'z',
10052 "got %d and %04x wParam %08lx instead of TRUE and WM_CHAR wParam 'z'\n",
10053 ret
, msg
.message
, msg
.wParam
);
10054 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
10056 qstatus
= GetQueueStatus(qs_all_input
);
10058 "wrong qstatus %08x\n", qstatus
);
10061 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
10063 "PeekMessageA should have returned FALSE instead of msg %04x\n",
10065 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
10067 qstatus
= GetQueueStatus(qs_all_input
);
10069 "wrong qstatus %08x\n", qstatus
);
10071 /* test whether presence of the quit flag in the queue affects
10074 PostQuitMessage(0x1234abcd);
10076 qstatus
= GetQueueStatus(qs_all_input
);
10077 ok(qstatus
== MAKELONG(QS_POSTMESSAGE
, QS_POSTMESSAGE
),
10078 "wrong qstatus %08x\n", qstatus
);
10080 PostMessageA(info
.hwnd
, WM_USER
, 0, 0);
10082 qstatus
= GetQueueStatus(qs_all_input
);
10083 ok(qstatus
== MAKELONG(QS_POSTMESSAGE
, QS_POSTMESSAGE
),
10084 "wrong qstatus %08x\n", qstatus
);
10087 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
10088 ok(ret
&& msg
.message
== WM_USER
,
10089 "got %d and %04x instead of TRUE and WM_USER\n", ret
, msg
.message
);
10090 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
10092 qstatus
= GetQueueStatus(qs_all_input
);
10093 ok(qstatus
== MAKELONG(0, QS_POSTMESSAGE
),
10094 "wrong qstatus %08x\n", qstatus
);
10097 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
10098 ok(ret
&& msg
.message
== WM_QUIT
,
10099 "got %d and %04x instead of TRUE and WM_QUIT\n", ret
, msg
.message
);
10100 ok(msg
.wParam
== 0x1234abcd, "got wParam %08lx instead of 0x1234abcd\n", msg
.wParam
);
10101 ok(msg
.lParam
== 0, "got lParam %08lx instead of 0\n", msg
.lParam
);
10102 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
10104 qstatus
= GetQueueStatus(qs_all_input
);
10106 ok(qstatus
== MAKELONG(0, QS_POSTMESSAGE
),
10107 "wrong qstatus %08x\n", qstatus
);
10111 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
10113 "PeekMessageA should have returned FALSE instead of msg %04x\n",
10115 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
10117 qstatus
= GetQueueStatus(qs_all_input
);
10119 "wrong qstatus %08x\n", qstatus
);
10121 /* some GetMessage tests */
10123 keybd_event('N', 0, 0, 0);
10124 qstatus
= GetQueueStatus(qs_all_input
);
10125 ok(qstatus
== MAKELONG(QS_KEY
, QS_KEY
), "wrong qstatus %08x\n", qstatus
);
10127 PostMessageA(info
.hwnd
, WM_CHAR
, 'z', 0);
10128 qstatus
= GetQueueStatus(qs_all_input
);
10129 ok(qstatus
== MAKELONG(QS_POSTMESSAGE
, QS_POSTMESSAGE
|QS_KEY
), "wrong qstatus %08x\n", qstatus
);
10133 ret
= GetMessageA( &msg
, 0, 0, 0 );
10134 ok(ret
&& msg
.message
== WM_CHAR
&& msg
.wParam
== 'z',
10135 "got %d and %04x wParam %08lx instead of TRUE and WM_CHAR wParam 'z'\n",
10136 ret
, msg
.message
, msg
.wParam
);
10137 qstatus
= GetQueueStatus(qs_all_input
);
10138 ok(qstatus
== MAKELONG(0, QS_KEY
), "wrong qstatus %08x\n", qstatus
);
10143 ret
= GetMessageA( &msg
, 0, 0, 0 );
10144 ok(ret
&& msg
.message
== WM_KEYDOWN
&& msg
.wParam
== 'N',
10145 "got %d and %04x wParam %08lx instead of TRUE and WM_KEYDOWN wParam 'N'\n",
10146 ret
, msg
.message
, msg
.wParam
);
10147 ok_sequence(WmKeyDownSkippedSeq
, "WmKeyDownSkippedSeq", FALSE
);
10148 qstatus
= GetQueueStatus(qs_all_input
);
10149 ok(qstatus
== 0, "wrong qstatus %08x\n", qstatus
);
10152 keybd_event('N', 0, 0, 0);
10153 qstatus
= GetQueueStatus(qs_all_input
);
10154 ok(qstatus
== MAKELONG(QS_KEY
, QS_KEY
), "wrong qstatus %08x\n", qstatus
);
10156 PostMessageA(info
.hwnd
, WM_CHAR
, 'z', 0);
10157 qstatus
= GetQueueStatus(qs_all_input
);
10158 ok(qstatus
== MAKELONG(QS_POSTMESSAGE
, QS_POSTMESSAGE
|QS_KEY
), "wrong qstatus %08x\n", qstatus
);
10160 if (qstatus
& (QS_KEY
<< 16))
10162 ret
= GetMessageA( &msg
, 0, WM_KEYDOWN
, WM_KEYUP
);
10163 ok(ret
&& msg
.message
== WM_KEYDOWN
&& msg
.wParam
== 'N',
10164 "got %d and %04x wParam %08lx instead of TRUE and WM_KEYDOWN wParam 'N'\n",
10165 ret
, msg
.message
, msg
.wParam
);
10166 ok_sequence(WmKeyDownWasDownSkippedSeq
, "WmKeyDownWasDownSkippedSeq", FALSE
);
10167 qstatus
= GetQueueStatus(qs_all_input
);
10168 ok(qstatus
== MAKELONG(0, QS_POSTMESSAGE
), "wrong qstatus %08x\n", qstatus
);
10173 ret
= GetMessageA( &msg
, 0, WM_CHAR
, WM_CHAR
);
10174 ok(ret
&& msg
.message
== WM_CHAR
&& msg
.wParam
== 'z',
10175 "got %d and %04x wParam %08lx instead of TRUE and WM_CHAR wParam 'z'\n",
10176 ret
, msg
.message
, msg
.wParam
);
10177 qstatus
= GetQueueStatus(qs_all_input
);
10178 ok(qstatus
== 0, "wrong qstatus %08x\n", qstatus
);
10181 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
10182 qstatus
= GetQueueStatus(qs_all_input
);
10183 ok(qstatus
== MAKELONG(QS_KEY
, QS_KEY
), "wrong qstatus %08x\n", qstatus
);
10185 PostMessageA(info
.hwnd
, WM_CHAR
, 'z', 0);
10186 qstatus
= GetQueueStatus(qs_all_input
);
10187 ok(qstatus
== MAKELONG(QS_POSTMESSAGE
, QS_POSTMESSAGE
|QS_KEY
), "wrong qstatus %08x\n", qstatus
);
10189 trace("signalling to send message\n");
10190 SetEvent(info
.hevent
[EV_SENDMSG
]);
10191 WaitForSingleObject(info
.hevent
[EV_ACK
], INFINITE
);
10192 qstatus
= GetQueueStatus(qs_all_input
);
10193 ok(qstatus
== MAKELONG(QS_SENDMESSAGE
, QS_SENDMESSAGE
|QS_POSTMESSAGE
|QS_KEY
),
10194 "wrong qstatus %08x\n", qstatus
);
10196 if (qstatus
& (QS_KEY
<< 16))
10198 ret
= GetMessageA( &msg
, 0, WM_KEYDOWN
, WM_KEYUP
);
10199 ok(ret
&& msg
.message
== WM_KEYUP
&& msg
.wParam
== 'N',
10200 "got %d and %04x wParam %08lx instead of TRUE and WM_KEYDOWN wParam 'N'\n",
10201 ret
, msg
.message
, msg
.wParam
);
10202 ok_sequence(WmUserKeyUpSkippedSeq
, "WmUserKeyUpSkippedSeq", FALSE
);
10203 qstatus
= GetQueueStatus(qs_all_input
);
10204 ok(qstatus
== MAKELONG(0, QS_POSTMESSAGE
), "wrong qstatus %08x\n", qstatus
);
10209 ret
= GetMessageA( &msg
, 0, WM_CHAR
, WM_CHAR
);
10210 ok(ret
&& msg
.message
== WM_CHAR
&& msg
.wParam
== 'z',
10211 "got %d and %04x wParam %08lx instead of TRUE and WM_CHAR wParam 'z'\n",
10212 ret
, msg
.message
, msg
.wParam
);
10213 qstatus
= GetQueueStatus(qs_all_input
);
10214 ok(qstatus
== 0, "wrong qstatus %08x\n", qstatus
);
10217 trace("signalling to exit\n");
10218 SetEvent(info
.hevent
[EV_STOP
]);
10220 WaitForSingleObject(hthread
, INFINITE
);
10222 CloseHandle(hthread
);
10223 CloseHandle(info
.hevent
[0]);
10224 CloseHandle(info
.hevent
[1]);
10225 CloseHandle(info
.hevent
[2]);
10227 DestroyWindow(info
.hwnd
);
10230 static void wait_move_event(HWND hwnd
, int x
, int y
)
10234 BOOL ret
, go
= FALSE
;
10236 time
= GetTickCount();
10237 while (GetTickCount() - time
< 200 && !go
) {
10238 ret
= PeekMessageA(&msg
, hwnd
, WM_MOUSEMOVE
, WM_MOUSEMOVE
, PM_NOREMOVE
);
10239 go
= ret
&& msg
.pt
.x
> x
&& msg
.pt
.y
> y
;
10240 if (!ret
) MsgWaitForMultipleObjects( 0, NULL
, FALSE
, GetTickCount() - time
, QS_ALLINPUT
);
10245 static void test_PeekMessage2(void)
10251 DWORD time1
, time2
, time3
;
10252 int x1
, y1
, x2
, y2
, x3
, y3
;
10255 time1
= time2
= time3
= 0;
10256 x1
= y1
= x2
= y2
= x3
= y3
= 0;
10258 /* Initialise window and make sure it is ready for events */
10259 hwnd
= CreateWindowA("TestWindowClass", "PeekMessage2", WS_OVERLAPPEDWINDOW
,
10260 10, 10, 800, 800, NULL
, NULL
, NULL
, NULL
);
10262 trace("Window for test_PeekMessage2 %p\n", hwnd
);
10263 ShowWindow(hwnd
, SW_SHOW
);
10264 UpdateWindow(hwnd
);
10266 GetCursorPos(&pos
);
10267 SetCursorPos(100, 100);
10268 mouse_event(MOUSEEVENTF_MOVE
, -STEP
, -STEP
, 0, 0);
10271 /* Do initial mousemove, wait until we can see it
10272 and then do our test peek with PM_NOREMOVE. */
10273 mouse_event(MOUSEEVENTF_MOVE
, STEP
, STEP
, 0, 0);
10274 wait_move_event(hwnd
, 100-STEP
, 100-STEP
);
10276 ret
= PeekMessageA(&msg
, hwnd
, WM_MOUSEMOVE
, WM_MOUSEMOVE
, PM_NOREMOVE
);
10279 skip( "queuing mouse events not supported\n" );
10284 trace("1st move event: %04x %x %d %d\n", msg
.message
, msg
.time
, msg
.pt
.x
, msg
.pt
.y
);
10285 message
= msg
.message
;
10289 ok(message
== WM_MOUSEMOVE
, "message not WM_MOUSEMOVE, %04x instead\n", message
);
10292 /* Allow time to advance a bit, and then simulate the user moving their
10293 * mouse around. After that we peek again with PM_NOREMOVE.
10294 * Although the previous mousemove message was never removed, the
10295 * mousemove we now peek should reflect the recent mouse movements
10296 * because the input queue will merge the move events. */
10298 mouse_event(MOUSEEVENTF_MOVE
, STEP
, STEP
, 0, 0);
10299 wait_move_event(hwnd
, x1
, y1
);
10301 ret
= PeekMessageA(&msg
, hwnd
, WM_MOUSEMOVE
, WM_MOUSEMOVE
, PM_NOREMOVE
);
10302 ok(ret
, "no message available\n");
10304 trace("2nd move event: %04x %x %d %d\n", msg
.message
, msg
.time
, msg
.pt
.x
, msg
.pt
.y
);
10305 message
= msg
.message
;
10309 ok(message
== WM_MOUSEMOVE
, "message not WM_MOUSEMOVE, %04x instead\n", message
);
10310 ok(time2
> time1
, "message time not advanced: %x %x\n", time1
, time2
);
10311 ok(x2
!= x1
&& y2
!= y1
, "coords not changed: (%d %d) (%d %d)\n", x1
, y1
, x2
, y2
);
10314 /* Have another go, to drive the point home */
10316 mouse_event(MOUSEEVENTF_MOVE
, STEP
, STEP
, 0, 0);
10317 wait_move_event(hwnd
, x2
, y2
);
10319 ret
= PeekMessageA(&msg
, hwnd
, WM_MOUSEMOVE
, WM_MOUSEMOVE
, PM_NOREMOVE
);
10320 ok(ret
, "no message available\n");
10322 trace("3rd move event: %04x %x %d %d\n", msg
.message
, msg
.time
, msg
.pt
.x
, msg
.pt
.y
);
10323 message
= msg
.message
;
10327 ok(message
== WM_MOUSEMOVE
, "message not WM_MOUSEMOVE, %04x instead\n", message
);
10328 ok(time3
> time2
, "message time not advanced: %x %x\n", time2
, time3
);
10329 ok(x3
!= x2
&& y3
!= y2
, "coords not changed: (%d %d) (%d %d)\n", x2
, y2
, x3
, y3
);
10333 DestroyWindow(hwnd
);
10334 SetCursorPos(pos
.x
, pos
.y
);
10338 static INT_PTR CALLBACK
wm_quit_dlg_proc(HWND hwnd
, UINT message
, WPARAM wp
, LPARAM lp
)
10340 struct recvd_message msg
;
10342 if (ignore_message( message
)) return 0;
10345 msg
.message
= message
;
10346 msg
.flags
= sent
|wparam
|lparam
;
10349 msg
.descr
= "dialog";
10354 case WM_INITDIALOG
:
10355 PostMessageA(hwnd
, WM_QUIT
, 0x1234, 0x5678);
10356 PostMessageA(hwnd
, WM_USER
, 0xdead, 0xbeef);
10359 case WM_GETDLGCODE
:
10363 EndDialog(hwnd
, 0);
10370 static const struct message WmQuitDialogSeq
[] = {
10371 { HCBT_CREATEWND
, hook
},
10372 { WM_SETFONT
, sent
},
10373 { WM_INITDIALOG
, sent
},
10374 { WM_CHANGEUISTATE
, sent
|optional
},
10375 { HCBT_DESTROYWND
, hook
},
10376 { 0x0090, sent
|optional
}, /* Vista */
10377 { WM_DESTROY
, sent
},
10378 { WM_NCDESTROY
, sent
},
10382 static const struct message WmStopQuitSeq
[] = {
10383 { WM_DWMNCRENDERINGCHANGED
, posted
|optional
},
10384 { WM_CLOSE
, posted
},
10385 { WM_QUIT
, posted
|wparam
|lparam
, 0x1234, 0 },
10389 static void test_quit_message(void)
10394 /* test using PostQuitMessage */
10396 PostQuitMessage(0xbeef);
10398 ret
= PeekMessageA(&msg
, NULL
, 0, 0, PM_NOREMOVE
);
10399 ok(ret
, "PeekMessage failed with error %d\n", GetLastError());
10400 ok(msg
.message
== WM_QUIT
, "Received message 0x%04x instead of WM_QUIT\n", msg
.message
);
10401 ok(msg
.wParam
== 0xbeef, "wParam was 0x%lx instead of 0xbeef\n", msg
.wParam
);
10403 ret
= PostThreadMessageA(GetCurrentThreadId(), WM_USER
, 0, 0);
10404 ok(ret
, "PostMessage failed with error %d\n", GetLastError());
10406 ret
= GetMessageA(&msg
, NULL
, 0, 0);
10407 ok(ret
> 0, "GetMessage failed with error %d\n", GetLastError());
10408 ok(msg
.message
== WM_USER
, "Received message 0x%04x instead of WM_USER\n", msg
.message
);
10410 /* note: WM_QUIT message received after WM_USER message */
10411 ret
= GetMessageA(&msg
, NULL
, 0, 0);
10412 ok(!ret
, "GetMessage return %d with error %d instead of FALSE\n", ret
, GetLastError());
10413 ok(msg
.message
== WM_QUIT
, "Received message 0x%04x instead of WM_QUIT\n", msg
.message
);
10414 ok(msg
.wParam
== 0xbeef, "wParam was 0x%lx instead of 0xbeef\n", msg
.wParam
);
10416 ret
= PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
);
10417 ok( !ret
|| msg
.message
!= WM_QUIT
, "Received WM_QUIT again\n" );
10419 /* now test with PostThreadMessage - different behaviour! */
10420 PostThreadMessageA(GetCurrentThreadId(), WM_QUIT
, 0xdead, 0);
10422 ret
= PeekMessageA(&msg
, NULL
, 0, 0, PM_NOREMOVE
);
10423 ok(ret
, "PeekMessage failed with error %d\n", GetLastError());
10424 ok(msg
.message
== WM_QUIT
, "Received message 0x%04x instead of WM_QUIT\n", msg
.message
);
10425 ok(msg
.wParam
== 0xdead, "wParam was 0x%lx instead of 0xdead\n", msg
.wParam
);
10427 ret
= PostThreadMessageA(GetCurrentThreadId(), WM_USER
, 0, 0);
10428 ok(ret
, "PostMessage failed with error %d\n", GetLastError());
10430 /* note: we receive the WM_QUIT message first this time */
10431 ret
= GetMessageA(&msg
, NULL
, 0, 0);
10432 ok(!ret
, "GetMessage return %d with error %d instead of FALSE\n", ret
, GetLastError());
10433 ok(msg
.message
== WM_QUIT
, "Received message 0x%04x instead of WM_QUIT\n", msg
.message
);
10434 ok(msg
.wParam
== 0xdead, "wParam was 0x%lx instead of 0xdead\n", msg
.wParam
);
10436 ret
= GetMessageA(&msg
, NULL
, 0, 0);
10437 ok(ret
> 0, "GetMessage failed with error %d\n", GetLastError());
10438 ok(msg
.message
== WM_USER
, "Received message 0x%04x instead of WM_USER\n", msg
.message
);
10442 ret
= DialogBoxParamA(GetModuleHandleA(NULL
), "TEST_EMPTY_DIALOG", 0, wm_quit_dlg_proc
, 0);
10443 ok(ret
== 1, "expected 1, got %d\n", ret
);
10444 ok_sequence(WmQuitDialogSeq
, "WmQuitDialogSeq", FALSE
);
10445 memset(&msg
, 0xab, sizeof(msg
));
10446 ret
= PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
);
10447 ok(ret
, "PeekMessage failed\n");
10448 ok(msg
.message
== WM_QUIT
, "Received message 0x%04x instead of WM_QUIT\n", msg
.message
);
10449 ok(msg
.wParam
== 0x1234, "wParam was 0x%lx instead of 0x1234\n", msg
.wParam
);
10450 ok(msg
.lParam
== 0, "lParam was 0x%lx instead of 0\n", msg
.lParam
);
10452 /* Check what happens to a WM_QUIT message posted to a window that gets
10455 CreateWindowExA(0, "StopQuitClass", "Stop Quit Test", WS_OVERLAPPEDWINDOW
,
10456 0, 0, 100, 100, NULL
, NULL
, NULL
, NULL
);
10458 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
))
10460 struct recvd_message rmsg
;
10461 rmsg
.hwnd
= msg
.hwnd
;
10462 rmsg
.message
= msg
.message
;
10463 rmsg
.flags
= posted
|wparam
|lparam
;
10464 rmsg
.wParam
= msg
.wParam
;
10465 rmsg
.lParam
= msg
.lParam
;
10466 rmsg
.descr
= "stop/quit";
10467 if (msg
.message
== WM_QUIT
)
10468 /* The hwnd can only be checked here */
10469 ok(!msg
.hwnd
, "The WM_QUIT hwnd was %p instead of NULL\n", msg
.hwnd
);
10470 add_message(&rmsg
);
10471 DispatchMessageA(&msg
);
10473 ok_sequence(WmStopQuitSeq
, "WmStopQuitSeq", FALSE
);
10476 static const struct message WmMouseHoverSeq
[] = {
10477 { WM_MOUSEACTIVATE
, sent
|optional
}, /* we can get those when moving the mouse in focus-follow-mouse mode under X11 */
10478 { WM_MOUSEACTIVATE
, sent
|optional
},
10479 { WM_TIMER
, sent
|optional
}, /* XP sends it */
10480 { WM_SYSTIMER
, sent
},
10481 { WM_MOUSEHOVER
, sent
|wparam
, 0 },
10485 static void pump_msg_loop_timeout(DWORD timeout
, BOOL inject_mouse_move
)
10488 DWORD start_ticks
, end_ticks
;
10490 start_ticks
= GetTickCount();
10491 /* add some deviation (50%) to cover not expected delays */
10492 start_ticks
+= timeout
/ 2;
10496 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
))
10498 /* Timer proc messages are not dispatched to the window proc,
10499 * and therefore not logged.
10501 if ((msg
.message
== WM_TIMER
|| msg
.message
== WM_SYSTIMER
) && msg
.hwnd
)
10503 struct recvd_message s_msg
;
10505 s_msg
.hwnd
= msg
.hwnd
;
10506 s_msg
.message
= msg
.message
;
10507 s_msg
.flags
= sent
|wparam
|lparam
;
10508 s_msg
.wParam
= msg
.wParam
;
10509 s_msg
.lParam
= msg
.lParam
;
10510 s_msg
.descr
= "msg_loop";
10511 add_message(&s_msg
);
10513 DispatchMessageA(&msg
);
10516 end_ticks
= GetTickCount();
10518 /* inject WM_MOUSEMOVE to see how it changes tracking */
10519 if (inject_mouse_move
&& start_ticks
+ timeout
/ 2 >= end_ticks
)
10521 mouse_event(MOUSEEVENTF_MOVE
, -1, 0, 0, 0);
10522 mouse_event(MOUSEEVENTF_MOVE
, 1, 0, 0, 0);
10524 inject_mouse_move
= FALSE
;
10526 } while (start_ticks
+ timeout
>= end_ticks
);
10529 static void test_TrackMouseEvent(void)
10531 TRACKMOUSEEVENT tme
;
10534 RECT rc_parent
, rc_child
;
10535 UINT default_hover_time
, hover_width
= 0, hover_height
= 0;
10537 #define track_hover(track_hwnd, track_hover_time) \
10538 tme.cbSize = sizeof(tme); \
10539 tme.dwFlags = TME_HOVER; \
10540 tme.hwndTrack = track_hwnd; \
10541 tme.dwHoverTime = track_hover_time; \
10542 SetLastError(0xdeadbeef); \
10543 ret = pTrackMouseEvent(&tme); \
10544 ok(ret, "TrackMouseEvent(TME_HOVER) error %d\n", GetLastError())
10546 #define track_query(expected_track_flags, expected_track_hwnd, expected_hover_time) \
10547 tme.cbSize = sizeof(tme); \
10548 tme.dwFlags = TME_QUERY; \
10549 tme.hwndTrack = (HWND)0xdeadbeef; \
10550 tme.dwHoverTime = 0xdeadbeef; \
10551 SetLastError(0xdeadbeef); \
10552 ret = pTrackMouseEvent(&tme); \
10553 ok(ret, "TrackMouseEvent(TME_QUERY) error %d\n", GetLastError());\
10554 ok(tme.cbSize == sizeof(tme), "wrong tme.cbSize %u\n", tme.cbSize); \
10555 ok(tme.dwFlags == (expected_track_flags), \
10556 "wrong tme.dwFlags %08x, expected %08x\n", tme.dwFlags, (expected_track_flags)); \
10557 ok(tme.hwndTrack == (expected_track_hwnd), \
10558 "wrong tme.hwndTrack %p, expected %p\n", tme.hwndTrack, (expected_track_hwnd)); \
10559 ok(tme.dwHoverTime == (expected_hover_time), \
10560 "wrong tme.dwHoverTime %u, expected %u\n", tme.dwHoverTime, (expected_hover_time))
10562 #define track_hover_cancel(track_hwnd) \
10563 tme.cbSize = sizeof(tme); \
10564 tme.dwFlags = TME_HOVER | TME_CANCEL; \
10565 tme.hwndTrack = track_hwnd; \
10566 tme.dwHoverTime = 0xdeadbeef; \
10567 SetLastError(0xdeadbeef); \
10568 ret = pTrackMouseEvent(&tme); \
10569 ok(ret, "TrackMouseEvent(TME_HOVER | TME_CANCEL) error %d\n", GetLastError())
10571 default_hover_time
= 0xdeadbeef;
10572 SetLastError(0xdeadbeef);
10573 ret
= SystemParametersInfoA(SPI_GETMOUSEHOVERTIME
, 0, &default_hover_time
, 0);
10574 ok(ret
|| broken(GetLastError() == 0xdeadbeef), /* win9x */
10575 "SystemParametersInfo(SPI_GETMOUSEHOVERTIME) error %u\n", GetLastError());
10576 if (!ret
) default_hover_time
= 400;
10577 trace("SPI_GETMOUSEHOVERTIME returned %u ms\n", default_hover_time
);
10579 SetLastError(0xdeadbeef);
10580 ret
= SystemParametersInfoA(SPI_GETMOUSEHOVERWIDTH
, 0, &hover_width
, 0);
10581 ok(ret
|| broken(GetLastError() == 0xdeadbeef), /* win9x */
10582 "SystemParametersInfo(SPI_GETMOUSEHOVERWIDTH) error %u\n", GetLastError());
10583 if (!ret
) hover_width
= 4;
10584 SetLastError(0xdeadbeef);
10585 ret
= SystemParametersInfoA(SPI_GETMOUSEHOVERHEIGHT
, 0, &hover_height
, 0);
10586 ok(ret
|| broken(GetLastError() == 0xdeadbeef), /* win9x */
10587 "SystemParametersInfo(SPI_GETMOUSEHOVERHEIGHT) error %u\n", GetLastError());
10588 if (!ret
) hover_height
= 4;
10589 trace("hover rect is %u x %d\n", hover_width
, hover_height
);
10591 hwnd
= CreateWindowExA(0, "TestWindowClass", NULL
,
10592 WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
10593 CW_USEDEFAULT
, CW_USEDEFAULT
, 300, 300, 0,
10597 hchild
= CreateWindowExA(0, "TestWindowClass", NULL
,
10598 WS_CHILD
| WS_BORDER
| WS_VISIBLE
,
10599 50, 50, 200, 200, hwnd
,
10603 SetWindowPos( hwnd
, HWND_TOPMOST
, 0, 0, 0, 0, SWP_NOSIZE
|SWP_NOMOVE
);
10608 tme
.dwFlags
= TME_QUERY
;
10609 tme
.hwndTrack
= (HWND
)0xdeadbeef;
10610 tme
.dwHoverTime
= 0xdeadbeef;
10611 SetLastError(0xdeadbeef);
10612 ret
= pTrackMouseEvent(&tme
);
10613 ok(!ret
, "TrackMouseEvent should fail\n");
10614 ok(GetLastError() == ERROR_INVALID_PARAMETER
|| broken(GetLastError() == 0xdeadbeef),
10615 "not expected error %u\n", GetLastError());
10617 tme
.cbSize
= sizeof(tme
);
10618 tme
.dwFlags
= TME_HOVER
;
10619 tme
.hwndTrack
= (HWND
)0xdeadbeef;
10620 tme
.dwHoverTime
= 0xdeadbeef;
10621 SetLastError(0xdeadbeef);
10622 ret
= pTrackMouseEvent(&tme
);
10623 ok(!ret
, "TrackMouseEvent should fail\n");
10624 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
|| broken(GetLastError() == 0xdeadbeef),
10625 "not expected error %u\n", GetLastError());
10627 tme
.cbSize
= sizeof(tme
);
10628 tme
.dwFlags
= TME_HOVER
| TME_CANCEL
;
10629 tme
.hwndTrack
= (HWND
)0xdeadbeef;
10630 tme
.dwHoverTime
= 0xdeadbeef;
10631 SetLastError(0xdeadbeef);
10632 ret
= pTrackMouseEvent(&tme
);
10633 ok(!ret
, "TrackMouseEvent should fail\n");
10634 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
|| broken(GetLastError() == 0xdeadbeef),
10635 "not expected error %u\n", GetLastError());
10637 GetWindowRect(hwnd
, &rc_parent
);
10638 GetWindowRect(hchild
, &rc_child
);
10639 SetCursorPos(rc_child
.left
- 10, rc_child
.top
- 10);
10641 /* Process messages so that the system updates its internal current
10642 * window and hittest, otherwise TrackMouseEvent calls don't have any
10648 track_query(0, NULL
, 0);
10649 track_hover(hchild
, 0);
10650 track_query(0, NULL
, 0);
10655 track_hover(hwnd
, 0);
10656 tme
.cbSize
= sizeof(tme
);
10657 tme
.dwFlags
= TME_QUERY
;
10658 tme
.hwndTrack
= (HWND
)0xdeadbeef;
10659 tme
.dwHoverTime
= 0xdeadbeef;
10660 SetLastError(0xdeadbeef);
10661 ret
= pTrackMouseEvent(&tme
);
10662 ok(ret
, "TrackMouseEvent(TME_QUERY) error %d\n", GetLastError());
10663 ok(tme
.cbSize
== sizeof(tme
), "wrong tme.cbSize %u\n", tme
.cbSize
);
10666 skip( "Cursor not inside window, skipping TrackMouseEvent tests\n" );
10667 DestroyWindow( hwnd
);
10670 ok(tme
.dwFlags
== TME_HOVER
, "wrong tme.dwFlags %08x, expected TME_HOVER\n", tme
.dwFlags
);
10671 ok(tme
.hwndTrack
== hwnd
, "wrong tme.hwndTrack %p, expected %p\n", tme
.hwndTrack
, hwnd
);
10672 ok(tme
.dwHoverTime
== default_hover_time
, "wrong tme.dwHoverTime %u, expected %u\n",
10673 tme
.dwHoverTime
, default_hover_time
);
10675 pump_msg_loop_timeout(default_hover_time
, FALSE
);
10676 ok_sequence(WmMouseHoverSeq
, "WmMouseHoverSeq", FALSE
);
10678 track_query(0, NULL
, 0);
10680 track_hover(hwnd
, HOVER_DEFAULT
);
10681 track_query(TME_HOVER
, hwnd
, default_hover_time
);
10683 Sleep(default_hover_time
/ 2);
10684 mouse_event(MOUSEEVENTF_MOVE
, -1, 0, 0, 0);
10685 mouse_event(MOUSEEVENTF_MOVE
, 1, 0, 0, 0);
10687 track_query(TME_HOVER
, hwnd
, default_hover_time
);
10689 pump_msg_loop_timeout(default_hover_time
, FALSE
);
10690 ok_sequence(WmMouseHoverSeq
, "WmMouseHoverSeq", FALSE
);
10692 track_query(0, NULL
, 0);
10694 track_hover(hwnd
, HOVER_DEFAULT
);
10695 track_query(TME_HOVER
, hwnd
, default_hover_time
);
10697 pump_msg_loop_timeout(default_hover_time
, TRUE
);
10698 ok_sequence(WmMouseHoverSeq
, "WmMouseHoverSeq", FALSE
);
10700 track_query(0, NULL
, 0);
10702 track_hover(hwnd
, HOVER_DEFAULT
);
10703 track_query(TME_HOVER
, hwnd
, default_hover_time
);
10704 track_hover_cancel(hwnd
);
10706 DestroyWindow(hwnd
);
10710 #undef track_hover_cancel
10714 static const struct message WmSetWindowRgn
[] = {
10715 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
},
10716 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
10717 { WM_NCPAINT
, sent
|optional
}, /* wparam != 1 */
10718 { WM_GETTEXT
, sent
|defwinproc
|optional
},
10719 { WM_ERASEBKGND
, sent
|optional
},
10720 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
},
10721 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
10725 static const struct message WmSetWindowRgn_no_redraw
[] = {
10726 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
},
10727 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
10728 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
},
10729 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
10733 static const struct message WmSetWindowRgn_clear
[] = {
10734 { WM_WINDOWPOSCHANGING
, sent
/*|wparam*/, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
/*|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE only on some Windows versions */ },
10735 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
10736 { WM_NCPAINT
, sent
|optional
},
10737 { WM_GETTEXT
, sent
|defwinproc
|optional
},
10738 { WM_ERASEBKGND
, sent
|optional
}, /* FIXME: remove optional once Wine is fixed */
10739 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
},
10740 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
10741 { WM_NCPAINT
, sent
|optional
},
10742 { WM_GETTEXT
, sent
|defwinproc
|optional
},
10743 { WM_ERASEBKGND
, sent
|optional
},
10744 { WM_WINDOWPOSCHANGING
, sent
|optional
},
10745 { WM_NCCALCSIZE
, sent
|optional
|wparam
, 1 },
10746 { WM_NCPAINT
, sent
|optional
},
10747 { WM_GETTEXT
, sent
|defwinproc
|optional
},
10748 { WM_ERASEBKGND
, sent
|optional
},
10749 { WM_WINDOWPOSCHANGED
, sent
|optional
|wparam
, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
},
10750 { WM_NCCALCSIZE
, sent
|optional
|wparam
, 1 },
10751 { WM_NCPAINT
, sent
|optional
},
10752 { WM_GETTEXT
, sent
|defwinproc
|optional
},
10753 { WM_ERASEBKGND
, sent
|optional
},
10754 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
10755 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
10759 static void test_SetWindowRgn(void)
10762 HWND hwnd
= CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW
,
10763 100, 100, 200, 200, 0, 0, 0, NULL
);
10764 ok( hwnd
!= 0, "Failed to create overlapped window\n" );
10766 ShowWindow( hwnd
, SW_SHOW
);
10767 UpdateWindow( hwnd
);
10771 trace("testing SetWindowRgn\n");
10772 hrgn
= CreateRectRgn( 0, 0, 150, 150 );
10773 SetWindowRgn( hwnd
, hrgn
, TRUE
);
10774 ok_sequence( WmSetWindowRgn
, "WmSetWindowRgn", FALSE
);
10776 hrgn
= CreateRectRgn( 30, 30, 160, 160 );
10777 SetWindowRgn( hwnd
, hrgn
, FALSE
);
10778 ok_sequence( WmSetWindowRgn_no_redraw
, "WmSetWindowRgn_no_redraw", FALSE
);
10780 hrgn
= CreateRectRgn( 0, 0, 180, 180 );
10781 SetWindowRgn( hwnd
, hrgn
, TRUE
);
10782 ok_sequence( WmSetWindowRgn
, "WmSetWindowRgn2", FALSE
);
10784 SetWindowRgn( hwnd
, 0, TRUE
);
10785 ok_sequence( WmSetWindowRgn_clear
, "WmSetWindowRgn_clear", FALSE
);
10787 DestroyWindow( hwnd
);
10790 /*************************** ShowWindow() test ******************************/
10791 static const struct message WmShowNormal
[] = {
10792 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
10793 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
10794 { HCBT_ACTIVATE
, hook
},
10795 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2003 doesn't send it */
10796 { HCBT_SETFOCUS
, hook
},
10797 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
10800 static const struct message WmShow
[] = {
10801 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
10802 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
10803 { HCBT_ACTIVATE
, hook
|optional
}, /* win2000 doesn't send it */
10804 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2000 doesn't send it */
10805 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 doesn't send it */
10806 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
10809 static const struct message WmShowNoActivate_1
[] = {
10810 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWNOACTIVATE
},
10811 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_STATECHANGED
, 0, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOSIZE
|SWP_NOMOVE
},
10812 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_STATECHANGED
, 0, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOSIZE
|SWP_NOMOVE
},
10813 { WM_MOVE
, sent
|defwinproc
|optional
},
10814 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_RESTORED
},
10817 static const struct message WmShowNoActivate_2
[] = {
10818 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWNOACTIVATE
},
10819 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
10820 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
10821 { WM_MOVE
, sent
|defwinproc
},
10822 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_RESTORED
},
10823 { HCBT_SETFOCUS
, hook
|optional
},
10824 { HCBT_ACTIVATE
, hook
|optional
}, /* win2003 doesn't send it */
10825 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2003 doesn't send it */
10826 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
10827 { HCBT_SETFOCUS
, hook
|optional
}, /* win2003 doesn't send it */
10830 static const struct message WmShowNA_1
[] = {
10831 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
10832 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
10833 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
10836 static const struct message WmShowNA_2
[] = {
10837 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
10838 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
10839 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
10842 static const struct message WmRestore_1
[] = {
10843 { HCBT_MINMAX
, hook
|lparam
, 0, SW_RESTORE
},
10844 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
10845 { HCBT_ACTIVATE
, hook
|optional
}, /* win2000 doesn't send it */
10846 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2000 doesn't send it */
10847 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 doesn't send it */
10848 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
10849 { WM_MOVE
, sent
|defwinproc
},
10850 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_RESTORED
},
10851 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 sends it */
10854 static const struct message WmRestore_2
[] = {
10855 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
10856 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
10857 { HCBT_ACTIVATE
, hook
|optional
}, /* win2000 doesn't send it */
10858 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2000 doesn't send it */
10859 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 doesn't send it */
10860 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
10863 static const struct message WmRestore_3
[] = {
10864 { HCBT_MINMAX
, hook
|lparam
, 0, SW_RESTORE
},
10865 { WM_GETMINMAXINFO
, sent
},
10866 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
10867 { HCBT_ACTIVATE
, hook
|optional
}, /* win2003 doesn't send it */
10868 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2003 doesn't send it */
10869 { HCBT_SETFOCUS
, hook
|optional
}, /* win2003 doesn't send it */
10870 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
10871 { WM_MOVE
, sent
|defwinproc
},
10872 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_MAXIMIZED
},
10873 { HCBT_SETFOCUS
, hook
|optional
}, /* win2003 sends it */
10876 static const struct message WmRestore_4
[] = {
10877 { HCBT_MINMAX
, hook
|lparam
|optional
, 0, SW_RESTORE
},
10878 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_FRAMECHANGED
|SWP_STATECHANGED
, 0, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOSIZE
|SWP_NOMOVE
},
10879 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_FRAMECHANGED
|SWP_STATECHANGED
, 0, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOSIZE
|SWP_NOMOVE
},
10880 { WM_MOVE
, sent
|defwinproc
|optional
},
10881 { WM_SIZE
, sent
|wparam
|defwinproc
|optional
, SIZE_RESTORED
},
10884 static const struct message WmRestore_5
[] = {
10885 { HCBT_MINMAX
, hook
|lparam
|optional
, 0, SW_SHOWNORMAL
},
10886 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_FRAMECHANGED
|SWP_STATECHANGED
, 0, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOSIZE
|SWP_NOMOVE
},
10887 { HCBT_ACTIVATE
, hook
|optional
},
10888 { HCBT_SETFOCUS
, hook
|optional
},
10889 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_FRAMECHANGED
|SWP_STATECHANGED
, 0, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOSIZE
|SWP_NOMOVE
},
10890 { WM_MOVE
, sent
|defwinproc
|optional
},
10891 { WM_SIZE
, sent
|wparam
|defwinproc
|optional
, SIZE_RESTORED
},
10894 static const struct message WmHide_1
[] = {
10895 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
10896 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
, 0, SWP_NOACTIVATE
},
10897 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
, 0, SWP_NOACTIVATE
},
10898 { HCBT_ACTIVATE
, hook
|optional
},
10899 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 sends it */
10902 static const struct message WmHide_2
[] = {
10903 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
10904 { WM_WINDOWPOSCHANGING
, sent
/*|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE*/ }, /* win2000 doesn't add SWP_NOACTIVATE */
10905 { WM_WINDOWPOSCHANGED
, sent
/*|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE*/ }, /* win2000 doesn't add SWP_NOACTIVATE */
10906 { HCBT_ACTIVATE
, hook
|optional
},
10909 static const struct message WmHide_3
[] = {
10910 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
10911 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
10912 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
10913 { HCBT_SETFOCUS
, hook
|optional
},
10914 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
10917 static const struct message WmShowMinimized_1
[] = {
10918 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINIMIZED
},
10919 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
10920 { HCBT_ACTIVATE
, hook
|optional
}, /* win2000 doesn't send it */
10921 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2000 doesn't send it */
10922 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
10923 { WM_MOVE
, sent
|defwinproc
},
10924 { WM_SIZE
, sent
|wparam
|lparam
|defwinproc
, SIZE_MINIMIZED
, 0 },
10927 static const struct message WmMinimize_1
[] = {
10928 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
10929 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 doesn't send it */
10930 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
10931 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
10932 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
10933 { WM_MOVE
, sent
|defwinproc
},
10934 { WM_SIZE
, sent
|wparam
|lparam
|defwinproc
, SIZE_MINIMIZED
, 0 },
10937 static const struct message WmMinimize_2
[] = {
10938 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
10939 { HCBT_SETFOCUS
, hook
|optional
},
10940 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
10941 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
10942 { WM_MOVE
, sent
|defwinproc
},
10943 { WM_SIZE
, sent
|wparam
|lparam
|defwinproc
, SIZE_MINIMIZED
, 0 },
10946 static const struct message WmMinimize_3
[] = {
10947 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
10948 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
10949 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
10950 { WM_MOVE
, sent
|defwinproc
},
10951 { WM_SIZE
, sent
|wparam
|lparam
|defwinproc
, SIZE_MINIMIZED
, 0 },
10954 static const struct message WmShowMinNoActivate
[] = {
10955 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINNOACTIVE
},
10956 { WM_WINDOWPOSCHANGING
, sent
},
10957 { WM_WINDOWPOSCHANGED
, sent
},
10958 { WM_MOVE
, sent
|defwinproc
|optional
},
10959 { WM_SIZE
, sent
|wparam
|lparam
|defwinproc
|optional
, SIZE_MINIMIZED
, 0 },
10962 static const struct message WmMinMax_1
[] = {
10963 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINIMIZED
},
10966 static const struct message WmMinMax_2
[] = {
10967 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMAXIMIZED
},
10968 { WM_GETMINMAXINFO
, sent
|optional
},
10969 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
10970 { HCBT_ACTIVATE
, hook
|optional
},
10971 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
10972 { HCBT_SETFOCUS
, hook
|optional
},
10973 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_FRAMECHANGED
|SWP_STATECHANGED
, 0, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
10974 { WM_MOVE
, sent
|defwinproc
|optional
},
10975 { WM_SIZE
, sent
|wparam
|defwinproc
|optional
, SIZE_MAXIMIZED
},
10976 { HCBT_SETFOCUS
, hook
|optional
},
10979 static const struct message WmMinMax_3
[] = {
10980 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
10981 { HCBT_SETFOCUS
, hook
|optional
},
10982 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
10983 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
10984 { WM_MOVE
, sent
|defwinproc
|optional
},
10985 { WM_SIZE
, sent
|wparam
|lparam
|defwinproc
|optional
, SIZE_MINIMIZED
, 0 },
10988 static const struct message WmMinMax_4
[] = {
10989 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINNOACTIVE
},
10992 static const struct message WmShowMaximized_1
[] = {
10993 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMAXIMIZED
},
10994 { WM_GETMINMAXINFO
, sent
},
10995 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
10996 { HCBT_ACTIVATE
, hook
|optional
}, /* win2000 doesn't send it */
10997 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2000 doesn't send it */
10998 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 doesn't send it */
10999 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
11000 { WM_MOVE
, sent
|defwinproc
},
11001 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_MAXIMIZED
},
11002 { HCBT_SETFOCUS
, hook
|optional
}, /* win2003 sends it */
11005 static const struct message WmShowMaximized_2
[] = {
11006 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMAXIMIZED
},
11007 { WM_GETMINMAXINFO
, sent
},
11008 { WM_WINDOWPOSCHANGING
, sent
|optional
},
11009 { HCBT_ACTIVATE
, hook
|optional
},
11010 { WM_WINDOWPOSCHANGED
, sent
|optional
},
11011 { WM_MOVE
, sent
|optional
}, /* Win9x doesn't send it */
11012 { WM_SIZE
, sent
|wparam
|optional
, SIZE_MAXIMIZED
}, /* Win9x doesn't send it */
11013 { WM_WINDOWPOSCHANGING
, sent
|optional
},
11014 { HCBT_SETFOCUS
, hook
|optional
},
11015 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
11016 { WM_MOVE
, sent
|defwinproc
},
11017 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_MAXIMIZED
},
11018 { HCBT_SETFOCUS
, hook
|optional
},
11021 static const struct message WmShowMaximized_3
[] = {
11022 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMAXIMIZED
},
11023 { WM_GETMINMAXINFO
, sent
|optional
},
11024 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
, 0, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOSIZE
|SWP_NOMOVE
},
11025 { HCBT_ACTIVATE
, hook
|optional
}, /* win2000 doesn't send it */
11026 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2000 doesn't send it */
11027 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 doesn't send it */
11028 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
, 0, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOSIZE
|SWP_NOMOVE
},
11029 { WM_MOVE
, sent
|defwinproc
|optional
},
11030 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_MAXIMIZED
},
11034 static void test_ShowWindow(void)
11036 /* ShowWindow commands in random order */
11037 static const struct
11039 INT cmd
; /* ShowWindow command */
11040 LPARAM ret
; /* ShowWindow return value */
11041 DWORD style
; /* window style after the command */
11042 const struct message
*msg
; /* message sequence the command produces */
11043 INT wp_cmd
, wp_flags
; /* window placement after the command */
11044 POINT wp_min
, wp_max
; /* window placement after the command */
11045 BOOL todo_msg
; /* message sequence doesn't match what Wine does */
11048 /* 1 */ { SW_SHOWNORMAL
, FALSE
, WS_VISIBLE
, WmShowNormal
,
11049 SW_SHOWNORMAL
, 0, {-1,-1}, {-1,-1}, FALSE
},
11050 /* 2 */ { SW_SHOWNORMAL
, TRUE
, WS_VISIBLE
, WmEmptySeq
,
11051 SW_SHOWNORMAL
, 0, {-1,-1}, {-1,-1}, FALSE
},
11052 /* 3 */ { SW_HIDE
, TRUE
, 0, WmHide_1
,
11053 SW_SHOWNORMAL
, 0, {-1,-1}, {-1,-1}, FALSE
},
11054 /* 4 */ { SW_HIDE
, FALSE
, 0, WmEmptySeq
,
11055 SW_SHOWNORMAL
, 0, {-1,-1}, {-1,-1}, FALSE
},
11056 /* 5 */ { SW_SHOWMINIMIZED
, FALSE
, WS_VISIBLE
|WS_MINIMIZE
, WmShowMinimized_1
,
11057 SW_SHOWMINIMIZED
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
11058 /* 6 */ { SW_SHOWMINIMIZED
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinMax_1
,
11059 SW_SHOWMINIMIZED
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
11060 /* 7 */ { SW_HIDE
, TRUE
, WS_MINIMIZE
, WmHide_1
,
11061 SW_SHOWMINIMIZED
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
11062 /* 8 */ { SW_HIDE
, FALSE
, WS_MINIMIZE
, WmEmptySeq
,
11063 SW_SHOWMINIMIZED
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
11064 /* 9 */ { SW_SHOWMAXIMIZED
, FALSE
, WS_VISIBLE
|WS_MAXIMIZE
, WmShowMaximized_1
,
11065 SW_SHOWMAXIMIZED
, WPF_RESTORETOMAXIMIZED
, {-32000,-32000}, {-1,-1}, FALSE
},
11066 /* 10 */ { SW_SHOWMAXIMIZED
, TRUE
, WS_VISIBLE
|WS_MAXIMIZE
, WmMinMax_2
,
11067 SW_SHOWMAXIMIZED
, WPF_RESTORETOMAXIMIZED
, {-32000,-32000}, {-1,-1}, FALSE
},
11068 /* 11 */ { SW_HIDE
, TRUE
, WS_MAXIMIZE
, WmHide_1
,
11069 SW_SHOWMAXIMIZED
, WPF_RESTORETOMAXIMIZED
, {-32000,-32000}, {-1,-1}, FALSE
},
11070 /* 12 */ { SW_HIDE
, FALSE
, WS_MAXIMIZE
, WmEmptySeq
,
11071 SW_SHOWMAXIMIZED
, WPF_RESTORETOMAXIMIZED
, {-32000,-32000}, {-1,-1}, FALSE
},
11072 /* 13 */ { SW_SHOWNOACTIVATE
, FALSE
, WS_VISIBLE
, WmShowNoActivate_1
,
11073 SW_SHOWNORMAL
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
11074 /* 14 */ { SW_SHOWNOACTIVATE
, TRUE
, WS_VISIBLE
, WmEmptySeq
,
11075 SW_SHOWNORMAL
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
11076 /* 15 */ { SW_HIDE
, TRUE
, 0, WmHide_2
,
11077 SW_SHOWNORMAL
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
11078 /* 16 */ { SW_HIDE
, FALSE
, 0, WmEmptySeq
,
11079 SW_SHOWNORMAL
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
11080 /* 17 */ { SW_SHOW
, FALSE
, WS_VISIBLE
, WmShow
,
11081 SW_SHOWNORMAL
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
11082 /* 18 */ { SW_SHOW
, TRUE
, WS_VISIBLE
, WmEmptySeq
,
11083 SW_SHOWNORMAL
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
11084 /* 19 */ { SW_MINIMIZE
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinimize_1
,
11085 SW_SHOWMINIMIZED
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
11086 /* 20 */ { SW_MINIMIZE
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinMax_3
,
11087 SW_SHOWMINIMIZED
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
11088 /* 21 */ { SW_HIDE
, TRUE
, WS_MINIMIZE
, WmHide_2
,
11089 SW_SHOWMINIMIZED
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
11090 /* 22 */ { SW_SHOWMINNOACTIVE
, FALSE
, WS_VISIBLE
|WS_MINIMIZE
, WmShowMinNoActivate
,
11091 SW_SHOWMINIMIZED
, 0, {-32000,-32000}, {-1,-1}, TRUE
},
11092 /* 23 */ { SW_SHOWMINNOACTIVE
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinMax_4
,
11093 SW_SHOWMINIMIZED
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
11094 /* 24 */ { SW_HIDE
, TRUE
, WS_MINIMIZE
, WmHide_2
,
11095 SW_SHOWMINIMIZED
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
11096 /* 25 */ { SW_HIDE
, FALSE
, WS_MINIMIZE
, WmEmptySeq
,
11097 SW_SHOWMINIMIZED
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
11098 /* 26 */ { SW_SHOWNA
, FALSE
, WS_VISIBLE
|WS_MINIMIZE
, WmShowNA_1
,
11099 SW_SHOWMINIMIZED
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
11100 /* 27 */ { SW_SHOWNA
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmShowNA_2
,
11101 SW_SHOWMINIMIZED
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
11102 /* 28 */ { SW_HIDE
, TRUE
, WS_MINIMIZE
, WmHide_2
,
11103 SW_SHOWMINIMIZED
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
11104 /* 29 */ { SW_HIDE
, FALSE
, WS_MINIMIZE
, WmEmptySeq
,
11105 SW_SHOWMINIMIZED
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
11106 /* 30 */ { SW_RESTORE
, FALSE
, WS_VISIBLE
, WmRestore_1
,
11107 SW_SHOWNORMAL
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
11108 /* 31 */ { SW_RESTORE
, TRUE
, WS_VISIBLE
, WmEmptySeq
,
11109 SW_SHOWNORMAL
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
11110 /* 32 */ { SW_HIDE
, TRUE
, 0, WmHide_3
,
11111 SW_SHOWNORMAL
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
11112 /* 33 */ { SW_HIDE
, FALSE
, 0, WmEmptySeq
,
11113 SW_SHOWNORMAL
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
11114 /* 34 */ { SW_NORMALNA
, FALSE
, 0, WmEmptySeq
, /* what does this mean?! */
11115 SW_SHOWNORMAL
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
11116 /* 35 */ { SW_NORMALNA
, FALSE
, 0, WmEmptySeq
,
11117 SW_SHOWNORMAL
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
11118 /* 36 */ { SW_HIDE
, FALSE
, 0, WmEmptySeq
,
11119 SW_SHOWNORMAL
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
11120 /* 37 */ { SW_RESTORE
, FALSE
, WS_VISIBLE
, WmRestore_2
,
11121 SW_SHOWNORMAL
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
11122 /* 38 */ { SW_RESTORE
, TRUE
, WS_VISIBLE
, WmEmptySeq
,
11123 SW_SHOWNORMAL
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
11124 /* 39 */ { SW_SHOWNOACTIVATE
, TRUE
, WS_VISIBLE
, WmEmptySeq
,
11125 SW_SHOWNORMAL
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
11126 /* 40 */ { SW_MINIMIZE
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinimize_2
,
11127 SW_SHOWMINIMIZED
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
11128 /* 41 */ { SW_MINIMIZE
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinMax_3
,
11129 SW_SHOWMINIMIZED
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
11130 /* 42 */ { SW_SHOWMAXIMIZED
, TRUE
, WS_VISIBLE
|WS_MAXIMIZE
, WmShowMaximized_2
,
11131 SW_SHOWMAXIMIZED
, WPF_RESTORETOMAXIMIZED
, {-32000,-32000}, {-1,-1}, FALSE
},
11132 /* 43 */ { SW_SHOWMAXIMIZED
, TRUE
, WS_VISIBLE
|WS_MAXIMIZE
, WmMinMax_2
,
11133 SW_SHOWMAXIMIZED
, WPF_RESTORETOMAXIMIZED
, {-32000,-32000}, {-1,-1}, FALSE
},
11134 /* 44 */ { SW_MINIMIZE
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinimize_1
,
11135 SW_SHOWMINIMIZED
, WPF_RESTORETOMAXIMIZED
, {-32000,-32000}, {-1,-1}, FALSE
},
11136 /* 45 */ { SW_MINIMIZE
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinMax_3
,
11137 SW_SHOWMINIMIZED
, WPF_RESTORETOMAXIMIZED
, {-32000,-32000}, {-1,-1}, FALSE
},
11138 /* 46 */ { SW_RESTORE
, TRUE
, WS_VISIBLE
|WS_MAXIMIZE
, WmRestore_3
,
11139 SW_SHOWMAXIMIZED
, WPF_RESTORETOMAXIMIZED
, {-32000,-32000}, {-1,-1}, FALSE
},
11140 /* 47 */ { SW_RESTORE
, TRUE
, WS_VISIBLE
, WmRestore_4
,
11141 SW_SHOWNORMAL
, WPF_RESTORETOMAXIMIZED
, {-32000,-32000}, {-1,-1}, FALSE
},
11142 /* 48 */ { SW_SHOWMAXIMIZED
, TRUE
, WS_VISIBLE
|WS_MAXIMIZE
, WmShowMaximized_3
,
11143 SW_SHOWMAXIMIZED
, WPF_RESTORETOMAXIMIZED
, {-32000,-32000}, {-1,-1}, FALSE
},
11144 /* 49 */ { SW_SHOW
, TRUE
, WS_VISIBLE
|WS_MAXIMIZE
, WmEmptySeq
,
11145 SW_SHOWMAXIMIZED
, WPF_RESTORETOMAXIMIZED
, {-32000,-32000}, {-1,-1}, FALSE
},
11146 /* 50 */ { SW_SHOWNORMAL
, TRUE
, WS_VISIBLE
, WmRestore_5
,
11147 SW_SHOWNORMAL
, WPF_RESTORETOMAXIMIZED
, {-32000,-32000}, {-1,-1}, FALSE
},
11148 /* 51 */ { SW_SHOWNORMAL
, TRUE
, WS_VISIBLE
, WmRestore_5
,
11149 SW_SHOWNORMAL
, WPF_RESTORETOMAXIMIZED
, {-32000,-32000}, {-1,-1}, FALSE
},
11150 /* 52 */ { SW_HIDE
, TRUE
, 0, WmHide_1
,
11151 SW_SHOWNORMAL
, WPF_RESTORETOMAXIMIZED
, {-32000,-32000}, {-1,-1}, FALSE
},
11152 /* 53 */ { SW_HIDE
, FALSE
, 0, WmEmptySeq
,
11153 SW_SHOWNORMAL
, WPF_RESTORETOMAXIMIZED
, {-32000,-32000}, {-1,-1}, FALSE
},
11154 /* 54 */ { SW_MINIMIZE
, FALSE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinimize_3
,
11155 SW_SHOWMINIMIZED
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
11156 /* 55 */ { SW_HIDE
, TRUE
, WS_MINIMIZE
, WmHide_2
,
11157 SW_SHOWMINIMIZED
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
11158 /* 56 */ { SW_SHOWNOACTIVATE
, FALSE
, WS_VISIBLE
, WmShowNoActivate_2
,
11159 SW_SHOWNORMAL
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
11160 /* 57 */ { SW_SHOW
, TRUE
, WS_VISIBLE
, WmEmptySeq
,
11161 SW_SHOWNORMAL
, 0, {-32000,-32000}, {-1,-1}, FALSE
}
11167 WINDOWPLACEMENT wp
;
11168 RECT win_rc
, work_rc
= {0, 0, 0, 0};
11170 #define WS_BASE (WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX|WS_MAXIMIZEBOX|WS_POPUP|WS_CLIPSIBLINGS)
11171 hwnd
= CreateWindowExA(0, "ShowWindowClass", NULL
, WS_BASE
,
11176 style
= GetWindowLongA(hwnd
, GWL_STYLE
) & ~WS_BASE
;
11177 ok(style
== 0, "expected style 0, got %08x\n", style
);
11182 if (pGetMonitorInfoA
&& pMonitorFromPoint
)
11188 SetLastError(0xdeadbeef);
11189 hmon
= pMonitorFromPoint(pt
, MONITOR_DEFAULTTOPRIMARY
);
11190 ok(hmon
!= 0, "MonitorFromPoint error %u\n", GetLastError());
11192 mi
.cbSize
= sizeof(mi
);
11193 SetLastError(0xdeadbeef);
11194 ret
= pGetMonitorInfoA(hmon
, &mi
);
11195 ok(ret
, "GetMonitorInfo error %u\n", GetLastError());
11196 trace("monitor (%d,%d-%d,%d), work (%d,%d-%d,%d)\n",
11197 mi
.rcMonitor
.left
, mi
.rcMonitor
.top
, mi
.rcMonitor
.right
, mi
.rcMonitor
.bottom
,
11198 mi
.rcWork
.left
, mi
.rcWork
.top
, mi
.rcWork
.right
, mi
.rcWork
.bottom
);
11199 work_rc
= mi
.rcWork
;
11202 GetWindowRect(hwnd
, &win_rc
);
11203 OffsetRect(&win_rc
, -work_rc
.left
, -work_rc
.top
);
11205 wp
.length
= sizeof(wp
);
11206 SetLastError(0xdeadbeaf);
11207 ret
= GetWindowPlacement(hwnd
, &wp
);
11208 ok(ret
, "GetWindowPlacement error %u\n", GetLastError());
11209 ok(wp
.flags
== 0, "expected 0, got %#x\n", wp
.flags
);
11210 ok(wp
.showCmd
== SW_SHOWNORMAL
, "expected SW_SHOWNORMAL, got %d\n", wp
.showCmd
);
11211 ok(wp
.ptMinPosition
.x
== -1 && wp
.ptMinPosition
.y
== -1,
11212 "expected -1,-1 got %d,%d\n", wp
.ptMinPosition
.x
, wp
.ptMinPosition
.y
);
11213 ok(wp
.ptMaxPosition
.x
== -1 && wp
.ptMaxPosition
.y
== -1,
11214 "expected -1,-1 got %d,%d\n", wp
.ptMaxPosition
.x
, wp
.ptMaxPosition
.y
);
11215 if (work_rc
.left
|| work_rc
.top
) todo_wine
/* FIXME: remove once Wine is fixed */
11216 ok(EqualRect(&win_rc
, &wp
.rcNormalPosition
),
11217 "expected %d,%d-%d,%d got %d,%d-%d,%d\n",
11218 win_rc
.left
, win_rc
.top
, win_rc
.right
, win_rc
.bottom
,
11219 wp
.rcNormalPosition
.left
, wp
.rcNormalPosition
.top
,
11220 wp
.rcNormalPosition
.right
, wp
.rcNormalPosition
.bottom
);
11222 ok(EqualRect(&win_rc
, &wp
.rcNormalPosition
),
11223 "expected %d,%d-%d,%d got %d,%d-%d,%d\n",
11224 win_rc
.left
, win_rc
.top
, win_rc
.right
, win_rc
.bottom
,
11225 wp
.rcNormalPosition
.left
, wp
.rcNormalPosition
.top
,
11226 wp
.rcNormalPosition
.right
, wp
.rcNormalPosition
.bottom
);
11228 for (i
= 0; i
< sizeof(sw
)/sizeof(sw
[0]); i
++)
11230 static const char * const sw_cmd_name
[13] =
11232 "SW_HIDE", "SW_SHOWNORMAL", "SW_SHOWMINIMIZED", "SW_SHOWMAXIMIZED",
11233 "SW_SHOWNOACTIVATE", "SW_SHOW", "SW_MINIMIZE", "SW_SHOWMINNOACTIVE",
11234 "SW_SHOWNA", "SW_RESTORE", "SW_SHOWDEFAULT", "SW_FORCEMINIMIZE",
11235 "SW_NORMALNA" /* 0xCC */
11238 INT idx
; /* index into the above array of names */
11240 idx
= (sw
[i
].cmd
== SW_NORMALNA
) ? 12 : sw
[i
].cmd
;
11242 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
11243 trace("%d: sending %s, current window style %08x\n", i
+1, sw_cmd_name
[idx
], style
);
11244 ret
= ShowWindow(hwnd
, sw
[i
].cmd
);
11245 ok(!ret
== !sw
[i
].ret
, "%d: cmd %s: expected ret %lu, got %lu\n", i
+1, sw_cmd_name
[idx
], sw
[i
].ret
, ret
);
11246 style
= GetWindowLongA(hwnd
, GWL_STYLE
) & ~WS_BASE
;
11247 ok(style
== sw
[i
].style
, "%d: expected style %08x, got %08x\n", i
+1, sw
[i
].style
, style
);
11249 sprintf(comment
, "%d: ShowWindow(%s)", i
+1, sw_cmd_name
[idx
]);
11250 ok_sequence(sw
[i
].msg
, comment
, sw
[i
].todo_msg
);
11252 wp
.length
= sizeof(wp
);
11253 SetLastError(0xdeadbeaf);
11254 ret
= GetWindowPlacement(hwnd
, &wp
);
11255 ok(ret
, "GetWindowPlacement error %u\n", GetLastError());
11256 ok(wp
.flags
== sw
[i
].wp_flags
, "expected %#x, got %#x\n", sw
[i
].wp_flags
, wp
.flags
);
11257 ok(wp
.showCmd
== sw
[i
].wp_cmd
, "expected %d, got %d\n", sw
[i
].wp_cmd
, wp
.showCmd
);
11259 /* NT moves the minimized window to -32000,-32000, win9x to 3000,3000 */
11260 if ((wp
.ptMinPosition
.x
+ work_rc
.left
== -32000 && wp
.ptMinPosition
.y
+ work_rc
.top
== -32000) ||
11261 (wp
.ptMinPosition
.x
+ work_rc
.left
== 3000 && wp
.ptMinPosition
.y
+ work_rc
.top
== 3000))
11263 ok((wp
.ptMinPosition
.x
+ work_rc
.left
== sw
[i
].wp_min
.x
&& wp
.ptMinPosition
.y
+ work_rc
.top
== sw
[i
].wp_min
.y
) ||
11264 (wp
.ptMinPosition
.x
+ work_rc
.left
== 3000 && wp
.ptMinPosition
.y
+ work_rc
.top
== 3000),
11265 "expected %d,%d got %d,%d\n", sw
[i
].wp_min
.x
, sw
[i
].wp_min
.y
, wp
.ptMinPosition
.x
, wp
.ptMinPosition
.y
);
11269 ok(wp
.ptMinPosition
.x
== sw
[i
].wp_min
.x
&& wp
.ptMinPosition
.y
== sw
[i
].wp_min
.y
,
11270 "expected %d,%d got %d,%d\n", sw
[i
].wp_min
.x
, sw
[i
].wp_min
.y
, wp
.ptMinPosition
.x
, wp
.ptMinPosition
.y
);
11273 if (wp
.ptMaxPosition
.x
!= sw
[i
].wp_max
.x
|| wp
.ptMaxPosition
.y
!= sw
[i
].wp_max
.y
)
11275 ok(wp
.ptMaxPosition
.x
== sw
[i
].wp_max
.x
&& wp
.ptMaxPosition
.y
== sw
[i
].wp_max
.y
,
11276 "expected %d,%d got %d,%d\n", sw
[i
].wp_max
.x
, sw
[i
].wp_max
.y
, wp
.ptMaxPosition
.x
, wp
.ptMaxPosition
.y
);
11278 ok(wp
.ptMaxPosition
.x
== sw
[i
].wp_max
.x
&& wp
.ptMaxPosition
.y
== sw
[i
].wp_max
.y
,
11279 "expected %d,%d got %d,%d\n", sw
[i
].wp_max
.x
, sw
[i
].wp_max
.y
, wp
.ptMaxPosition
.x
, wp
.ptMaxPosition
.y
);
11281 if (0) /* FIXME: Wine behaves completely different here */
11282 ok(EqualRect(&win_rc
, &wp
.rcNormalPosition
),
11283 "expected %d,%d-%d,%d got %d,%d-%d,%d\n",
11284 win_rc
.left
, win_rc
.top
, win_rc
.right
, win_rc
.bottom
,
11285 wp
.rcNormalPosition
.left
, wp
.rcNormalPosition
.top
,
11286 wp
.rcNormalPosition
.right
, wp
.rcNormalPosition
.bottom
);
11292 DestroyWindow(hwnd
);
11295 static INT_PTR WINAPI
test_dlg_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
11297 struct recvd_message msg
;
11299 if (ignore_message( message
)) return 0;
11302 msg
.message
= message
;
11303 msg
.flags
= sent
|wparam
|lparam
;
11304 msg
.wParam
= wParam
;
11305 msg
.lParam
= lParam
;
11306 msg
.descr
= "dialog";
11309 /* calling DefDlgProc leads to a recursion under XP */
11313 case WM_INITDIALOG
:
11314 case WM_GETDLGCODE
:
11320 static const struct message WmDefDlgSetFocus_1
[] = {
11321 { WM_GETDLGCODE
, sent
|wparam
|lparam
, 0, 0 },
11322 { WM_GETTEXTLENGTH
, sent
|wparam
|lparam
|optional
, 0, 0 }, /* XP */
11323 { WM_GETTEXT
, sent
|wparam
|optional
, 6 }, /* XP */
11324 { WM_GETTEXT
, sent
|wparam
|optional
, 12 }, /* XP */
11325 { EM_SETSEL
, sent
|wparam
, 0 }, /* XP sets lparam to text length, Win9x to -2 */
11326 { HCBT_SETFOCUS
, hook
},
11327 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
11328 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
11329 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
11330 { WM_SETFOCUS
, sent
|wparam
, 0 },
11331 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 10 },
11332 { WM_CTLCOLOREDIT
, sent
},
11333 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 11 },
11334 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
11335 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
11336 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
11337 { WM_COMMAND
, sent
|wparam
, MAKEWPARAM(1, EN_SETFOCUS
) },
11340 static const struct message WmDefDlgSetFocus_2
[] = {
11341 { WM_GETDLGCODE
, sent
|wparam
|lparam
, 0, 0 },
11342 { WM_GETTEXTLENGTH
, sent
|wparam
|lparam
|optional
, 0, 0 }, /* XP */
11343 { WM_GETTEXT
, sent
|wparam
|optional
, 6 }, /* XP */
11344 { WM_GETTEXT
, sent
|wparam
|optional
, 12 }, /* XP */
11345 { EM_SETSEL
, sent
|wparam
, 0 }, /* XP sets lparam to text length, Win9x to -2 */
11346 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
11347 { WM_CTLCOLOREDIT
, sent
|optional
}, /* XP */
11348 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
11351 /* Creation of a dialog */
11352 static const struct message WmCreateDialogParamSeq_1
[] = {
11353 { HCBT_CREATEWND
, hook
},
11354 { WM_NCCREATE
, sent
},
11355 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
11356 { WM_CREATE
, sent
},
11357 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
11358 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
11360 { WM_SETFONT
, sent
},
11361 { WM_INITDIALOG
, sent
},
11362 { WM_CHANGEUISTATE
, sent
|optional
},
11365 /* Creation of a dialog */
11366 static const struct message WmCreateDialogParamSeq_2
[] = {
11367 { HCBT_CREATEWND
, hook
},
11368 { WM_NCCREATE
, sent
},
11369 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
11370 { WM_CREATE
, sent
},
11371 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
11372 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
11374 { WM_CHANGEUISTATE
, sent
|optional
},
11378 static void test_dialog_messages(void)
11381 HWND hdlg
, hedit1
, hedit2
, hfocus
;
11384 #define set_selection(hctl, start, end) \
11385 ret = SendMessageA(hctl, EM_SETSEL, start, end); \
11386 ok(ret == 1, "EM_SETSEL returned %ld\n", ret);
11388 #define check_selection(hctl, start, end) \
11389 ret = SendMessageA(hctl, EM_GETSEL, 0, 0); \
11390 ok(ret == MAKELRESULT(start, end), "wrong selection (%d - %d)\n", LOWORD(ret), HIWORD(ret));
11394 hdlg
= CreateWindowExA(WS_EX_DLGMODALFRAME
, "TestDialogClass", NULL
,
11395 WS_VISIBLE
|WS_CAPTION
|WS_SYSMENU
|WS_DLGFRAME
,
11396 0, 0, 100, 100, 0, 0, 0, NULL
);
11397 ok(hdlg
!= 0, "Failed to create custom dialog window\n");
11399 hedit1
= CreateWindowExA(0, "my_edit_class", NULL
,
11400 WS_CHILD
|WS_BORDER
|WS_VISIBLE
|WS_TABSTOP
,
11401 0, 0, 80, 20, hdlg
, (HMENU
)1, 0, NULL
);
11402 ok(hedit1
!= 0, "Failed to create edit control\n");
11403 hedit2
= CreateWindowExA(0, "my_edit_class", NULL
,
11404 WS_CHILD
|WS_BORDER
|WS_VISIBLE
|WS_TABSTOP
,
11405 0, 40, 80, 20, hdlg
, (HMENU
)2, 0, NULL
);
11406 ok(hedit2
!= 0, "Failed to create edit control\n");
11408 SendMessageA(hedit1
, WM_SETTEXT
, 0, (LPARAM
)"hello");
11409 SendMessageA(hedit2
, WM_SETTEXT
, 0, (LPARAM
)"bye");
11411 hfocus
= GetFocus();
11412 ok(hfocus
== hdlg
, "wrong focus %p\n", hfocus
);
11415 hfocus
= GetFocus();
11416 ok(hfocus
== hedit2
, "wrong focus %p\n", hfocus
);
11418 check_selection(hedit1
, 0, 0);
11419 check_selection(hedit2
, 0, 0);
11421 set_selection(hedit2
, 0, -1);
11422 check_selection(hedit2
, 0, 3);
11425 hfocus
= GetFocus();
11426 ok(hfocus
== 0, "wrong focus %p\n", hfocus
);
11429 ret
= DefDlgProcA(hdlg
, WM_SETFOCUS
, 0, 0);
11430 ok(ret
== 0, "WM_SETFOCUS returned %ld\n", ret
);
11431 ok_sequence(WmDefDlgSetFocus_1
, "DefDlgProc(WM_SETFOCUS) 1", FALSE
);
11433 hfocus
= GetFocus();
11434 ok(hfocus
== hedit1
, "wrong focus %p\n", hfocus
);
11436 check_selection(hedit1
, 0, 5);
11437 check_selection(hedit2
, 0, 3);
11440 ret
= DefDlgProcA(hdlg
, WM_SETFOCUS
, 0, 0);
11441 ok(ret
== 0, "WM_SETFOCUS returned %ld\n", ret
);
11442 ok_sequence(WmDefDlgSetFocus_2
, "DefDlgProc(WM_SETFOCUS) 2", FALSE
);
11444 hfocus
= GetFocus();
11445 ok(hfocus
== hedit1
, "wrong focus %p\n", hfocus
);
11447 check_selection(hedit1
, 0, 5);
11448 check_selection(hedit2
, 0, 3);
11450 EndDialog(hdlg
, 0);
11451 DestroyWindow(hedit1
);
11452 DestroyWindow(hedit2
);
11453 DestroyWindow(hdlg
);
11456 #undef set_selection
11457 #undef check_selection
11459 ok(GetClassInfoA(0, "#32770", &cls
), "GetClassInfo failed\n");
11460 cls
.lpszClassName
= "MyDialogClass";
11461 cls
.hInstance
= GetModuleHandleA(NULL
);
11462 /* need a cast since a dlgproc is used as a wndproc */
11463 cls
.lpfnWndProc
= test_dlg_proc
;
11464 if (!RegisterClassA(&cls
)) assert(0);
11466 hdlg
= CreateDialogParamA(0, "CLASS_TEST_DIALOG_2", 0, test_dlg_proc
, 0);
11467 ok(IsWindow(hdlg
), "CreateDialogParam failed\n");
11468 ok_sequence(WmCreateDialogParamSeq_1
, "CreateDialogParam_1", FALSE
);
11469 EndDialog(hdlg
, 0);
11470 DestroyWindow(hdlg
);
11473 hdlg
= CreateDialogParamA(0, "CLASS_TEST_DIALOG_2", 0, NULL
, 0);
11474 ok(IsWindow(hdlg
), "CreateDialogParam failed\n");
11475 ok_sequence(WmCreateDialogParamSeq_2
, "CreateDialogParam_2", FALSE
);
11476 EndDialog(hdlg
, 0);
11477 DestroyWindow(hdlg
);
11480 UnregisterClassA(cls
.lpszClassName
, cls
.hInstance
);
11483 static void test_EndDialog(void)
11485 HWND hparent
, hother
, hactive
, hdlg
;
11488 hparent
= CreateWindowExA(0, "TestParentClass", "Test parent",
11489 WS_OVERLAPPEDWINDOW
| WS_VISIBLE
| WS_DISABLED
,
11490 100, 100, 200, 200, 0, 0, 0, NULL
);
11491 ok (hparent
!= 0, "Failed to create parent window\n");
11493 hother
= CreateWindowExA(0, "TestParentClass", "Test parent 2",
11494 WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
11495 100, 100, 200, 200, 0, 0, 0, NULL
);
11496 ok (hother
!= 0, "Failed to create parent window\n");
11498 ok(GetClassInfoA(0, "#32770", &cls
), "GetClassInfo failed\n");
11499 cls
.lpszClassName
= "MyDialogClass";
11500 cls
.hInstance
= GetModuleHandleA(NULL
);
11501 cls
.lpfnWndProc
= test_dlg_proc
;
11502 if (!RegisterClassA(&cls
)) assert(0);
11505 SetForegroundWindow(hother
);
11506 hactive
= GetForegroundWindow();
11507 ok(hother
== hactive
, "Wrong window has focus (%p != %p)\n", hother
, hactive
);
11509 /* create a dialog where the parent is disabled, this parent should still
11510 receive the focus when the dialog exits (even though "normally" a
11511 disabled window should not receive the focus) */
11512 hdlg
= CreateDialogParamA(0, "CLASS_TEST_DIALOG_2", hparent
, test_dlg_proc
, 0);
11513 ok(IsWindow(hdlg
), "CreateDialogParam failed\n");
11514 SetForegroundWindow(hdlg
);
11515 hactive
= GetForegroundWindow();
11516 ok(hdlg
== hactive
, "Wrong window has focus (%p != %p)\n", hdlg
, hactive
);
11517 EndDialog(hdlg
, 0);
11518 hactive
= GetForegroundWindow();
11519 ok(hparent
== hactive
, "Wrong window has focus (parent != active) (active: %p, parent: %p, dlg: %p, other: %p)\n", hactive
, hparent
, hdlg
, hother
);
11520 DestroyWindow(hdlg
);
11523 DestroyWindow( hother
);
11524 DestroyWindow( hparent
);
11525 UnregisterClassA(cls
.lpszClassName
, cls
.hInstance
);
11528 static void test_nullCallback(void)
11532 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW
,
11533 100, 100, 200, 200, 0, 0, 0, NULL
);
11534 ok (hwnd
!= 0, "Failed to create overlapped window\n");
11536 SendMessageCallbackA(hwnd
,WM_NULL
,0,0,NULL
,0);
11538 DestroyWindow(hwnd
);
11541 /* SetActiveWindow( 0 ) hwnd visible */
11542 static const struct message SetActiveWindowSeq0
[] =
11544 { HCBT_ACTIVATE
, hook
|optional
},
11545 { WM_NCACTIVATE
, sent
|wparam
, 0 },
11546 { WM_GETTEXT
, sent
|defwinproc
|optional
},
11547 { WM_ACTIVATE
, sent
|wparam
, 0 },
11548 { WM_ACTIVATEAPP
, sent
|wparam
|optional
, 0 },
11549 { WM_ACTIVATEAPP
, sent
|wparam
|optional
, 0 },
11550 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
11551 { WM_KILLFOCUS
, sent
|optional
},
11552 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
11553 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
11554 { WM_NCACTIVATE
, sent
|wparam
|optional
, 1 },
11555 { WM_GETTEXT
, sent
|defwinproc
|optional
},
11556 { WM_ACTIVATE
, sent
|wparam
|optional
, 1 },
11557 { HCBT_SETFOCUS
, hook
|optional
},
11558 { WM_KILLFOCUS
, sent
|defwinproc
|optional
},
11559 { WM_IME_SETCONTEXT
, sent
|defwinproc
|optional
},
11560 { WM_IME_SETCONTEXT
, sent
|defwinproc
|optional
},
11561 { WM_IME_SETCONTEXT
, sent
|optional
},
11562 { WM_IME_SETCONTEXT
, sent
|optional
},
11563 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 1 },
11564 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
11565 { WM_SETFOCUS
, sent
|defwinproc
|optional
},
11566 { WM_GETTEXT
, sent
|optional
},
11569 /* SetActiveWindow( hwnd ) hwnd visible */
11570 static const struct message SetActiveWindowSeq1
[] =
11572 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
11575 /* SetActiveWindow( popup ) hwnd visible, popup visible */
11576 static const struct message SetActiveWindowSeq2
[] =
11578 { HCBT_ACTIVATE
, hook
},
11579 { WM_NCACTIVATE
, sent
|wparam
, 0 },
11580 { WM_GETTEXT
, sent
|defwinproc
|optional
},
11581 { WM_ACTIVATE
, sent
|wparam
, 0 },
11582 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
11583 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
11584 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
11585 { WM_NCPAINT
, sent
|optional
},
11586 { WM_GETTEXT
, sent
|defwinproc
|optional
},
11587 { WM_ERASEBKGND
, sent
|optional
},
11588 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
11589 { WM_NCACTIVATE
, sent
|wparam
, 1 },
11590 { WM_GETTEXT
, sent
|defwinproc
|optional
},
11591 { WM_ACTIVATE
, sent
|wparam
, 1 },
11592 { HCBT_SETFOCUS
, hook
},
11593 { WM_KILLFOCUS
, sent
|defwinproc
},
11594 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 0 },
11595 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
11596 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 1 },
11597 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
11598 { WM_SETFOCUS
, sent
|defwinproc
},
11599 { WM_GETTEXT
, sent
|optional
},
11603 /* SetActiveWindow( hwnd ) hwnd not visible */
11604 static const struct message SetActiveWindowSeq3
[] =
11606 { HCBT_ACTIVATE
, hook
},
11607 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
11608 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
11609 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
},
11610 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOACTIVATE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
11611 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
11612 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
11613 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
11614 { WM_NCACTIVATE
, sent
|wparam
, 1 },
11615 { WM_ACTIVATE
, sent
|wparam
, 1 },
11616 { HCBT_SETFOCUS
, hook
},
11617 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
11618 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
11619 { WM_SETFOCUS
, sent
|defwinproc
},
11622 /* SetActiveWindow( popup ) hwnd not visible, popup not visible */
11623 static const struct message SetActiveWindowSeq4
[] =
11625 { HCBT_ACTIVATE
, hook
},
11626 { WM_NCACTIVATE
, sent
|wparam
, 0 },
11627 { WM_GETTEXT
, sent
|defwinproc
|optional
},
11628 { WM_ACTIVATE
, sent
|wparam
, 0 },
11629 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
11630 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
},
11631 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
11632 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
11633 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
11634 { WM_NCACTIVATE
, sent
|wparam
, 1 },
11635 { WM_GETTEXT
, sent
|defwinproc
|optional
},
11636 { WM_ACTIVATE
, sent
|wparam
, 1 },
11637 { HCBT_SETFOCUS
, hook
},
11638 { WM_KILLFOCUS
, sent
|defwinproc
},
11639 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 0 },
11640 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
11641 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 1 },
11642 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
11643 { WM_SETFOCUS
, sent
|defwinproc
},
11648 static void test_SetActiveWindow(void)
11650 HWND hwnd
, popup
, ret
;
11652 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test SetActiveWindow",
11653 WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
11654 100, 100, 200, 200, 0, 0, 0, NULL
);
11656 popup
= CreateWindowExA(0, "TestWindowClass", "Test SetActiveWindow",
11657 WS_OVERLAPPEDWINDOW
| WS_VISIBLE
| WS_POPUP
,
11658 100, 100, 200, 200, hwnd
, 0, 0, NULL
);
11660 ok(hwnd
!= 0, "Failed to create overlapped window\n");
11661 ok(popup
!= 0, "Failed to create popup window\n");
11662 SetForegroundWindow( popup
);
11665 trace("SetActiveWindow(0)\n");
11666 ret
= SetActiveWindow(0);
11667 ok( ret
== popup
, "Failed to SetActiveWindow(0)\n");
11668 ok_sequence(SetActiveWindowSeq0
, "SetActiveWindow(0)", FALSE
);
11671 trace("SetActiveWindow(hwnd), hwnd visible\n");
11672 ret
= SetActiveWindow(hwnd
);
11673 if (ret
== hwnd
) ok_sequence(SetActiveWindowSeq1
, "SetActiveWindow(hwnd), hwnd visible", TRUE
);
11676 trace("SetActiveWindow(popup), hwnd visible, popup visible\n");
11677 ret
= SetActiveWindow(popup
);
11678 ok( ret
== hwnd
, "Failed to SetActiveWindow(popup), popup visible\n");
11679 ok_sequence(SetActiveWindowSeq2
, "SetActiveWindow(popup), hwnd visible, popup visible", FALSE
);
11682 ShowWindow(hwnd
, SW_HIDE
);
11683 ShowWindow(popup
, SW_HIDE
);
11686 trace("SetActiveWindow(hwnd), hwnd not visible\n");
11687 ret
= SetActiveWindow(hwnd
);
11688 ok( ret
== NULL
, "SetActiveWindow(hwnd), hwnd not visible, previous is %p\n", ret
);
11689 ok_sequence(SetActiveWindowSeq3
, "SetActiveWindow(hwnd), hwnd not visible", TRUE
);
11692 trace("SetActiveWindow(popup), hwnd not visible, popup not visible\n");
11693 ret
= SetActiveWindow(popup
);
11694 ok( ret
== hwnd
, "Failed to SetActiveWindow(popup)\n");
11695 ok_sequence(SetActiveWindowSeq4
, "SetActiveWindow(popup), hwnd not visible, popup not visible", TRUE
);
11700 DestroyWindow(hwnd
);
11703 static const struct message SetForegroundWindowSeq
[] =
11705 { WM_NCACTIVATE
, sent
|wparam
, 0 },
11706 { WM_GETTEXT
, sent
|defwinproc
|optional
},
11707 { WM_ACTIVATE
, sent
|wparam
, 0 },
11708 { WM_ACTIVATEAPP
, sent
|wparam
, 0 },
11709 { WM_KILLFOCUS
, sent
},
11710 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
11711 { WM_IME_NOTIFY
, sent
|wparam
|optional
|defwinproc
, 1 },
11715 static void test_SetForegroundWindow(void)
11719 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test SetForegroundWindow",
11720 WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
11721 100, 100, 200, 200, 0, 0, 0, NULL
);
11722 ok (hwnd
!= 0, "Failed to create overlapped window\n");
11723 SetForegroundWindow( hwnd
);
11726 trace("SetForegroundWindow( 0 )\n");
11727 SetForegroundWindow( 0 );
11728 ok_sequence(WmEmptySeq
, "SetForegroundWindow( 0 ) away from foreground top level window", FALSE
);
11729 trace("SetForegroundWindow( GetDesktopWindow() )\n");
11730 SetForegroundWindow( GetDesktopWindow() );
11731 ok_sequence(SetForegroundWindowSeq
, "SetForegroundWindow( desktop ) away from "
11732 "foreground top level window", FALSE
);
11735 DestroyWindow(hwnd
);
11738 static void test_dbcs_wm_char(void)
11741 WCHAR wch
, bad_wch
;
11749 struct message wmCharSeq
[2];
11752 if (!pGetCPInfoExA
)
11754 win_skip("GetCPInfoExA is not available\n");
11758 pGetCPInfoExA( CP_ACP
, 0, &cpinfo
);
11759 if (cpinfo
.MaxCharSize
!= 2)
11761 skip( "Skipping DBCS WM_CHAR test in SBCS codepage '%s'\n", cpinfo
.CodePageName
);
11765 dbch
[0] = dbch
[1] = 0;
11767 bad_wch
= cpinfo
.UnicodeDefaultChar
;
11768 for (i
= 0; !wch
&& i
< MAX_LEADBYTES
&& cpinfo
.LeadByte
[i
]; i
+= 2)
11769 for (j
= cpinfo
.LeadByte
[i
]; !wch
&& j
<= cpinfo
.LeadByte
[i
+1]; j
++)
11770 for (k
= 128; k
<= 255; k
++)
11776 if (MultiByteToWideChar( CP_ACP
, 0, str
, 2, wstr
, 2 ) == 1 &&
11777 WideCharToMultiByte( CP_ACP
, 0, wstr
, 1, str
, 2, NULL
, NULL
) == 2 &&
11778 (BYTE
)str
[0] == j
&& (BYTE
)str
[1] == k
&&
11779 HIBYTE(wstr
[0]) && HIBYTE(wstr
[0]) != 0xff)
11790 skip( "Skipping DBCS WM_CHAR test, no appropriate char found\n" );
11793 trace( "using dbcs char %02x,%02x wchar %04x bad wchar %04x codepage '%s'\n",
11794 dbch
[0], dbch
[1], wch
, bad_wch
, cpinfo
.CodePageName
);
11796 hwnd
= CreateWindowExW(0, testWindowClassW
, NULL
,
11797 WS_OVERLAPPEDWINDOW
, 100, 100, 200, 200, 0, 0, 0, NULL
);
11798 hwnd2
= CreateWindowExW(0, testWindowClassW
, NULL
,
11799 WS_OVERLAPPEDWINDOW
, 100, 100, 200, 200, 0, 0, 0, NULL
);
11800 ok (hwnd
!= 0, "Failed to create overlapped window\n");
11801 ok (hwnd2
!= 0, "Failed to create overlapped window\n");
11804 memset( wmCharSeq
, 0, sizeof(wmCharSeq
) );
11805 wmCharSeq
[0].message
= WM_CHAR
;
11806 wmCharSeq
[0].flags
= sent
|wparam
;
11807 wmCharSeq
[0].wParam
= wch
;
11809 /* posted message */
11810 PostMessageA( hwnd
, WM_CHAR
, dbch
[0], 0 );
11811 ret
= PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
);
11812 ok( !ret
, "got message %x\n", msg
.message
);
11813 PostMessageA( hwnd
, WM_CHAR
, dbch
[1], 0 );
11814 ret
= PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
);
11815 ok( ret
, "no message\n" );
11816 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
11817 ok( msg
.wParam
== wch
, "bad wparam %lx/%x\n", msg
.wParam
, wch
);
11818 ret
= PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
);
11819 ok( !ret
, "got message %x\n", msg
.message
);
11821 /* posted thread message */
11822 PostThreadMessageA( GetCurrentThreadId(), WM_CHAR
, dbch
[0], 0 );
11823 ret
= PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
);
11824 ok( !ret
, "got message %x\n", msg
.message
);
11825 PostMessageA( hwnd
, WM_CHAR
, dbch
[1], 0 );
11826 ret
= PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
);
11827 ok( ret
, "no message\n" );
11828 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
11829 ok( msg
.wParam
== wch
, "bad wparam %lx/%x\n", msg
.wParam
, wch
);
11830 ret
= PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
);
11831 ok( !ret
, "got message %x\n", msg
.message
);
11835 SendMessageA( hwnd
, WM_CHAR
, dbch
[0], 0 );
11836 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
11837 SendMessageA( hwnd
, WM_CHAR
, dbch
[1], 0 );
11838 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
11839 ret
= PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
);
11840 ok( !ret
, "got message %x\n", msg
.message
);
11842 /* sent message with timeout */
11844 SendMessageTimeoutA( hwnd
, WM_CHAR
, dbch
[0], 0, SMTO_NORMAL
, 0, &res
);
11845 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
11846 SendMessageTimeoutA( hwnd
, WM_CHAR
, dbch
[1], 0, SMTO_NORMAL
, 0, &res
);
11847 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
11848 ret
= PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
);
11849 ok( !ret
, "got message %x\n", msg
.message
);
11851 /* sent message with timeout and callback */
11853 SendMessageTimeoutA( hwnd
, WM_CHAR
, dbch
[0], 0, SMTO_NORMAL
, 0, &res
);
11854 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
11855 SendMessageCallbackA( hwnd
, WM_CHAR
, dbch
[1], 0, NULL
, 0 );
11856 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
11857 ret
= PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
);
11858 ok( !ret
, "got message %x\n", msg
.message
);
11860 /* sent message with callback */
11862 SendNotifyMessageA( hwnd
, WM_CHAR
, dbch
[0], 0 );
11863 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
11864 SendMessageCallbackA( hwnd
, WM_CHAR
, dbch
[1], 0, NULL
, 0 );
11865 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
11866 ret
= PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
);
11867 ok( !ret
, "got message %x\n", msg
.message
);
11869 /* direct window proc call */
11871 CallWindowProcA( (WNDPROC
)GetWindowLongPtrA( hwnd
, GWLP_WNDPROC
), hwnd
, WM_CHAR
, dbch
[0], 0 );
11872 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
11873 CallWindowProcA( (WNDPROC
)GetWindowLongPtrA( hwnd
, GWLP_WNDPROC
), hwnd
, WM_CHAR
, dbch
[1], 0 );
11874 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
11876 /* dispatch message */
11878 msg
.message
= WM_CHAR
;
11879 msg
.wParam
= dbch
[0];
11881 DispatchMessageA( &msg
);
11882 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
11883 msg
.wParam
= dbch
[1];
11884 DispatchMessageA( &msg
);
11885 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
11887 /* window handle is irrelevant */
11889 SendMessageA( hwnd2
, WM_CHAR
, dbch
[0], 0 );
11890 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
11891 SendMessageA( hwnd
, WM_CHAR
, dbch
[1], 0 );
11892 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
11893 ret
= PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
);
11894 ok( !ret
, "got message %x\n", msg
.message
);
11896 /* interleaved post and send */
11898 PostMessageA( hwnd2
, WM_CHAR
, dbch
[0], 0 );
11899 SendMessageA( hwnd2
, WM_CHAR
, dbch
[0], 0 );
11900 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
11901 ret
= PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
);
11902 ok( !ret
, "got message %x\n", msg
.message
);
11903 PostMessageA( hwnd
, WM_CHAR
, dbch
[1], 0 );
11904 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
11905 ret
= PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
);
11906 ok( ret
, "no message\n" );
11907 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
11908 ok( msg
.wParam
== wch
, "bad wparam %lx/%x\n", msg
.wParam
, wch
);
11909 ret
= PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
);
11910 ok( !ret
, "got message %x\n", msg
.message
);
11911 SendMessageA( hwnd
, WM_CHAR
, dbch
[1], 0 );
11912 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
11913 ret
= PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
);
11914 ok( !ret
, "got message %x\n", msg
.message
);
11916 /* interleaved sent message and winproc */
11918 SendMessageA( hwnd
, WM_CHAR
, dbch
[0], 0 );
11919 CallWindowProcA( (WNDPROC
)GetWindowLongPtrA( hwnd
, GWLP_WNDPROC
), hwnd
, WM_CHAR
, dbch
[0], 0 );
11920 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
11921 SendMessageA( hwnd
, WM_CHAR
, dbch
[1], 0 );
11922 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
11923 CallWindowProcA( (WNDPROC
)GetWindowLongPtrA( hwnd
, GWLP_WNDPROC
), hwnd
, WM_CHAR
, dbch
[1], 0 );
11924 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
11926 /* interleaved winproc and dispatch */
11928 msg
.message
= WM_CHAR
;
11929 msg
.wParam
= dbch
[0];
11931 CallWindowProcA( (WNDPROC
)GetWindowLongPtrA( hwnd
, GWLP_WNDPROC
), hwnd
, WM_CHAR
, dbch
[0], 0 );
11932 DispatchMessageA( &msg
);
11933 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
11934 msg
.wParam
= dbch
[1];
11935 DispatchMessageA( &msg
);
11936 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
11937 CallWindowProcA( (WNDPROC
)GetWindowLongPtrA( hwnd
, GWLP_WNDPROC
), hwnd
, WM_CHAR
, dbch
[1], 0 );
11938 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
11940 /* interleaved sends */
11942 SendMessageA( hwnd
, WM_CHAR
, dbch
[0], 0 );
11943 SendMessageCallbackA( hwnd
, WM_CHAR
, dbch
[0], 0, NULL
, 0 );
11944 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
11945 SendMessageTimeoutA( hwnd
, WM_CHAR
, dbch
[1], 0, SMTO_NORMAL
, 0, &res
);
11946 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
11947 SendMessageA( hwnd
, WM_CHAR
, dbch
[1], 0 );
11948 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
11952 SendMessageA( hwnd2
, WM_CHAR
, (dbch
[1] << 8) | dbch
[0], 0 );
11953 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
11954 ret
= PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
);
11955 ok( !ret
, "got message %x\n", msg
.message
);
11957 /* other char messages are not magic */
11958 PostMessageA( hwnd
, WM_SYSCHAR
, dbch
[0], 0 );
11959 ret
= PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
);
11960 ok( ret
, "no message\n" );
11961 ok( msg
.message
== WM_SYSCHAR
, "unexpected message %x\n", msg
.message
);
11962 ok( msg
.wParam
== bad_wch
, "bad wparam %lx/%x\n", msg
.wParam
, bad_wch
);
11963 ret
= PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
);
11964 ok( !ret
, "got message %x\n", msg
.message
);
11965 PostMessageA( hwnd
, WM_DEADCHAR
, dbch
[0], 0 );
11966 ret
= PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
);
11967 ok( ret
, "no message\n" );
11968 ok( msg
.message
== WM_DEADCHAR
, "unexpected message %x\n", msg
.message
);
11969 ok( msg
.wParam
== bad_wch
, "bad wparam %lx/%x\n", msg
.wParam
, bad_wch
);
11970 ret
= PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
);
11971 ok( !ret
, "got message %x\n", msg
.message
);
11973 /* test retrieving messages */
11975 PostMessageW( hwnd
, WM_CHAR
, wch
, 0 );
11976 ret
= PeekMessageA( &msg
, hwnd
, 0, 0, PM_REMOVE
);
11977 ok( ret
, "no message\n" );
11978 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
11979 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
11980 ok( msg
.wParam
== dbch
[0], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
11981 ret
= PeekMessageA( &msg
, hwnd
, 0, 0, PM_REMOVE
);
11982 ok( ret
, "no message\n" );
11983 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
11984 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
11985 ok( msg
.wParam
== dbch
[1], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
11986 ret
= PeekMessageA( &msg
, hwnd
, 0, 0, PM_REMOVE
);
11987 ok( !ret
, "got message %x\n", msg
.message
);
11989 /* message filters */
11990 PostMessageW( hwnd
, WM_CHAR
, wch
, 0 );
11991 ret
= PeekMessageA( &msg
, hwnd
, 0, 0, PM_REMOVE
);
11992 ok( ret
, "no message\n" );
11993 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
11994 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
11995 ok( msg
.wParam
== dbch
[0], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
11996 /* message id is filtered, hwnd is not */
11997 ret
= PeekMessageA( &msg
, hwnd
, WM_MOUSEFIRST
, WM_MOUSELAST
, PM_REMOVE
);
11998 ok( !ret
, "no message\n" );
11999 ret
= PeekMessageA( &msg
, hwnd2
, 0, 0, PM_REMOVE
);
12000 ok( ret
, "no message\n" );
12001 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
12002 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
12003 ok( msg
.wParam
== dbch
[1], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
12004 ret
= PeekMessageA( &msg
, hwnd
, 0, 0, PM_REMOVE
);
12005 ok( !ret
, "got message %x\n", msg
.message
);
12007 /* mixing GetMessage and PostMessage */
12008 PostMessageW( hwnd
, WM_CHAR
, wch
, 0xbeef );
12009 ok( GetMessageA( &msg
, hwnd
, 0, 0 ), "no message\n" );
12010 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
12011 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
12012 ok( msg
.wParam
== dbch
[0], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
12013 ok( msg
.lParam
== 0xbeef, "bad lparam %lx\n", msg
.lParam
);
12016 ok( time
- GetTickCount() <= 100, "bad time %x\n", msg
.time
);
12017 ret
= PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
);
12018 ok( ret
, "no message\n" );
12019 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
12020 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
12021 ok( msg
.wParam
== dbch
[1], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
12022 ok( msg
.lParam
== 0xbeef, "bad lparam %lx\n", msg
.lParam
);
12023 ok( msg
.time
== time
, "bad time %x/%x\n", msg
.time
, time
);
12024 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
);
12025 ret
= PeekMessageA( &msg
, hwnd
, 0, 0, PM_REMOVE
);
12026 ok( !ret
, "got message %x\n", msg
.message
);
12028 /* without PM_REMOVE */
12029 PostMessageW( hwnd
, WM_CHAR
, wch
, 0 );
12030 ret
= PeekMessageA( &msg
, 0, 0, 0, PM_NOREMOVE
);
12031 ok( ret
, "no message\n" );
12032 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
12033 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
12034 ok( msg
.wParam
== dbch
[0], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
12035 ret
= PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
);
12036 ok( ret
, "no message\n" );
12037 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
12038 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
12039 ok( msg
.wParam
== dbch
[0], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
12040 ret
= PeekMessageA( &msg
, 0, 0, 0, PM_NOREMOVE
);
12041 ok( ret
, "no message\n" );
12042 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
12043 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
12044 ok( msg
.wParam
== dbch
[1], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
12045 ret
= PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
);
12046 ok( ret
, "no message\n" );
12047 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
12048 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
12049 ok( msg
.wParam
== dbch
[1], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
12050 ret
= PeekMessageA( &msg
, hwnd
, 0, 0, PM_REMOVE
);
12051 ok( !ret
, "got message %x\n", msg
.message
);
12053 DestroyWindow(hwnd
);
12054 DestroyWindow(hwnd2
);
12057 static void test_unicode_wm_char(void)
12061 struct message seq
[2];
12062 HKL hkl_orig
, hkl_greek
;
12064 LCID thread_locale
;
12066 hkl_orig
= GetKeyboardLayout( 0 );
12067 GetLocaleInfoW( LOWORD( hkl_orig
), LOCALE_IDEFAULTANSICODEPAGE
| LOCALE_RETURN_NUMBER
, (WCHAR
*)&cp
, sizeof(cp
) / sizeof(WCHAR
) );
12070 skip( "Default codepage %d\n", cp
);
12074 hkl_greek
= LoadKeyboardLayoutA( "00000408", 0 );
12075 if (!hkl_greek
|| hkl_greek
== hkl_orig
/* win2k */)
12077 skip( "Unable to load Greek keyboard layout\n" );
12081 hwnd
= CreateWindowExW( 0, testWindowClassW
, NULL
, WS_OVERLAPPEDWINDOW
,
12082 100, 100, 200, 200, 0, 0, 0, NULL
);
12085 PostMessageW( hwnd
, WM_CHAR
, 0x3b1, 0 );
12087 ok( GetMessageW( &msg
, hwnd
, 0, 0 ), "no message\n" );
12088 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
12089 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
12090 ok( msg
.wParam
== 0x3b1, "bad wparam %lx\n", msg
.wParam
);
12091 ok( msg
.lParam
== 0, "bad lparam %lx\n", msg
.lParam
);
12093 DispatchMessageW( &msg
);
12095 memset( seq
, 0, sizeof(seq
) );
12096 seq
[0].message
= WM_CHAR
;
12097 seq
[0].flags
= sent
|wparam
;
12098 seq
[0].wParam
= 0x3b1;
12100 ok_sequence( seq
, "unicode WM_CHAR", FALSE
);
12104 /* greek alpha -> 'a' in cp1252 */
12105 PostMessageW( hwnd
, WM_CHAR
, 0x3b1, 0 );
12107 ok( GetMessageA( &msg
, hwnd
, 0, 0 ), "no message\n" );
12108 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
12109 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
12110 ok( msg
.wParam
== 0x61, "bad wparam %lx\n", msg
.wParam
);
12111 ok( msg
.lParam
== 0, "bad lparam %lx\n", msg
.lParam
);
12113 DispatchMessageA( &msg
);
12115 seq
[0].wParam
= 0x61;
12116 ok_sequence( seq
, "unicode WM_CHAR", FALSE
);
12118 thread_locale
= GetThreadLocale();
12119 ActivateKeyboardLayout( hkl_greek
, 0 );
12120 ok( GetThreadLocale() == thread_locale
, "locale changed from %08x to %08x\n",
12121 thread_locale
, GetThreadLocale() );
12125 /* greek alpha -> 0xe1 in cp1253 */
12126 PostMessageW( hwnd
, WM_CHAR
, 0x3b1, 0 );
12128 ok( GetMessageA( &msg
, hwnd
, 0, 0 ), "no message\n" );
12129 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
12130 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
12131 ok( msg
.wParam
== 0xe1, "bad wparam %lx\n", msg
.wParam
);
12132 ok( msg
.lParam
== 0, "bad lparam %lx\n", msg
.lParam
);
12134 DispatchMessageA( &msg
);
12136 seq
[0].wParam
= 0x3b1;
12137 ok_sequence( seq
, "unicode WM_CHAR", FALSE
);
12139 DestroyWindow( hwnd
);
12140 ActivateKeyboardLayout( hkl_orig
, 0 );
12141 UnloadKeyboardLayout( hkl_greek
);
12144 #define ID_LISTBOX 0x000f
12146 static const struct message wm_lb_setcursel_0
[] =
12148 { LB_SETCURSEL
, sent
|wparam
|lparam
, 0, 0 },
12149 { WM_CTLCOLORLISTBOX
, sent
|parent
},
12150 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x000120f2 },
12151 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 1 },
12152 { EVENT_OBJECT_SELECTION
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 1 },
12155 static const struct message wm_lb_setcursel_1
[] =
12157 { LB_SETCURSEL
, sent
|wparam
|lparam
, 1, 0 },
12158 { WM_CTLCOLORLISTBOX
, sent
|parent
},
12159 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x000020f2 },
12160 { WM_CTLCOLORLISTBOX
, sent
|parent
},
12161 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x000121f2 },
12162 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 2 },
12163 { EVENT_OBJECT_SELECTION
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 2 },
12166 static const struct message wm_lb_setcursel_2
[] =
12168 { LB_SETCURSEL
, sent
|wparam
|lparam
, 2, 0 },
12169 { WM_CTLCOLORLISTBOX
, sent
|parent
},
12170 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x000021f2 },
12171 { WM_CTLCOLORLISTBOX
, sent
|parent
},
12172 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x000122f2 },
12173 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 3 },
12174 { EVENT_OBJECT_SELECTION
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 3 },
12177 static const struct message wm_lb_click_0
[] =
12179 { WM_LBUTTONDOWN
, sent
|wparam
|lparam
, 0, MAKELPARAM(1,1) },
12180 { HCBT_SETFOCUS
, hook
},
12181 { WM_KILLFOCUS
, sent
|parent
},
12182 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
|parent
, 0 },
12183 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
12184 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
12185 { WM_SETFOCUS
, sent
|defwinproc
},
12187 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x001142f2 },
12188 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_LISTBOX
, LBN_SETFOCUS
) },
12189 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 3 },
12190 { WM_LBTRACKPOINT
, sent
|wparam
|lparam
|parent
, 0, MAKELPARAM(1,1) },
12191 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
12193 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x000142f2 },
12194 { WM_CTLCOLORLISTBOX
, sent
|parent
},
12195 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x000022f2 },
12196 { WM_CTLCOLORLISTBOX
, sent
|parent
},
12197 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x000120f2 },
12198 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x001140f2 },
12200 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 1 },
12201 { EVENT_OBJECT_SELECTION
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 1 },
12203 { WM_LBUTTONUP
, sent
|wparam
|lparam
, 0, 0 },
12204 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, 0, 0 },
12205 { WM_CAPTURECHANGED
, sent
|wparam
|lparam
|defwinproc
, 0, 0 },
12206 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_LISTBOX
, LBN_SELCHANGE
) },
12209 static const struct message wm_lb_deletestring
[] =
12211 { LB_DELETESTRING
, sent
|wparam
|lparam
, 0, 0 },
12212 { WM_DELETEITEM
, sent
|wparam
|parent
|optional
, ID_LISTBOX
, 0 },
12213 { WM_DRAWITEM
, sent
|wparam
|parent
|optional
, ID_LISTBOX
},
12214 { WM_DRAWITEM
, sent
|wparam
|parent
|optional
, ID_LISTBOX
},
12217 static const struct message wm_lb_deletestring_reset
[] =
12219 { LB_DELETESTRING
, sent
|wparam
|lparam
, 0, 0 },
12220 { LB_RESETCONTENT
, sent
|wparam
|lparam
|defwinproc
|optional
, 0, 0 },
12221 { WM_DELETEITEM
, sent
|wparam
|parent
|optional
, ID_LISTBOX
, 0 },
12222 { WM_DRAWITEM
, sent
|wparam
|parent
|optional
, ID_LISTBOX
},
12223 { WM_DRAWITEM
, sent
|wparam
|parent
|optional
, ID_LISTBOX
},
12227 #define check_lb_state(a1, a2, a3, a4, a5) check_lb_state_dbg(a1, a2, a3, a4, a5, __LINE__)
12229 static LRESULT (WINAPI
*listbox_orig_proc
)(HWND
, UINT
, WPARAM
, LPARAM
);
12231 static LRESULT WINAPI
listbox_hook_proc(HWND hwnd
, UINT message
, WPARAM wp
, LPARAM lp
)
12233 static LONG defwndproc_counter
= 0;
12235 struct recvd_message msg
;
12237 /* do not log painting messages */
12238 if (message
!= WM_PAINT
&&
12239 message
!= WM_NCPAINT
&&
12240 message
!= WM_SYNCPAINT
&&
12241 message
!= WM_ERASEBKGND
&&
12242 message
!= WM_NCHITTEST
&&
12243 message
!= WM_GETTEXT
&&
12244 !ignore_message( message
))
12247 msg
.message
= message
;
12248 msg
.flags
= sent
|wparam
|lparam
;
12249 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
12252 msg
.descr
= "listbox";
12256 defwndproc_counter
++;
12257 ret
= CallWindowProcA(listbox_orig_proc
, hwnd
, message
, wp
, lp
);
12258 defwndproc_counter
--;
12263 static void check_lb_state_dbg(HWND listbox
, int count
, int cur_sel
,
12264 int caret_index
, int top_index
, int line
)
12268 /* calling an orig proc helps to avoid unnecessary message logging */
12269 ret
= CallWindowProcA(listbox_orig_proc
, listbox
, LB_GETCOUNT
, 0, 0);
12270 ok_(__FILE__
, line
)(ret
== count
, "expected count %d, got %ld\n", count
, ret
);
12271 ret
= CallWindowProcA(listbox_orig_proc
, listbox
, LB_GETCURSEL
, 0, 0);
12272 ok_(__FILE__
, line
)(ret
== cur_sel
, "expected cur sel %d, got %ld\n", cur_sel
, ret
);
12273 ret
= CallWindowProcA(listbox_orig_proc
, listbox
, LB_GETCARETINDEX
, 0, 0);
12274 ok_(__FILE__
, line
)(ret
== caret_index
||
12275 broken(cur_sel
== -1 && caret_index
== 0 && ret
== -1), /* nt4 */
12276 "expected caret index %d, got %ld\n", caret_index
, ret
);
12277 ret
= CallWindowProcA(listbox_orig_proc
, listbox
, LB_GETTOPINDEX
, 0, 0);
12278 ok_(__FILE__
, line
)(ret
== top_index
, "expected top index %d, got %ld\n", top_index
, ret
);
12281 static void test_listbox_messages(void)
12283 HWND parent
, listbox
;
12286 parent
= CreateWindowExA(0, "TestParentClass", NULL
, WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
12287 100, 100, 200, 200, 0, 0, 0, NULL
);
12288 listbox
= CreateWindowExA(WS_EX_NOPARENTNOTIFY
, "ListBox", NULL
,
12289 WS_CHILD
| LBS_NOTIFY
| LBS_OWNERDRAWVARIABLE
| LBS_HASSTRINGS
| WS_VISIBLE
,
12290 10, 10, 80, 80, parent
, (HMENU
)ID_LISTBOX
, 0, NULL
);
12291 listbox_orig_proc
= (WNDPROC
)SetWindowLongPtrA(listbox
, GWLP_WNDPROC
, (ULONG_PTR
)listbox_hook_proc
);
12293 check_lb_state(listbox
, 0, LB_ERR
, 0, 0);
12295 ret
= SendMessageA(listbox
, LB_ADDSTRING
, 0, (LPARAM
)"item 0");
12296 ok(ret
== 0, "expected 0, got %ld\n", ret
);
12297 ret
= SendMessageA(listbox
, LB_ADDSTRING
, 0, (LPARAM
)"item 1");
12298 ok(ret
== 1, "expected 1, got %ld\n", ret
);
12299 ret
= SendMessageA(listbox
, LB_ADDSTRING
, 0, (LPARAM
)"item 2");
12300 ok(ret
== 2, "expected 2, got %ld\n", ret
);
12302 check_lb_state(listbox
, 3, LB_ERR
, 0, 0);
12306 log_all_parent_messages
++;
12308 trace("selecting item 0\n");
12309 ret
= SendMessageA(listbox
, LB_SETCURSEL
, 0, 0);
12310 ok(ret
== 0, "expected 0, got %ld\n", ret
);
12311 ok_sequence(wm_lb_setcursel_0
, "LB_SETCURSEL 0", FALSE
);
12312 check_lb_state(listbox
, 3, 0, 0, 0);
12315 trace("selecting item 1\n");
12316 ret
= SendMessageA(listbox
, LB_SETCURSEL
, 1, 0);
12317 ok(ret
== 1, "expected 1, got %ld\n", ret
);
12318 ok_sequence(wm_lb_setcursel_1
, "LB_SETCURSEL 1", FALSE
);
12319 check_lb_state(listbox
, 3, 1, 1, 0);
12321 trace("selecting item 2\n");
12322 ret
= SendMessageA(listbox
, LB_SETCURSEL
, 2, 0);
12323 ok(ret
== 2, "expected 2, got %ld\n", ret
);
12324 ok_sequence(wm_lb_setcursel_2
, "LB_SETCURSEL 2", FALSE
);
12325 check_lb_state(listbox
, 3, 2, 2, 0);
12327 trace("clicking on item 0\n");
12328 ret
= SendMessageA(listbox
, WM_LBUTTONDOWN
, 0, MAKELPARAM(1, 1));
12329 ok(ret
== LB_OKAY
, "expected LB_OKAY, got %ld\n", ret
);
12330 ret
= SendMessageA(listbox
, WM_LBUTTONUP
, 0, 0);
12331 ok(ret
== LB_OKAY
, "expected LB_OKAY, got %ld\n", ret
);
12332 ok_sequence(wm_lb_click_0
, "WM_LBUTTONDOWN 0", FALSE
);
12333 check_lb_state(listbox
, 3, 0, 0, 0);
12336 trace("deleting item 0\n");
12337 ret
= SendMessageA(listbox
, LB_DELETESTRING
, 0, 0);
12338 ok(ret
== 2, "expected 2, got %ld\n", ret
);
12339 ok_sequence(wm_lb_deletestring
, "LB_DELETESTRING 0", FALSE
);
12340 check_lb_state(listbox
, 2, -1, 0, 0);
12343 trace("deleting item 0\n");
12344 ret
= SendMessageA(listbox
, LB_DELETESTRING
, 0, 0);
12345 ok(ret
== 1, "expected 1, got %ld\n", ret
);
12346 ok_sequence(wm_lb_deletestring
, "LB_DELETESTRING 0", FALSE
);
12347 check_lb_state(listbox
, 1, -1, 0, 0);
12350 trace("deleting item 0\n");
12351 ret
= SendMessageA(listbox
, LB_DELETESTRING
, 0, 0);
12352 ok(ret
== 0, "expected 0, got %ld\n", ret
);
12353 ok_sequence(wm_lb_deletestring_reset
, "LB_DELETESTRING 0", FALSE
);
12354 check_lb_state(listbox
, 0, -1, 0, 0);
12357 trace("deleting item 0\n");
12358 ret
= SendMessageA(listbox
, LB_DELETESTRING
, 0, 0);
12359 ok(ret
== LB_ERR
, "expected LB_ERR, got %ld\n", ret
);
12360 check_lb_state(listbox
, 0, -1, 0, 0);
12363 log_all_parent_messages
--;
12365 DestroyWindow(listbox
);
12366 DestroyWindow(parent
);
12369 /*************************** Menu test ******************************/
12370 static const struct message wm_popup_menu_1
[] =
12372 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 },
12373 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
12374 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'E', 0x20000001 },
12375 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, 'E', 0x20000001 },
12376 { WM_SYSCHAR
, sent
|wparam
|lparam
, 'e', 0x20000001 },
12377 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_KEYMENU
, 'e' },
12378 { WM_ENTERMENULOOP
, sent
|wparam
|lparam
, 0, 0 },
12379 { WM_INITMENU
, sent
|lparam
, 0, 0 },
12380 { WM_MENUSELECT
, sent
|wparam
, MAKEWPARAM(1,MF_HILITE
|MF_POPUP
) },
12381 { WM_INITMENUPOPUP
, sent
|lparam
, 0, 1 },
12382 { HCBT_CREATEWND
, hook
|optional
}, /* Win9x doesn't create a window */
12383 { WM_MENUSELECT
, sent
|wparam
, MAKEWPARAM(200,MF_HILITE
) },
12384 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'E', 0xf0000001 },
12385 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xd0000001 },
12386 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_RETURN
, 0x10000001, 0, 0x40000000 },
12387 { HCBT_DESTROYWND
, hook
|optional
}, /* Win9x doesn't create a window */
12388 { WM_UNINITMENUPOPUP
, sent
|lparam
, 0, 0 },
12389 { WM_MENUSELECT
, sent
|wparam
|lparam
, MAKEWPARAM(0,0xffff), 0 },
12390 { WM_EXITMENULOOP
, sent
|wparam
|lparam
, 0, 0 },
12391 { WM_MENUCOMMAND
, sent
}, /* |wparam, 200 - Win9x */
12392 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_RETURN
, 0xc0000001 },
12393 { WM_KEYUP
, sent
|wparam
|lparam
, VK_RETURN
, 0xc0000001 },
12396 static const struct message wm_popup_menu_2
[] =
12398 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 },
12399 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
12400 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'F', 0x20000001 },
12401 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, 'F', 0x20000001 },
12402 { WM_SYSCHAR
, sent
|wparam
|lparam
, 'f', 0x20000001 },
12403 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_KEYMENU
, 'f' },
12404 { WM_ENTERMENULOOP
, sent
|wparam
|lparam
, 0, 0 },
12405 { WM_INITMENU
, sent
|lparam
, 0, 0 },
12406 { WM_MENUSELECT
, sent
|wparam
, MAKEWPARAM(0,MF_HILITE
|MF_POPUP
) },
12407 { WM_INITMENUPOPUP
, sent
|lparam
, 0, 0 },
12408 { WM_MENUSELECT
, sent
|wparam
|optional
, MAKEWPARAM(0,MF_HILITE
|MF_POPUP
) }, /* Win9x */
12409 { WM_INITMENUPOPUP
, sent
|lparam
|optional
, 0, 0 }, /* Win9x */
12410 { HCBT_CREATEWND
, hook
},
12411 { WM_MENUSELECT
, sent
}, /*|wparam, MAKEWPARAM(0,MF_HILITE|MF_POPUP) - XP
12412 |wparam, MAKEWPARAM(100,MF_HILITE) - Win9x */
12413 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'F', 0xf0000001 },
12414 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xd0000001 },
12415 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_RIGHT
, 0x10000001 },
12416 { WM_INITMENUPOPUP
, sent
|lparam
|optional
, 0, 0 }, /* Win9x doesn't send it */
12417 { HCBT_CREATEWND
, hook
|optional
}, /* Win9x doesn't send it */
12418 { WM_MENUSELECT
, sent
|wparam
|optional
, MAKEWPARAM(100,MF_HILITE
) },
12419 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_RIGHT
, 0xd0000001 },
12420 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_RETURN
, 0x10000001 },
12421 { HCBT_DESTROYWND
, hook
},
12422 { WM_UNINITMENUPOPUP
, sent
|lparam
, 0, 0 },
12423 { HCBT_DESTROYWND
, hook
|optional
}, /* Win9x doesn't send it */
12424 { WM_UNINITMENUPOPUP
, sent
|lparam
, 0, 0 },
12425 { WM_MENUSELECT
, sent
|wparam
|lparam
, MAKEWPARAM(0,0xffff), 0 },
12426 { WM_EXITMENULOOP
, sent
|wparam
|lparam
, 0, 0 },
12427 { WM_MENUCOMMAND
, sent
}, /* |wparam, 100 - Win9x */
12428 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_RETURN
, 0xc0000001 },
12429 { WM_KEYUP
, sent
|wparam
|lparam
, VK_RETURN
, 0xc0000001 },
12432 static const struct message wm_popup_menu_3
[] =
12434 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 },
12435 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
12436 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'F', 0x20000001 },
12437 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, 'F', 0x20000001 },
12438 { WM_SYSCHAR
, sent
|wparam
|lparam
, 'f', 0x20000001 },
12439 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_KEYMENU
, 'f' },
12440 { WM_ENTERMENULOOP
, sent
|wparam
|lparam
, 0, 0 },
12441 { WM_INITMENU
, sent
|lparam
, 0, 0 },
12442 { WM_MENUSELECT
, sent
|wparam
, MAKEWPARAM(0,MF_HILITE
|MF_POPUP
) },
12443 { WM_INITMENUPOPUP
, sent
|lparam
, 0, 0 },
12444 { WM_MENUSELECT
, sent
|wparam
|optional
, MAKEWPARAM(0,MF_HILITE
|MF_POPUP
) }, /* Win9x */
12445 { WM_INITMENUPOPUP
, sent
|lparam
|optional
, 0, 0 }, /* Win9x */
12446 { HCBT_CREATEWND
, hook
},
12447 { WM_MENUSELECT
, sent
}, /*|wparam, MAKEWPARAM(0,MF_HILITE|MF_POPUP) - XP
12448 |wparam, MAKEWPARAM(100,MF_HILITE) - Win9x */
12449 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'F', 0xf0000001 },
12450 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xd0000001 },
12451 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_RIGHT
, 0x10000001 },
12452 { WM_INITMENUPOPUP
, sent
|lparam
|optional
, 0, 0 }, /* Win9x doesn't send it */
12453 { HCBT_CREATEWND
, hook
|optional
}, /* Win9x doesn't send it */
12454 { WM_MENUSELECT
, sent
|wparam
|optional
, MAKEWPARAM(100,MF_HILITE
) },
12455 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_RIGHT
, 0xd0000001 },
12456 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_RETURN
, 0x10000001 },
12457 { HCBT_DESTROYWND
, hook
},
12458 { WM_UNINITMENUPOPUP
, sent
|lparam
, 0, 0 },
12459 { HCBT_DESTROYWND
, hook
|optional
}, /* Win9x doesn't send it */
12460 { WM_UNINITMENUPOPUP
, sent
|lparam
, 0, 0 },
12461 { WM_MENUSELECT
, sent
|wparam
|lparam
, MAKEWPARAM(0,0xffff), 0 },
12462 { WM_EXITMENULOOP
, sent
|wparam
|lparam
, 0, 0 },
12463 { WM_COMMAND
, sent
|wparam
|lparam
, 100, 0 },
12464 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_RETURN
, 0xc0000001 },
12465 { WM_KEYUP
, sent
|wparam
|lparam
, VK_RETURN
, 0xc0000001 },
12469 static const struct message wm_single_menu_item
[] =
12471 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 },
12472 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
12473 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'Q', 0x20000001 },
12474 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, 'Q', 0x20000001 },
12475 { WM_SYSCHAR
, sent
|wparam
|lparam
, 'q', 0x20000001 },
12476 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_KEYMENU
, 'q' },
12477 { WM_ENTERMENULOOP
, sent
|wparam
|lparam
, 0, 0 },
12478 { WM_INITMENU
, sent
|lparam
, 0, 0 },
12479 { WM_MENUSELECT
, sent
|wparam
|optional
, MAKEWPARAM(300,MF_HILITE
) },
12480 { WM_MENUSELECT
, sent
|wparam
|lparam
, MAKEWPARAM(0,0xffff), 0 },
12481 { WM_EXITMENULOOP
, sent
|wparam
|lparam
, 0, 0 },
12482 { WM_MENUCOMMAND
, sent
},
12483 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'Q', 0xe0000001 },
12484 { WM_SYSKEYUP
, sent
|wparam
|lparam
, 'Q', 0xe0000001 },
12485 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xc0000001 },
12486 { WM_KEYUP
, sent
|wparam
|lparam
, VK_MENU
, 0xc0000001 },
12488 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_ESCAPE
, 1 },
12489 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_ESCAPE
, 1 },
12490 { WM_CHAR
, sent
|wparam
|lparam
, VK_ESCAPE
, 0x00000001 },
12491 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_ESCAPE
, 0xc0000001 },
12492 { WM_KEYUP
, sent
|wparam
|lparam
, VK_ESCAPE
, 0xc0000001 },
12496 static LRESULT WINAPI
parent_menu_proc(HWND hwnd
, UINT message
, WPARAM wp
, LPARAM lp
)
12498 if (message
== WM_ENTERIDLE
||
12499 message
== WM_INITMENU
||
12500 message
== WM_INITMENUPOPUP
||
12501 message
== WM_MENUSELECT
||
12502 message
== WM_PARENTNOTIFY
||
12503 message
== WM_ENTERMENULOOP
||
12504 message
== WM_EXITMENULOOP
||
12505 message
== WM_UNINITMENUPOPUP
||
12506 message
== WM_KEYDOWN
||
12507 message
== WM_KEYUP
||
12508 message
== WM_CHAR
||
12509 message
== WM_SYSKEYDOWN
||
12510 message
== WM_SYSKEYUP
||
12511 message
== WM_SYSCHAR
||
12512 message
== WM_COMMAND
||
12513 message
== WM_MENUCOMMAND
)
12515 struct recvd_message msg
;
12518 msg
.message
= message
;
12519 msg
.flags
= sent
|wparam
|lparam
;
12522 msg
.descr
= "parent_menu_proc";
12526 return DefWindowProcA(hwnd
, message
, wp
, lp
);
12529 static void set_menu_style(HMENU hmenu
, DWORD style
)
12534 mi
.cbSize
= sizeof(mi
);
12535 mi
.fMask
= MIM_STYLE
;
12536 mi
.dwStyle
= style
;
12537 SetLastError(0xdeadbeef);
12538 ret
= pSetMenuInfo(hmenu
, &mi
);
12539 ok(ret
, "SetMenuInfo error %u\n", GetLastError());
12542 static DWORD
get_menu_style(HMENU hmenu
)
12547 mi
.cbSize
= sizeof(mi
);
12548 mi
.fMask
= MIM_STYLE
;
12550 SetLastError(0xdeadbeef);
12551 ret
= pGetMenuInfo(hmenu
, &mi
);
12552 ok(ret
, "GetMenuInfo error %u\n", GetLastError());
12557 static void test_menu_messages(void)
12561 HMENU hmenu
, hmenu_popup
;
12565 if (!pGetMenuInfo
|| !pSetMenuInfo
)
12567 win_skip("GetMenuInfo and/or SetMenuInfo are not available\n");
12571 cls
.lpfnWndProc
= parent_menu_proc
;
12572 cls
.cbClsExtra
= 0;
12573 cls
.cbWndExtra
= 0;
12574 cls
.hInstance
= GetModuleHandleA(0);
12576 cls
.hCursor
= LoadCursorA(0, (LPCSTR
)IDC_ARROW
);
12577 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
12578 cls
.lpszMenuName
= NULL
;
12579 cls
.lpszClassName
= "TestMenuClass";
12580 UnregisterClassA(cls
.lpszClassName
, cls
.hInstance
);
12581 if (!RegisterClassA(&cls
)) assert(0);
12583 SetLastError(0xdeadbeef);
12584 hwnd
= CreateWindowExA(0, "TestMenuClass", NULL
, WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
12585 100, 100, 200, 200, 0, 0, 0, NULL
);
12586 ok(hwnd
!= 0, "LoadMenuA error %u\n", GetLastError());
12588 SetLastError(0xdeadbeef);
12589 hmenu
= LoadMenuA(GetModuleHandleA(NULL
), MAKEINTRESOURCEA(1));
12590 ok(hmenu
!= 0, "LoadMenuA error %u\n", GetLastError());
12592 SetMenu(hwnd
, hmenu
);
12593 SetForegroundWindow( hwnd
);
12595 set_menu_style(hmenu
, MNS_NOTIFYBYPOS
);
12596 style
= get_menu_style(hmenu
);
12597 ok(style
== MNS_NOTIFYBYPOS
, "expected MNS_NOTIFYBYPOS, got %u\n", style
);
12599 hmenu_popup
= GetSubMenu(hmenu
, 0);
12600 ok(hmenu_popup
!= 0, "GetSubMenu returned 0 for submenu 0\n");
12601 style
= get_menu_style(hmenu_popup
);
12602 ok(style
== 0, "expected 0, got %u\n", style
);
12604 hmenu_popup
= GetSubMenu(hmenu_popup
, 0);
12605 ok(hmenu_popup
!= 0, "GetSubMenu returned 0 for submenu 0\n");
12606 style
= get_menu_style(hmenu_popup
);
12607 ok(style
== 0, "expected 0, got %u\n", style
);
12610 trace("testing a popup menu command\n");
12612 keybd_event(VK_MENU
, 0, 0, 0);
12613 keybd_event('E', 0, 0, 0);
12614 keybd_event('E', 0, KEYEVENTF_KEYUP
, 0);
12615 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
12616 keybd_event(VK_RETURN
, 0, 0, 0);
12617 keybd_event(VK_RETURN
, 0, KEYEVENTF_KEYUP
, 0);
12618 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
))
12620 TranslateMessage(&msg
);
12621 DispatchMessageA(&msg
);
12623 if (!sequence_cnt
) /* we didn't get any message */
12625 skip( "queuing key events not supported\n" );
12628 /* win98 queues only a WM_KEYUP and doesn't start menu tracking */
12629 if (sequence
[0].message
== WM_KEYUP
&& sequence
[0].wParam
== VK_MENU
)
12631 win_skip( "menu tracking through VK_MENU not supported\n" );
12634 ok_sequence(wm_popup_menu_1
, "popup menu command", FALSE
);
12636 /* Alt+F, Right, Enter */
12637 trace("testing submenu of a popup menu command\n");
12639 keybd_event(VK_MENU
, 0, 0, 0);
12640 keybd_event('F', 0, 0, 0);
12641 keybd_event('F', 0, KEYEVENTF_KEYUP
, 0);
12642 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
12643 keybd_event(VK_RIGHT
, 0, 0, 0);
12644 keybd_event(VK_RIGHT
, 0, KEYEVENTF_KEYUP
, 0);
12645 keybd_event(VK_RETURN
, 0, 0, 0);
12646 keybd_event(VK_RETURN
, 0, KEYEVENTF_KEYUP
, 0);
12647 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
))
12649 TranslateMessage(&msg
);
12650 DispatchMessageA(&msg
);
12652 ok_sequence(wm_popup_menu_2
, "submenu of a popup menu command", FALSE
);
12654 trace("testing single menu item command\n");
12656 keybd_event(VK_MENU
, 0, 0, 0);
12657 keybd_event('Q', 0, 0, 0);
12658 keybd_event('Q', 0, KEYEVENTF_KEYUP
, 0);
12659 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
12660 keybd_event(VK_ESCAPE
, 0, 0, 0);
12661 keybd_event(VK_ESCAPE
, 0, KEYEVENTF_KEYUP
, 0);
12662 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
))
12664 TranslateMessage(&msg
);
12665 DispatchMessageA(&msg
);
12667 ok_sequence(wm_single_menu_item
, "single menu item command", FALSE
);
12669 set_menu_style(hmenu
, 0);
12670 style
= get_menu_style(hmenu
);
12671 ok(style
== 0, "expected 0, got %u\n", style
);
12673 hmenu_popup
= GetSubMenu(hmenu
, 0);
12674 ok(hmenu_popup
!= 0, "GetSubMenu returned 0 for submenu 0\n");
12675 set_menu_style(hmenu_popup
, MNS_NOTIFYBYPOS
);
12676 style
= get_menu_style(hmenu_popup
);
12677 ok(style
== MNS_NOTIFYBYPOS
, "expected MNS_NOTIFYBYPOS, got %u\n", style
);
12679 hmenu_popup
= GetSubMenu(hmenu_popup
, 0);
12680 ok(hmenu_popup
!= 0, "GetSubMenu returned 0 for submenu 0\n");
12681 style
= get_menu_style(hmenu_popup
);
12682 ok(style
== 0, "expected 0, got %u\n", style
);
12684 /* Alt+F, Right, Enter */
12685 trace("testing submenu of a popup menu command\n");
12687 keybd_event(VK_MENU
, 0, 0, 0);
12688 keybd_event('F', 0, 0, 0);
12689 keybd_event('F', 0, KEYEVENTF_KEYUP
, 0);
12690 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
12691 keybd_event(VK_RIGHT
, 0, 0, 0);
12692 keybd_event(VK_RIGHT
, 0, KEYEVENTF_KEYUP
, 0);
12693 keybd_event(VK_RETURN
, 0, 0, 0);
12694 keybd_event(VK_RETURN
, 0, KEYEVENTF_KEYUP
, 0);
12695 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
))
12697 TranslateMessage(&msg
);
12698 DispatchMessageA(&msg
);
12700 ok_sequence(wm_popup_menu_3
, "submenu of a popup menu command", FALSE
);
12703 DestroyWindow(hwnd
);
12704 DestroyMenu(hmenu
);
12708 static void test_paintingloop(void)
12712 paint_loop_done
= FALSE
;
12713 hwnd
= CreateWindowExA(0x0,"PaintLoopWindowClass",
12714 "PaintLoopWindowClass",WS_OVERLAPPEDWINDOW
,
12715 100, 100, 100, 100, 0, 0, 0, NULL
);
12716 ok(hwnd
!= 0, "PaintLoop window error %u\n", GetLastError());
12717 ShowWindow(hwnd
,SW_NORMAL
);
12720 while (!paint_loop_done
)
12723 if (PeekMessageA(&msg
, 0, 0, 0, 1))
12725 TranslateMessage(&msg
);
12726 DispatchMessageA(&msg
);
12729 DestroyWindow(hwnd
);
12732 static void test_defwinproc(void)
12736 BOOL gotwmquit
= FALSE
;
12737 hwnd
= CreateWindowExA(0, "static", "test_defwndproc", WS_POPUP
, 0,0,0,0,0,0,0, NULL
);
12739 DefWindowProcA( hwnd
, WM_ENDSESSION
, 1, 0);
12740 while (PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
)) {
12741 if( msg
.message
== WM_QUIT
) gotwmquit
= TRUE
;
12742 DispatchMessageA( &msg
);
12744 ok(!gotwmquit
, "Unexpected WM_QUIT message!\n");
12745 DestroyWindow( hwnd
);
12748 #define clear_clipboard(hwnd) clear_clipboard_(__LINE__, (hwnd))
12749 static void clear_clipboard_(int line
, HWND hWnd
)
12752 succ
= OpenClipboard(hWnd
);
12753 ok_(__FILE__
, line
)(succ
, "OpenClipboard failed, err=%u\n", GetLastError());
12754 succ
= EmptyClipboard();
12755 ok_(__FILE__
, line
)(succ
, "EmptyClipboard failed, err=%u\n", GetLastError());
12756 succ
= CloseClipboard();
12757 ok_(__FILE__
, line
)(succ
, "CloseClipboard failed, err=%u\n", GetLastError());
12760 #define expect_HWND(expected, got) expect_HWND_(__LINE__, (expected), (got))
12761 static void expect_HWND_(int line
, HWND expected
, HWND got
)
12763 ok_(__FILE__
, line
)(got
==expected
, "Expected %p, got %p\n", expected
, got
);
12766 static WNDPROC pOldViewerProc
;
12768 static LRESULT CALLBACK
recursive_viewer_proc(HWND hWnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
12770 static BOOL recursion_guard
;
12772 if (message
== WM_DRAWCLIPBOARD
&& !recursion_guard
)
12774 recursion_guard
= TRUE
;
12775 clear_clipboard(hWnd
);
12776 recursion_guard
= FALSE
;
12778 return CallWindowProcA(pOldViewerProc
, hWnd
, message
, wParam
, lParam
);
12781 static void test_clipboard_viewers(void)
12783 static struct message wm_change_cb_chain
[] =
12785 { WM_CHANGECBCHAIN
, sent
|wparam
|lparam
, 0, 0 },
12788 static const struct message wm_clipboard_destroyed
[] =
12790 { WM_DESTROYCLIPBOARD
, sent
|wparam
|lparam
, 0, 0 },
12793 static struct message wm_clipboard_changed
[] =
12795 { WM_DRAWCLIPBOARD
, sent
|wparam
|lparam
, 0, 0 },
12798 static struct message wm_clipboard_changed_and_owned
[] =
12800 { WM_DESTROYCLIPBOARD
, sent
|wparam
|lparam
, 0, 0 },
12801 { WM_DRAWCLIPBOARD
, sent
|wparam
|lparam
, 0, 0 },
12805 HINSTANCE hInst
= GetModuleHandleA(NULL
);
12806 HWND hWnd1
, hWnd2
, hWnd3
;
12810 hWnd1
= CreateWindowExA(0, "TestWindowClass", "Clipboard viewer test wnd 1",
12811 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
| WS_MAXIMIZEBOX
,
12812 CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
,
12813 GetDesktopWindow(), NULL
, hInst
, NULL
);
12814 hWnd2
= CreateWindowExA(0, "SimpleWindowClass", "Clipboard viewer test wnd 2",
12815 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
| WS_MAXIMIZEBOX
,
12816 CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
,
12817 GetDesktopWindow(), NULL
, hInst
, NULL
);
12818 hWnd3
= CreateWindowExA(0, "SimpleWindowClass", "Clipboard viewer test wnd 3",
12819 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
| WS_MAXIMIZEBOX
,
12820 CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
,
12821 GetDesktopWindow(), NULL
, hInst
, NULL
);
12822 trace("clipbd viewers: hWnd1=%p, hWnd2=%p, hWnd3=%p\n", hWnd1
, hWnd2
, hWnd3
);
12823 assert(hWnd1
&& hWnd2
&& hWnd3
);
12827 /* Test getting the clipboard viewer and setting the viewer to NULL. */
12828 hOrigViewer
= GetClipboardViewer();
12829 hRet
= SetClipboardViewer(NULL
);
12830 ok_sequence(WmEmptySeq
, "set viewer to NULL", FALSE
);
12831 expect_HWND(hOrigViewer
, hRet
);
12832 expect_HWND(NULL
, GetClipboardViewer());
12834 /* Test registering hWnd1 as a viewer. */
12835 hRet
= SetClipboardViewer(hWnd1
);
12836 wm_clipboard_changed
[0].wParam
= (WPARAM
) GetClipboardOwner();
12837 ok_sequence(wm_clipboard_changed
, "set viewer NULL->1", FALSE
);
12838 expect_HWND(NULL
, hRet
);
12839 expect_HWND(hWnd1
, GetClipboardViewer());
12841 /* Test that changing the clipboard actually refreshes the registered viewer. */
12842 clear_clipboard(hWnd1
);
12843 wm_clipboard_changed
[0].wParam
= (WPARAM
) GetClipboardOwner();
12844 ok_sequence(wm_clipboard_changed
, "clear clipbd (viewer=owner=1)", FALSE
);
12846 /* Again, but with different owner. */
12847 clear_clipboard(hWnd2
);
12848 wm_clipboard_changed_and_owned
[1].wParam
= (WPARAM
) GetClipboardOwner();
12849 ok_sequence(wm_clipboard_changed_and_owned
, "clear clipbd (viewer=1, owner=2)", FALSE
);
12851 /* Test re-registering same window. */
12852 hRet
= SetClipboardViewer(hWnd1
);
12853 wm_clipboard_changed
[0].wParam
= (WPARAM
) GetClipboardOwner();
12854 ok_sequence(wm_clipboard_changed
, "set viewer 1->1", FALSE
);
12855 expect_HWND(hWnd1
, hRet
);
12856 expect_HWND(hWnd1
, GetClipboardViewer());
12858 /* Test ChangeClipboardChain. */
12859 ChangeClipboardChain(hWnd2
, hWnd3
);
12860 wm_change_cb_chain
[0].wParam
= (WPARAM
) hWnd2
;
12861 wm_change_cb_chain
[0].lParam
= (LPARAM
) hWnd3
;
12862 ok_sequence(wm_change_cb_chain
, "change chain (viewer=1, remove=2, next=3)", FALSE
);
12863 expect_HWND(hWnd1
, GetClipboardViewer());
12865 ChangeClipboardChain(hWnd2
, NULL
);
12866 wm_change_cb_chain
[0].wParam
= (WPARAM
) hWnd2
;
12867 wm_change_cb_chain
[0].lParam
= 0;
12868 ok_sequence(wm_change_cb_chain
, "change chain (viewer=1, remove=2, next=NULL)", FALSE
);
12869 expect_HWND(hWnd1
, GetClipboardViewer());
12871 ChangeClipboardChain(NULL
, hWnd2
);
12872 ok_sequence(WmEmptySeq
, "change chain (viewer=1, remove=NULL, next=2)", TRUE
);
12873 expect_HWND(hWnd1
, GetClipboardViewer());
12875 /* Actually change clipboard viewer with ChangeClipboardChain. */
12876 ChangeClipboardChain(hWnd1
, hWnd2
);
12877 ok_sequence(WmEmptySeq
, "change chain (viewer=remove=1, next=2)", FALSE
);
12878 expect_HWND(hWnd2
, GetClipboardViewer());
12880 /* Test that no refresh messages are sent when viewer has unregistered. */
12881 clear_clipboard(hWnd2
);
12882 ok_sequence(WmEmptySeq
, "clear clipd (viewer=2, owner=1)", FALSE
);
12884 /* Register hWnd1 again. */
12885 ChangeClipboardChain(hWnd2
, hWnd1
);
12886 ok_sequence(WmEmptySeq
, "change chain (viewer=remove=2, next=1)", FALSE
);
12887 expect_HWND(hWnd1
, GetClipboardViewer());
12889 /* Subclass hWnd1 so that when it receives a WM_DRAWCLIPBOARD message, it
12890 * changes the clipboard. When this happens, the system shouldn't send
12891 * another WM_DRAWCLIPBOARD (as this could cause an infinite loop).
12893 pOldViewerProc
= (WNDPROC
) SetWindowLongPtrA(hWnd1
, GWLP_WNDPROC
, (LONG_PTR
) recursive_viewer_proc
);
12894 clear_clipboard(hWnd2
);
12895 /* The clipboard owner is changed in recursive_viewer_proc: */
12896 wm_clipboard_changed
[0].wParam
= (WPARAM
) hWnd2
;
12897 ok_sequence(wm_clipboard_changed
, "recursive clear clipbd (viewer=1, owner=2)", TRUE
);
12899 /* Test unregistering. */
12900 ChangeClipboardChain(hWnd1
, NULL
);
12901 ok_sequence(WmEmptySeq
, "change chain (viewer=remove=1, next=NULL)", FALSE
);
12902 expect_HWND(NULL
, GetClipboardViewer());
12904 clear_clipboard(hWnd1
);
12905 ok_sequence(wm_clipboard_destroyed
, "clear clipbd (no viewer, owner=1)", FALSE
);
12907 DestroyWindow(hWnd1
);
12908 DestroyWindow(hWnd2
);
12909 DestroyWindow(hWnd3
);
12910 SetClipboardViewer(hOrigViewer
);
12913 static void test_PostMessage(void)
12915 static const struct
12921 { HWND_TOP
/* 0 */, TRUE
},
12922 { HWND_BROADCAST
, TRUE
},
12923 { HWND_BOTTOM
, TRUE
},
12924 { HWND_TOPMOST
, TRUE
},
12925 { HWND_NOTOPMOST
, FALSE
},
12926 { HWND_MESSAGE
, FALSE
},
12927 { (HWND
)0xdeadbeef, FALSE
}
12933 static const WCHAR staticW
[] = {'s','t','a','t','i','c',0};
12935 SetLastError(0xdeadbeef);
12936 hwnd
= CreateWindowExW(0, staticW
, NULL
, WS_POPUP
, 0,0,0,0,0,0,0, NULL
);
12937 if (!hwnd
&& GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
)
12939 win_skip("Skipping some PostMessage tests on Win9x/WinMe\n");
12946 PostMessageA(hwnd
, WM_USER
+1, 0x1234, 0x5678);
12947 PostMessageA(0, WM_USER
+2, 0x5678, 0x1234);
12949 for (i
= 0; i
< sizeof(data
)/sizeof(data
[0]); i
++)
12951 memset(&msg
, 0xab, sizeof(msg
));
12952 ret
= PeekMessageA(&msg
, data
[i
].hwnd
, 0, 0, PM_NOREMOVE
);
12953 ok(ret
== data
[i
].ret
, "%d: hwnd %p expected %d, got %d\n", i
, data
[i
].hwnd
, data
[i
].ret
, ret
);
12957 ok(ret
&& msg
.hwnd
== 0 && msg
.message
== WM_USER
+2 &&
12958 msg
.wParam
== 0x5678 && msg
.lParam
== 0x1234,
12959 "%d: got ret %d hwnd %p msg %04x wParam %08lx lParam %08lx instead of TRUE/0/WM_USER+2/0x5678/0x1234\n",
12960 i
, ret
, msg
.hwnd
, msg
.message
, msg
.wParam
, msg
.lParam
);
12962 ok(ret
&& msg
.hwnd
== hwnd
&& msg
.message
== WM_USER
+1 &&
12963 msg
.wParam
== 0x1234 && msg
.lParam
== 0x5678,
12964 "%d: got ret %d hwnd %p msg %04x wParam %08lx lParam %08lx instead of TRUE/%p/WM_USER+1/0x1234/0x5678\n",
12965 i
, ret
, msg
.hwnd
, msg
.message
, msg
.wParam
, msg
.lParam
, msg
.hwnd
);
12969 DestroyWindow(hwnd
);
12973 static const struct
12977 } wait_idle_expect
[] =
12979 /* 0 */ { WAIT_TIMEOUT
, WAIT_TIMEOUT
, FALSE
},
12980 { WAIT_TIMEOUT
, 0, FALSE
},
12981 { WAIT_TIMEOUT
, 0, FALSE
},
12982 { WAIT_TIMEOUT
, WAIT_TIMEOUT
, FALSE
},
12983 { WAIT_TIMEOUT
, WAIT_TIMEOUT
, FALSE
},
12984 /* 5 */ { WAIT_TIMEOUT
, 0, FALSE
},
12985 { WAIT_TIMEOUT
, 0, FALSE
},
12986 { WAIT_TIMEOUT
, WAIT_TIMEOUT
, FALSE
},
12989 /* 10 */ { 0, 0, FALSE
},
12991 { 0, WAIT_TIMEOUT
, FALSE
},
12994 /* 15 */ { 0, 0, FALSE
},
12995 { WAIT_TIMEOUT
, 0, FALSE
},
12996 { WAIT_TIMEOUT
, 0, FALSE
},
12997 { WAIT_TIMEOUT
, 0, FALSE
},
12998 { WAIT_TIMEOUT
, 0, FALSE
},
12999 /* 20 */ { WAIT_TIMEOUT
, 0, FALSE
},
13002 static DWORD CALLBACK
do_wait_idle_child_thread( void *arg
)
13006 PeekMessageA( &msg
, 0, 0, 0, PM_NOREMOVE
);
13008 MsgWaitForMultipleObjects( 0, NULL
, FALSE
, 100, QS_ALLINPUT
);
13012 static void do_wait_idle_child( int arg
)
13019 HANDLE start_event
= OpenEventA( EVENT_ALL_ACCESS
, FALSE
, "test_WaitForInputIdle_start" );
13020 HANDLE end_event
= OpenEventA( EVENT_ALL_ACCESS
, FALSE
, "test_WaitForInputIdle_end" );
13022 memset( &cls
, 0, sizeof(cls
) );
13023 cls
.lpfnWndProc
= DefWindowProcA
;
13024 cls
.hbrBackground
= (HBRUSH
)(COLOR_WINDOW
+ 1);
13025 cls
.hCursor
= LoadCursorA(0, (LPCSTR
)IDC_ARROW
);
13026 cls
.lpszClassName
= "TestClass";
13027 RegisterClassA( &cls
);
13029 PeekMessageA( &msg
, 0, 0, 0, PM_NOREMOVE
); /* create the msg queue */
13031 ok( start_event
!= 0, "failed to create start event, error %u\n", GetLastError() );
13032 ok( end_event
!= 0, "failed to create end event, error %u\n", GetLastError() );
13037 SetEvent( start_event
);
13040 SetEvent( start_event
);
13042 PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
);
13045 SetEvent( start_event
);
13047 PeekMessageA( &msg
, 0, 0, 0, PM_NOREMOVE
);
13048 PostThreadMessageA( GetCurrentThreadId(), WM_COMMAND
, 0x1234, 0xabcd );
13049 PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
);
13052 SetEvent( start_event
);
13054 SendMessageA( HWND_BROADCAST
, WM_WININICHANGE
, 0, 0 );
13057 SetEvent( start_event
);
13059 hwnd
= CreateWindowExA(0, "TestClass", NULL
, WS_POPUP
|WS_VISIBLE
, 0, 0, 10, 10, 0, 0, 0, NULL
);
13060 while (PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
|PM_NOYIELD
)) DispatchMessageA( &msg
);
13063 SetEvent( start_event
);
13065 hwnd
= CreateWindowExA(0, "TestClass", NULL
, WS_POPUP
|WS_VISIBLE
, 0, 0, 10, 10, 0, 0, 0, NULL
);
13066 while (PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA( &msg
);
13069 SetEvent( start_event
);
13071 hwnd
= CreateWindowExA(0, "TestClass", NULL
, WS_POPUP
|WS_VISIBLE
, 0, 0, 10, 10, 0, 0, 0, NULL
);
13072 while (PeekMessageA( &msg
, 0, 0, 0, PM_NOREMOVE
))
13074 GetMessageA( &msg
, 0, 0, 0 );
13075 DispatchMessageA( &msg
);
13079 SetEvent( start_event
);
13081 hwnd
= CreateWindowExA(0, "TestClass", NULL
, WS_POPUP
|WS_VISIBLE
, 0, 0, 10, 10, 0, 0, 0, NULL
);
13082 SetTimer( hwnd
, 3, 1, NULL
);
13084 while (PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
|PM_NOYIELD
)) DispatchMessageA( &msg
);
13087 SetEvent( start_event
);
13089 PeekMessageA( &msg
, 0, 0, 0, PM_NOREMOVE
);
13090 MsgWaitForMultipleObjects( 0, NULL
, FALSE
, 100, QS_ALLINPUT
);
13093 SetEvent( start_event
);
13095 hwnd
= CreateWindowExA(0, "TestClass", NULL
, WS_POPUP
|WS_VISIBLE
, 0, 0, 10, 10, 0, 0, 0, NULL
);
13096 while (PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA( &msg
);
13097 for (;;) GetMessageA( &msg
, 0, 0, 0 );
13100 SetEvent( start_event
);
13102 hwnd
= CreateWindowExA(0, "TestClass", NULL
, WS_POPUP
|WS_VISIBLE
, 0, 0, 10, 10, 0, 0, 0, NULL
);
13103 SetTimer( hwnd
, 3, 1, NULL
);
13105 while (PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA( &msg
);
13108 SetEvent( start_event
);
13110 return; /* exiting the process makes WaitForInputIdle return success too */
13112 PeekMessageA( &msg
, 0, 0, 0, PM_NOREMOVE
);
13114 MsgWaitForMultipleObjects( 0, NULL
, FALSE
, 100, QS_ALLINPUT
);
13115 SetEvent( start_event
);
13118 SetEvent( start_event
);
13119 PeekMessageA( &msg
, 0, 0, 0, PM_NOREMOVE
);
13121 thread
= CreateThread( NULL
, 0, do_wait_idle_child_thread
, NULL
, 0, &id
);
13122 WaitForSingleObject( thread
, 10000 );
13123 CloseHandle( thread
);
13126 SetEvent( start_event
);
13128 PeekMessageA( &msg
, HWND_TOPMOST
, 0, 0, PM_NOREMOVE
);
13131 SetEvent( start_event
);
13133 PeekMessageA( &msg
, HWND_BROADCAST
, 0, 0, PM_NOREMOVE
);
13136 SetEvent( start_event
);
13138 PeekMessageA( &msg
, HWND_BOTTOM
, 0, 0, PM_NOREMOVE
);
13141 SetEvent( start_event
);
13143 PeekMessageA( &msg
, (HWND
)0xdeadbeef, 0, 0, PM_NOREMOVE
);
13146 SetEvent( start_event
);
13148 PeekMessageA( &msg
, HWND_NOTOPMOST
, 0, 0, PM_NOREMOVE
);
13151 SetEvent( start_event
);
13153 PeekMessageA( &msg
, HWND_MESSAGE
, 0, 0, PM_NOREMOVE
);
13156 SetEvent( start_event
);
13158 PeekMessageA( &msg
, GetDesktopWindow(), 0, 0, PM_NOREMOVE
);
13161 WaitForSingleObject( end_event
, 2000 );
13162 CloseHandle( start_event
);
13163 CloseHandle( end_event
);
13164 if (hwnd
) DestroyWindow( hwnd
);
13167 static LRESULT CALLBACK
wait_idle_proc( HWND hwnd
, UINT msg
, WPARAM wp
, LPARAM lp
)
13169 if (msg
== WM_WININICHANGE
) Sleep( 200 ); /* make sure the child waits */
13170 return DefWindowProcA( hwnd
, msg
, wp
, lp
);
13173 static DWORD CALLBACK
wait_idle_thread( void *arg
)
13179 memset( &cls
, 0, sizeof(cls
) );
13180 cls
.lpfnWndProc
= wait_idle_proc
;
13181 cls
.hbrBackground
= (HBRUSH
)(COLOR_WINDOW
+ 1);
13182 cls
.hCursor
= LoadCursorA(0, (LPCSTR
)IDC_ARROW
);
13183 cls
.lpszClassName
= "TestClass";
13184 RegisterClassA( &cls
);
13186 hwnd
= CreateWindowExA(0, "TestClass", NULL
, WS_POPUP
, 0, 0, 10, 10, 0, 0, 0, NULL
);
13187 while (GetMessageA( &msg
, 0, 0, 0 )) DispatchMessageA( &msg
);
13188 DestroyWindow(hwnd
);
13192 static void test_WaitForInputIdle( char *argv0
)
13194 char path
[MAX_PATH
];
13195 PROCESS_INFORMATION pi
;
13196 STARTUPINFOA startup
;
13198 HANDLE start_event
, end_event
, thread
;
13201 const IMAGE_DOS_HEADER
*dos
= (const IMAGE_DOS_HEADER
*)GetModuleHandleA(0);
13202 const IMAGE_NT_HEADERS
*nt
= (const IMAGE_NT_HEADERS
*)((const char *)dos
+ dos
->e_lfanew
);
13203 BOOL console_app
= (nt
->OptionalHeader
.Subsystem
!= IMAGE_SUBSYSTEM_WINDOWS_GUI
);
13205 if (console_app
) /* build the test with -mwindows for better coverage */
13206 trace( "not built as a GUI app, WaitForInputIdle may not be fully tested\n" );
13208 start_event
= CreateEventA(NULL
, 0, 0, "test_WaitForInputIdle_start");
13209 end_event
= CreateEventA(NULL
, 0, 0, "test_WaitForInputIdle_end");
13210 ok(start_event
!= 0, "failed to create start event, error %u\n", GetLastError());
13211 ok(end_event
!= 0, "failed to create end event, error %u\n", GetLastError());
13213 memset( &startup
, 0, sizeof(startup
) );
13214 startup
.cb
= sizeof(startup
);
13215 startup
.dwFlags
= STARTF_USESHOWWINDOW
;
13216 startup
.wShowWindow
= SW_SHOWNORMAL
;
13218 thread
= CreateThread( NULL
, 0, wait_idle_thread
, NULL
, 0, &id
);
13220 for (i
= 0; i
< sizeof(wait_idle_expect
)/sizeof(wait_idle_expect
[0]); i
++)
13222 ResetEvent( start_event
);
13223 ResetEvent( end_event
);
13224 sprintf( path
, "%s msg %u", argv0
, i
);
13225 ret
= CreateProcessA( NULL
, path
, NULL
, NULL
, TRUE
, 0, NULL
, NULL
, &startup
, &pi
);
13226 ok( ret
, "CreateProcess '%s' failed err %u.\n", path
, GetLastError() );
13229 ret
= WaitForSingleObject( start_event
, 5000 );
13230 ok( ret
== WAIT_OBJECT_0
, "%u: WaitForSingleObject failed\n", i
);
13231 if (ret
== WAIT_OBJECT_0
)
13233 ret
= WaitForInputIdle( pi
.hProcess
, 1000 );
13234 if (ret
== WAIT_FAILED
)
13236 ret
== wait_idle_expect
[i
].exp
||
13237 broken(ret
== wait_idle_expect
[i
].broken
),
13238 "%u: WaitForInputIdle error %08x expected %08x\n",
13239 i
, ret
, wait_idle_expect
[i
].exp
);
13240 else if (wait_idle_expect
[i
].todo
)
13242 ok( ret
== wait_idle_expect
[i
].exp
|| broken(ret
== wait_idle_expect
[i
].broken
),
13243 "%u: WaitForInputIdle error %08x expected %08x\n",
13244 i
, ret
, wait_idle_expect
[i
].exp
);
13246 ok( ret
== wait_idle_expect
[i
].exp
|| broken(ret
== wait_idle_expect
[i
].broken
),
13247 "%u: WaitForInputIdle error %08x expected %08x\n",
13248 i
, ret
, wait_idle_expect
[i
].exp
);
13249 SetEvent( end_event
);
13250 WaitForSingleObject( pi
.hProcess
, 1000 ); /* give it a chance to exit on its own */
13252 TerminateProcess( pi
.hProcess
, 0 ); /* just in case */
13253 winetest_wait_child_process( pi
.hProcess
);
13254 ret
= WaitForInputIdle( pi
.hProcess
, 100 );
13255 ok( ret
== WAIT_FAILED
, "%u: WaitForInputIdle after exit error %08x\n", i
, ret
);
13256 CloseHandle( pi
.hProcess
);
13257 CloseHandle( pi
.hThread
);
13260 CloseHandle( start_event
);
13261 PostThreadMessageA( id
, WM_QUIT
, 0, 0 );
13262 WaitForSingleObject( thread
, 10000 );
13263 CloseHandle( thread
);
13266 static const struct message WmSetParentSeq_1
[] = {
13267 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
13268 { EVENT_OBJECT_PARENTCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
13269 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
},
13270 { WM_CHILDACTIVATE
, sent
},
13271 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOSIZE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
},
13272 { WM_MOVE
, sent
|defwinproc
|wparam
, 0 },
13273 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
13274 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
13278 static const struct message WmSetParentSeq_2
[] = {
13279 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
13280 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
13281 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
13282 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
13283 { HCBT_SETFOCUS
, hook
|optional
},
13284 { WM_NCACTIVATE
, sent
|wparam
|optional
, 0 },
13285 { WM_ACTIVATE
, sent
|wparam
|optional
, 0 },
13286 { WM_ACTIVATEAPP
, sent
|wparam
|optional
, 0 },
13287 { WM_KILLFOCUS
, sent
|wparam
, 0 },
13288 { EVENT_OBJECT_PARENTCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
13289 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
},
13290 { HCBT_ACTIVATE
, hook
|optional
},
13291 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
13292 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
13293 { WM_NCACTIVATE
, sent
|wparam
|optional
, 1 },
13294 { WM_ACTIVATE
, sent
|wparam
|optional
, 1 },
13295 { HCBT_SETFOCUS
, hook
|optional
},
13296 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
13297 { WM_SETFOCUS
, sent
|optional
|defwinproc
},
13298 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOREDRAW
|SWP_NOSIZE
|SWP_NOCLIENTSIZE
},
13299 { WM_MOVE
, sent
|defwinproc
|wparam
, 0 },
13300 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
13301 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
13302 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
13303 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
13304 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
13309 static void test_SetParent(void)
13311 HWND parent1
, parent2
, child
, popup
;
13314 parent1
= CreateWindowExA(0, "TestParentClass", NULL
, WS_OVERLAPPEDWINDOW
,
13315 100, 100, 200, 200, 0, 0, 0, NULL
);
13316 ok(parent1
!= 0, "Failed to create parent1 window\n");
13318 parent2
= CreateWindowExA(0, "TestParentClass", NULL
, WS_OVERLAPPEDWINDOW
,
13319 400, 100, 200, 200, 0, 0, 0, NULL
);
13320 ok(parent2
!= 0, "Failed to create parent2 window\n");
13322 /* WS_CHILD window */
13323 child
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_CHILD
| WS_VISIBLE
,
13324 10, 10, 150, 150, parent1
, 0, 0, NULL
);
13325 ok(child
!= 0, "Failed to create child window\n");
13327 GetWindowRect(parent1
, &rc
);
13328 trace("parent1 (%d,%d)-(%d,%d)\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
13329 GetWindowRect(child
, &rc_old
);
13330 MapWindowPoints(0, parent1
, (POINT
*)&rc_old
, 2);
13331 trace("child (%d,%d)-(%d,%d)\n", rc_old
.left
, rc_old
.top
, rc_old
.right
, rc_old
.bottom
);
13335 SetParent(child
, parent2
);
13337 ok_sequence(WmSetParentSeq_1
, "SetParent() visible WS_CHILD", TRUE
);
13339 ok(GetWindowLongA(child
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
13340 ok(!IsWindowVisible(child
), "IsWindowVisible() should return FALSE\n");
13342 GetWindowRect(parent2
, &rc
);
13343 trace("parent2 (%d,%d)-(%d,%d)\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
13344 GetWindowRect(child
, &rc
);
13345 MapWindowPoints(0, parent2
, (POINT
*)&rc
, 2);
13346 trace("child (%d,%d)-(%d,%d)\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
13348 ok(EqualRect(&rc_old
, &rc
), "rects do not match (%d,%d-%d,%d) / (%d,%d-%d,%d)\n",
13349 rc_old
.left
, rc_old
.top
, rc_old
.right
, rc_old
.bottom
,
13350 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
13352 /* WS_POPUP window */
13353 popup
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_POPUP
| WS_VISIBLE
,
13354 20, 20, 100, 100, 0, 0, 0, NULL
);
13355 ok(popup
!= 0, "Failed to create popup window\n");
13357 GetWindowRect(popup
, &rc_old
);
13358 trace("popup (%d,%d)-(%d,%d)\n", rc_old
.left
, rc_old
.top
, rc_old
.right
, rc_old
.bottom
);
13362 SetParent(popup
, child
);
13364 ok_sequence(WmSetParentSeq_2
, "SetParent() visible WS_POPUP", TRUE
);
13366 ok(GetWindowLongA(popup
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
13367 ok(!IsWindowVisible(popup
), "IsWindowVisible() should return FALSE\n");
13369 GetWindowRect(child
, &rc
);
13370 trace("parent2 (%d,%d)-(%d,%d)\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
13371 GetWindowRect(popup
, &rc
);
13372 MapWindowPoints(0, child
, (POINT
*)&rc
, 2);
13373 trace("popup (%d,%d)-(%d,%d)\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
13375 ok(EqualRect(&rc_old
, &rc
), "rects do not match (%d,%d-%d,%d) / (%d,%d-%d,%d)\n",
13376 rc_old
.left
, rc_old
.top
, rc_old
.right
, rc_old
.bottom
,
13377 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
13379 DestroyWindow(popup
);
13380 DestroyWindow(child
);
13381 DestroyWindow(parent1
);
13382 DestroyWindow(parent2
);
13387 static const struct message WmKeyReleaseOnly
[] = {
13388 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 0x41, 0x80000001 },
13389 { WM_KEYUP
, sent
|wparam
|lparam
, 0x41, 0x80000001 },
13392 static const struct message WmKeyPressNormal
[] = {
13393 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 0x41, 0x1 },
13394 { WM_KEYDOWN
, sent
|wparam
|lparam
, 0x41, 0x1 },
13397 static const struct message WmKeyPressRepeat
[] = {
13398 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 0x41, 0x40000001 },
13399 { WM_KEYDOWN
, sent
|wparam
|lparam
, 0x41, 0x40000001 },
13402 static const struct message WmKeyReleaseNormal
[] = {
13403 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 0x41, 0xc0000001 },
13404 { WM_KEYUP
, sent
|wparam
|lparam
, 0x41, 0xc0000001 },
13408 static void test_keyflags(void)
13412 BYTE keyboard_state
[256];
13415 test_window
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
13416 100, 100, 200, 200, 0, 0, 0, NULL
);
13421 /* keyup without a keydown */
13422 keybd_event(0x41, 0, KEYEVENTF_KEYUP
, 0);
13423 while (PeekMessageA(&msg
, NULL
, WM_KEYFIRST
, WM_KEYLAST
, PM_REMOVE
))
13424 DispatchMessageA(&msg
);
13425 ok_sequence(WmKeyReleaseOnly
, "key release only", TRUE
);
13427 key_state
= GetAsyncKeyState(0x41);
13428 ok((key_state
& 0x8000) == 0, "unexpected key state %x\n", key_state
);
13430 key_state
= GetKeyState(0x41);
13431 ok((key_state
& 0x8000) == 0, "unexpected key state %x\n", key_state
);
13434 keybd_event(0x41, 0, 0, 0);
13435 while (PeekMessageA(&msg
, NULL
, WM_KEYFIRST
, WM_KEYLAST
, PM_REMOVE
))
13436 DispatchMessageA(&msg
);
13437 ok_sequence(WmKeyPressNormal
, "key press only", FALSE
);
13439 key_state
= GetAsyncKeyState(0x41);
13440 ok((key_state
& 0x8000) == 0x8000, "unexpected key state %x\n", key_state
);
13442 key_state
= GetKeyState(0x41);
13443 ok((key_state
& 0x8000) == 0x8000, "unexpected key state %x\n", key_state
);
13445 /* keydown repeat */
13446 keybd_event(0x41, 0, 0, 0);
13447 while (PeekMessageA(&msg
, NULL
, WM_KEYFIRST
, WM_KEYLAST
, PM_REMOVE
))
13448 DispatchMessageA(&msg
);
13449 ok_sequence(WmKeyPressRepeat
, "key press repeat", FALSE
);
13451 key_state
= GetAsyncKeyState(0x41);
13452 ok((key_state
& 0x8000) == 0x8000, "unexpected key state %x\n", key_state
);
13454 key_state
= GetKeyState(0x41);
13455 ok((key_state
& 0x8000) == 0x8000, "unexpected key state %x\n", key_state
);
13458 keybd_event(0x41, 0, KEYEVENTF_KEYUP
, 0);
13459 while (PeekMessageA(&msg
, NULL
, WM_KEYFIRST
, WM_KEYLAST
, PM_REMOVE
))
13460 DispatchMessageA(&msg
);
13461 ok_sequence(WmKeyReleaseNormal
, "key release repeat", FALSE
);
13463 key_state
= GetAsyncKeyState(0x41);
13464 ok((key_state
& 0x8000) == 0, "unexpected key state %x\n", key_state
);
13466 key_state
= GetKeyState(0x41);
13467 ok((key_state
& 0x8000) == 0, "unexpected key state %x\n", key_state
);
13469 /* set the key state in this thread */
13470 GetKeyboardState(keyboard_state
);
13471 keyboard_state
[0x41] = 0x80;
13472 SetKeyboardState(keyboard_state
);
13474 key_state
= GetAsyncKeyState(0x41);
13475 ok((key_state
& 0x8000) == 0, "unexpected key state %x\n", key_state
);
13478 keybd_event(0x41, 0, 0, 0);
13479 while (PeekMessageA(&msg
, NULL
, WM_KEYFIRST
, WM_KEYLAST
, PM_REMOVE
))
13480 DispatchMessageA(&msg
);
13481 ok_sequence(WmKeyPressRepeat
, "key press after setkeyboardstate", TRUE
);
13483 key_state
= GetAsyncKeyState(0x41);
13484 ok((key_state
& 0x8000) == 0x8000, "unexpected key state %x\n", key_state
);
13486 key_state
= GetKeyState(0x41);
13487 ok((key_state
& 0x8000) == 0x8000, "unexpected key state %x\n", key_state
);
13489 /* clear the key state in this thread */
13490 GetKeyboardState(keyboard_state
);
13491 keyboard_state
[0x41] = 0;
13492 SetKeyboardState(keyboard_state
);
13494 key_state
= GetAsyncKeyState(0x41);
13495 ok((key_state
& 0x8000) == 0x8000, "unexpected key state %x\n", key_state
);
13498 keybd_event(0x41, 0, KEYEVENTF_KEYUP
, 0);
13499 while (PeekMessageA(&msg
, NULL
, WM_KEYFIRST
, WM_KEYLAST
, PM_REMOVE
))
13500 DispatchMessageA(&msg
);
13501 ok_sequence(WmKeyReleaseOnly
, "key release after setkeyboardstate", TRUE
);
13503 key_state
= GetAsyncKeyState(0x41);
13504 ok((key_state
& 0x8000) == 0, "unexpected key state %x\n", key_state
);
13506 key_state
= GetKeyState(0x41);
13507 ok((key_state
& 0x8000) == 0, "unexpected key state %x\n", key_state
);
13509 DestroyWindow(test_window
);
13513 static const struct message WmHotkeyPressLWIN
[] = {
13514 { WM_KEYDOWN
, kbd_hook
|wparam
|lparam
, VK_LWIN
, LLKHF_INJECTED
},
13515 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_LWIN
, 1 },
13516 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_LWIN
, 1 },
13519 static const struct message WmHotkeyPress
[] = {
13520 { WM_KEYDOWN
, kbd_hook
|lparam
, 0, LLKHF_INJECTED
},
13521 { WM_HOTKEY
, sent
|wparam
, 5 },
13524 static const struct message WmHotkeyRelease
[] = {
13525 { WM_KEYUP
, kbd_hook
|lparam
, 0, LLKHF_INJECTED
|LLKHF_UP
},
13526 { HCBT_KEYSKIPPED
, hook
|lparam
|optional
, 0, 0x80000001 },
13527 { WM_KEYUP
, sent
|lparam
, 0, 0x80000001 },
13530 static const struct message WmHotkeyReleaseLWIN
[] = {
13531 { WM_KEYUP
, kbd_hook
|wparam
|lparam
, VK_LWIN
, LLKHF_INJECTED
|LLKHF_UP
},
13532 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_LWIN
, 0xc0000001 },
13533 { WM_KEYUP
, sent
|wparam
|lparam
, VK_LWIN
, 0xc0000001 },
13536 static const struct message WmHotkeyCombined
[] = {
13537 { WM_KEYDOWN
, kbd_hook
|wparam
|lparam
, VK_LWIN
, LLKHF_INJECTED
},
13538 { WM_KEYDOWN
, kbd_hook
|lparam
, 0, LLKHF_INJECTED
},
13539 { WM_KEYUP
, kbd_hook
|lparam
, 0, LLKHF_INJECTED
|LLKHF_UP
},
13540 { WM_KEYUP
, kbd_hook
|wparam
|lparam
, VK_LWIN
, LLKHF_INJECTED
|LLKHF_UP
},
13541 { WM_APP
, sent
, 0, 0 },
13542 { WM_HOTKEY
, sent
|wparam
, 5 },
13543 { WM_APP
+1, sent
, 0, 0 },
13544 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_LWIN
, 1 },
13545 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_LWIN
, 1 },
13546 { HCBT_KEYSKIPPED
, hook
|optional
, 0, 0x80000001 },
13547 { WM_KEYUP
, sent
, 0, 0x80000001 }, /* lparam not checked so the sequence isn't a todo */
13548 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_LWIN
, 0xc0000001 },
13549 { WM_KEYUP
, sent
|wparam
|lparam
, VK_LWIN
, 0xc0000001 },
13552 static const struct message WmHotkeyPrevious
[] = {
13553 { WM_KEYDOWN
, kbd_hook
|wparam
|lparam
, VK_LWIN
, LLKHF_INJECTED
},
13554 { WM_KEYDOWN
, kbd_hook
|lparam
, 0, LLKHF_INJECTED
},
13555 { WM_KEYUP
, kbd_hook
|lparam
, 0, LLKHF_INJECTED
|LLKHF_UP
},
13556 { WM_KEYUP
, kbd_hook
|wparam
|lparam
, VK_LWIN
, LLKHF_INJECTED
|LLKHF_UP
},
13557 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_LWIN
, 1 },
13558 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_LWIN
, 1 },
13559 { HCBT_KEYSKIPPED
, hook
|lparam
|optional
, 0, 1 },
13560 { WM_KEYDOWN
, sent
|lparam
, 0, 1 },
13561 { HCBT_KEYSKIPPED
, hook
|optional
|lparam
, 0, 0xc0000001 },
13562 { WM_KEYUP
, sent
|lparam
, 0, 0xc0000001 },
13563 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_LWIN
, 0xc0000001 },
13564 { WM_KEYUP
, sent
|wparam
|lparam
, VK_LWIN
, 0xc0000001 },
13567 static const struct message WmHotkeyNew
[] = {
13568 { WM_KEYDOWN
, kbd_hook
|lparam
, 0, LLKHF_INJECTED
},
13569 { WM_KEYUP
, kbd_hook
|lparam
, 0, LLKHF_INJECTED
|LLKHF_UP
},
13570 { WM_HOTKEY
, sent
|wparam
, 5 },
13571 { HCBT_KEYSKIPPED
, hook
|optional
, 0, 0x80000001 },
13572 { WM_KEYUP
, sent
, 0, 0x80000001 }, /* lparam not checked so the sequence isn't a todo */
13576 static int hotkey_letter
;
13578 static LRESULT CALLBACK
KeyboardHookProc(int nCode
, WPARAM wParam
, LPARAM lParam
)
13580 struct recvd_message msg
;
13582 if (nCode
== HC_ACTION
)
13584 KBDLLHOOKSTRUCT
*kdbhookstruct
= (KBDLLHOOKSTRUCT
*)lParam
;
13587 msg
.message
= wParam
;
13588 msg
.flags
= kbd_hook
|wparam
|lparam
;
13589 msg
.wParam
= kdbhookstruct
->vkCode
;
13590 msg
.lParam
= kdbhookstruct
->flags
;
13591 msg
.descr
= "KeyboardHookProc";
13594 if (wParam
== WM_KEYUP
|| wParam
== WM_KEYDOWN
)
13596 ok(kdbhookstruct
->vkCode
== VK_LWIN
|| kdbhookstruct
->vkCode
== hotkey_letter
,
13597 "unexpected keycode %x\n", kdbhookstruct
->vkCode
);
13601 return CallNextHookEx(hKBD_hook
, nCode
, wParam
, lParam
);
13604 static void test_hotkey(void)
13606 HWND test_window
, taskbar_window
;
13609 DWORD queue_status
;
13612 SetLastError(0xdeadbeef);
13613 ret
= UnregisterHotKey(NULL
, 0);
13614 ok(ret
== FALSE
, "expected FALSE, got %i\n", ret
);
13615 ok(GetLastError() == ERROR_HOTKEY_NOT_REGISTERED
|| broken(GetLastError() == 0xdeadbeef),
13616 "unexpected error %d\n", GetLastError());
13620 skip("hotkeys not supported\n");
13624 test_window
= CreateWindowExA(0, "HotkeyWindowClass", NULL
, WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
13625 100, 100, 200, 200, 0, 0, 0, NULL
);
13629 SetLastError(0xdeadbeef);
13630 ret
= UnregisterHotKey(test_window
, 0);
13631 ok(ret
== FALSE
, "expected FALSE, got %i\n", ret
);
13632 ok(GetLastError() == ERROR_HOTKEY_NOT_REGISTERED
|| broken(GetLastError() == 0xdeadbeef),
13633 "unexpected error %d\n", GetLastError());
13635 /* Search for a Windows Key + letter combination that hasn't been registered */
13636 for (hotkey_letter
= 0x41; hotkey_letter
<= 0x51; hotkey_letter
++)
13638 SetLastError(0xdeadbeef);
13639 ret
= RegisterHotKey(test_window
, 5, MOD_WIN
, hotkey_letter
);
13647 ok(GetLastError() == ERROR_HOTKEY_ALREADY_REGISTERED
|| broken(GetLastError() == 0xdeadbeef),
13648 "unexpected error %d\n", GetLastError());
13652 if (hotkey_letter
== 0x52)
13654 ok(0, "Couldn't find any free Windows Key + letter combination\n");
13658 hKBD_hook
= SetWindowsHookExA(WH_KEYBOARD_LL
, KeyboardHookProc
, GetModuleHandleA(NULL
), 0);
13659 if (!hKBD_hook
) win_skip("WH_KEYBOARD_LL is not supported\n");
13661 /* Same key combination, different id */
13662 SetLastError(0xdeadbeef);
13663 ret
= RegisterHotKey(test_window
, 4, MOD_WIN
, hotkey_letter
);
13664 ok(ret
== FALSE
, "expected FALSE, got %i\n", ret
);
13665 ok(GetLastError() == ERROR_HOTKEY_ALREADY_REGISTERED
|| broken(GetLastError() == 0xdeadbeef),
13666 "unexpected error %d\n", GetLastError());
13668 /* Same key combination, different window */
13669 SetLastError(0xdeadbeef);
13670 ret
= RegisterHotKey(NULL
, 5, MOD_WIN
, hotkey_letter
);
13671 ok(ret
== FALSE
, "expected FALSE, got %i\n", ret
);
13672 ok(GetLastError() == ERROR_HOTKEY_ALREADY_REGISTERED
|| broken(GetLastError() == 0xdeadbeef),
13673 "unexpected error %d\n", GetLastError());
13675 /* Register the same hotkey twice */
13676 SetLastError(0xdeadbeef);
13677 ret
= RegisterHotKey(test_window
, 5, MOD_WIN
, hotkey_letter
);
13678 ok(ret
== FALSE
, "expected FALSE, got %i\n", ret
);
13679 ok(GetLastError() == ERROR_HOTKEY_ALREADY_REGISTERED
|| broken(GetLastError() == 0xdeadbeef),
13680 "unexpected error %d\n", GetLastError());
13682 /* Window on another thread */
13683 taskbar_window
= FindWindowA("Shell_TrayWnd", NULL
);
13684 if (!taskbar_window
)
13686 skip("no taskbar?\n");
13690 SetLastError(0xdeadbeef);
13691 ret
= RegisterHotKey(taskbar_window
, 5, 0, hotkey_letter
);
13692 ok(ret
== FALSE
, "expected FALSE, got %i\n", ret
);
13693 ok(GetLastError() == ERROR_WINDOW_OF_OTHER_THREAD
|| broken(GetLastError() == 0xdeadbeef),
13694 "unexpected error %d\n", GetLastError());
13697 /* Inject the appropriate key sequence */
13698 keybd_event(VK_LWIN
, 0, 0, 0);
13699 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
))
13700 DispatchMessageA(&msg
);
13701 ok_sequence(WmHotkeyPressLWIN
, "window hotkey press LWIN", FALSE
);
13703 keybd_event(hotkey_letter
, 0, 0, 0);
13704 queue_status
= GetQueueStatus(QS_HOTKEY
);
13705 ok((queue_status
& (QS_HOTKEY
<< 16)) == QS_HOTKEY
<< 16, "expected QS_HOTKEY << 16 set, got %x\n", queue_status
);
13706 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
))
13708 if (msg
.message
== WM_HOTKEY
)
13710 ok(msg
.hwnd
== test_window
, "unexpected hwnd %p\n", msg
.hwnd
);
13711 ok(msg
.lParam
== MAKELPARAM(MOD_WIN
, hotkey_letter
), "unexpected WM_HOTKEY lparam %lx\n", msg
.lParam
);
13713 DispatchMessageA(&msg
);
13715 ok_sequence(WmHotkeyPress
, "window hotkey press", FALSE
);
13717 queue_status
= GetQueueStatus(QS_HOTKEY
);
13718 ok((queue_status
& (QS_HOTKEY
<< 16)) == 0, "expected QS_HOTKEY << 16 cleared, got %x\n", queue_status
);
13720 key_state
= GetAsyncKeyState(hotkey_letter
);
13721 ok((key_state
& 0x8000) == 0x8000, "unexpected key state %x\n", key_state
);
13723 keybd_event(hotkey_letter
, 0, KEYEVENTF_KEYUP
, 0);
13724 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
))
13725 DispatchMessageA(&msg
);
13726 ok_sequence(WmHotkeyRelease
, "window hotkey release", TRUE
);
13728 keybd_event(VK_LWIN
, 0, KEYEVENTF_KEYUP
, 0);
13729 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
))
13730 DispatchMessageA(&msg
);
13731 ok_sequence(WmHotkeyReleaseLWIN
, "window hotkey release LWIN", FALSE
);
13733 /* normal posted WM_HOTKEY messages set QS_HOTKEY */
13734 PostMessageA(test_window
, WM_HOTKEY
, 0, 0);
13735 queue_status
= GetQueueStatus(QS_HOTKEY
);
13736 ok((queue_status
& (QS_HOTKEY
<< 16)) == QS_HOTKEY
<< 16, "expected QS_HOTKEY << 16 set, got %x\n", queue_status
);
13737 queue_status
= GetQueueStatus(QS_POSTMESSAGE
);
13738 ok((queue_status
& (QS_POSTMESSAGE
<< 16)) == QS_POSTMESSAGE
<< 16, "expected QS_POSTMESSAGE << 16 set, got %x\n", queue_status
);
13739 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
))
13740 DispatchMessageA(&msg
);
13743 /* Send and process all messages at once */
13744 PostMessageA(test_window
, WM_APP
, 0, 0);
13745 keybd_event(VK_LWIN
, 0, 0, 0);
13746 keybd_event(hotkey_letter
, 0, 0, 0);
13747 keybd_event(hotkey_letter
, 0, KEYEVENTF_KEYUP
, 0);
13748 keybd_event(VK_LWIN
, 0, KEYEVENTF_KEYUP
, 0);
13750 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
))
13752 if (msg
.message
== WM_HOTKEY
)
13754 ok(msg
.hwnd
== test_window
, "unexpected hwnd %p\n", msg
.hwnd
);
13755 ok(msg
.lParam
== MAKELPARAM(MOD_WIN
, hotkey_letter
), "unexpected WM_HOTKEY lparam %lx\n", msg
.lParam
);
13757 DispatchMessageA(&msg
);
13759 ok_sequence(WmHotkeyCombined
, "window hotkey combined", FALSE
);
13761 /* Register same hwnd/id with different key combination */
13762 ret
= RegisterHotKey(test_window
, 5, 0, hotkey_letter
);
13763 ok(ret
== TRUE
, "expected TRUE, got %i, err=%d\n", ret
, GetLastError());
13765 /* Previous key combination does not work */
13766 keybd_event(VK_LWIN
, 0, 0, 0);
13767 keybd_event(hotkey_letter
, 0, 0, 0);
13768 keybd_event(hotkey_letter
, 0, KEYEVENTF_KEYUP
, 0);
13769 keybd_event(VK_LWIN
, 0, KEYEVENTF_KEYUP
, 0);
13771 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
))
13772 DispatchMessageA(&msg
);
13773 ok_sequence(WmHotkeyPrevious
, "window hotkey previous", FALSE
);
13775 /* New key combination works */
13776 keybd_event(hotkey_letter
, 0, 0, 0);
13777 keybd_event(hotkey_letter
, 0, KEYEVENTF_KEYUP
, 0);
13779 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
))
13781 if (msg
.message
== WM_HOTKEY
)
13783 ok(msg
.hwnd
== test_window
, "unexpected hwnd %p\n", msg
.hwnd
);
13784 ok(msg
.lParam
== MAKELPARAM(0, hotkey_letter
), "unexpected WM_HOTKEY lparam %lx\n", msg
.lParam
);
13786 DispatchMessageA(&msg
);
13788 ok_sequence(WmHotkeyNew
, "window hotkey new", FALSE
);
13790 /* Unregister hotkey properly */
13791 ret
= UnregisterHotKey(test_window
, 5);
13792 ok(ret
== TRUE
, "expected TRUE, got %i, err=%d\n", ret
, GetLastError());
13794 /* Unregister hotkey again */
13795 SetLastError(0xdeadbeef);
13796 ret
= UnregisterHotKey(test_window
, 5);
13797 ok(ret
== FALSE
, "expected FALSE, got %i\n", ret
);
13798 ok(GetLastError() == ERROR_HOTKEY_NOT_REGISTERED
|| broken(GetLastError() == 0xdeadbeef),
13799 "unexpected error %d\n", GetLastError());
13801 /* Register thread hotkey */
13802 ret
= RegisterHotKey(NULL
, 5, MOD_WIN
, hotkey_letter
);
13803 ok(ret
== TRUE
, "expected TRUE, got %i, err=%d\n", ret
, GetLastError());
13805 /* Inject the appropriate key sequence */
13806 keybd_event(VK_LWIN
, 0, 0, 0);
13807 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
))
13809 ok(msg
.hwnd
!= NULL
, "unexpected thread message %x\n", msg
.message
);
13810 DispatchMessageA(&msg
);
13812 ok_sequence(WmHotkeyPressLWIN
, "thread hotkey press LWIN", FALSE
);
13814 keybd_event(hotkey_letter
, 0, 0, 0);
13815 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
))
13817 if (msg
.message
== WM_HOTKEY
)
13819 struct recvd_message message
;
13820 ok(msg
.hwnd
== NULL
, "unexpected hwnd %p\n", msg
.hwnd
);
13821 ok(msg
.lParam
== MAKELPARAM(MOD_WIN
, hotkey_letter
), "unexpected WM_HOTKEY lparam %lx\n", msg
.lParam
);
13822 message
.message
= msg
.message
;
13823 message
.flags
= sent
|wparam
|lparam
;
13824 message
.wParam
= msg
.wParam
;
13825 message
.lParam
= msg
.lParam
;
13826 message
.descr
= "test_hotkey thread message";
13827 add_message(&message
);
13830 ok(msg
.hwnd
!= NULL
, "unexpected thread message %x\n", msg
.message
);
13831 DispatchMessageA(&msg
);
13833 ok_sequence(WmHotkeyPress
, "thread hotkey press", FALSE
);
13835 keybd_event(hotkey_letter
, 0, KEYEVENTF_KEYUP
, 0);
13836 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
))
13838 ok(msg
.hwnd
!= NULL
, "unexpected thread message %x\n", msg
.message
);
13839 DispatchMessageA(&msg
);
13841 ok_sequence(WmHotkeyRelease
, "thread hotkey release", TRUE
);
13843 keybd_event(VK_LWIN
, 0, KEYEVENTF_KEYUP
, 0);
13844 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
))
13846 ok(msg
.hwnd
!= NULL
, "unexpected thread message %x\n", msg
.message
);
13847 DispatchMessageA(&msg
);
13849 ok_sequence(WmHotkeyReleaseLWIN
, "thread hotkey release LWIN", FALSE
);
13851 /* Unregister thread hotkey */
13852 ret
= UnregisterHotKey(NULL
, 5);
13853 ok(ret
== TRUE
, "expected TRUE, got %i, err=%d\n", ret
, GetLastError());
13855 if (hKBD_hook
) UnhookWindowsHookEx(hKBD_hook
);
13859 UnregisterHotKey(NULL
, 5);
13860 UnregisterHotKey(test_window
, 5);
13861 DestroyWindow(test_window
);
13866 static const struct message WmSetFocus_1
[] = {
13867 { HCBT_SETFOCUS
, hook
}, /* child */
13868 { HCBT_ACTIVATE
, hook
}, /* parent */
13869 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|parent
|optional
, 0, 0 },
13870 { WM_WINDOWPOSCHANGING
, sent
|parent
, 0, SWP_NOSIZE
|SWP_NOMOVE
},
13871 { WM_ACTIVATEAPP
, sent
|wparam
|parent
, 1 },
13872 { WM_NCACTIVATE
, sent
|parent
},
13873 { WM_GETTEXT
, sent
|defwinproc
|parent
|optional
},
13874 { WM_GETTEXT
, sent
|defwinproc
|parent
|optional
},
13875 { WM_ACTIVATE
, sent
|wparam
|parent
, 1 },
13876 { HCBT_SETFOCUS
, hook
}, /* parent */
13877 { WM_SETFOCUS
, sent
|defwinproc
|parent
},
13878 { WM_KILLFOCUS
, sent
|parent
},
13879 { WM_SETFOCUS
, sent
},
13882 static const struct message WmSetFocus_2
[] = {
13883 { HCBT_SETFOCUS
, hook
}, /* parent */
13884 { WM_KILLFOCUS
, sent
},
13885 { WM_SETFOCUS
, sent
|parent
},
13888 static const struct message WmSetFocus_3
[] = {
13889 { HCBT_SETFOCUS
, hook
}, /* child */
13892 static const struct message WmSetFocus_4
[] = {
13896 static void test_SetFocus(void)
13898 HWND parent
, old_parent
, child
, old_focus
, old_active
;
13900 struct wnd_event wnd_event
;
13904 wnd_event
.start_event
= CreateEventW(NULL
, 0, 0, NULL
);
13905 ok(wnd_event
.start_event
!= 0, "CreateEvent error %d\n", GetLastError());
13906 hthread
= CreateThread(NULL
, 0, thread_proc
, &wnd_event
, 0, &tid
);
13907 ok(hthread
!= 0, "CreateThread error %d\n", GetLastError());
13908 ret
= WaitForSingleObject(wnd_event
.start_event
, INFINITE
);
13909 ok(ret
== WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
13910 CloseHandle(wnd_event
.start_event
);
13912 parent
= CreateWindowExA(0, "TestParentClass", NULL
, WS_OVERLAPPEDWINDOW
,
13913 0, 0, 0, 0, 0, 0, 0, NULL
);
13914 ok(parent
!= 0, "failed to create parent window\n");
13915 child
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_CHILD
,
13916 0, 0, 0, 0, parent
, 0, 0, NULL
);
13917 ok(child
!= 0, "failed to create child window\n");
13919 trace("parent %p, child %p, thread window %p\n", parent
, child
, wnd_event
.hwnd
);
13922 SetActiveWindow(0);
13927 ok(GetActiveWindow() == 0, "expected active 0, got %p\n", GetActiveWindow());
13928 ok(GetFocus() == 0, "expected focus 0, got %p\n", GetFocus());
13930 log_all_parent_messages
++;
13932 old_focus
= SetFocus(child
);
13933 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
13934 ok_sequence(WmSetFocus_1
, "SetFocus on a child window", TRUE
);
13935 ok(old_focus
== parent
, "expected old focus %p, got %p\n", parent
, old_focus
);
13936 ok(GetActiveWindow() == parent
, "expected active %p, got %p\n", parent
, GetActiveWindow());
13937 ok(GetFocus() == child
, "expected focus %p, got %p\n", child
, GetFocus());
13939 old_focus
= SetFocus(parent
);
13940 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
13941 ok_sequence(WmSetFocus_2
, "SetFocus on a parent window", FALSE
);
13942 ok(old_focus
== child
, "expected old focus %p, got %p\n", child
, old_focus
);
13943 ok(GetActiveWindow() == parent
, "expected active %p, got %p\n", parent
, GetActiveWindow());
13944 ok(GetFocus() == parent
, "expected focus %p, got %p\n", parent
, GetFocus());
13946 SetLastError(0xdeadbeef);
13947 old_focus
= SetFocus((HWND
)0xdeadbeef);
13948 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
|| broken(GetLastError() == 0xdeadbeef),
13949 "expected ERROR_INVALID_WINDOW_HANDLE, got %d\n", GetLastError());
13950 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
13951 ok_sequence(WmEmptySeq
, "SetFocus on an invalid window", FALSE
);
13952 ok(old_focus
== 0, "expected old focus 0, got %p\n", old_focus
);
13953 ok(GetActiveWindow() == parent
, "expected active %p, got %p\n", parent
, GetActiveWindow());
13954 ok(GetFocus() == parent
, "expected focus %p, got %p\n", parent
, GetFocus());
13956 SetLastError(0xdeadbeef);
13957 old_focus
= SetFocus(GetDesktopWindow());
13958 ok(GetLastError() == ERROR_ACCESS_DENIED
/* Vista+ */ ||
13959 broken(GetLastError() == 0xdeadbeef), "expected ERROR_ACCESS_DENIED, got %d\n", GetLastError());
13960 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
13961 ok_sequence(WmEmptySeq
, "SetFocus on a desktop window", TRUE
);
13962 ok(old_focus
== 0, "expected old focus 0, got %p\n", old_focus
);
13963 ok(GetActiveWindow() == parent
, "expected active %p, got %p\n", parent
, GetActiveWindow());
13964 ok(GetFocus() == parent
, "expected focus %p, got %p\n", parent
, GetFocus());
13966 SetLastError(0xdeadbeef);
13967 old_focus
= SetFocus(wnd_event
.hwnd
);
13968 ok(GetLastError() == ERROR_ACCESS_DENIED
/* Vista+ */ ||
13969 broken(GetLastError() == 0xdeadbeef), "expected ERROR_ACCESS_DENIED, got %d\n", GetLastError());
13970 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
13971 ok_sequence(WmEmptySeq
, "SetFocus on another thread window", TRUE
);
13972 ok(old_focus
== 0, "expected old focus 0, got %p\n", old_focus
);
13973 ok(GetActiveWindow() == parent
, "expected active %p, got %p\n", parent
, GetActiveWindow());
13974 ok(GetFocus() == parent
, "expected focus %p, got %p\n", parent
, GetFocus());
13976 SetLastError(0xdeadbeef);
13977 old_active
= SetActiveWindow((HWND
)0xdeadbeef);
13978 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
|| broken(GetLastError() == 0xdeadbeef),
13979 "expected ERROR_INVALID_WINDOW_HANDLE, got %d\n", GetLastError());
13980 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
13981 ok_sequence(WmEmptySeq
, "SetActiveWindow on an invalid window", FALSE
);
13982 ok(old_active
== 0, "expected old focus 0, got %p\n", old_active
);
13983 ok(GetActiveWindow() == parent
, "expected active %p, got %p\n", parent
, GetActiveWindow());
13984 ok(GetFocus() == parent
, "expected focus %p, got %p\n", parent
, GetFocus());
13986 SetLastError(0xdeadbeef);
13987 old_active
= SetActiveWindow(GetDesktopWindow());
13989 ok(GetLastError() == 0xdeadbeef, "expected 0xdeadbeef, got %d\n", GetLastError());
13990 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
13991 ok_sequence(WmEmptySeq
, "SetActiveWindow on a desktop window", TRUE
);
13992 ok(old_active
== 0, "expected old focus 0, got %p\n", old_focus
);
13993 ok(GetActiveWindow() == parent
, "expected active %p, got %p\n", parent
, GetActiveWindow());
13994 ok(GetFocus() == parent
, "expected focus %p, got %p\n", parent
, GetFocus());
13996 SetLastError(0xdeadbeef);
13997 old_active
= SetActiveWindow(wnd_event
.hwnd
);
13999 ok(GetLastError() == 0xdeadbeef, "expected 0xdeadbeef, got %d\n", GetLastError());
14000 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
14001 ok_sequence(WmEmptySeq
, "SetActiveWindow on another thread window", TRUE
);
14002 ok(old_active
== 0, "expected old focus 0, got %p\n", old_active
);
14003 ok(GetActiveWindow() == parent
, "expected active %p, got %p\n", parent
, GetActiveWindow());
14004 ok(GetFocus() == parent
, "expected focus %p, got %p\n", parent
, GetFocus());
14006 SetLastError(0xdeadbeef);
14007 ret
= AttachThreadInput(GetCurrentThreadId(), tid
, TRUE
);
14008 ok(ret
, "AttachThreadInput error %d\n", GetLastError());
14011 ok(GetActiveWindow() == parent
, "expected active %p, got %p\n", parent
, GetActiveWindow());
14012 ok(GetFocus() == parent
, "expected focus %p, got %p\n", parent
, GetFocus());
14017 old_focus
= SetFocus(wnd_event
.hwnd
);
14018 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
14019 ok(old_focus
== wnd_event
.hwnd
, "expected old focus %p, got %p\n", wnd_event
.hwnd
, old_focus
);
14020 ok(GetActiveWindow() == wnd_event
.hwnd
, "expected active %p, got %p\n", wnd_event
.hwnd
, GetActiveWindow());
14021 ok(GetFocus() == wnd_event
.hwnd
, "expected focus %p, got %p\n", wnd_event
.hwnd
, GetFocus());
14023 old_focus
= SetFocus(parent
);
14024 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
14025 ok(old_focus
== parent
, "expected old focus %p, got %p\n", parent
, old_focus
);
14026 ok(GetActiveWindow() == parent
, "expected active %p, got %p\n", parent
, GetActiveWindow());
14027 ok(GetFocus() == parent
, "expected focus %p, got %p\n", parent
, GetFocus());
14032 old_active
= SetActiveWindow(wnd_event
.hwnd
);
14033 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
14034 ok(old_active
== parent
, "expected old focus %p, got %p\n", parent
, old_active
);
14035 ok(GetActiveWindow() == wnd_event
.hwnd
, "expected active %p, got %p\n", wnd_event
.hwnd
, GetActiveWindow());
14036 ok(GetFocus() == wnd_event
.hwnd
, "expected focus %p, got %p\n", wnd_event
.hwnd
, GetFocus());
14038 SetLastError(0xdeadbeef);
14039 ret
= AttachThreadInput(GetCurrentThreadId(), tid
, FALSE
);
14040 ok(ret
, "AttachThreadInput error %d\n", GetLastError());
14042 ok(GetActiveWindow() == 0, "expected active 0, got %p\n", GetActiveWindow());
14043 ok(GetFocus() == 0, "expected focus 0, got %p\n", GetFocus());
14045 old_parent
= SetParent(child
, GetDesktopWindow());
14046 ok(old_parent
== parent
, "expected old parent %p, got %p\n", parent
, old_parent
);
14048 ok(GetActiveWindow() == 0, "expected active 0, got %p\n", GetActiveWindow());
14049 ok(GetFocus() == 0, "expected focus 0, got %p\n", GetFocus());
14051 old_focus
= SetFocus(parent
);
14052 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
14053 ok(old_focus
== parent
, "expected old focus %p, got %p\n", parent
, old_focus
);
14054 ok(GetActiveWindow() == parent
, "expected active %p, got %p\n", parent
, GetActiveWindow());
14055 ok(GetFocus() == parent
, "expected focus %p, got %p\n", parent
, GetFocus());
14060 SetLastError(0xdeadbeef);
14061 old_focus
= SetFocus(child
);
14063 ok(GetLastError() == ERROR_INVALID_PARAMETER
/* Vista+ */ ||
14064 broken(GetLastError() == 0) /* XP */ ||
14065 broken(GetLastError() == 0xdeadbeef), "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
14066 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
14067 ok_sequence(WmSetFocus_3
, "SetFocus on a child window", TRUE
);
14068 ok(old_focus
== 0, "expected old focus 0, got %p\n", old_focus
);
14069 ok(GetActiveWindow() == parent
, "expected active %p, got %p\n", parent
, GetActiveWindow());
14070 ok(GetFocus() == parent
, "expected focus %p, got %p\n", parent
, GetFocus());
14072 SetLastError(0xdeadbeef);
14073 old_active
= SetActiveWindow(child
);
14074 ok(GetLastError() == 0xdeadbeef, "expected 0xdeadbeef, got %d\n", GetLastError());
14075 while (PeekMessageA(&msg
, NULL
, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
14076 ok_sequence(WmEmptySeq
, "SetActiveWindow on a child window", FALSE
);
14077 ok(old_active
== parent
, "expected old active %p, got %p\n", parent
, old_active
);
14078 ok(GetActiveWindow() == parent
, "expected active %p, got %p\n", parent
, GetActiveWindow());
14079 ok(GetFocus() == parent
, "expected focus %p, got %p\n", parent
, GetFocus());
14081 log_all_parent_messages
--;
14083 DestroyWindow(child
);
14084 DestroyWindow(parent
);
14086 ret
= PostMessageA(wnd_event
.hwnd
, WM_QUIT
, 0, 0);
14087 ok(ret
, "PostMessage(WM_QUIT) error %d\n", GetLastError());
14088 ret
= WaitForSingleObject(hthread
, INFINITE
);
14089 ok(ret
== WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
14090 CloseHandle(hthread
);
14093 static const struct message WmSetLayeredStyle
[] = {
14094 { WM_STYLECHANGING
, sent
},
14095 { WM_STYLECHANGED
, sent
},
14096 { WM_GETTEXT
, sent
|defwinproc
|optional
},
14100 static const struct message WmSetLayeredStyle2
[] = {
14101 { WM_STYLECHANGING
, sent
},
14102 { WM_STYLECHANGED
, sent
},
14103 { WM_WINDOWPOSCHANGING
, sent
|optional
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
14104 { WM_NCCALCSIZE
, sent
|optional
|wparam
|defwinproc
, 1 },
14105 { WM_WINDOWPOSCHANGED
, sent
|optional
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
14106 { WM_MOVE
, sent
|optional
|defwinproc
|wparam
, 0 },
14107 { WM_SIZE
, sent
|optional
|defwinproc
|wparam
, SIZE_RESTORED
},
14111 struct layered_window_info
14120 static DWORD CALLBACK
update_layered_proc( void *param
)
14122 struct layered_window_info
*info
= param
;
14123 POINT src
= { 0, 0 };
14125 info
->ret
= pUpdateLayeredWindow( info
->hwnd
, 0, NULL
, &info
->size
,
14126 info
->hdc
, &src
, 0, NULL
, ULW_OPAQUE
);
14127 ok( info
->ret
, "failed\n");
14128 SetEvent( info
->event
);
14132 static void test_layered_window(void)
14143 struct layered_window_info info
;
14145 if (!pUpdateLayeredWindow
)
14147 win_skip( "UpdateLayeredWindow not supported\n" );
14151 hdc
= CreateCompatibleDC( 0 );
14152 bmp
= CreateCompatibleBitmap( hdc
, 300, 300 );
14153 SelectObject( hdc
, bmp
);
14155 hwnd
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_CAPTION
| WS_THICKFRAME
| WS_SYSMENU
,
14156 100, 100, 300, 300, 0, 0, 0, NULL
);
14157 ok( hwnd
!= 0, "failed to create window\n" );
14158 ShowWindow( hwnd
, SW_SHOWNORMAL
);
14159 UpdateWindow( hwnd
);
14163 GetWindowRect( hwnd
, &rect
);
14164 GetClientRect( hwnd
, &client
);
14165 ok( client
.right
< rect
.right
- rect
.left
, "wrong client area\n" );
14166 ok( client
.bottom
< rect
.bottom
- rect
.top
, "wrong client area\n" );
14169 pos
.x
= pos
.y
= 300;
14170 size
.cx
= size
.cy
= 250;
14171 ret
= pUpdateLayeredWindow( hwnd
, 0, &pos
, &size
, hdc
, &src
, 0, NULL
, ULW_OPAQUE
);
14172 ok( !ret
, "UpdateLayeredWindow should fail on non-layered window\n" );
14173 ok( GetLastError() == ERROR_INVALID_PARAMETER
, "wrong error %u\n", GetLastError() );
14174 SetWindowLongA( hwnd
, GWL_EXSTYLE
, GetWindowLongA(hwnd
, GWL_EXSTYLE
) | WS_EX_LAYERED
);
14175 ok_sequence( WmSetLayeredStyle
, "WmSetLayeredStyle", FALSE
);
14177 ret
= pUpdateLayeredWindow( hwnd
, 0, &pos
, &size
, hdc
, &src
, 0, NULL
, ULW_OPAQUE
);
14178 ok( ret
, "UpdateLayeredWindow failed err %u\n", GetLastError() );
14179 ok_sequence( WmEmptySeq
, "UpdateLayeredWindow", FALSE
);
14180 GetWindowRect( hwnd
, &rect
);
14181 ok( rect
.left
== 300 && rect
.top
== 300 && rect
.right
== 550 && rect
.bottom
== 550,
14182 "wrong window rect %d,%d,%d,%d\n", rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
14183 GetClientRect( hwnd
, &rect
);
14184 ok( rect
.right
== client
.right
- 50 && rect
.bottom
== client
.bottom
- 50,
14185 "wrong client rect %d,%d,%d,%d\n", rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
14189 ret
= pUpdateLayeredWindow( hwnd
, 0, &pos
, &size
, hdc
, &src
, 0, NULL
, ULW_OPAQUE
);
14190 ok( ret
, "UpdateLayeredWindow failed err %u\n", GetLastError() );
14191 ok_sequence( WmEmptySeq
, "UpdateLayeredWindow", FALSE
);
14192 GetWindowRect( hwnd
, &rect
);
14193 ok( rect
.left
== 300 && rect
.top
== 200 && rect
.right
== 450 && rect
.bottom
== 450,
14194 "wrong window rect %d,%d,%d,%d\n", rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
14195 GetClientRect( hwnd
, &rect
);
14196 ok( rect
.right
== client
.right
- 150 && rect
.bottom
== client
.bottom
- 50,
14197 "wrong client rect %d,%d,%d,%d\n", rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
14199 SetWindowLongA( hwnd
, GWL_STYLE
,
14200 GetWindowLongA(hwnd
, GWL_STYLE
) & ~(WS_CAPTION
| WS_THICKFRAME
| WS_SYSMENU
) );
14201 ok_sequence( WmSetLayeredStyle2
, "WmSetLayeredStyle2", FALSE
);
14205 ret
= pUpdateLayeredWindow( hwnd
, 0, &pos
, &size
, hdc
, &src
, 0, NULL
, ULW_OPAQUE
);
14206 ok( ret
, "UpdateLayeredWindow failed err %u\n", GetLastError() );
14207 ok_sequence( WmEmptySeq
, "UpdateLayeredWindow", FALSE
);
14208 GetWindowRect( hwnd
, &rect
);
14209 ok( rect
.left
== 200 && rect
.top
== 200 && rect
.right
== 400 && rect
.bottom
== 450,
14210 "wrong window rect %d,%d,%d,%d\n", rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
14211 GetClientRect( hwnd
, &rect
);
14212 ok( (rect
.right
== 200 && rect
.bottom
== 250) ||
14213 broken(rect
.right
== client
.right
- 100 && rect
.bottom
== client
.bottom
- 50),
14214 "wrong client rect %d,%d,%d,%d\n", rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
14217 ret
= pUpdateLayeredWindow( hwnd
, 0, &pos
, &size
, hdc
, &src
, 0, NULL
, ULW_OPAQUE
);
14218 ok( !ret
, "UpdateLayeredWindow should fail on non-layered window\n" );
14219 ok( GetLastError() == ERROR_INVALID_PARAMETER
|| broken(ERROR_MR_MID_NOT_FOUND
) /* win7 */,
14220 "wrong error %u\n", GetLastError() );
14223 ret
= pUpdateLayeredWindow( hwnd
, 0, &pos
, &size
, hdc
, &src
, 0, NULL
, ULW_OPAQUE
);
14224 ok( !ret
, "UpdateLayeredWindow should fail on non-layered window\n" );
14225 ok( GetLastError() == ERROR_INVALID_PARAMETER
, "wrong error %u\n", GetLastError() );
14227 SetWindowLongA( hwnd
, GWL_EXSTYLE
, GetWindowLongA(hwnd
, GWL_EXSTYLE
) & ~WS_EX_LAYERED
);
14228 ok_sequence( WmSetLayeredStyle
, "WmSetLayeredStyle", FALSE
);
14229 GetWindowRect( hwnd
, &rect
);
14230 ok( rect
.left
== 200 && rect
.top
== 200 && rect
.right
== 400 && rect
.bottom
== 450,
14231 "wrong window rect %d,%d,%d,%d\n", rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
14232 GetClientRect( hwnd
, &rect
);
14233 ok( (rect
.right
== 200 && rect
.bottom
== 250) ||
14234 broken(rect
.right
== client
.right
- 100 && rect
.bottom
== client
.bottom
- 50),
14235 "wrong client rect %d,%d,%d,%d\n", rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
14237 SetWindowLongA( hwnd
, GWL_EXSTYLE
, GetWindowLongA(hwnd
, GWL_EXSTYLE
) | WS_EX_LAYERED
);
14240 info
.size
.cx
= 250;
14241 info
.size
.cy
= 300;
14242 info
.event
= CreateEventA( NULL
, TRUE
, FALSE
, NULL
);
14244 thread
= CreateThread( NULL
, 0, update_layered_proc
, &info
, 0, &tid
);
14245 ok( WaitForSingleObject( info
.event
, 1000 ) == 0, "wait failed\n" );
14246 ok( info
.ret
, "UpdateLayeredWindow failed in other thread\n" );
14247 WaitForSingleObject( thread
, 1000 );
14248 CloseHandle( thread
);
14249 GetWindowRect( hwnd
, &rect
);
14250 ok( rect
.left
== 200 && rect
.top
== 200 && rect
.right
== 450 && rect
.bottom
== 500,
14251 "wrong window rect %d,%d,%d,%d\n", rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
14252 GetClientRect( hwnd
, &rect
);
14253 ok( (rect
.right
== 250 && rect
.bottom
== 300) ||
14254 broken(rect
.right
== client
.right
- 50 && rect
.bottom
== client
.bottom
),
14255 "wrong client rect %d,%d,%d,%d\n", rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
14257 DestroyWindow( hwnd
);
14259 DeleteObject( bmp
);
14262 static void init_funcs(void)
14264 HMODULE hKernel32
= GetModuleHandleA("kernel32.dll");
14266 #define X(f) p##f = (void*)GetProcAddress(hKernel32, #f)
14269 X(DeactivateActCtx
);
14270 X(GetCurrentActCtx
);
14279 BOOL (WINAPI
*pIsWinEventHookInstalled
)(DWORD
)= 0;/*GetProcAddress(user32, "IsWinEventHookInstalled");*/
14280 HMODULE hModuleImm32
;
14281 BOOL (WINAPI
*pImmDisableIME
)(DWORD
);
14286 argc
= winetest_get_mainargs( &test_argv
);
14290 /* Child process. */
14291 sscanf (test_argv
[2], "%d", (unsigned int *) &arg
);
14292 do_wait_idle_child( arg
);
14296 InitializeCriticalSection( &sequence_cs
);
14299 hModuleImm32
= LoadLibraryA("imm32.dll");
14300 if (hModuleImm32
) {
14301 pImmDisableIME
= (void *)GetProcAddress(hModuleImm32
, "ImmDisableIME");
14302 if (pImmDisableIME
)
14305 pImmDisableIME
= NULL
;
14306 FreeLibrary(hModuleImm32
);
14308 if (!RegisterWindowClasses()) assert(0);
14310 if (pSetWinEventHook
)
14312 hEvent_hook
= pSetWinEventHook(EVENT_MIN
, EVENT_MAX
,
14313 GetModuleHandleA(0), win_event_proc
,
14314 0, GetCurrentThreadId(),
14315 WINEVENT_INCONTEXT
);
14316 if (pIsWinEventHookInstalled
&& hEvent_hook
)
14319 for (event
= EVENT_MIN
; event
<= EVENT_MAX
; event
++)
14320 ok(pIsWinEventHookInstalled(event
), "IsWinEventHookInstalled(%u) failed\n", event
);
14323 if (!hEvent_hook
) win_skip( "no win event hook support\n" );
14325 cbt_hook_thread_id
= GetCurrentThreadId();
14326 hCBT_hook
= SetWindowsHookExA(WH_CBT
, cbt_hook_proc
, 0, GetCurrentThreadId());
14327 if (!hCBT_hook
) win_skip( "cannot set global hook, will skip hook tests\n" );
14331 /* Fix message sequences before removing 4 lines below */
14332 if (pUnhookWinEvent
&& hEvent_hook
)
14334 ret
= pUnhookWinEvent(hEvent_hook
);
14335 ok( ret
, "UnhookWinEvent error %d\n", GetLastError());
14336 pUnhookWinEvent
= 0;
14342 test_PostMessage();
14344 test_PeekMessage();
14345 test_PeekMessage2();
14346 test_WaitForInputIdle( test_argv
[0] );
14347 test_scrollwindowex();
14349 test_setwindowpos();
14351 invisible_parent_tests();
14352 test_mdi_messages();
14353 test_button_messages();
14354 test_static_messages();
14355 test_listbox_messages();
14356 test_combobox_messages();
14357 test_wmime_keydown_message();
14358 test_paint_messages();
14359 test_interthread_messages();
14360 test_message_conversion();
14361 test_accelerators();
14363 test_timers_no_wnd();
14364 if (hCBT_hook
) test_set_hook();
14365 test_DestroyWindow();
14366 test_DispatchMessage();
14367 test_SendMessageTimeout();
14368 test_edit_messages();
14369 test_quit_message();
14370 test_SetActiveWindow();
14372 if (!pTrackMouseEvent
)
14373 win_skip("TrackMouseEvent is not available\n");
14375 test_TrackMouseEvent();
14377 test_SetWindowRgn();
14379 test_dialog_messages();
14381 test_nullCallback();
14382 test_dbcs_wm_char();
14383 test_unicode_wm_char();
14384 test_menu_messages();
14385 test_paintingloop();
14387 test_clipboard_viewers();
14390 test_layered_window();
14391 /* keep it the last test, under Windows it tends to break the tests
14392 * which rely on active/foreground windows being correct.
14394 test_SetForegroundWindow();
14396 UnhookWindowsHookEx(hCBT_hook
);
14397 if (pUnhookWinEvent
&& hEvent_hook
)
14399 ret
= pUnhookWinEvent(hEvent_hook
);
14400 ok( ret
, "UnhookWinEvent error %d\n", GetLastError());
14401 SetLastError(0xdeadbeef);
14402 ok(!pUnhookWinEvent(hEvent_hook
), "UnhookWinEvent succeeded\n");
14403 ok(GetLastError() == ERROR_INVALID_HANDLE
|| /* Win2k */
14404 GetLastError() == 0xdeadbeef, /* Win9x */
14405 "unexpected error %d\n", GetLastError());
14407 DeleteCriticalSection( &sequence_cs
);