Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Window classes functions |
| 3 | * |
Alexandre Julliard | bfce151 | 2003-12-10 04:08:06 +0000 | [diff] [blame] | 4 | * Copyright 1993, 1996, 2003 Alexandre Julliard |
| 5 | * Copyright 1998 Juergen Schmied (jsch) |
Alexandre Julliard | 2197901 | 1997-03-05 08:22:35 +0000 | [diff] [blame] | 6 | * |
Alexandre Julliard | 0799c1a | 2002-03-09 23:29:33 +0000 | [diff] [blame] | 7 | * This library is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU Lesser General Public |
| 9 | * License as published by the Free Software Foundation; either |
| 10 | * version 2.1 of the License, or (at your option) any later version. |
| 11 | * |
| 12 | * This library is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | * Lesser General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU Lesser General Public |
| 18 | * License along with this library; if not, write to the Free Software |
| 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
Alexandre Julliard | bd34d4f | 1995-06-20 19:08:12 +0000 | [diff] [blame] | 20 | */ |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 21 | |
François Gouget | 1425941 | 2001-11-06 20:57:11 +0000 | [diff] [blame] | 22 | #include "config.h" |
Francois Gouget | 386cf6e | 2001-10-14 16:25:47 +0000 | [diff] [blame] | 23 | #include "wine/port.h" |
| 24 | |
Alexandre Julliard | bfce151 | 2003-12-10 04:08:06 +0000 | [diff] [blame] | 25 | #include <assert.h> |
Alexandre Julliard | e37c6e1 | 2003-09-05 23:08:26 +0000 | [diff] [blame] | 26 | #include <stdarg.h> |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 27 | #include <stdlib.h> |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 28 | #include <string.h> |
Francois Gouget | 386cf6e | 2001-10-14 16:25:47 +0000 | [diff] [blame] | 29 | |
Marcus Meissner | 317af32 | 1999-02-17 13:51:06 +0000 | [diff] [blame] | 30 | #include "wine/winbase16.h" |
Alexandre Julliard | c7e7df8 | 2000-08-14 14:41:19 +0000 | [diff] [blame] | 31 | #include "winerror.h" |
| 32 | #include "windef.h" |
Alexandre Julliard | e37c6e1 | 2003-09-05 23:08:26 +0000 | [diff] [blame] | 33 | #include "winbase.h" |
Alexandre Julliard | c7e7df8 | 2000-08-14 14:41:19 +0000 | [diff] [blame] | 34 | #include "wingdi.h" |
| 35 | #include "wine/winuser16.h" |
Alexandre Julliard | 0ca051e | 2002-10-17 16:43:42 +0000 | [diff] [blame] | 36 | #include "wownt32.h" |
Alexandre Julliard | c7e7df8 | 2000-08-14 14:41:19 +0000 | [diff] [blame] | 37 | #include "wine/unicode.h" |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 38 | #include "win.h" |
Alexandre Julliard | e6d90ea | 2001-10-09 23:27:17 +0000 | [diff] [blame] | 39 | #include "user.h" |
Alexandre Julliard | 91222da | 2000-12-10 23:01:33 +0000 | [diff] [blame] | 40 | #include "controls.h" |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 41 | #include "dce.h" |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 42 | #include "winproc.h" |
Alexandre Julliard | bfce151 | 2003-12-10 04:08:06 +0000 | [diff] [blame] | 43 | #include "wine/server.h" |
| 44 | #include "wine/list.h" |
Alexandre Julliard | 0799c1a | 2002-03-09 23:29:33 +0000 | [diff] [blame] | 45 | #include "wine/debug.h" |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 46 | |
Alexandre Julliard | 0799c1a | 2002-03-09 23:29:33 +0000 | [diff] [blame] | 47 | WINE_DEFAULT_DEBUG_CHANNEL(class); |
Patrik Stridvall | b4b9fae | 1999-04-19 14:56:29 +0000 | [diff] [blame] | 48 | |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 49 | typedef struct tagCLASS |
| 50 | { |
Alexandre Julliard | bfce151 | 2003-12-10 04:08:06 +0000 | [diff] [blame] | 51 | struct list entry; /* Entry in class list */ |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 52 | UINT style; /* Class style */ |
Alexandre Julliard | bfce151 | 2003-12-10 04:08:06 +0000 | [diff] [blame] | 53 | BOOL local; /* Local class? */ |
Alexandre Julliard | 18d0297 | 2002-12-03 23:34:52 +0000 | [diff] [blame] | 54 | WNDPROC winprocA; /* Window procedure (ASCII) */ |
| 55 | WNDPROC winprocW; /* Window procedure (Unicode) */ |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 56 | INT cbClsExtra; /* Class extra bytes */ |
| 57 | INT cbWndExtra; /* Window extra bytes */ |
| 58 | LPWSTR menuName; /* Default menu name (Unicode followed by ASCII) */ |
Alexandre Julliard | d7b7682 | 2001-12-20 00:19:40 +0000 | [diff] [blame] | 59 | SEGPTR segMenuName; /* Default menu name as SEGPTR */ |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 60 | struct tagDCE *dce; /* Class DCE (if CS_CLASSDC) */ |
| 61 | HINSTANCE hInstance; /* Module that created the task */ |
| 62 | HICON hIcon; /* Default icon */ |
| 63 | HICON hIconSm; /* Default small icon */ |
| 64 | HCURSOR hCursor; /* Default cursor */ |
| 65 | HBRUSH hbrBackground; /* Default background */ |
| 66 | ATOM atomName; /* Name of the class */ |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 67 | } CLASS; |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 68 | |
Alexandre Julliard | bfce151 | 2003-12-10 04:08:06 +0000 | [diff] [blame] | 69 | static struct list class_list = LIST_INIT( class_list ); |
Alexandre Julliard | bd13ab8 | 2003-12-11 05:34:53 +0000 | [diff] [blame] | 70 | static CLASS *desktop_class; |
Alexandre Julliard | bfce151 | 2003-12-10 04:08:06 +0000 | [diff] [blame] | 71 | static HMODULE user32_module; |
| 72 | |
| 73 | #define CLASS_OTHER_PROCESS ((CLASS *)1) |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 74 | |
Alexandre Julliard | e6d90ea | 2001-10-09 23:27:17 +0000 | [diff] [blame] | 75 | /*********************************************************************** |
| 76 | * get_class_ptr |
| 77 | */ |
Alexandre Julliard | 8fd26b9 | 2001-10-15 17:56:45 +0000 | [diff] [blame] | 78 | static CLASS *get_class_ptr( HWND hwnd, BOOL write_access ) |
Alexandre Julliard | e6d90ea | 2001-10-09 23:27:17 +0000 | [diff] [blame] | 79 | { |
Alexandre Julliard | 8fd26b9 | 2001-10-15 17:56:45 +0000 | [diff] [blame] | 80 | WND *ptr = WIN_GetPtr( hwnd ); |
Alexandre Julliard | e6d90ea | 2001-10-09 23:27:17 +0000 | [diff] [blame] | 81 | |
Alexandre Julliard | 8fd26b9 | 2001-10-15 17:56:45 +0000 | [diff] [blame] | 82 | if (ptr) |
Alexandre Julliard | e6d90ea | 2001-10-09 23:27:17 +0000 | [diff] [blame] | 83 | { |
Alexandre Julliard | 8fd26b9 | 2001-10-15 17:56:45 +0000 | [diff] [blame] | 84 | if (ptr != WND_OTHER_PROCESS) return ptr->class; |
Alexandre Julliard | bfce151 | 2003-12-10 04:08:06 +0000 | [diff] [blame] | 85 | if (write_access && IsWindow( hwnd )) /* check other processes */ |
Alexandre Julliard | e6d90ea | 2001-10-09 23:27:17 +0000 | [diff] [blame] | 86 | { |
Alexandre Julliard | bfce151 | 2003-12-10 04:08:06 +0000 | [diff] [blame] | 87 | /* modifying classes in other processes is not allowed */ |
| 88 | SetLastError( ERROR_ACCESS_DENIED ); |
| 89 | return NULL; |
Alexandre Julliard | e6d90ea | 2001-10-09 23:27:17 +0000 | [diff] [blame] | 90 | } |
Alexandre Julliard | bfce151 | 2003-12-10 04:08:06 +0000 | [diff] [blame] | 91 | return CLASS_OTHER_PROCESS; |
Alexandre Julliard | e6d90ea | 2001-10-09 23:27:17 +0000 | [diff] [blame] | 92 | } |
Alexandre Julliard | 8fd26b9 | 2001-10-15 17:56:45 +0000 | [diff] [blame] | 93 | SetLastError( ERROR_INVALID_WINDOW_HANDLE ); |
| 94 | return NULL; |
Alexandre Julliard | e6d90ea | 2001-10-09 23:27:17 +0000 | [diff] [blame] | 95 | } |
| 96 | |
| 97 | |
| 98 | /*********************************************************************** |
| 99 | * release_class_ptr |
| 100 | */ |
| 101 | inline static void release_class_ptr( CLASS *ptr ) |
| 102 | { |
| 103 | USER_Unlock(); |
| 104 | } |
| 105 | |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 106 | |
| 107 | /*********************************************************************** |
Alexandre Julliard | bfce151 | 2003-12-10 04:08:06 +0000 | [diff] [blame] | 108 | * set_server_info |
| 109 | * |
| 110 | * Set class info with the wine server. |
| 111 | */ |
| 112 | static BOOL set_server_info( HWND hwnd, INT offset, LONG newval ) |
| 113 | { |
| 114 | BOOL ret; |
| 115 | |
| 116 | SERVER_START_REQ( set_class_info ) |
| 117 | { |
| 118 | req->window = hwnd; |
| 119 | req->extra_offset = -1; |
| 120 | switch(offset) |
| 121 | { |
| 122 | case GCW_ATOM: |
| 123 | req->flags = SET_CLASS_ATOM; |
| 124 | req->atom = newval; |
| 125 | case GCL_STYLE: |
| 126 | req->flags = SET_CLASS_STYLE; |
| 127 | req->style = newval; |
| 128 | break; |
| 129 | case GCL_CBWNDEXTRA: |
| 130 | req->flags = SET_CLASS_WINEXTRA; |
| 131 | req->win_extra = newval; |
| 132 | break; |
| 133 | case GCL_HMODULE: |
| 134 | req->flags = SET_CLASS_INSTANCE; |
| 135 | req->instance = (void *)newval; |
| 136 | break; |
| 137 | default: |
| 138 | assert( offset >= 0 ); |
| 139 | req->flags = SET_CLASS_EXTRA; |
| 140 | req->extra_offset = offset; |
| 141 | req->extra_size = sizeof(newval); |
| 142 | memcpy( &req->extra_value, &newval, sizeof(newval) ); |
| 143 | break; |
| 144 | } |
| 145 | ret = !wine_server_call_err( req ); |
| 146 | } |
| 147 | SERVER_END_REQ; |
| 148 | return ret; |
| 149 | } |
| 150 | |
| 151 | |
| 152 | /*********************************************************************** |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 153 | * CLASS_GetProc |
Alexandre Julliard | b817f4f | 1996-03-14 18:08:34 +0000 | [diff] [blame] | 154 | * |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 155 | * Get the class winproc for a given proc type |
Alexandre Julliard | b817f4f | 1996-03-14 18:08:34 +0000 | [diff] [blame] | 156 | */ |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 157 | static WNDPROC16 CLASS_GetProc( CLASS *classPtr, WINDOWPROCTYPE type ) |
Alexandre Julliard | b817f4f | 1996-03-14 18:08:34 +0000 | [diff] [blame] | 158 | { |
Alexandre Julliard | 18d0297 | 2002-12-03 23:34:52 +0000 | [diff] [blame] | 159 | WNDPROC proc = classPtr->winprocA; |
Alexandre Julliard | b817f4f | 1996-03-14 18:08:34 +0000 | [diff] [blame] | 160 | |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 161 | if (classPtr->winprocW) |
Alexandre Julliard | b817f4f | 1996-03-14 18:08:34 +0000 | [diff] [blame] | 162 | { |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 163 | /* if we have a Unicode proc, use it if we have no ASCII proc |
| 164 | * or if we have both and Unicode was requested |
| 165 | */ |
| 166 | if (!proc || type == WIN_PROC_32W) proc = classPtr->winprocW; |
Alexandre Julliard | b817f4f | 1996-03-14 18:08:34 +0000 | [diff] [blame] | 167 | } |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 168 | return WINPROC_GetProc( proc, type ); |
Alexandre Julliard | b817f4f | 1996-03-14 18:08:34 +0000 | [diff] [blame] | 169 | } |
| 170 | |
| 171 | |
| 172 | /*********************************************************************** |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 173 | * CLASS_SetProc |
Alexandre Julliard | b817f4f | 1996-03-14 18:08:34 +0000 | [diff] [blame] | 174 | * |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 175 | * Set the class winproc for a given proc type. |
| 176 | * Returns the previous window proc. |
Alexandre Julliard | b817f4f | 1996-03-14 18:08:34 +0000 | [diff] [blame] | 177 | */ |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 178 | static WNDPROC16 CLASS_SetProc( CLASS *classPtr, WNDPROC newproc, WINDOWPROCTYPE type ) |
Alexandre Julliard | b817f4f | 1996-03-14 18:08:34 +0000 | [diff] [blame] | 179 | { |
Alexandre Julliard | 18d0297 | 2002-12-03 23:34:52 +0000 | [diff] [blame] | 180 | WNDPROC *proc = &classPtr->winprocA; |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 181 | WNDPROC16 ret; |
Alexandre Julliard | b817f4f | 1996-03-14 18:08:34 +0000 | [diff] [blame] | 182 | |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 183 | if (classPtr->winprocW) |
Alexandre Julliard | b817f4f | 1996-03-14 18:08:34 +0000 | [diff] [blame] | 184 | { |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 185 | /* if we have a Unicode proc, use it if we have no ASCII proc |
| 186 | * or if we have both and Unicode was requested |
| 187 | */ |
| 188 | if (!*proc || type == WIN_PROC_32W) proc = &classPtr->winprocW; |
Alexandre Julliard | b817f4f | 1996-03-14 18:08:34 +0000 | [diff] [blame] | 189 | } |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 190 | ret = WINPROC_GetProc( *proc, type ); |
Alexandre Julliard | 18d0297 | 2002-12-03 23:34:52 +0000 | [diff] [blame] | 191 | WINPROC_SetProc( proc, newproc, type, WIN_PROC_CLASS ); |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 192 | /* now free the one that we didn't set */ |
| 193 | if (classPtr->winprocA && classPtr->winprocW) |
| 194 | { |
| 195 | if (proc == &classPtr->winprocA) |
| 196 | { |
| 197 | WINPROC_FreeProc( classPtr->winprocW, WIN_PROC_CLASS ); |
| 198 | classPtr->winprocW = 0; |
| 199 | } |
| 200 | else |
| 201 | { |
| 202 | WINPROC_FreeProc( classPtr->winprocA, WIN_PROC_CLASS ); |
| 203 | classPtr->winprocA = 0; |
| 204 | } |
| 205 | } |
| 206 | return ret; |
Alexandre Julliard | b817f4f | 1996-03-14 18:08:34 +0000 | [diff] [blame] | 207 | } |
| 208 | |
| 209 | |
| 210 | /*********************************************************************** |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 211 | * CLASS_GetMenuNameA |
| 212 | * |
| 213 | * Get the menu name as a ASCII string. |
| 214 | */ |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 215 | inline static LPSTR CLASS_GetMenuNameA( CLASS *classPtr ) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 216 | { |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 217 | if (!HIWORD(classPtr->menuName)) return (LPSTR)classPtr->menuName; |
| 218 | return (LPSTR)(classPtr->menuName + strlenW(classPtr->menuName) + 1); |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 219 | } |
| 220 | |
| 221 | |
| 222 | /*********************************************************************** |
Alexandre Julliard | d7b7682 | 2001-12-20 00:19:40 +0000 | [diff] [blame] | 223 | * CLASS_GetMenuName16 |
| 224 | * |
| 225 | * Get the menu name as a SEGPTR. |
| 226 | */ |
| 227 | inline static SEGPTR CLASS_GetMenuName16( CLASS *classPtr ) |
| 228 | { |
| 229 | if (!HIWORD(classPtr->menuName)) return (SEGPTR)classPtr->menuName; |
| 230 | if (!classPtr->segMenuName) |
| 231 | classPtr->segMenuName = MapLS( CLASS_GetMenuNameA(classPtr) ); |
| 232 | return classPtr->segMenuName; |
| 233 | } |
| 234 | |
| 235 | |
| 236 | /*********************************************************************** |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 237 | * CLASS_GetMenuNameW |
| 238 | * |
| 239 | * Get the menu name as a Unicode string. |
| 240 | */ |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 241 | inline static LPWSTR CLASS_GetMenuNameW( CLASS *classPtr ) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 242 | { |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 243 | return classPtr->menuName; |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 244 | } |
| 245 | |
| 246 | |
| 247 | /*********************************************************************** |
| 248 | * CLASS_SetMenuNameA |
| 249 | * |
| 250 | * Set the menu name in a class structure by copying the string. |
| 251 | */ |
| 252 | static void CLASS_SetMenuNameA( CLASS *classPtr, LPCSTR name ) |
| 253 | { |
Alexandre Julliard | d7b7682 | 2001-12-20 00:19:40 +0000 | [diff] [blame] | 254 | UnMapLS( classPtr->segMenuName ); |
| 255 | classPtr->segMenuName = 0; |
| 256 | if (HIWORD(classPtr->menuName)) HeapFree( GetProcessHeap(), 0, classPtr->menuName ); |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 257 | if (HIWORD(name)) |
| 258 | { |
| 259 | DWORD lenA = strlen(name) + 1; |
| 260 | DWORD lenW = MultiByteToWideChar( CP_ACP, 0, name, lenA, NULL, 0 ); |
Alexandre Julliard | d7b7682 | 2001-12-20 00:19:40 +0000 | [diff] [blame] | 261 | classPtr->menuName = HeapAlloc( GetProcessHeap(), 0, lenA + lenW*sizeof(WCHAR) ); |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 262 | MultiByteToWideChar( CP_ACP, 0, name, lenA, classPtr->menuName, lenW ); |
| 263 | memcpy( classPtr->menuName + lenW, name, lenA ); |
| 264 | } |
| 265 | else classPtr->menuName = (LPWSTR)name; |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 266 | } |
| 267 | |
| 268 | |
| 269 | /*********************************************************************** |
| 270 | * CLASS_SetMenuNameW |
| 271 | * |
| 272 | * Set the menu name in a class structure by copying the string. |
| 273 | */ |
| 274 | static void CLASS_SetMenuNameW( CLASS *classPtr, LPCWSTR name ) |
| 275 | { |
Alexandre Julliard | d7b7682 | 2001-12-20 00:19:40 +0000 | [diff] [blame] | 276 | UnMapLS( classPtr->segMenuName ); |
| 277 | classPtr->segMenuName = 0; |
| 278 | if (HIWORD(classPtr->menuName)) HeapFree( GetProcessHeap(), 0, classPtr->menuName ); |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 279 | if (HIWORD(name)) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 280 | { |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 281 | DWORD lenW = strlenW(name) + 1; |
| 282 | DWORD lenA = WideCharToMultiByte( CP_ACP, 0, name, lenW, NULL, 0, NULL, NULL ); |
Alexandre Julliard | d7b7682 | 2001-12-20 00:19:40 +0000 | [diff] [blame] | 283 | classPtr->menuName = HeapAlloc( GetProcessHeap(), 0, lenA + lenW*sizeof(WCHAR) ); |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 284 | memcpy( classPtr->menuName, name, lenW*sizeof(WCHAR) ); |
| 285 | WideCharToMultiByte( CP_ACP, 0, name, lenW, |
| 286 | (char *)(classPtr->menuName + lenW), lenA, NULL, NULL ); |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 287 | } |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 288 | else classPtr->menuName = (LPWSTR)name; |
Gavriel State | c77c592 | 1998-11-15 09:21:17 +0000 | [diff] [blame] | 289 | } |
| 290 | |
| 291 | |
| 292 | /*********************************************************************** |
Alexandre Julliard | 2ace16a | 1996-04-28 15:09:19 +0000 | [diff] [blame] | 293 | * CLASS_FreeClass |
| 294 | * |
| 295 | * Free a class structure. |
| 296 | */ |
Alexandre Julliard | bd13ab8 | 2003-12-11 05:34:53 +0000 | [diff] [blame] | 297 | static void CLASS_FreeClass( CLASS *classPtr ) |
Alexandre Julliard | 2ace16a | 1996-04-28 15:09:19 +0000 | [diff] [blame] | 298 | { |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 299 | TRACE("%p\n", classPtr); |
Alexandre Julliard | 2ace16a | 1996-04-28 15:09:19 +0000 | [diff] [blame] | 300 | |
Alexandre Julliard | bd13ab8 | 2003-12-11 05:34:53 +0000 | [diff] [blame] | 301 | USER_Lock(); |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 302 | |
Alexandre Julliard | bd13ab8 | 2003-12-11 05:34:53 +0000 | [diff] [blame] | 303 | list_remove( &classPtr->entry ); |
| 304 | if (classPtr->dce) DCE_FreeDCE( classPtr->dce ); |
| 305 | if (classPtr->hbrBackground > (HBRUSH)(COLOR_GRADIENTINACTIVECAPTION + 1)) |
| 306 | DeleteObject( classPtr->hbrBackground ); |
| 307 | WINPROC_FreeProc( classPtr->winprocA, WIN_PROC_CLASS ); |
| 308 | WINPROC_FreeProc( classPtr->winprocW, WIN_PROC_CLASS ); |
| 309 | UnMapLS( classPtr->segMenuName ); |
| 310 | HeapFree( GetProcessHeap(), 0, classPtr->menuName ); |
| 311 | HeapFree( GetProcessHeap(), 0, classPtr ); |
| 312 | USER_Unlock(); |
Alexandre Julliard | 2ace16a | 1996-04-28 15:09:19 +0000 | [diff] [blame] | 313 | } |
| 314 | |
| 315 | |
| 316 | /*********************************************************************** |
| 317 | * CLASS_FreeModuleClasses |
| 318 | */ |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 319 | void CLASS_FreeModuleClasses( HMODULE16 hModule ) |
Alexandre Julliard | 2ace16a | 1996-04-28 15:09:19 +0000 | [diff] [blame] | 320 | { |
Alexandre Julliard | bfce151 | 2003-12-10 04:08:06 +0000 | [diff] [blame] | 321 | struct list *ptr, *next; |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 322 | |
Alexandre Julliard | e6d90ea | 2001-10-09 23:27:17 +0000 | [diff] [blame] | 323 | TRACE("0x%08x\n", hModule); |
| 324 | |
| 325 | USER_Lock(); |
Alexandre Julliard | bfce151 | 2003-12-10 04:08:06 +0000 | [diff] [blame] | 326 | for (ptr = list_head( &class_list ); ptr; ptr = next) |
Alexandre Julliard | 2ace16a | 1996-04-28 15:09:19 +0000 | [diff] [blame] | 327 | { |
Alexandre Julliard | bfce151 | 2003-12-10 04:08:06 +0000 | [diff] [blame] | 328 | CLASS *class = LIST_ENTRY( ptr, CLASS, entry ); |
| 329 | next = list_next( &class_list, ptr ); |
Alexandre Julliard | bd13ab8 | 2003-12-11 05:34:53 +0000 | [diff] [blame] | 330 | if (class->hInstance == HINSTANCE_32(hModule)) |
| 331 | { |
| 332 | BOOL ret; |
| 333 | |
| 334 | SERVER_START_REQ( destroy_class ) |
| 335 | { |
| 336 | req->atom = class->atomName; |
| 337 | req->instance = class->hInstance; |
| 338 | ret = !wine_server_call_err( req ); |
| 339 | } |
| 340 | SERVER_END_REQ; |
| 341 | if (ret) CLASS_FreeClass( class ); |
| 342 | } |
Alexandre Julliard | 2ace16a | 1996-04-28 15:09:19 +0000 | [diff] [blame] | 343 | } |
Alexandre Julliard | e6d90ea | 2001-10-09 23:27:17 +0000 | [diff] [blame] | 344 | USER_Unlock(); |
Alexandre Julliard | 2ace16a | 1996-04-28 15:09:19 +0000 | [diff] [blame] | 345 | } |
| 346 | |
| 347 | |
| 348 | /*********************************************************************** |
Alexandre Julliard | 1285c2f | 1996-05-06 16:06:24 +0000 | [diff] [blame] | 349 | * CLASS_FindClassByAtom |
| 350 | * |
| 351 | * Return a pointer to the class. |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 352 | * hinstance has been normalized by the caller. |
Alexandre Julliard | 1285c2f | 1996-05-06 16:06:24 +0000 | [diff] [blame] | 353 | */ |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 354 | static CLASS *CLASS_FindClassByAtom( ATOM atom, HINSTANCE hinstance ) |
| 355 | { |
Alexandre Julliard | bfce151 | 2003-12-10 04:08:06 +0000 | [diff] [blame] | 356 | struct list *ptr; |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 357 | |
Alexandre Julliard | bd13ab8 | 2003-12-11 05:34:53 +0000 | [diff] [blame] | 358 | USER_Lock(); |
| 359 | |
Alexandre Julliard | bfce151 | 2003-12-10 04:08:06 +0000 | [diff] [blame] | 360 | LIST_FOR_EACH( ptr, &class_list ) |
Alexandre Julliard | 1285c2f | 1996-05-06 16:06:24 +0000 | [diff] [blame] | 361 | { |
Alexandre Julliard | bfce151 | 2003-12-10 04:08:06 +0000 | [diff] [blame] | 362 | CLASS *class = LIST_ENTRY( ptr, CLASS, entry ); |
| 363 | if (class->atomName != atom) continue; |
| 364 | if (!hinstance || !class->local || class->hInstance == hinstance) |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 365 | { |
Alexandre Julliard | bfce151 | 2003-12-10 04:08:06 +0000 | [diff] [blame] | 366 | TRACE("0x%04x %p -> %p\n", atom, hinstance, class); |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 367 | return class; |
| 368 | } |
Alexandre Julliard | 1285c2f | 1996-05-06 16:06:24 +0000 | [diff] [blame] | 369 | } |
Alexandre Julliard | bd13ab8 | 2003-12-11 05:34:53 +0000 | [diff] [blame] | 370 | USER_Unlock(); |
Alexandre Julliard | bfce151 | 2003-12-10 04:08:06 +0000 | [diff] [blame] | 371 | TRACE("0x%04x %p -> not found\n", atom, hinstance); |
| 372 | return NULL; |
Alexandre Julliard | 1285c2f | 1996-05-06 16:06:24 +0000 | [diff] [blame] | 373 | } |
| 374 | |
| 375 | |
| 376 | /*********************************************************************** |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 377 | * CLASS_RegisterClass |
| 378 | * |
| 379 | * The real RegisterClass() functionality. |
Alexandre Julliard | bd13ab8 | 2003-12-11 05:34:53 +0000 | [diff] [blame] | 380 | * The atom is deleted no matter what. |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 381 | */ |
Alexandre Julliard | bfce151 | 2003-12-10 04:08:06 +0000 | [diff] [blame] | 382 | static CLASS *CLASS_RegisterClass( ATOM atom, HINSTANCE hInstance, BOOL local, |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 383 | DWORD style, INT classExtra, INT winExtra ) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 384 | { |
| 385 | CLASS *classPtr; |
Alexandre Julliard | bfce151 | 2003-12-10 04:08:06 +0000 | [diff] [blame] | 386 | BOOL ret; |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 387 | |
Alexandre Julliard | aff7dda | 2002-11-22 21:22:14 +0000 | [diff] [blame] | 388 | TRACE("atom=0x%x hinst=%p style=0x%lx clExtr=0x%x winExtr=0x%x\n", |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 389 | atom, hInstance, style, classExtra, winExtra ); |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 390 | |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 391 | /* Fix the extra bytes value */ |
| 392 | |
| 393 | if (classExtra < 0) classExtra = 0; |
| 394 | else if (classExtra > 40) /* Extra bytes are limited to 40 in Win32 */ |
Alexandre Julliard | 359f497e | 1999-07-04 16:02:24 +0000 | [diff] [blame] | 395 | WARN("Class extra bytes %d is > 40\n", classExtra); |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 396 | if (winExtra < 0) winExtra = 0; |
| 397 | else if (winExtra > 40) /* Extra bytes are limited to 40 in Win32 */ |
Alexandre Julliard | 359f497e | 1999-07-04 16:02:24 +0000 | [diff] [blame] | 398 | WARN("Win extra bytes %d is > 40\n", winExtra ); |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 399 | |
Alexandre Julliard | d44e495 | 2001-08-20 18:09:39 +0000 | [diff] [blame] | 400 | classPtr = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(CLASS) + classExtra ); |
Alexandre Julliard | bd13ab8 | 2003-12-11 05:34:53 +0000 | [diff] [blame] | 401 | if (!classPtr) |
| 402 | { |
| 403 | GlobalDeleteAtom( atom ); |
| 404 | return NULL; |
| 405 | } |
Alexandre Julliard | bfce151 | 2003-12-10 04:08:06 +0000 | [diff] [blame] | 406 | |
| 407 | SERVER_START_REQ( create_class ) |
| 408 | { |
Alexandre Julliard | bd13ab8 | 2003-12-11 05:34:53 +0000 | [diff] [blame] | 409 | req->local = local; |
| 410 | req->atom = atom; |
| 411 | req->style = style; |
| 412 | req->instance = hInstance; |
| 413 | req->extra = classExtra; |
| 414 | req->win_extra = winExtra; |
| 415 | req->client_ptr = classPtr; |
Alexandre Julliard | bfce151 | 2003-12-10 04:08:06 +0000 | [diff] [blame] | 416 | ret = !wine_server_call_err( req ); |
| 417 | } |
| 418 | SERVER_END_REQ; |
Alexandre Julliard | bd13ab8 | 2003-12-11 05:34:53 +0000 | [diff] [blame] | 419 | GlobalDeleteAtom( atom ); /* the server increased the atom ref count */ |
Alexandre Julliard | bfce151 | 2003-12-10 04:08:06 +0000 | [diff] [blame] | 420 | if (!ret) |
| 421 | { |
| 422 | HeapFree( GetProcessHeap(), 0, classPtr ); |
| 423 | return NULL; |
| 424 | } |
| 425 | |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 426 | classPtr->style = style; |
Alexandre Julliard | bfce151 | 2003-12-10 04:08:06 +0000 | [diff] [blame] | 427 | classPtr->local = local; |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 428 | classPtr->cbWndExtra = winExtra; |
| 429 | classPtr->cbClsExtra = classExtra; |
| 430 | classPtr->hInstance = hInstance; |
| 431 | classPtr->atomName = atom; |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 432 | classPtr->dce = (style & CS_CLASSDC) ? DCE_AllocDCE( 0, DCE_CLASS_DC ) : NULL; |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 433 | |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 434 | /* Other non-null values must be set by caller */ |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 435 | |
Alexandre Julliard | bd13ab8 | 2003-12-11 05:34:53 +0000 | [diff] [blame] | 436 | USER_Lock(); |
Alexandre Julliard | bfce151 | 2003-12-10 04:08:06 +0000 | [diff] [blame] | 437 | if (local) list_add_head( &class_list, &classPtr->entry ); |
| 438 | else list_add_tail( &class_list, &classPtr->entry ); |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 439 | return classPtr; |
| 440 | } |
| 441 | |
| 442 | |
| 443 | /*********************************************************************** |
Alexandre Julliard | bfce151 | 2003-12-10 04:08:06 +0000 | [diff] [blame] | 444 | * register_builtin |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 445 | * |
| 446 | * Register a builtin control class. |
| 447 | * This allows having both ASCII and Unicode winprocs for the same class. |
| 448 | */ |
Alexandre Julliard | bd13ab8 | 2003-12-11 05:34:53 +0000 | [diff] [blame] | 449 | static CLASS *register_builtin( const struct builtin_class_descr *descr ) |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 450 | { |
| 451 | ATOM atom; |
| 452 | CLASS *classPtr; |
| 453 | |
Alexandre Julliard | 91222da | 2000-12-10 23:01:33 +0000 | [diff] [blame] | 454 | if (!(atom = GlobalAddAtomA( descr->name ))) return 0; |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 455 | |
Alexandre Julliard | bfce151 | 2003-12-10 04:08:06 +0000 | [diff] [blame] | 456 | if (!(classPtr = CLASS_RegisterClass( atom, user32_module, FALSE, |
Alexandre Julliard | bd13ab8 | 2003-12-11 05:34:53 +0000 | [diff] [blame] | 457 | descr->style, 0, descr->extra ))) return 0; |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 458 | |
Alexandre Julliard | cf52644 | 2003-09-10 03:56:47 +0000 | [diff] [blame] | 459 | classPtr->hCursor = LoadCursorA( 0, (LPSTR)descr->cursor ); |
Alexandre Julliard | 91222da | 2000-12-10 23:01:33 +0000 | [diff] [blame] | 460 | classPtr->hbrBackground = descr->brush; |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 461 | |
Alexandre Julliard | 18d0297 | 2002-12-03 23:34:52 +0000 | [diff] [blame] | 462 | if (descr->procA) WINPROC_SetProc( &classPtr->winprocA, descr->procA, |
Alexandre Julliard | 91222da | 2000-12-10 23:01:33 +0000 | [diff] [blame] | 463 | WIN_PROC_32A, WIN_PROC_CLASS ); |
Alexandre Julliard | 18d0297 | 2002-12-03 23:34:52 +0000 | [diff] [blame] | 464 | if (descr->procW) WINPROC_SetProc( &classPtr->winprocW, descr->procW, |
Alexandre Julliard | 91222da | 2000-12-10 23:01:33 +0000 | [diff] [blame] | 465 | WIN_PROC_32W, WIN_PROC_CLASS ); |
Alexandre Julliard | bd13ab8 | 2003-12-11 05:34:53 +0000 | [diff] [blame] | 466 | release_class_ptr( classPtr ); |
| 467 | return classPtr; |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 468 | } |
| 469 | |
| 470 | |
| 471 | /*********************************************************************** |
Alexandre Julliard | bfce151 | 2003-12-10 04:08:06 +0000 | [diff] [blame] | 472 | * CLASS_RegisterBuiltinClasses |
| 473 | */ |
| 474 | void CLASS_RegisterBuiltinClasses( HMODULE user32 ) |
| 475 | { |
| 476 | extern const struct builtin_class_descr BUTTON_builtin_class; |
| 477 | extern const struct builtin_class_descr COMBO_builtin_class; |
| 478 | extern const struct builtin_class_descr COMBOLBOX_builtin_class; |
| 479 | extern const struct builtin_class_descr DIALOG_builtin_class; |
| 480 | extern const struct builtin_class_descr DESKTOP_builtin_class; |
| 481 | extern const struct builtin_class_descr EDIT_builtin_class; |
| 482 | extern const struct builtin_class_descr ICONTITLE_builtin_class; |
| 483 | extern const struct builtin_class_descr LISTBOX_builtin_class; |
| 484 | extern const struct builtin_class_descr MDICLIENT_builtin_class; |
| 485 | extern const struct builtin_class_descr MENU_builtin_class; |
| 486 | extern const struct builtin_class_descr SCROLL_builtin_class; |
| 487 | extern const struct builtin_class_descr STATIC_builtin_class; |
| 488 | |
| 489 | user32_module = user32; |
Alexandre Julliard | bd13ab8 | 2003-12-11 05:34:53 +0000 | [diff] [blame] | 490 | desktop_class = register_builtin( &DESKTOP_builtin_class ); |
Alexandre Julliard | bfce151 | 2003-12-10 04:08:06 +0000 | [diff] [blame] | 491 | register_builtin( &BUTTON_builtin_class ); |
| 492 | register_builtin( &COMBO_builtin_class ); |
| 493 | register_builtin( &COMBOLBOX_builtin_class ); |
| 494 | register_builtin( &DIALOG_builtin_class ); |
Alexandre Julliard | bfce151 | 2003-12-10 04:08:06 +0000 | [diff] [blame] | 495 | register_builtin( &EDIT_builtin_class ); |
| 496 | register_builtin( &ICONTITLE_builtin_class ); |
| 497 | register_builtin( &LISTBOX_builtin_class ); |
| 498 | register_builtin( &MDICLIENT_builtin_class ); |
| 499 | register_builtin( &MENU_builtin_class ); |
| 500 | register_builtin( &SCROLL_builtin_class ); |
| 501 | register_builtin( &STATIC_builtin_class ); |
| 502 | } |
| 503 | |
| 504 | |
| 505 | /*********************************************************************** |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 506 | * CLASS_AddWindow |
| 507 | * |
Alexandre Julliard | bd13ab8 | 2003-12-11 05:34:53 +0000 | [diff] [blame] | 508 | * Add a new window using this class, and set the necessary |
| 509 | * information inside the window structure. |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 510 | */ |
Alexandre Julliard | bd13ab8 | 2003-12-11 05:34:53 +0000 | [diff] [blame] | 511 | void CLASS_AddWindow( CLASS *class, WND *win, WINDOWPROCTYPE type ) |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 512 | { |
Alexandre Julliard | bd13ab8 | 2003-12-11 05:34:53 +0000 | [diff] [blame] | 513 | if (!class) class = desktop_class; |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 514 | |
| 515 | if (type == WIN_PROC_32W) |
| 516 | { |
Alexandre Julliard | bd13ab8 | 2003-12-11 05:34:53 +0000 | [diff] [blame] | 517 | if (!(win->winproc = class->winprocW)) win->winproc = class->winprocA; |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 518 | } |
| 519 | else |
| 520 | { |
Alexandre Julliard | bd13ab8 | 2003-12-11 05:34:53 +0000 | [diff] [blame] | 521 | if (!(win->winproc = class->winprocA)) win->winproc = class->winprocW; |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 522 | } |
Alexandre Julliard | bd13ab8 | 2003-12-11 05:34:53 +0000 | [diff] [blame] | 523 | win->class = class; |
| 524 | win->clsStyle = class->style; |
| 525 | win->dce = class->dce; |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 526 | } |
| 527 | |
| 528 | |
| 529 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 530 | * RegisterClass (USER.57) |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 531 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 532 | ATOM WINAPI RegisterClass16( const WNDCLASS16 *wc ) |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 533 | { |
Alexandre Julliard | 5f32566 | 2003-12-10 01:46:52 +0000 | [diff] [blame] | 534 | WNDCLASSEX16 wcex; |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 535 | |
Alexandre Julliard | 5f32566 | 2003-12-10 01:46:52 +0000 | [diff] [blame] | 536 | wcex.cbSize = sizeof(wcex); |
| 537 | wcex.style = wc->style; |
| 538 | wcex.lpfnWndProc = wc->lpfnWndProc; |
| 539 | wcex.cbClsExtra = wc->cbClsExtra; |
| 540 | wcex.cbWndExtra = wc->cbWndExtra; |
| 541 | wcex.hInstance = wc->hInstance; |
| 542 | wcex.hIcon = wc->hIcon; |
| 543 | wcex.hCursor = wc->hCursor; |
| 544 | wcex.hbrBackground = wc->hbrBackground; |
| 545 | wcex.lpszMenuName = wc->lpszMenuName; |
| 546 | wcex.lpszClassName = wc->lpszClassName; |
| 547 | wcex.hIconSm = 0; |
| 548 | return RegisterClassEx16( &wcex ); |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 549 | } |
| 550 | |
| 551 | |
| 552 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 553 | * RegisterClassA (USER32.@) |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 554 | * RETURNS |
| 555 | * >0: Unique identifier |
| 556 | * 0: Failure |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 557 | */ |
Patrik Stridvall | 2b3aa61 | 2000-12-01 23:58:28 +0000 | [diff] [blame] | 558 | ATOM WINAPI RegisterClassA( const WNDCLASSA* wc ) /* [in] Address of structure with class data */ |
Alexandre Julliard | f681cd0 | 2000-08-23 19:18:44 +0000 | [diff] [blame] | 559 | { |
Alexandre Julliard | 5f32566 | 2003-12-10 01:46:52 +0000 | [diff] [blame] | 560 | WNDCLASSEXA wcex; |
Alexandre Julliard | 1285c2f | 1996-05-06 16:06:24 +0000 | [diff] [blame] | 561 | |
Alexandre Julliard | 5f32566 | 2003-12-10 01:46:52 +0000 | [diff] [blame] | 562 | wcex.cbSize = sizeof(wcex); |
| 563 | wcex.style = wc->style; |
| 564 | wcex.lpfnWndProc = wc->lpfnWndProc; |
| 565 | wcex.cbClsExtra = wc->cbClsExtra; |
| 566 | wcex.cbWndExtra = wc->cbWndExtra; |
| 567 | wcex.hInstance = wc->hInstance; |
| 568 | wcex.hIcon = wc->hIcon; |
| 569 | wcex.hCursor = wc->hCursor; |
| 570 | wcex.hbrBackground = wc->hbrBackground; |
| 571 | wcex.lpszMenuName = wc->lpszMenuName; |
| 572 | wcex.lpszClassName = wc->lpszClassName; |
| 573 | wcex.hIconSm = 0; |
| 574 | return RegisterClassExA( &wcex ); |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 575 | } |
| 576 | |
| 577 | |
| 578 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 579 | * RegisterClassW (USER32.@) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 580 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 581 | ATOM WINAPI RegisterClassW( const WNDCLASSW* wc ) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 582 | { |
Alexandre Julliard | 5f32566 | 2003-12-10 01:46:52 +0000 | [diff] [blame] | 583 | WNDCLASSEXW wcex; |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 584 | |
Alexandre Julliard | 5f32566 | 2003-12-10 01:46:52 +0000 | [diff] [blame] | 585 | wcex.cbSize = sizeof(wcex); |
| 586 | wcex.style = wc->style; |
| 587 | wcex.lpfnWndProc = wc->lpfnWndProc; |
| 588 | wcex.cbClsExtra = wc->cbClsExtra; |
| 589 | wcex.cbWndExtra = wc->cbWndExtra; |
| 590 | wcex.hInstance = wc->hInstance; |
| 591 | wcex.hIcon = wc->hIcon; |
| 592 | wcex.hCursor = wc->hCursor; |
| 593 | wcex.hbrBackground = wc->hbrBackground; |
| 594 | wcex.lpszMenuName = wc->lpszMenuName; |
| 595 | wcex.lpszClassName = wc->lpszClassName; |
| 596 | wcex.hIconSm = 0; |
| 597 | return RegisterClassExW( &wcex ); |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 598 | } |
| 599 | |
| 600 | |
| 601 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 602 | * RegisterClassEx (USER.397) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 603 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 604 | ATOM WINAPI RegisterClassEx16( const WNDCLASSEX16 *wc ) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 605 | { |
| 606 | ATOM atom; |
| 607 | CLASS *classPtr; |
Alexandre Julliard | bfce151 | 2003-12-10 04:08:06 +0000 | [diff] [blame] | 608 | HINSTANCE hInstance; |
| 609 | |
| 610 | if (!(hInstance = HINSTANCE_32(GetExePtr(wc->hInstance)))) |
| 611 | hInstance = HINSTANCE_32(GetModuleHandle16(NULL)); |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 612 | |
Alexandre Julliard | 982a223 | 2000-12-13 20:20:09 +0000 | [diff] [blame] | 613 | if (!(atom = GlobalAddAtomA( MapSL(wc->lpszClassName) ))) return 0; |
Alexandre Julliard | bfce151 | 2003-12-10 04:08:06 +0000 | [diff] [blame] | 614 | if (!(classPtr = CLASS_RegisterClass( atom, hInstance, !(wc->style & CS_GLOBALCLASS), |
| 615 | wc->style, wc->cbClsExtra, wc->cbWndExtra ))) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 616 | return 0; |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 617 | |
Alexandre Julliard | aff7dda | 2002-11-22 21:22:14 +0000 | [diff] [blame] | 618 | TRACE("atom=%04x wndproc=%p hinst=%p bg=%04x style=%08x clsExt=%d winExt=%d class=%p\n", |
| 619 | atom, wc->lpfnWndProc, hInstance, |
| 620 | wc->hbrBackground, wc->style, wc->cbClsExtra, |
| 621 | wc->cbWndExtra, classPtr ); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 622 | |
Michael Stefaniuc | bc54d78 | 2002-10-10 21:22:09 +0000 | [diff] [blame] | 623 | classPtr->hIcon = HICON_32(wc->hIcon); |
| 624 | classPtr->hIconSm = HICON_32(wc->hIconSm); |
| 625 | classPtr->hCursor = HCURSOR_32(wc->hCursor); |
| 626 | classPtr->hbrBackground = HBRUSH_32(wc->hbrBackground); |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 627 | |
Alexandre Julliard | 18d0297 | 2002-12-03 23:34:52 +0000 | [diff] [blame] | 628 | WINPROC_SetProc( &classPtr->winprocA, (WNDPROC)wc->lpfnWndProc, |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 629 | WIN_PROC_16, WIN_PROC_CLASS ); |
Alexandre Julliard | 982a223 | 2000-12-13 20:20:09 +0000 | [diff] [blame] | 630 | CLASS_SetMenuNameA( classPtr, MapSL(wc->lpszMenuName) ); |
Alexandre Julliard | bd13ab8 | 2003-12-11 05:34:53 +0000 | [diff] [blame] | 631 | release_class_ptr( classPtr ); |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 632 | return atom; |
| 633 | } |
| 634 | |
| 635 | |
| 636 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 637 | * RegisterClassExA (USER32.@) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 638 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 639 | ATOM WINAPI RegisterClassExA( const WNDCLASSEXA* wc ) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 640 | { |
| 641 | ATOM atom; |
| 642 | CLASS *classPtr; |
Alexandre Julliard | bfce151 | 2003-12-10 04:08:06 +0000 | [diff] [blame] | 643 | HINSTANCE instance; |
| 644 | |
| 645 | if (wc->hInstance == user32_module) |
| 646 | { |
| 647 | /* we can't register a class for user32 */ |
| 648 | SetLastError( ERROR_INVALID_PARAMETER ); |
| 649 | return 0; |
| 650 | } |
| 651 | if (!(instance = wc->hInstance)) instance = GetModuleHandleW( NULL ); |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 652 | |
Alexandre Julliard | f681cd0 | 2000-08-23 19:18:44 +0000 | [diff] [blame] | 653 | if (!(atom = GlobalAddAtomA( wc->lpszClassName ))) return 0; |
| 654 | |
Alexandre Julliard | bfce151 | 2003-12-10 04:08:06 +0000 | [diff] [blame] | 655 | if (!(classPtr = CLASS_RegisterClass( atom, instance, !(wc->style & CS_GLOBALCLASS), |
| 656 | wc->style, wc->cbClsExtra, wc->cbWndExtra ))) |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 657 | return 0; |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 658 | |
Alexandre Julliard | aff7dda | 2002-11-22 21:22:14 +0000 | [diff] [blame] | 659 | TRACE("atom=%04x wndproc=%p hinst=%p bg=%p style=%08x clsExt=%d winExt=%d class=%p\n", |
Alexandre Julliard | bfce151 | 2003-12-10 04:08:06 +0000 | [diff] [blame] | 660 | atom, wc->lpfnWndProc, instance, wc->hbrBackground, |
| 661 | wc->style, wc->cbClsExtra, wc->cbWndExtra, classPtr ); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 662 | |
Michael Stefaniuc | bc54d78 | 2002-10-10 21:22:09 +0000 | [diff] [blame] | 663 | classPtr->hIcon = wc->hIcon; |
| 664 | classPtr->hIconSm = wc->hIconSm; |
| 665 | classPtr->hCursor = wc->hCursor; |
| 666 | classPtr->hbrBackground = wc->hbrBackground; |
Alexandre Julliard | 18d0297 | 2002-12-03 23:34:52 +0000 | [diff] [blame] | 667 | WINPROC_SetProc( &classPtr->winprocA, wc->lpfnWndProc, WIN_PROC_32A, WIN_PROC_CLASS ); |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 668 | CLASS_SetMenuNameA( classPtr, wc->lpszMenuName ); |
Alexandre Julliard | bd13ab8 | 2003-12-11 05:34:53 +0000 | [diff] [blame] | 669 | release_class_ptr( classPtr ); |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 670 | return atom; |
| 671 | } |
| 672 | |
| 673 | |
| 674 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 675 | * RegisterClassExW (USER32.@) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 676 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 677 | ATOM WINAPI RegisterClassExW( const WNDCLASSEXW* wc ) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 678 | { |
| 679 | ATOM atom; |
| 680 | CLASS *classPtr; |
Alexandre Julliard | bfce151 | 2003-12-10 04:08:06 +0000 | [diff] [blame] | 681 | HINSTANCE instance; |
| 682 | |
| 683 | if (wc->hInstance == user32_module) |
| 684 | { |
| 685 | /* we can't register a class for user32 */ |
| 686 | SetLastError( ERROR_INVALID_PARAMETER ); |
| 687 | return 0; |
| 688 | } |
| 689 | if (!(instance = wc->hInstance)) instance = GetModuleHandleW( NULL ); |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 690 | |
Alexandre Julliard | f681cd0 | 2000-08-23 19:18:44 +0000 | [diff] [blame] | 691 | if (!(atom = GlobalAddAtomW( wc->lpszClassName ))) return 0; |
| 692 | |
Alexandre Julliard | bfce151 | 2003-12-10 04:08:06 +0000 | [diff] [blame] | 693 | if (!(classPtr = CLASS_RegisterClass( atom, instance, !(wc->style & CS_GLOBALCLASS), |
| 694 | wc->style, wc->cbClsExtra, wc->cbWndExtra ))) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 695 | return 0; |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 696 | |
Alexandre Julliard | aff7dda | 2002-11-22 21:22:14 +0000 | [diff] [blame] | 697 | TRACE("atom=%04x wndproc=%p hinst=%p bg=%p style=%08x clsExt=%d winExt=%d class=%p\n", |
Alexandre Julliard | bfce151 | 2003-12-10 04:08:06 +0000 | [diff] [blame] | 698 | atom, wc->lpfnWndProc, instance, wc->hbrBackground, |
| 699 | wc->style, wc->cbClsExtra, wc->cbWndExtra, classPtr ); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 700 | |
Michael Stefaniuc | bc54d78 | 2002-10-10 21:22:09 +0000 | [diff] [blame] | 701 | classPtr->hIcon = wc->hIcon; |
| 702 | classPtr->hIconSm = wc->hIconSm; |
| 703 | classPtr->hCursor = wc->hCursor; |
| 704 | classPtr->hbrBackground = wc->hbrBackground; |
Alexandre Julliard | 18d0297 | 2002-12-03 23:34:52 +0000 | [diff] [blame] | 705 | WINPROC_SetProc( &classPtr->winprocW, wc->lpfnWndProc, WIN_PROC_32W, WIN_PROC_CLASS ); |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 706 | CLASS_SetMenuNameW( classPtr, wc->lpszMenuName ); |
Alexandre Julliard | bd13ab8 | 2003-12-11 05:34:53 +0000 | [diff] [blame] | 707 | release_class_ptr( classPtr ); |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 708 | return atom; |
Alexandre Julliard | 1285c2f | 1996-05-06 16:06:24 +0000 | [diff] [blame] | 709 | } |
| 710 | |
| 711 | |
| 712 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 713 | * UnregisterClass (USER.403) |
Alexandre Julliard | 1285c2f | 1996-05-06 16:06:24 +0000 | [diff] [blame] | 714 | */ |
Alexandre Julliard | b849d79 | 2000-02-13 13:56:13 +0000 | [diff] [blame] | 715 | BOOL16 WINAPI UnregisterClass16( LPCSTR className, HINSTANCE16 hInstance ) |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 716 | { |
Alexandre Julliard | bfce151 | 2003-12-10 04:08:06 +0000 | [diff] [blame] | 717 | if (hInstance == GetModuleHandle16("user")) hInstance = 0; |
Alexandre Julliard | a8a422f | 2002-11-22 20:43:01 +0000 | [diff] [blame] | 718 | return UnregisterClassA( className, HINSTANCE_32(GetExePtr( hInstance )) ); |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 719 | } |
| 720 | |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 721 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 722 | * UnregisterClassA (USER32.@) |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 723 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 724 | BOOL WINAPI UnregisterClassA( LPCSTR className, HINSTANCE hInstance ) |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 725 | { |
Alexandre Julliard | bfce151 | 2003-12-10 04:08:06 +0000 | [diff] [blame] | 726 | ATOM atom = HIWORD(className) ? GlobalFindAtomA( className ) : LOWORD(className); |
| 727 | return UnregisterClassW( MAKEINTATOMW(atom), hInstance ); |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 728 | } |
| 729 | |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 730 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 731 | * UnregisterClassW (USER32.@) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 732 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 733 | BOOL WINAPI UnregisterClassW( LPCWSTR className, HINSTANCE hInstance ) |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 734 | { |
Alexandre Julliard | bd13ab8 | 2003-12-11 05:34:53 +0000 | [diff] [blame] | 735 | CLASS *classPtr = NULL; |
Alexandre Julliard | bfce151 | 2003-12-10 04:08:06 +0000 | [diff] [blame] | 736 | ATOM atom = HIWORD(className) ? GlobalFindAtomW( className ) : LOWORD(className); |
| 737 | |
| 738 | TRACE("%s %p %x\n",debugstr_w(className), hInstance, atom); |
| 739 | |
Alexandre Julliard | bd13ab8 | 2003-12-11 05:34:53 +0000 | [diff] [blame] | 740 | if (!atom) |
| 741 | { |
| 742 | SetLastError( ERROR_CLASS_DOES_NOT_EXIST ); |
| 743 | return FALSE; |
| 744 | } |
| 745 | |
Alexandre Julliard | bfce151 | 2003-12-10 04:08:06 +0000 | [diff] [blame] | 746 | if (!hInstance) hInstance = GetModuleHandleW( NULL ); |
| 747 | |
Alexandre Julliard | bd13ab8 | 2003-12-11 05:34:53 +0000 | [diff] [blame] | 748 | SERVER_START_REQ( destroy_class ) |
Alexandre Julliard | bfce151 | 2003-12-10 04:08:06 +0000 | [diff] [blame] | 749 | { |
Alexandre Julliard | bd13ab8 | 2003-12-11 05:34:53 +0000 | [diff] [blame] | 750 | req->atom = atom; |
| 751 | req->instance = hInstance; |
| 752 | if (!wine_server_call_err( req )) classPtr = reply->client_ptr; |
Alexandre Julliard | bfce151 | 2003-12-10 04:08:06 +0000 | [diff] [blame] | 753 | } |
Alexandre Julliard | bd13ab8 | 2003-12-11 05:34:53 +0000 | [diff] [blame] | 754 | SERVER_END_REQ; |
| 755 | |
| 756 | if (classPtr) CLASS_FreeClass( classPtr ); |
| 757 | return (classPtr != NULL); |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 758 | } |
| 759 | |
Alexandre Julliard | 2197901 | 1997-03-05 08:22:35 +0000 | [diff] [blame] | 760 | |
| 761 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 762 | * GetClassWord (USER32.@) |
Alexandre Julliard | 2197901 | 1997-03-05 08:22:35 +0000 | [diff] [blame] | 763 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 764 | WORD WINAPI GetClassWord( HWND hwnd, INT offset ) |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 765 | { |
Alexandre Julliard | e6d90ea | 2001-10-09 23:27:17 +0000 | [diff] [blame] | 766 | CLASS *class; |
Guy Albertelli | 2fa281f | 1999-04-24 11:54:40 +0000 | [diff] [blame] | 767 | WORD retvalue = 0; |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 768 | |
Alexandre Julliard | e6d90ea | 2001-10-09 23:27:17 +0000 | [diff] [blame] | 769 | if (offset < 0) return GetClassLongA( hwnd, offset ); |
| 770 | |
Alexandre Julliard | aff7dda | 2002-11-22 21:22:14 +0000 | [diff] [blame] | 771 | TRACE("%p %x\n",hwnd, offset); |
Alexandre Julliard | e6d90ea | 2001-10-09 23:27:17 +0000 | [diff] [blame] | 772 | |
Alexandre Julliard | 8fd26b9 | 2001-10-15 17:56:45 +0000 | [diff] [blame] | 773 | if (!(class = get_class_ptr( hwnd, FALSE ))) return 0; |
Alexandre Julliard | e6d90ea | 2001-10-09 23:27:17 +0000 | [diff] [blame] | 774 | |
Alexandre Julliard | bfce151 | 2003-12-10 04:08:06 +0000 | [diff] [blame] | 775 | if (class == CLASS_OTHER_PROCESS) |
| 776 | { |
| 777 | SERVER_START_REQ( set_class_info ) |
| 778 | { |
| 779 | req->window = hwnd; |
| 780 | req->flags = 0; |
| 781 | req->extra_offset = offset; |
| 782 | req->extra_size = sizeof(retvalue); |
| 783 | if (!wine_server_call_err( req )) |
| 784 | memcpy( &retvalue, &reply->old_extra_value, sizeof(retvalue) ); |
| 785 | } |
| 786 | SERVER_END_REQ; |
| 787 | return retvalue; |
| 788 | } |
| 789 | |
Alexandre Julliard | e6d90ea | 2001-10-09 23:27:17 +0000 | [diff] [blame] | 790 | if (offset <= class->cbClsExtra - sizeof(WORD)) |
Alexandre Julliard | 7fbd74e | 2002-05-23 02:53:10 +0000 | [diff] [blame] | 791 | memcpy( &retvalue, (char *)(class + 1) + offset, sizeof(retvalue) ); |
Alexandre Julliard | e6d90ea | 2001-10-09 23:27:17 +0000 | [diff] [blame] | 792 | else |
| 793 | SetLastError( ERROR_INVALID_INDEX ); |
| 794 | release_class_ptr( class ); |
Guy Albertelli | 2fa281f | 1999-04-24 11:54:40 +0000 | [diff] [blame] | 795 | return retvalue; |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 796 | } |
| 797 | |
| 798 | |
| 799 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 800 | * GetClassLong (USER.131) |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 801 | */ |
Alexandre Julliard | e6d90ea | 2001-10-09 23:27:17 +0000 | [diff] [blame] | 802 | LONG WINAPI GetClassLong16( HWND16 hwnd16, INT16 offset ) |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 803 | { |
Alexandre Julliard | e6d90ea | 2001-10-09 23:27:17 +0000 | [diff] [blame] | 804 | CLASS *class; |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 805 | LONG ret; |
Alexandre Julliard | e6d90ea | 2001-10-09 23:27:17 +0000 | [diff] [blame] | 806 | HWND hwnd = (HWND)(ULONG_PTR)hwnd16; /* no need for full handle */ |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 807 | |
Alexandre Julliard | aff7dda | 2002-11-22 21:22:14 +0000 | [diff] [blame] | 808 | TRACE("%p %d\n",hwnd, offset); |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 809 | |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 810 | switch( offset ) |
| 811 | { |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 812 | case GCL_WNDPROC: |
Alexandre Julliard | 8fd26b9 | 2001-10-15 17:56:45 +0000 | [diff] [blame] | 813 | if (!(class = get_class_ptr( hwnd, FALSE ))) return 0; |
Alexandre Julliard | bfce151 | 2003-12-10 04:08:06 +0000 | [diff] [blame] | 814 | if (class == CLASS_OTHER_PROCESS) break; |
Alexandre Julliard | e6d90ea | 2001-10-09 23:27:17 +0000 | [diff] [blame] | 815 | ret = (LONG)CLASS_GetProc( class, WIN_PROC_16 ); |
| 816 | release_class_ptr( class ); |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 817 | return ret; |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 818 | case GCL_MENUNAME: |
Alexandre Julliard | d7b7682 | 2001-12-20 00:19:40 +0000 | [diff] [blame] | 819 | if (!(class = get_class_ptr( hwnd, FALSE ))) return 0; |
Alexandre Julliard | bfce151 | 2003-12-10 04:08:06 +0000 | [diff] [blame] | 820 | if (class == CLASS_OTHER_PROCESS) break; |
Alexandre Julliard | d7b7682 | 2001-12-20 00:19:40 +0000 | [diff] [blame] | 821 | ret = (LONG)CLASS_GetMenuName16( class ); |
| 822 | release_class_ptr( class ); |
| 823 | return ret; |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 824 | default: |
Alexandre Julliard | e6d90ea | 2001-10-09 23:27:17 +0000 | [diff] [blame] | 825 | return GetClassLongA( hwnd, offset ); |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 826 | } |
Alexandre Julliard | bfce151 | 2003-12-10 04:08:06 +0000 | [diff] [blame] | 827 | FIXME( "offset %d not supported on other process window %p\n", offset, hwnd ); |
| 828 | SetLastError( ERROR_INVALID_HANDLE ); |
| 829 | return 0; |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 830 | } |
| 831 | |
| 832 | |
| 833 | /*********************************************************************** |
Stefan Leichter | 2c75672 | 2002-11-21 21:48:27 +0000 | [diff] [blame] | 834 | * GetClassLongW (USER32.@) |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 835 | */ |
Stefan Leichter | 2c75672 | 2002-11-21 21:48:27 +0000 | [diff] [blame] | 836 | LONG WINAPI GetClassLongW( HWND hwnd, INT offset ) |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 837 | { |
Alexandre Julliard | e6d90ea | 2001-10-09 23:27:17 +0000 | [diff] [blame] | 838 | CLASS *class; |
| 839 | LONG retvalue = 0; |
| 840 | |
Alexandre Julliard | aff7dda | 2002-11-22 21:22:14 +0000 | [diff] [blame] | 841 | TRACE("%p %d\n", hwnd, offset); |
Alexandre Julliard | e6d90ea | 2001-10-09 23:27:17 +0000 | [diff] [blame] | 842 | |
Alexandre Julliard | 8fd26b9 | 2001-10-15 17:56:45 +0000 | [diff] [blame] | 843 | if (!(class = get_class_ptr( hwnd, FALSE ))) return 0; |
Alexandre Julliard | e6d90ea | 2001-10-09 23:27:17 +0000 | [diff] [blame] | 844 | |
Alexandre Julliard | bfce151 | 2003-12-10 04:08:06 +0000 | [diff] [blame] | 845 | if (class == CLASS_OTHER_PROCESS) |
| 846 | { |
| 847 | SERVER_START_REQ( set_class_info ) |
| 848 | { |
| 849 | req->window = hwnd; |
| 850 | req->flags = 0; |
| 851 | req->extra_offset = (offset >= 0) ? offset : -1; |
| 852 | req->extra_size = (offset >= 0) ? sizeof(retvalue) : 0; |
| 853 | if (!wine_server_call_err( req )) |
| 854 | { |
| 855 | switch(offset) |
| 856 | { |
| 857 | case GCL_HBRBACKGROUND: |
| 858 | case GCL_HCURSOR: |
| 859 | case GCL_HICON: |
| 860 | case GCL_HICONSM: |
| 861 | case GCL_WNDPROC: |
| 862 | case GCL_MENUNAME: |
| 863 | FIXME( "offset %d not supported on other process window %p\n", offset, hwnd ); |
| 864 | SetLastError( ERROR_INVALID_HANDLE ); |
| 865 | break; |
| 866 | case GCL_STYLE: |
| 867 | retvalue = reply->old_style; |
| 868 | break; |
| 869 | case GCL_CBWNDEXTRA: |
| 870 | retvalue = reply->old_win_extra; |
| 871 | break; |
| 872 | case GCL_CBCLSEXTRA: |
| 873 | retvalue = reply->old_extra; |
| 874 | break; |
| 875 | case GCL_HMODULE: |
| 876 | retvalue = (LONG)reply->old_instance; |
| 877 | break; |
| 878 | case GCW_ATOM: |
| 879 | retvalue = reply->old_atom; |
| 880 | break; |
| 881 | default: |
| 882 | if (offset >= 0) memcpy( &retvalue, &reply->old_extra_value, sizeof(retvalue) ); |
| 883 | else SetLastError( ERROR_INVALID_INDEX ); |
| 884 | break; |
| 885 | } |
| 886 | } |
| 887 | } |
| 888 | SERVER_END_REQ; |
| 889 | return retvalue; |
| 890 | } |
| 891 | |
Alexandre Julliard | 2ace16a | 1996-04-28 15:09:19 +0000 | [diff] [blame] | 892 | if (offset >= 0) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 893 | { |
Alexandre Julliard | e6d90ea | 2001-10-09 23:27:17 +0000 | [diff] [blame] | 894 | if (offset <= class->cbClsExtra - sizeof(LONG)) |
Alexandre Julliard | 7fbd74e | 2002-05-23 02:53:10 +0000 | [diff] [blame] | 895 | memcpy( &retvalue, (char *)(class + 1) + offset, sizeof(retvalue) ); |
Alexandre Julliard | e6d90ea | 2001-10-09 23:27:17 +0000 | [diff] [blame] | 896 | else |
| 897 | SetLastError( ERROR_INVALID_INDEX ); |
| 898 | release_class_ptr( class ); |
| 899 | return retvalue; |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 900 | } |
Alexandre Julliard | d44e495 | 2001-08-20 18:09:39 +0000 | [diff] [blame] | 901 | |
Alexandre Julliard | 2ace16a | 1996-04-28 15:09:19 +0000 | [diff] [blame] | 902 | switch(offset) |
| 903 | { |
Alexandre Julliard | e6d90ea | 2001-10-09 23:27:17 +0000 | [diff] [blame] | 904 | case GCL_HBRBACKGROUND: |
| 905 | retvalue = (LONG)class->hbrBackground; |
| 906 | break; |
| 907 | case GCL_HCURSOR: |
| 908 | retvalue = (LONG)class->hCursor; |
| 909 | break; |
| 910 | case GCL_HICON: |
| 911 | retvalue = (LONG)class->hIcon; |
| 912 | break; |
| 913 | case GCL_HICONSM: |
| 914 | retvalue = (LONG)class->hIconSm; |
| 915 | break; |
| 916 | case GCL_STYLE: |
| 917 | retvalue = (LONG)class->style; |
| 918 | break; |
| 919 | case GCL_CBWNDEXTRA: |
| 920 | retvalue = (LONG)class->cbWndExtra; |
| 921 | break; |
| 922 | case GCL_CBCLSEXTRA: |
| 923 | retvalue = (LONG)class->cbClsExtra; |
| 924 | break; |
| 925 | case GCL_HMODULE: |
| 926 | retvalue = (LONG)class->hInstance; |
| 927 | break; |
| 928 | case GCL_WNDPROC: |
Stefan Leichter | 2c75672 | 2002-11-21 21:48:27 +0000 | [diff] [blame] | 929 | retvalue = (LONG)CLASS_GetProc( class, WIN_PROC_32W ); |
Alexandre Julliard | e6d90ea | 2001-10-09 23:27:17 +0000 | [diff] [blame] | 930 | break; |
| 931 | case GCL_MENUNAME: |
Stefan Leichter | 2c75672 | 2002-11-21 21:48:27 +0000 | [diff] [blame] | 932 | retvalue = (LONG)CLASS_GetMenuNameW( class ); |
Alexandre Julliard | e6d90ea | 2001-10-09 23:27:17 +0000 | [diff] [blame] | 933 | break; |
| 934 | case GCW_ATOM: |
| 935 | retvalue = (DWORD)class->atomName; |
| 936 | break; |
| 937 | default: |
| 938 | SetLastError( ERROR_INVALID_INDEX ); |
| 939 | break; |
Alexandre Julliard | 2ace16a | 1996-04-28 15:09:19 +0000 | [diff] [blame] | 940 | } |
Alexandre Julliard | e6d90ea | 2001-10-09 23:27:17 +0000 | [diff] [blame] | 941 | release_class_ptr( class ); |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 942 | return retvalue; |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 943 | } |
| 944 | |
| 945 | |
| 946 | /*********************************************************************** |
Stefan Leichter | 2c75672 | 2002-11-21 21:48:27 +0000 | [diff] [blame] | 947 | * GetClassLongA (USER32.@) |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 948 | */ |
Stefan Leichter | 2c75672 | 2002-11-21 21:48:27 +0000 | [diff] [blame] | 949 | LONG WINAPI GetClassLongA( HWND hwnd, INT offset ) |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 950 | { |
Alexandre Julliard | e6d90ea | 2001-10-09 23:27:17 +0000 | [diff] [blame] | 951 | CLASS *class; |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 952 | LONG retvalue; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 953 | |
Alexandre Julliard | e6d90ea | 2001-10-09 23:27:17 +0000 | [diff] [blame] | 954 | if (offset != GCL_WNDPROC && offset != GCL_MENUNAME) |
Stefan Leichter | 2c75672 | 2002-11-21 21:48:27 +0000 | [diff] [blame] | 955 | return GetClassLongW( hwnd, offset ); |
Alexandre Julliard | e6d90ea | 2001-10-09 23:27:17 +0000 | [diff] [blame] | 956 | |
Alexandre Julliard | aff7dda | 2002-11-22 21:22:14 +0000 | [diff] [blame] | 957 | TRACE("%p %d\n", hwnd, offset); |
Alexandre Julliard | e6d90ea | 2001-10-09 23:27:17 +0000 | [diff] [blame] | 958 | |
Alexandre Julliard | 8fd26b9 | 2001-10-15 17:56:45 +0000 | [diff] [blame] | 959 | if (!(class = get_class_ptr( hwnd, FALSE ))) return 0; |
Alexandre Julliard | e6d90ea | 2001-10-09 23:27:17 +0000 | [diff] [blame] | 960 | |
Alexandre Julliard | bfce151 | 2003-12-10 04:08:06 +0000 | [diff] [blame] | 961 | if (class == CLASS_OTHER_PROCESS) |
| 962 | { |
| 963 | FIXME( "offset %d not supported on other process window %p\n", offset, hwnd ); |
| 964 | SetLastError( ERROR_INVALID_HANDLE ); |
| 965 | return 0; |
| 966 | } |
| 967 | |
Alexandre Julliard | e6d90ea | 2001-10-09 23:27:17 +0000 | [diff] [blame] | 968 | if (offset == GCL_WNDPROC) |
Stefan Leichter | 2c75672 | 2002-11-21 21:48:27 +0000 | [diff] [blame] | 969 | retvalue = (LONG)CLASS_GetProc( class, WIN_PROC_32A ); |
Alexandre Julliard | e6d90ea | 2001-10-09 23:27:17 +0000 | [diff] [blame] | 970 | else /* GCL_MENUNAME */ |
Stefan Leichter | 2c75672 | 2002-11-21 21:48:27 +0000 | [diff] [blame] | 971 | retvalue = (LONG)CLASS_GetMenuNameA( class ); |
Alexandre Julliard | e6d90ea | 2001-10-09 23:27:17 +0000 | [diff] [blame] | 972 | |
| 973 | release_class_ptr( class ); |
| 974 | return retvalue; |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 975 | } |
| 976 | |
| 977 | |
| 978 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 979 | * SetClassWord (USER32.@) |
Alexandre Julliard | 2197901 | 1997-03-05 08:22:35 +0000 | [diff] [blame] | 980 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 981 | WORD WINAPI SetClassWord( HWND hwnd, INT offset, WORD newval ) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 982 | { |
Alexandre Julliard | e6d90ea | 2001-10-09 23:27:17 +0000 | [diff] [blame] | 983 | CLASS *class; |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 984 | WORD retval = 0; |
Alexandre Julliard | e6d90ea | 2001-10-09 23:27:17 +0000 | [diff] [blame] | 985 | |
| 986 | if (offset < 0) return SetClassLongA( hwnd, offset, (DWORD)newval ); |
| 987 | |
Alexandre Julliard | aff7dda | 2002-11-22 21:22:14 +0000 | [diff] [blame] | 988 | TRACE("%p %d %x\n", hwnd, offset, newval); |
Alexandre Julliard | e6d90ea | 2001-10-09 23:27:17 +0000 | [diff] [blame] | 989 | |
Alexandre Julliard | 8fd26b9 | 2001-10-15 17:56:45 +0000 | [diff] [blame] | 990 | if (!(class = get_class_ptr( hwnd, TRUE ))) return 0; |
Alexandre Julliard | e6d90ea | 2001-10-09 23:27:17 +0000 | [diff] [blame] | 991 | |
Alexandre Julliard | bfce151 | 2003-12-10 04:08:06 +0000 | [diff] [blame] | 992 | SERVER_START_REQ( set_class_info ) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 993 | { |
Alexandre Julliard | bfce151 | 2003-12-10 04:08:06 +0000 | [diff] [blame] | 994 | req->window = hwnd; |
| 995 | req->flags = SET_CLASS_EXTRA; |
| 996 | req->extra_offset = offset; |
| 997 | req->extra_size = sizeof(newval); |
| 998 | memcpy( &req->extra_value, &newval, sizeof(newval) ); |
| 999 | if (!wine_server_call_err( req )) |
| 1000 | { |
| 1001 | void *ptr = (char *)(class + 1) + offset; |
| 1002 | memcpy( &retval, ptr, sizeof(retval) ); |
| 1003 | memcpy( ptr, &newval, sizeof(newval) ); |
| 1004 | } |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1005 | } |
Alexandre Julliard | bfce151 | 2003-12-10 04:08:06 +0000 | [diff] [blame] | 1006 | SERVER_END_REQ; |
Alexandre Julliard | e6d90ea | 2001-10-09 23:27:17 +0000 | [diff] [blame] | 1007 | release_class_ptr( class ); |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 1008 | return retval; |
| 1009 | } |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 1010 | |
| 1011 | |
| 1012 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1013 | * SetClassLong (USER.132) |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 1014 | */ |
Alexandre Julliard | e6d90ea | 2001-10-09 23:27:17 +0000 | [diff] [blame] | 1015 | LONG WINAPI SetClassLong16( HWND16 hwnd16, INT16 offset, LONG newval ) |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 1016 | { |
Alexandre Julliard | e6d90ea | 2001-10-09 23:27:17 +0000 | [diff] [blame] | 1017 | CLASS *class; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1018 | LONG retval; |
Alexandre Julliard | e6d90ea | 2001-10-09 23:27:17 +0000 | [diff] [blame] | 1019 | HWND hwnd = (HWND)(ULONG_PTR)hwnd16; /* no need for full handle */ |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1020 | |
Alexandre Julliard | aff7dda | 2002-11-22 21:22:14 +0000 | [diff] [blame] | 1021 | TRACE("%p %d %lx\n", hwnd, offset, newval); |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 1022 | |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1023 | switch(offset) |
| 1024 | { |
| 1025 | case GCL_WNDPROC: |
Alexandre Julliard | 8fd26b9 | 2001-10-15 17:56:45 +0000 | [diff] [blame] | 1026 | if (!(class = get_class_ptr( hwnd, TRUE ))) return 0; |
Alexandre Julliard | e6d90ea | 2001-10-09 23:27:17 +0000 | [diff] [blame] | 1027 | retval = (LONG)CLASS_SetProc( class, (WNDPROC)newval, WIN_PROC_16 ); |
| 1028 | release_class_ptr( class ); |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1029 | return retval; |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1030 | case GCL_MENUNAME: |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 1031 | newval = (LONG)MapSL( newval ); |
| 1032 | /* fall through */ |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1033 | default: |
Alexandre Julliard | e6d90ea | 2001-10-09 23:27:17 +0000 | [diff] [blame] | 1034 | return SetClassLongA( hwnd, offset, newval ); |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1035 | } |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 1036 | } |
| 1037 | |
| 1038 | |
| 1039 | /*********************************************************************** |
Stefan Leichter | 2c75672 | 2002-11-21 21:48:27 +0000 | [diff] [blame] | 1040 | * SetClassLongW (USER32.@) |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 1041 | */ |
Stefan Leichter | 2c75672 | 2002-11-21 21:48:27 +0000 | [diff] [blame] | 1042 | LONG WINAPI SetClassLongW( HWND hwnd, INT offset, LONG newval ) |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 1043 | { |
Alexandre Julliard | e6d90ea | 2001-10-09 23:27:17 +0000 | [diff] [blame] | 1044 | CLASS *class; |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1045 | LONG retval = 0; |
Alexandre Julliard | e6d90ea | 2001-10-09 23:27:17 +0000 | [diff] [blame] | 1046 | |
Alexandre Julliard | aff7dda | 2002-11-22 21:22:14 +0000 | [diff] [blame] | 1047 | TRACE("%p %d %lx\n", hwnd, offset, newval); |
Alexandre Julliard | e6d90ea | 2001-10-09 23:27:17 +0000 | [diff] [blame] | 1048 | |
Alexandre Julliard | 8fd26b9 | 2001-10-15 17:56:45 +0000 | [diff] [blame] | 1049 | if (!(class = get_class_ptr( hwnd, TRUE ))) return 0; |
Alexandre Julliard | e6d90ea | 2001-10-09 23:27:17 +0000 | [diff] [blame] | 1050 | |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1051 | if (offset >= 0) |
| 1052 | { |
Alexandre Julliard | bfce151 | 2003-12-10 04:08:06 +0000 | [diff] [blame] | 1053 | if (set_server_info( hwnd, offset, newval )) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1054 | { |
Alexandre Julliard | e6d90ea | 2001-10-09 23:27:17 +0000 | [diff] [blame] | 1055 | void *ptr = (char *)(class + 1) + offset; |
Alexandre Julliard | 7fbd74e | 2002-05-23 02:53:10 +0000 | [diff] [blame] | 1056 | memcpy( &retval, ptr, sizeof(retval) ); |
| 1057 | memcpy( ptr, &newval, sizeof(newval) ); |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1058 | } |
| 1059 | } |
| 1060 | else switch(offset) |
| 1061 | { |
Alexandre Julliard | e6d90ea | 2001-10-09 23:27:17 +0000 | [diff] [blame] | 1062 | case GCL_MENUNAME: |
Stefan Leichter | 2c75672 | 2002-11-21 21:48:27 +0000 | [diff] [blame] | 1063 | CLASS_SetMenuNameW( class, (LPCWSTR)newval ); |
Alexandre Julliard | e6d90ea | 2001-10-09 23:27:17 +0000 | [diff] [blame] | 1064 | retval = 0; /* Old value is now meaningless anyway */ |
| 1065 | break; |
| 1066 | case GCL_WNDPROC: |
Stefan Leichter | 2c75672 | 2002-11-21 21:48:27 +0000 | [diff] [blame] | 1067 | retval = (LONG)CLASS_SetProc( class, (WNDPROC)newval, WIN_PROC_32W ); |
Alexandre Julliard | e6d90ea | 2001-10-09 23:27:17 +0000 | [diff] [blame] | 1068 | break; |
| 1069 | case GCL_HBRBACKGROUND: |
| 1070 | retval = (LONG)class->hbrBackground; |
Alexandre Julliard | 7ef66af | 2002-11-22 04:47:10 +0000 | [diff] [blame] | 1071 | class->hbrBackground = (HBRUSH)newval; |
Alexandre Julliard | e6d90ea | 2001-10-09 23:27:17 +0000 | [diff] [blame] | 1072 | break; |
| 1073 | case GCL_HCURSOR: |
| 1074 | retval = (LONG)class->hCursor; |
Michael Stefaniuc | bc54d78 | 2002-10-10 21:22:09 +0000 | [diff] [blame] | 1075 | class->hCursor = (HCURSOR)newval; |
Alexandre Julliard | e6d90ea | 2001-10-09 23:27:17 +0000 | [diff] [blame] | 1076 | break; |
| 1077 | case GCL_HICON: |
| 1078 | retval = (LONG)class->hIcon; |
Michael Stefaniuc | bc54d78 | 2002-10-10 21:22:09 +0000 | [diff] [blame] | 1079 | class->hIcon = (HICON)newval; |
Alexandre Julliard | e6d90ea | 2001-10-09 23:27:17 +0000 | [diff] [blame] | 1080 | break; |
| 1081 | case GCL_HICONSM: |
| 1082 | retval = (LONG)class->hIconSm; |
Michael Stefaniuc | bc54d78 | 2002-10-10 21:22:09 +0000 | [diff] [blame] | 1083 | class->hIconSm = (HICON)newval; |
Alexandre Julliard | e6d90ea | 2001-10-09 23:27:17 +0000 | [diff] [blame] | 1084 | break; |
| 1085 | case GCL_STYLE: |
Alexandre Julliard | bfce151 | 2003-12-10 04:08:06 +0000 | [diff] [blame] | 1086 | if (!set_server_info( hwnd, offset, newval )) break; |
Alexandre Julliard | e6d90ea | 2001-10-09 23:27:17 +0000 | [diff] [blame] | 1087 | retval = (LONG)class->style; |
| 1088 | class->style = newval; |
| 1089 | break; |
| 1090 | case GCL_CBWNDEXTRA: |
Alexandre Julliard | bfce151 | 2003-12-10 04:08:06 +0000 | [diff] [blame] | 1091 | if (!set_server_info( hwnd, offset, newval )) break; |
Alexandre Julliard | e6d90ea | 2001-10-09 23:27:17 +0000 | [diff] [blame] | 1092 | retval = (LONG)class->cbWndExtra; |
| 1093 | class->cbWndExtra = newval; |
| 1094 | break; |
Alexandre Julliard | e6d90ea | 2001-10-09 23:27:17 +0000 | [diff] [blame] | 1095 | case GCL_HMODULE: |
Alexandre Julliard | bfce151 | 2003-12-10 04:08:06 +0000 | [diff] [blame] | 1096 | if (!set_server_info( hwnd, offset, newval )) break; |
Alexandre Julliard | e6d90ea | 2001-10-09 23:27:17 +0000 | [diff] [blame] | 1097 | retval = (LONG)class->hInstance; |
Alexandre Julliard | 7ef66af | 2002-11-22 04:47:10 +0000 | [diff] [blame] | 1098 | class->hInstance = (HINSTANCE)newval; |
Alexandre Julliard | e6d90ea | 2001-10-09 23:27:17 +0000 | [diff] [blame] | 1099 | break; |
| 1100 | case GCW_ATOM: |
Alexandre Julliard | bfce151 | 2003-12-10 04:08:06 +0000 | [diff] [blame] | 1101 | if (!set_server_info( hwnd, offset, newval )) break; |
Alexandre Julliard | e6d90ea | 2001-10-09 23:27:17 +0000 | [diff] [blame] | 1102 | retval = (DWORD)class->atomName; |
| 1103 | class->atomName = newval; |
| 1104 | break; |
Alexandre Julliard | 8fd26b9 | 2001-10-15 17:56:45 +0000 | [diff] [blame] | 1105 | case GCL_CBCLSEXTRA: /* cannot change this one */ |
| 1106 | SetLastError( ERROR_INVALID_PARAMETER ); |
| 1107 | break; |
Alexandre Julliard | e6d90ea | 2001-10-09 23:27:17 +0000 | [diff] [blame] | 1108 | default: |
| 1109 | SetLastError( ERROR_INVALID_INDEX ); |
| 1110 | break; |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1111 | } |
Alexandre Julliard | e6d90ea | 2001-10-09 23:27:17 +0000 | [diff] [blame] | 1112 | release_class_ptr( class ); |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1113 | return retval; |
| 1114 | } |
| 1115 | |
| 1116 | |
| 1117 | /*********************************************************************** |
Stefan Leichter | 2c75672 | 2002-11-21 21:48:27 +0000 | [diff] [blame] | 1118 | * SetClassLongA (USER32.@) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1119 | */ |
Stefan Leichter | 2c75672 | 2002-11-21 21:48:27 +0000 | [diff] [blame] | 1120 | LONG WINAPI SetClassLongA( HWND hwnd, INT offset, LONG newval ) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1121 | { |
Alexandre Julliard | e6d90ea | 2001-10-09 23:27:17 +0000 | [diff] [blame] | 1122 | CLASS *class; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1123 | LONG retval; |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1124 | |
Alexandre Julliard | e6d90ea | 2001-10-09 23:27:17 +0000 | [diff] [blame] | 1125 | if (offset != GCL_WNDPROC && offset != GCL_MENUNAME) |
Stefan Leichter | 2c75672 | 2002-11-21 21:48:27 +0000 | [diff] [blame] | 1126 | return SetClassLongW( hwnd, offset, newval ); |
Alexandre Julliard | e6d90ea | 2001-10-09 23:27:17 +0000 | [diff] [blame] | 1127 | |
Alexandre Julliard | aff7dda | 2002-11-22 21:22:14 +0000 | [diff] [blame] | 1128 | TRACE("%p %d %lx\n", hwnd, offset, newval); |
Alexandre Julliard | e6d90ea | 2001-10-09 23:27:17 +0000 | [diff] [blame] | 1129 | |
Alexandre Julliard | 8fd26b9 | 2001-10-15 17:56:45 +0000 | [diff] [blame] | 1130 | if (!(class = get_class_ptr( hwnd, TRUE ))) return 0; |
Alexandre Julliard | e6d90ea | 2001-10-09 23:27:17 +0000 | [diff] [blame] | 1131 | |
| 1132 | if (offset == GCL_WNDPROC) |
Stefan Leichter | 2c75672 | 2002-11-21 21:48:27 +0000 | [diff] [blame] | 1133 | retval = (LONG)CLASS_SetProc( class, (WNDPROC)newval, WIN_PROC_32A ); |
Alexandre Julliard | e6d90ea | 2001-10-09 23:27:17 +0000 | [diff] [blame] | 1134 | else /* GCL_MENUNAME */ |
| 1135 | { |
Stefan Leichter | 2c75672 | 2002-11-21 21:48:27 +0000 | [diff] [blame] | 1136 | CLASS_SetMenuNameA( class, (LPCSTR)newval ); |
Alexandre Julliard | e6d90ea | 2001-10-09 23:27:17 +0000 | [diff] [blame] | 1137 | retval = 0; /* Old value is now meaningless anyway */ |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1138 | } |
Alexandre Julliard | e6d90ea | 2001-10-09 23:27:17 +0000 | [diff] [blame] | 1139 | release_class_ptr( class ); |
| 1140 | return retval; |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1141 | } |
| 1142 | |
| 1143 | |
| 1144 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1145 | * GetClassNameA (USER32.@) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1146 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1147 | INT WINAPI GetClassNameA( HWND hwnd, LPSTR buffer, INT count ) |
Alexandre Julliard | e6d90ea | 2001-10-09 23:27:17 +0000 | [diff] [blame] | 1148 | { |
Alexandre Julliard | 8fd26b9 | 2001-10-15 17:56:45 +0000 | [diff] [blame] | 1149 | INT ret = GlobalGetAtomNameA( GetClassLongA( hwnd, GCW_ATOM ), buffer, count ); |
Alexandre Julliard | e6d90ea | 2001-10-09 23:27:17 +0000 | [diff] [blame] | 1150 | |
Alexandre Julliard | aff7dda | 2002-11-22 21:22:14 +0000 | [diff] [blame] | 1151 | TRACE("%p %s %x\n",hwnd, debugstr_a(buffer), count); |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 1152 | return ret; |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1153 | } |
| 1154 | |
| 1155 | |
| 1156 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1157 | * GetClassNameW (USER32.@) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1158 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1159 | INT WINAPI GetClassNameW( HWND hwnd, LPWSTR buffer, INT count ) |
Alexandre Julliard | e6d90ea | 2001-10-09 23:27:17 +0000 | [diff] [blame] | 1160 | { |
Alexandre Julliard | 8fd26b9 | 2001-10-15 17:56:45 +0000 | [diff] [blame] | 1161 | INT ret = GlobalGetAtomNameW( GetClassLongW( hwnd, GCW_ATOM ), buffer, count ); |
Alexandre Julliard | e6d90ea | 2001-10-09 23:27:17 +0000 | [diff] [blame] | 1162 | |
Alexandre Julliard | aff7dda | 2002-11-22 21:22:14 +0000 | [diff] [blame] | 1163 | TRACE("%p %s %x\n",hwnd, debugstr_w(buffer), count); |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 1164 | return ret; |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1165 | } |
| 1166 | |
| 1167 | |
| 1168 | /*********************************************************************** |
Dmitry Timoshkov | 2999165 | 2003-09-27 03:47:07 +0000 | [diff] [blame] | 1169 | * RealGetWindowClassA (USER32.@) |
| 1170 | */ |
| 1171 | UINT WINAPI RealGetWindowClassA( HWND hwnd, LPSTR buffer, UINT count ) |
| 1172 | { |
| 1173 | return GetClassNameA( hwnd, buffer, count ); |
| 1174 | } |
| 1175 | |
| 1176 | |
| 1177 | /*********************************************************************** |
| 1178 | * RealGetWindowClassW (USER32.@) |
| 1179 | */ |
| 1180 | UINT WINAPI RealGetWindowClassW( HWND hwnd, LPWSTR buffer, UINT count ) |
| 1181 | { |
| 1182 | return GetClassNameW( hwnd, buffer, count ); |
| 1183 | } |
| 1184 | |
| 1185 | |
| 1186 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1187 | * GetClassInfo (USER.404) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1188 | */ |
Alexandre Julliard | a8a422f | 2002-11-22 20:43:01 +0000 | [diff] [blame] | 1189 | BOOL16 WINAPI GetClassInfo16( HINSTANCE16 hInst16, SEGPTR name, WNDCLASS16 *wc ) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1190 | { |
Alexandre Julliard | 5f32566 | 2003-12-10 01:46:52 +0000 | [diff] [blame] | 1191 | WNDCLASSEX16 wcex; |
| 1192 | UINT16 ret = GetClassInfoEx16( hInst16, name, &wcex ); |
Alexandre Julliard | 3ed37e0 | 1994-11-07 18:20:42 +0000 | [diff] [blame] | 1193 | |
Alexandre Julliard | 5f32566 | 2003-12-10 01:46:52 +0000 | [diff] [blame] | 1194 | if (ret) |
| 1195 | { |
| 1196 | wc->style = wcex.style; |
| 1197 | wc->lpfnWndProc = wcex.lpfnWndProc; |
| 1198 | wc->cbClsExtra = wcex.cbClsExtra; |
| 1199 | wc->cbWndExtra = wcex.cbWndExtra; |
| 1200 | wc->hInstance = wcex.hInstance; |
| 1201 | wc->hIcon = wcex.hIcon; |
| 1202 | wc->hCursor = wcex.hCursor; |
| 1203 | wc->hbrBackground = wcex.hbrBackground; |
| 1204 | wc->lpszMenuName = wcex.lpszMenuName; |
| 1205 | wc->lpszClassName = wcex.lpszClassName; |
| 1206 | } |
| 1207 | return ret; |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1208 | } |
| 1209 | |
| 1210 | |
| 1211 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1212 | * GetClassInfoA (USER32.@) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1213 | */ |
Alexandre Julliard | 5f32566 | 2003-12-10 01:46:52 +0000 | [diff] [blame] | 1214 | BOOL WINAPI GetClassInfoA( HINSTANCE hInstance, LPCSTR name, WNDCLASSA *wc ) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1215 | { |
Alexandre Julliard | 5f32566 | 2003-12-10 01:46:52 +0000 | [diff] [blame] | 1216 | WNDCLASSEXA wcex; |
| 1217 | UINT ret = GetClassInfoExA( hInstance, name, &wcex ); |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1218 | |
Alexandre Julliard | 5f32566 | 2003-12-10 01:46:52 +0000 | [diff] [blame] | 1219 | if (ret) |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 1220 | { |
Alexandre Julliard | 5f32566 | 2003-12-10 01:46:52 +0000 | [diff] [blame] | 1221 | wc->style = wcex.style; |
| 1222 | wc->lpfnWndProc = wcex.lpfnWndProc; |
| 1223 | wc->cbClsExtra = wcex.cbClsExtra; |
| 1224 | wc->cbWndExtra = wcex.cbWndExtra; |
| 1225 | wc->hInstance = wcex.hInstance; |
| 1226 | wc->hIcon = wcex.hIcon; |
| 1227 | wc->hCursor = wcex.hCursor; |
| 1228 | wc->hbrBackground = wcex.hbrBackground; |
| 1229 | wc->lpszMenuName = wcex.lpszMenuName; |
| 1230 | wc->lpszClassName = wcex.lpszClassName; |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 1231 | } |
Alexandre Julliard | 5f32566 | 2003-12-10 01:46:52 +0000 | [diff] [blame] | 1232 | return ret; |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1233 | } |
| 1234 | |
| 1235 | |
| 1236 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1237 | * GetClassInfoW (USER32.@) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1238 | */ |
Alexandre Julliard | 5f32566 | 2003-12-10 01:46:52 +0000 | [diff] [blame] | 1239 | BOOL WINAPI GetClassInfoW( HINSTANCE hInstance, LPCWSTR name, WNDCLASSW *wc ) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1240 | { |
Alexandre Julliard | 5f32566 | 2003-12-10 01:46:52 +0000 | [diff] [blame] | 1241 | WNDCLASSEXW wcex; |
| 1242 | UINT ret = GetClassInfoExW( hInstance, name, &wcex ); |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1243 | |
Alexandre Julliard | 5f32566 | 2003-12-10 01:46:52 +0000 | [diff] [blame] | 1244 | if (ret) |
Noomen Hamza | 1040eaf | 2000-07-09 12:21:07 +0000 | [diff] [blame] | 1245 | { |
Alexandre Julliard | 5f32566 | 2003-12-10 01:46:52 +0000 | [diff] [blame] | 1246 | wc->style = wcex.style; |
| 1247 | wc->lpfnWndProc = wcex.lpfnWndProc; |
| 1248 | wc->cbClsExtra = wcex.cbClsExtra; |
| 1249 | wc->cbWndExtra = wcex.cbWndExtra; |
| 1250 | wc->hInstance = wcex.hInstance; |
| 1251 | wc->hIcon = wcex.hIcon; |
| 1252 | wc->hCursor = wcex.hCursor; |
| 1253 | wc->hbrBackground = wcex.hbrBackground; |
| 1254 | wc->lpszMenuName = wcex.lpszMenuName; |
| 1255 | wc->lpszClassName = wcex.lpszClassName; |
Marcus Meissner | 43806217 | 1999-09-03 12:28:20 +0000 | [diff] [blame] | 1256 | } |
Alexandre Julliard | 5f32566 | 2003-12-10 01:46:52 +0000 | [diff] [blame] | 1257 | return ret; |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1258 | } |
| 1259 | |
| 1260 | |
| 1261 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1262 | * GetClassInfoEx (USER.398) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1263 | * |
| 1264 | * FIXME: this is just a guess, I have no idea if GetClassInfoEx() is the |
| 1265 | * same in Win16 as in Win32. --AJ |
| 1266 | */ |
Alexandre Julliard | a8a422f | 2002-11-22 20:43:01 +0000 | [diff] [blame] | 1267 | BOOL16 WINAPI GetClassInfoEx16( HINSTANCE16 hInst16, SEGPTR name, WNDCLASSEX16 *wc ) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1268 | { |
Alexandre Julliard | bfce151 | 2003-12-10 04:08:06 +0000 | [diff] [blame] | 1269 | ATOM atom = HIWORD(name) ? GlobalFindAtomA( MapSL(name) ) : LOWORD(name); |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1270 | CLASS *classPtr; |
Alexandre Julliard | bfce151 | 2003-12-10 04:08:06 +0000 | [diff] [blame] | 1271 | HINSTANCE hInstance; |
Alexandre Julliard | 808cb04 | 1995-08-17 17:11:36 +0000 | [diff] [blame] | 1272 | |
Alexandre Julliard | bfce151 | 2003-12-10 04:08:06 +0000 | [diff] [blame] | 1273 | if (hInst16 == GetModuleHandle16("user")) hInstance = user32_module; |
| 1274 | else hInstance = HINSTANCE_32(GetExePtr( hInst16 )); |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 1275 | |
Alexandre Julliard | bfce151 | 2003-12-10 04:08:06 +0000 | [diff] [blame] | 1276 | TRACE("%p %s %x %p\n", hInstance, debugstr_a( MapSL(name) ), atom, wc); |
| 1277 | |
| 1278 | if (!atom || !(classPtr = CLASS_FindClassByAtom( atom, hInstance ))) return FALSE; |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1279 | wc->style = classPtr->style; |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 1280 | wc->lpfnWndProc = CLASS_GetProc( classPtr, WIN_PROC_16 ); |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1281 | wc->cbClsExtra = (INT16)classPtr->cbClsExtra; |
| 1282 | wc->cbWndExtra = (INT16)classPtr->cbWndExtra; |
Alexandre Julliard | bfce151 | 2003-12-10 04:08:06 +0000 | [diff] [blame] | 1283 | wc->hInstance = (classPtr->hInstance == user32_module) ? GetModuleHandle16("user") : HINSTANCE_16(classPtr->hInstance); |
Michael Stefaniuc | bc54d78 | 2002-10-10 21:22:09 +0000 | [diff] [blame] | 1284 | wc->hIcon = HICON_16(classPtr->hIcon); |
| 1285 | wc->hIconSm = HICON_16(classPtr->hIconSm); |
| 1286 | wc->hCursor = HCURSOR_16(classPtr->hCursor); |
| 1287 | wc->hbrBackground = HBRUSH_16(classPtr->hbrBackground); |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1288 | wc->lpszClassName = (SEGPTR)0; |
Alexandre Julliard | d7b7682 | 2001-12-20 00:19:40 +0000 | [diff] [blame] | 1289 | wc->lpszMenuName = CLASS_GetMenuName16( classPtr ); |
| 1290 | wc->lpszClassName = name; |
Alexandre Julliard | bd13ab8 | 2003-12-11 05:34:53 +0000 | [diff] [blame] | 1291 | release_class_ptr( classPtr ); |
James Hatheway | 9fa09e7 | 2000-06-18 17:19:38 +0000 | [diff] [blame] | 1292 | |
| 1293 | /* We must return the atom of the class here instead of just TRUE. */ |
| 1294 | return atom; |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1295 | } |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 1296 | |
Alexandre Julliard | 1285c2f | 1996-05-06 16:06:24 +0000 | [diff] [blame] | 1297 | |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1298 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1299 | * GetClassInfoExA (USER32.@) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1300 | */ |
Alexandre Julliard | bfce151 | 2003-12-10 04:08:06 +0000 | [diff] [blame] | 1301 | BOOL WINAPI GetClassInfoExA( HINSTANCE hInstance, LPCSTR name, WNDCLASSEXA *wc ) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1302 | { |
Alexandre Julliard | bfce151 | 2003-12-10 04:08:06 +0000 | [diff] [blame] | 1303 | ATOM atom = HIWORD(name) ? GlobalFindAtomA( name ) : LOWORD(name); |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1304 | CLASS *classPtr; |
| 1305 | |
Alexandre Julliard | bfce151 | 2003-12-10 04:08:06 +0000 | [diff] [blame] | 1306 | TRACE("%p %s %x %p\n", hInstance, debugstr_a(name), atom, wc); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1307 | |
Alexandre Julliard | bfce151 | 2003-12-10 04:08:06 +0000 | [diff] [blame] | 1308 | if (!hInstance) hInstance = user32_module; |
| 1309 | |
| 1310 | if (!atom || !(classPtr = CLASS_FindClassByAtom( atom, hInstance ))) |
| 1311 | { |
| 1312 | SetLastError( ERROR_CLASS_DOES_NOT_EXIST ); |
| 1313 | return FALSE; |
| 1314 | } |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1315 | wc->style = classPtr->style; |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 1316 | wc->lpfnWndProc = (WNDPROC)CLASS_GetProc( classPtr, WIN_PROC_32A ); |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1317 | wc->cbClsExtra = classPtr->cbClsExtra; |
| 1318 | wc->cbWndExtra = classPtr->cbWndExtra; |
Alexandre Julliard | bfce151 | 2003-12-10 04:08:06 +0000 | [diff] [blame] | 1319 | wc->hInstance = (hInstance == user32_module) ? 0 : hInstance; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1320 | wc->hIcon = (HICON)classPtr->hIcon; |
| 1321 | wc->hIconSm = (HICON)classPtr->hIconSm; |
| 1322 | wc->hCursor = (HCURSOR)classPtr->hCursor; |
| 1323 | wc->hbrBackground = (HBRUSH)classPtr->hbrBackground; |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1324 | wc->lpszMenuName = CLASS_GetMenuNameA( classPtr ); |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 1325 | wc->lpszClassName = name; |
Alexandre Julliard | bd13ab8 | 2003-12-11 05:34:53 +0000 | [diff] [blame] | 1326 | release_class_ptr( classPtr ); |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 1327 | |
James Hatheway | 9fa09e7 | 2000-06-18 17:19:38 +0000 | [diff] [blame] | 1328 | /* We must return the atom of the class here instead of just TRUE. */ |
| 1329 | return atom; |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1330 | } |
| 1331 | |
| 1332 | |
| 1333 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1334 | * GetClassInfoExW (USER32.@) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1335 | */ |
Alexandre Julliard | bfce151 | 2003-12-10 04:08:06 +0000 | [diff] [blame] | 1336 | BOOL WINAPI GetClassInfoExW( HINSTANCE hInstance, LPCWSTR name, WNDCLASSEXW *wc ) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1337 | { |
Alexandre Julliard | bfce151 | 2003-12-10 04:08:06 +0000 | [diff] [blame] | 1338 | ATOM atom = HIWORD(name) ? GlobalFindAtomW( name ) : LOWORD(name); |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1339 | CLASS *classPtr; |
| 1340 | |
Alexandre Julliard | bfce151 | 2003-12-10 04:08:06 +0000 | [diff] [blame] | 1341 | TRACE("%p %s %x %p\n", hInstance, debugstr_w(name), atom, wc); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1342 | |
Alexandre Julliard | bfce151 | 2003-12-10 04:08:06 +0000 | [diff] [blame] | 1343 | if (!hInstance) hInstance = user32_module; |
| 1344 | |
| 1345 | if (!atom || !(classPtr = CLASS_FindClassByAtom( atom, hInstance ))) |
| 1346 | { |
| 1347 | SetLastError( ERROR_CLASS_DOES_NOT_EXIST ); |
| 1348 | return FALSE; |
| 1349 | } |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1350 | wc->style = classPtr->style; |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 1351 | wc->lpfnWndProc = (WNDPROC)CLASS_GetProc( classPtr, WIN_PROC_32W ); |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1352 | wc->cbClsExtra = classPtr->cbClsExtra; |
| 1353 | wc->cbWndExtra = classPtr->cbWndExtra; |
Alexandre Julliard | bfce151 | 2003-12-10 04:08:06 +0000 | [diff] [blame] | 1354 | wc->hInstance = (hInstance == user32_module) ? 0 : hInstance; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1355 | wc->hIcon = (HICON)classPtr->hIcon; |
| 1356 | wc->hIconSm = (HICON)classPtr->hIconSm; |
| 1357 | wc->hCursor = (HCURSOR)classPtr->hCursor; |
| 1358 | wc->hbrBackground = (HBRUSH)classPtr->hbrBackground; |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1359 | wc->lpszMenuName = CLASS_GetMenuNameW( classPtr ); |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 1360 | wc->lpszClassName = name; |
Alexandre Julliard | bd13ab8 | 2003-12-11 05:34:53 +0000 | [diff] [blame] | 1361 | release_class_ptr( classPtr ); |
Alexandre Julliard | 9877906 | 2000-12-07 23:39:16 +0000 | [diff] [blame] | 1362 | |
James Hatheway | 9fa09e7 | 2000-06-18 17:19:38 +0000 | [diff] [blame] | 1363 | /* We must return the atom of the class here instead of just TRUE. */ |
| 1364 | return atom; |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 1365 | } |
Alexandre Julliard | e2abbb1 | 1995-03-19 17:39:39 +0000 | [diff] [blame] | 1366 | |
| 1367 | |
Alexandre Julliard | f899ef0 | 2001-07-23 00:04:00 +0000 | [diff] [blame] | 1368 | #if 0 /* toolhelp is in kernel, so this cannot work */ |
| 1369 | |
Alexandre Julliard | e2abbb1 | 1995-03-19 17:39:39 +0000 | [diff] [blame] | 1370 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1371 | * ClassFirst (TOOLHELP.69) |
Alexandre Julliard | e2abbb1 | 1995-03-19 17:39:39 +0000 | [diff] [blame] | 1372 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1373 | BOOL16 WINAPI ClassFirst16( CLASSENTRY *pClassEntry ) |
Alexandre Julliard | e2abbb1 | 1995-03-19 17:39:39 +0000 | [diff] [blame] | 1374 | { |
Alexandre Julliard | 359f497e | 1999-07-04 16:02:24 +0000 | [diff] [blame] | 1375 | TRACE("%p\n",pClassEntry); |
Alexandre Julliard | 2ace16a | 1996-04-28 15:09:19 +0000 | [diff] [blame] | 1376 | pClassEntry->wNext = 1; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1377 | return ClassNext16( pClassEntry ); |
Alexandre Julliard | e2abbb1 | 1995-03-19 17:39:39 +0000 | [diff] [blame] | 1378 | } |
| 1379 | |
| 1380 | |
| 1381 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1382 | * ClassNext (TOOLHELP.70) |
Alexandre Julliard | e2abbb1 | 1995-03-19 17:39:39 +0000 | [diff] [blame] | 1383 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1384 | BOOL16 WINAPI ClassNext16( CLASSENTRY *pClassEntry ) |
Alexandre Julliard | e2abbb1 | 1995-03-19 17:39:39 +0000 | [diff] [blame] | 1385 | { |
Alexandre Julliard | 2ace16a | 1996-04-28 15:09:19 +0000 | [diff] [blame] | 1386 | int i; |
| 1387 | CLASS *class = firstClass; |
Alexandre Julliard | e2abbb1 | 1995-03-19 17:39:39 +0000 | [diff] [blame] | 1388 | |
Alexandre Julliard | 359f497e | 1999-07-04 16:02:24 +0000 | [diff] [blame] | 1389 | TRACE("%p\n",pClassEntry); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1390 | |
Alexandre Julliard | 2ace16a | 1996-04-28 15:09:19 +0000 | [diff] [blame] | 1391 | if (!pClassEntry->wNext) return FALSE; |
| 1392 | for (i = 1; (i < pClassEntry->wNext) && class; i++) class = class->next; |
| 1393 | if (!class) |
| 1394 | { |
| 1395 | pClassEntry->wNext = 0; |
| 1396 | return FALSE; |
| 1397 | } |
Alexandre Julliard | 1285c2f | 1996-05-06 16:06:24 +0000 | [diff] [blame] | 1398 | pClassEntry->hInst = class->hInstance; |
Alexandre Julliard | 2ace16a | 1996-04-28 15:09:19 +0000 | [diff] [blame] | 1399 | pClassEntry->wNext++; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1400 | GlobalGetAtomNameA( class->atomName, pClassEntry->szClassName, |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1401 | sizeof(pClassEntry->szClassName) ); |
Alexandre Julliard | e2abbb1 | 1995-03-19 17:39:39 +0000 | [diff] [blame] | 1402 | return TRUE; |
| 1403 | } |
Alexandre Julliard | f899ef0 | 2001-07-23 00:04:00 +0000 | [diff] [blame] | 1404 | #endif |