blob: 3ae47f4c0110313e146fd1a81c442a3f2a67dca9 [file] [log] [blame]
Alexandre Julliard401710d1993-09-04 10:09:32 +00001/*
2 * Window classes functions
3 *
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00004 * Copyright 1993, 1996 Alexandre Julliard
Alexandre Julliard767e6f61998-08-09 12:47:43 +00005 * 1998 Juergen Schmied (jsch)
Alexandre Julliard21979011997-03-05 08:22:35 +00006 *
Alexandre Julliard0799c1a2002-03-09 23:29:33 +00007 * 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 *
Vincent Béron9a624912002-05-31 23:06:46 +000021 * FIXME: In win32 all classes are local. They are registered at
Alexandre Julliard21979011997-03-05 08:22:35 +000022 * program start. Processes CANNOT share classes. (Source: some
23 * win31->NT migration book)
Alexandre Julliard767e6f61998-08-09 12:47:43 +000024 *
25 * FIXME: There seems to be a general problem with hInstance in WINE
Andreas Mohr1af53cb2000-12-09 03:15:32 +000026 * classes are getting registered with wrong hInstance.
Alexandre Julliardbd34d4f1995-06-20 19:08:12 +000027 */
Alexandre Julliard401710d1993-09-04 10:09:32 +000028
François Gouget14259412001-11-06 20:57:11 +000029#include "config.h"
Francois Gouget386cf6e2001-10-14 16:25:47 +000030#include "wine/port.h"
31
Alexandre Julliard8d24ae61994-04-05 21:42:43 +000032#include <stdlib.h>
Alexandre Julliard8d24ae61994-04-05 21:42:43 +000033#include <string.h>
Francois Gouget386cf6e2001-10-14 16:25:47 +000034
Marcus Meissner317af321999-02-17 13:51:06 +000035#include "wine/winbase16.h"
Alexandre Julliardc7e7df82000-08-14 14:41:19 +000036#include "winerror.h"
37#include "windef.h"
38#include "wingdi.h"
39#include "wine/winuser16.h"
Alexandre Julliard0ca051e2002-10-17 16:43:42 +000040#include "wownt32.h"
Alexandre Julliardc7e7df82000-08-14 14:41:19 +000041#include "wine/unicode.h"
Alexandre Julliard401710d1993-09-04 10:09:32 +000042#include "win.h"
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +000043#include "user.h"
Alexandre Julliard91222da2000-12-10 23:01:33 +000044#include "controls.h"
Alexandre Julliard5f721f81994-01-04 20:14:34 +000045#include "dce.h"
Alexandre Julliard2d93d001996-05-21 15:01:41 +000046#include "winproc.h"
Alexandre Julliard0799c1a2002-03-09 23:29:33 +000047#include "wine/debug.h"
Alexandre Julliard8d24ae61994-04-05 21:42:43 +000048
Alexandre Julliard0799c1a2002-03-09 23:29:33 +000049WINE_DEFAULT_DEBUG_CHANNEL(class);
Patrik Stridvallb4b9fae1999-04-19 14:56:29 +000050
Alexandre Julliard98779062000-12-07 23:39:16 +000051typedef struct tagCLASS
52{
53 struct tagCLASS *next; /* Next class */
54 struct tagCLASS *prev; /* Prev class */
55 UINT cWindows; /* Count of existing windows */
56 UINT style; /* Class style */
Alexandre Julliard18d02972002-12-03 23:34:52 +000057 WNDPROC winprocA; /* Window procedure (ASCII) */
58 WNDPROC winprocW; /* Window procedure (Unicode) */
Alexandre Julliard98779062000-12-07 23:39:16 +000059 INT cbClsExtra; /* Class extra bytes */
60 INT cbWndExtra; /* Window extra bytes */
61 LPWSTR menuName; /* Default menu name (Unicode followed by ASCII) */
Alexandre Julliardd7b76822001-12-20 00:19:40 +000062 SEGPTR segMenuName; /* Default menu name as SEGPTR */
Alexandre Julliard98779062000-12-07 23:39:16 +000063 struct tagDCE *dce; /* Class DCE (if CS_CLASSDC) */
64 HINSTANCE hInstance; /* Module that created the task */
65 HICON hIcon; /* Default icon */
66 HICON hIconSm; /* Default small icon */
67 HCURSOR hCursor; /* Default cursor */
68 HBRUSH hbrBackground; /* Default background */
69 ATOM atomName; /* Name of the class */
Alexandre Julliard98779062000-12-07 23:39:16 +000070} CLASS;
Alexandre Julliard401710d1993-09-04 10:09:32 +000071
Alexandre Julliard98779062000-12-07 23:39:16 +000072static CLASS *firstClass;
Alexandre Julliard401710d1993-09-04 10:09:32 +000073
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +000074/***********************************************************************
75 * get_class_ptr
76 */
Alexandre Julliard8fd26b92001-10-15 17:56:45 +000077static CLASS *get_class_ptr( HWND hwnd, BOOL write_access )
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +000078{
Alexandre Julliard8fd26b92001-10-15 17:56:45 +000079 WND *ptr = WIN_GetPtr( hwnd );
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +000080
Alexandre Julliard8fd26b92001-10-15 17:56:45 +000081 if (ptr)
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +000082 {
Alexandre Julliard8fd26b92001-10-15 17:56:45 +000083 if (ptr != WND_OTHER_PROCESS) return ptr->class;
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +000084 if (IsWindow( hwnd )) /* check other processes */
85 {
Alexandre Julliard8fd26b92001-10-15 17:56:45 +000086 if (write_access)
87 {
88 /* modifying classes in other processes is not allowed */
89 SetLastError( ERROR_ACCESS_DENIED );
90 return NULL;
91 }
Alexandre Julliardaff7dda2002-11-22 21:22:14 +000092 FIXME( "reading from class of other process window %p\n", hwnd );
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +000093 /* DbgBreakPoint(); */
94 }
95 }
Alexandre Julliard8fd26b92001-10-15 17:56:45 +000096 SetLastError( ERROR_INVALID_WINDOW_HANDLE );
97 return NULL;
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +000098}
99
100
101/***********************************************************************
102 * release_class_ptr
103 */
104inline static void release_class_ptr( CLASS *ptr )
105{
106 USER_Unlock();
107}
108
Alexandre Julliard401710d1993-09-04 10:09:32 +0000109
110/***********************************************************************
Alexandre Julliard98779062000-12-07 23:39:16 +0000111 * CLASS_GetProc
Alexandre Julliardb817f4f1996-03-14 18:08:34 +0000112 *
Alexandre Julliard98779062000-12-07 23:39:16 +0000113 * Get the class winproc for a given proc type
Alexandre Julliardb817f4f1996-03-14 18:08:34 +0000114 */
Alexandre Julliard98779062000-12-07 23:39:16 +0000115static WNDPROC16 CLASS_GetProc( CLASS *classPtr, WINDOWPROCTYPE type )
Alexandre Julliardb817f4f1996-03-14 18:08:34 +0000116{
Alexandre Julliard18d02972002-12-03 23:34:52 +0000117 WNDPROC proc = classPtr->winprocA;
Alexandre Julliardb817f4f1996-03-14 18:08:34 +0000118
Alexandre Julliard98779062000-12-07 23:39:16 +0000119 if (classPtr->winprocW)
Alexandre Julliardb817f4f1996-03-14 18:08:34 +0000120 {
Alexandre Julliard98779062000-12-07 23:39:16 +0000121 /* if we have a Unicode proc, use it if we have no ASCII proc
122 * or if we have both and Unicode was requested
123 */
124 if (!proc || type == WIN_PROC_32W) proc = classPtr->winprocW;
Alexandre Julliardb817f4f1996-03-14 18:08:34 +0000125 }
Alexandre Julliard98779062000-12-07 23:39:16 +0000126 return WINPROC_GetProc( proc, type );
Alexandre Julliardb817f4f1996-03-14 18:08:34 +0000127}
128
129
130/***********************************************************************
Alexandre Julliard98779062000-12-07 23:39:16 +0000131 * CLASS_SetProc
Alexandre Julliardb817f4f1996-03-14 18:08:34 +0000132 *
Alexandre Julliard98779062000-12-07 23:39:16 +0000133 * Set the class winproc for a given proc type.
134 * Returns the previous window proc.
Alexandre Julliardb817f4f1996-03-14 18:08:34 +0000135 */
Alexandre Julliard98779062000-12-07 23:39:16 +0000136static WNDPROC16 CLASS_SetProc( CLASS *classPtr, WNDPROC newproc, WINDOWPROCTYPE type )
Alexandre Julliardb817f4f1996-03-14 18:08:34 +0000137{
Alexandre Julliard18d02972002-12-03 23:34:52 +0000138 WNDPROC *proc = &classPtr->winprocA;
Alexandre Julliard98779062000-12-07 23:39:16 +0000139 WNDPROC16 ret;
Alexandre Julliardb817f4f1996-03-14 18:08:34 +0000140
Alexandre Julliard98779062000-12-07 23:39:16 +0000141 if (classPtr->winprocW)
Alexandre Julliardb817f4f1996-03-14 18:08:34 +0000142 {
Alexandre Julliard98779062000-12-07 23:39:16 +0000143 /* if we have a Unicode proc, use it if we have no ASCII proc
144 * or if we have both and Unicode was requested
145 */
146 if (!*proc || type == WIN_PROC_32W) proc = &classPtr->winprocW;
Alexandre Julliardb817f4f1996-03-14 18:08:34 +0000147 }
Alexandre Julliard98779062000-12-07 23:39:16 +0000148 ret = WINPROC_GetProc( *proc, type );
Alexandre Julliard18d02972002-12-03 23:34:52 +0000149 WINPROC_SetProc( proc, newproc, type, WIN_PROC_CLASS );
Alexandre Julliard98779062000-12-07 23:39:16 +0000150 /* now free the one that we didn't set */
151 if (classPtr->winprocA && classPtr->winprocW)
152 {
153 if (proc == &classPtr->winprocA)
154 {
155 WINPROC_FreeProc( classPtr->winprocW, WIN_PROC_CLASS );
156 classPtr->winprocW = 0;
157 }
158 else
159 {
160 WINPROC_FreeProc( classPtr->winprocA, WIN_PROC_CLASS );
161 classPtr->winprocA = 0;
162 }
163 }
164 return ret;
Alexandre Julliardb817f4f1996-03-14 18:08:34 +0000165}
166
167
168/***********************************************************************
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000169 * CLASS_GetMenuNameA
170 *
171 * Get the menu name as a ASCII string.
172 */
Alexandre Julliard98779062000-12-07 23:39:16 +0000173inline static LPSTR CLASS_GetMenuNameA( CLASS *classPtr )
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000174{
Alexandre Julliard98779062000-12-07 23:39:16 +0000175 if (!HIWORD(classPtr->menuName)) return (LPSTR)classPtr->menuName;
176 return (LPSTR)(classPtr->menuName + strlenW(classPtr->menuName) + 1);
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000177}
178
179
180/***********************************************************************
Alexandre Julliardd7b76822001-12-20 00:19:40 +0000181 * CLASS_GetMenuName16
182 *
183 * Get the menu name as a SEGPTR.
184 */
185inline static SEGPTR CLASS_GetMenuName16( CLASS *classPtr )
186{
187 if (!HIWORD(classPtr->menuName)) return (SEGPTR)classPtr->menuName;
188 if (!classPtr->segMenuName)
189 classPtr->segMenuName = MapLS( CLASS_GetMenuNameA(classPtr) );
190 return classPtr->segMenuName;
191}
192
193
194/***********************************************************************
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000195 * CLASS_GetMenuNameW
196 *
197 * Get the menu name as a Unicode string.
198 */
Alexandre Julliard98779062000-12-07 23:39:16 +0000199inline static LPWSTR CLASS_GetMenuNameW( CLASS *classPtr )
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000200{
Alexandre Julliard98779062000-12-07 23:39:16 +0000201 return classPtr->menuName;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000202}
203
204
205/***********************************************************************
206 * CLASS_SetMenuNameA
207 *
208 * Set the menu name in a class structure by copying the string.
209 */
210static void CLASS_SetMenuNameA( CLASS *classPtr, LPCSTR name )
211{
Alexandre Julliardd7b76822001-12-20 00:19:40 +0000212 UnMapLS( classPtr->segMenuName );
213 classPtr->segMenuName = 0;
214 if (HIWORD(classPtr->menuName)) HeapFree( GetProcessHeap(), 0, classPtr->menuName );
Alexandre Julliard98779062000-12-07 23:39:16 +0000215 if (HIWORD(name))
216 {
217 DWORD lenA = strlen(name) + 1;
218 DWORD lenW = MultiByteToWideChar( CP_ACP, 0, name, lenA, NULL, 0 );
Alexandre Julliardd7b76822001-12-20 00:19:40 +0000219 classPtr->menuName = HeapAlloc( GetProcessHeap(), 0, lenA + lenW*sizeof(WCHAR) );
Alexandre Julliard98779062000-12-07 23:39:16 +0000220 MultiByteToWideChar( CP_ACP, 0, name, lenA, classPtr->menuName, lenW );
221 memcpy( classPtr->menuName + lenW, name, lenA );
222 }
223 else classPtr->menuName = (LPWSTR)name;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000224}
225
226
227/***********************************************************************
228 * CLASS_SetMenuNameW
229 *
230 * Set the menu name in a class structure by copying the string.
231 */
232static void CLASS_SetMenuNameW( CLASS *classPtr, LPCWSTR name )
233{
Alexandre Julliardd7b76822001-12-20 00:19:40 +0000234 UnMapLS( classPtr->segMenuName );
235 classPtr->segMenuName = 0;
236 if (HIWORD(classPtr->menuName)) HeapFree( GetProcessHeap(), 0, classPtr->menuName );
Alexandre Julliard98779062000-12-07 23:39:16 +0000237 if (HIWORD(name))
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000238 {
Alexandre Julliard98779062000-12-07 23:39:16 +0000239 DWORD lenW = strlenW(name) + 1;
240 DWORD lenA = WideCharToMultiByte( CP_ACP, 0, name, lenW, NULL, 0, NULL, NULL );
Alexandre Julliardd7b76822001-12-20 00:19:40 +0000241 classPtr->menuName = HeapAlloc( GetProcessHeap(), 0, lenA + lenW*sizeof(WCHAR) );
Alexandre Julliard98779062000-12-07 23:39:16 +0000242 memcpy( classPtr->menuName, name, lenW*sizeof(WCHAR) );
243 WideCharToMultiByte( CP_ACP, 0, name, lenW,
244 (char *)(classPtr->menuName + lenW), lenA, NULL, NULL );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000245 }
Alexandre Julliard98779062000-12-07 23:39:16 +0000246 else classPtr->menuName = (LPWSTR)name;
Gavriel Statec77c5921998-11-15 09:21:17 +0000247}
248
249
250/***********************************************************************
Alexandre Julliard2ace16a1996-04-28 15:09:19 +0000251 * CLASS_FreeClass
252 *
253 * Free a class structure.
254 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000255static BOOL CLASS_FreeClass( CLASS *classPtr )
Alexandre Julliard2ace16a1996-04-28 15:09:19 +0000256{
Alexandre Julliard98779062000-12-07 23:39:16 +0000257 TRACE("%p\n", classPtr);
Alexandre Julliard2ace16a1996-04-28 15:09:19 +0000258
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000259 /* Check if we can remove this class */
260
Alexandre Julliard98779062000-12-07 23:39:16 +0000261 if (classPtr->cWindows > 0)
262 {
263 SetLastError( ERROR_CLASS_HAS_WINDOWS );
264 return FALSE;
265 }
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000266
Alexandre Julliard2ace16a1996-04-28 15:09:19 +0000267 /* Remove the class from the linked list */
268
Alexandre Julliard98779062000-12-07 23:39:16 +0000269 if (classPtr->next) classPtr->next->prev = classPtr->prev;
270 if (classPtr->prev) classPtr->prev->next = classPtr->next;
271 else firstClass = classPtr->next;
Alexandre Julliard2ace16a1996-04-28 15:09:19 +0000272
273 /* Delete the class */
274
Alexandre Julliard2c69f6d1996-09-28 18:11:01 +0000275 if (classPtr->dce) DCE_FreeDCE( classPtr->dce );
Huw D M Davies2f245af2000-09-12 23:38:33 +0000276 if (classPtr->hbrBackground > (HBRUSH)(COLOR_GRADIENTINACTIVECAPTION + 1))
277 DeleteObject( classPtr->hbrBackground );
Alexandre Julliard2ace16a1996-04-28 15:09:19 +0000278 GlobalDeleteAtom( classPtr->atomName );
Alexandre Julliard98779062000-12-07 23:39:16 +0000279 WINPROC_FreeProc( classPtr->winprocA, WIN_PROC_CLASS );
280 WINPROC_FreeProc( classPtr->winprocW, WIN_PROC_CLASS );
Alexandre Julliardd7b76822001-12-20 00:19:40 +0000281 UnMapLS( classPtr->segMenuName );
Alexandre Julliard98779062000-12-07 23:39:16 +0000282 HeapFree( GetProcessHeap(), 0, classPtr->menuName );
283 HeapFree( GetProcessHeap(), 0, classPtr );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000284 return TRUE;
Alexandre Julliard2ace16a1996-04-28 15:09:19 +0000285}
286
287
288/***********************************************************************
289 * CLASS_FreeModuleClasses
290 */
Alexandre Julliard3051b641996-07-05 17:14:13 +0000291void CLASS_FreeModuleClasses( HMODULE16 hModule )
Alexandre Julliard2ace16a1996-04-28 15:09:19 +0000292{
293 CLASS *ptr, *next;
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000294
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000295 TRACE("0x%08x\n", hModule);
296
297 USER_Lock();
Alexandre Julliard2ace16a1996-04-28 15:09:19 +0000298 for (ptr = firstClass; ptr; ptr = next)
299 {
300 next = ptr->next;
Alexandre Julliarda8a422f2002-11-22 20:43:01 +0000301 if (ptr->hInstance == HINSTANCE_32(hModule)) CLASS_FreeClass( ptr );
Alexandre Julliard2ace16a1996-04-28 15:09:19 +0000302 }
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000303 USER_Unlock();
Alexandre Julliard2ace16a1996-04-28 15:09:19 +0000304}
305
306
307/***********************************************************************
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000308 * CLASS_FindClassByAtom
309 *
310 * Return a pointer to the class.
Alexandre Julliard77b99181997-09-14 17:17:23 +0000311 * hinstance has been normalized by the caller.
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000312 *
313 * NOTES
314 * 980805 a local class will be found now if registred with hInst=0
315 * and looed up with a hInst!=0. msmoney does it (jsch)
Vincent Béron9a624912002-05-31 23:06:46 +0000316 *
317 * Local class registered with a USER instance handle are found as if
Joshua Thielend9ed57a2001-11-16 18:11:43 +0000318 * they were global classes.
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000319 */
Alexandre Julliard98779062000-12-07 23:39:16 +0000320static CLASS *CLASS_FindClassByAtom( ATOM atom, HINSTANCE hinstance )
321{
Joshua Thielend9ed57a2001-11-16 18:11:43 +0000322 CLASS * class, *tclass = 0, *user_class = 0;
323 HINSTANCE16 hUser = GetModuleHandle16("USER");
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000324
Alexandre Julliardaff7dda2002-11-22 21:22:14 +0000325 TRACE("0x%08x %p\n", atom, hinstance);
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000326
Alexandre Julliard77b99181997-09-14 17:17:23 +0000327 /* First search task-specific classes */
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000328
329 for (class = firstClass; (class); class = class->next)
330 {
331 if (class->style & CS_GLOBALCLASS) continue;
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000332 if (class->atomName == atom)
333 {
Alexandre Julliarda8a422f2002-11-22 20:43:01 +0000334 if (hinstance==class->hInstance || hinstance == (HINSTANCE)0xffff)
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000335 {
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000336 TRACE("-- found local %p\n", class);
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000337 return class;
338 }
Joshua Thielend9ed57a2001-11-16 18:11:43 +0000339 if (class->hInstance == 0) tclass = class;
Alexandre Julliarda8a422f2002-11-22 20:43:01 +0000340 else if(class->hInstance == HINSTANCE_32(hUser))
Joshua Thielend9ed57a2001-11-16 18:11:43 +0000341 {
342 user_class = class;
343 }
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000344 }
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000345 }
Vincent Béron9a624912002-05-31 23:06:46 +0000346
Joshua Thielend9ed57a2001-11-16 18:11:43 +0000347 /* Then search global classes */
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000348
349 for (class = firstClass; (class); class = class->next)
350 {
351 if (!(class->style & CS_GLOBALCLASS)) continue;
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000352 if (class->atomName == atom)
353 {
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000354 TRACE("-- found global %p\n", class);
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000355 return class;
356 }
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000357 }
358
Joshua Thielend9ed57a2001-11-16 18:11:43 +0000359 /* Check if there was a local class registered with USER */
360 if( user_class )
361 {
362 TRACE("--found local USER class %p\n", user_class);
363 return user_class;
364 }
365
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000366 /* Then check if there was a local class with hInst=0*/
367 if ( tclass )
368 {
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000369 WARN("-- found local Class registred with hInst=0\n");
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000370 return tclass;
371 }
Vincent Béron9a624912002-05-31 23:06:46 +0000372
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000373 TRACE("-- not found\n");
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000374 return 0;
375}
376
377
378/***********************************************************************
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000379 * CLASS_RegisterClass
380 *
381 * The real RegisterClass() functionality.
382 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000383static CLASS *CLASS_RegisterClass( ATOM atom, HINSTANCE hInstance,
Alexandre Julliard98779062000-12-07 23:39:16 +0000384 DWORD style, INT classExtra, INT winExtra )
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000385{
386 CLASS *classPtr;
387
Alexandre Julliardaff7dda2002-11-22 21:22:14 +0000388 TRACE("atom=0x%x hinst=%p style=0x%lx clExtr=0x%x winExtr=0x%x\n",
Alexandre Julliard98779062000-12-07 23:39:16 +0000389 atom, hInstance, style, classExtra, winExtra );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000390
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000391 /* Check if a class with this name already exists */
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000392 classPtr = CLASS_FindClassByAtom( atom, hInstance );
393 if (classPtr)
394 {
395 /* Class can be created only if it is local and */
396 /* if the class with the same name is global. */
397
Alexandre Julliard98779062000-12-07 23:39:16 +0000398 if ((style & CS_GLOBALCLASS) || !(classPtr->style & CS_GLOBALCLASS))
399 {
400 SetLastError( ERROR_CLASS_ALREADY_EXISTS );
401 return NULL;
402 }
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000403 }
404
405 /* Fix the extra bytes value */
406
407 if (classExtra < 0) classExtra = 0;
408 else if (classExtra > 40) /* Extra bytes are limited to 40 in Win32 */
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000409 WARN("Class extra bytes %d is > 40\n", classExtra);
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000410 if (winExtra < 0) winExtra = 0;
411 else if (winExtra > 40) /* Extra bytes are limited to 40 in Win32 */
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000412 WARN("Win extra bytes %d is > 40\n", winExtra );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000413
414 /* Create the class */
415
Alexandre Julliardd44e4952001-08-20 18:09:39 +0000416 classPtr = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(CLASS) + classExtra );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000417 if (!classPtr) return NULL;
Alexandre Julliard2d93d001996-05-21 15:01:41 +0000418 classPtr->style = style;
Alexandre Julliard2d93d001996-05-21 15:01:41 +0000419 classPtr->cbWndExtra = winExtra;
420 classPtr->cbClsExtra = classExtra;
421 classPtr->hInstance = hInstance;
422 classPtr->atomName = atom;
Alexandre Julliard98779062000-12-07 23:39:16 +0000423 classPtr->dce = (style & CS_CLASSDC) ? DCE_AllocDCE( 0, DCE_CLASS_DC ) : NULL;
Alexandre Julliard2c69f6d1996-09-28 18:11:01 +0000424
Alexandre Julliard98779062000-12-07 23:39:16 +0000425 /* Other non-null values must be set by caller */
Alexandre Julliard3051b641996-07-05 17:14:13 +0000426
Alexandre Julliard98779062000-12-07 23:39:16 +0000427 if ((classPtr->next = firstClass)) firstClass->prev = classPtr;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000428 firstClass = classPtr;
429 return classPtr;
430}
431
432
433/***********************************************************************
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000434 * CLASS_UnregisterClass
435 *
436 * The real UnregisterClass() functionality.
437 */
438static BOOL CLASS_UnregisterClass( ATOM atom, HINSTANCE hInstance )
439{
440 CLASS *classPtr;
441 BOOL ret = FALSE;
442
443 USER_Lock();
444 if (atom &&
445 (classPtr = CLASS_FindClassByAtom( atom, hInstance )) &&
Bill Medland0ca07c92001-11-20 18:53:16 +0000446 (!hInstance || classPtr->hInstance == hInstance))
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000447 {
448 ret = CLASS_FreeClass( classPtr );
449 }
450 else SetLastError( ERROR_CLASS_DOES_NOT_EXIST );
451
452 USER_Unlock();
453 return ret;
454}
455
456
457/***********************************************************************
Alexandre Julliard98779062000-12-07 23:39:16 +0000458 * CLASS_RegisterBuiltinClass
459 *
460 * Register a builtin control class.
461 * This allows having both ASCII and Unicode winprocs for the same class.
462 */
Alexandre Julliard91222da2000-12-10 23:01:33 +0000463ATOM CLASS_RegisterBuiltinClass( const struct builtin_class_descr *descr )
Alexandre Julliard98779062000-12-07 23:39:16 +0000464{
465 ATOM atom;
466 CLASS *classPtr;
467
Alexandre Julliard91222da2000-12-10 23:01:33 +0000468 if (!(atom = GlobalAddAtomA( descr->name ))) return 0;
Alexandre Julliard98779062000-12-07 23:39:16 +0000469
Alexandre Julliard91222da2000-12-10 23:01:33 +0000470 if (!(classPtr = CLASS_RegisterClass( atom, 0, descr->style, 0, descr->extra )))
Alexandre Julliard98779062000-12-07 23:39:16 +0000471 {
472 GlobalDeleteAtom( atom );
473 return 0;
474 }
475
Alexandre Julliard91222da2000-12-10 23:01:33 +0000476 classPtr->hCursor = LoadCursorA( 0, descr->cursor );
477 classPtr->hbrBackground = descr->brush;
Alexandre Julliard98779062000-12-07 23:39:16 +0000478
Alexandre Julliard18d02972002-12-03 23:34:52 +0000479 if (descr->procA) WINPROC_SetProc( &classPtr->winprocA, descr->procA,
Alexandre Julliard91222da2000-12-10 23:01:33 +0000480 WIN_PROC_32A, WIN_PROC_CLASS );
Alexandre Julliard18d02972002-12-03 23:34:52 +0000481 if (descr->procW) WINPROC_SetProc( &classPtr->winprocW, descr->procW,
Alexandre Julliard91222da2000-12-10 23:01:33 +0000482 WIN_PROC_32W, WIN_PROC_CLASS );
Alexandre Julliard98779062000-12-07 23:39:16 +0000483 return atom;
484}
485
486
487/***********************************************************************
488 * CLASS_AddWindow
489 *
490 * Add a new window using this class, and return the necessary
491 * information for creating the window.
492 */
493CLASS *CLASS_AddWindow( ATOM atom, HINSTANCE inst, WINDOWPROCTYPE type,
494 INT *winExtra, WNDPROC *winproc, DWORD *style, struct tagDCE **dce )
495{
496 CLASS *class;
Alexandre Julliarda8a422f2002-11-22 20:43:01 +0000497 if (type == WIN_PROC_16) inst = HINSTANCE_32(GetExePtr(HINSTANCE_16(inst)));
Alexandre Julliard98779062000-12-07 23:39:16 +0000498
499 if (!(class = CLASS_FindClassByAtom( atom, inst ))) return NULL;
500 class->cWindows++;
501
502 if (type == WIN_PROC_32W)
503 {
504 if (!(*winproc = class->winprocW)) *winproc = class->winprocA;
505 }
506 else
507 {
508 if (!(*winproc = class->winprocA)) *winproc = class->winprocW;
509 }
510 *winExtra = class->cbWndExtra;
511 *style = class->style;
512 *dce = class->dce;
513 return class;
514}
515
516
517/***********************************************************************
518 * CLASS_RemoveWindow
519 *
520 * Remove a window from the class window count.
521 */
522void CLASS_RemoveWindow( CLASS *cls )
523{
524 if (cls && cls->cWindows) cls->cWindows--;
525}
526
527
528/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +0000529 * RegisterClass (USER.57)
Alexandre Julliard401710d1993-09-04 10:09:32 +0000530 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000531ATOM WINAPI RegisterClass16( const WNDCLASS16 *wc )
Alexandre Julliard401710d1993-09-04 10:09:32 +0000532{
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000533 ATOM atom;
534 CLASS *classPtr;
Pierre Mageau4ac8db71999-09-04 11:16:48 +0000535 int iSmIconWidth, iSmIconHeight;
Alexandre Julliarda8a422f2002-11-22 20:43:01 +0000536 HINSTANCE hInstance = HINSTANCE_32(GetExePtr(wc->hInstance));
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000537
Alexandre Julliard982a2232000-12-13 20:20:09 +0000538 if (!(atom = GlobalAddAtomA( MapSL(wc->lpszClassName) ))) return 0;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000539 if (!(classPtr = CLASS_RegisterClass( atom, hInstance, wc->style,
Alexandre Julliard98779062000-12-07 23:39:16 +0000540 wc->cbClsExtra, wc->cbWndExtra )))
Alexandre Julliard5f721f81994-01-04 20:14:34 +0000541 {
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000542 GlobalDeleteAtom( atom );
543 return 0;
Alexandre Julliard5f721f81994-01-04 20:14:34 +0000544 }
545
Alexandre Julliardaff7dda2002-11-22 21:22:14 +0000546 TRACE("atom=%04x wndproc=%08lx hinst=%p bg=%04x style=%08x clsExt=%d winExt=%d class=%p name='%s'\n",
547 atom, (DWORD)wc->lpfnWndProc, hInstance,
548 wc->hbrBackground, wc->style, wc->cbClsExtra,
549 wc->cbWndExtra, classPtr,
550 HIWORD(wc->lpszClassName) ? (char *)MapSL(wc->lpszClassName) : "" );
Alexandre Julliard5f721f81994-01-04 20:14:34 +0000551
Pierre Mageau4ac8db71999-09-04 11:16:48 +0000552 iSmIconWidth = GetSystemMetrics(SM_CXSMICON);
553 iSmIconHeight = GetSystemMetrics(SM_CYSMICON);
554
Michael Stefaniucbc54d782002-10-10 21:22:09 +0000555 classPtr->hIcon = HICON_32(wc->hIcon);
Alexandre Julliarda8a422f2002-11-22 20:43:01 +0000556 classPtr->hIconSm = CopyImage(classPtr->hIcon, IMAGE_ICON,
Pierre Mageau4ac8db71999-09-04 11:16:48 +0000557 iSmIconWidth, iSmIconHeight,
558 LR_COPYFROMRESOURCE);
Michael Stefaniucbc54d782002-10-10 21:22:09 +0000559 classPtr->hCursor = HCURSOR_32(wc->hCursor);
560 classPtr->hbrBackground = HBRUSH_32(wc->hbrBackground);
Alexandre Julliardf0b23541993-09-29 12:21:49 +0000561
Alexandre Julliard18d02972002-12-03 23:34:52 +0000562 WINPROC_SetProc( &classPtr->winprocA, (WNDPROC)wc->lpfnWndProc,
Alexandre Julliard98779062000-12-07 23:39:16 +0000563 WIN_PROC_16, WIN_PROC_CLASS );
Alexandre Julliard982a2232000-12-13 20:20:09 +0000564 CLASS_SetMenuNameA( classPtr, MapSL(wc->lpszMenuName) );
Gavriel Statec77c5921998-11-15 09:21:17 +0000565
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000566 return atom;
Alexandre Julliard401710d1993-09-04 10:09:32 +0000567}
568
569
570/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +0000571 * RegisterClassA (USER32.@)
Alexandre Julliarda69b88b1998-03-15 20:29:56 +0000572 * RETURNS
573 * >0: Unique identifier
574 * 0: Failure
Alexandre Julliard401710d1993-09-04 10:09:32 +0000575 */
Patrik Stridvall2b3aa612000-12-01 23:58:28 +0000576ATOM WINAPI RegisterClassA( const WNDCLASSA* wc ) /* [in] Address of structure with class data */
Alexandre Julliardf681cd02000-08-23 19:18:44 +0000577{
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000578 ATOM atom;
Pierre Mageau4ac8db71999-09-04 11:16:48 +0000579 int iSmIconWidth, iSmIconHeight;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000580 CLASS *classPtr;
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000581
Alexandre Julliardf681cd02000-08-23 19:18:44 +0000582 if (!(atom = GlobalAddAtomA( wc->lpszClassName ))) return 0;
583
Alexandre Julliard77b99181997-09-14 17:17:23 +0000584 if (!(classPtr = CLASS_RegisterClass( atom, wc->hInstance, wc->style,
Alexandre Julliard98779062000-12-07 23:39:16 +0000585 wc->cbClsExtra, wc->cbWndExtra )))
586 {
587 GlobalDeleteAtom( atom );
588 return 0;
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000589 }
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000590
Alexandre Julliardaff7dda2002-11-22 21:22:14 +0000591 TRACE("atom=%04x wndproc=%p hinst=%p bg=%p style=%08x clsExt=%d winExt=%d class=%p name='%s'\n",
592 atom, wc->lpfnWndProc, wc->hInstance,
593 wc->hbrBackground, wc->style, wc->cbClsExtra,
594 wc->cbWndExtra, classPtr,
595 HIWORD(wc->lpszClassName) ? wc->lpszClassName : "" );
Vincent Béron9a624912002-05-31 23:06:46 +0000596
Pierre Mageau4ac8db71999-09-04 11:16:48 +0000597 iSmIconWidth = GetSystemMetrics(SM_CXSMICON);
598 iSmIconHeight = GetSystemMetrics(SM_CYSMICON);
Vincent Béron9a624912002-05-31 23:06:46 +0000599
Pierre Mageau4ac8db71999-09-04 11:16:48 +0000600 classPtr->hIcon = wc->hIcon;
601 classPtr->hIconSm = CopyImage(wc->hIcon, IMAGE_ICON,
602 iSmIconWidth, iSmIconHeight,
603 LR_COPYFROMRESOURCE);
Michael Stefaniucbc54d782002-10-10 21:22:09 +0000604 classPtr->hCursor = wc->hCursor;
605 classPtr->hbrBackground = wc->hbrBackground;
Alexandre Julliard98779062000-12-07 23:39:16 +0000606
Alexandre Julliard18d02972002-12-03 23:34:52 +0000607 WINPROC_SetProc( &classPtr->winprocA, wc->lpfnWndProc,
Alexandre Julliard98779062000-12-07 23:39:16 +0000608 WIN_PROC_32A, WIN_PROC_CLASS );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000609 CLASS_SetMenuNameA( classPtr, wc->lpszMenuName );
610 return atom;
611}
612
613
614/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +0000615 * RegisterClassW (USER32.@)
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000616 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000617ATOM WINAPI RegisterClassW( const WNDCLASSW* wc )
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000618{
619 ATOM atom;
Pierre Mageau4ac8db71999-09-04 11:16:48 +0000620 int iSmIconWidth, iSmIconHeight;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000621 CLASS *classPtr;
622
Alexandre Julliardf681cd02000-08-23 19:18:44 +0000623 if (!(atom = GlobalAddAtomW( wc->lpszClassName ))) return 0;
624
Alexandre Julliard77b99181997-09-14 17:17:23 +0000625 if (!(classPtr = CLASS_RegisterClass( atom, wc->hInstance, wc->style,
Alexandre Julliard98779062000-12-07 23:39:16 +0000626 wc->cbClsExtra, wc->cbWndExtra )))
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000627 {
628 GlobalDeleteAtom( atom );
629 return 0;
630 }
631
Alexandre Julliardaff7dda2002-11-22 21:22:14 +0000632 TRACE("atom=%04x wndproc=%p hinst=%p bg=%p style=%08x clsExt=%d winExt=%d class=%p\n",
633 atom, wc->lpfnWndProc, wc->hInstance,
634 wc->hbrBackground, wc->style, wc->cbClsExtra,
635 wc->cbWndExtra, classPtr );
Vincent Béron9a624912002-05-31 23:06:46 +0000636
Pierre Mageau4ac8db71999-09-04 11:16:48 +0000637 iSmIconWidth = GetSystemMetrics(SM_CXSMICON);
638 iSmIconHeight = GetSystemMetrics(SM_CYSMICON);
639
640 classPtr->hIcon = wc->hIcon;
641 classPtr->hIconSm = CopyImage(wc->hIcon, IMAGE_ICON,
642 iSmIconWidth, iSmIconHeight,
643 LR_COPYFROMRESOURCE);
Michael Stefaniucbc54d782002-10-10 21:22:09 +0000644 classPtr->hCursor = wc->hCursor;
645 classPtr->hbrBackground = wc->hbrBackground;
Alexandre Julliard98779062000-12-07 23:39:16 +0000646
Alexandre Julliard18d02972002-12-03 23:34:52 +0000647 WINPROC_SetProc( &classPtr->winprocW, wc->lpfnWndProc,
Alexandre Julliard98779062000-12-07 23:39:16 +0000648 WIN_PROC_32W, WIN_PROC_CLASS );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000649 CLASS_SetMenuNameW( classPtr, wc->lpszMenuName );
650 return atom;
651}
652
653
654/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +0000655 * RegisterClassEx (USER.397)
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000656 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000657ATOM WINAPI RegisterClassEx16( const WNDCLASSEX16 *wc )
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000658{
659 ATOM atom;
660 CLASS *classPtr;
Alexandre Julliarda8a422f2002-11-22 20:43:01 +0000661 HINSTANCE hInstance = HINSTANCE_32(GetExePtr( wc->hInstance ));
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000662
Alexandre Julliard982a2232000-12-13 20:20:09 +0000663 if (!(atom = GlobalAddAtomA( MapSL(wc->lpszClassName) ))) return 0;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000664 if (!(classPtr = CLASS_RegisterClass( atom, hInstance, wc->style,
Alexandre Julliard98779062000-12-07 23:39:16 +0000665 wc->cbClsExtra, wc->cbWndExtra )))
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000666 {
667 GlobalDeleteAtom( atom );
668 return 0;
669 }
670
Alexandre Julliardaff7dda2002-11-22 21:22:14 +0000671 TRACE("atom=%04x wndproc=%p hinst=%p bg=%04x style=%08x clsExt=%d winExt=%d class=%p\n",
672 atom, wc->lpfnWndProc, hInstance,
673 wc->hbrBackground, wc->style, wc->cbClsExtra,
674 wc->cbWndExtra, classPtr );
Vincent Béron9a624912002-05-31 23:06:46 +0000675
Michael Stefaniucbc54d782002-10-10 21:22:09 +0000676 classPtr->hIcon = HICON_32(wc->hIcon);
677 classPtr->hIconSm = HICON_32(wc->hIconSm);
678 classPtr->hCursor = HCURSOR_32(wc->hCursor);
679 classPtr->hbrBackground = HBRUSH_32(wc->hbrBackground);
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000680
Alexandre Julliard18d02972002-12-03 23:34:52 +0000681 WINPROC_SetProc( &classPtr->winprocA, (WNDPROC)wc->lpfnWndProc,
Alexandre Julliard98779062000-12-07 23:39:16 +0000682 WIN_PROC_16, WIN_PROC_CLASS );
Alexandre Julliard982a2232000-12-13 20:20:09 +0000683 CLASS_SetMenuNameA( classPtr, MapSL(wc->lpszMenuName) );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000684 return atom;
685}
686
687
688/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +0000689 * RegisterClassExA (USER32.@)
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000690 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000691ATOM WINAPI RegisterClassExA( const WNDCLASSEXA* wc )
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000692{
693 ATOM atom;
694 CLASS *classPtr;
695
Alexandre Julliardf681cd02000-08-23 19:18:44 +0000696 if (!(atom = GlobalAddAtomA( wc->lpszClassName ))) return 0;
697
Alexandre Julliard77b99181997-09-14 17:17:23 +0000698 if (!(classPtr = CLASS_RegisterClass( atom, wc->hInstance, wc->style,
Alexandre Julliard98779062000-12-07 23:39:16 +0000699 wc->cbClsExtra, wc->cbWndExtra )))
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000700 {
701 GlobalDeleteAtom( atom );
Alexandre Julliard98779062000-12-07 23:39:16 +0000702 return 0;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000703 }
704
Alexandre Julliardaff7dda2002-11-22 21:22:14 +0000705 TRACE("atom=%04x wndproc=%p hinst=%p bg=%p style=%08x clsExt=%d winExt=%d class=%p\n",
706 atom, wc->lpfnWndProc, wc->hInstance,
707 wc->hbrBackground, wc->style, wc->cbClsExtra,
708 wc->cbWndExtra, classPtr );
Vincent Béron9a624912002-05-31 23:06:46 +0000709
Michael Stefaniucbc54d782002-10-10 21:22:09 +0000710 classPtr->hIcon = wc->hIcon;
711 classPtr->hIconSm = wc->hIconSm;
712 classPtr->hCursor = wc->hCursor;
713 classPtr->hbrBackground = wc->hbrBackground;
Alexandre Julliard18d02972002-12-03 23:34:52 +0000714 WINPROC_SetProc( &classPtr->winprocA, wc->lpfnWndProc, WIN_PROC_32A, WIN_PROC_CLASS );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000715 CLASS_SetMenuNameA( classPtr, wc->lpszMenuName );
716 return atom;
717}
718
719
720/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +0000721 * RegisterClassExW (USER32.@)
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000722 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000723ATOM WINAPI RegisterClassExW( const WNDCLASSEXW* wc )
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000724{
725 ATOM atom;
726 CLASS *classPtr;
727
Alexandre Julliardf681cd02000-08-23 19:18:44 +0000728 if (!(atom = GlobalAddAtomW( wc->lpszClassName ))) return 0;
729
Alexandre Julliard77b99181997-09-14 17:17:23 +0000730 if (!(classPtr = CLASS_RegisterClass( atom, wc->hInstance, wc->style,
Alexandre Julliard98779062000-12-07 23:39:16 +0000731 wc->cbClsExtra, wc->cbWndExtra )))
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000732 {
733 GlobalDeleteAtom( atom );
734 return 0;
735 }
736
Alexandre Julliardaff7dda2002-11-22 21:22:14 +0000737 TRACE("atom=%04x wndproc=%p hinst=%p bg=%p style=%08x clsExt=%d winExt=%d class=%p\n",
738 atom, wc->lpfnWndProc, wc->hInstance,
739 wc->hbrBackground, wc->style, wc->cbClsExtra,
740 wc->cbWndExtra, classPtr );
Vincent Béron9a624912002-05-31 23:06:46 +0000741
Michael Stefaniucbc54d782002-10-10 21:22:09 +0000742 classPtr->hIcon = wc->hIcon;
743 classPtr->hIconSm = wc->hIconSm;
744 classPtr->hCursor = wc->hCursor;
745 classPtr->hbrBackground = wc->hbrBackground;
Alexandre Julliard18d02972002-12-03 23:34:52 +0000746 WINPROC_SetProc( &classPtr->winprocW, wc->lpfnWndProc, WIN_PROC_32W, WIN_PROC_CLASS );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000747 CLASS_SetMenuNameW( classPtr, wc->lpszMenuName );
748 return atom;
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000749}
750
751
752/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +0000753 * UnregisterClass (USER.403)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000754 */
Alexandre Julliardb849d792000-02-13 13:56:13 +0000755BOOL16 WINAPI UnregisterClass16( LPCSTR className, HINSTANCE16 hInstance )
Alexandre Julliard401710d1993-09-04 10:09:32 +0000756{
Alexandre Julliarda8a422f2002-11-22 20:43:01 +0000757 return UnregisterClassA( className, HINSTANCE_32(GetExePtr( hInstance )) );
Alexandre Julliard401710d1993-09-04 10:09:32 +0000758}
759
Alexandre Julliard401710d1993-09-04 10:09:32 +0000760/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +0000761 * UnregisterClassA (USER32.@)
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000762 *
Alexandre Julliard401710d1993-09-04 10:09:32 +0000763 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000764BOOL WINAPI UnregisterClassA( LPCSTR className, HINSTANCE hInstance )
Alexandre Julliard98779062000-12-07 23:39:16 +0000765{
Alexandre Julliardaff7dda2002-11-22 21:22:14 +0000766 TRACE("%s %p\n",debugstr_a(className), hInstance);
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000767 return CLASS_UnregisterClass( GlobalFindAtomA( className ), hInstance );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000768}
769
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000770/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +0000771 * UnregisterClassW (USER32.@)
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000772 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000773BOOL WINAPI UnregisterClassW( LPCWSTR className, HINSTANCE hInstance )
Alexandre Julliard98779062000-12-07 23:39:16 +0000774{
Alexandre Julliardaff7dda2002-11-22 21:22:14 +0000775 TRACE("%s %p\n",debugstr_w(className), hInstance);
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000776 return CLASS_UnregisterClass( GlobalFindAtomW( className ), hInstance );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000777}
778
Alexandre Julliard21979011997-03-05 08:22:35 +0000779
780/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +0000781 * GetClassWord (USER32.@)
Alexandre Julliard21979011997-03-05 08:22:35 +0000782 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000783WORD WINAPI GetClassWord( HWND hwnd, INT offset )
Alexandre Julliard401710d1993-09-04 10:09:32 +0000784{
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000785 CLASS *class;
Guy Albertelli2fa281f1999-04-24 11:54:40 +0000786 WORD retvalue = 0;
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000787
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000788 if (offset < 0) return GetClassLongA( hwnd, offset );
789
Alexandre Julliardaff7dda2002-11-22 21:22:14 +0000790 TRACE("%p %x\n",hwnd, offset);
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000791
Alexandre Julliard8fd26b92001-10-15 17:56:45 +0000792 if (!(class = get_class_ptr( hwnd, FALSE ))) return 0;
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000793
794 if (offset <= class->cbClsExtra - sizeof(WORD))
Alexandre Julliard7fbd74e2002-05-23 02:53:10 +0000795 memcpy( &retvalue, (char *)(class + 1) + offset, sizeof(retvalue) );
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000796 else
797 SetLastError( ERROR_INVALID_INDEX );
798 release_class_ptr( class );
Guy Albertelli2fa281f1999-04-24 11:54:40 +0000799 return retvalue;
Alexandre Julliard401710d1993-09-04 10:09:32 +0000800}
801
802
803/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +0000804 * GetClassLong (USER.131)
Alexandre Julliard401710d1993-09-04 10:09:32 +0000805 */
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000806LONG WINAPI GetClassLong16( HWND16 hwnd16, INT16 offset )
Alexandre Julliard401710d1993-09-04 10:09:32 +0000807{
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000808 CLASS *class;
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000809 LONG ret;
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000810 HWND hwnd = (HWND)(ULONG_PTR)hwnd16; /* no need for full handle */
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000811
Alexandre Julliardaff7dda2002-11-22 21:22:14 +0000812 TRACE("%p %d\n",hwnd, offset);
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000813
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000814 switch( offset )
815 {
Alexandre Julliard3051b641996-07-05 17:14:13 +0000816 case GCL_WNDPROC:
Alexandre Julliard8fd26b92001-10-15 17:56:45 +0000817 if (!(class = get_class_ptr( hwnd, FALSE ))) return 0;
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000818 ret = (LONG)CLASS_GetProc( class, WIN_PROC_16 );
819 release_class_ptr( class );
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000820 return ret;
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000821 case GCL_MENUNAME:
Alexandre Julliardd7b76822001-12-20 00:19:40 +0000822 if (!(class = get_class_ptr( hwnd, FALSE ))) return 0;
823 ret = (LONG)CLASS_GetMenuName16( class );
824 release_class_ptr( class );
825 return ret;
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000826 default:
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000827 return GetClassLongA( hwnd, offset );
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000828 }
Alexandre Julliard401710d1993-09-04 10:09:32 +0000829}
830
831
832/***********************************************************************
Stefan Leichter2c756722002-11-21 21:48:27 +0000833 * GetClassLongW (USER32.@)
Alexandre Julliard401710d1993-09-04 10:09:32 +0000834 */
Stefan Leichter2c756722002-11-21 21:48:27 +0000835LONG WINAPI GetClassLongW( HWND hwnd, INT offset )
Alexandre Julliard401710d1993-09-04 10:09:32 +0000836{
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000837 CLASS *class;
838 LONG retvalue = 0;
839
Alexandre Julliardaff7dda2002-11-22 21:22:14 +0000840 TRACE("%p %d\n", hwnd, offset);
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000841
Alexandre Julliard8fd26b92001-10-15 17:56:45 +0000842 if (!(class = get_class_ptr( hwnd, FALSE ))) return 0;
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000843
Alexandre Julliard2ace16a1996-04-28 15:09:19 +0000844 if (offset >= 0)
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000845 {
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000846 if (offset <= class->cbClsExtra - sizeof(LONG))
Alexandre Julliard7fbd74e2002-05-23 02:53:10 +0000847 memcpy( &retvalue, (char *)(class + 1) + offset, sizeof(retvalue) );
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000848 else
849 SetLastError( ERROR_INVALID_INDEX );
850 release_class_ptr( class );
851 return retvalue;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000852 }
Alexandre Julliardd44e4952001-08-20 18:09:39 +0000853
Alexandre Julliard2ace16a1996-04-28 15:09:19 +0000854 switch(offset)
855 {
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000856 case GCL_HBRBACKGROUND:
857 retvalue = (LONG)class->hbrBackground;
858 break;
859 case GCL_HCURSOR:
860 retvalue = (LONG)class->hCursor;
861 break;
862 case GCL_HICON:
863 retvalue = (LONG)class->hIcon;
864 break;
865 case GCL_HICONSM:
866 retvalue = (LONG)class->hIconSm;
867 break;
868 case GCL_STYLE:
869 retvalue = (LONG)class->style;
870 break;
871 case GCL_CBWNDEXTRA:
872 retvalue = (LONG)class->cbWndExtra;
873 break;
874 case GCL_CBCLSEXTRA:
875 retvalue = (LONG)class->cbClsExtra;
876 break;
877 case GCL_HMODULE:
878 retvalue = (LONG)class->hInstance;
879 break;
880 case GCL_WNDPROC:
Stefan Leichter2c756722002-11-21 21:48:27 +0000881 retvalue = (LONG)CLASS_GetProc( class, WIN_PROC_32W );
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000882 break;
883 case GCL_MENUNAME:
Stefan Leichter2c756722002-11-21 21:48:27 +0000884 retvalue = (LONG)CLASS_GetMenuNameW( class );
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000885 break;
886 case GCW_ATOM:
887 retvalue = (DWORD)class->atomName;
888 break;
889 default:
890 SetLastError( ERROR_INVALID_INDEX );
891 break;
Alexandre Julliard2ace16a1996-04-28 15:09:19 +0000892 }
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000893 release_class_ptr( class );
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000894 return retvalue;
Alexandre Julliard401710d1993-09-04 10:09:32 +0000895}
896
897
898/***********************************************************************
Stefan Leichter2c756722002-11-21 21:48:27 +0000899 * GetClassLongA (USER32.@)
Alexandre Julliard401710d1993-09-04 10:09:32 +0000900 */
Stefan Leichter2c756722002-11-21 21:48:27 +0000901LONG WINAPI GetClassLongA( HWND hwnd, INT offset )
Alexandre Julliard401710d1993-09-04 10:09:32 +0000902{
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000903 CLASS *class;
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000904 LONG retvalue;
Alexandre Julliard3051b641996-07-05 17:14:13 +0000905
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000906 if (offset != GCL_WNDPROC && offset != GCL_MENUNAME)
Stefan Leichter2c756722002-11-21 21:48:27 +0000907 return GetClassLongW( hwnd, offset );
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000908
Alexandre Julliardaff7dda2002-11-22 21:22:14 +0000909 TRACE("%p %d\n", hwnd, offset);
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000910
Alexandre Julliard8fd26b92001-10-15 17:56:45 +0000911 if (!(class = get_class_ptr( hwnd, FALSE ))) return 0;
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000912
913 if (offset == GCL_WNDPROC)
Stefan Leichter2c756722002-11-21 21:48:27 +0000914 retvalue = (LONG)CLASS_GetProc( class, WIN_PROC_32A );
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000915 else /* GCL_MENUNAME */
Stefan Leichter2c756722002-11-21 21:48:27 +0000916 retvalue = (LONG)CLASS_GetMenuNameA( class );
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000917
918 release_class_ptr( class );
919 return retvalue;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000920}
921
922
923/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +0000924 * SetClassWord (USER32.@)
Alexandre Julliard21979011997-03-05 08:22:35 +0000925 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000926WORD WINAPI SetClassWord( HWND hwnd, INT offset, WORD newval )
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000927{
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000928 CLASS *class;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000929 WORD retval = 0;
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000930
931 if (offset < 0) return SetClassLongA( hwnd, offset, (DWORD)newval );
932
Alexandre Julliardaff7dda2002-11-22 21:22:14 +0000933 TRACE("%p %d %x\n", hwnd, offset, newval);
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000934
Alexandre Julliard8fd26b92001-10-15 17:56:45 +0000935 if (!(class = get_class_ptr( hwnd, TRUE ))) return 0;
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000936
937 if (offset <= class->cbClsExtra - sizeof(WORD))
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000938 {
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000939 void *ptr = (char *)(class + 1) + offset;
Alexandre Julliard7fbd74e2002-05-23 02:53:10 +0000940 memcpy( &retval, ptr, sizeof(retval) );
941 memcpy( ptr, &newval, sizeof(newval) );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000942 }
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000943 else SetLastError( ERROR_INVALID_INDEX );
944
945 release_class_ptr( class );
Alexandre Julliard401710d1993-09-04 10:09:32 +0000946 return retval;
947}
Alexandre Julliard5f721f81994-01-04 20:14:34 +0000948
949
950/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +0000951 * SetClassLong (USER.132)
Alexandre Julliard5f721f81994-01-04 20:14:34 +0000952 */
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000953LONG WINAPI SetClassLong16( HWND16 hwnd16, INT16 offset, LONG newval )
Alexandre Julliard5f721f81994-01-04 20:14:34 +0000954{
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000955 CLASS *class;
Alexandre Julliard3051b641996-07-05 17:14:13 +0000956 LONG retval;
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000957 HWND hwnd = (HWND)(ULONG_PTR)hwnd16; /* no need for full handle */
Alexandre Julliard2d93d001996-05-21 15:01:41 +0000958
Alexandre Julliardaff7dda2002-11-22 21:22:14 +0000959 TRACE("%p %d %lx\n", hwnd, offset, newval);
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000960
Alexandre Julliard2d93d001996-05-21 15:01:41 +0000961 switch(offset)
962 {
963 case GCL_WNDPROC:
Alexandre Julliard8fd26b92001-10-15 17:56:45 +0000964 if (!(class = get_class_ptr( hwnd, TRUE ))) return 0;
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000965 retval = (LONG)CLASS_SetProc( class, (WNDPROC)newval, WIN_PROC_16 );
966 release_class_ptr( class );
Alexandre Julliard3051b641996-07-05 17:14:13 +0000967 return retval;
Alexandre Julliard2d93d001996-05-21 15:01:41 +0000968 case GCL_MENUNAME:
Alexandre Julliardd23a82b2001-09-19 20:37:04 +0000969 newval = (LONG)MapSL( newval );
970 /* fall through */
Alexandre Julliard2d93d001996-05-21 15:01:41 +0000971 default:
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000972 return SetClassLongA( hwnd, offset, newval );
Alexandre Julliard2d93d001996-05-21 15:01:41 +0000973 }
Alexandre Julliard5f721f81994-01-04 20:14:34 +0000974}
975
976
977/***********************************************************************
Stefan Leichter2c756722002-11-21 21:48:27 +0000978 * SetClassLongW (USER32.@)
Alexandre Julliard5f721f81994-01-04 20:14:34 +0000979 */
Stefan Leichter2c756722002-11-21 21:48:27 +0000980LONG WINAPI SetClassLongW( HWND hwnd, INT offset, LONG newval )
Alexandre Julliard5f721f81994-01-04 20:14:34 +0000981{
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000982 CLASS *class;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000983 LONG retval = 0;
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000984
Alexandre Julliardaff7dda2002-11-22 21:22:14 +0000985 TRACE("%p %d %lx\n", hwnd, offset, newval);
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000986
Alexandre Julliard8fd26b92001-10-15 17:56:45 +0000987 if (!(class = get_class_ptr( hwnd, TRUE ))) return 0;
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000988
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000989 if (offset >= 0)
990 {
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000991 if (offset <= class->cbClsExtra - sizeof(LONG))
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000992 {
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000993 void *ptr = (char *)(class + 1) + offset;
Alexandre Julliard7fbd74e2002-05-23 02:53:10 +0000994 memcpy( &retval, ptr, sizeof(retval) );
995 memcpy( ptr, &newval, sizeof(newval) );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000996 }
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000997 else SetLastError( ERROR_INVALID_INDEX );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000998 }
999 else switch(offset)
1000 {
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +00001001 case GCL_MENUNAME:
Stefan Leichter2c756722002-11-21 21:48:27 +00001002 CLASS_SetMenuNameW( class, (LPCWSTR)newval );
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +00001003 retval = 0; /* Old value is now meaningless anyway */
1004 break;
1005 case GCL_WNDPROC:
Stefan Leichter2c756722002-11-21 21:48:27 +00001006 retval = (LONG)CLASS_SetProc( class, (WNDPROC)newval, WIN_PROC_32W );
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +00001007 break;
1008 case GCL_HBRBACKGROUND:
1009 retval = (LONG)class->hbrBackground;
Alexandre Julliard7ef66af2002-11-22 04:47:10 +00001010 class->hbrBackground = (HBRUSH)newval;
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +00001011 break;
1012 case GCL_HCURSOR:
1013 retval = (LONG)class->hCursor;
Michael Stefaniucbc54d782002-10-10 21:22:09 +00001014 class->hCursor = (HCURSOR)newval;
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +00001015 break;
1016 case GCL_HICON:
1017 retval = (LONG)class->hIcon;
Michael Stefaniucbc54d782002-10-10 21:22:09 +00001018 class->hIcon = (HICON)newval;
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +00001019 break;
1020 case GCL_HICONSM:
1021 retval = (LONG)class->hIconSm;
Michael Stefaniucbc54d782002-10-10 21:22:09 +00001022 class->hIconSm = (HICON)newval;
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +00001023 break;
1024 case GCL_STYLE:
1025 retval = (LONG)class->style;
1026 class->style = newval;
1027 break;
1028 case GCL_CBWNDEXTRA:
1029 retval = (LONG)class->cbWndExtra;
1030 class->cbWndExtra = newval;
1031 break;
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +00001032 case GCL_HMODULE:
1033 retval = (LONG)class->hInstance;
Alexandre Julliard7ef66af2002-11-22 04:47:10 +00001034 class->hInstance = (HINSTANCE)newval;
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +00001035 break;
1036 case GCW_ATOM:
1037 retval = (DWORD)class->atomName;
1038 class->atomName = newval;
1039 break;
Alexandre Julliard8fd26b92001-10-15 17:56:45 +00001040 case GCL_CBCLSEXTRA: /* cannot change this one */
1041 SetLastError( ERROR_INVALID_PARAMETER );
1042 break;
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +00001043 default:
1044 SetLastError( ERROR_INVALID_INDEX );
1045 break;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001046 }
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +00001047 release_class_ptr( class );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001048 return retval;
1049}
1050
1051
1052/***********************************************************************
Stefan Leichter2c756722002-11-21 21:48:27 +00001053 * SetClassLongA (USER32.@)
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001054 */
Stefan Leichter2c756722002-11-21 21:48:27 +00001055LONG WINAPI SetClassLongA( HWND hwnd, INT offset, LONG newval )
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001056{
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +00001057 CLASS *class;
Alexandre Julliard3051b641996-07-05 17:14:13 +00001058 LONG retval;
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001059
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +00001060 if (offset != GCL_WNDPROC && offset != GCL_MENUNAME)
Stefan Leichter2c756722002-11-21 21:48:27 +00001061 return SetClassLongW( hwnd, offset, newval );
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +00001062
Alexandre Julliardaff7dda2002-11-22 21:22:14 +00001063 TRACE("%p %d %lx\n", hwnd, offset, newval);
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +00001064
Alexandre Julliard8fd26b92001-10-15 17:56:45 +00001065 if (!(class = get_class_ptr( hwnd, TRUE ))) return 0;
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +00001066
1067 if (offset == GCL_WNDPROC)
Stefan Leichter2c756722002-11-21 21:48:27 +00001068 retval = (LONG)CLASS_SetProc( class, (WNDPROC)newval, WIN_PROC_32A );
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +00001069 else /* GCL_MENUNAME */
1070 {
Stefan Leichter2c756722002-11-21 21:48:27 +00001071 CLASS_SetMenuNameA( class, (LPCSTR)newval );
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +00001072 retval = 0; /* Old value is now meaningless anyway */
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001073 }
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +00001074 release_class_ptr( class );
1075 return retval;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001076}
1077
1078
1079/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +00001080 * GetClassNameA (USER32.@)
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001081 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001082INT WINAPI GetClassNameA( HWND hwnd, LPSTR buffer, INT count )
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +00001083{
Alexandre Julliard8fd26b92001-10-15 17:56:45 +00001084 INT ret = GlobalGetAtomNameA( GetClassLongA( hwnd, GCW_ATOM ), buffer, count );
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +00001085
Alexandre Julliardaff7dda2002-11-22 21:22:14 +00001086 TRACE("%p %s %x\n",hwnd, debugstr_a(buffer), count);
Alexandre Julliard767e6f61998-08-09 12:47:43 +00001087 return ret;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001088}
1089
1090
1091/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +00001092 * GetClassNameW (USER32.@)
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001093 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001094INT WINAPI GetClassNameW( HWND hwnd, LPWSTR buffer, INT count )
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +00001095{
Alexandre Julliard8fd26b92001-10-15 17:56:45 +00001096 INT ret = GlobalGetAtomNameW( GetClassLongW( hwnd, GCW_ATOM ), buffer, count );
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +00001097
Alexandre Julliardaff7dda2002-11-22 21:22:14 +00001098 TRACE("%p %s %x\n",hwnd, debugstr_w(buffer), count);
Alexandre Julliard767e6f61998-08-09 12:47:43 +00001099 return ret;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001100}
1101
1102
1103/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +00001104 * GetClassInfo (USER.404)
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001105 */
Alexandre Julliarda8a422f2002-11-22 20:43:01 +00001106BOOL16 WINAPI GetClassInfo16( HINSTANCE16 hInst16, SEGPTR name, WNDCLASS16 *wc )
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001107{
1108 ATOM atom;
Alexandre Julliard5f721f81994-01-04 20:14:34 +00001109 CLASS *classPtr;
Alexandre Julliarda8a422f2002-11-22 20:43:01 +00001110 HINSTANCE hInstance = HINSTANCE_32(GetExePtr( hInst16 ));
Alexandre Julliard3ed37e01994-11-07 18:20:42 +00001111
Alexandre Julliardaff7dda2002-11-22 21:22:14 +00001112 TRACE("%p %s %p\n",hInstance, debugstr_a(MapSL(name)), wc);
Alexandre Julliard98779062000-12-07 23:39:16 +00001113
Alexandre Julliard982a2232000-12-13 20:20:09 +00001114 if (!(atom = GlobalFindAtomA( MapSL(name) )) ||
Alexandre Julliard670cdc41997-08-24 16:00:30 +00001115 !(classPtr = CLASS_FindClassByAtom( atom, hInstance )))
1116 return FALSE;
1117 if ((hInstance != classPtr->hInstance) &&
1118 !(classPtr->style & CS_GLOBALCLASS)) /*BWCC likes to pass hInstance=0*/
1119 return FALSE;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001120 wc->style = (UINT16)classPtr->style;
Alexandre Julliard98779062000-12-07 23:39:16 +00001121 wc->lpfnWndProc = CLASS_GetProc( classPtr, WIN_PROC_16 );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001122 wc->cbClsExtra = (INT16)classPtr->cbClsExtra;
1123 wc->cbWndExtra = (INT16)classPtr->cbWndExtra;
Alexandre Julliarda8a422f2002-11-22 20:43:01 +00001124 wc->hInstance = classPtr->style & CS_GLOBALCLASS ? GetModuleHandle16("USER") : HINSTANCE_16(classPtr->hInstance);
Michael Stefaniucbc54d782002-10-10 21:22:09 +00001125 wc->hIcon = HICON_16(classPtr->hIcon);
1126 wc->hCursor = HCURSOR_16(classPtr->hCursor);
1127 wc->hbrBackground = HBRUSH_16(classPtr->hbrBackground);
Alexandre Julliard98779062000-12-07 23:39:16 +00001128 wc->lpszClassName = name;
Alexandre Julliardd7b76822001-12-20 00:19:40 +00001129 wc->lpszMenuName = CLASS_GetMenuName16( classPtr );
Dmitry Timoshkov33cf3e02003-05-19 23:10:54 +00001130
1131 /* We must return the atom of the class here instead of just TRUE. */
1132 return atom;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001133}
1134
1135
1136/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +00001137 * GetClassInfoA (USER32.@)
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001138 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001139BOOL WINAPI GetClassInfoA( HINSTANCE hInstance, LPCSTR name,
1140 WNDCLASSA *wc )
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001141{
1142 ATOM atom;
1143 CLASS *classPtr;
1144
Alexandre Julliardaff7dda2002-11-22 21:22:14 +00001145 TRACE("%p %p %p\n",hInstance, name, wc);
Alexandre Julliard767e6f61998-08-09 12:47:43 +00001146
1147 /* workaround: if hInstance=NULL you expect to get the system classes
1148 but this classes (as example from comctl32.dll SysListView) won't be
Andreas Mohr2caee712000-07-16 15:44:22 +00001149 registered with hInstance=NULL in WINE because of the late loading
Alexandre Julliard767e6f61998-08-09 12:47:43 +00001150 of this dll. fixes file dialogs in WinWord95 (jsch)*/
1151
Alexandre Julliarda3960291999-02-26 11:11:13 +00001152 if (!(atom=GlobalFindAtomA(name)) || !(classPtr=CLASS_FindClassByAtom(atom,hInstance)))
Alexandre Julliard21979011997-03-05 08:22:35 +00001153 return FALSE;
1154
Noomen Hamza1040eaf2000-07-09 12:21:07 +00001155 if (!(classPtr->style & CS_GLOBALCLASS) &&
1156 classPtr->hInstance &&
1157 (hInstance != classPtr->hInstance))
Alexandre Julliard767e6f61998-08-09 12:47:43 +00001158 {
1159 if (hInstance) return FALSE;
Noomen Hamza1040eaf2000-07-09 12:21:07 +00001160 WARN("systemclass %s (hInst=0) demanded but only class with hInst!=0 found\n",name);
Alexandre Julliard767e6f61998-08-09 12:47:43 +00001161 }
1162
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001163 wc->style = classPtr->style;
Alexandre Julliard98779062000-12-07 23:39:16 +00001164 wc->lpfnWndProc = (WNDPROC)CLASS_GetProc( classPtr, WIN_PROC_32A );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001165 wc->cbClsExtra = classPtr->cbClsExtra;
1166 wc->cbWndExtra = classPtr->cbWndExtra;
Noomen Hamza1040eaf2000-07-09 12:21:07 +00001167 wc->hInstance = hInstance;
Alexandre Julliarda3960291999-02-26 11:11:13 +00001168 wc->hIcon = (HICON)classPtr->hIcon;
1169 wc->hCursor = (HCURSOR)classPtr->hCursor;
1170 wc->hbrBackground = (HBRUSH)classPtr->hbrBackground;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001171 wc->lpszMenuName = CLASS_GetMenuNameA( classPtr );
Alexandre Julliard98779062000-12-07 23:39:16 +00001172 wc->lpszClassName = name;
Dmitry Timoshkov33cf3e02003-05-19 23:10:54 +00001173
1174 /* We must return the atom of the class here instead of just TRUE. */
1175 return atom;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001176}
1177
1178
1179/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +00001180 * GetClassInfoW (USER32.@)
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001181 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001182BOOL WINAPI GetClassInfoW( HINSTANCE hInstance, LPCWSTR name,
1183 WNDCLASSW *wc )
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001184{
1185 ATOM atom;
1186 CLASS *classPtr;
1187
Alexandre Julliardaff7dda2002-11-22 21:22:14 +00001188 TRACE("%p %p %p\n",hInstance, name, wc);
Alexandre Julliard767e6f61998-08-09 12:47:43 +00001189
Marcus Meissner438062171999-09-03 12:28:20 +00001190 if ( !(atom=GlobalFindAtomW(name)) ||
1191 !(classPtr=CLASS_FindClassByAtom(atom,hInstance))
1192 )
Alexandre Julliard21979011997-03-05 08:22:35 +00001193 return FALSE;
1194
Noomen Hamza1040eaf2000-07-09 12:21:07 +00001195 if (!(classPtr->style & CS_GLOBALCLASS) &&
1196 classPtr->hInstance &&
1197 (hInstance != classPtr->hInstance))
1198 {
1199 if (hInstance) return FALSE;
1200 WARN("systemclass %s (hInst=0) demanded but only class with hInst!=0 found\n",debugstr_w(name));
Marcus Meissner438062171999-09-03 12:28:20 +00001201 }
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001202 wc->style = classPtr->style;
Alexandre Julliard98779062000-12-07 23:39:16 +00001203 wc->lpfnWndProc = (WNDPROC)CLASS_GetProc( classPtr, WIN_PROC_32W );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001204 wc->cbClsExtra = classPtr->cbClsExtra;
1205 wc->cbWndExtra = classPtr->cbWndExtra;
Noomen Hamza1040eaf2000-07-09 12:21:07 +00001206 wc->hInstance = hInstance;
Alexandre Julliarda3960291999-02-26 11:11:13 +00001207 wc->hIcon = (HICON)classPtr->hIcon;
1208 wc->hCursor = (HCURSOR)classPtr->hCursor;
1209 wc->hbrBackground = (HBRUSH)classPtr->hbrBackground;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001210 wc->lpszMenuName = CLASS_GetMenuNameW( classPtr );
Alexandre Julliard98779062000-12-07 23:39:16 +00001211 wc->lpszClassName = name;
Dmitry Timoshkov33cf3e02003-05-19 23:10:54 +00001212
1213 /* We must return the atom of the class here instead of just TRUE. */
1214 return atom;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001215}
1216
1217
1218/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +00001219 * GetClassInfoEx (USER.398)
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001220 *
1221 * FIXME: this is just a guess, I have no idea if GetClassInfoEx() is the
1222 * same in Win16 as in Win32. --AJ
1223 */
Alexandre Julliarda8a422f2002-11-22 20:43:01 +00001224BOOL16 WINAPI GetClassInfoEx16( HINSTANCE16 hInst16, SEGPTR name, WNDCLASSEX16 *wc )
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001225{
1226 ATOM atom;
1227 CLASS *classPtr;
Alexandre Julliarda8a422f2002-11-22 20:43:01 +00001228 HINSTANCE hInstance = HINSTANCE_32(GetExePtr( hInst16 ));
Alexandre Julliard808cb041995-08-17 17:11:36 +00001229
Alexandre Julliardaff7dda2002-11-22 21:22:14 +00001230 TRACE("%p %s %p\n",hInstance,debugstr_a( MapSL(name) ), wc);
Alexandre Julliard98779062000-12-07 23:39:16 +00001231
Alexandre Julliard982a2232000-12-13 20:20:09 +00001232 if (!(atom = GlobalFindAtomA( MapSL(name) )) ||
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001233 !(classPtr = CLASS_FindClassByAtom( atom, hInstance )) ||
1234 (hInstance != classPtr->hInstance)) return FALSE;
1235 wc->style = classPtr->style;
Alexandre Julliard98779062000-12-07 23:39:16 +00001236 wc->lpfnWndProc = CLASS_GetProc( classPtr, WIN_PROC_16 );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001237 wc->cbClsExtra = (INT16)classPtr->cbClsExtra;
1238 wc->cbWndExtra = (INT16)classPtr->cbWndExtra;
Alexandre Julliarda8a422f2002-11-22 20:43:01 +00001239 wc->hInstance = HINSTANCE_16(classPtr->hInstance);
Michael Stefaniucbc54d782002-10-10 21:22:09 +00001240 wc->hIcon = HICON_16(classPtr->hIcon);
1241 wc->hIconSm = HICON_16(classPtr->hIconSm);
1242 wc->hCursor = HCURSOR_16(classPtr->hCursor);
1243 wc->hbrBackground = HBRUSH_16(classPtr->hbrBackground);
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001244 wc->lpszClassName = (SEGPTR)0;
Alexandre Julliardd7b76822001-12-20 00:19:40 +00001245 wc->lpszMenuName = CLASS_GetMenuName16( classPtr );
1246 wc->lpszClassName = name;
James Hatheway9fa09e72000-06-18 17:19:38 +00001247
1248 /* We must return the atom of the class here instead of just TRUE. */
1249 return atom;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001250}
Alexandre Julliard5f721f81994-01-04 20:14:34 +00001251
Alexandre Julliard1285c2f1996-05-06 16:06:24 +00001252
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001253/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +00001254 * GetClassInfoExA (USER32.@)
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001255 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001256BOOL WINAPI GetClassInfoExA( HINSTANCE hInstance, LPCSTR name,
1257 WNDCLASSEXA *wc )
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001258{
1259 ATOM atom;
1260 CLASS *classPtr;
1261
Alexandre Julliardaff7dda2002-11-22 21:22:14 +00001262 TRACE("%p %p %p\n",hInstance, name, wc);
Vincent Béron9a624912002-05-31 23:06:46 +00001263
Alexandre Julliarda3960291999-02-26 11:11:13 +00001264 if (!(atom = GlobalFindAtomA( name )) ||
Vincent Béron9a624912002-05-31 23:06:46 +00001265 !(classPtr = CLASS_FindClassByAtom( atom, hInstance ))
Alexandre Julliarda0d77311998-09-13 16:32:00 +00001266 /*|| (hInstance != classPtr->hInstance) */ ) return FALSE;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001267 wc->style = classPtr->style;
Alexandre Julliard98779062000-12-07 23:39:16 +00001268 wc->lpfnWndProc = (WNDPROC)CLASS_GetProc( classPtr, WIN_PROC_32A );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001269 wc->cbClsExtra = classPtr->cbClsExtra;
1270 wc->cbWndExtra = classPtr->cbWndExtra;
1271 wc->hInstance = classPtr->hInstance;
Alexandre Julliarda3960291999-02-26 11:11:13 +00001272 wc->hIcon = (HICON)classPtr->hIcon;
1273 wc->hIconSm = (HICON)classPtr->hIconSm;
1274 wc->hCursor = (HCURSOR)classPtr->hCursor;
1275 wc->hbrBackground = (HBRUSH)classPtr->hbrBackground;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001276 wc->lpszMenuName = CLASS_GetMenuNameA( classPtr );
Alexandre Julliard98779062000-12-07 23:39:16 +00001277 wc->lpszClassName = name;
1278
James Hatheway9fa09e72000-06-18 17:19:38 +00001279 /* We must return the atom of the class here instead of just TRUE. */
1280 return atom;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001281}
1282
1283
1284/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +00001285 * GetClassInfoExW (USER32.@)
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001286 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001287BOOL WINAPI GetClassInfoExW( HINSTANCE hInstance, LPCWSTR name,
1288 WNDCLASSEXW *wc )
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001289{
1290 ATOM atom;
1291 CLASS *classPtr;
1292
Alexandre Julliardaff7dda2002-11-22 21:22:14 +00001293 TRACE("%p %p %p\n",hInstance, name, wc);
Vincent Béron9a624912002-05-31 23:06:46 +00001294
Alexandre Julliarda3960291999-02-26 11:11:13 +00001295 if (!(atom = GlobalFindAtomW( name )) ||
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001296 !(classPtr = CLASS_FindClassByAtom( atom, hInstance )) ||
1297 (hInstance != classPtr->hInstance)) return FALSE;
1298 wc->style = classPtr->style;
Alexandre Julliard98779062000-12-07 23:39:16 +00001299 wc->lpfnWndProc = (WNDPROC)CLASS_GetProc( classPtr, WIN_PROC_32W );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001300 wc->cbClsExtra = classPtr->cbClsExtra;
1301 wc->cbWndExtra = classPtr->cbWndExtra;
1302 wc->hInstance = classPtr->hInstance;
Alexandre Julliarda3960291999-02-26 11:11:13 +00001303 wc->hIcon = (HICON)classPtr->hIcon;
1304 wc->hIconSm = (HICON)classPtr->hIconSm;
1305 wc->hCursor = (HCURSOR)classPtr->hCursor;
1306 wc->hbrBackground = (HBRUSH)classPtr->hbrBackground;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001307 wc->lpszMenuName = CLASS_GetMenuNameW( classPtr );
Alexandre Julliard98779062000-12-07 23:39:16 +00001308 wc->lpszClassName = name;
1309
James Hatheway9fa09e72000-06-18 17:19:38 +00001310 /* We must return the atom of the class here instead of just TRUE. */
1311 return atom;
Alexandre Julliard5f721f81994-01-04 20:14:34 +00001312}
Alexandre Julliarde2abbb11995-03-19 17:39:39 +00001313
1314
Alexandre Julliardf899ef02001-07-23 00:04:00 +00001315#if 0 /* toolhelp is in kernel, so this cannot work */
1316
Alexandre Julliarde2abbb11995-03-19 17:39:39 +00001317/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +00001318 * ClassFirst (TOOLHELP.69)
Alexandre Julliarde2abbb11995-03-19 17:39:39 +00001319 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001320BOOL16 WINAPI ClassFirst16( CLASSENTRY *pClassEntry )
Alexandre Julliarde2abbb11995-03-19 17:39:39 +00001321{
Alexandre Julliard359f497e1999-07-04 16:02:24 +00001322 TRACE("%p\n",pClassEntry);
Alexandre Julliard2ace16a1996-04-28 15:09:19 +00001323 pClassEntry->wNext = 1;
Alexandre Julliarda3960291999-02-26 11:11:13 +00001324 return ClassNext16( pClassEntry );
Alexandre Julliarde2abbb11995-03-19 17:39:39 +00001325}
1326
1327
1328/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +00001329 * ClassNext (TOOLHELP.70)
Alexandre Julliarde2abbb11995-03-19 17:39:39 +00001330 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001331BOOL16 WINAPI ClassNext16( CLASSENTRY *pClassEntry )
Alexandre Julliarde2abbb11995-03-19 17:39:39 +00001332{
Alexandre Julliard2ace16a1996-04-28 15:09:19 +00001333 int i;
1334 CLASS *class = firstClass;
Alexandre Julliarde2abbb11995-03-19 17:39:39 +00001335
Alexandre Julliard359f497e1999-07-04 16:02:24 +00001336 TRACE("%p\n",pClassEntry);
Vincent Béron9a624912002-05-31 23:06:46 +00001337
Alexandre Julliard2ace16a1996-04-28 15:09:19 +00001338 if (!pClassEntry->wNext) return FALSE;
1339 for (i = 1; (i < pClassEntry->wNext) && class; i++) class = class->next;
1340 if (!class)
1341 {
1342 pClassEntry->wNext = 0;
1343 return FALSE;
1344 }
Alexandre Julliard1285c2f1996-05-06 16:06:24 +00001345 pClassEntry->hInst = class->hInstance;
Alexandre Julliard2ace16a1996-04-28 15:09:19 +00001346 pClassEntry->wNext++;
Alexandre Julliarda3960291999-02-26 11:11:13 +00001347 GlobalGetAtomNameA( class->atomName, pClassEntry->szClassName,
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001348 sizeof(pClassEntry->szClassName) );
Alexandre Julliarde2abbb11995-03-19 17:39:39 +00001349 return TRUE;
1350}
Alexandre Julliardf899ef02001-07-23 00:04:00 +00001351#endif