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