blob: 2ea116120c6de9cce787f2d974ce173eef8e2777 [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 *
7 * FIXME: In win32 all classes are local. They are registered at
8 * program start. Processes CANNOT share classes. (Source: some
9 * win31->NT migration book)
Alexandre Julliard767e6f61998-08-09 12:47:43 +000010 *
11 * FIXME: There seems to be a general problem with hInstance in WINE
12 * classes are getting registred with wrong hInstance.
Alexandre Julliardbd34d4f1995-06-20 19:08:12 +000013 */
Alexandre Julliard401710d1993-09-04 10:09:32 +000014
Alexandre Julliard8d24ae61994-04-05 21:42:43 +000015#include <stdlib.h>
Alexandre Julliard8d24ae61994-04-05 21:42:43 +000016#include <string.h>
Marcus Meissner317af321999-02-17 13:51:06 +000017#include "wine/winbase16.h"
Alexandre Julliardc7e7df82000-08-14 14:41:19 +000018#include "winerror.h"
19#include "windef.h"
20#include "wingdi.h"
21#include "wine/winuser16.h"
22#include "wine/unicode.h"
Alexandre Julliard401710d1993-09-04 10:09:32 +000023#include "class.h"
Alexandre Julliard1285c2f1996-05-06 16:06:24 +000024#include "heap.h"
Alexandre Julliard401710d1993-09-04 10:09:32 +000025#include "win.h"
Alexandre Julliard5f721f81994-01-04 20:14:34 +000026#include "dce.h"
Alexandre Julliard808cb041995-08-17 17:11:36 +000027#include "ldt.h"
Alexandre Julliarde2abbb11995-03-19 17:39:39 +000028#include "toolhelp.h"
Alexandre Julliard2d93d001996-05-21 15:01:41 +000029#include "winproc.h"
Alexandre Julliard359f497e1999-07-04 16:02:24 +000030#include "debugtools.h"
Alexandre Julliard8d24ae61994-04-05 21:42:43 +000031
Alexandre Julliardc7e7df82000-08-14 14:41:19 +000032DEFAULT_DEBUG_CHANNEL(class);
Patrik Stridvallb4b9fae1999-04-19 14:56:29 +000033
Alexandre Julliard401710d1993-09-04 10:09:32 +000034
Alexandre Julliard2ace16a1996-04-28 15:09:19 +000035static CLASS *firstClass = NULL;
Alexandre Julliard401710d1993-09-04 10:09:32 +000036
37
38/***********************************************************************
Alexandre Julliardb817f4f1996-03-14 18:08:34 +000039 * CLASS_DumpClass
40 *
41 * Dump the content of a class structure to stderr.
42 */
Alexandre Julliard2ace16a1996-04-28 15:09:19 +000043void CLASS_DumpClass( CLASS *ptr )
Alexandre Julliardb817f4f1996-03-14 18:08:34 +000044{
Gavriel Statec77c5921998-11-15 09:21:17 +000045 char className[MAX_CLASSNAME+1];
Alexandre Julliardb817f4f1996-03-14 18:08:34 +000046 int i;
47
Alexandre Julliard1285c2f1996-05-06 16:06:24 +000048 if (ptr->magic != CLASS_MAGIC)
Alexandre Julliardb817f4f1996-03-14 18:08:34 +000049 {
Alexandre Julliard359f497e1999-07-04 16:02:24 +000050 DPRINTF("%p is not a class\n", ptr );
Alexandre Julliardb817f4f1996-03-14 18:08:34 +000051 return;
52 }
Alexandre Julliard2ace16a1996-04-28 15:09:19 +000053
Alexandre Julliarda3960291999-02-26 11:11:13 +000054 GlobalGetAtomNameA( ptr->atomName, className, sizeof(className) );
Alexandre Julliardb817f4f1996-03-14 18:08:34 +000055
Alexandre Julliard359f497e1999-07-04 16:02:24 +000056 DPRINTF( "Class %p:\n", ptr );
57 DPRINTF( "next=%p name=%04x '%s' style=%08x wndProc=%08x\n"
Alexandre Julliard2c69f6d1996-09-28 18:11:01 +000058 "inst=%04x dce=%08x icon=%04x cursor=%04x bkgnd=%04x\n"
Alexandre Julliardb817f4f1996-03-14 18:08:34 +000059 "clsExtra=%d winExtra=%d #windows=%d\n",
Alexandre Julliard1285c2f1996-05-06 16:06:24 +000060 ptr->next, ptr->atomName, className, ptr->style,
Alexandre Julliarda3960291999-02-26 11:11:13 +000061 (UINT)ptr->winproc, ptr->hInstance, (UINT)ptr->dce,
Alexandre Julliard1285c2f1996-05-06 16:06:24 +000062 ptr->hIcon, ptr->hCursor, ptr->hbrBackground,
63 ptr->cbClsExtra, ptr->cbWndExtra, ptr->cWindows );
64 if (ptr->cbClsExtra)
Alexandre Julliardb817f4f1996-03-14 18:08:34 +000065 {
Alexandre Julliard359f497e1999-07-04 16:02:24 +000066 DPRINTF( "extra bytes:" );
Alexandre Julliard1285c2f1996-05-06 16:06:24 +000067 for (i = 0; i < ptr->cbClsExtra; i++)
Alexandre Julliard359f497e1999-07-04 16:02:24 +000068 DPRINTF( " %02x", *((BYTE *)ptr->wExtra+i) );
69 DPRINTF( "\n" );
Alexandre Julliardb817f4f1996-03-14 18:08:34 +000070 }
Alexandre Julliard359f497e1999-07-04 16:02:24 +000071 DPRINTF( "\n" );
Alexandre Julliardb817f4f1996-03-14 18:08:34 +000072}
73
74
75/***********************************************************************
76 * CLASS_WalkClasses
77 *
78 * Walk the class list and print each class on stderr.
79 */
80void CLASS_WalkClasses(void)
81{
Alexandre Julliardb817f4f1996-03-14 18:08:34 +000082 CLASS *ptr;
Gavriel Statec77c5921998-11-15 09:21:17 +000083 char className[MAX_CLASSNAME+1];
Alexandre Julliardb817f4f1996-03-14 18:08:34 +000084
Alexandre Julliard359f497e1999-07-04 16:02:24 +000085 DPRINTF( " Class Name Style WndProc\n" );
Alexandre Julliard2ace16a1996-04-28 15:09:19 +000086 for (ptr = firstClass; ptr; ptr = ptr->next)
Alexandre Julliardb817f4f1996-03-14 18:08:34 +000087 {
Alexandre Julliarda3960291999-02-26 11:11:13 +000088 GlobalGetAtomNameA( ptr->atomName, className, sizeof(className) );
Alexandre Julliard359f497e1999-07-04 16:02:24 +000089 DPRINTF( "%08x %-20.20s %08x %08x\n", (UINT)ptr, className,
Alexandre Julliarda3960291999-02-26 11:11:13 +000090 ptr->style, (UINT)ptr->winproc );
Alexandre Julliardb817f4f1996-03-14 18:08:34 +000091 }
Alexandre Julliard359f497e1999-07-04 16:02:24 +000092 DPRINTF( "\n" );
Alexandre Julliardb817f4f1996-03-14 18:08:34 +000093}
94
95
96/***********************************************************************
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +000097 * CLASS_GetMenuNameA
98 *
99 * Get the menu name as a ASCII string.
100 */
101static LPSTR CLASS_GetMenuNameA( CLASS *classPtr )
102{
103 if (!classPtr->menuNameA && classPtr->menuNameW)
104 {
105 /* We need to copy the Unicode string */
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000106 classPtr->menuNameA = SEGPTR_STRDUP_WtoA( classPtr->menuNameW );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000107 }
108 return classPtr->menuNameA;
109}
110
111
112/***********************************************************************
113 * CLASS_GetMenuNameW
114 *
115 * Get the menu name as a Unicode string.
116 */
117static LPWSTR CLASS_GetMenuNameW( CLASS *classPtr )
118{
119 if (!classPtr->menuNameW && classPtr->menuNameA)
120 {
121 if (!HIWORD(classPtr->menuNameA))
122 return (LPWSTR)classPtr->menuNameA;
123 /* Now we need to copy the ASCII string */
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000124 classPtr->menuNameW = HEAP_strdupAtoW( SystemHeap, 0,
125 classPtr->menuNameA );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000126 }
127 return classPtr->menuNameW;
128}
129
130
131/***********************************************************************
132 * CLASS_SetMenuNameA
133 *
134 * Set the menu name in a class structure by copying the string.
135 */
136static void CLASS_SetMenuNameA( CLASS *classPtr, LPCSTR name )
137{
138 if (HIWORD(classPtr->menuNameA)) SEGPTR_FREE( classPtr->menuNameA );
139 if (classPtr->menuNameW) HeapFree( SystemHeap, 0, classPtr->menuNameW );
140 classPtr->menuNameA = SEGPTR_STRDUP( name );
141 classPtr->menuNameW = 0;
142}
143
144
145/***********************************************************************
146 * CLASS_SetMenuNameW
147 *
148 * Set the menu name in a class structure by copying the string.
149 */
150static void CLASS_SetMenuNameW( CLASS *classPtr, LPCWSTR name )
151{
152 if (!HIWORD(name))
153 {
154 CLASS_SetMenuNameA( classPtr, (LPCSTR)name );
155 return;
156 }
157 if (HIWORD(classPtr->menuNameA)) SEGPTR_FREE( classPtr->menuNameA );
158 if (classPtr->menuNameW) HeapFree( SystemHeap, 0, classPtr->menuNameW );
159 if ((classPtr->menuNameW = HeapAlloc( SystemHeap, 0,
Alexandre Julliardc7e7df82000-08-14 14:41:19 +0000160 (strlenW(name)+1)*sizeof(WCHAR) )))
161 strcpyW( classPtr->menuNameW, name );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000162 classPtr->menuNameA = 0;
163}
164
165
166/***********************************************************************
Gavriel Statec77c5921998-11-15 09:21:17 +0000167 * CLASS_GetClassNameA
168 *
169 * Get the clas name as a ASCII string.
170 */
171static LPSTR CLASS_GetClassNameA( CLASS *classPtr )
172{
173 if (!classPtr->classNameA && classPtr->classNameW)
174 {
175 /* We need to copy the Unicode string */
176 classPtr->classNameA = SEGPTR_STRDUP_WtoA( classPtr->classNameW );
177 }
178 return classPtr->classNameA;
179}
180
181
182/***********************************************************************
183 * CLASS_GetClassNameW
184 *
185 * Get the class name as a Unicode string.
186 */
187static LPWSTR CLASS_GetClassNameW( CLASS *classPtr )
188{
189 if (!classPtr->classNameW && classPtr->classNameA)
190 {
191 if (!HIWORD(classPtr->classNameA))
192 return (LPWSTR)classPtr->classNameA;
193 /* Now we need to copy the ASCII string */
194 classPtr->classNameW = HEAP_strdupAtoW( SystemHeap, 0,
195 classPtr->classNameA );
196 }
197 return classPtr->classNameW;
198}
199
200/***********************************************************************
201 * CLASS_SetClassNameA
202 *
203 * Set the class name in a class structure by copying the string.
204 */
205static void CLASS_SetClassNameA( CLASS *classPtr, LPCSTR name )
206{
207 if (HIWORD(classPtr->classNameA)) SEGPTR_FREE( classPtr->classNameA );
208 if (classPtr->classNameW) HeapFree( SystemHeap, 0, classPtr->classNameW );
209 classPtr->classNameA = SEGPTR_STRDUP( name );
210 classPtr->classNameW = 0;
211}
212
213
214/***********************************************************************
215 * CLASS_SetClassNameW
216 *
217 * Set the class name in a class structure by copying the string.
218 */
219static void CLASS_SetClassNameW( CLASS *classPtr, LPCWSTR name )
220{
221 if (!HIWORD(name))
222 {
223 CLASS_SetClassNameA( classPtr, (LPCSTR)name );
224 return;
225 }
226 if (HIWORD(classPtr->classNameA)) SEGPTR_FREE( classPtr->classNameA );
227 if (classPtr->classNameW) HeapFree( SystemHeap, 0, classPtr->classNameW );
228 if ((classPtr->classNameW = HeapAlloc( SystemHeap, 0,
Alexandre Julliardc7e7df82000-08-14 14:41:19 +0000229 (strlenW(name)+1)*sizeof(WCHAR) )))
230 strcpyW( classPtr->classNameW, name );
Gavriel Statec77c5921998-11-15 09:21:17 +0000231 classPtr->classNameA = 0;
232}
233
234
235/***********************************************************************
Alexandre Julliard2ace16a1996-04-28 15:09:19 +0000236 * CLASS_FreeClass
237 *
238 * Free a class structure.
239 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000240static BOOL CLASS_FreeClass( CLASS *classPtr )
Alexandre Julliard2ace16a1996-04-28 15:09:19 +0000241{
242 CLASS **ppClass;
Huw D M Davies2f245af2000-09-12 23:38:33 +0000243 TRACE("%p\n", classPtr);
Alexandre Julliard2ace16a1996-04-28 15:09:19 +0000244
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000245 /* Check if we can remove this class */
246
247 if (classPtr->cWindows > 0) return FALSE;
248
Alexandre Julliard2ace16a1996-04-28 15:09:19 +0000249 /* Remove the class from the linked list */
250
251 for (ppClass = &firstClass; *ppClass; ppClass = &(*ppClass)->next)
252 if (*ppClass == classPtr) break;
253 if (!*ppClass)
254 {
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000255 ERR("Class list corrupted\n" );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000256 return FALSE;
Alexandre Julliard2ace16a1996-04-28 15:09:19 +0000257 }
258 *ppClass = classPtr->next;
259
260 /* Delete the class */
261
Alexandre Julliard2c69f6d1996-09-28 18:11:01 +0000262 if (classPtr->dce) DCE_FreeDCE( classPtr->dce );
Huw D M Davies2f245af2000-09-12 23:38:33 +0000263 if (classPtr->hbrBackground > (HBRUSH)(COLOR_GRADIENTINACTIVECAPTION + 1))
264 DeleteObject( classPtr->hbrBackground );
Alexandre Julliard2ace16a1996-04-28 15:09:19 +0000265 GlobalDeleteAtom( classPtr->atomName );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000266 CLASS_SetMenuNameA( classPtr, NULL );
Gavriel Statec77c5921998-11-15 09:21:17 +0000267 CLASS_SetClassNameA( classPtr, NULL );
Alexandre Julliarddf2673b1997-03-29 17:20:20 +0000268 WINPROC_FreeProc( classPtr->winproc, WIN_PROC_CLASS );
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000269 HeapFree( SystemHeap, 0, classPtr );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000270 return TRUE;
Alexandre Julliard2ace16a1996-04-28 15:09:19 +0000271}
272
273
274/***********************************************************************
275 * CLASS_FreeModuleClasses
276 */
Alexandre Julliard3051b641996-07-05 17:14:13 +0000277void CLASS_FreeModuleClasses( HMODULE16 hModule )
Alexandre Julliard2ace16a1996-04-28 15:09:19 +0000278{
279 CLASS *ptr, *next;
280
Huw D M Davies2f245af2000-09-12 23:38:33 +0000281 TRACE("0x%08x\n", hModule);
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000282
Alexandre Julliard2ace16a1996-04-28 15:09:19 +0000283 for (ptr = firstClass; ptr; ptr = next)
284 {
285 next = ptr->next;
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000286 if (ptr->hInstance == hModule) CLASS_FreeClass( ptr );
Alexandre Julliard2ace16a1996-04-28 15:09:19 +0000287 }
288}
289
290
291/***********************************************************************
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000292 * CLASS_FindClassByAtom
293 *
294 * Return a pointer to the class.
Alexandre Julliard77b99181997-09-14 17:17:23 +0000295 * hinstance has been normalized by the caller.
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000296 *
297 * NOTES
298 * 980805 a local class will be found now if registred with hInst=0
299 * and looed up with a hInst!=0. msmoney does it (jsch)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000300 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000301CLASS *CLASS_FindClassByAtom( ATOM atom, HINSTANCE hinstance )
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000302{ CLASS * class, *tclass=0;
303
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000304 TRACE("0x%08x 0x%08x\n", atom, hinstance);
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000305
Alexandre Julliard77b99181997-09-14 17:17:23 +0000306 /* First search task-specific classes */
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000307
308 for (class = firstClass; (class); class = class->next)
309 {
310 if (class->style & CS_GLOBALCLASS) continue;
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000311 if (class->atomName == atom)
312 {
313 if (hinstance==class->hInstance || hinstance==0xffff )
314 {
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000315 TRACE("-- found local %p\n", class);
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000316 return class;
317 }
318 if (class->hInstance==0) tclass = class;
319 }
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000320 }
321
322 /* Then search global classes */
323
324 for (class = firstClass; (class); class = class->next)
325 {
326 if (!(class->style & CS_GLOBALCLASS)) continue;
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000327 if (class->atomName == atom)
328 {
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000329 TRACE("-- found global %p\n", class);
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000330 return class;
331 }
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000332 }
333
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000334 /* Then check if there was a local class with hInst=0*/
335 if ( tclass )
336 {
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000337 WARN("-- found local Class registred with hInst=0\n");
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000338 return tclass;
339 }
340
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000341 TRACE("-- not found\n");
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000342 return 0;
343}
344
345
346/***********************************************************************
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000347 * CLASS_RegisterClass
348 *
349 * The real RegisterClass() functionality.
350 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000351static CLASS *CLASS_RegisterClass( ATOM atom, HINSTANCE hInstance,
352 DWORD style, INT classExtra,
353 INT winExtra, WNDPROC16 wndProc,
Alexandre Julliard2d93d001996-05-21 15:01:41 +0000354 WINDOWPROCTYPE wndProcType )
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000355{
356 CLASS *classPtr;
357
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000358 TRACE("atom=0x%x hinst=0x%x style=0x%lx clExtr=0x%x winExtr=0x%x wndProc=0x%p ProcType=0x%x\n",
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000359 atom, hInstance, style, classExtra, winExtra, wndProc, wndProcType);
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000360
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000361 /* Check if a class with this name already exists */
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000362 classPtr = CLASS_FindClassByAtom( atom, hInstance );
363 if (classPtr)
364 {
365 /* Class can be created only if it is local and */
366 /* if the class with the same name is global. */
367
368 if (style & CS_GLOBALCLASS) return NULL;
369 if (!(classPtr->style & CS_GLOBALCLASS)) return NULL;
370 }
371
372 /* Fix the extra bytes value */
373
374 if (classExtra < 0) classExtra = 0;
375 else if (classExtra > 40) /* Extra bytes are limited to 40 in Win32 */
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000376 WARN("Class extra bytes %d is > 40\n", classExtra);
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000377 if (winExtra < 0) winExtra = 0;
378 else if (winExtra > 40) /* Extra bytes are limited to 40 in Win32 */
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000379 WARN("Win extra bytes %d is > 40\n", winExtra );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000380
381 /* Create the class */
382
383 classPtr = (CLASS *)HeapAlloc( SystemHeap, 0, sizeof(CLASS) +
384 classExtra - sizeof(classPtr->wExtra) );
385 if (!classPtr) return NULL;
Alexandre Julliard2d93d001996-05-21 15:01:41 +0000386 classPtr->next = firstClass;
387 classPtr->magic = CLASS_MAGIC;
388 classPtr->cWindows = 0;
389 classPtr->style = style;
Alexandre Julliard3051b641996-07-05 17:14:13 +0000390 classPtr->winproc = (HWINDOWPROC)0;
Alexandre Julliard2d93d001996-05-21 15:01:41 +0000391 classPtr->cbWndExtra = winExtra;
392 classPtr->cbClsExtra = classExtra;
393 classPtr->hInstance = hInstance;
394 classPtr->atomName = atom;
395 classPtr->menuNameA = 0;
396 classPtr->menuNameW = 0;
Rein Klazescb37dfd1998-11-22 14:13:47 +0000397 classPtr->classNameA = 0;
398 classPtr->classNameW = 0;
Alexandre Julliard2c69f6d1996-09-28 18:11:01 +0000399 classPtr->dce = (style & CS_CLASSDC) ?
400 DCE_AllocDCE( 0, DCE_CLASS_DC ) : NULL;
401
Gavriel Statec77c5921998-11-15 09:21:17 +0000402 WINPROC_SetProc( &classPtr->winproc, wndProc, wndProcType, WIN_PROC_CLASS);
Alexandre Julliard3051b641996-07-05 17:14:13 +0000403
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000404 /* Other values must be set by caller */
405
406 if (classExtra) memset( classPtr->wExtra, 0, classExtra );
407 firstClass = classPtr;
408 return classPtr;
409}
410
411
412/***********************************************************************
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000413 * RegisterClass16 (USER.57)
Alexandre Julliard401710d1993-09-04 10:09:32 +0000414 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000415ATOM WINAPI RegisterClass16( const WNDCLASS16 *wc )
Alexandre Julliard401710d1993-09-04 10:09:32 +0000416{
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000417 ATOM atom;
418 CLASS *classPtr;
Pierre Mageau4ac8db71999-09-04 11:16:48 +0000419 int iSmIconWidth, iSmIconHeight;
Alexandre Julliard77b99181997-09-14 17:17:23 +0000420 HINSTANCE16 hInstance=GetExePtr(wc->hInstance);
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000421
Alexandre Julliardb849d792000-02-13 13:56:13 +0000422 if (!(atom = GlobalAddAtomA( PTR_SEG_TO_LIN(wc->lpszClassName) ))) return 0;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000423 if (!(classPtr = CLASS_RegisterClass( atom, hInstance, wc->style,
Alexandre Julliard2d93d001996-05-21 15:01:41 +0000424 wc->cbClsExtra, wc->cbWndExtra,
Alexandre Julliard3051b641996-07-05 17:14:13 +0000425 wc->lpfnWndProc, WIN_PROC_16 )))
Alexandre Julliard5f721f81994-01-04 20:14:34 +0000426 {
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000427 GlobalDeleteAtom( atom );
428 return 0;
Alexandre Julliard5f721f81994-01-04 20:14:34 +0000429 }
430
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000431 TRACE("atom=%04x wndproc=%08lx hinst=%04x "
Patrik Stridvalla9a671d1999-04-25 19:01:52 +0000432 "bg=%04x style=%08x clsExt=%d winExt=%d class=%p name='%s'\n",
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000433 atom, (DWORD)wc->lpfnWndProc, hInstance,
434 wc->hbrBackground, wc->style, wc->cbClsExtra,
Alexandre Julliard641ee761997-08-04 16:34:36 +0000435 wc->cbWndExtra, classPtr,
436 HIWORD(wc->lpszClassName) ?
437 (char *)PTR_SEG_TO_LIN(wc->lpszClassName) : "" );
Alexandre Julliard5f721f81994-01-04 20:14:34 +0000438
Pierre Mageau4ac8db71999-09-04 11:16:48 +0000439 iSmIconWidth = GetSystemMetrics(SM_CXSMICON);
440 iSmIconHeight = GetSystemMetrics(SM_CYSMICON);
441
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000442 classPtr->hIcon = wc->hIcon;
Pierre Mageau4ac8db71999-09-04 11:16:48 +0000443 classPtr->hIconSm = CopyImage(wc->hIcon, IMAGE_ICON,
444 iSmIconWidth, iSmIconHeight,
445 LR_COPYFROMRESOURCE);
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000446 classPtr->hCursor = wc->hCursor;
447 classPtr->hbrBackground = wc->hbrBackground;
Alexandre Julliardf0b23541993-09-29 12:21:49 +0000448
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000449 CLASS_SetMenuNameA( classPtr, HIWORD(wc->lpszMenuName) ?
450 PTR_SEG_TO_LIN(wc->lpszMenuName) : (LPCSTR)wc->lpszMenuName );
Gavriel Statec77c5921998-11-15 09:21:17 +0000451 CLASS_SetClassNameA( classPtr, HIWORD(wc->lpszClassName) ?
452 PTR_SEG_TO_LIN(wc->lpszClassName) : (LPCSTR)wc->lpszClassName );
453
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000454 return atom;
Alexandre Julliard401710d1993-09-04 10:09:32 +0000455}
456
457
458/***********************************************************************
Patrik Stridvall2d6457c2000-03-28 20:22:59 +0000459 * RegisterClassA (USER32.427)
Alexandre Julliarda69b88b1998-03-15 20:29:56 +0000460 * RETURNS
461 * >0: Unique identifier
462 * 0: Failure
Alexandre Julliard401710d1993-09-04 10:09:32 +0000463 */
Alexandre Julliardf681cd02000-08-23 19:18:44 +0000464ATOM WINAPI RegisterClassA( const WNDCLASSA* wc ) /* Address of structure with class data */
465{
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000466 ATOM atom;
Pierre Mageau4ac8db71999-09-04 11:16:48 +0000467 int iSmIconWidth, iSmIconHeight;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000468 CLASS *classPtr;
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000469
Alexandre Julliardf681cd02000-08-23 19:18:44 +0000470 if (!(atom = GlobalAddAtomA( wc->lpszClassName ))) return 0;
471
Alexandre Julliard77b99181997-09-14 17:17:23 +0000472 if (!(classPtr = CLASS_RegisterClass( atom, wc->hInstance, wc->style,
Alexandre Julliard2d93d001996-05-21 15:01:41 +0000473 wc->cbClsExtra, wc->cbWndExtra,
Alexandre Julliard3051b641996-07-05 17:14:13 +0000474 (WNDPROC16)wc->lpfnWndProc,
Alexandre Julliard2d93d001996-05-21 15:01:41 +0000475 WIN_PROC_32A )))
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000476 { GlobalDeleteAtom( atom );
477 SetLastError(ERROR_CLASS_ALREADY_EXISTS);
478 return FALSE;
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000479 }
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000480
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000481 TRACE("atom=%04x wndproc=%08lx hinst=%04x bg=%04x style=%08x clsExt=%d winExt=%d class=%p name='%s'\n",
Alexandre Julliard77b99181997-09-14 17:17:23 +0000482 atom, (DWORD)wc->lpfnWndProc, wc->hInstance,
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000483 wc->hbrBackground, wc->style, wc->cbClsExtra,
Alexandre Julliard641ee761997-08-04 16:34:36 +0000484 wc->cbWndExtra, classPtr,
485 HIWORD(wc->lpszClassName) ? wc->lpszClassName : "" );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000486
Pierre Mageau4ac8db71999-09-04 11:16:48 +0000487 iSmIconWidth = GetSystemMetrics(SM_CXSMICON);
488 iSmIconHeight = GetSystemMetrics(SM_CYSMICON);
489
490 classPtr->hIcon = wc->hIcon;
491 classPtr->hIconSm = CopyImage(wc->hIcon, IMAGE_ICON,
492 iSmIconWidth, iSmIconHeight,
493 LR_COPYFROMRESOURCE);
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000494 classPtr->hCursor = (HCURSOR16)wc->hCursor;
495 classPtr->hbrBackground = (HBRUSH16)wc->hbrBackground;
Gavriel Statec77c5921998-11-15 09:21:17 +0000496
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000497 CLASS_SetMenuNameA( classPtr, wc->lpszMenuName );
Gavriel Statec77c5921998-11-15 09:21:17 +0000498 CLASS_SetClassNameA( classPtr, wc->lpszClassName );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000499 return atom;
500}
501
502
503/***********************************************************************
Patrik Stridvall2d6457c2000-03-28 20:22:59 +0000504 * RegisterClassW (USER32.430)
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000505 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000506ATOM WINAPI RegisterClassW( const WNDCLASSW* wc )
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000507{
508 ATOM atom;
Pierre Mageau4ac8db71999-09-04 11:16:48 +0000509 int iSmIconWidth, iSmIconHeight;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000510 CLASS *classPtr;
511
Alexandre Julliardf681cd02000-08-23 19:18:44 +0000512 if (!(atom = GlobalAddAtomW( wc->lpszClassName ))) return 0;
513
Alexandre Julliard77b99181997-09-14 17:17:23 +0000514 if (!(classPtr = CLASS_RegisterClass( atom, wc->hInstance, wc->style,
Alexandre Julliard2d93d001996-05-21 15:01:41 +0000515 wc->cbClsExtra, wc->cbWndExtra,
Alexandre Julliard3051b641996-07-05 17:14:13 +0000516 (WNDPROC16)wc->lpfnWndProc,
Alexandre Julliard2d93d001996-05-21 15:01:41 +0000517 WIN_PROC_32W )))
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000518 {
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000519 SetLastError(ERROR_CLASS_ALREADY_EXISTS);
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000520 GlobalDeleteAtom( atom );
521 return 0;
522 }
523
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000524 TRACE("atom=%04x wndproc=%08lx hinst=%04x bg=%04x style=%08x clsExt=%d winExt=%d class=%p\n",
Alexandre Julliard77b99181997-09-14 17:17:23 +0000525 atom, (DWORD)wc->lpfnWndProc, wc->hInstance,
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000526 wc->hbrBackground, wc->style, wc->cbClsExtra,
527 wc->cbWndExtra, classPtr );
528
Pierre Mageau4ac8db71999-09-04 11:16:48 +0000529 iSmIconWidth = GetSystemMetrics(SM_CXSMICON);
530 iSmIconHeight = GetSystemMetrics(SM_CYSMICON);
531
532 classPtr->hIcon = wc->hIcon;
533 classPtr->hIconSm = CopyImage(wc->hIcon, IMAGE_ICON,
534 iSmIconWidth, iSmIconHeight,
535 LR_COPYFROMRESOURCE);
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000536 classPtr->hCursor = (HCURSOR16)wc->hCursor;
537 classPtr->hbrBackground = (HBRUSH16)wc->hbrBackground;
Gavriel Statec77c5921998-11-15 09:21:17 +0000538
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000539 CLASS_SetMenuNameW( classPtr, wc->lpszMenuName );
Gavriel Statec77c5921998-11-15 09:21:17 +0000540 CLASS_SetClassNameW( classPtr, wc->lpszClassName );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000541 return atom;
542}
543
544
545/***********************************************************************
546 * RegisterClassEx16 (USER.397)
547 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000548ATOM WINAPI RegisterClassEx16( const WNDCLASSEX16 *wc )
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000549{
550 ATOM atom;
551 CLASS *classPtr;
Alexandre Julliard77b99181997-09-14 17:17:23 +0000552 HINSTANCE16 hInstance = GetExePtr( wc->hInstance );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000553
Alexandre Julliardb849d792000-02-13 13:56:13 +0000554 if (!(atom = GlobalAddAtomA( PTR_SEG_TO_LIN(wc->lpszClassName) ))) return 0;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000555 if (!(classPtr = CLASS_RegisterClass( atom, hInstance, wc->style,
Alexandre Julliard2d93d001996-05-21 15:01:41 +0000556 wc->cbClsExtra, wc->cbWndExtra,
Alexandre Julliard3051b641996-07-05 17:14:13 +0000557 wc->lpfnWndProc, WIN_PROC_16 )))
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000558 {
559 GlobalDeleteAtom( atom );
560 return 0;
561 }
562
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000563 TRACE("atom=%04x wndproc=%08lx hinst=%04x bg=%04x style=%08x clsExt=%d winExt=%d class=%p\n",
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000564 atom, (DWORD)wc->lpfnWndProc, hInstance,
565 wc->hbrBackground, wc->style, wc->cbClsExtra,
566 wc->cbWndExtra, classPtr );
567
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000568 classPtr->hIcon = wc->hIcon;
569 classPtr->hIconSm = wc->hIconSm;
570 classPtr->hCursor = wc->hCursor;
571 classPtr->hbrBackground = wc->hbrBackground;
572
573 CLASS_SetMenuNameA( classPtr, HIWORD(wc->lpszMenuName) ?
574 PTR_SEG_TO_LIN(wc->lpszMenuName) : (LPCSTR)wc->lpszMenuName );
Gavriel Statec77c5921998-11-15 09:21:17 +0000575 CLASS_SetClassNameA( classPtr, HIWORD(wc->lpszClassName) ?
576 PTR_SEG_TO_LIN(wc->lpszClassName) : (LPCSTR)wc->lpszClassName );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000577 return atom;
578}
579
580
581/***********************************************************************
Patrik Stridvall2d6457c2000-03-28 20:22:59 +0000582 * RegisterClassExA (USER32.428)
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000583 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000584ATOM WINAPI RegisterClassExA( const WNDCLASSEXA* wc )
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000585{
586 ATOM atom;
587 CLASS *classPtr;
588
Alexandre Julliardf681cd02000-08-23 19:18:44 +0000589 if (!(atom = GlobalAddAtomA( wc->lpszClassName ))) return 0;
590
Alexandre Julliard77b99181997-09-14 17:17:23 +0000591 if (!(classPtr = CLASS_RegisterClass( atom, wc->hInstance, wc->style,
Alexandre Julliard2d93d001996-05-21 15:01:41 +0000592 wc->cbClsExtra, wc->cbWndExtra,
Alexandre Julliard3051b641996-07-05 17:14:13 +0000593 (WNDPROC16)wc->lpfnWndProc,
Alexandre Julliard2d93d001996-05-21 15:01:41 +0000594 WIN_PROC_32A )))
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000595 {
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000596 SetLastError(ERROR_CLASS_ALREADY_EXISTS);
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000597 GlobalDeleteAtom( atom );
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000598 return FALSE;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000599 }
600
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000601 TRACE("atom=%04x wndproc=%08lx hinst=%04x bg=%04x style=%08x clsExt=%d winExt=%d class=%p\n",
Alexandre Julliard77b99181997-09-14 17:17:23 +0000602 atom, (DWORD)wc->lpfnWndProc, wc->hInstance,
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000603 wc->hbrBackground, wc->style, wc->cbClsExtra,
604 wc->cbWndExtra, classPtr );
605
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000606 classPtr->hIcon = (HICON16)wc->hIcon;
607 classPtr->hIconSm = (HICON16)wc->hIconSm;
608 classPtr->hCursor = (HCURSOR16)wc->hCursor;
609 classPtr->hbrBackground = (HBRUSH16)wc->hbrBackground;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000610 CLASS_SetMenuNameA( classPtr, wc->lpszMenuName );
Gavriel Statec77c5921998-11-15 09:21:17 +0000611 CLASS_SetClassNameA( classPtr, wc->lpszClassName );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000612 return atom;
613}
614
615
616/***********************************************************************
Patrik Stridvall2d6457c2000-03-28 20:22:59 +0000617 * RegisterClassExW (USER32.429)
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000618 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000619ATOM WINAPI RegisterClassExW( const WNDCLASSEXW* wc )
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000620{
621 ATOM atom;
622 CLASS *classPtr;
623
Alexandre Julliardf681cd02000-08-23 19:18:44 +0000624 if (!(atom = GlobalAddAtomW( wc->lpszClassName ))) return 0;
625
Alexandre Julliard77b99181997-09-14 17:17:23 +0000626 if (!(classPtr = CLASS_RegisterClass( atom, wc->hInstance, wc->style,
Alexandre Julliard2d93d001996-05-21 15:01:41 +0000627 wc->cbClsExtra, wc->cbWndExtra,
Alexandre Julliard3051b641996-07-05 17:14:13 +0000628 (WNDPROC16)wc->lpfnWndProc,
Alexandre Julliard2d93d001996-05-21 15:01:41 +0000629 WIN_PROC_32W )))
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000630 {
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000631 SetLastError(ERROR_CLASS_ALREADY_EXISTS);
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000632 GlobalDeleteAtom( atom );
633 return 0;
634 }
635
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000636 TRACE("atom=%04x wndproc=%08lx hinst=%04x bg=%04x style=%08x clsExt=%d winExt=%d class=%p\n",
Alexandre Julliard77b99181997-09-14 17:17:23 +0000637 atom, (DWORD)wc->lpfnWndProc, wc->hInstance,
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000638 wc->hbrBackground, wc->style, wc->cbClsExtra,
639 wc->cbWndExtra, classPtr );
640
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000641 classPtr->hIcon = (HICON16)wc->hIcon;
642 classPtr->hIconSm = (HICON16)wc->hIconSm;
643 classPtr->hCursor = (HCURSOR16)wc->hCursor;
644 classPtr->hbrBackground = (HBRUSH16)wc->hbrBackground;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000645 CLASS_SetMenuNameW( classPtr, wc->lpszMenuName );
Gavriel Statec77c5921998-11-15 09:21:17 +0000646 CLASS_SetClassNameW( classPtr, wc->lpszClassName );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000647 return atom;
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000648}
649
650
651/***********************************************************************
652 * UnregisterClass16 (USER.403)
653 */
Alexandre Julliardb849d792000-02-13 13:56:13 +0000654BOOL16 WINAPI UnregisterClass16( LPCSTR className, HINSTANCE16 hInstance )
Alexandre Julliard401710d1993-09-04 10:09:32 +0000655{
Alexandre Julliardb849d792000-02-13 13:56:13 +0000656 return UnregisterClassA( className, GetExePtr( hInstance ) );
Alexandre Julliard401710d1993-09-04 10:09:32 +0000657}
658
659
660/***********************************************************************
Patrik Stridvall2d6457c2000-03-28 20:22:59 +0000661 * UnregisterClassA (USER32.563)
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000662 *
Alexandre Julliard401710d1993-09-04 10:09:32 +0000663 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000664BOOL WINAPI UnregisterClassA( LPCSTR className, HINSTANCE hInstance )
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000665{ CLASS *classPtr;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000666 ATOM atom;
Alexandre Julliarda3960291999-02-26 11:11:13 +0000667 BOOL ret;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000668
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000669 TRACE("%s %x\n",debugres_a(className), hInstance);
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000670
Alexandre Julliarda3960291999-02-26 11:11:13 +0000671 if (!(atom = GlobalFindAtomA( className )))
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000672 {
673 SetLastError(ERROR_CLASS_DOES_NOT_EXIST);
674 return FALSE;
675 }
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000676 if (!(classPtr = CLASS_FindClassByAtom( atom, hInstance )) ||
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000677 (classPtr->hInstance != hInstance))
678 {
679 SetLastError(ERROR_CLASS_DOES_NOT_EXIST);
680 return FALSE;
681 }
682 if (!(ret = CLASS_FreeClass( classPtr )))
683 SetLastError(ERROR_CLASS_HAS_WINDOWS);
684 return ret;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000685}
686
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000687/***********************************************************************
Patrik Stridvall2d6457c2000-03-28 20:22:59 +0000688 * UnregisterClassW (USER32.564)
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000689 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000690BOOL WINAPI UnregisterClassW( LPCWSTR className, HINSTANCE hInstance )
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000691{ CLASS *classPtr;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000692 ATOM atom;
Alexandre Julliarda3960291999-02-26 11:11:13 +0000693 BOOL ret;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000694
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000695 TRACE("%s %x\n",debugres_w(className), hInstance);
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000696
Alexandre Julliarda3960291999-02-26 11:11:13 +0000697 if (!(atom = GlobalFindAtomW( className )))
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000698 {
699 SetLastError(ERROR_CLASS_DOES_NOT_EXIST);
700 return FALSE;
701 }
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000702 if (!(classPtr = CLASS_FindClassByAtom( atom, hInstance )) ||
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000703 (classPtr->hInstance != hInstance))
704 {
705 SetLastError(ERROR_CLASS_DOES_NOT_EXIST);
706 return FALSE;
707 }
708 if (!(ret = CLASS_FreeClass( classPtr )))
709 SetLastError(ERROR_CLASS_HAS_WINDOWS);
710 return ret;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000711}
712
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000713/***********************************************************************
Alexandre Julliard21979011997-03-05 08:22:35 +0000714 * GetClassWord16 (USER.129)
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000715 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000716WORD WINAPI GetClassWord16( HWND16 hwnd, INT16 offset )
Alexandre Julliard21979011997-03-05 08:22:35 +0000717{
Alexandre Julliarda3960291999-02-26 11:11:13 +0000718 return GetClassWord( hwnd, offset );
Alexandre Julliard21979011997-03-05 08:22:35 +0000719}
720
721
722/***********************************************************************
Patrik Stridvall2d6457c2000-03-28 20:22:59 +0000723 * GetClassWord (USER32.219)
Alexandre Julliard21979011997-03-05 08:22:35 +0000724 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000725WORD WINAPI GetClassWord( HWND hwnd, INT offset )
Alexandre Julliard401710d1993-09-04 10:09:32 +0000726{
Alexandre Julliard2ace16a1996-04-28 15:09:19 +0000727 WND * wndPtr;
Guy Albertelli2fa281f1999-04-24 11:54:40 +0000728 WORD retvalue = 0;
Alexandre Julliard2ace16a1996-04-28 15:09:19 +0000729
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000730 TRACE("%x %x\n",hwnd, offset);
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000731
Alexandre Julliard2ace16a1996-04-28 15:09:19 +0000732 if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return 0;
733 if (offset >= 0)
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000734 {
735 if (offset <= wndPtr->class->cbClsExtra - sizeof(WORD))
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000736 {
Guy Albertelli2fa281f1999-04-24 11:54:40 +0000737 retvalue = GET_WORD(((char *)wndPtr->class->wExtra) + offset);
738 goto END;
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000739 }
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000740 }
741 else switch(offset)
Alexandre Julliard2ace16a1996-04-28 15:09:19 +0000742 {
Guy Albertelli2fa281f1999-04-24 11:54:40 +0000743 case GCW_HBRBACKGROUND: retvalue = wndPtr->class->hbrBackground;
744 goto END;
745 case GCW_HCURSOR: retvalue = wndPtr->class->hCursor;
746 goto END;
747 case GCW_HICON: retvalue = wndPtr->class->hIcon;
748 goto END;
749 case GCW_HICONSM: retvalue = wndPtr->class->hIconSm;
750 goto END;
751 case GCW_ATOM: retvalue = wndPtr->class->atomName;
752 goto END;
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000753 case GCW_STYLE:
754 case GCW_CBWNDEXTRA:
755 case GCW_CBCLSEXTRA:
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000756 case GCW_HMODULE:
Guy Albertelli2fa281f1999-04-24 11:54:40 +0000757 retvalue = (WORD)GetClassLongA( hwnd, offset );
Phillip Ezolta1f092a2000-02-10 22:37:24 +0000758 goto END;
Alexandre Julliard2ace16a1996-04-28 15:09:19 +0000759 }
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000760
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000761 WARN("Invalid offset %d\n", offset);
Guy Albertelli2fa281f1999-04-24 11:54:40 +0000762 END:
763 WIN_ReleaseWndPtr(wndPtr);
764 return retvalue;
Alexandre Julliard401710d1993-09-04 10:09:32 +0000765}
766
767
768/***********************************************************************
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000769 * GetClassLong16 (USER.131)
Alexandre Julliard401710d1993-09-04 10:09:32 +0000770 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000771LONG WINAPI GetClassLong16( HWND16 hwnd, INT16 offset )
Alexandre Julliard401710d1993-09-04 10:09:32 +0000772{
Alexandre Julliard3051b641996-07-05 17:14:13 +0000773 WND *wndPtr;
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000774 LONG ret;
775
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000776 TRACE("%x %x\n",hwnd, offset);
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000777
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000778 switch( offset )
779 {
Alexandre Julliard3051b641996-07-05 17:14:13 +0000780 case GCL_WNDPROC:
781 if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return 0;
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000782 ret = (LONG)WINPROC_GetProc( wndPtr->class->winproc, WIN_PROC_16 );
783 WIN_ReleaseWndPtr(wndPtr);
784 return ret;
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000785 case GCL_MENUNAME:
Alexandre Julliarda3960291999-02-26 11:11:13 +0000786 ret = GetClassLongA( hwnd, offset );
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000787 return (LONG)SEGPTR_GET( (void *)ret );
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000788 default:
Alexandre Julliarda3960291999-02-26 11:11:13 +0000789 return GetClassLongA( hwnd, offset );
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000790 }
Alexandre Julliard401710d1993-09-04 10:09:32 +0000791}
792
793
794/***********************************************************************
Patrik Stridvall2d6457c2000-03-28 20:22:59 +0000795 * GetClassLongA (USER32.215)
Alexandre Julliard401710d1993-09-04 10:09:32 +0000796 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000797LONG WINAPI GetClassLongA( HWND hwnd, INT offset )
Alexandre Julliard401710d1993-09-04 10:09:32 +0000798{
Alexandre Julliard401710d1993-09-04 10:09:32 +0000799 WND * wndPtr;
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000800 LONG retvalue;
Alexandre Julliard401710d1993-09-04 10:09:32 +0000801
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000802 TRACE("%x %x\n",hwnd, offset);
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000803
Alexandre Julliard401710d1993-09-04 10:09:32 +0000804 if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return 0;
Alexandre Julliard2ace16a1996-04-28 15:09:19 +0000805 if (offset >= 0)
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000806 {
807 if (offset <= wndPtr->class->cbClsExtra - sizeof(LONG))
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000808 {
809 retvalue = GET_DWORD(((char *)wndPtr->class->wExtra) + offset);
810 goto END;
811 }
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000812 }
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000813
Alexandre Julliard2ace16a1996-04-28 15:09:19 +0000814 switch(offset)
815 {
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000816 case GCL_STYLE: retvalue = (LONG)wndPtr->class->style;
817 goto END;
818 case GCL_CBWNDEXTRA: retvalue = (LONG)wndPtr->class->cbWndExtra;
819 goto END;
820 case GCL_CBCLSEXTRA: retvalue = (LONG)wndPtr->class->cbClsExtra;
821 goto END;
822 case GCL_HMODULE: retvalue = (LONG)wndPtr->class->hInstance;
823 goto END;
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000824 case GCL_WNDPROC:
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000825 retvalue = (LONG)WINPROC_GetProc(wndPtr->class->winproc, WIN_PROC_32A);
826 goto END;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000827 case GCL_MENUNAME:
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000828 retvalue = (LONG)CLASS_GetMenuNameA( wndPtr->class );
829 goto END;
NF Stevensbe156661998-12-07 12:48:16 +0000830 case GCW_ATOM:
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000831 case GCL_HBRBACKGROUND:
832 case GCL_HCURSOR:
833 case GCL_HICON:
834 case GCL_HICONSM:
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000835 retvalue = GetClassWord( hwnd, offset );
836 goto END;
Alexandre Julliard2ace16a1996-04-28 15:09:19 +0000837 }
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000838 WARN("Invalid offset %d\n", offset);
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000839 retvalue = 0;
840END:
841 WIN_ReleaseWndPtr(wndPtr);
842 return retvalue;
Alexandre Julliard401710d1993-09-04 10:09:32 +0000843}
844
845
846/***********************************************************************
Patrik Stridvall2d6457c2000-03-28 20:22:59 +0000847 * GetClassLongW (USER32.216)
Alexandre Julliard401710d1993-09-04 10:09:32 +0000848 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000849LONG WINAPI GetClassLongW( HWND hwnd, INT offset )
Alexandre Julliard401710d1993-09-04 10:09:32 +0000850{
Alexandre Julliard401710d1993-09-04 10:09:32 +0000851 WND * wndPtr;
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000852 LONG retvalue;
Alexandre Julliard3051b641996-07-05 17:14:13 +0000853
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000854 TRACE("%x %x\n",hwnd, offset);
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000855
Alexandre Julliard3051b641996-07-05 17:14:13 +0000856 switch(offset)
857 {
858 case GCL_WNDPROC:
859 if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return 0;
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000860 retvalue = (LONG)WINPROC_GetProc( wndPtr->class->winproc, WIN_PROC_32W );
861 WIN_ReleaseWndPtr(wndPtr);
862 return retvalue;
Alexandre Julliard3051b641996-07-05 17:14:13 +0000863 case GCL_MENUNAME:
864 if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return 0;
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000865 retvalue = (LONG)CLASS_GetMenuNameW( wndPtr->class );
866 WIN_ReleaseWndPtr(wndPtr);
867 return retvalue;
Alexandre Julliard3051b641996-07-05 17:14:13 +0000868 default:
Alexandre Julliarda3960291999-02-26 11:11:13 +0000869 return GetClassLongA( hwnd, offset );
Alexandre Julliard3051b641996-07-05 17:14:13 +0000870 }
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000871}
872
873
874/***********************************************************************
Alexandre Julliard21979011997-03-05 08:22:35 +0000875 * SetClassWord16 (USER.130)
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000876 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000877WORD WINAPI SetClassWord16( HWND16 hwnd, INT16 offset, WORD newval )
Alexandre Julliard21979011997-03-05 08:22:35 +0000878{
Alexandre Julliarda3960291999-02-26 11:11:13 +0000879 return SetClassWord( hwnd, offset, newval );
Alexandre Julliard21979011997-03-05 08:22:35 +0000880}
881
882
883/***********************************************************************
Patrik Stridvall2d6457c2000-03-28 20:22:59 +0000884 * SetClassWord (USER32.469)
Alexandre Julliard21979011997-03-05 08:22:35 +0000885 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000886WORD WINAPI SetClassWord( HWND hwnd, INT offset, WORD newval )
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000887{
888 WND * wndPtr;
889 WORD retval = 0;
890 void *ptr;
Alexandre Julliard401710d1993-09-04 10:09:32 +0000891
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000892 TRACE("%x %x %x\n",hwnd, offset, newval);
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000893
Alexandre Julliard401710d1993-09-04 10:09:32 +0000894 if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return 0;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000895 if (offset >= 0)
896 {
Alexandre Julliard3051b641996-07-05 17:14:13 +0000897 if (offset + sizeof(WORD) <= wndPtr->class->cbClsExtra)
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000898 ptr = ((char *)wndPtr->class->wExtra) + offset;
Alexandre Julliard3051b641996-07-05 17:14:13 +0000899 else
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000900 {
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000901 WARN("Invalid offset %d\n", offset );
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000902 WIN_ReleaseWndPtr(wndPtr);
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000903 return 0;
904 }
905 }
Alexandre Julliard2ace16a1996-04-28 15:09:19 +0000906 else switch(offset)
907 {
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000908 case GCW_STYLE:
909 case GCW_CBWNDEXTRA:
910 case GCW_CBCLSEXTRA:
911 case GCW_HMODULE:
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000912 WIN_ReleaseWndPtr(wndPtr);
Alexandre Julliarda3960291999-02-26 11:11:13 +0000913 return (WORD)SetClassLongA( hwnd, offset, (LONG)newval );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000914 case GCW_HBRBACKGROUND: ptr = &wndPtr->class->hbrBackground; break;
915 case GCW_HCURSOR: ptr = &wndPtr->class->hCursor; break;
916 case GCW_HICON: ptr = &wndPtr->class->hIcon; break;
917 case GCW_HICONSM: ptr = &wndPtr->class->hIconSm; break;
918 case GCW_ATOM: ptr = &wndPtr->class->atomName; break;
Alexandre Julliard2ace16a1996-04-28 15:09:19 +0000919 default:
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000920 WARN("Invalid offset %d\n", offset);
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000921 WIN_ReleaseWndPtr(wndPtr);
Alexandre Julliard2ace16a1996-04-28 15:09:19 +0000922 return 0;
923 }
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000924 retval = GET_WORD(ptr);
925 PUT_WORD( ptr, newval );
Gavriel Statec77c5921998-11-15 09:21:17 +0000926
927 /* Note: If the GCW_ATOM was changed, this means that the WNDCLASS className fields
928 need to be updated as well. Problem is that we can't tell whether the atom is
929 using wide or narrow characters. For now, we'll just NULL out the className
930 fields, and emit a FIXME. */
931 if (offset == GCW_ATOM)
932 {
933 CLASS_SetClassNameA( wndPtr->class, NULL );
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000934 FIXME("GCW_ATOM changed for a class. Not updating className, so GetClassInfoEx may not return correct className!\n");
Gavriel Statec77c5921998-11-15 09:21:17 +0000935 }
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000936 WIN_ReleaseWndPtr(wndPtr);
Alexandre Julliard401710d1993-09-04 10:09:32 +0000937 return retval;
938}
Alexandre Julliard5f721f81994-01-04 20:14:34 +0000939
940
941/***********************************************************************
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000942 * SetClassLong16 (USER.132)
Alexandre Julliard5f721f81994-01-04 20:14:34 +0000943 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000944LONG WINAPI SetClassLong16( HWND16 hwnd, INT16 offset, LONG newval )
Alexandre Julliard5f721f81994-01-04 20:14:34 +0000945{
Alexandre Julliard2d93d001996-05-21 15:01:41 +0000946 WND *wndPtr;
Alexandre Julliard3051b641996-07-05 17:14:13 +0000947 LONG retval;
Alexandre Julliard2d93d001996-05-21 15:01:41 +0000948
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000949 TRACE("%x %x %lx\n",hwnd, offset, newval);
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000950
Alexandre Julliard2d93d001996-05-21 15:01:41 +0000951 switch(offset)
952 {
953 case GCL_WNDPROC:
954 if (!(wndPtr = WIN_FindWndPtr(hwnd))) return 0;
Alexandre Julliard3051b641996-07-05 17:14:13 +0000955 retval = (LONG)WINPROC_GetProc( wndPtr->class->winproc, WIN_PROC_16 );
956 WINPROC_SetProc( &wndPtr->class->winproc, (WNDPROC16)newval,
Alexandre Julliarddf2673b1997-03-29 17:20:20 +0000957 WIN_PROC_16, WIN_PROC_CLASS );
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000958 WIN_ReleaseWndPtr(wndPtr);
Alexandre Julliard3051b641996-07-05 17:14:13 +0000959 return retval;
Alexandre Julliard2d93d001996-05-21 15:01:41 +0000960 case GCL_MENUNAME:
Alexandre Julliarda3960291999-02-26 11:11:13 +0000961 return SetClassLongA( hwnd, offset, (LONG)PTR_SEG_TO_LIN(newval) );
Alexandre Julliard2d93d001996-05-21 15:01:41 +0000962 default:
Alexandre Julliarda3960291999-02-26 11:11:13 +0000963 return SetClassLongA( hwnd, offset, newval );
Alexandre Julliard2d93d001996-05-21 15:01:41 +0000964 }
Alexandre Julliard5f721f81994-01-04 20:14:34 +0000965}
966
967
968/***********************************************************************
Patrik Stridvall2d6457c2000-03-28 20:22:59 +0000969 * SetClassLongA (USER32.467)
Alexandre Julliard5f721f81994-01-04 20:14:34 +0000970 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000971LONG WINAPI SetClassLongA( HWND hwnd, INT offset, LONG newval )
Alexandre Julliard5f721f81994-01-04 20:14:34 +0000972{
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000973 WND * wndPtr;
974 LONG retval = 0;
975 void *ptr;
976
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000977 TRACE("%x %x %lx\n",hwnd, offset, newval);
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000978
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000979 if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return 0;
980 if (offset >= 0)
981 {
Alexandre Julliard3051b641996-07-05 17:14:13 +0000982 if (offset + sizeof(LONG) <= wndPtr->class->cbClsExtra)
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000983 ptr = ((char *)wndPtr->class->wExtra) + offset;
984 else
985 {
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000986 WARN("Invalid offset %d\n", offset );
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000987 retval = 0;
988 goto END;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000989 }
990 }
991 else switch(offset)
992 {
993 case GCL_MENUNAME:
994 CLASS_SetMenuNameA( wndPtr->class, (LPCSTR)newval );
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000995 retval = 0; /* Old value is now meaningless anyway */
996 goto END;
Alexandre Julliard2d93d001996-05-21 15:01:41 +0000997 case GCL_WNDPROC:
Alexandre Julliard3051b641996-07-05 17:14:13 +0000998 retval = (LONG)WINPROC_GetProc( wndPtr->class->winproc,
999 WIN_PROC_32A );
1000 WINPROC_SetProc( &wndPtr->class->winproc, (WNDPROC16)newval,
Alexandre Julliarddf2673b1997-03-29 17:20:20 +00001001 WIN_PROC_32A, WIN_PROC_CLASS );
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001002 goto END;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001003 case GCL_HBRBACKGROUND:
1004 case GCL_HCURSOR:
1005 case GCL_HICON:
1006 case GCL_HICONSM:
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001007 retval = SetClassWord( hwnd, offset, (WORD)newval );
1008 goto END;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001009 case GCL_STYLE: ptr = &wndPtr->class->style; break;
1010 case GCL_CBWNDEXTRA: ptr = &wndPtr->class->cbWndExtra; break;
1011 case GCL_CBCLSEXTRA: ptr = &wndPtr->class->cbClsExtra; break;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001012 case GCL_HMODULE: ptr = &wndPtr->class->hInstance; break;
1013 default:
Alexandre Julliard359f497e1999-07-04 16:02:24 +00001014 WARN("Invalid offset %d\n", offset );
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001015 retval = 0;
1016 goto END;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001017 }
1018 retval = GET_DWORD(ptr);
1019 PUT_DWORD( ptr, newval );
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001020END:
1021 WIN_ReleaseWndPtr(wndPtr);
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001022 return retval;
1023}
1024
1025
1026/***********************************************************************
Patrik Stridvall2d6457c2000-03-28 20:22:59 +00001027 * SetClassLongW (USER32.468)
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001028 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001029LONG WINAPI SetClassLongW( HWND hwnd, INT offset, LONG newval )
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001030{
1031 WND *wndPtr;
Alexandre Julliard3051b641996-07-05 17:14:13 +00001032 LONG retval;
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001033
Alexandre Julliard359f497e1999-07-04 16:02:24 +00001034 TRACE("%x %x %lx\n",hwnd, offset, newval);
Alexandre Julliard767e6f61998-08-09 12:47:43 +00001035
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001036 switch(offset)
1037 {
1038 case GCL_WNDPROC:
Alexandre Julliard3051b641996-07-05 17:14:13 +00001039 if (!(wndPtr = WIN_FindWndPtr(hwnd))) return 0;
1040 retval = (LONG)WINPROC_GetProc( wndPtr->class->winproc, WIN_PROC_32W );
1041 WINPROC_SetProc( &wndPtr->class->winproc, (WNDPROC16)newval,
Alexandre Julliarddf2673b1997-03-29 17:20:20 +00001042 WIN_PROC_32W, WIN_PROC_CLASS );
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001043 WIN_ReleaseWndPtr(wndPtr);
Alexandre Julliard3051b641996-07-05 17:14:13 +00001044 return retval;
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001045 case GCL_MENUNAME:
Alexandre Julliard3051b641996-07-05 17:14:13 +00001046 if (!(wndPtr = WIN_FindWndPtr(hwnd))) return 0;
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001047 CLASS_SetMenuNameW( wndPtr->class, (LPCWSTR)newval );
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001048 WIN_ReleaseWndPtr(wndPtr);
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001049 return 0; /* Old value is now meaningless anyway */
1050 default:
Alexandre Julliarda3960291999-02-26 11:11:13 +00001051 return SetClassLongA( hwnd, offset, newval );
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001052 }
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001053}
1054
1055
1056/***********************************************************************
1057 * GetClassName16 (USER.58)
1058 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +00001059INT16 WINAPI GetClassName16( HWND16 hwnd, LPSTR buffer, INT16 count )
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001060{
Alexandre Julliardb849d792000-02-13 13:56:13 +00001061 return GetClassNameA( hwnd, buffer, count );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001062}
1063
1064
1065/***********************************************************************
Patrik Stridvall2d6457c2000-03-28 20:22:59 +00001066 * GetClassNameA (USER32.217)
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001067 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001068INT WINAPI GetClassNameA( HWND hwnd, LPSTR buffer, INT count )
1069{ INT ret;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001070 WND *wndPtr;
Alexandre Julliard767e6f61998-08-09 12:47:43 +00001071
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001072 if (!(wndPtr = WIN_FindWndPtr(hwnd))) return 0;
Alexandre Julliarda3960291999-02-26 11:11:13 +00001073 ret = GlobalGetAtomNameA( wndPtr->class->atomName, buffer, count );
Alexandre Julliard767e6f61998-08-09 12:47:43 +00001074
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001075 WIN_ReleaseWndPtr(wndPtr);
Alexandre Julliard359f497e1999-07-04 16:02:24 +00001076 TRACE("%x %s %x\n",hwnd, buffer, count);
Alexandre Julliard767e6f61998-08-09 12:47:43 +00001077 return ret;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001078}
1079
1080
1081/***********************************************************************
Patrik Stridvall2d6457c2000-03-28 20:22:59 +00001082 * GetClassNameW (USER32.218)
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001083 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001084INT WINAPI GetClassNameW( HWND hwnd, LPWSTR buffer, INT count )
1085{ INT ret;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001086 WND *wndPtr;
Alexandre Julliard767e6f61998-08-09 12:47:43 +00001087
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001088 if (!(wndPtr = WIN_FindWndPtr(hwnd))) return 0;
Alexandre Julliarda3960291999-02-26 11:11:13 +00001089 ret = GlobalGetAtomNameW( wndPtr->class->atomName, buffer, count );
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001090 WIN_ReleaseWndPtr(wndPtr);
Alexandre Julliard359f497e1999-07-04 16:02:24 +00001091 TRACE("%x %s %x\n",hwnd, debugstr_w(buffer), count);
Alexandre Julliard767e6f61998-08-09 12:47:43 +00001092
1093 return ret;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001094}
1095
1096
1097/***********************************************************************
1098 * GetClassInfo16 (USER.404)
1099 */
Alexandre Julliardb849d792000-02-13 13:56:13 +00001100BOOL16 WINAPI GetClassInfo16( HINSTANCE16 hInstance, LPCSTR name, WNDCLASS16 *wc )
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001101{
1102 ATOM atom;
Alexandre Julliard5f721f81994-01-04 20:14:34 +00001103 CLASS *classPtr;
Alexandre Julliard3ed37e01994-11-07 18:20:42 +00001104
Alexandre Julliardb849d792000-02-13 13:56:13 +00001105 TRACE("%x %s %p\n",hInstance, debugres_a(name), wc);
Alexandre Julliard767e6f61998-08-09 12:47:43 +00001106
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001107 hInstance = GetExePtr( hInstance );
Alexandre Julliardb849d792000-02-13 13:56:13 +00001108 if (!(atom = GlobalFindAtomA( name )) ||
Alexandre Julliard670cdc41997-08-24 16:00:30 +00001109 !(classPtr = CLASS_FindClassByAtom( atom, hInstance )))
1110 return FALSE;
1111 if ((hInstance != classPtr->hInstance) &&
1112 !(classPtr->style & CS_GLOBALCLASS)) /*BWCC likes to pass hInstance=0*/
1113 return FALSE;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001114 wc->style = (UINT16)classPtr->style;
Alexandre Julliard3051b641996-07-05 17:14:13 +00001115 wc->lpfnWndProc = WINPROC_GetProc( classPtr->winproc, WIN_PROC_16 );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001116 wc->cbClsExtra = (INT16)classPtr->cbClsExtra;
1117 wc->cbWndExtra = (INT16)classPtr->cbWndExtra;
1118 wc->hInstance = (HINSTANCE16)classPtr->hInstance;
1119 wc->hIcon = classPtr->hIcon;
1120 wc->hCursor = classPtr->hCursor;
1121 wc->hbrBackground = classPtr->hbrBackground;
Gavriel Statec77c5921998-11-15 09:21:17 +00001122 wc->lpszClassName = (SEGPTR)CLASS_GetClassNameA( classPtr );;
NF Stevensa4066821998-12-01 08:29:29 +00001123 if (HIWORD(wc->lpszClassName)) /* Make it a SEGPTR */
1124 wc->lpszClassName = SEGPTR_GET( (LPSTR)wc->lpszClassName );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001125 wc->lpszMenuName = (SEGPTR)CLASS_GetMenuNameA( classPtr );
1126 if (HIWORD(wc->lpszMenuName)) /* Make it a SEGPTR */
1127 wc->lpszMenuName = SEGPTR_GET( (LPSTR)wc->lpszMenuName );
1128 return TRUE;
1129}
1130
1131
1132/***********************************************************************
Patrik Stridvall2d6457c2000-03-28 20:22:59 +00001133 * GetClassInfoA (USER32.211)
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001134 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001135BOOL WINAPI GetClassInfoA( HINSTANCE hInstance, LPCSTR name,
1136 WNDCLASSA *wc )
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001137{
1138 ATOM atom;
1139 CLASS *classPtr;
1140
Alexandre Julliard359f497e1999-07-04 16:02:24 +00001141 TRACE("%x %p %p\n",hInstance, name, wc);
Alexandre Julliard767e6f61998-08-09 12:47:43 +00001142
1143 /* workaround: if hInstance=NULL you expect to get the system classes
1144 but this classes (as example from comctl32.dll SysListView) won't be
Andreas Mohr2caee712000-07-16 15:44:22 +00001145 registered with hInstance=NULL in WINE because of the late loading
Alexandre Julliard767e6f61998-08-09 12:47:43 +00001146 of this dll. fixes file dialogs in WinWord95 (jsch)*/
1147
Alexandre Julliarda3960291999-02-26 11:11:13 +00001148 if (!(atom=GlobalFindAtomA(name)) || !(classPtr=CLASS_FindClassByAtom(atom,hInstance)))
Alexandre Julliard21979011997-03-05 08:22:35 +00001149 return FALSE;
1150
Noomen Hamza1040eaf2000-07-09 12:21:07 +00001151 if (!(classPtr->style & CS_GLOBALCLASS) &&
1152 classPtr->hInstance &&
1153 (hInstance != classPtr->hInstance))
Alexandre Julliard767e6f61998-08-09 12:47:43 +00001154 {
1155 if (hInstance) return FALSE;
Noomen Hamza1040eaf2000-07-09 12:21:07 +00001156 WARN("systemclass %s (hInst=0) demanded but only class with hInst!=0 found\n",name);
Alexandre Julliard767e6f61998-08-09 12:47:43 +00001157 }
1158
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001159 wc->style = classPtr->style;
Alexandre Julliarda3960291999-02-26 11:11:13 +00001160 wc->lpfnWndProc = (WNDPROC)WINPROC_GetProc( classPtr->winproc,
Alexandre Julliard3051b641996-07-05 17:14:13 +00001161 WIN_PROC_32A );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001162 wc->cbClsExtra = classPtr->cbClsExtra;
1163 wc->cbWndExtra = classPtr->cbWndExtra;
Noomen Hamza1040eaf2000-07-09 12:21:07 +00001164 wc->hInstance = hInstance;
Alexandre Julliarda3960291999-02-26 11:11:13 +00001165 wc->hIcon = (HICON)classPtr->hIcon;
1166 wc->hCursor = (HCURSOR)classPtr->hCursor;
1167 wc->hbrBackground = (HBRUSH)classPtr->hbrBackground;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001168 wc->lpszMenuName = CLASS_GetMenuNameA( classPtr );
Gavriel Statec77c5921998-11-15 09:21:17 +00001169 wc->lpszClassName = CLASS_GetClassNameA( classPtr );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001170 return TRUE;
1171}
1172
1173
1174/***********************************************************************
Patrik Stridvall2d6457c2000-03-28 20:22:59 +00001175 * GetClassInfoW (USER32.214)
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001176 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001177BOOL WINAPI GetClassInfoW( HINSTANCE hInstance, LPCWSTR name,
1178 WNDCLASSW *wc )
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001179{
1180 ATOM atom;
1181 CLASS *classPtr;
1182
Alexandre Julliard359f497e1999-07-04 16:02:24 +00001183 TRACE("%x %p %p\n",hInstance, name, wc);
Alexandre Julliard767e6f61998-08-09 12:47:43 +00001184
Marcus Meissner438062171999-09-03 12:28:20 +00001185 if ( !(atom=GlobalFindAtomW(name)) ||
1186 !(classPtr=CLASS_FindClassByAtom(atom,hInstance))
1187 )
Alexandre Julliard21979011997-03-05 08:22:35 +00001188 return FALSE;
1189
Noomen Hamza1040eaf2000-07-09 12:21:07 +00001190 if (!(classPtr->style & CS_GLOBALCLASS) &&
1191 classPtr->hInstance &&
1192 (hInstance != classPtr->hInstance))
1193 {
1194 if (hInstance) return FALSE;
1195 WARN("systemclass %s (hInst=0) demanded but only class with hInst!=0 found\n",debugstr_w(name));
Marcus Meissner438062171999-09-03 12:28:20 +00001196 }
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001197 wc->style = classPtr->style;
Alexandre Julliarda3960291999-02-26 11:11:13 +00001198 wc->lpfnWndProc = (WNDPROC)WINPROC_GetProc( classPtr->winproc,
Alexandre Julliard3051b641996-07-05 17:14:13 +00001199 WIN_PROC_32W );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001200 wc->cbClsExtra = classPtr->cbClsExtra;
1201 wc->cbWndExtra = classPtr->cbWndExtra;
Noomen Hamza1040eaf2000-07-09 12:21:07 +00001202 wc->hInstance = hInstance;
Alexandre Julliarda3960291999-02-26 11:11:13 +00001203 wc->hIcon = (HICON)classPtr->hIcon;
1204 wc->hCursor = (HCURSOR)classPtr->hCursor;
1205 wc->hbrBackground = (HBRUSH)classPtr->hbrBackground;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001206 wc->lpszMenuName = CLASS_GetMenuNameW( classPtr );
Gavriel Statec77c5921998-11-15 09:21:17 +00001207 wc->lpszClassName = CLASS_GetClassNameW( classPtr );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001208 return TRUE;
1209}
1210
1211
1212/***********************************************************************
1213 * GetClassInfoEx16 (USER.398)
1214 *
1215 * FIXME: this is just a guess, I have no idea if GetClassInfoEx() is the
1216 * same in Win16 as in Win32. --AJ
1217 */
Alexandre Julliardb849d792000-02-13 13:56:13 +00001218BOOL16 WINAPI GetClassInfoEx16( HINSTANCE16 hInstance, LPCSTR name, WNDCLASSEX16 *wc )
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001219{
1220 ATOM atom;
1221 CLASS *classPtr;
Alexandre Julliard808cb041995-08-17 17:11:36 +00001222
Alexandre Julliardb849d792000-02-13 13:56:13 +00001223 TRACE("%x %s %p\n",hInstance,debugres_a( name ), wc);
Alexandre Julliard767e6f61998-08-09 12:47:43 +00001224
Alexandre Julliard808cb041995-08-17 17:11:36 +00001225 hInstance = GetExePtr( hInstance );
Alexandre Julliardb849d792000-02-13 13:56:13 +00001226 if (!(atom = GlobalFindAtomA( name )) ||
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001227 !(classPtr = CLASS_FindClassByAtom( atom, hInstance )) ||
1228 (hInstance != classPtr->hInstance)) return FALSE;
1229 wc->style = classPtr->style;
Alexandre Julliard3051b641996-07-05 17:14:13 +00001230 wc->lpfnWndProc = WINPROC_GetProc( classPtr->winproc, WIN_PROC_16 );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001231 wc->cbClsExtra = (INT16)classPtr->cbClsExtra;
1232 wc->cbWndExtra = (INT16)classPtr->cbWndExtra;
1233 wc->hInstance = (HINSTANCE16)classPtr->hInstance;
1234 wc->hIcon = classPtr->hIcon;
1235 wc->hIconSm = classPtr->hIconSm;
1236 wc->hCursor = classPtr->hCursor;
1237 wc->hbrBackground = classPtr->hbrBackground;
1238 wc->lpszClassName = (SEGPTR)0;
1239 wc->lpszMenuName = (SEGPTR)CLASS_GetMenuNameA( classPtr );
1240 if (HIWORD(wc->lpszMenuName)) /* Make it a SEGPTR */
1241 wc->lpszMenuName = SEGPTR_GET( (LPSTR)wc->lpszMenuName );
Gavriel Statec77c5921998-11-15 09:21:17 +00001242 wc->lpszClassName = (SEGPTR)CLASS_GetClassNameA( classPtr );
1243 if (HIWORD(wc->lpszClassName)) /* Make it a SEGPTR */
1244 wc->lpszClassName = SEGPTR_GET( (LPSTR)wc->lpszClassName );
James Hatheway9fa09e72000-06-18 17:19:38 +00001245
1246 /* We must return the atom of the class here instead of just TRUE. */
1247 return atom;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001248}
Alexandre Julliard5f721f81994-01-04 20:14:34 +00001249
Alexandre Julliard1285c2f1996-05-06 16:06:24 +00001250
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001251/***********************************************************************
Patrik Stridvall2d6457c2000-03-28 20:22:59 +00001252 * GetClassInfoExA (USER32.212)
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001253 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001254BOOL WINAPI GetClassInfoExA( HINSTANCE hInstance, LPCSTR name,
1255 WNDCLASSEXA *wc )
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001256{
1257 ATOM atom;
1258 CLASS *classPtr;
1259
Alexandre Julliard359f497e1999-07-04 16:02:24 +00001260 TRACE("%x %p %p\n",hInstance, name, wc);
Alexandre Julliard767e6f61998-08-09 12:47:43 +00001261
Alexandre Julliarda3960291999-02-26 11:11:13 +00001262 if (!(atom = GlobalFindAtomA( name )) ||
Alexandre Julliarda0d77311998-09-13 16:32:00 +00001263 !(classPtr = CLASS_FindClassByAtom( atom, hInstance ))
1264 /*|| (hInstance != classPtr->hInstance) */ ) return FALSE;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001265 wc->style = classPtr->style;
Alexandre Julliarda3960291999-02-26 11:11:13 +00001266 wc->lpfnWndProc = (WNDPROC)WINPROC_GetProc( classPtr->winproc,
Alexandre Julliard3051b641996-07-05 17:14:13 +00001267 WIN_PROC_32A );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001268 wc->cbClsExtra = classPtr->cbClsExtra;
1269 wc->cbWndExtra = classPtr->cbWndExtra;
1270 wc->hInstance = classPtr->hInstance;
Alexandre Julliarda3960291999-02-26 11:11:13 +00001271 wc->hIcon = (HICON)classPtr->hIcon;
1272 wc->hIconSm = (HICON)classPtr->hIconSm;
1273 wc->hCursor = (HCURSOR)classPtr->hCursor;
1274 wc->hbrBackground = (HBRUSH)classPtr->hbrBackground;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001275 wc->lpszMenuName = CLASS_GetMenuNameA( classPtr );
Gavriel Statec77c5921998-11-15 09:21:17 +00001276 wc->lpszClassName = CLASS_GetClassNameA( classPtr );
James Hatheway9fa09e72000-06-18 17:19:38 +00001277
1278 /* We must return the atom of the class here instead of just TRUE. */
1279 return atom;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001280}
1281
1282
1283/***********************************************************************
Patrik Stridvall2d6457c2000-03-28 20:22:59 +00001284 * GetClassInfoExW (USER32.213)
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001285 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001286BOOL WINAPI GetClassInfoExW( HINSTANCE hInstance, LPCWSTR name,
1287 WNDCLASSEXW *wc )
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001288{
1289 ATOM atom;
1290 CLASS *classPtr;
1291
Alexandre Julliard359f497e1999-07-04 16:02:24 +00001292 TRACE("%x %p %p\n",hInstance, name, wc);
Alexandre Julliard767e6f61998-08-09 12:47:43 +00001293
Alexandre Julliarda3960291999-02-26 11:11:13 +00001294 if (!(atom = GlobalFindAtomW( name )) ||
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001295 !(classPtr = CLASS_FindClassByAtom( atom, hInstance )) ||
1296 (hInstance != classPtr->hInstance)) return FALSE;
1297 wc->style = classPtr->style;
Alexandre Julliarda3960291999-02-26 11:11:13 +00001298 wc->lpfnWndProc = (WNDPROC)WINPROC_GetProc( classPtr->winproc,
Alexandre Julliard3051b641996-07-05 17:14:13 +00001299 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 );
Gavriel Statec77c5921998-11-15 09:21:17 +00001308 wc->lpszClassName = CLASS_GetClassNameW( classPtr );;
James Hatheway9fa09e72000-06-18 17:19:38 +00001309
1310 /* 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
1315/***********************************************************************
1316 * ClassFirst (TOOLHELP.69)
1317 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001318BOOL16 WINAPI ClassFirst16( CLASSENTRY *pClassEntry )
Alexandre Julliarde2abbb11995-03-19 17:39:39 +00001319{
Alexandre Julliard359f497e1999-07-04 16:02:24 +00001320 TRACE("%p\n",pClassEntry);
Alexandre Julliard2ace16a1996-04-28 15:09:19 +00001321 pClassEntry->wNext = 1;
Alexandre Julliarda3960291999-02-26 11:11:13 +00001322 return ClassNext16( pClassEntry );
Alexandre Julliarde2abbb11995-03-19 17:39:39 +00001323}
1324
1325
1326/***********************************************************************
1327 * ClassNext (TOOLHELP.70)
1328 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001329BOOL16 WINAPI ClassNext16( CLASSENTRY *pClassEntry )
Alexandre Julliarde2abbb11995-03-19 17:39:39 +00001330{
Alexandre Julliard2ace16a1996-04-28 15:09:19 +00001331 int i;
1332 CLASS *class = firstClass;
Alexandre Julliarde2abbb11995-03-19 17:39:39 +00001333
Alexandre Julliard359f497e1999-07-04 16:02:24 +00001334 TRACE("%p\n",pClassEntry);
Alexandre Julliard767e6f61998-08-09 12:47:43 +00001335
Alexandre Julliard2ace16a1996-04-28 15:09:19 +00001336 if (!pClassEntry->wNext) return FALSE;
1337 for (i = 1; (i < pClassEntry->wNext) && class; i++) class = class->next;
1338 if (!class)
1339 {
1340 pClassEntry->wNext = 0;
1341 return FALSE;
1342 }
Alexandre Julliard1285c2f1996-05-06 16:06:24 +00001343 pClassEntry->hInst = class->hInstance;
Alexandre Julliard2ace16a1996-04-28 15:09:19 +00001344 pClassEntry->wNext++;
Alexandre Julliarda3960291999-02-26 11:11:13 +00001345 GlobalGetAtomNameA( class->atomName, pClassEntry->szClassName,
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001346 sizeof(pClassEntry->szClassName) );
Alexandre Julliarde2abbb11995-03-19 17:39:39 +00001347 return TRUE;
1348}