2 * Window position related functions.
4 * Copyright 1993, 1994, 1995 Alexandre Julliard
5 * 1995, 1996, 1999 Alex Korobka
13 #include "wine/winuser16.h"
25 #include "nonclient.h"
26 #include "debugtools.h"
29 DEFAULT_DEBUG_CHANNEL(win);
31 #define HAS_DLGFRAME(style,exStyle) \
32 (((exStyle) & WS_EX_DLGMODALFRAME) || \
33 (((style) & WS_DLGFRAME) && !((style) & WS_BORDER)))
35 #define HAS_THICKFRAME(style) \
36 (((style) & WS_THICKFRAME) && \
37 !(((style) & (WS_DLGFRAME|WS_BORDER)) == WS_DLGFRAME))
39 #define EMPTYPOINT(pt) ((*(LONG*)&(pt)) == -1)
41 #define PLACE_MIN 0x0001
42 #define PLACE_MAX 0x0002
43 #define PLACE_RECT 0x0004
45 #define MINMAX_NOSWP 0x00010000
48 #define DWP_MAGIC ((INT)('W' | ('P' << 8) | ('O' << 16) | ('S' << 24)))
60 /* ----- internal variables ----- */
62 static HWND hwndPrevActive = 0; /* Previously active window */
63 static HWND hGlobalShellWindow=0; /*the shell*/
64 static HWND hGlobalTaskmanWindow=0;
65 static HWND hGlobalProgmanWindow=0;
67 static LPCSTR atomInternalPos;
69 extern HQUEUE16 hActiveQueue;
71 /***********************************************************************
72 * WINPOS_CreateInternalPosAtom
74 BOOL WINPOS_CreateInternalPosAtom()
77 atomInternalPos = (LPCSTR)(DWORD)GlobalAddAtomA(str);
78 return (atomInternalPos) ? TRUE : FALSE;
81 /***********************************************************************
82 * WINPOS_CheckInternalPos
84 * Called when a window is destroyed.
86 void WINPOS_CheckInternalPos( WND* wndPtr )
89 MESSAGEQUEUE *pMsgQ = 0;
90 HWND hwnd = wndPtr->hwndSelf;
92 lpPos = (LPINTERNALPOS) GetPropA( hwnd, atomInternalPos );
94 /* Retrieve the message queue associated with this window */
95 pMsgQ = (MESSAGEQUEUE *)QUEUE_Lock( wndPtr->hmemTaskQ );
98 WARN("\tMessage queue not found. Exiting!\n" );
102 if( hwnd == hwndPrevActive ) hwndPrevActive = 0;
104 if( hwnd == PERQDATA_GetActiveWnd( pMsgQ->pQData ) )
106 PERQDATA_SetActiveWnd( pMsgQ->pQData, 0 );
107 WARN("\tattempt to activate destroyed window!\n");
112 if( IsWindow(lpPos->hwndIconTitle) )
113 DestroyWindow( lpPos->hwndIconTitle );
114 HeapFree( GetProcessHeap(), 0, lpPos );
117 QUEUE_Unlock( pMsgQ );
121 /***********************************************************************
124 * Find a suitable place for an iconic window.
126 static POINT16 WINPOS_FindIconPos( WND* wndPtr, POINT16 pt )
129 short x, y, xspacing, yspacing;
131 GetClientRect16( wndPtr->parent->hwndSelf, &rectParent );
132 if ((pt.x >= rectParent.left) && (pt.x + GetSystemMetrics(SM_CXICON) < rectParent.right) &&
133 (pt.y >= rectParent.top) && (pt.y + GetSystemMetrics(SM_CYICON) < rectParent.bottom))
134 return pt; /* The icon already has a suitable position */
136 xspacing = GetSystemMetrics(SM_CXICONSPACING);
137 yspacing = GetSystemMetrics(SM_CYICONSPACING);
139 y = rectParent.bottom;
145 /* Check if another icon already occupies this spot */
146 WND *childPtr = WIN_LockWndPtr(wndPtr->parent->child);
149 if ((childPtr->dwStyle & WS_MINIMIZE) && (childPtr != wndPtr))
151 if ((childPtr->rectWindow.left < x + xspacing) &&
152 (childPtr->rectWindow.right >= x) &&
153 (childPtr->rectWindow.top <= y) &&
154 (childPtr->rectWindow.bottom > y - yspacing))
155 break; /* There's a window in there */
157 WIN_UpdateWndPtr(&childPtr,childPtr->next);
159 WIN_ReleaseWndPtr(childPtr);
160 if (!childPtr) /* No window was found, so it's OK for us */
162 pt.x = x + (xspacing - GetSystemMetrics(SM_CXICON)) / 2;
163 pt.y = y - (yspacing + GetSystemMetrics(SM_CYICON)) / 2;
167 } while(x <= rectParent.right-xspacing);
173 /***********************************************************************
174 * ArrangeIconicWindows (USER.170)
176 UINT16 WINAPI ArrangeIconicWindows16( HWND16 parent)
178 return ArrangeIconicWindows(parent);
180 /***********************************************************************
181 * ArrangeIconicWindows (USER32.@)
183 UINT WINAPI ArrangeIconicWindows( HWND parent )
187 INT x, y, xspacing, yspacing;
189 GetClientRect( parent, &rectParent );
191 y = rectParent.bottom;
192 xspacing = GetSystemMetrics(SM_CXICONSPACING);
193 yspacing = GetSystemMetrics(SM_CYICONSPACING);
195 hwndChild = GetWindow( parent, GW_CHILD );
198 if( IsIconic( hwndChild ) )
200 WND *wndPtr = WIN_FindWndPtr(hwndChild);
202 WINPOS_ShowIconTitle( wndPtr, FALSE );
204 SetWindowPos( hwndChild, 0, x + (xspacing - GetSystemMetrics(SM_CXICON)) / 2,
205 y - yspacing - GetSystemMetrics(SM_CYICON)/2, 0, 0,
206 SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE );
207 if( IsWindow(hwndChild) )
208 WINPOS_ShowIconTitle(wndPtr , TRUE );
209 WIN_ReleaseWndPtr(wndPtr);
211 if (x <= rectParent.right - xspacing) x += xspacing;
218 hwndChild = GetWindow( hwndChild, GW_HWNDNEXT );
224 /***********************************************************************
225 * SwitchToThisWindow (USER.172)
227 void WINAPI SwitchToThisWindow16( HWND16 hwnd, BOOL16 restore )
229 SwitchToThisWindow( hwnd, restore );
233 /***********************************************************************
234 * SwitchToThisWindow (USER32.@)
236 void WINAPI SwitchToThisWindow( HWND hwnd, BOOL restore )
238 ShowWindow( hwnd, restore ? SW_RESTORE : SW_SHOWMINIMIZED );
242 /***********************************************************************
243 * GetWindowRect (USER.32)
245 void WINAPI GetWindowRect16( HWND16 hwnd, LPRECT16 rect )
247 WND * wndPtr = WIN_FindWndPtr( hwnd );
250 CONV_RECT32TO16( &wndPtr->rectWindow, rect );
252 MapWindowPoints16( wndPtr->parent->hwndSelf, 0, (POINT16 *)rect, 2 );
253 WIN_ReleaseWndPtr(wndPtr);
257 /***********************************************************************
258 * GetWindowRect (USER32.@)
260 BOOL WINAPI GetWindowRect( HWND hwnd, LPRECT rect )
262 WND * wndPtr = WIN_FindWndPtr( hwnd );
263 if (!wndPtr) return FALSE;
265 *rect = wndPtr->rectWindow;
267 MapWindowPoints( wndPtr->parent->hwndSelf, 0, (POINT *)rect, 2 );
268 WIN_ReleaseWndPtr(wndPtr);
273 /***********************************************************************
274 * GetWindowRgn (USER32.@)
276 int WINAPI GetWindowRgn ( HWND hwnd, HRGN hrgn )
279 WND *wndPtr = WIN_FindWndPtr( hwnd );
282 if (wndPtr->hrgnWnd) nRet = CombineRgn( hrgn, wndPtr->hrgnWnd, 0, RGN_COPY );
283 WIN_ReleaseWndPtr(wndPtr);
288 /***********************************************************************
289 * SetWindowRgn (USER32.@)
291 int WINAPI SetWindowRgn( HWND hwnd, HRGN hrgn, BOOL bRedraw )
297 if (USER_Driver.pSetWindowRgn)
298 return USER_Driver.pSetWindowRgn( hwnd, hrgn, bRedraw );
300 if (!(wndPtr = WIN_FindWndPtr(hwnd))) return FALSE;
302 if (wndPtr->hrgnWnd == hrgn)
308 if (hrgn) /* verify that region really exists */
310 if (GetRgnBox( hrgn, &rect ) == ERROR) goto done;
315 /* delete previous region */
316 DeleteObject(wndPtr->hrgnWnd);
319 wndPtr->hrgnWnd = hrgn;
321 /* Size the window to the rectangle of the new region (if it isn't NULL) */
322 if (hrgn) SetWindowPos( hwnd, 0, rect.left, rect.top,
323 rect.right - rect.left, rect.bottom - rect.top,
324 SWP_NOSIZE | SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOACTIVATE |
325 SWP_NOZORDER | (bRedraw ? 0 : SWP_NOREDRAW) );
329 WIN_ReleaseWndPtr(wndPtr);
333 /***********************************************************************
334 * SetWindowRgn (USER.668)
336 INT16 WINAPI SetWindowRgn16( HWND16 hwnd, HRGN16 hrgn,BOOL16 bRedraw)
340 FIXME("SetWindowRgn16: stub\n");
345 /***********************************************************************
346 * GetClientRect (USER.33)
348 void WINAPI GetClientRect16( HWND16 hwnd, LPRECT16 rect )
350 WND * wndPtr = WIN_FindWndPtr( hwnd );
352 rect->left = rect->top = rect->right = rect->bottom = 0;
355 rect->right = wndPtr->rectClient.right - wndPtr->rectClient.left;
356 rect->bottom = wndPtr->rectClient.bottom - wndPtr->rectClient.top;
358 WIN_ReleaseWndPtr(wndPtr);
362 /***********************************************************************
363 * GetClientRect (USER32.@)
365 BOOL WINAPI GetClientRect( HWND hwnd, LPRECT rect )
367 WND * wndPtr = WIN_FindWndPtr( hwnd );
369 rect->left = rect->top = rect->right = rect->bottom = 0;
370 if (!wndPtr) return FALSE;
371 rect->right = wndPtr->rectClient.right - wndPtr->rectClient.left;
372 rect->bottom = wndPtr->rectClient.bottom - wndPtr->rectClient.top;
374 WIN_ReleaseWndPtr(wndPtr);
379 /*******************************************************************
380 * ClientToScreen (USER.28)
382 void WINAPI ClientToScreen16( HWND16 hwnd, LPPOINT16 lppnt )
384 MapWindowPoints16( hwnd, 0, lppnt, 1 );
388 /*******************************************************************
389 * ClientToScreen (USER32.@)
391 BOOL WINAPI ClientToScreen( HWND hwnd, LPPOINT lppnt )
393 MapWindowPoints( hwnd, 0, lppnt, 1 );
398 /*******************************************************************
399 * ScreenToClient (USER.29)
401 void WINAPI ScreenToClient16( HWND16 hwnd, LPPOINT16 lppnt )
403 MapWindowPoints16( 0, hwnd, lppnt, 1 );
407 /*******************************************************************
408 * ScreenToClient (USER32.@)
410 BOOL WINAPI ScreenToClient( HWND hwnd, LPPOINT lppnt )
412 MapWindowPoints( 0, hwnd, lppnt, 1 );
417 /***********************************************************************
418 * WINPOS_WindowFromPoint
420 * Find the window and hittest for a given point.
422 INT16 WINPOS_WindowFromPoint( WND* wndScope, POINT pt, WND **ppWnd )
425 INT16 hittest = HTERROR;
429 TRACE("scope %04x %ld,%ld\n", wndScope->hwndSelf, pt.x, pt.y);
431 wndPtr = WIN_LockWndPtr(wndScope->child);
433 if( wndScope->dwStyle & WS_DISABLED )
439 if (wndScope->parent)
440 MapWindowPoints( GetDesktopWindow(), wndScope->parent->hwndSelf, &xy, 1 );
442 if (xy.x < wndScope->rectClient.left || pt.x >= wndScope->rectClient.right ||
443 xy.y < wndScope->rectClient.top || pt.y >= wndScope->rectClient.bottom)
446 xy.x -= wndScope->rectClient.left;
447 xy.y -= wndScope->rectClient.top;
453 /* If point is in window, and window is visible, and it */
454 /* is enabled (or it's a top-level window), then explore */
455 /* its children. Otherwise, go to the next window. */
457 if ((wndPtr->dwStyle & WS_VISIBLE) &&
458 ((wndPtr->dwExStyle & (WS_EX_LAYERED | WS_EX_TRANSPARENT)) != (WS_EX_LAYERED | WS_EX_TRANSPARENT)) &&
459 (!(wndPtr->dwStyle & WS_DISABLED) ||
460 ((wndPtr->dwStyle & (WS_POPUP | WS_CHILD)) != WS_CHILD)) &&
462 PtInRegion(wndPtr->hrgnWnd, xy.x - wndPtr->rectWindow.left,
463 xy.y - wndPtr->rectWindow.top) :
464 ((xy.x >= wndPtr->rectWindow.left) &&
465 (xy.x < wndPtr->rectWindow.right) &&
466 (xy.y >= wndPtr->rectWindow.top) &&
467 (xy.y < wndPtr->rectWindow.bottom))))
469 TRACE("%ld,%ld is inside %04x\n", xy.x, xy.y, wndPtr->hwndSelf);
470 *ppWnd = wndPtr; /* Got a suitable window */
472 /* If window is minimized or disabled, return at once */
473 if (wndPtr->dwStyle & WS_MINIMIZE)
475 retvalue = HTCAPTION;
478 if (wndPtr->dwStyle & WS_DISABLED)
484 /* If point is not in client area, ignore the children */
485 if ((xy.x < wndPtr->rectClient.left) ||
486 (xy.x >= wndPtr->rectClient.right) ||
487 (xy.y < wndPtr->rectClient.top) ||
488 (xy.y >= wndPtr->rectClient.bottom)) break;
490 xy.x -= wndPtr->rectClient.left;
491 xy.y -= wndPtr->rectClient.top;
492 WIN_UpdateWndPtr(&wndPtr,wndPtr->child);
496 WIN_UpdateWndPtr(&wndPtr,wndPtr->next);
501 /* If nothing found, try the scope window */
502 if (!*ppWnd) *ppWnd = wndScope;
504 /* Send the WM_NCHITTEST message (only if to the same task) */
505 if ((*ppWnd)->hmemTaskQ == GetFastQueue16())
507 hittest = SendMessageA( (*ppWnd)->hwndSelf, WM_NCHITTEST,
508 0, MAKELONG( pt.x, pt.y ) );
509 if (hittest != HTTRANSPARENT)
511 retvalue = hittest; /* Found the window */
521 /* If no children found in last search, make point relative to parent */
524 xy.x += (*ppWnd)->rectClient.left;
525 xy.y += (*ppWnd)->rectClient.top;
528 /* Restart the search from the next sibling */
529 WIN_UpdateWndPtr(&wndPtr,(*ppWnd)->next);
530 *ppWnd = (*ppWnd)->parent;
534 WIN_ReleaseWndPtr(wndPtr);
539 /*******************************************************************
540 * WindowFromPoint (USER.30)
542 HWND16 WINAPI WindowFromPoint16( POINT16 pt )
546 CONV_POINT16TO32( &pt, &pt32 );
547 return WindowFromPoint( pt32 );
551 /*******************************************************************
552 * WindowFromPoint (USER32.@)
554 HWND WINAPI WindowFromPoint( POINT pt )
557 WINPOS_WindowFromPoint( WIN_GetDesktop(), pt, &pWnd );
558 WIN_ReleaseDesktop();
559 return (HWND)pWnd->hwndSelf;
563 /*******************************************************************
564 * ChildWindowFromPoint (USER.191)
566 HWND16 WINAPI ChildWindowFromPoint16( HWND16 hwndParent, POINT16 pt )
569 CONV_POINT16TO32( &pt, &pt32 );
570 return (HWND16)ChildWindowFromPoint( hwndParent, pt32 );
574 /*******************************************************************
575 * ChildWindowFromPoint (USER32.@)
577 HWND WINAPI ChildWindowFromPoint( HWND hwndParent, POINT pt )
579 /* pt is in the client coordinates */
581 WND* wnd = WIN_FindWndPtr(hwndParent);
587 /* get client rect fast */
588 rect.top = rect.left = 0;
589 rect.right = wnd->rectClient.right - wnd->rectClient.left;
590 rect.bottom = wnd->rectClient.bottom - wnd->rectClient.top;
592 if (!PtInRect( &rect, pt ))
597 WIN_UpdateWndPtr(&wnd,wnd->child);
600 if (PtInRect( &wnd->rectWindow, pt ))
602 retvalue = wnd->hwndSelf;
605 WIN_UpdateWndPtr(&wnd,wnd->next);
607 retvalue = hwndParent;
609 WIN_ReleaseWndPtr(wnd);
613 /*******************************************************************
614 * ChildWindowFromPointEx (USER.399)
616 HWND16 WINAPI ChildWindowFromPointEx16( HWND16 hwndParent, POINT16 pt, UINT16 uFlags)
619 CONV_POINT16TO32( &pt, &pt32 );
620 return (HWND16)ChildWindowFromPointEx( hwndParent, pt32, uFlags );
624 /*******************************************************************
625 * ChildWindowFromPointEx (USER32.@)
627 HWND WINAPI ChildWindowFromPointEx( HWND hwndParent, POINT pt,
630 /* pt is in the client coordinates */
632 WND* wnd = WIN_FindWndPtr(hwndParent);
638 /* get client rect fast */
639 rect.top = rect.left = 0;
640 rect.right = wnd->rectClient.right - wnd->rectClient.left;
641 rect.bottom = wnd->rectClient.bottom - wnd->rectClient.top;
643 if (!PtInRect( &rect, pt ))
648 WIN_UpdateWndPtr(&wnd,wnd->child);
652 if (PtInRect( &wnd->rectWindow, pt )) {
653 if ( (uFlags & CWP_SKIPINVISIBLE) &&
654 !(wnd->dwStyle & WS_VISIBLE) );
655 else if ( (uFlags & CWP_SKIPDISABLED) &&
656 (wnd->dwStyle & WS_DISABLED) );
657 else if ( (uFlags & CWP_SKIPTRANSPARENT) &&
658 (wnd->dwExStyle & WS_EX_TRANSPARENT) );
661 retvalue = wnd->hwndSelf;
666 WIN_UpdateWndPtr(&wnd,wnd->next);
668 retvalue = hwndParent;
670 WIN_ReleaseWndPtr(wnd);
675 /*******************************************************************
676 * WINPOS_GetWinOffset
678 * Calculate the offset between the origin of the two windows. Used
679 * to implement MapWindowPoints.
681 static void WINPOS_GetWinOffset( HWND hwndFrom, HWND hwndTo,
686 offset->x = offset->y = 0;
687 if (hwndFrom == hwndTo ) return;
689 /* Translate source window origin to screen coords */
692 if (!(wndPtr = WIN_FindWndPtr( hwndFrom )))
694 ERR("bad hwndFrom = %04x\n",hwndFrom);
697 while (wndPtr->parent)
699 offset->x += wndPtr->rectClient.left;
700 offset->y += wndPtr->rectClient.top;
701 WIN_UpdateWndPtr(&wndPtr,wndPtr->parent);
703 WIN_ReleaseWndPtr(wndPtr);
706 /* Translate origin to destination window coords */
709 if (!(wndPtr = WIN_FindWndPtr( hwndTo )))
711 ERR("bad hwndTo = %04x\n", hwndTo );
714 while (wndPtr->parent)
716 offset->x -= wndPtr->rectClient.left;
717 offset->y -= wndPtr->rectClient.top;
718 WIN_UpdateWndPtr(&wndPtr,wndPtr->parent);
720 WIN_ReleaseWndPtr(wndPtr);
725 /*******************************************************************
726 * MapWindowPoints (USER.258)
728 void WINAPI MapWindowPoints16( HWND16 hwndFrom, HWND16 hwndTo,
729 LPPOINT16 lppt, UINT16 count )
733 WINPOS_GetWinOffset( hwndFrom, hwndTo, &offset );
743 /*******************************************************************
744 * MapWindowPoints (USER32.@)
746 INT WINAPI MapWindowPoints( HWND hwndFrom, HWND hwndTo,
747 LPPOINT lppt, UINT count )
751 WINPOS_GetWinOffset( hwndFrom, hwndTo, &offset );
758 return MAKELONG( LOWORD(offset.x), LOWORD(offset.y) );
762 /***********************************************************************
765 BOOL16 WINAPI IsIconic16(HWND16 hWnd)
767 return IsIconic(hWnd);
771 /***********************************************************************
772 * IsIconic (USER32.@)
774 BOOL WINAPI IsIconic(HWND hWnd)
777 WND * wndPtr = WIN_FindWndPtr(hWnd);
778 if (wndPtr == NULL) return FALSE;
779 retvalue = (wndPtr->dwStyle & WS_MINIMIZE) != 0;
780 WIN_ReleaseWndPtr(wndPtr);
785 /***********************************************************************
786 * IsZoomed (USER.272)
788 BOOL16 WINAPI IsZoomed16(HWND16 hWnd)
790 return IsZoomed(hWnd);
794 /***********************************************************************
795 * IsZoomed (USER32.@)
797 BOOL WINAPI IsZoomed(HWND hWnd)
800 WND * wndPtr = WIN_FindWndPtr(hWnd);
801 if (wndPtr == NULL) return FALSE;
802 retvalue = (wndPtr->dwStyle & WS_MAXIMIZE) != 0;
803 WIN_ReleaseWndPtr(wndPtr);
808 /*******************************************************************
809 * GetActiveWindow (USER.60)
811 HWND16 WINAPI GetActiveWindow16(void)
813 return (HWND16)GetActiveWindow();
816 /*******************************************************************
817 * GetActiveWindow (USER32.@)
819 HWND WINAPI GetActiveWindow(void)
821 MESSAGEQUEUE *pCurMsgQ = 0;
824 /* Get the messageQ for the current thread */
825 if (!(pCurMsgQ = (MESSAGEQUEUE *)QUEUE_Lock( GetFastQueue16() )))
827 WARN("\tCurrent message queue not found. Exiting!\n" );
831 /* Return the current active window from the perQ data of the current message Q */
832 hwndActive = PERQDATA_GetActiveWnd( pCurMsgQ->pQData );
834 QUEUE_Unlock( pCurMsgQ );
839 /*******************************************************************
842 static BOOL WINPOS_CanActivate(WND* pWnd)
844 if( pWnd && ( (pWnd->dwStyle & (WS_DISABLED | WS_VISIBLE | WS_CHILD))
845 == WS_VISIBLE ) ) return TRUE;
850 /*******************************************************************
851 * SetActiveWindow (USER.59)
853 HWND16 WINAPI SetActiveWindow16( HWND16 hwnd )
855 return SetActiveWindow(hwnd);
859 /*******************************************************************
860 * SetActiveWindow (USER32.@)
862 HWND WINAPI SetActiveWindow( HWND hwnd )
865 WND *wndPtr = WIN_FindWndPtr( hwnd );
866 MESSAGEQUEUE *pMsgQ = 0, *pCurMsgQ = 0;
868 if (!wndPtr || (wndPtr->dwStyle & (WS_DISABLED | WS_CHILD)))
874 /* Get the messageQ for the current thread */
875 if (!(pCurMsgQ = (MESSAGEQUEUE *)QUEUE_Lock( GetFastQueue16() )))
877 WARN("\tCurrent message queue not found. Exiting!\n" );
881 /* Retrieve the message queue associated with this window */
882 pMsgQ = (MESSAGEQUEUE *)QUEUE_Lock( wndPtr->hmemTaskQ );
885 WARN("\tWindow message queue not found. Exiting!\n" );
889 /* Make sure that the window is associated with the calling threads
890 * message queue. It must share the same perQ data.
893 if ( pCurMsgQ->pQData != pMsgQ->pQData )
896 /* Save current active window */
897 prev = PERQDATA_GetActiveWnd( pMsgQ->pQData );
899 WINPOS_SetActiveWindow( hwnd, 0, 0 );
902 /* Unlock the queues before returning */
904 QUEUE_Unlock( pMsgQ );
906 QUEUE_Unlock( pCurMsgQ );
909 WIN_ReleaseWndPtr(wndPtr);
914 /*******************************************************************
915 * GetForegroundWindow (USER.608)
917 HWND16 WINAPI GetForegroundWindow16(void)
919 return (HWND16)GetForegroundWindow();
923 /*******************************************************************
924 * SetForegroundWindow (USER.609)
926 BOOL16 WINAPI SetForegroundWindow16( HWND16 hwnd )
928 return SetForegroundWindow( hwnd );
932 /*******************************************************************
933 * GetForegroundWindow (USER32.@)
935 HWND WINAPI GetForegroundWindow(void)
939 /* Get the foreground window (active window of hActiveQueue) */
942 MESSAGEQUEUE *pActiveQueue = QUEUE_Lock( hActiveQueue );
944 hwndActive = PERQDATA_GetActiveWnd( pActiveQueue->pQData );
946 QUEUE_Unlock( pActiveQueue );
952 /*******************************************************************
953 * SetForegroundWindow (USER32.@)
955 BOOL WINAPI SetForegroundWindow( HWND hwnd )
957 return WINPOS_ChangeActiveWindow( hwnd, FALSE );
961 /*******************************************************************
962 * AllowSetForegroundWindow (USER32.@)
964 BOOL WINAPI AllowSetForegroundWindow( DWORD procid )
966 /* FIXME: If Win98/2000 style SetForegroundWindow behavior is
967 * implemented, then fix this function. */
972 /*******************************************************************
973 * LockSetForegroundWindow (USER32.@)
975 BOOL WINAPI LockSetForegroundWindow( UINT lockcode )
977 /* FIXME: If Win98/2000 style SetForegroundWindow behavior is
978 * implemented, then fix this function. */
983 /*******************************************************************
984 * GetShellWindow (USER.600)
986 HWND16 WINAPI GetShellWindow16(void)
988 return GetShellWindow();
991 /*******************************************************************
992 * SetShellWindow (USER32.@)
994 HWND WINAPI SetShellWindow(HWND hwndshell)
995 { WARN("(hWnd=%08x) semi stub\n",hwndshell );
997 hGlobalShellWindow = hwndshell;
998 return hGlobalShellWindow;
1002 /*******************************************************************
1003 * GetShellWindow (USER32.@)
1005 HWND WINAPI GetShellWindow(void)
1006 { WARN("(hWnd=%x) semi stub\n",hGlobalShellWindow );
1008 return hGlobalShellWindow;
1012 /***********************************************************************
1013 * BringWindowToTop (USER.45)
1015 BOOL16 WINAPI BringWindowToTop16( HWND16 hwnd )
1017 return BringWindowToTop(hwnd);
1021 /***********************************************************************
1022 * BringWindowToTop (USER32.@)
1024 BOOL WINAPI BringWindowToTop( HWND hwnd )
1026 return SetWindowPos( hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE );
1030 /***********************************************************************
1031 * MoveWindow (USER.56)
1033 BOOL16 WINAPI MoveWindow16( HWND16 hwnd, INT16 x, INT16 y, INT16 cx, INT16 cy,
1036 return MoveWindow(hwnd,x,y,cx,cy,repaint);
1040 /***********************************************************************
1041 * MoveWindow (USER32.@)
1043 BOOL WINAPI MoveWindow( HWND hwnd, INT x, INT y, INT cx, INT cy,
1046 int flags = SWP_NOZORDER | SWP_NOACTIVATE;
1047 if (!repaint) flags |= SWP_NOREDRAW;
1048 TRACE("%04x %d,%d %dx%d %d\n",
1049 hwnd, x, y, cx, cy, repaint );
1050 return SetWindowPos( hwnd, 0, x, y, cx, cy, flags );
1053 /***********************************************************************
1054 * WINPOS_InitInternalPos
1056 static LPINTERNALPOS WINPOS_InitInternalPos( WND* wnd, POINT pt,
1057 LPRECT restoreRect )
1059 LPINTERNALPOS lpPos = (LPINTERNALPOS) GetPropA( wnd->hwndSelf,
1063 /* this happens when the window is minimized/maximized
1064 * for the first time (rectWindow is not adjusted yet) */
1066 lpPos = HeapAlloc( GetProcessHeap(), 0, sizeof(INTERNALPOS) );
1067 if( !lpPos ) return NULL;
1069 SetPropA( wnd->hwndSelf, atomInternalPos, (HANDLE)lpPos );
1070 lpPos->hwndIconTitle = 0; /* defer until needs to be shown */
1071 CONV_RECT32TO16( &wnd->rectWindow, &lpPos->rectNormal );
1072 *(UINT*)&lpPos->ptIconPos = *(UINT*)&lpPos->ptMaxPos = 0xFFFFFFFF;
1075 if( wnd->dwStyle & WS_MINIMIZE )
1076 CONV_POINT32TO16( &pt, &lpPos->ptIconPos );
1077 else if( wnd->dwStyle & WS_MAXIMIZE )
1078 CONV_POINT32TO16( &pt, &lpPos->ptMaxPos );
1079 else if( restoreRect )
1080 CONV_RECT32TO16( restoreRect, &lpPos->rectNormal );
1085 /***********************************************************************
1086 * WINPOS_RedrawIconTitle
1088 BOOL WINPOS_RedrawIconTitle( HWND hWnd )
1090 LPINTERNALPOS lpPos = (LPINTERNALPOS)GetPropA( hWnd, atomInternalPos );
1093 if( lpPos->hwndIconTitle )
1095 SendMessageA( lpPos->hwndIconTitle, WM_SHOWWINDOW, TRUE, 0);
1096 InvalidateRect( lpPos->hwndIconTitle, NULL, TRUE );
1103 /***********************************************************************
1104 * WINPOS_ShowIconTitle
1106 BOOL WINPOS_ShowIconTitle( WND* pWnd, BOOL bShow )
1108 LPINTERNALPOS lpPos = (LPINTERNALPOS)GetPropA( pWnd->hwndSelf, atomInternalPos );
1110 if( lpPos && !(pWnd->dwExStyle & WS_EX_MANAGED))
1112 HWND16 hWnd = lpPos->hwndIconTitle;
1114 TRACE("0x%04x %i\n", pWnd->hwndSelf, (bShow != 0) );
1117 lpPos->hwndIconTitle = hWnd = ICONTITLE_Create( pWnd );
1120 if( ( pWnd = WIN_FindWndPtr(hWnd) ) != NULL)
1122 if( !(pWnd->dwStyle & WS_VISIBLE) )
1124 SendMessageA( hWnd, WM_SHOWWINDOW, TRUE, 0 );
1125 SetWindowPos( hWnd, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE |
1126 SWP_NOACTIVATE | SWP_NOZORDER | SWP_SHOWWINDOW );
1128 WIN_ReleaseWndPtr(pWnd);
1131 else ShowWindow( hWnd, SW_HIDE );
1136 /*******************************************************************
1137 * WINPOS_GetMinMaxInfo
1139 * Get the minimized and maximized information for a window.
1141 void WINPOS_GetMinMaxInfo( WND *wndPtr, POINT *maxSize, POINT *maxPos,
1142 POINT *minTrack, POINT *maxTrack )
1144 LPINTERNALPOS lpPos;
1148 /* Compute default values */
1150 MinMax.ptMaxSize.x = GetSystemMetrics(SM_CXSCREEN);
1151 MinMax.ptMaxSize.y = GetSystemMetrics(SM_CYSCREEN);
1152 MinMax.ptMinTrackSize.x = GetSystemMetrics(SM_CXMINTRACK);
1153 MinMax.ptMinTrackSize.y = GetSystemMetrics(SM_CYMINTRACK);
1154 MinMax.ptMaxTrackSize.x = GetSystemMetrics(SM_CXSCREEN);
1155 MinMax.ptMaxTrackSize.y = GetSystemMetrics(SM_CYSCREEN);
1157 if (wndPtr->dwExStyle & WS_EX_MANAGED) xinc = yinc = 0;
1158 else if (HAS_DLGFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
1160 xinc = GetSystemMetrics(SM_CXDLGFRAME);
1161 yinc = GetSystemMetrics(SM_CYDLGFRAME);
1166 if (HAS_THICKFRAME(wndPtr->dwStyle))
1168 xinc += GetSystemMetrics(SM_CXFRAME);
1169 yinc += GetSystemMetrics(SM_CYFRAME);
1171 if (wndPtr->dwStyle & WS_BORDER)
1173 xinc += GetSystemMetrics(SM_CXBORDER);
1174 yinc += GetSystemMetrics(SM_CYBORDER);
1177 MinMax.ptMaxSize.x += 2 * xinc;
1178 MinMax.ptMaxSize.y += 2 * yinc;
1180 lpPos = (LPINTERNALPOS)GetPropA( wndPtr->hwndSelf, atomInternalPos );
1181 if( lpPos && !EMPTYPOINT(lpPos->ptMaxPos) )
1182 CONV_POINT16TO32( &lpPos->ptMaxPos, &MinMax.ptMaxPosition );
1185 MinMax.ptMaxPosition.x = -xinc;
1186 MinMax.ptMaxPosition.y = -yinc;
1189 SendMessageA( wndPtr->hwndSelf, WM_GETMINMAXINFO, 0, (LPARAM)&MinMax );
1191 /* Some sanity checks */
1193 TRACE("%ld %ld / %ld %ld / %ld %ld / %ld %ld\n",
1194 MinMax.ptMaxSize.x, MinMax.ptMaxSize.y,
1195 MinMax.ptMaxPosition.x, MinMax.ptMaxPosition.y,
1196 MinMax.ptMaxTrackSize.x, MinMax.ptMaxTrackSize.y,
1197 MinMax.ptMinTrackSize.x, MinMax.ptMinTrackSize.y);
1198 MinMax.ptMaxTrackSize.x = max( MinMax.ptMaxTrackSize.x,
1199 MinMax.ptMinTrackSize.x );
1200 MinMax.ptMaxTrackSize.y = max( MinMax.ptMaxTrackSize.y,
1201 MinMax.ptMinTrackSize.y );
1203 if (maxSize) *maxSize = MinMax.ptMaxSize;
1204 if (maxPos) *maxPos = MinMax.ptMaxPosition;
1205 if (minTrack) *minTrack = MinMax.ptMinTrackSize;
1206 if (maxTrack) *maxTrack = MinMax.ptMaxTrackSize;
1209 /***********************************************************************
1210 * WINPOS_MinMaximize
1212 * Fill in lpRect and return additional flags to be used with SetWindowPos().
1213 * This function assumes that 'cmd' is different from the current window
1216 UINT WINPOS_MinMaximize( WND* wndPtr, UINT16 cmd, LPRECT16 lpRect )
1220 LPINTERNALPOS lpPos;
1222 TRACE("0x%04x %u\n", wndPtr->hwndSelf, cmd );
1224 size.x = wndPtr->rectWindow.left; size.y = wndPtr->rectWindow.top;
1225 lpPos = WINPOS_InitInternalPos( wndPtr, size, &wndPtr->rectWindow );
1227 if (lpPos && !HOOK_CallHooksA(WH_CBT, HCBT_MINMAX, wndPtr->hwndSelf, cmd))
1229 if( wndPtr->dwStyle & WS_MINIMIZE )
1231 if( !SendMessageA( wndPtr->hwndSelf, WM_QUERYOPEN, 0, 0L ) )
1232 return (SWP_NOSIZE | SWP_NOMOVE);
1233 swpFlags |= SWP_NOCOPYBITS;
1238 if( wndPtr->dwStyle & WS_MAXIMIZE)
1240 wndPtr->flags |= WIN_RESTORE_MAX;
1241 wndPtr->dwStyle &= ~WS_MAXIMIZE;
1244 wndPtr->flags &= ~WIN_RESTORE_MAX;
1245 wndPtr->dwStyle |= WS_MINIMIZE;
1247 if( wndPtr->pDriver->pSetHostAttr( wndPtr, HAK_ICONICSTATE, TRUE ) )
1248 swpFlags |= MINMAX_NOSWP;
1250 lpPos->ptIconPos = WINPOS_FindIconPos( wndPtr, lpPos->ptIconPos );
1252 SetRect16( lpRect, lpPos->ptIconPos.x, lpPos->ptIconPos.y,
1253 GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON) );
1254 swpFlags |= SWP_NOCOPYBITS;
1258 CONV_POINT16TO32( &lpPos->ptMaxPos, &pt );
1259 WINPOS_GetMinMaxInfo( wndPtr, &size, &pt, NULL, NULL );
1260 CONV_POINT32TO16( &pt, &lpPos->ptMaxPos );
1262 if( wndPtr->dwStyle & WS_MINIMIZE )
1264 wndPtr->pDriver->pSetHostAttr( wndPtr, HAK_ICONICSTATE, FALSE );
1266 WINPOS_ShowIconTitle( wndPtr, FALSE );
1267 wndPtr->dwStyle &= ~WS_MINIMIZE;
1269 wndPtr->dwStyle |= WS_MAXIMIZE;
1271 SetRect16( lpRect, lpPos->ptMaxPos.x, lpPos->ptMaxPos.y,
1276 if( wndPtr->dwStyle & WS_MINIMIZE )
1278 wndPtr->pDriver->pSetHostAttr( wndPtr, HAK_ICONICSTATE, FALSE );
1280 wndPtr->dwStyle &= ~WS_MINIMIZE;
1281 WINPOS_ShowIconTitle( wndPtr, FALSE );
1283 if( wndPtr->flags & WIN_RESTORE_MAX)
1285 /* Restore to maximized position */
1286 CONV_POINT16TO32( &lpPos->ptMaxPos, &pt );
1287 WINPOS_GetMinMaxInfo( wndPtr, &size, &pt, NULL, NULL);
1288 CONV_POINT32TO16( &pt, &lpPos->ptMaxPos );
1289 wndPtr->dwStyle |= WS_MAXIMIZE;
1290 SetRect16( lpRect, lpPos->ptMaxPos.x, lpPos->ptMaxPos.y, size.x, size.y );
1295 if( !(wndPtr->dwStyle & WS_MAXIMIZE) ) return (UINT16)(-1);
1296 else wndPtr->dwStyle &= ~WS_MAXIMIZE;
1298 /* Restore to normal position */
1300 *lpRect = lpPos->rectNormal;
1301 lpRect->right -= lpRect->left;
1302 lpRect->bottom -= lpRect->top;
1306 } else swpFlags |= SWP_NOSIZE | SWP_NOMOVE;
1310 /***********************************************************************
1311 * ShowWindowAsync (USER32.@)
1313 * doesn't wait; returns immediately.
1314 * used by threads to toggle windows in other (possibly hanging) threads
1316 BOOL WINAPI ShowWindowAsync( HWND hwnd, INT cmd )
1318 /* FIXME: does ShowWindow() return immediately ? */
1319 return ShowWindow(hwnd, cmd);
1323 /***********************************************************************
1324 * ShowWindow (USER.42)
1326 BOOL16 WINAPI ShowWindow16( HWND16 hwnd, INT16 cmd )
1328 return ShowWindow(hwnd,cmd);
1332 /***********************************************************************
1333 * ShowWindow (USER32.@)
1335 BOOL WINAPI ShowWindow( HWND hwnd, INT cmd )
1337 WND* wndPtr = WIN_FindWndPtr( hwnd );
1338 BOOL wasVisible, showFlag;
1339 RECT16 newPos = {0, 0, 0, 0};
1342 if (!wndPtr) return FALSE;
1344 TRACE("hwnd=%04x, cmd=%d\n", hwnd, cmd);
1346 wasVisible = (wndPtr->dwStyle & WS_VISIBLE) != 0;
1351 if (!wasVisible) goto END;;
1352 swp |= SWP_HIDEWINDOW | SWP_NOSIZE | SWP_NOMOVE |
1353 SWP_NOACTIVATE | SWP_NOZORDER;
1356 case SW_SHOWMINNOACTIVE:
1357 swp |= SWP_NOACTIVATE | SWP_NOZORDER;
1359 case SW_SHOWMINIMIZED:
1360 swp |= SWP_SHOWWINDOW;
1363 swp |= SWP_FRAMECHANGED;
1364 if( !(wndPtr->dwStyle & WS_MINIMIZE) )
1365 swp |= WINPOS_MinMaximize( wndPtr, SW_MINIMIZE, &newPos );
1366 else swp |= SWP_NOSIZE | SWP_NOMOVE;
1369 case SW_SHOWMAXIMIZED: /* same as SW_MAXIMIZE */
1370 swp |= SWP_SHOWWINDOW | SWP_FRAMECHANGED;
1371 if( !(wndPtr->dwStyle & WS_MAXIMIZE) )
1372 swp |= WINPOS_MinMaximize( wndPtr, SW_MAXIMIZE, &newPos );
1373 else swp |= SWP_NOSIZE | SWP_NOMOVE;
1377 swp |= SWP_NOACTIVATE | SWP_NOZORDER;
1380 swp |= SWP_SHOWWINDOW | SWP_NOSIZE | SWP_NOMOVE;
1383 * ShowWindow has a little peculiar behavior that if the
1384 * window is already the topmost window, it will not
1387 if (GetTopWindow((HWND)0)==hwnd && (wasVisible || GetActiveWindow() == hwnd))
1388 swp |= SWP_NOACTIVATE;
1392 case SW_SHOWNOACTIVATE:
1393 swp |= SWP_NOZORDER;
1394 if (GetActiveWindow()) swp |= SWP_NOACTIVATE;
1396 case SW_SHOWNORMAL: /* same as SW_NORMAL: */
1397 case SW_SHOWDEFAULT: /* FIXME: should have its own handler */
1399 swp |= SWP_SHOWWINDOW | SWP_FRAMECHANGED;
1401 if( wndPtr->dwStyle & (WS_MINIMIZE | WS_MAXIMIZE) )
1402 swp |= WINPOS_MinMaximize( wndPtr, SW_RESTORE, &newPos );
1403 else swp |= SWP_NOSIZE | SWP_NOMOVE;
1407 showFlag = (cmd != SW_HIDE);
1408 if (showFlag != wasVisible)
1410 SendMessageA( hwnd, WM_SHOWWINDOW, showFlag, 0 );
1411 if (!IsWindow( hwnd )) goto END;
1414 if ((wndPtr->dwStyle & WS_CHILD) &&
1415 !IsWindowVisible( wndPtr->parent->hwndSelf ) &&
1416 (swp & (SWP_NOSIZE | SWP_NOMOVE)) == (SWP_NOSIZE | SWP_NOMOVE) )
1418 /* Don't call SetWindowPos() on invisible child windows */
1419 if (cmd == SW_HIDE) wndPtr->dwStyle &= ~WS_VISIBLE;
1420 else wndPtr->dwStyle |= WS_VISIBLE;
1424 /* We can't activate a child window */
1425 if ((wndPtr->dwStyle & WS_CHILD) &&
1426 !(wndPtr->dwExStyle & WS_EX_MDICHILD))
1427 swp |= SWP_NOACTIVATE | SWP_NOZORDER;
1428 if (!(swp & MINMAX_NOSWP))
1430 SetWindowPos( hwnd, HWND_TOP, newPos.left, newPos.top,
1431 newPos.right, newPos.bottom, LOWORD(swp) );
1434 /* FIXME: This will cause the window to be activated irrespective
1435 * of whether it is owned by the same thread. Has to be done
1439 if (hwnd == GetActiveWindow())
1440 WINPOS_ActivateOtherWindow(wndPtr);
1442 /* Revert focus to parent */
1443 if (hwnd == GetFocus() || IsChild(hwnd, GetFocus()))
1444 SetFocus( GetParent(hwnd) );
1447 if (!IsWindow( hwnd )) goto END;
1448 else if( wndPtr->dwStyle & WS_MINIMIZE ) WINPOS_ShowIconTitle( wndPtr, TRUE );
1451 if (wndPtr->flags & WIN_NEED_SIZE)
1453 /* should happen only in CreateWindowEx() */
1454 int wParam = SIZE_RESTORED;
1456 wndPtr->flags &= ~WIN_NEED_SIZE;
1457 if (wndPtr->dwStyle & WS_MAXIMIZE) wParam = SIZE_MAXIMIZED;
1458 else if (wndPtr->dwStyle & WS_MINIMIZE) wParam = SIZE_MINIMIZED;
1459 SendMessageA( hwnd, WM_SIZE, wParam,
1460 MAKELONG(wndPtr->rectClient.right-wndPtr->rectClient.left,
1461 wndPtr->rectClient.bottom-wndPtr->rectClient.top));
1462 SendMessageA( hwnd, WM_MOVE, 0,
1463 MAKELONG(wndPtr->rectClient.left, wndPtr->rectClient.top) );
1467 WIN_ReleaseWndPtr(wndPtr);
1472 /***********************************************************************
1473 * GetInternalWindowPos (USER.460)
1475 UINT16 WINAPI GetInternalWindowPos16( HWND16 hwnd, LPRECT16 rectWnd,
1478 WINDOWPLACEMENT16 wndpl;
1479 if (GetWindowPlacement16( hwnd, &wndpl ))
1481 if (rectWnd) *rectWnd = wndpl.rcNormalPosition;
1482 if (ptIcon) *ptIcon = wndpl.ptMinPosition;
1483 return wndpl.showCmd;
1489 /***********************************************************************
1490 * GetInternalWindowPos (USER32.@)
1492 UINT WINAPI GetInternalWindowPos( HWND hwnd, LPRECT rectWnd,
1495 WINDOWPLACEMENT wndpl;
1496 if (GetWindowPlacement( hwnd, &wndpl ))
1498 if (rectWnd) *rectWnd = wndpl.rcNormalPosition;
1499 if (ptIcon) *ptIcon = wndpl.ptMinPosition;
1500 return wndpl.showCmd;
1505 /***********************************************************************
1506 * GetWindowPlacement (USER.370)
1508 BOOL16 WINAPI GetWindowPlacement16( HWND16 hwnd, WINDOWPLACEMENT16 *wndpl )
1510 WND *pWnd = WIN_FindWndPtr( hwnd );
1511 LPINTERNALPOS lpPos;
1513 if(!pWnd ) return FALSE;
1515 lpPos = (LPINTERNALPOS)WINPOS_InitInternalPos( pWnd,
1516 *(LPPOINT)&pWnd->rectWindow.left, &pWnd->rectWindow );
1517 wndpl->length = sizeof(*wndpl);
1518 if( pWnd->dwStyle & WS_MINIMIZE )
1519 wndpl->showCmd = SW_SHOWMINIMIZED;
1521 wndpl->showCmd = ( pWnd->dwStyle & WS_MAXIMIZE )
1522 ? SW_SHOWMAXIMIZED : SW_SHOWNORMAL ;
1523 if( pWnd->flags & WIN_RESTORE_MAX )
1524 wndpl->flags = WPF_RESTORETOMAXIMIZED;
1527 wndpl->ptMinPosition = lpPos->ptIconPos;
1528 wndpl->ptMaxPosition = lpPos->ptMaxPos;
1529 wndpl->rcNormalPosition = lpPos->rectNormal;
1531 WIN_ReleaseWndPtr(pWnd);
1536 /***********************************************************************
1537 * GetWindowPlacement (USER32.@)
1540 * Fails if wndpl->length of Win95 (!) apps is invalid.
1542 BOOL WINAPI GetWindowPlacement( HWND hwnd, WINDOWPLACEMENT *pwpl32 )
1546 WINDOWPLACEMENT16 wpl;
1547 wpl.length = sizeof(wpl);
1548 if( GetWindowPlacement16( hwnd, &wpl ) )
1550 pwpl32->length = sizeof(*pwpl32);
1551 pwpl32->flags = wpl.flags;
1552 pwpl32->showCmd = wpl.showCmd;
1553 CONV_POINT16TO32( &wpl.ptMinPosition, &pwpl32->ptMinPosition );
1554 CONV_POINT16TO32( &wpl.ptMaxPosition, &pwpl32->ptMaxPosition );
1555 CONV_RECT16TO32( &wpl.rcNormalPosition, &pwpl32->rcNormalPosition );
1563 /***********************************************************************
1564 * WINPOS_SetPlacement
1566 static BOOL WINPOS_SetPlacement( HWND hwnd, const WINDOWPLACEMENT16 *wndpl,
1569 WND *pWnd = WIN_FindWndPtr( hwnd );
1572 LPINTERNALPOS lpPos = (LPINTERNALPOS)WINPOS_InitInternalPos( pWnd,
1573 *(LPPOINT)&pWnd->rectWindow.left, &pWnd->rectWindow );
1575 if( flags & PLACE_MIN ) lpPos->ptIconPos = wndpl->ptMinPosition;
1576 if( flags & PLACE_MAX ) lpPos->ptMaxPos = wndpl->ptMaxPosition;
1577 if( flags & PLACE_RECT) lpPos->rectNormal = wndpl->rcNormalPosition;
1579 if( pWnd->dwStyle & WS_MINIMIZE )
1581 WINPOS_ShowIconTitle( pWnd, FALSE );
1582 if( wndpl->flags & WPF_SETMINPOSITION && !EMPTYPOINT(lpPos->ptIconPos))
1583 SetWindowPos( hwnd, 0, lpPos->ptIconPos.x, lpPos->ptIconPos.y,
1584 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE );
1586 else if( pWnd->dwStyle & WS_MAXIMIZE )
1588 if( !EMPTYPOINT(lpPos->ptMaxPos) )
1589 SetWindowPos( hwnd, 0, lpPos->ptMaxPos.x, lpPos->ptMaxPos.y,
1590 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE );
1592 else if( flags & PLACE_RECT )
1593 SetWindowPos( hwnd, 0, lpPos->rectNormal.left, lpPos->rectNormal.top,
1594 lpPos->rectNormal.right - lpPos->rectNormal.left,
1595 lpPos->rectNormal.bottom - lpPos->rectNormal.top,
1596 SWP_NOZORDER | SWP_NOACTIVATE );
1598 ShowWindow( hwnd, wndpl->showCmd );
1599 if( IsWindow(hwnd) && pWnd->dwStyle & WS_MINIMIZE )
1601 if( pWnd->dwStyle & WS_VISIBLE ) WINPOS_ShowIconTitle( pWnd, TRUE );
1603 /* SDK: ...valid only the next time... */
1604 if( wndpl->flags & WPF_RESTORETOMAXIMIZED ) pWnd->flags |= WIN_RESTORE_MAX;
1606 WIN_ReleaseWndPtr(pWnd);
1613 /***********************************************************************
1614 * SetWindowPlacement (USER.371)
1616 BOOL16 WINAPI SetWindowPlacement16(HWND16 hwnd, const WINDOWPLACEMENT16 *wndpl)
1618 return WINPOS_SetPlacement( hwnd, wndpl,
1619 PLACE_MIN | PLACE_MAX | PLACE_RECT );
1622 /***********************************************************************
1623 * SetWindowPlacement (USER32.@)
1626 * Fails if wndpl->length of Win95 (!) apps is invalid.
1628 BOOL WINAPI SetWindowPlacement( HWND hwnd, const WINDOWPLACEMENT *pwpl32 )
1632 WINDOWPLACEMENT16 wpl;
1634 wpl.length = sizeof(WINDOWPLACEMENT16);
1635 wpl.flags = pwpl32->flags;
1636 wpl.showCmd = pwpl32->showCmd;
1637 wpl.ptMinPosition.x = pwpl32->ptMinPosition.x;
1638 wpl.ptMinPosition.y = pwpl32->ptMinPosition.y;
1639 wpl.ptMaxPosition.x = pwpl32->ptMaxPosition.x;
1640 wpl.ptMaxPosition.y = pwpl32->ptMaxPosition.y;
1641 wpl.rcNormalPosition.left = pwpl32->rcNormalPosition.left;
1642 wpl.rcNormalPosition.top = pwpl32->rcNormalPosition.top;
1643 wpl.rcNormalPosition.right = pwpl32->rcNormalPosition.right;
1644 wpl.rcNormalPosition.bottom = pwpl32->rcNormalPosition.bottom;
1646 return WINPOS_SetPlacement( hwnd, &wpl, PLACE_MIN | PLACE_MAX | PLACE_RECT );
1652 /***********************************************************************
1653 * SetInternalWindowPos (USER.461)
1655 void WINAPI SetInternalWindowPos16( HWND16 hwnd, UINT16 showCmd,
1656 LPRECT16 rect, LPPOINT16 pt )
1658 if( IsWindow16(hwnd) )
1660 WINDOWPLACEMENT16 wndpl;
1663 wndpl.length = sizeof(wndpl);
1664 wndpl.showCmd = showCmd;
1665 wndpl.flags = flags = 0;
1670 wndpl.flags |= WPF_SETMINPOSITION;
1671 wndpl.ptMinPosition = *pt;
1675 flags |= PLACE_RECT;
1676 wndpl.rcNormalPosition = *rect;
1678 WINPOS_SetPlacement( hwnd, &wndpl, flags );
1683 /***********************************************************************
1684 * SetInternalWindowPos (USER32.@)
1686 void WINAPI SetInternalWindowPos( HWND hwnd, UINT showCmd,
1687 LPRECT rect, LPPOINT pt )
1689 if( IsWindow(hwnd) )
1691 WINDOWPLACEMENT16 wndpl;
1694 wndpl.length = sizeof(wndpl);
1695 wndpl.showCmd = showCmd;
1696 wndpl.flags = flags = 0;
1701 wndpl.flags |= WPF_SETMINPOSITION;
1702 CONV_POINT32TO16( pt, &wndpl.ptMinPosition );
1706 flags |= PLACE_RECT;
1707 CONV_RECT32TO16( rect, &wndpl.rcNormalPosition );
1709 WINPOS_SetPlacement( hwnd, &wndpl, flags );
1713 /*******************************************************************
1714 * WINPOS_SetActiveWindow
1716 * SetActiveWindow() back-end. This is the only function that
1717 * can assign active status to a window. It must be called only
1718 * for the top level windows.
1720 BOOL WINPOS_SetActiveWindow( HWND hWnd, BOOL fMouse, BOOL fChangeFocus)
1722 WND* wndPtr=0, *wndTemp;
1723 HQUEUE16 hOldActiveQueue, hNewActiveQueue;
1724 MESSAGEQUEUE *pOldActiveQueue = 0, *pNewActiveQueue = 0;
1726 HWND hwndActive = 0;
1729 TRACE("(%04x, %d, %d)\n", hWnd, fMouse, fChangeFocus );
1731 /* Get current active window from the active queue */
1734 pOldActiveQueue = QUEUE_Lock( hActiveQueue );
1735 if ( pOldActiveQueue )
1736 hwndActive = PERQDATA_GetActiveWnd( pOldActiveQueue->pQData );
1739 /* paranoid checks */
1740 if( hWnd == GetDesktopWindow() || (bRet = (hWnd == hwndActive)) )
1743 /* if (wndPtr && (GetFastQueue16() != wndPtr->hmemTaskQ))
1746 wndPtr = WIN_FindWndPtr(hWnd);
1747 hOldActiveQueue = hActiveQueue;
1749 if( (wndTemp = WIN_FindWndPtr(hwndActive)) )
1751 wIconized = HIWORD(wndTemp->dwStyle & WS_MINIMIZE);
1752 WIN_ReleaseWndPtr(wndTemp);
1755 TRACE("no current active window.\n");
1757 /* call CBT hook chain */
1758 if (HOOK_IsHooked( WH_CBT ))
1760 CBTACTIVATESTRUCT cbt;
1761 cbt.fMouse = fMouse;
1762 cbt.hWndActive = hwndActive;
1763 if (HOOK_CallHooksA( WH_CBT, HCBT_ACTIVATE, hWnd, (LPARAM)&cbt )) goto CLEANUP_END;
1766 /* set prev active wnd to current active wnd and send notification */
1767 if ((hwndPrevActive = hwndActive) && IsWindow(hwndPrevActive))
1769 MESSAGEQUEUE *pTempActiveQueue = 0;
1771 if (!SendMessageA( hwndPrevActive, WM_NCACTIVATE, FALSE, 0 ))
1773 if (GetSysModalWindow16() != hWnd)
1775 /* disregard refusal if hWnd is sysmodal */
1778 SendMessageA( hwndPrevActive, WM_ACTIVATE,
1779 MAKEWPARAM( WA_INACTIVE, wIconized ),
1782 /* check if something happened during message processing
1783 * (global active queue may have changed)
1785 pTempActiveQueue = QUEUE_Lock( hActiveQueue );
1786 if(!pTempActiveQueue)
1789 hwndActive = PERQDATA_GetActiveWnd( pTempActiveQueue->pQData );
1790 QUEUE_Unlock( pTempActiveQueue );
1791 if( hwndPrevActive != hwndActive )
1795 /* Set new active window in the message queue */
1799 pNewActiveQueue = QUEUE_Lock( wndPtr->hmemTaskQ );
1800 if ( pNewActiveQueue )
1801 PERQDATA_SetActiveWnd( pNewActiveQueue->pQData, hwndActive );
1803 else /* have to do this or MDI frame activation goes to hell */
1804 if( pOldActiveQueue )
1805 PERQDATA_SetActiveWnd( pOldActiveQueue->pQData, 0 );
1807 /* send palette messages */
1808 if (hWnd && SendMessage16( hWnd, WM_QUERYNEWPALETTE, 0, 0L))
1809 SendMessage16((HWND16)-1, WM_PALETTEISCHANGING, (WPARAM16)hWnd, 0L );
1811 /* if prev wnd is minimized redraw icon title */
1812 if( IsIconic( hwndPrevActive ) ) WINPOS_RedrawIconTitle(hwndPrevActive);
1814 /* managed windows will get ConfigureNotify event */
1815 if (wndPtr && !(wndPtr->dwStyle & WS_CHILD) && !(wndPtr->dwExStyle & WS_EX_MANAGED))
1817 /* check Z-order and bring hWnd to the top */
1818 for (wndTemp = WIN_LockWndPtr(WIN_GetDesktop()->child); wndTemp; WIN_UpdateWndPtr(&wndTemp,wndTemp->next))
1820 if (wndTemp->dwStyle & WS_VISIBLE) break;
1822 WIN_ReleaseDesktop();
1823 WIN_ReleaseWndPtr(wndTemp);
1825 if( wndTemp != wndPtr )
1826 SetWindowPos(hWnd, HWND_TOP, 0,0,0,0,
1827 SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE );
1828 if (!IsWindow(hWnd))
1832 /* Get a handle to the new active queue */
1833 hNewActiveQueue = wndPtr ? wndPtr->hmemTaskQ : 0;
1835 /* send WM_ACTIVATEAPP if necessary */
1836 if (hOldActiveQueue != hNewActiveQueue)
1838 WND **list, **ppWnd;
1839 WND *pDesktop = WIN_GetDesktop();
1841 if ((list = WIN_BuildWinArray( pDesktop, 0, NULL )))
1843 for (ppWnd = list; *ppWnd; ppWnd++)
1845 if (!IsWindow( (*ppWnd)->hwndSelf )) continue;
1847 if ((*ppWnd)->hmemTaskQ == hOldActiveQueue)
1848 SendMessage16( (*ppWnd)->hwndSelf, WM_ACTIVATEAPP,
1849 0, QUEUE_GetQueueTask(hNewActiveQueue) );
1851 WIN_ReleaseWinArray(list);
1854 hActiveQueue = hNewActiveQueue;
1856 if ((list = WIN_BuildWinArray(pDesktop, 0, NULL )))
1858 for (ppWnd = list; *ppWnd; ppWnd++)
1860 if (!IsWindow( (*ppWnd)->hwndSelf )) continue;
1862 if ((*ppWnd)->hmemTaskQ == hNewActiveQueue)
1863 SendMessage16( (*ppWnd)->hwndSelf, WM_ACTIVATEAPP,
1864 1, QUEUE_GetQueueTask( hOldActiveQueue ) );
1866 WIN_ReleaseWinArray(list);
1868 WIN_ReleaseDesktop();
1870 if (hWnd && !IsWindow(hWnd)) goto CLEANUP;
1875 /* walk up to the first unowned window */
1876 wndTemp = WIN_LockWndPtr(wndPtr);
1877 while (wndTemp->owner)
1879 WIN_UpdateWndPtr(&wndTemp,wndTemp->owner);
1881 /* and set last active owned popup */
1882 wndTemp->hwndLastActive = hWnd;
1884 wIconized = HIWORD(wndTemp->dwStyle & WS_MINIMIZE);
1885 WIN_ReleaseWndPtr(wndTemp);
1886 SendMessageA( hWnd, WM_NCACTIVATE, TRUE, 0 );
1887 SendMessageA( hWnd, WM_ACTIVATE,
1888 MAKEWPARAM( (fMouse) ? WA_CLICKACTIVE : WA_ACTIVE, wIconized),
1889 (LPARAM)hwndPrevActive );
1890 if( !IsWindow(hWnd) ) goto CLEANUP;
1893 /* change focus if possible */
1896 if ( pNewActiveQueue )
1898 HWND hOldFocus = PERQDATA_GetFocusWnd( pNewActiveQueue->pQData );
1900 if ( hOldFocus && WIN_GetTopParent( hOldFocus ) != hwndActive )
1901 FOCUS_SwitchFocus( pNewActiveQueue, hOldFocus,
1902 (wndPtr && (wndPtr->dwStyle & WS_MINIMIZE))?
1906 if ( pOldActiveQueue &&
1907 ( !pNewActiveQueue ||
1908 pNewActiveQueue->pQData != pOldActiveQueue->pQData ) )
1910 HWND hOldFocus = PERQDATA_GetFocusWnd( pOldActiveQueue->pQData );
1912 FOCUS_SwitchFocus( pOldActiveQueue, hOldFocus, 0 );
1916 if( !hwndPrevActive && wndPtr )
1917 (*wndPtr->pDriver->pForceWindowRaise)(wndPtr);
1919 /* if active wnd is minimized redraw icon title */
1920 if( IsIconic(hwndActive) ) WINPOS_RedrawIconTitle(hwndActive);
1922 bRet = (hWnd == hwndActive); /* Success? */
1924 CLEANUP: /* Unlock the message queues before returning */
1926 if ( pNewActiveQueue )
1927 QUEUE_Unlock( pNewActiveQueue );
1931 if ( pOldActiveQueue )
1932 QUEUE_Unlock( pOldActiveQueue );
1934 WIN_ReleaseWndPtr(wndPtr);
1938 /*******************************************************************
1939 * WINPOS_ActivateOtherWindow
1941 * Activates window other than pWnd.
1943 BOOL WINPOS_ActivateOtherWindow(WND* pWnd)
1947 HWND hwndActive = 0;
1949 /* Get current active window from the active queue */
1952 MESSAGEQUEUE *pActiveQueue = QUEUE_Lock( hActiveQueue );
1955 hwndActive = PERQDATA_GetActiveWnd( pActiveQueue->pQData );
1956 QUEUE_Unlock( pActiveQueue );
1960 if( pWnd->hwndSelf == hwndPrevActive )
1963 if( hwndActive != pWnd->hwndSelf &&
1964 ( hwndActive || QUEUE_IsExitingQueue(pWnd->hmemTaskQ)) )
1967 if( !(pWnd->dwStyle & WS_POPUP) || !(pWnd->owner) ||
1968 !WINPOS_CanActivate((pWndTo = WIN_GetTopParentPtr(pWnd->owner))) )
1970 WND* pWndPtr = WIN_GetTopParentPtr(pWnd);
1972 WIN_ReleaseWndPtr(pWndTo);
1973 pWndTo = WIN_FindWndPtr(hwndPrevActive);
1975 while( !WINPOS_CanActivate(pWndTo) )
1977 /* by now owned windows should've been taken care of */
1978 WIN_UpdateWndPtr(&pWndTo,pWndPtr->next);
1979 WIN_UpdateWndPtr(&pWndPtr,pWndTo);
1980 if( !pWndTo ) break;
1982 WIN_ReleaseWndPtr(pWndPtr);
1985 bRet = WINPOS_SetActiveWindow( pWndTo ? pWndTo->hwndSelf : 0, FALSE, TRUE );
1987 if( pWndTo ) WIN_ReleaseWndPtr(pWndTo);
1993 /*******************************************************************
1994 * WINPOS_ChangeActiveWindow
1997 BOOL WINPOS_ChangeActiveWindow( HWND hWnd, BOOL mouseMsg )
2001 HWND hwndActive = 0;
2003 /* Get current active window from the active queue */
2006 MESSAGEQUEUE *pActiveQueue = QUEUE_Lock( hActiveQueue );
2009 hwndActive = PERQDATA_GetActiveWnd( pActiveQueue->pQData );
2010 QUEUE_Unlock( pActiveQueue );
2015 return WINPOS_SetActiveWindow( 0, mouseMsg, TRUE );
2017 wndPtr = WIN_FindWndPtr(hWnd);
2018 if( !wndPtr ) return FALSE;
2020 /* child windows get WM_CHILDACTIVATE message */
2021 if( (wndPtr->dwStyle & (WS_CHILD | WS_POPUP)) == WS_CHILD )
2023 retvalue = SendMessageA(hWnd, WM_CHILDACTIVATE, 0, 0L);
2027 if( hWnd == hwndActive )
2033 if( !WINPOS_SetActiveWindow(hWnd ,mouseMsg ,TRUE) )
2041 WIN_ReleaseWndPtr(wndPtr);
2046 /***********************************************************************
2047 * WINPOS_SendNCCalcSize
2049 * Send a WM_NCCALCSIZE message to a window.
2050 * All parameters are read-only except newClientRect.
2051 * oldWindowRect, oldClientRect and winpos must be non-NULL only
2052 * when calcValidRect is TRUE.
2054 LONG WINPOS_SendNCCalcSize( HWND hwnd, BOOL calcValidRect,
2055 RECT *newWindowRect, RECT *oldWindowRect,
2056 RECT *oldClientRect, WINDOWPOS *winpos,
2057 RECT *newClientRect )
2059 NCCALCSIZE_PARAMS params;
2060 WINDOWPOS winposCopy;
2063 params.rgrc[0] = *newWindowRect;
2066 winposCopy = *winpos;
2067 params.rgrc[1] = *oldWindowRect;
2068 params.rgrc[2] = *oldClientRect;
2069 params.lppos = &winposCopy;
2071 result = SendMessageA( hwnd, WM_NCCALCSIZE, calcValidRect,
2073 TRACE("%d,%d-%d,%d\n",
2074 params.rgrc[0].left, params.rgrc[0].top,
2075 params.rgrc[0].right, params.rgrc[0].bottom );
2077 /* If the application send back garbage, ignore it */
2078 if (params.rgrc[0].left <= params.rgrc[0].right && params.rgrc[0].top <= params.rgrc[0].bottom)
2079 *newClientRect = params.rgrc[0];
2085 /***********************************************************************
2086 * WINPOS_HandleWindowPosChanging16
2088 * Default handling for a WM_WINDOWPOSCHANGING. Called from DefWindowProc().
2090 LONG WINPOS_HandleWindowPosChanging16( WND *wndPtr, WINDOWPOS16 *winpos )
2092 POINT maxSize, minTrack;
2093 if (winpos->flags & SWP_NOSIZE) return 0;
2094 if ((wndPtr->dwStyle & WS_THICKFRAME) ||
2095 ((wndPtr->dwStyle & (WS_POPUP | WS_CHILD)) == 0))
2097 WINPOS_GetMinMaxInfo( wndPtr, &maxSize, NULL, &minTrack, NULL );
2098 if (maxSize.x < winpos->cx) winpos->cx = maxSize.x;
2099 if (maxSize.y < winpos->cy) winpos->cy = maxSize.y;
2100 if (!(wndPtr->dwStyle & WS_MINIMIZE))
2102 if (winpos->cx < minTrack.x ) winpos->cx = minTrack.x;
2103 if (winpos->cy < minTrack.y ) winpos->cy = minTrack.y;
2110 /***********************************************************************
2111 * WINPOS_HandleWindowPosChanging
2113 * Default handling for a WM_WINDOWPOSCHANGING. Called from DefWindowProc().
2115 LONG WINPOS_HandleWindowPosChanging( WND *wndPtr, WINDOWPOS *winpos )
2117 POINT maxSize, minTrack;
2118 if (winpos->flags & SWP_NOSIZE) return 0;
2119 if ((wndPtr->dwStyle & WS_THICKFRAME) ||
2120 ((wndPtr->dwStyle & (WS_POPUP | WS_CHILD)) == 0))
2122 WINPOS_GetMinMaxInfo( wndPtr, &maxSize, NULL, &minTrack, NULL );
2123 winpos->cx = min( winpos->cx, maxSize.x );
2124 winpos->cy = min( winpos->cy, maxSize.y );
2125 if (!(wndPtr->dwStyle & WS_MINIMIZE))
2127 if (winpos->cx < minTrack.x ) winpos->cx = minTrack.x;
2128 if (winpos->cy < minTrack.y ) winpos->cy = minTrack.y;
2134 /***********************************************************************
2135 * SetWindowPos (USER.232)
2137 BOOL16 WINAPI SetWindowPos16( HWND16 hwnd, HWND16 hwndInsertAfter,
2138 INT16 x, INT16 y, INT16 cx, INT16 cy, WORD flags)
2140 return SetWindowPos(hwnd,(INT)(INT16)hwndInsertAfter,x,y,cx,cy,flags);
2143 /***********************************************************************
2144 * SetWindowPos (USER32.@)
2146 BOOL WINAPI SetWindowPos( HWND hwnd, HWND hwndInsertAfter,
2147 INT x, INT y, INT cx, INT cy, UINT flags )
2152 winpos.hwndInsertAfter = hwndInsertAfter;
2157 winpos.flags = flags;
2158 return USER_Driver.pSetWindowPos( &winpos );
2162 /***********************************************************************
2163 * BeginDeferWindowPos (USER.259)
2165 HDWP16 WINAPI BeginDeferWindowPos16( INT16 count )
2167 return BeginDeferWindowPos( count );
2171 /***********************************************************************
2172 * BeginDeferWindowPos (USER32.@)
2174 HDWP WINAPI BeginDeferWindowPos( INT count )
2181 SetLastError(ERROR_INVALID_PARAMETER);
2184 /* Windows allows zero count, in which case it allocates context for 8 moves */
2185 if (count == 0) count = 8;
2187 handle = USER_HEAP_ALLOC( sizeof(DWP) + (count-1)*sizeof(WINDOWPOS) );
2188 if (!handle) return 0;
2189 pDWP = (DWP *) USER_HEAP_LIN_ADDR( handle );
2190 pDWP->actualCount = 0;
2191 pDWP->suggestedCount = count;
2193 pDWP->wMagic = DWP_MAGIC;
2194 pDWP->hwndParent = 0;
2199 /***********************************************************************
2200 * DeferWindowPos (USER.260)
2202 HDWP16 WINAPI DeferWindowPos16( HDWP16 hdwp, HWND16 hwnd, HWND16 hwndAfter,
2203 INT16 x, INT16 y, INT16 cx, INT16 cy,
2206 return DeferWindowPos( hdwp, hwnd, (INT)(INT16)hwndAfter,
2207 x, y, cx, cy, flags );
2211 /***********************************************************************
2212 * DeferWindowPos (USER32.@)
2214 HDWP WINAPI DeferWindowPos( HDWP hdwp, HWND hwnd, HWND hwndAfter,
2215 INT x, INT y, INT cx, INT cy,
2220 HDWP newhdwp = hdwp,retvalue;
2224 pDWP = (DWP *) USER_HEAP_LIN_ADDR( hdwp );
2225 if (!pDWP) return 0;
2226 if (hwnd == GetDesktopWindow()) return 0;
2228 if (!(pWnd=WIN_FindWndPtr( hwnd ))) {
2229 USER_HEAP_FREE( hdwp );
2233 /* Numega Bounds Checker Demo dislikes the following code.
2234 In fact, I've not been able to find any "same parent" requirement in any docu
2238 /* All the windows of a DeferWindowPos() must have the same parent */
2239 parent = pWnd->parent->hwndSelf;
2240 if (pDWP->actualCount == 0) pDWP->hwndParent = parent;
2241 else if (parent != pDWP->hwndParent)
2243 USER_HEAP_FREE( hdwp );
2249 for (i = 0; i < pDWP->actualCount; i++)
2251 if (pDWP->winPos[i].hwnd == hwnd)
2253 /* Merge with the other changes */
2254 if (!(flags & SWP_NOZORDER))
2256 pDWP->winPos[i].hwndInsertAfter = hwndAfter;
2258 if (!(flags & SWP_NOMOVE))
2260 pDWP->winPos[i].x = x;
2261 pDWP->winPos[i].y = y;
2263 if (!(flags & SWP_NOSIZE))
2265 pDWP->winPos[i].cx = cx;
2266 pDWP->winPos[i].cy = cy;
2268 pDWP->winPos[i].flags &= flags | ~(SWP_NOSIZE | SWP_NOMOVE |
2269 SWP_NOZORDER | SWP_NOREDRAW |
2270 SWP_NOACTIVATE | SWP_NOCOPYBITS|
2272 pDWP->winPos[i].flags |= flags & (SWP_SHOWWINDOW | SWP_HIDEWINDOW |
2278 if (pDWP->actualCount >= pDWP->suggestedCount)
2280 newhdwp = USER_HEAP_REALLOC( hdwp,
2281 sizeof(DWP) + pDWP->suggestedCount*sizeof(WINDOWPOS) );
2287 pDWP = (DWP *) USER_HEAP_LIN_ADDR( newhdwp );
2288 pDWP->suggestedCount++;
2290 pDWP->winPos[pDWP->actualCount].hwnd = hwnd;
2291 pDWP->winPos[pDWP->actualCount].hwndInsertAfter = hwndAfter;
2292 pDWP->winPos[pDWP->actualCount].x = x;
2293 pDWP->winPos[pDWP->actualCount].y = y;
2294 pDWP->winPos[pDWP->actualCount].cx = cx;
2295 pDWP->winPos[pDWP->actualCount].cy = cy;
2296 pDWP->winPos[pDWP->actualCount].flags = flags;
2297 pDWP->actualCount++;
2300 WIN_ReleaseWndPtr(pWnd);
2305 /***********************************************************************
2306 * EndDeferWindowPos (USER.261)
2308 BOOL16 WINAPI EndDeferWindowPos16( HDWP16 hdwp )
2310 return EndDeferWindowPos( hdwp );
2314 /***********************************************************************
2315 * EndDeferWindowPos (USER32.@)
2317 BOOL WINAPI EndDeferWindowPos( HDWP hdwp )
2324 pDWP = (DWP *) USER_HEAP_LIN_ADDR( hdwp );
2325 if (!pDWP) return FALSE;
2326 for (i = 0, winpos = pDWP->winPos; i < pDWP->actualCount; i++, winpos++)
2328 if (!(res = USER_Driver.pSetWindowPos( winpos ))) break;
2330 USER_HEAP_FREE( hdwp );
2335 /***********************************************************************
2336 * TileChildWindows (USER.199)
2338 void WINAPI TileChildWindows16( HWND16 parent, WORD action )
2340 FIXME("(%04x, %d): stub\n", parent, action);
2343 /***********************************************************************
2344 * CascadeChildWindows (USER.198)
2346 void WINAPI CascadeChildWindows16( HWND16 parent, WORD action )
2348 FIXME("(%04x, %d): stub\n", parent, action);
2351 /***********************************************************************
2352 * SetProgmanWindow (USER32.@)
2354 HRESULT WINAPI SetProgmanWindow ( HWND hwnd )
2356 hGlobalProgmanWindow = hwnd;
2357 return hGlobalProgmanWindow;
2360 /***********************************************************************
2361 * GetProgmanWindow (USER32.@)
2363 HRESULT WINAPI GetProgmanWindow ( )
2365 return hGlobalProgmanWindow;
2368 /***********************************************************************
2369 * SetShellWindowEx (USER32.@)
2370 * hwndProgman = Progman[Program Manager]
2371 * |-> SHELLDLL_DefView
2372 * hwndListView = | |-> SysListView32
2373 * | | |-> tooltips_class32
2379 HRESULT WINAPI SetShellWindowEx ( HWND hwndProgman, HWND hwndListView )
2381 FIXME("0x%08x 0x%08x stub\n",hwndProgman ,hwndListView );
2382 hGlobalShellWindow = hwndProgman;
2383 return hGlobalShellWindow;
2387 /***********************************************************************
2388 * SetTaskmanWindow (USER32.@)
2390 * hwnd = MSTaskSwWClass
2391 * |-> SysTabControl32
2393 HRESULT WINAPI SetTaskmanWindow ( HWND hwnd )
2395 hGlobalTaskmanWindow = hwnd;
2396 return hGlobalTaskmanWindow;
2399 /***********************************************************************
2400 * GetTaskmanWindow (USER32.@)
2402 HRESULT WINAPI GetTaskmanWindow ( )
2404 return hGlobalTaskmanWindow;