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