comctl32: Introduce ListBox control.
[wine.git] / dlls / user32 / class.c
blobe733cc2ce2e5143333ac104232f185f1ba48c405
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 {'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 = (sizeof(classesW) / sizeof(classesW[0])) - 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 )
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;
337 if (basename_offset)
338 *basename_offset = 0;
340 if (IS_INTRESOURCE( name ))
341 return name;
343 if (is_comctl32_class( name ) || is_builtin_class( name ))
344 return name;
346 data.cbSize = sizeof(data);
347 if (!FindActCtxSectionStringW(0, NULL, ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION, name, &data))
348 return name;
350 wndclass = (struct wndclass_redirect_data *)data.lpData;
351 if (basename_offset)
352 *basename_offset = wndclass->name_len / sizeof(WCHAR) - strlenW(name);
354 module = (const WCHAR *)((BYTE *)data.lpSectionBase + wndclass->module_offset);
355 if (!GetModuleHandleW( module ))
356 LoadLibraryW( module );
358 return (const WCHAR *)((BYTE *)wndclass + wndclass->name_offset);
361 /***********************************************************************
362 * CLASS_FindClass
364 * Return a pointer to the class.
366 static CLASS *CLASS_FindClass( LPCWSTR name, HINSTANCE hinstance )
368 static const WCHAR comctl32W[] = {'c','o','m','c','t','l','3','2','.','d','l','l',0};
369 struct list *ptr;
370 ATOM atom = get_int_atom_value( name );
372 GetDesktopWindow(); /* create the desktop window to trigger builtin class registration */
374 if (!name) return NULL;
376 name = CLASS_GetVersionedName( name, NULL );
378 for (;;)
380 USER_Lock();
382 LIST_FOR_EACH( ptr, &class_list )
384 CLASS *class = LIST_ENTRY( ptr, CLASS, entry );
385 if (atom)
387 if (class->atomName != atom) continue;
389 else
391 if (strcmpiW( class->name, name )) continue;
393 if (!class->local || class->hInstance == hinstance)
395 TRACE("%s %p -> %p\n", debugstr_w(name), hinstance, class);
396 return class;
399 USER_Unlock();
401 if (atom) break;
402 if (!is_comctl32_class( name )) break;
403 if (GetModuleHandleW( comctl32W )) break;
404 if (!LoadLibraryW( comctl32W )) break;
405 TRACE( "%s retrying after loading comctl32\n", debugstr_w(name) );
408 TRACE("%s %p -> not found\n", debugstr_w(name), hinstance);
409 return NULL;
413 /***********************************************************************
414 * CLASS_RegisterClass
416 * The real RegisterClass() functionality.
418 static CLASS *CLASS_RegisterClass( LPCWSTR name, UINT basename_offset, HINSTANCE hInstance, BOOL local,
419 DWORD style, INT classExtra, INT winExtra )
421 CLASS *classPtr;
422 BOOL ret;
424 TRACE("name=%s hinst=%p style=0x%x clExtr=0x%x winExtr=0x%x\n",
425 debugstr_w(name), hInstance, style, classExtra, winExtra );
427 /* Fix the extra bytes value */
429 if (classExtra > 40) /* Extra bytes are limited to 40 in Win32 */
430 WARN("Class extra bytes %d is > 40\n", classExtra);
431 if (winExtra > 40) /* Extra bytes are limited to 40 in Win32 */
432 WARN("Win extra bytes %d is > 40\n", winExtra );
434 classPtr = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(CLASS) + classExtra );
435 if (!classPtr) return NULL;
437 classPtr->atomName = get_int_atom_value( name );
438 classPtr->basename = classPtr->name;
439 if (!classPtr->atomName && name)
441 strcpyW( classPtr->name, name );
442 classPtr->basename += basename_offset;
444 else GlobalGetAtomNameW( classPtr->atomName, classPtr->name, sizeof(classPtr->name)/sizeof(WCHAR) );
446 SERVER_START_REQ( create_class )
448 req->local = local;
449 req->style = style;
450 req->instance = wine_server_client_ptr( hInstance );
451 req->extra = classExtra;
452 req->win_extra = winExtra;
453 req->client_ptr = wine_server_client_ptr( classPtr );
454 req->atom = classPtr->atomName;
455 if (!req->atom && name) wine_server_add_data( req, name, strlenW(name) * sizeof(WCHAR) );
456 ret = !wine_server_call_err( req );
457 classPtr->atomName = reply->atom;
459 SERVER_END_REQ;
460 if (!ret)
462 HeapFree( GetProcessHeap(), 0, classPtr );
463 return NULL;
466 classPtr->style = style;
467 classPtr->local = local;
468 classPtr->cbWndExtra = winExtra;
469 classPtr->cbClsExtra = classExtra;
470 classPtr->hInstance = hInstance;
472 /* Other non-null values must be set by caller */
474 USER_Lock();
475 if (local) list_add_head( &class_list, &classPtr->entry );
476 else list_add_tail( &class_list, &classPtr->entry );
477 return classPtr;
481 /***********************************************************************
482 * register_builtin
484 * Register a builtin control class.
485 * This allows having both ASCII and Unicode winprocs for the same class.
487 static void register_builtin( const struct builtin_class_descr *descr )
489 CLASS *classPtr;
491 if (!(classPtr = CLASS_RegisterClass( descr->name, 0, user32_module, FALSE,
492 descr->style, 0, descr->extra ))) return;
494 if (descr->cursor) classPtr->hCursor = LoadCursorA( 0, (LPSTR)descr->cursor );
495 classPtr->hbrBackground = descr->brush;
496 classPtr->winproc = BUILTIN_WINPROC( descr->proc );
497 release_class_ptr( classPtr );
501 /***********************************************************************
502 * register_builtins
504 static BOOL WINAPI register_builtins( INIT_ONCE *once, void *param, void **context )
506 register_builtin( &BUTTON_builtin_class );
507 register_builtin( &COMBO_builtin_class );
508 register_builtin( &COMBOLBOX_builtin_class );
509 register_builtin( &DIALOG_builtin_class );
510 register_builtin( &EDIT_builtin_class );
511 register_builtin( &ICONTITLE_builtin_class );
512 register_builtin( &LISTBOX_builtin_class );
513 register_builtin( &MDICLIENT_builtin_class );
514 register_builtin( &MENU_builtin_class );
515 register_builtin( &SCROLL_builtin_class );
516 register_builtin( &STATIC_builtin_class );
517 register_builtin( &IME_builtin_class );
518 return TRUE;
522 /***********************************************************************
523 * register_builtin_classes
525 void register_builtin_classes(void)
527 InitOnceExecuteOnce( &init_once, register_builtins, NULL, NULL );
531 /***********************************************************************
532 * register_desktop_class
534 void register_desktop_class(void)
536 register_builtin( &DESKTOP_builtin_class );
537 register_builtin( &MESSAGE_builtin_class );
541 /***********************************************************************
542 * get_class_winproc
544 WNDPROC get_class_winproc( CLASS *class )
546 return class->winproc;
550 /***********************************************************************
551 * get_class_dce
553 struct dce *get_class_dce( CLASS *class )
555 return class->dce;
559 /***********************************************************************
560 * set_class_dce
562 struct dce *set_class_dce( CLASS *class, struct dce *dce )
564 if (class->dce) return class->dce; /* already set, don't change it */
565 class->dce = dce;
566 return dce;
570 /***********************************************************************
571 * RegisterClassA (USER32.@)
573 * Register a window class.
575 * RETURNS
576 * >0: Unique identifier
577 * 0: Failure
579 ATOM WINAPI RegisterClassA( const WNDCLASSA* wc ) /* [in] Address of structure with class data */
581 WNDCLASSEXA wcex;
583 wcex.cbSize = sizeof(wcex);
584 wcex.style = wc->style;
585 wcex.lpfnWndProc = wc->lpfnWndProc;
586 wcex.cbClsExtra = wc->cbClsExtra;
587 wcex.cbWndExtra = wc->cbWndExtra;
588 wcex.hInstance = wc->hInstance;
589 wcex.hIcon = wc->hIcon;
590 wcex.hCursor = wc->hCursor;
591 wcex.hbrBackground = wc->hbrBackground;
592 wcex.lpszMenuName = wc->lpszMenuName;
593 wcex.lpszClassName = wc->lpszClassName;
594 wcex.hIconSm = 0;
595 return RegisterClassExA( &wcex );
599 /***********************************************************************
600 * RegisterClassW (USER32.@)
602 * See RegisterClassA.
604 ATOM WINAPI RegisterClassW( const WNDCLASSW* wc )
606 WNDCLASSEXW wcex;
608 wcex.cbSize = sizeof(wcex);
609 wcex.style = wc->style;
610 wcex.lpfnWndProc = wc->lpfnWndProc;
611 wcex.cbClsExtra = wc->cbClsExtra;
612 wcex.cbWndExtra = wc->cbWndExtra;
613 wcex.hInstance = wc->hInstance;
614 wcex.hIcon = wc->hIcon;
615 wcex.hCursor = wc->hCursor;
616 wcex.hbrBackground = wc->hbrBackground;
617 wcex.lpszMenuName = wc->lpszMenuName;
618 wcex.lpszClassName = wc->lpszClassName;
619 wcex.hIconSm = 0;
620 return RegisterClassExW( &wcex );
624 /***********************************************************************
625 * RegisterClassExA (USER32.@)
627 ATOM WINAPI RegisterClassExA( const WNDCLASSEXA* wc )
629 const WCHAR *classname = NULL;
630 WCHAR name[MAX_ATOM_LEN + 1];
631 ATOM atom;
632 CLASS *classPtr;
633 HINSTANCE instance;
635 GetDesktopWindow(); /* create the desktop window to trigger builtin class registration */
637 if (wc->cbSize != sizeof(*wc) || wc->cbClsExtra < 0 || wc->cbWndExtra < 0 ||
638 wc->hInstance == user32_module) /* we can't register a class for user32 */
640 SetLastError( ERROR_INVALID_PARAMETER );
641 return 0;
643 if (!(instance = wc->hInstance)) instance = GetModuleHandleW( NULL );
645 if (!IS_INTRESOURCE(wc->lpszClassName))
647 UINT basename_offset;
648 if (!MultiByteToWideChar( CP_ACP, 0, wc->lpszClassName, -1, name, MAX_ATOM_LEN + 1 )) return 0;
649 classname = CLASS_GetVersionedName( name, &basename_offset );
650 classPtr = CLASS_RegisterClass( classname, basename_offset, instance, !(wc->style & CS_GLOBALCLASS),
651 wc->style, wc->cbClsExtra, wc->cbWndExtra );
653 else
655 classPtr = CLASS_RegisterClass( (LPCWSTR)wc->lpszClassName, 0, instance,
656 !(wc->style & CS_GLOBALCLASS), wc->style,
657 wc->cbClsExtra, wc->cbWndExtra );
659 if (!classPtr) return 0;
660 atom = classPtr->atomName;
662 TRACE("name=%s%s%s atom=%04x wndproc=%p hinst=%p bg=%p style=%08x clsExt=%d winExt=%d class=%p\n",
663 debugstr_a(wc->lpszClassName), classname != name ? "->" : "", classname != name ? debugstr_w(classname) : "",
664 atom, wc->lpfnWndProc, instance, wc->hbrBackground, wc->style, wc->cbClsExtra, wc->cbWndExtra, classPtr );
666 classPtr->hIcon = wc->hIcon;
667 classPtr->hIconSm = wc->hIconSm;
668 classPtr->hIconSmIntern = wc->hIcon && !wc->hIconSm ?
669 CopyImage( wc->hIcon, IMAGE_ICON,
670 GetSystemMetrics( SM_CXSMICON ),
671 GetSystemMetrics( SM_CYSMICON ),
672 LR_COPYFROMRESOURCE ) : NULL;
673 classPtr->hCursor = wc->hCursor;
674 classPtr->hbrBackground = wc->hbrBackground;
675 classPtr->winproc = WINPROC_AllocProc( wc->lpfnWndProc, FALSE );
676 CLASS_SetMenuNameA( classPtr, wc->lpszMenuName );
677 release_class_ptr( classPtr );
678 return atom;
682 /***********************************************************************
683 * RegisterClassExW (USER32.@)
685 ATOM WINAPI RegisterClassExW( const WNDCLASSEXW* wc )
687 const WCHAR *classname;
688 UINT basename_offset;
689 ATOM atom;
690 CLASS *classPtr;
691 HINSTANCE instance;
693 GetDesktopWindow(); /* create the desktop window to trigger builtin class registration */
695 if (wc->cbSize != sizeof(*wc) || wc->cbClsExtra < 0 || wc->cbWndExtra < 0 ||
696 wc->hInstance == user32_module) /* we can't register a class for user32 */
698 SetLastError( ERROR_INVALID_PARAMETER );
699 return 0;
701 if (!(instance = wc->hInstance)) instance = GetModuleHandleW( NULL );
703 classname = CLASS_GetVersionedName( wc->lpszClassName, &basename_offset );
704 if (!(classPtr = CLASS_RegisterClass( classname, basename_offset, instance, !(wc->style & CS_GLOBALCLASS),
705 wc->style, wc->cbClsExtra, wc->cbWndExtra )))
706 return 0;
708 atom = classPtr->atomName;
710 TRACE("name=%s%s%s atom=%04x wndproc=%p hinst=%p bg=%p style=%08x clsExt=%d winExt=%d class=%p\n",
711 debugstr_w(wc->lpszClassName), classname != wc->lpszClassName ? "->" : "",
712 classname != wc->lpszClassName ? debugstr_w(classname) : "", atom, wc->lpfnWndProc, instance,
713 wc->hbrBackground, wc->style, wc->cbClsExtra, wc->cbWndExtra, classPtr );
715 classPtr->hIcon = wc->hIcon;
716 classPtr->hIconSm = wc->hIconSm;
717 classPtr->hIconSmIntern = wc->hIcon && !wc->hIconSm ?
718 CopyImage( wc->hIcon, IMAGE_ICON,
719 GetSystemMetrics( SM_CXSMICON ),
720 GetSystemMetrics( SM_CYSMICON ),
721 LR_COPYFROMRESOURCE ) : NULL;
722 classPtr->hCursor = wc->hCursor;
723 classPtr->hbrBackground = wc->hbrBackground;
724 classPtr->winproc = WINPROC_AllocProc( wc->lpfnWndProc, TRUE );
725 CLASS_SetMenuNameW( classPtr, wc->lpszMenuName );
726 release_class_ptr( classPtr );
727 return atom;
731 /***********************************************************************
732 * UnregisterClassA (USER32.@)
734 BOOL WINAPI UnregisterClassA( LPCSTR className, HINSTANCE hInstance )
736 if (!IS_INTRESOURCE(className))
738 WCHAR name[MAX_ATOM_LEN + 1];
740 if (!MultiByteToWideChar( CP_ACP, 0, className, -1, name, MAX_ATOM_LEN + 1 ))
741 return FALSE;
742 return UnregisterClassW( name, hInstance );
744 return UnregisterClassW( (LPCWSTR)className, hInstance );
747 /***********************************************************************
748 * UnregisterClassW (USER32.@)
750 BOOL WINAPI UnregisterClassW( LPCWSTR className, HINSTANCE hInstance )
752 CLASS *classPtr = NULL;
754 GetDesktopWindow(); /* create the desktop window to trigger builtin class registration */
756 className = CLASS_GetVersionedName( className, NULL );
757 SERVER_START_REQ( destroy_class )
759 req->instance = wine_server_client_ptr( hInstance );
760 if (!(req->atom = get_int_atom_value(className)) && className)
761 wine_server_add_data( req, className, strlenW(className) * sizeof(WCHAR) );
762 if (!wine_server_call_err( req )) classPtr = wine_server_get_ptr( reply->client_ptr );
764 SERVER_END_REQ;
766 if (classPtr) CLASS_FreeClass( classPtr );
767 return (classPtr != NULL);
771 /***********************************************************************
772 * GetClassWord (USER32.@)
774 WORD WINAPI GetClassWord( HWND hwnd, INT offset )
776 CLASS *class;
777 WORD retvalue = 0;
779 if (offset < 0) return GetClassLongA( hwnd, offset );
781 if (!(class = get_class_ptr( hwnd, FALSE ))) return 0;
783 if (class == CLASS_OTHER_PROCESS)
785 SERVER_START_REQ( set_class_info )
787 req->window = wine_server_user_handle( hwnd );
788 req->flags = 0;
789 req->extra_offset = offset;
790 req->extra_size = sizeof(retvalue);
791 if (!wine_server_call_err( req ))
792 memcpy( &retvalue, &reply->old_extra_value, sizeof(retvalue) );
794 SERVER_END_REQ;
795 return retvalue;
798 if (offset <= class->cbClsExtra - sizeof(WORD))
799 memcpy( &retvalue, (char *)(class + 1) + offset, sizeof(retvalue) );
800 else
801 SetLastError( ERROR_INVALID_INDEX );
802 release_class_ptr( class );
803 return retvalue;
807 /***********************************************************************
808 * CLASS_GetClassLong
810 * Implementation of GetClassLong(Ptr)A/W
812 static ULONG_PTR CLASS_GetClassLong( HWND hwnd, INT offset, UINT size,
813 BOOL unicode )
815 CLASS *class;
816 ULONG_PTR retvalue = 0;
818 if (!(class = get_class_ptr( hwnd, FALSE ))) return 0;
820 if (class == CLASS_OTHER_PROCESS)
822 SERVER_START_REQ( set_class_info )
824 req->window = wine_server_user_handle( hwnd );
825 req->flags = 0;
826 req->extra_offset = (offset >= 0) ? offset : -1;
827 req->extra_size = (offset >= 0) ? size : 0;
828 if (!wine_server_call_err( req ))
830 switch(offset)
832 case GCLP_HBRBACKGROUND:
833 case GCLP_HCURSOR:
834 case GCLP_HICON:
835 case GCLP_HICONSM:
836 case GCLP_WNDPROC:
837 case GCLP_MENUNAME:
838 FIXME( "offset %d (%s) not supported on other process window %p\n",
839 offset, SPY_GetClassLongOffsetName(offset), hwnd );
840 SetLastError( ERROR_INVALID_HANDLE );
841 break;
842 case GCL_STYLE:
843 retvalue = reply->old_style;
844 break;
845 case GCL_CBWNDEXTRA:
846 retvalue = reply->old_win_extra;
847 break;
848 case GCL_CBCLSEXTRA:
849 retvalue = reply->old_extra;
850 break;
851 case GCLP_HMODULE:
852 retvalue = (ULONG_PTR)wine_server_get_ptr( reply->old_instance );
853 break;
854 case GCW_ATOM:
855 retvalue = reply->old_atom;
856 break;
857 default:
858 if (offset >= 0)
860 if (size == sizeof(DWORD))
862 DWORD retdword;
863 memcpy( &retdword, &reply->old_extra_value, sizeof(DWORD) );
864 retvalue = retdword;
866 else
867 memcpy( &retvalue, &reply->old_extra_value,
868 sizeof(ULONG_PTR) );
870 else SetLastError( ERROR_INVALID_INDEX );
871 break;
875 SERVER_END_REQ;
876 return retvalue;
879 if (offset >= 0)
881 if (offset <= class->cbClsExtra - size)
883 if (size == sizeof(DWORD))
885 DWORD retdword;
886 memcpy( &retdword, (char *)(class + 1) + offset, sizeof(DWORD) );
887 retvalue = retdword;
889 else
890 memcpy( &retvalue, (char *)(class + 1) + offset, sizeof(ULONG_PTR) );
892 else
893 SetLastError( ERROR_INVALID_INDEX );
894 release_class_ptr( class );
895 return retvalue;
898 switch(offset)
900 case GCLP_HBRBACKGROUND:
901 retvalue = (ULONG_PTR)class->hbrBackground;
902 break;
903 case GCLP_HCURSOR:
904 retvalue = (ULONG_PTR)class->hCursor;
905 break;
906 case GCLP_HICON:
907 retvalue = (ULONG_PTR)class->hIcon;
908 break;
909 case GCLP_HICONSM:
910 retvalue = (ULONG_PTR)(class->hIconSm ? class->hIconSm : class->hIconSmIntern);
911 break;
912 case GCL_STYLE:
913 retvalue = class->style;
914 break;
915 case GCL_CBWNDEXTRA:
916 retvalue = class->cbWndExtra;
917 break;
918 case GCL_CBCLSEXTRA:
919 retvalue = class->cbClsExtra;
920 break;
921 case GCLP_HMODULE:
922 retvalue = (ULONG_PTR)class->hInstance;
923 break;
924 case GCLP_WNDPROC:
925 retvalue = (ULONG_PTR)WINPROC_GetProc( class->winproc, unicode );
926 break;
927 case GCLP_MENUNAME:
928 retvalue = (ULONG_PTR)CLASS_GetMenuNameW( class );
929 if (unicode)
930 retvalue = (ULONG_PTR)CLASS_GetMenuNameW( class );
931 else
932 retvalue = (ULONG_PTR)CLASS_GetMenuNameA( class );
933 break;
934 case GCW_ATOM:
935 retvalue = class->atomName;
936 break;
937 default:
938 SetLastError( ERROR_INVALID_INDEX );
939 break;
941 release_class_ptr( class );
942 return retvalue;
946 /***********************************************************************
947 * GetClassLongW (USER32.@)
949 DWORD WINAPI GetClassLongW( HWND hwnd, INT offset )
951 return CLASS_GetClassLong( hwnd, offset, sizeof(DWORD), TRUE );
956 /***********************************************************************
957 * GetClassLongA (USER32.@)
959 DWORD WINAPI GetClassLongA( HWND hwnd, INT offset )
961 return CLASS_GetClassLong( hwnd, offset, sizeof(DWORD), FALSE );
965 /***********************************************************************
966 * SetClassWord (USER32.@)
968 WORD WINAPI SetClassWord( HWND hwnd, INT offset, WORD newval )
970 CLASS *class;
971 WORD retval = 0;
973 if (offset < 0) return SetClassLongA( hwnd, offset, (DWORD)newval );
975 if (!(class = get_class_ptr( hwnd, TRUE ))) return 0;
977 SERVER_START_REQ( set_class_info )
979 req->window = wine_server_user_handle( hwnd );
980 req->flags = SET_CLASS_EXTRA;
981 req->extra_offset = offset;
982 req->extra_size = sizeof(newval);
983 memcpy( &req->extra_value, &newval, sizeof(newval) );
984 if (!wine_server_call_err( req ))
986 void *ptr = (char *)(class + 1) + offset;
987 memcpy( &retval, ptr, sizeof(retval) );
988 memcpy( ptr, &newval, sizeof(newval) );
991 SERVER_END_REQ;
992 release_class_ptr( class );
993 return retval;
997 /***********************************************************************
998 * CLASS_SetClassLong
1000 * Implementation of SetClassLong(Ptr)A/W
1002 static ULONG_PTR CLASS_SetClassLong( HWND hwnd, INT offset, LONG_PTR newval,
1003 UINT size, BOOL unicode )
1005 CLASS *class;
1006 ULONG_PTR retval = 0;
1008 if (!(class = get_class_ptr( hwnd, TRUE ))) return 0;
1010 if (offset >= 0)
1012 if (set_server_info( hwnd, offset, newval, size ))
1014 void *ptr = (char *)(class + 1) + offset;
1015 if ( size == sizeof(LONG) )
1017 DWORD retdword;
1018 LONG newlong = newval;
1019 memcpy( &retdword, ptr, sizeof(DWORD) );
1020 memcpy( ptr, &newlong, sizeof(LONG) );
1021 retval = retdword;
1023 else
1025 memcpy( &retval, ptr, sizeof(ULONG_PTR) );
1026 memcpy( ptr, &newval, sizeof(LONG_PTR) );
1030 else switch(offset)
1032 case GCLP_MENUNAME:
1033 if ( unicode )
1034 CLASS_SetMenuNameW( class, (LPCWSTR)newval );
1035 else
1036 CLASS_SetMenuNameA( class, (LPCSTR)newval );
1037 retval = 0; /* Old value is now meaningless anyway */
1038 break;
1039 case GCLP_WNDPROC:
1040 retval = (ULONG_PTR)WINPROC_GetProc( class->winproc, unicode );
1041 class->winproc = WINPROC_AllocProc( (WNDPROC)newval, unicode );
1042 break;
1043 case GCLP_HBRBACKGROUND:
1044 retval = (ULONG_PTR)class->hbrBackground;
1045 class->hbrBackground = (HBRUSH)newval;
1046 break;
1047 case GCLP_HCURSOR:
1048 retval = (ULONG_PTR)class->hCursor;
1049 class->hCursor = (HCURSOR)newval;
1050 break;
1051 case GCLP_HICON:
1052 retval = (ULONG_PTR)class->hIcon;
1053 if (class->hIconSmIntern)
1055 DestroyIcon(class->hIconSmIntern);
1056 class->hIconSmIntern = NULL;
1058 if (newval && !class->hIconSm)
1059 class->hIconSmIntern = CopyImage( (HICON)newval, IMAGE_ICON,
1060 GetSystemMetrics( SM_CXSMICON ), GetSystemMetrics( SM_CYSMICON ),
1061 LR_COPYFROMRESOURCE );
1062 class->hIcon = (HICON)newval;
1063 break;
1064 case GCLP_HICONSM:
1065 retval = (ULONG_PTR)class->hIconSm;
1066 if (retval && !newval && class->hIcon)
1067 class->hIconSmIntern = CopyImage( class->hIcon, IMAGE_ICON,
1068 GetSystemMetrics( SM_CXSMICON ), GetSystemMetrics( SM_CYSMICON ),
1069 LR_COPYFROMRESOURCE );
1070 else if (newval && class->hIconSmIntern)
1072 DestroyIcon(class->hIconSmIntern);
1073 class->hIconSmIntern = NULL;
1075 class->hIconSm = (HICON)newval;
1076 break;
1077 case GCL_STYLE:
1078 if (!set_server_info( hwnd, offset, newval, size )) break;
1079 retval = class->style;
1080 class->style = newval;
1081 break;
1082 case GCL_CBWNDEXTRA:
1083 if (!set_server_info( hwnd, offset, newval, size )) break;
1084 retval = class->cbWndExtra;
1085 class->cbWndExtra = newval;
1086 break;
1087 case GCLP_HMODULE:
1088 if (!set_server_info( hwnd, offset, newval, size )) break;
1089 retval = (ULONG_PTR)class->hInstance;
1090 class->hInstance = (HINSTANCE)newval;
1091 break;
1092 case GCW_ATOM:
1093 if (!set_server_info( hwnd, offset, newval, size )) break;
1094 retval = class->atomName;
1095 class->atomName = newval;
1096 GlobalGetAtomNameW( newval, class->name, sizeof(class->name)/sizeof(WCHAR) );
1097 break;
1098 case GCL_CBCLSEXTRA: /* cannot change this one */
1099 SetLastError( ERROR_INVALID_PARAMETER );
1100 break;
1101 default:
1102 SetLastError( ERROR_INVALID_INDEX );
1103 break;
1105 release_class_ptr( class );
1106 return retval;
1110 /***********************************************************************
1111 * SetClassLongW (USER32.@)
1113 DWORD WINAPI SetClassLongW( HWND hwnd, INT offset, LONG newval )
1115 return CLASS_SetClassLong( hwnd, offset, newval, sizeof(LONG), TRUE );
1119 /***********************************************************************
1120 * SetClassLongA (USER32.@)
1122 DWORD WINAPI SetClassLongA( HWND hwnd, INT offset, LONG newval )
1124 return CLASS_SetClassLong( hwnd, offset, newval, sizeof(LONG), FALSE );
1128 /***********************************************************************
1129 * GetClassNameA (USER32.@)
1131 INT WINAPI GetClassNameA( HWND hwnd, LPSTR buffer, INT count )
1133 WCHAR tmpbuf[MAX_ATOM_LEN + 1];
1134 DWORD len;
1136 if (count <= 0) return 0;
1137 if (!GetClassNameW( hwnd, tmpbuf, sizeof(tmpbuf)/sizeof(WCHAR) )) return 0;
1138 RtlUnicodeToMultiByteN( buffer, count - 1, &len, tmpbuf, strlenW(tmpbuf) * sizeof(WCHAR) );
1139 buffer[len] = 0;
1140 return len;
1144 /***********************************************************************
1145 * GetClassNameW (USER32.@)
1147 INT WINAPI GetClassNameW( HWND hwnd, LPWSTR buffer, INT count )
1149 CLASS *class;
1150 INT ret;
1152 TRACE("%p %p %d\n", hwnd, buffer, count);
1154 if (count <= 0) return 0;
1156 if (!(class = get_class_ptr( hwnd, FALSE ))) return 0;
1158 if (class == CLASS_OTHER_PROCESS)
1160 WCHAR tmpbuf[MAX_ATOM_LEN + 1];
1162 ret = GlobalGetAtomNameW( GetClassLongW( hwnd, GCW_ATOM ), tmpbuf, MAX_ATOM_LEN + 1 );
1163 if (ret)
1165 ret = min(count - 1, ret);
1166 memcpy(buffer, tmpbuf, ret * sizeof(WCHAR));
1167 buffer[ret] = 0;
1170 else
1172 /* Return original name class was registered with. */
1173 lstrcpynW( buffer, class->basename, count );
1174 release_class_ptr( class );
1175 ret = strlenW( buffer );
1177 return ret;
1181 /***********************************************************************
1182 * RealGetWindowClassA (USER32.@)
1184 UINT WINAPI RealGetWindowClassA( HWND hwnd, LPSTR buffer, UINT count )
1186 return GetClassNameA( hwnd, buffer, count );
1190 /***********************************************************************
1191 * RealGetWindowClassW (USER32.@)
1193 UINT WINAPI RealGetWindowClassW( HWND hwnd, LPWSTR buffer, UINT count )
1195 return GetClassNameW( hwnd, buffer, count );
1199 /***********************************************************************
1200 * GetClassInfoA (USER32.@)
1202 BOOL WINAPI GetClassInfoA( HINSTANCE hInstance, LPCSTR name, WNDCLASSA *wc )
1204 WNDCLASSEXA wcex;
1205 UINT ret = GetClassInfoExA( hInstance, name, &wcex );
1207 if (ret)
1209 wc->style = wcex.style;
1210 wc->lpfnWndProc = wcex.lpfnWndProc;
1211 wc->cbClsExtra = wcex.cbClsExtra;
1212 wc->cbWndExtra = wcex.cbWndExtra;
1213 wc->hInstance = wcex.hInstance;
1214 wc->hIcon = wcex.hIcon;
1215 wc->hCursor = wcex.hCursor;
1216 wc->hbrBackground = wcex.hbrBackground;
1217 wc->lpszMenuName = wcex.lpszMenuName;
1218 wc->lpszClassName = wcex.lpszClassName;
1220 return ret;
1224 /***********************************************************************
1225 * GetClassInfoW (USER32.@)
1227 BOOL WINAPI GetClassInfoW( HINSTANCE hInstance, LPCWSTR name, WNDCLASSW *wc )
1229 WNDCLASSEXW wcex;
1230 UINT ret = GetClassInfoExW( hInstance, name, &wcex );
1232 if (ret)
1234 wc->style = wcex.style;
1235 wc->lpfnWndProc = wcex.lpfnWndProc;
1236 wc->cbClsExtra = wcex.cbClsExtra;
1237 wc->cbWndExtra = wcex.cbWndExtra;
1238 wc->hInstance = wcex.hInstance;
1239 wc->hIcon = wcex.hIcon;
1240 wc->hCursor = wcex.hCursor;
1241 wc->hbrBackground = wcex.hbrBackground;
1242 wc->lpszMenuName = wcex.lpszMenuName;
1243 wc->lpszClassName = wcex.lpszClassName;
1245 return ret;
1249 /***********************************************************************
1250 * GetClassInfoExA (USER32.@)
1252 BOOL WINAPI GetClassInfoExA( HINSTANCE hInstance, LPCSTR name, WNDCLASSEXA *wc )
1254 ATOM atom;
1255 CLASS *classPtr;
1257 TRACE("%p %s %p\n", hInstance, debugstr_a(name), wc);
1259 if (!wc)
1261 SetLastError( ERROR_NOACCESS );
1262 return FALSE;
1265 if (!hInstance) hInstance = user32_module;
1267 if (!IS_INTRESOURCE(name))
1269 WCHAR nameW[MAX_ATOM_LEN + 1];
1270 if (!MultiByteToWideChar( CP_ACP, 0, name, -1, nameW, sizeof(nameW)/sizeof(WCHAR) ))
1271 return FALSE;
1272 classPtr = CLASS_FindClass( nameW, hInstance );
1274 else classPtr = CLASS_FindClass( (LPCWSTR)name, hInstance );
1276 if (!classPtr)
1278 SetLastError( ERROR_CLASS_DOES_NOT_EXIST );
1279 return FALSE;
1281 wc->style = classPtr->style;
1282 wc->lpfnWndProc = WINPROC_GetProc( classPtr->winproc, FALSE );
1283 wc->cbClsExtra = classPtr->cbClsExtra;
1284 wc->cbWndExtra = classPtr->cbWndExtra;
1285 wc->hInstance = (hInstance == user32_module) ? 0 : hInstance;
1286 wc->hIcon = classPtr->hIcon;
1287 wc->hIconSm = classPtr->hIconSm ? classPtr->hIconSm : classPtr->hIconSmIntern;
1288 wc->hCursor = classPtr->hCursor;
1289 wc->hbrBackground = classPtr->hbrBackground;
1290 wc->lpszMenuName = CLASS_GetMenuNameA( classPtr );
1291 wc->lpszClassName = name;
1292 atom = classPtr->atomName;
1293 release_class_ptr( classPtr );
1295 /* We must return the atom of the class here instead of just TRUE. */
1296 return atom;
1300 /***********************************************************************
1301 * GetClassInfoExW (USER32.@)
1303 BOOL WINAPI GetClassInfoExW( HINSTANCE hInstance, LPCWSTR name, WNDCLASSEXW *wc )
1305 ATOM atom;
1306 CLASS *classPtr;
1308 TRACE("%p %s %p\n", hInstance, debugstr_w(name), wc);
1310 if (!wc)
1312 SetLastError( ERROR_NOACCESS );
1313 return FALSE;
1316 if (!hInstance) hInstance = user32_module;
1318 if (!(classPtr = CLASS_FindClass( name, hInstance )))
1320 SetLastError( ERROR_CLASS_DOES_NOT_EXIST );
1321 return FALSE;
1323 wc->style = classPtr->style;
1324 wc->lpfnWndProc = WINPROC_GetProc( classPtr->winproc, TRUE );
1325 wc->cbClsExtra = classPtr->cbClsExtra;
1326 wc->cbWndExtra = classPtr->cbWndExtra;
1327 wc->hInstance = (hInstance == user32_module) ? 0 : hInstance;
1328 wc->hIcon = classPtr->hIcon;
1329 wc->hIconSm = classPtr->hIconSm ? classPtr->hIconSm : classPtr->hIconSmIntern;
1330 wc->hCursor = classPtr->hCursor;
1331 wc->hbrBackground = classPtr->hbrBackground;
1332 wc->lpszMenuName = CLASS_GetMenuNameW( classPtr );
1333 wc->lpszClassName = name;
1334 atom = classPtr->atomName;
1335 release_class_ptr( classPtr );
1337 /* We must return the atom of the class here instead of just TRUE. */
1338 return atom;
1342 #if 0 /* toolhelp is in kernel, so this cannot work */
1344 /***********************************************************************
1345 * ClassFirst (TOOLHELP.69)
1347 BOOL16 WINAPI ClassFirst16( CLASSENTRY *pClassEntry )
1349 TRACE("%p\n",pClassEntry);
1350 pClassEntry->wNext = 1;
1351 return ClassNext16( pClassEntry );
1355 /***********************************************************************
1356 * ClassNext (TOOLHELP.70)
1358 BOOL16 WINAPI ClassNext16( CLASSENTRY *pClassEntry )
1360 int i;
1361 CLASS *class = firstClass;
1363 TRACE("%p\n",pClassEntry);
1365 if (!pClassEntry->wNext) return FALSE;
1366 for (i = 1; (i < pClassEntry->wNext) && class; i++) class = class->next;
1367 if (!class)
1369 pClassEntry->wNext = 0;
1370 return FALSE;
1372 pClassEntry->hInst = class->hInstance;
1373 pClassEntry->wNext++;
1374 GlobalGetAtomNameA( class->atomName, pClassEntry->szClassName,
1375 sizeof(pClassEntry->szClassName) );
1376 return TRUE;
1378 #endif
1380 /* 64bit versions */
1382 #ifdef GetClassLongPtrA
1383 #undef GetClassLongPtrA
1384 #endif
1386 #ifdef GetClassLongPtrW
1387 #undef GetClassLongPtrW
1388 #endif
1390 #ifdef SetClassLongPtrA
1391 #undef SetClassLongPtrA
1392 #endif
1394 #ifdef SetClassLongPtrW
1395 #undef SetClassLongPtrW
1396 #endif
1398 /***********************************************************************
1399 * GetClassLongPtrA (USER32.@)
1401 ULONG_PTR WINAPI GetClassLongPtrA( HWND hwnd, INT offset )
1403 return CLASS_GetClassLong( hwnd, offset, sizeof(ULONG_PTR), FALSE );
1406 /***********************************************************************
1407 * GetClassLongPtrW (USER32.@)
1409 ULONG_PTR WINAPI GetClassLongPtrW( HWND hwnd, INT offset )
1411 return CLASS_GetClassLong( hwnd, offset, sizeof(ULONG_PTR), TRUE );
1414 /***********************************************************************
1415 * SetClassLongPtrW (USER32.@)
1417 ULONG_PTR WINAPI SetClassLongPtrW( HWND hwnd, INT offset, LONG_PTR newval )
1419 return CLASS_SetClassLong( hwnd, offset, newval, sizeof(LONG_PTR), TRUE );
1422 /***********************************************************************
1423 * SetClassLongPtrA (USER32.@)
1425 ULONG_PTR WINAPI SetClassLongPtrA( HWND hwnd, INT offset, LONG_PTR newval )
1427 return CLASS_SetClassLong( hwnd, offset, newval, sizeof(LONG_PTR), FALSE );