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
63 /* encoded DRAWITEMSTRUCT into an LPARAM */
70 UINT type
: 4; /* ODT_* flags */
71 UINT ctl_id
: 4; /* Control ID */
72 UINT item_id
: 4; /* Menu item ID */
73 UINT action
: 4; /* ODA_* flags */
74 UINT state
: 16; /* ODS_* flags */
80 static BOOL test_DestroyWindow_flag
;
81 static HWINEVENTHOOK hEvent_hook
;
82 static HHOOK hKBD_hook
;
83 static HHOOK hCBT_hook
;
84 static DWORD cbt_hook_thread_id
;
86 static const WCHAR testWindowClassW
[] =
87 { 'T','e','s','t','W','i','n','d','o','w','C','l','a','s','s','W',0 };
90 FIXME: add tests for these
91 Window Edge Styles (Win31/Win95/98 look), in order of precedence:
92 WS_EX_DLGMODALFRAME: double border, WS_CAPTION allowed
93 WS_THICKFRAME: thick border
94 WS_DLGFRAME: double border, WS_CAPTION not allowed (but possibly shown anyway)
95 WS_BORDER (default for overlapped windows): single black border
96 none (default for child (and popup?) windows): no border
114 UINT message
; /* the WM_* code */
115 msg_flags_t flags
; /* message props */
116 WPARAM wParam
; /* expected value of wParam */
117 LPARAM lParam
; /* expected value of lParam */
118 WPARAM wp_mask
; /* mask for wParam checks */
119 LPARAM lp_mask
; /* mask for lParam checks */
122 struct recvd_message
{
123 UINT message
; /* the WM_* code */
124 msg_flags_t flags
; /* message props */
125 HWND hwnd
; /* window that received the message */
126 WPARAM wParam
; /* expected value of wParam */
127 LPARAM lParam
; /* expected value of lParam */
128 int line
; /* source line where logged */
129 const char *descr
; /* description for trace output */
130 char output
[512]; /* trace output */
133 /* Empty message sequence */
134 static const struct message WmEmptySeq
[] =
138 /* CreateWindow (for overlapped window, not initially visible) (16/32) */
139 static const struct message WmCreateOverlappedSeq
[] = {
140 { HCBT_CREATEWND
, hook
},
141 { WM_GETMINMAXINFO
, sent
},
142 { WM_NCCREATE
, sent
},
143 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
144 { 0x0093, sent
|defwinproc
|optional
},
145 { 0x0094, sent
|defwinproc
|optional
},
146 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
148 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
151 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
152 * for a not visible overlapped window.
154 static const struct message WmSWP_ShowOverlappedSeq
[] = {
155 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
156 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
157 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
158 { WM_GETTEXT
, sent
|defwinproc
|optional
},
159 { WM_ERASEBKGND
, sent
|optional
},
160 { HCBT_ACTIVATE
, hook
},
161 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
162 { WM_NOTIFYFORMAT
, sent
|optional
},
163 { WM_QUERYUISTATE
, sent
|optional
},
164 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
165 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* Win9x: SWP_NOSENDCHANGING */
166 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
167 { WM_NCACTIVATE
, sent
},
168 { WM_GETTEXT
, sent
|defwinproc
|optional
},
169 { WM_ACTIVATE
, sent
|wparam
, 1 },
170 { HCBT_SETFOCUS
, hook
},
171 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
172 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
173 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
174 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
175 { WM_GETTEXT
, sent
|optional
},
176 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
177 { WM_GETTEXT
, sent
|defwinproc
|optional
},
178 { WM_ERASEBKGND
, sent
|optional
},
179 /* Win9x adds SWP_NOZORDER below */
180 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
181 { WM_GETTEXT
, sent
|optional
},
182 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
183 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
184 { WM_ERASEBKGND
, sent
|optional
},
185 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
186 { WM_SYNCPAINT
, sent
|optional
},
187 { WM_GETTITLEBARINFOEX
, sent
|optional
},
188 { WM_PAINT
, sent
|optional
},
189 { WM_NCPAINT
, sent
|beginpaint
|optional
},
190 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
191 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
194 /* SetWindowPos(SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE)
195 * for a visible overlapped window.
197 static const struct message WmSWP_HideOverlappedSeq
[] = {
198 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
199 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
200 { HCBT_ACTIVATE
, hook
|optional
},
201 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
202 { WM_ACTIVATEAPP
, sent
|wparam
|optional
, 1 },
203 { WM_NCACTIVATE
, sent
|optional
},
204 { WM_ACTIVATE
, sent
|optional
},
205 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
209 /* SetWindowPos(SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOMOVE)
210 * for a visible overlapped window.
212 static const struct message WmSWP_ResizeSeq
[] = {
213 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
},
214 { WM_GETMINMAXINFO
, sent
|defwinproc
},
215 { WM_NCCALCSIZE
, sent
|wparam
|optional
, TRUE
},
216 { WM_NCPAINT
, sent
|optional
},
217 { WM_GETTEXT
, sent
|defwinproc
|optional
},
218 { WM_ERASEBKGND
, sent
|optional
},
219 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
},
220 { WM_SIZE
, sent
|defwinproc
|optional
},
221 { WM_NCCALCSIZE
, sent
|wparam
|optional
, TRUE
},
222 { WM_NCPAINT
, sent
|optional
},
223 { WM_GETTEXT
, sent
|defwinproc
|optional
},
224 { WM_ERASEBKGND
, sent
|optional
},
225 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
226 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* XP sends a duplicate */
230 /* SetWindowPos(SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOMOVE)
231 * for a visible popup window.
233 static const struct message WmSWP_ResizePopupSeq
[] = {
234 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
},
235 { WM_GETMINMAXINFO
, sent
|defwinproc
|optional
}, /* Win9x */
236 { WM_NCCALCSIZE
, sent
|wparam
|optional
, TRUE
},
237 { WM_NCPAINT
, sent
|optional
},
238 { WM_GETTEXT
, sent
|defwinproc
|optional
},
239 { WM_ERASEBKGND
, sent
|optional
},
240 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
},
241 { WM_SIZE
, sent
|defwinproc
|wparam
|optional
, SIZE_RESTORED
},
242 { WM_NCCALCSIZE
, sent
|wparam
|optional
, TRUE
},
243 { WM_NCPAINT
, sent
|optional
},
244 { WM_GETTEXT
, sent
|defwinproc
|optional
},
245 { WM_ERASEBKGND
, sent
|optional
},
246 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
250 /* SetWindowPos(SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOSIZE)
251 * for a visible overlapped window.
253 static const struct message WmSWP_MoveSeq
[] = {
254 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOSIZE
},
255 { WM_NCPAINT
, sent
|optional
},
256 { WM_GETTEXT
, sent
|defwinproc
|optional
},
257 { WM_ERASEBKGND
, sent
|optional
},
258 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOCLIENTSIZE
},
259 { WM_MOVE
, sent
|defwinproc
|wparam
, 0 },
260 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
263 /* Resize with SetWindowPos(SWP_NOZORDER)
264 * for a visible overlapped window
265 * SWP_NOZORDER is stripped by the logging code
267 static const struct message WmSWP_ResizeNoZOrder
[] = {
268 { WM_WINDOWPOSCHANGING
, sent
|wparam
, /*SWP_NOZORDER|*/SWP_NOACTIVATE
},
269 { WM_GETMINMAXINFO
, sent
|defwinproc
},
270 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
271 { WM_NCPAINT
, sent
|optional
},
272 { WM_GETTEXT
, sent
|defwinproc
|optional
},
273 { WM_ERASEBKGND
, sent
|optional
},
274 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, /*SWP_NOZORDER|*/SWP_NOACTIVATE
, 0,
275 SWP_NOMOVE
|SWP_NOCLIENTMOVE
|SWP_NOSIZE
|SWP_NOCLIENTSIZE
},
276 { WM_MOVE
, sent
|defwinproc
|optional
},
277 { WM_SIZE
, sent
|defwinproc
|optional
},
278 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 }, /* Win9x doesn't send it */
279 { WM_NCPAINT
, sent
|optional
}, /* Win9x doesn't send it */
280 { WM_GETTEXT
, sent
|defwinproc
|optional
}, /* Win9x doesn't send it */
281 { WM_ERASEBKGND
, sent
|optional
}, /* Win9x doesn't send it */
282 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
283 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
287 /* Switch visible mdi children */
288 static const struct message WmSwitchChild
[] = {
289 /* Switch MDI child */
290 { WM_MDIACTIVATE
, sent
},/* in the MDI client */
291 { WM_WINDOWPOSCHANGING
, sent
|wparam
,SWP_NOSIZE
|SWP_NOMOVE
},/* in the 1st MDI child */
292 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
293 { WM_CHILDACTIVATE
, sent
},/* in the 1st MDI child */
294 /* Deactivate 2nd MDI child */
295 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 0 }, /* in the 2nd MDI child */
296 { WM_MDIACTIVATE
, sent
|defwinproc
}, /* in the 2nd MDI child */
297 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
298 /* Preparing for maximize and maximaze the 1st MDI child */
299 { WM_GETMINMAXINFO
, sent
|defwinproc
}, /* in the 1st MDI child */
300 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_STATECHANGED
}, /* in the 1st MDI child */
301 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 }, /* in the 1st MDI child */
302 { WM_CHILDACTIVATE
, sent
|defwinproc
}, /* in the 1st MDI child */
303 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
}, /* in the 1st MDI child */
304 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
}, /* in the 1st MDI child */
305 /* Lock redraw 2nd MDI child */
306 { WM_SETREDRAW
, sent
|wparam
|defwinproc
, 0 }, /* in the 2nd MDI child */
307 { HCBT_MINMAX
, hook
|lparam
, 0, SW_NORMALNA
},
308 /* Restore 2nd MDI child */
309 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_STATECHANGED
},/* in the 2nd MDI child */
310 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 },/* in the 2nd MDI child */
311 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* in the 2nd MDI child */
312 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
}, /* in the 2nd MDI child */
313 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
}, /* in the 2nd MDI child */
314 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* in the 2nd MDI child */
315 /* Redraw 2nd MDI child */
316 { WM_SETREDRAW
, sent
|wparam
|defwinproc
, 1 },/* in the 2nd MDI child */
317 /* Redraw MDI frame */
318 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
},/* in MDI frame */
319 { WM_NCCALCSIZE
, sent
|wparam
, 1 },/* in MDI frame */
320 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
}, /* in MDI frame */
321 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* in MDI frame */
322 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* in the 1st MDI child */
323 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
}, /* in the 1st MDI child */
324 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 }, /* in the 1st MDI child */
325 { HCBT_SETFOCUS
, hook
},
326 { WM_KILLFOCUS
, sent
|defwinproc
}, /* in the 2nd MDI child */
327 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 0 },/* in the 1st MDI child */
328 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
329 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
330 { WM_SETFOCUS
, sent
},/* in the MDI client */
331 { HCBT_SETFOCUS
, hook
},
332 { WM_KILLFOCUS
, sent
},/* in the MDI client */
333 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
334 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 }, /* in the 1st MDI child */
335 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
336 { WM_SETFOCUS
, sent
|defwinproc
}, /* in the 1st MDI child */
337 { WM_MDIACTIVATE
, sent
|defwinproc
},/* in the 1st MDI child */
338 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
}, /* in the 1st MDI child */
342 /* Switch visible not maximized mdi children */
343 static const struct message WmSwitchNotMaximizedChild
[] = {
344 /* Switch not maximized MDI child */
345 { WM_MDIACTIVATE
, sent
},/* in the MDI client */
346 { WM_WINDOWPOSCHANGING
, sent
|wparam
,SWP_NOSIZE
|SWP_NOMOVE
},/* in the 2nd MDI child */
347 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
348 { WM_CHILDACTIVATE
, sent
},/* in the 2nd MDI child */
349 /* Deactivate 1st MDI child */
350 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 0 }, /* in the 1st MDI child */
351 { WM_MDIACTIVATE
, sent
|defwinproc
}, /* in the 1st MDI child */
352 /* Activate 2nd MDI child */
353 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
}, /* in the 2nd MDI child */
354 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 }, /* in the 2nd MDI child */
355 { HCBT_SETFOCUS
, hook
}, /* in the 1st MDI child */
356 { WM_KILLFOCUS
, sent
|defwinproc
}, /* in the 1st MDI child */
357 { WM_IME_SETCONTEXT
, sent
|defwinproc
|optional
}, /* in the 1st MDI child */
358 { WM_IME_SETCONTEXT
, sent
|optional
}, /* in the MDI client */
359 { WM_SETFOCUS
, sent
, 0 }, /* in the MDI client */
360 { HCBT_SETFOCUS
, hook
},
361 { WM_KILLFOCUS
, sent
}, /* in the MDI client */
362 { WM_IME_SETCONTEXT
, sent
|optional
}, /* in the MDI client */
363 { WM_IME_SETCONTEXT
, sent
|defwinproc
|optional
}, /* in the 1st MDI child */
364 { WM_SETFOCUS
, sent
|defwinproc
}, /* in the 2nd MDI child */
365 { WM_MDIACTIVATE
, sent
|defwinproc
}, /* in the 2nd MDI child */
366 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
}, /* in the 2nd MDI child */
371 /* SetWindowPos(SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|
372 SWP_NOZORDER|SWP_FRAMECHANGED)
373 * for a visible overlapped window with WS_CLIPCHILDREN style set.
375 static const struct message WmSWP_FrameChanged_clip
[] = {
376 { WM_WINDOWPOSCHANGING
, sent
|wparam
|parent
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
},
377 { WM_NCCALCSIZE
, sent
|wparam
|parent
, 1 },
378 { WM_NCPAINT
, sent
|parent
|optional
}, /* wparam != 1 */
379 { WM_GETTEXT
, sent
|parent
|defwinproc
|optional
},
380 { WM_ERASEBKGND
, sent
|parent
|optional
}, /* FIXME: remove optional once Wine is fixed */
381 { WM_NCPAINT
, sent
}, /* wparam != 1 */
382 { WM_ERASEBKGND
, sent
},
383 { WM_WINDOWPOSCHANGED
, sent
|wparam
|parent
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
384 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
388 /* SetWindowPos(SWP_NOSIZE|SWP_NOMOVE|SWP_DEFERERASE|SWP_NOACTIVATE|
389 SWP_NOZORDER|SWP_FRAMECHANGED)
390 * for a visible overlapped window.
392 static const struct message WmSWP_FrameChangedDeferErase
[] = {
393 { WM_WINDOWPOSCHANGING
, sent
|wparam
|parent
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_DEFERERASE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
},
394 { WM_NCCALCSIZE
, sent
|wparam
|parent
, 1 },
395 { WM_WINDOWPOSCHANGED
, sent
|wparam
|parent
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_DEFERERASE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
396 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
397 { WM_PAINT
, sent
|parent
|optional
},
398 { WM_NCPAINT
, sent
|beginpaint
|parent
|optional
}, /* wparam != 1 */
399 { WM_GETTEXT
, sent
|beginpaint
|parent
|defwinproc
|optional
},
401 { WM_NCPAINT
, sent
|beginpaint
}, /* wparam != 1 */
402 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
406 /* SetWindowPos(SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|
407 SWP_NOZORDER|SWP_FRAMECHANGED)
408 * for a visible overlapped window without WS_CLIPCHILDREN style set.
410 static const struct message WmSWP_FrameChanged_noclip
[] = {
411 { WM_WINDOWPOSCHANGING
, sent
|wparam
|parent
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
},
412 { WM_NCCALCSIZE
, sent
|wparam
|parent
, 1 },
413 { WM_NCPAINT
, sent
|parent
|optional
}, /* wparam != 1 */
414 { WM_GETTEXT
, sent
|parent
|defwinproc
|optional
},
415 { WM_ERASEBKGND
, sent
|parent
|optional
},
416 { WM_WINDOWPOSCHANGED
, sent
|wparam
|parent
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
417 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
419 { WM_NCPAINT
, sent
|beginpaint
}, /* wparam != 1 */
420 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
424 /* ShowWindow(SW_SHOW) for a not visible overlapped window */
425 static const struct message WmShowOverlappedSeq
[] = {
426 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
427 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
428 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
429 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
430 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
431 { WM_GETTEXT
, sent
|defwinproc
|optional
},
432 { WM_ERASEBKGND
, sent
|optional
},
433 { HCBT_ACTIVATE
, hook
},
434 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
435 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
436 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
437 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
438 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
439 { WM_NCACTIVATE
, sent
|wparam
, 1 },
440 { WM_GETTEXT
, sent
|defwinproc
|optional
},
441 { WM_ACTIVATE
, sent
|wparam
, 1 },
442 { HCBT_SETFOCUS
, hook
},
443 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
444 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
445 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
446 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
447 { WM_GETTEXT
, sent
|optional
},
448 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
449 { WM_GETTEXT
, sent
|defwinproc
|optional
},
450 { WM_ERASEBKGND
, sent
|optional
},
451 /* Win9x adds SWP_NOZORDER below */
452 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
453 { WM_NCCALCSIZE
, sent
|optional
},
454 { WM_GETTEXT
, sent
|optional
},
455 { WM_NCPAINT
, sent
|optional
},
456 { WM_ERASEBKGND
, sent
|optional
},
457 { WM_SYNCPAINT
, sent
|optional
},
458 #if 0 /* CreateWindow/ShowWindow(SW_SHOW) also generates WM_SIZE/WM_MOVE
459 * messages. Does that mean that CreateWindow doesn't set initial
460 * window dimensions for overlapped windows?
465 { WM_PAINT
, sent
|optional
},
466 { WM_NCPAINT
, sent
|beginpaint
|optional
},
469 /* ShowWindow(SW_SHOWMAXIMIZED) for a not visible overlapped window */
470 static const struct message WmShowMaxOverlappedSeq
[] = {
471 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
472 { WM_GETMINMAXINFO
, sent
},
473 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_STATECHANGED
},
474 { WM_GETMINMAXINFO
, sent
|defwinproc
},
475 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
476 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
477 { HCBT_ACTIVATE
, hook
},
478 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
479 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
480 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
481 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
482 { WM_NCACTIVATE
, sent
|wparam
, 1 },
483 { WM_GETTEXT
, sent
|defwinproc
|optional
},
484 { WM_ACTIVATE
, sent
|wparam
, 1 },
485 { HCBT_SETFOCUS
, hook
},
486 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
487 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
488 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
489 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
490 { WM_GETTEXT
, sent
|optional
},
491 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
492 { WM_GETTEXT
, sent
|defwinproc
|optional
},
493 { WM_ERASEBKGND
, sent
|optional
},
494 /* Win9x adds SWP_NOZORDER below */
495 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_STATECHANGED
},
496 { WM_MOVE
, sent
|defwinproc
},
497 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
498 { WM_GETTEXT
, sent
|optional
},
499 { WM_NCCALCSIZE
, sent
|optional
},
500 { WM_NCPAINT
, sent
|optional
},
501 { WM_ERASEBKGND
, sent
|optional
},
502 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
503 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
504 { WM_SYNCPAINT
, sent
|optional
},
505 { WM_GETTITLEBARINFOEX
, sent
|optional
},
506 { WM_PAINT
, sent
|optional
},
507 { WM_NCPAINT
, sent
|beginpaint
|optional
},
508 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
511 /* ShowWindow(SW_RESTORE) for a not visible maximized overlapped window */
512 static const struct message WmShowRestoreMaxOverlappedSeq
[] = {
513 { HCBT_MINMAX
, hook
|lparam
, 0, SW_RESTORE
},
514 { WM_GETTEXT
, sent
|optional
},
515 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
516 { WM_GETMINMAXINFO
, sent
|defwinproc
},
517 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
518 { WM_NCPAINT
, sent
|optional
},
519 { WM_GETTEXT
, sent
|defwinproc
|optional
},
520 { WM_ERASEBKGND
, sent
|optional
},
521 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
, 0, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOSIZE
|SWP_NOMOVE
},
522 { WM_MOVE
, sent
|defwinproc
|optional
},
523 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
524 { WM_NCCALCSIZE
, sent
|wparam
|optional
, TRUE
},
525 { WM_NCPAINT
, sent
|optional
},
526 { WM_ERASEBKGND
, sent
|optional
},
527 { WM_PAINT
, sent
|optional
},
528 { WM_GETTITLEBARINFOEX
, sent
|optional
},
529 { WM_NCPAINT
, sent
|beginpaint
|optional
},
530 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
533 /* ShowWindow(SW_RESTORE) for a not visible minimized overlapped window */
534 static const struct message WmShowRestoreMinOverlappedSeq
[] = {
535 { HCBT_MINMAX
, hook
|lparam
, 0, SW_RESTORE
},
536 { WM_QUERYOPEN
, sent
|optional
},
537 { WM_GETTEXT
, sent
|optional
},
538 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
|SWP_NOCOPYBITS
},
539 { WM_GETMINMAXINFO
, sent
|defwinproc
},
540 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
541 { HCBT_ACTIVATE
, hook
},
542 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
543 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
544 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
545 { WM_NCACTIVATE
, sent
|wparam
, 1 },
546 { WM_GETTEXT
, sent
|defwinproc
|optional
},
547 { WM_ACTIVATE
, sent
|wparam
, 1 },
548 { HCBT_SETFOCUS
, hook
},
549 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
550 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
551 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
552 { WM_GETTEXT
, sent
|optional
},
553 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
554 { WM_GETTEXT
, sent
|defwinproc
|optional
},
555 { WM_ERASEBKGND
, sent
},
556 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_STATECHANGED
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
},
557 { WM_MOVE
, sent
|defwinproc
},
558 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
559 { WM_NCCALCSIZE
, sent
|wparam
|optional
, TRUE
},
560 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
561 { WM_ERASEBKGND
, sent
|optional
},
562 { WM_ACTIVATE
, sent
|wparam
, 1 },
563 { WM_GETTEXT
, sent
|optional
},
564 { WM_PAINT
, sent
|optional
},
565 { WM_GETTITLEBARINFOEX
, sent
|optional
},
566 { WM_NCPAINT
, sent
|beginpaint
|optional
},
567 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
570 /* ShowWindow(SW_SHOWMINIMIZED) for a not visible overlapped window */
571 static const struct message WmShowMinOverlappedSeq
[] = {
572 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
573 { HCBT_SETFOCUS
, hook
},
574 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
575 { WM_KILLFOCUS
, sent
},
576 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
577 { WM_IME_NOTIFY
, sent
|wparam
|optional
|defwinproc
, 1 },
578 { WM_GETTEXT
, sent
|optional
},
579 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOCOPYBITS
|SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_STATECHANGED
},
580 { WM_GETMINMAXINFO
, sent
|defwinproc
},
581 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
582 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
583 { WM_NCPAINT
, sent
|optional
},
584 { WM_GETTEXT
, sent
|defwinproc
|optional
},
585 { WM_WINDOWPOSCHANGED
, sent
},
586 { WM_MOVE
, sent
|defwinproc
},
587 { WM_SIZE
, sent
|defwinproc
|wparam
|lparam
, SIZE_MINIMIZED
, 0 },
588 { WM_NCCALCSIZE
, sent
|optional
},
589 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
590 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
591 { EVENT_SYSTEM_MINIMIZESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
592 { WM_NCACTIVATE
, sent
|wparam
, 0 },
593 { WM_GETTEXT
, sent
|defwinproc
|optional
},
594 { WM_ACTIVATE
, sent
},
595 { WM_ACTIVATEAPP
, sent
|wparam
, 0 },
597 /* Vista sometimes restores the window right away... */
598 { WM_SYSCOMMAND
, sent
|optional
|wparam
, SC_RESTORE
},
599 { HCBT_SYSCOMMAND
, hook
|optional
|wparam
, SC_RESTORE
},
600 { HCBT_MINMAX
, hook
|optional
|lparam
, 0, SW_RESTORE
},
601 { WM_QUERYOPEN
, sent
|optional
},
602 { WM_WINDOWPOSCHANGING
, sent
|optional
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
603 { WM_GETMINMAXINFO
, sent
|optional
|defwinproc
},
604 { WM_NCCALCSIZE
, sent
|optional
|wparam
, TRUE
},
605 { HCBT_ACTIVATE
, hook
|optional
},
606 { WM_ACTIVATEAPP
, sent
|optional
|wparam
, 1 },
607 { WM_NCACTIVATE
, sent
|optional
},
608 { WM_GETTEXT
, sent
|optional
},
609 { WM_ACTIVATE
, sent
|optional
|wparam
, 1 },
610 { HCBT_SETFOCUS
, hook
|optional
},
611 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
612 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
613 { WM_SETFOCUS
, sent
|optional
},
614 { WM_NCPAINT
, sent
|optional
},
615 { WM_GETTEXT
, sent
|defwinproc
|optional
},
616 { WM_ERASEBKGND
, sent
|optional
},
617 { WM_WINDOWPOSCHANGED
, sent
|optional
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
618 { WM_MOVE
, sent
|defwinproc
|optional
},
619 { WM_SIZE
, sent
|defwinproc
|optional
|wparam
, SIZE_RESTORED
},
620 { WM_ACTIVATE
, sent
|optional
|wparam
, 1 },
621 { WM_SYSCOMMAND
, sent
|optional
|wparam
, SC_RESTORE
},
622 { HCBT_SYSCOMMAND
, hook
|optional
|wparam
, SC_RESTORE
},
624 { WM_PAINT
, sent
|optional
},
625 { WM_NCPAINT
, sent
|beginpaint
|optional
},
626 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
629 /* ShowWindow(SW_HIDE) for a visible overlapped window */
630 static const struct message WmHideOverlappedSeq
[] = {
631 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
632 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
633 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
634 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
635 { WM_SIZE
, sent
|optional
}, /* XP doesn't send it */
636 { WM_MOVE
, sent
|optional
}, /* XP doesn't send it */
637 { WM_NCACTIVATE
, sent
|wparam
|optional
, 0 },
638 { WM_ACTIVATE
, sent
|wparam
|optional
, 0 },
639 { WM_ACTIVATEAPP
, sent
|wparam
|optional
, 0 },
640 { HCBT_SETFOCUS
, hook
|optional
},
641 { WM_KILLFOCUS
, sent
|wparam
, 0 },
642 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
643 { WM_IME_NOTIFY
, sent
|wparam
|optional
|defwinproc
, 1 },
646 /* DestroyWindow for a visible overlapped window */
647 static const struct message WmDestroyOverlappedSeq
[] = {
648 { HCBT_DESTROYWND
, hook
},
649 { 0x0090, sent
|optional
},
650 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
651 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
652 { 0x0090, sent
|optional
},
653 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
654 { WM_NCACTIVATE
, sent
|optional
|wparam
, 0 },
655 { WM_ACTIVATE
, sent
|optional
},
656 { WM_ACTIVATEAPP
, sent
|optional
|wparam
, 0 },
657 { WM_KILLFOCUS
, sent
|optional
|wparam
, 0 },
658 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
659 { WM_IME_NOTIFY
, sent
|wparam
|optional
|defwinproc
, 1 },
660 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
661 { WM_DESTROY
, sent
},
662 { WM_NCDESTROY
, sent
},
665 /* CreateWindow(WS_MAXIMIZE|WS_VISIBLE) for popup window */
666 static const struct message WmCreateMaxPopupSeq
[] = {
667 { HCBT_CREATEWND
, hook
},
668 { WM_NCCREATE
, sent
},
669 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
671 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
672 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
674 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
675 { WM_GETMINMAXINFO
, sent
},
676 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_STATECHANGED
},
677 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
678 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOREDRAW
|SWP_STATECHANGED
},
679 { WM_MOVE
, sent
|defwinproc
},
680 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
681 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
682 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
683 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
684 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
685 { HCBT_ACTIVATE
, hook
},
686 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
687 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
688 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
689 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
690 { WM_ERASEBKGND
, sent
|optional
},
691 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOCLIENTMOVE
|SWP_NOCLIENTSIZE
|SWP_NOMOVE
|SWP_NOSIZE
},
692 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
693 { WM_NCACTIVATE
, sent
},
694 { WM_ACTIVATE
, sent
|wparam
, 1 },
695 { HCBT_SETFOCUS
, hook
},
696 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
697 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
698 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
699 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
700 { WM_GETTEXT
, sent
|optional
},
701 { WM_SYNCPAINT
, sent
|wparam
|optional
, 4 },
702 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
703 { WM_ERASEBKGND
, sent
|optional
},
704 { WM_NCPAINT
, sent
|wparam
|defwinproc
|optional
, 1 },
705 { WM_ERASEBKGND
, sent
|defwinproc
|optional
},
706 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOCLIENTMOVE
|SWP_NOCLIENTSIZE
|SWP_SHOWWINDOW
|SWP_NOMOVE
|SWP_NOSIZE
},
709 /* CreateWindow(WS_MAXIMIZE) for popup window, not initially visible */
710 static const struct message WmCreateInvisibleMaxPopupSeq
[] = {
711 { HCBT_CREATEWND
, hook
},
712 { WM_NCCREATE
, sent
},
713 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
715 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
716 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
718 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
719 { WM_GETMINMAXINFO
, sent
},
720 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_STATECHANGED
},
721 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
722 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOREDRAW
|SWP_STATECHANGED
},
723 { WM_MOVE
, sent
|defwinproc
},
724 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
725 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
728 /* ShowWindow(SW_SHOWMAXIMIZED) for a resized not visible popup window */
729 static const struct message WmShowMaxPopupResizedSeq
[] = {
730 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
731 { WM_GETMINMAXINFO
, sent
},
732 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
},
733 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
734 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
735 { HCBT_ACTIVATE
, hook
},
736 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
737 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
738 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
739 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
740 { WM_ERASEBKGND
, sent
|optional
},
741 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
742 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
743 { WM_NCACTIVATE
, sent
},
744 { WM_ACTIVATE
, sent
|wparam
, 1 },
745 { HCBT_SETFOCUS
, hook
},
746 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
747 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
748 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
749 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
750 { WM_GETTEXT
, sent
|optional
},
751 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
752 { WM_ERASEBKGND
, sent
|optional
},
753 { WM_WINDOWPOSCHANGED
, sent
},
754 /* WinNT4.0 sends WM_MOVE */
755 { WM_MOVE
, sent
|defwinproc
|optional
},
756 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
757 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
760 /* ShowWindow(SW_SHOWMAXIMIZED) for a not visible popup window */
761 static const struct message WmShowMaxPopupSeq
[] = {
762 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
763 { WM_GETMINMAXINFO
, sent
},
764 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
},
765 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
766 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
767 { HCBT_ACTIVATE
, hook
},
768 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
769 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
770 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
771 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
772 { WM_NCACTIVATE
, sent
},
773 { WM_ACTIVATE
, sent
|wparam
, 1 },
774 { HCBT_SETFOCUS
, hook
},
775 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
776 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
777 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
778 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
779 { WM_GETTEXT
, sent
|optional
},
780 { WM_SYNCPAINT
, sent
|wparam
|optional
, 4 },
781 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
782 { WM_ERASEBKGND
, sent
|optional
},
783 { WM_NCPAINT
, sent
|wparam
|defwinproc
|optional
, 1 },
784 { WM_ERASEBKGND
, sent
|defwinproc
|optional
},
785 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOMOVE
|SWP_NOSIZE
},
786 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
789 /* CreateWindow(WS_VISIBLE) for popup window */
790 static const struct message WmCreatePopupSeq
[] = {
791 { HCBT_CREATEWND
, hook
},
792 { WM_NCCREATE
, sent
},
793 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
795 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
796 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
798 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
799 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
800 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
801 { HCBT_ACTIVATE
, hook
},
802 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
803 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
804 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
805 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
806 { WM_ERASEBKGND
, sent
|optional
},
807 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
808 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
809 { WM_NCACTIVATE
, sent
},
810 { WM_ACTIVATE
, sent
|wparam
, 1 },
811 { HCBT_SETFOCUS
, hook
},
812 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
813 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
814 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
815 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
816 { WM_GETTEXT
, sent
|optional
},
817 { WM_SYNCPAINT
, sent
|wparam
|optional
, 4 },
818 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
819 { WM_ERASEBKGND
, sent
|optional
},
820 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOCLIENTMOVE
|SWP_NOCLIENTSIZE
|SWP_SHOWWINDOW
|SWP_NOMOVE
|SWP_NOSIZE
},
823 /* ShowWindow(SW_SHOWMAXIMIZED) for a visible popup window */
824 static const struct message WmShowVisMaxPopupSeq
[] = {
825 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
826 { WM_GETMINMAXINFO
, sent
},
827 { WM_GETTEXT
, sent
|optional
},
828 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
829 { WM_GETTEXT
, sent
|optional
},
830 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
831 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
832 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
833 { WM_ERASEBKGND
, sent
|optional
},
834 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
835 { WM_MOVE
, sent
|defwinproc
},
836 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
837 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
840 /* CreateWindow (for a child popup window, not initially visible) */
841 static const struct message WmCreateChildPopupSeq
[] = {
842 { HCBT_CREATEWND
, hook
},
843 { WM_NCCREATE
, sent
},
844 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
846 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
847 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
851 /* CreateWindow (for a popup window, not initially visible,
852 * which sets WS_VISIBLE in WM_CREATE handler)
854 static const struct message WmCreateInvisiblePopupSeq
[] = {
855 { HCBT_CREATEWND
, hook
},
856 { WM_NCCREATE
, sent
},
857 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
859 { WM_STYLECHANGING
, sent
},
860 { WM_STYLECHANGED
, sent
},
861 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
862 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
866 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER)
867 * for a popup window with WS_VISIBLE style set
869 static const struct message WmShowVisiblePopupSeq_2
[] = {
870 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
873 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
874 * for a popup window with WS_VISIBLE style set
876 static const struct message WmShowVisiblePopupSeq_3
[] = {
877 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
878 { HCBT_ACTIVATE
, hook
},
879 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
880 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
881 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
882 { WM_NCACTIVATE
, sent
},
883 { WM_ACTIVATE
, sent
|wparam
, 1 },
884 { HCBT_SETFOCUS
, hook
},
885 { WM_KILLFOCUS
, sent
|parent
},
886 { WM_IME_SETCONTEXT
, sent
|parent
|wparam
|optional
, 0 },
887 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
888 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
889 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
890 { WM_SETFOCUS
, sent
|defwinproc
},
891 { WM_GETTEXT
, sent
|optional
},
892 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
, 0, SWP_SHOWWINDOW
},
895 /* CreateWindow (for child window, not initially visible) */
896 static const struct message WmCreateChildSeq
[] = {
897 { HCBT_CREATEWND
, hook
},
898 { WM_NCCREATE
, sent
},
899 /* child is inserted into parent's child list after WM_NCCREATE returns */
900 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
902 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
903 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
905 { WM_PARENTNOTIFY
, sent
|parent
|wparam
, WM_CREATE
},
908 /* CreateWindow (for maximized child window, not initially visible) */
909 static const struct message WmCreateMaximizedChildSeq
[] = {
910 { HCBT_CREATEWND
, hook
},
911 { WM_NCCREATE
, sent
},
912 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
914 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
915 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
917 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
918 { WM_GETMINMAXINFO
, sent
},
919 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_STATECHANGED
},
920 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
921 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
922 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
923 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
924 { WM_PARENTNOTIFY
, sent
|parent
|wparam
, WM_CREATE
},
927 /* CreateWindow (for a child window, initially visible) */
928 static const struct message WmCreateVisibleChildSeq
[] = {
929 { HCBT_CREATEWND
, hook
},
930 { WM_NCCREATE
, sent
},
931 /* child is inserted into parent's child list after WM_NCCREATE returns */
932 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
933 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
935 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
936 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
938 { WM_PARENTNOTIFY
, sent
|parent
|wparam
, WM_CREATE
},
939 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
940 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
941 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
942 { WM_ERASEBKGND
, sent
|parent
|optional
},
943 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
944 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 }, /* WinXP */
945 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
948 /* ShowWindow(SW_SHOW) for a not visible child window */
949 static const struct message WmShowChildSeq
[] = {
950 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
951 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
952 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
953 { WM_ERASEBKGND
, sent
|parent
|optional
},
954 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
957 /* ShowWindow(SW_HIDE) for a visible child window */
958 static const struct message WmHideChildSeq
[] = {
959 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
960 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
961 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
962 { WM_ERASEBKGND
, sent
|parent
|optional
},
963 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
966 /* ShowWindow(SW_HIDE) for a visible child window checking all parent events*/
967 static const struct message WmHideChildSeq2
[] = {
968 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
969 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
970 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
971 { WM_ERASEBKGND
, sent
|parent
|optional
},
972 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
975 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
976 * for a not visible child window
978 static const struct message WmShowChildSeq_2
[] = {
979 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
980 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
981 { WM_CHILDACTIVATE
, sent
},
982 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
985 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE)
986 * for a not visible child window
988 static const struct message WmShowChildSeq_3
[] = {
989 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
990 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
991 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
994 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
995 * for a visible child window with a caption
997 static const struct message WmShowChildSeq_4
[] = {
998 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
999 { WM_CHILDACTIVATE
, sent
},
1002 /* ShowWindow(SW_MINIMIZE) for child with invisible parent */
1003 static const struct message WmShowChildInvisibleParentSeq_1
[] = {
1004 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
1005 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
, 0, SWP_NOACTIVATE
},
1006 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1007 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1008 { WM_CHILDACTIVATE
, sent
|optional
},
1009 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOREDRAW
|SWP_NOCOPYBITS
|SWP_STATECHANGED
, 0, SWP_NOACTIVATE
},
1010 { WM_MOVE
, sent
|defwinproc
},
1011 { WM_SIZE
, sent
|defwinproc
|wparam
|lparam
, SIZE_MINIMIZED
, 0 },
1012 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1013 { EVENT_SYSTEM_MINIMIZESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
1014 /* FIXME: Wine creates an icon/title window while Windows doesn't */
1015 { WM_PARENTNOTIFY
, sent
|parent
|wparam
|optional
, WM_CREATE
},
1016 { WM_GETTEXT
, sent
|optional
},
1019 /* repeated ShowWindow(SW_MINIMIZE) for child with invisible parent */
1020 static const struct message WmShowChildInvisibleParentSeq_1r
[] = {
1021 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
1024 /* ShowWindow(SW_MAXIMIZE) for child with invisible parent */
1025 static const struct message WmShowChildInvisibleParentSeq_2
[] = {
1026 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
1027 { WM_GETMINMAXINFO
, sent
},
1028 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_STATECHANGED
},
1029 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1030 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1031 { WM_CHILDACTIVATE
, sent
},
1032 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
1033 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
1034 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1037 /* repeated ShowWindow(SW_MAXIMIZE) for child with invisible parent */
1038 static const struct message WmShowChildInvisibleParentSeq_2r
[] = {
1039 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
1042 /* ShowWindow(SW_SHOWMINIMIZED) for child with invisible parent */
1043 static const struct message WmShowChildInvisibleParentSeq_3
[] = {
1044 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINIMIZED
},
1045 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
1046 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1047 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1048 { WM_CHILDACTIVATE
, sent
},
1049 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOREDRAW
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
1050 { WM_MOVE
, sent
|defwinproc
},
1051 { WM_SIZE
, sent
|defwinproc
|wparam
|lparam
, SIZE_MINIMIZED
, 0 },
1052 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1053 { EVENT_SYSTEM_MINIMIZESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
1054 /* FIXME: Wine creates an icon/title window while Windows doesn't */
1055 { WM_PARENTNOTIFY
, sent
|parent
|wparam
|optional
, WM_CREATE
},
1056 { WM_GETTEXT
, sent
|optional
},
1059 /* repeated ShowWindow(SW_SHOWMINIMIZED) for child with invisible parent */
1060 static const struct message WmShowChildInvisibleParentSeq_3r
[] = {
1061 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINIMIZED
},
1064 /* ShowWindow(SW_SHOWMINNOACTIVE) for child with invisible parent */
1065 static const struct message WmShowChildInvisibleParentSeq_4
[] = {
1066 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINNOACTIVE
},
1067 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
1068 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1069 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1070 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOREDRAW
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
1071 { WM_MOVE
, sent
|defwinproc
},
1072 { WM_SIZE
, sent
|defwinproc
|wparam
|lparam
, SIZE_MINIMIZED
, 0 },
1073 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1074 { EVENT_SYSTEM_MINIMIZESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
1075 /* FIXME: Wine creates an icon/title window while Windows doesn't */
1076 { WM_PARENTNOTIFY
, sent
|parent
|wparam
|optional
, WM_CREATE
},
1077 { WM_GETTEXT
, sent
|optional
},
1080 /* repeated ShowWindow(SW_SHOWMINNOACTIVE) for child with invisible parent */
1081 static const struct message WmShowChildInvisibleParentSeq_4r
[] = {
1082 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINNOACTIVE
},
1085 /* ShowWindow(SW_SHOW) for child with invisible parent */
1086 static const struct message WmShowChildInvisibleParentSeq_5
[] = {
1087 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1090 /* ShowWindow(SW_HIDE) for child with invisible parent */
1091 static const struct message WmHideChildInvisibleParentSeq
[] = {
1092 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
1095 /* SetWindowPos(SWP_SHOWWINDOW) for child with invisible parent */
1096 static const struct message WmShowChildInvisibleParentSeq_6
[] = {
1097 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
1098 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1099 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1102 /* SetWindowPos(SWP_HIDEWINDOW) for child with invisible parent */
1103 static const struct message WmHideChildInvisibleParentSeq_2
[] = {
1104 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1105 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1106 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1109 /* DestroyWindow for a visible child window */
1110 static const struct message WmDestroyChildSeq
[] = {
1111 { HCBT_DESTROYWND
, hook
},
1112 { 0x0090, sent
|optional
},
1113 { WM_PARENTNOTIFY
, sent
|parent
|wparam
, WM_DESTROY
},
1114 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
1115 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1116 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1117 { WM_ERASEBKGND
, sent
|parent
|optional
},
1118 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1119 { HCBT_SETFOCUS
, hook
}, /* set focus to a parent */
1120 { WM_KILLFOCUS
, sent
},
1121 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
1122 { WM_IME_SETCONTEXT
, sent
|wparam
|parent
|optional
, 1 },
1123 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1124 { WM_SETFOCUS
, sent
|parent
},
1125 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
1126 { WM_DESTROY
, sent
},
1127 { WM_DESTROY
, sent
|optional
}, /* some other (IME?) window */
1128 { WM_NCDESTROY
, sent
|optional
}, /* some other (IME?) window */
1129 { WM_NCDESTROY
, sent
},
1132 /* visible child window destroyed by thread exit */
1133 static const struct message WmExitThreadSeq
[] = {
1134 { WM_NCDESTROY
, sent
}, /* actually in grandchild */
1135 { WM_PAINT
, sent
|parent
},
1136 { WM_ERASEBKGND
, sent
|parent
|beginpaint
},
1139 /* DestroyWindow for a visible child window with invisible parent */
1140 static const struct message WmDestroyInvisibleChildSeq
[] = {
1141 { HCBT_DESTROYWND
, hook
},
1142 { 0x0090, sent
|optional
},
1143 { WM_PARENTNOTIFY
, sent
|parent
|wparam
, WM_DESTROY
},
1144 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
1145 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
1146 { WM_DESTROY
, sent
},
1147 { WM_NCDESTROY
, sent
},
1150 /* Moving the mouse in nonclient area */
1151 static const struct message WmMouseMoveInNonClientAreaSeq
[] = { /* FIXME: add */
1152 { WM_NCHITTEST
, sent
},
1153 { WM_SETCURSOR
, sent
},
1154 { WM_NCMOUSEMOVE
, posted
},
1157 /* Moving the mouse in client area */
1158 static const struct message WmMouseMoveInClientAreaSeq
[] = { /* FIXME: add */
1159 { WM_NCHITTEST
, sent
},
1160 { WM_SETCURSOR
, sent
},
1161 { WM_MOUSEMOVE
, posted
},
1164 /* Moving by dragging the title bar (after WM_NCHITTEST and WM_SETCURSOR) (outline move) */
1165 static const struct message WmDragTitleBarSeq
[] = { /* FIXME: add */
1166 { WM_NCLBUTTONDOWN
, sent
|wparam
, HTCAPTION
},
1167 { WM_SYSCOMMAND
, sent
|defwinproc
|wparam
, SC_MOVE
+2 },
1168 { WM_GETMINMAXINFO
, sent
|defwinproc
},
1169 { WM_ENTERSIZEMOVE
, sent
|defwinproc
},
1170 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, 0 },
1171 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, 0 },
1172 { WM_MOVE
, sent
|defwinproc
},
1173 { WM_EXITSIZEMOVE
, sent
|defwinproc
},
1176 /* Sizing by dragging the thick borders (after WM_NCHITTEST and WM_SETCURSOR) (outline move) */
1177 static const struct message WmDragThickBordersBarSeq
[] = { /* FIXME: add */
1178 { WM_NCLBUTTONDOWN
, sent
|wparam
, 0xd },
1179 { WM_SYSCOMMAND
, sent
|defwinproc
|wparam
, 0xf004 },
1180 { WM_GETMINMAXINFO
, sent
|defwinproc
},
1181 { WM_ENTERSIZEMOVE
, sent
|defwinproc
},
1182 { WM_SIZING
, sent
|defwinproc
|wparam
, 4}, /* one for each mouse movement */
1183 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, 0 },
1184 { WM_GETMINMAXINFO
, sent
|defwinproc
},
1185 { WM_NCCALCSIZE
, sent
|defwinproc
|wparam
, 1 },
1186 { WM_NCPAINT
, sent
|defwinproc
|wparam
, 1 },
1187 { WM_GETTEXT
, sent
|defwinproc
},
1188 { WM_ERASEBKGND
, sent
|defwinproc
},
1189 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, 0 },
1190 { WM_MOVE
, sent
|defwinproc
},
1191 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
1192 { WM_EXITSIZEMOVE
, sent
|defwinproc
},
1195 /* Resizing child window with MoveWindow (32) */
1196 static const struct message WmResizingChildWithMoveWindowSeq
[] = {
1197 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
1198 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1199 { WM_ERASEBKGND
, sent
|parent
|optional
},
1200 { WM_ERASEBKGND
, sent
|optional
},
1201 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
},
1202 { WM_MOVE
, sent
|defwinproc
},
1203 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
1204 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1207 /* Clicking on inactive button */
1208 static const struct message WmClickInactiveButtonSeq
[] = { /* FIXME: add */
1209 { WM_NCHITTEST
, sent
},
1210 { WM_PARENTNOTIFY
, sent
|parent
|wparam
, WM_LBUTTONDOWN
},
1211 { WM_MOUSEACTIVATE
, sent
},
1212 { WM_MOUSEACTIVATE
, sent
|parent
|defwinproc
},
1213 { WM_SETCURSOR
, sent
},
1214 { WM_SETCURSOR
, sent
|parent
|defwinproc
},
1215 { WM_LBUTTONDOWN
, posted
},
1216 { WM_KILLFOCUS
, posted
|parent
},
1217 { WM_SETFOCUS
, posted
},
1218 { WM_CTLCOLORBTN
, posted
|parent
},
1219 { BM_SETSTATE
, posted
},
1220 { WM_CTLCOLORBTN
, posted
|parent
},
1221 { WM_LBUTTONUP
, posted
},
1222 { BM_SETSTATE
, posted
},
1223 { WM_CTLCOLORBTN
, posted
|parent
},
1224 { WM_COMMAND
, posted
|parent
},
1227 /* Reparenting a button (16/32) */
1228 /* The last child (button) reparented gets topmost for its new parent. */
1229 static const struct message WmReparentButtonSeq
[] = { /* FIXME: add */
1230 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
1231 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOSIZE
},
1232 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1233 { WM_ERASEBKGND
, sent
|parent
},
1234 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOSIZE
},
1235 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
},
1236 { WM_CHILDACTIVATE
, sent
},
1237 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOSIZE
|SWP_NOREDRAW
},
1238 { WM_MOVE
, sent
|defwinproc
},
1239 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1242 /* Creation of a custom dialog (32) */
1243 static const struct message WmCreateCustomDialogSeq
[] = {
1244 { HCBT_CREATEWND
, hook
},
1245 { WM_GETMINMAXINFO
, sent
},
1246 { WM_NCCREATE
, sent
},
1247 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
1248 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
1249 { WM_CREATE
, sent
},
1250 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1251 { WM_NOTIFYFORMAT
, sent
|optional
},
1252 { WM_QUERYUISTATE
, sent
|optional
},
1253 { WM_WINDOWPOSCHANGING
, sent
|optional
},
1254 { WM_GETMINMAXINFO
, sent
|optional
},
1255 { WM_NCCALCSIZE
, sent
|optional
},
1256 { WM_WINDOWPOSCHANGED
, sent
|optional
},
1257 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1258 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
1259 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1260 { HCBT_ACTIVATE
, hook
},
1261 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
1264 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
1266 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
1268 { WM_NCACTIVATE
, sent
},
1269 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1270 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1271 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1272 { EVENT_OBJECT_DEFACTIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, OBJID_CLIENT
, 0 },
1273 { WM_ACTIVATE
, sent
|wparam
, 1 },
1274 { WM_GETTEXT
, sent
|optional
},
1275 { WM_KILLFOCUS
, sent
|parent
},
1276 { WM_IME_SETCONTEXT
, sent
|parent
|wparam
|optional
, 0 },
1277 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
1278 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
1279 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1280 { WM_SETFOCUS
, sent
},
1281 { WM_GETDLGCODE
, sent
|defwinproc
|wparam
, 0 },
1282 { WM_NCPAINT
, sent
|wparam
, 1 },
1283 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1284 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1285 { WM_ERASEBKGND
, sent
},
1286 { WM_CTLCOLORDLG
, sent
|optional
|defwinproc
},
1287 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1288 { WM_GETTEXT
, sent
|optional
},
1289 { WM_GETTEXT
, sent
|optional
},
1290 { WM_NCCALCSIZE
, sent
|optional
},
1291 { WM_NCPAINT
, sent
|optional
},
1292 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1293 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1294 { WM_ERASEBKGND
, sent
|optional
},
1295 { WM_CTLCOLORDLG
, sent
|optional
|defwinproc
},
1296 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1297 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
1301 /* Calling EndDialog for a custom dialog (32) */
1302 static const struct message WmEndCustomDialogSeq
[] = {
1303 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1304 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1305 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1306 { WM_GETTEXT
, sent
|optional
},
1307 { HCBT_ACTIVATE
, hook
},
1308 { WM_NCACTIVATE
, sent
|wparam
, 0 },
1309 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1310 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1311 { WM_ACTIVATE
, sent
|wparam
, 0 },
1312 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
1313 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1314 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOACTIVATE
|SWP_NOREDRAW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1315 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1316 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1317 { HCBT_SETFOCUS
, hook
},
1318 { WM_KILLFOCUS
, sent
},
1319 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
1320 { WM_IME_SETCONTEXT
, sent
|parent
|wparam
|defwinproc
|optional
, 1 },
1321 { WM_IME_NOTIFY
, sent
|wparam
|optional
, 1 },
1322 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1323 { WM_SETFOCUS
, sent
|parent
|defwinproc
},
1326 /* ShowWindow(SW_SHOW) for a custom dialog (initially invisible) */
1327 static const struct message WmShowCustomDialogSeq
[] = {
1328 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1329 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
1330 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1331 { HCBT_ACTIVATE
, hook
},
1332 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
1334 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
1336 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
1337 { WM_ACTIVATEAPP
, sent
|wparam
|optional
, 1 },
1338 { WM_NCACTIVATE
, sent
},
1339 { WM_ACTIVATE
, sent
|wparam
, 1 },
1340 { WM_GETTEXT
, sent
|optional
},
1342 { WM_KILLFOCUS
, sent
|parent
},
1343 { WM_IME_SETCONTEXT
, sent
|parent
|wparam
|optional
, 0 },
1344 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
1345 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
1346 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1347 { WM_SETFOCUS
, sent
},
1348 { WM_GETDLGCODE
, sent
|defwinproc
|wparam
, 0 },
1349 { WM_NCPAINT
, sent
|wparam
, 1 },
1350 { WM_ERASEBKGND
, sent
},
1351 { WM_CTLCOLORDLG
, sent
|defwinproc
},
1352 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1355 /* Creation and destruction of a modal dialog (32) */
1356 static const struct message WmModalDialogSeq
[] = {
1357 { WM_CANCELMODE
, sent
|parent
},
1358 { HCBT_SETFOCUS
, hook
},
1359 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1360 { WM_KILLFOCUS
, sent
|parent
},
1361 { WM_IME_SETCONTEXT
, sent
|parent
|wparam
|optional
, 0 },
1362 { EVENT_OBJECT_STATECHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1363 { WM_ENABLE
, sent
|parent
|wparam
, 0 },
1364 { HCBT_CREATEWND
, hook
},
1365 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
1366 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1367 { WM_SETFONT
, sent
},
1368 { WM_INITDIALOG
, sent
},
1369 { WM_CHANGEUISTATE
, sent
|optional
},
1370 { WM_UPDATEUISTATE
, sent
|optional
},
1371 { WM_SHOWWINDOW
, sent
},
1372 { HCBT_ACTIVATE
, hook
},
1373 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
1374 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
1375 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
},
1376 { WM_NCACTIVATE
, sent
},
1377 { WM_GETTEXT
, sent
|optional
},
1378 { WM_ACTIVATE
, sent
|wparam
, 1 },
1379 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
1380 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1381 { WM_NCPAINT
, sent
|optional
},
1382 { WM_GETTEXT
, sent
|optional
},
1383 { WM_ERASEBKGND
, sent
|optional
},
1384 { WM_CTLCOLORDLG
, sent
|optional
},
1385 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1386 { WM_GETTEXT
, sent
|optional
},
1387 { WM_NCCALCSIZE
, sent
|optional
},
1388 { WM_NCPAINT
, sent
|optional
},
1389 { WM_GETTEXT
, sent
|optional
},
1390 { WM_ERASEBKGND
, sent
|optional
},
1391 { WM_CTLCOLORDLG
, sent
|optional
},
1392 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1393 { WM_PAINT
, sent
|optional
},
1394 { WM_CTLCOLORBTN
, sent
|optional
},
1395 { WM_GETTITLEBARINFOEX
, sent
|optional
},
1396 { WM_ENTERIDLE
, sent
|parent
|optional
},
1397 { WM_ENTERIDLE
, sent
|parent
|optional
},
1398 { WM_ENTERIDLE
, sent
|parent
|optional
},
1399 { WM_ENTERIDLE
, sent
|parent
|optional
},
1400 { WM_ENTERIDLE
, sent
|parent
|optional
},
1401 { WM_ENTERIDLE
, sent
|parent
|optional
},
1402 { WM_ENTERIDLE
, sent
|parent
|optional
},
1403 { WM_ENTERIDLE
, sent
|parent
|optional
},
1404 { WM_ENTERIDLE
, sent
|parent
|optional
},
1405 { WM_ENTERIDLE
, sent
|parent
|optional
},
1406 { WM_ENTERIDLE
, sent
|parent
|optional
},
1407 { WM_ENTERIDLE
, sent
|parent
|optional
},
1408 { WM_ENTERIDLE
, sent
|parent
|optional
},
1409 { WM_ENTERIDLE
, sent
|parent
|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
},
1417 { EVENT_OBJECT_STATECHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1418 { WM_ENABLE
, sent
|parent
|wparam
, 1 },
1419 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
1420 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1421 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1422 { WM_GETTEXT
, sent
|optional
},
1423 { HCBT_ACTIVATE
, hook
},
1424 { WM_NCACTIVATE
, sent
|wparam
, 0 },
1425 { WM_GETTEXT
, sent
|optional
},
1426 { WM_ACTIVATE
, sent
|wparam
, 0 },
1427 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
1428 { WM_WINDOWPOSCHANGING
, sent
|optional
},
1429 { WM_WINDOWPOSCHANGED
, sent
|optional
},
1430 { HCBT_SETFOCUS
, hook
},
1431 { WM_IME_SETCONTEXT
, sent
|parent
|wparam
|defwinproc
|optional
, 1 },
1432 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1433 { WM_SETFOCUS
, sent
|parent
|defwinproc
},
1434 { EVENT_SYSTEM_DIALOGEND
, winevent_hook
|wparam
|lparam
, 0, 0 },
1435 { HCBT_DESTROYWND
, hook
},
1436 { 0x0090, sent
|optional
},
1437 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
1438 { WM_DESTROY
, sent
},
1439 { WM_NCDESTROY
, sent
},
1442 /* Creation of a modal dialog that is resized inside WM_INITDIALOG (32) */
1443 static const struct message WmCreateModalDialogResizeSeq
[] = { /* FIXME: add */
1444 /* (inside dialog proc, handling WM_INITDIALOG) */
1445 { WM_WINDOWPOSCHANGING
, sent
|wparam
, 0 },
1446 { WM_NCCALCSIZE
, sent
},
1447 { WM_NCACTIVATE
, sent
|parent
|wparam
, 0 },
1448 { WM_GETTEXT
, sent
|defwinproc
},
1449 { WM_ACTIVATE
, sent
|parent
|wparam
, 0 },
1450 { WM_WINDOWPOSCHANGING
, sent
|wparam
, 0 },
1451 { WM_WINDOWPOSCHANGING
, sent
|parent
},
1452 { WM_NCACTIVATE
, sent
|wparam
, 1 },
1453 { WM_ACTIVATE
, sent
|wparam
, 1 },
1454 { WM_WINDOWPOSCHANGED
, sent
|wparam
, 0 },
1455 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
1456 /* (setting focus) */
1457 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1458 { WM_WINDOWPOSCHANGING
, sent
|wparam
, 0 },
1459 { WM_NCPAINT
, sent
},
1460 { WM_GETTEXT
, sent
|defwinproc
},
1461 { WM_ERASEBKGND
, sent
},
1462 { WM_CTLCOLORDLG
, sent
|defwinproc
},
1463 { WM_WINDOWPOSCHANGED
, sent
|wparam
, 0 },
1465 /* (bunch of WM_CTLCOLOR* for each control) */
1466 { WM_PAINT
, sent
|parent
},
1467 { WM_ENTERIDLE
, sent
|parent
|wparam
, 0 },
1468 { WM_SETCURSOR
, sent
|parent
},
1471 /* SetMenu for NonVisible windows with size change*/
1472 static const struct message WmSetMenuNonVisibleSizeChangeSeq
[] = {
1473 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1474 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1475 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
1476 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
},
1477 { WM_MOVE
, sent
|defwinproc
},
1478 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
1479 { WM_NCCALCSIZE
,sent
|wparam
|optional
, 1 }, /* XP */
1480 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1481 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* XP sends a duplicate */
1482 { WM_GETTEXT
, sent
|optional
},
1483 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
1486 /* SetMenu for NonVisible windows with no size change */
1487 static const struct message WmSetMenuNonVisibleNoSizeChangeSeq
[] = {
1488 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1489 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1490 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1491 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1494 /* SetMenu for Visible windows with size change */
1495 static const struct message WmSetMenuVisibleSizeChangeSeq
[] = {
1496 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1497 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1498 { 0x0093, sent
|defwinproc
|optional
},
1499 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
1500 { WM_NCPAINT
, sent
|optional
}, /* wparam != 1 */
1501 { 0x0093, sent
|defwinproc
|optional
},
1502 { 0x0093, sent
|defwinproc
|optional
},
1503 { 0x0091, sent
|defwinproc
|optional
},
1504 { 0x0092, sent
|defwinproc
|optional
},
1505 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1506 { WM_ERASEBKGND
, sent
|optional
},
1507 { WM_ACTIVATE
, sent
|optional
},
1508 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1509 { WM_MOVE
, sent
|defwinproc
},
1510 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
1511 { 0x0093, sent
|optional
},
1512 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
1513 { 0x0093, sent
|defwinproc
|optional
},
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_ERASEBKGND
, sent
|optional
},
1520 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1521 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* XP sends a duplicate */
1524 /* SetMenu for Visible windows with no size change */
1525 static const struct message WmSetMenuVisibleNoSizeChangeSeq
[] = {
1526 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1527 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1528 { WM_NCPAINT
, sent
|optional
}, /* wparam != 1 */
1529 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1530 { WM_ERASEBKGND
, sent
|optional
},
1531 { WM_ACTIVATE
, sent
|optional
},
1532 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1533 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1536 /* DrawMenuBar for a visible window */
1537 static const struct message WmDrawMenuBarSeq
[] =
1539 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1540 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1541 { 0x0093, sent
|defwinproc
|optional
},
1542 { WM_NCPAINT
, sent
|optional
}, /* wparam != 1 */
1543 { 0x0093, sent
|defwinproc
|optional
},
1544 { 0x0093, sent
|defwinproc
|optional
},
1545 { 0x0091, sent
|defwinproc
|optional
},
1546 { 0x0092, sent
|defwinproc
|optional
},
1547 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1548 { WM_ERASEBKGND
, sent
|optional
},
1549 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1550 { 0x0093, sent
|optional
},
1551 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1555 static const struct message WmSetRedrawFalseSeq
[] =
1557 { WM_SETREDRAW
, sent
|wparam
, 0 },
1561 static const struct message WmSetRedrawTrueSeq
[] =
1563 { WM_SETREDRAW
, sent
|wparam
, 1 },
1567 static const struct message WmEnableWindowSeq_1
[] =
1569 { WM_CANCELMODE
, sent
|wparam
|lparam
, 0, 0 },
1570 { EVENT_OBJECT_STATECHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1571 { HCBT_SETFOCUS
, hook
|optional
},
1572 { WM_KILLFOCUS
, sent
|optional
},
1573 { WM_ENABLE
, sent
|wparam
|lparam
, FALSE
, 0 },
1577 static const struct message WmEnableWindowSeq_2
[] =
1579 { EVENT_OBJECT_STATECHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1580 { WM_ENABLE
, sent
|wparam
|lparam
, TRUE
, 0 },
1584 static const struct message WmGetScrollRangeSeq
[] =
1586 { SBM_GETRANGE
, sent
},
1589 static const struct message WmGetScrollInfoSeq
[] =
1591 { SBM_GETSCROLLINFO
, sent
},
1594 static const struct message WmSetScrollRangeSeq
[] =
1596 /* MSDN claims that Windows sends SBM_SETRANGE message, but win2k SP4
1597 sends SBM_SETSCROLLINFO.
1599 { SBM_SETSCROLLINFO
, sent
},
1602 /* SetScrollRange for a window without a non-client area */
1603 static const struct message WmSetScrollRangeHSeq_empty
[] =
1605 { EVENT_OBJECT_VALUECHANGE
, winevent_hook
|wparam
|lparam
, OBJID_HSCROLL
, 0 },
1608 static const struct message WmSetScrollRangeVSeq_empty
[] =
1610 { EVENT_OBJECT_VALUECHANGE
, winevent_hook
|wparam
|lparam
, OBJID_VSCROLL
, 0 },
1613 static const struct message WmSetScrollRangeHVSeq
[] =
1615 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOSIZE
},
1616 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1617 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1618 { WM_ERASEBKGND
, sent
|optional
},
1619 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1620 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1621 { EVENT_OBJECT_VALUECHANGE
, winevent_hook
|lparam
|optional
, 0/*OBJID_HSCROLL or OBJID_VSCROLL*/, 0 },
1624 /* SetScrollRange for a window with a non-client area */
1625 static const struct message WmSetScrollRangeHV_NC_Seq
[] =
1627 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOSIZE
},
1628 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1629 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
1630 { WM_NCPAINT
, sent
|optional
},
1631 { WM_STYLECHANGING
, sent
|defwinproc
|optional
},
1632 { WM_STYLECHANGED
, sent
|defwinproc
|optional
},
1633 { WM_STYLECHANGING
, sent
|defwinproc
|optional
},
1634 { WM_STYLECHANGED
, sent
|defwinproc
|optional
},
1635 { WM_STYLECHANGING
, sent
|defwinproc
|optional
},
1636 { WM_STYLECHANGED
, sent
|defwinproc
|optional
},
1637 { WM_STYLECHANGING
, sent
|defwinproc
|optional
},
1638 { WM_STYLECHANGED
, sent
|defwinproc
|optional
},
1639 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1640 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1641 { WM_ERASEBKGND
, sent
|optional
},
1642 { WM_CTLCOLORDLG
, sent
|defwinproc
|optional
}, /* sent to a parent of the dialog */
1643 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOCLIENTMOVE
, 0, SWP_NOCLIENTSIZE
},
1644 { WM_SIZE
, sent
|defwinproc
|optional
},
1645 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1646 { EVENT_OBJECT_VALUECHANGE
, winevent_hook
|lparam
|optional
, 0/*OBJID_HSCROLL or OBJID_VSCROLL*/, 0 },
1647 { WM_GETTEXT
, sent
|optional
},
1648 { WM_GETTEXT
, sent
|optional
},
1649 { WM_GETTEXT
, sent
|optional
},
1650 { WM_GETTEXT
, sent
|optional
},
1653 /* test if we receive the right sequence of messages */
1654 /* after calling ShowWindow( SW_SHOWNA) */
1655 static const struct message WmSHOWNAChildInvisParInvis
[] = {
1656 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1659 static const struct message WmSHOWNAChildVisParInvis
[] = {
1660 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1663 static const struct message WmSHOWNAChildVisParVis
[] = {
1664 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1665 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
1668 static const struct message WmSHOWNAChildInvisParVis
[] = {
1669 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1670 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1671 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1672 { WM_ERASEBKGND
, sent
|optional
},
1673 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOACTIVATE
|SWP_NOCLIENTMOVE
},
1676 static const struct message WmSHOWNATopVisible
[] = {
1677 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1678 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
1679 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
1680 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1681 { WM_ERASEBKGND
, sent
|optional
},
1682 { WM_WINDOWPOSCHANGED
, sent
|optional
},
1685 static const struct message WmSHOWNATopInvisible
[] = {
1686 { WM_NOTIFYFORMAT
, sent
|optional
},
1687 { WM_QUERYUISTATE
, sent
|optional
},
1688 { WM_WINDOWPOSCHANGING
, sent
|optional
},
1689 { WM_GETMINMAXINFO
, sent
|optional
},
1690 { WM_NCCALCSIZE
, sent
|optional
},
1691 { WM_WINDOWPOSCHANGED
, sent
|optional
},
1692 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1693 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1694 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1695 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
1696 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1697 { WM_ERASEBKGND
, sent
|optional
},
1698 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1699 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
1700 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
1701 { WM_ERASEBKGND
, sent
|optional
},
1702 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1703 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
1708 static int after_end_dialog
, test_def_id
;
1709 static int sequence_cnt
, sequence_size
;
1710 static struct recvd_message
* sequence
;
1711 static int log_all_parent_messages
;
1712 static int paint_loop_done
;
1714 /* user32 functions */
1715 static HWND (WINAPI
*pGetAncestor
)(HWND
,UINT
);
1716 static BOOL (WINAPI
*pGetMenuInfo
)(HMENU
,LPCMENUINFO
);
1717 static void (WINAPI
*pNotifyWinEvent
)(DWORD
, HWND
, LONG
, LONG
);
1718 static BOOL (WINAPI
*pSetMenuInfo
)(HMENU
,LPCMENUINFO
);
1719 static HWINEVENTHOOK (WINAPI
*pSetWinEventHook
)(DWORD
, DWORD
, HMODULE
, WINEVENTPROC
, DWORD
, DWORD
, DWORD
);
1720 static BOOL (WINAPI
*pTrackMouseEvent
)(TRACKMOUSEEVENT
*);
1721 static BOOL (WINAPI
*pUnhookWinEvent
)(HWINEVENTHOOK
);
1722 static BOOL (WINAPI
*pGetMonitorInfoA
)(HMONITOR
,LPMONITORINFO
);
1723 static HMONITOR (WINAPI
*pMonitorFromPoint
)(POINT
,DWORD
);
1724 /* kernel32 functions */
1725 static BOOL (WINAPI
*pGetCPInfoExA
)(UINT
, DWORD
, LPCPINFOEXA
);
1727 static void init_procs(void)
1729 HMODULE user32
= GetModuleHandleA("user32.dll");
1730 HMODULE kernel32
= GetModuleHandleA("kernel32.dll");
1732 #define GET_PROC(dll, func) \
1733 p ## func = (void*)GetProcAddress(dll, #func); \
1735 trace("GetProcAddress(%s) failed\n", #func); \
1738 GET_PROC(user32
, GetAncestor
)
1739 GET_PROC(user32
, GetMenuInfo
)
1740 GET_PROC(user32
, NotifyWinEvent
)
1741 GET_PROC(user32
, SetMenuInfo
)
1742 GET_PROC(user32
, SetWinEventHook
)
1743 GET_PROC(user32
, TrackMouseEvent
)
1744 GET_PROC(user32
, UnhookWinEvent
)
1745 GET_PROC(user32
, GetMonitorInfoA
)
1746 GET_PROC(user32
, MonitorFromPoint
)
1748 GET_PROC(kernel32
, GetCPInfoExA
)
1753 static const char *get_winpos_flags(UINT flags
)
1755 static char buffer
[300];
1758 #define DUMP(flag) do { if (flags & flag) { strcat( buffer, "|" #flag ); flags &= ~flag; } } while(0)
1759 DUMP( SWP_SHOWWINDOW
);
1760 DUMP( SWP_HIDEWINDOW
);
1761 DUMP( SWP_NOACTIVATE
);
1762 DUMP( SWP_FRAMECHANGED
);
1763 DUMP( SWP_NOCOPYBITS
);
1764 DUMP( SWP_NOOWNERZORDER
);
1765 DUMP( SWP_NOSENDCHANGING
);
1766 DUMP( SWP_DEFERERASE
);
1767 DUMP( SWP_ASYNCWINDOWPOS
);
1768 DUMP( SWP_NOZORDER
);
1769 DUMP( SWP_NOREDRAW
);
1772 DUMP( SWP_NOCLIENTSIZE
);
1773 DUMP( SWP_NOCLIENTMOVE
);
1774 if (flags
) sprintf(buffer
+ strlen(buffer
),"|0x%04x", flags
);
1779 static BOOL
ignore_message( UINT message
)
1781 /* these are always ignored */
1782 return (message
>= 0xc000 ||
1783 message
== WM_GETICON
||
1784 message
== WM_GETOBJECT
||
1785 message
== WM_TIMECHANGE
||
1786 message
== WM_DISPLAYCHANGE
||
1787 message
== WM_DEVICECHANGE
||
1788 message
== WM_DWMNCRENDERINGCHANGED
);
1792 #define add_message(msg) add_message_(__LINE__,msg);
1793 static void add_message_(int line
, const struct recvd_message
*msg
)
1795 struct recvd_message
*seq
;
1800 sequence
= HeapAlloc( GetProcessHeap(), 0, sequence_size
* sizeof(*sequence
) );
1802 if (sequence_cnt
== sequence_size
)
1805 sequence
= HeapReAlloc( GetProcessHeap(), 0, sequence
, sequence_size
* sizeof(*sequence
) );
1809 seq
= &sequence
[sequence_cnt
];
1810 seq
->hwnd
= msg
->hwnd
;
1811 seq
->message
= msg
->message
;
1812 seq
->flags
= msg
->flags
;
1813 seq
->wParam
= msg
->wParam
;
1814 seq
->lParam
= msg
->lParam
;
1816 seq
->descr
= msg
->descr
;
1821 if (msg
->flags
& hook
)
1823 static const char * const CBT_code_name
[10] =
1831 "HCBT_CLICKSKIPPED",
1836 const char *code_name
= (msg
->message
<= HCBT_SETFOCUS
) ? CBT_code_name
[msg
->message
] : "Unknown";
1838 sprintf( seq
->output
, "%s: hook %d (%s) wp %08lx lp %08lx",
1839 msg
->descr
, msg
->message
, code_name
, msg
->wParam
, msg
->lParam
);
1841 else if (msg
->flags
& winevent_hook
)
1843 sprintf( seq
->output
, "%s: winevent %p %08x %08lx %08lx",
1844 msg
->descr
, msg
->hwnd
, msg
->message
, msg
->wParam
, msg
->lParam
);
1848 switch (msg
->message
)
1850 case WM_WINDOWPOSCHANGING
:
1851 case WM_WINDOWPOSCHANGED
:
1853 WINDOWPOS
*winpos
= (WINDOWPOS
*)msg
->lParam
;
1855 sprintf( seq
->output
, "%s: %p WM_WINDOWPOS%s wp %08lx lp %08lx after %p x %d y %d cx %d cy %d flags %s",
1856 msg
->descr
, msg
->hwnd
,
1857 (msg
->message
== WM_WINDOWPOSCHANGING
) ? "CHANGING" : "CHANGED",
1858 msg
->wParam
, msg
->lParam
, winpos
->hwndInsertAfter
,
1859 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
,
1860 get_winpos_flags(winpos
->flags
) );
1862 /* Log only documented flags, win2k uses 0x1000 and 0x2000
1863 * in the high word for internal purposes
1865 seq
->wParam
= winpos
->flags
& 0xffff;
1866 /* We are not interested in the flags that don't match under XP and Win9x */
1867 seq
->wParam
&= ~SWP_NOZORDER
;
1873 DRAW_ITEM_STRUCT di
;
1874 DRAWITEMSTRUCT
*dis
= (DRAWITEMSTRUCT
*)msg
->lParam
;
1876 sprintf( seq
->output
, "%s: %p WM_DRAWITEM: type %x, ctl_id %x, item_id %x, action %x, state %x",
1877 msg
->descr
, msg
->hwnd
, dis
->CtlType
, dis
->CtlID
,
1878 dis
->itemID
, dis
->itemAction
, dis
->itemState
);
1881 di
.u
.item
.type
= dis
->CtlType
;
1882 di
.u
.item
.ctl_id
= dis
->CtlID
;
1883 if (dis
->CtlType
== ODT_LISTBOX
||
1884 dis
->CtlType
== ODT_COMBOBOX
||
1885 dis
->CtlType
== ODT_MENU
)
1886 di
.u
.item
.item_id
= dis
->itemID
;
1887 di
.u
.item
.action
= dis
->itemAction
;
1888 di
.u
.item
.state
= dis
->itemState
;
1890 seq
->lParam
= di
.u
.lp
;
1894 if (msg
->message
>= 0xc000) return; /* ignore registered messages */
1895 sprintf( seq
->output
, "%s: %p %04x wp %08lx lp %08lx",
1896 msg
->descr
, msg
->hwnd
, msg
->message
, msg
->wParam
, msg
->lParam
);
1898 if (msg
->flags
& (sent
|posted
|parent
|defwinproc
|beginpaint
))
1899 sprintf( seq
->output
+ strlen(seq
->output
), " (flags %x)", msg
->flags
);
1906 /* try to make sure pending X events have been processed before continuing */
1907 static void flush_events(void)
1911 int min_timeout
= 100;
1912 DWORD time
= GetTickCount() + diff
;
1916 if (MsgWaitForMultipleObjects( 0, NULL
, FALSE
, min_timeout
, QS_ALLINPUT
) == WAIT_TIMEOUT
) break;
1917 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
1918 diff
= time
- GetTickCount();
1922 static void flush_sequence(void)
1924 HeapFree(GetProcessHeap(), 0, sequence
);
1926 sequence_cnt
= sequence_size
= 0;
1929 static void dump_sequence(const struct message
*expected
, const char *context
, const char *file
, int line
)
1931 const struct recvd_message
*actual
= sequence
;
1932 unsigned int count
= 0;
1934 trace_(file
, line
)("Failed sequence %s:\n", context
);
1935 while (expected
->message
&& actual
->message
)
1937 if (actual
->output
[0])
1939 if (expected
->flags
& hook
)
1941 trace_(file
, line
)( " %u: expected: hook %04x - actual: %s\n",
1942 count
, expected
->message
, actual
->output
);
1944 else if (expected
->flags
& winevent_hook
)
1946 trace_(file
, line
)( " %u: expected: winevent %04x - actual: %s\n",
1947 count
, expected
->message
, actual
->output
);
1949 else if (expected
->flags
& kbd_hook
)
1951 trace_(file
, line
)( " %u: expected: kbd %04x - actual: %s\n",
1952 count
, expected
->message
, actual
->output
);
1956 trace_(file
, line
)( " %u: expected: msg %04x - actual: %s\n",
1957 count
, expected
->message
, actual
->output
);
1961 if (expected
->message
== actual
->message
)
1963 if ((expected
->flags
& defwinproc
) != (actual
->flags
& defwinproc
) &&
1964 (expected
->flags
& optional
))
1966 /* don't match messages if their defwinproc status differs */
1975 /* silently drop winevent messages if there is no support for them */
1976 else if ((expected
->flags
& optional
) || ((expected
->flags
& winevent_hook
) && !hEvent_hook
))
1986 /* optional trailing messages */
1987 while (expected
->message
&& ((expected
->flags
& optional
) ||
1988 ((expected
->flags
& winevent_hook
) && !hEvent_hook
)))
1990 trace_(file
, line
)( " %u: expected: msg %04x - actual: nothing\n", count
, expected
->message
);
1995 if (expected
->message
)
1997 trace_(file
, line
)( " %u: expected: msg %04x - actual: nothing\n", count
, expected
->message
);
2001 while (actual
->message
&& actual
->output
[0])
2003 trace_(file
, line
)( " %u: expected: nothing - actual: %s\n", count
, actual
->output
);
2009 #define ok_sequence( exp, contx, todo) \
2010 ok_sequence_( (exp), (contx), (todo), __FILE__, __LINE__)
2013 static void ok_sequence_(const struct message
*expected_list
, const char *context
, int todo
,
2014 const char *file
, int line
)
2016 static const struct recvd_message end_of_sequence
;
2017 const struct message
*expected
= expected_list
;
2018 const struct recvd_message
*actual
;
2019 int failcount
= 0, dump
= 0;
2020 unsigned int count
= 0;
2022 add_message(&end_of_sequence
);
2026 while (expected
->message
&& actual
->message
)
2028 if (expected
->message
== actual
->message
)
2030 if (expected
->flags
& wparam
)
2032 if (((expected
->wParam
^ actual
->wParam
) & ~expected
->wp_mask
) && todo
)
2036 if (strcmp(winetest_platform
, "wine")) dump
++;
2037 ok_( file
, line
) (FALSE
,
2038 "%s: %u: in msg 0x%04x expecting wParam 0x%lx got 0x%lx\n",
2039 context
, count
, expected
->message
, expected
->wParam
, actual
->wParam
);
2044 ok_( file
, line
)( ((expected
->wParam
^ actual
->wParam
) & ~expected
->wp_mask
) == 0,
2045 "%s: %u: in msg 0x%04x expecting wParam 0x%lx got 0x%lx\n",
2046 context
, count
, expected
->message
, expected
->wParam
, actual
->wParam
);
2047 if ((expected
->wParam
^ actual
->wParam
) & ~expected
->wp_mask
) dump
++;
2051 if (expected
->flags
& lparam
)
2053 if (((expected
->lParam
^ actual
->lParam
) & ~expected
->lp_mask
) && todo
)
2057 if (strcmp(winetest_platform
, "wine")) dump
++;
2058 ok_( file
, line
) (FALSE
,
2059 "%s: %u: in msg 0x%04x expecting lParam 0x%lx got 0x%lx\n",
2060 context
, count
, expected
->message
, expected
->lParam
, actual
->lParam
);
2065 ok_( file
, line
)(((expected
->lParam
^ actual
->lParam
) & ~expected
->lp_mask
) == 0,
2066 "%s: %u: in msg 0x%04x expecting lParam 0x%lx got 0x%lx\n",
2067 context
, count
, expected
->message
, expected
->lParam
, actual
->lParam
);
2068 if ((expected
->lParam
^ actual
->lParam
) & ~expected
->lp_mask
) dump
++;
2071 if ((expected
->flags
& optional
) &&
2072 ((expected
->flags
^ actual
->flags
) & (defwinproc
|parent
)))
2074 /* don't match optional messages if their defwinproc or parent status differs */
2079 if ((expected
->flags
& defwinproc
) != (actual
->flags
& defwinproc
) && todo
)
2083 if (strcmp(winetest_platform
, "wine")) dump
++;
2084 ok_( file
, line
) (FALSE
,
2085 "%s: %u: the msg 0x%04x should %shave been sent by DefWindowProc\n",
2086 context
, count
, expected
->message
, (expected
->flags
& defwinproc
) ? "" : "NOT ");
2091 ok_( file
, line
) ((expected
->flags
& defwinproc
) == (actual
->flags
& defwinproc
),
2092 "%s: %u: the msg 0x%04x should %shave been sent by DefWindowProc\n",
2093 context
, count
, expected
->message
, (expected
->flags
& defwinproc
) ? "" : "NOT ");
2094 if ((expected
->flags
& defwinproc
) != (actual
->flags
& defwinproc
)) dump
++;
2097 ok_( file
, line
) ((expected
->flags
& beginpaint
) == (actual
->flags
& beginpaint
),
2098 "%s: %u: the msg 0x%04x should %shave been sent by BeginPaint\n",
2099 context
, count
, expected
->message
, (expected
->flags
& beginpaint
) ? "" : "NOT ");
2100 if ((expected
->flags
& beginpaint
) != (actual
->flags
& beginpaint
)) dump
++;
2102 ok_( file
, line
) ((expected
->flags
& (sent
|posted
)) == (actual
->flags
& (sent
|posted
)),
2103 "%s: %u: the msg 0x%04x should have been %s\n",
2104 context
, count
, expected
->message
, (expected
->flags
& posted
) ? "posted" : "sent");
2105 if ((expected
->flags
& (sent
|posted
)) != (actual
->flags
& (sent
|posted
))) dump
++;
2107 ok_( file
, line
) ((expected
->flags
& parent
) == (actual
->flags
& parent
),
2108 "%s: %u: the msg 0x%04x was expected in %s\n",
2109 context
, count
, expected
->message
, (expected
->flags
& parent
) ? "parent" : "child");
2110 if ((expected
->flags
& parent
) != (actual
->flags
& parent
)) dump
++;
2112 ok_( file
, line
) ((expected
->flags
& hook
) == (actual
->flags
& hook
),
2113 "%s: %u: the msg 0x%04x should have been sent by a hook\n",
2114 context
, count
, expected
->message
);
2115 if ((expected
->flags
& hook
) != (actual
->flags
& hook
)) dump
++;
2117 ok_( file
, line
) ((expected
->flags
& winevent_hook
) == (actual
->flags
& winevent_hook
),
2118 "%s: %u: the msg 0x%04x should have been sent by a winevent hook\n",
2119 context
, count
, expected
->message
);
2120 if ((expected
->flags
& winevent_hook
) != (actual
->flags
& winevent_hook
)) dump
++;
2122 ok_( file
, line
) ((expected
->flags
& kbd_hook
) == (actual
->flags
& kbd_hook
),
2123 "%s: %u: the msg 0x%04x should have been sent by a keyboard hook\n",
2124 context
, count
, expected
->message
);
2125 if ((expected
->flags
& kbd_hook
) != (actual
->flags
& kbd_hook
)) dump
++;
2130 /* silently drop hook messages if there is no support for them */
2131 else if ((expected
->flags
& optional
) ||
2132 ((expected
->flags
& hook
) && !hCBT_hook
) ||
2133 ((expected
->flags
& winevent_hook
) && !hEvent_hook
))
2139 if (strcmp(winetest_platform
, "wine")) dump
++;
2140 ok_( file
, line
) (FALSE
, "%s: %u: the msg 0x%04x was expected, but got msg 0x%04x instead\n",
2141 context
, count
, expected
->message
, actual
->message
);
2147 ok_( file
, line
) (FALSE
, "%s: %u: the msg 0x%04x was expected, but got msg 0x%04x instead\n",
2148 context
, count
, expected
->message
, actual
->message
);
2156 /* skip all optional trailing messages */
2157 while (expected
->message
&& ((expected
->flags
& optional
) ||
2158 ((expected
->flags
& hook
) && !hCBT_hook
) ||
2159 ((expected
->flags
& winevent_hook
) && !hEvent_hook
)))
2165 if (expected
->message
|| actual
->message
) {
2167 if (strcmp(winetest_platform
, "wine")) dump
++;
2168 ok_( file
, line
) (FALSE
, "%s: %u: the msg sequence is not complete: expected %04x - actual %04x\n",
2169 context
, count
, expected
->message
, actual
->message
);
2175 if (expected
->message
|| actual
->message
)
2178 ok_( file
, line
) (FALSE
, "%s: %u: the msg sequence is not complete: expected %04x - actual %04x\n",
2179 context
, count
, expected
->message
, actual
->message
);
2182 if( todo
&& !failcount
) /* succeeded yet marked todo */
2184 if (!strcmp(winetest_platform
, "wine")) dump
++;
2185 ok_( file
, line
)( TRUE
, "%s: marked \"todo_wine\" but succeeds\n", context
);
2189 if (dump
) dump_sequence(expected_list
, context
, file
, line
);
2193 #define expect(EXPECTED,GOT) ok((GOT)==(EXPECTED), "Expected %d, got %d\n", (EXPECTED), (GOT))
2195 /******************************** MDI test **********************************/
2197 /* CreateWindow for MDI frame window, initially visible */
2198 static const struct message WmCreateMDIframeSeq
[] = {
2199 { HCBT_CREATEWND
, hook
},
2200 { WM_GETMINMAXINFO
, sent
},
2201 { WM_NCCREATE
, sent
},
2202 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
2203 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
2204 { WM_CREATE
, sent
},
2205 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2206 { WM_NOTIFYFORMAT
, sent
|optional
},
2207 { WM_QUERYUISTATE
, sent
|optional
},
2208 { WM_WINDOWPOSCHANGING
, sent
|optional
},
2209 { WM_GETMINMAXINFO
, sent
|optional
},
2210 { WM_NCCALCSIZE
, sent
|optional
},
2211 { WM_WINDOWPOSCHANGED
, sent
|optional
},
2212 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
2213 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
2214 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2215 { HCBT_ACTIVATE
, hook
},
2216 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
2217 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
2218 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* XP */
2219 { WM_ACTIVATEAPP
, sent
|wparam
|optional
, 1 }, /* Win9x doesn't send it */
2220 { WM_NCACTIVATE
, sent
},
2221 { WM_GETTEXT
, sent
|defwinproc
|optional
},
2222 { WM_ACTIVATE
, sent
|wparam
, 1 },
2223 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* Win9x */
2224 { HCBT_SETFOCUS
, hook
},
2225 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
2226 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
2227 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2228 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
2229 /* Win9x adds SWP_NOZORDER below */
2230 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2231 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 }, /* XP */
2232 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2233 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2237 /* DestroyWindow for MDI frame window, initially visible */
2238 static const struct message WmDestroyMDIframeSeq
[] = {
2239 { HCBT_DESTROYWND
, hook
},
2240 { 0x0090, sent
|optional
},
2241 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2242 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2243 { WM_NCACTIVATE
, sent
|wparam
|optional
, 0 }, /* Win9x */
2244 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2245 { WM_NCACTIVATE
, sent
|wparam
|optional
, 0 }, /* XP */
2246 { WM_ACTIVATE
, sent
|wparam
|optional
, 0 }, /* Win9x */
2247 { WM_ACTIVATEAPP
, sent
|wparam
|optional
, 0 }, /* Win9x */
2248 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
2249 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
2250 { WM_DESTROY
, sent
},
2251 { WM_NCDESTROY
, sent
},
2254 /* CreateWindow for MDI client window, initially visible */
2255 static const struct message WmCreateMDIclientSeq
[] = {
2256 { HCBT_CREATEWND
, hook
},
2257 { WM_NCCREATE
, sent
},
2258 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
2259 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 },
2260 { WM_CREATE
, sent
},
2261 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 },
2262 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2263 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2265 { WM_PARENTNOTIFY
, sent
|wparam
, WM_CREATE
}, /* in MDI frame */
2266 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
2267 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2268 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2269 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2272 /* ShowWindow(SW_SHOW) for MDI client window */
2273 static const struct message WmShowMDIclientSeq
[] = {
2274 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
2275 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2276 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2277 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2280 /* ShowWindow(SW_HIDE) for MDI client window */
2281 static const struct message WmHideMDIclientSeq
[] = {
2282 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
2283 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2284 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* win2000 */
2285 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* XP */
2286 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2289 /* DestroyWindow for MDI client window, initially visible */
2290 static const struct message WmDestroyMDIclientSeq
[] = {
2291 { HCBT_DESTROYWND
, hook
},
2292 { 0x0090, sent
|optional
},
2293 { WM_PARENTNOTIFY
, sent
|wparam
, WM_DESTROY
}, /* in MDI frame */
2294 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
2295 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2296 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2297 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2298 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
2299 { WM_DESTROY
, sent
},
2300 { WM_NCDESTROY
, sent
},
2303 /* CreateWindow for MDI child window, initially visible */
2304 static const struct message WmCreateMDIchildVisibleSeq
[] = {
2305 { HCBT_CREATEWND
, hook
},
2306 { WM_NCCREATE
, sent
},
2307 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
2308 { WM_CREATE
, sent
},
2309 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2310 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2312 /* Win2k sends wparam set to
2313 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2314 * while Win9x doesn't bother to set child window id according to
2315 * CLIENTCREATESTRUCT.idFirstChild
2317 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
2318 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
2319 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2320 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2321 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2322 { WM_MDIREFRESHMENU
, sent
/*|wparam|lparam, 0, 0*/ },
2323 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
2324 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2325 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2327 /* Win9x: message sequence terminates here. */
2329 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 },
2330 { HCBT_SETFOCUS
, hook
}, /* in MDI client */
2331 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2332 { WM_IME_NOTIFY
, sent
|wparam
|optional
, 2 }, /* in MDI client */
2333 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2334 { WM_SETFOCUS
, sent
}, /* in MDI client */
2335 { HCBT_SETFOCUS
, hook
},
2336 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2337 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2338 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
2339 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2340 { WM_SETFOCUS
, sent
|defwinproc
},
2341 { WM_MDIACTIVATE
, sent
|defwinproc
},
2344 /* CreateWindow for MDI child window with invisible parent */
2345 static const struct message WmCreateMDIchildInvisibleParentSeq
[] = {
2346 { HCBT_CREATEWND
, hook
},
2347 { WM_GETMINMAXINFO
, sent
},
2348 { WM_NCCREATE
, sent
},
2349 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
2350 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 },
2351 { WM_CREATE
, sent
},
2352 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2353 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2355 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
2356 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
2357 { WM_MDIREFRESHMENU
, sent
}, /* in MDI client */
2358 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
2359 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2360 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2362 /* Win9x: message sequence terminates here. */
2364 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 },
2365 { HCBT_SETFOCUS
, hook
}, /* in MDI client */
2366 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2367 { WM_IME_NOTIFY
, sent
|wparam
|optional
, 2 }, /* in MDI client */
2368 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2369 { WM_SETFOCUS
, sent
}, /* in MDI client */
2370 { HCBT_SETFOCUS
, hook
},
2371 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2372 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2373 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
2374 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2375 { WM_SETFOCUS
, sent
|defwinproc
},
2376 { WM_MDIACTIVATE
, sent
|defwinproc
},
2379 /* DestroyWindow for MDI child window, initially visible */
2380 static const struct message WmDestroyMDIchildVisibleSeq
[] = {
2381 { HCBT_DESTROYWND
, hook
},
2382 /* Win2k sends wparam set to
2383 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
2384 * while Win9x doesn't bother to set child window id according to
2385 * CLIENTCREATESTRUCT.idFirstChild
2387 { 0x0090, sent
|optional
},
2388 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_DESTROY*/ }, /* in MDI client */
2389 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
2390 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2391 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2392 { WM_ERASEBKGND
, sent
|parent
|optional
},
2393 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2395 /* { WM_DESTROY, sent }
2396 * Win9x: message sequence terminates here.
2399 { HCBT_SETFOCUS
, hook
}, /* set focus to MDI client */
2400 { WM_KILLFOCUS
, sent
},
2401 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
2402 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2403 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2404 { WM_SETFOCUS
, sent
}, /* in MDI client */
2406 { HCBT_SETFOCUS
, hook
}, /* MDI client sets focus back to MDI child */
2407 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2408 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2409 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
2410 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2411 { WM_SETFOCUS
, sent
}, /* in MDI client */
2413 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
2415 { HCBT_SETFOCUS
, hook
}, /* set focus to MDI client */
2416 { WM_KILLFOCUS
, sent
},
2417 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
2418 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2419 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2420 { WM_SETFOCUS
, sent
}, /* in MDI client */
2422 { HCBT_SETFOCUS
, hook
}, /* MDI client sets focus back to MDI child */
2423 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2424 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2425 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
2426 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2427 { WM_SETFOCUS
, sent
}, /* in MDI client */
2429 { WM_DESTROY
, sent
},
2431 { HCBT_SETFOCUS
, hook
}, /* set focus to MDI client */
2432 { WM_KILLFOCUS
, sent
},
2433 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
2434 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2435 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2436 { WM_SETFOCUS
, sent
}, /* in MDI client */
2438 { HCBT_SETFOCUS
, hook
}, /* MDI client sets focus back to MDI child */
2439 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2440 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2441 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
2442 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2443 { WM_SETFOCUS
, sent
}, /* in MDI client */
2445 { WM_NCDESTROY
, sent
},
2448 /* CreateWindow for MDI child window, initially invisible */
2449 static const struct message WmCreateMDIchildInvisibleSeq
[] = {
2450 { HCBT_CREATEWND
, hook
},
2451 { WM_NCCREATE
, sent
},
2452 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
2453 { WM_CREATE
, sent
},
2454 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2455 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2457 /* Win2k sends wparam set to
2458 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2459 * while Win9x doesn't bother to set child window id according to
2460 * CLIENTCREATESTRUCT.idFirstChild
2462 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
2465 /* DestroyWindow for MDI child window, initially invisible */
2466 static const struct message WmDestroyMDIchildInvisibleSeq
[] = {
2467 { HCBT_DESTROYWND
, hook
},
2468 /* Win2k sends wparam set to
2469 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
2470 * while Win9x doesn't bother to set child window id according to
2471 * CLIENTCREATESTRUCT.idFirstChild
2473 { 0x0090, sent
|optional
},
2474 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_DESTROY*/ }, /* in MDI client */
2475 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
2476 { WM_DESTROY
, sent
},
2477 { WM_NCDESTROY
, sent
},
2478 /* FIXME: Wine destroys an icon/title window while Windows doesn't */
2479 { WM_PARENTNOTIFY
, sent
|wparam
|optional
, WM_DESTROY
}, /* MDI client */
2482 /* CreateWindow for the 1st MDI child window, initially visible and maximized */
2483 static const struct message WmCreateMDIchildVisibleMaxSeq1
[] = {
2484 { HCBT_CREATEWND
, hook
},
2485 { WM_NCCREATE
, sent
},
2486 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
2487 { WM_CREATE
, sent
},
2488 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2489 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2491 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
2492 { WM_GETMINMAXINFO
, sent
},
2493 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_STATECHANGED
},
2494 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2495 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
2496 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2498 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2499 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2500 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2501 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2502 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2503 /* Win2k sends wparam set to
2504 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2505 * while Win9x doesn't bother to set child window id according to
2506 * CLIENTCREATESTRUCT.idFirstChild
2508 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
2509 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
2510 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2511 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2512 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2513 { WM_MDIREFRESHMENU
, sent
/*|wparam|lparam, 0, 0*/ },
2514 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
2515 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2516 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
|optional
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
, 0, SWP_FRAMECHANGED
},
2518 /* Win9x: message sequence terminates here. */
2520 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
|optional
, 1 },
2521 { HCBT_SETFOCUS
, hook
|optional
}, /* in MDI client */
2522 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2523 { WM_IME_NOTIFY
, sent
|wparam
|optional
, 2 }, /* in MDI client */
2524 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2525 { WM_SETFOCUS
, sent
|optional
}, /* in MDI client */
2526 { HCBT_SETFOCUS
, hook
|optional
},
2527 { WM_KILLFOCUS
, sent
|optional
}, /* in MDI client */
2528 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2529 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
2530 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2531 { WM_SETFOCUS
, sent
|defwinproc
|optional
},
2532 { WM_MDIACTIVATE
, sent
|defwinproc
|optional
},
2534 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2535 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2536 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2537 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2540 /* CreateWindow for the 2nd MDI child window, initially visible and maximized */
2541 static const struct message WmCreateMDIchildVisibleMaxSeq2
[] = {
2542 /* restore the 1st MDI child */
2543 { WM_SETREDRAW
, sent
|wparam
, 0 },
2544 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWNORMAL
},
2545 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
2546 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2547 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2548 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
2549 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2551 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2552 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2553 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2554 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2555 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2556 { WM_SETREDRAW
, sent
|wparam
, 1 }, /* in the 1st MDI child */
2557 /* create the 2nd MDI child */
2558 { HCBT_CREATEWND
, hook
},
2559 { WM_NCCREATE
, sent
},
2560 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
2561 { WM_CREATE
, sent
},
2562 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2563 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2565 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
2566 { WM_GETMINMAXINFO
, sent
},
2567 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_STATECHANGED
},
2568 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2569 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2570 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
2571 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2573 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2574 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2575 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2576 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2577 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2578 /* Win2k sends wparam set to
2579 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2580 * while Win9x doesn't bother to set child window id according to
2581 * CLIENTCREATESTRUCT.idFirstChild
2583 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
2584 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
2585 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2586 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2587 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2588 { WM_MDIREFRESHMENU
, sent
/*|wparam|lparam, 0, 0*/ },
2589 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
2590 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2592 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 0 }, /* in the 1st MDI child */
2593 { WM_MDIACTIVATE
, sent
|defwinproc
}, /* in the 1st MDI child */
2595 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2597 /* Win9x: message sequence terminates here. */
2599 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 },
2600 { HCBT_SETFOCUS
, hook
},
2601 { WM_KILLFOCUS
, sent
|defwinproc
|optional
}, /* in the 1st MDI child */
2602 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 0 }, /* in the 1st MDI child */
2603 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2604 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2605 { WM_SETFOCUS
, sent
}, /* in MDI client */
2606 { HCBT_SETFOCUS
, hook
},
2607 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2608 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2609 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
2610 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2611 { WM_SETFOCUS
, sent
|defwinproc
},
2613 { WM_MDIACTIVATE
, sent
|defwinproc
},
2615 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2616 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2617 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2618 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2621 /* WM_MDICREATE MDI child window, initially visible and maximized */
2622 static const struct message WmCreateMDIchildVisibleMaxSeq3
[] = {
2623 { WM_MDICREATE
, sent
},
2624 { HCBT_CREATEWND
, hook
},
2625 { WM_NCCREATE
, sent
},
2626 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
2627 { WM_CREATE
, sent
},
2628 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2629 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2631 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
2632 { WM_GETMINMAXINFO
, sent
},
2633 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_STATECHANGED
},
2634 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2635 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
2636 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
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 */
2643 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2645 /* Win2k sends wparam set to
2646 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2647 * while Win9x doesn't bother to set child window id according to
2648 * CLIENTCREATESTRUCT.idFirstChild
2650 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
2651 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
2652 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2654 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2656 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2657 { WM_MDIREFRESHMENU
, sent
/*|wparam|lparam, 0, 0*/ },
2658 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
2660 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2661 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2663 /* Win9x: message sequence terminates here. */
2665 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 },
2666 { WM_SETFOCUS
, sent
|optional
}, /* in MDI client */
2667 { HCBT_SETFOCUS
, hook
}, /* in MDI client */
2668 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2669 { WM_IME_NOTIFY
, sent
|wparam
|optional
, 2 },
2670 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
|optional
, OBJID_CLIENT
, 0 },
2671 { WM_SETFOCUS
, sent
|optional
}, /* in MDI client */
2672 { HCBT_SETFOCUS
, hook
|optional
},
2673 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2674 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2675 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
2676 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2677 { WM_SETFOCUS
, sent
|defwinproc
},
2679 { WM_MDIACTIVATE
, sent
|defwinproc
},
2682 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2683 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2684 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2685 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2688 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2689 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2690 { 0x0093, sent
|defwinproc
|optional
},
2691 { 0x0093, sent
|defwinproc
|optional
},
2692 { 0x0093, sent
|defwinproc
|optional
},
2693 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2694 { WM_MOVE
, sent
|defwinproc
},
2695 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2698 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
2699 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2700 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
},
2701 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2704 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
2705 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2706 { 0x0093, sent
|optional
},
2707 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
},
2708 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2710 { 0x0093, sent
|optional
},
2711 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2712 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI client */
2713 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 }, /* XP sends it to MDI frame */
2714 { 0x0093, sent
|defwinproc
|optional
},
2715 { 0x0093, sent
|defwinproc
|optional
},
2716 { 0x0093, sent
|defwinproc
|optional
},
2717 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2718 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* XP sends a duplicate */
2722 /* CreateWindow for the 1st MDI child window, initially invisible and maximized */
2723 static const struct message WmCreateMDIchildInvisibleMaxSeq4
[] = {
2724 { HCBT_CREATEWND
, hook
},
2725 { WM_GETMINMAXINFO
, sent
},
2726 { WM_NCCREATE
, sent
},
2727 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
2728 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
2729 { WM_CREATE
, sent
},
2730 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2731 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2732 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
, 0, SWP_NOZORDER
}, /* MDI frame */
2733 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 }, /* MDI frame */
2734 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
, 0, SWP_NOZORDER
}, /* MDI frame */
2736 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
2737 { WM_GETMINMAXINFO
, sent
},
2738 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_STATECHANGED
},
2739 { WM_GETMINMAXINFO
, sent
|defwinproc
},
2740 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2741 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOREDRAW
|SWP_STATECHANGED
},
2742 { WM_MOVE
, sent
|defwinproc
},
2743 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2745 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2746 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2747 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2748 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2749 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 }, /* MDI child */
2750 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2751 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2752 /* Win2k sends wparam set to
2753 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2754 * while Win9x doesn't bother to set child window id according to
2755 * CLIENTCREATESTRUCT.idFirstChild
2757 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
2760 /* WM_SYSCOMMAND/SC_CLOSE for the 2nd MDI child window, initially visible and maximized */
2761 static const struct message WmDestroyMDIchildVisibleMaxSeq2
[] = {
2762 { WM_SYSCOMMAND
, sent
|wparam
, SC_CLOSE
},
2763 { HCBT_SYSCOMMAND
, hook
},
2764 { WM_CLOSE
, sent
|defwinproc
},
2765 { WM_MDIDESTROY
, sent
}, /* in MDI client */
2767 /* bring the 1st MDI child to top */
2768 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOSIZE
|SWP_NOMOVE
}, /* in the 1st MDI child */
2769 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
}, /* in the 2nd MDI child */
2771 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2773 { WM_CHILDACTIVATE
, sent
|defwinproc
|wparam
|lparam
, 0, 0 }, /* in the 1st MDI child */
2774 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 0 }, /* in the 1st MDI child */
2775 { WM_MDIACTIVATE
, sent
|defwinproc
}, /* in the 1st MDI child */
2777 /* maximize the 1st MDI child */
2778 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
2779 { WM_GETMINMAXINFO
, sent
|defwinproc
},
2780 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
2781 { WM_NCCALCSIZE
, sent
|defwinproc
|wparam
, 1 },
2782 { WM_CHILDACTIVATE
, sent
|defwinproc
|wparam
|lparam
, 0, 0 },
2783 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
2784 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2786 /* restore the 2nd MDI child */
2787 { WM_SETREDRAW
, sent
|defwinproc
|wparam
, 0 },
2788 { HCBT_MINMAX
, hook
|lparam
, 0, SW_NORMALNA
},
2789 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_SHOWWINDOW
|SWP_STATECHANGED
},
2790 { WM_NCCALCSIZE
, sent
|defwinproc
|wparam
, 1 },
2792 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2794 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_SHOWWINDOW
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
2795 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2797 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2799 { WM_SETREDRAW
, sent
|defwinproc
|wparam
, 1 },
2801 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2802 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2803 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2804 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2805 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2807 /* bring the 1st MDI child to top */
2808 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2809 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 },
2810 { HCBT_SETFOCUS
, hook
},
2811 { WM_KILLFOCUS
, sent
|defwinproc
},
2812 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 0 },
2813 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2814 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2815 { WM_SETFOCUS
, sent
}, /* in MDI client */
2816 { HCBT_SETFOCUS
, hook
},
2817 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2818 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2819 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
2820 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2821 { WM_SETFOCUS
, sent
|defwinproc
},
2822 { WM_MDIACTIVATE
, sent
|defwinproc
},
2823 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2825 /* apparently ShowWindow(SW_SHOW) on an MDI client */
2826 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
2827 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2828 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2829 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2830 { WM_MDIREFRESHMENU
, sent
},
2832 { HCBT_DESTROYWND
, hook
},
2833 /* Win2k sends wparam set to
2834 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
2835 * while Win9x doesn't bother to set child window id according to
2836 * CLIENTCREATESTRUCT.idFirstChild
2838 { 0x0090, sent
|defwinproc
|optional
},
2839 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_DESTROY*/ }, /* in MDI client */
2840 { WM_SHOWWINDOW
, sent
|defwinproc
|wparam
, 0 },
2841 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2842 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2843 { WM_ERASEBKGND
, sent
|parent
|optional
},
2844 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2846 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
2847 { WM_DESTROY
, sent
|defwinproc
},
2848 { WM_NCDESTROY
, sent
|defwinproc
},
2851 /* WM_MDIDESTROY for the single MDI child window, initially visible and maximized */
2852 static const struct message WmDestroyMDIchildVisibleMaxSeq1
[] = {
2853 { WM_MDIDESTROY
, sent
}, /* in MDI client */
2854 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
2855 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2856 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2857 { WM_ERASEBKGND
, sent
|parent
|optional
},
2858 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2860 { HCBT_SETFOCUS
, hook
},
2861 { WM_KILLFOCUS
, sent
},
2862 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
2863 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2864 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2865 { WM_SETFOCUS
, sent
}, /* in MDI client */
2866 { HCBT_SETFOCUS
, hook
},
2867 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2868 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2869 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
2870 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2871 { WM_SETFOCUS
, sent
},
2874 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2875 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2876 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2877 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2880 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2881 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2882 { 0x0093, sent
|defwinproc
|optional
},
2883 { 0x0093, sent
|defwinproc
|optional
},
2884 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2885 { WM_MOVE
, sent
|defwinproc
},
2886 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2889 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
2890 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2891 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
},
2892 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2895 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
2896 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2897 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
},
2898 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2901 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2902 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 },
2903 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2904 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2907 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2908 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 },
2909 { 0x0093, sent
|defwinproc
|optional
},
2910 { 0x0093, sent
|defwinproc
|optional
},
2911 { 0x0093, sent
|defwinproc
|optional
},
2912 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2913 { WM_MOVE
, sent
|defwinproc
},
2914 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2917 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
2918 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2919 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
},
2920 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2923 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
},
2924 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 },
2925 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
},
2926 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2927 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2928 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI client */
2930 { 0x0093, sent
|defwinproc
|optional
},
2931 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
|optional
, 1 }, /* XP sends it to MDI frame */
2932 { 0x0093, sent
|defwinproc
|optional
},
2933 { 0x0093, sent
|defwinproc
|optional
},
2934 { 0x0093, sent
|defwinproc
|optional
},
2935 { 0x0093, sent
|optional
},
2937 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2938 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2939 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI client */
2940 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2941 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* XP sends a duplicate */
2944 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2945 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
2946 { 0x0093, sent
|defwinproc
|optional
},
2947 { 0x0093, sent
|defwinproc
|optional
},
2948 { 0x0093, sent
|defwinproc
|optional
},
2949 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2950 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2951 { 0x0093, sent
|optional
},
2953 { WM_NCACTIVATE
, sent
|wparam
, 0 },
2954 { WM_MDIACTIVATE
, sent
},
2956 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWNORMAL
},
2957 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_SHOWWINDOW
|SWP_STATECHANGED
},
2958 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2960 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2962 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2963 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_SHOWWINDOW
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
2964 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2967 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2968 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 },
2969 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2970 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2973 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2974 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2975 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2976 { WM_MOVE
, sent
|defwinproc
},
2977 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2980 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
2981 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2982 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
},
2983 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2984 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2985 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 }, /* XP */
2986 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI client */
2987 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2988 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* XP sends a duplicate */
2990 { HCBT_SETFOCUS
, hook
},
2991 { WM_KILLFOCUS
, sent
},
2992 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
2993 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2994 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2995 { WM_SETFOCUS
, sent
}, /* in MDI client */
2997 { WM_MDIREFRESHMENU
, sent
}, /* in MDI client */
2999 { HCBT_DESTROYWND
, hook
},
3000 /* Win2k sends wparam set to
3001 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
3002 * while Win9x doesn't bother to set child window id according to
3003 * CLIENTCREATESTRUCT.idFirstChild
3005 { 0x0090, sent
|optional
},
3006 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_DESTROY*/ }, /* in MDI client */
3008 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
3009 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
3010 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
3011 { WM_ERASEBKGND
, sent
|parent
|optional
},
3012 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
3014 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
3015 { WM_DESTROY
, sent
},
3016 { WM_NCDESTROY
, sent
},
3019 /* ShowWindow(SW_MAXIMIZE) for a not visible MDI child window */
3020 static const struct message WmMaximizeMDIchildInvisibleSeq
[] = {
3021 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
3022 { WM_GETMINMAXINFO
, sent
},
3023 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_STATECHANGED
},
3024 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3025 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
3026 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
3028 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
3029 { WM_NCACTIVATE
, sent
|wparam
|optional
|defwinproc
, 1 },
3030 { HCBT_SETFOCUS
, hook
|optional
},
3031 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
3032 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
3033 { WM_SETFOCUS
, sent
|optional
}, /* in MDI client */
3034 { HCBT_SETFOCUS
, hook
|optional
},
3035 { WM_KILLFOCUS
, sent
|optional
}, /* in MDI client */
3036 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
3037 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
3038 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
3039 { WM_SETFOCUS
, sent
|optional
|defwinproc
},
3040 { WM_MDIACTIVATE
, sent
|optional
|defwinproc
},
3041 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
3042 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
3044 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
3045 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3046 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
3047 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
3048 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
3051 /* ShowWindow(SW_MAXIMIZE) for a not visible maximized MDI child window */
3052 static const struct message WmMaximizeMDIchildInvisibleSeq2
[] = {
3053 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
3054 { WM_GETMINMAXINFO
, sent
},
3055 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
},
3056 { WM_GETMINMAXINFO
, sent
|defwinproc
},
3057 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3058 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
3059 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
3061 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
|optional
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
3062 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
|optional
, 1 },
3063 { HCBT_SETFOCUS
, hook
|optional
},
3064 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
3065 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
3066 { WM_SETFOCUS
, sent
|optional
}, /* in MDI client */
3067 { HCBT_SETFOCUS
, hook
|optional
},
3068 { WM_KILLFOCUS
, sent
|optional
}, /* in MDI client */
3069 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
3070 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
3071 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
3072 { WM_SETFOCUS
, sent
|defwinproc
|optional
},
3073 { WM_MDIACTIVATE
, sent
|defwinproc
|optional
},
3074 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
3075 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
3078 /* WM_MDIMAXIMIZE for an MDI child window with invisible parent */
3079 static const struct message WmMaximizeMDIchildInvisibleParentSeq
[] = {
3080 { WM_MDIMAXIMIZE
, sent
}, /* in MDI client */
3081 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
3082 { WM_GETMINMAXINFO
, sent
},
3083 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
3084 { WM_GETMINMAXINFO
, sent
|defwinproc
},
3085 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3086 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* XP doesn't send it */
3087 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
3088 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOREDRAW
|SWP_STATECHANGED
},
3089 { WM_MOVE
, sent
|defwinproc
},
3090 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
3092 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
3093 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 },
3094 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
3095 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
|optional
, 1 },
3096 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI child XP */
3097 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI client XP */
3099 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
3100 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3101 { 0x0093, sent
|defwinproc
|optional
},
3102 { 0x0094, sent
|defwinproc
|optional
},
3103 { 0x0094, sent
|defwinproc
|optional
},
3104 { 0x0094, sent
|defwinproc
|optional
},
3105 { 0x0094, sent
|defwinproc
|optional
},
3106 { 0x0093, sent
|defwinproc
|optional
},
3107 { 0x0093, sent
|defwinproc
|optional
},
3108 { 0x0091, sent
|defwinproc
|optional
},
3109 { 0x0092, sent
|defwinproc
|optional
},
3110 { 0x0092, sent
|defwinproc
|optional
},
3111 { 0x0092, sent
|defwinproc
|optional
},
3112 { 0x0092, sent
|defwinproc
|optional
},
3113 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
3114 { WM_MOVE
, sent
|defwinproc
},
3115 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
3116 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI frame win2000 */
3118 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
3119 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3120 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
},
3121 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
3123 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
},
3124 { WM_GETMINMAXINFO
, sent
|defwinproc
},
3125 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 },
3126 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
},
3127 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
3128 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI child win2000 */
3129 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
|optional
, 1 },
3130 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI child XP */
3131 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI child XP */
3132 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI client XP */
3134 { 0x0093, sent
|optional
},
3135 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
3136 { 0x0093, sent
|defwinproc
|optional
},
3137 { 0x0093, sent
|defwinproc
|optional
},
3138 { 0x0093, sent
|defwinproc
|optional
},
3139 { 0x0091, sent
|defwinproc
|optional
},
3140 { 0x0092, sent
|defwinproc
|optional
},
3141 { 0x0092, sent
|defwinproc
|optional
},
3142 { 0x0092, sent
|defwinproc
|optional
},
3143 { 0x0092, sent
|defwinproc
|optional
},
3144 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI frame XP */
3145 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI frame XP */
3146 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI child XP */
3149 /* ShowWindow(SW_MAXIMIZE) for a visible MDI child window */
3150 static const struct message WmMaximizeMDIchildVisibleSeq
[] = {
3151 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
3152 { WM_GETMINMAXINFO
, sent
},
3153 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
3154 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3155 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
3156 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
3157 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
3159 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
3160 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3161 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
3162 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
3163 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
3166 /* ShowWindow(SW_RESTORE) for a visible maximized MDI child window */
3167 static const struct message WmRestoreMDIchildVisibleSeq
[] = {
3168 { HCBT_MINMAX
, hook
|lparam
, 0, SW_RESTORE
},
3169 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
3170 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3171 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
3172 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
3173 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
3175 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
3176 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3177 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
3178 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
3179 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
3182 /* ShowWindow(SW_RESTORE) for a visible minimized MDI child window */
3183 static const struct message WmRestoreMDIchildVisibleSeq_2
[] = {
3184 { HCBT_MINMAX
, hook
|lparam
, 0, SW_RESTORE
},
3185 { WM_QUERYOPEN
, sent
|wparam
|lparam
, 0, 0 },
3186 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
3187 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3188 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
3189 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
3190 { WM_MOVE
, sent
|defwinproc
},
3191 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
3192 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
3193 { EVENT_SYSTEM_MINIMIZEEND
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
3194 { HCBT_SETFOCUS
, hook
},
3195 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
3196 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
3197 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
3198 { WM_SETFOCUS
, sent
},
3201 /* ShowWindow(SW_MINIMIZE) for a visible restored MDI child window */
3202 static const struct message WmMinimizeMDIchildVisibleSeq
[] = {
3203 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
3204 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
3205 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3206 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
3207 { WM_MOVE
, sent
|defwinproc
},
3208 { WM_SIZE
, sent
|defwinproc
|wparam
|lparam
, SIZE_MINIMIZED
, 0 },
3209 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
|defwinproc
, 0, 0 },
3210 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
3211 { EVENT_SYSTEM_MINIMIZESTART
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
3212 /* FIXME: Wine creates an icon/title window while Windows doesn't */
3213 { WM_PARENTNOTIFY
, sent
|parent
|wparam
|optional
, WM_CREATE
}, /* MDI client */
3216 /* ShowWindow(SW_RESTORE) for a not visible MDI child window */
3217 static const struct message WmRestoreMDIchildInisibleSeq
[] = {
3218 { HCBT_MINMAX
, hook
|lparam
, 0, SW_RESTORE
},
3219 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_STATECHANGED
},
3220 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3221 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
3222 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
3223 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
3224 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
3226 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
3227 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3228 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
3229 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
3230 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
3234 static HWND mdi_client
;
3235 static WNDPROC old_mdi_client_proc
;
3237 static LRESULT WINAPI
mdi_client_hook_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
3239 struct recvd_message msg
;
3241 /* do not log painting messages */
3242 if (message
!= WM_PAINT
&&
3243 message
!= WM_NCPAINT
&&
3244 message
!= WM_SYNCPAINT
&&
3245 message
!= WM_ERASEBKGND
&&
3246 message
!= WM_NCHITTEST
&&
3247 message
!= WM_GETTEXT
&&
3248 message
!= WM_MDIGETACTIVE
&&
3249 !ignore_message( message
))
3252 msg
.message
= message
;
3253 msg
.flags
= sent
|wparam
|lparam
;
3254 msg
.wParam
= wParam
;
3255 msg
.lParam
= lParam
;
3256 msg
.descr
= "mdi client";
3260 return CallWindowProcA(old_mdi_client_proc
, hwnd
, message
, wParam
, lParam
);
3263 static LRESULT WINAPI
mdi_child_wnd_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
3265 static LONG defwndproc_counter
= 0;
3267 struct recvd_message msg
;
3269 /* do not log painting messages */
3270 if (message
!= WM_PAINT
&&
3271 message
!= WM_NCPAINT
&&
3272 message
!= WM_SYNCPAINT
&&
3273 message
!= WM_ERASEBKGND
&&
3274 message
!= WM_NCHITTEST
&&
3275 message
!= WM_GETTEXT
&&
3276 !ignore_message( message
))
3280 case WM_MDIACTIVATE
:
3282 HWND active
, client
= GetParent(hwnd
);
3284 active
= (HWND
)SendMessageA(client
, WM_MDIGETACTIVE
, 0, 0);
3286 if (hwnd
== (HWND
)lParam
) /* if we are being activated */
3287 ok (active
== (HWND
)lParam
, "new active %p != active %p\n", (HWND
)lParam
, active
);
3289 ok (active
== (HWND
)wParam
, "old active %p != active %p\n", (HWND
)wParam
, active
);
3295 msg
.message
= message
;
3296 msg
.flags
= sent
|wparam
|lparam
;
3297 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
3298 msg
.wParam
= wParam
;
3299 msg
.lParam
= lParam
;
3300 msg
.descr
= "mdi child";
3304 defwndproc_counter
++;
3305 ret
= DefMDIChildProcA(hwnd
, message
, wParam
, lParam
);
3306 defwndproc_counter
--;
3311 static LRESULT WINAPI
mdi_frame_wnd_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
3313 static LONG defwndproc_counter
= 0;
3315 struct recvd_message msg
;
3317 /* do not log painting messages */
3318 if (message
!= WM_PAINT
&&
3319 message
!= WM_NCPAINT
&&
3320 message
!= WM_SYNCPAINT
&&
3321 message
!= WM_ERASEBKGND
&&
3322 message
!= WM_NCHITTEST
&&
3323 message
!= WM_GETTEXT
&&
3324 !ignore_message( message
))
3327 msg
.message
= message
;
3328 msg
.flags
= sent
|wparam
|lparam
;
3329 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
3330 msg
.wParam
= wParam
;
3331 msg
.lParam
= lParam
;
3332 msg
.descr
= "mdi frame";
3336 defwndproc_counter
++;
3337 ret
= DefFrameProcA(hwnd
, mdi_client
, message
, wParam
, lParam
);
3338 defwndproc_counter
--;
3343 static BOOL
mdi_RegisterWindowClasses(void)
3348 cls
.lpfnWndProc
= mdi_frame_wnd_proc
;
3351 cls
.hInstance
= GetModuleHandleA(0);
3353 cls
.hCursor
= LoadCursorA(0, IDC_ARROW
);
3354 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
3355 cls
.lpszMenuName
= NULL
;
3356 cls
.lpszClassName
= "MDI_frame_class";
3357 if (!RegisterClassA(&cls
)) return FALSE
;
3359 cls
.lpfnWndProc
= mdi_child_wnd_proc
;
3360 cls
.lpszClassName
= "MDI_child_class";
3361 if (!RegisterClassA(&cls
)) return FALSE
;
3363 if (!GetClassInfoA(0, "MDIClient", &cls
)) assert(0);
3364 old_mdi_client_proc
= cls
.lpfnWndProc
;
3365 cls
.hInstance
= GetModuleHandleA(0);
3366 cls
.lpfnWndProc
= mdi_client_hook_proc
;
3367 cls
.lpszClassName
= "MDI_client_class";
3368 if (!RegisterClassA(&cls
)) assert(0);
3373 static void test_mdi_messages(void)
3375 MDICREATESTRUCTA mdi_cs
;
3376 CLIENTCREATESTRUCT client_cs
;
3377 HWND mdi_frame
, mdi_child
, mdi_child2
, active_child
;
3380 HMENU hMenu
= CreateMenu();
3382 if (!mdi_RegisterWindowClasses()) assert(0);
3386 trace("creating MDI frame window\n");
3387 mdi_frame
= CreateWindowExA(0, "MDI_frame_class", "MDI frame window",
3388 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
|
3389 WS_MAXIMIZEBOX
| WS_VISIBLE
,
3390 100, 100, CW_USEDEFAULT
, CW_USEDEFAULT
,
3391 GetDesktopWindow(), hMenu
,
3392 GetModuleHandleA(0), NULL
);
3394 ok_sequence(WmCreateMDIframeSeq
, "Create MDI frame window", FALSE
);
3396 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3397 ok(GetFocus() == mdi_frame
, "wrong focus window %p\n", GetFocus());
3399 trace("creating MDI client window\n");
3400 GetClientRect(mdi_frame
, &rc
);
3401 client_cs
.hWindowMenu
= 0;
3402 client_cs
.idFirstChild
= MDI_FIRST_CHILD_ID
;
3403 mdi_client
= CreateWindowExA(0, "MDI_client_class",
3405 WS_CHILD
| WS_VISIBLE
| MDIS_ALLCHILDSTYLES
,
3406 rc
.left
, rc
.top
, rc
.right
- rc
.left
, rc
.bottom
- rc
.top
,
3407 mdi_frame
, 0, GetModuleHandleA(0), &client_cs
);
3409 ok_sequence(WmCreateMDIclientSeq
, "Create visible MDI client window", FALSE
);
3411 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3412 ok(GetFocus() == mdi_frame
, "input focus should be on MDI frame not on %p\n", GetFocus());
3414 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3415 ok(!active_child
, "wrong active MDI child %p\n", active_child
);
3416 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
3421 trace("creating invisible MDI child window\n");
3422 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3424 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
3425 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3429 ShowWindow(mdi_child
, SW_SHOWNORMAL
);
3430 ok_sequence(WmShowChildSeq
, "ShowWindow(SW_SHOWNORMAL) MDI child window", FALSE
);
3432 ok(GetWindowLongA(mdi_child
, GWL_STYLE
) & WS_VISIBLE
, "MDI child should be visible\n");
3433 ok(IsWindowVisible(mdi_child
), "MDI child should be visible\n");
3435 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3436 ok(GetFocus() == 0, "wrong focus window %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
);
3442 ShowWindow(mdi_child
, SW_HIDE
);
3443 ok_sequence(WmHideChildSeq
, "ShowWindow(SW_HIDE) MDI child window", FALSE
);
3446 ShowWindow(mdi_child
, SW_SHOW
);
3447 ok_sequence(WmShowChildSeq
, "ShowWindow(SW_SHOW) MDI child window", FALSE
);
3449 ok(GetWindowLongA(mdi_child
, GWL_STYLE
) & WS_VISIBLE
, "MDI child should be visible\n");
3450 ok(IsWindowVisible(mdi_child
), "MDI child should be visible\n");
3452 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3453 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3455 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3456 ok(!active_child
, "wrong active MDI child %p\n", active_child
);
3457 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
3459 DestroyWindow(mdi_child
);
3462 trace("creating visible MDI child window\n");
3463 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3464 WS_CHILD
| WS_VISIBLE
,
3465 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
3466 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3468 ok_sequence(WmCreateMDIchildVisibleSeq
, "Create visible MDI child window", FALSE
);
3470 ok(GetWindowLongA(mdi_child
, GWL_STYLE
) & WS_VISIBLE
, "MDI child should be visible\n");
3471 ok(IsWindowVisible(mdi_child
), "MDI child should be visible\n");
3473 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3474 ok(GetFocus() == mdi_child
, "wrong focus window %p\n", GetFocus());
3476 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3477 ok(active_child
== mdi_child
, "wrong active MDI child %p\n", active_child
);
3478 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
3481 DestroyWindow(mdi_child
);
3482 ok_sequence(WmDestroyMDIchildVisibleSeq
, "Destroy visible MDI child window", TRUE
);
3484 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3485 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3487 /* Win2k: MDI client still returns a just destroyed child as active
3488 * Win9x: MDI client returns 0
3490 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3491 ok(active_child
== mdi_child
|| /* win2k */
3492 !active_child
, /* win9x */
3493 "wrong active MDI child %p\n", active_child
);
3494 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
3498 trace("creating invisible MDI child window\n");
3499 mdi_child2
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3501 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
3502 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3504 ok_sequence(WmCreateMDIchildInvisibleSeq
, "Create invisible MDI child window", FALSE
);
3506 ok(!(GetWindowLongA(mdi_child2
, GWL_STYLE
) & WS_VISIBLE
), "MDI child should not be visible\n");
3507 ok(!IsWindowVisible(mdi_child2
), "MDI child should not be visible\n");
3509 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3510 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3512 /* Win2k: MDI client still returns a just destroyed child as active
3513 * Win9x: MDI client returns mdi_child2
3515 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3516 ok(active_child
== mdi_child
|| /* win2k */
3517 active_child
== mdi_child2
, /* win9x */
3518 "wrong active MDI child %p\n", active_child
);
3519 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
3522 ShowWindow(mdi_child2
, SW_MAXIMIZE
);
3523 ok_sequence(WmMaximizeMDIchildInvisibleSeq
, "ShowWindow(SW_MAXIMIZE):invisible MDI child", FALSE
);
3525 ok(GetWindowLongA(mdi_child2
, GWL_STYLE
) & WS_VISIBLE
, "MDI child should be visible\n");
3526 ok(IsWindowVisible(mdi_child2
), "MDI child should be visible\n");
3528 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3529 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
3530 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
3533 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3534 ok(GetFocus() == mdi_child2
|| /* win2k */
3535 GetFocus() == 0, /* win9x */
3536 "wrong focus window %p\n", GetFocus());
3541 ShowWindow(mdi_child2
, SW_HIDE
);
3542 ok_sequence(WmHideChildSeq
, "ShowWindow(SW_HIDE):MDI child", FALSE
);
3544 ShowWindow(mdi_child2
, SW_RESTORE
);
3545 ok_sequence(WmRestoreMDIchildInisibleSeq
, "ShowWindow(SW_RESTORE):invisible MDI child", FALSE
);
3548 ok(GetWindowLongA(mdi_child2
, GWL_STYLE
) & WS_VISIBLE
, "MDI child should be visible\n");
3549 ok(IsWindowVisible(mdi_child2
), "MDI child should be visible\n");
3551 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3552 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
3553 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
3559 ShowWindow(mdi_child2
, SW_HIDE
);
3560 ok_sequence(WmHideChildSeq
, "ShowWindow(SW_HIDE):MDI child", FALSE
);
3562 ShowWindow(mdi_child2
, SW_SHOW
);
3563 ok_sequence(WmShowChildSeq
, "ShowWindow(SW_SHOW):MDI child", FALSE
);
3565 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3566 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3568 ShowWindow(mdi_child2
, SW_MAXIMIZE
);
3569 ok_sequence(WmMaximizeMDIchildVisibleSeq
, "ShowWindow(SW_MAXIMIZE):MDI child", FALSE
);
3571 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3572 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3574 ShowWindow(mdi_child2
, SW_RESTORE
);
3575 ok_sequence(WmRestoreMDIchildVisibleSeq
, "ShowWindow(SW_RESTORE):maximized MDI child", FALSE
);
3577 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3578 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3580 ShowWindow(mdi_child2
, SW_MINIMIZE
);
3581 ok_sequence(WmMinimizeMDIchildVisibleSeq
, "ShowWindow(SW_MINIMIZE):MDI child", TRUE
);
3583 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3584 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3586 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3587 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
3588 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
3591 ShowWindow(mdi_child2
, SW_RESTORE
);
3592 ok_sequence(WmRestoreMDIchildVisibleSeq_2
, "ShowWindow(SW_RESTORE):minimized MDI child", FALSE
);
3594 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3595 ok(GetFocus() == mdi_child2
, "wrong focus window %p\n", GetFocus());
3597 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3598 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
3599 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
3605 ShowWindow(mdi_child2
, SW_HIDE
);
3606 ok_sequence(WmHideChildSeq
, "ShowWindow(SW_HIDE):MDI child", FALSE
);
3608 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3609 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3611 DestroyWindow(mdi_child2
);
3612 ok_sequence(WmDestroyMDIchildInvisibleSeq
, "Destroy invisible MDI child window", FALSE
);
3614 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3615 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3617 /* test for maximized MDI children */
3618 trace("creating maximized visible MDI child window 1\n");
3619 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3620 WS_CHILD
| WS_VISIBLE
| WS_MAXIMIZEBOX
| WS_MAXIMIZE
,
3621 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
3622 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3624 ok_sequence(WmCreateMDIchildVisibleMaxSeq1
, "Create maximized visible 1st MDI child window", TRUE
);
3625 ok(IsZoomed(mdi_child
), "1st MDI child should be maximized\n");
3627 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3628 ok(GetFocus() == mdi_child
|| /* win2k */
3629 GetFocus() == 0, /* win9x */
3630 "wrong focus window %p\n", GetFocus());
3632 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3633 ok(active_child
== mdi_child
, "wrong active MDI child %p\n", active_child
);
3634 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
3637 trace("creating maximized visible MDI child window 2\n");
3638 mdi_child2
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3639 WS_CHILD
| WS_VISIBLE
| WS_MAXIMIZEBOX
| WS_MAXIMIZE
,
3640 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
3641 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3643 ok_sequence(WmCreateMDIchildVisibleMaxSeq2
, "Create maximized visible 2nd MDI child 2 window", TRUE
);
3644 ok(IsZoomed(mdi_child2
), "2nd MDI child should be maximized\n");
3645 ok(!IsZoomed(mdi_child
), "1st MDI child should NOT be maximized\n");
3647 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3648 ok(GetFocus() == mdi_child2
, "wrong focus window %p\n", GetFocus());
3650 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3651 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
3652 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
3655 trace("destroying maximized visible MDI child window 2\n");
3656 DestroyWindow(mdi_child2
);
3657 ok_sequence(WmDestroyMDIchildVisibleSeq
, "Destroy visible MDI child window", TRUE
);
3659 ok(!IsZoomed(mdi_child
), "1st MDI child should NOT be maximized\n");
3661 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3662 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3664 /* Win2k: MDI client still returns a just destroyed child as active
3665 * Win9x: MDI client returns 0
3667 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3668 ok(active_child
== mdi_child2
|| /* win2k */
3669 !active_child
, /* win9x */
3670 "wrong active MDI child %p\n", active_child
);
3673 ShowWindow(mdi_child
, SW_MAXIMIZE
);
3674 ok(IsZoomed(mdi_child
), "1st MDI child should be maximized\n");
3677 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3678 ok(GetFocus() == mdi_child
, "wrong focus window %p\n", GetFocus());
3680 trace("re-creating maximized visible MDI child window 2\n");
3681 mdi_child2
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3682 WS_CHILD
| WS_VISIBLE
| WS_MAXIMIZEBOX
| WS_MAXIMIZE
,
3683 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
3684 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3686 ok_sequence(WmCreateMDIchildVisibleMaxSeq2
, "Create maximized visible 2nd MDI child 2 window", TRUE
);
3687 ok(IsZoomed(mdi_child2
), "2nd MDI child should be maximized\n");
3688 ok(!IsZoomed(mdi_child
), "1st MDI child should NOT be maximized\n");
3690 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3691 ok(GetFocus() == mdi_child2
, "wrong focus window %p\n", GetFocus());
3693 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3694 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
3695 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
3698 SendMessageA(mdi_child2
, WM_SYSCOMMAND
, SC_CLOSE
, 0);
3699 ok_sequence(WmDestroyMDIchildVisibleMaxSeq2
, "WM_SYSCOMMAND/SC_CLOSE on a visible maximized MDI child window", TRUE
);
3700 ok(!IsWindow(mdi_child2
), "MDI child 2 should be destroyed\n");
3702 ok(IsZoomed(mdi_child
), "1st MDI child should be maximized\n");
3703 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3704 ok(GetFocus() == mdi_child
, "wrong focus window %p\n", GetFocus());
3706 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3707 ok(active_child
== mdi_child
, "wrong active MDI child %p\n", active_child
);
3708 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
3711 DestroyWindow(mdi_child
);
3712 ok_sequence(WmDestroyMDIchildVisibleSeq
, "Destroy visible MDI child window", TRUE
);
3714 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3715 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3717 /* Win2k: MDI client still returns a just destroyed child as active
3718 * Win9x: MDI client returns 0
3720 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3721 ok(active_child
== mdi_child
|| /* win2k */
3722 !active_child
, /* win9x */
3723 "wrong active MDI child %p\n", active_child
);
3726 trace("creating maximized invisible MDI child window\n");
3727 mdi_child2
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3728 WS_CHILD
| WS_MAXIMIZE
| WS_CAPTION
| WS_THICKFRAME
,
3729 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
3730 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3732 ok_sequence(WmCreateMDIchildInvisibleMaxSeq4
, "Create maximized invisible MDI child window", FALSE
);
3733 ok(IsZoomed(mdi_child2
), "MDI child should be maximized\n");
3734 ok(!(GetWindowLongA(mdi_child2
, GWL_STYLE
) & WS_VISIBLE
), "MDI child should be not visible\n");
3735 ok(!IsWindowVisible(mdi_child2
), "MDI child should be not visible\n");
3737 /* Win2k: MDI client still returns a just destroyed child as active
3738 * Win9x: MDI client returns 0
3740 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3741 ok(active_child
== mdi_child
|| /* win2k */
3742 !active_child
|| active_child
== mdi_child2
, /* win9x */
3743 "wrong active MDI child %p\n", active_child
);
3746 trace("call ShowWindow(mdi_child, SW_MAXIMIZE)\n");
3747 ShowWindow(mdi_child2
, SW_MAXIMIZE
);
3748 ok_sequence(WmMaximizeMDIchildInvisibleSeq2
, "ShowWindow(SW_MAXIMIZE):invisible maximized MDI child", FALSE
);
3749 ok(IsZoomed(mdi_child2
), "MDI child should be maximized\n");
3750 ok(GetWindowLongA(mdi_child2
, GWL_STYLE
) & WS_VISIBLE
, "MDI child should be visible\n");
3751 ok(IsWindowVisible(mdi_child2
), "MDI child should be visible\n");
3753 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3754 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
3755 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
3758 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child2
, 0);
3761 /* end of test for maximized MDI children */
3764 trace("creating maximized visible MDI child window 1(Switch test)\n");
3765 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3766 WS_CHILD
| WS_VISIBLE
| WS_MAXIMIZEBOX
| WS_MAXIMIZE
,
3767 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
3768 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3770 ok_sequence(WmCreateMDIchildVisibleMaxSeq1
, "Create maximized visible 1st MDI child window(Switch test)", TRUE
);
3771 ok(IsZoomed(mdi_child
), "1st MDI child should be maximized(Switch test)\n");
3773 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p(Switch test)\n", GetActiveWindow());
3774 ok(GetFocus() == mdi_child
|| /* win2k */
3775 GetFocus() == 0, /* win9x */
3776 "wrong focus window %p(Switch test)\n", GetFocus());
3778 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3779 ok(active_child
== mdi_child
, "wrong active MDI child %p(Switch test)\n", active_child
);
3780 ok(zoomed
, "wrong zoomed state %d(Switch test)\n", zoomed
);
3783 trace("creating maximized visible MDI child window 2(Switch test)\n");
3784 mdi_child2
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3785 WS_CHILD
| WS_VISIBLE
| WS_MAXIMIZEBOX
| WS_MAXIMIZE
,
3786 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
3787 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3789 ok_sequence(WmCreateMDIchildVisibleMaxSeq2
, "Create maximized visible 2nd MDI child window (Switch test)", TRUE
);
3791 ok(IsZoomed(mdi_child2
), "2nd MDI child should be maximized(Switch test)\n");
3792 ok(!IsZoomed(mdi_child
), "1st MDI child should NOT be maximized(Switch test)\n");
3794 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p(Switch test)\n", GetActiveWindow());
3795 ok(GetFocus() == mdi_child2
, "wrong focus window %p(Switch test)\n", GetFocus());
3797 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3798 ok(active_child
== mdi_child2
, "wrong active MDI child %p(Switch test)\n", active_child
);
3799 ok(zoomed
, "wrong zoomed state %d(Switch test)\n", zoomed
);
3802 trace("Switch child window.\n");
3803 SendMessageA(mdi_client
, WM_MDIACTIVATE
, (WPARAM
)mdi_child
, 0);
3804 ok_sequence(WmSwitchChild
, "Child did not switch correctly", TRUE
);
3805 trace("end of test for switch maximized MDI children\n");
3808 /* Prepare for switching test of not maximized MDI children */
3809 ShowWindow( mdi_child
, SW_NORMAL
);
3810 ok(!IsZoomed(mdi_child
), "wrong zoomed state for %p(Switch test)\n", mdi_child
);
3811 ok(!IsZoomed(mdi_child2
), "wrong zoomed state for %p(Switch test)\n", mdi_child2
);
3812 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, 0);
3813 ok(active_child
== mdi_child
, "wrong active MDI child %p(Switch test)\n", active_child
);
3816 SendMessageA(mdi_client
, WM_MDIACTIVATE
, (WPARAM
)mdi_child2
, 0);
3817 ok_sequence(WmSwitchNotMaximizedChild
, "Not maximized child did not switch correctly", FALSE
);
3818 trace("end of test for switch not maximized MDI children\n");
3821 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
3824 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child2
, 0);
3829 /* end of tests for switch maximized/not maximized MDI children */
3831 mdi_cs
.szClass
= "MDI_child_Class";
3832 mdi_cs
.szTitle
= "MDI child";
3833 mdi_cs
.hOwner
= GetModuleHandleA(0);
3836 mdi_cs
.cx
= CW_USEDEFAULT
;
3837 mdi_cs
.cy
= CW_USEDEFAULT
;
3838 mdi_cs
.style
= WS_CHILD
| WS_SYSMENU
| WS_VISIBLE
| WS_MAXIMIZEBOX
| WS_MAXIMIZE
;
3840 mdi_child
= (HWND
)SendMessageA(mdi_client
, WM_MDICREATE
, 0, (LPARAM
)&mdi_cs
);
3841 ok(mdi_child
!= 0, "MDI child creation failed\n");
3842 ok_sequence(WmCreateMDIchildVisibleMaxSeq3
, "WM_MDICREATE for maximized visible MDI child window", TRUE
);
3844 ok(GetMenuItemID(hMenu
, GetMenuItemCount(hMenu
) - 1) == SC_CLOSE
, "SC_CLOSE menu item not found\n");
3846 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3847 ok(active_child
== mdi_child
, "wrong active MDI child %p\n", active_child
);
3849 ok(IsZoomed(mdi_child
), "MDI child should be maximized\n");
3850 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3851 ok(GetFocus() == mdi_child
, "wrong focus window %p\n", GetFocus());
3853 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3854 ok(active_child
== mdi_child
, "wrong active MDI child %p\n", active_child
);
3855 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
3858 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
3859 ok_sequence(WmDestroyMDIchildVisibleMaxSeq1
, "Destroy visible maximized MDI child window", TRUE
);
3861 ok(!IsWindow(mdi_child
), "MDI child should be destroyed\n");
3862 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3863 ok(!active_child
, "wrong active MDI child %p\n", active_child
);
3868 DestroyWindow(mdi_client
);
3869 ok_sequence(WmDestroyMDIclientSeq
, "Destroy MDI client window", FALSE
);
3871 /* test maximization of MDI child with invisible parent */
3872 client_cs
.hWindowMenu
= 0;
3873 mdi_client
= CreateWindow("MDI_client_class",
3875 WS_CHILD
| WS_CLIPCHILDREN
| WS_VSCROLL
| WS_HSCROLL
| WS_VISIBLE
,
3877 mdi_frame
, 0, GetModuleHandleA(0), &client_cs
);
3878 ok_sequence(WmCreateMDIclientSeq
, "Create MDI client window", FALSE
);
3880 ShowWindow(mdi_client
, SW_HIDE
);
3881 ok_sequence(WmHideMDIclientSeq
, "Hide MDI client window", FALSE
);
3883 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3884 WS_CHILD
| WS_CLIPCHILDREN
| WS_VSCROLL
| WS_HSCROLL
,
3886 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3887 ok_sequence(WmCreateMDIchildInvisibleParentSeq
, "Create MDI child window with invisible parent", FALSE
);
3889 SendMessage(mdi_client
, WM_MDIMAXIMIZE
, (WPARAM
) mdi_child
, 0);
3890 ok_sequence(WmMaximizeMDIchildInvisibleParentSeq
, "Maximize MDI child window with invisible parent", TRUE
);
3891 zoomed
= IsZoomed(mdi_child
);
3892 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
3894 ShowWindow(mdi_client
, SW_SHOW
);
3895 ok_sequence(WmShowMDIclientSeq
, "Show MDI client window", FALSE
);
3897 DestroyWindow(mdi_child
);
3898 ok_sequence(WmDestroyMDIchildVisibleSeq
, "Destroy visible maximized MDI child window", TRUE
);
3900 /* end of test for maximization of MDI child with invisible parent */
3902 DestroyWindow(mdi_client
);
3903 ok_sequence(WmDestroyMDIclientSeq
, "Destroy MDI client window", FALSE
);
3905 DestroyWindow(mdi_frame
);
3906 ok_sequence(WmDestroyMDIframeSeq
, "Destroy MDI frame window", FALSE
);
3908 /************************* End of MDI test **********************************/
3910 static void test_WM_SETREDRAW(HWND hwnd
)
3912 DWORD style
= GetWindowLongA(hwnd
, GWL_STYLE
);
3917 SendMessageA(hwnd
, WM_SETREDRAW
, FALSE
, 0);
3918 ok_sequence(WmSetRedrawFalseSeq
, "SetRedraw:FALSE", FALSE
);
3920 ok(!(GetWindowLongA(hwnd
, GWL_STYLE
) & WS_VISIBLE
), "WS_VISIBLE should NOT be set\n");
3921 ok(!IsWindowVisible(hwnd
), "IsWindowVisible() should return FALSE\n");
3924 SendMessageA(hwnd
, WM_SETREDRAW
, TRUE
, 0);
3925 ok_sequence(WmSetRedrawTrueSeq
, "SetRedraw:TRUE", FALSE
);
3927 ok(GetWindowLongA(hwnd
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
3928 ok(IsWindowVisible(hwnd
), "IsWindowVisible() should return TRUE\n");
3930 /* restore original WS_VISIBLE state */
3931 SetWindowLongA(hwnd
, GWL_STYLE
, style
);
3937 static INT_PTR CALLBACK
TestModalDlgProcA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
3939 struct recvd_message msg
;
3941 if (ignore_message( message
)) return 0;
3947 case WM_NCMOUSEMOVE
:
3948 case WM_NCMOUSELEAVE
:
3956 msg
.message
= message
;
3957 msg
.flags
= sent
|wparam
|lparam
;
3958 msg
.wParam
= wParam
;
3959 msg
.lParam
= lParam
;
3960 msg
.descr
= "dialog";
3963 if (message
== WM_INITDIALOG
) SetTimer( hwnd
, 1, 100, NULL
);
3964 if (message
== WM_TIMER
) EndDialog( hwnd
, 0 );
3968 static void test_hv_scroll_1(HWND hwnd
, INT ctl
, DWORD clear
, DWORD set
, INT min
, INT max
)
3970 DWORD style
, exstyle
;
3974 exstyle
= GetWindowLongA(hwnd
, GWL_EXSTYLE
);
3975 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
3976 /* do not be confused by WS_DLGFRAME set */
3977 if ((style
& WS_CAPTION
) == WS_CAPTION
) style
&= ~WS_CAPTION
;
3979 if (clear
) ok(style
& clear
, "style %08x should be set\n", clear
);
3980 if (set
) ok(!(style
& set
), "style %08x should not be set\n", set
);
3982 ret
= SetScrollRange(hwnd
, ctl
, min
, max
, FALSE
);
3983 ok( ret
, "SetScrollRange(%d) error %d\n", ctl
, GetLastError());
3984 if ((style
& (WS_DLGFRAME
| WS_BORDER
| WS_THICKFRAME
)) || (exstyle
& WS_EX_DLGMODALFRAME
))
3985 ok_sequence(WmSetScrollRangeHV_NC_Seq
, "SetScrollRange(SB_HORZ/SB_VERT) NC", FALSE
);
3987 ok_sequence(WmSetScrollRangeHVSeq
, "SetScrollRange(SB_HORZ/SB_VERT)", FALSE
);
3989 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
3990 if (set
) ok(style
& set
, "style %08x should be set\n", set
);
3991 if (clear
) ok(!(style
& clear
), "style %08x should not be set\n", clear
);
3993 /* a subsequent call should do nothing */
3994 ret
= SetScrollRange(hwnd
, ctl
, min
, max
, FALSE
);
3995 ok( ret
, "SetScrollRange(%d) error %d\n", ctl
, GetLastError());
3996 ok_sequence(WmEmptySeq
, "SetScrollRange(SB_HORZ/SB_VERT) empty sequence", FALSE
);
4000 ret
= GetScrollRange(hwnd
, ctl
, &xmin
, &xmax
);
4001 ok( ret
, "GetScrollRange(%d) error %d\n", ctl
, GetLastError());
4002 ok_sequence(WmEmptySeq
, "GetScrollRange(SB_HORZ/SB_VERT) empty sequence", FALSE
);
4003 ok(xmin
== min
, "unexpected min scroll value %d\n", xmin
);
4004 ok(xmax
== max
, "unexpected max scroll value %d\n", xmax
);
4007 static void test_hv_scroll_2(HWND hwnd
, INT ctl
, DWORD clear
, DWORD set
, INT min
, INT max
)
4009 DWORD style
, exstyle
;
4013 exstyle
= GetWindowLongA(hwnd
, GWL_EXSTYLE
);
4014 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
4015 /* do not be confused by WS_DLGFRAME set */
4016 if ((style
& WS_CAPTION
) == WS_CAPTION
) style
&= ~WS_CAPTION
;
4018 if (clear
) ok(style
& clear
, "style %08x should be set\n", clear
);
4019 if (set
) ok(!(style
& set
), "style %08x should not be set\n", set
);
4021 si
.cbSize
= sizeof(si
);
4022 si
.fMask
= SIF_RANGE
;
4025 SetScrollInfo(hwnd
, ctl
, &si
, TRUE
);
4026 if ((style
& (WS_DLGFRAME
| WS_BORDER
| WS_THICKFRAME
)) || (exstyle
& WS_EX_DLGMODALFRAME
))
4027 ok_sequence(WmSetScrollRangeHV_NC_Seq
, "SetScrollInfo(SB_HORZ/SB_VERT) NC", FALSE
);
4029 ok_sequence(WmSetScrollRangeHVSeq
, "SetScrollInfo(SB_HORZ/SB_VERT)", FALSE
);
4031 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
4032 if (set
) ok(style
& set
, "style %08x should be set\n", set
);
4033 if (clear
) ok(!(style
& clear
), "style %08x should not be set\n", clear
);
4035 /* a subsequent call should do nothing */
4036 SetScrollInfo(hwnd
, ctl
, &si
, TRUE
);
4037 if (style
& WS_HSCROLL
)
4038 ok_sequence(WmSetScrollRangeHSeq_empty
, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE
);
4039 else if (style
& WS_VSCROLL
)
4040 ok_sequence(WmSetScrollRangeVSeq_empty
, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE
);
4042 ok_sequence(WmEmptySeq
, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE
);
4044 si
.fMask
= SIF_PAGE
;
4046 SetScrollInfo(hwnd
, ctl
, &si
, FALSE
);
4047 ok_sequence(WmEmptySeq
, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE
);
4051 SetScrollInfo(hwnd
, ctl
, &si
, FALSE
);
4052 ok_sequence(WmEmptySeq
, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE
);
4054 si
.fMask
= SIF_RANGE
;
4055 si
.nMin
= 0xdeadbeef;
4056 si
.nMax
= 0xdeadbeef;
4057 ret
= GetScrollInfo(hwnd
, ctl
, &si
);
4058 ok( ret
, "GetScrollInfo error %d\n", GetLastError());
4059 ok_sequence(WmEmptySeq
, "GetScrollRange(SB_HORZ/SB_VERT) empty sequence", FALSE
);
4060 ok(si
.nMin
== min
, "unexpected min scroll value %d\n", si
.nMin
);
4061 ok(si
.nMax
== max
, "unexpected max scroll value %d\n", si
.nMax
);
4064 /* Win9x sends WM_USER+xxx while and NT versions send SBM_xxx messages */
4065 static void test_scroll_messages(HWND hwnd
)
4076 ret
= GetScrollRange(hwnd
, SB_CTL
, &min
, &max
);
4077 ok( ret
, "GetScrollRange error %d\n", GetLastError());
4078 if (sequence
->message
!= WmGetScrollRangeSeq
[0].message
)
4079 trace("GetScrollRange(SB_CTL) generated unknown message %04x\n", sequence
->message
);
4080 /* values of min and max are undefined */
4083 ret
= SetScrollRange(hwnd
, SB_CTL
, 10, 150, FALSE
);
4084 ok( ret
, "SetScrollRange error %d\n", GetLastError());
4085 if (sequence
->message
!= WmSetScrollRangeSeq
[0].message
)
4086 trace("SetScrollRange(SB_CTL) generated unknown message %04x\n", sequence
->message
);
4091 ret
= GetScrollRange(hwnd
, SB_CTL
, &min
, &max
);
4092 ok( ret
, "GetScrollRange error %d\n", GetLastError());
4093 if (sequence
->message
!= WmGetScrollRangeSeq
[0].message
)
4094 trace("GetScrollRange(SB_CTL) generated unknown message %04x\n", sequence
->message
);
4095 /* values of min and max are undefined */
4098 si
.cbSize
= sizeof(si
);
4099 si
.fMask
= SIF_RANGE
;
4102 SetScrollInfo(hwnd
, SB_CTL
, &si
, FALSE
);
4103 if (sequence
->message
!= WmSetScrollRangeSeq
[0].message
)
4104 trace("SetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence
->message
);
4107 si
.fMask
= SIF_PAGE
;
4109 SetScrollInfo(hwnd
, SB_CTL
, &si
, FALSE
);
4110 if (sequence
->message
!= WmSetScrollRangeSeq
[0].message
)
4111 trace("SetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence
->message
);
4116 SetScrollInfo(hwnd
, SB_CTL
, &si
, FALSE
);
4117 if (sequence
->message
!= WmSetScrollRangeSeq
[0].message
)
4118 trace("SetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence
->message
);
4121 si
.fMask
= SIF_RANGE
;
4122 si
.nMin
= 0xdeadbeef;
4123 si
.nMax
= 0xdeadbeef;
4124 ret
= GetScrollInfo(hwnd
, SB_CTL
, &si
);
4125 ok( ret
, "GetScrollInfo error %d\n", GetLastError());
4126 if (sequence
->message
!= WmGetScrollInfoSeq
[0].message
)
4127 trace("GetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence
->message
);
4128 /* values of min and max are undefined */
4131 /* set WS_HSCROLL */
4132 test_hv_scroll_1(hwnd
, SB_HORZ
, 0, WS_HSCROLL
, 10, 150);
4133 /* clear WS_HSCROLL */
4134 test_hv_scroll_1(hwnd
, SB_HORZ
, WS_HSCROLL
, 0, 0, 0);
4136 /* set WS_HSCROLL */
4137 test_hv_scroll_2(hwnd
, SB_HORZ
, 0, WS_HSCROLL
, 10, 150);
4138 /* clear WS_HSCROLL */
4139 test_hv_scroll_2(hwnd
, SB_HORZ
, WS_HSCROLL
, 0, 0, 0);
4141 /* set WS_VSCROLL */
4142 test_hv_scroll_1(hwnd
, SB_VERT
, 0, WS_VSCROLL
, 10, 150);
4143 /* clear WS_VSCROLL */
4144 test_hv_scroll_1(hwnd
, SB_VERT
, WS_VSCROLL
, 0, 0, 0);
4146 /* set WS_VSCROLL */
4147 test_hv_scroll_2(hwnd
, SB_VERT
, 0, WS_VSCROLL
, 10, 150);
4148 /* clear WS_VSCROLL */
4149 test_hv_scroll_2(hwnd
, SB_VERT
, WS_VSCROLL
, 0, 0, 0);
4152 static void test_showwindow(void)
4157 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW
,
4158 100, 100, 200, 200, 0, 0, 0, NULL
);
4159 ok (hwnd
!= 0, "Failed to create overlapped window\n");
4160 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
4161 0, 0, 10, 10, hwnd
, 0, 0, NULL
);
4162 ok (hchild
!= 0, "Failed to create child\n");
4165 /* ShowWindow( SW_SHOWNA) for invisible top level window */
4166 trace("calling ShowWindow( SW_SHOWNA) for invisible top level window\n");
4167 ok( ShowWindow(hwnd
, SW_SHOWNA
) == FALSE
, "ShowWindow: window was visible\n" );
4168 ok_sequence(WmSHOWNATopInvisible
, "ShowWindow(SW_SHOWNA) on invisible top level window", FALSE
);
4170 /* ShowWindow( SW_SHOWNA) for now visible top level window */
4171 trace("calling ShowWindow( SW_SHOWNA) for now visible top level window\n");
4172 ok( ShowWindow(hwnd
, SW_SHOWNA
) != FALSE
, "ShowWindow: window was invisible\n" );
4173 ok_sequence(WmSHOWNATopVisible
, "ShowWindow(SW_SHOWNA) on visible top level window", FALSE
);
4174 /* back to invisible */
4175 ShowWindow(hchild
, SW_HIDE
);
4176 ShowWindow(hwnd
, SW_HIDE
);
4178 /* ShowWindow(SW_SHOWNA) with child and parent invisible */
4179 trace("calling ShowWindow( SW_SHOWNA) for invisible child with invisible parent\n");
4180 ok( ShowWindow(hchild
, SW_SHOWNA
) == FALSE
, "ShowWindow: window was visible\n" );
4181 ok_sequence(WmSHOWNAChildInvisParInvis
, "ShowWindow(SW_SHOWNA) invisible child and parent", FALSE
);
4182 /* ShowWindow(SW_SHOWNA) with child visible and parent invisible */
4183 ok( ShowWindow(hchild
, SW_SHOW
) != FALSE
, "ShowWindow: window was invisible\n" );
4185 trace("calling ShowWindow( SW_SHOWNA) for the visible child and invisible parent\n");
4186 ok( ShowWindow(hchild
, SW_SHOWNA
) != FALSE
, "ShowWindow: window was invisible\n" );
4187 ok_sequence(WmSHOWNAChildVisParInvis
, "ShowWindow(SW_SHOWNA) visible child and invisible parent", FALSE
);
4188 /* ShowWindow(SW_SHOWNA) with child visible and parent visible */
4189 ShowWindow( hwnd
, SW_SHOW
);
4191 trace("calling ShowWindow( SW_SHOWNA) for the visible child and parent\n");
4192 ok( ShowWindow(hchild
, SW_SHOWNA
) != FALSE
, "ShowWindow: window was invisible\n" );
4193 ok_sequence(WmSHOWNAChildVisParVis
, "ShowWindow(SW_SHOWNA) for the visible child and parent", FALSE
);
4195 /* ShowWindow(SW_SHOWNA) with child invisible and parent visible */
4196 ShowWindow( hchild
, SW_HIDE
);
4198 trace("calling ShowWindow( SW_SHOWNA) for the invisible child and visible parent\n");
4199 ok( ShowWindow(hchild
, SW_SHOWNA
) == FALSE
, "ShowWindow: window was visible\n" );
4200 ok_sequence(WmSHOWNAChildInvisParVis
, "ShowWindow(SW_SHOWNA) for the invisible child and visible parent", FALSE
);
4203 ok(GetCapture() == hchild
, "wrong capture window %p\n", GetCapture());
4204 DestroyWindow(hchild
);
4205 ok(!GetCapture(), "wrong capture window %p\n", GetCapture());
4207 DestroyWindow(hwnd
);
4212 * 1. Create invisible maximized popup window.
4213 * 2. Move and resize it.
4214 * 3. Show it maximized.
4216 trace("calling CreateWindowExA( WS_MAXIMIZE ) for invisible maximized popup window\n");
4217 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP
| WS_MAXIMIZE
,
4218 100, 100, 200, 200, 0, 0, 0, NULL
);
4219 ok (hwnd
!= 0, "Failed to create popup window\n");
4220 ok(IsZoomed(hwnd
), "window should be maximized\n");
4221 ok_sequence(WmCreateInvisibleMaxPopupSeq
, "CreateWindow(WS_MAXIMIZED):popup", FALSE
);
4223 GetWindowRect(hwnd
, &rc
);
4224 ok( rc
.right
-rc
.left
== GetSystemMetrics(SM_CXSCREEN
) &&
4225 rc
.bottom
-rc
.top
== GetSystemMetrics(SM_CYSCREEN
),
4226 "Invalid maximized size before ShowWindow (%d,%d)-(%d,%d)\n",
4227 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4228 /* Reset window's size & position */
4229 SetWindowPos(hwnd
, 0, 10, 10, 200, 200, SWP_NOZORDER
| SWP_NOACTIVATE
);
4230 ok(IsZoomed(hwnd
), "window should be maximized\n");
4233 trace("calling ShowWindow( SW_SHOWMAXIMIZE ) for invisible maximized popup window\n");
4234 ShowWindow(hwnd
, SW_SHOWMAXIMIZED
);
4235 ok(IsZoomed(hwnd
), "window should be maximized\n");
4236 ok_sequence(WmShowMaxPopupResizedSeq
, "ShowWindow(SW_SHOWMAXIMIZED):invisible maximized and resized popup", FALSE
);
4238 GetWindowRect(hwnd
, &rc
);
4239 ok( rc
.right
-rc
.left
== GetSystemMetrics(SM_CXSCREEN
) &&
4240 rc
.bottom
-rc
.top
== GetSystemMetrics(SM_CYSCREEN
),
4241 "Invalid maximized size after ShowWindow (%d,%d)-(%d,%d)\n",
4242 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4243 DestroyWindow(hwnd
);
4247 * 1. Create invisible maximized popup window.
4248 * 2. Show it maximized.
4250 trace("calling CreateWindowExA( WS_MAXIMIZE ) for invisible maximized popup window\n");
4251 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP
| WS_MAXIMIZE
,
4252 100, 100, 200, 200, 0, 0, 0, NULL
);
4253 ok (hwnd
!= 0, "Failed to create popup window\n");
4254 ok(IsZoomed(hwnd
), "window should be maximized\n");
4255 ok_sequence(WmCreateInvisibleMaxPopupSeq
, "CreateWindow(WS_MAXIMIZED):popup", FALSE
);
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(WmShowMaxPopupSeq
, "ShowWindow(SW_SHOWMAXIMIZED):invisible maximized popup", FALSE
);
4261 DestroyWindow(hwnd
);
4265 * 1. Create visible maximized popup window.
4267 trace("calling CreateWindowExA( WS_MAXIMIZE ) for maximized popup window\n");
4268 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP
| WS_MAXIMIZE
| WS_VISIBLE
,
4269 100, 100, 200, 200, 0, 0, 0, NULL
);
4270 ok (hwnd
!= 0, "Failed to create popup window\n");
4271 ok(IsZoomed(hwnd
), "window should be maximized\n");
4272 ok_sequence(WmCreateMaxPopupSeq
, "CreateWindow(WS_MAXIMIZED):popup", FALSE
);
4273 DestroyWindow(hwnd
);
4277 * 1. Create visible popup window.
4280 trace("calling CreateWindowExA( WS_VISIBLE ) for popup window\n");
4281 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP
| WS_VISIBLE
,
4282 100, 100, 200, 200, 0, 0, 0, NULL
);
4283 ok (hwnd
!= 0, "Failed to create popup window\n");
4284 ok(!IsZoomed(hwnd
), "window should NOT be maximized\n");
4285 ok_sequence(WmCreatePopupSeq
, "CreateWindow(WS_VISIBLE):popup", FALSE
);
4287 trace("calling ShowWindow( SW_SHOWMAXIMIZE ) for visible popup window\n");
4288 ShowWindow(hwnd
, SW_SHOWMAXIMIZED
);
4289 ok(IsZoomed(hwnd
), "window should be maximized\n");
4290 ok_sequence(WmShowVisMaxPopupSeq
, "ShowWindow(SW_SHOWMAXIMIZED):popup", FALSE
);
4291 DestroyWindow(hwnd
);
4295 static void test_sys_menu(void)
4301 hwnd
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
4302 100, 100, 200, 200, 0, 0, 0, NULL
);
4303 ok (hwnd
!= 0, "Failed to create overlapped window\n");
4307 /* test existing window without CS_NOCLOSE style */
4308 hmenu
= GetSystemMenu(hwnd
, FALSE
);
4309 ok(hmenu
!= 0, "GetSystemMenu error %d\n", GetLastError());
4311 state
= GetMenuState(hmenu
, SC_CLOSE
, MF_BYCOMMAND
);
4312 ok(state
!= 0xffffffff, "wrong SC_CLOSE state %x\n", state
);
4313 ok(!(state
& (MF_DISABLED
| MF_GRAYED
)), "wrong SC_CLOSE state %x\n", state
);
4315 EnableMenuItem(hmenu
, SC_CLOSE
, MF_BYCOMMAND
| MF_GRAYED
);
4316 ok_sequence(WmEmptySeq
, "WmEnableMenuItem", FALSE
);
4318 state
= GetMenuState(hmenu
, SC_CLOSE
, MF_BYCOMMAND
);
4319 ok(state
!= 0xffffffff, "wrong SC_CLOSE state %x\n", state
);
4320 ok((state
& (MF_DISABLED
| MF_GRAYED
)) == MF_GRAYED
, "wrong SC_CLOSE state %x\n", state
);
4322 EnableMenuItem(hmenu
, SC_CLOSE
, 0);
4323 ok_sequence(WmEmptySeq
, "WmEnableMenuItem", FALSE
);
4325 state
= GetMenuState(hmenu
, SC_CLOSE
, MF_BYCOMMAND
);
4326 ok(state
!= 0xffffffff, "wrong SC_CLOSE state %x\n", state
);
4327 ok(!(state
& (MF_DISABLED
| MF_GRAYED
)), "wrong SC_CLOSE state %x\n", state
);
4329 /* test whether removing WS_SYSMENU destroys a system menu */
4330 SetWindowLongW(hwnd
, GWL_STYLE
, WS_POPUP
);
4331 SetWindowPos(hwnd
, 0, 0, 0, 0, 0, SWP_NOZORDER
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_FRAMECHANGED
);
4333 hmenu
= GetSystemMenu(hwnd
, FALSE
);
4334 ok(hmenu
!= 0, "GetSystemMenu error %d\n", GetLastError());
4336 DestroyWindow(hwnd
);
4338 /* test new window with CS_NOCLOSE style */
4339 hwnd
= CreateWindowExA(0, "NoCloseWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
4340 100, 100, 200, 200, 0, 0, 0, NULL
);
4341 ok (hwnd
!= 0, "Failed to create overlapped window\n");
4343 hmenu
= GetSystemMenu(hwnd
, FALSE
);
4344 ok(hmenu
!= 0, "GetSystemMenu error %d\n", GetLastError());
4346 state
= GetMenuState(hmenu
, SC_CLOSE
, MF_BYCOMMAND
);
4347 ok(state
== 0xffffffff, "wrong SC_CLOSE state %x\n", state
);
4349 DestroyWindow(hwnd
);
4351 /* test new window without WS_SYSMENU style */
4352 hwnd
= CreateWindowExA(0, "NoCloseWindowClass", NULL
, WS_OVERLAPPEDWINDOW
& ~WS_SYSMENU
,
4353 100, 100, 200, 200, 0, 0, 0, NULL
);
4354 ok(hwnd
!= 0, "Failed to create overlapped window\n");
4356 hmenu
= GetSystemMenu(hwnd
, FALSE
);
4357 ok(!hmenu
, "GetSystemMenu error %d\n", GetLastError());
4359 DestroyWindow(hwnd
);
4362 /* For shown WS_OVERLAPPEDWINDOW */
4363 static const struct message WmSetIcon_1
[] = {
4364 { WM_SETICON
, sent
},
4365 { 0x00AE, sent
|defwinproc
|optional
}, /* XP */
4366 { WM_GETTEXT
, sent
|defwinproc
|optional
},
4367 { WM_GETTEXT
, sent
|defwinproc
|optional
}, /* XP sends a duplicate */
4371 /* For WS_POPUP and hidden WS_OVERLAPPEDWINDOW */
4372 static const struct message WmSetIcon_2
[] = {
4373 { WM_SETICON
, sent
},
4377 /* Sending undocumented 0x3B message with wparam = 0x8000000b */
4378 static const struct message WmInitEndSession
[] = {
4380 { WM_QUERYENDSESSION
, sent
|defwinproc
|wparam
|lparam
, 0, ENDSESSION_LOGOFF
},
4384 /* Sending undocumented 0x3B message with wparam = 0x0000000b */
4385 static const struct message WmInitEndSession_2
[] = {
4387 { WM_QUERYENDSESSION
, sent
|defwinproc
|wparam
|lparam
, 0, 0 },
4391 /* Sending undocumented 0x3B message with wparam = 0x80000008 */
4392 static const struct message WmInitEndSession_3
[] = {
4394 { WM_ENDSESSION
, sent
|defwinproc
|wparam
|lparam
, 0, ENDSESSION_LOGOFF
},
4398 /* Sending undocumented 0x3B message with wparam = 0x00000008 */
4399 static const struct message WmInitEndSession_4
[] = {
4401 { WM_ENDSESSION
, sent
|defwinproc
|wparam
|lparam
, 0, 0 },
4405 /* Sending undocumented 0x3B message with wparam = 0x80000001 */
4406 static const struct message WmInitEndSession_5
[] = {
4408 { WM_ENDSESSION
, sent
|defwinproc
/*|wparam*/|lparam
, 1, ENDSESSION_LOGOFF
},
4412 static const struct message WmOptionalPaint
[] = {
4413 { WM_PAINT
, sent
|optional
},
4414 { WM_NCPAINT
, sent
|beginpaint
|optional
},
4415 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
4416 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
4420 static const struct message WmZOrder
[] = {
4421 { WM_WINDOWPOSCHANGING
, sent
|wparam
, 0, 0 },
4422 { WM_GETMINMAXINFO
, sent
|defwinproc
|wparam
, 0, 0 },
4423 { HCBT_ACTIVATE
, hook
},
4424 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
4425 { WM_WINDOWPOSCHANGING
, sent
|wparam
, 3, 0 },
4426 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOREDRAW
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
, 0 },
4427 { WM_GETTEXT
, sent
|optional
},
4428 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
4429 { WM_ACTIVATEAPP
, sent
|wparam
, 1, 0 },
4430 { WM_NCACTIVATE
, sent
|lparam
, 1, 0 },
4431 { WM_GETTEXT
, sent
|defwinproc
|optional
},
4432 { WM_GETTEXT
, sent
|defwinproc
|optional
},
4433 { WM_ACTIVATE
, sent
|wparam
|lparam
, 1, 0 },
4434 { HCBT_SETFOCUS
, hook
},
4435 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
4436 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
4437 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
4438 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
4439 { WM_GETTEXT
, sent
|optional
},
4440 { WM_NCCALCSIZE
, sent
|optional
},
4444 static void test_MsgWaitForMultipleObjects(HWND hwnd
)
4449 ret
= MsgWaitForMultipleObjects(0, NULL
, FALSE
, 0, QS_POSTMESSAGE
);
4450 ok(ret
== WAIT_TIMEOUT
, "MsgWaitForMultipleObjects returned %x\n", ret
);
4452 PostMessageA(hwnd
, WM_USER
, 0, 0);
4454 ret
= MsgWaitForMultipleObjects(0, NULL
, FALSE
, 0, QS_POSTMESSAGE
);
4455 ok(ret
== WAIT_OBJECT_0
, "MsgWaitForMultipleObjects returned %x\n", ret
);
4457 ok(PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
), "PeekMessage should succeed\n");
4458 ok(msg
.message
== WM_USER
, "got %04x instead of WM_USER\n", msg
.message
);
4460 ret
= MsgWaitForMultipleObjects(0, NULL
, FALSE
, 0, QS_POSTMESSAGE
);
4461 ok(ret
== WAIT_TIMEOUT
, "MsgWaitForMultipleObjects returned %x\n", ret
);
4463 PostMessageA(hwnd
, WM_USER
, 0, 0);
4465 ret
= MsgWaitForMultipleObjects(0, NULL
, FALSE
, 0, QS_POSTMESSAGE
);
4466 ok(ret
== WAIT_OBJECT_0
, "MsgWaitForMultipleObjects returned %x\n", ret
);
4468 ok(PeekMessageA( &msg
, 0, 0, 0, PM_NOREMOVE
), "PeekMessage should succeed\n");
4469 ok(msg
.message
== WM_USER
, "got %04x instead of WM_USER\n", msg
.message
);
4471 /* shows QS_POSTMESSAGE flag is cleared in the PeekMessage call */
4472 ret
= MsgWaitForMultipleObjects(0, NULL
, FALSE
, 0, QS_POSTMESSAGE
);
4473 ok(ret
== WAIT_TIMEOUT
, "MsgWaitForMultipleObjects returned %x\n", ret
);
4475 PostMessageA(hwnd
, WM_USER
, 0, 0);
4477 /* new incoming message causes it to become signaled again */
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
);
4483 ok(PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
), "PeekMessage should succeed\n");
4484 ok(msg
.message
== WM_USER
, "got %04x instead of WM_USER\n", msg
.message
);
4487 /* test if we receive the right sequence of messages */
4488 static void test_messages(void)
4490 HWND hwnd
, hparent
, hchild
;
4491 HWND hchild2
, hbutton
;
4498 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW
,
4499 100, 100, 200, 200, 0, 0, 0, NULL
);
4500 ok (hwnd
!= 0, "Failed to create overlapped window\n");
4501 ok_sequence(WmCreateOverlappedSeq
, "CreateWindow:overlapped", FALSE
);
4503 /* test ShowWindow(SW_HIDE) on a newly created invisible window */
4504 ok( ShowWindow(hwnd
, SW_HIDE
) == FALSE
, "ShowWindow: window was visible\n" );
4505 ok_sequence(WmEmptySeq
, "ShowWindow(SW_HIDE):overlapped, invisible", FALSE
);
4507 /* test WM_SETREDRAW on a not visible top level window */
4508 test_WM_SETREDRAW(hwnd
);
4510 SetWindowPos(hwnd
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
);
4512 ok_sequence(WmSWP_ShowOverlappedSeq
, "SetWindowPos:SWP_SHOWWINDOW:overlapped", FALSE
);
4513 ok(IsWindowVisible(hwnd
), "window should be visible at this point\n");
4515 ok(GetActiveWindow() == hwnd
, "window should be active\n");
4516 ok(GetFocus() == hwnd
, "window should have input focus\n");
4517 ShowWindow(hwnd
, SW_HIDE
);
4519 ok_sequence(WmHideOverlappedSeq
, "ShowWindow(SW_HIDE):overlapped", FALSE
);
4521 ShowWindow(hwnd
, SW_SHOW
);
4523 ok_sequence(WmShowOverlappedSeq
, "ShowWindow(SW_SHOW):overlapped", TRUE
);
4525 ShowWindow(hwnd
, SW_HIDE
);
4527 ok_sequence(WmHideOverlappedSeq
, "ShowWindow(SW_HIDE):overlapped", FALSE
);
4529 ShowWindow(hwnd
, SW_SHOWMAXIMIZED
);
4531 ok_sequence(WmShowMaxOverlappedSeq
, "ShowWindow(SW_SHOWMAXIMIZED):overlapped", TRUE
);
4534 if (GetWindowLongW( hwnd
, GWL_STYLE
) & WS_MAXIMIZE
)
4536 ShowWindow(hwnd
, SW_RESTORE
);
4538 ok_sequence(WmShowRestoreMaxOverlappedSeq
, "ShowWindow(SW_RESTORE):overlapped", TRUE
);
4542 ShowWindow(hwnd
, SW_MINIMIZE
);
4544 ok_sequence(WmShowMinOverlappedSeq
, "ShowWindow(SW_SHOWMINIMIZED):overlapped", TRUE
);
4547 if (GetWindowLongW( hwnd
, GWL_STYLE
) & WS_MINIMIZE
)
4549 ShowWindow(hwnd
, SW_RESTORE
);
4551 ok_sequence(WmShowRestoreMinOverlappedSeq
, "ShowWindow(SW_RESTORE):overlapped", TRUE
);
4555 ShowWindow(hwnd
, SW_SHOW
);
4557 ok_sequence(WmOptionalPaint
, "ShowWindow(SW_SHOW):overlapped already visible", FALSE
);
4559 SetWindowPos(hwnd
, 0,0,0,0,0, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
);
4560 ok_sequence(WmSWP_HideOverlappedSeq
, "SetWindowPos:SWP_HIDEWINDOW:overlapped", FALSE
);
4561 ok(!IsWindowVisible(hwnd
), "window should not be visible at this point\n");
4562 ok(GetActiveWindow() == hwnd
, "window should still be active\n");
4564 /* test WM_SETREDRAW on a visible top level window */
4565 ShowWindow(hwnd
, SW_SHOW
);
4567 test_WM_SETREDRAW(hwnd
);
4569 trace("testing scroll APIs on a visible top level window %p\n", hwnd
);
4570 test_scroll_messages(hwnd
);
4572 /* test resizing and moving */
4573 SetWindowPos( hwnd
, 0, 0, 0, 300, 300, SWP_NOMOVE
|SWP_NOACTIVATE
);
4574 ok_sequence(WmSWP_ResizeSeq
, "SetWindowPos:Resize", FALSE
);
4577 SetWindowPos( hwnd
, 0, 200, 200, 0, 0, SWP_NOSIZE
|SWP_NOACTIVATE
);
4578 ok_sequence(WmSWP_MoveSeq
, "SetWindowPos:Move", FALSE
);
4581 SetWindowPos( hwnd
, 0, 200, 200, 250, 250, SWP_NOZORDER
|SWP_NOACTIVATE
);
4582 ok_sequence(WmSWP_ResizeNoZOrder
, "SetWindowPos:WmSWP_ResizeNoZOrder", FALSE
);
4586 /* popups don't get WM_GETMINMAXINFO */
4587 SetWindowLongW( hwnd
, GWL_STYLE
, WS_VISIBLE
|WS_POPUP
);
4588 SetWindowPos( hwnd
, 0, 0, 0, 0, 0, SWP_NOZORDER
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_FRAMECHANGED
);
4590 SetWindowPos( hwnd
, 0, 0, 0, 200, 200, SWP_NOMOVE
|SWP_NOACTIVATE
);
4591 ok_sequence(WmSWP_ResizePopupSeq
, "SetWindowPos:ResizePopup", FALSE
);
4593 DestroyWindow(hwnd
);
4594 ok_sequence(WmDestroyOverlappedSeq
, "DestroyWindow:overlapped", FALSE
);
4596 hparent
= CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
4597 100, 100, 200, 200, 0, 0, 0, NULL
);
4598 ok (hparent
!= 0, "Failed to create parent window\n");
4601 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
| WS_MAXIMIZE
,
4602 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4603 ok (hchild
!= 0, "Failed to create child window\n");
4604 ok_sequence(WmCreateMaximizedChildSeq
, "CreateWindow:maximized child", FALSE
);
4605 DestroyWindow(hchild
);
4608 /* visible child window with a caption */
4609 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child",
4610 WS_CHILD
| WS_VISIBLE
| WS_CAPTION
,
4611 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4612 ok (hchild
!= 0, "Failed to create child window\n");
4613 ok_sequence(WmCreateVisibleChildSeq
, "CreateWindow:visible child", FALSE
);
4615 trace("testing scroll APIs on a visible child window %p\n", hchild
);
4616 test_scroll_messages(hchild
);
4618 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
);
4619 ok_sequence(WmShowChildSeq_4
, "SetWindowPos(SWP_SHOWWINDOW):child with a caption", FALSE
);
4621 DestroyWindow(hchild
);
4624 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
4625 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4626 ok (hchild
!= 0, "Failed to create child window\n");
4627 ok_sequence(WmCreateChildSeq
, "CreateWindow:child", FALSE
);
4629 hchild2
= CreateWindowExA(0, "SimpleWindowClass", "Test child2", WS_CHILD
,
4630 100, 100, 50, 50, hparent
, 0, 0, NULL
);
4631 ok (hchild2
!= 0, "Failed to create child2 window\n");
4634 hbutton
= CreateWindowExA(0, "TestWindowClass", "Test button", WS_CHILD
,
4635 0, 100, 50, 50, hchild
, 0, 0, NULL
);
4636 ok (hbutton
!= 0, "Failed to create button window\n");
4638 /* test WM_SETREDRAW on a not visible child window */
4639 test_WM_SETREDRAW(hchild
);
4641 ShowWindow(hchild
, SW_SHOW
);
4642 ok_sequence(WmShowChildSeq
, "ShowWindow(SW_SHOW):child", FALSE
);
4644 /* check parent messages too */
4645 log_all_parent_messages
++;
4646 ShowWindow(hchild
, SW_HIDE
);
4647 ok_sequence(WmHideChildSeq2
, "ShowWindow(SW_HIDE):child", FALSE
);
4648 log_all_parent_messages
--;
4650 ShowWindow(hchild
, SW_SHOW
);
4651 ok_sequence(WmShowChildSeq
, "ShowWindow(SW_SHOW):child", FALSE
);
4653 ShowWindow(hchild
, SW_HIDE
);
4654 ok_sequence(WmHideChildSeq
, "ShowWindow(SW_HIDE):child", FALSE
);
4656 ShowWindow(hchild
, SW_SHOW
);
4657 ok_sequence(WmShowChildSeq
, "ShowWindow(SW_SHOW):child", FALSE
);
4659 /* test WM_SETREDRAW on a visible child window */
4660 test_WM_SETREDRAW(hchild
);
4662 log_all_parent_messages
++;
4663 MoveWindow(hchild
, 10, 10, 20, 20, TRUE
);
4664 ok_sequence(WmResizingChildWithMoveWindowSeq
, "MoveWindow:child", FALSE
);
4665 log_all_parent_messages
--;
4667 ShowWindow(hchild
, SW_HIDE
);
4669 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
);
4670 ok_sequence(WmShowChildSeq_2
, "SetWindowPos:show_child_2", FALSE
);
4672 ShowWindow(hchild
, SW_HIDE
);
4674 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
);
4675 ok_sequence(WmShowChildSeq_3
, "SetWindowPos:show_child_3", FALSE
);
4677 /* DestroyWindow sequence below expects that a child has focus */
4681 DestroyWindow(hchild
);
4682 ok_sequence(WmDestroyChildSeq
, "DestroyWindow:child", FALSE
);
4683 DestroyWindow(hchild2
);
4684 DestroyWindow(hbutton
);
4687 hchild
= CreateWindowExA(0, "TestWindowClass", "Test Child Popup", WS_CHILD
| WS_POPUP
,
4688 0, 0, 100, 100, hparent
, 0, 0, NULL
);
4689 ok (hchild
!= 0, "Failed to create child popup window\n");
4690 ok_sequence(WmCreateChildPopupSeq
, "CreateWindow:child_popup", FALSE
);
4691 DestroyWindow(hchild
);
4693 /* test what happens to a window which sets WS_VISIBLE in WM_CREATE */
4695 hchild
= CreateWindowExA(0, "TestPopupClass", "Test Popup", WS_POPUP
,
4696 0, 0, 100, 100, hparent
, 0, 0, NULL
);
4697 ok (hchild
!= 0, "Failed to create popup window\n");
4698 ok_sequence(WmCreateInvisiblePopupSeq
, "CreateWindow:invisible_popup", FALSE
);
4699 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
4700 ok(IsWindowVisible(hchild
), "IsWindowVisible() should return TRUE\n");
4702 ShowWindow(hchild
, SW_SHOW
);
4703 ok_sequence(WmEmptySeq
, "ShowWindow:show_visible_popup", FALSE
);
4705 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOZORDER
);
4706 ok_sequence(WmShowVisiblePopupSeq_2
, "SetWindowPos:show_visible_popup_2", FALSE
);
4708 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
);
4709 ok_sequence(WmShowVisiblePopupSeq_3
, "SetWindowPos:show_visible_popup_3", FALSE
);
4710 DestroyWindow(hchild
);
4712 /* this time add WS_VISIBLE for CreateWindowEx, but this fact actually
4713 * changes nothing in message sequences.
4716 hchild
= CreateWindowExA(0, "TestPopupClass", "Test Popup", WS_POPUP
| WS_VISIBLE
,
4717 0, 0, 100, 100, hparent
, 0, 0, NULL
);
4718 ok (hchild
!= 0, "Failed to create popup window\n");
4719 ok_sequence(WmCreateInvisiblePopupSeq
, "CreateWindow:invisible_popup", FALSE
);
4720 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
4721 ok(IsWindowVisible(hchild
), "IsWindowVisible() should return TRUE\n");
4723 ShowWindow(hchild
, SW_SHOW
);
4724 ok_sequence(WmEmptySeq
, "ShowWindow:show_visible_popup", FALSE
);
4726 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOZORDER
);
4727 ok_sequence(WmShowVisiblePopupSeq_2
, "SetWindowPos:show_visible_popup_2", FALSE
);
4728 DestroyWindow(hchild
);
4731 hwnd
= CreateWindowExA(WS_EX_DLGMODALFRAME
, "TestDialogClass", NULL
, WS_VISIBLE
|WS_CAPTION
|WS_SYSMENU
|WS_DLGFRAME
,
4732 0, 0, 100, 100, hparent
, 0, 0, NULL
);
4733 ok(hwnd
!= 0, "Failed to create custom dialog window\n");
4734 ok_sequence(WmCreateCustomDialogSeq
, "CreateCustomDialog", TRUE
);
4737 trace("testing scroll APIs on a visible dialog %p\n", hwnd
);
4738 test_scroll_messages(hwnd
);
4744 SendMessage(hwnd
, WM_NULL
, 0, 0);
4747 after_end_dialog
= 1;
4748 EndDialog( hwnd
, 0 );
4749 ok_sequence(WmEndCustomDialogSeq
, "EndCustomDialog", FALSE
);
4751 DestroyWindow(hwnd
);
4752 after_end_dialog
= 0;
4755 hwnd
= CreateWindowExA(0, "TestDialogClass", NULL
, WS_POPUP
,
4756 0, 0, 100, 100, 0, 0, GetModuleHandleA(0), NULL
);
4757 ok(hwnd
!= 0, "Failed to create custom dialog window\n");
4759 trace("call ShowWindow(%p, SW_SHOW)\n", hwnd
);
4760 ShowWindow(hwnd
, SW_SHOW
);
4761 ok_sequence(WmShowCustomDialogSeq
, "ShowCustomDialog", TRUE
);
4762 DestroyWindow(hwnd
);
4765 DialogBoxA( 0, "TEST_DIALOG", hparent
, TestModalDlgProcA
);
4766 ok_sequence(WmModalDialogSeq
, "ModalDialog", TRUE
);
4768 DestroyWindow(hparent
);
4771 /* Message sequence for SetMenu */
4772 ok(!DrawMenuBar(hwnd
), "DrawMenuBar should return FALSE for a window without a menu\n");
4773 ok_sequence(WmEmptySeq
, "DrawMenuBar for a window without a menu", FALSE
);
4775 hmenu
= CreateMenu();
4776 ok (hmenu
!= 0, "Failed to create menu\n");
4777 ok (InsertMenuA(hmenu
, -1, MF_BYPOSITION
, 0x1000, "foo"), "InsertMenu failed\n");
4778 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW
,
4779 100, 100, 200, 200, 0, hmenu
, 0, NULL
);
4780 ok_sequence(WmCreateOverlappedSeq
, "CreateWindow:overlapped", FALSE
);
4781 ok (SetMenu(hwnd
, 0), "SetMenu\n");
4782 ok_sequence(WmSetMenuNonVisibleSizeChangeSeq
, "SetMenu:NonVisibleSizeChange", FALSE
);
4783 ok (SetMenu(hwnd
, 0), "SetMenu\n");
4784 ok_sequence(WmSetMenuNonVisibleNoSizeChangeSeq
, "SetMenu:NonVisibleNoSizeChange", FALSE
);
4785 ShowWindow(hwnd
, SW_SHOW
);
4786 UpdateWindow( hwnd
);
4789 ok (SetMenu(hwnd
, 0), "SetMenu\n");
4790 ok_sequence(WmSetMenuVisibleNoSizeChangeSeq
, "SetMenu:VisibleNoSizeChange", FALSE
);
4791 ok (SetMenu(hwnd
, hmenu
), "SetMenu\n");
4792 ok_sequence(WmSetMenuVisibleSizeChangeSeq
, "SetMenu:VisibleSizeChange", FALSE
);
4794 UpdateWindow( hwnd
);
4797 ok(DrawMenuBar(hwnd
), "DrawMenuBar\n");
4799 ok_sequence(WmDrawMenuBarSeq
, "DrawMenuBar", FALSE
);
4801 DestroyWindow(hwnd
);
4804 /* Message sequence for EnableWindow */
4805 hparent
= CreateWindowExA(0, "TestWindowClass", "Test parent", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
4806 100, 100, 200, 200, 0, 0, 0, NULL
);
4807 ok (hparent
!= 0, "Failed to create parent window\n");
4808 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
| WS_VISIBLE
,
4809 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4810 ok (hchild
!= 0, "Failed to create child window\n");
4816 EnableWindow(hparent
, FALSE
);
4817 ok_sequence(WmEnableWindowSeq_1
, "EnableWindow(FALSE)", FALSE
);
4819 EnableWindow(hparent
, TRUE
);
4820 ok_sequence(WmEnableWindowSeq_2
, "EnableWindow(TRUE)", FALSE
);
4825 test_MsgWaitForMultipleObjects(hparent
);
4827 /* the following test causes an exception in user.exe under win9x */
4828 if (!PostMessageW( hparent
, WM_USER
, 0, 0 ))
4830 DestroyWindow(hparent
);
4834 PostMessageW( hparent
, WM_USER
+1, 0, 0 );
4835 /* PeekMessage(NULL) fails, but still removes the message */
4836 SetLastError(0xdeadbeef);
4837 ok( !PeekMessageW( NULL
, 0, 0, 0, PM_REMOVE
), "PeekMessage(NULL) should fail\n" );
4838 ok( GetLastError() == ERROR_NOACCESS
|| /* Win2k */
4839 GetLastError() == 0xdeadbeef, /* NT4 */
4840 "last error is %d\n", GetLastError() );
4841 ok( PeekMessageW( &msg
, 0, 0, 0, PM_REMOVE
), "PeekMessage should succeed\n" );
4842 ok( msg
.message
== WM_USER
+1, "got %x instead of WM_USER+1\n", msg
.message
);
4844 DestroyWindow(hchild
);
4845 DestroyWindow(hparent
);
4848 /* Message sequences for WM_SETICON */
4849 trace("testing WM_SETICON\n");
4850 hwnd
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
4851 CW_USEDEFAULT
, CW_USEDEFAULT
, 300, 300, 0,
4853 ShowWindow(hwnd
, SW_SHOW
);
4857 SendMessage(hwnd
, WM_SETICON
, ICON_SMALL
, (LPARAM
)LoadIcon(0, IDI_APPLICATION
));
4858 ok_sequence(WmSetIcon_1
, "WM_SETICON for shown window with caption", FALSE
);
4860 ShowWindow(hwnd
, SW_HIDE
);
4863 SendMessage(hwnd
, WM_SETICON
, ICON_SMALL
, (LPARAM
)LoadIcon(0, IDI_APPLICATION
));
4864 ok_sequence(WmSetIcon_2
, "WM_SETICON for hidden window with caption", FALSE
);
4865 DestroyWindow(hwnd
);
4868 hwnd
= CreateWindowExA(0, "TestPopupClass", NULL
, WS_POPUP
,
4869 CW_USEDEFAULT
, CW_USEDEFAULT
, 300, 300, 0,
4871 ShowWindow(hwnd
, SW_SHOW
);
4875 SendMessage(hwnd
, WM_SETICON
, ICON_SMALL
, (LPARAM
)LoadIcon(0, IDI_APPLICATION
));
4876 ok_sequence(WmSetIcon_2
, "WM_SETICON for shown window without caption", FALSE
);
4878 ShowWindow(hwnd
, SW_HIDE
);
4881 SendMessage(hwnd
, WM_SETICON
, ICON_SMALL
, (LPARAM
)LoadIcon(0, IDI_APPLICATION
));
4882 ok_sequence(WmSetIcon_2
, "WM_SETICON for hidden window without caption", FALSE
);
4885 res
= SendMessage(hwnd
, 0x3B, 0x8000000b, 0);
4888 todo_wine
win_skip( "Message 0x3b not supported\n" );
4891 ok_sequence(WmInitEndSession
, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x8000000b", TRUE
);
4892 ok(res
== 1, "SendMessage(hwnd, 0x3B, 0x8000000b, 0) should have returned 1 instead of %ld\n", res
);
4893 res
= SendMessage(hwnd
, 0x3B, 0x0000000b, 0);
4894 ok_sequence(WmInitEndSession_2
, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x0000000b", TRUE
);
4895 ok(res
== 1, "SendMessage(hwnd, 0x3B, 0x0000000b, 0) should have returned 1 instead of %ld\n", res
);
4896 res
= SendMessage(hwnd
, 0x3B, 0x0000000f, 0);
4897 ok_sequence(WmInitEndSession_2
, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x0000000f", TRUE
);
4898 ok(res
== 1, "SendMessage(hwnd, 0x3B, 0x0000000f, 0) should have returned 1 instead of %ld\n", res
);
4901 res
= SendMessage(hwnd
, 0x3B, 0x80000008, 0);
4902 ok_sequence(WmInitEndSession_3
, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x80000008", TRUE
);
4903 ok(res
== 2, "SendMessage(hwnd, 0x3B, 0x80000008, 0) should have returned 2 instead of %ld\n", res
);
4904 res
= SendMessage(hwnd
, 0x3B, 0x00000008, 0);
4905 ok_sequence(WmInitEndSession_4
, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x00000008", TRUE
);
4906 ok(res
== 2, "SendMessage(hwnd, 0x3B, 0x00000008, 0) should have returned 2 instead of %ld\n", res
);
4908 res
= SendMessage(hwnd
, 0x3B, 0x80000004, 0);
4909 ok_sequence(WmInitEndSession_3
, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x80000004", TRUE
);
4910 ok(res
== 2, "SendMessage(hwnd, 0x3B, 0x80000004, 0) should have returned 2 instead of %ld\n", res
);
4912 res
= SendMessage(hwnd
, 0x3B, 0x80000001, 0);
4913 ok_sequence(WmInitEndSession_5
, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x80000001", TRUE
);
4914 ok(res
== 2, "SendMessage(hwnd, 0x3B, 0x80000001, 0) should have returned 2 instead of %ld\n", res
);
4917 DestroyWindow(hwnd
);
4921 static void test_setwindowpos(void)
4926 const INT winX
= 100;
4927 const INT winY
= 100;
4928 const INT sysX
= GetSystemMetrics(SM_CXMINTRACK
);
4930 hwnd
= CreateWindowExA(0, "TestWindowClass", NULL
, 0,
4931 0, 0, winX
, winY
, 0,
4934 GetWindowRect(hwnd
, &rc
);
4935 expect(sysX
, rc
.right
);
4936 expect(winY
, rc
.bottom
);
4940 res
= SetWindowPos(hwnd
, HWND_TOPMOST
, 0, 0, winX
, winY
, 0);
4941 ok_sequence(WmZOrder
, "Z-Order", TRUE
);
4942 ok(res
== TRUE
, "SetWindowPos expected TRUE, got %ld\n", res
);
4944 GetWindowRect(hwnd
, &rc
);
4945 expect(sysX
, rc
.right
);
4946 expect(winY
, rc
.bottom
);
4947 DestroyWindow(hwnd
);
4950 static void invisible_parent_tests(void)
4952 HWND hparent
, hchild
;
4954 hparent
= CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW
,
4955 100, 100, 200, 200, 0, 0, 0, NULL
);
4956 ok (hparent
!= 0, "Failed to create parent window\n");
4959 /* test showing child with hidden parent */
4961 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
4962 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4963 ok (hchild
!= 0, "Failed to create child window\n");
4964 ok_sequence(WmCreateChildSeq
, "CreateWindow:child", FALSE
);
4966 ShowWindow( hchild
, SW_MINIMIZE
);
4967 ok_sequence(WmShowChildInvisibleParentSeq_1
, "ShowWindow(SW_MINIMIZE) child with invisible parent", FALSE
);
4968 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
4969 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
4974 ShowWindow( hchild
, SW_MINIMIZE
);
4975 ok_sequence(WmShowChildInvisibleParentSeq_1r
, "ShowWindow(SW_MINIMIZE) child with invisible parent", FALSE
);
4977 DestroyWindow(hchild
);
4978 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
4979 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4982 ShowWindow( hchild
, SW_MAXIMIZE
);
4983 ok_sequence(WmShowChildInvisibleParentSeq_2
, "ShowWindow(SW_MAXIMIZE) child with invisible parent", FALSE
);
4984 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
4985 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
4990 ShowWindow( hchild
, SW_MAXIMIZE
);
4991 ok_sequence(WmShowChildInvisibleParentSeq_2r
, "ShowWindow(SW_MAXIMIZE) child with invisible parent", FALSE
);
4993 DestroyWindow(hchild
);
4994 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
4995 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4998 ShowWindow( hchild
, SW_RESTORE
);
4999 ok_sequence(WmShowChildInvisibleParentSeq_5
, "ShowWindow(SW_RESTORE) child with invisible parent", FALSE
);
5000 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
5001 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
5003 DestroyWindow(hchild
);
5004 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
5005 0, 0, 10, 10, hparent
, 0, 0, NULL
);
5008 ShowWindow( hchild
, SW_SHOWMINIMIZED
);
5009 ok_sequence(WmShowChildInvisibleParentSeq_3
, "ShowWindow(SW_SHOWMINIMIZED) child with invisible parent", FALSE
);
5010 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
5011 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
5016 ShowWindow( hchild
, SW_SHOWMINIMIZED
);
5017 ok_sequence(WmShowChildInvisibleParentSeq_3r
, "ShowWindow(SW_SHOWMINIMIZED) child with invisible parent", FALSE
);
5019 DestroyWindow(hchild
);
5020 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
5021 0, 0, 10, 10, hparent
, 0, 0, NULL
);
5024 /* same as ShowWindow( hchild, SW_MAXIMIZE ); */
5025 ShowWindow( hchild
, SW_SHOWMAXIMIZED
);
5026 ok_sequence(WmShowChildInvisibleParentSeq_2
, "ShowWindow(SW_SHOWMAXIMIZED) child with invisible parent", FALSE
);
5027 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
5028 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
5030 DestroyWindow(hchild
);
5031 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
5032 0, 0, 10, 10, hparent
, 0, 0, NULL
);
5035 ShowWindow( hchild
, SW_SHOWMINNOACTIVE
);
5036 ok_sequence(WmShowChildInvisibleParentSeq_4
, "ShowWindow(SW_SHOWMINNOACTIVE) child with invisible parent", FALSE
);
5037 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
5038 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
5043 ShowWindow( hchild
, SW_SHOWMINNOACTIVE
);
5044 ok_sequence(WmShowChildInvisibleParentSeq_4r
, "ShowWindow(SW_SHOWMINNOACTIVE) child with invisible parent", FALSE
);
5046 DestroyWindow(hchild
);
5047 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
5048 0, 0, 10, 10, hparent
, 0, 0, NULL
);
5051 /* FIXME: looks like XP SP2 doesn't know about SW_FORCEMINIMIZE at all */
5052 ShowWindow( hchild
, SW_FORCEMINIMIZE
);
5053 ok_sequence(WmEmptySeq
, "ShowWindow(SW_FORCEMINIMIZE) child with invisible parent", TRUE
);
5055 ok(!(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
), "WS_VISIBLE should be not set\n");
5057 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
5059 DestroyWindow(hchild
);
5060 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
5061 0, 0, 10, 10, hparent
, 0, 0, NULL
);
5064 ShowWindow( hchild
, SW_SHOWNA
);
5065 ok_sequence(WmShowChildInvisibleParentSeq_5
, "ShowWindow(SW_SHOWNA) child with invisible parent", FALSE
);
5066 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
5067 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
5072 ShowWindow( hchild
, SW_SHOWNA
);
5073 ok_sequence(WmShowChildInvisibleParentSeq_5
, "ShowWindow(SW_SHOWNA) child with invisible parent", FALSE
);
5075 DestroyWindow(hchild
);
5076 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
5077 0, 0, 10, 10, hparent
, 0, 0, NULL
);
5080 ShowWindow( hchild
, SW_SHOW
);
5081 ok_sequence(WmShowChildInvisibleParentSeq_5
, "ShowWindow(SW_SHOW) child with invisible parent", FALSE
);
5082 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
5083 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
5088 ShowWindow( hchild
, SW_SHOW
);
5089 ok_sequence(WmEmptySeq
, "ShowWindow(SW_SHOW) child with invisible parent", FALSE
);
5091 ShowWindow( hchild
, SW_HIDE
);
5092 ok_sequence(WmHideChildInvisibleParentSeq
, "ShowWindow:hide child with invisible parent", FALSE
);
5093 ok(!(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
), "WS_VISIBLE should be not set\n");
5094 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
5096 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOZORDER
);
5097 ok_sequence(WmShowChildInvisibleParentSeq_6
, "SetWindowPos:show child with invisible parent", FALSE
);
5098 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
5099 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
5101 SetWindowPos(hchild
, 0,0,0,0,0, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOZORDER
);
5102 ok_sequence(WmHideChildInvisibleParentSeq_2
, "SetWindowPos:hide child with invisible parent", FALSE
);
5103 ok(!(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
), "WS_VISIBLE should not be set\n");
5104 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
5106 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOZORDER
);
5108 DestroyWindow(hchild
);
5109 ok_sequence(WmDestroyInvisibleChildSeq
, "DestroyInvisibleChildSeq", FALSE
);
5111 DestroyWindow(hparent
);
5115 /****************** button message test *************************/
5116 #define ID_BUTTON 0x000e
5118 static const struct message WmSetFocusButtonSeq
[] =
5120 { HCBT_SETFOCUS
, hook
},
5121 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
5122 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
5123 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
5124 { WM_SETFOCUS
, sent
|wparam
, 0 },
5125 { WM_CTLCOLORBTN
, sent
|parent
},
5126 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_BUTTON
, BN_SETFOCUS
) },
5127 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5130 static const struct message WmKillFocusButtonSeq
[] =
5132 { HCBT_SETFOCUS
, hook
},
5133 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
5134 { WM_KILLFOCUS
, sent
|wparam
, 0 },
5135 { WM_CTLCOLORBTN
, sent
|parent
},
5136 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_BUTTON
, BN_KILLFOCUS
) },
5137 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
5138 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 1 },
5139 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5141 { WM_CTLCOLORBTN
, sent
|parent
},
5144 static const struct message WmSetFocusStaticSeq
[] =
5146 { HCBT_SETFOCUS
, hook
},
5147 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
5148 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
5149 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
5150 { WM_SETFOCUS
, sent
|wparam
, 0 },
5151 { WM_CTLCOLORSTATIC
, sent
|parent
},
5152 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_BUTTON
, BN_SETFOCUS
) },
5153 { WM_COMMAND
, sent
|wparam
|parent
|optional
, MAKEWPARAM(ID_BUTTON
, BN_CLICKED
) }, /* radio button */
5154 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5157 static const struct message WmKillFocusStaticSeq
[] =
5159 { HCBT_SETFOCUS
, hook
},
5160 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
5161 { WM_KILLFOCUS
, sent
|wparam
, 0 },
5162 { WM_CTLCOLORSTATIC
, sent
|parent
},
5163 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_BUTTON
, BN_KILLFOCUS
) },
5164 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
5165 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 1 },
5166 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5168 { WM_CTLCOLORSTATIC
, sent
|parent
},
5171 static const struct message WmSetFocusOwnerdrawSeq
[] =
5173 { HCBT_SETFOCUS
, hook
},
5174 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
5175 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
5176 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
5177 { WM_SETFOCUS
, sent
|wparam
, 0 },
5178 { WM_CTLCOLORBTN
, sent
|parent
},
5179 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_BUTTON
, 0x001040e4 },
5180 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_BUTTON
, BN_SETFOCUS
) },
5181 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5184 static const struct message WmKillFocusOwnerdrawSeq
[] =
5186 { HCBT_SETFOCUS
, hook
},
5187 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
5188 { WM_KILLFOCUS
, sent
|wparam
, 0 },
5189 { WM_CTLCOLORBTN
, sent
|parent
},
5190 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_BUTTON
, 0x000040e4 },
5191 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_BUTTON
, BN_KILLFOCUS
) },
5192 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
5193 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 1 },
5194 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5196 { WM_CTLCOLORBTN
, sent
|parent
},
5197 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_BUTTON
, 0x000010e4 },
5200 static const struct message WmLButtonDownSeq
[] =
5202 { WM_LBUTTONDOWN
, sent
|wparam
|lparam
, 0, 0 },
5203 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
5204 { HCBT_SETFOCUS
, hook
},
5205 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
5206 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
5207 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
5208 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
5209 { WM_CTLCOLORBTN
, sent
|defwinproc
},
5210 { BM_SETSTATE
, sent
|wparam
|defwinproc
, TRUE
},
5211 { WM_CTLCOLORBTN
, sent
|defwinproc
},
5212 { EVENT_OBJECT_STATECHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
5215 static const struct message WmLButtonUpSeq
[] =
5217 { WM_LBUTTONUP
, sent
|wparam
|lparam
, 0, 0 },
5218 { BM_SETSTATE
, sent
|wparam
|defwinproc
, FALSE
},
5219 { WM_CTLCOLORBTN
, sent
|defwinproc
},
5220 { EVENT_OBJECT_STATECHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
5221 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, 0, 0 },
5222 { WM_CAPTURECHANGED
, sent
|wparam
|defwinproc
, 0 },
5225 static const struct message WmSetFontButtonSeq
[] =
5227 { WM_SETFONT
, sent
},
5229 { WM_ERASEBKGND
, sent
|defwinproc
|optional
},
5230 { WM_CTLCOLORBTN
, sent
|defwinproc
},
5233 static const struct message WmSetStyleButtonSeq
[] =
5235 { BM_SETSTYLE
, sent
},
5236 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5238 { WM_NCPAINT
, sent
|defwinproc
|optional
}, /* FIXME: Wine sends it */
5239 { WM_ERASEBKGND
, sent
|defwinproc
|optional
}, /* Win9x doesn't send it */
5240 { WM_CTLCOLORBTN
, sent
|parent
},
5243 static const struct message WmSetStyleStaticSeq
[] =
5245 { BM_SETSTYLE
, sent
},
5246 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5248 { WM_NCPAINT
, sent
|defwinproc
|optional
}, /* FIXME: Wine sends it */
5249 { WM_ERASEBKGND
, sent
|defwinproc
|optional
}, /* Win9x doesn't send it */
5250 { WM_CTLCOLORSTATIC
, sent
|parent
},
5253 static const struct message WmSetStyleUserSeq
[] =
5255 { BM_SETSTYLE
, sent
},
5256 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5258 { WM_NCPAINT
, sent
|defwinproc
|optional
}, /* FIXME: Wine sends it */
5259 { WM_ERASEBKGND
, sent
|defwinproc
|optional
}, /* Win9x doesn't send it */
5260 { WM_CTLCOLORBTN
, sent
|parent
},
5261 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_BUTTON
, BN_PAINT
) },
5264 static const struct message WmSetStyleOwnerdrawSeq
[] =
5266 { BM_SETSTYLE
, sent
},
5267 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5269 { WM_NCPAINT
, sent
|optional
}, /* FIXME: Wine sends it */
5270 { WM_ERASEBKGND
, sent
|defwinproc
|optional
}, /* Win9x doesn't send it */
5271 { WM_CTLCOLORBTN
, sent
|parent
},
5272 { WM_CTLCOLORBTN
, sent
|parent
|optional
}, /* Win9x doesn't send it */
5273 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_BUTTON
, 0x000010e4 },
5276 static const struct message WmSetStateButtonSeq
[] =
5278 { BM_SETSTATE
, sent
},
5279 { WM_CTLCOLORBTN
, sent
|parent
},
5280 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5283 static const struct message WmSetStateStaticSeq
[] =
5285 { BM_SETSTATE
, sent
},
5286 { WM_CTLCOLORSTATIC
, sent
|parent
},
5287 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5290 static const struct message WmSetStateUserSeq
[] =
5292 { BM_SETSTATE
, sent
},
5293 { WM_CTLCOLORBTN
, sent
|parent
},
5294 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_BUTTON
, BN_HILITE
) },
5295 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5298 static const struct message WmSetStateOwnerdrawSeq
[] =
5300 { BM_SETSTATE
, sent
},
5301 { WM_CTLCOLORBTN
, sent
|parent
},
5302 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_BUTTON
, 0x000120e4 },
5303 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5306 static const struct message WmClearStateButtonSeq
[] =
5308 { BM_SETSTATE
, sent
},
5309 { WM_CTLCOLORBTN
, sent
|parent
},
5310 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_BUTTON
, BN_UNHILITE
) },
5311 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5314 static const struct message WmClearStateOwnerdrawSeq
[] =
5316 { BM_SETSTATE
, sent
},
5317 { WM_CTLCOLORBTN
, sent
|parent
},
5318 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_BUTTON
, 0x000020e4 },
5319 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5322 static const struct message WmSetCheckIgnoredSeq
[] =
5324 { BM_SETCHECK
, sent
},
5325 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5328 static const struct message WmSetCheckStaticSeq
[] =
5330 { BM_SETCHECK
, sent
},
5331 { WM_CTLCOLORSTATIC
, sent
|parent
},
5332 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5336 static WNDPROC old_button_proc
;
5338 static LRESULT CALLBACK
button_hook_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
5340 static LONG defwndproc_counter
= 0;
5342 struct recvd_message msg
;
5344 if (ignore_message( message
)) return 0;
5352 ok(GetCapture() == hwnd
, "GetCapture() = %p\n", GetCapture());
5356 msg
.message
= message
;
5357 msg
.flags
= sent
|wparam
|lparam
;
5358 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
5359 msg
.wParam
= wParam
;
5360 msg
.lParam
= lParam
;
5361 msg
.descr
= "button";
5365 defwndproc_counter
++;
5366 ret
= CallWindowProcA(old_button_proc
, hwnd
, message
, wParam
, lParam
);
5367 defwndproc_counter
--;
5372 static void subclass_button(void)
5376 if (!GetClassInfoA(0, "button", &cls
)) assert(0);
5378 old_button_proc
= cls
.lpfnWndProc
;
5380 cls
.hInstance
= GetModuleHandle(0);
5381 cls
.lpfnWndProc
= button_hook_proc
;
5382 cls
.lpszClassName
= "my_button_class";
5383 UnregisterClass(cls
.lpszClassName
, cls
.hInstance
);
5384 if (!RegisterClassA(&cls
)) assert(0);
5387 static void test_button_messages(void)
5393 const struct message
*setfocus
;
5394 const struct message
*killfocus
;
5395 const struct message
*setstyle
;
5396 const struct message
*setstate
;
5397 const struct message
*clearstate
;
5398 const struct message
*setcheck
;
5400 { BS_PUSHBUTTON
, DLGC_BUTTON
| DLGC_UNDEFPUSHBUTTON
,
5401 WmSetFocusButtonSeq
, WmKillFocusButtonSeq
, WmSetStyleButtonSeq
,
5402 WmSetStateButtonSeq
, WmSetStateButtonSeq
, WmSetCheckIgnoredSeq
},
5403 { BS_DEFPUSHBUTTON
, DLGC_BUTTON
| DLGC_DEFPUSHBUTTON
,
5404 WmSetFocusButtonSeq
, WmKillFocusButtonSeq
, WmSetStyleButtonSeq
,
5405 WmSetStateButtonSeq
, WmSetStateButtonSeq
, WmSetCheckIgnoredSeq
},
5406 { BS_CHECKBOX
, DLGC_BUTTON
,
5407 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
, WmSetStyleStaticSeq
,
5408 WmSetStateStaticSeq
, WmSetStateStaticSeq
, WmSetCheckStaticSeq
},
5409 { BS_AUTOCHECKBOX
, DLGC_BUTTON
,
5410 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
, WmSetStyleStaticSeq
,
5411 WmSetStateStaticSeq
, WmSetStateStaticSeq
, WmSetCheckStaticSeq
},
5412 { BS_RADIOBUTTON
, DLGC_BUTTON
| DLGC_RADIOBUTTON
,
5413 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
, WmSetStyleStaticSeq
,
5414 WmSetStateStaticSeq
, WmSetStateStaticSeq
, WmSetCheckStaticSeq
},
5415 { BS_3STATE
, DLGC_BUTTON
,
5416 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
, WmSetStyleStaticSeq
,
5417 WmSetStateStaticSeq
, WmSetStateStaticSeq
, WmSetCheckStaticSeq
},
5418 { BS_AUTO3STATE
, DLGC_BUTTON
,
5419 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
, WmSetStyleStaticSeq
,
5420 WmSetStateStaticSeq
, WmSetStateStaticSeq
, WmSetCheckStaticSeq
},
5421 { BS_GROUPBOX
, DLGC_STATIC
,
5422 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
, WmSetStyleStaticSeq
,
5423 WmSetStateStaticSeq
, WmSetStateStaticSeq
, WmSetCheckIgnoredSeq
},
5424 { BS_USERBUTTON
, DLGC_BUTTON
| DLGC_UNDEFPUSHBUTTON
,
5425 WmSetFocusButtonSeq
, WmKillFocusButtonSeq
, WmSetStyleUserSeq
,
5426 WmSetStateUserSeq
, WmClearStateButtonSeq
, WmSetCheckIgnoredSeq
},
5427 { BS_AUTORADIOBUTTON
, DLGC_BUTTON
| DLGC_RADIOBUTTON
,
5428 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
, WmSetStyleStaticSeq
,
5429 WmSetStateStaticSeq
, WmSetStateStaticSeq
, WmSetCheckStaticSeq
},
5430 { BS_OWNERDRAW
, DLGC_BUTTON
,
5431 WmSetFocusOwnerdrawSeq
, WmKillFocusOwnerdrawSeq
, WmSetStyleOwnerdrawSeq
,
5432 WmSetStateOwnerdrawSeq
, WmClearStateOwnerdrawSeq
, WmSetCheckIgnoredSeq
},
5439 /* selection with VK_SPACE should capture button window */
5440 hwnd
= CreateWindowExA(0, "button", "test", BS_CHECKBOX
| WS_VISIBLE
| WS_POPUP
,
5441 0, 0, 50, 14, 0, 0, 0, NULL
);
5442 ok(hwnd
!= 0, "Failed to create button window\n");
5445 SendMessageA(hwnd
, WM_KEYDOWN
, VK_SPACE
, 0);
5446 ok(GetCapture() == hwnd
, "Should be captured on VK_SPACE WM_KEYDOWN\n");
5447 SendMessageA(hwnd
, WM_KEYUP
, VK_SPACE
, 0);
5448 DestroyWindow(hwnd
);
5452 parent
= CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
5453 100, 100, 200, 200, 0, 0, 0, NULL
);
5454 ok(parent
!= 0, "Failed to create parent window\n");
5456 for (i
= 0; i
< sizeof(button
)/sizeof(button
[0]); i
++)
5461 trace("button style %08x\n", button
[i
].style
);
5463 hwnd
= CreateWindowExA(0, "my_button_class", "test", button
[i
].style
| WS_CHILD
| BS_NOTIFY
,
5464 0, 0, 50, 14, parent
, (HMENU
)ID_BUTTON
, 0, NULL
);
5465 ok(hwnd
!= 0, "Failed to create button window\n");
5467 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
5468 style
&= ~(WS_CHILD
| BS_NOTIFY
);
5469 /* XP turns a BS_USERBUTTON into BS_PUSHBUTTON */
5470 if (button
[i
].style
== BS_USERBUTTON
)
5471 ok(style
== BS_PUSHBUTTON
, "expected style BS_PUSHBUTTON got %x\n", style
);
5473 ok(style
== button
[i
].style
, "expected style %x got %x\n", button
[i
].style
, style
);
5475 dlg_code
= SendMessageA(hwnd
, WM_GETDLGCODE
, 0, 0);
5476 ok(dlg_code
== button
[i
].dlg_code
, "%u: wrong dlg_code %08x\n", i
, dlg_code
);
5478 ShowWindow(hwnd
, SW_SHOW
);
5485 log_all_parent_messages
++;
5487 ok(GetFocus() == 0, "expected focus 0, got %p\n", GetFocus());
5489 SendMessage(hwnd
, WM_APP
, 0, 0); /* place a separator mark here */
5490 while (PeekMessage(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage(&msg
);
5491 ok_sequence(button
[i
].setfocus
, "SetFocus(hwnd) on a button", FALSE
);
5494 SendMessage(hwnd
, WM_APP
, 0, 0); /* place a separator mark here */
5495 while (PeekMessage(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage(&msg
);
5496 ok_sequence(button
[i
].killfocus
, "SetFocus(0) on a button", FALSE
);
5498 ok(GetFocus() == 0, "expected focus 0, got %p\n", GetFocus());
5500 SendMessage(hwnd
, BM_SETSTYLE
, button
[i
].style
| BS_BOTTOM
, TRUE
);
5501 SendMessage(hwnd
, WM_APP
, 0, 0); /* place a separator mark here */
5502 while (PeekMessage(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage(&msg
);
5503 ok_sequence(button
[i
].setstyle
, "BM_SETSTYLE on a button", FALSE
);
5505 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
5506 style
&= ~(WS_VISIBLE
| WS_CHILD
| BS_NOTIFY
);
5507 /* XP doesn't turn a BS_USERBUTTON into BS_PUSHBUTTON here! */
5508 ok(style
== button
[i
].style
, "expected style %04x got %04x\n", button
[i
].style
, style
);
5510 state
= SendMessage(hwnd
, BM_GETSTATE
, 0, 0);
5511 ok(state
== 0, "expected state 0, got %04x\n", state
);
5515 SendMessage(hwnd
, BM_SETSTATE
, TRUE
, 0);
5516 SendMessage(hwnd
, WM_APP
, 0, 0); /* place a separator mark here */
5517 while (PeekMessage(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage(&msg
);
5518 ok_sequence(button
[i
].setstate
, "BM_SETSTATE/TRUE on a button", FALSE
);
5520 state
= SendMessage(hwnd
, BM_GETSTATE
, 0, 0);
5521 ok(state
== 0x0004, "expected state 0x0004, got %04x\n", state
);
5523 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
5524 style
&= ~(WS_CHILD
| BS_NOTIFY
| WS_VISIBLE
);
5525 ok(style
== button
[i
].style
, "expected style %04x got %04x\n", button
[i
].style
, style
);
5529 SendMessage(hwnd
, BM_SETSTATE
, FALSE
, 0);
5530 SendMessage(hwnd
, WM_APP
, 0, 0); /* place a separator mark here */
5531 while (PeekMessage(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage(&msg
);
5532 ok_sequence(button
[i
].clearstate
, "BM_SETSTATE/FALSE on a button", FALSE
);
5534 state
= SendMessage(hwnd
, BM_GETSTATE
, 0, 0);
5535 ok(state
== 0, "expected state 0, got %04x\n", state
);
5537 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
5538 style
&= ~(WS_CHILD
| BS_NOTIFY
| WS_VISIBLE
);
5539 ok(style
== button
[i
].style
, "expected style %04x got %04x\n", button
[i
].style
, style
);
5541 state
= SendMessage(hwnd
, BM_GETCHECK
, 0, 0);
5542 ok(state
== BST_UNCHECKED
, "expected BST_UNCHECKED, got %04x\n", state
);
5546 SendMessage(hwnd
, BM_SETCHECK
, BST_UNCHECKED
, 0);
5547 SendMessage(hwnd
, WM_APP
, 0, 0); /* place a separator mark here */
5548 while (PeekMessage(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage(&msg
);
5549 ok_sequence(WmSetCheckIgnoredSeq
, "BM_SETCHECK on a button", FALSE
);
5551 state
= SendMessage(hwnd
, BM_GETCHECK
, 0, 0);
5552 ok(state
== BST_UNCHECKED
, "expected BST_UNCHECKED, got %04x\n", state
);
5554 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
5555 style
&= ~(WS_CHILD
| BS_NOTIFY
| WS_VISIBLE
);
5556 ok(style
== button
[i
].style
, "expected style %04x got %04x\n", button
[i
].style
, style
);
5560 SendMessage(hwnd
, BM_SETCHECK
, BST_CHECKED
, 0);
5561 SendMessage(hwnd
, WM_APP
, 0, 0); /* place a separator mark here */
5562 while (PeekMessage(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage(&msg
);
5563 ok_sequence(button
[i
].setcheck
, "BM_SETCHECK on a button", FALSE
);
5565 state
= SendMessage(hwnd
, BM_GETCHECK
, 0, 0);
5566 if (button
[i
].style
== BS_PUSHBUTTON
||
5567 button
[i
].style
== BS_DEFPUSHBUTTON
||
5568 button
[i
].style
== BS_GROUPBOX
||
5569 button
[i
].style
== BS_USERBUTTON
||
5570 button
[i
].style
== BS_OWNERDRAW
)
5571 ok(state
== BST_UNCHECKED
, "expected check 0, got %04x\n", state
);
5573 ok(state
== BST_CHECKED
, "expected check 1, got %04x\n", state
);
5575 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
5576 style
&= ~(WS_CHILD
| BS_NOTIFY
| WS_VISIBLE
);
5577 if (button
[i
].style
== BS_RADIOBUTTON
||
5578 button
[i
].style
== BS_AUTORADIOBUTTON
)
5579 ok(style
== (button
[i
].style
| WS_TABSTOP
), "expected style %04x | WS_TABSTOP got %04x\n", button
[i
].style
, style
);
5581 ok(style
== button
[i
].style
, "expected style %04x got %04x\n", button
[i
].style
, style
);
5583 log_all_parent_messages
--;
5585 DestroyWindow(hwnd
);
5588 DestroyWindow(parent
);
5590 hwnd
= CreateWindowExA(0, "my_button_class", "test", BS_PUSHBUTTON
| WS_POPUP
| WS_VISIBLE
,
5591 0, 0, 50, 14, 0, 0, 0, NULL
);
5592 ok(hwnd
!= 0, "Failed to create button window\n");
5594 SetForegroundWindow(hwnd
);
5597 SetActiveWindow(hwnd
);
5601 SendMessageA(hwnd
, WM_LBUTTONDOWN
, 0, 0);
5602 ok_sequence(WmLButtonDownSeq
, "WM_LBUTTONDOWN on a button", FALSE
);
5604 SendMessageA(hwnd
, WM_LBUTTONUP
, 0, 0);
5605 ok_sequence(WmLButtonUpSeq
, "WM_LBUTTONUP on a button", FALSE
);
5608 zfont
= GetStockObject(SYSTEM_FONT
);
5609 SendMessageA(hwnd
, WM_SETFONT
, (WPARAM
)zfont
, TRUE
);
5611 ok_sequence(WmSetFontButtonSeq
, "WM_SETFONT on a button", FALSE
);
5613 DestroyWindow(hwnd
);
5616 /****************** static message test *************************/
5617 static const struct message WmSetFontStaticSeq
[] =
5619 { WM_SETFONT
, sent
},
5620 { WM_PAINT
, sent
|defwinproc
|optional
},
5621 { WM_ERASEBKGND
, sent
|defwinproc
|optional
},
5622 { WM_CTLCOLORSTATIC
, sent
|defwinproc
|optional
},
5626 static WNDPROC old_static_proc
;
5628 static LRESULT CALLBACK
static_hook_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
5630 static LONG defwndproc_counter
= 0;
5632 struct recvd_message msg
;
5634 if (ignore_message( message
)) return 0;
5637 msg
.message
= message
;
5638 msg
.flags
= sent
|wparam
|lparam
;
5639 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
5640 msg
.wParam
= wParam
;
5641 msg
.lParam
= lParam
;
5642 msg
.descr
= "static";
5645 defwndproc_counter
++;
5646 ret
= CallWindowProcA(old_static_proc
, hwnd
, message
, wParam
, lParam
);
5647 defwndproc_counter
--;
5652 static void subclass_static(void)
5656 if (!GetClassInfoA(0, "static", &cls
)) assert(0);
5658 old_static_proc
= cls
.lpfnWndProc
;
5660 cls
.hInstance
= GetModuleHandle(0);
5661 cls
.lpfnWndProc
= static_hook_proc
;
5662 cls
.lpszClassName
= "my_static_class";
5663 UnregisterClass(cls
.lpszClassName
, cls
.hInstance
);
5664 if (!RegisterClassA(&cls
)) assert(0);
5667 static void test_static_messages(void)
5669 /* FIXME: make as comprehensive as the button message test */
5674 const struct message
*setfont
;
5676 { SS_LEFT
, DLGC_STATIC
,
5677 WmSetFontStaticSeq
}
5685 for (i
= 0; i
< sizeof(static_ctrl
)/sizeof(static_ctrl
[0]); i
++)
5687 hwnd
= CreateWindowExA(0, "my_static_class", "test", static_ctrl
[i
].style
| WS_POPUP
,
5688 0, 0, 50, 14, 0, 0, 0, NULL
);
5689 ok(hwnd
!= 0, "Failed to create static window\n");
5691 dlg_code
= SendMessageA(hwnd
, WM_GETDLGCODE
, 0, 0);
5692 ok(dlg_code
== static_ctrl
[i
].dlg_code
, "%u: wrong dlg_code %08x\n", i
, dlg_code
);
5694 ShowWindow(hwnd
, SW_SHOW
);
5699 trace("static style %08x\n", static_ctrl
[i
].style
);
5700 SendMessage(hwnd
, WM_SETFONT
, (WPARAM
)GetStockObject(DEFAULT_GUI_FONT
), TRUE
);
5701 ok_sequence(static_ctrl
[i
].setfont
, "WM_SETFONT on a static", FALSE
);
5703 DestroyWindow(hwnd
);
5707 /****************** ComboBox message test *************************/
5708 #define ID_COMBOBOX 0x000f
5710 static const struct message WmKeyDownComboSeq
[] =
5712 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_DOWN
, 0 },
5713 { WM_COMMAND
, sent
|wparam
|defwinproc
, MAKEWPARAM(1000, LBN_SELCHANGE
) },
5714 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_COMBOBOX
, CBN_SELENDOK
) },
5715 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_COMBOBOX
, CBN_SELCHANGE
) },
5716 { WM_CTLCOLOREDIT
, sent
|parent
},
5717 { WM_KEYUP
, sent
|wparam
|lparam
, VK_DOWN
, 0 },
5721 static WNDPROC old_combobox_proc
;
5723 static LRESULT CALLBACK
combobox_hook_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
5725 static LONG defwndproc_counter
= 0;
5727 struct recvd_message msg
;
5729 /* do not log painting messages */
5730 if (message
!= WM_PAINT
&&
5731 message
!= WM_NCPAINT
&&
5732 message
!= WM_SYNCPAINT
&&
5733 message
!= WM_ERASEBKGND
&&
5734 message
!= WM_NCHITTEST
&&
5735 message
!= WM_GETTEXT
&&
5736 !ignore_message( message
))
5739 msg
.message
= message
;
5740 msg
.flags
= sent
|wparam
|lparam
;
5741 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
5742 msg
.wParam
= wParam
;
5743 msg
.lParam
= lParam
;
5744 msg
.descr
= "combo";
5748 defwndproc_counter
++;
5749 ret
= CallWindowProcA(old_combobox_proc
, hwnd
, message
, wParam
, lParam
);
5750 defwndproc_counter
--;
5755 static void subclass_combobox(void)
5759 if (!GetClassInfoA(0, "ComboBox", &cls
)) assert(0);
5761 old_combobox_proc
= cls
.lpfnWndProc
;
5763 cls
.hInstance
= GetModuleHandle(0);
5764 cls
.lpfnWndProc
= combobox_hook_proc
;
5765 cls
.lpszClassName
= "my_combobox_class";
5766 UnregisterClass(cls
.lpszClassName
, cls
.hInstance
);
5767 if (!RegisterClassA(&cls
)) assert(0);
5770 static void test_combobox_messages(void)
5775 subclass_combobox();
5777 parent
= CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
5778 100, 100, 200, 200, 0, 0, 0, NULL
);
5779 ok(parent
!= 0, "Failed to create parent window\n");
5782 combo
= CreateWindowEx(0, "my_combobox_class", "test", WS_CHILD
| WS_VISIBLE
| CBS_DROPDOWNLIST
| CBS_HASSTRINGS
,
5783 0, 0, 100, 150, parent
, (HMENU
)ID_COMBOBOX
, 0, NULL
);
5784 ok(combo
!= 0, "Failed to create combobox window\n");
5786 UpdateWindow(combo
);
5788 ret
= SendMessage(combo
, WM_GETDLGCODE
, 0, 0);
5789 ok(ret
== (DLGC_WANTCHARS
| DLGC_WANTARROWS
), "wrong dlg_code %08lx\n", ret
);
5791 ret
= SendMessage(combo
, CB_ADDSTRING
, 0, (LPARAM
)"item 0");
5792 ok(ret
== 0, "expected 0, got %ld\n", ret
);
5793 ret
= SendMessage(combo
, CB_ADDSTRING
, 0, (LPARAM
)"item 1");
5794 ok(ret
== 1, "expected 1, got %ld\n", ret
);
5795 ret
= SendMessage(combo
, CB_ADDSTRING
, 0, (LPARAM
)"item 2");
5796 ok(ret
== 2, "expected 2, got %ld\n", ret
);
5798 SendMessage(combo
, CB_SETCURSEL
, 0, 0);
5802 log_all_parent_messages
++;
5803 SendMessage(combo
, WM_KEYDOWN
, VK_DOWN
, 0);
5804 SendMessage(combo
, WM_KEYUP
, VK_DOWN
, 0);
5805 log_all_parent_messages
--;
5806 ok_sequence(WmKeyDownComboSeq
, "WM_KEYDOWN/VK_DOWN on a ComboBox", FALSE
);
5808 DestroyWindow(combo
);
5809 DestroyWindow(parent
);
5812 /****************** WM_IME_KEYDOWN message test *******************/
5814 static const struct message WmImeKeydownMsgSeq_0
[] =
5816 { WM_IME_KEYDOWN
, wparam
, VK_RETURN
},
5817 { WM_CHAR
, wparam
, 'A' },
5821 static const struct message WmImeKeydownMsgSeq_1
[] =
5823 { WM_KEYDOWN
, optional
|wparam
, VK_RETURN
},
5824 { WM_CHAR
, optional
|wparam
, VK_RETURN
},
5828 static LRESULT WINAPI
wmime_keydown_procA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
5830 struct recvd_message msg
;
5833 msg
.message
= message
;
5834 msg
.flags
= wparam
|lparam
;
5835 msg
.wParam
= wParam
;
5836 msg
.lParam
= lParam
;
5837 msg
.descr
= "wmime_keydown";
5840 return DefWindowProcA(hwnd
, message
, wParam
, lParam
);
5843 static void register_wmime_keydown_class(void)
5847 ZeroMemory(&cls
, sizeof(WNDCLASSA
));
5848 cls
.lpfnWndProc
= wmime_keydown_procA
;
5849 cls
.hInstance
= GetModuleHandleA(0);
5850 cls
.lpszClassName
= "wmime_keydown_class";
5851 if (!RegisterClassA(&cls
)) assert(0);
5854 static void test_wmime_keydown_message(void)
5859 trace("Message sequences by WM_IME_KEYDOWN\n");
5861 register_wmime_keydown_class();
5862 hwnd
= CreateWindowExA(0, "wmime_keydown_class", NULL
, WS_OVERLAPPEDWINDOW
,
5863 CW_USEDEFAULT
, CW_USEDEFAULT
, 300, 300, 0,
5868 SendMessage(hwnd
, WM_IME_KEYDOWN
, VK_RETURN
, 0x1c0001);
5869 SendMessage(hwnd
, WM_CHAR
, 'A', 1);
5870 ok_sequence(WmImeKeydownMsgSeq_0
, "WM_IME_KEYDOWN 0", FALSE
);
5872 while ( PeekMessage(&msg
, 0, 0, 0, PM_REMOVE
) )
5874 TranslateMessage(&msg
);
5875 DispatchMessage(&msg
);
5877 ok_sequence(WmImeKeydownMsgSeq_1
, "WM_IME_KEYDOWN 1", FALSE
);
5879 DestroyWindow(hwnd
);
5882 /************* painting message test ********************/
5884 void dump_region(HRGN hrgn
)
5887 RGNDATA
*data
= NULL
;
5892 printf( "null region\n" );
5895 if (!(size
= GetRegionData( hrgn
, 0, NULL
))) return;
5896 if (!(data
= HeapAlloc( GetProcessHeap(), 0, size
))) return;
5897 GetRegionData( hrgn
, size
, data
);
5898 printf("%d rects:", data
->rdh
.nCount
);
5899 for (i
= 0, rect
= (RECT
*)data
->Buffer
; i
< data
->rdh
.nCount
; i
++, rect
++)
5900 printf( " (%d,%d)-(%d,%d)", rect
->left
, rect
->top
, rect
->right
, rect
->bottom
);
5902 HeapFree( GetProcessHeap(), 0, data
);
5905 static void check_update_rgn( HWND hwnd
, HRGN hrgn
)
5909 HRGN tmp
= CreateRectRgn( 0, 0, 0, 0 );
5910 HRGN update
= CreateRectRgn( 0, 0, 0, 0 );
5912 ret
= GetUpdateRgn( hwnd
, update
, FALSE
);
5913 ok( ret
!= ERROR
, "GetUpdateRgn failed\n" );
5914 if (ret
== NULLREGION
)
5916 ok( !hrgn
, "Update region shouldn't be empty\n" );
5920 if (CombineRgn( tmp
, hrgn
, update
, RGN_XOR
) != NULLREGION
)
5922 ok( 0, "Regions are different\n" );
5923 if (winetest_debug
> 0)
5925 printf( "Update region: " );
5926 dump_region( update
);
5927 printf( "Wanted region: " );
5928 dump_region( hrgn
);
5932 GetRgnBox( update
, &r1
);
5933 GetUpdateRect( hwnd
, &r2
, FALSE
);
5934 ok( r1
.left
== r2
.left
&& r1
.top
== r2
.top
&& r1
.right
== r2
.right
&& r1
.bottom
== r2
.bottom
,
5935 "Rectangles are different: %d,%d-%d,%d / %d,%d-%d,%d\n",
5936 r1
.left
, r1
.top
, r1
.right
, r1
.bottom
, r2
.left
, r2
.top
, r2
.right
, r2
.bottom
);
5938 DeleteObject( tmp
);
5939 DeleteObject( update
);
5942 static const struct message WmInvalidateRgn
[] = {
5943 { WM_NCPAINT
, sent
},
5944 { WM_GETTEXT
, sent
|defwinproc
|optional
},
5948 static const struct message WmGetUpdateRect
[] = {
5949 { WM_NCPAINT
, sent
},
5950 { WM_GETTEXT
, sent
|defwinproc
|optional
},
5955 static const struct message WmInvalidateFull
[] = {
5956 { WM_NCPAINT
, sent
|wparam
, 1 },
5957 { WM_GETTEXT
, sent
|defwinproc
|optional
},
5961 static const struct message WmInvalidateErase
[] = {
5962 { WM_NCPAINT
, sent
|wparam
, 1 },
5963 { WM_GETTEXT
, sent
|defwinproc
|optional
},
5964 { WM_ERASEBKGND
, sent
},
5968 static const struct message WmInvalidatePaint
[] = {
5970 { WM_NCPAINT
, sent
|wparam
|beginpaint
, 1 },
5971 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
5975 static const struct message WmInvalidateErasePaint
[] = {
5977 { WM_NCPAINT
, sent
|wparam
|beginpaint
, 1 },
5978 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
5979 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
5983 static const struct message WmInvalidateErasePaint2
[] = {
5985 { WM_NCPAINT
, sent
|beginpaint
},
5986 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
5987 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
5991 static const struct message WmErase
[] = {
5992 { WM_ERASEBKGND
, sent
},
5996 static const struct message WmPaint
[] = {
6001 static const struct message WmParentOnlyPaint
[] = {
6002 { WM_PAINT
, sent
|parent
},
6006 static const struct message WmInvalidateParent
[] = {
6007 { WM_NCPAINT
, sent
|parent
},
6008 { WM_GETTEXT
, sent
|defwinproc
|parent
|optional
},
6009 { WM_ERASEBKGND
, sent
|parent
},
6013 static const struct message WmInvalidateParentChild
[] = {
6014 { WM_NCPAINT
, sent
|parent
},
6015 { WM_GETTEXT
, sent
|defwinproc
|parent
|optional
},
6016 { WM_ERASEBKGND
, sent
|parent
},
6017 { WM_NCPAINT
, sent
},
6018 { WM_GETTEXT
, sent
|defwinproc
|optional
},
6019 { WM_ERASEBKGND
, sent
},
6023 static const struct message WmInvalidateParentChild2
[] = {
6024 { WM_ERASEBKGND
, sent
|parent
},
6025 { WM_NCPAINT
, sent
},
6026 { WM_GETTEXT
, sent
|defwinproc
|optional
},
6027 { WM_ERASEBKGND
, sent
},
6031 static const struct message WmParentPaint
[] = {
6032 { WM_PAINT
, sent
|parent
},
6037 static const struct message WmParentPaintNc
[] = {
6038 { WM_PAINT
, sent
|parent
},
6040 { WM_NCPAINT
, sent
|beginpaint
},
6041 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
6042 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
6046 static const struct message WmChildPaintNc
[] = {
6048 { WM_NCPAINT
, sent
|beginpaint
},
6049 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
6050 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
6054 static const struct message WmParentErasePaint
[] = {
6055 { WM_PAINT
, sent
|parent
},
6056 { WM_NCPAINT
, sent
|parent
|beginpaint
},
6057 { WM_GETTEXT
, sent
|parent
|beginpaint
|defwinproc
|optional
},
6058 { WM_ERASEBKGND
, sent
|parent
|beginpaint
|optional
},
6060 { WM_NCPAINT
, sent
|beginpaint
},
6061 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
6062 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
6066 static const struct message WmParentOnlyNcPaint
[] = {
6067 { WM_PAINT
, sent
|parent
},
6068 { WM_NCPAINT
, sent
|parent
|beginpaint
},
6069 { WM_GETTEXT
, sent
|parent
|beginpaint
|defwinproc
|optional
},
6073 static const struct message WmSetParentStyle
[] = {
6074 { WM_STYLECHANGING
, sent
|parent
},
6075 { WM_STYLECHANGED
, sent
|parent
},
6079 static void test_paint_messages(void)
6085 HWND hparent
, hchild
;
6086 HRGN hrgn
= CreateRectRgn( 0, 0, 0, 0 );
6087 HRGN hrgn2
= CreateRectRgn( 0, 0, 0, 0 );
6088 HWND hwnd
= CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW
,
6089 100, 100, 200, 200, 0, 0, 0, NULL
);
6090 ok (hwnd
!= 0, "Failed to create overlapped window\n");
6092 ShowWindow( hwnd
, SW_SHOW
);
6093 UpdateWindow( hwnd
);
6097 check_update_rgn( hwnd
, 0 );
6098 SetRectRgn( hrgn
, 10, 10, 20, 20 );
6099 ret
= RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
);
6100 ok(ret
, "RedrawWindow returned %d instead of TRUE\n", ret
);
6101 check_update_rgn( hwnd
, hrgn
);
6102 SetRectRgn( hrgn2
, 20, 20, 30, 30 );
6103 ret
= RedrawWindow( hwnd
, NULL
, hrgn2
, RDW_INVALIDATE
);
6104 ok(ret
, "RedrawWindow returned %d instead of TRUE\n", ret
);
6105 CombineRgn( hrgn
, hrgn
, hrgn2
, RGN_OR
);
6106 check_update_rgn( hwnd
, hrgn
);
6107 /* validate everything */
6108 ret
= RedrawWindow( hwnd
, NULL
, NULL
, RDW_VALIDATE
);
6109 ok(ret
, "RedrawWindow returned %d instead of TRUE\n", ret
);
6110 check_update_rgn( hwnd
, 0 );
6112 /* test empty region */
6113 SetRectRgn( hrgn
, 10, 10, 10, 15 );
6114 ret
= RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
);
6115 ok(ret
, "RedrawWindow returned %d instead of TRUE\n", ret
);
6116 check_update_rgn( hwnd
, 0 );
6117 /* test empty rect */
6118 SetRect( &rect
, 10, 10, 10, 15 );
6119 ret
= RedrawWindow( hwnd
, &rect
, NULL
, RDW_INVALIDATE
);
6120 ok(ret
, "RedrawWindow returned %d instead of TRUE\n", ret
);
6121 check_update_rgn( hwnd
, 0 );
6123 /* flush pending messages */
6127 GetClientRect( hwnd
, &rect
);
6128 SetRectRgn( hrgn
, 0, 0, rect
.right
- rect
.left
, rect
.bottom
- rect
.top
);
6129 /* MSDN: if hwnd parameter is NULL, InvalidateRect invalidates and redraws
6130 * all windows and sends WM_ERASEBKGND and WM_NCPAINT.
6132 trace("testing InvalidateRect(0, NULL, FALSE)\n");
6133 SetRectEmpty( &rect
);
6134 ok(InvalidateRect(0, &rect
, FALSE
), "InvalidateRect(0, &rc, FALSE) should fail\n");
6135 check_update_rgn( hwnd
, hrgn
);
6136 ok_sequence( WmInvalidateErase
, "InvalidateErase", FALSE
);
6138 ok_sequence( WmPaint
, "Paint", FALSE
);
6139 RedrawWindow( hwnd
, NULL
, NULL
, RDW_VALIDATE
);
6140 check_update_rgn( hwnd
, 0 );
6142 /* MSDN: if hwnd parameter is NULL, ValidateRect invalidates and redraws
6143 * all windows and sends WM_ERASEBKGND and WM_NCPAINT.
6145 trace("testing ValidateRect(0, NULL)\n");
6146 SetRectEmpty( &rect
);
6147 if (ValidateRect(0, &rect
)) /* not supported on Win9x */
6149 check_update_rgn( hwnd
, hrgn
);
6150 ok_sequence( WmInvalidateErase
, "InvalidateErase", FALSE
);
6152 ok_sequence( WmPaint
, "Paint", FALSE
);
6153 RedrawWindow( hwnd
, NULL
, NULL
, RDW_VALIDATE
);
6154 check_update_rgn( hwnd
, 0 );
6157 trace("testing InvalidateRgn(0, NULL, FALSE)\n");
6158 SetLastError(0xdeadbeef);
6159 ok(!InvalidateRgn(0, NULL
, FALSE
), "InvalidateRgn(0, NULL, FALSE) should fail\n");
6160 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
|| GetLastError() == 0xdeadbeef,
6161 "wrong error code %d\n", GetLastError());
6162 check_update_rgn( hwnd
, 0 );
6164 ok_sequence( WmEmptySeq
, "WmEmptySeq", FALSE
);
6166 trace("testing ValidateRgn(0, NULL)\n");
6167 SetLastError(0xdeadbeef);
6168 ok(!ValidateRgn(0, NULL
), "ValidateRgn(0, NULL) should fail\n");
6169 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
||
6170 broken( GetLastError() == 0xdeadbeef ) /* win9x */,
6171 "wrong error code %d\n", GetLastError());
6172 check_update_rgn( hwnd
, 0 );
6174 ok_sequence( WmEmptySeq
, "WmEmptySeq", FALSE
);
6176 trace("testing UpdateWindow(NULL)\n");
6177 SetLastError(0xdeadbeef);
6178 ok(!UpdateWindow(NULL
), "UpdateWindow(NULL) should fail\n");
6179 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
||
6180 broken( GetLastError() == 0xdeadbeef ) /* win9x */,
6181 "wrong error code %d\n", GetLastError());
6182 check_update_rgn( hwnd
, 0 );
6184 ok_sequence( WmEmptySeq
, "WmEmptySeq", FALSE
);
6186 /* now with frame */
6187 SetRectRgn( hrgn
, -5, -5, 20, 20 );
6189 /* flush pending messages */
6192 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_FRAME
);
6193 ok_sequence( WmEmptySeq
, "EmptySeq", FALSE
);
6195 SetRectRgn( hrgn
, 0, 0, 20, 20 ); /* GetUpdateRgn clips to client area */
6196 check_update_rgn( hwnd
, hrgn
);
6199 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASENOW
);
6200 ok_sequence( WmInvalidateRgn
, "InvalidateRgn", FALSE
);
6203 RedrawWindow( hwnd
, NULL
, NULL
, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASENOW
);
6204 ok_sequence( WmInvalidateFull
, "InvalidateFull", FALSE
);
6206 GetClientRect( hwnd
, &rect
);
6207 SetRectRgn( hrgn
, rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
6208 check_update_rgn( hwnd
, hrgn
);
6211 RedrawWindow( hwnd
, NULL
, NULL
, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASE
| RDW_ERASENOW
);
6212 ok_sequence( WmInvalidateErase
, "InvalidateErase", FALSE
);
6215 RedrawWindow( hwnd
, NULL
, NULL
, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASENOW
| RDW_UPDATENOW
);
6216 ok_sequence( WmInvalidatePaint
, "InvalidatePaint", FALSE
);
6217 check_update_rgn( hwnd
, 0 );
6220 RedrawWindow( hwnd
, NULL
, NULL
, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASE
| RDW_UPDATENOW
);
6221 ok_sequence( WmInvalidateErasePaint
, "InvalidateErasePaint", FALSE
);
6222 check_update_rgn( hwnd
, 0 );
6225 SetRectRgn( hrgn
, 0, 0, 100, 100 );
6226 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
);
6227 SetRectRgn( hrgn
, 0, 0, 50, 100 );
6228 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_VALIDATE
);
6229 SetRectRgn( hrgn
, 50, 0, 100, 100 );
6230 check_update_rgn( hwnd
, hrgn
);
6231 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_VALIDATE
| RDW_ERASENOW
);
6232 ok_sequence( WmEmptySeq
, "EmptySeq", FALSE
); /* must not generate messages, everything is valid */
6233 check_update_rgn( hwnd
, 0 );
6236 SetRectRgn( hrgn
, 0, 0, 100, 100 );
6237 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_ERASE
);
6238 SetRectRgn( hrgn
, 0, 0, 100, 50 );
6239 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_VALIDATE
| RDW_ERASENOW
);
6240 ok_sequence( WmErase
, "Erase", FALSE
);
6241 SetRectRgn( hrgn
, 0, 50, 100, 100 );
6242 check_update_rgn( hwnd
, hrgn
);
6245 SetRectRgn( hrgn
, 0, 0, 100, 100 );
6246 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_ERASE
);
6247 SetRectRgn( hrgn
, 0, 0, 50, 50 );
6248 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_VALIDATE
| RDW_NOERASE
| RDW_UPDATENOW
);
6249 ok_sequence( WmPaint
, "Paint", FALSE
);
6252 SetRectRgn( hrgn
, -4, -4, -2, -2 );
6253 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_FRAME
);
6254 SetRectRgn( hrgn
, -200, -200, -198, -198 );
6255 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_VALIDATE
| RDW_NOFRAME
| RDW_ERASENOW
);
6256 ok_sequence( WmEmptySeq
, "EmptySeq", FALSE
);
6259 SetRectRgn( hrgn
, -4, -4, -2, -2 );
6260 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_FRAME
);
6261 SetRectRgn( hrgn
, -4, -4, -3, -3 );
6262 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_VALIDATE
| RDW_NOFRAME
);
6263 SetRectRgn( hrgn
, 0, 0, 1, 1 );
6264 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_UPDATENOW
);
6265 ok_sequence( WmPaint
, "Paint", FALSE
);
6268 SetRectRgn( hrgn
, -4, -4, -1, -1 );
6269 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_FRAME
);
6270 RedrawWindow( hwnd
, NULL
, 0, RDW_ERASENOW
);
6271 /* make sure no WM_PAINT was generated */
6273 ok_sequence( WmInvalidateRgn
, "InvalidateRgn", FALSE
);
6276 SetRectRgn( hrgn
, -4, -4, -1, -1 );
6277 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_FRAME
);
6278 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
))
6280 if (msg
.hwnd
== hwnd
&& msg
.message
== WM_PAINT
)
6282 /* GetUpdateRgn must return empty region since only nonclient area is invalidated */
6283 INT ret
= GetUpdateRgn( hwnd
, hrgn
, FALSE
);
6284 ok( ret
== NULLREGION
, "Invalid GetUpdateRgn result %d\n", ret
);
6285 ret
= GetUpdateRect( hwnd
, &rect
, FALSE
);
6286 ok( ret
, "Invalid GetUpdateRect result %d\n", ret
);
6287 /* this will send WM_NCPAINT and validate the non client area */
6288 ret
= GetUpdateRect( hwnd
, &rect
, TRUE
);
6289 ok( !ret
, "Invalid GetUpdateRect result %d\n", ret
);
6291 DispatchMessage( &msg
);
6293 ok_sequence( WmGetUpdateRect
, "GetUpdateRect", FALSE
);
6295 DestroyWindow( hwnd
);
6297 /* now test with a child window */
6299 hparent
= CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW
,
6300 100, 100, 200, 200, 0, 0, 0, NULL
);
6301 ok (hparent
!= 0, "Failed to create parent window\n");
6303 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
| WS_VISIBLE
| WS_BORDER
,
6304 10, 10, 100, 100, hparent
, 0, 0, NULL
);
6305 ok (hchild
!= 0, "Failed to create child window\n");
6307 ShowWindow( hparent
, SW_SHOW
);
6308 UpdateWindow( hparent
);
6309 UpdateWindow( hchild
);
6312 log_all_parent_messages
++;
6314 SetRect( &rect
, 0, 0, 50, 50 );
6315 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
6316 RedrawWindow( hparent
, NULL
, 0, RDW_ERASENOW
| RDW_ALLCHILDREN
);
6317 ok_sequence( WmInvalidateParentChild
, "InvalidateParentChild", FALSE
);
6319 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
6321 MapWindowPoints( hchild
, hparent
, &pt
, 1 );
6322 SetRectRgn( hrgn
, 0, 0, 50 - pt
.x
, 50 - pt
.y
);
6323 check_update_rgn( hchild
, hrgn
);
6324 SetRectRgn( hrgn
, 0, 0, 50, 50 );
6325 check_update_rgn( hparent
, hrgn
);
6326 RedrawWindow( hparent
, NULL
, 0, RDW_ERASENOW
);
6327 ok_sequence( WmInvalidateParent
, "InvalidateParent", FALSE
);
6328 RedrawWindow( hchild
, NULL
, 0, RDW_ERASENOW
);
6329 ok_sequence( WmEmptySeq
, "EraseNow child", FALSE
);
6332 ok_sequence( WmParentPaintNc
, "WmParentPaintNc", FALSE
);
6334 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
| RDW_ALLCHILDREN
);
6335 RedrawWindow( hparent
, NULL
, 0, RDW_ERASENOW
);
6336 ok_sequence( WmInvalidateParent
, "InvalidateParent2", FALSE
);
6337 RedrawWindow( hchild
, NULL
, 0, RDW_ERASENOW
);
6338 ok_sequence( WmEmptySeq
, "EraseNow child", FALSE
);
6340 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
);
6341 RedrawWindow( hparent
, NULL
, 0, RDW_ERASENOW
| RDW_ALLCHILDREN
);
6342 ok_sequence( WmInvalidateParentChild2
, "InvalidateParentChild2", FALSE
);
6344 SetWindowLong( hparent
, GWL_STYLE
, GetWindowLong(hparent
,GWL_STYLE
) | WS_CLIPCHILDREN
);
6346 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
| RDW_ALLCHILDREN
);
6347 RedrawWindow( hparent
, NULL
, 0, RDW_ERASENOW
);
6348 ok_sequence( WmInvalidateParentChild
, "InvalidateParentChild3", FALSE
);
6350 /* flush all paint messages */
6354 /* RDW_UPDATENOW on child with WS_CLIPCHILDREN doesn't change corresponding parent area */
6355 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
| RDW_ALLCHILDREN
);
6356 SetRectRgn( hrgn
, 0, 0, 50, 50 );
6357 check_update_rgn( hparent
, hrgn
);
6358 RedrawWindow( hchild
, NULL
, 0, RDW_UPDATENOW
);
6359 ok_sequence( WmInvalidateErasePaint2
, "WmInvalidateErasePaint2", FALSE
);
6360 SetRectRgn( hrgn
, 0, 0, 50, 50 );
6361 check_update_rgn( hparent
, hrgn
);
6363 /* flush all paint messages */
6365 SetWindowLong( hparent
, GWL_STYLE
, GetWindowLong(hparent
,GWL_STYLE
) & ~WS_CLIPCHILDREN
);
6368 /* RDW_UPDATENOW on child without WS_CLIPCHILDREN will validate corresponding parent area */
6369 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
6370 SetRectRgn( hrgn
, 0, 0, 50, 50 );
6371 check_update_rgn( hparent
, hrgn
);
6372 RedrawWindow( hchild
, NULL
, 0, RDW_UPDATENOW
);
6373 ok_sequence( WmInvalidateErasePaint2
, "WmInvalidateErasePaint2", FALSE
);
6374 SetRectRgn( hrgn2
, 10, 10, 50, 50 );
6375 CombineRgn( hrgn
, hrgn
, hrgn2
, RGN_DIFF
);
6376 check_update_rgn( hparent
, hrgn
);
6377 /* flush all paint messages */
6381 /* same as above but parent gets completely validated */
6382 SetRect( &rect
, 20, 20, 30, 30 );
6383 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
6384 SetRectRgn( hrgn
, 20, 20, 30, 30 );
6385 check_update_rgn( hparent
, hrgn
);
6386 RedrawWindow( hchild
, NULL
, 0, RDW_UPDATENOW
);
6387 ok_sequence( WmInvalidateErasePaint2
, "WmInvalidateErasePaint2", FALSE
);
6388 check_update_rgn( hparent
, 0 ); /* no update region */
6390 ok_sequence( WmEmptySeq
, "WmEmpty", FALSE
); /* and no paint messages */
6392 /* make sure RDW_VALIDATE on child doesn't have the same effect */
6394 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
6395 SetRectRgn( hrgn
, 20, 20, 30, 30 );
6396 check_update_rgn( hparent
, hrgn
);
6397 RedrawWindow( hchild
, NULL
, 0, RDW_VALIDATE
| RDW_NOERASE
);
6398 SetRectRgn( hrgn
, 20, 20, 30, 30 );
6399 check_update_rgn( hparent
, hrgn
);
6401 /* same as above but normal WM_PAINT doesn't validate parent */
6403 SetRect( &rect
, 20, 20, 30, 30 );
6404 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
6405 SetRectRgn( hrgn
, 20, 20, 30, 30 );
6406 check_update_rgn( hparent
, hrgn
);
6407 /* no WM_PAINT in child while parent still pending */
6408 while (PeekMessage( &msg
, hchild
, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
6409 ok_sequence( WmEmptySeq
, "No WM_PAINT", FALSE
);
6410 while (PeekMessage( &msg
, hparent
, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
6411 ok_sequence( WmParentErasePaint
, "WmParentErasePaint", FALSE
);
6414 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
6415 /* no WM_PAINT in child while parent still pending */
6416 while (PeekMessage( &msg
, hchild
, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
6417 ok_sequence( WmEmptySeq
, "No WM_PAINT", FALSE
);
6418 RedrawWindow( hparent
, &rect
, 0, RDW_VALIDATE
| RDW_NOERASE
| RDW_NOCHILDREN
);
6419 /* now that parent is valid child should get WM_PAINT */
6420 while (PeekMessage( &msg
, hchild
, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
6421 ok_sequence( WmInvalidateErasePaint2
, "WmInvalidateErasePaint2", FALSE
);
6422 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
6423 ok_sequence( WmEmptySeq
, "No other message", FALSE
);
6425 /* same thing with WS_CLIPCHILDREN in parent */
6427 SetWindowLong( hparent
, GWL_STYLE
, GetWindowLong(hparent
,GWL_STYLE
) | WS_CLIPCHILDREN
);
6428 ok_sequence( WmSetParentStyle
, "WmSetParentStyle", FALSE
);
6429 /* changing style invalidates non client area, but we need to invalidate something else to see it */
6430 RedrawWindow( hparent
, &rect
, 0, RDW_UPDATENOW
);
6431 ok_sequence( WmEmptySeq
, "No message", FALSE
);
6432 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_UPDATENOW
);
6433 ok_sequence( WmParentOnlyNcPaint
, "WmParentOnlyNcPaint", FALSE
);
6436 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_ALLCHILDREN
);
6437 SetRectRgn( hrgn
, 20, 20, 30, 30 );
6438 check_update_rgn( hparent
, hrgn
);
6439 /* no WM_PAINT in child while parent still pending */
6440 while (PeekMessage( &msg
, hchild
, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
6441 ok_sequence( WmEmptySeq
, "No WM_PAINT", FALSE
);
6442 /* WM_PAINT in parent first */
6443 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
6444 ok_sequence( WmParentPaintNc
, "WmParentPaintNc2", FALSE
);
6446 /* no RDW_ERASE in parent still causes RDW_ERASE and RDW_FRAME in child */
6448 SetRect( &rect
, 0, 0, 30, 30 );
6449 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ALLCHILDREN
);
6450 SetRectRgn( hrgn
, 0, 0, 30, 30 );
6451 check_update_rgn( hparent
, hrgn
);
6453 ok_sequence( WmParentPaintNc
, "WmParentPaintNc3", FALSE
);
6455 /* validate doesn't cause RDW_NOERASE or RDW_NOFRAME in child */
6457 SetRect( &rect
, -10, 0, 30, 30 );
6458 RedrawWindow( hchild
, &rect
, 0, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASE
);
6459 SetRect( &rect
, 0, 0, 20, 20 );
6460 RedrawWindow( hparent
, &rect
, 0, RDW_VALIDATE
| RDW_ALLCHILDREN
);
6461 RedrawWindow( hparent
, NULL
, 0, RDW_UPDATENOW
);
6462 ok_sequence( WmChildPaintNc
, "WmChildPaintNc", FALSE
);
6464 /* validate doesn't cause RDW_NOERASE or RDW_NOFRAME in child */
6466 SetRect( &rect
, -10, 0, 30, 30 );
6467 RedrawWindow( hchild
, &rect
, 0, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASE
);
6468 SetRect( &rect
, 0, 0, 100, 100 );
6469 RedrawWindow( hparent
, &rect
, 0, RDW_VALIDATE
| RDW_ALLCHILDREN
);
6470 RedrawWindow( hparent
, NULL
, 0, RDW_UPDATENOW
);
6471 ok_sequence( WmEmptySeq
, "WmChildPaintNc2", FALSE
);
6472 RedrawWindow( hparent
, NULL
, 0, RDW_ERASENOW
);
6473 ok_sequence( WmEmptySeq
, "WmChildPaintNc3", FALSE
);
6475 /* test RDW_INTERNALPAINT behavior */
6478 RedrawWindow( hparent
, NULL
, 0, RDW_INTERNALPAINT
| RDW_NOCHILDREN
);
6480 ok_sequence( WmParentOnlyPaint
, "WmParentOnlyPaint", FALSE
);
6482 RedrawWindow( hparent
, NULL
, 0, RDW_INTERNALPAINT
| RDW_ALLCHILDREN
);
6484 ok_sequence( WmParentPaint
, "WmParentPaint", FALSE
);
6486 RedrawWindow( hparent
, NULL
, 0, RDW_INTERNALPAINT
);
6488 ok_sequence( WmParentOnlyPaint
, "WmParentOnlyPaint", FALSE
);
6490 assert( GetWindowLong(hparent
, GWL_STYLE
) & WS_CLIPCHILDREN
);
6491 UpdateWindow( hparent
);
6494 trace("testing SWP_FRAMECHANGED on parent with WS_CLIPCHILDREN\n");
6495 RedrawWindow( hchild
, NULL
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
6496 SetWindowPos( hparent
, 0, 0, 0, 0, 0, SWP_NOSIZE
| SWP_NOMOVE
|
6497 SWP_NOACTIVATE
| SWP_NOZORDER
| SWP_FRAMECHANGED
);
6499 ok_sequence(WmSWP_FrameChanged_clip
, "SetWindowPos:FrameChanged_clip", FALSE
);
6501 UpdateWindow( hparent
);
6504 trace("testing SWP_FRAMECHANGED|SWP_DEFERERASE on parent with WS_CLIPCHILDREN\n");
6505 RedrawWindow( hchild
, NULL
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
6506 SetWindowPos( hparent
, 0, 0, 0, 0, 0, SWP_NOSIZE
| SWP_NOMOVE
| SWP_DEFERERASE
|
6507 SWP_NOACTIVATE
| SWP_NOZORDER
| SWP_FRAMECHANGED
);
6509 ok_sequence(WmSWP_FrameChangedDeferErase
, "SetWindowPos:FrameChangedDeferErase", FALSE
);
6511 SetWindowLong( hparent
, GWL_STYLE
, GetWindowLong(hparent
,GWL_STYLE
) & ~WS_CLIPCHILDREN
);
6512 ok_sequence( WmSetParentStyle
, "WmSetParentStyle", FALSE
);
6513 RedrawWindow( hparent
, NULL
, 0, RDW_INTERNALPAINT
);
6515 ok_sequence( WmParentPaint
, "WmParentPaint", FALSE
);
6517 assert( !(GetWindowLong(hparent
, GWL_STYLE
) & WS_CLIPCHILDREN
) );
6518 UpdateWindow( hparent
);
6521 trace("testing SWP_FRAMECHANGED on parent without WS_CLIPCHILDREN\n");
6522 RedrawWindow( hchild
, NULL
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
6523 SetWindowPos( hparent
, 0, 0, 0, 0, 0, SWP_NOSIZE
| SWP_NOMOVE
|
6524 SWP_NOACTIVATE
| SWP_NOZORDER
| SWP_FRAMECHANGED
);
6526 ok_sequence(WmSWP_FrameChanged_noclip
, "SetWindowPos:FrameChanged_noclip", FALSE
);
6528 UpdateWindow( hparent
);
6531 trace("testing SWP_FRAMECHANGED|SWP_DEFERERASE on parent without WS_CLIPCHILDREN\n");
6532 RedrawWindow( hchild
, NULL
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
6533 SetWindowPos( hparent
, 0, 0, 0, 0, 0, SWP_NOSIZE
| SWP_NOMOVE
| SWP_DEFERERASE
|
6534 SWP_NOACTIVATE
| SWP_NOZORDER
| SWP_FRAMECHANGED
);
6536 ok_sequence(WmSWP_FrameChangedDeferErase
, "SetWindowPos:FrameChangedDeferErase", FALSE
);
6538 ok(GetWindowLong( hparent
, GWL_STYLE
) & WS_VISIBLE
, "parent should be visible\n");
6539 ok(GetWindowLong( hchild
, GWL_STYLE
) & WS_VISIBLE
, "child should be visible\n");
6541 UpdateWindow( hparent
);
6544 trace("testing SetWindowPos(-10000, -10000) on child\n");
6545 SetWindowPos( hchild
, 0, -10000, -10000, 0, 0, SWP_NOSIZE
| SWP_NOACTIVATE
| SWP_NOZORDER
);
6546 check_update_rgn( hchild
, 0 );
6549 #if 0 /* this one doesn't pass under Wine yet */
6550 UpdateWindow( hparent
);
6553 trace("testing ShowWindow(SW_MINIMIZE) on child\n");
6554 ShowWindow( hchild
, SW_MINIMIZE
);
6555 check_update_rgn( hchild
, 0 );
6559 UpdateWindow( hparent
);
6562 trace("testing SetWindowPos(-10000, -10000) on parent\n");
6563 SetWindowPos( hparent
, 0, -10000, -10000, 0, 0, SWP_NOSIZE
| SWP_NOACTIVATE
| SWP_NOZORDER
);
6564 check_update_rgn( hparent
, 0 );
6567 log_all_parent_messages
--;
6568 DestroyWindow( hparent
);
6569 ok(!IsWindow(hchild
), "child must be destroyed with its parent\n");
6571 /* tests for moving windows off-screen (needs simple WS_POPUP windows) */
6573 hparent
= CreateWindowExA(0, "TestParentClass", "Test parent", WS_POPUP
| WS_VISIBLE
,
6574 100, 100, 200, 200, 0, 0, 0, NULL
);
6575 ok (hparent
!= 0, "Failed to create parent window\n");
6577 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
| WS_VISIBLE
,
6578 10, 10, 100, 100, hparent
, 0, 0, NULL
);
6579 ok (hchild
!= 0, "Failed to create child window\n");
6581 ShowWindow( hparent
, SW_SHOW
);
6582 UpdateWindow( hparent
);
6583 UpdateWindow( hchild
);
6587 /* moving child outside of parent boundaries changes update region */
6588 SetRect( &rect
, 0, 0, 40, 40 );
6589 RedrawWindow( hchild
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
);
6590 SetRectRgn( hrgn
, 0, 0, 40, 40 );
6591 check_update_rgn( hchild
, hrgn
);
6592 MoveWindow( hchild
, -10, 10, 100, 100, FALSE
);
6593 SetRectRgn( hrgn
, 10, 0, 40, 40 );
6594 check_update_rgn( hchild
, hrgn
);
6595 MoveWindow( hchild
, -10, -10, 100, 100, FALSE
);
6596 SetRectRgn( hrgn
, 10, 10, 40, 40 );
6597 check_update_rgn( hchild
, hrgn
);
6599 /* moving parent off-screen does too */
6600 SetRect( &rect
, 0, 0, 100, 100 );
6601 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_NOCHILDREN
);
6602 SetRectRgn( hrgn
, 0, 0, 100, 100 );
6603 check_update_rgn( hparent
, hrgn
);
6604 SetRectRgn( hrgn
, 10, 10, 40, 40 );
6605 check_update_rgn( hchild
, hrgn
);
6606 MoveWindow( hparent
, -20, -20, 200, 200, FALSE
);
6607 SetRectRgn( hrgn
, 20, 20, 100, 100 );
6608 check_update_rgn( hparent
, hrgn
);
6609 SetRectRgn( hrgn
, 30, 30, 40, 40 );
6610 check_update_rgn( hchild
, hrgn
);
6612 /* invalidated region is cropped by the parent rects */
6613 SetRect( &rect
, 0, 0, 50, 50 );
6614 RedrawWindow( hchild
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
);
6615 SetRectRgn( hrgn
, 30, 30, 50, 50 );
6616 check_update_rgn( hchild
, hrgn
);
6618 DestroyWindow( hparent
);
6619 ok(!IsWindow(hchild
), "child must be destroyed with its parent\n");
6622 DeleteObject( hrgn
);
6623 DeleteObject( hrgn2
);
6634 static DWORD WINAPI
thread_proc(void *param
)
6637 struct wnd_event
*wnd_event
= param
;
6639 wnd_event
->hwnd
= CreateWindowExA(0, "TestWindowClass", "window caption text", WS_OVERLAPPEDWINDOW
,
6640 100, 100, 200, 200, 0, 0, 0, NULL
);
6641 ok(wnd_event
->hwnd
!= 0, "Failed to create overlapped window\n");
6643 SetEvent(wnd_event
->start_event
);
6645 while (GetMessage(&msg
, 0, 0, 0))
6647 TranslateMessage(&msg
);
6648 DispatchMessage(&msg
);
6651 ok(IsWindow(wnd_event
->hwnd
), "window should still exist\n");
6656 static DWORD CALLBACK
create_grand_child_thread( void *param
)
6658 struct wnd_event
*wnd_event
= param
;
6662 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child",
6663 WS_CHILD
| WS_VISIBLE
, 0, 0, 10, 10, wnd_event
->hwnd
, 0, 0, NULL
);
6664 ok (hchild
!= 0, "Failed to create child window\n");
6667 SetEvent( wnd_event
->start_event
);
6671 MsgWaitForMultipleObjects(0, NULL
, FALSE
, 1000, QS_ALLINPUT
);
6672 if (!IsWindow( hchild
)) break; /* will be destroyed when parent thread exits */
6673 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage(&msg
);
6678 static DWORD CALLBACK
create_child_thread( void *param
)
6680 struct wnd_event
*wnd_event
= param
;
6681 struct wnd_event child_event
;
6685 child_event
.hwnd
= CreateWindowExA(0, "TestWindowClass", "Test child",
6686 WS_CHILD
| WS_VISIBLE
, 0, 0, 10, 10, wnd_event
->hwnd
, 0, 0, NULL
);
6687 ok (child_event
.hwnd
!= 0, "Failed to create child window\n");
6688 SetFocus( child_event
.hwnd
);
6691 child_event
.start_event
= wnd_event
->start_event
;
6692 wnd_event
->grand_child
= CreateThread(NULL
, 0, create_grand_child_thread
, &child_event
, 0, &tid
);
6695 DWORD ret
= MsgWaitForMultipleObjects(1, &child_event
.start_event
, FALSE
, 1000, QS_SENDMESSAGE
);
6696 if (ret
!= 1) break;
6697 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage(&msg
);
6699 ret
= WaitForSingleObject( wnd_event
->stop_event
, 5000 );
6700 ok( !ret
, "WaitForSingleObject failed %x\n", ret
);
6704 static void test_interthread_messages(void)
6711 int len
, expected_len
;
6712 struct wnd_event wnd_event
;
6715 wnd_event
.start_event
= CreateEventW(NULL
, 0, 0, NULL
);
6716 if (!wnd_event
.start_event
)
6718 win_skip("skipping interthread message test under win9x\n");
6722 hThread
= CreateThread(NULL
, 0, thread_proc
, &wnd_event
, 0, &tid
);
6723 ok(hThread
!= NULL
, "CreateThread failed, error %d\n", GetLastError());
6725 ok(WaitForSingleObject(wnd_event
.start_event
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
6727 CloseHandle(wnd_event
.start_event
);
6729 SetLastError(0xdeadbeef);
6730 ok(!DestroyWindow(wnd_event
.hwnd
), "DestroyWindow succeded\n");
6731 ok(GetLastError() == ERROR_ACCESS_DENIED
|| GetLastError() == 0xdeadbeef,
6732 "wrong error code %d\n", GetLastError());
6734 proc
= (WNDPROC
)GetWindowLongPtrA(wnd_event
.hwnd
, GWLP_WNDPROC
);
6735 ok(proc
!= NULL
, "GetWindowLongPtrA(GWLP_WNDPROC) error %d\n", GetLastError());
6737 expected_len
= lstrlenA("window caption text");
6738 memset(buf
, 0, sizeof(buf
));
6739 SetLastError(0xdeadbeef);
6740 len
= CallWindowProcA(proc
, wnd_event
.hwnd
, WM_GETTEXT
, sizeof(buf
), (LPARAM
)buf
);
6741 ok(len
== expected_len
, "CallWindowProcA(WM_GETTEXT) error %d, len %d, expected len %d\n", GetLastError(), len
, expected_len
);
6742 ok(!lstrcmpA(buf
, "window caption text"), "window text mismatch\n");
6744 msg
.hwnd
= wnd_event
.hwnd
;
6745 msg
.message
= WM_GETTEXT
;
6746 msg
.wParam
= sizeof(buf
);
6747 msg
.lParam
= (LPARAM
)buf
;
6748 memset(buf
, 0, sizeof(buf
));
6749 SetLastError(0xdeadbeef);
6750 len
= DispatchMessageA(&msg
);
6751 ok((!len
&& GetLastError() == ERROR_MESSAGE_SYNC_ONLY
) || broken(len
), /* nt4 */
6752 "DispatchMessageA(WM_GETTEXT) succeded on another thread window: ret %d, error %d\n", len
, GetLastError());
6754 /* the following test causes an exception in user.exe under win9x */
6755 msg
.hwnd
= wnd_event
.hwnd
;
6756 msg
.message
= WM_TIMER
;
6758 msg
.lParam
= GetWindowLongPtrA(wnd_event
.hwnd
, GWLP_WNDPROC
);
6759 SetLastError(0xdeadbeef);
6760 len
= DispatchMessageA(&msg
);
6761 ok(!len
&& GetLastError() == 0xdeadbeef,
6762 "DispatchMessageA(WM_TIMER) failed on another thread window: ret %d, error %d\n", len
, GetLastError());
6764 ret
= PostMessageA(wnd_event
.hwnd
, WM_QUIT
, 0, 0);
6765 ok( ret
, "PostMessageA(WM_QUIT) error %d\n", GetLastError());
6767 ok(WaitForSingleObject(hThread
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
6768 CloseHandle(hThread
);
6770 ok(!IsWindow(wnd_event
.hwnd
), "window should be destroyed on thread exit\n");
6772 wnd_event
.hwnd
= CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
6773 100, 100, 200, 200, 0, 0, 0, NULL
);
6774 ok (wnd_event
.hwnd
!= 0, "Failed to create parent window\n");
6776 log_all_parent_messages
++;
6777 wnd_event
.start_event
= CreateEventA( NULL
, TRUE
, FALSE
, NULL
);
6778 wnd_event
.stop_event
= CreateEventA( NULL
, TRUE
, FALSE
, NULL
);
6779 hThread
= CreateThread( NULL
, 0, create_child_thread
, &wnd_event
, 0, &tid
);
6782 ret
= MsgWaitForMultipleObjects(1, &wnd_event
.start_event
, FALSE
, 1000, QS_SENDMESSAGE
);
6783 if (ret
!= 1) break;
6784 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage(&msg
);
6786 ok( !ret
, "MsgWaitForMultipleObjects failed %x\n", ret
);
6787 /* now wait for the thread without processing messages; this shouldn't deadlock */
6788 SetEvent( wnd_event
.stop_event
);
6789 ret
= WaitForSingleObject( hThread
, 5000 );
6790 ok( !ret
, "WaitForSingleObject failed %x\n", ret
);
6791 CloseHandle( hThread
);
6793 ret
= WaitForSingleObject( wnd_event
.grand_child
, 5000 );
6794 ok( !ret
, "WaitForSingleObject failed %x\n", ret
);
6795 CloseHandle( wnd_event
.grand_child
);
6797 CloseHandle( wnd_event
.start_event
);
6798 CloseHandle( wnd_event
.stop_event
);
6800 ok_sequence(WmExitThreadSeq
, "destroy child on thread exit", FALSE
);
6801 log_all_parent_messages
--;
6802 DestroyWindow( wnd_event
.hwnd
);
6806 static const struct message WmVkN
[] = {
6807 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 1 }, /* XP */
6808 { WM_KEYDOWN
, wparam
|lparam
, 'N', 1 },
6809 { WM_KEYDOWN
, sent
|wparam
|lparam
, 'N', 1 },
6810 { WM_CHAR
, wparam
|lparam
, 'n', 1 },
6811 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1002,1), 0 },
6812 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xc0000001 }, /* XP */
6813 { WM_KEYUP
, wparam
|lparam
, 'N', 0xc0000001 },
6814 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xc0000001 },
6817 static const struct message WmShiftVkN
[] = {
6818 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 1 }, /* XP */
6819 { WM_KEYDOWN
, wparam
|lparam
, VK_SHIFT
, 1 },
6820 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_SHIFT
, 1 },
6821 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 1 }, /* XP */
6822 { WM_KEYDOWN
, wparam
|lparam
, 'N', 1 },
6823 { WM_KEYDOWN
, sent
|wparam
|lparam
, 'N', 1 },
6824 { WM_CHAR
, wparam
|lparam
, 'N', 1 },
6825 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1001,1), 0 },
6826 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xc0000001 }, /* XP */
6827 { WM_KEYUP
, wparam
|lparam
, 'N', 0xc0000001 },
6828 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xc0000001 },
6829 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 0xc0000001 }, /* XP */
6830 { WM_KEYUP
, wparam
|lparam
, VK_SHIFT
, 0xc0000001 },
6831 { WM_KEYUP
, sent
|wparam
|lparam
, VK_SHIFT
, 0xc0000001 },
6834 static const struct message WmCtrlVkN
[] = {
6835 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 1 }, /* XP */
6836 { WM_KEYDOWN
, wparam
|lparam
, VK_CONTROL
, 1 },
6837 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_CONTROL
, 1 },
6838 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 1 }, /* XP */
6839 { WM_KEYDOWN
, wparam
|lparam
, 'N', 1 },
6840 { WM_KEYDOWN
, sent
|wparam
|lparam
, 'N', 1 },
6841 { WM_CHAR
, wparam
|lparam
, 0x000e, 1 },
6842 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1000,1), 0 },
6843 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xc0000001 }, /* XP */
6844 { WM_KEYUP
, wparam
|lparam
, 'N', 0xc0000001 },
6845 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xc0000001 },
6846 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 0xc0000001 }, /* XP */
6847 { WM_KEYUP
, wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
6848 { WM_KEYUP
, sent
|wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
6851 static const struct message WmCtrlVkN_2
[] = {
6852 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 1 }, /* XP */
6853 { WM_KEYDOWN
, wparam
|lparam
, VK_CONTROL
, 1 },
6854 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_CONTROL
, 1 },
6855 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 1 }, /* XP */
6856 { WM_KEYDOWN
, wparam
|lparam
, 'N', 1 },
6857 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1000,1), 0 },
6858 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xc0000001 }, /* XP */
6859 { WM_KEYUP
, wparam
|lparam
, 'N', 0xc0000001 },
6860 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xc0000001 },
6861 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 0xc0000001 }, /* XP */
6862 { WM_KEYUP
, wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
6863 { WM_KEYUP
, sent
|wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
6866 static const struct message WmAltVkN
[] = {
6867 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 }, /* XP */
6868 { WM_SYSKEYDOWN
, wparam
|lparam
, VK_MENU
, 0x20000001 },
6869 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
6870 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0x20000001 }, /* XP */
6871 { WM_SYSKEYDOWN
, wparam
|lparam
, 'N', 0x20000001 },
6872 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, 'N', 0x20000001 },
6873 { WM_SYSCHAR
, wparam
|lparam
, 'n', 0x20000001 },
6874 { WM_SYSCHAR
, sent
|wparam
|lparam
, 'n', 0x20000001 },
6875 { WM_SYSCOMMAND
, sent
|defwinproc
|wparam
|lparam
, SC_KEYMENU
, 'n' },
6876 { HCBT_SYSCOMMAND
, hook
},
6877 { WM_ENTERMENULOOP
, sent
|defwinproc
|wparam
|lparam
, 0, 0 },
6878 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
6879 { 0x00AE, sent
|defwinproc
|optional
}, /* XP */
6880 { WM_GETTEXT
, sent
|defwinproc
|optional
}, /* XP */
6881 { WM_INITMENU
, sent
|defwinproc
},
6882 { EVENT_SYSTEM_MENUSTART
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 0 },
6883 { WM_MENUCHAR
, sent
|defwinproc
|wparam
, MAKEWPARAM('n',MF_SYSMENU
) },
6884 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, 0, 0 },
6885 { WM_CAPTURECHANGED
, sent
|defwinproc
},
6886 { WM_MENUSELECT
, sent
|defwinproc
|wparam
, MAKEWPARAM(0,0xffff) },
6887 { EVENT_SYSTEM_MENUEND
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 0 },
6888 { WM_EXITMENULOOP
, sent
|defwinproc
},
6889 { WM_MENUSELECT
, sent
|defwinproc
|wparam
|optional
, MAKEWPARAM(0,0xffff) }, /* Win95 bug */
6890 { WM_EXITMENULOOP
, sent
|defwinproc
|optional
}, /* Win95 bug */
6891 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xe0000001 }, /* XP */
6892 { WM_SYSKEYUP
, wparam
|lparam
, 'N', 0xe0000001 },
6893 { WM_SYSKEYUP
, sent
|wparam
|lparam
, 'N', 0xe0000001 },
6894 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xc0000001 }, /* XP */
6895 { WM_KEYUP
, wparam
|lparam
, VK_MENU
, 0xc0000001 },
6896 { WM_KEYUP
, sent
|wparam
|lparam
, VK_MENU
, 0xc0000001 },
6899 static const struct message WmAltVkN_2
[] = {
6900 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 }, /* XP */
6901 { WM_SYSKEYDOWN
, wparam
|lparam
, VK_MENU
, 0x20000001 },
6902 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
6903 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0x20000001 }, /* XP */
6904 { WM_SYSKEYDOWN
, wparam
|lparam
, 'N', 0x20000001 },
6905 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1003,1), 0 },
6906 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xe0000001 }, /* XP */
6907 { WM_SYSKEYUP
, wparam
|lparam
, 'N', 0xe0000001 },
6908 { WM_SYSKEYUP
, sent
|wparam
|lparam
, 'N', 0xe0000001 },
6909 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xc0000001 }, /* XP */
6910 { WM_KEYUP
, wparam
|lparam
, VK_MENU
, 0xc0000001 },
6911 { WM_KEYUP
, sent
|wparam
|lparam
, VK_MENU
, 0xc0000001 },
6914 static const struct message WmCtrlAltVkN
[] = {
6915 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 1 }, /* XP */
6916 { WM_KEYDOWN
, wparam
|lparam
, VK_CONTROL
, 1 },
6917 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_CONTROL
, 1 },
6918 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 }, /* XP */
6919 { WM_KEYDOWN
, wparam
|lparam
, VK_MENU
, 0x20000001 },
6920 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
6921 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0x20000001 }, /* XP */
6922 { WM_KEYDOWN
, wparam
|lparam
, 'N', 0x20000001 },
6923 { WM_KEYDOWN
, sent
|wparam
|lparam
, 'N', 0x20000001 },
6924 { WM_CHAR
, optional
},
6925 { WM_CHAR
, sent
|optional
},
6926 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xe0000001 }, /* XP */
6927 { WM_KEYUP
, wparam
|lparam
, 'N', 0xe0000001 },
6928 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xe0000001 },
6929 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xc0000001 }, /* XP */
6930 { WM_KEYUP
, wparam
|lparam
, VK_MENU
, 0xc0000001 },
6931 { WM_KEYUP
, sent
|wparam
|lparam
, VK_MENU
, 0xc0000001 },
6932 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 0xc0000001 }, /* XP */
6933 { WM_KEYUP
, wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
6934 { WM_KEYUP
, sent
|wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
6937 static const struct message WmCtrlShiftVkN
[] = {
6938 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 1 }, /* XP */
6939 { WM_KEYDOWN
, wparam
|lparam
, VK_CONTROL
, 1 },
6940 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_CONTROL
, 1 },
6941 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 1 }, /* XP */
6942 { WM_KEYDOWN
, wparam
|lparam
, VK_SHIFT
, 1 },
6943 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_SHIFT
, 1 },
6944 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 1 }, /* XP */
6945 { WM_KEYDOWN
, wparam
|lparam
, 'N', 1 },
6946 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1004,1), 0 },
6947 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xc0000001 }, /* XP */
6948 { WM_KEYUP
, wparam
|lparam
, 'N', 0xc0000001 },
6949 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xc0000001 },
6950 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 0xc0000001 }, /* XP */
6951 { WM_KEYUP
, wparam
|lparam
, VK_SHIFT
, 0xc0000001 },
6952 { WM_KEYUP
, sent
|wparam
|lparam
, VK_SHIFT
, 0xc0000001 },
6953 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 0xc0000001 }, /* XP */
6954 { WM_KEYUP
, wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
6955 { WM_KEYUP
, sent
|wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
6958 static const struct message WmCtrlAltShiftVkN
[] = {
6959 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 1 }, /* XP */
6960 { WM_KEYDOWN
, wparam
|lparam
, VK_CONTROL
, 1 },
6961 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_CONTROL
, 1 },
6962 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 }, /* XP */
6963 { WM_KEYDOWN
, wparam
|lparam
, VK_MENU
, 0x20000001 },
6964 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
6965 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 0x20000001 }, /* XP */
6966 { WM_KEYDOWN
, wparam
|lparam
, VK_SHIFT
, 0x20000001 },
6967 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_SHIFT
, 0x20000001 },
6968 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0x20000001 }, /* XP */
6969 { WM_KEYDOWN
, wparam
|lparam
, 'N', 0x20000001 },
6970 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1005,1), 0 },
6971 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xe0000001 }, /* XP */
6972 { WM_KEYUP
, wparam
|lparam
, 'N', 0xe0000001 },
6973 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xe0000001 },
6974 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 0xe0000001 }, /* XP */
6975 { WM_KEYUP
, wparam
|lparam
, VK_SHIFT
, 0xe0000001 },
6976 { WM_KEYUP
, sent
|wparam
|lparam
, VK_SHIFT
, 0xe0000001 },
6977 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xc0000001 }, /* XP */
6978 { WM_KEYUP
, wparam
|lparam
, VK_MENU
, 0xc0000001 },
6979 { WM_KEYUP
, sent
|wparam
|lparam
, VK_MENU
, 0xc0000001 },
6980 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 0xc0000001 }, /* XP */
6981 { WM_KEYUP
, wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
6982 { WM_KEYUP
, sent
|wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
6985 static const struct message WmAltPressRelease
[] = {
6986 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 }, /* XP */
6987 { WM_SYSKEYDOWN
, wparam
|lparam
, VK_MENU
, 0x20000001 },
6988 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
6989 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xc0000001 }, /* XP */
6990 { WM_SYSKEYUP
, wparam
|lparam
, VK_MENU
, 0xc0000001 },
6991 { WM_SYSKEYUP
, sent
|wparam
|lparam
, VK_MENU
, 0xc0000001 },
6992 { WM_SYSCOMMAND
, sent
|defwinproc
|wparam
|lparam
, SC_KEYMENU
, 0 },
6993 { HCBT_SYSCOMMAND
, hook
},
6994 { WM_ENTERMENULOOP
, sent
|defwinproc
|wparam
|lparam
, 0, 0 },
6995 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
6996 { WM_INITMENU
, sent
|defwinproc
},
6997 { EVENT_SYSTEM_MENUSTART
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 0 },
6998 { WM_MENUSELECT
, sent
|defwinproc
|wparam
, MAKEWPARAM(0,MF_SYSMENU
|MF_POPUP
|MF_HILITE
) },
6999 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 1 },
7001 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x30000001 }, /* XP */
7003 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 0 },
7004 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, 0, 0, },
7005 { WM_CAPTURECHANGED
, sent
|defwinproc
},
7006 { WM_MENUSELECT
, sent
|defwinproc
|wparam
|optional
, MAKEWPARAM(0,0xffff) },
7007 { EVENT_SYSTEM_MENUEND
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 0 },
7008 { WM_EXITMENULOOP
, sent
|defwinproc
},
7009 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xc0000001 }, /* XP */
7010 { WM_SYSKEYUP
, wparam
|lparam
, VK_MENU
, 0xc0000001 },
7011 { WM_SYSKEYUP
, sent
|wparam
|lparam
, VK_MENU
, 0xc0000001 },
7014 static const struct message WmShiftMouseButton
[] = {
7015 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 1 }, /* XP */
7016 { WM_KEYDOWN
, wparam
|lparam
, VK_SHIFT
, 1 },
7017 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_SHIFT
, 1 },
7018 { WM_MOUSEMOVE
, wparam
|optional
, 0, 0 },
7019 { WM_MOUSEMOVE
, sent
|wparam
|optional
, 0, 0 },
7020 { WM_LBUTTONDOWN
, wparam
, MK_LBUTTON
|MK_SHIFT
, 0 },
7021 { WM_LBUTTONDOWN
, sent
|wparam
, MK_LBUTTON
|MK_SHIFT
, 0 },
7022 { WM_LBUTTONUP
, wparam
, MK_SHIFT
, 0 },
7023 { WM_LBUTTONUP
, sent
|wparam
, MK_SHIFT
, 0 },
7024 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 0xc0000001 }, /* XP */
7025 { WM_KEYUP
, wparam
|lparam
, VK_SHIFT
, 0xc0000001 },
7026 { WM_KEYUP
, sent
|wparam
|lparam
, VK_SHIFT
, 0xc0000001 },
7029 static const struct message WmF1Seq
[] = {
7030 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_F1
, 1 }, /* XP */
7031 { WM_KEYDOWN
, wparam
|lparam
, VK_F1
, 1 },
7032 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_F1
, 0x00000001 },
7033 { WM_KEYF1
, wparam
|lparam
, 0, 0 },
7034 { WM_KEYF1
, sent
|wparam
|lparam
, 0, 0 },
7035 { WM_HELP
, sent
|defwinproc
},
7036 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_F1
, 0xc0000001 }, /* XP */
7037 { WM_KEYUP
, wparam
|lparam
, VK_F1
, 0xc0000001 },
7038 { WM_KEYUP
, sent
|wparam
|lparam
, VK_F1
, 0xc0000001 },
7041 static const struct message WmVkAppsSeq
[] = {
7042 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_APPS
, 1 }, /* XP */
7043 { WM_KEYDOWN
, wparam
|lparam
, VK_APPS
, 1 },
7044 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_APPS
, 0x00000001 },
7045 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_APPS
, 0xc0000001 }, /* XP */
7046 { WM_KEYUP
, wparam
|lparam
, VK_APPS
, 0xc0000001 },
7047 { WM_KEYUP
, sent
|wparam
|lparam
, VK_APPS
, 0xc0000001 },
7048 { WM_CONTEXTMENU
, lparam
, /*hwnd*/0, -1 },
7049 { WM_CONTEXTMENU
, sent
|lparam
, /*hwnd*/0, -1 },
7052 static const struct message WmVkF10Seq
[] = {
7053 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_F10
, 1 }, /* XP */
7054 { WM_SYSKEYDOWN
, wparam
|lparam
, VK_F10
, 1 },
7055 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, VK_F10
, 0x00000001 },
7056 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_F10
, 0xc0000001 }, /* XP */
7057 { WM_SYSKEYUP
, wparam
|lparam
, VK_F10
, 0xc0000001 },
7058 { WM_SYSKEYUP
, sent
|wparam
|lparam
, VK_F10
, 0xc0000001 },
7059 { WM_SYSCOMMAND
, sent
|defwinproc
|wparam
, SC_KEYMENU
},
7060 { HCBT_SYSCOMMAND
, hook
},
7061 { WM_ENTERMENULOOP
, sent
|defwinproc
|wparam
|lparam
, 0, 0 },
7062 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
7063 { WM_INITMENU
, sent
|defwinproc
},
7064 { EVENT_SYSTEM_MENUSTART
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 0 },
7065 { WM_MENUSELECT
, sent
|defwinproc
|wparam
, MAKEWPARAM(0,MF_SYSMENU
|MF_POPUP
|MF_HILITE
) },
7066 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 1 },
7068 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_F10
, 0x10000001 }, /* XP */
7070 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_F10
, 1 }, /* XP */
7071 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 0 },
7072 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, 0, 0, },
7073 { WM_CAPTURECHANGED
, sent
|defwinproc
},
7074 { WM_MENUSELECT
, sent
|defwinproc
|wparam
|optional
, MAKEWPARAM(0,0xffff) },
7075 { EVENT_SYSTEM_MENUEND
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 0 },
7076 { WM_EXITMENULOOP
, sent
|defwinproc
},
7077 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_F10
, 0xc0000001 }, /* XP */
7078 { WM_SYSKEYUP
, wparam
|lparam
, VK_F10
, 0xc0000001 },
7079 { WM_SYSKEYUP
, sent
|wparam
|lparam
, VK_F10
, 0xc0000001 },
7082 static const struct message WmShiftF10Seq
[] = {
7083 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 1 }, /* XP */
7084 { WM_KEYDOWN
, wparam
|lparam
, VK_SHIFT
, 1 },
7085 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_SHIFT
, 0x00000001 },
7086 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_F10
, 1 }, /* XP */
7087 { WM_SYSKEYDOWN
, wparam
|lparam
, VK_F10
, 1 },
7088 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, VK_F10
, 0x00000001 },
7089 { WM_CONTEXTMENU
, sent
|defwinproc
|lparam
, /*hwnd*/0, -1 },
7090 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_F10
, 0xc0000001 }, /* XP */
7091 { WM_SYSKEYUP
, wparam
|lparam
, VK_F10
, 0xc0000001 },
7092 { WM_SYSKEYUP
, sent
|wparam
|lparam
, VK_F10
, 0xc0000001 },
7093 { WM_SYSCOMMAND
, sent
|defwinproc
|wparam
, SC_KEYMENU
},
7094 { HCBT_SYSCOMMAND
, hook
},
7095 { WM_ENTERMENULOOP
, sent
|defwinproc
|wparam
|lparam
, 0, 0 },
7096 { WM_INITMENU
, sent
|defwinproc
},
7097 { WM_MENUSELECT
, sent
|defwinproc
|wparam
, MAKEWPARAM(0,MF_SYSMENU
|MF_POPUP
|MF_HILITE
) },
7098 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 0xd0000001 }, /* XP */
7099 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_ESCAPE
, 0x10000001 }, /* XP */
7100 { WM_CAPTURECHANGED
, sent
|defwinproc
|wparam
|lparam
, 0, 0 },
7101 { WM_MENUSELECT
, sent
|defwinproc
|wparam
|lparam
, 0xffff0000, 0 },
7102 { WM_EXITMENULOOP
, sent
|defwinproc
|wparam
|lparam
, 0, 0 },
7103 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_ESCAPE
, 0xc0000001 }, /* XP */
7104 { WM_KEYUP
, wparam
|lparam
, VK_ESCAPE
, 0xc0000001 },
7105 { WM_KEYUP
, sent
|wparam
|lparam
, VK_ESCAPE
, 0xc0000001 },
7109 static void pump_msg_loop(HWND hwnd
, HACCEL hAccel
)
7113 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
))
7115 struct recvd_message log_msg
;
7117 /* ignore some unwanted messages */
7118 if (msg
.message
== WM_MOUSEMOVE
||
7119 msg
.message
== WM_TIMER
||
7120 ignore_message( msg
.message
))
7123 log_msg
.hwnd
= msg
.hwnd
;
7124 log_msg
.message
= msg
.message
;
7125 log_msg
.flags
= wparam
|lparam
;
7126 log_msg
.wParam
= msg
.wParam
;
7127 log_msg
.lParam
= msg
.lParam
;
7128 log_msg
.descr
= "accel";
7129 add_message(&log_msg
);
7131 if (!hAccel
|| !TranslateAccelerator(hwnd
, hAccel
, &msg
))
7133 TranslateMessage(&msg
);
7134 DispatchMessage(&msg
);
7139 static void test_accelerators(void)
7145 HWND hwnd
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
7146 100, 100, 200, 200, 0, 0, 0, NULL
);
7155 ok(GetFocus() == hwnd
, "wrong focus window %p\n", GetFocus());
7157 state
= GetKeyState(VK_SHIFT
);
7158 ok(!(state
& 0x8000), "wrong Shift state %04x\n", state
);
7159 state
= GetKeyState(VK_CAPITAL
);
7160 ok(state
== 0, "wrong CapsLock state %04x\n", state
);
7162 hAccel
= LoadAccelerators(GetModuleHandleA(0), MAKEINTRESOURCE(1));
7163 assert(hAccel
!= 0);
7166 pump_msg_loop(hwnd
, 0);
7169 trace("testing VK_N press/release\n");
7171 keybd_event('N', 0, 0, 0);
7172 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
7173 pump_msg_loop(hwnd
, hAccel
);
7174 if (!sequence_cnt
) /* we didn't get any message */
7176 skip( "queuing key events not supported\n" );
7179 ok_sequence(WmVkN
, "VK_N press/release", FALSE
);
7181 trace("testing Shift+VK_N press/release\n");
7183 keybd_event(VK_SHIFT
, 0, 0, 0);
7184 keybd_event('N', 0, 0, 0);
7185 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
7186 keybd_event(VK_SHIFT
, 0, KEYEVENTF_KEYUP
, 0);
7187 pump_msg_loop(hwnd
, hAccel
);
7188 ok_sequence(WmShiftVkN
, "Shift+VK_N press/release", FALSE
);
7190 trace("testing Ctrl+VK_N press/release\n");
7192 keybd_event(VK_CONTROL
, 0, 0, 0);
7193 keybd_event('N', 0, 0, 0);
7194 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
7195 keybd_event(VK_CONTROL
, 0, KEYEVENTF_KEYUP
, 0);
7196 pump_msg_loop(hwnd
, hAccel
);
7197 ok_sequence(WmCtrlVkN
, "Ctrl+VK_N press/release", FALSE
);
7199 trace("testing Alt+VK_N press/release\n");
7201 keybd_event(VK_MENU
, 0, 0, 0);
7202 keybd_event('N', 0, 0, 0);
7203 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
7204 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
7205 pump_msg_loop(hwnd
, hAccel
);
7206 ok_sequence(WmAltVkN
, "Alt+VK_N press/release", FALSE
);
7208 trace("testing Ctrl+Alt+VK_N press/release 1\n");
7210 keybd_event(VK_CONTROL
, 0, 0, 0);
7211 keybd_event(VK_MENU
, 0, 0, 0);
7212 keybd_event('N', 0, 0, 0);
7213 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
7214 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
7215 keybd_event(VK_CONTROL
, 0, KEYEVENTF_KEYUP
, 0);
7216 pump_msg_loop(hwnd
, hAccel
);
7217 ok_sequence(WmCtrlAltVkN
, "Ctrl+Alt+VK_N press/release 1", FALSE
);
7219 ret
= DestroyAcceleratorTable(hAccel
);
7220 ok( ret
, "DestroyAcceleratorTable error %d\n", GetLastError());
7222 hAccel
= LoadAccelerators(GetModuleHandleA(0), MAKEINTRESOURCE(2));
7223 assert(hAccel
!= 0);
7225 trace("testing VK_N press/release\n");
7227 keybd_event('N', 0, 0, 0);
7228 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
7229 pump_msg_loop(hwnd
, hAccel
);
7230 ok_sequence(WmVkN
, "VK_N press/release", FALSE
);
7232 trace("testing Shift+VK_N press/release\n");
7234 keybd_event(VK_SHIFT
, 0, 0, 0);
7235 keybd_event('N', 0, 0, 0);
7236 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
7237 keybd_event(VK_SHIFT
, 0, KEYEVENTF_KEYUP
, 0);
7238 pump_msg_loop(hwnd
, hAccel
);
7239 ok_sequence(WmShiftVkN
, "Shift+VK_N press/release", FALSE
);
7241 trace("testing Ctrl+VK_N press/release 2\n");
7243 keybd_event(VK_CONTROL
, 0, 0, 0);
7244 keybd_event('N', 0, 0, 0);
7245 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
7246 keybd_event(VK_CONTROL
, 0, KEYEVENTF_KEYUP
, 0);
7247 pump_msg_loop(hwnd
, hAccel
);
7248 ok_sequence(WmCtrlVkN_2
, "Ctrl+VK_N press/release 2", FALSE
);
7250 trace("testing Alt+VK_N press/release 2\n");
7252 keybd_event(VK_MENU
, 0, 0, 0);
7253 keybd_event('N', 0, 0, 0);
7254 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
7255 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
7256 pump_msg_loop(hwnd
, hAccel
);
7257 ok_sequence(WmAltVkN_2
, "Alt+VK_N press/release 2", FALSE
);
7259 trace("testing Ctrl+Alt+VK_N press/release 2\n");
7261 keybd_event(VK_CONTROL
, 0, 0, 0);
7262 keybd_event(VK_MENU
, 0, 0, 0);
7263 keybd_event('N', 0, 0, 0);
7264 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
7265 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
7266 keybd_event(VK_CONTROL
, 0, KEYEVENTF_KEYUP
, 0);
7267 pump_msg_loop(hwnd
, hAccel
);
7268 ok_sequence(WmCtrlAltVkN
, "Ctrl+Alt+VK_N press/release 2", FALSE
);
7270 trace("testing Ctrl+Shift+VK_N press/release\n");
7272 keybd_event(VK_CONTROL
, 0, 0, 0);
7273 keybd_event(VK_SHIFT
, 0, 0, 0);
7274 keybd_event('N', 0, 0, 0);
7275 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
7276 keybd_event(VK_SHIFT
, 0, KEYEVENTF_KEYUP
, 0);
7277 keybd_event(VK_CONTROL
, 0, KEYEVENTF_KEYUP
, 0);
7278 pump_msg_loop(hwnd
, hAccel
);
7279 ok_sequence(WmCtrlShiftVkN
, "Ctrl+Shift+VK_N press/release", FALSE
);
7281 trace("testing Ctrl+Alt+Shift+VK_N press/release\n");
7283 keybd_event(VK_CONTROL
, 0, 0, 0);
7284 keybd_event(VK_MENU
, 0, 0, 0);
7285 keybd_event(VK_SHIFT
, 0, 0, 0);
7286 keybd_event('N', 0, 0, 0);
7287 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
7288 keybd_event(VK_SHIFT
, 0, KEYEVENTF_KEYUP
, 0);
7289 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
7290 keybd_event(VK_CONTROL
, 0, KEYEVENTF_KEYUP
, 0);
7291 pump_msg_loop(hwnd
, hAccel
);
7292 ok_sequence(WmCtrlAltShiftVkN
, "Ctrl+Alt+Shift+VK_N press/release", FALSE
);
7294 ret
= DestroyAcceleratorTable(hAccel
);
7295 ok( ret
, "DestroyAcceleratorTable error %d\n", GetLastError());
7298 trace("testing Alt press/release\n");
7300 keybd_event(VK_MENU
, 0, 0, 0);
7301 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
7302 keybd_event(VK_MENU
, 0, 0, 0);
7303 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
7304 pump_msg_loop(hwnd
, 0);
7305 /* this test doesn't pass in Wine for managed windows */
7306 ok_sequence(WmAltPressRelease
, "Alt press/release", TRUE
);
7308 trace("testing VK_F1 press/release\n");
7309 keybd_event(VK_F1
, 0, 0, 0);
7310 keybd_event(VK_F1
, 0, KEYEVENTF_KEYUP
, 0);
7311 pump_msg_loop(hwnd
, 0);
7312 ok_sequence(WmF1Seq
, "F1 press/release", FALSE
);
7314 trace("testing VK_APPS press/release\n");
7315 keybd_event(VK_APPS
, 0, 0, 0);
7316 keybd_event(VK_APPS
, 0, KEYEVENTF_KEYUP
, 0);
7317 pump_msg_loop(hwnd
, 0);
7318 ok_sequence(WmVkAppsSeq
, "VK_APPS press/release", FALSE
);
7320 trace("testing VK_F10 press/release\n");
7321 keybd_event(VK_F10
, 0, 0, 0);
7322 keybd_event(VK_F10
, 0, KEYEVENTF_KEYUP
, 0);
7323 keybd_event(VK_F10
, 0, 0, 0);
7324 keybd_event(VK_F10
, 0, KEYEVENTF_KEYUP
, 0);
7325 pump_msg_loop(hwnd
, 0);
7326 ok_sequence(WmVkF10Seq
, "VK_F10 press/release", TRUE
);
7328 trace("testing SHIFT+F10 press/release\n");
7329 keybd_event(VK_SHIFT
, 0, 0, 0);
7330 keybd_event(VK_F10
, 0, 0, 0);
7331 keybd_event(VK_F10
, 0, KEYEVENTF_KEYUP
, 0);
7332 keybd_event(VK_SHIFT
, 0, KEYEVENTF_KEYUP
, 0);
7333 keybd_event(VK_ESCAPE
, 0, 0, 0);
7334 keybd_event(VK_ESCAPE
, 0, KEYEVENTF_KEYUP
, 0);
7335 pump_msg_loop(hwnd
, 0);
7336 ok_sequence(WmShiftF10Seq
, "SHIFT+F10 press/release", TRUE
);
7338 trace("testing Shift+MouseButton press/release\n");
7339 /* first, move mouse pointer inside of the window client area */
7340 GetClientRect(hwnd
, &rc
);
7341 MapWindowPoints(hwnd
, 0, (LPPOINT
)&rc
, 2);
7342 rc
.left
+= (rc
.right
- rc
.left
)/2;
7343 rc
.top
+= (rc
.bottom
- rc
.top
)/2;
7344 SetCursorPos(rc
.left
, rc
.top
);
7345 SetActiveWindow(hwnd
);
7350 if (pt
.x
== rc
.left
&& pt
.y
== rc
.top
)
7353 keybd_event(VK_SHIFT
, 0, 0, 0);
7354 mouse_event(MOUSEEVENTF_LEFTDOWN
, 0, 0, 0, 0);
7355 mouse_event(MOUSEEVENTF_LEFTUP
, 0, 0, 0, 0);
7356 keybd_event(VK_SHIFT
, 0, KEYEVENTF_KEYUP
, 0);
7357 pump_msg_loop(hwnd
, 0);
7358 for (i
= 0; i
< sequence_cnt
; i
++) if (sequence
[i
].message
== WM_LBUTTONDOWN
) break;
7359 if (i
< sequence_cnt
)
7360 ok_sequence(WmShiftMouseButton
, "Shift+MouseButton press/release", FALSE
);
7362 skip( "Shift+MouseButton event didn't get to the window\n" );
7366 if (hAccel
) DestroyAcceleratorTable(hAccel
);
7367 DestroyWindow(hwnd
);
7370 /************* window procedures ********************/
7372 static LRESULT
MsgCheckProc (BOOL unicode
, HWND hwnd
, UINT message
,
7373 WPARAM wParam
, LPARAM lParam
)
7375 static LONG defwndproc_counter
= 0;
7376 static LONG beginpaint_counter
= 0;
7378 struct recvd_message msg
;
7380 if (ignore_message( message
)) return 0;
7386 LONG style
= GetWindowLongA(hwnd
, GWL_STYLE
);
7387 ok((BOOL
)wParam
== !(style
& WS_DISABLED
),
7388 "wrong WS_DISABLED state: %ld != %d\n", wParam
, !(style
& WS_DISABLED
));
7392 case WM_CAPTURECHANGED
:
7393 if (test_DestroyWindow_flag
)
7395 DWORD style
= GetWindowLongA(hwnd
, GWL_STYLE
);
7396 if (style
& WS_CHILD
)
7397 lParam
= GetWindowLongPtrA(hwnd
, GWLP_ID
);
7398 else if (style
& WS_POPUP
)
7399 lParam
= WND_POPUP_ID
;
7401 lParam
= WND_PARENT_ID
;
7409 ok(!GetWindow(hwnd
, GW_CHILD
), "children should be unlinked at this point\n");
7410 capture
= GetCapture();
7413 ok(capture
== hwnd
, "capture should NOT be released at this point (capture %p)\n", capture
);
7414 trace("current capture %p, releasing...\n", capture
);
7421 ok(pGetAncestor(hwnd
, GA_PARENT
) != 0, "parent should NOT be unlinked at this point\n");
7422 if (test_DestroyWindow_flag
)
7424 DWORD style
= GetWindowLongA(hwnd
, GWL_STYLE
);
7425 if (style
& WS_CHILD
)
7426 lParam
= GetWindowLongPtrA(hwnd
, GWLP_ID
);
7427 else if (style
& WS_POPUP
)
7428 lParam
= WND_POPUP_ID
;
7430 lParam
= WND_PARENT_ID
;
7434 /* test_accelerators() depends on this */
7440 case WM_MOUSEACTIVATE
:
7441 case WM_NCMOUSEMOVE
:
7448 msg
.message
= message
;
7449 msg
.flags
= sent
|wparam
|lparam
;
7450 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
7451 if (beginpaint_counter
) msg
.flags
|= beginpaint
;
7452 msg
.wParam
= wParam
;
7453 msg
.lParam
= lParam
;
7454 msg
.descr
= "MsgCheckProc";
7457 if (message
== WM_GETMINMAXINFO
&& (GetWindowLongA(hwnd
, GWL_STYLE
) & WS_CHILD
))
7459 HWND parent
= GetParent(hwnd
);
7461 MINMAXINFO
*minmax
= (MINMAXINFO
*)lParam
;
7463 GetClientRect(parent
, &rc
);
7464 trace("parent %p client size = (%d x %d)\n", parent
, rc
.right
, rc
.bottom
);
7465 trace("Reserved=%d,%d MaxSize=%d,%d MaxPos=%d,%d MinTrack=%d,%d MaxTrack=%d,%d\n",
7466 minmax
->ptReserved
.x
, minmax
->ptReserved
.y
,
7467 minmax
->ptMaxSize
.x
, minmax
->ptMaxSize
.y
,
7468 minmax
->ptMaxPosition
.x
, minmax
->ptMaxPosition
.y
,
7469 minmax
->ptMinTrackSize
.x
, minmax
->ptMinTrackSize
.y
,
7470 minmax
->ptMaxTrackSize
.x
, minmax
->ptMaxTrackSize
.y
);
7472 ok(minmax
->ptMaxSize
.x
== rc
.right
, "default width of maximized child %d != %d\n",
7473 minmax
->ptMaxSize
.x
, rc
.right
);
7474 ok(minmax
->ptMaxSize
.y
== rc
.bottom
, "default height of maximized child %d != %d\n",
7475 minmax
->ptMaxSize
.y
, rc
.bottom
);
7478 if (message
== WM_PAINT
)
7481 beginpaint_counter
++;
7482 BeginPaint( hwnd
, &ps
);
7483 beginpaint_counter
--;
7484 EndPaint( hwnd
, &ps
);
7488 defwndproc_counter
++;
7489 ret
= unicode
? DefWindowProcW(hwnd
, message
, wParam
, lParam
)
7490 : DefWindowProcA(hwnd
, message
, wParam
, lParam
);
7491 defwndproc_counter
--;
7496 static LRESULT WINAPI
MsgCheckProcA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
7498 return MsgCheckProc (FALSE
, hwnd
, message
, wParam
, lParam
);
7501 static LRESULT WINAPI
MsgCheckProcW(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
7503 return MsgCheckProc (TRUE
, hwnd
, message
, wParam
, lParam
);
7506 static LRESULT WINAPI
PopupMsgCheckProcA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
7508 static LONG defwndproc_counter
= 0;
7510 struct recvd_message msg
;
7512 if (ignore_message( message
)) return 0;
7516 case WM_QUERYENDSESSION
:
7518 lParam
&= ~0x01; /* Vista adds a 0x01 flag */
7523 msg
.message
= message
;
7524 msg
.flags
= sent
|wparam
|lparam
;
7525 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
7526 msg
.wParam
= wParam
;
7527 msg
.lParam
= lParam
;
7528 msg
.descr
= "popup";
7531 if (message
== WM_CREATE
)
7533 DWORD style
= GetWindowLongA(hwnd
, GWL_STYLE
) | WS_VISIBLE
;
7534 SetWindowLongA(hwnd
, GWL_STYLE
, style
);
7537 defwndproc_counter
++;
7538 ret
= DefWindowProcA(hwnd
, message
, wParam
, lParam
);
7539 defwndproc_counter
--;
7544 static LRESULT WINAPI
ParentMsgCheckProcA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
7546 static LONG defwndproc_counter
= 0;
7547 static LONG beginpaint_counter
= 0;
7549 struct recvd_message msg
;
7551 if (ignore_message( message
)) return 0;
7553 if (log_all_parent_messages
||
7554 message
== WM_PARENTNOTIFY
|| message
== WM_CANCELMODE
||
7555 message
== WM_SETFOCUS
|| message
== WM_KILLFOCUS
||
7556 message
== WM_ENABLE
|| message
== WM_ENTERIDLE
||
7557 message
== WM_DRAWITEM
|| message
== WM_COMMAND
||
7558 message
== WM_IME_SETCONTEXT
)
7567 case WM_NCMOUSEMOVE
:
7573 INT ret
= GetClipBox((HDC
)wParam
, &rc
);
7575 trace("WM_ERASEBKGND: GetClipBox()=%d, (%d,%d-%d,%d)\n",
7576 ret
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
7582 msg
.message
= message
;
7583 msg
.flags
= sent
|parent
|wparam
|lparam
;
7584 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
7585 if (beginpaint_counter
) msg
.flags
|= beginpaint
;
7586 msg
.wParam
= wParam
;
7587 msg
.lParam
= lParam
;
7588 msg
.descr
= "parent";
7592 if (message
== WM_PAINT
)
7595 beginpaint_counter
++;
7596 BeginPaint( hwnd
, &ps
);
7597 beginpaint_counter
--;
7598 EndPaint( hwnd
, &ps
);
7602 defwndproc_counter
++;
7603 ret
= DefWindowProcA(hwnd
, message
, wParam
, lParam
);
7604 defwndproc_counter
--;
7609 static LRESULT WINAPI
TestDlgProcA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
7611 static LONG defwndproc_counter
= 0;
7613 struct recvd_message msg
;
7615 if (ignore_message( message
)) return 0;
7619 DefDlgProcA(hwnd
, DM_SETDEFID
, 1, 0);
7620 ret
= DefDlgProcA(hwnd
, DM_GETDEFID
, 0, 0);
7621 if (after_end_dialog
)
7622 ok( ret
== 0, "DM_GETDEFID should return 0 after EndDialog, got %lx\n", ret
);
7624 ok(HIWORD(ret
) == DC_HASDEFID
, "DM_GETDEFID should return DC_HASDEFID, got %lx\n", ret
);
7628 msg
.message
= message
;
7629 msg
.flags
= sent
|wparam
|lparam
;
7630 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
7631 msg
.wParam
= wParam
;
7632 msg
.lParam
= lParam
;
7633 msg
.descr
= "dialog";
7636 defwndproc_counter
++;
7637 ret
= DefDlgProcA(hwnd
, message
, wParam
, lParam
);
7638 defwndproc_counter
--;
7643 static LRESULT WINAPI
ShowWindowProcA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
7645 static LONG defwndproc_counter
= 0;
7647 struct recvd_message msg
;
7649 /* log only specific messages we are interested in */
7652 #if 0 /* probably log these as well */
7660 case WM_GETMINMAXINFO
:
7661 case WM_WINDOWPOSCHANGING
:
7662 case WM_WINDOWPOSCHANGED
:
7665 default: /* ignore */
7666 /*trace("showwindow: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);*/
7667 return DefWindowProcA(hwnd
, message
, wParam
, lParam
);
7671 msg
.message
= message
;
7672 msg
.flags
= sent
|wparam
|lparam
;
7673 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
7674 msg
.wParam
= wParam
;
7675 msg
.lParam
= lParam
;
7679 defwndproc_counter
++;
7680 ret
= DefWindowProcA(hwnd
, message
, wParam
, lParam
);
7681 defwndproc_counter
--;
7686 static LRESULT WINAPI
PaintLoopProcA(HWND hWnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
7690 case WM_CREATE
: return 0;
7699 if (PeekMessageA(&msg2
, 0, 0, 0, 1))
7701 TranslateMessage(&msg2
);
7702 DispatchMessage(&msg2
);
7706 else ok(broken(1), "infinite loop\n");
7708 paint_loop_done
= 1;
7709 return DefWindowProcA(hWnd
,msg
,wParam
,lParam
);
7712 return DefWindowProcA(hWnd
,msg
,wParam
,lParam
);
7715 static LRESULT WINAPI
HotkeyMsgCheckProcA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
7717 static LONG defwndproc_counter
= 0;
7719 struct recvd_message msg
;
7721 if (ignore_message( message
)) return 0;
7723 if ((message
>= WM_KEYFIRST
&& message
<= WM_KEYLAST
) ||
7724 message
== WM_HOTKEY
|| message
>= WM_APP
)
7727 msg
.message
= message
;
7728 msg
.flags
= sent
|wparam
|lparam
;
7729 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
7730 msg
.wParam
= wParam
;
7731 msg
.lParam
= lParam
;
7732 msg
.descr
= "HotkeyMsgCheckProcA";
7736 defwndproc_counter
++;
7737 ret
= DefWindowProcA(hwnd
, message
, wParam
, lParam
);
7738 defwndproc_counter
--;
7740 if (message
== WM_APP
)
7741 PostMessageA(hwnd
, WM_APP
+1, 0, 0);
7746 static BOOL
RegisterWindowClasses(void)
7752 cls
.lpfnWndProc
= MsgCheckProcA
;
7755 cls
.hInstance
= GetModuleHandleA(0);
7757 cls
.hCursor
= LoadCursorA(0, IDC_ARROW
);
7758 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
7759 cls
.lpszMenuName
= NULL
;
7760 cls
.lpszClassName
= "TestWindowClass";
7761 if(!RegisterClassA(&cls
)) return FALSE
;
7763 cls
.lpfnWndProc
= HotkeyMsgCheckProcA
;
7764 cls
.lpszClassName
= "HotkeyWindowClass";
7765 if(!RegisterClassA(&cls
)) return FALSE
;
7767 cls
.lpfnWndProc
= ShowWindowProcA
;
7768 cls
.lpszClassName
= "ShowWindowClass";
7769 if(!RegisterClassA(&cls
)) return FALSE
;
7771 cls
.lpfnWndProc
= PopupMsgCheckProcA
;
7772 cls
.lpszClassName
= "TestPopupClass";
7773 if(!RegisterClassA(&cls
)) return FALSE
;
7775 cls
.lpfnWndProc
= ParentMsgCheckProcA
;
7776 cls
.lpszClassName
= "TestParentClass";
7777 if(!RegisterClassA(&cls
)) return FALSE
;
7779 cls
.lpfnWndProc
= DefWindowProcA
;
7780 cls
.lpszClassName
= "SimpleWindowClass";
7781 if(!RegisterClassA(&cls
)) return FALSE
;
7783 cls
.lpfnWndProc
= PaintLoopProcA
;
7784 cls
.lpszClassName
= "PaintLoopWindowClass";
7785 if(!RegisterClassA(&cls
)) return FALSE
;
7787 cls
.style
= CS_NOCLOSE
;
7788 cls
.lpszClassName
= "NoCloseWindowClass";
7789 if(!RegisterClassA(&cls
)) return FALSE
;
7791 ok(GetClassInfoA(0, "#32770", &cls
), "GetClassInfo failed\n");
7793 cls
.hInstance
= GetModuleHandleA(0);
7794 cls
.hbrBackground
= 0;
7795 cls
.lpfnWndProc
= TestDlgProcA
;
7796 cls
.lpszClassName
= "TestDialogClass";
7797 if(!RegisterClassA(&cls
)) return FALSE
;
7800 clsW
.lpfnWndProc
= MsgCheckProcW
;
7801 clsW
.cbClsExtra
= 0;
7802 clsW
.cbWndExtra
= 0;
7803 clsW
.hInstance
= GetModuleHandleW(0);
7805 clsW
.hCursor
= LoadCursorW(0, (LPWSTR
)IDC_ARROW
);
7806 clsW
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
7807 clsW
.lpszMenuName
= NULL
;
7808 clsW
.lpszClassName
= testWindowClassW
;
7809 RegisterClassW(&clsW
); /* ignore error, this fails on Win9x */
7814 static BOOL
is_our_logged_class(HWND hwnd
)
7818 if (GetClassNameA(hwnd
, buf
, sizeof(buf
)))
7820 if (!lstrcmpiA(buf
, "TestWindowClass") ||
7821 !lstrcmpiA(buf
, "ShowWindowClass") ||
7822 !lstrcmpiA(buf
, "TestParentClass") ||
7823 !lstrcmpiA(buf
, "TestPopupClass") ||
7824 !lstrcmpiA(buf
, "SimpleWindowClass") ||
7825 !lstrcmpiA(buf
, "TestDialogClass") ||
7826 !lstrcmpiA(buf
, "MDI_frame_class") ||
7827 !lstrcmpiA(buf
, "MDI_client_class") ||
7828 !lstrcmpiA(buf
, "MDI_child_class") ||
7829 !lstrcmpiA(buf
, "my_button_class") ||
7830 !lstrcmpiA(buf
, "my_edit_class") ||
7831 !lstrcmpiA(buf
, "static") ||
7832 !lstrcmpiA(buf
, "ListBox") ||
7833 !lstrcmpiA(buf
, "ComboBox") ||
7834 !lstrcmpiA(buf
, "MyDialogClass") ||
7835 !lstrcmpiA(buf
, "#32770") ||
7836 !lstrcmpiA(buf
, "#32768"))
7842 static LRESULT CALLBACK
cbt_hook_proc(int nCode
, WPARAM wParam
, LPARAM lParam
)
7846 ok(cbt_hook_thread_id
== GetCurrentThreadId(), "we didn't ask for events from other threads\n");
7848 if (nCode
== HCBT_CLICKSKIPPED
)
7850 /* ignore this event, XP sends it a lot when switching focus between windows */
7851 return CallNextHookEx(hCBT_hook
, nCode
, wParam
, lParam
);
7854 if (nCode
== HCBT_SYSCOMMAND
|| nCode
== HCBT_KEYSKIPPED
)
7856 struct recvd_message msg
;
7859 msg
.message
= nCode
;
7860 msg
.flags
= hook
|wparam
|lparam
;
7861 msg
.wParam
= wParam
;
7862 msg
.lParam
= lParam
;
7866 return CallNextHookEx(hCBT_hook
, nCode
, wParam
, lParam
);
7869 if (nCode
== HCBT_DESTROYWND
)
7871 if (test_DestroyWindow_flag
)
7873 DWORD style
= GetWindowLongA((HWND
)wParam
, GWL_STYLE
);
7874 if (style
& WS_CHILD
)
7875 lParam
= GetWindowLongPtrA((HWND
)wParam
, GWLP_ID
);
7876 else if (style
& WS_POPUP
)
7877 lParam
= WND_POPUP_ID
;
7879 lParam
= WND_PARENT_ID
;
7883 /* Log also SetFocus(0) calls */
7884 hwnd
= wParam
? (HWND
)wParam
: (HWND
)lParam
;
7886 if (is_our_logged_class(hwnd
))
7888 struct recvd_message msg
;
7891 msg
.message
= nCode
;
7892 msg
.flags
= hook
|wparam
|lparam
;
7893 msg
.wParam
= wParam
;
7894 msg
.lParam
= lParam
;
7898 return CallNextHookEx(hCBT_hook
, nCode
, wParam
, lParam
);
7901 static void CALLBACK
win_event_proc(HWINEVENTHOOK hevent
,
7909 ok(thread_id
== GetCurrentThreadId(), "we didn't ask for events from other threads\n");
7911 /* ignore mouse cursor events */
7912 if (object_id
== OBJID_CURSOR
) return;
7914 if (!hwnd
|| is_our_logged_class(hwnd
))
7916 struct recvd_message msg
;
7919 msg
.message
= event
;
7920 msg
.flags
= winevent_hook
|wparam
|lparam
;
7921 msg
.wParam
= object_id
;
7922 msg
.lParam
= child_id
;
7928 static const WCHAR wszUnicode
[] = {'U','n','i','c','o','d','e',0};
7929 static const WCHAR wszAnsi
[] = {'U',0};
7931 static LRESULT CALLBACK
MsgConversionProcW(HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
7935 case CB_FINDSTRINGEXACT
:
7936 trace("String: %p\n", (LPCWSTR
)lParam
);
7937 if (!lstrcmpW((LPCWSTR
)lParam
, wszUnicode
))
7939 if (!lstrcmpW((LPCWSTR
)lParam
, wszAnsi
))
7943 return DefWindowProcW(hwnd
, uMsg
, wParam
, lParam
);
7946 static const struct message WmGetTextLengthAfromW
[] = {
7947 { WM_GETTEXTLENGTH
, sent
},
7948 { WM_GETTEXT
, sent
|optional
},
7952 static const WCHAR dummy_window_text
[] = {'d','u','m','m','y',' ','t','e','x','t',0};
7954 /* dummy window proc for WM_GETTEXTLENGTH test */
7955 static LRESULT CALLBACK
get_text_len_proc( HWND hwnd
, UINT msg
, WPARAM wp
, LPARAM lp
)
7959 case WM_GETTEXTLENGTH
:
7960 return lstrlenW(dummy_window_text
) + 37; /* some random length */
7962 lstrcpynW( (LPWSTR
)lp
, dummy_window_text
, wp
);
7963 return lstrlenW( (LPWSTR
)lp
);
7965 return DefWindowProcW( hwnd
, msg
, wp
, lp
);
7969 static void test_message_conversion(void)
7971 static const WCHAR wszMsgConversionClass
[] =
7972 {'M','s','g','C','o','n','v','e','r','s','i','o','n','C','l','a','s','s',0};
7976 WNDPROC wndproc
, newproc
;
7980 cls
.lpfnWndProc
= MsgConversionProcW
;
7983 cls
.hInstance
= GetModuleHandleW(NULL
);
7985 cls
.hCursor
= LoadCursorW(NULL
, (LPWSTR
)IDC_ARROW
);
7986 cls
.hbrBackground
= (HBRUSH
)(COLOR_BTNFACE
+1);
7987 cls
.lpszMenuName
= NULL
;
7988 cls
.lpszClassName
= wszMsgConversionClass
;
7989 /* this call will fail on Win9x, but that doesn't matter as this test is
7990 * meaningless on those platforms */
7991 if(!RegisterClassW(&cls
)) return;
7993 hwnd
= CreateWindowExW(0, wszMsgConversionClass
, NULL
, WS_OVERLAPPED
,
7994 100, 100, 200, 200, 0, 0, 0, NULL
);
7995 ok(hwnd
!= NULL
, "Window creation failed\n");
7999 wndproc
= (WNDPROC
)GetWindowLongPtrA(hwnd
, GWLP_WNDPROC
);
8000 lRes
= CallWindowProcA(wndproc
, hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
8001 ok(lRes
== 0, "String should have been converted\n");
8002 lRes
= CallWindowProcW(wndproc
, hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
8003 ok(lRes
== 1, "String shouldn't have been converted\n");
8007 wndproc
= (WNDPROC
)GetWindowLongPtrW(hwnd
, GWLP_WNDPROC
);
8008 lRes
= CallWindowProcA(wndproc
, hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
8009 ok(lRes
== 1, "String shouldn't have been converted\n");
8010 lRes
= CallWindowProcW(wndproc
, hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
8011 ok(lRes
== 1, "String shouldn't have been converted\n");
8013 /* Synchronous messages */
8015 lRes
= SendMessageA(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
8016 ok(lRes
== 0, "String should have been converted\n");
8017 lRes
= SendMessageW(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
8018 ok(lRes
== 1, "String shouldn't have been converted\n");
8020 /* Asynchronous messages */
8023 lRes
= PostMessageA(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
8024 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
8025 "PostMessage on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
8027 lRes
= PostMessageW(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
8028 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
8029 "PostMessage on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
8031 lRes
= PostThreadMessageA(GetCurrentThreadId(), CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
8032 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
8033 "PosThreadtMessage on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
8035 lRes
= PostThreadMessageW(GetCurrentThreadId(), CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
8036 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
8037 "PosThreadtMessage on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
8039 lRes
= SendNotifyMessageA(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
8040 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
8041 "SendNotifyMessage on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
8043 lRes
= SendNotifyMessageW(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
8044 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
8045 "SendNotifyMessage on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
8047 lRes
= SendMessageCallbackA(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
, NULL
, 0);
8048 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
8049 "SendMessageCallback on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
8051 lRes
= SendMessageCallbackW(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
, NULL
, 0);
8052 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
8053 "SendMessageCallback on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
8055 /* Check WM_GETTEXTLENGTH A->W behaviour, whether WM_GETTEXT is also sent or not */
8057 hwnd
= CreateWindowW (testWindowClassW
, wszUnicode
,
8058 WS_OVERLAPPEDWINDOW
,
8059 100, 100, 200, 200, 0, 0, 0, NULL
);
8062 lRes
= SendMessageA (hwnd
, WM_GETTEXTLENGTH
, 0, 0);
8063 ok_sequence(WmGetTextLengthAfromW
, "ANSI WM_GETTEXTLENGTH to Unicode window", FALSE
);
8064 ok( lRes
== WideCharToMultiByte( CP_ACP
, 0, wszUnicode
, lstrlenW(wszUnicode
), NULL
, 0, NULL
, NULL
),
8065 "got bad length %ld\n", lRes
);
8068 lRes
= CallWindowProcA( (WNDPROC
)GetWindowLongPtrA( hwnd
, GWLP_WNDPROC
),
8069 hwnd
, WM_GETTEXTLENGTH
, 0, 0);
8070 ok_sequence(WmGetTextLengthAfromW
, "ANSI WM_GETTEXTLENGTH to Unicode window", FALSE
);
8071 ok( lRes
== WideCharToMultiByte( CP_ACP
, 0, wszUnicode
, lstrlenW(wszUnicode
), NULL
, 0, NULL
, NULL
),
8072 "got bad length %ld\n", lRes
);
8074 wndproc
= (WNDPROC
)SetWindowLongPtrW( hwnd
, GWLP_WNDPROC
, (LONG_PTR
)get_text_len_proc
);
8075 newproc
= (WNDPROC
)GetWindowLongPtrA( hwnd
, GWLP_WNDPROC
);
8076 lRes
= CallWindowProcA( newproc
, hwnd
, WM_GETTEXTLENGTH
, 0, 0 );
8077 ok( lRes
== WideCharToMultiByte( CP_ACP
, 0, dummy_window_text
, lstrlenW(dummy_window_text
),
8078 NULL
, 0, NULL
, NULL
) ||
8079 broken(lRes
== lstrlenW(dummy_window_text
) + 37),
8080 "got bad length %ld\n", lRes
);
8082 SetWindowLongPtrW( hwnd
, GWLP_WNDPROC
, (LONG_PTR
)wndproc
); /* restore old wnd proc */
8083 lRes
= CallWindowProcA( newproc
, hwnd
, WM_GETTEXTLENGTH
, 0, 0 );
8084 ok( lRes
== WideCharToMultiByte( CP_ACP
, 0, dummy_window_text
, lstrlenW(dummy_window_text
),
8085 NULL
, 0, NULL
, NULL
) ||
8086 broken(lRes
== lstrlenW(dummy_window_text
) + 37),
8087 "got bad length %ld\n", lRes
);
8089 ret
= DestroyWindow(hwnd
);
8090 ok( ret
, "DestroyWindow() error %d\n", GetLastError());
8100 static VOID CALLBACK
tfunc(HWND hwnd
, UINT uMsg
, UINT_PTR id
, DWORD dwTime
)
8104 static VOID CALLBACK
tfunc_crash(HWND hwnd
, UINT uMsg
, UINT_PTR id
, DWORD dwTime
)
8106 /* Crash on purpose */
8107 *(volatile int *)0 = 2;
8110 #define TIMER_ID 0x19
8112 static DWORD WINAPI
timer_thread_proc(LPVOID x
)
8114 struct timer_info
*info
= x
;
8117 r
= KillTimer(info
->hWnd
, 0x19);
8118 ok(r
,"KillTimer failed in thread\n");
8119 r
= SetTimer(info
->hWnd
,TIMER_ID
,10000,tfunc
);
8120 ok(r
,"SetTimer failed in thread\n");
8121 ok(r
==TIMER_ID
,"SetTimer id different\n");
8122 r
= SetEvent(info
->handles
[0]);
8123 ok(r
,"SetEvent failed in thread\n");
8127 static void test_timers(void)
8129 struct timer_info info
;
8133 info
.hWnd
= CreateWindow ("TestWindowClass", NULL
,
8134 WS_OVERLAPPEDWINDOW
,
8135 CW_USEDEFAULT
, CW_USEDEFAULT
, 300, 300, 0,
8138 info
.id
= SetTimer(info
.hWnd
,TIMER_ID
,10000,tfunc
);
8139 ok(info
.id
, "SetTimer failed\n");
8140 ok(info
.id
==TIMER_ID
, "SetTimer timer ID different\n");
8141 info
.handles
[0] = CreateEvent(NULL
,0,0,NULL
);
8142 info
.handles
[1] = CreateThread(NULL
,0,timer_thread_proc
,&info
,0,&id
);
8144 WaitForMultipleObjects(2, info
.handles
, FALSE
, INFINITE
);
8146 WaitForSingleObject(info
.handles
[1], INFINITE
);
8148 CloseHandle(info
.handles
[0]);
8149 CloseHandle(info
.handles
[1]);
8151 ok( KillTimer(info
.hWnd
, TIMER_ID
), "KillTimer failed\n");
8153 ok(DestroyWindow(info
.hWnd
), "failed to destroy window\n");
8155 /* Test timer callback with crash */
8156 SetLastError(0xdeadbeef);
8157 info
.hWnd
= CreateWindowW(testWindowClassW
, NULL
,
8158 WS_OVERLAPPEDWINDOW
,
8159 CW_USEDEFAULT
, CW_USEDEFAULT
, 300, 300, 0,
8161 if ((!info
.hWnd
&& GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
) || /* Win9x/Me */
8162 (!pGetMenuInfo
)) /* Win95/NT4 */
8164 win_skip("Test would crash on Win9x/WinMe/NT4\n");
8165 DestroyWindow(info
.hWnd
);
8168 info
.id
= SetTimer(info
.hWnd
, TIMER_ID
, 0, tfunc_crash
);
8169 ok(info
.id
, "SetTimer failed\n");
8171 while (PeekMessage(&msg
, NULL
, 0, 0, PM_REMOVE
)) DispatchMessage(&msg
);
8173 ok(DestroyWindow(info
.hWnd
), "failed to destroy window\n");
8176 static int count
= 0;
8177 static VOID CALLBACK
callback_count(
8187 static void test_timers_no_wnd(void)
8193 id
= SetTimer(NULL
, 0, 100, callback_count
);
8194 ok(id
!= 0, "did not get id from SetTimer.\n");
8195 id2
= SetTimer(NULL
, id
, 200, callback_count
);
8196 ok(id2
== id
, "did not get same id from SetTimer when replacing (%li expected %li).\n", id2
, id
);
8198 while (PeekMessage(&msg
, NULL
, 0, 0, PM_REMOVE
)) DispatchMessage(&msg
);
8199 ok(count
== 0, "did not get zero count as expected (%i).\n", count
);
8201 while (PeekMessage(&msg
, NULL
, 0, 0, PM_REMOVE
)) DispatchMessage(&msg
);
8202 ok(count
== 1, "did not get one count as expected (%i).\n", count
);
8203 KillTimer(NULL
, id
);
8205 while (PeekMessage(&msg
, NULL
, 0, 0, PM_REMOVE
)) DispatchMessage(&msg
);
8206 ok(count
== 1, "killing replaced timer did not work (%i).\n", count
);
8209 /* Various win events with arbitrary parameters */
8210 static const struct message WmWinEventsSeq
[] = {
8211 { EVENT_SYSTEM_SOUND
, winevent_hook
|wparam
|lparam
, OBJID_WINDOW
, 0 },
8212 { EVENT_SYSTEM_ALERT
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 1 },
8213 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, OBJID_TITLEBAR
, 2 },
8214 { EVENT_SYSTEM_MENUSTART
, winevent_hook
|wparam
|lparam
, OBJID_MENU
, 3 },
8215 { EVENT_SYSTEM_MENUEND
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 4 },
8216 { EVENT_SYSTEM_MENUPOPUPSTART
, winevent_hook
|wparam
|lparam
, OBJID_VSCROLL
, 5 },
8217 { EVENT_SYSTEM_MENUPOPUPEND
, winevent_hook
|wparam
|lparam
, OBJID_HSCROLL
, 6 },
8218 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, OBJID_SIZEGRIP
, 7 },
8219 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 8 },
8220 /* our win event hook ignores OBJID_CURSOR events */
8221 /*{ EVENT_SYSTEM_MOVESIZESTART, winevent_hook|wparam|lparam, OBJID_CURSOR, 9 },*/
8222 { EVENT_SYSTEM_MOVESIZEEND
, winevent_hook
|wparam
|lparam
, OBJID_ALERT
, 10 },
8223 { EVENT_SYSTEM_CONTEXTHELPSTART
, winevent_hook
|wparam
|lparam
, OBJID_SOUND
, 11 },
8224 { EVENT_SYSTEM_CONTEXTHELPEND
, winevent_hook
|wparam
|lparam
, OBJID_QUERYCLASSNAMEIDX
, 12 },
8225 { EVENT_SYSTEM_DRAGDROPSTART
, winevent_hook
|wparam
|lparam
, OBJID_NATIVEOM
, 13 },
8226 { EVENT_SYSTEM_DRAGDROPEND
, winevent_hook
|wparam
|lparam
, OBJID_WINDOW
, 0 },
8227 { EVENT_SYSTEM_DIALOGSTART
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 1 },
8228 { EVENT_SYSTEM_DIALOGEND
, winevent_hook
|wparam
|lparam
, OBJID_TITLEBAR
, 2 },
8229 { EVENT_SYSTEM_SCROLLINGSTART
, winevent_hook
|wparam
|lparam
, OBJID_MENU
, 3 },
8230 { EVENT_SYSTEM_SCROLLINGEND
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 4 },
8231 { EVENT_SYSTEM_SWITCHSTART
, winevent_hook
|wparam
|lparam
, OBJID_VSCROLL
, 5 },
8232 { EVENT_SYSTEM_SWITCHEND
, winevent_hook
|wparam
|lparam
, OBJID_HSCROLL
, 6 },
8233 { EVENT_SYSTEM_MINIMIZESTART
, winevent_hook
|wparam
|lparam
, OBJID_SIZEGRIP
, 7 },
8234 { EVENT_SYSTEM_MINIMIZEEND
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 8 },
8237 static const struct message WmWinEventCaretSeq
[] = {
8238 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 1 */
8239 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 1 */
8240 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 2 */
8241 { EVENT_OBJECT_NAMECHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 1 */
8244 static const struct message WmWinEventCaretSeq_2
[] = {
8245 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 1/2 */
8246 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 1/2 */
8247 { EVENT_OBJECT_NAMECHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 1/2 */
8250 static const struct message WmWinEventAlertSeq
[] = {
8251 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_ALERT
, 0 },
8254 static const struct message WmWinEventAlertSeq_2
[] = {
8255 /* create window in the thread proc */
8256 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_WINDOW
, 2 },
8257 /* our test event */
8258 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_ALERT
, 2 },
8261 static const struct message WmGlobalHookSeq_1
[] = {
8262 /* create window in the thread proc */
8263 { HCBT_CREATEWND
, hook
|lparam
, 0, 2 },
8264 /* our test events */
8265 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_PREVWINDOW
, 2 },
8266 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_NEXTWINDOW
, 2 },
8269 static const struct message WmGlobalHookSeq_2
[] = {
8270 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_NEXTWINDOW
, 0 }, /* old local hook */
8271 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_NEXTWINDOW
, 2 }, /* new global hook */
8272 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_PREVWINDOW
, 0 }, /* old local hook */
8273 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_PREVWINDOW
, 2 }, /* new global hook */
8277 static const struct message WmMouseLLHookSeq
[] = {
8278 { WM_MOUSEMOVE
, hook
},
8279 { WM_LBUTTONUP
, hook
},
8280 { WM_MOUSEMOVE
, hook
},
8284 static void CALLBACK
win_event_global_hook_proc(HWINEVENTHOOK hevent
,
8294 if (GetClassNameA(hwnd
, buf
, sizeof(buf
)))
8296 if (!lstrcmpiA(buf
, "TestWindowClass") ||
8297 !lstrcmpiA(buf
, "static"))
8299 struct recvd_message msg
;
8302 msg
.message
= event
;
8303 msg
.flags
= winevent_hook
|wparam
|lparam
;
8304 msg
.wParam
= object_id
;
8305 msg
.lParam
= (thread_id
== GetCurrentThreadId()) ? child_id
: (child_id
+ 2);
8306 msg
.descr
= "WEH_2";
8312 static HHOOK hCBT_global_hook
;
8313 static DWORD cbt_global_hook_thread_id
;
8315 static LRESULT CALLBACK
cbt_global_hook_proc(int nCode
, WPARAM wParam
, LPARAM lParam
)
8320 if (nCode
== HCBT_SYSCOMMAND
)
8322 struct recvd_message msg
;
8325 msg
.message
= nCode
;
8326 msg
.flags
= hook
|wparam
|lparam
;
8327 msg
.wParam
= wParam
;
8328 msg
.lParam
= (cbt_global_hook_thread_id
== GetCurrentThreadId()) ? 1 : 2;
8329 msg
.descr
= "CBT_2";
8332 return CallNextHookEx(hCBT_global_hook
, nCode
, wParam
, lParam
);
8334 /* WH_MOUSE_LL hook */
8335 if (nCode
== HC_ACTION
)
8337 MSLLHOOKSTRUCT
*mhll
= (MSLLHOOKSTRUCT
*)lParam
;
8339 /* we can't test for real mouse events */
8340 if (mhll
->flags
& LLMHF_INJECTED
)
8342 struct recvd_message msg
;
8344 memset (&msg
, 0, sizeof (msg
));
8345 msg
.message
= wParam
;
8347 msg
.descr
= "CBT_2";
8350 return CallNextHookEx(hCBT_global_hook
, nCode
, wParam
, lParam
);
8353 /* Log also SetFocus(0) calls */
8354 hwnd
= wParam
? (HWND
)wParam
: (HWND
)lParam
;
8356 if (GetClassNameA(hwnd
, buf
, sizeof(buf
)))
8358 if (!lstrcmpiA(buf
, "TestWindowClass") ||
8359 !lstrcmpiA(buf
, "static"))
8361 struct recvd_message msg
;
8364 msg
.message
= nCode
;
8365 msg
.flags
= hook
|wparam
|lparam
;
8366 msg
.wParam
= wParam
;
8367 msg
.lParam
= (cbt_global_hook_thread_id
== GetCurrentThreadId()) ? 1 : 2;
8368 msg
.descr
= "CBT_2";
8372 return CallNextHookEx(hCBT_global_hook
, nCode
, wParam
, lParam
);
8375 static DWORD WINAPI
win_event_global_thread_proc(void *param
)
8379 HANDLE hevent
= *(HANDLE
*)param
;
8381 assert(pNotifyWinEvent
);
8383 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
, 0,0,0,0,0,0,0, NULL
);
8385 trace("created thread window %p\n", hwnd
);
8387 *(HWND
*)param
= hwnd
;
8390 /* this event should be received only by our new hook proc,
8391 * an old one does not expect an event from another thread.
8393 pNotifyWinEvent(EVENT_OBJECT_LOCATIONCHANGE
, hwnd
, OBJID_ALERT
, 0);
8396 while (GetMessage(&msg
, 0, 0, 0))
8398 TranslateMessage(&msg
);
8399 DispatchMessage(&msg
);
8404 static DWORD WINAPI
cbt_global_hook_thread_proc(void *param
)
8408 HANDLE hevent
= *(HANDLE
*)param
;
8411 /* these events should be received only by our new hook proc,
8412 * an old one does not expect an event from another thread.
8415 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
, 0,0,0,0,0,0,0, NULL
);
8417 trace("created thread window %p\n", hwnd
);
8419 *(HWND
*)param
= hwnd
;
8421 /* Windows doesn't like when a thread plays games with the focus,
8422 that leads to all kinds of misbehaviours and failures to activate
8423 a window. So, better keep next lines commented out.
8427 DefWindowProcA(hwnd
, WM_SYSCOMMAND
, SC_PREVWINDOW
, 0);
8428 DefWindowProcA(hwnd
, WM_SYSCOMMAND
, SC_NEXTWINDOW
, 0);
8432 while (GetMessage(&msg
, 0, 0, 0))
8434 TranslateMessage(&msg
);
8435 DispatchMessage(&msg
);
8440 static DWORD WINAPI
mouse_ll_global_thread_proc(void *param
)
8444 HANDLE hevent
= *(HANDLE
*)param
;
8446 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
, 0,0,0,0,0,0,0, NULL
);
8448 trace("created thread window %p\n", hwnd
);
8450 *(HWND
*)param
= hwnd
;
8454 /* Windows doesn't like when a thread plays games with the focus,
8455 * that leads to all kinds of misbehaviours and failures to activate
8456 * a window. So, better don't generate a mouse click message below.
8458 mouse_event(MOUSEEVENTF_MOVE
, -1, 0, 0, 0);
8459 mouse_event(MOUSEEVENTF_LEFTUP
, 0, 0, 0, 0);
8460 mouse_event(MOUSEEVENTF_MOVE
, 1, 0, 0, 0);
8463 while (GetMessage(&msg
, 0, 0, 0))
8465 TranslateMessage(&msg
);
8466 DispatchMessage(&msg
);
8471 static void test_winevents(void)
8477 HANDLE hthread
, hevent
;
8479 HWINEVENTHOOK hhook
;
8480 const struct message
*events
= WmWinEventsSeq
;
8482 hwnd
= CreateWindowExA(0, "TestWindowClass", NULL
,
8483 WS_OVERLAPPEDWINDOW
,
8484 CW_USEDEFAULT
, CW_USEDEFAULT
, 300, 300, 0,
8488 /****** start of global hook test *************/
8489 hCBT_global_hook
= SetWindowsHookExA(WH_CBT
, cbt_global_hook_proc
, GetModuleHandleA(0), 0);
8490 if (!hCBT_global_hook
)
8492 ok(DestroyWindow(hwnd
), "failed to destroy window\n");
8493 skip( "cannot set global hook\n" );
8497 hevent
= CreateEventA(NULL
, 0, 0, NULL
);
8501 hthread
= CreateThread(NULL
, 0, cbt_global_hook_thread_proc
, &hwnd2
, 0, &tid
);
8502 ok(hthread
!= NULL
, "CreateThread failed, error %d\n", GetLastError());
8504 ok(WaitForSingleObject(hevent
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
8506 ok_sequence(WmGlobalHookSeq_1
, "global hook 1", FALSE
);
8509 /* this one should be received only by old hook proc */
8510 DefWindowProcA(hwnd
, WM_SYSCOMMAND
, SC_NEXTWINDOW
, 0);
8511 /* this one should be received only by old hook proc */
8512 DefWindowProcA(hwnd
, WM_SYSCOMMAND
, SC_PREVWINDOW
, 0);
8514 ok_sequence(WmGlobalHookSeq_2
, "global hook 2", FALSE
);
8516 ret
= UnhookWindowsHookEx(hCBT_global_hook
);
8517 ok( ret
, "UnhookWindowsHookEx error %d\n", GetLastError());
8519 PostThreadMessageA(tid
, WM_QUIT
, 0, 0);
8520 ok(WaitForSingleObject(hthread
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
8521 CloseHandle(hthread
);
8522 CloseHandle(hevent
);
8523 ok(!IsWindow(hwnd2
), "window should be destroyed on thread exit\n");
8524 /****** end of global hook test *************/
8526 if (!pSetWinEventHook
|| !pNotifyWinEvent
|| !pUnhookWinEvent
)
8528 ok(DestroyWindow(hwnd
), "failed to destroy window\n");
8536 /* this test doesn't pass under Win9x */
8537 /* win2k ignores events with hwnd == 0 */
8538 SetLastError(0xdeadbeef);
8539 pNotifyWinEvent(events
[0].message
, 0, events
[0].wParam
, events
[0].lParam
);
8540 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
|| /* Win2k */
8541 GetLastError() == 0xdeadbeef, /* Win9x */
8542 "unexpected error %d\n", GetLastError());
8543 ok_sequence(WmEmptySeq
, "empty notify winevents", FALSE
);
8546 for (i
= 0; i
< sizeof(WmWinEventsSeq
)/sizeof(WmWinEventsSeq
[0]); i
++)
8547 pNotifyWinEvent(events
[i
].message
, hwnd
, events
[i
].wParam
, events
[i
].lParam
);
8549 ok_sequence(WmWinEventsSeq
, "notify winevents", FALSE
);
8551 /****** start of event filtering test *************/
8552 hhook
= pSetWinEventHook(
8553 EVENT_OBJECT_SHOW
, /* 0x8002 */
8554 EVENT_OBJECT_LOCATIONCHANGE
, /* 0x800B */
8555 GetModuleHandleA(0), win_event_global_hook_proc
,
8556 GetCurrentProcessId(), 0,
8557 WINEVENT_INCONTEXT
);
8558 ok(hhook
!= 0, "SetWinEventHook error %d\n", GetLastError());
8560 hevent
= CreateEventA(NULL
, 0, 0, NULL
);
8564 hthread
= CreateThread(NULL
, 0, win_event_global_thread_proc
, &hwnd2
, 0, &tid
);
8565 ok(hthread
!= NULL
, "CreateThread failed, error %d\n", GetLastError());
8567 ok(WaitForSingleObject(hevent
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
8569 ok_sequence(WmWinEventAlertSeq
, "alert winevent", FALSE
);
8572 /* this one should be received only by old hook proc */
8573 pNotifyWinEvent(EVENT_OBJECT_CREATE
, hwnd
, OBJID_CARET
, 0); /* 0x8000 */
8574 pNotifyWinEvent(EVENT_OBJECT_SHOW
, hwnd
, OBJID_CARET
, 0); /* 0x8002 */
8575 /* this one should be received only by old hook proc */
8576 pNotifyWinEvent(EVENT_OBJECT_NAMECHANGE
, hwnd
, OBJID_CARET
, 0); /* 0x800C */
8578 ok_sequence(WmWinEventCaretSeq
, "caret winevent", FALSE
);
8580 ret
= pUnhookWinEvent(hhook
);
8581 ok( ret
, "UnhookWinEvent error %d\n", GetLastError());
8583 PostThreadMessageA(tid
, WM_QUIT
, 0, 0);
8584 ok(WaitForSingleObject(hthread
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
8585 CloseHandle(hthread
);
8586 CloseHandle(hevent
);
8587 ok(!IsWindow(hwnd2
), "window should be destroyed on thread exit\n");
8588 /****** end of event filtering test *************/
8590 /****** start of out of context event test *************/
8591 hhook
= pSetWinEventHook(EVENT_MIN
, EVENT_MAX
, 0,
8592 win_event_global_hook_proc
, GetCurrentProcessId(), 0,
8593 WINEVENT_OUTOFCONTEXT
);
8594 ok(hhook
!= 0, "SetWinEventHook error %d\n", GetLastError());
8596 hevent
= CreateEventA(NULL
, 0, 0, NULL
);
8602 hthread
= CreateThread(NULL
, 0, win_event_global_thread_proc
, &hwnd2
, 0, &tid
);
8603 ok(hthread
!= NULL
, "CreateThread failed, error %d\n", GetLastError());
8605 ok(WaitForSingleObject(hevent
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
8607 ok_sequence(WmEmptySeq
, "empty notify winevents", FALSE
);
8608 /* process pending winevent messages */
8609 ok(!PeekMessageA(&msg
, 0, 0, 0, PM_NOREMOVE
), "msg queue should be empty\n");
8610 ok_sequence(WmWinEventAlertSeq_2
, "alert winevent for out of context proc", FALSE
);
8613 /* this one should be received only by old hook proc */
8614 pNotifyWinEvent(EVENT_OBJECT_CREATE
, hwnd
, OBJID_CARET
, 0); /* 0x8000 */
8615 pNotifyWinEvent(EVENT_OBJECT_SHOW
, hwnd
, OBJID_CARET
, 0); /* 0x8002 */
8616 /* this one should be received only by old hook proc */
8617 pNotifyWinEvent(EVENT_OBJECT_NAMECHANGE
, hwnd
, OBJID_CARET
, 0); /* 0x800C */
8619 ok_sequence(WmWinEventCaretSeq_2
, "caret winevent for incontext proc", FALSE
);
8620 /* process pending winevent messages */
8621 ok(!PeekMessageA(&msg
, 0, 0, 0, PM_NOREMOVE
), "msg queue should be empty\n");
8622 ok_sequence(WmWinEventCaretSeq_2
, "caret winevent for out of context proc", FALSE
);
8624 ret
= pUnhookWinEvent(hhook
);
8625 ok( ret
, "UnhookWinEvent error %d\n", GetLastError());
8627 PostThreadMessageA(tid
, WM_QUIT
, 0, 0);
8628 ok(WaitForSingleObject(hthread
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
8629 CloseHandle(hthread
);
8630 CloseHandle(hevent
);
8631 ok(!IsWindow(hwnd2
), "window should be destroyed on thread exit\n");
8632 /****** end of out of context event test *************/
8634 /****** start of MOUSE_LL hook test *************/
8635 hCBT_global_hook
= SetWindowsHookExA(WH_MOUSE_LL
, cbt_global_hook_proc
, GetModuleHandleA(0), 0);
8636 /* WH_MOUSE_LL is not supported on Win9x platforms */
8637 if (!hCBT_global_hook
)
8639 win_skip("Skipping WH_MOUSE_LL test on this platform\n");
8640 goto skip_mouse_ll_hook_test
;
8643 hevent
= CreateEventA(NULL
, 0, 0, NULL
);
8647 hthread
= CreateThread(NULL
, 0, mouse_ll_global_thread_proc
, &hwnd2
, 0, &tid
);
8648 ok(hthread
!= NULL
, "CreateThread failed, error %d\n", GetLastError());
8650 while (WaitForSingleObject(hevent
, 100) == WAIT_TIMEOUT
)
8651 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
8653 ok_sequence(WmMouseLLHookSeq
, "MOUSE_LL hook other thread", FALSE
);
8656 mouse_event(MOUSEEVENTF_MOVE
, -1, 0, 0, 0);
8657 mouse_event(MOUSEEVENTF_LEFTUP
, 0, 0, 0, 0);
8658 mouse_event(MOUSEEVENTF_MOVE
, 1, 0, 0, 0);
8660 ok_sequence(WmMouseLLHookSeq
, "MOUSE_LL hook same thread", FALSE
);
8662 ret
= UnhookWindowsHookEx(hCBT_global_hook
);
8663 ok( ret
, "UnhookWindowsHookEx error %d\n", GetLastError());
8665 PostThreadMessageA(tid
, WM_QUIT
, 0, 0);
8666 ok(WaitForSingleObject(hthread
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
8667 CloseHandle(hthread
);
8668 CloseHandle(hevent
);
8669 ok(!IsWindow(hwnd2
), "window should be destroyed on thread exit\n");
8670 /****** end of MOUSE_LL hook test *************/
8671 skip_mouse_ll_hook_test
:
8673 ok(DestroyWindow(hwnd
), "failed to destroy window\n");
8676 static void test_set_hook(void)
8680 HWINEVENTHOOK hwinevent_hook
;
8682 hhook
= SetWindowsHookExA(WH_CBT
, cbt_hook_proc
, GetModuleHandleA(0), GetCurrentThreadId());
8683 ok(hhook
!= 0, "local hook does not require hModule set to 0\n");
8684 UnhookWindowsHookEx(hhook
);
8688 /* this test doesn't pass under Win9x: BUG! */
8689 SetLastError(0xdeadbeef);
8690 hhook
= SetWindowsHookExA(WH_CBT
, cbt_hook_proc
, 0, 0);
8691 ok(!hhook
, "global hook requires hModule != 0\n");
8692 ok(GetLastError() == ERROR_HOOK_NEEDS_HMOD
, "unexpected error %d\n", GetLastError());
8695 SetLastError(0xdeadbeef);
8696 hhook
= SetWindowsHookExA(WH_CBT
, 0, GetModuleHandleA(0), GetCurrentThreadId());
8697 ok(!hhook
, "SetWinEventHook with invalid proc should fail\n");
8698 ok(GetLastError() == ERROR_INVALID_FILTER_PROC
|| /* Win2k */
8699 GetLastError() == 0xdeadbeef, /* Win9x */
8700 "unexpected error %d\n", GetLastError());
8702 SetLastError(0xdeadbeef);
8703 ok(!UnhookWindowsHookEx((HHOOK
)0xdeadbeef), "UnhookWindowsHookEx succeeded\n");
8704 ok(GetLastError() == ERROR_INVALID_HOOK_HANDLE
|| /* Win2k */
8705 GetLastError() == 0xdeadbeef, /* Win9x */
8706 "unexpected error %d\n", GetLastError());
8708 if (!pSetWinEventHook
|| !pUnhookWinEvent
) return;
8710 /* even process local incontext hooks require hmodule */
8711 SetLastError(0xdeadbeef);
8712 hwinevent_hook
= pSetWinEventHook(EVENT_MIN
, EVENT_MAX
, 0, win_event_proc
,
8713 GetCurrentProcessId(), 0, WINEVENT_INCONTEXT
);
8714 ok(!hwinevent_hook
, "WINEVENT_INCONTEXT requires hModule != 0\n");
8715 ok(GetLastError() == ERROR_HOOK_NEEDS_HMOD
|| /* Win2k */
8716 GetLastError() == 0xdeadbeef, /* Win9x */
8717 "unexpected error %d\n", GetLastError());
8719 /* even thread local incontext hooks require hmodule */
8720 SetLastError(0xdeadbeef);
8721 hwinevent_hook
= pSetWinEventHook(EVENT_MIN
, EVENT_MAX
, 0, win_event_proc
,
8722 GetCurrentProcessId(), GetCurrentThreadId(), WINEVENT_INCONTEXT
);
8723 ok(!hwinevent_hook
, "WINEVENT_INCONTEXT requires hModule != 0\n");
8724 ok(GetLastError() == ERROR_HOOK_NEEDS_HMOD
|| /* Win2k */
8725 GetLastError() == 0xdeadbeef, /* Win9x */
8726 "unexpected error %d\n", GetLastError());
8730 /* these 3 tests don't pass under Win9x */
8731 SetLastError(0xdeadbeef);
8732 hwinevent_hook
= pSetWinEventHook(1, 0, 0, win_event_proc
,
8733 GetCurrentProcessId(), 0, WINEVENT_OUTOFCONTEXT
);
8734 ok(!hwinevent_hook
, "SetWinEventHook with invalid event range should fail\n");
8735 ok(GetLastError() == ERROR_INVALID_HOOK_FILTER
, "unexpected error %d\n", GetLastError());
8737 SetLastError(0xdeadbeef);
8738 hwinevent_hook
= pSetWinEventHook(-1, 1, 0, win_event_proc
,
8739 GetCurrentProcessId(), 0, WINEVENT_OUTOFCONTEXT
);
8740 ok(!hwinevent_hook
, "SetWinEventHook with invalid event range should fail\n");
8741 ok(GetLastError() == ERROR_INVALID_HOOK_FILTER
, "unexpected error %d\n", GetLastError());
8743 SetLastError(0xdeadbeef);
8744 hwinevent_hook
= pSetWinEventHook(EVENT_MIN
, EVENT_MAX
, 0, win_event_proc
,
8745 0, 0xdeadbeef, WINEVENT_OUTOFCONTEXT
);
8746 ok(!hwinevent_hook
, "SetWinEventHook with invalid tid should fail\n");
8747 ok(GetLastError() == ERROR_INVALID_THREAD_ID
, "unexpected error %d\n", GetLastError());
8750 SetLastError(0xdeadbeef);
8751 hwinevent_hook
= pSetWinEventHook(0, 0, 0, win_event_proc
,
8752 GetCurrentProcessId(), 0, WINEVENT_OUTOFCONTEXT
);
8753 ok(hwinevent_hook
!= 0, "SetWinEventHook error %d\n", GetLastError());
8754 ok(GetLastError() == 0xdeadbeef, "unexpected error %d\n", GetLastError());
8755 ret
= pUnhookWinEvent(hwinevent_hook
);
8756 ok( ret
, "UnhookWinEvent error %d\n", GetLastError());
8759 /* This call succeeds under win2k SP4, but fails under Wine.
8760 Does win2k test/use passed process id? */
8761 SetLastError(0xdeadbeef);
8762 hwinevent_hook
= pSetWinEventHook(EVENT_MIN
, EVENT_MAX
, 0, win_event_proc
,
8763 0xdeadbeef, 0, WINEVENT_OUTOFCONTEXT
);
8764 ok(hwinevent_hook
!= 0, "SetWinEventHook error %d\n", GetLastError());
8765 ok(GetLastError() == 0xdeadbeef, "unexpected error %d\n", GetLastError());
8766 ret
= pUnhookWinEvent(hwinevent_hook
);
8767 ok( ret
, "UnhookWinEvent error %d\n", GetLastError());
8770 SetLastError(0xdeadbeef);
8771 ok(!pUnhookWinEvent((HWINEVENTHOOK
)0xdeadbeef), "UnhookWinEvent succeeded\n");
8772 ok(GetLastError() == ERROR_INVALID_HANDLE
|| /* Win2k */
8773 GetLastError() == 0xdeadbeef, /* Win9x */
8774 "unexpected error %d\n", GetLastError());
8777 static const struct message ScrollWindowPaint1
[] = {
8779 { WM_ERASEBKGND
, sent
|beginpaint
},
8780 { WM_GETTEXTLENGTH
, sent
|optional
},
8781 { WM_PAINT
, sent
|optional
},
8782 { WM_NCPAINT
, sent
|beginpaint
|optional
},
8783 { WM_GETTEXT
, sent
|beginpaint
|optional
},
8784 { WM_GETTEXT
, sent
|beginpaint
|optional
},
8785 { WM_GETTEXT
, sent
|beginpaint
|optional
},
8786 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
8787 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
8791 static const struct message ScrollWindowPaint2
[] = {
8796 static void test_scrollwindowex(void)
8799 RECT rect
={0,0,130,130};
8801 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test Scroll",
8802 WS_VISIBLE
|WS_OVERLAPPEDWINDOW
,
8803 100, 100, 200, 200, 0, 0, 0, NULL
);
8804 ok (hwnd
!= 0, "Failed to create overlapped window\n");
8805 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child",
8806 WS_VISIBLE
|WS_CAPTION
|WS_CHILD
,
8807 10, 10, 150, 150, hwnd
, 0, 0, NULL
);
8808 ok (hchild
!= 0, "Failed to create child\n");
8813 /* scroll without the child window */
8814 trace("start scroll\n");
8815 ScrollWindowEx( hwnd
, 10, 10, &rect
, NULL
, NULL
, NULL
,
8816 SW_ERASE
|SW_INVALIDATE
);
8817 ok_sequence(WmEmptySeq
, "ScrollWindowEx", 0);
8818 trace("end scroll\n");
8821 ok_sequence(ScrollWindowPaint1
, "ScrollWindowEx", 0);
8825 /* Now without the SW_ERASE flag */
8826 trace("start scroll\n");
8827 ScrollWindowEx( hwnd
, 10, 10, &rect
, NULL
, NULL
, NULL
, SW_INVALIDATE
);
8828 ok_sequence(WmEmptySeq
, "ScrollWindowEx", 0);
8829 trace("end scroll\n");
8832 ok_sequence(ScrollWindowPaint2
, "ScrollWindowEx", 0);
8836 /* now scroll the child window as well */
8837 trace("start scroll\n");
8838 ScrollWindowEx( hwnd
, 10, 10, &rect
, NULL
, NULL
, NULL
,
8839 SW_SCROLLCHILDREN
|SW_ERASE
|SW_INVALIDATE
);
8840 /* wine sends WM_POSCHANGING, WM_POSCHANGED messages */
8841 /* windows sometimes a WM_MOVE */
8842 ok_sequence(WmEmptySeq
, "ScrollWindowEx", TRUE
);
8843 trace("end scroll\n");
8846 ok_sequence(ScrollWindowPaint1
, "ScrollWindowEx", 0);
8850 /* now scroll with ScrollWindow() */
8851 trace("start scroll with ScrollWindow\n");
8852 ScrollWindow( hwnd
, 5, 5, NULL
, NULL
);
8853 trace("end scroll\n");
8856 ok_sequence(ScrollWindowPaint1
, "ScrollWindow", 0);
8858 ok(DestroyWindow(hchild
), "failed to destroy window\n");
8859 ok(DestroyWindow(hwnd
), "failed to destroy window\n");
8863 static const struct message destroy_window_with_children
[] = {
8864 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* popup */
8865 { HCBT_DESTROYWND
, hook
|lparam
, 0, WND_PARENT_ID
}, /* parent */
8866 { 0x0090, sent
|optional
},
8867 { HCBT_DESTROYWND
, hook
|lparam
, 0, WND_POPUP_ID
}, /* popup */
8868 { 0x0090, sent
|optional
},
8869 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* popup */
8870 { WM_DESTROY
, sent
|wparam
|lparam
, 0, WND_POPUP_ID
}, /* popup */
8871 { WM_CAPTURECHANGED
, sent
|wparam
|lparam
, 0, WND_POPUP_ID
}, /* popup */
8872 { WM_NCDESTROY
, sent
|wparam
|lparam
, 0, WND_POPUP_ID
}, /* popup */
8873 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* parent */
8874 { WM_DESTROY
, sent
|wparam
|lparam
, 0, WND_PARENT_ID
}, /* parent */
8875 { WM_DESTROY
, sent
|wparam
|lparam
, 0, WND_CHILD_ID
+ 2 }, /* child2 */
8876 { WM_DESTROY
, sent
|wparam
|lparam
, 0, WND_CHILD_ID
+ 1 }, /* child1 */
8877 { WM_DESTROY
, sent
|wparam
|lparam
, 0, WND_CHILD_ID
+ 3 }, /* child3 */
8878 { WM_NCDESTROY
, sent
|wparam
|lparam
, 0, WND_CHILD_ID
+ 2 }, /* child2 */
8879 { WM_NCDESTROY
, sent
|wparam
|lparam
, 0, WND_CHILD_ID
+ 3 }, /* child3 */
8880 { WM_NCDESTROY
, sent
|wparam
|lparam
, 0, WND_CHILD_ID
+ 1 }, /* child1 */
8881 { WM_NCDESTROY
, sent
|wparam
|lparam
, 0, WND_PARENT_ID
}, /* parent */
8885 static void test_DestroyWindow(void)
8888 HWND parent
, child1
, child2
, child3
, child4
, test
;
8889 UINT_PTR child_id
= WND_CHILD_ID
+ 1;
8891 parent
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
8892 100, 100, 200, 200, 0, 0, 0, NULL
);
8893 assert(parent
!= 0);
8894 child1
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_CHILD
,
8895 0, 0, 50, 50, parent
, (HMENU
)child_id
++, 0, NULL
);
8896 assert(child1
!= 0);
8897 child2
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_CHILD
,
8898 0, 0, 50, 50, GetDesktopWindow(), (HMENU
)child_id
++, 0, NULL
);
8899 assert(child2
!= 0);
8900 child3
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_CHILD
,
8901 0, 0, 50, 50, child1
, (HMENU
)child_id
++, 0, NULL
);
8902 assert(child3
!= 0);
8903 child4
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_POPUP
,
8904 0, 0, 50, 50, parent
, 0, 0, NULL
);
8905 assert(child4
!= 0);
8907 /* test owner/parent of child2 */
8908 test
= GetParent(child2
);
8909 ok(test
== GetDesktopWindow(), "wrong parent %p\n", test
);
8910 ok(!IsChild(parent
, child2
), "wrong parent/child %p/%p\n", parent
, child2
);
8912 test
= pGetAncestor(child2
, GA_PARENT
);
8913 ok(test
== GetDesktopWindow(), "wrong parent %p\n", test
);
8915 test
= GetWindow(child2
, GW_OWNER
);
8916 ok(!test
, "wrong owner %p\n", test
);
8918 test
= SetParent(child2
, parent
);
8919 ok(test
== GetDesktopWindow(), "wrong old parent %p\n", test
);
8921 /* test owner/parent of the parent */
8922 test
= GetParent(parent
);
8923 ok(!test
, "wrong parent %p\n", test
);
8924 ok(!IsChild(GetDesktopWindow(), parent
), "wrong parent/child %p/%p\n", GetDesktopWindow(), parent
);
8926 test
= pGetAncestor(parent
, GA_PARENT
);
8927 ok(test
== GetDesktopWindow(), "wrong parent %p\n", test
);
8929 test
= GetWindow(parent
, GW_OWNER
);
8930 ok(!test
, "wrong owner %p\n", test
);
8932 /* test owner/parent of child1 */
8933 test
= GetParent(child1
);
8934 ok(test
== parent
, "wrong parent %p\n", test
);
8935 ok(IsChild(parent
, child1
), "wrong parent/child %p/%p\n", parent
, child1
);
8937 test
= pGetAncestor(child1
, GA_PARENT
);
8938 ok(test
== parent
, "wrong parent %p\n", test
);
8940 test
= GetWindow(child1
, GW_OWNER
);
8941 ok(!test
, "wrong owner %p\n", test
);
8943 /* test owner/parent of child2 */
8944 test
= GetParent(child2
);
8945 ok(test
== parent
, "wrong parent %p\n", test
);
8946 ok(IsChild(parent
, child2
), "wrong parent/child %p/%p\n", parent
, child2
);
8948 test
= pGetAncestor(child2
, GA_PARENT
);
8949 ok(test
== parent
, "wrong parent %p\n", test
);
8951 test
= GetWindow(child2
, GW_OWNER
);
8952 ok(!test
, "wrong owner %p\n", test
);
8954 /* test owner/parent of child3 */
8955 test
= GetParent(child3
);
8956 ok(test
== child1
, "wrong parent %p\n", test
);
8957 ok(IsChild(parent
, child3
), "wrong parent/child %p/%p\n", parent
, child3
);
8959 test
= pGetAncestor(child3
, GA_PARENT
);
8960 ok(test
== child1
, "wrong parent %p\n", test
);
8962 test
= GetWindow(child3
, GW_OWNER
);
8963 ok(!test
, "wrong owner %p\n", test
);
8965 /* test owner/parent of child4 */
8966 test
= GetParent(child4
);
8967 ok(test
== parent
, "wrong parent %p\n", test
);
8968 ok(!IsChild(parent
, child4
), "wrong parent/child %p/%p\n", parent
, child4
);
8970 test
= pGetAncestor(child4
, GA_PARENT
);
8971 ok(test
== GetDesktopWindow(), "wrong parent %p\n", test
);
8973 test
= GetWindow(child4
, GW_OWNER
);
8974 ok(test
== parent
, "wrong owner %p\n", test
);
8978 trace("parent %p, child1 %p, child2 %p, child3 %p, child4 %p\n",
8979 parent
, child1
, child2
, child3
, child4
);
8982 test
= GetCapture();
8983 ok(test
== child4
, "wrong capture window %p\n", test
);
8985 test_DestroyWindow_flag
= TRUE
;
8986 ret
= DestroyWindow(parent
);
8987 ok( ret
, "DestroyWindow() error %d\n", GetLastError());
8988 test_DestroyWindow_flag
= FALSE
;
8989 ok_sequence(destroy_window_with_children
, "destroy window with children", 0);
8991 ok(!IsWindow(parent
), "parent still exists\n");
8992 ok(!IsWindow(child1
), "child1 still exists\n");
8993 ok(!IsWindow(child2
), "child2 still exists\n");
8994 ok(!IsWindow(child3
), "child3 still exists\n");
8995 ok(!IsWindow(child4
), "child4 still exists\n");
8997 test
= GetCapture();
8998 ok(!test
, "wrong capture window %p\n", test
);
9002 static const struct message WmDispatchPaint
[] = {
9003 { WM_NCPAINT
, sent
},
9004 { WM_GETTEXT
, sent
|defwinproc
|optional
},
9005 { WM_GETTEXT
, sent
|defwinproc
|optional
},
9006 { WM_ERASEBKGND
, sent
},
9010 static LRESULT WINAPI
DispatchMessageCheckProc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
9012 if (message
== WM_PAINT
) return 0;
9013 return MsgCheckProcA( hwnd
, message
, wParam
, lParam
);
9016 static void test_DispatchMessage(void)
9021 HWND hwnd
= CreateWindowA( "TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
9022 100, 100, 200, 200, 0, 0, 0, NULL
);
9023 ShowWindow( hwnd
, SW_SHOW
);
9024 UpdateWindow( hwnd
);
9027 SetWindowLongPtrA( hwnd
, GWLP_WNDPROC
, (LONG_PTR
)DispatchMessageCheckProc
);
9029 SetRect( &rect
, -5, -5, 5, 5 );
9030 RedrawWindow( hwnd
, &rect
, 0, RDW_INVALIDATE
|RDW_ERASE
|RDW_FRAME
);
9032 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
))
9034 if (msg
.message
!= WM_PAINT
) DispatchMessage( &msg
);
9038 DispatchMessage( &msg
);
9039 /* DispatchMessage will send WM_NCPAINT if non client area is still invalid after WM_PAINT */
9040 if (!count
) ok_sequence( WmDispatchPaint
, "WmDispatchPaint", FALSE
);
9041 else ok_sequence( WmEmptySeq
, "WmEmpty", FALSE
);
9042 if (++count
> 10) break;
9045 ok( msg
.message
== WM_PAINT
&& count
> 10, "WM_PAINT messages stopped\n" );
9047 trace("now without DispatchMessage\n");
9049 RedrawWindow( hwnd
, &rect
, 0, RDW_INVALIDATE
|RDW_ERASE
|RDW_FRAME
);
9051 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
))
9053 if (msg
.message
!= WM_PAINT
) DispatchMessage( &msg
);
9056 HRGN hrgn
= CreateRectRgn( 0, 0, 0, 0 );
9058 /* this will send WM_NCCPAINT just like DispatchMessage does */
9059 GetUpdateRgn( hwnd
, hrgn
, TRUE
);
9060 ok_sequence( WmDispatchPaint
, "WmDispatchPaint", FALSE
);
9061 DeleteObject( hrgn
);
9062 GetClientRect( hwnd
, &rect
);
9063 ValidateRect( hwnd
, &rect
); /* this will stop WM_PAINTs */
9064 ok( !count
, "Got multiple WM_PAINTs\n" );
9065 if (++count
> 10) break;
9068 DestroyWindow(hwnd
);
9072 static const struct message WmUser
[] = {
9084 static DWORD CALLBACK
send_msg_thread( LPVOID arg
)
9086 struct sendmsg_info
*info
= arg
;
9087 SetLastError( 0xdeadbeef );
9088 info
->ret
= SendMessageTimeoutA( info
->hwnd
, WM_USER
, 0, 0, 0, info
->timeout
, NULL
);
9089 if (!info
->ret
) ok( GetLastError() == ERROR_TIMEOUT
||
9090 broken(GetLastError() == 0), /* win9x */
9091 "unexpected error %d\n", GetLastError());
9095 static void wait_for_thread( HANDLE thread
)
9097 while (MsgWaitForMultipleObjects(1, &thread
, FALSE
, INFINITE
, QS_SENDMESSAGE
) != WAIT_OBJECT_0
)
9100 while (PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage(&msg
);
9104 static LRESULT WINAPI
send_msg_delay_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
9106 if (message
== WM_USER
) Sleep(200);
9107 return MsgCheckProcA( hwnd
, message
, wParam
, lParam
);
9110 static void test_SendMessageTimeout(void)
9113 struct sendmsg_info info
;
9117 info
.hwnd
= CreateWindowA( "TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
9118 100, 100, 200, 200, 0, 0, 0, NULL
);
9122 info
.timeout
= 1000;
9123 info
.ret
= 0xdeadbeef;
9124 thread
= CreateThread( NULL
, 0, send_msg_thread
, &info
, 0, &tid
);
9125 wait_for_thread( thread
);
9126 CloseHandle( thread
);
9127 ok( info
.ret
== 1, "SendMessageTimeout failed\n" );
9128 ok_sequence( WmUser
, "WmUser", FALSE
);
9131 info
.ret
= 0xdeadbeef;
9132 thread
= CreateThread( NULL
, 0, send_msg_thread
, &info
, 0, &tid
);
9133 Sleep(100); /* SendMessageTimeout should time out here */
9134 wait_for_thread( thread
);
9135 CloseHandle( thread
);
9136 ok( info
.ret
== 0, "SendMessageTimeout succeeded\n" );
9137 ok_sequence( WmEmptySeq
, "WmEmptySeq", FALSE
);
9139 /* 0 means infinite timeout (but not on win9x) */
9141 info
.ret
= 0xdeadbeef;
9142 thread
= CreateThread( NULL
, 0, send_msg_thread
, &info
, 0, &tid
);
9144 wait_for_thread( thread
);
9145 CloseHandle( thread
);
9146 is_win9x
= !info
.ret
;
9147 if (is_win9x
) ok_sequence( WmEmptySeq
, "WmEmptySeq", FALSE
);
9148 else ok_sequence( WmUser
, "WmUser", FALSE
);
9150 /* timeout is treated as signed despite the prototype (but not on win9x) */
9151 info
.timeout
= 0x7fffffff;
9152 info
.ret
= 0xdeadbeef;
9153 thread
= CreateThread( NULL
, 0, send_msg_thread
, &info
, 0, &tid
);
9155 wait_for_thread( thread
);
9156 CloseHandle( thread
);
9157 ok( info
.ret
== 1, "SendMessageTimeout failed\n" );
9158 ok_sequence( WmUser
, "WmUser", FALSE
);
9160 info
.timeout
= 0x80000000;
9161 info
.ret
= 0xdeadbeef;
9162 thread
= CreateThread( NULL
, 0, send_msg_thread
, &info
, 0, &tid
);
9164 wait_for_thread( thread
);
9165 CloseHandle( thread
);
9168 ok( info
.ret
== 1, "SendMessageTimeout failed\n" );
9169 ok_sequence( WmUser
, "WmUser", FALSE
);
9173 ok( info
.ret
== 0, "SendMessageTimeout succeeded\n" );
9174 ok_sequence( WmEmptySeq
, "WmEmptySeq", FALSE
);
9177 /* now check for timeout during message processing */
9178 SetWindowLongPtrA( info
.hwnd
, GWLP_WNDPROC
, (LONG_PTR
)send_msg_delay_proc
);
9180 info
.ret
= 0xdeadbeef;
9181 thread
= CreateThread( NULL
, 0, send_msg_thread
, &info
, 0, &tid
);
9182 wait_for_thread( thread
);
9183 CloseHandle( thread
);
9184 /* we should time out but still get the message */
9185 ok( info
.ret
== 0, "SendMessageTimeout failed\n" );
9186 ok_sequence( WmUser
, "WmUser", FALSE
);
9188 DestroyWindow( info
.hwnd
);
9192 /****************** edit message test *************************/
9193 #define ID_EDIT 0x1234
9194 static const struct message sl_edit_setfocus
[] =
9196 { HCBT_SETFOCUS
, hook
},
9197 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
9198 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
9199 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
9200 { WM_SETFOCUS
, sent
|wparam
, 0 },
9201 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 10 },
9202 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 15 },
9203 { WM_CTLCOLOREDIT
, sent
|parent
},
9204 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 11 },
9205 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
9206 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
9207 { WM_COMMAND
, sent
|parent
|wparam
, MAKEWPARAM(ID_EDIT
, EN_SETFOCUS
) },
9210 static const struct message ml_edit_setfocus
[] =
9212 { HCBT_SETFOCUS
, hook
},
9213 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
9214 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
9215 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
9216 { WM_SETFOCUS
, sent
|wparam
, 0 },
9217 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 10 },
9218 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 11 },
9219 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
9220 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
9221 { WM_COMMAND
, sent
|parent
|wparam
, MAKEWPARAM(ID_EDIT
, EN_SETFOCUS
) },
9224 static const struct message sl_edit_killfocus
[] =
9226 { HCBT_SETFOCUS
, hook
},
9227 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
9228 { WM_KILLFOCUS
, sent
|wparam
, 0 },
9229 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
9230 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
9231 { WM_COMMAND
, sent
|parent
|wparam
, MAKEWPARAM(ID_EDIT
, EN_KILLFOCUS
) },
9232 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
9233 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 1 },
9236 static const struct message sl_edit_lbutton_dblclk
[] =
9238 { WM_LBUTTONDBLCLK
, sent
},
9239 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
9242 static const struct message sl_edit_lbutton_down
[] =
9244 { WM_LBUTTONDOWN
, sent
|wparam
|lparam
, 0, 0 },
9245 { HCBT_SETFOCUS
, hook
},
9246 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
9247 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
9248 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
9249 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
9250 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 10 },
9251 { WM_CTLCOLOREDIT
, sent
|parent
},
9252 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 11 },
9253 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
9254 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
9255 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
9256 { WM_COMMAND
, sent
|parent
|wparam
, MAKEWPARAM(ID_EDIT
, EN_SETFOCUS
) },
9257 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
9258 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
9259 { WM_CTLCOLOREDIT
, sent
|parent
|optional
},
9260 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 11 },
9261 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
9262 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
9265 static const struct message ml_edit_lbutton_down
[] =
9267 { WM_LBUTTONDOWN
, sent
|wparam
|lparam
, 0, 0 },
9268 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
9269 { HCBT_SETFOCUS
, hook
},
9270 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
9271 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
9272 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
9273 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
9274 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 10 },
9275 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 11 },
9276 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
9277 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
9278 { WM_COMMAND
, sent
|parent
|wparam
, MAKEWPARAM(ID_EDIT
, EN_SETFOCUS
) },
9281 static const struct message sl_edit_lbutton_up
[] =
9283 { WM_LBUTTONUP
, sent
|wparam
|lparam
, 0, 0 },
9284 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
9285 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, 0, 0 },
9286 { WM_CAPTURECHANGED
, sent
|defwinproc
},
9287 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
9290 static const struct message ml_edit_lbutton_up
[] =
9292 { WM_LBUTTONUP
, sent
|wparam
|lparam
, 0, 0 },
9293 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, 0, 0 },
9294 { WM_CAPTURECHANGED
, sent
|defwinproc
},
9298 static WNDPROC old_edit_proc
;
9300 static LRESULT CALLBACK
edit_hook_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
9302 static LONG defwndproc_counter
= 0;
9304 struct recvd_message msg
;
9306 if (ignore_message( message
)) return 0;
9309 msg
.message
= message
;
9310 msg
.flags
= sent
|wparam
|lparam
;
9311 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
9312 msg
.wParam
= wParam
;
9313 msg
.lParam
= lParam
;
9317 defwndproc_counter
++;
9318 ret
= CallWindowProcA(old_edit_proc
, hwnd
, message
, wParam
, lParam
);
9319 defwndproc_counter
--;
9324 static void subclass_edit(void)
9328 if (!GetClassInfoA(0, "edit", &cls
)) assert(0);
9330 old_edit_proc
= cls
.lpfnWndProc
;
9332 cls
.hInstance
= GetModuleHandle(0);
9333 cls
.lpfnWndProc
= edit_hook_proc
;
9334 cls
.lpszClassName
= "my_edit_class";
9335 UnregisterClass(cls
.lpszClassName
, cls
.hInstance
);
9336 if (!RegisterClassA(&cls
)) assert(0);
9339 static void test_edit_messages(void)
9345 log_all_parent_messages
++;
9347 parent
= CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
9348 100, 100, 200, 200, 0, 0, 0, NULL
);
9349 ok (parent
!= 0, "Failed to create parent window\n");
9351 /* test single line edit */
9352 hwnd
= CreateWindowExA(0, "my_edit_class", "test", WS_CHILD
,
9353 0, 0, 80, 20, parent
, (HMENU
)ID_EDIT
, 0, NULL
);
9354 ok(hwnd
!= 0, "Failed to create edit window\n");
9356 dlg_code
= SendMessageA(hwnd
, WM_GETDLGCODE
, 0, 0);
9357 ok(dlg_code
== (DLGC_WANTCHARS
|DLGC_HASSETSEL
|DLGC_WANTARROWS
), "wrong dlg_code %08x\n", dlg_code
);
9359 ShowWindow(hwnd
, SW_SHOW
);
9365 ok_sequence(sl_edit_setfocus
, "SetFocus(hwnd) on an edit", FALSE
);
9368 ok_sequence(sl_edit_killfocus
, "SetFocus(0) on an edit", FALSE
);
9374 SendMessageA(hwnd
, WM_LBUTTONDBLCLK
, 0, 0);
9375 ok_sequence(sl_edit_lbutton_dblclk
, "WM_LBUTTONDBLCLK on an edit", FALSE
);
9381 SendMessageA(hwnd
, WM_LBUTTONDOWN
, 0, 0);
9382 ok_sequence(sl_edit_lbutton_down
, "WM_LBUTTONDOWN on an edit", FALSE
);
9384 SendMessageA(hwnd
, WM_LBUTTONUP
, 0, 0);
9385 ok_sequence(sl_edit_lbutton_up
, "WM_LBUTTONUP on an edit", FALSE
);
9387 DestroyWindow(hwnd
);
9389 /* test multiline edit */
9390 hwnd
= CreateWindowExA(0, "my_edit_class", "test", WS_CHILD
| ES_MULTILINE
,
9391 0, 0, 80, 20, parent
, (HMENU
)ID_EDIT
, 0, NULL
);
9392 ok(hwnd
!= 0, "Failed to create edit window\n");
9394 dlg_code
= SendMessageA(hwnd
, WM_GETDLGCODE
, 0, 0);
9395 ok(dlg_code
== (DLGC_WANTCHARS
|DLGC_HASSETSEL
|DLGC_WANTARROWS
|DLGC_WANTALLKEYS
),
9396 "wrong dlg_code %08x\n", dlg_code
);
9398 ShowWindow(hwnd
, SW_SHOW
);
9404 ok_sequence(ml_edit_setfocus
, "SetFocus(hwnd) on multiline edit", FALSE
);
9407 ok_sequence(sl_edit_killfocus
, "SetFocus(0) on multiline edit", FALSE
);
9413 SendMessageA(hwnd
, WM_LBUTTONDBLCLK
, 0, 0);
9414 ok_sequence(sl_edit_lbutton_dblclk
, "WM_LBUTTONDBLCLK on multiline edit", FALSE
);
9420 SendMessageA(hwnd
, WM_LBUTTONDOWN
, 0, 0);
9421 ok_sequence(ml_edit_lbutton_down
, "WM_LBUTTONDOWN on multiline edit", FALSE
);
9423 SendMessageA(hwnd
, WM_LBUTTONUP
, 0, 0);
9424 ok_sequence(ml_edit_lbutton_up
, "WM_LBUTTONUP on multiline edit", FALSE
);
9426 DestroyWindow(hwnd
);
9427 DestroyWindow(parent
);
9429 log_all_parent_messages
--;
9432 /**************************** End of Edit test ******************************/
9434 static const struct message WmKeyDownSkippedSeq
[] =
9436 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 1 }, /* XP */
9439 static const struct message WmKeyDownWasDownSkippedSeq
[] =
9441 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0x40000001 }, /* XP */
9444 static const struct message WmKeyUpSkippedSeq
[] =
9446 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xc0000001 }, /* XP */
9449 static const struct message WmUserKeyUpSkippedSeq
[] =
9452 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xc0000001 }, /* XP */
9457 #define EV_SENDMSG 1
9463 HANDLE hevent
[3]; /* 0 - start/stop, 1 - SendMessage, 2 - ack */
9466 static DWORD CALLBACK
send_msg_thread_2(void *param
)
9469 struct peekmsg_info
*info
= param
;
9471 trace("thread: looping\n");
9472 SetEvent(info
->hevent
[EV_ACK
]);
9476 ret
= WaitForMultipleObjects(2, info
->hevent
, FALSE
, INFINITE
);
9480 case WAIT_OBJECT_0
+ EV_STOP
:
9481 trace("thread: exiting\n");
9484 case WAIT_OBJECT_0
+ EV_SENDMSG
:
9485 trace("thread: sending message\n");
9486 ok( SendNotifyMessageA(info
->hwnd
, WM_USER
, 0, 0),
9487 "SendNotifyMessageA failed error %u\n", GetLastError());
9488 SetEvent(info
->hevent
[EV_ACK
]);
9492 trace("unexpected return: %04x\n", ret
);
9500 static void test_PeekMessage(void)
9505 UINT qs_all_input
= QS_ALLINPUT
;
9506 UINT qs_input
= QS_INPUT
;
9508 struct peekmsg_info info
;
9510 info
.hwnd
= CreateWindowA("TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
9511 100, 100, 200, 200, 0, 0, 0, NULL
);
9513 ShowWindow(info
.hwnd
, SW_SHOW
);
9514 UpdateWindow(info
.hwnd
);
9515 SetFocus(info
.hwnd
);
9517 info
.hevent
[EV_STOP
] = CreateEventA(NULL
, 0, 0, NULL
);
9518 info
.hevent
[EV_SENDMSG
] = CreateEventA(NULL
, 0, 0, NULL
);
9519 info
.hevent
[EV_ACK
] = CreateEventA(NULL
, 0, 0, NULL
);
9521 hthread
= CreateThread(NULL
, 0, send_msg_thread_2
, &info
, 0, &tid
);
9522 WaitForSingleObject(info
.hevent
[EV_ACK
], 10000);
9527 SetLastError(0xdeadbeef);
9528 qstatus
= GetQueueStatus(qs_all_input
);
9529 if (GetLastError() == ERROR_INVALID_FLAGS
)
9531 trace("QS_RAWINPUT not supported on this platform\n");
9532 qs_all_input
&= ~QS_RAWINPUT
;
9533 qs_input
&= ~QS_RAWINPUT
;
9535 if (qstatus
& QS_POSTMESSAGE
)
9537 while (PeekMessage(&msg
, 0, 0, 0, PM_REMOVE
)) /* nothing */ ;
9538 qstatus
= GetQueueStatus(qs_all_input
);
9540 ok(qstatus
== 0, "wrong qstatus %08x\n", qstatus
);
9542 trace("signalling to send message\n");
9543 SetEvent(info
.hevent
[EV_SENDMSG
]);
9544 WaitForSingleObject(info
.hevent
[EV_ACK
], INFINITE
);
9546 /* pass invalid QS_xxxx flags */
9547 SetLastError(0xdeadbeef);
9548 qstatus
= GetQueueStatus(0xffffffff);
9549 ok(qstatus
== 0 || broken(qstatus
) /* win9x */, "GetQueueStatus should fail: %08x\n", qstatus
);
9552 ok(GetLastError() == ERROR_INVALID_FLAGS
, "wrong error %d\n", GetLastError());
9553 qstatus
= GetQueueStatus(qs_all_input
);
9555 qstatus
&= ~MAKELONG( 0x4000, 0x4000 ); /* sometimes set on Win95 */
9556 ok(qstatus
== MAKELONG(QS_SENDMESSAGE
, QS_SENDMESSAGE
),
9557 "wrong qstatus %08x\n", qstatus
);
9560 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
9562 "PeekMessageA should have returned FALSE instead of msg %04x\n",
9564 ok_sequence(WmUser
, "WmUser", FALSE
);
9566 qstatus
= GetQueueStatus(qs_all_input
);
9567 ok(qstatus
== 0, "wrong qstatus %08x\n", qstatus
);
9569 keybd_event('N', 0, 0, 0);
9570 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
9571 qstatus
= GetQueueStatus(qs_all_input
);
9572 if (!(qstatus
& MAKELONG(QS_KEY
, QS_KEY
)))
9574 skip( "queuing key events not supported\n" );
9577 ok(qstatus
== MAKELONG(QS_KEY
, QS_KEY
) ||
9578 /* keybd_event seems to trigger a sent message on NT4 */
9579 qstatus
== MAKELONG(QS_KEY
|QS_SENDMESSAGE
, QS_KEY
|QS_SENDMESSAGE
),
9580 "wrong qstatus %08x\n", qstatus
);
9582 PostMessageA(info
.hwnd
, WM_CHAR
, 'z', 0);
9583 qstatus
= GetQueueStatus(qs_all_input
);
9584 ok(qstatus
== MAKELONG(QS_POSTMESSAGE
, QS_POSTMESSAGE
|QS_KEY
) ||
9585 qstatus
== MAKELONG(QS_POSTMESSAGE
, QS_POSTMESSAGE
|QS_KEY
|QS_SENDMESSAGE
),
9586 "wrong qstatus %08x\n", qstatus
);
9588 InvalidateRect(info
.hwnd
, NULL
, FALSE
);
9589 qstatus
= GetQueueStatus(qs_all_input
);
9590 ok(qstatus
== MAKELONG(QS_PAINT
, QS_PAINT
|QS_POSTMESSAGE
|QS_KEY
) ||
9591 qstatus
== MAKELONG(QS_PAINT
, QS_PAINT
|QS_POSTMESSAGE
|QS_KEY
|QS_SENDMESSAGE
),
9592 "wrong qstatus %08x\n", qstatus
);
9594 trace("signalling to send message\n");
9595 SetEvent(info
.hevent
[EV_SENDMSG
]);
9596 WaitForSingleObject(info
.hevent
[EV_ACK
], INFINITE
);
9598 qstatus
= GetQueueStatus(qs_all_input
);
9599 ok(qstatus
== MAKELONG(QS_SENDMESSAGE
, QS_SENDMESSAGE
|QS_PAINT
|QS_POSTMESSAGE
|QS_KEY
),
9600 "wrong qstatus %08x\n", qstatus
);
9603 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| (qs_input
<< 16));
9604 if (ret
&& msg
.message
== WM_CHAR
)
9606 win_skip( "PM_QS_* flags not supported in PeekMessage\n" );
9610 "PeekMessageA should have returned FALSE instead of msg %04x\n",
9612 if (!sequence_cnt
) /* nt4 doesn't fetch anything with PM_QS_* flags */
9614 win_skip( "PM_QS_* flags not supported in PeekMessage\n" );
9617 ok_sequence(WmUser
, "WmUser", FALSE
);
9619 qstatus
= GetQueueStatus(qs_all_input
);
9620 ok(qstatus
== MAKELONG(0, QS_PAINT
|QS_POSTMESSAGE
|QS_KEY
),
9621 "wrong qstatus %08x\n", qstatus
);
9623 trace("signalling to send message\n");
9624 SetEvent(info
.hevent
[EV_SENDMSG
]);
9625 WaitForSingleObject(info
.hevent
[EV_ACK
], INFINITE
);
9627 qstatus
= GetQueueStatus(qs_all_input
);
9628 ok(qstatus
== MAKELONG(QS_SENDMESSAGE
, QS_SENDMESSAGE
|QS_PAINT
|QS_POSTMESSAGE
|QS_KEY
),
9629 "wrong qstatus %08x\n", qstatus
);
9632 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| PM_QS_POSTMESSAGE
);
9634 "PeekMessageA should have returned FALSE instead of msg %04x\n",
9636 ok_sequence(WmUser
, "WmUser", FALSE
);
9638 qstatus
= GetQueueStatus(qs_all_input
);
9639 ok(qstatus
== MAKELONG(0, QS_PAINT
|QS_POSTMESSAGE
|QS_KEY
),
9640 "wrong qstatus %08x\n", qstatus
);
9643 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| PM_QS_POSTMESSAGE
);
9644 ok(ret
&& msg
.message
== WM_CHAR
&& msg
.wParam
== 'z',
9645 "got %d and %04x wParam %08lx instead of TRUE and WM_CHAR wParam 'z'\n",
9646 ret
, msg
.message
, msg
.wParam
);
9647 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
9649 qstatus
= GetQueueStatus(qs_all_input
);
9650 ok(qstatus
== MAKELONG(0, QS_PAINT
|QS_KEY
),
9651 "wrong qstatus %08x\n", qstatus
);
9654 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| PM_QS_POSTMESSAGE
);
9656 "PeekMessageA should have returned FALSE instead of msg %04x\n",
9658 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
9660 qstatus
= GetQueueStatus(qs_all_input
);
9661 ok(qstatus
== MAKELONG(0, QS_PAINT
|QS_KEY
),
9662 "wrong qstatus %08x\n", qstatus
);
9665 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| PM_QS_PAINT
);
9666 ok(ret
&& msg
.message
== WM_PAINT
,
9667 "got %d and %04x instead of TRUE and WM_PAINT\n", ret
, msg
.message
);
9668 DispatchMessageA(&msg
);
9669 ok_sequence(WmPaint
, "WmPaint", FALSE
);
9671 qstatus
= GetQueueStatus(qs_all_input
);
9672 ok(qstatus
== MAKELONG(0, QS_KEY
),
9673 "wrong qstatus %08x\n", qstatus
);
9676 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| PM_QS_PAINT
);
9678 "PeekMessageA should have returned FALSE instead of msg %04x\n",
9680 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
9682 qstatus
= GetQueueStatus(qs_all_input
);
9683 ok(qstatus
== MAKELONG(0, QS_KEY
),
9684 "wrong qstatus %08x\n", qstatus
);
9686 trace("signalling to send message\n");
9687 SetEvent(info
.hevent
[EV_SENDMSG
]);
9688 WaitForSingleObject(info
.hevent
[EV_ACK
], INFINITE
);
9690 qstatus
= GetQueueStatus(qs_all_input
);
9691 ok(qstatus
== MAKELONG(QS_SENDMESSAGE
, QS_SENDMESSAGE
|QS_KEY
),
9692 "wrong qstatus %08x\n", qstatus
);
9694 PostMessageA(info
.hwnd
, WM_CHAR
, 'z', 0);
9696 qstatus
= GetQueueStatus(qs_all_input
);
9697 ok(qstatus
== MAKELONG(QS_POSTMESSAGE
, QS_SENDMESSAGE
|QS_POSTMESSAGE
|QS_KEY
),
9698 "wrong qstatus %08x\n", qstatus
);
9701 ret
= PeekMessageA(&msg
, 0, WM_CHAR
, WM_CHAR
, PM_REMOVE
);
9702 ok(ret
&& msg
.message
== WM_CHAR
&& msg
.wParam
== 'z',
9703 "got %d and %04x wParam %08lx instead of TRUE and WM_CHAR wParam 'z'\n",
9704 ret
, msg
.message
, msg
.wParam
);
9705 ok_sequence(WmUser
, "WmUser", FALSE
);
9707 qstatus
= GetQueueStatus(qs_all_input
);
9708 ok(qstatus
== MAKELONG(0, QS_KEY
),
9709 "wrong qstatus %08x\n", qstatus
);
9712 ret
= PeekMessageA(&msg
, 0, WM_CHAR
, WM_CHAR
, PM_REMOVE
);
9714 "PeekMessageA should have returned FALSE instead of msg %04x\n",
9716 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
9718 qstatus
= GetQueueStatus(qs_all_input
);
9719 ok(qstatus
== MAKELONG(0, QS_KEY
),
9720 "wrong qstatus %08x\n", qstatus
);
9722 PostMessageA(info
.hwnd
, WM_CHAR
, 'z', 0);
9724 qstatus
= GetQueueStatus(qs_all_input
);
9725 ok(qstatus
== MAKELONG(QS_POSTMESSAGE
, QS_POSTMESSAGE
|QS_KEY
),
9726 "wrong qstatus %08x\n", qstatus
);
9728 trace("signalling to send message\n");
9729 SetEvent(info
.hevent
[EV_SENDMSG
]);
9730 WaitForSingleObject(info
.hevent
[EV_ACK
], INFINITE
);
9732 qstatus
= GetQueueStatus(qs_all_input
);
9733 ok(qstatus
== MAKELONG(QS_SENDMESSAGE
, QS_SENDMESSAGE
|QS_POSTMESSAGE
|QS_KEY
),
9734 "wrong qstatus %08x\n", qstatus
);
9737 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| (QS_KEY
<< 16));
9739 "PeekMessageA should have returned FALSE instead of msg %04x\n",
9741 ok_sequence(WmUser
, "WmUser", FALSE
);
9743 qstatus
= GetQueueStatus(qs_all_input
);
9744 ok(qstatus
== MAKELONG(0, QS_POSTMESSAGE
|QS_KEY
),
9745 "wrong qstatus %08x\n", qstatus
);
9748 if (qs_all_input
& QS_RAWINPUT
) /* use QS_RAWINPUT only if supported */
9749 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| (QS_RAWINPUT
<< 16));
9750 else /* workaround for a missing QS_RAWINPUT support */
9751 ret
= PeekMessageA(&msg
, 0, WM_KEYDOWN
, WM_KEYDOWN
, PM_REMOVE
);
9752 ok(ret
&& msg
.message
== WM_KEYDOWN
&& msg
.wParam
== 'N',
9753 "got %d and %04x wParam %08lx instead of TRUE and WM_KEYDOWN wParam 'N'\n",
9754 ret
, msg
.message
, msg
.wParam
);
9755 ok_sequence(WmKeyDownSkippedSeq
, "WmKeyDownSkippedSeq", FALSE
);
9757 qstatus
= GetQueueStatus(qs_all_input
);
9758 ok(qstatus
== MAKELONG(0, QS_POSTMESSAGE
|QS_KEY
),
9759 "wrong qstatus %08x\n", qstatus
);
9762 if (qs_all_input
& QS_RAWINPUT
) /* use QS_RAWINPUT only if supported */
9763 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| (QS_RAWINPUT
<< 16));
9764 else /* workaround for a missing QS_RAWINPUT support */
9765 ret
= PeekMessageA(&msg
, 0, WM_KEYUP
, WM_KEYUP
, PM_REMOVE
);
9766 ok(ret
&& msg
.message
== WM_KEYUP
&& msg
.wParam
== 'N',
9767 "got %d and %04x wParam %08lx instead of TRUE and WM_KEYUP wParam 'N'\n",
9768 ret
, msg
.message
, msg
.wParam
);
9769 ok_sequence(WmKeyUpSkippedSeq
, "WmKeyUpSkippedSeq", FALSE
);
9771 qstatus
= GetQueueStatus(qs_all_input
);
9772 ok(qstatus
== MAKELONG(0, QS_POSTMESSAGE
),
9773 "wrong qstatus %08x\n", qstatus
);
9776 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| PM_QS_SENDMESSAGE
);
9778 "PeekMessageA should have returned FALSE instead of msg %04x\n",
9780 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
9782 qstatus
= GetQueueStatus(qs_all_input
);
9783 ok(qstatus
== MAKELONG(0, QS_POSTMESSAGE
),
9784 "wrong qstatus %08x\n", qstatus
);
9787 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
9788 ok(ret
&& msg
.message
== WM_CHAR
&& msg
.wParam
== 'z',
9789 "got %d and %04x wParam %08lx instead of TRUE and WM_CHAR wParam 'z'\n",
9790 ret
, msg
.message
, msg
.wParam
);
9791 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
9793 qstatus
= GetQueueStatus(qs_all_input
);
9795 "wrong qstatus %08x\n", qstatus
);
9798 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
9800 "PeekMessageA should have returned FALSE instead of msg %04x\n",
9802 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
9804 qstatus
= GetQueueStatus(qs_all_input
);
9806 "wrong qstatus %08x\n", qstatus
);
9808 /* test whether presence of the quit flag in the queue affects
9811 PostQuitMessage(0x1234abcd);
9813 qstatus
= GetQueueStatus(qs_all_input
);
9814 ok(qstatus
== MAKELONG(QS_POSTMESSAGE
, QS_POSTMESSAGE
),
9815 "wrong qstatus %08x\n", qstatus
);
9817 PostMessageA(info
.hwnd
, WM_USER
, 0, 0);
9819 qstatus
= GetQueueStatus(qs_all_input
);
9820 ok(qstatus
== MAKELONG(QS_POSTMESSAGE
, QS_POSTMESSAGE
),
9821 "wrong qstatus %08x\n", qstatus
);
9824 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
9825 ok(ret
&& msg
.message
== WM_USER
,
9826 "got %d and %04x instead of TRUE and WM_USER\n", ret
, msg
.message
);
9827 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
9829 qstatus
= GetQueueStatus(qs_all_input
);
9830 ok(qstatus
== MAKELONG(0, QS_POSTMESSAGE
),
9831 "wrong qstatus %08x\n", qstatus
);
9834 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
9835 ok(ret
&& msg
.message
== WM_QUIT
,
9836 "got %d and %04x instead of TRUE and WM_QUIT\n", ret
, msg
.message
);
9837 ok(msg
.wParam
== 0x1234abcd, "got wParam %08lx instead of 0x1234abcd\n", msg
.wParam
);
9838 ok(msg
.lParam
== 0, "got lParam %08lx instead of 0\n", msg
.lParam
);
9839 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
9841 qstatus
= GetQueueStatus(qs_all_input
);
9843 ok(qstatus
== MAKELONG(0, QS_POSTMESSAGE
),
9844 "wrong qstatus %08x\n", qstatus
);
9848 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
9850 "PeekMessageA should have returned FALSE instead of msg %04x\n",
9852 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
9854 qstatus
= GetQueueStatus(qs_all_input
);
9856 "wrong qstatus %08x\n", qstatus
);
9858 /* some GetMessage tests */
9860 keybd_event('N', 0, 0, 0);
9861 qstatus
= GetQueueStatus(qs_all_input
);
9862 ok(qstatus
== MAKELONG(QS_KEY
, QS_KEY
), "wrong qstatus %08x\n", qstatus
);
9864 PostMessageA(info
.hwnd
, WM_CHAR
, 'z', 0);
9865 qstatus
= GetQueueStatus(qs_all_input
);
9866 ok(qstatus
== MAKELONG(QS_POSTMESSAGE
, QS_POSTMESSAGE
|QS_KEY
), "wrong qstatus %08x\n", qstatus
);
9870 ret
= GetMessageA( &msg
, 0, 0, 0 );
9871 ok(ret
&& msg
.message
== WM_CHAR
&& msg
.wParam
== 'z',
9872 "got %d and %04x wParam %08lx instead of TRUE and WM_CHAR wParam 'z'\n",
9873 ret
, msg
.message
, msg
.wParam
);
9874 qstatus
= GetQueueStatus(qs_all_input
);
9875 ok(qstatus
== MAKELONG(0, QS_KEY
), "wrong qstatus %08x\n", qstatus
);
9880 ret
= GetMessageA( &msg
, 0, 0, 0 );
9881 ok(ret
&& msg
.message
== WM_KEYDOWN
&& msg
.wParam
== 'N',
9882 "got %d and %04x wParam %08lx instead of TRUE and WM_KEYDOWN wParam 'N'\n",
9883 ret
, msg
.message
, msg
.wParam
);
9884 ok_sequence(WmKeyDownSkippedSeq
, "WmKeyDownSkippedSeq", FALSE
);
9885 qstatus
= GetQueueStatus(qs_all_input
);
9886 ok(qstatus
== 0, "wrong qstatus %08x\n", qstatus
);
9889 keybd_event('N', 0, 0, 0);
9890 qstatus
= GetQueueStatus(qs_all_input
);
9891 ok(qstatus
== MAKELONG(QS_KEY
, QS_KEY
), "wrong qstatus %08x\n", qstatus
);
9893 PostMessageA(info
.hwnd
, WM_CHAR
, 'z', 0);
9894 qstatus
= GetQueueStatus(qs_all_input
);
9895 ok(qstatus
== MAKELONG(QS_POSTMESSAGE
, QS_POSTMESSAGE
|QS_KEY
), "wrong qstatus %08x\n", qstatus
);
9897 if (qstatus
& (QS_KEY
<< 16))
9899 ret
= GetMessageA( &msg
, 0, WM_KEYDOWN
, WM_KEYUP
);
9900 ok(ret
&& msg
.message
== WM_KEYDOWN
&& msg
.wParam
== 'N',
9901 "got %d and %04x wParam %08lx instead of TRUE and WM_KEYDOWN wParam 'N'\n",
9902 ret
, msg
.message
, msg
.wParam
);
9903 ok_sequence(WmKeyDownWasDownSkippedSeq
, "WmKeyDownWasDownSkippedSeq", FALSE
);
9904 qstatus
= GetQueueStatus(qs_all_input
);
9905 ok(qstatus
== MAKELONG(0, QS_POSTMESSAGE
), "wrong qstatus %08x\n", qstatus
);
9910 ret
= GetMessageA( &msg
, 0, WM_CHAR
, WM_CHAR
);
9911 ok(ret
&& msg
.message
== WM_CHAR
&& msg
.wParam
== 'z',
9912 "got %d and %04x wParam %08lx instead of TRUE and WM_CHAR wParam 'z'\n",
9913 ret
, msg
.message
, msg
.wParam
);
9914 qstatus
= GetQueueStatus(qs_all_input
);
9915 ok(qstatus
== 0, "wrong qstatus %08x\n", qstatus
);
9918 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
9919 qstatus
= GetQueueStatus(qs_all_input
);
9920 ok(qstatus
== MAKELONG(QS_KEY
, QS_KEY
), "wrong qstatus %08x\n", qstatus
);
9922 PostMessageA(info
.hwnd
, WM_CHAR
, 'z', 0);
9923 qstatus
= GetQueueStatus(qs_all_input
);
9924 ok(qstatus
== MAKELONG(QS_POSTMESSAGE
, QS_POSTMESSAGE
|QS_KEY
), "wrong qstatus %08x\n", qstatus
);
9926 trace("signalling to send message\n");
9927 SetEvent(info
.hevent
[EV_SENDMSG
]);
9928 WaitForSingleObject(info
.hevent
[EV_ACK
], INFINITE
);
9929 qstatus
= GetQueueStatus(qs_all_input
);
9930 ok(qstatus
== MAKELONG(QS_SENDMESSAGE
, QS_SENDMESSAGE
|QS_POSTMESSAGE
|QS_KEY
),
9931 "wrong qstatus %08x\n", qstatus
);
9933 if (qstatus
& (QS_KEY
<< 16))
9935 ret
= GetMessageA( &msg
, 0, WM_KEYDOWN
, WM_KEYUP
);
9936 ok(ret
&& msg
.message
== WM_KEYUP
&& msg
.wParam
== 'N',
9937 "got %d and %04x wParam %08lx instead of TRUE and WM_KEYDOWN wParam 'N'\n",
9938 ret
, msg
.message
, msg
.wParam
);
9939 ok_sequence(WmUserKeyUpSkippedSeq
, "WmUserKeyUpSkippedSeq", FALSE
);
9940 qstatus
= GetQueueStatus(qs_all_input
);
9941 ok(qstatus
== MAKELONG(0, QS_POSTMESSAGE
), "wrong qstatus %08x\n", qstatus
);
9946 ret
= GetMessageA( &msg
, 0, WM_CHAR
, WM_CHAR
);
9947 ok(ret
&& msg
.message
== WM_CHAR
&& msg
.wParam
== 'z',
9948 "got %d and %04x wParam %08lx instead of TRUE and WM_CHAR wParam 'z'\n",
9949 ret
, msg
.message
, msg
.wParam
);
9950 qstatus
= GetQueueStatus(qs_all_input
);
9951 ok(qstatus
== 0, "wrong qstatus %08x\n", qstatus
);
9954 trace("signalling to exit\n");
9955 SetEvent(info
.hevent
[EV_STOP
]);
9957 WaitForSingleObject(hthread
, INFINITE
);
9959 CloseHandle(hthread
);
9960 CloseHandle(info
.hevent
[0]);
9961 CloseHandle(info
.hevent
[1]);
9962 CloseHandle(info
.hevent
[2]);
9964 DestroyWindow(info
.hwnd
);
9967 static void wait_move_event(HWND hwnd
, int x
, int y
)
9974 time
= GetTickCount();
9975 while (GetTickCount() - time
< 200 && !go
) {
9976 ret
= PeekMessageA(&msg
, hwnd
, WM_MOUSEMOVE
, WM_MOUSEMOVE
, PM_NOREMOVE
);
9977 go
= ret
&& msg
.pt
.x
> x
&& msg
.pt
.y
> y
;
9978 if (!ret
) MsgWaitForMultipleObjects( 0, NULL
, FALSE
, GetTickCount() - time
, QS_ALLINPUT
);
9983 static void test_PeekMessage2(void)
9989 DWORD time1
, time2
, time3
;
9990 int x1
, y1
, x2
, y2
, x3
, y3
;
9993 time1
= time2
= time3
= 0;
9994 x1
= y1
= x2
= y2
= x3
= y3
= 0;
9996 /* Initialise window and make sure it is ready for events */
9997 hwnd
= CreateWindow("TestWindowClass", "PeekMessage2", WS_OVERLAPPEDWINDOW
,
9998 10, 10, 800, 800, NULL
, NULL
, NULL
, NULL
);
10000 trace("Window for test_PeekMessage2 %p\n", hwnd
);
10001 ShowWindow(hwnd
, SW_SHOW
);
10002 UpdateWindow(hwnd
);
10004 GetCursorPos(&pos
);
10005 SetCursorPos(100, 100);
10006 mouse_event(MOUSEEVENTF_MOVE
, -STEP
, -STEP
, 0, 0);
10009 /* Do initial mousemove, wait until we can see it
10010 and then do our test peek with PM_NOREMOVE. */
10011 mouse_event(MOUSEEVENTF_MOVE
, STEP
, STEP
, 0, 0);
10012 wait_move_event(hwnd
, 100-STEP
, 100-STEP
);
10014 ret
= PeekMessageA(&msg
, hwnd
, WM_MOUSEMOVE
, WM_MOUSEMOVE
, PM_NOREMOVE
);
10017 skip( "queuing mouse events not supported\n" );
10022 trace("1st move event: %04x %x %d %d\n", msg
.message
, msg
.time
, msg
.pt
.x
, msg
.pt
.y
);
10023 message
= msg
.message
;
10027 ok(message
== WM_MOUSEMOVE
, "message not WM_MOUSEMOVE, %04x instead\n", message
);
10030 /* Allow time to advance a bit, and then simulate the user moving their
10031 * mouse around. After that we peek again with PM_NOREMOVE.
10032 * Although the previous mousemove message was never removed, the
10033 * mousemove we now peek should reflect the recent mouse movements
10034 * because the input queue will merge the move events. */
10036 mouse_event(MOUSEEVENTF_MOVE
, STEP
, STEP
, 0, 0);
10037 wait_move_event(hwnd
, x1
, y1
);
10039 ret
= PeekMessageA(&msg
, hwnd
, WM_MOUSEMOVE
, WM_MOUSEMOVE
, PM_NOREMOVE
);
10040 ok(ret
, "no message available\n");
10042 trace("2nd move event: %04x %x %d %d\n", msg
.message
, msg
.time
, msg
.pt
.x
, msg
.pt
.y
);
10043 message
= msg
.message
;
10047 ok(message
== WM_MOUSEMOVE
, "message not WM_MOUSEMOVE, %04x instead\n", message
);
10048 ok(time2
> time1
, "message time not advanced: %x %x\n", time1
, time2
);
10049 ok(x2
!= x1
&& y2
!= y1
, "coords not changed: (%d %d) (%d %d)\n", x1
, y1
, x2
, y2
);
10052 /* Have another go, to drive the point home */
10054 mouse_event(MOUSEEVENTF_MOVE
, STEP
, STEP
, 0, 0);
10055 wait_move_event(hwnd
, x2
, y2
);
10057 ret
= PeekMessageA(&msg
, hwnd
, WM_MOUSEMOVE
, WM_MOUSEMOVE
, PM_NOREMOVE
);
10058 ok(ret
, "no message available\n");
10060 trace("3rd move event: %04x %x %d %d\n", msg
.message
, msg
.time
, msg
.pt
.x
, msg
.pt
.y
);
10061 message
= msg
.message
;
10065 ok(message
== WM_MOUSEMOVE
, "message not WM_MOUSEMOVE, %04x instead\n", message
);
10066 ok(time3
> time2
, "message time not advanced: %x %x\n", time2
, time3
);
10067 ok(x3
!= x2
&& y3
!= y2
, "coords not changed: (%d %d) (%d %d)\n", x2
, y2
, x3
, y3
);
10071 DestroyWindow(hwnd
);
10072 SetCursorPos(pos
.x
, pos
.y
);
10076 static INT_PTR CALLBACK
wm_quit_dlg_proc(HWND hwnd
, UINT message
, WPARAM wp
, LPARAM lp
)
10078 struct recvd_message msg
;
10080 if (ignore_message( message
)) return 0;
10083 msg
.message
= message
;
10084 msg
.flags
= sent
|wparam
|lparam
;
10087 msg
.descr
= "dialog";
10092 case WM_INITDIALOG
:
10093 PostMessage(hwnd
, WM_QUIT
, 0x1234, 0x5678);
10094 PostMessage(hwnd
, WM_USER
, 0xdead, 0xbeef);
10097 case WM_GETDLGCODE
:
10101 EndDialog(hwnd
, 0);
10108 static const struct message WmQuitDialogSeq
[] = {
10109 { HCBT_CREATEWND
, hook
},
10110 { WM_SETFONT
, sent
},
10111 { WM_INITDIALOG
, sent
},
10112 { WM_CHANGEUISTATE
, sent
|optional
},
10113 { HCBT_DESTROYWND
, hook
},
10114 { 0x0090, sent
|optional
}, /* Vista */
10115 { WM_DESTROY
, sent
},
10116 { WM_NCDESTROY
, sent
},
10120 static void test_quit_message(void)
10125 /* test using PostQuitMessage */
10127 PostQuitMessage(0xbeef);
10129 ret
= PeekMessage(&msg
, NULL
, 0, 0, PM_NOREMOVE
);
10130 ok(ret
, "PeekMessage failed with error %d\n", GetLastError());
10131 ok(msg
.message
== WM_QUIT
, "Received message 0x%04x instead of WM_QUIT\n", msg
.message
);
10132 ok(msg
.wParam
== 0xbeef, "wParam was 0x%lx instead of 0xbeef\n", msg
.wParam
);
10134 ret
= PostThreadMessage(GetCurrentThreadId(), WM_USER
, 0, 0);
10135 ok(ret
, "PostMessage failed with error %d\n", GetLastError());
10137 ret
= GetMessage(&msg
, NULL
, 0, 0);
10138 ok(ret
> 0, "GetMessage failed with error %d\n", GetLastError());
10139 ok(msg
.message
== WM_USER
, "Received message 0x%04x instead of WM_USER\n", msg
.message
);
10141 /* note: WM_QUIT message received after WM_USER message */
10142 ret
= GetMessage(&msg
, NULL
, 0, 0);
10143 ok(!ret
, "GetMessage return %d with error %d instead of FALSE\n", ret
, GetLastError());
10144 ok(msg
.message
== WM_QUIT
, "Received message 0x%04x instead of WM_QUIT\n", msg
.message
);
10145 ok(msg
.wParam
== 0xbeef, "wParam was 0x%lx instead of 0xbeef\n", msg
.wParam
);
10147 ret
= PeekMessage(&msg
, NULL
, 0, 0, PM_REMOVE
);
10148 ok( !ret
|| msg
.message
!= WM_QUIT
, "Received WM_QUIT again\n" );
10150 /* now test with PostThreadMessage - different behaviour! */
10151 PostThreadMessage(GetCurrentThreadId(), WM_QUIT
, 0xdead, 0);
10153 ret
= PeekMessage(&msg
, NULL
, 0, 0, PM_NOREMOVE
);
10154 ok(ret
, "PeekMessage failed with error %d\n", GetLastError());
10155 ok(msg
.message
== WM_QUIT
, "Received message 0x%04x instead of WM_QUIT\n", msg
.message
);
10156 ok(msg
.wParam
== 0xdead, "wParam was 0x%lx instead of 0xdead\n", msg
.wParam
);
10158 ret
= PostThreadMessage(GetCurrentThreadId(), WM_USER
, 0, 0);
10159 ok(ret
, "PostMessage failed with error %d\n", GetLastError());
10161 /* note: we receive the WM_QUIT message first this time */
10162 ret
= GetMessage(&msg
, NULL
, 0, 0);
10163 ok(!ret
, "GetMessage return %d with error %d instead of FALSE\n", ret
, GetLastError());
10164 ok(msg
.message
== WM_QUIT
, "Received message 0x%04x instead of WM_QUIT\n", msg
.message
);
10165 ok(msg
.wParam
== 0xdead, "wParam was 0x%lx instead of 0xdead\n", msg
.wParam
);
10167 ret
= GetMessage(&msg
, NULL
, 0, 0);
10168 ok(ret
> 0, "GetMessage failed with error %d\n", GetLastError());
10169 ok(msg
.message
== WM_USER
, "Received message 0x%04x instead of WM_USER\n", msg
.message
);
10173 ret
= DialogBoxParam(GetModuleHandle(0), "TEST_EMPTY_DIALOG", 0, wm_quit_dlg_proc
, 0);
10174 ok(ret
== 1, "expected 1, got %d\n", ret
);
10175 ok_sequence(WmQuitDialogSeq
, "WmQuitDialogSeq", FALSE
);
10176 memset(&msg
, 0xab, sizeof(msg
));
10177 ret
= PeekMessage(&msg
, NULL
, 0, 0, PM_REMOVE
);
10178 ok(ret
, "PeekMessage failed\n");
10179 ok(msg
.message
== WM_QUIT
, "Received message 0x%04x instead of WM_QUIT\n", msg
.message
);
10180 ok(msg
.wParam
== 0x1234, "wParam was 0x%lx instead of 0x1234\n", msg
.wParam
);
10181 ok(msg
.lParam
== 0, "lParam was 0x%lx instead of 0\n", msg
.lParam
);
10184 static const struct message WmMouseHoverSeq
[] = {
10185 { WM_MOUSEACTIVATE
, sent
|optional
}, /* we can get those when moving the mouse in focus-follow-mouse mode under X11 */
10186 { WM_MOUSEACTIVATE
, sent
|optional
},
10187 { WM_TIMER
, sent
|optional
}, /* XP sends it */
10188 { WM_SYSTIMER
, sent
},
10189 { WM_MOUSEHOVER
, sent
|wparam
, 0 },
10193 static void pump_msg_loop_timeout(DWORD timeout
, BOOL inject_mouse_move
)
10196 DWORD start_ticks
, end_ticks
;
10198 start_ticks
= GetTickCount();
10199 /* add some deviation (50%) to cover not expected delays */
10200 start_ticks
+= timeout
/ 2;
10204 while (PeekMessage(&msg
, 0, 0, 0, PM_REMOVE
))
10206 /* Timer proc messages are not dispatched to the window proc,
10207 * and therefore not logged.
10209 if ((msg
.message
== WM_TIMER
|| msg
.message
== WM_SYSTIMER
) && msg
.hwnd
)
10211 struct recvd_message s_msg
;
10213 s_msg
.hwnd
= msg
.hwnd
;
10214 s_msg
.message
= msg
.message
;
10215 s_msg
.flags
= sent
|wparam
|lparam
;
10216 s_msg
.wParam
= msg
.wParam
;
10217 s_msg
.lParam
= msg
.lParam
;
10218 s_msg
.descr
= "msg_loop";
10219 add_message(&s_msg
);
10221 DispatchMessage(&msg
);
10224 end_ticks
= GetTickCount();
10226 /* inject WM_MOUSEMOVE to see how it changes tracking */
10227 if (inject_mouse_move
&& start_ticks
+ timeout
/ 2 >= end_ticks
)
10229 mouse_event(MOUSEEVENTF_MOVE
, -1, 0, 0, 0);
10230 mouse_event(MOUSEEVENTF_MOVE
, 1, 0, 0, 0);
10232 inject_mouse_move
= FALSE
;
10234 } while (start_ticks
+ timeout
>= end_ticks
);
10237 static void test_TrackMouseEvent(void)
10239 TRACKMOUSEEVENT tme
;
10242 RECT rc_parent
, rc_child
;
10243 UINT default_hover_time
, hover_width
= 0, hover_height
= 0;
10245 #define track_hover(track_hwnd, track_hover_time) \
10246 tme.cbSize = sizeof(tme); \
10247 tme.dwFlags = TME_HOVER; \
10248 tme.hwndTrack = track_hwnd; \
10249 tme.dwHoverTime = track_hover_time; \
10250 SetLastError(0xdeadbeef); \
10251 ret = pTrackMouseEvent(&tme); \
10252 ok(ret, "TrackMouseEvent(TME_HOVER) error %d\n", GetLastError())
10254 #define track_query(expected_track_flags, expected_track_hwnd, expected_hover_time) \
10255 tme.cbSize = sizeof(tme); \
10256 tme.dwFlags = TME_QUERY; \
10257 tme.hwndTrack = (HWND)0xdeadbeef; \
10258 tme.dwHoverTime = 0xdeadbeef; \
10259 SetLastError(0xdeadbeef); \
10260 ret = pTrackMouseEvent(&tme); \
10261 ok(ret, "TrackMouseEvent(TME_QUERY) error %d\n", GetLastError());\
10262 ok(tme.cbSize == sizeof(tme), "wrong tme.cbSize %u\n", tme.cbSize); \
10263 ok(tme.dwFlags == (expected_track_flags), \
10264 "wrong tme.dwFlags %08x, expected %08x\n", tme.dwFlags, (expected_track_flags)); \
10265 ok(tme.hwndTrack == (expected_track_hwnd), \
10266 "wrong tme.hwndTrack %p, expected %p\n", tme.hwndTrack, (expected_track_hwnd)); \
10267 ok(tme.dwHoverTime == (expected_hover_time), \
10268 "wrong tme.dwHoverTime %u, expected %u\n", tme.dwHoverTime, (expected_hover_time))
10270 #define track_hover_cancel(track_hwnd) \
10271 tme.cbSize = sizeof(tme); \
10272 tme.dwFlags = TME_HOVER | TME_CANCEL; \
10273 tme.hwndTrack = track_hwnd; \
10274 tme.dwHoverTime = 0xdeadbeef; \
10275 SetLastError(0xdeadbeef); \
10276 ret = pTrackMouseEvent(&tme); \
10277 ok(ret, "TrackMouseEvent(TME_HOVER | TME_CANCEL) error %d\n", GetLastError())
10279 default_hover_time
= 0xdeadbeef;
10280 SetLastError(0xdeadbeef);
10281 ret
= SystemParametersInfo(SPI_GETMOUSEHOVERTIME
, 0, &default_hover_time
, 0);
10282 ok(ret
|| broken(GetLastError() == 0xdeadbeef), /* win9x */
10283 "SystemParametersInfo(SPI_GETMOUSEHOVERTIME) error %u\n", GetLastError());
10284 if (!ret
) default_hover_time
= 400;
10285 trace("SPI_GETMOUSEHOVERTIME returned %u ms\n", default_hover_time
);
10287 SetLastError(0xdeadbeef);
10288 ret
= SystemParametersInfo(SPI_GETMOUSEHOVERWIDTH
, 0, &hover_width
, 0);
10289 ok(ret
|| broken(GetLastError() == 0xdeadbeef), /* win9x */
10290 "SystemParametersInfo(SPI_GETMOUSEHOVERWIDTH) error %u\n", GetLastError());
10291 if (!ret
) hover_width
= 4;
10292 SetLastError(0xdeadbeef);
10293 ret
= SystemParametersInfo(SPI_GETMOUSEHOVERHEIGHT
, 0, &hover_height
, 0);
10294 ok(ret
|| broken(GetLastError() == 0xdeadbeef), /* win9x */
10295 "SystemParametersInfo(SPI_GETMOUSEHOVERHEIGHT) error %u\n", GetLastError());
10296 if (!ret
) hover_height
= 4;
10297 trace("hover rect is %u x %d\n", hover_width
, hover_height
);
10299 hwnd
= CreateWindowEx(0, "TestWindowClass", NULL
,
10300 WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
10301 CW_USEDEFAULT
, CW_USEDEFAULT
, 300, 300, 0,
10305 hchild
= CreateWindowEx(0, "TestWindowClass", NULL
,
10306 WS_CHILD
| WS_BORDER
| WS_VISIBLE
,
10307 50, 50, 200, 200, hwnd
,
10311 SetWindowPos( hwnd
, HWND_TOPMOST
, 0, 0, 0, 0, SWP_NOSIZE
|SWP_NOMOVE
);
10316 tme
.dwFlags
= TME_QUERY
;
10317 tme
.hwndTrack
= (HWND
)0xdeadbeef;
10318 tme
.dwHoverTime
= 0xdeadbeef;
10319 SetLastError(0xdeadbeef);
10320 ret
= pTrackMouseEvent(&tme
);
10321 ok(!ret
, "TrackMouseEvent should fail\n");
10322 ok(GetLastError() == ERROR_INVALID_PARAMETER
|| broken(GetLastError() == 0xdeadbeef),
10323 "not expected error %u\n", GetLastError());
10325 tme
.cbSize
= sizeof(tme
);
10326 tme
.dwFlags
= TME_HOVER
;
10327 tme
.hwndTrack
= (HWND
)0xdeadbeef;
10328 tme
.dwHoverTime
= 0xdeadbeef;
10329 SetLastError(0xdeadbeef);
10330 ret
= pTrackMouseEvent(&tme
);
10331 ok(!ret
, "TrackMouseEvent should fail\n");
10332 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
|| broken(GetLastError() == 0xdeadbeef),
10333 "not expected error %u\n", GetLastError());
10335 tme
.cbSize
= sizeof(tme
);
10336 tme
.dwFlags
= TME_HOVER
| TME_CANCEL
;
10337 tme
.hwndTrack
= (HWND
)0xdeadbeef;
10338 tme
.dwHoverTime
= 0xdeadbeef;
10339 SetLastError(0xdeadbeef);
10340 ret
= pTrackMouseEvent(&tme
);
10341 ok(!ret
, "TrackMouseEvent should fail\n");
10342 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
|| broken(GetLastError() == 0xdeadbeef),
10343 "not expected error %u\n", GetLastError());
10345 GetWindowRect(hwnd
, &rc_parent
);
10346 GetWindowRect(hchild
, &rc_child
);
10347 SetCursorPos(rc_child
.left
- 10, rc_child
.top
- 10);
10349 /* Process messages so that the system updates its internal current
10350 * window and hittest, otherwise TrackMouseEvent calls don't have any
10356 track_query(0, NULL
, 0);
10357 track_hover(hchild
, 0);
10358 track_query(0, NULL
, 0);
10363 track_hover(hwnd
, 0);
10364 tme
.cbSize
= sizeof(tme
);
10365 tme
.dwFlags
= TME_QUERY
;
10366 tme
.hwndTrack
= (HWND
)0xdeadbeef;
10367 tme
.dwHoverTime
= 0xdeadbeef;
10368 SetLastError(0xdeadbeef);
10369 ret
= pTrackMouseEvent(&tme
);
10370 ok(ret
, "TrackMouseEvent(TME_QUERY) error %d\n", GetLastError());
10371 ok(tme
.cbSize
== sizeof(tme
), "wrong tme.cbSize %u\n", tme
.cbSize
);
10374 skip( "Cursor not inside window, skipping TrackMouseEvent tests\n" );
10375 DestroyWindow( hwnd
);
10378 ok(tme
.dwFlags
== TME_HOVER
, "wrong tme.dwFlags %08x, expected TME_HOVER\n", tme
.dwFlags
);
10379 ok(tme
.hwndTrack
== hwnd
, "wrong tme.hwndTrack %p, expected %p\n", tme
.hwndTrack
, hwnd
);
10380 ok(tme
.dwHoverTime
== default_hover_time
, "wrong tme.dwHoverTime %u, expected %u\n",
10381 tme
.dwHoverTime
, default_hover_time
);
10383 pump_msg_loop_timeout(default_hover_time
, FALSE
);
10384 ok_sequence(WmMouseHoverSeq
, "WmMouseHoverSeq", FALSE
);
10386 track_query(0, NULL
, 0);
10388 track_hover(hwnd
, HOVER_DEFAULT
);
10389 track_query(TME_HOVER
, hwnd
, default_hover_time
);
10391 Sleep(default_hover_time
/ 2);
10392 mouse_event(MOUSEEVENTF_MOVE
, -1, 0, 0, 0);
10393 mouse_event(MOUSEEVENTF_MOVE
, 1, 0, 0, 0);
10395 track_query(TME_HOVER
, hwnd
, default_hover_time
);
10397 pump_msg_loop_timeout(default_hover_time
, FALSE
);
10398 ok_sequence(WmMouseHoverSeq
, "WmMouseHoverSeq", FALSE
);
10400 track_query(0, NULL
, 0);
10402 track_hover(hwnd
, HOVER_DEFAULT
);
10403 track_query(TME_HOVER
, hwnd
, default_hover_time
);
10405 pump_msg_loop_timeout(default_hover_time
, TRUE
);
10406 ok_sequence(WmMouseHoverSeq
, "WmMouseHoverSeq", FALSE
);
10408 track_query(0, NULL
, 0);
10410 track_hover(hwnd
, HOVER_DEFAULT
);
10411 track_query(TME_HOVER
, hwnd
, default_hover_time
);
10412 track_hover_cancel(hwnd
);
10414 DestroyWindow(hwnd
);
10418 #undef track_hover_cancel
10422 static const struct message WmSetWindowRgn
[] = {
10423 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
},
10424 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
10425 { WM_NCPAINT
, sent
|optional
}, /* wparam != 1 */
10426 { WM_GETTEXT
, sent
|defwinproc
|optional
},
10427 { WM_ERASEBKGND
, sent
|optional
},
10428 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
},
10429 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
10433 static const struct message WmSetWindowRgn_no_redraw
[] = {
10434 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
},
10435 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
10436 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
},
10437 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
10441 static const struct message WmSetWindowRgn_clear
[] = {
10442 { WM_WINDOWPOSCHANGING
, sent
/*|wparam*/, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
/*|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE only on some Windows versions */ },
10443 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
10444 { WM_NCPAINT
, sent
|optional
},
10445 { WM_GETTEXT
, sent
|defwinproc
|optional
},
10446 { WM_ERASEBKGND
, sent
|optional
}, /* FIXME: remove optional once Wine is fixed */
10447 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
},
10448 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
10449 { WM_NCPAINT
, sent
|optional
},
10450 { WM_GETTEXT
, sent
|defwinproc
|optional
},
10451 { WM_ERASEBKGND
, sent
|optional
},
10452 { WM_WINDOWPOSCHANGING
, sent
|optional
},
10453 { WM_NCCALCSIZE
, sent
|optional
|wparam
, 1 },
10454 { WM_NCPAINT
, sent
|optional
},
10455 { WM_GETTEXT
, sent
|defwinproc
|optional
},
10456 { WM_ERASEBKGND
, sent
|optional
},
10457 { WM_WINDOWPOSCHANGED
, sent
|optional
|wparam
, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
},
10458 { WM_NCCALCSIZE
, sent
|optional
|wparam
, 1 },
10459 { WM_NCPAINT
, sent
|optional
},
10460 { WM_GETTEXT
, sent
|defwinproc
|optional
},
10461 { WM_ERASEBKGND
, sent
|optional
},
10462 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
10463 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
10467 static void test_SetWindowRgn(void)
10470 HWND hwnd
= CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW
,
10471 100, 100, 200, 200, 0, 0, 0, NULL
);
10472 ok( hwnd
!= 0, "Failed to create overlapped window\n" );
10474 ShowWindow( hwnd
, SW_SHOW
);
10475 UpdateWindow( hwnd
);
10479 trace("testing SetWindowRgn\n");
10480 hrgn
= CreateRectRgn( 0, 0, 150, 150 );
10481 SetWindowRgn( hwnd
, hrgn
, TRUE
);
10482 ok_sequence( WmSetWindowRgn
, "WmSetWindowRgn", FALSE
);
10484 hrgn
= CreateRectRgn( 30, 30, 160, 160 );
10485 SetWindowRgn( hwnd
, hrgn
, FALSE
);
10486 ok_sequence( WmSetWindowRgn_no_redraw
, "WmSetWindowRgn_no_redraw", FALSE
);
10488 hrgn
= CreateRectRgn( 0, 0, 180, 180 );
10489 SetWindowRgn( hwnd
, hrgn
, TRUE
);
10490 ok_sequence( WmSetWindowRgn
, "WmSetWindowRgn2", FALSE
);
10492 SetWindowRgn( hwnd
, 0, TRUE
);
10493 ok_sequence( WmSetWindowRgn_clear
, "WmSetWindowRgn_clear", FALSE
);
10495 DestroyWindow( hwnd
);
10498 /*************************** ShowWindow() test ******************************/
10499 static const struct message WmShowNormal
[] = {
10500 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
10501 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
10502 { HCBT_ACTIVATE
, hook
},
10503 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2003 doesn't send it */
10504 { HCBT_SETFOCUS
, hook
},
10505 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
10508 static const struct message WmShow
[] = {
10509 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
10510 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
10511 { HCBT_ACTIVATE
, hook
|optional
}, /* win2000 doesn't send it */
10512 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2000 doesn't send it */
10513 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 doesn't send it */
10514 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
10517 static const struct message WmShowNoActivate_1
[] = {
10518 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWNOACTIVATE
},
10519 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_STATECHANGED
, 0, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOSIZE
|SWP_NOMOVE
},
10520 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_STATECHANGED
, 0, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOSIZE
|SWP_NOMOVE
},
10521 { WM_MOVE
, sent
|defwinproc
|optional
},
10522 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_RESTORED
},
10525 static const struct message WmShowNoActivate_2
[] = {
10526 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWNOACTIVATE
},
10527 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
10528 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
10529 { WM_MOVE
, sent
|defwinproc
},
10530 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_RESTORED
},
10531 { HCBT_SETFOCUS
, hook
|optional
},
10532 { HCBT_ACTIVATE
, hook
|optional
}, /* win2003 doesn't send it */
10533 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2003 doesn't send it */
10534 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
10535 { HCBT_SETFOCUS
, hook
|optional
}, /* win2003 doesn't send it */
10538 static const struct message WmShowNA_1
[] = {
10539 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
10540 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
10541 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
10544 static const struct message WmShowNA_2
[] = {
10545 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
10546 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
10547 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
10550 static const struct message WmRestore_1
[] = {
10551 { HCBT_MINMAX
, hook
|lparam
, 0, SW_RESTORE
},
10552 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
10553 { HCBT_ACTIVATE
, hook
|optional
}, /* win2000 doesn't send it */
10554 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2000 doesn't send it */
10555 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 doesn't send it */
10556 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
10557 { WM_MOVE
, sent
|defwinproc
},
10558 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_RESTORED
},
10559 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 sends it */
10562 static const struct message WmRestore_2
[] = {
10563 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
10564 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
10565 { HCBT_ACTIVATE
, hook
|optional
}, /* win2000 doesn't send it */
10566 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2000 doesn't send it */
10567 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 doesn't send it */
10568 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
10571 static const struct message WmRestore_3
[] = {
10572 { HCBT_MINMAX
, hook
|lparam
, 0, SW_RESTORE
},
10573 { WM_GETMINMAXINFO
, sent
},
10574 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
10575 { HCBT_ACTIVATE
, hook
|optional
}, /* win2003 doesn't send it */
10576 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2003 doesn't send it */
10577 { HCBT_SETFOCUS
, hook
|optional
}, /* win2003 doesn't send it */
10578 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
10579 { WM_MOVE
, sent
|defwinproc
},
10580 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_MAXIMIZED
},
10581 { HCBT_SETFOCUS
, hook
|optional
}, /* win2003 sends it */
10584 static const struct message WmRestore_4
[] = {
10585 { HCBT_MINMAX
, hook
|lparam
|optional
, 0, SW_RESTORE
},
10586 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_FRAMECHANGED
|SWP_STATECHANGED
, 0, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOSIZE
|SWP_NOMOVE
},
10587 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_FRAMECHANGED
|SWP_STATECHANGED
, 0, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOSIZE
|SWP_NOMOVE
},
10588 { WM_MOVE
, sent
|defwinproc
|optional
},
10589 { WM_SIZE
, sent
|wparam
|defwinproc
|optional
, SIZE_RESTORED
},
10592 static const struct message WmRestore_5
[] = {
10593 { HCBT_MINMAX
, hook
|lparam
|optional
, 0, SW_SHOWNORMAL
},
10594 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_FRAMECHANGED
|SWP_STATECHANGED
, 0, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOSIZE
|SWP_NOMOVE
},
10595 { HCBT_ACTIVATE
, hook
|optional
},
10596 { HCBT_SETFOCUS
, hook
|optional
},
10597 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_FRAMECHANGED
|SWP_STATECHANGED
, 0, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOSIZE
|SWP_NOMOVE
},
10598 { WM_MOVE
, sent
|defwinproc
|optional
},
10599 { WM_SIZE
, sent
|wparam
|defwinproc
|optional
, SIZE_RESTORED
},
10602 static const struct message WmHide_1
[] = {
10603 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
10604 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
, 0, SWP_NOACTIVATE
},
10605 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
, 0, SWP_NOACTIVATE
},
10606 { HCBT_ACTIVATE
, hook
|optional
},
10607 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 sends it */
10610 static const struct message WmHide_2
[] = {
10611 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
10612 { WM_WINDOWPOSCHANGING
, sent
/*|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE*/ }, /* win2000 doesn't add SWP_NOACTIVATE */
10613 { WM_WINDOWPOSCHANGED
, sent
/*|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE*/ }, /* win2000 doesn't add SWP_NOACTIVATE */
10614 { HCBT_ACTIVATE
, hook
|optional
},
10617 static const struct message WmHide_3
[] = {
10618 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
10619 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
10620 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
10621 { HCBT_SETFOCUS
, hook
|optional
},
10622 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
10625 static const struct message WmShowMinimized_1
[] = {
10626 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINIMIZED
},
10627 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
10628 { HCBT_ACTIVATE
, hook
|optional
}, /* win2000 doesn't send it */
10629 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2000 doesn't send it */
10630 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
10631 { WM_MOVE
, sent
|defwinproc
},
10632 { WM_SIZE
, sent
|wparam
|lparam
|defwinproc
, SIZE_MINIMIZED
, 0 },
10635 static const struct message WmMinimize_1
[] = {
10636 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
10637 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 doesn't send it */
10638 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
10639 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
10640 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
10641 { WM_MOVE
, sent
|defwinproc
},
10642 { WM_SIZE
, sent
|wparam
|lparam
|defwinproc
, SIZE_MINIMIZED
, 0 },
10645 static const struct message WmMinimize_2
[] = {
10646 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
10647 { HCBT_SETFOCUS
, hook
|optional
},
10648 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
10649 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
10650 { WM_MOVE
, sent
|defwinproc
},
10651 { WM_SIZE
, sent
|wparam
|lparam
|defwinproc
, SIZE_MINIMIZED
, 0 },
10654 static const struct message WmMinimize_3
[] = {
10655 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
10656 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
10657 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
10658 { WM_MOVE
, sent
|defwinproc
},
10659 { WM_SIZE
, sent
|wparam
|lparam
|defwinproc
, SIZE_MINIMIZED
, 0 },
10662 static const struct message WmShowMinNoActivate
[] = {
10663 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINNOACTIVE
},
10664 { WM_WINDOWPOSCHANGING
, sent
},
10665 { WM_WINDOWPOSCHANGED
, sent
},
10666 { WM_MOVE
, sent
|defwinproc
|optional
},
10667 { WM_SIZE
, sent
|wparam
|lparam
|defwinproc
|optional
, SIZE_MINIMIZED
, 0 },
10670 static const struct message WmMinMax_1
[] = {
10671 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINIMIZED
},
10674 static const struct message WmMinMax_2
[] = {
10675 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMAXIMIZED
},
10676 { WM_GETMINMAXINFO
, sent
|optional
},
10677 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
10678 { HCBT_ACTIVATE
, hook
|optional
},
10679 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
10680 { HCBT_SETFOCUS
, hook
|optional
},
10681 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_FRAMECHANGED
|SWP_STATECHANGED
, 0, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
10682 { WM_MOVE
, sent
|defwinproc
|optional
},
10683 { WM_SIZE
, sent
|wparam
|defwinproc
|optional
, SIZE_MAXIMIZED
},
10684 { HCBT_SETFOCUS
, hook
|optional
},
10687 static const struct message WmMinMax_3
[] = {
10688 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
10689 { HCBT_SETFOCUS
, hook
|optional
},
10690 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
10691 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
10692 { WM_MOVE
, sent
|defwinproc
|optional
},
10693 { WM_SIZE
, sent
|wparam
|lparam
|defwinproc
|optional
, SIZE_MINIMIZED
, 0 },
10696 static const struct message WmMinMax_4
[] = {
10697 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINNOACTIVE
},
10700 static const struct message WmShowMaximized_1
[] = {
10701 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMAXIMIZED
},
10702 { WM_GETMINMAXINFO
, sent
},
10703 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
10704 { HCBT_ACTIVATE
, hook
|optional
}, /* win2000 doesn't send it */
10705 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2000 doesn't send it */
10706 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 doesn't send it */
10707 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
10708 { WM_MOVE
, sent
|defwinproc
},
10709 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_MAXIMIZED
},
10710 { HCBT_SETFOCUS
, hook
|optional
}, /* win2003 sends it */
10713 static const struct message WmShowMaximized_2
[] = {
10714 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMAXIMIZED
},
10715 { WM_GETMINMAXINFO
, sent
},
10716 { WM_WINDOWPOSCHANGING
, sent
|optional
},
10717 { HCBT_ACTIVATE
, hook
|optional
},
10718 { WM_WINDOWPOSCHANGED
, sent
|optional
},
10719 { WM_MOVE
, sent
|optional
}, /* Win9x doesn't send it */
10720 { WM_SIZE
, sent
|wparam
|optional
, SIZE_MAXIMIZED
}, /* Win9x doesn't send it */
10721 { WM_WINDOWPOSCHANGING
, sent
|optional
},
10722 { HCBT_SETFOCUS
, hook
|optional
},
10723 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
10724 { WM_MOVE
, sent
|defwinproc
},
10725 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_MAXIMIZED
},
10726 { HCBT_SETFOCUS
, hook
|optional
},
10729 static const struct message WmShowMaximized_3
[] = {
10730 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMAXIMIZED
},
10731 { WM_GETMINMAXINFO
, sent
|optional
},
10732 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
, 0, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOSIZE
|SWP_NOMOVE
},
10733 { HCBT_ACTIVATE
, hook
|optional
}, /* win2000 doesn't send it */
10734 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2000 doesn't send it */
10735 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 doesn't send it */
10736 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
, 0, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOSIZE
|SWP_NOMOVE
},
10737 { WM_MOVE
, sent
|defwinproc
|optional
},
10738 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_MAXIMIZED
},
10742 static void test_ShowWindow(void)
10744 /* ShowWindow commands in random order */
10745 static const struct
10747 INT cmd
; /* ShowWindow command */
10748 LPARAM ret
; /* ShowWindow return value */
10749 DWORD style
; /* window style after the command */
10750 const struct message
*msg
; /* message sequence the command produces */
10751 INT wp_cmd
, wp_flags
; /* window placement after the command */
10752 POINT wp_min
, wp_max
; /* window placement after the command */
10753 BOOL todo_msg
; /* message sequence doesn't match what Wine does */
10756 /* 1 */ { SW_SHOWNORMAL
, FALSE
, WS_VISIBLE
, WmShowNormal
,
10757 SW_SHOWNORMAL
, 0, {-1,-1}, {-1,-1}, FALSE
},
10758 /* 2 */ { SW_SHOWNORMAL
, TRUE
, WS_VISIBLE
, WmEmptySeq
,
10759 SW_SHOWNORMAL
, 0, {-1,-1}, {-1,-1}, FALSE
},
10760 /* 3 */ { SW_HIDE
, TRUE
, 0, WmHide_1
,
10761 SW_SHOWNORMAL
, 0, {-1,-1}, {-1,-1}, FALSE
},
10762 /* 4 */ { SW_HIDE
, FALSE
, 0, WmEmptySeq
,
10763 SW_SHOWNORMAL
, 0, {-1,-1}, {-1,-1}, FALSE
},
10764 /* 5 */ { SW_SHOWMINIMIZED
, FALSE
, WS_VISIBLE
|WS_MINIMIZE
, WmShowMinimized_1
,
10765 SW_SHOWMINIMIZED
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
10766 /* 6 */ { SW_SHOWMINIMIZED
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinMax_1
,
10767 SW_SHOWMINIMIZED
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
10768 /* 7 */ { SW_HIDE
, TRUE
, WS_MINIMIZE
, WmHide_1
,
10769 SW_SHOWMINIMIZED
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
10770 /* 8 */ { SW_HIDE
, FALSE
, WS_MINIMIZE
, WmEmptySeq
,
10771 SW_SHOWMINIMIZED
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
10772 /* 9 */ { SW_SHOWMAXIMIZED
, FALSE
, WS_VISIBLE
|WS_MAXIMIZE
, WmShowMaximized_1
,
10773 SW_SHOWMAXIMIZED
, WPF_RESTORETOMAXIMIZED
, {-32000,-32000}, {-1,-1}, FALSE
},
10774 /* 10 */ { SW_SHOWMAXIMIZED
, TRUE
, WS_VISIBLE
|WS_MAXIMIZE
, WmMinMax_2
,
10775 SW_SHOWMAXIMIZED
, WPF_RESTORETOMAXIMIZED
, {-32000,-32000}, {-1,-1}, FALSE
},
10776 /* 11 */ { SW_HIDE
, TRUE
, WS_MAXIMIZE
, WmHide_1
,
10777 SW_SHOWMAXIMIZED
, WPF_RESTORETOMAXIMIZED
, {-32000,-32000}, {-1,-1}, FALSE
},
10778 /* 12 */ { SW_HIDE
, FALSE
, WS_MAXIMIZE
, WmEmptySeq
,
10779 SW_SHOWMAXIMIZED
, WPF_RESTORETOMAXIMIZED
, {-32000,-32000}, {-1,-1}, FALSE
},
10780 /* 13 */ { SW_SHOWNOACTIVATE
, FALSE
, WS_VISIBLE
, WmShowNoActivate_1
,
10781 SW_SHOWNORMAL
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
10782 /* 14 */ { SW_SHOWNOACTIVATE
, TRUE
, WS_VISIBLE
, WmEmptySeq
,
10783 SW_SHOWNORMAL
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
10784 /* 15 */ { SW_HIDE
, TRUE
, 0, WmHide_2
,
10785 SW_SHOWNORMAL
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
10786 /* 16 */ { SW_HIDE
, FALSE
, 0, WmEmptySeq
,
10787 SW_SHOWNORMAL
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
10788 /* 17 */ { SW_SHOW
, FALSE
, WS_VISIBLE
, WmShow
,
10789 SW_SHOWNORMAL
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
10790 /* 18 */ { SW_SHOW
, TRUE
, WS_VISIBLE
, WmEmptySeq
,
10791 SW_SHOWNORMAL
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
10792 /* 19 */ { SW_MINIMIZE
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinimize_1
,
10793 SW_SHOWMINIMIZED
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
10794 /* 20 */ { SW_MINIMIZE
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinMax_3
,
10795 SW_SHOWMINIMIZED
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
10796 /* 21 */ { SW_HIDE
, TRUE
, WS_MINIMIZE
, WmHide_2
,
10797 SW_SHOWMINIMIZED
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
10798 /* 22 */ { SW_SHOWMINNOACTIVE
, FALSE
, WS_VISIBLE
|WS_MINIMIZE
, WmShowMinNoActivate
,
10799 SW_SHOWMINIMIZED
, 0, {-32000,-32000}, {-1,-1}, TRUE
},
10800 /* 23 */ { SW_SHOWMINNOACTIVE
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinMax_4
,
10801 SW_SHOWMINIMIZED
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
10802 /* 24 */ { SW_HIDE
, TRUE
, WS_MINIMIZE
, WmHide_2
,
10803 SW_SHOWMINIMIZED
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
10804 /* 25 */ { SW_HIDE
, FALSE
, WS_MINIMIZE
, WmEmptySeq
,
10805 SW_SHOWMINIMIZED
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
10806 /* 26 */ { SW_SHOWNA
, FALSE
, WS_VISIBLE
|WS_MINIMIZE
, WmShowNA_1
,
10807 SW_SHOWMINIMIZED
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
10808 /* 27 */ { SW_SHOWNA
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmShowNA_2
,
10809 SW_SHOWMINIMIZED
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
10810 /* 28 */ { SW_HIDE
, TRUE
, WS_MINIMIZE
, WmHide_2
,
10811 SW_SHOWMINIMIZED
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
10812 /* 29 */ { SW_HIDE
, FALSE
, WS_MINIMIZE
, WmEmptySeq
,
10813 SW_SHOWMINIMIZED
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
10814 /* 30 */ { SW_RESTORE
, FALSE
, WS_VISIBLE
, WmRestore_1
,
10815 SW_SHOWNORMAL
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
10816 /* 31 */ { SW_RESTORE
, TRUE
, WS_VISIBLE
, WmEmptySeq
,
10817 SW_SHOWNORMAL
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
10818 /* 32 */ { SW_HIDE
, TRUE
, 0, WmHide_3
,
10819 SW_SHOWNORMAL
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
10820 /* 33 */ { SW_HIDE
, FALSE
, 0, WmEmptySeq
,
10821 SW_SHOWNORMAL
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
10822 /* 34 */ { SW_NORMALNA
, FALSE
, 0, WmEmptySeq
, /* what does this mean?! */
10823 SW_SHOWNORMAL
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
10824 /* 35 */ { SW_NORMALNA
, FALSE
, 0, WmEmptySeq
,
10825 SW_SHOWNORMAL
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
10826 /* 36 */ { SW_HIDE
, FALSE
, 0, WmEmptySeq
,
10827 SW_SHOWNORMAL
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
10828 /* 37 */ { SW_RESTORE
, FALSE
, WS_VISIBLE
, WmRestore_2
,
10829 SW_SHOWNORMAL
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
10830 /* 38 */ { SW_RESTORE
, TRUE
, WS_VISIBLE
, WmEmptySeq
,
10831 SW_SHOWNORMAL
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
10832 /* 39 */ { SW_SHOWNOACTIVATE
, TRUE
, WS_VISIBLE
, WmEmptySeq
,
10833 SW_SHOWNORMAL
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
10834 /* 40 */ { SW_MINIMIZE
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinimize_2
,
10835 SW_SHOWMINIMIZED
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
10836 /* 41 */ { SW_MINIMIZE
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinMax_3
,
10837 SW_SHOWMINIMIZED
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
10838 /* 42 */ { SW_SHOWMAXIMIZED
, TRUE
, WS_VISIBLE
|WS_MAXIMIZE
, WmShowMaximized_2
,
10839 SW_SHOWMAXIMIZED
, WPF_RESTORETOMAXIMIZED
, {-32000,-32000}, {-1,-1}, FALSE
},
10840 /* 43 */ { SW_SHOWMAXIMIZED
, TRUE
, WS_VISIBLE
|WS_MAXIMIZE
, WmMinMax_2
,
10841 SW_SHOWMAXIMIZED
, WPF_RESTORETOMAXIMIZED
, {-32000,-32000}, {-1,-1}, FALSE
},
10842 /* 44 */ { SW_MINIMIZE
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinimize_1
,
10843 SW_SHOWMINIMIZED
, WPF_RESTORETOMAXIMIZED
, {-32000,-32000}, {-1,-1}, FALSE
},
10844 /* 45 */ { SW_MINIMIZE
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinMax_3
,
10845 SW_SHOWMINIMIZED
, WPF_RESTORETOMAXIMIZED
, {-32000,-32000}, {-1,-1}, FALSE
},
10846 /* 46 */ { SW_RESTORE
, TRUE
, WS_VISIBLE
|WS_MAXIMIZE
, WmRestore_3
,
10847 SW_SHOWMAXIMIZED
, WPF_RESTORETOMAXIMIZED
, {-32000,-32000}, {-1,-1}, FALSE
},
10848 /* 47 */ { SW_RESTORE
, TRUE
, WS_VISIBLE
, WmRestore_4
,
10849 SW_SHOWNORMAL
, WPF_RESTORETOMAXIMIZED
, {-32000,-32000}, {-1,-1}, FALSE
},
10850 /* 48 */ { SW_SHOWMAXIMIZED
, TRUE
, WS_VISIBLE
|WS_MAXIMIZE
, WmShowMaximized_3
,
10851 SW_SHOWMAXIMIZED
, WPF_RESTORETOMAXIMIZED
, {-32000,-32000}, {-1,-1}, FALSE
},
10852 /* 49 */ { SW_SHOW
, TRUE
, WS_VISIBLE
|WS_MAXIMIZE
, WmEmptySeq
,
10853 SW_SHOWMAXIMIZED
, WPF_RESTORETOMAXIMIZED
, {-32000,-32000}, {-1,-1}, FALSE
},
10854 /* 50 */ { SW_SHOWNORMAL
, TRUE
, WS_VISIBLE
, WmRestore_5
,
10855 SW_SHOWNORMAL
, WPF_RESTORETOMAXIMIZED
, {-32000,-32000}, {-1,-1}, FALSE
},
10856 /* 51 */ { SW_SHOWNORMAL
, TRUE
, WS_VISIBLE
, WmRestore_5
,
10857 SW_SHOWNORMAL
, WPF_RESTORETOMAXIMIZED
, {-32000,-32000}, {-1,-1}, FALSE
},
10858 /* 52 */ { SW_HIDE
, TRUE
, 0, WmHide_1
,
10859 SW_SHOWNORMAL
, WPF_RESTORETOMAXIMIZED
, {-32000,-32000}, {-1,-1}, FALSE
},
10860 /* 53 */ { SW_HIDE
, FALSE
, 0, WmEmptySeq
,
10861 SW_SHOWNORMAL
, WPF_RESTORETOMAXIMIZED
, {-32000,-32000}, {-1,-1}, FALSE
},
10862 /* 54 */ { SW_MINIMIZE
, FALSE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinimize_3
,
10863 SW_SHOWMINIMIZED
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
10864 /* 55 */ { SW_HIDE
, TRUE
, WS_MINIMIZE
, WmHide_2
,
10865 SW_SHOWMINIMIZED
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
10866 /* 56 */ { SW_SHOWNOACTIVATE
, FALSE
, WS_VISIBLE
, WmShowNoActivate_2
,
10867 SW_SHOWNORMAL
, 0, {-32000,-32000}, {-1,-1}, FALSE
},
10868 /* 57 */ { SW_SHOW
, TRUE
, WS_VISIBLE
, WmEmptySeq
,
10869 SW_SHOWNORMAL
, 0, {-32000,-32000}, {-1,-1}, FALSE
}
10875 WINDOWPLACEMENT wp
;
10876 RECT win_rc
, work_rc
= {0, 0, 0, 0};
10878 #define WS_BASE (WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX|WS_MAXIMIZEBOX|WS_POPUP|WS_CLIPSIBLINGS)
10879 hwnd
= CreateWindowEx(0, "ShowWindowClass", NULL
, WS_BASE
,
10884 style
= GetWindowLong(hwnd
, GWL_STYLE
) & ~WS_BASE
;
10885 ok(style
== 0, "expected style 0, got %08x\n", style
);
10890 if (pGetMonitorInfoA
&& pMonitorFromPoint
)
10896 SetLastError(0xdeadbeef);
10897 hmon
= pMonitorFromPoint(pt
, MONITOR_DEFAULTTOPRIMARY
);
10898 ok(hmon
!= 0, "MonitorFromPoint error %u\n", GetLastError());
10900 mi
.cbSize
= sizeof(mi
);
10901 SetLastError(0xdeadbeef);
10902 ret
= pGetMonitorInfoA(hmon
, &mi
);
10903 ok(ret
, "GetMonitorInfo error %u\n", GetLastError());
10904 trace("monitor (%d,%d-%d,%d), work (%d,%d-%d,%d)\n",
10905 mi
.rcMonitor
.left
, mi
.rcMonitor
.top
, mi
.rcMonitor
.right
, mi
.rcMonitor
.bottom
,
10906 mi
.rcWork
.left
, mi
.rcWork
.top
, mi
.rcWork
.right
, mi
.rcWork
.bottom
);
10907 work_rc
= mi
.rcWork
;
10910 GetWindowRect(hwnd
, &win_rc
);
10911 OffsetRect(&win_rc
, -work_rc
.left
, -work_rc
.top
);
10913 wp
.length
= sizeof(wp
);
10914 SetLastError(0xdeadbeaf);
10915 ret
= GetWindowPlacement(hwnd
, &wp
);
10916 ok(ret
, "GetWindowPlacement error %u\n", GetLastError());
10917 ok(wp
.flags
== 0, "expected 0, got %#x\n", wp
.flags
);
10918 ok(wp
.showCmd
== SW_SHOWNORMAL
, "expected SW_SHOWNORMAL, got %d\n", wp
.showCmd
);
10919 ok(wp
.ptMinPosition
.x
== -1 && wp
.ptMinPosition
.y
== -1,
10920 "expected -1,-1 got %d,%d\n", wp
.ptMinPosition
.x
, wp
.ptMinPosition
.y
);
10921 ok(wp
.ptMaxPosition
.x
== -1 && wp
.ptMaxPosition
.y
== -1,
10922 "expected -1,-1 got %d,%d\n", wp
.ptMaxPosition
.x
, wp
.ptMaxPosition
.y
);
10923 if (work_rc
.left
|| work_rc
.top
) todo_wine
/* FIXME: remove once Wine is fixed */
10924 ok(EqualRect(&win_rc
, &wp
.rcNormalPosition
),
10925 "expected %d,%d-%d,%d got %d,%d-%d,%d\n",
10926 win_rc
.left
, win_rc
.top
, win_rc
.right
, win_rc
.bottom
,
10927 wp
.rcNormalPosition
.left
, wp
.rcNormalPosition
.top
,
10928 wp
.rcNormalPosition
.right
, wp
.rcNormalPosition
.bottom
);
10930 ok(EqualRect(&win_rc
, &wp
.rcNormalPosition
),
10931 "expected %d,%d-%d,%d got %d,%d-%d,%d\n",
10932 win_rc
.left
, win_rc
.top
, win_rc
.right
, win_rc
.bottom
,
10933 wp
.rcNormalPosition
.left
, wp
.rcNormalPosition
.top
,
10934 wp
.rcNormalPosition
.right
, wp
.rcNormalPosition
.bottom
);
10936 for (i
= 0; i
< sizeof(sw
)/sizeof(sw
[0]); i
++)
10938 static const char * const sw_cmd_name
[13] =
10940 "SW_HIDE", "SW_SHOWNORMAL", "SW_SHOWMINIMIZED", "SW_SHOWMAXIMIZED",
10941 "SW_SHOWNOACTIVATE", "SW_SHOW", "SW_MINIMIZE", "SW_SHOWMINNOACTIVE",
10942 "SW_SHOWNA", "SW_RESTORE", "SW_SHOWDEFAULT", "SW_FORCEMINIMIZE",
10943 "SW_NORMALNA" /* 0xCC */
10946 INT idx
; /* index into the above array of names */
10948 idx
= (sw
[i
].cmd
== SW_NORMALNA
) ? 12 : sw
[i
].cmd
;
10950 style
= GetWindowLong(hwnd
, GWL_STYLE
);
10951 trace("%d: sending %s, current window style %08x\n", i
+1, sw_cmd_name
[idx
], style
);
10952 ret
= ShowWindow(hwnd
, sw
[i
].cmd
);
10953 ok(!ret
== !sw
[i
].ret
, "%d: cmd %s: expected ret %lu, got %lu\n", i
+1, sw_cmd_name
[idx
], sw
[i
].ret
, ret
);
10954 style
= GetWindowLong(hwnd
, GWL_STYLE
) & ~WS_BASE
;
10955 ok(style
== sw
[i
].style
, "%d: expected style %08x, got %08x\n", i
+1, sw
[i
].style
, style
);
10957 sprintf(comment
, "%d: ShowWindow(%s)", i
+1, sw_cmd_name
[idx
]);
10958 ok_sequence(sw
[i
].msg
, comment
, sw
[i
].todo_msg
);
10960 wp
.length
= sizeof(wp
);
10961 SetLastError(0xdeadbeaf);
10962 ret
= GetWindowPlacement(hwnd
, &wp
);
10963 ok(ret
, "GetWindowPlacement error %u\n", GetLastError());
10964 ok(wp
.flags
== sw
[i
].wp_flags
, "expected %#x, got %#x\n", sw
[i
].wp_flags
, wp
.flags
);
10965 ok(wp
.showCmd
== sw
[i
].wp_cmd
, "expected %d, got %d\n", sw
[i
].wp_cmd
, wp
.showCmd
);
10967 /* NT moves the minimized window to -32000,-32000, win9x to 3000,3000 */
10968 if ((wp
.ptMinPosition
.x
+ work_rc
.left
== -32000 && wp
.ptMinPosition
.y
+ work_rc
.top
== -32000) ||
10969 (wp
.ptMinPosition
.x
+ work_rc
.left
== 3000 && wp
.ptMinPosition
.y
+ work_rc
.top
== 3000))
10971 ok((wp
.ptMinPosition
.x
+ work_rc
.left
== sw
[i
].wp_min
.x
&& wp
.ptMinPosition
.y
+ work_rc
.top
== sw
[i
].wp_min
.y
) ||
10972 (wp
.ptMinPosition
.x
+ work_rc
.left
== 3000 && wp
.ptMinPosition
.y
+ work_rc
.top
== 3000),
10973 "expected %d,%d got %d,%d\n", sw
[i
].wp_min
.x
, sw
[i
].wp_min
.y
, wp
.ptMinPosition
.x
, wp
.ptMinPosition
.y
);
10977 if (wp
.ptMinPosition
.x
!= sw
[i
].wp_min
.x
|| wp
.ptMinPosition
.y
!= sw
[i
].wp_min
.y
)
10979 ok(wp
.ptMinPosition
.x
== sw
[i
].wp_min
.x
&& wp
.ptMinPosition
.y
== sw
[i
].wp_min
.y
,
10980 "expected %d,%d got %d,%d\n", sw
[i
].wp_min
.x
, sw
[i
].wp_min
.y
, wp
.ptMinPosition
.x
, wp
.ptMinPosition
.y
);
10982 ok(wp
.ptMinPosition
.x
== sw
[i
].wp_min
.x
&& wp
.ptMinPosition
.y
== sw
[i
].wp_min
.y
,
10983 "expected %d,%d got %d,%d\n", sw
[i
].wp_min
.x
, sw
[i
].wp_min
.y
, wp
.ptMinPosition
.x
, wp
.ptMinPosition
.y
);
10986 if (wp
.ptMaxPosition
.x
!= sw
[i
].wp_max
.x
|| wp
.ptMaxPosition
.y
!= sw
[i
].wp_max
.y
)
10988 ok(wp
.ptMaxPosition
.x
== sw
[i
].wp_max
.x
&& wp
.ptMaxPosition
.y
== sw
[i
].wp_max
.y
,
10989 "expected %d,%d got %d,%d\n", sw
[i
].wp_max
.x
, sw
[i
].wp_max
.y
, wp
.ptMaxPosition
.x
, wp
.ptMaxPosition
.y
);
10991 ok(wp
.ptMaxPosition
.x
== sw
[i
].wp_max
.x
&& wp
.ptMaxPosition
.y
== sw
[i
].wp_max
.y
,
10992 "expected %d,%d got %d,%d\n", sw
[i
].wp_max
.x
, sw
[i
].wp_max
.y
, wp
.ptMaxPosition
.x
, wp
.ptMaxPosition
.y
);
10994 if (0) /* FIXME: Wine behaves completely different here */
10995 ok(EqualRect(&win_rc
, &wp
.rcNormalPosition
),
10996 "expected %d,%d-%d,%d got %d,%d-%d,%d\n",
10997 win_rc
.left
, win_rc
.top
, win_rc
.right
, win_rc
.bottom
,
10998 wp
.rcNormalPosition
.left
, wp
.rcNormalPosition
.top
,
10999 wp
.rcNormalPosition
.right
, wp
.rcNormalPosition
.bottom
);
11005 DestroyWindow(hwnd
);
11008 static INT_PTR WINAPI
test_dlg_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
11010 struct recvd_message msg
;
11012 if (ignore_message( message
)) return 0;
11015 msg
.message
= message
;
11016 msg
.flags
= sent
|wparam
|lparam
;
11017 msg
.wParam
= wParam
;
11018 msg
.lParam
= lParam
;
11019 msg
.descr
= "dialog";
11022 /* calling DefDlgProc leads to a recursion under XP */
11026 case WM_INITDIALOG
:
11027 case WM_GETDLGCODE
:
11033 static const struct message WmDefDlgSetFocus_1
[] = {
11034 { WM_GETDLGCODE
, sent
|wparam
|lparam
, 0, 0 },
11035 { WM_GETTEXTLENGTH
, sent
|wparam
|lparam
|optional
, 0, 0 }, /* XP */
11036 { WM_GETTEXT
, sent
|wparam
|optional
, 6 }, /* XP */
11037 { WM_GETTEXT
, sent
|wparam
|optional
, 12 }, /* XP */
11038 { EM_SETSEL
, sent
|wparam
, 0 }, /* XP sets lparam to text length, Win9x to -2 */
11039 { HCBT_SETFOCUS
, hook
},
11040 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
11041 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
11042 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
11043 { WM_SETFOCUS
, sent
|wparam
, 0 },
11044 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 10 },
11045 { WM_CTLCOLOREDIT
, sent
},
11046 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 11 },
11047 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
11048 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
11049 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
11050 { WM_COMMAND
, sent
|wparam
, MAKEWPARAM(1, EN_SETFOCUS
) },
11053 static const struct message WmDefDlgSetFocus_2
[] = {
11054 { WM_GETDLGCODE
, sent
|wparam
|lparam
, 0, 0 },
11055 { WM_GETTEXTLENGTH
, sent
|wparam
|lparam
|optional
, 0, 0 }, /* XP */
11056 { WM_GETTEXT
, sent
|wparam
|optional
, 6 }, /* XP */
11057 { WM_GETTEXT
, sent
|wparam
|optional
, 12 }, /* XP */
11058 { EM_SETSEL
, sent
|wparam
, 0 }, /* XP sets lparam to text length, Win9x to -2 */
11059 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
11060 { WM_CTLCOLOREDIT
, sent
|optional
}, /* XP */
11061 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
11064 /* Creation of a dialog */
11065 static const struct message WmCreateDialogParamSeq_1
[] = {
11066 { HCBT_CREATEWND
, hook
},
11067 { WM_NCCREATE
, sent
},
11068 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
11069 { WM_CREATE
, sent
},
11070 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
11071 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
11073 { WM_SETFONT
, sent
},
11074 { WM_INITDIALOG
, sent
},
11075 { WM_CHANGEUISTATE
, sent
|optional
},
11078 /* Creation of a dialog */
11079 static const struct message WmCreateDialogParamSeq_2
[] = {
11080 { HCBT_CREATEWND
, hook
},
11081 { WM_NCCREATE
, sent
},
11082 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
11083 { WM_CREATE
, sent
},
11084 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
11085 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
11087 { WM_CHANGEUISTATE
, sent
|optional
},
11091 static void test_dialog_messages(void)
11094 HWND hdlg
, hedit1
, hedit2
, hfocus
;
11097 #define set_selection(hctl, start, end) \
11098 ret = SendMessage(hctl, EM_SETSEL, start, end); \
11099 ok(ret == 1, "EM_SETSEL returned %ld\n", ret);
11101 #define check_selection(hctl, start, end) \
11102 ret = SendMessage(hctl, EM_GETSEL, 0, 0); \
11103 ok(ret == MAKELRESULT(start, end), "wrong selection (%d - %d)\n", LOWORD(ret), HIWORD(ret));
11107 hdlg
= CreateWindowEx(WS_EX_DLGMODALFRAME
, "TestDialogClass", NULL
,
11108 WS_VISIBLE
|WS_CAPTION
|WS_SYSMENU
|WS_DLGFRAME
,
11109 0, 0, 100, 100, 0, 0, 0, NULL
);
11110 ok(hdlg
!= 0, "Failed to create custom dialog window\n");
11112 hedit1
= CreateWindowEx(0, "my_edit_class", NULL
,
11113 WS_CHILD
|WS_BORDER
|WS_VISIBLE
|WS_TABSTOP
,
11114 0, 0, 80, 20, hdlg
, (HMENU
)1, 0, NULL
);
11115 ok(hedit1
!= 0, "Failed to create edit control\n");
11116 hedit2
= CreateWindowEx(0, "my_edit_class", NULL
,
11117 WS_CHILD
|WS_BORDER
|WS_VISIBLE
|WS_TABSTOP
,
11118 0, 40, 80, 20, hdlg
, (HMENU
)2, 0, NULL
);
11119 ok(hedit2
!= 0, "Failed to create edit control\n");
11121 SendMessage(hedit1
, WM_SETTEXT
, 0, (LPARAM
)"hello");
11122 SendMessage(hedit2
, WM_SETTEXT
, 0, (LPARAM
)"bye");
11124 hfocus
= GetFocus();
11125 ok(hfocus
== hdlg
, "wrong focus %p\n", hfocus
);
11128 hfocus
= GetFocus();
11129 ok(hfocus
== hedit2
, "wrong focus %p\n", hfocus
);
11131 check_selection(hedit1
, 0, 0);
11132 check_selection(hedit2
, 0, 0);
11134 set_selection(hedit2
, 0, -1);
11135 check_selection(hedit2
, 0, 3);
11138 hfocus
= GetFocus();
11139 ok(hfocus
== 0, "wrong focus %p\n", hfocus
);
11142 ret
= DefDlgProc(hdlg
, WM_SETFOCUS
, 0, 0);
11143 ok(ret
== 0, "WM_SETFOCUS returned %ld\n", ret
);
11144 ok_sequence(WmDefDlgSetFocus_1
, "DefDlgProc(WM_SETFOCUS) 1", FALSE
);
11146 hfocus
= GetFocus();
11147 ok(hfocus
== hedit1
, "wrong focus %p\n", hfocus
);
11149 check_selection(hedit1
, 0, 5);
11150 check_selection(hedit2
, 0, 3);
11153 ret
= DefDlgProc(hdlg
, WM_SETFOCUS
, 0, 0);
11154 ok(ret
== 0, "WM_SETFOCUS returned %ld\n", ret
);
11155 ok_sequence(WmDefDlgSetFocus_2
, "DefDlgProc(WM_SETFOCUS) 2", FALSE
);
11157 hfocus
= GetFocus();
11158 ok(hfocus
== hedit1
, "wrong focus %p\n", hfocus
);
11160 check_selection(hedit1
, 0, 5);
11161 check_selection(hedit2
, 0, 3);
11163 EndDialog(hdlg
, 0);
11164 DestroyWindow(hedit1
);
11165 DestroyWindow(hedit2
);
11166 DestroyWindow(hdlg
);
11169 #undef set_selection
11170 #undef check_selection
11172 ok(GetClassInfo(0, "#32770", &cls
), "GetClassInfo failed\n");
11173 cls
.lpszClassName
= "MyDialogClass";
11174 cls
.hInstance
= GetModuleHandle(0);
11175 /* need a cast since a dlgproc is used as a wndproc */
11176 cls
.lpfnWndProc
= (WNDPROC
)test_dlg_proc
;
11177 if (!RegisterClass(&cls
)) assert(0);
11179 hdlg
= CreateDialogParam(0, "CLASS_TEST_DIALOG_2", 0, test_dlg_proc
, 0);
11180 ok(IsWindow(hdlg
), "CreateDialogParam failed\n");
11181 ok_sequence(WmCreateDialogParamSeq_1
, "CreateDialogParam_1", FALSE
);
11182 EndDialog(hdlg
, 0);
11183 DestroyWindow(hdlg
);
11186 hdlg
= CreateDialogParam(0, "CLASS_TEST_DIALOG_2", 0, NULL
, 0);
11187 ok(IsWindow(hdlg
), "CreateDialogParam failed\n");
11188 ok_sequence(WmCreateDialogParamSeq_2
, "CreateDialogParam_2", FALSE
);
11189 EndDialog(hdlg
, 0);
11190 DestroyWindow(hdlg
);
11193 UnregisterClass(cls
.lpszClassName
, cls
.hInstance
);
11196 static void test_nullCallback(void)
11200 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW
,
11201 100, 100, 200, 200, 0, 0, 0, NULL
);
11202 ok (hwnd
!= 0, "Failed to create overlapped window\n");
11204 SendMessageCallbackA(hwnd
,WM_NULL
,0,0,NULL
,0);
11206 DestroyWindow(hwnd
);
11209 /* SetActiveWindow( 0 ) hwnd visible */
11210 static const struct message SetActiveWindowSeq0
[] =
11212 { HCBT_ACTIVATE
, hook
|optional
},
11213 { WM_NCACTIVATE
, sent
|wparam
, 0 },
11214 { WM_GETTEXT
, sent
|defwinproc
|optional
},
11215 { WM_ACTIVATE
, sent
|wparam
, 0 },
11216 { WM_ACTIVATEAPP
, sent
|wparam
|optional
, 0 },
11217 { WM_ACTIVATEAPP
, sent
|wparam
|optional
, 0 },
11218 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
11219 { WM_KILLFOCUS
, sent
|optional
},
11220 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
11221 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
11222 { WM_NCACTIVATE
, sent
|wparam
|optional
, 1 },
11223 { WM_GETTEXT
, sent
|defwinproc
|optional
},
11224 { WM_ACTIVATE
, sent
|wparam
|optional
, 1 },
11225 { HCBT_SETFOCUS
, hook
|optional
},
11226 { WM_KILLFOCUS
, sent
|defwinproc
|optional
},
11227 { WM_IME_SETCONTEXT
, sent
|defwinproc
|optional
},
11228 { WM_IME_SETCONTEXT
, sent
|defwinproc
|optional
},
11229 { WM_IME_SETCONTEXT
, sent
|optional
},
11230 { WM_IME_SETCONTEXT
, sent
|optional
},
11231 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 1 },
11232 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
11233 { WM_SETFOCUS
, sent
|defwinproc
|optional
},
11234 { WM_GETTEXT
, sent
|optional
},
11237 /* SetActiveWindow( hwnd ) hwnd visible */
11238 static const struct message SetActiveWindowSeq1
[] =
11240 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
11243 /* SetActiveWindow( popup ) hwnd visible, popup visible */
11244 static const struct message SetActiveWindowSeq2
[] =
11246 { HCBT_ACTIVATE
, hook
},
11247 { WM_NCACTIVATE
, sent
|wparam
, 0 },
11248 { WM_GETTEXT
, sent
|defwinproc
|optional
},
11249 { WM_ACTIVATE
, sent
|wparam
, 0 },
11250 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
11251 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
11252 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
11253 { WM_NCPAINT
, sent
|optional
},
11254 { WM_GETTEXT
, sent
|defwinproc
|optional
},
11255 { WM_ERASEBKGND
, sent
|optional
},
11256 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
11257 { WM_NCACTIVATE
, sent
|wparam
, 1 },
11258 { WM_GETTEXT
, sent
|defwinproc
|optional
},
11259 { WM_ACTIVATE
, sent
|wparam
, 1 },
11260 { HCBT_SETFOCUS
, hook
},
11261 { WM_KILLFOCUS
, sent
|defwinproc
},
11262 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 0 },
11263 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
11264 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 1 },
11265 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
11266 { WM_SETFOCUS
, sent
|defwinproc
},
11267 { WM_GETTEXT
, sent
|optional
},
11271 /* SetActiveWindow( hwnd ) hwnd not visible */
11272 static const struct message SetActiveWindowSeq3
[] =
11274 { HCBT_ACTIVATE
, hook
},
11275 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
11276 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
11277 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
},
11278 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOACTIVATE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
11279 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
11280 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
11281 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
11282 { WM_NCACTIVATE
, sent
|wparam
, 1 },
11283 { WM_ACTIVATE
, sent
|wparam
, 1 },
11284 { HCBT_SETFOCUS
, hook
},
11285 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
11286 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
11287 { WM_SETFOCUS
, sent
|defwinproc
},
11290 /* SetActiveWindow( popup ) hwnd not visible, popup not visible */
11291 static const struct message SetActiveWindowSeq4
[] =
11293 { HCBT_ACTIVATE
, hook
},
11294 { WM_NCACTIVATE
, sent
|wparam
, 0 },
11295 { WM_GETTEXT
, sent
|defwinproc
|optional
},
11296 { WM_ACTIVATE
, sent
|wparam
, 0 },
11297 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
11298 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
},
11299 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
11300 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
11301 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
11302 { WM_NCACTIVATE
, sent
|wparam
, 1 },
11303 { WM_GETTEXT
, sent
|defwinproc
|optional
},
11304 { WM_ACTIVATE
, sent
|wparam
, 1 },
11305 { HCBT_SETFOCUS
, hook
},
11306 { WM_KILLFOCUS
, sent
|defwinproc
},
11307 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 0 },
11308 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
11309 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 1 },
11310 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
11311 { WM_SETFOCUS
, sent
|defwinproc
},
11316 static void test_SetActiveWindow(void)
11318 HWND hwnd
, popup
, ret
;
11320 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test SetActiveWindow",
11321 WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
11322 100, 100, 200, 200, 0, 0, 0, NULL
);
11324 popup
= CreateWindowExA(0, "TestWindowClass", "Test SetActiveWindow",
11325 WS_OVERLAPPEDWINDOW
| WS_VISIBLE
| WS_POPUP
,
11326 100, 100, 200, 200, hwnd
, 0, 0, NULL
);
11328 ok(hwnd
!= 0, "Failed to create overlapped window\n");
11329 ok(popup
!= 0, "Failed to create popup window\n");
11330 SetForegroundWindow( popup
);
11333 trace("SetActiveWindow(0)\n");
11334 ret
= SetActiveWindow(0);
11335 ok( ret
== popup
, "Failed to SetActiveWindow(0)\n");
11336 ok_sequence(SetActiveWindowSeq0
, "SetActiveWindow(0)", FALSE
);
11339 trace("SetActiveWindow(hwnd), hwnd visible\n");
11340 ret
= SetActiveWindow(hwnd
);
11341 if (ret
== hwnd
) ok_sequence(SetActiveWindowSeq1
, "SetActiveWindow(hwnd), hwnd visible", TRUE
);
11344 trace("SetActiveWindow(popup), hwnd visible, popup visible\n");
11345 ret
= SetActiveWindow(popup
);
11346 ok( ret
== hwnd
, "Failed to SetActiveWindow(popup), popup visible\n");
11347 ok_sequence(SetActiveWindowSeq2
, "SetActiveWindow(popup), hwnd visible, popup visible", FALSE
);
11350 ShowWindow(hwnd
, SW_HIDE
);
11351 ShowWindow(popup
, SW_HIDE
);
11354 trace("SetActiveWindow(hwnd), hwnd not visible\n");
11355 ret
= SetActiveWindow(hwnd
);
11356 ok( ret
== NULL
, "SetActiveWindow(hwnd), hwnd not visible, previous is %p\n", ret
);
11357 ok_sequence(SetActiveWindowSeq3
, "SetActiveWindow(hwnd), hwnd not visible", TRUE
);
11360 trace("SetActiveWindow(popup), hwnd not visible, popup not visible\n");
11361 ret
= SetActiveWindow(popup
);
11362 ok( ret
== hwnd
, "Failed to SetActiveWindow(popup)\n");
11363 ok_sequence(SetActiveWindowSeq4
, "SetActiveWindow(popup), hwnd not visible, popup not visible", TRUE
);
11368 DestroyWindow(hwnd
);
11371 static const struct message SetForegroundWindowSeq
[] =
11373 { WM_NCACTIVATE
, sent
|wparam
, 0 },
11374 { WM_GETTEXT
, sent
|defwinproc
|optional
},
11375 { WM_ACTIVATE
, sent
|wparam
, 0 },
11376 { WM_ACTIVATEAPP
, sent
|wparam
, 0 },
11377 { WM_KILLFOCUS
, sent
},
11378 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
11379 { WM_IME_NOTIFY
, sent
|wparam
|optional
|defwinproc
, 1 },
11383 static void test_SetForegroundWindow(void)
11387 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test SetForegroundWindow",
11388 WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
11389 100, 100, 200, 200, 0, 0, 0, NULL
);
11390 ok (hwnd
!= 0, "Failed to create overlapped window\n");
11391 SetForegroundWindow( hwnd
);
11394 trace("SetForegroundWindow( 0 )\n");
11395 SetForegroundWindow( 0 );
11396 ok_sequence(WmEmptySeq
, "SetForegroundWindow( 0 ) away from foreground top level window", FALSE
);
11397 trace("SetForegroundWindow( GetDesktopWindow() )\n");
11398 SetForegroundWindow( GetDesktopWindow() );
11399 ok_sequence(SetForegroundWindowSeq
, "SetForegroundWindow( desktop ) away from "
11400 "foreground top level window", FALSE
);
11403 DestroyWindow(hwnd
);
11406 static void test_dbcs_wm_char(void)
11409 WCHAR wch
, bad_wch
;
11417 struct message wmCharSeq
[2];
11419 if (!pGetCPInfoExA
)
11421 win_skip("GetCPInfoExA is not available\n");
11425 pGetCPInfoExA( CP_ACP
, 0, &cpinfo
);
11426 if (cpinfo
.MaxCharSize
!= 2)
11428 skip( "Skipping DBCS WM_CHAR test in SBCS codepage '%s'\n", cpinfo
.CodePageName
);
11432 dbch
[0] = dbch
[1] = 0;
11434 bad_wch
= cpinfo
.UnicodeDefaultChar
;
11435 for (i
= 0; !wch
&& i
< MAX_LEADBYTES
&& cpinfo
.LeadByte
[i
]; i
+= 2)
11436 for (j
= cpinfo
.LeadByte
[i
]; !wch
&& j
<= cpinfo
.LeadByte
[i
+1]; j
++)
11437 for (k
= 128; k
<= 255; k
++)
11443 if (MultiByteToWideChar( CP_ACP
, 0, str
, 2, wstr
, 2 ) == 1 &&
11444 WideCharToMultiByte( CP_ACP
, 0, wstr
, 1, str
, 2, NULL
, NULL
) == 2 &&
11445 (BYTE
)str
[0] == j
&& (BYTE
)str
[1] == k
&&
11446 HIBYTE(wstr
[0]) && HIBYTE(wstr
[0]) != 0xff)
11457 skip( "Skipping DBCS WM_CHAR test, no appropriate char found\n" );
11460 trace( "using dbcs char %02x,%02x wchar %04x bad wchar %04x codepage '%s'\n",
11461 dbch
[0], dbch
[1], wch
, bad_wch
, cpinfo
.CodePageName
);
11463 hwnd
= CreateWindowExW(0, testWindowClassW
, NULL
,
11464 WS_OVERLAPPEDWINDOW
, 100, 100, 200, 200, 0, 0, 0, NULL
);
11465 hwnd2
= CreateWindowExW(0, testWindowClassW
, NULL
,
11466 WS_OVERLAPPEDWINDOW
, 100, 100, 200, 200, 0, 0, 0, NULL
);
11467 ok (hwnd
!= 0, "Failed to create overlapped window\n");
11468 ok (hwnd2
!= 0, "Failed to create overlapped window\n");
11471 memset( wmCharSeq
, 0, sizeof(wmCharSeq
) );
11472 wmCharSeq
[0].message
= WM_CHAR
;
11473 wmCharSeq
[0].flags
= sent
|wparam
;
11474 wmCharSeq
[0].wParam
= wch
;
11476 /* posted message */
11477 PostMessageA( hwnd
, WM_CHAR
, dbch
[0], 0 );
11478 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
11479 PostMessageA( hwnd
, WM_CHAR
, dbch
[1], 0 );
11480 ok( PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "no message\n" );
11481 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
11482 ok( msg
.wParam
== wch
, "bad wparam %lx/%x\n", msg
.wParam
, wch
);
11483 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
11485 /* posted thread message */
11486 PostThreadMessageA( GetCurrentThreadId(), WM_CHAR
, dbch
[0], 0 );
11487 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
11488 PostMessageA( hwnd
, WM_CHAR
, dbch
[1], 0 );
11489 ok( PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "no message\n" );
11490 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
11491 ok( msg
.wParam
== wch
, "bad wparam %lx/%x\n", msg
.wParam
, wch
);
11492 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
11496 SendMessageA( hwnd
, WM_CHAR
, dbch
[0], 0 );
11497 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
11498 SendMessageA( hwnd
, WM_CHAR
, dbch
[1], 0 );
11499 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
11500 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
11502 /* sent message with timeout */
11504 SendMessageTimeoutA( hwnd
, WM_CHAR
, dbch
[0], 0, SMTO_NORMAL
, 0, &res
);
11505 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
11506 SendMessageTimeoutA( hwnd
, WM_CHAR
, dbch
[1], 0, SMTO_NORMAL
, 0, &res
);
11507 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
11508 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
11510 /* sent message with timeout and callback */
11512 SendMessageTimeoutA( hwnd
, WM_CHAR
, dbch
[0], 0, SMTO_NORMAL
, 0, &res
);
11513 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
11514 SendMessageCallbackA( hwnd
, WM_CHAR
, dbch
[1], 0, NULL
, 0 );
11515 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
11516 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
11518 /* sent message with callback */
11520 SendNotifyMessageA( hwnd
, WM_CHAR
, dbch
[0], 0 );
11521 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
11522 SendMessageCallbackA( hwnd
, WM_CHAR
, dbch
[1], 0, NULL
, 0 );
11523 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
11524 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
11526 /* direct window proc call */
11528 CallWindowProcA( (WNDPROC
)GetWindowLongPtrA( hwnd
, GWLP_WNDPROC
), hwnd
, WM_CHAR
, dbch
[0], 0 );
11529 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
11530 CallWindowProcA( (WNDPROC
)GetWindowLongPtrA( hwnd
, GWLP_WNDPROC
), hwnd
, WM_CHAR
, dbch
[1], 0 );
11531 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
11533 /* dispatch message */
11535 msg
.message
= WM_CHAR
;
11536 msg
.wParam
= dbch
[0];
11538 DispatchMessageA( &msg
);
11539 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
11540 msg
.wParam
= dbch
[1];
11541 DispatchMessageA( &msg
);
11542 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
11544 /* window handle is irrelevant */
11546 SendMessageA( hwnd2
, WM_CHAR
, dbch
[0], 0 );
11547 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
11548 SendMessageA( hwnd
, WM_CHAR
, dbch
[1], 0 );
11549 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
11550 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
11552 /* interleaved post and send */
11554 PostMessageA( hwnd2
, WM_CHAR
, dbch
[0], 0 );
11555 SendMessageA( hwnd2
, WM_CHAR
, dbch
[0], 0 );
11556 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
11557 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
11558 PostMessageA( hwnd
, WM_CHAR
, dbch
[1], 0 );
11559 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
11560 ok( PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "no message\n" );
11561 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
11562 ok( msg
.wParam
== wch
, "bad wparam %lx/%x\n", msg
.wParam
, wch
);
11563 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
11564 SendMessageA( hwnd
, WM_CHAR
, dbch
[1], 0 );
11565 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
11566 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
11568 /* interleaved sent message and winproc */
11570 SendMessageA( hwnd
, WM_CHAR
, dbch
[0], 0 );
11571 CallWindowProcA( (WNDPROC
)GetWindowLongPtrA( hwnd
, GWLP_WNDPROC
), hwnd
, WM_CHAR
, dbch
[0], 0 );
11572 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
11573 SendMessageA( hwnd
, WM_CHAR
, dbch
[1], 0 );
11574 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
11575 CallWindowProcA( (WNDPROC
)GetWindowLongPtrA( hwnd
, GWLP_WNDPROC
), hwnd
, WM_CHAR
, dbch
[1], 0 );
11576 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
11578 /* interleaved winproc and dispatch */
11580 msg
.message
= WM_CHAR
;
11581 msg
.wParam
= dbch
[0];
11583 CallWindowProcA( (WNDPROC
)GetWindowLongPtrA( hwnd
, GWLP_WNDPROC
), hwnd
, WM_CHAR
, dbch
[0], 0 );
11584 DispatchMessageA( &msg
);
11585 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
11586 msg
.wParam
= dbch
[1];
11587 DispatchMessageA( &msg
);
11588 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
11589 CallWindowProcA( (WNDPROC
)GetWindowLongPtrA( hwnd
, GWLP_WNDPROC
), hwnd
, WM_CHAR
, dbch
[1], 0 );
11590 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
11592 /* interleaved sends */
11594 SendMessageA( hwnd
, WM_CHAR
, dbch
[0], 0 );
11595 SendMessageCallbackA( hwnd
, WM_CHAR
, dbch
[0], 0, NULL
, 0 );
11596 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
11597 SendMessageTimeoutA( hwnd
, WM_CHAR
, dbch
[1], 0, SMTO_NORMAL
, 0, &res
);
11598 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
11599 SendMessageA( hwnd
, WM_CHAR
, dbch
[1], 0 );
11600 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
11604 SendMessageA( hwnd2
, WM_CHAR
, (dbch
[1] << 8) | dbch
[0], 0 );
11605 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
11606 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
11608 /* other char messages are not magic */
11609 PostMessageA( hwnd
, WM_SYSCHAR
, dbch
[0], 0 );
11610 ok( PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "no message\n" );
11611 ok( msg
.message
== WM_SYSCHAR
, "unexpected message %x\n", msg
.message
);
11612 ok( msg
.wParam
== bad_wch
, "bad wparam %lx/%x\n", msg
.wParam
, bad_wch
);
11613 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
11614 PostMessageA( hwnd
, WM_DEADCHAR
, dbch
[0], 0 );
11615 ok( PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "no message\n" );
11616 ok( msg
.message
== WM_DEADCHAR
, "unexpected message %x\n", msg
.message
);
11617 ok( msg
.wParam
== bad_wch
, "bad wparam %lx/%x\n", msg
.wParam
, bad_wch
);
11618 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
11620 /* test retrieving messages */
11622 PostMessageW( hwnd
, WM_CHAR
, wch
, 0 );
11623 ok( PeekMessageA( &msg
, hwnd
, 0, 0, PM_REMOVE
), "no message\n" );
11624 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
11625 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
11626 ok( msg
.wParam
== dbch
[0], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
11627 ok( PeekMessageA( &msg
, hwnd
, 0, 0, PM_REMOVE
), "no message\n" );
11628 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
11629 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
11630 ok( msg
.wParam
== dbch
[1], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
11631 ok( !PeekMessageA( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
11633 /* message filters */
11634 PostMessageW( hwnd
, WM_CHAR
, wch
, 0 );
11635 ok( PeekMessageA( &msg
, hwnd
, 0, 0, PM_REMOVE
), "no message\n" );
11636 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
11637 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
11638 ok( msg
.wParam
== dbch
[0], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
11639 /* message id is filtered, hwnd is not */
11640 ok( !PeekMessageA( &msg
, hwnd
, WM_MOUSEFIRST
, WM_MOUSELAST
, PM_REMOVE
), "no message\n" );
11641 ok( PeekMessageA( &msg
, hwnd2
, 0, 0, PM_REMOVE
), "no message\n" );
11642 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
11643 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
11644 ok( msg
.wParam
== dbch
[1], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
11645 ok( !PeekMessageA( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
11647 /* mixing GetMessage and PostMessage */
11648 PostMessageW( hwnd
, WM_CHAR
, wch
, 0xbeef );
11649 ok( GetMessageA( &msg
, hwnd
, 0, 0 ), "no message\n" );
11650 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
11651 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
11652 ok( msg
.wParam
== dbch
[0], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
11653 ok( msg
.lParam
== 0xbeef, "bad lparam %lx\n", msg
.lParam
);
11656 ok( time
- GetTickCount() <= 100, "bad time %x\n", msg
.time
);
11657 ok( PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
), "no message\n" );
11658 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
11659 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
11660 ok( msg
.wParam
== dbch
[1], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
11661 ok( msg
.lParam
== 0xbeef, "bad lparam %lx\n", msg
.lParam
);
11662 ok( msg
.time
== time
, "bad time %x/%x\n", msg
.time
, time
);
11663 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
);
11664 ok( !PeekMessageA( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
11666 /* without PM_REMOVE */
11667 PostMessageW( hwnd
, WM_CHAR
, wch
, 0 );
11668 ok( PeekMessageA( &msg
, 0, 0, 0, PM_NOREMOVE
), "no message\n" );
11669 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
11670 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
11671 ok( msg
.wParam
== dbch
[0], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
11672 ok( PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
), "no message\n" );
11673 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
11674 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
11675 ok( msg
.wParam
== dbch
[0], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
11676 ok( PeekMessageA( &msg
, 0, 0, 0, PM_NOREMOVE
), "no message\n" );
11677 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
11678 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
11679 ok( msg
.wParam
== dbch
[1], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
11680 ok( PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
), "no message\n" );
11681 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
11682 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
11683 ok( msg
.wParam
== dbch
[1], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
11684 ok( !PeekMessageA( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
11686 DestroyWindow(hwnd
);
11687 DestroyWindow(hwnd2
);
11690 #define ID_LISTBOX 0x000f
11692 static const struct message wm_lb_setcursel_0
[] =
11694 { LB_SETCURSEL
, sent
|wparam
|lparam
, 0, 0 },
11695 { WM_CTLCOLORLISTBOX
, sent
|parent
},
11696 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x000120f2 },
11697 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 1 },
11698 { EVENT_OBJECT_SELECTION
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 1 },
11701 static const struct message wm_lb_setcursel_1
[] =
11703 { LB_SETCURSEL
, sent
|wparam
|lparam
, 1, 0 },
11704 { WM_CTLCOLORLISTBOX
, sent
|parent
},
11705 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x000020f2 },
11706 { WM_CTLCOLORLISTBOX
, sent
|parent
},
11707 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x000121f2 },
11708 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 2 },
11709 { EVENT_OBJECT_SELECTION
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 2 },
11712 static const struct message wm_lb_setcursel_2
[] =
11714 { LB_SETCURSEL
, sent
|wparam
|lparam
, 2, 0 },
11715 { WM_CTLCOLORLISTBOX
, sent
|parent
},
11716 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x000021f2 },
11717 { WM_CTLCOLORLISTBOX
, sent
|parent
},
11718 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x000122f2 },
11719 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 3 },
11720 { EVENT_OBJECT_SELECTION
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 3 },
11723 static const struct message wm_lb_click_0
[] =
11725 { WM_LBUTTONDOWN
, sent
|wparam
|lparam
, 0, MAKELPARAM(1,1) },
11726 { HCBT_SETFOCUS
, hook
},
11727 { WM_KILLFOCUS
, sent
|parent
},
11728 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
|parent
, 0 },
11729 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
11730 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
11731 { WM_SETFOCUS
, sent
|defwinproc
},
11733 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x001142f2 },
11734 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_LISTBOX
, LBN_SETFOCUS
) },
11735 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 3 },
11736 { WM_LBTRACKPOINT
, sent
|wparam
|lparam
|parent
, 0, MAKELPARAM(1,1) },
11737 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
11739 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x000142f2 },
11740 { WM_CTLCOLORLISTBOX
, sent
|parent
},
11741 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x000022f2 },
11742 { WM_CTLCOLORLISTBOX
, sent
|parent
},
11743 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x000120f2 },
11744 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x001140f2 },
11746 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 1 },
11747 { EVENT_OBJECT_SELECTION
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 1 },
11749 { WM_LBUTTONUP
, sent
|wparam
|lparam
, 0, 0 },
11750 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, 0, 0 },
11751 { WM_CAPTURECHANGED
, sent
|wparam
|lparam
|defwinproc
, 0, 0 },
11752 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_LISTBOX
, LBN_SELCHANGE
) },
11755 static const struct message wm_lb_deletestring
[] =
11757 { LB_DELETESTRING
, sent
|wparam
|lparam
, 0, 0 },
11758 { WM_DELETEITEM
, sent
|wparam
|parent
|optional
, ID_LISTBOX
, 0 },
11759 { WM_DRAWITEM
, sent
|wparam
|parent
|optional
, ID_LISTBOX
},
11760 { WM_DRAWITEM
, sent
|wparam
|parent
|optional
, ID_LISTBOX
},
11763 static const struct message wm_lb_deletestring_reset
[] =
11765 { LB_DELETESTRING
, sent
|wparam
|lparam
, 0, 0 },
11766 { LB_RESETCONTENT
, sent
|wparam
|lparam
|defwinproc
|optional
, 0, 0 },
11767 { WM_DELETEITEM
, sent
|wparam
|parent
|optional
, ID_LISTBOX
, 0 },
11768 { WM_DRAWITEM
, sent
|wparam
|parent
|optional
, ID_LISTBOX
},
11769 { WM_DRAWITEM
, sent
|wparam
|parent
|optional
, ID_LISTBOX
},
11773 #define check_lb_state(a1, a2, a3, a4, a5) check_lb_state_dbg(a1, a2, a3, a4, a5, __LINE__)
11775 static LRESULT (WINAPI
*listbox_orig_proc
)(HWND
, UINT
, WPARAM
, LPARAM
);
11777 static LRESULT WINAPI
listbox_hook_proc(HWND hwnd
, UINT message
, WPARAM wp
, LPARAM lp
)
11779 static LONG defwndproc_counter
= 0;
11781 struct recvd_message msg
;
11783 /* do not log painting messages */
11784 if (message
!= WM_PAINT
&&
11785 message
!= WM_NCPAINT
&&
11786 message
!= WM_SYNCPAINT
&&
11787 message
!= WM_ERASEBKGND
&&
11788 message
!= WM_NCHITTEST
&&
11789 message
!= WM_GETTEXT
&&
11790 !ignore_message( message
))
11793 msg
.message
= message
;
11794 msg
.flags
= sent
|wparam
|lparam
;
11795 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
11798 msg
.descr
= "listbox";
11802 defwndproc_counter
++;
11803 ret
= CallWindowProcA(listbox_orig_proc
, hwnd
, message
, wp
, lp
);
11804 defwndproc_counter
--;
11809 static void check_lb_state_dbg(HWND listbox
, int count
, int cur_sel
,
11810 int caret_index
, int top_index
, int line
)
11814 /* calling an orig proc helps to avoid unnecessary message logging */
11815 ret
= CallWindowProcA(listbox_orig_proc
, listbox
, LB_GETCOUNT
, 0, 0);
11816 ok_(__FILE__
, line
)(ret
== count
, "expected count %d, got %ld\n", count
, ret
);
11817 ret
= CallWindowProcA(listbox_orig_proc
, listbox
, LB_GETCURSEL
, 0, 0);
11818 ok_(__FILE__
, line
)(ret
== cur_sel
, "expected cur sel %d, got %ld\n", cur_sel
, ret
);
11819 ret
= CallWindowProcA(listbox_orig_proc
, listbox
, LB_GETCARETINDEX
, 0, 0);
11820 ok_(__FILE__
, line
)(ret
== caret_index
||
11821 broken(cur_sel
== -1 && caret_index
== 0 && ret
== -1), /* nt4 */
11822 "expected caret index %d, got %ld\n", caret_index
, ret
);
11823 ret
= CallWindowProcA(listbox_orig_proc
, listbox
, LB_GETTOPINDEX
, 0, 0);
11824 ok_(__FILE__
, line
)(ret
== top_index
, "expected top index %d, got %ld\n", top_index
, ret
);
11827 static void test_listbox_messages(void)
11829 HWND parent
, listbox
;
11832 parent
= CreateWindowExA(0, "TestParentClass", NULL
, WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
11833 100, 100, 200, 200, 0, 0, 0, NULL
);
11834 listbox
= CreateWindowExA(WS_EX_NOPARENTNOTIFY
, "ListBox", NULL
,
11835 WS_CHILD
| LBS_NOTIFY
| LBS_OWNERDRAWVARIABLE
| LBS_HASSTRINGS
| WS_VISIBLE
,
11836 10, 10, 80, 80, parent
, (HMENU
)ID_LISTBOX
, 0, NULL
);
11837 listbox_orig_proc
= (WNDPROC
)SetWindowLongPtrA(listbox
, GWLP_WNDPROC
, (ULONG_PTR
)listbox_hook_proc
);
11839 check_lb_state(listbox
, 0, LB_ERR
, 0, 0);
11841 ret
= SendMessage(listbox
, LB_ADDSTRING
, 0, (LPARAM
)"item 0");
11842 ok(ret
== 0, "expected 0, got %ld\n", ret
);
11843 ret
= SendMessage(listbox
, LB_ADDSTRING
, 0, (LPARAM
)"item 1");
11844 ok(ret
== 1, "expected 1, got %ld\n", ret
);
11845 ret
= SendMessage(listbox
, LB_ADDSTRING
, 0, (LPARAM
)"item 2");
11846 ok(ret
== 2, "expected 2, got %ld\n", ret
);
11848 check_lb_state(listbox
, 3, LB_ERR
, 0, 0);
11852 log_all_parent_messages
++;
11854 trace("selecting item 0\n");
11855 ret
= SendMessage(listbox
, LB_SETCURSEL
, 0, 0);
11856 ok(ret
== 0, "expected 0, got %ld\n", ret
);
11857 ok_sequence(wm_lb_setcursel_0
, "LB_SETCURSEL 0", FALSE
);
11858 check_lb_state(listbox
, 3, 0, 0, 0);
11861 trace("selecting item 1\n");
11862 ret
= SendMessage(listbox
, LB_SETCURSEL
, 1, 0);
11863 ok(ret
== 1, "expected 1, got %ld\n", ret
);
11864 ok_sequence(wm_lb_setcursel_1
, "LB_SETCURSEL 1", FALSE
);
11865 check_lb_state(listbox
, 3, 1, 1, 0);
11867 trace("selecting item 2\n");
11868 ret
= SendMessage(listbox
, LB_SETCURSEL
, 2, 0);
11869 ok(ret
== 2, "expected 2, got %ld\n", ret
);
11870 ok_sequence(wm_lb_setcursel_2
, "LB_SETCURSEL 2", FALSE
);
11871 check_lb_state(listbox
, 3, 2, 2, 0);
11873 trace("clicking on item 0\n");
11874 ret
= SendMessage(listbox
, WM_LBUTTONDOWN
, 0, MAKELPARAM(1, 1));
11875 ok(ret
== LB_OKAY
, "expected LB_OKAY, got %ld\n", ret
);
11876 ret
= SendMessage(listbox
, WM_LBUTTONUP
, 0, 0);
11877 ok(ret
== LB_OKAY
, "expected LB_OKAY, got %ld\n", ret
);
11878 ok_sequence(wm_lb_click_0
, "WM_LBUTTONDOWN 0", FALSE
);
11879 check_lb_state(listbox
, 3, 0, 0, 0);
11882 trace("deleting item 0\n");
11883 ret
= SendMessage(listbox
, LB_DELETESTRING
, 0, 0);
11884 ok(ret
== 2, "expected 2, got %ld\n", ret
);
11885 ok_sequence(wm_lb_deletestring
, "LB_DELETESTRING 0", FALSE
);
11886 check_lb_state(listbox
, 2, -1, 0, 0);
11889 trace("deleting item 0\n");
11890 ret
= SendMessage(listbox
, LB_DELETESTRING
, 0, 0);
11891 ok(ret
== 1, "expected 1, got %ld\n", ret
);
11892 ok_sequence(wm_lb_deletestring
, "LB_DELETESTRING 0", FALSE
);
11893 check_lb_state(listbox
, 1, -1, 0, 0);
11896 trace("deleting item 0\n");
11897 ret
= SendMessage(listbox
, LB_DELETESTRING
, 0, 0);
11898 ok(ret
== 0, "expected 0, got %ld\n", ret
);
11899 ok_sequence(wm_lb_deletestring_reset
, "LB_DELETESTRING 0", FALSE
);
11900 check_lb_state(listbox
, 0, -1, 0, 0);
11903 trace("deleting item 0\n");
11904 ret
= SendMessage(listbox
, LB_DELETESTRING
, 0, 0);
11905 ok(ret
== LB_ERR
, "expected LB_ERR, got %ld\n", ret
);
11906 check_lb_state(listbox
, 0, -1, 0, 0);
11909 log_all_parent_messages
--;
11911 DestroyWindow(listbox
);
11912 DestroyWindow(parent
);
11915 /*************************** Menu test ******************************/
11916 static const struct message wm_popup_menu_1
[] =
11918 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 },
11919 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
11920 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'E', 0x20000001 },
11921 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, 'E', 0x20000001 },
11922 { WM_SYSCHAR
, sent
|wparam
|lparam
, 'e', 0x20000001 },
11923 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_KEYMENU
, 'e' },
11924 { WM_ENTERMENULOOP
, sent
|wparam
|lparam
, 0, 0 },
11925 { WM_INITMENU
, sent
|lparam
, 0, 0 },
11926 { WM_MENUSELECT
, sent
|wparam
, MAKEWPARAM(1,MF_HILITE
|MF_POPUP
) },
11927 { WM_INITMENUPOPUP
, sent
|lparam
, 0, 1 },
11928 { HCBT_CREATEWND
, hook
|optional
}, /* Win9x doesn't create a window */
11929 { WM_MENUSELECT
, sent
|wparam
, MAKEWPARAM(200,MF_HILITE
) },
11930 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'E', 0xf0000001 },
11931 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xd0000001 },
11932 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_RETURN
, 0x10000001, 0, 0x40000000 },
11933 { HCBT_DESTROYWND
, hook
|optional
}, /* Win9x doesn't create a window */
11934 { WM_UNINITMENUPOPUP
, sent
|lparam
, 0, 0 },
11935 { WM_MENUSELECT
, sent
|wparam
|lparam
, MAKEWPARAM(0,0xffff), 0 },
11936 { WM_EXITMENULOOP
, sent
|wparam
|lparam
, 0, 0 },
11937 { WM_MENUCOMMAND
, sent
}, /* |wparam, 200 - Win9x */
11938 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_RETURN
, 0xc0000001 },
11939 { WM_KEYUP
, sent
|wparam
|lparam
, VK_RETURN
, 0xc0000001 },
11942 static const struct message wm_popup_menu_2
[] =
11944 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 },
11945 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
11946 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'F', 0x20000001 },
11947 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, 'F', 0x20000001 },
11948 { WM_SYSCHAR
, sent
|wparam
|lparam
, 'f', 0x20000001 },
11949 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_KEYMENU
, 'f' },
11950 { WM_ENTERMENULOOP
, sent
|wparam
|lparam
, 0, 0 },
11951 { WM_INITMENU
, sent
|lparam
, 0, 0 },
11952 { WM_MENUSELECT
, sent
|wparam
, MAKEWPARAM(0,MF_HILITE
|MF_POPUP
) },
11953 { WM_INITMENUPOPUP
, sent
|lparam
, 0, 0 },
11954 { WM_MENUSELECT
, sent
|wparam
|optional
, MAKEWPARAM(0,MF_HILITE
|MF_POPUP
) }, /* Win9x */
11955 { WM_INITMENUPOPUP
, sent
|lparam
|optional
, 0, 0 }, /* Win9x */
11956 { HCBT_CREATEWND
, hook
},
11957 { WM_MENUSELECT
, sent
}, /*|wparam, MAKEWPARAM(0,MF_HILITE|MF_POPUP) - XP
11958 |wparam, MAKEWPARAM(100,MF_HILITE) - Win9x */
11959 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'F', 0xf0000001 },
11960 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xd0000001 },
11961 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_RIGHT
, 0x10000001 },
11962 { WM_INITMENUPOPUP
, sent
|lparam
|optional
, 0, 0 }, /* Win9x doesn't send it */
11963 { HCBT_CREATEWND
, hook
|optional
}, /* Win9x doesn't send it */
11964 { WM_MENUSELECT
, sent
|wparam
|optional
, MAKEWPARAM(100,MF_HILITE
) },
11965 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_RIGHT
, 0xd0000001 },
11966 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_RETURN
, 0x10000001 },
11967 { HCBT_DESTROYWND
, hook
},
11968 { WM_UNINITMENUPOPUP
, sent
|lparam
, 0, 0 },
11969 { HCBT_DESTROYWND
, hook
|optional
}, /* Win9x doesn't send it */
11970 { WM_UNINITMENUPOPUP
, sent
|lparam
, 0, 0 },
11971 { WM_MENUSELECT
, sent
|wparam
|lparam
, MAKEWPARAM(0,0xffff), 0 },
11972 { WM_EXITMENULOOP
, sent
|wparam
|lparam
, 0, 0 },
11973 { WM_MENUCOMMAND
, sent
}, /* |wparam, 100 - Win9x */
11974 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_RETURN
, 0xc0000001 },
11975 { WM_KEYUP
, sent
|wparam
|lparam
, VK_RETURN
, 0xc0000001 },
11978 static const struct message wm_popup_menu_3
[] =
11980 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 },
11981 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
11982 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'F', 0x20000001 },
11983 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, 'F', 0x20000001 },
11984 { WM_SYSCHAR
, sent
|wparam
|lparam
, 'f', 0x20000001 },
11985 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_KEYMENU
, 'f' },
11986 { WM_ENTERMENULOOP
, sent
|wparam
|lparam
, 0, 0 },
11987 { WM_INITMENU
, sent
|lparam
, 0, 0 },
11988 { WM_MENUSELECT
, sent
|wparam
, MAKEWPARAM(0,MF_HILITE
|MF_POPUP
) },
11989 { WM_INITMENUPOPUP
, sent
|lparam
, 0, 0 },
11990 { WM_MENUSELECT
, sent
|wparam
|optional
, MAKEWPARAM(0,MF_HILITE
|MF_POPUP
) }, /* Win9x */
11991 { WM_INITMENUPOPUP
, sent
|lparam
|optional
, 0, 0 }, /* Win9x */
11992 { HCBT_CREATEWND
, hook
},
11993 { WM_MENUSELECT
, sent
}, /*|wparam, MAKEWPARAM(0,MF_HILITE|MF_POPUP) - XP
11994 |wparam, MAKEWPARAM(100,MF_HILITE) - Win9x */
11995 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'F', 0xf0000001 },
11996 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xd0000001 },
11997 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_RIGHT
, 0x10000001 },
11998 { WM_INITMENUPOPUP
, sent
|lparam
|optional
, 0, 0 }, /* Win9x doesn't send it */
11999 { HCBT_CREATEWND
, hook
|optional
}, /* Win9x doesn't send it */
12000 { WM_MENUSELECT
, sent
|wparam
|optional
, MAKEWPARAM(100,MF_HILITE
) },
12001 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_RIGHT
, 0xd0000001 },
12002 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_RETURN
, 0x10000001 },
12003 { HCBT_DESTROYWND
, hook
},
12004 { WM_UNINITMENUPOPUP
, sent
|lparam
, 0, 0 },
12005 { HCBT_DESTROYWND
, hook
|optional
}, /* Win9x doesn't send it */
12006 { WM_UNINITMENUPOPUP
, sent
|lparam
, 0, 0 },
12007 { WM_MENUSELECT
, sent
|wparam
|lparam
, MAKEWPARAM(0,0xffff), 0 },
12008 { WM_EXITMENULOOP
, sent
|wparam
|lparam
, 0, 0 },
12009 { WM_COMMAND
, sent
|wparam
|lparam
, 100, 0 },
12010 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_RETURN
, 0xc0000001 },
12011 { WM_KEYUP
, sent
|wparam
|lparam
, VK_RETURN
, 0xc0000001 },
12015 static const struct message wm_single_menu_item
[] =
12017 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 },
12018 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
12019 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'Q', 0x20000001 },
12020 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, 'Q', 0x20000001 },
12021 { WM_SYSCHAR
, sent
|wparam
|lparam
, 'q', 0x20000001 },
12022 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_KEYMENU
, 'q' },
12023 { WM_ENTERMENULOOP
, sent
|wparam
|lparam
, 0, 0 },
12024 { WM_INITMENU
, sent
|lparam
, 0, 0 },
12025 { WM_MENUSELECT
, sent
|wparam
|optional
, MAKEWPARAM(300,MF_HILITE
) },
12026 { WM_MENUSELECT
, sent
|wparam
|lparam
, MAKEWPARAM(0,0xffff), 0 },
12027 { WM_EXITMENULOOP
, sent
|wparam
|lparam
, 0, 0 },
12028 { WM_MENUCOMMAND
, sent
},
12029 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'Q', 0xe0000001 },
12030 { WM_SYSKEYUP
, sent
|wparam
|lparam
, 'Q', 0xe0000001 },
12031 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xc0000001 },
12032 { WM_KEYUP
, sent
|wparam
|lparam
, VK_MENU
, 0xc0000001 },
12034 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_ESCAPE
, 1 },
12035 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_ESCAPE
, 1 },
12036 { WM_CHAR
, sent
|wparam
|lparam
, VK_ESCAPE
, 0x00000001 },
12037 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_ESCAPE
, 0xc0000001 },
12038 { WM_KEYUP
, sent
|wparam
|lparam
, VK_ESCAPE
, 0xc0000001 },
12042 static LRESULT WINAPI
parent_menu_proc(HWND hwnd
, UINT message
, WPARAM wp
, LPARAM lp
)
12044 if (message
== WM_ENTERIDLE
||
12045 message
== WM_INITMENU
||
12046 message
== WM_INITMENUPOPUP
||
12047 message
== WM_MENUSELECT
||
12048 message
== WM_PARENTNOTIFY
||
12049 message
== WM_ENTERMENULOOP
||
12050 message
== WM_EXITMENULOOP
||
12051 message
== WM_UNINITMENUPOPUP
||
12052 message
== WM_KEYDOWN
||
12053 message
== WM_KEYUP
||
12054 message
== WM_CHAR
||
12055 message
== WM_SYSKEYDOWN
||
12056 message
== WM_SYSKEYUP
||
12057 message
== WM_SYSCHAR
||
12058 message
== WM_COMMAND
||
12059 message
== WM_MENUCOMMAND
)
12061 struct recvd_message msg
;
12064 msg
.message
= message
;
12065 msg
.flags
= sent
|wparam
|lparam
;
12068 msg
.descr
= "parent_menu_proc";
12072 return DefWindowProcA(hwnd
, message
, wp
, lp
);
12075 static void set_menu_style(HMENU hmenu
, DWORD style
)
12080 mi
.cbSize
= sizeof(mi
);
12081 mi
.fMask
= MIM_STYLE
;
12082 mi
.dwStyle
= style
;
12083 SetLastError(0xdeadbeef);
12084 ret
= pSetMenuInfo(hmenu
, &mi
);
12085 ok(ret
, "SetMenuInfo error %u\n", GetLastError());
12088 static DWORD
get_menu_style(HMENU hmenu
)
12093 mi
.cbSize
= sizeof(mi
);
12094 mi
.fMask
= MIM_STYLE
;
12096 SetLastError(0xdeadbeef);
12097 ret
= pGetMenuInfo(hmenu
, &mi
);
12098 ok(ret
, "GetMenuInfo error %u\n", GetLastError());
12103 static void test_menu_messages(void)
12107 HMENU hmenu
, hmenu_popup
;
12111 if (!pGetMenuInfo
|| !pSetMenuInfo
)
12113 win_skip("GetMenuInfo and/or SetMenuInfo are not available\n");
12117 cls
.lpfnWndProc
= parent_menu_proc
;
12118 cls
.cbClsExtra
= 0;
12119 cls
.cbWndExtra
= 0;
12120 cls
.hInstance
= GetModuleHandleA(0);
12122 cls
.hCursor
= LoadCursorA(0, IDC_ARROW
);
12123 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
12124 cls
.lpszMenuName
= NULL
;
12125 cls
.lpszClassName
= "TestMenuClass";
12126 UnregisterClass(cls
.lpszClassName
, cls
.hInstance
);
12127 if (!RegisterClassA(&cls
)) assert(0);
12129 SetLastError(0xdeadbeef);
12130 hwnd
= CreateWindowExA(0, "TestMenuClass", NULL
, WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
12131 100, 100, 200, 200, 0, 0, 0, NULL
);
12132 ok(hwnd
!= 0, "LoadMenuA error %u\n", GetLastError());
12134 SetLastError(0xdeadbeef);
12135 hmenu
= LoadMenuA(GetModuleHandle(0), MAKEINTRESOURCE(1));
12136 ok(hmenu
!= 0, "LoadMenuA error %u\n", GetLastError());
12138 SetMenu(hwnd
, hmenu
);
12139 SetForegroundWindow( hwnd
);
12141 set_menu_style(hmenu
, MNS_NOTIFYBYPOS
);
12142 style
= get_menu_style(hmenu
);
12143 ok(style
== MNS_NOTIFYBYPOS
, "expected MNS_NOTIFYBYPOS, got %u\n", style
);
12145 hmenu_popup
= GetSubMenu(hmenu
, 0);
12146 ok(hmenu_popup
!= 0, "GetSubMenu returned 0 for submenu 0\n");
12147 style
= get_menu_style(hmenu_popup
);
12148 ok(style
== 0, "expected 0, got %u\n", style
);
12150 hmenu_popup
= GetSubMenu(hmenu_popup
, 0);
12151 ok(hmenu_popup
!= 0, "GetSubMenu returned 0 for submenu 0\n");
12152 style
= get_menu_style(hmenu_popup
);
12153 ok(style
== 0, "expected 0, got %u\n", style
);
12156 trace("testing a popup menu command\n");
12158 keybd_event(VK_MENU
, 0, 0, 0);
12159 keybd_event('E', 0, 0, 0);
12160 keybd_event('E', 0, KEYEVENTF_KEYUP
, 0);
12161 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
12162 keybd_event(VK_RETURN
, 0, 0, 0);
12163 keybd_event(VK_RETURN
, 0, KEYEVENTF_KEYUP
, 0);
12164 while (PeekMessage(&msg
, 0, 0, 0, PM_REMOVE
))
12166 TranslateMessage(&msg
);
12167 DispatchMessage(&msg
);
12169 if (!sequence_cnt
) /* we didn't get any message */
12171 skip( "queuing key events not supported\n" );
12174 /* win98 queues only a WM_KEYUP and doesn't start menu tracking */
12175 if (sequence
[0].message
== WM_KEYUP
&& sequence
[0].wParam
== VK_MENU
)
12177 win_skip( "menu tracking through VK_MENU not supported\n" );
12180 ok_sequence(wm_popup_menu_1
, "popup menu command", FALSE
);
12182 /* Alt+F, Right, Enter */
12183 trace("testing submenu of a popup menu command\n");
12185 keybd_event(VK_MENU
, 0, 0, 0);
12186 keybd_event('F', 0, 0, 0);
12187 keybd_event('F', 0, KEYEVENTF_KEYUP
, 0);
12188 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
12189 keybd_event(VK_RIGHT
, 0, 0, 0);
12190 keybd_event(VK_RIGHT
, 0, KEYEVENTF_KEYUP
, 0);
12191 keybd_event(VK_RETURN
, 0, 0, 0);
12192 keybd_event(VK_RETURN
, 0, KEYEVENTF_KEYUP
, 0);
12193 while (PeekMessage(&msg
, 0, 0, 0, PM_REMOVE
))
12195 TranslateMessage(&msg
);
12196 DispatchMessage(&msg
);
12198 ok_sequence(wm_popup_menu_2
, "submenu of a popup menu command", FALSE
);
12200 trace("testing single menu item command\n");
12202 keybd_event(VK_MENU
, 0, 0, 0);
12203 keybd_event('Q', 0, 0, 0);
12204 keybd_event('Q', 0, KEYEVENTF_KEYUP
, 0);
12205 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
12206 keybd_event(VK_ESCAPE
, 0, 0, 0);
12207 keybd_event(VK_ESCAPE
, 0, KEYEVENTF_KEYUP
, 0);
12208 while (PeekMessage(&msg
, 0, 0, 0, PM_REMOVE
))
12210 TranslateMessage(&msg
);
12211 DispatchMessage(&msg
);
12213 ok_sequence(wm_single_menu_item
, "single menu item command", FALSE
);
12215 set_menu_style(hmenu
, 0);
12216 style
= get_menu_style(hmenu
);
12217 ok(style
== 0, "expected 0, got %u\n", style
);
12219 hmenu_popup
= GetSubMenu(hmenu
, 0);
12220 ok(hmenu_popup
!= 0, "GetSubMenu returned 0 for submenu 0\n");
12221 set_menu_style(hmenu_popup
, MNS_NOTIFYBYPOS
);
12222 style
= get_menu_style(hmenu_popup
);
12223 ok(style
== MNS_NOTIFYBYPOS
, "expected MNS_NOTIFYBYPOS, got %u\n", style
);
12225 hmenu_popup
= GetSubMenu(hmenu_popup
, 0);
12226 ok(hmenu_popup
!= 0, "GetSubMenu returned 0 for submenu 0\n");
12227 style
= get_menu_style(hmenu_popup
);
12228 ok(style
== 0, "expected 0, got %u\n", style
);
12230 /* Alt+F, Right, Enter */
12231 trace("testing submenu of a popup menu command\n");
12233 keybd_event(VK_MENU
, 0, 0, 0);
12234 keybd_event('F', 0, 0, 0);
12235 keybd_event('F', 0, KEYEVENTF_KEYUP
, 0);
12236 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
12237 keybd_event(VK_RIGHT
, 0, 0, 0);
12238 keybd_event(VK_RIGHT
, 0, KEYEVENTF_KEYUP
, 0);
12239 keybd_event(VK_RETURN
, 0, 0, 0);
12240 keybd_event(VK_RETURN
, 0, KEYEVENTF_KEYUP
, 0);
12241 while (PeekMessage(&msg
, 0, 0, 0, PM_REMOVE
))
12243 TranslateMessage(&msg
);
12244 DispatchMessage(&msg
);
12246 ok_sequence(wm_popup_menu_3
, "submenu of a popup menu command", FALSE
);
12249 DestroyWindow(hwnd
);
12250 DestroyMenu(hmenu
);
12254 static void test_paintingloop(void)
12258 paint_loop_done
= 0;
12259 hwnd
= CreateWindowExA(0x0,"PaintLoopWindowClass",
12260 "PaintLoopWindowClass",WS_OVERLAPPEDWINDOW
,
12261 100, 100, 100, 100, 0, 0, 0, NULL
);
12262 ok(hwnd
!= 0, "PaintLoop window error %u\n", GetLastError());
12263 ShowWindow(hwnd
,SW_NORMAL
);
12266 while (!paint_loop_done
)
12269 if (PeekMessageA(&msg
, 0, 0, 0, 1))
12271 TranslateMessage(&msg
);
12272 DispatchMessage(&msg
);
12275 DestroyWindow(hwnd
);
12278 static void test_defwinproc(void)
12282 int gotwmquit
= FALSE
;
12283 hwnd
= CreateWindowExA(0, "static", "test_defwndproc", WS_POPUP
, 0,0,0,0,0,0,0, NULL
);
12285 DefWindowProcA( hwnd
, WM_ENDSESSION
, 1, 0);
12286 while (PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
)) {
12287 if( msg
.message
== WM_QUIT
) gotwmquit
= TRUE
;
12288 DispatchMessageA( &msg
);
12290 ok( gotwmquit
== FALSE
, "Unexpected WM_QUIT message!\n");
12291 DestroyWindow( hwnd
);
12294 #define clear_clipboard(hwnd) clear_clipboard_(__LINE__, (hwnd))
12295 static void clear_clipboard_(int line
, HWND hWnd
)
12298 succ
= OpenClipboard(hWnd
);
12299 ok_(__FILE__
, line
)(succ
, "OpenClipboard failed, err=%u\n", GetLastError());
12300 succ
= EmptyClipboard();
12301 ok_(__FILE__
, line
)(succ
, "EmptyClipboard failed, err=%u\n", GetLastError());
12302 succ
= CloseClipboard();
12303 ok_(__FILE__
, line
)(succ
, "CloseClipboard failed, err=%u\n", GetLastError());
12306 #define expect_HWND(expected, got) expect_HWND_(__LINE__, (expected), (got))
12307 static void expect_HWND_(int line
, HWND expected
, HWND got
)
12309 ok_(__FILE__
, line
)(got
==expected
, "Expected %p, got %p\n", expected
, got
);
12312 static WNDPROC pOldViewerProc
;
12314 static LRESULT CALLBACK
recursive_viewer_proc(HWND hWnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
12316 static BOOL recursion_guard
;
12318 if (message
== WM_DRAWCLIPBOARD
&& !recursion_guard
)
12320 recursion_guard
= TRUE
;
12321 clear_clipboard(hWnd
);
12322 recursion_guard
= FALSE
;
12324 return CallWindowProcA(pOldViewerProc
, hWnd
, message
, wParam
, lParam
);
12327 static void test_clipboard_viewers(void)
12329 static struct message wm_change_cb_chain
[] =
12331 { WM_CHANGECBCHAIN
, sent
|wparam
|lparam
, 0, 0 },
12334 static const struct message wm_clipboard_destroyed
[] =
12336 { WM_DESTROYCLIPBOARD
, sent
|wparam
|lparam
, 0, 0 },
12339 static struct message wm_clipboard_changed
[] =
12341 { WM_DRAWCLIPBOARD
, sent
|wparam
|lparam
, 0, 0 },
12344 static struct message wm_clipboard_changed_and_owned
[] =
12346 { WM_DESTROYCLIPBOARD
, sent
|wparam
|lparam
, 0, 0 },
12347 { WM_DRAWCLIPBOARD
, sent
|wparam
|lparam
, 0, 0 },
12351 HINSTANCE hInst
= GetModuleHandleA(NULL
);
12352 HWND hWnd1
, hWnd2
, hWnd3
;
12356 hWnd1
= CreateWindowExA(0, "TestWindowClass", "Clipboard viewer test wnd 1",
12357 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
| WS_MAXIMIZEBOX
,
12358 CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
,
12359 GetDesktopWindow(), NULL
, hInst
, NULL
);
12360 hWnd2
= CreateWindowExA(0, "SimpleWindowClass", "Clipboard viewer test wnd 2",
12361 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
| WS_MAXIMIZEBOX
,
12362 CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
,
12363 GetDesktopWindow(), NULL
, hInst
, NULL
);
12364 hWnd3
= CreateWindowExA(0, "SimpleWindowClass", "Clipboard viewer test wnd 3",
12365 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
| WS_MAXIMIZEBOX
,
12366 CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
,
12367 GetDesktopWindow(), NULL
, hInst
, NULL
);
12368 trace("clipbd viewers: hWnd1=%p, hWnd2=%p, hWnd3=%p\n", hWnd1
, hWnd2
, hWnd3
);
12369 assert(hWnd1
&& hWnd2
&& hWnd3
);
12373 /* Test getting the clipboard viewer and setting the viewer to NULL. */
12374 hOrigViewer
= GetClipboardViewer();
12375 hRet
= SetClipboardViewer(NULL
);
12376 ok_sequence(WmEmptySeq
, "set viewer to NULL", FALSE
);
12377 expect_HWND(hOrigViewer
, hRet
);
12378 expect_HWND(NULL
, GetClipboardViewer());
12380 /* Test registering hWnd1 as a viewer. */
12381 hRet
= SetClipboardViewer(hWnd1
);
12382 wm_clipboard_changed
[0].wParam
= (WPARAM
) GetClipboardOwner();
12383 ok_sequence(wm_clipboard_changed
, "set viewer NULL->1", FALSE
);
12384 expect_HWND(NULL
, hRet
);
12385 expect_HWND(hWnd1
, GetClipboardViewer());
12387 /* Test that changing the clipboard actually refreshes the registered viewer. */
12388 clear_clipboard(hWnd1
);
12389 wm_clipboard_changed
[0].wParam
= (WPARAM
) GetClipboardOwner();
12390 ok_sequence(wm_clipboard_changed
, "clear clipbd (viewer=owner=1)", FALSE
);
12392 /* Again, but with different owner. */
12393 clear_clipboard(hWnd2
);
12394 wm_clipboard_changed_and_owned
[1].wParam
= (WPARAM
) GetClipboardOwner();
12395 ok_sequence(wm_clipboard_changed_and_owned
, "clear clipbd (viewer=1, owner=2)", FALSE
);
12397 /* Test re-registering same window. */
12398 hRet
= SetClipboardViewer(hWnd1
);
12399 wm_clipboard_changed
[0].wParam
= (WPARAM
) GetClipboardOwner();
12400 ok_sequence(wm_clipboard_changed
, "set viewer 1->1", FALSE
);
12401 expect_HWND(hWnd1
, hRet
);
12402 expect_HWND(hWnd1
, GetClipboardViewer());
12404 /* Test ChangeClipboardChain. */
12405 ChangeClipboardChain(hWnd2
, hWnd3
);
12406 wm_change_cb_chain
[0].wParam
= (WPARAM
) hWnd2
;
12407 wm_change_cb_chain
[0].lParam
= (LPARAM
) hWnd3
;
12408 ok_sequence(wm_change_cb_chain
, "change chain (viewer=1, remove=2, next=3)", FALSE
);
12409 expect_HWND(hWnd1
, GetClipboardViewer());
12411 ChangeClipboardChain(hWnd2
, NULL
);
12412 wm_change_cb_chain
[0].wParam
= (WPARAM
) hWnd2
;
12413 wm_change_cb_chain
[0].lParam
= 0;
12414 ok_sequence(wm_change_cb_chain
, "change chain (viewer=1, remove=2, next=NULL)", FALSE
);
12415 expect_HWND(hWnd1
, GetClipboardViewer());
12417 ChangeClipboardChain(NULL
, hWnd2
);
12418 ok_sequence(WmEmptySeq
, "change chain (viewer=1, remove=NULL, next=2)", TRUE
);
12419 expect_HWND(hWnd1
, GetClipboardViewer());
12421 /* Actually change clipboard viewer with ChangeClipboardChain. */
12422 ChangeClipboardChain(hWnd1
, hWnd2
);
12423 ok_sequence(WmEmptySeq
, "change chain (viewer=remove=1, next=2)", FALSE
);
12424 expect_HWND(hWnd2
, GetClipboardViewer());
12426 /* Test that no refresh messages are sent when viewer has unregistered. */
12427 clear_clipboard(hWnd2
);
12428 ok_sequence(WmEmptySeq
, "clear clipd (viewer=2, owner=1)", FALSE
);
12430 /* Register hWnd1 again. */
12431 ChangeClipboardChain(hWnd2
, hWnd1
);
12432 ok_sequence(WmEmptySeq
, "change chain (viewer=remove=2, next=1)", FALSE
);
12433 expect_HWND(hWnd1
, GetClipboardViewer());
12435 /* Subclass hWnd1 so that when it receives a WM_DRAWCLIPBOARD message, it
12436 * changes the clipboard. When this happens, the system shouldn't send
12437 * another WM_DRAWCLIPBOARD (as this could cause an infinite loop).
12439 pOldViewerProc
= (WNDPROC
) SetWindowLongPtrA(hWnd1
, GWLP_WNDPROC
, (LONG_PTR
) recursive_viewer_proc
);
12440 clear_clipboard(hWnd2
);
12441 /* The clipboard owner is changed in recursive_viewer_proc: */
12442 wm_clipboard_changed
[0].wParam
= (WPARAM
) hWnd2
;
12443 ok_sequence(wm_clipboard_changed
, "recursive clear clipbd (viewer=1, owner=2)", TRUE
);
12445 /* Test unregistering. */
12446 ChangeClipboardChain(hWnd1
, NULL
);
12447 ok_sequence(WmEmptySeq
, "change chain (viewer=remove=1, next=NULL)", FALSE
);
12448 expect_HWND(NULL
, GetClipboardViewer());
12450 clear_clipboard(hWnd1
);
12451 ok_sequence(wm_clipboard_destroyed
, "clear clipbd (no viewer, owner=1)", FALSE
);
12453 DestroyWindow(hWnd1
);
12454 DestroyWindow(hWnd2
);
12455 DestroyWindow(hWnd3
);
12456 SetClipboardViewer(hOrigViewer
);
12459 static void test_PostMessage(void)
12461 static const struct
12467 { HWND_TOP
/* 0 */, TRUE
},
12468 { HWND_BROADCAST
, TRUE
},
12469 { HWND_BOTTOM
, TRUE
},
12470 { HWND_TOPMOST
, TRUE
},
12471 { HWND_NOTOPMOST
, FALSE
},
12472 { HWND_MESSAGE
, FALSE
},
12473 { (HWND
)0xdeadbeef, FALSE
}
12479 static const WCHAR staticW
[] = {'s','t','a','t','i','c',0};
12481 SetLastError(0xdeadbeef);
12482 hwnd
= CreateWindowExW(0, staticW
, NULL
, WS_POPUP
, 0,0,0,0,0,0,0, NULL
);
12483 if (!hwnd
&& GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
)
12485 win_skip("Skipping some PostMessage tests on Win9x/WinMe\n");
12492 PostMessage(hwnd
, WM_USER
+1, 0x1234, 0x5678);
12493 PostMessage(0, WM_USER
+2, 0x5678, 0x1234);
12495 for (i
= 0; i
< sizeof(data
)/sizeof(data
[0]); i
++)
12497 memset(&msg
, 0xab, sizeof(msg
));
12498 ret
= PeekMessageA(&msg
, data
[i
].hwnd
, 0, 0, PM_NOREMOVE
);
12499 ok(ret
== data
[i
].ret
, "%d: hwnd %p expected %d, got %d\n", i
, data
[i
].hwnd
, data
[i
].ret
, ret
);
12503 ok(ret
&& msg
.hwnd
== 0 && msg
.message
== WM_USER
+2 &&
12504 msg
.wParam
== 0x5678 && msg
.lParam
== 0x1234,
12505 "%d: got ret %d hwnd %p msg %04x wParam %08lx lParam %08lx instead of TRUE/0/WM_USER+2/0x5678/0x1234\n",
12506 i
, ret
, msg
.hwnd
, msg
.message
, msg
.wParam
, msg
.lParam
);
12508 ok(ret
&& msg
.hwnd
== hwnd
&& msg
.message
== WM_USER
+1 &&
12509 msg
.wParam
== 0x1234 && msg
.lParam
== 0x5678,
12510 "%d: got ret %d hwnd %p msg %04x wParam %08lx lParam %08lx instead of TRUE/%p/WM_USER+1/0x1234/0x5678\n",
12511 i
, ret
, msg
.hwnd
, msg
.message
, msg
.wParam
, msg
.lParam
, msg
.hwnd
);
12515 DestroyWindow(hwnd
);
12519 static const struct
12523 } wait_idle_expect
[] =
12525 /* 0 */ { WAIT_TIMEOUT
, WAIT_TIMEOUT
, FALSE
},
12526 { WAIT_TIMEOUT
, 0, FALSE
},
12527 { WAIT_TIMEOUT
, 0, FALSE
},
12528 { WAIT_TIMEOUT
, WAIT_TIMEOUT
, FALSE
},
12529 { WAIT_TIMEOUT
, WAIT_TIMEOUT
, FALSE
},
12530 /* 5 */ { WAIT_TIMEOUT
, 0, FALSE
},
12531 { WAIT_TIMEOUT
, 0, FALSE
},
12532 { WAIT_TIMEOUT
, WAIT_TIMEOUT
, FALSE
},
12535 /* 10 */ { 0, 0, FALSE
},
12537 { 0, WAIT_TIMEOUT
, FALSE
},
12540 /* 15 */ { 0, 0, FALSE
},
12541 { WAIT_TIMEOUT
, 0, FALSE
},
12542 { WAIT_TIMEOUT
, 0, FALSE
},
12543 { WAIT_TIMEOUT
, 0, FALSE
},
12544 { WAIT_TIMEOUT
, 0, FALSE
},
12545 /* 20 */ { WAIT_TIMEOUT
, 0, FALSE
},
12548 static DWORD CALLBACK
do_wait_idle_child_thread( void *arg
)
12552 PeekMessage( &msg
, 0, 0, 0, PM_NOREMOVE
);
12554 MsgWaitForMultipleObjects( 0, NULL
, FALSE
, 100, QS_ALLINPUT
);
12558 static void do_wait_idle_child( int arg
)
12565 HANDLE start_event
= OpenEventA( EVENT_ALL_ACCESS
, FALSE
, "test_WaitForInputIdle_start" );
12566 HANDLE end_event
= OpenEventA( EVENT_ALL_ACCESS
, FALSE
, "test_WaitForInputIdle_end" );
12568 memset( &cls
, 0, sizeof(cls
) );
12569 cls
.lpfnWndProc
= DefWindowProc
;
12570 cls
.hbrBackground
= (HBRUSH
)(COLOR_WINDOW
+ 1);
12571 cls
.hCursor
= LoadCursor(0, IDC_ARROW
);
12572 cls
.lpszClassName
= "TestClass";
12573 RegisterClass( &cls
);
12575 PeekMessage( &msg
, 0, 0, 0, PM_NOREMOVE
); /* create the msg queue */
12577 ok( start_event
!= 0, "failed to create start event, error %u\n", GetLastError() );
12578 ok( end_event
!= 0, "failed to create end event, error %u\n", GetLastError() );
12583 SetEvent( start_event
);
12586 SetEvent( start_event
);
12588 PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
);
12591 SetEvent( start_event
);
12593 PeekMessage( &msg
, 0, 0, 0, PM_NOREMOVE
);
12594 PostThreadMessage( GetCurrentThreadId(), WM_COMMAND
, 0x1234, 0xabcd );
12595 PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
);
12598 SetEvent( start_event
);
12600 SendMessage( HWND_BROADCAST
, WM_WININICHANGE
, 0, 0 );
12603 SetEvent( start_event
);
12605 hwnd
= CreateWindowExA(0, "TestClass", NULL
, WS_POPUP
|WS_VISIBLE
, 0, 0, 10, 10, 0, 0, 0, NULL
);
12606 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
|PM_NOYIELD
)) DispatchMessage( &msg
);
12609 SetEvent( start_event
);
12611 hwnd
= CreateWindowExA(0, "TestClass", NULL
, WS_POPUP
|WS_VISIBLE
, 0, 0, 10, 10, 0, 0, 0, NULL
);
12612 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
12615 SetEvent( start_event
);
12617 hwnd
= CreateWindowExA(0, "TestClass", NULL
, WS_POPUP
|WS_VISIBLE
, 0, 0, 10, 10, 0, 0, 0, NULL
);
12618 while (PeekMessage( &msg
, 0, 0, 0, PM_NOREMOVE
))
12620 GetMessage( &msg
, 0, 0, 0 );
12621 DispatchMessage( &msg
);
12625 SetEvent( start_event
);
12627 hwnd
= CreateWindowExA(0, "TestClass", NULL
, WS_POPUP
|WS_VISIBLE
, 0, 0, 10, 10, 0, 0, 0, NULL
);
12628 SetTimer( hwnd
, 3, 1, NULL
);
12630 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
|PM_NOYIELD
)) DispatchMessage( &msg
);
12633 SetEvent( start_event
);
12635 PeekMessage( &msg
, 0, 0, 0, PM_NOREMOVE
);
12636 MsgWaitForMultipleObjects( 0, NULL
, FALSE
, 100, QS_ALLINPUT
);
12639 SetEvent( start_event
);
12641 hwnd
= CreateWindowExA(0, "TestClass", NULL
, WS_POPUP
|WS_VISIBLE
, 0, 0, 10, 10, 0, 0, 0, NULL
);
12642 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
12643 for (;;) GetMessage( &msg
, 0, 0, 0 );
12646 SetEvent( start_event
);
12648 hwnd
= CreateWindowExA(0, "TestClass", NULL
, WS_POPUP
|WS_VISIBLE
, 0, 0, 10, 10, 0, 0, 0, NULL
);
12649 SetTimer( hwnd
, 3, 1, NULL
);
12651 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
12654 SetEvent( start_event
);
12656 return; /* exiting the process makes WaitForInputIdle return success too */
12658 PeekMessage( &msg
, 0, 0, 0, PM_NOREMOVE
);
12660 MsgWaitForMultipleObjects( 0, NULL
, FALSE
, 100, QS_ALLINPUT
);
12661 SetEvent( start_event
);
12664 SetEvent( start_event
);
12665 PeekMessage( &msg
, 0, 0, 0, PM_NOREMOVE
);
12667 thread
= CreateThread( NULL
, 0, do_wait_idle_child_thread
, NULL
, 0, &id
);
12668 WaitForSingleObject( thread
, 10000 );
12669 CloseHandle( thread
);
12672 SetEvent( start_event
);
12674 PeekMessage( &msg
, HWND_TOPMOST
, 0, 0, PM_NOREMOVE
);
12677 SetEvent( start_event
);
12679 PeekMessage( &msg
, HWND_BROADCAST
, 0, 0, PM_NOREMOVE
);
12682 SetEvent( start_event
);
12684 PeekMessage( &msg
, HWND_BOTTOM
, 0, 0, PM_NOREMOVE
);
12687 SetEvent( start_event
);
12689 PeekMessage( &msg
, (HWND
)0xdeadbeef, 0, 0, PM_NOREMOVE
);
12692 SetEvent( start_event
);
12694 PeekMessage( &msg
, HWND_NOTOPMOST
, 0, 0, PM_NOREMOVE
);
12697 SetEvent( start_event
);
12699 PeekMessage( &msg
, HWND_MESSAGE
, 0, 0, PM_NOREMOVE
);
12702 SetEvent( start_event
);
12704 PeekMessage( &msg
, GetDesktopWindow(), 0, 0, PM_NOREMOVE
);
12707 WaitForSingleObject( end_event
, 2000 );
12708 CloseHandle( start_event
);
12709 CloseHandle( end_event
);
12710 if (hwnd
) DestroyWindow( hwnd
);
12713 static LRESULT CALLBACK
wait_idle_proc( HWND hwnd
, UINT msg
, WPARAM wp
, LPARAM lp
)
12715 if (msg
== WM_WININICHANGE
) Sleep( 200 ); /* make sure the child waits */
12716 return DefWindowProcA( hwnd
, msg
, wp
, lp
);
12719 static DWORD CALLBACK
wait_idle_thread( void *arg
)
12725 memset( &cls
, 0, sizeof(cls
) );
12726 cls
.lpfnWndProc
= wait_idle_proc
;
12727 cls
.hbrBackground
= (HBRUSH
)(COLOR_WINDOW
+ 1);
12728 cls
.hCursor
= LoadCursor(0, IDC_ARROW
);
12729 cls
.lpszClassName
= "TestClass";
12730 RegisterClass( &cls
);
12732 hwnd
= CreateWindowExA(0, "TestClass", NULL
, WS_POPUP
, 0, 0, 10, 10, 0, 0, 0, NULL
);
12733 while (GetMessage( &msg
, 0, 0, 0 )) DispatchMessage( &msg
);
12734 DestroyWindow(hwnd
);
12738 static void test_WaitForInputIdle( char *argv0
)
12740 char path
[MAX_PATH
];
12741 PROCESS_INFORMATION pi
;
12742 STARTUPINFOA startup
;
12744 HANDLE start_event
, end_event
, thread
;
12747 const IMAGE_DOS_HEADER
*dos
= (const IMAGE_DOS_HEADER
*)GetModuleHandleA(0);
12748 const IMAGE_NT_HEADERS
*nt
= (const IMAGE_NT_HEADERS
*)((const char *)dos
+ dos
->e_lfanew
);
12749 BOOL console_app
= (nt
->OptionalHeader
.Subsystem
!= IMAGE_SUBSYSTEM_WINDOWS_GUI
);
12751 if (console_app
) /* build the test with -mwindows for better coverage */
12752 trace( "not built as a GUI app, WaitForInputIdle may not be fully tested\n" );
12754 start_event
= CreateEventA(NULL
, 0, 0, "test_WaitForInputIdle_start");
12755 end_event
= CreateEventA(NULL
, 0, 0, "test_WaitForInputIdle_end");
12756 ok(start_event
!= 0, "failed to create start event, error %u\n", GetLastError());
12757 ok(end_event
!= 0, "failed to create end event, error %u\n", GetLastError());
12759 memset( &startup
, 0, sizeof(startup
) );
12760 startup
.cb
= sizeof(startup
);
12761 startup
.dwFlags
= STARTF_USESHOWWINDOW
;
12762 startup
.wShowWindow
= SW_SHOWNORMAL
;
12764 thread
= CreateThread( NULL
, 0, wait_idle_thread
, NULL
, 0, &id
);
12766 for (i
= 0; i
< sizeof(wait_idle_expect
)/sizeof(wait_idle_expect
[0]); i
++)
12768 ResetEvent( start_event
);
12769 ResetEvent( end_event
);
12770 sprintf( path
, "%s msg %u", argv0
, i
);
12771 ret
= CreateProcessA( NULL
, path
, NULL
, NULL
, TRUE
, 0, NULL
, NULL
, &startup
, &pi
);
12772 ok( ret
, "CreateProcess '%s' failed err %u.\n", path
, GetLastError() );
12775 ret
= WaitForSingleObject( start_event
, 5000 );
12776 ok( ret
== WAIT_OBJECT_0
, "%u: WaitForSingleObject failed\n", i
);
12777 if (ret
== WAIT_OBJECT_0
)
12779 ret
= WaitForInputIdle( pi
.hProcess
, 1000 );
12780 if (ret
== WAIT_FAILED
)
12782 ret
== wait_idle_expect
[i
].exp
||
12783 broken(ret
== wait_idle_expect
[i
].broken
),
12784 "%u: WaitForInputIdle error %08x expected %08x\n",
12785 i
, ret
, wait_idle_expect
[i
].exp
);
12786 else if (wait_idle_expect
[i
].todo
)
12788 ok( ret
== wait_idle_expect
[i
].exp
|| broken(ret
== wait_idle_expect
[i
].broken
),
12789 "%u: WaitForInputIdle error %08x expected %08x\n",
12790 i
, ret
, wait_idle_expect
[i
].exp
);
12792 ok( ret
== wait_idle_expect
[i
].exp
|| broken(ret
== wait_idle_expect
[i
].broken
),
12793 "%u: WaitForInputIdle error %08x expected %08x\n",
12794 i
, ret
, wait_idle_expect
[i
].exp
);
12795 SetEvent( end_event
);
12796 WaitForSingleObject( pi
.hProcess
, 1000 ); /* give it a chance to exit on its own */
12798 TerminateProcess( pi
.hProcess
, 0 ); /* just in case */
12799 winetest_wait_child_process( pi
.hProcess
);
12800 ret
= WaitForInputIdle( pi
.hProcess
, 100 );
12801 ok( ret
== WAIT_FAILED
, "%u: WaitForInputIdle after exit error %08x\n", i
, ret
);
12802 CloseHandle( pi
.hProcess
);
12803 CloseHandle( pi
.hThread
);
12806 CloseHandle( start_event
);
12807 PostThreadMessage( id
, WM_QUIT
, 0, 0 );
12808 WaitForSingleObject( thread
, 10000 );
12809 CloseHandle( thread
);
12812 static const struct message WmSetParentSeq_1
[] = {
12813 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
12814 { EVENT_OBJECT_PARENTCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
12815 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
},
12816 { WM_CHILDACTIVATE
, sent
},
12817 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOSIZE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
},
12818 { WM_MOVE
, sent
|defwinproc
|wparam
, 0 },
12819 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
12820 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
12824 static const struct message WmSetParentSeq_2
[] = {
12825 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
12826 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
12827 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
12828 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
12829 { HCBT_SETFOCUS
, hook
|optional
},
12830 { WM_NCACTIVATE
, sent
|wparam
, 0 },
12831 { WM_ACTIVATE
, sent
|wparam
, 0 },
12832 { WM_ACTIVATEAPP
, sent
|wparam
, 0 },
12833 { WM_KILLFOCUS
, sent
|wparam
, 0 },
12834 { EVENT_OBJECT_PARENTCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
12835 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
},
12836 { HCBT_ACTIVATE
, hook
},
12837 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
12838 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
},
12839 { WM_NCACTIVATE
, sent
|wparam
, 1 },
12840 { WM_ACTIVATE
, sent
|wparam
, 1 },
12841 { HCBT_SETFOCUS
, hook
},
12842 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
12843 { WM_SETFOCUS
, sent
|defwinproc
},
12844 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOREDRAW
|SWP_NOSIZE
|SWP_NOCLIENTSIZE
},
12845 { WM_MOVE
, sent
|defwinproc
|wparam
, 0 },
12846 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
12847 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
12848 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
12849 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
12850 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
12855 static void test_SetParent(void)
12857 HWND parent1
, parent2
, child
, popup
;
12860 parent1
= CreateWindowEx(0, "TestParentClass", NULL
, WS_OVERLAPPEDWINDOW
,
12861 100, 100, 200, 200, 0, 0, 0, NULL
);
12862 ok(parent1
!= 0, "Failed to create parent1 window\n");
12864 parent2
= CreateWindowEx(0, "TestParentClass", NULL
, WS_OVERLAPPEDWINDOW
,
12865 400, 100, 200, 200, 0, 0, 0, NULL
);
12866 ok(parent2
!= 0, "Failed to create parent2 window\n");
12868 /* WS_CHILD window */
12869 child
= CreateWindowEx(0, "TestWindowClass", NULL
, WS_CHILD
| WS_VISIBLE
,
12870 10, 10, 150, 150, parent1
, 0, 0, NULL
);
12871 ok(child
!= 0, "Failed to create child window\n");
12873 GetWindowRect(parent1
, &rc
);
12874 trace("parent1 (%d,%d)-(%d,%d)\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
12875 GetWindowRect(child
, &rc_old
);
12876 MapWindowPoints(0, parent1
, (POINT
*)&rc_old
, 2);
12877 trace("child (%d,%d)-(%d,%d)\n", rc_old
.left
, rc_old
.top
, rc_old
.right
, rc_old
.bottom
);
12881 SetParent(child
, parent2
);
12883 ok_sequence(WmSetParentSeq_1
, "SetParent() visible WS_CHILD", TRUE
);
12885 ok(GetWindowLongA(child
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
12886 ok(!IsWindowVisible(child
), "IsWindowVisible() should return FALSE\n");
12888 GetWindowRect(parent2
, &rc
);
12889 trace("parent2 (%d,%d)-(%d,%d)\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
12890 GetWindowRect(child
, &rc
);
12891 MapWindowPoints(0, parent2
, (POINT
*)&rc
, 2);
12892 trace("child (%d,%d)-(%d,%d)\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
12894 ok(EqualRect(&rc_old
, &rc
), "rects do not match (%d,%d-%d,%d) / (%d,%d-%d,%d)\n",
12895 rc_old
.left
, rc_old
.top
, rc_old
.right
, rc_old
.bottom
,
12896 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
12898 /* WS_POPUP window */
12899 popup
= CreateWindowEx(0, "TestWindowClass", NULL
, WS_POPUP
| WS_VISIBLE
,
12900 20, 20, 100, 100, 0, 0, 0, NULL
);
12901 ok(popup
!= 0, "Failed to create popup window\n");
12903 GetWindowRect(popup
, &rc_old
);
12904 trace("popup (%d,%d)-(%d,%d)\n", rc_old
.left
, rc_old
.top
, rc_old
.right
, rc_old
.bottom
);
12908 SetParent(popup
, child
);
12910 ok_sequence(WmSetParentSeq_2
, "SetParent() visible WS_POPUP", TRUE
);
12912 ok(GetWindowLongA(popup
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
12913 ok(!IsWindowVisible(popup
), "IsWindowVisible() should return FALSE\n");
12915 GetWindowRect(child
, &rc
);
12916 trace("parent2 (%d,%d)-(%d,%d)\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
12917 GetWindowRect(popup
, &rc
);
12918 MapWindowPoints(0, child
, (POINT
*)&rc
, 2);
12919 trace("popup (%d,%d)-(%d,%d)\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
12921 ok(EqualRect(&rc_old
, &rc
), "rects do not match (%d,%d-%d,%d) / (%d,%d-%d,%d)\n",
12922 rc_old
.left
, rc_old
.top
, rc_old
.right
, rc_old
.bottom
,
12923 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
12925 DestroyWindow(popup
);
12926 DestroyWindow(child
);
12927 DestroyWindow(parent1
);
12928 DestroyWindow(parent2
);
12933 static const struct message WmKeyReleaseOnly
[] = {
12934 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 0x41, 0x80000001 },
12935 { WM_KEYUP
, sent
|wparam
|lparam
, 0x41, 0x80000001 },
12938 static const struct message WmKeyPressNormal
[] = {
12939 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 0x41, 0x1 },
12940 { WM_KEYDOWN
, sent
|wparam
|lparam
, 0x41, 0x1 },
12943 static const struct message WmKeyPressRepeat
[] = {
12944 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 0x41, 0x40000001 },
12945 { WM_KEYDOWN
, sent
|wparam
|lparam
, 0x41, 0x40000001 },
12948 static const struct message WmKeyReleaseNormal
[] = {
12949 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 0x41, 0xc0000001 },
12950 { WM_KEYUP
, sent
|wparam
|lparam
, 0x41, 0xc0000001 },
12954 static void test_keyflags(void)
12958 BYTE keyboard_state
[256];
12961 test_window
= CreateWindowEx(0, "TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
12962 100, 100, 200, 200, 0, 0, 0, NULL
);
12966 /* keyup without a keydown */
12967 keybd_event(0x41, 0, KEYEVENTF_KEYUP
, 0);
12968 while (PeekMessage(&msg
, NULL
, WM_KEYFIRST
, WM_KEYLAST
, PM_REMOVE
))
12969 DispatchMessage(&msg
);
12970 ok_sequence(WmKeyReleaseOnly
, "key release only", TRUE
);
12972 key_state
= GetAsyncKeyState(0x41);
12973 ok((key_state
& 0x8000) == 0, "unexpected key state %x\n", key_state
);
12975 key_state
= GetKeyState(0x41);
12976 ok((key_state
& 0x8000) == 0, "unexpected key state %x\n", key_state
);
12979 keybd_event(0x41, 0, 0, 0);
12980 while (PeekMessage(&msg
, NULL
, WM_KEYFIRST
, WM_KEYLAST
, PM_REMOVE
))
12981 DispatchMessage(&msg
);
12982 ok_sequence(WmKeyPressNormal
, "key press only", FALSE
);
12984 key_state
= GetAsyncKeyState(0x41);
12985 ok((key_state
& 0x8000) == 0x8000, "unexpected key state %x\n", key_state
);
12987 key_state
= GetKeyState(0x41);
12988 ok((key_state
& 0x8000) == 0x8000, "unexpected key state %x\n", key_state
);
12990 /* keydown repeat */
12991 keybd_event(0x41, 0, 0, 0);
12992 while (PeekMessage(&msg
, NULL
, WM_KEYFIRST
, WM_KEYLAST
, PM_REMOVE
))
12993 DispatchMessage(&msg
);
12994 ok_sequence(WmKeyPressRepeat
, "key press repeat", FALSE
);
12996 key_state
= GetAsyncKeyState(0x41);
12997 ok((key_state
& 0x8000) == 0x8000, "unexpected key state %x\n", key_state
);
12999 key_state
= GetKeyState(0x41);
13000 ok((key_state
& 0x8000) == 0x8000, "unexpected key state %x\n", key_state
);
13003 keybd_event(0x41, 0, KEYEVENTF_KEYUP
, 0);
13004 while (PeekMessage(&msg
, NULL
, WM_KEYFIRST
, WM_KEYLAST
, PM_REMOVE
))
13005 DispatchMessage(&msg
);
13006 ok_sequence(WmKeyReleaseNormal
, "key release repeat", FALSE
);
13008 key_state
= GetAsyncKeyState(0x41);
13009 ok((key_state
& 0x8000) == 0, "unexpected key state %x\n", key_state
);
13011 key_state
= GetKeyState(0x41);
13012 ok((key_state
& 0x8000) == 0, "unexpected key state %x\n", key_state
);
13014 /* set the key state in this thread */
13015 GetKeyboardState(keyboard_state
);
13016 keyboard_state
[0x41] = 0x80;
13017 SetKeyboardState(keyboard_state
);
13019 key_state
= GetAsyncKeyState(0x41);
13020 ok((key_state
& 0x8000) == 0, "unexpected key state %x\n", key_state
);
13023 keybd_event(0x41, 0, 0, 0);
13024 while (PeekMessage(&msg
, NULL
, WM_KEYFIRST
, WM_KEYLAST
, PM_REMOVE
))
13025 DispatchMessage(&msg
);
13026 ok_sequence(WmKeyPressRepeat
, "key press after setkeyboardstate", TRUE
);
13028 key_state
= GetAsyncKeyState(0x41);
13029 ok((key_state
& 0x8000) == 0x8000, "unexpected key state %x\n", key_state
);
13031 key_state
= GetKeyState(0x41);
13032 ok((key_state
& 0x8000) == 0x8000, "unexpected key state %x\n", key_state
);
13034 /* clear the key state in this thread */
13035 GetKeyboardState(keyboard_state
);
13036 keyboard_state
[0x41] = 0;
13037 SetKeyboardState(keyboard_state
);
13039 key_state
= GetAsyncKeyState(0x41);
13040 ok((key_state
& 0x8000) == 0x8000, "unexpected key state %x\n", key_state
);
13043 keybd_event(0x41, 0, KEYEVENTF_KEYUP
, 0);
13044 while (PeekMessage(&msg
, NULL
, WM_KEYFIRST
, WM_KEYLAST
, PM_REMOVE
))
13045 DispatchMessage(&msg
);
13046 ok_sequence(WmKeyReleaseOnly
, "key release after setkeyboardstate", TRUE
);
13048 key_state
= GetAsyncKeyState(0x41);
13049 ok((key_state
& 0x8000) == 0, "unexpected key state %x\n", key_state
);
13051 key_state
= GetKeyState(0x41);
13052 ok((key_state
& 0x8000) == 0, "unexpected key state %x\n", key_state
);
13054 DestroyWindow(test_window
);
13058 static const struct message WmHotkeyPressLWIN
[] = {
13059 { WM_KEYDOWN
, kbd_hook
|wparam
|lparam
, VK_LWIN
, LLKHF_INJECTED
},
13060 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_LWIN
, 1 },
13061 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_LWIN
, 1 },
13064 static const struct message WmHotkeyPress
[] = {
13065 { WM_KEYDOWN
, kbd_hook
|lparam
, 0, LLKHF_INJECTED
},
13066 { WM_HOTKEY
, sent
|wparam
, 5 },
13069 static const struct message WmHotkeyRelease
[] = {
13070 { WM_KEYUP
, kbd_hook
|lparam
, 0, LLKHF_INJECTED
|LLKHF_UP
},
13071 { HCBT_KEYSKIPPED
, hook
|lparam
|optional
, 0, 0x80000001 },
13072 { WM_KEYUP
, sent
|lparam
, 0, 0x80000001 },
13075 static const struct message WmHotkeyReleaseLWIN
[] = {
13076 { WM_KEYUP
, kbd_hook
|wparam
|lparam
, VK_LWIN
, LLKHF_INJECTED
|LLKHF_UP
},
13077 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_LWIN
, 0xc0000001 },
13078 { WM_KEYUP
, sent
|wparam
|lparam
, VK_LWIN
, 0xc0000001 },
13082 static int hotkey_letter
;
13084 static LRESULT CALLBACK
KeyboardHookProc(int nCode
, WPARAM wParam
, LPARAM lParam
)
13086 struct recvd_message msg
;
13088 if (nCode
== HC_ACTION
)
13090 KBDLLHOOKSTRUCT
*kdbhookstruct
= (KBDLLHOOKSTRUCT
*)lParam
;
13093 msg
.message
= wParam
;
13094 msg
.flags
= kbd_hook
|wparam
|lparam
;
13095 msg
.wParam
= kdbhookstruct
->vkCode
;
13096 msg
.lParam
= kdbhookstruct
->flags
;
13097 msg
.descr
= "KeyboardHookProc";
13100 if (wParam
== WM_KEYUP
|| wParam
== WM_KEYDOWN
)
13102 ok(kdbhookstruct
->vkCode
== VK_LWIN
|| kdbhookstruct
->vkCode
== hotkey_letter
,
13103 "unexpected keycode %x\n", kdbhookstruct
->vkCode
);
13107 return CallNextHookEx(hKBD_hook
, nCode
, wParam
, lParam
);
13110 static void test_hotkey(void)
13112 HWND test_window
, taskbar_window
;
13117 SetLastError(0xdeadbeef);
13118 ret
= UnregisterHotKey(NULL
, 0);
13119 todo_wine
ok(ret
== FALSE
, "expected FALSE, got %i\n", ret
);
13120 todo_wine
ok(GetLastError() == ERROR_HOTKEY_NOT_REGISTERED
, "unexpected error %d\n", GetLastError());
13124 skip("hotkeys not supported\n");
13128 test_window
= CreateWindowEx(0, "HotkeyWindowClass", NULL
, WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
13129 100, 100, 200, 200, 0, 0, 0, NULL
);
13133 SetLastError(0xdeadbeef);
13134 ret
= UnregisterHotKey(test_window
, 0);
13135 ok(ret
== FALSE
, "expected FALSE, got %i\n", ret
);
13136 ok(GetLastError() == ERROR_HOTKEY_NOT_REGISTERED
, "unexpected error %d\n", GetLastError());
13138 /* Search for a Windows Key + letter combination that hasn't been registered */
13139 for (hotkey_letter
= 0x41; hotkey_letter
<= 0x51; hotkey_letter
++)
13141 SetLastError(0xdeadbeef);
13142 ret
= RegisterHotKey(test_window
, 5, MOD_WIN
, hotkey_letter
);
13150 ok(GetLastError() == ERROR_HOTKEY_ALREADY_REGISTERED
, "unexpected error %d\n", GetLastError());
13154 if (hotkey_letter
== 0x52)
13156 ok(0, "Couldn't find any free Windows Key + letter combination\n");
13160 hKBD_hook
= SetWindowsHookEx(WH_KEYBOARD_LL
, KeyboardHookProc
, GetModuleHandle(NULL
), 0);
13161 ok(hKBD_hook
!= NULL
, "failed to install hook, err %i\n", GetLastError());
13163 /* Same key combination, different id */
13164 SetLastError(0xdeadbeef);
13165 ret
= RegisterHotKey(test_window
, 4, MOD_WIN
, hotkey_letter
);
13166 ok(ret
== FALSE
, "expected FALSE, got %i\n", ret
);
13167 ok(GetLastError() == ERROR_HOTKEY_ALREADY_REGISTERED
, "unexpected error %d\n", GetLastError());
13169 /* Same key combination, different window */
13170 SetLastError(0xdeadbeef);
13171 ret
= RegisterHotKey(NULL
, 5, MOD_WIN
, hotkey_letter
);
13172 ok(ret
== FALSE
, "expected FALSE, got %i\n", ret
);
13173 ok(GetLastError() == ERROR_HOTKEY_ALREADY_REGISTERED
, "unexpected error %d\n", GetLastError());
13175 /* Register the same hotkey twice */
13176 SetLastError(0xdeadbeef);
13177 ret
= RegisterHotKey(test_window
, 5, MOD_WIN
, hotkey_letter
);
13178 ok(ret
== FALSE
, "expected FALSE, got %i\n", ret
);
13179 ok(GetLastError() == ERROR_HOTKEY_ALREADY_REGISTERED
, "unexpected error %d\n", GetLastError());
13181 /* Window on another thread */
13182 taskbar_window
= FindWindowA("Shell_TrayWnd", NULL
);
13183 if (!taskbar_window
)
13185 skip("no taskbar?\n");
13189 SetLastError(0xdeadbeef);
13190 ret
= RegisterHotKey(taskbar_window
, 5, 0, hotkey_letter
);
13191 ok(ret
== FALSE
, "expected FALSE, got %i\n", ret
);
13192 ok(GetLastError() == ERROR_WINDOW_OF_OTHER_THREAD
, "unexpected error %d\n", GetLastError());
13195 /* Inject the appropriate key sequence */
13196 keybd_event(VK_LWIN
, 0, 0, 0);
13197 while (PeekMessage(&msg
, NULL
, 0, 0, PM_REMOVE
))
13198 DispatchMessage(&msg
);
13199 ok_sequence(WmHotkeyPressLWIN
, "window hotkey press LWIN", FALSE
);
13201 keybd_event(hotkey_letter
, 0, 0, 0);
13202 while (PeekMessage(&msg
, NULL
, 0, 0, PM_REMOVE
))
13204 if (msg
.message
== WM_HOTKEY
)
13206 ok(msg
.hwnd
== test_window
, "unexpected hwnd %p\n", msg
.hwnd
);
13207 ok(msg
.lParam
== MAKELPARAM(MOD_WIN
, hotkey_letter
), "unexpected WM_HOTKEY lparam %lx\n", msg
.lParam
);
13209 DispatchMessage(&msg
);
13211 ok_sequence(WmHotkeyPress
, "window hotkey press", FALSE
);
13213 key_state
= GetAsyncKeyState(hotkey_letter
);
13214 ok((key_state
& 0x8000) == 0x8000, "unexpected key state %x\n", key_state
);
13216 keybd_event(hotkey_letter
, 0, KEYEVENTF_KEYUP
, 0);
13217 while (PeekMessage(&msg
, NULL
, 0, 0, PM_REMOVE
))
13218 DispatchMessage(&msg
);
13219 ok_sequence(WmHotkeyRelease
, "window hotkey release", FALSE
);
13221 keybd_event(VK_LWIN
, 0, KEYEVENTF_KEYUP
, 0);
13222 while (PeekMessage(&msg
, NULL
, 0, 0, PM_REMOVE
))
13223 DispatchMessage(&msg
);
13224 ok_sequence(WmHotkeyReleaseLWIN
, "window hotkey release LWIN", FALSE
);
13226 /* Register same hwnd/id with different key combination */
13227 ret
= RegisterHotKey(test_window
, 5, 0, hotkey_letter
);
13228 ok(ret
== TRUE
, "expected TRUE, got %i, err=%d\n", ret
, GetLastError());
13230 /* Unregister hotkey properly */
13231 ret
= UnregisterHotKey(test_window
, 5);
13232 ok(ret
== TRUE
, "expected TRUE, got %i, err=%d\n", ret
, GetLastError());
13234 /* Unregister hotkey again */
13235 SetLastError(0xdeadbeef);
13236 ret
= UnregisterHotKey(test_window
, 5);
13237 ok(ret
== FALSE
, "expected FALSE, got %i\n", ret
);
13238 ok(GetLastError() == ERROR_HOTKEY_NOT_REGISTERED
, "unexpected error %d\n", GetLastError());
13240 /* Register thread hotkey */
13241 ret
= RegisterHotKey(NULL
, 5, MOD_WIN
, hotkey_letter
);
13242 ok(ret
== TRUE
, "expected TRUE, got %i, err=%d\n", ret
, GetLastError());
13244 /* Inject the appropriate key sequence */
13245 keybd_event(VK_LWIN
, 0, 0, 0);
13246 while (PeekMessage(&msg
, NULL
, 0, 0, PM_REMOVE
))
13248 ok(msg
.hwnd
!= NULL
, "unexpected thread message %x\n", msg
.message
);
13249 DispatchMessage(&msg
);
13251 ok_sequence(WmHotkeyPressLWIN
, "thread hotkey press LWIN", FALSE
);
13253 keybd_event(hotkey_letter
, 0, 0, 0);
13254 while (PeekMessage(&msg
, NULL
, 0, 0, PM_REMOVE
))
13256 if (msg
.message
== WM_HOTKEY
)
13258 struct recvd_message message
;
13259 ok(msg
.hwnd
== NULL
, "unexpected hwnd %p\n", msg
.hwnd
);
13260 ok(msg
.lParam
== MAKELPARAM(MOD_WIN
, hotkey_letter
), "unexpected WM_HOTKEY lparam %lx\n", msg
.lParam
);
13261 message
.message
= msg
.message
;
13262 message
.flags
= sent
|wparam
|lparam
;
13263 message
.wParam
= msg
.wParam
;
13264 message
.lParam
= msg
.lParam
;
13265 message
.descr
= "test_hotkey thread message";
13266 add_message(&message
);
13269 ok(msg
.hwnd
!= NULL
, "unexpected thread message %x\n", msg
.message
);
13270 DispatchMessage(&msg
);
13272 ok_sequence(WmHotkeyPress
, "thread hotkey press", FALSE
);
13274 keybd_event(hotkey_letter
, 0, KEYEVENTF_KEYUP
, 0);
13275 while (PeekMessage(&msg
, NULL
, 0, 0, PM_REMOVE
))
13277 ok(msg
.hwnd
!= NULL
, "unexpected thread message %x\n", msg
.message
);
13278 DispatchMessage(&msg
);
13280 ok_sequence(WmHotkeyRelease
, "thread hotkey release", FALSE
);
13282 keybd_event(VK_LWIN
, 0, KEYEVENTF_KEYUP
, 0);
13283 while (PeekMessage(&msg
, NULL
, 0, 0, PM_REMOVE
))
13285 ok(msg
.hwnd
!= NULL
, "unexpected thread message %x\n", msg
.message
);
13286 DispatchMessage(&msg
);
13288 ok_sequence(WmHotkeyReleaseLWIN
, "thread hotkey release LWIN", FALSE
);
13290 /* Unregister thread hotkey */
13291 ret
= UnregisterHotKey(NULL
, 5);
13292 ok(ret
== TRUE
, "expected TRUE, got %i, err=%d\n", ret
, GetLastError());
13294 UnhookWindowsHookEx(hKBD_hook
);
13298 UnregisterHotKey(NULL
, 5);
13299 UnregisterHotKey(test_window
, 5);
13300 DestroyWindow(test_window
);
13308 BOOL (WINAPI
*pIsWinEventHookInstalled
)(DWORD
)= 0;/*GetProcAddress(user32, "IsWinEventHookInstalled");*/
13309 HMODULE hModuleImm32
;
13310 BOOL (WINAPI
*pImmDisableIME
)(DWORD
);
13312 int argc
= winetest_get_mainargs( &test_argv
);
13316 /* Child process. */
13317 sscanf (test_argv
[2], "%d", (unsigned int *) &arg
);
13318 do_wait_idle_child( arg
);
13324 hModuleImm32
= LoadLibrary("imm32.dll");
13325 if (hModuleImm32
) {
13326 pImmDisableIME
= (void *)GetProcAddress(hModuleImm32
, "ImmDisableIME");
13327 if (pImmDisableIME
)
13330 pImmDisableIME
= NULL
;
13331 FreeLibrary(hModuleImm32
);
13333 if (!RegisterWindowClasses()) assert(0);
13335 if (pSetWinEventHook
)
13337 hEvent_hook
= pSetWinEventHook(EVENT_MIN
, EVENT_MAX
,
13338 GetModuleHandleA(0), win_event_proc
,
13339 0, GetCurrentThreadId(),
13340 WINEVENT_INCONTEXT
);
13341 if (pIsWinEventHookInstalled
&& hEvent_hook
)
13344 for (event
= EVENT_MIN
; event
<= EVENT_MAX
; event
++)
13345 ok(pIsWinEventHookInstalled(event
), "IsWinEventHookInstalled(%u) failed\n", event
);
13348 if (!hEvent_hook
) win_skip( "no win event hook support\n" );
13350 cbt_hook_thread_id
= GetCurrentThreadId();
13351 hCBT_hook
= SetWindowsHookExA(WH_CBT
, cbt_hook_proc
, 0, GetCurrentThreadId());
13352 if (!hCBT_hook
) win_skip( "cannot set global hook, will skip hook tests\n" );
13356 /* Fix message sequences before removing 4 lines below */
13358 if (pUnhookWinEvent
&& hEvent_hook
)
13360 ret
= pUnhookWinEvent(hEvent_hook
);
13361 ok( ret
, "UnhookWinEvent error %d\n", GetLastError());
13362 pUnhookWinEvent
= 0;
13368 test_PostMessage();
13370 test_PeekMessage();
13371 test_PeekMessage2();
13372 test_WaitForInputIdle( test_argv
[0] );
13373 test_scrollwindowex();
13375 test_setwindowpos();
13377 invisible_parent_tests();
13378 test_mdi_messages();
13379 test_button_messages();
13380 test_static_messages();
13381 test_listbox_messages();
13382 test_combobox_messages();
13383 test_wmime_keydown_message();
13384 test_paint_messages();
13385 test_interthread_messages();
13386 test_message_conversion();
13387 test_accelerators();
13389 test_timers_no_wnd();
13390 if (hCBT_hook
) test_set_hook();
13391 test_DestroyWindow();
13392 test_DispatchMessage();
13393 test_SendMessageTimeout();
13394 test_edit_messages();
13395 test_quit_message();
13396 test_SetActiveWindow();
13398 if (!pTrackMouseEvent
)
13399 win_skip("TrackMouseEvent is not available\n");
13401 test_TrackMouseEvent();
13403 test_SetWindowRgn();
13405 test_dialog_messages();
13406 test_nullCallback();
13407 test_dbcs_wm_char();
13408 test_menu_messages();
13409 test_paintingloop();
13411 test_clipboard_viewers();
13414 /* keep it the last test, under Windows it tends to break the tests
13415 * which rely on active/foreground windows being correct.
13417 test_SetForegroundWindow();
13419 UnhookWindowsHookEx(hCBT_hook
);
13420 if (pUnhookWinEvent
&& hEvent_hook
)
13422 ret
= pUnhookWinEvent(hEvent_hook
);
13423 ok( ret
, "UnhookWinEvent error %d\n", GetLastError());
13424 SetLastError(0xdeadbeef);
13425 ok(!pUnhookWinEvent(hEvent_hook
), "UnhookWinEvent succeeded\n");
13426 ok(GetLastError() == ERROR_INVALID_HANDLE
|| /* Win2k */
13427 GetLastError() == 0xdeadbeef, /* Win9x */
13428 "unexpected error %d\n", GetLastError());