ntdll: Fix crash on nested thread exit.
[wine.git] / dlls / user32 / class.c
blob441d5cb132e72293cd97ed814eb5df612dee592b
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 = (sizeof(classesW) / sizeof(classesW[0])) - 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 {'C','o','m','b','o','B','o','x',0},
170 {'C','o','m','b','o','L','B','o','x',0},
171 {'I','M','E',0},
172 {'L','i','s','t','B','o','x',0},
173 {'M','D','I','C','l','i','e','n','t',0},
174 {'S','c','r','o','l','l','b','a','r',0},
175 {'S','t','a','t','i','c',0},
178 int min = 0, max = (sizeof(classesW) / sizeof(classesW[0])) - 1;
180 while (min <= max)
182 int res, pos = (min + max) / 2;
183 if (!(res = strcmpiW( name, classesW[pos] ))) return TRUE;
184 if (res < 0) max = pos - 1;
185 else min = pos + 1;
187 return FALSE;
190 /***********************************************************************
191 * set_server_info
193 * Set class info with the wine server.
195 static BOOL set_server_info( HWND hwnd, INT offset, LONG_PTR newval, UINT size )
197 BOOL ret;
199 SERVER_START_REQ( set_class_info )
201 req->window = wine_server_user_handle( hwnd );
202 req->extra_offset = -1;
203 switch(offset)
205 case GCW_ATOM:
206 req->flags = SET_CLASS_ATOM;
207 req->atom = LOWORD(newval);
208 break;
209 case GCL_STYLE:
210 req->flags = SET_CLASS_STYLE;
211 req->style = newval;
212 break;
213 case GCL_CBWNDEXTRA:
214 req->flags = SET_CLASS_WINEXTRA;
215 req->win_extra = newval;
216 break;
217 case GCLP_HMODULE:
218 req->flags = SET_CLASS_INSTANCE;
219 req->instance = wine_server_client_ptr( (void *)newval );
220 break;
221 default:
222 assert( offset >= 0 );
223 req->flags = SET_CLASS_EXTRA;
224 req->extra_offset = offset;
225 req->extra_size = size;
226 if ( size == sizeof(LONG) )
228 LONG newlong = newval;
229 memcpy( &req->extra_value, &newlong, sizeof(LONG) );
231 else
232 memcpy( &req->extra_value, &newval, sizeof(LONG_PTR) );
233 break;
235 ret = !wine_server_call_err( req );
237 SERVER_END_REQ;
238 return ret;
242 /***********************************************************************
243 * CLASS_GetMenuNameA
245 * Get the menu name as a ASCII string.
247 static inline LPSTR CLASS_GetMenuNameA( CLASS *classPtr )
249 if (IS_INTRESOURCE(classPtr->menuName)) return (LPSTR)classPtr->menuName;
250 return (LPSTR)(classPtr->menuName + strlenW(classPtr->menuName) + 1);
254 /***********************************************************************
255 * CLASS_GetMenuNameW
257 * Get the menu name as a Unicode string.
259 static inline LPWSTR CLASS_GetMenuNameW( CLASS *classPtr )
261 return classPtr->menuName;
265 /***********************************************************************
266 * CLASS_SetMenuNameA
268 * Set the menu name in a class structure by copying the string.
270 static void CLASS_SetMenuNameA( CLASS *classPtr, LPCSTR name )
272 if (!IS_INTRESOURCE(classPtr->menuName)) HeapFree( GetProcessHeap(), 0, classPtr->menuName );
273 if (!IS_INTRESOURCE(name))
275 DWORD lenA = strlen(name) + 1;
276 DWORD lenW = MultiByteToWideChar( CP_ACP, 0, name, lenA, NULL, 0 );
277 classPtr->menuName = HeapAlloc( GetProcessHeap(), 0, lenA + lenW*sizeof(WCHAR) );
278 MultiByteToWideChar( CP_ACP, 0, name, lenA, classPtr->menuName, lenW );
279 memcpy( classPtr->menuName + lenW, name, lenA );
281 else classPtr->menuName = (LPWSTR)name;
285 /***********************************************************************
286 * CLASS_SetMenuNameW
288 * Set the menu name in a class structure by copying the string.
290 static void CLASS_SetMenuNameW( CLASS *classPtr, LPCWSTR name )
292 if (!IS_INTRESOURCE(classPtr->menuName)) HeapFree( GetProcessHeap(), 0, classPtr->menuName );
293 if (!IS_INTRESOURCE(name))
295 DWORD lenW = strlenW(name) + 1;
296 DWORD lenA = WideCharToMultiByte( CP_ACP, 0, name, lenW, NULL, 0, NULL, NULL );
297 classPtr->menuName = HeapAlloc( GetProcessHeap(), 0, lenA + lenW*sizeof(WCHAR) );
298 memcpy( classPtr->menuName, name, lenW*sizeof(WCHAR) );
299 WideCharToMultiByte( CP_ACP, 0, name, lenW,
300 (char *)(classPtr->menuName + lenW), lenA, NULL, NULL );
302 else classPtr->menuName = (LPWSTR)name;
306 /***********************************************************************
307 * CLASS_FreeClass
309 * Free a class structure.
311 static void CLASS_FreeClass( CLASS *classPtr )
313 TRACE("%p\n", classPtr);
315 USER_Lock();
317 if (classPtr->dce) free_dce( classPtr->dce, 0 );
318 list_remove( &classPtr->entry );
319 if (classPtr->hbrBackground > (HBRUSH)(COLOR_GRADIENTINACTIVECAPTION + 1))
320 DeleteObject( classPtr->hbrBackground );
321 DestroyIcon( classPtr->hIconSmIntern );
322 HeapFree( GetProcessHeap(), 0, classPtr->menuName );
323 HeapFree( GetProcessHeap(), 0, classPtr );
324 USER_Unlock();
327 const WCHAR *CLASS_GetVersionedName( const WCHAR *name, UINT *basename_offset )
329 ACTCTX_SECTION_KEYED_DATA data;
330 struct wndclass_redirect_data
332 ULONG size;
333 DWORD res;
334 ULONG name_len;
335 ULONG name_offset;
336 ULONG module_len;
337 ULONG module_offset;
338 } *wndclass;
340 if (basename_offset)
341 *basename_offset = 0;
343 if (IS_INTRESOURCE( name ))
344 return name;
346 if (is_comctl32_class( name ) || is_builtin_class( name ))
347 return name;
349 data.cbSize = sizeof(data);
350 if (!FindActCtxSectionStringW(0, NULL, ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION, name, &data))
351 return name;
353 wndclass = (struct wndclass_redirect_data *)data.lpData;
354 if (basename_offset)
355 *basename_offset = wndclass->name_len / sizeof(WCHAR) - strlenW(name);
357 return (const WCHAR *)((BYTE *)wndclass + wndclass->name_offset);
360 /***********************************************************************
361 * CLASS_FindClass
363 * Return a pointer to the class.
365 static CLASS *CLASS_FindClass( LPCWSTR name, HINSTANCE hinstance )
367 static const WCHAR comctl32W[] = {'c','o','m','c','t','l','3','2','.','d','l','l',0};
368 struct list *ptr;
369 ATOM atom = get_int_atom_value( name );
371 GetDesktopWindow(); /* create the desktop window to trigger builtin class registration */
373 if (!name) return NULL;
375 name = CLASS_GetVersionedName( name, NULL );
377 for (;;)
379 USER_Lock();
381 LIST_FOR_EACH( ptr, &class_list )
383 CLASS *class = LIST_ENTRY( ptr, CLASS, entry );
384 if (atom)
386 if (class->atomName != atom) continue;
388 else
390 if (strcmpiW( class->name, name )) continue;
392 if (!class->local || class->hInstance == hinstance)
394 TRACE("%s %p -> %p\n", debugstr_w(name), hinstance, class);
395 return class;
398 USER_Unlock();
400 if (atom) break;
401 if (!is_comctl32_class( name )) break;
402 if (GetModuleHandleW( comctl32W )) break;
403 if (!LoadLibraryW( comctl32W )) break;
404 TRACE( "%s retrying after loading comctl32\n", debugstr_w(name) );
407 TRACE("%s %p -> not found\n", debugstr_w(name), hinstance);
408 return NULL;
412 /***********************************************************************
413 * CLASS_RegisterClass
415 * The real RegisterClass() functionality.
417 static CLASS *CLASS_RegisterClass( LPCWSTR name, UINT basename_offset, HINSTANCE hInstance, BOOL local,
418 DWORD style, INT classExtra, INT winExtra )
420 CLASS *classPtr;
421 BOOL ret;
423 TRACE("name=%s hinst=%p style=0x%x clExtr=0x%x winExtr=0x%x\n",
424 debugstr_w(name), hInstance, style, classExtra, winExtra );
426 /* Fix the extra bytes value */
428 if (classExtra > 40) /* Extra bytes are limited to 40 in Win32 */
429 WARN("Class extra bytes %d is > 40\n", classExtra);
430 if (winExtra > 40) /* Extra bytes are limited to 40 in Win32 */
431 WARN("Win extra bytes %d is > 40\n", winExtra );
433 classPtr = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(CLASS) + classExtra );
434 if (!classPtr) return NULL;
436 classPtr->atomName = get_int_atom_value( name );
437 classPtr->basename = classPtr->name;
438 if (!classPtr->atomName && name)
440 strcpyW( classPtr->name, name );
441 classPtr->basename += basename_offset;
443 else GlobalGetAtomNameW( classPtr->atomName, classPtr->name, sizeof(classPtr->name)/sizeof(WCHAR) );
445 SERVER_START_REQ( create_class )
447 req->local = local;
448 req->style = style;
449 req->instance = wine_server_client_ptr( hInstance );
450 req->extra = classExtra;
451 req->win_extra = winExtra;
452 req->client_ptr = wine_server_client_ptr( classPtr );
453 req->atom = classPtr->atomName;
454 if (!req->atom && name) wine_server_add_data( req, name, strlenW(name) * sizeof(WCHAR) );
455 ret = !wine_server_call_err( req );
456 classPtr->atomName = reply->atom;
458 SERVER_END_REQ;
459 if (!ret)
461 HeapFree( GetProcessHeap(), 0, classPtr );
462 return NULL;
465 classPtr->style = style;
466 classPtr->local = local;
467 classPtr->cbWndExtra = winExtra;
468 classPtr->cbClsExtra = classExtra;
469 classPtr->hInstance = hInstance;
471 /* Other non-null values must be set by caller */
473 USER_Lock();
474 if (local) list_add_head( &class_list, &classPtr->entry );
475 else list_add_tail( &class_list, &classPtr->entry );
476 return classPtr;
480 /***********************************************************************
481 * register_builtin
483 * Register a builtin control class.
484 * This allows having both ASCII and Unicode winprocs for the same class.
486 static void register_builtin( const struct builtin_class_descr *descr )
488 CLASS *classPtr;
490 if (!(classPtr = CLASS_RegisterClass( descr->name, 0, user32_module, FALSE,
491 descr->style, 0, descr->extra ))) return;
493 if (descr->cursor) classPtr->hCursor = LoadCursorA( 0, (LPSTR)descr->cursor );
494 classPtr->hbrBackground = descr->brush;
495 classPtr->winproc = BUILTIN_WINPROC( descr->proc );
496 release_class_ptr( classPtr );
500 /***********************************************************************
501 * register_builtins
503 static BOOL WINAPI register_builtins( INIT_ONCE *once, void *param, void **context )
505 register_builtin( &BUTTON_builtin_class );
506 register_builtin( &COMBO_builtin_class );
507 register_builtin( &COMBOLBOX_builtin_class );
508 register_builtin( &DIALOG_builtin_class );
509 register_builtin( &EDIT_builtin_class );
510 register_builtin( &ICONTITLE_builtin_class );
511 register_builtin( &LISTBOX_builtin_class );
512 register_builtin( &MDICLIENT_builtin_class );
513 register_builtin( &MENU_builtin_class );
514 register_builtin( &SCROLL_builtin_class );
515 register_builtin( &STATIC_builtin_class );
516 register_builtin( &IME_builtin_class );
517 return TRUE;
521 /***********************************************************************
522 * register_builtin_classes
524 void register_builtin_classes(void)
526 InitOnceExecuteOnce( &init_once, register_builtins, NULL, NULL );
530 /***********************************************************************
531 * register_desktop_class
533 void register_desktop_class(void)
535 register_builtin( &DESKTOP_builtin_class );
536 register_builtin( &MESSAGE_builtin_class );
540 /***********************************************************************
541 * get_class_winproc
543 WNDPROC get_class_winproc( CLASS *class )
545 return class->winproc;
549 /***********************************************************************
550 * get_class_dce
552 struct dce *get_class_dce( CLASS *class )
554 return class->dce;
558 /***********************************************************************
559 * set_class_dce
561 struct dce *set_class_dce( CLASS *class, struct dce *dce )
563 if (class->dce) return class->dce; /* already set, don't change it */
564 class->dce = dce;
565 return dce;
569 /***********************************************************************
570 * RegisterClassA (USER32.@)
572 * Register a window class.
574 * RETURNS
575 * >0: Unique identifier
576 * 0: Failure
578 ATOM WINAPI RegisterClassA( const WNDCLASSA* wc ) /* [in] Address of structure with class data */
580 WNDCLASSEXA wcex;
582 wcex.cbSize = sizeof(wcex);
583 wcex.style = wc->style;
584 wcex.lpfnWndProc = wc->lpfnWndProc;
585 wcex.cbClsExtra = wc->cbClsExtra;
586 wcex.cbWndExtra = wc->cbWndExtra;
587 wcex.hInstance = wc->hInstance;
588 wcex.hIcon = wc->hIcon;
589 wcex.hCursor = wc->hCursor;
590 wcex.hbrBackground = wc->hbrBackground;
591 wcex.lpszMenuName = wc->lpszMenuName;
592 wcex.lpszClassName = wc->lpszClassName;
593 wcex.hIconSm = 0;
594 return RegisterClassExA( &wcex );
598 /***********************************************************************
599 * RegisterClassW (USER32.@)
601 * See RegisterClassA.
603 ATOM WINAPI RegisterClassW( const WNDCLASSW* wc )
605 WNDCLASSEXW wcex;
607 wcex.cbSize = sizeof(wcex);
608 wcex.style = wc->style;
609 wcex.lpfnWndProc = wc->lpfnWndProc;
610 wcex.cbClsExtra = wc->cbClsExtra;
611 wcex.cbWndExtra = wc->cbWndExtra;
612 wcex.hInstance = wc->hInstance;
613 wcex.hIcon = wc->hIcon;
614 wcex.hCursor = wc->hCursor;
615 wcex.hbrBackground = wc->hbrBackground;
616 wcex.lpszMenuName = wc->lpszMenuName;
617 wcex.lpszClassName = wc->lpszClassName;
618 wcex.hIconSm = 0;
619 return RegisterClassExW( &wcex );
623 /***********************************************************************
624 * RegisterClassExA (USER32.@)
626 ATOM WINAPI RegisterClassExA( const WNDCLASSEXA* wc )
628 const WCHAR *classname = NULL;
629 WCHAR name[MAX_ATOM_LEN + 1];
630 ATOM atom;
631 CLASS *classPtr;
632 HINSTANCE instance;
634 GetDesktopWindow(); /* create the desktop window to trigger builtin class registration */
636 if (wc->cbSize != sizeof(*wc) || wc->cbClsExtra < 0 || wc->cbWndExtra < 0 ||
637 wc->hInstance == user32_module) /* we can't register a class for user32 */
639 SetLastError( ERROR_INVALID_PARAMETER );
640 return 0;
642 if (!(instance = wc->hInstance)) instance = GetModuleHandleW( NULL );
644 if (!IS_INTRESOURCE(wc->lpszClassName))
646 UINT basename_offset;
647 if (!MultiByteToWideChar( CP_ACP, 0, wc->lpszClassName, -1, name, MAX_ATOM_LEN + 1 )) return 0;
648 classname = CLASS_GetVersionedName( name, &basename_offset );
649 classPtr = CLASS_RegisterClass( classname, basename_offset, instance, !(wc->style & CS_GLOBALCLASS),
650 wc->style, wc->cbClsExtra, wc->cbWndExtra );
652 else
654 classPtr = CLASS_RegisterClass( (LPCWSTR)wc->lpszClassName, 0, instance,
655 !(wc->style & CS_GLOBALCLASS), wc->style,
656 wc->cbClsExtra, wc->cbWndExtra );
658 if (!classPtr) return 0;
659 atom = classPtr->atomName;
661 TRACE("name=%s%s%s atom=%04x wndproc=%p hinst=%p bg=%p style=%08x clsExt=%d winExt=%d class=%p\n",
662 debugstr_a(wc->lpszClassName), classname != name ? "->" : "", classname != name ? debugstr_w(classname) : "",
663 atom, wc->lpfnWndProc, instance, wc->hbrBackground, wc->style, wc->cbClsExtra, wc->cbWndExtra, classPtr );
665 classPtr->hIcon = wc->hIcon;
666 classPtr->hIconSm = wc->hIconSm;
667 classPtr->hIconSmIntern = wc->hIcon && !wc->hIconSm ?
668 CopyImage( wc->hIcon, IMAGE_ICON,
669 GetSystemMetrics( SM_CXSMICON ),
670 GetSystemMetrics( SM_CYSMICON ),
671 LR_COPYFROMRESOURCE ) : NULL;
672 classPtr->hCursor = wc->hCursor;
673 classPtr->hbrBackground = wc->hbrBackground;
674 classPtr->winproc = WINPROC_AllocProc( wc->lpfnWndProc, FALSE );
675 CLASS_SetMenuNameA( classPtr, wc->lpszMenuName );
676 release_class_ptr( classPtr );
677 return atom;
681 /***********************************************************************
682 * RegisterClassExW (USER32.@)
684 ATOM WINAPI RegisterClassExW( const WNDCLASSEXW* wc )
686 const WCHAR *classname;
687 UINT basename_offset;
688 ATOM atom;
689 CLASS *classPtr;
690 HINSTANCE instance;
692 GetDesktopWindow(); /* create the desktop window to trigger builtin class registration */
694 if (wc->cbSize != sizeof(*wc) || wc->cbClsExtra < 0 || wc->cbWndExtra < 0 ||
695 wc->hInstance == user32_module) /* we can't register a class for user32 */
697 SetLastError( ERROR_INVALID_PARAMETER );
698 return 0;
700 if (!(instance = wc->hInstance)) instance = GetModuleHandleW( NULL );
702 classname = CLASS_GetVersionedName( wc->lpszClassName, &basename_offset );
703 if (!(classPtr = CLASS_RegisterClass( classname, basename_offset, instance, !(wc->style & CS_GLOBALCLASS),
704 wc->style, wc->cbClsExtra, wc->cbWndExtra )))
705 return 0;
707 atom = classPtr->atomName;
709 TRACE("name=%s%s%s atom=%04x wndproc=%p hinst=%p bg=%p style=%08x clsExt=%d winExt=%d class=%p\n",
710 debugstr_w(wc->lpszClassName), classname != wc->lpszClassName ? "->" : "",
711 classname != wc->lpszClassName ? debugstr_w(classname) : "", atom, wc->lpfnWndProc, instance,
712 wc->hbrBackground, wc->style, wc->cbClsExtra, wc->cbWndExtra, classPtr );
714 classPtr->hIcon = wc->hIcon;
715 classPtr->hIconSm = wc->hIconSm;
716 classPtr->hIconSmIntern = wc->hIcon && !wc->hIconSm ?
717 CopyImage( wc->hIcon, IMAGE_ICON,
718 GetSystemMetrics( SM_CXSMICON ),
719 GetSystemMetrics( SM_CYSMICON ),
720 LR_COPYFROMRESOURCE ) : NULL;
721 classPtr->hCursor = wc->hCursor;
722 classPtr->hbrBackground = wc->hbrBackground;
723 classPtr->winproc = WINPROC_AllocProc( wc->lpfnWndProc, TRUE );
724 CLASS_SetMenuNameW( classPtr, wc->lpszMenuName );
725 release_class_ptr( classPtr );
726 return atom;
730 /***********************************************************************
731 * UnregisterClassA (USER32.@)
733 BOOL WINAPI UnregisterClassA( LPCSTR className, HINSTANCE hInstance )
735 if (!IS_INTRESOURCE(className))
737 WCHAR name[MAX_ATOM_LEN + 1];
739 if (!MultiByteToWideChar( CP_ACP, 0, className, -1, name, MAX_ATOM_LEN + 1 ))
740 return FALSE;
741 return UnregisterClassW( name, hInstance );
743 return UnregisterClassW( (LPCWSTR)className, hInstance );
746 /***********************************************************************
747 * UnregisterClassW (USER32.@)
749 BOOL WINAPI UnregisterClassW( LPCWSTR className, HINSTANCE hInstance )
751 CLASS *classPtr = NULL;
753 GetDesktopWindow(); /* create the desktop window to trigger builtin class registration */
755 className = CLASS_GetVersionedName( className, NULL );
756 SERVER_START_REQ( destroy_class )
758 req->instance = wine_server_client_ptr( hInstance );
759 if (!(req->atom = get_int_atom_value(className)) && className)
760 wine_server_add_data( req, className, strlenW(className) * sizeof(WCHAR) );
761 if (!wine_server_call_err( req )) classPtr = wine_server_get_ptr( reply->client_ptr );
763 SERVER_END_REQ;
765 if (classPtr) CLASS_FreeClass( classPtr );
766 return (classPtr != NULL);
770 /***********************************************************************
771 * GetClassWord (USER32.@)
773 WORD WINAPI GetClassWord( HWND hwnd, INT offset )
775 CLASS *class;
776 WORD retvalue = 0;
778 if (offset < 0) return GetClassLongA( hwnd, offset );
780 if (!(class = get_class_ptr( hwnd, FALSE ))) return 0;
782 if (class == CLASS_OTHER_PROCESS)
784 SERVER_START_REQ( set_class_info )
786 req->window = wine_server_user_handle( hwnd );
787 req->flags = 0;
788 req->extra_offset = offset;
789 req->extra_size = sizeof(retvalue);
790 if (!wine_server_call_err( req ))
791 memcpy( &retvalue, &reply->old_extra_value, sizeof(retvalue) );
793 SERVER_END_REQ;
794 return retvalue;
797 if (offset <= class->cbClsExtra - sizeof(WORD))
798 memcpy( &retvalue, (char *)(class + 1) + offset, sizeof(retvalue) );
799 else
800 SetLastError( ERROR_INVALID_INDEX );
801 release_class_ptr( class );
802 return retvalue;
806 /***********************************************************************
807 * CLASS_GetClassLong
809 * Implementation of GetClassLong(Ptr)A/W
811 static ULONG_PTR CLASS_GetClassLong( HWND hwnd, INT offset, UINT size,
812 BOOL unicode )
814 CLASS *class;
815 ULONG_PTR retvalue = 0;
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 >= 0) ? offset : -1;
826 req->extra_size = (offset >= 0) ? size : 0;
827 if (!wine_server_call_err( req ))
829 switch(offset)
831 case GCLP_HBRBACKGROUND:
832 case GCLP_HCURSOR:
833 case GCLP_HICON:
834 case GCLP_HICONSM:
835 case GCLP_WNDPROC:
836 case GCLP_MENUNAME:
837 FIXME( "offset %d (%s) not supported on other process window %p\n",
838 offset, SPY_GetClassLongOffsetName(offset), hwnd );
839 SetLastError( ERROR_INVALID_HANDLE );
840 break;
841 case GCL_STYLE:
842 retvalue = reply->old_style;
843 break;
844 case GCL_CBWNDEXTRA:
845 retvalue = reply->old_win_extra;
846 break;
847 case GCL_CBCLSEXTRA:
848 retvalue = reply->old_extra;
849 break;
850 case GCLP_HMODULE:
851 retvalue = (ULONG_PTR)wine_server_get_ptr( reply->old_instance );
852 break;
853 case GCW_ATOM:
854 retvalue = reply->old_atom;
855 break;
856 default:
857 if (offset >= 0)
859 if (size == sizeof(DWORD))
861 DWORD retdword;
862 memcpy( &retdword, &reply->old_extra_value, sizeof(DWORD) );
863 retvalue = retdword;
865 else
866 memcpy( &retvalue, &reply->old_extra_value,
867 sizeof(ULONG_PTR) );
869 else SetLastError( ERROR_INVALID_INDEX );
870 break;
874 SERVER_END_REQ;
875 return retvalue;
878 if (offset >= 0)
880 if (offset <= class->cbClsExtra - size)
882 if (size == sizeof(DWORD))
884 DWORD retdword;
885 memcpy( &retdword, (char *)(class + 1) + offset, sizeof(DWORD) );
886 retvalue = retdword;
888 else
889 memcpy( &retvalue, (char *)(class + 1) + offset, sizeof(ULONG_PTR) );
891 else
892 SetLastError( ERROR_INVALID_INDEX );
893 release_class_ptr( class );
894 return retvalue;
897 switch(offset)
899 case GCLP_HBRBACKGROUND:
900 retvalue = (ULONG_PTR)class->hbrBackground;
901 break;
902 case GCLP_HCURSOR:
903 retvalue = (ULONG_PTR)class->hCursor;
904 break;
905 case GCLP_HICON:
906 retvalue = (ULONG_PTR)class->hIcon;
907 break;
908 case GCLP_HICONSM:
909 retvalue = (ULONG_PTR)(class->hIconSm ? class->hIconSm : class->hIconSmIntern);
910 break;
911 case GCL_STYLE:
912 retvalue = class->style;
913 break;
914 case GCL_CBWNDEXTRA:
915 retvalue = class->cbWndExtra;
916 break;
917 case GCL_CBCLSEXTRA:
918 retvalue = class->cbClsExtra;
919 break;
920 case GCLP_HMODULE:
921 retvalue = (ULONG_PTR)class->hInstance;
922 break;
923 case GCLP_WNDPROC:
924 retvalue = (ULONG_PTR)WINPROC_GetProc( class->winproc, unicode );
925 break;
926 case GCLP_MENUNAME:
927 retvalue = (ULONG_PTR)CLASS_GetMenuNameW( class );
928 if (unicode)
929 retvalue = (ULONG_PTR)CLASS_GetMenuNameW( class );
930 else
931 retvalue = (ULONG_PTR)CLASS_GetMenuNameA( class );
932 break;
933 case GCW_ATOM:
934 retvalue = class->atomName;
935 break;
936 default:
937 SetLastError( ERROR_INVALID_INDEX );
938 break;
940 release_class_ptr( class );
941 return retvalue;
945 /***********************************************************************
946 * GetClassLongW (USER32.@)
948 DWORD WINAPI GetClassLongW( HWND hwnd, INT offset )
950 return CLASS_GetClassLong( hwnd, offset, sizeof(DWORD), TRUE );
955 /***********************************************************************
956 * GetClassLongA (USER32.@)
958 DWORD WINAPI GetClassLongA( HWND hwnd, INT offset )
960 return CLASS_GetClassLong( hwnd, offset, sizeof(DWORD), FALSE );
964 /***********************************************************************
965 * SetClassWord (USER32.@)
967 WORD WINAPI SetClassWord( HWND hwnd, INT offset, WORD newval )
969 CLASS *class;
970 WORD retval = 0;
972 if (offset < 0) return SetClassLongA( hwnd, offset, (DWORD)newval );
974 if (!(class = get_class_ptr( hwnd, TRUE ))) return 0;
976 SERVER_START_REQ( set_class_info )
978 req->window = wine_server_user_handle( hwnd );
979 req->flags = SET_CLASS_EXTRA;
980 req->extra_offset = offset;
981 req->extra_size = sizeof(newval);
982 memcpy( &req->extra_value, &newval, sizeof(newval) );
983 if (!wine_server_call_err( req ))
985 void *ptr = (char *)(class + 1) + offset;
986 memcpy( &retval, ptr, sizeof(retval) );
987 memcpy( ptr, &newval, sizeof(newval) );
990 SERVER_END_REQ;
991 release_class_ptr( class );
992 return retval;
996 /***********************************************************************
997 * CLASS_SetClassLong
999 * Implementation of SetClassLong(Ptr)A/W
1001 static ULONG_PTR CLASS_SetClassLong( HWND hwnd, INT offset, LONG_PTR newval,
1002 UINT size, BOOL unicode )
1004 CLASS *class;
1005 ULONG_PTR retval = 0;
1007 if (!(class = get_class_ptr( hwnd, TRUE ))) return 0;
1009 if (offset >= 0)
1011 if (set_server_info( hwnd, offset, newval, size ))
1013 void *ptr = (char *)(class + 1) + offset;
1014 if ( size == sizeof(LONG) )
1016 DWORD retdword;
1017 LONG newlong = newval;
1018 memcpy( &retdword, ptr, sizeof(DWORD) );
1019 memcpy( ptr, &newlong, sizeof(LONG) );
1020 retval = retdword;
1022 else
1024 memcpy( &retval, ptr, sizeof(ULONG_PTR) );
1025 memcpy( ptr, &newval, sizeof(LONG_PTR) );
1029 else switch(offset)
1031 case GCLP_MENUNAME:
1032 if ( unicode )
1033 CLASS_SetMenuNameW( class, (LPCWSTR)newval );
1034 else
1035 CLASS_SetMenuNameA( class, (LPCSTR)newval );
1036 retval = 0; /* Old value is now meaningless anyway */
1037 break;
1038 case GCLP_WNDPROC:
1039 retval = (ULONG_PTR)WINPROC_GetProc( class->winproc, unicode );
1040 class->winproc = WINPROC_AllocProc( (WNDPROC)newval, unicode );
1041 break;
1042 case GCLP_HBRBACKGROUND:
1043 retval = (ULONG_PTR)class->hbrBackground;
1044 class->hbrBackground = (HBRUSH)newval;
1045 break;
1046 case GCLP_HCURSOR:
1047 retval = (ULONG_PTR)class->hCursor;
1048 class->hCursor = (HCURSOR)newval;
1049 break;
1050 case GCLP_HICON:
1051 retval = (ULONG_PTR)class->hIcon;
1052 if (class->hIconSmIntern)
1054 DestroyIcon(class->hIconSmIntern);
1055 class->hIconSmIntern = NULL;
1057 if (newval && !class->hIconSm)
1058 class->hIconSmIntern = CopyImage( (HICON)newval, IMAGE_ICON,
1059 GetSystemMetrics( SM_CXSMICON ), GetSystemMetrics( SM_CYSMICON ),
1060 LR_COPYFROMRESOURCE );
1061 class->hIcon = (HICON)newval;
1062 break;
1063 case GCLP_HICONSM:
1064 retval = (ULONG_PTR)class->hIconSm;
1065 if (retval && !newval && class->hIcon)
1066 class->hIconSmIntern = CopyImage( class->hIcon, IMAGE_ICON,
1067 GetSystemMetrics( SM_CXSMICON ), GetSystemMetrics( SM_CYSMICON ),
1068 LR_COPYFROMRESOURCE );
1069 else if (newval && class->hIconSmIntern)
1071 DestroyIcon(class->hIconSmIntern);
1072 class->hIconSmIntern = NULL;
1074 class->hIconSm = (HICON)newval;
1075 break;
1076 case GCL_STYLE:
1077 if (!set_server_info( hwnd, offset, newval, size )) break;
1078 retval = class->style;
1079 class->style = newval;
1080 break;
1081 case GCL_CBWNDEXTRA:
1082 if (!set_server_info( hwnd, offset, newval, size )) break;
1083 retval = class->cbWndExtra;
1084 class->cbWndExtra = newval;
1085 break;
1086 case GCLP_HMODULE:
1087 if (!set_server_info( hwnd, offset, newval, size )) break;
1088 retval = (ULONG_PTR)class->hInstance;
1089 class->hInstance = (HINSTANCE)newval;
1090 break;
1091 case GCW_ATOM:
1092 if (!set_server_info( hwnd, offset, newval, size )) break;
1093 retval = class->atomName;
1094 class->atomName = newval;
1095 GlobalGetAtomNameW( newval, class->name, sizeof(class->name)/sizeof(WCHAR) );
1096 break;
1097 case GCL_CBCLSEXTRA: /* cannot change this one */
1098 SetLastError( ERROR_INVALID_PARAMETER );
1099 break;
1100 default:
1101 SetLastError( ERROR_INVALID_INDEX );
1102 break;
1104 release_class_ptr( class );
1105 return retval;
1109 /***********************************************************************
1110 * SetClassLongW (USER32.@)
1112 DWORD WINAPI SetClassLongW( HWND hwnd, INT offset, LONG newval )
1114 return CLASS_SetClassLong( hwnd, offset, newval, sizeof(LONG), TRUE );
1118 /***********************************************************************
1119 * SetClassLongA (USER32.@)
1121 DWORD WINAPI SetClassLongA( HWND hwnd, INT offset, LONG newval )
1123 return CLASS_SetClassLong( hwnd, offset, newval, sizeof(LONG), FALSE );
1127 /***********************************************************************
1128 * GetClassNameA (USER32.@)
1130 INT WINAPI GetClassNameA( HWND hwnd, LPSTR buffer, INT count )
1132 WCHAR tmpbuf[MAX_ATOM_LEN + 1];
1133 DWORD len;
1135 if (count <= 0) return 0;
1136 if (!GetClassNameW( hwnd, tmpbuf, sizeof(tmpbuf)/sizeof(WCHAR) )) return 0;
1137 RtlUnicodeToMultiByteN( buffer, count - 1, &len, tmpbuf, strlenW(tmpbuf) * sizeof(WCHAR) );
1138 buffer[len] = 0;
1139 return len;
1143 /***********************************************************************
1144 * GetClassNameW (USER32.@)
1146 INT WINAPI GetClassNameW( HWND hwnd, LPWSTR buffer, INT count )
1148 CLASS *class;
1149 INT ret;
1151 TRACE("%p %p %d\n", hwnd, buffer, count);
1153 if (count <= 0) return 0;
1155 if (!(class = get_class_ptr( hwnd, FALSE ))) return 0;
1157 if (class == CLASS_OTHER_PROCESS)
1159 WCHAR tmpbuf[MAX_ATOM_LEN + 1];
1161 ret = GlobalGetAtomNameW( GetClassLongW( hwnd, GCW_ATOM ), tmpbuf, MAX_ATOM_LEN + 1 );
1162 if (ret)
1164 ret = min(count - 1, ret);
1165 memcpy(buffer, tmpbuf, ret * sizeof(WCHAR));
1166 buffer[ret] = 0;
1169 else
1171 /* Return original name class was registered with. */
1172 lstrcpynW( buffer, class->basename, count );
1173 release_class_ptr( class );
1174 ret = strlenW( buffer );
1176 return ret;
1180 /***********************************************************************
1181 * RealGetWindowClassA (USER32.@)
1183 UINT WINAPI RealGetWindowClassA( HWND hwnd, LPSTR buffer, UINT count )
1185 return GetClassNameA( hwnd, buffer, count );
1189 /***********************************************************************
1190 * RealGetWindowClassW (USER32.@)
1192 UINT WINAPI RealGetWindowClassW( HWND hwnd, LPWSTR buffer, UINT count )
1194 return GetClassNameW( hwnd, buffer, count );
1198 /***********************************************************************
1199 * GetClassInfoA (USER32.@)
1201 BOOL WINAPI GetClassInfoA( HINSTANCE hInstance, LPCSTR name, WNDCLASSA *wc )
1203 WNDCLASSEXA wcex;
1204 UINT ret = GetClassInfoExA( hInstance, name, &wcex );
1206 if (ret)
1208 wc->style = wcex.style;
1209 wc->lpfnWndProc = wcex.lpfnWndProc;
1210 wc->cbClsExtra = wcex.cbClsExtra;
1211 wc->cbWndExtra = wcex.cbWndExtra;
1212 wc->hInstance = wcex.hInstance;
1213 wc->hIcon = wcex.hIcon;
1214 wc->hCursor = wcex.hCursor;
1215 wc->hbrBackground = wcex.hbrBackground;
1216 wc->lpszMenuName = wcex.lpszMenuName;
1217 wc->lpszClassName = wcex.lpszClassName;
1219 return ret;
1223 /***********************************************************************
1224 * GetClassInfoW (USER32.@)
1226 BOOL WINAPI GetClassInfoW( HINSTANCE hInstance, LPCWSTR name, WNDCLASSW *wc )
1228 WNDCLASSEXW wcex;
1229 UINT ret = GetClassInfoExW( hInstance, name, &wcex );
1231 if (ret)
1233 wc->style = wcex.style;
1234 wc->lpfnWndProc = wcex.lpfnWndProc;
1235 wc->cbClsExtra = wcex.cbClsExtra;
1236 wc->cbWndExtra = wcex.cbWndExtra;
1237 wc->hInstance = wcex.hInstance;
1238 wc->hIcon = wcex.hIcon;
1239 wc->hCursor = wcex.hCursor;
1240 wc->hbrBackground = wcex.hbrBackground;
1241 wc->lpszMenuName = wcex.lpszMenuName;
1242 wc->lpszClassName = wcex.lpszClassName;
1244 return ret;
1248 /***********************************************************************
1249 * GetClassInfoExA (USER32.@)
1251 BOOL WINAPI GetClassInfoExA( HINSTANCE hInstance, LPCSTR name, WNDCLASSEXA *wc )
1253 ATOM atom;
1254 CLASS *classPtr;
1256 TRACE("%p %s %p\n", hInstance, debugstr_a(name), wc);
1258 if (!wc)
1260 SetLastError( ERROR_NOACCESS );
1261 return FALSE;
1264 if (!hInstance) hInstance = user32_module;
1266 if (!IS_INTRESOURCE(name))
1268 WCHAR nameW[MAX_ATOM_LEN + 1];
1269 if (!MultiByteToWideChar( CP_ACP, 0, name, -1, nameW, sizeof(nameW)/sizeof(WCHAR) ))
1270 return FALSE;
1271 classPtr = CLASS_FindClass( nameW, hInstance );
1273 else classPtr = CLASS_FindClass( (LPCWSTR)name, hInstance );
1275 if (!classPtr)
1277 SetLastError( ERROR_CLASS_DOES_NOT_EXIST );
1278 return FALSE;
1280 wc->style = classPtr->style;
1281 wc->lpfnWndProc = WINPROC_GetProc( classPtr->winproc, FALSE );
1282 wc->cbClsExtra = classPtr->cbClsExtra;
1283 wc->cbWndExtra = classPtr->cbWndExtra;
1284 wc->hInstance = (hInstance == user32_module) ? 0 : hInstance;
1285 wc->hIcon = classPtr->hIcon;
1286 wc->hIconSm = classPtr->hIconSm ? classPtr->hIconSm : classPtr->hIconSmIntern;
1287 wc->hCursor = classPtr->hCursor;
1288 wc->hbrBackground = classPtr->hbrBackground;
1289 wc->lpszMenuName = CLASS_GetMenuNameA( classPtr );
1290 wc->lpszClassName = name;
1291 atom = classPtr->atomName;
1292 release_class_ptr( classPtr );
1294 /* We must return the atom of the class here instead of just TRUE. */
1295 return atom;
1299 /***********************************************************************
1300 * GetClassInfoExW (USER32.@)
1302 BOOL WINAPI GetClassInfoExW( HINSTANCE hInstance, LPCWSTR name, WNDCLASSEXW *wc )
1304 ATOM atom;
1305 CLASS *classPtr;
1307 TRACE("%p %s %p\n", hInstance, debugstr_w(name), wc);
1309 if (!wc)
1311 SetLastError( ERROR_NOACCESS );
1312 return FALSE;
1315 if (!hInstance) hInstance = user32_module;
1317 if (!(classPtr = CLASS_FindClass( name, hInstance )))
1319 SetLastError( ERROR_CLASS_DOES_NOT_EXIST );
1320 return FALSE;
1322 wc->style = classPtr->style;
1323 wc->lpfnWndProc = WINPROC_GetProc( classPtr->winproc, TRUE );
1324 wc->cbClsExtra = classPtr->cbClsExtra;
1325 wc->cbWndExtra = classPtr->cbWndExtra;
1326 wc->hInstance = (hInstance == user32_module) ? 0 : hInstance;
1327 wc->hIcon = classPtr->hIcon;
1328 wc->hIconSm = classPtr->hIconSm ? classPtr->hIconSm : classPtr->hIconSmIntern;
1329 wc->hCursor = classPtr->hCursor;
1330 wc->hbrBackground = classPtr->hbrBackground;
1331 wc->lpszMenuName = CLASS_GetMenuNameW( classPtr );
1332 wc->lpszClassName = name;
1333 atom = classPtr->atomName;
1334 release_class_ptr( classPtr );
1336 /* We must return the atom of the class here instead of just TRUE. */
1337 return atom;
1341 #if 0 /* toolhelp is in kernel, so this cannot work */
1343 /***********************************************************************
1344 * ClassFirst (TOOLHELP.69)
1346 BOOL16 WINAPI ClassFirst16( CLASSENTRY *pClassEntry )
1348 TRACE("%p\n",pClassEntry);
1349 pClassEntry->wNext = 1;
1350 return ClassNext16( pClassEntry );
1354 /***********************************************************************
1355 * ClassNext (TOOLHELP.70)
1357 BOOL16 WINAPI ClassNext16( CLASSENTRY *pClassEntry )
1359 int i;
1360 CLASS *class = firstClass;
1362 TRACE("%p\n",pClassEntry);
1364 if (!pClassEntry->wNext) return FALSE;
1365 for (i = 1; (i < pClassEntry->wNext) && class; i++) class = class->next;
1366 if (!class)
1368 pClassEntry->wNext = 0;
1369 return FALSE;
1371 pClassEntry->hInst = class->hInstance;
1372 pClassEntry->wNext++;
1373 GlobalGetAtomNameA( class->atomName, pClassEntry->szClassName,
1374 sizeof(pClassEntry->szClassName) );
1375 return TRUE;
1377 #endif
1379 /* 64bit versions */
1381 #ifdef GetClassLongPtrA
1382 #undef GetClassLongPtrA
1383 #endif
1385 #ifdef GetClassLongPtrW
1386 #undef GetClassLongPtrW
1387 #endif
1389 #ifdef SetClassLongPtrA
1390 #undef SetClassLongPtrA
1391 #endif
1393 #ifdef SetClassLongPtrW
1394 #undef SetClassLongPtrW
1395 #endif
1397 /***********************************************************************
1398 * GetClassLongPtrA (USER32.@)
1400 ULONG_PTR WINAPI GetClassLongPtrA( HWND hwnd, INT offset )
1402 return CLASS_GetClassLong( hwnd, offset, sizeof(ULONG_PTR), FALSE );
1405 /***********************************************************************
1406 * GetClassLongPtrW (USER32.@)
1408 ULONG_PTR WINAPI GetClassLongPtrW( HWND hwnd, INT offset )
1410 return CLASS_GetClassLong( hwnd, offset, sizeof(ULONG_PTR), TRUE );
1413 /***********************************************************************
1414 * SetClassLongPtrW (USER32.@)
1416 ULONG_PTR WINAPI SetClassLongPtrW( HWND hwnd, INT offset, LONG_PTR newval )
1418 return CLASS_SetClassLong( hwnd, offset, newval, sizeof(LONG_PTR), TRUE );
1421 /***********************************************************************
1422 * SetClassLongPtrA (USER32.@)
1424 ULONG_PTR WINAPI SetClassLongPtrA( HWND hwnd, INT offset, LONG_PTR newval )
1426 return CLASS_SetClassLong( hwnd, offset, newval, sizeof(LONG_PTR), FALSE );