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 0x0501 /* For WM_CHANGEUISTATE,QS_RAWINPUT */
35 #include "wine/test.h"
37 #define MDI_FIRST_CHILD_ID 2004
39 /* undocumented SWP flags - from SDK 3.1 */
40 #define SWP_NOCLIENTSIZE 0x0800
41 #define SWP_NOCLIENTMOVE 0x1000
42 #define SWP_STATECHANGED 0x8000
44 #define SW_NORMALNA 0xCC /* undoc. flag in MinMaximize */
47 #define WM_KEYF1 0x004d
51 #define WM_SYSTIMER 0x0118
54 #define WND_PARENT_ID 1
55 #define WND_POPUP_ID 2
56 #define WND_CHILD_ID 3
58 #ifndef WM_LBTRACKPOINT
59 #define WM_LBTRACKPOINT 0x0131
62 /* encoded DRAWITEMSTRUCT into an LPARAM */
69 UINT type
: 4; /* ODT_* flags */
70 UINT ctl_id
: 4; /* Control ID */
71 UINT item_id
: 4; /* Menu item ID */
72 UINT action
: 4; /* ODA_* flags */
73 UINT state
: 16; /* ODS_* flags */
79 static BOOL test_DestroyWindow_flag
;
80 static HWINEVENTHOOK hEvent_hook
;
81 static HHOOK hCBT_hook
;
82 static DWORD cbt_hook_thread_id
;
84 static const WCHAR testWindowClassW
[] =
85 { 'T','e','s','t','W','i','n','d','o','w','C','l','a','s','s','W',0 };
88 FIXME: add tests for these
89 Window Edge Styles (Win31/Win95/98 look), in order of precedence:
90 WS_EX_DLGMODALFRAME: double border, WS_CAPTION allowed
91 WS_THICKFRAME: thick border
92 WS_DLGFRAME: double border, WS_CAPTION not allowed (but possibly shown anyway)
93 WS_BORDER (default for overlapped windows): single black border
94 none (default for child (and popup?) windows): no border
111 UINT message
; /* the WM_* code */
112 msg_flags_t flags
; /* message props */
113 WPARAM wParam
; /* expected value of wParam */
114 LPARAM lParam
; /* expected value of lParam */
115 WPARAM wp_mask
; /* mask for wParam checks */
116 LPARAM lp_mask
; /* mask for lParam checks */
119 struct recvd_message
{
120 UINT message
; /* the WM_* code */
121 msg_flags_t flags
; /* message props */
122 HWND hwnd
; /* window that received the message */
123 WPARAM wParam
; /* expected value of wParam */
124 LPARAM lParam
; /* expected value of lParam */
125 int line
; /* source line where logged */
126 const char *descr
; /* description for trace output */
127 char output
[512]; /* trace output */
130 /* Empty message sequence */
131 static const struct message WmEmptySeq
[] =
135 /* CreateWindow (for overlapped window, not initially visible) (16/32) */
136 static const struct message WmCreateOverlappedSeq
[] = {
137 { HCBT_CREATEWND
, hook
},
138 { WM_GETMINMAXINFO
, sent
},
139 { WM_NCCREATE
, sent
},
140 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
141 { 0x0093, sent
|defwinproc
|optional
},
142 { 0x0094, sent
|defwinproc
|optional
},
143 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
145 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
148 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
149 * for a not visible overlapped window.
151 static const struct message WmSWP_ShowOverlappedSeq
[] = {
152 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
153 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
154 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
155 { WM_GETTEXT
, sent
|defwinproc
|optional
},
156 { WM_ERASEBKGND
, sent
|optional
},
157 { HCBT_ACTIVATE
, hook
},
158 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
159 { WM_NOTIFYFORMAT
, sent
|optional
},
160 { WM_QUERYUISTATE
, sent
|optional
},
161 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
162 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* Win9x: SWP_NOSENDCHANGING */
163 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
164 { WM_NCACTIVATE
, sent
|wparam
, 1 },
165 { WM_GETTEXT
, sent
|defwinproc
|optional
},
166 { WM_ACTIVATE
, sent
|wparam
, 1 },
167 { HCBT_SETFOCUS
, hook
},
168 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
169 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
170 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
171 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
172 { WM_GETTEXT
, sent
|optional
},
173 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
174 { WM_GETTEXT
, sent
|defwinproc
|optional
},
175 { WM_ERASEBKGND
, sent
|optional
},
176 /* Win9x adds SWP_NOZORDER below */
177 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
178 { WM_GETTEXT
, sent
|optional
},
179 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
180 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
181 { WM_ERASEBKGND
, sent
|optional
},
182 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
183 { WM_SYNCPAINT
, sent
|optional
},
184 { WM_GETTITLEBARINFOEX
, sent
|optional
},
185 { WM_PAINT
, sent
|optional
},
186 { WM_NCPAINT
, sent
|beginpaint
|optional
},
187 { WM_GETTEXT
, sent
|defwinproc
|optional
},
188 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
191 /* SetWindowPos(SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE)
192 * for a visible overlapped window.
194 static const struct message WmSWP_HideOverlappedSeq
[] = {
195 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
196 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
197 { HCBT_ACTIVATE
, hook
|optional
},
198 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
199 { WM_ACTIVATEAPP
, sent
|wparam
|optional
, 1 },
200 { WM_NCACTIVATE
, sent
|optional
},
201 { WM_ACTIVATE
, sent
|optional
},
202 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
206 /* SetWindowPos(SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOMOVE)
207 * for a visible overlapped window.
209 static const struct message WmSWP_ResizeSeq
[] = {
210 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
},
211 { WM_GETMINMAXINFO
, sent
|defwinproc
},
212 { WM_NCCALCSIZE
, sent
|wparam
|optional
, TRUE
},
213 { WM_NCPAINT
, sent
|optional
},
214 { WM_GETTEXT
, sent
|defwinproc
|optional
},
215 { WM_ERASEBKGND
, sent
|optional
},
216 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
},
217 { WM_SIZE
, sent
|defwinproc
|optional
},
218 { WM_NCCALCSIZE
, sent
|wparam
|optional
, TRUE
},
219 { WM_NCPAINT
, sent
|optional
},
220 { WM_GETTEXT
, sent
|defwinproc
|optional
},
221 { WM_ERASEBKGND
, sent
|optional
},
222 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
223 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* XP sends a duplicate */
227 /* SetWindowPos(SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOMOVE)
228 * for a visible popup window.
230 static const struct message WmSWP_ResizePopupSeq
[] = {
231 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
},
232 { WM_GETMINMAXINFO
, sent
|defwinproc
|optional
}, /* Win9x */
233 { WM_NCCALCSIZE
, sent
|wparam
|optional
, TRUE
},
234 { WM_NCPAINT
, sent
|optional
},
235 { WM_GETTEXT
, sent
|defwinproc
|optional
},
236 { WM_ERASEBKGND
, sent
|optional
},
237 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
},
238 { WM_SIZE
, sent
|defwinproc
|wparam
|optional
, SIZE_RESTORED
},
239 { WM_NCCALCSIZE
, sent
|wparam
|optional
, TRUE
},
240 { WM_NCPAINT
, sent
|optional
},
241 { WM_GETTEXT
, sent
|defwinproc
|optional
},
242 { WM_ERASEBKGND
, sent
|optional
},
243 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
247 /* SetWindowPos(SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOSIZE)
248 * for a visible overlapped window.
250 static const struct message WmSWP_MoveSeq
[] = {
251 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOSIZE
},
252 { WM_NCPAINT
, sent
|optional
},
253 { WM_GETTEXT
, sent
|defwinproc
|optional
},
254 { WM_ERASEBKGND
, sent
|optional
},
255 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOCLIENTSIZE
},
256 { WM_MOVE
, sent
|defwinproc
|wparam
, 0 },
257 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
260 /* Resize with SetWindowPos(SWP_NOZORDER)
261 * for a visible overlapped window
262 * SWP_NOZORDER is stripped by the logging code
264 static const struct message WmSWP_ResizeNoZOrder
[] = {
265 { WM_WINDOWPOSCHANGING
, sent
|wparam
, /*SWP_NOZORDER|*/SWP_NOACTIVATE
},
266 { WM_GETMINMAXINFO
, sent
|defwinproc
},
267 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
268 { WM_NCPAINT
, sent
|optional
},
269 { WM_GETTEXT
, sent
|defwinproc
|optional
},
270 { WM_ERASEBKGND
, sent
|optional
},
271 { WM_WINDOWPOSCHANGED
, sent
|wparam
, /*SWP_NOZORDER|*/SWP_NOACTIVATE
, 0,
272 SWP_NOMOVE
|SWP_NOCLIENTMOVE
|SWP_NOSIZE
|SWP_NOCLIENTSIZE
},
273 { WM_MOVE
, sent
|defwinproc
|optional
},
274 { WM_SIZE
, sent
|defwinproc
|optional
},
275 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 }, /* Win9x doesn't send it */
276 { WM_NCPAINT
, sent
|optional
}, /* Win9x doesn't send it */
277 { WM_GETTEXT
, sent
|defwinproc
|optional
}, /* Win9x doesn't send it */
278 { WM_ERASEBKGND
, sent
|optional
}, /* Win9x doesn't send it */
279 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
280 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
284 /* Switch visible mdi children */
285 static const struct message WmSwitchChild
[] = {
286 /* Switch MDI child */
287 { WM_MDIACTIVATE
, sent
},/* in the MDI client */
288 { WM_WINDOWPOSCHANGING
, sent
|wparam
,SWP_NOSIZE
|SWP_NOMOVE
},/* in the 1st MDI child */
289 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
290 { WM_CHILDACTIVATE
, sent
},/* in the 1st MDI child */
291 /* Deactivate 2nd MDI child */
292 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 0 }, /* in the 2nd MDI child */
293 { WM_MDIACTIVATE
, sent
|defwinproc
}, /* in the 2nd MDI child */
294 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
295 /* Preparing for maximize and maximaze the 1st MDI child */
296 { WM_GETMINMAXINFO
, sent
|defwinproc
}, /* in the 1st MDI child */
297 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_STATECHANGED
}, /* in the 1st MDI child */
298 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 }, /* in the 1st MDI child */
299 { WM_CHILDACTIVATE
, sent
|defwinproc
}, /* in the 1st MDI child */
300 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
}, /* in the 1st MDI child */
301 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
}, /* in the 1st MDI child */
302 /* Lock redraw 2nd MDI child */
303 { WM_SETREDRAW
, sent
|wparam
|defwinproc
, 0 }, /* in the 2nd MDI child */
304 { HCBT_MINMAX
, hook
|lparam
, 0, SW_NORMALNA
},
305 /* Restore 2nd MDI child */
306 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_STATECHANGED
},/* in the 2nd MDI child */
307 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 },/* in the 2nd MDI child */
308 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* in the 2nd MDI child */
309 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
}, /* in the 2nd MDI child */
310 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
}, /* in the 2nd MDI child */
311 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* in the 2nd MDI child */
312 /* Redraw 2nd MDI child */
313 { WM_SETREDRAW
, sent
|wparam
|defwinproc
, 1 },/* in the 2nd MDI child */
314 /* Redraw MDI frame */
315 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
},/* in MDI frame */
316 { WM_NCCALCSIZE
, sent
|wparam
, 1 },/* in MDI frame */
317 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
}, /* in MDI frame */
318 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* in MDI frame */
319 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* in the 1st MDI child */
320 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
}, /* in the 1st MDI child */
321 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 }, /* in the 1st MDI child */
322 { HCBT_SETFOCUS
, hook
},
323 { WM_KILLFOCUS
, sent
|defwinproc
}, /* in the 2nd MDI child */
324 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 0 },/* in the 1st MDI child */
325 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
326 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
327 { WM_SETFOCUS
, sent
},/* in the MDI client */
328 { HCBT_SETFOCUS
, hook
},
329 { WM_KILLFOCUS
, sent
},/* in the MDI client */
330 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
331 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 }, /* in the 1st MDI child */
332 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
333 { WM_SETFOCUS
, sent
|defwinproc
}, /* in the 1st MDI child */
334 { WM_MDIACTIVATE
, sent
|defwinproc
},/* in the 1st MDI child */
335 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
}, /* in the 1st MDI child */
339 /* Switch visible not maximized mdi children */
340 static const struct message WmSwitchNotMaximizedChild
[] = {
341 /* Switch not maximized MDI child */
342 { WM_MDIACTIVATE
, sent
},/* in the MDI client */
343 { WM_WINDOWPOSCHANGING
, sent
|wparam
,SWP_NOSIZE
|SWP_NOMOVE
},/* in the 2nd MDI child */
344 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
345 { WM_CHILDACTIVATE
, sent
},/* in the 2nd MDI child */
346 /* Deactivate 1st MDI child */
347 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 0 }, /* in the 1st MDI child */
348 { WM_MDIACTIVATE
, sent
|defwinproc
}, /* in the 1st MDI child */
349 /* Activate 2nd MDI child */
350 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
}, /* in the 2nd MDI child */
351 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 }, /* in the 2nd MDI child */
352 { HCBT_SETFOCUS
, hook
}, /* in the 1st MDI child */
353 { WM_KILLFOCUS
, sent
|defwinproc
}, /* in the 1st MDI child */
354 { WM_IME_SETCONTEXT
, sent
|defwinproc
|optional
}, /* in the 1st MDI child */
355 { WM_IME_SETCONTEXT
, sent
|optional
}, /* in the MDI client */
356 { WM_SETFOCUS
, sent
, 0 }, /* in the MDI client */
357 { HCBT_SETFOCUS
, hook
},
358 { WM_KILLFOCUS
, sent
}, /* in the MDI client */
359 { WM_IME_SETCONTEXT
, sent
|optional
}, /* in the MDI client */
360 { WM_IME_SETCONTEXT
, sent
|defwinproc
|optional
}, /* in the 1st MDI child */
361 { WM_SETFOCUS
, sent
|defwinproc
}, /* in the 2nd MDI child */
362 { WM_MDIACTIVATE
, sent
|defwinproc
}, /* in the 2nd MDI child */
363 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
}, /* in the 2nd MDI child */
368 /* SetWindowPos(SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|
369 SWP_NOZORDER|SWP_FRAMECHANGED)
370 * for a visible overlapped window with WS_CLIPCHILDREN style set.
372 static const struct message WmSWP_FrameChanged_clip
[] = {
373 { WM_WINDOWPOSCHANGING
, sent
|wparam
|parent
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
},
374 { WM_NCCALCSIZE
, sent
|wparam
|parent
, 1 },
375 { WM_NCPAINT
, sent
|parent
|optional
}, /* wparam != 1 */
376 { WM_GETTEXT
, sent
|parent
|defwinproc
|optional
},
377 { WM_ERASEBKGND
, sent
|parent
|optional
}, /* FIXME: remove optional once Wine is fixed */
378 { WM_NCPAINT
, sent
}, /* wparam != 1 */
379 { WM_ERASEBKGND
, sent
},
380 { WM_WINDOWPOSCHANGED
, sent
|wparam
|parent
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
381 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
385 /* SetWindowPos(SWP_NOSIZE|SWP_NOMOVE|SWP_DEFERERASE|SWP_NOACTIVATE|
386 SWP_NOZORDER|SWP_FRAMECHANGED)
387 * for a visible overlapped window.
389 static const struct message WmSWP_FrameChangedDeferErase
[] = {
390 { WM_WINDOWPOSCHANGING
, sent
|wparam
|parent
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_DEFERERASE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
},
391 { WM_NCCALCSIZE
, sent
|wparam
|parent
, 1 },
392 { WM_WINDOWPOSCHANGED
, sent
|wparam
|parent
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_DEFERERASE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
393 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
394 { WM_PAINT
, sent
|parent
|optional
},
395 { WM_NCPAINT
, sent
|beginpaint
|parent
|optional
}, /* wparam != 1 */
396 { WM_GETTEXT
, sent
|beginpaint
|parent
|defwinproc
|optional
},
398 { WM_NCPAINT
, sent
|beginpaint
}, /* wparam != 1 */
399 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
403 /* SetWindowPos(SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|
404 SWP_NOZORDER|SWP_FRAMECHANGED)
405 * for a visible overlapped window without WS_CLIPCHILDREN style set.
407 static const struct message WmSWP_FrameChanged_noclip
[] = {
408 { WM_WINDOWPOSCHANGING
, sent
|wparam
|parent
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
},
409 { WM_NCCALCSIZE
, sent
|wparam
|parent
, 1 },
410 { WM_NCPAINT
, sent
|parent
|optional
}, /* wparam != 1 */
411 { WM_GETTEXT
, sent
|parent
|defwinproc
|optional
},
412 { WM_ERASEBKGND
, sent
|parent
|optional
},
413 { WM_WINDOWPOSCHANGED
, sent
|wparam
|parent
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
414 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
416 { WM_NCPAINT
, sent
|beginpaint
}, /* wparam != 1 */
417 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
421 /* ShowWindow(SW_SHOW) for a not visible overlapped window */
422 static const struct message WmShowOverlappedSeq
[] = {
423 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
424 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
425 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
426 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
427 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
428 { WM_GETTEXT
, sent
|defwinproc
|optional
},
429 { WM_ERASEBKGND
, sent
|optional
},
430 { HCBT_ACTIVATE
, hook
},
431 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
432 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
433 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
434 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
435 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
436 { WM_NCACTIVATE
, sent
|wparam
, 1 },
437 { WM_GETTEXT
, sent
|defwinproc
|optional
},
438 { WM_ACTIVATE
, sent
|wparam
, 1 },
439 { HCBT_SETFOCUS
, hook
},
440 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
441 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
442 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
443 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
444 { WM_GETTEXT
, sent
|optional
},
445 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
446 { WM_GETTEXT
, sent
|defwinproc
|optional
},
447 { WM_ERASEBKGND
, sent
|optional
},
448 /* Win9x adds SWP_NOZORDER below */
449 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
450 { WM_NCCALCSIZE
, sent
|optional
},
451 { WM_GETTEXT
, sent
|optional
},
452 { WM_NCPAINT
, sent
|optional
},
453 { WM_ERASEBKGND
, sent
|optional
},
454 { WM_SYNCPAINT
, sent
|optional
},
455 #if 0 /* CreateWindow/ShowWindow(SW_SHOW) also generates WM_SIZE/WM_MOVE
456 * messages. Does that mean that CreateWindow doesn't set initial
457 * window dimensions for overlapped windows?
462 { WM_PAINT
, sent
|optional
},
463 { WM_NCPAINT
, sent
|beginpaint
|optional
},
466 /* ShowWindow(SW_SHOWMAXIMIZED) for a not visible overlapped window */
467 static const struct message WmShowMaxOverlappedSeq
[] = {
468 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
469 { WM_GETMINMAXINFO
, sent
},
470 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_STATECHANGED
},
471 { WM_GETMINMAXINFO
, sent
|defwinproc
},
472 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
473 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
474 { HCBT_ACTIVATE
, hook
},
475 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
476 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
477 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
478 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
479 { WM_NCACTIVATE
, sent
|wparam
, 1 },
480 { WM_GETTEXT
, sent
|defwinproc
|optional
},
481 { WM_ACTIVATE
, sent
|wparam
, 1 },
482 { HCBT_SETFOCUS
, hook
},
483 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
484 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
485 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
486 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
487 { WM_GETTEXT
, sent
|optional
},
488 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
489 { WM_GETTEXT
, sent
|defwinproc
|optional
},
490 { WM_ERASEBKGND
, sent
|optional
},
491 /* Win9x adds SWP_NOZORDER below */
492 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_STATECHANGED
},
493 { WM_MOVE
, sent
|defwinproc
},
494 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
495 { WM_GETTEXT
, sent
|optional
},
496 { WM_NCCALCSIZE
, sent
|optional
},
497 { WM_NCPAINT
, sent
|optional
},
498 { WM_ERASEBKGND
, sent
|optional
},
499 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
500 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
501 { WM_SYNCPAINT
, sent
|optional
},
502 { WM_GETTITLEBARINFOEX
, sent
|optional
},
503 { WM_PAINT
, sent
|optional
},
504 { WM_NCPAINT
, sent
|beginpaint
|optional
},
505 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
508 /* ShowWindow(SW_RESTORE) for a not visible maximized overlapped window */
509 static const struct message WmShowRestoreMaxOverlappedSeq
[] = {
510 { HCBT_MINMAX
, hook
|lparam
, 0, SW_RESTORE
},
511 { WM_GETTEXT
, sent
|optional
},
512 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
513 { WM_GETMINMAXINFO
, sent
|defwinproc
},
514 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
515 { WM_NCPAINT
, sent
|optional
},
516 { WM_GETTEXT
, sent
|defwinproc
|optional
},
517 { WM_ERASEBKGND
, sent
|optional
},
518 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
, 0, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOSIZE
|SWP_NOMOVE
},
519 { WM_MOVE
, sent
|defwinproc
|optional
},
520 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
521 { WM_NCCALCSIZE
, sent
|wparam
|optional
, TRUE
},
522 { WM_NCPAINT
, sent
|optional
},
523 { WM_ERASEBKGND
, sent
|optional
},
524 { WM_PAINT
, sent
|optional
},
525 { WM_GETTITLEBARINFOEX
, sent
|optional
},
526 { WM_NCPAINT
, sent
|beginpaint
|optional
},
527 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
530 /* ShowWindow(SW_RESTORE) for a not visible minimized overlapped window */
531 static const struct message WmShowRestoreMinOverlappedSeq
[] = {
532 { HCBT_MINMAX
, hook
|lparam
, 0, SW_RESTORE
},
533 { WM_QUERYOPEN
, sent
|optional
},
534 { WM_GETTEXT
, sent
|optional
},
535 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
|SWP_NOCOPYBITS
},
536 { WM_GETMINMAXINFO
, sent
|defwinproc
},
537 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
538 { HCBT_ACTIVATE
, hook
},
539 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
540 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
541 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
542 { WM_NCACTIVATE
, sent
|wparam
, 1 },
543 { WM_GETTEXT
, sent
|defwinproc
|optional
},
544 { WM_ACTIVATE
, sent
|wparam
, 1 },
545 { HCBT_SETFOCUS
, hook
},
546 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
547 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
548 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
549 { WM_GETTEXT
, sent
|optional
},
550 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
551 { WM_GETTEXT
, sent
|defwinproc
|optional
},
552 { WM_ERASEBKGND
, sent
},
553 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_STATECHANGED
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
},
554 { WM_MOVE
, sent
|defwinproc
},
555 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
556 { WM_NCCALCSIZE
, sent
|wparam
|optional
, TRUE
},
557 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
558 { WM_ERASEBKGND
, sent
|optional
},
559 { WM_ACTIVATE
, sent
|wparam
, 1 },
560 { WM_GETTEXT
, sent
|optional
},
561 { WM_PAINT
, sent
|optional
},
562 { WM_GETTITLEBARINFOEX
, sent
|optional
},
563 { WM_NCPAINT
, sent
|beginpaint
|optional
},
564 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
567 /* ShowWindow(SW_SHOWMINIMIZED) for a not visible overlapped window */
568 static const struct message WmShowMinOverlappedSeq
[] = {
569 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
570 { HCBT_SETFOCUS
, hook
},
571 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
572 { WM_KILLFOCUS
, sent
},
573 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
574 { WM_IME_NOTIFY
, sent
|wparam
|optional
|defwinproc
, 1 },
575 { WM_GETTEXT
, sent
|optional
},
576 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOCOPYBITS
|SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_STATECHANGED
},
577 { WM_GETMINMAXINFO
, sent
|defwinproc
},
578 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
579 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
580 { WM_NCPAINT
, sent
|optional
},
581 { WM_GETTEXT
, sent
|defwinproc
|optional
},
582 { WM_WINDOWPOSCHANGED
, sent
},
583 { WM_MOVE
, sent
|defwinproc
},
584 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MINIMIZED
},
585 { WM_NCCALCSIZE
, sent
|optional
},
586 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
587 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
588 { EVENT_SYSTEM_MINIMIZESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
589 { WM_NCACTIVATE
, sent
|wparam
, 0 },
590 { WM_GETTEXT
, sent
|defwinproc
|optional
},
591 { WM_ACTIVATE
, sent
},
592 { WM_ACTIVATEAPP
, sent
|wparam
, 0 },
594 /* Vista sometimes restores the window right away... */
595 { WM_SYSCOMMAND
, sent
|optional
|wparam
, SC_RESTORE
},
596 { HCBT_SYSCOMMAND
, hook
|optional
|wparam
, SC_RESTORE
},
597 { HCBT_MINMAX
, hook
|optional
|lparam
, 0, SW_RESTORE
},
598 { WM_QUERYOPEN
, sent
|optional
},
599 { WM_WINDOWPOSCHANGING
, sent
|optional
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
600 { WM_GETMINMAXINFO
, sent
|optional
|defwinproc
},
601 { WM_NCCALCSIZE
, sent
|optional
|wparam
, TRUE
},
602 { HCBT_ACTIVATE
, hook
|optional
},
603 { WM_ACTIVATEAPP
, sent
|optional
|wparam
, 1 },
604 { WM_NCACTIVATE
, sent
|optional
},
605 { WM_GETTEXT
, sent
|optional
},
606 { WM_ACTIVATE
, sent
|optional
|wparam
, 1 },
607 { HCBT_SETFOCUS
, hook
|optional
},
608 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
609 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
610 { WM_SETFOCUS
, sent
|optional
},
611 { WM_NCPAINT
, sent
|optional
},
612 { WM_GETTEXT
, sent
|defwinproc
|optional
},
613 { WM_ERASEBKGND
, sent
|optional
},
614 { WM_WINDOWPOSCHANGED
, sent
|optional
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
615 { WM_MOVE
, sent
|defwinproc
|optional
},
616 { WM_SIZE
, sent
|defwinproc
|optional
|wparam
, SIZE_RESTORED
},
617 { WM_ACTIVATE
, sent
|optional
|wparam
, 1 },
618 { WM_SYSCOMMAND
, sent
|optional
|wparam
, SC_RESTORE
},
619 { HCBT_SYSCOMMAND
, hook
|optional
|wparam
, SC_RESTORE
},
621 { WM_PAINT
, sent
|optional
},
622 { WM_NCPAINT
, sent
|beginpaint
|optional
},
623 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
626 /* ShowWindow(SW_HIDE) for a visible overlapped window */
627 static const struct message WmHideOverlappedSeq
[] = {
628 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
629 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
630 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
631 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
632 { WM_SIZE
, sent
|optional
}, /* XP doesn't send it */
633 { WM_MOVE
, sent
|optional
}, /* XP doesn't send it */
634 { WM_NCACTIVATE
, sent
|wparam
, 0 },
635 { WM_ACTIVATE
, sent
|wparam
, 0 },
636 { WM_ACTIVATEAPP
, sent
|wparam
, 0 },
637 { WM_KILLFOCUS
, sent
|wparam
, 0 },
638 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
639 { WM_IME_NOTIFY
, sent
|wparam
|optional
|defwinproc
, 1 },
642 /* DestroyWindow for a visible overlapped window */
643 static const struct message WmDestroyOverlappedSeq
[] = {
644 { HCBT_DESTROYWND
, hook
},
645 { 0x0090, sent
|optional
},
646 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
647 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
648 { 0x0090, sent
|optional
},
649 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
650 { WM_NCACTIVATE
, sent
|optional
|wparam
, 0 },
651 { WM_ACTIVATE
, sent
|optional
},
652 { WM_ACTIVATEAPP
, sent
|optional
|wparam
, 0 },
653 { WM_KILLFOCUS
, sent
|optional
|wparam
, 0 },
654 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
655 { WM_IME_NOTIFY
, sent
|wparam
|optional
|defwinproc
, 1 },
656 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
657 { WM_DESTROY
, sent
},
658 { WM_NCDESTROY
, sent
},
661 /* CreateWindow(WS_MAXIMIZE|WS_VISIBLE) for popup window */
662 static const struct message WmCreateMaxPopupSeq
[] = {
663 { HCBT_CREATEWND
, hook
},
664 { WM_NCCREATE
, sent
},
665 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
667 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
668 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
670 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
671 { WM_GETMINMAXINFO
, sent
},
672 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_STATECHANGED
},
673 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
674 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOREDRAW
|SWP_STATECHANGED
},
675 { WM_MOVE
, sent
|defwinproc
},
676 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
677 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
678 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
679 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
680 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
681 { HCBT_ACTIVATE
, hook
},
682 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
683 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
684 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
685 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
686 { WM_ERASEBKGND
, sent
|optional
},
687 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOCLIENTMOVE
|SWP_NOCLIENTSIZE
|SWP_NOMOVE
|SWP_NOSIZE
},
688 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
689 { WM_NCACTIVATE
, sent
},
690 { WM_ACTIVATE
, sent
|wparam
, 1 },
691 { HCBT_SETFOCUS
, hook
},
692 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
693 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
694 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
695 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
696 { WM_GETTEXT
, sent
|optional
},
697 { WM_SYNCPAINT
, sent
|wparam
|optional
, 4 },
698 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
699 { WM_ERASEBKGND
, sent
|optional
},
700 { WM_NCPAINT
, sent
|wparam
|defwinproc
|optional
, 1 },
701 { WM_ERASEBKGND
, sent
|defwinproc
|optional
},
702 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOCLIENTMOVE
|SWP_NOCLIENTSIZE
|SWP_SHOWWINDOW
|SWP_NOMOVE
|SWP_NOSIZE
},
705 /* CreateWindow(WS_MAXIMIZE) for popup window, not initially visible */
706 static const struct message WmCreateInvisibleMaxPopupSeq
[] = {
707 { HCBT_CREATEWND
, hook
},
708 { WM_NCCREATE
, sent
},
709 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
711 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
712 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
714 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
715 { WM_GETMINMAXINFO
, sent
},
716 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_STATECHANGED
},
717 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
718 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOREDRAW
|SWP_STATECHANGED
},
719 { WM_MOVE
, sent
|defwinproc
},
720 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
721 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
724 /* ShowWindow(SW_SHOWMAXIMIZED) for a resized not visible popup window */
725 static const struct message WmShowMaxPopupResizedSeq
[] = {
726 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
727 { WM_GETMINMAXINFO
, sent
},
728 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
},
729 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
730 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
731 { HCBT_ACTIVATE
, hook
},
732 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
733 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
734 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
735 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
736 { WM_ERASEBKGND
, sent
|optional
},
737 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
738 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
739 { WM_NCACTIVATE
, sent
},
740 { WM_ACTIVATE
, sent
|wparam
, 1 },
741 { HCBT_SETFOCUS
, hook
},
742 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
743 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
744 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
745 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
746 { WM_GETTEXT
, sent
|optional
},
747 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
748 { WM_ERASEBKGND
, sent
|optional
},
749 { WM_WINDOWPOSCHANGED
, sent
},
750 /* WinNT4.0 sends WM_MOVE */
751 { WM_MOVE
, sent
|defwinproc
|optional
},
752 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
753 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
756 /* ShowWindow(SW_SHOWMAXIMIZED) for a not visible popup window */
757 static const struct message WmShowMaxPopupSeq
[] = {
758 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
759 { WM_GETMINMAXINFO
, sent
},
760 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
},
761 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
762 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
763 { HCBT_ACTIVATE
, hook
},
764 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
765 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
766 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
767 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
768 { WM_NCACTIVATE
, sent
},
769 { WM_ACTIVATE
, sent
|wparam
, 1 },
770 { HCBT_SETFOCUS
, hook
},
771 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
772 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
773 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
774 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
775 { WM_GETTEXT
, sent
|optional
},
776 { WM_SYNCPAINT
, sent
|wparam
|optional
, 4 },
777 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
778 { WM_ERASEBKGND
, sent
|optional
},
779 { WM_NCPAINT
, sent
|wparam
|defwinproc
|optional
, 1 },
780 { WM_ERASEBKGND
, sent
|defwinproc
|optional
},
781 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOMOVE
|SWP_NOSIZE
},
782 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
785 /* CreateWindow(WS_VISIBLE) for popup window */
786 static const struct message WmCreatePopupSeq
[] = {
787 { HCBT_CREATEWND
, hook
},
788 { WM_NCCREATE
, sent
},
789 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
791 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
792 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
794 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
795 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
796 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
797 { HCBT_ACTIVATE
, hook
},
798 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
799 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
800 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
801 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
802 { WM_ERASEBKGND
, sent
|optional
},
803 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
804 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
805 { WM_NCACTIVATE
, sent
},
806 { WM_ACTIVATE
, sent
|wparam
, 1 },
807 { HCBT_SETFOCUS
, hook
},
808 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
809 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
810 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
811 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
812 { WM_GETTEXT
, sent
|optional
},
813 { WM_SYNCPAINT
, sent
|wparam
|optional
, 4 },
814 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
815 { WM_ERASEBKGND
, sent
|optional
},
816 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOCLIENTMOVE
|SWP_NOCLIENTSIZE
|SWP_SHOWWINDOW
|SWP_NOMOVE
|SWP_NOSIZE
},
819 /* ShowWindow(SW_SHOWMAXIMIZED) for a visible popup window */
820 static const struct message WmShowVisMaxPopupSeq
[] = {
821 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
822 { WM_GETMINMAXINFO
, sent
},
823 { WM_GETTEXT
, sent
|optional
},
824 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
825 { WM_GETTEXT
, sent
|optional
},
826 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
827 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
828 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
829 { WM_ERASEBKGND
, sent
|optional
},
830 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
831 { WM_MOVE
, sent
|defwinproc
},
832 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
833 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
836 /* CreateWindow (for a child popup window, not initially visible) */
837 static const struct message WmCreateChildPopupSeq
[] = {
838 { HCBT_CREATEWND
, hook
},
839 { WM_NCCREATE
, sent
},
840 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
842 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
843 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
847 /* CreateWindow (for a popup window, not initially visible,
848 * which sets WS_VISIBLE in WM_CREATE handler)
850 static const struct message WmCreateInvisiblePopupSeq
[] = {
851 { HCBT_CREATEWND
, hook
},
852 { WM_NCCREATE
, sent
},
853 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
855 { WM_STYLECHANGING
, sent
},
856 { WM_STYLECHANGED
, sent
},
857 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
858 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
862 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER)
863 * for a popup window with WS_VISIBLE style set
865 static const struct message WmShowVisiblePopupSeq_2
[] = {
866 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
869 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
870 * for a popup window with WS_VISIBLE style set
872 static const struct message WmShowVisiblePopupSeq_3
[] = {
873 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
874 { HCBT_ACTIVATE
, hook
},
875 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
876 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
877 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
878 { WM_NCACTIVATE
, sent
},
879 { WM_ACTIVATE
, sent
|wparam
, 1 },
880 { HCBT_SETFOCUS
, hook
},
881 { WM_KILLFOCUS
, sent
|parent
},
882 { WM_IME_SETCONTEXT
, sent
|parent
|wparam
|optional
, 0 },
883 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
884 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
885 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
886 { WM_SETFOCUS
, sent
|defwinproc
},
887 { WM_GETTEXT
, sent
|optional
},
888 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
, 0, SWP_SHOWWINDOW
},
891 /* CreateWindow (for child window, not initially visible) */
892 static const struct message WmCreateChildSeq
[] = {
893 { HCBT_CREATEWND
, hook
},
894 { WM_NCCREATE
, sent
},
895 /* child is inserted into parent's child list after WM_NCCREATE returns */
896 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
898 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
899 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
901 { WM_PARENTNOTIFY
, sent
|parent
|wparam
, WM_CREATE
},
904 /* CreateWindow (for maximized child window, not initially visible) */
905 static const struct message WmCreateMaximizedChildSeq
[] = {
906 { HCBT_CREATEWND
, hook
},
907 { WM_NCCREATE
, sent
},
908 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
910 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
911 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
913 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
914 { WM_GETMINMAXINFO
, sent
},
915 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_STATECHANGED
},
916 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
917 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
918 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
919 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
920 { WM_PARENTNOTIFY
, sent
|parent
|wparam
, WM_CREATE
},
923 /* CreateWindow (for a child window, initially visible) */
924 static const struct message WmCreateVisibleChildSeq
[] = {
925 { HCBT_CREATEWND
, hook
},
926 { WM_NCCREATE
, sent
},
927 /* child is inserted into parent's child list after WM_NCCREATE returns */
928 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
929 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
931 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
932 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
934 { WM_PARENTNOTIFY
, sent
|parent
|wparam
, WM_CREATE
},
935 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
936 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
937 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
938 { WM_ERASEBKGND
, sent
|parent
|optional
},
939 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
940 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 }, /* WinXP */
941 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
944 /* ShowWindow(SW_SHOW) for a not visible child window */
945 static const struct message WmShowChildSeq
[] = {
946 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
947 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
948 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
949 { WM_ERASEBKGND
, sent
|parent
|optional
},
950 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
953 /* ShowWindow(SW_HIDE) for a visible child window */
954 static const struct message WmHideChildSeq
[] = {
955 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
956 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
957 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
958 { WM_ERASEBKGND
, sent
|parent
|optional
},
959 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
962 /* ShowWindow(SW_HIDE) for a visible child window checking all parent events*/
963 static const struct message WmHideChildSeq2
[] = {
964 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
965 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
966 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
967 { WM_ERASEBKGND
, sent
|parent
|optional
},
968 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
971 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
972 * for a not visible child window
974 static const struct message WmShowChildSeq_2
[] = {
975 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
976 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
977 { WM_CHILDACTIVATE
, sent
},
978 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
981 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE)
982 * for a not visible child window
984 static const struct message WmShowChildSeq_3
[] = {
985 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
986 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
987 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
990 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
991 * for a visible child window with a caption
993 static const struct message WmShowChildSeq_4
[] = {
994 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
995 { WM_CHILDACTIVATE
, sent
},
998 /* ShowWindow(SW_MINIMIZE) for child with invisible parent */
999 static const struct message WmShowChildInvisibleParentSeq_1
[] = {
1000 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
1001 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
, 0, SWP_NOACTIVATE
},
1002 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1003 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1004 { WM_CHILDACTIVATE
, sent
|optional
},
1005 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOREDRAW
|SWP_NOCOPYBITS
|SWP_STATECHANGED
, 0, SWP_NOACTIVATE
},
1006 { WM_MOVE
, sent
|defwinproc
},
1007 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MINIMIZED
},
1008 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1009 { EVENT_SYSTEM_MINIMIZESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
1010 /* FIXME: Wine creates an icon/title window while Windows doesn't */
1011 { WM_PARENTNOTIFY
, sent
|parent
|wparam
|optional
, WM_CREATE
},
1012 { WM_GETTEXT
, sent
|optional
},
1015 /* repeated ShowWindow(SW_MINIMIZE) for child with invisible parent */
1016 static const struct message WmShowChildInvisibleParentSeq_1r
[] = {
1017 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
1020 /* ShowWindow(SW_MAXIMIZE) for child with invisible parent */
1021 static const struct message WmShowChildInvisibleParentSeq_2
[] = {
1022 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
1023 { WM_GETMINMAXINFO
, sent
},
1024 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_STATECHANGED
},
1025 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1026 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1027 { WM_CHILDACTIVATE
, sent
},
1028 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
1029 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
1030 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1033 /* repeated ShowWindow(SW_MAXIMIZE) for child with invisible parent */
1034 static const struct message WmShowChildInvisibleParentSeq_2r
[] = {
1035 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
1038 /* ShowWindow(SW_SHOWMINIMIZED) for child with invisible parent */
1039 static const struct message WmShowChildInvisibleParentSeq_3
[] = {
1040 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINIMIZED
},
1041 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
1042 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1043 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1044 { WM_CHILDACTIVATE
, sent
},
1045 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOREDRAW
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
1046 { WM_MOVE
, sent
|defwinproc
},
1047 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MINIMIZED
},
1048 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1049 { EVENT_SYSTEM_MINIMIZESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
1050 /* FIXME: Wine creates an icon/title window while Windows doesn't */
1051 { WM_PARENTNOTIFY
, sent
|parent
|wparam
|optional
, WM_CREATE
},
1052 { WM_GETTEXT
, sent
|optional
},
1055 /* repeated ShowWindow(SW_SHOWMINIMIZED) for child with invisible parent */
1056 static const struct message WmShowChildInvisibleParentSeq_3r
[] = {
1057 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINIMIZED
},
1060 /* ShowWindow(SW_SHOWMINNOACTIVE) for child with invisible parent */
1061 static const struct message WmShowChildInvisibleParentSeq_4
[] = {
1062 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINNOACTIVE
},
1063 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
1064 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1065 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1066 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOREDRAW
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
1067 { WM_MOVE
, sent
|defwinproc
},
1068 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MINIMIZED
},
1069 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1070 { EVENT_SYSTEM_MINIMIZESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
1071 /* FIXME: Wine creates an icon/title window while Windows doesn't */
1072 { WM_PARENTNOTIFY
, sent
|parent
|wparam
|optional
, WM_CREATE
},
1073 { WM_GETTEXT
, sent
|optional
},
1076 /* repeated ShowWindow(SW_SHOWMINNOACTIVE) for child with invisible parent */
1077 static const struct message WmShowChildInvisibleParentSeq_4r
[] = {
1078 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINNOACTIVE
},
1081 /* ShowWindow(SW_SHOW) for child with invisible parent */
1082 static const struct message WmShowChildInvisibleParentSeq_5
[] = {
1083 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1086 /* ShowWindow(SW_HIDE) for child with invisible parent */
1087 static const struct message WmHideChildInvisibleParentSeq
[] = {
1088 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
1091 /* SetWindowPos(SWP_SHOWWINDOW) for child with invisible parent */
1092 static const struct message WmShowChildInvisibleParentSeq_6
[] = {
1093 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
1094 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1095 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1098 /* SetWindowPos(SWP_HIDEWINDOW) for child with invisible parent */
1099 static const struct message WmHideChildInvisibleParentSeq_2
[] = {
1100 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1101 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1102 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1105 /* DestroyWindow for a visible child window */
1106 static const struct message WmDestroyChildSeq
[] = {
1107 { HCBT_DESTROYWND
, hook
},
1108 { 0x0090, sent
|optional
},
1109 { WM_PARENTNOTIFY
, sent
|parent
|wparam
, WM_DESTROY
},
1110 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
1111 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1112 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1113 { WM_ERASEBKGND
, sent
|parent
|optional
},
1114 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1115 { HCBT_SETFOCUS
, hook
}, /* set focus to a parent */
1116 { WM_KILLFOCUS
, sent
},
1117 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
1118 { WM_IME_SETCONTEXT
, sent
|wparam
|parent
|optional
, 1 },
1119 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1120 { WM_SETFOCUS
, sent
|parent
},
1121 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
1122 { WM_DESTROY
, sent
},
1123 { WM_DESTROY
, sent
|optional
}, /* some other (IME?) window */
1124 { WM_NCDESTROY
, sent
|optional
}, /* some other (IME?) window */
1125 { WM_NCDESTROY
, sent
},
1128 /* visible child window destroyed by thread exit */
1129 static const struct message WmExitThreadSeq
[] = {
1130 { WM_NCDESTROY
, sent
}, /* actually in grandchild */
1131 { WM_PAINT
, sent
|parent
},
1132 { WM_ERASEBKGND
, sent
|parent
|beginpaint
},
1135 /* DestroyWindow for a visible child window with invisible parent */
1136 static const struct message WmDestroyInvisibleChildSeq
[] = {
1137 { HCBT_DESTROYWND
, hook
},
1138 { 0x0090, sent
|optional
},
1139 { WM_PARENTNOTIFY
, sent
|parent
|wparam
, WM_DESTROY
},
1140 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
1141 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
1142 { WM_DESTROY
, sent
},
1143 { WM_NCDESTROY
, sent
},
1146 /* Moving the mouse in nonclient area */
1147 static const struct message WmMouseMoveInNonClientAreaSeq
[] = { /* FIXME: add */
1148 { WM_NCHITTEST
, sent
},
1149 { WM_SETCURSOR
, sent
},
1150 { WM_NCMOUSEMOVE
, posted
},
1153 /* Moving the mouse in client area */
1154 static const struct message WmMouseMoveInClientAreaSeq
[] = { /* FIXME: add */
1155 { WM_NCHITTEST
, sent
},
1156 { WM_SETCURSOR
, sent
},
1157 { WM_MOUSEMOVE
, posted
},
1160 /* Moving by dragging the title bar (after WM_NCHITTEST and WM_SETCURSOR) (outline move) */
1161 static const struct message WmDragTitleBarSeq
[] = { /* FIXME: add */
1162 { WM_NCLBUTTONDOWN
, sent
|wparam
, HTCAPTION
},
1163 { WM_SYSCOMMAND
, sent
|defwinproc
|wparam
, SC_MOVE
+2 },
1164 { WM_GETMINMAXINFO
, sent
|defwinproc
},
1165 { WM_ENTERSIZEMOVE
, sent
|defwinproc
},
1166 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, 0 },
1167 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, 0 },
1168 { WM_MOVE
, sent
|defwinproc
},
1169 { WM_EXITSIZEMOVE
, sent
|defwinproc
},
1172 /* Sizing by dragging the thick borders (after WM_NCHITTEST and WM_SETCURSOR) (outline move) */
1173 static const struct message WmDragThickBordersBarSeq
[] = { /* FIXME: add */
1174 { WM_NCLBUTTONDOWN
, sent
|wparam
, 0xd },
1175 { WM_SYSCOMMAND
, sent
|defwinproc
|wparam
, 0xf004 },
1176 { WM_GETMINMAXINFO
, sent
|defwinproc
},
1177 { WM_ENTERSIZEMOVE
, sent
|defwinproc
},
1178 { WM_SIZING
, sent
|defwinproc
|wparam
, 4}, /* one for each mouse movement */
1179 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, 0 },
1180 { WM_GETMINMAXINFO
, sent
|defwinproc
},
1181 { WM_NCCALCSIZE
, sent
|defwinproc
|wparam
, 1 },
1182 { WM_NCPAINT
, sent
|defwinproc
|wparam
, 1 },
1183 { WM_GETTEXT
, sent
|defwinproc
},
1184 { WM_ERASEBKGND
, sent
|defwinproc
},
1185 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, 0 },
1186 { WM_MOVE
, sent
|defwinproc
},
1187 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
1188 { WM_EXITSIZEMOVE
, sent
|defwinproc
},
1191 /* Resizing child window with MoveWindow (32) */
1192 static const struct message WmResizingChildWithMoveWindowSeq
[] = {
1193 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
1194 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1195 { WM_ERASEBKGND
, sent
|parent
|optional
},
1196 { WM_ERASEBKGND
, sent
|optional
},
1197 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
},
1198 { WM_MOVE
, sent
|defwinproc
},
1199 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
1200 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1203 /* Clicking on inactive button */
1204 static const struct message WmClickInactiveButtonSeq
[] = { /* FIXME: add */
1205 { WM_NCHITTEST
, sent
},
1206 { WM_PARENTNOTIFY
, sent
|parent
|wparam
, WM_LBUTTONDOWN
},
1207 { WM_MOUSEACTIVATE
, sent
},
1208 { WM_MOUSEACTIVATE
, sent
|parent
|defwinproc
},
1209 { WM_SETCURSOR
, sent
},
1210 { WM_SETCURSOR
, sent
|parent
|defwinproc
},
1211 { WM_LBUTTONDOWN
, posted
},
1212 { WM_KILLFOCUS
, posted
|parent
},
1213 { WM_SETFOCUS
, posted
},
1214 { WM_CTLCOLORBTN
, posted
|parent
},
1215 { BM_SETSTATE
, posted
},
1216 { WM_CTLCOLORBTN
, posted
|parent
},
1217 { WM_LBUTTONUP
, posted
},
1218 { BM_SETSTATE
, posted
},
1219 { WM_CTLCOLORBTN
, posted
|parent
},
1220 { WM_COMMAND
, posted
|parent
},
1223 /* Reparenting a button (16/32) */
1224 /* The last child (button) reparented gets topmost for its new parent. */
1225 static const struct message WmReparentButtonSeq
[] = { /* FIXME: add */
1226 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
1227 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOSIZE
},
1228 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1229 { WM_ERASEBKGND
, sent
|parent
},
1230 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOSIZE
},
1231 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
},
1232 { WM_CHILDACTIVATE
, sent
},
1233 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOSIZE
|SWP_NOREDRAW
},
1234 { WM_MOVE
, sent
|defwinproc
},
1235 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1238 /* Creation of a custom dialog (32) */
1239 static const struct message WmCreateCustomDialogSeq
[] = {
1240 { HCBT_CREATEWND
, hook
},
1241 { WM_GETMINMAXINFO
, sent
},
1242 { WM_NCCREATE
, sent
},
1243 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
1244 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
1245 { WM_CREATE
, sent
},
1246 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1247 { WM_NOTIFYFORMAT
, sent
|optional
},
1248 { WM_QUERYUISTATE
, sent
|optional
},
1249 { WM_WINDOWPOSCHANGING
, sent
|optional
},
1250 { WM_GETMINMAXINFO
, sent
|optional
},
1251 { WM_NCCALCSIZE
, sent
|optional
},
1252 { WM_WINDOWPOSCHANGED
, sent
|optional
},
1253 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1254 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
1255 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1256 { HCBT_ACTIVATE
, hook
},
1257 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
1260 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
1262 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
1264 { WM_NCACTIVATE
, sent
},
1265 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1266 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1267 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1268 { EVENT_OBJECT_DEFACTIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, OBJID_CLIENT
, 0 },
1269 { WM_ACTIVATE
, sent
|wparam
, 1 },
1270 { WM_GETTEXT
, sent
|optional
},
1271 { WM_KILLFOCUS
, sent
|parent
},
1272 { WM_IME_SETCONTEXT
, sent
|parent
|wparam
|optional
, 0 },
1273 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
1274 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
1275 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1276 { WM_SETFOCUS
, sent
},
1277 { WM_GETDLGCODE
, sent
|defwinproc
|wparam
, 0 },
1278 { WM_NCPAINT
, sent
|wparam
, 1 },
1279 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1280 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1281 { WM_ERASEBKGND
, sent
},
1282 { WM_CTLCOLORDLG
, sent
|optional
|defwinproc
},
1283 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1284 { WM_GETTEXT
, sent
|optional
},
1285 { WM_GETTEXT
, sent
|optional
},
1286 { WM_NCCALCSIZE
, sent
|optional
},
1287 { WM_NCPAINT
, sent
|optional
},
1288 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1289 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1290 { WM_ERASEBKGND
, sent
|optional
},
1291 { WM_CTLCOLORDLG
, sent
|optional
|defwinproc
},
1292 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1293 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
1297 /* Calling EndDialog for a custom dialog (32) */
1298 static const struct message WmEndCustomDialogSeq
[] = {
1299 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1300 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1301 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1302 { WM_GETTEXT
, sent
|optional
},
1303 { HCBT_ACTIVATE
, hook
},
1304 { WM_NCACTIVATE
, sent
|wparam
, 0 },
1305 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1306 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1307 { WM_ACTIVATE
, sent
|wparam
, 0 },
1308 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
1309 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1310 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOACTIVATE
|SWP_NOREDRAW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1311 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1312 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1313 { HCBT_SETFOCUS
, hook
},
1314 { WM_KILLFOCUS
, sent
},
1315 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
1316 { WM_IME_SETCONTEXT
, sent
|parent
|wparam
|defwinproc
|optional
, 1 },
1317 { WM_IME_NOTIFY
, sent
|wparam
|optional
, 1 },
1318 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1319 { WM_SETFOCUS
, sent
|parent
|defwinproc
},
1322 /* ShowWindow(SW_SHOW) for a custom dialog (initially invisible) */
1323 static const struct message WmShowCustomDialogSeq
[] = {
1324 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1325 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
1326 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1327 { HCBT_ACTIVATE
, hook
},
1328 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
1330 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
1332 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
1333 { WM_ACTIVATEAPP
, sent
|wparam
|optional
, 1 },
1334 { WM_NCACTIVATE
, sent
},
1335 { WM_ACTIVATE
, sent
|wparam
, 1 },
1336 { WM_GETTEXT
, sent
|optional
},
1338 { WM_KILLFOCUS
, sent
|parent
},
1339 { WM_IME_SETCONTEXT
, sent
|parent
|wparam
|optional
, 0 },
1340 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
1341 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
1342 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1343 { WM_SETFOCUS
, sent
},
1344 { WM_GETDLGCODE
, sent
|defwinproc
|wparam
, 0 },
1345 { WM_NCPAINT
, sent
|wparam
, 1 },
1346 { WM_ERASEBKGND
, sent
},
1347 { WM_CTLCOLORDLG
, sent
|defwinproc
},
1348 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1351 /* Creation and destruction of a modal dialog (32) */
1352 static const struct message WmModalDialogSeq
[] = {
1353 { WM_CANCELMODE
, sent
|parent
},
1354 { HCBT_SETFOCUS
, hook
},
1355 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1356 { WM_KILLFOCUS
, sent
|parent
},
1357 { WM_IME_SETCONTEXT
, sent
|parent
|wparam
|optional
, 0 },
1358 { EVENT_OBJECT_STATECHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1359 { WM_ENABLE
, sent
|parent
|wparam
, 0 },
1360 { HCBT_CREATEWND
, hook
},
1361 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
1362 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1363 { WM_SETFONT
, sent
},
1364 { WM_INITDIALOG
, sent
},
1365 { WM_CHANGEUISTATE
, sent
|optional
},
1366 { WM_UPDATEUISTATE
, sent
|optional
},
1367 { WM_SHOWWINDOW
, sent
},
1368 { HCBT_ACTIVATE
, hook
},
1369 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
1370 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
1371 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
},
1372 { WM_NCACTIVATE
, sent
},
1373 { WM_GETTEXT
, sent
|optional
},
1374 { WM_ACTIVATE
, sent
|wparam
, 1 },
1375 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
1376 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1377 { WM_NCPAINT
, sent
|optional
},
1378 { WM_GETTEXT
, sent
|optional
},
1379 { WM_ERASEBKGND
, sent
|optional
},
1380 { WM_CTLCOLORDLG
, sent
|optional
},
1381 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1382 { WM_GETTEXT
, sent
|optional
},
1383 { WM_NCCALCSIZE
, sent
|optional
},
1384 { WM_NCPAINT
, sent
|optional
},
1385 { WM_GETTEXT
, sent
|optional
},
1386 { WM_ERASEBKGND
, sent
|optional
},
1387 { WM_CTLCOLORDLG
, sent
|optional
},
1388 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1389 { WM_PAINT
, sent
|optional
},
1390 { WM_CTLCOLORBTN
, sent
|optional
},
1391 { WM_GETTITLEBARINFOEX
, sent
|optional
},
1392 { WM_ENTERIDLE
, sent
|parent
|optional
},
1393 { WM_ENTERIDLE
, sent
|parent
|optional
},
1394 { WM_ENTERIDLE
, sent
|parent
|optional
},
1395 { WM_ENTERIDLE
, sent
|parent
|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
},
1413 { EVENT_OBJECT_STATECHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1414 { WM_ENABLE
, sent
|parent
|wparam
, 1 },
1415 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
1416 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1417 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1418 { WM_GETTEXT
, sent
|optional
},
1419 { HCBT_ACTIVATE
, hook
},
1420 { WM_NCACTIVATE
, sent
|wparam
, 0 },
1421 { WM_GETTEXT
, sent
|optional
},
1422 { WM_ACTIVATE
, sent
|wparam
, 0 },
1423 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
1424 { WM_WINDOWPOSCHANGING
, sent
|optional
},
1425 { WM_WINDOWPOSCHANGED
, sent
|optional
},
1426 { HCBT_SETFOCUS
, hook
},
1427 { WM_IME_SETCONTEXT
, sent
|parent
|wparam
|defwinproc
|optional
, 1 },
1428 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1429 { WM_SETFOCUS
, sent
|parent
|defwinproc
},
1430 { EVENT_SYSTEM_DIALOGEND
, winevent_hook
|wparam
|lparam
, 0, 0 },
1431 { HCBT_DESTROYWND
, hook
},
1432 { 0x0090, sent
|optional
},
1433 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
1434 { WM_DESTROY
, sent
},
1435 { WM_NCDESTROY
, sent
},
1438 /* Creation of a modal dialog that is resized inside WM_INITDIALOG (32) */
1439 static const struct message WmCreateModalDialogResizeSeq
[] = { /* FIXME: add */
1440 /* (inside dialog proc, handling WM_INITDIALOG) */
1441 { WM_WINDOWPOSCHANGING
, sent
|wparam
, 0 },
1442 { WM_NCCALCSIZE
, sent
},
1443 { WM_NCACTIVATE
, sent
|parent
|wparam
, 0 },
1444 { WM_GETTEXT
, sent
|defwinproc
},
1445 { WM_ACTIVATE
, sent
|parent
|wparam
, 0 },
1446 { WM_WINDOWPOSCHANGING
, sent
|wparam
, 0 },
1447 { WM_WINDOWPOSCHANGING
, sent
|parent
},
1448 { WM_NCACTIVATE
, sent
|wparam
, 1 },
1449 { WM_ACTIVATE
, sent
|wparam
, 1 },
1450 { WM_WINDOWPOSCHANGED
, sent
|wparam
, 0 },
1451 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
1452 /* (setting focus) */
1453 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1454 { WM_WINDOWPOSCHANGING
, sent
|wparam
, 0 },
1455 { WM_NCPAINT
, sent
},
1456 { WM_GETTEXT
, sent
|defwinproc
},
1457 { WM_ERASEBKGND
, sent
},
1458 { WM_CTLCOLORDLG
, sent
|defwinproc
},
1459 { WM_WINDOWPOSCHANGED
, sent
|wparam
, 0 },
1461 /* (bunch of WM_CTLCOLOR* for each control) */
1462 { WM_PAINT
, sent
|parent
},
1463 { WM_ENTERIDLE
, sent
|parent
|wparam
, 0 },
1464 { WM_SETCURSOR
, sent
|parent
},
1467 /* SetMenu for NonVisible windows with size change*/
1468 static const struct message WmSetMenuNonVisibleSizeChangeSeq
[] = {
1469 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1470 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1471 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
1472 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
},
1473 { WM_MOVE
, sent
|defwinproc
},
1474 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
1475 { WM_NCCALCSIZE
,sent
|wparam
|optional
, 1 }, /* XP */
1476 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1477 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* XP sends a duplicate */
1478 { WM_GETTEXT
, sent
|optional
},
1479 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
1482 /* SetMenu for NonVisible windows with no size change */
1483 static const struct message WmSetMenuNonVisibleNoSizeChangeSeq
[] = {
1484 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1485 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1486 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1487 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1490 /* SetMenu for Visible windows with size change */
1491 static const struct message WmSetMenuVisibleSizeChangeSeq
[] = {
1492 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1493 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1494 { 0x0093, sent
|defwinproc
|optional
},
1495 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
1496 { WM_NCPAINT
, sent
|optional
}, /* wparam != 1 */
1497 { 0x0093, sent
|defwinproc
|optional
},
1498 { 0x0093, sent
|defwinproc
|optional
},
1499 { 0x0091, sent
|defwinproc
|optional
},
1500 { 0x0092, sent
|defwinproc
|optional
},
1501 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1502 { WM_ERASEBKGND
, sent
|optional
},
1503 { WM_ACTIVATE
, sent
|optional
},
1504 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1505 { WM_MOVE
, sent
|defwinproc
},
1506 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
1507 { 0x0093, sent
|optional
},
1508 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
1509 { 0x0093, sent
|defwinproc
|optional
},
1510 { WM_NCPAINT
, sent
|optional
}, /* wparam != 1 */
1511 { 0x0093, sent
|defwinproc
|optional
},
1512 { 0x0093, sent
|defwinproc
|optional
},
1513 { 0x0091, sent
|defwinproc
|optional
},
1514 { 0x0092, sent
|defwinproc
|optional
},
1515 { WM_ERASEBKGND
, sent
|optional
},
1516 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1517 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* XP sends a duplicate */
1520 /* SetMenu for Visible windows with no size change */
1521 static const struct message WmSetMenuVisibleNoSizeChangeSeq
[] = {
1522 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1523 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1524 { WM_NCPAINT
, sent
|optional
}, /* wparam != 1 */
1525 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1526 { WM_ERASEBKGND
, sent
|optional
},
1527 { WM_ACTIVATE
, sent
|optional
},
1528 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1529 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1532 /* DrawMenuBar for a visible window */
1533 static const struct message WmDrawMenuBarSeq
[] =
1535 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1536 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1537 { 0x0093, sent
|defwinproc
|optional
},
1538 { WM_NCPAINT
, sent
|optional
}, /* wparam != 1 */
1539 { 0x0093, sent
|defwinproc
|optional
},
1540 { 0x0093, sent
|defwinproc
|optional
},
1541 { 0x0091, sent
|defwinproc
|optional
},
1542 { 0x0092, sent
|defwinproc
|optional
},
1543 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1544 { WM_ERASEBKGND
, sent
|optional
},
1545 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1546 { 0x0093, sent
|optional
},
1547 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1551 static const struct message WmSetRedrawFalseSeq
[] =
1553 { WM_SETREDRAW
, sent
|wparam
, 0 },
1557 static const struct message WmSetRedrawTrueSeq
[] =
1559 { WM_SETREDRAW
, sent
|wparam
, 1 },
1563 static const struct message WmEnableWindowSeq_1
[] =
1565 { WM_CANCELMODE
, sent
|wparam
|lparam
, 0, 0 },
1566 { EVENT_OBJECT_STATECHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1567 { HCBT_SETFOCUS
, hook
|optional
},
1568 { WM_KILLFOCUS
, sent
|optional
},
1569 { WM_ENABLE
, sent
|wparam
|lparam
, FALSE
, 0 },
1573 static const struct message WmEnableWindowSeq_2
[] =
1575 { EVENT_OBJECT_STATECHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1576 { WM_ENABLE
, sent
|wparam
|lparam
, TRUE
, 0 },
1580 static const struct message WmGetScrollRangeSeq
[] =
1582 { SBM_GETRANGE
, sent
},
1585 static const struct message WmGetScrollInfoSeq
[] =
1587 { SBM_GETSCROLLINFO
, sent
},
1590 static const struct message WmSetScrollRangeSeq
[] =
1592 /* MSDN claims that Windows sends SBM_SETRANGE message, but win2k SP4
1593 sends SBM_SETSCROLLINFO.
1595 { SBM_SETSCROLLINFO
, sent
},
1598 /* SetScrollRange for a window without a non-client area */
1599 static const struct message WmSetScrollRangeHSeq_empty
[] =
1601 { EVENT_OBJECT_VALUECHANGE
, winevent_hook
|wparam
|lparam
, OBJID_HSCROLL
, 0 },
1604 static const struct message WmSetScrollRangeVSeq_empty
[] =
1606 { EVENT_OBJECT_VALUECHANGE
, winevent_hook
|wparam
|lparam
, OBJID_VSCROLL
, 0 },
1609 static const struct message WmSetScrollRangeHVSeq
[] =
1611 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOSIZE
},
1612 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1613 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1614 { WM_ERASEBKGND
, sent
|optional
},
1615 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1616 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1617 { EVENT_OBJECT_VALUECHANGE
, winevent_hook
|lparam
|optional
, 0/*OBJID_HSCROLL or OBJID_VSCROLL*/, 0 },
1620 /* SetScrollRange for a window with a non-client area */
1621 static const struct message WmSetScrollRangeHV_NC_Seq
[] =
1623 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOSIZE
},
1624 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1625 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
1626 { WM_NCPAINT
, sent
|optional
},
1627 { WM_STYLECHANGING
, sent
|defwinproc
|optional
},
1628 { WM_STYLECHANGED
, sent
|defwinproc
|optional
},
1629 { WM_STYLECHANGING
, sent
|defwinproc
|optional
},
1630 { WM_STYLECHANGED
, sent
|defwinproc
|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_GETTEXT
, sent
|defwinproc
|optional
},
1636 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1637 { WM_ERASEBKGND
, sent
|optional
},
1638 { WM_CTLCOLORDLG
, sent
|defwinproc
|optional
}, /* sent to a parent of the dialog */
1639 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOCLIENTMOVE
, 0, SWP_NOCLIENTSIZE
},
1640 { WM_SIZE
, sent
|defwinproc
|optional
},
1641 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1642 { EVENT_OBJECT_VALUECHANGE
, winevent_hook
|lparam
|optional
, 0/*OBJID_HSCROLL or OBJID_VSCROLL*/, 0 },
1643 { WM_GETTEXT
, sent
|optional
},
1644 { WM_GETTEXT
, sent
|optional
},
1645 { WM_GETTEXT
, sent
|optional
},
1646 { WM_GETTEXT
, sent
|optional
},
1649 /* test if we receive the right sequence of messages */
1650 /* after calling ShowWindow( SW_SHOWNA) */
1651 static const struct message WmSHOWNAChildInvisParInvis
[] = {
1652 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1655 static const struct message WmSHOWNAChildVisParInvis
[] = {
1656 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1659 static const struct message WmSHOWNAChildVisParVis
[] = {
1660 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1661 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
1664 static const struct message WmSHOWNAChildInvisParVis
[] = {
1665 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1666 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1667 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1668 { WM_ERASEBKGND
, sent
|optional
},
1669 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOACTIVATE
|SWP_NOCLIENTMOVE
},
1672 static const struct message WmSHOWNATopVisible
[] = {
1673 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1674 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
1675 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
1676 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1677 { WM_ERASEBKGND
, sent
|optional
},
1678 { WM_WINDOWPOSCHANGED
, sent
|optional
},
1681 static const struct message WmSHOWNATopInvisible
[] = {
1682 { WM_NOTIFYFORMAT
, sent
|optional
},
1683 { WM_QUERYUISTATE
, sent
|optional
},
1684 { WM_WINDOWPOSCHANGING
, sent
|optional
},
1685 { WM_GETMINMAXINFO
, sent
|optional
},
1686 { WM_NCCALCSIZE
, sent
|optional
},
1687 { WM_WINDOWPOSCHANGED
, sent
|optional
},
1688 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1689 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1690 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1691 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
1692 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1693 { WM_ERASEBKGND
, sent
|optional
},
1694 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1695 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
1696 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
1697 { WM_ERASEBKGND
, sent
|optional
},
1698 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1699 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
1704 static int after_end_dialog
, test_def_id
;
1705 static int sequence_cnt
, sequence_size
;
1706 static struct recvd_message
* sequence
;
1707 static int log_all_parent_messages
;
1708 static int paint_loop_done
;
1710 /* user32 functions */
1711 static HWND (WINAPI
*pGetAncestor
)(HWND
,UINT
);
1712 static BOOL (WINAPI
*pGetMenuInfo
)(HMENU
,LPCMENUINFO
);
1713 static void (WINAPI
*pNotifyWinEvent
)(DWORD
, HWND
, LONG
, LONG
);
1714 static BOOL (WINAPI
*pSetMenuInfo
)(HMENU
,LPCMENUINFO
);
1715 static HWINEVENTHOOK (WINAPI
*pSetWinEventHook
)(DWORD
, DWORD
, HMODULE
, WINEVENTPROC
, DWORD
, DWORD
, DWORD
);
1716 static BOOL (WINAPI
*pTrackMouseEvent
)(TRACKMOUSEEVENT
*);
1717 static BOOL (WINAPI
*pUnhookWinEvent
)(HWINEVENTHOOK
);
1718 /* kernel32 functions */
1719 static BOOL (WINAPI
*pGetCPInfoExA
)(UINT
, DWORD
, LPCPINFOEXA
);
1721 static void init_procs(void)
1723 HMODULE user32
= GetModuleHandleA("user32.dll");
1724 HMODULE kernel32
= GetModuleHandleA("kernel32.dll");
1726 #define GET_PROC(dll, func) \
1727 p ## func = (void*)GetProcAddress(dll, #func); \
1729 trace("GetProcAddress(%s) failed\n", #func); \
1732 GET_PROC(user32
, GetAncestor
)
1733 GET_PROC(user32
, GetMenuInfo
)
1734 GET_PROC(user32
, NotifyWinEvent
)
1735 GET_PROC(user32
, SetMenuInfo
)
1736 GET_PROC(user32
, SetWinEventHook
)
1737 GET_PROC(user32
, TrackMouseEvent
)
1738 GET_PROC(user32
, UnhookWinEvent
)
1740 GET_PROC(kernel32
, GetCPInfoExA
)
1745 static const char *get_winpos_flags(UINT flags
)
1747 static char buffer
[300];
1750 #define DUMP(flag) do { if (flags & flag) { strcat( buffer, "|" #flag ); flags &= ~flag; } } while(0)
1751 DUMP( SWP_SHOWWINDOW
);
1752 DUMP( SWP_HIDEWINDOW
);
1753 DUMP( SWP_NOACTIVATE
);
1754 DUMP( SWP_FRAMECHANGED
);
1755 DUMP( SWP_NOCOPYBITS
);
1756 DUMP( SWP_NOOWNERZORDER
);
1757 DUMP( SWP_NOSENDCHANGING
);
1758 DUMP( SWP_DEFERERASE
);
1759 DUMP( SWP_ASYNCWINDOWPOS
);
1760 DUMP( SWP_NOZORDER
);
1761 DUMP( SWP_NOREDRAW
);
1764 DUMP( SWP_NOCLIENTSIZE
);
1765 DUMP( SWP_NOCLIENTMOVE
);
1766 if (flags
) sprintf(buffer
+ strlen(buffer
),"|0x%04x", flags
);
1771 static BOOL
ignore_message( UINT message
)
1773 /* these are always ignored */
1774 return (message
>= 0xc000 ||
1775 message
== WM_GETICON
||
1776 message
== WM_GETOBJECT
||
1777 message
== WM_TIMECHANGE
||
1778 message
== WM_DISPLAYCHANGE
||
1779 message
== WM_DEVICECHANGE
);
1783 #define add_message(msg) add_message_(__LINE__,msg);
1784 static void add_message_(int line
, const struct recvd_message
*msg
)
1786 struct recvd_message
*seq
;
1791 sequence
= HeapAlloc( GetProcessHeap(), 0, sequence_size
* sizeof(*sequence
) );
1793 if (sequence_cnt
== sequence_size
)
1796 sequence
= HeapReAlloc( GetProcessHeap(), 0, sequence
, sequence_size
* sizeof(*sequence
) );
1800 seq
= &sequence
[sequence_cnt
];
1801 seq
->hwnd
= msg
->hwnd
;
1802 seq
->message
= msg
->message
;
1803 seq
->flags
= msg
->flags
;
1804 seq
->wParam
= msg
->wParam
;
1805 seq
->lParam
= msg
->lParam
;
1807 seq
->descr
= msg
->descr
;
1812 if (msg
->flags
& hook
)
1814 static const char * const CBT_code_name
[10] =
1822 "HCBT_CLICKSKIPPED",
1827 const char *code_name
= (msg
->message
<= HCBT_SETFOCUS
) ? CBT_code_name
[msg
->message
] : "Unknown";
1829 sprintf( seq
->output
, "%s: hook %d (%s) wp %08lx lp %08lx",
1830 msg
->descr
, msg
->message
, code_name
, msg
->wParam
, msg
->lParam
);
1832 else if (msg
->flags
& winevent_hook
)
1834 sprintf( seq
->output
, "%s: winevent %p %08x %08lx %08lx",
1835 msg
->descr
, msg
->hwnd
, msg
->message
, msg
->wParam
, msg
->lParam
);
1839 switch (msg
->message
)
1841 case WM_WINDOWPOSCHANGING
:
1842 case WM_WINDOWPOSCHANGED
:
1844 WINDOWPOS
*winpos
= (WINDOWPOS
*)msg
->lParam
;
1846 sprintf( seq
->output
, "%s: %p WM_WINDOWPOS%s wp %08lx lp %08lx after %p x %d y %d cx %d cy %d flags %s",
1847 msg
->descr
, msg
->hwnd
,
1848 (msg
->message
== WM_WINDOWPOSCHANGING
) ? "CHANGING" : "CHANGED",
1849 msg
->wParam
, msg
->lParam
, winpos
->hwndInsertAfter
,
1850 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
,
1851 get_winpos_flags(winpos
->flags
) );
1853 /* Log only documented flags, win2k uses 0x1000 and 0x2000
1854 * in the high word for internal purposes
1856 seq
->wParam
= winpos
->flags
& 0xffff;
1857 /* We are not interested in the flags that don't match under XP and Win9x */
1858 seq
->wParam
&= ~SWP_NOZORDER
;
1864 DRAW_ITEM_STRUCT di
;
1865 DRAWITEMSTRUCT
*dis
= (DRAWITEMSTRUCT
*)msg
->lParam
;
1867 sprintf( seq
->output
, "%s: %p WM_DRAWITEM: type %x, ctl_id %x, item_id %x, action %x, state %x",
1868 msg
->descr
, msg
->hwnd
, dis
->CtlType
, dis
->CtlID
,
1869 dis
->itemID
, dis
->itemAction
, dis
->itemState
);
1872 di
.u
.item
.type
= dis
->CtlType
;
1873 di
.u
.item
.ctl_id
= dis
->CtlID
;
1874 if (dis
->CtlType
== ODT_LISTBOX
||
1875 dis
->CtlType
== ODT_COMBOBOX
||
1876 dis
->CtlType
== ODT_MENU
)
1877 di
.u
.item
.item_id
= dis
->itemID
;
1878 di
.u
.item
.action
= dis
->itemAction
;
1879 di
.u
.item
.state
= dis
->itemState
;
1881 seq
->lParam
= di
.u
.lp
;
1885 if (msg
->message
>= 0xc000) return; /* ignore registered messages */
1886 sprintf( seq
->output
, "%s: %p %04x wp %08lx lp %08lx",
1887 msg
->descr
, msg
->hwnd
, msg
->message
, msg
->wParam
, msg
->lParam
);
1889 if (msg
->flags
& (sent
|posted
|parent
|defwinproc
|beginpaint
))
1890 sprintf( seq
->output
+ strlen(seq
->output
), " (flags %x)", msg
->flags
);
1897 /* try to make sure pending X events have been processed before continuing */
1898 static void flush_events(void)
1902 int min_timeout
= 100;
1903 DWORD time
= GetTickCount() + diff
;
1907 if (MsgWaitForMultipleObjects( 0, NULL
, FALSE
, min_timeout
, QS_ALLINPUT
) == WAIT_TIMEOUT
) break;
1908 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
1909 diff
= time
- GetTickCount();
1913 static void flush_sequence(void)
1915 HeapFree(GetProcessHeap(), 0, sequence
);
1917 sequence_cnt
= sequence_size
= 0;
1920 static void dump_sequence(const struct message
*expected
, const char *context
, const char *file
, int line
)
1922 const struct recvd_message
*actual
= sequence
;
1923 unsigned int count
= 0;
1925 trace_(file
, line
)("Failed sequence %s:\n", context
);
1926 while (expected
->message
&& actual
->message
)
1928 if (actual
->output
[0])
1930 if (expected
->flags
& hook
)
1932 trace_(file
, line
)( " %u: expected: hook %04x - actual: %s\n",
1933 count
, expected
->message
, actual
->output
);
1935 else if (expected
->flags
& winevent_hook
)
1937 trace_(file
, line
)( " %u: expected: winevent %04x - actual: %s\n",
1938 count
, expected
->message
, actual
->output
);
1942 trace_(file
, line
)( " %u: expected: msg %04x - actual: %s\n",
1943 count
, expected
->message
, actual
->output
);
1947 if (expected
->message
== actual
->message
)
1949 if ((expected
->flags
& defwinproc
) != (actual
->flags
& defwinproc
) &&
1950 (expected
->flags
& optional
))
1952 /* don't match messages if their defwinproc status differs */
1961 /* silently drop winevent messages if there is no support for them */
1962 else if ((expected
->flags
& optional
) || ((expected
->flags
& winevent_hook
) && !hEvent_hook
))
1972 /* optional trailing messages */
1973 while (expected
->message
&& ((expected
->flags
& optional
) ||
1974 ((expected
->flags
& winevent_hook
) && !hEvent_hook
)))
1976 trace_(file
, line
)( " %u: expected: msg %04x - actual: nothing\n", count
, expected
->message
);
1981 if (expected
->message
)
1983 trace_(file
, line
)( " %u: expected: msg %04x - actual: nothing\n", count
, expected
->message
);
1987 while (actual
->message
&& actual
->output
[0])
1989 trace_(file
, line
)( " %u: expected: nothing - actual: %s\n", count
, actual
->output
);
1995 #define ok_sequence( exp, contx, todo) \
1996 ok_sequence_( (exp), (contx), (todo), __FILE__, __LINE__)
1999 static void ok_sequence_(const struct message
*expected_list
, const char *context
, int todo
,
2000 const char *file
, int line
)
2002 static const struct recvd_message end_of_sequence
;
2003 const struct message
*expected
= expected_list
;
2004 const struct recvd_message
*actual
;
2005 int failcount
= 0, dump
= 0;
2006 unsigned int count
= 0;
2008 add_message(&end_of_sequence
);
2012 while (expected
->message
&& actual
->message
)
2014 if (expected
->message
== actual
->message
)
2016 if (expected
->flags
& wparam
)
2018 if (((expected
->wParam
^ actual
->wParam
) & ~expected
->wp_mask
) && todo
)
2022 if (strcmp(winetest_platform
, "wine")) dump
++;
2023 ok_( file
, line
) (FALSE
,
2024 "%s: %u: in msg 0x%04x expecting wParam 0x%lx got 0x%lx\n",
2025 context
, count
, expected
->message
, expected
->wParam
, actual
->wParam
);
2030 ok_( file
, line
)( ((expected
->wParam
^ actual
->wParam
) & ~expected
->wp_mask
) == 0,
2031 "%s: %u: in msg 0x%04x expecting wParam 0x%lx got 0x%lx\n",
2032 context
, count
, expected
->message
, expected
->wParam
, actual
->wParam
);
2033 if ((expected
->wParam
^ actual
->wParam
) & ~expected
->wp_mask
) dump
++;
2037 if (expected
->flags
& lparam
)
2039 if (((expected
->lParam
^ actual
->lParam
) & ~expected
->lp_mask
) && todo
)
2043 if (strcmp(winetest_platform
, "wine")) dump
++;
2044 ok_( file
, line
) (FALSE
,
2045 "%s: %u: in msg 0x%04x expecting lParam 0x%lx got 0x%lx\n",
2046 context
, count
, expected
->message
, expected
->lParam
, actual
->lParam
);
2051 ok_( file
, line
)(((expected
->lParam
^ actual
->lParam
) & ~expected
->lp_mask
) == 0,
2052 "%s: %u: in msg 0x%04x expecting lParam 0x%lx got 0x%lx\n",
2053 context
, count
, expected
->message
, expected
->lParam
, actual
->lParam
);
2054 if ((expected
->lParam
^ actual
->lParam
) & ~expected
->lp_mask
) dump
++;
2057 if ((expected
->flags
& optional
) &&
2058 ((expected
->flags
^ actual
->flags
) & (defwinproc
|parent
)))
2060 /* don't match optional messages if their defwinproc or parent status differs */
2065 if ((expected
->flags
& defwinproc
) != (actual
->flags
& defwinproc
) && todo
)
2069 if (strcmp(winetest_platform
, "wine")) dump
++;
2070 ok_( file
, line
) (FALSE
,
2071 "%s: %u: the msg 0x%04x should %shave been sent by DefWindowProc\n",
2072 context
, count
, expected
->message
, (expected
->flags
& defwinproc
) ? "" : "NOT ");
2077 ok_( file
, line
) ((expected
->flags
& defwinproc
) == (actual
->flags
& defwinproc
),
2078 "%s: %u: the msg 0x%04x should %shave been sent by DefWindowProc\n",
2079 context
, count
, expected
->message
, (expected
->flags
& defwinproc
) ? "" : "NOT ");
2080 if ((expected
->flags
& defwinproc
) != (actual
->flags
& defwinproc
)) dump
++;
2083 ok_( file
, line
) ((expected
->flags
& beginpaint
) == (actual
->flags
& beginpaint
),
2084 "%s: %u: the msg 0x%04x should %shave been sent by BeginPaint\n",
2085 context
, count
, expected
->message
, (expected
->flags
& beginpaint
) ? "" : "NOT ");
2086 if ((expected
->flags
& beginpaint
) != (actual
->flags
& beginpaint
)) dump
++;
2088 ok_( file
, line
) ((expected
->flags
& (sent
|posted
)) == (actual
->flags
& (sent
|posted
)),
2089 "%s: %u: the msg 0x%04x should have been %s\n",
2090 context
, count
, expected
->message
, (expected
->flags
& posted
) ? "posted" : "sent");
2091 if ((expected
->flags
& (sent
|posted
)) != (actual
->flags
& (sent
|posted
))) dump
++;
2093 ok_( file
, line
) ((expected
->flags
& parent
) == (actual
->flags
& parent
),
2094 "%s: %u: the msg 0x%04x was expected in %s\n",
2095 context
, count
, expected
->message
, (expected
->flags
& parent
) ? "parent" : "child");
2096 if ((expected
->flags
& parent
) != (actual
->flags
& parent
)) dump
++;
2098 ok_( file
, line
) ((expected
->flags
& hook
) == (actual
->flags
& hook
),
2099 "%s: %u: the msg 0x%04x should have been sent by a hook\n",
2100 context
, count
, expected
->message
);
2101 if ((expected
->flags
& hook
) != (actual
->flags
& hook
)) dump
++;
2103 ok_( file
, line
) ((expected
->flags
& winevent_hook
) == (actual
->flags
& winevent_hook
),
2104 "%s: %u: the msg 0x%04x should have been sent by a winevent hook\n",
2105 context
, count
, expected
->message
);
2106 if ((expected
->flags
& winevent_hook
) != (actual
->flags
& winevent_hook
)) dump
++;
2111 /* silently drop hook messages if there is no support for them */
2112 else if ((expected
->flags
& optional
) ||
2113 ((expected
->flags
& hook
) && !hCBT_hook
) ||
2114 ((expected
->flags
& winevent_hook
) && !hEvent_hook
))
2120 if (strcmp(winetest_platform
, "wine")) dump
++;
2121 ok_( file
, line
) (FALSE
, "%s: %u: the msg 0x%04x was expected, but got msg 0x%04x instead\n",
2122 context
, count
, expected
->message
, actual
->message
);
2128 ok_( file
, line
) (FALSE
, "%s: %u: the msg 0x%04x was expected, but got msg 0x%04x instead\n",
2129 context
, count
, expected
->message
, actual
->message
);
2137 /* skip all optional trailing messages */
2138 while (expected
->message
&& ((expected
->flags
& optional
) ||
2139 ((expected
->flags
& hook
) && !hCBT_hook
) ||
2140 ((expected
->flags
& winevent_hook
) && !hEvent_hook
)))
2146 if (expected
->message
|| actual
->message
) {
2148 if (strcmp(winetest_platform
, "wine")) dump
++;
2149 ok_( file
, line
) (FALSE
, "%s: %u: the msg sequence is not complete: expected %04x - actual %04x\n",
2150 context
, count
, expected
->message
, actual
->message
);
2156 if (expected
->message
|| actual
->message
)
2159 ok_( file
, line
) (FALSE
, "%s: %u: the msg sequence is not complete: expected %04x - actual %04x\n",
2160 context
, count
, expected
->message
, actual
->message
);
2163 if( todo
&& !failcount
) /* succeeded yet marked todo */
2165 if (!strcmp(winetest_platform
, "wine")) dump
++;
2166 ok_( file
, line
)( TRUE
, "%s: marked \"todo_wine\" but succeeds\n", context
);
2170 if (dump
) dump_sequence(expected_list
, context
, file
, line
);
2174 #define expect(EXPECTED,GOT) ok((GOT)==(EXPECTED), "Expected %d, got %d\n", (EXPECTED), (GOT))
2176 /******************************** MDI test **********************************/
2178 /* CreateWindow for MDI frame window, initially visible */
2179 static const struct message WmCreateMDIframeSeq
[] = {
2180 { HCBT_CREATEWND
, hook
},
2181 { WM_GETMINMAXINFO
, sent
},
2182 { WM_NCCREATE
, sent
},
2183 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
2184 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
2185 { WM_CREATE
, sent
},
2186 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2187 { WM_NOTIFYFORMAT
, sent
|optional
},
2188 { WM_QUERYUISTATE
, sent
|optional
},
2189 { WM_WINDOWPOSCHANGING
, sent
|optional
},
2190 { WM_GETMINMAXINFO
, sent
|optional
},
2191 { WM_NCCALCSIZE
, sent
|optional
},
2192 { WM_WINDOWPOSCHANGED
, sent
|optional
},
2193 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
2194 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
2195 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2196 { HCBT_ACTIVATE
, hook
},
2197 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
2198 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
2199 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* XP */
2200 { WM_ACTIVATEAPP
, sent
|wparam
|optional
, 1 }, /* Win9x doesn't send it */
2201 { WM_NCACTIVATE
, sent
},
2202 { WM_GETTEXT
, sent
|defwinproc
|optional
},
2203 { WM_ACTIVATE
, sent
|wparam
, 1 },
2204 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* Win9x */
2205 { HCBT_SETFOCUS
, hook
},
2206 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
2207 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
2208 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2209 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
2210 /* Win9x adds SWP_NOZORDER below */
2211 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2212 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 }, /* XP */
2213 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2214 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2218 /* DestroyWindow for MDI frame window, initially visible */
2219 static const struct message WmDestroyMDIframeSeq
[] = {
2220 { HCBT_DESTROYWND
, hook
},
2221 { 0x0090, sent
|optional
},
2222 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2223 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2224 { WM_NCACTIVATE
, sent
|wparam
|optional
, 0 }, /* Win9x */
2225 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2226 { WM_NCACTIVATE
, sent
|wparam
|optional
, 0 }, /* XP */
2227 { WM_ACTIVATE
, sent
|wparam
|optional
, 0 }, /* Win9x */
2228 { WM_ACTIVATEAPP
, sent
|wparam
|optional
, 0 }, /* Win9x */
2229 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
2230 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
2231 { WM_DESTROY
, sent
},
2232 { WM_NCDESTROY
, sent
},
2235 /* CreateWindow for MDI client window, initially visible */
2236 static const struct message WmCreateMDIclientSeq
[] = {
2237 { HCBT_CREATEWND
, hook
},
2238 { WM_NCCREATE
, sent
},
2239 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
2240 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 },
2241 { WM_CREATE
, sent
},
2242 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 },
2243 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2244 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2246 { WM_PARENTNOTIFY
, sent
|wparam
, WM_CREATE
}, /* in MDI frame */
2247 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
2248 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2249 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2250 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2253 /* ShowWindow(SW_SHOW) for MDI client window */
2254 static const struct message WmShowMDIclientSeq
[] = {
2255 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
2256 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2257 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2258 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2261 /* ShowWindow(SW_HIDE) for MDI client window */
2262 static const struct message WmHideMDIclientSeq
[] = {
2263 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
2264 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2265 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* win2000 */
2266 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* XP */
2267 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2270 /* DestroyWindow for MDI client window, initially visible */
2271 static const struct message WmDestroyMDIclientSeq
[] = {
2272 { HCBT_DESTROYWND
, hook
},
2273 { 0x0090, sent
|optional
},
2274 { WM_PARENTNOTIFY
, sent
|wparam
, WM_DESTROY
}, /* in MDI frame */
2275 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
2276 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2277 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2278 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2279 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
2280 { WM_DESTROY
, sent
},
2281 { WM_NCDESTROY
, sent
},
2284 /* CreateWindow for MDI child window, initially visible */
2285 static const struct message WmCreateMDIchildVisibleSeq
[] = {
2286 { HCBT_CREATEWND
, hook
},
2287 { WM_NCCREATE
, sent
},
2288 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
2289 { WM_CREATE
, sent
},
2290 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2291 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2293 /* Win2k sends wparam set to
2294 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2295 * while Win9x doesn't bother to set child window id according to
2296 * CLIENTCREATESTRUCT.idFirstChild
2298 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
2299 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
2300 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2301 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2302 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2303 { WM_MDIREFRESHMENU
, sent
/*|wparam|lparam, 0, 0*/ },
2304 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
2305 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2306 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2308 /* Win9x: message sequence terminates here. */
2310 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 },
2311 { HCBT_SETFOCUS
, hook
}, /* in MDI client */
2312 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2313 { WM_IME_NOTIFY
, sent
|wparam
|optional
, 2 }, /* in MDI client */
2314 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2315 { WM_SETFOCUS
, sent
}, /* in MDI client */
2316 { HCBT_SETFOCUS
, hook
},
2317 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2318 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2319 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
2320 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2321 { WM_SETFOCUS
, sent
|defwinproc
},
2322 { WM_MDIACTIVATE
, sent
|defwinproc
},
2325 /* CreateWindow for MDI child window with invisible parent */
2326 static const struct message WmCreateMDIchildInvisibleParentSeq
[] = {
2327 { HCBT_CREATEWND
, hook
},
2328 { WM_GETMINMAXINFO
, sent
},
2329 { WM_NCCREATE
, sent
},
2330 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
2331 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 },
2332 { WM_CREATE
, sent
},
2333 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2334 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2336 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
2337 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
2338 { WM_MDIREFRESHMENU
, sent
}, /* in MDI client */
2339 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
2340 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2341 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2343 /* Win9x: message sequence terminates here. */
2345 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 },
2346 { HCBT_SETFOCUS
, hook
}, /* in MDI client */
2347 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2348 { WM_IME_NOTIFY
, sent
|wparam
|optional
, 2 }, /* in MDI client */
2349 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2350 { WM_SETFOCUS
, sent
}, /* in MDI client */
2351 { HCBT_SETFOCUS
, hook
},
2352 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2353 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2354 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
2355 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2356 { WM_SETFOCUS
, sent
|defwinproc
},
2357 { WM_MDIACTIVATE
, sent
|defwinproc
},
2360 /* DestroyWindow for MDI child window, initially visible */
2361 static const struct message WmDestroyMDIchildVisibleSeq
[] = {
2362 { HCBT_DESTROYWND
, hook
},
2363 /* Win2k sends wparam set to
2364 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
2365 * while Win9x doesn't bother to set child window id according to
2366 * CLIENTCREATESTRUCT.idFirstChild
2368 { 0x0090, sent
|optional
},
2369 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_DESTROY*/ }, /* in MDI client */
2370 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
2371 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2372 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2373 { WM_ERASEBKGND
, sent
|parent
|optional
},
2374 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2376 /* { WM_DESTROY, sent }
2377 * Win9x: message sequence terminates here.
2380 { HCBT_SETFOCUS
, hook
}, /* set focus to MDI client */
2381 { WM_KILLFOCUS
, sent
},
2382 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
2383 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2384 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2385 { WM_SETFOCUS
, sent
}, /* in MDI client */
2387 { HCBT_SETFOCUS
, hook
}, /* MDI client sets focus back to MDI child */
2388 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2389 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2390 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
2391 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2392 { WM_SETFOCUS
, sent
}, /* in MDI client */
2394 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
2396 { HCBT_SETFOCUS
, hook
}, /* set focus to MDI client */
2397 { WM_KILLFOCUS
, sent
},
2398 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
2399 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2400 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2401 { WM_SETFOCUS
, sent
}, /* in MDI client */
2403 { HCBT_SETFOCUS
, hook
}, /* MDI client sets focus back to MDI child */
2404 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2405 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2406 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
2407 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2408 { WM_SETFOCUS
, sent
}, /* in MDI client */
2410 { WM_DESTROY
, sent
},
2412 { HCBT_SETFOCUS
, hook
}, /* set focus to MDI client */
2413 { WM_KILLFOCUS
, sent
},
2414 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
2415 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2416 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2417 { WM_SETFOCUS
, sent
}, /* in MDI client */
2419 { HCBT_SETFOCUS
, hook
}, /* MDI client sets focus back to MDI child */
2420 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2421 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2422 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
2423 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2424 { WM_SETFOCUS
, sent
}, /* in MDI client */
2426 { WM_NCDESTROY
, sent
},
2429 /* CreateWindow for MDI child window, initially invisible */
2430 static const struct message WmCreateMDIchildInvisibleSeq
[] = {
2431 { HCBT_CREATEWND
, hook
},
2432 { WM_NCCREATE
, sent
},
2433 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
2434 { WM_CREATE
, sent
},
2435 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2436 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2438 /* Win2k sends wparam set to
2439 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2440 * while Win9x doesn't bother to set child window id according to
2441 * CLIENTCREATESTRUCT.idFirstChild
2443 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
2446 /* DestroyWindow for MDI child window, initially invisible */
2447 static const struct message WmDestroyMDIchildInvisibleSeq
[] = {
2448 { HCBT_DESTROYWND
, hook
},
2449 /* Win2k sends wparam set to
2450 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
2451 * while Win9x doesn't bother to set child window id according to
2452 * CLIENTCREATESTRUCT.idFirstChild
2454 { 0x0090, sent
|optional
},
2455 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_DESTROY*/ }, /* in MDI client */
2456 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
2457 { WM_DESTROY
, sent
},
2458 { WM_NCDESTROY
, sent
},
2459 /* FIXME: Wine destroys an icon/title window while Windows doesn't */
2460 { WM_PARENTNOTIFY
, sent
|wparam
|optional
, WM_DESTROY
}, /* MDI client */
2463 /* CreateWindow for the 1st MDI child window, initially visible and maximized */
2464 static const struct message WmCreateMDIchildVisibleMaxSeq1
[] = {
2465 { HCBT_CREATEWND
, hook
},
2466 { WM_NCCREATE
, sent
},
2467 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
2468 { WM_CREATE
, sent
},
2469 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2470 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2472 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
2473 { WM_GETMINMAXINFO
, sent
},
2474 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_STATECHANGED
},
2475 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2476 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
2477 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2479 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2480 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2481 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2482 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2483 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2484 /* Win2k sends wparam set to
2485 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2486 * while Win9x doesn't bother to set child window id according to
2487 * CLIENTCREATESTRUCT.idFirstChild
2489 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
2490 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
2491 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2492 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2493 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2494 { WM_MDIREFRESHMENU
, sent
/*|wparam|lparam, 0, 0*/ },
2495 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
2496 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2497 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
|optional
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
, 0, SWP_FRAMECHANGED
},
2499 /* Win9x: message sequence terminates here. */
2501 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
|optional
, 1 },
2502 { HCBT_SETFOCUS
, hook
|optional
}, /* in MDI client */
2503 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2504 { WM_IME_NOTIFY
, sent
|wparam
|optional
, 2 }, /* in MDI client */
2505 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2506 { WM_SETFOCUS
, sent
|optional
}, /* in MDI client */
2507 { HCBT_SETFOCUS
, hook
|optional
},
2508 { WM_KILLFOCUS
, sent
|optional
}, /* in MDI client */
2509 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2510 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
2511 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2512 { WM_SETFOCUS
, sent
|defwinproc
|optional
},
2513 { WM_MDIACTIVATE
, sent
|defwinproc
|optional
},
2515 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2516 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2517 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2518 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2521 /* CreateWindow for the 2nd MDI child window, initially visible and maximized */
2522 static const struct message WmCreateMDIchildVisibleMaxSeq2
[] = {
2523 /* restore the 1st MDI child */
2524 { WM_SETREDRAW
, sent
|wparam
, 0 },
2525 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWNORMAL
},
2526 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
2527 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2528 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2529 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
2530 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2532 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2533 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2534 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2535 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2536 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2537 { WM_SETREDRAW
, sent
|wparam
, 1 }, /* in the 1st MDI child */
2538 /* create the 2nd MDI child */
2539 { HCBT_CREATEWND
, hook
},
2540 { WM_NCCREATE
, sent
},
2541 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
2542 { WM_CREATE
, sent
},
2543 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2544 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2546 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
2547 { WM_GETMINMAXINFO
, sent
},
2548 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_STATECHANGED
},
2549 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2550 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2551 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
2552 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2554 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2555 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2556 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2557 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2558 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2559 /* Win2k sends wparam set to
2560 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2561 * while Win9x doesn't bother to set child window id according to
2562 * CLIENTCREATESTRUCT.idFirstChild
2564 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
2565 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
2566 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2567 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2568 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2569 { WM_MDIREFRESHMENU
, sent
/*|wparam|lparam, 0, 0*/ },
2570 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
2571 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2573 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 0 }, /* in the 1st MDI child */
2574 { WM_MDIACTIVATE
, sent
|defwinproc
}, /* in the 1st MDI child */
2576 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2578 /* Win9x: message sequence terminates here. */
2580 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 },
2581 { HCBT_SETFOCUS
, hook
},
2582 { WM_KILLFOCUS
, sent
|defwinproc
|optional
}, /* in the 1st MDI child */
2583 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 0 }, /* in the 1st MDI child */
2584 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2585 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2586 { WM_SETFOCUS
, sent
}, /* in MDI client */
2587 { HCBT_SETFOCUS
, hook
},
2588 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2589 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2590 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
2591 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2592 { WM_SETFOCUS
, sent
|defwinproc
},
2594 { WM_MDIACTIVATE
, sent
|defwinproc
},
2596 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2597 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2598 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2599 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2602 /* WM_MDICREATE MDI child window, initially visible and maximized */
2603 static const struct message WmCreateMDIchildVisibleMaxSeq3
[] = {
2604 { WM_MDICREATE
, sent
},
2605 { HCBT_CREATEWND
, hook
},
2606 { WM_NCCREATE
, sent
},
2607 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
2608 { WM_CREATE
, sent
},
2609 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2610 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2612 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
2613 { WM_GETMINMAXINFO
, sent
},
2614 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_STATECHANGED
},
2615 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2616 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
2617 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2620 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2621 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2622 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2623 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2624 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2626 /* Win2k sends wparam set to
2627 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2628 * while Win9x doesn't bother to set child window id according to
2629 * CLIENTCREATESTRUCT.idFirstChild
2631 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
2632 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
2633 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2635 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2637 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2638 { WM_MDIREFRESHMENU
, sent
/*|wparam|lparam, 0, 0*/ },
2639 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
2641 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2642 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2644 /* Win9x: message sequence terminates here. */
2646 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 },
2647 { WM_SETFOCUS
, sent
|optional
}, /* in MDI client */
2648 { HCBT_SETFOCUS
, hook
}, /* in MDI client */
2649 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2650 { WM_IME_NOTIFY
, sent
|wparam
|optional
, 2 },
2651 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
|optional
, OBJID_CLIENT
, 0 },
2652 { WM_SETFOCUS
, sent
|optional
}, /* in MDI client */
2653 { HCBT_SETFOCUS
, hook
|optional
},
2654 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2655 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2656 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
2657 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2658 { WM_SETFOCUS
, sent
|defwinproc
},
2660 { WM_MDIACTIVATE
, sent
|defwinproc
},
2663 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2664 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2665 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2666 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2669 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2670 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2671 { 0x0093, sent
|defwinproc
|optional
},
2672 { 0x0093, sent
|defwinproc
|optional
},
2673 { 0x0093, sent
|defwinproc
|optional
},
2674 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2675 { WM_MOVE
, sent
|defwinproc
},
2676 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2679 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
2680 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2681 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
},
2682 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2685 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
2686 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2687 { 0x0093, sent
|optional
},
2688 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
},
2689 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2691 { 0x0093, sent
|optional
},
2692 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2693 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI client */
2694 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 }, /* XP sends it to MDI frame */
2695 { 0x0093, sent
|defwinproc
|optional
},
2696 { 0x0093, sent
|defwinproc
|optional
},
2697 { 0x0093, sent
|defwinproc
|optional
},
2698 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2699 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* XP sends a duplicate */
2703 /* CreateWindow for the 1st MDI child window, initially invisible and maximized */
2704 static const struct message WmCreateMDIchildInvisibleMaxSeq4
[] = {
2705 { HCBT_CREATEWND
, hook
},
2706 { WM_GETMINMAXINFO
, sent
},
2707 { WM_NCCREATE
, sent
},
2708 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
2709 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
2710 { WM_CREATE
, sent
},
2711 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2712 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2713 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
, 0, SWP_NOZORDER
}, /* MDI frame */
2714 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 }, /* MDI frame */
2715 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
, 0, SWP_NOZORDER
}, /* MDI frame */
2717 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
2718 { WM_GETMINMAXINFO
, sent
},
2719 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_STATECHANGED
},
2720 { WM_GETMINMAXINFO
, sent
|defwinproc
},
2721 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2722 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_STATECHANGED
},
2723 { WM_MOVE
, sent
|defwinproc
},
2724 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2726 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2727 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2728 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2729 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2730 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 }, /* MDI child */
2731 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2732 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2733 /* Win2k sends wparam set to
2734 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2735 * while Win9x doesn't bother to set child window id according to
2736 * CLIENTCREATESTRUCT.idFirstChild
2738 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
2741 /* WM_SYSCOMMAND/SC_CLOSE for the 2nd MDI child window, initially visible and maximized */
2742 static const struct message WmDestroyMDIchildVisibleMaxSeq2
[] = {
2743 { WM_SYSCOMMAND
, sent
|wparam
, SC_CLOSE
},
2744 { HCBT_SYSCOMMAND
, hook
},
2745 { WM_CLOSE
, sent
|defwinproc
},
2746 { WM_MDIDESTROY
, sent
}, /* in MDI client */
2748 /* bring the 1st MDI child to top */
2749 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOSIZE
|SWP_NOMOVE
}, /* in the 1st MDI child */
2750 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
}, /* in the 2nd MDI child */
2752 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2754 { WM_CHILDACTIVATE
, sent
|defwinproc
|wparam
|lparam
, 0, 0 }, /* in the 1st MDI child */
2755 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 0 }, /* in the 1st MDI child */
2756 { WM_MDIACTIVATE
, sent
|defwinproc
}, /* in the 1st MDI child */
2758 /* maximize the 1st MDI child */
2759 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
2760 { WM_GETMINMAXINFO
, sent
|defwinproc
},
2761 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
2762 { WM_NCCALCSIZE
, sent
|defwinproc
|wparam
, 1 },
2763 { WM_CHILDACTIVATE
, sent
|defwinproc
|wparam
|lparam
, 0, 0 },
2764 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
2765 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2767 /* restore the 2nd MDI child */
2768 { WM_SETREDRAW
, sent
|defwinproc
|wparam
, 0 },
2769 { HCBT_MINMAX
, hook
|lparam
, 0, SW_NORMALNA
},
2770 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_SHOWWINDOW
|SWP_STATECHANGED
},
2771 { WM_NCCALCSIZE
, sent
|defwinproc
|wparam
, 1 },
2773 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2775 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
2776 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2778 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2780 { WM_SETREDRAW
, sent
|defwinproc
|wparam
, 1 },
2782 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2783 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2784 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2785 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2786 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2788 /* bring the 1st MDI child to top */
2789 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2790 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 },
2791 { HCBT_SETFOCUS
, hook
},
2792 { WM_KILLFOCUS
, sent
|defwinproc
},
2793 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 0 },
2794 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2795 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2796 { WM_SETFOCUS
, sent
}, /* in MDI client */
2797 { HCBT_SETFOCUS
, hook
},
2798 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2799 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2800 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
2801 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2802 { WM_SETFOCUS
, sent
|defwinproc
},
2803 { WM_MDIACTIVATE
, sent
|defwinproc
},
2804 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2806 /* apparently ShowWindow(SW_SHOW) on an MDI client */
2807 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
2808 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2809 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2810 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2811 { WM_MDIREFRESHMENU
, sent
},
2813 { HCBT_DESTROYWND
, hook
},
2814 /* Win2k sends wparam set to
2815 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
2816 * while Win9x doesn't bother to set child window id according to
2817 * CLIENTCREATESTRUCT.idFirstChild
2819 { 0x0090, sent
|defwinproc
|optional
},
2820 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_DESTROY*/ }, /* in MDI client */
2821 { WM_SHOWWINDOW
, sent
|defwinproc
|wparam
, 0 },
2822 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2823 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2824 { WM_ERASEBKGND
, sent
|parent
|optional
},
2825 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2827 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
2828 { WM_DESTROY
, sent
|defwinproc
},
2829 { WM_NCDESTROY
, sent
|defwinproc
},
2832 /* WM_MDIDESTROY for the single MDI child window, initially visible and maximized */
2833 static const struct message WmDestroyMDIchildVisibleMaxSeq1
[] = {
2834 { WM_MDIDESTROY
, sent
}, /* in MDI client */
2835 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
2836 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2837 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2838 { WM_ERASEBKGND
, sent
|parent
|optional
},
2839 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2841 { HCBT_SETFOCUS
, hook
},
2842 { WM_KILLFOCUS
, sent
},
2843 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
2844 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2845 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2846 { WM_SETFOCUS
, sent
}, /* in MDI client */
2847 { HCBT_SETFOCUS
, hook
},
2848 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2849 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2850 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
2851 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2852 { WM_SETFOCUS
, sent
},
2855 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2856 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2857 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2858 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2861 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2862 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2863 { 0x0093, sent
|defwinproc
|optional
},
2864 { 0x0093, sent
|defwinproc
|optional
},
2865 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2866 { WM_MOVE
, sent
|defwinproc
},
2867 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2870 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
2871 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2872 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
},
2873 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2876 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
2877 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2878 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
},
2879 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2882 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2883 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 },
2884 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2885 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2888 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2889 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 },
2890 { 0x0093, sent
|defwinproc
|optional
},
2891 { 0x0093, sent
|defwinproc
|optional
},
2892 { 0x0093, sent
|defwinproc
|optional
},
2893 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2894 { WM_MOVE
, sent
|defwinproc
},
2895 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2898 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
2899 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2900 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
},
2901 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2904 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
},
2905 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 },
2906 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
},
2907 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2908 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2909 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI client */
2911 { 0x0093, sent
|defwinproc
|optional
},
2912 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
|optional
, 1 }, /* XP sends it to MDI frame */
2913 { 0x0093, sent
|defwinproc
|optional
},
2914 { 0x0093, sent
|defwinproc
|optional
},
2915 { 0x0093, sent
|defwinproc
|optional
},
2916 { 0x0093, sent
|optional
},
2918 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2919 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2920 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI client */
2921 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2922 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* XP sends a duplicate */
2925 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2926 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
2927 { 0x0093, sent
|defwinproc
|optional
},
2928 { 0x0093, sent
|defwinproc
|optional
},
2929 { 0x0093, sent
|defwinproc
|optional
},
2930 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2931 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2932 { 0x0093, sent
|optional
},
2934 { WM_NCACTIVATE
, sent
|wparam
, 0 },
2935 { WM_MDIACTIVATE
, sent
},
2937 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWNORMAL
},
2938 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_SHOWWINDOW
|SWP_STATECHANGED
},
2939 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2941 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2943 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2944 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_SHOWWINDOW
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
2945 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2948 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2949 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 },
2950 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2951 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2954 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2955 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2956 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2957 { WM_MOVE
, sent
|defwinproc
},
2958 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2961 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
2962 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2963 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
},
2964 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2965 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2966 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 }, /* XP */
2967 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI client */
2968 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2969 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* XP sends a duplicate */
2971 { HCBT_SETFOCUS
, hook
},
2972 { WM_KILLFOCUS
, sent
},
2973 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
2974 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2975 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2976 { WM_SETFOCUS
, sent
}, /* in MDI client */
2978 { WM_MDIREFRESHMENU
, sent
}, /* in MDI client */
2980 { HCBT_DESTROYWND
, hook
},
2981 /* Win2k sends wparam set to
2982 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
2983 * while Win9x doesn't bother to set child window id according to
2984 * CLIENTCREATESTRUCT.idFirstChild
2986 { 0x0090, sent
|optional
},
2987 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_DESTROY*/ }, /* in MDI client */
2989 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
2990 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2991 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2992 { WM_ERASEBKGND
, sent
|parent
|optional
},
2993 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2995 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
2996 { WM_DESTROY
, sent
},
2997 { WM_NCDESTROY
, sent
},
3000 /* ShowWindow(SW_MAXIMIZE) for a not visible MDI child window */
3001 static const struct message WmMaximizeMDIchildInvisibleSeq
[] = {
3002 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
3003 { WM_GETMINMAXINFO
, sent
},
3004 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_STATECHANGED
},
3005 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3006 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
3007 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
3009 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
3010 { WM_NCACTIVATE
, sent
|wparam
|optional
|defwinproc
, 1 },
3011 { HCBT_SETFOCUS
, hook
|optional
},
3012 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
3013 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
3014 { WM_SETFOCUS
, sent
|optional
}, /* in MDI client */
3015 { HCBT_SETFOCUS
, hook
|optional
},
3016 { WM_KILLFOCUS
, sent
|optional
}, /* in MDI client */
3017 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
3018 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
3019 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
3020 { WM_SETFOCUS
, sent
|optional
|defwinproc
},
3021 { WM_MDIACTIVATE
, sent
|optional
|defwinproc
},
3022 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
3023 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
3025 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
3026 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3027 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
3028 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
3029 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
3032 /* ShowWindow(SW_MAXIMIZE) for a not visible maximized MDI child window */
3033 static const struct message WmMaximizeMDIchildInvisibleSeq2
[] = {
3034 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
3035 { WM_GETMINMAXINFO
, sent
},
3036 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
},
3037 { WM_GETMINMAXINFO
, sent
|defwinproc
},
3038 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3039 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
3040 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
3042 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
|optional
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
3043 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
|optional
, 1 },
3044 { HCBT_SETFOCUS
, hook
|optional
},
3045 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
3046 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
3047 { WM_SETFOCUS
, sent
|optional
}, /* in MDI client */
3048 { HCBT_SETFOCUS
, hook
|optional
},
3049 { WM_KILLFOCUS
, sent
|optional
}, /* in MDI client */
3050 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
3051 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
3052 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
3053 { WM_SETFOCUS
, sent
|defwinproc
|optional
},
3054 { WM_MDIACTIVATE
, sent
|defwinproc
|optional
},
3055 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
3056 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
3059 /* WM_MDIMAXIMIZE for an MDI child window with invisible parent */
3060 static const struct message WmMaximizeMDIchildInvisibleParentSeq
[] = {
3061 { WM_MDIMAXIMIZE
, sent
}, /* in MDI client */
3062 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
3063 { WM_GETMINMAXINFO
, sent
},
3064 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
3065 { WM_GETMINMAXINFO
, sent
|defwinproc
},
3066 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3067 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* XP doesn't send it */
3068 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
3069 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOREDRAW
|SWP_STATECHANGED
},
3070 { WM_MOVE
, sent
|defwinproc
},
3071 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
3073 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
3074 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 },
3075 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
3076 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
|optional
, 1 },
3077 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI child XP */
3078 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI client XP */
3080 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
3081 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3082 { 0x0093, sent
|defwinproc
|optional
},
3083 { 0x0094, sent
|defwinproc
|optional
},
3084 { 0x0094, sent
|defwinproc
|optional
},
3085 { 0x0094, sent
|defwinproc
|optional
},
3086 { 0x0094, sent
|defwinproc
|optional
},
3087 { 0x0093, sent
|defwinproc
|optional
},
3088 { 0x0093, sent
|defwinproc
|optional
},
3089 { 0x0091, sent
|defwinproc
|optional
},
3090 { 0x0092, sent
|defwinproc
|optional
},
3091 { 0x0092, sent
|defwinproc
|optional
},
3092 { 0x0092, sent
|defwinproc
|optional
},
3093 { 0x0092, sent
|defwinproc
|optional
},
3094 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
3095 { WM_MOVE
, sent
|defwinproc
},
3096 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
3097 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI frame win2000 */
3099 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
3100 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3101 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
},
3102 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
3104 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
},
3105 { WM_GETMINMAXINFO
, sent
|defwinproc
},
3106 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 },
3107 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
},
3108 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
3109 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI child win2000 */
3110 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
|optional
, 1 },
3111 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI child XP */
3112 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI child XP */
3113 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI client XP */
3115 { 0x0093, sent
|optional
},
3116 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
3117 { 0x0093, sent
|defwinproc
|optional
},
3118 { 0x0093, sent
|defwinproc
|optional
},
3119 { 0x0093, sent
|defwinproc
|optional
},
3120 { 0x0091, sent
|defwinproc
|optional
},
3121 { 0x0092, sent
|defwinproc
|optional
},
3122 { 0x0092, sent
|defwinproc
|optional
},
3123 { 0x0092, sent
|defwinproc
|optional
},
3124 { 0x0092, sent
|defwinproc
|optional
},
3125 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI frame XP */
3126 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI frame XP */
3127 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI child XP */
3130 /* ShowWindow(SW_MAXIMIZE) for a visible MDI child window */
3131 static const struct message WmMaximizeMDIchildVisibleSeq
[] = {
3132 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
3133 { WM_GETMINMAXINFO
, sent
},
3134 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
3135 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3136 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
3137 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
3138 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
3140 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
3141 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3142 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
3143 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
3144 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
3147 /* ShowWindow(SW_RESTORE) for a visible maximized MDI child window */
3148 static const struct message WmRestoreMDIchildVisibleSeq
[] = {
3149 { HCBT_MINMAX
, hook
|lparam
, 0, SW_RESTORE
},
3150 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
3151 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3152 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
3153 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
3154 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
3156 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
3157 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3158 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
3159 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
3160 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
3163 /* ShowWindow(SW_RESTORE) for a visible minimized MDI child window */
3164 static const struct message WmRestoreMDIchildVisibleSeq_2
[] = {
3165 { HCBT_MINMAX
, hook
|lparam
, 0, SW_RESTORE
},
3166 { WM_QUERYOPEN
, sent
|wparam
|lparam
, 0, 0 },
3167 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
3168 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3169 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
3170 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_NOCLIENTSIZE
|SWP_STATECHANGED
},
3171 { WM_MOVE
, sent
|defwinproc
},
3172 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
3173 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
3174 { EVENT_SYSTEM_MINIMIZEEND
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
3175 { HCBT_SETFOCUS
, hook
},
3176 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
3177 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
3178 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
3179 { WM_SETFOCUS
, sent
},
3182 /* ShowWindow(SW_MINIMIZE) for a visible restored MDI child window */
3183 static const struct message WmMinimizeMDIchildVisibleSeq
[] = {
3184 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
3185 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
3186 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3187 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOCOPYBITS
|SWP_NOCLIENTSIZE
|SWP_STATECHANGED
},
3188 { WM_MOVE
, sent
|defwinproc
},
3189 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MINIMIZED
},
3190 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
|defwinproc
, 0, 0 },
3191 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
3192 { EVENT_SYSTEM_MINIMIZESTART
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
3193 /* FIXME: Wine creates an icon/title window while Windows doesn't */
3194 { WM_PARENTNOTIFY
, sent
|parent
|wparam
|optional
, WM_CREATE
}, /* MDI client */
3197 /* ShowWindow(SW_RESTORE) for a not visible MDI child window */
3198 static const struct message WmRestoreMDIchildInisibleSeq
[] = {
3199 { HCBT_MINMAX
, hook
|lparam
, 0, SW_RESTORE
},
3200 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_STATECHANGED
},
3201 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3202 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
3203 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
3204 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
3205 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
3207 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
3208 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3209 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
3210 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
3211 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
3215 static HWND mdi_client
;
3216 static WNDPROC old_mdi_client_proc
;
3218 static LRESULT WINAPI
mdi_client_hook_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
3220 struct recvd_message msg
;
3222 /* do not log painting messages */
3223 if (message
!= WM_PAINT
&&
3224 message
!= WM_NCPAINT
&&
3225 message
!= WM_SYNCPAINT
&&
3226 message
!= WM_ERASEBKGND
&&
3227 message
!= WM_NCHITTEST
&&
3228 message
!= WM_GETTEXT
&&
3229 message
!= WM_MDIGETACTIVE
&&
3230 !ignore_message( message
))
3233 msg
.message
= message
;
3234 msg
.flags
= sent
|wparam
|lparam
;
3235 msg
.wParam
= wParam
;
3236 msg
.lParam
= lParam
;
3237 msg
.descr
= "mdi client";
3241 return CallWindowProcA(old_mdi_client_proc
, hwnd
, message
, wParam
, lParam
);
3244 static LRESULT WINAPI
mdi_child_wnd_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
3246 static LONG defwndproc_counter
= 0;
3248 struct recvd_message msg
;
3250 /* do not log painting messages */
3251 if (message
!= WM_PAINT
&&
3252 message
!= WM_NCPAINT
&&
3253 message
!= WM_SYNCPAINT
&&
3254 message
!= WM_ERASEBKGND
&&
3255 message
!= WM_NCHITTEST
&&
3256 message
!= WM_GETTEXT
&&
3257 !ignore_message( message
))
3261 case WM_MDIACTIVATE
:
3263 HWND active
, client
= GetParent(hwnd
);
3265 active
= (HWND
)SendMessageA(client
, WM_MDIGETACTIVE
, 0, 0);
3267 if (hwnd
== (HWND
)lParam
) /* if we are being activated */
3268 ok (active
== (HWND
)lParam
, "new active %p != active %p\n", (HWND
)lParam
, active
);
3270 ok (active
== (HWND
)wParam
, "old active %p != active %p\n", (HWND
)wParam
, active
);
3276 msg
.message
= message
;
3277 msg
.flags
= sent
|wparam
|lparam
;
3278 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
3279 msg
.wParam
= wParam
;
3280 msg
.lParam
= lParam
;
3281 msg
.descr
= "mdi child";
3285 defwndproc_counter
++;
3286 ret
= DefMDIChildProcA(hwnd
, message
, wParam
, lParam
);
3287 defwndproc_counter
--;
3292 static LRESULT WINAPI
mdi_frame_wnd_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
3294 static LONG defwndproc_counter
= 0;
3296 struct recvd_message msg
;
3298 /* do not log painting messages */
3299 if (message
!= WM_PAINT
&&
3300 message
!= WM_NCPAINT
&&
3301 message
!= WM_SYNCPAINT
&&
3302 message
!= WM_ERASEBKGND
&&
3303 message
!= WM_NCHITTEST
&&
3304 message
!= WM_GETTEXT
&&
3305 !ignore_message( message
))
3308 msg
.message
= message
;
3309 msg
.flags
= sent
|wparam
|lparam
;
3310 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
3311 msg
.wParam
= wParam
;
3312 msg
.lParam
= lParam
;
3313 msg
.descr
= "mdi frame";
3317 defwndproc_counter
++;
3318 ret
= DefFrameProcA(hwnd
, mdi_client
, message
, wParam
, lParam
);
3319 defwndproc_counter
--;
3324 static BOOL
mdi_RegisterWindowClasses(void)
3329 cls
.lpfnWndProc
= mdi_frame_wnd_proc
;
3332 cls
.hInstance
= GetModuleHandleA(0);
3334 cls
.hCursor
= LoadCursorA(0, IDC_ARROW
);
3335 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
3336 cls
.lpszMenuName
= NULL
;
3337 cls
.lpszClassName
= "MDI_frame_class";
3338 if (!RegisterClassA(&cls
)) return FALSE
;
3340 cls
.lpfnWndProc
= mdi_child_wnd_proc
;
3341 cls
.lpszClassName
= "MDI_child_class";
3342 if (!RegisterClassA(&cls
)) return FALSE
;
3344 if (!GetClassInfoA(0, "MDIClient", &cls
)) assert(0);
3345 old_mdi_client_proc
= cls
.lpfnWndProc
;
3346 cls
.hInstance
= GetModuleHandleA(0);
3347 cls
.lpfnWndProc
= mdi_client_hook_proc
;
3348 cls
.lpszClassName
= "MDI_client_class";
3349 if (!RegisterClassA(&cls
)) assert(0);
3354 static void test_mdi_messages(void)
3356 MDICREATESTRUCTA mdi_cs
;
3357 CLIENTCREATESTRUCT client_cs
;
3358 HWND mdi_frame
, mdi_child
, mdi_child2
, active_child
;
3360 HMENU hMenu
= CreateMenu();
3362 assert(mdi_RegisterWindowClasses());
3366 trace("creating MDI frame window\n");
3367 mdi_frame
= CreateWindowExA(0, "MDI_frame_class", "MDI frame window",
3368 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
|
3369 WS_MAXIMIZEBOX
| WS_VISIBLE
,
3370 100, 100, CW_USEDEFAULT
, CW_USEDEFAULT
,
3371 GetDesktopWindow(), hMenu
,
3372 GetModuleHandleA(0), NULL
);
3374 ok_sequence(WmCreateMDIframeSeq
, "Create MDI frame window", FALSE
);
3376 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3377 ok(GetFocus() == mdi_frame
, "wrong focus window %p\n", GetFocus());
3379 trace("creating MDI client window\n");
3380 client_cs
.hWindowMenu
= 0;
3381 client_cs
.idFirstChild
= MDI_FIRST_CHILD_ID
;
3382 mdi_client
= CreateWindowExA(0, "MDI_client_class",
3384 WS_CHILD
| WS_VISIBLE
| MDIS_ALLCHILDSTYLES
,
3386 mdi_frame
, 0, GetModuleHandleA(0), &client_cs
);
3388 ok_sequence(WmCreateMDIclientSeq
, "Create visible MDI client window", FALSE
);
3390 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3391 ok(GetFocus() == mdi_frame
, "input focus should be on MDI frame not on %p\n", GetFocus());
3393 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3394 ok(!active_child
, "wrong active MDI child %p\n", active_child
);
3395 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
3400 trace("creating invisible MDI child window\n");
3401 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3403 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
3404 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3408 ShowWindow(mdi_child
, SW_SHOWNORMAL
);
3409 ok_sequence(WmShowChildSeq
, "ShowWindow(SW_SHOWNORMAL) MDI child window", FALSE
);
3411 ok(GetWindowLongA(mdi_child
, GWL_STYLE
) & WS_VISIBLE
, "MDI child should be visible\n");
3412 ok(IsWindowVisible(mdi_child
), "MDI child should be visible\n");
3414 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3415 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3417 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3418 ok(!active_child
, "wrong active MDI child %p\n", active_child
);
3419 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
3421 ShowWindow(mdi_child
, SW_HIDE
);
3422 ok_sequence(WmHideChildSeq
, "ShowWindow(SW_HIDE) MDI child window", FALSE
);
3425 ShowWindow(mdi_child
, SW_SHOW
);
3426 ok_sequence(WmShowChildSeq
, "ShowWindow(SW_SHOW) MDI child window", FALSE
);
3428 ok(GetWindowLongA(mdi_child
, GWL_STYLE
) & WS_VISIBLE
, "MDI child should be visible\n");
3429 ok(IsWindowVisible(mdi_child
), "MDI child should be visible\n");
3431 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3432 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3434 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3435 ok(!active_child
, "wrong active MDI child %p\n", active_child
);
3436 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
3438 DestroyWindow(mdi_child
);
3441 trace("creating visible MDI child window\n");
3442 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3443 WS_CHILD
| WS_VISIBLE
,
3444 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
3445 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3447 ok_sequence(WmCreateMDIchildVisibleSeq
, "Create visible 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() == mdi_child
, "wrong focus window %p\n", GetFocus());
3455 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3456 ok(active_child
== mdi_child
, "wrong active MDI child %p\n", active_child
);
3457 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
3460 DestroyWindow(mdi_child
);
3461 ok_sequence(WmDestroyMDIchildVisibleSeq
, "Destroy visible MDI child window", TRUE
);
3463 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3464 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3466 /* Win2k: MDI client still returns a just destroyed child as active
3467 * Win9x: MDI client returns 0
3469 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3470 ok(active_child
== mdi_child
|| /* win2k */
3471 !active_child
, /* win9x */
3472 "wrong active MDI child %p\n", active_child
);
3473 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
3477 trace("creating invisible MDI child window\n");
3478 mdi_child2
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3480 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
3481 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3483 ok_sequence(WmCreateMDIchildInvisibleSeq
, "Create invisible MDI child window", FALSE
);
3485 ok(!(GetWindowLongA(mdi_child2
, GWL_STYLE
) & WS_VISIBLE
), "MDI child should not be visible\n");
3486 ok(!IsWindowVisible(mdi_child2
), "MDI child should not be visible\n");
3488 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3489 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3491 /* Win2k: MDI client still returns a just destroyed child as active
3492 * Win9x: MDI client returns mdi_child2
3494 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3495 ok(active_child
== mdi_child
|| /* win2k */
3496 active_child
== mdi_child2
, /* win9x */
3497 "wrong active MDI child %p\n", active_child
);
3498 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
3501 ShowWindow(mdi_child2
, SW_MAXIMIZE
);
3502 ok_sequence(WmMaximizeMDIchildInvisibleSeq
, "ShowWindow(SW_MAXIMIZE):invisible MDI child", FALSE
);
3504 ok(GetWindowLongA(mdi_child2
, GWL_STYLE
) & WS_VISIBLE
, "MDI child should be visible\n");
3505 ok(IsWindowVisible(mdi_child2
), "MDI child should be visible\n");
3507 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3508 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
3509 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
3512 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3513 ok(GetFocus() == mdi_child2
|| /* win2k */
3514 GetFocus() == 0, /* win9x */
3515 "wrong focus window %p\n", GetFocus());
3520 ShowWindow(mdi_child2
, SW_HIDE
);
3521 ok_sequence(WmHideChildSeq
, "ShowWindow(SW_HIDE):MDI child", FALSE
);
3523 ShowWindow(mdi_child2
, SW_RESTORE
);
3524 ok_sequence(WmRestoreMDIchildInisibleSeq
, "ShowWindow(SW_RESTORE):invisible MDI child", FALSE
);
3527 ok(GetWindowLongA(mdi_child2
, GWL_STYLE
) & WS_VISIBLE
, "MDI child should be visible\n");
3528 ok(IsWindowVisible(mdi_child2
), "MDI child should be visible\n");
3530 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3531 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
3532 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
3538 ShowWindow(mdi_child2
, SW_HIDE
);
3539 ok_sequence(WmHideChildSeq
, "ShowWindow(SW_HIDE):MDI child", FALSE
);
3541 ShowWindow(mdi_child2
, SW_SHOW
);
3542 ok_sequence(WmShowChildSeq
, "ShowWindow(SW_SHOW):MDI child", FALSE
);
3544 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3545 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3547 ShowWindow(mdi_child2
, SW_MAXIMIZE
);
3548 ok_sequence(WmMaximizeMDIchildVisibleSeq
, "ShowWindow(SW_MAXIMIZE):MDI child", FALSE
);
3550 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3551 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3553 ShowWindow(mdi_child2
, SW_RESTORE
);
3554 ok_sequence(WmRestoreMDIchildVisibleSeq
, "ShowWindow(SW_RESTORE):maximized MDI child", FALSE
);
3556 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3557 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3559 ShowWindow(mdi_child2
, SW_MINIMIZE
);
3560 ok_sequence(WmMinimizeMDIchildVisibleSeq
, "ShowWindow(SW_MINIMIZE):MDI child", TRUE
);
3562 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3563 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3565 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3566 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
3567 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
3570 ShowWindow(mdi_child2
, SW_RESTORE
);
3571 ok_sequence(WmRestoreMDIchildVisibleSeq_2
, "ShowWindow(SW_RESTORE):minimized MDI child", TRUE
);
3573 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3574 ok(GetFocus() == mdi_child2
, "wrong focus window %p\n", GetFocus());
3576 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3577 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
3578 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
3584 ShowWindow(mdi_child2
, SW_HIDE
);
3585 ok_sequence(WmHideChildSeq
, "ShowWindow(SW_HIDE):MDI child", FALSE
);
3587 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3588 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3590 DestroyWindow(mdi_child2
);
3591 ok_sequence(WmDestroyMDIchildInvisibleSeq
, "Destroy invisible MDI child window", FALSE
);
3593 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3594 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3596 /* test for maximized MDI children */
3597 trace("creating maximized visible MDI child window 1\n");
3598 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3599 WS_CHILD
| WS_VISIBLE
| WS_MAXIMIZEBOX
| WS_MAXIMIZE
,
3600 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
3601 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3603 ok_sequence(WmCreateMDIchildVisibleMaxSeq1
, "Create maximized visible 1st MDI child window", TRUE
);
3604 ok(IsZoomed(mdi_child
), "1st MDI child should be maximized\n");
3606 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3607 ok(GetFocus() == mdi_child
|| /* win2k */
3608 GetFocus() == 0, /* win9x */
3609 "wrong focus window %p\n", GetFocus());
3611 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3612 ok(active_child
== mdi_child
, "wrong active MDI child %p\n", active_child
);
3613 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
3616 trace("creating maximized visible MDI child window 2\n");
3617 mdi_child2
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3618 WS_CHILD
| WS_VISIBLE
| WS_MAXIMIZEBOX
| WS_MAXIMIZE
,
3619 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
3620 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3622 ok_sequence(WmCreateMDIchildVisibleMaxSeq2
, "Create maximized visible 2nd MDI child 2 window", TRUE
);
3623 ok(IsZoomed(mdi_child2
), "2nd MDI child should be maximized\n");
3624 ok(!IsZoomed(mdi_child
), "1st MDI child should NOT be maximized\n");
3626 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3627 ok(GetFocus() == mdi_child2
, "wrong focus window %p\n", GetFocus());
3629 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3630 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
3631 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
3634 trace("destroying maximized visible MDI child window 2\n");
3635 DestroyWindow(mdi_child2
);
3636 ok_sequence(WmDestroyMDIchildVisibleSeq
, "Destroy visible MDI child window", TRUE
);
3638 ok(!IsZoomed(mdi_child
), "1st MDI child should NOT be maximized\n");
3640 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3641 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3643 /* Win2k: MDI client still returns a just destroyed child as active
3644 * Win9x: MDI client returns 0
3646 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3647 ok(active_child
== mdi_child2
|| /* win2k */
3648 !active_child
, /* win9x */
3649 "wrong active MDI child %p\n", active_child
);
3652 ShowWindow(mdi_child
, SW_MAXIMIZE
);
3653 ok(IsZoomed(mdi_child
), "1st MDI child should be maximized\n");
3656 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3657 ok(GetFocus() == mdi_child
, "wrong focus window %p\n", GetFocus());
3659 trace("re-creating maximized visible MDI child window 2\n");
3660 mdi_child2
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3661 WS_CHILD
| WS_VISIBLE
| WS_MAXIMIZEBOX
| WS_MAXIMIZE
,
3662 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
3663 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3665 ok_sequence(WmCreateMDIchildVisibleMaxSeq2
, "Create maximized visible 2nd MDI child 2 window", TRUE
);
3666 ok(IsZoomed(mdi_child2
), "2nd MDI child should be maximized\n");
3667 ok(!IsZoomed(mdi_child
), "1st MDI child should NOT be maximized\n");
3669 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3670 ok(GetFocus() == mdi_child2
, "wrong focus window %p\n", GetFocus());
3672 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3673 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
3674 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
3677 SendMessageA(mdi_child2
, WM_SYSCOMMAND
, SC_CLOSE
, 0);
3678 ok_sequence(WmDestroyMDIchildVisibleMaxSeq2
, "WM_SYSCOMMAND/SC_CLOSE on a visible maximized MDI child window", TRUE
);
3679 ok(!IsWindow(mdi_child2
), "MDI child 2 should be destroyed\n");
3681 ok(IsZoomed(mdi_child
), "1st MDI child should be maximized\n");
3682 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3683 ok(GetFocus() == mdi_child
, "wrong focus window %p\n", GetFocus());
3685 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3686 ok(active_child
== mdi_child
, "wrong active MDI child %p\n", active_child
);
3687 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
3690 DestroyWindow(mdi_child
);
3691 ok_sequence(WmDestroyMDIchildVisibleSeq
, "Destroy visible MDI child window", TRUE
);
3693 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3694 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3696 /* Win2k: MDI client still returns a just destroyed child as active
3697 * Win9x: MDI client returns 0
3699 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3700 ok(active_child
== mdi_child
|| /* win2k */
3701 !active_child
, /* win9x */
3702 "wrong active MDI child %p\n", active_child
);
3705 trace("creating maximized invisible MDI child window\n");
3706 mdi_child2
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3707 WS_CHILD
| WS_MAXIMIZE
| WS_CAPTION
| WS_THICKFRAME
,
3708 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
3709 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3711 ok_sequence(WmCreateMDIchildInvisibleMaxSeq4
, "Create maximized invisible MDI child window", FALSE
);
3712 ok(IsZoomed(mdi_child2
), "MDI child should be maximized\n");
3713 ok(!(GetWindowLongA(mdi_child2
, GWL_STYLE
) & WS_VISIBLE
), "MDI child should be not visible\n");
3714 ok(!IsWindowVisible(mdi_child2
), "MDI child should be not visible\n");
3716 /* Win2k: MDI client still returns a just destroyed child as active
3717 * Win9x: MDI client returns 0
3719 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3720 ok(active_child
== mdi_child
|| /* win2k */
3721 !active_child
|| active_child
== mdi_child2
, /* win9x */
3722 "wrong active MDI child %p\n", active_child
);
3725 trace("call ShowWindow(mdi_child, SW_MAXIMIZE)\n");
3726 ShowWindow(mdi_child2
, SW_MAXIMIZE
);
3727 ok_sequence(WmMaximizeMDIchildInvisibleSeq2
, "ShowWindow(SW_MAXIMIZE):invisible maximized MDI child", FALSE
);
3728 ok(IsZoomed(mdi_child2
), "MDI child should be maximized\n");
3729 ok(GetWindowLongA(mdi_child2
, GWL_STYLE
) & WS_VISIBLE
, "MDI child should be visible\n");
3730 ok(IsWindowVisible(mdi_child2
), "MDI child should be visible\n");
3732 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3733 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
3734 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
3737 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child2
, 0);
3740 /* end of test for maximized MDI children */
3743 trace("creating maximized visible MDI child window 1(Switch test)\n");
3744 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3745 WS_CHILD
| WS_VISIBLE
| WS_MAXIMIZEBOX
| WS_MAXIMIZE
,
3746 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
3747 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3749 ok_sequence(WmCreateMDIchildVisibleMaxSeq1
, "Create maximized visible 1st MDI child window(Switch test)", TRUE
);
3750 ok(IsZoomed(mdi_child
), "1st MDI child should be maximized(Switch test)\n");
3752 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p(Switch test)\n", GetActiveWindow());
3753 ok(GetFocus() == mdi_child
|| /* win2k */
3754 GetFocus() == 0, /* win9x */
3755 "wrong focus window %p(Switch test)\n", GetFocus());
3757 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3758 ok(active_child
== mdi_child
, "wrong active MDI child %p(Switch test)\n", active_child
);
3759 ok(zoomed
, "wrong zoomed state %d(Switch test)\n", zoomed
);
3762 trace("creating maximized visible MDI child window 2(Switch test)\n");
3763 mdi_child2
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3764 WS_CHILD
| WS_VISIBLE
| WS_MAXIMIZEBOX
| WS_MAXIMIZE
,
3765 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
3766 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3768 ok_sequence(WmCreateMDIchildVisibleMaxSeq2
, "Create maximized visible 2nd MDI child window (Switch test)", TRUE
);
3770 ok(IsZoomed(mdi_child2
), "2nd MDI child should be maximized(Switch test)\n");
3771 ok(!IsZoomed(mdi_child
), "1st MDI child should NOT be maximized(Switch test)\n");
3773 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p(Switch test)\n", GetActiveWindow());
3774 ok(GetFocus() == mdi_child2
, "wrong focus window %p(Switch test)\n", GetFocus());
3776 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3777 ok(active_child
== mdi_child2
, "wrong active MDI child %p(Switch test)\n", active_child
);
3778 ok(zoomed
, "wrong zoomed state %d(Switch test)\n", zoomed
);
3781 trace("Switch child window.\n");
3782 SendMessageA(mdi_client
, WM_MDIACTIVATE
, (WPARAM
)mdi_child
, 0);
3783 ok_sequence(WmSwitchChild
, "Child did not switch correctly", TRUE
);
3784 trace("end of test for switch maximized MDI children\n");
3787 /* Prepare for switching test of not maximized MDI children */
3788 ShowWindow( mdi_child
, SW_NORMAL
);
3789 ok(!IsZoomed(mdi_child
), "wrong zoomed state for %p(Switch test)\n", mdi_child
);
3790 ok(!IsZoomed(mdi_child2
), "wrong zoomed state for %p(Switch test)\n", mdi_child2
);
3791 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, 0);
3792 ok(active_child
== mdi_child
, "wrong active MDI child %p(Switch test)\n", active_child
);
3795 SendMessageA(mdi_client
, WM_MDIACTIVATE
, (WPARAM
)mdi_child2
, 0);
3796 ok_sequence(WmSwitchNotMaximizedChild
, "Not maximized child did not switch correctly", FALSE
);
3797 trace("end of test for switch not maximized MDI children\n");
3800 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
3803 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child2
, 0);
3808 /* end of tests for switch maximized/not maximized MDI children */
3810 mdi_cs
.szClass
= "MDI_child_Class";
3811 mdi_cs
.szTitle
= "MDI child";
3812 mdi_cs
.hOwner
= GetModuleHandleA(0);
3815 mdi_cs
.cx
= CW_USEDEFAULT
;
3816 mdi_cs
.cy
= CW_USEDEFAULT
;
3817 mdi_cs
.style
= WS_CHILD
| WS_SYSMENU
| WS_VISIBLE
| WS_MAXIMIZEBOX
| WS_MAXIMIZE
;
3819 mdi_child
= (HWND
)SendMessageA(mdi_client
, WM_MDICREATE
, 0, (LPARAM
)&mdi_cs
);
3820 ok(mdi_child
!= 0, "MDI child creation failed\n");
3821 ok_sequence(WmCreateMDIchildVisibleMaxSeq3
, "WM_MDICREATE for maximized visible MDI child window", TRUE
);
3823 ok(GetMenuItemID(hMenu
, GetMenuItemCount(hMenu
) - 1) == SC_CLOSE
, "SC_CLOSE menu item not found\n");
3825 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3826 ok(active_child
== mdi_child
, "wrong active MDI child %p\n", active_child
);
3828 ok(IsZoomed(mdi_child
), "MDI child should be maximized\n");
3829 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3830 ok(GetFocus() == mdi_child
, "wrong focus window %p\n", GetFocus());
3832 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3833 ok(active_child
== mdi_child
, "wrong active MDI child %p\n", active_child
);
3834 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
3837 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
3838 ok_sequence(WmDestroyMDIchildVisibleMaxSeq1
, "Destroy visible maximized MDI child window", TRUE
);
3840 ok(!IsWindow(mdi_child
), "MDI child should be destroyed\n");
3841 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3842 ok(!active_child
, "wrong active MDI child %p\n", active_child
);
3847 DestroyWindow(mdi_client
);
3848 ok_sequence(WmDestroyMDIclientSeq
, "Destroy MDI client window", FALSE
);
3850 /* test maximization of MDI child with invisible parent */
3851 client_cs
.hWindowMenu
= 0;
3852 mdi_client
= CreateWindow("MDI_client_class",
3854 WS_CHILD
| WS_CLIPCHILDREN
| WS_VSCROLL
| WS_HSCROLL
| WS_VISIBLE
,
3856 mdi_frame
, 0, GetModuleHandleA(0), &client_cs
);
3857 ok_sequence(WmCreateMDIclientSeq
, "Create MDI client window", FALSE
);
3859 ShowWindow(mdi_client
, SW_HIDE
);
3860 ok_sequence(WmHideMDIclientSeq
, "Hide MDI client window", FALSE
);
3862 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3863 WS_CHILD
| WS_CLIPCHILDREN
| WS_VSCROLL
| WS_HSCROLL
,
3865 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3866 ok_sequence(WmCreateMDIchildInvisibleParentSeq
, "Create MDI child window with invisible parent", FALSE
);
3868 SendMessage(mdi_client
, WM_MDIMAXIMIZE
, (WPARAM
) mdi_child
, 0);
3869 ok_sequence(WmMaximizeMDIchildInvisibleParentSeq
, "Maximize MDI child window with invisible parent", TRUE
);
3870 zoomed
= IsZoomed(mdi_child
);
3871 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
3873 ShowWindow(mdi_client
, SW_SHOW
);
3874 ok_sequence(WmShowMDIclientSeq
, "Show MDI client window", FALSE
);
3876 DestroyWindow(mdi_child
);
3877 ok_sequence(WmDestroyMDIchildVisibleSeq
, "Destroy visible maximized MDI child window", TRUE
);
3879 /* end of test for maximization of MDI child with invisible parent */
3881 DestroyWindow(mdi_client
);
3882 ok_sequence(WmDestroyMDIclientSeq
, "Destroy MDI client window", FALSE
);
3884 DestroyWindow(mdi_frame
);
3885 ok_sequence(WmDestroyMDIframeSeq
, "Destroy MDI frame window", FALSE
);
3887 /************************* End of MDI test **********************************/
3889 static void test_WM_SETREDRAW(HWND hwnd
)
3891 DWORD style
= GetWindowLongA(hwnd
, GWL_STYLE
);
3896 SendMessageA(hwnd
, WM_SETREDRAW
, FALSE
, 0);
3897 ok_sequence(WmSetRedrawFalseSeq
, "SetRedraw:FALSE", FALSE
);
3899 ok(!(GetWindowLongA(hwnd
, GWL_STYLE
) & WS_VISIBLE
), "WS_VISIBLE should NOT be set\n");
3900 ok(!IsWindowVisible(hwnd
), "IsWindowVisible() should return FALSE\n");
3903 SendMessageA(hwnd
, WM_SETREDRAW
, TRUE
, 0);
3904 ok_sequence(WmSetRedrawTrueSeq
, "SetRedraw:TRUE", FALSE
);
3906 ok(GetWindowLongA(hwnd
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
3907 ok(IsWindowVisible(hwnd
), "IsWindowVisible() should return TRUE\n");
3909 /* restore original WS_VISIBLE state */
3910 SetWindowLongA(hwnd
, GWL_STYLE
, style
);
3916 static INT_PTR CALLBACK
TestModalDlgProcA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
3918 struct recvd_message msg
;
3920 if (ignore_message( message
)) return 0;
3926 case WM_NCMOUSEMOVE
:
3927 case WM_NCMOUSELEAVE
:
3935 msg
.message
= message
;
3936 msg
.flags
= sent
|wparam
|lparam
;
3937 msg
.wParam
= wParam
;
3938 msg
.lParam
= lParam
;
3939 msg
.descr
= "dialog";
3942 if (message
== WM_INITDIALOG
) SetTimer( hwnd
, 1, 100, NULL
);
3943 if (message
== WM_TIMER
) EndDialog( hwnd
, 0 );
3947 static void test_hv_scroll_1(HWND hwnd
, INT ctl
, DWORD clear
, DWORD set
, INT min
, INT max
)
3949 DWORD style
, exstyle
;
3953 exstyle
= GetWindowLongA(hwnd
, GWL_EXSTYLE
);
3954 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
3955 /* do not be confused by WS_DLGFRAME set */
3956 if ((style
& WS_CAPTION
) == WS_CAPTION
) style
&= ~WS_CAPTION
;
3958 if (clear
) ok(style
& clear
, "style %08x should be set\n", clear
);
3959 if (set
) ok(!(style
& set
), "style %08x should not be set\n", set
);
3961 ret
= SetScrollRange(hwnd
, ctl
, min
, max
, FALSE
);
3962 ok( ret
, "SetScrollRange(%d) error %d\n", ctl
, GetLastError());
3963 if ((style
& (WS_DLGFRAME
| WS_BORDER
| WS_THICKFRAME
)) || (exstyle
& WS_EX_DLGMODALFRAME
))
3964 ok_sequence(WmSetScrollRangeHV_NC_Seq
, "SetScrollRange(SB_HORZ/SB_VERT) NC", FALSE
);
3966 ok_sequence(WmSetScrollRangeHVSeq
, "SetScrollRange(SB_HORZ/SB_VERT)", FALSE
);
3968 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
3969 if (set
) ok(style
& set
, "style %08x should be set\n", set
);
3970 if (clear
) ok(!(style
& clear
), "style %08x should not be set\n", clear
);
3972 /* a subsequent call should do nothing */
3973 ret
= SetScrollRange(hwnd
, ctl
, min
, max
, FALSE
);
3974 ok( ret
, "SetScrollRange(%d) error %d\n", ctl
, GetLastError());
3975 ok_sequence(WmEmptySeq
, "SetScrollRange(SB_HORZ/SB_VERT) empty sequence", FALSE
);
3979 ret
= GetScrollRange(hwnd
, ctl
, &xmin
, &xmax
);
3980 ok( ret
, "GetScrollRange(%d) error %d\n", ctl
, GetLastError());
3981 ok_sequence(WmEmptySeq
, "GetScrollRange(SB_HORZ/SB_VERT) empty sequence", FALSE
);
3982 ok(xmin
== min
, "unexpected min scroll value %d\n", xmin
);
3983 ok(xmax
== max
, "unexpected max scroll value %d\n", xmax
);
3986 static void test_hv_scroll_2(HWND hwnd
, INT ctl
, DWORD clear
, DWORD set
, INT min
, INT max
)
3988 DWORD style
, exstyle
;
3992 exstyle
= GetWindowLongA(hwnd
, GWL_EXSTYLE
);
3993 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
3994 /* do not be confused by WS_DLGFRAME set */
3995 if ((style
& WS_CAPTION
) == WS_CAPTION
) style
&= ~WS_CAPTION
;
3997 if (clear
) ok(style
& clear
, "style %08x should be set\n", clear
);
3998 if (set
) ok(!(style
& set
), "style %08x should not be set\n", set
);
4000 si
.cbSize
= sizeof(si
);
4001 si
.fMask
= SIF_RANGE
;
4004 SetScrollInfo(hwnd
, ctl
, &si
, TRUE
);
4005 if ((style
& (WS_DLGFRAME
| WS_BORDER
| WS_THICKFRAME
)) || (exstyle
& WS_EX_DLGMODALFRAME
))
4006 ok_sequence(WmSetScrollRangeHV_NC_Seq
, "SetScrollInfo(SB_HORZ/SB_VERT) NC", FALSE
);
4008 ok_sequence(WmSetScrollRangeHVSeq
, "SetScrollInfo(SB_HORZ/SB_VERT)", FALSE
);
4010 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
4011 if (set
) ok(style
& set
, "style %08x should be set\n", set
);
4012 if (clear
) ok(!(style
& clear
), "style %08x should not be set\n", clear
);
4014 /* a subsequent call should do nothing */
4015 SetScrollInfo(hwnd
, ctl
, &si
, TRUE
);
4016 if (style
& WS_HSCROLL
)
4017 ok_sequence(WmSetScrollRangeHSeq_empty
, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE
);
4018 else if (style
& WS_VSCROLL
)
4019 ok_sequence(WmSetScrollRangeVSeq_empty
, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE
);
4021 ok_sequence(WmEmptySeq
, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE
);
4023 si
.fMask
= SIF_PAGE
;
4025 SetScrollInfo(hwnd
, ctl
, &si
, FALSE
);
4026 ok_sequence(WmEmptySeq
, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE
);
4030 SetScrollInfo(hwnd
, ctl
, &si
, FALSE
);
4031 ok_sequence(WmEmptySeq
, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE
);
4033 si
.fMask
= SIF_RANGE
;
4034 si
.nMin
= 0xdeadbeef;
4035 si
.nMax
= 0xdeadbeef;
4036 ret
= GetScrollInfo(hwnd
, ctl
, &si
);
4037 ok( ret
, "GetScrollInfo error %d\n", GetLastError());
4038 ok_sequence(WmEmptySeq
, "GetScrollRange(SB_HORZ/SB_VERT) empty sequence", FALSE
);
4039 ok(si
.nMin
== min
, "unexpected min scroll value %d\n", si
.nMin
);
4040 ok(si
.nMax
== max
, "unexpected max scroll value %d\n", si
.nMax
);
4043 /* Win9x sends WM_USER+xxx while and NT versions send SBM_xxx messages */
4044 static void test_scroll_messages(HWND hwnd
)
4055 ret
= GetScrollRange(hwnd
, SB_CTL
, &min
, &max
);
4056 ok( ret
, "GetScrollRange error %d\n", GetLastError());
4057 if (sequence
->message
!= WmGetScrollRangeSeq
[0].message
)
4058 trace("GetScrollRange(SB_CTL) generated unknown message %04x\n", sequence
->message
);
4059 /* values of min and max are undefined */
4062 ret
= SetScrollRange(hwnd
, SB_CTL
, 10, 150, FALSE
);
4063 ok( ret
, "SetScrollRange error %d\n", GetLastError());
4064 if (sequence
->message
!= WmSetScrollRangeSeq
[0].message
)
4065 trace("SetScrollRange(SB_CTL) generated unknown message %04x\n", sequence
->message
);
4070 ret
= GetScrollRange(hwnd
, SB_CTL
, &min
, &max
);
4071 ok( ret
, "GetScrollRange error %d\n", GetLastError());
4072 if (sequence
->message
!= WmGetScrollRangeSeq
[0].message
)
4073 trace("GetScrollRange(SB_CTL) generated unknown message %04x\n", sequence
->message
);
4074 /* values of min and max are undefined */
4077 si
.cbSize
= sizeof(si
);
4078 si
.fMask
= SIF_RANGE
;
4081 SetScrollInfo(hwnd
, SB_CTL
, &si
, FALSE
);
4082 if (sequence
->message
!= WmSetScrollRangeSeq
[0].message
)
4083 trace("SetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence
->message
);
4086 si
.fMask
= SIF_PAGE
;
4088 SetScrollInfo(hwnd
, SB_CTL
, &si
, FALSE
);
4089 if (sequence
->message
!= WmSetScrollRangeSeq
[0].message
)
4090 trace("SetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence
->message
);
4095 SetScrollInfo(hwnd
, SB_CTL
, &si
, FALSE
);
4096 if (sequence
->message
!= WmSetScrollRangeSeq
[0].message
)
4097 trace("SetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence
->message
);
4100 si
.fMask
= SIF_RANGE
;
4101 si
.nMin
= 0xdeadbeef;
4102 si
.nMax
= 0xdeadbeef;
4103 ret
= GetScrollInfo(hwnd
, SB_CTL
, &si
);
4104 ok( ret
, "GetScrollInfo error %d\n", GetLastError());
4105 if (sequence
->message
!= WmGetScrollInfoSeq
[0].message
)
4106 trace("GetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence
->message
);
4107 /* values of min and max are undefined */
4110 /* set WS_HSCROLL */
4111 test_hv_scroll_1(hwnd
, SB_HORZ
, 0, WS_HSCROLL
, 10, 150);
4112 /* clear WS_HSCROLL */
4113 test_hv_scroll_1(hwnd
, SB_HORZ
, WS_HSCROLL
, 0, 0, 0);
4115 /* set WS_HSCROLL */
4116 test_hv_scroll_2(hwnd
, SB_HORZ
, 0, WS_HSCROLL
, 10, 150);
4117 /* clear WS_HSCROLL */
4118 test_hv_scroll_2(hwnd
, SB_HORZ
, WS_HSCROLL
, 0, 0, 0);
4120 /* set WS_VSCROLL */
4121 test_hv_scroll_1(hwnd
, SB_VERT
, 0, WS_VSCROLL
, 10, 150);
4122 /* clear WS_VSCROLL */
4123 test_hv_scroll_1(hwnd
, SB_VERT
, WS_VSCROLL
, 0, 0, 0);
4125 /* set WS_VSCROLL */
4126 test_hv_scroll_2(hwnd
, SB_VERT
, 0, WS_VSCROLL
, 10, 150);
4127 /* clear WS_VSCROLL */
4128 test_hv_scroll_2(hwnd
, SB_VERT
, WS_VSCROLL
, 0, 0, 0);
4131 static void test_showwindow(void)
4136 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW
,
4137 100, 100, 200, 200, 0, 0, 0, NULL
);
4138 ok (hwnd
!= 0, "Failed to create overlapped window\n");
4139 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
4140 0, 0, 10, 10, hwnd
, 0, 0, NULL
);
4141 ok (hchild
!= 0, "Failed to create child\n");
4144 /* ShowWindow( SW_SHOWNA) for invisible top level window */
4145 trace("calling ShowWindow( SW_SHOWNA) for invisible top level window\n");
4146 ok( ShowWindow(hwnd
, SW_SHOWNA
) == FALSE
, "ShowWindow: window was visible\n" );
4147 ok_sequence(WmSHOWNATopInvisible
, "ShowWindow(SW_SHOWNA) on invisible top level window", FALSE
);
4149 /* ShowWindow( SW_SHOWNA) for now visible top level window */
4150 trace("calling ShowWindow( SW_SHOWNA) for now visible top level window\n");
4151 ok( ShowWindow(hwnd
, SW_SHOWNA
) != FALSE
, "ShowWindow: window was invisible\n" );
4152 ok_sequence(WmSHOWNATopVisible
, "ShowWindow(SW_SHOWNA) on visible top level window", FALSE
);
4153 /* back to invisible */
4154 ShowWindow(hchild
, SW_HIDE
);
4155 ShowWindow(hwnd
, SW_HIDE
);
4157 /* ShowWindow(SW_SHOWNA) with child and parent invisible */
4158 trace("calling ShowWindow( SW_SHOWNA) for invisible child with invisible parent\n");
4159 ok( ShowWindow(hchild
, SW_SHOWNA
) == FALSE
, "ShowWindow: window was visible\n" );
4160 ok_sequence(WmSHOWNAChildInvisParInvis
, "ShowWindow(SW_SHOWNA) invisible child and parent", FALSE
);
4161 /* ShowWindow(SW_SHOWNA) with child visible and parent invisible */
4162 ok( ShowWindow(hchild
, SW_SHOW
) != FALSE
, "ShowWindow: window was invisible\n" );
4164 trace("calling ShowWindow( SW_SHOWNA) for the visible child and invisible parent\n");
4165 ok( ShowWindow(hchild
, SW_SHOWNA
) != FALSE
, "ShowWindow: window was invisible\n" );
4166 ok_sequence(WmSHOWNAChildVisParInvis
, "ShowWindow(SW_SHOWNA) visible child and invisible parent", FALSE
);
4167 /* ShowWindow(SW_SHOWNA) with child visible and parent visible */
4168 ShowWindow( hwnd
, SW_SHOW
);
4170 trace("calling ShowWindow( SW_SHOWNA) for the visible child and parent\n");
4171 ok( ShowWindow(hchild
, SW_SHOWNA
) != FALSE
, "ShowWindow: window was invisible\n" );
4172 ok_sequence(WmSHOWNAChildVisParVis
, "ShowWindow(SW_SHOWNA) for the visible child and parent", FALSE
);
4174 /* ShowWindow(SW_SHOWNA) with child invisible and parent visible */
4175 ShowWindow( hchild
, SW_HIDE
);
4177 trace("calling ShowWindow( SW_SHOWNA) for the invisible child and visible parent\n");
4178 ok( ShowWindow(hchild
, SW_SHOWNA
) == FALSE
, "ShowWindow: window was visible\n" );
4179 ok_sequence(WmSHOWNAChildInvisParVis
, "ShowWindow(SW_SHOWNA) for the invisible child and visible parent", FALSE
);
4182 ok(GetCapture() == hchild
, "wrong capture window %p\n", GetCapture());
4183 DestroyWindow(hchild
);
4184 ok(!GetCapture(), "wrong capture window %p\n", GetCapture());
4186 DestroyWindow(hwnd
);
4191 * 1. Create invisible maximized popup window.
4192 * 2. Move and resize it.
4193 * 3. Show it maximized.
4195 trace("calling CreateWindowExA( WS_MAXIMIZE ) for invisible maximized popup window\n");
4196 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP
| WS_MAXIMIZE
,
4197 100, 100, 200, 200, 0, 0, 0, NULL
);
4198 ok (hwnd
!= 0, "Failed to create popup window\n");
4199 ok(IsZoomed(hwnd
), "window should be maximized\n");
4200 ok_sequence(WmCreateInvisibleMaxPopupSeq
, "CreateWindow(WS_MAXIMIZED):popup", FALSE
);
4202 GetWindowRect(hwnd
, &rc
);
4203 ok( rc
.right
-rc
.left
== GetSystemMetrics(SM_CXSCREEN
) &&
4204 rc
.bottom
-rc
.top
== GetSystemMetrics(SM_CYSCREEN
),
4205 "Invalid maximized size before ShowWindow (%d,%d)-(%d,%d)\n",
4206 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4207 /* Reset window's size & position */
4208 SetWindowPos(hwnd
, 0, 10, 10, 200, 200, SWP_NOZORDER
| SWP_NOACTIVATE
);
4209 ok(IsZoomed(hwnd
), "window should be maximized\n");
4212 trace("calling ShowWindow( SW_SHOWMAXIMIZE ) for invisible maximized popup window\n");
4213 ShowWindow(hwnd
, SW_SHOWMAXIMIZED
);
4214 ok(IsZoomed(hwnd
), "window should be maximized\n");
4215 ok_sequence(WmShowMaxPopupResizedSeq
, "ShowWindow(SW_SHOWMAXIMIZED):invisible maximized and resized popup", FALSE
);
4217 GetWindowRect(hwnd
, &rc
);
4218 ok( rc
.right
-rc
.left
== GetSystemMetrics(SM_CXSCREEN
) &&
4219 rc
.bottom
-rc
.top
== GetSystemMetrics(SM_CYSCREEN
),
4220 "Invalid maximized size after ShowWindow (%d,%d)-(%d,%d)\n",
4221 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4222 DestroyWindow(hwnd
);
4226 * 1. Create invisible maximized popup window.
4227 * 2. Show it maximized.
4229 trace("calling CreateWindowExA( WS_MAXIMIZE ) for invisible maximized popup window\n");
4230 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP
| WS_MAXIMIZE
,
4231 100, 100, 200, 200, 0, 0, 0, NULL
);
4232 ok (hwnd
!= 0, "Failed to create popup window\n");
4233 ok(IsZoomed(hwnd
), "window should be maximized\n");
4234 ok_sequence(WmCreateInvisibleMaxPopupSeq
, "CreateWindow(WS_MAXIMIZED):popup", FALSE
);
4236 trace("calling ShowWindow( SW_SHOWMAXIMIZE ) for invisible maximized popup window\n");
4237 ShowWindow(hwnd
, SW_SHOWMAXIMIZED
);
4238 ok(IsZoomed(hwnd
), "window should be maximized\n");
4239 ok_sequence(WmShowMaxPopupSeq
, "ShowWindow(SW_SHOWMAXIMIZED):invisible maximized popup", FALSE
);
4240 DestroyWindow(hwnd
);
4244 * 1. Create visible maximized popup window.
4246 trace("calling CreateWindowExA( WS_MAXIMIZE ) for maximized popup window\n");
4247 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP
| WS_MAXIMIZE
| WS_VISIBLE
,
4248 100, 100, 200, 200, 0, 0, 0, NULL
);
4249 ok (hwnd
!= 0, "Failed to create popup window\n");
4250 ok(IsZoomed(hwnd
), "window should be maximized\n");
4251 ok_sequence(WmCreateMaxPopupSeq
, "CreateWindow(WS_MAXIMIZED):popup", FALSE
);
4252 DestroyWindow(hwnd
);
4256 * 1. Create visible popup window.
4259 trace("calling CreateWindowExA( WS_VISIBLE ) for popup window\n");
4260 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP
| WS_VISIBLE
,
4261 100, 100, 200, 200, 0, 0, 0, NULL
);
4262 ok (hwnd
!= 0, "Failed to create popup window\n");
4263 ok(!IsZoomed(hwnd
), "window should NOT be maximized\n");
4264 ok_sequence(WmCreatePopupSeq
, "CreateWindow(WS_VISIBLE):popup", FALSE
);
4266 trace("calling ShowWindow( SW_SHOWMAXIMIZE ) for visible popup window\n");
4267 ShowWindow(hwnd
, SW_SHOWMAXIMIZED
);
4268 ok(IsZoomed(hwnd
), "window should be maximized\n");
4269 ok_sequence(WmShowVisMaxPopupSeq
, "ShowWindow(SW_SHOWMAXIMIZED):popup", FALSE
);
4270 DestroyWindow(hwnd
);
4274 static void test_sys_menu(void)
4280 hwnd
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
4281 100, 100, 200, 200, 0, 0, 0, NULL
);
4282 ok (hwnd
!= 0, "Failed to create overlapped window\n");
4286 /* test existing window without CS_NOCLOSE style */
4287 hmenu
= GetSystemMenu(hwnd
, FALSE
);
4288 ok(hmenu
!= 0, "GetSystemMenu error %d\n", GetLastError());
4290 state
= GetMenuState(hmenu
, SC_CLOSE
, MF_BYCOMMAND
);
4291 ok(state
!= 0xffffffff, "wrong SC_CLOSE state %x\n", state
);
4292 ok(!(state
& (MF_DISABLED
| MF_GRAYED
)), "wrong SC_CLOSE state %x\n", state
);
4294 EnableMenuItem(hmenu
, SC_CLOSE
, MF_BYCOMMAND
| MF_GRAYED
);
4295 ok_sequence(WmEmptySeq
, "WmEnableMenuItem", FALSE
);
4297 state
= GetMenuState(hmenu
, SC_CLOSE
, MF_BYCOMMAND
);
4298 ok(state
!= 0xffffffff, "wrong SC_CLOSE state %x\n", state
);
4299 ok((state
& (MF_DISABLED
| MF_GRAYED
)) == MF_GRAYED
, "wrong SC_CLOSE state %x\n", state
);
4301 EnableMenuItem(hmenu
, SC_CLOSE
, 0);
4302 ok_sequence(WmEmptySeq
, "WmEnableMenuItem", FALSE
);
4304 state
= GetMenuState(hmenu
, SC_CLOSE
, MF_BYCOMMAND
);
4305 ok(state
!= 0xffffffff, "wrong SC_CLOSE state %x\n", state
);
4306 ok(!(state
& (MF_DISABLED
| MF_GRAYED
)), "wrong SC_CLOSE state %x\n", state
);
4308 /* test whether removing WS_SYSMENU destroys a system menu */
4309 SetWindowLongW(hwnd
, GWL_STYLE
, WS_POPUP
);
4310 SetWindowPos(hwnd
, 0, 0, 0, 0, 0, SWP_NOZORDER
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_FRAMECHANGED
);
4312 hmenu
= GetSystemMenu(hwnd
, FALSE
);
4313 ok(hmenu
!= 0, "GetSystemMenu error %d\n", GetLastError());
4315 DestroyWindow(hwnd
);
4317 /* test new window with CS_NOCLOSE style */
4318 hwnd
= CreateWindowExA(0, "NoCloseWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
4319 100, 100, 200, 200, 0, 0, 0, NULL
);
4320 ok (hwnd
!= 0, "Failed to create overlapped window\n");
4322 hmenu
= GetSystemMenu(hwnd
, FALSE
);
4323 ok(hmenu
!= 0, "GetSystemMenu error %d\n", GetLastError());
4325 state
= GetMenuState(hmenu
, SC_CLOSE
, MF_BYCOMMAND
);
4326 ok(state
== 0xffffffff, "wrong SC_CLOSE state %x\n", state
);
4328 DestroyWindow(hwnd
);
4330 /* test new window without WS_SYSMENU style */
4331 hwnd
= CreateWindowExA(0, "NoCloseWindowClass", NULL
, WS_OVERLAPPEDWINDOW
& ~WS_SYSMENU
,
4332 100, 100, 200, 200, 0, 0, 0, NULL
);
4333 ok(hwnd
!= 0, "Failed to create overlapped window\n");
4335 hmenu
= GetSystemMenu(hwnd
, FALSE
);
4336 ok(!hmenu
, "GetSystemMenu error %d\n", GetLastError());
4338 DestroyWindow(hwnd
);
4341 /* For shown WS_OVERLAPPEDWINDOW */
4342 static const struct message WmSetIcon_1
[] = {
4343 { WM_SETICON
, sent
},
4344 { 0x00AE, sent
|defwinproc
|optional
}, /* XP */
4345 { WM_GETTEXT
, sent
|defwinproc
|optional
},
4346 { WM_GETTEXT
, sent
|defwinproc
|optional
}, /* XP sends a duplicate */
4350 /* For WS_POPUP and hidden WS_OVERLAPPEDWINDOW */
4351 static const struct message WmSetIcon_2
[] = {
4352 { WM_SETICON
, sent
},
4356 /* Sending undocumented 0x3B message with wparam = 0x8000000b */
4357 static const struct message WmInitEndSession
[] = {
4359 { WM_QUERYENDSESSION
, sent
|defwinproc
|wparam
|lparam
, 0, ENDSESSION_LOGOFF
},
4363 /* Sending undocumented 0x3B message with wparam = 0x0000000b */
4364 static const struct message WmInitEndSession_2
[] = {
4366 { WM_QUERYENDSESSION
, sent
|defwinproc
|wparam
|lparam
, 0, 0 },
4370 /* Sending undocumented 0x3B message with wparam = 0x80000008 */
4371 static const struct message WmInitEndSession_3
[] = {
4373 { WM_ENDSESSION
, sent
|defwinproc
|wparam
|lparam
, 0, ENDSESSION_LOGOFF
},
4377 /* Sending undocumented 0x3B message with wparam = 0x00000008 */
4378 static const struct message WmInitEndSession_4
[] = {
4380 { WM_ENDSESSION
, sent
|defwinproc
|wparam
|lparam
, 0, 0 },
4384 /* Sending undocumented 0x3B message with wparam = 0x80000001 */
4385 static const struct message WmInitEndSession_5
[] = {
4387 { WM_ENDSESSION
, sent
|defwinproc
/*|wparam*/|lparam
, 1, ENDSESSION_LOGOFF
},
4391 static const struct message WmOptionalPaint
[] = {
4392 { WM_PAINT
, sent
|optional
},
4393 { WM_NCPAINT
, sent
|beginpaint
|optional
},
4394 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
4395 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
4399 static const struct message WmZOrder
[] = {
4400 { WM_WINDOWPOSCHANGING
, sent
|wparam
, 0, 0 },
4401 { WM_GETMINMAXINFO
, sent
|defwinproc
|wparam
, 0, 0 },
4402 { HCBT_ACTIVATE
, hook
},
4403 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
4404 { WM_WINDOWPOSCHANGING
, sent
|wparam
, 3, 0 },
4405 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOREDRAW
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
, 0 },
4406 { WM_GETTEXT
, sent
|optional
},
4407 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
4408 { WM_ACTIVATEAPP
, sent
|wparam
, 1, 0 },
4409 { WM_NCACTIVATE
, sent
|lparam
, 1, 0 },
4410 { WM_GETTEXT
, sent
|defwinproc
|optional
},
4411 { WM_GETTEXT
, sent
|defwinproc
|optional
},
4412 { WM_ACTIVATE
, sent
|wparam
|lparam
, 1, 0 },
4413 { HCBT_SETFOCUS
, hook
},
4414 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
4415 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
4416 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
4417 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
4418 { WM_GETTEXT
, sent
|optional
},
4419 { WM_NCCALCSIZE
, sent
|optional
},
4423 static void test_MsgWaitForMultipleObjects(HWND hwnd
)
4428 ret
= MsgWaitForMultipleObjects(0, NULL
, FALSE
, 0, QS_POSTMESSAGE
);
4429 ok(ret
== WAIT_TIMEOUT
, "MsgWaitForMultipleObjects returned %x\n", ret
);
4431 PostMessageA(hwnd
, WM_USER
, 0, 0);
4433 ret
= MsgWaitForMultipleObjects(0, NULL
, FALSE
, 0, QS_POSTMESSAGE
);
4434 ok(ret
== WAIT_OBJECT_0
, "MsgWaitForMultipleObjects returned %x\n", ret
);
4436 ok(PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
), "PeekMessage should succeed\n");
4437 ok(msg
.message
== WM_USER
, "got %04x instead of WM_USER\n", msg
.message
);
4439 ret
= MsgWaitForMultipleObjects(0, NULL
, FALSE
, 0, QS_POSTMESSAGE
);
4440 ok(ret
== WAIT_TIMEOUT
, "MsgWaitForMultipleObjects returned %x\n", ret
);
4442 PostMessageA(hwnd
, WM_USER
, 0, 0);
4444 ret
= MsgWaitForMultipleObjects(0, NULL
, FALSE
, 0, QS_POSTMESSAGE
);
4445 ok(ret
== WAIT_OBJECT_0
, "MsgWaitForMultipleObjects returned %x\n", ret
);
4447 ok(PeekMessageA( &msg
, 0, 0, 0, PM_NOREMOVE
), "PeekMessage should succeed\n");
4448 ok(msg
.message
== WM_USER
, "got %04x instead of WM_USER\n", msg
.message
);
4450 /* shows QS_POSTMESSAGE flag is cleared in the PeekMessage call */
4451 ret
= MsgWaitForMultipleObjects(0, NULL
, FALSE
, 0, QS_POSTMESSAGE
);
4452 ok(ret
== WAIT_TIMEOUT
, "MsgWaitForMultipleObjects returned %x\n", ret
);
4454 PostMessageA(hwnd
, WM_USER
, 0, 0);
4456 /* new incoming message causes it to become signaled again */
4457 ret
= MsgWaitForMultipleObjects(0, NULL
, FALSE
, 0, QS_POSTMESSAGE
);
4458 ok(ret
== WAIT_OBJECT_0
, "MsgWaitForMultipleObjects returned %x\n", ret
);
4460 ok(PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
), "PeekMessage should succeed\n");
4461 ok(msg
.message
== WM_USER
, "got %04x instead of WM_USER\n", msg
.message
);
4462 ok(PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
), "PeekMessage should succeed\n");
4463 ok(msg
.message
== WM_USER
, "got %04x instead of WM_USER\n", msg
.message
);
4466 /* test if we receive the right sequence of messages */
4467 static void test_messages(void)
4469 HWND hwnd
, hparent
, hchild
;
4470 HWND hchild2
, hbutton
;
4477 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW
,
4478 100, 100, 200, 200, 0, 0, 0, NULL
);
4479 ok (hwnd
!= 0, "Failed to create overlapped window\n");
4480 ok_sequence(WmCreateOverlappedSeq
, "CreateWindow:overlapped", FALSE
);
4482 /* test ShowWindow(SW_HIDE) on a newly created invisible window */
4483 ok( ShowWindow(hwnd
, SW_HIDE
) == FALSE
, "ShowWindow: window was visible\n" );
4484 ok_sequence(WmEmptySeq
, "ShowWindow(SW_HIDE):overlapped, invisible", FALSE
);
4486 /* test WM_SETREDRAW on a not visible top level window */
4487 test_WM_SETREDRAW(hwnd
);
4489 SetWindowPos(hwnd
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
);
4491 ok_sequence(WmSWP_ShowOverlappedSeq
, "SetWindowPos:SWP_SHOWWINDOW:overlapped", FALSE
);
4492 ok(IsWindowVisible(hwnd
), "window should be visible at this point\n");
4494 ok(GetActiveWindow() == hwnd
, "window should be active\n");
4495 ok(GetFocus() == hwnd
, "window should have input focus\n");
4496 ShowWindow(hwnd
, SW_HIDE
);
4498 ok_sequence(WmHideOverlappedSeq
, "ShowWindow(SW_HIDE):overlapped", FALSE
);
4500 ShowWindow(hwnd
, SW_SHOW
);
4502 ok_sequence(WmShowOverlappedSeq
, "ShowWindow(SW_SHOW):overlapped", TRUE
);
4504 ShowWindow(hwnd
, SW_HIDE
);
4506 ok_sequence(WmHideOverlappedSeq
, "ShowWindow(SW_HIDE):overlapped", FALSE
);
4508 ShowWindow(hwnd
, SW_SHOWMAXIMIZED
);
4510 ok_sequence(WmShowMaxOverlappedSeq
, "ShowWindow(SW_SHOWMAXIMIZED):overlapped", TRUE
);
4513 if (GetWindowLongW( hwnd
, GWL_STYLE
) & WS_MAXIMIZE
)
4515 ShowWindow(hwnd
, SW_RESTORE
);
4517 ok_sequence(WmShowRestoreMaxOverlappedSeq
, "ShowWindow(SW_RESTORE):overlapped", TRUE
);
4521 ShowWindow(hwnd
, SW_MINIMIZE
);
4523 ok_sequence(WmShowMinOverlappedSeq
, "ShowWindow(SW_SHOWMINIMIZED):overlapped", TRUE
);
4526 if (GetWindowLongW( hwnd
, GWL_STYLE
) & WS_MINIMIZE
)
4528 ShowWindow(hwnd
, SW_RESTORE
);
4530 ok_sequence(WmShowRestoreMinOverlappedSeq
, "ShowWindow(SW_RESTORE):overlapped", TRUE
);
4534 ShowWindow(hwnd
, SW_SHOW
);
4536 ok_sequence(WmOptionalPaint
, "ShowWindow(SW_SHOW):overlapped already visible", FALSE
);
4538 SetWindowPos(hwnd
, 0,0,0,0,0, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
);
4539 ok_sequence(WmSWP_HideOverlappedSeq
, "SetWindowPos:SWP_HIDEWINDOW:overlapped", FALSE
);
4540 ok(!IsWindowVisible(hwnd
), "window should not be visible at this point\n");
4541 ok(GetActiveWindow() == hwnd
, "window should still be active\n");
4543 /* test WM_SETREDRAW on a visible top level window */
4544 ShowWindow(hwnd
, SW_SHOW
);
4546 test_WM_SETREDRAW(hwnd
);
4548 trace("testing scroll APIs on a visible top level window %p\n", hwnd
);
4549 test_scroll_messages(hwnd
);
4551 /* test resizing and moving */
4552 SetWindowPos( hwnd
, 0, 0, 0, 300, 300, SWP_NOMOVE
|SWP_NOACTIVATE
);
4553 ok_sequence(WmSWP_ResizeSeq
, "SetWindowPos:Resize", FALSE
);
4556 SetWindowPos( hwnd
, 0, 200, 200, 0, 0, SWP_NOSIZE
|SWP_NOACTIVATE
);
4557 ok_sequence(WmSWP_MoveSeq
, "SetWindowPos:Move", FALSE
);
4560 SetWindowPos( hwnd
, 0, 200, 200, 250, 250, SWP_NOZORDER
|SWP_NOACTIVATE
);
4561 ok_sequence(WmSWP_ResizeNoZOrder
, "SetWindowPos:WmSWP_ResizeNoZOrder", FALSE
);
4565 /* popups don't get WM_GETMINMAXINFO */
4566 SetWindowLongW( hwnd
, GWL_STYLE
, WS_VISIBLE
|WS_POPUP
);
4567 SetWindowPos( hwnd
, 0, 0, 0, 0, 0, SWP_NOZORDER
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_FRAMECHANGED
);
4569 SetWindowPos( hwnd
, 0, 0, 0, 200, 200, SWP_NOMOVE
|SWP_NOACTIVATE
);
4570 ok_sequence(WmSWP_ResizePopupSeq
, "SetWindowPos:ResizePopup", FALSE
);
4572 DestroyWindow(hwnd
);
4573 ok_sequence(WmDestroyOverlappedSeq
, "DestroyWindow:overlapped", FALSE
);
4575 hparent
= CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
4576 100, 100, 200, 200, 0, 0, 0, NULL
);
4577 ok (hparent
!= 0, "Failed to create parent window\n");
4580 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
| WS_MAXIMIZE
,
4581 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4582 ok (hchild
!= 0, "Failed to create child window\n");
4583 ok_sequence(WmCreateMaximizedChildSeq
, "CreateWindow:maximized child", FALSE
);
4584 DestroyWindow(hchild
);
4587 /* visible child window with a caption */
4588 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child",
4589 WS_CHILD
| WS_VISIBLE
| WS_CAPTION
,
4590 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4591 ok (hchild
!= 0, "Failed to create child window\n");
4592 ok_sequence(WmCreateVisibleChildSeq
, "CreateWindow:visible child", FALSE
);
4594 trace("testing scroll APIs on a visible child window %p\n", hchild
);
4595 test_scroll_messages(hchild
);
4597 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
);
4598 ok_sequence(WmShowChildSeq_4
, "SetWindowPos(SWP_SHOWWINDOW):child with a caption", FALSE
);
4600 DestroyWindow(hchild
);
4603 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
4604 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4605 ok (hchild
!= 0, "Failed to create child window\n");
4606 ok_sequence(WmCreateChildSeq
, "CreateWindow:child", FALSE
);
4608 hchild2
= CreateWindowExA(0, "SimpleWindowClass", "Test child2", WS_CHILD
,
4609 100, 100, 50, 50, hparent
, 0, 0, NULL
);
4610 ok (hchild2
!= 0, "Failed to create child2 window\n");
4613 hbutton
= CreateWindowExA(0, "TestWindowClass", "Test button", WS_CHILD
,
4614 0, 100, 50, 50, hchild
, 0, 0, NULL
);
4615 ok (hbutton
!= 0, "Failed to create button window\n");
4617 /* test WM_SETREDRAW on a not visible child window */
4618 test_WM_SETREDRAW(hchild
);
4620 ShowWindow(hchild
, SW_SHOW
);
4621 ok_sequence(WmShowChildSeq
, "ShowWindow(SW_SHOW):child", FALSE
);
4623 /* check parent messages too */
4624 log_all_parent_messages
++;
4625 ShowWindow(hchild
, SW_HIDE
);
4626 ok_sequence(WmHideChildSeq2
, "ShowWindow(SW_HIDE):child", FALSE
);
4627 log_all_parent_messages
--;
4629 ShowWindow(hchild
, SW_SHOW
);
4630 ok_sequence(WmShowChildSeq
, "ShowWindow(SW_SHOW):child", FALSE
);
4632 ShowWindow(hchild
, SW_HIDE
);
4633 ok_sequence(WmHideChildSeq
, "ShowWindow(SW_HIDE):child", FALSE
);
4635 ShowWindow(hchild
, SW_SHOW
);
4636 ok_sequence(WmShowChildSeq
, "ShowWindow(SW_SHOW):child", FALSE
);
4638 /* test WM_SETREDRAW on a visible child window */
4639 test_WM_SETREDRAW(hchild
);
4641 log_all_parent_messages
++;
4642 MoveWindow(hchild
, 10, 10, 20, 20, TRUE
);
4643 ok_sequence(WmResizingChildWithMoveWindowSeq
, "MoveWindow:child", FALSE
);
4644 log_all_parent_messages
--;
4646 ShowWindow(hchild
, SW_HIDE
);
4648 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
);
4649 ok_sequence(WmShowChildSeq_2
, "SetWindowPos:show_child_2", FALSE
);
4651 ShowWindow(hchild
, SW_HIDE
);
4653 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
);
4654 ok_sequence(WmShowChildSeq_3
, "SetWindowPos:show_child_3", FALSE
);
4656 /* DestroyWindow sequence below expects that a child has focus */
4660 DestroyWindow(hchild
);
4661 ok_sequence(WmDestroyChildSeq
, "DestroyWindow:child", FALSE
);
4662 DestroyWindow(hchild2
);
4663 DestroyWindow(hbutton
);
4666 hchild
= CreateWindowExA(0, "TestWindowClass", "Test Child Popup", WS_CHILD
| WS_POPUP
,
4667 0, 0, 100, 100, hparent
, 0, 0, NULL
);
4668 ok (hchild
!= 0, "Failed to create child popup window\n");
4669 ok_sequence(WmCreateChildPopupSeq
, "CreateWindow:child_popup", FALSE
);
4670 DestroyWindow(hchild
);
4672 /* test what happens to a window which sets WS_VISIBLE in WM_CREATE */
4674 hchild
= CreateWindowExA(0, "TestPopupClass", "Test Popup", WS_POPUP
,
4675 0, 0, 100, 100, hparent
, 0, 0, NULL
);
4676 ok (hchild
!= 0, "Failed to create popup window\n");
4677 ok_sequence(WmCreateInvisiblePopupSeq
, "CreateWindow:invisible_popup", FALSE
);
4678 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
4679 ok(IsWindowVisible(hchild
), "IsWindowVisible() should return TRUE\n");
4681 ShowWindow(hchild
, SW_SHOW
);
4682 ok_sequence(WmEmptySeq
, "ShowWindow:show_visible_popup", FALSE
);
4684 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOZORDER
);
4685 ok_sequence(WmShowVisiblePopupSeq_2
, "SetWindowPos:show_visible_popup_2", FALSE
);
4687 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
);
4688 ok_sequence(WmShowVisiblePopupSeq_3
, "SetWindowPos:show_visible_popup_3", FALSE
);
4689 DestroyWindow(hchild
);
4691 /* this time add WS_VISIBLE for CreateWindowEx, but this fact actually
4692 * changes nothing in message sequences.
4695 hchild
= CreateWindowExA(0, "TestPopupClass", "Test Popup", WS_POPUP
| WS_VISIBLE
,
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
);
4707 DestroyWindow(hchild
);
4710 hwnd
= CreateWindowExA(WS_EX_DLGMODALFRAME
, "TestDialogClass", NULL
, WS_VISIBLE
|WS_CAPTION
|WS_SYSMENU
|WS_DLGFRAME
,
4711 0, 0, 100, 100, hparent
, 0, 0, NULL
);
4712 ok(hwnd
!= 0, "Failed to create custom dialog window\n");
4713 ok_sequence(WmCreateCustomDialogSeq
, "CreateCustomDialog", TRUE
);
4716 trace("testing scroll APIs on a visible dialog %p\n", hwnd);
4717 test_scroll_messages(hwnd);
4723 SendMessage(hwnd
, WM_NULL
, 0, 0);
4726 after_end_dialog
= 1;
4727 EndDialog( hwnd
, 0 );
4728 ok_sequence(WmEndCustomDialogSeq
, "EndCustomDialog", FALSE
);
4730 DestroyWindow(hwnd
);
4731 after_end_dialog
= 0;
4734 hwnd
= CreateWindowExA(0, "TestDialogClass", NULL
, WS_POPUP
,
4735 0, 0, 100, 100, 0, 0, GetModuleHandleA(0), NULL
);
4736 ok(hwnd
!= 0, "Failed to create custom dialog window\n");
4738 trace("call ShowWindow(%p, SW_SHOW)\n", hwnd
);
4739 ShowWindow(hwnd
, SW_SHOW
);
4740 ok_sequence(WmShowCustomDialogSeq
, "ShowCustomDialog", TRUE
);
4741 DestroyWindow(hwnd
);
4744 DialogBoxA( 0, "TEST_DIALOG", hparent
, TestModalDlgProcA
);
4745 ok_sequence(WmModalDialogSeq
, "ModalDialog", TRUE
);
4747 DestroyWindow(hparent
);
4750 /* Message sequence for SetMenu */
4751 ok(!DrawMenuBar(hwnd
), "DrawMenuBar should return FALSE for a window without a menu\n");
4752 ok_sequence(WmEmptySeq
, "DrawMenuBar for a window without a menu", FALSE
);
4754 hmenu
= CreateMenu();
4755 ok (hmenu
!= 0, "Failed to create menu\n");
4756 ok (InsertMenuA(hmenu
, -1, MF_BYPOSITION
, 0x1000, "foo"), "InsertMenu failed\n");
4757 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW
,
4758 100, 100, 200, 200, 0, hmenu
, 0, NULL
);
4759 ok_sequence(WmCreateOverlappedSeq
, "CreateWindow:overlapped", FALSE
);
4760 ok (SetMenu(hwnd
, 0), "SetMenu\n");
4761 ok_sequence(WmSetMenuNonVisibleSizeChangeSeq
, "SetMenu:NonVisibleSizeChange", FALSE
);
4762 ok (SetMenu(hwnd
, 0), "SetMenu\n");
4763 ok_sequence(WmSetMenuNonVisibleNoSizeChangeSeq
, "SetMenu:NonVisibleNoSizeChange", FALSE
);
4764 ShowWindow(hwnd
, SW_SHOW
);
4765 UpdateWindow( hwnd
);
4768 ok (SetMenu(hwnd
, 0), "SetMenu\n");
4769 ok_sequence(WmSetMenuVisibleNoSizeChangeSeq
, "SetMenu:VisibleNoSizeChange", FALSE
);
4770 ok (SetMenu(hwnd
, hmenu
), "SetMenu\n");
4771 ok_sequence(WmSetMenuVisibleSizeChangeSeq
, "SetMenu:VisibleSizeChange", FALSE
);
4773 UpdateWindow( hwnd
);
4776 ok(DrawMenuBar(hwnd
), "DrawMenuBar\n");
4778 ok_sequence(WmDrawMenuBarSeq
, "DrawMenuBar", FALSE
);
4780 DestroyWindow(hwnd
);
4783 /* Message sequence for EnableWindow */
4784 hparent
= CreateWindowExA(0, "TestWindowClass", "Test parent", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
4785 100, 100, 200, 200, 0, 0, 0, NULL
);
4786 ok (hparent
!= 0, "Failed to create parent window\n");
4787 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
| WS_VISIBLE
,
4788 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4789 ok (hchild
!= 0, "Failed to create child window\n");
4795 EnableWindow(hparent
, FALSE
);
4796 ok_sequence(WmEnableWindowSeq_1
, "EnableWindow(FALSE)", FALSE
);
4798 EnableWindow(hparent
, TRUE
);
4799 ok_sequence(WmEnableWindowSeq_2
, "EnableWindow(TRUE)", FALSE
);
4804 test_MsgWaitForMultipleObjects(hparent
);
4806 /* the following test causes an exception in user.exe under win9x */
4807 if (!PostMessageW( hparent
, WM_USER
, 0, 0 ))
4809 DestroyWindow(hparent
);
4813 PostMessageW( hparent
, WM_USER
+1, 0, 0 );
4814 /* PeekMessage(NULL) fails, but still removes the message */
4815 SetLastError(0xdeadbeef);
4816 ok( !PeekMessageW( NULL
, 0, 0, 0, PM_REMOVE
), "PeekMessage(NULL) should fail\n" );
4817 ok( GetLastError() == ERROR_NOACCESS
|| /* Win2k */
4818 GetLastError() == 0xdeadbeef, /* NT4 */
4819 "last error is %d\n", GetLastError() );
4820 ok( PeekMessageW( &msg
, 0, 0, 0, PM_REMOVE
), "PeekMessage should succeed\n" );
4821 ok( msg
.message
== WM_USER
+1, "got %x instead of WM_USER+1\n", msg
.message
);
4823 DestroyWindow(hchild
);
4824 DestroyWindow(hparent
);
4827 /* Message sequences for WM_SETICON */
4828 trace("testing WM_SETICON\n");
4829 hwnd
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
4830 CW_USEDEFAULT
, CW_USEDEFAULT
, 300, 300, 0,
4832 ShowWindow(hwnd
, SW_SHOW
);
4836 SendMessage(hwnd
, WM_SETICON
, ICON_SMALL
, (LPARAM
)LoadIcon(0, IDI_APPLICATION
));
4837 ok_sequence(WmSetIcon_1
, "WM_SETICON for shown window with caption", FALSE
);
4839 ShowWindow(hwnd
, SW_HIDE
);
4842 SendMessage(hwnd
, WM_SETICON
, ICON_SMALL
, (LPARAM
)LoadIcon(0, IDI_APPLICATION
));
4843 ok_sequence(WmSetIcon_2
, "WM_SETICON for hidden window with caption", FALSE
);
4844 DestroyWindow(hwnd
);
4847 hwnd
= CreateWindowExA(0, "TestPopupClass", NULL
, WS_POPUP
,
4848 CW_USEDEFAULT
, CW_USEDEFAULT
, 300, 300, 0,
4850 ShowWindow(hwnd
, SW_SHOW
);
4854 SendMessage(hwnd
, WM_SETICON
, ICON_SMALL
, (LPARAM
)LoadIcon(0, IDI_APPLICATION
));
4855 ok_sequence(WmSetIcon_2
, "WM_SETICON for shown window without caption", FALSE
);
4857 ShowWindow(hwnd
, SW_HIDE
);
4860 SendMessage(hwnd
, WM_SETICON
, ICON_SMALL
, (LPARAM
)LoadIcon(0, IDI_APPLICATION
));
4861 ok_sequence(WmSetIcon_2
, "WM_SETICON for hidden window without caption", FALSE
);
4864 res
= SendMessage(hwnd
, 0x3B, 0x8000000b, 0);
4867 todo_wine
win_skip( "Message 0x3b not supported\n" );
4870 ok_sequence(WmInitEndSession
, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x8000000b", TRUE
);
4871 ok(res
== 1, "SendMessage(hwnd, 0x3B, 0x8000000b, 0) should have returned 1 instead of %ld\n", res
);
4872 res
= SendMessage(hwnd
, 0x3B, 0x0000000b, 0);
4873 ok_sequence(WmInitEndSession_2
, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x0000000b", TRUE
);
4874 ok(res
== 1, "SendMessage(hwnd, 0x3B, 0x0000000b, 0) should have returned 1 instead of %ld\n", res
);
4875 res
= SendMessage(hwnd
, 0x3B, 0x0000000f, 0);
4876 ok_sequence(WmInitEndSession_2
, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x0000000f", TRUE
);
4877 ok(res
== 1, "SendMessage(hwnd, 0x3B, 0x0000000f, 0) should have returned 1 instead of %ld\n", res
);
4880 res
= SendMessage(hwnd
, 0x3B, 0x80000008, 0);
4881 ok_sequence(WmInitEndSession_3
, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x80000008", TRUE
);
4882 ok(res
== 2, "SendMessage(hwnd, 0x3B, 0x80000008, 0) should have returned 2 instead of %ld\n", res
);
4883 res
= SendMessage(hwnd
, 0x3B, 0x00000008, 0);
4884 ok_sequence(WmInitEndSession_4
, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x00000008", TRUE
);
4885 ok(res
== 2, "SendMessage(hwnd, 0x3B, 0x00000008, 0) should have returned 2 instead of %ld\n", res
);
4887 res
= SendMessage(hwnd
, 0x3B, 0x80000004, 0);
4888 ok_sequence(WmInitEndSession_3
, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x80000004", TRUE
);
4889 ok(res
== 2, "SendMessage(hwnd, 0x3B, 0x80000004, 0) should have returned 2 instead of %ld\n", res
);
4891 res
= SendMessage(hwnd
, 0x3B, 0x80000001, 0);
4892 ok_sequence(WmInitEndSession_5
, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x80000001", TRUE
);
4893 ok(res
== 2, "SendMessage(hwnd, 0x3B, 0x80000001, 0) should have returned 2 instead of %ld\n", res
);
4896 DestroyWindow(hwnd
);
4900 static void test_setwindowpos(void)
4905 const INT winX
= 100;
4906 const INT winY
= 100;
4907 const INT sysX
= GetSystemMetrics(SM_CXMINTRACK
);
4909 hwnd
= CreateWindowExA(0, "TestWindowClass", NULL
, 0,
4910 0, 0, winX
, winY
, 0,
4913 GetWindowRect(hwnd
, &rc
);
4914 expect(sysX
, rc
.right
);
4915 expect(winY
, rc
.bottom
);
4919 res
= SetWindowPos(hwnd
, HWND_TOPMOST
, 0, 0, winX
, winY
, 0);
4920 ok_sequence(WmZOrder
, "Z-Order", TRUE
);
4921 ok(res
== TRUE
, "SetWindowPos expected TRUE, got %ld\n", res
);
4923 GetWindowRect(hwnd
, &rc
);
4924 expect(sysX
, rc
.right
);
4925 expect(winY
, rc
.bottom
);
4926 DestroyWindow(hwnd
);
4929 static void invisible_parent_tests(void)
4931 HWND hparent
, hchild
;
4933 hparent
= CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW
,
4934 100, 100, 200, 200, 0, 0, 0, NULL
);
4935 ok (hparent
!= 0, "Failed to create parent window\n");
4938 /* test showing child with hidden parent */
4940 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
4941 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4942 ok (hchild
!= 0, "Failed to create child window\n");
4943 ok_sequence(WmCreateChildSeq
, "CreateWindow:child", FALSE
);
4945 ShowWindow( hchild
, SW_MINIMIZE
);
4946 ok_sequence(WmShowChildInvisibleParentSeq_1
, "ShowWindow(SW_MINIMIZE) child with invisible parent", FALSE
);
4947 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
4948 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
4953 ShowWindow( hchild
, SW_MINIMIZE
);
4954 ok_sequence(WmShowChildInvisibleParentSeq_1r
, "ShowWindow(SW_MINIMIZE) child with invisible parent", FALSE
);
4956 DestroyWindow(hchild
);
4957 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
4958 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4961 ShowWindow( hchild
, SW_MAXIMIZE
);
4962 ok_sequence(WmShowChildInvisibleParentSeq_2
, "ShowWindow(SW_MAXIMIZE) child with invisible parent", FALSE
);
4963 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
4964 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
4969 ShowWindow( hchild
, SW_MAXIMIZE
);
4970 ok_sequence(WmShowChildInvisibleParentSeq_2r
, "ShowWindow(SW_MAXIMIZE) child with invisible parent", FALSE
);
4972 DestroyWindow(hchild
);
4973 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
4974 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4977 ShowWindow( hchild
, SW_RESTORE
);
4978 ok_sequence(WmShowChildInvisibleParentSeq_5
, "ShowWindow(SW_RESTORE) child with invisible parent", FALSE
);
4979 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
4980 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
4982 DestroyWindow(hchild
);
4983 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
4984 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4987 ShowWindow( hchild
, SW_SHOWMINIMIZED
);
4988 ok_sequence(WmShowChildInvisibleParentSeq_3
, "ShowWindow(SW_SHOWMINIMIZED) child with invisible parent", FALSE
);
4989 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
4990 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
4995 ShowWindow( hchild
, SW_SHOWMINIMIZED
);
4996 ok_sequence(WmShowChildInvisibleParentSeq_3r
, "ShowWindow(SW_SHOWMINIMIZED) child with invisible parent", FALSE
);
4998 DestroyWindow(hchild
);
4999 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
5000 0, 0, 10, 10, hparent
, 0, 0, NULL
);
5003 /* same as ShowWindow( hchild, SW_MAXIMIZE ); */
5004 ShowWindow( hchild
, SW_SHOWMAXIMIZED
);
5005 ok_sequence(WmShowChildInvisibleParentSeq_2
, "ShowWindow(SW_SHOWMAXIMIZED) child with invisible parent", FALSE
);
5006 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
5007 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
5009 DestroyWindow(hchild
);
5010 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
5011 0, 0, 10, 10, hparent
, 0, 0, NULL
);
5014 ShowWindow( hchild
, SW_SHOWMINNOACTIVE
);
5015 ok_sequence(WmShowChildInvisibleParentSeq_4
, "ShowWindow(SW_SHOWMINNOACTIVE) child with invisible parent", FALSE
);
5016 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
5017 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
5022 ShowWindow( hchild
, SW_SHOWMINNOACTIVE
);
5023 ok_sequence(WmShowChildInvisibleParentSeq_4r
, "ShowWindow(SW_SHOWMINNOACTIVE) child with invisible parent", FALSE
);
5025 DestroyWindow(hchild
);
5026 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
5027 0, 0, 10, 10, hparent
, 0, 0, NULL
);
5030 /* FIXME: looks like XP SP2 doesn't know about SW_FORCEMINIMIZE at all */
5031 ShowWindow( hchild
, SW_FORCEMINIMIZE
);
5032 ok_sequence(WmEmptySeq
, "ShowWindow(SW_FORCEMINIMIZE) child with invisible parent", TRUE
);
5034 ok(!(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
), "WS_VISIBLE should be not set\n");
5036 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
5038 DestroyWindow(hchild
);
5039 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
5040 0, 0, 10, 10, hparent
, 0, 0, NULL
);
5043 ShowWindow( hchild
, SW_SHOWNA
);
5044 ok_sequence(WmShowChildInvisibleParentSeq_5
, "ShowWindow(SW_SHOWNA) child with invisible parent", FALSE
);
5045 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
5046 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
5051 ShowWindow( hchild
, SW_SHOWNA
);
5052 ok_sequence(WmShowChildInvisibleParentSeq_5
, "ShowWindow(SW_SHOWNA) child with invisible parent", FALSE
);
5054 DestroyWindow(hchild
);
5055 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
5056 0, 0, 10, 10, hparent
, 0, 0, NULL
);
5059 ShowWindow( hchild
, SW_SHOW
);
5060 ok_sequence(WmShowChildInvisibleParentSeq_5
, "ShowWindow(SW_SHOW) child with invisible parent", FALSE
);
5061 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
5062 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
5067 ShowWindow( hchild
, SW_SHOW
);
5068 ok_sequence(WmEmptySeq
, "ShowWindow(SW_SHOW) child with invisible parent", FALSE
);
5070 ShowWindow( hchild
, SW_HIDE
);
5071 ok_sequence(WmHideChildInvisibleParentSeq
, "ShowWindow:hide child with invisible parent", FALSE
);
5072 ok(!(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
), "WS_VISIBLE should be not set\n");
5073 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
5075 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOZORDER
);
5076 ok_sequence(WmShowChildInvisibleParentSeq_6
, "SetWindowPos:show child with invisible parent", FALSE
);
5077 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
5078 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
5080 SetWindowPos(hchild
, 0,0,0,0,0, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOZORDER
);
5081 ok_sequence(WmHideChildInvisibleParentSeq_2
, "SetWindowPos:hide child with invisible parent", FALSE
);
5082 ok(!(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
), "WS_VISIBLE should not be set\n");
5083 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
5085 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOZORDER
);
5087 DestroyWindow(hchild
);
5088 ok_sequence(WmDestroyInvisibleChildSeq
, "DestroyInvisibleChildSeq", FALSE
);
5090 DestroyWindow(hparent
);
5094 /****************** button message test *************************/
5095 #define ID_BUTTON 0x000e
5097 static const struct message WmSetFocusButtonSeq
[] =
5099 { HCBT_SETFOCUS
, hook
},
5100 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
5101 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
5102 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
5103 { WM_SETFOCUS
, sent
|wparam
, 0 },
5104 { WM_CTLCOLORBTN
, sent
|parent
},
5105 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_BUTTON
, BN_SETFOCUS
) },
5106 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5109 static const struct message WmKillFocusButtonSeq
[] =
5111 { HCBT_SETFOCUS
, hook
},
5112 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
5113 { WM_KILLFOCUS
, sent
|wparam
, 0 },
5114 { WM_CTLCOLORBTN
, sent
|parent
},
5115 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_BUTTON
, BN_KILLFOCUS
) },
5116 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
5117 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 1 },
5118 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5120 { WM_CTLCOLORBTN
, sent
|parent
},
5123 static const struct message WmSetFocusStaticSeq
[] =
5125 { HCBT_SETFOCUS
, hook
},
5126 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
5127 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
5128 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
5129 { WM_SETFOCUS
, sent
|wparam
, 0 },
5130 { WM_CTLCOLORSTATIC
, sent
|parent
},
5131 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_BUTTON
, BN_SETFOCUS
) },
5132 { WM_COMMAND
, sent
|wparam
|parent
|optional
, MAKEWPARAM(ID_BUTTON
, BN_CLICKED
) }, /* radio button */
5133 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5136 static const struct message WmKillFocusStaticSeq
[] =
5138 { HCBT_SETFOCUS
, hook
},
5139 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
5140 { WM_KILLFOCUS
, sent
|wparam
, 0 },
5141 { WM_CTLCOLORSTATIC
, sent
|parent
},
5142 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_BUTTON
, BN_KILLFOCUS
) },
5143 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
5144 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 1 },
5145 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5147 { WM_CTLCOLORSTATIC
, sent
|parent
},
5150 static const struct message WmSetFocusOwnerdrawSeq
[] =
5152 { HCBT_SETFOCUS
, hook
},
5153 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
5154 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
5155 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
5156 { WM_SETFOCUS
, sent
|wparam
, 0 },
5157 { WM_CTLCOLORBTN
, sent
|parent
},
5158 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_BUTTON
, 0x001040e4 },
5159 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_BUTTON
, BN_SETFOCUS
) },
5160 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5163 static const struct message WmKillFocusOwnerdrawSeq
[] =
5165 { HCBT_SETFOCUS
, hook
},
5166 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
5167 { WM_KILLFOCUS
, sent
|wparam
, 0 },
5168 { WM_CTLCOLORBTN
, sent
|parent
},
5169 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_BUTTON
, 0x000040e4 },
5170 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_BUTTON
, BN_KILLFOCUS
) },
5171 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
5172 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 1 },
5173 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5175 { WM_CTLCOLORBTN
, sent
|parent
},
5176 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_BUTTON
, 0x000010e4 },
5179 static const struct message WmLButtonDownSeq
[] =
5181 { WM_LBUTTONDOWN
, sent
|wparam
|lparam
, 0, 0 },
5182 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
5183 { HCBT_SETFOCUS
, hook
},
5184 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
5185 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
5186 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
5187 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
5188 { WM_CTLCOLORBTN
, sent
|defwinproc
},
5189 { BM_SETSTATE
, sent
|wparam
|defwinproc
, TRUE
},
5190 { WM_CTLCOLORBTN
, sent
|defwinproc
},
5191 { EVENT_OBJECT_STATECHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
5194 static const struct message WmLButtonUpSeq
[] =
5196 { WM_LBUTTONUP
, sent
|wparam
|lparam
, 0, 0 },
5197 { BM_SETSTATE
, sent
|wparam
|defwinproc
, FALSE
},
5198 { WM_CTLCOLORBTN
, sent
|defwinproc
},
5199 { EVENT_OBJECT_STATECHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
5200 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, 0, 0 },
5201 { WM_CAPTURECHANGED
, sent
|wparam
|defwinproc
, 0 },
5204 static const struct message WmSetFontButtonSeq
[] =
5206 { WM_SETFONT
, sent
},
5208 { WM_ERASEBKGND
, sent
|defwinproc
|optional
},
5209 { WM_CTLCOLORBTN
, sent
|defwinproc
},
5213 static WNDPROC old_button_proc
;
5215 static LRESULT CALLBACK
button_hook_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
5217 static long defwndproc_counter
= 0;
5219 struct recvd_message msg
;
5221 if (ignore_message( message
)) return 0;
5228 ok(GetCapture() == hwnd
, "GetCapture() = %p\n", GetCapture());
5232 msg
.message
= message
;
5233 msg
.flags
= sent
|wparam
|lparam
;
5234 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
5235 msg
.wParam
= wParam
;
5236 msg
.lParam
= lParam
;
5237 msg
.descr
= "button";
5241 defwndproc_counter
++;
5242 ret
= CallWindowProcA(old_button_proc
, hwnd
, message
, wParam
, lParam
);
5243 defwndproc_counter
--;
5248 static void subclass_button(void)
5252 if (!GetClassInfoA(0, "button", &cls
)) assert(0);
5254 old_button_proc
= cls
.lpfnWndProc
;
5256 cls
.hInstance
= GetModuleHandle(0);
5257 cls
.lpfnWndProc
= button_hook_proc
;
5258 cls
.lpszClassName
= "my_button_class";
5259 UnregisterClass(cls
.lpszClassName
, cls
.hInstance
);
5260 if (!RegisterClassA(&cls
)) assert(0);
5263 static void test_button_messages(void)
5269 const struct message
*setfocus
;
5270 const struct message
*killfocus
;
5272 { BS_PUSHBUTTON
, DLGC_BUTTON
| DLGC_UNDEFPUSHBUTTON
,
5273 WmSetFocusButtonSeq
, WmKillFocusButtonSeq
},
5274 { BS_DEFPUSHBUTTON
, DLGC_BUTTON
| DLGC_DEFPUSHBUTTON
,
5275 WmSetFocusButtonSeq
, WmKillFocusButtonSeq
},
5276 { BS_CHECKBOX
, DLGC_BUTTON
,
5277 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
},
5278 { BS_AUTOCHECKBOX
, DLGC_BUTTON
,
5279 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
},
5280 { BS_RADIOBUTTON
, DLGC_BUTTON
| DLGC_RADIOBUTTON
,
5281 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
},
5282 { BS_3STATE
, DLGC_BUTTON
,
5283 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
},
5284 { BS_AUTO3STATE
, DLGC_BUTTON
,
5285 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
},
5286 { BS_GROUPBOX
, DLGC_STATIC
,
5287 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
},
5288 { BS_USERBUTTON
, DLGC_BUTTON
| DLGC_UNDEFPUSHBUTTON
,
5289 WmSetFocusButtonSeq
, WmKillFocusButtonSeq
},
5290 { BS_AUTORADIOBUTTON
, DLGC_BUTTON
| DLGC_RADIOBUTTON
,
5291 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
},
5292 { BS_OWNERDRAW
, DLGC_BUTTON
,
5293 WmSetFocusOwnerdrawSeq
, WmKillFocusOwnerdrawSeq
}
5300 /* selection with VK_SPACE should capture button window */
5301 hwnd
= CreateWindowExA(0, "button", "test", BS_CHECKBOX
| WS_VISIBLE
| WS_POPUP
,
5302 0, 0, 50, 14, 0, 0, 0, NULL
);
5303 ok(hwnd
!= 0, "Failed to create button window\n");
5306 SendMessageA(hwnd
, WM_KEYDOWN
, VK_SPACE
, 0);
5307 ok(GetCapture() == hwnd
, "Should be captured on VK_SPACE WM_KEYDOWN\n");
5308 SendMessageA(hwnd
, WM_KEYUP
, VK_SPACE
, 0);
5309 DestroyWindow(hwnd
);
5313 parent
= CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
5314 100, 100, 200, 200, 0, 0, 0, NULL
);
5315 ok(parent
!= 0, "Failed to create parent window\n");
5317 for (i
= 0; i
< sizeof(button
)/sizeof(button
[0]); i
++)
5322 hwnd
= CreateWindowExA(0, "my_button_class", "test", button
[i
].style
| WS_CHILD
| BS_NOTIFY
,
5323 0, 0, 50, 14, parent
, (HMENU
)ID_BUTTON
, 0, NULL
);
5324 ok(hwnd
!= 0, "Failed to create button window\n");
5326 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
5327 style
&= ~(WS_CHILD
| BS_NOTIFY
);
5328 /* XP turns a BS_USERBUTTON into BS_PUSHBUTTON */
5329 if (button
[i
].style
== BS_USERBUTTON
)
5330 todo_wine
ok(style
== BS_PUSHBUTTON
, "expected style BS_PUSHBUTTON got %x\n", style
);
5332 ok(style
== button
[i
].style
, "expected style %x got %x\n", button
[i
].style
, style
);
5334 dlg_code
= SendMessageA(hwnd
, WM_GETDLGCODE
, 0, 0);
5335 ok(dlg_code
== button
[i
].dlg_code
, "%u: wrong dlg_code %08x\n", i
, dlg_code
);
5337 ShowWindow(hwnd
, SW_SHOW
);
5343 log_all_parent_messages
++;
5345 trace("button style %08x\n", button
[i
].style
);
5346 ok(GetFocus() == 0, "expected focus 0, got %p\n", GetFocus());
5348 SendMessage(hwnd
, WM_APP
, 0, 0); /* place a separator mark here */
5349 while (PeekMessage(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage(&msg
);
5350 ok_sequence(button
[i
].setfocus
, "SetFocus(hwnd) on a button", FALSE
);
5353 SendMessage(hwnd
, WM_APP
, 0, 0); /* place a separator mark here */
5354 while (PeekMessage(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage(&msg
);
5355 ok_sequence(button
[i
].killfocus
, "SetFocus(0) on a button", FALSE
);
5357 log_all_parent_messages
--;
5359 ok(GetFocus() == 0, "expected focus 0, got %p\n", GetFocus());
5360 DestroyWindow(hwnd
);
5363 DestroyWindow(parent
);
5365 hwnd
= CreateWindowExA(0, "my_button_class", "test", BS_PUSHBUTTON
| WS_POPUP
| WS_VISIBLE
,
5366 0, 0, 50, 14, 0, 0, 0, NULL
);
5367 ok(hwnd
!= 0, "Failed to create button window\n");
5369 SetForegroundWindow(hwnd
);
5372 SetActiveWindow(hwnd
);
5376 SendMessageA(hwnd
, WM_LBUTTONDOWN
, 0, 0);
5377 ok_sequence(WmLButtonDownSeq
, "WM_LBUTTONDOWN on a button", FALSE
);
5379 SendMessageA(hwnd
, WM_LBUTTONUP
, 0, 0);
5380 ok_sequence(WmLButtonUpSeq
, "WM_LBUTTONUP on a button", FALSE
);
5383 zfont
= GetStockObject(SYSTEM_FONT
);
5384 SendMessageA(hwnd
, WM_SETFONT
, (WPARAM
)zfont
, TRUE
);
5386 ok_sequence(WmSetFontButtonSeq
, "WM_SETFONT on a button", FALSE
);
5388 DestroyWindow(hwnd
);
5391 /****************** static message test *************************/
5392 static const struct message WmSetFontStaticSeq
[] =
5394 { WM_SETFONT
, sent
},
5395 { WM_PAINT
, sent
|defwinproc
|optional
},
5396 { WM_ERASEBKGND
, sent
|defwinproc
|optional
},
5397 { WM_CTLCOLORSTATIC
, sent
|defwinproc
|optional
},
5401 static WNDPROC old_static_proc
;
5403 static LRESULT CALLBACK
static_hook_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
5405 static long defwndproc_counter
= 0;
5407 struct recvd_message msg
;
5409 if (ignore_message( message
)) return 0;
5412 msg
.message
= message
;
5413 msg
.flags
= sent
|wparam
|lparam
;
5414 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
5415 msg
.wParam
= wParam
;
5416 msg
.lParam
= lParam
;
5417 msg
.descr
= "static";
5420 defwndproc_counter
++;
5421 ret
= CallWindowProcA(old_static_proc
, hwnd
, message
, wParam
, lParam
);
5422 defwndproc_counter
--;
5427 static void subclass_static(void)
5431 if (!GetClassInfoA(0, "static", &cls
)) assert(0);
5433 old_static_proc
= cls
.lpfnWndProc
;
5435 cls
.hInstance
= GetModuleHandle(0);
5436 cls
.lpfnWndProc
= static_hook_proc
;
5437 cls
.lpszClassName
= "my_static_class";
5438 UnregisterClass(cls
.lpszClassName
, cls
.hInstance
);
5439 if (!RegisterClassA(&cls
)) assert(0);
5442 static void test_static_messages(void)
5444 /* FIXME: make as comprehensive as the button message test */
5449 const struct message
*setfont
;
5451 { SS_LEFT
, DLGC_STATIC
,
5452 WmSetFontStaticSeq
}
5460 for (i
= 0; i
< sizeof(static_ctrl
)/sizeof(static_ctrl
[0]); i
++)
5462 hwnd
= CreateWindowExA(0, "my_static_class", "test", static_ctrl
[i
].style
| WS_POPUP
,
5463 0, 0, 50, 14, 0, 0, 0, NULL
);
5464 ok(hwnd
!= 0, "Failed to create static window\n");
5466 dlg_code
= SendMessageA(hwnd
, WM_GETDLGCODE
, 0, 0);
5467 ok(dlg_code
== static_ctrl
[i
].dlg_code
, "%u: wrong dlg_code %08x\n", i
, dlg_code
);
5469 ShowWindow(hwnd
, SW_SHOW
);
5474 trace("static style %08x\n", static_ctrl
[i
].style
);
5475 SendMessage(hwnd
, WM_SETFONT
, (WPARAM
)GetStockObject(DEFAULT_GUI_FONT
), TRUE
);
5476 ok_sequence(static_ctrl
[i
].setfont
, "WM_SETFONT on a static", FALSE
);
5478 DestroyWindow(hwnd
);
5482 /****************** ComboBox message test *************************/
5483 #define ID_COMBOBOX 0x000f
5485 static const struct message WmKeyDownComboSeq
[] =
5487 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_DOWN
, 0 },
5488 { WM_COMMAND
, sent
|wparam
|defwinproc
, MAKEWPARAM(1000, LBN_SELCHANGE
) },
5489 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_COMBOBOX
, CBN_SELENDOK
) },
5490 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_COMBOBOX
, CBN_SELCHANGE
) },
5491 { WM_CTLCOLOREDIT
, sent
|parent
},
5492 { WM_KEYUP
, sent
|wparam
|lparam
, VK_DOWN
, 0 },
5496 static WNDPROC old_combobox_proc
;
5498 static LRESULT CALLBACK
combobox_hook_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
5500 static long defwndproc_counter
= 0;
5502 struct recvd_message msg
;
5504 /* do not log painting messages */
5505 if (message
!= WM_PAINT
&&
5506 message
!= WM_NCPAINT
&&
5507 message
!= WM_SYNCPAINT
&&
5508 message
!= WM_ERASEBKGND
&&
5509 message
!= WM_NCHITTEST
&&
5510 message
!= WM_GETTEXT
&&
5511 !ignore_message( message
))
5514 msg
.message
= message
;
5515 msg
.flags
= sent
|wparam
|lparam
;
5516 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
5517 msg
.wParam
= wParam
;
5518 msg
.lParam
= lParam
;
5519 msg
.descr
= "combo";
5523 defwndproc_counter
++;
5524 ret
= CallWindowProcA(old_combobox_proc
, hwnd
, message
, wParam
, lParam
);
5525 defwndproc_counter
--;
5530 static void subclass_combobox(void)
5534 if (!GetClassInfoA(0, "ComboBox", &cls
)) assert(0);
5536 old_combobox_proc
= cls
.lpfnWndProc
;
5538 cls
.hInstance
= GetModuleHandle(0);
5539 cls
.lpfnWndProc
= combobox_hook_proc
;
5540 cls
.lpszClassName
= "my_combobox_class";
5541 UnregisterClass(cls
.lpszClassName
, cls
.hInstance
);
5542 if (!RegisterClassA(&cls
)) assert(0);
5545 static void test_combobox_messages(void)
5550 subclass_combobox();
5552 parent
= CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
5553 100, 100, 200, 200, 0, 0, 0, NULL
);
5554 ok(parent
!= 0, "Failed to create parent window\n");
5557 combo
= CreateWindowEx(0, "my_combobox_class", "test", WS_CHILD
| WS_VISIBLE
| CBS_DROPDOWNLIST
| CBS_HASSTRINGS
,
5558 0, 0, 100, 150, parent
, (HMENU
)ID_COMBOBOX
, 0, NULL
);
5559 ok(combo
!= 0, "Failed to create combobox window\n");
5561 UpdateWindow(combo
);
5563 ret
= SendMessage(combo
, WM_GETDLGCODE
, 0, 0);
5564 ok(ret
== (DLGC_WANTCHARS
| DLGC_WANTARROWS
), "wrong dlg_code %08lx\n", ret
);
5566 ret
= SendMessage(combo
, CB_ADDSTRING
, 0, (LPARAM
)"item 0");
5567 ok(ret
== 0, "expected 0, got %ld\n", ret
);
5568 ret
= SendMessage(combo
, CB_ADDSTRING
, 0, (LPARAM
)"item 1");
5569 ok(ret
== 1, "expected 1, got %ld\n", ret
);
5570 ret
= SendMessage(combo
, CB_ADDSTRING
, 0, (LPARAM
)"item 2");
5571 ok(ret
== 2, "expected 2, got %ld\n", ret
);
5573 SendMessage(combo
, CB_SETCURSEL
, 0, 0);
5577 log_all_parent_messages
++;
5578 SendMessage(combo
, WM_KEYDOWN
, VK_DOWN
, 0);
5579 SendMessage(combo
, WM_KEYUP
, VK_DOWN
, 0);
5580 log_all_parent_messages
--;
5581 ok_sequence(WmKeyDownComboSeq
, "WM_KEYDOWN/VK_DOWN on a ComboBox", FALSE
);
5583 DestroyWindow(combo
);
5584 DestroyWindow(parent
);
5587 /****************** WM_IME_KEYDOWN message test *******************/
5589 static const struct message WmImeKeydownMsgSeq_0
[] =
5591 { WM_IME_KEYDOWN
, wparam
, VK_RETURN
},
5592 { WM_CHAR
, wparam
, 'A' },
5596 static const struct message WmImeKeydownMsgSeq_1
[] =
5598 { WM_KEYDOWN
, optional
|wparam
, VK_RETURN
},
5599 { WM_CHAR
, optional
|wparam
, VK_RETURN
},
5603 static LRESULT WINAPI
wmime_keydown_procA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
5605 struct recvd_message msg
;
5608 msg
.message
= message
;
5609 msg
.flags
= wparam
|lparam
;
5610 msg
.wParam
= wParam
;
5611 msg
.lParam
= lParam
;
5612 msg
.descr
= "wmime_keydown";
5615 return DefWindowProcA(hwnd
, message
, wParam
, lParam
);
5618 static void register_wmime_keydown_class(void)
5622 ZeroMemory(&cls
, sizeof(WNDCLASSA
));
5623 cls
.lpfnWndProc
= wmime_keydown_procA
;
5624 cls
.hInstance
= GetModuleHandleA(0);
5625 cls
.lpszClassName
= "wmime_keydown_class";
5626 if (!RegisterClassA(&cls
)) assert(0);
5629 static void test_wmime_keydown_message(void)
5634 trace("Message sequences by WM_IME_KEYDOWN\n");
5636 register_wmime_keydown_class();
5637 hwnd
= CreateWindowExA(0, "wmime_keydown_class", NULL
, WS_OVERLAPPEDWINDOW
,
5638 CW_USEDEFAULT
, CW_USEDEFAULT
, 300, 300, 0,
5643 SendMessage(hwnd
, WM_IME_KEYDOWN
, VK_RETURN
, 0x1c0001);
5644 SendMessage(hwnd
, WM_CHAR
, 'A', 1);
5645 ok_sequence(WmImeKeydownMsgSeq_0
, "WM_IME_KEYDOWN 0", FALSE
);
5647 while ( PeekMessage(&msg
, 0, 0, 0, PM_REMOVE
) )
5649 TranslateMessage(&msg
);
5650 DispatchMessage(&msg
);
5652 ok_sequence(WmImeKeydownMsgSeq_1
, "WM_IME_KEYDOWN 1", FALSE
);
5654 DestroyWindow(hwnd
);
5657 /************* painting message test ********************/
5659 void dump_region(HRGN hrgn
)
5662 RGNDATA
*data
= NULL
;
5667 printf( "null region\n" );
5670 if (!(size
= GetRegionData( hrgn
, 0, NULL
))) return;
5671 if (!(data
= HeapAlloc( GetProcessHeap(), 0, size
))) return;
5672 GetRegionData( hrgn
, size
, data
);
5673 printf("%d rects:", data
->rdh
.nCount
);
5674 for (i
= 0, rect
= (RECT
*)data
->Buffer
; i
< data
->rdh
.nCount
; i
++, rect
++)
5675 printf( " (%d,%d)-(%d,%d)", rect
->left
, rect
->top
, rect
->right
, rect
->bottom
);
5677 HeapFree( GetProcessHeap(), 0, data
);
5680 static void check_update_rgn( HWND hwnd
, HRGN hrgn
)
5684 HRGN tmp
= CreateRectRgn( 0, 0, 0, 0 );
5685 HRGN update
= CreateRectRgn( 0, 0, 0, 0 );
5687 ret
= GetUpdateRgn( hwnd
, update
, FALSE
);
5688 ok( ret
!= ERROR
, "GetUpdateRgn failed\n" );
5689 if (ret
== NULLREGION
)
5691 ok( !hrgn
, "Update region shouldn't be empty\n" );
5695 if (CombineRgn( tmp
, hrgn
, update
, RGN_XOR
) != NULLREGION
)
5697 ok( 0, "Regions are different\n" );
5698 if (winetest_debug
> 0)
5700 printf( "Update region: " );
5701 dump_region( update
);
5702 printf( "Wanted region: " );
5703 dump_region( hrgn
);
5707 GetRgnBox( update
, &r1
);
5708 GetUpdateRect( hwnd
, &r2
, FALSE
);
5709 ok( r1
.left
== r2
.left
&& r1
.top
== r2
.top
&& r1
.right
== r2
.right
&& r1
.bottom
== r2
.bottom
,
5710 "Rectangles are different: %d,%d-%d,%d / %d,%d-%d,%d\n",
5711 r1
.left
, r1
.top
, r1
.right
, r1
.bottom
, r2
.left
, r2
.top
, r2
.right
, r2
.bottom
);
5713 DeleteObject( tmp
);
5714 DeleteObject( update
);
5717 static const struct message WmInvalidateRgn
[] = {
5718 { WM_NCPAINT
, sent
},
5719 { WM_GETTEXT
, sent
|defwinproc
|optional
},
5723 static const struct message WmGetUpdateRect
[] = {
5724 { WM_NCPAINT
, sent
},
5725 { WM_GETTEXT
, sent
|defwinproc
|optional
},
5730 static const struct message WmInvalidateFull
[] = {
5731 { WM_NCPAINT
, sent
|wparam
, 1 },
5732 { WM_GETTEXT
, sent
|defwinproc
|optional
},
5736 static const struct message WmInvalidateErase
[] = {
5737 { WM_NCPAINT
, sent
|wparam
, 1 },
5738 { WM_GETTEXT
, sent
|defwinproc
|optional
},
5739 { WM_ERASEBKGND
, sent
},
5743 static const struct message WmInvalidatePaint
[] = {
5745 { WM_NCPAINT
, sent
|wparam
|beginpaint
, 1 },
5746 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
5750 static const struct message WmInvalidateErasePaint
[] = {
5752 { WM_NCPAINT
, sent
|wparam
|beginpaint
, 1 },
5753 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
5754 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
5758 static const struct message WmInvalidateErasePaint2
[] = {
5760 { WM_NCPAINT
, sent
|beginpaint
},
5761 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
5762 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
5766 static const struct message WmErase
[] = {
5767 { WM_ERASEBKGND
, sent
},
5771 static const struct message WmPaint
[] = {
5776 static const struct message WmParentOnlyPaint
[] = {
5777 { WM_PAINT
, sent
|parent
},
5781 static const struct message WmInvalidateParent
[] = {
5782 { WM_NCPAINT
, sent
|parent
},
5783 { WM_GETTEXT
, sent
|defwinproc
|parent
|optional
},
5784 { WM_ERASEBKGND
, sent
|parent
},
5788 static const struct message WmInvalidateParentChild
[] = {
5789 { WM_NCPAINT
, sent
|parent
},
5790 { WM_GETTEXT
, sent
|defwinproc
|parent
|optional
},
5791 { WM_ERASEBKGND
, sent
|parent
},
5792 { WM_NCPAINT
, sent
},
5793 { WM_GETTEXT
, sent
|defwinproc
|optional
},
5794 { WM_ERASEBKGND
, sent
},
5798 static const struct message WmInvalidateParentChild2
[] = {
5799 { WM_ERASEBKGND
, sent
|parent
},
5800 { WM_NCPAINT
, sent
},
5801 { WM_GETTEXT
, sent
|defwinproc
|optional
},
5802 { WM_ERASEBKGND
, sent
},
5806 static const struct message WmParentPaint
[] = {
5807 { WM_PAINT
, sent
|parent
},
5812 static const struct message WmParentPaintNc
[] = {
5813 { WM_PAINT
, sent
|parent
},
5815 { WM_NCPAINT
, sent
|beginpaint
},
5816 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
5817 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
5821 static const struct message WmChildPaintNc
[] = {
5823 { WM_NCPAINT
, sent
|beginpaint
},
5824 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
5825 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
5829 static const struct message WmParentErasePaint
[] = {
5830 { WM_PAINT
, sent
|parent
},
5831 { WM_NCPAINT
, sent
|parent
|beginpaint
},
5832 { WM_GETTEXT
, sent
|parent
|beginpaint
|defwinproc
|optional
},
5833 { WM_ERASEBKGND
, sent
|parent
|beginpaint
|optional
},
5835 { WM_NCPAINT
, sent
|beginpaint
},
5836 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
5837 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
5841 static const struct message WmParentOnlyNcPaint
[] = {
5842 { WM_PAINT
, sent
|parent
},
5843 { WM_NCPAINT
, sent
|parent
|beginpaint
},
5844 { WM_GETTEXT
, sent
|parent
|beginpaint
|defwinproc
|optional
},
5848 static const struct message WmSetParentStyle
[] = {
5849 { WM_STYLECHANGING
, sent
|parent
},
5850 { WM_STYLECHANGED
, sent
|parent
},
5854 static void test_paint_messages(void)
5860 HWND hparent
, hchild
;
5861 HRGN hrgn
= CreateRectRgn( 0, 0, 0, 0 );
5862 HRGN hrgn2
= CreateRectRgn( 0, 0, 0, 0 );
5863 HWND hwnd
= CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW
,
5864 100, 100, 200, 200, 0, 0, 0, NULL
);
5865 ok (hwnd
!= 0, "Failed to create overlapped window\n");
5867 ShowWindow( hwnd
, SW_SHOW
);
5868 UpdateWindow( hwnd
);
5872 check_update_rgn( hwnd
, 0 );
5873 SetRectRgn( hrgn
, 10, 10, 20, 20 );
5874 ret
= RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
);
5875 ok(ret
, "RedrawWindow returned %d instead of TRUE\n", ret
);
5876 check_update_rgn( hwnd
, hrgn
);
5877 SetRectRgn( hrgn2
, 20, 20, 30, 30 );
5878 ret
= RedrawWindow( hwnd
, NULL
, hrgn2
, RDW_INVALIDATE
);
5879 ok(ret
, "RedrawWindow returned %d instead of TRUE\n", ret
);
5880 CombineRgn( hrgn
, hrgn
, hrgn2
, RGN_OR
);
5881 check_update_rgn( hwnd
, hrgn
);
5882 /* validate everything */
5883 ret
= RedrawWindow( hwnd
, NULL
, NULL
, RDW_VALIDATE
);
5884 ok(ret
, "RedrawWindow returned %d instead of TRUE\n", ret
);
5885 check_update_rgn( hwnd
, 0 );
5887 /* test empty region */
5888 SetRectRgn( hrgn
, 10, 10, 10, 15 );
5889 ret
= RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
);
5890 ok(ret
, "RedrawWindow returned %d instead of TRUE\n", ret
);
5891 check_update_rgn( hwnd
, 0 );
5892 /* test empty rect */
5893 SetRect( &rect
, 10, 10, 10, 15 );
5894 ret
= RedrawWindow( hwnd
, &rect
, NULL
, RDW_INVALIDATE
);
5895 ok(ret
, "RedrawWindow returned %d instead of TRUE\n", ret
);
5896 check_update_rgn( hwnd
, 0 );
5898 /* flush pending messages */
5902 GetClientRect( hwnd
, &rect
);
5903 SetRectRgn( hrgn
, 0, 0, rect
.right
- rect
.left
, rect
.bottom
- rect
.top
);
5904 /* MSDN: if hwnd parameter is NULL, InvalidateRect invalidates and redraws
5905 * all windows and sends WM_ERASEBKGND and WM_NCPAINT.
5907 trace("testing InvalidateRect(0, NULL, FALSE)\n");
5908 SetRectEmpty( &rect
);
5909 ok(InvalidateRect(0, &rect
, FALSE
), "InvalidateRect(0, &rc, FALSE) should fail\n");
5910 check_update_rgn( hwnd
, hrgn
);
5911 ok_sequence( WmInvalidateErase
, "InvalidateErase", FALSE
);
5913 ok_sequence( WmPaint
, "Paint", FALSE
);
5914 RedrawWindow( hwnd
, NULL
, NULL
, RDW_VALIDATE
);
5915 check_update_rgn( hwnd
, 0 );
5917 /* MSDN: if hwnd parameter is NULL, ValidateRect invalidates and redraws
5918 * all windows and sends WM_ERASEBKGND and WM_NCPAINT.
5920 trace("testing ValidateRect(0, NULL)\n");
5921 SetRectEmpty( &rect
);
5922 if (ValidateRect(0, &rect
)) /* not supported on Win9x */
5924 check_update_rgn( hwnd
, hrgn
);
5925 ok_sequence( WmInvalidateErase
, "InvalidateErase", FALSE
);
5927 ok_sequence( WmPaint
, "Paint", FALSE
);
5928 RedrawWindow( hwnd
, NULL
, NULL
, RDW_VALIDATE
);
5929 check_update_rgn( hwnd
, 0 );
5932 trace("testing InvalidateRgn(0, NULL, FALSE)\n");
5933 SetLastError(0xdeadbeef);
5934 ok(!InvalidateRgn(0, NULL
, FALSE
), "InvalidateRgn(0, NULL, FALSE) should fail\n");
5935 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
|| GetLastError() == 0xdeadbeef,
5936 "wrong error code %d\n", GetLastError());
5937 check_update_rgn( hwnd
, 0 );
5939 ok_sequence( WmEmptySeq
, "WmEmptySeq", FALSE
);
5941 trace("testing ValidateRgn(0, NULL)\n");
5942 SetLastError(0xdeadbeef);
5943 ok(!ValidateRgn(0, NULL
), "ValidateRgn(0, NULL) should fail\n");
5944 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
||
5945 broken( GetLastError() == 0xdeadbeef ) /* win9x */,
5946 "wrong error code %d\n", GetLastError());
5947 check_update_rgn( hwnd
, 0 );
5949 ok_sequence( WmEmptySeq
, "WmEmptySeq", FALSE
);
5951 /* now with frame */
5952 SetRectRgn( hrgn
, -5, -5, 20, 20 );
5954 /* flush pending messages */
5957 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_FRAME
);
5958 ok_sequence( WmEmptySeq
, "EmptySeq", FALSE
);
5960 SetRectRgn( hrgn
, 0, 0, 20, 20 ); /* GetUpdateRgn clips to client area */
5961 check_update_rgn( hwnd
, hrgn
);
5964 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASENOW
);
5965 ok_sequence( WmInvalidateRgn
, "InvalidateRgn", FALSE
);
5968 RedrawWindow( hwnd
, NULL
, NULL
, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASENOW
);
5969 ok_sequence( WmInvalidateFull
, "InvalidateFull", FALSE
);
5971 GetClientRect( hwnd
, &rect
);
5972 SetRectRgn( hrgn
, rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
5973 check_update_rgn( hwnd
, hrgn
);
5976 RedrawWindow( hwnd
, NULL
, NULL
, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASE
| RDW_ERASENOW
);
5977 ok_sequence( WmInvalidateErase
, "InvalidateErase", FALSE
);
5980 RedrawWindow( hwnd
, NULL
, NULL
, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASENOW
| RDW_UPDATENOW
);
5981 ok_sequence( WmInvalidatePaint
, "InvalidatePaint", FALSE
);
5982 check_update_rgn( hwnd
, 0 );
5985 RedrawWindow( hwnd
, NULL
, NULL
, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASE
| RDW_UPDATENOW
);
5986 ok_sequence( WmInvalidateErasePaint
, "InvalidateErasePaint", FALSE
);
5987 check_update_rgn( hwnd
, 0 );
5990 SetRectRgn( hrgn
, 0, 0, 100, 100 );
5991 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
);
5992 SetRectRgn( hrgn
, 0, 0, 50, 100 );
5993 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_VALIDATE
);
5994 SetRectRgn( hrgn
, 50, 0, 100, 100 );
5995 check_update_rgn( hwnd
, hrgn
);
5996 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_VALIDATE
| RDW_ERASENOW
);
5997 ok_sequence( WmEmptySeq
, "EmptySeq", FALSE
); /* must not generate messages, everything is valid */
5998 check_update_rgn( hwnd
, 0 );
6001 SetRectRgn( hrgn
, 0, 0, 100, 100 );
6002 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_ERASE
);
6003 SetRectRgn( hrgn
, 0, 0, 100, 50 );
6004 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_VALIDATE
| RDW_ERASENOW
);
6005 ok_sequence( WmErase
, "Erase", FALSE
);
6006 SetRectRgn( hrgn
, 0, 50, 100, 100 );
6007 check_update_rgn( hwnd
, hrgn
);
6010 SetRectRgn( hrgn
, 0, 0, 100, 100 );
6011 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_ERASE
);
6012 SetRectRgn( hrgn
, 0, 0, 50, 50 );
6013 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_VALIDATE
| RDW_NOERASE
| RDW_UPDATENOW
);
6014 ok_sequence( WmPaint
, "Paint", FALSE
);
6017 SetRectRgn( hrgn
, -4, -4, -2, -2 );
6018 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_FRAME
);
6019 SetRectRgn( hrgn
, -200, -200, -198, -198 );
6020 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_VALIDATE
| RDW_NOFRAME
| RDW_ERASENOW
);
6021 ok_sequence( WmEmptySeq
, "EmptySeq", FALSE
);
6024 SetRectRgn( hrgn
, -4, -4, -2, -2 );
6025 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_FRAME
);
6026 SetRectRgn( hrgn
, -4, -4, -3, -3 );
6027 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_VALIDATE
| RDW_NOFRAME
);
6028 SetRectRgn( hrgn
, 0, 0, 1, 1 );
6029 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_UPDATENOW
);
6030 ok_sequence( WmPaint
, "Paint", FALSE
);
6033 SetRectRgn( hrgn
, -4, -4, -1, -1 );
6034 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_FRAME
);
6035 RedrawWindow( hwnd
, NULL
, 0, RDW_ERASENOW
);
6036 /* make sure no WM_PAINT was generated */
6038 ok_sequence( WmInvalidateRgn
, "InvalidateRgn", FALSE
);
6041 SetRectRgn( hrgn
, -4, -4, -1, -1 );
6042 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_FRAME
);
6043 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
))
6045 if (msg
.hwnd
== hwnd
&& msg
.message
== WM_PAINT
)
6047 /* GetUpdateRgn must return empty region since only nonclient area is invalidated */
6048 INT ret
= GetUpdateRgn( hwnd
, hrgn
, FALSE
);
6049 ok( ret
== NULLREGION
, "Invalid GetUpdateRgn result %d\n", ret
);
6050 ret
= GetUpdateRect( hwnd
, &rect
, FALSE
);
6051 ok( ret
, "Invalid GetUpdateRect result %d\n", ret
);
6052 /* this will send WM_NCPAINT and validate the non client area */
6053 ret
= GetUpdateRect( hwnd
, &rect
, TRUE
);
6054 ok( !ret
, "Invalid GetUpdateRect result %d\n", ret
);
6056 DispatchMessage( &msg
);
6058 ok_sequence( WmGetUpdateRect
, "GetUpdateRect", FALSE
);
6060 DestroyWindow( hwnd
);
6062 /* now test with a child window */
6064 hparent
= CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW
,
6065 100, 100, 200, 200, 0, 0, 0, NULL
);
6066 ok (hparent
!= 0, "Failed to create parent window\n");
6068 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
| WS_VISIBLE
| WS_BORDER
,
6069 10, 10, 100, 100, hparent
, 0, 0, NULL
);
6070 ok (hchild
!= 0, "Failed to create child window\n");
6072 ShowWindow( hparent
, SW_SHOW
);
6073 UpdateWindow( hparent
);
6074 UpdateWindow( hchild
);
6077 log_all_parent_messages
++;
6079 SetRect( &rect
, 0, 0, 50, 50 );
6080 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
6081 RedrawWindow( hparent
, NULL
, 0, RDW_ERASENOW
| RDW_ALLCHILDREN
);
6082 ok_sequence( WmInvalidateParentChild
, "InvalidateParentChild", FALSE
);
6084 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
6086 MapWindowPoints( hchild
, hparent
, &pt
, 1 );
6087 SetRectRgn( hrgn
, 0, 0, 50 - pt
.x
, 50 - pt
.y
);
6088 check_update_rgn( hchild
, hrgn
);
6089 SetRectRgn( hrgn
, 0, 0, 50, 50 );
6090 check_update_rgn( hparent
, hrgn
);
6091 RedrawWindow( hparent
, NULL
, 0, RDW_ERASENOW
);
6092 ok_sequence( WmInvalidateParent
, "InvalidateParent", FALSE
);
6093 RedrawWindow( hchild
, NULL
, 0, RDW_ERASENOW
);
6094 ok_sequence( WmEmptySeq
, "EraseNow child", FALSE
);
6097 ok_sequence( WmParentPaintNc
, "WmParentPaintNc", FALSE
);
6099 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
| RDW_ALLCHILDREN
);
6100 RedrawWindow( hparent
, NULL
, 0, RDW_ERASENOW
);
6101 ok_sequence( WmInvalidateParent
, "InvalidateParent2", FALSE
);
6102 RedrawWindow( hchild
, NULL
, 0, RDW_ERASENOW
);
6103 ok_sequence( WmEmptySeq
, "EraseNow child", FALSE
);
6105 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
);
6106 RedrawWindow( hparent
, NULL
, 0, RDW_ERASENOW
| RDW_ALLCHILDREN
);
6107 ok_sequence( WmInvalidateParentChild2
, "InvalidateParentChild2", FALSE
);
6109 SetWindowLong( hparent
, GWL_STYLE
, GetWindowLong(hparent
,GWL_STYLE
) | WS_CLIPCHILDREN
);
6111 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
| RDW_ALLCHILDREN
);
6112 RedrawWindow( hparent
, NULL
, 0, RDW_ERASENOW
);
6113 ok_sequence( WmInvalidateParentChild
, "InvalidateParentChild3", FALSE
);
6115 /* flush all paint messages */
6119 /* RDW_UPDATENOW on child with WS_CLIPCHILDREN doesn't change corresponding parent area */
6120 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
| RDW_ALLCHILDREN
);
6121 SetRectRgn( hrgn
, 0, 0, 50, 50 );
6122 check_update_rgn( hparent
, hrgn
);
6123 RedrawWindow( hchild
, NULL
, 0, RDW_UPDATENOW
);
6124 ok_sequence( WmInvalidateErasePaint2
, "WmInvalidateErasePaint2", FALSE
);
6125 SetRectRgn( hrgn
, 0, 0, 50, 50 );
6126 check_update_rgn( hparent
, hrgn
);
6128 /* flush all paint messages */
6130 SetWindowLong( hparent
, GWL_STYLE
, GetWindowLong(hparent
,GWL_STYLE
) & ~WS_CLIPCHILDREN
);
6133 /* RDW_UPDATENOW on child without WS_CLIPCHILDREN will validate corresponding parent area */
6134 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
6135 SetRectRgn( hrgn
, 0, 0, 50, 50 );
6136 check_update_rgn( hparent
, hrgn
);
6137 RedrawWindow( hchild
, NULL
, 0, RDW_UPDATENOW
);
6138 ok_sequence( WmInvalidateErasePaint2
, "WmInvalidateErasePaint2", FALSE
);
6139 SetRectRgn( hrgn2
, 10, 10, 50, 50 );
6140 CombineRgn( hrgn
, hrgn
, hrgn2
, RGN_DIFF
);
6141 check_update_rgn( hparent
, hrgn
);
6142 /* flush all paint messages */
6146 /* same as above but parent gets completely validated */
6147 SetRect( &rect
, 20, 20, 30, 30 );
6148 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
6149 SetRectRgn( hrgn
, 20, 20, 30, 30 );
6150 check_update_rgn( hparent
, hrgn
);
6151 RedrawWindow( hchild
, NULL
, 0, RDW_UPDATENOW
);
6152 ok_sequence( WmInvalidateErasePaint2
, "WmInvalidateErasePaint2", FALSE
);
6153 check_update_rgn( hparent
, 0 ); /* no update region */
6155 ok_sequence( WmEmptySeq
, "WmEmpty", FALSE
); /* and no paint messages */
6157 /* make sure RDW_VALIDATE on child doesn't have the same effect */
6159 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
6160 SetRectRgn( hrgn
, 20, 20, 30, 30 );
6161 check_update_rgn( hparent
, hrgn
);
6162 RedrawWindow( hchild
, NULL
, 0, RDW_VALIDATE
| RDW_NOERASE
);
6163 SetRectRgn( hrgn
, 20, 20, 30, 30 );
6164 check_update_rgn( hparent
, hrgn
);
6166 /* same as above but normal WM_PAINT doesn't validate parent */
6168 SetRect( &rect
, 20, 20, 30, 30 );
6169 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
6170 SetRectRgn( hrgn
, 20, 20, 30, 30 );
6171 check_update_rgn( hparent
, hrgn
);
6172 /* no WM_PAINT in child while parent still pending */
6173 while (PeekMessage( &msg
, hchild
, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
6174 ok_sequence( WmEmptySeq
, "No WM_PAINT", FALSE
);
6175 while (PeekMessage( &msg
, hparent
, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
6176 ok_sequence( WmParentErasePaint
, "WmParentErasePaint", FALSE
);
6179 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
6180 /* no WM_PAINT in child while parent still pending */
6181 while (PeekMessage( &msg
, hchild
, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
6182 ok_sequence( WmEmptySeq
, "No WM_PAINT", FALSE
);
6183 RedrawWindow( hparent
, &rect
, 0, RDW_VALIDATE
| RDW_NOERASE
| RDW_NOCHILDREN
);
6184 /* now that parent is valid child should get WM_PAINT */
6185 while (PeekMessage( &msg
, hchild
, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
6186 ok_sequence( WmInvalidateErasePaint2
, "WmInvalidateErasePaint2", FALSE
);
6187 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
6188 ok_sequence( WmEmptySeq
, "No other message", FALSE
);
6190 /* same thing with WS_CLIPCHILDREN in parent */
6192 SetWindowLong( hparent
, GWL_STYLE
, GetWindowLong(hparent
,GWL_STYLE
) | WS_CLIPCHILDREN
);
6193 ok_sequence( WmSetParentStyle
, "WmSetParentStyle", FALSE
);
6194 /* changing style invalidates non client area, but we need to invalidate something else to see it */
6195 RedrawWindow( hparent
, &rect
, 0, RDW_UPDATENOW
);
6196 ok_sequence( WmEmptySeq
, "No message", FALSE
);
6197 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_UPDATENOW
);
6198 ok_sequence( WmParentOnlyNcPaint
, "WmParentOnlyNcPaint", FALSE
);
6201 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_ALLCHILDREN
);
6202 SetRectRgn( hrgn
, 20, 20, 30, 30 );
6203 check_update_rgn( hparent
, hrgn
);
6204 /* no WM_PAINT in child while parent still pending */
6205 while (PeekMessage( &msg
, hchild
, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
6206 ok_sequence( WmEmptySeq
, "No WM_PAINT", FALSE
);
6207 /* WM_PAINT in parent first */
6208 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
6209 ok_sequence( WmParentPaintNc
, "WmParentPaintNc2", FALSE
);
6211 /* no RDW_ERASE in parent still causes RDW_ERASE and RDW_FRAME in child */
6213 SetRect( &rect
, 0, 0, 30, 30 );
6214 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ALLCHILDREN
);
6215 SetRectRgn( hrgn
, 0, 0, 30, 30 );
6216 check_update_rgn( hparent
, hrgn
);
6218 ok_sequence( WmParentPaintNc
, "WmParentPaintNc3", FALSE
);
6220 /* validate doesn't cause RDW_NOERASE or RDW_NOFRAME in child */
6222 SetRect( &rect
, -10, 0, 30, 30 );
6223 RedrawWindow( hchild
, &rect
, 0, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASE
);
6224 SetRect( &rect
, 0, 0, 20, 20 );
6225 RedrawWindow( hparent
, &rect
, 0, RDW_VALIDATE
| RDW_ALLCHILDREN
);
6226 RedrawWindow( hparent
, NULL
, 0, RDW_UPDATENOW
);
6227 ok_sequence( WmChildPaintNc
, "WmChildPaintNc", FALSE
);
6229 /* validate doesn't cause RDW_NOERASE or RDW_NOFRAME in child */
6231 SetRect( &rect
, -10, 0, 30, 30 );
6232 RedrawWindow( hchild
, &rect
, 0, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASE
);
6233 SetRect( &rect
, 0, 0, 100, 100 );
6234 RedrawWindow( hparent
, &rect
, 0, RDW_VALIDATE
| RDW_ALLCHILDREN
);
6235 RedrawWindow( hparent
, NULL
, 0, RDW_UPDATENOW
);
6236 ok_sequence( WmEmptySeq
, "WmChildPaintNc2", FALSE
);
6237 RedrawWindow( hparent
, NULL
, 0, RDW_ERASENOW
);
6238 ok_sequence( WmEmptySeq
, "WmChildPaintNc3", FALSE
);
6240 /* test RDW_INTERNALPAINT behavior */
6243 RedrawWindow( hparent
, NULL
, 0, RDW_INTERNALPAINT
| RDW_NOCHILDREN
);
6245 ok_sequence( WmParentOnlyPaint
, "WmParentOnlyPaint", FALSE
);
6247 RedrawWindow( hparent
, NULL
, 0, RDW_INTERNALPAINT
| RDW_ALLCHILDREN
);
6249 ok_sequence( WmParentPaint
, "WmParentPaint", FALSE
);
6251 RedrawWindow( hparent
, NULL
, 0, RDW_INTERNALPAINT
);
6253 ok_sequence( WmParentOnlyPaint
, "WmParentOnlyPaint", FALSE
);
6255 assert( GetWindowLong(hparent
, GWL_STYLE
) & WS_CLIPCHILDREN
);
6256 UpdateWindow( hparent
);
6259 trace("testing SWP_FRAMECHANGED on parent with WS_CLIPCHILDREN\n");
6260 RedrawWindow( hchild
, NULL
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
6261 SetWindowPos( hparent
, 0, 0, 0, 0, 0, SWP_NOSIZE
| SWP_NOMOVE
|
6262 SWP_NOACTIVATE
| SWP_NOZORDER
| SWP_FRAMECHANGED
);
6264 ok_sequence(WmSWP_FrameChanged_clip
, "SetWindowPos:FrameChanged_clip", FALSE
);
6266 UpdateWindow( hparent
);
6269 trace("testing SWP_FRAMECHANGED|SWP_DEFERERASE on parent with WS_CLIPCHILDREN\n");
6270 RedrawWindow( hchild
, NULL
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
6271 SetWindowPos( hparent
, 0, 0, 0, 0, 0, SWP_NOSIZE
| SWP_NOMOVE
| SWP_DEFERERASE
|
6272 SWP_NOACTIVATE
| SWP_NOZORDER
| SWP_FRAMECHANGED
);
6274 ok_sequence(WmSWP_FrameChangedDeferErase
, "SetWindowPos:FrameChangedDeferErase", FALSE
);
6276 SetWindowLong( hparent
, GWL_STYLE
, GetWindowLong(hparent
,GWL_STYLE
) & ~WS_CLIPCHILDREN
);
6277 ok_sequence( WmSetParentStyle
, "WmSetParentStyle", FALSE
);
6278 RedrawWindow( hparent
, NULL
, 0, RDW_INTERNALPAINT
);
6280 ok_sequence( WmParentPaint
, "WmParentPaint", FALSE
);
6282 assert( !(GetWindowLong(hparent
, GWL_STYLE
) & WS_CLIPCHILDREN
) );
6283 UpdateWindow( hparent
);
6286 trace("testing SWP_FRAMECHANGED on parent without WS_CLIPCHILDREN\n");
6287 RedrawWindow( hchild
, NULL
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
6288 SetWindowPos( hparent
, 0, 0, 0, 0, 0, SWP_NOSIZE
| SWP_NOMOVE
|
6289 SWP_NOACTIVATE
| SWP_NOZORDER
| SWP_FRAMECHANGED
);
6291 ok_sequence(WmSWP_FrameChanged_noclip
, "SetWindowPos:FrameChanged_noclip", FALSE
);
6293 UpdateWindow( hparent
);
6296 trace("testing SWP_FRAMECHANGED|SWP_DEFERERASE on parent without WS_CLIPCHILDREN\n");
6297 RedrawWindow( hchild
, NULL
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
6298 SetWindowPos( hparent
, 0, 0, 0, 0, 0, SWP_NOSIZE
| SWP_NOMOVE
| SWP_DEFERERASE
|
6299 SWP_NOACTIVATE
| SWP_NOZORDER
| SWP_FRAMECHANGED
);
6301 ok_sequence(WmSWP_FrameChangedDeferErase
, "SetWindowPos:FrameChangedDeferErase", FALSE
);
6303 ok(GetWindowLong( hparent
, GWL_STYLE
) & WS_VISIBLE
, "parent should be visible\n");
6304 ok(GetWindowLong( hchild
, GWL_STYLE
) & WS_VISIBLE
, "child should be visible\n");
6306 UpdateWindow( hparent
);
6309 trace("testing SetWindowPos(-10000, -10000) on child\n");
6310 SetWindowPos( hchild
, 0, -10000, -10000, 0, 0, SWP_NOSIZE
| SWP_NOACTIVATE
| SWP_NOZORDER
);
6311 check_update_rgn( hchild
, 0 );
6314 #if 0 /* this one doesn't pass under Wine yet */
6315 UpdateWindow( hparent
);
6318 trace("testing ShowWindow(SW_MINIMIZE) on child\n");
6319 ShowWindow( hchild
, SW_MINIMIZE
);
6320 check_update_rgn( hchild
, 0 );
6324 UpdateWindow( hparent
);
6327 trace("testing SetWindowPos(-10000, -10000) on parent\n");
6328 SetWindowPos( hparent
, 0, -10000, -10000, 0, 0, SWP_NOSIZE
| SWP_NOACTIVATE
| SWP_NOZORDER
);
6329 check_update_rgn( hparent
, 0 );
6332 log_all_parent_messages
--;
6333 DestroyWindow( hparent
);
6334 ok(!IsWindow(hchild
), "child must be destroyed with its parent\n");
6336 /* tests for moving windows off-screen (needs simple WS_POPUP windows) */
6338 hparent
= CreateWindowExA(0, "TestParentClass", "Test parent", WS_POPUP
| WS_VISIBLE
,
6339 100, 100, 200, 200, 0, 0, 0, NULL
);
6340 ok (hparent
!= 0, "Failed to create parent window\n");
6342 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
| WS_VISIBLE
,
6343 10, 10, 100, 100, hparent
, 0, 0, NULL
);
6344 ok (hchild
!= 0, "Failed to create child window\n");
6346 ShowWindow( hparent
, SW_SHOW
);
6347 UpdateWindow( hparent
);
6348 UpdateWindow( hchild
);
6352 /* moving child outside of parent boundaries changes update region */
6353 SetRect( &rect
, 0, 0, 40, 40 );
6354 RedrawWindow( hchild
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
);
6355 SetRectRgn( hrgn
, 0, 0, 40, 40 );
6356 check_update_rgn( hchild
, hrgn
);
6357 MoveWindow( hchild
, -10, 10, 100, 100, FALSE
);
6358 SetRectRgn( hrgn
, 10, 0, 40, 40 );
6359 check_update_rgn( hchild
, hrgn
);
6360 MoveWindow( hchild
, -10, -10, 100, 100, FALSE
);
6361 SetRectRgn( hrgn
, 10, 10, 40, 40 );
6362 check_update_rgn( hchild
, hrgn
);
6364 /* moving parent off-screen does too */
6365 SetRect( &rect
, 0, 0, 100, 100 );
6366 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_NOCHILDREN
);
6367 SetRectRgn( hrgn
, 0, 0, 100, 100 );
6368 check_update_rgn( hparent
, hrgn
);
6369 SetRectRgn( hrgn
, 10, 10, 40, 40 );
6370 check_update_rgn( hchild
, hrgn
);
6371 MoveWindow( hparent
, -20, -20, 200, 200, FALSE
);
6372 SetRectRgn( hrgn
, 20, 20, 100, 100 );
6373 check_update_rgn( hparent
, hrgn
);
6374 SetRectRgn( hrgn
, 30, 30, 40, 40 );
6375 check_update_rgn( hchild
, hrgn
);
6377 /* invalidated region is cropped by the parent rects */
6378 SetRect( &rect
, 0, 0, 50, 50 );
6379 RedrawWindow( hchild
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
);
6380 SetRectRgn( hrgn
, 30, 30, 50, 50 );
6381 check_update_rgn( hchild
, hrgn
);
6383 DestroyWindow( hparent
);
6384 ok(!IsWindow(hchild
), "child must be destroyed with its parent\n");
6387 DeleteObject( hrgn
);
6388 DeleteObject( hrgn2
);
6399 static DWORD WINAPI
thread_proc(void *param
)
6402 struct wnd_event
*wnd_event
= param
;
6404 wnd_event
->hwnd
= CreateWindowExA(0, "TestWindowClass", "window caption text", WS_OVERLAPPEDWINDOW
,
6405 100, 100, 200, 200, 0, 0, 0, NULL
);
6406 ok(wnd_event
->hwnd
!= 0, "Failed to create overlapped window\n");
6408 SetEvent(wnd_event
->start_event
);
6410 while (GetMessage(&msg
, 0, 0, 0))
6412 TranslateMessage(&msg
);
6413 DispatchMessage(&msg
);
6416 ok(IsWindow(wnd_event
->hwnd
), "window should still exist\n");
6421 static DWORD CALLBACK
create_grand_child_thread( void *param
)
6423 struct wnd_event
*wnd_event
= param
;
6427 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child",
6428 WS_CHILD
| WS_VISIBLE
, 0, 0, 10, 10, wnd_event
->hwnd
, 0, 0, NULL
);
6429 ok (hchild
!= 0, "Failed to create child window\n");
6432 SetEvent( wnd_event
->start_event
);
6436 MsgWaitForMultipleObjects(0, NULL
, FALSE
, 1000, QS_ALLINPUT
);
6437 if (!IsWindow( hchild
)) break; /* will be destroyed when parent thread exits */
6438 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage(&msg
);
6443 static DWORD CALLBACK
create_child_thread( void *param
)
6445 struct wnd_event
*wnd_event
= param
;
6446 struct wnd_event child_event
;
6450 child_event
.hwnd
= CreateWindowExA(0, "TestWindowClass", "Test child",
6451 WS_CHILD
| WS_VISIBLE
, 0, 0, 10, 10, wnd_event
->hwnd
, 0, 0, NULL
);
6452 ok (child_event
.hwnd
!= 0, "Failed to create child window\n");
6453 SetFocus( child_event
.hwnd
);
6456 child_event
.start_event
= wnd_event
->start_event
;
6457 wnd_event
->grand_child
= CreateThread(NULL
, 0, create_grand_child_thread
, &child_event
, 0, &tid
);
6460 DWORD ret
= MsgWaitForMultipleObjects(1, &child_event
.start_event
, FALSE
, 1000, QS_SENDMESSAGE
);
6461 if (ret
!= 1) break;
6462 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage(&msg
);
6464 ret
= WaitForSingleObject( wnd_event
->stop_event
, 5000 );
6465 ok( !ret
, "WaitForSingleObject failed %x\n", ret
);
6469 static void test_interthread_messages(void)
6476 int len
, expected_len
;
6477 struct wnd_event wnd_event
;
6480 wnd_event
.start_event
= CreateEventW(NULL
, 0, 0, NULL
);
6481 if (!wnd_event
.start_event
)
6483 win_skip("skipping interthread message test under win9x\n");
6487 hThread
= CreateThread(NULL
, 0, thread_proc
, &wnd_event
, 0, &tid
);
6488 ok(hThread
!= NULL
, "CreateThread failed, error %d\n", GetLastError());
6490 ok(WaitForSingleObject(wnd_event
.start_event
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
6492 CloseHandle(wnd_event
.start_event
);
6494 SetLastError(0xdeadbeef);
6495 ok(!DestroyWindow(wnd_event
.hwnd
), "DestroyWindow succeded\n");
6496 ok(GetLastError() == ERROR_ACCESS_DENIED
|| GetLastError() == 0xdeadbeef,
6497 "wrong error code %d\n", GetLastError());
6499 proc
= (WNDPROC
)GetWindowLongPtrA(wnd_event
.hwnd
, GWLP_WNDPROC
);
6500 ok(proc
!= NULL
, "GetWindowLongPtrA(GWLP_WNDPROC) error %d\n", GetLastError());
6502 expected_len
= lstrlenA("window caption text");
6503 memset(buf
, 0, sizeof(buf
));
6504 SetLastError(0xdeadbeef);
6505 len
= CallWindowProcA(proc
, wnd_event
.hwnd
, WM_GETTEXT
, sizeof(buf
), (LPARAM
)buf
);
6506 ok(len
== expected_len
, "CallWindowProcA(WM_GETTEXT) error %d, len %d, expected len %d\n", GetLastError(), len
, expected_len
);
6507 ok(!lstrcmpA(buf
, "window caption text"), "window text mismatch\n");
6509 msg
.hwnd
= wnd_event
.hwnd
;
6510 msg
.message
= WM_GETTEXT
;
6511 msg
.wParam
= sizeof(buf
);
6512 msg
.lParam
= (LPARAM
)buf
;
6513 memset(buf
, 0, sizeof(buf
));
6514 SetLastError(0xdeadbeef);
6515 len
= DispatchMessageA(&msg
);
6516 ok((!len
&& GetLastError() == ERROR_MESSAGE_SYNC_ONLY
) || broken(len
), /* nt4 */
6517 "DispatchMessageA(WM_GETTEXT) succeded on another thread window: ret %d, error %d\n", len
, GetLastError());
6519 /* the following test causes an exception in user.exe under win9x */
6520 msg
.hwnd
= wnd_event
.hwnd
;
6521 msg
.message
= WM_TIMER
;
6523 msg
.lParam
= GetWindowLongPtrA(wnd_event
.hwnd
, GWLP_WNDPROC
);
6524 SetLastError(0xdeadbeef);
6525 len
= DispatchMessageA(&msg
);
6526 ok(!len
&& GetLastError() == 0xdeadbeef,
6527 "DispatchMessageA(WM_TIMER) failed on another thread window: ret %d, error %d\n", len
, GetLastError());
6529 ret
= PostMessageA(wnd_event
.hwnd
, WM_QUIT
, 0, 0);
6530 ok( ret
, "PostMessageA(WM_QUIT) error %d\n", GetLastError());
6532 ok(WaitForSingleObject(hThread
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
6533 CloseHandle(hThread
);
6535 ok(!IsWindow(wnd_event
.hwnd
), "window should be destroyed on thread exit\n");
6537 wnd_event
.hwnd
= CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
6538 100, 100, 200, 200, 0, 0, 0, NULL
);
6539 ok (wnd_event
.hwnd
!= 0, "Failed to create parent window\n");
6541 log_all_parent_messages
++;
6542 wnd_event
.start_event
= CreateEventA( NULL
, TRUE
, FALSE
, NULL
);
6543 wnd_event
.stop_event
= CreateEventA( NULL
, TRUE
, FALSE
, NULL
);
6544 hThread
= CreateThread( NULL
, 0, create_child_thread
, &wnd_event
, 0, &tid
);
6547 ret
= MsgWaitForMultipleObjects(1, &wnd_event
.start_event
, FALSE
, 1000, QS_SENDMESSAGE
);
6548 if (ret
!= 1) break;
6549 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage(&msg
);
6551 ok( !ret
, "MsgWaitForMultipleObjects failed %x\n", ret
);
6552 /* now wait for the thread without processing messages; this shouldn't deadlock */
6553 SetEvent( wnd_event
.stop_event
);
6554 ret
= WaitForSingleObject( hThread
, 5000 );
6555 ok( !ret
, "WaitForSingleObject failed %x\n", ret
);
6556 CloseHandle( hThread
);
6558 ret
= WaitForSingleObject( wnd_event
.grand_child
, 5000 );
6559 ok( !ret
, "WaitForSingleObject failed %x\n", ret
);
6560 CloseHandle( wnd_event
.grand_child
);
6562 CloseHandle( wnd_event
.start_event
);
6563 CloseHandle( wnd_event
.stop_event
);
6565 ok_sequence(WmExitThreadSeq
, "destroy child on thread exit", FALSE
);
6566 log_all_parent_messages
--;
6567 DestroyWindow( wnd_event
.hwnd
);
6571 static const struct message WmVkN
[] = {
6572 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 1 }, /* XP */
6573 { WM_KEYDOWN
, wparam
|lparam
, 'N', 1 },
6574 { WM_KEYDOWN
, sent
|wparam
|lparam
, 'N', 1 },
6575 { WM_CHAR
, wparam
|lparam
, 'n', 1 },
6576 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1002,1), 0 },
6577 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xc0000001 }, /* XP */
6578 { WM_KEYUP
, wparam
|lparam
, 'N', 0xc0000001 },
6579 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xc0000001 },
6582 static const struct message WmShiftVkN
[] = {
6583 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 1 }, /* XP */
6584 { WM_KEYDOWN
, wparam
|lparam
, VK_SHIFT
, 1 },
6585 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_SHIFT
, 1 },
6586 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 1 }, /* XP */
6587 { WM_KEYDOWN
, wparam
|lparam
, 'N', 1 },
6588 { WM_KEYDOWN
, sent
|wparam
|lparam
, 'N', 1 },
6589 { WM_CHAR
, wparam
|lparam
, 'N', 1 },
6590 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1001,1), 0 },
6591 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xc0000001 }, /* XP */
6592 { WM_KEYUP
, wparam
|lparam
, 'N', 0xc0000001 },
6593 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xc0000001 },
6594 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 0xc0000001 }, /* XP */
6595 { WM_KEYUP
, wparam
|lparam
, VK_SHIFT
, 0xc0000001 },
6596 { WM_KEYUP
, sent
|wparam
|lparam
, VK_SHIFT
, 0xc0000001 },
6599 static const struct message WmCtrlVkN
[] = {
6600 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 1 }, /* XP */
6601 { WM_KEYDOWN
, wparam
|lparam
, VK_CONTROL
, 1 },
6602 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_CONTROL
, 1 },
6603 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 1 }, /* XP */
6604 { WM_KEYDOWN
, wparam
|lparam
, 'N', 1 },
6605 { WM_KEYDOWN
, sent
|wparam
|lparam
, 'N', 1 },
6606 { WM_CHAR
, wparam
|lparam
, 0x000e, 1 },
6607 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1000,1), 0 },
6608 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xc0000001 }, /* XP */
6609 { WM_KEYUP
, wparam
|lparam
, 'N', 0xc0000001 },
6610 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xc0000001 },
6611 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 0xc0000001 }, /* XP */
6612 { WM_KEYUP
, wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
6613 { WM_KEYUP
, sent
|wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
6616 static const struct message WmCtrlVkN_2
[] = {
6617 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 1 }, /* XP */
6618 { WM_KEYDOWN
, wparam
|lparam
, VK_CONTROL
, 1 },
6619 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_CONTROL
, 1 },
6620 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 1 }, /* XP */
6621 { WM_KEYDOWN
, wparam
|lparam
, 'N', 1 },
6622 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1000,1), 0 },
6623 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xc0000001 }, /* XP */
6624 { WM_KEYUP
, wparam
|lparam
, 'N', 0xc0000001 },
6625 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xc0000001 },
6626 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 0xc0000001 }, /* XP */
6627 { WM_KEYUP
, wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
6628 { WM_KEYUP
, sent
|wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
6631 static const struct message WmAltVkN
[] = {
6632 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 }, /* XP */
6633 { WM_SYSKEYDOWN
, wparam
|lparam
, VK_MENU
, 0x20000001 },
6634 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
6635 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0x20000001 }, /* XP */
6636 { WM_SYSKEYDOWN
, wparam
|lparam
, 'N', 0x20000001 },
6637 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, 'N', 0x20000001 },
6638 { WM_SYSCHAR
, wparam
|lparam
, 'n', 0x20000001 },
6639 { WM_SYSCHAR
, sent
|wparam
|lparam
, 'n', 0x20000001 },
6640 { WM_SYSCOMMAND
, sent
|defwinproc
|wparam
|lparam
, SC_KEYMENU
, 'n' },
6641 { HCBT_SYSCOMMAND
, hook
},
6642 { WM_ENTERMENULOOP
, sent
|defwinproc
|wparam
|lparam
, 0, 0 },
6643 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
6644 { 0x00AE, sent
|defwinproc
|optional
}, /* XP */
6645 { WM_GETTEXT
, sent
|defwinproc
|optional
}, /* XP */
6646 { WM_INITMENU
, sent
|defwinproc
},
6647 { EVENT_SYSTEM_MENUSTART
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 0 },
6648 { WM_MENUCHAR
, sent
|defwinproc
|wparam
, MAKEWPARAM('n',MF_SYSMENU
) },
6649 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, 0, 0 },
6650 { WM_CAPTURECHANGED
, sent
|defwinproc
},
6651 { WM_MENUSELECT
, sent
|defwinproc
|wparam
, MAKEWPARAM(0,0xffff) },
6652 { EVENT_SYSTEM_MENUEND
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 0 },
6653 { WM_EXITMENULOOP
, sent
|defwinproc
},
6654 { WM_MENUSELECT
, sent
|defwinproc
|wparam
|optional
, MAKEWPARAM(0,0xffff) }, /* Win95 bug */
6655 { WM_EXITMENULOOP
, sent
|defwinproc
|optional
}, /* Win95 bug */
6656 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xe0000001 }, /* XP */
6657 { WM_SYSKEYUP
, wparam
|lparam
, 'N', 0xe0000001 },
6658 { WM_SYSKEYUP
, sent
|wparam
|lparam
, 'N', 0xe0000001 },
6659 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xc0000001 }, /* XP */
6660 { WM_KEYUP
, wparam
|lparam
, VK_MENU
, 0xc0000001 },
6661 { WM_KEYUP
, sent
|wparam
|lparam
, VK_MENU
, 0xc0000001 },
6664 static const struct message WmAltVkN_2
[] = {
6665 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 }, /* XP */
6666 { WM_SYSKEYDOWN
, wparam
|lparam
, VK_MENU
, 0x20000001 },
6667 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
6668 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0x20000001 }, /* XP */
6669 { WM_SYSKEYDOWN
, wparam
|lparam
, 'N', 0x20000001 },
6670 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1003,1), 0 },
6671 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xe0000001 }, /* XP */
6672 { WM_SYSKEYUP
, wparam
|lparam
, 'N', 0xe0000001 },
6673 { WM_SYSKEYUP
, sent
|wparam
|lparam
, 'N', 0xe0000001 },
6674 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xc0000001 }, /* XP */
6675 { WM_KEYUP
, wparam
|lparam
, VK_MENU
, 0xc0000001 },
6676 { WM_KEYUP
, sent
|wparam
|lparam
, VK_MENU
, 0xc0000001 },
6679 static const struct message WmCtrlAltVkN
[] = {
6680 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 1 }, /* XP */
6681 { WM_KEYDOWN
, wparam
|lparam
, VK_CONTROL
, 1 },
6682 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_CONTROL
, 1 },
6683 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 }, /* XP */
6684 { WM_KEYDOWN
, wparam
|lparam
, VK_MENU
, 0x20000001 },
6685 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
6686 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0x20000001 }, /* XP */
6687 { WM_KEYDOWN
, wparam
|lparam
, 'N', 0x20000001 },
6688 { WM_KEYDOWN
, sent
|wparam
|lparam
, 'N', 0x20000001 },
6689 { WM_CHAR
, optional
},
6690 { WM_CHAR
, sent
|optional
},
6691 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xe0000001 }, /* XP */
6692 { WM_KEYUP
, wparam
|lparam
, 'N', 0xe0000001 },
6693 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xe0000001 },
6694 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xc0000001 }, /* XP */
6695 { WM_KEYUP
, wparam
|lparam
, VK_MENU
, 0xc0000001 },
6696 { WM_KEYUP
, sent
|wparam
|lparam
, VK_MENU
, 0xc0000001 },
6697 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 0xc0000001 }, /* XP */
6698 { WM_KEYUP
, wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
6699 { WM_KEYUP
, sent
|wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
6702 static const struct message WmCtrlShiftVkN
[] = {
6703 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 1 }, /* XP */
6704 { WM_KEYDOWN
, wparam
|lparam
, VK_CONTROL
, 1 },
6705 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_CONTROL
, 1 },
6706 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 1 }, /* XP */
6707 { WM_KEYDOWN
, wparam
|lparam
, VK_SHIFT
, 1 },
6708 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_SHIFT
, 1 },
6709 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 1 }, /* XP */
6710 { WM_KEYDOWN
, wparam
|lparam
, 'N', 1 },
6711 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1004,1), 0 },
6712 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xc0000001 }, /* XP */
6713 { WM_KEYUP
, wparam
|lparam
, 'N', 0xc0000001 },
6714 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xc0000001 },
6715 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 0xc0000001 }, /* XP */
6716 { WM_KEYUP
, wparam
|lparam
, VK_SHIFT
, 0xc0000001 },
6717 { WM_KEYUP
, sent
|wparam
|lparam
, VK_SHIFT
, 0xc0000001 },
6718 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 0xc0000001 }, /* XP */
6719 { WM_KEYUP
, wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
6720 { WM_KEYUP
, sent
|wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
6723 static const struct message WmCtrlAltShiftVkN
[] = {
6724 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 1 }, /* XP */
6725 { WM_KEYDOWN
, wparam
|lparam
, VK_CONTROL
, 1 },
6726 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_CONTROL
, 1 },
6727 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 }, /* XP */
6728 { WM_KEYDOWN
, wparam
|lparam
, VK_MENU
, 0x20000001 },
6729 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
6730 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 0x20000001 }, /* XP */
6731 { WM_KEYDOWN
, wparam
|lparam
, VK_SHIFT
, 0x20000001 },
6732 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_SHIFT
, 0x20000001 },
6733 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0x20000001 }, /* XP */
6734 { WM_KEYDOWN
, wparam
|lparam
, 'N', 0x20000001 },
6735 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1005,1), 0 },
6736 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xe0000001 }, /* XP */
6737 { WM_KEYUP
, wparam
|lparam
, 'N', 0xe0000001 },
6738 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xe0000001 },
6739 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 0xe0000001 }, /* XP */
6740 { WM_KEYUP
, wparam
|lparam
, VK_SHIFT
, 0xe0000001 },
6741 { WM_KEYUP
, sent
|wparam
|lparam
, VK_SHIFT
, 0xe0000001 },
6742 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xc0000001 }, /* XP */
6743 { WM_KEYUP
, wparam
|lparam
, VK_MENU
, 0xc0000001 },
6744 { WM_KEYUP
, sent
|wparam
|lparam
, VK_MENU
, 0xc0000001 },
6745 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 0xc0000001 }, /* XP */
6746 { WM_KEYUP
, wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
6747 { WM_KEYUP
, sent
|wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
6750 static const struct message WmAltPressRelease
[] = {
6751 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 }, /* XP */
6752 { WM_SYSKEYDOWN
, wparam
|lparam
, VK_MENU
, 0x20000001 },
6753 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
6754 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xc0000001 }, /* XP */
6755 { WM_SYSKEYUP
, wparam
|lparam
, VK_MENU
, 0xc0000001 },
6756 { WM_SYSKEYUP
, sent
|wparam
|lparam
, VK_MENU
, 0xc0000001 },
6757 { WM_SYSCOMMAND
, sent
|defwinproc
|wparam
|lparam
, SC_KEYMENU
, 0 },
6758 { HCBT_SYSCOMMAND
, hook
},
6759 { WM_ENTERMENULOOP
, sent
|defwinproc
|wparam
|lparam
, 0, 0 },
6760 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
6761 { WM_INITMENU
, sent
|defwinproc
},
6762 { EVENT_SYSTEM_MENUSTART
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 0 },
6763 { WM_MENUSELECT
, sent
|defwinproc
|wparam
, MAKEWPARAM(0,MF_SYSMENU
|MF_POPUP
|MF_HILITE
) },
6764 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 1 },
6766 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x30000001 }, /* XP */
6768 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 0 },
6769 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, 0, 0, },
6770 { WM_CAPTURECHANGED
, sent
|defwinproc
},
6771 { WM_MENUSELECT
, sent
|defwinproc
|wparam
|optional
, MAKEWPARAM(0,0xffff) },
6772 { EVENT_SYSTEM_MENUEND
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 0 },
6773 { WM_EXITMENULOOP
, sent
|defwinproc
},
6774 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xc0000001 }, /* XP */
6775 { WM_SYSKEYUP
, wparam
|lparam
, VK_MENU
, 0xc0000001 },
6776 { WM_SYSKEYUP
, sent
|wparam
|lparam
, VK_MENU
, 0xc0000001 },
6779 static const struct message WmShiftMouseButton
[] = {
6780 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 1 }, /* XP */
6781 { WM_KEYDOWN
, wparam
|lparam
, VK_SHIFT
, 1 },
6782 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_SHIFT
, 1 },
6783 { WM_MOUSEMOVE
, wparam
|optional
, 0, 0 },
6784 { WM_MOUSEMOVE
, sent
|wparam
|optional
, 0, 0 },
6785 { WM_LBUTTONDOWN
, wparam
, MK_LBUTTON
|MK_SHIFT
, 0 },
6786 { WM_LBUTTONDOWN
, sent
|wparam
, MK_LBUTTON
|MK_SHIFT
, 0 },
6787 { WM_LBUTTONUP
, wparam
, MK_SHIFT
, 0 },
6788 { WM_LBUTTONUP
, sent
|wparam
, MK_SHIFT
, 0 },
6789 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 0xc0000001 }, /* XP */
6790 { WM_KEYUP
, wparam
|lparam
, VK_SHIFT
, 0xc0000001 },
6791 { WM_KEYUP
, sent
|wparam
|lparam
, VK_SHIFT
, 0xc0000001 },
6794 static const struct message WmF1Seq
[] = {
6795 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_F1
, 1 }, /* XP */
6796 { WM_KEYDOWN
, wparam
|lparam
, VK_F1
, 1 },
6797 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_F1
, 0x00000001 },
6798 { WM_KEYF1
, wparam
|lparam
, 0, 0 },
6799 { WM_KEYF1
, sent
|wparam
|lparam
, 0, 0 },
6800 { WM_HELP
, sent
|defwinproc
},
6801 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_F1
, 0xc0000001 }, /* XP */
6802 { WM_KEYUP
, wparam
|lparam
, VK_F1
, 0xc0000001 },
6803 { WM_KEYUP
, sent
|wparam
|lparam
, VK_F1
, 0xc0000001 },
6806 static const struct message WmVkAppsSeq
[] = {
6807 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_APPS
, 1 }, /* XP */
6808 { WM_KEYDOWN
, wparam
|lparam
, VK_APPS
, 1 },
6809 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_APPS
, 0x00000001 },
6810 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_APPS
, 0xc0000001 }, /* XP */
6811 { WM_KEYUP
, wparam
|lparam
, VK_APPS
, 0xc0000001 },
6812 { WM_KEYUP
, sent
|wparam
|lparam
, VK_APPS
, 0xc0000001 },
6813 { WM_CONTEXTMENU
, lparam
, /*hwnd*/0, (LPARAM
)-1 },
6814 { WM_CONTEXTMENU
, sent
|lparam
, /*hwnd*/0, (LPARAM
)-1 },
6818 static void pump_msg_loop(HWND hwnd
, HACCEL hAccel
)
6822 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
))
6824 struct recvd_message log_msg
;
6826 /* ignore some unwanted messages */
6827 if (msg
.message
== WM_MOUSEMOVE
||
6828 msg
.message
== WM_TIMER
||
6829 ignore_message( msg
.message
))
6832 log_msg
.hwnd
= msg
.hwnd
;
6833 log_msg
.message
= msg
.message
;
6834 log_msg
.flags
= wparam
|lparam
;
6835 log_msg
.wParam
= msg
.wParam
;
6836 log_msg
.lParam
= msg
.lParam
;
6837 log_msg
.descr
= "accel";
6838 add_message(&log_msg
);
6840 if (!hAccel
|| !TranslateAccelerator(hwnd
, hAccel
, &msg
))
6842 TranslateMessage(&msg
);
6843 DispatchMessage(&msg
);
6848 static void test_accelerators(void)
6854 HWND hwnd
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
6855 100, 100, 200, 200, 0, 0, 0, NULL
);
6864 ok(GetFocus() == hwnd
, "wrong focus window %p\n", GetFocus());
6866 state
= GetKeyState(VK_SHIFT
);
6867 ok(!(state
& 0x8000), "wrong Shift state %04x\n", state
);
6868 state
= GetKeyState(VK_CAPITAL
);
6869 ok(state
== 0, "wrong CapsLock state %04x\n", state
);
6871 hAccel
= LoadAccelerators(GetModuleHandleA(0), MAKEINTRESOURCE(1));
6872 assert(hAccel
!= 0);
6875 pump_msg_loop(hwnd
, 0);
6878 trace("testing VK_N press/release\n");
6880 keybd_event('N', 0, 0, 0);
6881 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
6882 pump_msg_loop(hwnd
, hAccel
);
6883 if (!sequence_cnt
) /* we didn't get any message */
6885 skip( "queuing key events not supported\n" );
6888 ok_sequence(WmVkN
, "VK_N press/release", FALSE
);
6890 trace("testing Shift+VK_N press/release\n");
6892 keybd_event(VK_SHIFT
, 0, 0, 0);
6893 keybd_event('N', 0, 0, 0);
6894 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
6895 keybd_event(VK_SHIFT
, 0, KEYEVENTF_KEYUP
, 0);
6896 pump_msg_loop(hwnd
, hAccel
);
6897 ok_sequence(WmShiftVkN
, "Shift+VK_N press/release", FALSE
);
6899 trace("testing Ctrl+VK_N press/release\n");
6901 keybd_event(VK_CONTROL
, 0, 0, 0);
6902 keybd_event('N', 0, 0, 0);
6903 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
6904 keybd_event(VK_CONTROL
, 0, KEYEVENTF_KEYUP
, 0);
6905 pump_msg_loop(hwnd
, hAccel
);
6906 ok_sequence(WmCtrlVkN
, "Ctrl+VK_N press/release", FALSE
);
6908 trace("testing Alt+VK_N press/release\n");
6910 keybd_event(VK_MENU
, 0, 0, 0);
6911 keybd_event('N', 0, 0, 0);
6912 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
6913 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
6914 pump_msg_loop(hwnd
, hAccel
);
6915 ok_sequence(WmAltVkN
, "Alt+VK_N press/release", FALSE
);
6917 trace("testing Ctrl+Alt+VK_N press/release 1\n");
6919 keybd_event(VK_CONTROL
, 0, 0, 0);
6920 keybd_event(VK_MENU
, 0, 0, 0);
6921 keybd_event('N', 0, 0, 0);
6922 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
6923 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
6924 keybd_event(VK_CONTROL
, 0, KEYEVENTF_KEYUP
, 0);
6925 pump_msg_loop(hwnd
, hAccel
);
6926 ok_sequence(WmCtrlAltVkN
, "Ctrl+Alt+VK_N press/release 1", FALSE
);
6928 ret
= DestroyAcceleratorTable(hAccel
);
6929 ok( ret
, "DestroyAcceleratorTable error %d\n", GetLastError());
6931 hAccel
= LoadAccelerators(GetModuleHandleA(0), MAKEINTRESOURCE(2));
6932 assert(hAccel
!= 0);
6934 trace("testing VK_N press/release\n");
6936 keybd_event('N', 0, 0, 0);
6937 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
6938 pump_msg_loop(hwnd
, hAccel
);
6939 ok_sequence(WmVkN
, "VK_N press/release", FALSE
);
6941 trace("testing Shift+VK_N press/release\n");
6943 keybd_event(VK_SHIFT
, 0, 0, 0);
6944 keybd_event('N', 0, 0, 0);
6945 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
6946 keybd_event(VK_SHIFT
, 0, KEYEVENTF_KEYUP
, 0);
6947 pump_msg_loop(hwnd
, hAccel
);
6948 ok_sequence(WmShiftVkN
, "Shift+VK_N press/release", FALSE
);
6950 trace("testing Ctrl+VK_N press/release 2\n");
6952 keybd_event(VK_CONTROL
, 0, 0, 0);
6953 keybd_event('N', 0, 0, 0);
6954 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
6955 keybd_event(VK_CONTROL
, 0, KEYEVENTF_KEYUP
, 0);
6956 pump_msg_loop(hwnd
, hAccel
);
6957 ok_sequence(WmCtrlVkN_2
, "Ctrl+VK_N press/release 2", FALSE
);
6959 trace("testing Alt+VK_N press/release 2\n");
6961 keybd_event(VK_MENU
, 0, 0, 0);
6962 keybd_event('N', 0, 0, 0);
6963 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
6964 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
6965 pump_msg_loop(hwnd
, hAccel
);
6966 ok_sequence(WmAltVkN_2
, "Alt+VK_N press/release 2", FALSE
);
6968 trace("testing Ctrl+Alt+VK_N press/release 2\n");
6970 keybd_event(VK_CONTROL
, 0, 0, 0);
6971 keybd_event(VK_MENU
, 0, 0, 0);
6972 keybd_event('N', 0, 0, 0);
6973 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
6974 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
6975 keybd_event(VK_CONTROL
, 0, KEYEVENTF_KEYUP
, 0);
6976 pump_msg_loop(hwnd
, hAccel
);
6977 ok_sequence(WmCtrlAltVkN
, "Ctrl+Alt+VK_N press/release 2", FALSE
);
6979 trace("testing Ctrl+Shift+VK_N press/release\n");
6981 keybd_event(VK_CONTROL
, 0, 0, 0);
6982 keybd_event(VK_SHIFT
, 0, 0, 0);
6983 keybd_event('N', 0, 0, 0);
6984 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
6985 keybd_event(VK_SHIFT
, 0, KEYEVENTF_KEYUP
, 0);
6986 keybd_event(VK_CONTROL
, 0, KEYEVENTF_KEYUP
, 0);
6987 pump_msg_loop(hwnd
, hAccel
);
6988 ok_sequence(WmCtrlShiftVkN
, "Ctrl+Shift+VK_N press/release", FALSE
);
6990 trace("testing Ctrl+Alt+Shift+VK_N press/release\n");
6992 keybd_event(VK_CONTROL
, 0, 0, 0);
6993 keybd_event(VK_MENU
, 0, 0, 0);
6994 keybd_event(VK_SHIFT
, 0, 0, 0);
6995 keybd_event('N', 0, 0, 0);
6996 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
6997 keybd_event(VK_SHIFT
, 0, KEYEVENTF_KEYUP
, 0);
6998 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
6999 keybd_event(VK_CONTROL
, 0, KEYEVENTF_KEYUP
, 0);
7000 pump_msg_loop(hwnd
, hAccel
);
7001 ok_sequence(WmCtrlAltShiftVkN
, "Ctrl+Alt+Shift+VK_N press/release", FALSE
);
7003 ret
= DestroyAcceleratorTable(hAccel
);
7004 ok( ret
, "DestroyAcceleratorTable error %d\n", GetLastError());
7007 trace("testing Alt press/release\n");
7009 keybd_event(VK_MENU
, 0, 0, 0);
7010 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
7011 keybd_event(VK_MENU
, 0, 0, 0);
7012 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
7013 pump_msg_loop(hwnd
, 0);
7014 /* this test doesn't pass in Wine for managed windows */
7015 ok_sequence(WmAltPressRelease
, "Alt press/release", TRUE
);
7017 trace("testing VK_F1 press/release\n");
7018 keybd_event(VK_F1
, 0, 0, 0);
7019 keybd_event(VK_F1
, 0, KEYEVENTF_KEYUP
, 0);
7020 pump_msg_loop(hwnd
, 0);
7021 ok_sequence(WmF1Seq
, "F1 press/release", FALSE
);
7023 trace("testing VK_APPS press/release\n");
7024 keybd_event(VK_APPS
, 0, 0, 0);
7025 keybd_event(VK_APPS
, 0, KEYEVENTF_KEYUP
, 0);
7026 pump_msg_loop(hwnd
, 0);
7027 ok_sequence(WmVkAppsSeq
, "VK_APPS press/release", FALSE
);
7029 trace("testing Shift+MouseButton press/release\n");
7030 /* first, move mouse pointer inside of the window client area */
7031 GetClientRect(hwnd
, &rc
);
7032 MapWindowPoints(hwnd
, 0, (LPPOINT
)&rc
, 2);
7033 rc
.left
+= (rc
.right
- rc
.left
)/2;
7034 rc
.top
+= (rc
.bottom
- rc
.top
)/2;
7035 SetCursorPos(rc
.left
, rc
.top
);
7036 SetActiveWindow(hwnd
);
7041 if (pt
.x
== rc
.left
&& pt
.y
== rc
.top
)
7044 keybd_event(VK_SHIFT
, 0, 0, 0);
7045 mouse_event(MOUSEEVENTF_LEFTDOWN
, 0, 0, 0, 0);
7046 mouse_event(MOUSEEVENTF_LEFTUP
, 0, 0, 0, 0);
7047 keybd_event(VK_SHIFT
, 0, KEYEVENTF_KEYUP
, 0);
7048 pump_msg_loop(hwnd
, 0);
7049 for (i
= 0; i
< sequence_cnt
; i
++) if (sequence
[i
].message
== WM_LBUTTONDOWN
) break;
7050 if (i
< sequence_cnt
)
7051 ok_sequence(WmShiftMouseButton
, "Shift+MouseButton press/release", FALSE
);
7053 skip( "Shift+MouseButton event didn't get to the window\n" );
7057 if (hAccel
) DestroyAcceleratorTable(hAccel
);
7058 DestroyWindow(hwnd
);
7061 /************* window procedures ********************/
7063 static LRESULT
MsgCheckProc (BOOL unicode
, HWND hwnd
, UINT message
,
7064 WPARAM wParam
, LPARAM lParam
)
7066 static LONG defwndproc_counter
= 0;
7067 static LONG beginpaint_counter
= 0;
7069 struct recvd_message msg
;
7071 if (ignore_message( message
)) return 0;
7077 LONG style
= GetWindowLongA(hwnd
, GWL_STYLE
);
7078 ok((BOOL
)wParam
== !(style
& WS_DISABLED
),
7079 "wrong WS_DISABLED state: %ld != %d\n", wParam
, !(style
& WS_DISABLED
));
7083 case WM_CAPTURECHANGED
:
7084 if (test_DestroyWindow_flag
)
7086 DWORD style
= GetWindowLongA(hwnd
, GWL_STYLE
);
7087 if (style
& WS_CHILD
)
7088 lParam
= GetWindowLongPtrA(hwnd
, GWLP_ID
);
7089 else if (style
& WS_POPUP
)
7090 lParam
= WND_POPUP_ID
;
7092 lParam
= WND_PARENT_ID
;
7100 ok(!GetWindow(hwnd
, GW_CHILD
), "children should be unlinked at this point\n");
7101 capture
= GetCapture();
7104 ok(capture
== hwnd
, "capture should NOT be released at this point (capture %p)\n", capture
);
7105 trace("current capture %p, releasing...\n", capture
);
7112 ok(pGetAncestor(hwnd
, GA_PARENT
) != 0, "parent should NOT be unlinked at this point\n");
7113 if (test_DestroyWindow_flag
)
7115 DWORD style
= GetWindowLongA(hwnd
, GWL_STYLE
);
7116 if (style
& WS_CHILD
)
7117 lParam
= GetWindowLongPtrA(hwnd
, GWLP_ID
);
7118 else if (style
& WS_POPUP
)
7119 lParam
= WND_POPUP_ID
;
7121 lParam
= WND_PARENT_ID
;
7125 /* test_accelerators() depends on this */
7131 case WM_MOUSEACTIVATE
:
7132 case WM_NCMOUSEMOVE
:
7139 msg
.message
= message
;
7140 msg
.flags
= sent
|wparam
|lparam
;
7141 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
7142 if (beginpaint_counter
) msg
.flags
|= beginpaint
;
7143 msg
.wParam
= wParam
;
7144 msg
.lParam
= lParam
;
7145 msg
.descr
= "MsgCheckProc";
7148 if (message
== WM_GETMINMAXINFO
&& (GetWindowLongA(hwnd
, GWL_STYLE
) & WS_CHILD
))
7150 HWND parent
= GetParent(hwnd
);
7152 MINMAXINFO
*minmax
= (MINMAXINFO
*)lParam
;
7154 GetClientRect(parent
, &rc
);
7155 trace("parent %p client size = (%d x %d)\n", parent
, rc
.right
, rc
.bottom
);
7156 trace("Reserved=%d,%d MaxSize=%d,%d MaxPos=%d,%d MinTrack=%d,%d MaxTrack=%d,%d\n",
7157 minmax
->ptReserved
.x
, minmax
->ptReserved
.y
,
7158 minmax
->ptMaxSize
.x
, minmax
->ptMaxSize
.y
,
7159 minmax
->ptMaxPosition
.x
, minmax
->ptMaxPosition
.y
,
7160 minmax
->ptMinTrackSize
.x
, minmax
->ptMinTrackSize
.y
,
7161 minmax
->ptMaxTrackSize
.x
, minmax
->ptMaxTrackSize
.y
);
7163 ok(minmax
->ptMaxSize
.x
== rc
.right
, "default width of maximized child %d != %d\n",
7164 minmax
->ptMaxSize
.x
, rc
.right
);
7165 ok(minmax
->ptMaxSize
.y
== rc
.bottom
, "default height of maximized child %d != %d\n",
7166 minmax
->ptMaxSize
.y
, rc
.bottom
);
7169 if (message
== WM_PAINT
)
7172 beginpaint_counter
++;
7173 BeginPaint( hwnd
, &ps
);
7174 beginpaint_counter
--;
7175 EndPaint( hwnd
, &ps
);
7179 defwndproc_counter
++;
7180 ret
= unicode
? DefWindowProcW(hwnd
, message
, wParam
, lParam
)
7181 : DefWindowProcA(hwnd
, message
, wParam
, lParam
);
7182 defwndproc_counter
--;
7187 static LRESULT WINAPI
MsgCheckProcA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
7189 return MsgCheckProc (FALSE
, hwnd
, message
, wParam
, lParam
);
7192 static LRESULT WINAPI
MsgCheckProcW(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
7194 return MsgCheckProc (TRUE
, hwnd
, message
, wParam
, lParam
);
7197 static LRESULT WINAPI
PopupMsgCheckProcA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
7199 static LONG defwndproc_counter
= 0;
7201 struct recvd_message msg
;
7203 if (ignore_message( message
)) return 0;
7207 case WM_QUERYENDSESSION
:
7209 lParam
&= ~0x01; /* Vista adds a 0x01 flag */
7214 msg
.message
= message
;
7215 msg
.flags
= sent
|wparam
|lparam
;
7216 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
7217 msg
.wParam
= wParam
;
7218 msg
.lParam
= lParam
;
7219 msg
.descr
= "popup";
7222 if (message
== WM_CREATE
)
7224 DWORD style
= GetWindowLongA(hwnd
, GWL_STYLE
) | WS_VISIBLE
;
7225 SetWindowLongA(hwnd
, GWL_STYLE
, style
);
7228 defwndproc_counter
++;
7229 ret
= DefWindowProcA(hwnd
, message
, wParam
, lParam
);
7230 defwndproc_counter
--;
7235 static LRESULT WINAPI
ParentMsgCheckProcA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
7237 static LONG defwndproc_counter
= 0;
7238 static LONG beginpaint_counter
= 0;
7240 struct recvd_message msg
;
7242 if (ignore_message( message
)) return 0;
7244 if (log_all_parent_messages
||
7245 message
== WM_PARENTNOTIFY
|| message
== WM_CANCELMODE
||
7246 message
== WM_SETFOCUS
|| message
== WM_KILLFOCUS
||
7247 message
== WM_ENABLE
|| message
== WM_ENTERIDLE
||
7248 message
== WM_DRAWITEM
|| message
== WM_COMMAND
||
7249 message
== WM_IME_SETCONTEXT
)
7258 case WM_NCMOUSEMOVE
:
7264 INT ret
= GetClipBox((HDC
)wParam
, &rc
);
7266 trace("WM_ERASEBKGND: GetClipBox()=%d, (%d,%d-%d,%d)\n",
7267 ret
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
7273 msg
.message
= message
;
7274 msg
.flags
= sent
|parent
|wparam
|lparam
;
7275 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
7276 if (beginpaint_counter
) msg
.flags
|= beginpaint
;
7277 msg
.wParam
= wParam
;
7278 msg
.lParam
= lParam
;
7279 msg
.descr
= "parent";
7283 if (message
== WM_PAINT
)
7286 beginpaint_counter
++;
7287 BeginPaint( hwnd
, &ps
);
7288 beginpaint_counter
--;
7289 EndPaint( hwnd
, &ps
);
7293 defwndproc_counter
++;
7294 ret
= DefWindowProcA(hwnd
, message
, wParam
, lParam
);
7295 defwndproc_counter
--;
7300 static LRESULT WINAPI
TestDlgProcA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
7302 static LONG defwndproc_counter
= 0;
7304 struct recvd_message msg
;
7306 if (ignore_message( message
)) return 0;
7310 DefDlgProcA(hwnd
, DM_SETDEFID
, 1, 0);
7311 ret
= DefDlgProcA(hwnd
, DM_GETDEFID
, 0, 0);
7312 if (after_end_dialog
)
7313 ok( ret
== 0, "DM_GETDEFID should return 0 after EndDialog, got %lx\n", ret
);
7315 ok(HIWORD(ret
) == DC_HASDEFID
, "DM_GETDEFID should return DC_HASDEFID, got %lx\n", ret
);
7319 msg
.message
= message
;
7320 msg
.flags
= sent
|wparam
|lparam
;
7321 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
7322 msg
.wParam
= wParam
;
7323 msg
.lParam
= lParam
;
7324 msg
.descr
= "dialog";
7327 defwndproc_counter
++;
7328 ret
= DefDlgProcA(hwnd
, message
, wParam
, lParam
);
7329 defwndproc_counter
--;
7334 static LRESULT WINAPI
ShowWindowProcA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
7336 static LONG defwndproc_counter
= 0;
7338 struct recvd_message msg
;
7340 /* log only specific messages we are interested in */
7343 #if 0 /* probably log these as well */
7351 case WM_GETMINMAXINFO
:
7352 case WM_WINDOWPOSCHANGING
:
7353 case WM_WINDOWPOSCHANGED
:
7356 default: /* ignore */
7357 /*trace("showwindow: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);*/
7358 return DefWindowProcA(hwnd
, message
, wParam
, lParam
);
7362 msg
.message
= message
;
7363 msg
.flags
= sent
|wparam
|lparam
;
7364 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
7365 msg
.wParam
= wParam
;
7366 msg
.lParam
= lParam
;
7370 defwndproc_counter
++;
7371 ret
= DefWindowProcA(hwnd
, message
, wParam
, lParam
);
7372 defwndproc_counter
--;
7377 static LRESULT WINAPI
PaintLoopProcA(HWND hWnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
7381 case WM_CREATE
: return 0;
7390 if (PeekMessageA(&msg2
, 0, 0, 0, 1))
7392 TranslateMessage(&msg2
);
7393 DispatchMessage(&msg2
);
7397 else ok(broken(1), "infinite loop\n");
7399 paint_loop_done
= 1;
7400 return DefWindowProcA(hWnd
,msg
,wParam
,lParam
);
7403 return DefWindowProcA(hWnd
,msg
,wParam
,lParam
);
7406 static BOOL
RegisterWindowClasses(void)
7412 cls
.lpfnWndProc
= MsgCheckProcA
;
7415 cls
.hInstance
= GetModuleHandleA(0);
7417 cls
.hCursor
= LoadCursorA(0, IDC_ARROW
);
7418 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
7419 cls
.lpszMenuName
= NULL
;
7420 cls
.lpszClassName
= "TestWindowClass";
7421 if(!RegisterClassA(&cls
)) return FALSE
;
7423 cls
.lpfnWndProc
= ShowWindowProcA
;
7424 cls
.lpszClassName
= "ShowWindowClass";
7425 if(!RegisterClassA(&cls
)) return FALSE
;
7427 cls
.lpfnWndProc
= PopupMsgCheckProcA
;
7428 cls
.lpszClassName
= "TestPopupClass";
7429 if(!RegisterClassA(&cls
)) return FALSE
;
7431 cls
.lpfnWndProc
= ParentMsgCheckProcA
;
7432 cls
.lpszClassName
= "TestParentClass";
7433 if(!RegisterClassA(&cls
)) return FALSE
;
7435 cls
.lpfnWndProc
= DefWindowProcA
;
7436 cls
.lpszClassName
= "SimpleWindowClass";
7437 if(!RegisterClassA(&cls
)) return FALSE
;
7439 cls
.lpfnWndProc
= PaintLoopProcA
;
7440 cls
.lpszClassName
= "PaintLoopWindowClass";
7441 if(!RegisterClassA(&cls
)) return FALSE
;
7443 cls
.style
= CS_NOCLOSE
;
7444 cls
.lpszClassName
= "NoCloseWindowClass";
7445 if(!RegisterClassA(&cls
)) return FALSE
;
7447 ok(GetClassInfoA(0, "#32770", &cls
), "GetClassInfo failed\n");
7449 cls
.hInstance
= GetModuleHandleA(0);
7450 cls
.hbrBackground
= 0;
7451 cls
.lpfnWndProc
= TestDlgProcA
;
7452 cls
.lpszClassName
= "TestDialogClass";
7453 if(!RegisterClassA(&cls
)) return FALSE
;
7456 clsW
.lpfnWndProc
= MsgCheckProcW
;
7457 clsW
.cbClsExtra
= 0;
7458 clsW
.cbWndExtra
= 0;
7459 clsW
.hInstance
= GetModuleHandleW(0);
7461 clsW
.hCursor
= LoadCursorW(0, (LPWSTR
)IDC_ARROW
);
7462 clsW
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
7463 clsW
.lpszMenuName
= NULL
;
7464 clsW
.lpszClassName
= testWindowClassW
;
7465 RegisterClassW(&clsW
); /* ignore error, this fails on Win9x */
7470 static BOOL
is_our_logged_class(HWND hwnd
)
7474 if (GetClassNameA(hwnd
, buf
, sizeof(buf
)))
7476 if (!lstrcmpiA(buf
, "TestWindowClass") ||
7477 !lstrcmpiA(buf
, "ShowWindowClass") ||
7478 !lstrcmpiA(buf
, "TestParentClass") ||
7479 !lstrcmpiA(buf
, "TestPopupClass") ||
7480 !lstrcmpiA(buf
, "SimpleWindowClass") ||
7481 !lstrcmpiA(buf
, "TestDialogClass") ||
7482 !lstrcmpiA(buf
, "MDI_frame_class") ||
7483 !lstrcmpiA(buf
, "MDI_client_class") ||
7484 !lstrcmpiA(buf
, "MDI_child_class") ||
7485 !lstrcmpiA(buf
, "my_button_class") ||
7486 !lstrcmpiA(buf
, "my_edit_class") ||
7487 !lstrcmpiA(buf
, "static") ||
7488 !lstrcmpiA(buf
, "ListBox") ||
7489 !lstrcmpiA(buf
, "ComboBox") ||
7490 !lstrcmpiA(buf
, "MyDialogClass") ||
7491 !lstrcmpiA(buf
, "#32770") ||
7492 !lstrcmpiA(buf
, "#32768"))
7498 static LRESULT CALLBACK
cbt_hook_proc(int nCode
, WPARAM wParam
, LPARAM lParam
)
7502 ok(cbt_hook_thread_id
== GetCurrentThreadId(), "we didn't ask for events from other threads\n");
7504 if (nCode
== HCBT_CLICKSKIPPED
)
7506 /* ignore this event, XP sends it a lot when switching focus between windows */
7507 return CallNextHookEx(hCBT_hook
, nCode
, wParam
, lParam
);
7510 if (nCode
== HCBT_SYSCOMMAND
|| nCode
== HCBT_KEYSKIPPED
)
7512 struct recvd_message msg
;
7515 msg
.message
= nCode
;
7516 msg
.flags
= hook
|wparam
|lparam
;
7517 msg
.wParam
= wParam
;
7518 msg
.lParam
= lParam
;
7522 return CallNextHookEx(hCBT_hook
, nCode
, wParam
, lParam
);
7525 if (nCode
== HCBT_DESTROYWND
)
7527 if (test_DestroyWindow_flag
)
7529 DWORD style
= GetWindowLongA((HWND
)wParam
, GWL_STYLE
);
7530 if (style
& WS_CHILD
)
7531 lParam
= GetWindowLongPtrA((HWND
)wParam
, GWLP_ID
);
7532 else if (style
& WS_POPUP
)
7533 lParam
= WND_POPUP_ID
;
7535 lParam
= WND_PARENT_ID
;
7539 /* Log also SetFocus(0) calls */
7540 hwnd
= wParam
? (HWND
)wParam
: (HWND
)lParam
;
7542 if (is_our_logged_class(hwnd
))
7544 struct recvd_message msg
;
7547 msg
.message
= nCode
;
7548 msg
.flags
= hook
|wparam
|lparam
;
7549 msg
.wParam
= wParam
;
7550 msg
.lParam
= lParam
;
7554 return CallNextHookEx(hCBT_hook
, nCode
, wParam
, lParam
);
7557 static void CALLBACK
win_event_proc(HWINEVENTHOOK hevent
,
7565 ok(thread_id
== GetCurrentThreadId(), "we didn't ask for events from other threads\n");
7567 /* ignore mouse cursor events */
7568 if (object_id
== OBJID_CURSOR
) return;
7570 if (!hwnd
|| is_our_logged_class(hwnd
))
7572 struct recvd_message msg
;
7575 msg
.message
= event
;
7576 msg
.flags
= winevent_hook
|wparam
|lparam
;
7577 msg
.wParam
= object_id
;
7578 msg
.lParam
= child_id
;
7584 static const WCHAR wszUnicode
[] = {'U','n','i','c','o','d','e',0};
7585 static const WCHAR wszAnsi
[] = {'U',0};
7587 static LRESULT CALLBACK
MsgConversionProcW(HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
7591 case CB_FINDSTRINGEXACT
:
7592 trace("String: %p\n", (LPCWSTR
)lParam
);
7593 if (!lstrcmpW((LPCWSTR
)lParam
, wszUnicode
))
7595 if (!lstrcmpW((LPCWSTR
)lParam
, wszAnsi
))
7599 return DefWindowProcW(hwnd
, uMsg
, wParam
, lParam
);
7602 static const struct message WmGetTextLengthAfromW
[] = {
7603 { WM_GETTEXTLENGTH
, sent
},
7604 { WM_GETTEXT
, sent
|optional
},
7608 static const WCHAR dummy_window_text
[] = {'d','u','m','m','y',' ','t','e','x','t',0};
7610 /* dummy window proc for WM_GETTEXTLENGTH test */
7611 static LRESULT CALLBACK
get_text_len_proc( HWND hwnd
, UINT msg
, WPARAM wp
, LPARAM lp
)
7615 case WM_GETTEXTLENGTH
:
7616 return lstrlenW(dummy_window_text
) + 37; /* some random length */
7618 lstrcpynW( (LPWSTR
)lp
, dummy_window_text
, wp
);
7619 return lstrlenW( (LPWSTR
)lp
);
7621 return DefWindowProcW( hwnd
, msg
, wp
, lp
);
7625 static void test_message_conversion(void)
7627 static const WCHAR wszMsgConversionClass
[] =
7628 {'M','s','g','C','o','n','v','e','r','s','i','o','n','C','l','a','s','s',0};
7632 WNDPROC wndproc
, newproc
;
7636 cls
.lpfnWndProc
= MsgConversionProcW
;
7639 cls
.hInstance
= GetModuleHandleW(NULL
);
7641 cls
.hCursor
= LoadCursorW(NULL
, (LPWSTR
)IDC_ARROW
);
7642 cls
.hbrBackground
= (HBRUSH
)(COLOR_BTNFACE
+1);
7643 cls
.lpszMenuName
= NULL
;
7644 cls
.lpszClassName
= wszMsgConversionClass
;
7645 /* this call will fail on Win9x, but that doesn't matter as this test is
7646 * meaningless on those platforms */
7647 if(!RegisterClassW(&cls
)) return;
7649 hwnd
= CreateWindowExW(0, wszMsgConversionClass
, NULL
, WS_OVERLAPPED
,
7650 100, 100, 200, 200, 0, 0, 0, NULL
);
7651 ok(hwnd
!= NULL
, "Window creation failed\n");
7655 wndproc
= (WNDPROC
)GetWindowLongPtrA(hwnd
, GWLP_WNDPROC
);
7656 lRes
= CallWindowProcA(wndproc
, hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
7657 ok(lRes
== 0, "String should have been converted\n");
7658 lRes
= CallWindowProcW(wndproc
, hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
7659 ok(lRes
== 1, "String shouldn't have been converted\n");
7663 wndproc
= (WNDPROC
)GetWindowLongPtrW(hwnd
, GWLP_WNDPROC
);
7664 lRes
= CallWindowProcA(wndproc
, hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
7665 ok(lRes
== 1, "String shouldn't have been converted\n");
7666 lRes
= CallWindowProcW(wndproc
, hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
7667 ok(lRes
== 1, "String shouldn't have been converted\n");
7669 /* Synchronous messages */
7671 lRes
= SendMessageA(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
7672 ok(lRes
== 0, "String should have been converted\n");
7673 lRes
= SendMessageW(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
7674 ok(lRes
== 1, "String shouldn't have been converted\n");
7676 /* Asynchronous messages */
7679 lRes
= PostMessageA(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
7680 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
7681 "PostMessage on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
7683 lRes
= PostMessageW(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
7684 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
7685 "PostMessage on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
7687 lRes
= PostThreadMessageA(GetCurrentThreadId(), CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
7688 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
7689 "PosThreadtMessage on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
7691 lRes
= PostThreadMessageW(GetCurrentThreadId(), CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
7692 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
7693 "PosThreadtMessage on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
7695 lRes
= SendNotifyMessageA(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
7696 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
7697 "SendNotifyMessage on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
7699 lRes
= SendNotifyMessageW(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
7700 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
7701 "SendNotifyMessage on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
7703 lRes
= SendMessageCallbackA(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
, NULL
, 0);
7704 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
7705 "SendMessageCallback on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
7707 lRes
= SendMessageCallbackW(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
, NULL
, 0);
7708 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
7709 "SendMessageCallback on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
7711 /* Check WM_GETTEXTLENGTH A->W behaviour, whether WM_GETTEXT is also sent or not */
7713 hwnd
= CreateWindowW (testWindowClassW
, wszUnicode
,
7714 WS_OVERLAPPEDWINDOW
,
7715 100, 100, 200, 200, 0, 0, 0, NULL
);
7718 lRes
= SendMessageA (hwnd
, WM_GETTEXTLENGTH
, 0, 0);
7719 ok_sequence(WmGetTextLengthAfromW
, "ANSI WM_GETTEXTLENGTH to Unicode window", FALSE
);
7720 ok( lRes
== WideCharToMultiByte( CP_ACP
, 0, wszUnicode
, lstrlenW(wszUnicode
), NULL
, 0, NULL
, NULL
),
7721 "got bad length %ld\n", lRes
);
7724 lRes
= CallWindowProcA( (WNDPROC
)GetWindowLongPtrA( hwnd
, GWLP_WNDPROC
),
7725 hwnd
, WM_GETTEXTLENGTH
, 0, 0);
7726 ok_sequence(WmGetTextLengthAfromW
, "ANSI WM_GETTEXTLENGTH to Unicode window", FALSE
);
7727 ok( lRes
== WideCharToMultiByte( CP_ACP
, 0, wszUnicode
, lstrlenW(wszUnicode
), NULL
, 0, NULL
, NULL
),
7728 "got bad length %ld\n", lRes
);
7730 wndproc
= (WNDPROC
)SetWindowLongPtrW( hwnd
, GWLP_WNDPROC
, (LONG_PTR
)get_text_len_proc
);
7731 newproc
= (WNDPROC
)GetWindowLongPtrA( hwnd
, GWLP_WNDPROC
);
7732 lRes
= CallWindowProcA( newproc
, hwnd
, WM_GETTEXTLENGTH
, 0, 0 );
7733 ok( lRes
== WideCharToMultiByte( CP_ACP
, 0, dummy_window_text
, lstrlenW(dummy_window_text
),
7734 NULL
, 0, NULL
, NULL
) ||
7735 broken(lRes
== lstrlenW(dummy_window_text
) + 37),
7736 "got bad length %ld\n", lRes
);
7738 SetWindowLongPtrW( hwnd
, GWLP_WNDPROC
, (LONG_PTR
)wndproc
); /* restore old wnd proc */
7739 lRes
= CallWindowProcA( newproc
, hwnd
, WM_GETTEXTLENGTH
, 0, 0 );
7740 ok( lRes
== WideCharToMultiByte( CP_ACP
, 0, dummy_window_text
, lstrlenW(dummy_window_text
),
7741 NULL
, 0, NULL
, NULL
) ||
7742 broken(lRes
== lstrlenW(dummy_window_text
) + 37),
7743 "got bad length %ld\n", lRes
);
7745 ret
= DestroyWindow(hwnd
);
7746 ok( ret
, "DestroyWindow() error %d\n", GetLastError());
7756 static VOID CALLBACK
tfunc(HWND hwnd
, UINT uMsg
, UINT_PTR id
, DWORD dwTime
)
7760 #define TIMER_ID 0x19
7762 static DWORD WINAPI
timer_thread_proc(LPVOID x
)
7764 struct timer_info
*info
= x
;
7767 r
= KillTimer(info
->hWnd
, 0x19);
7768 ok(r
,"KillTimer failed in thread\n");
7769 r
= SetTimer(info
->hWnd
,TIMER_ID
,10000,tfunc
);
7770 ok(r
,"SetTimer failed in thread\n");
7771 ok(r
==TIMER_ID
,"SetTimer id different\n");
7772 r
= SetEvent(info
->handles
[0]);
7773 ok(r
,"SetEvent failed in thread\n");
7777 static void test_timers(void)
7779 struct timer_info info
;
7782 info
.hWnd
= CreateWindow ("TestWindowClass", NULL
,
7783 WS_OVERLAPPEDWINDOW
,
7784 CW_USEDEFAULT
, CW_USEDEFAULT
, 300, 300, 0,
7787 info
.id
= SetTimer(info
.hWnd
,TIMER_ID
,10000,tfunc
);
7788 ok(info
.id
, "SetTimer failed\n");
7789 ok(info
.id
==TIMER_ID
, "SetTimer timer ID different\n");
7790 info
.handles
[0] = CreateEvent(NULL
,0,0,NULL
);
7791 info
.handles
[1] = CreateThread(NULL
,0,timer_thread_proc
,&info
,0,&id
);
7793 WaitForMultipleObjects(2, info
.handles
, FALSE
, INFINITE
);
7795 WaitForSingleObject(info
.handles
[1], INFINITE
);
7797 CloseHandle(info
.handles
[0]);
7798 CloseHandle(info
.handles
[1]);
7800 ok( KillTimer(info
.hWnd
, TIMER_ID
), "KillTimer failed\n");
7802 ok(DestroyWindow(info
.hWnd
), "failed to destroy window\n");
7805 static int count
= 0;
7806 static VOID CALLBACK
callback_count(
7816 static void test_timers_no_wnd(void)
7822 id
= SetTimer(NULL
, 0, 100, callback_count
);
7823 ok(id
!= 0, "did not get id from SetTimer.\n");
7824 id2
= SetTimer(NULL
, id
, 200, callback_count
);
7825 ok(id2
== id
, "did not get same id from SetTimer when replacing (%li expected %li).\n", id2
, id
);
7827 while (PeekMessage(&msg
, NULL
, 0, 0, PM_REMOVE
)) DispatchMessage(&msg
);
7828 ok(count
== 0, "did not get zero count as expected (%i).\n", count
);
7830 while (PeekMessage(&msg
, NULL
, 0, 0, PM_REMOVE
)) DispatchMessage(&msg
);
7831 ok(count
== 1, "did not get one count as expected (%i).\n", count
);
7832 KillTimer(NULL
, id
);
7834 while (PeekMessage(&msg
, NULL
, 0, 0, PM_REMOVE
)) DispatchMessage(&msg
);
7835 ok(count
== 1, "killing replaced timer did not work (%i).\n", count
);
7838 /* Various win events with arbitrary parameters */
7839 static const struct message WmWinEventsSeq
[] = {
7840 { EVENT_SYSTEM_SOUND
, winevent_hook
|wparam
|lparam
, OBJID_WINDOW
, 0 },
7841 { EVENT_SYSTEM_ALERT
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 1 },
7842 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, OBJID_TITLEBAR
, 2 },
7843 { EVENT_SYSTEM_MENUSTART
, winevent_hook
|wparam
|lparam
, OBJID_MENU
, 3 },
7844 { EVENT_SYSTEM_MENUEND
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 4 },
7845 { EVENT_SYSTEM_MENUPOPUPSTART
, winevent_hook
|wparam
|lparam
, OBJID_VSCROLL
, 5 },
7846 { EVENT_SYSTEM_MENUPOPUPEND
, winevent_hook
|wparam
|lparam
, OBJID_HSCROLL
, 6 },
7847 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, OBJID_SIZEGRIP
, 7 },
7848 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 8 },
7849 /* our win event hook ignores OBJID_CURSOR events */
7850 /*{ EVENT_SYSTEM_MOVESIZESTART, winevent_hook|wparam|lparam, OBJID_CURSOR, 9 },*/
7851 { EVENT_SYSTEM_MOVESIZEEND
, winevent_hook
|wparam
|lparam
, OBJID_ALERT
, 10 },
7852 { EVENT_SYSTEM_CONTEXTHELPSTART
, winevent_hook
|wparam
|lparam
, OBJID_SOUND
, 11 },
7853 { EVENT_SYSTEM_CONTEXTHELPEND
, winevent_hook
|wparam
|lparam
, OBJID_QUERYCLASSNAMEIDX
, 12 },
7854 { EVENT_SYSTEM_DRAGDROPSTART
, winevent_hook
|wparam
|lparam
, OBJID_NATIVEOM
, 13 },
7855 { EVENT_SYSTEM_DRAGDROPEND
, winevent_hook
|wparam
|lparam
, OBJID_WINDOW
, 0 },
7856 { EVENT_SYSTEM_DIALOGSTART
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 1 },
7857 { EVENT_SYSTEM_DIALOGEND
, winevent_hook
|wparam
|lparam
, OBJID_TITLEBAR
, 2 },
7858 { EVENT_SYSTEM_SCROLLINGSTART
, winevent_hook
|wparam
|lparam
, OBJID_MENU
, 3 },
7859 { EVENT_SYSTEM_SCROLLINGEND
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 4 },
7860 { EVENT_SYSTEM_SWITCHSTART
, winevent_hook
|wparam
|lparam
, OBJID_VSCROLL
, 5 },
7861 { EVENT_SYSTEM_SWITCHEND
, winevent_hook
|wparam
|lparam
, OBJID_HSCROLL
, 6 },
7862 { EVENT_SYSTEM_MINIMIZESTART
, winevent_hook
|wparam
|lparam
, OBJID_SIZEGRIP
, 7 },
7863 { EVENT_SYSTEM_MINIMIZEEND
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 8 },
7866 static const struct message WmWinEventCaretSeq
[] = {
7867 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 1 */
7868 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 1 */
7869 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 2 */
7870 { EVENT_OBJECT_NAMECHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 1 */
7873 static const struct message WmWinEventCaretSeq_2
[] = {
7874 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 1/2 */
7875 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 1/2 */
7876 { EVENT_OBJECT_NAMECHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 1/2 */
7879 static const struct message WmWinEventAlertSeq
[] = {
7880 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_ALERT
, 0 },
7883 static const struct message WmWinEventAlertSeq_2
[] = {
7884 /* create window in the thread proc */
7885 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_WINDOW
, 2 },
7886 /* our test event */
7887 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_ALERT
, 2 },
7890 static const struct message WmGlobalHookSeq_1
[] = {
7891 /* create window in the thread proc */
7892 { HCBT_CREATEWND
, hook
|lparam
, 0, 2 },
7893 /* our test events */
7894 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_PREVWINDOW
, 2 },
7895 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_NEXTWINDOW
, 2 },
7898 static const struct message WmGlobalHookSeq_2
[] = {
7899 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_NEXTWINDOW
, 0 }, /* old local hook */
7900 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_NEXTWINDOW
, 2 }, /* new global hook */
7901 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_PREVWINDOW
, 0 }, /* old local hook */
7902 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_PREVWINDOW
, 2 }, /* new global hook */
7906 static const struct message WmMouseLLHookSeq
[] = {
7907 { WM_MOUSEMOVE
, hook
},
7908 { WM_LBUTTONUP
, hook
},
7909 { WM_MOUSEMOVE
, hook
},
7913 static void CALLBACK
win_event_global_hook_proc(HWINEVENTHOOK hevent
,
7923 if (GetClassNameA(hwnd
, buf
, sizeof(buf
)))
7925 if (!lstrcmpiA(buf
, "TestWindowClass") ||
7926 !lstrcmpiA(buf
, "static"))
7928 struct recvd_message msg
;
7931 msg
.message
= event
;
7932 msg
.flags
= winevent_hook
|wparam
|lparam
;
7933 msg
.wParam
= object_id
;
7934 msg
.lParam
= (thread_id
== GetCurrentThreadId()) ? child_id
: (child_id
+ 2);
7935 msg
.descr
= "WEH_2";
7941 static HHOOK hCBT_global_hook
;
7942 static DWORD cbt_global_hook_thread_id
;
7944 static LRESULT CALLBACK
cbt_global_hook_proc(int nCode
, WPARAM wParam
, LPARAM lParam
)
7949 if (nCode
== HCBT_SYSCOMMAND
)
7951 struct recvd_message msg
;
7954 msg
.message
= nCode
;
7955 msg
.flags
= hook
|wparam
|lparam
;
7956 msg
.wParam
= wParam
;
7957 msg
.lParam
= (cbt_global_hook_thread_id
== GetCurrentThreadId()) ? 1 : 2;
7958 msg
.descr
= "CBT_2";
7961 return CallNextHookEx(hCBT_global_hook
, nCode
, wParam
, lParam
);
7963 /* WH_MOUSE_LL hook */
7964 if (nCode
== HC_ACTION
)
7966 MSLLHOOKSTRUCT
*mhll
= (MSLLHOOKSTRUCT
*)lParam
;
7968 /* we can't test for real mouse events */
7969 if (mhll
->flags
& LLMHF_INJECTED
)
7971 struct recvd_message msg
;
7973 memset (&msg
, 0, sizeof (msg
));
7974 msg
.message
= wParam
;
7976 msg
.descr
= "CBT_2";
7979 return CallNextHookEx(hCBT_global_hook
, nCode
, wParam
, lParam
);
7982 /* Log also SetFocus(0) calls */
7983 hwnd
= wParam
? (HWND
)wParam
: (HWND
)lParam
;
7985 if (GetClassNameA(hwnd
, buf
, sizeof(buf
)))
7987 if (!lstrcmpiA(buf
, "TestWindowClass") ||
7988 !lstrcmpiA(buf
, "static"))
7990 struct recvd_message msg
;
7993 msg
.message
= nCode
;
7994 msg
.flags
= hook
|wparam
|lparam
;
7995 msg
.wParam
= wParam
;
7996 msg
.lParam
= (cbt_global_hook_thread_id
== GetCurrentThreadId()) ? 1 : 2;
7997 msg
.descr
= "CBT_2";
8001 return CallNextHookEx(hCBT_global_hook
, nCode
, wParam
, lParam
);
8004 static DWORD WINAPI
win_event_global_thread_proc(void *param
)
8008 HANDLE hevent
= *(HANDLE
*)param
;
8010 assert(pNotifyWinEvent
);
8012 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
, 0,0,0,0,0,0,0, NULL
);
8014 trace("created thread window %p\n", hwnd
);
8016 *(HWND
*)param
= hwnd
;
8019 /* this event should be received only by our new hook proc,
8020 * an old one does not expect an event from another thread.
8022 pNotifyWinEvent(EVENT_OBJECT_LOCATIONCHANGE
, hwnd
, OBJID_ALERT
, 0);
8025 while (GetMessage(&msg
, 0, 0, 0))
8027 TranslateMessage(&msg
);
8028 DispatchMessage(&msg
);
8033 static DWORD WINAPI
cbt_global_hook_thread_proc(void *param
)
8037 HANDLE hevent
= *(HANDLE
*)param
;
8040 /* these events should be received only by our new hook proc,
8041 * an old one does not expect an event from another thread.
8044 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
, 0,0,0,0,0,0,0, NULL
);
8046 trace("created thread window %p\n", hwnd
);
8048 *(HWND
*)param
= hwnd
;
8050 /* Windows doesn't like when a thread plays games with the focus,
8051 that leads to all kinds of misbehaviours and failures to activate
8052 a window. So, better keep next lines commented out.
8056 DefWindowProcA(hwnd
, WM_SYSCOMMAND
, SC_PREVWINDOW
, 0);
8057 DefWindowProcA(hwnd
, WM_SYSCOMMAND
, SC_NEXTWINDOW
, 0);
8061 while (GetMessage(&msg
, 0, 0, 0))
8063 TranslateMessage(&msg
);
8064 DispatchMessage(&msg
);
8069 static DWORD WINAPI
mouse_ll_global_thread_proc(void *param
)
8073 HANDLE hevent
= *(HANDLE
*)param
;
8075 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
, 0,0,0,0,0,0,0, NULL
);
8077 trace("created thread window %p\n", hwnd
);
8079 *(HWND
*)param
= hwnd
;
8083 /* Windows doesn't like when a thread plays games with the focus,
8084 * that leads to all kinds of misbehaviours and failures to activate
8085 * a window. So, better don't generate a mouse click message below.
8087 mouse_event(MOUSEEVENTF_MOVE
, -1, 0, 0, 0);
8088 mouse_event(MOUSEEVENTF_LEFTUP
, 0, 0, 0, 0);
8089 mouse_event(MOUSEEVENTF_MOVE
, 1, 0, 0, 0);
8092 while (GetMessage(&msg
, 0, 0, 0))
8094 TranslateMessage(&msg
);
8095 DispatchMessage(&msg
);
8100 static void test_winevents(void)
8106 HANDLE hthread
, hevent
;
8108 HWINEVENTHOOK hhook
;
8109 const struct message
*events
= WmWinEventsSeq
;
8111 hwnd
= CreateWindowExA(0, "TestWindowClass", NULL
,
8112 WS_OVERLAPPEDWINDOW
,
8113 CW_USEDEFAULT
, CW_USEDEFAULT
, 300, 300, 0,
8117 /****** start of global hook test *************/
8118 hCBT_global_hook
= SetWindowsHookExA(WH_CBT
, cbt_global_hook_proc
, GetModuleHandleA(0), 0);
8119 if (!hCBT_global_hook
)
8121 ok(DestroyWindow(hwnd
), "failed to destroy window\n");
8122 skip( "cannot set global hook\n" );
8126 hevent
= CreateEventA(NULL
, 0, 0, NULL
);
8130 hthread
= CreateThread(NULL
, 0, cbt_global_hook_thread_proc
, &hwnd2
, 0, &tid
);
8131 ok(hthread
!= NULL
, "CreateThread failed, error %d\n", GetLastError());
8133 ok(WaitForSingleObject(hevent
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
8135 ok_sequence(WmGlobalHookSeq_1
, "global hook 1", FALSE
);
8138 /* this one should be received only by old hook proc */
8139 DefWindowProcA(hwnd
, WM_SYSCOMMAND
, SC_NEXTWINDOW
, 0);
8140 /* this one should be received only by old hook proc */
8141 DefWindowProcA(hwnd
, WM_SYSCOMMAND
, SC_PREVWINDOW
, 0);
8143 ok_sequence(WmGlobalHookSeq_2
, "global hook 2", FALSE
);
8145 ret
= UnhookWindowsHookEx(hCBT_global_hook
);
8146 ok( ret
, "UnhookWindowsHookEx error %d\n", GetLastError());
8148 PostThreadMessageA(tid
, WM_QUIT
, 0, 0);
8149 ok(WaitForSingleObject(hthread
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
8150 CloseHandle(hthread
);
8151 CloseHandle(hevent
);
8152 ok(!IsWindow(hwnd2
), "window should be destroyed on thread exit\n");
8153 /****** end of global hook test *************/
8155 if (!pSetWinEventHook
|| !pNotifyWinEvent
|| !pUnhookWinEvent
)
8157 ok(DestroyWindow(hwnd
), "failed to destroy window\n");
8165 /* this test doesn't pass under Win9x */
8166 /* win2k ignores events with hwnd == 0 */
8167 SetLastError(0xdeadbeef);
8168 pNotifyWinEvent(events
[0].message
, 0, events
[0].wParam
, events
[0].lParam
);
8169 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
|| /* Win2k */
8170 GetLastError() == 0xdeadbeef, /* Win9x */
8171 "unexpected error %d\n", GetLastError());
8172 ok_sequence(WmEmptySeq
, "empty notify winevents", FALSE
);
8175 for (i
= 0; i
< sizeof(WmWinEventsSeq
)/sizeof(WmWinEventsSeq
[0]); i
++)
8176 pNotifyWinEvent(events
[i
].message
, hwnd
, events
[i
].wParam
, events
[i
].lParam
);
8178 ok_sequence(WmWinEventsSeq
, "notify winevents", FALSE
);
8180 /****** start of event filtering test *************/
8181 hhook
= pSetWinEventHook(
8182 EVENT_OBJECT_SHOW
, /* 0x8002 */
8183 EVENT_OBJECT_LOCATIONCHANGE
, /* 0x800B */
8184 GetModuleHandleA(0), win_event_global_hook_proc
,
8185 GetCurrentProcessId(), 0,
8186 WINEVENT_INCONTEXT
);
8187 ok(hhook
!= 0, "SetWinEventHook error %d\n", GetLastError());
8189 hevent
= CreateEventA(NULL
, 0, 0, NULL
);
8193 hthread
= CreateThread(NULL
, 0, win_event_global_thread_proc
, &hwnd2
, 0, &tid
);
8194 ok(hthread
!= NULL
, "CreateThread failed, error %d\n", GetLastError());
8196 ok(WaitForSingleObject(hevent
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
8198 ok_sequence(WmWinEventAlertSeq
, "alert winevent", FALSE
);
8201 /* this one should be received only by old hook proc */
8202 pNotifyWinEvent(EVENT_OBJECT_CREATE
, hwnd
, OBJID_CARET
, 0); /* 0x8000 */
8203 pNotifyWinEvent(EVENT_OBJECT_SHOW
, hwnd
, OBJID_CARET
, 0); /* 0x8002 */
8204 /* this one should be received only by old hook proc */
8205 pNotifyWinEvent(EVENT_OBJECT_NAMECHANGE
, hwnd
, OBJID_CARET
, 0); /* 0x800C */
8207 ok_sequence(WmWinEventCaretSeq
, "caret winevent", FALSE
);
8209 ret
= pUnhookWinEvent(hhook
);
8210 ok( ret
, "UnhookWinEvent error %d\n", GetLastError());
8212 PostThreadMessageA(tid
, WM_QUIT
, 0, 0);
8213 ok(WaitForSingleObject(hthread
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
8214 CloseHandle(hthread
);
8215 CloseHandle(hevent
);
8216 ok(!IsWindow(hwnd2
), "window should be destroyed on thread exit\n");
8217 /****** end of event filtering test *************/
8219 /****** start of out of context event test *************/
8220 hhook
= pSetWinEventHook(EVENT_MIN
, EVENT_MAX
, 0,
8221 win_event_global_hook_proc
, GetCurrentProcessId(), 0,
8222 WINEVENT_OUTOFCONTEXT
);
8223 ok(hhook
!= 0, "SetWinEventHook error %d\n", GetLastError());
8225 hevent
= CreateEventA(NULL
, 0, 0, NULL
);
8231 hthread
= CreateThread(NULL
, 0, win_event_global_thread_proc
, &hwnd2
, 0, &tid
);
8232 ok(hthread
!= NULL
, "CreateThread failed, error %d\n", GetLastError());
8234 ok(WaitForSingleObject(hevent
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
8236 ok_sequence(WmEmptySeq
, "empty notify winevents", FALSE
);
8237 /* process pending winevent messages */
8238 ok(!PeekMessageA(&msg
, 0, 0, 0, PM_NOREMOVE
), "msg queue should be empty\n");
8239 ok_sequence(WmWinEventAlertSeq_2
, "alert winevent for out of context proc", FALSE
);
8242 /* this one should be received only by old hook proc */
8243 pNotifyWinEvent(EVENT_OBJECT_CREATE
, hwnd
, OBJID_CARET
, 0); /* 0x8000 */
8244 pNotifyWinEvent(EVENT_OBJECT_SHOW
, hwnd
, OBJID_CARET
, 0); /* 0x8002 */
8245 /* this one should be received only by old hook proc */
8246 pNotifyWinEvent(EVENT_OBJECT_NAMECHANGE
, hwnd
, OBJID_CARET
, 0); /* 0x800C */
8248 ok_sequence(WmWinEventCaretSeq_2
, "caret winevent for incontext proc", FALSE
);
8249 /* process pending winevent messages */
8250 ok(!PeekMessageA(&msg
, 0, 0, 0, PM_NOREMOVE
), "msg queue should be empty\n");
8251 ok_sequence(WmWinEventCaretSeq_2
, "caret winevent for out of context proc", FALSE
);
8253 ret
= pUnhookWinEvent(hhook
);
8254 ok( ret
, "UnhookWinEvent error %d\n", GetLastError());
8256 PostThreadMessageA(tid
, WM_QUIT
, 0, 0);
8257 ok(WaitForSingleObject(hthread
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
8258 CloseHandle(hthread
);
8259 CloseHandle(hevent
);
8260 ok(!IsWindow(hwnd2
), "window should be destroyed on thread exit\n");
8261 /****** end of out of context event test *************/
8263 /****** start of MOUSE_LL hook test *************/
8264 hCBT_global_hook
= SetWindowsHookExA(WH_MOUSE_LL
, cbt_global_hook_proc
, GetModuleHandleA(0), 0);
8265 /* WH_MOUSE_LL is not supported on Win9x platforms */
8266 if (!hCBT_global_hook
)
8268 win_skip("Skipping WH_MOUSE_LL test on this platform\n");
8269 goto skip_mouse_ll_hook_test
;
8272 hevent
= CreateEventA(NULL
, 0, 0, NULL
);
8276 hthread
= CreateThread(NULL
, 0, mouse_ll_global_thread_proc
, &hwnd2
, 0, &tid
);
8277 ok(hthread
!= NULL
, "CreateThread failed, error %d\n", GetLastError());
8279 while (WaitForSingleObject(hevent
, 100) == WAIT_TIMEOUT
)
8280 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
8282 ok_sequence(WmMouseLLHookSeq
, "MOUSE_LL hook other thread", FALSE
);
8285 mouse_event(MOUSEEVENTF_MOVE
, -1, 0, 0, 0);
8286 mouse_event(MOUSEEVENTF_LEFTUP
, 0, 0, 0, 0);
8287 mouse_event(MOUSEEVENTF_MOVE
, 1, 0, 0, 0);
8289 ok_sequence(WmMouseLLHookSeq
, "MOUSE_LL hook same thread", FALSE
);
8291 ret
= UnhookWindowsHookEx(hCBT_global_hook
);
8292 ok( ret
, "UnhookWindowsHookEx error %d\n", GetLastError());
8294 PostThreadMessageA(tid
, WM_QUIT
, 0, 0);
8295 ok(WaitForSingleObject(hthread
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
8296 CloseHandle(hthread
);
8297 CloseHandle(hevent
);
8298 ok(!IsWindow(hwnd2
), "window should be destroyed on thread exit\n");
8299 /****** end of MOUSE_LL hook test *************/
8300 skip_mouse_ll_hook_test
:
8302 ok(DestroyWindow(hwnd
), "failed to destroy window\n");
8305 static void test_set_hook(void)
8309 HWINEVENTHOOK hwinevent_hook
;
8311 hhook
= SetWindowsHookExA(WH_CBT
, cbt_hook_proc
, GetModuleHandleA(0), GetCurrentThreadId());
8312 ok(hhook
!= 0, "local hook does not require hModule set to 0\n");
8313 UnhookWindowsHookEx(hhook
);
8317 /* this test doesn't pass under Win9x: BUG! */
8318 SetLastError(0xdeadbeef);
8319 hhook
= SetWindowsHookExA(WH_CBT
, cbt_hook_proc
, 0, 0);
8320 ok(!hhook
, "global hook requires hModule != 0\n");
8321 ok(GetLastError() == ERROR_HOOK_NEEDS_HMOD
, "unexpected error %d\n", GetLastError());
8324 SetLastError(0xdeadbeef);
8325 hhook
= SetWindowsHookExA(WH_CBT
, 0, GetModuleHandleA(0), GetCurrentThreadId());
8326 ok(!hhook
, "SetWinEventHook with invalid proc should fail\n");
8327 ok(GetLastError() == ERROR_INVALID_FILTER_PROC
|| /* Win2k */
8328 GetLastError() == 0xdeadbeef, /* Win9x */
8329 "unexpected error %d\n", GetLastError());
8331 SetLastError(0xdeadbeef);
8332 ok(!UnhookWindowsHookEx((HHOOK
)0xdeadbeef), "UnhookWindowsHookEx succeeded\n");
8333 ok(GetLastError() == ERROR_INVALID_HOOK_HANDLE
|| /* Win2k */
8334 GetLastError() == 0xdeadbeef, /* Win9x */
8335 "unexpected error %d\n", GetLastError());
8337 if (!pSetWinEventHook
|| !pUnhookWinEvent
) return;
8339 /* even process local incontext hooks require hmodule */
8340 SetLastError(0xdeadbeef);
8341 hwinevent_hook
= pSetWinEventHook(EVENT_MIN
, EVENT_MAX
, 0, win_event_proc
,
8342 GetCurrentProcessId(), 0, WINEVENT_INCONTEXT
);
8343 ok(!hwinevent_hook
, "WINEVENT_INCONTEXT requires hModule != 0\n");
8344 ok(GetLastError() == ERROR_HOOK_NEEDS_HMOD
|| /* Win2k */
8345 GetLastError() == 0xdeadbeef, /* Win9x */
8346 "unexpected error %d\n", GetLastError());
8348 /* even thread local incontext hooks require hmodule */
8349 SetLastError(0xdeadbeef);
8350 hwinevent_hook
= pSetWinEventHook(EVENT_MIN
, EVENT_MAX
, 0, win_event_proc
,
8351 GetCurrentProcessId(), GetCurrentThreadId(), WINEVENT_INCONTEXT
);
8352 ok(!hwinevent_hook
, "WINEVENT_INCONTEXT requires hModule != 0\n");
8353 ok(GetLastError() == ERROR_HOOK_NEEDS_HMOD
|| /* Win2k */
8354 GetLastError() == 0xdeadbeef, /* Win9x */
8355 "unexpected error %d\n", GetLastError());
8359 /* these 3 tests don't pass under Win9x */
8360 SetLastError(0xdeadbeef);
8361 hwinevent_hook
= pSetWinEventHook(1, 0, 0, win_event_proc
,
8362 GetCurrentProcessId(), 0, WINEVENT_OUTOFCONTEXT
);
8363 ok(!hwinevent_hook
, "SetWinEventHook with invalid event range should fail\n");
8364 ok(GetLastError() == ERROR_INVALID_HOOK_FILTER
, "unexpected error %d\n", GetLastError());
8366 SetLastError(0xdeadbeef);
8367 hwinevent_hook
= pSetWinEventHook(-1, 1, 0, win_event_proc
,
8368 GetCurrentProcessId(), 0, WINEVENT_OUTOFCONTEXT
);
8369 ok(!hwinevent_hook
, "SetWinEventHook with invalid event range should fail\n");
8370 ok(GetLastError() == ERROR_INVALID_HOOK_FILTER
, "unexpected error %d\n", GetLastError());
8372 SetLastError(0xdeadbeef);
8373 hwinevent_hook
= pSetWinEventHook(EVENT_MIN
, EVENT_MAX
, 0, win_event_proc
,
8374 0, 0xdeadbeef, WINEVENT_OUTOFCONTEXT
);
8375 ok(!hwinevent_hook
, "SetWinEventHook with invalid tid should fail\n");
8376 ok(GetLastError() == ERROR_INVALID_THREAD_ID
, "unexpected error %d\n", GetLastError());
8379 SetLastError(0xdeadbeef);
8380 hwinevent_hook
= pSetWinEventHook(0, 0, 0, win_event_proc
,
8381 GetCurrentProcessId(), 0, WINEVENT_OUTOFCONTEXT
);
8382 ok(hwinevent_hook
!= 0, "SetWinEventHook error %d\n", GetLastError());
8383 ok(GetLastError() == 0xdeadbeef, "unexpected error %d\n", GetLastError());
8384 ret
= pUnhookWinEvent(hwinevent_hook
);
8385 ok( ret
, "UnhookWinEvent error %d\n", GetLastError());
8388 /* This call succeeds under win2k SP4, but fails under Wine.
8389 Does win2k test/use passed process id? */
8390 SetLastError(0xdeadbeef);
8391 hwinevent_hook
= pSetWinEventHook(EVENT_MIN
, EVENT_MAX
, 0, win_event_proc
,
8392 0xdeadbeef, 0, WINEVENT_OUTOFCONTEXT
);
8393 ok(hwinevent_hook
!= 0, "SetWinEventHook error %d\n", GetLastError());
8394 ok(GetLastError() == 0xdeadbeef, "unexpected error %d\n", GetLastError());
8395 ret
= pUnhookWinEvent(hwinevent_hook
);
8396 ok( ret
, "UnhookWinEvent error %d\n", GetLastError());
8399 SetLastError(0xdeadbeef);
8400 ok(!pUnhookWinEvent((HWINEVENTHOOK
)0xdeadbeef), "UnhookWinEvent succeeded\n");
8401 ok(GetLastError() == ERROR_INVALID_HANDLE
|| /* Win2k */
8402 GetLastError() == 0xdeadbeef, /* Win9x */
8403 "unexpected error %d\n", GetLastError());
8406 static const struct message ScrollWindowPaint1
[] = {
8408 { WM_ERASEBKGND
, sent
|beginpaint
},
8409 { WM_GETTEXTLENGTH
, sent
|optional
},
8410 { WM_PAINT
, sent
|optional
},
8411 { WM_NCPAINT
, sent
|beginpaint
|optional
},
8412 { WM_GETTEXT
, sent
|beginpaint
|optional
},
8413 { WM_GETTEXT
, sent
|beginpaint
|optional
},
8414 { WM_GETTEXT
, sent
|beginpaint
|optional
},
8415 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
8416 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
8420 static const struct message ScrollWindowPaint2
[] = {
8425 static void test_scrollwindowex(void)
8428 RECT rect
={0,0,130,130};
8430 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test Scroll",
8431 WS_VISIBLE
|WS_OVERLAPPEDWINDOW
,
8432 100, 100, 200, 200, 0, 0, 0, NULL
);
8433 ok (hwnd
!= 0, "Failed to create overlapped window\n");
8434 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child",
8435 WS_VISIBLE
|WS_CAPTION
|WS_CHILD
,
8436 10, 10, 150, 150, hwnd
, 0, 0, NULL
);
8437 ok (hchild
!= 0, "Failed to create child\n");
8442 /* scroll without the child window */
8443 trace("start scroll\n");
8444 ScrollWindowEx( hwnd
, 10, 10, &rect
, NULL
, NULL
, NULL
,
8445 SW_ERASE
|SW_INVALIDATE
);
8446 ok_sequence(WmEmptySeq
, "ScrollWindowEx", 0);
8447 trace("end scroll\n");
8450 ok_sequence(ScrollWindowPaint1
, "ScrollWindowEx", 0);
8454 /* Now without the SW_ERASE flag */
8455 trace("start scroll\n");
8456 ScrollWindowEx( hwnd
, 10, 10, &rect
, NULL
, NULL
, NULL
, SW_INVALIDATE
);
8457 ok_sequence(WmEmptySeq
, "ScrollWindowEx", 0);
8458 trace("end scroll\n");
8461 ok_sequence(ScrollWindowPaint2
, "ScrollWindowEx", 0);
8465 /* now scroll the child window as well */
8466 trace("start scroll\n");
8467 ScrollWindowEx( hwnd
, 10, 10, &rect
, NULL
, NULL
, NULL
,
8468 SW_SCROLLCHILDREN
|SW_ERASE
|SW_INVALIDATE
);
8469 /* wine sends WM_POSCHANGING, WM_POSCHANGED messages */
8470 /* windows sometimes a WM_MOVE */
8471 ok_sequence(WmEmptySeq
, "ScrollWindowEx", TRUE
);
8472 trace("end scroll\n");
8475 ok_sequence(ScrollWindowPaint1
, "ScrollWindowEx", 0);
8479 /* now scroll with ScrollWindow() */
8480 trace("start scroll with ScrollWindow\n");
8481 ScrollWindow( hwnd
, 5, 5, NULL
, NULL
);
8482 trace("end scroll\n");
8485 ok_sequence(ScrollWindowPaint1
, "ScrollWindow", 0);
8487 ok(DestroyWindow(hchild
), "failed to destroy window\n");
8488 ok(DestroyWindow(hwnd
), "failed to destroy window\n");
8492 static const struct message destroy_window_with_children
[] = {
8493 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* popup */
8494 { HCBT_DESTROYWND
, hook
|lparam
, 0, WND_PARENT_ID
}, /* parent */
8495 { 0x0090, sent
|optional
},
8496 { HCBT_DESTROYWND
, hook
|lparam
, 0, WND_POPUP_ID
}, /* popup */
8497 { 0x0090, sent
|optional
},
8498 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* popup */
8499 { WM_DESTROY
, sent
|wparam
|lparam
, 0, WND_POPUP_ID
}, /* popup */
8500 { WM_CAPTURECHANGED
, sent
|wparam
|lparam
, 0, WND_POPUP_ID
}, /* popup */
8501 { WM_NCDESTROY
, sent
|wparam
|lparam
, 0, WND_POPUP_ID
}, /* popup */
8502 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* parent */
8503 { WM_DESTROY
, sent
|wparam
|lparam
, 0, WND_PARENT_ID
}, /* parent */
8504 { WM_DESTROY
, sent
|wparam
|lparam
, 0, WND_CHILD_ID
+ 2 }, /* child2 */
8505 { WM_DESTROY
, sent
|wparam
|lparam
, 0, WND_CHILD_ID
+ 1 }, /* child1 */
8506 { WM_DESTROY
, sent
|wparam
|lparam
, 0, WND_CHILD_ID
+ 3 }, /* child3 */
8507 { WM_NCDESTROY
, sent
|wparam
|lparam
, 0, WND_CHILD_ID
+ 2 }, /* child2 */
8508 { WM_NCDESTROY
, sent
|wparam
|lparam
, 0, WND_CHILD_ID
+ 3 }, /* child3 */
8509 { WM_NCDESTROY
, sent
|wparam
|lparam
, 0, WND_CHILD_ID
+ 1 }, /* child1 */
8510 { WM_NCDESTROY
, sent
|wparam
|lparam
, 0, WND_PARENT_ID
}, /* parent */
8514 static void test_DestroyWindow(void)
8517 HWND parent
, child1
, child2
, child3
, child4
, test
;
8518 UINT_PTR child_id
= WND_CHILD_ID
+ 1;
8520 parent
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
8521 100, 100, 200, 200, 0, 0, 0, NULL
);
8522 assert(parent
!= 0);
8523 child1
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_CHILD
,
8524 0, 0, 50, 50, parent
, (HMENU
)child_id
++, 0, NULL
);
8525 assert(child1
!= 0);
8526 child2
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_CHILD
,
8527 0, 0, 50, 50, GetDesktopWindow(), (HMENU
)child_id
++, 0, NULL
);
8528 assert(child2
!= 0);
8529 child3
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_CHILD
,
8530 0, 0, 50, 50, child1
, (HMENU
)child_id
++, 0, NULL
);
8531 assert(child3
!= 0);
8532 child4
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_POPUP
,
8533 0, 0, 50, 50, parent
, 0, 0, NULL
);
8534 assert(child4
!= 0);
8536 /* test owner/parent of child2 */
8537 test
= GetParent(child2
);
8538 ok(test
== GetDesktopWindow(), "wrong parent %p\n", test
);
8539 ok(!IsChild(parent
, child2
), "wrong parent/child %p/%p\n", parent
, child2
);
8541 test
= pGetAncestor(child2
, GA_PARENT
);
8542 ok(test
== GetDesktopWindow(), "wrong parent %p\n", test
);
8544 test
= GetWindow(child2
, GW_OWNER
);
8545 ok(!test
, "wrong owner %p\n", test
);
8547 test
= SetParent(child2
, parent
);
8548 ok(test
== GetDesktopWindow(), "wrong old parent %p\n", test
);
8550 /* test owner/parent of the parent */
8551 test
= GetParent(parent
);
8552 ok(!test
, "wrong parent %p\n", test
);
8553 ok(!IsChild(GetDesktopWindow(), parent
), "wrong parent/child %p/%p\n", GetDesktopWindow(), parent
);
8555 test
= pGetAncestor(parent
, GA_PARENT
);
8556 ok(test
== GetDesktopWindow(), "wrong parent %p\n", test
);
8558 test
= GetWindow(parent
, GW_OWNER
);
8559 ok(!test
, "wrong owner %p\n", test
);
8561 /* test owner/parent of child1 */
8562 test
= GetParent(child1
);
8563 ok(test
== parent
, "wrong parent %p\n", test
);
8564 ok(IsChild(parent
, child1
), "wrong parent/child %p/%p\n", parent
, child1
);
8566 test
= pGetAncestor(child1
, GA_PARENT
);
8567 ok(test
== parent
, "wrong parent %p\n", test
);
8569 test
= GetWindow(child1
, GW_OWNER
);
8570 ok(!test
, "wrong owner %p\n", test
);
8572 /* test owner/parent of child2 */
8573 test
= GetParent(child2
);
8574 ok(test
== parent
, "wrong parent %p\n", test
);
8575 ok(IsChild(parent
, child2
), "wrong parent/child %p/%p\n", parent
, child2
);
8577 test
= pGetAncestor(child2
, GA_PARENT
);
8578 ok(test
== parent
, "wrong parent %p\n", test
);
8580 test
= GetWindow(child2
, GW_OWNER
);
8581 ok(!test
, "wrong owner %p\n", test
);
8583 /* test owner/parent of child3 */
8584 test
= GetParent(child3
);
8585 ok(test
== child1
, "wrong parent %p\n", test
);
8586 ok(IsChild(parent
, child3
), "wrong parent/child %p/%p\n", parent
, child3
);
8588 test
= pGetAncestor(child3
, GA_PARENT
);
8589 ok(test
== child1
, "wrong parent %p\n", test
);
8591 test
= GetWindow(child3
, GW_OWNER
);
8592 ok(!test
, "wrong owner %p\n", test
);
8594 /* test owner/parent of child4 */
8595 test
= GetParent(child4
);
8596 ok(test
== parent
, "wrong parent %p\n", test
);
8597 ok(!IsChild(parent
, child4
), "wrong parent/child %p/%p\n", parent
, child4
);
8599 test
= pGetAncestor(child4
, GA_PARENT
);
8600 ok(test
== GetDesktopWindow(), "wrong parent %p\n", test
);
8602 test
= GetWindow(child4
, GW_OWNER
);
8603 ok(test
== parent
, "wrong owner %p\n", test
);
8607 trace("parent %p, child1 %p, child2 %p, child3 %p, child4 %p\n",
8608 parent
, child1
, child2
, child3
, child4
);
8611 test
= GetCapture();
8612 ok(test
== child4
, "wrong capture window %p\n", test
);
8614 test_DestroyWindow_flag
= TRUE
;
8615 ret
= DestroyWindow(parent
);
8616 ok( ret
, "DestroyWindow() error %d\n", GetLastError());
8617 test_DestroyWindow_flag
= FALSE
;
8618 ok_sequence(destroy_window_with_children
, "destroy window with children", 0);
8620 ok(!IsWindow(parent
), "parent still exists\n");
8621 ok(!IsWindow(child1
), "child1 still exists\n");
8622 ok(!IsWindow(child2
), "child2 still exists\n");
8623 ok(!IsWindow(child3
), "child3 still exists\n");
8624 ok(!IsWindow(child4
), "child4 still exists\n");
8626 test
= GetCapture();
8627 ok(!test
, "wrong capture window %p\n", test
);
8631 static const struct message WmDispatchPaint
[] = {
8632 { WM_NCPAINT
, sent
},
8633 { WM_GETTEXT
, sent
|defwinproc
|optional
},
8634 { WM_GETTEXT
, sent
|defwinproc
|optional
},
8635 { WM_ERASEBKGND
, sent
},
8639 static LRESULT WINAPI
DispatchMessageCheckProc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
8641 if (message
== WM_PAINT
) return 0;
8642 return MsgCheckProcA( hwnd
, message
, wParam
, lParam
);
8645 static void test_DispatchMessage(void)
8650 HWND hwnd
= CreateWindowA( "TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
8651 100, 100, 200, 200, 0, 0, 0, NULL
);
8652 ShowWindow( hwnd
, SW_SHOW
);
8653 UpdateWindow( hwnd
);
8656 SetWindowLongPtrA( hwnd
, GWLP_WNDPROC
, (LONG_PTR
)DispatchMessageCheckProc
);
8658 SetRect( &rect
, -5, -5, 5, 5 );
8659 RedrawWindow( hwnd
, &rect
, 0, RDW_INVALIDATE
|RDW_ERASE
|RDW_FRAME
);
8661 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
))
8663 if (msg
.message
!= WM_PAINT
) DispatchMessage( &msg
);
8667 DispatchMessage( &msg
);
8668 /* DispatchMessage will send WM_NCPAINT if non client area is still invalid after WM_PAINT */
8669 if (!count
) ok_sequence( WmDispatchPaint
, "WmDispatchPaint", FALSE
);
8670 else ok_sequence( WmEmptySeq
, "WmEmpty", FALSE
);
8671 if (++count
> 10) break;
8674 ok( msg
.message
== WM_PAINT
&& count
> 10, "WM_PAINT messages stopped\n" );
8676 trace("now without DispatchMessage\n");
8678 RedrawWindow( hwnd
, &rect
, 0, RDW_INVALIDATE
|RDW_ERASE
|RDW_FRAME
);
8680 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
))
8682 if (msg
.message
!= WM_PAINT
) DispatchMessage( &msg
);
8685 HRGN hrgn
= CreateRectRgn( 0, 0, 0, 0 );
8687 /* this will send WM_NCCPAINT just like DispatchMessage does */
8688 GetUpdateRgn( hwnd
, hrgn
, TRUE
);
8689 ok_sequence( WmDispatchPaint
, "WmDispatchPaint", FALSE
);
8690 DeleteObject( hrgn
);
8691 GetClientRect( hwnd
, &rect
);
8692 ValidateRect( hwnd
, &rect
); /* this will stop WM_PAINTs */
8693 ok( !count
, "Got multiple WM_PAINTs\n" );
8694 if (++count
> 10) break;
8697 DestroyWindow(hwnd
);
8701 static const struct message WmUser
[] = {
8713 static DWORD CALLBACK
send_msg_thread( LPVOID arg
)
8715 struct sendmsg_info
*info
= arg
;
8716 SetLastError( 0xdeadbeef );
8717 info
->ret
= SendMessageTimeoutA( info
->hwnd
, WM_USER
, 0, 0, 0, info
->timeout
, NULL
);
8718 if (!info
->ret
) ok( GetLastError() == ERROR_TIMEOUT
||
8719 broken(GetLastError() == 0), /* win9x */
8720 "unexpected error %d\n", GetLastError());
8724 static void wait_for_thread( HANDLE thread
)
8726 while (MsgWaitForMultipleObjects(1, &thread
, FALSE
, INFINITE
, QS_SENDMESSAGE
) != WAIT_OBJECT_0
)
8729 while (PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage(&msg
);
8733 static LRESULT WINAPI
send_msg_delay_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
8735 if (message
== WM_USER
) Sleep(200);
8736 return MsgCheckProcA( hwnd
, message
, wParam
, lParam
);
8739 static void test_SendMessageTimeout(void)
8742 struct sendmsg_info info
;
8746 info
.hwnd
= CreateWindowA( "TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
8747 100, 100, 200, 200, 0, 0, 0, NULL
);
8751 info
.timeout
= 1000;
8752 info
.ret
= 0xdeadbeef;
8753 thread
= CreateThread( NULL
, 0, send_msg_thread
, &info
, 0, &tid
);
8754 wait_for_thread( thread
);
8755 CloseHandle( thread
);
8756 ok( info
.ret
== 1, "SendMessageTimeout failed\n" );
8757 ok_sequence( WmUser
, "WmUser", FALSE
);
8760 info
.ret
= 0xdeadbeef;
8761 thread
= CreateThread( NULL
, 0, send_msg_thread
, &info
, 0, &tid
);
8762 Sleep(100); /* SendMessageTimeout should time out here */
8763 wait_for_thread( thread
);
8764 CloseHandle( thread
);
8765 ok( info
.ret
== 0, "SendMessageTimeout succeeded\n" );
8766 ok_sequence( WmEmptySeq
, "WmEmptySeq", FALSE
);
8768 /* 0 means infinite timeout (but not on win9x) */
8770 info
.ret
= 0xdeadbeef;
8771 thread
= CreateThread( NULL
, 0, send_msg_thread
, &info
, 0, &tid
);
8773 wait_for_thread( thread
);
8774 CloseHandle( thread
);
8775 is_win9x
= !info
.ret
;
8776 if (is_win9x
) ok_sequence( WmEmptySeq
, "WmEmptySeq", FALSE
);
8777 else ok_sequence( WmUser
, "WmUser", FALSE
);
8779 /* timeout is treated as signed despite the prototype (but not on win9x) */
8780 info
.timeout
= 0x7fffffff;
8781 info
.ret
= 0xdeadbeef;
8782 thread
= CreateThread( NULL
, 0, send_msg_thread
, &info
, 0, &tid
);
8784 wait_for_thread( thread
);
8785 CloseHandle( thread
);
8786 ok( info
.ret
== 1, "SendMessageTimeout failed\n" );
8787 ok_sequence( WmUser
, "WmUser", FALSE
);
8789 info
.timeout
= 0x80000000;
8790 info
.ret
= 0xdeadbeef;
8791 thread
= CreateThread( NULL
, 0, send_msg_thread
, &info
, 0, &tid
);
8793 wait_for_thread( thread
);
8794 CloseHandle( thread
);
8797 ok( info
.ret
== 1, "SendMessageTimeout failed\n" );
8798 ok_sequence( WmUser
, "WmUser", FALSE
);
8802 ok( info
.ret
== 0, "SendMessageTimeout succeeded\n" );
8803 ok_sequence( WmEmptySeq
, "WmEmptySeq", FALSE
);
8806 /* now check for timeout during message processing */
8807 SetWindowLongPtrA( info
.hwnd
, GWLP_WNDPROC
, (LONG_PTR
)send_msg_delay_proc
);
8809 info
.ret
= 0xdeadbeef;
8810 thread
= CreateThread( NULL
, 0, send_msg_thread
, &info
, 0, &tid
);
8811 wait_for_thread( thread
);
8812 CloseHandle( thread
);
8813 /* we should time out but still get the message */
8814 ok( info
.ret
== 0, "SendMessageTimeout failed\n" );
8815 ok_sequence( WmUser
, "WmUser", FALSE
);
8817 DestroyWindow( info
.hwnd
);
8821 /****************** edit message test *************************/
8822 #define ID_EDIT 0x1234
8823 static const struct message sl_edit_setfocus
[] =
8825 { HCBT_SETFOCUS
, hook
},
8826 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
8827 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
8828 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
8829 { WM_SETFOCUS
, sent
|wparam
, 0 },
8830 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 10 },
8831 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 15 },
8832 { WM_CTLCOLOREDIT
, sent
|parent
},
8833 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 11 },
8834 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
8835 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
8836 { WM_COMMAND
, sent
|parent
|wparam
, MAKEWPARAM(ID_EDIT
, EN_SETFOCUS
) },
8839 static const struct message ml_edit_setfocus
[] =
8841 { HCBT_SETFOCUS
, hook
},
8842 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
8843 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
8844 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
8845 { WM_SETFOCUS
, sent
|wparam
, 0 },
8846 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 10 },
8847 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 11 },
8848 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
8849 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
8850 { WM_COMMAND
, sent
|parent
|wparam
, MAKEWPARAM(ID_EDIT
, EN_SETFOCUS
) },
8853 static const struct message sl_edit_killfocus
[] =
8855 { HCBT_SETFOCUS
, hook
},
8856 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
8857 { WM_KILLFOCUS
, sent
|wparam
, 0 },
8858 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
8859 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
8860 { WM_COMMAND
, sent
|parent
|wparam
, MAKEWPARAM(ID_EDIT
, EN_KILLFOCUS
) },
8861 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
8862 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 1 },
8865 static const struct message sl_edit_lbutton_dblclk
[] =
8867 { WM_LBUTTONDBLCLK
, sent
},
8868 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
8871 static const struct message sl_edit_lbutton_down
[] =
8873 { WM_LBUTTONDOWN
, sent
|wparam
|lparam
, 0, 0 },
8874 { HCBT_SETFOCUS
, hook
},
8875 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
8876 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
8877 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
8878 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
8879 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 10 },
8880 { WM_CTLCOLOREDIT
, sent
|parent
},
8881 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 11 },
8882 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
8883 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
8884 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
8885 { WM_COMMAND
, sent
|parent
|wparam
, MAKEWPARAM(ID_EDIT
, EN_SETFOCUS
) },
8886 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
8887 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
8888 { WM_CTLCOLOREDIT
, sent
|parent
|optional
},
8889 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 11 },
8890 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
8891 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
8894 static const struct message ml_edit_lbutton_down
[] =
8896 { WM_LBUTTONDOWN
, sent
|wparam
|lparam
, 0, 0 },
8897 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
8898 { HCBT_SETFOCUS
, hook
},
8899 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
8900 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
8901 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
8902 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
8903 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 10 },
8904 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 11 },
8905 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
8906 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
8907 { WM_COMMAND
, sent
|parent
|wparam
, MAKEWPARAM(ID_EDIT
, EN_SETFOCUS
) },
8910 static const struct message sl_edit_lbutton_up
[] =
8912 { WM_LBUTTONUP
, sent
|wparam
|lparam
, 0, 0 },
8913 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
8914 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, 0, 0 },
8915 { WM_CAPTURECHANGED
, sent
|defwinproc
},
8916 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
8919 static const struct message ml_edit_lbutton_up
[] =
8921 { WM_LBUTTONUP
, sent
|wparam
|lparam
, 0, 0 },
8922 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, 0, 0 },
8923 { WM_CAPTURECHANGED
, sent
|defwinproc
},
8927 static WNDPROC old_edit_proc
;
8929 static LRESULT CALLBACK
edit_hook_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
8931 static long defwndproc_counter
= 0;
8933 struct recvd_message msg
;
8935 if (ignore_message( message
)) return 0;
8938 msg
.message
= message
;
8939 msg
.flags
= sent
|wparam
|lparam
;
8940 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
8941 msg
.wParam
= wParam
;
8942 msg
.lParam
= lParam
;
8946 defwndproc_counter
++;
8947 ret
= CallWindowProcA(old_edit_proc
, hwnd
, message
, wParam
, lParam
);
8948 defwndproc_counter
--;
8953 static void subclass_edit(void)
8957 if (!GetClassInfoA(0, "edit", &cls
)) assert(0);
8959 old_edit_proc
= cls
.lpfnWndProc
;
8961 cls
.hInstance
= GetModuleHandle(0);
8962 cls
.lpfnWndProc
= edit_hook_proc
;
8963 cls
.lpszClassName
= "my_edit_class";
8964 UnregisterClass(cls
.lpszClassName
, cls
.hInstance
);
8965 if (!RegisterClassA(&cls
)) assert(0);
8968 static void test_edit_messages(void)
8974 log_all_parent_messages
++;
8976 parent
= CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
8977 100, 100, 200, 200, 0, 0, 0, NULL
);
8978 ok (parent
!= 0, "Failed to create parent window\n");
8980 /* test single line edit */
8981 hwnd
= CreateWindowExA(0, "my_edit_class", "test", WS_CHILD
,
8982 0, 0, 80, 20, parent
, (HMENU
)ID_EDIT
, 0, NULL
);
8983 ok(hwnd
!= 0, "Failed to create edit window\n");
8985 dlg_code
= SendMessageA(hwnd
, WM_GETDLGCODE
, 0, 0);
8986 ok(dlg_code
== (DLGC_WANTCHARS
|DLGC_HASSETSEL
|DLGC_WANTARROWS
), "wrong dlg_code %08x\n", dlg_code
);
8988 ShowWindow(hwnd
, SW_SHOW
);
8994 ok_sequence(sl_edit_setfocus
, "SetFocus(hwnd) on an edit", FALSE
);
8997 ok_sequence(sl_edit_killfocus
, "SetFocus(0) on an edit", FALSE
);
9003 SendMessageA(hwnd
, WM_LBUTTONDBLCLK
, 0, 0);
9004 ok_sequence(sl_edit_lbutton_dblclk
, "WM_LBUTTONDBLCLK on an edit", FALSE
);
9010 SendMessageA(hwnd
, WM_LBUTTONDOWN
, 0, 0);
9011 ok_sequence(sl_edit_lbutton_down
, "WM_LBUTTONDOWN on an edit", FALSE
);
9013 SendMessageA(hwnd
, WM_LBUTTONUP
, 0, 0);
9014 ok_sequence(sl_edit_lbutton_up
, "WM_LBUTTONUP on an edit", FALSE
);
9016 DestroyWindow(hwnd
);
9018 /* test multiline edit */
9019 hwnd
= CreateWindowExA(0, "my_edit_class", "test", WS_CHILD
| ES_MULTILINE
,
9020 0, 0, 80, 20, parent
, (HMENU
)ID_EDIT
, 0, NULL
);
9021 ok(hwnd
!= 0, "Failed to create edit window\n");
9023 dlg_code
= SendMessageA(hwnd
, WM_GETDLGCODE
, 0, 0);
9024 ok(dlg_code
== (DLGC_WANTCHARS
|DLGC_HASSETSEL
|DLGC_WANTARROWS
|DLGC_WANTALLKEYS
),
9025 "wrong dlg_code %08x\n", dlg_code
);
9027 ShowWindow(hwnd
, SW_SHOW
);
9033 ok_sequence(ml_edit_setfocus
, "SetFocus(hwnd) on multiline edit", FALSE
);
9036 ok_sequence(sl_edit_killfocus
, "SetFocus(0) on multiline edit", FALSE
);
9042 SendMessageA(hwnd
, WM_LBUTTONDBLCLK
, 0, 0);
9043 ok_sequence(sl_edit_lbutton_dblclk
, "WM_LBUTTONDBLCLK on multiline edit", FALSE
);
9049 SendMessageA(hwnd
, WM_LBUTTONDOWN
, 0, 0);
9050 ok_sequence(ml_edit_lbutton_down
, "WM_LBUTTONDOWN on multiline edit", FALSE
);
9052 SendMessageA(hwnd
, WM_LBUTTONUP
, 0, 0);
9053 ok_sequence(ml_edit_lbutton_up
, "WM_LBUTTONUP on multiline edit", FALSE
);
9055 DestroyWindow(hwnd
);
9056 DestroyWindow(parent
);
9058 log_all_parent_messages
--;
9061 /**************************** End of Edit test ******************************/
9063 static const struct message WmKeyDownSkippedSeq
[] =
9065 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 1 }, /* XP */
9068 static const struct message WmKeyDownWasDownSkippedSeq
[] =
9070 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0x40000001 }, /* XP */
9073 static const struct message WmKeyUpSkippedSeq
[] =
9075 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xc0000001 }, /* XP */
9078 static const struct message WmUserKeyUpSkippedSeq
[] =
9081 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xc0000001 }, /* XP */
9086 #define EV_SENDMSG 1
9092 HANDLE hevent
[3]; /* 0 - start/stop, 1 - SendMessage, 2 - ack */
9095 static DWORD CALLBACK
send_msg_thread_2(void *param
)
9098 struct peekmsg_info
*info
= param
;
9100 trace("thread: looping\n");
9101 SetEvent(info
->hevent
[EV_ACK
]);
9105 ret
= WaitForMultipleObjects(2, info
->hevent
, FALSE
, INFINITE
);
9109 case WAIT_OBJECT_0
+ EV_STOP
:
9110 trace("thread: exiting\n");
9113 case WAIT_OBJECT_0
+ EV_SENDMSG
:
9114 trace("thread: sending message\n");
9115 ok( SendNotifyMessageA(info
->hwnd
, WM_USER
, 0, 0),
9116 "SendNotifyMessageA failed error %u\n", GetLastError());
9117 SetEvent(info
->hevent
[EV_ACK
]);
9121 trace("unexpected return: %04x\n", ret
);
9129 static void test_PeekMessage(void)
9134 UINT qs_all_input
= QS_ALLINPUT
;
9135 UINT qs_input
= QS_INPUT
;
9137 struct peekmsg_info info
;
9139 info
.hwnd
= CreateWindowA("TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
9140 100, 100, 200, 200, 0, 0, 0, NULL
);
9142 ShowWindow(info
.hwnd
, SW_SHOW
);
9143 UpdateWindow(info
.hwnd
);
9144 SetFocus(info
.hwnd
);
9146 info
.hevent
[EV_STOP
] = CreateEventA(NULL
, 0, 0, NULL
);
9147 info
.hevent
[EV_SENDMSG
] = CreateEventA(NULL
, 0, 0, NULL
);
9148 info
.hevent
[EV_ACK
] = CreateEventA(NULL
, 0, 0, NULL
);
9150 hthread
= CreateThread(NULL
, 0, send_msg_thread_2
, &info
, 0, &tid
);
9151 WaitForSingleObject(info
.hevent
[EV_ACK
], 10000);
9156 SetLastError(0xdeadbeef);
9157 qstatus
= GetQueueStatus(qs_all_input
);
9158 if (GetLastError() == ERROR_INVALID_FLAGS
)
9160 trace("QS_RAWINPUT not supported on this platform\n");
9161 qs_all_input
&= ~QS_RAWINPUT
;
9162 qs_input
&= ~QS_RAWINPUT
;
9164 if (qstatus
& QS_POSTMESSAGE
)
9166 while (PeekMessage(&msg
, 0, 0, 0, PM_REMOVE
)) /* nothing */ ;
9167 qstatus
= GetQueueStatus(qs_all_input
);
9169 ok(qstatus
== 0, "wrong qstatus %08x\n", qstatus
);
9171 trace("signalling to send message\n");
9172 SetEvent(info
.hevent
[EV_SENDMSG
]);
9173 WaitForSingleObject(info
.hevent
[EV_ACK
], INFINITE
);
9175 /* pass invalid QS_xxxx flags */
9176 SetLastError(0xdeadbeef);
9177 qstatus
= GetQueueStatus(0xffffffff);
9178 ok(qstatus
== 0 || broken(qstatus
) /* win9x */, "GetQueueStatus should fail: %08x\n", qstatus
);
9181 ok(GetLastError() == ERROR_INVALID_FLAGS
, "wrong error %d\n", GetLastError());
9182 qstatus
= GetQueueStatus(qs_all_input
);
9184 qstatus
&= ~MAKELONG( 0x4000, 0x4000 ); /* sometimes set on Win95 */
9185 ok(qstatus
== MAKELONG(QS_SENDMESSAGE
, QS_SENDMESSAGE
),
9186 "wrong qstatus %08x\n", qstatus
);
9189 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
9191 "PeekMessageA should have returned FALSE instead of msg %04x\n",
9193 ok_sequence(WmUser
, "WmUser", FALSE
);
9195 qstatus
= GetQueueStatus(qs_all_input
);
9196 ok(qstatus
== 0, "wrong qstatus %08x\n", qstatus
);
9198 keybd_event('N', 0, 0, 0);
9199 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
9200 qstatus
= GetQueueStatus(qs_all_input
);
9201 if (!(qstatus
& MAKELONG(QS_KEY
, QS_KEY
)))
9203 skip( "queuing key events not supported\n" );
9206 ok(qstatus
== MAKELONG(QS_KEY
, QS_KEY
),
9207 "wrong qstatus %08x\n", qstatus
);
9209 PostMessageA(info
.hwnd
, WM_CHAR
, 'z', 0);
9210 qstatus
= GetQueueStatus(qs_all_input
);
9211 ok(qstatus
== MAKELONG(QS_POSTMESSAGE
, QS_POSTMESSAGE
|QS_KEY
),
9212 "wrong qstatus %08x\n", qstatus
);
9214 InvalidateRect(info
.hwnd
, NULL
, FALSE
);
9215 qstatus
= GetQueueStatus(qs_all_input
);
9216 ok(qstatus
== MAKELONG(QS_PAINT
, QS_PAINT
|QS_POSTMESSAGE
|QS_KEY
),
9217 "wrong qstatus %08x\n", qstatus
);
9219 trace("signalling to send message\n");
9220 SetEvent(info
.hevent
[EV_SENDMSG
]);
9221 WaitForSingleObject(info
.hevent
[EV_ACK
], INFINITE
);
9223 qstatus
= GetQueueStatus(qs_all_input
);
9224 ok(qstatus
== MAKELONG(QS_SENDMESSAGE
, QS_SENDMESSAGE
|QS_PAINT
|QS_POSTMESSAGE
|QS_KEY
),
9225 "wrong qstatus %08x\n", qstatus
);
9228 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| (qs_input
<< 16));
9229 if (ret
&& msg
.message
== WM_CHAR
)
9231 win_skip( "PM_QS_* flags not supported in PeekMessage\n" );
9235 "PeekMessageA should have returned FALSE instead of msg %04x\n",
9237 if (!sequence_cnt
) /* nt4 doesn't fetch anything with PM_QS_* flags */
9239 win_skip( "PM_QS_* flags not supported in PeekMessage\n" );
9242 ok_sequence(WmUser
, "WmUser", FALSE
);
9244 qstatus
= GetQueueStatus(qs_all_input
);
9245 ok(qstatus
== MAKELONG(0, QS_PAINT
|QS_POSTMESSAGE
|QS_KEY
),
9246 "wrong qstatus %08x\n", qstatus
);
9248 trace("signalling to send message\n");
9249 SetEvent(info
.hevent
[EV_SENDMSG
]);
9250 WaitForSingleObject(info
.hevent
[EV_ACK
], INFINITE
);
9252 qstatus
= GetQueueStatus(qs_all_input
);
9253 ok(qstatus
== MAKELONG(QS_SENDMESSAGE
, QS_SENDMESSAGE
|QS_PAINT
|QS_POSTMESSAGE
|QS_KEY
),
9254 "wrong qstatus %08x\n", qstatus
);
9257 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| PM_QS_POSTMESSAGE
);
9259 "PeekMessageA should have returned FALSE instead of msg %04x\n",
9261 ok_sequence(WmUser
, "WmUser", FALSE
);
9263 qstatus
= GetQueueStatus(qs_all_input
);
9264 ok(qstatus
== MAKELONG(0, QS_PAINT
|QS_POSTMESSAGE
|QS_KEY
),
9265 "wrong qstatus %08x\n", qstatus
);
9268 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| PM_QS_POSTMESSAGE
);
9269 ok(ret
&& msg
.message
== WM_CHAR
&& msg
.wParam
== 'z',
9270 "got %d and %04x wParam %08lx instead of TRUE and WM_CHAR wParam 'z'\n",
9271 ret
, msg
.message
, msg
.wParam
);
9272 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
9274 qstatus
= GetQueueStatus(qs_all_input
);
9275 ok(qstatus
== MAKELONG(0, QS_PAINT
|QS_KEY
),
9276 "wrong qstatus %08x\n", qstatus
);
9279 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| PM_QS_POSTMESSAGE
);
9281 "PeekMessageA should have returned FALSE instead of msg %04x\n",
9283 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
9285 qstatus
= GetQueueStatus(qs_all_input
);
9286 ok(qstatus
== MAKELONG(0, QS_PAINT
|QS_KEY
),
9287 "wrong qstatus %08x\n", qstatus
);
9290 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| PM_QS_PAINT
);
9291 ok(ret
&& msg
.message
== WM_PAINT
,
9292 "got %d and %04x instead of TRUE and WM_PAINT\n", ret
, msg
.message
);
9293 DispatchMessageA(&msg
);
9294 ok_sequence(WmPaint
, "WmPaint", FALSE
);
9296 qstatus
= GetQueueStatus(qs_all_input
);
9297 ok(qstatus
== MAKELONG(0, QS_KEY
),
9298 "wrong qstatus %08x\n", qstatus
);
9301 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| PM_QS_PAINT
);
9303 "PeekMessageA should have returned FALSE instead of msg %04x\n",
9305 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
9307 qstatus
= GetQueueStatus(qs_all_input
);
9308 ok(qstatus
== MAKELONG(0, QS_KEY
),
9309 "wrong qstatus %08x\n", qstatus
);
9311 trace("signalling to send message\n");
9312 SetEvent(info
.hevent
[EV_SENDMSG
]);
9313 WaitForSingleObject(info
.hevent
[EV_ACK
], INFINITE
);
9315 qstatus
= GetQueueStatus(qs_all_input
);
9316 ok(qstatus
== MAKELONG(QS_SENDMESSAGE
, QS_SENDMESSAGE
|QS_KEY
),
9317 "wrong qstatus %08x\n", qstatus
);
9319 PostMessageA(info
.hwnd
, WM_CHAR
, 'z', 0);
9321 qstatus
= GetQueueStatus(qs_all_input
);
9322 ok(qstatus
== MAKELONG(QS_POSTMESSAGE
, QS_SENDMESSAGE
|QS_POSTMESSAGE
|QS_KEY
),
9323 "wrong qstatus %08x\n", qstatus
);
9326 ret
= PeekMessageA(&msg
, 0, WM_CHAR
, WM_CHAR
, PM_REMOVE
);
9327 ok(ret
&& msg
.message
== WM_CHAR
&& msg
.wParam
== 'z',
9328 "got %d and %04x wParam %08lx instead of TRUE and WM_CHAR wParam 'z'\n",
9329 ret
, msg
.message
, msg
.wParam
);
9330 ok_sequence(WmUser
, "WmUser", FALSE
);
9332 qstatus
= GetQueueStatus(qs_all_input
);
9333 ok(qstatus
== MAKELONG(0, QS_KEY
),
9334 "wrong qstatus %08x\n", qstatus
);
9337 ret
= PeekMessageA(&msg
, 0, WM_CHAR
, WM_CHAR
, PM_REMOVE
);
9339 "PeekMessageA should have returned FALSE instead of msg %04x\n",
9341 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
9343 qstatus
= GetQueueStatus(qs_all_input
);
9344 ok(qstatus
== MAKELONG(0, QS_KEY
),
9345 "wrong qstatus %08x\n", qstatus
);
9347 PostMessageA(info
.hwnd
, WM_CHAR
, 'z', 0);
9349 qstatus
= GetQueueStatus(qs_all_input
);
9350 ok(qstatus
== MAKELONG(QS_POSTMESSAGE
, QS_POSTMESSAGE
|QS_KEY
),
9351 "wrong qstatus %08x\n", qstatus
);
9353 trace("signalling to send message\n");
9354 SetEvent(info
.hevent
[EV_SENDMSG
]);
9355 WaitForSingleObject(info
.hevent
[EV_ACK
], INFINITE
);
9357 qstatus
= GetQueueStatus(qs_all_input
);
9358 ok(qstatus
== MAKELONG(QS_SENDMESSAGE
, QS_SENDMESSAGE
|QS_POSTMESSAGE
|QS_KEY
),
9359 "wrong qstatus %08x\n", qstatus
);
9362 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| (QS_KEY
<< 16));
9364 "PeekMessageA should have returned FALSE instead of msg %04x\n",
9366 ok_sequence(WmUser
, "WmUser", FALSE
);
9368 qstatus
= GetQueueStatus(qs_all_input
);
9369 ok(qstatus
== MAKELONG(0, QS_POSTMESSAGE
|QS_KEY
),
9370 "wrong qstatus %08x\n", qstatus
);
9373 if (qs_all_input
& QS_RAWINPUT
) /* use QS_RAWINPUT only if supported */
9374 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| (QS_RAWINPUT
<< 16));
9375 else /* workaround for a missing QS_RAWINPUT support */
9376 ret
= PeekMessageA(&msg
, 0, WM_KEYDOWN
, WM_KEYDOWN
, PM_REMOVE
);
9377 ok(ret
&& msg
.message
== WM_KEYDOWN
&& msg
.wParam
== 'N',
9378 "got %d and %04x wParam %08lx instead of TRUE and WM_KEYDOWN wParam 'N'\n",
9379 ret
, msg
.message
, msg
.wParam
);
9380 ok_sequence(WmKeyDownSkippedSeq
, "WmKeyDownSkippedSeq", FALSE
);
9382 qstatus
= GetQueueStatus(qs_all_input
);
9383 ok(qstatus
== MAKELONG(0, QS_POSTMESSAGE
|QS_KEY
),
9384 "wrong qstatus %08x\n", qstatus
);
9387 if (qs_all_input
& QS_RAWINPUT
) /* use QS_RAWINPUT only if supported */
9388 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| (QS_RAWINPUT
<< 16));
9389 else /* workaround for a missing QS_RAWINPUT support */
9390 ret
= PeekMessageA(&msg
, 0, WM_KEYUP
, WM_KEYUP
, PM_REMOVE
);
9391 ok(ret
&& msg
.message
== WM_KEYUP
&& msg
.wParam
== 'N',
9392 "got %d and %04x wParam %08lx instead of TRUE and WM_KEYUP wParam 'N'\n",
9393 ret
, msg
.message
, msg
.wParam
);
9394 ok_sequence(WmKeyUpSkippedSeq
, "WmKeyUpSkippedSeq", FALSE
);
9396 qstatus
= GetQueueStatus(qs_all_input
);
9397 ok(qstatus
== MAKELONG(0, QS_POSTMESSAGE
),
9398 "wrong qstatus %08x\n", qstatus
);
9401 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| PM_QS_SENDMESSAGE
);
9403 "PeekMessageA should have returned FALSE instead of msg %04x\n",
9405 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
9407 qstatus
= GetQueueStatus(qs_all_input
);
9408 ok(qstatus
== MAKELONG(0, QS_POSTMESSAGE
),
9409 "wrong qstatus %08x\n", qstatus
);
9412 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
9413 ok(ret
&& msg
.message
== WM_CHAR
&& msg
.wParam
== 'z',
9414 "got %d and %04x wParam %08lx instead of TRUE and WM_CHAR wParam 'z'\n",
9415 ret
, msg
.message
, msg
.wParam
);
9416 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
9418 qstatus
= GetQueueStatus(qs_all_input
);
9420 "wrong qstatus %08x\n", qstatus
);
9423 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
9425 "PeekMessageA should have returned FALSE instead of msg %04x\n",
9427 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
9429 qstatus
= GetQueueStatus(qs_all_input
);
9431 "wrong qstatus %08x\n", qstatus
);
9433 /* test whether presence of the quit flag in the queue affects
9436 PostQuitMessage(0x1234abcd);
9438 qstatus
= GetQueueStatus(qs_all_input
);
9439 ok(qstatus
== MAKELONG(QS_POSTMESSAGE
, QS_POSTMESSAGE
),
9440 "wrong qstatus %08x\n", qstatus
);
9442 PostMessageA(info
.hwnd
, WM_USER
, 0, 0);
9444 qstatus
= GetQueueStatus(qs_all_input
);
9445 ok(qstatus
== MAKELONG(QS_POSTMESSAGE
, QS_POSTMESSAGE
),
9446 "wrong qstatus %08x\n", qstatus
);
9449 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
9450 ok(ret
&& msg
.message
== WM_USER
,
9451 "got %d and %04x instead of TRUE and WM_USER\n", ret
, msg
.message
);
9452 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
9454 qstatus
= GetQueueStatus(qs_all_input
);
9455 ok(qstatus
== MAKELONG(0, QS_POSTMESSAGE
),
9456 "wrong qstatus %08x\n", qstatus
);
9459 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
9460 ok(ret
&& msg
.message
== WM_QUIT
,
9461 "got %d and %04x instead of TRUE and WM_QUIT\n", ret
, msg
.message
);
9462 ok(msg
.wParam
== 0x1234abcd, "got wParam %08lx instead of 0x1234abcd\n", msg
.wParam
);
9463 ok(msg
.lParam
== 0, "got lParam %08lx instead of 0\n", msg
.lParam
);
9464 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
9466 qstatus
= GetQueueStatus(qs_all_input
);
9468 ok(qstatus
== MAKELONG(0, QS_POSTMESSAGE
),
9469 "wrong qstatus %08x\n", qstatus
);
9473 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
9475 "PeekMessageA should have returned FALSE instead of msg %04x\n",
9477 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
9479 qstatus
= GetQueueStatus(qs_all_input
);
9481 "wrong qstatus %08x\n", qstatus
);
9483 /* some GetMessage tests */
9485 keybd_event('N', 0, 0, 0);
9486 qstatus
= GetQueueStatus(qs_all_input
);
9487 ok(qstatus
== MAKELONG(QS_KEY
, QS_KEY
), "wrong qstatus %08x\n", qstatus
);
9489 PostMessageA(info
.hwnd
, WM_CHAR
, 'z', 0);
9490 qstatus
= GetQueueStatus(qs_all_input
);
9491 ok(qstatus
== MAKELONG(QS_POSTMESSAGE
, QS_POSTMESSAGE
|QS_KEY
), "wrong qstatus %08x\n", qstatus
);
9495 ret
= GetMessageA( &msg
, 0, 0, 0 );
9496 ok(ret
&& msg
.message
== WM_CHAR
&& msg
.wParam
== 'z',
9497 "got %d and %04x wParam %08lx instead of TRUE and WM_CHAR wParam 'z'\n",
9498 ret
, msg
.message
, msg
.wParam
);
9499 qstatus
= GetQueueStatus(qs_all_input
);
9500 ok(qstatus
== MAKELONG(0, QS_KEY
), "wrong qstatus %08x\n", qstatus
);
9505 ret
= GetMessageA( &msg
, 0, 0, 0 );
9506 ok(ret
&& msg
.message
== WM_KEYDOWN
&& msg
.wParam
== 'N',
9507 "got %d and %04x wParam %08lx instead of TRUE and WM_KEYDOWN wParam 'N'\n",
9508 ret
, msg
.message
, msg
.wParam
);
9509 ok_sequence(WmKeyDownSkippedSeq
, "WmKeyDownSkippedSeq", FALSE
);
9510 qstatus
= GetQueueStatus(qs_all_input
);
9511 ok(qstatus
== 0, "wrong qstatus %08x\n", qstatus
);
9514 keybd_event('N', 0, 0, 0);
9515 qstatus
= GetQueueStatus(qs_all_input
);
9516 ok(qstatus
== MAKELONG(QS_KEY
, QS_KEY
), "wrong qstatus %08x\n", qstatus
);
9518 PostMessageA(info
.hwnd
, WM_CHAR
, 'z', 0);
9519 qstatus
= GetQueueStatus(qs_all_input
);
9520 ok(qstatus
== MAKELONG(QS_POSTMESSAGE
, QS_POSTMESSAGE
|QS_KEY
), "wrong qstatus %08x\n", qstatus
);
9522 if (qstatus
& (QS_KEY
<< 16))
9524 ret
= GetMessageA( &msg
, 0, WM_KEYDOWN
, WM_KEYUP
);
9525 ok(ret
&& msg
.message
== WM_KEYDOWN
&& msg
.wParam
== 'N',
9526 "got %d and %04x wParam %08lx instead of TRUE and WM_KEYDOWN wParam 'N'\n",
9527 ret
, msg
.message
, msg
.wParam
);
9528 ok_sequence(WmKeyDownWasDownSkippedSeq
, "WmKeyDownWasDownSkippedSeq", FALSE
);
9529 qstatus
= GetQueueStatus(qs_all_input
);
9530 ok(qstatus
== MAKELONG(0, QS_POSTMESSAGE
), "wrong qstatus %08x\n", qstatus
);
9535 ret
= GetMessageA( &msg
, 0, WM_CHAR
, WM_CHAR
);
9536 ok(ret
&& msg
.message
== WM_CHAR
&& msg
.wParam
== 'z',
9537 "got %d and %04x wParam %08lx instead of TRUE and WM_CHAR wParam 'z'\n",
9538 ret
, msg
.message
, msg
.wParam
);
9539 qstatus
= GetQueueStatus(qs_all_input
);
9540 ok(qstatus
== 0, "wrong qstatus %08x\n", qstatus
);
9543 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
9544 qstatus
= GetQueueStatus(qs_all_input
);
9545 ok(qstatus
== MAKELONG(QS_KEY
, QS_KEY
), "wrong qstatus %08x\n", qstatus
);
9547 PostMessageA(info
.hwnd
, WM_CHAR
, 'z', 0);
9548 qstatus
= GetQueueStatus(qs_all_input
);
9549 ok(qstatus
== MAKELONG(QS_POSTMESSAGE
, QS_POSTMESSAGE
|QS_KEY
), "wrong qstatus %08x\n", qstatus
);
9551 trace("signalling to send message\n");
9552 SetEvent(info
.hevent
[EV_SENDMSG
]);
9553 WaitForSingleObject(info
.hevent
[EV_ACK
], INFINITE
);
9554 qstatus
= GetQueueStatus(qs_all_input
);
9555 ok(qstatus
== MAKELONG(QS_SENDMESSAGE
, QS_SENDMESSAGE
|QS_POSTMESSAGE
|QS_KEY
),
9556 "wrong qstatus %08x\n", qstatus
);
9558 if (qstatus
& (QS_KEY
<< 16))
9560 ret
= GetMessageA( &msg
, 0, WM_KEYDOWN
, WM_KEYUP
);
9561 ok(ret
&& msg
.message
== WM_KEYUP
&& msg
.wParam
== 'N',
9562 "got %d and %04x wParam %08lx instead of TRUE and WM_KEYDOWN wParam 'N'\n",
9563 ret
, msg
.message
, msg
.wParam
);
9564 ok_sequence(WmUserKeyUpSkippedSeq
, "WmUserKeyUpSkippedSeq", FALSE
);
9565 qstatus
= GetQueueStatus(qs_all_input
);
9566 ok(qstatus
== MAKELONG(0, QS_POSTMESSAGE
), "wrong qstatus %08x\n", qstatus
);
9571 ret
= GetMessageA( &msg
, 0, WM_CHAR
, WM_CHAR
);
9572 ok(ret
&& msg
.message
== WM_CHAR
&& msg
.wParam
== 'z',
9573 "got %d and %04x wParam %08lx instead of TRUE and WM_CHAR wParam 'z'\n",
9574 ret
, msg
.message
, msg
.wParam
);
9575 qstatus
= GetQueueStatus(qs_all_input
);
9576 ok(qstatus
== 0, "wrong qstatus %08x\n", qstatus
);
9579 trace("signalling to exit\n");
9580 SetEvent(info
.hevent
[EV_STOP
]);
9582 WaitForSingleObject(hthread
, INFINITE
);
9584 CloseHandle(hthread
);
9585 CloseHandle(info
.hevent
[0]);
9586 CloseHandle(info
.hevent
[1]);
9587 CloseHandle(info
.hevent
[2]);
9589 DestroyWindow(info
.hwnd
);
9592 static void wait_move_event(HWND hwnd
, int x
, int y
)
9599 time
= GetTickCount();
9600 while (GetTickCount() - time
< 200 && !go
) {
9601 ret
= PeekMessageA(&msg
, hwnd
, WM_MOUSEMOVE
, WM_MOUSEMOVE
, PM_NOREMOVE
);
9602 go
= ret
&& msg
.pt
.x
> x
&& msg
.pt
.y
> y
;
9603 if (!ret
) MsgWaitForMultipleObjects( 0, NULL
, FALSE
, GetTickCount() - time
, QS_ALLINPUT
);
9608 static void test_PeekMessage2(void)
9614 DWORD time1
, time2
, time3
;
9615 int x1
, y1
, x2
, y2
, x3
, y3
;
9618 time1
= time2
= time3
= 0;
9619 x1
= y1
= x2
= y2
= x3
= y3
= 0;
9621 /* Initialise window and make sure it is ready for events */
9622 hwnd
= CreateWindow("TestWindowClass", "PeekMessage2", WS_OVERLAPPEDWINDOW
,
9623 10, 10, 800, 800, NULL
, NULL
, NULL
, NULL
);
9625 trace("Window for test_PeekMessage2 %p\n", hwnd
);
9626 ShowWindow(hwnd
, SW_SHOW
);
9630 SetCursorPos(100, 100);
9631 mouse_event(MOUSEEVENTF_MOVE
, -STEP
, -STEP
, 0, 0);
9634 /* Do initial mousemove, wait until we can see it
9635 and then do our test peek with PM_NOREMOVE. */
9636 mouse_event(MOUSEEVENTF_MOVE
, STEP
, STEP
, 0, 0);
9637 wait_move_event(hwnd
, 100-STEP
, 100-STEP
);
9639 ret
= PeekMessageA(&msg
, hwnd
, WM_MOUSEMOVE
, WM_MOUSEMOVE
, PM_NOREMOVE
);
9642 skip( "queuing mouse events not supported\n" );
9647 trace("1st move event: %04x %x %d %d\n", msg
.message
, msg
.time
, msg
.pt
.x
, msg
.pt
.y
);
9648 message
= msg
.message
;
9652 ok(message
== WM_MOUSEMOVE
, "message not WM_MOUSEMOVE, %04x instead\n", message
);
9655 /* Allow time to advance a bit, and then simulate the user moving their
9656 * mouse around. After that we peek again with PM_NOREMOVE.
9657 * Although the previous mousemove message was never removed, the
9658 * mousemove we now peek should reflect the recent mouse movements
9659 * because the input queue will merge the move events. */
9661 mouse_event(MOUSEEVENTF_MOVE
, STEP
, STEP
, 0, 0);
9662 wait_move_event(hwnd
, x1
, y1
);
9664 ret
= PeekMessageA(&msg
, hwnd
, WM_MOUSEMOVE
, WM_MOUSEMOVE
, PM_NOREMOVE
);
9665 ok(ret
, "no message available\n");
9667 trace("2nd move event: %04x %x %d %d\n", msg
.message
, msg
.time
, msg
.pt
.x
, msg
.pt
.y
);
9668 message
= msg
.message
;
9672 ok(message
== WM_MOUSEMOVE
, "message not WM_MOUSEMOVE, %04x instead\n", message
);
9673 ok(time2
> time1
, "message time not advanced: %x %x\n", time1
, time2
);
9674 ok(x2
!= x1
&& y2
!= y1
, "coords not changed: (%d %d) (%d %d)\n", x1
, y1
, x2
, y2
);
9677 /* Have another go, to drive the point home */
9679 mouse_event(MOUSEEVENTF_MOVE
, STEP
, STEP
, 0, 0);
9680 wait_move_event(hwnd
, x2
, y2
);
9682 ret
= PeekMessageA(&msg
, hwnd
, WM_MOUSEMOVE
, WM_MOUSEMOVE
, PM_NOREMOVE
);
9683 ok(ret
, "no message available\n");
9685 trace("3rd move event: %04x %x %d %d\n", msg
.message
, msg
.time
, msg
.pt
.x
, msg
.pt
.y
);
9686 message
= msg
.message
;
9690 ok(message
== WM_MOUSEMOVE
, "message not WM_MOUSEMOVE, %04x instead\n", message
);
9691 ok(time3
> time2
, "message time not advanced: %x %x\n", time2
, time3
);
9692 ok(x3
!= x2
&& y3
!= y2
, "coords not changed: (%d %d) (%d %d)\n", x2
, y2
, x3
, y3
);
9696 DestroyWindow(hwnd
);
9697 SetCursorPos(pos
.x
, pos
.y
);
9701 static void test_quit_message(void)
9706 /* test using PostQuitMessage */
9708 PostQuitMessage(0xbeef);
9710 ret
= PeekMessage(&msg
, NULL
, 0, 0, PM_NOREMOVE
);
9711 ok(ret
, "PeekMessage failed with error %d\n", GetLastError());
9712 ok(msg
.message
== WM_QUIT
, "Received message 0x%04x instead of WM_QUIT\n", msg
.message
);
9713 ok(msg
.wParam
== 0xbeef, "wParam was 0x%lx instead of 0xbeef\n", msg
.wParam
);
9715 ret
= PostThreadMessage(GetCurrentThreadId(), WM_USER
, 0, 0);
9716 ok(ret
, "PostMessage failed with error %d\n", GetLastError());
9718 ret
= GetMessage(&msg
, NULL
, 0, 0);
9719 ok(ret
> 0, "GetMessage failed with error %d\n", GetLastError());
9720 ok(msg
.message
== WM_USER
, "Received message 0x%04x instead of WM_USER\n", msg
.message
);
9722 /* note: WM_QUIT message received after WM_USER message */
9723 ret
= GetMessage(&msg
, NULL
, 0, 0);
9724 ok(!ret
, "GetMessage return %d with error %d instead of FALSE\n", ret
, GetLastError());
9725 ok(msg
.message
== WM_QUIT
, "Received message 0x%04x instead of WM_QUIT\n", msg
.message
);
9726 ok(msg
.wParam
== 0xbeef, "wParam was 0x%lx instead of 0xbeef\n", msg
.wParam
);
9728 ret
= PeekMessage(&msg
, NULL
, 0, 0, PM_REMOVE
);
9729 ok( !ret
|| msg
.message
!= WM_QUIT
, "Received WM_QUIT again\n" );
9731 /* now test with PostThreadMessage - different behaviour! */
9732 PostThreadMessage(GetCurrentThreadId(), WM_QUIT
, 0xdead, 0);
9734 ret
= PeekMessage(&msg
, NULL
, 0, 0, PM_NOREMOVE
);
9735 ok(ret
, "PeekMessage failed with error %d\n", GetLastError());
9736 ok(msg
.message
== WM_QUIT
, "Received message 0x%04x instead of WM_QUIT\n", msg
.message
);
9737 ok(msg
.wParam
== 0xdead, "wParam was 0x%lx instead of 0xdead\n", msg
.wParam
);
9739 ret
= PostThreadMessage(GetCurrentThreadId(), WM_USER
, 0, 0);
9740 ok(ret
, "PostMessage failed with error %d\n", GetLastError());
9742 /* note: we receive the WM_QUIT message first this time */
9743 ret
= GetMessage(&msg
, NULL
, 0, 0);
9744 ok(!ret
, "GetMessage return %d with error %d instead of FALSE\n", ret
, GetLastError());
9745 ok(msg
.message
== WM_QUIT
, "Received message 0x%04x instead of WM_QUIT\n", msg
.message
);
9746 ok(msg
.wParam
== 0xdead, "wParam was 0x%lx instead of 0xdead\n", msg
.wParam
);
9748 ret
= GetMessage(&msg
, NULL
, 0, 0);
9749 ok(ret
> 0, "GetMessage failed with error %d\n", GetLastError());
9750 ok(msg
.message
== WM_USER
, "Received message 0x%04x instead of WM_USER\n", msg
.message
);
9753 static const struct message WmMouseHoverSeq
[] = {
9754 { WM_MOUSEACTIVATE
, sent
|optional
}, /* we can get those when moving the mouse in focus-follow-mouse mode under X11 */
9755 { WM_MOUSEACTIVATE
, sent
|optional
},
9756 { WM_TIMER
, sent
|optional
}, /* XP sends it */
9757 { WM_SYSTIMER
, sent
},
9758 { WM_MOUSEHOVER
, sent
|wparam
, 0 },
9762 static void pump_msg_loop_timeout(DWORD timeout
, BOOL inject_mouse_move
)
9765 DWORD start_ticks
, end_ticks
;
9767 start_ticks
= GetTickCount();
9768 /* add some deviation (50%) to cover not expected delays */
9769 start_ticks
+= timeout
/ 2;
9773 while (PeekMessage(&msg
, 0, 0, 0, PM_REMOVE
))
9775 /* Timer proc messages are not dispatched to the window proc,
9776 * and therefore not logged.
9778 if (msg
.message
== WM_TIMER
|| msg
.message
== WM_SYSTIMER
)
9780 struct recvd_message s_msg
;
9782 s_msg
.hwnd
= msg
.hwnd
;
9783 s_msg
.message
= msg
.message
;
9784 s_msg
.flags
= sent
|wparam
|lparam
;
9785 s_msg
.wParam
= msg
.wParam
;
9786 s_msg
.lParam
= msg
.lParam
;
9787 s_msg
.descr
= "msg_loop";
9788 add_message(&s_msg
);
9790 DispatchMessage(&msg
);
9793 end_ticks
= GetTickCount();
9795 /* inject WM_MOUSEMOVE to see how it changes tracking */
9796 if (inject_mouse_move
&& start_ticks
+ timeout
/ 2 >= end_ticks
)
9798 mouse_event(MOUSEEVENTF_MOVE
, -1, 0, 0, 0);
9799 mouse_event(MOUSEEVENTF_MOVE
, 1, 0, 0, 0);
9801 inject_mouse_move
= FALSE
;
9803 } while (start_ticks
+ timeout
>= end_ticks
);
9806 static void test_TrackMouseEvent(void)
9808 TRACKMOUSEEVENT tme
;
9811 RECT rc_parent
, rc_child
;
9812 UINT default_hover_time
, hover_width
= 0, hover_height
= 0;
9814 #define track_hover(track_hwnd, track_hover_time) \
9815 tme.cbSize = sizeof(tme); \
9816 tme.dwFlags = TME_HOVER; \
9817 tme.hwndTrack = track_hwnd; \
9818 tme.dwHoverTime = track_hover_time; \
9819 SetLastError(0xdeadbeef); \
9820 ret = pTrackMouseEvent(&tme); \
9821 ok(ret, "TrackMouseEvent(TME_HOVER) error %d\n", GetLastError())
9823 #define track_query(expected_track_flags, expected_track_hwnd, expected_hover_time) \
9824 tme.cbSize = sizeof(tme); \
9825 tme.dwFlags = TME_QUERY; \
9826 tme.hwndTrack = (HWND)0xdeadbeef; \
9827 tme.dwHoverTime = 0xdeadbeef; \
9828 SetLastError(0xdeadbeef); \
9829 ret = pTrackMouseEvent(&tme); \
9830 ok(ret, "TrackMouseEvent(TME_QUERY) error %d\n", GetLastError());\
9831 ok(tme.cbSize == sizeof(tme), "wrong tme.cbSize %u\n", tme.cbSize); \
9832 ok(tme.dwFlags == (expected_track_flags), \
9833 "wrong tme.dwFlags %08x, expected %08x\n", tme.dwFlags, (expected_track_flags)); \
9834 ok(tme.hwndTrack == (expected_track_hwnd), \
9835 "wrong tme.hwndTrack %p, expected %p\n", tme.hwndTrack, (expected_track_hwnd)); \
9836 ok(tme.dwHoverTime == (expected_hover_time), \
9837 "wrong tme.dwHoverTime %u, expected %u\n", tme.dwHoverTime, (expected_hover_time))
9839 #define track_hover_cancel(track_hwnd) \
9840 tme.cbSize = sizeof(tme); \
9841 tme.dwFlags = TME_HOVER | TME_CANCEL; \
9842 tme.hwndTrack = track_hwnd; \
9843 tme.dwHoverTime = 0xdeadbeef; \
9844 SetLastError(0xdeadbeef); \
9845 ret = pTrackMouseEvent(&tme); \
9846 ok(ret, "TrackMouseEvent(TME_HOVER | TME_CANCEL) error %d\n", GetLastError())
9848 default_hover_time
= 0xdeadbeef;
9849 SetLastError(0xdeadbeef);
9850 ret
= SystemParametersInfo(SPI_GETMOUSEHOVERTIME
, 0, &default_hover_time
, 0);
9851 ok(ret
|| broken(GetLastError() == 0xdeadbeef), /* win9x */
9852 "SystemParametersInfo(SPI_GETMOUSEHOVERTIME) error %u\n", GetLastError());
9853 if (!ret
) default_hover_time
= 400;
9854 trace("SPI_GETMOUSEHOVERTIME returned %u ms\n", default_hover_time
);
9856 SetLastError(0xdeadbeef);
9857 ret
= SystemParametersInfo(SPI_GETMOUSEHOVERWIDTH
, 0, &hover_width
, 0);
9858 ok(ret
|| broken(GetLastError() == 0xdeadbeef), /* win9x */
9859 "SystemParametersInfo(SPI_GETMOUSEHOVERWIDTH) error %u\n", GetLastError());
9860 if (!ret
) hover_width
= 4;
9861 SetLastError(0xdeadbeef);
9862 ret
= SystemParametersInfo(SPI_GETMOUSEHOVERHEIGHT
, 0, &hover_height
, 0);
9863 ok(ret
|| broken(GetLastError() == 0xdeadbeef), /* win9x */
9864 "SystemParametersInfo(SPI_GETMOUSEHOVERHEIGHT) error %u\n", GetLastError());
9865 if (!ret
) hover_height
= 4;
9866 trace("hover rect is %u x %d\n", hover_width
, hover_height
);
9868 hwnd
= CreateWindowEx(0, "TestWindowClass", NULL
,
9869 WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
9870 CW_USEDEFAULT
, CW_USEDEFAULT
, 300, 300, 0,
9874 hchild
= CreateWindowEx(0, "TestWindowClass", NULL
,
9875 WS_CHILD
| WS_BORDER
| WS_VISIBLE
,
9876 50, 50, 200, 200, hwnd
,
9880 SetWindowPos( hwnd
, HWND_TOPMOST
, 0, 0, 0, 0, SWP_NOSIZE
|SWP_NOMOVE
);
9885 tme
.dwFlags
= TME_QUERY
;
9886 tme
.hwndTrack
= (HWND
)0xdeadbeef;
9887 tme
.dwHoverTime
= 0xdeadbeef;
9888 SetLastError(0xdeadbeef);
9889 ret
= pTrackMouseEvent(&tme
);
9890 ok(!ret
, "TrackMouseEvent should fail\n");
9891 ok(GetLastError() == ERROR_INVALID_PARAMETER
|| broken(GetLastError() == 0xdeadbeef),
9892 "not expected error %u\n", GetLastError());
9894 tme
.cbSize
= sizeof(tme
);
9895 tme
.dwFlags
= TME_HOVER
;
9896 tme
.hwndTrack
= (HWND
)0xdeadbeef;
9897 tme
.dwHoverTime
= 0xdeadbeef;
9898 SetLastError(0xdeadbeef);
9899 ret
= pTrackMouseEvent(&tme
);
9900 ok(!ret
, "TrackMouseEvent should fail\n");
9901 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
|| broken(GetLastError() == 0xdeadbeef),
9902 "not expected error %u\n", GetLastError());
9904 tme
.cbSize
= sizeof(tme
);
9905 tme
.dwFlags
= TME_HOVER
| TME_CANCEL
;
9906 tme
.hwndTrack
= (HWND
)0xdeadbeef;
9907 tme
.dwHoverTime
= 0xdeadbeef;
9908 SetLastError(0xdeadbeef);
9909 ret
= pTrackMouseEvent(&tme
);
9910 ok(!ret
, "TrackMouseEvent should fail\n");
9911 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
|| broken(GetLastError() == 0xdeadbeef),
9912 "not expected error %u\n", GetLastError());
9914 GetWindowRect(hwnd
, &rc_parent
);
9915 GetWindowRect(hchild
, &rc_child
);
9916 SetCursorPos(rc_child
.left
- 10, rc_child
.top
- 10);
9918 /* Process messages so that the system updates its internal current
9919 * window and hittest, otherwise TrackMouseEvent calls don't have any
9925 track_query(0, NULL
, 0);
9926 track_hover(hchild
, 0);
9927 track_query(0, NULL
, 0);
9932 track_hover(hwnd
, 0);
9933 tme
.cbSize
= sizeof(tme
);
9934 tme
.dwFlags
= TME_QUERY
;
9935 tme
.hwndTrack
= (HWND
)0xdeadbeef;
9936 tme
.dwHoverTime
= 0xdeadbeef;
9937 SetLastError(0xdeadbeef);
9938 ret
= pTrackMouseEvent(&tme
);
9939 ok(ret
, "TrackMouseEvent(TME_QUERY) error %d\n", GetLastError());
9940 ok(tme
.cbSize
== sizeof(tme
), "wrong tme.cbSize %u\n", tme
.cbSize
);
9943 skip( "Cursor not inside window, skipping TrackMouseEvent tests\n" );
9944 DestroyWindow( hwnd
);
9947 ok(tme
.dwFlags
== TME_HOVER
, "wrong tme.dwFlags %08x, expected TME_HOVER\n", tme
.dwFlags
);
9948 ok(tme
.hwndTrack
== hwnd
, "wrong tme.hwndTrack %p, expected %p\n", tme
.hwndTrack
, hwnd
);
9949 ok(tme
.dwHoverTime
== default_hover_time
, "wrong tme.dwHoverTime %u, expected %u\n",
9950 tme
.dwHoverTime
, default_hover_time
);
9952 pump_msg_loop_timeout(default_hover_time
, FALSE
);
9953 ok_sequence(WmMouseHoverSeq
, "WmMouseHoverSeq", FALSE
);
9955 track_query(0, NULL
, 0);
9957 track_hover(hwnd
, HOVER_DEFAULT
);
9958 track_query(TME_HOVER
, hwnd
, default_hover_time
);
9960 Sleep(default_hover_time
/ 2);
9961 mouse_event(MOUSEEVENTF_MOVE
, -1, 0, 0, 0);
9962 mouse_event(MOUSEEVENTF_MOVE
, 1, 0, 0, 0);
9964 track_query(TME_HOVER
, hwnd
, default_hover_time
);
9966 pump_msg_loop_timeout(default_hover_time
, FALSE
);
9967 ok_sequence(WmMouseHoverSeq
, "WmMouseHoverSeq", FALSE
);
9969 track_query(0, NULL
, 0);
9971 track_hover(hwnd
, HOVER_DEFAULT
);
9972 track_query(TME_HOVER
, hwnd
, default_hover_time
);
9974 pump_msg_loop_timeout(default_hover_time
, TRUE
);
9975 ok_sequence(WmMouseHoverSeq
, "WmMouseHoverSeq", FALSE
);
9977 track_query(0, NULL
, 0);
9979 track_hover(hwnd
, HOVER_DEFAULT
);
9980 track_query(TME_HOVER
, hwnd
, default_hover_time
);
9981 track_hover_cancel(hwnd
);
9983 DestroyWindow(hwnd
);
9987 #undef track_hover_cancel
9991 static const struct message WmSetWindowRgn
[] = {
9992 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
},
9993 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
9994 { WM_NCPAINT
, sent
|optional
}, /* wparam != 1 */
9995 { WM_GETTEXT
, sent
|defwinproc
|optional
},
9996 { WM_ERASEBKGND
, sent
|optional
},
9997 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
},
9998 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
10002 static const struct message WmSetWindowRgn_no_redraw
[] = {
10003 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
},
10004 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
10005 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
},
10006 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
10010 static const struct message WmSetWindowRgn_clear
[] = {
10011 { WM_WINDOWPOSCHANGING
, sent
/*|wparam*/, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
/*|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE only on some Windows versions */ },
10012 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
10013 { WM_NCPAINT
, sent
|optional
},
10014 { WM_GETTEXT
, sent
|defwinproc
|optional
},
10015 { WM_ERASEBKGND
, sent
|optional
}, /* FIXME: remove optional once Wine is fixed */
10016 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
},
10017 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
10018 { WM_NCPAINT
, sent
|optional
},
10019 { WM_GETTEXT
, sent
|defwinproc
|optional
},
10020 { WM_ERASEBKGND
, sent
|optional
},
10021 { WM_WINDOWPOSCHANGING
, sent
|optional
},
10022 { WM_NCCALCSIZE
, sent
|optional
|wparam
, 1 },
10023 { WM_NCPAINT
, sent
|optional
},
10024 { WM_GETTEXT
, sent
|defwinproc
|optional
},
10025 { WM_ERASEBKGND
, sent
|optional
},
10026 { WM_WINDOWPOSCHANGED
, sent
|optional
|wparam
, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
},
10027 { WM_NCCALCSIZE
, sent
|optional
|wparam
, 1 },
10028 { WM_NCPAINT
, sent
|optional
},
10029 { WM_GETTEXT
, sent
|defwinproc
|optional
},
10030 { WM_ERASEBKGND
, sent
|optional
},
10031 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
10032 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
10036 static void test_SetWindowRgn(void)
10039 HWND hwnd
= CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW
,
10040 100, 100, 200, 200, 0, 0, 0, NULL
);
10041 ok( hwnd
!= 0, "Failed to create overlapped window\n" );
10043 ShowWindow( hwnd
, SW_SHOW
);
10044 UpdateWindow( hwnd
);
10048 trace("testing SetWindowRgn\n");
10049 hrgn
= CreateRectRgn( 0, 0, 150, 150 );
10050 SetWindowRgn( hwnd
, hrgn
, TRUE
);
10051 ok_sequence( WmSetWindowRgn
, "WmSetWindowRgn", FALSE
);
10053 hrgn
= CreateRectRgn( 30, 30, 160, 160 );
10054 SetWindowRgn( hwnd
, hrgn
, FALSE
);
10055 ok_sequence( WmSetWindowRgn_no_redraw
, "WmSetWindowRgn_no_redraw", FALSE
);
10057 hrgn
= CreateRectRgn( 0, 0, 180, 180 );
10058 SetWindowRgn( hwnd
, hrgn
, TRUE
);
10059 ok_sequence( WmSetWindowRgn
, "WmSetWindowRgn2", FALSE
);
10061 SetWindowRgn( hwnd
, 0, TRUE
);
10062 ok_sequence( WmSetWindowRgn_clear
, "WmSetWindowRgn_clear", FALSE
);
10064 DestroyWindow( hwnd
);
10067 /*************************** ShowWindow() test ******************************/
10068 static const struct message WmShowNormal
[] = {
10069 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
10070 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
10071 { HCBT_ACTIVATE
, hook
},
10072 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2003 doesn't send it */
10073 { HCBT_SETFOCUS
, hook
},
10074 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
10077 static const struct message WmShow
[] = {
10078 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
10079 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
10080 { HCBT_ACTIVATE
, hook
|optional
}, /* win2000 doesn't send it */
10081 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2000 doesn't send it */
10082 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 doesn't send it */
10083 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
10086 static const struct message WmShowNoActivate_1
[] = {
10087 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWNOACTIVATE
},
10088 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_STATECHANGED
, 0, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOSIZE
|SWP_NOMOVE
},
10089 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_STATECHANGED
, 0, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOSIZE
|SWP_NOMOVE
},
10090 { WM_MOVE
, sent
|defwinproc
|optional
},
10091 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_RESTORED
},
10094 static const struct message WmShowNoActivate_2
[] = {
10095 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWNOACTIVATE
},
10096 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
10097 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
10098 { WM_MOVE
, sent
|defwinproc
},
10099 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_RESTORED
},
10100 { HCBT_SETFOCUS
, hook
|optional
},
10101 { HCBT_ACTIVATE
, hook
|optional
}, /* win2003 doesn't send it */
10102 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2003 doesn't send it */
10103 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
10104 { HCBT_SETFOCUS
, hook
|optional
}, /* win2003 doesn't send it */
10107 static const struct message WmShowNA_1
[] = {
10108 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
10109 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
10110 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
10113 static const struct message WmShowNA_2
[] = {
10114 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
10115 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
10116 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
10119 static const struct message WmRestore_1
[] = {
10120 { HCBT_MINMAX
, hook
|lparam
, 0, SW_RESTORE
},
10121 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
10122 { HCBT_ACTIVATE
, hook
|optional
}, /* win2000 doesn't send it */
10123 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2000 doesn't send it */
10124 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 doesn't send it */
10125 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
10126 { WM_MOVE
, sent
|defwinproc
},
10127 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_RESTORED
},
10128 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 sends it */
10131 static const struct message WmRestore_2
[] = {
10132 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
10133 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
10134 { HCBT_ACTIVATE
, hook
|optional
}, /* win2000 doesn't send it */
10135 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2000 doesn't send it */
10136 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 doesn't send it */
10137 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
10140 static const struct message WmRestore_3
[] = {
10141 { HCBT_MINMAX
, hook
|lparam
, 0, SW_RESTORE
},
10142 { WM_GETMINMAXINFO
, sent
},
10143 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
10144 { HCBT_ACTIVATE
, hook
|optional
}, /* win2003 doesn't send it */
10145 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2003 doesn't send it */
10146 { HCBT_SETFOCUS
, hook
|optional
}, /* win2003 doesn't send it */
10147 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
10148 { WM_MOVE
, sent
|defwinproc
},
10149 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_MAXIMIZED
},
10150 { HCBT_SETFOCUS
, hook
|optional
}, /* win2003 sends it */
10153 static const struct message WmRestore_4
[] = {
10154 { HCBT_MINMAX
, hook
|lparam
|optional
, 0, SW_RESTORE
},
10155 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_FRAMECHANGED
|SWP_STATECHANGED
, 0, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOSIZE
|SWP_NOMOVE
},
10156 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_FRAMECHANGED
|SWP_STATECHANGED
, 0, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOSIZE
|SWP_NOMOVE
},
10157 { WM_MOVE
, sent
|defwinproc
|optional
},
10158 { WM_SIZE
, sent
|wparam
|defwinproc
|optional
, SIZE_RESTORED
},
10161 static const struct message WmRestore_5
[] = {
10162 { HCBT_MINMAX
, hook
|lparam
|optional
, 0, SW_SHOWNORMAL
},
10163 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_FRAMECHANGED
|SWP_STATECHANGED
, 0, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOSIZE
|SWP_NOMOVE
},
10164 { HCBT_ACTIVATE
, hook
|optional
},
10165 { HCBT_SETFOCUS
, hook
|optional
},
10166 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_FRAMECHANGED
|SWP_STATECHANGED
, 0, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOSIZE
|SWP_NOMOVE
},
10167 { WM_MOVE
, sent
|defwinproc
|optional
},
10168 { WM_SIZE
, sent
|wparam
|defwinproc
|optional
, SIZE_RESTORED
},
10171 static const struct message WmHide_1
[] = {
10172 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
10173 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
10174 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
10175 { HCBT_ACTIVATE
, hook
|optional
},
10176 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 sends it */
10179 static const struct message WmHide_2
[] = {
10180 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
10181 { WM_WINDOWPOSCHANGING
, sent
/*|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE*/ }, /* win2000 doesn't add SWP_NOACTIVATE */
10182 { WM_WINDOWPOSCHANGED
, sent
/*|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE*/ }, /* win2000 doesn't add SWP_NOACTIVATE */
10183 { HCBT_ACTIVATE
, hook
|optional
},
10186 static const struct message WmHide_3
[] = {
10187 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
10188 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
10189 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
10190 { HCBT_SETFOCUS
, hook
|optional
},
10191 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
10194 static const struct message WmShowMinimized_1
[] = {
10195 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINIMIZED
},
10196 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
10197 { HCBT_ACTIVATE
, hook
|optional
}, /* win2000 doesn't send it */
10198 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2000 doesn't send it */
10199 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
10200 { WM_MOVE
, sent
|defwinproc
},
10201 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_MINIMIZED
},
10204 static const struct message WmMinimize_1
[] = {
10205 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
10206 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 doesn't send it */
10207 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
10208 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
10209 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
10210 { WM_MOVE
, sent
|defwinproc
},
10211 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_MINIMIZED
},
10214 static const struct message WmMinimize_2
[] = {
10215 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
10216 { HCBT_SETFOCUS
, hook
|optional
},
10217 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
10218 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
10219 { WM_MOVE
, sent
|defwinproc
},
10220 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_MINIMIZED
},
10223 static const struct message WmMinimize_3
[] = {
10224 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
10225 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
10226 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
10227 { WM_MOVE
, sent
|defwinproc
},
10228 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_MINIMIZED
},
10231 static const struct message WmShowMinNoActivate
[] = {
10232 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINNOACTIVE
},
10233 { WM_WINDOWPOSCHANGING
, sent
},
10234 { WM_WINDOWPOSCHANGED
, sent
},
10235 { WM_MOVE
, sent
|defwinproc
|optional
},
10236 { WM_SIZE
, sent
|wparam
|defwinproc
|optional
, SIZE_MINIMIZED
},
10239 static const struct message WmMinMax_1
[] = {
10240 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINIMIZED
},
10243 static const struct message WmMinMax_2
[] = {
10244 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMAXIMIZED
},
10245 { WM_GETMINMAXINFO
, sent
|optional
},
10246 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
10247 { HCBT_ACTIVATE
, hook
|optional
},
10248 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
10249 { HCBT_SETFOCUS
, hook
|optional
},
10250 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_FRAMECHANGED
|SWP_STATECHANGED
, 0, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
10251 { WM_MOVE
, sent
|defwinproc
|optional
},
10252 { WM_SIZE
, sent
|wparam
|defwinproc
|optional
, SIZE_MAXIMIZED
},
10253 { HCBT_SETFOCUS
, hook
|optional
},
10256 static const struct message WmMinMax_3
[] = {
10257 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
10258 { HCBT_SETFOCUS
, hook
|optional
},
10259 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
10260 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
10261 { WM_MOVE
, sent
|defwinproc
|optional
},
10262 { WM_SIZE
, sent
|wparam
|defwinproc
|optional
, SIZE_MINIMIZED
},
10265 static const struct message WmMinMax_4
[] = {
10266 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINNOACTIVE
},
10269 static const struct message WmShowMaximized_1
[] = {
10270 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMAXIMIZED
},
10271 { WM_GETMINMAXINFO
, sent
},
10272 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
10273 { HCBT_ACTIVATE
, hook
|optional
}, /* win2000 doesn't send it */
10274 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2000 doesn't send it */
10275 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 doesn't send it */
10276 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
10277 { WM_MOVE
, sent
|defwinproc
},
10278 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_MAXIMIZED
},
10279 { HCBT_SETFOCUS
, hook
|optional
}, /* win2003 sends it */
10282 static const struct message WmShowMaximized_2
[] = {
10283 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMAXIMIZED
},
10284 { WM_GETMINMAXINFO
, sent
},
10285 { WM_WINDOWPOSCHANGING
, sent
|optional
},
10286 { HCBT_ACTIVATE
, hook
|optional
},
10287 { WM_WINDOWPOSCHANGED
, sent
|optional
},
10288 { WM_MOVE
, sent
|optional
}, /* Win9x doesn't send it */
10289 { WM_SIZE
, sent
|wparam
|optional
, SIZE_MAXIMIZED
}, /* Win9x doesn't send it */
10290 { WM_WINDOWPOSCHANGING
, sent
|optional
},
10291 { HCBT_SETFOCUS
, hook
|optional
},
10292 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
10293 { WM_MOVE
, sent
|defwinproc
},
10294 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_MAXIMIZED
},
10295 { HCBT_SETFOCUS
, hook
|optional
},
10298 static const struct message WmShowMaximized_3
[] = {
10299 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMAXIMIZED
},
10300 { WM_GETMINMAXINFO
, sent
|optional
},
10301 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
, 0, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOSIZE
|SWP_NOMOVE
},
10302 { HCBT_ACTIVATE
, hook
|optional
}, /* win2000 doesn't send it */
10303 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2000 doesn't send it */
10304 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 doesn't send it */
10305 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
, 0, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOSIZE
|SWP_NOMOVE
},
10306 { WM_MOVE
, sent
|defwinproc
|optional
},
10307 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_MAXIMIZED
},
10311 static void test_ShowWindow(void)
10313 /* ShowWindow commands in random order */
10314 static const struct
10316 INT cmd
; /* ShowWindow command */
10317 LPARAM ret
; /* ShowWindow return value */
10318 DWORD style
; /* window style after the command */
10319 const struct message
*msg
; /* message sequence the command produces */
10320 BOOL todo_msg
; /* message sequence doesn't match what Wine does */
10323 /* 1 */ { SW_SHOWNORMAL
, FALSE
, WS_VISIBLE
, WmShowNormal
, FALSE
},
10324 /* 2 */ { SW_SHOWNORMAL
, TRUE
, WS_VISIBLE
, WmEmptySeq
, FALSE
},
10325 /* 3 */ { SW_HIDE
, TRUE
, 0, WmHide_1
, FALSE
},
10326 /* 4 */ { SW_HIDE
, FALSE
, 0, WmEmptySeq
, FALSE
},
10327 /* 5 */ { SW_SHOWMINIMIZED
, FALSE
, WS_VISIBLE
|WS_MINIMIZE
, WmShowMinimized_1
, FALSE
},
10328 /* 6 */ { SW_SHOWMINIMIZED
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinMax_1
, FALSE
},
10329 /* 7 */ { SW_HIDE
, TRUE
, WS_MINIMIZE
, WmHide_1
, FALSE
},
10330 /* 8 */ { SW_HIDE
, FALSE
, WS_MINIMIZE
, WmEmptySeq
, FALSE
},
10331 /* 9 */ { SW_SHOWMAXIMIZED
, FALSE
, WS_VISIBLE
|WS_MAXIMIZE
, WmShowMaximized_1
, FALSE
},
10332 /* 10 */ { SW_SHOWMAXIMIZED
, TRUE
, WS_VISIBLE
|WS_MAXIMIZE
, WmMinMax_2
, FALSE
},
10333 /* 11 */ { SW_HIDE
, TRUE
, WS_MAXIMIZE
, WmHide_1
, FALSE
},
10334 /* 12 */ { SW_HIDE
, FALSE
, WS_MAXIMIZE
, WmEmptySeq
, FALSE
},
10335 /* 13 */ { SW_SHOWNOACTIVATE
, FALSE
, WS_VISIBLE
, WmShowNoActivate_1
, FALSE
},
10336 /* 14 */ { SW_SHOWNOACTIVATE
, TRUE
, WS_VISIBLE
, WmEmptySeq
, FALSE
},
10337 /* 15 */ { SW_HIDE
, TRUE
, 0, WmHide_2
, FALSE
},
10338 /* 16 */ { SW_HIDE
, FALSE
, 0, WmEmptySeq
, FALSE
},
10339 /* 17 */ { SW_SHOW
, FALSE
, WS_VISIBLE
, WmShow
, FALSE
},
10340 /* 18 */ { SW_SHOW
, TRUE
, WS_VISIBLE
, WmEmptySeq
, FALSE
},
10341 /* 19 */ { SW_MINIMIZE
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinimize_1
, FALSE
},
10342 /* 20 */ { SW_MINIMIZE
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinMax_3
, FALSE
},
10343 /* 21 */ { SW_HIDE
, TRUE
, WS_MINIMIZE
, WmHide_2
, FALSE
},
10344 /* 22 */ { SW_SHOWMINNOACTIVE
, FALSE
, WS_VISIBLE
|WS_MINIMIZE
, WmShowMinNoActivate
, TRUE
},
10345 /* 23 */ { SW_SHOWMINNOACTIVE
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinMax_4
, FALSE
},
10346 /* 24 */ { SW_HIDE
, TRUE
, WS_MINIMIZE
, WmHide_2
, FALSE
},
10347 /* 25 */ { SW_HIDE
, FALSE
, WS_MINIMIZE
, WmEmptySeq
, FALSE
},
10348 /* 26 */ { SW_SHOWNA
, FALSE
, WS_VISIBLE
|WS_MINIMIZE
, WmShowNA_1
, FALSE
},
10349 /* 27 */ { SW_SHOWNA
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmShowNA_2
, FALSE
},
10350 /* 28 */ { SW_HIDE
, TRUE
, WS_MINIMIZE
, WmHide_2
, FALSE
},
10351 /* 29 */ { SW_HIDE
, FALSE
, WS_MINIMIZE
, WmEmptySeq
, FALSE
},
10352 /* 30 */ { SW_RESTORE
, FALSE
, WS_VISIBLE
, WmRestore_1
, FALSE
},
10353 /* 31 */ { SW_RESTORE
, TRUE
, WS_VISIBLE
, WmEmptySeq
, FALSE
},
10354 /* 32 */ { SW_HIDE
, TRUE
, 0, WmHide_3
, FALSE
},
10355 /* 33 */ { SW_HIDE
, FALSE
, 0, WmEmptySeq
, FALSE
},
10356 /* 34 */ { SW_NORMALNA
, FALSE
, 0, WmEmptySeq
, FALSE
}, /* what does this mean?! */
10357 /* 35 */ { SW_NORMALNA
, FALSE
, 0, WmEmptySeq
, FALSE
},
10358 /* 36 */ { SW_HIDE
, FALSE
, 0, WmEmptySeq
, FALSE
},
10359 /* 37 */ { SW_RESTORE
, FALSE
, WS_VISIBLE
, WmRestore_2
, FALSE
},
10360 /* 38 */ { SW_RESTORE
, TRUE
, WS_VISIBLE
, WmEmptySeq
, FALSE
},
10361 /* 39 */ { SW_SHOWNOACTIVATE
, TRUE
, WS_VISIBLE
, WmEmptySeq
, FALSE
},
10362 /* 40 */ { SW_MINIMIZE
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinimize_2
, FALSE
},
10363 /* 41 */ { SW_MINIMIZE
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinMax_3
, FALSE
},
10364 /* 42 */ { SW_SHOWMAXIMIZED
, TRUE
, WS_VISIBLE
|WS_MAXIMIZE
, WmShowMaximized_2
, FALSE
},
10365 /* 43 */ { SW_SHOWMAXIMIZED
, TRUE
, WS_VISIBLE
|WS_MAXIMIZE
, WmMinMax_2
, FALSE
},
10366 /* 44 */ { SW_MINIMIZE
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinimize_1
, FALSE
},
10367 /* 45 */ { SW_MINIMIZE
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinMax_3
, FALSE
},
10368 /* 46 */ { SW_RESTORE
, TRUE
, WS_VISIBLE
|WS_MAXIMIZE
, WmRestore_3
, FALSE
},
10369 /* 47 */ { SW_RESTORE
, TRUE
, WS_VISIBLE
, WmRestore_4
, FALSE
},
10370 /* 48 */ { SW_SHOWMAXIMIZED
, TRUE
, WS_VISIBLE
|WS_MAXIMIZE
, WmShowMaximized_3
, FALSE
},
10371 /* 49 */ { SW_SHOW
, TRUE
, WS_VISIBLE
|WS_MAXIMIZE
, WmEmptySeq
, FALSE
},
10372 /* 50 */ { SW_SHOWNORMAL
, TRUE
, WS_VISIBLE
, WmRestore_5
, FALSE
},
10373 /* 51 */ { SW_SHOWNORMAL
, TRUE
, WS_VISIBLE
, WmRestore_5
, FALSE
},
10374 /* 52 */ { SW_HIDE
, TRUE
, 0, WmHide_1
, FALSE
},
10375 /* 53 */ { SW_HIDE
, FALSE
, 0, WmEmptySeq
, FALSE
},
10376 /* 54 */ { SW_MINIMIZE
, FALSE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinimize_3
, FALSE
},
10377 /* 55 */ { SW_HIDE
, TRUE
, WS_MINIMIZE
, WmHide_2
, FALSE
},
10378 /* 56 */ { SW_SHOWNOACTIVATE
, FALSE
, WS_VISIBLE
, WmShowNoActivate_2
, FALSE
},
10379 /* 57 */ { SW_SHOW
, TRUE
, WS_VISIBLE
, WmEmptySeq
, FALSE
}
10386 #define WS_BASE (WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX|WS_MAXIMIZEBOX|WS_POPUP|WS_CLIPSIBLINGS)
10387 hwnd
= CreateWindowEx(0, "ShowWindowClass", NULL
, WS_BASE
,
10392 style
= GetWindowLong(hwnd
, GWL_STYLE
) & ~WS_BASE
;
10393 ok(style
== 0, "expected style 0, got %08x\n", style
);
10398 for (i
= 0; i
< sizeof(sw
)/sizeof(sw
[0]); i
++)
10400 static const char * const sw_cmd_name
[13] =
10402 "SW_HIDE", "SW_SHOWNORMAL", "SW_SHOWMINIMIZED", "SW_SHOWMAXIMIZED",
10403 "SW_SHOWNOACTIVATE", "SW_SHOW", "SW_MINIMIZE", "SW_SHOWMINNOACTIVE",
10404 "SW_SHOWNA", "SW_RESTORE", "SW_SHOWDEFAULT", "SW_FORCEMINIMIZE",
10405 "SW_NORMALNA" /* 0xCC */
10408 INT idx
; /* index into the above array of names */
10410 idx
= (sw
[i
].cmd
== SW_NORMALNA
) ? 12 : sw
[i
].cmd
;
10412 style
= GetWindowLong(hwnd
, GWL_STYLE
);
10413 trace("%d: sending %s, current window style %08x\n", i
+1, sw_cmd_name
[idx
], style
);
10414 ret
= ShowWindow(hwnd
, sw
[i
].cmd
);
10415 ok(!ret
== !sw
[i
].ret
, "%d: cmd %s: expected ret %lu, got %lu\n", i
+1, sw_cmd_name
[idx
], sw
[i
].ret
, ret
);
10416 style
= GetWindowLong(hwnd
, GWL_STYLE
) & ~WS_BASE
;
10417 ok(style
== sw
[i
].style
, "%d: expected style %08x, got %08x\n", i
+1, sw
[i
].style
, style
);
10419 sprintf(comment
, "%d: ShowWindow(%s)", i
+1, sw_cmd_name
[idx
]);
10420 ok_sequence(sw
[i
].msg
, comment
, sw
[i
].todo_msg
);
10426 DestroyWindow(hwnd
);
10429 static INT_PTR WINAPI
test_dlg_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
10431 struct recvd_message msg
;
10433 if (ignore_message( message
)) return 0;
10436 msg
.message
= message
;
10437 msg
.flags
= sent
|wparam
|lparam
;
10438 msg
.wParam
= wParam
;
10439 msg
.lParam
= lParam
;
10440 msg
.descr
= "dialog";
10443 /* calling DefDlgProc leads to a recursion under XP */
10447 case WM_INITDIALOG
:
10448 case WM_GETDLGCODE
:
10454 static const struct message WmDefDlgSetFocus_1
[] = {
10455 { WM_GETDLGCODE
, sent
|wparam
|lparam
, 0, 0 },
10456 { WM_GETTEXTLENGTH
, sent
|wparam
|lparam
|optional
, 0, 0 }, /* XP */
10457 { WM_GETTEXT
, sent
|wparam
|optional
, 6 }, /* XP */
10458 { WM_GETTEXT
, sent
|wparam
|optional
, 12 }, /* XP */
10459 { EM_SETSEL
, sent
|wparam
, 0 }, /* XP sets lparam to text length, Win9x to -2 */
10460 { HCBT_SETFOCUS
, hook
},
10461 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
10462 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
10463 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
10464 { WM_SETFOCUS
, sent
|wparam
, 0 },
10465 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 10 },
10466 { WM_CTLCOLOREDIT
, sent
},
10467 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 11 },
10468 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
10469 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
10470 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
10471 { WM_COMMAND
, sent
|wparam
, MAKEWPARAM(1, EN_SETFOCUS
) },
10474 static const struct message WmDefDlgSetFocus_2
[] = {
10475 { WM_GETDLGCODE
, sent
|wparam
|lparam
, 0, 0 },
10476 { WM_GETTEXTLENGTH
, sent
|wparam
|lparam
|optional
, 0, 0 }, /* XP */
10477 { WM_GETTEXT
, sent
|wparam
|optional
, 6 }, /* XP */
10478 { WM_GETTEXT
, sent
|wparam
|optional
, 12 }, /* XP */
10479 { EM_SETSEL
, sent
|wparam
, 0 }, /* XP sets lparam to text length, Win9x to -2 */
10480 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
10481 { WM_CTLCOLOREDIT
, sent
|optional
}, /* XP */
10482 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
10485 /* Creation of a dialog */
10486 static const struct message WmCreateDialogParamSeq_1
[] = {
10487 { HCBT_CREATEWND
, hook
},
10488 { WM_NCCREATE
, sent
},
10489 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
10490 { WM_CREATE
, sent
},
10491 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
10492 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
10494 { WM_SETFONT
, sent
},
10495 { WM_INITDIALOG
, sent
},
10496 { WM_CHANGEUISTATE
, sent
|optional
},
10499 /* Creation of a dialog */
10500 static const struct message WmCreateDialogParamSeq_2
[] = {
10501 { HCBT_CREATEWND
, hook
},
10502 { WM_NCCREATE
, sent
},
10503 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
10504 { WM_CREATE
, sent
},
10505 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
10506 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
10508 { WM_CHANGEUISTATE
, sent
|optional
},
10512 static void test_dialog_messages(void)
10515 HWND hdlg
, hedit1
, hedit2
, hfocus
;
10518 #define set_selection(hctl, start, end) \
10519 ret = SendMessage(hctl, EM_SETSEL, start, end); \
10520 ok(ret == 1, "EM_SETSEL returned %ld\n", ret);
10522 #define check_selection(hctl, start, end) \
10523 ret = SendMessage(hctl, EM_GETSEL, 0, 0); \
10524 ok(ret == MAKELRESULT(start, end), "wrong selection (%d - %d)\n", LOWORD(ret), HIWORD(ret));
10528 hdlg
= CreateWindowEx(WS_EX_DLGMODALFRAME
, "TestDialogClass", NULL
,
10529 WS_VISIBLE
|WS_CAPTION
|WS_SYSMENU
|WS_DLGFRAME
,
10530 0, 0, 100, 100, 0, 0, 0, NULL
);
10531 ok(hdlg
!= 0, "Failed to create custom dialog window\n");
10533 hedit1
= CreateWindowEx(0, "my_edit_class", NULL
,
10534 WS_CHILD
|WS_BORDER
|WS_VISIBLE
|WS_TABSTOP
,
10535 0, 0, 80, 20, hdlg
, (HMENU
)1, 0, NULL
);
10536 ok(hedit1
!= 0, "Failed to create edit control\n");
10537 hedit2
= CreateWindowEx(0, "my_edit_class", NULL
,
10538 WS_CHILD
|WS_BORDER
|WS_VISIBLE
|WS_TABSTOP
,
10539 0, 40, 80, 20, hdlg
, (HMENU
)2, 0, NULL
);
10540 ok(hedit2
!= 0, "Failed to create edit control\n");
10542 SendMessage(hedit1
, WM_SETTEXT
, 0, (LPARAM
)"hello");
10543 SendMessage(hedit2
, WM_SETTEXT
, 0, (LPARAM
)"bye");
10545 hfocus
= GetFocus();
10546 ok(hfocus
== hdlg
, "wrong focus %p\n", hfocus
);
10549 hfocus
= GetFocus();
10550 ok(hfocus
== hedit2
, "wrong focus %p\n", hfocus
);
10552 check_selection(hedit1
, 0, 0);
10553 check_selection(hedit2
, 0, 0);
10555 set_selection(hedit2
, 0, -1);
10556 check_selection(hedit2
, 0, 3);
10559 hfocus
= GetFocus();
10560 ok(hfocus
== 0, "wrong focus %p\n", hfocus
);
10563 ret
= DefDlgProc(hdlg
, WM_SETFOCUS
, 0, 0);
10564 ok(ret
== 0, "WM_SETFOCUS returned %ld\n", ret
);
10565 ok_sequence(WmDefDlgSetFocus_1
, "DefDlgProc(WM_SETFOCUS) 1", FALSE
);
10567 hfocus
= GetFocus();
10568 ok(hfocus
== hedit1
, "wrong focus %p\n", hfocus
);
10570 check_selection(hedit1
, 0, 5);
10571 check_selection(hedit2
, 0, 3);
10574 ret
= DefDlgProc(hdlg
, WM_SETFOCUS
, 0, 0);
10575 ok(ret
== 0, "WM_SETFOCUS returned %ld\n", ret
);
10576 ok_sequence(WmDefDlgSetFocus_2
, "DefDlgProc(WM_SETFOCUS) 2", FALSE
);
10578 hfocus
= GetFocus();
10579 ok(hfocus
== hedit1
, "wrong focus %p\n", hfocus
);
10581 check_selection(hedit1
, 0, 5);
10582 check_selection(hedit2
, 0, 3);
10584 EndDialog(hdlg
, 0);
10585 DestroyWindow(hedit1
);
10586 DestroyWindow(hedit2
);
10587 DestroyWindow(hdlg
);
10590 #undef set_selection
10591 #undef check_selection
10593 ok(GetClassInfo(0, "#32770", &cls
), "GetClassInfo failed\n");
10594 cls
.lpszClassName
= "MyDialogClass";
10595 cls
.hInstance
= GetModuleHandle(0);
10596 /* need a cast since a dlgproc is used as a wndproc */
10597 cls
.lpfnWndProc
= (WNDPROC
)test_dlg_proc
;
10598 if (!RegisterClass(&cls
)) assert(0);
10600 hdlg
= CreateDialogParam(0, "CLASS_TEST_DIALOG_2", 0, test_dlg_proc
, 0);
10601 ok(IsWindow(hdlg
), "CreateDialogParam failed\n");
10602 ok_sequence(WmCreateDialogParamSeq_1
, "CreateDialogParam_1", FALSE
);
10603 EndDialog(hdlg
, 0);
10604 DestroyWindow(hdlg
);
10607 hdlg
= CreateDialogParam(0, "CLASS_TEST_DIALOG_2", 0, NULL
, 0);
10608 ok(IsWindow(hdlg
), "CreateDialogParam failed\n");
10609 ok_sequence(WmCreateDialogParamSeq_2
, "CreateDialogParam_2", FALSE
);
10610 EndDialog(hdlg
, 0);
10611 DestroyWindow(hdlg
);
10614 UnregisterClass(cls
.lpszClassName
, cls
.hInstance
);
10617 static void test_nullCallback(void)
10621 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW
,
10622 100, 100, 200, 200, 0, 0, 0, NULL
);
10623 ok (hwnd
!= 0, "Failed to create overlapped window\n");
10625 SendMessageCallbackA(hwnd
,WM_NULL
,0,0,NULL
,0);
10627 DestroyWindow(hwnd
);
10630 /* SetActiveWindow( 0 ) hwnd visible */
10631 static const struct message SetActiveWindowSeq0
[] =
10633 { HCBT_ACTIVATE
, hook
|optional
},
10634 { WM_NCACTIVATE
, sent
|wparam
, 0 },
10635 { WM_GETTEXT
, sent
|defwinproc
|optional
},
10636 { WM_ACTIVATE
, sent
|wparam
, 0 },
10637 { WM_ACTIVATEAPP
, sent
|wparam
|optional
, 0 },
10638 { WM_ACTIVATEAPP
, sent
|wparam
|optional
, 0 },
10639 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
10640 { WM_KILLFOCUS
, sent
|optional
},
10641 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
10642 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
10643 { WM_NCACTIVATE
, sent
|wparam
|optional
, 1 },
10644 { WM_GETTEXT
, sent
|defwinproc
|optional
},
10645 { WM_ACTIVATE
, sent
|wparam
|optional
, 1 },
10646 { HCBT_SETFOCUS
, hook
|optional
},
10647 { WM_KILLFOCUS
, sent
|defwinproc
|optional
},
10648 { WM_IME_SETCONTEXT
, sent
|defwinproc
|optional
},
10649 { WM_IME_SETCONTEXT
, sent
|defwinproc
|optional
},
10650 { WM_IME_SETCONTEXT
, sent
|optional
},
10651 { WM_IME_SETCONTEXT
, sent
|optional
},
10652 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 1 },
10653 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
10654 { WM_SETFOCUS
, sent
|defwinproc
|optional
},
10655 { WM_GETTEXT
, sent
|optional
},
10658 /* SetActiveWindow( hwnd ) hwnd visible */
10659 static const struct message SetActiveWindowSeq1
[] =
10661 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
10664 /* SetActiveWindow( popup ) hwnd visible, popup visible */
10665 static const struct message SetActiveWindowSeq2
[] =
10667 { HCBT_ACTIVATE
, hook
},
10668 { WM_NCACTIVATE
, sent
|wparam
, 0 },
10669 { WM_GETTEXT
, sent
|defwinproc
|optional
},
10670 { WM_ACTIVATE
, sent
|wparam
, 0 },
10671 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
10672 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
10673 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
10674 { WM_NCPAINT
, sent
|optional
},
10675 { WM_GETTEXT
, sent
|defwinproc
|optional
},
10676 { WM_ERASEBKGND
, sent
|optional
},
10677 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
10678 { WM_NCACTIVATE
, sent
|wparam
, 1 },
10679 { WM_GETTEXT
, sent
|defwinproc
|optional
},
10680 { WM_ACTIVATE
, sent
|wparam
, 1 },
10681 { HCBT_SETFOCUS
, hook
},
10682 { WM_KILLFOCUS
, sent
|defwinproc
},
10683 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 0 },
10684 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
10685 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 1 },
10686 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
10687 { WM_SETFOCUS
, sent
|defwinproc
},
10688 { WM_GETTEXT
, sent
|optional
},
10692 /* SetActiveWindow( hwnd ) hwnd not visible */
10693 static const struct message SetActiveWindowSeq3
[] =
10695 { HCBT_ACTIVATE
, hook
},
10696 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
10697 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
10698 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
},
10699 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOACTIVATE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
10700 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
10701 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
10702 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
10703 { WM_NCACTIVATE
, sent
|wparam
, 1 },
10704 { WM_ACTIVATE
, sent
|wparam
, 1 },
10705 { HCBT_SETFOCUS
, hook
},
10706 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
10707 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
10708 { WM_SETFOCUS
, sent
|defwinproc
},
10711 /* SetActiveWindow( popup ) hwnd not visible, popup not visible */
10712 static const struct message SetActiveWindowSeq4
[] =
10714 { HCBT_ACTIVATE
, hook
},
10715 { WM_NCACTIVATE
, sent
|wparam
, 0 },
10716 { WM_GETTEXT
, sent
|defwinproc
|optional
},
10717 { WM_ACTIVATE
, sent
|wparam
, 0 },
10718 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
10719 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
},
10720 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
10721 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
10722 { WM_NCACTIVATE
, sent
|wparam
, 1 },
10723 { WM_GETTEXT
, sent
|defwinproc
|optional
},
10724 { WM_ACTIVATE
, sent
|wparam
, 1 },
10725 { HCBT_SETFOCUS
, hook
},
10726 { WM_KILLFOCUS
, sent
|defwinproc
},
10727 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 0 },
10728 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
10729 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 1 },
10730 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
10731 { WM_SETFOCUS
, sent
|defwinproc
},
10736 static void test_SetActiveWindow(void)
10738 HWND hwnd
, popup
, ret
;
10740 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test SetActiveWindow",
10741 WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
10742 100, 100, 200, 200, 0, 0, 0, NULL
);
10744 popup
= CreateWindowExA(0, "TestWindowClass", "Test SetActiveWindow",
10745 WS_OVERLAPPEDWINDOW
| WS_VISIBLE
| WS_POPUP
,
10746 100, 100, 200, 200, hwnd
, 0, 0, NULL
);
10748 ok(hwnd
!= 0, "Failed to create overlapped window\n");
10749 ok(popup
!= 0, "Failed to create popup window\n");
10750 SetForegroundWindow( popup
);
10753 trace("SetActiveWindow(0)\n");
10754 ret
= SetActiveWindow(0);
10755 ok( ret
== popup
, "Failed to SetActiveWindow(0)\n");
10756 ok_sequence(SetActiveWindowSeq0
, "SetActiveWindow(0)", FALSE
);
10759 trace("SetActiveWindow(hwnd), hwnd visible\n");
10760 ret
= SetActiveWindow(hwnd
);
10761 if (ret
== hwnd
) ok_sequence(SetActiveWindowSeq1
, "SetActiveWindow(hwnd), hwnd visible", TRUE
);
10764 trace("SetActiveWindow(popup), hwnd visible, popup visible\n");
10765 ret
= SetActiveWindow(popup
);
10766 ok( ret
== hwnd
, "Failed to SetActiveWindow(popup), popup visible\n");
10767 ok_sequence(SetActiveWindowSeq2
, "SetActiveWindow(popup), hwnd visible, popup visible", FALSE
);
10770 ShowWindow(hwnd
, SW_HIDE
);
10771 ShowWindow(popup
, SW_HIDE
);
10774 trace("SetActiveWindow(hwnd), hwnd not visible\n");
10775 ret
= SetActiveWindow(hwnd
);
10776 ok( ret
== NULL
, "SetActiveWindow(hwnd), hwnd not visible, previous is %p\n", ret
);
10777 ok_sequence(SetActiveWindowSeq3
, "SetActiveWindow(hwnd), hwnd not visible", TRUE
);
10780 trace("SetActiveWindow(popup), hwnd not visible, popup not visible\n");
10781 ret
= SetActiveWindow(popup
);
10782 ok( ret
== hwnd
, "Failed to SetActiveWindow(popup)\n");
10783 ok_sequence(SetActiveWindowSeq4
, "SetActiveWindow(popup), hwnd not visible, popup not visible", TRUE
);
10788 DestroyWindow(hwnd
);
10791 static const struct message SetForegroundWindowSeq
[] =
10793 { WM_NCACTIVATE
, sent
|wparam
, 0 },
10794 { WM_GETTEXT
, sent
|defwinproc
|optional
},
10795 { WM_ACTIVATE
, sent
|wparam
, 0 },
10796 { WM_ACTIVATEAPP
, sent
|wparam
, 0 },
10797 { WM_KILLFOCUS
, sent
},
10798 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
10799 { WM_IME_NOTIFY
, sent
|wparam
|optional
|defwinproc
, 1 },
10803 static void test_SetForegroundWindow(void)
10807 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test SetForegroundWindow",
10808 WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
10809 100, 100, 200, 200, 0, 0, 0, NULL
);
10810 ok (hwnd
!= 0, "Failed to create overlapped window\n");
10811 SetForegroundWindow( hwnd
);
10814 trace("SetForegroundWindow( 0 )\n");
10815 SetForegroundWindow( 0 );
10816 ok_sequence(WmEmptySeq
, "SetForegroundWindow( 0 ) away from foreground top level window", FALSE
);
10817 trace("SetForegroundWindow( GetDesktopWindow() )\n");
10818 SetForegroundWindow( GetDesktopWindow() );
10819 ok_sequence(SetForegroundWindowSeq
, "SetForegroundWindow( desktop ) away from "
10820 "foreground top level window", FALSE
);
10823 DestroyWindow(hwnd
);
10826 static void test_dbcs_wm_char(void)
10829 WCHAR wch
, bad_wch
;
10837 struct message wmCharSeq
[2];
10839 if (!pGetCPInfoExA
)
10841 win_skip("GetCPInfoExA is not available\n");
10845 pGetCPInfoExA( CP_ACP
, 0, &cpinfo
);
10846 if (cpinfo
.MaxCharSize
!= 2)
10848 skip( "Skipping DBCS WM_CHAR test in SBCS codepage '%s'\n", cpinfo
.CodePageName
);
10852 dbch
[0] = dbch
[1] = 0;
10854 bad_wch
= cpinfo
.UnicodeDefaultChar
;
10855 for (i
= 0; !wch
&& i
< MAX_LEADBYTES
&& cpinfo
.LeadByte
[i
]; i
+= 2)
10856 for (j
= cpinfo
.LeadByte
[i
]; !wch
&& j
<= cpinfo
.LeadByte
[i
+1]; j
++)
10857 for (k
= 128; k
<= 255; k
++)
10863 if (MultiByteToWideChar( CP_ACP
, 0, str
, 2, wstr
, 2 ) == 1 &&
10864 WideCharToMultiByte( CP_ACP
, 0, wstr
, 1, str
, 2, NULL
, NULL
) == 2 &&
10865 (BYTE
)str
[0] == j
&& (BYTE
)str
[1] == k
&&
10866 HIBYTE(wstr
[0]) && HIBYTE(wstr
[0]) != 0xff)
10877 skip( "Skipping DBCS WM_CHAR test, no appropriate char found\n" );
10880 trace( "using dbcs char %02x,%02x wchar %04x bad wchar %04x codepage '%s'\n",
10881 dbch
[0], dbch
[1], wch
, bad_wch
, cpinfo
.CodePageName
);
10883 hwnd
= CreateWindowExW(0, testWindowClassW
, NULL
,
10884 WS_OVERLAPPEDWINDOW
, 100, 100, 200, 200, 0, 0, 0, NULL
);
10885 hwnd2
= CreateWindowExW(0, testWindowClassW
, NULL
,
10886 WS_OVERLAPPEDWINDOW
, 100, 100, 200, 200, 0, 0, 0, NULL
);
10887 ok (hwnd
!= 0, "Failed to create overlapped window\n");
10888 ok (hwnd2
!= 0, "Failed to create overlapped window\n");
10891 memset( wmCharSeq
, 0, sizeof(wmCharSeq
) );
10892 wmCharSeq
[0].message
= WM_CHAR
;
10893 wmCharSeq
[0].flags
= sent
|wparam
;
10894 wmCharSeq
[0].wParam
= wch
;
10896 /* posted message */
10897 PostMessageA( hwnd
, WM_CHAR
, dbch
[0], 0 );
10898 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
10899 PostMessageA( hwnd
, WM_CHAR
, dbch
[1], 0 );
10900 ok( PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "no message\n" );
10901 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
10902 ok( msg
.wParam
== wch
, "bad wparam %lx/%x\n", msg
.wParam
, wch
);
10903 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
10905 /* posted thread message */
10906 PostThreadMessageA( GetCurrentThreadId(), WM_CHAR
, dbch
[0], 0 );
10907 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
10908 PostMessageA( hwnd
, WM_CHAR
, dbch
[1], 0 );
10909 ok( PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "no message\n" );
10910 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
10911 ok( msg
.wParam
== wch
, "bad wparam %lx/%x\n", msg
.wParam
, wch
);
10912 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
10916 SendMessageA( hwnd
, WM_CHAR
, dbch
[0], 0 );
10917 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
10918 SendMessageA( hwnd
, WM_CHAR
, dbch
[1], 0 );
10919 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
10920 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
10922 /* sent message with timeout */
10924 SendMessageTimeoutA( hwnd
, WM_CHAR
, dbch
[0], 0, SMTO_NORMAL
, 0, &res
);
10925 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
10926 SendMessageTimeoutA( hwnd
, WM_CHAR
, dbch
[1], 0, SMTO_NORMAL
, 0, &res
);
10927 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
10928 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
10930 /* sent message with timeout and callback */
10932 SendMessageTimeoutA( hwnd
, WM_CHAR
, dbch
[0], 0, SMTO_NORMAL
, 0, &res
);
10933 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
10934 SendMessageCallbackA( hwnd
, WM_CHAR
, dbch
[1], 0, NULL
, 0 );
10935 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
10936 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
10938 /* sent message with callback */
10940 SendNotifyMessageA( hwnd
, WM_CHAR
, dbch
[0], 0 );
10941 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
10942 SendMessageCallbackA( hwnd
, WM_CHAR
, dbch
[1], 0, NULL
, 0 );
10943 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
10944 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
10946 /* direct window proc call */
10948 CallWindowProcA( (WNDPROC
)GetWindowLongPtrA( hwnd
, GWLP_WNDPROC
), hwnd
, WM_CHAR
, dbch
[0], 0 );
10949 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
10950 CallWindowProcA( (WNDPROC
)GetWindowLongPtrA( hwnd
, GWLP_WNDPROC
), hwnd
, WM_CHAR
, dbch
[1], 0 );
10951 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
10953 /* dispatch message */
10955 msg
.message
= WM_CHAR
;
10956 msg
.wParam
= dbch
[0];
10958 DispatchMessageA( &msg
);
10959 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
10960 msg
.wParam
= dbch
[1];
10961 DispatchMessageA( &msg
);
10962 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
10964 /* window handle is irrelevant */
10966 SendMessageA( hwnd2
, WM_CHAR
, dbch
[0], 0 );
10967 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
10968 SendMessageA( hwnd
, WM_CHAR
, dbch
[1], 0 );
10969 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
10970 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
10972 /* interleaved post and send */
10974 PostMessageA( hwnd2
, WM_CHAR
, dbch
[0], 0 );
10975 SendMessageA( hwnd2
, WM_CHAR
, dbch
[0], 0 );
10976 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
10977 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
10978 PostMessageA( hwnd
, WM_CHAR
, dbch
[1], 0 );
10979 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
10980 ok( PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "no message\n" );
10981 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
10982 ok( msg
.wParam
== wch
, "bad wparam %lx/%x\n", msg
.wParam
, wch
);
10983 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
10984 SendMessageA( hwnd
, WM_CHAR
, dbch
[1], 0 );
10985 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
10986 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
10988 /* interleaved sent message and winproc */
10990 SendMessageA( hwnd
, WM_CHAR
, dbch
[0], 0 );
10991 CallWindowProcA( (WNDPROC
)GetWindowLongPtrA( hwnd
, GWLP_WNDPROC
), hwnd
, WM_CHAR
, dbch
[0], 0 );
10992 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
10993 SendMessageA( hwnd
, WM_CHAR
, dbch
[1], 0 );
10994 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
10995 CallWindowProcA( (WNDPROC
)GetWindowLongPtrA( hwnd
, GWLP_WNDPROC
), hwnd
, WM_CHAR
, dbch
[1], 0 );
10996 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
10998 /* interleaved winproc and dispatch */
11000 msg
.message
= WM_CHAR
;
11001 msg
.wParam
= dbch
[0];
11003 CallWindowProcA( (WNDPROC
)GetWindowLongPtrA( hwnd
, GWLP_WNDPROC
), hwnd
, WM_CHAR
, dbch
[0], 0 );
11004 DispatchMessageA( &msg
);
11005 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
11006 msg
.wParam
= dbch
[1];
11007 DispatchMessageA( &msg
);
11008 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
11009 CallWindowProcA( (WNDPROC
)GetWindowLongPtrA( hwnd
, GWLP_WNDPROC
), hwnd
, WM_CHAR
, dbch
[1], 0 );
11010 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
11012 /* interleaved sends */
11014 SendMessageA( hwnd
, WM_CHAR
, dbch
[0], 0 );
11015 SendMessageCallbackA( hwnd
, WM_CHAR
, dbch
[0], 0, NULL
, 0 );
11016 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
11017 SendMessageTimeoutA( hwnd
, WM_CHAR
, dbch
[1], 0, SMTO_NORMAL
, 0, &res
);
11018 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
11019 SendMessageA( hwnd
, WM_CHAR
, dbch
[1], 0 );
11020 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
11024 SendMessageA( hwnd2
, WM_CHAR
, (dbch
[1] << 8) | dbch
[0], 0 );
11025 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
11026 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
11028 /* other char messages are not magic */
11029 PostMessageA( hwnd
, WM_SYSCHAR
, dbch
[0], 0 );
11030 ok( PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "no message\n" );
11031 ok( msg
.message
== WM_SYSCHAR
, "unexpected message %x\n", msg
.message
);
11032 ok( msg
.wParam
== bad_wch
, "bad wparam %lx/%x\n", msg
.wParam
, bad_wch
);
11033 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
11034 PostMessageA( hwnd
, WM_DEADCHAR
, dbch
[0], 0 );
11035 ok( PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "no message\n" );
11036 ok( msg
.message
== WM_DEADCHAR
, "unexpected message %x\n", msg
.message
);
11037 ok( msg
.wParam
== bad_wch
, "bad wparam %lx/%x\n", msg
.wParam
, bad_wch
);
11038 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
11040 /* test retrieving messages */
11042 PostMessageW( hwnd
, WM_CHAR
, wch
, 0 );
11043 ok( PeekMessageA( &msg
, hwnd
, 0, 0, PM_REMOVE
), "no message\n" );
11044 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
11045 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
11046 ok( msg
.wParam
== dbch
[0], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
11047 ok( PeekMessageA( &msg
, hwnd
, 0, 0, PM_REMOVE
), "no message\n" );
11048 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
11049 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
11050 ok( msg
.wParam
== dbch
[1], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
11051 ok( !PeekMessageA( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
11053 /* message filters */
11054 PostMessageW( hwnd
, WM_CHAR
, wch
, 0 );
11055 ok( PeekMessageA( &msg
, hwnd
, 0, 0, PM_REMOVE
), "no message\n" );
11056 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
11057 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
11058 ok( msg
.wParam
== dbch
[0], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
11059 /* message id is filtered, hwnd is not */
11060 ok( !PeekMessageA( &msg
, hwnd
, WM_MOUSEFIRST
, WM_MOUSELAST
, PM_REMOVE
), "no message\n" );
11061 ok( PeekMessageA( &msg
, hwnd2
, 0, 0, PM_REMOVE
), "no message\n" );
11062 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
11063 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
11064 ok( msg
.wParam
== dbch
[1], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
11065 ok( !PeekMessageA( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
11067 /* mixing GetMessage and PostMessage */
11068 PostMessageW( hwnd
, WM_CHAR
, wch
, 0xbeef );
11069 ok( GetMessageA( &msg
, hwnd
, 0, 0 ), "no message\n" );
11070 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
11071 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
11072 ok( msg
.wParam
== dbch
[0], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
11073 ok( msg
.lParam
== 0xbeef, "bad lparam %lx\n", msg
.lParam
);
11076 ok( time
- GetTickCount() <= 100, "bad time %x\n", msg
.time
);
11077 ok( PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
), "no message\n" );
11078 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
11079 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
11080 ok( msg
.wParam
== dbch
[1], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
11081 ok( msg
.lParam
== 0xbeef, "bad lparam %lx\n", msg
.lParam
);
11082 ok( msg
.time
== time
, "bad time %x/%x\n", msg
.time
, time
);
11083 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
);
11084 ok( !PeekMessageA( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
11086 /* without PM_REMOVE */
11087 PostMessageW( hwnd
, WM_CHAR
, wch
, 0 );
11088 ok( PeekMessageA( &msg
, 0, 0, 0, PM_NOREMOVE
), "no message\n" );
11089 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
11090 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
11091 ok( msg
.wParam
== dbch
[0], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
11092 ok( PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
), "no message\n" );
11093 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
11094 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
11095 ok( msg
.wParam
== dbch
[0], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
11096 ok( PeekMessageA( &msg
, 0, 0, 0, PM_NOREMOVE
), "no message\n" );
11097 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
11098 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
11099 ok( msg
.wParam
== dbch
[1], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
11100 ok( PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
), "no message\n" );
11101 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
11102 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
11103 ok( msg
.wParam
== dbch
[1], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
11104 ok( !PeekMessageA( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
11106 DestroyWindow(hwnd
);
11109 #define ID_LISTBOX 0x000f
11111 static const struct message wm_lb_setcursel_0
[] =
11113 { LB_SETCURSEL
, sent
|wparam
|lparam
, 0, 0 },
11114 { WM_CTLCOLORLISTBOX
, sent
|parent
},
11115 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x000120f2 },
11116 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 1 },
11117 { EVENT_OBJECT_SELECTION
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 1 },
11120 static const struct message wm_lb_setcursel_1
[] =
11122 { LB_SETCURSEL
, sent
|wparam
|lparam
, 1, 0 },
11123 { WM_CTLCOLORLISTBOX
, sent
|parent
},
11124 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x000020f2 },
11125 { WM_CTLCOLORLISTBOX
, sent
|parent
},
11126 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x000121f2 },
11127 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 2 },
11128 { EVENT_OBJECT_SELECTION
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 2 },
11131 static const struct message wm_lb_setcursel_2
[] =
11133 { LB_SETCURSEL
, sent
|wparam
|lparam
, 2, 0 },
11134 { WM_CTLCOLORLISTBOX
, sent
|parent
},
11135 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x000021f2 },
11136 { WM_CTLCOLORLISTBOX
, sent
|parent
},
11137 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x000122f2 },
11138 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 3 },
11139 { EVENT_OBJECT_SELECTION
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 3 },
11142 static const struct message wm_lb_click_0
[] =
11144 { WM_LBUTTONDOWN
, sent
|wparam
|lparam
, 0, MAKELPARAM(1,1) },
11145 { HCBT_SETFOCUS
, hook
},
11146 { WM_KILLFOCUS
, sent
|parent
},
11147 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
|parent
, 0 },
11148 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
11149 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
11150 { WM_SETFOCUS
, sent
|defwinproc
},
11152 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x001142f2 },
11153 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_LISTBOX
, LBN_SETFOCUS
) },
11154 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 3 },
11155 { WM_LBTRACKPOINT
, sent
|wparam
|lparam
|parent
, 0, MAKELPARAM(1,1) },
11156 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
11158 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x000142f2 },
11159 { WM_CTLCOLORLISTBOX
, sent
|parent
},
11160 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x000022f2 },
11161 { WM_CTLCOLORLISTBOX
, sent
|parent
},
11162 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x000120f2 },
11163 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x001140f2 },
11165 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 1 },
11166 { EVENT_OBJECT_SELECTION
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 1 },
11168 { WM_LBUTTONUP
, sent
|wparam
|lparam
, 0, 0 },
11169 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, 0, 0 },
11170 { WM_CAPTURECHANGED
, sent
|wparam
|lparam
|defwinproc
, 0, 0 },
11171 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_LISTBOX
, LBN_SELCHANGE
) },
11174 static const struct message wm_lb_deletestring
[] =
11176 { LB_DELETESTRING
, sent
|wparam
|lparam
, 0, 0 },
11177 { WM_DELETEITEM
, sent
|wparam
|parent
|optional
, ID_LISTBOX
, 0 },
11178 { WM_DRAWITEM
, sent
|wparam
|parent
|optional
, ID_LISTBOX
},
11179 { WM_DRAWITEM
, sent
|wparam
|parent
|optional
, ID_LISTBOX
},
11182 static const struct message wm_lb_deletestring_reset
[] =
11184 { LB_DELETESTRING
, sent
|wparam
|lparam
, 0, 0 },
11185 { LB_RESETCONTENT
, sent
|wparam
|lparam
|defwinproc
|optional
, 0, 0 },
11186 { WM_DELETEITEM
, sent
|wparam
|parent
|optional
, ID_LISTBOX
, 0 },
11187 { WM_DRAWITEM
, sent
|wparam
|parent
|optional
, ID_LISTBOX
},
11188 { WM_DRAWITEM
, sent
|wparam
|parent
|optional
, ID_LISTBOX
},
11192 #define check_lb_state(a1, a2, a3, a4, a5) check_lb_state_dbg(a1, a2, a3, a4, a5, __LINE__)
11194 static LRESULT (WINAPI
*listbox_orig_proc
)(HWND
, UINT
, WPARAM
, LPARAM
);
11196 static LRESULT WINAPI
listbox_hook_proc(HWND hwnd
, UINT message
, WPARAM wp
, LPARAM lp
)
11198 static LONG defwndproc_counter
= 0;
11200 struct recvd_message msg
;
11202 /* do not log painting messages */
11203 if (message
!= WM_PAINT
&&
11204 message
!= WM_NCPAINT
&&
11205 message
!= WM_SYNCPAINT
&&
11206 message
!= WM_ERASEBKGND
&&
11207 message
!= WM_NCHITTEST
&&
11208 message
!= WM_GETTEXT
&&
11209 !ignore_message( message
))
11212 msg
.message
= message
;
11213 msg
.flags
= sent
|wparam
|lparam
;
11214 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
11217 msg
.descr
= "listbox";
11221 defwndproc_counter
++;
11222 ret
= CallWindowProcA(listbox_orig_proc
, hwnd
, message
, wp
, lp
);
11223 defwndproc_counter
--;
11228 static void check_lb_state_dbg(HWND listbox
, int count
, int cur_sel
,
11229 int caret_index
, int top_index
, int line
)
11233 /* calling an orig proc helps to avoid unnecessary message logging */
11234 ret
= CallWindowProcA(listbox_orig_proc
, listbox
, LB_GETCOUNT
, 0, 0);
11235 ok_(__FILE__
, line
)(ret
== count
, "expected count %d, got %ld\n", count
, ret
);
11236 ret
= CallWindowProcA(listbox_orig_proc
, listbox
, LB_GETCURSEL
, 0, 0);
11237 ok_(__FILE__
, line
)(ret
== cur_sel
, "expected cur sel %d, got %ld\n", cur_sel
, ret
);
11238 ret
= CallWindowProcA(listbox_orig_proc
, listbox
, LB_GETCARETINDEX
, 0, 0);
11239 ok_(__FILE__
, line
)(ret
== caret_index
||
11240 broken(cur_sel
== -1 && caret_index
== 0 && ret
== -1), /* nt4 */
11241 "expected caret index %d, got %ld\n", caret_index
, ret
);
11242 ret
= CallWindowProcA(listbox_orig_proc
, listbox
, LB_GETTOPINDEX
, 0, 0);
11243 ok_(__FILE__
, line
)(ret
== top_index
, "expected top index %d, got %ld\n", top_index
, ret
);
11246 static void test_listbox_messages(void)
11248 HWND parent
, listbox
;
11251 parent
= CreateWindowExA(0, "TestParentClass", NULL
, WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
11252 100, 100, 200, 200, 0, 0, 0, NULL
);
11253 listbox
= CreateWindowExA(WS_EX_NOPARENTNOTIFY
, "ListBox", NULL
,
11254 WS_CHILD
| LBS_NOTIFY
| LBS_OWNERDRAWVARIABLE
| LBS_HASSTRINGS
| WS_VISIBLE
,
11255 10, 10, 80, 80, parent
, (HMENU
)ID_LISTBOX
, 0, NULL
);
11256 listbox_orig_proc
= (WNDPROC
)SetWindowLongPtrA(listbox
, GWLP_WNDPROC
, (ULONG_PTR
)listbox_hook_proc
);
11258 check_lb_state(listbox
, 0, LB_ERR
, 0, 0);
11260 ret
= SendMessage(listbox
, LB_ADDSTRING
, 0, (LPARAM
)"item 0");
11261 ok(ret
== 0, "expected 0, got %ld\n", ret
);
11262 ret
= SendMessage(listbox
, LB_ADDSTRING
, 0, (LPARAM
)"item 1");
11263 ok(ret
== 1, "expected 1, got %ld\n", ret
);
11264 ret
= SendMessage(listbox
, LB_ADDSTRING
, 0, (LPARAM
)"item 2");
11265 ok(ret
== 2, "expected 2, got %ld\n", ret
);
11267 check_lb_state(listbox
, 3, LB_ERR
, 0, 0);
11271 log_all_parent_messages
++;
11273 trace("selecting item 0\n");
11274 ret
= SendMessage(listbox
, LB_SETCURSEL
, 0, 0);
11275 ok(ret
== 0, "expected 0, got %ld\n", ret
);
11276 ok_sequence(wm_lb_setcursel_0
, "LB_SETCURSEL 0", FALSE
);
11277 check_lb_state(listbox
, 3, 0, 0, 0);
11280 trace("selecting item 1\n");
11281 ret
= SendMessage(listbox
, LB_SETCURSEL
, 1, 0);
11282 ok(ret
== 1, "expected 1, got %ld\n", ret
);
11283 ok_sequence(wm_lb_setcursel_1
, "LB_SETCURSEL 1", FALSE
);
11284 check_lb_state(listbox
, 3, 1, 1, 0);
11286 trace("selecting item 2\n");
11287 ret
= SendMessage(listbox
, LB_SETCURSEL
, 2, 0);
11288 ok(ret
== 2, "expected 2, got %ld\n", ret
);
11289 ok_sequence(wm_lb_setcursel_2
, "LB_SETCURSEL 2", FALSE
);
11290 check_lb_state(listbox
, 3, 2, 2, 0);
11292 trace("clicking on item 0\n");
11293 ret
= SendMessage(listbox
, WM_LBUTTONDOWN
, 0, MAKELPARAM(1, 1));
11294 ok(ret
== LB_OKAY
, "expected LB_OKAY, got %ld\n", ret
);
11295 ret
= SendMessage(listbox
, WM_LBUTTONUP
, 0, 0);
11296 ok(ret
== LB_OKAY
, "expected LB_OKAY, got %ld\n", ret
);
11297 ok_sequence(wm_lb_click_0
, "WM_LBUTTONDOWN 0", FALSE
);
11298 check_lb_state(listbox
, 3, 0, 0, 0);
11301 trace("deleting item 0\n");
11302 ret
= SendMessage(listbox
, LB_DELETESTRING
, 0, 0);
11303 ok(ret
== 2, "expected 2, got %ld\n", ret
);
11304 ok_sequence(wm_lb_deletestring
, "LB_DELETESTRING 0", FALSE
);
11305 check_lb_state(listbox
, 2, -1, 0, 0);
11308 trace("deleting item 0\n");
11309 ret
= SendMessage(listbox
, LB_DELETESTRING
, 0, 0);
11310 ok(ret
== 1, "expected 1, got %ld\n", ret
);
11311 ok_sequence(wm_lb_deletestring
, "LB_DELETESTRING 0", FALSE
);
11312 check_lb_state(listbox
, 1, -1, 0, 0);
11315 trace("deleting item 0\n");
11316 ret
= SendMessage(listbox
, LB_DELETESTRING
, 0, 0);
11317 ok(ret
== 0, "expected 0, got %ld\n", ret
);
11318 ok_sequence(wm_lb_deletestring_reset
, "LB_DELETESTRING 0", FALSE
);
11319 check_lb_state(listbox
, 0, -1, 0, 0);
11322 trace("deleting item 0\n");
11323 ret
= SendMessage(listbox
, LB_DELETESTRING
, 0, 0);
11324 ok(ret
== LB_ERR
, "expected LB_ERR, got %ld\n", ret
);
11325 check_lb_state(listbox
, 0, -1, 0, 0);
11328 log_all_parent_messages
--;
11330 DestroyWindow(listbox
);
11331 DestroyWindow(parent
);
11334 /*************************** Menu test ******************************/
11335 static const struct message wm_popup_menu_1
[] =
11337 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 },
11338 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
11339 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'E', 0x20000001 },
11340 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, 'E', 0x20000001 },
11341 { WM_SYSCHAR
, sent
|wparam
|lparam
, 'e', 0x20000001 },
11342 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_KEYMENU
, 'e' },
11343 { WM_ENTERMENULOOP
, sent
|wparam
|lparam
, 0, 0 },
11344 { WM_INITMENU
, sent
|lparam
, 0, 0 },
11345 { WM_MENUSELECT
, sent
|wparam
, MAKEWPARAM(1,MF_HILITE
|MF_POPUP
) },
11346 { WM_INITMENUPOPUP
, sent
|lparam
, 0, 1 },
11347 { HCBT_CREATEWND
, hook
|optional
}, /* Win9x doesn't create a window */
11348 { WM_MENUSELECT
, sent
|wparam
, MAKEWPARAM(200,MF_HILITE
) },
11349 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'E', 0xf0000001 },
11350 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xd0000001 },
11351 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_RETURN
, 0x10000001 },
11352 { HCBT_DESTROYWND
, hook
|optional
}, /* Win9x doesn't create a window */
11353 { WM_UNINITMENUPOPUP
, sent
|lparam
, 0, 0 },
11354 { WM_MENUSELECT
, sent
|wparam
|lparam
, MAKEWPARAM(0,0xffff), 0 },
11355 { WM_EXITMENULOOP
, sent
|wparam
|lparam
, 0, 0 },
11356 { WM_MENUCOMMAND
, sent
}, /* |wparam, 200 - Win9x */
11357 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_RETURN
, 0xc0000001 },
11358 { WM_KEYUP
, sent
|wparam
|lparam
, VK_RETURN
, 0xc0000001 },
11361 static const struct message wm_popup_menu_2
[] =
11363 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 },
11364 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
11365 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'F', 0x20000001 },
11366 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, 'F', 0x20000001 },
11367 { WM_SYSCHAR
, sent
|wparam
|lparam
, 'f', 0x20000001 },
11368 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_KEYMENU
, 'f' },
11369 { WM_ENTERMENULOOP
, sent
|wparam
|lparam
, 0, 0 },
11370 { WM_INITMENU
, sent
|lparam
, 0, 0 },
11371 { WM_MENUSELECT
, sent
|wparam
, MAKEWPARAM(0,MF_HILITE
|MF_POPUP
) },
11372 { WM_INITMENUPOPUP
, sent
|lparam
, 0, 0 },
11373 { WM_MENUSELECT
, sent
|wparam
|optional
, MAKEWPARAM(0,MF_HILITE
|MF_POPUP
) }, /* Win9x */
11374 { WM_INITMENUPOPUP
, sent
|lparam
|optional
, 0, 0 }, /* Win9x */
11375 { HCBT_CREATEWND
, hook
},
11376 { WM_MENUSELECT
, sent
}, /*|wparam, MAKEWPARAM(0,MF_HILITE|MF_POPUP) - XP
11377 |wparam, MAKEWPARAM(100,MF_HILITE) - Win9x */
11378 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'F', 0xf0000001 },
11379 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xd0000001 },
11380 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_RIGHT
, 0x10000001 },
11381 { WM_INITMENUPOPUP
, sent
|lparam
|optional
, 0, 0 }, /* Win9x doesn't send it */
11382 { HCBT_CREATEWND
, hook
|optional
}, /* Win9x doesn't send it */
11383 { WM_MENUSELECT
, sent
|wparam
|optional
, MAKEWPARAM(100,MF_HILITE
) },
11384 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_RIGHT
, 0xd0000001 },
11385 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_RETURN
, 0x10000001 },
11386 { HCBT_DESTROYWND
, hook
},
11387 { WM_UNINITMENUPOPUP
, sent
|lparam
, 0, 0 },
11388 { HCBT_DESTROYWND
, hook
|optional
}, /* Win9x doesn't send it */
11389 { WM_UNINITMENUPOPUP
, sent
|lparam
, 0, 0 },
11390 { WM_MENUSELECT
, sent
|wparam
|lparam
, MAKEWPARAM(0,0xffff), 0 },
11391 { WM_EXITMENULOOP
, sent
|wparam
|lparam
, 0, 0 },
11392 { WM_MENUCOMMAND
, sent
}, /* |wparam, 100 - Win9x */
11393 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_RETURN
, 0xc0000001 },
11394 { WM_KEYUP
, sent
|wparam
|lparam
, VK_RETURN
, 0xc0000001 },
11397 static const struct message wm_popup_menu_3
[] =
11399 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 },
11400 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
11401 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'F', 0x20000001 },
11402 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, 'F', 0x20000001 },
11403 { WM_SYSCHAR
, sent
|wparam
|lparam
, 'f', 0x20000001 },
11404 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_KEYMENU
, 'f' },
11405 { WM_ENTERMENULOOP
, sent
|wparam
|lparam
, 0, 0 },
11406 { WM_INITMENU
, sent
|lparam
, 0, 0 },
11407 { WM_MENUSELECT
, sent
|wparam
, MAKEWPARAM(0,MF_HILITE
|MF_POPUP
) },
11408 { WM_INITMENUPOPUP
, sent
|lparam
, 0, 0 },
11409 { WM_MENUSELECT
, sent
|wparam
|optional
, MAKEWPARAM(0,MF_HILITE
|MF_POPUP
) }, /* Win9x */
11410 { WM_INITMENUPOPUP
, sent
|lparam
|optional
, 0, 0 }, /* Win9x */
11411 { HCBT_CREATEWND
, hook
},
11412 { WM_MENUSELECT
, sent
}, /*|wparam, MAKEWPARAM(0,MF_HILITE|MF_POPUP) - XP
11413 |wparam, MAKEWPARAM(100,MF_HILITE) - Win9x */
11414 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'F', 0xf0000001 },
11415 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xd0000001 },
11416 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_RIGHT
, 0x10000001 },
11417 { WM_INITMENUPOPUP
, sent
|lparam
|optional
, 0, 0 }, /* Win9x doesn't send it */
11418 { HCBT_CREATEWND
, hook
|optional
}, /* Win9x doesn't send it */
11419 { WM_MENUSELECT
, sent
|wparam
|optional
, MAKEWPARAM(100,MF_HILITE
) },
11420 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_RIGHT
, 0xd0000001 },
11421 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_RETURN
, 0x10000001 },
11422 { HCBT_DESTROYWND
, hook
},
11423 { WM_UNINITMENUPOPUP
, sent
|lparam
, 0, 0 },
11424 { HCBT_DESTROYWND
, hook
|optional
}, /* Win9x doesn't send it */
11425 { WM_UNINITMENUPOPUP
, sent
|lparam
, 0, 0 },
11426 { WM_MENUSELECT
, sent
|wparam
|lparam
, MAKEWPARAM(0,0xffff), 0 },
11427 { WM_EXITMENULOOP
, sent
|wparam
|lparam
, 0, 0 },
11428 { WM_COMMAND
, sent
|wparam
|lparam
, 100, 0 },
11429 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_RETURN
, 0xc0000001 },
11430 { WM_KEYUP
, sent
|wparam
|lparam
, VK_RETURN
, 0xc0000001 },
11434 static LRESULT WINAPI
parent_menu_proc(HWND hwnd
, UINT message
, WPARAM wp
, LPARAM lp
)
11436 if (message
== WM_ENTERIDLE
||
11437 message
== WM_INITMENU
||
11438 message
== WM_INITMENUPOPUP
||
11439 message
== WM_MENUSELECT
||
11440 message
== WM_PARENTNOTIFY
||
11441 message
== WM_ENTERMENULOOP
||
11442 message
== WM_EXITMENULOOP
||
11443 message
== WM_UNINITMENUPOPUP
||
11444 message
== WM_KEYDOWN
||
11445 message
== WM_KEYUP
||
11446 message
== WM_CHAR
||
11447 message
== WM_SYSKEYDOWN
||
11448 message
== WM_SYSKEYUP
||
11449 message
== WM_SYSCHAR
||
11450 message
== WM_COMMAND
||
11451 message
== WM_MENUCOMMAND
)
11453 struct recvd_message msg
;
11456 msg
.message
= message
;
11457 msg
.flags
= sent
|wparam
|lparam
;
11460 msg
.descr
= "parent_menu_proc";
11464 return DefWindowProcA(hwnd
, message
, wp
, lp
);
11467 static void set_menu_style(HMENU hmenu
, DWORD style
)
11472 mi
.cbSize
= sizeof(mi
);
11473 mi
.fMask
= MIM_STYLE
;
11474 mi
.dwStyle
= style
;
11475 SetLastError(0xdeadbeef);
11476 ret
= pSetMenuInfo(hmenu
, &mi
);
11477 ok(ret
, "SetMenuInfo error %u\n", GetLastError());
11480 static DWORD
get_menu_style(HMENU hmenu
)
11485 mi
.cbSize
= sizeof(mi
);
11486 mi
.fMask
= MIM_STYLE
;
11488 SetLastError(0xdeadbeef);
11489 ret
= pGetMenuInfo(hmenu
, &mi
);
11490 ok(ret
, "GetMenuInfo error %u\n", GetLastError());
11495 static void test_menu_messages(void)
11499 HMENU hmenu
, hmenu_popup
;
11503 if (!pGetMenuInfo
|| !pSetMenuInfo
)
11505 win_skip("GetMenuInfo and/or SetMenuInfo are not available\n");
11509 cls
.lpfnWndProc
= parent_menu_proc
;
11510 cls
.cbClsExtra
= 0;
11511 cls
.cbWndExtra
= 0;
11512 cls
.hInstance
= GetModuleHandleA(0);
11514 cls
.hCursor
= LoadCursorA(0, IDC_ARROW
);
11515 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
11516 cls
.lpszMenuName
= NULL
;
11517 cls
.lpszClassName
= "TestMenuClass";
11518 UnregisterClass(cls
.lpszClassName
, cls
.hInstance
);
11519 if (!RegisterClassA(&cls
)) assert(0);
11521 SetLastError(0xdeadbeef);
11522 hwnd
= CreateWindowExA(0, "TestMenuClass", NULL
, WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
11523 100, 100, 200, 200, 0, 0, 0, NULL
);
11524 ok(hwnd
!= 0, "LoadMenuA error %u\n", GetLastError());
11526 SetLastError(0xdeadbeef);
11527 hmenu
= LoadMenuA(GetModuleHandle(0), MAKEINTRESOURCE(1));
11528 ok(hmenu
!= 0, "LoadMenuA error %u\n", GetLastError());
11530 SetMenu(hwnd
, hmenu
);
11531 SetForegroundWindow( hwnd
);
11533 set_menu_style(hmenu
, MNS_NOTIFYBYPOS
);
11534 style
= get_menu_style(hmenu
);
11535 ok(style
== MNS_NOTIFYBYPOS
, "expected MNS_NOTIFYBYPOS, got %u\n", style
);
11537 hmenu_popup
= GetSubMenu(hmenu
, 0);
11538 ok(hmenu_popup
!= 0, "GetSubMenu returned 0 for submenu 0\n");
11539 style
= get_menu_style(hmenu_popup
);
11540 ok(style
== 0, "expected 0, got %u\n", style
);
11542 hmenu_popup
= GetSubMenu(hmenu_popup
, 0);
11543 ok(hmenu_popup
!= 0, "GetSubMenu returned 0 for submenu 0\n");
11544 style
= get_menu_style(hmenu_popup
);
11545 ok(style
== 0, "expected 0, got %u\n", style
);
11548 trace("testing a popup menu command\n");
11550 keybd_event(VK_MENU
, 0, 0, 0);
11551 keybd_event('E', 0, 0, 0);
11552 keybd_event('E', 0, KEYEVENTF_KEYUP
, 0);
11553 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
11554 keybd_event(VK_RETURN
, 0, 0, 0);
11555 keybd_event(VK_RETURN
, 0, KEYEVENTF_KEYUP
, 0);
11556 while (PeekMessage(&msg
, 0, 0, 0, PM_REMOVE
))
11558 TranslateMessage(&msg
);
11559 DispatchMessage(&msg
);
11561 if (!sequence_cnt
) /* we didn't get any message */
11563 skip( "queuing key events not supported\n" );
11566 /* win98 queues only a WM_KEYUP and doesn't start menu tracking */
11567 if (sequence
[0].message
== WM_KEYUP
&& sequence
[0].wParam
== VK_MENU
)
11569 win_skip( "menu tracking through VK_MENU not supported\n" );
11572 ok_sequence(wm_popup_menu_1
, "popup menu command", FALSE
);
11574 /* Alt+F, Right, Enter */
11575 trace("testing submenu of a popup menu command\n");
11577 keybd_event(VK_MENU
, 0, 0, 0);
11578 keybd_event('F', 0, 0, 0);
11579 keybd_event('F', 0, KEYEVENTF_KEYUP
, 0);
11580 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
11581 keybd_event(VK_RIGHT
, 0, 0, 0);
11582 keybd_event(VK_RIGHT
, 0, KEYEVENTF_KEYUP
, 0);
11583 keybd_event(VK_RETURN
, 0, 0, 0);
11584 keybd_event(VK_RETURN
, 0, KEYEVENTF_KEYUP
, 0);
11585 while (PeekMessage(&msg
, 0, 0, 0, PM_REMOVE
))
11587 TranslateMessage(&msg
);
11588 DispatchMessage(&msg
);
11590 ok_sequence(wm_popup_menu_2
, "submenu of a popup menu command", FALSE
);
11592 set_menu_style(hmenu
, 0);
11593 style
= get_menu_style(hmenu
);
11594 ok(style
== 0, "expected 0, got %u\n", style
);
11596 hmenu_popup
= GetSubMenu(hmenu
, 0);
11597 ok(hmenu_popup
!= 0, "GetSubMenu returned 0 for submenu 0\n");
11598 set_menu_style(hmenu_popup
, MNS_NOTIFYBYPOS
);
11599 style
= get_menu_style(hmenu_popup
);
11600 ok(style
== MNS_NOTIFYBYPOS
, "expected MNS_NOTIFYBYPOS, got %u\n", style
);
11602 hmenu_popup
= GetSubMenu(hmenu_popup
, 0);
11603 ok(hmenu_popup
!= 0, "GetSubMenu returned 0 for submenu 0\n");
11604 style
= get_menu_style(hmenu_popup
);
11605 ok(style
== 0, "expected 0, got %u\n", style
);
11607 /* Alt+F, Right, Enter */
11608 trace("testing submenu of a popup menu command\n");
11610 keybd_event(VK_MENU
, 0, 0, 0);
11611 keybd_event('F', 0, 0, 0);
11612 keybd_event('F', 0, KEYEVENTF_KEYUP
, 0);
11613 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
11614 keybd_event(VK_RIGHT
, 0, 0, 0);
11615 keybd_event(VK_RIGHT
, 0, KEYEVENTF_KEYUP
, 0);
11616 keybd_event(VK_RETURN
, 0, 0, 0);
11617 keybd_event(VK_RETURN
, 0, KEYEVENTF_KEYUP
, 0);
11618 while (PeekMessage(&msg
, 0, 0, 0, PM_REMOVE
))
11620 TranslateMessage(&msg
);
11621 DispatchMessage(&msg
);
11623 ok_sequence(wm_popup_menu_3
, "submenu of a popup menu command", FALSE
);
11626 DestroyWindow(hwnd
);
11627 DestroyMenu(hmenu
);
11631 static void test_paintingloop(void)
11635 paint_loop_done
= 0;
11636 hwnd
= CreateWindowExA(0x0,"PaintLoopWindowClass",
11637 "PaintLoopWindowClass",WS_OVERLAPPEDWINDOW
,
11638 100, 100, 100, 100, 0, 0, 0, NULL
);
11639 ok(hwnd
!= 0, "PaintLoop window error %u\n", GetLastError());
11640 ShowWindow(hwnd
,SW_NORMAL
);
11643 while (!paint_loop_done
)
11646 if (PeekMessageA(&msg
, 0, 0, 0, 1))
11648 TranslateMessage(&msg
);
11649 DispatchMessage(&msg
);
11652 DestroyWindow(hwnd
);
11655 static void test_defwinproc(void)
11659 int gotwmquit
= FALSE
;
11660 hwnd
= CreateWindowExA(0, "static", "test_defwndproc", WS_POPUP
, 0,0,0,0,0,0,0, NULL
);
11662 DefWindowProcA( hwnd
, WM_ENDSESSION
, 1, 0);
11663 while (PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
)) {
11664 if( msg
.message
== WM_QUIT
) gotwmquit
= TRUE
;
11665 DispatchMessageA( &msg
);
11667 ok( gotwmquit
== FALSE
, "Unexpected WM_QUIT message!\n");
11668 DestroyWindow( hwnd
);
11671 static void test_PostMessage(void)
11673 static const struct
11679 { HWND_TOP
/* 0 */, TRUE
},
11680 { HWND_BROADCAST
, TRUE
},
11681 { HWND_BOTTOM
, TRUE
},
11682 { HWND_TOPMOST
, TRUE
},
11683 { HWND_NOTOPMOST
, FALSE
},
11684 { HWND_MESSAGE
, FALSE
},
11685 { (HWND
)0xdeadbeef, FALSE
}
11691 static const WCHAR staticW
[] = {'s','t','a','t','i','c',0};
11693 SetLastError(0xdeadbeef);
11694 hwnd
= CreateWindowExW(0, staticW
, NULL
, WS_POPUP
, 0,0,0,0,0,0,0, NULL
);
11695 if (!hwnd
&& GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
)
11697 win_skip("Skipping some PostMessage tests on Win9x/WinMe\n");
11704 PostMessage(hwnd
, WM_USER
+1, 0x1234, 0x5678);
11705 PostMessage(0, WM_USER
+2, 0x5678, 0x1234);
11707 for (i
= 0; i
< sizeof(data
)/sizeof(data
[0]); i
++)
11709 memset(&msg
, 0xab, sizeof(msg
));
11710 ret
= PeekMessageA(&msg
, data
[i
].hwnd
, 0, 0, PM_NOREMOVE
);
11711 ok(ret
== data
[i
].ret
, "%d: hwnd %p expected %d, got %d\n", i
, data
[i
].hwnd
, data
[i
].ret
, ret
);
11715 ok(ret
&& msg
.hwnd
== 0 && msg
.message
== WM_USER
+2 &&
11716 msg
.wParam
== 0x5678 && msg
.lParam
== 0x1234,
11717 "%d: got ret %d hwnd %p msg %04x wParam %08lx lParam %08lx instead of TRUE/0/WM_USER+2/0x5678/0x1234\n",
11718 i
, ret
, msg
.hwnd
, msg
.message
, msg
.wParam
, msg
.lParam
);
11720 ok(ret
&& msg
.hwnd
== hwnd
&& msg
.message
== WM_USER
+1 &&
11721 msg
.wParam
== 0x1234 && msg
.lParam
== 0x5678,
11722 "%d: got ret %d hwnd %p msg %04x wParam %08lx lParam %08lx instead of TRUE/%p/WM_USER+1/0x1234/0x5678\n",
11723 i
, ret
, msg
.hwnd
, msg
.message
, msg
.wParam
, msg
.lParam
, msg
.hwnd
);
11727 DestroyWindow(hwnd
);
11734 FARPROC pIsWinEventHookInstalled
= 0;/*GetProcAddress(user32, "IsWinEventHookInstalled");*/
11738 if (!RegisterWindowClasses()) assert(0);
11740 if (pSetWinEventHook
)
11742 hEvent_hook
= pSetWinEventHook(EVENT_MIN
, EVENT_MAX
,
11743 GetModuleHandleA(0), win_event_proc
,
11744 0, GetCurrentThreadId(),
11745 WINEVENT_INCONTEXT
);
11746 if (pIsWinEventHookInstalled
&& hEvent_hook
)
11749 for (event
= EVENT_MIN
; event
<= EVENT_MAX
; event
++)
11750 ok(pIsWinEventHookInstalled(event
), "IsWinEventHookInstalled(%u) failed\n", event
);
11753 if (!hEvent_hook
) win_skip( "no win event hook support\n" );
11755 cbt_hook_thread_id
= GetCurrentThreadId();
11756 hCBT_hook
= SetWindowsHookExA(WH_CBT
, cbt_hook_proc
, 0, GetCurrentThreadId());
11757 if (!hCBT_hook
) win_skip( "cannot set global hook, will skip hook tests\n" );
11761 /* Fix message sequences before removing 4 lines below */
11763 if (pUnhookWinEvent
&& hEvent_hook
)
11765 ret
= pUnhookWinEvent(hEvent_hook
);
11766 ok( ret
, "UnhookWinEvent error %d\n", GetLastError());
11767 pUnhookWinEvent
= 0;
11772 test_PostMessage();
11774 test_PeekMessage();
11775 test_PeekMessage2();
11776 test_scrollwindowex();
11778 test_setwindowpos();
11780 invisible_parent_tests();
11781 test_mdi_messages();
11782 test_button_messages();
11783 test_static_messages();
11784 test_listbox_messages();
11785 test_combobox_messages();
11786 test_wmime_keydown_message();
11787 test_paint_messages();
11788 test_interthread_messages();
11789 test_message_conversion();
11790 test_accelerators();
11792 test_timers_no_wnd();
11793 if (hCBT_hook
) test_set_hook();
11794 test_DestroyWindow();
11795 test_DispatchMessage();
11796 test_SendMessageTimeout();
11797 test_edit_messages();
11798 test_quit_message();
11799 test_SetActiveWindow();
11801 if (!pTrackMouseEvent
)
11802 win_skip("TrackMouseEvent is not available\n");
11804 test_TrackMouseEvent();
11806 test_SetWindowRgn();
11808 test_dialog_messages();
11809 test_nullCallback();
11810 test_dbcs_wm_char();
11811 test_menu_messages();
11812 test_paintingloop();
11814 /* keep it the last test, under Windows it tends to break the tests
11815 * which rely on active/foreground windows being correct.
11817 test_SetForegroundWindow();
11819 UnhookWindowsHookEx(hCBT_hook
);
11820 if (pUnhookWinEvent
&& hEvent_hook
)
11822 ret
= pUnhookWinEvent(hEvent_hook
);
11823 ok( ret
, "UnhookWinEvent error %d\n", GetLastError());
11824 SetLastError(0xdeadbeef);
11825 ok(!pUnhookWinEvent(hEvent_hook
), "UnhookWinEvent succeeded\n");
11826 ok(GetLastError() == ERROR_INVALID_HANDLE
|| /* Win2k */
11827 GetLastError() == 0xdeadbeef, /* Win9x */
11828 "unexpected error %d\n", GetLastError());