Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Window related functions |
| 3 | * |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 4 | * Copyright 1993, 1994 Alexandre Julliard |
Alexandre Julliard | 0799c1a | 2002-03-09 23:29:33 +0000 | [diff] [blame] | 5 | * |
| 6 | * This library is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU Lesser General Public |
| 8 | * License as published by the Free Software Foundation; either |
| 9 | * version 2.1 of the License, or (at your option) any later version. |
| 10 | * |
| 11 | * This library is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 | * Lesser General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU Lesser General Public |
| 17 | * License along with this library; if not, write to the Free Software |
| 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 19 | */ |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 20 | |
Alexandre Julliard | 5769d1d | 2002-04-26 19:05:15 +0000 | [diff] [blame] | 21 | #include "config.h" |
| 22 | #include "wine/port.h" |
| 23 | |
Alexandre Julliard | 7695d69 | 2001-09-24 01:19:59 +0000 | [diff] [blame] | 24 | #include <assert.h> |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 25 | #include <stdlib.h> |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 26 | #include <string.h> |
Jeremy White | d3e22d9 | 2000-02-10 19:03:02 +0000 | [diff] [blame] | 27 | #include "windef.h" |
Marcus Meissner | 317af32 | 1999-02-17 13:51:06 +0000 | [diff] [blame] | 28 | #include "wine/winbase16.h" |
Michael Veksler | 9d14a00 | 1999-05-08 12:40:24 +0000 | [diff] [blame] | 29 | #include "wine/winuser16.h" |
Alexandre Julliard | 0ca051e | 2002-10-17 16:43:42 +0000 | [diff] [blame] | 30 | #include "wownt32.h" |
Alexandre Julliard | 1a66d22 | 2001-08-28 18:44:52 +0000 | [diff] [blame] | 31 | #include "wine/server.h" |
Alexandre Julliard | cb10fda | 2000-08-06 02:41:16 +0000 | [diff] [blame] | 32 | #include "wine/unicode.h" |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 33 | #include "win.h" |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 34 | #include "user.h" |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 35 | #include "dce.h" |
Alexandre Julliard | 91222da | 2000-12-10 23:01:33 +0000 | [diff] [blame] | 36 | #include "controls.h" |
Alexandre Julliard | af0bae5 | 1995-10-03 17:06:08 +0000 | [diff] [blame] | 37 | #include "cursoricon.h" |
Alexandre Julliard | ef702d8 | 1996-05-28 18:54:58 +0000 | [diff] [blame] | 38 | #include "message.h" |
Alexandre Julliard | b817f4f | 1996-03-14 18:08:34 +0000 | [diff] [blame] | 39 | #include "queue.h" |
Alexandre Julliard | 234bc24 | 1994-12-10 13:02:28 +0000 | [diff] [blame] | 40 | #include "winpos.h" |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 41 | #include "winerror.h" |
Alexandre Julliard | 4220b29 | 1999-07-11 17:20:01 +0000 | [diff] [blame] | 42 | #include "stackframe.h" |
Alexandre Julliard | 0799c1a | 2002-03-09 23:29:33 +0000 | [diff] [blame] | 43 | #include "wine/debug.h" |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 44 | |
Alexandre Julliard | 0799c1a | 2002-03-09 23:29:33 +0000 | [diff] [blame] | 45 | WINE_DEFAULT_DEBUG_CHANNEL(win); |
| 46 | WINE_DECLARE_DEBUG_CHANNEL(msg); |
Patrik Stridvall | b4b9fae | 1999-04-19 14:56:29 +0000 | [diff] [blame] | 47 | |
Alexandre Julliard | 7695d69 | 2001-09-24 01:19:59 +0000 | [diff] [blame] | 48 | #define NB_USER_HANDLES (LAST_USER_HANDLE - FIRST_USER_HANDLE + 1) |
| 49 | |
Patrik Stridvall | b87fe2e | 1999-04-01 08:16:08 +0000 | [diff] [blame] | 50 | /**********************************************************************/ |
| 51 | |
Alexandre Julliard | 59730ae | 1996-03-24 16:20:51 +0000 | [diff] [blame] | 52 | /* Desktop window */ |
| 53 | static WND *pWndDesktop = NULL; |
| 54 | |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 55 | static WORD wDragWidth = 4; |
| 56 | static WORD wDragHeight= 3; |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 57 | |
Alexandre Julliard | 7695d69 | 2001-09-24 01:19:59 +0000 | [diff] [blame] | 58 | static void *user_handles[NB_USER_HANDLES]; |
Alexandre Julliard | 1a66d22 | 2001-08-28 18:44:52 +0000 | [diff] [blame] | 59 | |
Francois Boisvert | 93e3f90 | 1999-02-25 17:32:31 +0000 | [diff] [blame] | 60 | /* thread safeness */ |
Alexandre Julliard | 6837b9c | 2001-08-16 18:14:22 +0000 | [diff] [blame] | 61 | extern SYSLEVEL USER_SysLevel; /* FIXME */ |
Ulrich Weigand | c5b8b3a | 1999-05-22 16:28:47 +0000 | [diff] [blame] | 62 | |
Francois Boisvert | 93e3f90 | 1999-02-25 17:32:31 +0000 | [diff] [blame] | 63 | /*********************************************************************** |
| 64 | * WIN_SuspendWndsLock |
| 65 | * |
| 66 | * Suspend the lock on WND structures. |
| 67 | * Returns the number of locks suspended |
| 68 | */ |
Ulrich Weigand | c5b8b3a | 1999-05-22 16:28:47 +0000 | [diff] [blame] | 69 | int WIN_SuspendWndsLock( void ) |
Francois Boisvert | 93e3f90 | 1999-02-25 17:32:31 +0000 | [diff] [blame] | 70 | { |
Alexandre Julliard | 6837b9c | 2001-08-16 18:14:22 +0000 | [diff] [blame] | 71 | int isuspendedLocks = _ConfirmSysLevel( &USER_SysLevel ); |
Ulrich Weigand | c5b8b3a | 1999-05-22 16:28:47 +0000 | [diff] [blame] | 72 | int count = isuspendedLocks; |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 73 | |
Ulrich Weigand | c5b8b3a | 1999-05-22 16:28:47 +0000 | [diff] [blame] | 74 | while ( count-- > 0 ) |
Alexandre Julliard | 6837b9c | 2001-08-16 18:14:22 +0000 | [diff] [blame] | 75 | _LeaveSysLevel( &USER_SysLevel ); |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 76 | |
Francois Boisvert | 93e3f90 | 1999-02-25 17:32:31 +0000 | [diff] [blame] | 77 | return isuspendedLocks; |
Francois Boisvert | 93e3f90 | 1999-02-25 17:32:31 +0000 | [diff] [blame] | 78 | } |
| 79 | |
| 80 | /*********************************************************************** |
| 81 | * WIN_RestoreWndsLock |
| 82 | * |
| 83 | * Restore the suspended locks on WND structures |
| 84 | */ |
Ulrich Weigand | c5b8b3a | 1999-05-22 16:28:47 +0000 | [diff] [blame] | 85 | void WIN_RestoreWndsLock( int ipreviousLocks ) |
Francois Boisvert | 93e3f90 | 1999-02-25 17:32:31 +0000 | [diff] [blame] | 86 | { |
Ulrich Weigand | c5b8b3a | 1999-05-22 16:28:47 +0000 | [diff] [blame] | 87 | while ( ipreviousLocks-- > 0 ) |
Alexandre Julliard | 6837b9c | 2001-08-16 18:14:22 +0000 | [diff] [blame] | 88 | _EnterSysLevel( &USER_SysLevel ); |
Francois Boisvert | 93e3f90 | 1999-02-25 17:32:31 +0000 | [diff] [blame] | 89 | } |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 90 | |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 91 | /*********************************************************************** |
Alexandre Julliard | 1a66d22 | 2001-08-28 18:44:52 +0000 | [diff] [blame] | 92 | * create_window_handle |
| 93 | * |
| 94 | * Create a window handle with the server. |
| 95 | */ |
Alexandre Julliard | 844ceb9 | 2001-10-09 23:26:40 +0000 | [diff] [blame] | 96 | static WND *create_window_handle( HWND parent, HWND owner, ATOM atom, INT size ) |
Alexandre Julliard | 1a66d22 | 2001-08-28 18:44:52 +0000 | [diff] [blame] | 97 | { |
| 98 | BOOL res; |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 99 | user_handle_t handle = 0; |
Alexandre Julliard | 7695d69 | 2001-09-24 01:19:59 +0000 | [diff] [blame] | 100 | WORD index; |
Alexandre Julliard | 1a66d22 | 2001-08-28 18:44:52 +0000 | [diff] [blame] | 101 | WND *win = HeapAlloc( GetProcessHeap(), 0, size ); |
| 102 | |
| 103 | if (!win) return NULL; |
| 104 | |
| 105 | USER_Lock(); |
| 106 | |
Alexandre Julliard | a09da0c | 2001-09-21 21:08:40 +0000 | [diff] [blame] | 107 | SERVER_START_REQ( create_window ) |
Alexandre Julliard | 1a66d22 | 2001-08-28 18:44:52 +0000 | [diff] [blame] | 108 | { |
Alexandre Julliard | a09da0c | 2001-09-21 21:08:40 +0000 | [diff] [blame] | 109 | req->parent = parent; |
| 110 | req->owner = owner; |
Alexandre Julliard | 844ceb9 | 2001-10-09 23:26:40 +0000 | [diff] [blame] | 111 | req->atom = atom; |
Alexandre Julliard | 9caa71e | 2001-11-30 18:46:42 +0000 | [diff] [blame] | 112 | if ((res = !wine_server_call_err( req ))) handle = reply->handle; |
Alexandre Julliard | 1a66d22 | 2001-08-28 18:44:52 +0000 | [diff] [blame] | 113 | } |
Alexandre Julliard | a09da0c | 2001-09-21 21:08:40 +0000 | [diff] [blame] | 114 | SERVER_END_REQ; |
Alexandre Julliard | 1a66d22 | 2001-08-28 18:44:52 +0000 | [diff] [blame] | 115 | |
| 116 | if (!res) |
| 117 | { |
| 118 | USER_Unlock(); |
| 119 | HeapFree( GetProcessHeap(), 0, win ); |
| 120 | return NULL; |
| 121 | } |
Alexandre Julliard | 7695d69 | 2001-09-24 01:19:59 +0000 | [diff] [blame] | 122 | index = LOWORD(handle) - FIRST_USER_HANDLE; |
| 123 | assert( index < NB_USER_HANDLES ); |
| 124 | user_handles[index] = win; |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 125 | win->hwndSelf = handle; |
Alexandre Julliard | 1a66d22 | 2001-08-28 18:44:52 +0000 | [diff] [blame] | 126 | win->dwMagic = WND_MAGIC; |
| 127 | win->irefCount = 1; |
| 128 | return win; |
| 129 | } |
| 130 | |
| 131 | |
| 132 | /*********************************************************************** |
| 133 | * free_window_handle |
| 134 | * |
| 135 | * Free a window handle. |
| 136 | */ |
| 137 | static WND *free_window_handle( HWND hwnd ) |
| 138 | { |
| 139 | WND *ptr; |
Alexandre Julliard | 7695d69 | 2001-09-24 01:19:59 +0000 | [diff] [blame] | 140 | WORD index = LOWORD(hwnd) - FIRST_USER_HANDLE; |
Alexandre Julliard | 1a66d22 | 2001-08-28 18:44:52 +0000 | [diff] [blame] | 141 | |
Alexandre Julliard | 7695d69 | 2001-09-24 01:19:59 +0000 | [diff] [blame] | 142 | if (index >= NB_USER_HANDLES) return NULL; |
Alexandre Julliard | 1a66d22 | 2001-08-28 18:44:52 +0000 | [diff] [blame] | 143 | USER_Lock(); |
Alexandre Julliard | 7695d69 | 2001-09-24 01:19:59 +0000 | [diff] [blame] | 144 | if ((ptr = user_handles[index])) |
Alexandre Julliard | 1a66d22 | 2001-08-28 18:44:52 +0000 | [diff] [blame] | 145 | { |
| 146 | SERVER_START_REQ( destroy_window ) |
| 147 | { |
| 148 | req->handle = hwnd; |
Alexandre Julliard | 9caa71e | 2001-11-30 18:46:42 +0000 | [diff] [blame] | 149 | if (!wine_server_call_err( req )) |
Alexandre Julliard | 7695d69 | 2001-09-24 01:19:59 +0000 | [diff] [blame] | 150 | user_handles[index] = NULL; |
Alexandre Julliard | 1a66d22 | 2001-08-28 18:44:52 +0000 | [diff] [blame] | 151 | else |
| 152 | ptr = NULL; |
| 153 | } |
| 154 | SERVER_END_REQ; |
| 155 | } |
| 156 | USER_Unlock(); |
| 157 | if (ptr) HeapFree( GetProcessHeap(), 0, ptr ); |
| 158 | return ptr; |
| 159 | } |
| 160 | |
| 161 | |
Alexandre Julliard | 844ceb9 | 2001-10-09 23:26:40 +0000 | [diff] [blame] | 162 | /******************************************************************* |
| 163 | * list_window_children |
| 164 | * |
| 165 | * Build an array of the children of a given window. The array must be |
| 166 | * freed with HeapFree. Returns NULL when no windows are found. |
| 167 | */ |
| 168 | static HWND *list_window_children( HWND hwnd, ATOM atom, DWORD tid ) |
| 169 | { |
Alexandre Julliard | 9caa71e | 2001-11-30 18:46:42 +0000 | [diff] [blame] | 170 | HWND *list; |
| 171 | int size = 32; |
Alexandre Julliard | 844ceb9 | 2001-10-09 23:26:40 +0000 | [diff] [blame] | 172 | |
Alexandre Julliard | 9caa71e | 2001-11-30 18:46:42 +0000 | [diff] [blame] | 173 | for (;;) |
Alexandre Julliard | 844ceb9 | 2001-10-09 23:26:40 +0000 | [diff] [blame] | 174 | { |
Alexandre Julliard | 9caa71e | 2001-11-30 18:46:42 +0000 | [diff] [blame] | 175 | int count = 0; |
| 176 | |
| 177 | if (!(list = HeapAlloc( GetProcessHeap(), 0, size * sizeof(HWND) ))) break; |
| 178 | |
| 179 | SERVER_START_REQ( get_window_children ) |
Alexandre Julliard | 844ceb9 | 2001-10-09 23:26:40 +0000 | [diff] [blame] | 180 | { |
Alexandre Julliard | 9caa71e | 2001-11-30 18:46:42 +0000 | [diff] [blame] | 181 | req->parent = hwnd; |
| 182 | req->atom = atom; |
Alexandre Julliard | 54f2287 | 2002-10-03 19:54:57 +0000 | [diff] [blame] | 183 | req->tid = tid; |
Alexandre Julliard | 9caa71e | 2001-11-30 18:46:42 +0000 | [diff] [blame] | 184 | wine_server_set_reply( req, list, (size-1) * sizeof(HWND) ); |
| 185 | if (!wine_server_call( req )) count = reply->count; |
Alexandre Julliard | 844ceb9 | 2001-10-09 23:26:40 +0000 | [diff] [blame] | 186 | } |
Alexandre Julliard | 9caa71e | 2001-11-30 18:46:42 +0000 | [diff] [blame] | 187 | SERVER_END_REQ; |
| 188 | if (count && count < size) |
| 189 | { |
| 190 | list[count] = 0; |
| 191 | return list; |
| 192 | } |
| 193 | HeapFree( GetProcessHeap(), 0, list ); |
| 194 | if (!count) break; |
| 195 | size = count + 1; /* restart with a large enough buffer */ |
Alexandre Julliard | 844ceb9 | 2001-10-09 23:26:40 +0000 | [diff] [blame] | 196 | } |
Alexandre Julliard | 9caa71e | 2001-11-30 18:46:42 +0000 | [diff] [blame] | 197 | return NULL; |
Alexandre Julliard | 844ceb9 | 2001-10-09 23:26:40 +0000 | [diff] [blame] | 198 | } |
| 199 | |
| 200 | |
Alexandre Julliard | fb0ff05 | 2001-10-16 21:58:58 +0000 | [diff] [blame] | 201 | /******************************************************************* |
| 202 | * send_parent_notify |
| 203 | */ |
| 204 | static void send_parent_notify( HWND hwnd, UINT msg ) |
| 205 | { |
| 206 | if (!(GetWindowLongW( hwnd, GWL_STYLE ) & WS_CHILD)) return; |
| 207 | if (GetWindowLongW( hwnd, GWL_EXSTYLE ) & WS_EX_NOPARENTNOTIFY) return; |
| 208 | SendMessageW( GetParent(hwnd), WM_PARENTNOTIFY, |
| 209 | MAKEWPARAM( msg, GetWindowLongW( hwnd, GWL_ID )), (LPARAM)hwnd ); |
| 210 | } |
| 211 | |
| 212 | |
Alexandre Julliard | 805bdc5 | 2001-11-13 22:23:48 +0000 | [diff] [blame] | 213 | /******************************************************************* |
| 214 | * get_server_window_text |
| 215 | * |
| 216 | * Retrieve the window text from the server. |
| 217 | */ |
| 218 | static void get_server_window_text( HWND hwnd, LPWSTR text, INT count ) |
| 219 | { |
Alexandre Julliard | 9caa71e | 2001-11-30 18:46:42 +0000 | [diff] [blame] | 220 | size_t len = 0; |
| 221 | |
| 222 | SERVER_START_REQ( get_window_text ) |
Alexandre Julliard | 805bdc5 | 2001-11-13 22:23:48 +0000 | [diff] [blame] | 223 | { |
| 224 | req->handle = hwnd; |
Alexandre Julliard | 9caa71e | 2001-11-30 18:46:42 +0000 | [diff] [blame] | 225 | wine_server_set_reply( req, text, (count - 1) * sizeof(WCHAR) ); |
| 226 | if (!wine_server_call_err( req )) len = wine_server_reply_size(reply); |
Alexandre Julliard | 805bdc5 | 2001-11-13 22:23:48 +0000 | [diff] [blame] | 227 | } |
Alexandre Julliard | 9caa71e | 2001-11-30 18:46:42 +0000 | [diff] [blame] | 228 | SERVER_END_REQ; |
Alexandre Julliard | 805bdc5 | 2001-11-13 22:23:48 +0000 | [diff] [blame] | 229 | text[len / sizeof(WCHAR)] = 0; |
| 230 | } |
| 231 | |
| 232 | |
Alexandre Julliard | 1a66d22 | 2001-08-28 18:44:52 +0000 | [diff] [blame] | 233 | /*********************************************************************** |
Alexandre Julliard | 8fd26b9 | 2001-10-15 17:56:45 +0000 | [diff] [blame] | 234 | * WIN_GetPtr |
Alexandre Julliard | 6bf2abf | 2001-08-29 00:16:00 +0000 | [diff] [blame] | 235 | * |
Alexandre Julliard | 7695d69 | 2001-09-24 01:19:59 +0000 | [diff] [blame] | 236 | * Return a pointer to the WND structure if local to the process, |
Andreas Mohr | 7df2d9f | 2002-07-24 19:02:50 +0000 | [diff] [blame] | 237 | * or WND_OTHER_PROCESS if handle may be valid in other process. |
Alexandre Julliard | 8fd26b9 | 2001-10-15 17:56:45 +0000 | [diff] [blame] | 238 | * If ret value is a valid pointer, it must be released with WIN_ReleasePtr. |
Alexandre Julliard | 6bf2abf | 2001-08-29 00:16:00 +0000 | [diff] [blame] | 239 | */ |
Alexandre Julliard | 8fd26b9 | 2001-10-15 17:56:45 +0000 | [diff] [blame] | 240 | WND *WIN_GetPtr( HWND hwnd ) |
Alexandre Julliard | 6bf2abf | 2001-08-29 00:16:00 +0000 | [diff] [blame] | 241 | { |
Alexandre Julliard | 37a4639 | 2001-09-12 17:19:13 +0000 | [diff] [blame] | 242 | WND * ptr; |
Alexandre Julliard | 7695d69 | 2001-09-24 01:19:59 +0000 | [diff] [blame] | 243 | WORD index = LOWORD(hwnd) - FIRST_USER_HANDLE; |
Alexandre Julliard | 37a4639 | 2001-09-12 17:19:13 +0000 | [diff] [blame] | 244 | |
Alexandre Julliard | 8fd26b9 | 2001-10-15 17:56:45 +0000 | [diff] [blame] | 245 | if (index >= NB_USER_HANDLES) return NULL; |
Alexandre Julliard | 37a4639 | 2001-09-12 17:19:13 +0000 | [diff] [blame] | 246 | |
| 247 | USER_Lock(); |
Alexandre Julliard | 7695d69 | 2001-09-24 01:19:59 +0000 | [diff] [blame] | 248 | if ((ptr = user_handles[index])) |
Alexandre Julliard | 37a4639 | 2001-09-12 17:19:13 +0000 | [diff] [blame] | 249 | { |
| 250 | if (ptr->dwMagic == WND_MAGIC && (!HIWORD(hwnd) || hwnd == ptr->hwndSelf)) |
| 251 | return ptr; |
Alexandre Julliard | 8fd26b9 | 2001-10-15 17:56:45 +0000 | [diff] [blame] | 252 | ptr = NULL; |
Alexandre Julliard | 37a4639 | 2001-09-12 17:19:13 +0000 | [diff] [blame] | 253 | } |
Alexandre Julliard | 8fd26b9 | 2001-10-15 17:56:45 +0000 | [diff] [blame] | 254 | else ptr = WND_OTHER_PROCESS; |
Alexandre Julliard | 37a4639 | 2001-09-12 17:19:13 +0000 | [diff] [blame] | 255 | USER_Unlock(); |
Alexandre Julliard | 7695d69 | 2001-09-24 01:19:59 +0000 | [diff] [blame] | 256 | return ptr; |
| 257 | } |
| 258 | |
| 259 | |
| 260 | /*********************************************************************** |
| 261 | * WIN_IsCurrentProcess |
| 262 | * |
Alexandre Julliard | 8fd26b9 | 2001-10-15 17:56:45 +0000 | [diff] [blame] | 263 | * Check whether a given window belongs to the current process (and return the full handle). |
Alexandre Julliard | 7695d69 | 2001-09-24 01:19:59 +0000 | [diff] [blame] | 264 | */ |
Alexandre Julliard | 8fd26b9 | 2001-10-15 17:56:45 +0000 | [diff] [blame] | 265 | HWND WIN_IsCurrentProcess( HWND hwnd ) |
Alexandre Julliard | 7695d69 | 2001-09-24 01:19:59 +0000 | [diff] [blame] | 266 | { |
| 267 | WND *ptr; |
Alexandre Julliard | 8fd26b9 | 2001-10-15 17:56:45 +0000 | [diff] [blame] | 268 | HWND ret; |
Alexandre Julliard | 7695d69 | 2001-09-24 01:19:59 +0000 | [diff] [blame] | 269 | |
Alexandre Julliard | 8fd26b9 | 2001-10-15 17:56:45 +0000 | [diff] [blame] | 270 | if (!(ptr = WIN_GetPtr( hwnd )) || ptr == WND_OTHER_PROCESS) return 0; |
| 271 | ret = ptr->hwndSelf; |
| 272 | WIN_ReleasePtr( ptr ); |
| 273 | return ret; |
Alexandre Julliard | 7695d69 | 2001-09-24 01:19:59 +0000 | [diff] [blame] | 274 | } |
| 275 | |
| 276 | |
| 277 | /*********************************************************************** |
| 278 | * WIN_IsCurrentThread |
| 279 | * |
Alexandre Julliard | 8fd26b9 | 2001-10-15 17:56:45 +0000 | [diff] [blame] | 280 | * Check whether a given window belongs to the current thread (and return the full handle). |
Alexandre Julliard | 7695d69 | 2001-09-24 01:19:59 +0000 | [diff] [blame] | 281 | */ |
Alexandre Julliard | 8fd26b9 | 2001-10-15 17:56:45 +0000 | [diff] [blame] | 282 | HWND WIN_IsCurrentThread( HWND hwnd ) |
Alexandre Julliard | 7695d69 | 2001-09-24 01:19:59 +0000 | [diff] [blame] | 283 | { |
| 284 | WND *ptr; |
Alexandre Julliard | 8fd26b9 | 2001-10-15 17:56:45 +0000 | [diff] [blame] | 285 | HWND ret = 0; |
Alexandre Julliard | 7695d69 | 2001-09-24 01:19:59 +0000 | [diff] [blame] | 286 | |
Alexandre Julliard | 8fd26b9 | 2001-10-15 17:56:45 +0000 | [diff] [blame] | 287 | if ((ptr = WIN_GetPtr( hwnd )) && ptr != WND_OTHER_PROCESS) |
Alexandre Julliard | 7695d69 | 2001-09-24 01:19:59 +0000 | [diff] [blame] | 288 | { |
Alexandre Julliard | 8fd26b9 | 2001-10-15 17:56:45 +0000 | [diff] [blame] | 289 | if (ptr->tid == GetCurrentThreadId()) ret = ptr->hwndSelf; |
| 290 | WIN_ReleasePtr( ptr ); |
Alexandre Julliard | 7695d69 | 2001-09-24 01:19:59 +0000 | [diff] [blame] | 291 | } |
| 292 | return ret; |
Alexandre Julliard | 37a4639 | 2001-09-12 17:19:13 +0000 | [diff] [blame] | 293 | } |
| 294 | |
| 295 | |
| 296 | /*********************************************************************** |
| 297 | * WIN_Handle32 |
| 298 | * |
| 299 | * Convert a 16-bit window handle to a full 32-bit handle. |
| 300 | */ |
| 301 | HWND WIN_Handle32( HWND16 hwnd16 ) |
| 302 | { |
| 303 | WND *ptr; |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 304 | HWND hwnd = (HWND)(ULONG_PTR)hwnd16; |
Alexandre Julliard | 37a4639 | 2001-09-12 17:19:13 +0000 | [diff] [blame] | 305 | |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 306 | if (hwnd16 <= 1 || hwnd16 == 0xffff) return hwnd; |
| 307 | /* do sign extension for -2 and -3 */ |
| 308 | if (hwnd16 >= (HWND16)-3) return (HWND)(LONG_PTR)(INT16)hwnd16; |
Alexandre Julliard | 37a4639 | 2001-09-12 17:19:13 +0000 | [diff] [blame] | 309 | |
Alexandre Julliard | 8fd26b9 | 2001-10-15 17:56:45 +0000 | [diff] [blame] | 310 | if (!(ptr = WIN_GetPtr( hwnd ))) return hwnd; |
| 311 | |
| 312 | if (ptr != WND_OTHER_PROCESS) |
Alexandre Julliard | 37a4639 | 2001-09-12 17:19:13 +0000 | [diff] [blame] | 313 | { |
Alexandre Julliard | 8fd26b9 | 2001-10-15 17:56:45 +0000 | [diff] [blame] | 314 | hwnd = ptr->hwndSelf; |
| 315 | WIN_ReleasePtr( ptr ); |
Alexandre Julliard | 37a4639 | 2001-09-12 17:19:13 +0000 | [diff] [blame] | 316 | } |
| 317 | else /* may belong to another process */ |
Alexandre Julliard | 6bf2abf | 2001-08-29 00:16:00 +0000 | [diff] [blame] | 318 | { |
| 319 | SERVER_START_REQ( get_window_info ) |
| 320 | { |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 321 | req->handle = hwnd; |
Alexandre Julliard | 9caa71e | 2001-11-30 18:46:42 +0000 | [diff] [blame] | 322 | if (!wine_server_call_err( req )) hwnd = reply->full_handle; |
Alexandre Julliard | 6bf2abf | 2001-08-29 00:16:00 +0000 | [diff] [blame] | 323 | } |
| 324 | SERVER_END_REQ; |
| 325 | } |
| 326 | return hwnd; |
| 327 | } |
| 328 | |
| 329 | |
| 330 | /*********************************************************************** |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 331 | * WIN_FindWndPtr |
| 332 | * |
| 333 | * Return a pointer to the WND structure corresponding to a HWND. |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 334 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 335 | WND * WIN_FindWndPtr( HWND hwnd ) |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 336 | { |
| 337 | WND * ptr; |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 338 | |
Alexandre Julliard | 1a66d22 | 2001-08-28 18:44:52 +0000 | [diff] [blame] | 339 | if (!hwnd) return NULL; |
| 340 | |
Alexandre Julliard | 8fd26b9 | 2001-10-15 17:56:45 +0000 | [diff] [blame] | 341 | if ((ptr = WIN_GetPtr( hwnd ))) |
Alexandre Julliard | 59730ae | 1996-03-24 16:20:51 +0000 | [diff] [blame] | 342 | { |
Alexandre Julliard | 8fd26b9 | 2001-10-15 17:56:45 +0000 | [diff] [blame] | 343 | if (ptr != WND_OTHER_PROCESS) |
Alexandre Julliard | 7695d69 | 2001-09-24 01:19:59 +0000 | [diff] [blame] | 344 | { |
| 345 | /* increment destruction monitoring */ |
| 346 | ptr->irefCount++; |
| 347 | return ptr; |
| 348 | } |
Alexandre Julliard | 8fd26b9 | 2001-10-15 17:56:45 +0000 | [diff] [blame] | 349 | if (IsWindow( hwnd )) /* check other processes */ |
| 350 | { |
| 351 | ERR( "window %04x belongs to other process\n", hwnd ); |
| 352 | /* DbgBreakPoint(); */ |
| 353 | } |
Alexandre Julliard | 37a4639 | 2001-09-12 17:19:13 +0000 | [diff] [blame] | 354 | } |
Alexandre Julliard | 1a66d22 | 2001-08-28 18:44:52 +0000 | [diff] [blame] | 355 | SetLastError( ERROR_INVALID_WINDOW_HANDLE ); |
Eric Pouech | b9544f1 | 1999-02-14 14:09:42 +0000 | [diff] [blame] | 356 | return NULL; |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 357 | } |
| 358 | |
Alexandre Julliard | 1a66d22 | 2001-08-28 18:44:52 +0000 | [diff] [blame] | 359 | |
Francois Boisvert | 93e3f90 | 1999-02-25 17:32:31 +0000 | [diff] [blame] | 360 | /*********************************************************************** |
| 361 | * WIN_ReleaseWndPtr |
| 362 | * |
| 363 | * Release the pointer to the WND structure. |
| 364 | */ |
| 365 | void WIN_ReleaseWndPtr(WND *wndPtr) |
| 366 | { |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 367 | if(!wndPtr) return; |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 368 | |
Andreas Mohr | e15badb | 2001-10-21 15:18:15 +0000 | [diff] [blame] | 369 | /* Decrement destruction monitoring value */ |
Francois Boisvert | 93e3f90 | 1999-02-25 17:32:31 +0000 | [diff] [blame] | 370 | wndPtr->irefCount--; |
Andreas Mohr | e15badb | 2001-10-21 15:18:15 +0000 | [diff] [blame] | 371 | /* Check if it's time to release the memory */ |
Francois Boisvert | 86e2e11 | 1999-04-03 11:13:33 +0000 | [diff] [blame] | 372 | if(wndPtr->irefCount == 0 && !wndPtr->dwMagic) |
Francois Boisvert | 93e3f90 | 1999-02-25 17:32:31 +0000 | [diff] [blame] | 373 | { |
Francois Boisvert | 86e2e11 | 1999-04-03 11:13:33 +0000 | [diff] [blame] | 374 | /* Release memory */ |
Alexandre Julliard | 1a66d22 | 2001-08-28 18:44:52 +0000 | [diff] [blame] | 375 | free_window_handle( wndPtr->hwndSelf ); |
Francois Boisvert | 93e3f90 | 1999-02-25 17:32:31 +0000 | [diff] [blame] | 376 | } |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 377 | else if(wndPtr->irefCount < 0) |
| 378 | { |
| 379 | /* This else if is useful to monitor the WIN_ReleaseWndPtr function */ |
Dimitrie O. Paun | dd03cc1 | 1999-12-08 03:56:23 +0000 | [diff] [blame] | 380 | ERR("forgot a Lock on %p somewhere\n",wndPtr); |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 381 | } |
Andreas Mohr | e15badb | 2001-10-21 15:18:15 +0000 | [diff] [blame] | 382 | /* unlock all WND structures for thread safeness */ |
Alexandre Julliard | 6837b9c | 2001-08-16 18:14:22 +0000 | [diff] [blame] | 383 | USER_Unlock(); |
Francois Boisvert | 93e3f90 | 1999-02-25 17:32:31 +0000 | [diff] [blame] | 384 | } |
| 385 | |
Alexandre Julliard | b817f4f | 1996-03-14 18:08:34 +0000 | [diff] [blame] | 386 | |
| 387 | /*********************************************************************** |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 388 | * WIN_UnlinkWindow |
| 389 | * |
| 390 | * Remove a window from the siblings linked list. |
| 391 | */ |
Alexandre Julliard | 1a66d22 | 2001-08-28 18:44:52 +0000 | [diff] [blame] | 392 | void WIN_UnlinkWindow( HWND hwnd ) |
| 393 | { |
| 394 | WIN_LinkWindow( hwnd, 0, 0 ); |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 395 | } |
| 396 | |
| 397 | |
| 398 | /*********************************************************************** |
| 399 | * WIN_LinkWindow |
| 400 | * |
| 401 | * Insert a window into the siblings linked list. |
| 402 | * The window is inserted after the specified window, which can also |
| 403 | * be specified as HWND_TOP or HWND_BOTTOM. |
Alexandre Julliard | 1a66d22 | 2001-08-28 18:44:52 +0000 | [diff] [blame] | 404 | * If parent is 0, window is unlinked from the tree. |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 405 | */ |
Alexandre Julliard | 1a66d22 | 2001-08-28 18:44:52 +0000 | [diff] [blame] | 406 | void WIN_LinkWindow( HWND hwnd, HWND parent, HWND hwndInsertAfter ) |
| 407 | { |
Alexandre Julliard | fb0ff05 | 2001-10-16 21:58:58 +0000 | [diff] [blame] | 408 | WND *wndPtr = WIN_GetPtr( hwnd ); |
| 409 | |
| 410 | if (!wndPtr) return; |
| 411 | if (wndPtr == WND_OTHER_PROCESS) |
| 412 | { |
| 413 | if (IsWindow(hwnd)) ERR(" cannot link other process window %x\n", hwnd ); |
| 414 | return; |
| 415 | } |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 416 | |
Alexandre Julliard | 1a66d22 | 2001-08-28 18:44:52 +0000 | [diff] [blame] | 417 | SERVER_START_REQ( link_window ) |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 418 | { |
Alexandre Julliard | 1a66d22 | 2001-08-28 18:44:52 +0000 | [diff] [blame] | 419 | req->handle = hwnd; |
| 420 | req->parent = parent; |
| 421 | req->previous = hwndInsertAfter; |
Alexandre Julliard | 9caa71e | 2001-11-30 18:46:42 +0000 | [diff] [blame] | 422 | if (!wine_server_call( req )) |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 423 | { |
Alexandre Julliard | 7dafa61 | 2002-09-25 00:21:56 +0000 | [diff] [blame] | 424 | if (reply->full_parent) wndPtr->parent = reply->full_parent; |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 425 | } |
| 426 | |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 427 | } |
Alexandre Julliard | 1a66d22 | 2001-08-28 18:44:52 +0000 | [diff] [blame] | 428 | SERVER_END_REQ; |
Alexandre Julliard | fb0ff05 | 2001-10-16 21:58:58 +0000 | [diff] [blame] | 429 | WIN_ReleasePtr( wndPtr ); |
| 430 | } |
| 431 | |
| 432 | |
| 433 | /*********************************************************************** |
| 434 | * WIN_SetOwner |
| 435 | * |
| 436 | * Change the owner of a window. |
| 437 | */ |
Alexandre Julliard | 7dafa61 | 2002-09-25 00:21:56 +0000 | [diff] [blame] | 438 | HWND WIN_SetOwner( HWND hwnd, HWND owner ) |
Alexandre Julliard | fb0ff05 | 2001-10-16 21:58:58 +0000 | [diff] [blame] | 439 | { |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 440 | WND *win = WIN_GetPtr( hwnd ); |
Alexandre Julliard | 7dafa61 | 2002-09-25 00:21:56 +0000 | [diff] [blame] | 441 | HWND ret = 0; |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 442 | |
Alexandre Julliard | 7dafa61 | 2002-09-25 00:21:56 +0000 | [diff] [blame] | 443 | if (!win) return 0; |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 444 | if (win == WND_OTHER_PROCESS) |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 445 | { |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 446 | if (IsWindow(hwnd)) ERR( "cannot set owner %x on other process window %x\n", owner, hwnd ); |
Alexandre Julliard | 7dafa61 | 2002-09-25 00:21:56 +0000 | [diff] [blame] | 447 | return 0; |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 448 | } |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 449 | SERVER_START_REQ( set_window_owner ) |
| 450 | { |
| 451 | req->handle = hwnd; |
| 452 | req->owner = owner; |
Alexandre Julliard | 7dafa61 | 2002-09-25 00:21:56 +0000 | [diff] [blame] | 453 | if (!wine_server_call( req )) |
| 454 | { |
| 455 | win->owner = reply->full_owner; |
| 456 | ret = reply->prev_owner; |
| 457 | } |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 458 | } |
| 459 | SERVER_END_REQ; |
| 460 | WIN_ReleasePtr( win ); |
Alexandre Julliard | 7dafa61 | 2002-09-25 00:21:56 +0000 | [diff] [blame] | 461 | return ret; |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 462 | } |
| 463 | |
| 464 | |
| 465 | /*********************************************************************** |
| 466 | * WIN_SetStyle |
| 467 | * |
| 468 | * Change the style of a window. |
| 469 | */ |
| 470 | LONG WIN_SetStyle( HWND hwnd, LONG style ) |
| 471 | { |
| 472 | BOOL ok; |
| 473 | LONG ret = 0; |
| 474 | WND *win = WIN_GetPtr( hwnd ); |
| 475 | |
| 476 | if (!win) return 0; |
| 477 | if (win == WND_OTHER_PROCESS) |
| 478 | { |
| 479 | if (IsWindow(hwnd)) |
| 480 | ERR( "cannot set style %lx on other process window %x\n", style, hwnd ); |
| 481 | return 0; |
| 482 | } |
| 483 | if (style == win->dwStyle) |
| 484 | { |
| 485 | WIN_ReleasePtr( win ); |
| 486 | return style; |
| 487 | } |
| 488 | SERVER_START_REQ( set_window_info ) |
| 489 | { |
| 490 | req->handle = hwnd; |
| 491 | req->flags = SET_WIN_STYLE; |
| 492 | req->style = style; |
Alexandre Julliard | 9caa71e | 2001-11-30 18:46:42 +0000 | [diff] [blame] | 493 | if ((ok = !wine_server_call( req ))) |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 494 | { |
Alexandre Julliard | 9caa71e | 2001-11-30 18:46:42 +0000 | [diff] [blame] | 495 | ret = reply->old_style; |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 496 | win->dwStyle = style; |
| 497 | } |
| 498 | } |
| 499 | SERVER_END_REQ; |
| 500 | WIN_ReleasePtr( win ); |
| 501 | if (ok && USER_Driver.pSetWindowStyle) USER_Driver.pSetWindowStyle( hwnd, ret ); |
| 502 | return ret; |
| 503 | } |
| 504 | |
| 505 | |
| 506 | /*********************************************************************** |
| 507 | * WIN_SetExStyle |
| 508 | * |
| 509 | * Change the extended style of a window. |
| 510 | */ |
| 511 | LONG WIN_SetExStyle( HWND hwnd, LONG style ) |
| 512 | { |
| 513 | LONG ret = 0; |
| 514 | WND *win = WIN_GetPtr( hwnd ); |
| 515 | |
| 516 | if (!win) return 0; |
| 517 | if (win == WND_OTHER_PROCESS) |
| 518 | { |
| 519 | if (IsWindow(hwnd)) |
| 520 | ERR( "cannot set exstyle %lx on other process window %x\n", style, hwnd ); |
| 521 | return 0; |
| 522 | } |
| 523 | if (style == win->dwExStyle) |
| 524 | { |
| 525 | WIN_ReleasePtr( win ); |
| 526 | return style; |
| 527 | } |
| 528 | SERVER_START_REQ( set_window_info ) |
| 529 | { |
| 530 | req->handle = hwnd; |
| 531 | req->flags = SET_WIN_EXSTYLE; |
| 532 | req->ex_style = style; |
Alexandre Julliard | 9caa71e | 2001-11-30 18:46:42 +0000 | [diff] [blame] | 533 | if (!wine_server_call( req )) |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 534 | { |
Alexandre Julliard | 9caa71e | 2001-11-30 18:46:42 +0000 | [diff] [blame] | 535 | ret = reply->old_ex_style; |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 536 | win->dwExStyle = style; |
| 537 | } |
| 538 | } |
| 539 | SERVER_END_REQ; |
| 540 | WIN_ReleasePtr( win ); |
| 541 | return ret; |
Alexandre Julliard | 80593bf | 2001-10-11 20:49:40 +0000 | [diff] [blame] | 542 | } |
Alexandre Julliard | 1a66d22 | 2001-08-28 18:44:52 +0000 | [diff] [blame] | 543 | |
Alexandre Julliard | 80593bf | 2001-10-11 20:49:40 +0000 | [diff] [blame] | 544 | |
| 545 | /*********************************************************************** |
Alexandre Julliard | fb0ff05 | 2001-10-16 21:58:58 +0000 | [diff] [blame] | 546 | * WIN_SetRectangles |
| 547 | * |
| 548 | * Set the window and client rectangles. |
| 549 | */ |
| 550 | void WIN_SetRectangles( HWND hwnd, const RECT *rectWindow, const RECT *rectClient ) |
| 551 | { |
| 552 | WND *win = WIN_GetPtr( hwnd ); |
| 553 | BOOL ret; |
| 554 | |
| 555 | if (!win) return; |
| 556 | if (win == WND_OTHER_PROCESS) |
| 557 | { |
| 558 | if (IsWindow( hwnd )) ERR( "cannot set rectangles of other process window %x\n", hwnd ); |
| 559 | return; |
| 560 | } |
| 561 | SERVER_START_REQ( set_window_rectangles ) |
| 562 | { |
| 563 | req->handle = hwnd; |
| 564 | req->window.left = rectWindow->left; |
| 565 | req->window.top = rectWindow->top; |
| 566 | req->window.right = rectWindow->right; |
| 567 | req->window.bottom = rectWindow->bottom; |
| 568 | req->client.left = rectClient->left; |
| 569 | req->client.top = rectClient->top; |
| 570 | req->client.right = rectClient->right; |
| 571 | req->client.bottom = rectClient->bottom; |
Alexandre Julliard | 9caa71e | 2001-11-30 18:46:42 +0000 | [diff] [blame] | 572 | ret = !wine_server_call( req ); |
Alexandre Julliard | fb0ff05 | 2001-10-16 21:58:58 +0000 | [diff] [blame] | 573 | } |
| 574 | SERVER_END_REQ; |
| 575 | if (ret) |
| 576 | { |
| 577 | win->rectWindow = *rectWindow; |
| 578 | win->rectClient = *rectClient; |
| 579 | |
| 580 | TRACE( "win %x window (%d,%d)-(%d,%d) client (%d,%d)-(%d,%d)\n", hwnd, |
| 581 | rectWindow->left, rectWindow->top, rectWindow->right, rectWindow->bottom, |
| 582 | rectClient->left, rectClient->top, rectClient->right, rectClient->bottom ); |
| 583 | } |
| 584 | WIN_ReleasePtr( win ); |
| 585 | } |
| 586 | |
| 587 | |
| 588 | /*********************************************************************** |
Alexandre Julliard | 5797fbb | 2001-12-06 22:33:58 +0000 | [diff] [blame] | 589 | * WIN_GetRectangles |
| 590 | * |
| 591 | * Get the window and client rectangles. |
| 592 | */ |
| 593 | BOOL WIN_GetRectangles( HWND hwnd, RECT *rectWindow, RECT *rectClient ) |
| 594 | { |
| 595 | WND *win = WIN_GetPtr( hwnd ); |
| 596 | BOOL ret = TRUE; |
| 597 | |
| 598 | if (!win) return FALSE; |
| 599 | if (win == WND_OTHER_PROCESS) |
| 600 | { |
| 601 | SERVER_START_REQ( get_window_rectangles ) |
| 602 | { |
| 603 | req->handle = hwnd; |
| 604 | if ((ret = !wine_server_call( req ))) |
| 605 | { |
| 606 | if (rectWindow) |
| 607 | { |
| 608 | rectWindow->left = reply->window.left; |
| 609 | rectWindow->top = reply->window.top; |
| 610 | rectWindow->right = reply->window.right; |
| 611 | rectWindow->bottom = reply->window.bottom; |
| 612 | } |
| 613 | if (rectClient) |
| 614 | { |
| 615 | rectClient->left = reply->client.left; |
| 616 | rectClient->top = reply->client.top; |
| 617 | rectClient->right = reply->client.right; |
| 618 | rectClient->bottom = reply->client.bottom; |
| 619 | } |
| 620 | } |
| 621 | } |
| 622 | SERVER_END_REQ; |
| 623 | } |
| 624 | else |
| 625 | { |
| 626 | if (rectWindow) *rectWindow = win->rectWindow; |
| 627 | if (rectClient) *rectClient = win->rectClient; |
| 628 | WIN_ReleasePtr( win ); |
| 629 | } |
| 630 | return ret; |
| 631 | } |
| 632 | |
| 633 | |
| 634 | /*********************************************************************** |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 635 | * WIN_DestroyWindow |
| 636 | * |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 637 | * Destroy storage associated to a window. "Internals" p.358 |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 638 | */ |
Alexandre Julliard | fb0ff05 | 2001-10-16 21:58:58 +0000 | [diff] [blame] | 639 | LRESULT WIN_DestroyWindow( HWND hwnd ) |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 640 | { |
Alexandre Julliard | 80593bf | 2001-10-11 20:49:40 +0000 | [diff] [blame] | 641 | WND *wndPtr; |
| 642 | HWND *list; |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 643 | |
Alexandre Julliard | 80593bf | 2001-10-11 20:49:40 +0000 | [diff] [blame] | 644 | TRACE("%04x\n", hwnd ); |
Alexandre Julliard | 75d86e1 | 1996-11-17 18:59:11 +0000 | [diff] [blame] | 645 | |
Alexandre Julliard | fb0ff05 | 2001-10-16 21:58:58 +0000 | [diff] [blame] | 646 | if (!(hwnd = WIN_IsCurrentThread( hwnd ))) |
| 647 | { |
| 648 | ERR( "window doesn't belong to current thread\n" ); |
| 649 | return 0; |
| 650 | } |
| 651 | |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 652 | /* free child windows */ |
Alexandre Julliard | 80593bf | 2001-10-11 20:49:40 +0000 | [diff] [blame] | 653 | if ((list = WIN_ListChildren( hwnd ))) |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 654 | { |
Alexandre Julliard | 80593bf | 2001-10-11 20:49:40 +0000 | [diff] [blame] | 655 | int i; |
Alexandre Julliard | fb0ff05 | 2001-10-16 21:58:58 +0000 | [diff] [blame] | 656 | for (i = 0; list[i]; i++) |
| 657 | { |
| 658 | if (WIN_IsCurrentThread( list[i] )) WIN_DestroyWindow( list[i] ); |
| 659 | else SendMessageW( list[i], WM_WINE_DESTROYWINDOW, 0, 0 ); |
| 660 | } |
Alexandre Julliard | 80593bf | 2001-10-11 20:49:40 +0000 | [diff] [blame] | 661 | HeapFree( GetProcessHeap(), 0, list ); |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 662 | } |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 663 | |
Francis Beaudet | 7c2f0fe | 1999-03-21 08:50:41 +0000 | [diff] [blame] | 664 | /* |
| 665 | * Clear the update region to make sure no WM_PAINT messages will be |
| 666 | * generated for this window while processing the WM_NCDESTROY. |
| 667 | */ |
Alexandre Julliard | 80593bf | 2001-10-11 20:49:40 +0000 | [diff] [blame] | 668 | RedrawWindow( hwnd, NULL, 0, |
Alexandre Julliard | 4b0343d | 2001-06-20 22:55:31 +0000 | [diff] [blame] | 669 | RDW_VALIDATE | RDW_NOFRAME | RDW_NOERASE | RDW_NOINTERNALPAINT | RDW_NOCHILDREN); |
Francis Beaudet | 7c2f0fe | 1999-03-21 08:50:41 +0000 | [diff] [blame] | 670 | |
| 671 | /* |
| 672 | * Send the WM_NCDESTROY to the window being destroyed. |
| 673 | */ |
Alexandre Julliard | 80593bf | 2001-10-11 20:49:40 +0000 | [diff] [blame] | 674 | SendMessageA( hwnd, WM_NCDESTROY, 0, 0); |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 675 | |
| 676 | /* FIXME: do we need to fake QS_MOUSEMOVE wakebit? */ |
| 677 | |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 678 | WINPOS_CheckInternalPos( hwnd ); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 679 | if( hwnd == GetCapture()) ReleaseCapture(); |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 680 | |
| 681 | /* free resources associated with the window */ |
| 682 | |
Alexandre Julliard | 80593bf | 2001-10-11 20:49:40 +0000 | [diff] [blame] | 683 | TIMER_RemoveWindowTimers( hwnd ); |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 684 | |
Alexandre Julliard | fb0ff05 | 2001-10-16 21:58:58 +0000 | [diff] [blame] | 685 | if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return 0; |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 686 | |
| 687 | if (!(wndPtr->dwStyle & WS_CHILD)) |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 688 | { |
| 689 | HMENU menu = (HMENU)SetWindowLongW( hwnd, GWL_ID, 0 ); |
| 690 | if (menu) DestroyMenu( menu ); |
| 691 | } |
Guy Albertelli | 38db098 | 2000-05-11 00:06:38 +0000 | [diff] [blame] | 692 | if (wndPtr->hSysMenu) |
| 693 | { |
| 694 | DestroyMenu( wndPtr->hSysMenu ); |
| 695 | wndPtr->hSysMenu = 0; |
| 696 | } |
Alexandre Julliard | 80593bf | 2001-10-11 20:49:40 +0000 | [diff] [blame] | 697 | USER_Driver.pDestroyWindow( hwnd ); |
| 698 | DCE_FreeWindowDCE( hwnd ); /* Always do this to catch orphaned DCs */ |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 699 | WINPROC_FreeProc( wndPtr->winproc, WIN_PROC_WINDOW ); |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 700 | CLASS_RemoveWindow( wndPtr->class ); |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 701 | wndPtr->class = NULL; |
Alexandre Julliard | 9ae0fe5 | 2001-04-24 23:28:52 +0000 | [diff] [blame] | 702 | wndPtr->dwMagic = 0; /* Mark it as invalid */ |
Alexandre Julliard | 80593bf | 2001-10-11 20:49:40 +0000 | [diff] [blame] | 703 | WIN_ReleaseWndPtr( wndPtr ); |
Alexandre Julliard | fb0ff05 | 2001-10-16 21:58:58 +0000 | [diff] [blame] | 704 | return 0; |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 705 | } |
| 706 | |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 707 | /*********************************************************************** |
Alexandre Julliard | 4b0343d | 2001-06-20 22:55:31 +0000 | [diff] [blame] | 708 | * WIN_DestroyThreadWindows |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 709 | * |
Alexandre Julliard | 4b0343d | 2001-06-20 22:55:31 +0000 | [diff] [blame] | 710 | * Destroy all children of 'wnd' owned by the current thread. |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 711 | * Return TRUE if something was done. |
Alexandre Julliard | 2ace16a | 1996-04-28 15:09:19 +0000 | [diff] [blame] | 712 | */ |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 713 | void WIN_DestroyThreadWindows( HWND hwnd ) |
Alexandre Julliard | 2ace16a | 1996-04-28 15:09:19 +0000 | [diff] [blame] | 714 | { |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 715 | HWND *list; |
| 716 | int i; |
Alexandre Julliard | 2ace16a | 1996-04-28 15:09:19 +0000 | [diff] [blame] | 717 | |
Alexandre Julliard | 9d9dac0 | 2001-08-24 19:28:21 +0000 | [diff] [blame] | 718 | if (!(list = WIN_ListChildren( hwnd ))) return; |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 719 | for (i = 0; list[i]; i++) |
Alexandre Julliard | 2ace16a | 1996-04-28 15:09:19 +0000 | [diff] [blame] | 720 | { |
Alexandre Julliard | 7695d69 | 2001-09-24 01:19:59 +0000 | [diff] [blame] | 721 | if (WIN_IsCurrentThread( list[i] )) |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 722 | DestroyWindow( list[i] ); |
| 723 | else |
| 724 | WIN_DestroyThreadWindows( list[i] ); |
Alexandre Julliard | 2ace16a | 1996-04-28 15:09:19 +0000 | [diff] [blame] | 725 | } |
Alexandre Julliard | 9d9dac0 | 2001-08-24 19:28:21 +0000 | [diff] [blame] | 726 | HeapFree( GetProcessHeap(), 0, list ); |
Alexandre Julliard | 2ace16a | 1996-04-28 15:09:19 +0000 | [diff] [blame] | 727 | } |
| 728 | |
Alexandre Julliard | 2ace16a | 1996-04-28 15:09:19 +0000 | [diff] [blame] | 729 | /*********************************************************************** |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 730 | * WIN_CreateDesktopWindow |
| 731 | * |
| 732 | * Create the desktop window. |
| 733 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 734 | BOOL WIN_CreateDesktopWindow(void) |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 735 | { |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 736 | struct tagCLASS *class; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 737 | HWND hwndDesktop; |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 738 | INT wndExtra; |
| 739 | DWORD clsStyle; |
| 740 | WNDPROC winproc; |
| 741 | DCE *dce; |
Alexandre Julliard | dc4fe77 | 2001-06-04 21:55:17 +0000 | [diff] [blame] | 742 | CREATESTRUCTA cs; |
Alexandre Julliard | fb0ff05 | 2001-10-16 21:58:58 +0000 | [diff] [blame] | 743 | RECT rect; |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 744 | |
Dimitrie O. Paun | dd03cc1 | 1999-12-08 03:56:23 +0000 | [diff] [blame] | 745 | TRACE("Creating desktop window\n"); |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 746 | |
Alexandre Julliard | 91222da | 2000-12-10 23:01:33 +0000 | [diff] [blame] | 747 | if (!WINPOS_CreateInternalPosAtom() || |
| 748 | !(class = CLASS_AddWindow( (ATOM)LOWORD(DESKTOP_CLASS_ATOM), 0, WIN_PROC_32W, |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 749 | &wndExtra, &winproc, &clsStyle, &dce ))) |
| 750 | return FALSE; |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 751 | |
Alexandre Julliard | 844ceb9 | 2001-10-09 23:26:40 +0000 | [diff] [blame] | 752 | pWndDesktop = create_window_handle( 0, 0, LOWORD(DESKTOP_CLASS_ATOM), |
| 753 | sizeof(WND) + wndExtra - sizeof(pWndDesktop->wExtra) ); |
Alexandre Julliard | 1a66d22 | 2001-08-28 18:44:52 +0000 | [diff] [blame] | 754 | if (!pWndDesktop) return FALSE; |
| 755 | hwndDesktop = pWndDesktop->hwndSelf; |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 756 | |
Alexandre Julliard | 1a66d22 | 2001-08-28 18:44:52 +0000 | [diff] [blame] | 757 | pWndDesktop->tid = 0; /* nobody owns the desktop */ |
Alexandre Julliard | 556607a | 2001-10-10 20:28:17 +0000 | [diff] [blame] | 758 | pWndDesktop->parent = 0; |
Alexandre Julliard | 9d9dac0 | 2001-08-24 19:28:21 +0000 | [diff] [blame] | 759 | pWndDesktop->owner = 0; |
Alexandre Julliard | 2ace16a | 1996-04-28 15:09:19 +0000 | [diff] [blame] | 760 | pWndDesktop->class = class; |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 761 | pWndDesktop->text = NULL; |
Alexandre Julliard | 59730ae | 1996-03-24 16:20:51 +0000 | [diff] [blame] | 762 | pWndDesktop->hrgnUpdate = 0; |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 763 | pWndDesktop->clsStyle = clsStyle; |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 764 | pWndDesktop->dce = NULL; |
Alexandre Julliard | ca22b33 | 1996-07-12 19:02:39 +0000 | [diff] [blame] | 765 | pWndDesktop->pVScroll = NULL; |
| 766 | pWndDesktop->pHScroll = NULL; |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 767 | pWndDesktop->helpContext = 0; |
Alexandre Julliard | 26320d1 | 2001-03-23 23:45:45 +0000 | [diff] [blame] | 768 | pWndDesktop->flags = 0; |
Alexandre Julliard | 59730ae | 1996-03-24 16:20:51 +0000 | [diff] [blame] | 769 | pWndDesktop->hSysMenu = 0; |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 770 | pWndDesktop->winproc = winproc; |
| 771 | pWndDesktop->cbWndExtra = wndExtra; |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 772 | |
Alexandre Julliard | dc4fe77 | 2001-06-04 21:55:17 +0000 | [diff] [blame] | 773 | cs.lpCreateParams = NULL; |
| 774 | cs.hInstance = 0; |
| 775 | cs.hMenu = 0; |
| 776 | cs.hwndParent = 0; |
| 777 | cs.x = 0; |
| 778 | cs.y = 0; |
Alexandre Julliard | fb0ff05 | 2001-10-16 21:58:58 +0000 | [diff] [blame] | 779 | cs.cx = GetSystemMetrics( SM_CXSCREEN ); |
| 780 | cs.cy = GetSystemMetrics( SM_CYSCREEN ); |
Alexandre Julliard | dc4fe77 | 2001-06-04 21:55:17 +0000 | [diff] [blame] | 781 | cs.style = pWndDesktop->dwStyle; |
| 782 | cs.dwExStyle = pWndDesktop->dwExStyle; |
| 783 | cs.lpszName = NULL; |
| 784 | cs.lpszClass = DESKTOP_CLASS_ATOM; |
Alexandre Julliard | 91222da | 2000-12-10 23:01:33 +0000 | [diff] [blame] | 785 | |
Alexandre Julliard | fb0ff05 | 2001-10-16 21:58:58 +0000 | [diff] [blame] | 786 | SetRect( &rect, 0, 0, cs.cx, cs.cy ); |
| 787 | WIN_SetRectangles( hwndDesktop, &rect, &rect ); |
Alexandre Julliard | 7dafa61 | 2002-09-25 00:21:56 +0000 | [diff] [blame] | 788 | |
| 789 | SERVER_START_REQ( set_window_info ) |
| 790 | { |
| 791 | req->handle = hwndDesktop; |
| 792 | req->flags = 0; /* don't set anything, just retrieve */ |
| 793 | wine_server_call( req ); |
| 794 | pWndDesktop->dwStyle = reply->old_style; |
| 795 | pWndDesktop->dwExStyle = reply->old_ex_style; |
| 796 | pWndDesktop->hInstance = (ULONG_PTR)reply->old_instance; |
| 797 | pWndDesktop->userdata = (ULONG_PTR)reply->old_user_data; |
| 798 | pWndDesktop->wIDmenu = reply->old_id; |
| 799 | } |
| 800 | SERVER_END_REQ; |
Alexandre Julliard | fb0ff05 | 2001-10-16 21:58:58 +0000 | [diff] [blame] | 801 | |
Francois Gouget | 69e3500 | 2002-05-19 22:20:31 +0000 | [diff] [blame] | 802 | if (!USER_Driver.pCreateWindow( hwndDesktop, &cs, FALSE )) |
| 803 | { |
| 804 | WIN_ReleaseWndPtr( pWndDesktop ); |
| 805 | return FALSE; |
| 806 | } |
Alexandre Julliard | dc4fe77 | 2001-06-04 21:55:17 +0000 | [diff] [blame] | 807 | |
Alexandre Julliard | 1e37a18 | 1996-08-18 16:21:52 +0000 | [diff] [blame] | 808 | pWndDesktop->flags |= WIN_NEEDS_ERASEBKGND; |
Alexandre Julliard | 1a66d22 | 2001-08-28 18:44:52 +0000 | [diff] [blame] | 809 | WIN_ReleaseWndPtr( pWndDesktop ); |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 810 | return TRUE; |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 811 | } |
| 812 | |
| 813 | |
| 814 | /*********************************************************************** |
Dmitry Timoshkov | 5956b98 | 2000-11-28 23:53:08 +0000 | [diff] [blame] | 815 | * WIN_FixCoordinates |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 816 | * |
Gerard Patel | 78f52b5 | 2000-05-31 19:23:20 +0000 | [diff] [blame] | 817 | * Fix the coordinates - Helper for WIN_CreateWindowEx. |
| 818 | * returns default show mode in sw. |
| 819 | * Note: the feature presented as undocumented *is* in the MSDN since 1993. |
| 820 | */ |
| 821 | static void WIN_FixCoordinates( CREATESTRUCTA *cs, INT *sw) |
| 822 | { |
| 823 | if (cs->x == CW_USEDEFAULT || cs->x == CW_USEDEFAULT16 || |
| 824 | cs->cx == CW_USEDEFAULT || cs->cx == CW_USEDEFAULT16) |
| 825 | { |
Alexandre Julliard | 6aa2843 | 2000-06-08 01:01:09 +0000 | [diff] [blame] | 826 | if (cs->style & (WS_CHILD | WS_POPUP)) |
Gerard Patel | 78f52b5 | 2000-05-31 19:23:20 +0000 | [diff] [blame] | 827 | { |
Alexandre Julliard | 6aa2843 | 2000-06-08 01:01:09 +0000 | [diff] [blame] | 828 | if (cs->x == CW_USEDEFAULT || cs->x == CW_USEDEFAULT16) cs->x = cs->y = 0; |
| 829 | if (cs->cx == CW_USEDEFAULT || cs->cx == CW_USEDEFAULT16) cs->cx = cs->cy = 0; |
Gerard Patel | 78f52b5 | 2000-05-31 19:23:20 +0000 | [diff] [blame] | 830 | } |
Alexandre Julliard | 6aa2843 | 2000-06-08 01:01:09 +0000 | [diff] [blame] | 831 | else /* overlapped window */ |
Gerard Patel | 78f52b5 | 2000-05-31 19:23:20 +0000 | [diff] [blame] | 832 | { |
Alexandre Julliard | 6aa2843 | 2000-06-08 01:01:09 +0000 | [diff] [blame] | 833 | STARTUPINFOA info; |
| 834 | |
| 835 | GetStartupInfoA( &info ); |
| 836 | |
| 837 | if (cs->x == CW_USEDEFAULT || cs->x == CW_USEDEFAULT16) |
| 838 | { |
Alexandre Julliard | 0d92fe2 | 2001-09-10 23:26:42 +0000 | [diff] [blame] | 839 | /* Never believe Microsoft's documentation... CreateWindowEx doc says |
| 840 | * that if an overlapped window is created with WS_VISIBLE style bit |
Alexandre Julliard | 6aa2843 | 2000-06-08 01:01:09 +0000 | [diff] [blame] | 841 | * set and the x parameter is set to CW_USEDEFAULT, the system ignores |
| 842 | * the y parameter. However, disassembling NT implementation (WIN32K.SYS) |
| 843 | * reveals that |
| 844 | * |
Alexandre Julliard | 0d92fe2 | 2001-09-10 23:26:42 +0000 | [diff] [blame] | 845 | * 1) not only it checks for CW_USEDEFAULT but also for CW_USEDEFAULT16 |
| 846 | * 2) it does not ignore the y parameter as the docs claim; instead, it |
Alexandre Julliard | 6aa2843 | 2000-06-08 01:01:09 +0000 | [diff] [blame] | 847 | * uses it as second parameter to ShowWindow() unless y is either |
| 848 | * CW_USEDEFAULT or CW_USEDEFAULT16. |
Alexandre Julliard | 0d92fe2 | 2001-09-10 23:26:42 +0000 | [diff] [blame] | 849 | * |
Alexandre Julliard | 6aa2843 | 2000-06-08 01:01:09 +0000 | [diff] [blame] | 850 | * The fact that we didn't do 2) caused bogus windows pop up when wine |
Alexandre Julliard | 0d92fe2 | 2001-09-10 23:26:42 +0000 | [diff] [blame] | 851 | * was running apps that were using this obscure feature. Example - |
| 852 | * calc.exe that comes with Win98 (only Win98, it's different from |
Alexandre Julliard | 6aa2843 | 2000-06-08 01:01:09 +0000 | [diff] [blame] | 853 | * the one that comes with Win95 and NT) |
| 854 | */ |
| 855 | if (cs->y != CW_USEDEFAULT && cs->y != CW_USEDEFAULT16) *sw = cs->y; |
| 856 | cs->x = (info.dwFlags & STARTF_USEPOSITION) ? info.dwX : 0; |
| 857 | cs->y = (info.dwFlags & STARTF_USEPOSITION) ? info.dwY : 0; |
| 858 | } |
| 859 | |
| 860 | if (cs->cx == CW_USEDEFAULT || cs->cx == CW_USEDEFAULT16) |
| 861 | { |
| 862 | if (info.dwFlags & STARTF_USESIZE) |
| 863 | { |
| 864 | cs->cx = info.dwXSize; |
| 865 | cs->cy = info.dwYSize; |
| 866 | } |
| 867 | else /* if no other hint from the app, pick 3/4 of the screen real estate */ |
| 868 | { |
| 869 | RECT r; |
| 870 | SystemParametersInfoA( SPI_GETWORKAREA, 0, &r, 0); |
| 871 | cs->cx = (((r.right - r.left) * 3) / 4) - cs->x; |
| 872 | cs->cy = (((r.bottom - r.top) * 3) / 4) - cs->y; |
| 873 | } |
| 874 | } |
Gerard Patel | 78f52b5 | 2000-05-31 19:23:20 +0000 | [diff] [blame] | 875 | } |
| 876 | } |
Guy L. Albertelli | f1a624d | 2002-02-27 01:20:54 +0000 | [diff] [blame] | 877 | else |
| 878 | { |
| 879 | /* neither x nor cx are default. Check the y values . |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 880 | * In the trace we see Outlook and Outlook Express using |
Guy L. Albertelli | f1a624d | 2002-02-27 01:20:54 +0000 | [diff] [blame] | 881 | * cy set to CW_USEDEFAULT when opening the address book. |
| 882 | */ |
| 883 | if (cs->cy == CW_USEDEFAULT || cs->cy == CW_USEDEFAULT16) { |
| 884 | RECT r; |
| 885 | FIXME("Strange use of CW_USEDEFAULT in nHeight\n"); |
| 886 | SystemParametersInfoA( SPI_GETWORKAREA, 0, &r, 0); |
| 887 | cs->cy = (((r.bottom - r.top) * 3) / 4) - cs->y; |
| 888 | } |
| 889 | } |
Gerard Patel | 78f52b5 | 2000-05-31 19:23:20 +0000 | [diff] [blame] | 890 | } |
| 891 | |
| 892 | /*********************************************************************** |
Dmitry Timoshkov | 5d3e1f7 | 2001-11-07 21:52:24 +0000 | [diff] [blame] | 893 | * dump_window_styles |
| 894 | */ |
| 895 | static void dump_window_styles( DWORD style, DWORD exstyle ) |
| 896 | { |
| 897 | TRACE( "style:" ); |
| 898 | if(style & WS_POPUP) DPRINTF(" WS_POPUP"); |
| 899 | if(style & WS_CHILD) DPRINTF(" WS_CHILD"); |
| 900 | if(style & WS_MINIMIZE) DPRINTF(" WS_MINIMIZE"); |
| 901 | if(style & WS_VISIBLE) DPRINTF(" WS_VISIBLE"); |
| 902 | if(style & WS_DISABLED) DPRINTF(" WS_DISABLED"); |
| 903 | if(style & WS_CLIPSIBLINGS) DPRINTF(" WS_CLIPSIBLINGS"); |
| 904 | if(style & WS_CLIPCHILDREN) DPRINTF(" WS_CLIPCHILDREN"); |
| 905 | if(style & WS_MAXIMIZE) DPRINTF(" WS_MAXIMIZE"); |
| 906 | if((style & WS_CAPTION) == WS_CAPTION) DPRINTF(" WS_CAPTION"); |
| 907 | else |
| 908 | { |
| 909 | if(style & WS_BORDER) DPRINTF(" WS_BORDER"); |
| 910 | if(style & WS_DLGFRAME) DPRINTF(" WS_DLGFRAME"); |
| 911 | } |
| 912 | if(style & WS_VSCROLL) DPRINTF(" WS_VSCROLL"); |
| 913 | if(style & WS_HSCROLL) DPRINTF(" WS_HSCROLL"); |
| 914 | if(style & WS_SYSMENU) DPRINTF(" WS_SYSMENU"); |
| 915 | if(style & WS_THICKFRAME) DPRINTF(" WS_THICKFRAME"); |
| 916 | if(style & WS_GROUP) DPRINTF(" WS_GROUP"); |
| 917 | if(style & WS_TABSTOP) DPRINTF(" WS_TABSTOP"); |
| 918 | if(style & WS_MINIMIZEBOX) DPRINTF(" WS_MINIMIZEBOX"); |
| 919 | if(style & WS_MAXIMIZEBOX) DPRINTF(" WS_MAXIMIZEBOX"); |
| 920 | |
| 921 | /* FIXME: Add dumping of BS_/ES_/SBS_/LBS_/CBS_/DS_/etc. styles */ |
| 922 | #define DUMPED_STYLES \ |
| 923 | (WS_POPUP | \ |
| 924 | WS_CHILD | \ |
| 925 | WS_MINIMIZE | \ |
| 926 | WS_VISIBLE | \ |
| 927 | WS_DISABLED | \ |
| 928 | WS_CLIPSIBLINGS | \ |
| 929 | WS_CLIPCHILDREN | \ |
| 930 | WS_MAXIMIZE | \ |
| 931 | WS_BORDER | \ |
| 932 | WS_DLGFRAME | \ |
| 933 | WS_VSCROLL | \ |
| 934 | WS_HSCROLL | \ |
| 935 | WS_SYSMENU | \ |
| 936 | WS_THICKFRAME | \ |
| 937 | WS_GROUP | \ |
| 938 | WS_TABSTOP | \ |
| 939 | WS_MINIMIZEBOX | \ |
| 940 | WS_MAXIMIZEBOX) |
| 941 | |
| 942 | if(style & ~DUMPED_STYLES) DPRINTF(" %08lx", style & ~DUMPED_STYLES); |
| 943 | DPRINTF("\n"); |
| 944 | #undef DUMPED_STYLES |
| 945 | |
| 946 | TRACE( "exstyle:" ); |
| 947 | if(exstyle & WS_EX_DLGMODALFRAME) DPRINTF(" WS_EX_DLGMODALFRAME"); |
| 948 | if(exstyle & WS_EX_DRAGDETECT) DPRINTF(" WS_EX_DRAGDETECT"); |
| 949 | if(exstyle & WS_EX_NOPARENTNOTIFY) DPRINTF(" WS_EX_NOPARENTNOTIFY"); |
| 950 | if(exstyle & WS_EX_TOPMOST) DPRINTF(" WS_EX_TOPMOST"); |
| 951 | if(exstyle & WS_EX_ACCEPTFILES) DPRINTF(" WS_EX_ACCEPTFILES"); |
| 952 | if(exstyle & WS_EX_TRANSPARENT) DPRINTF(" WS_EX_TRANSPARENT"); |
| 953 | if(exstyle & WS_EX_MDICHILD) DPRINTF(" WS_EX_MDICHILD"); |
| 954 | if(exstyle & WS_EX_TOOLWINDOW) DPRINTF(" WS_EX_TOOLWINDOW"); |
| 955 | if(exstyle & WS_EX_WINDOWEDGE) DPRINTF(" WS_EX_WINDOWEDGE"); |
| 956 | if(exstyle & WS_EX_CLIENTEDGE) DPRINTF(" WS_EX_CLIENTEDGE"); |
| 957 | if(exstyle & WS_EX_CONTEXTHELP) DPRINTF(" WS_EX_CONTEXTHELP"); |
| 958 | if(exstyle & WS_EX_RIGHT) DPRINTF(" WS_EX_RIGHT"); |
| 959 | if(exstyle & WS_EX_RTLREADING) DPRINTF(" WS_EX_RTLREADING"); |
| 960 | if(exstyle & WS_EX_LEFTSCROLLBAR) DPRINTF(" WS_EX_LEFTSCROLLBAR"); |
| 961 | if(exstyle & WS_EX_CONTROLPARENT) DPRINTF(" WS_EX_CONTROLPARENT"); |
| 962 | if(exstyle & WS_EX_STATICEDGE) DPRINTF(" WS_EX_STATICEDGE"); |
| 963 | if(exstyle & WS_EX_APPWINDOW) DPRINTF(" WS_EX_APPWINDOW"); |
| 964 | if(exstyle & WS_EX_LAYERED) DPRINTF(" WS_EX_LAYERED"); |
| 965 | |
| 966 | #define DUMPED_EX_STYLES \ |
| 967 | (WS_EX_DLGMODALFRAME | \ |
| 968 | WS_EX_DRAGDETECT | \ |
| 969 | WS_EX_NOPARENTNOTIFY | \ |
| 970 | WS_EX_TOPMOST | \ |
| 971 | WS_EX_ACCEPTFILES | \ |
| 972 | WS_EX_TRANSPARENT | \ |
| 973 | WS_EX_MDICHILD | \ |
| 974 | WS_EX_TOOLWINDOW | \ |
| 975 | WS_EX_WINDOWEDGE | \ |
| 976 | WS_EX_CLIENTEDGE | \ |
| 977 | WS_EX_CONTEXTHELP | \ |
| 978 | WS_EX_RIGHT | \ |
| 979 | WS_EX_RTLREADING | \ |
| 980 | WS_EX_LEFTSCROLLBAR | \ |
| 981 | WS_EX_CONTROLPARENT | \ |
| 982 | WS_EX_STATICEDGE | \ |
| 983 | WS_EX_APPWINDOW | \ |
| 984 | WS_EX_LAYERED) |
| 985 | |
| 986 | if(exstyle & ~DUMPED_EX_STYLES) DPRINTF(" %08lx", exstyle & ~DUMPED_EX_STYLES); |
| 987 | DPRINTF("\n"); |
| 988 | #undef DUMPED_EX_STYLES |
| 989 | } |
| 990 | |
| 991 | |
| 992 | /*********************************************************************** |
Gerard Patel | 78f52b5 | 2000-05-31 19:23:20 +0000 | [diff] [blame] | 993 | * WIN_CreateWindowEx |
| 994 | * |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 995 | * Implementation of CreateWindowEx(). |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 996 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 997 | static HWND WIN_CreateWindowEx( CREATESTRUCTA *cs, ATOM classAtom, |
Dmitry Timoshkov | 5956b98 | 2000-11-28 23:53:08 +0000 | [diff] [blame] | 998 | WINDOWPROCTYPE type ) |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 999 | { |
Alexandre Julliard | 0d92fe2 | 2001-09-10 23:26:42 +0000 | [diff] [blame] | 1000 | INT sw = SW_SHOW; |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 1001 | struct tagCLASS *classPtr; |
Alexandre Julliard | d2e1c1a | 1996-03-09 16:12:43 +0000 | [diff] [blame] | 1002 | WND *wndPtr; |
Rein Klazes | 0f2f2b3 | 2002-01-09 19:09:06 +0000 | [diff] [blame] | 1003 | HWND hwnd, parent, owner; |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 1004 | INT wndExtra; |
| 1005 | DWORD clsStyle; |
| 1006 | WNDPROC winproc; |
| 1007 | DCE *dce; |
Gerard Patel | ad36303 | 2001-06-06 21:26:50 +0000 | [diff] [blame] | 1008 | BOOL unicode = (type == WIN_PROC_32W); |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 1009 | |
Alexandre Julliard | f44bbb8 | 2001-09-14 00:24:39 +0000 | [diff] [blame] | 1010 | TRACE("%s %s ex=%08lx style=%08lx %d,%d %dx%d parent=%04x menu=%04x inst=%08x params=%p\n", |
Alexandre Julliard | 0aa28b5 | 2002-05-17 02:55:48 +0000 | [diff] [blame] | 1011 | (type == WIN_PROC_32W) ? debugstr_w((LPWSTR)cs->lpszName) : debugstr_a(cs->lpszName), |
| 1012 | (type == WIN_PROC_32W) ? debugstr_w((LPWSTR)cs->lpszClass) : debugstr_a(cs->lpszClass), |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 1013 | cs->dwExStyle, cs->style, cs->x, cs->y, cs->cx, cs->cy, |
| 1014 | cs->hwndParent, cs->hMenu, cs->hInstance, cs->lpCreateParams ); |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 1015 | |
Dmitry Timoshkov | 5d3e1f7 | 2001-11-07 21:52:24 +0000 | [diff] [blame] | 1016 | if(TRACE_ON(win)) dump_window_styles( cs->style, cs->dwExStyle ); |
| 1017 | |
Dmitry Timoshkov | 5956b98 | 2000-11-28 23:53:08 +0000 | [diff] [blame] | 1018 | TRACE("winproc type is %d (%s)\n", type, (type == WIN_PROC_16) ? "WIN_PROC_16" : |
| 1019 | ((type == WIN_PROC_32A) ? "WIN_PROC_32A" : "WIN_PROC_32W") ); |
| 1020 | |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1021 | /* Find the parent window */ |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 1022 | |
Alexandre Julliard | a09da0c | 2001-09-21 21:08:40 +0000 | [diff] [blame] | 1023 | parent = GetDesktopWindow(); |
| 1024 | owner = 0; |
Juergen Schmied | eb2db1a | 2002-08-29 01:49:46 +0000 | [diff] [blame] | 1025 | |
| 1026 | if (cs->hwndParent == HWND_MESSAGE) |
| 1027 | { |
| 1028 | /* native ole32.OleInitialize uses HWND_MESSAGE to create the |
| 1029 | * message window (style: WS_POPUP|WS_DISABLED) |
| 1030 | */ |
| 1031 | FIXME("Parent is HWND_MESSAGE\n"); |
| 1032 | } |
| 1033 | else if (cs->hwndParent) |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 1034 | { |
Alexandre Julliard | bd34d4f | 1995-06-20 19:08:12 +0000 | [diff] [blame] | 1035 | /* Make sure parent is valid */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1036 | if (!IsWindow( cs->hwndParent )) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1037 | { |
Dimitrie O. Paun | dd03cc1 | 1999-12-08 03:56:23 +0000 | [diff] [blame] | 1038 | WARN("Bad parent %04x\n", cs->hwndParent ); |
Alexandre Julliard | bd34d4f | 1995-06-20 19:08:12 +0000 | [diff] [blame] | 1039 | return 0; |
Alexandre Julliard | fa68b75 | 1995-04-03 16:55:37 +0000 | [diff] [blame] | 1040 | } |
Alexandre Julliard | 7dafa61 | 2002-09-25 00:21:56 +0000 | [diff] [blame] | 1041 | if ((cs->style & (WS_CHILD|WS_POPUP)) == WS_CHILD) |
| 1042 | parent = WIN_GetFullHandle(cs->hwndParent); |
| 1043 | else |
| 1044 | owner = GetAncestor( cs->hwndParent, GA_ROOT ); |
Alexandre Julliard | a09da0c | 2001-09-21 21:08:40 +0000 | [diff] [blame] | 1045 | } |
Alexandre Julliard | 7dafa61 | 2002-09-25 00:21:56 +0000 | [diff] [blame] | 1046 | else if ((cs->style & (WS_CHILD|WS_POPUP)) == WS_CHILD) |
Alexandre Julliard | a09da0c | 2001-09-21 21:08:40 +0000 | [diff] [blame] | 1047 | { |
Dimitrie O. Paun | dd03cc1 | 1999-12-08 03:56:23 +0000 | [diff] [blame] | 1048 | WARN("No parent for child window\n" ); |
Alexandre Julliard | 3db94ef | 1997-09-28 17:43:24 +0000 | [diff] [blame] | 1049 | return 0; /* WS_CHILD needs a parent, but WS_POPUP doesn't */ |
Alexandre Julliard | bd34d4f | 1995-06-20 19:08:12 +0000 | [diff] [blame] | 1050 | } |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 1051 | |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1052 | /* Find the window class */ |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 1053 | if (!(classPtr = CLASS_AddWindow( classAtom, cs->hInstance, type, |
| 1054 | &wndExtra, &winproc, &clsStyle, &dce ))) |
Alexandre Julliard | 808cb04 | 1995-08-17 17:11:36 +0000 | [diff] [blame] | 1055 | { |
Gerard Patel | 6fdb5dd | 2000-02-16 21:23:24 +0000 | [diff] [blame] | 1056 | WARN("Bad class '%s'\n", cs->lpszClass ); |
Alexandre Julliard | ff8331e | 1995-09-18 11:19:54 +0000 | [diff] [blame] | 1057 | return 0; |
Alexandre Julliard | bd34d4f | 1995-06-20 19:08:12 +0000 | [diff] [blame] | 1058 | } |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 1059 | |
Gerard Patel | 78f52b5 | 2000-05-31 19:23:20 +0000 | [diff] [blame] | 1060 | WIN_FixCoordinates(cs, &sw); /* fix default coordinates */ |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 1061 | |
Bill Medland | 3f68bc9 | 2001-07-20 18:36:25 +0000 | [diff] [blame] | 1062 | /* Correct the window style - stage 1 |
| 1063 | * |
| 1064 | * These are patches that appear to affect both the style loaded into the |
| 1065 | * WIN structure and passed in the CreateStruct to the WM_CREATE etc. |
| 1066 | * |
Alexandre Julliard | 0d92fe2 | 2001-09-10 23:26:42 +0000 | [diff] [blame] | 1067 | * WS_EX_WINDOWEDGE appears to be enforced based on the other styles, so |
Bill Medland | 3f68bc9 | 2001-07-20 18:36:25 +0000 | [diff] [blame] | 1068 | * why does the user get to set it? |
| 1069 | */ |
| 1070 | |
| 1071 | /* This has been tested for WS_CHILD | WS_VISIBLE. It has not been |
| 1072 | * tested for WS_POPUP |
| 1073 | */ |
| 1074 | if ((cs->dwExStyle & WS_EX_DLGMODALFRAME) || |
| 1075 | ((!(cs->dwExStyle & WS_EX_STATICEDGE)) && |
| 1076 | (cs->style & (WS_DLGFRAME | WS_THICKFRAME)))) |
| 1077 | cs->dwExStyle |= WS_EX_WINDOWEDGE; |
| 1078 | else |
| 1079 | cs->dwExStyle &= ~WS_EX_WINDOWEDGE; |
| 1080 | |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1081 | /* Create the window structure */ |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 1082 | |
Alexandre Julliard | 844ceb9 | 2001-10-09 23:26:40 +0000 | [diff] [blame] | 1083 | if (!(wndPtr = create_window_handle( parent, owner, classAtom, |
Alexandre Julliard | 1a66d22 | 2001-08-28 18:44:52 +0000 | [diff] [blame] | 1084 | sizeof(*wndPtr) + wndExtra - sizeof(wndPtr->wExtra) ))) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1085 | { |
Dimitrie O. Paun | dd03cc1 | 1999-12-08 03:56:23 +0000 | [diff] [blame] | 1086 | TRACE("out of memory\n" ); |
Alexandre Julliard | bd34d4f | 1995-06-20 19:08:12 +0000 | [diff] [blame] | 1087 | return 0; |
| 1088 | } |
Alexandre Julliard | 1a66d22 | 2001-08-28 18:44:52 +0000 | [diff] [blame] | 1089 | hwnd = wndPtr->hwndSelf; |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 1090 | |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1091 | /* Fill the window structure */ |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 1092 | |
Alexandre Julliard | 80593bf | 2001-10-11 20:49:40 +0000 | [diff] [blame] | 1093 | wndPtr->tid = GetCurrentThreadId(); |
| 1094 | wndPtr->owner = owner; |
Alexandre Julliard | 556607a | 2001-10-10 20:28:17 +0000 | [diff] [blame] | 1095 | wndPtr->parent = parent; |
Alexandre Julliard | 2ace16a | 1996-04-28 15:09:19 +0000 | [diff] [blame] | 1096 | wndPtr->class = classPtr; |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 1097 | wndPtr->winproc = winproc; |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 1098 | wndPtr->hInstance = cs->hInstance; |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1099 | wndPtr->text = NULL; |
Alexandre Julliard | bd34d4f | 1995-06-20 19:08:12 +0000 | [diff] [blame] | 1100 | wndPtr->hrgnUpdate = 0; |
Huw D M Davies | a14ca86 | 2000-07-29 11:31:29 +0000 | [diff] [blame] | 1101 | wndPtr->hrgnWnd = 0; |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 1102 | wndPtr->dwStyle = cs->style & ~WS_VISIBLE; |
| 1103 | wndPtr->dwExStyle = cs->dwExStyle; |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 1104 | wndPtr->clsStyle = clsStyle; |
Alexandre Julliard | bd34d4f | 1995-06-20 19:08:12 +0000 | [diff] [blame] | 1105 | wndPtr->wIDmenu = 0; |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 1106 | wndPtr->helpContext = 0; |
Dmitry Timoshkov | 5956b98 | 2000-11-28 23:53:08 +0000 | [diff] [blame] | 1107 | wndPtr->flags = (type == WIN_PROC_16) ? 0 : WIN_ISWIN32; |
Alexandre Julliard | ca22b33 | 1996-07-12 19:02:39 +0000 | [diff] [blame] | 1108 | wndPtr->pVScroll = NULL; |
| 1109 | wndPtr->pHScroll = NULL; |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 1110 | wndPtr->userdata = 0; |
Alexandre Julliard | 7ff1c41 | 1997-05-25 13:58:18 +0000 | [diff] [blame] | 1111 | wndPtr->hSysMenu = (wndPtr->dwStyle & WS_SYSMENU) |
| 1112 | ? MENU_GetSysMenu( hwnd, 0 ) : 0; |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 1113 | wndPtr->cbWndExtra = wndExtra; |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 1114 | |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 1115 | if (wndExtra) memset( wndPtr->wExtra, 0, wndExtra); |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 1116 | |
Bill Medland | 3f68bc9 | 2001-07-20 18:36:25 +0000 | [diff] [blame] | 1117 | /* Correct the window style - stage 2 */ |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1118 | |
Alex Korobka | 44a1b59 | 1999-04-01 12:03:52 +0000 | [diff] [blame] | 1119 | if (!(cs->style & WS_CHILD)) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1120 | { |
Alex Korobka | 44a1b59 | 1999-04-01 12:03:52 +0000 | [diff] [blame] | 1121 | wndPtr->dwStyle |= WS_CLIPSIBLINGS; |
| 1122 | if (!(cs->style & WS_POPUP)) |
| 1123 | { |
| 1124 | wndPtr->dwStyle |= WS_CAPTION; |
| 1125 | wndPtr->flags |= WIN_NEED_SIZE; |
| 1126 | } |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1127 | } |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 1128 | SERVER_START_REQ( set_window_info ) |
| 1129 | { |
| 1130 | req->handle = hwnd; |
| 1131 | req->flags = SET_WIN_STYLE | SET_WIN_EXSTYLE | SET_WIN_INSTANCE; |
| 1132 | req->style = wndPtr->dwStyle; |
| 1133 | req->ex_style = wndPtr->dwExStyle; |
| 1134 | req->instance = (void *)wndPtr->hInstance; |
Alexandre Julliard | 9caa71e | 2001-11-30 18:46:42 +0000 | [diff] [blame] | 1135 | wine_server_call( req ); |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 1136 | } |
| 1137 | SERVER_END_REQ; |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1138 | |
| 1139 | /* Get class or window DC if needed */ |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 1140 | |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 1141 | if (clsStyle & CS_OWNDC) wndPtr->dce = DCE_AllocDCE(hwnd,DCE_WINDOW_DC); |
| 1142 | else if (clsStyle & CS_CLASSDC) wndPtr->dce = dce; |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 1143 | else wndPtr->dce = NULL; |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 1144 | |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1145 | /* Set the window menu */ |
| 1146 | |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 1147 | if ((wndPtr->dwStyle & (WS_CAPTION | WS_CHILD)) == WS_CAPTION ) |
Alexandre Julliard | e2abbb1 | 1995-03-19 17:39:39 +0000 | [diff] [blame] | 1148 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1149 | if (cs->hMenu) SetMenu(hwnd, cs->hMenu); |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1150 | else |
| 1151 | { |
Alexandre Julliard | ac7efef | 2000-11-27 21:54:01 +0000 | [diff] [blame] | 1152 | LPCSTR menuName = (LPCSTR)GetClassLongA( hwnd, GCL_MENUNAME ); |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 1153 | if (menuName) |
| 1154 | { |
Ulrich Weigand | 7df1fbb | 1998-11-01 18:01:53 +0000 | [diff] [blame] | 1155 | if (HIWORD(cs->hInstance)) |
Alexandre Julliard | ac7efef | 2000-11-27 21:54:01 +0000 | [diff] [blame] | 1156 | cs->hMenu = LoadMenuA(cs->hInstance,menuName); |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 1157 | else |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 1158 | cs->hMenu = LoadMenu16(cs->hInstance,menuName); |
| 1159 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1160 | if (cs->hMenu) SetMenu( hwnd, cs->hMenu ); |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 1161 | } |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1162 | } |
Alexandre Julliard | e2abbb1 | 1995-03-19 17:39:39 +0000 | [diff] [blame] | 1163 | } |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 1164 | else SetWindowLongW( hwnd, GWL_ID, (UINT)cs->hMenu ); |
| 1165 | WIN_ReleaseWndPtr( wndPtr ); |
Alexandre Julliard | 490a27e | 1994-06-08 13:57:50 +0000 | [diff] [blame] | 1166 | |
Alexandre Julliard | 80593bf | 2001-10-11 20:49:40 +0000 | [diff] [blame] | 1167 | if (!USER_Driver.pCreateWindow( hwnd, cs, unicode)) |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1168 | { |
Alexandre Julliard | 80593bf | 2001-10-11 20:49:40 +0000 | [diff] [blame] | 1169 | WIN_DestroyWindow( hwnd ); |
Alexandre Julliard | dc4fe77 | 2001-06-04 21:55:17 +0000 | [diff] [blame] | 1170 | return 0; |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 1171 | } |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 1172 | |
Alexandre Julliard | fb0ff05 | 2001-10-16 21:58:58 +0000 | [diff] [blame] | 1173 | /* Notify the parent window only */ |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 1174 | |
Alexandre Julliard | fb0ff05 | 2001-10-16 21:58:58 +0000 | [diff] [blame] | 1175 | send_parent_notify( hwnd, WM_CREATE ); |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 1176 | if (!IsWindow( hwnd )) return 0; |
Alexandre Julliard | dc4fe77 | 2001-06-04 21:55:17 +0000 | [diff] [blame] | 1177 | |
| 1178 | if (cs->style & WS_VISIBLE) |
| 1179 | { |
| 1180 | /* in case WS_VISIBLE got set in the meantime */ |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 1181 | if (!(wndPtr = WIN_GetPtr( hwnd ))) return 0; |
| 1182 | WIN_SetStyle( hwnd, wndPtr->dwStyle & ~WS_VISIBLE ); |
| 1183 | WIN_ReleasePtr( wndPtr ); |
Alexandre Julliard | dc4fe77 | 2001-06-04 21:55:17 +0000 | [diff] [blame] | 1184 | ShowWindow( hwnd, sw ); |
| 1185 | } |
| 1186 | |
| 1187 | /* Call WH_SHELL hook */ |
| 1188 | |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 1189 | if (!(GetWindowLongW( hwnd, GWL_STYLE ) & WS_CHILD) && !GetWindow( hwnd, GW_OWNER )) |
Alexandre Julliard | 0286135 | 2002-10-29 00:41:42 +0000 | [diff] [blame] | 1190 | HOOK_CallHooks( WH_SHELL, HSHELL_WINDOWCREATED, (WPARAM)hwnd, 0, TRUE ); |
Alexandre Julliard | dc4fe77 | 2001-06-04 21:55:17 +0000 | [diff] [blame] | 1191 | |
| 1192 | TRACE("created window %04x\n", hwnd); |
Alexandre Julliard | dc4fe77 | 2001-06-04 21:55:17 +0000 | [diff] [blame] | 1193 | return hwnd; |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 1194 | } |
| 1195 | |
| 1196 | |
| 1197 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1198 | * CreateWindow (USER.41) |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 1199 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 1200 | HWND16 WINAPI CreateWindow16( LPCSTR className, LPCSTR windowName, |
| 1201 | DWORD style, INT16 x, INT16 y, INT16 width, |
| 1202 | INT16 height, HWND16 parent, HMENU16 menu, |
Alexandre Julliard | 0d92fe2 | 2001-09-10 23:26:42 +0000 | [diff] [blame] | 1203 | HINSTANCE16 instance, LPVOID data ) |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 1204 | { |
| 1205 | return CreateWindowEx16( 0, className, windowName, style, |
| 1206 | x, y, width, height, parent, menu, instance, data ); |
| 1207 | } |
| 1208 | |
| 1209 | |
| 1210 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1211 | * CreateWindowEx (USER.452) |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 1212 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 1213 | HWND16 WINAPI CreateWindowEx16( DWORD exStyle, LPCSTR className, |
| 1214 | LPCSTR windowName, DWORD style, INT16 x, |
| 1215 | INT16 y, INT16 width, INT16 height, |
| 1216 | HWND16 parent, HMENU16 menu, |
Alexandre Julliard | 0d92fe2 | 2001-09-10 23:26:42 +0000 | [diff] [blame] | 1217 | HINSTANCE16 instance, LPVOID data ) |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 1218 | { |
| 1219 | ATOM classAtom; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1220 | CREATESTRUCTA cs; |
Alexandre Julliard | f1f6831 | 2000-01-01 22:22:21 +0000 | [diff] [blame] | 1221 | char buffer[256]; |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 1222 | |
| 1223 | /* Find the class atom */ |
| 1224 | |
Gerard Patel | 6fdb5dd | 2000-02-16 21:23:24 +0000 | [diff] [blame] | 1225 | if (HIWORD(className)) |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 1226 | { |
Gerard Patel | 6fdb5dd | 2000-02-16 21:23:24 +0000 | [diff] [blame] | 1227 | if (!(classAtom = GlobalFindAtomA( className ))) |
| 1228 | { |
Alexandre Julliard | 0aa28b5 | 2002-05-17 02:55:48 +0000 | [diff] [blame] | 1229 | ERR( "bad class name %s\n", debugstr_a(className) ); |
Gerard Patel | 6fdb5dd | 2000-02-16 21:23:24 +0000 | [diff] [blame] | 1230 | return 0; |
| 1231 | } |
| 1232 | } |
| 1233 | else |
| 1234 | { |
| 1235 | classAtom = LOWORD(className); |
| 1236 | if (!GlobalGetAtomNameA( classAtom, buffer, sizeof(buffer) )) |
| 1237 | { |
| 1238 | ERR( "bad atom %x\n", classAtom); |
| 1239 | return 0; |
| 1240 | } |
| 1241 | className = buffer; |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 1242 | } |
| 1243 | |
| 1244 | /* Fix the coordinates */ |
| 1245 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1246 | cs.x = (x == CW_USEDEFAULT16) ? CW_USEDEFAULT : (INT)x; |
| 1247 | cs.y = (y == CW_USEDEFAULT16) ? CW_USEDEFAULT : (INT)y; |
| 1248 | cs.cx = (width == CW_USEDEFAULT16) ? CW_USEDEFAULT : (INT)width; |
| 1249 | cs.cy = (height == CW_USEDEFAULT16) ? CW_USEDEFAULT : (INT)height; |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 1250 | |
| 1251 | /* Create the window */ |
| 1252 | |
| 1253 | cs.lpCreateParams = data; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1254 | cs.hInstance = (HINSTANCE)instance; |
| 1255 | cs.hMenu = (HMENU)menu; |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 1256 | cs.hwndParent = WIN_Handle32( parent ); |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 1257 | cs.style = style; |
| 1258 | cs.lpszName = windowName; |
| 1259 | cs.lpszClass = className; |
| 1260 | cs.dwExStyle = exStyle; |
Alexandre Julliard | f1f6831 | 2000-01-01 22:22:21 +0000 | [diff] [blame] | 1261 | |
Michael Stefaniuc | 2247af3 | 2002-09-04 19:37:01 +0000 | [diff] [blame] | 1262 | return HWND_16( WIN_CreateWindowEx( &cs, classAtom, WIN_PROC_16 )); |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1263 | } |
| 1264 | |
| 1265 | |
| 1266 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1267 | * CreateWindowExA (USER32.@) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1268 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1269 | HWND WINAPI CreateWindowExA( DWORD exStyle, LPCSTR className, |
| 1270 | LPCSTR windowName, DWORD style, INT x, |
| 1271 | INT y, INT width, INT height, |
| 1272 | HWND parent, HMENU menu, |
| 1273 | HINSTANCE instance, LPVOID data ) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1274 | { |
| 1275 | ATOM classAtom; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1276 | CREATESTRUCTA cs; |
Alexandre Julliard | f1f6831 | 2000-01-01 22:22:21 +0000 | [diff] [blame] | 1277 | char buffer[256]; |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1278 | |
Rein Klazes | d4a2cee | 1999-10-23 13:57:36 +0000 | [diff] [blame] | 1279 | if(!instance) |
| 1280 | instance=GetModuleHandleA(NULL); |
| 1281 | |
Rein Klazes | 5c6fc1b | 1998-11-01 14:50:06 +0000 | [diff] [blame] | 1282 | if(exStyle & WS_EX_MDICHILD) |
Dmitry Timoshkov | 91adf0a | 2001-02-12 03:40:41 +0000 | [diff] [blame] | 1283 | return CreateMDIWindowA(className, windowName, style, x, y, width, height, parent, instance, (LPARAM)data); |
Gerard Patel | 6fdb5dd | 2000-02-16 21:23:24 +0000 | [diff] [blame] | 1284 | |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1285 | /* Find the class atom */ |
| 1286 | |
Gerard Patel | 6fdb5dd | 2000-02-16 21:23:24 +0000 | [diff] [blame] | 1287 | if (HIWORD(className)) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1288 | { |
Gerard Patel | 6fdb5dd | 2000-02-16 21:23:24 +0000 | [diff] [blame] | 1289 | if (!(classAtom = GlobalFindAtomA( className ))) |
| 1290 | { |
Alexandre Julliard | 0aa28b5 | 2002-05-17 02:55:48 +0000 | [diff] [blame] | 1291 | ERR( "bad class name %s\n", debugstr_a(className) ); |
Gerard Patel | 6fdb5dd | 2000-02-16 21:23:24 +0000 | [diff] [blame] | 1292 | return 0; |
| 1293 | } |
| 1294 | } |
| 1295 | else |
| 1296 | { |
| 1297 | classAtom = LOWORD(className); |
| 1298 | if (!GlobalGetAtomNameA( classAtom, buffer, sizeof(buffer) )) |
| 1299 | { |
| 1300 | ERR( "bad atom %x\n", classAtom); |
| 1301 | return 0; |
| 1302 | } |
| 1303 | className = buffer; |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1304 | } |
| 1305 | |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 1306 | /* Create the window */ |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1307 | |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1308 | cs.lpCreateParams = data; |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 1309 | cs.hInstance = instance; |
| 1310 | cs.hMenu = menu; |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1311 | cs.hwndParent = parent; |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 1312 | cs.x = x; |
| 1313 | cs.y = y; |
| 1314 | cs.cx = width; |
| 1315 | cs.cy = height; |
| 1316 | cs.style = style; |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1317 | cs.lpszName = windowName; |
| 1318 | cs.lpszClass = className; |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 1319 | cs.dwExStyle = exStyle; |
Alexandre Julliard | f1f6831 | 2000-01-01 22:22:21 +0000 | [diff] [blame] | 1320 | |
Dmitry Timoshkov | 5956b98 | 2000-11-28 23:53:08 +0000 | [diff] [blame] | 1321 | return WIN_CreateWindowEx( &cs, classAtom, WIN_PROC_32A ); |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1322 | } |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1323 | |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1324 | |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1325 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1326 | * CreateWindowExW (USER32.@) |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1327 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1328 | HWND WINAPI CreateWindowExW( DWORD exStyle, LPCWSTR className, |
| 1329 | LPCWSTR windowName, DWORD style, INT x, |
| 1330 | INT y, INT width, INT height, |
| 1331 | HWND parent, HMENU menu, |
| 1332 | HINSTANCE instance, LPVOID data ) |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1333 | { |
| 1334 | ATOM classAtom; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1335 | CREATESTRUCTW cs; |
Alexandre Julliard | f1f6831 | 2000-01-01 22:22:21 +0000 | [diff] [blame] | 1336 | WCHAR buffer[256]; |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1337 | |
Rein Klazes | d4a2cee | 1999-10-23 13:57:36 +0000 | [diff] [blame] | 1338 | if(!instance) |
| 1339 | instance=GetModuleHandleA(NULL); |
| 1340 | |
Rein Klazes | 5c6fc1b | 1998-11-01 14:50:06 +0000 | [diff] [blame] | 1341 | if(exStyle & WS_EX_MDICHILD) |
Dmitry Timoshkov | 91adf0a | 2001-02-12 03:40:41 +0000 | [diff] [blame] | 1342 | return CreateMDIWindowW(className, windowName, style, x, y, width, height, parent, instance, (LPARAM)data); |
Rein Klazes | 5c6fc1b | 1998-11-01 14:50:06 +0000 | [diff] [blame] | 1343 | |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1344 | /* Find the class atom */ |
| 1345 | |
Gerard Patel | 6fdb5dd | 2000-02-16 21:23:24 +0000 | [diff] [blame] | 1346 | if (HIWORD(className)) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1347 | { |
Gerard Patel | 6fdb5dd | 2000-02-16 21:23:24 +0000 | [diff] [blame] | 1348 | if (!(classAtom = GlobalFindAtomW( className ))) |
| 1349 | { |
Alexandre Julliard | 0aa28b5 | 2002-05-17 02:55:48 +0000 | [diff] [blame] | 1350 | ERR( "bad class name %s\n", debugstr_w(className) ); |
Gerard Patel | 6fdb5dd | 2000-02-16 21:23:24 +0000 | [diff] [blame] | 1351 | return 0; |
| 1352 | } |
| 1353 | } |
| 1354 | else |
| 1355 | { |
| 1356 | classAtom = LOWORD(className); |
| 1357 | if (!GlobalGetAtomNameW( classAtom, buffer, sizeof(buffer)/sizeof(WCHAR) )) |
| 1358 | { |
| 1359 | ERR( "bad atom %x\n", classAtom); |
| 1360 | return 0; |
| 1361 | } |
| 1362 | className = buffer; |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1363 | } |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1364 | |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 1365 | /* Create the window */ |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1366 | |
| 1367 | cs.lpCreateParams = data; |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 1368 | cs.hInstance = instance; |
| 1369 | cs.hMenu = menu; |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1370 | cs.hwndParent = parent; |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 1371 | cs.x = x; |
| 1372 | cs.y = y; |
| 1373 | cs.cx = width; |
| 1374 | cs.cy = height; |
| 1375 | cs.style = style; |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1376 | cs.lpszName = windowName; |
| 1377 | cs.lpszClass = className; |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 1378 | cs.dwExStyle = exStyle; |
Alexandre Julliard | f1f6831 | 2000-01-01 22:22:21 +0000 | [diff] [blame] | 1379 | |
Patrik Stridvall | 2d6457c | 2000-03-28 20:22:59 +0000 | [diff] [blame] | 1380 | /* Note: we rely on the fact that CREATESTRUCTA and */ |
| 1381 | /* CREATESTRUCTW have the same layout. */ |
Dmitry Timoshkov | 5956b98 | 2000-11-28 23:53:08 +0000 | [diff] [blame] | 1382 | return WIN_CreateWindowEx( (CREATESTRUCTA *)&cs, classAtom, WIN_PROC_32W ); |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 1383 | } |
| 1384 | |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 1385 | |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 1386 | /*********************************************************************** |
| 1387 | * WIN_SendDestroyMsg |
| 1388 | */ |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 1389 | static void WIN_SendDestroyMsg( HWND hwnd ) |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 1390 | { |
Alexandre Julliard | 11e3523 | 2002-10-17 01:24:33 +0000 | [diff] [blame] | 1391 | GUITHREADINFO info; |
| 1392 | |
| 1393 | if (GetGUIThreadInfo( GetCurrentThreadId(), &info )) |
| 1394 | { |
| 1395 | if (hwnd == info.hwndCaret) DestroyCaret(); |
| 1396 | } |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1397 | if (USER_Driver.pResetSelectionOwner) |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 1398 | USER_Driver.pResetSelectionOwner( hwnd, TRUE ); |
Francis Beaudet | eb6a9f0 | 1999-03-17 15:17:48 +0000 | [diff] [blame] | 1399 | |
| 1400 | /* |
| 1401 | * Send the WM_DESTROY to the window. |
| 1402 | */ |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 1403 | SendMessageA( hwnd, WM_DESTROY, 0, 0); |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 1404 | |
Francis Beaudet | eb6a9f0 | 1999-03-17 15:17:48 +0000 | [diff] [blame] | 1405 | /* |
| 1406 | * This WM_DESTROY message can trigger re-entrant calls to DestroyWindow |
| 1407 | * make sure that the window still exists when we come back. |
| 1408 | */ |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 1409 | if (IsWindow(hwnd)) |
Alexandre Julliard | a0b2b1d | 1997-11-16 17:38:29 +0000 | [diff] [blame] | 1410 | { |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 1411 | HWND* pWndArray; |
| 1412 | int i; |
Francis Beaudet | eb6a9f0 | 1999-03-17 15:17:48 +0000 | [diff] [blame] | 1413 | |
Alexandre Julliard | 9d9dac0 | 2001-08-24 19:28:21 +0000 | [diff] [blame] | 1414 | if (!(pWndArray = WIN_ListChildren( hwnd ))) return; |
Francis Beaudet | eb6a9f0 | 1999-03-17 15:17:48 +0000 | [diff] [blame] | 1415 | |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 1416 | /* start from the end (FIXME: is this needed?) */ |
| 1417 | for (i = 0; pWndArray[i]; i++) ; |
Francis Beaudet | eb6a9f0 | 1999-03-17 15:17:48 +0000 | [diff] [blame] | 1418 | |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 1419 | while (--i >= 0) |
| 1420 | { |
| 1421 | if (IsWindow( pWndArray[i] )) WIN_SendDestroyMsg( pWndArray[i] ); |
| 1422 | } |
Alexandre Julliard | 9d9dac0 | 2001-08-24 19:28:21 +0000 | [diff] [blame] | 1423 | HeapFree( GetProcessHeap(), 0, pWndArray ); |
Alexandre Julliard | a0b2b1d | 1997-11-16 17:38:29 +0000 | [diff] [blame] | 1424 | } |
| 1425 | else |
Dimitrie O. Paun | dd03cc1 | 1999-12-08 03:56:23 +0000 | [diff] [blame] | 1426 | WARN("\tdestroyed itself while in WM_DESTROY!\n"); |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 1427 | } |
| 1428 | |
| 1429 | |
| 1430 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1431 | * DestroyWindow (USER32.@) |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 1432 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1433 | BOOL WINAPI DestroyWindow( HWND hwnd ) |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 1434 | { |
Alexandre Julliard | fb0ff05 | 2001-10-16 21:58:58 +0000 | [diff] [blame] | 1435 | BOOL is_child; |
Alexandre Julliard | 1f029ea | 2000-11-02 20:08:59 +0000 | [diff] [blame] | 1436 | HWND h; |
Alexandre Julliard | 3a405ba | 1994-10-30 16:25:19 +0000 | [diff] [blame] | 1437 | |
Alexandre Julliard | fb0ff05 | 2001-10-16 21:58:58 +0000 | [diff] [blame] | 1438 | if (!(hwnd = WIN_IsCurrentThread( hwnd )) || (hwnd == GetDesktopWindow())) |
| 1439 | { |
| 1440 | SetLastError( ERROR_ACCESS_DENIED ); |
| 1441 | return FALSE; |
| 1442 | } |
| 1443 | |
Dimitrie O. Paun | dd03cc1 | 1999-12-08 03:56:23 +0000 | [diff] [blame] | 1444 | TRACE("(%04x)\n", hwnd); |
Alexandre Julliard | 1f029ea | 2000-11-02 20:08:59 +0000 | [diff] [blame] | 1445 | |
Alexandre Julliard | 1f029ea | 2000-11-02 20:08:59 +0000 | [diff] [blame] | 1446 | /* Look whether the focus is within the tree of windows we will |
| 1447 | * be destroying. |
| 1448 | */ |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 1449 | h = GetFocus(); |
| 1450 | if (h == hwnd || IsChild( hwnd, h )) |
Alexandre Julliard | 1f029ea | 2000-11-02 20:08:59 +0000 | [diff] [blame] | 1451 | { |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 1452 | HWND parent = GetAncestor( hwnd, GA_PARENT ); |
| 1453 | if (parent == GetDesktopWindow()) parent = 0; |
| 1454 | SetFocus( parent ); |
Alexandre Julliard | 1f029ea | 2000-11-02 20:08:59 +0000 | [diff] [blame] | 1455 | } |
| 1456 | |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 1457 | /* Call hooks */ |
| 1458 | |
Alexandre Julliard | 0286135 | 2002-10-29 00:41:42 +0000 | [diff] [blame] | 1459 | if (HOOK_CallHooks( WH_CBT, HCBT_DESTROYWND, (WPARAM)hwnd, 0, TRUE )) return FALSE; |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1460 | |
Alexandre Julliard | fb0ff05 | 2001-10-16 21:58:58 +0000 | [diff] [blame] | 1461 | is_child = (GetWindowLongW( hwnd, GWL_STYLE ) & WS_CHILD) != 0; |
| 1462 | |
| 1463 | if (is_child) |
| 1464 | { |
| 1465 | if (!USER_IsExitingThread( GetCurrentThreadId() )) |
| 1466 | send_parent_notify( hwnd, WM_DESTROY ); |
| 1467 | } |
| 1468 | else if (!GetWindow( hwnd, GW_OWNER )) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1469 | { |
Alexandre Julliard | 0286135 | 2002-10-29 00:41:42 +0000 | [diff] [blame] | 1470 | HOOK_CallHooks( WH_SHELL, HSHELL_WINDOWDESTROYED, (WPARAM)hwnd, 0L, TRUE ); |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1471 | /* FIXME: clean up palette - see "Internals" p.352 */ |
| 1472 | } |
| 1473 | |
Alexandre Julliard | fb0ff05 | 2001-10-16 21:58:58 +0000 | [diff] [blame] | 1474 | if (!IsWindow(hwnd)) return TRUE; |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 1475 | |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1476 | if (USER_Driver.pResetSelectionOwner) |
| 1477 | USER_Driver.pResetSelectionOwner( hwnd, FALSE ); /* before the window is unmapped */ |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 1478 | |
Alexandre Julliard | 5819953 | 1994-04-21 01:20:00 +0000 | [diff] [blame] | 1479 | /* Hide the window */ |
| 1480 | |
Alexandre Julliard | 5030bda | 2002-10-11 23:41:06 +0000 | [diff] [blame] | 1481 | if (!ShowWindow( hwnd, SW_HIDE )) |
| 1482 | { |
| 1483 | if (hwnd == GetActiveWindow()) WINPOS_ActivateOtherWindow( hwnd ); |
| 1484 | } |
Alexandre Julliard | fb0ff05 | 2001-10-16 21:58:58 +0000 | [diff] [blame] | 1485 | if (!IsWindow(hwnd)) return TRUE; |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 1486 | |
Alexandre Julliard | 22945d5 | 1995-03-02 17:44:29 +0000 | [diff] [blame] | 1487 | /* Recursively destroy owned windows */ |
| 1488 | |
Alexandre Julliard | fb0ff05 | 2001-10-16 21:58:58 +0000 | [diff] [blame] | 1489 | if (!is_child) |
Alexandre Julliard | 22945d5 | 1995-03-02 17:44:29 +0000 | [diff] [blame] | 1490 | { |
Alexandre Julliard | fb0ff05 | 2001-10-16 21:58:58 +0000 | [diff] [blame] | 1491 | for (;;) |
| 1492 | { |
| 1493 | int i, got_one = 0; |
| 1494 | HWND *list = WIN_ListChildren( GetDesktopWindow() ); |
| 1495 | if (list) |
| 1496 | { |
| 1497 | for (i = 0; list[i]; i++) |
| 1498 | { |
| 1499 | if (GetWindow( list[i], GW_OWNER ) != hwnd) continue; |
| 1500 | if (WIN_IsCurrentThread( list[i] )) |
| 1501 | { |
| 1502 | DestroyWindow( list[i] ); |
| 1503 | got_one = 1; |
| 1504 | continue; |
| 1505 | } |
| 1506 | WIN_SetOwner( list[i], 0 ); |
| 1507 | } |
| 1508 | HeapFree( GetProcessHeap(), 0, list ); |
| 1509 | } |
| 1510 | if (!got_one) break; |
| 1511 | } |
Alexandre Julliard | 22945d5 | 1995-03-02 17:44:29 +0000 | [diff] [blame] | 1512 | } |
| 1513 | |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 1514 | /* Send destroy messages */ |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 1515 | |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 1516 | WIN_SendDestroyMsg( hwnd ); |
Alexandre Julliard | fb0ff05 | 2001-10-16 21:58:58 +0000 | [diff] [blame] | 1517 | if (!IsWindow( hwnd )) return TRUE; |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 1518 | |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 1519 | /* Unlink now so we won't bother with the children later on */ |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 1520 | |
Alexandre Julliard | fb0ff05 | 2001-10-16 21:58:58 +0000 | [diff] [blame] | 1521 | WIN_UnlinkWindow( hwnd ); |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 1522 | |
| 1523 | /* Destroy the window storage */ |
| 1524 | |
Alexandre Julliard | 80593bf | 2001-10-11 20:49:40 +0000 | [diff] [blame] | 1525 | WIN_DestroyWindow( hwnd ); |
Alexandre Julliard | fb0ff05 | 2001-10-16 21:58:58 +0000 | [diff] [blame] | 1526 | return TRUE; |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 1527 | } |
| 1528 | |
| 1529 | |
| 1530 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1531 | * CloseWindow (USER32.@) |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 1532 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1533 | BOOL WINAPI CloseWindow( HWND hwnd ) |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 1534 | { |
Alexandre Julliard | fb0ff05 | 2001-10-16 21:58:58 +0000 | [diff] [blame] | 1535 | if (GetWindowLongW( hwnd, GWL_STYLE ) & WS_CHILD) return FALSE; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1536 | ShowWindow( hwnd, SW_MINIMIZE ); |
Alexandre Julliard | fb0ff05 | 2001-10-16 21:58:58 +0000 | [diff] [blame] | 1537 | return TRUE; |
Alexandre Julliard | e399fc3 | 1993-11-24 17:08:56 +0000 | [diff] [blame] | 1538 | } |
| 1539 | |
Alexandre Julliard | 0d92fe2 | 2001-09-10 23:26:42 +0000 | [diff] [blame] | 1540 | |
Alexandre Julliard | e399fc3 | 1993-11-24 17:08:56 +0000 | [diff] [blame] | 1541 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1542 | * OpenIcon (USER32.@) |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 1543 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1544 | BOOL WINAPI OpenIcon( HWND hwnd ) |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 1545 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1546 | if (!IsIconic( hwnd )) return FALSE; |
| 1547 | ShowWindow( hwnd, SW_SHOWNORMAL ); |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 1548 | return TRUE; |
Alexandre Julliard | e399fc3 | 1993-11-24 17:08:56 +0000 | [diff] [blame] | 1549 | } |
| 1550 | |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 1551 | |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1552 | /*********************************************************************** |
| 1553 | * WIN_FindWindow |
| 1554 | * |
| 1555 | * Implementation of FindWindow() and FindWindowEx(). |
| 1556 | */ |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 1557 | static HWND WIN_FindWindow( HWND parent, HWND child, ATOM className, LPCWSTR title ) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1558 | { |
Alexandre Julliard | 844ceb9 | 2001-10-09 23:26:40 +0000 | [diff] [blame] | 1559 | HWND *list = NULL; |
| 1560 | HWND retvalue = 0; |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 1561 | int i = 0, len = 0; |
| 1562 | WCHAR *buffer = NULL; |
| 1563 | |
| 1564 | if (!parent) parent = GetDesktopWindow(); |
| 1565 | if (title) |
| 1566 | { |
| 1567 | len = strlenW(title) + 1; /* one extra char to check for chars beyond the end */ |
| 1568 | if (!(buffer = HeapAlloc( GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR) ))) return 0; |
| 1569 | } |
| 1570 | |
Alexandre Julliard | 844ceb9 | 2001-10-09 23:26:40 +0000 | [diff] [blame] | 1571 | if (!(list = list_window_children( parent, className, 0 ))) goto done; |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1572 | |
| 1573 | if (child) |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 1574 | { |
Alexandre Julliard | f44bbb8 | 2001-09-14 00:24:39 +0000 | [diff] [blame] | 1575 | child = WIN_GetFullHandle( child ); |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 1576 | while (list[i] && list[i] != child) i++; |
Alexandre Julliard | 844ceb9 | 2001-10-09 23:26:40 +0000 | [diff] [blame] | 1577 | if (!list[i]) goto done; |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 1578 | i++; /* start from next window */ |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 1579 | } |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1580 | |
Alexandre Julliard | 844ceb9 | 2001-10-09 23:26:40 +0000 | [diff] [blame] | 1581 | if (title) |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 1582 | { |
Alexandre Julliard | 844ceb9 | 2001-10-09 23:26:40 +0000 | [diff] [blame] | 1583 | while (list[i]) |
| 1584 | { |
| 1585 | if (GetWindowTextW( list[i], buffer, len ) && !strcmpiW( buffer, title )) break; |
| 1586 | i++; |
| 1587 | } |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 1588 | } |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 1589 | retvalue = list[i]; |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 1590 | |
Alexandre Julliard | 844ceb9 | 2001-10-09 23:26:40 +0000 | [diff] [blame] | 1591 | done: |
| 1592 | if (list) HeapFree( GetProcessHeap(), 0, list ); |
| 1593 | if (buffer) HeapFree( GetProcessHeap(), 0, buffer ); |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 1594 | return retvalue; |
Alexandre Julliard | e399fc3 | 1993-11-24 17:08:56 +0000 | [diff] [blame] | 1595 | } |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1596 | |
| 1597 | |
| 1598 | |
| 1599 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1600 | * FindWindowA (USER32.@) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1601 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1602 | HWND WINAPI FindWindowA( LPCSTR className, LPCSTR title ) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1603 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1604 | HWND ret = FindWindowExA( 0, 0, className, title ); |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 1605 | if (!ret) SetLastError (ERROR_CANNOT_FIND_WND_CLASS); |
| 1606 | return ret; |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1607 | } |
| 1608 | |
| 1609 | |
| 1610 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1611 | * FindWindowExA (USER32.@) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1612 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1613 | HWND WINAPI FindWindowExA( HWND parent, HWND child, |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 1614 | LPCSTR className, LPCSTR title ) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1615 | { |
Alexandre Julliard | 0e270f4 | 1996-08-24 18:26:35 +0000 | [diff] [blame] | 1616 | ATOM atom = 0; |
Dmitry Timoshkov | 04da8b8 | 2000-07-10 12:09:31 +0000 | [diff] [blame] | 1617 | LPWSTR buffer; |
| 1618 | HWND hwnd; |
Alexandre Julliard | 193cf50 | 2002-01-01 00:24:30 +0000 | [diff] [blame] | 1619 | INT len; |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1620 | |
Alexandre Julliard | 0e270f4 | 1996-08-24 18:26:35 +0000 | [diff] [blame] | 1621 | if (className) |
| 1622 | { |
| 1623 | /* If the atom doesn't exist, then no class */ |
| 1624 | /* with this name exists either. */ |
Alexandre Julliard | 0d92fe2 | 2001-09-10 23:26:42 +0000 | [diff] [blame] | 1625 | if (!(atom = GlobalFindAtomA( className ))) |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 1626 | { |
| 1627 | SetLastError (ERROR_CANNOT_FIND_WND_CLASS); |
| 1628 | return 0; |
| 1629 | } |
Alexandre Julliard | 0e270f4 | 1996-08-24 18:26:35 +0000 | [diff] [blame] | 1630 | } |
Alexandre Julliard | 193cf50 | 2002-01-01 00:24:30 +0000 | [diff] [blame] | 1631 | if (!title) return WIN_FindWindow( parent, child, atom, NULL ); |
Dmitry Timoshkov | 04da8b8 | 2000-07-10 12:09:31 +0000 | [diff] [blame] | 1632 | |
Alexandre Julliard | 193cf50 | 2002-01-01 00:24:30 +0000 | [diff] [blame] | 1633 | len = MultiByteToWideChar( CP_ACP, 0, title, -1, NULL, 0 ); |
| 1634 | if (!(buffer = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) ))) return 0; |
| 1635 | MultiByteToWideChar( CP_ACP, 0, title, -1, buffer, len ); |
Dmitry Timoshkov | 04da8b8 | 2000-07-10 12:09:31 +0000 | [diff] [blame] | 1636 | hwnd = WIN_FindWindow( parent, child, atom, buffer ); |
| 1637 | HeapFree( GetProcessHeap(), 0, buffer ); |
| 1638 | return hwnd; |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1639 | } |
| 1640 | |
| 1641 | |
| 1642 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1643 | * FindWindowExW (USER32.@) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1644 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1645 | HWND WINAPI FindWindowExW( HWND parent, HWND child, |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 1646 | LPCWSTR className, LPCWSTR title ) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1647 | { |
Alexandre Julliard | 0e270f4 | 1996-08-24 18:26:35 +0000 | [diff] [blame] | 1648 | ATOM atom = 0; |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1649 | |
Alexandre Julliard | 0e270f4 | 1996-08-24 18:26:35 +0000 | [diff] [blame] | 1650 | if (className) |
| 1651 | { |
| 1652 | /* If the atom doesn't exist, then no class */ |
| 1653 | /* with this name exists either. */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1654 | if (!(atom = GlobalFindAtomW( className ))) |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 1655 | { |
| 1656 | SetLastError (ERROR_CANNOT_FIND_WND_CLASS); |
| 1657 | return 0; |
| 1658 | } |
Alexandre Julliard | 0e270f4 | 1996-08-24 18:26:35 +0000 | [diff] [blame] | 1659 | } |
Dmitry Timoshkov | 04da8b8 | 2000-07-10 12:09:31 +0000 | [diff] [blame] | 1660 | return WIN_FindWindow( parent, child, atom, title ); |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1661 | } |
| 1662 | |
| 1663 | |
| 1664 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1665 | * FindWindowW (USER32.@) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1666 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1667 | HWND WINAPI FindWindowW( LPCWSTR className, LPCWSTR title ) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1668 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1669 | return FindWindowExW( 0, 0, className, title ); |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1670 | } |
| 1671 | |
| 1672 | |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 1673 | /********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1674 | * GetDesktopWindow (USER32.@) |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 1675 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1676 | HWND WINAPI GetDesktopWindow(void) |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 1677 | { |
Uwe Bonnes | 7361916 | 1999-10-24 20:42:39 +0000 | [diff] [blame] | 1678 | if (pWndDesktop) return pWndDesktop->hwndSelf; |
Gerard Patel | e717b1b | 2001-11-19 02:07:11 +0000 | [diff] [blame] | 1679 | ERR( "Wine init error: either you're trying to use an invalid native USER.EXE config, or some graphics/GUI libraries or DLLs didn't initialize properly. Aborting.\n" ); |
Uwe Bonnes | 7361916 | 1999-10-24 20:42:39 +0000 | [diff] [blame] | 1680 | ExitProcess(1); |
Huw D M Davies | 238b6d7 | 1999-10-31 01:56:51 +0000 | [diff] [blame] | 1681 | return 0; |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 1682 | } |
| 1683 | |
| 1684 | |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 1685 | /******************************************************************* |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1686 | * EnableWindow (USER32.@) |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 1687 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1688 | BOOL WINAPI EnableWindow( HWND hwnd, BOOL enable ) |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 1689 | { |
| 1690 | WND *wndPtr; |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 1691 | BOOL retvalue; |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 1692 | LONG style; |
| 1693 | HWND full_handle; |
| 1694 | |
| 1695 | if (!(full_handle = WIN_IsCurrentThread( hwnd ))) |
| 1696 | return SendMessageW( hwnd, WM_WINE_ENABLEWINDOW, enable, 0 ); |
| 1697 | |
| 1698 | hwnd = full_handle; |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 1699 | |
Alexandre Julliard | 9ae0fe5 | 2001-04-24 23:28:52 +0000 | [diff] [blame] | 1700 | TRACE("( %x, %d )\n", hwnd, enable); |
| 1701 | |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 1702 | if (!(wndPtr = WIN_GetPtr( hwnd ))) return FALSE; |
| 1703 | style = wndPtr->dwStyle; |
| 1704 | retvalue = ((style & WS_DISABLED) != 0); |
| 1705 | WIN_ReleasePtr( wndPtr ); |
Alexandre Julliard | 9ae0fe5 | 2001-04-24 23:28:52 +0000 | [diff] [blame] | 1706 | |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 1707 | if (enable && retvalue) |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 1708 | { |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 1709 | WIN_SetStyle( hwnd, style & ~WS_DISABLED ); |
Alexandre Julliard | 9ae0fe5 | 2001-04-24 23:28:52 +0000 | [diff] [blame] | 1710 | SendMessageA( hwnd, WM_ENABLE, TRUE, 0 ); |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 1711 | } |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 1712 | else if (!enable && !retvalue) |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 1713 | { |
Alexandre Julliard | f44bbb8 | 2001-09-14 00:24:39 +0000 | [diff] [blame] | 1714 | SendMessageA( hwnd, WM_CANCELMODE, 0, 0); |
Alex Korobka | 4f1ac05 | 1999-03-28 09:37:57 +0000 | [diff] [blame] | 1715 | |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 1716 | WIN_SetStyle( hwnd, style | WS_DISABLED ); |
Alex Korobka | 4f1ac05 | 1999-03-28 09:37:57 +0000 | [diff] [blame] | 1717 | |
Alexandre Julliard | 481f8ff | 2002-04-08 23:57:08 +0000 | [diff] [blame] | 1718 | if (hwnd == GetFocus() || IsChild(hwnd, GetFocus())) |
Alexandre Julliard | 9ae0fe5 | 2001-04-24 23:28:52 +0000 | [diff] [blame] | 1719 | SetFocus( 0 ); /* A disabled window can't have the focus */ |
Alex Korobka | 4f1ac05 | 1999-03-28 09:37:57 +0000 | [diff] [blame] | 1720 | |
Alexandre Julliard | 481f8ff | 2002-04-08 23:57:08 +0000 | [diff] [blame] | 1721 | if (hwnd == GetCapture() || IsChild(hwnd, GetCapture())) |
Alexandre Julliard | 9ae0fe5 | 2001-04-24 23:28:52 +0000 | [diff] [blame] | 1722 | ReleaseCapture(); /* A disabled window can't capture the mouse */ |
| 1723 | |
| 1724 | SendMessageA( hwnd, WM_ENABLE, FALSE, 0 ); |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 1725 | } |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 1726 | return retvalue; |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 1727 | } |
| 1728 | |
| 1729 | |
| 1730 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1731 | * IsWindowEnabled (USER32.@) |
Alexandre Julliard | 0d92fe2 | 2001-09-10 23:26:42 +0000 | [diff] [blame] | 1732 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1733 | BOOL WINAPI IsWindowEnabled(HWND hWnd) |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 1734 | { |
Alexandre Julliard | fb0ff05 | 2001-10-16 21:58:58 +0000 | [diff] [blame] | 1735 | return !(GetWindowLongW( hWnd, GWL_STYLE ) & WS_DISABLED); |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 1736 | } |
| 1737 | |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 1738 | |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1739 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1740 | * IsWindowUnicode (USER32.@) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1741 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1742 | BOOL WINAPI IsWindowUnicode( HWND hwnd ) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1743 | { |
Alexandre Julliard | 0d92fe2 | 2001-09-10 23:26:42 +0000 | [diff] [blame] | 1744 | WND * wndPtr; |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 1745 | BOOL retvalue; |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1746 | |
| 1747 | if (!(wndPtr = WIN_FindWndPtr(hwnd))) return FALSE; |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 1748 | retvalue = (WINPROC_GetProcType( wndPtr->winproc ) == WIN_PROC_32W); |
| 1749 | WIN_ReleaseWndPtr(wndPtr); |
| 1750 | return retvalue; |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1751 | } |
| 1752 | |
| 1753 | |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 1754 | /********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1755 | * GetWindowWord (USER32.@) |
Alexandre Julliard | 2197901 | 1997-03-05 08:22:35 +0000 | [diff] [blame] | 1756 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1757 | WORD WINAPI GetWindowWord( HWND hwnd, INT offset ) |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 1758 | { |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1759 | if (offset >= 0) |
| 1760 | { |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 1761 | WORD retvalue = 0; |
| 1762 | WND *wndPtr = WIN_GetPtr( hwnd ); |
| 1763 | if (!wndPtr) |
| 1764 | { |
| 1765 | SetLastError( ERROR_INVALID_WINDOW_HANDLE ); |
| 1766 | return 0; |
| 1767 | } |
| 1768 | if (wndPtr == WND_OTHER_PROCESS) |
| 1769 | { |
| 1770 | if (IsWindow( hwnd )) |
| 1771 | FIXME( "(%d) not supported yet on other process window %x\n", offset, hwnd ); |
| 1772 | SetLastError( ERROR_INVALID_WINDOW_HANDLE ); |
| 1773 | return 0; |
| 1774 | } |
| 1775 | if (offset > wndPtr->cbWndExtra - sizeof(WORD)) |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1776 | { |
Dimitrie O. Paun | dd03cc1 | 1999-12-08 03:56:23 +0000 | [diff] [blame] | 1777 | WARN("Invalid offset %d\n", offset ); |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 1778 | SetLastError( ERROR_INVALID_INDEX ); |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1779 | } |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 1780 | else retvalue = *(WORD *)(((char *)wndPtr->wExtra) + offset); |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 1781 | WIN_ReleasePtr( wndPtr ); |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 1782 | return retvalue; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1783 | } |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 1784 | |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 1785 | switch(offset) |
| 1786 | { |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 1787 | case GWL_HWNDPARENT: |
| 1788 | return GetWindowLongW( hwnd, offset ); |
| 1789 | case GWL_ID: |
| 1790 | case GWL_HINSTANCE: |
| 1791 | { |
| 1792 | LONG ret = GetWindowLongW( hwnd, offset ); |
| 1793 | if (HIWORD(ret)) |
| 1794 | WARN("%d: discards high bits of 0x%08lx!\n", offset, ret ); |
| 1795 | return LOWORD(ret); |
| 1796 | } |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1797 | default: |
Dimitrie O. Paun | dd03cc1 | 1999-12-08 03:56:23 +0000 | [diff] [blame] | 1798 | WARN("Invalid offset %d\n", offset ); |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 1799 | return 0; |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 1800 | } |
Alexandre Julliard | 2197901 | 1997-03-05 08:22:35 +0000 | [diff] [blame] | 1801 | } |
| 1802 | |
| 1803 | |
| 1804 | /********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1805 | * SetWindowWord (USER32.@) |
Alexandre Julliard | 2197901 | 1997-03-05 08:22:35 +0000 | [diff] [blame] | 1806 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1807 | WORD WINAPI SetWindowWord( HWND hwnd, INT offset, WORD newval ) |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 1808 | { |
| 1809 | WORD *ptr, retval; |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 1810 | WND * wndPtr; |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 1811 | |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 1812 | switch(offset) |
| 1813 | { |
| 1814 | case GWL_ID: |
| 1815 | case GWL_HINSTANCE: |
| 1816 | case GWL_HWNDPARENT: |
| 1817 | return SetWindowLongW( hwnd, offset, (UINT)newval ); |
| 1818 | default: |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 1819 | if (offset < 0) |
| 1820 | { |
| 1821 | WARN("Invalid offset %d\n", offset ); |
| 1822 | SetLastError( ERROR_INVALID_INDEX ); |
| 1823 | return 0; |
| 1824 | } |
| 1825 | } |
| 1826 | |
| 1827 | wndPtr = WIN_GetPtr( hwnd ); |
| 1828 | if (wndPtr == WND_OTHER_PROCESS) |
| 1829 | { |
| 1830 | if (IsWindow(hwnd)) |
| 1831 | FIXME( "set %d <- %x not supported yet on other process window %x\n", |
| 1832 | offset, newval, hwnd ); |
| 1833 | wndPtr = NULL; |
| 1834 | } |
| 1835 | if (!wndPtr) |
| 1836 | { |
| 1837 | SetLastError( ERROR_INVALID_WINDOW_HANDLE ); |
| 1838 | return 0; |
| 1839 | } |
| 1840 | |
| 1841 | if (offset > wndPtr->cbWndExtra - sizeof(WORD)) |
| 1842 | { |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 1843 | WARN("Invalid offset %d\n", offset ); |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 1844 | WIN_ReleasePtr(wndPtr); |
| 1845 | SetLastError( ERROR_INVALID_INDEX ); |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 1846 | return 0; |
| 1847 | } |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 1848 | ptr = (WORD *)(((char *)wndPtr->wExtra) + offset); |
| 1849 | retval = *ptr; |
| 1850 | *ptr = newval; |
| 1851 | WIN_ReleasePtr(wndPtr); |
| 1852 | return retval; |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 1853 | } |
| 1854 | |
| 1855 | |
| 1856 | /********************************************************************** |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1857 | * WIN_GetWindowLong |
| 1858 | * |
| 1859 | * Helper function for GetWindowLong(). |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 1860 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1861 | static LONG WIN_GetWindowLong( HWND hwnd, INT offset, WINDOWPROCTYPE type ) |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 1862 | { |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 1863 | LONG retvalue = 0; |
| 1864 | WND *wndPtr; |
| 1865 | |
Alexandre Julliard | 7dafa61 | 2002-09-25 00:21:56 +0000 | [diff] [blame] | 1866 | if (offset == GWL_HWNDPARENT) |
| 1867 | { |
| 1868 | HWND parent = GetAncestor( hwnd, GA_PARENT ); |
| 1869 | if (parent == GetDesktopWindow()) parent = GetWindow( hwnd, GW_OWNER ); |
| 1870 | return (LONG)parent; |
| 1871 | } |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 1872 | |
| 1873 | if (!(wndPtr = WIN_GetPtr( hwnd ))) |
| 1874 | { |
| 1875 | SetLastError( ERROR_INVALID_WINDOW_HANDLE ); |
| 1876 | return 0; |
| 1877 | } |
| 1878 | |
| 1879 | if (wndPtr == WND_OTHER_PROCESS) |
| 1880 | { |
| 1881 | if (offset >= 0) |
| 1882 | { |
Alexandre Julliard | 96ebfa9 | 2001-10-23 20:35:44 +0000 | [diff] [blame] | 1883 | if (IsWindow(hwnd)) |
| 1884 | FIXME( "(%d) not supported on other process window %x\n", offset, hwnd ); |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 1885 | SetLastError( ERROR_INVALID_WINDOW_HANDLE ); |
| 1886 | return 0; |
| 1887 | } |
| 1888 | if (offset == GWL_WNDPROC) |
| 1889 | { |
| 1890 | SetLastError( ERROR_ACCESS_DENIED ); |
| 1891 | return 0; |
| 1892 | } |
| 1893 | SERVER_START_REQ( set_window_info ) |
| 1894 | { |
| 1895 | req->handle = hwnd; |
| 1896 | req->flags = 0; /* don't set anything, just retrieve */ |
Alexandre Julliard | 9caa71e | 2001-11-30 18:46:42 +0000 | [diff] [blame] | 1897 | if (!wine_server_call_err( req )) |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 1898 | { |
| 1899 | switch(offset) |
| 1900 | { |
Alexandre Julliard | 9caa71e | 2001-11-30 18:46:42 +0000 | [diff] [blame] | 1901 | case GWL_STYLE: retvalue = reply->old_style; break; |
| 1902 | case GWL_EXSTYLE: retvalue = reply->old_ex_style; break; |
| 1903 | case GWL_ID: retvalue = reply->old_id; break; |
| 1904 | case GWL_HINSTANCE: retvalue = (ULONG_PTR)reply->old_instance; break; |
| 1905 | case GWL_USERDATA: retvalue = (ULONG_PTR)reply->old_user_data; break; |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 1906 | default: |
| 1907 | SetLastError( ERROR_INVALID_INDEX ); |
| 1908 | break; |
| 1909 | } |
| 1910 | } |
| 1911 | } |
| 1912 | SERVER_END_REQ; |
| 1913 | return retvalue; |
| 1914 | } |
| 1915 | |
| 1916 | /* now we have a valid wndPtr */ |
| 1917 | |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1918 | if (offset >= 0) |
| 1919 | { |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 1920 | if (offset > wndPtr->cbWndExtra - sizeof(LONG)) |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1921 | { |
Jukka Heinonen | 3fead8f | 2002-02-15 18:22:23 +0000 | [diff] [blame] | 1922 | /* |
| 1923 | * Some programs try to access last element from 16 bit |
| 1924 | * code using illegal offset value. Hopefully this is |
| 1925 | * what those programs really expect. |
| 1926 | */ |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1927 | if (type == WIN_PROC_16 && |
Jukka Heinonen | 3fead8f | 2002-02-15 18:22:23 +0000 | [diff] [blame] | 1928 | wndPtr->cbWndExtra >= 4 && |
| 1929 | offset == wndPtr->cbWndExtra - sizeof(WORD)) |
| 1930 | { |
| 1931 | INT offset2 = wndPtr->cbWndExtra - sizeof(LONG); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1932 | |
Jukka Heinonen | 3fead8f | 2002-02-15 18:22:23 +0000 | [diff] [blame] | 1933 | ERR( "- replaced invalid offset %d with %d\n", |
| 1934 | offset, offset2 ); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1935 | |
Jukka Heinonen | 3fead8f | 2002-02-15 18:22:23 +0000 | [diff] [blame] | 1936 | retvalue = *(LONG *)(((char *)wndPtr->wExtra) + offset2); |
| 1937 | WIN_ReleasePtr( wndPtr ); |
| 1938 | return retvalue; |
| 1939 | } |
Dimitrie O. Paun | dd03cc1 | 1999-12-08 03:56:23 +0000 | [diff] [blame] | 1940 | WARN("Invalid offset %d\n", offset ); |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 1941 | WIN_ReleasePtr( wndPtr ); |
| 1942 | SetLastError( ERROR_INVALID_INDEX ); |
| 1943 | return 0; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1944 | } |
Gerard Patel | e717b1b | 2001-11-19 02:07:11 +0000 | [diff] [blame] | 1945 | retvalue = *(LONG *)(((char *)wndPtr->wExtra) + offset); |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1946 | /* Special case for dialog window procedure */ |
| 1947 | if ((offset == DWL_DLGPROC) && (wndPtr->flags & WIN_ISDIALOG)) |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 1948 | retvalue = (LONG)WINPROC_GetProc( (HWINDOWPROC)retvalue, type ); |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 1949 | WIN_ReleasePtr( wndPtr ); |
| 1950 | return retvalue; |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 1951 | } |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 1952 | |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 1953 | switch(offset) |
| 1954 | { |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 1955 | case GWL_USERDATA: retvalue = wndPtr->userdata; break; |
| 1956 | case GWL_STYLE: retvalue = wndPtr->dwStyle; break; |
| 1957 | case GWL_EXSTYLE: retvalue = wndPtr->dwExStyle; break; |
| 1958 | case GWL_ID: retvalue = (LONG)wndPtr->wIDmenu; break; |
| 1959 | case GWL_WNDPROC: retvalue = (LONG)WINPROC_GetProc( wndPtr->winproc, type ); break; |
| 1960 | case GWL_HINSTANCE: retvalue = wndPtr->hInstance; break; |
| 1961 | default: |
| 1962 | WARN("Unknown offset %d\n", offset ); |
| 1963 | SetLastError( ERROR_INVALID_INDEX ); |
| 1964 | break; |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 1965 | } |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 1966 | WIN_ReleasePtr(wndPtr); |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 1967 | return retvalue; |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 1968 | } |
| 1969 | |
| 1970 | |
| 1971 | /********************************************************************** |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1972 | * WIN_SetWindowLong |
| 1973 | * |
| 1974 | * Helper function for SetWindowLong(). |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 1975 | * |
| 1976 | * 0 is the failure code. However, in the case of failure SetLastError |
| 1977 | * must be set to distinguish between a 0 return value and a failure. |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 1978 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1979 | static LONG WIN_SetWindowLong( HWND hwnd, INT offset, LONG newval, |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1980 | WINDOWPROCTYPE type ) |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 1981 | { |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 1982 | LONG retval = 0; |
| 1983 | WND *wndPtr; |
Alexandre Julliard | 0d92fe2 | 2001-09-10 23:26:42 +0000 | [diff] [blame] | 1984 | |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 1985 | TRACE( "%x %d %lx %x\n", hwnd, offset, newval, type ); |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 1986 | |
Alexandre Julliard | 5555731 | 2001-10-23 00:26:10 +0000 | [diff] [blame] | 1987 | if (!WIN_IsCurrentProcess( hwnd )) |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 1988 | { |
Alexandre Julliard | 5555731 | 2001-10-23 00:26:10 +0000 | [diff] [blame] | 1989 | if (offset == GWL_WNDPROC) |
| 1990 | { |
| 1991 | SetLastError( ERROR_ACCESS_DENIED ); |
| 1992 | return 0; |
| 1993 | } |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 1994 | return SendMessageW( hwnd, WM_WINE_SETWINDOWLONG, offset, newval ); |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 1995 | } |
| 1996 | |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 1997 | wndPtr = WIN_GetPtr( hwnd ); |
Alexandre Julliard | 7dafa61 | 2002-09-25 00:21:56 +0000 | [diff] [blame] | 1998 | if (wndPtr->hwndSelf == GetDesktopWindow()) |
| 1999 | { |
| 2000 | /* can't change anything on the desktop window */ |
Alexandre Julliard | 02b8cb7 | 2002-09-25 03:25:43 +0000 | [diff] [blame] | 2001 | WIN_ReleasePtr( wndPtr ); |
Alexandre Julliard | 7dafa61 | 2002-09-25 00:21:56 +0000 | [diff] [blame] | 2002 | SetLastError( ERROR_ACCESS_DENIED ); |
| 2003 | return 0; |
| 2004 | } |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 2005 | |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2006 | if (offset >= 0) |
| 2007 | { |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 2008 | LONG *ptr = (LONG *)(((char *)wndPtr->wExtra) + offset); |
| 2009 | if (offset > wndPtr->cbWndExtra - sizeof(LONG)) |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2010 | { |
Dimitrie O. Paun | dd03cc1 | 1999-12-08 03:56:23 +0000 | [diff] [blame] | 2011 | WARN("Invalid offset %d\n", offset ); |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 2012 | WIN_ReleasePtr( wndPtr ); |
| 2013 | SetLastError( ERROR_INVALID_INDEX ); |
| 2014 | return 0; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2015 | } |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2016 | /* Special case for dialog window procedure */ |
| 2017 | if ((offset == DWL_DLGPROC) && (wndPtr->flags & WIN_ISDIALOG)) |
| 2018 | { |
| 2019 | retval = (LONG)WINPROC_GetProc( (HWINDOWPROC)*ptr, type ); |
Alexandre Julliard | 0d92fe2 | 2001-09-10 23:26:42 +0000 | [diff] [blame] | 2020 | WINPROC_SetProc( (HWINDOWPROC *)ptr, (WNDPROC16)newval, |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 2021 | type, WIN_PROC_WINDOW ); |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 2022 | WIN_ReleasePtr( wndPtr ); |
| 2023 | return retval; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2024 | } |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 2025 | retval = *ptr; |
| 2026 | *ptr = newval; |
| 2027 | WIN_ReleasePtr( wndPtr ); |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2028 | } |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 2029 | else |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 2030 | { |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 2031 | STYLESTRUCT style; |
| 2032 | BOOL ok; |
| 2033 | |
| 2034 | /* first some special cases */ |
| 2035 | switch( offset ) |
| 2036 | { |
| 2037 | case GWL_STYLE: |
Alexandre Julliard | 0d92fe2 | 2001-09-10 23:26:42 +0000 | [diff] [blame] | 2038 | case GWL_EXSTYLE: |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 2039 | style.styleOld = wndPtr->dwStyle; |
| 2040 | style.styleNew = newval; |
| 2041 | WIN_ReleasePtr( wndPtr ); |
| 2042 | SendMessageW( hwnd, WM_STYLECHANGING, offset, (LPARAM)&style ); |
| 2043 | if (!(wndPtr = WIN_GetPtr( hwnd )) || wndPtr == WND_OTHER_PROCESS) return 0; |
| 2044 | newval = style.styleNew; |
| 2045 | break; |
| 2046 | case GWL_HWNDPARENT: |
Alexandre Julliard | 7dafa61 | 2002-09-25 00:21:56 +0000 | [diff] [blame] | 2047 | if (wndPtr->parent == GetDesktopWindow()) |
| 2048 | { |
| 2049 | WIN_ReleasePtr( wndPtr ); |
| 2050 | return (LONG)WIN_SetOwner( hwnd, (HWND)newval ); |
| 2051 | } |
| 2052 | else |
| 2053 | { |
| 2054 | WIN_ReleasePtr( wndPtr ); |
| 2055 | return (LONG)SetParent( hwnd, (HWND)newval ); |
| 2056 | } |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 2057 | case GWL_WNDPROC: |
| 2058 | retval = (LONG)WINPROC_GetProc( wndPtr->winproc, type ); |
| 2059 | WINPROC_SetProc( &wndPtr->winproc, (WNDPROC16)newval, |
| 2060 | type, WIN_PROC_WINDOW ); |
| 2061 | WIN_ReleasePtr( wndPtr ); |
| 2062 | return retval; |
| 2063 | case GWL_ID: |
| 2064 | case GWL_HINSTANCE: |
| 2065 | case GWL_USERDATA: |
| 2066 | break; |
| 2067 | default: |
| 2068 | WIN_ReleasePtr( wndPtr ); |
Dimitrie O. Paun | dd03cc1 | 1999-12-08 03:56:23 +0000 | [diff] [blame] | 2069 | WARN("Invalid offset %d\n", offset ); |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 2070 | SetLastError( ERROR_INVALID_INDEX ); |
| 2071 | return 0; |
| 2072 | } |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 2073 | |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 2074 | SERVER_START_REQ( set_window_info ) |
| 2075 | { |
| 2076 | req->handle = hwnd; |
| 2077 | switch(offset) |
| 2078 | { |
| 2079 | case GWL_STYLE: |
| 2080 | req->flags = SET_WIN_STYLE; |
| 2081 | req->style = newval; |
| 2082 | break; |
| 2083 | case GWL_EXSTYLE: |
| 2084 | req->flags = SET_WIN_EXSTYLE; |
| 2085 | req->ex_style = newval; |
| 2086 | break; |
| 2087 | case GWL_ID: |
| 2088 | req->flags = SET_WIN_ID; |
| 2089 | req->id = newval; |
| 2090 | break; |
| 2091 | case GWL_HINSTANCE: |
| 2092 | req->flags = SET_WIN_INSTANCE; |
| 2093 | req->instance = (void *)newval; |
| 2094 | break; |
| 2095 | case GWL_USERDATA: |
| 2096 | req->flags = SET_WIN_USERDATA; |
| 2097 | req->user_data = (void *)newval; |
| 2098 | break; |
| 2099 | } |
Alexandre Julliard | 9caa71e | 2001-11-30 18:46:42 +0000 | [diff] [blame] | 2100 | if ((ok = !wine_server_call_err( req ))) |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 2101 | { |
| 2102 | switch(offset) |
| 2103 | { |
| 2104 | case GWL_STYLE: |
| 2105 | wndPtr->dwStyle = newval; |
Alexandre Julliard | 9caa71e | 2001-11-30 18:46:42 +0000 | [diff] [blame] | 2106 | retval = reply->old_style; |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 2107 | break; |
| 2108 | case GWL_EXSTYLE: |
| 2109 | wndPtr->dwExStyle = newval; |
Alexandre Julliard | 9caa71e | 2001-11-30 18:46:42 +0000 | [diff] [blame] | 2110 | retval = reply->old_ex_style; |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 2111 | break; |
| 2112 | case GWL_ID: |
| 2113 | wndPtr->wIDmenu = newval; |
Alexandre Julliard | 9caa71e | 2001-11-30 18:46:42 +0000 | [diff] [blame] | 2114 | retval = reply->old_id; |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 2115 | break; |
| 2116 | case GWL_HINSTANCE: |
| 2117 | wndPtr->hInstance = newval; |
Alexandre Julliard | 9caa71e | 2001-11-30 18:46:42 +0000 | [diff] [blame] | 2118 | retval = (HINSTANCE)reply->old_instance; |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 2119 | break; |
| 2120 | case GWL_USERDATA: |
| 2121 | wndPtr->userdata = newval; |
Alexandre Julliard | 9caa71e | 2001-11-30 18:46:42 +0000 | [diff] [blame] | 2122 | retval = (ULONG_PTR)reply->old_user_data; |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 2123 | break; |
| 2124 | } |
| 2125 | } |
| 2126 | } |
| 2127 | SERVER_END_REQ; |
| 2128 | WIN_ReleasePtr( wndPtr ); |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 2129 | |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 2130 | if (!ok) return 0; |
| 2131 | |
| 2132 | if (offset == GWL_STYLE && USER_Driver.pSetWindowStyle) |
| 2133 | USER_Driver.pSetWindowStyle( hwnd, retval ); |
| 2134 | |
| 2135 | if (offset == GWL_STYLE || offset == GWL_EXSTYLE) |
| 2136 | SendMessageW( hwnd, WM_STYLECHANGED, offset, (LPARAM)&style ); |
| 2137 | |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 2138 | } |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 2139 | return retval; |
| 2140 | } |
| 2141 | |
| 2142 | |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 2143 | /********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2144 | * GetWindowLong (USER.135) |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2145 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 2146 | LONG WINAPI GetWindowLong16( HWND16 hwnd, INT16 offset ) |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2147 | { |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 2148 | return WIN_GetWindowLong( WIN_Handle32(hwnd), offset, WIN_PROC_16 ); |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2149 | } |
| 2150 | |
| 2151 | |
| 2152 | /********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2153 | * GetWindowLongA (USER32.@) |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2154 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2155 | LONG WINAPI GetWindowLongA( HWND hwnd, INT offset ) |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2156 | { |
| 2157 | return WIN_GetWindowLong( hwnd, offset, WIN_PROC_32A ); |
| 2158 | } |
| 2159 | |
| 2160 | |
| 2161 | /********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2162 | * GetWindowLongW (USER32.@) |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2163 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2164 | LONG WINAPI GetWindowLongW( HWND hwnd, INT offset ) |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2165 | { |
| 2166 | return WIN_GetWindowLong( hwnd, offset, WIN_PROC_32W ); |
| 2167 | } |
| 2168 | |
| 2169 | |
| 2170 | /********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2171 | * SetWindowLong (USER.136) |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2172 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 2173 | LONG WINAPI SetWindowLong16( HWND16 hwnd, INT16 offset, LONG newval ) |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2174 | { |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 2175 | return WIN_SetWindowLong( WIN_Handle32(hwnd), offset, newval, WIN_PROC_16 ); |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2176 | } |
| 2177 | |
| 2178 | |
| 2179 | /********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2180 | * SetWindowLongA (USER32.@) |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2181 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2182 | LONG WINAPI SetWindowLongA( HWND hwnd, INT offset, LONG newval ) |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2183 | { |
| 2184 | return WIN_SetWindowLong( hwnd, offset, newval, WIN_PROC_32A ); |
| 2185 | } |
| 2186 | |
| 2187 | |
| 2188 | /********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2189 | * SetWindowLongW (USER32.@) Set window attribute |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 2190 | * |
| 2191 | * SetWindowLong() alters one of a window's attributes or sets a 32-bit (long) |
Alexandre Julliard | 0d92fe2 | 2001-09-10 23:26:42 +0000 | [diff] [blame] | 2192 | * value in a window's extra memory. |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 2193 | * |
| 2194 | * The _hwnd_ parameter specifies the window. is the handle to a |
| 2195 | * window that has extra memory. The _newval_ parameter contains the |
| 2196 | * new attribute or extra memory value. If positive, the _offset_ |
| 2197 | * parameter is the byte-addressed location in the window's extra |
| 2198 | * memory to set. If negative, _offset_ specifies the window |
| 2199 | * attribute to set, and should be one of the following values: |
| 2200 | * |
| 2201 | * GWL_EXSTYLE The window's extended window style |
| 2202 | * |
Alexandre Julliard | 0d92fe2 | 2001-09-10 23:26:42 +0000 | [diff] [blame] | 2203 | * GWL_STYLE The window's window style. |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 2204 | * |
Alexandre Julliard | 0d92fe2 | 2001-09-10 23:26:42 +0000 | [diff] [blame] | 2205 | * GWL_WNDPROC Pointer to the window's window procedure. |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 2206 | * |
| 2207 | * GWL_HINSTANCE The window's pplication instance handle. |
| 2208 | * |
| 2209 | * GWL_ID The window's identifier. |
| 2210 | * |
Alexandre Julliard | 0d92fe2 | 2001-09-10 23:26:42 +0000 | [diff] [blame] | 2211 | * GWL_USERDATA The window's user-specified data. |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 2212 | * |
Alexandre Julliard | 0d92fe2 | 2001-09-10 23:26:42 +0000 | [diff] [blame] | 2213 | * If the window is a dialog box, the _offset_ parameter can be one of |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 2214 | * the following values: |
| 2215 | * |
| 2216 | * DWL_DLGPROC The address of the window's dialog box procedure. |
| 2217 | * |
Alexandre Julliard | 0d92fe2 | 2001-09-10 23:26:42 +0000 | [diff] [blame] | 2218 | * DWL_MSGRESULT The return value of a message |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 2219 | * that the dialog box procedure processed. |
| 2220 | * |
| 2221 | * DWL_USER Application specific information. |
| 2222 | * |
| 2223 | * RETURNS |
| 2224 | * |
| 2225 | * If successful, returns the previous value located at _offset_. Otherwise, |
| 2226 | * returns 0. |
| 2227 | * |
| 2228 | * NOTES |
| 2229 | * |
Alexandre Julliard | 0d92fe2 | 2001-09-10 23:26:42 +0000 | [diff] [blame] | 2230 | * Extra memory for a window class is specified by a nonzero cbWndExtra |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 2231 | * parameter of the WNDCLASS structure passed to RegisterClass() at the |
| 2232 | * time of class creation. |
Alexandre Julliard | 0d92fe2 | 2001-09-10 23:26:42 +0000 | [diff] [blame] | 2233 | * |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 2234 | * Using GWL_WNDPROC to set a new window procedure effectively creates |
| 2235 | * a window subclass. Use CallWindowProc() in the new windows procedure |
| 2236 | * to pass messages to the superclass's window procedure. |
| 2237 | * |
| 2238 | * The user data is reserved for use by the application which created |
| 2239 | * the window. |
| 2240 | * |
Gerard Patel | e717b1b | 2001-11-19 02:07:11 +0000 | [diff] [blame] | 2241 | * Do not use GWL_STYLE to change the window's WS_DISABLED style; |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 2242 | * instead, call the EnableWindow() function to change the window's |
| 2243 | * disabled state. |
| 2244 | * |
| 2245 | * Do not use GWL_HWNDPARENT to reset the window's parent, use |
| 2246 | * SetParent() instead. |
| 2247 | * |
Alexandre Julliard | 638f169 | 1999-01-17 16:32:32 +0000 | [diff] [blame] | 2248 | * Win95: |
| 2249 | * When offset is GWL_STYLE and the calling app's ver is 4.0, |
| 2250 | * it sends WM_STYLECHANGING before changing the settings |
| 2251 | * and WM_STYLECHANGED afterwards. |
| 2252 | * App ver 4.0 can't use SetWindowLong to change WS_EX_TOPMOST. |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 2253 | */ |
Alexandre Julliard | 0d92fe2 | 2001-09-10 23:26:42 +0000 | [diff] [blame] | 2254 | LONG WINAPI SetWindowLongW( |
Patrik Stridvall | 2b3aa61 | 2000-12-01 23:58:28 +0000 | [diff] [blame] | 2255 | HWND hwnd, /* [in] window to alter */ |
| 2256 | INT offset, /* [in] offset, in bytes, of location to alter */ |
| 2257 | LONG newval /* [in] new value of location */ |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 2258 | ) { |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2259 | return WIN_SetWindowLong( hwnd, offset, newval, WIN_PROC_32W ); |
Alexandre Julliard | e2abbb1 | 1995-03-19 17:39:39 +0000 | [diff] [blame] | 2260 | } |
| 2261 | |
| 2262 | |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 2263 | /******************************************************************* |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2264 | * GetWindowTextA (USER32.@) |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 2265 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2266 | INT WINAPI GetWindowTextA( HWND hwnd, LPSTR lpString, INT nMaxCount ) |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 2267 | { |
Alexandre Julliard | 805bdc5 | 2001-11-13 22:23:48 +0000 | [diff] [blame] | 2268 | WCHAR *buffer; |
| 2269 | |
| 2270 | if (WIN_IsCurrentProcess( hwnd )) |
| 2271 | return (INT)SendMessageA( hwnd, WM_GETTEXT, nMaxCount, (LPARAM)lpString ); |
| 2272 | |
| 2273 | /* when window belongs to other process, don't send a message */ |
| 2274 | if (nMaxCount <= 0) return 0; |
| 2275 | if (!(buffer = HeapAlloc( GetProcessHeap(), 0, nMaxCount * sizeof(WCHAR) ))) return 0; |
| 2276 | get_server_window_text( hwnd, buffer, nMaxCount ); |
| 2277 | if (!WideCharToMultiByte( CP_ACP, 0, buffer, -1, lpString, nMaxCount, NULL, NULL )) |
| 2278 | lpString[nMaxCount-1] = 0; |
| 2279 | HeapFree( GetProcessHeap(), 0, buffer ); |
| 2280 | return strlen(lpString); |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 2281 | } |
| 2282 | |
Alexandre Julliard | 805bdc5 | 2001-11-13 22:23:48 +0000 | [diff] [blame] | 2283 | |
Alexandre Julliard | f90efa9 | 1998-06-14 15:24:15 +0000 | [diff] [blame] | 2284 | /******************************************************************* |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2285 | * InternalGetWindowText (USER32.@) |
Alexandre Julliard | f90efa9 | 1998-06-14 15:24:15 +0000 | [diff] [blame] | 2286 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2287 | INT WINAPI InternalGetWindowText(HWND hwnd,LPWSTR lpString,INT nMaxCount ) |
Alexandre Julliard | f90efa9 | 1998-06-14 15:24:15 +0000 | [diff] [blame] | 2288 | { |
Alexandre Julliard | 805bdc5 | 2001-11-13 22:23:48 +0000 | [diff] [blame] | 2289 | WND *win; |
| 2290 | |
| 2291 | if (nMaxCount <= 0) return 0; |
| 2292 | if (!(win = WIN_GetPtr( hwnd ))) return 0; |
| 2293 | if (win != WND_OTHER_PROCESS) |
| 2294 | { |
| 2295 | if (win->text) lstrcpynW( lpString, win->text, nMaxCount ); |
| 2296 | else lpString[0] = 0; |
| 2297 | WIN_ReleasePtr( win ); |
| 2298 | } |
| 2299 | else |
| 2300 | { |
| 2301 | get_server_window_text( hwnd, lpString, nMaxCount ); |
| 2302 | } |
Alexandre Julliard | dc4fe77 | 2001-06-04 21:55:17 +0000 | [diff] [blame] | 2303 | return strlenW(lpString); |
Alexandre Julliard | f90efa9 | 1998-06-14 15:24:15 +0000 | [diff] [blame] | 2304 | } |
| 2305 | |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 2306 | |
| 2307 | /******************************************************************* |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2308 | * GetWindowTextW (USER32.@) |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 2309 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2310 | INT WINAPI GetWindowTextW( HWND hwnd, LPWSTR lpString, INT nMaxCount ) |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 2311 | { |
Alexandre Julliard | 805bdc5 | 2001-11-13 22:23:48 +0000 | [diff] [blame] | 2312 | if (WIN_IsCurrentProcess( hwnd )) |
| 2313 | return (INT)SendMessageW( hwnd, WM_GETTEXT, nMaxCount, (LPARAM)lpString ); |
| 2314 | |
| 2315 | /* when window belongs to other process, don't send a message */ |
| 2316 | if (nMaxCount <= 0) return 0; |
| 2317 | get_server_window_text( hwnd, lpString, nMaxCount ); |
| 2318 | return strlenW(lpString); |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 2319 | } |
| 2320 | |
| 2321 | |
| 2322 | /******************************************************************* |
Patrik Stridvall | 17fd4e3 | 2001-06-28 18:04:41 +0000 | [diff] [blame] | 2323 | * SetWindowText (USER32.@) |
| 2324 | * SetWindowTextA (USER32.@) |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 2325 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2326 | BOOL WINAPI SetWindowTextA( HWND hwnd, LPCSTR lpString ) |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 2327 | { |
Alexandre Julliard | 805bdc5 | 2001-11-13 22:23:48 +0000 | [diff] [blame] | 2328 | if (!WIN_IsCurrentProcess( hwnd )) |
| 2329 | { |
| 2330 | FIXME( "cannot set text %s of other process window %x\n", debugstr_a(lpString), hwnd ); |
| 2331 | SetLastError( ERROR_ACCESS_DENIED ); |
| 2332 | return FALSE; |
| 2333 | } |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2334 | return (BOOL)SendMessageA( hwnd, WM_SETTEXT, 0, (LPARAM)lpString ); |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 2335 | } |
| 2336 | |
| 2337 | |
| 2338 | /******************************************************************* |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2339 | * SetWindowTextW (USER32.@) |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 2340 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2341 | BOOL WINAPI SetWindowTextW( HWND hwnd, LPCWSTR lpString ) |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 2342 | { |
Alexandre Julliard | 805bdc5 | 2001-11-13 22:23:48 +0000 | [diff] [blame] | 2343 | if (!WIN_IsCurrentProcess( hwnd )) |
| 2344 | { |
| 2345 | FIXME( "cannot set text %s of other process window %x\n", debugstr_w(lpString), hwnd ); |
| 2346 | SetLastError( ERROR_ACCESS_DENIED ); |
| 2347 | return FALSE; |
| 2348 | } |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2349 | return (BOOL)SendMessageW( hwnd, WM_SETTEXT, 0, (LPARAM)lpString ); |
Alexandre Julliard | e2abbb1 | 1995-03-19 17:39:39 +0000 | [diff] [blame] | 2350 | } |
| 2351 | |
| 2352 | |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 2353 | /******************************************************************* |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2354 | * GetWindowTextLengthA (USER32.@) |
Alexandre Julliard | b1bac32 | 1996-12-15 19:45:59 +0000 | [diff] [blame] | 2355 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2356 | INT WINAPI GetWindowTextLengthA( HWND hwnd ) |
Alexandre Julliard | b1bac32 | 1996-12-15 19:45:59 +0000 | [diff] [blame] | 2357 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2358 | return SendMessageA( hwnd, WM_GETTEXTLENGTH, 0, 0 ); |
Alexandre Julliard | b1bac32 | 1996-12-15 19:45:59 +0000 | [diff] [blame] | 2359 | } |
| 2360 | |
| 2361 | /******************************************************************* |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2362 | * GetWindowTextLengthW (USER32.@) |
Alexandre Julliard | b1bac32 | 1996-12-15 19:45:59 +0000 | [diff] [blame] | 2363 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2364 | INT WINAPI GetWindowTextLengthW( HWND hwnd ) |
Alexandre Julliard | b1bac32 | 1996-12-15 19:45:59 +0000 | [diff] [blame] | 2365 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2366 | return SendMessageW( hwnd, WM_GETTEXTLENGTH, 0, 0 ); |
Alexandre Julliard | b1bac32 | 1996-12-15 19:45:59 +0000 | [diff] [blame] | 2367 | } |
| 2368 | |
Alexandre Julliard | 2197901 | 1997-03-05 08:22:35 +0000 | [diff] [blame] | 2369 | |
Alexandre Julliard | b1bac32 | 1996-12-15 19:45:59 +0000 | [diff] [blame] | 2370 | /******************************************************************* |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2371 | * IsWindow (USER32.@) |
Alexandre Julliard | 2197901 | 1997-03-05 08:22:35 +0000 | [diff] [blame] | 2372 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2373 | BOOL WINAPI IsWindow( HWND hwnd ) |
Alexandre Julliard | e399fc3 | 1993-11-24 17:08:56 +0000 | [diff] [blame] | 2374 | { |
Alexandre Julliard | 1a66d22 | 2001-08-28 18:44:52 +0000 | [diff] [blame] | 2375 | WND *ptr; |
Alexandre Julliard | 37a4639 | 2001-09-12 17:19:13 +0000 | [diff] [blame] | 2376 | BOOL ret; |
Alexandre Julliard | 1a66d22 | 2001-08-28 18:44:52 +0000 | [diff] [blame] | 2377 | |
Alexandre Julliard | 8fd26b9 | 2001-10-15 17:56:45 +0000 | [diff] [blame] | 2378 | if (!(ptr = WIN_GetPtr( hwnd ))) return FALSE; |
| 2379 | |
| 2380 | if (ptr != WND_OTHER_PROCESS) |
Alexandre Julliard | 1a66d22 | 2001-08-28 18:44:52 +0000 | [diff] [blame] | 2381 | { |
Alexandre Julliard | 8fd26b9 | 2001-10-15 17:56:45 +0000 | [diff] [blame] | 2382 | WIN_ReleasePtr( ptr ); |
Alexandre Julliard | 7695d69 | 2001-09-24 01:19:59 +0000 | [diff] [blame] | 2383 | return TRUE; |
Alexandre Julliard | 1a66d22 | 2001-08-28 18:44:52 +0000 | [diff] [blame] | 2384 | } |
Alexandre Julliard | 1a66d22 | 2001-08-28 18:44:52 +0000 | [diff] [blame] | 2385 | |
Alexandre Julliard | 37a4639 | 2001-09-12 17:19:13 +0000 | [diff] [blame] | 2386 | /* check other processes */ |
| 2387 | SERVER_START_REQ( get_window_info ) |
Alexandre Julliard | 1a66d22 | 2001-08-28 18:44:52 +0000 | [diff] [blame] | 2388 | { |
Alexandre Julliard | 37a4639 | 2001-09-12 17:19:13 +0000 | [diff] [blame] | 2389 | req->handle = hwnd; |
Alexandre Julliard | 9caa71e | 2001-11-30 18:46:42 +0000 | [diff] [blame] | 2390 | ret = !wine_server_call_err( req ); |
Alexandre Julliard | 1a66d22 | 2001-08-28 18:44:52 +0000 | [diff] [blame] | 2391 | } |
Alexandre Julliard | 37a4639 | 2001-09-12 17:19:13 +0000 | [diff] [blame] | 2392 | SERVER_END_REQ; |
Alexandre Julliard | 1a66d22 | 2001-08-28 18:44:52 +0000 | [diff] [blame] | 2393 | return ret; |
| 2394 | } |
| 2395 | |
| 2396 | |
| 2397 | /*********************************************************************** |
| 2398 | * GetWindowThreadProcessId (USER32.@) |
| 2399 | */ |
| 2400 | DWORD WINAPI GetWindowThreadProcessId( HWND hwnd, LPDWORD process ) |
| 2401 | { |
| 2402 | WND *ptr; |
| 2403 | DWORD tid = 0; |
| 2404 | |
Alexandre Julliard | 8fd26b9 | 2001-10-15 17:56:45 +0000 | [diff] [blame] | 2405 | if (!(ptr = WIN_GetPtr( hwnd ))) |
Alexandre Julliard | 1a66d22 | 2001-08-28 18:44:52 +0000 | [diff] [blame] | 2406 | { |
Alexandre Julliard | 8fd26b9 | 2001-10-15 17:56:45 +0000 | [diff] [blame] | 2407 | SetLastError( ERROR_INVALID_WINDOW_HANDLE); |
| 2408 | return 0; |
| 2409 | } |
| 2410 | |
| 2411 | if (ptr != WND_OTHER_PROCESS) |
| 2412 | { |
| 2413 | /* got a valid window */ |
| 2414 | tid = ptr->tid; |
| 2415 | if (process) *process = GetCurrentProcessId(); |
| 2416 | WIN_ReleasePtr( ptr ); |
Alexandre Julliard | 1a66d22 | 2001-08-28 18:44:52 +0000 | [diff] [blame] | 2417 | return tid; |
| 2418 | } |
Alexandre Julliard | 1a66d22 | 2001-08-28 18:44:52 +0000 | [diff] [blame] | 2419 | |
| 2420 | /* check other processes */ |
| 2421 | SERVER_START_REQ( get_window_info ) |
| 2422 | { |
| 2423 | req->handle = hwnd; |
Alexandre Julliard | 9caa71e | 2001-11-30 18:46:42 +0000 | [diff] [blame] | 2424 | if (!wine_server_call_err( req )) |
Alexandre Julliard | 1a66d22 | 2001-08-28 18:44:52 +0000 | [diff] [blame] | 2425 | { |
Alexandre Julliard | 9caa71e | 2001-11-30 18:46:42 +0000 | [diff] [blame] | 2426 | tid = (DWORD)reply->tid; |
| 2427 | if (process) *process = (DWORD)reply->pid; |
Alexandre Julliard | 1a66d22 | 2001-08-28 18:44:52 +0000 | [diff] [blame] | 2428 | } |
| 2429 | } |
| 2430 | SERVER_END_REQ; |
| 2431 | return tid; |
Alexandre Julliard | e399fc3 | 1993-11-24 17:08:56 +0000 | [diff] [blame] | 2432 | } |
| 2433 | |
| 2434 | |
| 2435 | /***************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2436 | * GetParent (USER32.@) |
Alexandre Julliard | d1ce8b2 | 1996-09-02 16:46:30 +0000 | [diff] [blame] | 2437 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2438 | HWND WINAPI GetParent( HWND hwnd ) |
Alexandre Julliard | e399fc3 | 1993-11-24 17:08:56 +0000 | [diff] [blame] | 2439 | { |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 2440 | WND *wndPtr; |
Andreas Mohr | 1c20b39 | 2000-02-20 19:17:35 +0000 | [diff] [blame] | 2441 | HWND retvalue = 0; |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 2442 | |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 2443 | if (!(wndPtr = WIN_GetPtr( hwnd ))) |
Alexandre Julliard | 9d9dac0 | 2001-08-24 19:28:21 +0000 | [diff] [blame] | 2444 | { |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 2445 | SetLastError( ERROR_INVALID_WINDOW_HANDLE ); |
| 2446 | return 0; |
| 2447 | } |
| 2448 | if (wndPtr == WND_OTHER_PROCESS) |
| 2449 | { |
| 2450 | LONG style = GetWindowLongW( hwnd, GWL_STYLE ); |
| 2451 | if (style & (WS_POPUP | WS_CHILD)) |
| 2452 | { |
| 2453 | SERVER_START_REQ( get_window_tree ) |
| 2454 | { |
| 2455 | req->handle = hwnd; |
Alexandre Julliard | 9caa71e | 2001-11-30 18:46:42 +0000 | [diff] [blame] | 2456 | if (!wine_server_call_err( req )) |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 2457 | { |
Alexandre Julliard | 7dafa61 | 2002-09-25 00:21:56 +0000 | [diff] [blame] | 2458 | if (style & WS_POPUP) retvalue = reply->owner; |
| 2459 | else if (style & WS_CHILD) retvalue = reply->parent; |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 2460 | } |
| 2461 | } |
| 2462 | SERVER_END_REQ; |
| 2463 | } |
| 2464 | } |
| 2465 | else |
| 2466 | { |
Alexandre Julliard | 7dafa61 | 2002-09-25 00:21:56 +0000 | [diff] [blame] | 2467 | if (wndPtr->dwStyle & WS_POPUP) retvalue = wndPtr->owner; |
| 2468 | else if (wndPtr->dwStyle & WS_CHILD) retvalue = wndPtr->parent; |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 2469 | WIN_ReleasePtr( wndPtr ); |
Alexandre Julliard | 9d9dac0 | 2001-08-24 19:28:21 +0000 | [diff] [blame] | 2470 | } |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 2471 | return retvalue; |
Alexandre Julliard | e399fc3 | 1993-11-24 17:08:56 +0000 | [diff] [blame] | 2472 | } |
| 2473 | |
Alexandre Julliard | e2991ea | 1995-07-29 13:09:43 +0000 | [diff] [blame] | 2474 | |
| 2475 | /***************************************************************** |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 2476 | * GetAncestor (USER32.@) |
Alexandre Julliard | e2991ea | 1995-07-29 13:09:43 +0000 | [diff] [blame] | 2477 | */ |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 2478 | HWND WINAPI GetAncestor( HWND hwnd, UINT type ) |
Alexandre Julliard | e2991ea | 1995-07-29 13:09:43 +0000 | [diff] [blame] | 2479 | { |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 2480 | WND *win; |
Alexandre Julliard | 9caa71e | 2001-11-30 18:46:42 +0000 | [diff] [blame] | 2481 | HWND *list, ret = 0; |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 2482 | |
Alexandre Julliard | 7dafa61 | 2002-09-25 00:21:56 +0000 | [diff] [blame] | 2483 | switch(type) |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 2484 | { |
Alexandre Julliard | 7dafa61 | 2002-09-25 00:21:56 +0000 | [diff] [blame] | 2485 | case GA_PARENT: |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 2486 | if (!(win = WIN_GetPtr( hwnd ))) |
| 2487 | { |
| 2488 | SetLastError( ERROR_INVALID_WINDOW_HANDLE ); |
| 2489 | return 0; |
| 2490 | } |
Alexandre Julliard | 9caa71e | 2001-11-30 18:46:42 +0000 | [diff] [blame] | 2491 | if (win != WND_OTHER_PROCESS) |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 2492 | { |
Alexandre Julliard | 9caa71e | 2001-11-30 18:46:42 +0000 | [diff] [blame] | 2493 | ret = win->parent; |
| 2494 | WIN_ReleasePtr( win ); |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 2495 | } |
Alexandre Julliard | 9caa71e | 2001-11-30 18:46:42 +0000 | [diff] [blame] | 2496 | else /* need to query the server */ |
Alexandre Julliard | 9d9dac0 | 2001-08-24 19:28:21 +0000 | [diff] [blame] | 2497 | { |
Alexandre Julliard | 9caa71e | 2001-11-30 18:46:42 +0000 | [diff] [blame] | 2498 | SERVER_START_REQ( get_window_tree ) |
Alexandre Julliard | 556607a | 2001-10-10 20:28:17 +0000 | [diff] [blame] | 2499 | { |
Alexandre Julliard | 9caa71e | 2001-11-30 18:46:42 +0000 | [diff] [blame] | 2500 | req->handle = hwnd; |
| 2501 | if (!wine_server_call_err( req )) ret = reply->parent; |
Alexandre Julliard | 556607a | 2001-10-10 20:28:17 +0000 | [diff] [blame] | 2502 | } |
Alexandre Julliard | 9caa71e | 2001-11-30 18:46:42 +0000 | [diff] [blame] | 2503 | SERVER_END_REQ; |
Alexandre Julliard | 9d9dac0 | 2001-08-24 19:28:21 +0000 | [diff] [blame] | 2504 | } |
Alexandre Julliard | 7dafa61 | 2002-09-25 00:21:56 +0000 | [diff] [blame] | 2505 | break; |
Alexandre Julliard | 556607a | 2001-10-10 20:28:17 +0000 | [diff] [blame] | 2506 | |
Alexandre Julliard | 7dafa61 | 2002-09-25 00:21:56 +0000 | [diff] [blame] | 2507 | case GA_ROOT: |
| 2508 | if (!(list = WIN_ListParents( hwnd ))) return 0; |
Alexandre Julliard | 9caa71e | 2001-11-30 18:46:42 +0000 | [diff] [blame] | 2509 | |
Alexandre Julliard | 7dafa61 | 2002-09-25 00:21:56 +0000 | [diff] [blame] | 2510 | if (!list[0] || !list[1]) ret = WIN_GetFullHandle( hwnd ); /* top-level window */ |
| 2511 | else |
| 2512 | { |
| 2513 | int count = 2; |
| 2514 | while (list[count]) count++; |
| 2515 | ret = list[count - 2]; /* get the one before the desktop */ |
| 2516 | } |
| 2517 | HeapFree( GetProcessHeap(), 0, list ); |
| 2518 | break; |
Alexandre Julliard | 9caa71e | 2001-11-30 18:46:42 +0000 | [diff] [blame] | 2519 | |
Alexandre Julliard | 7dafa61 | 2002-09-25 00:21:56 +0000 | [diff] [blame] | 2520 | case GA_ROOTOWNER: |
| 2521 | if ((ret = WIN_GetFullHandle( hwnd )) == GetDesktopWindow()) return 0; |
Alexandre Julliard | 556607a | 2001-10-10 20:28:17 +0000 | [diff] [blame] | 2522 | for (;;) |
| 2523 | { |
Alexandre Julliard | 7dafa61 | 2002-09-25 00:21:56 +0000 | [diff] [blame] | 2524 | HWND parent = GetParent( ret ); |
| 2525 | if (!parent) break; |
| 2526 | ret = parent; |
Alexandre Julliard | 556607a | 2001-10-10 20:28:17 +0000 | [diff] [blame] | 2527 | } |
Alexandre Julliard | 7dafa61 | 2002-09-25 00:21:56 +0000 | [diff] [blame] | 2528 | break; |
Alexandre Julliard | 556607a | 2001-10-10 20:28:17 +0000 | [diff] [blame] | 2529 | } |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 2530 | return ret; |
Alexandre Julliard | e2991ea | 1995-07-29 13:09:43 +0000 | [diff] [blame] | 2531 | } |
| 2532 | |
| 2533 | |
Alexandre Julliard | 940d58c | 1994-09-16 09:24:37 +0000 | [diff] [blame] | 2534 | /***************************************************************** |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 2535 | * SetParent (USER32.@) |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 2536 | */ |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 2537 | HWND WINAPI SetParent( HWND hwnd, HWND parent ) |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 2538 | { |
Alexandre Julliard | 9ae0fe5 | 2001-04-24 23:28:52 +0000 | [diff] [blame] | 2539 | WND *wndPtr; |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 2540 | HWND retvalue, full_handle; |
Alexandre Julliard | fb0ff05 | 2001-10-16 21:58:58 +0000 | [diff] [blame] | 2541 | BOOL was_visible; |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 2542 | |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 2543 | if (!parent) parent = GetDesktopWindow(); |
| 2544 | else parent = WIN_GetFullHandle( parent ); |
| 2545 | |
| 2546 | if (!IsWindow( parent )) |
| 2547 | { |
| 2548 | SetLastError( ERROR_INVALID_WINDOW_HANDLE ); |
| 2549 | return 0; |
| 2550 | } |
| 2551 | |
| 2552 | if (!(full_handle = WIN_IsCurrentThread( hwnd ))) |
Michael Stefaniuc | 2247af3 | 2002-09-04 19:37:01 +0000 | [diff] [blame] | 2553 | return (HWND)SendMessageW( hwnd, WM_WINE_SETPARENT, (WPARAM)parent, 0 ); |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 2554 | |
| 2555 | hwnd = full_handle; |
| 2556 | |
Alexandre Julliard | 9ae0fe5 | 2001-04-24 23:28:52 +0000 | [diff] [blame] | 2557 | if (USER_Driver.pSetParent) |
| 2558 | return USER_Driver.pSetParent( hwnd, parent ); |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 2559 | |
Alexandre Julliard | 9ae0fe5 | 2001-04-24 23:28:52 +0000 | [diff] [blame] | 2560 | /* Windows hides the window first, then shows it again |
| 2561 | * including the WM_SHOWWINDOW messages and all */ |
Alexandre Julliard | fb0ff05 | 2001-10-16 21:58:58 +0000 | [diff] [blame] | 2562 | was_visible = ShowWindow( hwnd, SW_HIDE ); |
| 2563 | |
| 2564 | if (!IsWindow( parent )) return 0; |
| 2565 | if (!(wndPtr = WIN_GetPtr(hwnd)) || wndPtr == WND_OTHER_PROCESS) return 0; |
Alexandre Julliard | 940d58c | 1994-09-16 09:24:37 +0000 | [diff] [blame] | 2566 | |
Alexandre Julliard | 556607a | 2001-10-10 20:28:17 +0000 | [diff] [blame] | 2567 | retvalue = wndPtr->parent; /* old parent */ |
Alexandre Julliard | 1a66d22 | 2001-08-28 18:44:52 +0000 | [diff] [blame] | 2568 | if (parent != retvalue) |
Alexandre Julliard | 9ae0fe5 | 2001-04-24 23:28:52 +0000 | [diff] [blame] | 2569 | { |
Alexandre Julliard | 1a66d22 | 2001-08-28 18:44:52 +0000 | [diff] [blame] | 2570 | WIN_LinkWindow( hwnd, parent, HWND_TOP ); |
Ove Kaaven | 72d8dbe | 1999-02-13 09:02:17 +0000 | [diff] [blame] | 2571 | |
Alexandre Julliard | 9ae0fe5 | 2001-04-24 23:28:52 +0000 | [diff] [blame] | 2572 | if (parent != GetDesktopWindow()) /* a child window */ |
| 2573 | { |
Alexandre Julliard | fb0ff05 | 2001-10-16 21:58:58 +0000 | [diff] [blame] | 2574 | if (!(wndPtr->dwStyle & WS_CHILD)) |
Alexandre Julliard | 9ae0fe5 | 2001-04-24 23:28:52 +0000 | [diff] [blame] | 2575 | { |
Alexandre Julliard | 1a66d22 | 2001-08-28 18:44:52 +0000 | [diff] [blame] | 2576 | HMENU menu = (HMENU)SetWindowLongW( hwnd, GWL_ID, 0 ); |
| 2577 | if (menu) DestroyMenu( menu ); |
Alexandre Julliard | 9ae0fe5 | 2001-04-24 23:28:52 +0000 | [diff] [blame] | 2578 | } |
| 2579 | } |
Alexandre Julliard | 9ae0fe5 | 2001-04-24 23:28:52 +0000 | [diff] [blame] | 2580 | } |
Alexandre Julliard | fb0ff05 | 2001-10-16 21:58:58 +0000 | [diff] [blame] | 2581 | WIN_ReleasePtr( wndPtr ); |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 2582 | |
Alexandre Julliard | 9ae0fe5 | 2001-04-24 23:28:52 +0000 | [diff] [blame] | 2583 | /* SetParent additionally needs to make hwnd the topmost window |
| 2584 | in the x-order and send the expected WM_WINDOWPOSCHANGING and |
Alexandre Julliard | 0d92fe2 | 2001-09-10 23:26:42 +0000 | [diff] [blame] | 2585 | WM_WINDOWPOSCHANGED notification messages. |
Alexandre Julliard | 9ae0fe5 | 2001-04-24 23:28:52 +0000 | [diff] [blame] | 2586 | */ |
| 2587 | SetWindowPos( hwnd, HWND_TOPMOST, 0, 0, 0, 0, |
Alexandre Julliard | fb0ff05 | 2001-10-16 21:58:58 +0000 | [diff] [blame] | 2588 | SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | (was_visible ? SWP_SHOWWINDOW : 0) ); |
Alexandre Julliard | 9ae0fe5 | 2001-04-24 23:28:52 +0000 | [diff] [blame] | 2589 | /* FIXME: a WM_MOVE is also generated (in the DefWindowProc handler |
| 2590 | * for WM_WINDOWPOSCHANGED) in Windows, should probably remove SWP_NOMOVE */ |
| 2591 | return retvalue; |
Alexandre Julliard | 940d58c | 1994-09-16 09:24:37 +0000 | [diff] [blame] | 2592 | } |
| 2593 | |
Alexandre Julliard | 9ae0fe5 | 2001-04-24 23:28:52 +0000 | [diff] [blame] | 2594 | |
Alexandre Julliard | e399fc3 | 1993-11-24 17:08:56 +0000 | [diff] [blame] | 2595 | /******************************************************************* |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2596 | * IsChild (USER32.@) |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 2597 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2598 | BOOL WINAPI IsChild( HWND parent, HWND child ) |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 2599 | { |
Alexandre Julliard | 9d9dac0 | 2001-08-24 19:28:21 +0000 | [diff] [blame] | 2600 | HWND *list = WIN_ListParents( child ); |
| 2601 | int i; |
| 2602 | BOOL ret; |
| 2603 | |
| 2604 | if (!list) return FALSE; |
Alexandre Julliard | f44bbb8 | 2001-09-14 00:24:39 +0000 | [diff] [blame] | 2605 | parent = WIN_GetFullHandle( parent ); |
Alexandre Julliard | 9d9dac0 | 2001-08-24 19:28:21 +0000 | [diff] [blame] | 2606 | for (i = 0; list[i]; i++) if (list[i] == parent) break; |
| 2607 | ret = (list[i] != 0); |
| 2608 | HeapFree( GetProcessHeap(), 0, list ); |
| 2609 | return ret; |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 2610 | } |
| 2611 | |
| 2612 | |
Alexandre Julliard | e399fc3 | 1993-11-24 17:08:56 +0000 | [diff] [blame] | 2613 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2614 | * IsWindowVisible (USER32.@) |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 2615 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2616 | BOOL WINAPI IsWindowVisible( HWND hwnd ) |
Alexandre Julliard | e399fc3 | 1993-11-24 17:08:56 +0000 | [diff] [blame] | 2617 | { |
Alexandre Julliard | 9d9dac0 | 2001-08-24 19:28:21 +0000 | [diff] [blame] | 2618 | HWND *list; |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 2619 | BOOL retval; |
Alexandre Julliard | 9d9dac0 | 2001-08-24 19:28:21 +0000 | [diff] [blame] | 2620 | int i; |
| 2621 | |
| 2622 | if (!(GetWindowLongW( hwnd, GWL_STYLE ) & WS_VISIBLE)) return FALSE; |
| 2623 | if (!(list = WIN_ListParents( hwnd ))) return TRUE; |
| 2624 | for (i = 0; list[i]; i++) |
| 2625 | if (!(GetWindowLongW( list[i], GWL_STYLE ) & WS_VISIBLE)) break; |
| 2626 | retval = !list[i]; |
| 2627 | HeapFree( GetProcessHeap(), 0, list ); |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 2628 | return retval; |
Alexandre Julliard | e399fc3 | 1993-11-24 17:08:56 +0000 | [diff] [blame] | 2629 | } |
| 2630 | |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 2631 | |
Alexandre Julliard | 1e37a18 | 1996-08-18 16:21:52 +0000 | [diff] [blame] | 2632 | /*********************************************************************** |
| 2633 | * WIN_IsWindowDrawable |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 2634 | * |
| 2635 | * hwnd is drawable when it is visible, all parents are not |
| 2636 | * minimized, and it is itself not minimized unless we are |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 2637 | * trying to draw its default class icon. |
Alexandre Julliard | 1e37a18 | 1996-08-18 16:21:52 +0000 | [diff] [blame] | 2638 | */ |
Alexandre Julliard | 8fd26b9 | 2001-10-15 17:56:45 +0000 | [diff] [blame] | 2639 | BOOL WIN_IsWindowDrawable( HWND hwnd, BOOL icon ) |
Alexandre Julliard | 1e37a18 | 1996-08-18 16:21:52 +0000 | [diff] [blame] | 2640 | { |
Alexandre Julliard | 9d9dac0 | 2001-08-24 19:28:21 +0000 | [diff] [blame] | 2641 | HWND *list; |
| 2642 | BOOL retval; |
| 2643 | int i; |
Alexandre Julliard | 8fd26b9 | 2001-10-15 17:56:45 +0000 | [diff] [blame] | 2644 | LONG style = GetWindowLongW( hwnd, GWL_STYLE ); |
Alexandre Julliard | 9d9dac0 | 2001-08-24 19:28:21 +0000 | [diff] [blame] | 2645 | |
Alexandre Julliard | 8fd26b9 | 2001-10-15 17:56:45 +0000 | [diff] [blame] | 2646 | if (!(style & WS_VISIBLE)) return FALSE; |
| 2647 | if ((style & WS_MINIMIZE) && icon && GetClassLongA( hwnd, GCL_HICON )) return FALSE; |
Alexandre Julliard | 9d9dac0 | 2001-08-24 19:28:21 +0000 | [diff] [blame] | 2648 | |
Alexandre Julliard | 8fd26b9 | 2001-10-15 17:56:45 +0000 | [diff] [blame] | 2649 | if (!(list = WIN_ListParents( hwnd ))) return TRUE; |
Alexandre Julliard | 9d9dac0 | 2001-08-24 19:28:21 +0000 | [diff] [blame] | 2650 | for (i = 0; list[i]; i++) |
| 2651 | if ((GetWindowLongW( list[i], GWL_STYLE ) & (WS_VISIBLE|WS_MINIMIZE)) != WS_VISIBLE) |
| 2652 | break; |
| 2653 | retval = !list[i]; |
| 2654 | HeapFree( GetProcessHeap(), 0, list ); |
| 2655 | return retval; |
Alexandre Julliard | 1e37a18 | 1996-08-18 16:21:52 +0000 | [diff] [blame] | 2656 | } |
| 2657 | |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 2658 | |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 2659 | /******************************************************************* |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2660 | * GetTopWindow (USER32.@) |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 2661 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2662 | HWND WINAPI GetTopWindow( HWND hwnd ) |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 2663 | { |
Alexandre Julliard | fa42aa8 | 2001-08-21 17:13:55 +0000 | [diff] [blame] | 2664 | if (!hwnd) hwnd = GetDesktopWindow(); |
| 2665 | return GetWindow( hwnd, GW_CHILD ); |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 2666 | } |
| 2667 | |
| 2668 | |
| 2669 | /******************************************************************* |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2670 | * GetWindow (USER32.@) |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 2671 | */ |
Alexandre Julliard | a09da0c | 2001-09-21 21:08:40 +0000 | [diff] [blame] | 2672 | HWND WINAPI GetWindow( HWND hwnd, UINT rel ) |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 2673 | { |
Alexandre Julliard | a09da0c | 2001-09-21 21:08:40 +0000 | [diff] [blame] | 2674 | HWND retval = 0; |
Alexandre Julliard | 0d92fe2 | 2001-09-10 23:26:42 +0000 | [diff] [blame] | 2675 | |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 2676 | if (rel == GW_OWNER) /* this one may be available locally */ |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 2677 | { |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 2678 | WND *wndPtr = WIN_GetPtr( hwnd ); |
| 2679 | if (!wndPtr) |
| 2680 | { |
| 2681 | SetLastError( ERROR_INVALID_HANDLE ); |
| 2682 | return 0; |
| 2683 | } |
| 2684 | if (wndPtr != WND_OTHER_PROCESS) |
| 2685 | { |
| 2686 | retval = wndPtr->owner; |
| 2687 | WIN_ReleasePtr( wndPtr ); |
| 2688 | return retval; |
| 2689 | } |
| 2690 | /* else fall through to server call */ |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 2691 | } |
Alexandre Julliard | a09da0c | 2001-09-21 21:08:40 +0000 | [diff] [blame] | 2692 | |
| 2693 | SERVER_START_REQ( get_window_tree ) |
| 2694 | { |
| 2695 | req->handle = hwnd; |
Alexandre Julliard | 9caa71e | 2001-11-30 18:46:42 +0000 | [diff] [blame] | 2696 | if (!wine_server_call_err( req )) |
Alexandre Julliard | a09da0c | 2001-09-21 21:08:40 +0000 | [diff] [blame] | 2697 | { |
| 2698 | switch(rel) |
| 2699 | { |
| 2700 | case GW_HWNDFIRST: |
Alexandre Julliard | 9caa71e | 2001-11-30 18:46:42 +0000 | [diff] [blame] | 2701 | retval = reply->first_sibling; |
Alexandre Julliard | a09da0c | 2001-09-21 21:08:40 +0000 | [diff] [blame] | 2702 | break; |
| 2703 | case GW_HWNDLAST: |
Alexandre Julliard | 9caa71e | 2001-11-30 18:46:42 +0000 | [diff] [blame] | 2704 | retval = reply->last_sibling; |
Alexandre Julliard | a09da0c | 2001-09-21 21:08:40 +0000 | [diff] [blame] | 2705 | break; |
| 2706 | case GW_HWNDNEXT: |
Alexandre Julliard | 9caa71e | 2001-11-30 18:46:42 +0000 | [diff] [blame] | 2707 | retval = reply->next_sibling; |
Alexandre Julliard | a09da0c | 2001-09-21 21:08:40 +0000 | [diff] [blame] | 2708 | break; |
| 2709 | case GW_HWNDPREV: |
Alexandre Julliard | 9caa71e | 2001-11-30 18:46:42 +0000 | [diff] [blame] | 2710 | retval = reply->prev_sibling; |
Alexandre Julliard | a09da0c | 2001-09-21 21:08:40 +0000 | [diff] [blame] | 2711 | break; |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 2712 | case GW_OWNER: |
Alexandre Julliard | 9caa71e | 2001-11-30 18:46:42 +0000 | [diff] [blame] | 2713 | retval = reply->owner; |
Alexandre Julliard | ddc3317 | 2001-10-22 19:08:33 +0000 | [diff] [blame] | 2714 | break; |
Alexandre Julliard | a09da0c | 2001-09-21 21:08:40 +0000 | [diff] [blame] | 2715 | case GW_CHILD: |
Alexandre Julliard | 9caa71e | 2001-11-30 18:46:42 +0000 | [diff] [blame] | 2716 | retval = reply->first_child; |
Alexandre Julliard | a09da0c | 2001-09-21 21:08:40 +0000 | [diff] [blame] | 2717 | break; |
| 2718 | } |
| 2719 | } |
| 2720 | } |
| 2721 | SERVER_END_REQ; |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 2722 | return retval; |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 2723 | } |
| 2724 | |
| 2725 | |
Louis Philippe Gagnon | 06057e7 | 2000-08-20 03:40:59 +0000 | [diff] [blame] | 2726 | /*********************************************************************** |
Alexandre Julliard | 0d92fe2 | 2001-09-10 23:26:42 +0000 | [diff] [blame] | 2727 | * WIN_InternalShowOwnedPopups |
Louis Philippe Gagnon | 06057e7 | 2000-08-20 03:40:59 +0000 | [diff] [blame] | 2728 | * |
| 2729 | * Internal version of ShowOwnedPopups; Wine functions should use this |
| 2730 | * to avoid interfering with application calls to ShowOwnedPopups |
| 2731 | * and to make sure the application can't prevent showing/hiding. |
| 2732 | * |
Alexandre Julliard | 0d92fe2 | 2001-09-10 23:26:42 +0000 | [diff] [blame] | 2733 | * Set unmanagedOnly to TRUE to show/hide unmanaged windows only. |
Louis Philippe Gagnon | 06057e7 | 2000-08-20 03:40:59 +0000 | [diff] [blame] | 2734 | * |
| 2735 | */ |
| 2736 | |
| 2737 | BOOL WIN_InternalShowOwnedPopups( HWND owner, BOOL fShow, BOOL unmanagedOnly ) |
| 2738 | { |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 2739 | int count = 0; |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 2740 | WND *pWnd; |
Alexandre Julliard | 9d9dac0 | 2001-08-24 19:28:21 +0000 | [diff] [blame] | 2741 | HWND *win_array = WIN_ListChildren( GetDesktopWindow() ); |
Louis Philippe Gagnon | 06057e7 | 2000-08-20 03:40:59 +0000 | [diff] [blame] | 2742 | |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 2743 | if (!win_array) return TRUE; |
Louis Philippe Gagnon | 06057e7 | 2000-08-20 03:40:59 +0000 | [diff] [blame] | 2744 | |
| 2745 | /* |
| 2746 | * Show windows Lowest first, Highest last to preserve Z-Order |
| 2747 | */ |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 2748 | while (win_array[count]) count++; |
| 2749 | while (--count >= 0) |
Louis Philippe Gagnon | 06057e7 | 2000-08-20 03:40:59 +0000 | [diff] [blame] | 2750 | { |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 2751 | if (GetWindow( win_array[count], GW_OWNER ) != owner) continue; |
| 2752 | if (!(pWnd = WIN_FindWndPtr( win_array[count] ))) continue; |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 2753 | |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 2754 | if (pWnd->dwStyle & WS_POPUP) |
Louis Philippe Gagnon | 06057e7 | 2000-08-20 03:40:59 +0000 | [diff] [blame] | 2755 | { |
| 2756 | if (fShow) |
| 2757 | { |
| 2758 | /* check in window was flagged for showing in previous WIN_InternalShowOwnedPopups call */ |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 2759 | if (pWnd->flags & WIN_NEEDS_INTERNALSOP) |
Louis Philippe Gagnon | 06057e7 | 2000-08-20 03:40:59 +0000 | [diff] [blame] | 2760 | { |
| 2761 | /* |
| 2762 | * Call ShowWindow directly because an application can intercept WM_SHOWWINDOW messages |
| 2763 | */ |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 2764 | ShowWindow(pWnd->hwndSelf,SW_SHOW); |
| 2765 | pWnd->flags &= ~WIN_NEEDS_INTERNALSOP; /* remove the flag */ |
Louis Philippe Gagnon | 06057e7 | 2000-08-20 03:40:59 +0000 | [diff] [blame] | 2766 | } |
| 2767 | } |
| 2768 | else |
| 2769 | { |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 2770 | if ( IsWindowVisible(pWnd->hwndSelf) && /* hide only if window is visible */ |
| 2771 | !( pWnd->flags & WIN_NEEDS_INTERNALSOP ) && /* don't hide if previous call already did it */ |
| 2772 | !( unmanagedOnly && (pWnd->dwExStyle & WS_EX_MANAGED) ) ) /* don't hide managed windows if unmanagedOnly is TRUE */ |
Louis Philippe Gagnon | 06057e7 | 2000-08-20 03:40:59 +0000 | [diff] [blame] | 2773 | { |
| 2774 | /* |
| 2775 | * Call ShowWindow directly because an application can intercept WM_SHOWWINDOW messages |
| 2776 | */ |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 2777 | ShowWindow(pWnd->hwndSelf,SW_HIDE); |
Louis Philippe Gagnon | 06057e7 | 2000-08-20 03:40:59 +0000 | [diff] [blame] | 2778 | /* flag the window for showing on next WIN_InternalShowOwnedPopups call */ |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 2779 | pWnd->flags |= WIN_NEEDS_INTERNALSOP; |
Louis Philippe Gagnon | 06057e7 | 2000-08-20 03:40:59 +0000 | [diff] [blame] | 2780 | } |
| 2781 | } |
| 2782 | } |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 2783 | WIN_ReleaseWndPtr( pWnd ); |
Louis Philippe Gagnon | 06057e7 | 2000-08-20 03:40:59 +0000 | [diff] [blame] | 2784 | } |
Alexandre Julliard | 9d9dac0 | 2001-08-24 19:28:21 +0000 | [diff] [blame] | 2785 | HeapFree( GetProcessHeap(), 0, win_array ); |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 2786 | |
Louis Philippe Gagnon | 06057e7 | 2000-08-20 03:40:59 +0000 | [diff] [blame] | 2787 | return TRUE; |
| 2788 | } |
| 2789 | |
Alexandre Julliard | e2991ea | 1995-07-29 13:09:43 +0000 | [diff] [blame] | 2790 | /******************************************************************* |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2791 | * ShowOwnedPopups (USER32.@) |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 2792 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2793 | BOOL WINAPI ShowOwnedPopups( HWND owner, BOOL fShow ) |
Alexandre Julliard | e2991ea | 1995-07-29 13:09:43 +0000 | [diff] [blame] | 2794 | { |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 2795 | int count = 0; |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 2796 | WND *pWnd; |
Alexandre Julliard | 9d9dac0 | 2001-08-24 19:28:21 +0000 | [diff] [blame] | 2797 | HWND *win_array = WIN_ListChildren( GetDesktopWindow() ); |
Noomen Hamza | a018d85 | 1999-09-28 16:26:09 +0000 | [diff] [blame] | 2798 | |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 2799 | if (!win_array) return TRUE; |
Noomen Hamza | a018d85 | 1999-09-28 16:26:09 +0000 | [diff] [blame] | 2800 | |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 2801 | while (win_array[count]) count++; |
| 2802 | while (--count >= 0) |
Alexandre Julliard | e2991ea | 1995-07-29 13:09:43 +0000 | [diff] [blame] | 2803 | { |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 2804 | if (GetWindow( win_array[count], GW_OWNER ) != owner) continue; |
| 2805 | if (!(pWnd = WIN_FindWndPtr( win_array[count] ))) continue; |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 2806 | |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 2807 | if (pWnd->dwStyle & WS_POPUP) |
Noomen Hamza | ff72776 | 2000-02-18 19:11:04 +0000 | [diff] [blame] | 2808 | { |
| 2809 | if (fShow) |
| 2810 | { |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 2811 | if (pWnd->flags & WIN_NEEDS_SHOW_OWNEDPOPUP) |
Noomen Hamza | ff72776 | 2000-02-18 19:11:04 +0000 | [diff] [blame] | 2812 | { |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 2813 | /* In Windows, ShowOwnedPopups(TRUE) generates |
| 2814 | * WM_SHOWWINDOW messages with SW_PARENTOPENING, |
Louis Philippe Gagnon | 06057e7 | 2000-08-20 03:40:59 +0000 | [diff] [blame] | 2815 | * regardless of the state of the owner |
| 2816 | */ |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 2817 | SendMessageA(pWnd->hwndSelf, WM_SHOWWINDOW, SW_SHOW, SW_PARENTOPENING); |
| 2818 | pWnd->flags &= ~WIN_NEEDS_SHOW_OWNEDPOPUP; |
Noomen Hamza | ff72776 | 2000-02-18 19:11:04 +0000 | [diff] [blame] | 2819 | } |
| 2820 | } |
| 2821 | else |
| 2822 | { |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 2823 | if (IsWindowVisible(pWnd->hwndSelf)) |
Noomen Hamza | ff72776 | 2000-02-18 19:11:04 +0000 | [diff] [blame] | 2824 | { |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 2825 | /* In Windows, ShowOwnedPopups(FALSE) generates |
| 2826 | * WM_SHOWWINDOW messages with SW_PARENTCLOSING, |
Louis Philippe Gagnon | 06057e7 | 2000-08-20 03:40:59 +0000 | [diff] [blame] | 2827 | * regardless of the state of the owner |
| 2828 | */ |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 2829 | SendMessageA(pWnd->hwndSelf, WM_SHOWWINDOW, SW_HIDE, SW_PARENTCLOSING); |
| 2830 | pWnd->flags |= WIN_NEEDS_SHOW_OWNEDPOPUP; |
Noomen Hamza | ff72776 | 2000-02-18 19:11:04 +0000 | [diff] [blame] | 2831 | } |
| 2832 | } |
| 2833 | } |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 2834 | WIN_ReleaseWndPtr( pWnd ); |
Alexandre Julliard | e2991ea | 1995-07-29 13:09:43 +0000 | [diff] [blame] | 2835 | } |
Alexandre Julliard | 9d9dac0 | 2001-08-24 19:28:21 +0000 | [diff] [blame] | 2836 | HeapFree( GetProcessHeap(), 0, win_array ); |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 2837 | return TRUE; |
Alexandre Julliard | e2991ea | 1995-07-29 13:09:43 +0000 | [diff] [blame] | 2838 | } |
Alexandre Julliard | dba420a | 1994-02-02 06:48:31 +0000 | [diff] [blame] | 2839 | |
| 2840 | |
Alexandre Julliard | 3a405ba | 1994-10-30 16:25:19 +0000 | [diff] [blame] | 2841 | /******************************************************************* |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2842 | * GetLastActivePopup (USER32.@) |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 2843 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2844 | HWND WINAPI GetLastActivePopup( HWND hwnd ) |
Alexandre Julliard | 3a405ba | 1994-10-30 16:25:19 +0000 | [diff] [blame] | 2845 | { |
Alexandre Julliard | 0b850f9 | 2002-10-12 01:23:05 +0000 | [diff] [blame] | 2846 | HWND retval = hwnd; |
| 2847 | |
| 2848 | SERVER_START_REQ( get_window_info ) |
| 2849 | { |
| 2850 | req->handle = hwnd; |
| 2851 | if (!wine_server_call_err( req )) retval = reply->last_active; |
| 2852 | } |
| 2853 | SERVER_END_REQ; |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 2854 | return retval; |
Alexandre Julliard | 3a405ba | 1994-10-30 16:25:19 +0000 | [diff] [blame] | 2855 | } |
| 2856 | |
Alexandre Julliard | dba420a | 1994-02-02 06:48:31 +0000 | [diff] [blame] | 2857 | |
| 2858 | /******************************************************************* |
Alexandre Julliard | 9d9dac0 | 2001-08-24 19:28:21 +0000 | [diff] [blame] | 2859 | * WIN_ListParents |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2860 | * |
Alexandre Julliard | 9d9dac0 | 2001-08-24 19:28:21 +0000 | [diff] [blame] | 2861 | * Build an array of all parents of a given window, starting with |
| 2862 | * the immediate parent. The array must be freed with HeapFree. |
| 2863 | * Returns NULL if window is a top-level window. |
Alexandre Julliard | dba420a | 1994-02-02 06:48:31 +0000 | [diff] [blame] | 2864 | */ |
Alexandre Julliard | 9d9dac0 | 2001-08-24 19:28:21 +0000 | [diff] [blame] | 2865 | HWND *WIN_ListParents( HWND hwnd ) |
Alexandre Julliard | dba420a | 1994-02-02 06:48:31 +0000 | [diff] [blame] | 2866 | { |
Alexandre Julliard | 5555731 | 2001-10-23 00:26:10 +0000 | [diff] [blame] | 2867 | WND *win; |
| 2868 | HWND current, *list; |
Alexandre Julliard | 96ebfa9 | 2001-10-23 20:35:44 +0000 | [diff] [blame] | 2869 | int pos = 0, size = 16, count = 0; |
Alexandre Julliard | 9d9dac0 | 2001-08-24 19:28:21 +0000 | [diff] [blame] | 2870 | |
Alexandre Julliard | 5555731 | 2001-10-23 00:26:10 +0000 | [diff] [blame] | 2871 | if (!(list = HeapAlloc( GetProcessHeap(), 0, size * sizeof(HWND) ))) return NULL; |
| 2872 | |
| 2873 | current = hwnd; |
| 2874 | for (;;) |
| 2875 | { |
| 2876 | if (!(win = WIN_GetPtr( current ))) goto empty; |
| 2877 | if (win == WND_OTHER_PROCESS) break; /* need to do it the hard way */ |
| 2878 | list[pos] = win->parent; |
| 2879 | WIN_ReleasePtr( win ); |
| 2880 | if (!(current = list[pos])) |
| 2881 | { |
| 2882 | if (!pos) goto empty; |
| 2883 | return list; |
| 2884 | } |
| 2885 | if (++pos == size - 1) |
| 2886 | { |
| 2887 | /* need to grow the list */ |
| 2888 | HWND *new_list = HeapReAlloc( GetProcessHeap(), 0, list, (size+16) * sizeof(HWND) ); |
| 2889 | if (!new_list) goto empty; |
| 2890 | list = new_list; |
| 2891 | size += 16; |
| 2892 | } |
| 2893 | } |
| 2894 | |
| 2895 | /* at least one parent belongs to another process, have to query the server */ |
Alexandre Julliard | 9caa71e | 2001-11-30 18:46:42 +0000 | [diff] [blame] | 2896 | |
| 2897 | for (;;) |
Alexandre Julliard | 9d9dac0 | 2001-08-24 19:28:21 +0000 | [diff] [blame] | 2898 | { |
Alexandre Julliard | 9caa71e | 2001-11-30 18:46:42 +0000 | [diff] [blame] | 2899 | count = 0; |
| 2900 | SERVER_START_REQ( get_window_parents ) |
Alexandre Julliard | 9d9dac0 | 2001-08-24 19:28:21 +0000 | [diff] [blame] | 2901 | { |
Alexandre Julliard | 9caa71e | 2001-11-30 18:46:42 +0000 | [diff] [blame] | 2902 | req->handle = hwnd; |
| 2903 | wine_server_set_reply( req, list, (size-1) * sizeof(HWND) ); |
| 2904 | if (!wine_server_call( req )) count = reply->count; |
Alexandre Julliard | 9d9dac0 | 2001-08-24 19:28:21 +0000 | [diff] [blame] | 2905 | } |
Alexandre Julliard | 9caa71e | 2001-11-30 18:46:42 +0000 | [diff] [blame] | 2906 | SERVER_END_REQ; |
| 2907 | if (!count) goto empty; |
| 2908 | if (size > count) |
| 2909 | { |
| 2910 | list[count] = 0; |
| 2911 | return list; |
| 2912 | } |
| 2913 | HeapFree( GetProcessHeap(), 0, list ); |
| 2914 | size = count + 1; |
| 2915 | if (!(list = HeapAlloc( GetProcessHeap(), 0, size * sizeof(HWND) ))) return NULL; |
Alexandre Julliard | 9d9dac0 | 2001-08-24 19:28:21 +0000 | [diff] [blame] | 2916 | } |
Alexandre Julliard | 5555731 | 2001-10-23 00:26:10 +0000 | [diff] [blame] | 2917 | |
| 2918 | empty: |
| 2919 | HeapFree( GetProcessHeap(), 0, list ); |
| 2920 | return NULL; |
Alexandre Julliard | 9d9dac0 | 2001-08-24 19:28:21 +0000 | [diff] [blame] | 2921 | } |
| 2922 | |
| 2923 | |
| 2924 | /******************************************************************* |
| 2925 | * WIN_ListChildren |
| 2926 | * |
| 2927 | * Build an array of the children of a given window. The array must be |
| 2928 | * freed with HeapFree. Returns NULL when no windows are found. |
| 2929 | */ |
| 2930 | HWND *WIN_ListChildren( HWND hwnd ) |
| 2931 | { |
Alexandre Julliard | 844ceb9 | 2001-10-09 23:26:40 +0000 | [diff] [blame] | 2932 | return list_window_children( hwnd, 0, 0 ); |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2933 | } |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 2934 | |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2935 | |
| 2936 | /******************************************************************* |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2937 | * EnumWindows (USER32.@) |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2938 | */ |
Alexandre Julliard | d6c0d86 | 2000-03-24 21:38:30 +0000 | [diff] [blame] | 2939 | BOOL WINAPI EnumWindows( WNDENUMPROC lpEnumFunc, LPARAM lParam ) |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2940 | { |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 2941 | HWND *list; |
| 2942 | BOOL ret = TRUE; |
| 2943 | int i, iWndsLocks; |
Alexandre Julliard | dba420a | 1994-02-02 06:48:31 +0000 | [diff] [blame] | 2944 | |
Alexandre Julliard | 594997c | 1995-04-30 10:05:20 +0000 | [diff] [blame] | 2945 | /* We have to build a list of all windows first, to avoid */ |
Andreas Mohr | 1c20b39 | 2000-02-20 19:17:35 +0000 | [diff] [blame] | 2946 | /* unpleasant side-effects, for instance if the callback */ |
| 2947 | /* function changes the Z-order of the windows. */ |
Alexandre Julliard | dba420a | 1994-02-02 06:48:31 +0000 | [diff] [blame] | 2948 | |
Tommy Schultz Lassen | 440adc1 | 2002-01-22 00:50:07 +0000 | [diff] [blame] | 2949 | if (!(list = WIN_ListChildren( GetDesktopWindow() ))) return TRUE; |
Alexandre Julliard | 594997c | 1995-04-30 10:05:20 +0000 | [diff] [blame] | 2950 | |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2951 | /* Now call the callback function for every window */ |
Alexandre Julliard | 594997c | 1995-04-30 10:05:20 +0000 | [diff] [blame] | 2952 | |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 2953 | iWndsLocks = WIN_SuspendWndsLock(); |
| 2954 | for (i = 0; list[i]; i++) |
Alexandre Julliard | 594997c | 1995-04-30 10:05:20 +0000 | [diff] [blame] | 2955 | { |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2956 | /* Make sure that the window still exists */ |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 2957 | if (!IsWindow( list[i] )) continue; |
| 2958 | if (!(ret = lpEnumFunc( list[i], lParam ))) break; |
Alexandre Julliard | 594997c | 1995-04-30 10:05:20 +0000 | [diff] [blame] | 2959 | } |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 2960 | WIN_RestoreWndsLock(iWndsLocks); |
Alexandre Julliard | 9d9dac0 | 2001-08-24 19:28:21 +0000 | [diff] [blame] | 2961 | HeapFree( GetProcessHeap(), 0, list ); |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 2962 | return ret; |
Alexandre Julliard | 594997c | 1995-04-30 10:05:20 +0000 | [diff] [blame] | 2963 | } |
| 2964 | |
| 2965 | |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2966 | /********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2967 | * EnumThreadWindows (USER32.@) |
Alexandre Julliard | dba420a | 1994-02-02 06:48:31 +0000 | [diff] [blame] | 2968 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2969 | BOOL WINAPI EnumThreadWindows( DWORD id, WNDENUMPROC func, LPARAM lParam ) |
Alexandre Julliard | dba420a | 1994-02-02 06:48:31 +0000 | [diff] [blame] | 2970 | { |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 2971 | HWND *list; |
| 2972 | int i, iWndsLocks; |
| 2973 | |
Alexandre Julliard | 4f71615 | 2002-10-17 18:21:29 +0000 | [diff] [blame] | 2974 | if (!(list = list_window_children( GetDesktopWindow(), 0, id ))) return TRUE; |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 2975 | |
| 2976 | /* Now call the callback function for every window */ |
| 2977 | |
| 2978 | iWndsLocks = WIN_SuspendWndsLock(); |
| 2979 | for (i = 0; list[i]; i++) |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 2980 | if (!func( list[i], lParam )) break; |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 2981 | WIN_RestoreWndsLock(iWndsLocks); |
Alexandre Julliard | 9d9dac0 | 2001-08-24 19:28:21 +0000 | [diff] [blame] | 2982 | HeapFree( GetProcessHeap(), 0, list ); |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 2983 | return TRUE; |
Alexandre Julliard | dba420a | 1994-02-02 06:48:31 +0000 | [diff] [blame] | 2984 | } |
| 2985 | |
Alexandre Julliard | 59730ae | 1996-03-24 16:20:51 +0000 | [diff] [blame] | 2986 | |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2987 | /********************************************************************** |
Alexandre Julliard | f1aa303 | 1996-08-05 17:42:43 +0000 | [diff] [blame] | 2988 | * WIN_EnumChildWindows |
Alexandre Julliard | dba420a | 1994-02-02 06:48:31 +0000 | [diff] [blame] | 2989 | * |
Alexandre Julliard | f1aa303 | 1996-08-05 17:42:43 +0000 | [diff] [blame] | 2990 | * Helper function for EnumChildWindows(). |
Alexandre Julliard | dba420a | 1994-02-02 06:48:31 +0000 | [diff] [blame] | 2991 | */ |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 2992 | static BOOL WIN_EnumChildWindows( HWND *list, WNDENUMPROC func, LPARAM lParam ) |
Alexandre Julliard | dba420a | 1994-02-02 06:48:31 +0000 | [diff] [blame] | 2993 | { |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 2994 | HWND *childList; |
| 2995 | BOOL ret = FALSE; |
Alexandre Julliard | dba420a | 1994-02-02 06:48:31 +0000 | [diff] [blame] | 2996 | |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 2997 | for ( ; *list; list++) |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2998 | { |
| 2999 | /* Make sure that the window still exists */ |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 3000 | if (!IsWindow( *list )) continue; |
| 3001 | /* skip owned windows */ |
| 3002 | if (GetWindow( *list, GW_OWNER )) continue; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 3003 | /* Build children list first */ |
Alexandre Julliard | 9d9dac0 | 2001-08-24 19:28:21 +0000 | [diff] [blame] | 3004 | childList = WIN_ListChildren( *list ); |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 3005 | |
| 3006 | ret = func( *list, lParam ); |
Francois Boisvert | d96bc15 | 1999-04-02 10:34:43 +0000 | [diff] [blame] | 3007 | |
Alexandre Julliard | 85ed45e | 1998-08-22 19:03:56 +0000 | [diff] [blame] | 3008 | if (childList) |
| 3009 | { |
| 3010 | if (ret) ret = WIN_EnumChildWindows( childList, func, lParam ); |
Alexandre Julliard | 9d9dac0 | 2001-08-24 19:28:21 +0000 | [diff] [blame] | 3011 | HeapFree( GetProcessHeap(), 0, childList ); |
Alexandre Julliard | 85ed45e | 1998-08-22 19:03:56 +0000 | [diff] [blame] | 3012 | } |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 3013 | if (!ret) return FALSE; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 3014 | } |
| 3015 | return TRUE; |
| 3016 | } |
| 3017 | |
| 3018 | |
| 3019 | /********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 3020 | * EnumChildWindows (USER32.@) |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 3021 | */ |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 3022 | BOOL WINAPI EnumChildWindows( HWND parent, WNDENUMPROC func, LPARAM lParam ) |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 3023 | { |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 3024 | HWND *list; |
| 3025 | int iWndsLocks; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 3026 | |
Alexandre Julliard | 9d9dac0 | 2001-08-24 19:28:21 +0000 | [diff] [blame] | 3027 | if (!(list = WIN_ListChildren( parent ))) return FALSE; |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 3028 | iWndsLocks = WIN_SuspendWndsLock(); |
Alexandre Julliard | f1aa303 | 1996-08-05 17:42:43 +0000 | [diff] [blame] | 3029 | WIN_EnumChildWindows( list, func, lParam ); |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 3030 | WIN_RestoreWndsLock(iWndsLocks); |
Alexandre Julliard | 9d9dac0 | 2001-08-24 19:28:21 +0000 | [diff] [blame] | 3031 | HeapFree( GetProcessHeap(), 0, list ); |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 3032 | return TRUE; |
| 3033 | } |
| 3034 | |
| 3035 | |
Alexandre Julliard | 5819953 | 1994-04-21 01:20:00 +0000 | [diff] [blame] | 3036 | /******************************************************************* |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 3037 | * AnyPopup (USER.52) |
Alexandre Julliard | d18872d | 1994-05-11 12:18:19 +0000 | [diff] [blame] | 3038 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 3039 | BOOL16 WINAPI AnyPopup16(void) |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 3040 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 3041 | return AnyPopup(); |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 3042 | } |
| 3043 | |
| 3044 | |
| 3045 | /******************************************************************* |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 3046 | * AnyPopup (USER32.@) |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 3047 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 3048 | BOOL WINAPI AnyPopup(void) |
Alexandre Julliard | d18872d | 1994-05-11 12:18:19 +0000 | [diff] [blame] | 3049 | { |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 3050 | int i; |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 3051 | BOOL retvalue; |
Alexandre Julliard | 9d9dac0 | 2001-08-24 19:28:21 +0000 | [diff] [blame] | 3052 | HWND *list = WIN_ListChildren( GetDesktopWindow() ); |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 3053 | |
| 3054 | if (!list) return FALSE; |
| 3055 | for (i = 0; list[i]; i++) |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 3056 | { |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 3057 | if (IsWindowVisible( list[i] ) && GetWindow( list[i], GW_OWNER )) break; |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 3058 | } |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 3059 | retvalue = (list[i] != 0); |
Alexandre Julliard | 9d9dac0 | 2001-08-24 19:28:21 +0000 | [diff] [blame] | 3060 | HeapFree( GetProcessHeap(), 0, list ); |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 3061 | return retvalue; |
Alexandre Julliard | d18872d | 1994-05-11 12:18:19 +0000 | [diff] [blame] | 3062 | } |
| 3063 | |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 3064 | |
Alexandre Julliard | 73450d6 | 1994-05-18 18:29:32 +0000 | [diff] [blame] | 3065 | /******************************************************************* |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 3066 | * FlashWindow (USER32.@) |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 3067 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 3068 | BOOL WINAPI FlashWindow( HWND hWnd, BOOL bInvert ) |
Alexandre Julliard | 73450d6 | 1994-05-18 18:29:32 +0000 | [diff] [blame] | 3069 | { |
Alexandre Julliard | 7d654eb | 1996-02-25 11:36:22 +0000 | [diff] [blame] | 3070 | WND *wndPtr = WIN_FindWndPtr(hWnd); |
| 3071 | |
Dimitrie O. Paun | dd03cc1 | 1999-12-08 03:56:23 +0000 | [diff] [blame] | 3072 | TRACE("%04x\n", hWnd); |
Alexandre Julliard | 7d654eb | 1996-02-25 11:36:22 +0000 | [diff] [blame] | 3073 | |
| 3074 | if (!wndPtr) return FALSE; |
Alexandre Julliard | f44bbb8 | 2001-09-14 00:24:39 +0000 | [diff] [blame] | 3075 | hWnd = wndPtr->hwndSelf; /* make it a full handle */ |
Alexandre Julliard | 7d654eb | 1996-02-25 11:36:22 +0000 | [diff] [blame] | 3076 | |
| 3077 | if (wndPtr->dwStyle & WS_MINIMIZE) |
| 3078 | { |
| 3079 | if (bInvert && !(wndPtr->flags & WIN_NCACTIVATED)) |
| 3080 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 3081 | HDC hDC = GetDC(hWnd); |
Alexandre Julliard | 0d92fe2 | 2001-09-10 23:26:42 +0000 | [diff] [blame] | 3082 | |
Michael Stefaniuc | 61d9256 | 2002-10-19 00:52:55 +0000 | [diff] [blame] | 3083 | if (!SendMessageW( hWnd, WM_ERASEBKGND, (WPARAM)hDC, 0 )) |
Alexandre Julliard | 7d654eb | 1996-02-25 11:36:22 +0000 | [diff] [blame] | 3084 | wndPtr->flags |= WIN_NEEDS_ERASEBKGND; |
Alexandre Julliard | 0d92fe2 | 2001-09-10 23:26:42 +0000 | [diff] [blame] | 3085 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 3086 | ReleaseDC( hWnd, hDC ); |
Alexandre Julliard | 7d654eb | 1996-02-25 11:36:22 +0000 | [diff] [blame] | 3087 | wndPtr->flags |= WIN_NCACTIVATED; |
| 3088 | } |
| 3089 | else |
| 3090 | { |
Alexandre Julliard | 9ae0fe5 | 2001-04-24 23:28:52 +0000 | [diff] [blame] | 3091 | RedrawWindow( hWnd, 0, 0, RDW_INVALIDATE | RDW_ERASE | RDW_UPDATENOW | RDW_FRAME ); |
Alexandre Julliard | 7d654eb | 1996-02-25 11:36:22 +0000 | [diff] [blame] | 3092 | wndPtr->flags &= ~WIN_NCACTIVATED; |
| 3093 | } |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 3094 | WIN_ReleaseWndPtr(wndPtr); |
Alexandre Julliard | 7d654eb | 1996-02-25 11:36:22 +0000 | [diff] [blame] | 3095 | return TRUE; |
| 3096 | } |
| 3097 | else |
| 3098 | { |
Alexandre Julliard | 530ee84 | 1996-10-23 16:59:13 +0000 | [diff] [blame] | 3099 | WPARAM16 wparam; |
Alexandre Julliard | 7d654eb | 1996-02-25 11:36:22 +0000 | [diff] [blame] | 3100 | if (bInvert) wparam = !(wndPtr->flags & WIN_NCACTIVATED); |
Alexandre Julliard | 5030bda | 2002-10-11 23:41:06 +0000 | [diff] [blame] | 3101 | else wparam = (hWnd == GetForegroundWindow()); |
Alexandre Julliard | 7d654eb | 1996-02-25 11:36:22 +0000 | [diff] [blame] | 3102 | |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 3103 | WIN_ReleaseWndPtr(wndPtr); |
Alexandre Julliard | f44bbb8 | 2001-09-14 00:24:39 +0000 | [diff] [blame] | 3104 | SendMessageW( hWnd, WM_NCACTIVATE, wparam, (LPARAM)0 ); |
Alexandre Julliard | 7d654eb | 1996-02-25 11:36:22 +0000 | [diff] [blame] | 3105 | return wparam; |
| 3106 | } |
Alexandre Julliard | 73450d6 | 1994-05-18 18:29:32 +0000 | [diff] [blame] | 3107 | } |
| 3108 | |
Alexandre Julliard | d18872d | 1994-05-11 12:18:19 +0000 | [diff] [blame] | 3109 | |
| 3110 | /******************************************************************* |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 3111 | * GetWindowContextHelpId (USER32.@) |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 3112 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 3113 | DWORD WINAPI GetWindowContextHelpId( HWND hwnd ) |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 3114 | { |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 3115 | DWORD retval; |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 3116 | WND *wnd = WIN_FindWndPtr( hwnd ); |
| 3117 | if (!wnd) return 0; |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 3118 | retval = wnd->helpContext; |
| 3119 | WIN_ReleaseWndPtr(wnd); |
| 3120 | return retval; |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 3121 | } |
| 3122 | |
| 3123 | |
| 3124 | /******************************************************************* |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 3125 | * SetWindowContextHelpId (USER32.@) |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 3126 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 3127 | BOOL WINAPI SetWindowContextHelpId( HWND hwnd, DWORD id ) |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 3128 | { |
| 3129 | WND *wnd = WIN_FindWndPtr( hwnd ); |
| 3130 | if (!wnd) return FALSE; |
| 3131 | wnd->helpContext = id; |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 3132 | WIN_ReleaseWndPtr(wnd); |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 3133 | return TRUE; |
| 3134 | } |
| 3135 | |
| 3136 | |
| 3137 | /******************************************************************* |
Dimitrie O. Paun | 9dd1279 | 2002-09-23 20:56:37 +0000 | [diff] [blame] | 3138 | * DRAG_QueryUpdate16 |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3139 | * |
Alexandre Julliard | 0d92fe2 | 2001-09-10 23:26:42 +0000 | [diff] [blame] | 3140 | * recursively find a child that contains spDragInfo->pt point |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3141 | * and send WM_QUERYDROPOBJECT |
| 3142 | */ |
Dimitrie O. Paun | 9dd1279 | 2002-09-23 20:56:37 +0000 | [diff] [blame] | 3143 | static BOOL16 DRAG_QueryUpdate16( HWND hQueryWnd, SEGPTR spDragInfo ) |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3144 | { |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 3145 | BOOL16 wParam, bResult = 0; |
Alexandre Julliard | 48f860c | 2002-10-28 19:04:39 +0000 | [diff] [blame] | 3146 | POINT pt, client_pt; |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 3147 | LPDRAGINFO16 ptrDragInfo = MapSL(spDragInfo); |
| 3148 | RECT tempRect; |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3149 | |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 3150 | if (!ptrDragInfo) return FALSE; |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3151 | |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 3152 | CONV_POINT16TO32( &ptrDragInfo->pt, &pt ); |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3153 | |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 3154 | GetWindowRect(hQueryWnd,&tempRect); |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3155 | |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 3156 | if( !PtInRect(&tempRect,pt) || !IsWindowEnabled(hQueryWnd)) return FALSE; |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3157 | |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 3158 | if (!IsIconic( hQueryWnd )) |
| 3159 | { |
Alexandre Julliard | 1a66d22 | 2001-08-28 18:44:52 +0000 | [diff] [blame] | 3160 | GetClientRect( hQueryWnd, &tempRect ); |
| 3161 | MapWindowPoints( hQueryWnd, 0, (LPPOINT)&tempRect, 2 ); |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3162 | |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 3163 | if (PtInRect( &tempRect, pt)) |
| 3164 | { |
Alexandre Julliard | 1a66d22 | 2001-08-28 18:44:52 +0000 | [diff] [blame] | 3165 | int i; |
| 3166 | HWND *list = WIN_ListChildren( hQueryWnd ); |
| 3167 | |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 3168 | wParam = 0; |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 3169 | |
Alexandre Julliard | 1a66d22 | 2001-08-28 18:44:52 +0000 | [diff] [blame] | 3170 | if (list) |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 3171 | { |
Alexandre Julliard | 1a66d22 | 2001-08-28 18:44:52 +0000 | [diff] [blame] | 3172 | for (i = 0; list[i]; i++) |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 3173 | { |
Alexandre Julliard | 1a66d22 | 2001-08-28 18:44:52 +0000 | [diff] [blame] | 3174 | if (GetWindowLongW( list[i], GWL_STYLE ) & WS_VISIBLE) |
| 3175 | { |
| 3176 | GetWindowRect( list[i], &tempRect ); |
| 3177 | if (PtInRect( &tempRect, pt )) break; |
| 3178 | } |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 3179 | } |
Alexandre Julliard | 1a66d22 | 2001-08-28 18:44:52 +0000 | [diff] [blame] | 3180 | if (list[i]) |
| 3181 | { |
| 3182 | if (IsWindowEnabled( list[i] )) |
Dimitrie O. Paun | 9dd1279 | 2002-09-23 20:56:37 +0000 | [diff] [blame] | 3183 | bResult = DRAG_QueryUpdate16( list[i], spDragInfo ); |
Alexandre Julliard | 1a66d22 | 2001-08-28 18:44:52 +0000 | [diff] [blame] | 3184 | } |
| 3185 | HeapFree( GetProcessHeap(), 0, list ); |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 3186 | } |
Alexandre Julliard | 1a66d22 | 2001-08-28 18:44:52 +0000 | [diff] [blame] | 3187 | if(bResult) return bResult; |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 3188 | } |
| 3189 | else wParam = 1; |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 3190 | } |
| 3191 | else wParam = 1; |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3192 | |
Alexandre Julliard | 48f860c | 2002-10-28 19:04:39 +0000 | [diff] [blame] | 3193 | client_pt = pt; |
| 3194 | ScreenToClient( hQueryWnd, &client_pt ); |
| 3195 | ptrDragInfo->pt.x = client_pt.x; |
| 3196 | ptrDragInfo->pt.y = client_pt.y; |
Michael Stefaniuc | 2247af3 | 2002-09-04 19:37:01 +0000 | [diff] [blame] | 3197 | ptrDragInfo->hScope = HWND_16(hQueryWnd); |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 3198 | |
Dimitrie O. Paun | 9dd1279 | 2002-09-23 20:56:37 +0000 | [diff] [blame] | 3199 | bResult = SendMessage16( HWND_16(hQueryWnd), WM_QUERYDROPOBJECT, (WPARAM16)wParam, spDragInfo ); |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 3200 | |
| 3201 | if( !bResult ) CONV_POINT32TO16( &pt, &ptrDragInfo->pt ); |
| 3202 | |
| 3203 | return bResult; |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3204 | } |
| 3205 | |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 3206 | |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3207 | /******************************************************************* |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 3208 | * DragDetect (USER32.@) |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 3209 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 3210 | BOOL WINAPI DragDetect( HWND hWnd, POINT pt ) |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3211 | { |
Alexandre Julliard | 0ff083b | 2000-09-24 19:51:15 +0000 | [diff] [blame] | 3212 | MSG msg; |
| 3213 | RECT rect; |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3214 | |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 3215 | rect.left = pt.x - wDragWidth; |
| 3216 | rect.right = pt.x + wDragWidth; |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3217 | |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 3218 | rect.top = pt.y - wDragHeight; |
| 3219 | rect.bottom = pt.y + wDragHeight; |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3220 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 3221 | SetCapture(hWnd); |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3222 | |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 3223 | while(1) |
| 3224 | { |
Alexandre Julliard | 0ff083b | 2000-09-24 19:51:15 +0000 | [diff] [blame] | 3225 | while(PeekMessageA(&msg ,0 ,WM_MOUSEFIRST ,WM_MOUSELAST ,PM_REMOVE)) |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 3226 | { |
| 3227 | if( msg.message == WM_LBUTTONUP ) |
| 3228 | { |
| 3229 | ReleaseCapture(); |
| 3230 | return 0; |
| 3231 | } |
| 3232 | if( msg.message == WM_MOUSEMOVE ) |
| 3233 | { |
Alexandre Julliard | 0ff083b | 2000-09-24 19:51:15 +0000 | [diff] [blame] | 3234 | POINT tmp; |
| 3235 | tmp.x = LOWORD(msg.lParam); |
| 3236 | tmp.y = HIWORD(msg.lParam); |
| 3237 | if( !PtInRect( &rect, tmp )) |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3238 | { |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 3239 | ReleaseCapture(); |
| 3240 | return 1; |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3241 | } |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 3242 | } |
| 3243 | } |
| 3244 | WaitMessage(); |
| 3245 | } |
| 3246 | return 0; |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3247 | } |
| 3248 | |
| 3249 | /****************************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 3250 | * DragObject (USER.464) |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3251 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 3252 | DWORD WINAPI DragObject16( HWND16 hwndScope, HWND16 hWnd, UINT16 wObj, |
| 3253 | HANDLE16 hOfStruct, WORD szList, HCURSOR16 hCursor ) |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3254 | { |
Alexandre Julliard | 0ff083b | 2000-09-24 19:51:15 +0000 | [diff] [blame] | 3255 | MSG msg; |
Alexandre Julliard | 83f52d1 | 2000-09-26 22:20:14 +0000 | [diff] [blame] | 3256 | LPDRAGINFO16 lpDragInfo; |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 3257 | SEGPTR spDragInfo; |
Michael Stefaniuc | bc54d78 | 2002-10-10 21:22:09 +0000 | [diff] [blame] | 3258 | HCURSOR hOldCursor=0, hBummer=0; |
Alexandre Julliard | 83f52d1 | 2000-09-26 22:20:14 +0000 | [diff] [blame] | 3259 | HGLOBAL16 hDragInfo = GlobalAlloc16( GMEM_SHARE | GMEM_ZEROINIT, 2*sizeof(DRAGINFO16)); |
Michael Stefaniuc | bc54d78 | 2002-10-10 21:22:09 +0000 | [diff] [blame] | 3260 | HCURSOR hCurrentCursor = 0; |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 3261 | HWND16 hCurrentWnd = 0; |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3262 | |
Alexandre Julliard | 83f52d1 | 2000-09-26 22:20:14 +0000 | [diff] [blame] | 3263 | lpDragInfo = (LPDRAGINFO16) GlobalLock16(hDragInfo); |
Alexandre Julliard | 5801723 | 2000-12-22 01:09:26 +0000 | [diff] [blame] | 3264 | spDragInfo = K32WOWGlobalLock16(hDragInfo); |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3265 | |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 3266 | if( !lpDragInfo || !spDragInfo ) return 0L; |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3267 | |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 3268 | if (!(hBummer = LoadCursorA(0, MAKEINTRESOURCEA(OCR_NO)))) |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 3269 | { |
Alexandre Julliard | 1285c2f | 1996-05-06 16:06:24 +0000 | [diff] [blame] | 3270 | GlobalFree16(hDragInfo); |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3271 | return 0L; |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 3272 | } |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3273 | |
Michael Stefaniuc | bc54d78 | 2002-10-10 21:22:09 +0000 | [diff] [blame] | 3274 | if(hCursor) hOldCursor = SetCursor(HCURSOR_32(hCursor)); |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3275 | |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 3276 | lpDragInfo->hWnd = hWnd; |
| 3277 | lpDragInfo->hScope = 0; |
| 3278 | lpDragInfo->wFlags = wObj; |
| 3279 | lpDragInfo->hList = szList; /* near pointer! */ |
| 3280 | lpDragInfo->hOfStruct = hOfStruct; |
Alexandre Julliard | 0d92fe2 | 2001-09-10 23:26:42 +0000 | [diff] [blame] | 3281 | lpDragInfo->l = 0L; |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3282 | |
Michael Stefaniuc | 2247af3 | 2002-09-04 19:37:01 +0000 | [diff] [blame] | 3283 | SetCapture(WIN_Handle32(hWnd)); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 3284 | ShowCursor( TRUE ); |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3285 | |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 3286 | do |
| 3287 | { |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 3288 | GetMessageW( &msg, 0, WM_MOUSEFIRST, WM_MOUSELAST ); |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3289 | |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 3290 | *(lpDragInfo+1) = *lpDragInfo; |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3291 | |
Alexandre Julliard | 0ff083b | 2000-09-24 19:51:15 +0000 | [diff] [blame] | 3292 | lpDragInfo->pt.x = msg.pt.x; |
| 3293 | lpDragInfo->pt.y = msg.pt.y; |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3294 | |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 3295 | /* update DRAGINFO struct */ |
Alexandre Julliard | 06c275a | 1999-05-02 14:32:27 +0000 | [diff] [blame] | 3296 | TRACE_(msg)("lpDI->hScope = %04x\n",lpDragInfo->hScope); |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3297 | |
Dimitrie O. Paun | 9dd1279 | 2002-09-23 20:56:37 +0000 | [diff] [blame] | 3298 | if( DRAG_QueryUpdate16(WIN_Handle32(hwndScope), spDragInfo) > 0 ) |
Michael Stefaniuc | bc54d78 | 2002-10-10 21:22:09 +0000 | [diff] [blame] | 3299 | hCurrentCursor = HCURSOR_32(hCursor); |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 3300 | else |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3301 | { |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 3302 | hCurrentCursor = hBummer; |
| 3303 | lpDragInfo->hScope = 0; |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3304 | } |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 3305 | if( hCurrentCursor ) |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 3306 | SetCursor(hCurrentCursor); |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3307 | |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 3308 | /* send WM_DRAGLOOP */ |
Alexandre Julliard | 0d92fe2 | 2001-09-10 23:26:42 +0000 | [diff] [blame] | 3309 | SendMessage16( hWnd, WM_DRAGLOOP, (WPARAM16)(hCurrentCursor != hBummer), |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 3310 | (LPARAM) spDragInfo ); |
| 3311 | /* send WM_DRAGSELECT or WM_DRAGMOVE */ |
| 3312 | if( hCurrentWnd != lpDragInfo->hScope ) |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3313 | { |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 3314 | if( hCurrentWnd ) |
Alexandre Julliard | 0d92fe2 | 2001-09-10 23:26:42 +0000 | [diff] [blame] | 3315 | SendMessage16( hCurrentWnd, WM_DRAGSELECT, 0, |
Alexandre Julliard | 83f52d1 | 2000-09-26 22:20:14 +0000 | [diff] [blame] | 3316 | (LPARAM)MAKELONG(LOWORD(spDragInfo)+sizeof(DRAGINFO16), |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3317 | HIWORD(spDragInfo)) ); |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 3318 | hCurrentWnd = lpDragInfo->hScope; |
| 3319 | if( hCurrentWnd ) |
Alexandre Julliard | 0d92fe2 | 2001-09-10 23:26:42 +0000 | [diff] [blame] | 3320 | SendMessage16( hCurrentWnd, WM_DRAGSELECT, 1, (LPARAM)spDragInfo); |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3321 | } |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 3322 | else |
| 3323 | if( hCurrentWnd ) |
| 3324 | SendMessage16( hCurrentWnd, WM_DRAGMOVE, 0, (LPARAM)spDragInfo); |
| 3325 | |
| 3326 | } while( msg.message != WM_LBUTTONUP && msg.message != WM_NCLBUTTONUP ); |
| 3327 | |
| 3328 | ReleaseCapture(); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 3329 | ShowCursor( FALSE ); |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 3330 | |
Michael Stefaniuc | bc54d78 | 2002-10-10 21:22:09 +0000 | [diff] [blame] | 3331 | if( hCursor ) SetCursor(hOldCursor); |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 3332 | |
Alexandre Julliard | 0d92fe2 | 2001-09-10 23:26:42 +0000 | [diff] [blame] | 3333 | if( hCurrentCursor != hBummer ) |
| 3334 | msg.lParam = SendMessage16( lpDragInfo->hScope, WM_DROPOBJECT, |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 3335 | (WPARAM16)hWnd, (LPARAM)spDragInfo ); |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3336 | else |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 3337 | msg.lParam = 0; |
| 3338 | GlobalFree16(hDragInfo); |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3339 | |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 3340 | return (DWORD)(msg.lParam); |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 3341 | } |
Eric Kohl | ca6c9a6 | 2001-03-20 01:53:51 +0000 | [diff] [blame] | 3342 | |
| 3343 | |
| 3344 | /****************************************************************************** |
| 3345 | * GetWindowModuleFileNameA (USER32.@) |
| 3346 | */ |
| 3347 | UINT WINAPI GetWindowModuleFileNameA( HWND hwnd, LPSTR lpszFileName, UINT cchFileNameMax) |
| 3348 | { |
| 3349 | FIXME("GetWindowModuleFileNameA(hwnd 0x%x, lpszFileName %p, cchFileNameMax %u) stub!\n", |
| 3350 | hwnd, lpszFileName, cchFileNameMax); |
| 3351 | return 0; |
| 3352 | } |
| 3353 | |
| 3354 | /****************************************************************************** |
| 3355 | * GetWindowModuleFileNameW (USER32.@) |
| 3356 | */ |
| 3357 | UINT WINAPI GetWindowModuleFileNameW( HWND hwnd, LPSTR lpszFileName, UINT cchFileNameMax) |
| 3358 | { |
| 3359 | FIXME("GetWindowModuleFileNameW(hwnd 0x%x, lpszFileName %p, cchFileNameMax %u) stub!\n", |
| 3360 | hwnd, lpszFileName, cchFileNameMax); |
| 3361 | return 0; |
| 3362 | } |
David Hammerton | ca30e48 | 2002-05-06 20:11:18 +0000 | [diff] [blame] | 3363 | |
| 3364 | /****************************************************************************** |
| 3365 | * GetWindowInfo (USER32.@) |
| 3366 | * hwnd: in |
| 3367 | * pwi: out. |
| 3368 | * MS Documentation mentions that pwi->cbSize must be set to SIZEOF(WINDOWINFO) |
| 3369 | * this may be because this structure changed over time. If this is the |
| 3370 | * the case, then please: FIXME. |
| 3371 | * Using the structure described in MSDN for 98/ME/NT(4.0 SP3)/2000/XP. |
| 3372 | */ |
| 3373 | BOOL WINAPI GetWindowInfo( HWND hwnd, PWINDOWINFO pwi) |
| 3374 | { |
| 3375 | WND *wndInfo = NULL; |
| 3376 | if (!pwi) return FALSE; |
| 3377 | if (pwi->cbSize != sizeof(WINDOWINFO)) |
| 3378 | { |
| 3379 | FIXME("windowinfo->cbSize != sizeof(WINDOWINFO). Please report\n"); |
| 3380 | return FALSE; |
| 3381 | } |
| 3382 | wndInfo = WIN_GetPtr(hwnd); |
| 3383 | if (!wndInfo) return FALSE; |
| 3384 | if (wndInfo == WND_OTHER_PROCESS) |
| 3385 | { |
| 3386 | FIXME("window belong to other process\n"); |
| 3387 | return FALSE; |
| 3388 | } |
| 3389 | |
| 3390 | pwi->rcWindow = wndInfo->rectWindow; |
| 3391 | pwi->rcClient = wndInfo->rectClient; |
| 3392 | pwi->dwStyle = wndInfo->dwStyle; |
| 3393 | pwi->dwExStyle = wndInfo->dwExStyle; |
| 3394 | pwi->dwWindowStatus = ((GetActiveWindow() == hwnd) ? WS_ACTIVECAPTION : 0); |
| 3395 | /* if active WS_ACTIVECAPTION, else 0 */ |
| 3396 | |
| 3397 | pwi->cxWindowBorders = ((wndInfo->dwStyle & WS_BORDER) ? |
| 3398 | GetSystemMetrics(SM_CXBORDER) : 0); |
| 3399 | pwi->cyWindowBorders = ((wndInfo->dwStyle & WS_BORDER) ? |
| 3400 | GetSystemMetrics(SM_CYBORDER) : 0); |
| 3401 | /* above two: I'm presuming that borders widths are the same |
| 3402 | * for each window - so long as its actually using a border.. */ |
| 3403 | |
| 3404 | pwi->atomWindowType = GetClassLongA( hwnd, GCW_ATOM ); |
| 3405 | pwi->wCreatorVersion = GetVersion(); |
| 3406 | /* Docs say this should be the version that |
| 3407 | * CREATED the window. But eh?.. Isn't that just the |
| 3408 | * version we are running.. Unless ofcourse its some wacky |
| 3409 | * RPC stuff or something */ |
| 3410 | |
| 3411 | WIN_ReleasePtr(wndInfo); |
| 3412 | return TRUE; |
| 3413 | } |