ucrtbase: Add support for r-value demangling in unDName.
[wine.git] / dlls / user32 / class.c
blobb37db67540014a9b1e356d0c5c750e58bb1c6a9e
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 <assert.h>
23 #include <stdarg.h>
24 #include <stdlib.h>
25 #include <string.h>
27 #include "winerror.h"
28 #include "windef.h"
29 #include "winbase.h"
30 #include "wingdi.h"
31 #include "winnls.h"
32 #include "win.h"
33 #include "user_private.h"
34 #include "controls.h"
35 #include "wine/server.h"
36 #include "wine/list.h"
37 #include "wine/debug.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(class);
41 #define MAX_ATOM_LEN 255 /* from dlls/kernel32/atom.c */
43 typedef struct tagCLASS
45 struct list entry; /* Entry in class list */
46 UINT style; /* Class style */
47 BOOL local; /* Local class? */
48 WNDPROC winproc; /* Window procedure */
49 INT cbClsExtra; /* Class extra bytes */
50 INT cbWndExtra; /* Window extra bytes */
51 LPWSTR menuName; /* Default menu name (Unicode followed by ASCII) */
52 struct dce *dce; /* Opaque pointer to class DCE */
53 HINSTANCE hInstance; /* Module that created the task */
54 HICON hIcon; /* Default icon */
55 HICON hIconSm; /* Default small icon */
56 HICON hIconSmIntern; /* Internal small icon, derived from hIcon */
57 HCURSOR hCursor; /* Default cursor */
58 HBRUSH hbrBackground; /* Default background */
59 ATOM atomName; /* Name of the class */
60 WCHAR name[MAX_ATOM_LEN + 1];
61 WCHAR *basename; /* Base name for redirected classes, pointer within 'name'. */
62 } CLASS;
64 static struct list class_list = LIST_INIT( class_list );
65 static INIT_ONCE init_once = INIT_ONCE_STATIC_INIT;
67 #define CLASS_OTHER_PROCESS ((CLASS *)1)
69 /***********************************************************************
70 * get_class_ptr
72 static CLASS *get_class_ptr( HWND hwnd, BOOL write_access )
74 WND *ptr = WIN_GetPtr( hwnd );
76 if (ptr)
78 if (ptr != WND_OTHER_PROCESS && ptr != WND_DESKTOP) return ptr->class;
79 if (!write_access) return CLASS_OTHER_PROCESS;
81 /* modifying classes in other processes is not allowed */
82 if (ptr == WND_DESKTOP || IsWindow( hwnd ))
84 SetLastError( ERROR_ACCESS_DENIED );
85 return NULL;
88 SetLastError( ERROR_INVALID_WINDOW_HANDLE );
89 return NULL;
93 /***********************************************************************
94 * release_class_ptr
96 static inline void release_class_ptr( CLASS *ptr )
98 USER_Unlock();
102 /***********************************************************************
103 * get_int_atom_value
105 ATOM get_int_atom_value( LPCWSTR name )
107 UINT ret = 0;
109 if (IS_INTRESOURCE(name)) return LOWORD(name);
110 if (*name++ != '#') return 0;
111 while (*name)
113 if (*name < '0' || *name > '9') return 0;
114 ret = ret * 10 + *name++ - '0';
115 if (ret > 0xffff) return 0;
117 return ret;
121 /***********************************************************************
122 * is_comctl32_class
124 static BOOL is_comctl32_class( const WCHAR *name )
126 static const WCHAR *classesW[] =
128 L"ComboBoxEx32",
129 L"msctls_hotkey32",
130 L"msctls_progress32",
131 L"msctls_statusbar32",
132 L"msctls_trackbar32",
133 L"msctls_updown32",
134 L"NativeFontCtl",
135 L"ReBarWindow32",
136 L"SysAnimate32",
137 L"SysDateTimePick32",
138 L"SysHeader32",
139 L"SysIPAddress32",
140 L"SysLink",
141 L"SysListView32",
142 L"SysMonthCal32",
143 L"SysPager",
144 L"SysTabControl32",
145 L"SysTreeView32",
146 L"ToolbarWindow32",
147 L"tooltips_class32",
150 int min = 0, max = ARRAY_SIZE( classesW ) - 1;
152 while (min <= max)
154 int res, pos = (min + max) / 2;
155 if (!(res = wcsicmp( name, classesW[pos] ))) return TRUE;
156 if (res < 0) max = pos - 1;
157 else min = pos + 1;
159 return FALSE;
162 static BOOL is_builtin_class( const WCHAR *name )
164 static const WCHAR *classesW[] =
166 L"IME",
167 L"MDIClient",
168 L"Scrollbar",
171 int min = 0, max = ARRAY_SIZE( classesW ) - 1;
173 while (min <= max)
175 int res, pos = (min + max) / 2;
176 if (!(res = wcsicmp( name, classesW[pos] ))) return TRUE;
177 if (res < 0) max = pos - 1;
178 else min = pos + 1;
180 return FALSE;
183 /***********************************************************************
184 * set_server_info
186 * Set class info with the wine server.
188 static BOOL set_server_info( HWND hwnd, INT offset, LONG_PTR newval, UINT size )
190 BOOL ret;
192 SERVER_START_REQ( set_class_info )
194 req->window = wine_server_user_handle( hwnd );
195 req->extra_offset = -1;
196 switch(offset)
198 case GCW_ATOM:
199 req->flags = SET_CLASS_ATOM;
200 req->atom = LOWORD(newval);
201 break;
202 case GCL_STYLE:
203 req->flags = SET_CLASS_STYLE;
204 req->style = newval;
205 break;
206 case GCL_CBWNDEXTRA:
207 req->flags = SET_CLASS_WINEXTRA;
208 req->win_extra = newval;
209 break;
210 case GCLP_HMODULE:
211 req->flags = SET_CLASS_INSTANCE;
212 req->instance = wine_server_client_ptr( (void *)newval );
213 break;
214 default:
215 assert( offset >= 0 );
216 req->flags = SET_CLASS_EXTRA;
217 req->extra_offset = offset;
218 req->extra_size = size;
219 if ( size == sizeof(LONG) )
221 LONG newlong = newval;
222 memcpy( &req->extra_value, &newlong, sizeof(LONG) );
224 else
225 memcpy( &req->extra_value, &newval, sizeof(LONG_PTR) );
226 break;
228 ret = !wine_server_call_err( req );
230 SERVER_END_REQ;
231 return ret;
235 /***********************************************************************
236 * CLASS_GetMenuNameA
238 * Get the menu name as an ANSI string.
240 static inline LPSTR CLASS_GetMenuNameA( CLASS *classPtr )
242 if (IS_INTRESOURCE(classPtr->menuName)) return (LPSTR)classPtr->menuName;
243 return (LPSTR)(classPtr->menuName + lstrlenW(classPtr->menuName) + 1);
247 /***********************************************************************
248 * CLASS_GetMenuNameW
250 * Get the menu name as a Unicode string.
252 static inline LPWSTR CLASS_GetMenuNameW( CLASS *classPtr )
254 return classPtr->menuName;
258 /***********************************************************************
259 * CLASS_SetMenuNameA
261 * Set the menu name in a class structure by copying the string.
263 static void CLASS_SetMenuNameA( CLASS *classPtr, LPCSTR name )
265 if (!IS_INTRESOURCE(classPtr->menuName)) HeapFree( GetProcessHeap(), 0, classPtr->menuName );
266 if (!IS_INTRESOURCE(name))
268 DWORD lenA = strlen(name) + 1;
269 DWORD lenW = MultiByteToWideChar( CP_ACP, 0, name, lenA, NULL, 0 );
270 classPtr->menuName = HeapAlloc( GetProcessHeap(), 0, lenA + lenW*sizeof(WCHAR) );
271 MultiByteToWideChar( CP_ACP, 0, name, lenA, classPtr->menuName, lenW );
272 memcpy( classPtr->menuName + lenW, name, lenA );
274 else classPtr->menuName = (LPWSTR)name;
278 /***********************************************************************
279 * CLASS_SetMenuNameW
281 * Set the menu name in a class structure by copying the string.
283 static void CLASS_SetMenuNameW( CLASS *classPtr, LPCWSTR name )
285 if (!IS_INTRESOURCE(classPtr->menuName)) HeapFree( GetProcessHeap(), 0, classPtr->menuName );
286 if (!IS_INTRESOURCE(name))
288 DWORD lenW = lstrlenW(name) + 1;
289 DWORD lenA = WideCharToMultiByte( CP_ACP, 0, name, lenW, NULL, 0, NULL, NULL );
290 classPtr->menuName = HeapAlloc( GetProcessHeap(), 0, lenA + lenW*sizeof(WCHAR) );
291 memcpy( classPtr->menuName, name, lenW*sizeof(WCHAR) );
292 WideCharToMultiByte( CP_ACP, 0, name, lenW,
293 (char *)(classPtr->menuName + lenW), lenA, NULL, NULL );
295 else classPtr->menuName = (LPWSTR)name;
299 /***********************************************************************
300 * CLASS_FreeClass
302 * Free a class structure.
304 static void CLASS_FreeClass( CLASS *classPtr )
306 TRACE("%p\n", classPtr);
308 USER_Lock();
310 if (classPtr->dce) free_dce( classPtr->dce, 0 );
311 list_remove( &classPtr->entry );
312 if (classPtr->hbrBackground > (HBRUSH)(COLOR_GRADIENTINACTIVECAPTION + 1))
313 DeleteObject( classPtr->hbrBackground );
314 DestroyIcon( classPtr->hIconSmIntern );
315 HeapFree( GetProcessHeap(), 0, classPtr->menuName );
316 HeapFree( GetProcessHeap(), 0, classPtr );
317 USER_Unlock();
320 const WCHAR *CLASS_GetVersionedName( const WCHAR *name, UINT *basename_offset, WCHAR *combined, BOOL register_class )
322 ACTCTX_SECTION_KEYED_DATA data;
323 struct wndclass_redirect_data
325 ULONG size;
326 DWORD res;
327 ULONG name_len;
328 ULONG name_offset;
329 ULONG module_len;
330 ULONG module_offset;
331 } *wndclass;
332 const WCHAR *module, *ret;
333 UNICODE_STRING name_us;
334 HMODULE hmod;
335 UINT offset;
337 if (!basename_offset)
338 basename_offset = &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 *basename_offset = wndclass->name_len / sizeof(WCHAR) - lstrlenW(name);
357 module = (const WCHAR *)((BYTE *)data.lpSectionBase + wndclass->module_offset);
358 if (!(hmod = GetModuleHandleW( module )))
359 hmod = LoadLibraryW( module );
361 /* Combined name is used to register versioned class name. Base name part will match exactly
362 original class name and won't be reused from context data. */
363 ret = (const WCHAR *)((BYTE *)wndclass + wndclass->name_offset);
364 if (combined)
366 memcpy(combined, ret, *basename_offset * sizeof(WCHAR));
367 lstrcpyW(&combined[*basename_offset], name);
368 ret = combined;
371 if (register_class && hmod)
373 BOOL found = FALSE;
374 struct list *ptr;
376 USER_Lock();
378 LIST_FOR_EACH( ptr, &class_list )
380 CLASS *class = LIST_ENTRY( ptr, CLASS, entry );
381 if (wcsicmp( class->name, ret )) continue;
382 if (!class->local || class->hInstance == hmod)
384 found = TRUE;
385 break;
389 USER_Unlock();
391 if (!found)
393 BOOL (WINAPI *pRegisterClassNameW)(const WCHAR *class);
395 pRegisterClassNameW = (void *)GetProcAddress(hmod, "RegisterClassNameW");
396 if (pRegisterClassNameW)
397 pRegisterClassNameW(name);
401 return ret;
404 /***********************************************************************
405 * CLASS_FindClass
407 * Return a pointer to the class.
409 static CLASS *CLASS_FindClass( LPCWSTR name, HINSTANCE hinstance )
411 struct list *ptr;
412 ATOM atom = get_int_atom_value( name );
414 GetDesktopWindow(); /* create the desktop window to trigger builtin class registration */
416 if (!name) return NULL;
418 name = CLASS_GetVersionedName( name, NULL, NULL, TRUE );
420 for (;;)
422 USER_Lock();
424 LIST_FOR_EACH( ptr, &class_list )
426 CLASS *class = LIST_ENTRY( ptr, CLASS, entry );
427 if (atom)
429 if (class->atomName != atom) continue;
431 else
433 if (wcsicmp( class->name, name )) continue;
435 if (!class->local || class->hInstance == hinstance)
437 TRACE("%s %p -> %p\n", debugstr_w(name), hinstance, class);
438 return class;
441 USER_Unlock();
443 if (atom) break;
444 if (!is_comctl32_class( name )) break;
445 if (GetModuleHandleW( L"comctl32.dll" )) break;
446 if (!LoadLibraryW( L"comctl32.dll" )) break;
447 TRACE( "%s retrying after loading comctl32\n", debugstr_w(name) );
450 TRACE("%s %p -> not found\n", debugstr_w(name), hinstance);
451 return NULL;
454 /***********************************************************************
455 * CLASS_RegisterClass
457 * The real RegisterClass() functionality.
459 static CLASS *CLASS_RegisterClass( LPCWSTR name, UINT basename_offset, HINSTANCE hInstance, BOOL local,
460 DWORD style, INT classExtra, INT winExtra )
462 CLASS *classPtr;
463 BOOL ret;
465 TRACE("name=%s hinst=%p style=0x%x clExtr=0x%x winExtr=0x%x\n",
466 debugstr_w(name), hInstance, style, classExtra, winExtra );
468 /* Fix the extra bytes value */
470 if (classExtra > 40) /* Extra bytes are limited to 40 in Win32 */
471 WARN("Class extra bytes %d is > 40\n", classExtra);
472 if (winExtra > 40) /* Extra bytes are limited to 40 in Win32 */
473 WARN("Win extra bytes %d is > 40\n", winExtra );
475 classPtr = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(CLASS) + classExtra );
476 if (!classPtr) return NULL;
478 classPtr->atomName = get_int_atom_value( name );
479 classPtr->basename = classPtr->name;
480 if (!classPtr->atomName && name)
482 lstrcpyW( classPtr->name, name );
483 classPtr->basename += basename_offset;
485 else GlobalGetAtomNameW( classPtr->atomName, classPtr->name, ARRAY_SIZE( classPtr->name ));
487 SERVER_START_REQ( create_class )
489 req->local = local;
490 req->style = style;
491 req->instance = wine_server_client_ptr( hInstance );
492 req->extra = classExtra;
493 req->win_extra = winExtra;
494 req->client_ptr = wine_server_client_ptr( classPtr );
495 req->atom = classPtr->atomName;
496 req->name_offset = basename_offset;
497 if (!req->atom && name) wine_server_add_data( req, name, lstrlenW(name) * sizeof(WCHAR) );
498 ret = !wine_server_call_err( req );
499 classPtr->atomName = reply->atom;
501 SERVER_END_REQ;
502 if (!ret)
504 HeapFree( GetProcessHeap(), 0, classPtr );
505 return NULL;
508 classPtr->style = style;
509 classPtr->local = local;
510 classPtr->cbWndExtra = winExtra;
511 classPtr->cbClsExtra = classExtra;
512 classPtr->hInstance = hInstance;
514 /* Other non-null values must be set by caller */
516 USER_Lock();
517 if (local) list_add_head( &class_list, &classPtr->entry );
518 else list_add_tail( &class_list, &classPtr->entry );
519 return classPtr;
523 /***********************************************************************
524 * register_builtin
526 * Register a builtin control class.
527 * This allows having both ANSI and Unicode winprocs for the same class.
529 static void register_builtin( const struct builtin_class_descr *descr )
531 CLASS *classPtr;
532 HCURSOR cursor = 0;
534 if (descr->cursor) cursor = LoadCursorA( 0, (LPSTR)descr->cursor );
536 if (!(classPtr = CLASS_RegisterClass( descr->name, 0, user32_module, FALSE,
537 descr->style, 0, descr->extra )))
539 if (cursor) DestroyCursor( cursor );
540 return;
543 classPtr->hCursor = cursor;
544 classPtr->hbrBackground = descr->brush;
545 classPtr->winproc = BUILTIN_WINPROC( descr->proc );
546 release_class_ptr( classPtr );
549 static void load_uxtheme(void)
551 BOOL (WINAPI * pIsThemeActive)(void);
552 HMODULE uxtheme;
554 uxtheme = LoadLibraryA("uxtheme.dll");
555 if (uxtheme)
557 pIsThemeActive = (void *)GetProcAddress(uxtheme, "IsThemeActive");
558 if (!pIsThemeActive || !pIsThemeActive())
559 FreeLibrary(uxtheme);
563 /***********************************************************************
564 * register_builtins
566 static BOOL WINAPI register_builtins( INIT_ONCE *once, void *param, void **context )
568 register_builtin( &BUTTON_builtin_class );
569 register_builtin( &COMBO_builtin_class );
570 register_builtin( &COMBOLBOX_builtin_class );
571 register_builtin( &DIALOG_builtin_class );
572 register_builtin( &EDIT_builtin_class );
573 register_builtin( &ICONTITLE_builtin_class );
574 register_builtin( &LISTBOX_builtin_class );
575 register_builtin( &MDICLIENT_builtin_class );
576 register_builtin( &MENU_builtin_class );
577 register_builtin( &SCROLL_builtin_class );
578 register_builtin( &STATIC_builtin_class );
579 register_builtin( &IME_builtin_class );
581 /* Load uxtheme.dll so that standard scrollbars and dialogs are hooked for theming support */
582 load_uxtheme();
583 return TRUE;
587 /***********************************************************************
588 * register_builtin_classes
590 void register_builtin_classes(void)
592 InitOnceExecuteOnce( &init_once, register_builtins, NULL, NULL );
596 /***********************************************************************
597 * register_desktop_class
599 void register_desktop_class(void)
601 register_builtin( &DESKTOP_builtin_class );
602 register_builtin( &MESSAGE_builtin_class );
606 /***********************************************************************
607 * get_class_winproc
609 WNDPROC get_class_winproc( CLASS *class )
611 return class->winproc;
615 /***********************************************************************
616 * get_class_dce
618 struct dce *get_class_dce( CLASS *class )
620 return class->dce;
624 /***********************************************************************
625 * set_class_dce
627 struct dce *set_class_dce( CLASS *class, struct dce *dce )
629 if (class->dce) return class->dce; /* already set, don't change it */
630 class->dce = dce;
631 return dce;
635 /***********************************************************************
636 * RegisterClassA (USER32.@)
638 * Register a window class.
640 * RETURNS
641 * >0: Unique identifier
642 * 0: Failure
644 ATOM WINAPI RegisterClassA( const WNDCLASSA* wc ) /* [in] Address of structure with class data */
646 WNDCLASSEXA wcex;
648 wcex.cbSize = sizeof(wcex);
649 wcex.style = wc->style;
650 wcex.lpfnWndProc = wc->lpfnWndProc;
651 wcex.cbClsExtra = wc->cbClsExtra;
652 wcex.cbWndExtra = wc->cbWndExtra;
653 wcex.hInstance = wc->hInstance;
654 wcex.hIcon = wc->hIcon;
655 wcex.hCursor = wc->hCursor;
656 wcex.hbrBackground = wc->hbrBackground;
657 wcex.lpszMenuName = wc->lpszMenuName;
658 wcex.lpszClassName = wc->lpszClassName;
659 wcex.hIconSm = 0;
660 return RegisterClassExA( &wcex );
664 /***********************************************************************
665 * RegisterClassW (USER32.@)
667 * See RegisterClassA.
669 ATOM WINAPI RegisterClassW( const WNDCLASSW* wc )
671 WNDCLASSEXW wcex;
673 wcex.cbSize = sizeof(wcex);
674 wcex.style = wc->style;
675 wcex.lpfnWndProc = wc->lpfnWndProc;
676 wcex.cbClsExtra = wc->cbClsExtra;
677 wcex.cbWndExtra = wc->cbWndExtra;
678 wcex.hInstance = wc->hInstance;
679 wcex.hIcon = wc->hIcon;
680 wcex.hCursor = wc->hCursor;
681 wcex.hbrBackground = wc->hbrBackground;
682 wcex.lpszMenuName = wc->lpszMenuName;
683 wcex.lpszClassName = wc->lpszClassName;
684 wcex.hIconSm = 0;
685 return RegisterClassExW( &wcex );
689 /***********************************************************************
690 * RegisterClassExA (USER32.@)
692 ATOM WINAPI RegisterClassExA( const WNDCLASSEXA* wc )
694 WCHAR name[MAX_ATOM_LEN + 1], combined[MAX_ATOM_LEN + 1];
695 const WCHAR *classname = NULL;
696 ATOM atom;
697 CLASS *classPtr;
698 HINSTANCE instance;
700 GetDesktopWindow(); /* create the desktop window to trigger builtin class registration */
702 if (wc->cbSize != sizeof(*wc) || wc->cbClsExtra < 0 || wc->cbWndExtra < 0 ||
703 wc->hInstance == user32_module) /* we can't register a class for user32 */
705 SetLastError( ERROR_INVALID_PARAMETER );
706 return 0;
708 if (!(instance = wc->hInstance)) instance = GetModuleHandleW( NULL );
710 if (!IS_INTRESOURCE(wc->lpszClassName))
712 UINT basename_offset;
713 if (!MultiByteToWideChar( CP_ACP, 0, wc->lpszClassName, -1, name, MAX_ATOM_LEN + 1 )) return 0;
714 classname = CLASS_GetVersionedName( name, &basename_offset, combined, FALSE );
715 classPtr = CLASS_RegisterClass( classname, basename_offset, instance, !(wc->style & CS_GLOBALCLASS),
716 wc->style, wc->cbClsExtra, wc->cbWndExtra );
718 else
720 classPtr = CLASS_RegisterClass( (LPCWSTR)wc->lpszClassName, 0, instance,
721 !(wc->style & CS_GLOBALCLASS), wc->style,
722 wc->cbClsExtra, wc->cbWndExtra );
724 if (!classPtr) return 0;
725 atom = classPtr->atomName;
727 TRACE("name=%s%s%s atom=%04x wndproc=%p hinst=%p bg=%p style=%08x clsExt=%d winExt=%d class=%p\n",
728 debugstr_a(wc->lpszClassName), classname != name ? "->" : "", classname != name ? debugstr_w(classname) : "",
729 atom, wc->lpfnWndProc, instance, wc->hbrBackground, wc->style, wc->cbClsExtra, wc->cbWndExtra, classPtr );
731 classPtr->hIcon = wc->hIcon;
732 classPtr->hIconSm = wc->hIconSm;
733 classPtr->hIconSmIntern = wc->hIcon && !wc->hIconSm ?
734 CopyImage( wc->hIcon, IMAGE_ICON,
735 GetSystemMetrics( SM_CXSMICON ),
736 GetSystemMetrics( SM_CYSMICON ),
737 LR_COPYFROMRESOURCE ) : NULL;
738 classPtr->hCursor = wc->hCursor;
739 classPtr->hbrBackground = wc->hbrBackground;
740 classPtr->winproc = WINPROC_AllocProc( wc->lpfnWndProc, FALSE );
741 CLASS_SetMenuNameA( classPtr, wc->lpszMenuName );
742 release_class_ptr( classPtr );
743 return atom;
747 /***********************************************************************
748 * RegisterClassExW (USER32.@)
750 ATOM WINAPI RegisterClassExW( const WNDCLASSEXW* wc )
752 WCHAR name[MAX_ATOM_LEN + 1];
753 const WCHAR *classname;
754 UINT basename_offset;
755 ATOM atom;
756 CLASS *classPtr;
757 HINSTANCE instance;
759 GetDesktopWindow(); /* create the desktop window to trigger builtin class registration */
761 if (wc->cbSize != sizeof(*wc) || wc->cbClsExtra < 0 || wc->cbWndExtra < 0 ||
762 wc->hInstance == user32_module) /* we can't register a class for user32 */
764 SetLastError( ERROR_INVALID_PARAMETER );
765 return 0;
767 if (!(instance = wc->hInstance)) instance = GetModuleHandleW( NULL );
769 classname = CLASS_GetVersionedName( wc->lpszClassName, &basename_offset, name, FALSE );
770 if (!(classPtr = CLASS_RegisterClass( classname, basename_offset, instance, !(wc->style & CS_GLOBALCLASS),
771 wc->style, wc->cbClsExtra, wc->cbWndExtra )))
772 return 0;
774 atom = classPtr->atomName;
776 TRACE("name=%s%s%s atom=%04x wndproc=%p hinst=%p bg=%p style=%08x clsExt=%d winExt=%d class=%p\n",
777 debugstr_w(wc->lpszClassName), classname != wc->lpszClassName ? "->" : "",
778 classname != wc->lpszClassName ? debugstr_w(classname) : "", atom, wc->lpfnWndProc, instance,
779 wc->hbrBackground, wc->style, wc->cbClsExtra, wc->cbWndExtra, classPtr );
781 classPtr->hIcon = wc->hIcon;
782 classPtr->hIconSm = wc->hIconSm;
783 classPtr->hIconSmIntern = wc->hIcon && !wc->hIconSm ?
784 CopyImage( wc->hIcon, IMAGE_ICON,
785 GetSystemMetrics( SM_CXSMICON ),
786 GetSystemMetrics( SM_CYSMICON ),
787 LR_COPYFROMRESOURCE ) : NULL;
788 classPtr->hCursor = wc->hCursor;
789 classPtr->hbrBackground = wc->hbrBackground;
790 classPtr->winproc = WINPROC_AllocProc( wc->lpfnWndProc, TRUE );
791 CLASS_SetMenuNameW( classPtr, wc->lpszMenuName );
792 release_class_ptr( classPtr );
793 return atom;
797 /***********************************************************************
798 * UnregisterClassA (USER32.@)
800 BOOL WINAPI UnregisterClassA( LPCSTR className, HINSTANCE hInstance )
802 if (!IS_INTRESOURCE(className))
804 WCHAR name[MAX_ATOM_LEN + 1];
806 if (!MultiByteToWideChar( CP_ACP, 0, className, -1, name, MAX_ATOM_LEN + 1 ))
807 return FALSE;
808 return UnregisterClassW( name, hInstance );
810 return UnregisterClassW( (LPCWSTR)className, hInstance );
813 /***********************************************************************
814 * UnregisterClassW (USER32.@)
816 BOOL WINAPI UnregisterClassW( LPCWSTR className, HINSTANCE hInstance )
818 CLASS *classPtr = NULL;
820 GetDesktopWindow(); /* create the desktop window to trigger builtin class registration */
822 className = CLASS_GetVersionedName( className, NULL, NULL, FALSE );
823 SERVER_START_REQ( destroy_class )
825 req->instance = wine_server_client_ptr( hInstance );
826 if (!(req->atom = get_int_atom_value(className)) && className)
827 wine_server_add_data( req, className, lstrlenW(className) * sizeof(WCHAR) );
828 if (!wine_server_call_err( req )) classPtr = wine_server_get_ptr( reply->client_ptr );
830 SERVER_END_REQ;
832 if (classPtr) CLASS_FreeClass( classPtr );
833 return (classPtr != NULL);
837 /***********************************************************************
838 * GetClassWord (USER32.@)
840 WORD WINAPI GetClassWord( HWND hwnd, INT offset )
842 CLASS *class;
843 WORD retvalue = 0;
845 if (offset < 0) return GetClassLongA( hwnd, offset );
847 if (!(class = get_class_ptr( hwnd, FALSE ))) return 0;
849 if (class == CLASS_OTHER_PROCESS)
851 SERVER_START_REQ( set_class_info )
853 req->window = wine_server_user_handle( hwnd );
854 req->flags = 0;
855 req->extra_offset = offset;
856 req->extra_size = sizeof(retvalue);
857 if (!wine_server_call_err( req ))
858 memcpy( &retvalue, &reply->old_extra_value, sizeof(retvalue) );
860 SERVER_END_REQ;
861 return retvalue;
864 if (offset <= class->cbClsExtra - sizeof(WORD))
865 memcpy( &retvalue, (char *)(class + 1) + offset, sizeof(retvalue) );
866 else
867 SetLastError( ERROR_INVALID_INDEX );
868 release_class_ptr( class );
869 return retvalue;
873 /***********************************************************************
874 * CLASS_GetClassLong
876 * Implementation of GetClassLong(Ptr)A/W
878 static ULONG_PTR CLASS_GetClassLong( HWND hwnd, INT offset, UINT size,
879 BOOL unicode )
881 CLASS *class;
882 ULONG_PTR retvalue = 0;
884 if (!(class = get_class_ptr( hwnd, FALSE ))) return 0;
886 if (class == CLASS_OTHER_PROCESS)
888 SERVER_START_REQ( set_class_info )
890 req->window = wine_server_user_handle( hwnd );
891 req->flags = 0;
892 req->extra_offset = (offset >= 0) ? offset : -1;
893 req->extra_size = (offset >= 0) ? size : 0;
894 if (!wine_server_call_err( req ))
896 switch(offset)
898 case GCLP_HBRBACKGROUND:
899 case GCLP_HCURSOR:
900 case GCLP_HICON:
901 case GCLP_HICONSM:
902 case GCLP_WNDPROC:
903 case GCLP_MENUNAME:
904 FIXME( "offset %d (%s) not supported on other process window %p\n",
905 offset, SPY_GetClassLongOffsetName(offset), hwnd );
906 SetLastError( ERROR_INVALID_HANDLE );
907 break;
908 case GCL_STYLE:
909 retvalue = reply->old_style;
910 break;
911 case GCL_CBWNDEXTRA:
912 retvalue = reply->old_win_extra;
913 break;
914 case GCL_CBCLSEXTRA:
915 retvalue = reply->old_extra;
916 break;
917 case GCLP_HMODULE:
918 retvalue = (ULONG_PTR)wine_server_get_ptr( reply->old_instance );
919 break;
920 case GCW_ATOM:
921 retvalue = reply->old_atom;
922 break;
923 default:
924 if (offset >= 0)
926 if (size == sizeof(DWORD))
928 DWORD retdword;
929 memcpy( &retdword, &reply->old_extra_value, sizeof(DWORD) );
930 retvalue = retdword;
932 else
933 memcpy( &retvalue, &reply->old_extra_value,
934 sizeof(ULONG_PTR) );
936 else SetLastError( ERROR_INVALID_INDEX );
937 break;
941 SERVER_END_REQ;
942 return retvalue;
945 if (offset >= 0)
947 if (offset <= class->cbClsExtra - size)
949 if (size == sizeof(DWORD))
951 DWORD retdword;
952 memcpy( &retdword, (char *)(class + 1) + offset, sizeof(DWORD) );
953 retvalue = retdword;
955 else
956 memcpy( &retvalue, (char *)(class + 1) + offset, sizeof(ULONG_PTR) );
958 else
959 SetLastError( ERROR_INVALID_INDEX );
960 release_class_ptr( class );
961 return retvalue;
964 switch(offset)
966 case GCLP_HBRBACKGROUND:
967 retvalue = (ULONG_PTR)class->hbrBackground;
968 break;
969 case GCLP_HCURSOR:
970 retvalue = (ULONG_PTR)class->hCursor;
971 break;
972 case GCLP_HICON:
973 retvalue = (ULONG_PTR)class->hIcon;
974 break;
975 case GCLP_HICONSM:
976 retvalue = (ULONG_PTR)(class->hIconSm ? class->hIconSm : class->hIconSmIntern);
977 break;
978 case GCL_STYLE:
979 retvalue = class->style;
980 break;
981 case GCL_CBWNDEXTRA:
982 retvalue = class->cbWndExtra;
983 break;
984 case GCL_CBCLSEXTRA:
985 retvalue = class->cbClsExtra;
986 break;
987 case GCLP_HMODULE:
988 retvalue = (ULONG_PTR)class->hInstance;
989 break;
990 case GCLP_WNDPROC:
991 retvalue = (ULONG_PTR)WINPROC_GetProc( class->winproc, unicode );
992 break;
993 case GCLP_MENUNAME:
994 retvalue = (ULONG_PTR)CLASS_GetMenuNameW( class );
995 if (unicode)
996 retvalue = (ULONG_PTR)CLASS_GetMenuNameW( class );
997 else
998 retvalue = (ULONG_PTR)CLASS_GetMenuNameA( class );
999 break;
1000 case GCW_ATOM:
1001 retvalue = class->atomName;
1002 break;
1003 default:
1004 SetLastError( ERROR_INVALID_INDEX );
1005 break;
1007 release_class_ptr( class );
1008 return retvalue;
1012 /***********************************************************************
1013 * GetClassLongW (USER32.@)
1015 DWORD WINAPI GetClassLongW( HWND hwnd, INT offset )
1017 return CLASS_GetClassLong( hwnd, offset, sizeof(DWORD), TRUE );
1022 /***********************************************************************
1023 * GetClassLongA (USER32.@)
1025 DWORD WINAPI GetClassLongA( HWND hwnd, INT offset )
1027 return CLASS_GetClassLong( hwnd, offset, sizeof(DWORD), FALSE );
1031 /***********************************************************************
1032 * SetClassWord (USER32.@)
1034 WORD WINAPI SetClassWord( HWND hwnd, INT offset, WORD newval )
1036 CLASS *class;
1037 WORD retval = 0;
1039 if (offset < 0) return SetClassLongA( hwnd, offset, (DWORD)newval );
1041 if (!(class = get_class_ptr( hwnd, TRUE ))) return 0;
1043 SERVER_START_REQ( set_class_info )
1045 req->window = wine_server_user_handle( hwnd );
1046 req->flags = SET_CLASS_EXTRA;
1047 req->extra_offset = offset;
1048 req->extra_size = sizeof(newval);
1049 memcpy( &req->extra_value, &newval, sizeof(newval) );
1050 if (!wine_server_call_err( req ))
1052 void *ptr = (char *)(class + 1) + offset;
1053 memcpy( &retval, ptr, sizeof(retval) );
1054 memcpy( ptr, &newval, sizeof(newval) );
1057 SERVER_END_REQ;
1058 release_class_ptr( class );
1059 return retval;
1063 /***********************************************************************
1064 * CLASS_SetClassLong
1066 * Implementation of SetClassLong(Ptr)A/W
1068 static ULONG_PTR CLASS_SetClassLong( HWND hwnd, INT offset, LONG_PTR newval,
1069 UINT size, BOOL unicode )
1071 CLASS *class;
1072 ULONG_PTR retval = 0;
1074 if (!(class = get_class_ptr( hwnd, TRUE ))) return 0;
1076 if (offset >= 0)
1078 if (set_server_info( hwnd, offset, newval, size ))
1080 void *ptr = (char *)(class + 1) + offset;
1081 if ( size == sizeof(LONG) )
1083 DWORD retdword;
1084 LONG newlong = newval;
1085 memcpy( &retdword, ptr, sizeof(DWORD) );
1086 memcpy( ptr, &newlong, sizeof(LONG) );
1087 retval = retdword;
1089 else
1091 memcpy( &retval, ptr, sizeof(ULONG_PTR) );
1092 memcpy( ptr, &newval, sizeof(LONG_PTR) );
1096 else switch(offset)
1098 case GCLP_MENUNAME:
1099 if ( unicode )
1100 CLASS_SetMenuNameW( class, (LPCWSTR)newval );
1101 else
1102 CLASS_SetMenuNameA( class, (LPCSTR)newval );
1103 retval = 0; /* Old value is now meaningless anyway */
1104 break;
1105 case GCLP_WNDPROC:
1106 retval = (ULONG_PTR)WINPROC_GetProc( class->winproc, unicode );
1107 class->winproc = WINPROC_AllocProc( (WNDPROC)newval, unicode );
1108 break;
1109 case GCLP_HBRBACKGROUND:
1110 retval = (ULONG_PTR)class->hbrBackground;
1111 class->hbrBackground = (HBRUSH)newval;
1112 break;
1113 case GCLP_HCURSOR:
1114 retval = (ULONG_PTR)class->hCursor;
1115 class->hCursor = (HCURSOR)newval;
1116 break;
1117 case GCLP_HICON:
1118 retval = (ULONG_PTR)class->hIcon;
1119 if (class->hIconSmIntern)
1121 DestroyIcon(class->hIconSmIntern);
1122 class->hIconSmIntern = NULL;
1124 if (newval && !class->hIconSm)
1125 class->hIconSmIntern = CopyImage( (HICON)newval, IMAGE_ICON,
1126 GetSystemMetrics( SM_CXSMICON ), GetSystemMetrics( SM_CYSMICON ),
1127 LR_COPYFROMRESOURCE );
1128 class->hIcon = (HICON)newval;
1129 break;
1130 case GCLP_HICONSM:
1131 retval = (ULONG_PTR)class->hIconSm;
1132 if (retval && !newval && class->hIcon)
1133 class->hIconSmIntern = CopyImage( class->hIcon, IMAGE_ICON,
1134 GetSystemMetrics( SM_CXSMICON ), GetSystemMetrics( SM_CYSMICON ),
1135 LR_COPYFROMRESOURCE );
1136 else if (newval && class->hIconSmIntern)
1138 DestroyIcon(class->hIconSmIntern);
1139 class->hIconSmIntern = NULL;
1141 class->hIconSm = (HICON)newval;
1142 break;
1143 case GCL_STYLE:
1144 if (!set_server_info( hwnd, offset, newval, size )) break;
1145 retval = class->style;
1146 class->style = newval;
1147 break;
1148 case GCL_CBWNDEXTRA:
1149 if (!set_server_info( hwnd, offset, newval, size )) break;
1150 retval = class->cbWndExtra;
1151 class->cbWndExtra = newval;
1152 break;
1153 case GCLP_HMODULE:
1154 if (!set_server_info( hwnd, offset, newval, size )) break;
1155 retval = (ULONG_PTR)class->hInstance;
1156 class->hInstance = (HINSTANCE)newval;
1157 break;
1158 case GCW_ATOM:
1159 if (!set_server_info( hwnd, offset, newval, size )) break;
1160 retval = class->atomName;
1161 class->atomName = newval;
1162 GlobalGetAtomNameW( newval, class->name, ARRAY_SIZE( class->name ));
1163 break;
1164 case GCL_CBCLSEXTRA: /* cannot change this one */
1165 SetLastError( ERROR_INVALID_PARAMETER );
1166 break;
1167 default:
1168 SetLastError( ERROR_INVALID_INDEX );
1169 break;
1171 release_class_ptr( class );
1172 return retval;
1176 /***********************************************************************
1177 * SetClassLongW (USER32.@)
1179 DWORD WINAPI SetClassLongW( HWND hwnd, INT offset, LONG newval )
1181 return CLASS_SetClassLong( hwnd, offset, newval, sizeof(LONG), TRUE );
1185 /***********************************************************************
1186 * SetClassLongA (USER32.@)
1188 DWORD WINAPI SetClassLongA( HWND hwnd, INT offset, LONG newval )
1190 return CLASS_SetClassLong( hwnd, offset, newval, sizeof(LONG), FALSE );
1194 /***********************************************************************
1195 * GetClassNameA (USER32.@)
1197 INT WINAPI GetClassNameA( HWND hwnd, LPSTR buffer, INT count )
1199 WCHAR tmpbuf[MAX_ATOM_LEN + 1];
1200 DWORD len;
1202 if (count <= 0) return 0;
1203 if (!GetClassNameW( hwnd, tmpbuf, ARRAY_SIZE( tmpbuf ))) return 0;
1204 RtlUnicodeToMultiByteN( buffer, count - 1, &len, tmpbuf, lstrlenW(tmpbuf) * sizeof(WCHAR) );
1205 buffer[len] = 0;
1206 return len;
1210 /***********************************************************************
1211 * GetClassNameW (USER32.@)
1213 INT WINAPI GetClassNameW( HWND hwnd, LPWSTR buffer, INT count )
1215 CLASS *class;
1216 INT ret;
1218 TRACE("%p %p %d\n", hwnd, buffer, count);
1220 if (count <= 0) return 0;
1222 if (!(class = get_class_ptr( hwnd, FALSE ))) return 0;
1224 if (class == CLASS_OTHER_PROCESS)
1226 WCHAR tmpbuf[MAX_ATOM_LEN + 1];
1227 ATOM atom = 0;
1229 SERVER_START_REQ( set_class_info )
1231 req->window = wine_server_user_handle( hwnd );
1232 req->flags = 0;
1233 req->extra_offset = -1;
1234 req->extra_size = 0;
1235 if (!wine_server_call_err( req ))
1236 atom = reply->base_atom;
1238 SERVER_END_REQ;
1240 ret = GlobalGetAtomNameW( atom, tmpbuf, MAX_ATOM_LEN + 1 );
1241 if (ret)
1243 ret = min(count - 1, ret);
1244 memcpy(buffer, tmpbuf, ret * sizeof(WCHAR));
1245 buffer[ret] = 0;
1248 else
1250 /* Return original name class was registered with. */
1251 lstrcpynW( buffer, class->basename, count );
1252 release_class_ptr( class );
1253 ret = lstrlenW( buffer );
1255 return ret;
1259 /***********************************************************************
1260 * RealGetWindowClassA (USER32.@)
1262 UINT WINAPI RealGetWindowClassA( HWND hwnd, LPSTR buffer, UINT count )
1264 return GetClassNameA( hwnd, buffer, count );
1268 /***********************************************************************
1269 * RealGetWindowClassW (USER32.@)
1271 UINT WINAPI RealGetWindowClassW( HWND hwnd, LPWSTR buffer, UINT count )
1273 return GetClassNameW( hwnd, buffer, count );
1277 /***********************************************************************
1278 * GetClassInfoA (USER32.@)
1280 BOOL WINAPI GetClassInfoA( HINSTANCE hInstance, LPCSTR name, WNDCLASSA *wc )
1282 WNDCLASSEXA wcex;
1283 UINT ret = GetClassInfoExA( hInstance, name, &wcex );
1285 if (ret)
1287 wc->style = wcex.style;
1288 wc->lpfnWndProc = wcex.lpfnWndProc;
1289 wc->cbClsExtra = wcex.cbClsExtra;
1290 wc->cbWndExtra = wcex.cbWndExtra;
1291 wc->hInstance = wcex.hInstance;
1292 wc->hIcon = wcex.hIcon;
1293 wc->hCursor = wcex.hCursor;
1294 wc->hbrBackground = wcex.hbrBackground;
1295 wc->lpszMenuName = wcex.lpszMenuName;
1296 wc->lpszClassName = wcex.lpszClassName;
1298 return ret;
1302 /***********************************************************************
1303 * GetClassInfoW (USER32.@)
1305 BOOL WINAPI GetClassInfoW( HINSTANCE hInstance, LPCWSTR name, WNDCLASSW *wc )
1307 WNDCLASSEXW wcex;
1308 UINT ret = GetClassInfoExW( hInstance, name, &wcex );
1310 if (ret)
1312 wc->style = wcex.style;
1313 wc->lpfnWndProc = wcex.lpfnWndProc;
1314 wc->cbClsExtra = wcex.cbClsExtra;
1315 wc->cbWndExtra = wcex.cbWndExtra;
1316 wc->hInstance = wcex.hInstance;
1317 wc->hIcon = wcex.hIcon;
1318 wc->hCursor = wcex.hCursor;
1319 wc->hbrBackground = wcex.hbrBackground;
1320 wc->lpszMenuName = wcex.lpszMenuName;
1321 wc->lpszClassName = wcex.lpszClassName;
1323 return ret;
1327 /***********************************************************************
1328 * GetClassInfoExA (USER32.@)
1330 BOOL WINAPI GetClassInfoExA( HINSTANCE hInstance, LPCSTR name, WNDCLASSEXA *wc )
1332 ATOM atom;
1333 CLASS *classPtr;
1335 TRACE("%p %s %p\n", hInstance, debugstr_a(name), wc);
1337 if (!wc)
1339 SetLastError( ERROR_NOACCESS );
1340 return FALSE;
1343 if (!hInstance) hInstance = user32_module;
1345 if (!IS_INTRESOURCE(name))
1347 WCHAR nameW[MAX_ATOM_LEN + 1];
1348 if (!MultiByteToWideChar( CP_ACP, 0, name, -1, nameW, ARRAY_SIZE( nameW )))
1349 return FALSE;
1350 classPtr = CLASS_FindClass( nameW, hInstance );
1352 else classPtr = CLASS_FindClass( (LPCWSTR)name, hInstance );
1354 if (!classPtr)
1356 SetLastError( ERROR_CLASS_DOES_NOT_EXIST );
1357 return FALSE;
1359 wc->style = classPtr->style;
1360 wc->lpfnWndProc = WINPROC_GetProc( classPtr->winproc, FALSE );
1361 wc->cbClsExtra = classPtr->cbClsExtra;
1362 wc->cbWndExtra = classPtr->cbWndExtra;
1363 wc->hInstance = (hInstance == user32_module) ? 0 : hInstance;
1364 wc->hIcon = classPtr->hIcon;
1365 wc->hIconSm = classPtr->hIconSm ? classPtr->hIconSm : classPtr->hIconSmIntern;
1366 wc->hCursor = classPtr->hCursor;
1367 wc->hbrBackground = classPtr->hbrBackground;
1368 wc->lpszMenuName = CLASS_GetMenuNameA( classPtr );
1369 wc->lpszClassName = name;
1370 atom = classPtr->atomName;
1371 release_class_ptr( classPtr );
1373 /* We must return the atom of the class here instead of just TRUE. */
1374 return atom;
1378 /***********************************************************************
1379 * GetClassInfoExW (USER32.@)
1381 BOOL WINAPI GetClassInfoExW( HINSTANCE hInstance, LPCWSTR name, WNDCLASSEXW *wc )
1383 ATOM atom;
1384 CLASS *classPtr;
1386 TRACE("%p %s %p\n", hInstance, debugstr_w(name), wc);
1388 if (!wc)
1390 SetLastError( ERROR_NOACCESS );
1391 return FALSE;
1394 if (!hInstance) hInstance = user32_module;
1396 if (!(classPtr = CLASS_FindClass( name, hInstance )))
1398 SetLastError( ERROR_CLASS_DOES_NOT_EXIST );
1399 return FALSE;
1401 wc->style = classPtr->style;
1402 wc->lpfnWndProc = WINPROC_GetProc( classPtr->winproc, TRUE );
1403 wc->cbClsExtra = classPtr->cbClsExtra;
1404 wc->cbWndExtra = classPtr->cbWndExtra;
1405 wc->hInstance = (hInstance == user32_module) ? 0 : hInstance;
1406 wc->hIcon = classPtr->hIcon;
1407 wc->hIconSm = classPtr->hIconSm ? classPtr->hIconSm : classPtr->hIconSmIntern;
1408 wc->hCursor = classPtr->hCursor;
1409 wc->hbrBackground = classPtr->hbrBackground;
1410 wc->lpszMenuName = CLASS_GetMenuNameW( classPtr );
1411 wc->lpszClassName = name;
1412 atom = classPtr->atomName;
1413 release_class_ptr( classPtr );
1415 /* We must return the atom of the class here instead of just TRUE. */
1416 return atom;
1420 #if 0 /* toolhelp is in kernel, so this cannot work */
1422 /***********************************************************************
1423 * ClassFirst (TOOLHELP.69)
1425 BOOL16 WINAPI ClassFirst16( CLASSENTRY *pClassEntry )
1427 TRACE("%p\n",pClassEntry);
1428 pClassEntry->wNext = 1;
1429 return ClassNext16( pClassEntry );
1433 /***********************************************************************
1434 * ClassNext (TOOLHELP.70)
1436 BOOL16 WINAPI ClassNext16( CLASSENTRY *pClassEntry )
1438 int i;
1439 CLASS *class = firstClass;
1441 TRACE("%p\n",pClassEntry);
1443 if (!pClassEntry->wNext) return FALSE;
1444 for (i = 1; (i < pClassEntry->wNext) && class; i++) class = class->next;
1445 if (!class)
1447 pClassEntry->wNext = 0;
1448 return FALSE;
1450 pClassEntry->hInst = class->hInstance;
1451 pClassEntry->wNext++;
1452 GlobalGetAtomNameA( class->atomName, pClassEntry->szClassName,
1453 sizeof(pClassEntry->szClassName) );
1454 return TRUE;
1456 #endif
1458 /* 64bit versions */
1460 #ifdef GetClassLongPtrA
1461 #undef GetClassLongPtrA
1462 #endif
1464 #ifdef GetClassLongPtrW
1465 #undef GetClassLongPtrW
1466 #endif
1468 #ifdef SetClassLongPtrA
1469 #undef SetClassLongPtrA
1470 #endif
1472 #ifdef SetClassLongPtrW
1473 #undef SetClassLongPtrW
1474 #endif
1476 /***********************************************************************
1477 * GetClassLongPtrA (USER32.@)
1479 ULONG_PTR WINAPI GetClassLongPtrA( HWND hwnd, INT offset )
1481 return CLASS_GetClassLong( hwnd, offset, sizeof(ULONG_PTR), FALSE );
1484 /***********************************************************************
1485 * GetClassLongPtrW (USER32.@)
1487 ULONG_PTR WINAPI GetClassLongPtrW( HWND hwnd, INT offset )
1489 return CLASS_GetClassLong( hwnd, offset, sizeof(ULONG_PTR), TRUE );
1492 /***********************************************************************
1493 * SetClassLongPtrW (USER32.@)
1495 ULONG_PTR WINAPI SetClassLongPtrW( HWND hwnd, INT offset, LONG_PTR newval )
1497 return CLASS_SetClassLong( hwnd, offset, newval, sizeof(LONG_PTR), TRUE );
1500 /***********************************************************************
1501 * SetClassLongPtrA (USER32.@)
1503 ULONG_PTR WINAPI SetClassLongPtrA( HWND hwnd, INT offset, LONG_PTR newval )
1505 return CLASS_SetClassLong( hwnd, offset, newval, sizeof(LONG_PTR), FALSE );