2 * Unit tests for window message handling
4 * Copyright 1999 Ove Kaaven
5 * Copyright 2003 Dimitrie O. Paun
6 * Copyright 2004, 2005 Dmitry Timoshkov
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #define _WIN32_WINNT 0x0600 /* For WM_CHANGEUISTATE,QS_RAWINPUT,WM_DWMxxxx */
24 #define WINVER 0x0600 /* for WM_GETTITLEBARINFOEX */
36 #include "wine/test.h"
38 #define MDI_FIRST_CHILD_ID 2004
40 /* undocumented SWP flags - from SDK 3.1 */
41 #define SWP_NOCLIENTSIZE 0x0800
42 #define SWP_NOCLIENTMOVE 0x1000
43 #define SWP_STATECHANGED 0x8000
45 #define SW_NORMALNA 0xCC /* undoc. flag in MinMaximize */
48 #define WM_KEYF1 0x004d
52 #define WM_SYSTIMER 0x0118
55 #define WND_PARENT_ID 1
56 #define WND_POPUP_ID 2
57 #define WND_CHILD_ID 3
59 #ifndef WM_LBTRACKPOINT
60 #define WM_LBTRACKPOINT 0x0131
63 /* encoded DRAWITEMSTRUCT into an LPARAM */
70 UINT type
: 4; /* ODT_* flags */
71 UINT ctl_id
: 4; /* Control ID */
72 UINT item_id
: 4; /* Menu item ID */
73 UINT action
: 4; /* ODA_* flags */
74 UINT state
: 16; /* ODS_* flags */
80 static BOOL test_DestroyWindow_flag
;
81 static HWINEVENTHOOK hEvent_hook
;
82 static HHOOK hCBT_hook
;
83 static DWORD cbt_hook_thread_id
;
85 static const WCHAR testWindowClassW
[] =
86 { 'T','e','s','t','W','i','n','d','o','w','C','l','a','s','s','W',0 };
89 FIXME: add tests for these
90 Window Edge Styles (Win31/Win95/98 look), in order of precedence:
91 WS_EX_DLGMODALFRAME: double border, WS_CAPTION allowed
92 WS_THICKFRAME: thick border
93 WS_DLGFRAME: double border, WS_CAPTION not allowed (but possibly shown anyway)
94 WS_BORDER (default for overlapped windows): single black border
95 none (default for child (and popup?) windows): no border
112 UINT message
; /* the WM_* code */
113 msg_flags_t flags
; /* message props */
114 WPARAM wParam
; /* expected value of wParam */
115 LPARAM lParam
; /* expected value of lParam */
116 WPARAM wp_mask
; /* mask for wParam checks */
117 LPARAM lp_mask
; /* mask for lParam checks */
120 struct recvd_message
{
121 UINT message
; /* the WM_* code */
122 msg_flags_t flags
; /* message props */
123 HWND hwnd
; /* window that received the message */
124 WPARAM wParam
; /* expected value of wParam */
125 LPARAM lParam
; /* expected value of lParam */
126 int line
; /* source line where logged */
127 const char *descr
; /* description for trace output */
128 char output
[512]; /* trace output */
131 /* Empty message sequence */
132 static const struct message WmEmptySeq
[] =
136 /* CreateWindow (for overlapped window, not initially visible) (16/32) */
137 static const struct message WmCreateOverlappedSeq
[] = {
138 { HCBT_CREATEWND
, hook
},
139 { WM_GETMINMAXINFO
, sent
},
140 { WM_NCCREATE
, sent
},
141 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
142 { 0x0093, sent
|defwinproc
|optional
},
143 { 0x0094, sent
|defwinproc
|optional
},
144 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
146 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
149 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
150 * for a not visible overlapped window.
152 static const struct message WmSWP_ShowOverlappedSeq
[] = {
153 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
154 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
155 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
156 { WM_GETTEXT
, sent
|defwinproc
|optional
},
157 { WM_ERASEBKGND
, sent
|optional
},
158 { HCBT_ACTIVATE
, hook
},
159 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
160 { WM_NOTIFYFORMAT
, sent
|optional
},
161 { WM_QUERYUISTATE
, sent
|optional
},
162 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
163 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* Win9x: SWP_NOSENDCHANGING */
164 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
165 { WM_NCACTIVATE
, sent
},
166 { WM_GETTEXT
, sent
|defwinproc
|optional
},
167 { WM_ACTIVATE
, sent
|wparam
, 1 },
168 { HCBT_SETFOCUS
, hook
},
169 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
170 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
171 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
172 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
173 { WM_GETTEXT
, sent
|optional
},
174 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
175 { WM_GETTEXT
, sent
|defwinproc
|optional
},
176 { WM_ERASEBKGND
, sent
|optional
},
177 /* Win9x adds SWP_NOZORDER below */
178 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
179 { WM_GETTEXT
, sent
|optional
},
180 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
181 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
182 { WM_ERASEBKGND
, sent
|optional
},
183 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
184 { WM_SYNCPAINT
, sent
|optional
},
185 { WM_GETTITLEBARINFOEX
, sent
|optional
},
186 { WM_PAINT
, sent
|optional
},
187 { WM_NCPAINT
, sent
|beginpaint
|optional
},
188 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
189 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
192 /* SetWindowPos(SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE)
193 * for a visible overlapped window.
195 static const struct message WmSWP_HideOverlappedSeq
[] = {
196 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
197 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
198 { HCBT_ACTIVATE
, hook
|optional
},
199 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
200 { WM_ACTIVATEAPP
, sent
|wparam
|optional
, 1 },
201 { WM_NCACTIVATE
, sent
|optional
},
202 { WM_ACTIVATE
, sent
|optional
},
203 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
207 /* SetWindowPos(SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOMOVE)
208 * for a visible overlapped window.
210 static const struct message WmSWP_ResizeSeq
[] = {
211 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
},
212 { WM_GETMINMAXINFO
, sent
|defwinproc
},
213 { WM_NCCALCSIZE
, sent
|wparam
|optional
, TRUE
},
214 { WM_NCPAINT
, sent
|optional
},
215 { WM_GETTEXT
, sent
|defwinproc
|optional
},
216 { WM_ERASEBKGND
, sent
|optional
},
217 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
},
218 { WM_SIZE
, sent
|defwinproc
|optional
},
219 { WM_NCCALCSIZE
, sent
|wparam
|optional
, TRUE
},
220 { WM_NCPAINT
, sent
|optional
},
221 { WM_GETTEXT
, sent
|defwinproc
|optional
},
222 { WM_ERASEBKGND
, sent
|optional
},
223 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
224 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* XP sends a duplicate */
228 /* SetWindowPos(SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOMOVE)
229 * for a visible popup window.
231 static const struct message WmSWP_ResizePopupSeq
[] = {
232 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
},
233 { WM_GETMINMAXINFO
, sent
|defwinproc
|optional
}, /* Win9x */
234 { WM_NCCALCSIZE
, sent
|wparam
|optional
, TRUE
},
235 { WM_NCPAINT
, sent
|optional
},
236 { WM_GETTEXT
, sent
|defwinproc
|optional
},
237 { WM_ERASEBKGND
, sent
|optional
},
238 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
},
239 { WM_SIZE
, sent
|defwinproc
|wparam
|optional
, SIZE_RESTORED
},
240 { WM_NCCALCSIZE
, sent
|wparam
|optional
, TRUE
},
241 { WM_NCPAINT
, sent
|optional
},
242 { WM_GETTEXT
, sent
|defwinproc
|optional
},
243 { WM_ERASEBKGND
, sent
|optional
},
244 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
248 /* SetWindowPos(SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOSIZE)
249 * for a visible overlapped window.
251 static const struct message WmSWP_MoveSeq
[] = {
252 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOSIZE
},
253 { WM_NCPAINT
, sent
|optional
},
254 { WM_GETTEXT
, sent
|defwinproc
|optional
},
255 { WM_ERASEBKGND
, sent
|optional
},
256 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOCLIENTSIZE
},
257 { WM_MOVE
, sent
|defwinproc
|wparam
, 0 },
258 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
261 /* Resize with SetWindowPos(SWP_NOZORDER)
262 * for a visible overlapped window
263 * SWP_NOZORDER is stripped by the logging code
265 static const struct message WmSWP_ResizeNoZOrder
[] = {
266 { WM_WINDOWPOSCHANGING
, sent
|wparam
, /*SWP_NOZORDER|*/SWP_NOACTIVATE
},
267 { WM_GETMINMAXINFO
, sent
|defwinproc
},
268 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
269 { WM_NCPAINT
, sent
|optional
},
270 { WM_GETTEXT
, sent
|defwinproc
|optional
},
271 { WM_ERASEBKGND
, sent
|optional
},
272 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, /*SWP_NOZORDER|*/SWP_NOACTIVATE
, 0,
273 SWP_NOMOVE
|SWP_NOCLIENTMOVE
|SWP_NOSIZE
|SWP_NOCLIENTSIZE
},
274 { WM_MOVE
, sent
|defwinproc
|optional
},
275 { WM_SIZE
, sent
|defwinproc
|optional
},
276 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 }, /* Win9x doesn't send it */
277 { WM_NCPAINT
, sent
|optional
}, /* Win9x doesn't send it */
278 { WM_GETTEXT
, sent
|defwinproc
|optional
}, /* Win9x doesn't send it */
279 { WM_ERASEBKGND
, sent
|optional
}, /* Win9x doesn't send it */
280 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
281 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
285 /* Switch visible mdi children */
286 static const struct message WmSwitchChild
[] = {
287 /* Switch MDI child */
288 { WM_MDIACTIVATE
, sent
},/* in the MDI client */
289 { WM_WINDOWPOSCHANGING
, sent
|wparam
,SWP_NOSIZE
|SWP_NOMOVE
},/* in the 1st MDI child */
290 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
291 { WM_CHILDACTIVATE
, sent
},/* in the 1st MDI child */
292 /* Deactivate 2nd MDI child */
293 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 0 }, /* in the 2nd MDI child */
294 { WM_MDIACTIVATE
, sent
|defwinproc
}, /* in the 2nd MDI child */
295 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
296 /* Preparing for maximize and maximaze the 1st MDI child */
297 { WM_GETMINMAXINFO
, sent
|defwinproc
}, /* in the 1st MDI child */
298 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_STATECHANGED
}, /* in the 1st MDI child */
299 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 }, /* in the 1st MDI child */
300 { WM_CHILDACTIVATE
, sent
|defwinproc
}, /* in the 1st MDI child */
301 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
}, /* in the 1st MDI child */
302 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
}, /* in the 1st MDI child */
303 /* Lock redraw 2nd MDI child */
304 { WM_SETREDRAW
, sent
|wparam
|defwinproc
, 0 }, /* in the 2nd MDI child */
305 { HCBT_MINMAX
, hook
|lparam
, 0, SW_NORMALNA
},
306 /* Restore 2nd MDI child */
307 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_STATECHANGED
},/* in the 2nd MDI child */
308 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 },/* in the 2nd MDI child */
309 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* in the 2nd MDI child */
310 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
}, /* in the 2nd MDI child */
311 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
}, /* in the 2nd MDI child */
312 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* in the 2nd MDI child */
313 /* Redraw 2nd MDI child */
314 { WM_SETREDRAW
, sent
|wparam
|defwinproc
, 1 },/* in the 2nd MDI child */
315 /* Redraw MDI frame */
316 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
},/* in MDI frame */
317 { WM_NCCALCSIZE
, sent
|wparam
, 1 },/* in MDI frame */
318 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
}, /* in MDI frame */
319 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* in MDI frame */
320 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* in the 1st MDI child */
321 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
}, /* in the 1st MDI child */
322 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 }, /* in the 1st MDI child */
323 { HCBT_SETFOCUS
, hook
},
324 { WM_KILLFOCUS
, sent
|defwinproc
}, /* in the 2nd MDI child */
325 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 0 },/* in the 1st MDI child */
326 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
327 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
328 { WM_SETFOCUS
, sent
},/* in the MDI client */
329 { HCBT_SETFOCUS
, hook
},
330 { WM_KILLFOCUS
, sent
},/* in the MDI client */
331 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
332 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 }, /* in the 1st MDI child */
333 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
334 { WM_SETFOCUS
, sent
|defwinproc
}, /* in the 1st MDI child */
335 { WM_MDIACTIVATE
, sent
|defwinproc
},/* in the 1st MDI child */
336 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
}, /* in the 1st MDI child */
340 /* Switch visible not maximized mdi children */
341 static const struct message WmSwitchNotMaximizedChild
[] = {
342 /* Switch not maximized MDI child */
343 { WM_MDIACTIVATE
, sent
},/* in the MDI client */
344 { WM_WINDOWPOSCHANGING
, sent
|wparam
,SWP_NOSIZE
|SWP_NOMOVE
},/* in the 2nd MDI child */
345 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
346 { WM_CHILDACTIVATE
, sent
},/* in the 2nd MDI child */
347 /* Deactivate 1st MDI child */
348 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 0 }, /* in the 1st MDI child */
349 { WM_MDIACTIVATE
, sent
|defwinproc
}, /* in the 1st MDI child */
350 /* Activate 2nd MDI child */
351 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
}, /* in the 2nd MDI child */
352 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 }, /* in the 2nd MDI child */
353 { HCBT_SETFOCUS
, hook
}, /* in the 1st MDI child */
354 { WM_KILLFOCUS
, sent
|defwinproc
}, /* in the 1st MDI child */
355 { WM_IME_SETCONTEXT
, sent
|defwinproc
|optional
}, /* in the 1st MDI child */
356 { WM_IME_SETCONTEXT
, sent
|optional
}, /* in the MDI client */
357 { WM_SETFOCUS
, sent
, 0 }, /* in the MDI client */
358 { HCBT_SETFOCUS
, hook
},
359 { WM_KILLFOCUS
, sent
}, /* in the MDI client */
360 { WM_IME_SETCONTEXT
, sent
|optional
}, /* in the MDI client */
361 { WM_IME_SETCONTEXT
, sent
|defwinproc
|optional
}, /* in the 1st MDI child */
362 { WM_SETFOCUS
, sent
|defwinproc
}, /* in the 2nd MDI child */
363 { WM_MDIACTIVATE
, sent
|defwinproc
}, /* in the 2nd MDI child */
364 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
}, /* in the 2nd MDI child */
369 /* SetWindowPos(SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|
370 SWP_NOZORDER|SWP_FRAMECHANGED)
371 * for a visible overlapped window with WS_CLIPCHILDREN style set.
373 static const struct message WmSWP_FrameChanged_clip
[] = {
374 { WM_WINDOWPOSCHANGING
, sent
|wparam
|parent
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
},
375 { WM_NCCALCSIZE
, sent
|wparam
|parent
, 1 },
376 { WM_NCPAINT
, sent
|parent
|optional
}, /* wparam != 1 */
377 { WM_GETTEXT
, sent
|parent
|defwinproc
|optional
},
378 { WM_ERASEBKGND
, sent
|parent
|optional
}, /* FIXME: remove optional once Wine is fixed */
379 { WM_NCPAINT
, sent
}, /* wparam != 1 */
380 { WM_ERASEBKGND
, sent
},
381 { WM_WINDOWPOSCHANGED
, sent
|wparam
|parent
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
382 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
386 /* SetWindowPos(SWP_NOSIZE|SWP_NOMOVE|SWP_DEFERERASE|SWP_NOACTIVATE|
387 SWP_NOZORDER|SWP_FRAMECHANGED)
388 * for a visible overlapped window.
390 static const struct message WmSWP_FrameChangedDeferErase
[] = {
391 { WM_WINDOWPOSCHANGING
, sent
|wparam
|parent
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_DEFERERASE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
},
392 { WM_NCCALCSIZE
, sent
|wparam
|parent
, 1 },
393 { WM_WINDOWPOSCHANGED
, sent
|wparam
|parent
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_DEFERERASE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
394 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
395 { WM_PAINT
, sent
|parent
|optional
},
396 { WM_NCPAINT
, sent
|beginpaint
|parent
|optional
}, /* wparam != 1 */
397 { WM_GETTEXT
, sent
|beginpaint
|parent
|defwinproc
|optional
},
399 { WM_NCPAINT
, sent
|beginpaint
}, /* wparam != 1 */
400 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
404 /* SetWindowPos(SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|
405 SWP_NOZORDER|SWP_FRAMECHANGED)
406 * for a visible overlapped window without WS_CLIPCHILDREN style set.
408 static const struct message WmSWP_FrameChanged_noclip
[] = {
409 { WM_WINDOWPOSCHANGING
, sent
|wparam
|parent
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
},
410 { WM_NCCALCSIZE
, sent
|wparam
|parent
, 1 },
411 { WM_NCPAINT
, sent
|parent
|optional
}, /* wparam != 1 */
412 { WM_GETTEXT
, sent
|parent
|defwinproc
|optional
},
413 { WM_ERASEBKGND
, sent
|parent
|optional
},
414 { WM_WINDOWPOSCHANGED
, sent
|wparam
|parent
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
415 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
417 { WM_NCPAINT
, sent
|beginpaint
}, /* wparam != 1 */
418 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
422 /* ShowWindow(SW_SHOW) for a not visible overlapped window */
423 static const struct message WmShowOverlappedSeq
[] = {
424 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
425 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
426 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
427 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
428 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
429 { WM_GETTEXT
, sent
|defwinproc
|optional
},
430 { WM_ERASEBKGND
, sent
|optional
},
431 { HCBT_ACTIVATE
, hook
},
432 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
433 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
434 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
435 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
436 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
437 { WM_NCACTIVATE
, sent
|wparam
, 1 },
438 { WM_GETTEXT
, sent
|defwinproc
|optional
},
439 { WM_ACTIVATE
, sent
|wparam
, 1 },
440 { HCBT_SETFOCUS
, hook
},
441 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
442 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
443 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
444 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
445 { WM_GETTEXT
, sent
|optional
},
446 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
447 { WM_GETTEXT
, sent
|defwinproc
|optional
},
448 { WM_ERASEBKGND
, sent
|optional
},
449 /* Win9x adds SWP_NOZORDER below */
450 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
451 { WM_NCCALCSIZE
, sent
|optional
},
452 { WM_GETTEXT
, sent
|optional
},
453 { WM_NCPAINT
, sent
|optional
},
454 { WM_ERASEBKGND
, sent
|optional
},
455 { WM_SYNCPAINT
, sent
|optional
},
456 #if 0 /* CreateWindow/ShowWindow(SW_SHOW) also generates WM_SIZE/WM_MOVE
457 * messages. Does that mean that CreateWindow doesn't set initial
458 * window dimensions for overlapped windows?
463 { WM_PAINT
, sent
|optional
},
464 { WM_NCPAINT
, sent
|beginpaint
|optional
},
467 /* ShowWindow(SW_SHOWMAXIMIZED) for a not visible overlapped window */
468 static const struct message WmShowMaxOverlappedSeq
[] = {
469 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
470 { WM_GETMINMAXINFO
, sent
},
471 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_STATECHANGED
},
472 { WM_GETMINMAXINFO
, sent
|defwinproc
},
473 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
474 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
475 { HCBT_ACTIVATE
, hook
},
476 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
477 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
478 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
479 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
480 { WM_NCACTIVATE
, sent
|wparam
, 1 },
481 { WM_GETTEXT
, sent
|defwinproc
|optional
},
482 { WM_ACTIVATE
, sent
|wparam
, 1 },
483 { HCBT_SETFOCUS
, hook
},
484 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
485 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
486 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
487 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
488 { WM_GETTEXT
, sent
|optional
},
489 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
490 { WM_GETTEXT
, sent
|defwinproc
|optional
},
491 { WM_ERASEBKGND
, sent
|optional
},
492 /* Win9x adds SWP_NOZORDER below */
493 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_STATECHANGED
},
494 { WM_MOVE
, sent
|defwinproc
},
495 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
496 { WM_GETTEXT
, sent
|optional
},
497 { WM_NCCALCSIZE
, sent
|optional
},
498 { WM_NCPAINT
, sent
|optional
},
499 { WM_ERASEBKGND
, sent
|optional
},
500 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
501 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
502 { WM_SYNCPAINT
, sent
|optional
},
503 { WM_GETTITLEBARINFOEX
, sent
|optional
},
504 { WM_PAINT
, sent
|optional
},
505 { WM_NCPAINT
, sent
|beginpaint
|optional
},
506 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
509 /* ShowWindow(SW_RESTORE) for a not visible maximized overlapped window */
510 static const struct message WmShowRestoreMaxOverlappedSeq
[] = {
511 { HCBT_MINMAX
, hook
|lparam
, 0, SW_RESTORE
},
512 { WM_GETTEXT
, sent
|optional
},
513 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
514 { WM_GETMINMAXINFO
, sent
|defwinproc
},
515 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
516 { WM_NCPAINT
, sent
|optional
},
517 { WM_GETTEXT
, sent
|defwinproc
|optional
},
518 { WM_ERASEBKGND
, sent
|optional
},
519 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
, 0, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOSIZE
|SWP_NOMOVE
},
520 { WM_MOVE
, sent
|defwinproc
|optional
},
521 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
522 { WM_NCCALCSIZE
, sent
|wparam
|optional
, TRUE
},
523 { WM_NCPAINT
, sent
|optional
},
524 { WM_ERASEBKGND
, sent
|optional
},
525 { WM_PAINT
, sent
|optional
},
526 { WM_GETTITLEBARINFOEX
, sent
|optional
},
527 { WM_NCPAINT
, sent
|beginpaint
|optional
},
528 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
531 /* ShowWindow(SW_RESTORE) for a not visible minimized overlapped window */
532 static const struct message WmShowRestoreMinOverlappedSeq
[] = {
533 { HCBT_MINMAX
, hook
|lparam
, 0, SW_RESTORE
},
534 { WM_QUERYOPEN
, sent
|optional
},
535 { WM_GETTEXT
, sent
|optional
},
536 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
|SWP_NOCOPYBITS
},
537 { WM_GETMINMAXINFO
, sent
|defwinproc
},
538 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
539 { HCBT_ACTIVATE
, hook
},
540 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
541 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
542 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
543 { WM_NCACTIVATE
, sent
|wparam
, 1 },
544 { WM_GETTEXT
, sent
|defwinproc
|optional
},
545 { WM_ACTIVATE
, sent
|wparam
, 1 },
546 { HCBT_SETFOCUS
, hook
},
547 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
548 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
549 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
550 { WM_GETTEXT
, sent
|optional
},
551 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
552 { WM_GETTEXT
, sent
|defwinproc
|optional
},
553 { WM_ERASEBKGND
, sent
},
554 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_STATECHANGED
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
},
555 { WM_MOVE
, sent
|defwinproc
},
556 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
557 { WM_NCCALCSIZE
, sent
|wparam
|optional
, TRUE
},
558 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
559 { WM_ERASEBKGND
, sent
|optional
},
560 { WM_ACTIVATE
, sent
|wparam
, 1 },
561 { WM_GETTEXT
, sent
|optional
},
562 { WM_PAINT
, sent
|optional
},
563 { WM_GETTITLEBARINFOEX
, sent
|optional
},
564 { WM_NCPAINT
, sent
|beginpaint
|optional
},
565 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
568 /* ShowWindow(SW_SHOWMINIMIZED) for a not visible overlapped window */
569 static const struct message WmShowMinOverlappedSeq
[] = {
570 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
571 { HCBT_SETFOCUS
, hook
},
572 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
573 { WM_KILLFOCUS
, sent
},
574 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
575 { WM_IME_NOTIFY
, sent
|wparam
|optional
|defwinproc
, 1 },
576 { WM_GETTEXT
, sent
|optional
},
577 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOCOPYBITS
|SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_STATECHANGED
},
578 { WM_GETMINMAXINFO
, sent
|defwinproc
},
579 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
580 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
581 { WM_NCPAINT
, sent
|optional
},
582 { WM_GETTEXT
, sent
|defwinproc
|optional
},
583 { WM_WINDOWPOSCHANGED
, sent
},
584 { WM_MOVE
, sent
|defwinproc
},
585 { WM_SIZE
, sent
|defwinproc
|wparam
|lparam
, SIZE_MINIMIZED
, 0 },
586 { WM_NCCALCSIZE
, sent
|optional
},
587 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
588 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
589 { EVENT_SYSTEM_MINIMIZESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
590 { WM_NCACTIVATE
, sent
|wparam
, 0 },
591 { WM_GETTEXT
, sent
|defwinproc
|optional
},
592 { WM_ACTIVATE
, sent
},
593 { WM_ACTIVATEAPP
, sent
|wparam
, 0 },
595 /* Vista sometimes restores the window right away... */
596 { WM_SYSCOMMAND
, sent
|optional
|wparam
, SC_RESTORE
},
597 { HCBT_SYSCOMMAND
, hook
|optional
|wparam
, SC_RESTORE
},
598 { HCBT_MINMAX
, hook
|optional
|lparam
, 0, SW_RESTORE
},
599 { WM_QUERYOPEN
, sent
|optional
},
600 { WM_WINDOWPOSCHANGING
, sent
|optional
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
601 { WM_GETMINMAXINFO
, sent
|optional
|defwinproc
},
602 { WM_NCCALCSIZE
, sent
|optional
|wparam
, TRUE
},
603 { HCBT_ACTIVATE
, hook
|optional
},
604 { WM_ACTIVATEAPP
, sent
|optional
|wparam
, 1 },
605 { WM_NCACTIVATE
, sent
|optional
},
606 { WM_GETTEXT
, sent
|optional
},
607 { WM_ACTIVATE
, sent
|optional
|wparam
, 1 },
608 { HCBT_SETFOCUS
, hook
|optional
},
609 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
610 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
611 { WM_SETFOCUS
, sent
|optional
},
612 { WM_NCPAINT
, sent
|optional
},
613 { WM_GETTEXT
, sent
|defwinproc
|optional
},
614 { WM_ERASEBKGND
, sent
|optional
},
615 { WM_WINDOWPOSCHANGED
, sent
|optional
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
616 { WM_MOVE
, sent
|defwinproc
|optional
},
617 { WM_SIZE
, sent
|defwinproc
|optional
|wparam
, SIZE_RESTORED
},
618 { WM_ACTIVATE
, sent
|optional
|wparam
, 1 },
619 { WM_SYSCOMMAND
, sent
|optional
|wparam
, SC_RESTORE
},
620 { HCBT_SYSCOMMAND
, hook
|optional
|wparam
, SC_RESTORE
},
622 { WM_PAINT
, sent
|optional
},
623 { WM_NCPAINT
, sent
|beginpaint
|optional
},
624 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
627 /* ShowWindow(SW_HIDE) for a visible overlapped window */
628 static const struct message WmHideOverlappedSeq
[] = {
629 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
630 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
631 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
632 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
633 { WM_SIZE
, sent
|optional
}, /* XP doesn't send it */
634 { WM_MOVE
, sent
|optional
}, /* XP doesn't send it */
635 { WM_NCACTIVATE
, sent
|wparam
|optional
, 0 },
636 { WM_ACTIVATE
, sent
|wparam
|optional
, 0 },
637 { WM_ACTIVATEAPP
, sent
|wparam
|optional
, 0 },
638 { HCBT_SETFOCUS
, hook
|optional
},
639 { WM_KILLFOCUS
, sent
|wparam
, 0 },
640 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
641 { WM_IME_NOTIFY
, sent
|wparam
|optional
|defwinproc
, 1 },
644 /* DestroyWindow for a visible overlapped window */
645 static const struct message WmDestroyOverlappedSeq
[] = {
646 { HCBT_DESTROYWND
, hook
},
647 { 0x0090, sent
|optional
},
648 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
649 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
650 { 0x0090, sent
|optional
},
651 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
652 { WM_NCACTIVATE
, sent
|optional
|wparam
, 0 },
653 { WM_ACTIVATE
, sent
|optional
},
654 { WM_ACTIVATEAPP
, sent
|optional
|wparam
, 0 },
655 { WM_KILLFOCUS
, sent
|optional
|wparam
, 0 },
656 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
657 { WM_IME_NOTIFY
, sent
|wparam
|optional
|defwinproc
, 1 },
658 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
659 { WM_DESTROY
, sent
},
660 { WM_NCDESTROY
, sent
},
663 /* CreateWindow(WS_MAXIMIZE|WS_VISIBLE) for popup window */
664 static const struct message WmCreateMaxPopupSeq
[] = {
665 { HCBT_CREATEWND
, hook
},
666 { WM_NCCREATE
, sent
},
667 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
669 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
670 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
672 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
673 { WM_GETMINMAXINFO
, sent
},
674 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_STATECHANGED
},
675 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
676 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOREDRAW
|SWP_STATECHANGED
},
677 { WM_MOVE
, sent
|defwinproc
},
678 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
679 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
680 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
681 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
682 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
683 { HCBT_ACTIVATE
, hook
},
684 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
685 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
686 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
687 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
688 { WM_ERASEBKGND
, sent
|optional
},
689 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOCLIENTMOVE
|SWP_NOCLIENTSIZE
|SWP_NOMOVE
|SWP_NOSIZE
},
690 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
691 { WM_NCACTIVATE
, sent
},
692 { WM_ACTIVATE
, sent
|wparam
, 1 },
693 { HCBT_SETFOCUS
, hook
},
694 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
695 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
696 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
697 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
698 { WM_GETTEXT
, sent
|optional
},
699 { WM_SYNCPAINT
, sent
|wparam
|optional
, 4 },
700 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
701 { WM_ERASEBKGND
, sent
|optional
},
702 { WM_NCPAINT
, sent
|wparam
|defwinproc
|optional
, 1 },
703 { WM_ERASEBKGND
, sent
|defwinproc
|optional
},
704 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOCLIENTMOVE
|SWP_NOCLIENTSIZE
|SWP_SHOWWINDOW
|SWP_NOMOVE
|SWP_NOSIZE
},
707 /* CreateWindow(WS_MAXIMIZE) for popup window, not initially visible */
708 static const struct message WmCreateInvisibleMaxPopupSeq
[] = {
709 { HCBT_CREATEWND
, hook
},
710 { WM_NCCREATE
, sent
},
711 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
713 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
714 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
716 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
717 { WM_GETMINMAXINFO
, sent
},
718 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_STATECHANGED
},
719 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
720 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOREDRAW
|SWP_STATECHANGED
},
721 { WM_MOVE
, sent
|defwinproc
},
722 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
723 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
726 /* ShowWindow(SW_SHOWMAXIMIZED) for a resized not visible popup window */
727 static const struct message WmShowMaxPopupResizedSeq
[] = {
728 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
729 { WM_GETMINMAXINFO
, sent
},
730 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
},
731 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
732 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
733 { HCBT_ACTIVATE
, hook
},
734 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
735 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
736 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
737 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
738 { WM_ERASEBKGND
, sent
|optional
},
739 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
740 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
741 { WM_NCACTIVATE
, sent
},
742 { WM_ACTIVATE
, sent
|wparam
, 1 },
743 { HCBT_SETFOCUS
, hook
},
744 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
745 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
746 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
747 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
748 { WM_GETTEXT
, sent
|optional
},
749 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
750 { WM_ERASEBKGND
, sent
|optional
},
751 { WM_WINDOWPOSCHANGED
, sent
},
752 /* WinNT4.0 sends WM_MOVE */
753 { WM_MOVE
, sent
|defwinproc
|optional
},
754 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
755 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
758 /* ShowWindow(SW_SHOWMAXIMIZED) for a not visible popup window */
759 static const struct message WmShowMaxPopupSeq
[] = {
760 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
761 { WM_GETMINMAXINFO
, sent
},
762 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
},
763 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
764 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
765 { HCBT_ACTIVATE
, hook
},
766 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
767 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
768 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
769 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
770 { WM_NCACTIVATE
, sent
},
771 { WM_ACTIVATE
, sent
|wparam
, 1 },
772 { HCBT_SETFOCUS
, hook
},
773 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
774 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
775 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
776 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
777 { WM_GETTEXT
, sent
|optional
},
778 { WM_SYNCPAINT
, sent
|wparam
|optional
, 4 },
779 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
780 { WM_ERASEBKGND
, sent
|optional
},
781 { WM_NCPAINT
, sent
|wparam
|defwinproc
|optional
, 1 },
782 { WM_ERASEBKGND
, sent
|defwinproc
|optional
},
783 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOMOVE
|SWP_NOSIZE
},
784 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
787 /* CreateWindow(WS_VISIBLE) for popup window */
788 static const struct message WmCreatePopupSeq
[] = {
789 { HCBT_CREATEWND
, hook
},
790 { WM_NCCREATE
, sent
},
791 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
793 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
794 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
796 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
797 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
798 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
799 { HCBT_ACTIVATE
, hook
},
800 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
801 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
802 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
803 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
804 { WM_ERASEBKGND
, sent
|optional
},
805 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
806 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
807 { WM_NCACTIVATE
, sent
},
808 { WM_ACTIVATE
, sent
|wparam
, 1 },
809 { HCBT_SETFOCUS
, hook
},
810 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
811 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
812 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
813 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
814 { WM_GETTEXT
, sent
|optional
},
815 { WM_SYNCPAINT
, sent
|wparam
|optional
, 4 },
816 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
817 { WM_ERASEBKGND
, sent
|optional
},
818 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOCLIENTMOVE
|SWP_NOCLIENTSIZE
|SWP_SHOWWINDOW
|SWP_NOMOVE
|SWP_NOSIZE
},
821 /* ShowWindow(SW_SHOWMAXIMIZED) for a visible popup window */
822 static const struct message WmShowVisMaxPopupSeq
[] = {
823 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
824 { WM_GETMINMAXINFO
, sent
},
825 { WM_GETTEXT
, sent
|optional
},
826 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
827 { WM_GETTEXT
, sent
|optional
},
828 { WM_NCCALCSIZE
, sent
|wparam
, TRUE
},
829 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
830 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
831 { WM_ERASEBKGND
, sent
|optional
},
832 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
833 { WM_MOVE
, sent
|defwinproc
},
834 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
835 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
838 /* CreateWindow (for a child popup window, not initially visible) */
839 static const struct message WmCreateChildPopupSeq
[] = {
840 { HCBT_CREATEWND
, hook
},
841 { WM_NCCREATE
, sent
},
842 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
844 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
845 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
849 /* CreateWindow (for a popup window, not initially visible,
850 * which sets WS_VISIBLE in WM_CREATE handler)
852 static const struct message WmCreateInvisiblePopupSeq
[] = {
853 { HCBT_CREATEWND
, hook
},
854 { WM_NCCREATE
, sent
},
855 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
857 { WM_STYLECHANGING
, sent
},
858 { WM_STYLECHANGED
, sent
},
859 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
860 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
864 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER)
865 * for a popup window with WS_VISIBLE style set
867 static const struct message WmShowVisiblePopupSeq_2
[] = {
868 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
871 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
872 * for a popup window with WS_VISIBLE style set
874 static const struct message WmShowVisiblePopupSeq_3
[] = {
875 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
876 { HCBT_ACTIVATE
, hook
},
877 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
878 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
879 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
880 { WM_NCACTIVATE
, sent
},
881 { WM_ACTIVATE
, sent
|wparam
, 1 },
882 { HCBT_SETFOCUS
, hook
},
883 { WM_KILLFOCUS
, sent
|parent
},
884 { WM_IME_SETCONTEXT
, sent
|parent
|wparam
|optional
, 0 },
885 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
886 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
887 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
888 { WM_SETFOCUS
, sent
|defwinproc
},
889 { WM_GETTEXT
, sent
|optional
},
890 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
, 0, SWP_SHOWWINDOW
},
893 /* CreateWindow (for child window, not initially visible) */
894 static const struct message WmCreateChildSeq
[] = {
895 { HCBT_CREATEWND
, hook
},
896 { WM_NCCREATE
, sent
},
897 /* child is inserted into parent's child list after WM_NCCREATE returns */
898 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
900 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
901 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
903 { WM_PARENTNOTIFY
, sent
|parent
|wparam
, WM_CREATE
},
906 /* CreateWindow (for maximized child window, not initially visible) */
907 static const struct message WmCreateMaximizedChildSeq
[] = {
908 { HCBT_CREATEWND
, hook
},
909 { WM_NCCREATE
, sent
},
910 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
912 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
913 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
915 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
916 { WM_GETMINMAXINFO
, sent
},
917 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_STATECHANGED
},
918 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
919 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
920 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
921 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
922 { WM_PARENTNOTIFY
, sent
|parent
|wparam
, WM_CREATE
},
925 /* CreateWindow (for a child window, initially visible) */
926 static const struct message WmCreateVisibleChildSeq
[] = {
927 { HCBT_CREATEWND
, hook
},
928 { WM_NCCREATE
, sent
},
929 /* child is inserted into parent's child list after WM_NCCREATE returns */
930 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
931 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
933 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
934 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
936 { WM_PARENTNOTIFY
, sent
|parent
|wparam
, WM_CREATE
},
937 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
938 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
939 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
940 { WM_ERASEBKGND
, sent
|parent
|optional
},
941 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
942 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 }, /* WinXP */
943 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
946 /* ShowWindow(SW_SHOW) for a not visible child window */
947 static const struct message WmShowChildSeq
[] = {
948 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
949 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
950 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
951 { WM_ERASEBKGND
, sent
|parent
|optional
},
952 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
955 /* ShowWindow(SW_HIDE) for a visible child window */
956 static const struct message WmHideChildSeq
[] = {
957 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
958 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
959 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
960 { WM_ERASEBKGND
, sent
|parent
|optional
},
961 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
964 /* ShowWindow(SW_HIDE) for a visible child window checking all parent events*/
965 static const struct message WmHideChildSeq2
[] = {
966 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
967 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
968 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
969 { WM_ERASEBKGND
, sent
|parent
|optional
},
970 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
973 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
974 * for a not visible child window
976 static const struct message WmShowChildSeq_2
[] = {
977 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
978 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
979 { WM_CHILDACTIVATE
, sent
},
980 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
983 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE)
984 * for a not visible child window
986 static const struct message WmShowChildSeq_3
[] = {
987 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
988 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
989 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
992 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
993 * for a visible child window with a caption
995 static const struct message WmShowChildSeq_4
[] = {
996 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
997 { WM_CHILDACTIVATE
, sent
},
1000 /* ShowWindow(SW_MINIMIZE) for child with invisible parent */
1001 static const struct message WmShowChildInvisibleParentSeq_1
[] = {
1002 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
1003 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
, 0, SWP_NOACTIVATE
},
1004 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1005 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1006 { WM_CHILDACTIVATE
, sent
|optional
},
1007 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOREDRAW
|SWP_NOCOPYBITS
|SWP_STATECHANGED
, 0, SWP_NOACTIVATE
},
1008 { WM_MOVE
, sent
|defwinproc
},
1009 { WM_SIZE
, sent
|defwinproc
|wparam
|lparam
, SIZE_MINIMIZED
, 0 },
1010 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1011 { EVENT_SYSTEM_MINIMIZESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
1012 /* FIXME: Wine creates an icon/title window while Windows doesn't */
1013 { WM_PARENTNOTIFY
, sent
|parent
|wparam
|optional
, WM_CREATE
},
1014 { WM_GETTEXT
, sent
|optional
},
1017 /* repeated ShowWindow(SW_MINIMIZE) for child with invisible parent */
1018 static const struct message WmShowChildInvisibleParentSeq_1r
[] = {
1019 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
1022 /* ShowWindow(SW_MAXIMIZE) for child with invisible parent */
1023 static const struct message WmShowChildInvisibleParentSeq_2
[] = {
1024 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
1025 { WM_GETMINMAXINFO
, sent
},
1026 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_STATECHANGED
},
1027 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1028 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1029 { WM_CHILDACTIVATE
, sent
},
1030 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
1031 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
1032 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1035 /* repeated ShowWindow(SW_MAXIMIZE) for child with invisible parent */
1036 static const struct message WmShowChildInvisibleParentSeq_2r
[] = {
1037 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
1040 /* ShowWindow(SW_SHOWMINIMIZED) for child with invisible parent */
1041 static const struct message WmShowChildInvisibleParentSeq_3
[] = {
1042 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINIMIZED
},
1043 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
1044 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1045 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1046 { WM_CHILDACTIVATE
, sent
},
1047 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOREDRAW
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
1048 { WM_MOVE
, sent
|defwinproc
},
1049 { WM_SIZE
, sent
|defwinproc
|wparam
|lparam
, SIZE_MINIMIZED
, 0 },
1050 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1051 { EVENT_SYSTEM_MINIMIZESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
1052 /* FIXME: Wine creates an icon/title window while Windows doesn't */
1053 { WM_PARENTNOTIFY
, sent
|parent
|wparam
|optional
, WM_CREATE
},
1054 { WM_GETTEXT
, sent
|optional
},
1057 /* repeated ShowWindow(SW_SHOWMINIMIZED) for child with invisible parent */
1058 static const struct message WmShowChildInvisibleParentSeq_3r
[] = {
1059 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINIMIZED
},
1062 /* ShowWindow(SW_SHOWMINNOACTIVE) for child with invisible parent */
1063 static const struct message WmShowChildInvisibleParentSeq_4
[] = {
1064 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINNOACTIVE
},
1065 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
1066 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1067 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1068 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOREDRAW
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
1069 { WM_MOVE
, sent
|defwinproc
},
1070 { WM_SIZE
, sent
|defwinproc
|wparam
|lparam
, SIZE_MINIMIZED
, 0 },
1071 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1072 { EVENT_SYSTEM_MINIMIZESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
1073 /* FIXME: Wine creates an icon/title window while Windows doesn't */
1074 { WM_PARENTNOTIFY
, sent
|parent
|wparam
|optional
, WM_CREATE
},
1075 { WM_GETTEXT
, sent
|optional
},
1078 /* repeated ShowWindow(SW_SHOWMINNOACTIVE) for child with invisible parent */
1079 static const struct message WmShowChildInvisibleParentSeq_4r
[] = {
1080 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINNOACTIVE
},
1083 /* ShowWindow(SW_SHOW) for child with invisible parent */
1084 static const struct message WmShowChildInvisibleParentSeq_5
[] = {
1085 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1088 /* ShowWindow(SW_HIDE) for child with invisible parent */
1089 static const struct message WmHideChildInvisibleParentSeq
[] = {
1090 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
1093 /* SetWindowPos(SWP_SHOWWINDOW) for child with invisible parent */
1094 static const struct message WmShowChildInvisibleParentSeq_6
[] = {
1095 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
1096 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1097 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1100 /* SetWindowPos(SWP_HIDEWINDOW) for child with invisible parent */
1101 static const struct message WmHideChildInvisibleParentSeq_2
[] = {
1102 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1103 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1104 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1107 /* DestroyWindow for a visible child window */
1108 static const struct message WmDestroyChildSeq
[] = {
1109 { HCBT_DESTROYWND
, hook
},
1110 { 0x0090, sent
|optional
},
1111 { WM_PARENTNOTIFY
, sent
|parent
|wparam
, WM_DESTROY
},
1112 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
1113 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1114 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1115 { WM_ERASEBKGND
, sent
|parent
|optional
},
1116 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1117 { HCBT_SETFOCUS
, hook
}, /* set focus to a parent */
1118 { WM_KILLFOCUS
, sent
},
1119 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
1120 { WM_IME_SETCONTEXT
, sent
|wparam
|parent
|optional
, 1 },
1121 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1122 { WM_SETFOCUS
, sent
|parent
},
1123 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
1124 { WM_DESTROY
, sent
},
1125 { WM_DESTROY
, sent
|optional
}, /* some other (IME?) window */
1126 { WM_NCDESTROY
, sent
|optional
}, /* some other (IME?) window */
1127 { WM_NCDESTROY
, sent
},
1130 /* visible child window destroyed by thread exit */
1131 static const struct message WmExitThreadSeq
[] = {
1132 { WM_NCDESTROY
, sent
}, /* actually in grandchild */
1133 { WM_PAINT
, sent
|parent
},
1134 { WM_ERASEBKGND
, sent
|parent
|beginpaint
},
1137 /* DestroyWindow for a visible child window with invisible parent */
1138 static const struct message WmDestroyInvisibleChildSeq
[] = {
1139 { HCBT_DESTROYWND
, hook
},
1140 { 0x0090, sent
|optional
},
1141 { WM_PARENTNOTIFY
, sent
|parent
|wparam
, WM_DESTROY
},
1142 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
1143 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
1144 { WM_DESTROY
, sent
},
1145 { WM_NCDESTROY
, sent
},
1148 /* Moving the mouse in nonclient area */
1149 static const struct message WmMouseMoveInNonClientAreaSeq
[] = { /* FIXME: add */
1150 { WM_NCHITTEST
, sent
},
1151 { WM_SETCURSOR
, sent
},
1152 { WM_NCMOUSEMOVE
, posted
},
1155 /* Moving the mouse in client area */
1156 static const struct message WmMouseMoveInClientAreaSeq
[] = { /* FIXME: add */
1157 { WM_NCHITTEST
, sent
},
1158 { WM_SETCURSOR
, sent
},
1159 { WM_MOUSEMOVE
, posted
},
1162 /* Moving by dragging the title bar (after WM_NCHITTEST and WM_SETCURSOR) (outline move) */
1163 static const struct message WmDragTitleBarSeq
[] = { /* FIXME: add */
1164 { WM_NCLBUTTONDOWN
, sent
|wparam
, HTCAPTION
},
1165 { WM_SYSCOMMAND
, sent
|defwinproc
|wparam
, SC_MOVE
+2 },
1166 { WM_GETMINMAXINFO
, sent
|defwinproc
},
1167 { WM_ENTERSIZEMOVE
, sent
|defwinproc
},
1168 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, 0 },
1169 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, 0 },
1170 { WM_MOVE
, sent
|defwinproc
},
1171 { WM_EXITSIZEMOVE
, sent
|defwinproc
},
1174 /* Sizing by dragging the thick borders (after WM_NCHITTEST and WM_SETCURSOR) (outline move) */
1175 static const struct message WmDragThickBordersBarSeq
[] = { /* FIXME: add */
1176 { WM_NCLBUTTONDOWN
, sent
|wparam
, 0xd },
1177 { WM_SYSCOMMAND
, sent
|defwinproc
|wparam
, 0xf004 },
1178 { WM_GETMINMAXINFO
, sent
|defwinproc
},
1179 { WM_ENTERSIZEMOVE
, sent
|defwinproc
},
1180 { WM_SIZING
, sent
|defwinproc
|wparam
, 4}, /* one for each mouse movement */
1181 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, 0 },
1182 { WM_GETMINMAXINFO
, sent
|defwinproc
},
1183 { WM_NCCALCSIZE
, sent
|defwinproc
|wparam
, 1 },
1184 { WM_NCPAINT
, sent
|defwinproc
|wparam
, 1 },
1185 { WM_GETTEXT
, sent
|defwinproc
},
1186 { WM_ERASEBKGND
, sent
|defwinproc
},
1187 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, 0 },
1188 { WM_MOVE
, sent
|defwinproc
},
1189 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
1190 { WM_EXITSIZEMOVE
, sent
|defwinproc
},
1193 /* Resizing child window with MoveWindow (32) */
1194 static const struct message WmResizingChildWithMoveWindowSeq
[] = {
1195 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
1196 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1197 { WM_ERASEBKGND
, sent
|parent
|optional
},
1198 { WM_ERASEBKGND
, sent
|optional
},
1199 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
},
1200 { WM_MOVE
, sent
|defwinproc
},
1201 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
1202 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1205 /* Clicking on inactive button */
1206 static const struct message WmClickInactiveButtonSeq
[] = { /* FIXME: add */
1207 { WM_NCHITTEST
, sent
},
1208 { WM_PARENTNOTIFY
, sent
|parent
|wparam
, WM_LBUTTONDOWN
},
1209 { WM_MOUSEACTIVATE
, sent
},
1210 { WM_MOUSEACTIVATE
, sent
|parent
|defwinproc
},
1211 { WM_SETCURSOR
, sent
},
1212 { WM_SETCURSOR
, sent
|parent
|defwinproc
},
1213 { WM_LBUTTONDOWN
, posted
},
1214 { WM_KILLFOCUS
, posted
|parent
},
1215 { WM_SETFOCUS
, posted
},
1216 { WM_CTLCOLORBTN
, posted
|parent
},
1217 { BM_SETSTATE
, posted
},
1218 { WM_CTLCOLORBTN
, posted
|parent
},
1219 { WM_LBUTTONUP
, posted
},
1220 { BM_SETSTATE
, posted
},
1221 { WM_CTLCOLORBTN
, posted
|parent
},
1222 { WM_COMMAND
, posted
|parent
},
1225 /* Reparenting a button (16/32) */
1226 /* The last child (button) reparented gets topmost for its new parent. */
1227 static const struct message WmReparentButtonSeq
[] = { /* FIXME: add */
1228 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
1229 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOSIZE
},
1230 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1231 { WM_ERASEBKGND
, sent
|parent
},
1232 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOSIZE
},
1233 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
},
1234 { WM_CHILDACTIVATE
, sent
},
1235 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOSIZE
|SWP_NOREDRAW
},
1236 { WM_MOVE
, sent
|defwinproc
},
1237 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1240 /* Creation of a custom dialog (32) */
1241 static const struct message WmCreateCustomDialogSeq
[] = {
1242 { HCBT_CREATEWND
, hook
},
1243 { WM_GETMINMAXINFO
, sent
},
1244 { WM_NCCREATE
, sent
},
1245 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
1246 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
1247 { WM_CREATE
, sent
},
1248 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1249 { WM_NOTIFYFORMAT
, sent
|optional
},
1250 { WM_QUERYUISTATE
, sent
|optional
},
1251 { WM_WINDOWPOSCHANGING
, sent
|optional
},
1252 { WM_GETMINMAXINFO
, sent
|optional
},
1253 { WM_NCCALCSIZE
, sent
|optional
},
1254 { WM_WINDOWPOSCHANGED
, sent
|optional
},
1255 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1256 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
1257 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1258 { HCBT_ACTIVATE
, hook
},
1259 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
1262 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
1264 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
1266 { WM_NCACTIVATE
, sent
},
1267 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1268 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1269 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1270 { EVENT_OBJECT_DEFACTIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, OBJID_CLIENT
, 0 },
1271 { WM_ACTIVATE
, sent
|wparam
, 1 },
1272 { WM_GETTEXT
, sent
|optional
},
1273 { WM_KILLFOCUS
, sent
|parent
},
1274 { WM_IME_SETCONTEXT
, sent
|parent
|wparam
|optional
, 0 },
1275 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
1276 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
1277 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1278 { WM_SETFOCUS
, sent
},
1279 { WM_GETDLGCODE
, sent
|defwinproc
|wparam
, 0 },
1280 { WM_NCPAINT
, sent
|wparam
, 1 },
1281 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1282 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1283 { WM_ERASEBKGND
, sent
},
1284 { WM_CTLCOLORDLG
, sent
|optional
|defwinproc
},
1285 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1286 { WM_GETTEXT
, sent
|optional
},
1287 { WM_GETTEXT
, sent
|optional
},
1288 { WM_NCCALCSIZE
, sent
|optional
},
1289 { WM_NCPAINT
, sent
|optional
},
1290 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1291 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1292 { WM_ERASEBKGND
, sent
|optional
},
1293 { WM_CTLCOLORDLG
, sent
|optional
|defwinproc
},
1294 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1295 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
1299 /* Calling EndDialog for a custom dialog (32) */
1300 static const struct message WmEndCustomDialogSeq
[] = {
1301 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1302 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1303 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1304 { WM_GETTEXT
, sent
|optional
},
1305 { HCBT_ACTIVATE
, hook
},
1306 { WM_NCACTIVATE
, sent
|wparam
, 0 },
1307 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1308 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1309 { WM_ACTIVATE
, sent
|wparam
, 0 },
1310 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
1311 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1312 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOACTIVATE
|SWP_NOREDRAW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1313 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1314 { WM_GETTEXT
, sent
|optional
|defwinproc
},
1315 { HCBT_SETFOCUS
, hook
},
1316 { WM_KILLFOCUS
, sent
},
1317 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
1318 { WM_IME_SETCONTEXT
, sent
|parent
|wparam
|defwinproc
|optional
, 1 },
1319 { WM_IME_NOTIFY
, sent
|wparam
|optional
, 1 },
1320 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1321 { WM_SETFOCUS
, sent
|parent
|defwinproc
},
1324 /* ShowWindow(SW_SHOW) for a custom dialog (initially invisible) */
1325 static const struct message WmShowCustomDialogSeq
[] = {
1326 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1327 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
1328 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1329 { HCBT_ACTIVATE
, hook
},
1330 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
1332 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
1334 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
1335 { WM_ACTIVATEAPP
, sent
|wparam
|optional
, 1 },
1336 { WM_NCACTIVATE
, sent
},
1337 { WM_ACTIVATE
, sent
|wparam
, 1 },
1338 { WM_GETTEXT
, sent
|optional
},
1340 { WM_KILLFOCUS
, sent
|parent
},
1341 { WM_IME_SETCONTEXT
, sent
|parent
|wparam
|optional
, 0 },
1342 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
1343 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
1344 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1345 { WM_SETFOCUS
, sent
},
1346 { WM_GETDLGCODE
, sent
|defwinproc
|wparam
, 0 },
1347 { WM_NCPAINT
, sent
|wparam
, 1 },
1348 { WM_ERASEBKGND
, sent
},
1349 { WM_CTLCOLORDLG
, sent
|defwinproc
},
1350 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1353 /* Creation and destruction of a modal dialog (32) */
1354 static const struct message WmModalDialogSeq
[] = {
1355 { WM_CANCELMODE
, sent
|parent
},
1356 { HCBT_SETFOCUS
, hook
},
1357 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1358 { WM_KILLFOCUS
, sent
|parent
},
1359 { WM_IME_SETCONTEXT
, sent
|parent
|wparam
|optional
, 0 },
1360 { EVENT_OBJECT_STATECHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1361 { WM_ENABLE
, sent
|parent
|wparam
, 0 },
1362 { HCBT_CREATEWND
, hook
},
1363 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
1364 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1365 { WM_SETFONT
, sent
},
1366 { WM_INITDIALOG
, sent
},
1367 { WM_CHANGEUISTATE
, sent
|optional
},
1368 { WM_UPDATEUISTATE
, sent
|optional
},
1369 { WM_SHOWWINDOW
, sent
},
1370 { HCBT_ACTIVATE
, hook
},
1371 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
1372 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
1373 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
},
1374 { WM_NCACTIVATE
, sent
},
1375 { WM_GETTEXT
, sent
|optional
},
1376 { WM_ACTIVATE
, sent
|wparam
, 1 },
1377 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
1378 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1379 { WM_NCPAINT
, sent
|optional
},
1380 { WM_GETTEXT
, sent
|optional
},
1381 { WM_ERASEBKGND
, sent
|optional
},
1382 { WM_CTLCOLORDLG
, sent
|optional
},
1383 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1384 { WM_GETTEXT
, sent
|optional
},
1385 { WM_NCCALCSIZE
, sent
|optional
},
1386 { WM_NCPAINT
, sent
|optional
},
1387 { WM_GETTEXT
, sent
|optional
},
1388 { WM_ERASEBKGND
, sent
|optional
},
1389 { WM_CTLCOLORDLG
, sent
|optional
},
1390 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1391 { WM_PAINT
, sent
|optional
},
1392 { WM_CTLCOLORBTN
, sent
|optional
},
1393 { WM_GETTITLEBARINFOEX
, sent
|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
},
1412 { WM_ENTERIDLE
, sent
|parent
|optional
},
1413 { WM_ENTERIDLE
, sent
|parent
|optional
},
1415 { EVENT_OBJECT_STATECHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1416 { WM_ENABLE
, sent
|parent
|wparam
, 1 },
1417 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
1418 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1419 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1420 { WM_GETTEXT
, sent
|optional
},
1421 { HCBT_ACTIVATE
, hook
},
1422 { WM_NCACTIVATE
, sent
|wparam
, 0 },
1423 { WM_GETTEXT
, sent
|optional
},
1424 { WM_ACTIVATE
, sent
|wparam
, 0 },
1425 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
1426 { WM_WINDOWPOSCHANGING
, sent
|optional
},
1427 { WM_WINDOWPOSCHANGED
, sent
|optional
},
1428 { HCBT_SETFOCUS
, hook
},
1429 { WM_IME_SETCONTEXT
, sent
|parent
|wparam
|defwinproc
|optional
, 1 },
1430 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
1431 { WM_SETFOCUS
, sent
|parent
|defwinproc
},
1432 { EVENT_SYSTEM_DIALOGEND
, winevent_hook
|wparam
|lparam
, 0, 0 },
1433 { HCBT_DESTROYWND
, hook
},
1434 { 0x0090, sent
|optional
},
1435 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
1436 { WM_DESTROY
, sent
},
1437 { WM_NCDESTROY
, sent
},
1440 /* Creation of a modal dialog that is resized inside WM_INITDIALOG (32) */
1441 static const struct message WmCreateModalDialogResizeSeq
[] = { /* FIXME: add */
1442 /* (inside dialog proc, handling WM_INITDIALOG) */
1443 { WM_WINDOWPOSCHANGING
, sent
|wparam
, 0 },
1444 { WM_NCCALCSIZE
, sent
},
1445 { WM_NCACTIVATE
, sent
|parent
|wparam
, 0 },
1446 { WM_GETTEXT
, sent
|defwinproc
},
1447 { WM_ACTIVATE
, sent
|parent
|wparam
, 0 },
1448 { WM_WINDOWPOSCHANGING
, sent
|wparam
, 0 },
1449 { WM_WINDOWPOSCHANGING
, sent
|parent
},
1450 { WM_NCACTIVATE
, sent
|wparam
, 1 },
1451 { WM_ACTIVATE
, sent
|wparam
, 1 },
1452 { WM_WINDOWPOSCHANGED
, sent
|wparam
, 0 },
1453 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
1454 /* (setting focus) */
1455 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1456 { WM_WINDOWPOSCHANGING
, sent
|wparam
, 0 },
1457 { WM_NCPAINT
, sent
},
1458 { WM_GETTEXT
, sent
|defwinproc
},
1459 { WM_ERASEBKGND
, sent
},
1460 { WM_CTLCOLORDLG
, sent
|defwinproc
},
1461 { WM_WINDOWPOSCHANGED
, sent
|wparam
, 0 },
1463 /* (bunch of WM_CTLCOLOR* for each control) */
1464 { WM_PAINT
, sent
|parent
},
1465 { WM_ENTERIDLE
, sent
|parent
|wparam
, 0 },
1466 { WM_SETCURSOR
, sent
|parent
},
1469 /* SetMenu for NonVisible windows with size change*/
1470 static const struct message WmSetMenuNonVisibleSizeChangeSeq
[] = {
1471 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1472 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1473 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
1474 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
},
1475 { WM_MOVE
, sent
|defwinproc
},
1476 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
1477 { WM_NCCALCSIZE
,sent
|wparam
|optional
, 1 }, /* XP */
1478 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1479 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* XP sends a duplicate */
1480 { WM_GETTEXT
, sent
|optional
},
1481 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
1484 /* SetMenu for NonVisible windows with no size change */
1485 static const struct message WmSetMenuNonVisibleNoSizeChangeSeq
[] = {
1486 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1487 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1488 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1489 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1492 /* SetMenu for Visible windows with size change */
1493 static const struct message WmSetMenuVisibleSizeChangeSeq
[] = {
1494 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1495 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1496 { 0x0093, sent
|defwinproc
|optional
},
1497 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
1498 { WM_NCPAINT
, sent
|optional
}, /* wparam != 1 */
1499 { 0x0093, sent
|defwinproc
|optional
},
1500 { 0x0093, sent
|defwinproc
|optional
},
1501 { 0x0091, sent
|defwinproc
|optional
},
1502 { 0x0092, sent
|defwinproc
|optional
},
1503 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1504 { WM_ERASEBKGND
, sent
|optional
},
1505 { WM_ACTIVATE
, sent
|optional
},
1506 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1507 { WM_MOVE
, sent
|defwinproc
},
1508 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
1509 { 0x0093, sent
|optional
},
1510 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
1511 { 0x0093, sent
|defwinproc
|optional
},
1512 { WM_NCPAINT
, sent
|optional
}, /* wparam != 1 */
1513 { 0x0093, sent
|defwinproc
|optional
},
1514 { 0x0093, sent
|defwinproc
|optional
},
1515 { 0x0091, sent
|defwinproc
|optional
},
1516 { 0x0092, sent
|defwinproc
|optional
},
1517 { WM_ERASEBKGND
, sent
|optional
},
1518 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1519 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* XP sends a duplicate */
1522 /* SetMenu for Visible windows with no size change */
1523 static const struct message WmSetMenuVisibleNoSizeChangeSeq
[] = {
1524 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1525 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1526 { WM_NCPAINT
, sent
|optional
}, /* wparam != 1 */
1527 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1528 { WM_ERASEBKGND
, sent
|optional
},
1529 { WM_ACTIVATE
, sent
|optional
},
1530 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1531 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1534 /* DrawMenuBar for a visible window */
1535 static const struct message WmDrawMenuBarSeq
[] =
1537 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1538 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1539 { 0x0093, sent
|defwinproc
|optional
},
1540 { WM_NCPAINT
, sent
|optional
}, /* wparam != 1 */
1541 { 0x0093, sent
|defwinproc
|optional
},
1542 { 0x0093, sent
|defwinproc
|optional
},
1543 { 0x0091, sent
|defwinproc
|optional
},
1544 { 0x0092, sent
|defwinproc
|optional
},
1545 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1546 { WM_ERASEBKGND
, sent
|optional
},
1547 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1548 { 0x0093, sent
|optional
},
1549 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1553 static const struct message WmSetRedrawFalseSeq
[] =
1555 { WM_SETREDRAW
, sent
|wparam
, 0 },
1559 static const struct message WmSetRedrawTrueSeq
[] =
1561 { WM_SETREDRAW
, sent
|wparam
, 1 },
1565 static const struct message WmEnableWindowSeq_1
[] =
1567 { WM_CANCELMODE
, sent
|wparam
|lparam
, 0, 0 },
1568 { EVENT_OBJECT_STATECHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1569 { HCBT_SETFOCUS
, hook
|optional
},
1570 { WM_KILLFOCUS
, sent
|optional
},
1571 { WM_ENABLE
, sent
|wparam
|lparam
, FALSE
, 0 },
1575 static const struct message WmEnableWindowSeq_2
[] =
1577 { EVENT_OBJECT_STATECHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1578 { WM_ENABLE
, sent
|wparam
|lparam
, TRUE
, 0 },
1582 static const struct message WmGetScrollRangeSeq
[] =
1584 { SBM_GETRANGE
, sent
},
1587 static const struct message WmGetScrollInfoSeq
[] =
1589 { SBM_GETSCROLLINFO
, sent
},
1592 static const struct message WmSetScrollRangeSeq
[] =
1594 /* MSDN claims that Windows sends SBM_SETRANGE message, but win2k SP4
1595 sends SBM_SETSCROLLINFO.
1597 { SBM_SETSCROLLINFO
, sent
},
1600 /* SetScrollRange for a window without a non-client area */
1601 static const struct message WmSetScrollRangeHSeq_empty
[] =
1603 { EVENT_OBJECT_VALUECHANGE
, winevent_hook
|wparam
|lparam
, OBJID_HSCROLL
, 0 },
1606 static const struct message WmSetScrollRangeVSeq_empty
[] =
1608 { EVENT_OBJECT_VALUECHANGE
, winevent_hook
|wparam
|lparam
, OBJID_VSCROLL
, 0 },
1611 static const struct message WmSetScrollRangeHVSeq
[] =
1613 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOSIZE
},
1614 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1615 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1616 { WM_ERASEBKGND
, sent
|optional
},
1617 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1618 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1619 { EVENT_OBJECT_VALUECHANGE
, winevent_hook
|lparam
|optional
, 0/*OBJID_HSCROLL or OBJID_VSCROLL*/, 0 },
1622 /* SetScrollRange for a window with a non-client area */
1623 static const struct message WmSetScrollRangeHV_NC_Seq
[] =
1625 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOSIZE
},
1626 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
1627 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
1628 { WM_NCPAINT
, sent
|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_STYLECHANGING
, sent
|defwinproc
|optional
},
1636 { WM_STYLECHANGED
, sent
|defwinproc
|optional
},
1637 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1638 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1639 { WM_ERASEBKGND
, sent
|optional
},
1640 { WM_CTLCOLORDLG
, sent
|defwinproc
|optional
}, /* sent to a parent of the dialog */
1641 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOCLIENTMOVE
, 0, SWP_NOCLIENTSIZE
},
1642 { WM_SIZE
, sent
|defwinproc
|optional
},
1643 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1644 { EVENT_OBJECT_VALUECHANGE
, winevent_hook
|lparam
|optional
, 0/*OBJID_HSCROLL or OBJID_VSCROLL*/, 0 },
1645 { WM_GETTEXT
, sent
|optional
},
1646 { WM_GETTEXT
, sent
|optional
},
1647 { WM_GETTEXT
, sent
|optional
},
1648 { WM_GETTEXT
, sent
|optional
},
1651 /* test if we receive the right sequence of messages */
1652 /* after calling ShowWindow( SW_SHOWNA) */
1653 static const struct message WmSHOWNAChildInvisParInvis
[] = {
1654 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1657 static const struct message WmSHOWNAChildVisParInvis
[] = {
1658 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1661 static const struct message WmSHOWNAChildVisParVis
[] = {
1662 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1663 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
1666 static const struct message WmSHOWNAChildInvisParVis
[] = {
1667 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1668 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1669 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1670 { WM_ERASEBKGND
, sent
|optional
},
1671 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOACTIVATE
|SWP_NOCLIENTMOVE
},
1674 static const struct message WmSHOWNATopVisible
[] = {
1675 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1676 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
1677 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
1678 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1679 { WM_ERASEBKGND
, sent
|optional
},
1680 { WM_WINDOWPOSCHANGED
, sent
|optional
},
1683 static const struct message WmSHOWNATopInvisible
[] = {
1684 { WM_NOTIFYFORMAT
, sent
|optional
},
1685 { WM_QUERYUISTATE
, sent
|optional
},
1686 { WM_WINDOWPOSCHANGING
, sent
|optional
},
1687 { WM_GETMINMAXINFO
, sent
|optional
},
1688 { WM_NCCALCSIZE
, sent
|optional
},
1689 { WM_WINDOWPOSCHANGED
, sent
|optional
},
1690 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
1691 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
1692 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
1693 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
1694 { WM_GETTEXT
, sent
|defwinproc
|optional
},
1695 { WM_ERASEBKGND
, sent
|optional
},
1696 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
1697 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
1698 { WM_NCPAINT
, sent
|wparam
|optional
, 1 },
1699 { WM_ERASEBKGND
, sent
|optional
},
1700 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
1701 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
1706 static int after_end_dialog
, test_def_id
;
1707 static int sequence_cnt
, sequence_size
;
1708 static struct recvd_message
* sequence
;
1709 static int log_all_parent_messages
;
1710 static int paint_loop_done
;
1712 /* user32 functions */
1713 static HWND (WINAPI
*pGetAncestor
)(HWND
,UINT
);
1714 static BOOL (WINAPI
*pGetMenuInfo
)(HMENU
,LPCMENUINFO
);
1715 static void (WINAPI
*pNotifyWinEvent
)(DWORD
, HWND
, LONG
, LONG
);
1716 static BOOL (WINAPI
*pSetMenuInfo
)(HMENU
,LPCMENUINFO
);
1717 static HWINEVENTHOOK (WINAPI
*pSetWinEventHook
)(DWORD
, DWORD
, HMODULE
, WINEVENTPROC
, DWORD
, DWORD
, DWORD
);
1718 static BOOL (WINAPI
*pTrackMouseEvent
)(TRACKMOUSEEVENT
*);
1719 static BOOL (WINAPI
*pUnhookWinEvent
)(HWINEVENTHOOK
);
1720 /* kernel32 functions */
1721 static BOOL (WINAPI
*pGetCPInfoExA
)(UINT
, DWORD
, LPCPINFOEXA
);
1723 static void init_procs(void)
1725 HMODULE user32
= GetModuleHandleA("user32.dll");
1726 HMODULE kernel32
= GetModuleHandleA("kernel32.dll");
1728 #define GET_PROC(dll, func) \
1729 p ## func = (void*)GetProcAddress(dll, #func); \
1731 trace("GetProcAddress(%s) failed\n", #func); \
1734 GET_PROC(user32
, GetAncestor
)
1735 GET_PROC(user32
, GetMenuInfo
)
1736 GET_PROC(user32
, NotifyWinEvent
)
1737 GET_PROC(user32
, SetMenuInfo
)
1738 GET_PROC(user32
, SetWinEventHook
)
1739 GET_PROC(user32
, TrackMouseEvent
)
1740 GET_PROC(user32
, UnhookWinEvent
)
1742 GET_PROC(kernel32
, GetCPInfoExA
)
1747 static const char *get_winpos_flags(UINT flags
)
1749 static char buffer
[300];
1752 #define DUMP(flag) do { if (flags & flag) { strcat( buffer, "|" #flag ); flags &= ~flag; } } while(0)
1753 DUMP( SWP_SHOWWINDOW
);
1754 DUMP( SWP_HIDEWINDOW
);
1755 DUMP( SWP_NOACTIVATE
);
1756 DUMP( SWP_FRAMECHANGED
);
1757 DUMP( SWP_NOCOPYBITS
);
1758 DUMP( SWP_NOOWNERZORDER
);
1759 DUMP( SWP_NOSENDCHANGING
);
1760 DUMP( SWP_DEFERERASE
);
1761 DUMP( SWP_ASYNCWINDOWPOS
);
1762 DUMP( SWP_NOZORDER
);
1763 DUMP( SWP_NOREDRAW
);
1766 DUMP( SWP_NOCLIENTSIZE
);
1767 DUMP( SWP_NOCLIENTMOVE
);
1768 if (flags
) sprintf(buffer
+ strlen(buffer
),"|0x%04x", flags
);
1773 static BOOL
ignore_message( UINT message
)
1775 /* these are always ignored */
1776 return (message
>= 0xc000 ||
1777 message
== WM_GETICON
||
1778 message
== WM_GETOBJECT
||
1779 message
== WM_TIMECHANGE
||
1780 message
== WM_DISPLAYCHANGE
||
1781 message
== WM_DEVICECHANGE
||
1782 message
== WM_DWMNCRENDERINGCHANGED
);
1786 #define add_message(msg) add_message_(__LINE__,msg);
1787 static void add_message_(int line
, const struct recvd_message
*msg
)
1789 struct recvd_message
*seq
;
1794 sequence
= HeapAlloc( GetProcessHeap(), 0, sequence_size
* sizeof(*sequence
) );
1796 if (sequence_cnt
== sequence_size
)
1799 sequence
= HeapReAlloc( GetProcessHeap(), 0, sequence
, sequence_size
* sizeof(*sequence
) );
1803 seq
= &sequence
[sequence_cnt
];
1804 seq
->hwnd
= msg
->hwnd
;
1805 seq
->message
= msg
->message
;
1806 seq
->flags
= msg
->flags
;
1807 seq
->wParam
= msg
->wParam
;
1808 seq
->lParam
= msg
->lParam
;
1810 seq
->descr
= msg
->descr
;
1815 if (msg
->flags
& hook
)
1817 static const char * const CBT_code_name
[10] =
1825 "HCBT_CLICKSKIPPED",
1830 const char *code_name
= (msg
->message
<= HCBT_SETFOCUS
) ? CBT_code_name
[msg
->message
] : "Unknown";
1832 sprintf( seq
->output
, "%s: hook %d (%s) wp %08lx lp %08lx",
1833 msg
->descr
, msg
->message
, code_name
, msg
->wParam
, msg
->lParam
);
1835 else if (msg
->flags
& winevent_hook
)
1837 sprintf( seq
->output
, "%s: winevent %p %08x %08lx %08lx",
1838 msg
->descr
, msg
->hwnd
, msg
->message
, msg
->wParam
, msg
->lParam
);
1842 switch (msg
->message
)
1844 case WM_WINDOWPOSCHANGING
:
1845 case WM_WINDOWPOSCHANGED
:
1847 WINDOWPOS
*winpos
= (WINDOWPOS
*)msg
->lParam
;
1849 sprintf( seq
->output
, "%s: %p WM_WINDOWPOS%s wp %08lx lp %08lx after %p x %d y %d cx %d cy %d flags %s",
1850 msg
->descr
, msg
->hwnd
,
1851 (msg
->message
== WM_WINDOWPOSCHANGING
) ? "CHANGING" : "CHANGED",
1852 msg
->wParam
, msg
->lParam
, winpos
->hwndInsertAfter
,
1853 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
,
1854 get_winpos_flags(winpos
->flags
) );
1856 /* Log only documented flags, win2k uses 0x1000 and 0x2000
1857 * in the high word for internal purposes
1859 seq
->wParam
= winpos
->flags
& 0xffff;
1860 /* We are not interested in the flags that don't match under XP and Win9x */
1861 seq
->wParam
&= ~SWP_NOZORDER
;
1867 DRAW_ITEM_STRUCT di
;
1868 DRAWITEMSTRUCT
*dis
= (DRAWITEMSTRUCT
*)msg
->lParam
;
1870 sprintf( seq
->output
, "%s: %p WM_DRAWITEM: type %x, ctl_id %x, item_id %x, action %x, state %x",
1871 msg
->descr
, msg
->hwnd
, dis
->CtlType
, dis
->CtlID
,
1872 dis
->itemID
, dis
->itemAction
, dis
->itemState
);
1875 di
.u
.item
.type
= dis
->CtlType
;
1876 di
.u
.item
.ctl_id
= dis
->CtlID
;
1877 if (dis
->CtlType
== ODT_LISTBOX
||
1878 dis
->CtlType
== ODT_COMBOBOX
||
1879 dis
->CtlType
== ODT_MENU
)
1880 di
.u
.item
.item_id
= dis
->itemID
;
1881 di
.u
.item
.action
= dis
->itemAction
;
1882 di
.u
.item
.state
= dis
->itemState
;
1884 seq
->lParam
= di
.u
.lp
;
1888 if (msg
->message
>= 0xc000) return; /* ignore registered messages */
1889 sprintf( seq
->output
, "%s: %p %04x wp %08lx lp %08lx",
1890 msg
->descr
, msg
->hwnd
, msg
->message
, msg
->wParam
, msg
->lParam
);
1892 if (msg
->flags
& (sent
|posted
|parent
|defwinproc
|beginpaint
))
1893 sprintf( seq
->output
+ strlen(seq
->output
), " (flags %x)", msg
->flags
);
1900 /* try to make sure pending X events have been processed before continuing */
1901 static void flush_events(void)
1905 int min_timeout
= 100;
1906 DWORD time
= GetTickCount() + diff
;
1910 if (MsgWaitForMultipleObjects( 0, NULL
, FALSE
, min_timeout
, QS_ALLINPUT
) == WAIT_TIMEOUT
) break;
1911 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
1912 diff
= time
- GetTickCount();
1916 static void flush_sequence(void)
1918 HeapFree(GetProcessHeap(), 0, sequence
);
1920 sequence_cnt
= sequence_size
= 0;
1923 static void dump_sequence(const struct message
*expected
, const char *context
, const char *file
, int line
)
1925 const struct recvd_message
*actual
= sequence
;
1926 unsigned int count
= 0;
1928 trace_(file
, line
)("Failed sequence %s:\n", context
);
1929 while (expected
->message
&& actual
->message
)
1931 if (actual
->output
[0])
1933 if (expected
->flags
& hook
)
1935 trace_(file
, line
)( " %u: expected: hook %04x - actual: %s\n",
1936 count
, expected
->message
, actual
->output
);
1938 else if (expected
->flags
& winevent_hook
)
1940 trace_(file
, line
)( " %u: expected: winevent %04x - actual: %s\n",
1941 count
, expected
->message
, actual
->output
);
1945 trace_(file
, line
)( " %u: expected: msg %04x - actual: %s\n",
1946 count
, expected
->message
, actual
->output
);
1950 if (expected
->message
== actual
->message
)
1952 if ((expected
->flags
& defwinproc
) != (actual
->flags
& defwinproc
) &&
1953 (expected
->flags
& optional
))
1955 /* don't match messages if their defwinproc status differs */
1964 /* silently drop winevent messages if there is no support for them */
1965 else if ((expected
->flags
& optional
) || ((expected
->flags
& winevent_hook
) && !hEvent_hook
))
1975 /* optional trailing messages */
1976 while (expected
->message
&& ((expected
->flags
& optional
) ||
1977 ((expected
->flags
& winevent_hook
) && !hEvent_hook
)))
1979 trace_(file
, line
)( " %u: expected: msg %04x - actual: nothing\n", count
, expected
->message
);
1984 if (expected
->message
)
1986 trace_(file
, line
)( " %u: expected: msg %04x - actual: nothing\n", count
, expected
->message
);
1990 while (actual
->message
&& actual
->output
[0])
1992 trace_(file
, line
)( " %u: expected: nothing - actual: %s\n", count
, actual
->output
);
1998 #define ok_sequence( exp, contx, todo) \
1999 ok_sequence_( (exp), (contx), (todo), __FILE__, __LINE__)
2002 static void ok_sequence_(const struct message
*expected_list
, const char *context
, int todo
,
2003 const char *file
, int line
)
2005 static const struct recvd_message end_of_sequence
;
2006 const struct message
*expected
= expected_list
;
2007 const struct recvd_message
*actual
;
2008 int failcount
= 0, dump
= 0;
2009 unsigned int count
= 0;
2011 add_message(&end_of_sequence
);
2015 while (expected
->message
&& actual
->message
)
2017 if (expected
->message
== actual
->message
)
2019 if (expected
->flags
& wparam
)
2021 if (((expected
->wParam
^ actual
->wParam
) & ~expected
->wp_mask
) && todo
)
2025 if (strcmp(winetest_platform
, "wine")) dump
++;
2026 ok_( file
, line
) (FALSE
,
2027 "%s: %u: in msg 0x%04x expecting wParam 0x%lx got 0x%lx\n",
2028 context
, count
, expected
->message
, expected
->wParam
, actual
->wParam
);
2033 ok_( file
, line
)( ((expected
->wParam
^ actual
->wParam
) & ~expected
->wp_mask
) == 0,
2034 "%s: %u: in msg 0x%04x expecting wParam 0x%lx got 0x%lx\n",
2035 context
, count
, expected
->message
, expected
->wParam
, actual
->wParam
);
2036 if ((expected
->wParam
^ actual
->wParam
) & ~expected
->wp_mask
) dump
++;
2040 if (expected
->flags
& lparam
)
2042 if (((expected
->lParam
^ actual
->lParam
) & ~expected
->lp_mask
) && todo
)
2046 if (strcmp(winetest_platform
, "wine")) dump
++;
2047 ok_( file
, line
) (FALSE
,
2048 "%s: %u: in msg 0x%04x expecting lParam 0x%lx got 0x%lx\n",
2049 context
, count
, expected
->message
, expected
->lParam
, actual
->lParam
);
2054 ok_( file
, line
)(((expected
->lParam
^ actual
->lParam
) & ~expected
->lp_mask
) == 0,
2055 "%s: %u: in msg 0x%04x expecting lParam 0x%lx got 0x%lx\n",
2056 context
, count
, expected
->message
, expected
->lParam
, actual
->lParam
);
2057 if ((expected
->lParam
^ actual
->lParam
) & ~expected
->lp_mask
) dump
++;
2060 if ((expected
->flags
& optional
) &&
2061 ((expected
->flags
^ actual
->flags
) & (defwinproc
|parent
)))
2063 /* don't match optional messages if their defwinproc or parent status differs */
2068 if ((expected
->flags
& defwinproc
) != (actual
->flags
& defwinproc
) && todo
)
2072 if (strcmp(winetest_platform
, "wine")) dump
++;
2073 ok_( file
, line
) (FALSE
,
2074 "%s: %u: the msg 0x%04x should %shave been sent by DefWindowProc\n",
2075 context
, count
, expected
->message
, (expected
->flags
& defwinproc
) ? "" : "NOT ");
2080 ok_( file
, line
) ((expected
->flags
& defwinproc
) == (actual
->flags
& defwinproc
),
2081 "%s: %u: the msg 0x%04x should %shave been sent by DefWindowProc\n",
2082 context
, count
, expected
->message
, (expected
->flags
& defwinproc
) ? "" : "NOT ");
2083 if ((expected
->flags
& defwinproc
) != (actual
->flags
& defwinproc
)) dump
++;
2086 ok_( file
, line
) ((expected
->flags
& beginpaint
) == (actual
->flags
& beginpaint
),
2087 "%s: %u: the msg 0x%04x should %shave been sent by BeginPaint\n",
2088 context
, count
, expected
->message
, (expected
->flags
& beginpaint
) ? "" : "NOT ");
2089 if ((expected
->flags
& beginpaint
) != (actual
->flags
& beginpaint
)) dump
++;
2091 ok_( file
, line
) ((expected
->flags
& (sent
|posted
)) == (actual
->flags
& (sent
|posted
)),
2092 "%s: %u: the msg 0x%04x should have been %s\n",
2093 context
, count
, expected
->message
, (expected
->flags
& posted
) ? "posted" : "sent");
2094 if ((expected
->flags
& (sent
|posted
)) != (actual
->flags
& (sent
|posted
))) dump
++;
2096 ok_( file
, line
) ((expected
->flags
& parent
) == (actual
->flags
& parent
),
2097 "%s: %u: the msg 0x%04x was expected in %s\n",
2098 context
, count
, expected
->message
, (expected
->flags
& parent
) ? "parent" : "child");
2099 if ((expected
->flags
& parent
) != (actual
->flags
& parent
)) dump
++;
2101 ok_( file
, line
) ((expected
->flags
& hook
) == (actual
->flags
& hook
),
2102 "%s: %u: the msg 0x%04x should have been sent by a hook\n",
2103 context
, count
, expected
->message
);
2104 if ((expected
->flags
& hook
) != (actual
->flags
& hook
)) dump
++;
2106 ok_( file
, line
) ((expected
->flags
& winevent_hook
) == (actual
->flags
& winevent_hook
),
2107 "%s: %u: the msg 0x%04x should have been sent by a winevent hook\n",
2108 context
, count
, expected
->message
);
2109 if ((expected
->flags
& winevent_hook
) != (actual
->flags
& winevent_hook
)) dump
++;
2114 /* silently drop hook messages if there is no support for them */
2115 else if ((expected
->flags
& optional
) ||
2116 ((expected
->flags
& hook
) && !hCBT_hook
) ||
2117 ((expected
->flags
& winevent_hook
) && !hEvent_hook
))
2123 if (strcmp(winetest_platform
, "wine")) dump
++;
2124 ok_( file
, line
) (FALSE
, "%s: %u: the msg 0x%04x was expected, but got msg 0x%04x instead\n",
2125 context
, count
, expected
->message
, actual
->message
);
2131 ok_( file
, line
) (FALSE
, "%s: %u: the msg 0x%04x was expected, but got msg 0x%04x instead\n",
2132 context
, count
, expected
->message
, actual
->message
);
2140 /* skip all optional trailing messages */
2141 while (expected
->message
&& ((expected
->flags
& optional
) ||
2142 ((expected
->flags
& hook
) && !hCBT_hook
) ||
2143 ((expected
->flags
& winevent_hook
) && !hEvent_hook
)))
2149 if (expected
->message
|| actual
->message
) {
2151 if (strcmp(winetest_platform
, "wine")) dump
++;
2152 ok_( file
, line
) (FALSE
, "%s: %u: the msg sequence is not complete: expected %04x - actual %04x\n",
2153 context
, count
, expected
->message
, actual
->message
);
2159 if (expected
->message
|| actual
->message
)
2162 ok_( file
, line
) (FALSE
, "%s: %u: the msg sequence is not complete: expected %04x - actual %04x\n",
2163 context
, count
, expected
->message
, actual
->message
);
2166 if( todo
&& !failcount
) /* succeeded yet marked todo */
2168 if (!strcmp(winetest_platform
, "wine")) dump
++;
2169 ok_( file
, line
)( TRUE
, "%s: marked \"todo_wine\" but succeeds\n", context
);
2173 if (dump
) dump_sequence(expected_list
, context
, file
, line
);
2177 #define expect(EXPECTED,GOT) ok((GOT)==(EXPECTED), "Expected %d, got %d\n", (EXPECTED), (GOT))
2179 /******************************** MDI test **********************************/
2181 /* CreateWindow for MDI frame window, initially visible */
2182 static const struct message WmCreateMDIframeSeq
[] = {
2183 { HCBT_CREATEWND
, hook
},
2184 { WM_GETMINMAXINFO
, sent
},
2185 { WM_NCCREATE
, sent
},
2186 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
2187 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
2188 { WM_CREATE
, sent
},
2189 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2190 { WM_NOTIFYFORMAT
, sent
|optional
},
2191 { WM_QUERYUISTATE
, sent
|optional
},
2192 { WM_WINDOWPOSCHANGING
, sent
|optional
},
2193 { WM_GETMINMAXINFO
, sent
|optional
},
2194 { WM_NCCALCSIZE
, sent
|optional
},
2195 { WM_WINDOWPOSCHANGED
, sent
|optional
},
2196 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
2197 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
2198 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2199 { HCBT_ACTIVATE
, hook
},
2200 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, 0, 0 },
2201 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
2202 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* XP */
2203 { WM_ACTIVATEAPP
, sent
|wparam
|optional
, 1 }, /* Win9x doesn't send it */
2204 { WM_NCACTIVATE
, sent
},
2205 { WM_GETTEXT
, sent
|defwinproc
|optional
},
2206 { WM_ACTIVATE
, sent
|wparam
, 1 },
2207 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* Win9x */
2208 { HCBT_SETFOCUS
, hook
},
2209 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
2210 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
2211 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2212 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
2213 /* Win9x adds SWP_NOZORDER below */
2214 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2215 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 }, /* XP */
2216 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2217 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2221 /* DestroyWindow for MDI frame window, initially visible */
2222 static const struct message WmDestroyMDIframeSeq
[] = {
2223 { HCBT_DESTROYWND
, hook
},
2224 { 0x0090, sent
|optional
},
2225 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2226 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2227 { WM_NCACTIVATE
, sent
|wparam
|optional
, 0 }, /* Win9x */
2228 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2229 { WM_NCACTIVATE
, sent
|wparam
|optional
, 0 }, /* XP */
2230 { WM_ACTIVATE
, sent
|wparam
|optional
, 0 }, /* Win9x */
2231 { WM_ACTIVATEAPP
, sent
|wparam
|optional
, 0 }, /* Win9x */
2232 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
2233 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
2234 { WM_DESTROY
, sent
},
2235 { WM_NCDESTROY
, sent
},
2238 /* CreateWindow for MDI client window, initially visible */
2239 static const struct message WmCreateMDIclientSeq
[] = {
2240 { HCBT_CREATEWND
, hook
},
2241 { WM_NCCREATE
, sent
},
2242 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
2243 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 },
2244 { WM_CREATE
, sent
},
2245 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 },
2246 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2247 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2249 { WM_PARENTNOTIFY
, sent
|wparam
, WM_CREATE
}, /* in MDI frame */
2250 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
2251 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2252 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2253 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2256 /* ShowWindow(SW_SHOW) for MDI client window */
2257 static const struct message WmShowMDIclientSeq
[] = {
2258 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
2259 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2260 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2261 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2264 /* ShowWindow(SW_HIDE) for MDI client window */
2265 static const struct message WmHideMDIclientSeq
[] = {
2266 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
2267 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2268 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* win2000 */
2269 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* XP */
2270 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2273 /* DestroyWindow for MDI client window, initially visible */
2274 static const struct message WmDestroyMDIclientSeq
[] = {
2275 { HCBT_DESTROYWND
, hook
},
2276 { 0x0090, sent
|optional
},
2277 { WM_PARENTNOTIFY
, sent
|wparam
, WM_DESTROY
}, /* in MDI frame */
2278 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
2279 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2280 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2281 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2282 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
2283 { WM_DESTROY
, sent
},
2284 { WM_NCDESTROY
, sent
},
2287 /* CreateWindow for MDI child window, initially visible */
2288 static const struct message WmCreateMDIchildVisibleSeq
[] = {
2289 { HCBT_CREATEWND
, hook
},
2290 { WM_NCCREATE
, sent
},
2291 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
2292 { WM_CREATE
, sent
},
2293 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2294 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2296 /* Win2k sends wparam set to
2297 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2298 * while Win9x doesn't bother to set child window id according to
2299 * CLIENTCREATESTRUCT.idFirstChild
2301 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
2302 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
2303 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2304 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2305 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2306 { WM_MDIREFRESHMENU
, sent
/*|wparam|lparam, 0, 0*/ },
2307 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
2308 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2309 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2311 /* Win9x: message sequence terminates here. */
2313 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 },
2314 { HCBT_SETFOCUS
, hook
}, /* in MDI client */
2315 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2316 { WM_IME_NOTIFY
, sent
|wparam
|optional
, 2 }, /* in MDI client */
2317 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2318 { WM_SETFOCUS
, sent
}, /* in MDI client */
2319 { HCBT_SETFOCUS
, hook
},
2320 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2321 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2322 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
2323 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2324 { WM_SETFOCUS
, sent
|defwinproc
},
2325 { WM_MDIACTIVATE
, sent
|defwinproc
},
2328 /* CreateWindow for MDI child window with invisible parent */
2329 static const struct message WmCreateMDIchildInvisibleParentSeq
[] = {
2330 { HCBT_CREATEWND
, hook
},
2331 { WM_GETMINMAXINFO
, sent
},
2332 { WM_NCCREATE
, sent
},
2333 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
2334 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 },
2335 { WM_CREATE
, sent
},
2336 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2337 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2339 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
2340 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
2341 { WM_MDIREFRESHMENU
, sent
}, /* in MDI client */
2342 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
2343 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2344 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2346 /* Win9x: message sequence terminates here. */
2348 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 },
2349 { HCBT_SETFOCUS
, hook
}, /* in MDI client */
2350 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2351 { WM_IME_NOTIFY
, sent
|wparam
|optional
, 2 }, /* in MDI client */
2352 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2353 { WM_SETFOCUS
, sent
}, /* in MDI client */
2354 { HCBT_SETFOCUS
, hook
},
2355 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2356 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2357 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
2358 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2359 { WM_SETFOCUS
, sent
|defwinproc
},
2360 { WM_MDIACTIVATE
, sent
|defwinproc
},
2363 /* DestroyWindow for MDI child window, initially visible */
2364 static const struct message WmDestroyMDIchildVisibleSeq
[] = {
2365 { HCBT_DESTROYWND
, hook
},
2366 /* Win2k sends wparam set to
2367 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
2368 * while Win9x doesn't bother to set child window id according to
2369 * CLIENTCREATESTRUCT.idFirstChild
2371 { 0x0090, sent
|optional
},
2372 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_DESTROY*/ }, /* in MDI client */
2373 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
2374 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2375 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2376 { WM_ERASEBKGND
, sent
|parent
|optional
},
2377 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2379 /* { WM_DESTROY, sent }
2380 * Win9x: message sequence terminates here.
2383 { HCBT_SETFOCUS
, hook
}, /* set focus to MDI client */
2384 { WM_KILLFOCUS
, sent
},
2385 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
2386 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2387 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2388 { WM_SETFOCUS
, sent
}, /* in MDI client */
2390 { HCBT_SETFOCUS
, hook
}, /* MDI client sets focus back to MDI child */
2391 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2392 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2393 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
2394 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2395 { WM_SETFOCUS
, sent
}, /* in MDI client */
2397 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
2399 { HCBT_SETFOCUS
, hook
}, /* set focus to MDI client */
2400 { WM_KILLFOCUS
, sent
},
2401 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
2402 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2403 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2404 { WM_SETFOCUS
, sent
}, /* in MDI client */
2406 { HCBT_SETFOCUS
, hook
}, /* MDI client sets focus back to MDI child */
2407 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2408 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2409 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
2410 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2411 { WM_SETFOCUS
, sent
}, /* in MDI client */
2413 { WM_DESTROY
, sent
},
2415 { HCBT_SETFOCUS
, hook
}, /* set focus to MDI client */
2416 { WM_KILLFOCUS
, sent
},
2417 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
2418 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2419 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2420 { WM_SETFOCUS
, sent
}, /* in MDI client */
2422 { HCBT_SETFOCUS
, hook
}, /* MDI client sets focus back to MDI child */
2423 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2424 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2425 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
2426 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2427 { WM_SETFOCUS
, sent
}, /* in MDI client */
2429 { WM_NCDESTROY
, sent
},
2432 /* CreateWindow for MDI child window, initially invisible */
2433 static const struct message WmCreateMDIchildInvisibleSeq
[] = {
2434 { HCBT_CREATEWND
, hook
},
2435 { WM_NCCREATE
, sent
},
2436 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
2437 { WM_CREATE
, sent
},
2438 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2439 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2441 /* Win2k sends wparam set to
2442 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2443 * while Win9x doesn't bother to set child window id according to
2444 * CLIENTCREATESTRUCT.idFirstChild
2446 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
2449 /* DestroyWindow for MDI child window, initially invisible */
2450 static const struct message WmDestroyMDIchildInvisibleSeq
[] = {
2451 { HCBT_DESTROYWND
, hook
},
2452 /* Win2k sends wparam set to
2453 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
2454 * while Win9x doesn't bother to set child window id according to
2455 * CLIENTCREATESTRUCT.idFirstChild
2457 { 0x0090, sent
|optional
},
2458 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_DESTROY*/ }, /* in MDI client */
2459 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
2460 { WM_DESTROY
, sent
},
2461 { WM_NCDESTROY
, sent
},
2462 /* FIXME: Wine destroys an icon/title window while Windows doesn't */
2463 { WM_PARENTNOTIFY
, sent
|wparam
|optional
, WM_DESTROY
}, /* MDI client */
2466 /* CreateWindow for the 1st MDI child window, initially visible and maximized */
2467 static const struct message WmCreateMDIchildVisibleMaxSeq1
[] = {
2468 { HCBT_CREATEWND
, hook
},
2469 { WM_NCCREATE
, sent
},
2470 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
2471 { WM_CREATE
, sent
},
2472 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2473 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2475 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
2476 { WM_GETMINMAXINFO
, sent
},
2477 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_STATECHANGED
},
2478 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2479 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
2480 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2482 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2483 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2484 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2485 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2486 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2487 /* Win2k sends wparam set to
2488 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2489 * while Win9x doesn't bother to set child window id according to
2490 * CLIENTCREATESTRUCT.idFirstChild
2492 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
2493 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
2494 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2495 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2496 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2497 { WM_MDIREFRESHMENU
, sent
/*|wparam|lparam, 0, 0*/ },
2498 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
2499 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2500 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
|optional
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
, 0, SWP_FRAMECHANGED
},
2502 /* Win9x: message sequence terminates here. */
2504 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
|optional
, 1 },
2505 { HCBT_SETFOCUS
, hook
|optional
}, /* in MDI client */
2506 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2507 { WM_IME_NOTIFY
, sent
|wparam
|optional
, 2 }, /* in MDI client */
2508 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2509 { WM_SETFOCUS
, sent
|optional
}, /* in MDI client */
2510 { HCBT_SETFOCUS
, hook
|optional
},
2511 { WM_KILLFOCUS
, sent
|optional
}, /* in MDI client */
2512 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2513 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
2514 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2515 { WM_SETFOCUS
, sent
|defwinproc
|optional
},
2516 { WM_MDIACTIVATE
, sent
|defwinproc
|optional
},
2518 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2519 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2520 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2521 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2524 /* CreateWindow for the 2nd MDI child window, initially visible and maximized */
2525 static const struct message WmCreateMDIchildVisibleMaxSeq2
[] = {
2526 /* restore the 1st MDI child */
2527 { WM_SETREDRAW
, sent
|wparam
, 0 },
2528 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWNORMAL
},
2529 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
2530 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2531 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2532 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
2533 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2535 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2536 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2537 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2538 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2539 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2540 { WM_SETREDRAW
, sent
|wparam
, 1 }, /* in the 1st MDI child */
2541 /* create the 2nd MDI child */
2542 { HCBT_CREATEWND
, hook
},
2543 { WM_NCCREATE
, sent
},
2544 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
2545 { WM_CREATE
, sent
},
2546 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2547 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2549 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
2550 { WM_GETMINMAXINFO
, sent
},
2551 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_STATECHANGED
},
2552 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2553 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2554 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
2555 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2557 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2558 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2559 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2560 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2561 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2562 /* Win2k sends wparam set to
2563 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2564 * while Win9x doesn't bother to set child window id according to
2565 * CLIENTCREATESTRUCT.idFirstChild
2567 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
2568 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
2569 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2570 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2571 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2572 { WM_MDIREFRESHMENU
, sent
/*|wparam|lparam, 0, 0*/ },
2573 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
2574 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2576 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 0 }, /* in the 1st MDI child */
2577 { WM_MDIACTIVATE
, sent
|defwinproc
}, /* in the 1st MDI child */
2579 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2581 /* Win9x: message sequence terminates here. */
2583 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 },
2584 { HCBT_SETFOCUS
, hook
},
2585 { WM_KILLFOCUS
, sent
|defwinproc
|optional
}, /* in the 1st MDI child */
2586 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 0 }, /* in the 1st MDI child */
2587 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2588 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2589 { WM_SETFOCUS
, sent
}, /* in MDI client */
2590 { HCBT_SETFOCUS
, hook
},
2591 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2592 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2593 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
2594 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2595 { WM_SETFOCUS
, sent
|defwinproc
},
2597 { WM_MDIACTIVATE
, sent
|defwinproc
},
2599 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2600 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2601 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2602 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2605 /* WM_MDICREATE MDI child window, initially visible and maximized */
2606 static const struct message WmCreateMDIchildVisibleMaxSeq3
[] = {
2607 { WM_MDICREATE
, sent
},
2608 { HCBT_CREATEWND
, hook
},
2609 { WM_NCCREATE
, sent
},
2610 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
2611 { WM_CREATE
, sent
},
2612 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2613 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2615 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
2616 { WM_GETMINMAXINFO
, sent
},
2617 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_STATECHANGED
},
2618 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2619 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
2620 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2623 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2624 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2625 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2626 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2627 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2629 /* Win2k sends wparam set to
2630 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2631 * while Win9x doesn't bother to set child window id according to
2632 * CLIENTCREATESTRUCT.idFirstChild
2634 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
2635 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
2636 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2638 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2640 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2641 { WM_MDIREFRESHMENU
, sent
/*|wparam|lparam, 0, 0*/ },
2642 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
2644 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2645 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2647 /* Win9x: message sequence terminates here. */
2649 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 },
2650 { WM_SETFOCUS
, sent
|optional
}, /* in MDI client */
2651 { HCBT_SETFOCUS
, hook
}, /* in MDI client */
2652 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2653 { WM_IME_NOTIFY
, sent
|wparam
|optional
, 2 },
2654 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
|optional
, OBJID_CLIENT
, 0 },
2655 { WM_SETFOCUS
, sent
|optional
}, /* in MDI client */
2656 { HCBT_SETFOCUS
, hook
|optional
},
2657 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2658 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2659 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
2660 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2661 { WM_SETFOCUS
, sent
|defwinproc
},
2663 { WM_MDIACTIVATE
, sent
|defwinproc
},
2666 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2667 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2668 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2669 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2672 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2673 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2674 { 0x0093, sent
|defwinproc
|optional
},
2675 { 0x0093, sent
|defwinproc
|optional
},
2676 { 0x0093, sent
|defwinproc
|optional
},
2677 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2678 { WM_MOVE
, sent
|defwinproc
},
2679 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2682 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
2683 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2684 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
},
2685 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2688 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
2689 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2690 { 0x0093, sent
|optional
},
2691 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
},
2692 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2694 { 0x0093, sent
|optional
},
2695 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2696 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI client */
2697 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 }, /* XP sends it to MDI frame */
2698 { 0x0093, sent
|defwinproc
|optional
},
2699 { 0x0093, sent
|defwinproc
|optional
},
2700 { 0x0093, sent
|defwinproc
|optional
},
2701 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2702 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* XP sends a duplicate */
2706 /* CreateWindow for the 1st MDI child window, initially invisible and maximized */
2707 static const struct message WmCreateMDIchildInvisibleMaxSeq4
[] = {
2708 { HCBT_CREATEWND
, hook
},
2709 { WM_GETMINMAXINFO
, sent
},
2710 { WM_NCCREATE
, sent
},
2711 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
2712 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, 0, 0 },
2713 { WM_CREATE
, sent
},
2714 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2715 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2716 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
, 0, SWP_NOZORDER
}, /* MDI frame */
2717 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 }, /* MDI frame */
2718 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
, 0, SWP_NOZORDER
}, /* MDI frame */
2720 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
2721 { WM_GETMINMAXINFO
, sent
},
2722 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_STATECHANGED
},
2723 { WM_GETMINMAXINFO
, sent
|defwinproc
},
2724 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2725 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOREDRAW
|SWP_STATECHANGED
},
2726 { WM_MOVE
, sent
|defwinproc
},
2727 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2729 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2730 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2731 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2732 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2733 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 }, /* MDI child */
2734 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2735 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2736 /* Win2k sends wparam set to
2737 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2738 * while Win9x doesn't bother to set child window id according to
2739 * CLIENTCREATESTRUCT.idFirstChild
2741 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_CREATE*/ }, /* in MDI client */
2744 /* WM_SYSCOMMAND/SC_CLOSE for the 2nd MDI child window, initially visible and maximized */
2745 static const struct message WmDestroyMDIchildVisibleMaxSeq2
[] = {
2746 { WM_SYSCOMMAND
, sent
|wparam
, SC_CLOSE
},
2747 { HCBT_SYSCOMMAND
, hook
},
2748 { WM_CLOSE
, sent
|defwinproc
},
2749 { WM_MDIDESTROY
, sent
}, /* in MDI client */
2751 /* bring the 1st MDI child to top */
2752 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOSIZE
|SWP_NOMOVE
}, /* in the 1st MDI child */
2753 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
}, /* in the 2nd MDI child */
2755 { EVENT_OBJECT_REORDER
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2757 { WM_CHILDACTIVATE
, sent
|defwinproc
|wparam
|lparam
, 0, 0 }, /* in the 1st MDI child */
2758 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 0 }, /* in the 1st MDI child */
2759 { WM_MDIACTIVATE
, sent
|defwinproc
}, /* in the 1st MDI child */
2761 /* maximize the 1st MDI child */
2762 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
2763 { WM_GETMINMAXINFO
, sent
|defwinproc
},
2764 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
2765 { WM_NCCALCSIZE
, sent
|defwinproc
|wparam
, 1 },
2766 { WM_CHILDACTIVATE
, sent
|defwinproc
|wparam
|lparam
, 0, 0 },
2767 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
2768 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2770 /* restore the 2nd MDI child */
2771 { WM_SETREDRAW
, sent
|defwinproc
|wparam
, 0 },
2772 { HCBT_MINMAX
, hook
|lparam
, 0, SW_NORMALNA
},
2773 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_SHOWWINDOW
|SWP_STATECHANGED
},
2774 { WM_NCCALCSIZE
, sent
|defwinproc
|wparam
, 1 },
2776 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2778 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_SHOWWINDOW
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
2779 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2781 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2783 { WM_SETREDRAW
, sent
|defwinproc
|wparam
, 1 },
2785 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2786 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2787 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2788 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2789 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2791 /* bring the 1st MDI child to top */
2792 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2793 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
, 1 },
2794 { HCBT_SETFOCUS
, hook
},
2795 { WM_KILLFOCUS
, sent
|defwinproc
},
2796 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 0 },
2797 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2798 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2799 { WM_SETFOCUS
, sent
}, /* in MDI client */
2800 { HCBT_SETFOCUS
, hook
},
2801 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2802 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2803 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
2804 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2805 { WM_SETFOCUS
, sent
|defwinproc
},
2806 { WM_MDIACTIVATE
, sent
|defwinproc
},
2807 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2809 /* apparently ShowWindow(SW_SHOW) on an MDI client */
2810 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
2811 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2812 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2813 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2814 { WM_MDIREFRESHMENU
, sent
},
2816 { HCBT_DESTROYWND
, hook
},
2817 /* Win2k sends wparam set to
2818 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
2819 * while Win9x doesn't bother to set child window id according to
2820 * CLIENTCREATESTRUCT.idFirstChild
2822 { 0x0090, sent
|defwinproc
|optional
},
2823 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_DESTROY*/ }, /* in MDI client */
2824 { WM_SHOWWINDOW
, sent
|defwinproc
|wparam
, 0 },
2825 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2826 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2827 { WM_ERASEBKGND
, sent
|parent
|optional
},
2828 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2830 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
2831 { WM_DESTROY
, sent
|defwinproc
},
2832 { WM_NCDESTROY
, sent
|defwinproc
},
2835 /* WM_MDIDESTROY for the single MDI child window, initially visible and maximized */
2836 static const struct message WmDestroyMDIchildVisibleMaxSeq1
[] = {
2837 { WM_MDIDESTROY
, sent
}, /* in MDI client */
2838 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
2839 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2840 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2841 { WM_ERASEBKGND
, sent
|parent
|optional
},
2842 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2844 { HCBT_SETFOCUS
, hook
},
2845 { WM_KILLFOCUS
, sent
},
2846 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
2847 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2848 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2849 { WM_SETFOCUS
, sent
}, /* in MDI client */
2850 { HCBT_SETFOCUS
, hook
},
2851 { WM_KILLFOCUS
, sent
}, /* in MDI client */
2852 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
2853 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
2854 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2855 { WM_SETFOCUS
, sent
},
2858 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2859 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2860 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2861 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2864 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2865 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2866 { 0x0093, sent
|defwinproc
|optional
},
2867 { 0x0093, sent
|defwinproc
|optional
},
2868 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2869 { WM_MOVE
, sent
|defwinproc
},
2870 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2873 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
2874 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2875 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
},
2876 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2879 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
2880 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2881 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
},
2882 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2885 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2886 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 },
2887 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2888 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2891 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2892 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 },
2893 { 0x0093, sent
|defwinproc
|optional
},
2894 { 0x0093, sent
|defwinproc
|optional
},
2895 { 0x0093, sent
|defwinproc
|optional
},
2896 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2897 { WM_MOVE
, sent
|defwinproc
},
2898 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2901 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
2902 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2903 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
},
2904 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2907 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
},
2908 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 },
2909 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
},
2910 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
2911 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2912 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI client */
2914 { 0x0093, sent
|defwinproc
|optional
},
2915 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
|optional
, 1 }, /* XP sends it to MDI frame */
2916 { 0x0093, sent
|defwinproc
|optional
},
2917 { 0x0093, sent
|defwinproc
|optional
},
2918 { 0x0093, sent
|defwinproc
|optional
},
2919 { 0x0093, sent
|optional
},
2921 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2922 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2923 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI client */
2924 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2925 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* XP sends a duplicate */
2928 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2929 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
2930 { 0x0093, sent
|defwinproc
|optional
},
2931 { 0x0093, sent
|defwinproc
|optional
},
2932 { 0x0093, sent
|defwinproc
|optional
},
2933 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2934 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2935 { 0x0093, sent
|optional
},
2937 { WM_NCACTIVATE
, sent
|wparam
, 0 },
2938 { WM_MDIACTIVATE
, sent
},
2940 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWNORMAL
},
2941 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_SHOWWINDOW
|SWP_STATECHANGED
},
2942 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2944 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
2946 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
2947 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_SHOWWINDOW
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
2948 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2951 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2952 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 },
2953 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2954 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2957 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2958 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2959 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2960 { WM_MOVE
, sent
|defwinproc
},
2961 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
2964 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
2965 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
2966 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
},
2967 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
2968 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
2969 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 }, /* XP */
2970 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI client */
2971 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
2972 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* XP sends a duplicate */
2974 { HCBT_SETFOCUS
, hook
},
2975 { WM_KILLFOCUS
, sent
},
2976 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
2977 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
2978 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
2979 { WM_SETFOCUS
, sent
}, /* in MDI client */
2981 { WM_MDIREFRESHMENU
, sent
}, /* in MDI client */
2983 { HCBT_DESTROYWND
, hook
},
2984 /* Win2k sends wparam set to
2985 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
2986 * while Win9x doesn't bother to set child window id according to
2987 * CLIENTCREATESTRUCT.idFirstChild
2989 { 0x0090, sent
|optional
},
2990 { WM_PARENTNOTIFY
, sent
/*|wparam, WM_DESTROY*/ }, /* in MDI client */
2992 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
2993 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
2994 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, 0, 0 },
2995 { WM_ERASEBKGND
, sent
|parent
|optional
},
2996 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_HIDEWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
2998 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 },
2999 { WM_DESTROY
, sent
},
3000 { WM_NCDESTROY
, sent
},
3003 /* ShowWindow(SW_MAXIMIZE) for a not visible MDI child window */
3004 static const struct message WmMaximizeMDIchildInvisibleSeq
[] = {
3005 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
3006 { WM_GETMINMAXINFO
, sent
},
3007 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_STATECHANGED
},
3008 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3009 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
3010 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
3012 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
|defwinproc
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
3013 { WM_NCACTIVATE
, sent
|wparam
|optional
|defwinproc
, 1 },
3014 { HCBT_SETFOCUS
, hook
|optional
},
3015 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
3016 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
3017 { WM_SETFOCUS
, sent
|optional
}, /* in MDI client */
3018 { HCBT_SETFOCUS
, hook
|optional
},
3019 { WM_KILLFOCUS
, sent
|optional
}, /* in MDI client */
3020 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
3021 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
3022 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
3023 { WM_SETFOCUS
, sent
|optional
|defwinproc
},
3024 { WM_MDIACTIVATE
, sent
|optional
|defwinproc
},
3025 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
3026 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
3028 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
3029 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3030 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
3031 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
3032 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
3035 /* ShowWindow(SW_MAXIMIZE) for a not visible maximized MDI child window */
3036 static const struct message WmMaximizeMDIchildInvisibleSeq2
[] = {
3037 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
3038 { WM_GETMINMAXINFO
, sent
},
3039 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
},
3040 { WM_GETMINMAXINFO
, sent
|defwinproc
},
3041 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3042 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
3043 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
3045 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
|optional
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
3046 { WM_NCACTIVATE
, sent
|wparam
|defwinproc
|optional
, 1 },
3047 { HCBT_SETFOCUS
, hook
|optional
},
3048 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 }, /* in MDI client */
3049 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
3050 { WM_SETFOCUS
, sent
|optional
}, /* in MDI client */
3051 { HCBT_SETFOCUS
, hook
|optional
},
3052 { WM_KILLFOCUS
, sent
|optional
}, /* in MDI client */
3053 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 }, /* in MDI client */
3054 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
3055 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
3056 { WM_SETFOCUS
, sent
|defwinproc
|optional
},
3057 { WM_MDIACTIVATE
, sent
|defwinproc
|optional
},
3058 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
3059 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
3062 /* WM_MDIMAXIMIZE for an MDI child window with invisible parent */
3063 static const struct message WmMaximizeMDIchildInvisibleParentSeq
[] = {
3064 { WM_MDIMAXIMIZE
, sent
}, /* in MDI client */
3065 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
3066 { WM_GETMINMAXINFO
, sent
},
3067 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
3068 { WM_GETMINMAXINFO
, sent
|defwinproc
},
3069 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3070 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* XP doesn't send it */
3071 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
3072 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOREDRAW
|SWP_STATECHANGED
},
3073 { WM_MOVE
, sent
|defwinproc
},
3074 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
3076 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
3077 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 },
3078 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
3079 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
|optional
, 1 },
3080 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI child XP */
3081 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI client XP */
3083 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
3084 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3085 { 0x0093, sent
|defwinproc
|optional
},
3086 { 0x0094, sent
|defwinproc
|optional
},
3087 { 0x0094, sent
|defwinproc
|optional
},
3088 { 0x0094, sent
|defwinproc
|optional
},
3089 { 0x0094, sent
|defwinproc
|optional
},
3090 { 0x0093, sent
|defwinproc
|optional
},
3091 { 0x0093, sent
|defwinproc
|optional
},
3092 { 0x0091, sent
|defwinproc
|optional
},
3093 { 0x0092, sent
|defwinproc
|optional
},
3094 { 0x0092, sent
|defwinproc
|optional
},
3095 { 0x0092, sent
|defwinproc
|optional
},
3096 { 0x0092, sent
|defwinproc
|optional
},
3097 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
3098 { WM_MOVE
, sent
|defwinproc
},
3099 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
3100 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI frame win2000 */
3102 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOACTIVATE
},
3103 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3104 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
},
3105 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
3107 { WM_WINDOWPOSCHANGING
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
},
3108 { WM_GETMINMAXINFO
, sent
|defwinproc
},
3109 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, 1 },
3110 { WM_WINDOWPOSCHANGED
, sent
|wparam
|defwinproc
, SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTMOVE
},
3111 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
3112 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI child win2000 */
3113 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
|optional
, 1 },
3114 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI child XP */
3115 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI child XP */
3116 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI client XP */
3118 { 0x0093, sent
|optional
},
3119 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
3120 { 0x0093, sent
|defwinproc
|optional
},
3121 { 0x0093, sent
|defwinproc
|optional
},
3122 { 0x0093, sent
|defwinproc
|optional
},
3123 { 0x0091, sent
|defwinproc
|optional
},
3124 { 0x0092, sent
|defwinproc
|optional
},
3125 { 0x0092, sent
|defwinproc
|optional
},
3126 { 0x0092, sent
|defwinproc
|optional
},
3127 { 0x0092, sent
|defwinproc
|optional
},
3128 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI frame XP */
3129 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI frame XP */
3130 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
|optional
, 0, 0 }, /* MDI child XP */
3133 /* ShowWindow(SW_MAXIMIZE) for a visible MDI child window */
3134 static const struct message WmMaximizeMDIchildVisibleSeq
[] = {
3135 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MAXIMIZE
},
3136 { WM_GETMINMAXINFO
, sent
},
3137 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
3138 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3139 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
3140 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
3141 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_MAXIMIZED
},
3143 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
3144 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3145 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
3146 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
3147 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
3150 /* ShowWindow(SW_RESTORE) for a visible maximized MDI child window */
3151 static const struct message WmRestoreMDIchildVisibleSeq
[] = {
3152 { HCBT_MINMAX
, hook
|lparam
, 0, SW_RESTORE
},
3153 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
3154 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3155 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
3156 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
3157 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
3159 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
3160 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3161 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
3162 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
3163 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
3166 /* ShowWindow(SW_RESTORE) for a visible minimized MDI child window */
3167 static const struct message WmRestoreMDIchildVisibleSeq_2
[] = {
3168 { HCBT_MINMAX
, hook
|lparam
, 0, SW_RESTORE
},
3169 { WM_QUERYOPEN
, sent
|wparam
|lparam
, 0, 0 },
3170 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
3171 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3172 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
3173 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
3174 { WM_MOVE
, sent
|defwinproc
},
3175 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
3176 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
3177 { EVENT_SYSTEM_MINIMIZEEND
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
3178 { HCBT_SETFOCUS
, hook
},
3179 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
3180 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
3181 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
3182 { WM_SETFOCUS
, sent
},
3185 /* ShowWindow(SW_MINIMIZE) for a visible restored MDI child window */
3186 static const struct message WmMinimizeMDIchildVisibleSeq
[] = {
3187 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
3188 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
3189 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3190 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
3191 { WM_MOVE
, sent
|defwinproc
},
3192 { WM_SIZE
, sent
|defwinproc
|wparam
|lparam
, SIZE_MINIMIZED
, 0 },
3193 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
|defwinproc
, 0, 0 },
3194 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
3195 { EVENT_SYSTEM_MINIMIZESTART
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
3196 /* FIXME: Wine creates an icon/title window while Windows doesn't */
3197 { WM_PARENTNOTIFY
, sent
|parent
|wparam
|optional
, WM_CREATE
}, /* MDI client */
3200 /* ShowWindow(SW_RESTORE) for a not visible MDI child window */
3201 static const struct message WmRestoreMDIchildInisibleSeq
[] = {
3202 { HCBT_MINMAX
, hook
|lparam
, 0, SW_RESTORE
},
3203 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_STATECHANGED
},
3204 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3205 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, 0, 0 },
3206 { WM_CHILDACTIVATE
, sent
|wparam
|lparam
, 0, 0 },
3207 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOMOVE
|SWP_NOCLIENTMOVE
|SWP_STATECHANGED
},
3208 { WM_SIZE
, sent
|defwinproc
|wparam
, SIZE_RESTORED
},
3210 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
3211 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
3212 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
3213 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI frame */
3214 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* MDI child */
3218 static HWND mdi_client
;
3219 static WNDPROC old_mdi_client_proc
;
3221 static LRESULT WINAPI
mdi_client_hook_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
3223 struct recvd_message msg
;
3225 /* do not log painting messages */
3226 if (message
!= WM_PAINT
&&
3227 message
!= WM_NCPAINT
&&
3228 message
!= WM_SYNCPAINT
&&
3229 message
!= WM_ERASEBKGND
&&
3230 message
!= WM_NCHITTEST
&&
3231 message
!= WM_GETTEXT
&&
3232 message
!= WM_MDIGETACTIVE
&&
3233 !ignore_message( message
))
3236 msg
.message
= message
;
3237 msg
.flags
= sent
|wparam
|lparam
;
3238 msg
.wParam
= wParam
;
3239 msg
.lParam
= lParam
;
3240 msg
.descr
= "mdi client";
3244 return CallWindowProcA(old_mdi_client_proc
, hwnd
, message
, wParam
, lParam
);
3247 static LRESULT WINAPI
mdi_child_wnd_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
3249 static LONG defwndproc_counter
= 0;
3251 struct recvd_message msg
;
3253 /* do not log painting messages */
3254 if (message
!= WM_PAINT
&&
3255 message
!= WM_NCPAINT
&&
3256 message
!= WM_SYNCPAINT
&&
3257 message
!= WM_ERASEBKGND
&&
3258 message
!= WM_NCHITTEST
&&
3259 message
!= WM_GETTEXT
&&
3260 !ignore_message( message
))
3264 case WM_MDIACTIVATE
:
3266 HWND active
, client
= GetParent(hwnd
);
3268 active
= (HWND
)SendMessageA(client
, WM_MDIGETACTIVE
, 0, 0);
3270 if (hwnd
== (HWND
)lParam
) /* if we are being activated */
3271 ok (active
== (HWND
)lParam
, "new active %p != active %p\n", (HWND
)lParam
, active
);
3273 ok (active
== (HWND
)wParam
, "old active %p != active %p\n", (HWND
)wParam
, active
);
3279 msg
.message
= message
;
3280 msg
.flags
= sent
|wparam
|lparam
;
3281 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
3282 msg
.wParam
= wParam
;
3283 msg
.lParam
= lParam
;
3284 msg
.descr
= "mdi child";
3288 defwndproc_counter
++;
3289 ret
= DefMDIChildProcA(hwnd
, message
, wParam
, lParam
);
3290 defwndproc_counter
--;
3295 static LRESULT WINAPI
mdi_frame_wnd_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
3297 static LONG defwndproc_counter
= 0;
3299 struct recvd_message msg
;
3301 /* do not log painting messages */
3302 if (message
!= WM_PAINT
&&
3303 message
!= WM_NCPAINT
&&
3304 message
!= WM_SYNCPAINT
&&
3305 message
!= WM_ERASEBKGND
&&
3306 message
!= WM_NCHITTEST
&&
3307 message
!= WM_GETTEXT
&&
3308 !ignore_message( message
))
3311 msg
.message
= message
;
3312 msg
.flags
= sent
|wparam
|lparam
;
3313 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
3314 msg
.wParam
= wParam
;
3315 msg
.lParam
= lParam
;
3316 msg
.descr
= "mdi frame";
3320 defwndproc_counter
++;
3321 ret
= DefFrameProcA(hwnd
, mdi_client
, message
, wParam
, lParam
);
3322 defwndproc_counter
--;
3327 static BOOL
mdi_RegisterWindowClasses(void)
3332 cls
.lpfnWndProc
= mdi_frame_wnd_proc
;
3335 cls
.hInstance
= GetModuleHandleA(0);
3337 cls
.hCursor
= LoadCursorA(0, IDC_ARROW
);
3338 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
3339 cls
.lpszMenuName
= NULL
;
3340 cls
.lpszClassName
= "MDI_frame_class";
3341 if (!RegisterClassA(&cls
)) return FALSE
;
3343 cls
.lpfnWndProc
= mdi_child_wnd_proc
;
3344 cls
.lpszClassName
= "MDI_child_class";
3345 if (!RegisterClassA(&cls
)) return FALSE
;
3347 if (!GetClassInfoA(0, "MDIClient", &cls
)) assert(0);
3348 old_mdi_client_proc
= cls
.lpfnWndProc
;
3349 cls
.hInstance
= GetModuleHandleA(0);
3350 cls
.lpfnWndProc
= mdi_client_hook_proc
;
3351 cls
.lpszClassName
= "MDI_client_class";
3352 if (!RegisterClassA(&cls
)) assert(0);
3357 static void test_mdi_messages(void)
3359 MDICREATESTRUCTA mdi_cs
;
3360 CLIENTCREATESTRUCT client_cs
;
3361 HWND mdi_frame
, mdi_child
, mdi_child2
, active_child
;
3364 HMENU hMenu
= CreateMenu();
3366 assert(mdi_RegisterWindowClasses());
3370 trace("creating MDI frame window\n");
3371 mdi_frame
= CreateWindowExA(0, "MDI_frame_class", "MDI frame window",
3372 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
|
3373 WS_MAXIMIZEBOX
| WS_VISIBLE
,
3374 100, 100, CW_USEDEFAULT
, CW_USEDEFAULT
,
3375 GetDesktopWindow(), hMenu
,
3376 GetModuleHandleA(0), NULL
);
3378 ok_sequence(WmCreateMDIframeSeq
, "Create MDI frame window", FALSE
);
3380 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3381 ok(GetFocus() == mdi_frame
, "wrong focus window %p\n", GetFocus());
3383 trace("creating MDI client window\n");
3384 GetClientRect(mdi_frame
, &rc
);
3385 client_cs
.hWindowMenu
= 0;
3386 client_cs
.idFirstChild
= MDI_FIRST_CHILD_ID
;
3387 mdi_client
= CreateWindowExA(0, "MDI_client_class",
3389 WS_CHILD
| WS_VISIBLE
| MDIS_ALLCHILDSTYLES
,
3390 rc
.left
, rc
.top
, rc
.right
- rc
.left
, rc
.bottom
- rc
.top
,
3391 mdi_frame
, 0, GetModuleHandleA(0), &client_cs
);
3393 ok_sequence(WmCreateMDIclientSeq
, "Create visible MDI client window", FALSE
);
3395 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3396 ok(GetFocus() == mdi_frame
, "input focus should be on MDI frame not on %p\n", GetFocus());
3398 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3399 ok(!active_child
, "wrong active MDI child %p\n", active_child
);
3400 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
3405 trace("creating invisible MDI child window\n");
3406 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3408 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
3409 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3413 ShowWindow(mdi_child
, SW_SHOWNORMAL
);
3414 ok_sequence(WmShowChildSeq
, "ShowWindow(SW_SHOWNORMAL) MDI child window", FALSE
);
3416 ok(GetWindowLongA(mdi_child
, GWL_STYLE
) & WS_VISIBLE
, "MDI child should be visible\n");
3417 ok(IsWindowVisible(mdi_child
), "MDI child should be visible\n");
3419 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3420 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3422 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3423 ok(!active_child
, "wrong active MDI child %p\n", active_child
);
3424 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
3426 ShowWindow(mdi_child
, SW_HIDE
);
3427 ok_sequence(WmHideChildSeq
, "ShowWindow(SW_HIDE) MDI child window", FALSE
);
3430 ShowWindow(mdi_child
, SW_SHOW
);
3431 ok_sequence(WmShowChildSeq
, "ShowWindow(SW_SHOW) MDI child window", FALSE
);
3433 ok(GetWindowLongA(mdi_child
, GWL_STYLE
) & WS_VISIBLE
, "MDI child should be visible\n");
3434 ok(IsWindowVisible(mdi_child
), "MDI child should be visible\n");
3436 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3437 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3439 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3440 ok(!active_child
, "wrong active MDI child %p\n", active_child
);
3441 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
3443 DestroyWindow(mdi_child
);
3446 trace("creating visible MDI child window\n");
3447 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3448 WS_CHILD
| WS_VISIBLE
,
3449 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
3450 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3452 ok_sequence(WmCreateMDIchildVisibleSeq
, "Create visible MDI child window", FALSE
);
3454 ok(GetWindowLongA(mdi_child
, GWL_STYLE
) & WS_VISIBLE
, "MDI child should be visible\n");
3455 ok(IsWindowVisible(mdi_child
), "MDI child should be visible\n");
3457 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3458 ok(GetFocus() == mdi_child
, "wrong focus window %p\n", GetFocus());
3460 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3461 ok(active_child
== mdi_child
, "wrong active MDI child %p\n", active_child
);
3462 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
3465 DestroyWindow(mdi_child
);
3466 ok_sequence(WmDestroyMDIchildVisibleSeq
, "Destroy visible MDI child window", TRUE
);
3468 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3469 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3471 /* Win2k: MDI client still returns a just destroyed child as active
3472 * Win9x: MDI client returns 0
3474 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3475 ok(active_child
== mdi_child
|| /* win2k */
3476 !active_child
, /* win9x */
3477 "wrong active MDI child %p\n", active_child
);
3478 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
3482 trace("creating invisible MDI child window\n");
3483 mdi_child2
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3485 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
3486 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3488 ok_sequence(WmCreateMDIchildInvisibleSeq
, "Create invisible MDI child window", FALSE
);
3490 ok(!(GetWindowLongA(mdi_child2
, GWL_STYLE
) & WS_VISIBLE
), "MDI child should not be visible\n");
3491 ok(!IsWindowVisible(mdi_child2
), "MDI child should not be visible\n");
3493 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3494 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3496 /* Win2k: MDI client still returns a just destroyed child as active
3497 * Win9x: MDI client returns mdi_child2
3499 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3500 ok(active_child
== mdi_child
|| /* win2k */
3501 active_child
== mdi_child2
, /* win9x */
3502 "wrong active MDI child %p\n", active_child
);
3503 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
3506 ShowWindow(mdi_child2
, SW_MAXIMIZE
);
3507 ok_sequence(WmMaximizeMDIchildInvisibleSeq
, "ShowWindow(SW_MAXIMIZE):invisible MDI child", FALSE
);
3509 ok(GetWindowLongA(mdi_child2
, GWL_STYLE
) & WS_VISIBLE
, "MDI child should be visible\n");
3510 ok(IsWindowVisible(mdi_child2
), "MDI child should be visible\n");
3512 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3513 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
3514 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
3517 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3518 ok(GetFocus() == mdi_child2
|| /* win2k */
3519 GetFocus() == 0, /* win9x */
3520 "wrong focus window %p\n", GetFocus());
3525 ShowWindow(mdi_child2
, SW_HIDE
);
3526 ok_sequence(WmHideChildSeq
, "ShowWindow(SW_HIDE):MDI child", FALSE
);
3528 ShowWindow(mdi_child2
, SW_RESTORE
);
3529 ok_sequence(WmRestoreMDIchildInisibleSeq
, "ShowWindow(SW_RESTORE):invisible MDI child", FALSE
);
3532 ok(GetWindowLongA(mdi_child2
, GWL_STYLE
) & WS_VISIBLE
, "MDI child should be visible\n");
3533 ok(IsWindowVisible(mdi_child2
), "MDI child should be visible\n");
3535 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3536 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
3537 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
3543 ShowWindow(mdi_child2
, SW_HIDE
);
3544 ok_sequence(WmHideChildSeq
, "ShowWindow(SW_HIDE):MDI child", FALSE
);
3546 ShowWindow(mdi_child2
, SW_SHOW
);
3547 ok_sequence(WmShowChildSeq
, "ShowWindow(SW_SHOW):MDI child", FALSE
);
3549 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3550 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3552 ShowWindow(mdi_child2
, SW_MAXIMIZE
);
3553 ok_sequence(WmMaximizeMDIchildVisibleSeq
, "ShowWindow(SW_MAXIMIZE):MDI child", FALSE
);
3555 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3556 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3558 ShowWindow(mdi_child2
, SW_RESTORE
);
3559 ok_sequence(WmRestoreMDIchildVisibleSeq
, "ShowWindow(SW_RESTORE):maximized MDI child", FALSE
);
3561 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3562 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3564 ShowWindow(mdi_child2
, SW_MINIMIZE
);
3565 ok_sequence(WmMinimizeMDIchildVisibleSeq
, "ShowWindow(SW_MINIMIZE):MDI child", TRUE
);
3567 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3568 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3570 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3571 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
3572 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
3575 ShowWindow(mdi_child2
, SW_RESTORE
);
3576 ok_sequence(WmRestoreMDIchildVisibleSeq_2
, "ShowWindow(SW_RESTORE):minimized MDI child", FALSE
);
3578 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3579 ok(GetFocus() == mdi_child2
, "wrong focus window %p\n", GetFocus());
3581 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3582 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
3583 ok(!zoomed
, "wrong zoomed state %d\n", zoomed
);
3589 ShowWindow(mdi_child2
, SW_HIDE
);
3590 ok_sequence(WmHideChildSeq
, "ShowWindow(SW_HIDE):MDI child", FALSE
);
3592 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3593 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3595 DestroyWindow(mdi_child2
);
3596 ok_sequence(WmDestroyMDIchildInvisibleSeq
, "Destroy invisible MDI child window", FALSE
);
3598 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3599 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3601 /* test for maximized MDI children */
3602 trace("creating maximized visible MDI child window 1\n");
3603 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3604 WS_CHILD
| WS_VISIBLE
| WS_MAXIMIZEBOX
| WS_MAXIMIZE
,
3605 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
3606 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3608 ok_sequence(WmCreateMDIchildVisibleMaxSeq1
, "Create maximized visible 1st MDI child window", TRUE
);
3609 ok(IsZoomed(mdi_child
), "1st MDI child should be maximized\n");
3611 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3612 ok(GetFocus() == mdi_child
|| /* win2k */
3613 GetFocus() == 0, /* win9x */
3614 "wrong focus window %p\n", GetFocus());
3616 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3617 ok(active_child
== mdi_child
, "wrong active MDI child %p\n", active_child
);
3618 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
3621 trace("creating maximized visible MDI child window 2\n");
3622 mdi_child2
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3623 WS_CHILD
| WS_VISIBLE
| WS_MAXIMIZEBOX
| WS_MAXIMIZE
,
3624 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
3625 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3627 ok_sequence(WmCreateMDIchildVisibleMaxSeq2
, "Create maximized visible 2nd MDI child 2 window", TRUE
);
3628 ok(IsZoomed(mdi_child2
), "2nd MDI child should be maximized\n");
3629 ok(!IsZoomed(mdi_child
), "1st MDI child should NOT be maximized\n");
3631 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3632 ok(GetFocus() == mdi_child2
, "wrong focus window %p\n", GetFocus());
3634 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3635 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
3636 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
3639 trace("destroying maximized visible MDI child window 2\n");
3640 DestroyWindow(mdi_child2
);
3641 ok_sequence(WmDestroyMDIchildVisibleSeq
, "Destroy visible MDI child window", TRUE
);
3643 ok(!IsZoomed(mdi_child
), "1st MDI child should NOT be maximized\n");
3645 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3646 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3648 /* Win2k: MDI client still returns a just destroyed child as active
3649 * Win9x: MDI client returns 0
3651 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3652 ok(active_child
== mdi_child2
|| /* win2k */
3653 !active_child
, /* win9x */
3654 "wrong active MDI child %p\n", active_child
);
3657 ShowWindow(mdi_child
, SW_MAXIMIZE
);
3658 ok(IsZoomed(mdi_child
), "1st MDI child should be maximized\n");
3661 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3662 ok(GetFocus() == mdi_child
, "wrong focus window %p\n", GetFocus());
3664 trace("re-creating maximized visible MDI child window 2\n");
3665 mdi_child2
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3666 WS_CHILD
| WS_VISIBLE
| WS_MAXIMIZEBOX
| WS_MAXIMIZE
,
3667 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
3668 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3670 ok_sequence(WmCreateMDIchildVisibleMaxSeq2
, "Create maximized visible 2nd MDI child 2 window", TRUE
);
3671 ok(IsZoomed(mdi_child2
), "2nd MDI child should be maximized\n");
3672 ok(!IsZoomed(mdi_child
), "1st MDI child should NOT be maximized\n");
3674 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3675 ok(GetFocus() == mdi_child2
, "wrong focus window %p\n", GetFocus());
3677 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3678 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
3679 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
3682 SendMessageA(mdi_child2
, WM_SYSCOMMAND
, SC_CLOSE
, 0);
3683 ok_sequence(WmDestroyMDIchildVisibleMaxSeq2
, "WM_SYSCOMMAND/SC_CLOSE on a visible maximized MDI child window", TRUE
);
3684 ok(!IsWindow(mdi_child2
), "MDI child 2 should be destroyed\n");
3686 ok(IsZoomed(mdi_child
), "1st MDI child should be maximized\n");
3687 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3688 ok(GetFocus() == mdi_child
, "wrong focus window %p\n", GetFocus());
3690 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3691 ok(active_child
== mdi_child
, "wrong active MDI child %p\n", active_child
);
3692 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
3695 DestroyWindow(mdi_child
);
3696 ok_sequence(WmDestroyMDIchildVisibleSeq
, "Destroy visible MDI child window", TRUE
);
3698 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3699 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3701 /* Win2k: MDI client still returns a just destroyed child as active
3702 * Win9x: MDI client returns 0
3704 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3705 ok(active_child
== mdi_child
|| /* win2k */
3706 !active_child
, /* win9x */
3707 "wrong active MDI child %p\n", active_child
);
3710 trace("creating maximized invisible MDI child window\n");
3711 mdi_child2
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3712 WS_CHILD
| WS_MAXIMIZE
| WS_CAPTION
| WS_THICKFRAME
,
3713 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
3714 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3716 ok_sequence(WmCreateMDIchildInvisibleMaxSeq4
, "Create maximized invisible MDI child window", FALSE
);
3717 ok(IsZoomed(mdi_child2
), "MDI child should be maximized\n");
3718 ok(!(GetWindowLongA(mdi_child2
, GWL_STYLE
) & WS_VISIBLE
), "MDI child should be not visible\n");
3719 ok(!IsWindowVisible(mdi_child2
), "MDI child should be not visible\n");
3721 /* Win2k: MDI client still returns a just destroyed child as active
3722 * Win9x: MDI client returns 0
3724 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3725 ok(active_child
== mdi_child
|| /* win2k */
3726 !active_child
|| active_child
== mdi_child2
, /* win9x */
3727 "wrong active MDI child %p\n", active_child
);
3730 trace("call ShowWindow(mdi_child, SW_MAXIMIZE)\n");
3731 ShowWindow(mdi_child2
, SW_MAXIMIZE
);
3732 ok_sequence(WmMaximizeMDIchildInvisibleSeq2
, "ShowWindow(SW_MAXIMIZE):invisible maximized MDI child", FALSE
);
3733 ok(IsZoomed(mdi_child2
), "MDI child should be maximized\n");
3734 ok(GetWindowLongA(mdi_child2
, GWL_STYLE
) & WS_VISIBLE
, "MDI child should be visible\n");
3735 ok(IsWindowVisible(mdi_child2
), "MDI child should be visible\n");
3737 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3738 ok(active_child
== mdi_child2
, "wrong active MDI child %p\n", active_child
);
3739 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
3742 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child2
, 0);
3745 /* end of test for maximized MDI children */
3748 trace("creating maximized visible MDI child window 1(Switch test)\n");
3749 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3750 WS_CHILD
| WS_VISIBLE
| WS_MAXIMIZEBOX
| WS_MAXIMIZE
,
3751 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
3752 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3754 ok_sequence(WmCreateMDIchildVisibleMaxSeq1
, "Create maximized visible 1st MDI child window(Switch test)", TRUE
);
3755 ok(IsZoomed(mdi_child
), "1st MDI child should be maximized(Switch test)\n");
3757 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p(Switch test)\n", GetActiveWindow());
3758 ok(GetFocus() == mdi_child
|| /* win2k */
3759 GetFocus() == 0, /* win9x */
3760 "wrong focus window %p(Switch test)\n", GetFocus());
3762 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3763 ok(active_child
== mdi_child
, "wrong active MDI child %p(Switch test)\n", active_child
);
3764 ok(zoomed
, "wrong zoomed state %d(Switch test)\n", zoomed
);
3767 trace("creating maximized visible MDI child window 2(Switch test)\n");
3768 mdi_child2
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3769 WS_CHILD
| WS_VISIBLE
| WS_MAXIMIZEBOX
| WS_MAXIMIZE
,
3770 0, 0, CW_USEDEFAULT
, CW_USEDEFAULT
,
3771 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3773 ok_sequence(WmCreateMDIchildVisibleMaxSeq2
, "Create maximized visible 2nd MDI child window (Switch test)", TRUE
);
3775 ok(IsZoomed(mdi_child2
), "2nd MDI child should be maximized(Switch test)\n");
3776 ok(!IsZoomed(mdi_child
), "1st MDI child should NOT be maximized(Switch test)\n");
3778 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p(Switch test)\n", GetActiveWindow());
3779 ok(GetFocus() == mdi_child2
, "wrong focus window %p(Switch test)\n", GetFocus());
3781 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3782 ok(active_child
== mdi_child2
, "wrong active MDI child %p(Switch test)\n", active_child
);
3783 ok(zoomed
, "wrong zoomed state %d(Switch test)\n", zoomed
);
3786 trace("Switch child window.\n");
3787 SendMessageA(mdi_client
, WM_MDIACTIVATE
, (WPARAM
)mdi_child
, 0);
3788 ok_sequence(WmSwitchChild
, "Child did not switch correctly", TRUE
);
3789 trace("end of test for switch maximized MDI children\n");
3792 /* Prepare for switching test of not maximized MDI children */
3793 ShowWindow( mdi_child
, SW_NORMAL
);
3794 ok(!IsZoomed(mdi_child
), "wrong zoomed state for %p(Switch test)\n", mdi_child
);
3795 ok(!IsZoomed(mdi_child2
), "wrong zoomed state for %p(Switch test)\n", mdi_child2
);
3796 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, 0);
3797 ok(active_child
== mdi_child
, "wrong active MDI child %p(Switch test)\n", active_child
);
3800 SendMessageA(mdi_client
, WM_MDIACTIVATE
, (WPARAM
)mdi_child2
, 0);
3801 ok_sequence(WmSwitchNotMaximizedChild
, "Not maximized child did not switch correctly", FALSE
);
3802 trace("end of test for switch not maximized MDI children\n");
3805 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
3808 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child2
, 0);
3813 /* end of tests for switch maximized/not maximized MDI children */
3815 mdi_cs
.szClass
= "MDI_child_Class";
3816 mdi_cs
.szTitle
= "MDI child";
3817 mdi_cs
.hOwner
= GetModuleHandleA(0);
3820 mdi_cs
.cx
= CW_USEDEFAULT
;
3821 mdi_cs
.cy
= CW_USEDEFAULT
;
3822 mdi_cs
.style
= WS_CHILD
| WS_SYSMENU
| WS_VISIBLE
| WS_MAXIMIZEBOX
| WS_MAXIMIZE
;
3824 mdi_child
= (HWND
)SendMessageA(mdi_client
, WM_MDICREATE
, 0, (LPARAM
)&mdi_cs
);
3825 ok(mdi_child
!= 0, "MDI child creation failed\n");
3826 ok_sequence(WmCreateMDIchildVisibleMaxSeq3
, "WM_MDICREATE for maximized visible MDI child window", TRUE
);
3828 ok(GetMenuItemID(hMenu
, GetMenuItemCount(hMenu
) - 1) == SC_CLOSE
, "SC_CLOSE menu item not found\n");
3830 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3831 ok(active_child
== mdi_child
, "wrong active MDI child %p\n", active_child
);
3833 ok(IsZoomed(mdi_child
), "MDI child should be maximized\n");
3834 ok(GetActiveWindow() == mdi_frame
, "wrong active window %p\n", GetActiveWindow());
3835 ok(GetFocus() == mdi_child
, "wrong focus window %p\n", GetFocus());
3837 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3838 ok(active_child
== mdi_child
, "wrong active MDI child %p\n", active_child
);
3839 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
3842 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
3843 ok_sequence(WmDestroyMDIchildVisibleMaxSeq1
, "Destroy visible maximized MDI child window", TRUE
);
3845 ok(!IsWindow(mdi_child
), "MDI child should be destroyed\n");
3846 active_child
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, (LPARAM
)&zoomed
);
3847 ok(!active_child
, "wrong active MDI child %p\n", active_child
);
3852 DestroyWindow(mdi_client
);
3853 ok_sequence(WmDestroyMDIclientSeq
, "Destroy MDI client window", FALSE
);
3855 /* test maximization of MDI child with invisible parent */
3856 client_cs
.hWindowMenu
= 0;
3857 mdi_client
= CreateWindow("MDI_client_class",
3859 WS_CHILD
| WS_CLIPCHILDREN
| WS_VSCROLL
| WS_HSCROLL
| WS_VISIBLE
,
3861 mdi_frame
, 0, GetModuleHandleA(0), &client_cs
);
3862 ok_sequence(WmCreateMDIclientSeq
, "Create MDI client window", FALSE
);
3864 ShowWindow(mdi_client
, SW_HIDE
);
3865 ok_sequence(WmHideMDIclientSeq
, "Hide MDI client window", FALSE
);
3867 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_class", "MDI child",
3868 WS_CHILD
| WS_CLIPCHILDREN
| WS_VSCROLL
| WS_HSCROLL
,
3870 mdi_client
, 0, GetModuleHandleA(0), NULL
);
3871 ok_sequence(WmCreateMDIchildInvisibleParentSeq
, "Create MDI child window with invisible parent", FALSE
);
3873 SendMessage(mdi_client
, WM_MDIMAXIMIZE
, (WPARAM
) mdi_child
, 0);
3874 ok_sequence(WmMaximizeMDIchildInvisibleParentSeq
, "Maximize MDI child window with invisible parent", TRUE
);
3875 zoomed
= IsZoomed(mdi_child
);
3876 ok(zoomed
, "wrong zoomed state %d\n", zoomed
);
3878 ShowWindow(mdi_client
, SW_SHOW
);
3879 ok_sequence(WmShowMDIclientSeq
, "Show MDI client window", FALSE
);
3881 DestroyWindow(mdi_child
);
3882 ok_sequence(WmDestroyMDIchildVisibleSeq
, "Destroy visible maximized MDI child window", TRUE
);
3884 /* end of test for maximization of MDI child with invisible parent */
3886 DestroyWindow(mdi_client
);
3887 ok_sequence(WmDestroyMDIclientSeq
, "Destroy MDI client window", FALSE
);
3889 DestroyWindow(mdi_frame
);
3890 ok_sequence(WmDestroyMDIframeSeq
, "Destroy MDI frame window", FALSE
);
3892 /************************* End of MDI test **********************************/
3894 static void test_WM_SETREDRAW(HWND hwnd
)
3896 DWORD style
= GetWindowLongA(hwnd
, GWL_STYLE
);
3901 SendMessageA(hwnd
, WM_SETREDRAW
, FALSE
, 0);
3902 ok_sequence(WmSetRedrawFalseSeq
, "SetRedraw:FALSE", FALSE
);
3904 ok(!(GetWindowLongA(hwnd
, GWL_STYLE
) & WS_VISIBLE
), "WS_VISIBLE should NOT be set\n");
3905 ok(!IsWindowVisible(hwnd
), "IsWindowVisible() should return FALSE\n");
3908 SendMessageA(hwnd
, WM_SETREDRAW
, TRUE
, 0);
3909 ok_sequence(WmSetRedrawTrueSeq
, "SetRedraw:TRUE", FALSE
);
3911 ok(GetWindowLongA(hwnd
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
3912 ok(IsWindowVisible(hwnd
), "IsWindowVisible() should return TRUE\n");
3914 /* restore original WS_VISIBLE state */
3915 SetWindowLongA(hwnd
, GWL_STYLE
, style
);
3921 static INT_PTR CALLBACK
TestModalDlgProcA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
3923 struct recvd_message msg
;
3925 if (ignore_message( message
)) return 0;
3931 case WM_NCMOUSEMOVE
:
3932 case WM_NCMOUSELEAVE
:
3940 msg
.message
= message
;
3941 msg
.flags
= sent
|wparam
|lparam
;
3942 msg
.wParam
= wParam
;
3943 msg
.lParam
= lParam
;
3944 msg
.descr
= "dialog";
3947 if (message
== WM_INITDIALOG
) SetTimer( hwnd
, 1, 100, NULL
);
3948 if (message
== WM_TIMER
) EndDialog( hwnd
, 0 );
3952 static void test_hv_scroll_1(HWND hwnd
, INT ctl
, DWORD clear
, DWORD set
, INT min
, INT max
)
3954 DWORD style
, exstyle
;
3958 exstyle
= GetWindowLongA(hwnd
, GWL_EXSTYLE
);
3959 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
3960 /* do not be confused by WS_DLGFRAME set */
3961 if ((style
& WS_CAPTION
) == WS_CAPTION
) style
&= ~WS_CAPTION
;
3963 if (clear
) ok(style
& clear
, "style %08x should be set\n", clear
);
3964 if (set
) ok(!(style
& set
), "style %08x should not be set\n", set
);
3966 ret
= SetScrollRange(hwnd
, ctl
, min
, max
, FALSE
);
3967 ok( ret
, "SetScrollRange(%d) error %d\n", ctl
, GetLastError());
3968 if ((style
& (WS_DLGFRAME
| WS_BORDER
| WS_THICKFRAME
)) || (exstyle
& WS_EX_DLGMODALFRAME
))
3969 ok_sequence(WmSetScrollRangeHV_NC_Seq
, "SetScrollRange(SB_HORZ/SB_VERT) NC", FALSE
);
3971 ok_sequence(WmSetScrollRangeHVSeq
, "SetScrollRange(SB_HORZ/SB_VERT)", FALSE
);
3973 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
3974 if (set
) ok(style
& set
, "style %08x should be set\n", set
);
3975 if (clear
) ok(!(style
& clear
), "style %08x should not be set\n", clear
);
3977 /* a subsequent call should do nothing */
3978 ret
= SetScrollRange(hwnd
, ctl
, min
, max
, FALSE
);
3979 ok( ret
, "SetScrollRange(%d) error %d\n", ctl
, GetLastError());
3980 ok_sequence(WmEmptySeq
, "SetScrollRange(SB_HORZ/SB_VERT) empty sequence", FALSE
);
3984 ret
= GetScrollRange(hwnd
, ctl
, &xmin
, &xmax
);
3985 ok( ret
, "GetScrollRange(%d) error %d\n", ctl
, GetLastError());
3986 ok_sequence(WmEmptySeq
, "GetScrollRange(SB_HORZ/SB_VERT) empty sequence", FALSE
);
3987 ok(xmin
== min
, "unexpected min scroll value %d\n", xmin
);
3988 ok(xmax
== max
, "unexpected max scroll value %d\n", xmax
);
3991 static void test_hv_scroll_2(HWND hwnd
, INT ctl
, DWORD clear
, DWORD set
, INT min
, INT max
)
3993 DWORD style
, exstyle
;
3997 exstyle
= GetWindowLongA(hwnd
, GWL_EXSTYLE
);
3998 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
3999 /* do not be confused by WS_DLGFRAME set */
4000 if ((style
& WS_CAPTION
) == WS_CAPTION
) style
&= ~WS_CAPTION
;
4002 if (clear
) ok(style
& clear
, "style %08x should be set\n", clear
);
4003 if (set
) ok(!(style
& set
), "style %08x should not be set\n", set
);
4005 si
.cbSize
= sizeof(si
);
4006 si
.fMask
= SIF_RANGE
;
4009 SetScrollInfo(hwnd
, ctl
, &si
, TRUE
);
4010 if ((style
& (WS_DLGFRAME
| WS_BORDER
| WS_THICKFRAME
)) || (exstyle
& WS_EX_DLGMODALFRAME
))
4011 ok_sequence(WmSetScrollRangeHV_NC_Seq
, "SetScrollInfo(SB_HORZ/SB_VERT) NC", FALSE
);
4013 ok_sequence(WmSetScrollRangeHVSeq
, "SetScrollInfo(SB_HORZ/SB_VERT)", FALSE
);
4015 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
4016 if (set
) ok(style
& set
, "style %08x should be set\n", set
);
4017 if (clear
) ok(!(style
& clear
), "style %08x should not be set\n", clear
);
4019 /* a subsequent call should do nothing */
4020 SetScrollInfo(hwnd
, ctl
, &si
, TRUE
);
4021 if (style
& WS_HSCROLL
)
4022 ok_sequence(WmSetScrollRangeHSeq_empty
, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE
);
4023 else if (style
& WS_VSCROLL
)
4024 ok_sequence(WmSetScrollRangeVSeq_empty
, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE
);
4026 ok_sequence(WmEmptySeq
, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE
);
4028 si
.fMask
= SIF_PAGE
;
4030 SetScrollInfo(hwnd
, ctl
, &si
, FALSE
);
4031 ok_sequence(WmEmptySeq
, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE
);
4035 SetScrollInfo(hwnd
, ctl
, &si
, FALSE
);
4036 ok_sequence(WmEmptySeq
, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE
);
4038 si
.fMask
= SIF_RANGE
;
4039 si
.nMin
= 0xdeadbeef;
4040 si
.nMax
= 0xdeadbeef;
4041 ret
= GetScrollInfo(hwnd
, ctl
, &si
);
4042 ok( ret
, "GetScrollInfo error %d\n", GetLastError());
4043 ok_sequence(WmEmptySeq
, "GetScrollRange(SB_HORZ/SB_VERT) empty sequence", FALSE
);
4044 ok(si
.nMin
== min
, "unexpected min scroll value %d\n", si
.nMin
);
4045 ok(si
.nMax
== max
, "unexpected max scroll value %d\n", si
.nMax
);
4048 /* Win9x sends WM_USER+xxx while and NT versions send SBM_xxx messages */
4049 static void test_scroll_messages(HWND hwnd
)
4060 ret
= GetScrollRange(hwnd
, SB_CTL
, &min
, &max
);
4061 ok( ret
, "GetScrollRange error %d\n", GetLastError());
4062 if (sequence
->message
!= WmGetScrollRangeSeq
[0].message
)
4063 trace("GetScrollRange(SB_CTL) generated unknown message %04x\n", sequence
->message
);
4064 /* values of min and max are undefined */
4067 ret
= SetScrollRange(hwnd
, SB_CTL
, 10, 150, FALSE
);
4068 ok( ret
, "SetScrollRange error %d\n", GetLastError());
4069 if (sequence
->message
!= WmSetScrollRangeSeq
[0].message
)
4070 trace("SetScrollRange(SB_CTL) generated unknown message %04x\n", sequence
->message
);
4075 ret
= GetScrollRange(hwnd
, SB_CTL
, &min
, &max
);
4076 ok( ret
, "GetScrollRange error %d\n", GetLastError());
4077 if (sequence
->message
!= WmGetScrollRangeSeq
[0].message
)
4078 trace("GetScrollRange(SB_CTL) generated unknown message %04x\n", sequence
->message
);
4079 /* values of min and max are undefined */
4082 si
.cbSize
= sizeof(si
);
4083 si
.fMask
= SIF_RANGE
;
4086 SetScrollInfo(hwnd
, SB_CTL
, &si
, FALSE
);
4087 if (sequence
->message
!= WmSetScrollRangeSeq
[0].message
)
4088 trace("SetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence
->message
);
4091 si
.fMask
= SIF_PAGE
;
4093 SetScrollInfo(hwnd
, SB_CTL
, &si
, FALSE
);
4094 if (sequence
->message
!= WmSetScrollRangeSeq
[0].message
)
4095 trace("SetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence
->message
);
4100 SetScrollInfo(hwnd
, SB_CTL
, &si
, FALSE
);
4101 if (sequence
->message
!= WmSetScrollRangeSeq
[0].message
)
4102 trace("SetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence
->message
);
4105 si
.fMask
= SIF_RANGE
;
4106 si
.nMin
= 0xdeadbeef;
4107 si
.nMax
= 0xdeadbeef;
4108 ret
= GetScrollInfo(hwnd
, SB_CTL
, &si
);
4109 ok( ret
, "GetScrollInfo error %d\n", GetLastError());
4110 if (sequence
->message
!= WmGetScrollInfoSeq
[0].message
)
4111 trace("GetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence
->message
);
4112 /* values of min and max are undefined */
4115 /* set WS_HSCROLL */
4116 test_hv_scroll_1(hwnd
, SB_HORZ
, 0, WS_HSCROLL
, 10, 150);
4117 /* clear WS_HSCROLL */
4118 test_hv_scroll_1(hwnd
, SB_HORZ
, WS_HSCROLL
, 0, 0, 0);
4120 /* set WS_HSCROLL */
4121 test_hv_scroll_2(hwnd
, SB_HORZ
, 0, WS_HSCROLL
, 10, 150);
4122 /* clear WS_HSCROLL */
4123 test_hv_scroll_2(hwnd
, SB_HORZ
, WS_HSCROLL
, 0, 0, 0);
4125 /* set WS_VSCROLL */
4126 test_hv_scroll_1(hwnd
, SB_VERT
, 0, WS_VSCROLL
, 10, 150);
4127 /* clear WS_VSCROLL */
4128 test_hv_scroll_1(hwnd
, SB_VERT
, WS_VSCROLL
, 0, 0, 0);
4130 /* set WS_VSCROLL */
4131 test_hv_scroll_2(hwnd
, SB_VERT
, 0, WS_VSCROLL
, 10, 150);
4132 /* clear WS_VSCROLL */
4133 test_hv_scroll_2(hwnd
, SB_VERT
, WS_VSCROLL
, 0, 0, 0);
4136 static void test_showwindow(void)
4141 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW
,
4142 100, 100, 200, 200, 0, 0, 0, NULL
);
4143 ok (hwnd
!= 0, "Failed to create overlapped window\n");
4144 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
4145 0, 0, 10, 10, hwnd
, 0, 0, NULL
);
4146 ok (hchild
!= 0, "Failed to create child\n");
4149 /* ShowWindow( SW_SHOWNA) for invisible top level window */
4150 trace("calling ShowWindow( SW_SHOWNA) for invisible top level window\n");
4151 ok( ShowWindow(hwnd
, SW_SHOWNA
) == FALSE
, "ShowWindow: window was visible\n" );
4152 ok_sequence(WmSHOWNATopInvisible
, "ShowWindow(SW_SHOWNA) on invisible top level window", FALSE
);
4154 /* ShowWindow( SW_SHOWNA) for now visible top level window */
4155 trace("calling ShowWindow( SW_SHOWNA) for now visible top level window\n");
4156 ok( ShowWindow(hwnd
, SW_SHOWNA
) != FALSE
, "ShowWindow: window was invisible\n" );
4157 ok_sequence(WmSHOWNATopVisible
, "ShowWindow(SW_SHOWNA) on visible top level window", FALSE
);
4158 /* back to invisible */
4159 ShowWindow(hchild
, SW_HIDE
);
4160 ShowWindow(hwnd
, SW_HIDE
);
4162 /* ShowWindow(SW_SHOWNA) with child and parent invisible */
4163 trace("calling ShowWindow( SW_SHOWNA) for invisible child with invisible parent\n");
4164 ok( ShowWindow(hchild
, SW_SHOWNA
) == FALSE
, "ShowWindow: window was visible\n" );
4165 ok_sequence(WmSHOWNAChildInvisParInvis
, "ShowWindow(SW_SHOWNA) invisible child and parent", FALSE
);
4166 /* ShowWindow(SW_SHOWNA) with child visible and parent invisible */
4167 ok( ShowWindow(hchild
, SW_SHOW
) != FALSE
, "ShowWindow: window was invisible\n" );
4169 trace("calling ShowWindow( SW_SHOWNA) for the visible child and invisible parent\n");
4170 ok( ShowWindow(hchild
, SW_SHOWNA
) != FALSE
, "ShowWindow: window was invisible\n" );
4171 ok_sequence(WmSHOWNAChildVisParInvis
, "ShowWindow(SW_SHOWNA) visible child and invisible parent", FALSE
);
4172 /* ShowWindow(SW_SHOWNA) with child visible and parent visible */
4173 ShowWindow( hwnd
, SW_SHOW
);
4175 trace("calling ShowWindow( SW_SHOWNA) for the visible child and parent\n");
4176 ok( ShowWindow(hchild
, SW_SHOWNA
) != FALSE
, "ShowWindow: window was invisible\n" );
4177 ok_sequence(WmSHOWNAChildVisParVis
, "ShowWindow(SW_SHOWNA) for the visible child and parent", FALSE
);
4179 /* ShowWindow(SW_SHOWNA) with child invisible and parent visible */
4180 ShowWindow( hchild
, SW_HIDE
);
4182 trace("calling ShowWindow( SW_SHOWNA) for the invisible child and visible parent\n");
4183 ok( ShowWindow(hchild
, SW_SHOWNA
) == FALSE
, "ShowWindow: window was visible\n" );
4184 ok_sequence(WmSHOWNAChildInvisParVis
, "ShowWindow(SW_SHOWNA) for the invisible child and visible parent", FALSE
);
4187 ok(GetCapture() == hchild
, "wrong capture window %p\n", GetCapture());
4188 DestroyWindow(hchild
);
4189 ok(!GetCapture(), "wrong capture window %p\n", GetCapture());
4191 DestroyWindow(hwnd
);
4196 * 1. Create invisible maximized popup window.
4197 * 2. Move and resize it.
4198 * 3. Show it maximized.
4200 trace("calling CreateWindowExA( WS_MAXIMIZE ) for invisible maximized popup window\n");
4201 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP
| WS_MAXIMIZE
,
4202 100, 100, 200, 200, 0, 0, 0, NULL
);
4203 ok (hwnd
!= 0, "Failed to create popup window\n");
4204 ok(IsZoomed(hwnd
), "window should be maximized\n");
4205 ok_sequence(WmCreateInvisibleMaxPopupSeq
, "CreateWindow(WS_MAXIMIZED):popup", FALSE
);
4207 GetWindowRect(hwnd
, &rc
);
4208 ok( rc
.right
-rc
.left
== GetSystemMetrics(SM_CXSCREEN
) &&
4209 rc
.bottom
-rc
.top
== GetSystemMetrics(SM_CYSCREEN
),
4210 "Invalid maximized size before ShowWindow (%d,%d)-(%d,%d)\n",
4211 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4212 /* Reset window's size & position */
4213 SetWindowPos(hwnd
, 0, 10, 10, 200, 200, SWP_NOZORDER
| SWP_NOACTIVATE
);
4214 ok(IsZoomed(hwnd
), "window should be maximized\n");
4217 trace("calling ShowWindow( SW_SHOWMAXIMIZE ) for invisible maximized popup window\n");
4218 ShowWindow(hwnd
, SW_SHOWMAXIMIZED
);
4219 ok(IsZoomed(hwnd
), "window should be maximized\n");
4220 ok_sequence(WmShowMaxPopupResizedSeq
, "ShowWindow(SW_SHOWMAXIMIZED):invisible maximized and resized popup", FALSE
);
4222 GetWindowRect(hwnd
, &rc
);
4223 ok( rc
.right
-rc
.left
== GetSystemMetrics(SM_CXSCREEN
) &&
4224 rc
.bottom
-rc
.top
== GetSystemMetrics(SM_CYSCREEN
),
4225 "Invalid maximized size after ShowWindow (%d,%d)-(%d,%d)\n",
4226 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4227 DestroyWindow(hwnd
);
4231 * 1. Create invisible maximized popup window.
4232 * 2. Show it maximized.
4234 trace("calling CreateWindowExA( WS_MAXIMIZE ) for invisible maximized popup window\n");
4235 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP
| WS_MAXIMIZE
,
4236 100, 100, 200, 200, 0, 0, 0, NULL
);
4237 ok (hwnd
!= 0, "Failed to create popup window\n");
4238 ok(IsZoomed(hwnd
), "window should be maximized\n");
4239 ok_sequence(WmCreateInvisibleMaxPopupSeq
, "CreateWindow(WS_MAXIMIZED):popup", FALSE
);
4241 trace("calling ShowWindow( SW_SHOWMAXIMIZE ) for invisible maximized popup window\n");
4242 ShowWindow(hwnd
, SW_SHOWMAXIMIZED
);
4243 ok(IsZoomed(hwnd
), "window should be maximized\n");
4244 ok_sequence(WmShowMaxPopupSeq
, "ShowWindow(SW_SHOWMAXIMIZED):invisible maximized popup", FALSE
);
4245 DestroyWindow(hwnd
);
4249 * 1. Create visible maximized popup window.
4251 trace("calling CreateWindowExA( WS_MAXIMIZE ) for maximized popup window\n");
4252 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP
| WS_MAXIMIZE
| WS_VISIBLE
,
4253 100, 100, 200, 200, 0, 0, 0, NULL
);
4254 ok (hwnd
!= 0, "Failed to create popup window\n");
4255 ok(IsZoomed(hwnd
), "window should be maximized\n");
4256 ok_sequence(WmCreateMaxPopupSeq
, "CreateWindow(WS_MAXIMIZED):popup", FALSE
);
4257 DestroyWindow(hwnd
);
4261 * 1. Create visible popup window.
4264 trace("calling CreateWindowExA( WS_VISIBLE ) for popup window\n");
4265 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP
| WS_VISIBLE
,
4266 100, 100, 200, 200, 0, 0, 0, NULL
);
4267 ok (hwnd
!= 0, "Failed to create popup window\n");
4268 ok(!IsZoomed(hwnd
), "window should NOT be maximized\n");
4269 ok_sequence(WmCreatePopupSeq
, "CreateWindow(WS_VISIBLE):popup", FALSE
);
4271 trace("calling ShowWindow( SW_SHOWMAXIMIZE ) for visible popup window\n");
4272 ShowWindow(hwnd
, SW_SHOWMAXIMIZED
);
4273 ok(IsZoomed(hwnd
), "window should be maximized\n");
4274 ok_sequence(WmShowVisMaxPopupSeq
, "ShowWindow(SW_SHOWMAXIMIZED):popup", FALSE
);
4275 DestroyWindow(hwnd
);
4279 static void test_sys_menu(void)
4285 hwnd
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
4286 100, 100, 200, 200, 0, 0, 0, NULL
);
4287 ok (hwnd
!= 0, "Failed to create overlapped window\n");
4291 /* test existing window without CS_NOCLOSE style */
4292 hmenu
= GetSystemMenu(hwnd
, FALSE
);
4293 ok(hmenu
!= 0, "GetSystemMenu error %d\n", GetLastError());
4295 state
= GetMenuState(hmenu
, SC_CLOSE
, MF_BYCOMMAND
);
4296 ok(state
!= 0xffffffff, "wrong SC_CLOSE state %x\n", state
);
4297 ok(!(state
& (MF_DISABLED
| MF_GRAYED
)), "wrong SC_CLOSE state %x\n", state
);
4299 EnableMenuItem(hmenu
, SC_CLOSE
, MF_BYCOMMAND
| MF_GRAYED
);
4300 ok_sequence(WmEmptySeq
, "WmEnableMenuItem", FALSE
);
4302 state
= GetMenuState(hmenu
, SC_CLOSE
, MF_BYCOMMAND
);
4303 ok(state
!= 0xffffffff, "wrong SC_CLOSE state %x\n", state
);
4304 ok((state
& (MF_DISABLED
| MF_GRAYED
)) == MF_GRAYED
, "wrong SC_CLOSE state %x\n", state
);
4306 EnableMenuItem(hmenu
, SC_CLOSE
, 0);
4307 ok_sequence(WmEmptySeq
, "WmEnableMenuItem", FALSE
);
4309 state
= GetMenuState(hmenu
, SC_CLOSE
, MF_BYCOMMAND
);
4310 ok(state
!= 0xffffffff, "wrong SC_CLOSE state %x\n", state
);
4311 ok(!(state
& (MF_DISABLED
| MF_GRAYED
)), "wrong SC_CLOSE state %x\n", state
);
4313 /* test whether removing WS_SYSMENU destroys a system menu */
4314 SetWindowLongW(hwnd
, GWL_STYLE
, WS_POPUP
);
4315 SetWindowPos(hwnd
, 0, 0, 0, 0, 0, SWP_NOZORDER
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_FRAMECHANGED
);
4317 hmenu
= GetSystemMenu(hwnd
, FALSE
);
4318 ok(hmenu
!= 0, "GetSystemMenu error %d\n", GetLastError());
4320 DestroyWindow(hwnd
);
4322 /* test new window with CS_NOCLOSE style */
4323 hwnd
= CreateWindowExA(0, "NoCloseWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
4324 100, 100, 200, 200, 0, 0, 0, NULL
);
4325 ok (hwnd
!= 0, "Failed to create overlapped window\n");
4327 hmenu
= GetSystemMenu(hwnd
, FALSE
);
4328 ok(hmenu
!= 0, "GetSystemMenu error %d\n", GetLastError());
4330 state
= GetMenuState(hmenu
, SC_CLOSE
, MF_BYCOMMAND
);
4331 ok(state
== 0xffffffff, "wrong SC_CLOSE state %x\n", state
);
4333 DestroyWindow(hwnd
);
4335 /* test new window without WS_SYSMENU style */
4336 hwnd
= CreateWindowExA(0, "NoCloseWindowClass", NULL
, WS_OVERLAPPEDWINDOW
& ~WS_SYSMENU
,
4337 100, 100, 200, 200, 0, 0, 0, NULL
);
4338 ok(hwnd
!= 0, "Failed to create overlapped window\n");
4340 hmenu
= GetSystemMenu(hwnd
, FALSE
);
4341 ok(!hmenu
, "GetSystemMenu error %d\n", GetLastError());
4343 DestroyWindow(hwnd
);
4346 /* For shown WS_OVERLAPPEDWINDOW */
4347 static const struct message WmSetIcon_1
[] = {
4348 { WM_SETICON
, sent
},
4349 { 0x00AE, sent
|defwinproc
|optional
}, /* XP */
4350 { WM_GETTEXT
, sent
|defwinproc
|optional
},
4351 { WM_GETTEXT
, sent
|defwinproc
|optional
}, /* XP sends a duplicate */
4355 /* For WS_POPUP and hidden WS_OVERLAPPEDWINDOW */
4356 static const struct message WmSetIcon_2
[] = {
4357 { WM_SETICON
, sent
},
4361 /* Sending undocumented 0x3B message with wparam = 0x8000000b */
4362 static const struct message WmInitEndSession
[] = {
4364 { WM_QUERYENDSESSION
, sent
|defwinproc
|wparam
|lparam
, 0, ENDSESSION_LOGOFF
},
4368 /* Sending undocumented 0x3B message with wparam = 0x0000000b */
4369 static const struct message WmInitEndSession_2
[] = {
4371 { WM_QUERYENDSESSION
, sent
|defwinproc
|wparam
|lparam
, 0, 0 },
4375 /* Sending undocumented 0x3B message with wparam = 0x80000008 */
4376 static const struct message WmInitEndSession_3
[] = {
4378 { WM_ENDSESSION
, sent
|defwinproc
|wparam
|lparam
, 0, ENDSESSION_LOGOFF
},
4382 /* Sending undocumented 0x3B message with wparam = 0x00000008 */
4383 static const struct message WmInitEndSession_4
[] = {
4385 { WM_ENDSESSION
, sent
|defwinproc
|wparam
|lparam
, 0, 0 },
4389 /* Sending undocumented 0x3B message with wparam = 0x80000001 */
4390 static const struct message WmInitEndSession_5
[] = {
4392 { WM_ENDSESSION
, sent
|defwinproc
/*|wparam*/|lparam
, 1, ENDSESSION_LOGOFF
},
4396 static const struct message WmOptionalPaint
[] = {
4397 { WM_PAINT
, sent
|optional
},
4398 { WM_NCPAINT
, sent
|beginpaint
|optional
},
4399 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
4400 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
4404 static const struct message WmZOrder
[] = {
4405 { WM_WINDOWPOSCHANGING
, sent
|wparam
, 0, 0 },
4406 { WM_GETMINMAXINFO
, sent
|defwinproc
|wparam
, 0, 0 },
4407 { HCBT_ACTIVATE
, hook
},
4408 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
4409 { WM_WINDOWPOSCHANGING
, sent
|wparam
, 3, 0 },
4410 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOREDRAW
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
, 0 },
4411 { WM_GETTEXT
, sent
|optional
},
4412 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
4413 { WM_ACTIVATEAPP
, sent
|wparam
, 1, 0 },
4414 { WM_NCACTIVATE
, sent
|lparam
, 1, 0 },
4415 { WM_GETTEXT
, sent
|defwinproc
|optional
},
4416 { WM_GETTEXT
, sent
|defwinproc
|optional
},
4417 { WM_ACTIVATE
, sent
|wparam
|lparam
, 1, 0 },
4418 { HCBT_SETFOCUS
, hook
},
4419 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
4420 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
4421 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
4422 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
4423 { WM_GETTEXT
, sent
|optional
},
4424 { WM_NCCALCSIZE
, sent
|optional
},
4428 static void test_MsgWaitForMultipleObjects(HWND hwnd
)
4433 ret
= MsgWaitForMultipleObjects(0, NULL
, FALSE
, 0, QS_POSTMESSAGE
);
4434 ok(ret
== WAIT_TIMEOUT
, "MsgWaitForMultipleObjects returned %x\n", ret
);
4436 PostMessageA(hwnd
, WM_USER
, 0, 0);
4438 ret
= MsgWaitForMultipleObjects(0, NULL
, FALSE
, 0, QS_POSTMESSAGE
);
4439 ok(ret
== WAIT_OBJECT_0
, "MsgWaitForMultipleObjects returned %x\n", ret
);
4441 ok(PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
), "PeekMessage should succeed\n");
4442 ok(msg
.message
== WM_USER
, "got %04x instead of WM_USER\n", msg
.message
);
4444 ret
= MsgWaitForMultipleObjects(0, NULL
, FALSE
, 0, QS_POSTMESSAGE
);
4445 ok(ret
== WAIT_TIMEOUT
, "MsgWaitForMultipleObjects returned %x\n", ret
);
4447 PostMessageA(hwnd
, WM_USER
, 0, 0);
4449 ret
= MsgWaitForMultipleObjects(0, NULL
, FALSE
, 0, QS_POSTMESSAGE
);
4450 ok(ret
== WAIT_OBJECT_0
, "MsgWaitForMultipleObjects returned %x\n", ret
);
4452 ok(PeekMessageA( &msg
, 0, 0, 0, PM_NOREMOVE
), "PeekMessage should succeed\n");
4453 ok(msg
.message
== WM_USER
, "got %04x instead of WM_USER\n", msg
.message
);
4455 /* shows QS_POSTMESSAGE flag is cleared in the PeekMessage call */
4456 ret
= MsgWaitForMultipleObjects(0, NULL
, FALSE
, 0, QS_POSTMESSAGE
);
4457 ok(ret
== WAIT_TIMEOUT
, "MsgWaitForMultipleObjects returned %x\n", ret
);
4459 PostMessageA(hwnd
, WM_USER
, 0, 0);
4461 /* new incoming message causes it to become signaled again */
4462 ret
= MsgWaitForMultipleObjects(0, NULL
, FALSE
, 0, QS_POSTMESSAGE
);
4463 ok(ret
== WAIT_OBJECT_0
, "MsgWaitForMultipleObjects returned %x\n", ret
);
4465 ok(PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
), "PeekMessage should succeed\n");
4466 ok(msg
.message
== WM_USER
, "got %04x instead of WM_USER\n", msg
.message
);
4467 ok(PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
), "PeekMessage should succeed\n");
4468 ok(msg
.message
== WM_USER
, "got %04x instead of WM_USER\n", msg
.message
);
4471 /* test if we receive the right sequence of messages */
4472 static void test_messages(void)
4474 HWND hwnd
, hparent
, hchild
;
4475 HWND hchild2
, hbutton
;
4482 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW
,
4483 100, 100, 200, 200, 0, 0, 0, NULL
);
4484 ok (hwnd
!= 0, "Failed to create overlapped window\n");
4485 ok_sequence(WmCreateOverlappedSeq
, "CreateWindow:overlapped", FALSE
);
4487 /* test ShowWindow(SW_HIDE) on a newly created invisible window */
4488 ok( ShowWindow(hwnd
, SW_HIDE
) == FALSE
, "ShowWindow: window was visible\n" );
4489 ok_sequence(WmEmptySeq
, "ShowWindow(SW_HIDE):overlapped, invisible", FALSE
);
4491 /* test WM_SETREDRAW on a not visible top level window */
4492 test_WM_SETREDRAW(hwnd
);
4494 SetWindowPos(hwnd
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
);
4496 ok_sequence(WmSWP_ShowOverlappedSeq
, "SetWindowPos:SWP_SHOWWINDOW:overlapped", FALSE
);
4497 ok(IsWindowVisible(hwnd
), "window should be visible at this point\n");
4499 ok(GetActiveWindow() == hwnd
, "window should be active\n");
4500 ok(GetFocus() == hwnd
, "window should have input focus\n");
4501 ShowWindow(hwnd
, SW_HIDE
);
4503 ok_sequence(WmHideOverlappedSeq
, "ShowWindow(SW_HIDE):overlapped", FALSE
);
4505 ShowWindow(hwnd
, SW_SHOW
);
4507 ok_sequence(WmShowOverlappedSeq
, "ShowWindow(SW_SHOW):overlapped", TRUE
);
4509 ShowWindow(hwnd
, SW_HIDE
);
4511 ok_sequence(WmHideOverlappedSeq
, "ShowWindow(SW_HIDE):overlapped", FALSE
);
4513 ShowWindow(hwnd
, SW_SHOWMAXIMIZED
);
4515 ok_sequence(WmShowMaxOverlappedSeq
, "ShowWindow(SW_SHOWMAXIMIZED):overlapped", TRUE
);
4518 if (GetWindowLongW( hwnd
, GWL_STYLE
) & WS_MAXIMIZE
)
4520 ShowWindow(hwnd
, SW_RESTORE
);
4522 ok_sequence(WmShowRestoreMaxOverlappedSeq
, "ShowWindow(SW_RESTORE):overlapped", TRUE
);
4526 ShowWindow(hwnd
, SW_MINIMIZE
);
4528 ok_sequence(WmShowMinOverlappedSeq
, "ShowWindow(SW_SHOWMINIMIZED):overlapped", TRUE
);
4531 if (GetWindowLongW( hwnd
, GWL_STYLE
) & WS_MINIMIZE
)
4533 ShowWindow(hwnd
, SW_RESTORE
);
4535 ok_sequence(WmShowRestoreMinOverlappedSeq
, "ShowWindow(SW_RESTORE):overlapped", TRUE
);
4539 ShowWindow(hwnd
, SW_SHOW
);
4541 ok_sequence(WmOptionalPaint
, "ShowWindow(SW_SHOW):overlapped already visible", FALSE
);
4543 SetWindowPos(hwnd
, 0,0,0,0,0, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
);
4544 ok_sequence(WmSWP_HideOverlappedSeq
, "SetWindowPos:SWP_HIDEWINDOW:overlapped", FALSE
);
4545 ok(!IsWindowVisible(hwnd
), "window should not be visible at this point\n");
4546 ok(GetActiveWindow() == hwnd
, "window should still be active\n");
4548 /* test WM_SETREDRAW on a visible top level window */
4549 ShowWindow(hwnd
, SW_SHOW
);
4551 test_WM_SETREDRAW(hwnd
);
4553 trace("testing scroll APIs on a visible top level window %p\n", hwnd
);
4554 test_scroll_messages(hwnd
);
4556 /* test resizing and moving */
4557 SetWindowPos( hwnd
, 0, 0, 0, 300, 300, SWP_NOMOVE
|SWP_NOACTIVATE
);
4558 ok_sequence(WmSWP_ResizeSeq
, "SetWindowPos:Resize", FALSE
);
4561 SetWindowPos( hwnd
, 0, 200, 200, 0, 0, SWP_NOSIZE
|SWP_NOACTIVATE
);
4562 ok_sequence(WmSWP_MoveSeq
, "SetWindowPos:Move", FALSE
);
4565 SetWindowPos( hwnd
, 0, 200, 200, 250, 250, SWP_NOZORDER
|SWP_NOACTIVATE
);
4566 ok_sequence(WmSWP_ResizeNoZOrder
, "SetWindowPos:WmSWP_ResizeNoZOrder", FALSE
);
4570 /* popups don't get WM_GETMINMAXINFO */
4571 SetWindowLongW( hwnd
, GWL_STYLE
, WS_VISIBLE
|WS_POPUP
);
4572 SetWindowPos( hwnd
, 0, 0, 0, 0, 0, SWP_NOZORDER
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_FRAMECHANGED
);
4574 SetWindowPos( hwnd
, 0, 0, 0, 200, 200, SWP_NOMOVE
|SWP_NOACTIVATE
);
4575 ok_sequence(WmSWP_ResizePopupSeq
, "SetWindowPos:ResizePopup", FALSE
);
4577 DestroyWindow(hwnd
);
4578 ok_sequence(WmDestroyOverlappedSeq
, "DestroyWindow:overlapped", FALSE
);
4580 hparent
= CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
4581 100, 100, 200, 200, 0, 0, 0, NULL
);
4582 ok (hparent
!= 0, "Failed to create parent window\n");
4585 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
| WS_MAXIMIZE
,
4586 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4587 ok (hchild
!= 0, "Failed to create child window\n");
4588 ok_sequence(WmCreateMaximizedChildSeq
, "CreateWindow:maximized child", FALSE
);
4589 DestroyWindow(hchild
);
4592 /* visible child window with a caption */
4593 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child",
4594 WS_CHILD
| WS_VISIBLE
| WS_CAPTION
,
4595 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4596 ok (hchild
!= 0, "Failed to create child window\n");
4597 ok_sequence(WmCreateVisibleChildSeq
, "CreateWindow:visible child", FALSE
);
4599 trace("testing scroll APIs on a visible child window %p\n", hchild
);
4600 test_scroll_messages(hchild
);
4602 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
);
4603 ok_sequence(WmShowChildSeq_4
, "SetWindowPos(SWP_SHOWWINDOW):child with a caption", FALSE
);
4605 DestroyWindow(hchild
);
4608 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
4609 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4610 ok (hchild
!= 0, "Failed to create child window\n");
4611 ok_sequence(WmCreateChildSeq
, "CreateWindow:child", FALSE
);
4613 hchild2
= CreateWindowExA(0, "SimpleWindowClass", "Test child2", WS_CHILD
,
4614 100, 100, 50, 50, hparent
, 0, 0, NULL
);
4615 ok (hchild2
!= 0, "Failed to create child2 window\n");
4618 hbutton
= CreateWindowExA(0, "TestWindowClass", "Test button", WS_CHILD
,
4619 0, 100, 50, 50, hchild
, 0, 0, NULL
);
4620 ok (hbutton
!= 0, "Failed to create button window\n");
4622 /* test WM_SETREDRAW on a not visible child window */
4623 test_WM_SETREDRAW(hchild
);
4625 ShowWindow(hchild
, SW_SHOW
);
4626 ok_sequence(WmShowChildSeq
, "ShowWindow(SW_SHOW):child", FALSE
);
4628 /* check parent messages too */
4629 log_all_parent_messages
++;
4630 ShowWindow(hchild
, SW_HIDE
);
4631 ok_sequence(WmHideChildSeq2
, "ShowWindow(SW_HIDE):child", FALSE
);
4632 log_all_parent_messages
--;
4634 ShowWindow(hchild
, SW_SHOW
);
4635 ok_sequence(WmShowChildSeq
, "ShowWindow(SW_SHOW):child", FALSE
);
4637 ShowWindow(hchild
, SW_HIDE
);
4638 ok_sequence(WmHideChildSeq
, "ShowWindow(SW_HIDE):child", FALSE
);
4640 ShowWindow(hchild
, SW_SHOW
);
4641 ok_sequence(WmShowChildSeq
, "ShowWindow(SW_SHOW):child", FALSE
);
4643 /* test WM_SETREDRAW on a visible child window */
4644 test_WM_SETREDRAW(hchild
);
4646 log_all_parent_messages
++;
4647 MoveWindow(hchild
, 10, 10, 20, 20, TRUE
);
4648 ok_sequence(WmResizingChildWithMoveWindowSeq
, "MoveWindow:child", FALSE
);
4649 log_all_parent_messages
--;
4651 ShowWindow(hchild
, SW_HIDE
);
4653 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
);
4654 ok_sequence(WmShowChildSeq_2
, "SetWindowPos:show_child_2", FALSE
);
4656 ShowWindow(hchild
, SW_HIDE
);
4658 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
);
4659 ok_sequence(WmShowChildSeq_3
, "SetWindowPos:show_child_3", FALSE
);
4661 /* DestroyWindow sequence below expects that a child has focus */
4665 DestroyWindow(hchild
);
4666 ok_sequence(WmDestroyChildSeq
, "DestroyWindow:child", FALSE
);
4667 DestroyWindow(hchild2
);
4668 DestroyWindow(hbutton
);
4671 hchild
= CreateWindowExA(0, "TestWindowClass", "Test Child Popup", WS_CHILD
| WS_POPUP
,
4672 0, 0, 100, 100, hparent
, 0, 0, NULL
);
4673 ok (hchild
!= 0, "Failed to create child popup window\n");
4674 ok_sequence(WmCreateChildPopupSeq
, "CreateWindow:child_popup", FALSE
);
4675 DestroyWindow(hchild
);
4677 /* test what happens to a window which sets WS_VISIBLE in WM_CREATE */
4679 hchild
= CreateWindowExA(0, "TestPopupClass", "Test Popup", WS_POPUP
,
4680 0, 0, 100, 100, hparent
, 0, 0, NULL
);
4681 ok (hchild
!= 0, "Failed to create popup window\n");
4682 ok_sequence(WmCreateInvisiblePopupSeq
, "CreateWindow:invisible_popup", FALSE
);
4683 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
4684 ok(IsWindowVisible(hchild
), "IsWindowVisible() should return TRUE\n");
4686 ShowWindow(hchild
, SW_SHOW
);
4687 ok_sequence(WmEmptySeq
, "ShowWindow:show_visible_popup", FALSE
);
4689 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOZORDER
);
4690 ok_sequence(WmShowVisiblePopupSeq_2
, "SetWindowPos:show_visible_popup_2", FALSE
);
4692 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
);
4693 ok_sequence(WmShowVisiblePopupSeq_3
, "SetWindowPos:show_visible_popup_3", FALSE
);
4694 DestroyWindow(hchild
);
4696 /* this time add WS_VISIBLE for CreateWindowEx, but this fact actually
4697 * changes nothing in message sequences.
4700 hchild
= CreateWindowExA(0, "TestPopupClass", "Test Popup", WS_POPUP
| WS_VISIBLE
,
4701 0, 0, 100, 100, hparent
, 0, 0, NULL
);
4702 ok (hchild
!= 0, "Failed to create popup window\n");
4703 ok_sequence(WmCreateInvisiblePopupSeq
, "CreateWindow:invisible_popup", FALSE
);
4704 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
4705 ok(IsWindowVisible(hchild
), "IsWindowVisible() should return TRUE\n");
4707 ShowWindow(hchild
, SW_SHOW
);
4708 ok_sequence(WmEmptySeq
, "ShowWindow:show_visible_popup", FALSE
);
4710 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOZORDER
);
4711 ok_sequence(WmShowVisiblePopupSeq_2
, "SetWindowPos:show_visible_popup_2", FALSE
);
4712 DestroyWindow(hchild
);
4715 hwnd
= CreateWindowExA(WS_EX_DLGMODALFRAME
, "TestDialogClass", NULL
, WS_VISIBLE
|WS_CAPTION
|WS_SYSMENU
|WS_DLGFRAME
,
4716 0, 0, 100, 100, hparent
, 0, 0, NULL
);
4717 ok(hwnd
!= 0, "Failed to create custom dialog window\n");
4718 ok_sequence(WmCreateCustomDialogSeq
, "CreateCustomDialog", TRUE
);
4721 trace("testing scroll APIs on a visible dialog %p\n", hwnd);
4722 test_scroll_messages(hwnd);
4728 SendMessage(hwnd
, WM_NULL
, 0, 0);
4731 after_end_dialog
= 1;
4732 EndDialog( hwnd
, 0 );
4733 ok_sequence(WmEndCustomDialogSeq
, "EndCustomDialog", FALSE
);
4735 DestroyWindow(hwnd
);
4736 after_end_dialog
= 0;
4739 hwnd
= CreateWindowExA(0, "TestDialogClass", NULL
, WS_POPUP
,
4740 0, 0, 100, 100, 0, 0, GetModuleHandleA(0), NULL
);
4741 ok(hwnd
!= 0, "Failed to create custom dialog window\n");
4743 trace("call ShowWindow(%p, SW_SHOW)\n", hwnd
);
4744 ShowWindow(hwnd
, SW_SHOW
);
4745 ok_sequence(WmShowCustomDialogSeq
, "ShowCustomDialog", TRUE
);
4746 DestroyWindow(hwnd
);
4749 DialogBoxA( 0, "TEST_DIALOG", hparent
, TestModalDlgProcA
);
4750 ok_sequence(WmModalDialogSeq
, "ModalDialog", TRUE
);
4752 DestroyWindow(hparent
);
4755 /* Message sequence for SetMenu */
4756 ok(!DrawMenuBar(hwnd
), "DrawMenuBar should return FALSE for a window without a menu\n");
4757 ok_sequence(WmEmptySeq
, "DrawMenuBar for a window without a menu", FALSE
);
4759 hmenu
= CreateMenu();
4760 ok (hmenu
!= 0, "Failed to create menu\n");
4761 ok (InsertMenuA(hmenu
, -1, MF_BYPOSITION
, 0x1000, "foo"), "InsertMenu failed\n");
4762 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW
,
4763 100, 100, 200, 200, 0, hmenu
, 0, NULL
);
4764 ok_sequence(WmCreateOverlappedSeq
, "CreateWindow:overlapped", FALSE
);
4765 ok (SetMenu(hwnd
, 0), "SetMenu\n");
4766 ok_sequence(WmSetMenuNonVisibleSizeChangeSeq
, "SetMenu:NonVisibleSizeChange", FALSE
);
4767 ok (SetMenu(hwnd
, 0), "SetMenu\n");
4768 ok_sequence(WmSetMenuNonVisibleNoSizeChangeSeq
, "SetMenu:NonVisibleNoSizeChange", FALSE
);
4769 ShowWindow(hwnd
, SW_SHOW
);
4770 UpdateWindow( hwnd
);
4773 ok (SetMenu(hwnd
, 0), "SetMenu\n");
4774 ok_sequence(WmSetMenuVisibleNoSizeChangeSeq
, "SetMenu:VisibleNoSizeChange", FALSE
);
4775 ok (SetMenu(hwnd
, hmenu
), "SetMenu\n");
4776 ok_sequence(WmSetMenuVisibleSizeChangeSeq
, "SetMenu:VisibleSizeChange", FALSE
);
4778 UpdateWindow( hwnd
);
4781 ok(DrawMenuBar(hwnd
), "DrawMenuBar\n");
4783 ok_sequence(WmDrawMenuBarSeq
, "DrawMenuBar", FALSE
);
4785 DestroyWindow(hwnd
);
4788 /* Message sequence for EnableWindow */
4789 hparent
= CreateWindowExA(0, "TestWindowClass", "Test parent", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
4790 100, 100, 200, 200, 0, 0, 0, NULL
);
4791 ok (hparent
!= 0, "Failed to create parent window\n");
4792 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
| WS_VISIBLE
,
4793 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4794 ok (hchild
!= 0, "Failed to create child window\n");
4800 EnableWindow(hparent
, FALSE
);
4801 ok_sequence(WmEnableWindowSeq_1
, "EnableWindow(FALSE)", FALSE
);
4803 EnableWindow(hparent
, TRUE
);
4804 ok_sequence(WmEnableWindowSeq_2
, "EnableWindow(TRUE)", FALSE
);
4809 test_MsgWaitForMultipleObjects(hparent
);
4811 /* the following test causes an exception in user.exe under win9x */
4812 if (!PostMessageW( hparent
, WM_USER
, 0, 0 ))
4814 DestroyWindow(hparent
);
4818 PostMessageW( hparent
, WM_USER
+1, 0, 0 );
4819 /* PeekMessage(NULL) fails, but still removes the message */
4820 SetLastError(0xdeadbeef);
4821 ok( !PeekMessageW( NULL
, 0, 0, 0, PM_REMOVE
), "PeekMessage(NULL) should fail\n" );
4822 ok( GetLastError() == ERROR_NOACCESS
|| /* Win2k */
4823 GetLastError() == 0xdeadbeef, /* NT4 */
4824 "last error is %d\n", GetLastError() );
4825 ok( PeekMessageW( &msg
, 0, 0, 0, PM_REMOVE
), "PeekMessage should succeed\n" );
4826 ok( msg
.message
== WM_USER
+1, "got %x instead of WM_USER+1\n", msg
.message
);
4828 DestroyWindow(hchild
);
4829 DestroyWindow(hparent
);
4832 /* Message sequences for WM_SETICON */
4833 trace("testing WM_SETICON\n");
4834 hwnd
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
4835 CW_USEDEFAULT
, CW_USEDEFAULT
, 300, 300, 0,
4837 ShowWindow(hwnd
, SW_SHOW
);
4841 SendMessage(hwnd
, WM_SETICON
, ICON_SMALL
, (LPARAM
)LoadIcon(0, IDI_APPLICATION
));
4842 ok_sequence(WmSetIcon_1
, "WM_SETICON for shown window with caption", FALSE
);
4844 ShowWindow(hwnd
, SW_HIDE
);
4847 SendMessage(hwnd
, WM_SETICON
, ICON_SMALL
, (LPARAM
)LoadIcon(0, IDI_APPLICATION
));
4848 ok_sequence(WmSetIcon_2
, "WM_SETICON for hidden window with caption", FALSE
);
4849 DestroyWindow(hwnd
);
4852 hwnd
= CreateWindowExA(0, "TestPopupClass", NULL
, WS_POPUP
,
4853 CW_USEDEFAULT
, CW_USEDEFAULT
, 300, 300, 0,
4855 ShowWindow(hwnd
, SW_SHOW
);
4859 SendMessage(hwnd
, WM_SETICON
, ICON_SMALL
, (LPARAM
)LoadIcon(0, IDI_APPLICATION
));
4860 ok_sequence(WmSetIcon_2
, "WM_SETICON for shown window without caption", FALSE
);
4862 ShowWindow(hwnd
, SW_HIDE
);
4865 SendMessage(hwnd
, WM_SETICON
, ICON_SMALL
, (LPARAM
)LoadIcon(0, IDI_APPLICATION
));
4866 ok_sequence(WmSetIcon_2
, "WM_SETICON for hidden window without caption", FALSE
);
4869 res
= SendMessage(hwnd
, 0x3B, 0x8000000b, 0);
4872 todo_wine
win_skip( "Message 0x3b not supported\n" );
4875 ok_sequence(WmInitEndSession
, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x8000000b", TRUE
);
4876 ok(res
== 1, "SendMessage(hwnd, 0x3B, 0x8000000b, 0) should have returned 1 instead of %ld\n", res
);
4877 res
= SendMessage(hwnd
, 0x3B, 0x0000000b, 0);
4878 ok_sequence(WmInitEndSession_2
, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x0000000b", TRUE
);
4879 ok(res
== 1, "SendMessage(hwnd, 0x3B, 0x0000000b, 0) should have returned 1 instead of %ld\n", res
);
4880 res
= SendMessage(hwnd
, 0x3B, 0x0000000f, 0);
4881 ok_sequence(WmInitEndSession_2
, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x0000000f", TRUE
);
4882 ok(res
== 1, "SendMessage(hwnd, 0x3B, 0x0000000f, 0) should have returned 1 instead of %ld\n", res
);
4885 res
= SendMessage(hwnd
, 0x3B, 0x80000008, 0);
4886 ok_sequence(WmInitEndSession_3
, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x80000008", TRUE
);
4887 ok(res
== 2, "SendMessage(hwnd, 0x3B, 0x80000008, 0) should have returned 2 instead of %ld\n", res
);
4888 res
= SendMessage(hwnd
, 0x3B, 0x00000008, 0);
4889 ok_sequence(WmInitEndSession_4
, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x00000008", TRUE
);
4890 ok(res
== 2, "SendMessage(hwnd, 0x3B, 0x00000008, 0) should have returned 2 instead of %ld\n", res
);
4892 res
= SendMessage(hwnd
, 0x3B, 0x80000004, 0);
4893 ok_sequence(WmInitEndSession_3
, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x80000004", TRUE
);
4894 ok(res
== 2, "SendMessage(hwnd, 0x3B, 0x80000004, 0) should have returned 2 instead of %ld\n", res
);
4896 res
= SendMessage(hwnd
, 0x3B, 0x80000001, 0);
4897 ok_sequence(WmInitEndSession_5
, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x80000001", TRUE
);
4898 ok(res
== 2, "SendMessage(hwnd, 0x3B, 0x80000001, 0) should have returned 2 instead of %ld\n", res
);
4901 DestroyWindow(hwnd
);
4905 static void test_setwindowpos(void)
4910 const INT winX
= 100;
4911 const INT winY
= 100;
4912 const INT sysX
= GetSystemMetrics(SM_CXMINTRACK
);
4914 hwnd
= CreateWindowExA(0, "TestWindowClass", NULL
, 0,
4915 0, 0, winX
, winY
, 0,
4918 GetWindowRect(hwnd
, &rc
);
4919 expect(sysX
, rc
.right
);
4920 expect(winY
, rc
.bottom
);
4924 res
= SetWindowPos(hwnd
, HWND_TOPMOST
, 0, 0, winX
, winY
, 0);
4925 ok_sequence(WmZOrder
, "Z-Order", TRUE
);
4926 ok(res
== TRUE
, "SetWindowPos expected TRUE, got %ld\n", res
);
4928 GetWindowRect(hwnd
, &rc
);
4929 expect(sysX
, rc
.right
);
4930 expect(winY
, rc
.bottom
);
4931 DestroyWindow(hwnd
);
4934 static void invisible_parent_tests(void)
4936 HWND hparent
, hchild
;
4938 hparent
= CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW
,
4939 100, 100, 200, 200, 0, 0, 0, NULL
);
4940 ok (hparent
!= 0, "Failed to create parent window\n");
4943 /* test showing child with hidden parent */
4945 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
4946 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4947 ok (hchild
!= 0, "Failed to create child window\n");
4948 ok_sequence(WmCreateChildSeq
, "CreateWindow:child", FALSE
);
4950 ShowWindow( hchild
, SW_MINIMIZE
);
4951 ok_sequence(WmShowChildInvisibleParentSeq_1
, "ShowWindow(SW_MINIMIZE) child with invisible parent", FALSE
);
4952 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
4953 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
4958 ShowWindow( hchild
, SW_MINIMIZE
);
4959 ok_sequence(WmShowChildInvisibleParentSeq_1r
, "ShowWindow(SW_MINIMIZE) child with invisible parent", FALSE
);
4961 DestroyWindow(hchild
);
4962 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
4963 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4966 ShowWindow( hchild
, SW_MAXIMIZE
);
4967 ok_sequence(WmShowChildInvisibleParentSeq_2
, "ShowWindow(SW_MAXIMIZE) child with invisible parent", FALSE
);
4968 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
4969 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
4974 ShowWindow( hchild
, SW_MAXIMIZE
);
4975 ok_sequence(WmShowChildInvisibleParentSeq_2r
, "ShowWindow(SW_MAXIMIZE) child with invisible parent", FALSE
);
4977 DestroyWindow(hchild
);
4978 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
4979 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4982 ShowWindow( hchild
, SW_RESTORE
);
4983 ok_sequence(WmShowChildInvisibleParentSeq_5
, "ShowWindow(SW_RESTORE) child with invisible parent", FALSE
);
4984 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
4985 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
4987 DestroyWindow(hchild
);
4988 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
4989 0, 0, 10, 10, hparent
, 0, 0, NULL
);
4992 ShowWindow( hchild
, SW_SHOWMINIMIZED
);
4993 ok_sequence(WmShowChildInvisibleParentSeq_3
, "ShowWindow(SW_SHOWMINIMIZED) child with invisible parent", FALSE
);
4994 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
4995 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
5000 ShowWindow( hchild
, SW_SHOWMINIMIZED
);
5001 ok_sequence(WmShowChildInvisibleParentSeq_3r
, "ShowWindow(SW_SHOWMINIMIZED) child with invisible parent", FALSE
);
5003 DestroyWindow(hchild
);
5004 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
5005 0, 0, 10, 10, hparent
, 0, 0, NULL
);
5008 /* same as ShowWindow( hchild, SW_MAXIMIZE ); */
5009 ShowWindow( hchild
, SW_SHOWMAXIMIZED
);
5010 ok_sequence(WmShowChildInvisibleParentSeq_2
, "ShowWindow(SW_SHOWMAXIMIZED) child with invisible parent", FALSE
);
5011 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
5012 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
5014 DestroyWindow(hchild
);
5015 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
5016 0, 0, 10, 10, hparent
, 0, 0, NULL
);
5019 ShowWindow( hchild
, SW_SHOWMINNOACTIVE
);
5020 ok_sequence(WmShowChildInvisibleParentSeq_4
, "ShowWindow(SW_SHOWMINNOACTIVE) child with invisible parent", FALSE
);
5021 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
5022 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
5027 ShowWindow( hchild
, SW_SHOWMINNOACTIVE
);
5028 ok_sequence(WmShowChildInvisibleParentSeq_4r
, "ShowWindow(SW_SHOWMINNOACTIVE) child with invisible parent", FALSE
);
5030 DestroyWindow(hchild
);
5031 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
5032 0, 0, 10, 10, hparent
, 0, 0, NULL
);
5035 /* FIXME: looks like XP SP2 doesn't know about SW_FORCEMINIMIZE at all */
5036 ShowWindow( hchild
, SW_FORCEMINIMIZE
);
5037 ok_sequence(WmEmptySeq
, "ShowWindow(SW_FORCEMINIMIZE) child with invisible parent", TRUE
);
5039 ok(!(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
), "WS_VISIBLE should be not set\n");
5041 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
5043 DestroyWindow(hchild
);
5044 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
5045 0, 0, 10, 10, hparent
, 0, 0, NULL
);
5048 ShowWindow( hchild
, SW_SHOWNA
);
5049 ok_sequence(WmShowChildInvisibleParentSeq_5
, "ShowWindow(SW_SHOWNA) child with invisible parent", FALSE
);
5050 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
5051 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
5056 ShowWindow( hchild
, SW_SHOWNA
);
5057 ok_sequence(WmShowChildInvisibleParentSeq_5
, "ShowWindow(SW_SHOWNA) child with invisible parent", FALSE
);
5059 DestroyWindow(hchild
);
5060 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
,
5061 0, 0, 10, 10, hparent
, 0, 0, NULL
);
5064 ShowWindow( hchild
, SW_SHOW
);
5065 ok_sequence(WmShowChildInvisibleParentSeq_5
, "ShowWindow(SW_SHOW) child with invisible parent", FALSE
);
5066 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
5067 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
5072 ShowWindow( hchild
, SW_SHOW
);
5073 ok_sequence(WmEmptySeq
, "ShowWindow(SW_SHOW) child with invisible parent", FALSE
);
5075 ShowWindow( hchild
, SW_HIDE
);
5076 ok_sequence(WmHideChildInvisibleParentSeq
, "ShowWindow:hide child with invisible parent", FALSE
);
5077 ok(!(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
), "WS_VISIBLE should be not set\n");
5078 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
5080 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOZORDER
);
5081 ok_sequence(WmShowChildInvisibleParentSeq_6
, "SetWindowPos:show child with invisible parent", FALSE
);
5082 ok(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
, "WS_VISIBLE should be set\n");
5083 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
5085 SetWindowPos(hchild
, 0,0,0,0,0, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOZORDER
);
5086 ok_sequence(WmHideChildInvisibleParentSeq_2
, "SetWindowPos:hide child with invisible parent", FALSE
);
5087 ok(!(GetWindowLongA(hchild
, GWL_STYLE
) & WS_VISIBLE
), "WS_VISIBLE should not be set\n");
5088 ok(!IsWindowVisible(hchild
), "IsWindowVisible() should return FALSE\n");
5090 SetWindowPos(hchild
, 0,0,0,0,0, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOZORDER
);
5092 DestroyWindow(hchild
);
5093 ok_sequence(WmDestroyInvisibleChildSeq
, "DestroyInvisibleChildSeq", FALSE
);
5095 DestroyWindow(hparent
);
5099 /****************** button message test *************************/
5100 #define ID_BUTTON 0x000e
5102 static const struct message WmSetFocusButtonSeq
[] =
5104 { HCBT_SETFOCUS
, hook
},
5105 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
5106 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
5107 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
5108 { WM_SETFOCUS
, sent
|wparam
, 0 },
5109 { WM_CTLCOLORBTN
, sent
|parent
},
5110 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_BUTTON
, BN_SETFOCUS
) },
5111 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5114 static const struct message WmKillFocusButtonSeq
[] =
5116 { HCBT_SETFOCUS
, hook
},
5117 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
5118 { WM_KILLFOCUS
, sent
|wparam
, 0 },
5119 { WM_CTLCOLORBTN
, sent
|parent
},
5120 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_BUTTON
, BN_KILLFOCUS
) },
5121 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
5122 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 1 },
5123 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5125 { WM_CTLCOLORBTN
, sent
|parent
},
5128 static const struct message WmSetFocusStaticSeq
[] =
5130 { HCBT_SETFOCUS
, hook
},
5131 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
5132 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
5133 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
5134 { WM_SETFOCUS
, sent
|wparam
, 0 },
5135 { WM_CTLCOLORSTATIC
, sent
|parent
},
5136 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_BUTTON
, BN_SETFOCUS
) },
5137 { WM_COMMAND
, sent
|wparam
|parent
|optional
, MAKEWPARAM(ID_BUTTON
, BN_CLICKED
) }, /* radio button */
5138 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5141 static const struct message WmKillFocusStaticSeq
[] =
5143 { HCBT_SETFOCUS
, hook
},
5144 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
5145 { WM_KILLFOCUS
, sent
|wparam
, 0 },
5146 { WM_CTLCOLORSTATIC
, sent
|parent
},
5147 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_BUTTON
, BN_KILLFOCUS
) },
5148 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
5149 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 1 },
5150 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5152 { WM_CTLCOLORSTATIC
, sent
|parent
},
5155 static const struct message WmSetFocusOwnerdrawSeq
[] =
5157 { HCBT_SETFOCUS
, hook
},
5158 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
5159 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
5160 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
5161 { WM_SETFOCUS
, sent
|wparam
, 0 },
5162 { WM_CTLCOLORBTN
, sent
|parent
},
5163 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_BUTTON
, 0x001040e4 },
5164 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_BUTTON
, BN_SETFOCUS
) },
5165 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5168 static const struct message WmKillFocusOwnerdrawSeq
[] =
5170 { HCBT_SETFOCUS
, hook
},
5171 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
5172 { WM_KILLFOCUS
, sent
|wparam
, 0 },
5173 { WM_CTLCOLORBTN
, sent
|parent
},
5174 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_BUTTON
, 0x000040e4 },
5175 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_BUTTON
, BN_KILLFOCUS
) },
5176 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
5177 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 1 },
5178 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5180 { WM_CTLCOLORBTN
, sent
|parent
},
5181 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_BUTTON
, 0x000010e4 },
5184 static const struct message WmLButtonDownSeq
[] =
5186 { WM_LBUTTONDOWN
, sent
|wparam
|lparam
, 0, 0 },
5187 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
5188 { HCBT_SETFOCUS
, hook
},
5189 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
5190 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
5191 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
5192 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
5193 { WM_CTLCOLORBTN
, sent
|defwinproc
},
5194 { BM_SETSTATE
, sent
|wparam
|defwinproc
, TRUE
},
5195 { WM_CTLCOLORBTN
, sent
|defwinproc
},
5196 { EVENT_OBJECT_STATECHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
5199 static const struct message WmLButtonUpSeq
[] =
5201 { WM_LBUTTONUP
, sent
|wparam
|lparam
, 0, 0 },
5202 { BM_SETSTATE
, sent
|wparam
|defwinproc
, FALSE
},
5203 { WM_CTLCOLORBTN
, sent
|defwinproc
},
5204 { EVENT_OBJECT_STATECHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
5205 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, 0, 0 },
5206 { WM_CAPTURECHANGED
, sent
|wparam
|defwinproc
, 0 },
5209 static const struct message WmSetFontButtonSeq
[] =
5211 { WM_SETFONT
, sent
},
5213 { WM_ERASEBKGND
, sent
|defwinproc
|optional
},
5214 { WM_CTLCOLORBTN
, sent
|defwinproc
},
5217 static const struct message WmSetStyleButtonSeq
[] =
5219 { BM_SETSTYLE
, sent
},
5220 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5222 { WM_NCPAINT
, sent
|defwinproc
|optional
}, /* FIXME: Wine sends it */
5223 { WM_ERASEBKGND
, sent
|defwinproc
|optional
}, /* Win9x doesn't send it */
5224 { WM_CTLCOLORBTN
, sent
|parent
},
5227 static const struct message WmSetStyleStaticSeq
[] =
5229 { BM_SETSTYLE
, sent
},
5230 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5232 { WM_NCPAINT
, sent
|defwinproc
|optional
}, /* FIXME: Wine sends it */
5233 { WM_ERASEBKGND
, sent
|defwinproc
|optional
}, /* Win9x doesn't send it */
5234 { WM_CTLCOLORSTATIC
, sent
|parent
},
5237 static const struct message WmSetStyleUserSeq
[] =
5239 { BM_SETSTYLE
, sent
},
5240 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5242 { WM_NCPAINT
, sent
|defwinproc
|optional
}, /* FIXME: Wine sends it */
5243 { WM_ERASEBKGND
, sent
|defwinproc
|optional
}, /* Win9x doesn't send it */
5244 { WM_CTLCOLORBTN
, sent
|parent
},
5245 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_BUTTON
, BN_PAINT
) },
5248 static const struct message WmSetStyleOwnerdrawSeq
[] =
5250 { BM_SETSTYLE
, sent
},
5251 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5253 { WM_NCPAINT
, sent
|optional
}, /* FIXME: Wine sends it */
5254 { WM_ERASEBKGND
, sent
|defwinproc
|optional
}, /* Win9x doesn't send it */
5255 { WM_CTLCOLORBTN
, sent
|parent
},
5256 { WM_CTLCOLORBTN
, sent
|parent
|optional
}, /* Win9x doesn't send it */
5257 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_BUTTON
, 0x000010e4 },
5260 static const struct message WmSetStateButtonSeq
[] =
5262 { BM_SETSTATE
, sent
},
5263 { WM_CTLCOLORBTN
, sent
|parent
},
5264 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5267 static const struct message WmSetStateStaticSeq
[] =
5269 { BM_SETSTATE
, sent
},
5270 { WM_CTLCOLORSTATIC
, sent
|parent
},
5271 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5274 static const struct message WmSetStateUserSeq
[] =
5276 { BM_SETSTATE
, sent
},
5277 { WM_CTLCOLORBTN
, sent
|parent
},
5278 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_BUTTON
, BN_HILITE
) },
5279 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5282 static const struct message WmSetStateOwnerdrawSeq
[] =
5284 { BM_SETSTATE
, sent
},
5285 { WM_CTLCOLORBTN
, sent
|parent
},
5286 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_BUTTON
, 0x000120e4 },
5287 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5290 static const struct message WmClearStateButtonSeq
[] =
5292 { BM_SETSTATE
, sent
},
5293 { WM_CTLCOLORBTN
, sent
|parent
},
5294 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_BUTTON
, BN_UNHILITE
) },
5295 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5298 static const struct message WmClearStateOwnerdrawSeq
[] =
5300 { BM_SETSTATE
, sent
},
5301 { WM_CTLCOLORBTN
, sent
|parent
},
5302 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_BUTTON
, 0x000020e4 },
5303 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5306 static const struct message WmSetCheckIgnoredSeq
[] =
5308 { BM_SETCHECK
, sent
},
5309 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5312 static const struct message WmSetCheckStaticSeq
[] =
5314 { BM_SETCHECK
, sent
},
5315 { WM_CTLCOLORSTATIC
, sent
|parent
},
5316 { WM_APP
, sent
|wparam
|lparam
, 0, 0 },
5320 static WNDPROC old_button_proc
;
5322 static LRESULT CALLBACK
button_hook_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
5324 static LONG defwndproc_counter
= 0;
5326 struct recvd_message msg
;
5328 if (ignore_message( message
)) return 0;
5336 ok(GetCapture() == hwnd
, "GetCapture() = %p\n", GetCapture());
5340 msg
.message
= message
;
5341 msg
.flags
= sent
|wparam
|lparam
;
5342 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
5343 msg
.wParam
= wParam
;
5344 msg
.lParam
= lParam
;
5345 msg
.descr
= "button";
5349 defwndproc_counter
++;
5350 ret
= CallWindowProcA(old_button_proc
, hwnd
, message
, wParam
, lParam
);
5351 defwndproc_counter
--;
5356 static void subclass_button(void)
5360 if (!GetClassInfoA(0, "button", &cls
)) assert(0);
5362 old_button_proc
= cls
.lpfnWndProc
;
5364 cls
.hInstance
= GetModuleHandle(0);
5365 cls
.lpfnWndProc
= button_hook_proc
;
5366 cls
.lpszClassName
= "my_button_class";
5367 UnregisterClass(cls
.lpszClassName
, cls
.hInstance
);
5368 if (!RegisterClassA(&cls
)) assert(0);
5371 static void test_button_messages(void)
5377 const struct message
*setfocus
;
5378 const struct message
*killfocus
;
5379 const struct message
*setstyle
;
5380 const struct message
*setstate
;
5381 const struct message
*clearstate
;
5382 const struct message
*setcheck
;
5384 { BS_PUSHBUTTON
, DLGC_BUTTON
| DLGC_UNDEFPUSHBUTTON
,
5385 WmSetFocusButtonSeq
, WmKillFocusButtonSeq
, WmSetStyleButtonSeq
,
5386 WmSetStateButtonSeq
, WmSetStateButtonSeq
, WmSetCheckIgnoredSeq
},
5387 { BS_DEFPUSHBUTTON
, DLGC_BUTTON
| DLGC_DEFPUSHBUTTON
,
5388 WmSetFocusButtonSeq
, WmKillFocusButtonSeq
, WmSetStyleButtonSeq
,
5389 WmSetStateButtonSeq
, WmSetStateButtonSeq
, WmSetCheckIgnoredSeq
},
5390 { BS_CHECKBOX
, DLGC_BUTTON
,
5391 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
, WmSetStyleStaticSeq
,
5392 WmSetStateStaticSeq
, WmSetStateStaticSeq
, WmSetCheckStaticSeq
},
5393 { BS_AUTOCHECKBOX
, DLGC_BUTTON
,
5394 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
, WmSetStyleStaticSeq
,
5395 WmSetStateStaticSeq
, WmSetStateStaticSeq
, WmSetCheckStaticSeq
},
5396 { BS_RADIOBUTTON
, DLGC_BUTTON
| DLGC_RADIOBUTTON
,
5397 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
, WmSetStyleStaticSeq
,
5398 WmSetStateStaticSeq
, WmSetStateStaticSeq
, WmSetCheckStaticSeq
},
5399 { BS_3STATE
, DLGC_BUTTON
,
5400 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
, WmSetStyleStaticSeq
,
5401 WmSetStateStaticSeq
, WmSetStateStaticSeq
, WmSetCheckStaticSeq
},
5402 { BS_AUTO3STATE
, DLGC_BUTTON
,
5403 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
, WmSetStyleStaticSeq
,
5404 WmSetStateStaticSeq
, WmSetStateStaticSeq
, WmSetCheckStaticSeq
},
5405 { BS_GROUPBOX
, DLGC_STATIC
,
5406 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
, WmSetStyleStaticSeq
,
5407 WmSetStateStaticSeq
, WmSetStateStaticSeq
, WmSetCheckIgnoredSeq
},
5408 { BS_USERBUTTON
, DLGC_BUTTON
| DLGC_UNDEFPUSHBUTTON
,
5409 WmSetFocusButtonSeq
, WmKillFocusButtonSeq
, WmSetStyleUserSeq
,
5410 WmSetStateUserSeq
, WmClearStateButtonSeq
, WmSetCheckIgnoredSeq
},
5411 { BS_AUTORADIOBUTTON
, DLGC_BUTTON
| DLGC_RADIOBUTTON
,
5412 WmSetFocusStaticSeq
, WmKillFocusStaticSeq
, WmSetStyleStaticSeq
,
5413 WmSetStateStaticSeq
, WmSetStateStaticSeq
, WmSetCheckStaticSeq
},
5414 { BS_OWNERDRAW
, DLGC_BUTTON
,
5415 WmSetFocusOwnerdrawSeq
, WmKillFocusOwnerdrawSeq
, WmSetStyleOwnerdrawSeq
,
5416 WmSetStateOwnerdrawSeq
, WmClearStateOwnerdrawSeq
, WmSetCheckIgnoredSeq
},
5423 /* selection with VK_SPACE should capture button window */
5424 hwnd
= CreateWindowExA(0, "button", "test", BS_CHECKBOX
| WS_VISIBLE
| WS_POPUP
,
5425 0, 0, 50, 14, 0, 0, 0, NULL
);
5426 ok(hwnd
!= 0, "Failed to create button window\n");
5429 SendMessageA(hwnd
, WM_KEYDOWN
, VK_SPACE
, 0);
5430 ok(GetCapture() == hwnd
, "Should be captured on VK_SPACE WM_KEYDOWN\n");
5431 SendMessageA(hwnd
, WM_KEYUP
, VK_SPACE
, 0);
5432 DestroyWindow(hwnd
);
5436 parent
= CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
5437 100, 100, 200, 200, 0, 0, 0, NULL
);
5438 ok(parent
!= 0, "Failed to create parent window\n");
5440 for (i
= 0; i
< sizeof(button
)/sizeof(button
[0]); i
++)
5445 trace("button style %08x\n", button
[i
].style
);
5447 hwnd
= CreateWindowExA(0, "my_button_class", "test", button
[i
].style
| WS_CHILD
| BS_NOTIFY
,
5448 0, 0, 50, 14, parent
, (HMENU
)ID_BUTTON
, 0, NULL
);
5449 ok(hwnd
!= 0, "Failed to create button window\n");
5451 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
5452 style
&= ~(WS_CHILD
| BS_NOTIFY
);
5453 /* XP turns a BS_USERBUTTON into BS_PUSHBUTTON */
5454 if (button
[i
].style
== BS_USERBUTTON
)
5455 ok(style
== BS_PUSHBUTTON
, "expected style BS_PUSHBUTTON got %x\n", style
);
5457 ok(style
== button
[i
].style
, "expected style %x got %x\n", button
[i
].style
, style
);
5459 dlg_code
= SendMessageA(hwnd
, WM_GETDLGCODE
, 0, 0);
5460 ok(dlg_code
== button
[i
].dlg_code
, "%u: wrong dlg_code %08x\n", i
, dlg_code
);
5462 ShowWindow(hwnd
, SW_SHOW
);
5469 log_all_parent_messages
++;
5471 ok(GetFocus() == 0, "expected focus 0, got %p\n", GetFocus());
5473 SendMessage(hwnd
, WM_APP
, 0, 0); /* place a separator mark here */
5474 while (PeekMessage(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage(&msg
);
5475 ok_sequence(button
[i
].setfocus
, "SetFocus(hwnd) on a button", FALSE
);
5478 SendMessage(hwnd
, WM_APP
, 0, 0); /* place a separator mark here */
5479 while (PeekMessage(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage(&msg
);
5480 ok_sequence(button
[i
].killfocus
, "SetFocus(0) on a button", FALSE
);
5482 ok(GetFocus() == 0, "expected focus 0, got %p\n", GetFocus());
5484 SendMessage(hwnd
, BM_SETSTYLE
, button
[i
].style
| BS_BOTTOM
, TRUE
);
5485 SendMessage(hwnd
, WM_APP
, 0, 0); /* place a separator mark here */
5486 while (PeekMessage(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage(&msg
);
5487 ok_sequence(button
[i
].setstyle
, "BM_SETSTYLE on a button", FALSE
);
5489 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
5490 style
&= ~(WS_VISIBLE
| WS_CHILD
| BS_NOTIFY
);
5491 /* XP doesn't turn a BS_USERBUTTON into BS_PUSHBUTTON here! */
5492 ok(style
== button
[i
].style
, "expected style %04x got %04x\n", button
[i
].style
, style
);
5494 state
= SendMessage(hwnd
, BM_GETSTATE
, 0, 0);
5495 ok(state
== 0, "expected state 0, got %04x\n", state
);
5499 SendMessage(hwnd
, BM_SETSTATE
, TRUE
, 0);
5500 SendMessage(hwnd
, WM_APP
, 0, 0); /* place a separator mark here */
5501 while (PeekMessage(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage(&msg
);
5502 ok_sequence(button
[i
].setstate
, "BM_SETSTATE/TRUE on a button", FALSE
);
5504 state
= SendMessage(hwnd
, BM_GETSTATE
, 0, 0);
5505 ok(state
== 0x0004, "expected state 0x0004, got %04x\n", state
);
5507 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
5508 style
&= ~(WS_CHILD
| BS_NOTIFY
| WS_VISIBLE
);
5509 ok(style
== button
[i
].style
, "expected style %04x got %04x\n", button
[i
].style
, style
);
5513 SendMessage(hwnd
, BM_SETSTATE
, FALSE
, 0);
5514 SendMessage(hwnd
, WM_APP
, 0, 0); /* place a separator mark here */
5515 while (PeekMessage(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage(&msg
);
5516 ok_sequence(button
[i
].clearstate
, "BM_SETSTATE/FALSE on a button", FALSE
);
5518 state
= SendMessage(hwnd
, BM_GETSTATE
, 0, 0);
5519 ok(state
== 0, "expected state 0, got %04x\n", state
);
5521 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
5522 style
&= ~(WS_CHILD
| BS_NOTIFY
| WS_VISIBLE
);
5523 ok(style
== button
[i
].style
, "expected style %04x got %04x\n", button
[i
].style
, style
);
5525 state
= SendMessage(hwnd
, BM_GETCHECK
, 0, 0);
5526 ok(state
== BST_UNCHECKED
, "expected BST_UNCHECKED, got %04x\n", state
);
5530 SendMessage(hwnd
, BM_SETCHECK
, BST_UNCHECKED
, 0);
5531 SendMessage(hwnd
, WM_APP
, 0, 0); /* place a separator mark here */
5532 while (PeekMessage(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage(&msg
);
5533 ok_sequence(WmSetCheckIgnoredSeq
, "BM_SETCHECK on a button", FALSE
);
5535 state
= SendMessage(hwnd
, BM_GETCHECK
, 0, 0);
5536 ok(state
== BST_UNCHECKED
, "expected BST_UNCHECKED, got %04x\n", state
);
5538 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
5539 style
&= ~(WS_CHILD
| BS_NOTIFY
| WS_VISIBLE
);
5540 ok(style
== button
[i
].style
, "expected style %04x got %04x\n", button
[i
].style
, style
);
5544 SendMessage(hwnd
, BM_SETCHECK
, BST_CHECKED
, 0);
5545 SendMessage(hwnd
, WM_APP
, 0, 0); /* place a separator mark here */
5546 while (PeekMessage(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage(&msg
);
5547 ok_sequence(button
[i
].setcheck
, "BM_SETCHECK on a button", FALSE
);
5549 state
= SendMessage(hwnd
, BM_GETCHECK
, 0, 0);
5550 if (button
[i
].style
== BS_PUSHBUTTON
||
5551 button
[i
].style
== BS_DEFPUSHBUTTON
||
5552 button
[i
].style
== BS_GROUPBOX
||
5553 button
[i
].style
== BS_USERBUTTON
||
5554 button
[i
].style
== BS_OWNERDRAW
)
5555 ok(state
== BST_UNCHECKED
, "expected check 0, got %04x\n", state
);
5557 ok(state
== BST_CHECKED
, "expected check 1, got %04x\n", state
);
5559 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
5560 style
&= ~(WS_CHILD
| BS_NOTIFY
| WS_VISIBLE
);
5561 if (button
[i
].style
== BS_RADIOBUTTON
||
5562 button
[i
].style
== BS_AUTORADIOBUTTON
)
5563 ok(style
== (button
[i
].style
| WS_TABSTOP
), "expected style %04x | WS_TABSTOP got %04x\n", button
[i
].style
, style
);
5565 ok(style
== button
[i
].style
, "expected style %04x got %04x\n", button
[i
].style
, style
);
5567 log_all_parent_messages
--;
5569 DestroyWindow(hwnd
);
5572 DestroyWindow(parent
);
5574 hwnd
= CreateWindowExA(0, "my_button_class", "test", BS_PUSHBUTTON
| WS_POPUP
| WS_VISIBLE
,
5575 0, 0, 50, 14, 0, 0, 0, NULL
);
5576 ok(hwnd
!= 0, "Failed to create button window\n");
5578 SetForegroundWindow(hwnd
);
5581 SetActiveWindow(hwnd
);
5585 SendMessageA(hwnd
, WM_LBUTTONDOWN
, 0, 0);
5586 ok_sequence(WmLButtonDownSeq
, "WM_LBUTTONDOWN on a button", FALSE
);
5588 SendMessageA(hwnd
, WM_LBUTTONUP
, 0, 0);
5589 ok_sequence(WmLButtonUpSeq
, "WM_LBUTTONUP on a button", FALSE
);
5592 zfont
= GetStockObject(SYSTEM_FONT
);
5593 SendMessageA(hwnd
, WM_SETFONT
, (WPARAM
)zfont
, TRUE
);
5595 ok_sequence(WmSetFontButtonSeq
, "WM_SETFONT on a button", FALSE
);
5597 DestroyWindow(hwnd
);
5600 /****************** static message test *************************/
5601 static const struct message WmSetFontStaticSeq
[] =
5603 { WM_SETFONT
, sent
},
5604 { WM_PAINT
, sent
|defwinproc
|optional
},
5605 { WM_ERASEBKGND
, sent
|defwinproc
|optional
},
5606 { WM_CTLCOLORSTATIC
, sent
|defwinproc
|optional
},
5610 static WNDPROC old_static_proc
;
5612 static LRESULT CALLBACK
static_hook_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
5614 static LONG defwndproc_counter
= 0;
5616 struct recvd_message msg
;
5618 if (ignore_message( message
)) return 0;
5621 msg
.message
= message
;
5622 msg
.flags
= sent
|wparam
|lparam
;
5623 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
5624 msg
.wParam
= wParam
;
5625 msg
.lParam
= lParam
;
5626 msg
.descr
= "static";
5629 defwndproc_counter
++;
5630 ret
= CallWindowProcA(old_static_proc
, hwnd
, message
, wParam
, lParam
);
5631 defwndproc_counter
--;
5636 static void subclass_static(void)
5640 if (!GetClassInfoA(0, "static", &cls
)) assert(0);
5642 old_static_proc
= cls
.lpfnWndProc
;
5644 cls
.hInstance
= GetModuleHandle(0);
5645 cls
.lpfnWndProc
= static_hook_proc
;
5646 cls
.lpszClassName
= "my_static_class";
5647 UnregisterClass(cls
.lpszClassName
, cls
.hInstance
);
5648 if (!RegisterClassA(&cls
)) assert(0);
5651 static void test_static_messages(void)
5653 /* FIXME: make as comprehensive as the button message test */
5658 const struct message
*setfont
;
5660 { SS_LEFT
, DLGC_STATIC
,
5661 WmSetFontStaticSeq
}
5669 for (i
= 0; i
< sizeof(static_ctrl
)/sizeof(static_ctrl
[0]); i
++)
5671 hwnd
= CreateWindowExA(0, "my_static_class", "test", static_ctrl
[i
].style
| WS_POPUP
,
5672 0, 0, 50, 14, 0, 0, 0, NULL
);
5673 ok(hwnd
!= 0, "Failed to create static window\n");
5675 dlg_code
= SendMessageA(hwnd
, WM_GETDLGCODE
, 0, 0);
5676 ok(dlg_code
== static_ctrl
[i
].dlg_code
, "%u: wrong dlg_code %08x\n", i
, dlg_code
);
5678 ShowWindow(hwnd
, SW_SHOW
);
5683 trace("static style %08x\n", static_ctrl
[i
].style
);
5684 SendMessage(hwnd
, WM_SETFONT
, (WPARAM
)GetStockObject(DEFAULT_GUI_FONT
), TRUE
);
5685 ok_sequence(static_ctrl
[i
].setfont
, "WM_SETFONT on a static", FALSE
);
5687 DestroyWindow(hwnd
);
5691 /****************** ComboBox message test *************************/
5692 #define ID_COMBOBOX 0x000f
5694 static const struct message WmKeyDownComboSeq
[] =
5696 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_DOWN
, 0 },
5697 { WM_COMMAND
, sent
|wparam
|defwinproc
, MAKEWPARAM(1000, LBN_SELCHANGE
) },
5698 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_COMBOBOX
, CBN_SELENDOK
) },
5699 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_COMBOBOX
, CBN_SELCHANGE
) },
5700 { WM_CTLCOLOREDIT
, sent
|parent
},
5701 { WM_KEYUP
, sent
|wparam
|lparam
, VK_DOWN
, 0 },
5705 static WNDPROC old_combobox_proc
;
5707 static LRESULT CALLBACK
combobox_hook_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
5709 static LONG defwndproc_counter
= 0;
5711 struct recvd_message msg
;
5713 /* do not log painting messages */
5714 if (message
!= WM_PAINT
&&
5715 message
!= WM_NCPAINT
&&
5716 message
!= WM_SYNCPAINT
&&
5717 message
!= WM_ERASEBKGND
&&
5718 message
!= WM_NCHITTEST
&&
5719 message
!= WM_GETTEXT
&&
5720 !ignore_message( message
))
5723 msg
.message
= message
;
5724 msg
.flags
= sent
|wparam
|lparam
;
5725 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
5726 msg
.wParam
= wParam
;
5727 msg
.lParam
= lParam
;
5728 msg
.descr
= "combo";
5732 defwndproc_counter
++;
5733 ret
= CallWindowProcA(old_combobox_proc
, hwnd
, message
, wParam
, lParam
);
5734 defwndproc_counter
--;
5739 static void subclass_combobox(void)
5743 if (!GetClassInfoA(0, "ComboBox", &cls
)) assert(0);
5745 old_combobox_proc
= cls
.lpfnWndProc
;
5747 cls
.hInstance
= GetModuleHandle(0);
5748 cls
.lpfnWndProc
= combobox_hook_proc
;
5749 cls
.lpszClassName
= "my_combobox_class";
5750 UnregisterClass(cls
.lpszClassName
, cls
.hInstance
);
5751 if (!RegisterClassA(&cls
)) assert(0);
5754 static void test_combobox_messages(void)
5759 subclass_combobox();
5761 parent
= CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
5762 100, 100, 200, 200, 0, 0, 0, NULL
);
5763 ok(parent
!= 0, "Failed to create parent window\n");
5766 combo
= CreateWindowEx(0, "my_combobox_class", "test", WS_CHILD
| WS_VISIBLE
| CBS_DROPDOWNLIST
| CBS_HASSTRINGS
,
5767 0, 0, 100, 150, parent
, (HMENU
)ID_COMBOBOX
, 0, NULL
);
5768 ok(combo
!= 0, "Failed to create combobox window\n");
5770 UpdateWindow(combo
);
5772 ret
= SendMessage(combo
, WM_GETDLGCODE
, 0, 0);
5773 ok(ret
== (DLGC_WANTCHARS
| DLGC_WANTARROWS
), "wrong dlg_code %08lx\n", ret
);
5775 ret
= SendMessage(combo
, CB_ADDSTRING
, 0, (LPARAM
)"item 0");
5776 ok(ret
== 0, "expected 0, got %ld\n", ret
);
5777 ret
= SendMessage(combo
, CB_ADDSTRING
, 0, (LPARAM
)"item 1");
5778 ok(ret
== 1, "expected 1, got %ld\n", ret
);
5779 ret
= SendMessage(combo
, CB_ADDSTRING
, 0, (LPARAM
)"item 2");
5780 ok(ret
== 2, "expected 2, got %ld\n", ret
);
5782 SendMessage(combo
, CB_SETCURSEL
, 0, 0);
5786 log_all_parent_messages
++;
5787 SendMessage(combo
, WM_KEYDOWN
, VK_DOWN
, 0);
5788 SendMessage(combo
, WM_KEYUP
, VK_DOWN
, 0);
5789 log_all_parent_messages
--;
5790 ok_sequence(WmKeyDownComboSeq
, "WM_KEYDOWN/VK_DOWN on a ComboBox", FALSE
);
5792 DestroyWindow(combo
);
5793 DestroyWindow(parent
);
5796 /****************** WM_IME_KEYDOWN message test *******************/
5798 static const struct message WmImeKeydownMsgSeq_0
[] =
5800 { WM_IME_KEYDOWN
, wparam
, VK_RETURN
},
5801 { WM_CHAR
, wparam
, 'A' },
5805 static const struct message WmImeKeydownMsgSeq_1
[] =
5807 { WM_KEYDOWN
, optional
|wparam
, VK_RETURN
},
5808 { WM_CHAR
, optional
|wparam
, VK_RETURN
},
5812 static LRESULT WINAPI
wmime_keydown_procA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
5814 struct recvd_message msg
;
5817 msg
.message
= message
;
5818 msg
.flags
= wparam
|lparam
;
5819 msg
.wParam
= wParam
;
5820 msg
.lParam
= lParam
;
5821 msg
.descr
= "wmime_keydown";
5824 return DefWindowProcA(hwnd
, message
, wParam
, lParam
);
5827 static void register_wmime_keydown_class(void)
5831 ZeroMemory(&cls
, sizeof(WNDCLASSA
));
5832 cls
.lpfnWndProc
= wmime_keydown_procA
;
5833 cls
.hInstance
= GetModuleHandleA(0);
5834 cls
.lpszClassName
= "wmime_keydown_class";
5835 if (!RegisterClassA(&cls
)) assert(0);
5838 static void test_wmime_keydown_message(void)
5843 trace("Message sequences by WM_IME_KEYDOWN\n");
5845 register_wmime_keydown_class();
5846 hwnd
= CreateWindowExA(0, "wmime_keydown_class", NULL
, WS_OVERLAPPEDWINDOW
,
5847 CW_USEDEFAULT
, CW_USEDEFAULT
, 300, 300, 0,
5852 SendMessage(hwnd
, WM_IME_KEYDOWN
, VK_RETURN
, 0x1c0001);
5853 SendMessage(hwnd
, WM_CHAR
, 'A', 1);
5854 ok_sequence(WmImeKeydownMsgSeq_0
, "WM_IME_KEYDOWN 0", FALSE
);
5856 while ( PeekMessage(&msg
, 0, 0, 0, PM_REMOVE
) )
5858 TranslateMessage(&msg
);
5859 DispatchMessage(&msg
);
5861 ok_sequence(WmImeKeydownMsgSeq_1
, "WM_IME_KEYDOWN 1", FALSE
);
5863 DestroyWindow(hwnd
);
5866 /************* painting message test ********************/
5868 void dump_region(HRGN hrgn
)
5871 RGNDATA
*data
= NULL
;
5876 printf( "null region\n" );
5879 if (!(size
= GetRegionData( hrgn
, 0, NULL
))) return;
5880 if (!(data
= HeapAlloc( GetProcessHeap(), 0, size
))) return;
5881 GetRegionData( hrgn
, size
, data
);
5882 printf("%d rects:", data
->rdh
.nCount
);
5883 for (i
= 0, rect
= (RECT
*)data
->Buffer
; i
< data
->rdh
.nCount
; i
++, rect
++)
5884 printf( " (%d,%d)-(%d,%d)", rect
->left
, rect
->top
, rect
->right
, rect
->bottom
);
5886 HeapFree( GetProcessHeap(), 0, data
);
5889 static void check_update_rgn( HWND hwnd
, HRGN hrgn
)
5893 HRGN tmp
= CreateRectRgn( 0, 0, 0, 0 );
5894 HRGN update
= CreateRectRgn( 0, 0, 0, 0 );
5896 ret
= GetUpdateRgn( hwnd
, update
, FALSE
);
5897 ok( ret
!= ERROR
, "GetUpdateRgn failed\n" );
5898 if (ret
== NULLREGION
)
5900 ok( !hrgn
, "Update region shouldn't be empty\n" );
5904 if (CombineRgn( tmp
, hrgn
, update
, RGN_XOR
) != NULLREGION
)
5906 ok( 0, "Regions are different\n" );
5907 if (winetest_debug
> 0)
5909 printf( "Update region: " );
5910 dump_region( update
);
5911 printf( "Wanted region: " );
5912 dump_region( hrgn
);
5916 GetRgnBox( update
, &r1
);
5917 GetUpdateRect( hwnd
, &r2
, FALSE
);
5918 ok( r1
.left
== r2
.left
&& r1
.top
== r2
.top
&& r1
.right
== r2
.right
&& r1
.bottom
== r2
.bottom
,
5919 "Rectangles are different: %d,%d-%d,%d / %d,%d-%d,%d\n",
5920 r1
.left
, r1
.top
, r1
.right
, r1
.bottom
, r2
.left
, r2
.top
, r2
.right
, r2
.bottom
);
5922 DeleteObject( tmp
);
5923 DeleteObject( update
);
5926 static const struct message WmInvalidateRgn
[] = {
5927 { WM_NCPAINT
, sent
},
5928 { WM_GETTEXT
, sent
|defwinproc
|optional
},
5932 static const struct message WmGetUpdateRect
[] = {
5933 { WM_NCPAINT
, sent
},
5934 { WM_GETTEXT
, sent
|defwinproc
|optional
},
5939 static const struct message WmInvalidateFull
[] = {
5940 { WM_NCPAINT
, sent
|wparam
, 1 },
5941 { WM_GETTEXT
, sent
|defwinproc
|optional
},
5945 static const struct message WmInvalidateErase
[] = {
5946 { WM_NCPAINT
, sent
|wparam
, 1 },
5947 { WM_GETTEXT
, sent
|defwinproc
|optional
},
5948 { WM_ERASEBKGND
, sent
},
5952 static const struct message WmInvalidatePaint
[] = {
5954 { WM_NCPAINT
, sent
|wparam
|beginpaint
, 1 },
5955 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
5959 static const struct message WmInvalidateErasePaint
[] = {
5961 { WM_NCPAINT
, sent
|wparam
|beginpaint
, 1 },
5962 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
5963 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
5967 static const struct message WmInvalidateErasePaint2
[] = {
5969 { WM_NCPAINT
, sent
|beginpaint
},
5970 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
5971 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
5975 static const struct message WmErase
[] = {
5976 { WM_ERASEBKGND
, sent
},
5980 static const struct message WmPaint
[] = {
5985 static const struct message WmParentOnlyPaint
[] = {
5986 { WM_PAINT
, sent
|parent
},
5990 static const struct message WmInvalidateParent
[] = {
5991 { WM_NCPAINT
, sent
|parent
},
5992 { WM_GETTEXT
, sent
|defwinproc
|parent
|optional
},
5993 { WM_ERASEBKGND
, sent
|parent
},
5997 static const struct message WmInvalidateParentChild
[] = {
5998 { WM_NCPAINT
, sent
|parent
},
5999 { WM_GETTEXT
, sent
|defwinproc
|parent
|optional
},
6000 { WM_ERASEBKGND
, sent
|parent
},
6001 { WM_NCPAINT
, sent
},
6002 { WM_GETTEXT
, sent
|defwinproc
|optional
},
6003 { WM_ERASEBKGND
, sent
},
6007 static const struct message WmInvalidateParentChild2
[] = {
6008 { WM_ERASEBKGND
, sent
|parent
},
6009 { WM_NCPAINT
, sent
},
6010 { WM_GETTEXT
, sent
|defwinproc
|optional
},
6011 { WM_ERASEBKGND
, sent
},
6015 static const struct message WmParentPaint
[] = {
6016 { WM_PAINT
, sent
|parent
},
6021 static const struct message WmParentPaintNc
[] = {
6022 { WM_PAINT
, sent
|parent
},
6024 { WM_NCPAINT
, sent
|beginpaint
},
6025 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
6026 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
6030 static const struct message WmChildPaintNc
[] = {
6032 { WM_NCPAINT
, sent
|beginpaint
},
6033 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
6034 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
6038 static const struct message WmParentErasePaint
[] = {
6039 { WM_PAINT
, sent
|parent
},
6040 { WM_NCPAINT
, sent
|parent
|beginpaint
},
6041 { WM_GETTEXT
, sent
|parent
|beginpaint
|defwinproc
|optional
},
6042 { WM_ERASEBKGND
, sent
|parent
|beginpaint
|optional
},
6044 { WM_NCPAINT
, sent
|beginpaint
},
6045 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
6046 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
6050 static const struct message WmParentOnlyNcPaint
[] = {
6051 { WM_PAINT
, sent
|parent
},
6052 { WM_NCPAINT
, sent
|parent
|beginpaint
},
6053 { WM_GETTEXT
, sent
|parent
|beginpaint
|defwinproc
|optional
},
6057 static const struct message WmSetParentStyle
[] = {
6058 { WM_STYLECHANGING
, sent
|parent
},
6059 { WM_STYLECHANGED
, sent
|parent
},
6063 static void test_paint_messages(void)
6069 HWND hparent
, hchild
;
6070 HRGN hrgn
= CreateRectRgn( 0, 0, 0, 0 );
6071 HRGN hrgn2
= CreateRectRgn( 0, 0, 0, 0 );
6072 HWND hwnd
= CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW
,
6073 100, 100, 200, 200, 0, 0, 0, NULL
);
6074 ok (hwnd
!= 0, "Failed to create overlapped window\n");
6076 ShowWindow( hwnd
, SW_SHOW
);
6077 UpdateWindow( hwnd
);
6081 check_update_rgn( hwnd
, 0 );
6082 SetRectRgn( hrgn
, 10, 10, 20, 20 );
6083 ret
= RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
);
6084 ok(ret
, "RedrawWindow returned %d instead of TRUE\n", ret
);
6085 check_update_rgn( hwnd
, hrgn
);
6086 SetRectRgn( hrgn2
, 20, 20, 30, 30 );
6087 ret
= RedrawWindow( hwnd
, NULL
, hrgn2
, RDW_INVALIDATE
);
6088 ok(ret
, "RedrawWindow returned %d instead of TRUE\n", ret
);
6089 CombineRgn( hrgn
, hrgn
, hrgn2
, RGN_OR
);
6090 check_update_rgn( hwnd
, hrgn
);
6091 /* validate everything */
6092 ret
= RedrawWindow( hwnd
, NULL
, NULL
, RDW_VALIDATE
);
6093 ok(ret
, "RedrawWindow returned %d instead of TRUE\n", ret
);
6094 check_update_rgn( hwnd
, 0 );
6096 /* test empty region */
6097 SetRectRgn( hrgn
, 10, 10, 10, 15 );
6098 ret
= RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
);
6099 ok(ret
, "RedrawWindow returned %d instead of TRUE\n", ret
);
6100 check_update_rgn( hwnd
, 0 );
6101 /* test empty rect */
6102 SetRect( &rect
, 10, 10, 10, 15 );
6103 ret
= RedrawWindow( hwnd
, &rect
, NULL
, RDW_INVALIDATE
);
6104 ok(ret
, "RedrawWindow returned %d instead of TRUE\n", ret
);
6105 check_update_rgn( hwnd
, 0 );
6107 /* flush pending messages */
6111 GetClientRect( hwnd
, &rect
);
6112 SetRectRgn( hrgn
, 0, 0, rect
.right
- rect
.left
, rect
.bottom
- rect
.top
);
6113 /* MSDN: if hwnd parameter is NULL, InvalidateRect invalidates and redraws
6114 * all windows and sends WM_ERASEBKGND and WM_NCPAINT.
6116 trace("testing InvalidateRect(0, NULL, FALSE)\n");
6117 SetRectEmpty( &rect
);
6118 ok(InvalidateRect(0, &rect
, FALSE
), "InvalidateRect(0, &rc, FALSE) should fail\n");
6119 check_update_rgn( hwnd
, hrgn
);
6120 ok_sequence( WmInvalidateErase
, "InvalidateErase", FALSE
);
6122 ok_sequence( WmPaint
, "Paint", FALSE
);
6123 RedrawWindow( hwnd
, NULL
, NULL
, RDW_VALIDATE
);
6124 check_update_rgn( hwnd
, 0 );
6126 /* MSDN: if hwnd parameter is NULL, ValidateRect invalidates and redraws
6127 * all windows and sends WM_ERASEBKGND and WM_NCPAINT.
6129 trace("testing ValidateRect(0, NULL)\n");
6130 SetRectEmpty( &rect
);
6131 if (ValidateRect(0, &rect
)) /* not supported on Win9x */
6133 check_update_rgn( hwnd
, hrgn
);
6134 ok_sequence( WmInvalidateErase
, "InvalidateErase", FALSE
);
6136 ok_sequence( WmPaint
, "Paint", FALSE
);
6137 RedrawWindow( hwnd
, NULL
, NULL
, RDW_VALIDATE
);
6138 check_update_rgn( hwnd
, 0 );
6141 trace("testing InvalidateRgn(0, NULL, FALSE)\n");
6142 SetLastError(0xdeadbeef);
6143 ok(!InvalidateRgn(0, NULL
, FALSE
), "InvalidateRgn(0, NULL, FALSE) should fail\n");
6144 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
|| GetLastError() == 0xdeadbeef,
6145 "wrong error code %d\n", GetLastError());
6146 check_update_rgn( hwnd
, 0 );
6148 ok_sequence( WmEmptySeq
, "WmEmptySeq", FALSE
);
6150 trace("testing ValidateRgn(0, NULL)\n");
6151 SetLastError(0xdeadbeef);
6152 ok(!ValidateRgn(0, NULL
), "ValidateRgn(0, NULL) should fail\n");
6153 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
||
6154 broken( GetLastError() == 0xdeadbeef ) /* win9x */,
6155 "wrong error code %d\n", GetLastError());
6156 check_update_rgn( hwnd
, 0 );
6158 ok_sequence( WmEmptySeq
, "WmEmptySeq", FALSE
);
6160 /* now with frame */
6161 SetRectRgn( hrgn
, -5, -5, 20, 20 );
6163 /* flush pending messages */
6166 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_FRAME
);
6167 ok_sequence( WmEmptySeq
, "EmptySeq", FALSE
);
6169 SetRectRgn( hrgn
, 0, 0, 20, 20 ); /* GetUpdateRgn clips to client area */
6170 check_update_rgn( hwnd
, hrgn
);
6173 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASENOW
);
6174 ok_sequence( WmInvalidateRgn
, "InvalidateRgn", FALSE
);
6177 RedrawWindow( hwnd
, NULL
, NULL
, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASENOW
);
6178 ok_sequence( WmInvalidateFull
, "InvalidateFull", FALSE
);
6180 GetClientRect( hwnd
, &rect
);
6181 SetRectRgn( hrgn
, rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
6182 check_update_rgn( hwnd
, hrgn
);
6185 RedrawWindow( hwnd
, NULL
, NULL
, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASE
| RDW_ERASENOW
);
6186 ok_sequence( WmInvalidateErase
, "InvalidateErase", FALSE
);
6189 RedrawWindow( hwnd
, NULL
, NULL
, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASENOW
| RDW_UPDATENOW
);
6190 ok_sequence( WmInvalidatePaint
, "InvalidatePaint", FALSE
);
6191 check_update_rgn( hwnd
, 0 );
6194 RedrawWindow( hwnd
, NULL
, NULL
, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASE
| RDW_UPDATENOW
);
6195 ok_sequence( WmInvalidateErasePaint
, "InvalidateErasePaint", FALSE
);
6196 check_update_rgn( hwnd
, 0 );
6199 SetRectRgn( hrgn
, 0, 0, 100, 100 );
6200 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
);
6201 SetRectRgn( hrgn
, 0, 0, 50, 100 );
6202 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_VALIDATE
);
6203 SetRectRgn( hrgn
, 50, 0, 100, 100 );
6204 check_update_rgn( hwnd
, hrgn
);
6205 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_VALIDATE
| RDW_ERASENOW
);
6206 ok_sequence( WmEmptySeq
, "EmptySeq", FALSE
); /* must not generate messages, everything is valid */
6207 check_update_rgn( hwnd
, 0 );
6210 SetRectRgn( hrgn
, 0, 0, 100, 100 );
6211 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_ERASE
);
6212 SetRectRgn( hrgn
, 0, 0, 100, 50 );
6213 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_VALIDATE
| RDW_ERASENOW
);
6214 ok_sequence( WmErase
, "Erase", FALSE
);
6215 SetRectRgn( hrgn
, 0, 50, 100, 100 );
6216 check_update_rgn( hwnd
, hrgn
);
6219 SetRectRgn( hrgn
, 0, 0, 100, 100 );
6220 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_ERASE
);
6221 SetRectRgn( hrgn
, 0, 0, 50, 50 );
6222 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_VALIDATE
| RDW_NOERASE
| RDW_UPDATENOW
);
6223 ok_sequence( WmPaint
, "Paint", FALSE
);
6226 SetRectRgn( hrgn
, -4, -4, -2, -2 );
6227 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_FRAME
);
6228 SetRectRgn( hrgn
, -200, -200, -198, -198 );
6229 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_VALIDATE
| RDW_NOFRAME
| RDW_ERASENOW
);
6230 ok_sequence( WmEmptySeq
, "EmptySeq", FALSE
);
6233 SetRectRgn( hrgn
, -4, -4, -2, -2 );
6234 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_FRAME
);
6235 SetRectRgn( hrgn
, -4, -4, -3, -3 );
6236 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_VALIDATE
| RDW_NOFRAME
);
6237 SetRectRgn( hrgn
, 0, 0, 1, 1 );
6238 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_UPDATENOW
);
6239 ok_sequence( WmPaint
, "Paint", FALSE
);
6242 SetRectRgn( hrgn
, -4, -4, -1, -1 );
6243 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_FRAME
);
6244 RedrawWindow( hwnd
, NULL
, 0, RDW_ERASENOW
);
6245 /* make sure no WM_PAINT was generated */
6247 ok_sequence( WmInvalidateRgn
, "InvalidateRgn", FALSE
);
6250 SetRectRgn( hrgn
, -4, -4, -1, -1 );
6251 RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_FRAME
);
6252 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
))
6254 if (msg
.hwnd
== hwnd
&& msg
.message
== WM_PAINT
)
6256 /* GetUpdateRgn must return empty region since only nonclient area is invalidated */
6257 INT ret
= GetUpdateRgn( hwnd
, hrgn
, FALSE
);
6258 ok( ret
== NULLREGION
, "Invalid GetUpdateRgn result %d\n", ret
);
6259 ret
= GetUpdateRect( hwnd
, &rect
, FALSE
);
6260 ok( ret
, "Invalid GetUpdateRect result %d\n", ret
);
6261 /* this will send WM_NCPAINT and validate the non client area */
6262 ret
= GetUpdateRect( hwnd
, &rect
, TRUE
);
6263 ok( !ret
, "Invalid GetUpdateRect result %d\n", ret
);
6265 DispatchMessage( &msg
);
6267 ok_sequence( WmGetUpdateRect
, "GetUpdateRect", FALSE
);
6269 DestroyWindow( hwnd
);
6271 /* now test with a child window */
6273 hparent
= CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW
,
6274 100, 100, 200, 200, 0, 0, 0, NULL
);
6275 ok (hparent
!= 0, "Failed to create parent window\n");
6277 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
| WS_VISIBLE
| WS_BORDER
,
6278 10, 10, 100, 100, hparent
, 0, 0, NULL
);
6279 ok (hchild
!= 0, "Failed to create child window\n");
6281 ShowWindow( hparent
, SW_SHOW
);
6282 UpdateWindow( hparent
);
6283 UpdateWindow( hchild
);
6286 log_all_parent_messages
++;
6288 SetRect( &rect
, 0, 0, 50, 50 );
6289 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
6290 RedrawWindow( hparent
, NULL
, 0, RDW_ERASENOW
| RDW_ALLCHILDREN
);
6291 ok_sequence( WmInvalidateParentChild
, "InvalidateParentChild", FALSE
);
6293 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
6295 MapWindowPoints( hchild
, hparent
, &pt
, 1 );
6296 SetRectRgn( hrgn
, 0, 0, 50 - pt
.x
, 50 - pt
.y
);
6297 check_update_rgn( hchild
, hrgn
);
6298 SetRectRgn( hrgn
, 0, 0, 50, 50 );
6299 check_update_rgn( hparent
, hrgn
);
6300 RedrawWindow( hparent
, NULL
, 0, RDW_ERASENOW
);
6301 ok_sequence( WmInvalidateParent
, "InvalidateParent", FALSE
);
6302 RedrawWindow( hchild
, NULL
, 0, RDW_ERASENOW
);
6303 ok_sequence( WmEmptySeq
, "EraseNow child", FALSE
);
6306 ok_sequence( WmParentPaintNc
, "WmParentPaintNc", FALSE
);
6308 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
| RDW_ALLCHILDREN
);
6309 RedrawWindow( hparent
, NULL
, 0, RDW_ERASENOW
);
6310 ok_sequence( WmInvalidateParent
, "InvalidateParent2", FALSE
);
6311 RedrawWindow( hchild
, NULL
, 0, RDW_ERASENOW
);
6312 ok_sequence( WmEmptySeq
, "EraseNow child", FALSE
);
6314 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
);
6315 RedrawWindow( hparent
, NULL
, 0, RDW_ERASENOW
| RDW_ALLCHILDREN
);
6316 ok_sequence( WmInvalidateParentChild2
, "InvalidateParentChild2", FALSE
);
6318 SetWindowLong( hparent
, GWL_STYLE
, GetWindowLong(hparent
,GWL_STYLE
) | WS_CLIPCHILDREN
);
6320 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
| RDW_ALLCHILDREN
);
6321 RedrawWindow( hparent
, NULL
, 0, RDW_ERASENOW
);
6322 ok_sequence( WmInvalidateParentChild
, "InvalidateParentChild3", FALSE
);
6324 /* flush all paint messages */
6328 /* RDW_UPDATENOW on child with WS_CLIPCHILDREN doesn't change corresponding parent area */
6329 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
| RDW_ALLCHILDREN
);
6330 SetRectRgn( hrgn
, 0, 0, 50, 50 );
6331 check_update_rgn( hparent
, hrgn
);
6332 RedrawWindow( hchild
, NULL
, 0, RDW_UPDATENOW
);
6333 ok_sequence( WmInvalidateErasePaint2
, "WmInvalidateErasePaint2", FALSE
);
6334 SetRectRgn( hrgn
, 0, 0, 50, 50 );
6335 check_update_rgn( hparent
, hrgn
);
6337 /* flush all paint messages */
6339 SetWindowLong( hparent
, GWL_STYLE
, GetWindowLong(hparent
,GWL_STYLE
) & ~WS_CLIPCHILDREN
);
6342 /* RDW_UPDATENOW on child without WS_CLIPCHILDREN will validate corresponding parent area */
6343 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
6344 SetRectRgn( hrgn
, 0, 0, 50, 50 );
6345 check_update_rgn( hparent
, hrgn
);
6346 RedrawWindow( hchild
, NULL
, 0, RDW_UPDATENOW
);
6347 ok_sequence( WmInvalidateErasePaint2
, "WmInvalidateErasePaint2", FALSE
);
6348 SetRectRgn( hrgn2
, 10, 10, 50, 50 );
6349 CombineRgn( hrgn
, hrgn
, hrgn2
, RGN_DIFF
);
6350 check_update_rgn( hparent
, hrgn
);
6351 /* flush all paint messages */
6355 /* same as above but parent gets completely validated */
6356 SetRect( &rect
, 20, 20, 30, 30 );
6357 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
6358 SetRectRgn( hrgn
, 20, 20, 30, 30 );
6359 check_update_rgn( hparent
, hrgn
);
6360 RedrawWindow( hchild
, NULL
, 0, RDW_UPDATENOW
);
6361 ok_sequence( WmInvalidateErasePaint2
, "WmInvalidateErasePaint2", FALSE
);
6362 check_update_rgn( hparent
, 0 ); /* no update region */
6364 ok_sequence( WmEmptySeq
, "WmEmpty", FALSE
); /* and no paint messages */
6366 /* make sure RDW_VALIDATE on child doesn't have the same effect */
6368 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
6369 SetRectRgn( hrgn
, 20, 20, 30, 30 );
6370 check_update_rgn( hparent
, hrgn
);
6371 RedrawWindow( hchild
, NULL
, 0, RDW_VALIDATE
| RDW_NOERASE
);
6372 SetRectRgn( hrgn
, 20, 20, 30, 30 );
6373 check_update_rgn( hparent
, hrgn
);
6375 /* same as above but normal WM_PAINT doesn't validate parent */
6377 SetRect( &rect
, 20, 20, 30, 30 );
6378 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
6379 SetRectRgn( hrgn
, 20, 20, 30, 30 );
6380 check_update_rgn( hparent
, hrgn
);
6381 /* no WM_PAINT in child while parent still pending */
6382 while (PeekMessage( &msg
, hchild
, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
6383 ok_sequence( WmEmptySeq
, "No WM_PAINT", FALSE
);
6384 while (PeekMessage( &msg
, hparent
, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
6385 ok_sequence( WmParentErasePaint
, "WmParentErasePaint", FALSE
);
6388 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
6389 /* no WM_PAINT in child while parent still pending */
6390 while (PeekMessage( &msg
, hchild
, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
6391 ok_sequence( WmEmptySeq
, "No WM_PAINT", FALSE
);
6392 RedrawWindow( hparent
, &rect
, 0, RDW_VALIDATE
| RDW_NOERASE
| RDW_NOCHILDREN
);
6393 /* now that parent is valid child should get WM_PAINT */
6394 while (PeekMessage( &msg
, hchild
, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
6395 ok_sequence( WmInvalidateErasePaint2
, "WmInvalidateErasePaint2", FALSE
);
6396 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
6397 ok_sequence( WmEmptySeq
, "No other message", FALSE
);
6399 /* same thing with WS_CLIPCHILDREN in parent */
6401 SetWindowLong( hparent
, GWL_STYLE
, GetWindowLong(hparent
,GWL_STYLE
) | WS_CLIPCHILDREN
);
6402 ok_sequence( WmSetParentStyle
, "WmSetParentStyle", FALSE
);
6403 /* changing style invalidates non client area, but we need to invalidate something else to see it */
6404 RedrawWindow( hparent
, &rect
, 0, RDW_UPDATENOW
);
6405 ok_sequence( WmEmptySeq
, "No message", FALSE
);
6406 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_UPDATENOW
);
6407 ok_sequence( WmParentOnlyNcPaint
, "WmParentOnlyNcPaint", FALSE
);
6410 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_ALLCHILDREN
);
6411 SetRectRgn( hrgn
, 20, 20, 30, 30 );
6412 check_update_rgn( hparent
, hrgn
);
6413 /* no WM_PAINT in child while parent still pending */
6414 while (PeekMessage( &msg
, hchild
, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
6415 ok_sequence( WmEmptySeq
, "No WM_PAINT", FALSE
);
6416 /* WM_PAINT in parent first */
6417 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
6418 ok_sequence( WmParentPaintNc
, "WmParentPaintNc2", FALSE
);
6420 /* no RDW_ERASE in parent still causes RDW_ERASE and RDW_FRAME in child */
6422 SetRect( &rect
, 0, 0, 30, 30 );
6423 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ALLCHILDREN
);
6424 SetRectRgn( hrgn
, 0, 0, 30, 30 );
6425 check_update_rgn( hparent
, hrgn
);
6427 ok_sequence( WmParentPaintNc
, "WmParentPaintNc3", FALSE
);
6429 /* validate doesn't cause RDW_NOERASE or RDW_NOFRAME in child */
6431 SetRect( &rect
, -10, 0, 30, 30 );
6432 RedrawWindow( hchild
, &rect
, 0, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASE
);
6433 SetRect( &rect
, 0, 0, 20, 20 );
6434 RedrawWindow( hparent
, &rect
, 0, RDW_VALIDATE
| RDW_ALLCHILDREN
);
6435 RedrawWindow( hparent
, NULL
, 0, RDW_UPDATENOW
);
6436 ok_sequence( WmChildPaintNc
, "WmChildPaintNc", FALSE
);
6438 /* validate doesn't cause RDW_NOERASE or RDW_NOFRAME in child */
6440 SetRect( &rect
, -10, 0, 30, 30 );
6441 RedrawWindow( hchild
, &rect
, 0, RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASE
);
6442 SetRect( &rect
, 0, 0, 100, 100 );
6443 RedrawWindow( hparent
, &rect
, 0, RDW_VALIDATE
| RDW_ALLCHILDREN
);
6444 RedrawWindow( hparent
, NULL
, 0, RDW_UPDATENOW
);
6445 ok_sequence( WmEmptySeq
, "WmChildPaintNc2", FALSE
);
6446 RedrawWindow( hparent
, NULL
, 0, RDW_ERASENOW
);
6447 ok_sequence( WmEmptySeq
, "WmChildPaintNc3", FALSE
);
6449 /* test RDW_INTERNALPAINT behavior */
6452 RedrawWindow( hparent
, NULL
, 0, RDW_INTERNALPAINT
| RDW_NOCHILDREN
);
6454 ok_sequence( WmParentOnlyPaint
, "WmParentOnlyPaint", FALSE
);
6456 RedrawWindow( hparent
, NULL
, 0, RDW_INTERNALPAINT
| RDW_ALLCHILDREN
);
6458 ok_sequence( WmParentPaint
, "WmParentPaint", FALSE
);
6460 RedrawWindow( hparent
, NULL
, 0, RDW_INTERNALPAINT
);
6462 ok_sequence( WmParentOnlyPaint
, "WmParentOnlyPaint", FALSE
);
6464 assert( GetWindowLong(hparent
, GWL_STYLE
) & WS_CLIPCHILDREN
);
6465 UpdateWindow( hparent
);
6468 trace("testing SWP_FRAMECHANGED on parent with WS_CLIPCHILDREN\n");
6469 RedrawWindow( hchild
, NULL
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
6470 SetWindowPos( hparent
, 0, 0, 0, 0, 0, SWP_NOSIZE
| SWP_NOMOVE
|
6471 SWP_NOACTIVATE
| SWP_NOZORDER
| SWP_FRAMECHANGED
);
6473 ok_sequence(WmSWP_FrameChanged_clip
, "SetWindowPos:FrameChanged_clip", FALSE
);
6475 UpdateWindow( hparent
);
6478 trace("testing SWP_FRAMECHANGED|SWP_DEFERERASE on parent with WS_CLIPCHILDREN\n");
6479 RedrawWindow( hchild
, NULL
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
6480 SetWindowPos( hparent
, 0, 0, 0, 0, 0, SWP_NOSIZE
| SWP_NOMOVE
| SWP_DEFERERASE
|
6481 SWP_NOACTIVATE
| SWP_NOZORDER
| SWP_FRAMECHANGED
);
6483 ok_sequence(WmSWP_FrameChangedDeferErase
, "SetWindowPos:FrameChangedDeferErase", FALSE
);
6485 SetWindowLong( hparent
, GWL_STYLE
, GetWindowLong(hparent
,GWL_STYLE
) & ~WS_CLIPCHILDREN
);
6486 ok_sequence( WmSetParentStyle
, "WmSetParentStyle", FALSE
);
6487 RedrawWindow( hparent
, NULL
, 0, RDW_INTERNALPAINT
);
6489 ok_sequence( WmParentPaint
, "WmParentPaint", FALSE
);
6491 assert( !(GetWindowLong(hparent
, GWL_STYLE
) & WS_CLIPCHILDREN
) );
6492 UpdateWindow( hparent
);
6495 trace("testing SWP_FRAMECHANGED on parent without WS_CLIPCHILDREN\n");
6496 RedrawWindow( hchild
, NULL
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
6497 SetWindowPos( hparent
, 0, 0, 0, 0, 0, SWP_NOSIZE
| SWP_NOMOVE
|
6498 SWP_NOACTIVATE
| SWP_NOZORDER
| SWP_FRAMECHANGED
);
6500 ok_sequence(WmSWP_FrameChanged_noclip
, "SetWindowPos:FrameChanged_noclip", FALSE
);
6502 UpdateWindow( hparent
);
6505 trace("testing SWP_FRAMECHANGED|SWP_DEFERERASE on parent without WS_CLIPCHILDREN\n");
6506 RedrawWindow( hchild
, NULL
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_FRAME
);
6507 SetWindowPos( hparent
, 0, 0, 0, 0, 0, SWP_NOSIZE
| SWP_NOMOVE
| SWP_DEFERERASE
|
6508 SWP_NOACTIVATE
| SWP_NOZORDER
| SWP_FRAMECHANGED
);
6510 ok_sequence(WmSWP_FrameChangedDeferErase
, "SetWindowPos:FrameChangedDeferErase", FALSE
);
6512 ok(GetWindowLong( hparent
, GWL_STYLE
) & WS_VISIBLE
, "parent should be visible\n");
6513 ok(GetWindowLong( hchild
, GWL_STYLE
) & WS_VISIBLE
, "child should be visible\n");
6515 UpdateWindow( hparent
);
6518 trace("testing SetWindowPos(-10000, -10000) on child\n");
6519 SetWindowPos( hchild
, 0, -10000, -10000, 0, 0, SWP_NOSIZE
| SWP_NOACTIVATE
| SWP_NOZORDER
);
6520 check_update_rgn( hchild
, 0 );
6523 #if 0 /* this one doesn't pass under Wine yet */
6524 UpdateWindow( hparent
);
6527 trace("testing ShowWindow(SW_MINIMIZE) on child\n");
6528 ShowWindow( hchild
, SW_MINIMIZE
);
6529 check_update_rgn( hchild
, 0 );
6533 UpdateWindow( hparent
);
6536 trace("testing SetWindowPos(-10000, -10000) on parent\n");
6537 SetWindowPos( hparent
, 0, -10000, -10000, 0, 0, SWP_NOSIZE
| SWP_NOACTIVATE
| SWP_NOZORDER
);
6538 check_update_rgn( hparent
, 0 );
6541 log_all_parent_messages
--;
6542 DestroyWindow( hparent
);
6543 ok(!IsWindow(hchild
), "child must be destroyed with its parent\n");
6545 /* tests for moving windows off-screen (needs simple WS_POPUP windows) */
6547 hparent
= CreateWindowExA(0, "TestParentClass", "Test parent", WS_POPUP
| WS_VISIBLE
,
6548 100, 100, 200, 200, 0, 0, 0, NULL
);
6549 ok (hparent
!= 0, "Failed to create parent window\n");
6551 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD
| WS_VISIBLE
,
6552 10, 10, 100, 100, hparent
, 0, 0, NULL
);
6553 ok (hchild
!= 0, "Failed to create child window\n");
6555 ShowWindow( hparent
, SW_SHOW
);
6556 UpdateWindow( hparent
);
6557 UpdateWindow( hchild
);
6561 /* moving child outside of parent boundaries changes update region */
6562 SetRect( &rect
, 0, 0, 40, 40 );
6563 RedrawWindow( hchild
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
);
6564 SetRectRgn( hrgn
, 0, 0, 40, 40 );
6565 check_update_rgn( hchild
, hrgn
);
6566 MoveWindow( hchild
, -10, 10, 100, 100, FALSE
);
6567 SetRectRgn( hrgn
, 10, 0, 40, 40 );
6568 check_update_rgn( hchild
, hrgn
);
6569 MoveWindow( hchild
, -10, -10, 100, 100, FALSE
);
6570 SetRectRgn( hrgn
, 10, 10, 40, 40 );
6571 check_update_rgn( hchild
, hrgn
);
6573 /* moving parent off-screen does too */
6574 SetRect( &rect
, 0, 0, 100, 100 );
6575 RedrawWindow( hparent
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_NOCHILDREN
);
6576 SetRectRgn( hrgn
, 0, 0, 100, 100 );
6577 check_update_rgn( hparent
, hrgn
);
6578 SetRectRgn( hrgn
, 10, 10, 40, 40 );
6579 check_update_rgn( hchild
, hrgn
);
6580 MoveWindow( hparent
, -20, -20, 200, 200, FALSE
);
6581 SetRectRgn( hrgn
, 20, 20, 100, 100 );
6582 check_update_rgn( hparent
, hrgn
);
6583 SetRectRgn( hrgn
, 30, 30, 40, 40 );
6584 check_update_rgn( hchild
, hrgn
);
6586 /* invalidated region is cropped by the parent rects */
6587 SetRect( &rect
, 0, 0, 50, 50 );
6588 RedrawWindow( hchild
, &rect
, 0, RDW_INVALIDATE
| RDW_ERASE
);
6589 SetRectRgn( hrgn
, 30, 30, 50, 50 );
6590 check_update_rgn( hchild
, hrgn
);
6592 DestroyWindow( hparent
);
6593 ok(!IsWindow(hchild
), "child must be destroyed with its parent\n");
6596 DeleteObject( hrgn
);
6597 DeleteObject( hrgn2
);
6608 static DWORD WINAPI
thread_proc(void *param
)
6611 struct wnd_event
*wnd_event
= param
;
6613 wnd_event
->hwnd
= CreateWindowExA(0, "TestWindowClass", "window caption text", WS_OVERLAPPEDWINDOW
,
6614 100, 100, 200, 200, 0, 0, 0, NULL
);
6615 ok(wnd_event
->hwnd
!= 0, "Failed to create overlapped window\n");
6617 SetEvent(wnd_event
->start_event
);
6619 while (GetMessage(&msg
, 0, 0, 0))
6621 TranslateMessage(&msg
);
6622 DispatchMessage(&msg
);
6625 ok(IsWindow(wnd_event
->hwnd
), "window should still exist\n");
6630 static DWORD CALLBACK
create_grand_child_thread( void *param
)
6632 struct wnd_event
*wnd_event
= param
;
6636 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child",
6637 WS_CHILD
| WS_VISIBLE
, 0, 0, 10, 10, wnd_event
->hwnd
, 0, 0, NULL
);
6638 ok (hchild
!= 0, "Failed to create child window\n");
6641 SetEvent( wnd_event
->start_event
);
6645 MsgWaitForMultipleObjects(0, NULL
, FALSE
, 1000, QS_ALLINPUT
);
6646 if (!IsWindow( hchild
)) break; /* will be destroyed when parent thread exits */
6647 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage(&msg
);
6652 static DWORD CALLBACK
create_child_thread( void *param
)
6654 struct wnd_event
*wnd_event
= param
;
6655 struct wnd_event child_event
;
6659 child_event
.hwnd
= CreateWindowExA(0, "TestWindowClass", "Test child",
6660 WS_CHILD
| WS_VISIBLE
, 0, 0, 10, 10, wnd_event
->hwnd
, 0, 0, NULL
);
6661 ok (child_event
.hwnd
!= 0, "Failed to create child window\n");
6662 SetFocus( child_event
.hwnd
);
6665 child_event
.start_event
= wnd_event
->start_event
;
6666 wnd_event
->grand_child
= CreateThread(NULL
, 0, create_grand_child_thread
, &child_event
, 0, &tid
);
6669 DWORD ret
= MsgWaitForMultipleObjects(1, &child_event
.start_event
, FALSE
, 1000, QS_SENDMESSAGE
);
6670 if (ret
!= 1) break;
6671 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage(&msg
);
6673 ret
= WaitForSingleObject( wnd_event
->stop_event
, 5000 );
6674 ok( !ret
, "WaitForSingleObject failed %x\n", ret
);
6678 static void test_interthread_messages(void)
6685 int len
, expected_len
;
6686 struct wnd_event wnd_event
;
6689 wnd_event
.start_event
= CreateEventW(NULL
, 0, 0, NULL
);
6690 if (!wnd_event
.start_event
)
6692 win_skip("skipping interthread message test under win9x\n");
6696 hThread
= CreateThread(NULL
, 0, thread_proc
, &wnd_event
, 0, &tid
);
6697 ok(hThread
!= NULL
, "CreateThread failed, error %d\n", GetLastError());
6699 ok(WaitForSingleObject(wnd_event
.start_event
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
6701 CloseHandle(wnd_event
.start_event
);
6703 SetLastError(0xdeadbeef);
6704 ok(!DestroyWindow(wnd_event
.hwnd
), "DestroyWindow succeded\n");
6705 ok(GetLastError() == ERROR_ACCESS_DENIED
|| GetLastError() == 0xdeadbeef,
6706 "wrong error code %d\n", GetLastError());
6708 proc
= (WNDPROC
)GetWindowLongPtrA(wnd_event
.hwnd
, GWLP_WNDPROC
);
6709 ok(proc
!= NULL
, "GetWindowLongPtrA(GWLP_WNDPROC) error %d\n", GetLastError());
6711 expected_len
= lstrlenA("window caption text");
6712 memset(buf
, 0, sizeof(buf
));
6713 SetLastError(0xdeadbeef);
6714 len
= CallWindowProcA(proc
, wnd_event
.hwnd
, WM_GETTEXT
, sizeof(buf
), (LPARAM
)buf
);
6715 ok(len
== expected_len
, "CallWindowProcA(WM_GETTEXT) error %d, len %d, expected len %d\n", GetLastError(), len
, expected_len
);
6716 ok(!lstrcmpA(buf
, "window caption text"), "window text mismatch\n");
6718 msg
.hwnd
= wnd_event
.hwnd
;
6719 msg
.message
= WM_GETTEXT
;
6720 msg
.wParam
= sizeof(buf
);
6721 msg
.lParam
= (LPARAM
)buf
;
6722 memset(buf
, 0, sizeof(buf
));
6723 SetLastError(0xdeadbeef);
6724 len
= DispatchMessageA(&msg
);
6725 ok((!len
&& GetLastError() == ERROR_MESSAGE_SYNC_ONLY
) || broken(len
), /* nt4 */
6726 "DispatchMessageA(WM_GETTEXT) succeded on another thread window: ret %d, error %d\n", len
, GetLastError());
6728 /* the following test causes an exception in user.exe under win9x */
6729 msg
.hwnd
= wnd_event
.hwnd
;
6730 msg
.message
= WM_TIMER
;
6732 msg
.lParam
= GetWindowLongPtrA(wnd_event
.hwnd
, GWLP_WNDPROC
);
6733 SetLastError(0xdeadbeef);
6734 len
= DispatchMessageA(&msg
);
6735 ok(!len
&& GetLastError() == 0xdeadbeef,
6736 "DispatchMessageA(WM_TIMER) failed on another thread window: ret %d, error %d\n", len
, GetLastError());
6738 ret
= PostMessageA(wnd_event
.hwnd
, WM_QUIT
, 0, 0);
6739 ok( ret
, "PostMessageA(WM_QUIT) error %d\n", GetLastError());
6741 ok(WaitForSingleObject(hThread
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
6742 CloseHandle(hThread
);
6744 ok(!IsWindow(wnd_event
.hwnd
), "window should be destroyed on thread exit\n");
6746 wnd_event
.hwnd
= CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
6747 100, 100, 200, 200, 0, 0, 0, NULL
);
6748 ok (wnd_event
.hwnd
!= 0, "Failed to create parent window\n");
6750 log_all_parent_messages
++;
6751 wnd_event
.start_event
= CreateEventA( NULL
, TRUE
, FALSE
, NULL
);
6752 wnd_event
.stop_event
= CreateEventA( NULL
, TRUE
, FALSE
, NULL
);
6753 hThread
= CreateThread( NULL
, 0, create_child_thread
, &wnd_event
, 0, &tid
);
6756 ret
= MsgWaitForMultipleObjects(1, &wnd_event
.start_event
, FALSE
, 1000, QS_SENDMESSAGE
);
6757 if (ret
!= 1) break;
6758 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage(&msg
);
6760 ok( !ret
, "MsgWaitForMultipleObjects failed %x\n", ret
);
6761 /* now wait for the thread without processing messages; this shouldn't deadlock */
6762 SetEvent( wnd_event
.stop_event
);
6763 ret
= WaitForSingleObject( hThread
, 5000 );
6764 ok( !ret
, "WaitForSingleObject failed %x\n", ret
);
6765 CloseHandle( hThread
);
6767 ret
= WaitForSingleObject( wnd_event
.grand_child
, 5000 );
6768 ok( !ret
, "WaitForSingleObject failed %x\n", ret
);
6769 CloseHandle( wnd_event
.grand_child
);
6771 CloseHandle( wnd_event
.start_event
);
6772 CloseHandle( wnd_event
.stop_event
);
6774 ok_sequence(WmExitThreadSeq
, "destroy child on thread exit", FALSE
);
6775 log_all_parent_messages
--;
6776 DestroyWindow( wnd_event
.hwnd
);
6780 static const struct message WmVkN
[] = {
6781 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 1 }, /* XP */
6782 { WM_KEYDOWN
, wparam
|lparam
, 'N', 1 },
6783 { WM_KEYDOWN
, sent
|wparam
|lparam
, 'N', 1 },
6784 { WM_CHAR
, wparam
|lparam
, 'n', 1 },
6785 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1002,1), 0 },
6786 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xc0000001 }, /* XP */
6787 { WM_KEYUP
, wparam
|lparam
, 'N', 0xc0000001 },
6788 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xc0000001 },
6791 static const struct message WmShiftVkN
[] = {
6792 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 1 }, /* XP */
6793 { WM_KEYDOWN
, wparam
|lparam
, VK_SHIFT
, 1 },
6794 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_SHIFT
, 1 },
6795 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 1 }, /* XP */
6796 { WM_KEYDOWN
, wparam
|lparam
, 'N', 1 },
6797 { WM_KEYDOWN
, sent
|wparam
|lparam
, 'N', 1 },
6798 { WM_CHAR
, wparam
|lparam
, 'N', 1 },
6799 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1001,1), 0 },
6800 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xc0000001 }, /* XP */
6801 { WM_KEYUP
, wparam
|lparam
, 'N', 0xc0000001 },
6802 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xc0000001 },
6803 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 0xc0000001 }, /* XP */
6804 { WM_KEYUP
, wparam
|lparam
, VK_SHIFT
, 0xc0000001 },
6805 { WM_KEYUP
, sent
|wparam
|lparam
, VK_SHIFT
, 0xc0000001 },
6808 static const struct message WmCtrlVkN
[] = {
6809 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 1 }, /* XP */
6810 { WM_KEYDOWN
, wparam
|lparam
, VK_CONTROL
, 1 },
6811 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_CONTROL
, 1 },
6812 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 1 }, /* XP */
6813 { WM_KEYDOWN
, wparam
|lparam
, 'N', 1 },
6814 { WM_KEYDOWN
, sent
|wparam
|lparam
, 'N', 1 },
6815 { WM_CHAR
, wparam
|lparam
, 0x000e, 1 },
6816 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1000,1), 0 },
6817 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xc0000001 }, /* XP */
6818 { WM_KEYUP
, wparam
|lparam
, 'N', 0xc0000001 },
6819 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xc0000001 },
6820 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 0xc0000001 }, /* XP */
6821 { WM_KEYUP
, wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
6822 { WM_KEYUP
, sent
|wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
6825 static const struct message WmCtrlVkN_2
[] = {
6826 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 1 }, /* XP */
6827 { WM_KEYDOWN
, wparam
|lparam
, VK_CONTROL
, 1 },
6828 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_CONTROL
, 1 },
6829 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 1 }, /* XP */
6830 { WM_KEYDOWN
, wparam
|lparam
, 'N', 1 },
6831 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1000,1), 0 },
6832 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xc0000001 }, /* XP */
6833 { WM_KEYUP
, wparam
|lparam
, 'N', 0xc0000001 },
6834 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xc0000001 },
6835 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 0xc0000001 }, /* XP */
6836 { WM_KEYUP
, wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
6837 { WM_KEYUP
, sent
|wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
6840 static const struct message WmAltVkN
[] = {
6841 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 }, /* XP */
6842 { WM_SYSKEYDOWN
, wparam
|lparam
, VK_MENU
, 0x20000001 },
6843 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
6844 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0x20000001 }, /* XP */
6845 { WM_SYSKEYDOWN
, wparam
|lparam
, 'N', 0x20000001 },
6846 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, 'N', 0x20000001 },
6847 { WM_SYSCHAR
, wparam
|lparam
, 'n', 0x20000001 },
6848 { WM_SYSCHAR
, sent
|wparam
|lparam
, 'n', 0x20000001 },
6849 { WM_SYSCOMMAND
, sent
|defwinproc
|wparam
|lparam
, SC_KEYMENU
, 'n' },
6850 { HCBT_SYSCOMMAND
, hook
},
6851 { WM_ENTERMENULOOP
, sent
|defwinproc
|wparam
|lparam
, 0, 0 },
6852 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
6853 { 0x00AE, sent
|defwinproc
|optional
}, /* XP */
6854 { WM_GETTEXT
, sent
|defwinproc
|optional
}, /* XP */
6855 { WM_INITMENU
, sent
|defwinproc
},
6856 { EVENT_SYSTEM_MENUSTART
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 0 },
6857 { WM_MENUCHAR
, sent
|defwinproc
|wparam
, MAKEWPARAM('n',MF_SYSMENU
) },
6858 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, 0, 0 },
6859 { WM_CAPTURECHANGED
, sent
|defwinproc
},
6860 { WM_MENUSELECT
, sent
|defwinproc
|wparam
, MAKEWPARAM(0,0xffff) },
6861 { EVENT_SYSTEM_MENUEND
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 0 },
6862 { WM_EXITMENULOOP
, sent
|defwinproc
},
6863 { WM_MENUSELECT
, sent
|defwinproc
|wparam
|optional
, MAKEWPARAM(0,0xffff) }, /* Win95 bug */
6864 { WM_EXITMENULOOP
, sent
|defwinproc
|optional
}, /* Win95 bug */
6865 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xe0000001 }, /* XP */
6866 { WM_SYSKEYUP
, wparam
|lparam
, 'N', 0xe0000001 },
6867 { WM_SYSKEYUP
, sent
|wparam
|lparam
, 'N', 0xe0000001 },
6868 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xc0000001 }, /* XP */
6869 { WM_KEYUP
, wparam
|lparam
, VK_MENU
, 0xc0000001 },
6870 { WM_KEYUP
, sent
|wparam
|lparam
, VK_MENU
, 0xc0000001 },
6873 static const struct message WmAltVkN_2
[] = {
6874 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 }, /* XP */
6875 { WM_SYSKEYDOWN
, wparam
|lparam
, VK_MENU
, 0x20000001 },
6876 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
6877 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0x20000001 }, /* XP */
6878 { WM_SYSKEYDOWN
, wparam
|lparam
, 'N', 0x20000001 },
6879 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1003,1), 0 },
6880 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xe0000001 }, /* XP */
6881 { WM_SYSKEYUP
, wparam
|lparam
, 'N', 0xe0000001 },
6882 { WM_SYSKEYUP
, sent
|wparam
|lparam
, 'N', 0xe0000001 },
6883 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xc0000001 }, /* XP */
6884 { WM_KEYUP
, wparam
|lparam
, VK_MENU
, 0xc0000001 },
6885 { WM_KEYUP
, sent
|wparam
|lparam
, VK_MENU
, 0xc0000001 },
6888 static const struct message WmCtrlAltVkN
[] = {
6889 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 1 }, /* XP */
6890 { WM_KEYDOWN
, wparam
|lparam
, VK_CONTROL
, 1 },
6891 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_CONTROL
, 1 },
6892 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 }, /* XP */
6893 { WM_KEYDOWN
, wparam
|lparam
, VK_MENU
, 0x20000001 },
6894 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
6895 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0x20000001 }, /* XP */
6896 { WM_KEYDOWN
, wparam
|lparam
, 'N', 0x20000001 },
6897 { WM_KEYDOWN
, sent
|wparam
|lparam
, 'N', 0x20000001 },
6898 { WM_CHAR
, optional
},
6899 { WM_CHAR
, sent
|optional
},
6900 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xe0000001 }, /* XP */
6901 { WM_KEYUP
, wparam
|lparam
, 'N', 0xe0000001 },
6902 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xe0000001 },
6903 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xc0000001 }, /* XP */
6904 { WM_KEYUP
, wparam
|lparam
, VK_MENU
, 0xc0000001 },
6905 { WM_KEYUP
, sent
|wparam
|lparam
, VK_MENU
, 0xc0000001 },
6906 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 0xc0000001 }, /* XP */
6907 { WM_KEYUP
, wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
6908 { WM_KEYUP
, sent
|wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
6911 static const struct message WmCtrlShiftVkN
[] = {
6912 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 1 }, /* XP */
6913 { WM_KEYDOWN
, wparam
|lparam
, VK_CONTROL
, 1 },
6914 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_CONTROL
, 1 },
6915 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 1 }, /* XP */
6916 { WM_KEYDOWN
, wparam
|lparam
, VK_SHIFT
, 1 },
6917 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_SHIFT
, 1 },
6918 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 1 }, /* XP */
6919 { WM_KEYDOWN
, wparam
|lparam
, 'N', 1 },
6920 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1004,1), 0 },
6921 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xc0000001 }, /* XP */
6922 { WM_KEYUP
, wparam
|lparam
, 'N', 0xc0000001 },
6923 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xc0000001 },
6924 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 0xc0000001 }, /* XP */
6925 { WM_KEYUP
, wparam
|lparam
, VK_SHIFT
, 0xc0000001 },
6926 { WM_KEYUP
, sent
|wparam
|lparam
, VK_SHIFT
, 0xc0000001 },
6927 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 0xc0000001 }, /* XP */
6928 { WM_KEYUP
, wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
6929 { WM_KEYUP
, sent
|wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
6932 static const struct message WmCtrlAltShiftVkN
[] = {
6933 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 1 }, /* XP */
6934 { WM_KEYDOWN
, wparam
|lparam
, VK_CONTROL
, 1 },
6935 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_CONTROL
, 1 },
6936 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 }, /* XP */
6937 { WM_KEYDOWN
, wparam
|lparam
, VK_MENU
, 0x20000001 },
6938 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
6939 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 0x20000001 }, /* XP */
6940 { WM_KEYDOWN
, wparam
|lparam
, VK_SHIFT
, 0x20000001 },
6941 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_SHIFT
, 0x20000001 },
6942 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0x20000001 }, /* XP */
6943 { WM_KEYDOWN
, wparam
|lparam
, 'N', 0x20000001 },
6944 { WM_COMMAND
, sent
|wparam
|lparam
, MAKEWPARAM(1005,1), 0 },
6945 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xe0000001 }, /* XP */
6946 { WM_KEYUP
, wparam
|lparam
, 'N', 0xe0000001 },
6947 { WM_KEYUP
, sent
|wparam
|lparam
, 'N', 0xe0000001 },
6948 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 0xe0000001 }, /* XP */
6949 { WM_KEYUP
, wparam
|lparam
, VK_SHIFT
, 0xe0000001 },
6950 { WM_KEYUP
, sent
|wparam
|lparam
, VK_SHIFT
, 0xe0000001 },
6951 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xc0000001 }, /* XP */
6952 { WM_KEYUP
, wparam
|lparam
, VK_MENU
, 0xc0000001 },
6953 { WM_KEYUP
, sent
|wparam
|lparam
, VK_MENU
, 0xc0000001 },
6954 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_CONTROL
, 0xc0000001 }, /* XP */
6955 { WM_KEYUP
, wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
6956 { WM_KEYUP
, sent
|wparam
|lparam
, VK_CONTROL
, 0xc0000001 },
6959 static const struct message WmAltPressRelease
[] = {
6960 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 }, /* XP */
6961 { WM_SYSKEYDOWN
, wparam
|lparam
, VK_MENU
, 0x20000001 },
6962 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
6963 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xc0000001 }, /* XP */
6964 { WM_SYSKEYUP
, wparam
|lparam
, VK_MENU
, 0xc0000001 },
6965 { WM_SYSKEYUP
, sent
|wparam
|lparam
, VK_MENU
, 0xc0000001 },
6966 { WM_SYSCOMMAND
, sent
|defwinproc
|wparam
|lparam
, SC_KEYMENU
, 0 },
6967 { HCBT_SYSCOMMAND
, hook
},
6968 { WM_ENTERMENULOOP
, sent
|defwinproc
|wparam
|lparam
, 0, 0 },
6969 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
6970 { WM_INITMENU
, sent
|defwinproc
},
6971 { EVENT_SYSTEM_MENUSTART
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 0 },
6972 { WM_MENUSELECT
, sent
|defwinproc
|wparam
, MAKEWPARAM(0,MF_SYSMENU
|MF_POPUP
|MF_HILITE
) },
6973 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 1 },
6975 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x30000001 }, /* XP */
6977 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 0 },
6978 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, 0, 0, },
6979 { WM_CAPTURECHANGED
, sent
|defwinproc
},
6980 { WM_MENUSELECT
, sent
|defwinproc
|wparam
|optional
, MAKEWPARAM(0,0xffff) },
6981 { EVENT_SYSTEM_MENUEND
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 0 },
6982 { WM_EXITMENULOOP
, sent
|defwinproc
},
6983 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xc0000001 }, /* XP */
6984 { WM_SYSKEYUP
, wparam
|lparam
, VK_MENU
, 0xc0000001 },
6985 { WM_SYSKEYUP
, sent
|wparam
|lparam
, VK_MENU
, 0xc0000001 },
6988 static const struct message WmShiftMouseButton
[] = {
6989 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 1 }, /* XP */
6990 { WM_KEYDOWN
, wparam
|lparam
, VK_SHIFT
, 1 },
6991 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_SHIFT
, 1 },
6992 { WM_MOUSEMOVE
, wparam
|optional
, 0, 0 },
6993 { WM_MOUSEMOVE
, sent
|wparam
|optional
, 0, 0 },
6994 { WM_LBUTTONDOWN
, wparam
, MK_LBUTTON
|MK_SHIFT
, 0 },
6995 { WM_LBUTTONDOWN
, sent
|wparam
, MK_LBUTTON
|MK_SHIFT
, 0 },
6996 { WM_LBUTTONUP
, wparam
, MK_SHIFT
, 0 },
6997 { WM_LBUTTONUP
, sent
|wparam
, MK_SHIFT
, 0 },
6998 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 0xc0000001 }, /* XP */
6999 { WM_KEYUP
, wparam
|lparam
, VK_SHIFT
, 0xc0000001 },
7000 { WM_KEYUP
, sent
|wparam
|lparam
, VK_SHIFT
, 0xc0000001 },
7003 static const struct message WmF1Seq
[] = {
7004 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_F1
, 1 }, /* XP */
7005 { WM_KEYDOWN
, wparam
|lparam
, VK_F1
, 1 },
7006 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_F1
, 0x00000001 },
7007 { WM_KEYF1
, wparam
|lparam
, 0, 0 },
7008 { WM_KEYF1
, sent
|wparam
|lparam
, 0, 0 },
7009 { WM_HELP
, sent
|defwinproc
},
7010 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_F1
, 0xc0000001 }, /* XP */
7011 { WM_KEYUP
, wparam
|lparam
, VK_F1
, 0xc0000001 },
7012 { WM_KEYUP
, sent
|wparam
|lparam
, VK_F1
, 0xc0000001 },
7015 static const struct message WmVkAppsSeq
[] = {
7016 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_APPS
, 1 }, /* XP */
7017 { WM_KEYDOWN
, wparam
|lparam
, VK_APPS
, 1 },
7018 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_APPS
, 0x00000001 },
7019 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_APPS
, 0xc0000001 }, /* XP */
7020 { WM_KEYUP
, wparam
|lparam
, VK_APPS
, 0xc0000001 },
7021 { WM_KEYUP
, sent
|wparam
|lparam
, VK_APPS
, 0xc0000001 },
7022 { WM_CONTEXTMENU
, lparam
, /*hwnd*/0, -1 },
7023 { WM_CONTEXTMENU
, sent
|lparam
, /*hwnd*/0, -1 },
7026 static const struct message WmVkF10Seq
[] = {
7027 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_F10
, 1 }, /* XP */
7028 { WM_SYSKEYDOWN
, wparam
|lparam
, VK_F10
, 1 },
7029 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, VK_F10
, 0x00000001 },
7030 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_F10
, 0xc0000001 }, /* XP */
7031 { WM_SYSKEYUP
, wparam
|lparam
, VK_F10
, 0xc0000001 },
7032 { WM_SYSKEYUP
, sent
|wparam
|lparam
, VK_F10
, 0xc0000001 },
7033 { WM_SYSCOMMAND
, sent
|defwinproc
|wparam
, SC_KEYMENU
},
7034 { HCBT_SYSCOMMAND
, hook
},
7035 { WM_ENTERMENULOOP
, sent
|defwinproc
|wparam
|lparam
, 0, 0 },
7036 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
7037 { WM_INITMENU
, sent
|defwinproc
},
7038 { EVENT_SYSTEM_MENUSTART
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 0 },
7039 { WM_MENUSELECT
, sent
|defwinproc
|wparam
, MAKEWPARAM(0,MF_SYSMENU
|MF_POPUP
|MF_HILITE
) },
7040 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 1 },
7042 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_F10
, 0x10000001 }, /* XP */
7044 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_F10
, 1 }, /* XP */
7045 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 0 },
7046 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, 0, 0, },
7047 { WM_CAPTURECHANGED
, sent
|defwinproc
},
7048 { WM_MENUSELECT
, sent
|defwinproc
|wparam
|optional
, MAKEWPARAM(0,0xffff) },
7049 { EVENT_SYSTEM_MENUEND
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 0 },
7050 { WM_EXITMENULOOP
, sent
|defwinproc
},
7051 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_F10
, 0xc0000001 }, /* XP */
7052 { WM_SYSKEYUP
, wparam
|lparam
, VK_F10
, 0xc0000001 },
7053 { WM_SYSKEYUP
, sent
|wparam
|lparam
, VK_F10
, 0xc0000001 },
7056 static const struct message WmShiftF10Seq
[] = {
7057 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 1 }, /* XP */
7058 { WM_KEYDOWN
, wparam
|lparam
, VK_SHIFT
, 1 },
7059 { WM_KEYDOWN
, sent
|wparam
|lparam
, VK_SHIFT
, 0x00000001 },
7060 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_F10
, 1 }, /* XP */
7061 { WM_SYSKEYDOWN
, wparam
|lparam
, VK_F10
, 1 },
7062 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, VK_F10
, 0x00000001 },
7063 { WM_CONTEXTMENU
, sent
|defwinproc
|lparam
, /*hwnd*/0, -1 },
7064 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_F10
, 0xc0000001 }, /* XP */
7065 { WM_SYSKEYUP
, wparam
|lparam
, VK_F10
, 0xc0000001 },
7066 { WM_SYSKEYUP
, sent
|wparam
|lparam
, VK_F10
, 0xc0000001 },
7067 { WM_SYSCOMMAND
, sent
|defwinproc
|wparam
, SC_KEYMENU
},
7068 { HCBT_SYSCOMMAND
, hook
},
7069 { WM_ENTERMENULOOP
, sent
|defwinproc
|wparam
|lparam
, 0, 0 },
7070 { WM_INITMENU
, sent
|defwinproc
},
7071 { WM_MENUSELECT
, sent
|defwinproc
|wparam
, MAKEWPARAM(0,MF_SYSMENU
|MF_POPUP
|MF_HILITE
) },
7072 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_SHIFT
, 0xd0000001 }, /* XP */
7073 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_ESCAPE
, 0x10000001 }, /* XP */
7074 { WM_CAPTURECHANGED
, sent
|defwinproc
|wparam
|lparam
, 0, 0 },
7075 { WM_MENUSELECT
, sent
|defwinproc
|wparam
|lparam
, 0xffff0000, 0 },
7076 { WM_EXITMENULOOP
, sent
|defwinproc
|wparam
|lparam
, 0, 0 },
7077 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_ESCAPE
, 0xc0000001 }, /* XP */
7078 { WM_KEYUP
, wparam
|lparam
, VK_ESCAPE
, 0xc0000001 },
7079 { WM_KEYUP
, sent
|wparam
|lparam
, VK_ESCAPE
, 0xc0000001 },
7083 static void pump_msg_loop(HWND hwnd
, HACCEL hAccel
)
7087 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
))
7089 struct recvd_message log_msg
;
7091 /* ignore some unwanted messages */
7092 if (msg
.message
== WM_MOUSEMOVE
||
7093 msg
.message
== WM_TIMER
||
7094 ignore_message( msg
.message
))
7097 log_msg
.hwnd
= msg
.hwnd
;
7098 log_msg
.message
= msg
.message
;
7099 log_msg
.flags
= wparam
|lparam
;
7100 log_msg
.wParam
= msg
.wParam
;
7101 log_msg
.lParam
= msg
.lParam
;
7102 log_msg
.descr
= "accel";
7103 add_message(&log_msg
);
7105 if (!hAccel
|| !TranslateAccelerator(hwnd
, hAccel
, &msg
))
7107 TranslateMessage(&msg
);
7108 DispatchMessage(&msg
);
7113 static void test_accelerators(void)
7119 HWND hwnd
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
7120 100, 100, 200, 200, 0, 0, 0, NULL
);
7129 ok(GetFocus() == hwnd
, "wrong focus window %p\n", GetFocus());
7131 state
= GetKeyState(VK_SHIFT
);
7132 ok(!(state
& 0x8000), "wrong Shift state %04x\n", state
);
7133 state
= GetKeyState(VK_CAPITAL
);
7134 ok(state
== 0, "wrong CapsLock state %04x\n", state
);
7136 hAccel
= LoadAccelerators(GetModuleHandleA(0), MAKEINTRESOURCE(1));
7137 assert(hAccel
!= 0);
7140 pump_msg_loop(hwnd
, 0);
7143 trace("testing VK_N press/release\n");
7145 keybd_event('N', 0, 0, 0);
7146 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
7147 pump_msg_loop(hwnd
, hAccel
);
7148 if (!sequence_cnt
) /* we didn't get any message */
7150 skip( "queuing key events not supported\n" );
7153 ok_sequence(WmVkN
, "VK_N press/release", FALSE
);
7155 trace("testing Shift+VK_N press/release\n");
7157 keybd_event(VK_SHIFT
, 0, 0, 0);
7158 keybd_event('N', 0, 0, 0);
7159 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
7160 keybd_event(VK_SHIFT
, 0, KEYEVENTF_KEYUP
, 0);
7161 pump_msg_loop(hwnd
, hAccel
);
7162 ok_sequence(WmShiftVkN
, "Shift+VK_N press/release", FALSE
);
7164 trace("testing Ctrl+VK_N press/release\n");
7166 keybd_event(VK_CONTROL
, 0, 0, 0);
7167 keybd_event('N', 0, 0, 0);
7168 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
7169 keybd_event(VK_CONTROL
, 0, KEYEVENTF_KEYUP
, 0);
7170 pump_msg_loop(hwnd
, hAccel
);
7171 ok_sequence(WmCtrlVkN
, "Ctrl+VK_N press/release", FALSE
);
7173 trace("testing Alt+VK_N press/release\n");
7175 keybd_event(VK_MENU
, 0, 0, 0);
7176 keybd_event('N', 0, 0, 0);
7177 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
7178 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
7179 pump_msg_loop(hwnd
, hAccel
);
7180 ok_sequence(WmAltVkN
, "Alt+VK_N press/release", FALSE
);
7182 trace("testing Ctrl+Alt+VK_N press/release 1\n");
7184 keybd_event(VK_CONTROL
, 0, 0, 0);
7185 keybd_event(VK_MENU
, 0, 0, 0);
7186 keybd_event('N', 0, 0, 0);
7187 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
7188 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
7189 keybd_event(VK_CONTROL
, 0, KEYEVENTF_KEYUP
, 0);
7190 pump_msg_loop(hwnd
, hAccel
);
7191 ok_sequence(WmCtrlAltVkN
, "Ctrl+Alt+VK_N press/release 1", FALSE
);
7193 ret
= DestroyAcceleratorTable(hAccel
);
7194 ok( ret
, "DestroyAcceleratorTable error %d\n", GetLastError());
7196 hAccel
= LoadAccelerators(GetModuleHandleA(0), MAKEINTRESOURCE(2));
7197 assert(hAccel
!= 0);
7199 trace("testing VK_N press/release\n");
7201 keybd_event('N', 0, 0, 0);
7202 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
7203 pump_msg_loop(hwnd
, hAccel
);
7204 ok_sequence(WmVkN
, "VK_N press/release", FALSE
);
7206 trace("testing Shift+VK_N press/release\n");
7208 keybd_event(VK_SHIFT
, 0, 0, 0);
7209 keybd_event('N', 0, 0, 0);
7210 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
7211 keybd_event(VK_SHIFT
, 0, KEYEVENTF_KEYUP
, 0);
7212 pump_msg_loop(hwnd
, hAccel
);
7213 ok_sequence(WmShiftVkN
, "Shift+VK_N press/release", FALSE
);
7215 trace("testing Ctrl+VK_N press/release 2\n");
7217 keybd_event(VK_CONTROL
, 0, 0, 0);
7218 keybd_event('N', 0, 0, 0);
7219 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
7220 keybd_event(VK_CONTROL
, 0, KEYEVENTF_KEYUP
, 0);
7221 pump_msg_loop(hwnd
, hAccel
);
7222 ok_sequence(WmCtrlVkN_2
, "Ctrl+VK_N press/release 2", FALSE
);
7224 trace("testing Alt+VK_N press/release 2\n");
7226 keybd_event(VK_MENU
, 0, 0, 0);
7227 keybd_event('N', 0, 0, 0);
7228 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
7229 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
7230 pump_msg_loop(hwnd
, hAccel
);
7231 ok_sequence(WmAltVkN_2
, "Alt+VK_N press/release 2", FALSE
);
7233 trace("testing Ctrl+Alt+VK_N press/release 2\n");
7235 keybd_event(VK_CONTROL
, 0, 0, 0);
7236 keybd_event(VK_MENU
, 0, 0, 0);
7237 keybd_event('N', 0, 0, 0);
7238 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
7239 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
7240 keybd_event(VK_CONTROL
, 0, KEYEVENTF_KEYUP
, 0);
7241 pump_msg_loop(hwnd
, hAccel
);
7242 ok_sequence(WmCtrlAltVkN
, "Ctrl+Alt+VK_N press/release 2", FALSE
);
7244 trace("testing Ctrl+Shift+VK_N press/release\n");
7246 keybd_event(VK_CONTROL
, 0, 0, 0);
7247 keybd_event(VK_SHIFT
, 0, 0, 0);
7248 keybd_event('N', 0, 0, 0);
7249 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
7250 keybd_event(VK_SHIFT
, 0, KEYEVENTF_KEYUP
, 0);
7251 keybd_event(VK_CONTROL
, 0, KEYEVENTF_KEYUP
, 0);
7252 pump_msg_loop(hwnd
, hAccel
);
7253 ok_sequence(WmCtrlShiftVkN
, "Ctrl+Shift+VK_N press/release", FALSE
);
7255 trace("testing Ctrl+Alt+Shift+VK_N press/release\n");
7257 keybd_event(VK_CONTROL
, 0, 0, 0);
7258 keybd_event(VK_MENU
, 0, 0, 0);
7259 keybd_event(VK_SHIFT
, 0, 0, 0);
7260 keybd_event('N', 0, 0, 0);
7261 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
7262 keybd_event(VK_SHIFT
, 0, KEYEVENTF_KEYUP
, 0);
7263 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
7264 keybd_event(VK_CONTROL
, 0, KEYEVENTF_KEYUP
, 0);
7265 pump_msg_loop(hwnd
, hAccel
);
7266 ok_sequence(WmCtrlAltShiftVkN
, "Ctrl+Alt+Shift+VK_N press/release", FALSE
);
7268 ret
= DestroyAcceleratorTable(hAccel
);
7269 ok( ret
, "DestroyAcceleratorTable error %d\n", GetLastError());
7272 trace("testing Alt press/release\n");
7274 keybd_event(VK_MENU
, 0, 0, 0);
7275 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
7276 keybd_event(VK_MENU
, 0, 0, 0);
7277 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
7278 pump_msg_loop(hwnd
, 0);
7279 /* this test doesn't pass in Wine for managed windows */
7280 ok_sequence(WmAltPressRelease
, "Alt press/release", TRUE
);
7282 trace("testing VK_F1 press/release\n");
7283 keybd_event(VK_F1
, 0, 0, 0);
7284 keybd_event(VK_F1
, 0, KEYEVENTF_KEYUP
, 0);
7285 pump_msg_loop(hwnd
, 0);
7286 ok_sequence(WmF1Seq
, "F1 press/release", FALSE
);
7288 trace("testing VK_APPS press/release\n");
7289 keybd_event(VK_APPS
, 0, 0, 0);
7290 keybd_event(VK_APPS
, 0, KEYEVENTF_KEYUP
, 0);
7291 pump_msg_loop(hwnd
, 0);
7292 ok_sequence(WmVkAppsSeq
, "VK_APPS press/release", FALSE
);
7294 trace("testing VK_F10 press/release\n");
7295 keybd_event(VK_F10
, 0, 0, 0);
7296 keybd_event(VK_F10
, 0, KEYEVENTF_KEYUP
, 0);
7297 keybd_event(VK_F10
, 0, 0, 0);
7298 keybd_event(VK_F10
, 0, KEYEVENTF_KEYUP
, 0);
7299 pump_msg_loop(hwnd
, 0);
7300 ok_sequence(WmVkF10Seq
, "VK_F10 press/release", TRUE
);
7302 trace("testing SHIFT+F10 press/release\n");
7303 keybd_event(VK_SHIFT
, 0, 0, 0);
7304 keybd_event(VK_F10
, 0, 0, 0);
7305 keybd_event(VK_F10
, 0, KEYEVENTF_KEYUP
, 0);
7306 keybd_event(VK_SHIFT
, 0, KEYEVENTF_KEYUP
, 0);
7307 keybd_event(VK_ESCAPE
, 0, 0, 0);
7308 keybd_event(VK_ESCAPE
, 0, KEYEVENTF_KEYUP
, 0);
7309 pump_msg_loop(hwnd
, 0);
7310 ok_sequence(WmShiftF10Seq
, "SHIFT+F10 press/release", TRUE
);
7312 trace("testing Shift+MouseButton press/release\n");
7313 /* first, move mouse pointer inside of the window client area */
7314 GetClientRect(hwnd
, &rc
);
7315 MapWindowPoints(hwnd
, 0, (LPPOINT
)&rc
, 2);
7316 rc
.left
+= (rc
.right
- rc
.left
)/2;
7317 rc
.top
+= (rc
.bottom
- rc
.top
)/2;
7318 SetCursorPos(rc
.left
, rc
.top
);
7319 SetActiveWindow(hwnd
);
7324 if (pt
.x
== rc
.left
&& pt
.y
== rc
.top
)
7327 keybd_event(VK_SHIFT
, 0, 0, 0);
7328 mouse_event(MOUSEEVENTF_LEFTDOWN
, 0, 0, 0, 0);
7329 mouse_event(MOUSEEVENTF_LEFTUP
, 0, 0, 0, 0);
7330 keybd_event(VK_SHIFT
, 0, KEYEVENTF_KEYUP
, 0);
7331 pump_msg_loop(hwnd
, 0);
7332 for (i
= 0; i
< sequence_cnt
; i
++) if (sequence
[i
].message
== WM_LBUTTONDOWN
) break;
7333 if (i
< sequence_cnt
)
7334 ok_sequence(WmShiftMouseButton
, "Shift+MouseButton press/release", FALSE
);
7336 skip( "Shift+MouseButton event didn't get to the window\n" );
7340 if (hAccel
) DestroyAcceleratorTable(hAccel
);
7341 DestroyWindow(hwnd
);
7344 /************* window procedures ********************/
7346 static LRESULT
MsgCheckProc (BOOL unicode
, HWND hwnd
, UINT message
,
7347 WPARAM wParam
, LPARAM lParam
)
7349 static LONG defwndproc_counter
= 0;
7350 static LONG beginpaint_counter
= 0;
7352 struct recvd_message msg
;
7354 if (ignore_message( message
)) return 0;
7360 LONG style
= GetWindowLongA(hwnd
, GWL_STYLE
);
7361 ok((BOOL
)wParam
== !(style
& WS_DISABLED
),
7362 "wrong WS_DISABLED state: %ld != %d\n", wParam
, !(style
& WS_DISABLED
));
7366 case WM_CAPTURECHANGED
:
7367 if (test_DestroyWindow_flag
)
7369 DWORD style
= GetWindowLongA(hwnd
, GWL_STYLE
);
7370 if (style
& WS_CHILD
)
7371 lParam
= GetWindowLongPtrA(hwnd
, GWLP_ID
);
7372 else if (style
& WS_POPUP
)
7373 lParam
= WND_POPUP_ID
;
7375 lParam
= WND_PARENT_ID
;
7383 ok(!GetWindow(hwnd
, GW_CHILD
), "children should be unlinked at this point\n");
7384 capture
= GetCapture();
7387 ok(capture
== hwnd
, "capture should NOT be released at this point (capture %p)\n", capture
);
7388 trace("current capture %p, releasing...\n", capture
);
7395 ok(pGetAncestor(hwnd
, GA_PARENT
) != 0, "parent should NOT be unlinked at this point\n");
7396 if (test_DestroyWindow_flag
)
7398 DWORD style
= GetWindowLongA(hwnd
, GWL_STYLE
);
7399 if (style
& WS_CHILD
)
7400 lParam
= GetWindowLongPtrA(hwnd
, GWLP_ID
);
7401 else if (style
& WS_POPUP
)
7402 lParam
= WND_POPUP_ID
;
7404 lParam
= WND_PARENT_ID
;
7408 /* test_accelerators() depends on this */
7414 case WM_MOUSEACTIVATE
:
7415 case WM_NCMOUSEMOVE
:
7422 msg
.message
= message
;
7423 msg
.flags
= sent
|wparam
|lparam
;
7424 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
7425 if (beginpaint_counter
) msg
.flags
|= beginpaint
;
7426 msg
.wParam
= wParam
;
7427 msg
.lParam
= lParam
;
7428 msg
.descr
= "MsgCheckProc";
7431 if (message
== WM_GETMINMAXINFO
&& (GetWindowLongA(hwnd
, GWL_STYLE
) & WS_CHILD
))
7433 HWND parent
= GetParent(hwnd
);
7435 MINMAXINFO
*minmax
= (MINMAXINFO
*)lParam
;
7437 GetClientRect(parent
, &rc
);
7438 trace("parent %p client size = (%d x %d)\n", parent
, rc
.right
, rc
.bottom
);
7439 trace("Reserved=%d,%d MaxSize=%d,%d MaxPos=%d,%d MinTrack=%d,%d MaxTrack=%d,%d\n",
7440 minmax
->ptReserved
.x
, minmax
->ptReserved
.y
,
7441 minmax
->ptMaxSize
.x
, minmax
->ptMaxSize
.y
,
7442 minmax
->ptMaxPosition
.x
, minmax
->ptMaxPosition
.y
,
7443 minmax
->ptMinTrackSize
.x
, minmax
->ptMinTrackSize
.y
,
7444 minmax
->ptMaxTrackSize
.x
, minmax
->ptMaxTrackSize
.y
);
7446 ok(minmax
->ptMaxSize
.x
== rc
.right
, "default width of maximized child %d != %d\n",
7447 minmax
->ptMaxSize
.x
, rc
.right
);
7448 ok(minmax
->ptMaxSize
.y
== rc
.bottom
, "default height of maximized child %d != %d\n",
7449 minmax
->ptMaxSize
.y
, rc
.bottom
);
7452 if (message
== WM_PAINT
)
7455 beginpaint_counter
++;
7456 BeginPaint( hwnd
, &ps
);
7457 beginpaint_counter
--;
7458 EndPaint( hwnd
, &ps
);
7462 defwndproc_counter
++;
7463 ret
= unicode
? DefWindowProcW(hwnd
, message
, wParam
, lParam
)
7464 : DefWindowProcA(hwnd
, message
, wParam
, lParam
);
7465 defwndproc_counter
--;
7470 static LRESULT WINAPI
MsgCheckProcA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
7472 return MsgCheckProc (FALSE
, hwnd
, message
, wParam
, lParam
);
7475 static LRESULT WINAPI
MsgCheckProcW(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
7477 return MsgCheckProc (TRUE
, hwnd
, message
, wParam
, lParam
);
7480 static LRESULT WINAPI
PopupMsgCheckProcA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
7482 static LONG defwndproc_counter
= 0;
7484 struct recvd_message msg
;
7486 if (ignore_message( message
)) return 0;
7490 case WM_QUERYENDSESSION
:
7492 lParam
&= ~0x01; /* Vista adds a 0x01 flag */
7497 msg
.message
= message
;
7498 msg
.flags
= sent
|wparam
|lparam
;
7499 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
7500 msg
.wParam
= wParam
;
7501 msg
.lParam
= lParam
;
7502 msg
.descr
= "popup";
7505 if (message
== WM_CREATE
)
7507 DWORD style
= GetWindowLongA(hwnd
, GWL_STYLE
) | WS_VISIBLE
;
7508 SetWindowLongA(hwnd
, GWL_STYLE
, style
);
7511 defwndproc_counter
++;
7512 ret
= DefWindowProcA(hwnd
, message
, wParam
, lParam
);
7513 defwndproc_counter
--;
7518 static LRESULT WINAPI
ParentMsgCheckProcA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
7520 static LONG defwndproc_counter
= 0;
7521 static LONG beginpaint_counter
= 0;
7523 struct recvd_message msg
;
7525 if (ignore_message( message
)) return 0;
7527 if (log_all_parent_messages
||
7528 message
== WM_PARENTNOTIFY
|| message
== WM_CANCELMODE
||
7529 message
== WM_SETFOCUS
|| message
== WM_KILLFOCUS
||
7530 message
== WM_ENABLE
|| message
== WM_ENTERIDLE
||
7531 message
== WM_DRAWITEM
|| message
== WM_COMMAND
||
7532 message
== WM_IME_SETCONTEXT
)
7541 case WM_NCMOUSEMOVE
:
7547 INT ret
= GetClipBox((HDC
)wParam
, &rc
);
7549 trace("WM_ERASEBKGND: GetClipBox()=%d, (%d,%d-%d,%d)\n",
7550 ret
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
7556 msg
.message
= message
;
7557 msg
.flags
= sent
|parent
|wparam
|lparam
;
7558 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
7559 if (beginpaint_counter
) msg
.flags
|= beginpaint
;
7560 msg
.wParam
= wParam
;
7561 msg
.lParam
= lParam
;
7562 msg
.descr
= "parent";
7566 if (message
== WM_PAINT
)
7569 beginpaint_counter
++;
7570 BeginPaint( hwnd
, &ps
);
7571 beginpaint_counter
--;
7572 EndPaint( hwnd
, &ps
);
7576 defwndproc_counter
++;
7577 ret
= DefWindowProcA(hwnd
, message
, wParam
, lParam
);
7578 defwndproc_counter
--;
7583 static LRESULT WINAPI
TestDlgProcA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
7585 static LONG defwndproc_counter
= 0;
7587 struct recvd_message msg
;
7589 if (ignore_message( message
)) return 0;
7593 DefDlgProcA(hwnd
, DM_SETDEFID
, 1, 0);
7594 ret
= DefDlgProcA(hwnd
, DM_GETDEFID
, 0, 0);
7595 if (after_end_dialog
)
7596 ok( ret
== 0, "DM_GETDEFID should return 0 after EndDialog, got %lx\n", ret
);
7598 ok(HIWORD(ret
) == DC_HASDEFID
, "DM_GETDEFID should return DC_HASDEFID, got %lx\n", ret
);
7602 msg
.message
= message
;
7603 msg
.flags
= sent
|wparam
|lparam
;
7604 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
7605 msg
.wParam
= wParam
;
7606 msg
.lParam
= lParam
;
7607 msg
.descr
= "dialog";
7610 defwndproc_counter
++;
7611 ret
= DefDlgProcA(hwnd
, message
, wParam
, lParam
);
7612 defwndproc_counter
--;
7617 static LRESULT WINAPI
ShowWindowProcA(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
7619 static LONG defwndproc_counter
= 0;
7621 struct recvd_message msg
;
7623 /* log only specific messages we are interested in */
7626 #if 0 /* probably log these as well */
7634 case WM_GETMINMAXINFO
:
7635 case WM_WINDOWPOSCHANGING
:
7636 case WM_WINDOWPOSCHANGED
:
7639 default: /* ignore */
7640 /*trace("showwindow: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);*/
7641 return DefWindowProcA(hwnd
, message
, wParam
, lParam
);
7645 msg
.message
= message
;
7646 msg
.flags
= sent
|wparam
|lparam
;
7647 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
7648 msg
.wParam
= wParam
;
7649 msg
.lParam
= lParam
;
7653 defwndproc_counter
++;
7654 ret
= DefWindowProcA(hwnd
, message
, wParam
, lParam
);
7655 defwndproc_counter
--;
7660 static LRESULT WINAPI
PaintLoopProcA(HWND hWnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
7664 case WM_CREATE
: return 0;
7673 if (PeekMessageA(&msg2
, 0, 0, 0, 1))
7675 TranslateMessage(&msg2
);
7676 DispatchMessage(&msg2
);
7680 else ok(broken(1), "infinite loop\n");
7682 paint_loop_done
= 1;
7683 return DefWindowProcA(hWnd
,msg
,wParam
,lParam
);
7686 return DefWindowProcA(hWnd
,msg
,wParam
,lParam
);
7689 static BOOL
RegisterWindowClasses(void)
7695 cls
.lpfnWndProc
= MsgCheckProcA
;
7698 cls
.hInstance
= GetModuleHandleA(0);
7700 cls
.hCursor
= LoadCursorA(0, IDC_ARROW
);
7701 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
7702 cls
.lpszMenuName
= NULL
;
7703 cls
.lpszClassName
= "TestWindowClass";
7704 if(!RegisterClassA(&cls
)) return FALSE
;
7706 cls
.lpfnWndProc
= ShowWindowProcA
;
7707 cls
.lpszClassName
= "ShowWindowClass";
7708 if(!RegisterClassA(&cls
)) return FALSE
;
7710 cls
.lpfnWndProc
= PopupMsgCheckProcA
;
7711 cls
.lpszClassName
= "TestPopupClass";
7712 if(!RegisterClassA(&cls
)) return FALSE
;
7714 cls
.lpfnWndProc
= ParentMsgCheckProcA
;
7715 cls
.lpszClassName
= "TestParentClass";
7716 if(!RegisterClassA(&cls
)) return FALSE
;
7718 cls
.lpfnWndProc
= DefWindowProcA
;
7719 cls
.lpszClassName
= "SimpleWindowClass";
7720 if(!RegisterClassA(&cls
)) return FALSE
;
7722 cls
.lpfnWndProc
= PaintLoopProcA
;
7723 cls
.lpszClassName
= "PaintLoopWindowClass";
7724 if(!RegisterClassA(&cls
)) return FALSE
;
7726 cls
.style
= CS_NOCLOSE
;
7727 cls
.lpszClassName
= "NoCloseWindowClass";
7728 if(!RegisterClassA(&cls
)) return FALSE
;
7730 ok(GetClassInfoA(0, "#32770", &cls
), "GetClassInfo failed\n");
7732 cls
.hInstance
= GetModuleHandleA(0);
7733 cls
.hbrBackground
= 0;
7734 cls
.lpfnWndProc
= TestDlgProcA
;
7735 cls
.lpszClassName
= "TestDialogClass";
7736 if(!RegisterClassA(&cls
)) return FALSE
;
7739 clsW
.lpfnWndProc
= MsgCheckProcW
;
7740 clsW
.cbClsExtra
= 0;
7741 clsW
.cbWndExtra
= 0;
7742 clsW
.hInstance
= GetModuleHandleW(0);
7744 clsW
.hCursor
= LoadCursorW(0, (LPWSTR
)IDC_ARROW
);
7745 clsW
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
7746 clsW
.lpszMenuName
= NULL
;
7747 clsW
.lpszClassName
= testWindowClassW
;
7748 RegisterClassW(&clsW
); /* ignore error, this fails on Win9x */
7753 static BOOL
is_our_logged_class(HWND hwnd
)
7757 if (GetClassNameA(hwnd
, buf
, sizeof(buf
)))
7759 if (!lstrcmpiA(buf
, "TestWindowClass") ||
7760 !lstrcmpiA(buf
, "ShowWindowClass") ||
7761 !lstrcmpiA(buf
, "TestParentClass") ||
7762 !lstrcmpiA(buf
, "TestPopupClass") ||
7763 !lstrcmpiA(buf
, "SimpleWindowClass") ||
7764 !lstrcmpiA(buf
, "TestDialogClass") ||
7765 !lstrcmpiA(buf
, "MDI_frame_class") ||
7766 !lstrcmpiA(buf
, "MDI_client_class") ||
7767 !lstrcmpiA(buf
, "MDI_child_class") ||
7768 !lstrcmpiA(buf
, "my_button_class") ||
7769 !lstrcmpiA(buf
, "my_edit_class") ||
7770 !lstrcmpiA(buf
, "static") ||
7771 !lstrcmpiA(buf
, "ListBox") ||
7772 !lstrcmpiA(buf
, "ComboBox") ||
7773 !lstrcmpiA(buf
, "MyDialogClass") ||
7774 !lstrcmpiA(buf
, "#32770") ||
7775 !lstrcmpiA(buf
, "#32768"))
7781 static LRESULT CALLBACK
cbt_hook_proc(int nCode
, WPARAM wParam
, LPARAM lParam
)
7785 ok(cbt_hook_thread_id
== GetCurrentThreadId(), "we didn't ask for events from other threads\n");
7787 if (nCode
== HCBT_CLICKSKIPPED
)
7789 /* ignore this event, XP sends it a lot when switching focus between windows */
7790 return CallNextHookEx(hCBT_hook
, nCode
, wParam
, lParam
);
7793 if (nCode
== HCBT_SYSCOMMAND
|| nCode
== HCBT_KEYSKIPPED
)
7795 struct recvd_message msg
;
7798 msg
.message
= nCode
;
7799 msg
.flags
= hook
|wparam
|lparam
;
7800 msg
.wParam
= wParam
;
7801 msg
.lParam
= lParam
;
7805 return CallNextHookEx(hCBT_hook
, nCode
, wParam
, lParam
);
7808 if (nCode
== HCBT_DESTROYWND
)
7810 if (test_DestroyWindow_flag
)
7812 DWORD style
= GetWindowLongA((HWND
)wParam
, GWL_STYLE
);
7813 if (style
& WS_CHILD
)
7814 lParam
= GetWindowLongPtrA((HWND
)wParam
, GWLP_ID
);
7815 else if (style
& WS_POPUP
)
7816 lParam
= WND_POPUP_ID
;
7818 lParam
= WND_PARENT_ID
;
7822 /* Log also SetFocus(0) calls */
7823 hwnd
= wParam
? (HWND
)wParam
: (HWND
)lParam
;
7825 if (is_our_logged_class(hwnd
))
7827 struct recvd_message msg
;
7830 msg
.message
= nCode
;
7831 msg
.flags
= hook
|wparam
|lparam
;
7832 msg
.wParam
= wParam
;
7833 msg
.lParam
= lParam
;
7837 return CallNextHookEx(hCBT_hook
, nCode
, wParam
, lParam
);
7840 static void CALLBACK
win_event_proc(HWINEVENTHOOK hevent
,
7848 ok(thread_id
== GetCurrentThreadId(), "we didn't ask for events from other threads\n");
7850 /* ignore mouse cursor events */
7851 if (object_id
== OBJID_CURSOR
) return;
7853 if (!hwnd
|| is_our_logged_class(hwnd
))
7855 struct recvd_message msg
;
7858 msg
.message
= event
;
7859 msg
.flags
= winevent_hook
|wparam
|lparam
;
7860 msg
.wParam
= object_id
;
7861 msg
.lParam
= child_id
;
7867 static const WCHAR wszUnicode
[] = {'U','n','i','c','o','d','e',0};
7868 static const WCHAR wszAnsi
[] = {'U',0};
7870 static LRESULT CALLBACK
MsgConversionProcW(HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
7874 case CB_FINDSTRINGEXACT
:
7875 trace("String: %p\n", (LPCWSTR
)lParam
);
7876 if (!lstrcmpW((LPCWSTR
)lParam
, wszUnicode
))
7878 if (!lstrcmpW((LPCWSTR
)lParam
, wszAnsi
))
7882 return DefWindowProcW(hwnd
, uMsg
, wParam
, lParam
);
7885 static const struct message WmGetTextLengthAfromW
[] = {
7886 { WM_GETTEXTLENGTH
, sent
},
7887 { WM_GETTEXT
, sent
|optional
},
7891 static const WCHAR dummy_window_text
[] = {'d','u','m','m','y',' ','t','e','x','t',0};
7893 /* dummy window proc for WM_GETTEXTLENGTH test */
7894 static LRESULT CALLBACK
get_text_len_proc( HWND hwnd
, UINT msg
, WPARAM wp
, LPARAM lp
)
7898 case WM_GETTEXTLENGTH
:
7899 return lstrlenW(dummy_window_text
) + 37; /* some random length */
7901 lstrcpynW( (LPWSTR
)lp
, dummy_window_text
, wp
);
7902 return lstrlenW( (LPWSTR
)lp
);
7904 return DefWindowProcW( hwnd
, msg
, wp
, lp
);
7908 static void test_message_conversion(void)
7910 static const WCHAR wszMsgConversionClass
[] =
7911 {'M','s','g','C','o','n','v','e','r','s','i','o','n','C','l','a','s','s',0};
7915 WNDPROC wndproc
, newproc
;
7919 cls
.lpfnWndProc
= MsgConversionProcW
;
7922 cls
.hInstance
= GetModuleHandleW(NULL
);
7924 cls
.hCursor
= LoadCursorW(NULL
, (LPWSTR
)IDC_ARROW
);
7925 cls
.hbrBackground
= (HBRUSH
)(COLOR_BTNFACE
+1);
7926 cls
.lpszMenuName
= NULL
;
7927 cls
.lpszClassName
= wszMsgConversionClass
;
7928 /* this call will fail on Win9x, but that doesn't matter as this test is
7929 * meaningless on those platforms */
7930 if(!RegisterClassW(&cls
)) return;
7932 hwnd
= CreateWindowExW(0, wszMsgConversionClass
, NULL
, WS_OVERLAPPED
,
7933 100, 100, 200, 200, 0, 0, 0, NULL
);
7934 ok(hwnd
!= NULL
, "Window creation failed\n");
7938 wndproc
= (WNDPROC
)GetWindowLongPtrA(hwnd
, GWLP_WNDPROC
);
7939 lRes
= CallWindowProcA(wndproc
, hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
7940 ok(lRes
== 0, "String should have been converted\n");
7941 lRes
= CallWindowProcW(wndproc
, hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
7942 ok(lRes
== 1, "String shouldn't have been converted\n");
7946 wndproc
= (WNDPROC
)GetWindowLongPtrW(hwnd
, GWLP_WNDPROC
);
7947 lRes
= CallWindowProcA(wndproc
, hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
7948 ok(lRes
== 1, "String shouldn't have been converted\n");
7949 lRes
= CallWindowProcW(wndproc
, hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
7950 ok(lRes
== 1, "String shouldn't have been converted\n");
7952 /* Synchronous messages */
7954 lRes
= SendMessageA(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
7955 ok(lRes
== 0, "String should have been converted\n");
7956 lRes
= SendMessageW(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
7957 ok(lRes
== 1, "String shouldn't have been converted\n");
7959 /* Asynchronous messages */
7962 lRes
= PostMessageA(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
7963 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
7964 "PostMessage on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
7966 lRes
= PostMessageW(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
7967 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
7968 "PostMessage on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
7970 lRes
= PostThreadMessageA(GetCurrentThreadId(), CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
7971 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
7972 "PosThreadtMessage on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
7974 lRes
= PostThreadMessageW(GetCurrentThreadId(), CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
7975 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
7976 "PosThreadtMessage on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
7978 lRes
= SendNotifyMessageA(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
7979 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
7980 "SendNotifyMessage on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
7982 lRes
= SendNotifyMessageW(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
);
7983 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
7984 "SendNotifyMessage on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
7986 lRes
= SendMessageCallbackA(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
, NULL
, 0);
7987 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
7988 "SendMessageCallback on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
7990 lRes
= SendMessageCallbackW(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)wszUnicode
, NULL
, 0);
7991 ok(lRes
== 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY
|| GetLastError() == ERROR_INVALID_PARAMETER
),
7992 "SendMessageCallback on sync only message returned %ld, last error %d\n", lRes
, GetLastError());
7994 /* Check WM_GETTEXTLENGTH A->W behaviour, whether WM_GETTEXT is also sent or not */
7996 hwnd
= CreateWindowW (testWindowClassW
, wszUnicode
,
7997 WS_OVERLAPPEDWINDOW
,
7998 100, 100, 200, 200, 0, 0, 0, NULL
);
8001 lRes
= SendMessageA (hwnd
, WM_GETTEXTLENGTH
, 0, 0);
8002 ok_sequence(WmGetTextLengthAfromW
, "ANSI WM_GETTEXTLENGTH to Unicode window", FALSE
);
8003 ok( lRes
== WideCharToMultiByte( CP_ACP
, 0, wszUnicode
, lstrlenW(wszUnicode
), NULL
, 0, NULL
, NULL
),
8004 "got bad length %ld\n", lRes
);
8007 lRes
= CallWindowProcA( (WNDPROC
)GetWindowLongPtrA( hwnd
, GWLP_WNDPROC
),
8008 hwnd
, WM_GETTEXTLENGTH
, 0, 0);
8009 ok_sequence(WmGetTextLengthAfromW
, "ANSI WM_GETTEXTLENGTH to Unicode window", FALSE
);
8010 ok( lRes
== WideCharToMultiByte( CP_ACP
, 0, wszUnicode
, lstrlenW(wszUnicode
), NULL
, 0, NULL
, NULL
),
8011 "got bad length %ld\n", lRes
);
8013 wndproc
= (WNDPROC
)SetWindowLongPtrW( hwnd
, GWLP_WNDPROC
, (LONG_PTR
)get_text_len_proc
);
8014 newproc
= (WNDPROC
)GetWindowLongPtrA( hwnd
, GWLP_WNDPROC
);
8015 lRes
= CallWindowProcA( newproc
, hwnd
, WM_GETTEXTLENGTH
, 0, 0 );
8016 ok( lRes
== WideCharToMultiByte( CP_ACP
, 0, dummy_window_text
, lstrlenW(dummy_window_text
),
8017 NULL
, 0, NULL
, NULL
) ||
8018 broken(lRes
== lstrlenW(dummy_window_text
) + 37),
8019 "got bad length %ld\n", lRes
);
8021 SetWindowLongPtrW( hwnd
, GWLP_WNDPROC
, (LONG_PTR
)wndproc
); /* restore old wnd proc */
8022 lRes
= CallWindowProcA( newproc
, hwnd
, WM_GETTEXTLENGTH
, 0, 0 );
8023 ok( lRes
== WideCharToMultiByte( CP_ACP
, 0, dummy_window_text
, lstrlenW(dummy_window_text
),
8024 NULL
, 0, NULL
, NULL
) ||
8025 broken(lRes
== lstrlenW(dummy_window_text
) + 37),
8026 "got bad length %ld\n", lRes
);
8028 ret
= DestroyWindow(hwnd
);
8029 ok( ret
, "DestroyWindow() error %d\n", GetLastError());
8039 static VOID CALLBACK
tfunc(HWND hwnd
, UINT uMsg
, UINT_PTR id
, DWORD dwTime
)
8043 static VOID CALLBACK
tfunc_crash(HWND hwnd
, UINT uMsg
, UINT_PTR id
, DWORD dwTime
)
8045 /* Crash on purpose */
8046 *(volatile int *)0 = 2;
8049 #define TIMER_ID 0x19
8051 static DWORD WINAPI
timer_thread_proc(LPVOID x
)
8053 struct timer_info
*info
= x
;
8056 r
= KillTimer(info
->hWnd
, 0x19);
8057 ok(r
,"KillTimer failed in thread\n");
8058 r
= SetTimer(info
->hWnd
,TIMER_ID
,10000,tfunc
);
8059 ok(r
,"SetTimer failed in thread\n");
8060 ok(r
==TIMER_ID
,"SetTimer id different\n");
8061 r
= SetEvent(info
->handles
[0]);
8062 ok(r
,"SetEvent failed in thread\n");
8066 static void test_timers(void)
8068 struct timer_info info
;
8072 info
.hWnd
= CreateWindow ("TestWindowClass", NULL
,
8073 WS_OVERLAPPEDWINDOW
,
8074 CW_USEDEFAULT
, CW_USEDEFAULT
, 300, 300, 0,
8077 info
.id
= SetTimer(info
.hWnd
,TIMER_ID
,10000,tfunc
);
8078 ok(info
.id
, "SetTimer failed\n");
8079 ok(info
.id
==TIMER_ID
, "SetTimer timer ID different\n");
8080 info
.handles
[0] = CreateEvent(NULL
,0,0,NULL
);
8081 info
.handles
[1] = CreateThread(NULL
,0,timer_thread_proc
,&info
,0,&id
);
8083 WaitForMultipleObjects(2, info
.handles
, FALSE
, INFINITE
);
8085 WaitForSingleObject(info
.handles
[1], INFINITE
);
8087 CloseHandle(info
.handles
[0]);
8088 CloseHandle(info
.handles
[1]);
8090 ok( KillTimer(info
.hWnd
, TIMER_ID
), "KillTimer failed\n");
8092 ok(DestroyWindow(info
.hWnd
), "failed to destroy window\n");
8094 /* Test timer callback with crash */
8095 SetLastError(0xdeadbeef);
8096 info
.hWnd
= CreateWindowW(testWindowClassW
, NULL
,
8097 WS_OVERLAPPEDWINDOW
,
8098 CW_USEDEFAULT
, CW_USEDEFAULT
, 300, 300, 0,
8100 if ((!info
.hWnd
&& GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
) || /* Win9x/Me */
8101 (!pGetMenuInfo
)) /* Win95/NT4 */
8103 win_skip("Test would crash on Win9x/WinMe/NT4\n");
8104 DestroyWindow(info
.hWnd
);
8107 info
.id
= SetTimer(info
.hWnd
, TIMER_ID
, 0, tfunc_crash
);
8108 ok(info
.id
, "SetTimer failed\n");
8110 while (PeekMessage(&msg
, NULL
, 0, 0, PM_REMOVE
)) DispatchMessage(&msg
);
8112 ok(DestroyWindow(info
.hWnd
), "failed to destroy window\n");
8115 static int count
= 0;
8116 static VOID CALLBACK
callback_count(
8126 static void test_timers_no_wnd(void)
8132 id
= SetTimer(NULL
, 0, 100, callback_count
);
8133 ok(id
!= 0, "did not get id from SetTimer.\n");
8134 id2
= SetTimer(NULL
, id
, 200, callback_count
);
8135 ok(id2
== id
, "did not get same id from SetTimer when replacing (%li expected %li).\n", id2
, id
);
8137 while (PeekMessage(&msg
, NULL
, 0, 0, PM_REMOVE
)) DispatchMessage(&msg
);
8138 ok(count
== 0, "did not get zero count as expected (%i).\n", count
);
8140 while (PeekMessage(&msg
, NULL
, 0, 0, PM_REMOVE
)) DispatchMessage(&msg
);
8141 ok(count
== 1, "did not get one count as expected (%i).\n", count
);
8142 KillTimer(NULL
, id
);
8144 while (PeekMessage(&msg
, NULL
, 0, 0, PM_REMOVE
)) DispatchMessage(&msg
);
8145 ok(count
== 1, "killing replaced timer did not work (%i).\n", count
);
8148 /* Various win events with arbitrary parameters */
8149 static const struct message WmWinEventsSeq
[] = {
8150 { EVENT_SYSTEM_SOUND
, winevent_hook
|wparam
|lparam
, OBJID_WINDOW
, 0 },
8151 { EVENT_SYSTEM_ALERT
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 1 },
8152 { EVENT_SYSTEM_FOREGROUND
, winevent_hook
|wparam
|lparam
, OBJID_TITLEBAR
, 2 },
8153 { EVENT_SYSTEM_MENUSTART
, winevent_hook
|wparam
|lparam
, OBJID_MENU
, 3 },
8154 { EVENT_SYSTEM_MENUEND
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 4 },
8155 { EVENT_SYSTEM_MENUPOPUPSTART
, winevent_hook
|wparam
|lparam
, OBJID_VSCROLL
, 5 },
8156 { EVENT_SYSTEM_MENUPOPUPEND
, winevent_hook
|wparam
|lparam
, OBJID_HSCROLL
, 6 },
8157 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, OBJID_SIZEGRIP
, 7 },
8158 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 8 },
8159 /* our win event hook ignores OBJID_CURSOR events */
8160 /*{ EVENT_SYSTEM_MOVESIZESTART, winevent_hook|wparam|lparam, OBJID_CURSOR, 9 },*/
8161 { EVENT_SYSTEM_MOVESIZEEND
, winevent_hook
|wparam
|lparam
, OBJID_ALERT
, 10 },
8162 { EVENT_SYSTEM_CONTEXTHELPSTART
, winevent_hook
|wparam
|lparam
, OBJID_SOUND
, 11 },
8163 { EVENT_SYSTEM_CONTEXTHELPEND
, winevent_hook
|wparam
|lparam
, OBJID_QUERYCLASSNAMEIDX
, 12 },
8164 { EVENT_SYSTEM_DRAGDROPSTART
, winevent_hook
|wparam
|lparam
, OBJID_NATIVEOM
, 13 },
8165 { EVENT_SYSTEM_DRAGDROPEND
, winevent_hook
|wparam
|lparam
, OBJID_WINDOW
, 0 },
8166 { EVENT_SYSTEM_DIALOGSTART
, winevent_hook
|wparam
|lparam
, OBJID_SYSMENU
, 1 },
8167 { EVENT_SYSTEM_DIALOGEND
, winevent_hook
|wparam
|lparam
, OBJID_TITLEBAR
, 2 },
8168 { EVENT_SYSTEM_SCROLLINGSTART
, winevent_hook
|wparam
|lparam
, OBJID_MENU
, 3 },
8169 { EVENT_SYSTEM_SCROLLINGEND
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 4 },
8170 { EVENT_SYSTEM_SWITCHSTART
, winevent_hook
|wparam
|lparam
, OBJID_VSCROLL
, 5 },
8171 { EVENT_SYSTEM_SWITCHEND
, winevent_hook
|wparam
|lparam
, OBJID_HSCROLL
, 6 },
8172 { EVENT_SYSTEM_MINIMIZESTART
, winevent_hook
|wparam
|lparam
, OBJID_SIZEGRIP
, 7 },
8173 { EVENT_SYSTEM_MINIMIZEEND
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 8 },
8176 static const struct message WmWinEventCaretSeq
[] = {
8177 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 1 */
8178 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 1 */
8179 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 2 */
8180 { EVENT_OBJECT_NAMECHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 1 */
8183 static const struct message WmWinEventCaretSeq_2
[] = {
8184 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 1/2 */
8185 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 1/2 */
8186 { EVENT_OBJECT_NAMECHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 }, /* hook 1/2 */
8189 static const struct message WmWinEventAlertSeq
[] = {
8190 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_ALERT
, 0 },
8193 static const struct message WmWinEventAlertSeq_2
[] = {
8194 /* create window in the thread proc */
8195 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_WINDOW
, 2 },
8196 /* our test event */
8197 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_ALERT
, 2 },
8200 static const struct message WmGlobalHookSeq_1
[] = {
8201 /* create window in the thread proc */
8202 { HCBT_CREATEWND
, hook
|lparam
, 0, 2 },
8203 /* our test events */
8204 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_PREVWINDOW
, 2 },
8205 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_NEXTWINDOW
, 2 },
8208 static const struct message WmGlobalHookSeq_2
[] = {
8209 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_NEXTWINDOW
, 0 }, /* old local hook */
8210 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_NEXTWINDOW
, 2 }, /* new global hook */
8211 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_PREVWINDOW
, 0 }, /* old local hook */
8212 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_PREVWINDOW
, 2 }, /* new global hook */
8216 static const struct message WmMouseLLHookSeq
[] = {
8217 { WM_MOUSEMOVE
, hook
},
8218 { WM_LBUTTONUP
, hook
},
8219 { WM_MOUSEMOVE
, hook
},
8223 static void CALLBACK
win_event_global_hook_proc(HWINEVENTHOOK hevent
,
8233 if (GetClassNameA(hwnd
, buf
, sizeof(buf
)))
8235 if (!lstrcmpiA(buf
, "TestWindowClass") ||
8236 !lstrcmpiA(buf
, "static"))
8238 struct recvd_message msg
;
8241 msg
.message
= event
;
8242 msg
.flags
= winevent_hook
|wparam
|lparam
;
8243 msg
.wParam
= object_id
;
8244 msg
.lParam
= (thread_id
== GetCurrentThreadId()) ? child_id
: (child_id
+ 2);
8245 msg
.descr
= "WEH_2";
8251 static HHOOK hCBT_global_hook
;
8252 static DWORD cbt_global_hook_thread_id
;
8254 static LRESULT CALLBACK
cbt_global_hook_proc(int nCode
, WPARAM wParam
, LPARAM lParam
)
8259 if (nCode
== HCBT_SYSCOMMAND
)
8261 struct recvd_message msg
;
8264 msg
.message
= nCode
;
8265 msg
.flags
= hook
|wparam
|lparam
;
8266 msg
.wParam
= wParam
;
8267 msg
.lParam
= (cbt_global_hook_thread_id
== GetCurrentThreadId()) ? 1 : 2;
8268 msg
.descr
= "CBT_2";
8271 return CallNextHookEx(hCBT_global_hook
, nCode
, wParam
, lParam
);
8273 /* WH_MOUSE_LL hook */
8274 if (nCode
== HC_ACTION
)
8276 MSLLHOOKSTRUCT
*mhll
= (MSLLHOOKSTRUCT
*)lParam
;
8278 /* we can't test for real mouse events */
8279 if (mhll
->flags
& LLMHF_INJECTED
)
8281 struct recvd_message msg
;
8283 memset (&msg
, 0, sizeof (msg
));
8284 msg
.message
= wParam
;
8286 msg
.descr
= "CBT_2";
8289 return CallNextHookEx(hCBT_global_hook
, nCode
, wParam
, lParam
);
8292 /* Log also SetFocus(0) calls */
8293 hwnd
= wParam
? (HWND
)wParam
: (HWND
)lParam
;
8295 if (GetClassNameA(hwnd
, buf
, sizeof(buf
)))
8297 if (!lstrcmpiA(buf
, "TestWindowClass") ||
8298 !lstrcmpiA(buf
, "static"))
8300 struct recvd_message msg
;
8303 msg
.message
= nCode
;
8304 msg
.flags
= hook
|wparam
|lparam
;
8305 msg
.wParam
= wParam
;
8306 msg
.lParam
= (cbt_global_hook_thread_id
== GetCurrentThreadId()) ? 1 : 2;
8307 msg
.descr
= "CBT_2";
8311 return CallNextHookEx(hCBT_global_hook
, nCode
, wParam
, lParam
);
8314 static DWORD WINAPI
win_event_global_thread_proc(void *param
)
8318 HANDLE hevent
= *(HANDLE
*)param
;
8320 assert(pNotifyWinEvent
);
8322 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
, 0,0,0,0,0,0,0, NULL
);
8324 trace("created thread window %p\n", hwnd
);
8326 *(HWND
*)param
= hwnd
;
8329 /* this event should be received only by our new hook proc,
8330 * an old one does not expect an event from another thread.
8332 pNotifyWinEvent(EVENT_OBJECT_LOCATIONCHANGE
, hwnd
, OBJID_ALERT
, 0);
8335 while (GetMessage(&msg
, 0, 0, 0))
8337 TranslateMessage(&msg
);
8338 DispatchMessage(&msg
);
8343 static DWORD WINAPI
cbt_global_hook_thread_proc(void *param
)
8347 HANDLE hevent
= *(HANDLE
*)param
;
8350 /* these events should be received only by our new hook proc,
8351 * an old one does not expect an event from another thread.
8354 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
, 0,0,0,0,0,0,0, NULL
);
8356 trace("created thread window %p\n", hwnd
);
8358 *(HWND
*)param
= hwnd
;
8360 /* Windows doesn't like when a thread plays games with the focus,
8361 that leads to all kinds of misbehaviours and failures to activate
8362 a window. So, better keep next lines commented out.
8366 DefWindowProcA(hwnd
, WM_SYSCOMMAND
, SC_PREVWINDOW
, 0);
8367 DefWindowProcA(hwnd
, WM_SYSCOMMAND
, SC_NEXTWINDOW
, 0);
8371 while (GetMessage(&msg
, 0, 0, 0))
8373 TranslateMessage(&msg
);
8374 DispatchMessage(&msg
);
8379 static DWORD WINAPI
mouse_ll_global_thread_proc(void *param
)
8383 HANDLE hevent
= *(HANDLE
*)param
;
8385 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
, 0,0,0,0,0,0,0, NULL
);
8387 trace("created thread window %p\n", hwnd
);
8389 *(HWND
*)param
= hwnd
;
8393 /* Windows doesn't like when a thread plays games with the focus,
8394 * that leads to all kinds of misbehaviours and failures to activate
8395 * a window. So, better don't generate a mouse click message below.
8397 mouse_event(MOUSEEVENTF_MOVE
, -1, 0, 0, 0);
8398 mouse_event(MOUSEEVENTF_LEFTUP
, 0, 0, 0, 0);
8399 mouse_event(MOUSEEVENTF_MOVE
, 1, 0, 0, 0);
8402 while (GetMessage(&msg
, 0, 0, 0))
8404 TranslateMessage(&msg
);
8405 DispatchMessage(&msg
);
8410 static void test_winevents(void)
8416 HANDLE hthread
, hevent
;
8418 HWINEVENTHOOK hhook
;
8419 const struct message
*events
= WmWinEventsSeq
;
8421 hwnd
= CreateWindowExA(0, "TestWindowClass", NULL
,
8422 WS_OVERLAPPEDWINDOW
,
8423 CW_USEDEFAULT
, CW_USEDEFAULT
, 300, 300, 0,
8427 /****** start of global hook test *************/
8428 hCBT_global_hook
= SetWindowsHookExA(WH_CBT
, cbt_global_hook_proc
, GetModuleHandleA(0), 0);
8429 if (!hCBT_global_hook
)
8431 ok(DestroyWindow(hwnd
), "failed to destroy window\n");
8432 skip( "cannot set global hook\n" );
8436 hevent
= CreateEventA(NULL
, 0, 0, NULL
);
8440 hthread
= CreateThread(NULL
, 0, cbt_global_hook_thread_proc
, &hwnd2
, 0, &tid
);
8441 ok(hthread
!= NULL
, "CreateThread failed, error %d\n", GetLastError());
8443 ok(WaitForSingleObject(hevent
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
8445 ok_sequence(WmGlobalHookSeq_1
, "global hook 1", FALSE
);
8448 /* this one should be received only by old hook proc */
8449 DefWindowProcA(hwnd
, WM_SYSCOMMAND
, SC_NEXTWINDOW
, 0);
8450 /* this one should be received only by old hook proc */
8451 DefWindowProcA(hwnd
, WM_SYSCOMMAND
, SC_PREVWINDOW
, 0);
8453 ok_sequence(WmGlobalHookSeq_2
, "global hook 2", FALSE
);
8455 ret
= UnhookWindowsHookEx(hCBT_global_hook
);
8456 ok( ret
, "UnhookWindowsHookEx error %d\n", GetLastError());
8458 PostThreadMessageA(tid
, WM_QUIT
, 0, 0);
8459 ok(WaitForSingleObject(hthread
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
8460 CloseHandle(hthread
);
8461 CloseHandle(hevent
);
8462 ok(!IsWindow(hwnd2
), "window should be destroyed on thread exit\n");
8463 /****** end of global hook test *************/
8465 if (!pSetWinEventHook
|| !pNotifyWinEvent
|| !pUnhookWinEvent
)
8467 ok(DestroyWindow(hwnd
), "failed to destroy window\n");
8475 /* this test doesn't pass under Win9x */
8476 /* win2k ignores events with hwnd == 0 */
8477 SetLastError(0xdeadbeef);
8478 pNotifyWinEvent(events
[0].message
, 0, events
[0].wParam
, events
[0].lParam
);
8479 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
|| /* Win2k */
8480 GetLastError() == 0xdeadbeef, /* Win9x */
8481 "unexpected error %d\n", GetLastError());
8482 ok_sequence(WmEmptySeq
, "empty notify winevents", FALSE
);
8485 for (i
= 0; i
< sizeof(WmWinEventsSeq
)/sizeof(WmWinEventsSeq
[0]); i
++)
8486 pNotifyWinEvent(events
[i
].message
, hwnd
, events
[i
].wParam
, events
[i
].lParam
);
8488 ok_sequence(WmWinEventsSeq
, "notify winevents", FALSE
);
8490 /****** start of event filtering test *************/
8491 hhook
= pSetWinEventHook(
8492 EVENT_OBJECT_SHOW
, /* 0x8002 */
8493 EVENT_OBJECT_LOCATIONCHANGE
, /* 0x800B */
8494 GetModuleHandleA(0), win_event_global_hook_proc
,
8495 GetCurrentProcessId(), 0,
8496 WINEVENT_INCONTEXT
);
8497 ok(hhook
!= 0, "SetWinEventHook error %d\n", GetLastError());
8499 hevent
= CreateEventA(NULL
, 0, 0, NULL
);
8503 hthread
= CreateThread(NULL
, 0, win_event_global_thread_proc
, &hwnd2
, 0, &tid
);
8504 ok(hthread
!= NULL
, "CreateThread failed, error %d\n", GetLastError());
8506 ok(WaitForSingleObject(hevent
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
8508 ok_sequence(WmWinEventAlertSeq
, "alert winevent", FALSE
);
8511 /* this one should be received only by old hook proc */
8512 pNotifyWinEvent(EVENT_OBJECT_CREATE
, hwnd
, OBJID_CARET
, 0); /* 0x8000 */
8513 pNotifyWinEvent(EVENT_OBJECT_SHOW
, hwnd
, OBJID_CARET
, 0); /* 0x8002 */
8514 /* this one should be received only by old hook proc */
8515 pNotifyWinEvent(EVENT_OBJECT_NAMECHANGE
, hwnd
, OBJID_CARET
, 0); /* 0x800C */
8517 ok_sequence(WmWinEventCaretSeq
, "caret winevent", FALSE
);
8519 ret
= pUnhookWinEvent(hhook
);
8520 ok( ret
, "UnhookWinEvent error %d\n", GetLastError());
8522 PostThreadMessageA(tid
, WM_QUIT
, 0, 0);
8523 ok(WaitForSingleObject(hthread
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
8524 CloseHandle(hthread
);
8525 CloseHandle(hevent
);
8526 ok(!IsWindow(hwnd2
), "window should be destroyed on thread exit\n");
8527 /****** end of event filtering test *************/
8529 /****** start of out of context event test *************/
8530 hhook
= pSetWinEventHook(EVENT_MIN
, EVENT_MAX
, 0,
8531 win_event_global_hook_proc
, GetCurrentProcessId(), 0,
8532 WINEVENT_OUTOFCONTEXT
);
8533 ok(hhook
!= 0, "SetWinEventHook error %d\n", GetLastError());
8535 hevent
= CreateEventA(NULL
, 0, 0, NULL
);
8541 hthread
= CreateThread(NULL
, 0, win_event_global_thread_proc
, &hwnd2
, 0, &tid
);
8542 ok(hthread
!= NULL
, "CreateThread failed, error %d\n", GetLastError());
8544 ok(WaitForSingleObject(hevent
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
8546 ok_sequence(WmEmptySeq
, "empty notify winevents", FALSE
);
8547 /* process pending winevent messages */
8548 ok(!PeekMessageA(&msg
, 0, 0, 0, PM_NOREMOVE
), "msg queue should be empty\n");
8549 ok_sequence(WmWinEventAlertSeq_2
, "alert winevent for out of context proc", FALSE
);
8552 /* this one should be received only by old hook proc */
8553 pNotifyWinEvent(EVENT_OBJECT_CREATE
, hwnd
, OBJID_CARET
, 0); /* 0x8000 */
8554 pNotifyWinEvent(EVENT_OBJECT_SHOW
, hwnd
, OBJID_CARET
, 0); /* 0x8002 */
8555 /* this one should be received only by old hook proc */
8556 pNotifyWinEvent(EVENT_OBJECT_NAMECHANGE
, hwnd
, OBJID_CARET
, 0); /* 0x800C */
8558 ok_sequence(WmWinEventCaretSeq_2
, "caret winevent for incontext proc", FALSE
);
8559 /* process pending winevent messages */
8560 ok(!PeekMessageA(&msg
, 0, 0, 0, PM_NOREMOVE
), "msg queue should be empty\n");
8561 ok_sequence(WmWinEventCaretSeq_2
, "caret winevent for out of context proc", FALSE
);
8563 ret
= pUnhookWinEvent(hhook
);
8564 ok( ret
, "UnhookWinEvent error %d\n", GetLastError());
8566 PostThreadMessageA(tid
, WM_QUIT
, 0, 0);
8567 ok(WaitForSingleObject(hthread
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
8568 CloseHandle(hthread
);
8569 CloseHandle(hevent
);
8570 ok(!IsWindow(hwnd2
), "window should be destroyed on thread exit\n");
8571 /****** end of out of context event test *************/
8573 /****** start of MOUSE_LL hook test *************/
8574 hCBT_global_hook
= SetWindowsHookExA(WH_MOUSE_LL
, cbt_global_hook_proc
, GetModuleHandleA(0), 0);
8575 /* WH_MOUSE_LL is not supported on Win9x platforms */
8576 if (!hCBT_global_hook
)
8578 win_skip("Skipping WH_MOUSE_LL test on this platform\n");
8579 goto skip_mouse_ll_hook_test
;
8582 hevent
= CreateEventA(NULL
, 0, 0, NULL
);
8586 hthread
= CreateThread(NULL
, 0, mouse_ll_global_thread_proc
, &hwnd2
, 0, &tid
);
8587 ok(hthread
!= NULL
, "CreateThread failed, error %d\n", GetLastError());
8589 while (WaitForSingleObject(hevent
, 100) == WAIT_TIMEOUT
)
8590 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
8592 ok_sequence(WmMouseLLHookSeq
, "MOUSE_LL hook other thread", FALSE
);
8595 mouse_event(MOUSEEVENTF_MOVE
, -1, 0, 0, 0);
8596 mouse_event(MOUSEEVENTF_LEFTUP
, 0, 0, 0, 0);
8597 mouse_event(MOUSEEVENTF_MOVE
, 1, 0, 0, 0);
8599 ok_sequence(WmMouseLLHookSeq
, "MOUSE_LL hook same thread", FALSE
);
8601 ret
= UnhookWindowsHookEx(hCBT_global_hook
);
8602 ok( ret
, "UnhookWindowsHookEx error %d\n", GetLastError());
8604 PostThreadMessageA(tid
, WM_QUIT
, 0, 0);
8605 ok(WaitForSingleObject(hthread
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
8606 CloseHandle(hthread
);
8607 CloseHandle(hevent
);
8608 ok(!IsWindow(hwnd2
), "window should be destroyed on thread exit\n");
8609 /****** end of MOUSE_LL hook test *************/
8610 skip_mouse_ll_hook_test
:
8612 ok(DestroyWindow(hwnd
), "failed to destroy window\n");
8615 static void test_set_hook(void)
8619 HWINEVENTHOOK hwinevent_hook
;
8621 hhook
= SetWindowsHookExA(WH_CBT
, cbt_hook_proc
, GetModuleHandleA(0), GetCurrentThreadId());
8622 ok(hhook
!= 0, "local hook does not require hModule set to 0\n");
8623 UnhookWindowsHookEx(hhook
);
8627 /* this test doesn't pass under Win9x: BUG! */
8628 SetLastError(0xdeadbeef);
8629 hhook
= SetWindowsHookExA(WH_CBT
, cbt_hook_proc
, 0, 0);
8630 ok(!hhook
, "global hook requires hModule != 0\n");
8631 ok(GetLastError() == ERROR_HOOK_NEEDS_HMOD
, "unexpected error %d\n", GetLastError());
8634 SetLastError(0xdeadbeef);
8635 hhook
= SetWindowsHookExA(WH_CBT
, 0, GetModuleHandleA(0), GetCurrentThreadId());
8636 ok(!hhook
, "SetWinEventHook with invalid proc should fail\n");
8637 ok(GetLastError() == ERROR_INVALID_FILTER_PROC
|| /* Win2k */
8638 GetLastError() == 0xdeadbeef, /* Win9x */
8639 "unexpected error %d\n", GetLastError());
8641 SetLastError(0xdeadbeef);
8642 ok(!UnhookWindowsHookEx((HHOOK
)0xdeadbeef), "UnhookWindowsHookEx succeeded\n");
8643 ok(GetLastError() == ERROR_INVALID_HOOK_HANDLE
|| /* Win2k */
8644 GetLastError() == 0xdeadbeef, /* Win9x */
8645 "unexpected error %d\n", GetLastError());
8647 if (!pSetWinEventHook
|| !pUnhookWinEvent
) return;
8649 /* even process local incontext hooks require hmodule */
8650 SetLastError(0xdeadbeef);
8651 hwinevent_hook
= pSetWinEventHook(EVENT_MIN
, EVENT_MAX
, 0, win_event_proc
,
8652 GetCurrentProcessId(), 0, WINEVENT_INCONTEXT
);
8653 ok(!hwinevent_hook
, "WINEVENT_INCONTEXT requires hModule != 0\n");
8654 ok(GetLastError() == ERROR_HOOK_NEEDS_HMOD
|| /* Win2k */
8655 GetLastError() == 0xdeadbeef, /* Win9x */
8656 "unexpected error %d\n", GetLastError());
8658 /* even thread local incontext hooks require hmodule */
8659 SetLastError(0xdeadbeef);
8660 hwinevent_hook
= pSetWinEventHook(EVENT_MIN
, EVENT_MAX
, 0, win_event_proc
,
8661 GetCurrentProcessId(), GetCurrentThreadId(), WINEVENT_INCONTEXT
);
8662 ok(!hwinevent_hook
, "WINEVENT_INCONTEXT requires hModule != 0\n");
8663 ok(GetLastError() == ERROR_HOOK_NEEDS_HMOD
|| /* Win2k */
8664 GetLastError() == 0xdeadbeef, /* Win9x */
8665 "unexpected error %d\n", GetLastError());
8669 /* these 3 tests don't pass under Win9x */
8670 SetLastError(0xdeadbeef);
8671 hwinevent_hook
= pSetWinEventHook(1, 0, 0, win_event_proc
,
8672 GetCurrentProcessId(), 0, WINEVENT_OUTOFCONTEXT
);
8673 ok(!hwinevent_hook
, "SetWinEventHook with invalid event range should fail\n");
8674 ok(GetLastError() == ERROR_INVALID_HOOK_FILTER
, "unexpected error %d\n", GetLastError());
8676 SetLastError(0xdeadbeef);
8677 hwinevent_hook
= pSetWinEventHook(-1, 1, 0, win_event_proc
,
8678 GetCurrentProcessId(), 0, WINEVENT_OUTOFCONTEXT
);
8679 ok(!hwinevent_hook
, "SetWinEventHook with invalid event range should fail\n");
8680 ok(GetLastError() == ERROR_INVALID_HOOK_FILTER
, "unexpected error %d\n", GetLastError());
8682 SetLastError(0xdeadbeef);
8683 hwinevent_hook
= pSetWinEventHook(EVENT_MIN
, EVENT_MAX
, 0, win_event_proc
,
8684 0, 0xdeadbeef, WINEVENT_OUTOFCONTEXT
);
8685 ok(!hwinevent_hook
, "SetWinEventHook with invalid tid should fail\n");
8686 ok(GetLastError() == ERROR_INVALID_THREAD_ID
, "unexpected error %d\n", GetLastError());
8689 SetLastError(0xdeadbeef);
8690 hwinevent_hook
= pSetWinEventHook(0, 0, 0, win_event_proc
,
8691 GetCurrentProcessId(), 0, WINEVENT_OUTOFCONTEXT
);
8692 ok(hwinevent_hook
!= 0, "SetWinEventHook error %d\n", GetLastError());
8693 ok(GetLastError() == 0xdeadbeef, "unexpected error %d\n", GetLastError());
8694 ret
= pUnhookWinEvent(hwinevent_hook
);
8695 ok( ret
, "UnhookWinEvent error %d\n", GetLastError());
8698 /* This call succeeds under win2k SP4, but fails under Wine.
8699 Does win2k test/use passed process id? */
8700 SetLastError(0xdeadbeef);
8701 hwinevent_hook
= pSetWinEventHook(EVENT_MIN
, EVENT_MAX
, 0, win_event_proc
,
8702 0xdeadbeef, 0, WINEVENT_OUTOFCONTEXT
);
8703 ok(hwinevent_hook
!= 0, "SetWinEventHook error %d\n", GetLastError());
8704 ok(GetLastError() == 0xdeadbeef, "unexpected error %d\n", GetLastError());
8705 ret
= pUnhookWinEvent(hwinevent_hook
);
8706 ok( ret
, "UnhookWinEvent error %d\n", GetLastError());
8709 SetLastError(0xdeadbeef);
8710 ok(!pUnhookWinEvent((HWINEVENTHOOK
)0xdeadbeef), "UnhookWinEvent succeeded\n");
8711 ok(GetLastError() == ERROR_INVALID_HANDLE
|| /* Win2k */
8712 GetLastError() == 0xdeadbeef, /* Win9x */
8713 "unexpected error %d\n", GetLastError());
8716 static const struct message ScrollWindowPaint1
[] = {
8718 { WM_ERASEBKGND
, sent
|beginpaint
},
8719 { WM_GETTEXTLENGTH
, sent
|optional
},
8720 { WM_PAINT
, sent
|optional
},
8721 { WM_NCPAINT
, sent
|beginpaint
|optional
},
8722 { WM_GETTEXT
, sent
|beginpaint
|optional
},
8723 { WM_GETTEXT
, sent
|beginpaint
|optional
},
8724 { WM_GETTEXT
, sent
|beginpaint
|optional
},
8725 { WM_GETTEXT
, sent
|beginpaint
|defwinproc
|optional
},
8726 { WM_ERASEBKGND
, sent
|beginpaint
|optional
},
8730 static const struct message ScrollWindowPaint2
[] = {
8735 static void test_scrollwindowex(void)
8738 RECT rect
={0,0,130,130};
8740 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test Scroll",
8741 WS_VISIBLE
|WS_OVERLAPPEDWINDOW
,
8742 100, 100, 200, 200, 0, 0, 0, NULL
);
8743 ok (hwnd
!= 0, "Failed to create overlapped window\n");
8744 hchild
= CreateWindowExA(0, "TestWindowClass", "Test child",
8745 WS_VISIBLE
|WS_CAPTION
|WS_CHILD
,
8746 10, 10, 150, 150, hwnd
, 0, 0, NULL
);
8747 ok (hchild
!= 0, "Failed to create child\n");
8752 /* scroll without the child window */
8753 trace("start scroll\n");
8754 ScrollWindowEx( hwnd
, 10, 10, &rect
, NULL
, NULL
, NULL
,
8755 SW_ERASE
|SW_INVALIDATE
);
8756 ok_sequence(WmEmptySeq
, "ScrollWindowEx", 0);
8757 trace("end scroll\n");
8760 ok_sequence(ScrollWindowPaint1
, "ScrollWindowEx", 0);
8764 /* Now without the SW_ERASE flag */
8765 trace("start scroll\n");
8766 ScrollWindowEx( hwnd
, 10, 10, &rect
, NULL
, NULL
, NULL
, SW_INVALIDATE
);
8767 ok_sequence(WmEmptySeq
, "ScrollWindowEx", 0);
8768 trace("end scroll\n");
8771 ok_sequence(ScrollWindowPaint2
, "ScrollWindowEx", 0);
8775 /* now scroll the child window as well */
8776 trace("start scroll\n");
8777 ScrollWindowEx( hwnd
, 10, 10, &rect
, NULL
, NULL
, NULL
,
8778 SW_SCROLLCHILDREN
|SW_ERASE
|SW_INVALIDATE
);
8779 /* wine sends WM_POSCHANGING, WM_POSCHANGED messages */
8780 /* windows sometimes a WM_MOVE */
8781 ok_sequence(WmEmptySeq
, "ScrollWindowEx", TRUE
);
8782 trace("end scroll\n");
8785 ok_sequence(ScrollWindowPaint1
, "ScrollWindowEx", 0);
8789 /* now scroll with ScrollWindow() */
8790 trace("start scroll with ScrollWindow\n");
8791 ScrollWindow( hwnd
, 5, 5, NULL
, NULL
);
8792 trace("end scroll\n");
8795 ok_sequence(ScrollWindowPaint1
, "ScrollWindow", 0);
8797 ok(DestroyWindow(hchild
), "failed to destroy window\n");
8798 ok(DestroyWindow(hwnd
), "failed to destroy window\n");
8802 static const struct message destroy_window_with_children
[] = {
8803 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* popup */
8804 { HCBT_DESTROYWND
, hook
|lparam
, 0, WND_PARENT_ID
}, /* parent */
8805 { 0x0090, sent
|optional
},
8806 { HCBT_DESTROYWND
, hook
|lparam
, 0, WND_POPUP_ID
}, /* popup */
8807 { 0x0090, sent
|optional
},
8808 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* popup */
8809 { WM_DESTROY
, sent
|wparam
|lparam
, 0, WND_POPUP_ID
}, /* popup */
8810 { WM_CAPTURECHANGED
, sent
|wparam
|lparam
, 0, WND_POPUP_ID
}, /* popup */
8811 { WM_NCDESTROY
, sent
|wparam
|lparam
, 0, WND_POPUP_ID
}, /* popup */
8812 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, 0, 0 }, /* parent */
8813 { WM_DESTROY
, sent
|wparam
|lparam
, 0, WND_PARENT_ID
}, /* parent */
8814 { WM_DESTROY
, sent
|wparam
|lparam
, 0, WND_CHILD_ID
+ 2 }, /* child2 */
8815 { WM_DESTROY
, sent
|wparam
|lparam
, 0, WND_CHILD_ID
+ 1 }, /* child1 */
8816 { WM_DESTROY
, sent
|wparam
|lparam
, 0, WND_CHILD_ID
+ 3 }, /* child3 */
8817 { WM_NCDESTROY
, sent
|wparam
|lparam
, 0, WND_CHILD_ID
+ 2 }, /* child2 */
8818 { WM_NCDESTROY
, sent
|wparam
|lparam
, 0, WND_CHILD_ID
+ 3 }, /* child3 */
8819 { WM_NCDESTROY
, sent
|wparam
|lparam
, 0, WND_CHILD_ID
+ 1 }, /* child1 */
8820 { WM_NCDESTROY
, sent
|wparam
|lparam
, 0, WND_PARENT_ID
}, /* parent */
8824 static void test_DestroyWindow(void)
8827 HWND parent
, child1
, child2
, child3
, child4
, test
;
8828 UINT_PTR child_id
= WND_CHILD_ID
+ 1;
8830 parent
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
8831 100, 100, 200, 200, 0, 0, 0, NULL
);
8832 assert(parent
!= 0);
8833 child1
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_CHILD
,
8834 0, 0, 50, 50, parent
, (HMENU
)child_id
++, 0, NULL
);
8835 assert(child1
!= 0);
8836 child2
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_CHILD
,
8837 0, 0, 50, 50, GetDesktopWindow(), (HMENU
)child_id
++, 0, NULL
);
8838 assert(child2
!= 0);
8839 child3
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_CHILD
,
8840 0, 0, 50, 50, child1
, (HMENU
)child_id
++, 0, NULL
);
8841 assert(child3
!= 0);
8842 child4
= CreateWindowExA(0, "TestWindowClass", NULL
, WS_POPUP
,
8843 0, 0, 50, 50, parent
, 0, 0, NULL
);
8844 assert(child4
!= 0);
8846 /* test owner/parent of child2 */
8847 test
= GetParent(child2
);
8848 ok(test
== GetDesktopWindow(), "wrong parent %p\n", test
);
8849 ok(!IsChild(parent
, child2
), "wrong parent/child %p/%p\n", parent
, child2
);
8851 test
= pGetAncestor(child2
, GA_PARENT
);
8852 ok(test
== GetDesktopWindow(), "wrong parent %p\n", test
);
8854 test
= GetWindow(child2
, GW_OWNER
);
8855 ok(!test
, "wrong owner %p\n", test
);
8857 test
= SetParent(child2
, parent
);
8858 ok(test
== GetDesktopWindow(), "wrong old parent %p\n", test
);
8860 /* test owner/parent of the parent */
8861 test
= GetParent(parent
);
8862 ok(!test
, "wrong parent %p\n", test
);
8863 ok(!IsChild(GetDesktopWindow(), parent
), "wrong parent/child %p/%p\n", GetDesktopWindow(), parent
);
8865 test
= pGetAncestor(parent
, GA_PARENT
);
8866 ok(test
== GetDesktopWindow(), "wrong parent %p\n", test
);
8868 test
= GetWindow(parent
, GW_OWNER
);
8869 ok(!test
, "wrong owner %p\n", test
);
8871 /* test owner/parent of child1 */
8872 test
= GetParent(child1
);
8873 ok(test
== parent
, "wrong parent %p\n", test
);
8874 ok(IsChild(parent
, child1
), "wrong parent/child %p/%p\n", parent
, child1
);
8876 test
= pGetAncestor(child1
, GA_PARENT
);
8877 ok(test
== parent
, "wrong parent %p\n", test
);
8879 test
= GetWindow(child1
, GW_OWNER
);
8880 ok(!test
, "wrong owner %p\n", test
);
8882 /* test owner/parent of child2 */
8883 test
= GetParent(child2
);
8884 ok(test
== parent
, "wrong parent %p\n", test
);
8885 ok(IsChild(parent
, child2
), "wrong parent/child %p/%p\n", parent
, child2
);
8887 test
= pGetAncestor(child2
, GA_PARENT
);
8888 ok(test
== parent
, "wrong parent %p\n", test
);
8890 test
= GetWindow(child2
, GW_OWNER
);
8891 ok(!test
, "wrong owner %p\n", test
);
8893 /* test owner/parent of child3 */
8894 test
= GetParent(child3
);
8895 ok(test
== child1
, "wrong parent %p\n", test
);
8896 ok(IsChild(parent
, child3
), "wrong parent/child %p/%p\n", parent
, child3
);
8898 test
= pGetAncestor(child3
, GA_PARENT
);
8899 ok(test
== child1
, "wrong parent %p\n", test
);
8901 test
= GetWindow(child3
, GW_OWNER
);
8902 ok(!test
, "wrong owner %p\n", test
);
8904 /* test owner/parent of child4 */
8905 test
= GetParent(child4
);
8906 ok(test
== parent
, "wrong parent %p\n", test
);
8907 ok(!IsChild(parent
, child4
), "wrong parent/child %p/%p\n", parent
, child4
);
8909 test
= pGetAncestor(child4
, GA_PARENT
);
8910 ok(test
== GetDesktopWindow(), "wrong parent %p\n", test
);
8912 test
= GetWindow(child4
, GW_OWNER
);
8913 ok(test
== parent
, "wrong owner %p\n", test
);
8917 trace("parent %p, child1 %p, child2 %p, child3 %p, child4 %p\n",
8918 parent
, child1
, child2
, child3
, child4
);
8921 test
= GetCapture();
8922 ok(test
== child4
, "wrong capture window %p\n", test
);
8924 test_DestroyWindow_flag
= TRUE
;
8925 ret
= DestroyWindow(parent
);
8926 ok( ret
, "DestroyWindow() error %d\n", GetLastError());
8927 test_DestroyWindow_flag
= FALSE
;
8928 ok_sequence(destroy_window_with_children
, "destroy window with children", 0);
8930 ok(!IsWindow(parent
), "parent still exists\n");
8931 ok(!IsWindow(child1
), "child1 still exists\n");
8932 ok(!IsWindow(child2
), "child2 still exists\n");
8933 ok(!IsWindow(child3
), "child3 still exists\n");
8934 ok(!IsWindow(child4
), "child4 still exists\n");
8936 test
= GetCapture();
8937 ok(!test
, "wrong capture window %p\n", test
);
8941 static const struct message WmDispatchPaint
[] = {
8942 { WM_NCPAINT
, sent
},
8943 { WM_GETTEXT
, sent
|defwinproc
|optional
},
8944 { WM_GETTEXT
, sent
|defwinproc
|optional
},
8945 { WM_ERASEBKGND
, sent
},
8949 static LRESULT WINAPI
DispatchMessageCheckProc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
8951 if (message
== WM_PAINT
) return 0;
8952 return MsgCheckProcA( hwnd
, message
, wParam
, lParam
);
8955 static void test_DispatchMessage(void)
8960 HWND hwnd
= CreateWindowA( "TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
8961 100, 100, 200, 200, 0, 0, 0, NULL
);
8962 ShowWindow( hwnd
, SW_SHOW
);
8963 UpdateWindow( hwnd
);
8966 SetWindowLongPtrA( hwnd
, GWLP_WNDPROC
, (LONG_PTR
)DispatchMessageCheckProc
);
8968 SetRect( &rect
, -5, -5, 5, 5 );
8969 RedrawWindow( hwnd
, &rect
, 0, RDW_INVALIDATE
|RDW_ERASE
|RDW_FRAME
);
8971 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
))
8973 if (msg
.message
!= WM_PAINT
) DispatchMessage( &msg
);
8977 DispatchMessage( &msg
);
8978 /* DispatchMessage will send WM_NCPAINT if non client area is still invalid after WM_PAINT */
8979 if (!count
) ok_sequence( WmDispatchPaint
, "WmDispatchPaint", FALSE
);
8980 else ok_sequence( WmEmptySeq
, "WmEmpty", FALSE
);
8981 if (++count
> 10) break;
8984 ok( msg
.message
== WM_PAINT
&& count
> 10, "WM_PAINT messages stopped\n" );
8986 trace("now without DispatchMessage\n");
8988 RedrawWindow( hwnd
, &rect
, 0, RDW_INVALIDATE
|RDW_ERASE
|RDW_FRAME
);
8990 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
))
8992 if (msg
.message
!= WM_PAINT
) DispatchMessage( &msg
);
8995 HRGN hrgn
= CreateRectRgn( 0, 0, 0, 0 );
8997 /* this will send WM_NCCPAINT just like DispatchMessage does */
8998 GetUpdateRgn( hwnd
, hrgn
, TRUE
);
8999 ok_sequence( WmDispatchPaint
, "WmDispatchPaint", FALSE
);
9000 DeleteObject( hrgn
);
9001 GetClientRect( hwnd
, &rect
);
9002 ValidateRect( hwnd
, &rect
); /* this will stop WM_PAINTs */
9003 ok( !count
, "Got multiple WM_PAINTs\n" );
9004 if (++count
> 10) break;
9007 DestroyWindow(hwnd
);
9011 static const struct message WmUser
[] = {
9023 static DWORD CALLBACK
send_msg_thread( LPVOID arg
)
9025 struct sendmsg_info
*info
= arg
;
9026 SetLastError( 0xdeadbeef );
9027 info
->ret
= SendMessageTimeoutA( info
->hwnd
, WM_USER
, 0, 0, 0, info
->timeout
, NULL
);
9028 if (!info
->ret
) ok( GetLastError() == ERROR_TIMEOUT
||
9029 broken(GetLastError() == 0), /* win9x */
9030 "unexpected error %d\n", GetLastError());
9034 static void wait_for_thread( HANDLE thread
)
9036 while (MsgWaitForMultipleObjects(1, &thread
, FALSE
, INFINITE
, QS_SENDMESSAGE
) != WAIT_OBJECT_0
)
9039 while (PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage(&msg
);
9043 static LRESULT WINAPI
send_msg_delay_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
9045 if (message
== WM_USER
) Sleep(200);
9046 return MsgCheckProcA( hwnd
, message
, wParam
, lParam
);
9049 static void test_SendMessageTimeout(void)
9052 struct sendmsg_info info
;
9056 info
.hwnd
= CreateWindowA( "TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
9057 100, 100, 200, 200, 0, 0, 0, NULL
);
9061 info
.timeout
= 1000;
9062 info
.ret
= 0xdeadbeef;
9063 thread
= CreateThread( NULL
, 0, send_msg_thread
, &info
, 0, &tid
);
9064 wait_for_thread( thread
);
9065 CloseHandle( thread
);
9066 ok( info
.ret
== 1, "SendMessageTimeout failed\n" );
9067 ok_sequence( WmUser
, "WmUser", FALSE
);
9070 info
.ret
= 0xdeadbeef;
9071 thread
= CreateThread( NULL
, 0, send_msg_thread
, &info
, 0, &tid
);
9072 Sleep(100); /* SendMessageTimeout should time out here */
9073 wait_for_thread( thread
);
9074 CloseHandle( thread
);
9075 ok( info
.ret
== 0, "SendMessageTimeout succeeded\n" );
9076 ok_sequence( WmEmptySeq
, "WmEmptySeq", FALSE
);
9078 /* 0 means infinite timeout (but not on win9x) */
9080 info
.ret
= 0xdeadbeef;
9081 thread
= CreateThread( NULL
, 0, send_msg_thread
, &info
, 0, &tid
);
9083 wait_for_thread( thread
);
9084 CloseHandle( thread
);
9085 is_win9x
= !info
.ret
;
9086 if (is_win9x
) ok_sequence( WmEmptySeq
, "WmEmptySeq", FALSE
);
9087 else ok_sequence( WmUser
, "WmUser", FALSE
);
9089 /* timeout is treated as signed despite the prototype (but not on win9x) */
9090 info
.timeout
= 0x7fffffff;
9091 info
.ret
= 0xdeadbeef;
9092 thread
= CreateThread( NULL
, 0, send_msg_thread
, &info
, 0, &tid
);
9094 wait_for_thread( thread
);
9095 CloseHandle( thread
);
9096 ok( info
.ret
== 1, "SendMessageTimeout failed\n" );
9097 ok_sequence( WmUser
, "WmUser", FALSE
);
9099 info
.timeout
= 0x80000000;
9100 info
.ret
= 0xdeadbeef;
9101 thread
= CreateThread( NULL
, 0, send_msg_thread
, &info
, 0, &tid
);
9103 wait_for_thread( thread
);
9104 CloseHandle( thread
);
9107 ok( info
.ret
== 1, "SendMessageTimeout failed\n" );
9108 ok_sequence( WmUser
, "WmUser", FALSE
);
9112 ok( info
.ret
== 0, "SendMessageTimeout succeeded\n" );
9113 ok_sequence( WmEmptySeq
, "WmEmptySeq", FALSE
);
9116 /* now check for timeout during message processing */
9117 SetWindowLongPtrA( info
.hwnd
, GWLP_WNDPROC
, (LONG_PTR
)send_msg_delay_proc
);
9119 info
.ret
= 0xdeadbeef;
9120 thread
= CreateThread( NULL
, 0, send_msg_thread
, &info
, 0, &tid
);
9121 wait_for_thread( thread
);
9122 CloseHandle( thread
);
9123 /* we should time out but still get the message */
9124 ok( info
.ret
== 0, "SendMessageTimeout failed\n" );
9125 ok_sequence( WmUser
, "WmUser", FALSE
);
9127 DestroyWindow( info
.hwnd
);
9131 /****************** edit message test *************************/
9132 #define ID_EDIT 0x1234
9133 static const struct message sl_edit_setfocus
[] =
9135 { HCBT_SETFOCUS
, hook
},
9136 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
9137 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
9138 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
9139 { WM_SETFOCUS
, sent
|wparam
, 0 },
9140 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 10 },
9141 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 15 },
9142 { WM_CTLCOLOREDIT
, sent
|parent
},
9143 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 11 },
9144 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
9145 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
9146 { WM_COMMAND
, sent
|parent
|wparam
, MAKEWPARAM(ID_EDIT
, EN_SETFOCUS
) },
9149 static const struct message ml_edit_setfocus
[] =
9151 { HCBT_SETFOCUS
, hook
},
9152 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
9153 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
9154 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
9155 { WM_SETFOCUS
, sent
|wparam
, 0 },
9156 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 10 },
9157 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 11 },
9158 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
9159 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
9160 { WM_COMMAND
, sent
|parent
|wparam
, MAKEWPARAM(ID_EDIT
, EN_SETFOCUS
) },
9163 static const struct message sl_edit_killfocus
[] =
9165 { HCBT_SETFOCUS
, hook
},
9166 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
9167 { WM_KILLFOCUS
, sent
|wparam
, 0 },
9168 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
9169 { EVENT_OBJECT_DESTROY
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
9170 { WM_COMMAND
, sent
|parent
|wparam
, MAKEWPARAM(ID_EDIT
, EN_KILLFOCUS
) },
9171 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
9172 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 1 },
9175 static const struct message sl_edit_lbutton_dblclk
[] =
9177 { WM_LBUTTONDBLCLK
, sent
},
9178 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
9181 static const struct message sl_edit_lbutton_down
[] =
9183 { WM_LBUTTONDOWN
, sent
|wparam
|lparam
, 0, 0 },
9184 { HCBT_SETFOCUS
, hook
},
9185 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
9186 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
9187 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
9188 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
9189 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 10 },
9190 { WM_CTLCOLOREDIT
, sent
|parent
},
9191 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 11 },
9192 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
9193 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
9194 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
9195 { WM_COMMAND
, sent
|parent
|wparam
, MAKEWPARAM(ID_EDIT
, EN_SETFOCUS
) },
9196 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
9197 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
9198 { WM_CTLCOLOREDIT
, sent
|parent
|optional
},
9199 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 11 },
9200 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
9201 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
9204 static const struct message ml_edit_lbutton_down
[] =
9206 { WM_LBUTTONDOWN
, sent
|wparam
|lparam
, 0, 0 },
9207 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
9208 { HCBT_SETFOCUS
, hook
},
9209 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
9210 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
9211 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
9212 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
9213 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 10 },
9214 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 11 },
9215 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
9216 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
9217 { WM_COMMAND
, sent
|parent
|wparam
, MAKEWPARAM(ID_EDIT
, EN_SETFOCUS
) },
9220 static const struct message sl_edit_lbutton_up
[] =
9222 { WM_LBUTTONUP
, sent
|wparam
|lparam
, 0, 0 },
9223 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
9224 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, 0, 0 },
9225 { WM_CAPTURECHANGED
, sent
|defwinproc
},
9226 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
9229 static const struct message ml_edit_lbutton_up
[] =
9231 { WM_LBUTTONUP
, sent
|wparam
|lparam
, 0, 0 },
9232 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, 0, 0 },
9233 { WM_CAPTURECHANGED
, sent
|defwinproc
},
9237 static WNDPROC old_edit_proc
;
9239 static LRESULT CALLBACK
edit_hook_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
9241 static LONG defwndproc_counter
= 0;
9243 struct recvd_message msg
;
9245 if (ignore_message( message
)) return 0;
9248 msg
.message
= message
;
9249 msg
.flags
= sent
|wparam
|lparam
;
9250 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
9251 msg
.wParam
= wParam
;
9252 msg
.lParam
= lParam
;
9256 defwndproc_counter
++;
9257 ret
= CallWindowProcA(old_edit_proc
, hwnd
, message
, wParam
, lParam
);
9258 defwndproc_counter
--;
9263 static void subclass_edit(void)
9267 if (!GetClassInfoA(0, "edit", &cls
)) assert(0);
9269 old_edit_proc
= cls
.lpfnWndProc
;
9271 cls
.hInstance
= GetModuleHandle(0);
9272 cls
.lpfnWndProc
= edit_hook_proc
;
9273 cls
.lpszClassName
= "my_edit_class";
9274 UnregisterClass(cls
.lpszClassName
, cls
.hInstance
);
9275 if (!RegisterClassA(&cls
)) assert(0);
9278 static void test_edit_messages(void)
9284 log_all_parent_messages
++;
9286 parent
= CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
9287 100, 100, 200, 200, 0, 0, 0, NULL
);
9288 ok (parent
!= 0, "Failed to create parent window\n");
9290 /* test single line edit */
9291 hwnd
= CreateWindowExA(0, "my_edit_class", "test", WS_CHILD
,
9292 0, 0, 80, 20, parent
, (HMENU
)ID_EDIT
, 0, NULL
);
9293 ok(hwnd
!= 0, "Failed to create edit window\n");
9295 dlg_code
= SendMessageA(hwnd
, WM_GETDLGCODE
, 0, 0);
9296 ok(dlg_code
== (DLGC_WANTCHARS
|DLGC_HASSETSEL
|DLGC_WANTARROWS
), "wrong dlg_code %08x\n", dlg_code
);
9298 ShowWindow(hwnd
, SW_SHOW
);
9304 ok_sequence(sl_edit_setfocus
, "SetFocus(hwnd) on an edit", FALSE
);
9307 ok_sequence(sl_edit_killfocus
, "SetFocus(0) on an edit", FALSE
);
9313 SendMessageA(hwnd
, WM_LBUTTONDBLCLK
, 0, 0);
9314 ok_sequence(sl_edit_lbutton_dblclk
, "WM_LBUTTONDBLCLK on an edit", FALSE
);
9320 SendMessageA(hwnd
, WM_LBUTTONDOWN
, 0, 0);
9321 ok_sequence(sl_edit_lbutton_down
, "WM_LBUTTONDOWN on an edit", FALSE
);
9323 SendMessageA(hwnd
, WM_LBUTTONUP
, 0, 0);
9324 ok_sequence(sl_edit_lbutton_up
, "WM_LBUTTONUP on an edit", FALSE
);
9326 DestroyWindow(hwnd
);
9328 /* test multiline edit */
9329 hwnd
= CreateWindowExA(0, "my_edit_class", "test", WS_CHILD
| ES_MULTILINE
,
9330 0, 0, 80, 20, parent
, (HMENU
)ID_EDIT
, 0, NULL
);
9331 ok(hwnd
!= 0, "Failed to create edit window\n");
9333 dlg_code
= SendMessageA(hwnd
, WM_GETDLGCODE
, 0, 0);
9334 ok(dlg_code
== (DLGC_WANTCHARS
|DLGC_HASSETSEL
|DLGC_WANTARROWS
|DLGC_WANTALLKEYS
),
9335 "wrong dlg_code %08x\n", dlg_code
);
9337 ShowWindow(hwnd
, SW_SHOW
);
9343 ok_sequence(ml_edit_setfocus
, "SetFocus(hwnd) on multiline edit", FALSE
);
9346 ok_sequence(sl_edit_killfocus
, "SetFocus(0) on multiline edit", FALSE
);
9352 SendMessageA(hwnd
, WM_LBUTTONDBLCLK
, 0, 0);
9353 ok_sequence(sl_edit_lbutton_dblclk
, "WM_LBUTTONDBLCLK on multiline edit", FALSE
);
9359 SendMessageA(hwnd
, WM_LBUTTONDOWN
, 0, 0);
9360 ok_sequence(ml_edit_lbutton_down
, "WM_LBUTTONDOWN on multiline edit", FALSE
);
9362 SendMessageA(hwnd
, WM_LBUTTONUP
, 0, 0);
9363 ok_sequence(ml_edit_lbutton_up
, "WM_LBUTTONUP on multiline edit", FALSE
);
9365 DestroyWindow(hwnd
);
9366 DestroyWindow(parent
);
9368 log_all_parent_messages
--;
9371 /**************************** End of Edit test ******************************/
9373 static const struct message WmKeyDownSkippedSeq
[] =
9375 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 1 }, /* XP */
9378 static const struct message WmKeyDownWasDownSkippedSeq
[] =
9380 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0x40000001 }, /* XP */
9383 static const struct message WmKeyUpSkippedSeq
[] =
9385 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xc0000001 }, /* XP */
9388 static const struct message WmUserKeyUpSkippedSeq
[] =
9391 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'N', 0xc0000001 }, /* XP */
9396 #define EV_SENDMSG 1
9402 HANDLE hevent
[3]; /* 0 - start/stop, 1 - SendMessage, 2 - ack */
9405 static DWORD CALLBACK
send_msg_thread_2(void *param
)
9408 struct peekmsg_info
*info
= param
;
9410 trace("thread: looping\n");
9411 SetEvent(info
->hevent
[EV_ACK
]);
9415 ret
= WaitForMultipleObjects(2, info
->hevent
, FALSE
, INFINITE
);
9419 case WAIT_OBJECT_0
+ EV_STOP
:
9420 trace("thread: exiting\n");
9423 case WAIT_OBJECT_0
+ EV_SENDMSG
:
9424 trace("thread: sending message\n");
9425 ok( SendNotifyMessageA(info
->hwnd
, WM_USER
, 0, 0),
9426 "SendNotifyMessageA failed error %u\n", GetLastError());
9427 SetEvent(info
->hevent
[EV_ACK
]);
9431 trace("unexpected return: %04x\n", ret
);
9439 static void test_PeekMessage(void)
9444 UINT qs_all_input
= QS_ALLINPUT
;
9445 UINT qs_input
= QS_INPUT
;
9447 struct peekmsg_info info
;
9449 info
.hwnd
= CreateWindowA("TestWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
9450 100, 100, 200, 200, 0, 0, 0, NULL
);
9452 ShowWindow(info
.hwnd
, SW_SHOW
);
9453 UpdateWindow(info
.hwnd
);
9454 SetFocus(info
.hwnd
);
9456 info
.hevent
[EV_STOP
] = CreateEventA(NULL
, 0, 0, NULL
);
9457 info
.hevent
[EV_SENDMSG
] = CreateEventA(NULL
, 0, 0, NULL
);
9458 info
.hevent
[EV_ACK
] = CreateEventA(NULL
, 0, 0, NULL
);
9460 hthread
= CreateThread(NULL
, 0, send_msg_thread_2
, &info
, 0, &tid
);
9461 WaitForSingleObject(info
.hevent
[EV_ACK
], 10000);
9466 SetLastError(0xdeadbeef);
9467 qstatus
= GetQueueStatus(qs_all_input
);
9468 if (GetLastError() == ERROR_INVALID_FLAGS
)
9470 trace("QS_RAWINPUT not supported on this platform\n");
9471 qs_all_input
&= ~QS_RAWINPUT
;
9472 qs_input
&= ~QS_RAWINPUT
;
9474 if (qstatus
& QS_POSTMESSAGE
)
9476 while (PeekMessage(&msg
, 0, 0, 0, PM_REMOVE
)) /* nothing */ ;
9477 qstatus
= GetQueueStatus(qs_all_input
);
9479 ok(qstatus
== 0, "wrong qstatus %08x\n", qstatus
);
9481 trace("signalling to send message\n");
9482 SetEvent(info
.hevent
[EV_SENDMSG
]);
9483 WaitForSingleObject(info
.hevent
[EV_ACK
], INFINITE
);
9485 /* pass invalid QS_xxxx flags */
9486 SetLastError(0xdeadbeef);
9487 qstatus
= GetQueueStatus(0xffffffff);
9488 ok(qstatus
== 0 || broken(qstatus
) /* win9x */, "GetQueueStatus should fail: %08x\n", qstatus
);
9491 ok(GetLastError() == ERROR_INVALID_FLAGS
, "wrong error %d\n", GetLastError());
9492 qstatus
= GetQueueStatus(qs_all_input
);
9494 qstatus
&= ~MAKELONG( 0x4000, 0x4000 ); /* sometimes set on Win95 */
9495 ok(qstatus
== MAKELONG(QS_SENDMESSAGE
, QS_SENDMESSAGE
),
9496 "wrong qstatus %08x\n", qstatus
);
9499 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
9501 "PeekMessageA should have returned FALSE instead of msg %04x\n",
9503 ok_sequence(WmUser
, "WmUser", FALSE
);
9505 qstatus
= GetQueueStatus(qs_all_input
);
9506 ok(qstatus
== 0, "wrong qstatus %08x\n", qstatus
);
9508 keybd_event('N', 0, 0, 0);
9509 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
9510 qstatus
= GetQueueStatus(qs_all_input
);
9511 if (!(qstatus
& MAKELONG(QS_KEY
, QS_KEY
)))
9513 skip( "queuing key events not supported\n" );
9516 ok(qstatus
== MAKELONG(QS_KEY
, QS_KEY
) ||
9517 /* keybd_event seems to trigger a sent message on NT4 */
9518 qstatus
== MAKELONG(QS_KEY
|QS_SENDMESSAGE
, QS_KEY
|QS_SENDMESSAGE
),
9519 "wrong qstatus %08x\n", qstatus
);
9521 PostMessageA(info
.hwnd
, WM_CHAR
, 'z', 0);
9522 qstatus
= GetQueueStatus(qs_all_input
);
9523 ok(qstatus
== MAKELONG(QS_POSTMESSAGE
, QS_POSTMESSAGE
|QS_KEY
) ||
9524 qstatus
== MAKELONG(QS_POSTMESSAGE
, QS_POSTMESSAGE
|QS_KEY
|QS_SENDMESSAGE
),
9525 "wrong qstatus %08x\n", qstatus
);
9527 InvalidateRect(info
.hwnd
, NULL
, FALSE
);
9528 qstatus
= GetQueueStatus(qs_all_input
);
9529 ok(qstatus
== MAKELONG(QS_PAINT
, QS_PAINT
|QS_POSTMESSAGE
|QS_KEY
) ||
9530 qstatus
== MAKELONG(QS_PAINT
, QS_PAINT
|QS_POSTMESSAGE
|QS_KEY
|QS_SENDMESSAGE
),
9531 "wrong qstatus %08x\n", qstatus
);
9533 trace("signalling to send message\n");
9534 SetEvent(info
.hevent
[EV_SENDMSG
]);
9535 WaitForSingleObject(info
.hevent
[EV_ACK
], INFINITE
);
9537 qstatus
= GetQueueStatus(qs_all_input
);
9538 ok(qstatus
== MAKELONG(QS_SENDMESSAGE
, QS_SENDMESSAGE
|QS_PAINT
|QS_POSTMESSAGE
|QS_KEY
),
9539 "wrong qstatus %08x\n", qstatus
);
9542 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| (qs_input
<< 16));
9543 if (ret
&& msg
.message
== WM_CHAR
)
9545 win_skip( "PM_QS_* flags not supported in PeekMessage\n" );
9549 "PeekMessageA should have returned FALSE instead of msg %04x\n",
9551 if (!sequence_cnt
) /* nt4 doesn't fetch anything with PM_QS_* flags */
9553 win_skip( "PM_QS_* flags not supported in PeekMessage\n" );
9556 ok_sequence(WmUser
, "WmUser", FALSE
);
9558 qstatus
= GetQueueStatus(qs_all_input
);
9559 ok(qstatus
== MAKELONG(0, QS_PAINT
|QS_POSTMESSAGE
|QS_KEY
),
9560 "wrong qstatus %08x\n", qstatus
);
9562 trace("signalling to send message\n");
9563 SetEvent(info
.hevent
[EV_SENDMSG
]);
9564 WaitForSingleObject(info
.hevent
[EV_ACK
], INFINITE
);
9566 qstatus
= GetQueueStatus(qs_all_input
);
9567 ok(qstatus
== MAKELONG(QS_SENDMESSAGE
, QS_SENDMESSAGE
|QS_PAINT
|QS_POSTMESSAGE
|QS_KEY
),
9568 "wrong qstatus %08x\n", qstatus
);
9571 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| PM_QS_POSTMESSAGE
);
9573 "PeekMessageA should have returned FALSE instead of msg %04x\n",
9575 ok_sequence(WmUser
, "WmUser", FALSE
);
9577 qstatus
= GetQueueStatus(qs_all_input
);
9578 ok(qstatus
== MAKELONG(0, QS_PAINT
|QS_POSTMESSAGE
|QS_KEY
),
9579 "wrong qstatus %08x\n", qstatus
);
9582 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| PM_QS_POSTMESSAGE
);
9583 ok(ret
&& msg
.message
== WM_CHAR
&& msg
.wParam
== 'z',
9584 "got %d and %04x wParam %08lx instead of TRUE and WM_CHAR wParam 'z'\n",
9585 ret
, msg
.message
, msg
.wParam
);
9586 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
9588 qstatus
= GetQueueStatus(qs_all_input
);
9589 ok(qstatus
== MAKELONG(0, QS_PAINT
|QS_KEY
),
9590 "wrong qstatus %08x\n", qstatus
);
9593 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| PM_QS_POSTMESSAGE
);
9595 "PeekMessageA should have returned FALSE instead of msg %04x\n",
9597 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
9599 qstatus
= GetQueueStatus(qs_all_input
);
9600 ok(qstatus
== MAKELONG(0, QS_PAINT
|QS_KEY
),
9601 "wrong qstatus %08x\n", qstatus
);
9604 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| PM_QS_PAINT
);
9605 ok(ret
&& msg
.message
== WM_PAINT
,
9606 "got %d and %04x instead of TRUE and WM_PAINT\n", ret
, msg
.message
);
9607 DispatchMessageA(&msg
);
9608 ok_sequence(WmPaint
, "WmPaint", FALSE
);
9610 qstatus
= GetQueueStatus(qs_all_input
);
9611 ok(qstatus
== MAKELONG(0, QS_KEY
),
9612 "wrong qstatus %08x\n", qstatus
);
9615 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| PM_QS_PAINT
);
9617 "PeekMessageA should have returned FALSE instead of msg %04x\n",
9619 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
9621 qstatus
= GetQueueStatus(qs_all_input
);
9622 ok(qstatus
== MAKELONG(0, QS_KEY
),
9623 "wrong qstatus %08x\n", qstatus
);
9625 trace("signalling to send message\n");
9626 SetEvent(info
.hevent
[EV_SENDMSG
]);
9627 WaitForSingleObject(info
.hevent
[EV_ACK
], INFINITE
);
9629 qstatus
= GetQueueStatus(qs_all_input
);
9630 ok(qstatus
== MAKELONG(QS_SENDMESSAGE
, QS_SENDMESSAGE
|QS_KEY
),
9631 "wrong qstatus %08x\n", qstatus
);
9633 PostMessageA(info
.hwnd
, WM_CHAR
, 'z', 0);
9635 qstatus
= GetQueueStatus(qs_all_input
);
9636 ok(qstatus
== MAKELONG(QS_POSTMESSAGE
, QS_SENDMESSAGE
|QS_POSTMESSAGE
|QS_KEY
),
9637 "wrong qstatus %08x\n", qstatus
);
9640 ret
= PeekMessageA(&msg
, 0, WM_CHAR
, WM_CHAR
, PM_REMOVE
);
9641 ok(ret
&& msg
.message
== WM_CHAR
&& msg
.wParam
== 'z',
9642 "got %d and %04x wParam %08lx instead of TRUE and WM_CHAR wParam 'z'\n",
9643 ret
, msg
.message
, msg
.wParam
);
9644 ok_sequence(WmUser
, "WmUser", FALSE
);
9646 qstatus
= GetQueueStatus(qs_all_input
);
9647 ok(qstatus
== MAKELONG(0, QS_KEY
),
9648 "wrong qstatus %08x\n", qstatus
);
9651 ret
= PeekMessageA(&msg
, 0, WM_CHAR
, WM_CHAR
, PM_REMOVE
);
9653 "PeekMessageA should have returned FALSE instead of msg %04x\n",
9655 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
9657 qstatus
= GetQueueStatus(qs_all_input
);
9658 ok(qstatus
== MAKELONG(0, QS_KEY
),
9659 "wrong qstatus %08x\n", qstatus
);
9661 PostMessageA(info
.hwnd
, WM_CHAR
, 'z', 0);
9663 qstatus
= GetQueueStatus(qs_all_input
);
9664 ok(qstatus
== MAKELONG(QS_POSTMESSAGE
, QS_POSTMESSAGE
|QS_KEY
),
9665 "wrong qstatus %08x\n", qstatus
);
9667 trace("signalling to send message\n");
9668 SetEvent(info
.hevent
[EV_SENDMSG
]);
9669 WaitForSingleObject(info
.hevent
[EV_ACK
], INFINITE
);
9671 qstatus
= GetQueueStatus(qs_all_input
);
9672 ok(qstatus
== MAKELONG(QS_SENDMESSAGE
, QS_SENDMESSAGE
|QS_POSTMESSAGE
|QS_KEY
),
9673 "wrong qstatus %08x\n", qstatus
);
9676 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| (QS_KEY
<< 16));
9678 "PeekMessageA should have returned FALSE instead of msg %04x\n",
9680 ok_sequence(WmUser
, "WmUser", FALSE
);
9682 qstatus
= GetQueueStatus(qs_all_input
);
9683 ok(qstatus
== MAKELONG(0, QS_POSTMESSAGE
|QS_KEY
),
9684 "wrong qstatus %08x\n", qstatus
);
9687 if (qs_all_input
& QS_RAWINPUT
) /* use QS_RAWINPUT only if supported */
9688 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| (QS_RAWINPUT
<< 16));
9689 else /* workaround for a missing QS_RAWINPUT support */
9690 ret
= PeekMessageA(&msg
, 0, WM_KEYDOWN
, WM_KEYDOWN
, PM_REMOVE
);
9691 ok(ret
&& msg
.message
== WM_KEYDOWN
&& msg
.wParam
== 'N',
9692 "got %d and %04x wParam %08lx instead of TRUE and WM_KEYDOWN wParam 'N'\n",
9693 ret
, msg
.message
, msg
.wParam
);
9694 ok_sequence(WmKeyDownSkippedSeq
, "WmKeyDownSkippedSeq", FALSE
);
9696 qstatus
= GetQueueStatus(qs_all_input
);
9697 ok(qstatus
== MAKELONG(0, QS_POSTMESSAGE
|QS_KEY
),
9698 "wrong qstatus %08x\n", qstatus
);
9701 if (qs_all_input
& QS_RAWINPUT
) /* use QS_RAWINPUT only if supported */
9702 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| (QS_RAWINPUT
<< 16));
9703 else /* workaround for a missing QS_RAWINPUT support */
9704 ret
= PeekMessageA(&msg
, 0, WM_KEYUP
, WM_KEYUP
, PM_REMOVE
);
9705 ok(ret
&& msg
.message
== WM_KEYUP
&& msg
.wParam
== 'N',
9706 "got %d and %04x wParam %08lx instead of TRUE and WM_KEYUP wParam 'N'\n",
9707 ret
, msg
.message
, msg
.wParam
);
9708 ok_sequence(WmKeyUpSkippedSeq
, "WmKeyUpSkippedSeq", FALSE
);
9710 qstatus
= GetQueueStatus(qs_all_input
);
9711 ok(qstatus
== MAKELONG(0, QS_POSTMESSAGE
),
9712 "wrong qstatus %08x\n", qstatus
);
9715 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| PM_QS_SENDMESSAGE
);
9717 "PeekMessageA should have returned FALSE instead of msg %04x\n",
9719 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
9721 qstatus
= GetQueueStatus(qs_all_input
);
9722 ok(qstatus
== MAKELONG(0, QS_POSTMESSAGE
),
9723 "wrong qstatus %08x\n", qstatus
);
9726 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
9727 ok(ret
&& msg
.message
== WM_CHAR
&& msg
.wParam
== 'z',
9728 "got %d and %04x wParam %08lx instead of TRUE and WM_CHAR wParam 'z'\n",
9729 ret
, msg
.message
, msg
.wParam
);
9730 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
9732 qstatus
= GetQueueStatus(qs_all_input
);
9734 "wrong qstatus %08x\n", qstatus
);
9737 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
9739 "PeekMessageA should have returned FALSE instead of msg %04x\n",
9741 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
9743 qstatus
= GetQueueStatus(qs_all_input
);
9745 "wrong qstatus %08x\n", qstatus
);
9747 /* test whether presence of the quit flag in the queue affects
9750 PostQuitMessage(0x1234abcd);
9752 qstatus
= GetQueueStatus(qs_all_input
);
9753 ok(qstatus
== MAKELONG(QS_POSTMESSAGE
, QS_POSTMESSAGE
),
9754 "wrong qstatus %08x\n", qstatus
);
9756 PostMessageA(info
.hwnd
, WM_USER
, 0, 0);
9758 qstatus
= GetQueueStatus(qs_all_input
);
9759 ok(qstatus
== MAKELONG(QS_POSTMESSAGE
, QS_POSTMESSAGE
),
9760 "wrong qstatus %08x\n", qstatus
);
9763 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
9764 ok(ret
&& msg
.message
== WM_USER
,
9765 "got %d and %04x instead of TRUE and WM_USER\n", ret
, msg
.message
);
9766 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
9768 qstatus
= GetQueueStatus(qs_all_input
);
9769 ok(qstatus
== MAKELONG(0, QS_POSTMESSAGE
),
9770 "wrong qstatus %08x\n", qstatus
);
9773 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
9774 ok(ret
&& msg
.message
== WM_QUIT
,
9775 "got %d and %04x instead of TRUE and WM_QUIT\n", ret
, msg
.message
);
9776 ok(msg
.wParam
== 0x1234abcd, "got wParam %08lx instead of 0x1234abcd\n", msg
.wParam
);
9777 ok(msg
.lParam
== 0, "got lParam %08lx instead of 0\n", msg
.lParam
);
9778 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
9780 qstatus
= GetQueueStatus(qs_all_input
);
9782 ok(qstatus
== MAKELONG(0, QS_POSTMESSAGE
),
9783 "wrong qstatus %08x\n", qstatus
);
9787 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
9789 "PeekMessageA should have returned FALSE instead of msg %04x\n",
9791 ok_sequence(WmEmptySeq
, "WmEmptySeq", FALSE
);
9793 qstatus
= GetQueueStatus(qs_all_input
);
9795 "wrong qstatus %08x\n", qstatus
);
9797 /* some GetMessage tests */
9799 keybd_event('N', 0, 0, 0);
9800 qstatus
= GetQueueStatus(qs_all_input
);
9801 ok(qstatus
== MAKELONG(QS_KEY
, QS_KEY
), "wrong qstatus %08x\n", qstatus
);
9803 PostMessageA(info
.hwnd
, WM_CHAR
, 'z', 0);
9804 qstatus
= GetQueueStatus(qs_all_input
);
9805 ok(qstatus
== MAKELONG(QS_POSTMESSAGE
, QS_POSTMESSAGE
|QS_KEY
), "wrong qstatus %08x\n", qstatus
);
9809 ret
= GetMessageA( &msg
, 0, 0, 0 );
9810 ok(ret
&& msg
.message
== WM_CHAR
&& msg
.wParam
== 'z',
9811 "got %d and %04x wParam %08lx instead of TRUE and WM_CHAR wParam 'z'\n",
9812 ret
, msg
.message
, msg
.wParam
);
9813 qstatus
= GetQueueStatus(qs_all_input
);
9814 ok(qstatus
== MAKELONG(0, QS_KEY
), "wrong qstatus %08x\n", qstatus
);
9819 ret
= GetMessageA( &msg
, 0, 0, 0 );
9820 ok(ret
&& msg
.message
== WM_KEYDOWN
&& msg
.wParam
== 'N',
9821 "got %d and %04x wParam %08lx instead of TRUE and WM_KEYDOWN wParam 'N'\n",
9822 ret
, msg
.message
, msg
.wParam
);
9823 ok_sequence(WmKeyDownSkippedSeq
, "WmKeyDownSkippedSeq", FALSE
);
9824 qstatus
= GetQueueStatus(qs_all_input
);
9825 ok(qstatus
== 0, "wrong qstatus %08x\n", qstatus
);
9828 keybd_event('N', 0, 0, 0);
9829 qstatus
= GetQueueStatus(qs_all_input
);
9830 ok(qstatus
== MAKELONG(QS_KEY
, QS_KEY
), "wrong qstatus %08x\n", qstatus
);
9832 PostMessageA(info
.hwnd
, WM_CHAR
, 'z', 0);
9833 qstatus
= GetQueueStatus(qs_all_input
);
9834 ok(qstatus
== MAKELONG(QS_POSTMESSAGE
, QS_POSTMESSAGE
|QS_KEY
), "wrong qstatus %08x\n", qstatus
);
9836 if (qstatus
& (QS_KEY
<< 16))
9838 ret
= GetMessageA( &msg
, 0, WM_KEYDOWN
, WM_KEYUP
);
9839 ok(ret
&& msg
.message
== WM_KEYDOWN
&& msg
.wParam
== 'N',
9840 "got %d and %04x wParam %08lx instead of TRUE and WM_KEYDOWN wParam 'N'\n",
9841 ret
, msg
.message
, msg
.wParam
);
9842 ok_sequence(WmKeyDownWasDownSkippedSeq
, "WmKeyDownWasDownSkippedSeq", FALSE
);
9843 qstatus
= GetQueueStatus(qs_all_input
);
9844 ok(qstatus
== MAKELONG(0, QS_POSTMESSAGE
), "wrong qstatus %08x\n", qstatus
);
9849 ret
= GetMessageA( &msg
, 0, WM_CHAR
, WM_CHAR
);
9850 ok(ret
&& msg
.message
== WM_CHAR
&& msg
.wParam
== 'z',
9851 "got %d and %04x wParam %08lx instead of TRUE and WM_CHAR wParam 'z'\n",
9852 ret
, msg
.message
, msg
.wParam
);
9853 qstatus
= GetQueueStatus(qs_all_input
);
9854 ok(qstatus
== 0, "wrong qstatus %08x\n", qstatus
);
9857 keybd_event('N', 0, KEYEVENTF_KEYUP
, 0);
9858 qstatus
= GetQueueStatus(qs_all_input
);
9859 ok(qstatus
== MAKELONG(QS_KEY
, QS_KEY
), "wrong qstatus %08x\n", qstatus
);
9861 PostMessageA(info
.hwnd
, WM_CHAR
, 'z', 0);
9862 qstatus
= GetQueueStatus(qs_all_input
);
9863 ok(qstatus
== MAKELONG(QS_POSTMESSAGE
, QS_POSTMESSAGE
|QS_KEY
), "wrong qstatus %08x\n", qstatus
);
9865 trace("signalling to send message\n");
9866 SetEvent(info
.hevent
[EV_SENDMSG
]);
9867 WaitForSingleObject(info
.hevent
[EV_ACK
], INFINITE
);
9868 qstatus
= GetQueueStatus(qs_all_input
);
9869 ok(qstatus
== MAKELONG(QS_SENDMESSAGE
, QS_SENDMESSAGE
|QS_POSTMESSAGE
|QS_KEY
),
9870 "wrong qstatus %08x\n", qstatus
);
9872 if (qstatus
& (QS_KEY
<< 16))
9874 ret
= GetMessageA( &msg
, 0, WM_KEYDOWN
, WM_KEYUP
);
9875 ok(ret
&& msg
.message
== WM_KEYUP
&& msg
.wParam
== 'N',
9876 "got %d and %04x wParam %08lx instead of TRUE and WM_KEYDOWN wParam 'N'\n",
9877 ret
, msg
.message
, msg
.wParam
);
9878 ok_sequence(WmUserKeyUpSkippedSeq
, "WmUserKeyUpSkippedSeq", FALSE
);
9879 qstatus
= GetQueueStatus(qs_all_input
);
9880 ok(qstatus
== MAKELONG(0, QS_POSTMESSAGE
), "wrong qstatus %08x\n", qstatus
);
9885 ret
= GetMessageA( &msg
, 0, WM_CHAR
, WM_CHAR
);
9886 ok(ret
&& msg
.message
== WM_CHAR
&& msg
.wParam
== 'z',
9887 "got %d and %04x wParam %08lx instead of TRUE and WM_CHAR wParam 'z'\n",
9888 ret
, msg
.message
, msg
.wParam
);
9889 qstatus
= GetQueueStatus(qs_all_input
);
9890 ok(qstatus
== 0, "wrong qstatus %08x\n", qstatus
);
9893 trace("signalling to exit\n");
9894 SetEvent(info
.hevent
[EV_STOP
]);
9896 WaitForSingleObject(hthread
, INFINITE
);
9898 CloseHandle(hthread
);
9899 CloseHandle(info
.hevent
[0]);
9900 CloseHandle(info
.hevent
[1]);
9901 CloseHandle(info
.hevent
[2]);
9903 DestroyWindow(info
.hwnd
);
9906 static void wait_move_event(HWND hwnd
, int x
, int y
)
9913 time
= GetTickCount();
9914 while (GetTickCount() - time
< 200 && !go
) {
9915 ret
= PeekMessageA(&msg
, hwnd
, WM_MOUSEMOVE
, WM_MOUSEMOVE
, PM_NOREMOVE
);
9916 go
= ret
&& msg
.pt
.x
> x
&& msg
.pt
.y
> y
;
9917 if (!ret
) MsgWaitForMultipleObjects( 0, NULL
, FALSE
, GetTickCount() - time
, QS_ALLINPUT
);
9922 static void test_PeekMessage2(void)
9928 DWORD time1
, time2
, time3
;
9929 int x1
, y1
, x2
, y2
, x3
, y3
;
9932 time1
= time2
= time3
= 0;
9933 x1
= y1
= x2
= y2
= x3
= y3
= 0;
9935 /* Initialise window and make sure it is ready for events */
9936 hwnd
= CreateWindow("TestWindowClass", "PeekMessage2", WS_OVERLAPPEDWINDOW
,
9937 10, 10, 800, 800, NULL
, NULL
, NULL
, NULL
);
9939 trace("Window for test_PeekMessage2 %p\n", hwnd
);
9940 ShowWindow(hwnd
, SW_SHOW
);
9944 SetCursorPos(100, 100);
9945 mouse_event(MOUSEEVENTF_MOVE
, -STEP
, -STEP
, 0, 0);
9948 /* Do initial mousemove, wait until we can see it
9949 and then do our test peek with PM_NOREMOVE. */
9950 mouse_event(MOUSEEVENTF_MOVE
, STEP
, STEP
, 0, 0);
9951 wait_move_event(hwnd
, 100-STEP
, 100-STEP
);
9953 ret
= PeekMessageA(&msg
, hwnd
, WM_MOUSEMOVE
, WM_MOUSEMOVE
, PM_NOREMOVE
);
9956 skip( "queuing mouse events not supported\n" );
9961 trace("1st move event: %04x %x %d %d\n", msg
.message
, msg
.time
, msg
.pt
.x
, msg
.pt
.y
);
9962 message
= msg
.message
;
9966 ok(message
== WM_MOUSEMOVE
, "message not WM_MOUSEMOVE, %04x instead\n", message
);
9969 /* Allow time to advance a bit, and then simulate the user moving their
9970 * mouse around. After that we peek again with PM_NOREMOVE.
9971 * Although the previous mousemove message was never removed, the
9972 * mousemove we now peek should reflect the recent mouse movements
9973 * because the input queue will merge the move events. */
9975 mouse_event(MOUSEEVENTF_MOVE
, STEP
, STEP
, 0, 0);
9976 wait_move_event(hwnd
, x1
, y1
);
9978 ret
= PeekMessageA(&msg
, hwnd
, WM_MOUSEMOVE
, WM_MOUSEMOVE
, PM_NOREMOVE
);
9979 ok(ret
, "no message available\n");
9981 trace("2nd move event: %04x %x %d %d\n", msg
.message
, msg
.time
, msg
.pt
.x
, msg
.pt
.y
);
9982 message
= msg
.message
;
9986 ok(message
== WM_MOUSEMOVE
, "message not WM_MOUSEMOVE, %04x instead\n", message
);
9987 ok(time2
> time1
, "message time not advanced: %x %x\n", time1
, time2
);
9988 ok(x2
!= x1
&& y2
!= y1
, "coords not changed: (%d %d) (%d %d)\n", x1
, y1
, x2
, y2
);
9991 /* Have another go, to drive the point home */
9993 mouse_event(MOUSEEVENTF_MOVE
, STEP
, STEP
, 0, 0);
9994 wait_move_event(hwnd
, x2
, y2
);
9996 ret
= PeekMessageA(&msg
, hwnd
, WM_MOUSEMOVE
, WM_MOUSEMOVE
, PM_NOREMOVE
);
9997 ok(ret
, "no message available\n");
9999 trace("3rd move event: %04x %x %d %d\n", msg
.message
, msg
.time
, msg
.pt
.x
, msg
.pt
.y
);
10000 message
= msg
.message
;
10004 ok(message
== WM_MOUSEMOVE
, "message not WM_MOUSEMOVE, %04x instead\n", message
);
10005 ok(time3
> time2
, "message time not advanced: %x %x\n", time2
, time3
);
10006 ok(x3
!= x2
&& y3
!= y2
, "coords not changed: (%d %d) (%d %d)\n", x2
, y2
, x3
, y3
);
10010 DestroyWindow(hwnd
);
10011 SetCursorPos(pos
.x
, pos
.y
);
10015 static void test_quit_message(void)
10020 /* test using PostQuitMessage */
10022 PostQuitMessage(0xbeef);
10024 ret
= PeekMessage(&msg
, NULL
, 0, 0, PM_NOREMOVE
);
10025 ok(ret
, "PeekMessage failed with error %d\n", GetLastError());
10026 ok(msg
.message
== WM_QUIT
, "Received message 0x%04x instead of WM_QUIT\n", msg
.message
);
10027 ok(msg
.wParam
== 0xbeef, "wParam was 0x%lx instead of 0xbeef\n", msg
.wParam
);
10029 ret
= PostThreadMessage(GetCurrentThreadId(), WM_USER
, 0, 0);
10030 ok(ret
, "PostMessage failed with error %d\n", GetLastError());
10032 ret
= GetMessage(&msg
, NULL
, 0, 0);
10033 ok(ret
> 0, "GetMessage failed with error %d\n", GetLastError());
10034 ok(msg
.message
== WM_USER
, "Received message 0x%04x instead of WM_USER\n", msg
.message
);
10036 /* note: WM_QUIT message received after WM_USER message */
10037 ret
= GetMessage(&msg
, NULL
, 0, 0);
10038 ok(!ret
, "GetMessage return %d with error %d instead of FALSE\n", ret
, GetLastError());
10039 ok(msg
.message
== WM_QUIT
, "Received message 0x%04x instead of WM_QUIT\n", msg
.message
);
10040 ok(msg
.wParam
== 0xbeef, "wParam was 0x%lx instead of 0xbeef\n", msg
.wParam
);
10042 ret
= PeekMessage(&msg
, NULL
, 0, 0, PM_REMOVE
);
10043 ok( !ret
|| msg
.message
!= WM_QUIT
, "Received WM_QUIT again\n" );
10045 /* now test with PostThreadMessage - different behaviour! */
10046 PostThreadMessage(GetCurrentThreadId(), WM_QUIT
, 0xdead, 0);
10048 ret
= PeekMessage(&msg
, NULL
, 0, 0, PM_NOREMOVE
);
10049 ok(ret
, "PeekMessage failed with error %d\n", GetLastError());
10050 ok(msg
.message
== WM_QUIT
, "Received message 0x%04x instead of WM_QUIT\n", msg
.message
);
10051 ok(msg
.wParam
== 0xdead, "wParam was 0x%lx instead of 0xdead\n", msg
.wParam
);
10053 ret
= PostThreadMessage(GetCurrentThreadId(), WM_USER
, 0, 0);
10054 ok(ret
, "PostMessage failed with error %d\n", GetLastError());
10056 /* note: we receive the WM_QUIT message first this time */
10057 ret
= GetMessage(&msg
, NULL
, 0, 0);
10058 ok(!ret
, "GetMessage return %d with error %d instead of FALSE\n", ret
, GetLastError());
10059 ok(msg
.message
== WM_QUIT
, "Received message 0x%04x instead of WM_QUIT\n", msg
.message
);
10060 ok(msg
.wParam
== 0xdead, "wParam was 0x%lx instead of 0xdead\n", msg
.wParam
);
10062 ret
= GetMessage(&msg
, NULL
, 0, 0);
10063 ok(ret
> 0, "GetMessage failed with error %d\n", GetLastError());
10064 ok(msg
.message
== WM_USER
, "Received message 0x%04x instead of WM_USER\n", msg
.message
);
10067 static const struct message WmMouseHoverSeq
[] = {
10068 { WM_MOUSEACTIVATE
, sent
|optional
}, /* we can get those when moving the mouse in focus-follow-mouse mode under X11 */
10069 { WM_MOUSEACTIVATE
, sent
|optional
},
10070 { WM_TIMER
, sent
|optional
}, /* XP sends it */
10071 { WM_SYSTIMER
, sent
},
10072 { WM_MOUSEHOVER
, sent
|wparam
, 0 },
10076 static void pump_msg_loop_timeout(DWORD timeout
, BOOL inject_mouse_move
)
10079 DWORD start_ticks
, end_ticks
;
10081 start_ticks
= GetTickCount();
10082 /* add some deviation (50%) to cover not expected delays */
10083 start_ticks
+= timeout
/ 2;
10087 while (PeekMessage(&msg
, 0, 0, 0, PM_REMOVE
))
10089 /* Timer proc messages are not dispatched to the window proc,
10090 * and therefore not logged.
10092 if ((msg
.message
== WM_TIMER
|| msg
.message
== WM_SYSTIMER
) && msg
.hwnd
)
10094 struct recvd_message s_msg
;
10096 s_msg
.hwnd
= msg
.hwnd
;
10097 s_msg
.message
= msg
.message
;
10098 s_msg
.flags
= sent
|wparam
|lparam
;
10099 s_msg
.wParam
= msg
.wParam
;
10100 s_msg
.lParam
= msg
.lParam
;
10101 s_msg
.descr
= "msg_loop";
10102 add_message(&s_msg
);
10104 DispatchMessage(&msg
);
10107 end_ticks
= GetTickCount();
10109 /* inject WM_MOUSEMOVE to see how it changes tracking */
10110 if (inject_mouse_move
&& start_ticks
+ timeout
/ 2 >= end_ticks
)
10112 mouse_event(MOUSEEVENTF_MOVE
, -1, 0, 0, 0);
10113 mouse_event(MOUSEEVENTF_MOVE
, 1, 0, 0, 0);
10115 inject_mouse_move
= FALSE
;
10117 } while (start_ticks
+ timeout
>= end_ticks
);
10120 static void test_TrackMouseEvent(void)
10122 TRACKMOUSEEVENT tme
;
10125 RECT rc_parent
, rc_child
;
10126 UINT default_hover_time
, hover_width
= 0, hover_height
= 0;
10128 #define track_hover(track_hwnd, track_hover_time) \
10129 tme.cbSize = sizeof(tme); \
10130 tme.dwFlags = TME_HOVER; \
10131 tme.hwndTrack = track_hwnd; \
10132 tme.dwHoverTime = track_hover_time; \
10133 SetLastError(0xdeadbeef); \
10134 ret = pTrackMouseEvent(&tme); \
10135 ok(ret, "TrackMouseEvent(TME_HOVER) error %d\n", GetLastError())
10137 #define track_query(expected_track_flags, expected_track_hwnd, expected_hover_time) \
10138 tme.cbSize = sizeof(tme); \
10139 tme.dwFlags = TME_QUERY; \
10140 tme.hwndTrack = (HWND)0xdeadbeef; \
10141 tme.dwHoverTime = 0xdeadbeef; \
10142 SetLastError(0xdeadbeef); \
10143 ret = pTrackMouseEvent(&tme); \
10144 ok(ret, "TrackMouseEvent(TME_QUERY) error %d\n", GetLastError());\
10145 ok(tme.cbSize == sizeof(tme), "wrong tme.cbSize %u\n", tme.cbSize); \
10146 ok(tme.dwFlags == (expected_track_flags), \
10147 "wrong tme.dwFlags %08x, expected %08x\n", tme.dwFlags, (expected_track_flags)); \
10148 ok(tme.hwndTrack == (expected_track_hwnd), \
10149 "wrong tme.hwndTrack %p, expected %p\n", tme.hwndTrack, (expected_track_hwnd)); \
10150 ok(tme.dwHoverTime == (expected_hover_time), \
10151 "wrong tme.dwHoverTime %u, expected %u\n", tme.dwHoverTime, (expected_hover_time))
10153 #define track_hover_cancel(track_hwnd) \
10154 tme.cbSize = sizeof(tme); \
10155 tme.dwFlags = TME_HOVER | TME_CANCEL; \
10156 tme.hwndTrack = track_hwnd; \
10157 tme.dwHoverTime = 0xdeadbeef; \
10158 SetLastError(0xdeadbeef); \
10159 ret = pTrackMouseEvent(&tme); \
10160 ok(ret, "TrackMouseEvent(TME_HOVER | TME_CANCEL) error %d\n", GetLastError())
10162 default_hover_time
= 0xdeadbeef;
10163 SetLastError(0xdeadbeef);
10164 ret
= SystemParametersInfo(SPI_GETMOUSEHOVERTIME
, 0, &default_hover_time
, 0);
10165 ok(ret
|| broken(GetLastError() == 0xdeadbeef), /* win9x */
10166 "SystemParametersInfo(SPI_GETMOUSEHOVERTIME) error %u\n", GetLastError());
10167 if (!ret
) default_hover_time
= 400;
10168 trace("SPI_GETMOUSEHOVERTIME returned %u ms\n", default_hover_time
);
10170 SetLastError(0xdeadbeef);
10171 ret
= SystemParametersInfo(SPI_GETMOUSEHOVERWIDTH
, 0, &hover_width
, 0);
10172 ok(ret
|| broken(GetLastError() == 0xdeadbeef), /* win9x */
10173 "SystemParametersInfo(SPI_GETMOUSEHOVERWIDTH) error %u\n", GetLastError());
10174 if (!ret
) hover_width
= 4;
10175 SetLastError(0xdeadbeef);
10176 ret
= SystemParametersInfo(SPI_GETMOUSEHOVERHEIGHT
, 0, &hover_height
, 0);
10177 ok(ret
|| broken(GetLastError() == 0xdeadbeef), /* win9x */
10178 "SystemParametersInfo(SPI_GETMOUSEHOVERHEIGHT) error %u\n", GetLastError());
10179 if (!ret
) hover_height
= 4;
10180 trace("hover rect is %u x %d\n", hover_width
, hover_height
);
10182 hwnd
= CreateWindowEx(0, "TestWindowClass", NULL
,
10183 WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
10184 CW_USEDEFAULT
, CW_USEDEFAULT
, 300, 300, 0,
10188 hchild
= CreateWindowEx(0, "TestWindowClass", NULL
,
10189 WS_CHILD
| WS_BORDER
| WS_VISIBLE
,
10190 50, 50, 200, 200, hwnd
,
10194 SetWindowPos( hwnd
, HWND_TOPMOST
, 0, 0, 0, 0, SWP_NOSIZE
|SWP_NOMOVE
);
10199 tme
.dwFlags
= TME_QUERY
;
10200 tme
.hwndTrack
= (HWND
)0xdeadbeef;
10201 tme
.dwHoverTime
= 0xdeadbeef;
10202 SetLastError(0xdeadbeef);
10203 ret
= pTrackMouseEvent(&tme
);
10204 ok(!ret
, "TrackMouseEvent should fail\n");
10205 ok(GetLastError() == ERROR_INVALID_PARAMETER
|| broken(GetLastError() == 0xdeadbeef),
10206 "not expected error %u\n", GetLastError());
10208 tme
.cbSize
= sizeof(tme
);
10209 tme
.dwFlags
= TME_HOVER
;
10210 tme
.hwndTrack
= (HWND
)0xdeadbeef;
10211 tme
.dwHoverTime
= 0xdeadbeef;
10212 SetLastError(0xdeadbeef);
10213 ret
= pTrackMouseEvent(&tme
);
10214 ok(!ret
, "TrackMouseEvent should fail\n");
10215 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
|| broken(GetLastError() == 0xdeadbeef),
10216 "not expected error %u\n", GetLastError());
10218 tme
.cbSize
= sizeof(tme
);
10219 tme
.dwFlags
= TME_HOVER
| TME_CANCEL
;
10220 tme
.hwndTrack
= (HWND
)0xdeadbeef;
10221 tme
.dwHoverTime
= 0xdeadbeef;
10222 SetLastError(0xdeadbeef);
10223 ret
= pTrackMouseEvent(&tme
);
10224 ok(!ret
, "TrackMouseEvent should fail\n");
10225 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
|| broken(GetLastError() == 0xdeadbeef),
10226 "not expected error %u\n", GetLastError());
10228 GetWindowRect(hwnd
, &rc_parent
);
10229 GetWindowRect(hchild
, &rc_child
);
10230 SetCursorPos(rc_child
.left
- 10, rc_child
.top
- 10);
10232 /* Process messages so that the system updates its internal current
10233 * window and hittest, otherwise TrackMouseEvent calls don't have any
10239 track_query(0, NULL
, 0);
10240 track_hover(hchild
, 0);
10241 track_query(0, NULL
, 0);
10246 track_hover(hwnd
, 0);
10247 tme
.cbSize
= sizeof(tme
);
10248 tme
.dwFlags
= TME_QUERY
;
10249 tme
.hwndTrack
= (HWND
)0xdeadbeef;
10250 tme
.dwHoverTime
= 0xdeadbeef;
10251 SetLastError(0xdeadbeef);
10252 ret
= pTrackMouseEvent(&tme
);
10253 ok(ret
, "TrackMouseEvent(TME_QUERY) error %d\n", GetLastError());
10254 ok(tme
.cbSize
== sizeof(tme
), "wrong tme.cbSize %u\n", tme
.cbSize
);
10257 skip( "Cursor not inside window, skipping TrackMouseEvent tests\n" );
10258 DestroyWindow( hwnd
);
10261 ok(tme
.dwFlags
== TME_HOVER
, "wrong tme.dwFlags %08x, expected TME_HOVER\n", tme
.dwFlags
);
10262 ok(tme
.hwndTrack
== hwnd
, "wrong tme.hwndTrack %p, expected %p\n", tme
.hwndTrack
, hwnd
);
10263 ok(tme
.dwHoverTime
== default_hover_time
, "wrong tme.dwHoverTime %u, expected %u\n",
10264 tme
.dwHoverTime
, default_hover_time
);
10266 pump_msg_loop_timeout(default_hover_time
, FALSE
);
10267 ok_sequence(WmMouseHoverSeq
, "WmMouseHoverSeq", FALSE
);
10269 track_query(0, NULL
, 0);
10271 track_hover(hwnd
, HOVER_DEFAULT
);
10272 track_query(TME_HOVER
, hwnd
, default_hover_time
);
10274 Sleep(default_hover_time
/ 2);
10275 mouse_event(MOUSEEVENTF_MOVE
, -1, 0, 0, 0);
10276 mouse_event(MOUSEEVENTF_MOVE
, 1, 0, 0, 0);
10278 track_query(TME_HOVER
, hwnd
, default_hover_time
);
10280 pump_msg_loop_timeout(default_hover_time
, FALSE
);
10281 ok_sequence(WmMouseHoverSeq
, "WmMouseHoverSeq", FALSE
);
10283 track_query(0, NULL
, 0);
10285 track_hover(hwnd
, HOVER_DEFAULT
);
10286 track_query(TME_HOVER
, hwnd
, default_hover_time
);
10288 pump_msg_loop_timeout(default_hover_time
, TRUE
);
10289 ok_sequence(WmMouseHoverSeq
, "WmMouseHoverSeq", FALSE
);
10291 track_query(0, NULL
, 0);
10293 track_hover(hwnd
, HOVER_DEFAULT
);
10294 track_query(TME_HOVER
, hwnd
, default_hover_time
);
10295 track_hover_cancel(hwnd
);
10297 DestroyWindow(hwnd
);
10301 #undef track_hover_cancel
10305 static const struct message WmSetWindowRgn
[] = {
10306 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
},
10307 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
10308 { WM_NCPAINT
, sent
|optional
}, /* wparam != 1 */
10309 { WM_GETTEXT
, sent
|defwinproc
|optional
},
10310 { WM_ERASEBKGND
, sent
|optional
},
10311 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
},
10312 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
10316 static const struct message WmSetWindowRgn_no_redraw
[] = {
10317 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
},
10318 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
10319 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
},
10320 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
10324 static const struct message WmSetWindowRgn_clear
[] = {
10325 { WM_WINDOWPOSCHANGING
, sent
/*|wparam*/, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
/*|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE only on some Windows versions */ },
10326 { WM_NCCALCSIZE
, sent
|wparam
, 1 },
10327 { WM_NCPAINT
, sent
|optional
},
10328 { WM_GETTEXT
, sent
|defwinproc
|optional
},
10329 { WM_ERASEBKGND
, sent
|optional
}, /* FIXME: remove optional once Wine is fixed */
10330 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
},
10331 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
10332 { WM_NCPAINT
, sent
|optional
},
10333 { WM_GETTEXT
, sent
|defwinproc
|optional
},
10334 { WM_ERASEBKGND
, sent
|optional
},
10335 { WM_WINDOWPOSCHANGING
, sent
|optional
},
10336 { WM_NCCALCSIZE
, sent
|optional
|wparam
, 1 },
10337 { WM_NCPAINT
, sent
|optional
},
10338 { WM_GETTEXT
, sent
|defwinproc
|optional
},
10339 { WM_ERASEBKGND
, sent
|optional
},
10340 { WM_WINDOWPOSCHANGED
, sent
|optional
|wparam
, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOSIZE
|SWP_NOMOVE
},
10341 { WM_NCCALCSIZE
, sent
|optional
|wparam
, 1 },
10342 { WM_NCPAINT
, sent
|optional
},
10343 { WM_GETTEXT
, sent
|defwinproc
|optional
},
10344 { WM_ERASEBKGND
, sent
|optional
},
10345 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
10346 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, 0, 0 },
10350 static void test_SetWindowRgn(void)
10353 HWND hwnd
= CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW
,
10354 100, 100, 200, 200, 0, 0, 0, NULL
);
10355 ok( hwnd
!= 0, "Failed to create overlapped window\n" );
10357 ShowWindow( hwnd
, SW_SHOW
);
10358 UpdateWindow( hwnd
);
10362 trace("testing SetWindowRgn\n");
10363 hrgn
= CreateRectRgn( 0, 0, 150, 150 );
10364 SetWindowRgn( hwnd
, hrgn
, TRUE
);
10365 ok_sequence( WmSetWindowRgn
, "WmSetWindowRgn", FALSE
);
10367 hrgn
= CreateRectRgn( 30, 30, 160, 160 );
10368 SetWindowRgn( hwnd
, hrgn
, FALSE
);
10369 ok_sequence( WmSetWindowRgn_no_redraw
, "WmSetWindowRgn_no_redraw", FALSE
);
10371 hrgn
= CreateRectRgn( 0, 0, 180, 180 );
10372 SetWindowRgn( hwnd
, hrgn
, TRUE
);
10373 ok_sequence( WmSetWindowRgn
, "WmSetWindowRgn2", FALSE
);
10375 SetWindowRgn( hwnd
, 0, TRUE
);
10376 ok_sequence( WmSetWindowRgn_clear
, "WmSetWindowRgn_clear", FALSE
);
10378 DestroyWindow( hwnd
);
10381 /*************************** ShowWindow() test ******************************/
10382 static const struct message WmShowNormal
[] = {
10383 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
10384 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
10385 { HCBT_ACTIVATE
, hook
},
10386 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2003 doesn't send it */
10387 { HCBT_SETFOCUS
, hook
},
10388 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
10391 static const struct message WmShow
[] = {
10392 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
10393 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
10394 { HCBT_ACTIVATE
, hook
|optional
}, /* win2000 doesn't send it */
10395 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2000 doesn't send it */
10396 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 doesn't send it */
10397 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
10400 static const struct message WmShowNoActivate_1
[] = {
10401 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWNOACTIVATE
},
10402 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_STATECHANGED
, 0, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOSIZE
|SWP_NOMOVE
},
10403 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_STATECHANGED
, 0, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOSIZE
|SWP_NOMOVE
},
10404 { WM_MOVE
, sent
|defwinproc
|optional
},
10405 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_RESTORED
},
10408 static const struct message WmShowNoActivate_2
[] = {
10409 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWNOACTIVATE
},
10410 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
10411 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
10412 { WM_MOVE
, sent
|defwinproc
},
10413 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_RESTORED
},
10414 { HCBT_SETFOCUS
, hook
|optional
},
10415 { HCBT_ACTIVATE
, hook
|optional
}, /* win2003 doesn't send it */
10416 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2003 doesn't send it */
10417 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
10418 { HCBT_SETFOCUS
, hook
|optional
}, /* win2003 doesn't send it */
10421 static const struct message WmShowNA_1
[] = {
10422 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
10423 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
10424 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
10427 static const struct message WmShowNA_2
[] = {
10428 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
10429 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
},
10430 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
10433 static const struct message WmRestore_1
[] = {
10434 { HCBT_MINMAX
, hook
|lparam
, 0, SW_RESTORE
},
10435 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
10436 { HCBT_ACTIVATE
, hook
|optional
}, /* win2000 doesn't send it */
10437 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2000 doesn't send it */
10438 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 doesn't send it */
10439 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
10440 { WM_MOVE
, sent
|defwinproc
},
10441 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_RESTORED
},
10442 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 sends it */
10445 static const struct message WmRestore_2
[] = {
10446 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
10447 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
10448 { HCBT_ACTIVATE
, hook
|optional
}, /* win2000 doesn't send it */
10449 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2000 doesn't send it */
10450 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 doesn't send it */
10451 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
10454 static const struct message WmRestore_3
[] = {
10455 { HCBT_MINMAX
, hook
|lparam
, 0, SW_RESTORE
},
10456 { WM_GETMINMAXINFO
, sent
},
10457 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
10458 { HCBT_ACTIVATE
, hook
|optional
}, /* win2003 doesn't send it */
10459 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2003 doesn't send it */
10460 { HCBT_SETFOCUS
, hook
|optional
}, /* win2003 doesn't send it */
10461 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
10462 { WM_MOVE
, sent
|defwinproc
},
10463 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_MAXIMIZED
},
10464 { HCBT_SETFOCUS
, hook
|optional
}, /* win2003 sends it */
10467 static const struct message WmRestore_4
[] = {
10468 { HCBT_MINMAX
, hook
|lparam
|optional
, 0, SW_RESTORE
},
10469 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_FRAMECHANGED
|SWP_STATECHANGED
, 0, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOSIZE
|SWP_NOMOVE
},
10470 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_FRAMECHANGED
|SWP_STATECHANGED
, 0, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOSIZE
|SWP_NOMOVE
},
10471 { WM_MOVE
, sent
|defwinproc
|optional
},
10472 { WM_SIZE
, sent
|wparam
|defwinproc
|optional
, SIZE_RESTORED
},
10475 static const struct message WmRestore_5
[] = {
10476 { HCBT_MINMAX
, hook
|lparam
|optional
, 0, SW_SHOWNORMAL
},
10477 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_FRAMECHANGED
|SWP_STATECHANGED
, 0, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOSIZE
|SWP_NOMOVE
},
10478 { HCBT_ACTIVATE
, hook
|optional
},
10479 { HCBT_SETFOCUS
, hook
|optional
},
10480 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_FRAMECHANGED
|SWP_STATECHANGED
, 0, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOSIZE
|SWP_NOMOVE
},
10481 { WM_MOVE
, sent
|defwinproc
|optional
},
10482 { WM_SIZE
, sent
|wparam
|defwinproc
|optional
, SIZE_RESTORED
},
10485 static const struct message WmHide_1
[] = {
10486 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
10487 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
, 0, SWP_NOACTIVATE
},
10488 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
, 0, SWP_NOACTIVATE
},
10489 { HCBT_ACTIVATE
, hook
|optional
},
10490 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 sends it */
10493 static const struct message WmHide_2
[] = {
10494 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
10495 { WM_WINDOWPOSCHANGING
, sent
/*|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE*/ }, /* win2000 doesn't add SWP_NOACTIVATE */
10496 { WM_WINDOWPOSCHANGED
, sent
/*|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE*/ }, /* win2000 doesn't add SWP_NOACTIVATE */
10497 { HCBT_ACTIVATE
, hook
|optional
},
10500 static const struct message WmHide_3
[] = {
10501 { WM_SHOWWINDOW
, sent
|wparam
, 0 },
10502 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
},
10503 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_HIDEWINDOW
|SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
10504 { HCBT_SETFOCUS
, hook
|optional
},
10505 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
10508 static const struct message WmShowMinimized_1
[] = {
10509 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINIMIZED
},
10510 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
10511 { HCBT_ACTIVATE
, hook
|optional
}, /* win2000 doesn't send it */
10512 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2000 doesn't send it */
10513 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
10514 { WM_MOVE
, sent
|defwinproc
},
10515 { WM_SIZE
, sent
|wparam
|lparam
|defwinproc
, SIZE_MINIMIZED
, 0 },
10518 static const struct message WmMinimize_1
[] = {
10519 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
10520 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 doesn't send it */
10521 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
10522 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
10523 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
10524 { WM_MOVE
, sent
|defwinproc
},
10525 { WM_SIZE
, sent
|wparam
|lparam
|defwinproc
, SIZE_MINIMIZED
, 0 },
10528 static const struct message WmMinimize_2
[] = {
10529 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
10530 { HCBT_SETFOCUS
, hook
|optional
},
10531 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
10532 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
10533 { WM_MOVE
, sent
|defwinproc
},
10534 { WM_SIZE
, sent
|wparam
|lparam
|defwinproc
, SIZE_MINIMIZED
, 0 },
10537 static const struct message WmMinimize_3
[] = {
10538 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
10539 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
10540 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
10541 { WM_MOVE
, sent
|defwinproc
},
10542 { WM_SIZE
, sent
|wparam
|lparam
|defwinproc
, SIZE_MINIMIZED
, 0 },
10545 static const struct message WmShowMinNoActivate
[] = {
10546 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINNOACTIVE
},
10547 { WM_WINDOWPOSCHANGING
, sent
},
10548 { WM_WINDOWPOSCHANGED
, sent
},
10549 { WM_MOVE
, sent
|defwinproc
|optional
},
10550 { WM_SIZE
, sent
|wparam
|lparam
|defwinproc
|optional
, SIZE_MINIMIZED
, 0 },
10553 static const struct message WmMinMax_1
[] = {
10554 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINIMIZED
},
10557 static const struct message WmMinMax_2
[] = {
10558 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMAXIMIZED
},
10559 { WM_GETMINMAXINFO
, sent
|optional
},
10560 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_FRAMECHANGED
|SWP_STATECHANGED
},
10561 { HCBT_ACTIVATE
, hook
|optional
},
10562 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
10563 { HCBT_SETFOCUS
, hook
|optional
},
10564 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_FRAMECHANGED
|SWP_STATECHANGED
, 0, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
10565 { WM_MOVE
, sent
|defwinproc
|optional
},
10566 { WM_SIZE
, sent
|wparam
|defwinproc
|optional
, SIZE_MAXIMIZED
},
10567 { HCBT_SETFOCUS
, hook
|optional
},
10570 static const struct message WmMinMax_3
[] = {
10571 { HCBT_MINMAX
, hook
|lparam
, 0, SW_MINIMIZE
},
10572 { HCBT_SETFOCUS
, hook
|optional
},
10573 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_SHOWWINDOW
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
10574 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
10575 { WM_MOVE
, sent
|defwinproc
|optional
},
10576 { WM_SIZE
, sent
|wparam
|lparam
|defwinproc
|optional
, SIZE_MINIMIZED
, 0 },
10579 static const struct message WmMinMax_4
[] = {
10580 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMINNOACTIVE
},
10583 static const struct message WmShowMaximized_1
[] = {
10584 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMAXIMIZED
},
10585 { WM_GETMINMAXINFO
, sent
},
10586 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
10587 { HCBT_ACTIVATE
, hook
|optional
}, /* win2000 doesn't send it */
10588 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2000 doesn't send it */
10589 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 doesn't send it */
10590 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_SHOWWINDOW
|SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
10591 { WM_MOVE
, sent
|defwinproc
},
10592 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_MAXIMIZED
},
10593 { HCBT_SETFOCUS
, hook
|optional
}, /* win2003 sends it */
10596 static const struct message WmShowMaximized_2
[] = {
10597 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMAXIMIZED
},
10598 { WM_GETMINMAXINFO
, sent
},
10599 { WM_WINDOWPOSCHANGING
, sent
|optional
},
10600 { HCBT_ACTIVATE
, hook
|optional
},
10601 { WM_WINDOWPOSCHANGED
, sent
|optional
},
10602 { WM_MOVE
, sent
|optional
}, /* Win9x doesn't send it */
10603 { WM_SIZE
, sent
|wparam
|optional
, SIZE_MAXIMIZED
}, /* Win9x doesn't send it */
10604 { WM_WINDOWPOSCHANGING
, sent
|optional
},
10605 { HCBT_SETFOCUS
, hook
|optional
},
10606 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_FRAMECHANGED
|SWP_NOCOPYBITS
|SWP_STATECHANGED
},
10607 { WM_MOVE
, sent
|defwinproc
},
10608 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_MAXIMIZED
},
10609 { HCBT_SETFOCUS
, hook
|optional
},
10612 static const struct message WmShowMaximized_3
[] = {
10613 { HCBT_MINMAX
, hook
|lparam
, 0, SW_SHOWMAXIMIZED
},
10614 { WM_GETMINMAXINFO
, sent
|optional
},
10615 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
, 0, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOSIZE
|SWP_NOMOVE
},
10616 { HCBT_ACTIVATE
, hook
|optional
}, /* win2000 doesn't send it */
10617 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
}, /* win2000 doesn't send it */
10618 { HCBT_SETFOCUS
, hook
|optional
}, /* win2000 doesn't send it */
10619 { WM_WINDOWPOSCHANGED
, sent
|wparam
, SWP_FRAMECHANGED
|SWP_STATECHANGED
, 0, SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
|SWP_NOSIZE
|SWP_NOMOVE
},
10620 { WM_MOVE
, sent
|defwinproc
|optional
},
10621 { WM_SIZE
, sent
|wparam
|defwinproc
, SIZE_MAXIMIZED
},
10625 static void test_ShowWindow(void)
10627 /* ShowWindow commands in random order */
10628 static const struct
10630 INT cmd
; /* ShowWindow command */
10631 LPARAM ret
; /* ShowWindow return value */
10632 DWORD style
; /* window style after the command */
10633 const struct message
*msg
; /* message sequence the command produces */
10634 BOOL todo_msg
; /* message sequence doesn't match what Wine does */
10637 /* 1 */ { SW_SHOWNORMAL
, FALSE
, WS_VISIBLE
, WmShowNormal
, FALSE
},
10638 /* 2 */ { SW_SHOWNORMAL
, TRUE
, WS_VISIBLE
, WmEmptySeq
, FALSE
},
10639 /* 3 */ { SW_HIDE
, TRUE
, 0, WmHide_1
, FALSE
},
10640 /* 4 */ { SW_HIDE
, FALSE
, 0, WmEmptySeq
, FALSE
},
10641 /* 5 */ { SW_SHOWMINIMIZED
, FALSE
, WS_VISIBLE
|WS_MINIMIZE
, WmShowMinimized_1
, FALSE
},
10642 /* 6 */ { SW_SHOWMINIMIZED
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinMax_1
, FALSE
},
10643 /* 7 */ { SW_HIDE
, TRUE
, WS_MINIMIZE
, WmHide_1
, FALSE
},
10644 /* 8 */ { SW_HIDE
, FALSE
, WS_MINIMIZE
, WmEmptySeq
, FALSE
},
10645 /* 9 */ { SW_SHOWMAXIMIZED
, FALSE
, WS_VISIBLE
|WS_MAXIMIZE
, WmShowMaximized_1
, FALSE
},
10646 /* 10 */ { SW_SHOWMAXIMIZED
, TRUE
, WS_VISIBLE
|WS_MAXIMIZE
, WmMinMax_2
, FALSE
},
10647 /* 11 */ { SW_HIDE
, TRUE
, WS_MAXIMIZE
, WmHide_1
, FALSE
},
10648 /* 12 */ { SW_HIDE
, FALSE
, WS_MAXIMIZE
, WmEmptySeq
, FALSE
},
10649 /* 13 */ { SW_SHOWNOACTIVATE
, FALSE
, WS_VISIBLE
, WmShowNoActivate_1
, FALSE
},
10650 /* 14 */ { SW_SHOWNOACTIVATE
, TRUE
, WS_VISIBLE
, WmEmptySeq
, FALSE
},
10651 /* 15 */ { SW_HIDE
, TRUE
, 0, WmHide_2
, FALSE
},
10652 /* 16 */ { SW_HIDE
, FALSE
, 0, WmEmptySeq
, FALSE
},
10653 /* 17 */ { SW_SHOW
, FALSE
, WS_VISIBLE
, WmShow
, FALSE
},
10654 /* 18 */ { SW_SHOW
, TRUE
, WS_VISIBLE
, WmEmptySeq
, FALSE
},
10655 /* 19 */ { SW_MINIMIZE
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinimize_1
, FALSE
},
10656 /* 20 */ { SW_MINIMIZE
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinMax_3
, FALSE
},
10657 /* 21 */ { SW_HIDE
, TRUE
, WS_MINIMIZE
, WmHide_2
, FALSE
},
10658 /* 22 */ { SW_SHOWMINNOACTIVE
, FALSE
, WS_VISIBLE
|WS_MINIMIZE
, WmShowMinNoActivate
, TRUE
},
10659 /* 23 */ { SW_SHOWMINNOACTIVE
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinMax_4
, FALSE
},
10660 /* 24 */ { SW_HIDE
, TRUE
, WS_MINIMIZE
, WmHide_2
, FALSE
},
10661 /* 25 */ { SW_HIDE
, FALSE
, WS_MINIMIZE
, WmEmptySeq
, FALSE
},
10662 /* 26 */ { SW_SHOWNA
, FALSE
, WS_VISIBLE
|WS_MINIMIZE
, WmShowNA_1
, FALSE
},
10663 /* 27 */ { SW_SHOWNA
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmShowNA_2
, FALSE
},
10664 /* 28 */ { SW_HIDE
, TRUE
, WS_MINIMIZE
, WmHide_2
, FALSE
},
10665 /* 29 */ { SW_HIDE
, FALSE
, WS_MINIMIZE
, WmEmptySeq
, FALSE
},
10666 /* 30 */ { SW_RESTORE
, FALSE
, WS_VISIBLE
, WmRestore_1
, FALSE
},
10667 /* 31 */ { SW_RESTORE
, TRUE
, WS_VISIBLE
, WmEmptySeq
, FALSE
},
10668 /* 32 */ { SW_HIDE
, TRUE
, 0, WmHide_3
, FALSE
},
10669 /* 33 */ { SW_HIDE
, FALSE
, 0, WmEmptySeq
, FALSE
},
10670 /* 34 */ { SW_NORMALNA
, FALSE
, 0, WmEmptySeq
, FALSE
}, /* what does this mean?! */
10671 /* 35 */ { SW_NORMALNA
, FALSE
, 0, WmEmptySeq
, FALSE
},
10672 /* 36 */ { SW_HIDE
, FALSE
, 0, WmEmptySeq
, FALSE
},
10673 /* 37 */ { SW_RESTORE
, FALSE
, WS_VISIBLE
, WmRestore_2
, FALSE
},
10674 /* 38 */ { SW_RESTORE
, TRUE
, WS_VISIBLE
, WmEmptySeq
, FALSE
},
10675 /* 39 */ { SW_SHOWNOACTIVATE
, TRUE
, WS_VISIBLE
, WmEmptySeq
, FALSE
},
10676 /* 40 */ { SW_MINIMIZE
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinimize_2
, FALSE
},
10677 /* 41 */ { SW_MINIMIZE
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinMax_3
, FALSE
},
10678 /* 42 */ { SW_SHOWMAXIMIZED
, TRUE
, WS_VISIBLE
|WS_MAXIMIZE
, WmShowMaximized_2
, FALSE
},
10679 /* 43 */ { SW_SHOWMAXIMIZED
, TRUE
, WS_VISIBLE
|WS_MAXIMIZE
, WmMinMax_2
, FALSE
},
10680 /* 44 */ { SW_MINIMIZE
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinimize_1
, FALSE
},
10681 /* 45 */ { SW_MINIMIZE
, TRUE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinMax_3
, FALSE
},
10682 /* 46 */ { SW_RESTORE
, TRUE
, WS_VISIBLE
|WS_MAXIMIZE
, WmRestore_3
, FALSE
},
10683 /* 47 */ { SW_RESTORE
, TRUE
, WS_VISIBLE
, WmRestore_4
, FALSE
},
10684 /* 48 */ { SW_SHOWMAXIMIZED
, TRUE
, WS_VISIBLE
|WS_MAXIMIZE
, WmShowMaximized_3
, FALSE
},
10685 /* 49 */ { SW_SHOW
, TRUE
, WS_VISIBLE
|WS_MAXIMIZE
, WmEmptySeq
, FALSE
},
10686 /* 50 */ { SW_SHOWNORMAL
, TRUE
, WS_VISIBLE
, WmRestore_5
, FALSE
},
10687 /* 51 */ { SW_SHOWNORMAL
, TRUE
, WS_VISIBLE
, WmRestore_5
, FALSE
},
10688 /* 52 */ { SW_HIDE
, TRUE
, 0, WmHide_1
, FALSE
},
10689 /* 53 */ { SW_HIDE
, FALSE
, 0, WmEmptySeq
, FALSE
},
10690 /* 54 */ { SW_MINIMIZE
, FALSE
, WS_VISIBLE
|WS_MINIMIZE
, WmMinimize_3
, FALSE
},
10691 /* 55 */ { SW_HIDE
, TRUE
, WS_MINIMIZE
, WmHide_2
, FALSE
},
10692 /* 56 */ { SW_SHOWNOACTIVATE
, FALSE
, WS_VISIBLE
, WmShowNoActivate_2
, FALSE
},
10693 /* 57 */ { SW_SHOW
, TRUE
, WS_VISIBLE
, WmEmptySeq
, FALSE
}
10700 #define WS_BASE (WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX|WS_MAXIMIZEBOX|WS_POPUP|WS_CLIPSIBLINGS)
10701 hwnd
= CreateWindowEx(0, "ShowWindowClass", NULL
, WS_BASE
,
10706 style
= GetWindowLong(hwnd
, GWL_STYLE
) & ~WS_BASE
;
10707 ok(style
== 0, "expected style 0, got %08x\n", style
);
10712 for (i
= 0; i
< sizeof(sw
)/sizeof(sw
[0]); i
++)
10714 static const char * const sw_cmd_name
[13] =
10716 "SW_HIDE", "SW_SHOWNORMAL", "SW_SHOWMINIMIZED", "SW_SHOWMAXIMIZED",
10717 "SW_SHOWNOACTIVATE", "SW_SHOW", "SW_MINIMIZE", "SW_SHOWMINNOACTIVE",
10718 "SW_SHOWNA", "SW_RESTORE", "SW_SHOWDEFAULT", "SW_FORCEMINIMIZE",
10719 "SW_NORMALNA" /* 0xCC */
10722 INT idx
; /* index into the above array of names */
10724 idx
= (sw
[i
].cmd
== SW_NORMALNA
) ? 12 : sw
[i
].cmd
;
10726 style
= GetWindowLong(hwnd
, GWL_STYLE
);
10727 trace("%d: sending %s, current window style %08x\n", i
+1, sw_cmd_name
[idx
], style
);
10728 ret
= ShowWindow(hwnd
, sw
[i
].cmd
);
10729 ok(!ret
== !sw
[i
].ret
, "%d: cmd %s: expected ret %lu, got %lu\n", i
+1, sw_cmd_name
[idx
], sw
[i
].ret
, ret
);
10730 style
= GetWindowLong(hwnd
, GWL_STYLE
) & ~WS_BASE
;
10731 ok(style
== sw
[i
].style
, "%d: expected style %08x, got %08x\n", i
+1, sw
[i
].style
, style
);
10733 sprintf(comment
, "%d: ShowWindow(%s)", i
+1, sw_cmd_name
[idx
]);
10734 ok_sequence(sw
[i
].msg
, comment
, sw
[i
].todo_msg
);
10740 DestroyWindow(hwnd
);
10743 static INT_PTR WINAPI
test_dlg_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
10745 struct recvd_message msg
;
10747 if (ignore_message( message
)) return 0;
10750 msg
.message
= message
;
10751 msg
.flags
= sent
|wparam
|lparam
;
10752 msg
.wParam
= wParam
;
10753 msg
.lParam
= lParam
;
10754 msg
.descr
= "dialog";
10757 /* calling DefDlgProc leads to a recursion under XP */
10761 case WM_INITDIALOG
:
10762 case WM_GETDLGCODE
:
10768 static const struct message WmDefDlgSetFocus_1
[] = {
10769 { WM_GETDLGCODE
, sent
|wparam
|lparam
, 0, 0 },
10770 { WM_GETTEXTLENGTH
, sent
|wparam
|lparam
|optional
, 0, 0 }, /* XP */
10771 { WM_GETTEXT
, sent
|wparam
|optional
, 6 }, /* XP */
10772 { WM_GETTEXT
, sent
|wparam
|optional
, 12 }, /* XP */
10773 { EM_SETSEL
, sent
|wparam
, 0 }, /* XP sets lparam to text length, Win9x to -2 */
10774 { HCBT_SETFOCUS
, hook
},
10775 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 1 },
10776 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
10777 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
10778 { WM_SETFOCUS
, sent
|wparam
, 0 },
10779 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 10 },
10780 { WM_CTLCOLOREDIT
, sent
},
10781 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 11 },
10782 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
10783 { EVENT_OBJECT_LOCATIONCHANGE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
10784 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
10785 { WM_COMMAND
, sent
|wparam
, MAKEWPARAM(1, EN_SETFOCUS
) },
10788 static const struct message WmDefDlgSetFocus_2
[] = {
10789 { WM_GETDLGCODE
, sent
|wparam
|lparam
, 0, 0 },
10790 { WM_GETTEXTLENGTH
, sent
|wparam
|lparam
|optional
, 0, 0 }, /* XP */
10791 { WM_GETTEXT
, sent
|wparam
|optional
, 6 }, /* XP */
10792 { WM_GETTEXT
, sent
|wparam
|optional
, 12 }, /* XP */
10793 { EM_SETSEL
, sent
|wparam
, 0 }, /* XP sets lparam to text length, Win9x to -2 */
10794 { EVENT_OBJECT_HIDE
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
10795 { WM_CTLCOLOREDIT
, sent
|optional
}, /* XP */
10796 { EVENT_OBJECT_SHOW
, winevent_hook
|wparam
|lparam
, OBJID_CARET
, 0 },
10799 /* Creation of a dialog */
10800 static const struct message WmCreateDialogParamSeq_1
[] = {
10801 { HCBT_CREATEWND
, hook
},
10802 { WM_NCCREATE
, sent
},
10803 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
10804 { WM_CREATE
, sent
},
10805 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
10806 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
10808 { WM_SETFONT
, sent
},
10809 { WM_INITDIALOG
, sent
},
10810 { WM_CHANGEUISTATE
, sent
|optional
},
10813 /* Creation of a dialog */
10814 static const struct message WmCreateDialogParamSeq_2
[] = {
10815 { HCBT_CREATEWND
, hook
},
10816 { WM_NCCREATE
, sent
},
10817 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
10818 { WM_CREATE
, sent
},
10819 { EVENT_OBJECT_CREATE
, winevent_hook
|wparam
|lparam
, 0, 0 },
10820 { WM_SIZE
, sent
|wparam
, SIZE_RESTORED
},
10822 { WM_CHANGEUISTATE
, sent
|optional
},
10826 static void test_dialog_messages(void)
10829 HWND hdlg
, hedit1
, hedit2
, hfocus
;
10832 #define set_selection(hctl, start, end) \
10833 ret = SendMessage(hctl, EM_SETSEL, start, end); \
10834 ok(ret == 1, "EM_SETSEL returned %ld\n", ret);
10836 #define check_selection(hctl, start, end) \
10837 ret = SendMessage(hctl, EM_GETSEL, 0, 0); \
10838 ok(ret == MAKELRESULT(start, end), "wrong selection (%d - %d)\n", LOWORD(ret), HIWORD(ret));
10842 hdlg
= CreateWindowEx(WS_EX_DLGMODALFRAME
, "TestDialogClass", NULL
,
10843 WS_VISIBLE
|WS_CAPTION
|WS_SYSMENU
|WS_DLGFRAME
,
10844 0, 0, 100, 100, 0, 0, 0, NULL
);
10845 ok(hdlg
!= 0, "Failed to create custom dialog window\n");
10847 hedit1
= CreateWindowEx(0, "my_edit_class", NULL
,
10848 WS_CHILD
|WS_BORDER
|WS_VISIBLE
|WS_TABSTOP
,
10849 0, 0, 80, 20, hdlg
, (HMENU
)1, 0, NULL
);
10850 ok(hedit1
!= 0, "Failed to create edit control\n");
10851 hedit2
= CreateWindowEx(0, "my_edit_class", NULL
,
10852 WS_CHILD
|WS_BORDER
|WS_VISIBLE
|WS_TABSTOP
,
10853 0, 40, 80, 20, hdlg
, (HMENU
)2, 0, NULL
);
10854 ok(hedit2
!= 0, "Failed to create edit control\n");
10856 SendMessage(hedit1
, WM_SETTEXT
, 0, (LPARAM
)"hello");
10857 SendMessage(hedit2
, WM_SETTEXT
, 0, (LPARAM
)"bye");
10859 hfocus
= GetFocus();
10860 ok(hfocus
== hdlg
, "wrong focus %p\n", hfocus
);
10863 hfocus
= GetFocus();
10864 ok(hfocus
== hedit2
, "wrong focus %p\n", hfocus
);
10866 check_selection(hedit1
, 0, 0);
10867 check_selection(hedit2
, 0, 0);
10869 set_selection(hedit2
, 0, -1);
10870 check_selection(hedit2
, 0, 3);
10873 hfocus
= GetFocus();
10874 ok(hfocus
== 0, "wrong focus %p\n", hfocus
);
10877 ret
= DefDlgProc(hdlg
, WM_SETFOCUS
, 0, 0);
10878 ok(ret
== 0, "WM_SETFOCUS returned %ld\n", ret
);
10879 ok_sequence(WmDefDlgSetFocus_1
, "DefDlgProc(WM_SETFOCUS) 1", FALSE
);
10881 hfocus
= GetFocus();
10882 ok(hfocus
== hedit1
, "wrong focus %p\n", hfocus
);
10884 check_selection(hedit1
, 0, 5);
10885 check_selection(hedit2
, 0, 3);
10888 ret
= DefDlgProc(hdlg
, WM_SETFOCUS
, 0, 0);
10889 ok(ret
== 0, "WM_SETFOCUS returned %ld\n", ret
);
10890 ok_sequence(WmDefDlgSetFocus_2
, "DefDlgProc(WM_SETFOCUS) 2", FALSE
);
10892 hfocus
= GetFocus();
10893 ok(hfocus
== hedit1
, "wrong focus %p\n", hfocus
);
10895 check_selection(hedit1
, 0, 5);
10896 check_selection(hedit2
, 0, 3);
10898 EndDialog(hdlg
, 0);
10899 DestroyWindow(hedit1
);
10900 DestroyWindow(hedit2
);
10901 DestroyWindow(hdlg
);
10904 #undef set_selection
10905 #undef check_selection
10907 ok(GetClassInfo(0, "#32770", &cls
), "GetClassInfo failed\n");
10908 cls
.lpszClassName
= "MyDialogClass";
10909 cls
.hInstance
= GetModuleHandle(0);
10910 /* need a cast since a dlgproc is used as a wndproc */
10911 cls
.lpfnWndProc
= (WNDPROC
)test_dlg_proc
;
10912 if (!RegisterClass(&cls
)) assert(0);
10914 hdlg
= CreateDialogParam(0, "CLASS_TEST_DIALOG_2", 0, test_dlg_proc
, 0);
10915 ok(IsWindow(hdlg
), "CreateDialogParam failed\n");
10916 ok_sequence(WmCreateDialogParamSeq_1
, "CreateDialogParam_1", FALSE
);
10917 EndDialog(hdlg
, 0);
10918 DestroyWindow(hdlg
);
10921 hdlg
= CreateDialogParam(0, "CLASS_TEST_DIALOG_2", 0, NULL
, 0);
10922 ok(IsWindow(hdlg
), "CreateDialogParam failed\n");
10923 ok_sequence(WmCreateDialogParamSeq_2
, "CreateDialogParam_2", FALSE
);
10924 EndDialog(hdlg
, 0);
10925 DestroyWindow(hdlg
);
10928 UnregisterClass(cls
.lpszClassName
, cls
.hInstance
);
10931 static void test_nullCallback(void)
10935 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW
,
10936 100, 100, 200, 200, 0, 0, 0, NULL
);
10937 ok (hwnd
!= 0, "Failed to create overlapped window\n");
10939 SendMessageCallbackA(hwnd
,WM_NULL
,0,0,NULL
,0);
10941 DestroyWindow(hwnd
);
10944 /* SetActiveWindow( 0 ) hwnd visible */
10945 static const struct message SetActiveWindowSeq0
[] =
10947 { HCBT_ACTIVATE
, hook
|optional
},
10948 { WM_NCACTIVATE
, sent
|wparam
, 0 },
10949 { WM_GETTEXT
, sent
|defwinproc
|optional
},
10950 { WM_ACTIVATE
, sent
|wparam
, 0 },
10951 { WM_ACTIVATEAPP
, sent
|wparam
|optional
, 0 },
10952 { WM_ACTIVATEAPP
, sent
|wparam
|optional
, 0 },
10953 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
10954 { WM_KILLFOCUS
, sent
|optional
},
10955 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
10956 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
10957 { WM_NCACTIVATE
, sent
|wparam
|optional
, 1 },
10958 { WM_GETTEXT
, sent
|defwinproc
|optional
},
10959 { WM_ACTIVATE
, sent
|wparam
|optional
, 1 },
10960 { HCBT_SETFOCUS
, hook
|optional
},
10961 { WM_KILLFOCUS
, sent
|defwinproc
|optional
},
10962 { WM_IME_SETCONTEXT
, sent
|defwinproc
|optional
},
10963 { WM_IME_SETCONTEXT
, sent
|defwinproc
|optional
},
10964 { WM_IME_SETCONTEXT
, sent
|optional
},
10965 { WM_IME_SETCONTEXT
, sent
|optional
},
10966 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 1 },
10967 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
10968 { WM_SETFOCUS
, sent
|defwinproc
|optional
},
10969 { WM_GETTEXT
, sent
|optional
},
10972 /* SetActiveWindow( hwnd ) hwnd visible */
10973 static const struct message SetActiveWindowSeq1
[] =
10975 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
10978 /* SetActiveWindow( popup ) hwnd visible, popup visible */
10979 static const struct message SetActiveWindowSeq2
[] =
10981 { HCBT_ACTIVATE
, hook
},
10982 { WM_NCACTIVATE
, sent
|wparam
, 0 },
10983 { WM_GETTEXT
, sent
|defwinproc
|optional
},
10984 { WM_ACTIVATE
, sent
|wparam
, 0 },
10985 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
10986 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
},
10987 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
10988 { WM_NCPAINT
, sent
|optional
},
10989 { WM_GETTEXT
, sent
|defwinproc
|optional
},
10990 { WM_ERASEBKGND
, sent
|optional
},
10991 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
10992 { WM_NCACTIVATE
, sent
|wparam
, 1 },
10993 { WM_GETTEXT
, sent
|defwinproc
|optional
},
10994 { WM_ACTIVATE
, sent
|wparam
, 1 },
10995 { HCBT_SETFOCUS
, hook
},
10996 { WM_KILLFOCUS
, sent
|defwinproc
},
10997 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 0 },
10998 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
10999 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 1 },
11000 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
11001 { WM_SETFOCUS
, sent
|defwinproc
},
11002 { WM_GETTEXT
, sent
|optional
},
11006 /* SetActiveWindow( hwnd ) hwnd not visible */
11007 static const struct message SetActiveWindowSeq3
[] =
11009 { HCBT_ACTIVATE
, hook
},
11010 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
11011 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
11012 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
},
11013 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOACTIVATE
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
11014 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
11015 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
11016 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
11017 { WM_NCACTIVATE
, sent
|wparam
, 1 },
11018 { WM_ACTIVATE
, sent
|wparam
, 1 },
11019 { HCBT_SETFOCUS
, hook
},
11020 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
11021 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
11022 { WM_SETFOCUS
, sent
|defwinproc
},
11025 /* SetActiveWindow( popup ) hwnd not visible, popup not visible */
11026 static const struct message SetActiveWindowSeq4
[] =
11028 { HCBT_ACTIVATE
, hook
},
11029 { WM_NCACTIVATE
, sent
|wparam
, 0 },
11030 { WM_GETTEXT
, sent
|defwinproc
|optional
},
11031 { WM_ACTIVATE
, sent
|wparam
, 0 },
11032 { WM_QUERYNEWPALETTE
, sent
|wparam
|lparam
|optional
, 0, 0 },
11033 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
},
11034 { WM_WINDOWPOSCHANGING
, sent
|wparam
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
},
11035 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
11036 { WM_WINDOWPOSCHANGED
, sent
|wparam
|optional
, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOREDRAW
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
},
11037 { WM_NCACTIVATE
, sent
|wparam
, 1 },
11038 { WM_GETTEXT
, sent
|defwinproc
|optional
},
11039 { WM_ACTIVATE
, sent
|wparam
, 1 },
11040 { HCBT_SETFOCUS
, hook
},
11041 { WM_KILLFOCUS
, sent
|defwinproc
},
11042 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 0 },
11043 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
11044 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 1 },
11045 { WM_IME_NOTIFY
, sent
|wparam
|defwinproc
|optional
, 2 },
11046 { WM_SETFOCUS
, sent
|defwinproc
},
11051 static void test_SetActiveWindow(void)
11053 HWND hwnd
, popup
, ret
;
11055 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test SetActiveWindow",
11056 WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
11057 100, 100, 200, 200, 0, 0, 0, NULL
);
11059 popup
= CreateWindowExA(0, "TestWindowClass", "Test SetActiveWindow",
11060 WS_OVERLAPPEDWINDOW
| WS_VISIBLE
| WS_POPUP
,
11061 100, 100, 200, 200, hwnd
, 0, 0, NULL
);
11063 ok(hwnd
!= 0, "Failed to create overlapped window\n");
11064 ok(popup
!= 0, "Failed to create popup window\n");
11065 SetForegroundWindow( popup
);
11068 trace("SetActiveWindow(0)\n");
11069 ret
= SetActiveWindow(0);
11070 ok( ret
== popup
, "Failed to SetActiveWindow(0)\n");
11071 ok_sequence(SetActiveWindowSeq0
, "SetActiveWindow(0)", FALSE
);
11074 trace("SetActiveWindow(hwnd), hwnd visible\n");
11075 ret
= SetActiveWindow(hwnd
);
11076 if (ret
== hwnd
) ok_sequence(SetActiveWindowSeq1
, "SetActiveWindow(hwnd), hwnd visible", TRUE
);
11079 trace("SetActiveWindow(popup), hwnd visible, popup visible\n");
11080 ret
= SetActiveWindow(popup
);
11081 ok( ret
== hwnd
, "Failed to SetActiveWindow(popup), popup visible\n");
11082 ok_sequence(SetActiveWindowSeq2
, "SetActiveWindow(popup), hwnd visible, popup visible", FALSE
);
11085 ShowWindow(hwnd
, SW_HIDE
);
11086 ShowWindow(popup
, SW_HIDE
);
11089 trace("SetActiveWindow(hwnd), hwnd not visible\n");
11090 ret
= SetActiveWindow(hwnd
);
11091 ok( ret
== NULL
, "SetActiveWindow(hwnd), hwnd not visible, previous is %p\n", ret
);
11092 ok_sequence(SetActiveWindowSeq3
, "SetActiveWindow(hwnd), hwnd not visible", TRUE
);
11095 trace("SetActiveWindow(popup), hwnd not visible, popup not visible\n");
11096 ret
= SetActiveWindow(popup
);
11097 ok( ret
== hwnd
, "Failed to SetActiveWindow(popup)\n");
11098 ok_sequence(SetActiveWindowSeq4
, "SetActiveWindow(popup), hwnd not visible, popup not visible", TRUE
);
11103 DestroyWindow(hwnd
);
11106 static const struct message SetForegroundWindowSeq
[] =
11108 { WM_NCACTIVATE
, sent
|wparam
, 0 },
11109 { WM_GETTEXT
, sent
|defwinproc
|optional
},
11110 { WM_ACTIVATE
, sent
|wparam
, 0 },
11111 { WM_ACTIVATEAPP
, sent
|wparam
, 0 },
11112 { WM_KILLFOCUS
, sent
},
11113 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0 },
11114 { WM_IME_NOTIFY
, sent
|wparam
|optional
|defwinproc
, 1 },
11118 static void test_SetForegroundWindow(void)
11122 hwnd
= CreateWindowExA(0, "TestWindowClass", "Test SetForegroundWindow",
11123 WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
11124 100, 100, 200, 200, 0, 0, 0, NULL
);
11125 ok (hwnd
!= 0, "Failed to create overlapped window\n");
11126 SetForegroundWindow( hwnd
);
11129 trace("SetForegroundWindow( 0 )\n");
11130 SetForegroundWindow( 0 );
11131 ok_sequence(WmEmptySeq
, "SetForegroundWindow( 0 ) away from foreground top level window", FALSE
);
11132 trace("SetForegroundWindow( GetDesktopWindow() )\n");
11133 SetForegroundWindow( GetDesktopWindow() );
11134 ok_sequence(SetForegroundWindowSeq
, "SetForegroundWindow( desktop ) away from "
11135 "foreground top level window", FALSE
);
11138 DestroyWindow(hwnd
);
11141 static void test_dbcs_wm_char(void)
11144 WCHAR wch
, bad_wch
;
11152 struct message wmCharSeq
[2];
11154 if (!pGetCPInfoExA
)
11156 win_skip("GetCPInfoExA is not available\n");
11160 pGetCPInfoExA( CP_ACP
, 0, &cpinfo
);
11161 if (cpinfo
.MaxCharSize
!= 2)
11163 skip( "Skipping DBCS WM_CHAR test in SBCS codepage '%s'\n", cpinfo
.CodePageName
);
11167 dbch
[0] = dbch
[1] = 0;
11169 bad_wch
= cpinfo
.UnicodeDefaultChar
;
11170 for (i
= 0; !wch
&& i
< MAX_LEADBYTES
&& cpinfo
.LeadByte
[i
]; i
+= 2)
11171 for (j
= cpinfo
.LeadByte
[i
]; !wch
&& j
<= cpinfo
.LeadByte
[i
+1]; j
++)
11172 for (k
= 128; k
<= 255; k
++)
11178 if (MultiByteToWideChar( CP_ACP
, 0, str
, 2, wstr
, 2 ) == 1 &&
11179 WideCharToMultiByte( CP_ACP
, 0, wstr
, 1, str
, 2, NULL
, NULL
) == 2 &&
11180 (BYTE
)str
[0] == j
&& (BYTE
)str
[1] == k
&&
11181 HIBYTE(wstr
[0]) && HIBYTE(wstr
[0]) != 0xff)
11192 skip( "Skipping DBCS WM_CHAR test, no appropriate char found\n" );
11195 trace( "using dbcs char %02x,%02x wchar %04x bad wchar %04x codepage '%s'\n",
11196 dbch
[0], dbch
[1], wch
, bad_wch
, cpinfo
.CodePageName
);
11198 hwnd
= CreateWindowExW(0, testWindowClassW
, NULL
,
11199 WS_OVERLAPPEDWINDOW
, 100, 100, 200, 200, 0, 0, 0, NULL
);
11200 hwnd2
= CreateWindowExW(0, testWindowClassW
, NULL
,
11201 WS_OVERLAPPEDWINDOW
, 100, 100, 200, 200, 0, 0, 0, NULL
);
11202 ok (hwnd
!= 0, "Failed to create overlapped window\n");
11203 ok (hwnd2
!= 0, "Failed to create overlapped window\n");
11206 memset( wmCharSeq
, 0, sizeof(wmCharSeq
) );
11207 wmCharSeq
[0].message
= WM_CHAR
;
11208 wmCharSeq
[0].flags
= sent
|wparam
;
11209 wmCharSeq
[0].wParam
= wch
;
11211 /* posted message */
11212 PostMessageA( hwnd
, WM_CHAR
, dbch
[0], 0 );
11213 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
11214 PostMessageA( hwnd
, WM_CHAR
, dbch
[1], 0 );
11215 ok( PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "no message\n" );
11216 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
11217 ok( msg
.wParam
== wch
, "bad wparam %lx/%x\n", msg
.wParam
, wch
);
11218 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
11220 /* posted thread message */
11221 PostThreadMessageA( GetCurrentThreadId(), WM_CHAR
, dbch
[0], 0 );
11222 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
11223 PostMessageA( hwnd
, WM_CHAR
, dbch
[1], 0 );
11224 ok( PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "no message\n" );
11225 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
11226 ok( msg
.wParam
== wch
, "bad wparam %lx/%x\n", msg
.wParam
, wch
);
11227 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
11231 SendMessageA( hwnd
, WM_CHAR
, dbch
[0], 0 );
11232 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
11233 SendMessageA( hwnd
, WM_CHAR
, dbch
[1], 0 );
11234 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
11235 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
11237 /* sent message with timeout */
11239 SendMessageTimeoutA( hwnd
, WM_CHAR
, dbch
[0], 0, SMTO_NORMAL
, 0, &res
);
11240 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
11241 SendMessageTimeoutA( hwnd
, WM_CHAR
, dbch
[1], 0, SMTO_NORMAL
, 0, &res
);
11242 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
11243 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
11245 /* sent message with timeout and callback */
11247 SendMessageTimeoutA( hwnd
, WM_CHAR
, dbch
[0], 0, SMTO_NORMAL
, 0, &res
);
11248 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
11249 SendMessageCallbackA( hwnd
, WM_CHAR
, dbch
[1], 0, NULL
, 0 );
11250 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
11251 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
11253 /* sent message with callback */
11255 SendNotifyMessageA( hwnd
, WM_CHAR
, dbch
[0], 0 );
11256 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
11257 SendMessageCallbackA( hwnd
, WM_CHAR
, dbch
[1], 0, NULL
, 0 );
11258 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
11259 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
11261 /* direct window proc call */
11263 CallWindowProcA( (WNDPROC
)GetWindowLongPtrA( hwnd
, GWLP_WNDPROC
), hwnd
, WM_CHAR
, dbch
[0], 0 );
11264 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
11265 CallWindowProcA( (WNDPROC
)GetWindowLongPtrA( hwnd
, GWLP_WNDPROC
), hwnd
, WM_CHAR
, dbch
[1], 0 );
11266 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
11268 /* dispatch message */
11270 msg
.message
= WM_CHAR
;
11271 msg
.wParam
= dbch
[0];
11273 DispatchMessageA( &msg
);
11274 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
11275 msg
.wParam
= dbch
[1];
11276 DispatchMessageA( &msg
);
11277 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
11279 /* window handle is irrelevant */
11281 SendMessageA( hwnd2
, WM_CHAR
, dbch
[0], 0 );
11282 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
11283 SendMessageA( hwnd
, WM_CHAR
, dbch
[1], 0 );
11284 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
11285 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
11287 /* interleaved post and send */
11289 PostMessageA( hwnd2
, WM_CHAR
, dbch
[0], 0 );
11290 SendMessageA( hwnd2
, WM_CHAR
, dbch
[0], 0 );
11291 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
11292 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
11293 PostMessageA( hwnd
, WM_CHAR
, dbch
[1], 0 );
11294 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
11295 ok( PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "no message\n" );
11296 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
11297 ok( msg
.wParam
== wch
, "bad wparam %lx/%x\n", msg
.wParam
, wch
);
11298 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
11299 SendMessageA( hwnd
, WM_CHAR
, dbch
[1], 0 );
11300 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
11301 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
11303 /* interleaved sent message and winproc */
11305 SendMessageA( hwnd
, WM_CHAR
, dbch
[0], 0 );
11306 CallWindowProcA( (WNDPROC
)GetWindowLongPtrA( hwnd
, GWLP_WNDPROC
), hwnd
, WM_CHAR
, dbch
[0], 0 );
11307 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
11308 SendMessageA( hwnd
, WM_CHAR
, dbch
[1], 0 );
11309 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
11310 CallWindowProcA( (WNDPROC
)GetWindowLongPtrA( hwnd
, GWLP_WNDPROC
), hwnd
, WM_CHAR
, dbch
[1], 0 );
11311 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
11313 /* interleaved winproc and dispatch */
11315 msg
.message
= WM_CHAR
;
11316 msg
.wParam
= dbch
[0];
11318 CallWindowProcA( (WNDPROC
)GetWindowLongPtrA( hwnd
, GWLP_WNDPROC
), hwnd
, WM_CHAR
, dbch
[0], 0 );
11319 DispatchMessageA( &msg
);
11320 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
11321 msg
.wParam
= dbch
[1];
11322 DispatchMessageA( &msg
);
11323 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
11324 CallWindowProcA( (WNDPROC
)GetWindowLongPtrA( hwnd
, GWLP_WNDPROC
), hwnd
, WM_CHAR
, dbch
[1], 0 );
11325 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
11327 /* interleaved sends */
11329 SendMessageA( hwnd
, WM_CHAR
, dbch
[0], 0 );
11330 SendMessageCallbackA( hwnd
, WM_CHAR
, dbch
[0], 0, NULL
, 0 );
11331 ok_sequence( WmEmptySeq
, "no messages", FALSE
);
11332 SendMessageTimeoutA( hwnd
, WM_CHAR
, dbch
[1], 0, SMTO_NORMAL
, 0, &res
);
11333 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
11334 SendMessageA( hwnd
, WM_CHAR
, dbch
[1], 0 );
11335 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
11339 SendMessageA( hwnd2
, WM_CHAR
, (dbch
[1] << 8) | dbch
[0], 0 );
11340 ok_sequence( wmCharSeq
, "Unicode WM_CHAR", FALSE
);
11341 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
11343 /* other char messages are not magic */
11344 PostMessageA( hwnd
, WM_SYSCHAR
, dbch
[0], 0 );
11345 ok( PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "no message\n" );
11346 ok( msg
.message
== WM_SYSCHAR
, "unexpected message %x\n", msg
.message
);
11347 ok( msg
.wParam
== bad_wch
, "bad wparam %lx/%x\n", msg
.wParam
, bad_wch
);
11348 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
11349 PostMessageA( hwnd
, WM_DEADCHAR
, dbch
[0], 0 );
11350 ok( PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "no message\n" );
11351 ok( msg
.message
== WM_DEADCHAR
, "unexpected message %x\n", msg
.message
);
11352 ok( msg
.wParam
== bad_wch
, "bad wparam %lx/%x\n", msg
.wParam
, bad_wch
);
11353 ok( !PeekMessageW( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
11355 /* test retrieving messages */
11357 PostMessageW( hwnd
, WM_CHAR
, wch
, 0 );
11358 ok( PeekMessageA( &msg
, hwnd
, 0, 0, PM_REMOVE
), "no message\n" );
11359 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
11360 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
11361 ok( msg
.wParam
== dbch
[0], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
11362 ok( PeekMessageA( &msg
, hwnd
, 0, 0, PM_REMOVE
), "no message\n" );
11363 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
11364 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
11365 ok( msg
.wParam
== dbch
[1], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
11366 ok( !PeekMessageA( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
11368 /* message filters */
11369 PostMessageW( hwnd
, WM_CHAR
, wch
, 0 );
11370 ok( PeekMessageA( &msg
, hwnd
, 0, 0, PM_REMOVE
), "no message\n" );
11371 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
11372 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
11373 ok( msg
.wParam
== dbch
[0], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
11374 /* message id is filtered, hwnd is not */
11375 ok( !PeekMessageA( &msg
, hwnd
, WM_MOUSEFIRST
, WM_MOUSELAST
, PM_REMOVE
), "no message\n" );
11376 ok( PeekMessageA( &msg
, hwnd2
, 0, 0, PM_REMOVE
), "no message\n" );
11377 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
11378 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
11379 ok( msg
.wParam
== dbch
[1], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
11380 ok( !PeekMessageA( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
11382 /* mixing GetMessage and PostMessage */
11383 PostMessageW( hwnd
, WM_CHAR
, wch
, 0xbeef );
11384 ok( GetMessageA( &msg
, hwnd
, 0, 0 ), "no message\n" );
11385 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
11386 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
11387 ok( msg
.wParam
== dbch
[0], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
11388 ok( msg
.lParam
== 0xbeef, "bad lparam %lx\n", msg
.lParam
);
11391 ok( time
- GetTickCount() <= 100, "bad time %x\n", msg
.time
);
11392 ok( PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
), "no message\n" );
11393 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
11394 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
11395 ok( msg
.wParam
== dbch
[1], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
11396 ok( msg
.lParam
== 0xbeef, "bad lparam %lx\n", msg
.lParam
);
11397 ok( msg
.time
== time
, "bad time %x/%x\n", msg
.time
, time
);
11398 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
);
11399 ok( !PeekMessageA( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
11401 /* without PM_REMOVE */
11402 PostMessageW( hwnd
, WM_CHAR
, wch
, 0 );
11403 ok( PeekMessageA( &msg
, 0, 0, 0, PM_NOREMOVE
), "no message\n" );
11404 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
11405 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
11406 ok( msg
.wParam
== dbch
[0], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
11407 ok( PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
), "no message\n" );
11408 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
11409 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
11410 ok( msg
.wParam
== dbch
[0], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
11411 ok( PeekMessageA( &msg
, 0, 0, 0, PM_NOREMOVE
), "no message\n" );
11412 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
11413 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
11414 ok( msg
.wParam
== dbch
[1], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
11415 ok( PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
), "no message\n" );
11416 ok( msg
.hwnd
== hwnd
, "unexpected hwnd %p\n", msg
.hwnd
);
11417 ok( msg
.message
== WM_CHAR
, "unexpected message %x\n", msg
.message
);
11418 ok( msg
.wParam
== dbch
[1], "bad wparam %lx/%x\n", msg
.wParam
, dbch
[0] );
11419 ok( !PeekMessageA( &msg
, hwnd
, 0, 0, PM_REMOVE
), "got message %x\n", msg
.message
);
11421 DestroyWindow(hwnd
);
11424 #define ID_LISTBOX 0x000f
11426 static const struct message wm_lb_setcursel_0
[] =
11428 { LB_SETCURSEL
, sent
|wparam
|lparam
, 0, 0 },
11429 { WM_CTLCOLORLISTBOX
, sent
|parent
},
11430 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x000120f2 },
11431 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 1 },
11432 { EVENT_OBJECT_SELECTION
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 1 },
11435 static const struct message wm_lb_setcursel_1
[] =
11437 { LB_SETCURSEL
, sent
|wparam
|lparam
, 1, 0 },
11438 { WM_CTLCOLORLISTBOX
, sent
|parent
},
11439 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x000020f2 },
11440 { WM_CTLCOLORLISTBOX
, sent
|parent
},
11441 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x000121f2 },
11442 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 2 },
11443 { EVENT_OBJECT_SELECTION
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 2 },
11446 static const struct message wm_lb_setcursel_2
[] =
11448 { LB_SETCURSEL
, sent
|wparam
|lparam
, 2, 0 },
11449 { WM_CTLCOLORLISTBOX
, sent
|parent
},
11450 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x000021f2 },
11451 { WM_CTLCOLORLISTBOX
, sent
|parent
},
11452 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x000122f2 },
11453 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 3 },
11454 { EVENT_OBJECT_SELECTION
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 3 },
11457 static const struct message wm_lb_click_0
[] =
11459 { WM_LBUTTONDOWN
, sent
|wparam
|lparam
, 0, MAKELPARAM(1,1) },
11460 { HCBT_SETFOCUS
, hook
},
11461 { WM_KILLFOCUS
, sent
|parent
},
11462 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
|parent
, 0 },
11463 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
11464 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 0 },
11465 { WM_SETFOCUS
, sent
|defwinproc
},
11467 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x001142f2 },
11468 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_LISTBOX
, LBN_SETFOCUS
) },
11469 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 3 },
11470 { WM_LBTRACKPOINT
, sent
|wparam
|lparam
|parent
, 0, MAKELPARAM(1,1) },
11471 { EVENT_SYSTEM_CAPTURESTART
, winevent_hook
|wparam
|lparam
, 0, 0 },
11473 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x000142f2 },
11474 { WM_CTLCOLORLISTBOX
, sent
|parent
},
11475 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x000022f2 },
11476 { WM_CTLCOLORLISTBOX
, sent
|parent
},
11477 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x000120f2 },
11478 { WM_DRAWITEM
, sent
|wparam
|lparam
|parent
, ID_LISTBOX
, 0x001140f2 },
11480 { EVENT_OBJECT_FOCUS
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 1 },
11481 { EVENT_OBJECT_SELECTION
, winevent_hook
|wparam
|lparam
, OBJID_CLIENT
, 1 },
11483 { WM_LBUTTONUP
, sent
|wparam
|lparam
, 0, 0 },
11484 { EVENT_SYSTEM_CAPTUREEND
, winevent_hook
|wparam
|lparam
, 0, 0 },
11485 { WM_CAPTURECHANGED
, sent
|wparam
|lparam
|defwinproc
, 0, 0 },
11486 { WM_COMMAND
, sent
|wparam
|parent
, MAKEWPARAM(ID_LISTBOX
, LBN_SELCHANGE
) },
11489 static const struct message wm_lb_deletestring
[] =
11491 { LB_DELETESTRING
, sent
|wparam
|lparam
, 0, 0 },
11492 { WM_DELETEITEM
, sent
|wparam
|parent
|optional
, ID_LISTBOX
, 0 },
11493 { WM_DRAWITEM
, sent
|wparam
|parent
|optional
, ID_LISTBOX
},
11494 { WM_DRAWITEM
, sent
|wparam
|parent
|optional
, ID_LISTBOX
},
11497 static const struct message wm_lb_deletestring_reset
[] =
11499 { LB_DELETESTRING
, sent
|wparam
|lparam
, 0, 0 },
11500 { LB_RESETCONTENT
, sent
|wparam
|lparam
|defwinproc
|optional
, 0, 0 },
11501 { WM_DELETEITEM
, sent
|wparam
|parent
|optional
, ID_LISTBOX
, 0 },
11502 { WM_DRAWITEM
, sent
|wparam
|parent
|optional
, ID_LISTBOX
},
11503 { WM_DRAWITEM
, sent
|wparam
|parent
|optional
, ID_LISTBOX
},
11507 #define check_lb_state(a1, a2, a3, a4, a5) check_lb_state_dbg(a1, a2, a3, a4, a5, __LINE__)
11509 static LRESULT (WINAPI
*listbox_orig_proc
)(HWND
, UINT
, WPARAM
, LPARAM
);
11511 static LRESULT WINAPI
listbox_hook_proc(HWND hwnd
, UINT message
, WPARAM wp
, LPARAM lp
)
11513 static LONG defwndproc_counter
= 0;
11515 struct recvd_message msg
;
11517 /* do not log painting messages */
11518 if (message
!= WM_PAINT
&&
11519 message
!= WM_NCPAINT
&&
11520 message
!= WM_SYNCPAINT
&&
11521 message
!= WM_ERASEBKGND
&&
11522 message
!= WM_NCHITTEST
&&
11523 message
!= WM_GETTEXT
&&
11524 !ignore_message( message
))
11527 msg
.message
= message
;
11528 msg
.flags
= sent
|wparam
|lparam
;
11529 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
11532 msg
.descr
= "listbox";
11536 defwndproc_counter
++;
11537 ret
= CallWindowProcA(listbox_orig_proc
, hwnd
, message
, wp
, lp
);
11538 defwndproc_counter
--;
11543 static void check_lb_state_dbg(HWND listbox
, int count
, int cur_sel
,
11544 int caret_index
, int top_index
, int line
)
11548 /* calling an orig proc helps to avoid unnecessary message logging */
11549 ret
= CallWindowProcA(listbox_orig_proc
, listbox
, LB_GETCOUNT
, 0, 0);
11550 ok_(__FILE__
, line
)(ret
== count
, "expected count %d, got %ld\n", count
, ret
);
11551 ret
= CallWindowProcA(listbox_orig_proc
, listbox
, LB_GETCURSEL
, 0, 0);
11552 ok_(__FILE__
, line
)(ret
== cur_sel
, "expected cur sel %d, got %ld\n", cur_sel
, ret
);
11553 ret
= CallWindowProcA(listbox_orig_proc
, listbox
, LB_GETCARETINDEX
, 0, 0);
11554 ok_(__FILE__
, line
)(ret
== caret_index
||
11555 broken(cur_sel
== -1 && caret_index
== 0 && ret
== -1), /* nt4 */
11556 "expected caret index %d, got %ld\n", caret_index
, ret
);
11557 ret
= CallWindowProcA(listbox_orig_proc
, listbox
, LB_GETTOPINDEX
, 0, 0);
11558 ok_(__FILE__
, line
)(ret
== top_index
, "expected top index %d, got %ld\n", top_index
, ret
);
11561 static void test_listbox_messages(void)
11563 HWND parent
, listbox
;
11566 parent
= CreateWindowExA(0, "TestParentClass", NULL
, WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
11567 100, 100, 200, 200, 0, 0, 0, NULL
);
11568 listbox
= CreateWindowExA(WS_EX_NOPARENTNOTIFY
, "ListBox", NULL
,
11569 WS_CHILD
| LBS_NOTIFY
| LBS_OWNERDRAWVARIABLE
| LBS_HASSTRINGS
| WS_VISIBLE
,
11570 10, 10, 80, 80, parent
, (HMENU
)ID_LISTBOX
, 0, NULL
);
11571 listbox_orig_proc
= (WNDPROC
)SetWindowLongPtrA(listbox
, GWLP_WNDPROC
, (ULONG_PTR
)listbox_hook_proc
);
11573 check_lb_state(listbox
, 0, LB_ERR
, 0, 0);
11575 ret
= SendMessage(listbox
, LB_ADDSTRING
, 0, (LPARAM
)"item 0");
11576 ok(ret
== 0, "expected 0, got %ld\n", ret
);
11577 ret
= SendMessage(listbox
, LB_ADDSTRING
, 0, (LPARAM
)"item 1");
11578 ok(ret
== 1, "expected 1, got %ld\n", ret
);
11579 ret
= SendMessage(listbox
, LB_ADDSTRING
, 0, (LPARAM
)"item 2");
11580 ok(ret
== 2, "expected 2, got %ld\n", ret
);
11582 check_lb_state(listbox
, 3, LB_ERR
, 0, 0);
11586 log_all_parent_messages
++;
11588 trace("selecting item 0\n");
11589 ret
= SendMessage(listbox
, LB_SETCURSEL
, 0, 0);
11590 ok(ret
== 0, "expected 0, got %ld\n", ret
);
11591 ok_sequence(wm_lb_setcursel_0
, "LB_SETCURSEL 0", FALSE
);
11592 check_lb_state(listbox
, 3, 0, 0, 0);
11595 trace("selecting item 1\n");
11596 ret
= SendMessage(listbox
, LB_SETCURSEL
, 1, 0);
11597 ok(ret
== 1, "expected 1, got %ld\n", ret
);
11598 ok_sequence(wm_lb_setcursel_1
, "LB_SETCURSEL 1", FALSE
);
11599 check_lb_state(listbox
, 3, 1, 1, 0);
11601 trace("selecting item 2\n");
11602 ret
= SendMessage(listbox
, LB_SETCURSEL
, 2, 0);
11603 ok(ret
== 2, "expected 2, got %ld\n", ret
);
11604 ok_sequence(wm_lb_setcursel_2
, "LB_SETCURSEL 2", FALSE
);
11605 check_lb_state(listbox
, 3, 2, 2, 0);
11607 trace("clicking on item 0\n");
11608 ret
= SendMessage(listbox
, WM_LBUTTONDOWN
, 0, MAKELPARAM(1, 1));
11609 ok(ret
== LB_OKAY
, "expected LB_OKAY, got %ld\n", ret
);
11610 ret
= SendMessage(listbox
, WM_LBUTTONUP
, 0, 0);
11611 ok(ret
== LB_OKAY
, "expected LB_OKAY, got %ld\n", ret
);
11612 ok_sequence(wm_lb_click_0
, "WM_LBUTTONDOWN 0", FALSE
);
11613 check_lb_state(listbox
, 3, 0, 0, 0);
11616 trace("deleting item 0\n");
11617 ret
= SendMessage(listbox
, LB_DELETESTRING
, 0, 0);
11618 ok(ret
== 2, "expected 2, got %ld\n", ret
);
11619 ok_sequence(wm_lb_deletestring
, "LB_DELETESTRING 0", FALSE
);
11620 check_lb_state(listbox
, 2, -1, 0, 0);
11623 trace("deleting item 0\n");
11624 ret
= SendMessage(listbox
, LB_DELETESTRING
, 0, 0);
11625 ok(ret
== 1, "expected 1, got %ld\n", ret
);
11626 ok_sequence(wm_lb_deletestring
, "LB_DELETESTRING 0", FALSE
);
11627 check_lb_state(listbox
, 1, -1, 0, 0);
11630 trace("deleting item 0\n");
11631 ret
= SendMessage(listbox
, LB_DELETESTRING
, 0, 0);
11632 ok(ret
== 0, "expected 0, got %ld\n", ret
);
11633 ok_sequence(wm_lb_deletestring_reset
, "LB_DELETESTRING 0", FALSE
);
11634 check_lb_state(listbox
, 0, -1, 0, 0);
11637 trace("deleting item 0\n");
11638 ret
= SendMessage(listbox
, LB_DELETESTRING
, 0, 0);
11639 ok(ret
== LB_ERR
, "expected LB_ERR, got %ld\n", ret
);
11640 check_lb_state(listbox
, 0, -1, 0, 0);
11643 log_all_parent_messages
--;
11645 DestroyWindow(listbox
);
11646 DestroyWindow(parent
);
11649 /*************************** Menu test ******************************/
11650 static const struct message wm_popup_menu_1
[] =
11652 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 },
11653 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
11654 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'E', 0x20000001 },
11655 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, 'E', 0x20000001 },
11656 { WM_SYSCHAR
, sent
|wparam
|lparam
, 'e', 0x20000001 },
11657 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_KEYMENU
, 'e' },
11658 { WM_ENTERMENULOOP
, sent
|wparam
|lparam
, 0, 0 },
11659 { WM_INITMENU
, sent
|lparam
, 0, 0 },
11660 { WM_MENUSELECT
, sent
|wparam
, MAKEWPARAM(1,MF_HILITE
|MF_POPUP
) },
11661 { WM_INITMENUPOPUP
, sent
|lparam
, 0, 1 },
11662 { HCBT_CREATEWND
, hook
|optional
}, /* Win9x doesn't create a window */
11663 { WM_MENUSELECT
, sent
|wparam
, MAKEWPARAM(200,MF_HILITE
) },
11664 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'E', 0xf0000001 },
11665 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xd0000001 },
11666 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_RETURN
, 0x10000001, 0, 0x40000000 },
11667 { HCBT_DESTROYWND
, hook
|optional
}, /* Win9x doesn't create a window */
11668 { WM_UNINITMENUPOPUP
, sent
|lparam
, 0, 0 },
11669 { WM_MENUSELECT
, sent
|wparam
|lparam
, MAKEWPARAM(0,0xffff), 0 },
11670 { WM_EXITMENULOOP
, sent
|wparam
|lparam
, 0, 0 },
11671 { WM_MENUCOMMAND
, sent
}, /* |wparam, 200 - Win9x */
11672 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_RETURN
, 0xc0000001 },
11673 { WM_KEYUP
, sent
|wparam
|lparam
, VK_RETURN
, 0xc0000001 },
11676 static const struct message wm_popup_menu_2
[] =
11678 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 },
11679 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
11680 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'F', 0x20000001 },
11681 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, 'F', 0x20000001 },
11682 { WM_SYSCHAR
, sent
|wparam
|lparam
, 'f', 0x20000001 },
11683 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_KEYMENU
, 'f' },
11684 { WM_ENTERMENULOOP
, sent
|wparam
|lparam
, 0, 0 },
11685 { WM_INITMENU
, sent
|lparam
, 0, 0 },
11686 { WM_MENUSELECT
, sent
|wparam
, MAKEWPARAM(0,MF_HILITE
|MF_POPUP
) },
11687 { WM_INITMENUPOPUP
, sent
|lparam
, 0, 0 },
11688 { WM_MENUSELECT
, sent
|wparam
|optional
, MAKEWPARAM(0,MF_HILITE
|MF_POPUP
) }, /* Win9x */
11689 { WM_INITMENUPOPUP
, sent
|lparam
|optional
, 0, 0 }, /* Win9x */
11690 { HCBT_CREATEWND
, hook
},
11691 { WM_MENUSELECT
, sent
}, /*|wparam, MAKEWPARAM(0,MF_HILITE|MF_POPUP) - XP
11692 |wparam, MAKEWPARAM(100,MF_HILITE) - Win9x */
11693 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'F', 0xf0000001 },
11694 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xd0000001 },
11695 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_RIGHT
, 0x10000001 },
11696 { WM_INITMENUPOPUP
, sent
|lparam
|optional
, 0, 0 }, /* Win9x doesn't send it */
11697 { HCBT_CREATEWND
, hook
|optional
}, /* Win9x doesn't send it */
11698 { WM_MENUSELECT
, sent
|wparam
|optional
, MAKEWPARAM(100,MF_HILITE
) },
11699 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_RIGHT
, 0xd0000001 },
11700 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_RETURN
, 0x10000001 },
11701 { HCBT_DESTROYWND
, hook
},
11702 { WM_UNINITMENUPOPUP
, sent
|lparam
, 0, 0 },
11703 { HCBT_DESTROYWND
, hook
|optional
}, /* Win9x doesn't send it */
11704 { WM_UNINITMENUPOPUP
, sent
|lparam
, 0, 0 },
11705 { WM_MENUSELECT
, sent
|wparam
|lparam
, MAKEWPARAM(0,0xffff), 0 },
11706 { WM_EXITMENULOOP
, sent
|wparam
|lparam
, 0, 0 },
11707 { WM_MENUCOMMAND
, sent
}, /* |wparam, 100 - Win9x */
11708 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_RETURN
, 0xc0000001 },
11709 { WM_KEYUP
, sent
|wparam
|lparam
, VK_RETURN
, 0xc0000001 },
11712 static const struct message wm_popup_menu_3
[] =
11714 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0x20000001 },
11715 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, VK_MENU
, 0x20000001 },
11716 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'F', 0x20000001 },
11717 { WM_SYSKEYDOWN
, sent
|wparam
|lparam
, 'F', 0x20000001 },
11718 { WM_SYSCHAR
, sent
|wparam
|lparam
, 'f', 0x20000001 },
11719 { HCBT_SYSCOMMAND
, hook
|wparam
|lparam
, SC_KEYMENU
, 'f' },
11720 { WM_ENTERMENULOOP
, sent
|wparam
|lparam
, 0, 0 },
11721 { WM_INITMENU
, sent
|lparam
, 0, 0 },
11722 { WM_MENUSELECT
, sent
|wparam
, MAKEWPARAM(0,MF_HILITE
|MF_POPUP
) },
11723 { WM_INITMENUPOPUP
, sent
|lparam
, 0, 0 },
11724 { WM_MENUSELECT
, sent
|wparam
|optional
, MAKEWPARAM(0,MF_HILITE
|MF_POPUP
) }, /* Win9x */
11725 { WM_INITMENUPOPUP
, sent
|lparam
|optional
, 0, 0 }, /* Win9x */
11726 { HCBT_CREATEWND
, hook
},
11727 { WM_MENUSELECT
, sent
}, /*|wparam, MAKEWPARAM(0,MF_HILITE|MF_POPUP) - XP
11728 |wparam, MAKEWPARAM(100,MF_HILITE) - Win9x */
11729 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, 'F', 0xf0000001 },
11730 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_MENU
, 0xd0000001 },
11731 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_RIGHT
, 0x10000001 },
11732 { WM_INITMENUPOPUP
, sent
|lparam
|optional
, 0, 0 }, /* Win9x doesn't send it */
11733 { HCBT_CREATEWND
, hook
|optional
}, /* Win9x doesn't send it */
11734 { WM_MENUSELECT
, sent
|wparam
|optional
, MAKEWPARAM(100,MF_HILITE
) },
11735 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_RIGHT
, 0xd0000001 },
11736 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_RETURN
, 0x10000001 },
11737 { HCBT_DESTROYWND
, hook
},
11738 { WM_UNINITMENUPOPUP
, sent
|lparam
, 0, 0 },
11739 { HCBT_DESTROYWND
, hook
|optional
}, /* Win9x doesn't send it */
11740 { WM_UNINITMENUPOPUP
, sent
|lparam
, 0, 0 },
11741 { WM_MENUSELECT
, sent
|wparam
|lparam
, MAKEWPARAM(0,0xffff), 0 },
11742 { WM_EXITMENULOOP
, sent
|wparam
|lparam
, 0, 0 },
11743 { WM_COMMAND
, sent
|wparam
|lparam
, 100, 0 },
11744 { HCBT_KEYSKIPPED
, hook
|wparam
|lparam
|optional
, VK_RETURN
, 0xc0000001 },
11745 { WM_KEYUP
, sent
|wparam
|lparam
, VK_RETURN
, 0xc0000001 },
11749 static LRESULT WINAPI
parent_menu_proc(HWND hwnd
, UINT message
, WPARAM wp
, LPARAM lp
)
11751 if (message
== WM_ENTERIDLE
||
11752 message
== WM_INITMENU
||
11753 message
== WM_INITMENUPOPUP
||
11754 message
== WM_MENUSELECT
||
11755 message
== WM_PARENTNOTIFY
||
11756 message
== WM_ENTERMENULOOP
||
11757 message
== WM_EXITMENULOOP
||
11758 message
== WM_UNINITMENUPOPUP
||
11759 message
== WM_KEYDOWN
||
11760 message
== WM_KEYUP
||
11761 message
== WM_CHAR
||
11762 message
== WM_SYSKEYDOWN
||
11763 message
== WM_SYSKEYUP
||
11764 message
== WM_SYSCHAR
||
11765 message
== WM_COMMAND
||
11766 message
== WM_MENUCOMMAND
)
11768 struct recvd_message msg
;
11771 msg
.message
= message
;
11772 msg
.flags
= sent
|wparam
|lparam
;
11775 msg
.descr
= "parent_menu_proc";
11779 return DefWindowProcA(hwnd
, message
, wp
, lp
);
11782 static void set_menu_style(HMENU hmenu
, DWORD style
)
11787 mi
.cbSize
= sizeof(mi
);
11788 mi
.fMask
= MIM_STYLE
;
11789 mi
.dwStyle
= style
;
11790 SetLastError(0xdeadbeef);
11791 ret
= pSetMenuInfo(hmenu
, &mi
);
11792 ok(ret
, "SetMenuInfo error %u\n", GetLastError());
11795 static DWORD
get_menu_style(HMENU hmenu
)
11800 mi
.cbSize
= sizeof(mi
);
11801 mi
.fMask
= MIM_STYLE
;
11803 SetLastError(0xdeadbeef);
11804 ret
= pGetMenuInfo(hmenu
, &mi
);
11805 ok(ret
, "GetMenuInfo error %u\n", GetLastError());
11810 static void test_menu_messages(void)
11814 HMENU hmenu
, hmenu_popup
;
11818 if (!pGetMenuInfo
|| !pSetMenuInfo
)
11820 win_skip("GetMenuInfo and/or SetMenuInfo are not available\n");
11824 cls
.lpfnWndProc
= parent_menu_proc
;
11825 cls
.cbClsExtra
= 0;
11826 cls
.cbWndExtra
= 0;
11827 cls
.hInstance
= GetModuleHandleA(0);
11829 cls
.hCursor
= LoadCursorA(0, IDC_ARROW
);
11830 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
11831 cls
.lpszMenuName
= NULL
;
11832 cls
.lpszClassName
= "TestMenuClass";
11833 UnregisterClass(cls
.lpszClassName
, cls
.hInstance
);
11834 if (!RegisterClassA(&cls
)) assert(0);
11836 SetLastError(0xdeadbeef);
11837 hwnd
= CreateWindowExA(0, "TestMenuClass", NULL
, WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
11838 100, 100, 200, 200, 0, 0, 0, NULL
);
11839 ok(hwnd
!= 0, "LoadMenuA error %u\n", GetLastError());
11841 SetLastError(0xdeadbeef);
11842 hmenu
= LoadMenuA(GetModuleHandle(0), MAKEINTRESOURCE(1));
11843 ok(hmenu
!= 0, "LoadMenuA error %u\n", GetLastError());
11845 SetMenu(hwnd
, hmenu
);
11846 SetForegroundWindow( hwnd
);
11848 set_menu_style(hmenu
, MNS_NOTIFYBYPOS
);
11849 style
= get_menu_style(hmenu
);
11850 ok(style
== MNS_NOTIFYBYPOS
, "expected MNS_NOTIFYBYPOS, got %u\n", style
);
11852 hmenu_popup
= GetSubMenu(hmenu
, 0);
11853 ok(hmenu_popup
!= 0, "GetSubMenu returned 0 for submenu 0\n");
11854 style
= get_menu_style(hmenu_popup
);
11855 ok(style
== 0, "expected 0, got %u\n", style
);
11857 hmenu_popup
= GetSubMenu(hmenu_popup
, 0);
11858 ok(hmenu_popup
!= 0, "GetSubMenu returned 0 for submenu 0\n");
11859 style
= get_menu_style(hmenu_popup
);
11860 ok(style
== 0, "expected 0, got %u\n", style
);
11863 trace("testing a popup menu command\n");
11865 keybd_event(VK_MENU
, 0, 0, 0);
11866 keybd_event('E', 0, 0, 0);
11867 keybd_event('E', 0, KEYEVENTF_KEYUP
, 0);
11868 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
11869 keybd_event(VK_RETURN
, 0, 0, 0);
11870 keybd_event(VK_RETURN
, 0, KEYEVENTF_KEYUP
, 0);
11871 while (PeekMessage(&msg
, 0, 0, 0, PM_REMOVE
))
11873 TranslateMessage(&msg
);
11874 DispatchMessage(&msg
);
11876 if (!sequence_cnt
) /* we didn't get any message */
11878 skip( "queuing key events not supported\n" );
11881 /* win98 queues only a WM_KEYUP and doesn't start menu tracking */
11882 if (sequence
[0].message
== WM_KEYUP
&& sequence
[0].wParam
== VK_MENU
)
11884 win_skip( "menu tracking through VK_MENU not supported\n" );
11887 ok_sequence(wm_popup_menu_1
, "popup menu command", FALSE
);
11889 /* Alt+F, Right, Enter */
11890 trace("testing submenu of a popup menu command\n");
11892 keybd_event(VK_MENU
, 0, 0, 0);
11893 keybd_event('F', 0, 0, 0);
11894 keybd_event('F', 0, KEYEVENTF_KEYUP
, 0);
11895 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
11896 keybd_event(VK_RIGHT
, 0, 0, 0);
11897 keybd_event(VK_RIGHT
, 0, KEYEVENTF_KEYUP
, 0);
11898 keybd_event(VK_RETURN
, 0, 0, 0);
11899 keybd_event(VK_RETURN
, 0, KEYEVENTF_KEYUP
, 0);
11900 while (PeekMessage(&msg
, 0, 0, 0, PM_REMOVE
))
11902 TranslateMessage(&msg
);
11903 DispatchMessage(&msg
);
11905 ok_sequence(wm_popup_menu_2
, "submenu of a popup menu command", FALSE
);
11907 set_menu_style(hmenu
, 0);
11908 style
= get_menu_style(hmenu
);
11909 ok(style
== 0, "expected 0, got %u\n", style
);
11911 hmenu_popup
= GetSubMenu(hmenu
, 0);
11912 ok(hmenu_popup
!= 0, "GetSubMenu returned 0 for submenu 0\n");
11913 set_menu_style(hmenu_popup
, MNS_NOTIFYBYPOS
);
11914 style
= get_menu_style(hmenu_popup
);
11915 ok(style
== MNS_NOTIFYBYPOS
, "expected MNS_NOTIFYBYPOS, got %u\n", style
);
11917 hmenu_popup
= GetSubMenu(hmenu_popup
, 0);
11918 ok(hmenu_popup
!= 0, "GetSubMenu returned 0 for submenu 0\n");
11919 style
= get_menu_style(hmenu_popup
);
11920 ok(style
== 0, "expected 0, got %u\n", style
);
11922 /* Alt+F, Right, Enter */
11923 trace("testing submenu of a popup menu command\n");
11925 keybd_event(VK_MENU
, 0, 0, 0);
11926 keybd_event('F', 0, 0, 0);
11927 keybd_event('F', 0, KEYEVENTF_KEYUP
, 0);
11928 keybd_event(VK_MENU
, 0, KEYEVENTF_KEYUP
, 0);
11929 keybd_event(VK_RIGHT
, 0, 0, 0);
11930 keybd_event(VK_RIGHT
, 0, KEYEVENTF_KEYUP
, 0);
11931 keybd_event(VK_RETURN
, 0, 0, 0);
11932 keybd_event(VK_RETURN
, 0, KEYEVENTF_KEYUP
, 0);
11933 while (PeekMessage(&msg
, 0, 0, 0, PM_REMOVE
))
11935 TranslateMessage(&msg
);
11936 DispatchMessage(&msg
);
11938 ok_sequence(wm_popup_menu_3
, "submenu of a popup menu command", FALSE
);
11941 DestroyWindow(hwnd
);
11942 DestroyMenu(hmenu
);
11946 static void test_paintingloop(void)
11950 paint_loop_done
= 0;
11951 hwnd
= CreateWindowExA(0x0,"PaintLoopWindowClass",
11952 "PaintLoopWindowClass",WS_OVERLAPPEDWINDOW
,
11953 100, 100, 100, 100, 0, 0, 0, NULL
);
11954 ok(hwnd
!= 0, "PaintLoop window error %u\n", GetLastError());
11955 ShowWindow(hwnd
,SW_NORMAL
);
11958 while (!paint_loop_done
)
11961 if (PeekMessageA(&msg
, 0, 0, 0, 1))
11963 TranslateMessage(&msg
);
11964 DispatchMessage(&msg
);
11967 DestroyWindow(hwnd
);
11970 static void test_defwinproc(void)
11974 int gotwmquit
= FALSE
;
11975 hwnd
= CreateWindowExA(0, "static", "test_defwndproc", WS_POPUP
, 0,0,0,0,0,0,0, NULL
);
11977 DefWindowProcA( hwnd
, WM_ENDSESSION
, 1, 0);
11978 while (PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
)) {
11979 if( msg
.message
== WM_QUIT
) gotwmquit
= TRUE
;
11980 DispatchMessageA( &msg
);
11982 ok( gotwmquit
== FALSE
, "Unexpected WM_QUIT message!\n");
11983 DestroyWindow( hwnd
);
11986 #define clear_clipboard(hwnd) clear_clipboard_(__LINE__, (hwnd))
11987 static void clear_clipboard_(int line
, HWND hWnd
)
11990 succ
= OpenClipboard(hWnd
);
11991 ok_(__FILE__
, line
)(succ
, "OpenClipboard failed, err=%u\n", GetLastError());
11992 succ
= EmptyClipboard();
11993 ok_(__FILE__
, line
)(succ
, "EmptyClipboard failed, err=%u\n", GetLastError());
11994 succ
= CloseClipboard();
11995 ok_(__FILE__
, line
)(succ
, "CloseClipboard failed, err=%u\n", GetLastError());
11998 #define expect_HWND(expected, got) expect_HWND_(__LINE__, (expected), (got))
11999 static void expect_HWND_(int line
, HWND expected
, HWND got
)
12001 ok_(__FILE__
, line
)(got
==expected
, "Expected %p, got %p\n", expected
, got
);
12004 static WNDPROC pOldViewerProc
;
12006 static LRESULT CALLBACK
recursive_viewer_proc(HWND hWnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
12008 static BOOL recursion_guard
;
12010 if (message
== WM_DRAWCLIPBOARD
&& !recursion_guard
)
12012 recursion_guard
= TRUE
;
12013 clear_clipboard(hWnd
);
12014 recursion_guard
= FALSE
;
12016 return CallWindowProcA(pOldViewerProc
, hWnd
, message
, wParam
, lParam
);
12019 static void test_clipboard_viewers(void)
12021 static struct message wm_change_cb_chain
[] =
12023 { WM_CHANGECBCHAIN
, sent
|wparam
|lparam
, 0, 0 },
12026 static const struct message wm_clipboard_destroyed
[] =
12028 { WM_DESTROYCLIPBOARD
, sent
|wparam
|lparam
, 0, 0 },
12031 static struct message wm_clipboard_changed
[] =
12033 { WM_DRAWCLIPBOARD
, sent
|wparam
|lparam
, 0, 0 },
12036 static struct message wm_clipboard_changed_and_owned
[] =
12038 { WM_DESTROYCLIPBOARD
, sent
|wparam
|lparam
, 0, 0 },
12039 { WM_DRAWCLIPBOARD
, sent
|wparam
|lparam
, 0, 0 },
12043 HINSTANCE hInst
= GetModuleHandleA(NULL
);
12044 HWND hWnd1
, hWnd2
, hWnd3
;
12048 hWnd1
= CreateWindowExA(0, "TestWindowClass", "Clipboard viewer test wnd 1",
12049 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
| WS_MAXIMIZEBOX
,
12050 CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
,
12051 GetDesktopWindow(), NULL
, hInst
, NULL
);
12052 hWnd2
= CreateWindowExA(0, "SimpleWindowClass", "Clipboard viewer test wnd 2",
12053 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
| WS_MAXIMIZEBOX
,
12054 CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
,
12055 GetDesktopWindow(), NULL
, hInst
, NULL
);
12056 hWnd3
= CreateWindowExA(0, "SimpleWindowClass", "Clipboard viewer test wnd 3",
12057 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
| WS_MAXIMIZEBOX
,
12058 CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
,
12059 GetDesktopWindow(), NULL
, hInst
, NULL
);
12060 trace("clipbd viewers: hWnd1=%p, hWnd2=%p, hWnd3=%p\n", hWnd1
, hWnd2
, hWnd3
);
12061 assert(hWnd1
&& hWnd2
&& hWnd3
);
12065 /* Test getting the clipboard viewer and setting the viewer to NULL. */
12066 hOrigViewer
= GetClipboardViewer();
12067 hRet
= SetClipboardViewer(NULL
);
12068 ok_sequence(WmEmptySeq
, "set viewer to NULL", FALSE
);
12069 expect_HWND(hOrigViewer
, hRet
);
12070 expect_HWND(NULL
, GetClipboardViewer());
12072 /* Test registering hWnd1 as a viewer. */
12073 hRet
= SetClipboardViewer(hWnd1
);
12074 wm_clipboard_changed
[0].wParam
= (WPARAM
) GetClipboardOwner();
12075 ok_sequence(wm_clipboard_changed
, "set viewer NULL->1", FALSE
);
12076 expect_HWND(NULL
, hRet
);
12077 expect_HWND(hWnd1
, GetClipboardViewer());
12079 /* Test that changing the clipboard actually refreshes the registered viewer. */
12080 clear_clipboard(hWnd1
);
12081 wm_clipboard_changed
[0].wParam
= (WPARAM
) GetClipboardOwner();
12082 ok_sequence(wm_clipboard_changed
, "clear clipbd (viewer=owner=1)", FALSE
);
12084 /* Again, but with different owner. */
12085 clear_clipboard(hWnd2
);
12086 wm_clipboard_changed_and_owned
[1].wParam
= (WPARAM
) GetClipboardOwner();
12087 ok_sequence(wm_clipboard_changed_and_owned
, "clear clipbd (viewer=1, owner=2)", FALSE
);
12089 /* Test re-registering same window. */
12090 hRet
= SetClipboardViewer(hWnd1
);
12091 wm_clipboard_changed
[0].wParam
= (WPARAM
) GetClipboardOwner();
12092 ok_sequence(wm_clipboard_changed
, "set viewer 1->1", FALSE
);
12093 expect_HWND(hWnd1
, hRet
);
12094 expect_HWND(hWnd1
, GetClipboardViewer());
12096 /* Test ChangeClipboardChain. */
12097 ChangeClipboardChain(hWnd2
, hWnd3
);
12098 wm_change_cb_chain
[0].wParam
= (WPARAM
) hWnd2
;
12099 wm_change_cb_chain
[0].lParam
= (LPARAM
) hWnd3
;
12100 ok_sequence(wm_change_cb_chain
, "change chain (viewer=1, remove=2, next=3)", FALSE
);
12101 expect_HWND(hWnd1
, GetClipboardViewer());
12103 ChangeClipboardChain(hWnd2
, NULL
);
12104 wm_change_cb_chain
[0].wParam
= (WPARAM
) hWnd2
;
12105 wm_change_cb_chain
[0].lParam
= 0;
12106 ok_sequence(wm_change_cb_chain
, "change chain (viewer=1, remove=2, next=NULL)", FALSE
);
12107 expect_HWND(hWnd1
, GetClipboardViewer());
12109 ChangeClipboardChain(NULL
, hWnd2
);
12110 ok_sequence(WmEmptySeq
, "change chain (viewer=1, remove=NULL, next=2)", TRUE
);
12111 expect_HWND(hWnd1
, GetClipboardViewer());
12113 /* Actually change clipboard viewer with ChangeClipboardChain. */
12114 ChangeClipboardChain(hWnd1
, hWnd2
);
12115 ok_sequence(WmEmptySeq
, "change chain (viewer=remove=1, next=2)", FALSE
);
12116 expect_HWND(hWnd2
, GetClipboardViewer());
12118 /* Test that no refresh messages are sent when viewer has unregistered. */
12119 clear_clipboard(hWnd2
);
12120 ok_sequence(WmEmptySeq
, "clear clipd (viewer=2, owner=1)", FALSE
);
12122 /* Register hWnd1 again. */
12123 ChangeClipboardChain(hWnd2
, hWnd1
);
12124 ok_sequence(WmEmptySeq
, "change chain (viewer=remove=2, next=1)", FALSE
);
12125 expect_HWND(hWnd1
, GetClipboardViewer());
12127 /* Subclass hWnd1 so that when it receives a WM_DRAWCLIPBOARD message, it
12128 * changes the clipboard. When this happens, the system shouldn't send
12129 * another WM_DRAWCLIPBOARD (as this could cause an infinite loop).
12131 pOldViewerProc
= (WNDPROC
) SetWindowLongPtrA(hWnd1
, GWLP_WNDPROC
, (LONG_PTR
) recursive_viewer_proc
);
12132 clear_clipboard(hWnd2
);
12133 /* The clipboard owner is changed in recursive_viewer_proc: */
12134 wm_clipboard_changed
[0].wParam
= (WPARAM
) hWnd2
;
12135 ok_sequence(wm_clipboard_changed
, "recursive clear clipbd (viewer=1, owner=2)", TRUE
);
12137 /* Test unregistering. */
12138 ChangeClipboardChain(hWnd1
, NULL
);
12139 ok_sequence(WmEmptySeq
, "change chain (viewer=remove=1, next=NULL)", FALSE
);
12140 expect_HWND(NULL
, GetClipboardViewer());
12142 clear_clipboard(hWnd1
);
12143 ok_sequence(wm_clipboard_destroyed
, "clear clipbd (no viewer, owner=1)", FALSE
);
12145 DestroyWindow(hWnd1
);
12146 DestroyWindow(hWnd2
);
12147 DestroyWindow(hWnd3
);
12148 SetClipboardViewer(hOrigViewer
);
12151 static void test_PostMessage(void)
12153 static const struct
12159 { HWND_TOP
/* 0 */, TRUE
},
12160 { HWND_BROADCAST
, TRUE
},
12161 { HWND_BOTTOM
, TRUE
},
12162 { HWND_TOPMOST
, TRUE
},
12163 { HWND_NOTOPMOST
, FALSE
},
12164 { HWND_MESSAGE
, FALSE
},
12165 { (HWND
)0xdeadbeef, FALSE
}
12171 static const WCHAR staticW
[] = {'s','t','a','t','i','c',0};
12173 SetLastError(0xdeadbeef);
12174 hwnd
= CreateWindowExW(0, staticW
, NULL
, WS_POPUP
, 0,0,0,0,0,0,0, NULL
);
12175 if (!hwnd
&& GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
)
12177 win_skip("Skipping some PostMessage tests on Win9x/WinMe\n");
12184 PostMessage(hwnd
, WM_USER
+1, 0x1234, 0x5678);
12185 PostMessage(0, WM_USER
+2, 0x5678, 0x1234);
12187 for (i
= 0; i
< sizeof(data
)/sizeof(data
[0]); i
++)
12189 memset(&msg
, 0xab, sizeof(msg
));
12190 ret
= PeekMessageA(&msg
, data
[i
].hwnd
, 0, 0, PM_NOREMOVE
);
12191 ok(ret
== data
[i
].ret
, "%d: hwnd %p expected %d, got %d\n", i
, data
[i
].hwnd
, data
[i
].ret
, ret
);
12195 ok(ret
&& msg
.hwnd
== 0 && msg
.message
== WM_USER
+2 &&
12196 msg
.wParam
== 0x5678 && msg
.lParam
== 0x1234,
12197 "%d: got ret %d hwnd %p msg %04x wParam %08lx lParam %08lx instead of TRUE/0/WM_USER+2/0x5678/0x1234\n",
12198 i
, ret
, msg
.hwnd
, msg
.message
, msg
.wParam
, msg
.lParam
);
12200 ok(ret
&& msg
.hwnd
== hwnd
&& msg
.message
== WM_USER
+1 &&
12201 msg
.wParam
== 0x1234 && msg
.lParam
== 0x5678,
12202 "%d: got ret %d hwnd %p msg %04x wParam %08lx lParam %08lx instead of TRUE/%p/WM_USER+1/0x1234/0x5678\n",
12203 i
, ret
, msg
.hwnd
, msg
.message
, msg
.wParam
, msg
.lParam
, msg
.hwnd
);
12207 DestroyWindow(hwnd
);
12211 static const struct
12215 } wait_idle_expect
[] =
12217 /* 0 */ { WAIT_TIMEOUT
, WAIT_TIMEOUT
, FALSE
},
12218 { WAIT_TIMEOUT
, 0, FALSE
},
12219 { WAIT_TIMEOUT
, 0, FALSE
},
12220 { WAIT_TIMEOUT
, WAIT_TIMEOUT
, FALSE
},
12221 { WAIT_TIMEOUT
, WAIT_TIMEOUT
, FALSE
},
12222 /* 5 */ { WAIT_TIMEOUT
, 0, FALSE
},
12223 { WAIT_TIMEOUT
, 0, FALSE
},
12224 { WAIT_TIMEOUT
, WAIT_TIMEOUT
, FALSE
},
12227 /* 10 */ { 0, 0, FALSE
},
12229 { 0, WAIT_TIMEOUT
, FALSE
},
12232 /* 15 */ { 0, 0, FALSE
},
12233 { WAIT_TIMEOUT
, 0, FALSE
},
12234 { WAIT_TIMEOUT
, 0, FALSE
},
12235 { WAIT_TIMEOUT
, 0, FALSE
},
12236 { WAIT_TIMEOUT
, 0, FALSE
},
12237 /* 20 */ { WAIT_TIMEOUT
, 0, FALSE
},
12240 static DWORD CALLBACK
do_wait_idle_child_thread( void *arg
)
12244 PeekMessage( &msg
, 0, 0, 0, PM_NOREMOVE
);
12246 MsgWaitForMultipleObjects( 0, NULL
, FALSE
, 100, QS_ALLINPUT
);
12250 static void do_wait_idle_child( int arg
)
12257 HANDLE start_event
= OpenEventA( EVENT_ALL_ACCESS
, FALSE
, "test_WaitForInputIdle_start" );
12258 HANDLE end_event
= OpenEventA( EVENT_ALL_ACCESS
, FALSE
, "test_WaitForInputIdle_end" );
12260 memset( &cls
, 0, sizeof(cls
) );
12261 cls
.lpfnWndProc
= DefWindowProc
;
12262 cls
.hbrBackground
= (HBRUSH
)(COLOR_WINDOW
+ 1);
12263 cls
.hCursor
= LoadCursor(0, IDC_ARROW
);
12264 cls
.lpszClassName
= "TestClass";
12265 RegisterClass( &cls
);
12267 PeekMessage( &msg
, 0, 0, 0, PM_NOREMOVE
); /* create the msg queue */
12269 ok( start_event
!= 0, "failed to create start event, error %u\n", GetLastError() );
12270 ok( end_event
!= 0, "failed to create end event, error %u\n", GetLastError() );
12275 SetEvent( start_event
);
12278 SetEvent( start_event
);
12280 PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
);
12283 SetEvent( start_event
);
12285 PeekMessage( &msg
, 0, 0, 0, PM_NOREMOVE
);
12286 PostThreadMessage( GetCurrentThreadId(), WM_COMMAND
, 0x1234, 0xabcd );
12287 PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
);
12290 SetEvent( start_event
);
12292 SendMessage( HWND_BROADCAST
, WM_WININICHANGE
, 0, 0 );
12295 SetEvent( start_event
);
12297 hwnd
= CreateWindowExA(0, "TestClass", NULL
, WS_POPUP
|WS_VISIBLE
, 0, 0, 10, 10, 0, 0, 0, NULL
);
12298 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
|PM_NOYIELD
)) DispatchMessage( &msg
);
12301 SetEvent( start_event
);
12303 hwnd
= CreateWindowExA(0, "TestClass", NULL
, WS_POPUP
|WS_VISIBLE
, 0, 0, 10, 10, 0, 0, 0, NULL
);
12304 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
12307 SetEvent( start_event
);
12309 hwnd
= CreateWindowExA(0, "TestClass", NULL
, WS_POPUP
|WS_VISIBLE
, 0, 0, 10, 10, 0, 0, 0, NULL
);
12310 while (PeekMessage( &msg
, 0, 0, 0, PM_NOREMOVE
))
12312 GetMessage( &msg
, 0, 0, 0 );
12313 DispatchMessage( &msg
);
12317 SetEvent( start_event
);
12319 hwnd
= CreateWindowExA(0, "TestClass", NULL
, WS_POPUP
|WS_VISIBLE
, 0, 0, 10, 10, 0, 0, 0, NULL
);
12320 SetTimer( hwnd
, 3, 1, NULL
);
12322 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
|PM_NOYIELD
)) DispatchMessage( &msg
);
12325 SetEvent( start_event
);
12327 PeekMessage( &msg
, 0, 0, 0, PM_NOREMOVE
);
12328 MsgWaitForMultipleObjects( 0, NULL
, FALSE
, 100, QS_ALLINPUT
);
12331 SetEvent( start_event
);
12333 hwnd
= CreateWindowExA(0, "TestClass", NULL
, WS_POPUP
|WS_VISIBLE
, 0, 0, 10, 10, 0, 0, 0, NULL
);
12334 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
12335 for (;;) GetMessage( &msg
, 0, 0, 0 );
12338 SetEvent( start_event
);
12340 hwnd
= CreateWindowExA(0, "TestClass", NULL
, WS_POPUP
|WS_VISIBLE
, 0, 0, 10, 10, 0, 0, 0, NULL
);
12341 SetTimer( hwnd
, 3, 1, NULL
);
12343 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
12346 SetEvent( start_event
);
12348 return; /* exiting the process makes WaitForInputIdle return success too */
12350 PeekMessage( &msg
, 0, 0, 0, PM_NOREMOVE
);
12352 MsgWaitForMultipleObjects( 0, NULL
, FALSE
, 100, QS_ALLINPUT
);
12353 SetEvent( start_event
);
12356 SetEvent( start_event
);
12357 PeekMessage( &msg
, 0, 0, 0, PM_NOREMOVE
);
12359 thread
= CreateThread( NULL
, 0, do_wait_idle_child_thread
, NULL
, 0, &id
);
12360 WaitForSingleObject( thread
, 10000 );
12361 CloseHandle( thread
);
12364 SetEvent( start_event
);
12366 PeekMessage( &msg
, HWND_TOPMOST
, 0, 0, PM_NOREMOVE
);
12369 SetEvent( start_event
);
12371 PeekMessage( &msg
, HWND_BROADCAST
, 0, 0, PM_NOREMOVE
);
12374 SetEvent( start_event
);
12376 PeekMessage( &msg
, HWND_BOTTOM
, 0, 0, PM_NOREMOVE
);
12379 SetEvent( start_event
);
12381 PeekMessage( &msg
, (HWND
)0xdeadbeef, 0, 0, PM_NOREMOVE
);
12384 SetEvent( start_event
);
12386 PeekMessage( &msg
, HWND_NOTOPMOST
, 0, 0, PM_NOREMOVE
);
12389 SetEvent( start_event
);
12391 PeekMessage( &msg
, HWND_MESSAGE
, 0, 0, PM_NOREMOVE
);
12394 SetEvent( start_event
);
12396 PeekMessage( &msg
, GetDesktopWindow(), 0, 0, PM_NOREMOVE
);
12399 WaitForSingleObject( end_event
, 2000 );
12400 CloseHandle( start_event
);
12401 CloseHandle( end_event
);
12402 if (hwnd
) DestroyWindow( hwnd
);
12405 static LRESULT CALLBACK
wait_idle_proc( HWND hwnd
, UINT msg
, WPARAM wp
, LPARAM lp
)
12407 if (msg
== WM_WININICHANGE
) Sleep( 200 ); /* make sure the child waits */
12408 return DefWindowProcA( hwnd
, msg
, wp
, lp
);
12411 static DWORD CALLBACK
wait_idle_thread( void *arg
)
12417 memset( &cls
, 0, sizeof(cls
) );
12418 cls
.lpfnWndProc
= wait_idle_proc
;
12419 cls
.hbrBackground
= (HBRUSH
)(COLOR_WINDOW
+ 1);
12420 cls
.hCursor
= LoadCursor(0, IDC_ARROW
);
12421 cls
.lpszClassName
= "TestClass";
12422 RegisterClass( &cls
);
12424 hwnd
= CreateWindowExA(0, "TestClass", NULL
, WS_POPUP
, 0, 0, 10, 10, 0, 0, 0, NULL
);
12425 while (GetMessage( &msg
, 0, 0, 0 )) DispatchMessage( &msg
);
12426 DestroyWindow(hwnd
);
12430 static void test_WaitForInputIdle( char *argv0
)
12432 char path
[MAX_PATH
];
12433 PROCESS_INFORMATION pi
;
12434 STARTUPINFOA startup
;
12436 HANDLE start_event
, end_event
, thread
;
12439 const IMAGE_DOS_HEADER
*dos
= (const IMAGE_DOS_HEADER
*)GetModuleHandleA(0);
12440 const IMAGE_NT_HEADERS
*nt
= (const IMAGE_NT_HEADERS
*)((const char *)dos
+ dos
->e_lfanew
);
12441 BOOL console_app
= (nt
->OptionalHeader
.Subsystem
!= IMAGE_SUBSYSTEM_WINDOWS_GUI
);
12443 if (console_app
) /* build the test with -mwindows for better coverage */
12444 trace( "not built as a GUI app, WaitForInputIdle may not be fully tested\n" );
12446 start_event
= CreateEventA(NULL
, 0, 0, "test_WaitForInputIdle_start");
12447 end_event
= CreateEventA(NULL
, 0, 0, "test_WaitForInputIdle_end");
12448 ok(start_event
!= 0, "failed to create start event, error %u\n", GetLastError());
12449 ok(end_event
!= 0, "failed to create end event, error %u\n", GetLastError());
12451 memset( &startup
, 0, sizeof(startup
) );
12452 startup
.cb
= sizeof(startup
);
12453 startup
.dwFlags
= STARTF_USESHOWWINDOW
;
12454 startup
.wShowWindow
= SW_SHOWNORMAL
;
12456 thread
= CreateThread( NULL
, 0, wait_idle_thread
, NULL
, 0, &id
);
12458 for (i
= 0; i
< sizeof(wait_idle_expect
)/sizeof(wait_idle_expect
[0]); i
++)
12460 ResetEvent( start_event
);
12461 ResetEvent( end_event
);
12462 sprintf( path
, "%s msg %u", argv0
, i
);
12463 ret
= CreateProcessA( NULL
, path
, NULL
, NULL
, TRUE
, 0, NULL
, NULL
, &startup
, &pi
);
12464 ok( ret
, "CreateProcess '%s' failed err %u.\n", path
, GetLastError() );
12467 ret
= WaitForSingleObject( start_event
, 5000 );
12468 ok( ret
== WAIT_OBJECT_0
, "%u: WaitForSingleObject failed\n", i
);
12469 if (ret
== WAIT_OBJECT_0
)
12471 ret
= WaitForInputIdle( pi
.hProcess
, 1000 );
12472 if (ret
== WAIT_FAILED
)
12474 ret
== wait_idle_expect
[i
].exp
||
12475 broken(ret
== wait_idle_expect
[i
].broken
),
12476 "%u: WaitForInputIdle error %08x expected %08x\n",
12477 i
, ret
, wait_idle_expect
[i
].exp
);
12478 else if (wait_idle_expect
[i
].todo
)
12480 ok( ret
== wait_idle_expect
[i
].exp
|| broken(ret
== wait_idle_expect
[i
].broken
),
12481 "%u: WaitForInputIdle error %08x expected %08x\n",
12482 i
, ret
, wait_idle_expect
[i
].exp
);
12484 ok( ret
== wait_idle_expect
[i
].exp
|| broken(ret
== wait_idle_expect
[i
].broken
),
12485 "%u: WaitForInputIdle error %08x expected %08x\n",
12486 i
, ret
, wait_idle_expect
[i
].exp
);
12487 SetEvent( end_event
);
12488 WaitForSingleObject( pi
.hProcess
, 1000 ); /* give it a chance to exit on its own */
12490 TerminateProcess( pi
.hProcess
, 0 ); /* just in case */
12491 winetest_wait_child_process( pi
.hProcess
);
12492 ret
= WaitForInputIdle( pi
.hProcess
, 100 );
12493 ok( ret
== WAIT_FAILED
, "%u: WaitForInputIdle after exit error %08x\n", i
, ret
);
12494 CloseHandle( pi
.hProcess
);
12495 CloseHandle( pi
.hThread
);
12498 CloseHandle( start_event
);
12499 PostThreadMessage( id
, WM_QUIT
, 0, 0 );
12500 WaitForSingleObject( thread
, 10000 );
12501 CloseHandle( thread
);
12508 BOOL (WINAPI
*pIsWinEventHookInstalled
)(DWORD
)= 0;/*GetProcAddress(user32, "IsWinEventHookInstalled");*/
12510 int argc
= winetest_get_mainargs( &test_argv
);
12514 /* Child process. */
12515 sscanf (test_argv
[2], "%d", (unsigned int *) &arg
);
12516 do_wait_idle_child( arg
);
12522 if (!RegisterWindowClasses()) assert(0);
12524 if (pSetWinEventHook
)
12526 hEvent_hook
= pSetWinEventHook(EVENT_MIN
, EVENT_MAX
,
12527 GetModuleHandleA(0), win_event_proc
,
12528 0, GetCurrentThreadId(),
12529 WINEVENT_INCONTEXT
);
12530 if (pIsWinEventHookInstalled
&& hEvent_hook
)
12533 for (event
= EVENT_MIN
; event
<= EVENT_MAX
; event
++)
12534 ok(pIsWinEventHookInstalled(event
), "IsWinEventHookInstalled(%u) failed\n", event
);
12537 if (!hEvent_hook
) win_skip( "no win event hook support\n" );
12539 cbt_hook_thread_id
= GetCurrentThreadId();
12540 hCBT_hook
= SetWindowsHookExA(WH_CBT
, cbt_hook_proc
, 0, GetCurrentThreadId());
12541 if (!hCBT_hook
) win_skip( "cannot set global hook, will skip hook tests\n" );
12545 /* Fix message sequences before removing 4 lines below */
12547 if (pUnhookWinEvent
&& hEvent_hook
)
12549 ret
= pUnhookWinEvent(hEvent_hook
);
12550 ok( ret
, "UnhookWinEvent error %d\n", GetLastError());
12551 pUnhookWinEvent
= 0;
12556 test_PostMessage();
12558 test_PeekMessage();
12559 test_PeekMessage2();
12560 test_WaitForInputIdle( test_argv
[0] );
12561 test_scrollwindowex();
12563 test_setwindowpos();
12565 invisible_parent_tests();
12566 test_mdi_messages();
12567 test_button_messages();
12568 test_static_messages();
12569 test_listbox_messages();
12570 test_combobox_messages();
12571 test_wmime_keydown_message();
12572 test_paint_messages();
12573 test_interthread_messages();
12574 test_message_conversion();
12575 test_accelerators();
12577 test_timers_no_wnd();
12578 if (hCBT_hook
) test_set_hook();
12579 test_DestroyWindow();
12580 test_DispatchMessage();
12581 test_SendMessageTimeout();
12582 test_edit_messages();
12583 test_quit_message();
12584 test_SetActiveWindow();
12586 if (!pTrackMouseEvent
)
12587 win_skip("TrackMouseEvent is not available\n");
12589 test_TrackMouseEvent();
12591 test_SetWindowRgn();
12593 test_dialog_messages();
12594 test_nullCallback();
12595 test_dbcs_wm_char();
12596 test_menu_messages();
12597 test_paintingloop();
12599 test_clipboard_viewers();
12600 /* keep it the last test, under Windows it tends to break the tests
12601 * which rely on active/foreground windows being correct.
12603 test_SetForegroundWindow();
12605 UnhookWindowsHookEx(hCBT_hook
);
12606 if (pUnhookWinEvent
&& hEvent_hook
)
12608 ret
= pUnhookWinEvent(hEvent_hook
);
12609 ok( ret
, "UnhookWinEvent error %d\n", GetLastError());
12610 SetLastError(0xdeadbeef);
12611 ok(!pUnhookWinEvent(hEvent_hook
), "UnhookWinEvent succeeded\n");
12612 ok(GetLastError() == ERROR_INVALID_HANDLE
|| /* Win2k */
12613 GetLastError() == 0xdeadbeef, /* Win9x */
12614 "unexpected error %d\n", GetLastError());