Changed DOS extended error handling to be based on SetLastError;
[wine/testsucceed.git] / windows / winpos.c
blob13711a6713ac97755a768533f30bb8dee14f5c2f
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 HQUEUE16 hActiveQueue;
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 if ((hwnd == GetFocus32()) || IsChild32( hwnd, GetFocus32()))
1126 /* Revert focus to parent */
1127 SetFocus32( GetParent32(hwnd) );
1129 break;
1131 case SW_SHOWMINNOACTIVE:
1132 swp |= SWP_NOACTIVATE | SWP_NOZORDER;
1133 /* fall through */
1134 case SW_SHOWMINIMIZED:
1135 swp |= SWP_SHOWWINDOW;
1136 /* fall through */
1137 case SW_MINIMIZE:
1138 swp |= SWP_FRAMECHANGED;
1139 if( !(wndPtr->dwStyle & WS_MINIMIZE) )
1140 swp |= WINPOS_MinMaximize( wndPtr, SW_MINIMIZE, &newPos );
1141 else swp |= SWP_NOSIZE | SWP_NOMOVE;
1142 break;
1144 case SW_SHOWMAXIMIZED: /* same as SW_MAXIMIZE */
1145 swp |= SWP_SHOWWINDOW | SWP_FRAMECHANGED;
1146 if( !(wndPtr->dwStyle & WS_MAXIMIZE) )
1147 swp |= WINPOS_MinMaximize( wndPtr, SW_MAXIMIZE, &newPos );
1148 else swp |= SWP_NOSIZE | SWP_NOMOVE;
1149 break;
1151 case SW_SHOWNA:
1152 swp |= SWP_NOACTIVATE | SWP_NOZORDER;
1153 /* fall through */
1154 case SW_SHOW:
1155 swp |= SWP_SHOWWINDOW | SWP_NOSIZE | SWP_NOMOVE;
1156 break;
1158 case SW_SHOWNOACTIVATE:
1159 swp |= SWP_NOZORDER;
1160 if (GetActiveWindow32()) swp |= SWP_NOACTIVATE;
1161 /* fall through */
1162 case SW_SHOWNORMAL: /* same as SW_NORMAL: */
1163 case SW_SHOWDEFAULT: /* FIXME: should have its own handler */
1164 case SW_RESTORE:
1165 swp |= SWP_SHOWWINDOW | SWP_FRAMECHANGED;
1167 if( wndPtr->dwStyle & (WS_MINIMIZE | WS_MAXIMIZE) )
1168 swp |= WINPOS_MinMaximize( wndPtr, SW_RESTORE, &newPos );
1169 else swp |= SWP_NOSIZE | SWP_NOMOVE;
1170 break;
1173 showFlag = (cmd != SW_HIDE);
1174 if (showFlag != wasVisible)
1176 SendMessage32A( hwnd, WM_SHOWWINDOW, showFlag, 0 );
1177 if (!IsWindow32( hwnd )) return wasVisible;
1180 if ((wndPtr->dwStyle & WS_CHILD) &&
1181 !IsWindowVisible32( wndPtr->parent->hwndSelf ) &&
1182 (swp & (SWP_NOSIZE | SWP_NOMOVE)) == (SWP_NOSIZE | SWP_NOMOVE) )
1184 /* Don't call SetWindowPos32() on invisible child windows */
1185 if (cmd == SW_HIDE) wndPtr->dwStyle &= ~WS_VISIBLE;
1186 else wndPtr->dwStyle |= WS_VISIBLE;
1188 else
1190 /* We can't activate a child window */
1191 if (wndPtr->dwStyle & WS_CHILD) swp |= SWP_NOACTIVATE | SWP_NOZORDER;
1192 SetWindowPos32( hwnd, HWND_TOP,
1193 newPos.left, newPos.top, newPos.right, newPos.bottom, swp );
1194 if (!IsWindow32( hwnd )) return wasVisible;
1195 else if( wndPtr->dwStyle & WS_MINIMIZE ) WINPOS_ShowIconTitle( wndPtr, TRUE );
1198 if (wndPtr->flags & WIN_NEED_SIZE)
1200 /* should happen only in CreateWindowEx() */
1201 int wParam = SIZE_RESTORED;
1203 wndPtr->flags &= ~WIN_NEED_SIZE;
1204 if (wndPtr->dwStyle & WS_MAXIMIZE) wParam = SIZE_MAXIMIZED;
1205 else if (wndPtr->dwStyle & WS_MINIMIZE) wParam = SIZE_MINIMIZED;
1206 SendMessage32A( hwnd, WM_SIZE, wParam,
1207 MAKELONG(wndPtr->rectClient.right-wndPtr->rectClient.left,
1208 wndPtr->rectClient.bottom-wndPtr->rectClient.top));
1209 SendMessage32A( hwnd, WM_MOVE, 0,
1210 MAKELONG(wndPtr->rectClient.left, wndPtr->rectClient.top) );
1213 return wasVisible;
1217 /***********************************************************************
1218 * GetInternalWindowPos16 (USER.460)
1220 UINT16 WINAPI GetInternalWindowPos16( HWND16 hwnd, LPRECT16 rectWnd,
1221 LPPOINT16 ptIcon )
1223 WINDOWPLACEMENT16 wndpl;
1224 if (GetWindowPlacement16( hwnd, &wndpl ))
1226 if (rectWnd) *rectWnd = wndpl.rcNormalPosition;
1227 if (ptIcon) *ptIcon = wndpl.ptMinPosition;
1228 return wndpl.showCmd;
1230 return 0;
1234 /***********************************************************************
1235 * GetInternalWindowPos32 (USER32.245)
1237 UINT32 WINAPI GetInternalWindowPos32( HWND32 hwnd, LPRECT32 rectWnd,
1238 LPPOINT32 ptIcon )
1240 WINDOWPLACEMENT32 wndpl;
1241 if (GetWindowPlacement32( hwnd, &wndpl ))
1243 if (rectWnd) *rectWnd = wndpl.rcNormalPosition;
1244 if (ptIcon) *ptIcon = wndpl.ptMinPosition;
1245 return wndpl.showCmd;
1247 return 0;
1250 /***********************************************************************
1251 * GetWindowPlacement16 (USER.370)
1253 BOOL16 WINAPI GetWindowPlacement16( HWND16 hwnd, WINDOWPLACEMENT16 *wndpl )
1255 WND *pWnd = WIN_FindWndPtr( hwnd );
1256 if( pWnd )
1258 LPINTERNALPOS lpPos = (LPINTERNALPOS)WINPOS_InitInternalPos( pWnd,
1259 *(LPPOINT32)&pWnd->rectWindow.left, &pWnd->rectWindow );
1260 wndpl->length = sizeof(*wndpl);
1261 if( pWnd->dwStyle & WS_MINIMIZE )
1262 wndpl->showCmd = SW_SHOWMINIMIZED;
1263 else
1264 wndpl->showCmd = ( pWnd->dwStyle & WS_MAXIMIZE )
1265 ? SW_SHOWMAXIMIZED : SW_SHOWNORMAL ;
1266 if( pWnd->flags & WIN_RESTORE_MAX )
1267 wndpl->flags = WPF_RESTORETOMAXIMIZED;
1268 else
1269 wndpl->flags = 0;
1270 wndpl->ptMinPosition = lpPos->ptIconPos;
1271 wndpl->ptMaxPosition = lpPos->ptMaxPos;
1272 wndpl->rcNormalPosition = lpPos->rectNormal;
1273 return TRUE;
1275 return FALSE;
1279 /***********************************************************************
1280 * GetWindowPlacement32 (USER32.307)
1282 * Win95:
1283 * Fails if wndpl->length of Win95 (!) apps is invalid.
1285 BOOL32 WINAPI GetWindowPlacement32( HWND32 hwnd, WINDOWPLACEMENT32 *pwpl32 )
1287 if( pwpl32 )
1289 WINDOWPLACEMENT16 wpl;
1290 wpl.length = sizeof(wpl);
1291 if( GetWindowPlacement16( hwnd, &wpl ) )
1293 pwpl32->length = sizeof(*pwpl32);
1294 pwpl32->flags = wpl.flags;
1295 pwpl32->showCmd = wpl.showCmd;
1296 CONV_POINT16TO32( &wpl.ptMinPosition, &pwpl32->ptMinPosition );
1297 CONV_POINT16TO32( &wpl.ptMaxPosition, &pwpl32->ptMaxPosition );
1298 CONV_RECT16TO32( &wpl.rcNormalPosition, &pwpl32->rcNormalPosition );
1299 return TRUE;
1302 return FALSE;
1306 /***********************************************************************
1307 * WINPOS_SetPlacement
1309 static BOOL32 WINPOS_SetPlacement( HWND32 hwnd, const WINDOWPLACEMENT16 *wndpl,
1310 UINT32 flags )
1312 WND *pWnd = WIN_FindWndPtr( hwnd );
1313 if( pWnd )
1315 LPINTERNALPOS lpPos = (LPINTERNALPOS)WINPOS_InitInternalPos( pWnd,
1316 *(LPPOINT32)&pWnd->rectWindow.left, &pWnd->rectWindow );
1318 if( flags & PLACE_MIN ) lpPos->ptIconPos = wndpl->ptMinPosition;
1319 if( flags & PLACE_MAX ) lpPos->ptMaxPos = wndpl->ptMaxPosition;
1320 if( flags & PLACE_RECT) lpPos->rectNormal = wndpl->rcNormalPosition;
1322 if( pWnd->dwStyle & WS_MINIMIZE )
1324 WINPOS_ShowIconTitle( pWnd, FALSE );
1325 if( wndpl->flags & WPF_SETMINPOSITION && !EMPTYPOINT(lpPos->ptIconPos))
1326 SetWindowPos32( hwnd, 0, lpPos->ptIconPos.x, lpPos->ptIconPos.y,
1327 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE );
1329 else if( pWnd->dwStyle & WS_MAXIMIZE )
1331 if( !EMPTYPOINT(lpPos->ptMaxPos) )
1332 SetWindowPos32( hwnd, 0, lpPos->ptMaxPos.x, lpPos->ptMaxPos.y,
1333 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE );
1335 else if( flags & PLACE_RECT )
1336 SetWindowPos32( hwnd, 0, lpPos->rectNormal.left, lpPos->rectNormal.top,
1337 lpPos->rectNormal.right - lpPos->rectNormal.left,
1338 lpPos->rectNormal.bottom - lpPos->rectNormal.top,
1339 SWP_NOZORDER | SWP_NOACTIVATE );
1341 ShowWindow32( hwnd, wndpl->showCmd );
1342 if( IsWindow32(hwnd) && pWnd->dwStyle & WS_MINIMIZE )
1344 if( pWnd->dwStyle & WS_VISIBLE ) WINPOS_ShowIconTitle( pWnd, TRUE );
1346 /* SDK: ...valid only the next time... */
1347 if( wndpl->flags & WPF_RESTORETOMAXIMIZED ) pWnd->flags |= WIN_RESTORE_MAX;
1349 return TRUE;
1351 return FALSE;
1355 /***********************************************************************
1356 * SetWindowPlacement16 (USER.371)
1358 BOOL16 WINAPI SetWindowPlacement16(HWND16 hwnd, const WINDOWPLACEMENT16 *wndpl)
1360 return WINPOS_SetPlacement( hwnd, wndpl,
1361 PLACE_MIN | PLACE_MAX | PLACE_RECT );
1364 /***********************************************************************
1365 * SetWindowPlacement32 (USER32.519)
1367 * Win95:
1368 * Fails if wndpl->length of Win95 (!) apps is invalid.
1370 BOOL32 WINAPI SetWindowPlacement32( HWND32 hwnd, const WINDOWPLACEMENT32 *pwpl32 )
1372 if( pwpl32 )
1374 WINDOWPLACEMENT16 wpl = { sizeof(WINDOWPLACEMENT16),
1375 pwpl32->flags, pwpl32->showCmd, { pwpl32->ptMinPosition.x,
1376 pwpl32->ptMinPosition.y }, { pwpl32->ptMaxPosition.x,
1377 pwpl32->ptMaxPosition.y }, { pwpl32->rcNormalPosition.left,
1378 pwpl32->rcNormalPosition.top, pwpl32->rcNormalPosition.right,
1379 pwpl32->rcNormalPosition.bottom } };
1381 return WINPOS_SetPlacement( hwnd, &wpl, PLACE_MIN | PLACE_MAX | PLACE_RECT );
1383 return FALSE;
1387 /***********************************************************************
1388 * SetInternalWindowPos16 (USER.461)
1390 void WINAPI SetInternalWindowPos16( HWND16 hwnd, UINT16 showCmd,
1391 LPRECT16 rect, LPPOINT16 pt )
1393 if( IsWindow16(hwnd) )
1395 WINDOWPLACEMENT16 wndpl;
1396 UINT32 flags;
1398 wndpl.length = sizeof(wndpl);
1399 wndpl.showCmd = showCmd;
1400 wndpl.flags = flags = 0;
1402 if( pt )
1404 flags |= PLACE_MIN;
1405 wndpl.flags |= WPF_SETMINPOSITION;
1406 wndpl.ptMinPosition = *pt;
1408 if( rect )
1410 flags |= PLACE_RECT;
1411 wndpl.rcNormalPosition = *rect;
1413 WINPOS_SetPlacement( hwnd, &wndpl, flags );
1418 /***********************************************************************
1419 * SetInternalWindowPos32 (USER32.483)
1421 void WINAPI SetInternalWindowPos32( HWND32 hwnd, UINT32 showCmd,
1422 LPRECT32 rect, LPPOINT32 pt )
1424 if( IsWindow32(hwnd) )
1426 WINDOWPLACEMENT16 wndpl;
1427 UINT32 flags;
1429 wndpl.length = sizeof(wndpl);
1430 wndpl.showCmd = showCmd;
1431 wndpl.flags = flags = 0;
1433 if( pt )
1435 flags |= PLACE_MIN;
1436 wndpl.flags |= WPF_SETMINPOSITION;
1437 CONV_POINT32TO16( pt, &wndpl.ptMinPosition );
1439 if( rect )
1441 flags |= PLACE_RECT;
1442 CONV_RECT32TO16( rect, &wndpl.rcNormalPosition );
1444 WINPOS_SetPlacement( hwnd, &wndpl, flags );
1448 /*******************************************************************
1449 * WINPOS_SetActiveWindow
1451 * SetActiveWindow() back-end. This is the only function that
1452 * can assign active status to a window. It must be called only
1453 * for the top level windows.
1455 BOOL32 WINPOS_SetActiveWindow( HWND32 hWnd, BOOL32 fMouse, BOOL32 fChangeFocus)
1457 CBTACTIVATESTRUCT16* cbtStruct;
1458 WND* wndPtr, *wndTemp;
1459 HQUEUE16 hOldActiveQueue, hNewActiveQueue;
1460 WORD wIconized = 0;
1462 /* paranoid checks */
1463 if( hWnd == GetDesktopWindow32() || hWnd == hwndActive ) return 0;
1465 /* if (wndPtr && (GetFastQueue() != wndPtr->hmemTaskQ))
1466 * return 0;
1468 wndPtr = WIN_FindWndPtr(hWnd);
1469 hOldActiveQueue = hActiveQueue;
1471 if( (wndTemp = WIN_FindWndPtr(hwndActive)) )
1472 wIconized = HIWORD(wndTemp->dwStyle & WS_MINIMIZE);
1473 else
1474 TRACE(win,"no current active window.\n");
1476 /* call CBT hook chain */
1477 if ((cbtStruct = SEGPTR_NEW(CBTACTIVATESTRUCT16)))
1479 LRESULT wRet;
1480 cbtStruct->fMouse = fMouse;
1481 cbtStruct->hWndActive = hwndActive;
1482 wRet = HOOK_CallHooks16( WH_CBT, HCBT_ACTIVATE, (WPARAM16)hWnd,
1483 (LPARAM)SEGPTR_GET(cbtStruct) );
1484 SEGPTR_FREE(cbtStruct);
1485 if (wRet) return wRet;
1488 /* set prev active wnd to current active wnd and send notification */
1489 if ((hwndPrevActive = hwndActive) && IsWindow32(hwndPrevActive))
1491 if (!SendMessage32A( hwndPrevActive, WM_NCACTIVATE, FALSE, 0 ))
1493 if (GetSysModalWindow16() != hWnd) return 0;
1494 /* disregard refusal if hWnd is sysmodal */
1497 #if 1
1498 SendMessage32A( hwndPrevActive, WM_ACTIVATE,
1499 MAKEWPARAM( WA_INACTIVE, wIconized ),
1500 (LPARAM)hWnd );
1501 #else
1502 /* FIXME: must be SendMessage16() because 32A doesn't do
1503 * intertask at this time */
1504 SendMessage16( hwndPrevActive, WM_ACTIVATE, WA_INACTIVE,
1505 MAKELPARAM( (HWND16)hWnd, wIconized ) );
1506 #endif
1508 /* check if something happened during message processing */
1509 if( hwndPrevActive != hwndActive ) return 0;
1512 /* set active wnd */
1513 hwndActive = hWnd;
1515 /* send palette messages */
1516 if (hWnd && SendMessage16( hWnd, WM_QUERYNEWPALETTE, 0, 0L))
1517 SendMessage16((HWND16)-1, WM_PALETTEISCHANGING, (WPARAM16)hWnd, 0L );
1519 /* if prev wnd is minimized redraw icon title */
1520 if( IsIconic32( hwndPrevActive ) ) WINPOS_RedrawIconTitle(hwndPrevActive);
1522 /* managed windows will get ConfigureNotify event */
1523 if (wndPtr && !(wndPtr->dwStyle & WS_CHILD) && !(wndPtr->flags & WIN_MANAGED))
1525 /* check Z-order and bring hWnd to the top */
1526 for (wndTemp = WIN_GetDesktop()->child; wndTemp; wndTemp = wndTemp->next)
1527 if (wndTemp->dwStyle & WS_VISIBLE) break;
1529 if( wndTemp != wndPtr )
1530 SetWindowPos32(hWnd, HWND_TOP, 0,0,0,0,
1531 SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE );
1532 if (!IsWindow32(hWnd)) return 0;
1535 hNewActiveQueue = wndPtr ? wndPtr->hmemTaskQ : 0;
1537 /* send WM_ACTIVATEAPP if necessary */
1538 if (hOldActiveQueue != hNewActiveQueue)
1540 WND **list, **ppWnd;
1542 if ((list = WIN_BuildWinArray( WIN_GetDesktop(), 0, NULL )))
1544 for (ppWnd = list; *ppWnd; ppWnd++)
1546 if (!IsWindow32( (*ppWnd)->hwndSelf )) continue;
1548 if ((*ppWnd)->hmemTaskQ == hOldActiveQueue)
1549 SendMessage16( (*ppWnd)->hwndSelf, WM_ACTIVATEAPP,
1550 0, QUEUE_GetQueueTask(hNewActiveQueue) );
1552 HeapFree( SystemHeap, 0, list );
1555 hActiveQueue = hNewActiveQueue;
1557 if ((list = WIN_BuildWinArray( WIN_GetDesktop(), 0, NULL )))
1559 for (ppWnd = list; *ppWnd; ppWnd++)
1561 if (!IsWindow32( (*ppWnd)->hwndSelf )) continue;
1563 if ((*ppWnd)->hmemTaskQ == hNewActiveQueue)
1564 SendMessage16( (*ppWnd)->hwndSelf, WM_ACTIVATEAPP,
1565 1, QUEUE_GetQueueTask( hOldActiveQueue ) );
1567 HeapFree( SystemHeap, 0, list );
1570 if (!IsWindow32(hWnd)) return 0;
1573 if (hWnd)
1575 /* walk up to the first unowned window */
1576 wndTemp = wndPtr;
1577 while (wndTemp->owner) wndTemp = wndTemp->owner;
1578 /* and set last active owned popup */
1579 wndTemp->hwndLastActive = hWnd;
1581 wIconized = HIWORD(wndTemp->dwStyle & WS_MINIMIZE);
1582 SendMessage32A( hWnd, WM_NCACTIVATE, TRUE, 0 );
1583 #if 1
1584 SendMessage32A( hWnd, WM_ACTIVATE,
1585 MAKEWPARAM( (fMouse) ? WA_CLICKACTIVE : WA_ACTIVE, wIconized),
1586 (LPARAM)hwndPrevActive );
1587 #else
1588 SendMessage16(hWnd, WM_ACTIVATE, (fMouse) ? WA_CLICKACTIVE : WA_ACTIVE,
1589 MAKELPARAM( (HWND16)hwndPrevActive, wIconized) );
1590 #endif
1592 if( !IsWindow32(hWnd) ) return 0;
1595 /* change focus if possible */
1596 if( fChangeFocus && GetFocus32() )
1597 if( WIN_GetTopParent(GetFocus32()) != hwndActive )
1598 FOCUS_SwitchFocus( GetFocus32(),
1599 (wndPtr && (wndPtr->dwStyle & WS_MINIMIZE))?
1601 hwndActive
1604 if( !hwndPrevActive && wndPtr )
1605 (*wndPtr->pDriver->pForceWindowRaise)(wndPtr);
1607 /* if active wnd is minimized redraw icon title */
1608 if( IsIconic32(hwndActive) ) WINPOS_RedrawIconTitle(hwndActive);
1610 return (hWnd == hwndActive);
1613 /*******************************************************************
1614 * WINPOS_ActivateOtherWindow
1616 * Activates window other than pWnd.
1618 BOOL32 WINPOS_ActivateOtherWindow(WND* pWnd)
1620 BOOL32 bRet = 0;
1621 WND* pWndTo = NULL;
1623 if( pWnd->hwndSelf == hwndPrevActive )
1624 hwndPrevActive = 0;
1626 if( hwndActive != pWnd->hwndSelf &&
1627 ( hwndActive || QUEUE_IsExitingQueue(pWnd->hmemTaskQ)) )
1628 return 0;
1630 if( !(pWnd->dwStyle & WS_POPUP) || !(pWnd->owner) ||
1631 !WINPOS_CanActivate((pWndTo = WIN_GetTopParentPtr(pWnd->owner))) )
1633 WND* pWndPtr = WIN_GetTopParentPtr(pWnd);
1635 pWndTo = WIN_FindWndPtr(hwndPrevActive);
1637 while( !WINPOS_CanActivate(pWndTo) )
1639 /* by now owned windows should've been taken care of */
1641 pWndTo = pWndPtr->next;
1642 pWndPtr = pWndTo;
1643 if( !pWndTo ) break;
1647 bRet = WINPOS_SetActiveWindow( pWndTo ? pWndTo->hwndSelf : 0, FALSE, TRUE );
1649 /* switch desktop queue to current active */
1650 if( pWndTo ) WIN_GetDesktop()->hmemTaskQ = pWndTo->hmemTaskQ;
1652 hwndPrevActive = 0;
1653 return bRet;
1656 /*******************************************************************
1657 * WINPOS_ChangeActiveWindow
1660 BOOL32 WINPOS_ChangeActiveWindow( HWND32 hWnd, BOOL32 mouseMsg )
1662 WND *wndPtr = WIN_FindWndPtr(hWnd);
1664 if (!hWnd) return WINPOS_SetActiveWindow( 0, mouseMsg, TRUE );
1666 if( !wndPtr ) return FALSE;
1668 /* child windows get WM_CHILDACTIVATE message */
1669 if( (wndPtr->dwStyle & (WS_CHILD | WS_POPUP)) == WS_CHILD )
1670 return SendMessage32A(hWnd, WM_CHILDACTIVATE, 0, 0L);
1672 /* owned popups imply owner activation - not sure */
1673 if ((wndPtr->dwStyle & WS_POPUP) && wndPtr->owner &&
1674 (wndPtr->owner->dwStyle & WS_VISIBLE ) &&
1675 !(wndPtr->owner->dwStyle & WS_DISABLED ))
1677 if (!(wndPtr = wndPtr->owner)) return FALSE;
1678 hWnd = wndPtr->hwndSelf;
1681 if( hWnd == hwndActive ) return FALSE;
1683 if( !WINPOS_SetActiveWindow(hWnd ,mouseMsg ,TRUE) )
1684 return FALSE;
1686 /* switch desktop queue to current active */
1687 if( wndPtr->parent == WIN_GetDesktop())
1688 WIN_GetDesktop()->hmemTaskQ = wndPtr->hmemTaskQ;
1690 return TRUE;
1694 /***********************************************************************
1695 * WINPOS_SendNCCalcSize
1697 * Send a WM_NCCALCSIZE message to a window.
1698 * All parameters are read-only except newClientRect.
1699 * oldWindowRect, oldClientRect and winpos must be non-NULL only
1700 * when calcValidRect is TRUE.
1702 LONG WINPOS_SendNCCalcSize( HWND32 hwnd, BOOL32 calcValidRect,
1703 RECT32 *newWindowRect, RECT32 *oldWindowRect,
1704 RECT32 *oldClientRect, WINDOWPOS32 *winpos,
1705 RECT32 *newClientRect )
1707 NCCALCSIZE_PARAMS32 params;
1708 WINDOWPOS32 winposCopy;
1709 LONG result;
1711 params.rgrc[0] = *newWindowRect;
1712 if (calcValidRect)
1714 winposCopy = *winpos;
1715 params.rgrc[1] = *oldWindowRect;
1716 params.rgrc[2] = *oldClientRect;
1717 params.lppos = &winposCopy;
1719 result = SendMessage32A( hwnd, WM_NCCALCSIZE, calcValidRect,
1720 (LPARAM)&params );
1721 TRACE(win, "%d,%d-%d,%d\n",
1722 params.rgrc[0].left, params.rgrc[0].top,
1723 params.rgrc[0].right, params.rgrc[0].bottom );
1724 *newClientRect = params.rgrc[0];
1725 return result;
1729 /***********************************************************************
1730 * WINPOS_HandleWindowPosChanging16
1732 * Default handling for a WM_WINDOWPOSCHANGING. Called from DefWindowProc().
1734 LONG WINPOS_HandleWindowPosChanging16( WND *wndPtr, WINDOWPOS16 *winpos )
1736 POINT32 maxSize, minTrack;
1737 if (winpos->flags & SWP_NOSIZE) return 0;
1738 if ((wndPtr->dwStyle & WS_THICKFRAME) ||
1739 ((wndPtr->dwStyle & (WS_POPUP | WS_CHILD)) == 0))
1741 WINPOS_GetMinMaxInfo( wndPtr, &maxSize, NULL, &minTrack, NULL );
1742 if (maxSize.x < winpos->cx) winpos->cx = maxSize.x;
1743 if (maxSize.y < winpos->cy) winpos->cy = maxSize.y;
1744 if (!(wndPtr->dwStyle & WS_MINIMIZE))
1746 if (winpos->cx < minTrack.x ) winpos->cx = minTrack.x;
1747 if (winpos->cy < minTrack.y ) winpos->cy = minTrack.y;
1750 return 0;
1754 /***********************************************************************
1755 * WINPOS_HandleWindowPosChanging32
1757 * Default handling for a WM_WINDOWPOSCHANGING. Called from DefWindowProc().
1759 LONG WINPOS_HandleWindowPosChanging32( WND *wndPtr, WINDOWPOS32 *winpos )
1761 POINT32 maxSize;
1762 if (winpos->flags & SWP_NOSIZE) return 0;
1763 if ((wndPtr->dwStyle & WS_THICKFRAME) ||
1764 ((wndPtr->dwStyle & (WS_POPUP | WS_CHILD)) == 0))
1766 WINPOS_GetMinMaxInfo( wndPtr, &maxSize, NULL, NULL, NULL );
1767 winpos->cx = MIN( winpos->cx, maxSize.x );
1768 winpos->cy = MIN( winpos->cy, maxSize.y );
1770 return 0;
1774 /***********************************************************************
1775 * WINPOS_MoveWindowZOrder
1777 * Move a window in Z order, invalidating everything that needs it.
1778 * Only necessary for windows without associated X window.
1780 static void WINPOS_MoveWindowZOrder( HWND32 hwnd, HWND32 hwndAfter )
1782 BOOL32 movingUp;
1783 WND *pWndAfter, *pWndCur, *wndPtr = WIN_FindWndPtr( hwnd );
1785 /* We have two possible cases:
1786 * - The window is moving up: we have to invalidate all areas
1787 * of the window that were covered by other windows
1788 * - The window is moving down: we have to invalidate areas
1789 * of other windows covered by this one.
1792 if (hwndAfter == HWND_TOP)
1794 movingUp = TRUE;
1796 else if (hwndAfter == HWND_BOTTOM)
1798 if (!wndPtr->next) return; /* Already at the bottom */
1799 movingUp = FALSE;
1801 else
1803 if (!(pWndAfter = WIN_FindWndPtr( hwndAfter ))) return;
1804 if (wndPtr->next == pWndAfter) return; /* Already placed right */
1806 /* Determine which window we encounter first in Z-order */
1807 pWndCur = wndPtr->parent->child;
1808 while ((pWndCur != wndPtr) && (pWndCur != pWndAfter))
1809 pWndCur = pWndCur->next;
1810 movingUp = (pWndCur == pWndAfter);
1813 if (movingUp)
1815 WND *pWndPrevAfter = wndPtr->next;
1816 WIN_UnlinkWindow( hwnd );
1817 WIN_LinkWindow( hwnd, hwndAfter );
1818 pWndCur = wndPtr->next;
1819 while (pWndCur != pWndPrevAfter)
1821 RECT32 rect = { pWndCur->rectWindow.left,
1822 pWndCur->rectWindow.top,
1823 pWndCur->rectWindow.right,
1824 pWndCur->rectWindow.bottom };
1825 OffsetRect32( &rect, -wndPtr->rectClient.left,
1826 -wndPtr->rectClient.top );
1827 PAINT_RedrawWindow( hwnd, &rect, 0, RDW_INVALIDATE | RDW_ALLCHILDREN |
1828 RDW_FRAME | RDW_ERASE, 0 );
1829 pWndCur = pWndCur->next;
1832 else /* Moving down */
1834 pWndCur = wndPtr->next;
1835 WIN_UnlinkWindow( hwnd );
1836 WIN_LinkWindow( hwnd, hwndAfter );
1837 while (pWndCur != wndPtr)
1839 RECT32 rect = { pWndCur->rectWindow.left,
1840 pWndCur->rectWindow.top,
1841 pWndCur->rectWindow.right,
1842 pWndCur->rectWindow.bottom };
1843 OffsetRect32( &rect, -pWndCur->rectClient.left,
1844 -pWndCur->rectClient.top );
1845 PAINT_RedrawWindow( pWndCur->hwndSelf, &rect, 0, RDW_INVALIDATE |
1846 RDW_ALLCHILDREN | RDW_FRAME | RDW_ERASE, 0 );
1847 pWndCur = pWndCur->next;
1852 /***********************************************************************
1853 * WINPOS_ReorderOwnedPopups
1855 * fix Z order taking into account owned popups -
1856 * basically we need to maintain them above the window that owns them
1858 HWND32 WINPOS_ReorderOwnedPopups(HWND32 hwndInsertAfter,WND* wndPtr,WORD flags)
1860 WND* w = WIN_GetDesktop()->child;
1862 if( wndPtr->dwStyle & WS_POPUP && wndPtr->owner )
1864 /* implement "local z-order" between the top and owner window */
1866 HWND32 hwndLocalPrev = HWND_TOP;
1868 if( hwndInsertAfter != HWND_TOP )
1870 while( w != wndPtr->owner )
1872 if (w != wndPtr) hwndLocalPrev = w->hwndSelf;
1873 if( hwndLocalPrev == hwndInsertAfter ) break;
1874 w = w->next;
1876 hwndInsertAfter = hwndLocalPrev;
1880 else if( wndPtr->dwStyle & WS_CHILD ) return hwndInsertAfter;
1882 w = WIN_GetDesktop()->child;
1883 while( w )
1885 if( w == wndPtr ) break;
1887 if( w->dwStyle & WS_POPUP && w->owner == wndPtr )
1889 SetWindowPos32(w->hwndSelf, hwndInsertAfter, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE |
1890 SWP_NOACTIVATE | SWP_NOSENDCHANGING | SWP_DEFERERASE);
1891 hwndInsertAfter = w->hwndSelf;
1893 w = w->next;
1896 return hwndInsertAfter;
1899 /***********************************************************************
1900 * WINPOS_SizeMoveClean
1902 * Make window look nice without excessive repainting
1904 * the pain:
1906 * visible regions are in window coordinates
1907 * update regions are in window client coordinates
1908 * client and window rectangles are in parent client coordinates
1910 * FIXME: Move visible and update regions to the same coordinate system
1911 * (either parent client or window). This is a lot of work though.
1913 static UINT32 WINPOS_SizeMoveClean( WND* Wnd, HRGN32 oldVisRgn,
1914 LPRECT32 lpOldWndRect,
1915 LPRECT32 lpOldClientRect, UINT32 uFlags )
1917 HRGN32 newVisRgn = DCE_GetVisRgn(Wnd->hwndSelf,DCX_WINDOW | DCX_CLIPSIBLINGS);
1918 HRGN32 dirtyRgn = CreateRectRgn32(0,0,0,0);
1919 int other, my;
1921 TRACE(win,"cleaning up...new wnd=(%i %i-%i %i) old wnd=(%i %i-%i %i)\n",
1922 Wnd->rectWindow.left, Wnd->rectWindow.top,
1923 Wnd->rectWindow.right, Wnd->rectWindow.bottom,
1924 lpOldWndRect->left, lpOldWndRect->top,
1925 lpOldWndRect->right, lpOldWndRect->bottom);
1926 TRACE(win,"\tnew client=(%i %i-%i %i) old client=(%i %i-%i %i)\n",
1927 Wnd->rectClient.left, Wnd->rectClient.top,
1928 Wnd->rectClient.right, Wnd->rectClient.bottom,
1929 lpOldClientRect->left, lpOldClientRect->top,
1930 lpOldClientRect->right,lpOldClientRect->bottom );
1932 if( (lpOldWndRect->right - lpOldWndRect->left) != (Wnd->rectWindow.right - Wnd->rectWindow.left) ||
1933 (lpOldWndRect->bottom - lpOldWndRect->top) != (Wnd->rectWindow.bottom - Wnd->rectWindow.top) )
1934 uFlags |= SMC_DRAWFRAME;
1936 CombineRgn32( dirtyRgn, newVisRgn, 0, RGN_COPY);
1938 if( !(uFlags & SMC_NOCOPY) )
1939 CombineRgn32( newVisRgn, newVisRgn, oldVisRgn, RGN_AND );
1941 /* map regions to the parent client area */
1943 OffsetRgn32( dirtyRgn, Wnd->rectWindow.left, Wnd->rectWindow.top );
1944 OffsetRgn32( oldVisRgn, lpOldWndRect->left, lpOldWndRect->top );
1946 /* compute invalidated region outside Wnd - (in client coordinates of the parent window) */
1948 other = CombineRgn32(dirtyRgn, oldVisRgn, dirtyRgn, RGN_DIFF);
1950 /* map visible region to the Wnd client area */
1952 OffsetRgn32( newVisRgn, Wnd->rectWindow.left - Wnd->rectClient.left,
1953 Wnd->rectWindow.top - Wnd->rectClient.top );
1955 /* substract previously invalidated region from the Wnd visible region */
1957 my = (Wnd->hrgnUpdate > 1) ? CombineRgn32( newVisRgn, newVisRgn,
1958 Wnd->hrgnUpdate, RGN_DIFF)
1959 : COMPLEXREGION;
1961 if( uFlags & SMC_NOCOPY ) /* invalidate Wnd visible region */
1963 if (my != NULLREGION)
1964 PAINT_RedrawWindow( Wnd->hwndSelf, NULL, newVisRgn, RDW_INVALIDATE |
1965 RDW_FRAME | RDW_ALLCHILDREN | RDW_ERASE, RDW_C_USEHRGN );
1966 else if(uFlags & SMC_DRAWFRAME)
1967 Wnd->flags |= WIN_NEEDS_NCPAINT;
1969 else /* bitblt old client area */
1971 HDC32 hDC;
1972 int update;
1973 HRGN32 updateRgn;
1974 int xfrom,yfrom,xto,yto,width,height;
1976 if( uFlags & SMC_DRAWFRAME )
1978 /* copy only client area, frame will be redrawn anyway */
1980 xfrom = lpOldClientRect->left; yfrom = lpOldClientRect->top;
1981 xto = Wnd->rectClient.left; yto = Wnd->rectClient.top;
1982 width = lpOldClientRect->right - xfrom; height = lpOldClientRect->bottom - yfrom;
1983 updateRgn = CreateRectRgn32( 0, 0, width, height );
1984 CombineRgn32( newVisRgn, newVisRgn, updateRgn, RGN_AND );
1985 SetRectRgn32( updateRgn, 0, 0, Wnd->rectClient.right - xto,
1986 Wnd->rectClient.bottom - yto );
1988 else
1990 xfrom = lpOldWndRect->left; yfrom = lpOldWndRect->top;
1991 xto = Wnd->rectWindow.left; yto = Wnd->rectWindow.top;
1992 width = lpOldWndRect->right - xfrom; height = lpOldWndRect->bottom - yfrom;
1993 updateRgn = CreateRectRgn32( xto - Wnd->rectClient.left,
1994 yto - Wnd->rectClient.top,
1995 Wnd->rectWindow.right - Wnd->rectClient.left,
1996 Wnd->rectWindow.bottom - Wnd->rectClient.top );
1999 CombineRgn32( newVisRgn, newVisRgn, updateRgn, RGN_AND );
2001 /* substract new visRgn from target rect to get a region that won't be copied */
2003 update = CombineRgn32( updateRgn, updateRgn, newVisRgn, RGN_DIFF );
2005 /* Blt valid bits using parent window DC */
2007 if( my != NULLREGION && (xfrom != xto || yfrom != yto) )
2010 /* compute clipping region in parent client coordinates */
2012 OffsetRgn32( newVisRgn, Wnd->rectClient.left, Wnd->rectClient.top );
2013 CombineRgn32( oldVisRgn, oldVisRgn, newVisRgn, RGN_OR );
2015 hDC = GetDCEx32( Wnd->parent->hwndSelf, oldVisRgn,
2016 DCX_KEEPCLIPRGN | DCX_INTERSECTRGN |
2017 DCX_CACHE | DCX_CLIPSIBLINGS);
2019 BitBlt32( hDC, xto, yto, width, height, hDC, xfrom, yfrom, SRCCOPY );
2020 ReleaseDC32( Wnd->parent->hwndSelf, hDC);
2023 if( update != NULLREGION )
2024 PAINT_RedrawWindow( Wnd->hwndSelf, NULL, updateRgn, RDW_INVALIDATE |
2025 RDW_FRAME | RDW_ALLCHILDREN | RDW_ERASE, RDW_C_USEHRGN );
2026 else if( uFlags & SMC_DRAWFRAME ) Wnd->flags |= WIN_NEEDS_NCPAINT;
2027 DeleteObject32( updateRgn );
2030 /* erase uncovered areas */
2032 if( !(uFlags & SMC_NOPARENTERASE) && (other != NULLREGION ) )
2033 PAINT_RedrawWindow( Wnd->parent->hwndSelf, NULL, dirtyRgn,
2034 RDW_INVALIDATE | RDW_ALLCHILDREN | RDW_ERASE, RDW_C_USEHRGN );
2035 DeleteObject32(dirtyRgn);
2036 DeleteObject32(newVisRgn);
2037 return uFlags;
2040 /***********************************************************************
2041 * SetWindowPos (USER.232)
2043 BOOL16 WINAPI SetWindowPos16( HWND16 hwnd, HWND16 hwndInsertAfter,
2044 INT16 x, INT16 y, INT16 cx, INT16 cy, WORD flags)
2046 return SetWindowPos32(hwnd,(INT32)(INT16)hwndInsertAfter,x,y,cx,cy,flags);
2049 /***********************************************************************
2050 * SetWindowPos (USER32.520)
2052 BOOL32 WINAPI SetWindowPos32( HWND32 hwnd, HWND32 hwndInsertAfter,
2053 INT32 x, INT32 y, INT32 cx, INT32 cy, WORD flags)
2055 WINDOWPOS32 winpos;
2056 WND * wndPtr;
2057 RECT32 newWindowRect, newClientRect, oldWindowRect;
2058 HRGN32 visRgn = 0;
2059 HWND32 tempInsertAfter= 0;
2060 int result = 0;
2061 UINT32 uFlags = 0;
2062 BOOL32 resync = FALSE;
2064 TRACE(win,"hwnd %04x, (%i,%i)-(%i,%i) flags %08x\n",
2065 hwnd, x, y, x+cx, y+cy, flags);
2066 /* Check window handle */
2068 if (hwnd == GetDesktopWindow32()) return FALSE;
2069 if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return FALSE;
2071 if(wndPtr->dwStyle & WS_VISIBLE)
2072 flags &= ~SWP_SHOWWINDOW;
2073 else
2075 uFlags |= SMC_NOPARENTERASE;
2076 flags &= ~SWP_HIDEWINDOW;
2077 if (!(flags & SWP_SHOWWINDOW)) flags |= SWP_NOREDRAW;
2080 /* Check for windows that may not be resized
2081 FIXME: this should be done only for Windows 3.0 programs
2082 if (flags & (SWP_SHOWWINDOW | SWP_HIDEWINDOW ) )
2083 flags |= SWP_NOSIZE | SWP_NOMOVE;
2085 /* Check dimensions */
2087 if (cx <= 0) cx = 1;
2088 if (cy <= 0) cy = 1;
2090 /* Check flags */
2092 if (hwnd == hwndActive) flags |= SWP_NOACTIVATE; /* Already active */
2093 if ((wndPtr->rectWindow.right - wndPtr->rectWindow.left == cx) &&
2094 (wndPtr->rectWindow.bottom - wndPtr->rectWindow.top == cy))
2095 flags |= SWP_NOSIZE; /* Already the right size */
2096 if ((wndPtr->rectWindow.left == x) && (wndPtr->rectWindow.top == y))
2097 flags |= SWP_NOMOVE; /* Already the right position */
2099 /* Check hwndInsertAfter */
2101 if (!(flags & (SWP_NOZORDER | SWP_NOACTIVATE)))
2103 /* Ignore TOPMOST flags when activating a window */
2104 /* _and_ moving it in Z order. */
2105 if ((hwndInsertAfter == HWND_TOPMOST) ||
2106 (hwndInsertAfter == HWND_NOTOPMOST))
2107 hwndInsertAfter = HWND_TOP;
2109 /* TOPMOST not supported yet */
2110 if ((hwndInsertAfter == HWND_TOPMOST) ||
2111 (hwndInsertAfter == HWND_NOTOPMOST)) hwndInsertAfter = HWND_TOP;
2113 /* hwndInsertAfter must be a sibling of the window */
2114 if ((hwndInsertAfter != HWND_TOP) && (hwndInsertAfter != HWND_BOTTOM))
2116 WND* wnd = WIN_FindWndPtr(hwndInsertAfter);
2118 if( wnd ) {
2119 if( wnd->parent != wndPtr->parent ) return FALSE;
2120 if( wnd->next == wndPtr ) flags |= SWP_NOZORDER;
2123 else if (!((X11DRV_WND_DATA *) wndPtr->pDriverData)->window)
2125 /* FIXME: the following optimization is no good for "X-ed" windows */
2126 if (hwndInsertAfter == HWND_TOP)
2127 flags |= ( wndPtr->parent->child == wndPtr)? SWP_NOZORDER: 0;
2128 else /* HWND_BOTTOM */
2129 flags |= ( wndPtr->next )? 0: SWP_NOZORDER;
2132 /* Fill the WINDOWPOS structure */
2134 winpos.hwnd = hwnd;
2135 winpos.hwndInsertAfter = hwndInsertAfter;
2136 winpos.x = x;
2137 winpos.y = y;
2138 winpos.cx = cx;
2139 winpos.cy = cy;
2140 winpos.flags = flags;
2142 /* Send WM_WINDOWPOSCHANGING message */
2144 if (!(winpos.flags & SWP_NOSENDCHANGING))
2145 SendMessage32A( hwnd, WM_WINDOWPOSCHANGING, 0, (LPARAM)&winpos );
2147 /* Calculate new position and size */
2149 newWindowRect = wndPtr->rectWindow;
2150 newClientRect = (wndPtr->dwStyle & WS_MINIMIZE) ? wndPtr->rectWindow
2151 : wndPtr->rectClient;
2153 if (!(winpos.flags & SWP_NOSIZE))
2155 newWindowRect.right = newWindowRect.left + winpos.cx;
2156 newWindowRect.bottom = newWindowRect.top + winpos.cy;
2158 if (!(winpos.flags & SWP_NOMOVE))
2160 newWindowRect.left = winpos.x;
2161 newWindowRect.top = winpos.y;
2162 newWindowRect.right += winpos.x - wndPtr->rectWindow.left;
2163 newWindowRect.bottom += winpos.y - wndPtr->rectWindow.top;
2165 OffsetRect32( &newClientRect, winpos.x - wndPtr->rectWindow.left,
2166 winpos.y - wndPtr->rectWindow.top );
2169 winpos.flags |= SWP_NOCLIENTMOVE | SWP_NOCLIENTSIZE;
2171 /* Reposition window in Z order */
2173 if (!(winpos.flags & SWP_NOZORDER))
2175 /* reorder owned popups if hwnd is top-level window
2177 if( wndPtr->parent == WIN_GetDesktop() )
2178 hwndInsertAfter = WINPOS_ReorderOwnedPopups( hwndInsertAfter,
2179 wndPtr, winpos.flags );
2181 if (((X11DRV_WND_DATA *) wndPtr->pDriverData)->window)
2183 WIN_UnlinkWindow( winpos.hwnd );
2184 WIN_LinkWindow( winpos.hwnd, hwndInsertAfter );
2186 else WINPOS_MoveWindowZOrder( winpos.hwnd, hwndInsertAfter );
2189 if ( !((X11DRV_WND_DATA *) wndPtr->pDriverData)->window && !(winpos.flags & SWP_NOREDRAW) &&
2190 ((winpos.flags & (SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED))
2191 != (SWP_NOMOVE | SWP_NOSIZE)) )
2192 visRgn = DCE_GetVisRgn(hwnd, DCX_WINDOW | DCX_CLIPSIBLINGS);
2195 /* Send WM_NCCALCSIZE message to get new client area */
2196 if( (winpos.flags & (SWP_FRAMECHANGED | SWP_NOSIZE)) != SWP_NOSIZE )
2198 result = WINPOS_SendNCCalcSize( winpos.hwnd, TRUE, &newWindowRect,
2199 &wndPtr->rectWindow, &wndPtr->rectClient,
2200 &winpos, &newClientRect );
2202 /* FIXME: WVR_ALIGNxxx */
2204 if( newClientRect.left != wndPtr->rectClient.left ||
2205 newClientRect.top != wndPtr->rectClient.top )
2206 winpos.flags &= ~SWP_NOCLIENTMOVE;
2208 if( (newClientRect.right - newClientRect.left !=
2209 wndPtr->rectClient.right - wndPtr->rectClient.left) ||
2210 (newClientRect.bottom - newClientRect.top !=
2211 wndPtr->rectClient.bottom - wndPtr->rectClient.top) )
2212 winpos.flags &= ~SWP_NOCLIENTSIZE;
2214 else
2215 if( !(flags & SWP_NOMOVE) && (newClientRect.left != wndPtr->rectClient.left ||
2216 newClientRect.top != wndPtr->rectClient.top) )
2217 winpos.flags &= ~SWP_NOCLIENTMOVE;
2219 /* Update active DCEs
2220 * TODO: Optimize conditions that trigger DCE update.
2223 if( (((winpos.flags & SWP_AGG_NOPOSCHANGE) != SWP_AGG_NOPOSCHANGE) &&
2224 wndPtr->dwStyle & WS_VISIBLE) ||
2225 (flags & (SWP_HIDEWINDOW | SWP_SHOWWINDOW)) )
2227 RECT32 rect;
2229 UnionRect32(&rect, &newWindowRect, &wndPtr->rectWindow);
2230 DCE_InvalidateDCE(wndPtr, &rect);
2233 /* change geometry */
2235 oldWindowRect = wndPtr->rectWindow;
2237 if (((X11DRV_WND_DATA *) wndPtr->pDriverData)->window)
2239 RECT32 oldClientRect = wndPtr->rectClient;
2241 tempInsertAfter = winpos.hwndInsertAfter;
2243 winpos.hwndInsertAfter = hwndInsertAfter;
2245 /* postpone geometry change */
2247 if( !(flags & (SWP_SHOWWINDOW | SWP_HIDEWINDOW)) )
2249 wndPtr->pDriver->pSetWindowPos(wndPtr, &winpos, TRUE);
2250 winpos.hwndInsertAfter = tempInsertAfter;
2252 else uFlags |= SMC_SETXPOS;
2254 wndPtr->rectWindow = newWindowRect;
2255 wndPtr->rectClient = newClientRect;
2257 if( !(flags & (SWP_SHOWWINDOW | SWP_HIDEWINDOW)) )
2259 if( (oldClientRect.left - oldWindowRect.left !=
2260 newClientRect.left - newWindowRect.left) ||
2261 (oldClientRect.top - oldWindowRect.top !=
2262 newClientRect.top - newWindowRect.top) ||
2263 (winpos.flags & SWP_NOCOPYBITS) )
2265 /* if the client area moved as a result of WM_NCCALCSIZE returning
2266 * obscure WVR_ALIGNxxx flags then we simply redraw the whole thing
2268 * TODO: use WINPOS_SizeMoveClean() if there is no SWP_NOCOPYBITS
2271 PAINT_RedrawWindow( wndPtr->hwndSelf, NULL, 0, RDW_INVALIDATE |
2272 RDW_ALLCHILDREN | RDW_FRAME | RDW_ERASE, 0 );
2274 else
2275 if( winpos.flags & SWP_FRAMECHANGED )
2277 WORD wErase = 0;
2278 RECT32 rect;
2280 if( newClientRect.right > oldClientRect.right ) /* redraw exposed client area on the right */
2282 rect.top = 0; rect.bottom = newClientRect.bottom - newClientRect.top;
2283 rect.left = oldClientRect.right - newClientRect.left;
2284 rect.right = newClientRect.right - newClientRect.left;
2285 wErase = 1;
2286 PAINT_RedrawWindow( wndPtr->hwndSelf, &rect, 0,
2287 RDW_INVALIDATE | RDW_FRAME | RDW_ERASE | RDW_ERASENOW | RDW_ALLCHILDREN, 0 );
2289 if( newClientRect.bottom > oldClientRect.bottom ) /* redraw exposed client area on the bottom */
2291 rect.left = 0; rect.right = ((wErase)?oldClientRect.right:newClientRect.right) - newClientRect.left;
2292 rect.top = oldClientRect.bottom - newClientRect.top;
2293 rect.bottom = newClientRect.bottom - newClientRect.top;
2294 wErase = 1;
2295 PAINT_RedrawWindow( wndPtr->hwndSelf, &rect, 0,
2296 RDW_INVALIDATE | RDW_FRAME | RDW_ERASE | RDW_ERASENOW | RDW_ALLCHILDREN, 0 );
2298 if( !wErase ) /* just update the nonclient area */
2299 wndPtr->flags |= WIN_NEEDS_NCPAINT;
2302 uFlags |= SMC_NOPARENTERASE; /* X windows do not have eraseable parents */
2304 else /* not an X window */
2306 RECT32 oldClientRect = wndPtr->rectClient;
2308 wndPtr->rectWindow = newWindowRect;
2309 wndPtr->rectClient = newClientRect;
2311 if( oldClientRect.bottom - oldClientRect.top ==
2312 newClientRect.bottom - newClientRect.top ) result &= ~WVR_VREDRAW;
2314 if( oldClientRect.right - oldClientRect.left ==
2315 newClientRect.right - newClientRect.left ) result &= ~WVR_HREDRAW;
2317 if( !(flags & (SWP_NOREDRAW | SWP_HIDEWINDOW | SWP_SHOWWINDOW)) )
2319 uFlags |= ((winpos.flags & SWP_NOCOPYBITS) ||
2320 (result >= WVR_HREDRAW && result < WVR_VALIDRECTS)) ? SMC_NOCOPY : 0;
2321 uFlags |= (winpos.flags & SWP_FRAMECHANGED) ? SMC_DRAWFRAME : 0;
2323 if( (winpos.flags & SWP_AGG_NOGEOMETRYCHANGE) != SWP_AGG_NOGEOMETRYCHANGE )
2324 uFlags = WINPOS_SizeMoveClean(wndPtr, visRgn, &oldWindowRect,
2325 &oldClientRect, uFlags);
2326 else
2328 /* adjust the frame and do not erase the parent */
2330 if( winpos.flags & SWP_FRAMECHANGED ) wndPtr->flags |= WIN_NEEDS_NCPAINT;
2331 if( winpos.flags & SWP_NOZORDER ) uFlags |= SMC_NOPARENTERASE;
2334 DeleteObject32(visRgn);
2337 if (flags & SWP_SHOWWINDOW)
2339 wndPtr->dwStyle |= WS_VISIBLE;
2340 if (((X11DRV_WND_DATA *) wndPtr->pDriverData)->window)
2342 HWND32 focus, curr;
2344 wndPtr->pDriver->pSetWindowPos(wndPtr, &winpos, uFlags & SMC_SETXPOS );
2345 if( uFlags & SMC_SETXPOS )
2347 winpos.hwndInsertAfter = tempInsertAfter;
2350 if (wndPtr->flags & WIN_MANAGED) resync = TRUE;
2352 /* If focus was set to an unmapped window, reset X focus now */
2353 focus = curr = GetFocus32();
2354 while (curr) {
2355 if (curr == hwnd) {
2356 SetFocus32( 0 );
2357 SetFocus32( focus );
2358 break;
2360 curr = GetParent32(curr);
2363 else
2365 if (!(flags & SWP_NOREDRAW))
2366 PAINT_RedrawWindow( winpos.hwnd, NULL, 0,
2367 RDW_INVALIDATE | RDW_ALLCHILDREN |
2368 RDW_FRAME | RDW_ERASENOW | RDW_ERASE, 0 );
2371 else if (flags & SWP_HIDEWINDOW)
2373 wndPtr->dwStyle &= ~WS_VISIBLE;
2375 if (((X11DRV_WND_DATA *) wndPtr->pDriverData)->window)
2377 wndPtr->pDriver->pSetWindowPos(wndPtr, &winpos, uFlags & SMC_SETXPOS );
2378 if( uFlags & SMC_SETXPOS )
2380 winpos.hwndInsertAfter = tempInsertAfter;
2383 else
2385 if (!(flags & SWP_NOREDRAW))
2386 PAINT_RedrawWindow( wndPtr->parent->hwndSelf, &oldWindowRect,
2387 0, RDW_INVALIDATE | RDW_ALLCHILDREN |
2388 RDW_ERASE | RDW_ERASENOW, 0 );
2389 uFlags |= SMC_NOPARENTERASE;
2392 if (hwnd == CARET_GetHwnd()) DestroyCaret32();
2394 if (winpos.hwnd == hwndActive)
2395 WINPOS_ActivateOtherWindow( wndPtr );
2398 /* Activate the window */
2400 if (!(flags & SWP_NOACTIVATE))
2401 WINPOS_ChangeActiveWindow( winpos.hwnd, FALSE );
2403 /* Repaint the window */
2405 if (((X11DRV_WND_DATA *) wndPtr->pDriverData)->window)
2406 EVENT_Synchronize(); /* Wait for all expose events */
2408 if (!GetCapture32())
2409 EVENT_DummyMotionNotify(); /* Simulate a mouse event to set the cursor */
2411 if (!(flags & SWP_DEFERERASE) && !(uFlags & SMC_NOPARENTERASE) )
2412 PAINT_RedrawWindow( wndPtr->parent->hwndSelf, NULL, 0, RDW_ALLCHILDREN | RDW_ERASENOW, 0 );
2413 else if( wndPtr->parent == WIN_GetDesktop() && wndPtr->parent->flags & WIN_NEEDS_ERASEBKGND )
2414 PAINT_RedrawWindow( wndPtr->parent->hwndSelf, NULL, 0, RDW_NOCHILDREN | RDW_ERASENOW, 0 );
2416 /* And last, send the WM_WINDOWPOSCHANGED message */
2418 TRACE(win,"\tstatus flags = %04x\n", winpos.flags & SWP_AGG_STATUSFLAGS);
2420 if ( resync ||
2421 (((winpos.flags & SWP_AGG_STATUSFLAGS) != SWP_AGG_NOPOSCHANGE) &&
2422 !(winpos.flags & SWP_NOSENDCHANGING)) )
2424 SendMessage32A( winpos.hwnd, WM_WINDOWPOSCHANGED, 0, (LPARAM)&winpos );
2425 if (resync) EVENT_Synchronize ();
2428 return TRUE;
2432 /***********************************************************************
2433 * BeginDeferWindowPos16 (USER.259)
2435 HDWP16 WINAPI BeginDeferWindowPos16( INT16 count )
2437 return BeginDeferWindowPos32( count );
2441 /***********************************************************************
2442 * BeginDeferWindowPos32 (USER32.9)
2444 HDWP32 WINAPI BeginDeferWindowPos32( INT32 count )
2446 HDWP32 handle;
2447 DWP *pDWP;
2449 if (count <= 0) return 0;
2450 handle = USER_HEAP_ALLOC( sizeof(DWP) + (count-1)*sizeof(WINDOWPOS32) );
2451 if (!handle) return 0;
2452 pDWP = (DWP *) USER_HEAP_LIN_ADDR( handle );
2453 pDWP->actualCount = 0;
2454 pDWP->suggestedCount = count;
2455 pDWP->valid = TRUE;
2456 pDWP->wMagic = DWP_MAGIC;
2457 pDWP->hwndParent = 0;
2458 return handle;
2462 /***********************************************************************
2463 * DeferWindowPos16 (USER.260)
2465 HDWP16 WINAPI DeferWindowPos16( HDWP16 hdwp, HWND16 hwnd, HWND16 hwndAfter,
2466 INT16 x, INT16 y, INT16 cx, INT16 cy,
2467 UINT16 flags )
2469 return DeferWindowPos32( hdwp, hwnd, (INT32)(INT16)hwndAfter,
2470 x, y, cx, cy, flags );
2474 /***********************************************************************
2475 * DeferWindowPos32 (USER32.128)
2477 HDWP32 WINAPI DeferWindowPos32( HDWP32 hdwp, HWND32 hwnd, HWND32 hwndAfter,
2478 INT32 x, INT32 y, INT32 cx, INT32 cy,
2479 UINT32 flags )
2481 DWP *pDWP;
2482 int i;
2483 HDWP32 newhdwp = hdwp;
2484 /* HWND32 parent; */
2485 WND *pWnd;
2487 pDWP = (DWP *) USER_HEAP_LIN_ADDR( hdwp );
2488 if (!pDWP) return 0;
2489 if (hwnd == GetDesktopWindow32()) return 0;
2491 if (!(pWnd=WIN_FindWndPtr( hwnd ))) {
2492 USER_HEAP_FREE( hdwp );
2493 return 0;
2496 /* Numega Bounds Checker Demo dislikes the following code.
2497 In fact, I've not been able to find any "same parent" requirement in any docu
2498 [AM 980509]
2500 #if 0
2501 /* All the windows of a DeferWindowPos() must have the same parent */
2502 parent = pWnd->parent->hwndSelf;
2503 if (pDWP->actualCount == 0) pDWP->hwndParent = parent;
2504 else if (parent != pDWP->hwndParent)
2506 USER_HEAP_FREE( hdwp );
2507 return 0;
2509 #endif
2511 for (i = 0; i < pDWP->actualCount; i++)
2513 if (pDWP->winPos[i].hwnd == hwnd)
2515 /* Merge with the other changes */
2516 if (!(flags & SWP_NOZORDER))
2518 pDWP->winPos[i].hwndInsertAfter = hwndAfter;
2520 if (!(flags & SWP_NOMOVE))
2522 pDWP->winPos[i].x = x;
2523 pDWP->winPos[i].y = y;
2525 if (!(flags & SWP_NOSIZE))
2527 pDWP->winPos[i].cx = cx;
2528 pDWP->winPos[i].cy = cy;
2530 pDWP->winPos[i].flags &= flags | ~(SWP_NOSIZE | SWP_NOMOVE |
2531 SWP_NOZORDER | SWP_NOREDRAW |
2532 SWP_NOACTIVATE | SWP_NOCOPYBITS|
2533 SWP_NOOWNERZORDER);
2534 pDWP->winPos[i].flags |= flags & (SWP_SHOWWINDOW | SWP_HIDEWINDOW |
2535 SWP_FRAMECHANGED);
2536 return hdwp;
2539 if (pDWP->actualCount >= pDWP->suggestedCount)
2541 newhdwp = USER_HEAP_REALLOC( hdwp,
2542 sizeof(DWP) + pDWP->suggestedCount*sizeof(WINDOWPOS32) );
2543 if (!newhdwp) return 0;
2544 pDWP = (DWP *) USER_HEAP_LIN_ADDR( newhdwp );
2545 pDWP->suggestedCount++;
2547 pDWP->winPos[pDWP->actualCount].hwnd = hwnd;
2548 pDWP->winPos[pDWP->actualCount].hwndInsertAfter = hwndAfter;
2549 pDWP->winPos[pDWP->actualCount].x = x;
2550 pDWP->winPos[pDWP->actualCount].y = y;
2551 pDWP->winPos[pDWP->actualCount].cx = cx;
2552 pDWP->winPos[pDWP->actualCount].cy = cy;
2553 pDWP->winPos[pDWP->actualCount].flags = flags;
2554 pDWP->actualCount++;
2555 return newhdwp;
2559 /***********************************************************************
2560 * EndDeferWindowPos16 (USER.261)
2562 BOOL16 WINAPI EndDeferWindowPos16( HDWP16 hdwp )
2564 return EndDeferWindowPos32( hdwp );
2568 /***********************************************************************
2569 * EndDeferWindowPos32 (USER32.173)
2571 BOOL32 WINAPI EndDeferWindowPos32( HDWP32 hdwp )
2573 DWP *pDWP;
2574 WINDOWPOS32 *winpos;
2575 BOOL32 res = TRUE;
2576 int i;
2578 pDWP = (DWP *) USER_HEAP_LIN_ADDR( hdwp );
2579 if (!pDWP) return FALSE;
2580 for (i = 0, winpos = pDWP->winPos; i < pDWP->actualCount; i++, winpos++)
2582 if (!(res = SetWindowPos32( winpos->hwnd, winpos->hwndInsertAfter,
2583 winpos->x, winpos->y, winpos->cx,
2584 winpos->cy, winpos->flags ))) break;
2586 USER_HEAP_FREE( hdwp );
2587 return res;
2591 /***********************************************************************
2592 * TileChildWindows (USER.199)
2594 void WINAPI TileChildWindows( HWND16 parent, WORD action )
2596 FIXME(win, "(%04x, %d): stub\n", parent, action);
2599 /***********************************************************************
2600 * CascageChildWindows (USER.198)
2602 void WINAPI CascadeChildWindows( HWND16 parent, WORD action )
2604 FIXME(win, "(%04x, %d): stub\n", parent, action);
2606 /***********************************************************************
2607 * GetProgmanWindow [USER32.289]
2609 HRESULT WINAPI GetProgmanWindow ( )
2610 { FIXME(win,"stub\n");
2611 return 0;
2613 /***********************************************************************
2614 * GetTaskmanWindow [USER32.304]
2616 HRESULT WINAPI GetTaskmanWindow ( )
2617 { FIXME(win,"stub\n");
2618 return 0;
2620 /***********************************************************************
2621 * SetProgmanWindow [USER32.522]
2623 HRESULT WINAPI SetProgmanWindow ( DWORD x )
2624 { FIXME(win,"0x%08lx stub\n",x);
2625 return 0;
2627 /***********************************************************************
2628 * SetShellWindowEx [USER32.531]
2630 HRESULT WINAPI SetShellWindowEx ( DWORD x, DWORD y )
2631 { FIXME(win,"0x%08lx 0x%08lx stub\n",x,y);
2632 return 0;
2634 /***********************************************************************
2635 * SetTaskmanWindow [USER32.537]
2637 HRESULT WINAPI SetTaskmanWindow ( DWORD x )
2638 { FIXME(win,"0x%08lx stub\n",x);
2639 return 0;