crypt32: Initialize mask when allocating it.
[wine] / dlls / user32 / winpos.c
1 /*
2  * Window position related functions.
3  *
4  * Copyright 1993, 1994, 1995 Alexandre Julliard
5  *                       1995, 1996, 1999 Alex Korobka
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20  */
21
22 #include "config.h"
23 #include "wine/port.h"
24
25 #include <stdarg.h>
26 #include <string.h>
27 #include "ntstatus.h"
28 #define WIN32_NO_STATUS
29 #include "winerror.h"
30 #include "windef.h"
31 #include "winbase.h"
32 #include "wingdi.h"
33 #include "winerror.h"
34 #include "wine/server.h"
35 #include "controls.h"
36 #include "user_private.h"
37 #include "win.h"
38 #include "wine/debug.h"
39
40 WINE_DEFAULT_DEBUG_CHANNEL(win);
41
42 #define SWP_AGG_NOGEOMETRYCHANGE \
43     (SWP_NOSIZE | SWP_NOCLIENTSIZE | SWP_NOZORDER)
44 #define SWP_AGG_NOPOSCHANGE \
45     (SWP_NOSIZE | SWP_NOMOVE | SWP_NOCLIENTSIZE | SWP_NOCLIENTMOVE | SWP_NOZORDER)
46 #define SWP_AGG_STATUSFLAGS \
47     (SWP_AGG_NOPOSCHANGE | SWP_FRAMECHANGED | SWP_HIDEWINDOW | SWP_SHOWWINDOW)
48
49 #define HAS_DLGFRAME(style,exStyle) \
50     (((exStyle) & WS_EX_DLGMODALFRAME) || \
51      (((style) & WS_DLGFRAME) && !((style) & WS_BORDER)))
52
53 #define HAS_THICKFRAME(style) \
54     (((style) & WS_THICKFRAME) && \
55      !(((style) & (WS_DLGFRAME|WS_BORDER)) == WS_DLGFRAME))
56
57 #define EMPTYPOINT(pt)          ((*(LONG*)&(pt)) == -1)
58
59 #define PLACE_MIN               0x0001
60 #define PLACE_MAX               0x0002
61 #define PLACE_RECT              0x0004
62
63
64 #define DWP_MAGIC  ((INT)('W' | ('P' << 8) | ('O' << 16) | ('S' << 24)))
65
66 typedef struct
67 {
68     INT       actualCount;
69     INT       suggestedCount;
70     BOOL      valid;
71     INT       wMagic;
72     HWND      hwndParent;
73     WINDOWPOS winPos[1];
74 } DWP;
75
76 typedef struct
77 {
78     RECT16   rectNormal;
79     POINT16  ptIconPos;
80     POINT16  ptMaxPos;
81     HWND     hwndIconTitle;
82 } INTERNALPOS, *LPINTERNALPOS;
83
84 /* ----- internal functions ----- */
85
86 static const WCHAR SysIP_W[] = { 'S','y','s','I','P',0 };
87
88 static inline INTERNALPOS *get_internal_pos( HWND hwnd )
89 {
90     return GetPropW( hwnd, SysIP_W );
91 }
92
93 static inline void set_internal_pos( HWND hwnd, INTERNALPOS *pos )
94 {
95     SetPropW( hwnd, SysIP_W, pos );
96 }
97
98 /***********************************************************************
99  *           WINPOS_CheckInternalPos
100  *
101  * Called when a window is destroyed.
102  */
103 void WINPOS_CheckInternalPos( HWND hwnd )
104 {
105     LPINTERNALPOS lpPos = get_internal_pos( hwnd );
106
107     if ( lpPos )
108     {
109         if( IsWindow(lpPos->hwndIconTitle) )
110             DestroyWindow( lpPos->hwndIconTitle );
111         HeapFree( GetProcessHeap(), 0, lpPos );
112     }
113 }
114
115 /***********************************************************************
116  *              ArrangeIconicWindows (USER32.@)
117  */
118 UINT WINAPI ArrangeIconicWindows( HWND parent )
119 {
120     RECT rectParent;
121     HWND hwndChild;
122     INT x, y, xspacing, yspacing;
123
124     GetClientRect( parent, &rectParent );
125     x = rectParent.left;
126     y = rectParent.bottom;
127     xspacing = GetSystemMetrics(SM_CXICONSPACING);
128     yspacing = GetSystemMetrics(SM_CYICONSPACING);
129
130     hwndChild = GetWindow( parent, GW_CHILD );
131     while (hwndChild)
132     {
133         if( IsIconic( hwndChild ) )
134         {
135             WINPOS_ShowIconTitle( hwndChild, FALSE );
136
137             SetWindowPos( hwndChild, 0, x + (xspacing - GetSystemMetrics(SM_CXICON)) / 2,
138                             y - yspacing - GetSystemMetrics(SM_CYICON)/2, 0, 0,
139                             SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE );
140             if( IsWindow(hwndChild) )
141                 WINPOS_ShowIconTitle(hwndChild , TRUE );
142
143             if (x <= rectParent.right - xspacing) x += xspacing;
144             else
145             {
146                 x = rectParent.left;
147                 y -= yspacing;
148             }
149         }
150         hwndChild = GetWindow( hwndChild, GW_HWNDNEXT );
151     }
152     return yspacing;
153 }
154
155
156 /***********************************************************************
157  *              SwitchToThisWindow (USER32.@)
158  */
159 void WINAPI SwitchToThisWindow( HWND hwnd, BOOL restore )
160 {
161     ShowWindow( hwnd, restore ? SW_RESTORE : SW_SHOWMINIMIZED );
162 }
163
164
165 /***********************************************************************
166  *              GetWindowRect (USER32.@)
167  */
168 BOOL WINAPI GetWindowRect( HWND hwnd, LPRECT rect )
169 {
170     BOOL ret = WIN_GetRectangles( hwnd, rect, NULL );
171     if (ret)
172     {
173         MapWindowPoints( GetAncestor( hwnd, GA_PARENT ), 0, (POINT *)rect, 2 );
174         TRACE( "hwnd %p (%d,%d)-(%d,%d)\n",
175                hwnd, rect->left, rect->top, rect->right, rect->bottom);
176     }
177     return ret;
178 }
179
180
181 /***********************************************************************
182  *              GetWindowRgn (USER32.@)
183  */
184 int WINAPI GetWindowRgn ( HWND hwnd, HRGN hrgn )
185 {
186     int nRet = ERROR;
187     NTSTATUS status;
188     HRGN win_rgn = 0;
189     RGNDATA *data;
190     size_t size = 256;
191
192     do
193     {
194         if (!(data = HeapAlloc( GetProcessHeap(), 0, sizeof(*data) + size - 1 )))
195         {
196             SetLastError( ERROR_OUTOFMEMORY );
197             return ERROR;
198         }
199         SERVER_START_REQ( get_window_region )
200         {
201             req->window = hwnd;
202             wine_server_set_reply( req, data->Buffer, size );
203             if (!(status = wine_server_call( req )))
204             {
205                 size_t reply_size = wine_server_reply_size( reply );
206                 if (reply_size)
207                 {
208                     data->rdh.dwSize   = sizeof(data->rdh);
209                     data->rdh.iType    = RDH_RECTANGLES;
210                     data->rdh.nCount   = reply_size / sizeof(RECT);
211                     data->rdh.nRgnSize = reply_size;
212                     win_rgn = ExtCreateRegion( NULL, size, data );
213                 }
214             }
215             else size = reply->total_size;
216         }
217         SERVER_END_REQ;
218         HeapFree( GetProcessHeap(), 0, data );
219     } while (status == STATUS_BUFFER_OVERFLOW);
220
221     if (status) SetLastError( RtlNtStatusToDosError(status) );
222     else if (win_rgn)
223     {
224         nRet = CombineRgn( hrgn, win_rgn, 0, RGN_COPY );
225         DeleteObject( win_rgn );
226     }
227     return nRet;
228 }
229
230
231 /***********************************************************************
232  *              SetWindowRgn (USER32.@)
233  */
234 int WINAPI SetWindowRgn( HWND hwnd, HRGN hrgn, BOOL bRedraw )
235 {
236     static const RECT empty_rect;
237     BOOL ret;
238
239     if (hrgn)
240     {
241         RGNDATA *data;
242         DWORD size;
243
244         if (!(size = GetRegionData( hrgn, 0, NULL ))) return FALSE;
245         if (!(data = HeapAlloc( GetProcessHeap(), 0, size ))) return FALSE;
246         if (!GetRegionData( hrgn, size, data ))
247         {
248             HeapFree( GetProcessHeap(), 0, data );
249             return FALSE;
250         }
251         SERVER_START_REQ( set_window_region )
252         {
253             req->window = hwnd;
254             req->redraw = (bRedraw != 0);
255             if (data->rdh.nCount)
256                 wine_server_add_data( req, data->Buffer, data->rdh.nCount * sizeof(RECT) );
257             else
258                 wine_server_add_data( req, &empty_rect, sizeof(empty_rect) );
259             ret = !wine_server_call_err( req );
260         }
261         SERVER_END_REQ;
262     }
263     else  /* clear existing region */
264     {
265         SERVER_START_REQ( set_window_region )
266         {
267             req->window = hwnd;
268             req->redraw = (bRedraw != 0);
269             ret = !wine_server_call_err( req );
270         }
271         SERVER_END_REQ;
272     }
273
274     if (ret) ret = USER_Driver->pSetWindowRgn( hwnd, hrgn, bRedraw );
275
276     if (ret)
277     {
278         UINT swp_flags = SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE|SWP_FRAMECHANGED;
279         if (hrgn) swp_flags |= SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE;
280         if (!bRedraw) swp_flags |= SWP_NOREDRAW;
281         SetWindowPos( hwnd, 0, 0, 0, 0, 0, swp_flags );
282     }
283     return ret;
284 }
285
286
287 /***********************************************************************
288  *              GetClientRect (USER32.@)
289  */
290 BOOL WINAPI GetClientRect( HWND hwnd, LPRECT rect )
291 {
292     BOOL ret;
293
294     if ((ret = WIN_GetRectangles( hwnd, NULL, rect )))
295     {
296         rect->right -= rect->left;
297         rect->bottom -= rect->top;
298         rect->left = rect->top = 0;
299     }
300     return ret;
301 }
302
303
304 /*******************************************************************
305  *              ClientToScreen (USER32.@)
306  */
307 BOOL WINAPI ClientToScreen( HWND hwnd, LPPOINT lppnt )
308 {
309     MapWindowPoints( hwnd, 0, lppnt, 1 );
310     return TRUE;
311 }
312
313
314 /*******************************************************************
315  *              ScreenToClient (USER32.@)
316  */
317 BOOL WINAPI ScreenToClient( HWND hwnd, LPPOINT lppnt )
318 {
319     MapWindowPoints( 0, hwnd, lppnt, 1 );
320     return TRUE;
321 }
322
323
324 /***********************************************************************
325  *           list_children_from_point
326  *
327  * Get the list of children that can contain point from the server.
328  * Point is in screen coordinates.
329  * Returned list must be freed by caller.
330  */
331 static HWND *list_children_from_point( HWND hwnd, POINT pt )
332 {
333     HWND *list;
334     int size = 32;
335
336     for (;;)
337     {
338         int count = 0;
339
340         if (!(list = HeapAlloc( GetProcessHeap(), 0, size * sizeof(HWND) ))) break;
341
342         SERVER_START_REQ( get_window_children_from_point )
343         {
344             req->parent = hwnd;
345             req->x = pt.x;
346             req->y = pt.y;
347             wine_server_set_reply( req, list, (size-1) * sizeof(HWND) );
348             if (!wine_server_call( req )) count = reply->count;
349         }
350         SERVER_END_REQ;
351         if (count && count < size)
352         {
353             list[count] = 0;
354             return list;
355         }
356         HeapFree( GetProcessHeap(), 0, list );
357         if (!count) break;
358         size = count + 1;  /* restart with a large enough buffer */
359     }
360     return NULL;
361 }
362
363
364 /***********************************************************************
365  *           WINPOS_WindowFromPoint
366  *
367  * Find the window and hittest for a given point.
368  */
369 HWND WINPOS_WindowFromPoint( HWND hwndScope, POINT pt, INT *hittest )
370 {
371     int i, res;
372     HWND ret, *list;
373
374     if (!hwndScope) hwndScope = GetDesktopWindow();
375
376     *hittest = HTNOWHERE;
377
378     if (!(list = list_children_from_point( hwndScope, pt ))) return 0;
379
380     /* now determine the hittest */
381
382     for (i = 0; list[i]; i++)
383     {
384         LONG style = GetWindowLongW( list[i], GWL_STYLE );
385
386         /* If window is minimized or disabled, return at once */
387         if (style & WS_MINIMIZE)
388         {
389             *hittest = HTCAPTION;
390             break;
391         }
392         if (style & WS_DISABLED)
393         {
394             *hittest = HTERROR;
395             break;
396         }
397         /* Send WM_NCCHITTEST (if same thread) */
398         if (!WIN_IsCurrentThread( list[i] ))
399         {
400             *hittest = HTCLIENT;
401             break;
402         }
403         res = SendMessageW( list[i], WM_NCHITTEST, 0, MAKELONG(pt.x,pt.y) );
404         if (res != HTTRANSPARENT)
405         {
406             *hittest = res;  /* Found the window */
407             break;
408         }
409         /* continue search with next window in z-order */
410     }
411     ret = list[i];
412     HeapFree( GetProcessHeap(), 0, list );
413     TRACE( "scope %p (%d,%d) returning %p\n", hwndScope, pt.x, pt.y, ret );
414     return ret;
415 }
416
417
418 /*******************************************************************
419  *              WindowFromPoint (USER32.@)
420  */
421 HWND WINAPI WindowFromPoint( POINT pt )
422 {
423     INT hittest;
424     return WINPOS_WindowFromPoint( 0, pt, &hittest );
425 }
426
427
428 /*******************************************************************
429  *              ChildWindowFromPoint (USER32.@)
430  */
431 HWND WINAPI ChildWindowFromPoint( HWND hwndParent, POINT pt )
432 {
433     return ChildWindowFromPointEx( hwndParent, pt, CWP_ALL );
434 }
435
436 /*******************************************************************
437  *              RealChildWindowFromPoint (USER32.@)
438  */
439 HWND WINAPI RealChildWindowFromPoint( HWND hwndParent, POINT pt )
440 {
441     return ChildWindowFromPointEx( hwndParent, pt, CWP_SKIPTRANSPARENT );
442 }
443
444 /*******************************************************************
445  *              ChildWindowFromPointEx (USER32.@)
446  */
447 HWND WINAPI ChildWindowFromPointEx( HWND hwndParent, POINT pt, UINT uFlags)
448 {
449     /* pt is in the client coordinates */
450     HWND *list;
451     int i;
452     RECT rect;
453     HWND retvalue;
454
455     GetClientRect( hwndParent, &rect );
456     if (!PtInRect( &rect, pt )) return 0;
457     if (!(list = WIN_ListChildren( hwndParent ))) return hwndParent;
458
459     for (i = 0; list[i]; i++)
460     {
461         if (!WIN_GetRectangles( list[i], &rect, NULL )) continue;
462         if (!PtInRect( &rect, pt )) continue;
463         if (uFlags & (CWP_SKIPINVISIBLE|CWP_SKIPDISABLED))
464         {
465             LONG style = GetWindowLongW( list[i], GWL_STYLE );
466             if ((uFlags & CWP_SKIPINVISIBLE) && !(style & WS_VISIBLE)) continue;
467             if ((uFlags & CWP_SKIPDISABLED) && (style & WS_DISABLED)) continue;
468         }
469         if (uFlags & CWP_SKIPTRANSPARENT)
470         {
471             if (GetWindowLongW( list[i], GWL_EXSTYLE ) & WS_EX_TRANSPARENT) continue;
472         }
473         break;
474     }
475     retvalue = list[i];
476     HeapFree( GetProcessHeap(), 0, list );
477     if (!retvalue) retvalue = hwndParent;
478     return retvalue;
479 }
480
481
482 /*******************************************************************
483  *         WINPOS_GetWinOffset
484  *
485  * Calculate the offset between the origin of the two windows. Used
486  * to implement MapWindowPoints.
487  */
488 static void WINPOS_GetWinOffset( HWND hwndFrom, HWND hwndTo, POINT *offset )
489 {
490     WND * wndPtr;
491
492     offset->x = offset->y = 0;
493
494     /* Translate source window origin to screen coords */
495     if (hwndFrom)
496     {
497         HWND hwnd = hwndFrom;
498
499         while (hwnd)
500         {
501             if (hwnd == hwndTo) return;
502             if (!(wndPtr = WIN_GetPtr( hwnd )))
503             {
504                 ERR( "bad hwndFrom = %p\n", hwnd );
505                 return;
506             }
507             if (wndPtr == WND_DESKTOP) break;
508             if (wndPtr == WND_OTHER_PROCESS) goto other_process;
509             offset->x += wndPtr->rectClient.left;
510             offset->y += wndPtr->rectClient.top;
511             hwnd = wndPtr->parent;
512             WIN_ReleasePtr( wndPtr );
513         }
514     }
515
516     /* Translate origin to destination window coords */
517     if (hwndTo)
518     {
519         HWND hwnd = hwndTo;
520
521         while (hwnd)
522         {
523             if (!(wndPtr = WIN_GetPtr( hwnd )))
524             {
525                 ERR( "bad hwndTo = %p\n", hwnd );
526                 return;
527             }
528             if (wndPtr == WND_DESKTOP) break;
529             if (wndPtr == WND_OTHER_PROCESS) goto other_process;
530             offset->x -= wndPtr->rectClient.left;
531             offset->y -= wndPtr->rectClient.top;
532             hwnd = wndPtr->parent;
533             WIN_ReleasePtr( wndPtr );
534         }
535     }
536     return;
537
538  other_process:  /* one of the parents may belong to another process, do it the hard way */
539     offset->x = offset->y = 0;
540     SERVER_START_REQ( get_windows_offset )
541     {
542         req->from = hwndFrom;
543         req->to   = hwndTo;
544         if (!wine_server_call( req ))
545         {
546             offset->x = reply->x;
547             offset->y = reply->y;
548         }
549     }
550     SERVER_END_REQ;
551 }
552
553
554 /*******************************************************************
555  *              MapWindowPoints (USER.258)
556  */
557 void WINAPI MapWindowPoints16( HWND16 hwndFrom, HWND16 hwndTo,
558                                LPPOINT16 lppt, UINT16 count )
559 {
560     POINT offset;
561
562     WINPOS_GetWinOffset( WIN_Handle32(hwndFrom), WIN_Handle32(hwndTo), &offset );
563     while (count--)
564     {
565         lppt->x += offset.x;
566         lppt->y += offset.y;
567         lppt++;
568     }
569 }
570
571
572 /*******************************************************************
573  *              MapWindowPoints (USER32.@)
574  */
575 INT WINAPI MapWindowPoints( HWND hwndFrom, HWND hwndTo, LPPOINT lppt, UINT count )
576 {
577     POINT offset;
578
579     WINPOS_GetWinOffset( hwndFrom, hwndTo, &offset );
580     while (count--)
581     {
582         lppt->x += offset.x;
583         lppt->y += offset.y;
584         lppt++;
585     }
586     return MAKELONG( LOWORD(offset.x), LOWORD(offset.y) );
587 }
588
589
590 /***********************************************************************
591  *              IsIconic (USER32.@)
592  */
593 BOOL WINAPI IsIconic(HWND hWnd)
594 {
595     return (GetWindowLongW( hWnd, GWL_STYLE ) & WS_MINIMIZE) != 0;
596 }
597
598
599 /***********************************************************************
600  *              IsZoomed (USER32.@)
601  */
602 BOOL WINAPI IsZoomed(HWND hWnd)
603 {
604     return (GetWindowLongW( hWnd, GWL_STYLE ) & WS_MAXIMIZE) != 0;
605 }
606
607
608 /*******************************************************************
609  *              AllowSetForegroundWindow (USER32.@)
610  */
611 BOOL WINAPI AllowSetForegroundWindow( DWORD procid )
612 {
613     /* FIXME: If Win98/2000 style SetForegroundWindow behavior is
614      * implemented, then fix this function. */
615     return TRUE;
616 }
617
618
619 /*******************************************************************
620  *              LockSetForegroundWindow (USER32.@)
621  */
622 BOOL WINAPI LockSetForegroundWindow( UINT lockcode )
623 {
624     /* FIXME: If Win98/2000 style SetForegroundWindow behavior is
625      * implemented, then fix this function. */
626     return TRUE;
627 }
628
629
630 /***********************************************************************
631  *              BringWindowToTop (USER32.@)
632  */
633 BOOL WINAPI BringWindowToTop( HWND hwnd )
634 {
635     return SetWindowPos( hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE );
636 }
637
638
639 /***********************************************************************
640  *              MoveWindow (USER32.@)
641  */
642 BOOL WINAPI MoveWindow( HWND hwnd, INT x, INT y, INT cx, INT cy,
643                             BOOL repaint )
644 {
645     int flags = SWP_NOZORDER | SWP_NOACTIVATE;
646     if (!repaint) flags |= SWP_NOREDRAW;
647     TRACE("%p %d,%d %dx%d %d\n", hwnd, x, y, cx, cy, repaint );
648     return SetWindowPos( hwnd, 0, x, y, cx, cy, flags );
649 }
650
651 /***********************************************************************
652  *           WINPOS_InitInternalPos
653  */
654 static LPINTERNALPOS WINPOS_InitInternalPos( WND* wnd )
655 {
656     LPINTERNALPOS lpPos = get_internal_pos( wnd->hwndSelf );
657     if( !lpPos )
658     {
659         /* this happens when the window is minimized/maximized
660          * for the first time (rectWindow is not adjusted yet) */
661
662         lpPos = HeapAlloc( GetProcessHeap(), 0, sizeof(INTERNALPOS) );
663         if( !lpPos ) return NULL;
664
665         set_internal_pos( wnd->hwndSelf, lpPos );
666         lpPos->hwndIconTitle = 0; /* defer until needs to be shown */
667         lpPos->rectNormal.left   = wnd->rectWindow.left;
668         lpPos->rectNormal.top    = wnd->rectWindow.top;
669         lpPos->rectNormal.right  = wnd->rectWindow.right;
670         lpPos->rectNormal.bottom = wnd->rectWindow.bottom;
671         lpPos->ptIconPos.x = lpPos->ptIconPos.y = -1;
672         lpPos->ptMaxPos.x = lpPos->ptMaxPos.y = -1;
673     }
674
675     if( wnd->dwStyle & WS_MINIMIZE )
676     {
677         lpPos->ptIconPos.x = wnd->rectWindow.left;
678         lpPos->ptIconPos.y = wnd->rectWindow.top;
679     }
680     else if( wnd->dwStyle & WS_MAXIMIZE )
681     {
682         lpPos->ptMaxPos.x = wnd->rectWindow.left;
683         lpPos->ptMaxPos.y = wnd->rectWindow.top;
684     }
685     else
686     {
687         lpPos->rectNormal.left   = wnd->rectWindow.left;
688         lpPos->rectNormal.top    = wnd->rectWindow.top;
689         lpPos->rectNormal.right  = wnd->rectWindow.right;
690         lpPos->rectNormal.bottom = wnd->rectWindow.bottom;
691     }
692     return lpPos;
693 }
694
695 /***********************************************************************
696  *           WINPOS_RedrawIconTitle
697  */
698 BOOL WINPOS_RedrawIconTitle( HWND hWnd )
699 {
700     LPINTERNALPOS lpPos = get_internal_pos( hWnd );
701     if( lpPos )
702     {
703         if( lpPos->hwndIconTitle )
704         {
705             SendMessageW( lpPos->hwndIconTitle, WM_SHOWWINDOW, TRUE, 0);
706             InvalidateRect( lpPos->hwndIconTitle, NULL, TRUE );
707             return TRUE;
708         }
709     }
710     return FALSE;
711 }
712
713 /***********************************************************************
714  *           WINPOS_ShowIconTitle
715  */
716 BOOL WINPOS_ShowIconTitle( HWND hwnd, BOOL bShow )
717 {
718     LPINTERNALPOS lpPos = get_internal_pos( hwnd );
719
720     if (lpPos && !GetPropA( hwnd, "__wine_x11_managed" ))
721     {
722         HWND title = lpPos->hwndIconTitle;
723
724         TRACE("%p %i\n", hwnd, (bShow != 0) );
725
726         if( !title )
727             lpPos->hwndIconTitle = title = ICONTITLE_Create( hwnd );
728         if( bShow )
729         {
730             if (!IsWindowVisible(title))
731             {
732                 SendMessageW( title, WM_SHOWWINDOW, TRUE, 0 );
733                 SetWindowPos( title, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE |
734                               SWP_NOACTIVATE | SWP_NOZORDER | SWP_SHOWWINDOW );
735             }
736         }
737         else ShowWindow( title, SW_HIDE );
738     }
739     return FALSE;
740 }
741
742 /*******************************************************************
743  *           WINPOS_GetMinMaxInfo
744  *
745  * Get the minimized and maximized information for a window.
746  */
747 void WINPOS_GetMinMaxInfo( HWND hwnd, POINT *maxSize, POINT *maxPos,
748                            POINT *minTrack, POINT *maxTrack )
749 {
750     LPINTERNALPOS lpPos;
751     MINMAXINFO MinMax;
752     HMONITOR monitor;
753     INT xinc, yinc;
754     LONG style = GetWindowLongA( hwnd, GWL_STYLE );
755     LONG exstyle = GetWindowLongA( hwnd, GWL_EXSTYLE );
756     RECT rc;
757
758     /* Compute default values */
759
760     GetWindowRect(hwnd, &rc);
761     MinMax.ptReserved.x = rc.left;
762     MinMax.ptReserved.y = rc.top;
763
764     if (style & WS_CHILD)
765     {
766         if ((style & WS_CAPTION) == WS_CAPTION)
767             style &= ~WS_BORDER; /* WS_CAPTION = WS_DLGFRAME | WS_BORDER */
768
769         GetClientRect(GetAncestor(hwnd,GA_PARENT), &rc);
770         AdjustWindowRectEx(&rc, style, ((style & WS_POPUP) && GetMenu(hwnd)), exstyle);
771
772         /* avoid calculating this twice */
773         style &= ~(WS_DLGFRAME | WS_BORDER | WS_THICKFRAME);
774
775         MinMax.ptMaxSize.x = rc.right - rc.left;
776         MinMax.ptMaxSize.y = rc.bottom - rc.top;
777     }
778     else
779     {
780         MinMax.ptMaxSize.x = GetSystemMetrics(SM_CXSCREEN);
781         MinMax.ptMaxSize.y = GetSystemMetrics(SM_CYSCREEN);
782     }
783     MinMax.ptMinTrackSize.x = GetSystemMetrics(SM_CXMINTRACK);
784     MinMax.ptMinTrackSize.y = GetSystemMetrics(SM_CYMINTRACK);
785     MinMax.ptMaxTrackSize.x = GetSystemMetrics(SM_CXMAXTRACK);
786     MinMax.ptMaxTrackSize.y = GetSystemMetrics(SM_CYMAXTRACK);
787
788     if (HAS_DLGFRAME( style, exstyle ))
789     {
790         xinc = GetSystemMetrics(SM_CXDLGFRAME);
791         yinc = GetSystemMetrics(SM_CYDLGFRAME);
792     }
793     else
794     {
795         xinc = yinc = 0;
796         if (HAS_THICKFRAME(style))
797         {
798             xinc += GetSystemMetrics(SM_CXFRAME);
799             yinc += GetSystemMetrics(SM_CYFRAME);
800         }
801         if (style & WS_BORDER)
802         {
803             xinc += GetSystemMetrics(SM_CXBORDER);
804             yinc += GetSystemMetrics(SM_CYBORDER);
805         }
806     }
807     MinMax.ptMaxSize.x += 2 * xinc;
808     MinMax.ptMaxSize.y += 2 * yinc;
809
810     lpPos = get_internal_pos( hwnd );
811     if( lpPos && !EMPTYPOINT(lpPos->ptMaxPos) )
812     {
813         MinMax.ptMaxPosition.x = lpPos->ptMaxPos.x;
814         MinMax.ptMaxPosition.y = lpPos->ptMaxPos.y;
815     }
816     else
817     {
818         MinMax.ptMaxPosition.x = -xinc;
819         MinMax.ptMaxPosition.y = -yinc;
820     }
821
822     SendMessageW( hwnd, WM_GETMINMAXINFO, 0, (LPARAM)&MinMax );
823
824     /* if the app didn't change the values, adapt them for the current monitor */
825
826     if ((monitor = MonitorFromWindow( hwnd, MONITOR_DEFAULTTOPRIMARY )))
827     {
828         MONITORINFO mon_info;
829
830         mon_info.cbSize = sizeof(mon_info);
831         GetMonitorInfoW( monitor, &mon_info );
832
833         if (MinMax.ptMaxSize.x == GetSystemMetrics(SM_CXSCREEN) + 2 * xinc &&
834             MinMax.ptMaxSize.y == GetSystemMetrics(SM_CYSCREEN) + 2 * yinc)
835         {
836             MinMax.ptMaxSize.x = (mon_info.rcWork.right - mon_info.rcWork.left) + 2 * xinc;
837             MinMax.ptMaxSize.y = (mon_info.rcWork.bottom - mon_info.rcWork.top) + 2 * yinc;
838         }
839         if (MinMax.ptMaxPosition.x == -xinc && MinMax.ptMaxPosition.y == -yinc)
840         {
841             MinMax.ptMaxPosition.x = mon_info.rcWork.left - xinc;
842             MinMax.ptMaxPosition.y = mon_info.rcWork.top - yinc;
843         }
844     }
845
846       /* Some sanity checks */
847
848     TRACE("%d %d / %d %d / %d %d / %d %d\n",
849                       MinMax.ptMaxSize.x, MinMax.ptMaxSize.y,
850                       MinMax.ptMaxPosition.x, MinMax.ptMaxPosition.y,
851                       MinMax.ptMaxTrackSize.x, MinMax.ptMaxTrackSize.y,
852                       MinMax.ptMinTrackSize.x, MinMax.ptMinTrackSize.y);
853     MinMax.ptMaxTrackSize.x = max( MinMax.ptMaxTrackSize.x,
854                                    MinMax.ptMinTrackSize.x );
855     MinMax.ptMaxTrackSize.y = max( MinMax.ptMaxTrackSize.y,
856                                    MinMax.ptMinTrackSize.y );
857
858     if (maxSize) *maxSize = MinMax.ptMaxSize;
859     if (maxPos) *maxPos = MinMax.ptMaxPosition;
860     if (minTrack) *minTrack = MinMax.ptMinTrackSize;
861     if (maxTrack) *maxTrack = MinMax.ptMaxTrackSize;
862 }
863
864 /***********************************************************************
865  *              ShowWindowAsync (USER32.@)
866  *
867  * doesn't wait; returns immediately.
868  * used by threads to toggle windows in other (possibly hanging) threads
869  */
870 BOOL WINAPI ShowWindowAsync( HWND hwnd, INT cmd )
871 {
872     HWND full_handle;
873
874     if (is_broadcast(hwnd))
875     {
876         SetLastError( ERROR_INVALID_PARAMETER );
877         return FALSE;
878     }
879
880     if ((full_handle = WIN_IsCurrentThread( hwnd )))
881         return USER_Driver->pShowWindow( full_handle, cmd );
882
883     return SendNotifyMessageW( hwnd, WM_WINE_SHOWWINDOW, cmd, 0 );
884 }
885
886
887 /***********************************************************************
888  *              ShowWindow (USER32.@)
889  */
890 BOOL WINAPI ShowWindow( HWND hwnd, INT cmd )
891 {
892     HWND full_handle;
893
894     if (is_broadcast(hwnd))
895     {
896         SetLastError( ERROR_INVALID_PARAMETER );
897         return FALSE;
898     }
899     if ((full_handle = WIN_IsCurrentThread( hwnd )))
900         return USER_Driver->pShowWindow( full_handle, cmd );
901
902     return SendMessageW( hwnd, WM_WINE_SHOWWINDOW, cmd, 0 );
903 }
904
905
906 /***********************************************************************
907  *              GetInternalWindowPos (USER32.@)
908  */
909 UINT WINAPI GetInternalWindowPos( HWND hwnd, LPRECT rectWnd,
910                                       LPPOINT ptIcon )
911 {
912     WINDOWPLACEMENT wndpl;
913     if (GetWindowPlacement( hwnd, &wndpl ))
914     {
915         if (rectWnd) *rectWnd = wndpl.rcNormalPosition;
916         if (ptIcon)  *ptIcon = wndpl.ptMinPosition;
917         return wndpl.showCmd;
918     }
919     return 0;
920 }
921
922
923 /***********************************************************************
924  *              GetWindowPlacement (USER32.@)
925  *
926  * Win95:
927  * Fails if wndpl->length of Win95 (!) apps is invalid.
928  */
929 BOOL WINAPI GetWindowPlacement( HWND hwnd, WINDOWPLACEMENT *wndpl )
930 {
931     WND *pWnd = WIN_GetPtr( hwnd );
932     LPINTERNALPOS lpPos;
933
934     if (!pWnd || pWnd == WND_DESKTOP) return FALSE;
935     if (pWnd == WND_OTHER_PROCESS)
936     {
937         if (IsWindow( hwnd )) FIXME( "not supported on other process window %p\n", hwnd );
938         return FALSE;
939     }
940
941     lpPos = WINPOS_InitInternalPos( pWnd );
942     wndpl->length  = sizeof(*wndpl);
943     if( pWnd->dwStyle & WS_MINIMIZE )
944         wndpl->showCmd = SW_SHOWMINIMIZED;
945     else
946         wndpl->showCmd = ( pWnd->dwStyle & WS_MAXIMIZE ) ? SW_SHOWMAXIMIZED : SW_SHOWNORMAL ;
947     if( pWnd->flags & WIN_RESTORE_MAX )
948         wndpl->flags = WPF_RESTORETOMAXIMIZED;
949     else
950         wndpl->flags = 0;
951     wndpl->ptMinPosition.x = lpPos->ptIconPos.x;
952     wndpl->ptMinPosition.y = lpPos->ptIconPos.y;
953     wndpl->ptMaxPosition.x = lpPos->ptMaxPos.x;
954     wndpl->ptMaxPosition.y = lpPos->ptMaxPos.y;
955     wndpl->rcNormalPosition.left   = lpPos->rectNormal.left;
956     wndpl->rcNormalPosition.top    = lpPos->rectNormal.top;
957     wndpl->rcNormalPosition.right  = lpPos->rectNormal.right;
958     wndpl->rcNormalPosition.bottom = lpPos->rectNormal.bottom;
959     WIN_ReleasePtr( pWnd );
960     return TRUE;
961 }
962
963
964 /***********************************************************************
965  *           WINPOS_SetPlacement
966  */
967 static BOOL WINPOS_SetPlacement( HWND hwnd, const WINDOWPLACEMENT *wndpl, UINT flags )
968 {
969     LPINTERNALPOS lpPos;
970     DWORD style;
971     WND *pWnd = WIN_GetPtr( hwnd );
972
973     if (!pWnd || pWnd == WND_OTHER_PROCESS || pWnd == WND_DESKTOP) return FALSE;
974     lpPos = WINPOS_InitInternalPos( pWnd );
975
976     if( flags & PLACE_MIN )
977     {
978         lpPos->ptIconPos.x = wndpl->ptMinPosition.x;
979         lpPos->ptIconPos.y = wndpl->ptMinPosition.y;
980     }
981     if( flags & PLACE_MAX )
982     {
983         lpPos->ptMaxPos.x = wndpl->ptMaxPosition.x;
984         lpPos->ptMaxPos.y = wndpl->ptMaxPosition.y;
985     }
986     if( flags & PLACE_RECT)
987     {
988         lpPos->rectNormal.left   = wndpl->rcNormalPosition.left;
989         lpPos->rectNormal.top    = wndpl->rcNormalPosition.top;
990         lpPos->rectNormal.right  = wndpl->rcNormalPosition.right;
991         lpPos->rectNormal.bottom = wndpl->rcNormalPosition.bottom;
992     }
993
994     style = pWnd->dwStyle;
995     WIN_ReleasePtr( pWnd );
996
997     if( style & WS_MINIMIZE )
998     {
999         WINPOS_ShowIconTitle( hwnd, FALSE );
1000         if( wndpl->flags & WPF_SETMINPOSITION && !EMPTYPOINT(lpPos->ptIconPos))
1001             SetWindowPos( hwnd, 0, lpPos->ptIconPos.x, lpPos->ptIconPos.y,
1002                           0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE );
1003     }
1004     else if( style & WS_MAXIMIZE )
1005     {
1006         if( !EMPTYPOINT(lpPos->ptMaxPos) )
1007             SetWindowPos( hwnd, 0, lpPos->ptMaxPos.x, lpPos->ptMaxPos.y,
1008                           0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE );
1009     }
1010     else if( flags & PLACE_RECT )
1011         SetWindowPos( hwnd, 0, lpPos->rectNormal.left, lpPos->rectNormal.top,
1012                       lpPos->rectNormal.right - lpPos->rectNormal.left,
1013                       lpPos->rectNormal.bottom - lpPos->rectNormal.top,
1014                       SWP_NOZORDER | SWP_NOACTIVATE );
1015
1016     ShowWindow( hwnd, wndpl->showCmd );
1017
1018     if (IsIconic( hwnd ))
1019     {
1020         if (GetWindowLongW( hwnd, GWL_STYLE ) & WS_VISIBLE) WINPOS_ShowIconTitle( hwnd, TRUE );
1021
1022         /* SDK: ...valid only the next time... */
1023         if( wndpl->flags & WPF_RESTORETOMAXIMIZED )
1024         {
1025             pWnd = WIN_GetPtr( hwnd );
1026             if (pWnd && pWnd != WND_OTHER_PROCESS)
1027             {
1028                 pWnd->flags |= WIN_RESTORE_MAX;
1029                 WIN_ReleasePtr( pWnd );
1030             }
1031         }
1032     }
1033     return TRUE;
1034 }
1035
1036
1037 /***********************************************************************
1038  *              SetWindowPlacement (USER32.@)
1039  *
1040  * Win95:
1041  * Fails if wndpl->length of Win95 (!) apps is invalid.
1042  */
1043 BOOL WINAPI SetWindowPlacement( HWND hwnd, const WINDOWPLACEMENT *wpl )
1044 {
1045     if (!wpl) return FALSE;
1046     return WINPOS_SetPlacement( hwnd, wpl, PLACE_MIN | PLACE_MAX | PLACE_RECT );
1047 }
1048
1049
1050 /***********************************************************************
1051  *              AnimateWindow (USER32.@)
1052  *              Shows/Hides a window with an animation
1053  *              NO ANIMATION YET
1054  */
1055 BOOL WINAPI AnimateWindow(HWND hwnd, DWORD dwTime, DWORD dwFlags)
1056 {
1057         FIXME("partial stub\n");
1058
1059         /* If trying to show/hide and it's already   *
1060          * shown/hidden or invalid window, fail with *
1061          * invalid parameter                         */
1062         if(!IsWindow(hwnd) ||
1063            (IsWindowVisible(hwnd) && !(dwFlags & AW_HIDE)) ||
1064            (!IsWindowVisible(hwnd) && (dwFlags & AW_HIDE)))
1065         {
1066                 SetLastError(ERROR_INVALID_PARAMETER);
1067                 return FALSE;
1068         }
1069
1070         ShowWindow(hwnd, (dwFlags & AW_HIDE) ? SW_HIDE : ((dwFlags & AW_ACTIVATE) ? SW_SHOW : SW_SHOWNA));
1071
1072         return TRUE;
1073 }
1074
1075 /***********************************************************************
1076  *              SetInternalWindowPos (USER32.@)
1077  */
1078 void WINAPI SetInternalWindowPos( HWND hwnd, UINT showCmd,
1079                                     LPRECT rect, LPPOINT pt )
1080 {
1081     if( IsWindow(hwnd) )
1082     {
1083         WINDOWPLACEMENT wndpl;
1084         UINT flags;
1085
1086         wndpl.length  = sizeof(wndpl);
1087         wndpl.showCmd = showCmd;
1088         wndpl.flags = flags = 0;
1089
1090         if( pt )
1091         {
1092             flags |= PLACE_MIN;
1093             wndpl.flags |= WPF_SETMINPOSITION;
1094             wndpl.ptMinPosition = *pt;
1095         }
1096         if( rect )
1097         {
1098             flags |= PLACE_RECT;
1099             wndpl.rcNormalPosition = *rect;
1100         }
1101         WINPOS_SetPlacement( hwnd, &wndpl, flags );
1102     }
1103 }
1104
1105
1106 /*******************************************************************
1107  *         can_activate_window
1108  *
1109  * Check if we can activate the specified window.
1110  */
1111 static BOOL can_activate_window( HWND hwnd )
1112 {
1113     LONG style;
1114
1115     if (!hwnd) return FALSE;
1116     style = GetWindowLongW( hwnd, GWL_STYLE );
1117     if (!(style & WS_VISIBLE)) return FALSE;
1118     if ((style & (WS_POPUP|WS_CHILD)) == WS_CHILD) return FALSE;
1119     return !(style & WS_DISABLED);
1120 }
1121
1122
1123 /*******************************************************************
1124  *         WINPOS_ActivateOtherWindow
1125  *
1126  *  Activates window other than pWnd.
1127  */
1128 void WINPOS_ActivateOtherWindow(HWND hwnd)
1129 {
1130     HWND hwndTo, fg;
1131
1132     if ((GetWindowLongW( hwnd, GWL_STYLE ) & WS_POPUP) && (hwndTo = GetWindow( hwnd, GW_OWNER )))
1133     {
1134         hwndTo = GetAncestor( hwndTo, GA_ROOT );
1135         if (can_activate_window( hwndTo )) goto done;
1136     }
1137
1138     hwndTo = hwnd;
1139     for (;;)
1140     {
1141         if (!(hwndTo = GetWindow( hwndTo, GW_HWNDNEXT ))) break;
1142         if (can_activate_window( hwndTo )) break;
1143     }
1144
1145  done:
1146     fg = GetForegroundWindow();
1147     TRACE("win = %p fg = %p\n", hwndTo, fg);
1148     if (!fg || (hwnd == fg))
1149     {
1150         if (SetForegroundWindow( hwndTo )) return;
1151     }
1152     if (!SetActiveWindow( hwndTo )) SetActiveWindow(0);
1153 }
1154
1155
1156 /***********************************************************************
1157  *           WINPOS_HandleWindowPosChanging
1158  *
1159  * Default handling for a WM_WINDOWPOSCHANGING. Called from DefWindowProc().
1160  */
1161 LONG WINPOS_HandleWindowPosChanging( HWND hwnd, WINDOWPOS *winpos )
1162 {
1163     POINT minTrack, maxTrack;
1164     LONG style = GetWindowLongW( hwnd, GWL_STYLE );
1165
1166     if (winpos->flags & SWP_NOSIZE) return 0;
1167     if ((style & WS_THICKFRAME) || ((style & (WS_POPUP | WS_CHILD)) == 0))
1168     {
1169         WINPOS_GetMinMaxInfo( hwnd, NULL, NULL, &minTrack, &maxTrack );
1170         if (winpos->cx > maxTrack.x) winpos->cx = maxTrack.x;
1171         if (winpos->cy > maxTrack.y) winpos->cy = maxTrack.y;
1172         if (!(style & WS_MINIMIZE))
1173         {
1174             if (winpos->cx < minTrack.x ) winpos->cx = minTrack.x;
1175             if (winpos->cy < minTrack.y ) winpos->cy = minTrack.y;
1176         }
1177     }
1178     return 0;
1179 }
1180
1181
1182 /***********************************************************************
1183  *           dump_winpos_flags
1184  */
1185 static void dump_winpos_flags(UINT flags)
1186 {
1187     TRACE("flags:");
1188     if(flags & SWP_NOSIZE) TRACE(" SWP_NOSIZE");
1189     if(flags & SWP_NOMOVE) TRACE(" SWP_NOMOVE");
1190     if(flags & SWP_NOZORDER) TRACE(" SWP_NOZORDER");
1191     if(flags & SWP_NOREDRAW) TRACE(" SWP_NOREDRAW");
1192     if(flags & SWP_NOACTIVATE) TRACE(" SWP_NOACTIVATE");
1193     if(flags & SWP_FRAMECHANGED) TRACE(" SWP_FRAMECHANGED");
1194     if(flags & SWP_SHOWWINDOW) TRACE(" SWP_SHOWWINDOW");
1195     if(flags & SWP_HIDEWINDOW) TRACE(" SWP_HIDEWINDOW");
1196     if(flags & SWP_NOCOPYBITS) TRACE(" SWP_NOCOPYBITS");
1197     if(flags & SWP_NOOWNERZORDER) TRACE(" SWP_NOOWNERZORDER");
1198     if(flags & SWP_NOSENDCHANGING) TRACE(" SWP_NOSENDCHANGING");
1199     if(flags & SWP_DEFERERASE) TRACE(" SWP_DEFERERASE");
1200     if(flags & SWP_ASYNCWINDOWPOS) TRACE(" SWP_ASYNCWINDOWPOS");
1201
1202 #define DUMPED_FLAGS \
1203     (SWP_NOSIZE | \
1204     SWP_NOMOVE | \
1205     SWP_NOZORDER | \
1206     SWP_NOREDRAW | \
1207     SWP_NOACTIVATE | \
1208     SWP_FRAMECHANGED | \
1209     SWP_SHOWWINDOW | \
1210     SWP_HIDEWINDOW | \
1211     SWP_NOCOPYBITS | \
1212     SWP_NOOWNERZORDER | \
1213     SWP_NOSENDCHANGING | \
1214     SWP_DEFERERASE | \
1215     SWP_ASYNCWINDOWPOS)
1216
1217     if(flags & ~DUMPED_FLAGS) TRACE(" %08x", flags & ~DUMPED_FLAGS);
1218     TRACE("\n");
1219 #undef DUMPED_FLAGS
1220 }
1221
1222 /***********************************************************************
1223  *           SWP_DoWinPosChanging
1224  */
1225 static BOOL SWP_DoWinPosChanging( WINDOWPOS* pWinpos, RECT* pNewWindowRect, RECT* pNewClientRect )
1226 {
1227     WND *wndPtr;
1228
1229     /* Send WM_WINDOWPOSCHANGING message */
1230
1231     if (!(pWinpos->flags & SWP_NOSENDCHANGING))
1232         SendMessageW( pWinpos->hwnd, WM_WINDOWPOSCHANGING, 0, (LPARAM)pWinpos );
1233
1234     if (!(wndPtr = WIN_GetPtr( pWinpos->hwnd )) ||
1235         wndPtr == WND_OTHER_PROCESS || wndPtr == WND_DESKTOP) return FALSE;
1236
1237     /* Calculate new position and size */
1238
1239     *pNewWindowRect = wndPtr->rectWindow;
1240     *pNewClientRect = (wndPtr->dwStyle & WS_MINIMIZE) ? wndPtr->rectWindow
1241                                                     : wndPtr->rectClient;
1242
1243     if (!(pWinpos->flags & SWP_NOSIZE))
1244     {
1245         pNewWindowRect->right  = pNewWindowRect->left + pWinpos->cx;
1246         pNewWindowRect->bottom = pNewWindowRect->top + pWinpos->cy;
1247     }
1248     if (!(pWinpos->flags & SWP_NOMOVE))
1249     {
1250         pNewWindowRect->left    = pWinpos->x;
1251         pNewWindowRect->top     = pWinpos->y;
1252         pNewWindowRect->right  += pWinpos->x - wndPtr->rectWindow.left;
1253         pNewWindowRect->bottom += pWinpos->y - wndPtr->rectWindow.top;
1254
1255         OffsetRect( pNewClientRect, pWinpos->x - wndPtr->rectWindow.left,
1256                                     pWinpos->y - wndPtr->rectWindow.top );
1257     }
1258     pWinpos->flags |= SWP_NOCLIENTMOVE | SWP_NOCLIENTSIZE;
1259
1260     TRACE( "hwnd %p, after %p, swp %d,%d %dx%d flags %08x\n",
1261            pWinpos->hwnd, pWinpos->hwndInsertAfter, pWinpos->x, pWinpos->y,
1262            pWinpos->cx, pWinpos->cy, pWinpos->flags );
1263     TRACE( "current %s style %08x new %s\n",
1264            wine_dbgstr_rect( &wndPtr->rectWindow ), wndPtr->dwStyle,
1265            wine_dbgstr_rect( pNewWindowRect ));
1266
1267     WIN_ReleasePtr( wndPtr );
1268     return TRUE;
1269 }
1270
1271 /***********************************************************************
1272  *           get_valid_rects
1273  *
1274  * Compute the valid rects from the old and new client rect and WVR_* flags.
1275  * Helper for WM_NCCALCSIZE handling.
1276  */
1277 static inline void get_valid_rects( const RECT *old_client, const RECT *new_client, UINT flags,
1278                                     RECT *valid )
1279 {
1280     int cx, cy;
1281
1282     if (flags & WVR_REDRAW)
1283     {
1284         SetRectEmpty( &valid[0] );
1285         SetRectEmpty( &valid[1] );
1286         return;
1287     }
1288
1289     if (flags & WVR_VALIDRECTS)
1290     {
1291         if (!IntersectRect( &valid[0], &valid[0], new_client ) ||
1292             !IntersectRect( &valid[1], &valid[1], old_client ))
1293         {
1294             SetRectEmpty( &valid[0] );
1295             SetRectEmpty( &valid[1] );
1296             return;
1297         }
1298         flags = WVR_ALIGNLEFT | WVR_ALIGNTOP;
1299     }
1300     else
1301     {
1302         valid[0] = *new_client;
1303         valid[1] = *old_client;
1304     }
1305
1306     /* make sure the rectangles have the same size */
1307     cx = min( valid[0].right - valid[0].left, valid[1].right - valid[1].left );
1308     cy = min( valid[0].bottom - valid[0].top, valid[1].bottom - valid[1].top );
1309
1310     if (flags & WVR_ALIGNBOTTOM)
1311     {
1312         valid[0].top = valid[0].bottom - cy;
1313         valid[1].top = valid[1].bottom - cy;
1314     }
1315     else
1316     {
1317         valid[0].bottom = valid[0].top + cy;
1318         valid[1].bottom = valid[1].top + cy;
1319     }
1320     if (flags & WVR_ALIGNRIGHT)
1321     {
1322         valid[0].left = valid[0].right - cx;
1323         valid[1].left = valid[1].right - cx;
1324     }
1325     else
1326     {
1327         valid[0].right = valid[0].left + cx;
1328         valid[1].right = valid[1].left + cx;
1329     }
1330 }
1331
1332 struct move_owned_info
1333 {
1334     HWND owner;
1335     HWND insert_after;
1336 };
1337
1338 static BOOL CALLBACK move_owned_popups( HWND hwnd, LPARAM lparam )
1339 {
1340     struct move_owned_info *info = (struct move_owned_info *)lparam;
1341
1342     if (hwnd == info->owner) return FALSE;
1343     if ((GetWindowLongW( hwnd, GWL_STYLE ) & WS_POPUP) &&
1344         GetWindow( hwnd, GW_OWNER ) == info->owner)
1345     {
1346         SetWindowPos( hwnd, info->insert_after, 0, 0, 0, 0,
1347                       SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE |
1348                       SWP_NOSENDCHANGING | SWP_DEFERERASE );
1349         info->insert_after = hwnd;
1350     }
1351     return TRUE;
1352 }
1353
1354 /***********************************************************************
1355  *           SWP_DoOwnedPopups
1356  *
1357  * fix Z order taking into account owned popups -
1358  * basically we need to maintain them above the window that owns them
1359  *
1360  * FIXME: hide/show owned popups when owner visibility changes.
1361  */
1362 static HWND SWP_DoOwnedPopups(HWND hwnd, HWND hwndInsertAfter)
1363 {
1364     HWND owner = GetWindow( hwnd, GW_OWNER );
1365     LONG style = GetWindowLongW( hwnd, GWL_STYLE );
1366     struct move_owned_info info;
1367
1368     TRACE("(%p) hInsertAfter = %p\n", hwnd, hwndInsertAfter );
1369
1370     if ((style & WS_POPUP) && owner)
1371     {
1372         /* make sure this popup stays above the owner */
1373
1374         if( hwndInsertAfter != HWND_TOP )
1375         {
1376             HWND hwndLocalPrev = HWND_TOP;
1377             HWND prev = GetWindow( owner, GW_HWNDPREV );
1378
1379             while (prev && prev != hwndInsertAfter)
1380             {
1381                 if (hwndLocalPrev == HWND_TOP && GetWindowLongW( prev, GWL_STYLE ) & WS_VISIBLE)
1382                     hwndLocalPrev = prev;
1383                 prev = GetWindow( prev, GW_HWNDPREV );
1384             }
1385             if (!prev) hwndInsertAfter = hwndLocalPrev;
1386         }
1387     }
1388     else if (style & WS_CHILD) return hwndInsertAfter;
1389
1390     info.owner = hwnd;
1391     info.insert_after = hwndInsertAfter;
1392     EnumWindows( move_owned_popups, (LPARAM)&info );
1393     return info.insert_after;
1394 }
1395
1396 /***********************************************************************
1397  *           SWP_DoNCCalcSize
1398  */
1399 static UINT SWP_DoNCCalcSize( WINDOWPOS* pWinpos, const RECT* pNewWindowRect, RECT* pNewClientRect,
1400                               RECT *validRects )
1401 {
1402     UINT wvrFlags = 0;
1403     WND *wndPtr;
1404
1405     if (!(wndPtr = WIN_GetPtr( pWinpos->hwnd )) || wndPtr == WND_OTHER_PROCESS) return 0;
1406
1407       /* Send WM_NCCALCSIZE message to get new client area */
1408     if( (pWinpos->flags & (SWP_FRAMECHANGED | SWP_NOSIZE)) != SWP_NOSIZE )
1409     {
1410         NCCALCSIZE_PARAMS params;
1411         WINDOWPOS winposCopy;
1412
1413         params.rgrc[0] = *pNewWindowRect;
1414         params.rgrc[1] = wndPtr->rectWindow;
1415         params.rgrc[2] = wndPtr->rectClient;
1416         params.lppos = &winposCopy;
1417         winposCopy = *pWinpos;
1418         WIN_ReleasePtr( wndPtr );
1419
1420         wvrFlags = SendMessageW( pWinpos->hwnd, WM_NCCALCSIZE, TRUE, (LPARAM)&params );
1421
1422         *pNewClientRect = params.rgrc[0];
1423
1424         if (!(wndPtr = WIN_GetPtr( pWinpos->hwnd )) || wndPtr == WND_OTHER_PROCESS) return 0;
1425
1426         TRACE( "hwnd %p old win %s old client %s new win %s new client %s\n", pWinpos->hwnd,
1427                wine_dbgstr_rect(&wndPtr->rectWindow), wine_dbgstr_rect(&wndPtr->rectClient),
1428                wine_dbgstr_rect(pNewWindowRect), wine_dbgstr_rect(pNewClientRect) );
1429
1430         if( pNewClientRect->left != wndPtr->rectClient.left ||
1431             pNewClientRect->top != wndPtr->rectClient.top )
1432             pWinpos->flags &= ~SWP_NOCLIENTMOVE;
1433
1434         if( (pNewClientRect->right - pNewClientRect->left !=
1435              wndPtr->rectClient.right - wndPtr->rectClient.left))
1436             pWinpos->flags &= ~SWP_NOCLIENTSIZE;
1437         else
1438             wvrFlags &= ~WVR_HREDRAW;
1439
1440         if (pNewClientRect->bottom - pNewClientRect->top !=
1441              wndPtr->rectClient.bottom - wndPtr->rectClient.top)
1442             pWinpos->flags &= ~SWP_NOCLIENTSIZE;
1443         else
1444             wvrFlags &= ~WVR_VREDRAW;
1445
1446         validRects[0] = params.rgrc[1];
1447         validRects[1] = params.rgrc[2];
1448     }
1449     else
1450     {
1451         if (!(pWinpos->flags & SWP_NOMOVE) &&
1452             (pNewClientRect->left != wndPtr->rectClient.left ||
1453              pNewClientRect->top != wndPtr->rectClient.top))
1454             pWinpos->flags &= ~SWP_NOCLIENTMOVE;
1455     }
1456
1457     if (pWinpos->flags & (SWP_NOCOPYBITS | SWP_NOREDRAW | SWP_SHOWWINDOW | SWP_HIDEWINDOW))
1458     {
1459         SetRectEmpty( &validRects[0] );
1460         SetRectEmpty( &validRects[1] );
1461     }
1462     else get_valid_rects( &wndPtr->rectClient, pNewClientRect, wvrFlags, validRects );
1463
1464     WIN_ReleasePtr( wndPtr );
1465     return wvrFlags;
1466 }
1467
1468 /* fix redundant flags and values in the WINDOWPOS structure */
1469 static BOOL fixup_flags( WINDOWPOS *winpos )
1470 {
1471     HWND parent;
1472     WND *wndPtr = WIN_GetPtr( winpos->hwnd );
1473     BOOL ret = TRUE;
1474
1475     if (!wndPtr || wndPtr == WND_OTHER_PROCESS)
1476     {
1477         SetLastError( ERROR_INVALID_WINDOW_HANDLE );
1478         return FALSE;
1479     }
1480     winpos->hwnd = wndPtr->hwndSelf;  /* make it a full handle */
1481
1482     /* Finally make sure that all coordinates are valid */
1483     if (winpos->x < -32768) winpos->x = -32768;
1484     else if (winpos->x > 32767) winpos->x = 32767;
1485     if (winpos->y < -32768) winpos->y = -32768;
1486     else if (winpos->y > 32767) winpos->y = 32767;
1487
1488     if (winpos->cx < 0) winpos->cx = 0;
1489     else if (winpos->cx > 32767) winpos->cx = 32767;
1490     if (winpos->cy < 0) winpos->cy = 0;
1491     else if (winpos->cy > 32767) winpos->cy = 32767;
1492
1493     parent = GetAncestor( winpos->hwnd, GA_PARENT );
1494     if (!IsWindowVisible( parent )) winpos->flags |= SWP_NOREDRAW;
1495
1496     if (wndPtr->dwStyle & WS_VISIBLE) winpos->flags &= ~SWP_SHOWWINDOW;
1497     else
1498     {
1499         winpos->flags &= ~SWP_HIDEWINDOW;
1500         if (!(winpos->flags & SWP_SHOWWINDOW)) winpos->flags |= SWP_NOREDRAW;
1501     }
1502
1503     if ((wndPtr->rectWindow.right - wndPtr->rectWindow.left == winpos->cx) &&
1504         (wndPtr->rectWindow.bottom - wndPtr->rectWindow.top == winpos->cy))
1505         winpos->flags |= SWP_NOSIZE;    /* Already the right size */
1506
1507     if ((wndPtr->rectWindow.left == winpos->x) && (wndPtr->rectWindow.top == winpos->y))
1508         winpos->flags |= SWP_NOMOVE;    /* Already the right position */
1509
1510     if ((wndPtr->dwStyle & (WS_POPUP | WS_CHILD)) != WS_CHILD)
1511     {
1512         if (!(winpos->flags & (SWP_NOACTIVATE|SWP_HIDEWINDOW))) /* Bring to the top when activating */
1513         {
1514             winpos->flags &= ~SWP_NOZORDER;
1515             winpos->hwndInsertAfter = HWND_TOP;
1516         }
1517     }
1518
1519     /* Check hwndInsertAfter */
1520     if (winpos->flags & SWP_NOZORDER) goto done;
1521
1522     /* fix sign extension */
1523     if (winpos->hwndInsertAfter == (HWND)0xffff) winpos->hwndInsertAfter = HWND_TOPMOST;
1524     else if (winpos->hwndInsertAfter == (HWND)0xfffe) winpos->hwndInsertAfter = HWND_NOTOPMOST;
1525
1526       /* FIXME: TOPMOST not supported yet */
1527     if ((winpos->hwndInsertAfter == HWND_TOPMOST) ||
1528         (winpos->hwndInsertAfter == HWND_NOTOPMOST)) winpos->hwndInsertAfter = HWND_TOP;
1529
1530     /* hwndInsertAfter must be a sibling of the window */
1531     if (winpos->hwndInsertAfter == HWND_TOP)
1532     {
1533         if (GetWindow(winpos->hwnd, GW_HWNDFIRST) == winpos->hwnd)
1534             winpos->flags |= SWP_NOZORDER;
1535     }
1536     else if (winpos->hwndInsertAfter == HWND_BOTTOM)
1537     {
1538         if (GetWindow(winpos->hwnd, GW_HWNDLAST) == winpos->hwnd)
1539             winpos->flags |= SWP_NOZORDER;
1540     }
1541     else
1542     {
1543         if (GetAncestor( winpos->hwndInsertAfter, GA_PARENT ) != parent) ret = FALSE;
1544         else
1545         {
1546             /* don't need to change the Zorder of hwnd if it's already inserted
1547              * after hwndInsertAfter or when inserting hwnd after itself.
1548              */
1549             if ((winpos->hwnd == winpos->hwndInsertAfter) ||
1550                 (winpos->hwnd == GetWindow( winpos->hwndInsertAfter, GW_HWNDNEXT )))
1551                 winpos->flags |= SWP_NOZORDER;
1552         }
1553     }
1554  done:
1555     WIN_ReleasePtr( wndPtr );
1556     return ret;
1557 }
1558
1559 /***********************************************************************
1560  *              USER_SetWindowPos
1561  *
1562  *     User32 internal function
1563  */
1564 BOOL USER_SetWindowPos( WINDOWPOS * winpos )
1565 {
1566     RECT newWindowRect, newClientRect, valid_rects[2];
1567     UINT orig_flags;
1568     
1569     orig_flags = winpos->flags;
1570     
1571     /* First make sure that coordinates are valid for WM_WINDOWPOSCHANGING */
1572     if (!(winpos->flags & SWP_NOMOVE))
1573     {
1574         if (winpos->x < -32768) winpos->x = -32768;
1575         else if (winpos->x > 32767) winpos->x = 32767;
1576         if (winpos->y < -32768) winpos->y = -32768;
1577         else if (winpos->y > 32767) winpos->y = 32767;
1578     }
1579     if (!(winpos->flags & SWP_NOSIZE))
1580     {
1581         if (winpos->cx < 0) winpos->cx = 0;
1582         else if (winpos->cx > 32767) winpos->cx = 32767;
1583         if (winpos->cy < 0) winpos->cy = 0;
1584         else if (winpos->cy > 32767) winpos->cy = 32767;
1585     }
1586
1587     if (!SWP_DoWinPosChanging( winpos, &newWindowRect, &newClientRect )) return FALSE;
1588
1589     /* Fix redundant flags */
1590     if (!fixup_flags( winpos )) return FALSE;
1591
1592     if((winpos->flags & (SWP_NOZORDER | SWP_HIDEWINDOW | SWP_SHOWWINDOW)) != SWP_NOZORDER)
1593     {
1594         if (GetAncestor( winpos->hwnd, GA_PARENT ) == GetDesktopWindow())
1595             winpos->hwndInsertAfter = SWP_DoOwnedPopups( winpos->hwnd, winpos->hwndInsertAfter );
1596     }
1597
1598     /* Common operations */
1599
1600     SWP_DoNCCalcSize( winpos, &newWindowRect, &newClientRect, valid_rects );
1601
1602     if(!USER_Driver->pSetWindowPos( winpos->hwnd, winpos->hwndInsertAfter, 
1603                             &newWindowRect, &newClientRect, orig_flags, valid_rects ))
1604         return FALSE;
1605
1606     /* erase parent when hiding or resizing child */
1607     if (!(orig_flags & SWP_DEFERERASE) &&
1608         ((orig_flags & SWP_HIDEWINDOW) ||
1609          (!(orig_flags & SWP_SHOWWINDOW) &&
1610           (winpos->flags & SWP_AGG_STATUSFLAGS) != SWP_AGG_NOGEOMETRYCHANGE)))
1611     {
1612         HWND parent = GetAncestor( winpos->hwnd, GA_PARENT );
1613         if (!parent || parent == GetDesktopWindow()) parent = winpos->hwnd;
1614         erase_now( parent, 0 );
1615     }
1616
1617     if( winpos->flags & SWP_HIDEWINDOW )
1618         HideCaret(winpos->hwnd);
1619     else if (winpos->flags & SWP_SHOWWINDOW)
1620         ShowCaret(winpos->hwnd);
1621
1622     if (!(winpos->flags & (SWP_NOACTIVATE|SWP_HIDEWINDOW)))
1623     {
1624         /* child windows get WM_CHILDACTIVATE message */
1625         if ((GetWindowLongW( winpos->hwnd, GWL_STYLE ) & (WS_CHILD | WS_POPUP)) == WS_CHILD)
1626             SendMessageW( winpos->hwnd, WM_CHILDACTIVATE, 0, 0 );
1627         else
1628             SetForegroundWindow( winpos->hwnd );
1629     }
1630
1631       /* And last, send the WM_WINDOWPOSCHANGED message */
1632
1633     TRACE("\tstatus flags = %04x\n", winpos->flags & SWP_AGG_STATUSFLAGS);
1634
1635     if (((winpos->flags & SWP_AGG_STATUSFLAGS) != SWP_AGG_NOPOSCHANGE))
1636     {
1637         /* WM_WINDOWPOSCHANGED is sent even if SWP_NOSENDCHANGING is set
1638            and always contains final window position.
1639          */
1640         winpos->x = newWindowRect.left;
1641         winpos->y = newWindowRect.top;
1642         winpos->cx = newWindowRect.right - newWindowRect.left;
1643         winpos->cy = newWindowRect.bottom - newWindowRect.top;
1644         SendMessageW( winpos->hwnd, WM_WINDOWPOSCHANGED, 0, (LPARAM)winpos );
1645     }
1646     return TRUE;
1647 }
1648
1649 /***********************************************************************
1650  *              SetWindowPos (USER32.@)
1651  */
1652 BOOL WINAPI SetWindowPos( HWND hwnd, HWND hwndInsertAfter,
1653                           INT x, INT y, INT cx, INT cy, UINT flags )
1654 {
1655     WINDOWPOS winpos;
1656
1657     TRACE("hwnd %p, after %p, %d,%d (%dx%d), flags %08x\n",
1658           hwnd, hwndInsertAfter, x, y, cx, cy, flags);
1659     if(TRACE_ON(win)) dump_winpos_flags(flags);
1660
1661     if (is_broadcast(hwnd))
1662     {
1663         SetLastError( ERROR_INVALID_PARAMETER );
1664         return FALSE;
1665     }
1666
1667     winpos.hwnd = WIN_GetFullHandle(hwnd);
1668     winpos.hwndInsertAfter = WIN_GetFullHandle(hwndInsertAfter);
1669     winpos.x = x;
1670     winpos.y = y;
1671     winpos.cx = cx;
1672     winpos.cy = cy;
1673     winpos.flags = flags;
1674     
1675     if (WIN_IsCurrentThread( hwnd ))
1676         return USER_SetWindowPos(&winpos);
1677
1678     return SendMessageW( winpos.hwnd, WM_WINE_SETWINDOWPOS, 0, (LPARAM)&winpos );
1679 }
1680
1681
1682 /***********************************************************************
1683  *              BeginDeferWindowPos (USER32.@)
1684  */
1685 HDWP WINAPI BeginDeferWindowPos( INT count )
1686 {
1687     HDWP handle;
1688     DWP *pDWP;
1689
1690     TRACE("%d\n", count);
1691
1692     if (count < 0)
1693     {
1694         SetLastError(ERROR_INVALID_PARAMETER);
1695         return 0;
1696     }
1697     /* Windows allows zero count, in which case it allocates context for 8 moves */
1698     if (count == 0) count = 8;
1699
1700     handle = USER_HEAP_ALLOC( sizeof(DWP) + (count-1)*sizeof(WINDOWPOS) );
1701     if (!handle) return 0;
1702     pDWP = (DWP *) USER_HEAP_LIN_ADDR( handle );
1703     pDWP->actualCount    = 0;
1704     pDWP->suggestedCount = count;
1705     pDWP->valid          = TRUE;
1706     pDWP->wMagic         = DWP_MAGIC;
1707     pDWP->hwndParent     = 0;
1708
1709     TRACE("returning hdwp %p\n", handle);
1710     return handle;
1711 }
1712
1713
1714 /***********************************************************************
1715  *              DeferWindowPos (USER32.@)
1716  */
1717 HDWP WINAPI DeferWindowPos( HDWP hdwp, HWND hwnd, HWND hwndAfter,
1718                                 INT x, INT y, INT cx, INT cy,
1719                                 UINT flags )
1720 {
1721     DWP *pDWP;
1722     int i;
1723     HDWP newhdwp = hdwp,retvalue;
1724
1725     TRACE("hdwp %p, hwnd %p, after %p, %d,%d (%dx%d), flags %08x\n",
1726           hdwp, hwnd, hwndAfter, x, y, cx, cy, flags);
1727
1728     hwnd = WIN_GetFullHandle( hwnd );
1729     if (hwnd == GetDesktopWindow()) return 0;
1730
1731     if (!(pDWP = USER_HEAP_LIN_ADDR( hdwp ))) return 0;
1732
1733     USER_Lock();
1734
1735     for (i = 0; i < pDWP->actualCount; i++)
1736     {
1737         if (pDWP->winPos[i].hwnd == hwnd)
1738         {
1739               /* Merge with the other changes */
1740             if (!(flags & SWP_NOZORDER))
1741             {
1742                 pDWP->winPos[i].hwndInsertAfter = WIN_GetFullHandle(hwndAfter);
1743             }
1744             if (!(flags & SWP_NOMOVE))
1745             {
1746                 pDWP->winPos[i].x = x;
1747                 pDWP->winPos[i].y = y;
1748             }
1749             if (!(flags & SWP_NOSIZE))
1750             {
1751                 pDWP->winPos[i].cx = cx;
1752                 pDWP->winPos[i].cy = cy;
1753             }
1754             pDWP->winPos[i].flags &= flags | ~(SWP_NOSIZE | SWP_NOMOVE |
1755                                                SWP_NOZORDER | SWP_NOREDRAW |
1756                                                SWP_NOACTIVATE | SWP_NOCOPYBITS|
1757                                                SWP_NOOWNERZORDER);
1758             pDWP->winPos[i].flags |= flags & (SWP_SHOWWINDOW | SWP_HIDEWINDOW |
1759                                               SWP_FRAMECHANGED);
1760             retvalue = hdwp;
1761             goto END;
1762         }
1763     }
1764     if (pDWP->actualCount >= pDWP->suggestedCount)
1765     {
1766         newhdwp = USER_HEAP_REALLOC( hdwp,
1767                       sizeof(DWP) + pDWP->suggestedCount*sizeof(WINDOWPOS) );
1768         if (!newhdwp)
1769         {
1770             retvalue = 0;
1771             goto END;
1772         }
1773         pDWP = (DWP *) USER_HEAP_LIN_ADDR( newhdwp );
1774         pDWP->suggestedCount++;
1775     }
1776     pDWP->winPos[pDWP->actualCount].hwnd = hwnd;
1777     pDWP->winPos[pDWP->actualCount].hwndInsertAfter = hwndAfter;
1778     pDWP->winPos[pDWP->actualCount].x = x;
1779     pDWP->winPos[pDWP->actualCount].y = y;
1780     pDWP->winPos[pDWP->actualCount].cx = cx;
1781     pDWP->winPos[pDWP->actualCount].cy = cy;
1782     pDWP->winPos[pDWP->actualCount].flags = flags;
1783     pDWP->actualCount++;
1784     retvalue = newhdwp;
1785 END:
1786     USER_Unlock();
1787     return retvalue;
1788 }
1789
1790
1791 /***********************************************************************
1792  *              EndDeferWindowPos (USER32.@)
1793  */
1794 BOOL WINAPI EndDeferWindowPos( HDWP hdwp )
1795 {
1796     DWP *pDWP;
1797     WINDOWPOS *winpos;
1798     BOOL res = TRUE;
1799     int i;
1800
1801     TRACE("%p\n", hdwp);
1802
1803     pDWP = (DWP *) USER_HEAP_LIN_ADDR( hdwp );
1804     if (!pDWP) return FALSE;
1805     for (i = 0, winpos = pDWP->winPos; i < pDWP->actualCount; i++, winpos++)
1806     {
1807         TRACE("hwnd %p, after %p, %d,%d (%dx%d), flags %08x\n",
1808                winpos->hwnd, winpos->hwndInsertAfter, winpos->x, winpos->y,
1809                winpos->cx, winpos->cy, winpos->flags);
1810
1811         if (!(res = USER_SetWindowPos( winpos ))) break;
1812     }
1813     USER_HEAP_FREE( hdwp );
1814     return res;
1815 }
1816
1817
1818 /***********************************************************************
1819  *              TileChildWindows (USER.199)
1820  */
1821 void WINAPI TileChildWindows16( HWND16 parent, WORD action )
1822 {
1823     FIXME("(%04x, %d): stub\n", parent, action);
1824 }
1825
1826 /***********************************************************************
1827  *              CascadeChildWindows (USER.198)
1828  */
1829 void WINAPI CascadeChildWindows16( HWND16 parent, WORD action )
1830 {
1831     FIXME("(%04x, %d): stub\n", parent, action);
1832 }