user32: Use the ARRAY_SIZE() macro.
[wine.git] / dlls / user32 / class.c
blob07d36f05d7df76044036db643d898e4cbd581b66
1 /*
2 * Window classes functions
4 * Copyright 1993, 1996, 2003 Alexandre Julliard
5 * Copyright 1998 Juergen Schmied (jsch)
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
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.
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include "config.h"
23 #include "wine/port.h"
25 #include <assert.h>
26 #include <stdarg.h>
27 #include <stdlib.h>
28 #include <string.h>
30 #include "winerror.h"
31 #include "windef.h"
32 #include "winbase.h"
33 #include "wingdi.h"
34 #include "wine/unicode.h"
35 #include "win.h"
36 #include "user_private.h"
37 #include "controls.h"
38 #include "wine/server.h"
39 #include "wine/list.h"
40 #include "wine/debug.h"
42 WINE_DEFAULT_DEBUG_CHANNEL(class);
44 #define MAX_ATOM_LEN 255 /* from dlls/kernel32/atom.c */
46 typedef struct tagCLASS
48 struct list entry; /* Entry in class list */
49 UINT style; /* Class style */
50 BOOL local; /* Local class? */
51 WNDPROC winproc; /* Window procedure */
52 INT cbClsExtra; /* Class extra bytes */
53 INT cbWndExtra; /* Window extra bytes */
54 LPWSTR menuName; /* Default menu name (Unicode followed by ASCII) */
55 struct dce *dce; /* Opaque pointer to class DCE */
56 HINSTANCE hInstance; /* Module that created the task */
57 HICON hIcon; /* Default icon */
58 HICON hIconSm; /* Default small icon */
59 HICON hIconSmIntern; /* Internal small icon, derived from hIcon */
60 HCURSOR hCursor; /* Default cursor */
61 HBRUSH hbrBackground; /* Default background */
62 ATOM atomName; /* Name of the class */
63 WCHAR name[MAX_ATOM_LEN + 1];
64 WCHAR *basename; /* Base name for redirected classes, pointer within 'name'. */
65 } CLASS;
67 static struct list class_list = LIST_INIT( class_list );
68 static INIT_ONCE init_once = INIT_ONCE_STATIC_INIT;
70 #define CLASS_OTHER_PROCESS ((CLASS *)1)
72 /***********************************************************************
73 * get_class_ptr
75 static CLASS *get_class_ptr( HWND hwnd, BOOL write_access )
77 WND *ptr = WIN_GetPtr( hwnd );
79 if (ptr)
81 if (ptr != WND_OTHER_PROCESS && ptr != WND_DESKTOP) return ptr->class;
82 if (!write_access) return CLASS_OTHER_PROCESS;
84 /* modifying classes in other processes is not allowed */
85 if (ptr == WND_DESKTOP || IsWindow( hwnd ))
87 SetLastError( ERROR_ACCESS_DENIED );
88 return NULL;
91 SetLastError( ERROR_INVALID_WINDOW_HANDLE );
92 return NULL;
96 /***********************************************************************
97 * release_class_ptr
99 static inline void release_class_ptr( CLASS *ptr )
101 USER_Unlock();
105 /***********************************************************************
106 * get_int_atom_value
108 ATOM get_int_atom_value( LPCWSTR name )
110 UINT ret = 0;
112 if (IS_INTRESOURCE(name)) return LOWORD(name);
113 if (*name++ != '#') return 0;
114 while (*name)
116 if (*name < '0' || *name > '9') return 0;
117 ret = ret * 10 + *name++ - '0';
118 if (ret > 0xffff) return 0;
120 return ret;
124 /***********************************************************************
125 * is_comctl32_class
127 static BOOL is_comctl32_class( const WCHAR *name )
129 static const WCHAR classesW[][20] =
131 {'C','o','m','b','o','B','o','x','E','x','3','2',0},
132 {'m','s','c','t','l','s','_','h','o','t','k','e','y','3','2',0},
133 {'m','s','c','t','l','s','_','p','r','o','g','r','e','s','s','3','2',0},
134 {'m','s','c','t','l','s','_','s','t','a','t','u','s','b','a','r','3','2',0},
135 {'m','s','c','t','l','s','_','t','r','a','c','k','b','a','r','3','2',0},
136 {'m','s','c','t','l','s','_','u','p','d','o','w','n','3','2',0},
137 {'N','a','t','i','v','e','F','o','n','t','C','t','l',0},
138 {'R','e','B','a','r','W','i','n','d','o','w','3','2',0},
139 {'S','y','s','A','n','i','m','a','t','e','3','2',0},
140 {'S','y','s','D','a','t','e','T','i','m','e','P','i','c','k','3','2',0},
141 {'S','y','s','H','e','a','d','e','r','3','2',0},
142 {'S','y','s','I','P','A','d','d','r','e','s','s','3','2',0},
143 {'S','y','s','L','i','n','k',0},
144 {'S','y','s','L','i','s','t','V','i','e','w','3','2',0},
145 {'S','y','s','M','o','n','t','h','C','a','l','3','2',0},
146 {'S','y','s','P','a','g','e','r',0},
147 {'S','y','s','T','a','b','C','o','n','t','r','o','l','3','2',0},
148 {'S','y','s','T','r','e','e','V','i','e','w','3','2',0},
149 {'T','o','o','l','b','a','r','W','i','n','d','o','w','3','2',0},
150 {'t','o','o','l','t','i','p','s','_','c','l','a','s','s','3','2',0},
153 int min = 0, max = ARRAY_SIZE( classesW ) - 1;
155 while (min <= max)
157 int res, pos = (min + max) / 2;
158 if (!(res = strcmpiW( name, classesW[pos] ))) return TRUE;
159 if (res < 0) max = pos - 1;
160 else min = pos + 1;
162 return FALSE;
165 static BOOL is_builtin_class( const WCHAR *name )
167 static const WCHAR classesW[][20] =
169 {'I','M','E',0},
170 {'M','D','I','C','l','i','e','n','t',0},
171 {'S','c','r','o','l','l','b','a','r',0},
174 int min = 0, max = ARRAY_SIZE( classesW ) - 1;
176 while (min <= max)
178 int res, pos = (min + max) / 2;
179 if (!(res = strcmpiW( name, classesW[pos] ))) return TRUE;
180 if (res < 0) max = pos - 1;
181 else min = pos + 1;
183 return FALSE;
186 /***********************************************************************
187 * set_server_info
189 * Set class info with the wine server.
191 static BOOL set_server_info( HWND hwnd, INT offset, LONG_PTR newval, UINT size )
193 BOOL ret;
195 SERVER_START_REQ( set_class_info )
197 req->window = wine_server_user_handle( hwnd );
198 req->extra_offset = -1;
199 switch(offset)
201 case GCW_ATOM:
202 req->flags = SET_CLASS_ATOM;
203 req->atom = LOWORD(newval);
204 break;
205 case GCL_STYLE:
206 req->flags = SET_CLASS_STYLE;
207 req->style = newval;
208 break;
209 case GCL_CBWNDEXTRA:
210 req->flags = SET_CLASS_WINEXTRA;
211 req->win_extra = newval;
212 break;
213 case GCLP_HMODULE:
214 req->flags = SET_CLASS_INSTANCE;
215 req->instance = wine_server_client_ptr( (void *)newval );
216 break;
217 default:
218 assert( offset >= 0 );
219 req->flags = SET_CLASS_EXTRA;
220 req->extra_offset = offset;
221 req->extra_size = size;
222 if ( size == sizeof(LONG) )
224 LONG newlong = newval;
225 memcpy( &req->extra_value, &newlong, sizeof(LONG) );
227 else
228 memcpy( &req->extra_value, &newval, sizeof(LONG_PTR) );
229 break;
231 ret = !wine_server_call_err( req );
233 SERVER_END_REQ;
234 return ret;
238 /***********************************************************************
239 * CLASS_GetMenuNameA
241 * Get the menu name as a ASCII string.
243 static inline LPSTR CLASS_GetMenuNameA( CLASS *classPtr )
245 if (IS_INTRESOURCE(classPtr->menuName)) return (LPSTR)classPtr->menuName;
246 return (LPSTR)(classPtr->menuName + strlenW(classPtr->menuName) + 1);
250 /***********************************************************************
251 * CLASS_GetMenuNameW
253 * Get the menu name as a Unicode string.
255 static inline LPWSTR CLASS_GetMenuNameW( CLASS *classPtr )
257 return classPtr->menuName;
261 /***********************************************************************
262 * CLASS_SetMenuNameA
264 * Set the menu name in a class structure by copying the string.
266 static void CLASS_SetMenuNameA( CLASS *classPtr, LPCSTR name )
268 if (!IS_INTRESOURCE(classPtr->menuName)) HeapFree( GetProcessHeap(), 0, classPtr->menuName );
269 if (!IS_INTRESOURCE(name))
271 DWORD lenA = strlen(name) + 1;
272 DWORD lenW = MultiByteToWideChar( CP_ACP, 0, name, lenA, NULL, 0 );
273 classPtr->menuName = HeapAlloc( GetProcessHeap(), 0, lenA + lenW*sizeof(WCHAR) );
274 MultiByteToWideChar( CP_ACP, 0, name, lenA, classPtr->menuName, lenW );
275 memcpy( classPtr->menuName + lenW, name, lenA );
277 else classPtr->menuName = (LPWSTR)name;
281 /***********************************************************************
282 * CLASS_SetMenuNameW
284 * Set the menu name in a class structure by copying the string.
286 static void CLASS_SetMenuNameW( CLASS *classPtr, LPCWSTR name )
288 if (!IS_INTRESOURCE(classPtr->menuName)) HeapFree( GetProcessHeap(), 0, classPtr->menuName );
289 if (!IS_INTRESOURCE(name))
291 DWORD lenW = strlenW(name) + 1;
292 DWORD lenA = WideCharToMultiByte( CP_ACP, 0, name, lenW, NULL, 0, NULL, NULL );
293 classPtr->menuName = HeapAlloc( GetProcessHeap(), 0, lenA + lenW*sizeof(WCHAR) );
294 memcpy( classPtr->menuName, name, lenW*sizeof(WCHAR) );
295 WideCharToMultiByte( CP_ACP, 0, name, lenW,
296 (char *)(classPtr->menuName + lenW), lenA, NULL, NULL );
298 else classPtr->menuName = (LPWSTR)name;
302 /***********************************************************************
303 * CLASS_FreeClass
305 * Free a class structure.
307 static void CLASS_FreeClass( CLASS *classPtr )
309 TRACE("%p\n", classPtr);
311 USER_Lock();
313 if (classPtr->dce) free_dce( classPtr->dce, 0 );
314 list_remove( &classPtr->entry );
315 if (classPtr->hbrBackground > (HBRUSH)(COLOR_GRADIENTINACTIVECAPTION + 1))
316 DeleteObject( classPtr->hbrBackground );
317 DestroyIcon( classPtr->hIconSmIntern );
318 HeapFree( GetProcessHeap(), 0, classPtr->menuName );
319 HeapFree( GetProcessHeap(), 0, classPtr );
320 USER_Unlock();
323 const WCHAR *CLASS_GetVersionedName( const WCHAR *name, UINT *basename_offset, BOOL register_class )
325 ACTCTX_SECTION_KEYED_DATA data;
326 struct wndclass_redirect_data
328 ULONG size;
329 DWORD res;
330 ULONG name_len;
331 ULONG name_offset;
332 ULONG module_len;
333 ULONG module_offset;
334 } *wndclass;
335 const WCHAR *module, *ret;
336 UNICODE_STRING name_us;
337 HMODULE hmod;
339 if (basename_offset)
340 *basename_offset = 0;
342 if (IS_INTRESOURCE( name ))
343 return name;
345 if (is_comctl32_class( name ) || is_builtin_class( name ))
346 return name;
348 data.cbSize = sizeof(data);
349 RtlInitUnicodeString(&name_us, name);
350 if (RtlFindActivationContextSectionString(0, NULL, ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION,
351 &name_us, &data))
352 return name;
354 wndclass = (struct wndclass_redirect_data *)data.lpData;
355 if (basename_offset)
356 *basename_offset = wndclass->name_len / sizeof(WCHAR) - strlenW(name);
358 module = (const WCHAR *)((BYTE *)data.lpSectionBase + wndclass->module_offset);
359 if (!(hmod = GetModuleHandleW( module )))
360 hmod = LoadLibraryW( module );
362 ret = (const WCHAR *)((BYTE *)wndclass + wndclass->name_offset);
364 if (register_class && hmod)
366 BOOL found = FALSE;
367 struct list *ptr;
369 USER_Lock();
371 LIST_FOR_EACH( ptr, &class_list )
373 CLASS *class = LIST_ENTRY( ptr, CLASS, entry );
374 if (strcmpiW( class->name, ret )) continue;
375 if (!class->local || class->hInstance == hmod)
377 found = TRUE;
378 break;
382 USER_Unlock();
384 if (!found)
386 BOOL (WINAPI *pRegisterClassNameW)(const WCHAR *class);
388 pRegisterClassNameW = (void *)GetProcAddress(hmod, "RegisterClassNameW");
389 if (pRegisterClassNameW)
390 pRegisterClassNameW(name);
394 return ret;
397 /***********************************************************************
398 * CLASS_FindClass
400 * Return a pointer to the class.
402 static CLASS *CLASS_FindClass( LPCWSTR name, HINSTANCE hinstance )
404 static const WCHAR comctl32W[] = {'c','o','m','c','t','l','3','2','.','d','l','l',0};
405 struct list *ptr;
406 ATOM atom = get_int_atom_value( name );
408 GetDesktopWindow(); /* create the desktop window to trigger builtin class registration */
410 if (!name) return NULL;
412 name = CLASS_GetVersionedName( name, NULL, TRUE );
414 for (;;)
416 USER_Lock();
418 LIST_FOR_EACH( ptr, &class_list )
420 CLASS *class = LIST_ENTRY( ptr, CLASS, entry );
421 if (atom)
423 if (class->atomName != atom) continue;
425 else
427 if (strcmpiW( class->name, name )) continue;
429 if (!class->local || class->hInstance == hinstance)
431 TRACE("%s %p -> %p\n", debugstr_w(name), hinstance, class);
432 return class;
435 USER_Unlock();
437 if (atom) break;
438 if (!is_comctl32_class( name )) break;
439 if (GetModuleHandleW( comctl32W )) break;
440 if (!LoadLibraryW( comctl32W )) break;
441 TRACE( "%s retrying after loading comctl32\n", debugstr_w(name) );
444 TRACE("%s %p -> not found\n", debugstr_w(name), hinstance);
445 return NULL;
448 /***********************************************************************
449 * CLASS_RegisterClass
451 * The real RegisterClass() functionality.
453 static CLASS *CLASS_RegisterClass( LPCWSTR name, UINT basename_offset, HINSTANCE hInstance, BOOL local,
454 DWORD style, INT classExtra, INT winExtra )
456 CLASS *classPtr;
457 BOOL ret;
459 TRACE("name=%s hinst=%p style=0x%x clExtr=0x%x winExtr=0x%x\n",
460 debugstr_w(name), hInstance, style, classExtra, winExtra );
462 /* Fix the extra bytes value */
464 if (classExtra > 40) /* Extra bytes are limited to 40 in Win32 */
465 WARN("Class extra bytes %d is > 40\n", classExtra);
466 if (winExtra > 40) /* Extra bytes are limited to 40 in Win32 */
467 WARN("Win extra bytes %d is > 40\n", winExtra );
469 classPtr = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(CLASS) + classExtra );
470 if (!classPtr) return NULL;
472 classPtr->atomName = get_int_atom_value( name );
473 classPtr->basename = classPtr->name;
474 if (!classPtr->atomName && name)
476 strcpyW( classPtr->name, name );
477 classPtr->basename += basename_offset;
479 else GlobalGetAtomNameW( classPtr->atomName, classPtr->name, ARRAY_SIZE( classPtr->name ));
481 SERVER_START_REQ( create_class )
483 req->local = local;
484 req->style = style;
485 req->instance = wine_server_client_ptr( hInstance );
486 req->extra = classExtra;
487 req->win_extra = winExtra;
488 req->client_ptr = wine_server_client_ptr( classPtr );
489 req->atom = classPtr->atomName;
490 req->name_offset = basename_offset;
491 if (!req->atom && name) wine_server_add_data( req, name, strlenW(name) * sizeof(WCHAR) );
492 ret = !wine_server_call_err( req );
493 classPtr->atomName = reply->atom;
495 SERVER_END_REQ;
496 if (!ret)
498 HeapFree( GetProcessHeap(), 0, classPtr );
499 return NULL;
502 classPtr->style = style;
503 classPtr->local = local;
504 classPtr->cbWndExtra = winExtra;
505 classPtr->cbClsExtra = classExtra;
506 classPtr->hInstance = hInstance;
508 /* Other non-null values must be set by caller */
510 USER_Lock();
511 if (local) list_add_head( &class_list, &classPtr->entry );
512 else list_add_tail( &class_list, &classPtr->entry );
513 return classPtr;
517 /***********************************************************************
518 * register_builtin
520 * Register a builtin control class.
521 * This allows having both ASCII and Unicode winprocs for the same class.
523 static void register_builtin( const struct builtin_class_descr *descr )
525 CLASS *classPtr;
527 if (!(classPtr = CLASS_RegisterClass( descr->name, 0, user32_module, FALSE,
528 descr->style, 0, descr->extra ))) return;
530 if (descr->cursor) classPtr->hCursor = LoadCursorA( 0, (LPSTR)descr->cursor );
531 classPtr->hbrBackground = descr->brush;
532 classPtr->winproc = BUILTIN_WINPROC( descr->proc );
533 release_class_ptr( classPtr );
537 /***********************************************************************
538 * register_builtins
540 static BOOL WINAPI register_builtins( INIT_ONCE *once, void *param, void **context )
542 register_builtin( &BUTTON_builtin_class );
543 register_builtin( &COMBO_builtin_class );
544 register_builtin( &COMBOLBOX_builtin_class );
545 register_builtin( &DIALOG_builtin_class );
546 register_builtin( &EDIT_builtin_class );
547 register_builtin( &ICONTITLE_builtin_class );
548 register_builtin( &LISTBOX_builtin_class );
549 register_builtin( &MDICLIENT_builtin_class );
550 register_builtin( &MENU_builtin_class );
551 register_builtin( &SCROLL_builtin_class );
552 register_builtin( &STATIC_builtin_class );
553 register_builtin( &IME_builtin_class );
554 return TRUE;
558 /***********************************************************************
559 * register_builtin_classes
561 void register_builtin_classes(void)
563 InitOnceExecuteOnce( &init_once, register_builtins, NULL, NULL );
567 /***********************************************************************
568 * register_desktop_class
570 void register_desktop_class(void)
572 register_builtin( &DESKTOP_builtin_class );
573 register_builtin( &MESSAGE_builtin_class );
577 /***********************************************************************
578 * get_class_winproc
580 WNDPROC get_class_winproc( CLASS *class )
582 return class->winproc;
586 /***********************************************************************
587 * get_class_dce
589 struct dce *get_class_dce( CLASS *class )
591 return class->dce;
595 /***********************************************************************
596 * set_class_dce
598 struct dce *set_class_dce( CLASS *class, struct dce *dce )
600 if (class->dce) return class->dce; /* already set, don't change it */
601 class->dce = dce;
602 return dce;
606 /***********************************************************************
607 * RegisterClassA (USER32.@)
609 * Register a window class.
611 * RETURNS
612 * >0: Unique identifier
613 * 0: Failure
615 ATOM WINAPI RegisterClassA( const WNDCLASSA* wc ) /* [in] Address of structure with class data */
617 WNDCLASSEXA wcex;
619 wcex.cbSize = sizeof(wcex);
620 wcex.style = wc->style;
621 wcex.lpfnWndProc = wc->lpfnWndProc;
622 wcex.cbClsExtra = wc->cbClsExtra;
623 wcex.cbWndExtra = wc->cbWndExtra;
624 wcex.hInstance = wc->hInstance;
625 wcex.hIcon = wc->hIcon;
626 wcex.hCursor = wc->hCursor;
627 wcex.hbrBackground = wc->hbrBackground;
628 wcex.lpszMenuName = wc->lpszMenuName;
629 wcex.lpszClassName = wc->lpszClassName;
630 wcex.hIconSm = 0;
631 return RegisterClassExA( &wcex );
635 /***********************************************************************
636 * RegisterClassW (USER32.@)
638 * See RegisterClassA.
640 ATOM WINAPI RegisterClassW( const WNDCLASSW* wc )
642 WNDCLASSEXW wcex;
644 wcex.cbSize = sizeof(wcex);
645 wcex.style = wc->style;
646 wcex.lpfnWndProc = wc->lpfnWndProc;
647 wcex.cbClsExtra = wc->cbClsExtra;
648 wcex.cbWndExtra = wc->cbWndExtra;
649 wcex.hInstance = wc->hInstance;
650 wcex.hIcon = wc->hIcon;
651 wcex.hCursor = wc->hCursor;
652 wcex.hbrBackground = wc->hbrBackground;
653 wcex.lpszMenuName = wc->lpszMenuName;
654 wcex.lpszClassName = wc->lpszClassName;
655 wcex.hIconSm = 0;
656 return RegisterClassExW( &wcex );
660 /***********************************************************************
661 * RegisterClassExA (USER32.@)
663 ATOM WINAPI RegisterClassExA( const WNDCLASSEXA* wc )
665 const WCHAR *classname = NULL;
666 WCHAR name[MAX_ATOM_LEN + 1];
667 ATOM atom;
668 CLASS *classPtr;
669 HINSTANCE instance;
671 GetDesktopWindow(); /* create the desktop window to trigger builtin class registration */
673 if (wc->cbSize != sizeof(*wc) || wc->cbClsExtra < 0 || wc->cbWndExtra < 0 ||
674 wc->hInstance == user32_module) /* we can't register a class for user32 */
676 SetLastError( ERROR_INVALID_PARAMETER );
677 return 0;
679 if (!(instance = wc->hInstance)) instance = GetModuleHandleW( NULL );
681 if (!IS_INTRESOURCE(wc->lpszClassName))
683 UINT basename_offset;
684 if (!MultiByteToWideChar( CP_ACP, 0, wc->lpszClassName, -1, name, MAX_ATOM_LEN + 1 )) return 0;
685 classname = CLASS_GetVersionedName( name, &basename_offset, FALSE );
686 classPtr = CLASS_RegisterClass( classname, basename_offset, instance, !(wc->style & CS_GLOBALCLASS),
687 wc->style, wc->cbClsExtra, wc->cbWndExtra );
689 else
691 classPtr = CLASS_RegisterClass( (LPCWSTR)wc->lpszClassName, 0, instance,
692 !(wc->style & CS_GLOBALCLASS), wc->style,
693 wc->cbClsExtra, wc->cbWndExtra );
695 if (!classPtr) return 0;
696 atom = classPtr->atomName;
698 TRACE("name=%s%s%s atom=%04x wndproc=%p hinst=%p bg=%p style=%08x clsExt=%d winExt=%d class=%p\n",
699 debugstr_a(wc->lpszClassName), classname != name ? "->" : "", classname != name ? debugstr_w(classname) : "",
700 atom, wc->lpfnWndProc, instance, wc->hbrBackground, wc->style, wc->cbClsExtra, wc->cbWndExtra, classPtr );
702 classPtr->hIcon = wc->hIcon;
703 classPtr->hIconSm = wc->hIconSm;
704 classPtr->hIconSmIntern = wc->hIcon && !wc->hIconSm ?
705 CopyImage( wc->hIcon, IMAGE_ICON,
706 GetSystemMetrics( SM_CXSMICON ),
707 GetSystemMetrics( SM_CYSMICON ),
708 LR_COPYFROMRESOURCE ) : NULL;
709 classPtr->hCursor = wc->hCursor;
710 classPtr->hbrBackground = wc->hbrBackground;
711 classPtr->winproc = WINPROC_AllocProc( wc->lpfnWndProc, FALSE );
712 CLASS_SetMenuNameA( classPtr, wc->lpszMenuName );
713 release_class_ptr( classPtr );
714 return atom;
718 /***********************************************************************
719 * RegisterClassExW (USER32.@)
721 ATOM WINAPI RegisterClassExW( const WNDCLASSEXW* wc )
723 const WCHAR *classname;
724 UINT basename_offset;
725 ATOM atom;
726 CLASS *classPtr;
727 HINSTANCE instance;
729 GetDesktopWindow(); /* create the desktop window to trigger builtin class registration */
731 if (wc->cbSize != sizeof(*wc) || wc->cbClsExtra < 0 || wc->cbWndExtra < 0 ||
732 wc->hInstance == user32_module) /* we can't register a class for user32 */
734 SetLastError( ERROR_INVALID_PARAMETER );
735 return 0;
737 if (!(instance = wc->hInstance)) instance = GetModuleHandleW( NULL );
739 classname = CLASS_GetVersionedName( wc->lpszClassName, &basename_offset, FALSE );
740 if (!(classPtr = CLASS_RegisterClass( classname, basename_offset, instance, !(wc->style & CS_GLOBALCLASS),
741 wc->style, wc->cbClsExtra, wc->cbWndExtra )))
742 return 0;
744 atom = classPtr->atomName;
746 TRACE("name=%s%s%s atom=%04x wndproc=%p hinst=%p bg=%p style=%08x clsExt=%d winExt=%d class=%p\n",
747 debugstr_w(wc->lpszClassName), classname != wc->lpszClassName ? "->" : "",
748 classname != wc->lpszClassName ? debugstr_w(classname) : "", atom, wc->lpfnWndProc, instance,
749 wc->hbrBackground, wc->style, wc->cbClsExtra, wc->cbWndExtra, classPtr );
751 classPtr->hIcon = wc->hIcon;
752 classPtr->hIconSm = wc->hIconSm;
753 classPtr->hIconSmIntern = wc->hIcon && !wc->hIconSm ?
754 CopyImage( wc->hIcon, IMAGE_ICON,
755 GetSystemMetrics( SM_CXSMICON ),
756 GetSystemMetrics( SM_CYSMICON ),
757 LR_COPYFROMRESOURCE ) : NULL;
758 classPtr->hCursor = wc->hCursor;
759 classPtr->hbrBackground = wc->hbrBackground;
760 classPtr->winproc = WINPROC_AllocProc( wc->lpfnWndProc, TRUE );
761 CLASS_SetMenuNameW( classPtr, wc->lpszMenuName );
762 release_class_ptr( classPtr );
763 return atom;
767 /***********************************************************************
768 * UnregisterClassA (USER32.@)
770 BOOL WINAPI UnregisterClassA( LPCSTR className, HINSTANCE hInstance )
772 if (!IS_INTRESOURCE(className))
774 WCHAR name[MAX_ATOM_LEN + 1];
776 if (!MultiByteToWideChar( CP_ACP, 0, className, -1, name, MAX_ATOM_LEN + 1 ))
777 return FALSE;
778 return UnregisterClassW( name, hInstance );
780 return UnregisterClassW( (LPCWSTR)className, hInstance );
783 /***********************************************************************
784 * UnregisterClassW (USER32.@)
786 BOOL WINAPI UnregisterClassW( LPCWSTR className, HINSTANCE hInstance )
788 CLASS *classPtr = NULL;
790 GetDesktopWindow(); /* create the desktop window to trigger builtin class registration */
792 className = CLASS_GetVersionedName( className, NULL, FALSE );
793 SERVER_START_REQ( destroy_class )
795 req->instance = wine_server_client_ptr( hInstance );
796 if (!(req->atom = get_int_atom_value(className)) && className)
797 wine_server_add_data( req, className, strlenW(className) * sizeof(WCHAR) );
798 if (!wine_server_call_err( req )) classPtr = wine_server_get_ptr( reply->client_ptr );
800 SERVER_END_REQ;
802 if (classPtr) CLASS_FreeClass( classPtr );
803 return (classPtr != NULL);
807 /***********************************************************************
808 * GetClassWord (USER32.@)
810 WORD WINAPI GetClassWord( HWND hwnd, INT offset )
812 CLASS *class;
813 WORD retvalue = 0;
815 if (offset < 0) return GetClassLongA( hwnd, offset );
817 if (!(class = get_class_ptr( hwnd, FALSE ))) return 0;
819 if (class == CLASS_OTHER_PROCESS)
821 SERVER_START_REQ( set_class_info )
823 req->window = wine_server_user_handle( hwnd );
824 req->flags = 0;
825 req->extra_offset = offset;
826 req->extra_size = sizeof(retvalue);
827 if (!wine_server_call_err( req ))
828 memcpy( &retvalue, &reply->old_extra_value, sizeof(retvalue) );
830 SERVER_END_REQ;
831 return retvalue;
834 if (offset <= class->cbClsExtra - sizeof(WORD))
835 memcpy( &retvalue, (char *)(class + 1) + offset, sizeof(retvalue) );
836 else
837 SetLastError( ERROR_INVALID_INDEX );
838 release_class_ptr( class );
839 return retvalue;
843 /***********************************************************************
844 * CLASS_GetClassLong
846 * Implementation of GetClassLong(Ptr)A/W
848 static ULONG_PTR CLASS_GetClassLong( HWND hwnd, INT offset, UINT size,
849 BOOL unicode )
851 CLASS *class;
852 ULONG_PTR retvalue = 0;
854 if (!(class = get_class_ptr( hwnd, FALSE ))) return 0;
856 if (class == CLASS_OTHER_PROCESS)
858 SERVER_START_REQ( set_class_info )
860 req->window = wine_server_user_handle( hwnd );
861 req->flags = 0;
862 req->extra_offset = (offset >= 0) ? offset : -1;
863 req->extra_size = (offset >= 0) ? size : 0;
864 if (!wine_server_call_err( req ))
866 switch(offset)
868 case GCLP_HBRBACKGROUND:
869 case GCLP_HCURSOR:
870 case GCLP_HICON:
871 case GCLP_HICONSM:
872 case GCLP_WNDPROC:
873 case GCLP_MENUNAME:
874 FIXME( "offset %d (%s) not supported on other process window %p\n",
875 offset, SPY_GetClassLongOffsetName(offset), hwnd );
876 SetLastError( ERROR_INVALID_HANDLE );
877 break;
878 case GCL_STYLE:
879 retvalue = reply->old_style;
880 break;
881 case GCL_CBWNDEXTRA:
882 retvalue = reply->old_win_extra;
883 break;
884 case GCL_CBCLSEXTRA:
885 retvalue = reply->old_extra;
886 break;
887 case GCLP_HMODULE:
888 retvalue = (ULONG_PTR)wine_server_get_ptr( reply->old_instance );
889 break;
890 case GCW_ATOM:
891 retvalue = reply->old_atom;
892 break;
893 default:
894 if (offset >= 0)
896 if (size == sizeof(DWORD))
898 DWORD retdword;
899 memcpy( &retdword, &reply->old_extra_value, sizeof(DWORD) );
900 retvalue = retdword;
902 else
903 memcpy( &retvalue, &reply->old_extra_value,
904 sizeof(ULONG_PTR) );
906 else SetLastError( ERROR_INVALID_INDEX );
907 break;
911 SERVER_END_REQ;
912 return retvalue;
915 if (offset >= 0)
917 if (offset <= class->cbClsExtra - size)
919 if (size == sizeof(DWORD))
921 DWORD retdword;
922 memcpy( &retdword, (char *)(class + 1) + offset, sizeof(DWORD) );
923 retvalue = retdword;
925 else
926 memcpy( &retvalue, (char *)(class + 1) + offset, sizeof(ULONG_PTR) );
928 else
929 SetLastError( ERROR_INVALID_INDEX );
930 release_class_ptr( class );
931 return retvalue;
934 switch(offset)
936 case GCLP_HBRBACKGROUND:
937 retvalue = (ULONG_PTR)class->hbrBackground;
938 break;
939 case GCLP_HCURSOR:
940 retvalue = (ULONG_PTR)class->hCursor;
941 break;
942 case GCLP_HICON:
943 retvalue = (ULONG_PTR)class->hIcon;
944 break;
945 case GCLP_HICONSM:
946 retvalue = (ULONG_PTR)(class->hIconSm ? class->hIconSm : class->hIconSmIntern);
947 break;
948 case GCL_STYLE:
949 retvalue = class->style;
950 break;
951 case GCL_CBWNDEXTRA:
952 retvalue = class->cbWndExtra;
953 break;
954 case GCL_CBCLSEXTRA:
955 retvalue = class->cbClsExtra;
956 break;
957 case GCLP_HMODULE:
958 retvalue = (ULONG_PTR)class->hInstance;
959 break;
960 case GCLP_WNDPROC:
961 retvalue = (ULONG_PTR)WINPROC_GetProc( class->winproc, unicode );
962 break;
963 case GCLP_MENUNAME:
964 retvalue = (ULONG_PTR)CLASS_GetMenuNameW( class );
965 if (unicode)
966 retvalue = (ULONG_PTR)CLASS_GetMenuNameW( class );
967 else
968 retvalue = (ULONG_PTR)CLASS_GetMenuNameA( class );
969 break;
970 case GCW_ATOM:
971 retvalue = class->atomName;
972 break;
973 default:
974 SetLastError( ERROR_INVALID_INDEX );
975 break;
977 release_class_ptr( class );
978 return retvalue;
982 /***********************************************************************
983 * GetClassLongW (USER32.@)
985 DWORD WINAPI GetClassLongW( HWND hwnd, INT offset )
987 return CLASS_GetClassLong( hwnd, offset, sizeof(DWORD), TRUE );
992 /***********************************************************************
993 * GetClassLongA (USER32.@)
995 DWORD WINAPI GetClassLongA( HWND hwnd, INT offset )
997 return CLASS_GetClassLong( hwnd, offset, sizeof(DWORD), FALSE );
1001 /***********************************************************************
1002 * SetClassWord (USER32.@)
1004 WORD WINAPI SetClassWord( HWND hwnd, INT offset, WORD newval )
1006 CLASS *class;
1007 WORD retval = 0;
1009 if (offset < 0) return SetClassLongA( hwnd, offset, (DWORD)newval );
1011 if (!(class = get_class_ptr( hwnd, TRUE ))) return 0;
1013 SERVER_START_REQ( set_class_info )
1015 req->window = wine_server_user_handle( hwnd );
1016 req->flags = SET_CLASS_EXTRA;
1017 req->extra_offset = offset;
1018 req->extra_size = sizeof(newval);
1019 memcpy( &req->extra_value, &newval, sizeof(newval) );
1020 if (!wine_server_call_err( req ))
1022 void *ptr = (char *)(class + 1) + offset;
1023 memcpy( &retval, ptr, sizeof(retval) );
1024 memcpy( ptr, &newval, sizeof(newval) );
1027 SERVER_END_REQ;
1028 release_class_ptr( class );
1029 return retval;
1033 /***********************************************************************
1034 * CLASS_SetClassLong
1036 * Implementation of SetClassLong(Ptr)A/W
1038 static ULONG_PTR CLASS_SetClassLong( HWND hwnd, INT offset, LONG_PTR newval,
1039 UINT size, BOOL unicode )
1041 CLASS *class;
1042 ULONG_PTR retval = 0;
1044 if (!(class = get_class_ptr( hwnd, TRUE ))) return 0;
1046 if (offset >= 0)
1048 if (set_server_info( hwnd, offset, newval, size ))
1050 void *ptr = (char *)(class + 1) + offset;
1051 if ( size == sizeof(LONG) )
1053 DWORD retdword;
1054 LONG newlong = newval;
1055 memcpy( &retdword, ptr, sizeof(DWORD) );
1056 memcpy( ptr, &newlong, sizeof(LONG) );
1057 retval = retdword;
1059 else
1061 memcpy( &retval, ptr, sizeof(ULONG_PTR) );
1062 memcpy( ptr, &newval, sizeof(LONG_PTR) );
1066 else switch(offset)
1068 case GCLP_MENUNAME:
1069 if ( unicode )
1070 CLASS_SetMenuNameW( class, (LPCWSTR)newval );
1071 else
1072 CLASS_SetMenuNameA( class, (LPCSTR)newval );
1073 retval = 0; /* Old value is now meaningless anyway */
1074 break;
1075 case GCLP_WNDPROC:
1076 retval = (ULONG_PTR)WINPROC_GetProc( class->winproc, unicode );
1077 class->winproc = WINPROC_AllocProc( (WNDPROC)newval, unicode );
1078 break;
1079 case GCLP_HBRBACKGROUND:
1080 retval = (ULONG_PTR)class->hbrBackground;
1081 class->hbrBackground = (HBRUSH)newval;
1082 break;
1083 case GCLP_HCURSOR:
1084 retval = (ULONG_PTR)class->hCursor;
1085 class->hCursor = (HCURSOR)newval;
1086 break;
1087 case GCLP_HICON:
1088 retval = (ULONG_PTR)class->hIcon;
1089 if (class->hIconSmIntern)
1091 DestroyIcon(class->hIconSmIntern);
1092 class->hIconSmIntern = NULL;
1094 if (newval && !class->hIconSm)
1095 class->hIconSmIntern = CopyImage( (HICON)newval, IMAGE_ICON,
1096 GetSystemMetrics( SM_CXSMICON ), GetSystemMetrics( SM_CYSMICON ),
1097 LR_COPYFROMRESOURCE );
1098 class->hIcon = (HICON)newval;
1099 break;
1100 case GCLP_HICONSM:
1101 retval = (ULONG_PTR)class->hIconSm;
1102 if (retval && !newval && class->hIcon)
1103 class->hIconSmIntern = CopyImage( class->hIcon, IMAGE_ICON,
1104 GetSystemMetrics( SM_CXSMICON ), GetSystemMetrics( SM_CYSMICON ),
1105 LR_COPYFROMRESOURCE );
1106 else if (newval && class->hIconSmIntern)
1108 DestroyIcon(class->hIconSmIntern);
1109 class->hIconSmIntern = NULL;
1111 class->hIconSm = (HICON)newval;
1112 break;
1113 case GCL_STYLE:
1114 if (!set_server_info( hwnd, offset, newval, size )) break;
1115 retval = class->style;
1116 class->style = newval;
1117 break;
1118 case GCL_CBWNDEXTRA:
1119 if (!set_server_info( hwnd, offset, newval, size )) break;
1120 retval = class->cbWndExtra;
1121 class->cbWndExtra = newval;
1122 break;
1123 case GCLP_HMODULE:
1124 if (!set_server_info( hwnd, offset, newval, size )) break;
1125 retval = (ULONG_PTR)class->hInstance;
1126 class->hInstance = (HINSTANCE)newval;
1127 break;
1128 case GCW_ATOM:
1129 if (!set_server_info( hwnd, offset, newval, size )) break;
1130 retval = class->atomName;
1131 class->atomName = newval;
1132 GlobalGetAtomNameW( newval, class->name, ARRAY_SIZE( class->name ));
1133 break;
1134 case GCL_CBCLSEXTRA: /* cannot change this one */
1135 SetLastError( ERROR_INVALID_PARAMETER );
1136 break;
1137 default:
1138 SetLastError( ERROR_INVALID_INDEX );
1139 break;
1141 release_class_ptr( class );
1142 return retval;
1146 /***********************************************************************
1147 * SetClassLongW (USER32.@)
1149 DWORD WINAPI SetClassLongW( HWND hwnd, INT offset, LONG newval )
1151 return CLASS_SetClassLong( hwnd, offset, newval, sizeof(LONG), TRUE );
1155 /***********************************************************************
1156 * SetClassLongA (USER32.@)
1158 DWORD WINAPI SetClassLongA( HWND hwnd, INT offset, LONG newval )
1160 return CLASS_SetClassLong( hwnd, offset, newval, sizeof(LONG), FALSE );
1164 /***********************************************************************
1165 * GetClassNameA (USER32.@)
1167 INT WINAPI GetClassNameA( HWND hwnd, LPSTR buffer, INT count )
1169 WCHAR tmpbuf[MAX_ATOM_LEN + 1];
1170 DWORD len;
1172 if (count <= 0) return 0;
1173 if (!GetClassNameW( hwnd, tmpbuf, ARRAY_SIZE( tmpbuf ))) return 0;
1174 RtlUnicodeToMultiByteN( buffer, count - 1, &len, tmpbuf, strlenW(tmpbuf) * sizeof(WCHAR) );
1175 buffer[len] = 0;
1176 return len;
1180 /***********************************************************************
1181 * GetClassNameW (USER32.@)
1183 INT WINAPI GetClassNameW( HWND hwnd, LPWSTR buffer, INT count )
1185 CLASS *class;
1186 INT ret;
1188 TRACE("%p %p %d\n", hwnd, buffer, count);
1190 if (count <= 0) return 0;
1192 if (!(class = get_class_ptr( hwnd, FALSE ))) return 0;
1194 if (class == CLASS_OTHER_PROCESS)
1196 WCHAR tmpbuf[MAX_ATOM_LEN + 1];
1197 ATOM atom = 0;
1199 SERVER_START_REQ( set_class_info )
1201 req->window = wine_server_user_handle( hwnd );
1202 req->flags = 0;
1203 req->extra_offset = -1;
1204 req->extra_size = 0;
1205 if (!wine_server_call_err( req ))
1206 atom = reply->base_atom;
1208 SERVER_END_REQ;
1210 ret = GlobalGetAtomNameW( atom, tmpbuf, MAX_ATOM_LEN + 1 );
1211 if (ret)
1213 ret = min(count - 1, ret);
1214 memcpy(buffer, tmpbuf, ret * sizeof(WCHAR));
1215 buffer[ret] = 0;
1218 else
1220 /* Return original name class was registered with. */
1221 lstrcpynW( buffer, class->basename, count );
1222 release_class_ptr( class );
1223 ret = strlenW( buffer );
1225 return ret;
1229 /***********************************************************************
1230 * RealGetWindowClassA (USER32.@)
1232 UINT WINAPI RealGetWindowClassA( HWND hwnd, LPSTR buffer, UINT count )
1234 return GetClassNameA( hwnd, buffer, count );
1238 /***********************************************************************
1239 * RealGetWindowClassW (USER32.@)
1241 UINT WINAPI RealGetWindowClassW( HWND hwnd, LPWSTR buffer, UINT count )
1243 return GetClassNameW( hwnd, buffer, count );
1247 /***********************************************************************
1248 * GetClassInfoA (USER32.@)
1250 BOOL WINAPI GetClassInfoA( HINSTANCE hInstance, LPCSTR name, WNDCLASSA *wc )
1252 WNDCLASSEXA wcex;
1253 UINT ret = GetClassInfoExA( hInstance, name, &wcex );
1255 if (ret)
1257 wc->style = wcex.style;
1258 wc->lpfnWndProc = wcex.lpfnWndProc;
1259 wc->cbClsExtra = wcex.cbClsExtra;
1260 wc->cbWndExtra = wcex.cbWndExtra;
1261 wc->hInstance = wcex.hInstance;
1262 wc->hIcon = wcex.hIcon;
1263 wc->hCursor = wcex.hCursor;
1264 wc->hbrBackground = wcex.hbrBackground;
1265 wc->lpszMenuName = wcex.lpszMenuName;
1266 wc->lpszClassName = wcex.lpszClassName;
1268 return ret;
1272 /***********************************************************************
1273 * GetClassInfoW (USER32.@)
1275 BOOL WINAPI GetClassInfoW( HINSTANCE hInstance, LPCWSTR name, WNDCLASSW *wc )
1277 WNDCLASSEXW wcex;
1278 UINT ret = GetClassInfoExW( hInstance, name, &wcex );
1280 if (ret)
1282 wc->style = wcex.style;
1283 wc->lpfnWndProc = wcex.lpfnWndProc;
1284 wc->cbClsExtra = wcex.cbClsExtra;
1285 wc->cbWndExtra = wcex.cbWndExtra;
1286 wc->hInstance = wcex.hInstance;
1287 wc->hIcon = wcex.hIcon;
1288 wc->hCursor = wcex.hCursor;
1289 wc->hbrBackground = wcex.hbrBackground;
1290 wc->lpszMenuName = wcex.lpszMenuName;
1291 wc->lpszClassName = wcex.lpszClassName;
1293 return ret;
1297 /***********************************************************************
1298 * GetClassInfoExA (USER32.@)
1300 BOOL WINAPI GetClassInfoExA( HINSTANCE hInstance, LPCSTR name, WNDCLASSEXA *wc )
1302 ATOM atom;
1303 CLASS *classPtr;
1305 TRACE("%p %s %p\n", hInstance, debugstr_a(name), wc);
1307 if (!wc)
1309 SetLastError( ERROR_NOACCESS );
1310 return FALSE;
1313 if (!hInstance) hInstance = user32_module;
1315 if (!IS_INTRESOURCE(name))
1317 WCHAR nameW[MAX_ATOM_LEN + 1];
1318 if (!MultiByteToWideChar( CP_ACP, 0, name, -1, nameW, ARRAY_SIZE( nameW )))
1319 return FALSE;
1320 classPtr = CLASS_FindClass( nameW, hInstance );
1322 else classPtr = CLASS_FindClass( (LPCWSTR)name, hInstance );
1324 if (!classPtr)
1326 SetLastError( ERROR_CLASS_DOES_NOT_EXIST );
1327 return FALSE;
1329 wc->style = classPtr->style;
1330 wc->lpfnWndProc = WINPROC_GetProc( classPtr->winproc, FALSE );
1331 wc->cbClsExtra = classPtr->cbClsExtra;
1332 wc->cbWndExtra = classPtr->cbWndExtra;
1333 wc->hInstance = (hInstance == user32_module) ? 0 : hInstance;
1334 wc->hIcon = classPtr->hIcon;
1335 wc->hIconSm = classPtr->hIconSm ? classPtr->hIconSm : classPtr->hIconSmIntern;
1336 wc->hCursor = classPtr->hCursor;
1337 wc->hbrBackground = classPtr->hbrBackground;
1338 wc->lpszMenuName = CLASS_GetMenuNameA( classPtr );
1339 wc->lpszClassName = name;
1340 atom = classPtr->atomName;
1341 release_class_ptr( classPtr );
1343 /* We must return the atom of the class here instead of just TRUE. */
1344 return atom;
1348 /***********************************************************************
1349 * GetClassInfoExW (USER32.@)
1351 BOOL WINAPI GetClassInfoExW( HINSTANCE hInstance, LPCWSTR name, WNDCLASSEXW *wc )
1353 ATOM atom;
1354 CLASS *classPtr;
1356 TRACE("%p %s %p\n", hInstance, debugstr_w(name), wc);
1358 if (!wc)
1360 SetLastError( ERROR_NOACCESS );
1361 return FALSE;
1364 if (!hInstance) hInstance = user32_module;
1366 if (!(classPtr = CLASS_FindClass( name, hInstance )))
1368 SetLastError( ERROR_CLASS_DOES_NOT_EXIST );
1369 return FALSE;
1371 wc->style = classPtr->style;
1372 wc->lpfnWndProc = WINPROC_GetProc( classPtr->winproc, TRUE );
1373 wc->cbClsExtra = classPtr->cbClsExtra;
1374 wc->cbWndExtra = classPtr->cbWndExtra;
1375 wc->hInstance = (hInstance == user32_module) ? 0 : hInstance;
1376 wc->hIcon = classPtr->hIcon;
1377 wc->hIconSm = classPtr->hIconSm ? classPtr->hIconSm : classPtr->hIconSmIntern;
1378 wc->hCursor = classPtr->hCursor;
1379 wc->hbrBackground = classPtr->hbrBackground;
1380 wc->lpszMenuName = CLASS_GetMenuNameW( classPtr );
1381 wc->lpszClassName = name;
1382 atom = classPtr->atomName;
1383 release_class_ptr( classPtr );
1385 /* We must return the atom of the class here instead of just TRUE. */
1386 return atom;
1390 #if 0 /* toolhelp is in kernel, so this cannot work */
1392 /***********************************************************************
1393 * ClassFirst (TOOLHELP.69)
1395 BOOL16 WINAPI ClassFirst16( CLASSENTRY *pClassEntry )
1397 TRACE("%p\n",pClassEntry);
1398 pClassEntry->wNext = 1;
1399 return ClassNext16( pClassEntry );
1403 /***********************************************************************
1404 * ClassNext (TOOLHELP.70)
1406 BOOL16 WINAPI ClassNext16( CLASSENTRY *pClassEntry )
1408 int i;
1409 CLASS *class = firstClass;
1411 TRACE("%p\n",pClassEntry);
1413 if (!pClassEntry->wNext) return FALSE;
1414 for (i = 1; (i < pClassEntry->wNext) && class; i++) class = class->next;
1415 if (!class)
1417 pClassEntry->wNext = 0;
1418 return FALSE;
1420 pClassEntry->hInst = class->hInstance;
1421 pClassEntry->wNext++;
1422 GlobalGetAtomNameA( class->atomName, pClassEntry->szClassName,
1423 sizeof(pClassEntry->szClassName) );
1424 return TRUE;
1426 #endif
1428 /* 64bit versions */
1430 #ifdef GetClassLongPtrA
1431 #undef GetClassLongPtrA
1432 #endif
1434 #ifdef GetClassLongPtrW
1435 #undef GetClassLongPtrW
1436 #endif
1438 #ifdef SetClassLongPtrA
1439 #undef SetClassLongPtrA
1440 #endif
1442 #ifdef SetClassLongPtrW
1443 #undef SetClassLongPtrW
1444 #endif
1446 /***********************************************************************
1447 * GetClassLongPtrA (USER32.@)
1449 ULONG_PTR WINAPI GetClassLongPtrA( HWND hwnd, INT offset )
1451 return CLASS_GetClassLong( hwnd, offset, sizeof(ULONG_PTR), FALSE );
1454 /***********************************************************************
1455 * GetClassLongPtrW (USER32.@)
1457 ULONG_PTR WINAPI GetClassLongPtrW( HWND hwnd, INT offset )
1459 return CLASS_GetClassLong( hwnd, offset, sizeof(ULONG_PTR), TRUE );
1462 /***********************************************************************
1463 * SetClassLongPtrW (USER32.@)
1465 ULONG_PTR WINAPI SetClassLongPtrW( HWND hwnd, INT offset, LONG_PTR newval )
1467 return CLASS_SetClassLong( hwnd, offset, newval, sizeof(LONG_PTR), TRUE );
1470 /***********************************************************************
1471 * SetClassLongPtrA (USER32.@)
1473 ULONG_PTR WINAPI SetClassLongPtrA( HWND hwnd, INT offset, LONG_PTR newval )
1475 return CLASS_SetClassLong( hwnd, offset, newval, sizeof(LONG_PTR), FALSE );