blob: 9272acf3bba1bb7fec518e3687f6b7345f7996bb [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 Julliarde37c6e12003-09-05 23:08:26 +000032#include <stdarg.h>
Alexandre Julliard8d24ae61994-04-05 21:42:43 +000033#include <stdlib.h>
Alexandre Julliard8d24ae61994-04-05 21:42:43 +000034#include <string.h>
Francois Gouget386cf6e2001-10-14 16:25:47 +000035
Marcus Meissner317af321999-02-17 13:51:06 +000036#include "wine/winbase16.h"
Alexandre Julliardc7e7df82000-08-14 14:41:19 +000037#include "winerror.h"
38#include "windef.h"
Alexandre Julliarde37c6e12003-09-05 23:08:26 +000039#include "winbase.h"
Alexandre Julliardc7e7df82000-08-14 14:41:19 +000040#include "wingdi.h"
41#include "wine/winuser16.h"
Alexandre Julliard0ca051e2002-10-17 16:43:42 +000042#include "wownt32.h"
Alexandre Julliardc7e7df82000-08-14 14:41:19 +000043#include "wine/unicode.h"
Alexandre Julliard401710d1993-09-04 10:09:32 +000044#include "win.h"
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +000045#include "user.h"
Alexandre Julliard91222da2000-12-10 23:01:33 +000046#include "controls.h"
Alexandre Julliard5f721f81994-01-04 20:14:34 +000047#include "dce.h"
Alexandre Julliard2d93d001996-05-21 15:01:41 +000048#include "winproc.h"
Alexandre Julliard0799c1a2002-03-09 23:29:33 +000049#include "wine/debug.h"
Alexandre Julliard8d24ae61994-04-05 21:42:43 +000050
Alexandre Julliard0799c1a2002-03-09 23:29:33 +000051WINE_DEFAULT_DEBUG_CHANNEL(class);
Patrik Stridvallb4b9fae1999-04-19 14:56:29 +000052
Alexandre Julliard98779062000-12-07 23:39:16 +000053typedef struct tagCLASS
54{
55 struct tagCLASS *next; /* Next class */
56 struct tagCLASS *prev; /* Prev class */
57 UINT cWindows; /* Count of existing windows */
58 UINT style; /* Class style */
Alexandre Julliard18d02972002-12-03 23:34:52 +000059 WNDPROC winprocA; /* Window procedure (ASCII) */
60 WNDPROC winprocW; /* Window procedure (Unicode) */
Alexandre Julliard98779062000-12-07 23:39:16 +000061 INT cbClsExtra; /* Class extra bytes */
62 INT cbWndExtra; /* Window extra bytes */
63 LPWSTR menuName; /* Default menu name (Unicode followed by ASCII) */
Alexandre Julliardd7b76822001-12-20 00:19:40 +000064 SEGPTR segMenuName; /* Default menu name as SEGPTR */
Alexandre Julliard98779062000-12-07 23:39:16 +000065 struct tagDCE *dce; /* Class DCE (if CS_CLASSDC) */
66 HINSTANCE hInstance; /* Module that created the task */
67 HICON hIcon; /* Default icon */
68 HICON hIconSm; /* Default small icon */
69 HCURSOR hCursor; /* Default cursor */
70 HBRUSH hbrBackground; /* Default background */
71 ATOM atomName; /* Name of the class */
Alexandre Julliard98779062000-12-07 23:39:16 +000072} CLASS;
Alexandre Julliard401710d1993-09-04 10:09:32 +000073
Alexandre Julliard98779062000-12-07 23:39:16 +000074static CLASS *firstClass;
Alexandre Julliard401710d1993-09-04 10:09:32 +000075
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +000076/***********************************************************************
77 * get_class_ptr
78 */
Alexandre Julliard8fd26b92001-10-15 17:56:45 +000079static CLASS *get_class_ptr( HWND hwnd, BOOL write_access )
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +000080{
Alexandre Julliard8fd26b92001-10-15 17:56:45 +000081 WND *ptr = WIN_GetPtr( hwnd );
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +000082
Alexandre Julliard8fd26b92001-10-15 17:56:45 +000083 if (ptr)
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +000084 {
Alexandre Julliard8fd26b92001-10-15 17:56:45 +000085 if (ptr != WND_OTHER_PROCESS) return ptr->class;
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +000086 if (IsWindow( hwnd )) /* check other processes */
87 {
Alexandre Julliard8fd26b92001-10-15 17:56:45 +000088 if (write_access)
89 {
90 /* modifying classes in other processes is not allowed */
91 SetLastError( ERROR_ACCESS_DENIED );
92 return NULL;
93 }
Alexandre Julliardaff7dda2002-11-22 21:22:14 +000094 FIXME( "reading from class of other process window %p\n", hwnd );
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +000095 /* DbgBreakPoint(); */
96 }
97 }
Alexandre Julliard8fd26b92001-10-15 17:56:45 +000098 SetLastError( ERROR_INVALID_WINDOW_HANDLE );
99 return NULL;
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000100}
101
102
103/***********************************************************************
104 * release_class_ptr
105 */
106inline static void release_class_ptr( CLASS *ptr )
107{
108 USER_Unlock();
109}
110
Alexandre Julliard401710d1993-09-04 10:09:32 +0000111
112/***********************************************************************
Alexandre Julliard98779062000-12-07 23:39:16 +0000113 * CLASS_GetProc
Alexandre Julliardb817f4f1996-03-14 18:08:34 +0000114 *
Alexandre Julliard98779062000-12-07 23:39:16 +0000115 * Get the class winproc for a given proc type
Alexandre Julliardb817f4f1996-03-14 18:08:34 +0000116 */
Alexandre Julliard98779062000-12-07 23:39:16 +0000117static WNDPROC16 CLASS_GetProc( CLASS *classPtr, WINDOWPROCTYPE type )
Alexandre Julliardb817f4f1996-03-14 18:08:34 +0000118{
Alexandre Julliard18d02972002-12-03 23:34:52 +0000119 WNDPROC proc = classPtr->winprocA;
Alexandre Julliardb817f4f1996-03-14 18:08:34 +0000120
Alexandre Julliard98779062000-12-07 23:39:16 +0000121 if (classPtr->winprocW)
Alexandre Julliardb817f4f1996-03-14 18:08:34 +0000122 {
Alexandre Julliard98779062000-12-07 23:39:16 +0000123 /* if we have a Unicode proc, use it if we have no ASCII proc
124 * or if we have both and Unicode was requested
125 */
126 if (!proc || type == WIN_PROC_32W) proc = classPtr->winprocW;
Alexandre Julliardb817f4f1996-03-14 18:08:34 +0000127 }
Alexandre Julliard98779062000-12-07 23:39:16 +0000128 return WINPROC_GetProc( proc, type );
Alexandre Julliardb817f4f1996-03-14 18:08:34 +0000129}
130
131
132/***********************************************************************
Alexandre Julliard98779062000-12-07 23:39:16 +0000133 * CLASS_SetProc
Alexandre Julliardb817f4f1996-03-14 18:08:34 +0000134 *
Alexandre Julliard98779062000-12-07 23:39:16 +0000135 * Set the class winproc for a given proc type.
136 * Returns the previous window proc.
Alexandre Julliardb817f4f1996-03-14 18:08:34 +0000137 */
Alexandre Julliard98779062000-12-07 23:39:16 +0000138static WNDPROC16 CLASS_SetProc( CLASS *classPtr, WNDPROC newproc, WINDOWPROCTYPE type )
Alexandre Julliardb817f4f1996-03-14 18:08:34 +0000139{
Alexandre Julliard18d02972002-12-03 23:34:52 +0000140 WNDPROC *proc = &classPtr->winprocA;
Alexandre Julliard98779062000-12-07 23:39:16 +0000141 WNDPROC16 ret;
Alexandre Julliardb817f4f1996-03-14 18:08:34 +0000142
Alexandre Julliard98779062000-12-07 23:39:16 +0000143 if (classPtr->winprocW)
Alexandre Julliardb817f4f1996-03-14 18:08:34 +0000144 {
Alexandre Julliard98779062000-12-07 23:39:16 +0000145 /* if we have a Unicode proc, use it if we have no ASCII proc
146 * or if we have both and Unicode was requested
147 */
148 if (!*proc || type == WIN_PROC_32W) proc = &classPtr->winprocW;
Alexandre Julliardb817f4f1996-03-14 18:08:34 +0000149 }
Alexandre Julliard98779062000-12-07 23:39:16 +0000150 ret = WINPROC_GetProc( *proc, type );
Alexandre Julliard18d02972002-12-03 23:34:52 +0000151 WINPROC_SetProc( proc, newproc, type, WIN_PROC_CLASS );
Alexandre Julliard98779062000-12-07 23:39:16 +0000152 /* now free the one that we didn't set */
153 if (classPtr->winprocA && classPtr->winprocW)
154 {
155 if (proc == &classPtr->winprocA)
156 {
157 WINPROC_FreeProc( classPtr->winprocW, WIN_PROC_CLASS );
158 classPtr->winprocW = 0;
159 }
160 else
161 {
162 WINPROC_FreeProc( classPtr->winprocA, WIN_PROC_CLASS );
163 classPtr->winprocA = 0;
164 }
165 }
166 return ret;
Alexandre Julliardb817f4f1996-03-14 18:08:34 +0000167}
168
169
170/***********************************************************************
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000171 * CLASS_GetMenuNameA
172 *
173 * Get the menu name as a ASCII string.
174 */
Alexandre Julliard98779062000-12-07 23:39:16 +0000175inline static LPSTR CLASS_GetMenuNameA( CLASS *classPtr )
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000176{
Alexandre Julliard98779062000-12-07 23:39:16 +0000177 if (!HIWORD(classPtr->menuName)) return (LPSTR)classPtr->menuName;
178 return (LPSTR)(classPtr->menuName + strlenW(classPtr->menuName) + 1);
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000179}
180
181
182/***********************************************************************
Alexandre Julliardd7b76822001-12-20 00:19:40 +0000183 * CLASS_GetMenuName16
184 *
185 * Get the menu name as a SEGPTR.
186 */
187inline static SEGPTR CLASS_GetMenuName16( CLASS *classPtr )
188{
189 if (!HIWORD(classPtr->menuName)) return (SEGPTR)classPtr->menuName;
190 if (!classPtr->segMenuName)
191 classPtr->segMenuName = MapLS( CLASS_GetMenuNameA(classPtr) );
192 return classPtr->segMenuName;
193}
194
195
196/***********************************************************************
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000197 * CLASS_GetMenuNameW
198 *
199 * Get the menu name as a Unicode string.
200 */
Alexandre Julliard98779062000-12-07 23:39:16 +0000201inline static LPWSTR CLASS_GetMenuNameW( CLASS *classPtr )
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000202{
Alexandre Julliard98779062000-12-07 23:39:16 +0000203 return classPtr->menuName;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000204}
205
206
207/***********************************************************************
208 * CLASS_SetMenuNameA
209 *
210 * Set the menu name in a class structure by copying the string.
211 */
212static void CLASS_SetMenuNameA( CLASS *classPtr, LPCSTR name )
213{
Alexandre Julliardd7b76822001-12-20 00:19:40 +0000214 UnMapLS( classPtr->segMenuName );
215 classPtr->segMenuName = 0;
216 if (HIWORD(classPtr->menuName)) HeapFree( GetProcessHeap(), 0, classPtr->menuName );
Alexandre Julliard98779062000-12-07 23:39:16 +0000217 if (HIWORD(name))
218 {
219 DWORD lenA = strlen(name) + 1;
220 DWORD lenW = MultiByteToWideChar( CP_ACP, 0, name, lenA, NULL, 0 );
Alexandre Julliardd7b76822001-12-20 00:19:40 +0000221 classPtr->menuName = HeapAlloc( GetProcessHeap(), 0, lenA + lenW*sizeof(WCHAR) );
Alexandre Julliard98779062000-12-07 23:39:16 +0000222 MultiByteToWideChar( CP_ACP, 0, name, lenA, classPtr->menuName, lenW );
223 memcpy( classPtr->menuName + lenW, name, lenA );
224 }
225 else classPtr->menuName = (LPWSTR)name;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000226}
227
228
229/***********************************************************************
230 * CLASS_SetMenuNameW
231 *
232 * Set the menu name in a class structure by copying the string.
233 */
234static void CLASS_SetMenuNameW( CLASS *classPtr, LPCWSTR name )
235{
Alexandre Julliardd7b76822001-12-20 00:19:40 +0000236 UnMapLS( classPtr->segMenuName );
237 classPtr->segMenuName = 0;
238 if (HIWORD(classPtr->menuName)) HeapFree( GetProcessHeap(), 0, classPtr->menuName );
Alexandre Julliard98779062000-12-07 23:39:16 +0000239 if (HIWORD(name))
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000240 {
Alexandre Julliard98779062000-12-07 23:39:16 +0000241 DWORD lenW = strlenW(name) + 1;
242 DWORD lenA = WideCharToMultiByte( CP_ACP, 0, name, lenW, NULL, 0, NULL, NULL );
Alexandre Julliardd7b76822001-12-20 00:19:40 +0000243 classPtr->menuName = HeapAlloc( GetProcessHeap(), 0, lenA + lenW*sizeof(WCHAR) );
Alexandre Julliard98779062000-12-07 23:39:16 +0000244 memcpy( classPtr->menuName, name, lenW*sizeof(WCHAR) );
245 WideCharToMultiByte( CP_ACP, 0, name, lenW,
246 (char *)(classPtr->menuName + lenW), lenA, NULL, NULL );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000247 }
Alexandre Julliard98779062000-12-07 23:39:16 +0000248 else classPtr->menuName = (LPWSTR)name;
Gavriel Statec77c5921998-11-15 09:21:17 +0000249}
250
251
252/***********************************************************************
Alexandre Julliard2ace16a1996-04-28 15:09:19 +0000253 * CLASS_FreeClass
254 *
255 * Free a class structure.
256 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000257static BOOL CLASS_FreeClass( CLASS *classPtr )
Alexandre Julliard2ace16a1996-04-28 15:09:19 +0000258{
Alexandre Julliard98779062000-12-07 23:39:16 +0000259 TRACE("%p\n", classPtr);
Alexandre Julliard2ace16a1996-04-28 15:09:19 +0000260
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000261 /* Check if we can remove this class */
262
Alexandre Julliard98779062000-12-07 23:39:16 +0000263 if (classPtr->cWindows > 0)
264 {
265 SetLastError( ERROR_CLASS_HAS_WINDOWS );
266 return FALSE;
267 }
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000268
Alexandre Julliard2ace16a1996-04-28 15:09:19 +0000269 /* Remove the class from the linked list */
270
Alexandre Julliard98779062000-12-07 23:39:16 +0000271 if (classPtr->next) classPtr->next->prev = classPtr->prev;
272 if (classPtr->prev) classPtr->prev->next = classPtr->next;
273 else firstClass = classPtr->next;
Alexandre Julliard2ace16a1996-04-28 15:09:19 +0000274
275 /* Delete the class */
276
Alexandre Julliard2c69f6d1996-09-28 18:11:01 +0000277 if (classPtr->dce) DCE_FreeDCE( classPtr->dce );
Huw D M Davies2f245af2000-09-12 23:38:33 +0000278 if (classPtr->hbrBackground > (HBRUSH)(COLOR_GRADIENTINACTIVECAPTION + 1))
279 DeleteObject( classPtr->hbrBackground );
Alexandre Julliard2ace16a1996-04-28 15:09:19 +0000280 GlobalDeleteAtom( classPtr->atomName );
Alexandre Julliard98779062000-12-07 23:39:16 +0000281 WINPROC_FreeProc( classPtr->winprocA, WIN_PROC_CLASS );
282 WINPROC_FreeProc( classPtr->winprocW, WIN_PROC_CLASS );
Alexandre Julliardd7b76822001-12-20 00:19:40 +0000283 UnMapLS( classPtr->segMenuName );
Alexandre Julliard98779062000-12-07 23:39:16 +0000284 HeapFree( GetProcessHeap(), 0, classPtr->menuName );
285 HeapFree( GetProcessHeap(), 0, classPtr );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000286 return TRUE;
Alexandre Julliard2ace16a1996-04-28 15:09:19 +0000287}
288
289
290/***********************************************************************
291 * CLASS_FreeModuleClasses
292 */
Alexandre Julliard3051b641996-07-05 17:14:13 +0000293void CLASS_FreeModuleClasses( HMODULE16 hModule )
Alexandre Julliard2ace16a1996-04-28 15:09:19 +0000294{
295 CLASS *ptr, *next;
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000296
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000297 TRACE("0x%08x\n", hModule);
298
299 USER_Lock();
Alexandre Julliard2ace16a1996-04-28 15:09:19 +0000300 for (ptr = firstClass; ptr; ptr = next)
301 {
302 next = ptr->next;
Alexandre Julliarda8a422f2002-11-22 20:43:01 +0000303 if (ptr->hInstance == HINSTANCE_32(hModule)) CLASS_FreeClass( ptr );
Alexandre Julliard2ace16a1996-04-28 15:09:19 +0000304 }
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000305 USER_Unlock();
Alexandre Julliard2ace16a1996-04-28 15:09:19 +0000306}
307
308
309/***********************************************************************
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000310 * CLASS_FindClassByAtom
311 *
312 * Return a pointer to the class.
Alexandre Julliard77b99181997-09-14 17:17:23 +0000313 * hinstance has been normalized by the caller.
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000314 *
315 * NOTES
316 * 980805 a local class will be found now if registred with hInst=0
317 * and looed up with a hInst!=0. msmoney does it (jsch)
Vincent Béron9a624912002-05-31 23:06:46 +0000318 *
319 * Local class registered with a USER instance handle are found as if
Joshua Thielend9ed57a2001-11-16 18:11:43 +0000320 * they were global classes.
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000321 */
Alexandre Julliard98779062000-12-07 23:39:16 +0000322static CLASS *CLASS_FindClassByAtom( ATOM atom, HINSTANCE hinstance )
323{
Joshua Thielend9ed57a2001-11-16 18:11:43 +0000324 CLASS * class, *tclass = 0, *user_class = 0;
325 HINSTANCE16 hUser = GetModuleHandle16("USER");
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000326
Alexandre Julliardaff7dda2002-11-22 21:22:14 +0000327 TRACE("0x%08x %p\n", atom, hinstance);
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000328
Alexandre Julliard77b99181997-09-14 17:17:23 +0000329 /* First search task-specific classes */
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000330
331 for (class = firstClass; (class); class = class->next)
332 {
333 if (class->style & CS_GLOBALCLASS) continue;
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000334 if (class->atomName == atom)
335 {
Alexandre Julliarda8a422f2002-11-22 20:43:01 +0000336 if (hinstance==class->hInstance || hinstance == (HINSTANCE)0xffff)
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000337 {
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000338 TRACE("-- found local %p\n", class);
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000339 return class;
340 }
Joshua Thielend9ed57a2001-11-16 18:11:43 +0000341 if (class->hInstance == 0) tclass = class;
Alexandre Julliarda8a422f2002-11-22 20:43:01 +0000342 else if(class->hInstance == HINSTANCE_32(hUser))
Joshua Thielend9ed57a2001-11-16 18:11:43 +0000343 {
344 user_class = class;
345 }
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000346 }
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000347 }
Vincent Béron9a624912002-05-31 23:06:46 +0000348
Joshua Thielend9ed57a2001-11-16 18:11:43 +0000349 /* Then search global classes */
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000350
351 for (class = firstClass; (class); class = class->next)
352 {
353 if (!(class->style & CS_GLOBALCLASS)) continue;
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000354 if (class->atomName == atom)
355 {
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000356 TRACE("-- found global %p\n", class);
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000357 return class;
358 }
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000359 }
360
Joshua Thielend9ed57a2001-11-16 18:11:43 +0000361 /* Check if there was a local class registered with USER */
362 if( user_class )
363 {
364 TRACE("--found local USER class %p\n", user_class);
365 return user_class;
366 }
367
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000368 /* Then check if there was a local class with hInst=0*/
369 if ( tclass )
370 {
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000371 WARN("-- found local Class registred with hInst=0\n");
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000372 return tclass;
373 }
Vincent Béron9a624912002-05-31 23:06:46 +0000374
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000375 TRACE("-- not found\n");
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000376 return 0;
377}
378
379
380/***********************************************************************
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000381 * CLASS_RegisterClass
382 *
383 * The real RegisterClass() functionality.
384 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000385static CLASS *CLASS_RegisterClass( ATOM atom, HINSTANCE hInstance,
Alexandre Julliard98779062000-12-07 23:39:16 +0000386 DWORD style, INT classExtra, INT winExtra )
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000387{
388 CLASS *classPtr;
389
Alexandre Julliardaff7dda2002-11-22 21:22:14 +0000390 TRACE("atom=0x%x hinst=%p style=0x%lx clExtr=0x%x winExtr=0x%x\n",
Alexandre Julliard98779062000-12-07 23:39:16 +0000391 atom, hInstance, style, classExtra, winExtra );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000392
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000393 /* Check if a class with this name already exists */
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000394 classPtr = CLASS_FindClassByAtom( atom, hInstance );
395 if (classPtr)
396 {
397 /* Class can be created only if it is local and */
398 /* if the class with the same name is global. */
399
Alexandre Julliard98779062000-12-07 23:39:16 +0000400 if ((style & CS_GLOBALCLASS) || !(classPtr->style & CS_GLOBALCLASS))
401 {
402 SetLastError( ERROR_CLASS_ALREADY_EXISTS );
403 return NULL;
404 }
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000405 }
406
407 /* Fix the extra bytes value */
408
409 if (classExtra < 0) classExtra = 0;
410 else if (classExtra > 40) /* Extra bytes are limited to 40 in Win32 */
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000411 WARN("Class extra bytes %d is > 40\n", classExtra);
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000412 if (winExtra < 0) winExtra = 0;
413 else if (winExtra > 40) /* Extra bytes are limited to 40 in Win32 */
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000414 WARN("Win extra bytes %d is > 40\n", winExtra );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000415
416 /* Create the class */
417
Alexandre Julliardd44e4952001-08-20 18:09:39 +0000418 classPtr = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(CLASS) + classExtra );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000419 if (!classPtr) return NULL;
Alexandre Julliard2d93d001996-05-21 15:01:41 +0000420 classPtr->style = style;
Alexandre Julliard2d93d001996-05-21 15:01:41 +0000421 classPtr->cbWndExtra = winExtra;
422 classPtr->cbClsExtra = classExtra;
423 classPtr->hInstance = hInstance;
424 classPtr->atomName = atom;
Alexandre Julliard98779062000-12-07 23:39:16 +0000425 classPtr->dce = (style & CS_CLASSDC) ? DCE_AllocDCE( 0, DCE_CLASS_DC ) : NULL;
Alexandre Julliard2c69f6d1996-09-28 18:11:01 +0000426
Alexandre Julliard98779062000-12-07 23:39:16 +0000427 /* Other non-null values must be set by caller */
Alexandre Julliard3051b641996-07-05 17:14:13 +0000428
Alexandre Julliard98779062000-12-07 23:39:16 +0000429 if ((classPtr->next = firstClass)) firstClass->prev = classPtr;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000430 firstClass = classPtr;
431 return classPtr;
432}
433
434
435/***********************************************************************
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000436 * CLASS_UnregisterClass
437 *
438 * The real UnregisterClass() functionality.
439 */
440static BOOL CLASS_UnregisterClass( ATOM atom, HINSTANCE hInstance )
441{
442 CLASS *classPtr;
443 BOOL ret = FALSE;
444
445 USER_Lock();
446 if (atom &&
447 (classPtr = CLASS_FindClassByAtom( atom, hInstance )) &&
Bill Medland0ca07c92001-11-20 18:53:16 +0000448 (!hInstance || classPtr->hInstance == hInstance))
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000449 {
450 ret = CLASS_FreeClass( classPtr );
451 }
452 else SetLastError( ERROR_CLASS_DOES_NOT_EXIST );
453
454 USER_Unlock();
455 return ret;
456}
457
458
459/***********************************************************************
Alexandre Julliard98779062000-12-07 23:39:16 +0000460 * CLASS_RegisterBuiltinClass
461 *
462 * Register a builtin control class.
463 * This allows having both ASCII and Unicode winprocs for the same class.
464 */
Alexandre Julliard91222da2000-12-10 23:01:33 +0000465ATOM CLASS_RegisterBuiltinClass( const struct builtin_class_descr *descr )
Alexandre Julliard98779062000-12-07 23:39:16 +0000466{
467 ATOM atom;
468 CLASS *classPtr;
469
Alexandre Julliard91222da2000-12-10 23:01:33 +0000470 if (!(atom = GlobalAddAtomA( descr->name ))) return 0;
Alexandre Julliard98779062000-12-07 23:39:16 +0000471
Alexandre Julliard91222da2000-12-10 23:01:33 +0000472 if (!(classPtr = CLASS_RegisterClass( atom, 0, descr->style, 0, descr->extra )))
Alexandre Julliard98779062000-12-07 23:39:16 +0000473 {
474 GlobalDeleteAtom( atom );
475 return 0;
476 }
477
Alexandre Julliardcf526442003-09-10 03:56:47 +0000478 classPtr->hCursor = LoadCursorA( 0, (LPSTR)descr->cursor );
Alexandre Julliard91222da2000-12-10 23:01:33 +0000479 classPtr->hbrBackground = descr->brush;
Alexandre Julliard98779062000-12-07 23:39:16 +0000480
Alexandre Julliard18d02972002-12-03 23:34:52 +0000481 if (descr->procA) WINPROC_SetProc( &classPtr->winprocA, descr->procA,
Alexandre Julliard91222da2000-12-10 23:01:33 +0000482 WIN_PROC_32A, WIN_PROC_CLASS );
Alexandre Julliard18d02972002-12-03 23:34:52 +0000483 if (descr->procW) WINPROC_SetProc( &classPtr->winprocW, descr->procW,
Alexandre Julliard91222da2000-12-10 23:01:33 +0000484 WIN_PROC_32W, WIN_PROC_CLASS );
Alexandre Julliard98779062000-12-07 23:39:16 +0000485 return atom;
486}
487
488
489/***********************************************************************
490 * CLASS_AddWindow
491 *
492 * Add a new window using this class, and return the necessary
493 * information for creating the window.
494 */
495CLASS *CLASS_AddWindow( ATOM atom, HINSTANCE inst, WINDOWPROCTYPE type,
496 INT *winExtra, WNDPROC *winproc, DWORD *style, struct tagDCE **dce )
497{
498 CLASS *class;
Alexandre Julliarda8a422f2002-11-22 20:43:01 +0000499 if (type == WIN_PROC_16) inst = HINSTANCE_32(GetExePtr(HINSTANCE_16(inst)));
Alexandre Julliard98779062000-12-07 23:39:16 +0000500
501 if (!(class = CLASS_FindClassByAtom( atom, inst ))) return NULL;
502 class->cWindows++;
503
504 if (type == WIN_PROC_32W)
505 {
506 if (!(*winproc = class->winprocW)) *winproc = class->winprocA;
507 }
508 else
509 {
510 if (!(*winproc = class->winprocA)) *winproc = class->winprocW;
511 }
512 *winExtra = class->cbWndExtra;
513 *style = class->style;
514 *dce = class->dce;
515 return class;
516}
517
518
519/***********************************************************************
520 * CLASS_RemoveWindow
521 *
522 * Remove a window from the class window count.
523 */
524void CLASS_RemoveWindow( CLASS *cls )
525{
526 if (cls && cls->cWindows) cls->cWindows--;
527}
528
529
530/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +0000531 * RegisterClass (USER.57)
Alexandre Julliard401710d1993-09-04 10:09:32 +0000532 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000533ATOM WINAPI RegisterClass16( const WNDCLASS16 *wc )
Alexandre Julliard401710d1993-09-04 10:09:32 +0000534{
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000535 ATOM atom;
536 CLASS *classPtr;
Pierre Mageau4ac8db71999-09-04 11:16:48 +0000537 int iSmIconWidth, iSmIconHeight;
Alexandre Julliarda8a422f2002-11-22 20:43:01 +0000538 HINSTANCE hInstance = HINSTANCE_32(GetExePtr(wc->hInstance));
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000539
Alexandre Julliard982a2232000-12-13 20:20:09 +0000540 if (!(atom = GlobalAddAtomA( MapSL(wc->lpszClassName) ))) return 0;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000541 if (!(classPtr = CLASS_RegisterClass( atom, hInstance, wc->style,
Alexandre Julliard98779062000-12-07 23:39:16 +0000542 wc->cbClsExtra, wc->cbWndExtra )))
Alexandre Julliard5f721f81994-01-04 20:14:34 +0000543 {
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000544 GlobalDeleteAtom( atom );
545 return 0;
Alexandre Julliard5f721f81994-01-04 20:14:34 +0000546 }
547
Alexandre Julliardaff7dda2002-11-22 21:22:14 +0000548 TRACE("atom=%04x wndproc=%08lx hinst=%p bg=%04x style=%08x clsExt=%d winExt=%d class=%p name='%s'\n",
549 atom, (DWORD)wc->lpfnWndProc, hInstance,
550 wc->hbrBackground, wc->style, wc->cbClsExtra,
551 wc->cbWndExtra, classPtr,
552 HIWORD(wc->lpszClassName) ? (char *)MapSL(wc->lpszClassName) : "" );
Alexandre Julliard5f721f81994-01-04 20:14:34 +0000553
Pierre Mageau4ac8db71999-09-04 11:16:48 +0000554 iSmIconWidth = GetSystemMetrics(SM_CXSMICON);
555 iSmIconHeight = GetSystemMetrics(SM_CYSMICON);
556
Michael Stefaniucbc54d782002-10-10 21:22:09 +0000557 classPtr->hIcon = HICON_32(wc->hIcon);
Alexandre Julliarda8a422f2002-11-22 20:43:01 +0000558 classPtr->hIconSm = CopyImage(classPtr->hIcon, IMAGE_ICON,
Pierre Mageau4ac8db71999-09-04 11:16:48 +0000559 iSmIconWidth, iSmIconHeight,
560 LR_COPYFROMRESOURCE);
Michael Stefaniucbc54d782002-10-10 21:22:09 +0000561 classPtr->hCursor = HCURSOR_32(wc->hCursor);
562 classPtr->hbrBackground = HBRUSH_32(wc->hbrBackground);
Alexandre Julliardf0b23541993-09-29 12:21:49 +0000563
Alexandre Julliard18d02972002-12-03 23:34:52 +0000564 WINPROC_SetProc( &classPtr->winprocA, (WNDPROC)wc->lpfnWndProc,
Alexandre Julliard98779062000-12-07 23:39:16 +0000565 WIN_PROC_16, WIN_PROC_CLASS );
Alexandre Julliard982a2232000-12-13 20:20:09 +0000566 CLASS_SetMenuNameA( classPtr, MapSL(wc->lpszMenuName) );
Gavriel Statec77c5921998-11-15 09:21:17 +0000567
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000568 return atom;
Alexandre Julliard401710d1993-09-04 10:09:32 +0000569}
570
571
572/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +0000573 * RegisterClassA (USER32.@)
Alexandre Julliarda69b88b1998-03-15 20:29:56 +0000574 * RETURNS
575 * >0: Unique identifier
576 * 0: Failure
Alexandre Julliard401710d1993-09-04 10:09:32 +0000577 */
Patrik Stridvall2b3aa612000-12-01 23:58:28 +0000578ATOM WINAPI RegisterClassA( const WNDCLASSA* wc ) /* [in] Address of structure with class data */
Alexandre Julliardf681cd02000-08-23 19:18:44 +0000579{
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000580 ATOM atom;
Pierre Mageau4ac8db71999-09-04 11:16:48 +0000581 int iSmIconWidth, iSmIconHeight;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000582 CLASS *classPtr;
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000583
Alexandre Julliardf681cd02000-08-23 19:18:44 +0000584 if (!(atom = GlobalAddAtomA( wc->lpszClassName ))) return 0;
585
Alexandre Julliard77b99181997-09-14 17:17:23 +0000586 if (!(classPtr = CLASS_RegisterClass( atom, wc->hInstance, wc->style,
Alexandre Julliard98779062000-12-07 23:39:16 +0000587 wc->cbClsExtra, wc->cbWndExtra )))
588 {
589 GlobalDeleteAtom( atom );
590 return 0;
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000591 }
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000592
Alexandre Julliardaff7dda2002-11-22 21:22:14 +0000593 TRACE("atom=%04x wndproc=%p hinst=%p bg=%p style=%08x clsExt=%d winExt=%d class=%p name='%s'\n",
594 atom, wc->lpfnWndProc, wc->hInstance,
595 wc->hbrBackground, wc->style, wc->cbClsExtra,
596 wc->cbWndExtra, classPtr,
597 HIWORD(wc->lpszClassName) ? wc->lpszClassName : "" );
Vincent Béron9a624912002-05-31 23:06:46 +0000598
Pierre Mageau4ac8db71999-09-04 11:16:48 +0000599 iSmIconWidth = GetSystemMetrics(SM_CXSMICON);
600 iSmIconHeight = GetSystemMetrics(SM_CYSMICON);
Vincent Béron9a624912002-05-31 23:06:46 +0000601
Pierre Mageau4ac8db71999-09-04 11:16:48 +0000602 classPtr->hIcon = wc->hIcon;
603 classPtr->hIconSm = CopyImage(wc->hIcon, IMAGE_ICON,
604 iSmIconWidth, iSmIconHeight,
605 LR_COPYFROMRESOURCE);
Michael Stefaniucbc54d782002-10-10 21:22:09 +0000606 classPtr->hCursor = wc->hCursor;
607 classPtr->hbrBackground = wc->hbrBackground;
Alexandre Julliard98779062000-12-07 23:39:16 +0000608
Alexandre Julliard18d02972002-12-03 23:34:52 +0000609 WINPROC_SetProc( &classPtr->winprocA, wc->lpfnWndProc,
Alexandre Julliard98779062000-12-07 23:39:16 +0000610 WIN_PROC_32A, WIN_PROC_CLASS );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000611 CLASS_SetMenuNameA( classPtr, wc->lpszMenuName );
612 return atom;
613}
614
615
616/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +0000617 * RegisterClassW (USER32.@)
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000618 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000619ATOM WINAPI RegisterClassW( const WNDCLASSW* wc )
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000620{
621 ATOM atom;
Pierre Mageau4ac8db71999-09-04 11:16:48 +0000622 int iSmIconWidth, iSmIconHeight;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000623 CLASS *classPtr;
624
Alexandre Julliardf681cd02000-08-23 19:18:44 +0000625 if (!(atom = GlobalAddAtomW( wc->lpszClassName ))) return 0;
626
Alexandre Julliard77b99181997-09-14 17:17:23 +0000627 if (!(classPtr = CLASS_RegisterClass( atom, wc->hInstance, wc->style,
Alexandre Julliard98779062000-12-07 23:39:16 +0000628 wc->cbClsExtra, wc->cbWndExtra )))
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000629 {
630 GlobalDeleteAtom( atom );
631 return 0;
632 }
633
Alexandre Julliardaff7dda2002-11-22 21:22:14 +0000634 TRACE("atom=%04x wndproc=%p hinst=%p bg=%p style=%08x clsExt=%d winExt=%d class=%p\n",
635 atom, wc->lpfnWndProc, wc->hInstance,
636 wc->hbrBackground, wc->style, wc->cbClsExtra,
637 wc->cbWndExtra, classPtr );
Vincent Béron9a624912002-05-31 23:06:46 +0000638
Pierre Mageau4ac8db71999-09-04 11:16:48 +0000639 iSmIconWidth = GetSystemMetrics(SM_CXSMICON);
640 iSmIconHeight = GetSystemMetrics(SM_CYSMICON);
641
642 classPtr->hIcon = wc->hIcon;
643 classPtr->hIconSm = CopyImage(wc->hIcon, IMAGE_ICON,
644 iSmIconWidth, iSmIconHeight,
645 LR_COPYFROMRESOURCE);
Michael Stefaniucbc54d782002-10-10 21:22:09 +0000646 classPtr->hCursor = wc->hCursor;
647 classPtr->hbrBackground = wc->hbrBackground;
Alexandre Julliard98779062000-12-07 23:39:16 +0000648
Alexandre Julliard18d02972002-12-03 23:34:52 +0000649 WINPROC_SetProc( &classPtr->winprocW, wc->lpfnWndProc,
Alexandre Julliard98779062000-12-07 23:39:16 +0000650 WIN_PROC_32W, WIN_PROC_CLASS );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000651 CLASS_SetMenuNameW( classPtr, wc->lpszMenuName );
652 return atom;
653}
654
655
656/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +0000657 * RegisterClassEx (USER.397)
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000658 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000659ATOM WINAPI RegisterClassEx16( const WNDCLASSEX16 *wc )
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000660{
661 ATOM atom;
662 CLASS *classPtr;
Alexandre Julliarda8a422f2002-11-22 20:43:01 +0000663 HINSTANCE hInstance = HINSTANCE_32(GetExePtr( wc->hInstance ));
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000664
Alexandre Julliard982a2232000-12-13 20:20:09 +0000665 if (!(atom = GlobalAddAtomA( MapSL(wc->lpszClassName) ))) return 0;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000666 if (!(classPtr = CLASS_RegisterClass( atom, hInstance, wc->style,
Alexandre Julliard98779062000-12-07 23:39:16 +0000667 wc->cbClsExtra, wc->cbWndExtra )))
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000668 {
669 GlobalDeleteAtom( atom );
670 return 0;
671 }
672
Alexandre Julliardaff7dda2002-11-22 21:22:14 +0000673 TRACE("atom=%04x wndproc=%p hinst=%p bg=%04x style=%08x clsExt=%d winExt=%d class=%p\n",
674 atom, wc->lpfnWndProc, hInstance,
675 wc->hbrBackground, wc->style, wc->cbClsExtra,
676 wc->cbWndExtra, classPtr );
Vincent Béron9a624912002-05-31 23:06:46 +0000677
Michael Stefaniucbc54d782002-10-10 21:22:09 +0000678 classPtr->hIcon = HICON_32(wc->hIcon);
679 classPtr->hIconSm = HICON_32(wc->hIconSm);
680 classPtr->hCursor = HCURSOR_32(wc->hCursor);
681 classPtr->hbrBackground = HBRUSH_32(wc->hbrBackground);
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000682
Alexandre Julliard18d02972002-12-03 23:34:52 +0000683 WINPROC_SetProc( &classPtr->winprocA, (WNDPROC)wc->lpfnWndProc,
Alexandre Julliard98779062000-12-07 23:39:16 +0000684 WIN_PROC_16, WIN_PROC_CLASS );
Alexandre Julliard982a2232000-12-13 20:20:09 +0000685 CLASS_SetMenuNameA( classPtr, MapSL(wc->lpszMenuName) );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000686 return atom;
687}
688
689
690/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +0000691 * RegisterClassExA (USER32.@)
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000692 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000693ATOM WINAPI RegisterClassExA( const WNDCLASSEXA* wc )
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000694{
695 ATOM atom;
696 CLASS *classPtr;
697
Alexandre Julliardf681cd02000-08-23 19:18:44 +0000698 if (!(atom = GlobalAddAtomA( wc->lpszClassName ))) return 0;
699
Alexandre Julliard77b99181997-09-14 17:17:23 +0000700 if (!(classPtr = CLASS_RegisterClass( atom, wc->hInstance, wc->style,
Alexandre Julliard98779062000-12-07 23:39:16 +0000701 wc->cbClsExtra, wc->cbWndExtra )))
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000702 {
703 GlobalDeleteAtom( atom );
Alexandre Julliard98779062000-12-07 23:39:16 +0000704 return 0;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000705 }
706
Alexandre Julliardaff7dda2002-11-22 21:22:14 +0000707 TRACE("atom=%04x wndproc=%p hinst=%p bg=%p style=%08x clsExt=%d winExt=%d class=%p\n",
708 atom, wc->lpfnWndProc, wc->hInstance,
709 wc->hbrBackground, wc->style, wc->cbClsExtra,
710 wc->cbWndExtra, classPtr );
Vincent Béron9a624912002-05-31 23:06:46 +0000711
Michael Stefaniucbc54d782002-10-10 21:22:09 +0000712 classPtr->hIcon = wc->hIcon;
713 classPtr->hIconSm = wc->hIconSm;
714 classPtr->hCursor = wc->hCursor;
715 classPtr->hbrBackground = wc->hbrBackground;
Alexandre Julliard18d02972002-12-03 23:34:52 +0000716 WINPROC_SetProc( &classPtr->winprocA, wc->lpfnWndProc, WIN_PROC_32A, WIN_PROC_CLASS );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000717 CLASS_SetMenuNameA( classPtr, wc->lpszMenuName );
718 return atom;
719}
720
721
722/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +0000723 * RegisterClassExW (USER32.@)
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000724 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000725ATOM WINAPI RegisterClassExW( const WNDCLASSEXW* wc )
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000726{
727 ATOM atom;
728 CLASS *classPtr;
729
Alexandre Julliardf681cd02000-08-23 19:18:44 +0000730 if (!(atom = GlobalAddAtomW( wc->lpszClassName ))) return 0;
731
Alexandre Julliard77b99181997-09-14 17:17:23 +0000732 if (!(classPtr = CLASS_RegisterClass( atom, wc->hInstance, wc->style,
Alexandre Julliard98779062000-12-07 23:39:16 +0000733 wc->cbClsExtra, wc->cbWndExtra )))
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000734 {
735 GlobalDeleteAtom( atom );
736 return 0;
737 }
738
Alexandre Julliardaff7dda2002-11-22 21:22:14 +0000739 TRACE("atom=%04x wndproc=%p hinst=%p bg=%p style=%08x clsExt=%d winExt=%d class=%p\n",
740 atom, wc->lpfnWndProc, wc->hInstance,
741 wc->hbrBackground, wc->style, wc->cbClsExtra,
742 wc->cbWndExtra, classPtr );
Vincent Béron9a624912002-05-31 23:06:46 +0000743
Michael Stefaniucbc54d782002-10-10 21:22:09 +0000744 classPtr->hIcon = wc->hIcon;
745 classPtr->hIconSm = wc->hIconSm;
746 classPtr->hCursor = wc->hCursor;
747 classPtr->hbrBackground = wc->hbrBackground;
Alexandre Julliard18d02972002-12-03 23:34:52 +0000748 WINPROC_SetProc( &classPtr->winprocW, wc->lpfnWndProc, WIN_PROC_32W, WIN_PROC_CLASS );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000749 CLASS_SetMenuNameW( classPtr, wc->lpszMenuName );
750 return atom;
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000751}
752
753
754/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +0000755 * UnregisterClass (USER.403)
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000756 */
Alexandre Julliardb849d792000-02-13 13:56:13 +0000757BOOL16 WINAPI UnregisterClass16( LPCSTR className, HINSTANCE16 hInstance )
Alexandre Julliard401710d1993-09-04 10:09:32 +0000758{
Alexandre Julliarda8a422f2002-11-22 20:43:01 +0000759 return UnregisterClassA( className, HINSTANCE_32(GetExePtr( hInstance )) );
Alexandre Julliard401710d1993-09-04 10:09:32 +0000760}
761
Alexandre Julliard401710d1993-09-04 10:09:32 +0000762/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +0000763 * UnregisterClassA (USER32.@)
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000764 *
Alexandre Julliard401710d1993-09-04 10:09:32 +0000765 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000766BOOL WINAPI UnregisterClassA( LPCSTR className, HINSTANCE hInstance )
Alexandre Julliard98779062000-12-07 23:39:16 +0000767{
Alexandre Julliardaff7dda2002-11-22 21:22:14 +0000768 TRACE("%s %p\n",debugstr_a(className), hInstance);
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000769 return CLASS_UnregisterClass( GlobalFindAtomA( className ), hInstance );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000770}
771
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000772/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +0000773 * UnregisterClassW (USER32.@)
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000774 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000775BOOL WINAPI UnregisterClassW( LPCWSTR className, HINSTANCE hInstance )
Alexandre Julliard98779062000-12-07 23:39:16 +0000776{
Alexandre Julliardaff7dda2002-11-22 21:22:14 +0000777 TRACE("%s %p\n",debugstr_w(className), hInstance);
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000778 return CLASS_UnregisterClass( GlobalFindAtomW( className ), hInstance );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000779}
780
Alexandre Julliard21979011997-03-05 08:22:35 +0000781
782/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +0000783 * GetClassWord (USER32.@)
Alexandre Julliard21979011997-03-05 08:22:35 +0000784 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000785WORD WINAPI GetClassWord( HWND hwnd, INT offset )
Alexandre Julliard401710d1993-09-04 10:09:32 +0000786{
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000787 CLASS *class;
Guy Albertelli2fa281f1999-04-24 11:54:40 +0000788 WORD retvalue = 0;
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000789
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000790 if (offset < 0) return GetClassLongA( hwnd, offset );
791
Alexandre Julliardaff7dda2002-11-22 21:22:14 +0000792 TRACE("%p %x\n",hwnd, offset);
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000793
Alexandre Julliard8fd26b92001-10-15 17:56:45 +0000794 if (!(class = get_class_ptr( hwnd, FALSE ))) return 0;
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000795
796 if (offset <= class->cbClsExtra - sizeof(WORD))
Alexandre Julliard7fbd74e2002-05-23 02:53:10 +0000797 memcpy( &retvalue, (char *)(class + 1) + offset, sizeof(retvalue) );
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000798 else
799 SetLastError( ERROR_INVALID_INDEX );
800 release_class_ptr( class );
Guy Albertelli2fa281f1999-04-24 11:54:40 +0000801 return retvalue;
Alexandre Julliard401710d1993-09-04 10:09:32 +0000802}
803
804
805/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +0000806 * GetClassLong (USER.131)
Alexandre Julliard401710d1993-09-04 10:09:32 +0000807 */
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000808LONG WINAPI GetClassLong16( HWND16 hwnd16, INT16 offset )
Alexandre Julliard401710d1993-09-04 10:09:32 +0000809{
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000810 CLASS *class;
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000811 LONG ret;
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000812 HWND hwnd = (HWND)(ULONG_PTR)hwnd16; /* no need for full handle */
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000813
Alexandre Julliardaff7dda2002-11-22 21:22:14 +0000814 TRACE("%p %d\n",hwnd, offset);
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000815
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000816 switch( offset )
817 {
Alexandre Julliard3051b641996-07-05 17:14:13 +0000818 case GCL_WNDPROC:
Alexandre Julliard8fd26b92001-10-15 17:56:45 +0000819 if (!(class = get_class_ptr( hwnd, FALSE ))) return 0;
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000820 ret = (LONG)CLASS_GetProc( class, WIN_PROC_16 );
821 release_class_ptr( class );
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000822 return ret;
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000823 case GCL_MENUNAME:
Alexandre Julliardd7b76822001-12-20 00:19:40 +0000824 if (!(class = get_class_ptr( hwnd, FALSE ))) return 0;
825 ret = (LONG)CLASS_GetMenuName16( class );
826 release_class_ptr( class );
827 return ret;
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000828 default:
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000829 return GetClassLongA( hwnd, offset );
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000830 }
Alexandre Julliard401710d1993-09-04 10:09:32 +0000831}
832
833
834/***********************************************************************
Stefan Leichter2c756722002-11-21 21:48:27 +0000835 * GetClassLongW (USER32.@)
Alexandre Julliard401710d1993-09-04 10:09:32 +0000836 */
Stefan Leichter2c756722002-11-21 21:48:27 +0000837LONG WINAPI GetClassLongW( HWND hwnd, INT offset )
Alexandre Julliard401710d1993-09-04 10:09:32 +0000838{
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000839 CLASS *class;
840 LONG retvalue = 0;
841
Alexandre Julliardaff7dda2002-11-22 21:22:14 +0000842 TRACE("%p %d\n", hwnd, offset);
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000843
Alexandre Julliard8fd26b92001-10-15 17:56:45 +0000844 if (!(class = get_class_ptr( hwnd, FALSE ))) return 0;
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000845
Alexandre Julliard2ace16a1996-04-28 15:09:19 +0000846 if (offset >= 0)
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000847 {
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000848 if (offset <= class->cbClsExtra - sizeof(LONG))
Alexandre Julliard7fbd74e2002-05-23 02:53:10 +0000849 memcpy( &retvalue, (char *)(class + 1) + offset, sizeof(retvalue) );
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000850 else
851 SetLastError( ERROR_INVALID_INDEX );
852 release_class_ptr( class );
853 return retvalue;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000854 }
Alexandre Julliardd44e4952001-08-20 18:09:39 +0000855
Alexandre Julliard2ace16a1996-04-28 15:09:19 +0000856 switch(offset)
857 {
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000858 case GCL_HBRBACKGROUND:
859 retvalue = (LONG)class->hbrBackground;
860 break;
861 case GCL_HCURSOR:
862 retvalue = (LONG)class->hCursor;
863 break;
864 case GCL_HICON:
865 retvalue = (LONG)class->hIcon;
866 break;
867 case GCL_HICONSM:
868 retvalue = (LONG)class->hIconSm;
869 break;
870 case GCL_STYLE:
871 retvalue = (LONG)class->style;
872 break;
873 case GCL_CBWNDEXTRA:
874 retvalue = (LONG)class->cbWndExtra;
875 break;
876 case GCL_CBCLSEXTRA:
877 retvalue = (LONG)class->cbClsExtra;
878 break;
879 case GCL_HMODULE:
880 retvalue = (LONG)class->hInstance;
881 break;
882 case GCL_WNDPROC:
Stefan Leichter2c756722002-11-21 21:48:27 +0000883 retvalue = (LONG)CLASS_GetProc( class, WIN_PROC_32W );
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000884 break;
885 case GCL_MENUNAME:
Stefan Leichter2c756722002-11-21 21:48:27 +0000886 retvalue = (LONG)CLASS_GetMenuNameW( class );
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000887 break;
888 case GCW_ATOM:
889 retvalue = (DWORD)class->atomName;
890 break;
891 default:
892 SetLastError( ERROR_INVALID_INDEX );
893 break;
Alexandre Julliard2ace16a1996-04-28 15:09:19 +0000894 }
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000895 release_class_ptr( class );
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000896 return retvalue;
Alexandre Julliard401710d1993-09-04 10:09:32 +0000897}
898
899
900/***********************************************************************
Stefan Leichter2c756722002-11-21 21:48:27 +0000901 * GetClassLongA (USER32.@)
Alexandre Julliard401710d1993-09-04 10:09:32 +0000902 */
Stefan Leichter2c756722002-11-21 21:48:27 +0000903LONG WINAPI GetClassLongA( HWND hwnd, INT offset )
Alexandre Julliard401710d1993-09-04 10:09:32 +0000904{
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000905 CLASS *class;
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000906 LONG retvalue;
Alexandre Julliard3051b641996-07-05 17:14:13 +0000907
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000908 if (offset != GCL_WNDPROC && offset != GCL_MENUNAME)
Stefan Leichter2c756722002-11-21 21:48:27 +0000909 return GetClassLongW( hwnd, offset );
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000910
Alexandre Julliardaff7dda2002-11-22 21:22:14 +0000911 TRACE("%p %d\n", hwnd, offset);
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000912
Alexandre Julliard8fd26b92001-10-15 17:56:45 +0000913 if (!(class = get_class_ptr( hwnd, FALSE ))) return 0;
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000914
915 if (offset == GCL_WNDPROC)
Stefan Leichter2c756722002-11-21 21:48:27 +0000916 retvalue = (LONG)CLASS_GetProc( class, WIN_PROC_32A );
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000917 else /* GCL_MENUNAME */
Stefan Leichter2c756722002-11-21 21:48:27 +0000918 retvalue = (LONG)CLASS_GetMenuNameA( class );
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000919
920 release_class_ptr( class );
921 return retvalue;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000922}
923
924
925/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +0000926 * SetClassWord (USER32.@)
Alexandre Julliard21979011997-03-05 08:22:35 +0000927 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000928WORD WINAPI SetClassWord( HWND hwnd, INT offset, WORD newval )
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000929{
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000930 CLASS *class;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000931 WORD retval = 0;
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000932
933 if (offset < 0) return SetClassLongA( hwnd, offset, (DWORD)newval );
934
Alexandre Julliardaff7dda2002-11-22 21:22:14 +0000935 TRACE("%p %d %x\n", hwnd, offset, newval);
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000936
Alexandre Julliard8fd26b92001-10-15 17:56:45 +0000937 if (!(class = get_class_ptr( hwnd, TRUE ))) return 0;
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000938
939 if (offset <= class->cbClsExtra - sizeof(WORD))
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000940 {
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000941 void *ptr = (char *)(class + 1) + offset;
Alexandre Julliard7fbd74e2002-05-23 02:53:10 +0000942 memcpy( &retval, ptr, sizeof(retval) );
943 memcpy( ptr, &newval, sizeof(newval) );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000944 }
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000945 else SetLastError( ERROR_INVALID_INDEX );
946
947 release_class_ptr( class );
Alexandre Julliard401710d1993-09-04 10:09:32 +0000948 return retval;
949}
Alexandre Julliard5f721f81994-01-04 20:14:34 +0000950
951
952/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +0000953 * SetClassLong (USER.132)
Alexandre Julliard5f721f81994-01-04 20:14:34 +0000954 */
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000955LONG WINAPI SetClassLong16( HWND16 hwnd16, INT16 offset, LONG newval )
Alexandre Julliard5f721f81994-01-04 20:14:34 +0000956{
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000957 CLASS *class;
Alexandre Julliard3051b641996-07-05 17:14:13 +0000958 LONG retval;
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000959 HWND hwnd = (HWND)(ULONG_PTR)hwnd16; /* no need for full handle */
Alexandre Julliard2d93d001996-05-21 15:01:41 +0000960
Alexandre Julliardaff7dda2002-11-22 21:22:14 +0000961 TRACE("%p %d %lx\n", hwnd, offset, newval);
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000962
Alexandre Julliard2d93d001996-05-21 15:01:41 +0000963 switch(offset)
964 {
965 case GCL_WNDPROC:
Alexandre Julliard8fd26b92001-10-15 17:56:45 +0000966 if (!(class = get_class_ptr( hwnd, TRUE ))) return 0;
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000967 retval = (LONG)CLASS_SetProc( class, (WNDPROC)newval, WIN_PROC_16 );
968 release_class_ptr( class );
Alexandre Julliard3051b641996-07-05 17:14:13 +0000969 return retval;
Alexandre Julliard2d93d001996-05-21 15:01:41 +0000970 case GCL_MENUNAME:
Alexandre Julliardd23a82b2001-09-19 20:37:04 +0000971 newval = (LONG)MapSL( newval );
972 /* fall through */
Alexandre Julliard2d93d001996-05-21 15:01:41 +0000973 default:
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000974 return SetClassLongA( hwnd, offset, newval );
Alexandre Julliard2d93d001996-05-21 15:01:41 +0000975 }
Alexandre Julliard5f721f81994-01-04 20:14:34 +0000976}
977
978
979/***********************************************************************
Stefan Leichter2c756722002-11-21 21:48:27 +0000980 * SetClassLongW (USER32.@)
Alexandre Julliard5f721f81994-01-04 20:14:34 +0000981 */
Stefan Leichter2c756722002-11-21 21:48:27 +0000982LONG WINAPI SetClassLongW( HWND hwnd, INT offset, LONG newval )
Alexandre Julliard5f721f81994-01-04 20:14:34 +0000983{
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000984 CLASS *class;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000985 LONG retval = 0;
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000986
Alexandre Julliardaff7dda2002-11-22 21:22:14 +0000987 TRACE("%p %d %lx\n", hwnd, offset, newval);
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000988
Alexandre Julliard8fd26b92001-10-15 17:56:45 +0000989 if (!(class = get_class_ptr( hwnd, TRUE ))) return 0;
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000990
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000991 if (offset >= 0)
992 {
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000993 if (offset <= class->cbClsExtra - sizeof(LONG))
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000994 {
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000995 void *ptr = (char *)(class + 1) + offset;
Alexandre Julliard7fbd74e2002-05-23 02:53:10 +0000996 memcpy( &retval, ptr, sizeof(retval) );
997 memcpy( ptr, &newval, sizeof(newval) );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000998 }
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +0000999 else SetLastError( ERROR_INVALID_INDEX );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001000 }
1001 else switch(offset)
1002 {
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +00001003 case GCL_MENUNAME:
Stefan Leichter2c756722002-11-21 21:48:27 +00001004 CLASS_SetMenuNameW( class, (LPCWSTR)newval );
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +00001005 retval = 0; /* Old value is now meaningless anyway */
1006 break;
1007 case GCL_WNDPROC:
Stefan Leichter2c756722002-11-21 21:48:27 +00001008 retval = (LONG)CLASS_SetProc( class, (WNDPROC)newval, WIN_PROC_32W );
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +00001009 break;
1010 case GCL_HBRBACKGROUND:
1011 retval = (LONG)class->hbrBackground;
Alexandre Julliard7ef66af2002-11-22 04:47:10 +00001012 class->hbrBackground = (HBRUSH)newval;
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +00001013 break;
1014 case GCL_HCURSOR:
1015 retval = (LONG)class->hCursor;
Michael Stefaniucbc54d782002-10-10 21:22:09 +00001016 class->hCursor = (HCURSOR)newval;
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +00001017 break;
1018 case GCL_HICON:
1019 retval = (LONG)class->hIcon;
Michael Stefaniucbc54d782002-10-10 21:22:09 +00001020 class->hIcon = (HICON)newval;
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +00001021 break;
1022 case GCL_HICONSM:
1023 retval = (LONG)class->hIconSm;
Michael Stefaniucbc54d782002-10-10 21:22:09 +00001024 class->hIconSm = (HICON)newval;
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +00001025 break;
1026 case GCL_STYLE:
1027 retval = (LONG)class->style;
1028 class->style = newval;
1029 break;
1030 case GCL_CBWNDEXTRA:
1031 retval = (LONG)class->cbWndExtra;
1032 class->cbWndExtra = newval;
1033 break;
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +00001034 case GCL_HMODULE:
1035 retval = (LONG)class->hInstance;
Alexandre Julliard7ef66af2002-11-22 04:47:10 +00001036 class->hInstance = (HINSTANCE)newval;
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +00001037 break;
1038 case GCW_ATOM:
1039 retval = (DWORD)class->atomName;
1040 class->atomName = newval;
1041 break;
Alexandre Julliard8fd26b92001-10-15 17:56:45 +00001042 case GCL_CBCLSEXTRA: /* cannot change this one */
1043 SetLastError( ERROR_INVALID_PARAMETER );
1044 break;
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +00001045 default:
1046 SetLastError( ERROR_INVALID_INDEX );
1047 break;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001048 }
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +00001049 release_class_ptr( class );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001050 return retval;
1051}
1052
1053
1054/***********************************************************************
Stefan Leichter2c756722002-11-21 21:48:27 +00001055 * SetClassLongA (USER32.@)
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001056 */
Stefan Leichter2c756722002-11-21 21:48:27 +00001057LONG WINAPI SetClassLongA( HWND hwnd, INT offset, LONG newval )
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001058{
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +00001059 CLASS *class;
Alexandre Julliard3051b641996-07-05 17:14:13 +00001060 LONG retval;
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001061
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +00001062 if (offset != GCL_WNDPROC && offset != GCL_MENUNAME)
Stefan Leichter2c756722002-11-21 21:48:27 +00001063 return SetClassLongW( hwnd, offset, newval );
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +00001064
Alexandre Julliardaff7dda2002-11-22 21:22:14 +00001065 TRACE("%p %d %lx\n", hwnd, offset, newval);
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +00001066
Alexandre Julliard8fd26b92001-10-15 17:56:45 +00001067 if (!(class = get_class_ptr( hwnd, TRUE ))) return 0;
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +00001068
1069 if (offset == GCL_WNDPROC)
Stefan Leichter2c756722002-11-21 21:48:27 +00001070 retval = (LONG)CLASS_SetProc( class, (WNDPROC)newval, WIN_PROC_32A );
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +00001071 else /* GCL_MENUNAME */
1072 {
Stefan Leichter2c756722002-11-21 21:48:27 +00001073 CLASS_SetMenuNameA( class, (LPCSTR)newval );
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +00001074 retval = 0; /* Old value is now meaningless anyway */
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001075 }
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +00001076 release_class_ptr( class );
1077 return retval;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001078}
1079
1080
1081/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +00001082 * GetClassNameA (USER32.@)
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001083 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001084INT WINAPI GetClassNameA( HWND hwnd, LPSTR buffer, INT count )
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +00001085{
Alexandre Julliard8fd26b92001-10-15 17:56:45 +00001086 INT ret = GlobalGetAtomNameA( GetClassLongA( hwnd, GCW_ATOM ), buffer, count );
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +00001087
Alexandre Julliardaff7dda2002-11-22 21:22:14 +00001088 TRACE("%p %s %x\n",hwnd, debugstr_a(buffer), count);
Alexandre Julliard767e6f61998-08-09 12:47:43 +00001089 return ret;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001090}
1091
1092
1093/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +00001094 * GetClassNameW (USER32.@)
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001095 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001096INT WINAPI GetClassNameW( HWND hwnd, LPWSTR buffer, INT count )
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +00001097{
Alexandre Julliard8fd26b92001-10-15 17:56:45 +00001098 INT ret = GlobalGetAtomNameW( GetClassLongW( hwnd, GCW_ATOM ), buffer, count );
Alexandre Julliarde6d90ea2001-10-09 23:27:17 +00001099
Alexandre Julliardaff7dda2002-11-22 21:22:14 +00001100 TRACE("%p %s %x\n",hwnd, debugstr_w(buffer), count);
Alexandre Julliard767e6f61998-08-09 12:47:43 +00001101 return ret;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001102}
1103
1104
1105/***********************************************************************
Dmitry Timoshkov29991652003-09-27 03:47:07 +00001106 * RealGetWindowClassA (USER32.@)
1107 */
1108UINT WINAPI RealGetWindowClassA( HWND hwnd, LPSTR buffer, UINT count )
1109{
1110 return GetClassNameA( hwnd, buffer, count );
1111}
1112
1113
1114/***********************************************************************
1115 * RealGetWindowClassW (USER32.@)
1116 */
1117UINT WINAPI RealGetWindowClassW( HWND hwnd, LPWSTR buffer, UINT count )
1118{
1119 return GetClassNameW( hwnd, buffer, count );
1120}
1121
1122
1123/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +00001124 * GetClassInfo (USER.404)
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001125 */
Alexandre Julliarda8a422f2002-11-22 20:43:01 +00001126BOOL16 WINAPI GetClassInfo16( HINSTANCE16 hInst16, SEGPTR name, WNDCLASS16 *wc )
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001127{
1128 ATOM atom;
Alexandre Julliard5f721f81994-01-04 20:14:34 +00001129 CLASS *classPtr;
Alexandre Julliarda8a422f2002-11-22 20:43:01 +00001130 HINSTANCE hInstance = HINSTANCE_32(GetExePtr( hInst16 ));
Alexandre Julliard3ed37e01994-11-07 18:20:42 +00001131
Alexandre Julliardaff7dda2002-11-22 21:22:14 +00001132 TRACE("%p %s %p\n",hInstance, debugstr_a(MapSL(name)), wc);
Alexandre Julliard98779062000-12-07 23:39:16 +00001133
Alexandre Julliard982a2232000-12-13 20:20:09 +00001134 if (!(atom = GlobalFindAtomA( MapSL(name) )) ||
Alexandre Julliard670cdc41997-08-24 16:00:30 +00001135 !(classPtr = CLASS_FindClassByAtom( atom, hInstance )))
1136 return FALSE;
1137 if ((hInstance != classPtr->hInstance) &&
1138 !(classPtr->style & CS_GLOBALCLASS)) /*BWCC likes to pass hInstance=0*/
1139 return FALSE;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001140 wc->style = (UINT16)classPtr->style;
Alexandre Julliard98779062000-12-07 23:39:16 +00001141 wc->lpfnWndProc = CLASS_GetProc( classPtr, WIN_PROC_16 );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001142 wc->cbClsExtra = (INT16)classPtr->cbClsExtra;
1143 wc->cbWndExtra = (INT16)classPtr->cbWndExtra;
Alexandre Julliarda8a422f2002-11-22 20:43:01 +00001144 wc->hInstance = classPtr->style & CS_GLOBALCLASS ? GetModuleHandle16("USER") : HINSTANCE_16(classPtr->hInstance);
Michael Stefaniucbc54d782002-10-10 21:22:09 +00001145 wc->hIcon = HICON_16(classPtr->hIcon);
1146 wc->hCursor = HCURSOR_16(classPtr->hCursor);
1147 wc->hbrBackground = HBRUSH_16(classPtr->hbrBackground);
Alexandre Julliard98779062000-12-07 23:39:16 +00001148 wc->lpszClassName = name;
Alexandre Julliardd7b76822001-12-20 00:19:40 +00001149 wc->lpszMenuName = CLASS_GetMenuName16( classPtr );
Dmitry Timoshkov33cf3e02003-05-19 23:10:54 +00001150
1151 /* We must return the atom of the class here instead of just TRUE. */
1152 return atom;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001153}
1154
1155
1156/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +00001157 * GetClassInfoA (USER32.@)
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001158 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001159BOOL WINAPI GetClassInfoA( HINSTANCE hInstance, LPCSTR name,
1160 WNDCLASSA *wc )
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001161{
1162 ATOM atom;
1163 CLASS *classPtr;
1164
Alexandre Julliardaff7dda2002-11-22 21:22:14 +00001165 TRACE("%p %p %p\n",hInstance, name, wc);
Alexandre Julliard767e6f61998-08-09 12:47:43 +00001166
1167 /* workaround: if hInstance=NULL you expect to get the system classes
1168 but this classes (as example from comctl32.dll SysListView) won't be
Andreas Mohr2caee712000-07-16 15:44:22 +00001169 registered with hInstance=NULL in WINE because of the late loading
Alexandre Julliard767e6f61998-08-09 12:47:43 +00001170 of this dll. fixes file dialogs in WinWord95 (jsch)*/
1171
Alexandre Julliarda3960291999-02-26 11:11:13 +00001172 if (!(atom=GlobalFindAtomA(name)) || !(classPtr=CLASS_FindClassByAtom(atom,hInstance)))
Alexandre Julliard21979011997-03-05 08:22:35 +00001173 return FALSE;
1174
Noomen Hamza1040eaf2000-07-09 12:21:07 +00001175 if (!(classPtr->style & CS_GLOBALCLASS) &&
1176 classPtr->hInstance &&
1177 (hInstance != classPtr->hInstance))
Alexandre Julliard767e6f61998-08-09 12:47:43 +00001178 {
1179 if (hInstance) return FALSE;
Noomen Hamza1040eaf2000-07-09 12:21:07 +00001180 WARN("systemclass %s (hInst=0) demanded but only class with hInst!=0 found\n",name);
Alexandre Julliard767e6f61998-08-09 12:47:43 +00001181 }
1182
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001183 wc->style = classPtr->style;
Alexandre Julliard98779062000-12-07 23:39:16 +00001184 wc->lpfnWndProc = (WNDPROC)CLASS_GetProc( classPtr, WIN_PROC_32A );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001185 wc->cbClsExtra = classPtr->cbClsExtra;
1186 wc->cbWndExtra = classPtr->cbWndExtra;
Noomen Hamza1040eaf2000-07-09 12:21:07 +00001187 wc->hInstance = hInstance;
Alexandre Julliarda3960291999-02-26 11:11:13 +00001188 wc->hIcon = (HICON)classPtr->hIcon;
1189 wc->hCursor = (HCURSOR)classPtr->hCursor;
1190 wc->hbrBackground = (HBRUSH)classPtr->hbrBackground;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001191 wc->lpszMenuName = CLASS_GetMenuNameA( classPtr );
Alexandre Julliard98779062000-12-07 23:39:16 +00001192 wc->lpszClassName = name;
Dmitry Timoshkov33cf3e02003-05-19 23:10:54 +00001193
1194 /* We must return the atom of the class here instead of just TRUE. */
1195 return atom;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001196}
1197
1198
1199/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +00001200 * GetClassInfoW (USER32.@)
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001201 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001202BOOL WINAPI GetClassInfoW( HINSTANCE hInstance, LPCWSTR name,
1203 WNDCLASSW *wc )
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001204{
1205 ATOM atom;
1206 CLASS *classPtr;
1207
Alexandre Julliardaff7dda2002-11-22 21:22:14 +00001208 TRACE("%p %p %p\n",hInstance, name, wc);
Alexandre Julliard767e6f61998-08-09 12:47:43 +00001209
Marcus Meissner438062171999-09-03 12:28:20 +00001210 if ( !(atom=GlobalFindAtomW(name)) ||
1211 !(classPtr=CLASS_FindClassByAtom(atom,hInstance))
1212 )
Alexandre Julliard21979011997-03-05 08:22:35 +00001213 return FALSE;
1214
Noomen Hamza1040eaf2000-07-09 12:21:07 +00001215 if (!(classPtr->style & CS_GLOBALCLASS) &&
1216 classPtr->hInstance &&
1217 (hInstance != classPtr->hInstance))
1218 {
1219 if (hInstance) return FALSE;
1220 WARN("systemclass %s (hInst=0) demanded but only class with hInst!=0 found\n",debugstr_w(name));
Marcus Meissner438062171999-09-03 12:28:20 +00001221 }
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001222 wc->style = classPtr->style;
Alexandre Julliard98779062000-12-07 23:39:16 +00001223 wc->lpfnWndProc = (WNDPROC)CLASS_GetProc( classPtr, WIN_PROC_32W );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001224 wc->cbClsExtra = classPtr->cbClsExtra;
1225 wc->cbWndExtra = classPtr->cbWndExtra;
Noomen Hamza1040eaf2000-07-09 12:21:07 +00001226 wc->hInstance = hInstance;
Alexandre Julliarda3960291999-02-26 11:11:13 +00001227 wc->hIcon = (HICON)classPtr->hIcon;
1228 wc->hCursor = (HCURSOR)classPtr->hCursor;
1229 wc->hbrBackground = (HBRUSH)classPtr->hbrBackground;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001230 wc->lpszMenuName = CLASS_GetMenuNameW( classPtr );
Alexandre Julliard98779062000-12-07 23:39:16 +00001231 wc->lpszClassName = name;
Dmitry Timoshkov33cf3e02003-05-19 23:10:54 +00001232
1233 /* We must return the atom of the class here instead of just TRUE. */
1234 return atom;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001235}
1236
1237
1238/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +00001239 * GetClassInfoEx (USER.398)
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001240 *
1241 * FIXME: this is just a guess, I have no idea if GetClassInfoEx() is the
1242 * same in Win16 as in Win32. --AJ
1243 */
Alexandre Julliarda8a422f2002-11-22 20:43:01 +00001244BOOL16 WINAPI GetClassInfoEx16( HINSTANCE16 hInst16, SEGPTR name, WNDCLASSEX16 *wc )
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001245{
1246 ATOM atom;
1247 CLASS *classPtr;
Alexandre Julliarda8a422f2002-11-22 20:43:01 +00001248 HINSTANCE hInstance = HINSTANCE_32(GetExePtr( hInst16 ));
Alexandre Julliard808cb041995-08-17 17:11:36 +00001249
Alexandre Julliardaff7dda2002-11-22 21:22:14 +00001250 TRACE("%p %s %p\n",hInstance,debugstr_a( MapSL(name) ), wc);
Alexandre Julliard98779062000-12-07 23:39:16 +00001251
Alexandre Julliard982a2232000-12-13 20:20:09 +00001252 if (!(atom = GlobalFindAtomA( MapSL(name) )) ||
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001253 !(classPtr = CLASS_FindClassByAtom( atom, hInstance )) ||
1254 (hInstance != classPtr->hInstance)) return FALSE;
1255 wc->style = classPtr->style;
Alexandre Julliard98779062000-12-07 23:39:16 +00001256 wc->lpfnWndProc = CLASS_GetProc( classPtr, WIN_PROC_16 );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001257 wc->cbClsExtra = (INT16)classPtr->cbClsExtra;
1258 wc->cbWndExtra = (INT16)classPtr->cbWndExtra;
Alexandre Julliarda8a422f2002-11-22 20:43:01 +00001259 wc->hInstance = HINSTANCE_16(classPtr->hInstance);
Michael Stefaniucbc54d782002-10-10 21:22:09 +00001260 wc->hIcon = HICON_16(classPtr->hIcon);
1261 wc->hIconSm = HICON_16(classPtr->hIconSm);
1262 wc->hCursor = HCURSOR_16(classPtr->hCursor);
1263 wc->hbrBackground = HBRUSH_16(classPtr->hbrBackground);
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001264 wc->lpszClassName = (SEGPTR)0;
Alexandre Julliardd7b76822001-12-20 00:19:40 +00001265 wc->lpszMenuName = CLASS_GetMenuName16( classPtr );
1266 wc->lpszClassName = name;
James Hatheway9fa09e72000-06-18 17:19:38 +00001267
1268 /* We must return the atom of the class here instead of just TRUE. */
1269 return atom;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001270}
Alexandre Julliard5f721f81994-01-04 20:14:34 +00001271
Alexandre Julliard1285c2f1996-05-06 16:06:24 +00001272
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001273/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +00001274 * GetClassInfoExA (USER32.@)
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001275 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001276BOOL WINAPI GetClassInfoExA( HINSTANCE hInstance, LPCSTR name,
1277 WNDCLASSEXA *wc )
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001278{
1279 ATOM atom;
1280 CLASS *classPtr;
1281
Alexandre Julliardaff7dda2002-11-22 21:22:14 +00001282 TRACE("%p %p %p\n",hInstance, name, wc);
Vincent Béron9a624912002-05-31 23:06:46 +00001283
Alexandre Julliarda3960291999-02-26 11:11:13 +00001284 if (!(atom = GlobalFindAtomA( name )) ||
Vincent Béron9a624912002-05-31 23:06:46 +00001285 !(classPtr = CLASS_FindClassByAtom( atom, hInstance ))
Alexandre Julliarda0d77311998-09-13 16:32:00 +00001286 /*|| (hInstance != classPtr->hInstance) */ ) return FALSE;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001287 wc->style = classPtr->style;
Alexandre Julliard98779062000-12-07 23:39:16 +00001288 wc->lpfnWndProc = (WNDPROC)CLASS_GetProc( classPtr, WIN_PROC_32A );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001289 wc->cbClsExtra = classPtr->cbClsExtra;
1290 wc->cbWndExtra = classPtr->cbWndExtra;
1291 wc->hInstance = classPtr->hInstance;
Alexandre Julliarda3960291999-02-26 11:11:13 +00001292 wc->hIcon = (HICON)classPtr->hIcon;
1293 wc->hIconSm = (HICON)classPtr->hIconSm;
1294 wc->hCursor = (HCURSOR)classPtr->hCursor;
1295 wc->hbrBackground = (HBRUSH)classPtr->hbrBackground;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001296 wc->lpszMenuName = CLASS_GetMenuNameA( classPtr );
Alexandre Julliard98779062000-12-07 23:39:16 +00001297 wc->lpszClassName = name;
1298
James Hatheway9fa09e72000-06-18 17:19:38 +00001299 /* We must return the atom of the class here instead of just TRUE. */
1300 return atom;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001301}
1302
1303
1304/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +00001305 * GetClassInfoExW (USER32.@)
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001306 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001307BOOL WINAPI GetClassInfoExW( HINSTANCE hInstance, LPCWSTR name,
1308 WNDCLASSEXW *wc )
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001309{
1310 ATOM atom;
1311 CLASS *classPtr;
1312
Alexandre Julliardaff7dda2002-11-22 21:22:14 +00001313 TRACE("%p %p %p\n",hInstance, name, wc);
Vincent Béron9a624912002-05-31 23:06:46 +00001314
Alexandre Julliarda3960291999-02-26 11:11:13 +00001315 if (!(atom = GlobalFindAtomW( name )) ||
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001316 !(classPtr = CLASS_FindClassByAtom( atom, hInstance )) ||
1317 (hInstance != classPtr->hInstance)) return FALSE;
1318 wc->style = classPtr->style;
Alexandre Julliard98779062000-12-07 23:39:16 +00001319 wc->lpfnWndProc = (WNDPROC)CLASS_GetProc( classPtr, WIN_PROC_32W );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001320 wc->cbClsExtra = classPtr->cbClsExtra;
1321 wc->cbWndExtra = classPtr->cbWndExtra;
1322 wc->hInstance = classPtr->hInstance;
Alexandre Julliarda3960291999-02-26 11:11:13 +00001323 wc->hIcon = (HICON)classPtr->hIcon;
1324 wc->hIconSm = (HICON)classPtr->hIconSm;
1325 wc->hCursor = (HCURSOR)classPtr->hCursor;
1326 wc->hbrBackground = (HBRUSH)classPtr->hbrBackground;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001327 wc->lpszMenuName = CLASS_GetMenuNameW( classPtr );
Alexandre Julliard98779062000-12-07 23:39:16 +00001328 wc->lpszClassName = name;
1329
James Hatheway9fa09e72000-06-18 17:19:38 +00001330 /* We must return the atom of the class here instead of just TRUE. */
1331 return atom;
Alexandre Julliard5f721f81994-01-04 20:14:34 +00001332}
Alexandre Julliarde2abbb11995-03-19 17:39:39 +00001333
1334
Alexandre Julliardf899ef02001-07-23 00:04:00 +00001335#if 0 /* toolhelp is in kernel, so this cannot work */
1336
Alexandre Julliarde2abbb11995-03-19 17:39:39 +00001337/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +00001338 * ClassFirst (TOOLHELP.69)
Alexandre Julliarde2abbb11995-03-19 17:39:39 +00001339 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001340BOOL16 WINAPI ClassFirst16( CLASSENTRY *pClassEntry )
Alexandre Julliarde2abbb11995-03-19 17:39:39 +00001341{
Alexandre Julliard359f497e1999-07-04 16:02:24 +00001342 TRACE("%p\n",pClassEntry);
Alexandre Julliard2ace16a1996-04-28 15:09:19 +00001343 pClassEntry->wNext = 1;
Alexandre Julliarda3960291999-02-26 11:11:13 +00001344 return ClassNext16( pClassEntry );
Alexandre Julliarde2abbb11995-03-19 17:39:39 +00001345}
1346
1347
1348/***********************************************************************
Patrik Stridvall2ece70e2000-12-22 01:38:01 +00001349 * ClassNext (TOOLHELP.70)
Alexandre Julliarde2abbb11995-03-19 17:39:39 +00001350 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001351BOOL16 WINAPI ClassNext16( CLASSENTRY *pClassEntry )
Alexandre Julliarde2abbb11995-03-19 17:39:39 +00001352{
Alexandre Julliard2ace16a1996-04-28 15:09:19 +00001353 int i;
1354 CLASS *class = firstClass;
Alexandre Julliarde2abbb11995-03-19 17:39:39 +00001355
Alexandre Julliard359f497e1999-07-04 16:02:24 +00001356 TRACE("%p\n",pClassEntry);
Vincent Béron9a624912002-05-31 23:06:46 +00001357
Alexandre Julliard2ace16a1996-04-28 15:09:19 +00001358 if (!pClassEntry->wNext) return FALSE;
1359 for (i = 1; (i < pClassEntry->wNext) && class; i++) class = class->next;
1360 if (!class)
1361 {
1362 pClassEntry->wNext = 0;
1363 return FALSE;
1364 }
Alexandre Julliard1285c2f1996-05-06 16:06:24 +00001365 pClassEntry->hInst = class->hInstance;
Alexandre Julliard2ace16a1996-04-28 15:09:19 +00001366 pClassEntry->wNext++;
Alexandre Julliarda3960291999-02-26 11:11:13 +00001367 GlobalGetAtomNameA( class->atomName, pClassEntry->szClassName,
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001368 sizeof(pClassEntry->szClassName) );
Alexandre Julliarde2abbb11995-03-19 17:39:39 +00001369 return TRUE;
1370}
Alexandre Julliardf899ef02001-07-23 00:04:00 +00001371#endif