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