Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Window position related functions. |
| 3 | * |
Alexandre Julliard | 22945d5 | 1995-03-02 17:44:29 +0000 | [diff] [blame] | 4 | * Copyright 1993, 1994, 1995 Alexandre Julliard |
Alex Korobka | 4f1ac05 | 1999-03-28 09:37:57 +0000 | [diff] [blame] | 5 | * 1995, 1996, 1999 Alex Korobka |
Alexandre Julliard | 0799c1a | 2002-03-09 23:29:33 +0000 | [diff] [blame] | 6 | * |
| 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. |
| 11 | * |
| 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. |
| 16 | * |
| 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 20 | */ |
| 21 | |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 22 | #include <string.h> |
Francois Jacques | 5b6879c | 2000-07-28 23:04:54 +0000 | [diff] [blame] | 23 | #include "winerror.h" |
Jeremy White | d3e22d9 | 2000-02-10 19:03:02 +0000 | [diff] [blame] | 24 | #include "windef.h" |
| 25 | #include "wingdi.h" |
Slava Monich | cdbe644 | 2000-07-08 12:44:09 +0000 | [diff] [blame] | 26 | #include "winerror.h" |
Michael Veksler | 9d14a00 | 1999-05-08 12:40:24 +0000 | [diff] [blame] | 27 | #include "wine/winuser16.h" |
Alexandre Julliard | fb0ff05 | 2001-10-16 21:58:58 +0000 | [diff] [blame] | 28 | #include "wine/server.h" |
Alexandre Julliard | 91222da | 2000-12-10 23:01:33 +0000 | [diff] [blame] | 29 | #include "controls.h" |
Alexandre Julliard | dba420a | 1994-02-02 06:48:31 +0000 | [diff] [blame] | 30 | #include "user.h" |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 31 | #include "win.h" |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 32 | #include "message.h" |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 33 | #include "winpos.h" |
Alexandre Julliard | 22945d5 | 1995-03-02 17:44:29 +0000 | [diff] [blame] | 34 | #include "nonclient.h" |
Alexandre Julliard | 0799c1a | 2002-03-09 23:29:33 +0000 | [diff] [blame] | 35 | #include "wine/debug.h" |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 36 | |
Alexandre Julliard | 0799c1a | 2002-03-09 23:29:33 +0000 | [diff] [blame] | 37 | WINE_DEFAULT_DEBUG_CHANNEL(win); |
Patrik Stridvall | b4b9fae | 1999-04-19 14:56:29 +0000 | [diff] [blame] | 38 | |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 39 | #define HAS_DLGFRAME(style,exStyle) \ |
| 40 | (((exStyle) & WS_EX_DLGMODALFRAME) || \ |
| 41 | (((style) & WS_DLGFRAME) && !((style) & WS_BORDER))) |
| 42 | |
| 43 | #define HAS_THICKFRAME(style) \ |
| 44 | (((style) & WS_THICKFRAME) && \ |
| 45 | !(((style) & (WS_DLGFRAME|WS_BORDER)) == WS_DLGFRAME)) |
| 46 | |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 47 | #define EMPTYPOINT(pt) ((*(LONG*)&(pt)) == -1) |
| 48 | |
| 49 | #define PLACE_MIN 0x0001 |
| 50 | #define PLACE_MAX 0x0002 |
| 51 | #define PLACE_RECT 0x0004 |
| 52 | |
Alexandre Julliard | 9ae0fe5 | 2001-04-24 23:28:52 +0000 | [diff] [blame] | 53 | |
| 54 | #define DWP_MAGIC ((INT)('W' | ('P' << 8) | ('O' << 16) | ('S' << 24))) |
| 55 | |
| 56 | typedef struct |
| 57 | { |
| 58 | INT actualCount; |
| 59 | INT suggestedCount; |
| 60 | BOOL valid; |
| 61 | INT wMagic; |
| 62 | HWND hwndParent; |
| 63 | WINDOWPOS winPos[1]; |
| 64 | } DWP; |
| 65 | |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 66 | /* ----- internal variables ----- */ |
| 67 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 68 | static HWND hGlobalShellWindow=0; /*the shell*/ |
Juergen Schmied | ddb2e29 | 1999-05-02 09:19:19 +0000 | [diff] [blame] | 69 | static HWND hGlobalTaskmanWindow=0; |
| 70 | static HWND hGlobalProgmanWindow=0; |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 71 | |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 72 | static LPCSTR atomInternalPos; |
| 73 | |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 74 | |
| 75 | /*********************************************************************** |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 76 | * WINPOS_CreateInternalPosAtom |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 77 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 78 | BOOL WINPOS_CreateInternalPosAtom() |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 79 | { |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 80 | LPSTR str = "SysIP"; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 81 | atomInternalPos = (LPCSTR)(DWORD)GlobalAddAtomA(str); |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 82 | return (atomInternalPos) ? TRUE : FALSE; |
| 83 | } |
| 84 | |
| 85 | /*********************************************************************** |
| 86 | * WINPOS_CheckInternalPos |
| 87 | * |
| 88 | * Called when a window is destroyed. |
| 89 | */ |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 90 | void WINPOS_CheckInternalPos( HWND hwnd ) |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 91 | { |
Alexandre Julliard | 5030bda | 2002-10-11 23:41:06 +0000 | [diff] [blame] | 92 | LPINTERNALPOS lpPos = (LPINTERNALPOS) GetPropA( hwnd, atomInternalPos ); |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 93 | |
| 94 | if( lpPos ) |
| 95 | { |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 96 | if( IsWindow(lpPos->hwndIconTitle) ) |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 97 | DestroyWindow( lpPos->hwndIconTitle ); |
Alexandre Julliard | da2892c | 2001-02-23 01:13:42 +0000 | [diff] [blame] | 98 | HeapFree( GetProcessHeap(), 0, lpPos ); |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 99 | } |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 100 | } |
| 101 | |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 102 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 103 | * ArrangeIconicWindows (USER32.@) |
Alexandre Julliard | 22945d5 | 1995-03-02 17:44:29 +0000 | [diff] [blame] | 104 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 105 | UINT WINAPI ArrangeIconicWindows( HWND parent ) |
Alexandre Julliard | 22945d5 | 1995-03-02 17:44:29 +0000 | [diff] [blame] | 106 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 107 | RECT rectParent; |
| 108 | HWND hwndChild; |
| 109 | INT x, y, xspacing, yspacing; |
Alexandre Julliard | 22945d5 | 1995-03-02 17:44:29 +0000 | [diff] [blame] | 110 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 111 | GetClientRect( parent, &rectParent ); |
Alexandre Julliard | 22945d5 | 1995-03-02 17:44:29 +0000 | [diff] [blame] | 112 | x = rectParent.left; |
| 113 | y = rectParent.bottom; |
Marcus Meissner | ddca315 | 1999-05-22 11:33:23 +0000 | [diff] [blame] | 114 | xspacing = GetSystemMetrics(SM_CXICONSPACING); |
| 115 | yspacing = GetSystemMetrics(SM_CYICONSPACING); |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 116 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 117 | hwndChild = GetWindow( parent, GW_CHILD ); |
Alexandre Julliard | 22945d5 | 1995-03-02 17:44:29 +0000 | [diff] [blame] | 118 | while (hwndChild) |
| 119 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 120 | if( IsIconic( hwndChild ) ) |
Alexandre Julliard | 22945d5 | 1995-03-02 17:44:29 +0000 | [diff] [blame] | 121 | { |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 122 | WINPOS_ShowIconTitle( hwndChild, FALSE ); |
| 123 | |
Marcus Meissner | ddca315 | 1999-05-22 11:33:23 +0000 | [diff] [blame] | 124 | SetWindowPos( hwndChild, 0, x + (xspacing - GetSystemMetrics(SM_CXICON)) / 2, |
| 125 | y - yspacing - GetSystemMetrics(SM_CYICON)/2, 0, 0, |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 126 | SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE ); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 127 | if( IsWindow(hwndChild) ) |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 128 | WINPOS_ShowIconTitle(hwndChild , TRUE ); |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 129 | |
Alexandre Julliard | 22945d5 | 1995-03-02 17:44:29 +0000 | [diff] [blame] | 130 | if (x <= rectParent.right - xspacing) x += xspacing; |
| 131 | else |
| 132 | { |
| 133 | x = rectParent.left; |
| 134 | y -= yspacing; |
| 135 | } |
| 136 | } |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 137 | hwndChild = GetWindow( hwndChild, GW_HWNDNEXT ); |
Alexandre Julliard | 22945d5 | 1995-03-02 17:44:29 +0000 | [diff] [blame] | 138 | } |
| 139 | return yspacing; |
| 140 | } |
| 141 | |
| 142 | |
| 143 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 144 | * SwitchToThisWindow (USER32.@) |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 145 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 146 | void WINAPI SwitchToThisWindow( HWND hwnd, BOOL restore ) |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 147 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 148 | ShowWindow( hwnd, restore ? SW_RESTORE : SW_SHOWMINIMIZED ); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 149 | } |
| 150 | |
| 151 | |
| 152 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 153 | * GetWindowRect (USER32.@) |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 154 | */ |
Alexandre Julliard | fb0ff05 | 2001-10-16 21:58:58 +0000 | [diff] [blame] | 155 | BOOL WINAPI GetWindowRect( HWND hwnd, LPRECT rect ) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 156 | { |
Alexandre Julliard | 5797fbb | 2001-12-06 22:33:58 +0000 | [diff] [blame] | 157 | BOOL ret = WIN_GetRectangles( hwnd, rect, NULL ); |
Alexandre Julliard | fb0ff05 | 2001-10-16 21:58:58 +0000 | [diff] [blame] | 158 | if (ret) |
| 159 | { |
| 160 | MapWindowPoints( GetAncestor( hwnd, GA_PARENT ), 0, (POINT *)rect, 2 ); |
Dan Kegel | 0fd521f | 2003-01-08 21:09:25 +0000 | [diff] [blame] | 161 | TRACE( "hwnd %p (%ld,%ld)-(%ld,%ld)\n", |
Alexandre Julliard | fb0ff05 | 2001-10-16 21:58:58 +0000 | [diff] [blame] | 162 | hwnd, rect->left, rect->top, rect->right, rect->bottom); |
| 163 | } |
| 164 | return ret; |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 165 | } |
| 166 | |
| 167 | |
| 168 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 169 | * GetWindowRgn (USER32.@) |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 170 | */ |
Francois Jacques | 5b6879c | 2000-07-28 23:04:54 +0000 | [diff] [blame] | 171 | int WINAPI GetWindowRgn ( HWND hwnd, HRGN hrgn ) |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 172 | { |
Francois Jacques | 5b6879c | 2000-07-28 23:04:54 +0000 | [diff] [blame] | 173 | int nRet = ERROR; |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 174 | WND *wndPtr = WIN_GetPtr( hwnd ); |
| 175 | |
| 176 | if (wndPtr == WND_OTHER_PROCESS) |
Francois Jacques | 5b6879c | 2000-07-28 23:04:54 +0000 | [diff] [blame] | 177 | { |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 178 | if (IsWindow( hwnd )) |
Alexandre Julliard | aff7dda | 2002-11-22 21:22:14 +0000 | [diff] [blame] | 179 | FIXME( "not supported on other process window %p\n", hwnd ); |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 180 | wndPtr = NULL; |
Francois Jacques | 5b6879c | 2000-07-28 23:04:54 +0000 | [diff] [blame] | 181 | } |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 182 | if (!wndPtr) |
| 183 | { |
| 184 | SetLastError( ERROR_INVALID_WINDOW_HANDLE ); |
| 185 | return ERROR; |
| 186 | } |
| 187 | if (wndPtr->hrgnWnd) nRet = CombineRgn( hrgn, wndPtr->hrgnWnd, 0, RGN_COPY ); |
| 188 | WIN_ReleasePtr( wndPtr ); |
Francois Jacques | 5b6879c | 2000-07-28 23:04:54 +0000 | [diff] [blame] | 189 | return nRet; |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 190 | } |
| 191 | |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 192 | |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 193 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 194 | * SetWindowRgn (USER32.@) |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 195 | */ |
Francois Jacques | 5b6879c | 2000-07-28 23:04:54 +0000 | [diff] [blame] | 196 | int WINAPI SetWindowRgn( HWND hwnd, HRGN hrgn, BOOL bRedraw ) |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 197 | { |
Alexandre Julliard | 9ae0fe5 | 2001-04-24 23:28:52 +0000 | [diff] [blame] | 198 | RECT rect; |
| 199 | WND *wndPtr; |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 200 | |
| 201 | if (hrgn) /* verify that region really exists */ |
| 202 | { |
| 203 | if (GetRgnBox( hrgn, &rect ) == ERROR) return FALSE; |
| 204 | } |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 205 | |
Alexandre Julliard | 9ae0fe5 | 2001-04-24 23:28:52 +0000 | [diff] [blame] | 206 | if (USER_Driver.pSetWindowRgn) |
| 207 | return USER_Driver.pSetWindowRgn( hwnd, hrgn, bRedraw ); |
Francois Jacques | 5b6879c | 2000-07-28 23:04:54 +0000 | [diff] [blame] | 208 | |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 209 | if ((wndPtr = WIN_GetPtr( hwnd )) == WND_OTHER_PROCESS) |
| 210 | { |
| 211 | if (IsWindow( hwnd )) |
Alexandre Julliard | aff7dda | 2002-11-22 21:22:14 +0000 | [diff] [blame] | 212 | FIXME( "not supported on other process window %p\n", hwnd ); |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 213 | wndPtr = NULL; |
| 214 | } |
| 215 | if (!wndPtr) |
| 216 | { |
| 217 | SetLastError( ERROR_INVALID_WINDOW_HANDLE ); |
| 218 | return FALSE; |
| 219 | } |
Francois Jacques | 5b6879c | 2000-07-28 23:04:54 +0000 | [diff] [blame] | 220 | |
Alexandre Julliard | 9ae0fe5 | 2001-04-24 23:28:52 +0000 | [diff] [blame] | 221 | if (wndPtr->hrgnWnd == hrgn) |
Francois Jacques | 5b6879c | 2000-07-28 23:04:54 +0000 | [diff] [blame] | 222 | { |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 223 | WIN_ReleasePtr( wndPtr ); |
| 224 | return TRUE; |
Francois Jacques | 5b6879c | 2000-07-28 23:04:54 +0000 | [diff] [blame] | 225 | } |
| 226 | |
James Hatheway | 3489997 | 2000-09-12 23:59:57 +0000 | [diff] [blame] | 227 | if (wndPtr->hrgnWnd) |
| 228 | { |
| 229 | /* delete previous region */ |
| 230 | DeleteObject(wndPtr->hrgnWnd); |
| 231 | wndPtr->hrgnWnd = 0; |
| 232 | } |
James Hatheway | 3489997 | 2000-09-12 23:59:57 +0000 | [diff] [blame] | 233 | wndPtr->hrgnWnd = hrgn; |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 234 | WIN_ReleasePtr( wndPtr ); |
Francois Jacques | 5b6879c | 2000-07-28 23:04:54 +0000 | [diff] [blame] | 235 | |
Alexandre Julliard | 9ae0fe5 | 2001-04-24 23:28:52 +0000 | [diff] [blame] | 236 | /* Size the window to the rectangle of the new region (if it isn't NULL) */ |
| 237 | if (hrgn) SetWindowPos( hwnd, 0, rect.left, rect.top, |
| 238 | rect.right - rect.left, rect.bottom - rect.top, |
| 239 | SWP_NOSIZE | SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOACTIVATE | |
| 240 | SWP_NOZORDER | (bRedraw ? 0 : SWP_NOREDRAW) ); |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 241 | return TRUE; |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 242 | } |
| 243 | |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 244 | |
| 245 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 246 | * GetClientRect (USER32.@) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 247 | */ |
Alexandre Julliard | fb0ff05 | 2001-10-16 21:58:58 +0000 | [diff] [blame] | 248 | BOOL WINAPI GetClientRect( HWND hwnd, LPRECT rect ) |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 249 | { |
Alexandre Julliard | fb0ff05 | 2001-10-16 21:58:58 +0000 | [diff] [blame] | 250 | BOOL ret; |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 251 | |
Alexandre Julliard | 5797fbb | 2001-12-06 22:33:58 +0000 | [diff] [blame] | 252 | rect->right = rect->bottom = 0; |
| 253 | if ((ret = WIN_GetRectangles( hwnd, NULL, rect ))) |
Alexandre Julliard | fb0ff05 | 2001-10-16 21:58:58 +0000 | [diff] [blame] | 254 | { |
Alexandre Julliard | 5797fbb | 2001-12-06 22:33:58 +0000 | [diff] [blame] | 255 | rect->right -= rect->left; |
| 256 | rect->bottom -= rect->top; |
Alexandre Julliard | fb0ff05 | 2001-10-16 21:58:58 +0000 | [diff] [blame] | 257 | } |
Alexandre Julliard | 5797fbb | 2001-12-06 22:33:58 +0000 | [diff] [blame] | 258 | rect->left = rect->top = 0; |
Alexandre Julliard | fb0ff05 | 2001-10-16 21:58:58 +0000 | [diff] [blame] | 259 | return ret; |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 260 | } |
| 261 | |
| 262 | |
| 263 | /******************************************************************* |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 264 | * ClientToScreen (USER32.@) |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 265 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 266 | BOOL WINAPI ClientToScreen( HWND hwnd, LPPOINT lppnt ) |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 267 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 268 | MapWindowPoints( hwnd, 0, lppnt, 1 ); |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 269 | return TRUE; |
| 270 | } |
| 271 | |
| 272 | |
| 273 | /******************************************************************* |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 274 | * ScreenToClient (USER32.@) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 275 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 276 | BOOL WINAPI ScreenToClient( HWND hwnd, LPPOINT lppnt ) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 277 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 278 | MapWindowPoints( 0, hwnd, lppnt, 1 ); |
Eric Pouech | b9544f1 | 1999-02-14 14:09:42 +0000 | [diff] [blame] | 279 | return TRUE; |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 280 | } |
| 281 | |
| 282 | |
Alexandre Julliard | 0c126c7 | 1996-02-18 18:44:41 +0000 | [diff] [blame] | 283 | /*********************************************************************** |
Alexandre Julliard | 80593bf | 2001-10-11 20:49:40 +0000 | [diff] [blame] | 284 | * find_child_from_point |
| 285 | * |
| 286 | * Find the child that contains pt. Helper for WindowFromPoint. |
| 287 | * pt is in parent client coordinates. |
| 288 | * lparam is the param to pass in the WM_NCHITTEST message. |
| 289 | */ |
| 290 | static HWND find_child_from_point( HWND parent, POINT pt, INT *hittest, LPARAM lparam ) |
| 291 | { |
| 292 | int i, res; |
Alexandre Julliard | 5797fbb | 2001-12-06 22:33:58 +0000 | [diff] [blame] | 293 | LONG style, exstyle; |
| 294 | RECT rectWindow, rectClient; |
Alexandre Julliard | 80593bf | 2001-10-11 20:49:40 +0000 | [diff] [blame] | 295 | WND *wndPtr; |
| 296 | HWND *list = WIN_ListChildren( parent ); |
Andreas Mohr | 284bcfc | 2002-05-28 22:47:01 +0000 | [diff] [blame] | 297 | HWND retvalue = 0; |
Alexandre Julliard | 80593bf | 2001-10-11 20:49:40 +0000 | [diff] [blame] | 298 | |
| 299 | if (!list) return 0; |
| 300 | for (i = 0; list[i]; i++) |
| 301 | { |
Alexandre Julliard | 80593bf | 2001-10-11 20:49:40 +0000 | [diff] [blame] | 302 | /* If point is in window, and window is visible, and it */ |
| 303 | /* is enabled (or it's a top-level window), then explore */ |
| 304 | /* its children. Otherwise, go to the next window. */ |
| 305 | |
Alexandre Julliard | 5797fbb | 2001-12-06 22:33:58 +0000 | [diff] [blame] | 306 | style = GetWindowLongW( list[i], GWL_STYLE ); |
| 307 | if (!(style & WS_VISIBLE)) continue; /* not visible -> skip */ |
| 308 | if ((style & (WS_POPUP | WS_CHILD | WS_DISABLED)) == (WS_CHILD | WS_DISABLED)) |
| 309 | continue; /* disabled child -> skip */ |
| 310 | exstyle = GetWindowLongW( list[i], GWL_EXSTYLE ); |
| 311 | if ((exstyle & (WS_EX_LAYERED | WS_EX_TRANSPARENT)) == (WS_EX_LAYERED | WS_EX_TRANSPARENT)) |
| 312 | continue; /* transparent -> skip */ |
| 313 | |
| 314 | if (!WIN_GetRectangles( list[i], &rectWindow, &rectClient )) continue; |
| 315 | if (!PtInRect( &rectWindow, pt )) continue; /* not in window -> skip */ |
| 316 | |
| 317 | /* FIXME: check window region for other processes too */ |
| 318 | if ((wndPtr = WIN_GetPtr( list[i] )) && wndPtr != WND_OTHER_PROCESS) |
Alexandre Julliard | 80593bf | 2001-10-11 20:49:40 +0000 | [diff] [blame] | 319 | { |
Alexandre Julliard | 5797fbb | 2001-12-06 22:33:58 +0000 | [diff] [blame] | 320 | if (wndPtr->hrgnWnd && !PtInRegion( wndPtr->hrgnWnd, |
| 321 | pt.x - rectWindow.left, pt.y - rectWindow.top )) |
| 322 | { |
| 323 | WIN_ReleasePtr( wndPtr ); |
| 324 | continue; /* point outside window region -> skip */ |
| 325 | } |
| 326 | WIN_ReleasePtr( wndPtr ); |
Alexandre Julliard | 80593bf | 2001-10-11 20:49:40 +0000 | [diff] [blame] | 327 | } |
Alexandre Julliard | 80593bf | 2001-10-11 20:49:40 +0000 | [diff] [blame] | 328 | |
Alexandre Julliard | 80593bf | 2001-10-11 20:49:40 +0000 | [diff] [blame] | 329 | /* If window is minimized or disabled, return at once */ |
Alexandre Julliard | 5797fbb | 2001-12-06 22:33:58 +0000 | [diff] [blame] | 330 | if (style & WS_MINIMIZE) |
Alexandre Julliard | 80593bf | 2001-10-11 20:49:40 +0000 | [diff] [blame] | 331 | { |
Alexandre Julliard | 80593bf | 2001-10-11 20:49:40 +0000 | [diff] [blame] | 332 | *hittest = HTCAPTION; |
Andreas Mohr | 284bcfc | 2002-05-28 22:47:01 +0000 | [diff] [blame] | 333 | retvalue = list[i]; |
| 334 | break; |
Alexandre Julliard | 80593bf | 2001-10-11 20:49:40 +0000 | [diff] [blame] | 335 | } |
Alexandre Julliard | 5797fbb | 2001-12-06 22:33:58 +0000 | [diff] [blame] | 336 | if (style & WS_DISABLED) |
Alexandre Julliard | 80593bf | 2001-10-11 20:49:40 +0000 | [diff] [blame] | 337 | { |
Alexandre Julliard | 80593bf | 2001-10-11 20:49:40 +0000 | [diff] [blame] | 338 | *hittest = HTERROR; |
Andreas Mohr | 284bcfc | 2002-05-28 22:47:01 +0000 | [diff] [blame] | 339 | retvalue = list[i]; |
| 340 | break; |
Alexandre Julliard | 80593bf | 2001-10-11 20:49:40 +0000 | [diff] [blame] | 341 | } |
| 342 | |
| 343 | /* If point is in client area, explore children */ |
Alexandre Julliard | 5797fbb | 2001-12-06 22:33:58 +0000 | [diff] [blame] | 344 | if (PtInRect( &rectClient, pt )) |
Alexandre Julliard | 80593bf | 2001-10-11 20:49:40 +0000 | [diff] [blame] | 345 | { |
| 346 | POINT new_pt; |
Alexandre Julliard | 80593bf | 2001-10-11 20:49:40 +0000 | [diff] [blame] | 347 | |
Alexandre Julliard | 5797fbb | 2001-12-06 22:33:58 +0000 | [diff] [blame] | 348 | new_pt.x = pt.x - rectClient.left; |
| 349 | new_pt.y = pt.y - rectClient.top; |
Andreas Mohr | 284bcfc | 2002-05-28 22:47:01 +0000 | [diff] [blame] | 350 | if ((retvalue = find_child_from_point( list[i], new_pt, hittest, lparam ))) break; |
Alexandre Julliard | 80593bf | 2001-10-11 20:49:40 +0000 | [diff] [blame] | 351 | } |
Alexandre Julliard | 80593bf | 2001-10-11 20:49:40 +0000 | [diff] [blame] | 352 | |
| 353 | /* Now it's inside window, send WM_NCCHITTEST (if same thread) */ |
| 354 | if (!WIN_IsCurrentThread( list[i] )) |
| 355 | { |
| 356 | *hittest = HTCLIENT; |
Andreas Mohr | 284bcfc | 2002-05-28 22:47:01 +0000 | [diff] [blame] | 357 | retvalue = list[i]; |
| 358 | break; |
Alexandre Julliard | 80593bf | 2001-10-11 20:49:40 +0000 | [diff] [blame] | 359 | } |
| 360 | if ((res = SendMessageA( list[i], WM_NCHITTEST, 0, lparam )) != HTTRANSPARENT) |
| 361 | { |
| 362 | *hittest = res; /* Found the window */ |
Andreas Mohr | 284bcfc | 2002-05-28 22:47:01 +0000 | [diff] [blame] | 363 | retvalue = list[i]; |
| 364 | break; |
Alexandre Julliard | 80593bf | 2001-10-11 20:49:40 +0000 | [diff] [blame] | 365 | } |
Alexandre Julliard | 5797fbb | 2001-12-06 22:33:58 +0000 | [diff] [blame] | 366 | /* continue search with next sibling */ |
Alexandre Julliard | 80593bf | 2001-10-11 20:49:40 +0000 | [diff] [blame] | 367 | } |
Andreas Mohr | 284bcfc | 2002-05-28 22:47:01 +0000 | [diff] [blame] | 368 | HeapFree( GetProcessHeap(), 0, list ); |
| 369 | return retvalue; |
Alexandre Julliard | 80593bf | 2001-10-11 20:49:40 +0000 | [diff] [blame] | 370 | } |
| 371 | |
| 372 | |
| 373 | /*********************************************************************** |
Alexandre Julliard | 0c126c7 | 1996-02-18 18:44:41 +0000 | [diff] [blame] | 374 | * WINPOS_WindowFromPoint |
Alexandre Julliard | 7e56f68 | 1996-01-31 19:02:28 +0000 | [diff] [blame] | 375 | * |
Alexandre Julliard | 0c126c7 | 1996-02-18 18:44:41 +0000 | [diff] [blame] | 376 | * Find the window and hittest for a given point. |
Alexandre Julliard | 7e56f68 | 1996-01-31 19:02:28 +0000 | [diff] [blame] | 377 | */ |
Alexandre Julliard | ee8ab7a | 2001-06-20 23:16:34 +0000 | [diff] [blame] | 378 | HWND WINPOS_WindowFromPoint( HWND hwndScope, POINT pt, INT *hittest ) |
Alexandre Julliard | 7e56f68 | 1996-01-31 19:02:28 +0000 | [diff] [blame] | 379 | { |
Alexandre Julliard | 5db8d2f | 2001-05-22 19:55:20 +0000 | [diff] [blame] | 380 | POINT xy = pt; |
Alexandre Julliard | 80593bf | 2001-10-11 20:49:40 +0000 | [diff] [blame] | 381 | int res; |
Alexandre Julliard | 5797fbb | 2001-12-06 22:33:58 +0000 | [diff] [blame] | 382 | LONG style; |
Alexandre Julliard | 7e56f68 | 1996-01-31 19:02:28 +0000 | [diff] [blame] | 383 | |
Alexandre Julliard | aff7dda | 2002-11-22 21:22:14 +0000 | [diff] [blame] | 384 | TRACE("scope %p %ld,%ld\n", hwndScope, pt.x, pt.y); |
Alexandre Julliard | ee8ab7a | 2001-06-20 23:16:34 +0000 | [diff] [blame] | 385 | |
| 386 | if (!hwndScope) hwndScope = GetDesktopWindow(); |
Alexandre Julliard | 5797fbb | 2001-12-06 22:33:58 +0000 | [diff] [blame] | 387 | style = GetWindowLongW( hwndScope, GWL_STYLE ); |
Alexandre Julliard | ee8ab7a | 2001-06-20 23:16:34 +0000 | [diff] [blame] | 388 | |
| 389 | *hittest = HTERROR; |
Alexandre Julliard | 5797fbb | 2001-12-06 22:33:58 +0000 | [diff] [blame] | 390 | if (style & WS_DISABLED) return 0; |
| 391 | |
| 392 | MapWindowPoints( GetDesktopWindow(), GetAncestor( hwndScope, GA_PARENT ), &xy, 1 ); |
| 393 | |
| 394 | if (!(style & WS_MINIMIZE)) |
Susan Farley | b3f8a63 | 2000-07-08 18:28:25 +0000 | [diff] [blame] | 395 | { |
Alexandre Julliard | 5797fbb | 2001-12-06 22:33:58 +0000 | [diff] [blame] | 396 | RECT rectClient; |
| 397 | if (WIN_GetRectangles( hwndScope, NULL, &rectClient ) && PtInRect( &rectClient, xy )) |
Alexandre Julliard | fb0ff05 | 2001-10-16 21:58:58 +0000 | [diff] [blame] | 398 | { |
Alexandre Julliard | 5797fbb | 2001-12-06 22:33:58 +0000 | [diff] [blame] | 399 | HWND ret; |
| 400 | |
| 401 | xy.x -= rectClient.left; |
| 402 | xy.y -= rectClient.top; |
| 403 | if ((ret = find_child_from_point( hwndScope, xy, hittest, MAKELONG( pt.x, pt.y ) ))) |
| 404 | { |
Alexandre Julliard | aff7dda | 2002-11-22 21:22:14 +0000 | [diff] [blame] | 405 | TRACE( "found child %p\n", ret ); |
Alexandre Julliard | 5797fbb | 2001-12-06 22:33:58 +0000 | [diff] [blame] | 406 | return ret; |
| 407 | } |
Alexandre Julliard | fb0ff05 | 2001-10-16 21:58:58 +0000 | [diff] [blame] | 408 | } |
Alexandre Julliard | 0c126c7 | 1996-02-18 18:44:41 +0000 | [diff] [blame] | 409 | } |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 410 | |
Alexandre Julliard | 80593bf | 2001-10-11 20:49:40 +0000 | [diff] [blame] | 411 | /* If nothing found, try the scope window */ |
| 412 | if (!WIN_IsCurrentThread( hwndScope )) |
| 413 | { |
| 414 | *hittest = HTCLIENT; |
Alexandre Julliard | aff7dda | 2002-11-22 21:22:14 +0000 | [diff] [blame] | 415 | TRACE( "returning %p\n", hwndScope ); |
Alexandre Julliard | 80593bf | 2001-10-11 20:49:40 +0000 | [diff] [blame] | 416 | return hwndScope; |
| 417 | } |
| 418 | res = SendMessageA( hwndScope, WM_NCHITTEST, 0, MAKELONG( pt.x, pt.y ) ); |
| 419 | if (res != HTTRANSPARENT) |
| 420 | { |
| 421 | *hittest = res; /* Found the window */ |
Alexandre Julliard | aff7dda | 2002-11-22 21:22:14 +0000 | [diff] [blame] | 422 | TRACE( "returning %p\n", hwndScope ); |
Alexandre Julliard | 80593bf | 2001-10-11 20:49:40 +0000 | [diff] [blame] | 423 | return hwndScope; |
| 424 | } |
| 425 | *hittest = HTNOWHERE; |
Alexandre Julliard | fb0ff05 | 2001-10-16 21:58:58 +0000 | [diff] [blame] | 426 | TRACE( "nothing found\n" ); |
Alexandre Julliard | 80593bf | 2001-10-11 20:49:40 +0000 | [diff] [blame] | 427 | return 0; |
Alexandre Julliard | 7e56f68 | 1996-01-31 19:02:28 +0000 | [diff] [blame] | 428 | } |
| 429 | |
| 430 | |
| 431 | /******************************************************************* |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 432 | * WindowFromPoint (USER32.@) |
Alexandre Julliard | 86a8d0f | 1994-01-18 23:04:40 +0000 | [diff] [blame] | 433 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 434 | HWND WINAPI WindowFromPoint( POINT pt ) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 435 | { |
Alexandre Julliard | ee8ab7a | 2001-06-20 23:16:34 +0000 | [diff] [blame] | 436 | INT hittest; |
| 437 | return WINPOS_WindowFromPoint( 0, pt, &hittest ); |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 438 | } |
| 439 | |
| 440 | |
| 441 | /******************************************************************* |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 442 | * ChildWindowFromPoint (USER32.@) |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 443 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 444 | HWND WINAPI ChildWindowFromPoint( HWND hwndParent, POINT pt ) |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 445 | { |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 446 | return ChildWindowFromPointEx( hwndParent, pt, CWP_ALL ); |
Alexandre Julliard | 86a8d0f | 1994-01-18 23:04:40 +0000 | [diff] [blame] | 447 | } |
| 448 | |
Paul Quinn | eede6b0 | 1998-11-30 13:15:36 +0000 | [diff] [blame] | 449 | /******************************************************************* |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 450 | * ChildWindowFromPointEx (USER32.@) |
Paul Quinn | eede6b0 | 1998-11-30 13:15:36 +0000 | [diff] [blame] | 451 | */ |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 452 | HWND WINAPI ChildWindowFromPointEx( HWND hwndParent, POINT pt, UINT uFlags) |
Paul Quinn | eede6b0 | 1998-11-30 13:15:36 +0000 | [diff] [blame] | 453 | { |
| 454 | /* pt is in the client coordinates */ |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 455 | HWND *list; |
| 456 | int i; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 457 | RECT rect; |
Alexandre Julliard | 5797fbb | 2001-12-06 22:33:58 +0000 | [diff] [blame] | 458 | HWND retvalue; |
Paul Quinn | eede6b0 | 1998-11-30 13:15:36 +0000 | [diff] [blame] | 459 | |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 460 | GetClientRect( hwndParent, &rect ); |
| 461 | if (!PtInRect( &rect, pt )) return 0; |
Alexandre Julliard | 9d9dac0 | 2001-08-24 19:28:21 +0000 | [diff] [blame] | 462 | if (!(list = WIN_ListChildren( hwndParent ))) return 0; |
Paul Quinn | eede6b0 | 1998-11-30 13:15:36 +0000 | [diff] [blame] | 463 | |
Alexandre Julliard | 5797fbb | 2001-12-06 22:33:58 +0000 | [diff] [blame] | 464 | for (i = 0; list[i]; i++) |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 465 | { |
Alexandre Julliard | 5797fbb | 2001-12-06 22:33:58 +0000 | [diff] [blame] | 466 | if (!WIN_GetRectangles( list[i], &rect, NULL )) continue; |
| 467 | if (!PtInRect( &rect, pt )) continue; |
| 468 | if (uFlags & (CWP_SKIPINVISIBLE|CWP_SKIPDISABLED)) |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 469 | { |
Alexandre Julliard | 5797fbb | 2001-12-06 22:33:58 +0000 | [diff] [blame] | 470 | LONG style = GetWindowLongW( list[i], GWL_STYLE ); |
| 471 | if ((uFlags & CWP_SKIPINVISIBLE) && !(style & WS_VISIBLE)) continue; |
| 472 | if ((uFlags & CWP_SKIPDISABLED) && (style & WS_DISABLED)) continue; |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 473 | } |
Alexandre Julliard | 5797fbb | 2001-12-06 22:33:58 +0000 | [diff] [blame] | 474 | if (uFlags & CWP_SKIPTRANSPARENT) |
| 475 | { |
| 476 | if (GetWindowLongW( list[i], GWL_EXSTYLE ) & WS_EX_TRANSPARENT) continue; |
| 477 | } |
| 478 | break; |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 479 | } |
Alexandre Julliard | 5797fbb | 2001-12-06 22:33:58 +0000 | [diff] [blame] | 480 | retvalue = list[i]; |
Alexandre Julliard | 9d9dac0 | 2001-08-24 19:28:21 +0000 | [diff] [blame] | 481 | HeapFree( GetProcessHeap(), 0, list ); |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 482 | if (!retvalue) retvalue = hwndParent; |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 483 | return retvalue; |
Paul Quinn | eede6b0 | 1998-11-30 13:15:36 +0000 | [diff] [blame] | 484 | } |
| 485 | |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 486 | |
Alexandre Julliard | 86a8d0f | 1994-01-18 23:04:40 +0000 | [diff] [blame] | 487 | /******************************************************************* |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 488 | * WINPOS_GetWinOffset |
| 489 | * |
| 490 | * Calculate the offset between the origin of the two windows. Used |
| 491 | * to implement MapWindowPoints. |
| 492 | */ |
Alexandre Julliard | fb0ff05 | 2001-10-16 21:58:58 +0000 | [diff] [blame] | 493 | static void WINPOS_GetWinOffset( HWND hwndFrom, HWND hwndTo, POINT *offset ) |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 494 | { |
Alexandre Julliard | fb0ff05 | 2001-10-16 21:58:58 +0000 | [diff] [blame] | 495 | WND * wndPtr; |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 496 | |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 497 | offset->x = offset->y = 0; |
Alexandre Julliard | 7e56f68 | 1996-01-31 19:02:28 +0000 | [diff] [blame] | 498 | |
Alexandre Julliard | fb0ff05 | 2001-10-16 21:58:58 +0000 | [diff] [blame] | 499 | /* Translate source window origin to screen coords */ |
Alexandre Julliard | 59730ae | 1996-03-24 16:20:51 +0000 | [diff] [blame] | 500 | if (hwndFrom) |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 501 | { |
Alexandre Julliard | fb0ff05 | 2001-10-16 21:58:58 +0000 | [diff] [blame] | 502 | HWND hwnd = hwndFrom; |
| 503 | |
| 504 | while (hwnd) |
Alexandre Julliard | 59730ae | 1996-03-24 16:20:51 +0000 | [diff] [blame] | 505 | { |
Alexandre Julliard | fb0ff05 | 2001-10-16 21:58:58 +0000 | [diff] [blame] | 506 | if (hwnd == hwndTo) return; |
| 507 | if (!(wndPtr = WIN_GetPtr( hwnd ))) |
Alexandre Julliard | 556607a | 2001-10-10 20:28:17 +0000 | [diff] [blame] | 508 | { |
Alexandre Julliard | aff7dda | 2002-11-22 21:22:14 +0000 | [diff] [blame] | 509 | ERR( "bad hwndFrom = %p\n", hwnd ); |
Alexandre Julliard | fb0ff05 | 2001-10-16 21:58:58 +0000 | [diff] [blame] | 510 | return; |
Alexandre Julliard | 556607a | 2001-10-10 20:28:17 +0000 | [diff] [blame] | 511 | } |
Alexandre Julliard | fb0ff05 | 2001-10-16 21:58:58 +0000 | [diff] [blame] | 512 | if (wndPtr == WND_OTHER_PROCESS) goto other_process; |
| 513 | offset->x += wndPtr->rectClient.left; |
| 514 | offset->y += wndPtr->rectClient.top; |
| 515 | hwnd = wndPtr->parent; |
| 516 | WIN_ReleasePtr( wndPtr ); |
Alexandre Julliard | 59730ae | 1996-03-24 16:20:51 +0000 | [diff] [blame] | 517 | } |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 518 | } |
| 519 | |
Alexandre Julliard | fb0ff05 | 2001-10-16 21:58:58 +0000 | [diff] [blame] | 520 | /* Translate origin to destination window coords */ |
Alexandre Julliard | 59730ae | 1996-03-24 16:20:51 +0000 | [diff] [blame] | 521 | if (hwndTo) |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 522 | { |
Alexandre Julliard | fb0ff05 | 2001-10-16 21:58:58 +0000 | [diff] [blame] | 523 | HWND hwnd = hwndTo; |
| 524 | |
| 525 | while (hwnd) |
Alexandre Julliard | 59730ae | 1996-03-24 16:20:51 +0000 | [diff] [blame] | 526 | { |
Alexandre Julliard | fb0ff05 | 2001-10-16 21:58:58 +0000 | [diff] [blame] | 527 | if (!(wndPtr = WIN_GetPtr( hwnd ))) |
Alexandre Julliard | 556607a | 2001-10-10 20:28:17 +0000 | [diff] [blame] | 528 | { |
Alexandre Julliard | aff7dda | 2002-11-22 21:22:14 +0000 | [diff] [blame] | 529 | ERR( "bad hwndTo = %p\n", hwnd ); |
Alexandre Julliard | fb0ff05 | 2001-10-16 21:58:58 +0000 | [diff] [blame] | 530 | return; |
Alexandre Julliard | 556607a | 2001-10-10 20:28:17 +0000 | [diff] [blame] | 531 | } |
Alexandre Julliard | fb0ff05 | 2001-10-16 21:58:58 +0000 | [diff] [blame] | 532 | if (wndPtr == WND_OTHER_PROCESS) goto other_process; |
| 533 | offset->x -= wndPtr->rectClient.left; |
| 534 | offset->y -= wndPtr->rectClient.top; |
| 535 | hwnd = wndPtr->parent; |
| 536 | WIN_ReleasePtr( wndPtr ); |
Alexandre Julliard | 556607a | 2001-10-10 20:28:17 +0000 | [diff] [blame] | 537 | } |
Alexandre Julliard | 59730ae | 1996-03-24 16:20:51 +0000 | [diff] [blame] | 538 | } |
Alexandre Julliard | fb0ff05 | 2001-10-16 21:58:58 +0000 | [diff] [blame] | 539 | return; |
| 540 | |
| 541 | other_process: /* one of the parents may belong to another process, do it the hard way */ |
| 542 | offset->x = offset->y = 0; |
| 543 | SERVER_START_REQ( get_windows_offset ) |
| 544 | { |
| 545 | req->from = hwndFrom; |
| 546 | req->to = hwndTo; |
Alexandre Julliard | 9caa71e | 2001-11-30 18:46:42 +0000 | [diff] [blame] | 547 | if (!wine_server_call( req )) |
Alexandre Julliard | fb0ff05 | 2001-10-16 21:58:58 +0000 | [diff] [blame] | 548 | { |
Alexandre Julliard | 9caa71e | 2001-11-30 18:46:42 +0000 | [diff] [blame] | 549 | offset->x = reply->x; |
| 550 | offset->y = reply->y; |
Alexandre Julliard | fb0ff05 | 2001-10-16 21:58:58 +0000 | [diff] [blame] | 551 | } |
| 552 | } |
| 553 | SERVER_END_REQ; |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 554 | } |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 555 | |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 556 | |
| 557 | /******************************************************************* |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 558 | * MapWindowPoints (USER.258) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 559 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 560 | void WINAPI MapWindowPoints16( HWND16 hwndFrom, HWND16 hwndTo, |
| 561 | LPPOINT16 lppt, UINT16 count ) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 562 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 563 | POINT offset; |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 564 | |
Alexandre Julliard | f44bbb8 | 2001-09-14 00:24:39 +0000 | [diff] [blame] | 565 | WINPOS_GetWinOffset( WIN_Handle32(hwndFrom), WIN_Handle32(hwndTo), &offset ); |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 566 | while (count--) |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 567 | { |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 568 | lppt->x += offset.x; |
| 569 | lppt->y += offset.y; |
| 570 | lppt++; |
| 571 | } |
| 572 | } |
| 573 | |
| 574 | |
| 575 | /******************************************************************* |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 576 | * MapWindowPoints (USER32.@) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 577 | */ |
Alexandre Julliard | fb0ff05 | 2001-10-16 21:58:58 +0000 | [diff] [blame] | 578 | INT WINAPI MapWindowPoints( HWND hwndFrom, HWND hwndTo, LPPOINT lppt, UINT count ) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 579 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 580 | POINT offset; |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 581 | |
Alexandre Julliard | fb0ff05 | 2001-10-16 21:58:58 +0000 | [diff] [blame] | 582 | WINPOS_GetWinOffset( hwndFrom, hwndTo, &offset ); |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 583 | while (count--) |
| 584 | { |
| 585 | lppt->x += offset.x; |
| 586 | lppt->y += offset.y; |
| 587 | lppt++; |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 588 | } |
Eric Pouech | b9544f1 | 1999-02-14 14:09:42 +0000 | [diff] [blame] | 589 | return MAKELONG( LOWORD(offset.x), LOWORD(offset.y) ); |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 590 | } |
| 591 | |
| 592 | |
| 593 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 594 | * IsIconic (USER32.@) |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 595 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 596 | BOOL WINAPI IsIconic(HWND hWnd) |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 597 | { |
Alexandre Julliard | fb0ff05 | 2001-10-16 21:58:58 +0000 | [diff] [blame] | 598 | return (GetWindowLongW( hWnd, GWL_STYLE ) & WS_MINIMIZE) != 0; |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 599 | } |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 600 | |
| 601 | |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 602 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 603 | * IsZoomed (USER32.@) |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 604 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 605 | BOOL WINAPI IsZoomed(HWND hWnd) |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 606 | { |
Alexandre Julliard | fb0ff05 | 2001-10-16 21:58:58 +0000 | [diff] [blame] | 607 | return (GetWindowLongW( hWnd, GWL_STYLE ) & WS_MAXIMIZE) != 0; |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 608 | } |
| 609 | |
| 610 | |
Alexandre Julliard | dba420a | 1994-02-02 06:48:31 +0000 | [diff] [blame] | 611 | /******************************************************************* |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 612 | * AllowSetForegroundWindow (USER32.@) |
David Elliott | 44f84b5 | 2000-10-29 01:24:54 +0000 | [diff] [blame] | 613 | */ |
| 614 | BOOL WINAPI AllowSetForegroundWindow( DWORD procid ) |
| 615 | { |
| 616 | /* FIXME: If Win98/2000 style SetForegroundWindow behavior is |
| 617 | * implemented, then fix this function. */ |
| 618 | return TRUE; |
| 619 | } |
| 620 | |
| 621 | |
| 622 | /******************************************************************* |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 623 | * LockSetForegroundWindow (USER32.@) |
David Elliott | 44f84b5 | 2000-10-29 01:24:54 +0000 | [diff] [blame] | 624 | */ |
| 625 | BOOL WINAPI LockSetForegroundWindow( UINT lockcode ) |
| 626 | { |
| 627 | /* FIXME: If Win98/2000 style SetForegroundWindow behavior is |
| 628 | * implemented, then fix this function. */ |
| 629 | return TRUE; |
| 630 | } |
| 631 | |
| 632 | |
| 633 | /******************************************************************* |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 634 | * SetShellWindow (USER32.@) |
Alexandre Julliard | e658d82 | 1997-11-30 17:45:40 +0000 | [diff] [blame] | 635 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 636 | HWND WINAPI SetShellWindow(HWND hwndshell) |
Alexandre Julliard | aff7dda | 2002-11-22 21:22:14 +0000 | [diff] [blame] | 637 | { WARN("(hWnd=%p) semi stub\n",hwndshell ); |
Alexandre Julliard | 85ed45e | 1998-08-22 19:03:56 +0000 | [diff] [blame] | 638 | |
Alexandre Julliard | 37a4639 | 2001-09-12 17:19:13 +0000 | [diff] [blame] | 639 | hGlobalShellWindow = WIN_GetFullHandle( hwndshell ); |
Alexandre Julliard | 85ed45e | 1998-08-22 19:03:56 +0000 | [diff] [blame] | 640 | return hGlobalShellWindow; |
Alexandre Julliard | e658d82 | 1997-11-30 17:45:40 +0000 | [diff] [blame] | 641 | } |
| 642 | |
Alexandre Julliard | 17216f5 | 1997-10-12 16:30:17 +0000 | [diff] [blame] | 643 | |
| 644 | /******************************************************************* |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 645 | * GetShellWindow (USER32.@) |
Alexandre Julliard | 17216f5 | 1997-10-12 16:30:17 +0000 | [diff] [blame] | 646 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 647 | HWND WINAPI GetShellWindow(void) |
Alexandre Julliard | aff7dda | 2002-11-22 21:22:14 +0000 | [diff] [blame] | 648 | { WARN("(hWnd=%p) semi stub\n",hGlobalShellWindow ); |
Alexandre Julliard | 85ed45e | 1998-08-22 19:03:56 +0000 | [diff] [blame] | 649 | |
| 650 | return hGlobalShellWindow; |
Alexandre Julliard | 17216f5 | 1997-10-12 16:30:17 +0000 | [diff] [blame] | 651 | } |
| 652 | |
| 653 | |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 654 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 655 | * BringWindowToTop (USER32.@) |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 656 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 657 | BOOL WINAPI BringWindowToTop( HWND hwnd ) |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 658 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 659 | return SetWindowPos( hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE ); |
Alexandre Julliard | 86a8d0f | 1994-01-18 23:04:40 +0000 | [diff] [blame] | 660 | } |
| 661 | |
| 662 | |
| 663 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 664 | * MoveWindow (USER32.@) |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 665 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 666 | BOOL WINAPI MoveWindow( HWND hwnd, INT x, INT y, INT cx, INT cy, |
| 667 | BOOL repaint ) |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 668 | { |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 669 | int flags = SWP_NOZORDER | SWP_NOACTIVATE; |
| 670 | if (!repaint) flags |= SWP_NOREDRAW; |
Alexandre Julliard | aff7dda | 2002-11-22 21:22:14 +0000 | [diff] [blame] | 671 | TRACE("%p %d,%d %dx%d %d\n", hwnd, x, y, cx, cy, repaint ); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 672 | return SetWindowPos( hwnd, 0, x, y, cx, cy, flags ); |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 673 | } |
| 674 | |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 675 | /*********************************************************************** |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 676 | * WINPOS_InitInternalPos |
| 677 | */ |
Alexandre Julliard | fb0ff05 | 2001-10-16 21:58:58 +0000 | [diff] [blame] | 678 | static LPINTERNALPOS WINPOS_InitInternalPos( WND* wnd, POINT pt, const RECT *restoreRect ) |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 679 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 680 | LPINTERNALPOS lpPos = (LPINTERNALPOS) GetPropA( wnd->hwndSelf, |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 681 | atomInternalPos ); |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 682 | if( !lpPos ) |
| 683 | { |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 684 | /* this happens when the window is minimized/maximized |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 685 | * for the first time (rectWindow is not adjusted yet) */ |
| 686 | |
Alexandre Julliard | da2892c | 2001-02-23 01:13:42 +0000 | [diff] [blame] | 687 | lpPos = HeapAlloc( GetProcessHeap(), 0, sizeof(INTERNALPOS) ); |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 688 | if( !lpPos ) return NULL; |
| 689 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 690 | SetPropA( wnd->hwndSelf, atomInternalPos, (HANDLE)lpPos ); |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 691 | lpPos->hwndIconTitle = 0; /* defer until needs to be shown */ |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 692 | CONV_RECT32TO16( &wnd->rectWindow, &lpPos->rectNormal ); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 693 | *(UINT*)&lpPos->ptIconPos = *(UINT*)&lpPos->ptMaxPos = 0xFFFFFFFF; |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 694 | } |
| 695 | |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 696 | if( wnd->dwStyle & WS_MINIMIZE ) |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 697 | CONV_POINT32TO16( &pt, &lpPos->ptIconPos ); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 698 | else if( wnd->dwStyle & WS_MAXIMIZE ) |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 699 | CONV_POINT32TO16( &pt, &lpPos->ptMaxPos ); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 700 | else if( restoreRect ) |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 701 | CONV_RECT32TO16( restoreRect, &lpPos->rectNormal ); |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 702 | |
| 703 | return lpPos; |
| 704 | } |
| 705 | |
| 706 | /*********************************************************************** |
| 707 | * WINPOS_RedrawIconTitle |
| 708 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 709 | BOOL WINPOS_RedrawIconTitle( HWND hWnd ) |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 710 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 711 | LPINTERNALPOS lpPos = (LPINTERNALPOS)GetPropA( hWnd, atomInternalPos ); |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 712 | if( lpPos ) |
| 713 | { |
| 714 | if( lpPos->hwndIconTitle ) |
| 715 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 716 | SendMessageA( lpPos->hwndIconTitle, WM_SHOWWINDOW, TRUE, 0); |
| 717 | InvalidateRect( lpPos->hwndIconTitle, NULL, TRUE ); |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 718 | return TRUE; |
| 719 | } |
| 720 | } |
| 721 | return FALSE; |
| 722 | } |
| 723 | |
| 724 | /*********************************************************************** |
| 725 | * WINPOS_ShowIconTitle |
| 726 | */ |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 727 | BOOL WINPOS_ShowIconTitle( HWND hwnd, BOOL bShow ) |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 728 | { |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 729 | LPINTERNALPOS lpPos = (LPINTERNALPOS)GetPropA( hwnd, atomInternalPos ); |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 730 | |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 731 | if( lpPos && !(GetWindowLongA( hwnd, GWL_EXSTYLE) & WS_EX_MANAGED)) |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 732 | { |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 733 | HWND title = lpPos->hwndIconTitle; |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 734 | |
Alexandre Julliard | aff7dda | 2002-11-22 21:22:14 +0000 | [diff] [blame] | 735 | TRACE("%p %i\n", hwnd, (bShow != 0) ); |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 736 | |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 737 | if( !title ) |
| 738 | lpPos->hwndIconTitle = title = ICONTITLE_Create( hwnd ); |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 739 | if( bShow ) |
| 740 | { |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 741 | if (!IsWindowVisible(title)) |
| 742 | { |
| 743 | SendMessageA( title, WM_SHOWWINDOW, TRUE, 0 ); |
| 744 | SetWindowPos( title, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | |
| 745 | SWP_NOACTIVATE | SWP_NOZORDER | SWP_SHOWWINDOW ); |
| 746 | } |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 747 | } |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 748 | else ShowWindow( title, SW_HIDE ); |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 749 | } |
| 750 | return FALSE; |
| 751 | } |
| 752 | |
| 753 | /******************************************************************* |
| 754 | * WINPOS_GetMinMaxInfo |
| 755 | * |
| 756 | * Get the minimized and maximized information for a window. |
| 757 | */ |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 758 | void WINPOS_GetMinMaxInfo( HWND hwnd, POINT *maxSize, POINT *maxPos, |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 759 | POINT *minTrack, POINT *maxTrack ) |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 760 | { |
| 761 | LPINTERNALPOS lpPos; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 762 | MINMAXINFO MinMax; |
| 763 | INT xinc, yinc; |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 764 | LONG style = GetWindowLongA( hwnd, GWL_STYLE ); |
| 765 | LONG exstyle = GetWindowLongA( hwnd, GWL_EXSTYLE ); |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 766 | |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 767 | /* Compute default values */ |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 768 | |
Marcus Meissner | ddca315 | 1999-05-22 11:33:23 +0000 | [diff] [blame] | 769 | MinMax.ptMaxSize.x = GetSystemMetrics(SM_CXSCREEN); |
| 770 | MinMax.ptMaxSize.y = GetSystemMetrics(SM_CYSCREEN); |
| 771 | MinMax.ptMinTrackSize.x = GetSystemMetrics(SM_CXMINTRACK); |
| 772 | MinMax.ptMinTrackSize.y = GetSystemMetrics(SM_CYMINTRACK); |
| 773 | MinMax.ptMaxTrackSize.x = GetSystemMetrics(SM_CXSCREEN); |
| 774 | MinMax.ptMaxTrackSize.y = GetSystemMetrics(SM_CYSCREEN); |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 775 | |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 776 | if (HAS_DLGFRAME( style, exstyle )) |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 777 | { |
Marcus Meissner | ddca315 | 1999-05-22 11:33:23 +0000 | [diff] [blame] | 778 | xinc = GetSystemMetrics(SM_CXDLGFRAME); |
| 779 | yinc = GetSystemMetrics(SM_CYDLGFRAME); |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 780 | } |
| 781 | else |
| 782 | { |
| 783 | xinc = yinc = 0; |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 784 | if (HAS_THICKFRAME(style)) |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 785 | { |
Marcus Meissner | ddca315 | 1999-05-22 11:33:23 +0000 | [diff] [blame] | 786 | xinc += GetSystemMetrics(SM_CXFRAME); |
| 787 | yinc += GetSystemMetrics(SM_CYFRAME); |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 788 | } |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 789 | if (style & WS_BORDER) |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 790 | { |
Marcus Meissner | ddca315 | 1999-05-22 11:33:23 +0000 | [diff] [blame] | 791 | xinc += GetSystemMetrics(SM_CXBORDER); |
| 792 | yinc += GetSystemMetrics(SM_CYBORDER); |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 793 | } |
| 794 | } |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 795 | MinMax.ptMaxSize.x += 2 * xinc; |
| 796 | MinMax.ptMaxSize.y += 2 * yinc; |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 797 | |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 798 | lpPos = (LPINTERNALPOS)GetPropA( hwnd, atomInternalPos ); |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 799 | if( lpPos && !EMPTYPOINT(lpPos->ptMaxPos) ) |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 800 | CONV_POINT16TO32( &lpPos->ptMaxPos, &MinMax.ptMaxPosition ); |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 801 | else |
| 802 | { |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 803 | MinMax.ptMaxPosition.x = -xinc; |
| 804 | MinMax.ptMaxPosition.y = -yinc; |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 805 | } |
| 806 | |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 807 | SendMessageA( hwnd, WM_GETMINMAXINFO, 0, (LPARAM)&MinMax ); |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 808 | |
| 809 | /* Some sanity checks */ |
| 810 | |
Alexandre Julliard | 359f497e | 1999-07-04 16:02:24 +0000 | [diff] [blame] | 811 | TRACE("%ld %ld / %ld %ld / %ld %ld / %ld %ld\n", |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 812 | MinMax.ptMaxSize.x, MinMax.ptMaxSize.y, |
| 813 | MinMax.ptMaxPosition.x, MinMax.ptMaxPosition.y, |
| 814 | MinMax.ptMaxTrackSize.x, MinMax.ptMaxTrackSize.y, |
| 815 | MinMax.ptMinTrackSize.x, MinMax.ptMinTrackSize.y); |
Francois Gouget | 6d77d3a | 2000-03-25 21:44:35 +0000 | [diff] [blame] | 816 | MinMax.ptMaxTrackSize.x = max( MinMax.ptMaxTrackSize.x, |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 817 | MinMax.ptMinTrackSize.x ); |
Francois Gouget | 6d77d3a | 2000-03-25 21:44:35 +0000 | [diff] [blame] | 818 | MinMax.ptMaxTrackSize.y = max( MinMax.ptMaxTrackSize.y, |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 819 | MinMax.ptMinTrackSize.y ); |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 820 | |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 821 | if (maxSize) *maxSize = MinMax.ptMaxSize; |
| 822 | if (maxPos) *maxPos = MinMax.ptMaxPosition; |
| 823 | if (minTrack) *minTrack = MinMax.ptMinTrackSize; |
| 824 | if (maxTrack) *maxTrack = MinMax.ptMaxTrackSize; |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 825 | } |
| 826 | |
| 827 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 828 | * ShowWindowAsync (USER32.@) |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 829 | * |
| 830 | * doesn't wait; returns immediately. |
| 831 | * used by threads to toggle windows in other (possibly hanging) threads |
| 832 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 833 | BOOL WINAPI ShowWindowAsync( HWND hwnd, INT cmd ) |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 834 | { |
Alexandre Julliard | c07a6cf | 2002-10-29 21:33:00 +0000 | [diff] [blame] | 835 | HWND full_handle; |
| 836 | |
| 837 | if ((full_handle = WIN_IsCurrentThread( hwnd ))) |
| 838 | return USER_Driver.pShowWindow( full_handle, cmd ); |
| 839 | return SendNotifyMessageW( hwnd, WM_WINE_SHOWWINDOW, cmd, 0 ); |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 840 | } |
| 841 | |
| 842 | |
| 843 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 844 | * ShowWindow (USER32.@) |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 845 | */ |
Alexandre Julliard | dc4fe77 | 2001-06-04 21:55:17 +0000 | [diff] [blame] | 846 | BOOL WINAPI ShowWindow( HWND hwnd, INT cmd ) |
| 847 | { |
Alexandre Julliard | fb0ff05 | 2001-10-16 21:58:58 +0000 | [diff] [blame] | 848 | HWND full_handle; |
| 849 | |
| 850 | if ((full_handle = WIN_IsCurrentThread( hwnd ))) |
| 851 | return USER_Driver.pShowWindow( full_handle, cmd ); |
| 852 | return SendMessageW( hwnd, WM_WINE_SHOWWINDOW, cmd, 0 ); |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 853 | } |
| 854 | |
| 855 | |
| 856 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 857 | * GetInternalWindowPos (USER32.@) |
Alexandre Julliard | 86a8d0f | 1994-01-18 23:04:40 +0000 | [diff] [blame] | 858 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 859 | UINT WINAPI GetInternalWindowPos( HWND hwnd, LPRECT rectWnd, |
| 860 | LPPOINT ptIcon ) |
Alexandre Julliard | 86a8d0f | 1994-01-18 23:04:40 +0000 | [diff] [blame] | 861 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 862 | WINDOWPLACEMENT wndpl; |
| 863 | if (GetWindowPlacement( hwnd, &wndpl )) |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 864 | { |
| 865 | if (rectWnd) *rectWnd = wndpl.rcNormalPosition; |
| 866 | if (ptIcon) *ptIcon = wndpl.ptMinPosition; |
| 867 | return wndpl.showCmd; |
| 868 | } |
| 869 | return 0; |
| 870 | } |
| 871 | |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 872 | |
| 873 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 874 | * GetWindowPlacement (USER32.@) |
Alexandre Julliard | 638f169 | 1999-01-17 16:32:32 +0000 | [diff] [blame] | 875 | * |
| 876 | * Win95: |
| 877 | * Fails if wndpl->length of Win95 (!) apps is invalid. |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 878 | */ |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 879 | BOOL WINAPI GetWindowPlacement( HWND hwnd, WINDOWPLACEMENT *wndpl ) |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 880 | { |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 881 | WND *pWnd = WIN_FindWndPtr( hwnd ); |
| 882 | LPINTERNALPOS lpPos; |
| 883 | |
| 884 | if(!pWnd ) return FALSE; |
| 885 | |
| 886 | lpPos = WINPOS_InitInternalPos( pWnd, *(LPPOINT)&pWnd->rectWindow.left, &pWnd->rectWindow ); |
| 887 | wndpl->length = sizeof(*wndpl); |
| 888 | if( pWnd->dwStyle & WS_MINIMIZE ) |
| 889 | wndpl->showCmd = SW_SHOWMINIMIZED; |
| 890 | else |
| 891 | wndpl->showCmd = ( pWnd->dwStyle & WS_MAXIMIZE ) ? SW_SHOWMAXIMIZED : SW_SHOWNORMAL ; |
| 892 | if( pWnd->flags & WIN_RESTORE_MAX ) |
| 893 | wndpl->flags = WPF_RESTORETOMAXIMIZED; |
| 894 | else |
| 895 | wndpl->flags = 0; |
| 896 | CONV_POINT16TO32( &lpPos->ptIconPos, &wndpl->ptMinPosition ); |
| 897 | CONV_POINT16TO32( &lpPos->ptMaxPos, &wndpl->ptMaxPosition ); |
| 898 | CONV_RECT16TO32( &lpPos->rectNormal, &wndpl->rcNormalPosition ); |
| 899 | WIN_ReleaseWndPtr(pWnd); |
| 900 | return TRUE; |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 901 | } |
| 902 | |
| 903 | |
| 904 | /*********************************************************************** |
| 905 | * WINPOS_SetPlacement |
| 906 | */ |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 907 | static BOOL WINPOS_SetPlacement( HWND hwnd, const WINDOWPLACEMENT *wndpl, UINT flags ) |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 908 | { |
| 909 | WND *pWnd = WIN_FindWndPtr( hwnd ); |
| 910 | if( pWnd ) |
| 911 | { |
| 912 | LPINTERNALPOS lpPos = (LPINTERNALPOS)WINPOS_InitInternalPos( pWnd, |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 913 | *(LPPOINT)&pWnd->rectWindow.left, &pWnd->rectWindow ); |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 914 | |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 915 | if( flags & PLACE_MIN ) CONV_POINT32TO16( &wndpl->ptMinPosition, &lpPos->ptIconPos ); |
| 916 | if( flags & PLACE_MAX ) CONV_POINT32TO16( &wndpl->ptMaxPosition, &lpPos->ptMaxPos ); |
| 917 | if( flags & PLACE_RECT) CONV_RECT32TO16( &wndpl->rcNormalPosition, &lpPos->rectNormal ); |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 918 | |
| 919 | if( pWnd->dwStyle & WS_MINIMIZE ) |
| 920 | { |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 921 | WINPOS_ShowIconTitle( pWnd->hwndSelf, FALSE ); |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 922 | if( wndpl->flags & WPF_SETMINPOSITION && !EMPTYPOINT(lpPos->ptIconPos)) |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 923 | SetWindowPos( hwnd, 0, lpPos->ptIconPos.x, lpPos->ptIconPos.y, |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 924 | 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE ); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 925 | } |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 926 | else if( pWnd->dwStyle & WS_MAXIMIZE ) |
| 927 | { |
| 928 | if( !EMPTYPOINT(lpPos->ptMaxPos) ) |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 929 | SetWindowPos( hwnd, 0, lpPos->ptMaxPos.x, lpPos->ptMaxPos.y, |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 930 | 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE ); |
| 931 | } |
| 932 | else if( flags & PLACE_RECT ) |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 933 | SetWindowPos( hwnd, 0, lpPos->rectNormal.left, lpPos->rectNormal.top, |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 934 | lpPos->rectNormal.right - lpPos->rectNormal.left, |
| 935 | lpPos->rectNormal.bottom - lpPos->rectNormal.top, |
| 936 | SWP_NOZORDER | SWP_NOACTIVATE ); |
| 937 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 938 | ShowWindow( hwnd, wndpl->showCmd ); |
| 939 | if( IsWindow(hwnd) && pWnd->dwStyle & WS_MINIMIZE ) |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 940 | { |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 941 | if( pWnd->dwStyle & WS_VISIBLE ) WINPOS_ShowIconTitle( pWnd->hwndSelf, TRUE ); |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 942 | |
| 943 | /* SDK: ...valid only the next time... */ |
| 944 | if( wndpl->flags & WPF_RESTORETOMAXIMIZED ) pWnd->flags |= WIN_RESTORE_MAX; |
| 945 | } |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 946 | WIN_ReleaseWndPtr(pWnd); |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 947 | return TRUE; |
| 948 | } |
| 949 | return FALSE; |
| 950 | } |
| 951 | |
| 952 | |
| 953 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 954 | * SetWindowPlacement (USER32.@) |
Alexandre Julliard | 638f169 | 1999-01-17 16:32:32 +0000 | [diff] [blame] | 955 | * |
| 956 | * Win95: |
| 957 | * Fails if wndpl->length of Win95 (!) apps is invalid. |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 958 | */ |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 959 | BOOL WINAPI SetWindowPlacement( HWND hwnd, const WINDOWPLACEMENT *wpl ) |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 960 | { |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 961 | if (!wpl) return FALSE; |
| 962 | return WINPOS_SetPlacement( hwnd, wpl, PLACE_MIN | PLACE_MAX | PLACE_RECT ); |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 963 | } |
| 964 | |
| 965 | |
| 966 | /*********************************************************************** |
Bobby Bingham | db4aae2 | 2001-06-06 20:20:09 +0000 | [diff] [blame] | 967 | * AnimateWindow (USER32.@) |
| 968 | * Shows/Hides a window with an animation |
| 969 | * NO ANIMATION YET |
| 970 | */ |
| 971 | BOOL WINAPI AnimateWindow(HWND hwnd, DWORD dwTime, DWORD dwFlags) |
| 972 | { |
| 973 | FIXME("partial stub\n"); |
| 974 | |
| 975 | /* If trying to show/hide and it's already * |
| 976 | * shown/hidden or invalid window, fail with * |
| 977 | * invalid parameter */ |
| 978 | if(!IsWindow(hwnd) || |
| 979 | (IsWindowVisible(hwnd) && !(dwFlags & AW_HIDE)) || |
| 980 | (!IsWindowVisible(hwnd) && (dwFlags & AW_HIDE))) |
| 981 | { |
| 982 | SetLastError(ERROR_INVALID_PARAMETER); |
| 983 | return FALSE; |
| 984 | } |
| 985 | |
| 986 | ShowWindow(hwnd, (dwFlags & AW_HIDE) ? SW_HIDE : ((dwFlags & AW_ACTIVATE) ? SW_SHOW : SW_SHOWNA)); |
| 987 | |
| 988 | return TRUE; |
| 989 | } |
Alexandre Julliard | 86a8d0f | 1994-01-18 23:04:40 +0000 | [diff] [blame] | 990 | |
| 991 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 992 | * SetInternalWindowPos (USER32.@) |
Alexandre Julliard | 86a8d0f | 1994-01-18 23:04:40 +0000 | [diff] [blame] | 993 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 994 | void WINAPI SetInternalWindowPos( HWND hwnd, UINT showCmd, |
| 995 | LPRECT rect, LPPOINT pt ) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 996 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 997 | if( IsWindow(hwnd) ) |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 998 | { |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 999 | WINDOWPLACEMENT wndpl; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1000 | UINT flags; |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1001 | |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 1002 | wndpl.length = sizeof(wndpl); |
| 1003 | wndpl.showCmd = showCmd; |
| 1004 | wndpl.flags = flags = 0; |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1005 | |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 1006 | if( pt ) |
| 1007 | { |
| 1008 | flags |= PLACE_MIN; |
| 1009 | wndpl.flags |= WPF_SETMINPOSITION; |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 1010 | wndpl.ptMinPosition = *pt; |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 1011 | } |
| 1012 | if( rect ) |
| 1013 | { |
| 1014 | flags |= PLACE_RECT; |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 1015 | wndpl.rcNormalPosition = *rect; |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 1016 | } |
| 1017 | WINPOS_SetPlacement( hwnd, &wndpl, flags ); |
| 1018 | } |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1019 | } |
| 1020 | |
Alexandre Julliard | 5030bda | 2002-10-11 23:41:06 +0000 | [diff] [blame] | 1021 | |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 1022 | /******************************************************************* |
Alexandre Julliard | 5030bda | 2002-10-11 23:41:06 +0000 | [diff] [blame] | 1023 | * can_activate_window |
Alexandre Julliard | dba420a | 1994-02-02 06:48:31 +0000 | [diff] [blame] | 1024 | * |
Alexandre Julliard | 5030bda | 2002-10-11 23:41:06 +0000 | [diff] [blame] | 1025 | * Check if we can activate the specified window. |
Alexandre Julliard | dba420a | 1994-02-02 06:48:31 +0000 | [diff] [blame] | 1026 | */ |
Alexandre Julliard | 5030bda | 2002-10-11 23:41:06 +0000 | [diff] [blame] | 1027 | static BOOL can_activate_window( HWND hwnd ) |
Alexandre Julliard | dba420a | 1994-02-02 06:48:31 +0000 | [diff] [blame] | 1028 | { |
Alexandre Julliard | 5030bda | 2002-10-11 23:41:06 +0000 | [diff] [blame] | 1029 | LONG style; |
Noel Borthwick | b427856 | 1999-02-05 10:37:53 +0000 | [diff] [blame] | 1030 | |
Alexandre Julliard | 5030bda | 2002-10-11 23:41:06 +0000 | [diff] [blame] | 1031 | if (!hwnd) return FALSE; |
| 1032 | style = GetWindowLongW( hwnd, GWL_STYLE ); |
| 1033 | if (!(style & WS_VISIBLE)) return FALSE; |
| 1034 | if ((style & (WS_POPUP|WS_CHILD)) == WS_CHILD) return FALSE; |
| 1035 | return !(style & WS_DISABLED); |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 1036 | } |
| 1037 | |
Alexandre Julliard | 5030bda | 2002-10-11 23:41:06 +0000 | [diff] [blame] | 1038 | |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 1039 | /******************************************************************* |
| 1040 | * WINPOS_ActivateOtherWindow |
| 1041 | * |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 1042 | * Activates window other than pWnd. |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 1043 | */ |
Alexandre Julliard | 03e07b5 | 2001-11-06 22:28:18 +0000 | [diff] [blame] | 1044 | void WINPOS_ActivateOtherWindow(HWND hwnd) |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 1045 | { |
Alexandre Julliard | 5030bda | 2002-10-11 23:41:06 +0000 | [diff] [blame] | 1046 | HWND hwndTo, fg; |
Noel Borthwick | b427856 | 1999-02-05 10:37:53 +0000 | [diff] [blame] | 1047 | |
Alexandre Julliard | 5030bda | 2002-10-11 23:41:06 +0000 | [diff] [blame] | 1048 | if ((GetWindowLongW( hwnd, GWL_STYLE ) & WS_POPUP) && (hwndTo = GetWindow( hwnd, GW_OWNER ))) |
Noel Borthwick | b427856 | 1999-02-05 10:37:53 +0000 | [diff] [blame] | 1049 | { |
Alexandre Julliard | 5030bda | 2002-10-11 23:41:06 +0000 | [diff] [blame] | 1050 | hwndTo = GetAncestor( hwndTo, GA_ROOT ); |
| 1051 | if (can_activate_window( hwndTo )) goto done; |
Noel Borthwick | b427856 | 1999-02-05 10:37:53 +0000 | [diff] [blame] | 1052 | } |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 1053 | |
Alexandre Julliard | 5030bda | 2002-10-11 23:41:06 +0000 | [diff] [blame] | 1054 | hwndTo = hwnd; |
| 1055 | for (;;) |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 1056 | { |
Alexandre Julliard | 5030bda | 2002-10-11 23:41:06 +0000 | [diff] [blame] | 1057 | if (!(hwndTo = GetWindow( hwndTo, GW_HWNDNEXT ))) break; |
| 1058 | if (can_activate_window( hwndTo )) break; |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 1059 | } |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 1060 | |
Alexandre Julliard | 5030bda | 2002-10-11 23:41:06 +0000 | [diff] [blame] | 1061 | done: |
| 1062 | fg = GetForegroundWindow(); |
Alexandre Julliard | aff7dda | 2002-11-22 21:22:14 +0000 | [diff] [blame] | 1063 | TRACE("win = %p fg = %p\n", hwndTo, fg); |
Alexandre Julliard | 5030bda | 2002-10-11 23:41:06 +0000 | [diff] [blame] | 1064 | if (!fg || (hwnd == fg)) |
| 1065 | { |
| 1066 | if (SetForegroundWindow( hwndTo )) return; |
| 1067 | } |
| 1068 | if (!SetActiveWindow( hwndTo )) SetActiveWindow(0); |
Alexandre Julliard | dba420a | 1994-02-02 06:48:31 +0000 | [diff] [blame] | 1069 | } |
| 1070 | |
| 1071 | |
Alexandre Julliard | 86a8d0f | 1994-01-18 23:04:40 +0000 | [diff] [blame] | 1072 | /*********************************************************************** |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1073 | * WINPOS_HandleWindowPosChanging16 |
Alexandre Julliard | 2d159fb | 1994-07-15 16:04:31 +0000 | [diff] [blame] | 1074 | * |
| 1075 | * Default handling for a WM_WINDOWPOSCHANGING. Called from DefWindowProc(). |
| 1076 | */ |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 1077 | LONG WINPOS_HandleWindowPosChanging16( HWND hwnd, WINDOWPOS16 *winpos ) |
Alexandre Julliard | 2d159fb | 1994-07-15 16:04:31 +0000 | [diff] [blame] | 1078 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1079 | POINT maxSize, minTrack; |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 1080 | LONG style = GetWindowLongA( hwnd, GWL_STYLE ); |
| 1081 | |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1082 | if (winpos->flags & SWP_NOSIZE) return 0; |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 1083 | if ((style & WS_THICKFRAME) || ((style & (WS_POPUP | WS_CHILD)) == 0)) |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1084 | { |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 1085 | WINPOS_GetMinMaxInfo( hwnd, &maxSize, NULL, &minTrack, NULL ); |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 1086 | if (maxSize.x < winpos->cx) winpos->cx = maxSize.x; |
| 1087 | if (maxSize.y < winpos->cy) winpos->cy = maxSize.y; |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 1088 | if (!(style & WS_MINIMIZE)) |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 1089 | { |
| 1090 | if (winpos->cx < minTrack.x ) winpos->cx = minTrack.x; |
| 1091 | if (winpos->cy < minTrack.y ) winpos->cy = minTrack.y; |
| 1092 | } |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1093 | } |
| 1094 | return 0; |
| 1095 | } |
| 1096 | |
| 1097 | |
| 1098 | /*********************************************************************** |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 1099 | * WINPOS_HandleWindowPosChanging |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1100 | * |
| 1101 | * Default handling for a WM_WINDOWPOSCHANGING. Called from DefWindowProc(). |
| 1102 | */ |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 1103 | LONG WINPOS_HandleWindowPosChanging( HWND hwnd, WINDOWPOS *winpos ) |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1104 | { |
Gerard Patel | cc3e0c5 | 2000-12-18 03:10:42 +0000 | [diff] [blame] | 1105 | POINT maxSize, minTrack; |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 1106 | LONG style = GetWindowLongA( hwnd, GWL_STYLE ); |
| 1107 | |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1108 | if (winpos->flags & SWP_NOSIZE) return 0; |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 1109 | if ((style & WS_THICKFRAME) || ((style & (WS_POPUP | WS_CHILD)) == 0)) |
Alexandre Julliard | 2d159fb | 1994-07-15 16:04:31 +0000 | [diff] [blame] | 1110 | { |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 1111 | WINPOS_GetMinMaxInfo( hwnd, &maxSize, NULL, &minTrack, NULL ); |
Francois Gouget | 6d77d3a | 2000-03-25 21:44:35 +0000 | [diff] [blame] | 1112 | winpos->cx = min( winpos->cx, maxSize.x ); |
| 1113 | winpos->cy = min( winpos->cy, maxSize.y ); |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 1114 | if (!(style & WS_MINIMIZE)) |
Gerard Patel | cc3e0c5 | 2000-12-18 03:10:42 +0000 | [diff] [blame] | 1115 | { |
| 1116 | if (winpos->cx < minTrack.x ) winpos->cx = minTrack.x; |
| 1117 | if (winpos->cy < minTrack.y ) winpos->cy = minTrack.y; |
| 1118 | } |
Alexandre Julliard | 2d159fb | 1994-07-15 16:04:31 +0000 | [diff] [blame] | 1119 | } |
| 1120 | return 0; |
| 1121 | } |
| 1122 | |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 1123 | |
| 1124 | /*********************************************************************** |
Dmitry Timoshkov | 85350c8 | 2002-08-27 01:14:44 +0000 | [diff] [blame] | 1125 | * dump_winpos_flags |
| 1126 | */ |
| 1127 | static void dump_winpos_flags(UINT flags) |
| 1128 | { |
| 1129 | TRACE("flags:"); |
Tony Lambregts | 7ce3a5a | 2003-03-14 04:11:17 +0000 | [diff] [blame] | 1130 | if(flags & SWP_NOSIZE) TRACE(" SWP_NOSIZE"); |
| 1131 | if(flags & SWP_NOMOVE) TRACE(" SWP_NOMOVE"); |
| 1132 | if(flags & SWP_NOZORDER) TRACE(" SWP_NOZORDER"); |
| 1133 | if(flags & SWP_NOREDRAW) TRACE(" SWP_NOREDRAW"); |
| 1134 | if(flags & SWP_NOACTIVATE) TRACE(" SWP_NOACTIVATE"); |
| 1135 | if(flags & SWP_FRAMECHANGED) TRACE(" SWP_FRAMECHANGED"); |
| 1136 | if(flags & SWP_SHOWWINDOW) TRACE(" SWP_SHOWWINDOW"); |
| 1137 | if(flags & SWP_HIDEWINDOW) TRACE(" SWP_HIDEWINDOW"); |
| 1138 | if(flags & SWP_NOCOPYBITS) TRACE(" SWP_NOCOPYBITS"); |
| 1139 | if(flags & SWP_NOOWNERZORDER) TRACE(" SWP_NOOWNERZORDER"); |
| 1140 | if(flags & SWP_NOSENDCHANGING) TRACE(" SWP_NOSENDCHANGING"); |
| 1141 | if(flags & SWP_DEFERERASE) TRACE(" SWP_DEFERERASE"); |
| 1142 | if(flags & SWP_ASYNCWINDOWPOS) TRACE(" SWP_ASYNCWINDOWPOS"); |
Dmitry Timoshkov | 85350c8 | 2002-08-27 01:14:44 +0000 | [diff] [blame] | 1143 | |
| 1144 | #define DUMPED_FLAGS \ |
| 1145 | (SWP_NOSIZE | \ |
| 1146 | SWP_NOMOVE | \ |
| 1147 | SWP_NOZORDER | \ |
| 1148 | SWP_NOREDRAW | \ |
| 1149 | SWP_NOACTIVATE | \ |
| 1150 | SWP_FRAMECHANGED | \ |
| 1151 | SWP_SHOWWINDOW | \ |
| 1152 | SWP_HIDEWINDOW | \ |
| 1153 | SWP_NOCOPYBITS | \ |
| 1154 | SWP_NOOWNERZORDER | \ |
| 1155 | SWP_NOSENDCHANGING | \ |
| 1156 | SWP_DEFERERASE | \ |
| 1157 | SWP_ASYNCWINDOWPOS) |
| 1158 | |
Tony Lambregts | 7ce3a5a | 2003-03-14 04:11:17 +0000 | [diff] [blame] | 1159 | if(flags & ~DUMPED_FLAGS) TRACE(" %08x", flags & ~DUMPED_FLAGS); |
| 1160 | TRACE("\n"); |
Dmitry Timoshkov | 85350c8 | 2002-08-27 01:14:44 +0000 | [diff] [blame] | 1161 | #undef DUMPED_FLAGS |
| 1162 | } |
| 1163 | |
| 1164 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1165 | * SetWindowPos (USER32.@) |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 1166 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1167 | BOOL WINAPI SetWindowPos( HWND hwnd, HWND hwndInsertAfter, |
Ulrich Weigand | 7f53c57 | 1999-06-18 17:03:13 +0000 | [diff] [blame] | 1168 | INT x, INT y, INT cx, INT cy, UINT flags ) |
Alexandre Julliard | 2d159fb | 1994-07-15 16:04:31 +0000 | [diff] [blame] | 1169 | { |
Alexandre Julliard | 9ae0fe5 | 2001-04-24 23:28:52 +0000 | [diff] [blame] | 1170 | WINDOWPOS winpos; |
Alexandre Julliard | e2abbb1 | 1995-03-19 17:39:39 +0000 | [diff] [blame] | 1171 | |
Alexandre Julliard | aff7dda | 2002-11-22 21:22:14 +0000 | [diff] [blame] | 1172 | TRACE("hwnd %p, after %p, %d,%d (%dx%d), flags %08x\n", |
| 1173 | hwnd, hwndInsertAfter, x, y, cx, cy, flags); |
Dmitry Timoshkov | 85350c8 | 2002-08-27 01:14:44 +0000 | [diff] [blame] | 1174 | if(TRACE_ON(win)) dump_winpos_flags(flags); |
| 1175 | |
Alexandre Julliard | cf2e57d | 2002-10-31 22:06:53 +0000 | [diff] [blame] | 1176 | winpos.hwnd = WIN_GetFullHandle(hwnd); |
| 1177 | winpos.hwndInsertAfter = WIN_GetFullHandle(hwndInsertAfter); |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 1178 | winpos.x = x; |
| 1179 | winpos.y = y; |
| 1180 | winpos.cx = cx; |
| 1181 | winpos.cy = cy; |
| 1182 | winpos.flags = flags; |
Alexandre Julliard | fb0ff05 | 2001-10-16 21:58:58 +0000 | [diff] [blame] | 1183 | if (WIN_IsCurrentThread( hwnd )) return USER_Driver.pSetWindowPos( &winpos ); |
| 1184 | return SendMessageW( winpos.hwnd, WM_WINE_SETWINDOWPOS, 0, (LPARAM)&winpos ); |
Alexandre Julliard | 2d159fb | 1994-07-15 16:04:31 +0000 | [diff] [blame] | 1185 | } |
| 1186 | |
Alexandre Julliard | 9ae0fe5 | 2001-04-24 23:28:52 +0000 | [diff] [blame] | 1187 | |
Alexandre Julliard | 2d159fb | 1994-07-15 16:04:31 +0000 | [diff] [blame] | 1188 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1189 | * BeginDeferWindowPos (USER32.@) |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 1190 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1191 | HDWP WINAPI BeginDeferWindowPos( INT count ) |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 1192 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1193 | HDWP handle; |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 1194 | DWP *pDWP; |
| 1195 | |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1196 | if (count < 0) |
Slava Monich | cdbe644 | 2000-07-08 12:44:09 +0000 | [diff] [blame] | 1197 | { |
| 1198 | SetLastError(ERROR_INVALID_PARAMETER); |
| 1199 | return 0; |
| 1200 | } |
| 1201 | /* Windows allows zero count, in which case it allocates context for 8 moves */ |
| 1202 | if (count == 0) count = 8; |
| 1203 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1204 | handle = USER_HEAP_ALLOC( sizeof(DWP) + (count-1)*sizeof(WINDOWPOS) ); |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 1205 | if (!handle) return 0; |
Alexandre Julliard | e2abbb1 | 1995-03-19 17:39:39 +0000 | [diff] [blame] | 1206 | pDWP = (DWP *) USER_HEAP_LIN_ADDR( handle ); |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 1207 | pDWP->actualCount = 0; |
| 1208 | pDWP->suggestedCount = count; |
| 1209 | pDWP->valid = TRUE; |
| 1210 | pDWP->wMagic = DWP_MAGIC; |
Alexandre Julliard | 3a405ba | 1994-10-30 16:25:19 +0000 | [diff] [blame] | 1211 | pDWP->hwndParent = 0; |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 1212 | return handle; |
| 1213 | } |
| 1214 | |
| 1215 | |
| 1216 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1217 | * DeferWindowPos (USER32.@) |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 1218 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1219 | HDWP WINAPI DeferWindowPos( HDWP hdwp, HWND hwnd, HWND hwndAfter, |
| 1220 | INT x, INT y, INT cx, INT cy, |
| 1221 | UINT flags ) |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 1222 | { |
| 1223 | DWP *pDWP; |
| 1224 | int i; |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 1225 | HDWP newhdwp = hdwp,retvalue; |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 1226 | |
Alexandre Julliard | f44bbb8 | 2001-09-14 00:24:39 +0000 | [diff] [blame] | 1227 | hwnd = WIN_GetFullHandle( hwnd ); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1228 | if (hwnd == GetDesktopWindow()) return 0; |
Alexandre Julliard | 3a405ba | 1994-10-30 16:25:19 +0000 | [diff] [blame] | 1229 | |
Alexandre Julliard | f44bbb8 | 2001-09-14 00:24:39 +0000 | [diff] [blame] | 1230 | if (!(pDWP = USER_HEAP_LIN_ADDR( hdwp ))) return 0; |
| 1231 | |
Alexandre Julliard | fb0ff05 | 2001-10-16 21:58:58 +0000 | [diff] [blame] | 1232 | USER_Lock(); |
Alexandre Julliard | 3a405ba | 1994-10-30 16:25:19 +0000 | [diff] [blame] | 1233 | |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 1234 | for (i = 0; i < pDWP->actualCount; i++) |
| 1235 | { |
| 1236 | if (pDWP->winPos[i].hwnd == hwnd) |
| 1237 | { |
| 1238 | /* Merge with the other changes */ |
| 1239 | if (!(flags & SWP_NOZORDER)) |
| 1240 | { |
Alexandre Julliard | cf2e57d | 2002-10-31 22:06:53 +0000 | [diff] [blame] | 1241 | pDWP->winPos[i].hwndInsertAfter = WIN_GetFullHandle(hwndAfter); |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 1242 | } |
| 1243 | if (!(flags & SWP_NOMOVE)) |
| 1244 | { |
| 1245 | pDWP->winPos[i].x = x; |
| 1246 | pDWP->winPos[i].y = y; |
Alexandre Julliard | fb0ff05 | 2001-10-16 21:58:58 +0000 | [diff] [blame] | 1247 | } |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 1248 | if (!(flags & SWP_NOSIZE)) |
| 1249 | { |
| 1250 | pDWP->winPos[i].cx = cx; |
| 1251 | pDWP->winPos[i].cy = cy; |
| 1252 | } |
Alexandre Julliard | 17216f5 | 1997-10-12 16:30:17 +0000 | [diff] [blame] | 1253 | pDWP->winPos[i].flags &= flags | ~(SWP_NOSIZE | SWP_NOMOVE | |
| 1254 | SWP_NOZORDER | SWP_NOREDRAW | |
| 1255 | SWP_NOACTIVATE | SWP_NOCOPYBITS| |
| 1256 | SWP_NOOWNERZORDER); |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 1257 | pDWP->winPos[i].flags |= flags & (SWP_SHOWWINDOW | SWP_HIDEWINDOW | |
| 1258 | SWP_FRAMECHANGED); |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 1259 | retvalue = hdwp; |
| 1260 | goto END; |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 1261 | } |
| 1262 | } |
| 1263 | if (pDWP->actualCount >= pDWP->suggestedCount) |
| 1264 | { |
| 1265 | newhdwp = USER_HEAP_REALLOC( hdwp, |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1266 | sizeof(DWP) + pDWP->suggestedCount*sizeof(WINDOWPOS) ); |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 1267 | if (!newhdwp) |
| 1268 | { |
| 1269 | retvalue = 0; |
| 1270 | goto END; |
| 1271 | } |
Alexandre Julliard | e2abbb1 | 1995-03-19 17:39:39 +0000 | [diff] [blame] | 1272 | pDWP = (DWP *) USER_HEAP_LIN_ADDR( newhdwp ); |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 1273 | pDWP->suggestedCount++; |
| 1274 | } |
| 1275 | pDWP->winPos[pDWP->actualCount].hwnd = hwnd; |
| 1276 | pDWP->winPos[pDWP->actualCount].hwndInsertAfter = hwndAfter; |
| 1277 | pDWP->winPos[pDWP->actualCount].x = x; |
| 1278 | pDWP->winPos[pDWP->actualCount].y = y; |
| 1279 | pDWP->winPos[pDWP->actualCount].cx = cx; |
| 1280 | pDWP->winPos[pDWP->actualCount].cy = cy; |
| 1281 | pDWP->winPos[pDWP->actualCount].flags = flags; |
| 1282 | pDWP->actualCount++; |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 1283 | retvalue = newhdwp; |
| 1284 | END: |
Alexandre Julliard | fb0ff05 | 2001-10-16 21:58:58 +0000 | [diff] [blame] | 1285 | USER_Unlock(); |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 1286 | return retvalue; |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 1287 | } |
| 1288 | |
| 1289 | |
| 1290 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1291 | * EndDeferWindowPos (USER32.@) |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 1292 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1293 | BOOL WINAPI EndDeferWindowPos( HDWP hdwp ) |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 1294 | { |
| 1295 | DWP *pDWP; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1296 | WINDOWPOS *winpos; |
| 1297 | BOOL res = TRUE; |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 1298 | int i; |
| 1299 | |
Alexandre Julliard | e2abbb1 | 1995-03-19 17:39:39 +0000 | [diff] [blame] | 1300 | pDWP = (DWP *) USER_HEAP_LIN_ADDR( hdwp ); |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 1301 | if (!pDWP) return FALSE; |
Alexandre Julliard | e2abbb1 | 1995-03-19 17:39:39 +0000 | [diff] [blame] | 1302 | for (i = 0, winpos = pDWP->winPos; i < pDWP->actualCount; i++, winpos++) |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 1303 | { |
Alexandre Julliard | 9ae0fe5 | 2001-04-24 23:28:52 +0000 | [diff] [blame] | 1304 | if (!(res = USER_Driver.pSetWindowPos( winpos ))) break; |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 1305 | } |
| 1306 | USER_HEAP_FREE( hdwp ); |
| 1307 | return res; |
| 1308 | } |
| 1309 | |
| 1310 | |
| 1311 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1312 | * TileChildWindows (USER.199) |
Alexandre Julliard | 3a405ba | 1994-10-30 16:25:19 +0000 | [diff] [blame] | 1313 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1314 | void WINAPI TileChildWindows16( HWND16 parent, WORD action ) |
Alexandre Julliard | 3a405ba | 1994-10-30 16:25:19 +0000 | [diff] [blame] | 1315 | { |
Alexandre Julliard | 359f497e | 1999-07-04 16:02:24 +0000 | [diff] [blame] | 1316 | FIXME("(%04x, %d): stub\n", parent, action); |
Alexandre Julliard | 3a405ba | 1994-10-30 16:25:19 +0000 | [diff] [blame] | 1317 | } |
| 1318 | |
| 1319 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1320 | * CascadeChildWindows (USER.198) |
Alexandre Julliard | 3a405ba | 1994-10-30 16:25:19 +0000 | [diff] [blame] | 1321 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1322 | void WINAPI CascadeChildWindows16( HWND16 parent, WORD action ) |
Alexandre Julliard | 3a405ba | 1994-10-30 16:25:19 +0000 | [diff] [blame] | 1323 | { |
Alexandre Julliard | 359f497e | 1999-07-04 16:02:24 +0000 | [diff] [blame] | 1324 | FIXME("(%04x, %d): stub\n", parent, action); |
Alexandre Julliard | 3a405ba | 1994-10-30 16:25:19 +0000 | [diff] [blame] | 1325 | } |
Juergen Schmied | ddb2e29 | 1999-05-02 09:19:19 +0000 | [diff] [blame] | 1326 | |
| 1327 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1328 | * SetProgmanWindow (USER32.@) |
Juergen Schmied | ddb2e29 | 1999-05-02 09:19:19 +0000 | [diff] [blame] | 1329 | */ |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 1330 | HWND WINAPI SetProgmanWindow ( HWND hwnd ) |
Juergen Schmied | ddb2e29 | 1999-05-02 09:19:19 +0000 | [diff] [blame] | 1331 | { |
| 1332 | hGlobalProgmanWindow = hwnd; |
| 1333 | return hGlobalProgmanWindow; |
| 1334 | } |
| 1335 | |
Juergen Schmied | 2c20591 | 1998-10-15 12:35:41 +0000 | [diff] [blame] | 1336 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1337 | * GetProgmanWindow (USER32.@) |
Juergen Schmied | 2c20591 | 1998-10-15 12:35:41 +0000 | [diff] [blame] | 1338 | */ |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 1339 | HWND WINAPI GetProgmanWindow(void) |
Juergen Schmied | ddb2e29 | 1999-05-02 09:19:19 +0000 | [diff] [blame] | 1340 | { |
| 1341 | return hGlobalProgmanWindow; |
Juergen Schmied | 2c20591 | 1998-10-15 12:35:41 +0000 | [diff] [blame] | 1342 | } |
Juergen Schmied | ddb2e29 | 1999-05-02 09:19:19 +0000 | [diff] [blame] | 1343 | |
| 1344 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1345 | * SetShellWindowEx (USER32.@) |
Juergen Schmied | ddb2e29 | 1999-05-02 09:19:19 +0000 | [diff] [blame] | 1346 | * hwndProgman = Progman[Program Manager] |
| 1347 | * |-> SHELLDLL_DefView |
| 1348 | * hwndListView = | |-> SysListView32 |
| 1349 | * | | |-> tooltips_class32 |
| 1350 | * | | |
| 1351 | * | |-> SysHeader32 |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1352 | * | |
Juergen Schmied | ddb2e29 | 1999-05-02 09:19:19 +0000 | [diff] [blame] | 1353 | * |-> ProxyTarget |
| 1354 | */ |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 1355 | HWND WINAPI SetShellWindowEx ( HWND hwndProgman, HWND hwndListView ) |
Juergen Schmied | ddb2e29 | 1999-05-02 09:19:19 +0000 | [diff] [blame] | 1356 | { |
Alexandre Julliard | aff7dda | 2002-11-22 21:22:14 +0000 | [diff] [blame] | 1357 | FIXME("%p %p stub\n",hwndProgman ,hwndListView ); |
Juergen Schmied | ddb2e29 | 1999-05-02 09:19:19 +0000 | [diff] [blame] | 1358 | hGlobalShellWindow = hwndProgman; |
| 1359 | return hGlobalShellWindow; |
| 1360 | |
| 1361 | } |
| 1362 | |
| 1363 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1364 | * SetTaskmanWindow (USER32.@) |
Juergen Schmied | ddb2e29 | 1999-05-02 09:19:19 +0000 | [diff] [blame] | 1365 | * NOTES |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1366 | * hwnd = MSTaskSwWClass |
Juergen Schmied | ddb2e29 | 1999-05-02 09:19:19 +0000 | [diff] [blame] | 1367 | * |-> SysTabControl32 |
| 1368 | */ |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 1369 | HWND WINAPI SetTaskmanWindow ( HWND hwnd ) |
Juergen Schmied | ddb2e29 | 1999-05-02 09:19:19 +0000 | [diff] [blame] | 1370 | { |
| 1371 | hGlobalTaskmanWindow = hwnd; |
| 1372 | return hGlobalTaskmanWindow; |
| 1373 | } |
| 1374 | |
Juergen Schmied | 2c20591 | 1998-10-15 12:35:41 +0000 | [diff] [blame] | 1375 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1376 | * GetTaskmanWindow (USER32.@) |
Juergen Schmied | 2c20591 | 1998-10-15 12:35:41 +0000 | [diff] [blame] | 1377 | */ |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 1378 | HWND WINAPI GetTaskmanWindow(void) |
| 1379 | { |
Juergen Schmied | ddb2e29 | 1999-05-02 09:19:19 +0000 | [diff] [blame] | 1380 | return hGlobalTaskmanWindow; |
Juergen Schmied | 2c20591 | 1998-10-15 12:35:41 +0000 | [diff] [blame] | 1381 | } |