2 * Window position related functions.
4 * Copyright 1993, 1994, 1995 Alexandre Julliard
5 * 1995, 1996 Alex Korobka
9 #include "sysmetrics.h"
20 #include "nonclient.h"
23 #define HAS_DLGFRAME(style,exStyle) \
24 (((exStyle) & WS_EX_DLGMODALFRAME) || \
25 (((style) & WS_DLGFRAME) && !((style) & WS_BORDER)))
27 #define HAS_THICKFRAME(style) \
28 (((style) & WS_THICKFRAME) && \
29 !(((style) & (WS_DLGFRAME|WS_BORDER)) == WS_DLGFRAME))
31 #define SWP_AGG_NOGEOMETRYCHANGE \
32 (SWP_NOSIZE | SWP_NOMOVE | SWP_NOCLIENTSIZE | SWP_NOCLIENTMOVE)
33 #define SWP_AGG_NOPOSCHANGE \
34 (SWP_AGG_NOGEOMETRYCHANGE | SWP_NOZORDER)
35 #define SWP_AGG_STATUSFLAGS \
36 (SWP_AGG_NOPOSCHANGE | SWP_FRAMECHANGED | SWP_HIDEWINDOW | SWP_SHOWWINDOW)
38 #define EMPTYPOINT(pt) ((*(LONG*)&(pt)) == -1)
40 #define PLACE_MIN 0x0001
41 #define PLACE_MAX 0x0002
42 #define PLACE_RECT 0x0004
44 #define SMC_NOCOPY 0x0001
45 #define SMC_NOPARENTERASE 0x0002
46 #define SMC_DRAWFRAME 0x0004
47 #define SMC_SETXPOS 0x0008
49 /* ----- internal variables ----- */
51 static HWND32 hwndActive
= 0; /* Currently active window */
52 static HWND32 hwndPrevActive
= 0; /* Previously active window */
53 static HWND32 hGlobalShellWindow
=0; /*the shell*/
55 static LPCSTR atomInternalPos
;
57 extern MESSAGEQUEUE
* pActiveQueue
;
59 /***********************************************************************
60 * WINPOS_CreateInternalPosAtom
62 BOOL32
WINPOS_CreateInternalPosAtom()
65 atomInternalPos
= (LPCSTR
)(DWORD
)GlobalAddAtom32A(str
);
66 return (atomInternalPos
) ? TRUE
: FALSE
;
69 /***********************************************************************
70 * WINPOS_CheckInternalPos
72 * Called when a window is destroyed.
74 void WINPOS_CheckInternalPos( HWND32 hwnd
)
76 LPINTERNALPOS lpPos
= (LPINTERNALPOS
) GetProp32A( hwnd
, atomInternalPos
);
78 if( hwnd
== hwndPrevActive
) hwndPrevActive
= 0;
79 if( hwnd
== hwndActive
)
82 WARN(win
, "\tattempt to activate destroyed window!\n");
87 if( IsWindow32(lpPos
->hwndIconTitle
) )
88 DestroyWindow32( lpPos
->hwndIconTitle
);
89 HeapFree( SystemHeap
, 0, lpPos
);
93 /***********************************************************************
96 * Find a suitable place for an iconic window.
98 static POINT16
WINPOS_FindIconPos( WND
* wndPtr
, POINT16 pt
)
101 short x
, y
, xspacing
, yspacing
;
103 GetClientRect16( wndPtr
->parent
->hwndSelf
, &rectParent
);
104 if ((pt
.x
>= rectParent
.left
) && (pt
.x
+ SYSMETRICS_CXICON
< rectParent
.right
) &&
105 (pt
.y
>= rectParent
.top
) && (pt
.y
+ SYSMETRICS_CYICON
< rectParent
.bottom
))
106 return pt
; /* The icon already has a suitable position */
108 xspacing
= SYSMETRICS_CXICONSPACING
;
109 yspacing
= SYSMETRICS_CYICONSPACING
;
111 y
= rectParent
.bottom
;
114 for (x
= rectParent
.left
; x
<= rectParent
.right
-xspacing
; x
+= xspacing
)
116 /* Check if another icon already occupies this spot */
117 WND
*childPtr
= wndPtr
->parent
->child
;
120 if ((childPtr
->dwStyle
& WS_MINIMIZE
) && (childPtr
!= wndPtr
))
122 if ((childPtr
->rectWindow
.left
< x
+ xspacing
) &&
123 (childPtr
->rectWindow
.right
>= x
) &&
124 (childPtr
->rectWindow
.top
<= y
) &&
125 (childPtr
->rectWindow
.bottom
> y
- yspacing
))
126 break; /* There's a window in there */
128 childPtr
= childPtr
->next
;
130 if (!childPtr
) /* No window was found, so it's OK for us */
132 pt
.x
= x
+ (xspacing
- SYSMETRICS_CXICON
) / 2;
133 pt
.y
= y
- (yspacing
+ SYSMETRICS_CYICON
) / 2;
142 /***********************************************************************
143 * ArrangeIconicWindows16 (USER.170)
145 UINT16 WINAPI
ArrangeIconicWindows16( HWND16 parent
)
147 return ArrangeIconicWindows32(parent
);
149 /***********************************************************************
150 * ArrangeIconicWindows32 (USER32.7)
152 UINT32 WINAPI
ArrangeIconicWindows32( HWND32 parent
)
156 INT32 x
, y
, xspacing
, yspacing
;
158 GetClientRect32( parent
, &rectParent
);
160 y
= rectParent
.bottom
;
161 xspacing
= SYSMETRICS_CXICONSPACING
;
162 yspacing
= SYSMETRICS_CYICONSPACING
;
164 hwndChild
= GetWindow32( parent
, GW_CHILD
);
167 if( IsIconic32( hwndChild
) )
169 WINPOS_ShowIconTitle( WIN_FindWndPtr(hwndChild
), FALSE
);
170 SetWindowPos32( hwndChild
, 0, x
+ (xspacing
- SYSMETRICS_CXICON
) / 2,
171 y
- yspacing
- SYSMETRICS_CYICON
/2, 0, 0,
172 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
173 if( IsWindow32(hwndChild
) )
174 WINPOS_ShowIconTitle( WIN_FindWndPtr(hwndChild
), TRUE
);
175 if (x
<= rectParent
.right
- xspacing
) x
+= xspacing
;
182 hwndChild
= GetWindow32( hwndChild
, GW_HWNDNEXT
);
188 /***********************************************************************
189 * SwitchToThisWindow16 (USER.172)
191 void WINAPI
SwitchToThisWindow16( HWND16 hwnd
, BOOL16 restore
)
193 SwitchToThisWindow32( hwnd
, restore
);
197 /***********************************************************************
198 * SwitchToThisWindow32 (USER32.539)
200 void WINAPI
SwitchToThisWindow32( HWND32 hwnd
, BOOL32 restore
)
202 ShowWindow32( hwnd
, restore
? SW_RESTORE
: SW_SHOWMINIMIZED
);
206 /***********************************************************************
207 * GetWindowRect16 (USER.32)
209 void WINAPI
GetWindowRect16( HWND16 hwnd
, LPRECT16 rect
)
211 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
214 CONV_RECT32TO16( &wndPtr
->rectWindow
, rect
);
215 if (wndPtr
->dwStyle
& WS_CHILD
)
216 MapWindowPoints16( wndPtr
->parent
->hwndSelf
, 0, (POINT16
*)rect
, 2 );
220 /***********************************************************************
221 * GetWindowRect32 (USER32.308)
223 BOOL32 WINAPI
GetWindowRect32( HWND32 hwnd
, LPRECT32 rect
)
225 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
226 if (!wndPtr
) return FALSE
;
228 *rect
= wndPtr
->rectWindow
;
229 if (wndPtr
->dwStyle
& WS_CHILD
)
230 MapWindowPoints32( wndPtr
->parent
->hwndSelf
, 0, (POINT32
*)rect
, 2 );
235 /***********************************************************************
238 BOOL32 WINAPI
GetWindowRgn32 ( HWND32 hwnd
, HRGN32 hrgn
)
242 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
243 if (!wndPtr
) return (ERROR
);
245 FIXME (win
, "GetWindowRgn32: doesn't really do regions\n");
247 memset (&rect
, 0, sizeof(rect
));
249 GetWindowRect32 ( hwnd
, &rect
);
251 FIXME (win
, "Check whether a valid region here\n");
253 SetRectRgn32 ( hrgn
, rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
255 return (SIMPLEREGION
);
258 /***********************************************************************
261 INT32 WINAPI
SetWindowRgn32( HWND32 hwnd
, HRGN32 hrgn
,BOOL32 bRedraw
)
265 FIXME (win
, "SetWindowRgn32: stub\n");
269 /***********************************************************************
272 INT16 WINAPI
SetWindowRgn16( HWND16 hwnd
, HRGN16 hrgn
,BOOL16 bRedraw
)
276 FIXME (win
, "SetWindowRgn16: stub\n");
281 /***********************************************************************
282 * GetClientRect16 (USER.33)
284 void WINAPI
GetClientRect16( HWND16 hwnd
, LPRECT16 rect
)
286 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
288 rect
->left
= rect
->top
= rect
->right
= rect
->bottom
= 0;
291 rect
->right
= wndPtr
->rectClient
.right
- wndPtr
->rectClient
.left
;
292 rect
->bottom
= wndPtr
->rectClient
.bottom
- wndPtr
->rectClient
.top
;
297 /***********************************************************************
298 * GetClientRect32 (USER32.220)
300 void WINAPI
GetClientRect32( HWND32 hwnd
, LPRECT32 rect
)
302 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
304 rect
->left
= rect
->top
= rect
->right
= rect
->bottom
= 0;
307 rect
->right
= wndPtr
->rectClient
.right
- wndPtr
->rectClient
.left
;
308 rect
->bottom
= wndPtr
->rectClient
.bottom
- wndPtr
->rectClient
.top
;
313 /*******************************************************************
314 * ClientToScreen16 (USER.28)
316 void WINAPI
ClientToScreen16( HWND16 hwnd
, LPPOINT16 lppnt
)
318 MapWindowPoints16( hwnd
, 0, lppnt
, 1 );
322 /*******************************************************************
323 * ClientToScreen32 (USER32.52)
325 BOOL32 WINAPI
ClientToScreen32( HWND32 hwnd
, LPPOINT32 lppnt
)
327 MapWindowPoints32( hwnd
, 0, lppnt
, 1 );
332 /*******************************************************************
333 * ScreenToClient16 (USER.29)
335 void WINAPI
ScreenToClient16( HWND16 hwnd
, LPPOINT16 lppnt
)
337 MapWindowPoints16( 0, hwnd
, lppnt
, 1 );
341 /*******************************************************************
342 * ScreenToClient32 (USER32.447)
344 void WINAPI
ScreenToClient32( HWND32 hwnd
, LPPOINT32 lppnt
)
346 MapWindowPoints32( 0, hwnd
, lppnt
, 1 );
350 /***********************************************************************
351 * WINPOS_WindowFromPoint
353 * Find the window and hittest for a given point.
355 INT16
WINPOS_WindowFromPoint( WND
* wndScope
, POINT16 pt
, WND
**ppWnd
)
358 INT16 hittest
= HTERROR
;
362 wndPtr
= wndScope
->child
;
363 if( wndScope
->flags
& WIN_MANAGED
)
365 /* this prevents mouse clicks from going "through" scrollbars in managed mode */
366 if( pt
.x
< wndScope
->rectClient
.left
|| pt
.x
>= wndScope
->rectClient
.right
||
367 pt
.y
< wndScope
->rectClient
.top
|| pt
.y
>= wndScope
->rectClient
.bottom
)
370 MapWindowPoints16( GetDesktopWindow16(), wndScope
->hwndSelf
, &xy
, 1 );
376 /* If point is in window, and window is visible, and it */
377 /* is enabled (or it's a top-level window), then explore */
378 /* its children. Otherwise, go to the next window. */
380 if ((wndPtr
->dwStyle
& WS_VISIBLE
) &&
381 (!(wndPtr
->dwStyle
& WS_DISABLED
) ||
382 ((wndPtr
->dwStyle
& (WS_POPUP
| WS_CHILD
)) != WS_CHILD
)) &&
383 (xy
.x
>= wndPtr
->rectWindow
.left
) &&
384 (xy
.x
< wndPtr
->rectWindow
.right
) &&
385 (xy
.y
>= wndPtr
->rectWindow
.top
) &&
386 (xy
.y
< wndPtr
->rectWindow
.bottom
))
388 *ppWnd
= wndPtr
; /* Got a suitable window */
390 /* If window is minimized or disabled, return at once */
391 if (wndPtr
->dwStyle
& WS_MINIMIZE
) return HTCAPTION
;
392 if (wndPtr
->dwStyle
& WS_DISABLED
) return HTERROR
;
394 /* If point is not in client area, ignore the children */
395 if ((xy
.x
< wndPtr
->rectClient
.left
) ||
396 (xy
.x
>= wndPtr
->rectClient
.right
) ||
397 (xy
.y
< wndPtr
->rectClient
.top
) ||
398 (xy
.y
>= wndPtr
->rectClient
.bottom
)) break;
400 xy
.x
-= wndPtr
->rectClient
.left
;
401 xy
.y
-= wndPtr
->rectClient
.top
;
402 wndPtr
= wndPtr
->child
;
404 else wndPtr
= wndPtr
->next
;
408 /* If nothing found, try the scope window */
409 if (!*ppWnd
) *ppWnd
= wndScope
;
411 /* Send the WM_NCHITTEST message (only if to the same task) */
412 if ((*ppWnd
)->hmemTaskQ
== GetTaskQueue(0))
414 hittest
= (INT16
)SendMessage16( (*ppWnd
)->hwndSelf
, WM_NCHITTEST
,
415 0, MAKELONG( pt
.x
, pt
.y
) );
416 if (hittest
!= HTTRANSPARENT
) return hittest
; /* Found the window */
418 else return HTCLIENT
;
420 /* If no children found in last search, make point relative to parent */
423 xy
.x
+= (*ppWnd
)->rectClient
.left
;
424 xy
.y
+= (*ppWnd
)->rectClient
.top
;
427 /* Restart the search from the next sibling */
428 wndPtr
= (*ppWnd
)->next
;
429 *ppWnd
= (*ppWnd
)->parent
;
434 /*******************************************************************
435 * WindowFromPoint16 (USER.30)
437 HWND16 WINAPI
WindowFromPoint16( POINT16 pt
)
440 WINPOS_WindowFromPoint( WIN_GetDesktop(), pt
, &pWnd
);
441 return pWnd
->hwndSelf
;
445 /*******************************************************************
446 * WindowFromPoint32 (USER32.582)
448 HWND32 WINAPI
WindowFromPoint32( POINT32 pt
)
452 CONV_POINT32TO16( &pt
, &pt16
);
453 WINPOS_WindowFromPoint( WIN_GetDesktop(), pt16
, &pWnd
);
454 return (HWND32
)pWnd
->hwndSelf
;
458 /*******************************************************************
459 * ChildWindowFromPoint16 (USER.191)
461 HWND16 WINAPI
ChildWindowFromPoint16( HWND16 hwndParent
, POINT16 pt
)
464 CONV_POINT16TO32( &pt
, &pt32
);
465 return (HWND16
)ChildWindowFromPoint32( hwndParent
, pt32
);
469 /*******************************************************************
470 * ChildWindowFromPoint32 (USER32.49)
472 HWND32 WINAPI
ChildWindowFromPoint32( HWND32 hwndParent
, POINT32 pt
)
474 /* pt is in the client coordinates */
476 WND
* wnd
= WIN_FindWndPtr(hwndParent
);
481 /* get client rect fast */
482 rect
.top
= rect
.left
= 0;
483 rect
.right
= wnd
->rectClient
.right
- wnd
->rectClient
.left
;
484 rect
.bottom
= wnd
->rectClient
.bottom
- wnd
->rectClient
.top
;
486 if (!PtInRect32( &rect
, pt
)) return 0;
491 if (PtInRect32( &wnd
->rectWindow
, pt
)) return wnd
->hwndSelf
;
497 /*******************************************************************
498 * ChildWindowFromPointEx16 (USER.50)
500 HWND16 WINAPI
ChildWindowFromPointEx16( HWND16 hwndParent
, POINT16 pt
, UINT16 uFlags
)
503 CONV_POINT16TO32( &pt
, &pt32
);
504 return (HWND16
)ChildWindowFromPointEx32( hwndParent
, pt32
, uFlags
);
508 /*******************************************************************
509 * ChildWindowFromPointEx32 (USER32.50)
511 HWND32 WINAPI
ChildWindowFromPointEx32( HWND32 hwndParent
, POINT32 pt
,
514 /* pt is in the client coordinates */
516 WND
* wnd
= WIN_FindWndPtr(hwndParent
);
521 /* get client rect fast */
522 rect
.top
= rect
.left
= 0;
523 rect
.right
= wnd
->rectClient
.right
- wnd
->rectClient
.left
;
524 rect
.bottom
= wnd
->rectClient
.bottom
- wnd
->rectClient
.top
;
526 if (!PtInRect32( &rect
, pt
)) return 0;
531 if (PtInRect32( &wnd
->rectWindow
, pt
)) {
532 if ( (uFlags
& CWP_SKIPINVISIBLE
) &&
533 !(wnd
->dwStyle
& WS_VISIBLE
) )
535 else if ( (uFlags
& CWP_SKIPDISABLED
) &&
536 (wnd
->dwStyle
& WS_DISABLED
) )
538 else if ( (uFlags
& CWP_SKIPTRANSPARENT
) &&
539 (wnd
->dwExStyle
& WS_EX_TRANSPARENT
) )
542 return wnd
->hwndSelf
;
549 /*******************************************************************
550 * WINPOS_GetWinOffset
552 * Calculate the offset between the origin of the two windows. Used
553 * to implement MapWindowPoints.
555 static void WINPOS_GetWinOffset( HWND32 hwndFrom
, HWND32 hwndTo
,
560 offset
->x
= offset
->y
= 0;
561 if (hwndFrom
== hwndTo
) return;
563 /* Translate source window origin to screen coords */
566 if (!(wndPtr
= WIN_FindWndPtr( hwndFrom
)))
568 ERR(win
,"bad hwndFrom = %04x\n",hwndFrom
);
571 while (wndPtr
->parent
)
573 offset
->x
+= wndPtr
->rectClient
.left
;
574 offset
->y
+= wndPtr
->rectClient
.top
;
575 wndPtr
= wndPtr
->parent
;
579 /* Translate origin to destination window coords */
582 if (!(wndPtr
= WIN_FindWndPtr( hwndTo
)))
584 ERR(win
,"bad hwndTo = %04x\n", hwndTo
);
587 while (wndPtr
->parent
)
589 offset
->x
-= wndPtr
->rectClient
.left
;
590 offset
->y
-= wndPtr
->rectClient
.top
;
591 wndPtr
= wndPtr
->parent
;
597 /*******************************************************************
598 * MapWindowPoints16 (USER.258)
600 void WINAPI
MapWindowPoints16( HWND16 hwndFrom
, HWND16 hwndTo
,
601 LPPOINT16 lppt
, UINT16 count
)
605 WINPOS_GetWinOffset( hwndFrom
, hwndTo
, &offset
);
615 /*******************************************************************
616 * MapWindowPoints32 (USER32.386)
618 void WINAPI
MapWindowPoints32( HWND32 hwndFrom
, HWND32 hwndTo
,
619 LPPOINT32 lppt
, UINT32 count
)
623 WINPOS_GetWinOffset( hwndFrom
, hwndTo
, &offset
);
633 /***********************************************************************
634 * IsIconic16 (USER.31)
636 BOOL16 WINAPI
IsIconic16(HWND16 hWnd
)
638 return IsIconic32(hWnd
);
642 /***********************************************************************
643 * IsIconic32 (USER32.345)
645 BOOL32 WINAPI
IsIconic32(HWND32 hWnd
)
647 WND
* wndPtr
= WIN_FindWndPtr(hWnd
);
648 if (wndPtr
== NULL
) return FALSE
;
649 return (wndPtr
->dwStyle
& WS_MINIMIZE
) != 0;
653 /***********************************************************************
654 * IsZoomed (USER.272)
656 BOOL16 WINAPI
IsZoomed16(HWND16 hWnd
)
658 return IsZoomed32(hWnd
);
662 /***********************************************************************
663 * IsZoomed (USER32.352)
665 BOOL32 WINAPI
IsZoomed32(HWND32 hWnd
)
667 WND
* wndPtr
= WIN_FindWndPtr(hWnd
);
668 if (wndPtr
== NULL
) return FALSE
;
669 return (wndPtr
->dwStyle
& WS_MAXIMIZE
) != 0;
673 /*******************************************************************
674 * GetActiveWindow (USER.60)
676 HWND16 WINAPI
GetActiveWindow16(void)
678 return (HWND16
)hwndActive
;
681 /*******************************************************************
682 * GetActiveWindow (USER32.205)
684 HWND32 WINAPI
GetActiveWindow32(void)
686 return (HWND32
)hwndActive
;
690 /*******************************************************************
693 static BOOL32
WINPOS_CanActivate(WND
* pWnd
)
695 if( pWnd
&& ((pWnd
->dwStyle
& (WS_DISABLED
| WS_VISIBLE
| WS_CHILD
))
696 == WS_VISIBLE
) ) return TRUE
;
701 /*******************************************************************
702 * SetActiveWindow16 (USER.59)
704 HWND16 WINAPI
SetActiveWindow16( HWND16 hwnd
)
706 return SetActiveWindow32(hwnd
);
710 /*******************************************************************
711 * SetActiveWindow32 (USER32.463)
713 HWND32 WINAPI
SetActiveWindow32( HWND32 hwnd
)
715 HWND32 prev
= hwndActive
;
716 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
718 if ( !WINPOS_CanActivate(wndPtr
) ) return 0;
720 WINPOS_SetActiveWindow( hwnd
, 0, 0 );
725 /*******************************************************************
726 * GetForegroundWindow16 (USER.608)
728 HWND16 WINAPI
GetForegroundWindow16(void)
730 return (HWND16
)GetForegroundWindow32();
734 /*******************************************************************
735 * SetForegroundWindow16 (USER.609)
737 BOOL16 WINAPI
SetForegroundWindow16( HWND16 hwnd
)
739 return SetForegroundWindow32( hwnd
);
743 /*******************************************************************
744 * GetForegroundWindow32 (USER32.241)
746 HWND32 WINAPI
GetForegroundWindow32(void)
748 return GetActiveWindow32();
752 /*******************************************************************
753 * SetForegroundWindow32 (USER32.482)
755 BOOL32 WINAPI
SetForegroundWindow32( HWND32 hwnd
)
757 SetActiveWindow32( hwnd
);
762 /*******************************************************************
763 * GetShellWindow16 (USER.600)
765 HWND16 WINAPI
GetShellWindow16(void)
767 return GetShellWindow32();
770 /*******************************************************************
771 * SetShellWindow32 (USER32.504)
773 HWND32 WINAPI
SetShellWindow32(HWND32 hwndshell
)
774 { WARN(win
, "(hWnd=%08x) semi stub\n",hwndshell
);
776 hGlobalShellWindow
= hwndshell
;
777 return hGlobalShellWindow
;
781 /*******************************************************************
782 * GetShellWindow32 (USER32.287)
784 HWND32 WINAPI
GetShellWindow32(void)
785 { WARN(win
, "(hWnd=%x) semi stub\n",hGlobalShellWindow
);
787 return hGlobalShellWindow
;
791 /***********************************************************************
792 * BringWindowToTop16 (USER.45)
794 BOOL16 WINAPI
BringWindowToTop16( HWND16 hwnd
)
796 return BringWindowToTop32(hwnd
);
800 /***********************************************************************
801 * BringWindowToTop32 (USER32.11)
803 BOOL32 WINAPI
BringWindowToTop32( HWND32 hwnd
)
805 return SetWindowPos32( hwnd
, HWND_TOP
, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
);
809 /***********************************************************************
810 * MoveWindow16 (USER.56)
812 BOOL16 WINAPI
MoveWindow16( HWND16 hwnd
, INT16 x
, INT16 y
, INT16 cx
, INT16 cy
,
815 return MoveWindow32(hwnd
,x
,y
,cx
,cy
,repaint
);
819 /***********************************************************************
820 * MoveWindow32 (USER32.399)
822 BOOL32 WINAPI
MoveWindow32( HWND32 hwnd
, INT32 x
, INT32 y
, INT32 cx
, INT32 cy
,
825 int flags
= SWP_NOZORDER
| SWP_NOACTIVATE
;
826 if (!repaint
) flags
|= SWP_NOREDRAW
;
827 TRACE(win
, "%04x %d,%d %dx%d %d\n",
828 hwnd
, x
, y
, cx
, cy
, repaint
);
829 return SetWindowPos32( hwnd
, 0, x
, y
, cx
, cy
, flags
);
832 /***********************************************************************
833 * WINPOS_InitInternalPos
835 static LPINTERNALPOS
WINPOS_InitInternalPos( WND
* wnd
, POINT32 pt
,
836 LPRECT32 restoreRect
)
838 LPINTERNALPOS lpPos
= (LPINTERNALPOS
) GetProp32A( wnd
->hwndSelf
,
842 /* this happens when the window is minimized/maximized
843 * for the first time (rectWindow is not adjusted yet) */
845 lpPos
= HeapAlloc( SystemHeap
, 0, sizeof(INTERNALPOS
) );
846 if( !lpPos
) return NULL
;
848 SetProp32A( wnd
->hwndSelf
, atomInternalPos
, (HANDLE32
)lpPos
);
849 lpPos
->hwndIconTitle
= 0; /* defer until needs to be shown */
850 CONV_RECT32TO16( &wnd
->rectWindow
, &lpPos
->rectNormal
);
851 *(UINT32
*)&lpPos
->ptIconPos
= *(UINT32
*)&lpPos
->ptMaxPos
= 0xFFFFFFFF;
854 if( wnd
->dwStyle
& WS_MINIMIZE
)
855 CONV_POINT32TO16( &pt
, &lpPos
->ptIconPos
);
856 else if( wnd
->dwStyle
& WS_MAXIMIZE
)
857 CONV_POINT32TO16( &pt
, &lpPos
->ptMaxPos
);
858 else if( restoreRect
)
859 CONV_RECT32TO16( restoreRect
, &lpPos
->rectNormal
);
864 /***********************************************************************
865 * WINPOS_RedrawIconTitle
867 BOOL32
WINPOS_RedrawIconTitle( HWND32 hWnd
)
869 LPINTERNALPOS lpPos
= (LPINTERNALPOS
)GetProp32A( hWnd
, atomInternalPos
);
872 if( lpPos
->hwndIconTitle
)
874 SendMessage32A( lpPos
->hwndIconTitle
, WM_SHOWWINDOW
, TRUE
, 0);
875 InvalidateRect32( lpPos
->hwndIconTitle
, NULL
, TRUE
);
882 /***********************************************************************
883 * WINPOS_ShowIconTitle
885 BOOL32
WINPOS_ShowIconTitle( WND
* pWnd
, BOOL32 bShow
)
887 LPINTERNALPOS lpPos
= (LPINTERNALPOS
)GetProp32A( pWnd
->hwndSelf
, atomInternalPos
);
889 if( lpPos
&& !(pWnd
->flags
& WIN_MANAGED
))
891 HWND16 hWnd
= lpPos
->hwndIconTitle
;
893 TRACE(win
,"0x%04x %i\n", pWnd
->hwndSelf
, (bShow
!= 0) );
896 lpPos
->hwndIconTitle
= hWnd
= ICONTITLE_Create( pWnd
);
899 pWnd
= WIN_FindWndPtr(hWnd
);
901 if( !(pWnd
->dwStyle
& WS_VISIBLE
) )
903 SendMessage32A( hWnd
, WM_SHOWWINDOW
, TRUE
, 0 );
904 SetWindowPos32( hWnd
, 0, 0, 0, 0, 0, SWP_NOSIZE
| SWP_NOMOVE
|
905 SWP_NOACTIVATE
| SWP_NOZORDER
| SWP_SHOWWINDOW
);
908 else ShowWindow32( hWnd
, SW_HIDE
);
913 /*******************************************************************
914 * WINPOS_GetMinMaxInfo
916 * Get the minimized and maximized information for a window.
918 void WINPOS_GetMinMaxInfo( WND
*wndPtr
, POINT32
*maxSize
, POINT32
*maxPos
,
919 POINT32
*minTrack
, POINT32
*maxTrack
)
925 /* Compute default values */
927 MinMax
.ptMaxSize
.x
= SYSMETRICS_CXSCREEN
;
928 MinMax
.ptMaxSize
.y
= SYSMETRICS_CYSCREEN
;
929 MinMax
.ptMinTrackSize
.x
= SYSMETRICS_CXMINTRACK
;
930 MinMax
.ptMinTrackSize
.y
= SYSMETRICS_CYMINTRACK
;
931 MinMax
.ptMaxTrackSize
.x
= SYSMETRICS_CXSCREEN
;
932 MinMax
.ptMaxTrackSize
.y
= SYSMETRICS_CYSCREEN
;
934 if (wndPtr
->flags
& WIN_MANAGED
) xinc
= yinc
= 0;
935 else if (HAS_DLGFRAME( wndPtr
->dwStyle
, wndPtr
->dwExStyle
))
937 xinc
= SYSMETRICS_CXDLGFRAME
;
938 yinc
= SYSMETRICS_CYDLGFRAME
;
943 if (HAS_THICKFRAME(wndPtr
->dwStyle
))
945 xinc
+= SYSMETRICS_CXFRAME
;
946 yinc
+= SYSMETRICS_CYFRAME
;
948 if (wndPtr
->dwStyle
& WS_BORDER
)
950 xinc
+= SYSMETRICS_CXBORDER
;
951 yinc
+= SYSMETRICS_CYBORDER
;
954 MinMax
.ptMaxSize
.x
+= 2 * xinc
;
955 MinMax
.ptMaxSize
.y
+= 2 * yinc
;
957 lpPos
= (LPINTERNALPOS
)GetProp32A( wndPtr
->hwndSelf
, atomInternalPos
);
958 if( lpPos
&& !EMPTYPOINT(lpPos
->ptMaxPos
) )
959 CONV_POINT16TO32( &lpPos
->ptMaxPos
, &MinMax
.ptMaxPosition
);
962 MinMax
.ptMaxPosition
.x
= -xinc
;
963 MinMax
.ptMaxPosition
.y
= -yinc
;
966 SendMessage32A( wndPtr
->hwndSelf
, WM_GETMINMAXINFO
, 0, (LPARAM
)&MinMax
);
968 /* Some sanity checks */
970 TRACE(win
,"%d %d / %d %d / %d %d / %d %d\n",
971 MinMax
.ptMaxSize
.x
, MinMax
.ptMaxSize
.y
,
972 MinMax
.ptMaxPosition
.x
, MinMax
.ptMaxPosition
.y
,
973 MinMax
.ptMaxTrackSize
.x
, MinMax
.ptMaxTrackSize
.y
,
974 MinMax
.ptMinTrackSize
.x
, MinMax
.ptMinTrackSize
.y
);
975 MinMax
.ptMaxTrackSize
.x
= MAX( MinMax
.ptMaxTrackSize
.x
,
976 MinMax
.ptMinTrackSize
.x
);
977 MinMax
.ptMaxTrackSize
.y
= MAX( MinMax
.ptMaxTrackSize
.y
,
978 MinMax
.ptMinTrackSize
.y
);
980 if (maxSize
) *maxSize
= MinMax
.ptMaxSize
;
981 if (maxPos
) *maxPos
= MinMax
.ptMaxPosition
;
982 if (minTrack
) *minTrack
= MinMax
.ptMinTrackSize
;
983 if (maxTrack
) *maxTrack
= MinMax
.ptMaxTrackSize
;
986 /***********************************************************************
989 * Fill in lpRect and return additional flags to be used with SetWindowPos().
990 * This function assumes that 'cmd' is different from the current window
993 UINT16
WINPOS_MinMaximize( WND
* wndPtr
, UINT16 cmd
, LPRECT16 lpRect
)
997 POINT32 size
= { wndPtr
->rectWindow
.left
, wndPtr
->rectWindow
.top
};
998 LPINTERNALPOS lpPos
= WINPOS_InitInternalPos( wndPtr
, size
,
999 &wndPtr
->rectWindow
);
1001 TRACE(win
,"0x%04x %u\n", wndPtr
->hwndSelf
, cmd
);
1003 if (lpPos
&& !HOOK_CallHooks16(WH_CBT
, HCBT_MINMAX
, wndPtr
->hwndSelf
, cmd
))
1005 if( wndPtr
->dwStyle
& WS_MINIMIZE
)
1007 if( !SendMessage32A( wndPtr
->hwndSelf
, WM_QUERYOPEN
, 0, 0L ) )
1008 return (SWP_NOSIZE
| SWP_NOMOVE
);
1009 swpFlags
|= SWP_NOCOPYBITS
;
1014 if( wndPtr
->dwStyle
& WS_MAXIMIZE
)
1016 wndPtr
->flags
|= WIN_RESTORE_MAX
;
1017 wndPtr
->dwStyle
&= ~WS_MAXIMIZE
;
1020 wndPtr
->flags
&= ~WIN_RESTORE_MAX
;
1021 wndPtr
->dwStyle
|= WS_MINIMIZE
;
1023 lpPos
->ptIconPos
= WINPOS_FindIconPos( wndPtr
, lpPos
->ptIconPos
);
1025 SetRect16( lpRect
, lpPos
->ptIconPos
.x
, lpPos
->ptIconPos
.y
,
1026 SYSMETRICS_CXICON
, SYSMETRICS_CYICON
);
1027 swpFlags
|= SWP_NOCOPYBITS
;
1031 CONV_POINT16TO32( &lpPos
->ptMaxPos
, &pt
);
1032 WINPOS_GetMinMaxInfo( wndPtr
, &size
, &pt
, NULL
, NULL
);
1033 CONV_POINT32TO16( &pt
, &lpPos
->ptMaxPos
);
1035 if( wndPtr
->dwStyle
& WS_MINIMIZE
)
1037 WINPOS_ShowIconTitle( wndPtr
, FALSE
);
1038 wndPtr
->dwStyle
&= ~WS_MINIMIZE
;
1040 wndPtr
->dwStyle
|= WS_MAXIMIZE
;
1042 SetRect16( lpRect
, lpPos
->ptMaxPos
.x
, lpPos
->ptMaxPos
.y
,
1047 if( wndPtr
->dwStyle
& WS_MINIMIZE
)
1049 wndPtr
->dwStyle
&= ~WS_MINIMIZE
;
1050 WINPOS_ShowIconTitle( wndPtr
, FALSE
);
1051 if( wndPtr
->flags
& WIN_RESTORE_MAX
)
1053 /* Restore to maximized position */
1054 CONV_POINT16TO32( &lpPos
->ptMaxPos
, &pt
);
1055 WINPOS_GetMinMaxInfo( wndPtr
, &size
, &pt
, NULL
, NULL
);
1056 CONV_POINT32TO16( &pt
, &lpPos
->ptMaxPos
);
1057 wndPtr
->dwStyle
|= WS_MAXIMIZE
;
1058 SetRect16( lpRect
, lpPos
->ptMaxPos
.x
, lpPos
->ptMaxPos
.y
, size
.x
, size
.y
);
1063 if( !(wndPtr
->dwStyle
& WS_MAXIMIZE
) ) return (UINT16
)(-1);
1064 else wndPtr
->dwStyle
&= ~WS_MAXIMIZE
;
1066 /* Restore to normal position */
1068 *lpRect
= lpPos
->rectNormal
;
1069 lpRect
->right
-= lpRect
->left
;
1070 lpRect
->bottom
-= lpRect
->top
;
1074 } else swpFlags
|= SWP_NOSIZE
| SWP_NOMOVE
;
1078 /***********************************************************************
1079 * ShowWindowAsync32 (USER32.535)
1081 * doesn't wait; returns immediately.
1082 * used by threads to toggle windows in other (possibly hanging) threads
1084 BOOL32 WINAPI
ShowWindowAsync32( HWND32 hwnd
, INT32 cmd
)
1086 /* FIXME: does ShowWindow32() return immediately ? */
1087 return ShowWindow32(hwnd
, cmd
);
1091 /***********************************************************************
1092 * ShowWindow16 (USER.42)
1094 BOOL16 WINAPI
ShowWindow16( HWND16 hwnd
, INT16 cmd
)
1096 return ShowWindow32(hwnd
,cmd
);
1100 /***********************************************************************
1101 * ShowWindow32 (USER32.534)
1103 BOOL32 WINAPI
ShowWindow32( HWND32 hwnd
, INT32 cmd
)
1105 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
1106 BOOL32 wasVisible
, showFlag
;
1107 RECT16 newPos
= {0, 0, 0, 0};
1110 if (!wndPtr
) return FALSE
;
1112 TRACE(win
,"hwnd=%04x, cmd=%d\n", hwnd
, cmd
);
1114 wasVisible
= (wndPtr
->dwStyle
& WS_VISIBLE
) != 0;
1119 if (!wasVisible
) return FALSE
;
1120 swp
|= SWP_HIDEWINDOW
| SWP_NOSIZE
| SWP_NOMOVE
|
1121 SWP_NOACTIVATE
| SWP_NOZORDER
;
1124 case SW_SHOWMINNOACTIVE
:
1125 swp
|= SWP_NOACTIVATE
| SWP_NOZORDER
;
1127 case SW_SHOWMINIMIZED
:
1128 swp
|= SWP_SHOWWINDOW
;
1131 swp
|= SWP_FRAMECHANGED
;
1132 if( !(wndPtr
->dwStyle
& WS_MINIMIZE
) )
1133 swp
|= WINPOS_MinMaximize( wndPtr
, SW_MINIMIZE
, &newPos
);
1134 else swp
|= SWP_NOSIZE
| SWP_NOMOVE
;
1137 case SW_SHOWMAXIMIZED
: /* same as SW_MAXIMIZE */
1138 swp
|= SWP_SHOWWINDOW
| SWP_FRAMECHANGED
;
1139 if( !(wndPtr
->dwStyle
& WS_MAXIMIZE
) )
1140 swp
|= WINPOS_MinMaximize( wndPtr
, SW_MAXIMIZE
, &newPos
);
1141 else swp
|= SWP_NOSIZE
| SWP_NOMOVE
;
1145 swp
|= SWP_NOACTIVATE
| SWP_NOZORDER
;
1148 swp
|= SWP_SHOWWINDOW
| SWP_NOSIZE
| SWP_NOMOVE
;
1151 case SW_SHOWNOACTIVATE
:
1152 swp
|= SWP_NOZORDER
;
1153 if (GetActiveWindow32()) swp
|= SWP_NOACTIVATE
;
1155 case SW_SHOWNORMAL
: /* same as SW_NORMAL: */
1156 case SW_SHOWDEFAULT
: /* FIXME: should have its own handler */
1158 swp
|= SWP_SHOWWINDOW
| SWP_FRAMECHANGED
;
1160 if( wndPtr
->dwStyle
& (WS_MINIMIZE
| WS_MAXIMIZE
) )
1161 swp
|= WINPOS_MinMaximize( wndPtr
, SW_RESTORE
, &newPos
);
1162 else swp
|= SWP_NOSIZE
| SWP_NOMOVE
;
1166 showFlag
= (cmd
!= SW_HIDE
);
1167 if (showFlag
!= wasVisible
)
1169 SendMessage32A( hwnd
, WM_SHOWWINDOW
, showFlag
, 0 );
1170 if (!IsWindow32( hwnd
)) return wasVisible
;
1173 if ((wndPtr
->dwStyle
& WS_CHILD
) &&
1174 !IsWindowVisible32( wndPtr
->parent
->hwndSelf
) &&
1175 (swp
& (SWP_NOSIZE
| SWP_NOMOVE
)) == (SWP_NOSIZE
| SWP_NOMOVE
) )
1177 /* Don't call SetWindowPos32() on invisible child windows */
1178 if (cmd
== SW_HIDE
) wndPtr
->dwStyle
&= ~WS_VISIBLE
;
1179 else wndPtr
->dwStyle
|= WS_VISIBLE
;
1183 /* We can't activate a child window */
1184 if (wndPtr
->dwStyle
& WS_CHILD
) swp
|= SWP_NOACTIVATE
| SWP_NOZORDER
;
1185 SetWindowPos32( hwnd
, HWND_TOP
,
1186 newPos
.left
, newPos
.top
, newPos
.right
, newPos
.bottom
, swp
);
1187 if (!IsWindow32( hwnd
)) return wasVisible
;
1188 else if( wndPtr
->dwStyle
& WS_MINIMIZE
) WINPOS_ShowIconTitle( wndPtr
, TRUE
);
1191 if (wndPtr
->flags
& WIN_NEED_SIZE
)
1193 /* should happen only in CreateWindowEx() */
1194 int wParam
= SIZE_RESTORED
;
1196 wndPtr
->flags
&= ~WIN_NEED_SIZE
;
1197 if (wndPtr
->dwStyle
& WS_MAXIMIZE
) wParam
= SIZE_MAXIMIZED
;
1198 else if (wndPtr
->dwStyle
& WS_MINIMIZE
) wParam
= SIZE_MINIMIZED
;
1199 SendMessage32A( hwnd
, WM_SIZE
, wParam
,
1200 MAKELONG(wndPtr
->rectClient
.right
-wndPtr
->rectClient
.left
,
1201 wndPtr
->rectClient
.bottom
-wndPtr
->rectClient
.top
));
1202 SendMessage32A( hwnd
, WM_MOVE
, 0,
1203 MAKELONG(wndPtr
->rectClient
.left
, wndPtr
->rectClient
.top
) );
1210 /***********************************************************************
1211 * GetInternalWindowPos16 (USER.460)
1213 UINT16 WINAPI
GetInternalWindowPos16( HWND16 hwnd
, LPRECT16 rectWnd
,
1216 WINDOWPLACEMENT16 wndpl
;
1217 if (GetWindowPlacement16( hwnd
, &wndpl
))
1219 if (rectWnd
) *rectWnd
= wndpl
.rcNormalPosition
;
1220 if (ptIcon
) *ptIcon
= wndpl
.ptMinPosition
;
1221 return wndpl
.showCmd
;
1227 /***********************************************************************
1228 * GetInternalWindowPos32 (USER32.245)
1230 UINT32 WINAPI
GetInternalWindowPos32( HWND32 hwnd
, LPRECT32 rectWnd
,
1233 WINDOWPLACEMENT32 wndpl
;
1234 if (GetWindowPlacement32( hwnd
, &wndpl
))
1236 if (rectWnd
) *rectWnd
= wndpl
.rcNormalPosition
;
1237 if (ptIcon
) *ptIcon
= wndpl
.ptMinPosition
;
1238 return wndpl
.showCmd
;
1243 /***********************************************************************
1244 * GetWindowPlacement16 (USER.370)
1246 BOOL16 WINAPI
GetWindowPlacement16( HWND16 hwnd
, WINDOWPLACEMENT16
*wndpl
)
1248 WND
*pWnd
= WIN_FindWndPtr( hwnd
);
1251 LPINTERNALPOS lpPos
= (LPINTERNALPOS
)WINPOS_InitInternalPos( pWnd
,
1252 *(LPPOINT32
)&pWnd
->rectWindow
.left
, &pWnd
->rectWindow
);
1253 wndpl
->length
= sizeof(*wndpl
);
1254 if( pWnd
->dwStyle
& WS_MINIMIZE
)
1255 wndpl
->showCmd
= SW_SHOWMINIMIZED
;
1257 wndpl
->showCmd
= ( pWnd
->dwStyle
& WS_MAXIMIZE
)
1258 ? SW_SHOWMAXIMIZED
: SW_SHOWNORMAL
;
1259 if( pWnd
->flags
& WIN_RESTORE_MAX
)
1260 wndpl
->flags
= WPF_RESTORETOMAXIMIZED
;
1263 wndpl
->ptMinPosition
= lpPos
->ptIconPos
;
1264 wndpl
->ptMaxPosition
= lpPos
->ptMaxPos
;
1265 wndpl
->rcNormalPosition
= lpPos
->rectNormal
;
1272 /***********************************************************************
1273 * GetWindowPlacement32 (USER32.307)
1275 BOOL32 WINAPI
GetWindowPlacement32( HWND32 hwnd
, WINDOWPLACEMENT32
*pwpl32
)
1279 WINDOWPLACEMENT16 wpl
;
1280 wpl
.length
= sizeof(wpl
);
1281 if( GetWindowPlacement16( hwnd
, &wpl
) )
1283 pwpl32
->length
= sizeof(*pwpl32
);
1284 pwpl32
->flags
= wpl
.flags
;
1285 pwpl32
->showCmd
= wpl
.showCmd
;
1286 CONV_POINT16TO32( &wpl
.ptMinPosition
, &pwpl32
->ptMinPosition
);
1287 CONV_POINT16TO32( &wpl
.ptMaxPosition
, &pwpl32
->ptMaxPosition
);
1288 CONV_RECT16TO32( &wpl
.rcNormalPosition
, &pwpl32
->rcNormalPosition
);
1296 /***********************************************************************
1297 * WINPOS_SetPlacement
1299 static BOOL32
WINPOS_SetPlacement( HWND32 hwnd
, const WINDOWPLACEMENT16
*wndpl
,
1302 WND
*pWnd
= WIN_FindWndPtr( hwnd
);
1305 LPINTERNALPOS lpPos
= (LPINTERNALPOS
)WINPOS_InitInternalPos( pWnd
,
1306 *(LPPOINT32
)&pWnd
->rectWindow
.left
, &pWnd
->rectWindow
);
1308 if( flags
& PLACE_MIN
) lpPos
->ptIconPos
= wndpl
->ptMinPosition
;
1309 if( flags
& PLACE_MAX
) lpPos
->ptMaxPos
= wndpl
->ptMaxPosition
;
1310 if( flags
& PLACE_RECT
) lpPos
->rectNormal
= wndpl
->rcNormalPosition
;
1312 if( pWnd
->dwStyle
& WS_MINIMIZE
)
1314 WINPOS_ShowIconTitle( pWnd
, FALSE
);
1315 if( wndpl
->flags
& WPF_SETMINPOSITION
&& !EMPTYPOINT(lpPos
->ptIconPos
))
1316 SetWindowPos32( hwnd
, 0, lpPos
->ptIconPos
.x
, lpPos
->ptIconPos
.y
,
1317 0, 0, SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
1319 else if( pWnd
->dwStyle
& WS_MAXIMIZE
)
1321 if( !EMPTYPOINT(lpPos
->ptMaxPos
) )
1322 SetWindowPos32( hwnd
, 0, lpPos
->ptMaxPos
.x
, lpPos
->ptMaxPos
.y
,
1323 0, 0, SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
1325 else if( flags
& PLACE_RECT
)
1326 SetWindowPos32( hwnd
, 0, lpPos
->rectNormal
.left
, lpPos
->rectNormal
.top
,
1327 lpPos
->rectNormal
.right
- lpPos
->rectNormal
.left
,
1328 lpPos
->rectNormal
.bottom
- lpPos
->rectNormal
.top
,
1329 SWP_NOZORDER
| SWP_NOACTIVATE
);
1331 ShowWindow32( hwnd
, wndpl
->showCmd
);
1332 if( IsWindow32(hwnd
) && pWnd
->dwStyle
& WS_MINIMIZE
)
1334 if( pWnd
->dwStyle
& WS_VISIBLE
) WINPOS_ShowIconTitle( pWnd
, TRUE
);
1336 /* SDK: ...valid only the next time... */
1337 if( wndpl
->flags
& WPF_RESTORETOMAXIMIZED
) pWnd
->flags
|= WIN_RESTORE_MAX
;
1345 /***********************************************************************
1346 * SetWindowPlacement16 (USER.371)
1348 BOOL16 WINAPI
SetWindowPlacement16(HWND16 hwnd
, const WINDOWPLACEMENT16
*wndpl
)
1350 return WINPOS_SetPlacement( hwnd
, wndpl
,
1351 PLACE_MIN
| PLACE_MAX
| PLACE_RECT
);
1354 /***********************************************************************
1355 * SetWindowPlacement32 (USER32.519)
1357 BOOL32 WINAPI
SetWindowPlacement32( HWND32 hwnd
, const WINDOWPLACEMENT32
*pwpl32
)
1361 WINDOWPLACEMENT16 wpl
= { sizeof(WINDOWPLACEMENT16
),
1362 pwpl32
->flags
, pwpl32
->showCmd
, { pwpl32
->ptMinPosition
.x
,
1363 pwpl32
->ptMinPosition
.y
}, { pwpl32
->ptMaxPosition
.x
,
1364 pwpl32
->ptMaxPosition
.y
}, { pwpl32
->rcNormalPosition
.left
,
1365 pwpl32
->rcNormalPosition
.top
, pwpl32
->rcNormalPosition
.right
,
1366 pwpl32
->rcNormalPosition
.bottom
} };
1368 return WINPOS_SetPlacement( hwnd
, &wpl
, PLACE_MIN
| PLACE_MAX
| PLACE_RECT
);
1374 /***********************************************************************
1375 * SetInternalWindowPos16 (USER.461)
1377 void WINAPI
SetInternalWindowPos16( HWND16 hwnd
, UINT16 showCmd
,
1378 LPRECT16 rect
, LPPOINT16 pt
)
1380 if( IsWindow16(hwnd
) )
1382 WINDOWPLACEMENT16 wndpl
;
1385 wndpl
.length
= sizeof(wndpl
);
1386 wndpl
.showCmd
= showCmd
;
1387 wndpl
.flags
= flags
= 0;
1392 wndpl
.flags
|= WPF_SETMINPOSITION
;
1393 wndpl
.ptMinPosition
= *pt
;
1397 flags
|= PLACE_RECT
;
1398 wndpl
.rcNormalPosition
= *rect
;
1400 WINPOS_SetPlacement( hwnd
, &wndpl
, flags
);
1405 /***********************************************************************
1406 * SetInternalWindowPos32 (USER32.483)
1408 void WINAPI
SetInternalWindowPos32( HWND32 hwnd
, UINT32 showCmd
,
1409 LPRECT32 rect
, LPPOINT32 pt
)
1411 if( IsWindow32(hwnd
) )
1413 WINDOWPLACEMENT16 wndpl
;
1416 wndpl
.length
= sizeof(wndpl
);
1417 wndpl
.showCmd
= showCmd
;
1418 wndpl
.flags
= flags
= 0;
1423 wndpl
.flags
|= WPF_SETMINPOSITION
;
1424 CONV_POINT32TO16( pt
, &wndpl
.ptMinPosition
);
1428 flags
|= PLACE_RECT
;
1429 CONV_RECT32TO16( rect
, &wndpl
.rcNormalPosition
);
1431 WINPOS_SetPlacement( hwnd
, &wndpl
, flags
);
1435 /*******************************************************************
1436 * WINPOS_SetActiveWindow
1438 * SetActiveWindow() back-end. This is the only function that
1439 * can assign active status to a window. It must be called only
1440 * for the top level windows.
1442 BOOL32
WINPOS_SetActiveWindow( HWND32 hWnd
, BOOL32 fMouse
, BOOL32 fChangeFocus
)
1444 CBTACTIVATESTRUCT16
* cbtStruct
;
1445 WND
* wndPtr
, *wndTemp
;
1446 HQUEUE16 hOldActiveQueue
, hNewActiveQueue
;
1449 /* paranoid checks */
1450 if( hWnd
== GetDesktopWindow32() || hWnd
== hwndActive
) return 0;
1452 /* if (wndPtr && (GetTaskQueue(0) != wndPtr->hmemTaskQ))
1455 wndPtr
= WIN_FindWndPtr(hWnd
);
1456 hOldActiveQueue
= (pActiveQueue
)?pActiveQueue
->self
: 0;
1458 if( (wndTemp
= WIN_FindWndPtr(hwndActive
)) )
1459 wIconized
= HIWORD(wndTemp
->dwStyle
& WS_MINIMIZE
);
1461 TRACE(win
,"no current active window.\n");
1463 /* call CBT hook chain */
1464 if ((cbtStruct
= SEGPTR_NEW(CBTACTIVATESTRUCT16
)))
1467 cbtStruct
->fMouse
= fMouse
;
1468 cbtStruct
->hWndActive
= hwndActive
;
1469 wRet
= HOOK_CallHooks16( WH_CBT
, HCBT_ACTIVATE
, (WPARAM16
)hWnd
,
1470 (LPARAM
)SEGPTR_GET(cbtStruct
) );
1471 SEGPTR_FREE(cbtStruct
);
1472 if (wRet
) return wRet
;
1475 /* set prev active wnd to current active wnd and send notification */
1476 if ((hwndPrevActive
= hwndActive
) && IsWindow32(hwndPrevActive
))
1478 if (!SendMessage32A( hwndPrevActive
, WM_NCACTIVATE
, FALSE
, 0 ))
1480 if (GetSysModalWindow16() != hWnd
) return 0;
1481 /* disregard refusal if hWnd is sysmodal */
1485 SendMessage32A( hwndPrevActive
, WM_ACTIVATE
,
1486 MAKEWPARAM( WA_INACTIVE
, wIconized
),
1489 /* FIXME: must be SendMessage16() because 32A doesn't do
1490 * intertask at this time */
1491 SendMessage16( hwndPrevActive
, WM_ACTIVATE
, WA_INACTIVE
,
1492 MAKELPARAM( (HWND16
)hWnd
, wIconized
) );
1495 /* check if something happened during message processing */
1496 if( hwndPrevActive
!= hwndActive
) return 0;
1499 /* set active wnd */
1502 /* send palette messages */
1503 if (hWnd
&& SendMessage16( hWnd
, WM_QUERYNEWPALETTE
, 0, 0L))
1504 SendMessage16((HWND16
)-1, WM_PALETTEISCHANGING
, (WPARAM16
)hWnd
, 0L );
1506 /* if prev wnd is minimized redraw icon title */
1507 if( IsIconic32( hwndPrevActive
) ) WINPOS_RedrawIconTitle(hwndPrevActive
);
1509 /* managed windows will get ConfigureNotify event */
1510 if (wndPtr
&& !(wndPtr
->dwStyle
& WS_CHILD
) && !(wndPtr
->flags
& WIN_MANAGED
))
1512 /* check Z-order and bring hWnd to the top */
1513 for (wndTemp
= WIN_GetDesktop()->child
; wndTemp
; wndTemp
= wndTemp
->next
)
1514 if (wndTemp
->dwStyle
& WS_VISIBLE
) break;
1516 if( wndTemp
!= wndPtr
)
1517 SetWindowPos32(hWnd
, HWND_TOP
, 0,0,0,0,
1518 SWP_NOSIZE
| SWP_NOMOVE
| SWP_NOACTIVATE
);
1519 if (!IsWindow32(hWnd
)) return 0;
1522 hNewActiveQueue
= wndPtr
? wndPtr
->hmemTaskQ
: 0;
1524 /* send WM_ACTIVATEAPP if necessary */
1525 if (hOldActiveQueue
!= hNewActiveQueue
)
1527 WND
**list
, **ppWnd
;
1529 if ((list
= WIN_BuildWinArray( WIN_GetDesktop(), 0, NULL
)))
1531 for (ppWnd
= list
; *ppWnd
; ppWnd
++)
1533 if (!IsWindow32( (*ppWnd
)->hwndSelf
)) continue;
1535 if ((*ppWnd
)->hmemTaskQ
== hOldActiveQueue
)
1536 SendMessage16( (*ppWnd
)->hwndSelf
, WM_ACTIVATEAPP
,
1537 0, QUEUE_GetQueueTask(hNewActiveQueue
) );
1539 HeapFree( SystemHeap
, 0, list
);
1542 pActiveQueue
= (hNewActiveQueue
)
1543 ? (MESSAGEQUEUE
*) GlobalLock16(hNewActiveQueue
) : NULL
;
1545 if ((list
= WIN_BuildWinArray( WIN_GetDesktop(), 0, NULL
)))
1547 for (ppWnd
= list
; *ppWnd
; ppWnd
++)
1549 if (!IsWindow32( (*ppWnd
)->hwndSelf
)) continue;
1551 if ((*ppWnd
)->hmemTaskQ
== hNewActiveQueue
)
1552 SendMessage16( (*ppWnd
)->hwndSelf
, WM_ACTIVATEAPP
,
1553 1, QUEUE_GetQueueTask( hOldActiveQueue
) );
1555 HeapFree( SystemHeap
, 0, list
);
1557 if (!IsWindow32(hWnd
)) return 0;
1562 /* walk up to the first unowned window */
1564 while (wndTemp
->owner
) wndTemp
= wndTemp
->owner
;
1565 /* and set last active owned popup */
1566 wndTemp
->hwndLastActive
= hWnd
;
1568 wIconized
= HIWORD(wndTemp
->dwStyle
& WS_MINIMIZE
);
1569 SendMessage32A( hWnd
, WM_NCACTIVATE
, TRUE
, 0 );
1571 SendMessage32A( hWnd
, WM_ACTIVATE
,
1572 MAKEWPARAM( (fMouse
) ? WA_CLICKACTIVE
: WA_ACTIVE
, wIconized
),
1573 (LPARAM
)hwndPrevActive
);
1575 SendMessage16(hWnd
, WM_ACTIVATE
, (fMouse
) ? WA_CLICKACTIVE
: WA_ACTIVE
,
1576 MAKELPARAM( (HWND16
)hwndPrevActive
, wIconized
) );
1579 if( !IsWindow32(hWnd
) ) return 0;
1582 /* change focus if possible */
1583 if( fChangeFocus
&& GetFocus32() )
1584 if( WIN_GetTopParent(GetFocus32()) != hwndActive
)
1585 FOCUS_SwitchFocus( GetFocus32(),
1586 (wndPtr
&& (wndPtr
->dwStyle
& WS_MINIMIZE
))?
1591 if( !hwndPrevActive
&& wndPtr
)
1592 (*wndPtr
->pDriver
->pForceWindowRaise
)(wndPtr
);
1594 /* if active wnd is minimized redraw icon title */
1595 if( IsIconic32(hwndActive
) ) WINPOS_RedrawIconTitle(hwndActive
);
1597 return (hWnd
== hwndActive
);
1600 /*******************************************************************
1601 * WINPOS_ActivateOtherWindow
1603 * Activates window other than pWnd.
1605 BOOL32
WINPOS_ActivateOtherWindow(WND
* pWnd
)
1610 if( pWnd
->hwndSelf
== hwndPrevActive
)
1613 if( hwndActive
!= pWnd
->hwndSelf
&&
1614 ( hwndActive
|| QUEUE_IsExitingQueue(pWnd
->hmemTaskQ
)) )
1617 if( !(pWnd
->dwStyle
& WS_POPUP
) || !(pWnd
->owner
) ||
1618 !WINPOS_CanActivate((pWndTo
= WIN_GetTopParentPtr(pWnd
->owner
))) )
1620 WND
* pWndPtr
= WIN_GetTopParentPtr(pWnd
);
1622 pWndTo
= WIN_FindWndPtr(hwndPrevActive
);
1624 while( !WINPOS_CanActivate(pWndTo
) )
1626 /* by now owned windows should've been taken care of */
1628 pWndTo
= pWndPtr
->next
;
1630 if( !pWndTo
) break;
1634 bRet
= WINPOS_SetActiveWindow( pWndTo
? pWndTo
->hwndSelf
: 0, FALSE
, TRUE
);
1636 /* switch desktop queue to current active */
1637 if( pWndTo
) WIN_GetDesktop()->hmemTaskQ
= pWndTo
->hmemTaskQ
;
1643 /*******************************************************************
1644 * WINPOS_ChangeActiveWindow
1647 BOOL32
WINPOS_ChangeActiveWindow( HWND32 hWnd
, BOOL32 mouseMsg
)
1649 WND
*wndPtr
= WIN_FindWndPtr(hWnd
);
1651 if (!hWnd
) return WINPOS_SetActiveWindow( 0, mouseMsg
, TRUE
);
1653 if( !wndPtr
) return FALSE
;
1655 /* child windows get WM_CHILDACTIVATE message */
1656 if( (wndPtr
->dwStyle
& (WS_CHILD
| WS_POPUP
)) == WS_CHILD
)
1657 return SendMessage32A(hWnd
, WM_CHILDACTIVATE
, 0, 0L);
1659 /* owned popups imply owner activation - not sure */
1660 if ((wndPtr
->dwStyle
& WS_POPUP
) && wndPtr
->owner
&&
1661 (wndPtr
->owner
->dwStyle
& WS_VISIBLE
) &&
1662 !(wndPtr
->owner
->dwStyle
& WS_DISABLED
))
1664 if (!(wndPtr
= wndPtr
->owner
)) return FALSE
;
1665 hWnd
= wndPtr
->hwndSelf
;
1668 if( hWnd
== hwndActive
) return FALSE
;
1670 if( !WINPOS_SetActiveWindow(hWnd
,mouseMsg
,TRUE
) )
1673 /* switch desktop queue to current active */
1674 if( wndPtr
->parent
== WIN_GetDesktop())
1675 WIN_GetDesktop()->hmemTaskQ
= wndPtr
->hmemTaskQ
;
1681 /***********************************************************************
1682 * WINPOS_SendNCCalcSize
1684 * Send a WM_NCCALCSIZE message to a window.
1685 * All parameters are read-only except newClientRect.
1686 * oldWindowRect, oldClientRect and winpos must be non-NULL only
1687 * when calcValidRect is TRUE.
1689 LONG
WINPOS_SendNCCalcSize( HWND32 hwnd
, BOOL32 calcValidRect
,
1690 RECT32
*newWindowRect
, RECT32
*oldWindowRect
,
1691 RECT32
*oldClientRect
, WINDOWPOS32
*winpos
,
1692 RECT32
*newClientRect
)
1694 NCCALCSIZE_PARAMS32 params
;
1695 WINDOWPOS32 winposCopy
;
1698 params
.rgrc
[0] = *newWindowRect
;
1701 winposCopy
= *winpos
;
1702 params
.rgrc
[1] = *oldWindowRect
;
1703 params
.rgrc
[2] = *oldClientRect
;
1704 params
.lppos
= &winposCopy
;
1706 result
= SendMessage32A( hwnd
, WM_NCCALCSIZE
, calcValidRect
,
1708 TRACE(win
, "%d,%d-%d,%d\n",
1709 params
.rgrc
[0].left
, params
.rgrc
[0].top
,
1710 params
.rgrc
[0].right
, params
.rgrc
[0].bottom
);
1711 *newClientRect
= params
.rgrc
[0];
1716 /***********************************************************************
1717 * WINPOS_HandleWindowPosChanging16
1719 * Default handling for a WM_WINDOWPOSCHANGING. Called from DefWindowProc().
1721 LONG
WINPOS_HandleWindowPosChanging16( WND
*wndPtr
, WINDOWPOS16
*winpos
)
1723 POINT32 maxSize
, minTrack
;
1724 if (winpos
->flags
& SWP_NOSIZE
) return 0;
1725 if ((wndPtr
->dwStyle
& WS_THICKFRAME
) ||
1726 ((wndPtr
->dwStyle
& (WS_POPUP
| WS_CHILD
)) == 0))
1728 WINPOS_GetMinMaxInfo( wndPtr
, &maxSize
, NULL
, &minTrack
, NULL
);
1729 if (maxSize
.x
< winpos
->cx
) winpos
->cx
= maxSize
.x
;
1730 if (maxSize
.y
< winpos
->cy
) winpos
->cy
= maxSize
.y
;
1731 if (!(wndPtr
->dwStyle
& WS_MINIMIZE
))
1733 if (winpos
->cx
< minTrack
.x
) winpos
->cx
= minTrack
.x
;
1734 if (winpos
->cy
< minTrack
.y
) winpos
->cy
= minTrack
.y
;
1741 /***********************************************************************
1742 * WINPOS_HandleWindowPosChanging32
1744 * Default handling for a WM_WINDOWPOSCHANGING. Called from DefWindowProc().
1746 LONG
WINPOS_HandleWindowPosChanging32( WND
*wndPtr
, WINDOWPOS32
*winpos
)
1749 if (winpos
->flags
& SWP_NOSIZE
) return 0;
1750 if ((wndPtr
->dwStyle
& WS_THICKFRAME
) ||
1751 ((wndPtr
->dwStyle
& (WS_POPUP
| WS_CHILD
)) == 0))
1753 WINPOS_GetMinMaxInfo( wndPtr
, &maxSize
, NULL
, NULL
, NULL
);
1754 winpos
->cx
= MIN( winpos
->cx
, maxSize
.x
);
1755 winpos
->cy
= MIN( winpos
->cy
, maxSize
.y
);
1761 /***********************************************************************
1762 * WINPOS_MoveWindowZOrder
1764 * Move a window in Z order, invalidating everything that needs it.
1765 * Only necessary for windows without associated X window.
1767 static void WINPOS_MoveWindowZOrder( HWND32 hwnd
, HWND32 hwndAfter
)
1770 WND
*pWndAfter
, *pWndCur
, *wndPtr
= WIN_FindWndPtr( hwnd
);
1772 /* We have two possible cases:
1773 * - The window is moving up: we have to invalidate all areas
1774 * of the window that were covered by other windows
1775 * - The window is moving down: we have to invalidate areas
1776 * of other windows covered by this one.
1779 if (hwndAfter
== HWND_TOP
)
1783 else if (hwndAfter
== HWND_BOTTOM
)
1785 if (!wndPtr
->next
) return; /* Already at the bottom */
1790 if (!(pWndAfter
= WIN_FindWndPtr( hwndAfter
))) return;
1791 if (wndPtr
->next
== pWndAfter
) return; /* Already placed right */
1793 /* Determine which window we encounter first in Z-order */
1794 pWndCur
= wndPtr
->parent
->child
;
1795 while ((pWndCur
!= wndPtr
) && (pWndCur
!= pWndAfter
))
1796 pWndCur
= pWndCur
->next
;
1797 movingUp
= (pWndCur
== pWndAfter
);
1802 WND
*pWndPrevAfter
= wndPtr
->next
;
1803 WIN_UnlinkWindow( hwnd
);
1804 WIN_LinkWindow( hwnd
, hwndAfter
);
1805 pWndCur
= wndPtr
->next
;
1806 while (pWndCur
!= pWndPrevAfter
)
1808 RECT32 rect
= { pWndCur
->rectWindow
.left
,
1809 pWndCur
->rectWindow
.top
,
1810 pWndCur
->rectWindow
.right
,
1811 pWndCur
->rectWindow
.bottom
};
1812 OffsetRect32( &rect
, -wndPtr
->rectClient
.left
,
1813 -wndPtr
->rectClient
.top
);
1814 PAINT_RedrawWindow( hwnd
, &rect
, 0, RDW_INVALIDATE
| RDW_ALLCHILDREN
|
1815 RDW_FRAME
| RDW_ERASE
, 0 );
1816 pWndCur
= pWndCur
->next
;
1819 else /* Moving down */
1821 pWndCur
= wndPtr
->next
;
1822 WIN_UnlinkWindow( hwnd
);
1823 WIN_LinkWindow( hwnd
, hwndAfter
);
1824 while (pWndCur
!= wndPtr
)
1826 RECT32 rect
= { pWndCur
->rectWindow
.left
,
1827 pWndCur
->rectWindow
.top
,
1828 pWndCur
->rectWindow
.right
,
1829 pWndCur
->rectWindow
.bottom
};
1830 OffsetRect32( &rect
, -pWndCur
->rectClient
.left
,
1831 -pWndCur
->rectClient
.top
);
1832 PAINT_RedrawWindow( pWndCur
->hwndSelf
, &rect
, 0, RDW_INVALIDATE
|
1833 RDW_ALLCHILDREN
| RDW_FRAME
| RDW_ERASE
, 0 );
1834 pWndCur
= pWndCur
->next
;
1839 /***********************************************************************
1840 * WINPOS_ReorderOwnedPopups
1842 * fix Z order taking into account owned popups -
1843 * basically we need to maintain them above the window that owns them
1845 HWND32
WINPOS_ReorderOwnedPopups(HWND32 hwndInsertAfter
,WND
* wndPtr
,WORD flags
)
1847 WND
* w
= WIN_GetDesktop()->child
;
1849 if( wndPtr
->dwStyle
& WS_POPUP
&& wndPtr
->owner
)
1851 /* implement "local z-order" between the top and owner window */
1853 HWND32 hwndLocalPrev
= HWND_TOP
;
1855 if( hwndInsertAfter
!= HWND_TOP
)
1857 while( w
!= wndPtr
->owner
)
1859 if (w
!= wndPtr
) hwndLocalPrev
= w
->hwndSelf
;
1860 if( hwndLocalPrev
== hwndInsertAfter
) break;
1863 hwndInsertAfter
= hwndLocalPrev
;
1867 else if( wndPtr
->dwStyle
& WS_CHILD
) return hwndInsertAfter
;
1869 w
= WIN_GetDesktop()->child
;
1872 if( w
== wndPtr
) break;
1874 if( w
->dwStyle
& WS_POPUP
&& w
->owner
== wndPtr
)
1876 SetWindowPos32(w
->hwndSelf
, hwndInsertAfter
, 0, 0, 0, 0, SWP_NOMOVE
| SWP_NOSIZE
|
1877 SWP_NOACTIVATE
| SWP_NOSENDCHANGING
| SWP_DEFERERASE
);
1878 hwndInsertAfter
= w
->hwndSelf
;
1883 return hwndInsertAfter
;
1886 /***********************************************************************
1887 * WINPOS_SizeMoveClean
1889 * Make window look nice without excessive repainting
1893 * visible regions are in window coordinates
1894 * update regions are in window client coordinates
1895 * client and window rectangles are in parent client coordinates
1897 * FIXME: Move visible and update regions to the same coordinate system
1898 * (either parent client or window). This is a lot of work though.
1900 static UINT32
WINPOS_SizeMoveClean( WND
* Wnd
, HRGN32 oldVisRgn
,
1901 LPRECT32 lpOldWndRect
,
1902 LPRECT32 lpOldClientRect
, UINT32 uFlags
)
1904 HRGN32 newVisRgn
= DCE_GetVisRgn(Wnd
->hwndSelf
,DCX_WINDOW
| DCX_CLIPSIBLINGS
);
1905 HRGN32 dirtyRgn
= CreateRectRgn32(0,0,0,0);
1908 TRACE(win
,"cleaning up...new wnd=(%i %i-%i %i) old wnd=(%i %i-%i %i)\n",
1909 Wnd
->rectWindow
.left
, Wnd
->rectWindow
.top
,
1910 Wnd
->rectWindow
.right
, Wnd
->rectWindow
.bottom
,
1911 lpOldWndRect
->left
, lpOldWndRect
->top
,
1912 lpOldWndRect
->right
, lpOldWndRect
->bottom
);
1913 TRACE(win
,"\tnew client=(%i %i-%i %i) old client=(%i %i-%i %i)\n",
1914 Wnd
->rectClient
.left
, Wnd
->rectClient
.top
,
1915 Wnd
->rectClient
.right
, Wnd
->rectClient
.bottom
,
1916 lpOldClientRect
->left
, lpOldClientRect
->top
,
1917 lpOldClientRect
->right
,lpOldClientRect
->bottom
);
1919 if( (lpOldWndRect
->right
- lpOldWndRect
->left
) != (Wnd
->rectWindow
.right
- Wnd
->rectWindow
.left
) ||
1920 (lpOldWndRect
->bottom
- lpOldWndRect
->top
) != (Wnd
->rectWindow
.bottom
- Wnd
->rectWindow
.top
) )
1921 uFlags
|= SMC_DRAWFRAME
;
1923 CombineRgn32( dirtyRgn
, newVisRgn
, 0, RGN_COPY
);
1925 if( !(uFlags
& SMC_NOCOPY
) )
1926 CombineRgn32( newVisRgn
, newVisRgn
, oldVisRgn
, RGN_AND
);
1928 /* map regions to the parent client area */
1930 OffsetRgn32( dirtyRgn
, Wnd
->rectWindow
.left
, Wnd
->rectWindow
.top
);
1931 OffsetRgn32( oldVisRgn
, lpOldWndRect
->left
, lpOldWndRect
->top
);
1933 /* compute invalidated region outside Wnd - (in client coordinates of the parent window) */
1935 other
= CombineRgn32(dirtyRgn
, oldVisRgn
, dirtyRgn
, RGN_DIFF
);
1937 /* map visible region to the Wnd client area */
1939 OffsetRgn32( newVisRgn
, Wnd
->rectWindow
.left
- Wnd
->rectClient
.left
,
1940 Wnd
->rectWindow
.top
- Wnd
->rectClient
.top
);
1942 /* substract previously invalidated region from the Wnd visible region */
1944 my
= (Wnd
->hrgnUpdate
> 1) ? CombineRgn32( newVisRgn
, newVisRgn
,
1945 Wnd
->hrgnUpdate
, RGN_DIFF
)
1948 if( uFlags
& SMC_NOCOPY
) /* invalidate Wnd visible region */
1950 if (my
!= NULLREGION
)
1951 PAINT_RedrawWindow( Wnd
->hwndSelf
, NULL
, newVisRgn
, RDW_INVALIDATE
|
1952 RDW_FRAME
| RDW_ALLCHILDREN
| RDW_ERASE
, RDW_C_USEHRGN
);
1953 else if(uFlags
& SMC_DRAWFRAME
)
1954 Wnd
->flags
|= WIN_NEEDS_NCPAINT
;
1956 else /* bitblt old client area */
1961 int xfrom
,yfrom
,xto
,yto
,width
,height
;
1963 if( uFlags
& SMC_DRAWFRAME
)
1965 /* copy only client area, frame will be redrawn anyway */
1967 xfrom
= lpOldClientRect
->left
; yfrom
= lpOldClientRect
->top
;
1968 xto
= Wnd
->rectClient
.left
; yto
= Wnd
->rectClient
.top
;
1969 width
= lpOldClientRect
->right
- xfrom
; height
= lpOldClientRect
->bottom
- yfrom
;
1970 updateRgn
= CreateRectRgn32( 0, 0, width
, height
);
1971 CombineRgn32( newVisRgn
, newVisRgn
, updateRgn
, RGN_AND
);
1972 SetRectRgn32( updateRgn
, 0, 0, Wnd
->rectClient
.right
- xto
,
1973 Wnd
->rectClient
.bottom
- yto
);
1977 xfrom
= lpOldWndRect
->left
; yfrom
= lpOldWndRect
->top
;
1978 xto
= Wnd
->rectWindow
.left
; yto
= Wnd
->rectWindow
.top
;
1979 width
= lpOldWndRect
->right
- xfrom
; height
= lpOldWndRect
->bottom
- yfrom
;
1980 updateRgn
= CreateRectRgn32( xto
- Wnd
->rectClient
.left
,
1981 yto
- Wnd
->rectClient
.top
,
1982 Wnd
->rectWindow
.right
- Wnd
->rectClient
.left
,
1983 Wnd
->rectWindow
.bottom
- Wnd
->rectClient
.top
);
1986 CombineRgn32( newVisRgn
, newVisRgn
, updateRgn
, RGN_AND
);
1988 /* substract new visRgn from target rect to get a region that won't be copied */
1990 update
= CombineRgn32( updateRgn
, updateRgn
, newVisRgn
, RGN_DIFF
);
1992 /* Blt valid bits using parent window DC */
1994 if( my
!= NULLREGION
&& (xfrom
!= xto
|| yfrom
!= yto
) )
1997 /* compute clipping region in parent client coordinates */
1999 OffsetRgn32( newVisRgn
, Wnd
->rectClient
.left
, Wnd
->rectClient
.top
);
2000 CombineRgn32( oldVisRgn
, oldVisRgn
, newVisRgn
, RGN_OR
);
2002 hDC
= GetDCEx32( Wnd
->parent
->hwndSelf
, oldVisRgn
,
2003 DCX_KEEPCLIPRGN
| DCX_INTERSECTRGN
|
2004 DCX_CACHE
| DCX_CLIPSIBLINGS
);
2006 BitBlt32( hDC
, xto
, yto
, width
, height
, hDC
, xfrom
, yfrom
, SRCCOPY
);
2007 ReleaseDC32( Wnd
->parent
->hwndSelf
, hDC
);
2010 if( update
!= NULLREGION
)
2011 PAINT_RedrawWindow( Wnd
->hwndSelf
, NULL
, updateRgn
, RDW_INVALIDATE
|
2012 RDW_FRAME
| RDW_ALLCHILDREN
| RDW_ERASE
, RDW_C_USEHRGN
);
2013 else if( uFlags
& SMC_DRAWFRAME
) Wnd
->flags
|= WIN_NEEDS_NCPAINT
;
2014 DeleteObject32( updateRgn
);
2017 /* erase uncovered areas */
2019 if( !(uFlags
& SMC_NOPARENTERASE
) && (other
!= NULLREGION
) )
2020 PAINT_RedrawWindow( Wnd
->parent
->hwndSelf
, NULL
, dirtyRgn
,
2021 RDW_INVALIDATE
| RDW_ALLCHILDREN
| RDW_ERASE
, RDW_C_USEHRGN
);
2022 DeleteObject32(dirtyRgn
);
2023 DeleteObject32(newVisRgn
);
2027 /***********************************************************************
2028 * SetWindowPos (USER.232)
2030 BOOL16 WINAPI
SetWindowPos16( HWND16 hwnd
, HWND16 hwndInsertAfter
,
2031 INT16 x
, INT16 y
, INT16 cx
, INT16 cy
, WORD flags
)
2033 return SetWindowPos32(hwnd
,(INT32
)(INT16
)hwndInsertAfter
,x
,y
,cx
,cy
,flags
);
2036 /***********************************************************************
2037 * SetWindowPos (USER32.520)
2039 BOOL32 WINAPI
SetWindowPos32( HWND32 hwnd
, HWND32 hwndInsertAfter
,
2040 INT32 x
, INT32 y
, INT32 cx
, INT32 cy
, WORD flags
)
2044 RECT32 newWindowRect
, newClientRect
, oldWindowRect
;
2046 HWND32 tempInsertAfter
= 0;
2049 BOOL32 resync
= FALSE
;
2051 TRACE(win
,"hwnd %04x, (%i,%i)-(%i,%i) flags %08x\n",
2052 hwnd
, x
, y
, x
+cx
, y
+cy
, flags
);
2053 /* Check window handle */
2055 if (hwnd
== GetDesktopWindow32()) return FALSE
;
2056 if (!(wndPtr
= WIN_FindWndPtr( hwnd
))) return FALSE
;
2058 if(wndPtr
->dwStyle
& WS_VISIBLE
)
2059 flags
&= ~SWP_SHOWWINDOW
;
2062 uFlags
|= SMC_NOPARENTERASE
;
2063 flags
&= ~SWP_HIDEWINDOW
;
2064 if (!(flags
& SWP_SHOWWINDOW
)) flags
|= SWP_NOREDRAW
;
2067 /* Check for windows that may not be resized
2068 FIXME: this should be done only for Windows 3.0 programs
2069 if (flags & (SWP_SHOWWINDOW | SWP_HIDEWINDOW ) )
2070 flags |= SWP_NOSIZE | SWP_NOMOVE;
2072 /* Check dimensions */
2074 if (cx
<= 0) cx
= 1;
2075 if (cy
<= 0) cy
= 1;
2079 if (hwnd
== hwndActive
) flags
|= SWP_NOACTIVATE
; /* Already active */
2080 if ((wndPtr
->rectWindow
.right
- wndPtr
->rectWindow
.left
== cx
) &&
2081 (wndPtr
->rectWindow
.bottom
- wndPtr
->rectWindow
.top
== cy
))
2082 flags
|= SWP_NOSIZE
; /* Already the right size */
2083 if ((wndPtr
->rectWindow
.left
== x
) && (wndPtr
->rectWindow
.top
== y
))
2084 flags
|= SWP_NOMOVE
; /* Already the right position */
2086 /* Check hwndInsertAfter */
2088 if (!(flags
& (SWP_NOZORDER
| SWP_NOACTIVATE
)))
2090 /* Ignore TOPMOST flags when activating a window */
2091 /* _and_ moving it in Z order. */
2092 if ((hwndInsertAfter
== HWND_TOPMOST
) ||
2093 (hwndInsertAfter
== HWND_NOTOPMOST
))
2094 hwndInsertAfter
= HWND_TOP
;
2096 /* TOPMOST not supported yet */
2097 if ((hwndInsertAfter
== HWND_TOPMOST
) ||
2098 (hwndInsertAfter
== HWND_NOTOPMOST
)) hwndInsertAfter
= HWND_TOP
;
2100 /* hwndInsertAfter must be a sibling of the window */
2101 if ((hwndInsertAfter
!= HWND_TOP
) && (hwndInsertAfter
!= HWND_BOTTOM
))
2103 WND
* wnd
= WIN_FindWndPtr(hwndInsertAfter
);
2106 if( wnd
->parent
!= wndPtr
->parent
) return FALSE
;
2107 if( wnd
->next
== wndPtr
) flags
|= SWP_NOZORDER
;
2110 else if (!(wndPtr
->window
))
2112 /* FIXME: the following optimization is no good for "X-ed" windows */
2113 if (hwndInsertAfter
== HWND_TOP
)
2114 flags
|= ( wndPtr
->parent
->child
== wndPtr
)? SWP_NOZORDER
: 0;
2115 else /* HWND_BOTTOM */
2116 flags
|= ( wndPtr
->next
)? 0: SWP_NOZORDER
;
2119 /* Fill the WINDOWPOS structure */
2122 winpos
.hwndInsertAfter
= hwndInsertAfter
;
2127 winpos
.flags
= flags
;
2129 /* Send WM_WINDOWPOSCHANGING message */
2131 if (!(winpos
.flags
& SWP_NOSENDCHANGING
))
2132 SendMessage32A( hwnd
, WM_WINDOWPOSCHANGING
, 0, (LPARAM
)&winpos
);
2134 /* Calculate new position and size */
2136 newWindowRect
= wndPtr
->rectWindow
;
2137 newClientRect
= (wndPtr
->dwStyle
& WS_MINIMIZE
) ? wndPtr
->rectWindow
2138 : wndPtr
->rectClient
;
2140 if (!(winpos
.flags
& SWP_NOSIZE
))
2142 newWindowRect
.right
= newWindowRect
.left
+ winpos
.cx
;
2143 newWindowRect
.bottom
= newWindowRect
.top
+ winpos
.cy
;
2145 if (!(winpos
.flags
& SWP_NOMOVE
))
2147 newWindowRect
.left
= winpos
.x
;
2148 newWindowRect
.top
= winpos
.y
;
2149 newWindowRect
.right
+= winpos
.x
- wndPtr
->rectWindow
.left
;
2150 newWindowRect
.bottom
+= winpos
.y
- wndPtr
->rectWindow
.top
;
2152 OffsetRect32( &newClientRect
, winpos
.x
- wndPtr
->rectWindow
.left
,
2153 winpos
.y
- wndPtr
->rectWindow
.top
);
2156 winpos
.flags
|= SWP_NOCLIENTMOVE
| SWP_NOCLIENTSIZE
;
2158 /* Reposition window in Z order */
2160 if (!(winpos
.flags
& SWP_NOZORDER
))
2162 /* reorder owned popups if hwnd is top-level window
2164 if( wndPtr
->parent
== WIN_GetDesktop() )
2165 hwndInsertAfter
= WINPOS_ReorderOwnedPopups( hwndInsertAfter
,
2166 wndPtr
, winpos
.flags
);
2170 WIN_UnlinkWindow( winpos
.hwnd
);
2171 WIN_LinkWindow( winpos
.hwnd
, hwndInsertAfter
);
2173 else WINPOS_MoveWindowZOrder( winpos
.hwnd
, hwndInsertAfter
);
2176 if ( !wndPtr
->window
&& !(winpos
.flags
& SWP_NOREDRAW
) &&
2177 ((winpos
.flags
& (SWP_NOMOVE
| SWP_NOSIZE
| SWP_FRAMECHANGED
))
2178 != (SWP_NOMOVE
| SWP_NOSIZE
)) )
2179 visRgn
= DCE_GetVisRgn(hwnd
, DCX_WINDOW
| DCX_CLIPSIBLINGS
);
2182 /* Send WM_NCCALCSIZE message to get new client area */
2183 if( (winpos
.flags
& (SWP_FRAMECHANGED
| SWP_NOSIZE
)) != SWP_NOSIZE
)
2185 result
= WINPOS_SendNCCalcSize( winpos
.hwnd
, TRUE
, &newWindowRect
,
2186 &wndPtr
->rectWindow
, &wndPtr
->rectClient
,
2187 &winpos
, &newClientRect
);
2189 /* FIXME: WVR_ALIGNxxx */
2191 if( newClientRect
.left
!= wndPtr
->rectClient
.left
||
2192 newClientRect
.top
!= wndPtr
->rectClient
.top
)
2193 winpos
.flags
&= ~SWP_NOCLIENTMOVE
;
2195 if( (newClientRect
.right
- newClientRect
.left
!=
2196 wndPtr
->rectClient
.right
- wndPtr
->rectClient
.left
) ||
2197 (newClientRect
.bottom
- newClientRect
.top
!=
2198 wndPtr
->rectClient
.bottom
- wndPtr
->rectClient
.top
) )
2199 winpos
.flags
&= ~SWP_NOCLIENTSIZE
;
2202 if( !(flags
& SWP_NOMOVE
) && (newClientRect
.left
!= wndPtr
->rectClient
.left
||
2203 newClientRect
.top
!= wndPtr
->rectClient
.top
) )
2204 winpos
.flags
&= ~SWP_NOCLIENTMOVE
;
2206 /* Update active DCEs
2207 * TODO: Optimize conditions that trigger DCE update.
2210 if( (((winpos
.flags
& SWP_AGG_NOPOSCHANGE
) != SWP_AGG_NOPOSCHANGE
) &&
2211 wndPtr
->dwStyle
& WS_VISIBLE
) ||
2212 (flags
& (SWP_HIDEWINDOW
| SWP_SHOWWINDOW
)) )
2216 UnionRect32(&rect
, &newWindowRect
, &wndPtr
->rectWindow
);
2217 DCE_InvalidateDCE(wndPtr
, &rect
);
2220 /* change geometry */
2222 oldWindowRect
= wndPtr
->rectWindow
;
2226 RECT32 oldClientRect
= wndPtr
->rectClient
;
2228 tempInsertAfter
= winpos
.hwndInsertAfter
;
2230 winpos
.hwndInsertAfter
= hwndInsertAfter
;
2232 /* postpone geometry change */
2234 if( !(flags
& (SWP_SHOWWINDOW
| SWP_HIDEWINDOW
)) )
2236 wndPtr
->pDriver
->pSetWindowPos(wndPtr
, &winpos
, TRUE
);
2237 winpos
.hwndInsertAfter
= tempInsertAfter
;
2239 else uFlags
|= SMC_SETXPOS
;
2241 wndPtr
->rectWindow
= newWindowRect
;
2242 wndPtr
->rectClient
= newClientRect
;
2244 if( !(flags
& (SWP_SHOWWINDOW
| SWP_HIDEWINDOW
)) )
2246 if( (oldClientRect
.left
- oldWindowRect
.left
!=
2247 newClientRect
.left
- newWindowRect
.left
) ||
2248 (oldClientRect
.top
- oldWindowRect
.top
!=
2249 newClientRect
.top
- newWindowRect
.top
) ||
2250 (winpos
.flags
& SWP_NOCOPYBITS
) )
2252 /* if the client area moved as a result of WM_NCCALCSIZE returning
2253 * obscure WVR_ALIGNxxx flags then we simply redraw the whole thing
2255 * TODO: use WINPOS_SizeMoveClean() if there is no SWP_NOCOPYBITS
2258 PAINT_RedrawWindow( wndPtr
->hwndSelf
, NULL
, 0, RDW_INVALIDATE
|
2259 RDW_ALLCHILDREN
| RDW_FRAME
| RDW_ERASE
, 0 );
2262 if( winpos
.flags
& SWP_FRAMECHANGED
)
2267 if( newClientRect
.right
> oldClientRect
.right
) /* redraw exposed client area on the right */
2269 rect
.top
= 0; rect
.bottom
= newClientRect
.bottom
- newClientRect
.top
;
2270 rect
.left
= oldClientRect
.right
- newClientRect
.left
;
2271 rect
.right
= newClientRect
.right
- newClientRect
.left
;
2273 PAINT_RedrawWindow( wndPtr
->hwndSelf
, &rect
, 0,
2274 RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASE
| RDW_ERASENOW
| RDW_ALLCHILDREN
, 0 );
2276 if( newClientRect
.bottom
> oldClientRect
.bottom
) /* redraw exposed client area on the bottom */
2278 rect
.left
= 0; rect
.right
= ((wErase
)?oldClientRect
.right
:newClientRect
.right
) - newClientRect
.left
;
2279 rect
.top
= oldClientRect
.bottom
- newClientRect
.top
;
2280 rect
.bottom
= newClientRect
.bottom
- newClientRect
.top
;
2282 PAINT_RedrawWindow( wndPtr
->hwndSelf
, &rect
, 0,
2283 RDW_INVALIDATE
| RDW_FRAME
| RDW_ERASE
| RDW_ERASENOW
| RDW_ALLCHILDREN
, 0 );
2285 if( !wErase
) /* just update the nonclient area */
2286 wndPtr
->flags
|= WIN_NEEDS_NCPAINT
;
2289 uFlags
|= SMC_NOPARENTERASE
; /* X windows do not have eraseable parents */
2291 else /* not an X window */
2293 RECT32 oldClientRect
= wndPtr
->rectClient
;
2295 wndPtr
->rectWindow
= newWindowRect
;
2296 wndPtr
->rectClient
= newClientRect
;
2298 if( oldClientRect
.bottom
- oldClientRect
.top
==
2299 newClientRect
.bottom
- newClientRect
.top
) result
&= ~WVR_VREDRAW
;
2301 if( oldClientRect
.right
- oldClientRect
.left
==
2302 newClientRect
.right
- newClientRect
.left
) result
&= ~WVR_HREDRAW
;
2304 if( !(flags
& (SWP_NOREDRAW
| SWP_HIDEWINDOW
| SWP_SHOWWINDOW
)) )
2306 uFlags
|= ((winpos
.flags
& SWP_NOCOPYBITS
) ||
2307 (result
>= WVR_HREDRAW
&& result
< WVR_VALIDRECTS
)) ? SMC_NOCOPY
: 0;
2308 uFlags
|= (winpos
.flags
& SWP_FRAMECHANGED
) ? SMC_DRAWFRAME
: 0;
2310 if( (winpos
.flags
& SWP_AGG_NOGEOMETRYCHANGE
) != SWP_AGG_NOGEOMETRYCHANGE
)
2311 uFlags
= WINPOS_SizeMoveClean(wndPtr
, visRgn
, &oldWindowRect
,
2312 &oldClientRect
, uFlags
);
2315 /* adjust the frame and do not erase the parent */
2317 if( winpos
.flags
& SWP_FRAMECHANGED
) wndPtr
->flags
|= WIN_NEEDS_NCPAINT
;
2318 if( winpos
.flags
& SWP_NOZORDER
) uFlags
|= SMC_NOPARENTERASE
;
2321 DeleteObject32(visRgn
);
2324 if (flags
& SWP_SHOWWINDOW
)
2326 wndPtr
->dwStyle
|= WS_VISIBLE
;
2331 wndPtr
->pDriver
->pSetWindowPos(wndPtr
, &winpos
, uFlags
& SMC_SETXPOS
);
2332 if( uFlags
& SMC_SETXPOS
)
2334 winpos
.hwndInsertAfter
= tempInsertAfter
;
2337 if (wndPtr
->flags
& WIN_MANAGED
) resync
= TRUE
;
2339 /* If focus was set to an unmapped window, reset X focus now */
2340 focus
= curr
= GetFocus32();
2344 SetFocus32( focus
);
2347 curr
= GetParent32(curr
);
2352 if (!(flags
& SWP_NOREDRAW
))
2353 PAINT_RedrawWindow( winpos
.hwnd
, NULL
, 0,
2354 RDW_INVALIDATE
| RDW_ALLCHILDREN
|
2355 RDW_FRAME
| RDW_ERASENOW
| RDW_ERASE
, 0 );
2358 else if (flags
& SWP_HIDEWINDOW
)
2360 wndPtr
->dwStyle
&= ~WS_VISIBLE
;
2364 wndPtr
->pDriver
->pSetWindowPos(wndPtr
, &winpos
, uFlags
& SMC_SETXPOS
);
2365 if( uFlags
& SMC_SETXPOS
)
2367 winpos
.hwndInsertAfter
= tempInsertAfter
;
2372 if (!(flags
& SWP_NOREDRAW
))
2373 PAINT_RedrawWindow( wndPtr
->parent
->hwndSelf
, &oldWindowRect
,
2374 0, RDW_INVALIDATE
| RDW_ALLCHILDREN
|
2375 RDW_ERASE
| RDW_ERASENOW
, 0 );
2376 uFlags
|= SMC_NOPARENTERASE
;
2379 if ((winpos
.hwnd
== GetFocus32()) ||
2380 IsChild32( winpos
.hwnd
, GetFocus32()))
2382 /* Revert focus to parent */
2383 SetFocus32( GetParent32(winpos
.hwnd
) );
2385 if (hwnd
== CARET_GetHwnd()) DestroyCaret32();
2387 if (winpos
.hwnd
== hwndActive
)
2388 WINPOS_ActivateOtherWindow( wndPtr
);
2391 /* Activate the window */
2393 if (!(flags
& SWP_NOACTIVATE
))
2394 WINPOS_ChangeActiveWindow( winpos
.hwnd
, FALSE
);
2396 /* Repaint the window */
2398 if (wndPtr
->window
) EVENT_Synchronize(); /* Wait for all expose events */
2400 if (!GetCapture32())
2401 EVENT_DummyMotionNotify(); /* Simulate a mouse event to set the cursor */
2403 if (!(flags
& SWP_DEFERERASE
) && !(uFlags
& SMC_NOPARENTERASE
) )
2404 PAINT_RedrawWindow( wndPtr
->parent
->hwndSelf
, NULL
, 0, RDW_ALLCHILDREN
| RDW_ERASENOW
, 0 );
2405 else if( wndPtr
->parent
== WIN_GetDesktop() && wndPtr
->parent
->flags
& WIN_NEEDS_ERASEBKGND
)
2406 PAINT_RedrawWindow( wndPtr
->parent
->hwndSelf
, NULL
, 0, RDW_NOCHILDREN
| RDW_ERASENOW
, 0 );
2408 /* And last, send the WM_WINDOWPOSCHANGED message */
2410 TRACE(win
,"\tstatus flags = %04x\n", winpos
.flags
& SWP_AGG_STATUSFLAGS
);
2413 (((winpos
.flags
& SWP_AGG_STATUSFLAGS
) != SWP_AGG_NOPOSCHANGE
) &&
2414 !(winpos
.flags
& SWP_NOSENDCHANGING
)) )
2416 SendMessage32A( winpos
.hwnd
, WM_WINDOWPOSCHANGED
, 0, (LPARAM
)&winpos
);
2417 if (resync
) EVENT_Synchronize ();
2424 /***********************************************************************
2425 * BeginDeferWindowPos16 (USER.259)
2427 HDWP16 WINAPI
BeginDeferWindowPos16( INT16 count
)
2429 return BeginDeferWindowPos32( count
);
2433 /***********************************************************************
2434 * BeginDeferWindowPos32 (USER32.9)
2436 HDWP32 WINAPI
BeginDeferWindowPos32( INT32 count
)
2441 if (count
<= 0) return 0;
2442 handle
= USER_HEAP_ALLOC( sizeof(DWP
) + (count
-1)*sizeof(WINDOWPOS32
) );
2443 if (!handle
) return 0;
2444 pDWP
= (DWP
*) USER_HEAP_LIN_ADDR( handle
);
2445 pDWP
->actualCount
= 0;
2446 pDWP
->suggestedCount
= count
;
2448 pDWP
->wMagic
= DWP_MAGIC
;
2449 pDWP
->hwndParent
= 0;
2454 /***********************************************************************
2455 * DeferWindowPos16 (USER.260)
2457 HDWP16 WINAPI
DeferWindowPos16( HDWP16 hdwp
, HWND16 hwnd
, HWND16 hwndAfter
,
2458 INT16 x
, INT16 y
, INT16 cx
, INT16 cy
,
2461 return DeferWindowPos32( hdwp
, hwnd
, (INT32
)(INT16
)hwndAfter
,
2462 x
, y
, cx
, cy
, flags
);
2466 /***********************************************************************
2467 * DeferWindowPos32 (USER32.128)
2469 HDWP32 WINAPI
DeferWindowPos32( HDWP32 hdwp
, HWND32 hwnd
, HWND32 hwndAfter
,
2470 INT32 x
, INT32 y
, INT32 cx
, INT32 cy
,
2475 HDWP32 newhdwp
= hdwp
;
2476 /* HWND32 parent; */
2479 pDWP
= (DWP
*) USER_HEAP_LIN_ADDR( hdwp
);
2480 if (!pDWP
) return 0;
2481 if (hwnd
== GetDesktopWindow32()) return 0;
2483 if (!(pWnd
=WIN_FindWndPtr( hwnd
))) {
2484 USER_HEAP_FREE( hdwp
);
2488 /* Numega Bounds Checker Demo dislikes the following code.
2489 In fact, I've not been able to find any "same parent" requirement in any docu
2493 /* All the windows of a DeferWindowPos() must have the same parent */
2494 parent
= pWnd
->parent
->hwndSelf
;
2495 if (pDWP
->actualCount
== 0) pDWP
->hwndParent
= parent
;
2496 else if (parent
!= pDWP
->hwndParent
)
2498 USER_HEAP_FREE( hdwp
);
2503 for (i
= 0; i
< pDWP
->actualCount
; i
++)
2505 if (pDWP
->winPos
[i
].hwnd
== hwnd
)
2507 /* Merge with the other changes */
2508 if (!(flags
& SWP_NOZORDER
))
2510 pDWP
->winPos
[i
].hwndInsertAfter
= hwndAfter
;
2512 if (!(flags
& SWP_NOMOVE
))
2514 pDWP
->winPos
[i
].x
= x
;
2515 pDWP
->winPos
[i
].y
= y
;
2517 if (!(flags
& SWP_NOSIZE
))
2519 pDWP
->winPos
[i
].cx
= cx
;
2520 pDWP
->winPos
[i
].cy
= cy
;
2522 pDWP
->winPos
[i
].flags
&= flags
| ~(SWP_NOSIZE
| SWP_NOMOVE
|
2523 SWP_NOZORDER
| SWP_NOREDRAW
|
2524 SWP_NOACTIVATE
| SWP_NOCOPYBITS
|
2526 pDWP
->winPos
[i
].flags
|= flags
& (SWP_SHOWWINDOW
| SWP_HIDEWINDOW
|
2531 if (pDWP
->actualCount
>= pDWP
->suggestedCount
)
2533 newhdwp
= USER_HEAP_REALLOC( hdwp
,
2534 sizeof(DWP
) + pDWP
->suggestedCount
*sizeof(WINDOWPOS32
) );
2535 if (!newhdwp
) return 0;
2536 pDWP
= (DWP
*) USER_HEAP_LIN_ADDR( newhdwp
);
2537 pDWP
->suggestedCount
++;
2539 pDWP
->winPos
[pDWP
->actualCount
].hwnd
= hwnd
;
2540 pDWP
->winPos
[pDWP
->actualCount
].hwndInsertAfter
= hwndAfter
;
2541 pDWP
->winPos
[pDWP
->actualCount
].x
= x
;
2542 pDWP
->winPos
[pDWP
->actualCount
].y
= y
;
2543 pDWP
->winPos
[pDWP
->actualCount
].cx
= cx
;
2544 pDWP
->winPos
[pDWP
->actualCount
].cy
= cy
;
2545 pDWP
->winPos
[pDWP
->actualCount
].flags
= flags
;
2546 pDWP
->actualCount
++;
2551 /***********************************************************************
2552 * EndDeferWindowPos16 (USER.261)
2554 BOOL16 WINAPI
EndDeferWindowPos16( HDWP16 hdwp
)
2556 return EndDeferWindowPos32( hdwp
);
2560 /***********************************************************************
2561 * EndDeferWindowPos32 (USER32.173)
2563 BOOL32 WINAPI
EndDeferWindowPos32( HDWP32 hdwp
)
2566 WINDOWPOS32
*winpos
;
2570 pDWP
= (DWP
*) USER_HEAP_LIN_ADDR( hdwp
);
2571 if (!pDWP
) return FALSE
;
2572 for (i
= 0, winpos
= pDWP
->winPos
; i
< pDWP
->actualCount
; i
++, winpos
++)
2574 if (!(res
= SetWindowPos32( winpos
->hwnd
, winpos
->hwndInsertAfter
,
2575 winpos
->x
, winpos
->y
, winpos
->cx
,
2576 winpos
->cy
, winpos
->flags
))) break;
2578 USER_HEAP_FREE( hdwp
);
2583 /***********************************************************************
2584 * TileChildWindows (USER.199)
2586 void WINAPI
TileChildWindows( HWND16 parent
, WORD action
)
2588 FIXME(win
, "(%04x, %d): stub\n", parent
, action
);
2591 /***********************************************************************
2592 * CascageChildWindows (USER.198)
2594 void WINAPI
CascadeChildWindows( HWND16 parent
, WORD action
)
2596 FIXME(win
, "(%04x, %d): stub\n", parent
, action
);
2598 /***********************************************************************
2599 * GetProgmanWindow [USER32.289]
2601 HRESULT WINAPI
GetProgmanWindow ( )
2602 { FIXME(win
,"stub\n");
2605 /***********************************************************************
2606 * GetTaskmanWindow [USER32.304]
2608 HRESULT WINAPI
GetTaskmanWindow ( )
2609 { FIXME(win
,"stub\n");
2612 /***********************************************************************
2613 * SetProgmanWindow [USER32.522]
2615 HRESULT WINAPI
SetProgmanWindow ( DWORD x
)
2616 { FIXME(win
,"0x%08lx stub\n",x
);
2619 /***********************************************************************
2620 * SetShellWindowEx [USER32.531]
2622 HRESULT WINAPI
SetShellWindowEx ( DWORD x
, DWORD y
)
2623 { FIXME(win
,"0x%08lx 0x%08lx stub\n",x
,y
);
2626 /***********************************************************************
2627 * SetTaskmanWindow [USER32.537]
2629 HRESULT WINAPI
SetTaskmanWindow ( DWORD x
)
2630 { FIXME(win
,"0x%08lx stub\n",x
);