Fixed bug in CreateFileMapping when name is not NULL.
[wine/multimedia.git] / windows / winpos.c
bloba5fba131c7d76fba584d4016052b1462aff15471
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"
23 #include "x11drv.h"
25 #define HAS_DLGFRAME(style,exStyle) \
26 (((exStyle) & WS_EX_DLGMODALFRAME) || \
27 (((style) & WS_DLGFRAME) && !((style) & WS_BORDER)))
29 #define HAS_THICKFRAME(style) \
30 (((style) & WS_THICKFRAME) && \
31 !(((style) & (WS_DLGFRAME|WS_BORDER)) == WS_DLGFRAME))
33 #define SWP_AGG_NOGEOMETRYCHANGE \
34 (SWP_NOSIZE | SWP_NOMOVE | SWP_NOCLIENTSIZE | SWP_NOCLIENTMOVE)
35 #define SWP_AGG_NOPOSCHANGE \
36 (SWP_AGG_NOGEOMETRYCHANGE | SWP_NOZORDER)
37 #define SWP_AGG_STATUSFLAGS \
38 (SWP_AGG_NOPOSCHANGE | SWP_FRAMECHANGED | SWP_HIDEWINDOW | SWP_SHOWWINDOW)
40 #define EMPTYPOINT(pt) ((*(LONG*)&(pt)) == -1)
42 #define PLACE_MIN 0x0001
43 #define PLACE_MAX 0x0002
44 #define PLACE_RECT 0x0004
46 #define SMC_NOCOPY 0x0001
47 #define SMC_NOPARENTERASE 0x0002
48 #define SMC_DRAWFRAME 0x0004
49 #define SMC_SETXPOS 0x0008
51 /* ----- internal variables ----- */
53 static HWND32 hwndActive = 0; /* Currently active window */
54 static HWND32 hwndPrevActive = 0; /* Previously active window */
55 static HWND32 hGlobalShellWindow=0; /*the shell*/
57 static LPCSTR atomInternalPos;
59 extern MESSAGEQUEUE* pActiveQueue;
61 /***********************************************************************
62 * WINPOS_CreateInternalPosAtom
64 BOOL32 WINPOS_CreateInternalPosAtom()
66 LPSTR str = "SysIP";
67 atomInternalPos = (LPCSTR)(DWORD)GlobalAddAtom32A(str);
68 return (atomInternalPos) ? TRUE : FALSE;
71 /***********************************************************************
72 * WINPOS_CheckInternalPos
74 * Called when a window is destroyed.
76 void WINPOS_CheckInternalPos( HWND32 hwnd )
78 LPINTERNALPOS lpPos = (LPINTERNALPOS) GetProp32A( hwnd, atomInternalPos );
80 if( hwnd == hwndPrevActive ) hwndPrevActive = 0;
81 if( hwnd == hwndActive )
83 hwndActive = 0;
84 WARN(win, "\tattempt to activate destroyed window!\n");
87 if( lpPos )
89 if( IsWindow32(lpPos->hwndIconTitle) )
90 DestroyWindow32( lpPos->hwndIconTitle );
91 HeapFree( SystemHeap, 0, lpPos );
95 /***********************************************************************
96 * WINPOS_FindIconPos
98 * Find a suitable place for an iconic window.
100 static POINT16 WINPOS_FindIconPos( WND* wndPtr, POINT16 pt )
102 RECT16 rectParent;
103 short x, y, xspacing, yspacing;
105 GetClientRect16( wndPtr->parent->hwndSelf, &rectParent );
106 if ((pt.x >= rectParent.left) && (pt.x + SYSMETRICS_CXICON < rectParent.right) &&
107 (pt.y >= rectParent.top) && (pt.y + SYSMETRICS_CYICON < rectParent.bottom))
108 return pt; /* The icon already has a suitable position */
110 xspacing = SYSMETRICS_CXICONSPACING;
111 yspacing = SYSMETRICS_CYICONSPACING;
113 y = rectParent.bottom;
114 for (;;)
116 for (x = rectParent.left; x <= rectParent.right-xspacing; x += xspacing)
118 /* Check if another icon already occupies this spot */
119 WND *childPtr = wndPtr->parent->child;
120 while (childPtr)
122 if ((childPtr->dwStyle & WS_MINIMIZE) && (childPtr != wndPtr))
124 if ((childPtr->rectWindow.left < x + xspacing) &&
125 (childPtr->rectWindow.right >= x) &&
126 (childPtr->rectWindow.top <= y) &&
127 (childPtr->rectWindow.bottom > y - yspacing))
128 break; /* There's a window in there */
130 childPtr = childPtr->next;
132 if (!childPtr) /* No window was found, so it's OK for us */
134 pt.x = x + (xspacing - SYSMETRICS_CXICON) / 2;
135 pt.y = y - (yspacing + SYSMETRICS_CYICON) / 2;
136 return pt;
139 y -= yspacing;
144 /***********************************************************************
145 * ArrangeIconicWindows16 (USER.170)
147 UINT16 WINAPI ArrangeIconicWindows16( HWND16 parent)
149 return ArrangeIconicWindows32(parent);
151 /***********************************************************************
152 * ArrangeIconicWindows32 (USER32.7)
154 UINT32 WINAPI ArrangeIconicWindows32( HWND32 parent )
156 RECT32 rectParent;
157 HWND32 hwndChild;
158 INT32 x, y, xspacing, yspacing;
160 GetClientRect32( parent, &rectParent );
161 x = rectParent.left;
162 y = rectParent.bottom;
163 xspacing = SYSMETRICS_CXICONSPACING;
164 yspacing = SYSMETRICS_CYICONSPACING;
166 hwndChild = GetWindow32( parent, GW_CHILD );
167 while (hwndChild)
169 if( IsIconic32( hwndChild ) )
171 WINPOS_ShowIconTitle( WIN_FindWndPtr(hwndChild), FALSE );
172 SetWindowPos32( hwndChild, 0, x + (xspacing - SYSMETRICS_CXICON) / 2,
173 y - yspacing - SYSMETRICS_CYICON/2, 0, 0,
174 SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE );
175 if( IsWindow32(hwndChild) )
176 WINPOS_ShowIconTitle( WIN_FindWndPtr(hwndChild), TRUE );
177 if (x <= rectParent.right - xspacing) x += xspacing;
178 else
180 x = rectParent.left;
181 y -= yspacing;
184 hwndChild = GetWindow32( hwndChild, GW_HWNDNEXT );
186 return yspacing;
190 /***********************************************************************
191 * SwitchToThisWindow16 (USER.172)
193 void WINAPI SwitchToThisWindow16( HWND16 hwnd, BOOL16 restore )
195 SwitchToThisWindow32( hwnd, restore );
199 /***********************************************************************
200 * SwitchToThisWindow32 (USER32.539)
202 void WINAPI SwitchToThisWindow32( HWND32 hwnd, BOOL32 restore )
204 ShowWindow32( hwnd, restore ? SW_RESTORE : SW_SHOWMINIMIZED );
208 /***********************************************************************
209 * GetWindowRect16 (USER.32)
211 void WINAPI GetWindowRect16( HWND16 hwnd, LPRECT16 rect )
213 WND * wndPtr = WIN_FindWndPtr( hwnd );
214 if (!wndPtr) return;
216 CONV_RECT32TO16( &wndPtr->rectWindow, rect );
217 if (wndPtr->dwStyle & WS_CHILD)
218 MapWindowPoints16( wndPtr->parent->hwndSelf, 0, (POINT16 *)rect, 2 );
222 /***********************************************************************
223 * GetWindowRect32 (USER32.308)
225 BOOL32 WINAPI GetWindowRect32( HWND32 hwnd, LPRECT32 rect )
227 WND * wndPtr = WIN_FindWndPtr( hwnd );
228 if (!wndPtr) return FALSE;
230 *rect = wndPtr->rectWindow;
231 if (wndPtr->dwStyle & WS_CHILD)
232 MapWindowPoints32( wndPtr->parent->hwndSelf, 0, (POINT32 *)rect, 2 );
233 return TRUE;
237 /***********************************************************************
238 * GetWindowRgn32
240 BOOL32 WINAPI GetWindowRgn32 ( HWND32 hwnd, HRGN32 hrgn )
243 RECT32 rect;
244 WND * wndPtr = WIN_FindWndPtr( hwnd );
245 if (!wndPtr) return (ERROR);
247 FIXME (win, "GetWindowRgn32: doesn't really do regions\n");
249 memset (&rect, 0, sizeof(rect));
251 GetWindowRect32 ( hwnd, &rect );
253 FIXME (win, "Check whether a valid region here\n");
255 SetRectRgn32 ( hrgn, rect.left, rect.top, rect.right, rect.bottom );
257 return (SIMPLEREGION);
260 /***********************************************************************
261 * SetWindowRgn32
263 INT32 WINAPI SetWindowRgn32( HWND32 hwnd, HRGN32 hrgn,BOOL32 bRedraw)
267 FIXME (win, "SetWindowRgn32: stub\n");
268 return TRUE;
271 /***********************************************************************
272 * SetWindowRgn16
274 INT16 WINAPI SetWindowRgn16( HWND16 hwnd, HRGN16 hrgn,BOOL16 bRedraw)
278 FIXME (win, "SetWindowRgn16: stub\n");
279 return TRUE;
283 /***********************************************************************
284 * GetClientRect16 (USER.33)
286 void WINAPI GetClientRect16( HWND16 hwnd, LPRECT16 rect )
288 WND * wndPtr = WIN_FindWndPtr( hwnd );
290 rect->left = rect->top = rect->right = rect->bottom = 0;
291 if (wndPtr)
293 rect->right = wndPtr->rectClient.right - wndPtr->rectClient.left;
294 rect->bottom = wndPtr->rectClient.bottom - wndPtr->rectClient.top;
299 /***********************************************************************
300 * GetClientRect32 (USER32.220)
302 void WINAPI GetClientRect32( HWND32 hwnd, LPRECT32 rect )
304 WND * wndPtr = WIN_FindWndPtr( hwnd );
306 rect->left = rect->top = rect->right = rect->bottom = 0;
307 if (wndPtr)
309 rect->right = wndPtr->rectClient.right - wndPtr->rectClient.left;
310 rect->bottom = wndPtr->rectClient.bottom - wndPtr->rectClient.top;
315 /*******************************************************************
316 * ClientToScreen16 (USER.28)
318 void WINAPI ClientToScreen16( HWND16 hwnd, LPPOINT16 lppnt )
320 MapWindowPoints16( hwnd, 0, lppnt, 1 );
324 /*******************************************************************
325 * ClientToScreen32 (USER32.52)
327 BOOL32 WINAPI ClientToScreen32( HWND32 hwnd, LPPOINT32 lppnt )
329 MapWindowPoints32( hwnd, 0, lppnt, 1 );
330 return TRUE;
334 /*******************************************************************
335 * ScreenToClient16 (USER.29)
337 void WINAPI ScreenToClient16( HWND16 hwnd, LPPOINT16 lppnt )
339 MapWindowPoints16( 0, hwnd, lppnt, 1 );
343 /*******************************************************************
344 * ScreenToClient32 (USER32.447)
346 void WINAPI ScreenToClient32( HWND32 hwnd, LPPOINT32 lppnt )
348 MapWindowPoints32( 0, hwnd, lppnt, 1 );
352 /***********************************************************************
353 * WINPOS_WindowFromPoint
355 * Find the window and hittest for a given point.
357 INT16 WINPOS_WindowFromPoint( WND* wndScope, POINT16 pt, WND **ppWnd )
359 WND *wndPtr;
360 INT16 hittest = HTERROR;
361 POINT16 xy = pt;
363 *ppWnd = NULL;
364 wndPtr = wndScope->child;
365 if( wndScope->flags & WIN_MANAGED )
367 /* this prevents mouse clicks from going "through" scrollbars in managed mode */
368 if( pt.x < wndScope->rectClient.left || pt.x >= wndScope->rectClient.right ||
369 pt.y < wndScope->rectClient.top || pt.y >= wndScope->rectClient.bottom )
370 goto hittest;
372 MapWindowPoints16( GetDesktopWindow16(), wndScope->hwndSelf, &xy, 1 );
374 for (;;)
376 while (wndPtr)
378 /* If point is in window, and window is visible, and it */
379 /* is enabled (or it's a top-level window), then explore */
380 /* its children. Otherwise, go to the next window. */
382 if ((wndPtr->dwStyle & WS_VISIBLE) &&
383 (!(wndPtr->dwStyle & WS_DISABLED) ||
384 ((wndPtr->dwStyle & (WS_POPUP | WS_CHILD)) != WS_CHILD)) &&
385 (xy.x >= wndPtr->rectWindow.left) &&
386 (xy.x < wndPtr->rectWindow.right) &&
387 (xy.y >= wndPtr->rectWindow.top) &&
388 (xy.y < wndPtr->rectWindow.bottom))
390 *ppWnd = wndPtr; /* Got a suitable window */
392 /* If window is minimized or disabled, return at once */
393 if (wndPtr->dwStyle & WS_MINIMIZE) return HTCAPTION;
394 if (wndPtr->dwStyle & WS_DISABLED) return HTERROR;
396 /* If point is not in client area, ignore the children */
397 if ((xy.x < wndPtr->rectClient.left) ||
398 (xy.x >= wndPtr->rectClient.right) ||
399 (xy.y < wndPtr->rectClient.top) ||
400 (xy.y >= wndPtr->rectClient.bottom)) break;
402 xy.x -= wndPtr->rectClient.left;
403 xy.y -= wndPtr->rectClient.top;
404 wndPtr = wndPtr->child;
406 else wndPtr = wndPtr->next;
409 hittest:
410 /* If nothing found, try the scope window */
411 if (!*ppWnd) *ppWnd = wndScope;
413 /* Send the WM_NCHITTEST message (only if to the same task) */
414 if ((*ppWnd)->hmemTaskQ == GetFastQueue())
416 hittest = (INT16)SendMessage16( (*ppWnd)->hwndSelf, WM_NCHITTEST,
417 0, MAKELONG( pt.x, pt.y ) );
418 if (hittest != HTTRANSPARENT) return hittest; /* Found the window */
420 else return HTCLIENT;
422 /* If no children found in last search, make point relative to parent */
423 if (!wndPtr)
425 xy.x += (*ppWnd)->rectClient.left;
426 xy.y += (*ppWnd)->rectClient.top;
429 /* Restart the search from the next sibling */
430 wndPtr = (*ppWnd)->next;
431 *ppWnd = (*ppWnd)->parent;
436 /*******************************************************************
437 * WindowFromPoint16 (USER.30)
439 HWND16 WINAPI WindowFromPoint16( POINT16 pt )
441 WND *pWnd;
442 WINPOS_WindowFromPoint( WIN_GetDesktop(), pt, &pWnd );
443 return pWnd->hwndSelf;
447 /*******************************************************************
448 * WindowFromPoint32 (USER32.582)
450 HWND32 WINAPI WindowFromPoint32( POINT32 pt )
452 WND *pWnd;
453 POINT16 pt16;
454 CONV_POINT32TO16( &pt, &pt16 );
455 WINPOS_WindowFromPoint( WIN_GetDesktop(), pt16, &pWnd );
456 return (HWND32)pWnd->hwndSelf;
460 /*******************************************************************
461 * ChildWindowFromPoint16 (USER.191)
463 HWND16 WINAPI ChildWindowFromPoint16( HWND16 hwndParent, POINT16 pt )
465 POINT32 pt32;
466 CONV_POINT16TO32( &pt, &pt32 );
467 return (HWND16)ChildWindowFromPoint32( hwndParent, pt32 );
471 /*******************************************************************
472 * ChildWindowFromPoint32 (USER32.49)
474 HWND32 WINAPI ChildWindowFromPoint32( HWND32 hwndParent, POINT32 pt )
476 /* pt is in the client coordinates */
478 WND* wnd = WIN_FindWndPtr(hwndParent);
479 RECT32 rect;
481 if( !wnd ) return 0;
483 /* get client rect fast */
484 rect.top = rect.left = 0;
485 rect.right = wnd->rectClient.right - wnd->rectClient.left;
486 rect.bottom = wnd->rectClient.bottom - wnd->rectClient.top;
488 if (!PtInRect32( &rect, pt )) return 0;
490 wnd = wnd->child;
491 while ( wnd )
493 if (PtInRect32( &wnd->rectWindow, pt )) return wnd->hwndSelf;
494 wnd = wnd->next;
496 return hwndParent;
499 /*******************************************************************
500 * ChildWindowFromPointEx16 (USER.50)
502 HWND16 WINAPI ChildWindowFromPointEx16( HWND16 hwndParent, POINT16 pt, UINT16 uFlags)
504 POINT32 pt32;
505 CONV_POINT16TO32( &pt, &pt32 );
506 return (HWND16)ChildWindowFromPointEx32( hwndParent, pt32, uFlags );
510 /*******************************************************************
511 * ChildWindowFromPointEx32 (USER32.50)
513 HWND32 WINAPI ChildWindowFromPointEx32( HWND32 hwndParent, POINT32 pt,
514 UINT32 uFlags)
516 /* pt is in the client coordinates */
518 WND* wnd = WIN_FindWndPtr(hwndParent);
519 RECT32 rect;
521 if( !wnd ) return 0;
523 /* get client rect fast */
524 rect.top = rect.left = 0;
525 rect.right = wnd->rectClient.right - wnd->rectClient.left;
526 rect.bottom = wnd->rectClient.bottom - wnd->rectClient.top;
528 if (!PtInRect32( &rect, pt )) return 0;
530 wnd = wnd->child;
531 while ( wnd )
533 if (PtInRect32( &wnd->rectWindow, pt )) {
534 if ( (uFlags & CWP_SKIPINVISIBLE) &&
535 !(wnd->dwStyle & WS_VISIBLE) )
536 wnd = wnd->next;
537 else if ( (uFlags & CWP_SKIPDISABLED) &&
538 (wnd->dwStyle & WS_DISABLED) )
539 wnd = wnd->next;
540 else if ( (uFlags & CWP_SKIPTRANSPARENT) &&
541 (wnd->dwExStyle & WS_EX_TRANSPARENT) )
542 wnd = wnd->next;
543 else
544 return wnd->hwndSelf;
547 return hwndParent;
551 /*******************************************************************
552 * WINPOS_GetWinOffset
554 * Calculate the offset between the origin of the two windows. Used
555 * to implement MapWindowPoints.
557 static void WINPOS_GetWinOffset( HWND32 hwndFrom, HWND32 hwndTo,
558 POINT32 *offset )
560 WND * wndPtr;
562 offset->x = offset->y = 0;
563 if (hwndFrom == hwndTo ) return;
565 /* Translate source window origin to screen coords */
566 if (hwndFrom)
568 if (!(wndPtr = WIN_FindWndPtr( hwndFrom )))
570 ERR(win,"bad hwndFrom = %04x\n",hwndFrom);
571 return;
573 while (wndPtr->parent)
575 offset->x += wndPtr->rectClient.left;
576 offset->y += wndPtr->rectClient.top;
577 wndPtr = wndPtr->parent;
581 /* Translate origin to destination window coords */
582 if (hwndTo)
584 if (!(wndPtr = WIN_FindWndPtr( hwndTo )))
586 ERR(win,"bad hwndTo = %04x\n", hwndTo );
587 return;
589 while (wndPtr->parent)
591 offset->x -= wndPtr->rectClient.left;
592 offset->y -= wndPtr->rectClient.top;
593 wndPtr = wndPtr->parent;
599 /*******************************************************************
600 * MapWindowPoints16 (USER.258)
602 void WINAPI MapWindowPoints16( HWND16 hwndFrom, HWND16 hwndTo,
603 LPPOINT16 lppt, UINT16 count )
605 POINT32 offset;
607 WINPOS_GetWinOffset( hwndFrom, hwndTo, &offset );
608 while (count--)
610 lppt->x += offset.x;
611 lppt->y += offset.y;
612 lppt++;
617 /*******************************************************************
618 * MapWindowPoints32 (USER32.386)
620 void WINAPI MapWindowPoints32( HWND32 hwndFrom, HWND32 hwndTo,
621 LPPOINT32 lppt, UINT32 count )
623 POINT32 offset;
625 WINPOS_GetWinOffset( hwndFrom, hwndTo, &offset );
626 while (count--)
628 lppt->x += offset.x;
629 lppt->y += offset.y;
630 lppt++;
635 /***********************************************************************
636 * IsIconic16 (USER.31)
638 BOOL16 WINAPI IsIconic16(HWND16 hWnd)
640 return IsIconic32(hWnd);
644 /***********************************************************************
645 * IsIconic32 (USER32.345)
647 BOOL32 WINAPI IsIconic32(HWND32 hWnd)
649 WND * wndPtr = WIN_FindWndPtr(hWnd);
650 if (wndPtr == NULL) return FALSE;
651 return (wndPtr->dwStyle & WS_MINIMIZE) != 0;
655 /***********************************************************************
656 * IsZoomed (USER.272)
658 BOOL16 WINAPI IsZoomed16(HWND16 hWnd)
660 return IsZoomed32(hWnd);
664 /***********************************************************************
665 * IsZoomed (USER32.352)
667 BOOL32 WINAPI IsZoomed32(HWND32 hWnd)
669 WND * wndPtr = WIN_FindWndPtr(hWnd);
670 if (wndPtr == NULL) return FALSE;
671 return (wndPtr->dwStyle & WS_MAXIMIZE) != 0;
675 /*******************************************************************
676 * GetActiveWindow (USER.60)
678 HWND16 WINAPI GetActiveWindow16(void)
680 return (HWND16)hwndActive;
683 /*******************************************************************
684 * GetActiveWindow (USER32.205)
686 HWND32 WINAPI GetActiveWindow32(void)
688 return (HWND32)hwndActive;
692 /*******************************************************************
693 * WINPOS_CanActivate
695 static BOOL32 WINPOS_CanActivate(WND* pWnd)
697 if( pWnd && ((pWnd->dwStyle & (WS_DISABLED | WS_VISIBLE | WS_CHILD))
698 == WS_VISIBLE) ) return TRUE;
699 return FALSE;
703 /*******************************************************************
704 * SetActiveWindow16 (USER.59)
706 HWND16 WINAPI SetActiveWindow16( HWND16 hwnd )
708 return SetActiveWindow32(hwnd);
712 /*******************************************************************
713 * SetActiveWindow32 (USER32.463)
715 HWND32 WINAPI SetActiveWindow32( HWND32 hwnd )
717 HWND32 prev = hwndActive;
718 WND *wndPtr = WIN_FindWndPtr( hwnd );
720 if ( !WINPOS_CanActivate(wndPtr) ) return 0;
722 WINPOS_SetActiveWindow( hwnd, 0, 0 );
723 return prev;
727 /*******************************************************************
728 * GetForegroundWindow16 (USER.608)
730 HWND16 WINAPI GetForegroundWindow16(void)
732 return (HWND16)GetForegroundWindow32();
736 /*******************************************************************
737 * SetForegroundWindow16 (USER.609)
739 BOOL16 WINAPI SetForegroundWindow16( HWND16 hwnd )
741 return SetForegroundWindow32( hwnd );
745 /*******************************************************************
746 * GetForegroundWindow32 (USER32.241)
748 HWND32 WINAPI GetForegroundWindow32(void)
750 return GetActiveWindow32();
754 /*******************************************************************
755 * SetForegroundWindow32 (USER32.482)
757 BOOL32 WINAPI SetForegroundWindow32( HWND32 hwnd )
759 SetActiveWindow32( hwnd );
760 return TRUE;
764 /*******************************************************************
765 * GetShellWindow16 (USER.600)
767 HWND16 WINAPI GetShellWindow16(void)
769 return GetShellWindow32();
772 /*******************************************************************
773 * SetShellWindow32 (USER32.504)
775 HWND32 WINAPI SetShellWindow32(HWND32 hwndshell)
776 { WARN(win, "(hWnd=%08x) semi stub\n",hwndshell );
778 hGlobalShellWindow = hwndshell;
779 return hGlobalShellWindow;
783 /*******************************************************************
784 * GetShellWindow32 (USER32.287)
786 HWND32 WINAPI GetShellWindow32(void)
787 { WARN(win, "(hWnd=%x) semi stub\n",hGlobalShellWindow );
789 return hGlobalShellWindow;
793 /***********************************************************************
794 * BringWindowToTop16 (USER.45)
796 BOOL16 WINAPI BringWindowToTop16( HWND16 hwnd )
798 return BringWindowToTop32(hwnd);
802 /***********************************************************************
803 * BringWindowToTop32 (USER32.11)
805 BOOL32 WINAPI BringWindowToTop32( HWND32 hwnd )
807 return SetWindowPos32( hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE );
811 /***********************************************************************
812 * MoveWindow16 (USER.56)
814 BOOL16 WINAPI MoveWindow16( HWND16 hwnd, INT16 x, INT16 y, INT16 cx, INT16 cy,
815 BOOL16 repaint )
817 return MoveWindow32(hwnd,x,y,cx,cy,repaint);
821 /***********************************************************************
822 * MoveWindow32 (USER32.399)
824 BOOL32 WINAPI MoveWindow32( HWND32 hwnd, INT32 x, INT32 y, INT32 cx, INT32 cy,
825 BOOL32 repaint )
827 int flags = SWP_NOZORDER | SWP_NOACTIVATE;
828 if (!repaint) flags |= SWP_NOREDRAW;
829 TRACE(win, "%04x %d,%d %dx%d %d\n",
830 hwnd, x, y, cx, cy, repaint );
831 return SetWindowPos32( hwnd, 0, x, y, cx, cy, flags );
834 /***********************************************************************
835 * WINPOS_InitInternalPos
837 static LPINTERNALPOS WINPOS_InitInternalPos( WND* wnd, POINT32 pt,
838 LPRECT32 restoreRect )
840 LPINTERNALPOS lpPos = (LPINTERNALPOS) GetProp32A( wnd->hwndSelf,
841 atomInternalPos );
842 if( !lpPos )
844 /* this happens when the window is minimized/maximized
845 * for the first time (rectWindow is not adjusted yet) */
847 lpPos = HeapAlloc( SystemHeap, 0, sizeof(INTERNALPOS) );
848 if( !lpPos ) return NULL;
850 SetProp32A( wnd->hwndSelf, atomInternalPos, (HANDLE32)lpPos );
851 lpPos->hwndIconTitle = 0; /* defer until needs to be shown */
852 CONV_RECT32TO16( &wnd->rectWindow, &lpPos->rectNormal );
853 *(UINT32*)&lpPos->ptIconPos = *(UINT32*)&lpPos->ptMaxPos = 0xFFFFFFFF;
856 if( wnd->dwStyle & WS_MINIMIZE )
857 CONV_POINT32TO16( &pt, &lpPos->ptIconPos );
858 else if( wnd->dwStyle & WS_MAXIMIZE )
859 CONV_POINT32TO16( &pt, &lpPos->ptMaxPos );
860 else if( restoreRect )
861 CONV_RECT32TO16( restoreRect, &lpPos->rectNormal );
863 return lpPos;
866 /***********************************************************************
867 * WINPOS_RedrawIconTitle
869 BOOL32 WINPOS_RedrawIconTitle( HWND32 hWnd )
871 LPINTERNALPOS lpPos = (LPINTERNALPOS)GetProp32A( hWnd, atomInternalPos );
872 if( lpPos )
874 if( lpPos->hwndIconTitle )
876 SendMessage32A( lpPos->hwndIconTitle, WM_SHOWWINDOW, TRUE, 0);
877 InvalidateRect32( lpPos->hwndIconTitle, NULL, TRUE );
878 return TRUE;
881 return FALSE;
884 /***********************************************************************
885 * WINPOS_ShowIconTitle
887 BOOL32 WINPOS_ShowIconTitle( WND* pWnd, BOOL32 bShow )
889 LPINTERNALPOS lpPos = (LPINTERNALPOS)GetProp32A( pWnd->hwndSelf, atomInternalPos );
891 if( lpPos && !(pWnd->flags & WIN_MANAGED))
893 HWND16 hWnd = lpPos->hwndIconTitle;
895 TRACE(win,"0x%04x %i\n", pWnd->hwndSelf, (bShow != 0) );
897 if( !hWnd )
898 lpPos->hwndIconTitle = hWnd = ICONTITLE_Create( pWnd );
899 if( bShow )
901 pWnd = WIN_FindWndPtr(hWnd);
903 if( !(pWnd->dwStyle & WS_VISIBLE) )
905 SendMessage32A( hWnd, WM_SHOWWINDOW, TRUE, 0 );
906 SetWindowPos32( hWnd, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE |
907 SWP_NOACTIVATE | SWP_NOZORDER | SWP_SHOWWINDOW );
910 else ShowWindow32( hWnd, SW_HIDE );
912 return FALSE;
915 /*******************************************************************
916 * WINPOS_GetMinMaxInfo
918 * Get the minimized and maximized information for a window.
920 void WINPOS_GetMinMaxInfo( WND *wndPtr, POINT32 *maxSize, POINT32 *maxPos,
921 POINT32 *minTrack, POINT32 *maxTrack )
923 LPINTERNALPOS lpPos;
924 MINMAXINFO32 MinMax;
925 INT32 xinc, yinc;
927 /* Compute default values */
929 MinMax.ptMaxSize.x = SYSMETRICS_CXSCREEN;
930 MinMax.ptMaxSize.y = SYSMETRICS_CYSCREEN;
931 MinMax.ptMinTrackSize.x = SYSMETRICS_CXMINTRACK;
932 MinMax.ptMinTrackSize.y = SYSMETRICS_CYMINTRACK;
933 MinMax.ptMaxTrackSize.x = SYSMETRICS_CXSCREEN;
934 MinMax.ptMaxTrackSize.y = SYSMETRICS_CYSCREEN;
936 if (wndPtr->flags & WIN_MANAGED) xinc = yinc = 0;
937 else if (HAS_DLGFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
939 xinc = SYSMETRICS_CXDLGFRAME;
940 yinc = SYSMETRICS_CYDLGFRAME;
942 else
944 xinc = yinc = 0;
945 if (HAS_THICKFRAME(wndPtr->dwStyle))
947 xinc += SYSMETRICS_CXFRAME;
948 yinc += SYSMETRICS_CYFRAME;
950 if (wndPtr->dwStyle & WS_BORDER)
952 xinc += SYSMETRICS_CXBORDER;
953 yinc += SYSMETRICS_CYBORDER;
956 MinMax.ptMaxSize.x += 2 * xinc;
957 MinMax.ptMaxSize.y += 2 * yinc;
959 lpPos = (LPINTERNALPOS)GetProp32A( wndPtr->hwndSelf, atomInternalPos );
960 if( lpPos && !EMPTYPOINT(lpPos->ptMaxPos) )
961 CONV_POINT16TO32( &lpPos->ptMaxPos, &MinMax.ptMaxPosition );
962 else
964 MinMax.ptMaxPosition.x = -xinc;
965 MinMax.ptMaxPosition.y = -yinc;
968 SendMessage32A( wndPtr->hwndSelf, WM_GETMINMAXINFO, 0, (LPARAM)&MinMax );
970 /* Some sanity checks */
972 TRACE(win,"%d %d / %d %d / %d %d / %d %d\n",
973 MinMax.ptMaxSize.x, MinMax.ptMaxSize.y,
974 MinMax.ptMaxPosition.x, MinMax.ptMaxPosition.y,
975 MinMax.ptMaxTrackSize.x, MinMax.ptMaxTrackSize.y,
976 MinMax.ptMinTrackSize.x, MinMax.ptMinTrackSize.y);
977 MinMax.ptMaxTrackSize.x = MAX( MinMax.ptMaxTrackSize.x,
978 MinMax.ptMinTrackSize.x );
979 MinMax.ptMaxTrackSize.y = MAX( MinMax.ptMaxTrackSize.y,
980 MinMax.ptMinTrackSize.y );
982 if (maxSize) *maxSize = MinMax.ptMaxSize;
983 if (maxPos) *maxPos = MinMax.ptMaxPosition;
984 if (minTrack) *minTrack = MinMax.ptMinTrackSize;
985 if (maxTrack) *maxTrack = MinMax.ptMaxTrackSize;
988 /***********************************************************************
989 * WINPOS_MinMaximize
991 * Fill in lpRect and return additional flags to be used with SetWindowPos().
992 * This function assumes that 'cmd' is different from the current window
993 * state.
995 UINT16 WINPOS_MinMaximize( WND* wndPtr, UINT16 cmd, LPRECT16 lpRect )
997 UINT16 swpFlags = 0;
998 POINT32 pt;
999 POINT32 size = { wndPtr->rectWindow.left, wndPtr->rectWindow.top };
1000 LPINTERNALPOS lpPos = WINPOS_InitInternalPos( wndPtr, size,
1001 &wndPtr->rectWindow );
1003 TRACE(win,"0x%04x %u\n", wndPtr->hwndSelf, cmd );
1005 if (lpPos && !HOOK_CallHooks16(WH_CBT, HCBT_MINMAX, wndPtr->hwndSelf, cmd))
1007 if( wndPtr->dwStyle & WS_MINIMIZE )
1009 if( !SendMessage32A( wndPtr->hwndSelf, WM_QUERYOPEN, 0, 0L ) )
1010 return (SWP_NOSIZE | SWP_NOMOVE);
1011 swpFlags |= SWP_NOCOPYBITS;
1013 switch( cmd )
1015 case SW_MINIMIZE:
1016 if( wndPtr->dwStyle & WS_MAXIMIZE)
1018 wndPtr->flags |= WIN_RESTORE_MAX;
1019 wndPtr->dwStyle &= ~WS_MAXIMIZE;
1021 else
1022 wndPtr->flags &= ~WIN_RESTORE_MAX;
1023 wndPtr->dwStyle |= WS_MINIMIZE;
1025 lpPos->ptIconPos = WINPOS_FindIconPos( wndPtr, lpPos->ptIconPos );
1027 SetRect16( lpRect, lpPos->ptIconPos.x, lpPos->ptIconPos.y,
1028 SYSMETRICS_CXICON, SYSMETRICS_CYICON );
1029 swpFlags |= SWP_NOCOPYBITS;
1030 break;
1032 case SW_MAXIMIZE:
1033 CONV_POINT16TO32( &lpPos->ptMaxPos, &pt );
1034 WINPOS_GetMinMaxInfo( wndPtr, &size, &pt, NULL, NULL );
1035 CONV_POINT32TO16( &pt, &lpPos->ptMaxPos );
1037 if( wndPtr->dwStyle & WS_MINIMIZE )
1039 WINPOS_ShowIconTitle( wndPtr, FALSE );
1040 wndPtr->dwStyle &= ~WS_MINIMIZE;
1042 wndPtr->dwStyle |= WS_MAXIMIZE;
1044 SetRect16( lpRect, lpPos->ptMaxPos.x, lpPos->ptMaxPos.y,
1045 size.x, size.y );
1046 break;
1048 case SW_RESTORE:
1049 if( wndPtr->dwStyle & WS_MINIMIZE )
1051 wndPtr->dwStyle &= ~WS_MINIMIZE;
1052 WINPOS_ShowIconTitle( wndPtr, FALSE );
1053 if( wndPtr->flags & WIN_RESTORE_MAX)
1055 /* Restore to maximized position */
1056 CONV_POINT16TO32( &lpPos->ptMaxPos, &pt );
1057 WINPOS_GetMinMaxInfo( wndPtr, &size, &pt, NULL, NULL);
1058 CONV_POINT32TO16( &pt, &lpPos->ptMaxPos );
1059 wndPtr->dwStyle |= WS_MAXIMIZE;
1060 SetRect16( lpRect, lpPos->ptMaxPos.x, lpPos->ptMaxPos.y, size.x, size.y );
1061 break;
1064 else
1065 if( !(wndPtr->dwStyle & WS_MAXIMIZE) ) return (UINT16)(-1);
1066 else wndPtr->dwStyle &= ~WS_MAXIMIZE;
1068 /* Restore to normal position */
1070 *lpRect = lpPos->rectNormal;
1071 lpRect->right -= lpRect->left;
1072 lpRect->bottom -= lpRect->top;
1074 break;
1076 } else swpFlags |= SWP_NOSIZE | SWP_NOMOVE;
1077 return swpFlags;
1080 /***********************************************************************
1081 * ShowWindowAsync32 (USER32.535)
1083 * doesn't wait; returns immediately.
1084 * used by threads to toggle windows in other (possibly hanging) threads
1086 BOOL32 WINAPI ShowWindowAsync32( HWND32 hwnd, INT32 cmd )
1088 /* FIXME: does ShowWindow32() return immediately ? */
1089 return ShowWindow32(hwnd, cmd);
1093 /***********************************************************************
1094 * ShowWindow16 (USER.42)
1096 BOOL16 WINAPI ShowWindow16( HWND16 hwnd, INT16 cmd )
1098 return ShowWindow32(hwnd,cmd);
1102 /***********************************************************************
1103 * ShowWindow32 (USER32.534)
1105 BOOL32 WINAPI ShowWindow32( HWND32 hwnd, INT32 cmd )
1107 WND* wndPtr = WIN_FindWndPtr( hwnd );
1108 BOOL32 wasVisible, showFlag;
1109 RECT16 newPos = {0, 0, 0, 0};
1110 int swp = 0;
1112 if (!wndPtr) return FALSE;
1114 TRACE(win,"hwnd=%04x, cmd=%d\n", hwnd, cmd);
1116 wasVisible = (wndPtr->dwStyle & WS_VISIBLE) != 0;
1118 switch(cmd)
1120 case SW_HIDE:
1121 if (!wasVisible) return FALSE;
1122 swp |= SWP_HIDEWINDOW | SWP_NOSIZE | SWP_NOMOVE |
1123 SWP_NOACTIVATE | SWP_NOZORDER;
1124 break;
1126 case SW_SHOWMINNOACTIVE:
1127 swp |= SWP_NOACTIVATE | SWP_NOZORDER;
1128 /* fall through */
1129 case SW_SHOWMINIMIZED:
1130 swp |= SWP_SHOWWINDOW;
1131 /* fall through */
1132 case SW_MINIMIZE:
1133 swp |= SWP_FRAMECHANGED;
1134 if( !(wndPtr->dwStyle & WS_MINIMIZE) )
1135 swp |= WINPOS_MinMaximize( wndPtr, SW_MINIMIZE, &newPos );
1136 else swp |= SWP_NOSIZE | SWP_NOMOVE;
1137 break;
1139 case SW_SHOWMAXIMIZED: /* same as SW_MAXIMIZE */
1140 swp |= SWP_SHOWWINDOW | SWP_FRAMECHANGED;
1141 if( !(wndPtr->dwStyle & WS_MAXIMIZE) )
1142 swp |= WINPOS_MinMaximize( wndPtr, SW_MAXIMIZE, &newPos );
1143 else swp |= SWP_NOSIZE | SWP_NOMOVE;
1144 break;
1146 case SW_SHOWNA:
1147 swp |= SWP_NOACTIVATE | SWP_NOZORDER;
1148 /* fall through */
1149 case SW_SHOW:
1150 swp |= SWP_SHOWWINDOW | SWP_NOSIZE | SWP_NOMOVE;
1151 break;
1153 case SW_SHOWNOACTIVATE:
1154 swp |= SWP_NOZORDER;
1155 if (GetActiveWindow32()) swp |= SWP_NOACTIVATE;
1156 /* fall through */
1157 case SW_SHOWNORMAL: /* same as SW_NORMAL: */
1158 case SW_SHOWDEFAULT: /* FIXME: should have its own handler */
1159 case SW_RESTORE:
1160 swp |= SWP_SHOWWINDOW | SWP_FRAMECHANGED;
1162 if( wndPtr->dwStyle & (WS_MINIMIZE | WS_MAXIMIZE) )
1163 swp |= WINPOS_MinMaximize( wndPtr, SW_RESTORE, &newPos );
1164 else swp |= SWP_NOSIZE | SWP_NOMOVE;
1165 break;
1168 showFlag = (cmd != SW_HIDE);
1169 if (showFlag != wasVisible)
1171 SendMessage32A( hwnd, WM_SHOWWINDOW, showFlag, 0 );
1172 if (!IsWindow32( hwnd )) return wasVisible;
1175 if ((wndPtr->dwStyle & WS_CHILD) &&
1176 !IsWindowVisible32( wndPtr->parent->hwndSelf ) &&
1177 (swp & (SWP_NOSIZE | SWP_NOMOVE)) == (SWP_NOSIZE | SWP_NOMOVE) )
1179 /* Don't call SetWindowPos32() on invisible child windows */
1180 if (cmd == SW_HIDE) wndPtr->dwStyle &= ~WS_VISIBLE;
1181 else wndPtr->dwStyle |= WS_VISIBLE;
1183 else
1185 /* We can't activate a child window */
1186 if (wndPtr->dwStyle & WS_CHILD) swp |= SWP_NOACTIVATE | SWP_NOZORDER;
1187 SetWindowPos32( hwnd, HWND_TOP,
1188 newPos.left, newPos.top, newPos.right, newPos.bottom, swp );
1189 if (!IsWindow32( hwnd )) return wasVisible;
1190 else if( wndPtr->dwStyle & WS_MINIMIZE ) WINPOS_ShowIconTitle( wndPtr, TRUE );
1193 if (wndPtr->flags & WIN_NEED_SIZE)
1195 /* should happen only in CreateWindowEx() */
1196 int wParam = SIZE_RESTORED;
1198 wndPtr->flags &= ~WIN_NEED_SIZE;
1199 if (wndPtr->dwStyle & WS_MAXIMIZE) wParam = SIZE_MAXIMIZED;
1200 else if (wndPtr->dwStyle & WS_MINIMIZE) wParam = SIZE_MINIMIZED;
1201 SendMessage32A( hwnd, WM_SIZE, wParam,
1202 MAKELONG(wndPtr->rectClient.right-wndPtr->rectClient.left,
1203 wndPtr->rectClient.bottom-wndPtr->rectClient.top));
1204 SendMessage32A( hwnd, WM_MOVE, 0,
1205 MAKELONG(wndPtr->rectClient.left, wndPtr->rectClient.top) );
1208 return wasVisible;
1212 /***********************************************************************
1213 * GetInternalWindowPos16 (USER.460)
1215 UINT16 WINAPI GetInternalWindowPos16( HWND16 hwnd, LPRECT16 rectWnd,
1216 LPPOINT16 ptIcon )
1218 WINDOWPLACEMENT16 wndpl;
1219 if (GetWindowPlacement16( hwnd, &wndpl ))
1221 if (rectWnd) *rectWnd = wndpl.rcNormalPosition;
1222 if (ptIcon) *ptIcon = wndpl.ptMinPosition;
1223 return wndpl.showCmd;
1225 return 0;
1229 /***********************************************************************
1230 * GetInternalWindowPos32 (USER32.245)
1232 UINT32 WINAPI GetInternalWindowPos32( HWND32 hwnd, LPRECT32 rectWnd,
1233 LPPOINT32 ptIcon )
1235 WINDOWPLACEMENT32 wndpl;
1236 if (GetWindowPlacement32( hwnd, &wndpl ))
1238 if (rectWnd) *rectWnd = wndpl.rcNormalPosition;
1239 if (ptIcon) *ptIcon = wndpl.ptMinPosition;
1240 return wndpl.showCmd;
1242 return 0;
1245 /***********************************************************************
1246 * GetWindowPlacement16 (USER.370)
1248 BOOL16 WINAPI GetWindowPlacement16( HWND16 hwnd, WINDOWPLACEMENT16 *wndpl )
1250 WND *pWnd = WIN_FindWndPtr( hwnd );
1251 if( pWnd )
1253 LPINTERNALPOS lpPos = (LPINTERNALPOS)WINPOS_InitInternalPos( pWnd,
1254 *(LPPOINT32)&pWnd->rectWindow.left, &pWnd->rectWindow );
1255 wndpl->length = sizeof(*wndpl);
1256 if( pWnd->dwStyle & WS_MINIMIZE )
1257 wndpl->showCmd = SW_SHOWMINIMIZED;
1258 else
1259 wndpl->showCmd = ( pWnd->dwStyle & WS_MAXIMIZE )
1260 ? SW_SHOWMAXIMIZED : SW_SHOWNORMAL ;
1261 if( pWnd->flags & WIN_RESTORE_MAX )
1262 wndpl->flags = WPF_RESTORETOMAXIMIZED;
1263 else
1264 wndpl->flags = 0;
1265 wndpl->ptMinPosition = lpPos->ptIconPos;
1266 wndpl->ptMaxPosition = lpPos->ptMaxPos;
1267 wndpl->rcNormalPosition = lpPos->rectNormal;
1268 return TRUE;
1270 return FALSE;
1274 /***********************************************************************
1275 * GetWindowPlacement32 (USER32.307)
1277 BOOL32 WINAPI GetWindowPlacement32( HWND32 hwnd, WINDOWPLACEMENT32 *pwpl32 )
1279 if( pwpl32 )
1281 WINDOWPLACEMENT16 wpl;
1282 wpl.length = sizeof(wpl);
1283 if( GetWindowPlacement16( hwnd, &wpl ) )
1285 pwpl32->length = sizeof(*pwpl32);
1286 pwpl32->flags = wpl.flags;
1287 pwpl32->showCmd = wpl.showCmd;
1288 CONV_POINT16TO32( &wpl.ptMinPosition, &pwpl32->ptMinPosition );
1289 CONV_POINT16TO32( &wpl.ptMaxPosition, &pwpl32->ptMaxPosition );
1290 CONV_RECT16TO32( &wpl.rcNormalPosition, &pwpl32->rcNormalPosition );
1291 return TRUE;
1294 return FALSE;
1298 /***********************************************************************
1299 * WINPOS_SetPlacement
1301 static BOOL32 WINPOS_SetPlacement( HWND32 hwnd, const WINDOWPLACEMENT16 *wndpl,
1302 UINT32 flags )
1304 WND *pWnd = WIN_FindWndPtr( hwnd );
1305 if( pWnd )
1307 LPINTERNALPOS lpPos = (LPINTERNALPOS)WINPOS_InitInternalPos( pWnd,
1308 *(LPPOINT32)&pWnd->rectWindow.left, &pWnd->rectWindow );
1310 if( flags & PLACE_MIN ) lpPos->ptIconPos = wndpl->ptMinPosition;
1311 if( flags & PLACE_MAX ) lpPos->ptMaxPos = wndpl->ptMaxPosition;
1312 if( flags & PLACE_RECT) lpPos->rectNormal = wndpl->rcNormalPosition;
1314 if( pWnd->dwStyle & WS_MINIMIZE )
1316 WINPOS_ShowIconTitle( pWnd, FALSE );
1317 if( wndpl->flags & WPF_SETMINPOSITION && !EMPTYPOINT(lpPos->ptIconPos))
1318 SetWindowPos32( hwnd, 0, lpPos->ptIconPos.x, lpPos->ptIconPos.y,
1319 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE );
1321 else if( pWnd->dwStyle & WS_MAXIMIZE )
1323 if( !EMPTYPOINT(lpPos->ptMaxPos) )
1324 SetWindowPos32( hwnd, 0, lpPos->ptMaxPos.x, lpPos->ptMaxPos.y,
1325 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE );
1327 else if( flags & PLACE_RECT )
1328 SetWindowPos32( hwnd, 0, lpPos->rectNormal.left, lpPos->rectNormal.top,
1329 lpPos->rectNormal.right - lpPos->rectNormal.left,
1330 lpPos->rectNormal.bottom - lpPos->rectNormal.top,
1331 SWP_NOZORDER | SWP_NOACTIVATE );
1333 ShowWindow32( hwnd, wndpl->showCmd );
1334 if( IsWindow32(hwnd) && pWnd->dwStyle & WS_MINIMIZE )
1336 if( pWnd->dwStyle & WS_VISIBLE ) WINPOS_ShowIconTitle( pWnd, TRUE );
1338 /* SDK: ...valid only the next time... */
1339 if( wndpl->flags & WPF_RESTORETOMAXIMIZED ) pWnd->flags |= WIN_RESTORE_MAX;
1341 return TRUE;
1343 return FALSE;
1347 /***********************************************************************
1348 * SetWindowPlacement16 (USER.371)
1350 BOOL16 WINAPI SetWindowPlacement16(HWND16 hwnd, const WINDOWPLACEMENT16 *wndpl)
1352 return WINPOS_SetPlacement( hwnd, wndpl,
1353 PLACE_MIN | PLACE_MAX | PLACE_RECT );
1356 /***********************************************************************
1357 * SetWindowPlacement32 (USER32.519)
1359 BOOL32 WINAPI SetWindowPlacement32( HWND32 hwnd, const WINDOWPLACEMENT32 *pwpl32 )
1361 if( pwpl32 )
1363 WINDOWPLACEMENT16 wpl = { sizeof(WINDOWPLACEMENT16),
1364 pwpl32->flags, pwpl32->showCmd, { pwpl32->ptMinPosition.x,
1365 pwpl32->ptMinPosition.y }, { pwpl32->ptMaxPosition.x,
1366 pwpl32->ptMaxPosition.y }, { pwpl32->rcNormalPosition.left,
1367 pwpl32->rcNormalPosition.top, pwpl32->rcNormalPosition.right,
1368 pwpl32->rcNormalPosition.bottom } };
1370 return WINPOS_SetPlacement( hwnd, &wpl, PLACE_MIN | PLACE_MAX | PLACE_RECT );
1372 return FALSE;
1376 /***********************************************************************
1377 * SetInternalWindowPos16 (USER.461)
1379 void WINAPI SetInternalWindowPos16( HWND16 hwnd, UINT16 showCmd,
1380 LPRECT16 rect, LPPOINT16 pt )
1382 if( IsWindow16(hwnd) )
1384 WINDOWPLACEMENT16 wndpl;
1385 UINT32 flags;
1387 wndpl.length = sizeof(wndpl);
1388 wndpl.showCmd = showCmd;
1389 wndpl.flags = flags = 0;
1391 if( pt )
1393 flags |= PLACE_MIN;
1394 wndpl.flags |= WPF_SETMINPOSITION;
1395 wndpl.ptMinPosition = *pt;
1397 if( rect )
1399 flags |= PLACE_RECT;
1400 wndpl.rcNormalPosition = *rect;
1402 WINPOS_SetPlacement( hwnd, &wndpl, flags );
1407 /***********************************************************************
1408 * SetInternalWindowPos32 (USER32.483)
1410 void WINAPI SetInternalWindowPos32( HWND32 hwnd, UINT32 showCmd,
1411 LPRECT32 rect, LPPOINT32 pt )
1413 if( IsWindow32(hwnd) )
1415 WINDOWPLACEMENT16 wndpl;
1416 UINT32 flags;
1418 wndpl.length = sizeof(wndpl);
1419 wndpl.showCmd = showCmd;
1420 wndpl.flags = flags = 0;
1422 if( pt )
1424 flags |= PLACE_MIN;
1425 wndpl.flags |= WPF_SETMINPOSITION;
1426 CONV_POINT32TO16( pt, &wndpl.ptMinPosition );
1428 if( rect )
1430 flags |= PLACE_RECT;
1431 CONV_RECT32TO16( rect, &wndpl.rcNormalPosition );
1433 WINPOS_SetPlacement( hwnd, &wndpl, flags );
1437 /*******************************************************************
1438 * WINPOS_SetActiveWindow
1440 * SetActiveWindow() back-end. This is the only function that
1441 * can assign active status to a window. It must be called only
1442 * for the top level windows.
1444 BOOL32 WINPOS_SetActiveWindow( HWND32 hWnd, BOOL32 fMouse, BOOL32 fChangeFocus)
1446 CBTACTIVATESTRUCT16* cbtStruct;
1447 WND* wndPtr, *wndTemp;
1448 HQUEUE16 hOldActiveQueue, hNewActiveQueue;
1449 WORD wIconized = 0;
1451 /* paranoid checks */
1452 if( hWnd == GetDesktopWindow32() || hWnd == hwndActive ) return 0;
1454 /* if (wndPtr && (GetFastQueue() != wndPtr->hmemTaskQ))
1455 * return 0;
1457 wndPtr = WIN_FindWndPtr(hWnd);
1458 hOldActiveQueue = (pActiveQueue)?pActiveQueue->self : 0;
1460 if( (wndTemp = WIN_FindWndPtr(hwndActive)) )
1461 wIconized = HIWORD(wndTemp->dwStyle & WS_MINIMIZE);
1462 else
1463 TRACE(win,"no current active window.\n");
1465 /* call CBT hook chain */
1466 if ((cbtStruct = SEGPTR_NEW(CBTACTIVATESTRUCT16)))
1468 LRESULT wRet;
1469 cbtStruct->fMouse = fMouse;
1470 cbtStruct->hWndActive = hwndActive;
1471 wRet = HOOK_CallHooks16( WH_CBT, HCBT_ACTIVATE, (WPARAM16)hWnd,
1472 (LPARAM)SEGPTR_GET(cbtStruct) );
1473 SEGPTR_FREE(cbtStruct);
1474 if (wRet) return wRet;
1477 /* set prev active wnd to current active wnd and send notification */
1478 if ((hwndPrevActive = hwndActive) && IsWindow32(hwndPrevActive))
1480 if (!SendMessage32A( hwndPrevActive, WM_NCACTIVATE, FALSE, 0 ))
1482 if (GetSysModalWindow16() != hWnd) return 0;
1483 /* disregard refusal if hWnd is sysmodal */
1486 #if 1
1487 SendMessage32A( hwndPrevActive, WM_ACTIVATE,
1488 MAKEWPARAM( WA_INACTIVE, wIconized ),
1489 (LPARAM)hWnd );
1490 #else
1491 /* FIXME: must be SendMessage16() because 32A doesn't do
1492 * intertask at this time */
1493 SendMessage16( hwndPrevActive, WM_ACTIVATE, WA_INACTIVE,
1494 MAKELPARAM( (HWND16)hWnd, wIconized ) );
1495 #endif
1497 /* check if something happened during message processing */
1498 if( hwndPrevActive != hwndActive ) return 0;
1501 /* set active wnd */
1502 hwndActive = hWnd;
1504 /* send palette messages */
1505 if (hWnd && SendMessage16( hWnd, WM_QUERYNEWPALETTE, 0, 0L))
1506 SendMessage16((HWND16)-1, WM_PALETTEISCHANGING, (WPARAM16)hWnd, 0L );
1508 /* if prev wnd is minimized redraw icon title */
1509 if( IsIconic32( hwndPrevActive ) ) WINPOS_RedrawIconTitle(hwndPrevActive);
1511 /* managed windows will get ConfigureNotify event */
1512 if (wndPtr && !(wndPtr->dwStyle & WS_CHILD) && !(wndPtr->flags & WIN_MANAGED))
1514 /* check Z-order and bring hWnd to the top */
1515 for (wndTemp = WIN_GetDesktop()->child; wndTemp; wndTemp = wndTemp->next)
1516 if (wndTemp->dwStyle & WS_VISIBLE) break;
1518 if( wndTemp != wndPtr )
1519 SetWindowPos32(hWnd, HWND_TOP, 0,0,0,0,
1520 SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE );
1521 if (!IsWindow32(hWnd)) return 0;
1524 hNewActiveQueue = wndPtr ? wndPtr->hmemTaskQ : 0;
1526 /* send WM_ACTIVATEAPP if necessary */
1527 if (hOldActiveQueue != hNewActiveQueue)
1529 WND **list, **ppWnd;
1531 if ((list = WIN_BuildWinArray( WIN_GetDesktop(), 0, NULL )))
1533 for (ppWnd = list; *ppWnd; ppWnd++)
1535 if (!IsWindow32( (*ppWnd)->hwndSelf )) continue;
1537 if ((*ppWnd)->hmemTaskQ == hOldActiveQueue)
1538 SendMessage16( (*ppWnd)->hwndSelf, WM_ACTIVATEAPP,
1539 0, QUEUE_GetQueueTask(hNewActiveQueue) );
1541 HeapFree( SystemHeap, 0, list );
1544 pActiveQueue = (hNewActiveQueue)
1545 ? (MESSAGEQUEUE*) GlobalLock16(hNewActiveQueue) : NULL;
1547 if ((list = WIN_BuildWinArray( WIN_GetDesktop(), 0, NULL )))
1549 for (ppWnd = list; *ppWnd; ppWnd++)
1551 if (!IsWindow32( (*ppWnd)->hwndSelf )) continue;
1553 if ((*ppWnd)->hmemTaskQ == hNewActiveQueue)
1554 SendMessage16( (*ppWnd)->hwndSelf, WM_ACTIVATEAPP,
1555 1, QUEUE_GetQueueTask( hOldActiveQueue ) );
1557 HeapFree( SystemHeap, 0, list );
1559 if (!IsWindow32(hWnd)) return 0;
1562 if (hWnd)
1564 /* walk up to the first unowned window */
1565 wndTemp = wndPtr;
1566 while (wndTemp->owner) wndTemp = wndTemp->owner;
1567 /* and set last active owned popup */
1568 wndTemp->hwndLastActive = hWnd;
1570 wIconized = HIWORD(wndTemp->dwStyle & WS_MINIMIZE);
1571 SendMessage32A( hWnd, WM_NCACTIVATE, TRUE, 0 );
1572 #if 1
1573 SendMessage32A( hWnd, WM_ACTIVATE,
1574 MAKEWPARAM( (fMouse) ? WA_CLICKACTIVE : WA_ACTIVE, wIconized),
1575 (LPARAM)hwndPrevActive );
1576 #else
1577 SendMessage16(hWnd, WM_ACTIVATE, (fMouse) ? WA_CLICKACTIVE : WA_ACTIVE,
1578 MAKELPARAM( (HWND16)hwndPrevActive, wIconized) );
1579 #endif
1581 if( !IsWindow32(hWnd) ) return 0;
1584 /* change focus if possible */
1585 if( fChangeFocus && GetFocus32() )
1586 if( WIN_GetTopParent(GetFocus32()) != hwndActive )
1587 FOCUS_SwitchFocus( GetFocus32(),
1588 (wndPtr && (wndPtr->dwStyle & WS_MINIMIZE))?
1590 hwndActive
1593 if( !hwndPrevActive && wndPtr )
1594 (*wndPtr->pDriver->pForceWindowRaise)(wndPtr);
1596 /* if active wnd is minimized redraw icon title */
1597 if( IsIconic32(hwndActive) ) WINPOS_RedrawIconTitle(hwndActive);
1599 return (hWnd == hwndActive);
1602 /*******************************************************************
1603 * WINPOS_ActivateOtherWindow
1605 * Activates window other than pWnd.
1607 BOOL32 WINPOS_ActivateOtherWindow(WND* pWnd)
1609 BOOL32 bRet = 0;
1610 WND* pWndTo = NULL;
1612 if( pWnd->hwndSelf == hwndPrevActive )
1613 hwndPrevActive = 0;
1615 if( hwndActive != pWnd->hwndSelf &&
1616 ( hwndActive || QUEUE_IsExitingQueue(pWnd->hmemTaskQ)) )
1617 return 0;
1619 if( !(pWnd->dwStyle & WS_POPUP) || !(pWnd->owner) ||
1620 !WINPOS_CanActivate((pWndTo = WIN_GetTopParentPtr(pWnd->owner))) )
1622 WND* pWndPtr = WIN_GetTopParentPtr(pWnd);
1624 pWndTo = WIN_FindWndPtr(hwndPrevActive);
1626 while( !WINPOS_CanActivate(pWndTo) )
1628 /* by now owned windows should've been taken care of */
1630 pWndTo = pWndPtr->next;
1631 pWndPtr = pWndTo;
1632 if( !pWndTo ) break;
1636 bRet = WINPOS_SetActiveWindow( pWndTo ? pWndTo->hwndSelf : 0, FALSE, TRUE );
1638 /* switch desktop queue to current active */
1639 if( pWndTo ) WIN_GetDesktop()->hmemTaskQ = pWndTo->hmemTaskQ;
1641 hwndPrevActive = 0;
1642 return bRet;
1645 /*******************************************************************
1646 * WINPOS_ChangeActiveWindow
1649 BOOL32 WINPOS_ChangeActiveWindow( HWND32 hWnd, BOOL32 mouseMsg )
1651 WND *wndPtr = WIN_FindWndPtr(hWnd);
1653 if (!hWnd) return WINPOS_SetActiveWindow( 0, mouseMsg, TRUE );
1655 if( !wndPtr ) return FALSE;
1657 /* child windows get WM_CHILDACTIVATE message */
1658 if( (wndPtr->dwStyle & (WS_CHILD | WS_POPUP)) == WS_CHILD )
1659 return SendMessage32A(hWnd, WM_CHILDACTIVATE, 0, 0L);
1661 /* owned popups imply owner activation - not sure */
1662 if ((wndPtr->dwStyle & WS_POPUP) && wndPtr->owner &&
1663 (wndPtr->owner->dwStyle & WS_VISIBLE ) &&
1664 !(wndPtr->owner->dwStyle & WS_DISABLED ))
1666 if (!(wndPtr = wndPtr->owner)) return FALSE;
1667 hWnd = wndPtr->hwndSelf;
1670 if( hWnd == hwndActive ) return FALSE;
1672 if( !WINPOS_SetActiveWindow(hWnd ,mouseMsg ,TRUE) )
1673 return FALSE;
1675 /* switch desktop queue to current active */
1676 if( wndPtr->parent == WIN_GetDesktop())
1677 WIN_GetDesktop()->hmemTaskQ = wndPtr->hmemTaskQ;
1679 return TRUE;
1683 /***********************************************************************
1684 * WINPOS_SendNCCalcSize
1686 * Send a WM_NCCALCSIZE message to a window.
1687 * All parameters are read-only except newClientRect.
1688 * oldWindowRect, oldClientRect and winpos must be non-NULL only
1689 * when calcValidRect is TRUE.
1691 LONG WINPOS_SendNCCalcSize( HWND32 hwnd, BOOL32 calcValidRect,
1692 RECT32 *newWindowRect, RECT32 *oldWindowRect,
1693 RECT32 *oldClientRect, WINDOWPOS32 *winpos,
1694 RECT32 *newClientRect )
1696 NCCALCSIZE_PARAMS32 params;
1697 WINDOWPOS32 winposCopy;
1698 LONG result;
1700 params.rgrc[0] = *newWindowRect;
1701 if (calcValidRect)
1703 winposCopy = *winpos;
1704 params.rgrc[1] = *oldWindowRect;
1705 params.rgrc[2] = *oldClientRect;
1706 params.lppos = &winposCopy;
1708 result = SendMessage32A( hwnd, WM_NCCALCSIZE, calcValidRect,
1709 (LPARAM)&params );
1710 TRACE(win, "%d,%d-%d,%d\n",
1711 params.rgrc[0].left, params.rgrc[0].top,
1712 params.rgrc[0].right, params.rgrc[0].bottom );
1713 *newClientRect = params.rgrc[0];
1714 return result;
1718 /***********************************************************************
1719 * WINPOS_HandleWindowPosChanging16
1721 * Default handling for a WM_WINDOWPOSCHANGING. Called from DefWindowProc().
1723 LONG WINPOS_HandleWindowPosChanging16( WND *wndPtr, WINDOWPOS16 *winpos )
1725 POINT32 maxSize, minTrack;
1726 if (winpos->flags & SWP_NOSIZE) return 0;
1727 if ((wndPtr->dwStyle & WS_THICKFRAME) ||
1728 ((wndPtr->dwStyle & (WS_POPUP | WS_CHILD)) == 0))
1730 WINPOS_GetMinMaxInfo( wndPtr, &maxSize, NULL, &minTrack, NULL );
1731 if (maxSize.x < winpos->cx) winpos->cx = maxSize.x;
1732 if (maxSize.y < winpos->cy) winpos->cy = maxSize.y;
1733 if (!(wndPtr->dwStyle & WS_MINIMIZE))
1735 if (winpos->cx < minTrack.x ) winpos->cx = minTrack.x;
1736 if (winpos->cy < minTrack.y ) winpos->cy = minTrack.y;
1739 return 0;
1743 /***********************************************************************
1744 * WINPOS_HandleWindowPosChanging32
1746 * Default handling for a WM_WINDOWPOSCHANGING. Called from DefWindowProc().
1748 LONG WINPOS_HandleWindowPosChanging32( WND *wndPtr, WINDOWPOS32 *winpos )
1750 POINT32 maxSize;
1751 if (winpos->flags & SWP_NOSIZE) return 0;
1752 if ((wndPtr->dwStyle & WS_THICKFRAME) ||
1753 ((wndPtr->dwStyle & (WS_POPUP | WS_CHILD)) == 0))
1755 WINPOS_GetMinMaxInfo( wndPtr, &maxSize, NULL, NULL, NULL );
1756 winpos->cx = MIN( winpos->cx, maxSize.x );
1757 winpos->cy = MIN( winpos->cy, maxSize.y );
1759 return 0;
1763 /***********************************************************************
1764 * WINPOS_MoveWindowZOrder
1766 * Move a window in Z order, invalidating everything that needs it.
1767 * Only necessary for windows without associated X window.
1769 static void WINPOS_MoveWindowZOrder( HWND32 hwnd, HWND32 hwndAfter )
1771 BOOL32 movingUp;
1772 WND *pWndAfter, *pWndCur, *wndPtr = WIN_FindWndPtr( hwnd );
1774 /* We have two possible cases:
1775 * - The window is moving up: we have to invalidate all areas
1776 * of the window that were covered by other windows
1777 * - The window is moving down: we have to invalidate areas
1778 * of other windows covered by this one.
1781 if (hwndAfter == HWND_TOP)
1783 movingUp = TRUE;
1785 else if (hwndAfter == HWND_BOTTOM)
1787 if (!wndPtr->next) return; /* Already at the bottom */
1788 movingUp = FALSE;
1790 else
1792 if (!(pWndAfter = WIN_FindWndPtr( hwndAfter ))) return;
1793 if (wndPtr->next == pWndAfter) return; /* Already placed right */
1795 /* Determine which window we encounter first in Z-order */
1796 pWndCur = wndPtr->parent->child;
1797 while ((pWndCur != wndPtr) && (pWndCur != pWndAfter))
1798 pWndCur = pWndCur->next;
1799 movingUp = (pWndCur == pWndAfter);
1802 if (movingUp)
1804 WND *pWndPrevAfter = wndPtr->next;
1805 WIN_UnlinkWindow( hwnd );
1806 WIN_LinkWindow( hwnd, hwndAfter );
1807 pWndCur = wndPtr->next;
1808 while (pWndCur != pWndPrevAfter)
1810 RECT32 rect = { pWndCur->rectWindow.left,
1811 pWndCur->rectWindow.top,
1812 pWndCur->rectWindow.right,
1813 pWndCur->rectWindow.bottom };
1814 OffsetRect32( &rect, -wndPtr->rectClient.left,
1815 -wndPtr->rectClient.top );
1816 PAINT_RedrawWindow( hwnd, &rect, 0, RDW_INVALIDATE | RDW_ALLCHILDREN |
1817 RDW_FRAME | RDW_ERASE, 0 );
1818 pWndCur = pWndCur->next;
1821 else /* Moving down */
1823 pWndCur = wndPtr->next;
1824 WIN_UnlinkWindow( hwnd );
1825 WIN_LinkWindow( hwnd, hwndAfter );
1826 while (pWndCur != wndPtr)
1828 RECT32 rect = { pWndCur->rectWindow.left,
1829 pWndCur->rectWindow.top,
1830 pWndCur->rectWindow.right,
1831 pWndCur->rectWindow.bottom };
1832 OffsetRect32( &rect, -pWndCur->rectClient.left,
1833 -pWndCur->rectClient.top );
1834 PAINT_RedrawWindow( pWndCur->hwndSelf, &rect, 0, RDW_INVALIDATE |
1835 RDW_ALLCHILDREN | RDW_FRAME | RDW_ERASE, 0 );
1836 pWndCur = pWndCur->next;
1841 /***********************************************************************
1842 * WINPOS_ReorderOwnedPopups
1844 * fix Z order taking into account owned popups -
1845 * basically we need to maintain them above the window that owns them
1847 HWND32 WINPOS_ReorderOwnedPopups(HWND32 hwndInsertAfter,WND* wndPtr,WORD flags)
1849 WND* w = WIN_GetDesktop()->child;
1851 if( wndPtr->dwStyle & WS_POPUP && wndPtr->owner )
1853 /* implement "local z-order" between the top and owner window */
1855 HWND32 hwndLocalPrev = HWND_TOP;
1857 if( hwndInsertAfter != HWND_TOP )
1859 while( w != wndPtr->owner )
1861 if (w != wndPtr) hwndLocalPrev = w->hwndSelf;
1862 if( hwndLocalPrev == hwndInsertAfter ) break;
1863 w = w->next;
1865 hwndInsertAfter = hwndLocalPrev;
1869 else if( wndPtr->dwStyle & WS_CHILD ) return hwndInsertAfter;
1871 w = WIN_GetDesktop()->child;
1872 while( w )
1874 if( w == wndPtr ) break;
1876 if( w->dwStyle & WS_POPUP && w->owner == wndPtr )
1878 SetWindowPos32(w->hwndSelf, hwndInsertAfter, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE |
1879 SWP_NOACTIVATE | SWP_NOSENDCHANGING | SWP_DEFERERASE);
1880 hwndInsertAfter = w->hwndSelf;
1882 w = w->next;
1885 return hwndInsertAfter;
1888 /***********************************************************************
1889 * WINPOS_SizeMoveClean
1891 * Make window look nice without excessive repainting
1893 * the pain:
1895 * visible regions are in window coordinates
1896 * update regions are in window client coordinates
1897 * client and window rectangles are in parent client coordinates
1899 * FIXME: Move visible and update regions to the same coordinate system
1900 * (either parent client or window). This is a lot of work though.
1902 static UINT32 WINPOS_SizeMoveClean( WND* Wnd, HRGN32 oldVisRgn,
1903 LPRECT32 lpOldWndRect,
1904 LPRECT32 lpOldClientRect, UINT32 uFlags )
1906 HRGN32 newVisRgn = DCE_GetVisRgn(Wnd->hwndSelf,DCX_WINDOW | DCX_CLIPSIBLINGS);
1907 HRGN32 dirtyRgn = CreateRectRgn32(0,0,0,0);
1908 int other, my;
1910 TRACE(win,"cleaning up...new wnd=(%i %i-%i %i) old wnd=(%i %i-%i %i)\n",
1911 Wnd->rectWindow.left, Wnd->rectWindow.top,
1912 Wnd->rectWindow.right, Wnd->rectWindow.bottom,
1913 lpOldWndRect->left, lpOldWndRect->top,
1914 lpOldWndRect->right, lpOldWndRect->bottom);
1915 TRACE(win,"\tnew client=(%i %i-%i %i) old client=(%i %i-%i %i)\n",
1916 Wnd->rectClient.left, Wnd->rectClient.top,
1917 Wnd->rectClient.right, Wnd->rectClient.bottom,
1918 lpOldClientRect->left, lpOldClientRect->top,
1919 lpOldClientRect->right,lpOldClientRect->bottom );
1921 if( (lpOldWndRect->right - lpOldWndRect->left) != (Wnd->rectWindow.right - Wnd->rectWindow.left) ||
1922 (lpOldWndRect->bottom - lpOldWndRect->top) != (Wnd->rectWindow.bottom - Wnd->rectWindow.top) )
1923 uFlags |= SMC_DRAWFRAME;
1925 CombineRgn32( dirtyRgn, newVisRgn, 0, RGN_COPY);
1927 if( !(uFlags & SMC_NOCOPY) )
1928 CombineRgn32( newVisRgn, newVisRgn, oldVisRgn, RGN_AND );
1930 /* map regions to the parent client area */
1932 OffsetRgn32( dirtyRgn, Wnd->rectWindow.left, Wnd->rectWindow.top );
1933 OffsetRgn32( oldVisRgn, lpOldWndRect->left, lpOldWndRect->top );
1935 /* compute invalidated region outside Wnd - (in client coordinates of the parent window) */
1937 other = CombineRgn32(dirtyRgn, oldVisRgn, dirtyRgn, RGN_DIFF);
1939 /* map visible region to the Wnd client area */
1941 OffsetRgn32( newVisRgn, Wnd->rectWindow.left - Wnd->rectClient.left,
1942 Wnd->rectWindow.top - Wnd->rectClient.top );
1944 /* substract previously invalidated region from the Wnd visible region */
1946 my = (Wnd->hrgnUpdate > 1) ? CombineRgn32( newVisRgn, newVisRgn,
1947 Wnd->hrgnUpdate, RGN_DIFF)
1948 : COMPLEXREGION;
1950 if( uFlags & SMC_NOCOPY ) /* invalidate Wnd visible region */
1952 if (my != NULLREGION)
1953 PAINT_RedrawWindow( Wnd->hwndSelf, NULL, newVisRgn, RDW_INVALIDATE |
1954 RDW_FRAME | RDW_ALLCHILDREN | RDW_ERASE, RDW_C_USEHRGN );
1955 else if(uFlags & SMC_DRAWFRAME)
1956 Wnd->flags |= WIN_NEEDS_NCPAINT;
1958 else /* bitblt old client area */
1960 HDC32 hDC;
1961 int update;
1962 HRGN32 updateRgn;
1963 int xfrom,yfrom,xto,yto,width,height;
1965 if( uFlags & SMC_DRAWFRAME )
1967 /* copy only client area, frame will be redrawn anyway */
1969 xfrom = lpOldClientRect->left; yfrom = lpOldClientRect->top;
1970 xto = Wnd->rectClient.left; yto = Wnd->rectClient.top;
1971 width = lpOldClientRect->right - xfrom; height = lpOldClientRect->bottom - yfrom;
1972 updateRgn = CreateRectRgn32( 0, 0, width, height );
1973 CombineRgn32( newVisRgn, newVisRgn, updateRgn, RGN_AND );
1974 SetRectRgn32( updateRgn, 0, 0, Wnd->rectClient.right - xto,
1975 Wnd->rectClient.bottom - yto );
1977 else
1979 xfrom = lpOldWndRect->left; yfrom = lpOldWndRect->top;
1980 xto = Wnd->rectWindow.left; yto = Wnd->rectWindow.top;
1981 width = lpOldWndRect->right - xfrom; height = lpOldWndRect->bottom - yfrom;
1982 updateRgn = CreateRectRgn32( xto - Wnd->rectClient.left,
1983 yto - Wnd->rectClient.top,
1984 Wnd->rectWindow.right - Wnd->rectClient.left,
1985 Wnd->rectWindow.bottom - Wnd->rectClient.top );
1988 CombineRgn32( newVisRgn, newVisRgn, updateRgn, RGN_AND );
1990 /* substract new visRgn from target rect to get a region that won't be copied */
1992 update = CombineRgn32( updateRgn, updateRgn, newVisRgn, RGN_DIFF );
1994 /* Blt valid bits using parent window DC */
1996 if( my != NULLREGION && (xfrom != xto || yfrom != yto) )
1999 /* compute clipping region in parent client coordinates */
2001 OffsetRgn32( newVisRgn, Wnd->rectClient.left, Wnd->rectClient.top );
2002 CombineRgn32( oldVisRgn, oldVisRgn, newVisRgn, RGN_OR );
2004 hDC = GetDCEx32( Wnd->parent->hwndSelf, oldVisRgn,
2005 DCX_KEEPCLIPRGN | DCX_INTERSECTRGN |
2006 DCX_CACHE | DCX_CLIPSIBLINGS);
2008 BitBlt32( hDC, xto, yto, width, height, hDC, xfrom, yfrom, SRCCOPY );
2009 ReleaseDC32( Wnd->parent->hwndSelf, hDC);
2012 if( update != NULLREGION )
2013 PAINT_RedrawWindow( Wnd->hwndSelf, NULL, updateRgn, RDW_INVALIDATE |
2014 RDW_FRAME | RDW_ALLCHILDREN | RDW_ERASE, RDW_C_USEHRGN );
2015 else if( uFlags & SMC_DRAWFRAME ) Wnd->flags |= WIN_NEEDS_NCPAINT;
2016 DeleteObject32( updateRgn );
2019 /* erase uncovered areas */
2021 if( !(uFlags & SMC_NOPARENTERASE) && (other != NULLREGION ) )
2022 PAINT_RedrawWindow( Wnd->parent->hwndSelf, NULL, dirtyRgn,
2023 RDW_INVALIDATE | RDW_ALLCHILDREN | RDW_ERASE, RDW_C_USEHRGN );
2024 DeleteObject32(dirtyRgn);
2025 DeleteObject32(newVisRgn);
2026 return uFlags;
2029 /***********************************************************************
2030 * SetWindowPos (USER.232)
2032 BOOL16 WINAPI SetWindowPos16( HWND16 hwnd, HWND16 hwndInsertAfter,
2033 INT16 x, INT16 y, INT16 cx, INT16 cy, WORD flags)
2035 return SetWindowPos32(hwnd,(INT32)(INT16)hwndInsertAfter,x,y,cx,cy,flags);
2038 /***********************************************************************
2039 * SetWindowPos (USER32.520)
2041 BOOL32 WINAPI SetWindowPos32( HWND32 hwnd, HWND32 hwndInsertAfter,
2042 INT32 x, INT32 y, INT32 cx, INT32 cy, WORD flags)
2044 WINDOWPOS32 winpos;
2045 WND * wndPtr;
2046 RECT32 newWindowRect, newClientRect, oldWindowRect;
2047 HRGN32 visRgn = 0;
2048 HWND32 tempInsertAfter= 0;
2049 int result = 0;
2050 UINT32 uFlags = 0;
2051 BOOL32 resync = FALSE;
2053 TRACE(win,"hwnd %04x, (%i,%i)-(%i,%i) flags %08x\n",
2054 hwnd, x, y, x+cx, y+cy, flags);
2055 /* Check window handle */
2057 if (hwnd == GetDesktopWindow32()) return FALSE;
2058 if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return FALSE;
2060 if(wndPtr->dwStyle & WS_VISIBLE)
2061 flags &= ~SWP_SHOWWINDOW;
2062 else
2064 uFlags |= SMC_NOPARENTERASE;
2065 flags &= ~SWP_HIDEWINDOW;
2066 if (!(flags & SWP_SHOWWINDOW)) flags |= SWP_NOREDRAW;
2069 /* Check for windows that may not be resized
2070 FIXME: this should be done only for Windows 3.0 programs
2071 if (flags & (SWP_SHOWWINDOW | SWP_HIDEWINDOW ) )
2072 flags |= SWP_NOSIZE | SWP_NOMOVE;
2074 /* Check dimensions */
2076 if (cx <= 0) cx = 1;
2077 if (cy <= 0) cy = 1;
2079 /* Check flags */
2081 if (hwnd == hwndActive) flags |= SWP_NOACTIVATE; /* Already active */
2082 if ((wndPtr->rectWindow.right - wndPtr->rectWindow.left == cx) &&
2083 (wndPtr->rectWindow.bottom - wndPtr->rectWindow.top == cy))
2084 flags |= SWP_NOSIZE; /* Already the right size */
2085 if ((wndPtr->rectWindow.left == x) && (wndPtr->rectWindow.top == y))
2086 flags |= SWP_NOMOVE; /* Already the right position */
2088 /* Check hwndInsertAfter */
2090 if (!(flags & (SWP_NOZORDER | SWP_NOACTIVATE)))
2092 /* Ignore TOPMOST flags when activating a window */
2093 /* _and_ moving it in Z order. */
2094 if ((hwndInsertAfter == HWND_TOPMOST) ||
2095 (hwndInsertAfter == HWND_NOTOPMOST))
2096 hwndInsertAfter = HWND_TOP;
2098 /* TOPMOST not supported yet */
2099 if ((hwndInsertAfter == HWND_TOPMOST) ||
2100 (hwndInsertAfter == HWND_NOTOPMOST)) hwndInsertAfter = HWND_TOP;
2102 /* hwndInsertAfter must be a sibling of the window */
2103 if ((hwndInsertAfter != HWND_TOP) && (hwndInsertAfter != HWND_BOTTOM))
2105 WND* wnd = WIN_FindWndPtr(hwndInsertAfter);
2107 if( wndPtr ) {
2108 if( wnd->parent != wndPtr->parent ) return FALSE;
2109 if( wnd->next == wndPtr ) flags |= SWP_NOZORDER;
2112 else if (!((X11DRV_WND_DATA *) wndPtr->pDriverData)->window)
2114 /* FIXME: the following optimization is no good for "X-ed" windows */
2115 if (hwndInsertAfter == HWND_TOP)
2116 flags |= ( wndPtr->parent->child == wndPtr)? SWP_NOZORDER: 0;
2117 else /* HWND_BOTTOM */
2118 flags |= ( wndPtr->next )? 0: SWP_NOZORDER;
2121 /* Fill the WINDOWPOS structure */
2123 winpos.hwnd = hwnd;
2124 winpos.hwndInsertAfter = hwndInsertAfter;
2125 winpos.x = x;
2126 winpos.y = y;
2127 winpos.cx = cx;
2128 winpos.cy = cy;
2129 winpos.flags = flags;
2131 /* Send WM_WINDOWPOSCHANGING message */
2133 if (!(winpos.flags & SWP_NOSENDCHANGING))
2134 SendMessage32A( hwnd, WM_WINDOWPOSCHANGING, 0, (LPARAM)&winpos );
2136 /* Calculate new position and size */
2138 newWindowRect = wndPtr->rectWindow;
2139 newClientRect = (wndPtr->dwStyle & WS_MINIMIZE) ? wndPtr->rectWindow
2140 : wndPtr->rectClient;
2142 if (!(winpos.flags & SWP_NOSIZE))
2144 newWindowRect.right = newWindowRect.left + winpos.cx;
2145 newWindowRect.bottom = newWindowRect.top + winpos.cy;
2147 if (!(winpos.flags & SWP_NOMOVE))
2149 newWindowRect.left = winpos.x;
2150 newWindowRect.top = winpos.y;
2151 newWindowRect.right += winpos.x - wndPtr->rectWindow.left;
2152 newWindowRect.bottom += winpos.y - wndPtr->rectWindow.top;
2154 OffsetRect32( &newClientRect, winpos.x - wndPtr->rectWindow.left,
2155 winpos.y - wndPtr->rectWindow.top );
2158 winpos.flags |= SWP_NOCLIENTMOVE | SWP_NOCLIENTSIZE;
2160 /* Reposition window in Z order */
2162 if (!(winpos.flags & SWP_NOZORDER))
2164 /* reorder owned popups if hwnd is top-level window
2166 if( wndPtr->parent == WIN_GetDesktop() )
2167 hwndInsertAfter = WINPOS_ReorderOwnedPopups( hwndInsertAfter,
2168 wndPtr, winpos.flags );
2170 if (((X11DRV_WND_DATA *) wndPtr->pDriverData)->window)
2172 WIN_UnlinkWindow( winpos.hwnd );
2173 WIN_LinkWindow( winpos.hwnd, hwndInsertAfter );
2175 else WINPOS_MoveWindowZOrder( winpos.hwnd, hwndInsertAfter );
2178 if ( !((X11DRV_WND_DATA *) wndPtr->pDriverData)->window && !(winpos.flags & SWP_NOREDRAW) &&
2179 ((winpos.flags & (SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED))
2180 != (SWP_NOMOVE | SWP_NOSIZE)) )
2181 visRgn = DCE_GetVisRgn(hwnd, DCX_WINDOW | DCX_CLIPSIBLINGS);
2184 /* Send WM_NCCALCSIZE message to get new client area */
2185 if( (winpos.flags & (SWP_FRAMECHANGED | SWP_NOSIZE)) != SWP_NOSIZE )
2187 result = WINPOS_SendNCCalcSize( winpos.hwnd, TRUE, &newWindowRect,
2188 &wndPtr->rectWindow, &wndPtr->rectClient,
2189 &winpos, &newClientRect );
2191 /* FIXME: WVR_ALIGNxxx */
2193 if( newClientRect.left != wndPtr->rectClient.left ||
2194 newClientRect.top != wndPtr->rectClient.top )
2195 winpos.flags &= ~SWP_NOCLIENTMOVE;
2197 if( (newClientRect.right - newClientRect.left !=
2198 wndPtr->rectClient.right - wndPtr->rectClient.left) ||
2199 (newClientRect.bottom - newClientRect.top !=
2200 wndPtr->rectClient.bottom - wndPtr->rectClient.top) )
2201 winpos.flags &= ~SWP_NOCLIENTSIZE;
2203 else
2204 if( !(flags & SWP_NOMOVE) && (newClientRect.left != wndPtr->rectClient.left ||
2205 newClientRect.top != wndPtr->rectClient.top) )
2206 winpos.flags &= ~SWP_NOCLIENTMOVE;
2208 /* Update active DCEs
2209 * TODO: Optimize conditions that trigger DCE update.
2212 if( (((winpos.flags & SWP_AGG_NOPOSCHANGE) != SWP_AGG_NOPOSCHANGE) &&
2213 wndPtr->dwStyle & WS_VISIBLE) ||
2214 (flags & (SWP_HIDEWINDOW | SWP_SHOWWINDOW)) )
2216 RECT32 rect;
2218 UnionRect32(&rect, &newWindowRect, &wndPtr->rectWindow);
2219 DCE_InvalidateDCE(wndPtr, &rect);
2222 /* change geometry */
2224 oldWindowRect = wndPtr->rectWindow;
2226 if (((X11DRV_WND_DATA *) wndPtr->pDriverData)->window)
2228 RECT32 oldClientRect = wndPtr->rectClient;
2230 tempInsertAfter = winpos.hwndInsertAfter;
2232 winpos.hwndInsertAfter = hwndInsertAfter;
2234 /* postpone geometry change */
2236 if( !(flags & (SWP_SHOWWINDOW | SWP_HIDEWINDOW)) )
2238 wndPtr->pDriver->pSetWindowPos(wndPtr, &winpos, TRUE);
2239 winpos.hwndInsertAfter = tempInsertAfter;
2241 else uFlags |= SMC_SETXPOS;
2243 wndPtr->rectWindow = newWindowRect;
2244 wndPtr->rectClient = newClientRect;
2246 if( !(flags & (SWP_SHOWWINDOW | SWP_HIDEWINDOW)) )
2248 if( (oldClientRect.left - oldWindowRect.left !=
2249 newClientRect.left - newWindowRect.left) ||
2250 (oldClientRect.top - oldWindowRect.top !=
2251 newClientRect.top - newWindowRect.top) ||
2252 (winpos.flags & SWP_NOCOPYBITS) )
2254 /* if the client area moved as a result of WM_NCCALCSIZE returning
2255 * obscure WVR_ALIGNxxx flags then we simply redraw the whole thing
2257 * TODO: use WINPOS_SizeMoveClean() if there is no SWP_NOCOPYBITS
2260 PAINT_RedrawWindow( wndPtr->hwndSelf, NULL, 0, RDW_INVALIDATE |
2261 RDW_ALLCHILDREN | RDW_FRAME | RDW_ERASE, 0 );
2263 else
2264 if( winpos.flags & SWP_FRAMECHANGED )
2266 WORD wErase = 0;
2267 RECT32 rect;
2269 if( newClientRect.right > oldClientRect.right ) /* redraw exposed client area on the right */
2271 rect.top = 0; rect.bottom = newClientRect.bottom - newClientRect.top;
2272 rect.left = oldClientRect.right - newClientRect.left;
2273 rect.right = newClientRect.right - newClientRect.left;
2274 wErase = 1;
2275 PAINT_RedrawWindow( wndPtr->hwndSelf, &rect, 0,
2276 RDW_INVALIDATE | RDW_FRAME | RDW_ERASE | RDW_ERASENOW | RDW_ALLCHILDREN, 0 );
2278 if( newClientRect.bottom > oldClientRect.bottom ) /* redraw exposed client area on the bottom */
2280 rect.left = 0; rect.right = ((wErase)?oldClientRect.right:newClientRect.right) - newClientRect.left;
2281 rect.top = oldClientRect.bottom - newClientRect.top;
2282 rect.bottom = newClientRect.bottom - newClientRect.top;
2283 wErase = 1;
2284 PAINT_RedrawWindow( wndPtr->hwndSelf, &rect, 0,
2285 RDW_INVALIDATE | RDW_FRAME | RDW_ERASE | RDW_ERASENOW | RDW_ALLCHILDREN, 0 );
2287 if( !wErase ) /* just update the nonclient area */
2288 wndPtr->flags |= WIN_NEEDS_NCPAINT;
2291 uFlags |= SMC_NOPARENTERASE; /* X windows do not have eraseable parents */
2293 else /* not an X window */
2295 RECT32 oldClientRect = wndPtr->rectClient;
2297 wndPtr->rectWindow = newWindowRect;
2298 wndPtr->rectClient = newClientRect;
2300 if( oldClientRect.bottom - oldClientRect.top ==
2301 newClientRect.bottom - newClientRect.top ) result &= ~WVR_VREDRAW;
2303 if( oldClientRect.right - oldClientRect.left ==
2304 newClientRect.right - newClientRect.left ) result &= ~WVR_HREDRAW;
2306 if( !(flags & (SWP_NOREDRAW | SWP_HIDEWINDOW | SWP_SHOWWINDOW)) )
2308 uFlags |= ((winpos.flags & SWP_NOCOPYBITS) ||
2309 (result >= WVR_HREDRAW && result < WVR_VALIDRECTS)) ? SMC_NOCOPY : 0;
2310 uFlags |= (winpos.flags & SWP_FRAMECHANGED) ? SMC_DRAWFRAME : 0;
2312 if( (winpos.flags & SWP_AGG_NOGEOMETRYCHANGE) != SWP_AGG_NOGEOMETRYCHANGE )
2313 uFlags = WINPOS_SizeMoveClean(wndPtr, visRgn, &oldWindowRect,
2314 &oldClientRect, uFlags);
2315 else
2317 /* adjust the frame and do not erase the parent */
2319 if( winpos.flags & SWP_FRAMECHANGED ) wndPtr->flags |= WIN_NEEDS_NCPAINT;
2320 if( winpos.flags & SWP_NOZORDER ) uFlags |= SMC_NOPARENTERASE;
2323 DeleteObject32(visRgn);
2326 if (flags & SWP_SHOWWINDOW)
2328 wndPtr->dwStyle |= WS_VISIBLE;
2329 if (((X11DRV_WND_DATA *) wndPtr->pDriverData)->window)
2331 HWND32 focus, curr;
2333 wndPtr->pDriver->pSetWindowPos(wndPtr, &winpos, uFlags & SMC_SETXPOS );
2334 if( uFlags & SMC_SETXPOS )
2336 winpos.hwndInsertAfter = tempInsertAfter;
2339 if (wndPtr->flags & WIN_MANAGED) resync = TRUE;
2341 /* If focus was set to an unmapped window, reset X focus now */
2342 focus = curr = GetFocus32();
2343 while (curr) {
2344 if (curr == hwnd) {
2345 SetFocus32( 0 );
2346 SetFocus32( focus );
2347 break;
2349 curr = GetParent32(curr);
2352 else
2354 if (!(flags & SWP_NOREDRAW))
2355 PAINT_RedrawWindow( winpos.hwnd, NULL, 0,
2356 RDW_INVALIDATE | RDW_ALLCHILDREN |
2357 RDW_FRAME | RDW_ERASENOW | RDW_ERASE, 0 );
2360 else if (flags & SWP_HIDEWINDOW)
2362 wndPtr->dwStyle &= ~WS_VISIBLE;
2364 if (((X11DRV_WND_DATA *) wndPtr->pDriverData)->window)
2366 wndPtr->pDriver->pSetWindowPos(wndPtr, &winpos, uFlags & SMC_SETXPOS );
2367 if( uFlags & SMC_SETXPOS )
2369 winpos.hwndInsertAfter = tempInsertAfter;
2372 else
2374 if (!(flags & SWP_NOREDRAW))
2375 PAINT_RedrawWindow( wndPtr->parent->hwndSelf, &oldWindowRect,
2376 0, RDW_INVALIDATE | RDW_ALLCHILDREN |
2377 RDW_ERASE | RDW_ERASENOW, 0 );
2378 uFlags |= SMC_NOPARENTERASE;
2381 if ((winpos.hwnd == GetFocus32()) ||
2382 IsChild32( winpos.hwnd, GetFocus32()))
2384 /* Revert focus to parent */
2385 SetFocus32( GetParent32(winpos.hwnd) );
2387 if (hwnd == CARET_GetHwnd()) DestroyCaret32();
2389 if (winpos.hwnd == hwndActive)
2390 WINPOS_ActivateOtherWindow( wndPtr );
2393 /* Activate the window */
2395 if (!(flags & SWP_NOACTIVATE))
2396 WINPOS_ChangeActiveWindow( winpos.hwnd, FALSE );
2398 /* Repaint the window */
2400 if (((X11DRV_WND_DATA *) wndPtr->pDriverData)->window)
2401 EVENT_Synchronize(); /* Wait for all expose events */
2403 if (!GetCapture32())
2404 EVENT_DummyMotionNotify(); /* Simulate a mouse event to set the cursor */
2406 if (!(flags & SWP_DEFERERASE) && !(uFlags & SMC_NOPARENTERASE) )
2407 PAINT_RedrawWindow( wndPtr->parent->hwndSelf, NULL, 0, RDW_ALLCHILDREN | RDW_ERASENOW, 0 );
2408 else if( wndPtr->parent == WIN_GetDesktop() && wndPtr->parent->flags & WIN_NEEDS_ERASEBKGND )
2409 PAINT_RedrawWindow( wndPtr->parent->hwndSelf, NULL, 0, RDW_NOCHILDREN | RDW_ERASENOW, 0 );
2411 /* And last, send the WM_WINDOWPOSCHANGED message */
2413 TRACE(win,"\tstatus flags = %04x\n", winpos.flags & SWP_AGG_STATUSFLAGS);
2415 if ( resync ||
2416 (((winpos.flags & SWP_AGG_STATUSFLAGS) != SWP_AGG_NOPOSCHANGE) &&
2417 !(winpos.flags & SWP_NOSENDCHANGING)) )
2419 SendMessage32A( winpos.hwnd, WM_WINDOWPOSCHANGED, 0, (LPARAM)&winpos );
2420 if (resync) EVENT_Synchronize ();
2423 return TRUE;
2427 /***********************************************************************
2428 * BeginDeferWindowPos16 (USER.259)
2430 HDWP16 WINAPI BeginDeferWindowPos16( INT16 count )
2432 return BeginDeferWindowPos32( count );
2436 /***********************************************************************
2437 * BeginDeferWindowPos32 (USER32.9)
2439 HDWP32 WINAPI BeginDeferWindowPos32( INT32 count )
2441 HDWP32 handle;
2442 DWP *pDWP;
2444 if (count <= 0) return 0;
2445 handle = USER_HEAP_ALLOC( sizeof(DWP) + (count-1)*sizeof(WINDOWPOS32) );
2446 if (!handle) return 0;
2447 pDWP = (DWP *) USER_HEAP_LIN_ADDR( handle );
2448 pDWP->actualCount = 0;
2449 pDWP->suggestedCount = count;
2450 pDWP->valid = TRUE;
2451 pDWP->wMagic = DWP_MAGIC;
2452 pDWP->hwndParent = 0;
2453 return handle;
2457 /***********************************************************************
2458 * DeferWindowPos16 (USER.260)
2460 HDWP16 WINAPI DeferWindowPos16( HDWP16 hdwp, HWND16 hwnd, HWND16 hwndAfter,
2461 INT16 x, INT16 y, INT16 cx, INT16 cy,
2462 UINT16 flags )
2464 return DeferWindowPos32( hdwp, hwnd, (INT32)(INT16)hwndAfter,
2465 x, y, cx, cy, flags );
2469 /***********************************************************************
2470 * DeferWindowPos32 (USER32.128)
2472 HDWP32 WINAPI DeferWindowPos32( HDWP32 hdwp, HWND32 hwnd, HWND32 hwndAfter,
2473 INT32 x, INT32 y, INT32 cx, INT32 cy,
2474 UINT32 flags )
2476 DWP *pDWP;
2477 int i;
2478 HDWP32 newhdwp = hdwp;
2479 /* HWND32 parent; */
2480 WND *pWnd;
2482 pDWP = (DWP *) USER_HEAP_LIN_ADDR( hdwp );
2483 if (!pDWP) return 0;
2484 if (hwnd == GetDesktopWindow32()) return 0;
2486 if (!(pWnd=WIN_FindWndPtr( hwnd ))) {
2487 USER_HEAP_FREE( hdwp );
2488 return 0;
2491 /* Numega Bounds Checker Demo dislikes the following code.
2492 In fact, I've not been able to find any "same parent" requirement in any docu
2493 [AM 980509]
2495 #if 0
2496 /* All the windows of a DeferWindowPos() must have the same parent */
2497 parent = pWnd->parent->hwndSelf;
2498 if (pDWP->actualCount == 0) pDWP->hwndParent = parent;
2499 else if (parent != pDWP->hwndParent)
2501 USER_HEAP_FREE( hdwp );
2502 return 0;
2504 #endif
2506 for (i = 0; i < pDWP->actualCount; i++)
2508 if (pDWP->winPos[i].hwnd == hwnd)
2510 /* Merge with the other changes */
2511 if (!(flags & SWP_NOZORDER))
2513 pDWP->winPos[i].hwndInsertAfter = hwndAfter;
2515 if (!(flags & SWP_NOMOVE))
2517 pDWP->winPos[i].x = x;
2518 pDWP->winPos[i].y = y;
2520 if (!(flags & SWP_NOSIZE))
2522 pDWP->winPos[i].cx = cx;
2523 pDWP->winPos[i].cy = cy;
2525 pDWP->winPos[i].flags &= flags | ~(SWP_NOSIZE | SWP_NOMOVE |
2526 SWP_NOZORDER | SWP_NOREDRAW |
2527 SWP_NOACTIVATE | SWP_NOCOPYBITS|
2528 SWP_NOOWNERZORDER);
2529 pDWP->winPos[i].flags |= flags & (SWP_SHOWWINDOW | SWP_HIDEWINDOW |
2530 SWP_FRAMECHANGED);
2531 return hdwp;
2534 if (pDWP->actualCount >= pDWP->suggestedCount)
2536 newhdwp = USER_HEAP_REALLOC( hdwp,
2537 sizeof(DWP) + pDWP->suggestedCount*sizeof(WINDOWPOS32) );
2538 if (!newhdwp) return 0;
2539 pDWP = (DWP *) USER_HEAP_LIN_ADDR( newhdwp );
2540 pDWP->suggestedCount++;
2542 pDWP->winPos[pDWP->actualCount].hwnd = hwnd;
2543 pDWP->winPos[pDWP->actualCount].hwndInsertAfter = hwndAfter;
2544 pDWP->winPos[pDWP->actualCount].x = x;
2545 pDWP->winPos[pDWP->actualCount].y = y;
2546 pDWP->winPos[pDWP->actualCount].cx = cx;
2547 pDWP->winPos[pDWP->actualCount].cy = cy;
2548 pDWP->winPos[pDWP->actualCount].flags = flags;
2549 pDWP->actualCount++;
2550 return newhdwp;
2554 /***********************************************************************
2555 * EndDeferWindowPos16 (USER.261)
2557 BOOL16 WINAPI EndDeferWindowPos16( HDWP16 hdwp )
2559 return EndDeferWindowPos32( hdwp );
2563 /***********************************************************************
2564 * EndDeferWindowPos32 (USER32.173)
2566 BOOL32 WINAPI EndDeferWindowPos32( HDWP32 hdwp )
2568 DWP *pDWP;
2569 WINDOWPOS32 *winpos;
2570 BOOL32 res = TRUE;
2571 int i;
2573 pDWP = (DWP *) USER_HEAP_LIN_ADDR( hdwp );
2574 if (!pDWP) return FALSE;
2575 for (i = 0, winpos = pDWP->winPos; i < pDWP->actualCount; i++, winpos++)
2577 if (!(res = SetWindowPos32( winpos->hwnd, winpos->hwndInsertAfter,
2578 winpos->x, winpos->y, winpos->cx,
2579 winpos->cy, winpos->flags ))) break;
2581 USER_HEAP_FREE( hdwp );
2582 return res;
2586 /***********************************************************************
2587 * TileChildWindows (USER.199)
2589 void WINAPI TileChildWindows( HWND16 parent, WORD action )
2591 FIXME(win, "(%04x, %d): stub\n", parent, action);
2594 /***********************************************************************
2595 * CascageChildWindows (USER.198)
2597 void WINAPI CascadeChildWindows( HWND16 parent, WORD action )
2599 FIXME(win, "(%04x, %d): stub\n", parent, action);
2601 /***********************************************************************
2602 * GetProgmanWindow [USER32.289]
2604 HRESULT WINAPI GetProgmanWindow ( )
2605 { FIXME(win,"stub\n");
2606 return 0;
2608 /***********************************************************************
2609 * GetTaskmanWindow [USER32.304]
2611 HRESULT WINAPI GetTaskmanWindow ( )
2612 { FIXME(win,"stub\n");
2613 return 0;
2615 /***********************************************************************
2616 * SetProgmanWindow [USER32.522]
2618 HRESULT WINAPI SetProgmanWindow ( DWORD x )
2619 { FIXME(win,"0x%08lx stub\n",x);
2620 return 0;
2622 /***********************************************************************
2623 * SetShellWindowEx [USER32.531]
2625 HRESULT WINAPI SetShellWindowEx ( DWORD x, DWORD y )
2626 { FIXME(win,"0x%08lx 0x%08lx stub\n",x,y);
2627 return 0;
2629 /***********************************************************************
2630 * SetTaskmanWindow [USER32.537]
2632 HRESULT WINAPI SetTaskmanWindow ( DWORD x )
2633 { FIXME(win,"0x%08lx stub\n",x);
2634 return 0;