2 * Window position related functions.
4 * Copyright 1993, 1994, 1995 Alexandre Julliard
5 * 1995, 1996, 1999 Alex Korobka
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #include "wine/port.h"
28 #define WIN32_NO_STATUS
33 #include "wine/server.h"
35 #include "user_private.h"
37 #include "wine/debug.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(win
);
41 #define SWP_AGG_NOGEOMETRYCHANGE \
42 (SWP_NOSIZE | SWP_NOCLIENTSIZE | SWP_NOZORDER)
43 #define SWP_AGG_NOPOSCHANGE \
44 (SWP_NOSIZE | SWP_NOMOVE | SWP_NOCLIENTSIZE | SWP_NOCLIENTMOVE | SWP_NOZORDER)
45 #define SWP_AGG_STATUSFLAGS \
46 (SWP_AGG_NOPOSCHANGE | SWP_FRAMECHANGED | SWP_HIDEWINDOW | SWP_SHOWWINDOW)
48 #define HAS_DLGFRAME(style,exStyle) \
49 (((exStyle) & WS_EX_DLGMODALFRAME) || \
50 (((style) & WS_DLGFRAME) && !((style) & WS_BORDER)))
52 #define HAS_THICKFRAME(style) \
53 (((style) & WS_THICKFRAME) && \
54 !(((style) & (WS_DLGFRAME|WS_BORDER)) == WS_DLGFRAME))
56 #define EMPTYPOINT(pt) ((pt).x == -1 && (pt).y == -1)
58 #define ON_LEFT_BORDER(hit) \
59 (((hit) == HTLEFT) || ((hit) == HTTOPLEFT) || ((hit) == HTBOTTOMLEFT))
60 #define ON_RIGHT_BORDER(hit) \
61 (((hit) == HTRIGHT) || ((hit) == HTTOPRIGHT) || ((hit) == HTBOTTOMRIGHT))
62 #define ON_TOP_BORDER(hit) \
63 (((hit) == HTTOP) || ((hit) == HTTOPLEFT) || ((hit) == HTTOPRIGHT))
64 #define ON_BOTTOM_BORDER(hit) \
65 (((hit) == HTBOTTOM) || ((hit) == HTBOTTOMLEFT) || ((hit) == HTBOTTOMRIGHT))
67 #define PLACE_MIN 0x0001
68 #define PLACE_MAX 0x0002
69 #define PLACE_RECT 0x0004
72 #define DWP_MAGIC ((INT)('W' | ('P' << 8) | ('O' << 16) | ('S' << 24)))
85 /***********************************************************************
86 * SwitchToThisWindow (USER32.@)
88 void WINAPI
SwitchToThisWindow( HWND hwnd
, BOOL restore
)
90 ShowWindow( hwnd
, restore
? SW_RESTORE
: SW_SHOWMINIMIZED
);
94 /***********************************************************************
95 * GetWindowRect (USER32.@)
97 BOOL WINAPI
GetWindowRect( HWND hwnd
, LPRECT rect
)
99 BOOL ret
= WIN_GetRectangles( hwnd
, rect
, NULL
);
102 MapWindowPoints( GetAncestor( hwnd
, GA_PARENT
), 0, (POINT
*)rect
, 2 );
103 TRACE( "hwnd %p (%s)\n", hwnd
, wine_dbgstr_rect(rect
) );
109 /***********************************************************************
110 * GetWindowRgn (USER32.@)
112 int WINAPI
GetWindowRgn ( HWND hwnd
, HRGN hrgn
)
122 if (!(data
= HeapAlloc( GetProcessHeap(), 0, sizeof(*data
) + size
- 1 )))
124 SetLastError( ERROR_OUTOFMEMORY
);
127 SERVER_START_REQ( get_window_region
)
130 wine_server_set_reply( req
, data
->Buffer
, size
);
131 if (!(status
= wine_server_call( req
)))
133 size_t reply_size
= wine_server_reply_size( reply
);
136 data
->rdh
.dwSize
= sizeof(data
->rdh
);
137 data
->rdh
.iType
= RDH_RECTANGLES
;
138 data
->rdh
.nCount
= reply_size
/ sizeof(RECT
);
139 data
->rdh
.nRgnSize
= reply_size
;
140 win_rgn
= ExtCreateRegion( NULL
, size
, data
);
143 else size
= reply
->total_size
;
146 HeapFree( GetProcessHeap(), 0, data
);
147 } while (status
== STATUS_BUFFER_OVERFLOW
);
149 if (status
) SetLastError( RtlNtStatusToDosError(status
) );
152 nRet
= CombineRgn( hrgn
, win_rgn
, 0, RGN_COPY
);
153 DeleteObject( win_rgn
);
159 /***********************************************************************
160 * SetWindowRgn (USER32.@)
162 int WINAPI
SetWindowRgn( HWND hwnd
, HRGN hrgn
, BOOL bRedraw
)
164 static const RECT empty_rect
;
172 if (!(size
= GetRegionData( hrgn
, 0, NULL
))) return FALSE
;
173 if (!(data
= HeapAlloc( GetProcessHeap(), 0, size
))) return FALSE
;
174 if (!GetRegionData( hrgn
, size
, data
))
176 HeapFree( GetProcessHeap(), 0, data
);
179 SERVER_START_REQ( set_window_region
)
182 req
->redraw
= (bRedraw
!= 0);
183 if (data
->rdh
.nCount
)
184 wine_server_add_data( req
, data
->Buffer
, data
->rdh
.nCount
* sizeof(RECT
) );
186 wine_server_add_data( req
, &empty_rect
, sizeof(empty_rect
) );
187 ret
= !wine_server_call_err( req
);
191 else /* clear existing region */
193 SERVER_START_REQ( set_window_region
)
196 req
->redraw
= (bRedraw
!= 0);
197 ret
= !wine_server_call_err( req
);
202 if (ret
) ret
= USER_Driver
->pSetWindowRgn( hwnd
, hrgn
, bRedraw
);
206 UINT swp_flags
= SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOZORDER
|SWP_NOACTIVATE
|SWP_FRAMECHANGED
|SWP_NOCLIENTSIZE
|SWP_NOCLIENTMOVE
;
207 if (!bRedraw
) swp_flags
|= SWP_NOREDRAW
;
208 SetWindowPos( hwnd
, 0, 0, 0, 0, 0, swp_flags
);
209 invalidate_dce( hwnd
, NULL
);
215 /***********************************************************************
216 * GetClientRect (USER32.@)
218 BOOL WINAPI
GetClientRect( HWND hwnd
, LPRECT rect
)
222 if ((ret
= WIN_GetRectangles( hwnd
, NULL
, rect
)))
224 rect
->right
-= rect
->left
;
225 rect
->bottom
-= rect
->top
;
226 rect
->left
= rect
->top
= 0;
232 /*******************************************************************
233 * ClientToScreen (USER32.@)
235 BOOL WINAPI
ClientToScreen( HWND hwnd
, LPPOINT lppnt
)
237 MapWindowPoints( hwnd
, 0, lppnt
, 1 );
242 /*******************************************************************
243 * ScreenToClient (USER32.@)
245 BOOL WINAPI
ScreenToClient( HWND hwnd
, LPPOINT lppnt
)
247 MapWindowPoints( 0, hwnd
, lppnt
, 1 );
252 /***********************************************************************
253 * list_children_from_point
255 * Get the list of children that can contain point from the server.
256 * Point is in screen coordinates.
257 * Returned list must be freed by caller.
259 static HWND
*list_children_from_point( HWND hwnd
, POINT pt
)
268 if (!(list
= HeapAlloc( GetProcessHeap(), 0, size
* sizeof(HWND
) ))) break;
270 SERVER_START_REQ( get_window_children_from_point
)
275 wine_server_set_reply( req
, list
, (size
-1) * sizeof(HWND
) );
276 if (!wine_server_call( req
)) count
= reply
->count
;
279 if (count
&& count
< size
)
284 HeapFree( GetProcessHeap(), 0, list
);
286 size
= count
+ 1; /* restart with a large enough buffer */
292 /***********************************************************************
293 * WINPOS_WindowFromPoint
295 * Find the window and hittest for a given point.
297 HWND
WINPOS_WindowFromPoint( HWND hwndScope
, POINT pt
, INT
*hittest
)
302 if (!hwndScope
) hwndScope
= GetDesktopWindow();
304 *hittest
= HTNOWHERE
;
306 if (!(list
= list_children_from_point( hwndScope
, pt
))) return 0;
308 /* now determine the hittest */
310 for (i
= 0; list
[i
]; i
++)
312 LONG style
= GetWindowLongW( list
[i
], GWL_STYLE
);
314 /* If window is minimized or disabled, return at once */
315 if (style
& WS_MINIMIZE
)
317 *hittest
= HTCAPTION
;
320 if (style
& WS_DISABLED
)
325 /* Send WM_NCCHITTEST (if same thread) */
326 if (!WIN_IsCurrentThread( list
[i
] ))
331 res
= SendMessageW( list
[i
], WM_NCHITTEST
, 0, MAKELONG(pt
.x
,pt
.y
) );
332 if (res
!= HTTRANSPARENT
)
334 *hittest
= res
; /* Found the window */
337 /* continue search with next window in z-order */
340 HeapFree( GetProcessHeap(), 0, list
);
341 TRACE( "scope %p (%d,%d) returning %p\n", hwndScope
, pt
.x
, pt
.y
, ret
);
346 /*******************************************************************
347 * WindowFromPoint (USER32.@)
349 HWND WINAPI
WindowFromPoint( POINT pt
)
352 return WINPOS_WindowFromPoint( 0, pt
, &hittest
);
356 /*******************************************************************
357 * ChildWindowFromPoint (USER32.@)
359 HWND WINAPI
ChildWindowFromPoint( HWND hwndParent
, POINT pt
)
361 return ChildWindowFromPointEx( hwndParent
, pt
, CWP_ALL
);
364 /*******************************************************************
365 * RealChildWindowFromPoint (USER32.@)
367 HWND WINAPI
RealChildWindowFromPoint( HWND hwndParent
, POINT pt
)
369 return ChildWindowFromPointEx( hwndParent
, pt
, CWP_SKIPTRANSPARENT
);
372 /*******************************************************************
373 * ChildWindowFromPointEx (USER32.@)
375 HWND WINAPI
ChildWindowFromPointEx( HWND hwndParent
, POINT pt
, UINT uFlags
)
377 /* pt is in the client coordinates */
383 GetClientRect( hwndParent
, &rect
);
384 if (!PtInRect( &rect
, pt
)) return 0;
385 if (!(list
= WIN_ListChildren( hwndParent
))) return hwndParent
;
387 for (i
= 0; list
[i
]; i
++)
389 if (!WIN_GetRectangles( list
[i
], &rect
, NULL
)) continue;
390 if (!PtInRect( &rect
, pt
)) continue;
391 if (uFlags
& (CWP_SKIPINVISIBLE
|CWP_SKIPDISABLED
))
393 LONG style
= GetWindowLongW( list
[i
], GWL_STYLE
);
394 if ((uFlags
& CWP_SKIPINVISIBLE
) && !(style
& WS_VISIBLE
)) continue;
395 if ((uFlags
& CWP_SKIPDISABLED
) && (style
& WS_DISABLED
)) continue;
397 if (uFlags
& CWP_SKIPTRANSPARENT
)
399 if (GetWindowLongW( list
[i
], GWL_EXSTYLE
) & WS_EX_TRANSPARENT
) continue;
404 HeapFree( GetProcessHeap(), 0, list
);
405 if (!retvalue
) retvalue
= hwndParent
;
410 /*******************************************************************
411 * WINPOS_GetWinOffset
413 * Calculate the offset between the origin of the two windows. Used
414 * to implement MapWindowPoints.
416 static void WINPOS_GetWinOffset( HWND hwndFrom
, HWND hwndTo
, POINT
*offset
)
420 offset
->x
= offset
->y
= 0;
422 /* Translate source window origin to screen coords */
425 HWND hwnd
= hwndFrom
;
429 if (hwnd
== hwndTo
) return;
430 if (!(wndPtr
= WIN_GetPtr( hwnd
)))
432 ERR( "bad hwndFrom = %p\n", hwnd
);
435 if (wndPtr
== WND_DESKTOP
) break;
436 if (wndPtr
== WND_OTHER_PROCESS
) goto other_process
;
437 offset
->x
+= wndPtr
->rectClient
.left
;
438 offset
->y
+= wndPtr
->rectClient
.top
;
439 hwnd
= wndPtr
->parent
;
440 WIN_ReleasePtr( wndPtr
);
444 /* Translate origin to destination window coords */
451 if (!(wndPtr
= WIN_GetPtr( hwnd
)))
453 ERR( "bad hwndTo = %p\n", hwnd
);
456 if (wndPtr
== WND_DESKTOP
) break;
457 if (wndPtr
== WND_OTHER_PROCESS
) goto other_process
;
458 offset
->x
-= wndPtr
->rectClient
.left
;
459 offset
->y
-= wndPtr
->rectClient
.top
;
460 hwnd
= wndPtr
->parent
;
461 WIN_ReleasePtr( wndPtr
);
466 other_process
: /* one of the parents may belong to another process, do it the hard way */
467 offset
->x
= offset
->y
= 0;
468 SERVER_START_REQ( get_windows_offset
)
470 req
->from
= hwndFrom
;
472 if (!wine_server_call( req
))
474 offset
->x
= reply
->x
;
475 offset
->y
= reply
->y
;
482 /*******************************************************************
483 * MapWindowPoints (USER.258)
485 void WINAPI
MapWindowPoints16( HWND16 hwndFrom
, HWND16 hwndTo
,
486 LPPOINT16 lppt
, UINT16 count
)
490 WINPOS_GetWinOffset( WIN_Handle32(hwndFrom
), WIN_Handle32(hwndTo
), &offset
);
500 /*******************************************************************
501 * MapWindowPoints (USER32.@)
503 INT WINAPI
MapWindowPoints( HWND hwndFrom
, HWND hwndTo
, LPPOINT lppt
, UINT count
)
507 WINPOS_GetWinOffset( hwndFrom
, hwndTo
, &offset
);
514 return MAKELONG( LOWORD(offset
.x
), LOWORD(offset
.y
) );
518 /***********************************************************************
519 * IsIconic (USER32.@)
521 BOOL WINAPI
IsIconic(HWND hWnd
)
523 return (GetWindowLongW( hWnd
, GWL_STYLE
) & WS_MINIMIZE
) != 0;
527 /***********************************************************************
528 * IsZoomed (USER32.@)
530 BOOL WINAPI
IsZoomed(HWND hWnd
)
532 return (GetWindowLongW( hWnd
, GWL_STYLE
) & WS_MAXIMIZE
) != 0;
536 /*******************************************************************
537 * AllowSetForegroundWindow (USER32.@)
539 BOOL WINAPI
AllowSetForegroundWindow( DWORD procid
)
541 /* FIXME: If Win98/2000 style SetForegroundWindow behavior is
542 * implemented, then fix this function. */
547 /*******************************************************************
548 * LockSetForegroundWindow (USER32.@)
550 BOOL WINAPI
LockSetForegroundWindow( UINT lockcode
)
552 /* FIXME: If Win98/2000 style SetForegroundWindow behavior is
553 * implemented, then fix this function. */
558 /***********************************************************************
559 * BringWindowToTop (USER32.@)
561 BOOL WINAPI
BringWindowToTop( HWND hwnd
)
563 return SetWindowPos( hwnd
, HWND_TOP
, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
);
567 /***********************************************************************
568 * MoveWindow (USER32.@)
570 BOOL WINAPI
MoveWindow( HWND hwnd
, INT x
, INT y
, INT cx
, INT cy
,
573 int flags
= SWP_NOZORDER
| SWP_NOACTIVATE
;
574 if (!repaint
) flags
|= SWP_NOREDRAW
;
575 TRACE("%p %d,%d %dx%d %d\n", hwnd
, x
, y
, cx
, cy
, repaint
);
576 return SetWindowPos( hwnd
, 0, x
, y
, cx
, cy
, flags
);
579 /***********************************************************************
580 * WINPOS_InitPlacement
582 static void WINPOS_InitPlacement( WND
* wnd
)
584 if (IsRectEmpty( &wnd
->normal_rect
))
586 /* this happens when the window is minimized/maximized
587 * for the first time (rectWindow is not adjusted yet) */
589 wnd
->normal_rect
= wnd
->rectWindow
;
590 wnd
->min_pos
.x
= wnd
->min_pos
.y
= -1;
591 wnd
->max_pos
.x
= wnd
->max_pos
.y
= -1;
594 if( wnd
->dwStyle
& WS_MINIMIZE
)
596 wnd
->min_pos
.x
= wnd
->rectWindow
.left
;
597 wnd
->min_pos
.y
= wnd
->rectWindow
.top
;
599 else if( wnd
->dwStyle
& WS_MAXIMIZE
)
601 wnd
->max_pos
.x
= wnd
->rectWindow
.left
;
602 wnd
->max_pos
.y
= wnd
->rectWindow
.top
;
606 wnd
->normal_rect
= wnd
->rectWindow
;
610 /***********************************************************************
611 * WINPOS_RedrawIconTitle
613 BOOL
WINPOS_RedrawIconTitle( HWND hWnd
)
616 WND
*win
= WIN_GetPtr( hWnd
);
618 if (win
&& win
!= WND_OTHER_PROCESS
&& win
!= WND_DESKTOP
)
620 icon_title
= win
->icon_title
;
621 WIN_ReleasePtr( win
);
623 if (!icon_title
) return FALSE
;
624 SendMessageW( icon_title
, WM_SHOWWINDOW
, TRUE
, 0 );
625 InvalidateRect( icon_title
, NULL
, TRUE
);
629 /***********************************************************************
630 * WINPOS_ShowIconTitle
632 static BOOL
WINPOS_ShowIconTitle( HWND hwnd
, BOOL bShow
)
634 if (!GetPropA( hwnd
, "__wine_x11_managed" ))
636 WND
*win
= WIN_GetPtr( hwnd
);
639 TRACE("%p %i\n", hwnd
, (bShow
!= 0) );
641 if (!win
|| win
== WND_OTHER_PROCESS
|| win
== WND_DESKTOP
) return FALSE
;
642 title
= win
->icon_title
;
643 WIN_ReleasePtr( win
);
649 title
= ICONTITLE_Create( hwnd
);
650 if (!(win
= WIN_GetPtr( hwnd
)) || win
== WND_OTHER_PROCESS
)
652 DestroyWindow( title
);
655 win
->icon_title
= title
;
656 WIN_ReleasePtr( win
);
658 if (!IsWindowVisible(title
))
660 SendMessageW( title
, WM_SHOWWINDOW
, TRUE
, 0 );
661 SetWindowPos( title
, 0, 0, 0, 0, 0, SWP_NOSIZE
| SWP_NOMOVE
|
662 SWP_NOACTIVATE
| SWP_NOZORDER
| SWP_SHOWWINDOW
);
665 else if (title
) ShowWindow( title
, SW_HIDE
);
670 /*******************************************************************
671 * WINPOS_GetMinMaxInfo
673 * Get the minimized and maximized information for a window.
675 void WINPOS_GetMinMaxInfo( HWND hwnd
, POINT
*maxSize
, POINT
*maxPos
,
676 POINT
*minTrack
, POINT
*maxTrack
)
681 LONG style
= GetWindowLongA( hwnd
, GWL_STYLE
);
682 LONG exstyle
= GetWindowLongA( hwnd
, GWL_EXSTYLE
);
686 /* Compute default values */
688 GetWindowRect(hwnd
, &rc
);
689 MinMax
.ptReserved
.x
= rc
.left
;
690 MinMax
.ptReserved
.y
= rc
.top
;
692 if (style
& WS_CHILD
)
694 if ((style
& WS_CAPTION
) == WS_CAPTION
)
695 style
&= ~WS_BORDER
; /* WS_CAPTION = WS_DLGFRAME | WS_BORDER */
697 GetClientRect(GetAncestor(hwnd
,GA_PARENT
), &rc
);
698 AdjustWindowRectEx(&rc
, style
, ((style
& WS_POPUP
) && GetMenu(hwnd
)), exstyle
);
700 /* avoid calculating this twice */
701 style
&= ~(WS_DLGFRAME
| WS_BORDER
| WS_THICKFRAME
);
703 MinMax
.ptMaxSize
.x
= rc
.right
- rc
.left
;
704 MinMax
.ptMaxSize
.y
= rc
.bottom
- rc
.top
;
708 MinMax
.ptMaxSize
.x
= GetSystemMetrics(SM_CXSCREEN
);
709 MinMax
.ptMaxSize
.y
= GetSystemMetrics(SM_CYSCREEN
);
711 MinMax
.ptMinTrackSize
.x
= GetSystemMetrics(SM_CXMINTRACK
);
712 MinMax
.ptMinTrackSize
.y
= GetSystemMetrics(SM_CYMINTRACK
);
713 MinMax
.ptMaxTrackSize
.x
= GetSystemMetrics(SM_CXMAXTRACK
);
714 MinMax
.ptMaxTrackSize
.y
= GetSystemMetrics(SM_CYMAXTRACK
);
716 if (HAS_DLGFRAME( style
, exstyle
))
718 xinc
= GetSystemMetrics(SM_CXDLGFRAME
);
719 yinc
= GetSystemMetrics(SM_CYDLGFRAME
);
724 if (HAS_THICKFRAME(style
))
726 xinc
+= GetSystemMetrics(SM_CXFRAME
);
727 yinc
+= GetSystemMetrics(SM_CYFRAME
);
729 if (style
& WS_BORDER
)
731 xinc
+= GetSystemMetrics(SM_CXBORDER
);
732 yinc
+= GetSystemMetrics(SM_CYBORDER
);
735 MinMax
.ptMaxSize
.x
+= 2 * xinc
;
736 MinMax
.ptMaxSize
.y
+= 2 * yinc
;
738 MinMax
.ptMaxPosition
.x
= -xinc
;
739 MinMax
.ptMaxPosition
.y
= -yinc
;
740 if ((win
= WIN_GetPtr( hwnd
)) && win
!= WND_DESKTOP
&& win
!= WND_OTHER_PROCESS
)
742 if (!EMPTYPOINT(win
->max_pos
)) MinMax
.ptMaxPosition
= win
->max_pos
;
743 WIN_ReleasePtr( win
);
746 SendMessageW( hwnd
, WM_GETMINMAXINFO
, 0, (LPARAM
)&MinMax
);
748 /* if the app didn't change the values, adapt them for the current monitor */
750 if ((monitor
= MonitorFromWindow( hwnd
, MONITOR_DEFAULTTOPRIMARY
)))
752 MONITORINFO mon_info
;
754 mon_info
.cbSize
= sizeof(mon_info
);
755 GetMonitorInfoW( monitor
, &mon_info
);
757 if (MinMax
.ptMaxSize
.x
== GetSystemMetrics(SM_CXSCREEN
) + 2 * xinc
&&
758 MinMax
.ptMaxSize
.y
== GetSystemMetrics(SM_CYSCREEN
) + 2 * yinc
)
760 MinMax
.ptMaxSize
.x
= (mon_info
.rcWork
.right
- mon_info
.rcWork
.left
) + 2 * xinc
;
761 MinMax
.ptMaxSize
.y
= (mon_info
.rcWork
.bottom
- mon_info
.rcWork
.top
) + 2 * yinc
;
763 if (MinMax
.ptMaxPosition
.x
== -xinc
&& MinMax
.ptMaxPosition
.y
== -yinc
)
765 MinMax
.ptMaxPosition
.x
= mon_info
.rcWork
.left
- xinc
;
766 MinMax
.ptMaxPosition
.y
= mon_info
.rcWork
.top
- yinc
;
770 /* Some sanity checks */
772 TRACE("%d %d / %d %d / %d %d / %d %d\n",
773 MinMax
.ptMaxSize
.x
, MinMax
.ptMaxSize
.y
,
774 MinMax
.ptMaxPosition
.x
, MinMax
.ptMaxPosition
.y
,
775 MinMax
.ptMaxTrackSize
.x
, MinMax
.ptMaxTrackSize
.y
,
776 MinMax
.ptMinTrackSize
.x
, MinMax
.ptMinTrackSize
.y
);
777 MinMax
.ptMaxTrackSize
.x
= max( MinMax
.ptMaxTrackSize
.x
,
778 MinMax
.ptMinTrackSize
.x
);
779 MinMax
.ptMaxTrackSize
.y
= max( MinMax
.ptMaxTrackSize
.y
,
780 MinMax
.ptMinTrackSize
.y
);
782 if (maxSize
) *maxSize
= MinMax
.ptMaxSize
;
783 if (maxPos
) *maxPos
= MinMax
.ptMaxPosition
;
784 if (minTrack
) *minTrack
= MinMax
.ptMinTrackSize
;
785 if (maxTrack
) *maxTrack
= MinMax
.ptMaxTrackSize
;
789 /***********************************************************************
792 * Find a suitable place for an iconic window.
794 static POINT
WINPOS_FindIconPos( HWND hwnd
, POINT pt
)
796 RECT rect
, rectParent
;
799 int xspacing
, yspacing
;
801 parent
= GetAncestor( hwnd
, GA_PARENT
);
802 GetClientRect( parent
, &rectParent
);
803 if ((pt
.x
>= rectParent
.left
) && (pt
.x
+ GetSystemMetrics(SM_CXICON
) < rectParent
.right
) &&
804 (pt
.y
>= rectParent
.top
) && (pt
.y
+ GetSystemMetrics(SM_CYICON
) < rectParent
.bottom
))
805 return pt
; /* The icon already has a suitable position */
807 xspacing
= GetSystemMetrics(SM_CXICONSPACING
);
808 yspacing
= GetSystemMetrics(SM_CYICONSPACING
);
810 /* Check if another icon already occupies this spot */
811 /* FIXME: this is completely inefficient */
813 hrgn
= CreateRectRgn( 0, 0, 0, 0 );
814 tmp
= CreateRectRgn( 0, 0, 0, 0 );
815 for (child
= GetWindow( parent
, GW_HWNDFIRST
); child
; child
= GetWindow( child
, GW_HWNDNEXT
))
818 if (child
== hwnd
) continue;
819 if ((GetWindowLongW( child
, GWL_STYLE
) & (WS_VISIBLE
|WS_MINIMIZE
)) != (WS_VISIBLE
|WS_MINIMIZE
))
821 if (!(childPtr
= WIN_GetPtr( child
)) || childPtr
== WND_OTHER_PROCESS
)
823 SetRectRgn( tmp
, childPtr
->rectWindow
.left
, childPtr
->rectWindow
.top
,
824 childPtr
->rectWindow
.right
, childPtr
->rectWindow
.bottom
);
825 CombineRgn( hrgn
, hrgn
, tmp
, RGN_OR
);
826 WIN_ReleasePtr( childPtr
);
830 for (rect
.bottom
= rectParent
.bottom
; rect
.bottom
>= yspacing
; rect
.bottom
-= yspacing
)
832 for (rect
.left
= rectParent
.left
; rect
.left
<= rectParent
.right
- xspacing
; rect
.left
+= xspacing
)
834 rect
.right
= rect
.left
+ xspacing
;
835 rect
.top
= rect
.bottom
- yspacing
;
836 if (!RectInRegion( hrgn
, &rect
))
838 /* No window was found, so it's OK for us */
839 pt
.x
= rect
.left
+ (xspacing
- GetSystemMetrics(SM_CXICON
)) / 2;
840 pt
.y
= rect
.top
+ (yspacing
- GetSystemMetrics(SM_CYICON
)) / 2;
841 DeleteObject( hrgn
);
846 DeleteObject( hrgn
);
852 /***********************************************************************
855 UINT
WINPOS_MinMaximize( HWND hwnd
, UINT cmd
, LPRECT rect
)
863 TRACE("%p %u\n", hwnd
, cmd
);
865 wpl
.length
= sizeof(wpl
);
866 GetWindowPlacement( hwnd
, &wpl
);
868 if (HOOK_CallHooks( WH_CBT
, HCBT_MINMAX
, (WPARAM
)hwnd
, cmd
, TRUE
))
869 return SWP_NOSIZE
| SWP_NOMOVE
;
871 if (IsIconic( hwnd
))
875 case SW_SHOWMINNOACTIVE
:
876 case SW_SHOWMINIMIZED
:
877 case SW_FORCEMINIMIZE
:
879 return SWP_NOSIZE
| SWP_NOMOVE
;
881 if (!SendMessageW( hwnd
, WM_QUERYOPEN
, 0, 0 )) return SWP_NOSIZE
| SWP_NOMOVE
;
882 swpFlags
|= SWP_NOCOPYBITS
;
887 case SW_SHOWMINNOACTIVE
:
888 case SW_SHOWMINIMIZED
:
889 case SW_FORCEMINIMIZE
:
891 if (!(wndPtr
= WIN_GetPtr( hwnd
)) || wndPtr
== WND_OTHER_PROCESS
) return 0;
892 if( wndPtr
->dwStyle
& WS_MAXIMIZE
) wndPtr
->flags
|= WIN_RESTORE_MAX
;
893 else wndPtr
->flags
&= ~WIN_RESTORE_MAX
;
894 WIN_ReleasePtr( wndPtr
);
896 old_style
= WIN_SetStyle( hwnd
, WS_MINIMIZE
, WS_MAXIMIZE
);
898 wpl
.ptMinPosition
= WINPOS_FindIconPos( hwnd
, wpl
.ptMinPosition
);
900 if (!(old_style
& WS_MINIMIZE
)) swpFlags
|= SWP_STATECHANGED
;
901 SetRect( rect
, wpl
.ptMinPosition
.x
, wpl
.ptMinPosition
.y
,
902 GetSystemMetrics(SM_CXICON
), GetSystemMetrics(SM_CYICON
) );
903 swpFlags
|= SWP_NOCOPYBITS
;
907 old_style
= GetWindowLongW( hwnd
, GWL_STYLE
);
908 if ((old_style
& WS_MAXIMIZE
) && (old_style
& WS_VISIBLE
)) return SWP_NOSIZE
| SWP_NOMOVE
;
910 WINPOS_GetMinMaxInfo( hwnd
, &size
, &wpl
.ptMaxPosition
, NULL
, NULL
);
912 old_style
= WIN_SetStyle( hwnd
, WS_MAXIMIZE
, WS_MINIMIZE
);
913 if (old_style
& WS_MINIMIZE
) WINPOS_ShowIconTitle( hwnd
, FALSE
);
915 if (!(old_style
& WS_MAXIMIZE
)) swpFlags
|= SWP_STATECHANGED
;
916 SetRect( rect
, wpl
.ptMaxPosition
.x
, wpl
.ptMaxPosition
.y
, size
.x
, size
.y
);
919 case SW_SHOWNOACTIVATE
:
922 old_style
= WIN_SetStyle( hwnd
, 0, WS_MINIMIZE
| WS_MAXIMIZE
);
923 if (old_style
& WS_MINIMIZE
)
927 WINPOS_ShowIconTitle( hwnd
, FALSE
);
929 if (!(wndPtr
= WIN_GetPtr( hwnd
)) || wndPtr
== WND_OTHER_PROCESS
) return 0;
930 restore_max
= (wndPtr
->flags
& WIN_RESTORE_MAX
) != 0;
931 WIN_ReleasePtr( wndPtr
);
934 /* Restore to maximized position */
935 WINPOS_GetMinMaxInfo( hwnd
, &size
, &wpl
.ptMaxPosition
, NULL
, NULL
);
936 WIN_SetStyle( hwnd
, WS_MAXIMIZE
, 0 );
937 swpFlags
|= SWP_STATECHANGED
;
938 SetRect( rect
, wpl
.ptMaxPosition
.x
, wpl
.ptMaxPosition
.y
, size
.x
, size
.y
);
942 else if (!(old_style
& WS_MAXIMIZE
)) break;
944 swpFlags
|= SWP_STATECHANGED
;
946 /* Restore to normal position */
948 *rect
= wpl
.rcNormalPosition
;
949 rect
->right
-= rect
->left
;
950 rect
->bottom
-= rect
->top
;
959 /***********************************************************************
962 * Implementation of ShowWindow and ShowWindowAsync.
964 static BOOL
show_window( HWND hwnd
, INT cmd
)
968 LONG style
= GetWindowLongW( hwnd
, GWL_STYLE
);
969 BOOL wasVisible
= (style
& WS_VISIBLE
) != 0;
970 BOOL showFlag
= TRUE
;
971 RECT newPos
= {0, 0, 0, 0};
974 TRACE("hwnd=%p, cmd=%d, wasVisible %d\n", hwnd
, cmd
, wasVisible
);
979 if (!wasVisible
) return FALSE
;
981 swp
|= SWP_HIDEWINDOW
| SWP_NOSIZE
| SWP_NOMOVE
;
982 if (style
& WS_CHILD
) swp
|= SWP_NOACTIVATE
| SWP_NOZORDER
;
985 case SW_SHOWMINNOACTIVE
:
987 case SW_FORCEMINIMIZE
: /* FIXME: Does not work if thread is hung. */
988 swp
|= SWP_NOACTIVATE
| SWP_NOZORDER
;
990 case SW_SHOWMINIMIZED
:
991 swp
|= SWP_SHOWWINDOW
| SWP_FRAMECHANGED
;
992 swp
|= WINPOS_MinMaximize( hwnd
, cmd
, &newPos
);
993 if ((style
& WS_MINIMIZE
) && wasVisible
) return TRUE
;
996 case SW_SHOWMAXIMIZED
: /* same as SW_MAXIMIZE */
997 if (!wasVisible
) swp
|= SWP_SHOWWINDOW
;
998 swp
|= SWP_FRAMECHANGED
;
999 swp
|= WINPOS_MinMaximize( hwnd
, SW_MAXIMIZE
, &newPos
);
1000 if ((style
& WS_MAXIMIZE
) && wasVisible
) return TRUE
;
1004 swp
|= SWP_NOACTIVATE
| SWP_SHOWWINDOW
| SWP_NOSIZE
| SWP_NOMOVE
;
1005 if (style
& WS_CHILD
) swp
|= SWP_NOZORDER
;
1008 if (wasVisible
) return TRUE
;
1009 swp
|= SWP_SHOWWINDOW
| SWP_NOSIZE
| SWP_NOMOVE
;
1010 if (style
& WS_CHILD
) swp
|= SWP_NOACTIVATE
| SWP_NOZORDER
;
1013 case SW_SHOWNOACTIVATE
:
1014 swp
|= SWP_NOACTIVATE
| SWP_NOZORDER
;
1018 case SW_SHOWNORMAL
: /* same as SW_NORMAL: */
1019 case SW_SHOWDEFAULT
: /* FIXME: should have its own handler */
1020 if (!wasVisible
) swp
|= SWP_SHOWWINDOW
;
1021 if (style
& (WS_MINIMIZE
| WS_MAXIMIZE
))
1023 swp
|= SWP_FRAMECHANGED
;
1024 swp
|= WINPOS_MinMaximize( hwnd
, cmd
, &newPos
);
1028 if (wasVisible
) return TRUE
;
1029 swp
|= SWP_NOSIZE
| SWP_NOMOVE
;
1031 if (style
& WS_CHILD
&& !(swp
& SWP_STATECHANGED
)) swp
|= SWP_NOACTIVATE
| SWP_NOZORDER
;
1037 if ((showFlag
!= wasVisible
|| cmd
== SW_SHOWNA
) && cmd
!= SW_SHOWMAXIMIZED
&& !(swp
& SWP_STATECHANGED
))
1039 SendMessageW( hwnd
, WM_SHOWWINDOW
, showFlag
, 0 );
1040 if (!IsWindow( hwnd
)) return wasVisible
;
1043 parent
= GetAncestor( hwnd
, GA_PARENT
);
1044 if (parent
&& !IsWindowVisible( parent
) && !(swp
& SWP_STATECHANGED
))
1046 /* if parent is not visible simply toggle WS_VISIBLE and return */
1047 if (showFlag
) WIN_SetStyle( hwnd
, WS_VISIBLE
, 0 );
1048 else WIN_SetStyle( hwnd
, 0, WS_VISIBLE
);
1051 SetWindowPos( hwnd
, HWND_TOP
, newPos
.left
, newPos
.top
,
1052 newPos
.right
, newPos
.bottom
, LOWORD(swp
) );
1058 WINPOS_ShowIconTitle( hwnd
, FALSE
);
1060 /* FIXME: This will cause the window to be activated irrespective
1061 * of whether it is owned by the same thread. Has to be done
1065 if (hwnd
== GetActiveWindow())
1066 WINPOS_ActivateOtherWindow(hwnd
);
1068 /* Revert focus to parent */
1069 hFocus
= GetFocus();
1070 if (hwnd
== hFocus
|| IsChild(hwnd
, hFocus
))
1072 HWND parent
= GetAncestor(hwnd
, GA_PARENT
);
1073 if (parent
== GetDesktopWindow()) parent
= 0;
1078 if (IsIconic(hwnd
)) WINPOS_ShowIconTitle( hwnd
, TRUE
);
1080 if (!(wndPtr
= WIN_GetPtr( hwnd
)) || wndPtr
== WND_OTHER_PROCESS
) return wasVisible
;
1082 if (wndPtr
->flags
& WIN_NEED_SIZE
)
1084 /* should happen only in CreateWindowEx() */
1085 int wParam
= SIZE_RESTORED
;
1086 RECT client
= wndPtr
->rectClient
;
1088 wndPtr
->flags
&= ~WIN_NEED_SIZE
;
1089 if (wndPtr
->dwStyle
& WS_MAXIMIZE
) wParam
= SIZE_MAXIMIZED
;
1090 else if (wndPtr
->dwStyle
& WS_MINIMIZE
) wParam
= SIZE_MINIMIZED
;
1091 WIN_ReleasePtr( wndPtr
);
1093 SendMessageW( hwnd
, WM_SIZE
, wParam
,
1094 MAKELONG( client
.right
- client
.left
, client
.bottom
- client
.top
));
1095 SendMessageW( hwnd
, WM_MOVE
, 0, MAKELONG( client
.left
, client
.top
));
1097 else WIN_ReleasePtr( wndPtr
);
1099 /* if previous state was minimized Windows sets focus to the window */
1100 if (style
& WS_MINIMIZE
) SetFocus( hwnd
);
1106 /***********************************************************************
1107 * ShowWindowAsync (USER32.@)
1109 * doesn't wait; returns immediately.
1110 * used by threads to toggle windows in other (possibly hanging) threads
1112 BOOL WINAPI
ShowWindowAsync( HWND hwnd
, INT cmd
)
1116 if (is_broadcast(hwnd
))
1118 SetLastError( ERROR_INVALID_PARAMETER
);
1122 if ((full_handle
= WIN_IsCurrentThread( hwnd
)))
1123 return show_window( full_handle
, cmd
);
1125 return SendNotifyMessageW( hwnd
, WM_WINE_SHOWWINDOW
, cmd
, 0 );
1129 /***********************************************************************
1130 * ShowWindow (USER32.@)
1132 BOOL WINAPI
ShowWindow( HWND hwnd
, INT cmd
)
1136 if (is_broadcast(hwnd
))
1138 SetLastError( ERROR_INVALID_PARAMETER
);
1141 if ((full_handle
= WIN_IsCurrentThread( hwnd
)))
1142 return show_window( full_handle
, cmd
);
1144 return SendMessageW( hwnd
, WM_WINE_SHOWWINDOW
, cmd
, 0 );
1148 /***********************************************************************
1149 * GetInternalWindowPos (USER32.@)
1151 UINT WINAPI
GetInternalWindowPos( HWND hwnd
, LPRECT rectWnd
,
1154 WINDOWPLACEMENT wndpl
;
1155 if (GetWindowPlacement( hwnd
, &wndpl
))
1157 if (rectWnd
) *rectWnd
= wndpl
.rcNormalPosition
;
1158 if (ptIcon
) *ptIcon
= wndpl
.ptMinPosition
;
1159 return wndpl
.showCmd
;
1165 /***********************************************************************
1166 * GetWindowPlacement (USER32.@)
1169 * Fails if wndpl->length of Win95 (!) apps is invalid.
1171 BOOL WINAPI
GetWindowPlacement( HWND hwnd
, WINDOWPLACEMENT
*wndpl
)
1173 WND
*pWnd
= WIN_GetPtr( hwnd
);
1175 if (!pWnd
|| pWnd
== WND_DESKTOP
) return FALSE
;
1176 if (pWnd
== WND_OTHER_PROCESS
)
1178 if (IsWindow( hwnd
)) FIXME( "not supported on other process window %p\n", hwnd
);
1182 WINPOS_InitPlacement( pWnd
);
1183 wndpl
->length
= sizeof(*wndpl
);
1184 if( pWnd
->dwStyle
& WS_MINIMIZE
)
1185 wndpl
->showCmd
= SW_SHOWMINIMIZED
;
1187 wndpl
->showCmd
= ( pWnd
->dwStyle
& WS_MAXIMIZE
) ? SW_SHOWMAXIMIZED
: SW_SHOWNORMAL
;
1188 if( pWnd
->flags
& WIN_RESTORE_MAX
)
1189 wndpl
->flags
= WPF_RESTORETOMAXIMIZED
;
1192 wndpl
->ptMinPosition
= pWnd
->min_pos
;
1193 wndpl
->ptMaxPosition
= pWnd
->max_pos
;
1194 wndpl
->rcNormalPosition
= pWnd
->normal_rect
;
1195 WIN_ReleasePtr( pWnd
);
1197 TRACE( "%p: returning min %d,%d max %d,%d normal %s\n",
1198 hwnd
, wndpl
->ptMinPosition
.x
, wndpl
->ptMinPosition
.y
,
1199 wndpl
->ptMaxPosition
.x
, wndpl
->ptMaxPosition
.y
,
1200 wine_dbgstr_rect(&wndpl
->rcNormalPosition
) );
1204 /* make sure the specified rect is visible on screen */
1205 static void make_rect_onscreen( RECT
*rect
)
1208 HMONITOR monitor
= MonitorFromRect( rect
, MONITOR_DEFAULTTONEAREST
);
1210 info
.cbSize
= sizeof(info
);
1211 if (!monitor
|| !GetMonitorInfoW( monitor
, &info
)) return;
1212 /* FIXME: map coordinates from rcWork to rcMonitor */
1213 if (rect
->right
<= info
.rcWork
.left
)
1215 rect
->right
+= info
.rcWork
.left
- rect
->left
;
1216 rect
->left
= info
.rcWork
.left
;
1218 else if (rect
->left
>= info
.rcWork
.right
)
1220 rect
->left
+= info
.rcWork
.right
- rect
->right
;
1221 rect
->right
= info
.rcWork
.right
;
1223 if (rect
->bottom
<= info
.rcWork
.top
)
1225 rect
->bottom
+= info
.rcWork
.top
- rect
->top
;
1226 rect
->top
= info
.rcWork
.top
;
1228 else if (rect
->top
>= info
.rcWork
.bottom
)
1230 rect
->top
+= info
.rcWork
.bottom
- rect
->bottom
;
1231 rect
->bottom
= info
.rcWork
.bottom
;
1235 /* make sure the specified point is visible on screen */
1236 static void make_point_onscreen( POINT
*pt
)
1240 SetRect( &rect
, pt
->x
, pt
->y
, pt
->x
+ 1, pt
->y
+ 1 );
1241 make_rect_onscreen( &rect
);
1247 /***********************************************************************
1248 * WINPOS_SetPlacement
1250 static BOOL
WINPOS_SetPlacement( HWND hwnd
, const WINDOWPLACEMENT
*wndpl
, UINT flags
)
1253 WND
*pWnd
= WIN_GetPtr( hwnd
);
1254 WINDOWPLACEMENT wp
= *wndpl
;
1256 if (flags
& PLACE_MIN
) make_point_onscreen( &wp
.ptMinPosition
);
1257 if (flags
& PLACE_MAX
) make_point_onscreen( &wp
.ptMaxPosition
);
1258 if (flags
& PLACE_RECT
) make_rect_onscreen( &wp
.rcNormalPosition
);
1260 TRACE( "%p: setting min %d,%d max %d,%d normal %s flags %x ajusted to min %d,%d max %d,%d normal %s\n",
1261 hwnd
, wndpl
->ptMinPosition
.x
, wndpl
->ptMinPosition
.y
,
1262 wndpl
->ptMaxPosition
.x
, wndpl
->ptMaxPosition
.y
,
1263 wine_dbgstr_rect(&wndpl
->rcNormalPosition
), flags
,
1264 wp
.ptMinPosition
.x
, wp
.ptMinPosition
.y
, wp
.ptMaxPosition
.x
, wp
.ptMaxPosition
.y
,
1265 wine_dbgstr_rect(&wp
.rcNormalPosition
) );
1267 if (!pWnd
|| pWnd
== WND_OTHER_PROCESS
|| pWnd
== WND_DESKTOP
) return FALSE
;
1269 if( flags
& PLACE_MIN
) pWnd
->min_pos
= wp
.ptMinPosition
;
1270 if( flags
& PLACE_MAX
) pWnd
->max_pos
= wp
.ptMaxPosition
;
1271 if( flags
& PLACE_RECT
) pWnd
->normal_rect
= wp
.rcNormalPosition
;
1273 style
= pWnd
->dwStyle
;
1275 WIN_ReleasePtr( pWnd
);
1277 if( style
& WS_MINIMIZE
)
1279 if (flags
& PLACE_MIN
)
1281 WINPOS_ShowIconTitle( hwnd
, FALSE
);
1282 SetWindowPos( hwnd
, 0, wp
.ptMinPosition
.x
, wp
.ptMinPosition
.y
, 0, 0,
1283 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
1286 else if( style
& WS_MAXIMIZE
)
1288 if (flags
& PLACE_MAX
)
1289 SetWindowPos( hwnd
, 0, wp
.ptMaxPosition
.x
, wp
.ptMaxPosition
.y
, 0, 0,
1290 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
1292 else if( flags
& PLACE_RECT
)
1293 SetWindowPos( hwnd
, 0, wp
.rcNormalPosition
.left
, wp
.rcNormalPosition
.top
,
1294 wp
.rcNormalPosition
.right
- wp
.rcNormalPosition
.left
,
1295 wp
.rcNormalPosition
.bottom
- wp
.rcNormalPosition
.top
,
1296 SWP_NOZORDER
| SWP_NOACTIVATE
);
1298 ShowWindow( hwnd
, wndpl
->showCmd
);
1300 if (IsIconic( hwnd
))
1302 if (GetWindowLongW( hwnd
, GWL_STYLE
) & WS_VISIBLE
) WINPOS_ShowIconTitle( hwnd
, TRUE
);
1304 /* SDK: ...valid only the next time... */
1305 if( wndpl
->flags
& WPF_RESTORETOMAXIMIZED
)
1307 pWnd
= WIN_GetPtr( hwnd
);
1308 if (pWnd
&& pWnd
!= WND_OTHER_PROCESS
)
1310 pWnd
->flags
|= WIN_RESTORE_MAX
;
1311 WIN_ReleasePtr( pWnd
);
1319 /***********************************************************************
1320 * SetWindowPlacement (USER32.@)
1323 * Fails if wndpl->length of Win95 (!) apps is invalid.
1325 BOOL WINAPI
SetWindowPlacement( HWND hwnd
, const WINDOWPLACEMENT
*wpl
)
1327 UINT flags
= PLACE_MAX
| PLACE_RECT
;
1328 if (!wpl
) return FALSE
;
1329 if (wpl
->flags
& WPF_SETMINPOSITION
) flags
|= PLACE_MIN
;
1330 return WINPOS_SetPlacement( hwnd
, wpl
, flags
);
1334 /***********************************************************************
1335 * AnimateWindow (USER32.@)
1336 * Shows/Hides a window with an animation
1339 BOOL WINAPI
AnimateWindow(HWND hwnd
, DWORD dwTime
, DWORD dwFlags
)
1341 FIXME("partial stub\n");
1343 /* If trying to show/hide and it's already *
1344 * shown/hidden or invalid window, fail with *
1345 * invalid parameter */
1346 if(!IsWindow(hwnd
) ||
1347 (IsWindowVisible(hwnd
) && !(dwFlags
& AW_HIDE
)) ||
1348 (!IsWindowVisible(hwnd
) && (dwFlags
& AW_HIDE
)))
1350 SetLastError(ERROR_INVALID_PARAMETER
);
1354 ShowWindow(hwnd
, (dwFlags
& AW_HIDE
) ? SW_HIDE
: ((dwFlags
& AW_ACTIVATE
) ? SW_SHOW
: SW_SHOWNA
));
1359 /***********************************************************************
1360 * SetInternalWindowPos (USER32.@)
1362 void WINAPI
SetInternalWindowPos( HWND hwnd
, UINT showCmd
,
1363 LPRECT rect
, LPPOINT pt
)
1365 WINDOWPLACEMENT wndpl
;
1368 wndpl
.length
= sizeof(wndpl
);
1369 wndpl
.showCmd
= showCmd
;
1370 wndpl
.flags
= flags
= 0;
1375 wndpl
.flags
|= WPF_SETMINPOSITION
;
1376 wndpl
.ptMinPosition
= *pt
;
1380 flags
|= PLACE_RECT
;
1381 wndpl
.rcNormalPosition
= *rect
;
1383 WINPOS_SetPlacement( hwnd
, &wndpl
, flags
);
1387 /*******************************************************************
1388 * can_activate_window
1390 * Check if we can activate the specified window.
1392 static BOOL
can_activate_window( HWND hwnd
)
1396 if (!hwnd
) return FALSE
;
1397 style
= GetWindowLongW( hwnd
, GWL_STYLE
);
1398 if (!(style
& WS_VISIBLE
)) return FALSE
;
1399 if ((style
& (WS_POPUP
|WS_CHILD
)) == WS_CHILD
) return FALSE
;
1400 return !(style
& WS_DISABLED
);
1404 /*******************************************************************
1405 * WINPOS_ActivateOtherWindow
1407 * Activates window other than pWnd.
1409 void WINPOS_ActivateOtherWindow(HWND hwnd
)
1413 if ((GetWindowLongW( hwnd
, GWL_STYLE
) & WS_POPUP
) && (hwndTo
= GetWindow( hwnd
, GW_OWNER
)))
1415 hwndTo
= GetAncestor( hwndTo
, GA_ROOT
);
1416 if (can_activate_window( hwndTo
)) goto done
;
1422 if (!(hwndTo
= GetWindow( hwndTo
, GW_HWNDNEXT
))) break;
1423 if (can_activate_window( hwndTo
)) break;
1427 fg
= GetForegroundWindow();
1428 TRACE("win = %p fg = %p\n", hwndTo
, fg
);
1429 if (!fg
|| (hwnd
== fg
))
1431 if (SetForegroundWindow( hwndTo
)) return;
1433 if (!SetActiveWindow( hwndTo
)) SetActiveWindow(0);
1437 /***********************************************************************
1438 * WINPOS_HandleWindowPosChanging
1440 * Default handling for a WM_WINDOWPOSCHANGING. Called from DefWindowProc().
1442 LONG
WINPOS_HandleWindowPosChanging( HWND hwnd
, WINDOWPOS
*winpos
)
1444 POINT minTrack
, maxTrack
;
1445 LONG style
= GetWindowLongW( hwnd
, GWL_STYLE
);
1447 if (winpos
->flags
& SWP_NOSIZE
) return 0;
1448 if ((style
& WS_THICKFRAME
) || ((style
& (WS_POPUP
| WS_CHILD
)) == 0))
1450 WINPOS_GetMinMaxInfo( hwnd
, NULL
, NULL
, &minTrack
, &maxTrack
);
1451 if (winpos
->cx
> maxTrack
.x
) winpos
->cx
= maxTrack
.x
;
1452 if (winpos
->cy
> maxTrack
.y
) winpos
->cy
= maxTrack
.y
;
1453 if (!(style
& WS_MINIMIZE
))
1455 if (winpos
->cx
< minTrack
.x
) winpos
->cx
= minTrack
.x
;
1456 if (winpos
->cy
< minTrack
.y
) winpos
->cy
= minTrack
.y
;
1463 /***********************************************************************
1466 static void dump_winpos_flags(UINT flags
)
1468 static const DWORD dumped_flags
= (SWP_NOSIZE
| SWP_NOMOVE
| SWP_NOZORDER
| SWP_NOREDRAW
|
1469 SWP_NOACTIVATE
| SWP_FRAMECHANGED
| SWP_SHOWWINDOW
|
1470 SWP_HIDEWINDOW
| SWP_NOCOPYBITS
| SWP_NOOWNERZORDER
|
1471 SWP_NOSENDCHANGING
| SWP_DEFERERASE
| SWP_ASYNCWINDOWPOS
|
1472 SWP_NOCLIENTSIZE
| SWP_NOCLIENTMOVE
| SWP_STATECHANGED
);
1474 if(flags
& SWP_NOSIZE
) TRACE(" SWP_NOSIZE");
1475 if(flags
& SWP_NOMOVE
) TRACE(" SWP_NOMOVE");
1476 if(flags
& SWP_NOZORDER
) TRACE(" SWP_NOZORDER");
1477 if(flags
& SWP_NOREDRAW
) TRACE(" SWP_NOREDRAW");
1478 if(flags
& SWP_NOACTIVATE
) TRACE(" SWP_NOACTIVATE");
1479 if(flags
& SWP_FRAMECHANGED
) TRACE(" SWP_FRAMECHANGED");
1480 if(flags
& SWP_SHOWWINDOW
) TRACE(" SWP_SHOWWINDOW");
1481 if(flags
& SWP_HIDEWINDOW
) TRACE(" SWP_HIDEWINDOW");
1482 if(flags
& SWP_NOCOPYBITS
) TRACE(" SWP_NOCOPYBITS");
1483 if(flags
& SWP_NOOWNERZORDER
) TRACE(" SWP_NOOWNERZORDER");
1484 if(flags
& SWP_NOSENDCHANGING
) TRACE(" SWP_NOSENDCHANGING");
1485 if(flags
& SWP_DEFERERASE
) TRACE(" SWP_DEFERERASE");
1486 if(flags
& SWP_ASYNCWINDOWPOS
) TRACE(" SWP_ASYNCWINDOWPOS");
1487 if(flags
& SWP_NOCLIENTSIZE
) TRACE(" SWP_NOCLIENTSIZE");
1488 if(flags
& SWP_NOCLIENTMOVE
) TRACE(" SWP_NOCLIENTMOVE");
1489 if(flags
& SWP_STATECHANGED
) TRACE(" SWP_STATECHANGED");
1491 if(flags
& ~dumped_flags
) TRACE(" %08x", flags
& ~dumped_flags
);
1495 /***********************************************************************
1496 * SWP_DoWinPosChanging
1498 static BOOL
SWP_DoWinPosChanging( WINDOWPOS
* pWinpos
, RECT
* pNewWindowRect
, RECT
* pNewClientRect
)
1502 /* Send WM_WINDOWPOSCHANGING message */
1504 if (!(pWinpos
->flags
& SWP_NOSENDCHANGING
))
1505 SendMessageW( pWinpos
->hwnd
, WM_WINDOWPOSCHANGING
, 0, (LPARAM
)pWinpos
);
1507 if (!(wndPtr
= WIN_GetPtr( pWinpos
->hwnd
)) ||
1508 wndPtr
== WND_OTHER_PROCESS
|| wndPtr
== WND_DESKTOP
) return FALSE
;
1510 /* Calculate new position and size */
1512 *pNewWindowRect
= wndPtr
->rectWindow
;
1513 *pNewClientRect
= (wndPtr
->dwStyle
& WS_MINIMIZE
) ? wndPtr
->rectWindow
1514 : wndPtr
->rectClient
;
1516 if (!(pWinpos
->flags
& SWP_NOSIZE
))
1518 pNewWindowRect
->right
= pNewWindowRect
->left
+ pWinpos
->cx
;
1519 pNewWindowRect
->bottom
= pNewWindowRect
->top
+ pWinpos
->cy
;
1521 if (!(pWinpos
->flags
& SWP_NOMOVE
))
1523 pNewWindowRect
->left
= pWinpos
->x
;
1524 pNewWindowRect
->top
= pWinpos
->y
;
1525 pNewWindowRect
->right
+= pWinpos
->x
- wndPtr
->rectWindow
.left
;
1526 pNewWindowRect
->bottom
+= pWinpos
->y
- wndPtr
->rectWindow
.top
;
1528 OffsetRect( pNewClientRect
, pWinpos
->x
- wndPtr
->rectWindow
.left
,
1529 pWinpos
->y
- wndPtr
->rectWindow
.top
);
1531 pWinpos
->flags
|= SWP_NOCLIENTMOVE
| SWP_NOCLIENTSIZE
;
1533 TRACE( "hwnd %p, after %p, swp %d,%d %dx%d flags %08x\n",
1534 pWinpos
->hwnd
, pWinpos
->hwndInsertAfter
, pWinpos
->x
, pWinpos
->y
,
1535 pWinpos
->cx
, pWinpos
->cy
, pWinpos
->flags
);
1536 TRACE( "current %s style %08x new %s\n",
1537 wine_dbgstr_rect( &wndPtr
->rectWindow
), wndPtr
->dwStyle
,
1538 wine_dbgstr_rect( pNewWindowRect
));
1540 WIN_ReleasePtr( wndPtr
);
1544 /***********************************************************************
1547 * Compute the valid rects from the old and new client rect and WVR_* flags.
1548 * Helper for WM_NCCALCSIZE handling.
1550 static inline void get_valid_rects( const RECT
*old_client
, const RECT
*new_client
, UINT flags
,
1555 if (flags
& WVR_REDRAW
)
1557 SetRectEmpty( &valid
[0] );
1558 SetRectEmpty( &valid
[1] );
1562 if (flags
& WVR_VALIDRECTS
)
1564 if (!IntersectRect( &valid
[0], &valid
[0], new_client
) ||
1565 !IntersectRect( &valid
[1], &valid
[1], old_client
))
1567 SetRectEmpty( &valid
[0] );
1568 SetRectEmpty( &valid
[1] );
1571 flags
= WVR_ALIGNLEFT
| WVR_ALIGNTOP
;
1575 valid
[0] = *new_client
;
1576 valid
[1] = *old_client
;
1579 /* make sure the rectangles have the same size */
1580 cx
= min( valid
[0].right
- valid
[0].left
, valid
[1].right
- valid
[1].left
);
1581 cy
= min( valid
[0].bottom
- valid
[0].top
, valid
[1].bottom
- valid
[1].top
);
1583 if (flags
& WVR_ALIGNBOTTOM
)
1585 valid
[0].top
= valid
[0].bottom
- cy
;
1586 valid
[1].top
= valid
[1].bottom
- cy
;
1590 valid
[0].bottom
= valid
[0].top
+ cy
;
1591 valid
[1].bottom
= valid
[1].top
+ cy
;
1593 if (flags
& WVR_ALIGNRIGHT
)
1595 valid
[0].left
= valid
[0].right
- cx
;
1596 valid
[1].left
= valid
[1].right
- cx
;
1600 valid
[0].right
= valid
[0].left
+ cx
;
1601 valid
[1].right
= valid
[1].left
+ cx
;
1606 /***********************************************************************
1609 * fix Z order taking into account owned popups -
1610 * basically we need to maintain them above the window that owns them
1612 * FIXME: hide/show owned popups when owner visibility changes.
1614 static HWND
SWP_DoOwnedPopups(HWND hwnd
, HWND hwndInsertAfter
)
1616 LONG style
= GetWindowLongW( hwnd
, GWL_STYLE
);
1617 HWND owner
, *list
= NULL
;
1620 TRACE("(%p) hInsertAfter = %p\n", hwnd
, hwndInsertAfter
);
1622 if ((style
& WS_POPUP
) && (owner
= GetWindow( hwnd
, GW_OWNER
)))
1624 /* make sure this popup stays above the owner */
1626 if (hwndInsertAfter
!= HWND_TOP
&& hwndInsertAfter
!= HWND_TOPMOST
)
1628 if (!(list
= WIN_ListChildren( GetDesktopWindow() ))) return hwndInsertAfter
;
1630 for (i
= 0; list
[i
]; i
++)
1632 if (list
[i
] == owner
)
1634 if (i
> 0) hwndInsertAfter
= list
[i
-1];
1635 else hwndInsertAfter
= HWND_TOP
;
1639 if (hwndInsertAfter
== HWND_NOTOPMOST
)
1641 if (!(GetWindowLongW( list
[i
], GWL_EXSTYLE
) & WS_EX_TOPMOST
)) break;
1643 else if (list
[i
] == hwndInsertAfter
) break;
1647 else if (style
& WS_CHILD
) return hwndInsertAfter
;
1649 if (hwndInsertAfter
== HWND_BOTTOM
) goto done
;
1650 if (!list
&& !(list
= WIN_ListChildren( GetDesktopWindow() ))) goto done
;
1653 if (hwndInsertAfter
== HWND_TOP
|| hwndInsertAfter
== HWND_NOTOPMOST
)
1655 if (hwndInsertAfter
== HWND_NOTOPMOST
|| !(GetWindowLongW( hwnd
, GWL_EXSTYLE
) & WS_EX_TOPMOST
))
1657 /* skip all the topmost windows */
1658 while (list
[i
] && (GetWindowLongW( list
[i
], GWL_EXSTYLE
) & WS_EX_TOPMOST
)) i
++;
1661 else if (hwndInsertAfter
!= HWND_TOPMOST
)
1663 /* skip windows that are already placed correctly */
1664 for (i
= 0; list
[i
]; i
++)
1666 if (list
[i
] == hwndInsertAfter
) break;
1667 if (list
[i
] == hwnd
) goto done
; /* nothing to do if window is moving backwards in z-order */
1671 for ( ; list
[i
]; i
++)
1673 if (list
[i
] == hwnd
) break;
1674 if (!(GetWindowLongW( list
[i
], GWL_STYLE
) & WS_POPUP
)) continue;
1675 if (GetWindow( list
[i
], GW_OWNER
) != hwnd
) continue;
1676 TRACE( "moving %p owned by %p after %p\n", list
[i
], hwnd
, hwndInsertAfter
);
1677 SetWindowPos( list
[i
], hwndInsertAfter
, 0, 0, 0, 0,
1678 SWP_NOMOVE
| SWP_NOSIZE
| SWP_NOACTIVATE
| SWP_NOSENDCHANGING
| SWP_DEFERERASE
);
1679 hwndInsertAfter
= list
[i
];
1683 HeapFree( GetProcessHeap(), 0, list
);
1684 return hwndInsertAfter
;
1687 /***********************************************************************
1690 static UINT
SWP_DoNCCalcSize( WINDOWPOS
* pWinpos
, const RECT
* pNewWindowRect
, RECT
* pNewClientRect
,
1696 if (!(wndPtr
= WIN_GetPtr( pWinpos
->hwnd
)) || wndPtr
== WND_OTHER_PROCESS
) return 0;
1698 /* Send WM_NCCALCSIZE message to get new client area */
1699 if( (pWinpos
->flags
& (SWP_FRAMECHANGED
| SWP_NOSIZE
)) != SWP_NOSIZE
)
1701 NCCALCSIZE_PARAMS params
;
1702 WINDOWPOS winposCopy
;
1704 params
.rgrc
[0] = *pNewWindowRect
;
1705 params
.rgrc
[1] = wndPtr
->rectWindow
;
1706 params
.rgrc
[2] = wndPtr
->rectClient
;
1707 params
.lppos
= &winposCopy
;
1708 winposCopy
= *pWinpos
;
1709 WIN_ReleasePtr( wndPtr
);
1711 wvrFlags
= SendMessageW( pWinpos
->hwnd
, WM_NCCALCSIZE
, TRUE
, (LPARAM
)¶ms
);
1713 *pNewClientRect
= params
.rgrc
[0];
1715 if (!(wndPtr
= WIN_GetPtr( pWinpos
->hwnd
)) || wndPtr
== WND_OTHER_PROCESS
) return 0;
1717 TRACE( "hwnd %p old win %s old client %s new win %s new client %s\n", pWinpos
->hwnd
,
1718 wine_dbgstr_rect(&wndPtr
->rectWindow
), wine_dbgstr_rect(&wndPtr
->rectClient
),
1719 wine_dbgstr_rect(pNewWindowRect
), wine_dbgstr_rect(pNewClientRect
) );
1721 if( pNewClientRect
->left
!= wndPtr
->rectClient
.left
||
1722 pNewClientRect
->top
!= wndPtr
->rectClient
.top
)
1723 pWinpos
->flags
&= ~SWP_NOCLIENTMOVE
;
1725 if( (pNewClientRect
->right
- pNewClientRect
->left
!=
1726 wndPtr
->rectClient
.right
- wndPtr
->rectClient
.left
))
1727 pWinpos
->flags
&= ~SWP_NOCLIENTSIZE
;
1729 wvrFlags
&= ~WVR_HREDRAW
;
1731 if (pNewClientRect
->bottom
- pNewClientRect
->top
!=
1732 wndPtr
->rectClient
.bottom
- wndPtr
->rectClient
.top
)
1733 pWinpos
->flags
&= ~SWP_NOCLIENTSIZE
;
1735 wvrFlags
&= ~WVR_VREDRAW
;
1737 validRects
[0] = params
.rgrc
[1];
1738 validRects
[1] = params
.rgrc
[2];
1742 if (!(pWinpos
->flags
& SWP_NOMOVE
) &&
1743 (pNewClientRect
->left
!= wndPtr
->rectClient
.left
||
1744 pNewClientRect
->top
!= wndPtr
->rectClient
.top
))
1745 pWinpos
->flags
&= ~SWP_NOCLIENTMOVE
;
1748 if (pWinpos
->flags
& (SWP_NOCOPYBITS
| SWP_NOREDRAW
| SWP_SHOWWINDOW
| SWP_HIDEWINDOW
))
1750 SetRectEmpty( &validRects
[0] );
1751 SetRectEmpty( &validRects
[1] );
1753 else get_valid_rects( &wndPtr
->rectClient
, pNewClientRect
, wvrFlags
, validRects
);
1755 WIN_ReleasePtr( wndPtr
);
1759 /* fix redundant flags and values in the WINDOWPOS structure */
1760 static BOOL
fixup_flags( WINDOWPOS
*winpos
)
1763 WND
*wndPtr
= WIN_GetPtr( winpos
->hwnd
);
1766 if (!wndPtr
|| wndPtr
== WND_OTHER_PROCESS
)
1768 SetLastError( ERROR_INVALID_WINDOW_HANDLE
);
1771 winpos
->hwnd
= wndPtr
->hwndSelf
; /* make it a full handle */
1773 /* Finally make sure that all coordinates are valid */
1774 if (winpos
->x
< -32768) winpos
->x
= -32768;
1775 else if (winpos
->x
> 32767) winpos
->x
= 32767;
1776 if (winpos
->y
< -32768) winpos
->y
= -32768;
1777 else if (winpos
->y
> 32767) winpos
->y
= 32767;
1779 if (winpos
->cx
< 0) winpos
->cx
= 0;
1780 else if (winpos
->cx
> 32767) winpos
->cx
= 32767;
1781 if (winpos
->cy
< 0) winpos
->cy
= 0;
1782 else if (winpos
->cy
> 32767) winpos
->cy
= 32767;
1784 parent
= GetAncestor( winpos
->hwnd
, GA_PARENT
);
1785 if (!IsWindowVisible( parent
)) winpos
->flags
|= SWP_NOREDRAW
;
1787 if (wndPtr
->dwStyle
& WS_VISIBLE
) winpos
->flags
&= ~SWP_SHOWWINDOW
;
1790 winpos
->flags
&= ~SWP_HIDEWINDOW
;
1791 if (!(winpos
->flags
& SWP_SHOWWINDOW
)) winpos
->flags
|= SWP_NOREDRAW
;
1794 if ((wndPtr
->rectWindow
.right
- wndPtr
->rectWindow
.left
== winpos
->cx
) &&
1795 (wndPtr
->rectWindow
.bottom
- wndPtr
->rectWindow
.top
== winpos
->cy
))
1796 winpos
->flags
|= SWP_NOSIZE
; /* Already the right size */
1798 if ((wndPtr
->rectWindow
.left
== winpos
->x
) && (wndPtr
->rectWindow
.top
== winpos
->y
))
1799 winpos
->flags
|= SWP_NOMOVE
; /* Already the right position */
1801 if ((wndPtr
->dwStyle
& (WS_POPUP
| WS_CHILD
)) != WS_CHILD
)
1803 if (!(winpos
->flags
& (SWP_NOACTIVATE
|SWP_HIDEWINDOW
)) && /* Bring to the top when activating */
1804 (winpos
->flags
& SWP_NOZORDER
||
1805 (winpos
->hwndInsertAfter
!= HWND_TOPMOST
&& winpos
->hwndInsertAfter
!= HWND_NOTOPMOST
)))
1807 winpos
->flags
&= ~SWP_NOZORDER
;
1808 winpos
->hwndInsertAfter
= HWND_TOP
;
1812 /* Check hwndInsertAfter */
1813 if (winpos
->flags
& SWP_NOZORDER
) goto done
;
1815 /* fix sign extension */
1816 if (winpos
->hwndInsertAfter
== (HWND
)0xffff) winpos
->hwndInsertAfter
= HWND_TOPMOST
;
1817 else if (winpos
->hwndInsertAfter
== (HWND
)0xfffe) winpos
->hwndInsertAfter
= HWND_NOTOPMOST
;
1819 /* hwndInsertAfter must be a sibling of the window */
1820 if (winpos
->hwndInsertAfter
== HWND_TOP
)
1822 if (GetWindow(winpos
->hwnd
, GW_HWNDFIRST
) == winpos
->hwnd
)
1823 winpos
->flags
|= SWP_NOZORDER
;
1825 else if (winpos
->hwndInsertAfter
== HWND_BOTTOM
)
1827 if (!(wndPtr
->dwExStyle
& WS_EX_TOPMOST
) && GetWindow(winpos
->hwnd
, GW_HWNDLAST
) == winpos
->hwnd
)
1828 winpos
->flags
|= SWP_NOZORDER
;
1830 else if (winpos
->hwndInsertAfter
== HWND_TOPMOST
)
1832 if ((wndPtr
->dwExStyle
& WS_EX_TOPMOST
) && GetWindow(winpos
->hwnd
, GW_HWNDFIRST
) == winpos
->hwnd
)
1833 winpos
->flags
|= SWP_NOZORDER
;
1835 else if (winpos
->hwndInsertAfter
== HWND_NOTOPMOST
)
1837 if (!(wndPtr
->dwExStyle
& WS_EX_TOPMOST
))
1838 winpos
->flags
|= SWP_NOZORDER
;
1842 if (GetAncestor( winpos
->hwndInsertAfter
, GA_PARENT
) != parent
) ret
= FALSE
;
1845 /* don't need to change the Zorder of hwnd if it's already inserted
1846 * after hwndInsertAfter or when inserting hwnd after itself.
1848 if ((winpos
->hwnd
== winpos
->hwndInsertAfter
) ||
1849 (winpos
->hwnd
== GetWindow( winpos
->hwndInsertAfter
, GW_HWNDNEXT
)))
1850 winpos
->flags
|= SWP_NOZORDER
;
1854 WIN_ReleasePtr( wndPtr
);
1859 /***********************************************************************
1862 * Backend implementation of SetWindowPos.
1864 BOOL
set_window_pos( HWND hwnd
, HWND insert_after
, UINT swp_flags
,
1865 const RECT
*window_rect
, const RECT
*client_rect
, const RECT
*valid_rects
)
1869 RECT visible_rect
, old_window_rect
;
1872 if (!(win
= WIN_GetPtr( hwnd
))) return FALSE
;
1873 if (win
== WND_DESKTOP
|| win
== WND_OTHER_PROCESS
) return FALSE
;
1875 old_window_rect
= win
->rectWindow
;
1876 SERVER_START_REQ( set_window_pos
)
1879 req
->previous
= insert_after
;
1880 req
->flags
= swp_flags
;
1881 req
->window
.left
= window_rect
->left
;
1882 req
->window
.top
= window_rect
->top
;
1883 req
->window
.right
= window_rect
->right
;
1884 req
->window
.bottom
= window_rect
->bottom
;
1885 req
->client
.left
= client_rect
->left
;
1886 req
->client
.top
= client_rect
->top
;
1887 req
->client
.right
= client_rect
->right
;
1888 req
->client
.bottom
= client_rect
->bottom
;
1889 if (!IsRectEmpty( &valid_rects
[0] ))
1890 wine_server_add_data( req
, valid_rects
, 2 * sizeof(*valid_rects
) );
1891 if ((ret
= !wine_server_call( req
)))
1893 win
->dwStyle
= reply
->new_style
;
1894 win
->dwExStyle
= reply
->new_ex_style
;
1895 win
->rectWindow
= *window_rect
;
1896 win
->rectClient
= *client_rect
;
1897 visible_rect
.left
= reply
->visible
.left
;
1898 visible_rect
.top
= reply
->visible
.top
;
1899 visible_rect
.right
= reply
->visible
.right
;
1900 visible_rect
.bottom
= reply
->visible
.bottom
;
1904 new_style
= win
->dwStyle
;
1905 WIN_ReleasePtr( win
);
1909 USER_Driver
->pSetWindowPos( hwnd
, insert_after
, swp_flags
, window_rect
,
1910 client_rect
, &visible_rect
, valid_rects
);
1912 if (((swp_flags
& SWP_AGG_NOPOSCHANGE
) != SWP_AGG_NOPOSCHANGE
) ||
1913 (swp_flags
& (SWP_HIDEWINDOW
| SWP_SHOWWINDOW
| SWP_STATECHANGED
)))
1914 invalidate_dce( hwnd
, &old_window_rect
);
1920 /***********************************************************************
1923 * User32 internal function
1925 BOOL
USER_SetWindowPos( WINDOWPOS
* winpos
)
1927 RECT newWindowRect
, newClientRect
, valid_rects
[2];
1930 orig_flags
= winpos
->flags
;
1932 /* First make sure that coordinates are valid for WM_WINDOWPOSCHANGING */
1933 if (!(winpos
->flags
& SWP_NOMOVE
))
1935 if (winpos
->x
< -32768) winpos
->x
= -32768;
1936 else if (winpos
->x
> 32767) winpos
->x
= 32767;
1937 if (winpos
->y
< -32768) winpos
->y
= -32768;
1938 else if (winpos
->y
> 32767) winpos
->y
= 32767;
1940 if (!(winpos
->flags
& SWP_NOSIZE
))
1942 if (winpos
->cx
< 0) winpos
->cx
= 0;
1943 else if (winpos
->cx
> 32767) winpos
->cx
= 32767;
1944 if (winpos
->cy
< 0) winpos
->cy
= 0;
1945 else if (winpos
->cy
> 32767) winpos
->cy
= 32767;
1948 if (!SWP_DoWinPosChanging( winpos
, &newWindowRect
, &newClientRect
)) return FALSE
;
1950 /* Fix redundant flags */
1951 if (!fixup_flags( winpos
)) return FALSE
;
1953 if((winpos
->flags
& (SWP_NOZORDER
| SWP_HIDEWINDOW
| SWP_SHOWWINDOW
)) != SWP_NOZORDER
)
1955 if (GetAncestor( winpos
->hwnd
, GA_PARENT
) == GetDesktopWindow())
1956 winpos
->hwndInsertAfter
= SWP_DoOwnedPopups( winpos
->hwnd
, winpos
->hwndInsertAfter
);
1959 /* Common operations */
1961 SWP_DoNCCalcSize( winpos
, &newWindowRect
, &newClientRect
, valid_rects
);
1963 if (!set_window_pos( winpos
->hwnd
, winpos
->hwndInsertAfter
, winpos
->flags
,
1964 &newWindowRect
, &newClientRect
, valid_rects
))
1967 /* erase parent when hiding or resizing child */
1968 if (!(orig_flags
& SWP_DEFERERASE
) &&
1969 ((orig_flags
& SWP_HIDEWINDOW
) ||
1970 (!(orig_flags
& SWP_SHOWWINDOW
) &&
1971 (winpos
->flags
& SWP_AGG_STATUSFLAGS
) != SWP_AGG_NOGEOMETRYCHANGE
)))
1973 HWND parent
= GetAncestor( winpos
->hwnd
, GA_PARENT
);
1974 if (!parent
|| parent
== GetDesktopWindow()) parent
= winpos
->hwnd
;
1975 erase_now( parent
, 0 );
1978 if( winpos
->flags
& SWP_HIDEWINDOW
)
1979 HideCaret(winpos
->hwnd
);
1980 else if (winpos
->flags
& SWP_SHOWWINDOW
)
1981 ShowCaret(winpos
->hwnd
);
1983 if (!(winpos
->flags
& (SWP_NOACTIVATE
|SWP_HIDEWINDOW
)))
1985 /* child windows get WM_CHILDACTIVATE message */
1986 if ((GetWindowLongW( winpos
->hwnd
, GWL_STYLE
) & (WS_CHILD
| WS_POPUP
)) == WS_CHILD
)
1987 SendMessageW( winpos
->hwnd
, WM_CHILDACTIVATE
, 0, 0 );
1989 SetForegroundWindow( winpos
->hwnd
);
1992 /* And last, send the WM_WINDOWPOSCHANGED message */
1994 TRACE("\tstatus flags = %04x\n", winpos
->flags
& SWP_AGG_STATUSFLAGS
);
1996 if (((winpos
->flags
& SWP_AGG_STATUSFLAGS
) != SWP_AGG_NOPOSCHANGE
))
1998 /* WM_WINDOWPOSCHANGED is sent even if SWP_NOSENDCHANGING is set
1999 and always contains final window position.
2001 winpos
->x
= newWindowRect
.left
;
2002 winpos
->y
= newWindowRect
.top
;
2003 winpos
->cx
= newWindowRect
.right
- newWindowRect
.left
;
2004 winpos
->cy
= newWindowRect
.bottom
- newWindowRect
.top
;
2005 SendMessageW( winpos
->hwnd
, WM_WINDOWPOSCHANGED
, 0, (LPARAM
)winpos
);
2010 /***********************************************************************
2011 * SetWindowPos (USER32.@)
2013 BOOL WINAPI
SetWindowPos( HWND hwnd
, HWND hwndInsertAfter
,
2014 INT x
, INT y
, INT cx
, INT cy
, UINT flags
)
2018 TRACE("hwnd %p, after %p, %d,%d (%dx%d), flags %08x\n",
2019 hwnd
, hwndInsertAfter
, x
, y
, cx
, cy
, flags
);
2020 if(TRACE_ON(win
)) dump_winpos_flags(flags
);
2022 if (is_broadcast(hwnd
))
2024 SetLastError( ERROR_INVALID_PARAMETER
);
2028 winpos
.hwnd
= WIN_GetFullHandle(hwnd
);
2029 winpos
.hwndInsertAfter
= WIN_GetFullHandle(hwndInsertAfter
);
2034 winpos
.flags
= flags
;
2036 if (WIN_IsCurrentThread( hwnd
))
2037 return USER_SetWindowPos(&winpos
);
2039 return SendMessageW( winpos
.hwnd
, WM_WINE_SETWINDOWPOS
, 0, (LPARAM
)&winpos
);
2043 /***********************************************************************
2044 * BeginDeferWindowPos (USER32.@)
2046 HDWP WINAPI
BeginDeferWindowPos( INT count
)
2051 TRACE("%d\n", count
);
2055 SetLastError(ERROR_INVALID_PARAMETER
);
2058 /* Windows allows zero count, in which case it allocates context for 8 moves */
2059 if (count
== 0) count
= 8;
2061 handle
= USER_HEAP_ALLOC( sizeof(DWP
) + (count
-1)*sizeof(WINDOWPOS
) );
2062 if (!handle
) return 0;
2063 pDWP
= (DWP
*) USER_HEAP_LIN_ADDR( handle
);
2064 pDWP
->actualCount
= 0;
2065 pDWP
->suggestedCount
= count
;
2067 pDWP
->wMagic
= DWP_MAGIC
;
2068 pDWP
->hwndParent
= 0;
2070 TRACE("returning hdwp %p\n", handle
);
2075 /***********************************************************************
2076 * DeferWindowPos (USER32.@)
2078 HDWP WINAPI
DeferWindowPos( HDWP hdwp
, HWND hwnd
, HWND hwndAfter
,
2079 INT x
, INT y
, INT cx
, INT cy
,
2084 HDWP newhdwp
= hdwp
,retvalue
;
2086 TRACE("hdwp %p, hwnd %p, after %p, %d,%d (%dx%d), flags %08x\n",
2087 hdwp
, hwnd
, hwndAfter
, x
, y
, cx
, cy
, flags
);
2089 hwnd
= WIN_GetFullHandle( hwnd
);
2090 if (hwnd
== GetDesktopWindow()) return 0;
2092 if (!(pDWP
= USER_HEAP_LIN_ADDR( hdwp
))) return 0;
2096 for (i
= 0; i
< pDWP
->actualCount
; i
++)
2098 if (pDWP
->winPos
[i
].hwnd
== hwnd
)
2100 /* Merge with the other changes */
2101 if (!(flags
& SWP_NOZORDER
))
2103 pDWP
->winPos
[i
].hwndInsertAfter
= WIN_GetFullHandle(hwndAfter
);
2105 if (!(flags
& SWP_NOMOVE
))
2107 pDWP
->winPos
[i
].x
= x
;
2108 pDWP
->winPos
[i
].y
= y
;
2110 if (!(flags
& SWP_NOSIZE
))
2112 pDWP
->winPos
[i
].cx
= cx
;
2113 pDWP
->winPos
[i
].cy
= cy
;
2115 pDWP
->winPos
[i
].flags
&= flags
| ~(SWP_NOSIZE
| SWP_NOMOVE
|
2116 SWP_NOZORDER
| SWP_NOREDRAW
|
2117 SWP_NOACTIVATE
| SWP_NOCOPYBITS
|
2119 pDWP
->winPos
[i
].flags
|= flags
& (SWP_SHOWWINDOW
| SWP_HIDEWINDOW
|
2125 if (pDWP
->actualCount
>= pDWP
->suggestedCount
)
2127 newhdwp
= USER_HEAP_REALLOC( hdwp
,
2128 sizeof(DWP
) + pDWP
->suggestedCount
*sizeof(WINDOWPOS
) );
2134 pDWP
= (DWP
*) USER_HEAP_LIN_ADDR( newhdwp
);
2135 pDWP
->suggestedCount
++;
2137 pDWP
->winPos
[pDWP
->actualCount
].hwnd
= hwnd
;
2138 pDWP
->winPos
[pDWP
->actualCount
].hwndInsertAfter
= hwndAfter
;
2139 pDWP
->winPos
[pDWP
->actualCount
].x
= x
;
2140 pDWP
->winPos
[pDWP
->actualCount
].y
= y
;
2141 pDWP
->winPos
[pDWP
->actualCount
].cx
= cx
;
2142 pDWP
->winPos
[pDWP
->actualCount
].cy
= cy
;
2143 pDWP
->winPos
[pDWP
->actualCount
].flags
= flags
;
2144 pDWP
->actualCount
++;
2152 /***********************************************************************
2153 * EndDeferWindowPos (USER32.@)
2155 BOOL WINAPI
EndDeferWindowPos( HDWP hdwp
)
2162 TRACE("%p\n", hdwp
);
2164 pDWP
= (DWP
*) USER_HEAP_LIN_ADDR( hdwp
);
2165 if (!pDWP
) return FALSE
;
2166 for (i
= 0, winpos
= pDWP
->winPos
; i
< pDWP
->actualCount
; i
++, winpos
++)
2168 TRACE("hwnd %p, after %p, %d,%d (%dx%d), flags %08x\n",
2169 winpos
->hwnd
, winpos
->hwndInsertAfter
, winpos
->x
, winpos
->y
,
2170 winpos
->cx
, winpos
->cy
, winpos
->flags
);
2172 if (!(res
= USER_SetWindowPos( winpos
))) break;
2174 USER_HEAP_FREE( hdwp
);
2179 /***********************************************************************
2180 * ArrangeIconicWindows (USER32.@)
2182 UINT WINAPI
ArrangeIconicWindows( HWND parent
)
2186 INT x
, y
, xspacing
, yspacing
;
2188 GetClientRect( parent
, &rectParent
);
2189 x
= rectParent
.left
;
2190 y
= rectParent
.bottom
;
2191 xspacing
= GetSystemMetrics(SM_CXICONSPACING
);
2192 yspacing
= GetSystemMetrics(SM_CYICONSPACING
);
2194 hwndChild
= GetWindow( parent
, GW_CHILD
);
2197 if( IsIconic( hwndChild
) )
2199 WINPOS_ShowIconTitle( hwndChild
, FALSE
);
2201 SetWindowPos( hwndChild
, 0, x
+ (xspacing
- GetSystemMetrics(SM_CXICON
)) / 2,
2202 y
- yspacing
- GetSystemMetrics(SM_CYICON
)/2, 0, 0,
2203 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
2204 if( IsWindow(hwndChild
) )
2205 WINPOS_ShowIconTitle(hwndChild
, TRUE
);
2207 if (x
<= rectParent
.right
- xspacing
) x
+= xspacing
;
2210 x
= rectParent
.left
;
2214 hwndChild
= GetWindow( hwndChild
, GW_HWNDNEXT
);
2220 /***********************************************************************
2223 * Draw the frame used when moving or resizing window.
2225 static void draw_moving_frame( HDC hdc
, RECT
*rect
, BOOL thickframe
)
2229 const int width
= GetSystemMetrics(SM_CXFRAME
);
2230 const int height
= GetSystemMetrics(SM_CYFRAME
);
2232 HBRUSH hbrush
= SelectObject( hdc
, GetStockObject( GRAY_BRUSH
) );
2233 PatBlt( hdc
, rect
->left
, rect
->top
,
2234 rect
->right
- rect
->left
- width
, height
, PATINVERT
);
2235 PatBlt( hdc
, rect
->left
, rect
->top
+ height
, width
,
2236 rect
->bottom
- rect
->top
- height
, PATINVERT
);
2237 PatBlt( hdc
, rect
->left
+ width
, rect
->bottom
- 1,
2238 rect
->right
- rect
->left
- width
, -height
, PATINVERT
);
2239 PatBlt( hdc
, rect
->right
- 1, rect
->top
, -width
,
2240 rect
->bottom
- rect
->top
- height
, PATINVERT
);
2241 SelectObject( hdc
, hbrush
);
2243 else DrawFocusRect( hdc
, rect
);
2247 /***********************************************************************
2250 * Initialization of a move or resize, when initiated from a menu choice.
2251 * Return hit test code for caption or sizing border.
2253 static LONG
start_size_move( HWND hwnd
, WPARAM wParam
, POINT
*capturePoint
, LONG style
)
2260 GetWindowRect( hwnd
, &rectWindow
);
2262 if ((wParam
& 0xfff0) == SC_MOVE
)
2264 /* Move pointer at the center of the caption */
2265 RECT rect
= rectWindow
;
2266 /* Note: to be exactly centered we should take the different types
2267 * of border into account, but it shouldn't make more than a few pixels
2268 * of difference so let's not bother with that */
2269 rect
.top
+= GetSystemMetrics(SM_CYBORDER
);
2270 if (style
& WS_SYSMENU
)
2271 rect
.left
+= GetSystemMetrics(SM_CXSIZE
) + 1;
2272 if (style
& WS_MINIMIZEBOX
)
2273 rect
.right
-= GetSystemMetrics(SM_CXSIZE
) + 1;
2274 if (style
& WS_MAXIMIZEBOX
)
2275 rect
.right
-= GetSystemMetrics(SM_CXSIZE
) + 1;
2276 pt
.x
= (rect
.right
+ rect
.left
) / 2;
2277 pt
.y
= rect
.top
+ GetSystemMetrics(SM_CYSIZE
)/2;
2278 hittest
= HTCAPTION
;
2283 SetCursor( LoadCursorW( 0, (LPWSTR
)IDC_SIZEALL
) );
2287 if (!GetMessageW( &msg
, 0, 0, 0 )) return 0;
2288 if (CallMsgFilterW( &msg
, MSGF_SIZE
)) continue;
2293 pt
.x
= min( max( msg
.pt
.x
, rectWindow
.left
), rectWindow
.right
- 1 );
2294 pt
.y
= min( max( msg
.pt
.y
, rectWindow
.top
), rectWindow
.bottom
- 1 );
2295 hittest
= SendMessageW( hwnd
, WM_NCHITTEST
, 0, MAKELONG( pt
.x
, pt
.y
) );
2296 if ((hittest
< HTLEFT
) || (hittest
> HTBOTTOMRIGHT
)) hittest
= 0;
2307 pt
.x
=(rectWindow
.left
+rectWindow
.right
)/2;
2308 pt
.y
= rectWindow
.top
+ GetSystemMetrics(SM_CYFRAME
) / 2;
2312 pt
.x
=(rectWindow
.left
+rectWindow
.right
)/2;
2313 pt
.y
= rectWindow
.bottom
- GetSystemMetrics(SM_CYFRAME
) / 2;
2317 pt
.x
= rectWindow
.left
+ GetSystemMetrics(SM_CXFRAME
) / 2;
2318 pt
.y
=(rectWindow
.top
+rectWindow
.bottom
)/2;
2322 pt
.x
= rectWindow
.right
- GetSystemMetrics(SM_CXFRAME
) / 2;
2323 pt
.y
=(rectWindow
.top
+rectWindow
.bottom
)/2;
2331 TranslateMessage( &msg
);
2332 DispatchMessageW( &msg
);
2338 SetCursorPos( pt
.x
, pt
.y
);
2339 SendMessageW( hwnd
, WM_SETCURSOR
, (WPARAM
)hwnd
, MAKELONG( hittest
, WM_MOUSEMOVE
));
2344 /***********************************************************************
2345 * WINPOS_SysCommandSizeMove
2347 * Perform SC_MOVE and SC_SIZE commands.
2349 void WINPOS_SysCommandSizeMove( HWND hwnd
, WPARAM wParam
)
2352 RECT sizingRect
, mouseRect
, origRect
;
2355 LONG hittest
= (LONG
)(wParam
& 0x0f);
2356 WPARAM syscommand
= wParam
& 0xfff0;
2357 HCURSOR hDragCursor
= 0, hOldCursor
= 0;
2358 POINT minTrack
, maxTrack
;
2359 POINT capturePoint
, pt
;
2360 LONG style
= GetWindowLongW( hwnd
, GWL_STYLE
);
2361 BOOL thickframe
= HAS_THICKFRAME( style
);
2362 BOOL iconic
= style
& WS_MINIMIZE
;
2364 DWORD dwPoint
= GetMessagePos ();
2365 BOOL DragFullWindows
= TRUE
;
2367 if (IsZoomed(hwnd
) || !IsWindowVisible(hwnd
)) return;
2369 pt
.x
= (short)LOWORD(dwPoint
);
2370 pt
.y
= (short)HIWORD(dwPoint
);
2373 TRACE("hwnd %p command %04lx, hittest %d, pos %d,%d\n",
2374 hwnd
, syscommand
, hittest
, pt
.x
, pt
.y
);
2376 if (syscommand
== SC_MOVE
)
2378 if (!hittest
) hittest
= start_size_move( hwnd
, wParam
, &capturePoint
, style
);
2379 if (!hittest
) return;
2383 if ( hittest
&& (syscommand
!= SC_MOUSEMENU
) )
2384 hittest
+= (HTLEFT
- WMSZ_LEFT
);
2387 set_capture_window( hwnd
, GUI_INMOVESIZE
, NULL
);
2388 hittest
= start_size_move( hwnd
, wParam
, &capturePoint
, style
);
2391 set_capture_window( 0, GUI_INMOVESIZE
, NULL
);
2397 /* Get min/max info */
2399 WINPOS_GetMinMaxInfo( hwnd
, NULL
, NULL
, &minTrack
, &maxTrack
);
2400 GetWindowRect( hwnd
, &sizingRect
);
2401 if (style
& WS_CHILD
)
2403 parent
= GetParent(hwnd
);
2404 /* make sizing rect relative to parent */
2405 MapWindowPoints( 0, parent
, (POINT
*)&sizingRect
, 2 );
2406 GetClientRect( parent
, &mouseRect
);
2411 GetClientRect( GetDesktopWindow(), &mouseRect
);
2412 mouseRect
.left
= GetSystemMetrics( SM_XVIRTUALSCREEN
);
2413 mouseRect
.top
= GetSystemMetrics( SM_YVIRTUALSCREEN
);
2414 mouseRect
.right
= mouseRect
.left
+ GetSystemMetrics( SM_CXVIRTUALSCREEN
);
2415 mouseRect
.bottom
= mouseRect
.top
+ GetSystemMetrics( SM_CYVIRTUALSCREEN
);
2417 origRect
= sizingRect
;
2419 if (ON_LEFT_BORDER(hittest
))
2421 mouseRect
.left
= max( mouseRect
.left
, sizingRect
.right
-maxTrack
.x
);
2422 mouseRect
.right
= min( mouseRect
.right
, sizingRect
.right
-minTrack
.x
);
2424 else if (ON_RIGHT_BORDER(hittest
))
2426 mouseRect
.left
= max( mouseRect
.left
, sizingRect
.left
+minTrack
.x
);
2427 mouseRect
.right
= min( mouseRect
.right
, sizingRect
.left
+maxTrack
.x
);
2429 if (ON_TOP_BORDER(hittest
))
2431 mouseRect
.top
= max( mouseRect
.top
, sizingRect
.bottom
-maxTrack
.y
);
2432 mouseRect
.bottom
= min( mouseRect
.bottom
,sizingRect
.bottom
-minTrack
.y
);
2434 else if (ON_BOTTOM_BORDER(hittest
))
2436 mouseRect
.top
= max( mouseRect
.top
, sizingRect
.top
+minTrack
.y
);
2437 mouseRect
.bottom
= min( mouseRect
.bottom
, sizingRect
.top
+maxTrack
.y
);
2439 if (parent
) MapWindowPoints( parent
, 0, (LPPOINT
)&mouseRect
, 2 );
2441 /* Retrieve a default cache DC (without using the window style) */
2442 hdc
= GetDCEx( parent
, 0, DCX_CACHE
);
2444 if( iconic
) /* create a cursor for dragging */
2446 hDragCursor
= (HCURSOR
)GetClassLongPtrW( hwnd
, GCLP_HICON
);
2447 if( !hDragCursor
) hDragCursor
= (HCURSOR
)SendMessageW( hwnd
, WM_QUERYDRAGICON
, 0, 0L);
2448 if( !hDragCursor
) iconic
= FALSE
;
2451 /* we only allow disabling the full window drag for child windows */
2452 if (parent
) SystemParametersInfoW( SPI_GETDRAGFULLWINDOWS
, 0, &DragFullWindows
, 0 );
2454 /* repaint the window before moving it around */
2455 RedrawWindow( hwnd
, NULL
, 0, RDW_UPDATENOW
| RDW_ALLCHILDREN
);
2457 SendMessageW( hwnd
, WM_ENTERSIZEMOVE
, 0, 0 );
2458 set_capture_window( hwnd
, GUI_INMOVESIZE
, NULL
);
2464 if (!GetMessageW( &msg
, 0, 0, 0 )) break;
2465 if (CallMsgFilterW( &msg
, MSGF_SIZE
)) continue;
2467 /* Exit on button-up, Return, or Esc */
2468 if ((msg
.message
== WM_LBUTTONUP
) ||
2469 ((msg
.message
== WM_KEYDOWN
) &&
2470 ((msg
.wParam
== VK_RETURN
) || (msg
.wParam
== VK_ESCAPE
)))) break;
2472 if ((msg
.message
!= WM_KEYDOWN
) && (msg
.message
!= WM_MOUSEMOVE
))
2474 TranslateMessage( &msg
);
2475 DispatchMessageW( &msg
);
2476 continue; /* We are not interested in other messages */
2481 if (msg
.message
== WM_KEYDOWN
) switch(msg
.wParam
)
2483 case VK_UP
: pt
.y
-= 8; break;
2484 case VK_DOWN
: pt
.y
+= 8; break;
2485 case VK_LEFT
: pt
.x
-= 8; break;
2486 case VK_RIGHT
: pt
.x
+= 8; break;
2489 pt
.x
= max( pt
.x
, mouseRect
.left
);
2490 pt
.x
= min( pt
.x
, mouseRect
.right
);
2491 pt
.y
= max( pt
.y
, mouseRect
.top
);
2492 pt
.y
= min( pt
.y
, mouseRect
.bottom
);
2494 dx
= pt
.x
- capturePoint
.x
;
2495 dy
= pt
.y
- capturePoint
.y
;
2503 if( iconic
) /* ok, no system popup tracking */
2505 hOldCursor
= SetCursor(hDragCursor
);
2507 WINPOS_ShowIconTitle( hwnd
, FALSE
);
2509 else if(!DragFullWindows
)
2510 draw_moving_frame( hdc
, &sizingRect
, thickframe
);
2513 if (msg
.message
== WM_KEYDOWN
) SetCursorPos( pt
.x
, pt
.y
);
2516 RECT newRect
= sizingRect
;
2517 WPARAM wpSizingHit
= 0;
2519 if (hittest
== HTCAPTION
) OffsetRect( &newRect
, dx
, dy
);
2520 if (ON_LEFT_BORDER(hittest
)) newRect
.left
+= dx
;
2521 else if (ON_RIGHT_BORDER(hittest
)) newRect
.right
+= dx
;
2522 if (ON_TOP_BORDER(hittest
)) newRect
.top
+= dy
;
2523 else if (ON_BOTTOM_BORDER(hittest
)) newRect
.bottom
+= dy
;
2524 if(!iconic
&& !DragFullWindows
) draw_moving_frame( hdc
, &sizingRect
, thickframe
);
2527 /* determine the hit location */
2528 if (hittest
>= HTLEFT
&& hittest
<= HTBOTTOMRIGHT
)
2529 wpSizingHit
= WMSZ_LEFT
+ (hittest
- HTLEFT
);
2530 SendMessageW( hwnd
, WM_SIZING
, wpSizingHit
, (LPARAM
)&newRect
);
2534 if(!DragFullWindows
)
2535 draw_moving_frame( hdc
, &newRect
, thickframe
);
2537 SetWindowPos( hwnd
, 0, newRect
.left
, newRect
.top
,
2538 newRect
.right
- newRect
.left
,
2539 newRect
.bottom
- newRect
.top
,
2540 ( hittest
== HTCAPTION
) ? SWP_NOSIZE
: 0 );
2542 sizingRect
= newRect
;
2549 if( moved
) /* restore cursors, show icon title later on */
2551 ShowCursor( FALSE
);
2552 SetCursor( hOldCursor
);
2555 else if (moved
&& !DragFullWindows
)
2557 draw_moving_frame( hdc
, &sizingRect
, thickframe
);
2560 set_capture_window( 0, GUI_INMOVESIZE
, NULL
);
2561 ReleaseDC( parent
, hdc
);
2563 if (HOOK_CallHooks( WH_CBT
, HCBT_MOVESIZE
, (WPARAM
)hwnd
, (LPARAM
)&sizingRect
, TRUE
))
2566 SendMessageW( hwnd
, WM_EXITSIZEMOVE
, 0, 0 );
2567 SendMessageW( hwnd
, WM_SETVISIBLE
, !IsIconic(hwnd
), 0L);
2569 /* window moved or resized */
2572 /* if the moving/resizing isn't canceled call SetWindowPos
2573 * with the new position or the new size of the window
2575 if (!((msg
.message
== WM_KEYDOWN
) && (msg
.wParam
== VK_ESCAPE
)) )
2577 /* NOTE: SWP_NOACTIVATE prevents document window activation in Word 6 */
2578 if(!DragFullWindows
)
2579 SetWindowPos( hwnd
, 0, sizingRect
.left
, sizingRect
.top
,
2580 sizingRect
.right
- sizingRect
.left
,
2581 sizingRect
.bottom
- sizingRect
.top
,
2582 ( hittest
== HTCAPTION
) ? SWP_NOSIZE
: 0 );
2585 { /* restore previous size/position */
2587 SetWindowPos( hwnd
, 0, origRect
.left
, origRect
.top
,
2588 origRect
.right
- origRect
.left
,
2589 origRect
.bottom
- origRect
.top
,
2590 ( hittest
== HTCAPTION
) ? SWP_NOSIZE
: 0 );
2596 /* Single click brings up the system menu when iconized */
2600 if(style
& WS_SYSMENU
)
2601 SendMessageW( hwnd
, WM_SYSCOMMAND
,
2602 SC_MOUSEMENU
+ HTSYSMENU
, MAKELONG(pt
.x
,pt
.y
));
2604 else WINPOS_ShowIconTitle( hwnd
, TRUE
);