Added a typedef for __int64 which is a builtin Visual C++ type
[wine/multimedia.git] / windows / winpos.c
blobb9abdfb5dffe5c7e33d293b0292e1ff278dbac0f
1 /*
2 * Window position related functions.
4 * Copyright 1993, 1994, 1995 Alexandre Julliard
5 * 1995, 1996 Alex Korobka
6 */
8 #include <string.h>
9 #include "sysmetrics.h"
10 #include "heap.h"
11 #include "module.h"
12 #include "user.h"
13 #include "win.h"
14 #include "hook.h"
15 #include "message.h"
16 #include "queue.h"
17 #include "options.h"
18 #include "task.h"
19 #include "winpos.h"
20 #include "dce.h"
21 #include "nonclient.h"
22 #include "debug.h"
24 #define HAS_DLGFRAME(style,exStyle) \
25 (((exStyle) & WS_EX_DLGMODALFRAME) || \
26 (((style) & WS_DLGFRAME) && !((style) & WS_BORDER)))
28 #define HAS_THICKFRAME(style) \
29 (((style) & WS_THICKFRAME) && \
30 !(((style) & (WS_DLGFRAME|WS_BORDER)) == WS_DLGFRAME))
32 #define SWP_AGG_NOGEOMETRYCHANGE \
33 (SWP_NOSIZE | SWP_NOMOVE | SWP_NOCLIENTSIZE | SWP_NOCLIENTMOVE)
34 #define SWP_AGG_NOPOSCHANGE \
35 (SWP_AGG_NOGEOMETRYCHANGE | SWP_NOZORDER)
36 #define SWP_AGG_STATUSFLAGS \
37 (SWP_AGG_NOPOSCHANGE | SWP_FRAMECHANGED | SWP_HIDEWINDOW | SWP_SHOWWINDOW)
39 #define EMPTYPOINT(pt) ((*(LONG*)&(pt)) == -1)
41 #define PLACE_MIN 0x0001
42 #define PLACE_MAX 0x0002
43 #define PLACE_RECT 0x0004
45 #define SMC_NOCOPY 0x0001
46 #define SMC_NOPARENTERASE 0x0002
47 #define SMC_DRAWFRAME 0x0004
48 #define SMC_SETXPOS 0x0008
50 /* ----- internal variables ----- */
52 static HWND32 hwndActive = 0; /* Currently active window */
53 static HWND32 hwndPrevActive = 0; /* Previously active window */
54 static HWND32 hGlobalShellWindow=0; /*the shell*/
56 static LPCSTR atomInternalPos;
58 extern MESSAGEQUEUE* pActiveQueue;
60 /***********************************************************************
61 * WINPOS_CreateInternalPosAtom
63 BOOL32 WINPOS_CreateInternalPosAtom()
65 LPSTR str = "SysIP";
66 atomInternalPos = (LPCSTR)(DWORD)GlobalAddAtom32A(str);
67 return (atomInternalPos) ? TRUE : FALSE;
70 /***********************************************************************
71 * WINPOS_CheckInternalPos
73 * Called when a window is destroyed.
75 void WINPOS_CheckInternalPos( HWND32 hwnd )
77 LPINTERNALPOS lpPos = (LPINTERNALPOS) GetProp32A( hwnd, atomInternalPos );
79 if( hwnd == hwndPrevActive ) hwndPrevActive = 0;
80 if( hwnd == hwndActive )
82 hwndActive = 0;
83 WARN(win, "\tattempt to activate destroyed window!\n");
86 if( lpPos )
88 if( IsWindow32(lpPos->hwndIconTitle) )
89 DestroyWindow32( lpPos->hwndIconTitle );
90 HeapFree( SystemHeap, 0, lpPos );
94 /***********************************************************************
95 * WINPOS_FindIconPos
97 * Find a suitable place for an iconic window.
99 static POINT16 WINPOS_FindIconPos( WND* wndPtr, POINT16 pt )
101 RECT16 rectParent;
102 short x, y, xspacing, yspacing;
104 GetClientRect16( wndPtr->parent->hwndSelf, &rectParent );
105 if ((pt.x >= rectParent.left) && (pt.x + SYSMETRICS_CXICON < rectParent.right) &&
106 (pt.y >= rectParent.top) && (pt.y + SYSMETRICS_CYICON < rectParent.bottom))
107 return pt; /* The icon already has a suitable position */
109 xspacing = SYSMETRICS_CXICONSPACING;
110 yspacing = SYSMETRICS_CYICONSPACING;
112 y = rectParent.bottom;
113 for (;;)
115 for (x = rectParent.left; x <= rectParent.right-xspacing; x += xspacing)
117 /* Check if another icon already occupies this spot */
118 WND *childPtr = wndPtr->parent->child;
119 while (childPtr)
121 if ((childPtr->dwStyle & WS_MINIMIZE) && (childPtr != wndPtr))
123 if ((childPtr->rectWindow.left < x + xspacing) &&
124 (childPtr->rectWindow.right >= x) &&
125 (childPtr->rectWindow.top <= y) &&
126 (childPtr->rectWindow.bottom > y - yspacing))
127 break; /* There's a window in there */
129 childPtr = childPtr->next;
131 if (!childPtr) /* No window was found, so it's OK for us */
133 pt.x = x + (xspacing - SYSMETRICS_CXICON) / 2;
134 pt.y = y - (yspacing + SYSMETRICS_CYICON) / 2;
135 return pt;
138 y -= yspacing;
143 /***********************************************************************
144 * ArrangeIconicWindows16 (USER.170)
146 UINT16 WINAPI ArrangeIconicWindows16( HWND16 parent)
148 return ArrangeIconicWindows32(parent);
150 /***********************************************************************
151 * ArrangeIconicWindows32 (USER32.7)
153 UINT32 WINAPI ArrangeIconicWindows32( HWND32 parent )
155 RECT32 rectParent;
156 HWND32 hwndChild;
157 INT32 x, y, xspacing, yspacing;
159 GetClientRect32( parent, &rectParent );
160 x = rectParent.left;
161 y = rectParent.bottom;
162 xspacing = SYSMETRICS_CXICONSPACING;
163 yspacing = SYSMETRICS_CYICONSPACING;
165 hwndChild = GetWindow32( parent, GW_CHILD );
166 while (hwndChild)
168 if( IsIconic32( hwndChild ) )
170 WINPOS_ShowIconTitle( WIN_FindWndPtr(hwndChild), FALSE );
171 SetWindowPos32( hwndChild, 0, x + (xspacing - SYSMETRICS_CXICON) / 2,
172 y - yspacing - SYSMETRICS_CYICON/2, 0, 0,
173 SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE );
174 if( IsWindow32(hwndChild) )
175 WINPOS_ShowIconTitle( WIN_FindWndPtr(hwndChild), TRUE );
176 if (x <= rectParent.right - xspacing) x += xspacing;
177 else
179 x = rectParent.left;
180 y -= yspacing;
183 hwndChild = GetWindow32( hwndChild, GW_HWNDNEXT );
185 return yspacing;
189 /***********************************************************************
190 * SwitchToThisWindow16 (USER.172)
192 void WINAPI SwitchToThisWindow16( HWND16 hwnd, BOOL16 restore )
194 SwitchToThisWindow32( hwnd, restore );
198 /***********************************************************************
199 * SwitchToThisWindow32 (USER32.539)
201 void WINAPI SwitchToThisWindow32( HWND32 hwnd, BOOL32 restore )
203 ShowWindow32( hwnd, restore ? SW_RESTORE : SW_SHOWMINIMIZED );
207 /***********************************************************************
208 * GetWindowRect16 (USER.32)
210 void WINAPI GetWindowRect16( HWND16 hwnd, LPRECT16 rect )
212 WND * wndPtr = WIN_FindWndPtr( hwnd );
213 if (!wndPtr) return;
215 CONV_RECT32TO16( &wndPtr->rectWindow, rect );
216 if (wndPtr->dwStyle & WS_CHILD)
217 MapWindowPoints16( wndPtr->parent->hwndSelf, 0, (POINT16 *)rect, 2 );
221 /***********************************************************************
222 * GetWindowRect32 (USER32.308)
224 BOOL32 WINAPI GetWindowRect32( HWND32 hwnd, LPRECT32 rect )
226 WND * wndPtr = WIN_FindWndPtr( hwnd );
227 if (!wndPtr) return FALSE;
229 *rect = wndPtr->rectWindow;
230 if (wndPtr->dwStyle & WS_CHILD)
231 MapWindowPoints32( wndPtr->parent->hwndSelf, 0, (POINT32 *)rect, 2 );
232 return TRUE;
236 /***********************************************************************
237 * GetWindowRgn32
239 BOOL32 WINAPI GetWindowRgn32 ( HWND32 hwnd, HRGN32 hrgn )
242 RECT32 rect;
243 WND * wndPtr = WIN_FindWndPtr( hwnd );
244 if (!wndPtr) return (ERROR);
246 FIXME (win, "GetWindowRgn32: doesn't really do regions\n");
248 memset (&rect, 0, sizeof(rect));
250 GetWindowRect32 ( hwnd, &rect );
252 FIXME (win, "Check whether a valid region here\n");
254 SetRectRgn32 ( hrgn, rect.left, rect.top, rect.right, rect.bottom );
256 return (SIMPLEREGION);
259 /***********************************************************************
260 * SetWindowRgn32
262 INT32 WINAPI SetWindowRgn32( HWND32 hwnd, HRGN32 hrgn,BOOL32 bRedraw)
266 FIXME (win, "SetWindowRgn32: stub\n");
267 return TRUE;
270 /***********************************************************************
271 * SetWindowRgn16
273 INT16 WINAPI SetWindowRgn16( HWND16 hwnd, HRGN16 hrgn,BOOL16 bRedraw)
277 FIXME (win, "SetWindowRgn16: stub\n");
278 return TRUE;
282 /***********************************************************************
283 * GetClientRect16 (USER.33)
285 void WINAPI GetClientRect16( HWND16 hwnd, LPRECT16 rect )
287 WND * wndPtr = WIN_FindWndPtr( hwnd );
289 rect->left = rect->top = rect->right = rect->bottom = 0;
290 if (wndPtr)
292 rect->right = wndPtr->rectClient.right - wndPtr->rectClient.left;
293 rect->bottom = wndPtr->rectClient.bottom - wndPtr->rectClient.top;
298 /***********************************************************************
299 * GetClientRect32 (USER32.220)
301 void WINAPI GetClientRect32( HWND32 hwnd, LPRECT32 rect )
303 WND * wndPtr = WIN_FindWndPtr( hwnd );
305 rect->left = rect->top = rect->right = rect->bottom = 0;
306 if (wndPtr)
308 rect->right = wndPtr->rectClient.right - wndPtr->rectClient.left;
309 rect->bottom = wndPtr->rectClient.bottom - wndPtr->rectClient.top;
314 /*******************************************************************
315 * ClientToScreen16 (USER.28)
317 void WINAPI ClientToScreen16( HWND16 hwnd, LPPOINT16 lppnt )
319 MapWindowPoints16( hwnd, 0, lppnt, 1 );
323 /*******************************************************************
324 * ClientToScreen32 (USER32.52)
326 BOOL32 WINAPI ClientToScreen32( HWND32 hwnd, LPPOINT32 lppnt )
328 MapWindowPoints32( hwnd, 0, lppnt, 1 );
329 return TRUE;
333 /*******************************************************************
334 * ScreenToClient16 (USER.29)
336 void WINAPI ScreenToClient16( HWND16 hwnd, LPPOINT16 lppnt )
338 MapWindowPoints16( 0, hwnd, lppnt, 1 );
342 /*******************************************************************
343 * ScreenToClient32 (USER32.447)
345 void WINAPI ScreenToClient32( HWND32 hwnd, LPPOINT32 lppnt )
347 MapWindowPoints32( 0, hwnd, lppnt, 1 );
351 /***********************************************************************
352 * WINPOS_WindowFromPoint
354 * Find the window and hittest for a given point.
356 INT16 WINPOS_WindowFromPoint( WND* wndScope, POINT16 pt, WND **ppWnd )
358 WND *wndPtr;
359 INT16 hittest = HTERROR;
360 POINT16 xy = pt;
362 *ppWnd = NULL;
363 wndPtr = wndScope->child;
364 if( wndScope->flags & WIN_MANAGED )
366 /* this prevents mouse clicks from going "through" scrollbars in managed mode */
367 if( pt.x < wndScope->rectClient.left || pt.x >= wndScope->rectClient.right ||
368 pt.y < wndScope->rectClient.top || pt.y >= wndScope->rectClient.bottom )
369 goto hittest;
371 MapWindowPoints16( GetDesktopWindow16(), wndScope->hwndSelf, &xy, 1 );
373 for (;;)
375 while (wndPtr)
377 /* If point is in window, and window is visible, and it */
378 /* is enabled (or it's a top-level window), then explore */
379 /* its children. Otherwise, go to the next window. */
381 if ((wndPtr->dwStyle & WS_VISIBLE) &&
382 (!(wndPtr->dwStyle & WS_DISABLED) ||
383 ((wndPtr->dwStyle & (WS_POPUP | WS_CHILD)) != WS_CHILD)) &&
384 (xy.x >= wndPtr->rectWindow.left) &&
385 (xy.x < wndPtr->rectWindow.right) &&
386 (xy.y >= wndPtr->rectWindow.top) &&
387 (xy.y < wndPtr->rectWindow.bottom))
389 *ppWnd = wndPtr; /* Got a suitable window */
391 /* If window is minimized or disabled, return at once */
392 if (wndPtr->dwStyle & WS_MINIMIZE) return HTCAPTION;
393 if (wndPtr->dwStyle & WS_DISABLED) return HTERROR;
395 /* If point is not in client area, ignore the children */
396 if ((xy.x < wndPtr->rectClient.left) ||
397 (xy.x >= wndPtr->rectClient.right) ||
398 (xy.y < wndPtr->rectClient.top) ||
399 (xy.y >= wndPtr->rectClient.bottom)) break;
401 xy.x -= wndPtr->rectClient.left;
402 xy.y -= wndPtr->rectClient.top;
403 wndPtr = wndPtr->child;
405 else wndPtr = wndPtr->next;
408 hittest:
409 /* If nothing found, try the scope window */
410 if (!*ppWnd) *ppWnd = wndScope;
412 /* Send the WM_NCHITTEST message (only if to the same task) */
413 if ((*ppWnd)->hmemTaskQ == GetFastQueue())
415 hittest = (INT16)SendMessage16( (*ppWnd)->hwndSelf, WM_NCHITTEST,
416 0, MAKELONG( pt.x, pt.y ) );
417 if (hittest != HTTRANSPARENT) return hittest; /* Found the window */
419 else return HTCLIENT;
421 /* If no children found in last search, make point relative to parent */
422 if (!wndPtr)
424 xy.x += (*ppWnd)->rectClient.left;
425 xy.y += (*ppWnd)->rectClient.top;
428 /* Restart the search from the next sibling */
429 wndPtr = (*ppWnd)->next;
430 *ppWnd = (*ppWnd)->parent;
435 /*******************************************************************
436 * WindowFromPoint16 (USER.30)
438 HWND16 WINAPI WindowFromPoint16( POINT16 pt )
440 WND *pWnd;
441 WINPOS_WindowFromPoint( WIN_GetDesktop(), pt, &pWnd );
442 return pWnd->hwndSelf;
446 /*******************************************************************
447 * WindowFromPoint32 (USER32.582)
449 HWND32 WINAPI WindowFromPoint32( POINT32 pt )
451 WND *pWnd;
452 POINT16 pt16;
453 CONV_POINT32TO16( &pt, &pt16 );
454 WINPOS_WindowFromPoint( WIN_GetDesktop(), pt16, &pWnd );
455 return (HWND32)pWnd->hwndSelf;
459 /*******************************************************************
460 * ChildWindowFromPoint16 (USER.191)
462 HWND16 WINAPI ChildWindowFromPoint16( HWND16 hwndParent, POINT16 pt )
464 POINT32 pt32;
465 CONV_POINT16TO32( &pt, &pt32 );
466 return (HWND16)ChildWindowFromPoint32( hwndParent, pt32 );
470 /*******************************************************************
471 * ChildWindowFromPoint32 (USER32.49)
473 HWND32 WINAPI ChildWindowFromPoint32( HWND32 hwndParent, POINT32 pt )
475 /* pt is in the client coordinates */
477 WND* wnd = WIN_FindWndPtr(hwndParent);
478 RECT32 rect;
480 if( !wnd ) return 0;
482 /* get client rect fast */
483 rect.top = rect.left = 0;
484 rect.right = wnd->rectClient.right - wnd->rectClient.left;
485 rect.bottom = wnd->rectClient.bottom - wnd->rectClient.top;
487 if (!PtInRect32( &rect, pt )) return 0;
489 wnd = wnd->child;
490 while ( wnd )
492 if (PtInRect32( &wnd->rectWindow, pt )) return wnd->hwndSelf;
493 wnd = wnd->next;
495 return hwndParent;
498 /*******************************************************************
499 * ChildWindowFromPointEx16 (USER.50)
501 HWND16 WINAPI ChildWindowFromPointEx16( HWND16 hwndParent, POINT16 pt, UINT16 uFlags)
503 POINT32 pt32;
504 CONV_POINT16TO32( &pt, &pt32 );
505 return (HWND16)ChildWindowFromPointEx32( hwndParent, pt32, uFlags );
509 /*******************************************************************
510 * ChildWindowFromPointEx32 (USER32.50)
512 HWND32 WINAPI ChildWindowFromPointEx32( HWND32 hwndParent, POINT32 pt,
513 UINT32 uFlags)
515 /* pt is in the client coordinates */
517 WND* wnd = WIN_FindWndPtr(hwndParent);
518 RECT32 rect;
520 if( !wnd ) return 0;
522 /* get client rect fast */
523 rect.top = rect.left = 0;
524 rect.right = wnd->rectClient.right - wnd->rectClient.left;
525 rect.bottom = wnd->rectClient.bottom - wnd->rectClient.top;
527 if (!PtInRect32( &rect, pt )) return 0;
529 wnd = wnd->child;
530 while ( wnd )
532 if (PtInRect32( &wnd->rectWindow, pt )) {
533 if ( (uFlags & CWP_SKIPINVISIBLE) &&
534 !(wnd->dwStyle & WS_VISIBLE) )
535 wnd = wnd->next;
536 else if ( (uFlags & CWP_SKIPDISABLED) &&
537 (wnd->dwStyle & WS_DISABLED) )
538 wnd = wnd->next;
539 else if ( (uFlags & CWP_SKIPTRANSPARENT) &&
540 (wnd->dwExStyle & WS_EX_TRANSPARENT) )
541 wnd = wnd->next;
542 else
543 return wnd->hwndSelf;
546 return hwndParent;
550 /*******************************************************************
551 * WINPOS_GetWinOffset
553 * Calculate the offset between the origin of the two windows. Used
554 * to implement MapWindowPoints.
556 static void WINPOS_GetWinOffset( HWND32 hwndFrom, HWND32 hwndTo,
557 POINT32 *offset )
559 WND * wndPtr;
561 offset->x = offset->y = 0;
562 if (hwndFrom == hwndTo ) return;
564 /* Translate source window origin to screen coords */
565 if (hwndFrom)
567 if (!(wndPtr = WIN_FindWndPtr( hwndFrom )))
569 ERR(win,"bad hwndFrom = %04x\n",hwndFrom);
570 return;
572 while (wndPtr->parent)
574 offset->x += wndPtr->rectClient.left;
575 offset->y += wndPtr->rectClient.top;
576 wndPtr = wndPtr->parent;
580 /* Translate origin to destination window coords */
581 if (hwndTo)
583 if (!(wndPtr = WIN_FindWndPtr( hwndTo )))
585 ERR(win,"bad hwndTo = %04x\n", hwndTo );
586 return;
588 while (wndPtr->parent)
590 offset->x -= wndPtr->rectClient.left;
591 offset->y -= wndPtr->rectClient.top;
592 wndPtr = wndPtr->parent;
598 /*******************************************************************
599 * MapWindowPoints16 (USER.258)
601 void WINAPI MapWindowPoints16( HWND16 hwndFrom, HWND16 hwndTo,
602 LPPOINT16 lppt, UINT16 count )
604 POINT32 offset;
606 WINPOS_GetWinOffset( hwndFrom, hwndTo, &offset );
607 while (count--)
609 lppt->x += offset.x;
610 lppt->y += offset.y;
611 lppt++;
616 /*******************************************************************
617 * MapWindowPoints32 (USER32.386)
619 void WINAPI MapWindowPoints32( HWND32 hwndFrom, HWND32 hwndTo,
620 LPPOINT32 lppt, UINT32 count )
622 POINT32 offset;
624 WINPOS_GetWinOffset( hwndFrom, hwndTo, &offset );
625 while (count--)
627 lppt->x += offset.x;
628 lppt->y += offset.y;
629 lppt++;
634 /***********************************************************************
635 * IsIconic16 (USER.31)
637 BOOL16 WINAPI IsIconic16(HWND16 hWnd)
639 return IsIconic32(hWnd);
643 /***********************************************************************
644 * IsIconic32 (USER32.345)
646 BOOL32 WINAPI IsIconic32(HWND32 hWnd)
648 WND * wndPtr = WIN_FindWndPtr(hWnd);
649 if (wndPtr == NULL) return FALSE;
650 return (wndPtr->dwStyle & WS_MINIMIZE) != 0;
654 /***********************************************************************
655 * IsZoomed (USER.272)
657 BOOL16 WINAPI IsZoomed16(HWND16 hWnd)
659 return IsZoomed32(hWnd);
663 /***********************************************************************
664 * IsZoomed (USER32.352)
666 BOOL32 WINAPI IsZoomed32(HWND32 hWnd)
668 WND * wndPtr = WIN_FindWndPtr(hWnd);
669 if (wndPtr == NULL) return FALSE;
670 return (wndPtr->dwStyle & WS_MAXIMIZE) != 0;
674 /*******************************************************************
675 * GetActiveWindow (USER.60)
677 HWND16 WINAPI GetActiveWindow16(void)
679 return (HWND16)hwndActive;
682 /*******************************************************************
683 * GetActiveWindow (USER32.205)
685 HWND32 WINAPI GetActiveWindow32(void)
687 return (HWND32)hwndActive;
691 /*******************************************************************
692 * WINPOS_CanActivate
694 static BOOL32 WINPOS_CanActivate(WND* pWnd)
696 if( pWnd && ((pWnd->dwStyle & (WS_DISABLED | WS_VISIBLE | WS_CHILD))
697 == WS_VISIBLE) ) return TRUE;
698 return FALSE;
702 /*******************************************************************
703 * SetActiveWindow16 (USER.59)
705 HWND16 WINAPI SetActiveWindow16( HWND16 hwnd )
707 return SetActiveWindow32(hwnd);
711 /*******************************************************************
712 * SetActiveWindow32 (USER32.463)
714 HWND32 WINAPI SetActiveWindow32( HWND32 hwnd )
716 HWND32 prev = hwndActive;
717 WND *wndPtr = WIN_FindWndPtr( hwnd );
719 if ( !WINPOS_CanActivate(wndPtr) ) return 0;
721 WINPOS_SetActiveWindow( hwnd, 0, 0 );
722 return prev;
726 /*******************************************************************
727 * GetForegroundWindow16 (USER.608)
729 HWND16 WINAPI GetForegroundWindow16(void)
731 return (HWND16)GetForegroundWindow32();
735 /*******************************************************************
736 * SetForegroundWindow16 (USER.609)
738 BOOL16 WINAPI SetForegroundWindow16( HWND16 hwnd )
740 return SetForegroundWindow32( hwnd );
744 /*******************************************************************
745 * GetForegroundWindow32 (USER32.241)
747 HWND32 WINAPI GetForegroundWindow32(void)
749 return GetActiveWindow32();
753 /*******************************************************************
754 * SetForegroundWindow32 (USER32.482)
756 BOOL32 WINAPI SetForegroundWindow32( HWND32 hwnd )
758 SetActiveWindow32( hwnd );
759 return TRUE;
763 /*******************************************************************
764 * GetShellWindow16 (USER.600)
766 HWND16 WINAPI GetShellWindow16(void)
768 return GetShellWindow32();
771 /*******************************************************************
772 * SetShellWindow32 (USER32.504)
774 HWND32 WINAPI SetShellWindow32(HWND32 hwndshell)
775 { WARN(win, "(hWnd=%08x) semi stub\n",hwndshell );
777 hGlobalShellWindow = hwndshell;
778 return hGlobalShellWindow;
782 /*******************************************************************
783 * GetShellWindow32 (USER32.287)
785 HWND32 WINAPI GetShellWindow32(void)
786 { WARN(win, "(hWnd=%x) semi stub\n",hGlobalShellWindow );
788 return hGlobalShellWindow;
792 /***********************************************************************
793 * BringWindowToTop16 (USER.45)
795 BOOL16 WINAPI BringWindowToTop16( HWND16 hwnd )
797 return BringWindowToTop32(hwnd);
801 /***********************************************************************
802 * BringWindowToTop32 (USER32.11)
804 BOOL32 WINAPI BringWindowToTop32( HWND32 hwnd )
806 return SetWindowPos32( hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE );
810 /***********************************************************************
811 * MoveWindow16 (USER.56)
813 BOOL16 WINAPI MoveWindow16( HWND16 hwnd, INT16 x, INT16 y, INT16 cx, INT16 cy,
814 BOOL16 repaint )
816 return MoveWindow32(hwnd,x,y,cx,cy,repaint);
820 /***********************************************************************
821 * MoveWindow32 (USER32.399)
823 BOOL32 WINAPI MoveWindow32( HWND32 hwnd, INT32 x, INT32 y, INT32 cx, INT32 cy,
824 BOOL32 repaint )
826 int flags = SWP_NOZORDER | SWP_NOACTIVATE;
827 if (!repaint) flags |= SWP_NOREDRAW;
828 TRACE(win, "%04x %d,%d %dx%d %d\n",
829 hwnd, x, y, cx, cy, repaint );
830 return SetWindowPos32( hwnd, 0, x, y, cx, cy, flags );
833 /***********************************************************************
834 * WINPOS_InitInternalPos
836 static LPINTERNALPOS WINPOS_InitInternalPos( WND* wnd, POINT32 pt,
837 LPRECT32 restoreRect )
839 LPINTERNALPOS lpPos = (LPINTERNALPOS) GetProp32A( wnd->hwndSelf,
840 atomInternalPos );
841 if( !lpPos )
843 /* this happens when the window is minimized/maximized
844 * for the first time (rectWindow is not adjusted yet) */
846 lpPos = HeapAlloc( SystemHeap, 0, sizeof(INTERNALPOS) );
847 if( !lpPos ) return NULL;
849 SetProp32A( wnd->hwndSelf, atomInternalPos, (HANDLE32)lpPos );
850 lpPos->hwndIconTitle = 0; /* defer until needs to be shown */
851 CONV_RECT32TO16( &wnd->rectWindow, &lpPos->rectNormal );
852 *(UINT32*)&lpPos->ptIconPos = *(UINT32*)&lpPos->ptMaxPos = 0xFFFFFFFF;
855 if( wnd->dwStyle & WS_MINIMIZE )
856 CONV_POINT32TO16( &pt, &lpPos->ptIconPos );
857 else if( wnd->dwStyle & WS_MAXIMIZE )
858 CONV_POINT32TO16( &pt, &lpPos->ptMaxPos );
859 else if( restoreRect )
860 CONV_RECT32TO16( restoreRect, &lpPos->rectNormal );
862 return lpPos;
865 /***********************************************************************
866 * WINPOS_RedrawIconTitle
868 BOOL32 WINPOS_RedrawIconTitle( HWND32 hWnd )
870 LPINTERNALPOS lpPos = (LPINTERNALPOS)GetProp32A( hWnd, atomInternalPos );
871 if( lpPos )
873 if( lpPos->hwndIconTitle )
875 SendMessage32A( lpPos->hwndIconTitle, WM_SHOWWINDOW, TRUE, 0);
876 InvalidateRect32( lpPos->hwndIconTitle, NULL, TRUE );
877 return TRUE;
880 return FALSE;
883 /***********************************************************************
884 * WINPOS_ShowIconTitle
886 BOOL32 WINPOS_ShowIconTitle( WND* pWnd, BOOL32 bShow )
888 LPINTERNALPOS lpPos = (LPINTERNALPOS)GetProp32A( pWnd->hwndSelf, atomInternalPos );
890 if( lpPos && !(pWnd->flags & WIN_MANAGED))
892 HWND16 hWnd = lpPos->hwndIconTitle;
894 TRACE(win,"0x%04x %i\n", pWnd->hwndSelf, (bShow != 0) );
896 if( !hWnd )
897 lpPos->hwndIconTitle = hWnd = ICONTITLE_Create( pWnd );
898 if( bShow )
900 pWnd = WIN_FindWndPtr(hWnd);
902 if( !(pWnd->dwStyle & WS_VISIBLE) )
904 SendMessage32A( hWnd, WM_SHOWWINDOW, TRUE, 0 );
905 SetWindowPos32( hWnd, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE |
906 SWP_NOACTIVATE | SWP_NOZORDER | SWP_SHOWWINDOW );
909 else ShowWindow32( hWnd, SW_HIDE );
911 return FALSE;
914 /*******************************************************************
915 * WINPOS_GetMinMaxInfo
917 * Get the minimized and maximized information for a window.
919 void WINPOS_GetMinMaxInfo( WND *wndPtr, POINT32 *maxSize, POINT32 *maxPos,
920 POINT32 *minTrack, POINT32 *maxTrack )
922 LPINTERNALPOS lpPos;
923 MINMAXINFO32 MinMax;
924 INT32 xinc, yinc;
926 /* Compute default values */
928 MinMax.ptMaxSize.x = SYSMETRICS_CXSCREEN;
929 MinMax.ptMaxSize.y = SYSMETRICS_CYSCREEN;
930 MinMax.ptMinTrackSize.x = SYSMETRICS_CXMINTRACK;
931 MinMax.ptMinTrackSize.y = SYSMETRICS_CYMINTRACK;
932 MinMax.ptMaxTrackSize.x = SYSMETRICS_CXSCREEN;
933 MinMax.ptMaxTrackSize.y = SYSMETRICS_CYSCREEN;
935 if (wndPtr->flags & WIN_MANAGED) xinc = yinc = 0;
936 else if (HAS_DLGFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
938 xinc = SYSMETRICS_CXDLGFRAME;
939 yinc = SYSMETRICS_CYDLGFRAME;
941 else
943 xinc = yinc = 0;
944 if (HAS_THICKFRAME(wndPtr->dwStyle))
946 xinc += SYSMETRICS_CXFRAME;
947 yinc += SYSMETRICS_CYFRAME;
949 if (wndPtr->dwStyle & WS_BORDER)
951 xinc += SYSMETRICS_CXBORDER;
952 yinc += SYSMETRICS_CYBORDER;
955 MinMax.ptMaxSize.x += 2 * xinc;
956 MinMax.ptMaxSize.y += 2 * yinc;
958 lpPos = (LPINTERNALPOS)GetProp32A( wndPtr->hwndSelf, atomInternalPos );
959 if( lpPos && !EMPTYPOINT(lpPos->ptMaxPos) )
960 CONV_POINT16TO32( &lpPos->ptMaxPos, &MinMax.ptMaxPosition );
961 else
963 MinMax.ptMaxPosition.x = -xinc;
964 MinMax.ptMaxPosition.y = -yinc;
967 SendMessage32A( wndPtr->hwndSelf, WM_GETMINMAXINFO, 0, (LPARAM)&MinMax );
969 /* Some sanity checks */
971 TRACE(win,"%d %d / %d %d / %d %d / %d %d\n",
972 MinMax.ptMaxSize.x, MinMax.ptMaxSize.y,
973 MinMax.ptMaxPosition.x, MinMax.ptMaxPosition.y,
974 MinMax.ptMaxTrackSize.x, MinMax.ptMaxTrackSize.y,
975 MinMax.ptMinTrackSize.x, MinMax.ptMinTrackSize.y);
976 MinMax.ptMaxTrackSize.x = MAX( MinMax.ptMaxTrackSize.x,
977 MinMax.ptMinTrackSize.x );
978 MinMax.ptMaxTrackSize.y = MAX( MinMax.ptMaxTrackSize.y,
979 MinMax.ptMinTrackSize.y );
981 if (maxSize) *maxSize = MinMax.ptMaxSize;
982 if (maxPos) *maxPos = MinMax.ptMaxPosition;
983 if (minTrack) *minTrack = MinMax.ptMinTrackSize;
984 if (maxTrack) *maxTrack = MinMax.ptMaxTrackSize;
987 /***********************************************************************
988 * WINPOS_MinMaximize
990 * Fill in lpRect and return additional flags to be used with SetWindowPos().
991 * This function assumes that 'cmd' is different from the current window
992 * state.
994 UINT16 WINPOS_MinMaximize( WND* wndPtr, UINT16 cmd, LPRECT16 lpRect )
996 UINT16 swpFlags = 0;
997 POINT32 pt;
998 POINT32 size = { wndPtr->rectWindow.left, wndPtr->rectWindow.top };
999 LPINTERNALPOS lpPos = WINPOS_InitInternalPos( wndPtr, size,
1000 &wndPtr->rectWindow );
1002 TRACE(win,"0x%04x %u\n", wndPtr->hwndSelf, cmd );
1004 if (lpPos && !HOOK_CallHooks16(WH_CBT, HCBT_MINMAX, wndPtr->hwndSelf, cmd))
1006 if( wndPtr->dwStyle & WS_MINIMIZE )
1008 if( !SendMessage32A( wndPtr->hwndSelf, WM_QUERYOPEN, 0, 0L ) )
1009 return (SWP_NOSIZE | SWP_NOMOVE);
1010 swpFlags |= SWP_NOCOPYBITS;
1012 switch( cmd )
1014 case SW_MINIMIZE:
1015 if( wndPtr->dwStyle & WS_MAXIMIZE)
1017 wndPtr->flags |= WIN_RESTORE_MAX;
1018 wndPtr->dwStyle &= ~WS_MAXIMIZE;
1020 else
1021 wndPtr->flags &= ~WIN_RESTORE_MAX;
1022 wndPtr->dwStyle |= WS_MINIMIZE;
1024 lpPos->ptIconPos = WINPOS_FindIconPos( wndPtr, lpPos->ptIconPos );
1026 SetRect16( lpRect, lpPos->ptIconPos.x, lpPos->ptIconPos.y,
1027 SYSMETRICS_CXICON, SYSMETRICS_CYICON );
1028 swpFlags |= SWP_NOCOPYBITS;
1029 break;
1031 case SW_MAXIMIZE:
1032 CONV_POINT16TO32( &lpPos->ptMaxPos, &pt );
1033 WINPOS_GetMinMaxInfo( wndPtr, &size, &pt, NULL, NULL );
1034 CONV_POINT32TO16( &pt, &lpPos->ptMaxPos );
1036 if( wndPtr->dwStyle & WS_MINIMIZE )
1038 WINPOS_ShowIconTitle( wndPtr, FALSE );
1039 wndPtr->dwStyle &= ~WS_MINIMIZE;
1041 wndPtr->dwStyle |= WS_MAXIMIZE;
1043 SetRect16( lpRect, lpPos->ptMaxPos.x, lpPos->ptMaxPos.y,
1044 size.x, size.y );
1045 break;
1047 case SW_RESTORE:
1048 if( wndPtr->dwStyle & WS_MINIMIZE )
1050 wndPtr->dwStyle &= ~WS_MINIMIZE;
1051 WINPOS_ShowIconTitle( wndPtr, FALSE );
1052 if( wndPtr->flags & WIN_RESTORE_MAX)
1054 /* Restore to maximized position */
1055 CONV_POINT16TO32( &lpPos->ptMaxPos, &pt );
1056 WINPOS_GetMinMaxInfo( wndPtr, &size, &pt, NULL, NULL);
1057 CONV_POINT32TO16( &pt, &lpPos->ptMaxPos );
1058 wndPtr->dwStyle |= WS_MAXIMIZE;
1059 SetRect16( lpRect, lpPos->ptMaxPos.x, lpPos->ptMaxPos.y, size.x, size.y );
1060 break;
1063 else
1064 if( !(wndPtr->dwStyle & WS_MAXIMIZE) ) return (UINT16)(-1);
1065 else wndPtr->dwStyle &= ~WS_MAXIMIZE;
1067 /* Restore to normal position */
1069 *lpRect = lpPos->rectNormal;
1070 lpRect->right -= lpRect->left;
1071 lpRect->bottom -= lpRect->top;
1073 break;
1075 } else swpFlags |= SWP_NOSIZE | SWP_NOMOVE;
1076 return swpFlags;
1079 /***********************************************************************
1080 * ShowWindowAsync32 (USER32.535)
1082 * doesn't wait; returns immediately.
1083 * used by threads to toggle windows in other (possibly hanging) threads
1085 BOOL32 WINAPI ShowWindowAsync32( HWND32 hwnd, INT32 cmd )
1087 /* FIXME: does ShowWindow32() return immediately ? */
1088 return ShowWindow32(hwnd, cmd);
1092 /***********************************************************************
1093 * ShowWindow16 (USER.42)
1095 BOOL16 WINAPI ShowWindow16( HWND16 hwnd, INT16 cmd )
1097 return ShowWindow32(hwnd,cmd);
1101 /***********************************************************************
1102 * ShowWindow32 (USER32.534)
1104 BOOL32 WINAPI ShowWindow32( HWND32 hwnd, INT32 cmd )
1106 WND* wndPtr = WIN_FindWndPtr( hwnd );
1107 BOOL32 wasVisible, showFlag;
1108 RECT16 newPos = {0, 0, 0, 0};
1109 int swp = 0;
1111 if (!wndPtr) return FALSE;
1113 TRACE(win,"hwnd=%04x, cmd=%d\n", hwnd, cmd);
1115 wasVisible = (wndPtr->dwStyle & WS_VISIBLE) != 0;
1117 switch(cmd)
1119 case SW_HIDE:
1120 if (!wasVisible) return FALSE;
1121 swp |= SWP_HIDEWINDOW | SWP_NOSIZE | SWP_NOMOVE |
1122 SWP_NOACTIVATE | SWP_NOZORDER;
1123 break;
1125 case SW_SHOWMINNOACTIVE:
1126 swp |= SWP_NOACTIVATE | SWP_NOZORDER;
1127 /* fall through */
1128 case SW_SHOWMINIMIZED:
1129 swp |= SWP_SHOWWINDOW;
1130 /* fall through */
1131 case SW_MINIMIZE:
1132 swp |= SWP_FRAMECHANGED;
1133 if( !(wndPtr->dwStyle & WS_MINIMIZE) )
1134 swp |= WINPOS_MinMaximize( wndPtr, SW_MINIMIZE, &newPos );
1135 else swp |= SWP_NOSIZE | SWP_NOMOVE;
1136 break;
1138 case SW_SHOWMAXIMIZED: /* same as SW_MAXIMIZE */
1139 swp |= SWP_SHOWWINDOW | SWP_FRAMECHANGED;
1140 if( !(wndPtr->dwStyle & WS_MAXIMIZE) )
1141 swp |= WINPOS_MinMaximize( wndPtr, SW_MAXIMIZE, &newPos );
1142 else swp |= SWP_NOSIZE | SWP_NOMOVE;
1143 break;
1145 case SW_SHOWNA:
1146 swp |= SWP_NOACTIVATE | SWP_NOZORDER;
1147 /* fall through */
1148 case SW_SHOW:
1149 swp |= SWP_SHOWWINDOW | SWP_NOSIZE | SWP_NOMOVE;
1150 break;
1152 case SW_SHOWNOACTIVATE:
1153 swp |= SWP_NOZORDER;
1154 if (GetActiveWindow32()) swp |= SWP_NOACTIVATE;
1155 /* fall through */
1156 case SW_SHOWNORMAL: /* same as SW_NORMAL: */
1157 case SW_SHOWDEFAULT: /* FIXME: should have its own handler */
1158 case SW_RESTORE:
1159 swp |= SWP_SHOWWINDOW | SWP_FRAMECHANGED;
1161 if( wndPtr->dwStyle & (WS_MINIMIZE | WS_MAXIMIZE) )
1162 swp |= WINPOS_MinMaximize( wndPtr, SW_RESTORE, &newPos );
1163 else swp |= SWP_NOSIZE | SWP_NOMOVE;
1164 break;
1167 showFlag = (cmd != SW_HIDE);
1168 if (showFlag != wasVisible)
1170 SendMessage32A( hwnd, WM_SHOWWINDOW, showFlag, 0 );
1171 if (!IsWindow32( hwnd )) return wasVisible;
1174 if ((wndPtr->dwStyle & WS_CHILD) &&
1175 !IsWindowVisible32( wndPtr->parent->hwndSelf ) &&
1176 (swp & (SWP_NOSIZE | SWP_NOMOVE)) == (SWP_NOSIZE | SWP_NOMOVE) )
1178 /* Don't call SetWindowPos32() on invisible child windows */
1179 if (cmd == SW_HIDE) wndPtr->dwStyle &= ~WS_VISIBLE;
1180 else wndPtr->dwStyle |= WS_VISIBLE;
1182 else
1184 /* We can't activate a child window */
1185 if (wndPtr->dwStyle & WS_CHILD) swp |= SWP_NOACTIVATE | SWP_NOZORDER;
1186 SetWindowPos32( hwnd, HWND_TOP,
1187 newPos.left, newPos.top, newPos.right, newPos.bottom, swp );
1188 if (!IsWindow32( hwnd )) return wasVisible;
1189 else if( wndPtr->dwStyle & WS_MINIMIZE ) WINPOS_ShowIconTitle( wndPtr, TRUE );
1192 if (wndPtr->flags & WIN_NEED_SIZE)
1194 /* should happen only in CreateWindowEx() */
1195 int wParam = SIZE_RESTORED;
1197 wndPtr->flags &= ~WIN_NEED_SIZE;
1198 if (wndPtr->dwStyle & WS_MAXIMIZE) wParam = SIZE_MAXIMIZED;
1199 else if (wndPtr->dwStyle & WS_MINIMIZE) wParam = SIZE_MINIMIZED;
1200 SendMessage32A( hwnd, WM_SIZE, wParam,
1201 MAKELONG(wndPtr->rectClient.right-wndPtr->rectClient.left,
1202 wndPtr->rectClient.bottom-wndPtr->rectClient.top));
1203 SendMessage32A( hwnd, WM_MOVE, 0,
1204 MAKELONG(wndPtr->rectClient.left, wndPtr->rectClient.top) );
1207 return wasVisible;
1211 /***********************************************************************
1212 * GetInternalWindowPos16 (USER.460)
1214 UINT16 WINAPI GetInternalWindowPos16( HWND16 hwnd, LPRECT16 rectWnd,
1215 LPPOINT16 ptIcon )
1217 WINDOWPLACEMENT16 wndpl;
1218 if (GetWindowPlacement16( hwnd, &wndpl ))
1220 if (rectWnd) *rectWnd = wndpl.rcNormalPosition;
1221 if (ptIcon) *ptIcon = wndpl.ptMinPosition;
1222 return wndpl.showCmd;
1224 return 0;
1228 /***********************************************************************
1229 * GetInternalWindowPos32 (USER32.245)
1231 UINT32 WINAPI GetInternalWindowPos32( HWND32 hwnd, LPRECT32 rectWnd,
1232 LPPOINT32 ptIcon )
1234 WINDOWPLACEMENT32 wndpl;
1235 if (GetWindowPlacement32( hwnd, &wndpl ))
1237 if (rectWnd) *rectWnd = wndpl.rcNormalPosition;
1238 if (ptIcon) *ptIcon = wndpl.ptMinPosition;
1239 return wndpl.showCmd;
1241 return 0;
1244 /***********************************************************************
1245 * GetWindowPlacement16 (USER.370)
1247 BOOL16 WINAPI GetWindowPlacement16( HWND16 hwnd, WINDOWPLACEMENT16 *wndpl )
1249 WND *pWnd = WIN_FindWndPtr( hwnd );
1250 if( pWnd )
1252 LPINTERNALPOS lpPos = (LPINTERNALPOS)WINPOS_InitInternalPos( pWnd,
1253 *(LPPOINT32)&pWnd->rectWindow.left, &pWnd->rectWindow );
1254 wndpl->length = sizeof(*wndpl);
1255 if( pWnd->dwStyle & WS_MINIMIZE )
1256 wndpl->showCmd = SW_SHOWMINIMIZED;
1257 else
1258 wndpl->showCmd = ( pWnd->dwStyle & WS_MAXIMIZE )
1259 ? SW_SHOWMAXIMIZED : SW_SHOWNORMAL ;
1260 if( pWnd->flags & WIN_RESTORE_MAX )
1261 wndpl->flags = WPF_RESTORETOMAXIMIZED;
1262 else
1263 wndpl->flags = 0;
1264 wndpl->ptMinPosition = lpPos->ptIconPos;
1265 wndpl->ptMaxPosition = lpPos->ptMaxPos;
1266 wndpl->rcNormalPosition = lpPos->rectNormal;
1267 return TRUE;
1269 return FALSE;
1273 /***********************************************************************
1274 * GetWindowPlacement32 (USER32.307)
1276 BOOL32 WINAPI GetWindowPlacement32( HWND32 hwnd, WINDOWPLACEMENT32 *pwpl32 )
1278 if( pwpl32 )
1280 WINDOWPLACEMENT16 wpl;
1281 wpl.length = sizeof(wpl);
1282 if( GetWindowPlacement16( hwnd, &wpl ) )
1284 pwpl32->length = sizeof(*pwpl32);
1285 pwpl32->flags = wpl.flags;
1286 pwpl32->showCmd = wpl.showCmd;
1287 CONV_POINT16TO32( &wpl.ptMinPosition, &pwpl32->ptMinPosition );
1288 CONV_POINT16TO32( &wpl.ptMaxPosition, &pwpl32->ptMaxPosition );
1289 CONV_RECT16TO32( &wpl.rcNormalPosition, &pwpl32->rcNormalPosition );
1290 return TRUE;
1293 return FALSE;
1297 /***********************************************************************
1298 * WINPOS_SetPlacement
1300 static BOOL32 WINPOS_SetPlacement( HWND32 hwnd, const WINDOWPLACEMENT16 *wndpl,
1301 UINT32 flags )
1303 WND *pWnd = WIN_FindWndPtr( hwnd );
1304 if( pWnd )
1306 LPINTERNALPOS lpPos = (LPINTERNALPOS)WINPOS_InitInternalPos( pWnd,
1307 *(LPPOINT32)&pWnd->rectWindow.left, &pWnd->rectWindow );
1309 if( flags & PLACE_MIN ) lpPos->ptIconPos = wndpl->ptMinPosition;
1310 if( flags & PLACE_MAX ) lpPos->ptMaxPos = wndpl->ptMaxPosition;
1311 if( flags & PLACE_RECT) lpPos->rectNormal = wndpl->rcNormalPosition;
1313 if( pWnd->dwStyle & WS_MINIMIZE )
1315 WINPOS_ShowIconTitle( pWnd, FALSE );
1316 if( wndpl->flags & WPF_SETMINPOSITION && !EMPTYPOINT(lpPos->ptIconPos))
1317 SetWindowPos32( hwnd, 0, lpPos->ptIconPos.x, lpPos->ptIconPos.y,
1318 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE );
1320 else if( pWnd->dwStyle & WS_MAXIMIZE )
1322 if( !EMPTYPOINT(lpPos->ptMaxPos) )
1323 SetWindowPos32( hwnd, 0, lpPos->ptMaxPos.x, lpPos->ptMaxPos.y,
1324 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE );
1326 else if( flags & PLACE_RECT )
1327 SetWindowPos32( hwnd, 0, lpPos->rectNormal.left, lpPos->rectNormal.top,
1328 lpPos->rectNormal.right - lpPos->rectNormal.left,
1329 lpPos->rectNormal.bottom - lpPos->rectNormal.top,
1330 SWP_NOZORDER | SWP_NOACTIVATE );
1332 ShowWindow32( hwnd, wndpl->showCmd );
1333 if( IsWindow32(hwnd) && pWnd->dwStyle & WS_MINIMIZE )
1335 if( pWnd->dwStyle & WS_VISIBLE ) WINPOS_ShowIconTitle( pWnd, TRUE );
1337 /* SDK: ...valid only the next time... */
1338 if( wndpl->flags & WPF_RESTORETOMAXIMIZED ) pWnd->flags |= WIN_RESTORE_MAX;
1340 return TRUE;
1342 return FALSE;
1346 /***********************************************************************
1347 * SetWindowPlacement16 (USER.371)
1349 BOOL16 WINAPI SetWindowPlacement16(HWND16 hwnd, const WINDOWPLACEMENT16 *wndpl)
1351 return WINPOS_SetPlacement( hwnd, wndpl,
1352 PLACE_MIN | PLACE_MAX | PLACE_RECT );
1355 /***********************************************************************
1356 * SetWindowPlacement32 (USER32.519)
1358 BOOL32 WINAPI SetWindowPlacement32( HWND32 hwnd, const WINDOWPLACEMENT32 *pwpl32 )
1360 if( pwpl32 )
1362 WINDOWPLACEMENT16 wpl = { sizeof(WINDOWPLACEMENT16),
1363 pwpl32->flags, pwpl32->showCmd, { pwpl32->ptMinPosition.x,
1364 pwpl32->ptMinPosition.y }, { pwpl32->ptMaxPosition.x,
1365 pwpl32->ptMaxPosition.y }, { pwpl32->rcNormalPosition.left,
1366 pwpl32->rcNormalPosition.top, pwpl32->rcNormalPosition.right,
1367 pwpl32->rcNormalPosition.bottom } };
1369 return WINPOS_SetPlacement( hwnd, &wpl, PLACE_MIN | PLACE_MAX | PLACE_RECT );
1371 return FALSE;
1375 /***********************************************************************
1376 * SetInternalWindowPos16 (USER.461)
1378 void WINAPI SetInternalWindowPos16( HWND16 hwnd, UINT16 showCmd,
1379 LPRECT16 rect, LPPOINT16 pt )
1381 if( IsWindow16(hwnd) )
1383 WINDOWPLACEMENT16 wndpl;
1384 UINT32 flags;
1386 wndpl.length = sizeof(wndpl);
1387 wndpl.showCmd = showCmd;
1388 wndpl.flags = flags = 0;
1390 if( pt )
1392 flags |= PLACE_MIN;
1393 wndpl.flags |= WPF_SETMINPOSITION;
1394 wndpl.ptMinPosition = *pt;
1396 if( rect )
1398 flags |= PLACE_RECT;
1399 wndpl.rcNormalPosition = *rect;
1401 WINPOS_SetPlacement( hwnd, &wndpl, flags );
1406 /***********************************************************************
1407 * SetInternalWindowPos32 (USER32.483)
1409 void WINAPI SetInternalWindowPos32( HWND32 hwnd, UINT32 showCmd,
1410 LPRECT32 rect, LPPOINT32 pt )
1412 if( IsWindow32(hwnd) )
1414 WINDOWPLACEMENT16 wndpl;
1415 UINT32 flags;
1417 wndpl.length = sizeof(wndpl);
1418 wndpl.showCmd = showCmd;
1419 wndpl.flags = flags = 0;
1421 if( pt )
1423 flags |= PLACE_MIN;
1424 wndpl.flags |= WPF_SETMINPOSITION;
1425 CONV_POINT32TO16( pt, &wndpl.ptMinPosition );
1427 if( rect )
1429 flags |= PLACE_RECT;
1430 CONV_RECT32TO16( rect, &wndpl.rcNormalPosition );
1432 WINPOS_SetPlacement( hwnd, &wndpl, flags );
1436 /*******************************************************************
1437 * WINPOS_SetActiveWindow
1439 * SetActiveWindow() back-end. This is the only function that
1440 * can assign active status to a window. It must be called only
1441 * for the top level windows.
1443 BOOL32 WINPOS_SetActiveWindow( HWND32 hWnd, BOOL32 fMouse, BOOL32 fChangeFocus)
1445 CBTACTIVATESTRUCT16* cbtStruct;
1446 WND* wndPtr, *wndTemp;
1447 HQUEUE16 hOldActiveQueue, hNewActiveQueue;
1448 WORD wIconized = 0;
1450 /* paranoid checks */
1451 if( hWnd == GetDesktopWindow32() || hWnd == hwndActive ) return 0;
1453 /* if (wndPtr && (GetFastQueue() != wndPtr->hmemTaskQ))
1454 * return 0;
1456 wndPtr = WIN_FindWndPtr(hWnd);
1457 hOldActiveQueue = (pActiveQueue)?pActiveQueue->self : 0;
1459 if( (wndTemp = WIN_FindWndPtr(hwndActive)) )
1460 wIconized = HIWORD(wndTemp->dwStyle & WS_MINIMIZE);
1461 else
1462 TRACE(win,"no current active window.\n");
1464 /* call CBT hook chain */
1465 if ((cbtStruct = SEGPTR_NEW(CBTACTIVATESTRUCT16)))
1467 LRESULT wRet;
1468 cbtStruct->fMouse = fMouse;
1469 cbtStruct->hWndActive = hwndActive;
1470 wRet = HOOK_CallHooks16( WH_CBT, HCBT_ACTIVATE, (WPARAM16)hWnd,
1471 (LPARAM)SEGPTR_GET(cbtStruct) );
1472 SEGPTR_FREE(cbtStruct);
1473 if (wRet) return wRet;
1476 /* set prev active wnd to current active wnd and send notification */
1477 if ((hwndPrevActive = hwndActive) && IsWindow32(hwndPrevActive))
1479 if (!SendMessage32A( hwndPrevActive, WM_NCACTIVATE, FALSE, 0 ))
1481 if (GetSysModalWindow16() != hWnd) return 0;
1482 /* disregard refusal if hWnd is sysmodal */
1485 #if 1
1486 SendMessage32A( hwndPrevActive, WM_ACTIVATE,
1487 MAKEWPARAM( WA_INACTIVE, wIconized ),
1488 (LPARAM)hWnd );
1489 #else
1490 /* FIXME: must be SendMessage16() because 32A doesn't do
1491 * intertask at this time */
1492 SendMessage16( hwndPrevActive, WM_ACTIVATE, WA_INACTIVE,
1493 MAKELPARAM( (HWND16)hWnd, wIconized ) );
1494 #endif
1496 /* check if something happened during message processing */
1497 if( hwndPrevActive != hwndActive ) return 0;
1500 /* set active wnd */
1501 hwndActive = hWnd;
1503 /* send palette messages */
1504 if (hWnd && SendMessage16( hWnd, WM_QUERYNEWPALETTE, 0, 0L))
1505 SendMessage16((HWND16)-1, WM_PALETTEISCHANGING, (WPARAM16)hWnd, 0L );
1507 /* if prev wnd is minimized redraw icon title */
1508 if( IsIconic32( hwndPrevActive ) ) WINPOS_RedrawIconTitle(hwndPrevActive);
1510 /* managed windows will get ConfigureNotify event */
1511 if (wndPtr && !(wndPtr->dwStyle & WS_CHILD) && !(wndPtr->flags & WIN_MANAGED))
1513 /* check Z-order and bring hWnd to the top */
1514 for (wndTemp = WIN_GetDesktop()->child; wndTemp; wndTemp = wndTemp->next)
1515 if (wndTemp->dwStyle & WS_VISIBLE) break;
1517 if( wndTemp != wndPtr )
1518 SetWindowPos32(hWnd, HWND_TOP, 0,0,0,0,
1519 SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE );
1520 if (!IsWindow32(hWnd)) return 0;
1523 hNewActiveQueue = wndPtr ? wndPtr->hmemTaskQ : 0;
1525 /* send WM_ACTIVATEAPP if necessary */
1526 if (hOldActiveQueue != hNewActiveQueue)
1528 WND **list, **ppWnd;
1530 if ((list = WIN_BuildWinArray( WIN_GetDesktop(), 0, NULL )))
1532 for (ppWnd = list; *ppWnd; ppWnd++)
1534 if (!IsWindow32( (*ppWnd)->hwndSelf )) continue;
1536 if ((*ppWnd)->hmemTaskQ == hOldActiveQueue)
1537 SendMessage16( (*ppWnd)->hwndSelf, WM_ACTIVATEAPP,
1538 0, QUEUE_GetQueueTask(hNewActiveQueue) );
1540 HeapFree( SystemHeap, 0, list );
1543 pActiveQueue = (hNewActiveQueue)
1544 ? (MESSAGEQUEUE*) GlobalLock16(hNewActiveQueue) : NULL;
1546 if ((list = WIN_BuildWinArray( WIN_GetDesktop(), 0, NULL )))
1548 for (ppWnd = list; *ppWnd; ppWnd++)
1550 if (!IsWindow32( (*ppWnd)->hwndSelf )) continue;
1552 if ((*ppWnd)->hmemTaskQ == hNewActiveQueue)
1553 SendMessage16( (*ppWnd)->hwndSelf, WM_ACTIVATEAPP,
1554 1, QUEUE_GetQueueTask( hOldActiveQueue ) );
1556 HeapFree( SystemHeap, 0, list );
1558 if (!IsWindow32(hWnd)) return 0;
1561 if (hWnd)
1563 /* walk up to the first unowned window */
1564 wndTemp = wndPtr;
1565 while (wndTemp->owner) wndTemp = wndTemp->owner;
1566 /* and set last active owned popup */
1567 wndTemp->hwndLastActive = hWnd;
1569 wIconized = HIWORD(wndTemp->dwStyle & WS_MINIMIZE);
1570 SendMessage32A( hWnd, WM_NCACTIVATE, TRUE, 0 );
1571 #if 1
1572 SendMessage32A( hWnd, WM_ACTIVATE,
1573 MAKEWPARAM( (fMouse) ? WA_CLICKACTIVE : WA_ACTIVE, wIconized),
1574 (LPARAM)hwndPrevActive );
1575 #else
1576 SendMessage16(hWnd, WM_ACTIVATE, (fMouse) ? WA_CLICKACTIVE : WA_ACTIVE,
1577 MAKELPARAM( (HWND16)hwndPrevActive, wIconized) );
1578 #endif
1580 if( !IsWindow32(hWnd) ) return 0;
1583 /* change focus if possible */
1584 if( fChangeFocus && GetFocus32() )
1585 if( WIN_GetTopParent(GetFocus32()) != hwndActive )
1586 FOCUS_SwitchFocus( GetFocus32(),
1587 (wndPtr && (wndPtr->dwStyle & WS_MINIMIZE))?
1589 hwndActive
1592 if( !hwndPrevActive && wndPtr )
1593 (*wndPtr->pDriver->pForceWindowRaise)(wndPtr);
1595 /* if active wnd is minimized redraw icon title */
1596 if( IsIconic32(hwndActive) ) WINPOS_RedrawIconTitle(hwndActive);
1598 return (hWnd == hwndActive);
1601 /*******************************************************************
1602 * WINPOS_ActivateOtherWindow
1604 * Activates window other than pWnd.
1606 BOOL32 WINPOS_ActivateOtherWindow(WND* pWnd)
1608 BOOL32 bRet = 0;
1609 WND* pWndTo = NULL;
1611 if( pWnd->hwndSelf == hwndPrevActive )
1612 hwndPrevActive = 0;
1614 if( hwndActive != pWnd->hwndSelf &&
1615 ( hwndActive || QUEUE_IsExitingQueue(pWnd->hmemTaskQ)) )
1616 return 0;
1618 if( !(pWnd->dwStyle & WS_POPUP) || !(pWnd->owner) ||
1619 !WINPOS_CanActivate((pWndTo = WIN_GetTopParentPtr(pWnd->owner))) )
1621 WND* pWndPtr = WIN_GetTopParentPtr(pWnd);
1623 pWndTo = WIN_FindWndPtr(hwndPrevActive);
1625 while( !WINPOS_CanActivate(pWndTo) )
1627 /* by now owned windows should've been taken care of */
1629 pWndTo = pWndPtr->next;
1630 pWndPtr = pWndTo;
1631 if( !pWndTo ) break;
1635 bRet = WINPOS_SetActiveWindow( pWndTo ? pWndTo->hwndSelf : 0, FALSE, TRUE );
1637 /* switch desktop queue to current active */
1638 if( pWndTo ) WIN_GetDesktop()->hmemTaskQ = pWndTo->hmemTaskQ;
1640 hwndPrevActive = 0;
1641 return bRet;
1644 /*******************************************************************
1645 * WINPOS_ChangeActiveWindow
1648 BOOL32 WINPOS_ChangeActiveWindow( HWND32 hWnd, BOOL32 mouseMsg )
1650 WND *wndPtr = WIN_FindWndPtr(hWnd);
1652 if (!hWnd) return WINPOS_SetActiveWindow( 0, mouseMsg, TRUE );
1654 if( !wndPtr ) return FALSE;
1656 /* child windows get WM_CHILDACTIVATE message */
1657 if( (wndPtr->dwStyle & (WS_CHILD | WS_POPUP)) == WS_CHILD )
1658 return SendMessage32A(hWnd, WM_CHILDACTIVATE, 0, 0L);
1660 /* owned popups imply owner activation - not sure */
1661 if ((wndPtr->dwStyle & WS_POPUP) && wndPtr->owner &&
1662 (wndPtr->owner->dwStyle & WS_VISIBLE ) &&
1663 !(wndPtr->owner->dwStyle & WS_DISABLED ))
1665 if (!(wndPtr = wndPtr->owner)) return FALSE;
1666 hWnd = wndPtr->hwndSelf;
1669 if( hWnd == hwndActive ) return FALSE;
1671 if( !WINPOS_SetActiveWindow(hWnd ,mouseMsg ,TRUE) )
1672 return FALSE;
1674 /* switch desktop queue to current active */
1675 if( wndPtr->parent == WIN_GetDesktop())
1676 WIN_GetDesktop()->hmemTaskQ = wndPtr->hmemTaskQ;
1678 return TRUE;
1682 /***********************************************************************
1683 * WINPOS_SendNCCalcSize
1685 * Send a WM_NCCALCSIZE message to a window.
1686 * All parameters are read-only except newClientRect.
1687 * oldWindowRect, oldClientRect and winpos must be non-NULL only
1688 * when calcValidRect is TRUE.
1690 LONG WINPOS_SendNCCalcSize( HWND32 hwnd, BOOL32 calcValidRect,
1691 RECT32 *newWindowRect, RECT32 *oldWindowRect,
1692 RECT32 *oldClientRect, WINDOWPOS32 *winpos,
1693 RECT32 *newClientRect )
1695 NCCALCSIZE_PARAMS32 params;
1696 WINDOWPOS32 winposCopy;
1697 LONG result;
1699 params.rgrc[0] = *newWindowRect;
1700 if (calcValidRect)
1702 winposCopy = *winpos;
1703 params.rgrc[1] = *oldWindowRect;
1704 params.rgrc[2] = *oldClientRect;
1705 params.lppos = &winposCopy;
1707 result = SendMessage32A( hwnd, WM_NCCALCSIZE, calcValidRect,
1708 (LPARAM)&params );
1709 TRACE(win, "%d,%d-%d,%d\n",
1710 params.rgrc[0].left, params.rgrc[0].top,
1711 params.rgrc[0].right, params.rgrc[0].bottom );
1712 *newClientRect = params.rgrc[0];
1713 return result;
1717 /***********************************************************************
1718 * WINPOS_HandleWindowPosChanging16
1720 * Default handling for a WM_WINDOWPOSCHANGING. Called from DefWindowProc().
1722 LONG WINPOS_HandleWindowPosChanging16( WND *wndPtr, WINDOWPOS16 *winpos )
1724 POINT32 maxSize, minTrack;
1725 if (winpos->flags & SWP_NOSIZE) return 0;
1726 if ((wndPtr->dwStyle & WS_THICKFRAME) ||
1727 ((wndPtr->dwStyle & (WS_POPUP | WS_CHILD)) == 0))
1729 WINPOS_GetMinMaxInfo( wndPtr, &maxSize, NULL, &minTrack, NULL );
1730 if (maxSize.x < winpos->cx) winpos->cx = maxSize.x;
1731 if (maxSize.y < winpos->cy) winpos->cy = maxSize.y;
1732 if (!(wndPtr->dwStyle & WS_MINIMIZE))
1734 if (winpos->cx < minTrack.x ) winpos->cx = minTrack.x;
1735 if (winpos->cy < minTrack.y ) winpos->cy = minTrack.y;
1738 return 0;
1742 /***********************************************************************
1743 * WINPOS_HandleWindowPosChanging32
1745 * Default handling for a WM_WINDOWPOSCHANGING. Called from DefWindowProc().
1747 LONG WINPOS_HandleWindowPosChanging32( WND *wndPtr, WINDOWPOS32 *winpos )
1749 POINT32 maxSize;
1750 if (winpos->flags & SWP_NOSIZE) return 0;
1751 if ((wndPtr->dwStyle & WS_THICKFRAME) ||
1752 ((wndPtr->dwStyle & (WS_POPUP | WS_CHILD)) == 0))
1754 WINPOS_GetMinMaxInfo( wndPtr, &maxSize, NULL, NULL, NULL );
1755 winpos->cx = MIN( winpos->cx, maxSize.x );
1756 winpos->cy = MIN( winpos->cy, maxSize.y );
1758 return 0;
1762 /***********************************************************************
1763 * WINPOS_MoveWindowZOrder
1765 * Move a window in Z order, invalidating everything that needs it.
1766 * Only necessary for windows without associated X window.
1768 static void WINPOS_MoveWindowZOrder( HWND32 hwnd, HWND32 hwndAfter )
1770 BOOL32 movingUp;
1771 WND *pWndAfter, *pWndCur, *wndPtr = WIN_FindWndPtr( hwnd );
1773 /* We have two possible cases:
1774 * - The window is moving up: we have to invalidate all areas
1775 * of the window that were covered by other windows
1776 * - The window is moving down: we have to invalidate areas
1777 * of other windows covered by this one.
1780 if (hwndAfter == HWND_TOP)
1782 movingUp = TRUE;
1784 else if (hwndAfter == HWND_BOTTOM)
1786 if (!wndPtr->next) return; /* Already at the bottom */
1787 movingUp = FALSE;
1789 else
1791 if (!(pWndAfter = WIN_FindWndPtr( hwndAfter ))) return;
1792 if (wndPtr->next == pWndAfter) return; /* Already placed right */
1794 /* Determine which window we encounter first in Z-order */
1795 pWndCur = wndPtr->parent->child;
1796 while ((pWndCur != wndPtr) && (pWndCur != pWndAfter))
1797 pWndCur = pWndCur->next;
1798 movingUp = (pWndCur == pWndAfter);
1801 if (movingUp)
1803 WND *pWndPrevAfter = wndPtr->next;
1804 WIN_UnlinkWindow( hwnd );
1805 WIN_LinkWindow( hwnd, hwndAfter );
1806 pWndCur = wndPtr->next;
1807 while (pWndCur != pWndPrevAfter)
1809 RECT32 rect = { pWndCur->rectWindow.left,
1810 pWndCur->rectWindow.top,
1811 pWndCur->rectWindow.right,
1812 pWndCur->rectWindow.bottom };
1813 OffsetRect32( &rect, -wndPtr->rectClient.left,
1814 -wndPtr->rectClient.top );
1815 PAINT_RedrawWindow( hwnd, &rect, 0, RDW_INVALIDATE | RDW_ALLCHILDREN |
1816 RDW_FRAME | RDW_ERASE, 0 );
1817 pWndCur = pWndCur->next;
1820 else /* Moving down */
1822 pWndCur = wndPtr->next;
1823 WIN_UnlinkWindow( hwnd );
1824 WIN_LinkWindow( hwnd, hwndAfter );
1825 while (pWndCur != wndPtr)
1827 RECT32 rect = { pWndCur->rectWindow.left,
1828 pWndCur->rectWindow.top,
1829 pWndCur->rectWindow.right,
1830 pWndCur->rectWindow.bottom };
1831 OffsetRect32( &rect, -pWndCur->rectClient.left,
1832 -pWndCur->rectClient.top );
1833 PAINT_RedrawWindow( pWndCur->hwndSelf, &rect, 0, RDW_INVALIDATE |
1834 RDW_ALLCHILDREN | RDW_FRAME | RDW_ERASE, 0 );
1835 pWndCur = pWndCur->next;
1840 /***********************************************************************
1841 * WINPOS_ReorderOwnedPopups
1843 * fix Z order taking into account owned popups -
1844 * basically we need to maintain them above the window that owns them
1846 HWND32 WINPOS_ReorderOwnedPopups(HWND32 hwndInsertAfter,WND* wndPtr,WORD flags)
1848 WND* w = WIN_GetDesktop()->child;
1850 if( wndPtr->dwStyle & WS_POPUP && wndPtr->owner )
1852 /* implement "local z-order" between the top and owner window */
1854 HWND32 hwndLocalPrev = HWND_TOP;
1856 if( hwndInsertAfter != HWND_TOP )
1858 while( w != wndPtr->owner )
1860 if (w != wndPtr) hwndLocalPrev = w->hwndSelf;
1861 if( hwndLocalPrev == hwndInsertAfter ) break;
1862 w = w->next;
1864 hwndInsertAfter = hwndLocalPrev;
1868 else if( wndPtr->dwStyle & WS_CHILD ) return hwndInsertAfter;
1870 w = WIN_GetDesktop()->child;
1871 while( w )
1873 if( w == wndPtr ) break;
1875 if( w->dwStyle & WS_POPUP && w->owner == wndPtr )
1877 SetWindowPos32(w->hwndSelf, hwndInsertAfter, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE |
1878 SWP_NOACTIVATE | SWP_NOSENDCHANGING | SWP_DEFERERASE);
1879 hwndInsertAfter = w->hwndSelf;
1881 w = w->next;
1884 return hwndInsertAfter;
1887 /***********************************************************************
1888 * WINPOS_SizeMoveClean
1890 * Make window look nice without excessive repainting
1892 * the pain:
1894 * visible regions are in window coordinates
1895 * update regions are in window client coordinates
1896 * client and window rectangles are in parent client coordinates
1898 * FIXME: Move visible and update regions to the same coordinate system
1899 * (either parent client or window). This is a lot of work though.
1901 static UINT32 WINPOS_SizeMoveClean( WND* Wnd, HRGN32 oldVisRgn,
1902 LPRECT32 lpOldWndRect,
1903 LPRECT32 lpOldClientRect, UINT32 uFlags )
1905 HRGN32 newVisRgn = DCE_GetVisRgn(Wnd->hwndSelf,DCX_WINDOW | DCX_CLIPSIBLINGS);
1906 HRGN32 dirtyRgn = CreateRectRgn32(0,0,0,0);
1907 int other, my;
1909 TRACE(win,"cleaning up...new wnd=(%i %i-%i %i) old wnd=(%i %i-%i %i)\n",
1910 Wnd->rectWindow.left, Wnd->rectWindow.top,
1911 Wnd->rectWindow.right, Wnd->rectWindow.bottom,
1912 lpOldWndRect->left, lpOldWndRect->top,
1913 lpOldWndRect->right, lpOldWndRect->bottom);
1914 TRACE(win,"\tnew client=(%i %i-%i %i) old client=(%i %i-%i %i)\n",
1915 Wnd->rectClient.left, Wnd->rectClient.top,
1916 Wnd->rectClient.right, Wnd->rectClient.bottom,
1917 lpOldClientRect->left, lpOldClientRect->top,
1918 lpOldClientRect->right,lpOldClientRect->bottom );
1920 if( (lpOldWndRect->right - lpOldWndRect->left) != (Wnd->rectWindow.right - Wnd->rectWindow.left) ||
1921 (lpOldWndRect->bottom - lpOldWndRect->top) != (Wnd->rectWindow.bottom - Wnd->rectWindow.top) )
1922 uFlags |= SMC_DRAWFRAME;
1924 CombineRgn32( dirtyRgn, newVisRgn, 0, RGN_COPY);
1926 if( !(uFlags & SMC_NOCOPY) )
1927 CombineRgn32( newVisRgn, newVisRgn, oldVisRgn, RGN_AND );
1929 /* map regions to the parent client area */
1931 OffsetRgn32( dirtyRgn, Wnd->rectWindow.left, Wnd->rectWindow.top );
1932 OffsetRgn32( oldVisRgn, lpOldWndRect->left, lpOldWndRect->top );
1934 /* compute invalidated region outside Wnd - (in client coordinates of the parent window) */
1936 other = CombineRgn32(dirtyRgn, oldVisRgn, dirtyRgn, RGN_DIFF);
1938 /* map visible region to the Wnd client area */
1940 OffsetRgn32( newVisRgn, Wnd->rectWindow.left - Wnd->rectClient.left,
1941 Wnd->rectWindow.top - Wnd->rectClient.top );
1943 /* substract previously invalidated region from the Wnd visible region */
1945 my = (Wnd->hrgnUpdate > 1) ? CombineRgn32( newVisRgn, newVisRgn,
1946 Wnd->hrgnUpdate, RGN_DIFF)
1947 : COMPLEXREGION;
1949 if( uFlags & SMC_NOCOPY ) /* invalidate Wnd visible region */
1951 if (my != NULLREGION)
1952 PAINT_RedrawWindow( Wnd->hwndSelf, NULL, newVisRgn, RDW_INVALIDATE |
1953 RDW_FRAME | RDW_ALLCHILDREN | RDW_ERASE, RDW_C_USEHRGN );
1954 else if(uFlags & SMC_DRAWFRAME)
1955 Wnd->flags |= WIN_NEEDS_NCPAINT;
1957 else /* bitblt old client area */
1959 HDC32 hDC;
1960 int update;
1961 HRGN32 updateRgn;
1962 int xfrom,yfrom,xto,yto,width,height;
1964 if( uFlags & SMC_DRAWFRAME )
1966 /* copy only client area, frame will be redrawn anyway */
1968 xfrom = lpOldClientRect->left; yfrom = lpOldClientRect->top;
1969 xto = Wnd->rectClient.left; yto = Wnd->rectClient.top;
1970 width = lpOldClientRect->right - xfrom; height = lpOldClientRect->bottom - yfrom;
1971 updateRgn = CreateRectRgn32( 0, 0, width, height );
1972 CombineRgn32( newVisRgn, newVisRgn, updateRgn, RGN_AND );
1973 SetRectRgn32( updateRgn, 0, 0, Wnd->rectClient.right - xto,
1974 Wnd->rectClient.bottom - yto );
1976 else
1978 xfrom = lpOldWndRect->left; yfrom = lpOldWndRect->top;
1979 xto = Wnd->rectWindow.left; yto = Wnd->rectWindow.top;
1980 width = lpOldWndRect->right - xfrom; height = lpOldWndRect->bottom - yfrom;
1981 updateRgn = CreateRectRgn32( xto - Wnd->rectClient.left,
1982 yto - Wnd->rectClient.top,
1983 Wnd->rectWindow.right - Wnd->rectClient.left,
1984 Wnd->rectWindow.bottom - Wnd->rectClient.top );
1987 CombineRgn32( newVisRgn, newVisRgn, updateRgn, RGN_AND );
1989 /* substract new visRgn from target rect to get a region that won't be copied */
1991 update = CombineRgn32( updateRgn, updateRgn, newVisRgn, RGN_DIFF );
1993 /* Blt valid bits using parent window DC */
1995 if( my != NULLREGION && (xfrom != xto || yfrom != yto) )
1998 /* compute clipping region in parent client coordinates */
2000 OffsetRgn32( newVisRgn, Wnd->rectClient.left, Wnd->rectClient.top );
2001 CombineRgn32( oldVisRgn, oldVisRgn, newVisRgn, RGN_OR );
2003 hDC = GetDCEx32( Wnd->parent->hwndSelf, oldVisRgn,
2004 DCX_KEEPCLIPRGN | DCX_INTERSECTRGN |
2005 DCX_CACHE | DCX_CLIPSIBLINGS);
2007 BitBlt32( hDC, xto, yto, width, height, hDC, xfrom, yfrom, SRCCOPY );
2008 ReleaseDC32( Wnd->parent->hwndSelf, hDC);
2011 if( update != NULLREGION )
2012 PAINT_RedrawWindow( Wnd->hwndSelf, NULL, updateRgn, RDW_INVALIDATE |
2013 RDW_FRAME | RDW_ALLCHILDREN | RDW_ERASE, RDW_C_USEHRGN );
2014 else if( uFlags & SMC_DRAWFRAME ) Wnd->flags |= WIN_NEEDS_NCPAINT;
2015 DeleteObject32( updateRgn );
2018 /* erase uncovered areas */
2020 if( !(uFlags & SMC_NOPARENTERASE) && (other != NULLREGION ) )
2021 PAINT_RedrawWindow( Wnd->parent->hwndSelf, NULL, dirtyRgn,
2022 RDW_INVALIDATE | RDW_ALLCHILDREN | RDW_ERASE, RDW_C_USEHRGN );
2023 DeleteObject32(dirtyRgn);
2024 DeleteObject32(newVisRgn);
2025 return uFlags;
2028 /***********************************************************************
2029 * SetWindowPos (USER.232)
2031 BOOL16 WINAPI SetWindowPos16( HWND16 hwnd, HWND16 hwndInsertAfter,
2032 INT16 x, INT16 y, INT16 cx, INT16 cy, WORD flags)
2034 return SetWindowPos32(hwnd,(INT32)(INT16)hwndInsertAfter,x,y,cx,cy,flags);
2037 /***********************************************************************
2038 * SetWindowPos (USER32.520)
2040 BOOL32 WINAPI SetWindowPos32( HWND32 hwnd, HWND32 hwndInsertAfter,
2041 INT32 x, INT32 y, INT32 cx, INT32 cy, WORD flags)
2043 WINDOWPOS32 winpos;
2044 WND * wndPtr;
2045 RECT32 newWindowRect, newClientRect, oldWindowRect;
2046 HRGN32 visRgn = 0;
2047 HWND32 tempInsertAfter= 0;
2048 int result = 0;
2049 UINT32 uFlags = 0;
2050 BOOL32 resync = FALSE;
2052 TRACE(win,"hwnd %04x, (%i,%i)-(%i,%i) flags %08x\n",
2053 hwnd, x, y, x+cx, y+cy, flags);
2054 /* Check window handle */
2056 if (hwnd == GetDesktopWindow32()) return FALSE;
2057 if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return FALSE;
2059 if(wndPtr->dwStyle & WS_VISIBLE)
2060 flags &= ~SWP_SHOWWINDOW;
2061 else
2063 uFlags |= SMC_NOPARENTERASE;
2064 flags &= ~SWP_HIDEWINDOW;
2065 if (!(flags & SWP_SHOWWINDOW)) flags |= SWP_NOREDRAW;
2068 /* Check for windows that may not be resized
2069 FIXME: this should be done only for Windows 3.0 programs
2070 if (flags & (SWP_SHOWWINDOW | SWP_HIDEWINDOW ) )
2071 flags |= SWP_NOSIZE | SWP_NOMOVE;
2073 /* Check dimensions */
2075 if (cx <= 0) cx = 1;
2076 if (cy <= 0) cy = 1;
2078 /* Check flags */
2080 if (hwnd == hwndActive) flags |= SWP_NOACTIVATE; /* Already active */
2081 if ((wndPtr->rectWindow.right - wndPtr->rectWindow.left == cx) &&
2082 (wndPtr->rectWindow.bottom - wndPtr->rectWindow.top == cy))
2083 flags |= SWP_NOSIZE; /* Already the right size */
2084 if ((wndPtr->rectWindow.left == x) && (wndPtr->rectWindow.top == y))
2085 flags |= SWP_NOMOVE; /* Already the right position */
2087 /* Check hwndInsertAfter */
2089 if (!(flags & (SWP_NOZORDER | SWP_NOACTIVATE)))
2091 /* Ignore TOPMOST flags when activating a window */
2092 /* _and_ moving it in Z order. */
2093 if ((hwndInsertAfter == HWND_TOPMOST) ||
2094 (hwndInsertAfter == HWND_NOTOPMOST))
2095 hwndInsertAfter = HWND_TOP;
2097 /* TOPMOST not supported yet */
2098 if ((hwndInsertAfter == HWND_TOPMOST) ||
2099 (hwndInsertAfter == HWND_NOTOPMOST)) hwndInsertAfter = HWND_TOP;
2101 /* hwndInsertAfter must be a sibling of the window */
2102 if ((hwndInsertAfter != HWND_TOP) && (hwndInsertAfter != HWND_BOTTOM))
2104 WND* wnd = WIN_FindWndPtr(hwndInsertAfter);
2106 if( wndPtr ) {
2107 if( wnd->parent != wndPtr->parent ) return FALSE;
2108 if( wnd->next == wndPtr ) flags |= SWP_NOZORDER;
2111 else if (!(wndPtr->window))
2113 /* FIXME: the following optimization is no good for "X-ed" windows */
2114 if (hwndInsertAfter == HWND_TOP)
2115 flags |= ( wndPtr->parent->child == wndPtr)? SWP_NOZORDER: 0;
2116 else /* HWND_BOTTOM */
2117 flags |= ( wndPtr->next )? 0: SWP_NOZORDER;
2120 /* Fill the WINDOWPOS structure */
2122 winpos.hwnd = hwnd;
2123 winpos.hwndInsertAfter = hwndInsertAfter;
2124 winpos.x = x;
2125 winpos.y = y;
2126 winpos.cx = cx;
2127 winpos.cy = cy;
2128 winpos.flags = flags;
2130 /* Send WM_WINDOWPOSCHANGING message */
2132 if (!(winpos.flags & SWP_NOSENDCHANGING))
2133 SendMessage32A( hwnd, WM_WINDOWPOSCHANGING, 0, (LPARAM)&winpos );
2135 /* Calculate new position and size */
2137 newWindowRect = wndPtr->rectWindow;
2138 newClientRect = (wndPtr->dwStyle & WS_MINIMIZE) ? wndPtr->rectWindow
2139 : wndPtr->rectClient;
2141 if (!(winpos.flags & SWP_NOSIZE))
2143 newWindowRect.right = newWindowRect.left + winpos.cx;
2144 newWindowRect.bottom = newWindowRect.top + winpos.cy;
2146 if (!(winpos.flags & SWP_NOMOVE))
2148 newWindowRect.left = winpos.x;
2149 newWindowRect.top = winpos.y;
2150 newWindowRect.right += winpos.x - wndPtr->rectWindow.left;
2151 newWindowRect.bottom += winpos.y - wndPtr->rectWindow.top;
2153 OffsetRect32( &newClientRect, winpos.x - wndPtr->rectWindow.left,
2154 winpos.y - wndPtr->rectWindow.top );
2157 winpos.flags |= SWP_NOCLIENTMOVE | SWP_NOCLIENTSIZE;
2159 /* Reposition window in Z order */
2161 if (!(winpos.flags & SWP_NOZORDER))
2163 /* reorder owned popups if hwnd is top-level window
2165 if( wndPtr->parent == WIN_GetDesktop() )
2166 hwndInsertAfter = WINPOS_ReorderOwnedPopups( hwndInsertAfter,
2167 wndPtr, winpos.flags );
2169 if (wndPtr->window)
2171 WIN_UnlinkWindow( winpos.hwnd );
2172 WIN_LinkWindow( winpos.hwnd, hwndInsertAfter );
2174 else WINPOS_MoveWindowZOrder( winpos.hwnd, hwndInsertAfter );
2177 if ( !wndPtr->window && !(winpos.flags & SWP_NOREDRAW) &&
2178 ((winpos.flags & (SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED))
2179 != (SWP_NOMOVE | SWP_NOSIZE)) )
2180 visRgn = DCE_GetVisRgn(hwnd, DCX_WINDOW | DCX_CLIPSIBLINGS);
2183 /* Send WM_NCCALCSIZE message to get new client area */
2184 if( (winpos.flags & (SWP_FRAMECHANGED | SWP_NOSIZE)) != SWP_NOSIZE )
2186 result = WINPOS_SendNCCalcSize( winpos.hwnd, TRUE, &newWindowRect,
2187 &wndPtr->rectWindow, &wndPtr->rectClient,
2188 &winpos, &newClientRect );
2190 /* FIXME: WVR_ALIGNxxx */
2192 if( newClientRect.left != wndPtr->rectClient.left ||
2193 newClientRect.top != wndPtr->rectClient.top )
2194 winpos.flags &= ~SWP_NOCLIENTMOVE;
2196 if( (newClientRect.right - newClientRect.left !=
2197 wndPtr->rectClient.right - wndPtr->rectClient.left) ||
2198 (newClientRect.bottom - newClientRect.top !=
2199 wndPtr->rectClient.bottom - wndPtr->rectClient.top) )
2200 winpos.flags &= ~SWP_NOCLIENTSIZE;
2202 else
2203 if( !(flags & SWP_NOMOVE) && (newClientRect.left != wndPtr->rectClient.left ||
2204 newClientRect.top != wndPtr->rectClient.top) )
2205 winpos.flags &= ~SWP_NOCLIENTMOVE;
2207 /* Update active DCEs
2208 * TODO: Optimize conditions that trigger DCE update.
2211 if( (((winpos.flags & SWP_AGG_NOPOSCHANGE) != SWP_AGG_NOPOSCHANGE) &&
2212 wndPtr->dwStyle & WS_VISIBLE) ||
2213 (flags & (SWP_HIDEWINDOW | SWP_SHOWWINDOW)) )
2215 RECT32 rect;
2217 UnionRect32(&rect, &newWindowRect, &wndPtr->rectWindow);
2218 DCE_InvalidateDCE(wndPtr, &rect);
2221 /* change geometry */
2223 oldWindowRect = wndPtr->rectWindow;
2225 if (wndPtr->window)
2227 RECT32 oldClientRect = wndPtr->rectClient;
2229 tempInsertAfter = winpos.hwndInsertAfter;
2231 winpos.hwndInsertAfter = hwndInsertAfter;
2233 /* postpone geometry change */
2235 if( !(flags & (SWP_SHOWWINDOW | SWP_HIDEWINDOW)) )
2237 wndPtr->pDriver->pSetWindowPos(wndPtr, &winpos, TRUE);
2238 winpos.hwndInsertAfter = tempInsertAfter;
2240 else uFlags |= SMC_SETXPOS;
2242 wndPtr->rectWindow = newWindowRect;
2243 wndPtr->rectClient = newClientRect;
2245 if( !(flags & (SWP_SHOWWINDOW | SWP_HIDEWINDOW)) )
2247 if( (oldClientRect.left - oldWindowRect.left !=
2248 newClientRect.left - newWindowRect.left) ||
2249 (oldClientRect.top - oldWindowRect.top !=
2250 newClientRect.top - newWindowRect.top) ||
2251 (winpos.flags & SWP_NOCOPYBITS) )
2253 /* if the client area moved as a result of WM_NCCALCSIZE returning
2254 * obscure WVR_ALIGNxxx flags then we simply redraw the whole thing
2256 * TODO: use WINPOS_SizeMoveClean() if there is no SWP_NOCOPYBITS
2259 PAINT_RedrawWindow( wndPtr->hwndSelf, NULL, 0, RDW_INVALIDATE |
2260 RDW_ALLCHILDREN | RDW_FRAME | RDW_ERASE, 0 );
2262 else
2263 if( winpos.flags & SWP_FRAMECHANGED )
2265 WORD wErase = 0;
2266 RECT32 rect;
2268 if( newClientRect.right > oldClientRect.right ) /* redraw exposed client area on the right */
2270 rect.top = 0; rect.bottom = newClientRect.bottom - newClientRect.top;
2271 rect.left = oldClientRect.right - newClientRect.left;
2272 rect.right = newClientRect.right - newClientRect.left;
2273 wErase = 1;
2274 PAINT_RedrawWindow( wndPtr->hwndSelf, &rect, 0,
2275 RDW_INVALIDATE | RDW_FRAME | RDW_ERASE | RDW_ERASENOW | RDW_ALLCHILDREN, 0 );
2277 if( newClientRect.bottom > oldClientRect.bottom ) /* redraw exposed client area on the bottom */
2279 rect.left = 0; rect.right = ((wErase)?oldClientRect.right:newClientRect.right) - newClientRect.left;
2280 rect.top = oldClientRect.bottom - newClientRect.top;
2281 rect.bottom = newClientRect.bottom - newClientRect.top;
2282 wErase = 1;
2283 PAINT_RedrawWindow( wndPtr->hwndSelf, &rect, 0,
2284 RDW_INVALIDATE | RDW_FRAME | RDW_ERASE | RDW_ERASENOW | RDW_ALLCHILDREN, 0 );
2286 if( !wErase ) /* just update the nonclient area */
2287 wndPtr->flags |= WIN_NEEDS_NCPAINT;
2290 uFlags |= SMC_NOPARENTERASE; /* X windows do not have eraseable parents */
2292 else /* not an X window */
2294 RECT32 oldClientRect = wndPtr->rectClient;
2296 wndPtr->rectWindow = newWindowRect;
2297 wndPtr->rectClient = newClientRect;
2299 if( oldClientRect.bottom - oldClientRect.top ==
2300 newClientRect.bottom - newClientRect.top ) result &= ~WVR_VREDRAW;
2302 if( oldClientRect.right - oldClientRect.left ==
2303 newClientRect.right - newClientRect.left ) result &= ~WVR_HREDRAW;
2305 if( !(flags & (SWP_NOREDRAW | SWP_HIDEWINDOW | SWP_SHOWWINDOW)) )
2307 uFlags |= ((winpos.flags & SWP_NOCOPYBITS) ||
2308 (result >= WVR_HREDRAW && result < WVR_VALIDRECTS)) ? SMC_NOCOPY : 0;
2309 uFlags |= (winpos.flags & SWP_FRAMECHANGED) ? SMC_DRAWFRAME : 0;
2311 if( (winpos.flags & SWP_AGG_NOGEOMETRYCHANGE) != SWP_AGG_NOGEOMETRYCHANGE )
2312 uFlags = WINPOS_SizeMoveClean(wndPtr, visRgn, &oldWindowRect,
2313 &oldClientRect, uFlags);
2314 else
2316 /* adjust the frame and do not erase the parent */
2318 if( winpos.flags & SWP_FRAMECHANGED ) wndPtr->flags |= WIN_NEEDS_NCPAINT;
2319 if( winpos.flags & SWP_NOZORDER ) uFlags |= SMC_NOPARENTERASE;
2322 DeleteObject32(visRgn);
2325 if (flags & SWP_SHOWWINDOW)
2327 wndPtr->dwStyle |= WS_VISIBLE;
2328 if (wndPtr->window)
2330 HWND32 focus, curr;
2332 wndPtr->pDriver->pSetWindowPos(wndPtr, &winpos, uFlags & SMC_SETXPOS );
2333 if( uFlags & SMC_SETXPOS )
2335 winpos.hwndInsertAfter = tempInsertAfter;
2338 if (wndPtr->flags & WIN_MANAGED) resync = TRUE;
2340 /* If focus was set to an unmapped window, reset X focus now */
2341 focus = curr = GetFocus32();
2342 while (curr) {
2343 if (curr == hwnd) {
2344 SetFocus32( 0 );
2345 SetFocus32( focus );
2346 break;
2348 curr = GetParent32(curr);
2351 else
2353 if (!(flags & SWP_NOREDRAW))
2354 PAINT_RedrawWindow( winpos.hwnd, NULL, 0,
2355 RDW_INVALIDATE | RDW_ALLCHILDREN |
2356 RDW_FRAME | RDW_ERASENOW | RDW_ERASE, 0 );
2359 else if (flags & SWP_HIDEWINDOW)
2361 wndPtr->dwStyle &= ~WS_VISIBLE;
2363 if (wndPtr->window)
2365 wndPtr->pDriver->pSetWindowPos(wndPtr, &winpos, uFlags & SMC_SETXPOS );
2366 if( uFlags & SMC_SETXPOS )
2368 winpos.hwndInsertAfter = tempInsertAfter;
2371 else
2373 if (!(flags & SWP_NOREDRAW))
2374 PAINT_RedrawWindow( wndPtr->parent->hwndSelf, &oldWindowRect,
2375 0, RDW_INVALIDATE | RDW_ALLCHILDREN |
2376 RDW_ERASE | RDW_ERASENOW, 0 );
2377 uFlags |= SMC_NOPARENTERASE;
2380 if ((winpos.hwnd == GetFocus32()) ||
2381 IsChild32( winpos.hwnd, GetFocus32()))
2383 /* Revert focus to parent */
2384 SetFocus32( GetParent32(winpos.hwnd) );
2386 if (hwnd == CARET_GetHwnd()) DestroyCaret32();
2388 if (winpos.hwnd == hwndActive)
2389 WINPOS_ActivateOtherWindow( wndPtr );
2392 /* Activate the window */
2394 if (!(flags & SWP_NOACTIVATE))
2395 WINPOS_ChangeActiveWindow( winpos.hwnd, FALSE );
2397 /* Repaint the window */
2399 if (wndPtr->window) EVENT_Synchronize(); /* Wait for all expose events */
2401 if (!GetCapture32())
2402 EVENT_DummyMotionNotify(); /* Simulate a mouse event to set the cursor */
2404 if (!(flags & SWP_DEFERERASE) && !(uFlags & SMC_NOPARENTERASE) )
2405 PAINT_RedrawWindow( wndPtr->parent->hwndSelf, NULL, 0, RDW_ALLCHILDREN | RDW_ERASENOW, 0 );
2406 else if( wndPtr->parent == WIN_GetDesktop() && wndPtr->parent->flags & WIN_NEEDS_ERASEBKGND )
2407 PAINT_RedrawWindow( wndPtr->parent->hwndSelf, NULL, 0, RDW_NOCHILDREN | RDW_ERASENOW, 0 );
2409 /* And last, send the WM_WINDOWPOSCHANGED message */
2411 TRACE(win,"\tstatus flags = %04x\n", winpos.flags & SWP_AGG_STATUSFLAGS);
2413 if ( resync ||
2414 (((winpos.flags & SWP_AGG_STATUSFLAGS) != SWP_AGG_NOPOSCHANGE) &&
2415 !(winpos.flags & SWP_NOSENDCHANGING)) )
2417 SendMessage32A( winpos.hwnd, WM_WINDOWPOSCHANGED, 0, (LPARAM)&winpos );
2418 if (resync) EVENT_Synchronize ();
2421 return TRUE;
2425 /***********************************************************************
2426 * BeginDeferWindowPos16 (USER.259)
2428 HDWP16 WINAPI BeginDeferWindowPos16( INT16 count )
2430 return BeginDeferWindowPos32( count );
2434 /***********************************************************************
2435 * BeginDeferWindowPos32 (USER32.9)
2437 HDWP32 WINAPI BeginDeferWindowPos32( INT32 count )
2439 HDWP32 handle;
2440 DWP *pDWP;
2442 if (count <= 0) return 0;
2443 handle = USER_HEAP_ALLOC( sizeof(DWP) + (count-1)*sizeof(WINDOWPOS32) );
2444 if (!handle) return 0;
2445 pDWP = (DWP *) USER_HEAP_LIN_ADDR( handle );
2446 pDWP->actualCount = 0;
2447 pDWP->suggestedCount = count;
2448 pDWP->valid = TRUE;
2449 pDWP->wMagic = DWP_MAGIC;
2450 pDWP->hwndParent = 0;
2451 return handle;
2455 /***********************************************************************
2456 * DeferWindowPos16 (USER.260)
2458 HDWP16 WINAPI DeferWindowPos16( HDWP16 hdwp, HWND16 hwnd, HWND16 hwndAfter,
2459 INT16 x, INT16 y, INT16 cx, INT16 cy,
2460 UINT16 flags )
2462 return DeferWindowPos32( hdwp, hwnd, (INT32)(INT16)hwndAfter,
2463 x, y, cx, cy, flags );
2467 /***********************************************************************
2468 * DeferWindowPos32 (USER32.128)
2470 HDWP32 WINAPI DeferWindowPos32( HDWP32 hdwp, HWND32 hwnd, HWND32 hwndAfter,
2471 INT32 x, INT32 y, INT32 cx, INT32 cy,
2472 UINT32 flags )
2474 DWP *pDWP;
2475 int i;
2476 HDWP32 newhdwp = hdwp;
2477 /* HWND32 parent; */
2478 WND *pWnd;
2480 pDWP = (DWP *) USER_HEAP_LIN_ADDR( hdwp );
2481 if (!pDWP) return 0;
2482 if (hwnd == GetDesktopWindow32()) return 0;
2484 if (!(pWnd=WIN_FindWndPtr( hwnd ))) {
2485 USER_HEAP_FREE( hdwp );
2486 return 0;
2489 /* Numega Bounds Checker Demo dislikes the following code.
2490 In fact, I've not been able to find any "same parent" requirement in any docu
2491 [AM 980509]
2493 #if 0
2494 /* All the windows of a DeferWindowPos() must have the same parent */
2495 parent = pWnd->parent->hwndSelf;
2496 if (pDWP->actualCount == 0) pDWP->hwndParent = parent;
2497 else if (parent != pDWP->hwndParent)
2499 USER_HEAP_FREE( hdwp );
2500 return 0;
2502 #endif
2504 for (i = 0; i < pDWP->actualCount; i++)
2506 if (pDWP->winPos[i].hwnd == hwnd)
2508 /* Merge with the other changes */
2509 if (!(flags & SWP_NOZORDER))
2511 pDWP->winPos[i].hwndInsertAfter = hwndAfter;
2513 if (!(flags & SWP_NOMOVE))
2515 pDWP->winPos[i].x = x;
2516 pDWP->winPos[i].y = y;
2518 if (!(flags & SWP_NOSIZE))
2520 pDWP->winPos[i].cx = cx;
2521 pDWP->winPos[i].cy = cy;
2523 pDWP->winPos[i].flags &= flags | ~(SWP_NOSIZE | SWP_NOMOVE |
2524 SWP_NOZORDER | SWP_NOREDRAW |
2525 SWP_NOACTIVATE | SWP_NOCOPYBITS|
2526 SWP_NOOWNERZORDER);
2527 pDWP->winPos[i].flags |= flags & (SWP_SHOWWINDOW | SWP_HIDEWINDOW |
2528 SWP_FRAMECHANGED);
2529 return hdwp;
2532 if (pDWP->actualCount >= pDWP->suggestedCount)
2534 newhdwp = USER_HEAP_REALLOC( hdwp,
2535 sizeof(DWP) + pDWP->suggestedCount*sizeof(WINDOWPOS32) );
2536 if (!newhdwp) return 0;
2537 pDWP = (DWP *) USER_HEAP_LIN_ADDR( newhdwp );
2538 pDWP->suggestedCount++;
2540 pDWP->winPos[pDWP->actualCount].hwnd = hwnd;
2541 pDWP->winPos[pDWP->actualCount].hwndInsertAfter = hwndAfter;
2542 pDWP->winPos[pDWP->actualCount].x = x;
2543 pDWP->winPos[pDWP->actualCount].y = y;
2544 pDWP->winPos[pDWP->actualCount].cx = cx;
2545 pDWP->winPos[pDWP->actualCount].cy = cy;
2546 pDWP->winPos[pDWP->actualCount].flags = flags;
2547 pDWP->actualCount++;
2548 return newhdwp;
2552 /***********************************************************************
2553 * EndDeferWindowPos16 (USER.261)
2555 BOOL16 WINAPI EndDeferWindowPos16( HDWP16 hdwp )
2557 return EndDeferWindowPos32( hdwp );
2561 /***********************************************************************
2562 * EndDeferWindowPos32 (USER32.173)
2564 BOOL32 WINAPI EndDeferWindowPos32( HDWP32 hdwp )
2566 DWP *pDWP;
2567 WINDOWPOS32 *winpos;
2568 BOOL32 res = TRUE;
2569 int i;
2571 pDWP = (DWP *) USER_HEAP_LIN_ADDR( hdwp );
2572 if (!pDWP) return FALSE;
2573 for (i = 0, winpos = pDWP->winPos; i < pDWP->actualCount; i++, winpos++)
2575 if (!(res = SetWindowPos32( winpos->hwnd, winpos->hwndInsertAfter,
2576 winpos->x, winpos->y, winpos->cx,
2577 winpos->cy, winpos->flags ))) break;
2579 USER_HEAP_FREE( hdwp );
2580 return res;
2584 /***********************************************************************
2585 * TileChildWindows (USER.199)
2587 void WINAPI TileChildWindows( HWND16 parent, WORD action )
2589 FIXME(win, "(%04x, %d): stub\n", parent, action);
2592 /***********************************************************************
2593 * CascageChildWindows (USER.198)
2595 void WINAPI CascadeChildWindows( HWND16 parent, WORD action )
2597 FIXME(win, "(%04x, %d): stub\n", parent, action);
2599 /***********************************************************************
2600 * GetProgmanWindow [USER32.289]
2602 HRESULT WINAPI GetProgmanWindow ( )
2603 { FIXME(win,"stub\n");
2604 return 0;
2606 /***********************************************************************
2607 * GetTaskmanWindow [USER32.304]
2609 HRESULT WINAPI GetTaskmanWindow ( )
2610 { FIXME(win,"stub\n");
2611 return 0;
2613 /***********************************************************************
2614 * SetProgmanWindow [USER32.522]
2616 HRESULT WINAPI SetProgmanWindow ( DWORD x )
2617 { FIXME(win,"0x%08lx stub\n",x);
2618 return 0;
2620 /***********************************************************************
2621 * SetShellWindowEx [USER32.531]
2623 HRESULT WINAPI SetShellWindowEx ( DWORD x, DWORD y )
2624 { FIXME(win,"0x%08lx 0x%08lx stub\n",x,y);
2625 return 0;
2627 /***********************************************************************
2628 * SetTaskmanWindow [USER32.537]
2630 HRESULT WINAPI SetTaskmanWindow ( DWORD x )
2631 { FIXME(win,"0x%08lx stub\n",x);
2632 return 0;