user32: Don't wait for other threads to process WM_NCDESTROY.
[wine.git] / dlls / user32 / class.c
blobd4e7951d3953eb2e84d672b701b03b782e021250
1 /*
2 * Window classes functions
4 * Copyright 1993, 1996, 2003 Alexandre Julliard
5 * Copyright 1998 Juergen Schmied (jsch)
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include "config.h"
23 #include "wine/port.h"
25 #include <assert.h>
26 #include <stdarg.h>
27 #include <stdlib.h>
28 #include <string.h>
30 #include "winerror.h"
31 #include "windef.h"
32 #include "winbase.h"
33 #include "wingdi.h"
34 #include "wine/unicode.h"
35 #include "win.h"
36 #include "user_private.h"
37 #include "controls.h"
38 #include "wine/server.h"
39 #include "wine/list.h"
40 #include "wine/debug.h"
42 WINE_DEFAULT_DEBUG_CHANNEL(class);
44 #define MAX_ATOM_LEN 255 /* from dlls/kernel32/atom.c */
46 typedef struct tagCLASS
48 struct list entry; /* Entry in class list */
49 UINT style; /* Class style */
50 BOOL local; /* Local class? */
51 WNDPROC winproc; /* Window procedure */
52 INT cbClsExtra; /* Class extra bytes */
53 INT cbWndExtra; /* Window extra bytes */
54 LPWSTR menuName; /* Default menu name (Unicode followed by ASCII) */
55 struct dce *dce; /* Opaque pointer to class DCE */
56 HINSTANCE hInstance; /* Module that created the task */
57 HICON hIcon; /* Default icon */
58 HICON hIconSm; /* Default small icon */
59 HICON hIconSmIntern; /* Internal small icon, derived from hIcon */
60 HCURSOR hCursor; /* Default cursor */
61 HBRUSH hbrBackground; /* Default background */
62 ATOM atomName; /* Name of the class */
63 WCHAR name[MAX_ATOM_LEN + 1];
64 WCHAR *basename; /* Base name for redirected classes, pointer within 'name'. */
65 } CLASS;
67 static struct list class_list = LIST_INIT( class_list );
68 static INIT_ONCE init_once = INIT_ONCE_STATIC_INIT;
70 #define CLASS_OTHER_PROCESS ((CLASS *)1)
72 /***********************************************************************
73 * get_class_ptr
75 static CLASS *get_class_ptr( HWND hwnd, BOOL write_access )
77 WND *ptr = WIN_GetPtr( hwnd );
79 if (ptr)
81 if (ptr != WND_OTHER_PROCESS && ptr != WND_DESKTOP) return ptr->class;
82 if (!write_access) return CLASS_OTHER_PROCESS;
84 /* modifying classes in other processes is not allowed */
85 if (ptr == WND_DESKTOP || IsWindow( hwnd ))
87 SetLastError( ERROR_ACCESS_DENIED );
88 return NULL;
91 SetLastError( ERROR_INVALID_WINDOW_HANDLE );
92 return NULL;
96 /***********************************************************************
97 * release_class_ptr
99 static inline void release_class_ptr( CLASS *ptr )
101 USER_Unlock();
105 /***********************************************************************
106 * get_int_atom_value
108 ATOM get_int_atom_value( LPCWSTR name )
110 UINT ret = 0;
112 if (IS_INTRESOURCE(name)) return LOWORD(name);
113 if (*name++ != '#') return 0;
114 while (*name)
116 if (*name < '0' || *name > '9') return 0;
117 ret = ret * 10 + *name++ - '0';
118 if (ret > 0xffff) return 0;
120 return ret;
124 /***********************************************************************
125 * is_comctl32_class
127 static BOOL is_comctl32_class( const WCHAR *name )
129 static const WCHAR classesW[][20] =
131 {'C','o','m','b','o','B','o','x','E','x','3','2',0},
132 {'m','s','c','t','l','s','_','h','o','t','k','e','y','3','2',0},
133 {'m','s','c','t','l','s','_','p','r','o','g','r','e','s','s','3','2',0},
134 {'m','s','c','t','l','s','_','s','t','a','t','u','s','b','a','r','3','2',0},
135 {'m','s','c','t','l','s','_','t','r','a','c','k','b','a','r','3','2',0},
136 {'m','s','c','t','l','s','_','u','p','d','o','w','n','3','2',0},
137 {'N','a','t','i','v','e','F','o','n','t','C','t','l',0},
138 {'R','e','B','a','r','W','i','n','d','o','w','3','2',0},
139 {'S','y','s','A','n','i','m','a','t','e','3','2',0},
140 {'S','y','s','D','a','t','e','T','i','m','e','P','i','c','k','3','2',0},
141 {'S','y','s','H','e','a','d','e','r','3','2',0},
142 {'S','y','s','I','P','A','d','d','r','e','s','s','3','2',0},
143 {'S','y','s','L','i','n','k',0},
144 {'S','y','s','L','i','s','t','V','i','e','w','3','2',0},
145 {'S','y','s','M','o','n','t','h','C','a','l','3','2',0},
146 {'S','y','s','P','a','g','e','r',0},
147 {'S','y','s','T','a','b','C','o','n','t','r','o','l','3','2',0},
148 {'S','y','s','T','r','e','e','V','i','e','w','3','2',0},
149 {'T','o','o','l','b','a','r','W','i','n','d','o','w','3','2',0},
150 {'t','o','o','l','t','i','p','s','_','c','l','a','s','s','3','2',0},
153 int min = 0, max = ARRAY_SIZE( classesW ) - 1;
155 while (min <= max)
157 int res, pos = (min + max) / 2;
158 if (!(res = strcmpiW( name, classesW[pos] ))) return TRUE;
159 if (res < 0) max = pos - 1;
160 else min = pos + 1;
162 return FALSE;
165 static BOOL is_builtin_class( const WCHAR *name )
167 static const WCHAR classesW[][20] =
169 {'I','M','E',0},
170 {'M','D','I','C','l','i','e','n','t',0},
171 {'S','c','r','o','l','l','b','a','r',0},
174 int min = 0, max = ARRAY_SIZE( classesW ) - 1;
176 while (min <= max)
178 int res, pos = (min + max) / 2;
179 if (!(res = strcmpiW( name, classesW[pos] ))) return TRUE;
180 if (res < 0) max = pos - 1;
181 else min = pos + 1;
183 return FALSE;
186 /***********************************************************************
187 * set_server_info
189 * Set class info with the wine server.
191 static BOOL set_server_info( HWND hwnd, INT offset, LONG_PTR newval, UINT size )
193 BOOL ret;
195 SERVER_START_REQ( set_class_info )
197 req->window = wine_server_user_handle( hwnd );
198 req->extra_offset = -1;
199 switch(offset)
201 case GCW_ATOM:
202 req->flags = SET_CLASS_ATOM;
203 req->atom = LOWORD(newval);
204 break;
205 case GCL_STYLE:
206 req->flags = SET_CLASS_STYLE;
207 req->style = newval;
208 break;
209 case GCL_CBWNDEXTRA:
210 req->flags = SET_CLASS_WINEXTRA;
211 req->win_extra = newval;
212 break;
213 case GCLP_HMODULE:
214 req->flags = SET_CLASS_INSTANCE;
215 req->instance = wine_server_client_ptr( (void *)newval );
216 break;
217 default:
218 assert( offset >= 0 );
219 req->flags = SET_CLASS_EXTRA;
220 req->extra_offset = offset;
221 req->extra_size = size;
222 if ( size == sizeof(LONG) )
224 LONG newlong = newval;
225 memcpy( &req->extra_value, &newlong, sizeof(LONG) );
227 else
228 memcpy( &req->extra_value, &newval, sizeof(LONG_PTR) );
229 break;
231 ret = !wine_server_call_err( req );
233 SERVER_END_REQ;
234 return ret;
238 /***********************************************************************
239 * CLASS_GetMenuNameA
241 * Get the menu name as a ASCII string.
243 static inline LPSTR CLASS_GetMenuNameA( CLASS *classPtr )
245 if (IS_INTRESOURCE(classPtr->menuName)) return (LPSTR)classPtr->menuName;
246 return (LPSTR)(classPtr->menuName + strlenW(classPtr->menuName) + 1);
250 /***********************************************************************
251 * CLASS_GetMenuNameW
253 * Get the menu name as a Unicode string.
255 static inline LPWSTR CLASS_GetMenuNameW( CLASS *classPtr )
257 return classPtr->menuName;
261 /***********************************************************************
262 * CLASS_SetMenuNameA
264 * Set the menu name in a class structure by copying the string.
266 static void CLASS_SetMenuNameA( CLASS *classPtr, LPCSTR name )
268 if (!IS_INTRESOURCE(classPtr->menuName)) HeapFree( GetProcessHeap(), 0, classPtr->menuName );
269 if (!IS_INTRESOURCE(name))
271 DWORD lenA = strlen(name) + 1;
272 DWORD lenW = MultiByteToWideChar( CP_ACP, 0, name, lenA, NULL, 0 );
273 classPtr->menuName = HeapAlloc( GetProcessHeap(), 0, lenA + lenW*sizeof(WCHAR) );
274 MultiByteToWideChar( CP_ACP, 0, name, lenA, classPtr->menuName, lenW );
275 memcpy( classPtr->menuName + lenW, name, lenA );
277 else classPtr->menuName = (LPWSTR)name;
281 /***********************************************************************
282 * CLASS_SetMenuNameW
284 * Set the menu name in a class structure by copying the string.
286 static void CLASS_SetMenuNameW( CLASS *classPtr, LPCWSTR name )
288 if (!IS_INTRESOURCE(classPtr->menuName)) HeapFree( GetProcessHeap(), 0, classPtr->menuName );
289 if (!IS_INTRESOURCE(name))
291 DWORD lenW = strlenW(name) + 1;
292 DWORD lenA = WideCharToMultiByte( CP_ACP, 0, name, lenW, NULL, 0, NULL, NULL );
293 classPtr->menuName = HeapAlloc( GetProcessHeap(), 0, lenA + lenW*sizeof(WCHAR) );
294 memcpy( classPtr->menuName, name, lenW*sizeof(WCHAR) );
295 WideCharToMultiByte( CP_ACP, 0, name, lenW,
296 (char *)(classPtr->menuName + lenW), lenA, NULL, NULL );
298 else classPtr->menuName = (LPWSTR)name;
302 /***********************************************************************
303 * CLASS_FreeClass
305 * Free a class structure.
307 static void CLASS_FreeClass( CLASS *classPtr )
309 TRACE("%p\n", classPtr);
311 USER_Lock();
313 if (classPtr->dce) free_dce( classPtr->dce, 0 );
314 list_remove( &classPtr->entry );
315 if (classPtr->hbrBackground > (HBRUSH)(COLOR_GRADIENTINACTIVECAPTION + 1))
316 DeleteObject( classPtr->hbrBackground );
317 DestroyIcon( classPtr->hIconSmIntern );
318 HeapFree( GetProcessHeap(), 0, classPtr->menuName );
319 HeapFree( GetProcessHeap(), 0, classPtr );
320 USER_Unlock();
323 const WCHAR *CLASS_GetVersionedName( const WCHAR *name, UINT *basename_offset, BOOL register_class )
325 ACTCTX_SECTION_KEYED_DATA data;
326 struct wndclass_redirect_data
328 ULONG size;
329 DWORD res;
330 ULONG name_len;
331 ULONG name_offset;
332 ULONG module_len;
333 ULONG module_offset;
334 } *wndclass;
335 const WCHAR *module, *ret;
336 HMODULE hmod;
338 if (basename_offset)
339 *basename_offset = 0;
341 if (IS_INTRESOURCE( name ))
342 return name;
344 if (is_comctl32_class( name ) || is_builtin_class( name ))
345 return name;
347 data.cbSize = sizeof(data);
348 if (!FindActCtxSectionStringW(0, NULL, ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION, name, &data))
349 return name;
351 wndclass = (struct wndclass_redirect_data *)data.lpData;
352 if (basename_offset)
353 *basename_offset = wndclass->name_len / sizeof(WCHAR) - strlenW(name);
355 module = (const WCHAR *)((BYTE *)data.lpSectionBase + wndclass->module_offset);
356 if (!(hmod = GetModuleHandleW( module )))
357 hmod = LoadLibraryW( module );
359 ret = (const WCHAR *)((BYTE *)wndclass + wndclass->name_offset);
361 if (register_class && hmod)
363 BOOL found = FALSE;
364 struct list *ptr;
366 USER_Lock();
368 LIST_FOR_EACH( ptr, &class_list )
370 CLASS *class = LIST_ENTRY( ptr, CLASS, entry );
371 if (strcmpiW( class->name, ret )) continue;
372 if (!class->local || class->hInstance == hmod)
374 found = TRUE;
375 break;
379 USER_Unlock();
381 if (!found)
383 BOOL (WINAPI *pRegisterClassNameW)(const WCHAR *class);
385 pRegisterClassNameW = (void *)GetProcAddress(hmod, "RegisterClassNameW");
386 if (pRegisterClassNameW)
387 pRegisterClassNameW(name);
391 return ret;
394 /***********************************************************************
395 * CLASS_FindClass
397 * Return a pointer to the class.
399 static CLASS *CLASS_FindClass( LPCWSTR name, HINSTANCE hinstance )
401 static const WCHAR comctl32W[] = {'c','o','m','c','t','l','3','2','.','d','l','l',0};
402 struct list *ptr;
403 ATOM atom = get_int_atom_value( name );
405 GetDesktopWindow(); /* create the desktop window to trigger builtin class registration */
407 if (!name) return NULL;
409 name = CLASS_GetVersionedName( name, NULL, TRUE );
411 for (;;)
413 USER_Lock();
415 LIST_FOR_EACH( ptr, &class_list )
417 CLASS *class = LIST_ENTRY( ptr, CLASS, entry );
418 if (atom)
420 if (class->atomName != atom) continue;
422 else
424 if (strcmpiW( class->name, name )) continue;
426 if (!class->local || class->hInstance == hinstance)
428 TRACE("%s %p -> %p\n", debugstr_w(name), hinstance, class);
429 return class;
432 USER_Unlock();
434 if (atom) break;
435 if (!is_comctl32_class( name )) break;
436 if (GetModuleHandleW( comctl32W )) break;
437 if (!LoadLibraryW( comctl32W )) break;
438 TRACE( "%s retrying after loading comctl32\n", debugstr_w(name) );
441 TRACE("%s %p -> not found\n", debugstr_w(name), hinstance);
442 return NULL;
445 /***********************************************************************
446 * CLASS_RegisterClass
448 * The real RegisterClass() functionality.
450 static CLASS *CLASS_RegisterClass( LPCWSTR name, UINT basename_offset, HINSTANCE hInstance, BOOL local,
451 DWORD style, INT classExtra, INT winExtra )
453 CLASS *classPtr;
454 BOOL ret;
456 TRACE("name=%s hinst=%p style=0x%x clExtr=0x%x winExtr=0x%x\n",
457 debugstr_w(name), hInstance, style, classExtra, winExtra );
459 /* Fix the extra bytes value */
461 if (classExtra > 40) /* Extra bytes are limited to 40 in Win32 */
462 WARN("Class extra bytes %d is > 40\n", classExtra);
463 if (winExtra > 40) /* Extra bytes are limited to 40 in Win32 */
464 WARN("Win extra bytes %d is > 40\n", winExtra );
466 classPtr = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(CLASS) + classExtra );
467 if (!classPtr) return NULL;
469 classPtr->atomName = get_int_atom_value( name );
470 classPtr->basename = classPtr->name;
471 if (!classPtr->atomName && name)
473 strcpyW( classPtr->name, name );
474 classPtr->basename += basename_offset;
476 else GlobalGetAtomNameW( classPtr->atomName, classPtr->name, ARRAY_SIZE( classPtr->name ));
478 SERVER_START_REQ( create_class )
480 req->local = local;
481 req->style = style;
482 req->instance = wine_server_client_ptr( hInstance );
483 req->extra = classExtra;
484 req->win_extra = winExtra;
485 req->client_ptr = wine_server_client_ptr( classPtr );
486 req->atom = classPtr->atomName;
487 if (!req->atom && name) wine_server_add_data( req, name, strlenW(name) * sizeof(WCHAR) );
488 ret = !wine_server_call_err( req );
489 classPtr->atomName = reply->atom;
491 SERVER_END_REQ;
492 if (!ret)
494 HeapFree( GetProcessHeap(), 0, classPtr );
495 return NULL;
498 classPtr->style = style;
499 classPtr->local = local;
500 classPtr->cbWndExtra = winExtra;
501 classPtr->cbClsExtra = classExtra;
502 classPtr->hInstance = hInstance;
504 /* Other non-null values must be set by caller */
506 USER_Lock();
507 if (local) list_add_head( &class_list, &classPtr->entry );
508 else list_add_tail( &class_list, &classPtr->entry );
509 return classPtr;
513 /***********************************************************************
514 * register_builtin
516 * Register a builtin control class.
517 * This allows having both ASCII and Unicode winprocs for the same class.
519 static void register_builtin( const struct builtin_class_descr *descr )
521 CLASS *classPtr;
523 if (!(classPtr = CLASS_RegisterClass( descr->name, 0, user32_module, FALSE,
524 descr->style, 0, descr->extra ))) return;
526 if (descr->cursor) classPtr->hCursor = LoadCursorA( 0, (LPSTR)descr->cursor );
527 classPtr->hbrBackground = descr->brush;
528 classPtr->winproc = BUILTIN_WINPROC( descr->proc );
529 release_class_ptr( classPtr );
533 /***********************************************************************
534 * register_builtins
536 static BOOL WINAPI register_builtins( INIT_ONCE *once, void *param, void **context )
538 register_builtin( &BUTTON_builtin_class );
539 register_builtin( &COMBO_builtin_class );
540 register_builtin( &COMBOLBOX_builtin_class );
541 register_builtin( &DIALOG_builtin_class );
542 register_builtin( &EDIT_builtin_class );
543 register_builtin( &ICONTITLE_builtin_class );
544 register_builtin( &LISTBOX_builtin_class );
545 register_builtin( &MDICLIENT_builtin_class );
546 register_builtin( &MENU_builtin_class );
547 register_builtin( &SCROLL_builtin_class );
548 register_builtin( &STATIC_builtin_class );
549 register_builtin( &IME_builtin_class );
550 return TRUE;
554 /***********************************************************************
555 * register_builtin_classes
557 void register_builtin_classes(void)
559 InitOnceExecuteOnce( &init_once, register_builtins, NULL, NULL );
563 /***********************************************************************
564 * register_desktop_class
566 void register_desktop_class(void)
568 register_builtin( &DESKTOP_builtin_class );
569 register_builtin( &MESSAGE_builtin_class );
573 /***********************************************************************
574 * get_class_winproc
576 WNDPROC get_class_winproc( CLASS *class )
578 return class->winproc;
582 /***********************************************************************
583 * get_class_dce
585 struct dce *get_class_dce( CLASS *class )
587 return class->dce;
591 /***********************************************************************
592 * set_class_dce
594 struct dce *set_class_dce( CLASS *class, struct dce *dce )
596 if (class->dce) return class->dce; /* already set, don't change it */
597 class->dce = dce;
598 return dce;
602 /***********************************************************************
603 * RegisterClassA (USER32.@)
605 * Register a window class.
607 * RETURNS
608 * >0: Unique identifier
609 * 0: Failure
611 ATOM WINAPI RegisterClassA( const WNDCLASSA* wc ) /* [in] Address of structure with class data */
613 WNDCLASSEXA wcex;
615 wcex.cbSize = sizeof(wcex);
616 wcex.style = wc->style;
617 wcex.lpfnWndProc = wc->lpfnWndProc;
618 wcex.cbClsExtra = wc->cbClsExtra;
619 wcex.cbWndExtra = wc->cbWndExtra;
620 wcex.hInstance = wc->hInstance;
621 wcex.hIcon = wc->hIcon;
622 wcex.hCursor = wc->hCursor;
623 wcex.hbrBackground = wc->hbrBackground;
624 wcex.lpszMenuName = wc->lpszMenuName;
625 wcex.lpszClassName = wc->lpszClassName;
626 wcex.hIconSm = 0;
627 return RegisterClassExA( &wcex );
631 /***********************************************************************
632 * RegisterClassW (USER32.@)
634 * See RegisterClassA.
636 ATOM WINAPI RegisterClassW( const WNDCLASSW* wc )
638 WNDCLASSEXW wcex;
640 wcex.cbSize = sizeof(wcex);
641 wcex.style = wc->style;
642 wcex.lpfnWndProc = wc->lpfnWndProc;
643 wcex.cbClsExtra = wc->cbClsExtra;
644 wcex.cbWndExtra = wc->cbWndExtra;
645 wcex.hInstance = wc->hInstance;
646 wcex.hIcon = wc->hIcon;
647 wcex.hCursor = wc->hCursor;
648 wcex.hbrBackground = wc->hbrBackground;
649 wcex.lpszMenuName = wc->lpszMenuName;
650 wcex.lpszClassName = wc->lpszClassName;
651 wcex.hIconSm = 0;
652 return RegisterClassExW( &wcex );
656 /***********************************************************************
657 * RegisterClassExA (USER32.@)
659 ATOM WINAPI RegisterClassExA( const WNDCLASSEXA* wc )
661 const WCHAR *classname = NULL;
662 WCHAR name[MAX_ATOM_LEN + 1];
663 ATOM atom;
664 CLASS *classPtr;
665 HINSTANCE instance;
667 GetDesktopWindow(); /* create the desktop window to trigger builtin class registration */
669 if (wc->cbSize != sizeof(*wc) || wc->cbClsExtra < 0 || wc->cbWndExtra < 0 ||
670 wc->hInstance == user32_module) /* we can't register a class for user32 */
672 SetLastError( ERROR_INVALID_PARAMETER );
673 return 0;
675 if (!(instance = wc->hInstance)) instance = GetModuleHandleW( NULL );
677 if (!IS_INTRESOURCE(wc->lpszClassName))
679 UINT basename_offset;
680 if (!MultiByteToWideChar( CP_ACP, 0, wc->lpszClassName, -1, name, MAX_ATOM_LEN + 1 )) return 0;
681 classname = CLASS_GetVersionedName( name, &basename_offset, FALSE );
682 classPtr = CLASS_RegisterClass( classname, basename_offset, instance, !(wc->style & CS_GLOBALCLASS),
683 wc->style, wc->cbClsExtra, wc->cbWndExtra );
685 else
687 classPtr = CLASS_RegisterClass( (LPCWSTR)wc->lpszClassName, 0, instance,
688 !(wc->style & CS_GLOBALCLASS), wc->style,
689 wc->cbClsExtra, wc->cbWndExtra );
691 if (!classPtr) return 0;
692 atom = classPtr->atomName;
694 TRACE("name=%s%s%s atom=%04x wndproc=%p hinst=%p bg=%p style=%08x clsExt=%d winExt=%d class=%p\n",
695 debugstr_a(wc->lpszClassName), classname != name ? "->" : "", classname != name ? debugstr_w(classname) : "",
696 atom, wc->lpfnWndProc, instance, wc->hbrBackground, wc->style, wc->cbClsExtra, wc->cbWndExtra, classPtr );
698 classPtr->hIcon = wc->hIcon;
699 classPtr->hIconSm = wc->hIconSm;
700 classPtr->hIconSmIntern = wc->hIcon && !wc->hIconSm ?
701 CopyImage( wc->hIcon, IMAGE_ICON,
702 GetSystemMetrics( SM_CXSMICON ),
703 GetSystemMetrics( SM_CYSMICON ),
704 LR_COPYFROMRESOURCE ) : NULL;
705 classPtr->hCursor = wc->hCursor;
706 classPtr->hbrBackground = wc->hbrBackground;
707 classPtr->winproc = WINPROC_AllocProc( wc->lpfnWndProc, FALSE );
708 CLASS_SetMenuNameA( classPtr, wc->lpszMenuName );
709 release_class_ptr( classPtr );
710 return atom;
714 /***********************************************************************
715 * RegisterClassExW (USER32.@)
717 ATOM WINAPI RegisterClassExW( const WNDCLASSEXW* wc )
719 const WCHAR *classname;
720 UINT basename_offset;
721 ATOM atom;
722 CLASS *classPtr;
723 HINSTANCE instance;
725 GetDesktopWindow(); /* create the desktop window to trigger builtin class registration */
727 if (wc->cbSize != sizeof(*wc) || wc->cbClsExtra < 0 || wc->cbWndExtra < 0 ||
728 wc->hInstance == user32_module) /* we can't register a class for user32 */
730 SetLastError( ERROR_INVALID_PARAMETER );
731 return 0;
733 if (!(instance = wc->hInstance)) instance = GetModuleHandleW( NULL );
735 classname = CLASS_GetVersionedName( wc->lpszClassName, &basename_offset, FALSE );
736 if (!(classPtr = CLASS_RegisterClass( classname, basename_offset, instance, !(wc->style & CS_GLOBALCLASS),
737 wc->style, wc->cbClsExtra, wc->cbWndExtra )))
738 return 0;
740 atom = classPtr->atomName;
742 TRACE("name=%s%s%s atom=%04x wndproc=%p hinst=%p bg=%p style=%08x clsExt=%d winExt=%d class=%p\n",
743 debugstr_w(wc->lpszClassName), classname != wc->lpszClassName ? "->" : "",
744 classname != wc->lpszClassName ? debugstr_w(classname) : "", atom, wc->lpfnWndProc, instance,
745 wc->hbrBackground, wc->style, wc->cbClsExtra, wc->cbWndExtra, classPtr );
747 classPtr->hIcon = wc->hIcon;
748 classPtr->hIconSm = wc->hIconSm;
749 classPtr->hIconSmIntern = wc->hIcon && !wc->hIconSm ?
750 CopyImage( wc->hIcon, IMAGE_ICON,
751 GetSystemMetrics( SM_CXSMICON ),
752 GetSystemMetrics( SM_CYSMICON ),
753 LR_COPYFROMRESOURCE ) : NULL;
754 classPtr->hCursor = wc->hCursor;
755 classPtr->hbrBackground = wc->hbrBackground;
756 classPtr->winproc = WINPROC_AllocProc( wc->lpfnWndProc, TRUE );
757 CLASS_SetMenuNameW( classPtr, wc->lpszMenuName );
758 release_class_ptr( classPtr );
759 return atom;
763 /***********************************************************************
764 * UnregisterClassA (USER32.@)
766 BOOL WINAPI UnregisterClassA( LPCSTR className, HINSTANCE hInstance )
768 if (!IS_INTRESOURCE(className))
770 WCHAR name[MAX_ATOM_LEN + 1];
772 if (!MultiByteToWideChar( CP_ACP, 0, className, -1, name, MAX_ATOM_LEN + 1 ))
773 return FALSE;
774 return UnregisterClassW( name, hInstance );
776 return UnregisterClassW( (LPCWSTR)className, hInstance );
779 /***********************************************************************
780 * UnregisterClassW (USER32.@)
782 BOOL WINAPI UnregisterClassW( LPCWSTR className, HINSTANCE hInstance )
784 CLASS *classPtr = NULL;
786 GetDesktopWindow(); /* create the desktop window to trigger builtin class registration */
788 className = CLASS_GetVersionedName( className, NULL, FALSE );
789 SERVER_START_REQ( destroy_class )
791 req->instance = wine_server_client_ptr( hInstance );
792 if (!(req->atom = get_int_atom_value(className)) && className)
793 wine_server_add_data( req, className, strlenW(className) * sizeof(WCHAR) );
794 if (!wine_server_call_err( req )) classPtr = wine_server_get_ptr( reply->client_ptr );
796 SERVER_END_REQ;
798 if (classPtr) CLASS_FreeClass( classPtr );
799 return (classPtr != NULL);
803 /***********************************************************************
804 * GetClassWord (USER32.@)
806 WORD WINAPI GetClassWord( HWND hwnd, INT offset )
808 CLASS *class;
809 WORD retvalue = 0;
811 if (offset < 0) return GetClassLongA( hwnd, offset );
813 if (!(class = get_class_ptr( hwnd, FALSE ))) return 0;
815 if (class == CLASS_OTHER_PROCESS)
817 SERVER_START_REQ( set_class_info )
819 req->window = wine_server_user_handle( hwnd );
820 req->flags = 0;
821 req->extra_offset = offset;
822 req->extra_size = sizeof(retvalue);
823 if (!wine_server_call_err( req ))
824 memcpy( &retvalue, &reply->old_extra_value, sizeof(retvalue) );
826 SERVER_END_REQ;
827 return retvalue;
830 if (offset <= class->cbClsExtra - sizeof(WORD))
831 memcpy( &retvalue, (char *)(class + 1) + offset, sizeof(retvalue) );
832 else
833 SetLastError( ERROR_INVALID_INDEX );
834 release_class_ptr( class );
835 return retvalue;
839 /***********************************************************************
840 * CLASS_GetClassLong
842 * Implementation of GetClassLong(Ptr)A/W
844 static ULONG_PTR CLASS_GetClassLong( HWND hwnd, INT offset, UINT size,
845 BOOL unicode )
847 CLASS *class;
848 ULONG_PTR retvalue = 0;
850 if (!(class = get_class_ptr( hwnd, FALSE ))) return 0;
852 if (class == CLASS_OTHER_PROCESS)
854 SERVER_START_REQ( set_class_info )
856 req->window = wine_server_user_handle( hwnd );
857 req->flags = 0;
858 req->extra_offset = (offset >= 0) ? offset : -1;
859 req->extra_size = (offset >= 0) ? size : 0;
860 if (!wine_server_call_err( req ))
862 switch(offset)
864 case GCLP_HBRBACKGROUND:
865 case GCLP_HCURSOR:
866 case GCLP_HICON:
867 case GCLP_HICONSM:
868 case GCLP_WNDPROC:
869 case GCLP_MENUNAME:
870 FIXME( "offset %d (%s) not supported on other process window %p\n",
871 offset, SPY_GetClassLongOffsetName(offset), hwnd );
872 SetLastError( ERROR_INVALID_HANDLE );
873 break;
874 case GCL_STYLE:
875 retvalue = reply->old_style;
876 break;
877 case GCL_CBWNDEXTRA:
878 retvalue = reply->old_win_extra;
879 break;
880 case GCL_CBCLSEXTRA:
881 retvalue = reply->old_extra;
882 break;
883 case GCLP_HMODULE:
884 retvalue = (ULONG_PTR)wine_server_get_ptr( reply->old_instance );
885 break;
886 case GCW_ATOM:
887 retvalue = reply->old_atom;
888 break;
889 default:
890 if (offset >= 0)
892 if (size == sizeof(DWORD))
894 DWORD retdword;
895 memcpy( &retdword, &reply->old_extra_value, sizeof(DWORD) );
896 retvalue = retdword;
898 else
899 memcpy( &retvalue, &reply->old_extra_value,
900 sizeof(ULONG_PTR) );
902 else SetLastError( ERROR_INVALID_INDEX );
903 break;
907 SERVER_END_REQ;
908 return retvalue;
911 if (offset >= 0)
913 if (offset <= class->cbClsExtra - size)
915 if (size == sizeof(DWORD))
917 DWORD retdword;
918 memcpy( &retdword, (char *)(class + 1) + offset, sizeof(DWORD) );
919 retvalue = retdword;
921 else
922 memcpy( &retvalue, (char *)(class + 1) + offset, sizeof(ULONG_PTR) );
924 else
925 SetLastError( ERROR_INVALID_INDEX );
926 release_class_ptr( class );
927 return retvalue;
930 switch(offset)
932 case GCLP_HBRBACKGROUND:
933 retvalue = (ULONG_PTR)class->hbrBackground;
934 break;
935 case GCLP_HCURSOR:
936 retvalue = (ULONG_PTR)class->hCursor;
937 break;
938 case GCLP_HICON:
939 retvalue = (ULONG_PTR)class->hIcon;
940 break;
941 case GCLP_HICONSM:
942 retvalue = (ULONG_PTR)(class->hIconSm ? class->hIconSm : class->hIconSmIntern);
943 break;
944 case GCL_STYLE:
945 retvalue = class->style;
946 break;
947 case GCL_CBWNDEXTRA:
948 retvalue = class->cbWndExtra;
949 break;
950 case GCL_CBCLSEXTRA:
951 retvalue = class->cbClsExtra;
952 break;
953 case GCLP_HMODULE:
954 retvalue = (ULONG_PTR)class->hInstance;
955 break;
956 case GCLP_WNDPROC:
957 retvalue = (ULONG_PTR)WINPROC_GetProc( class->winproc, unicode );
958 break;
959 case GCLP_MENUNAME:
960 retvalue = (ULONG_PTR)CLASS_GetMenuNameW( class );
961 if (unicode)
962 retvalue = (ULONG_PTR)CLASS_GetMenuNameW( class );
963 else
964 retvalue = (ULONG_PTR)CLASS_GetMenuNameA( class );
965 break;
966 case GCW_ATOM:
967 retvalue = class->atomName;
968 break;
969 default:
970 SetLastError( ERROR_INVALID_INDEX );
971 break;
973 release_class_ptr( class );
974 return retvalue;
978 /***********************************************************************
979 * GetClassLongW (USER32.@)
981 DWORD WINAPI GetClassLongW( HWND hwnd, INT offset )
983 return CLASS_GetClassLong( hwnd, offset, sizeof(DWORD), TRUE );
988 /***********************************************************************
989 * GetClassLongA (USER32.@)
991 DWORD WINAPI GetClassLongA( HWND hwnd, INT offset )
993 return CLASS_GetClassLong( hwnd, offset, sizeof(DWORD), FALSE );
997 /***********************************************************************
998 * SetClassWord (USER32.@)
1000 WORD WINAPI SetClassWord( HWND hwnd, INT offset, WORD newval )
1002 CLASS *class;
1003 WORD retval = 0;
1005 if (offset < 0) return SetClassLongA( hwnd, offset, (DWORD)newval );
1007 if (!(class = get_class_ptr( hwnd, TRUE ))) return 0;
1009 SERVER_START_REQ( set_class_info )
1011 req->window = wine_server_user_handle( hwnd );
1012 req->flags = SET_CLASS_EXTRA;
1013 req->extra_offset = offset;
1014 req->extra_size = sizeof(newval);
1015 memcpy( &req->extra_value, &newval, sizeof(newval) );
1016 if (!wine_server_call_err( req ))
1018 void *ptr = (char *)(class + 1) + offset;
1019 memcpy( &retval, ptr, sizeof(retval) );
1020 memcpy( ptr, &newval, sizeof(newval) );
1023 SERVER_END_REQ;
1024 release_class_ptr( class );
1025 return retval;
1029 /***********************************************************************
1030 * CLASS_SetClassLong
1032 * Implementation of SetClassLong(Ptr)A/W
1034 static ULONG_PTR CLASS_SetClassLong( HWND hwnd, INT offset, LONG_PTR newval,
1035 UINT size, BOOL unicode )
1037 CLASS *class;
1038 ULONG_PTR retval = 0;
1040 if (!(class = get_class_ptr( hwnd, TRUE ))) return 0;
1042 if (offset >= 0)
1044 if (set_server_info( hwnd, offset, newval, size ))
1046 void *ptr = (char *)(class + 1) + offset;
1047 if ( size == sizeof(LONG) )
1049 DWORD retdword;
1050 LONG newlong = newval;
1051 memcpy( &retdword, ptr, sizeof(DWORD) );
1052 memcpy( ptr, &newlong, sizeof(LONG) );
1053 retval = retdword;
1055 else
1057 memcpy( &retval, ptr, sizeof(ULONG_PTR) );
1058 memcpy( ptr, &newval, sizeof(LONG_PTR) );
1062 else switch(offset)
1064 case GCLP_MENUNAME:
1065 if ( unicode )
1066 CLASS_SetMenuNameW( class, (LPCWSTR)newval );
1067 else
1068 CLASS_SetMenuNameA( class, (LPCSTR)newval );
1069 retval = 0; /* Old value is now meaningless anyway */
1070 break;
1071 case GCLP_WNDPROC:
1072 retval = (ULONG_PTR)WINPROC_GetProc( class->winproc, unicode );
1073 class->winproc = WINPROC_AllocProc( (WNDPROC)newval, unicode );
1074 break;
1075 case GCLP_HBRBACKGROUND:
1076 retval = (ULONG_PTR)class->hbrBackground;
1077 class->hbrBackground = (HBRUSH)newval;
1078 break;
1079 case GCLP_HCURSOR:
1080 retval = (ULONG_PTR)class->hCursor;
1081 class->hCursor = (HCURSOR)newval;
1082 break;
1083 case GCLP_HICON:
1084 retval = (ULONG_PTR)class->hIcon;
1085 if (class->hIconSmIntern)
1087 DestroyIcon(class->hIconSmIntern);
1088 class->hIconSmIntern = NULL;
1090 if (newval && !class->hIconSm)
1091 class->hIconSmIntern = CopyImage( (HICON)newval, IMAGE_ICON,
1092 GetSystemMetrics( SM_CXSMICON ), GetSystemMetrics( SM_CYSMICON ),
1093 LR_COPYFROMRESOURCE );
1094 class->hIcon = (HICON)newval;
1095 break;
1096 case GCLP_HICONSM:
1097 retval = (ULONG_PTR)class->hIconSm;
1098 if (retval && !newval && class->hIcon)
1099 class->hIconSmIntern = CopyImage( class->hIcon, IMAGE_ICON,
1100 GetSystemMetrics( SM_CXSMICON ), GetSystemMetrics( SM_CYSMICON ),
1101 LR_COPYFROMRESOURCE );
1102 else if (newval && class->hIconSmIntern)
1104 DestroyIcon(class->hIconSmIntern);
1105 class->hIconSmIntern = NULL;
1107 class->hIconSm = (HICON)newval;
1108 break;
1109 case GCL_STYLE:
1110 if (!set_server_info( hwnd, offset, newval, size )) break;
1111 retval = class->style;
1112 class->style = newval;
1113 break;
1114 case GCL_CBWNDEXTRA:
1115 if (!set_server_info( hwnd, offset, newval, size )) break;
1116 retval = class->cbWndExtra;
1117 class->cbWndExtra = newval;
1118 break;
1119 case GCLP_HMODULE:
1120 if (!set_server_info( hwnd, offset, newval, size )) break;
1121 retval = (ULONG_PTR)class->hInstance;
1122 class->hInstance = (HINSTANCE)newval;
1123 break;
1124 case GCW_ATOM:
1125 if (!set_server_info( hwnd, offset, newval, size )) break;
1126 retval = class->atomName;
1127 class->atomName = newval;
1128 GlobalGetAtomNameW( newval, class->name, ARRAY_SIZE( class->name ));
1129 break;
1130 case GCL_CBCLSEXTRA: /* cannot change this one */
1131 SetLastError( ERROR_INVALID_PARAMETER );
1132 break;
1133 default:
1134 SetLastError( ERROR_INVALID_INDEX );
1135 break;
1137 release_class_ptr( class );
1138 return retval;
1142 /***********************************************************************
1143 * SetClassLongW (USER32.@)
1145 DWORD WINAPI SetClassLongW( HWND hwnd, INT offset, LONG newval )
1147 return CLASS_SetClassLong( hwnd, offset, newval, sizeof(LONG), TRUE );
1151 /***********************************************************************
1152 * SetClassLongA (USER32.@)
1154 DWORD WINAPI SetClassLongA( HWND hwnd, INT offset, LONG newval )
1156 return CLASS_SetClassLong( hwnd, offset, newval, sizeof(LONG), FALSE );
1160 /***********************************************************************
1161 * GetClassNameA (USER32.@)
1163 INT WINAPI GetClassNameA( HWND hwnd, LPSTR buffer, INT count )
1165 WCHAR tmpbuf[MAX_ATOM_LEN + 1];
1166 DWORD len;
1168 if (count <= 0) return 0;
1169 if (!GetClassNameW( hwnd, tmpbuf, ARRAY_SIZE( tmpbuf ))) return 0;
1170 RtlUnicodeToMultiByteN( buffer, count - 1, &len, tmpbuf, strlenW(tmpbuf) * sizeof(WCHAR) );
1171 buffer[len] = 0;
1172 return len;
1176 /***********************************************************************
1177 * GetClassNameW (USER32.@)
1179 INT WINAPI GetClassNameW( HWND hwnd, LPWSTR buffer, INT count )
1181 CLASS *class;
1182 INT ret;
1184 TRACE("%p %p %d\n", hwnd, buffer, count);
1186 if (count <= 0) return 0;
1188 if (!(class = get_class_ptr( hwnd, FALSE ))) return 0;
1190 if (class == CLASS_OTHER_PROCESS)
1192 WCHAR tmpbuf[MAX_ATOM_LEN + 1];
1194 ret = GlobalGetAtomNameW( GetClassLongW( hwnd, GCW_ATOM ), tmpbuf, MAX_ATOM_LEN + 1 );
1195 if (ret)
1197 ret = min(count - 1, ret);
1198 memcpy(buffer, tmpbuf, ret * sizeof(WCHAR));
1199 buffer[ret] = 0;
1202 else
1204 /* Return original name class was registered with. */
1205 lstrcpynW( buffer, class->basename, count );
1206 release_class_ptr( class );
1207 ret = strlenW( buffer );
1209 return ret;
1213 /***********************************************************************
1214 * RealGetWindowClassA (USER32.@)
1216 UINT WINAPI RealGetWindowClassA( HWND hwnd, LPSTR buffer, UINT count )
1218 return GetClassNameA( hwnd, buffer, count );
1222 /***********************************************************************
1223 * RealGetWindowClassW (USER32.@)
1225 UINT WINAPI RealGetWindowClassW( HWND hwnd, LPWSTR buffer, UINT count )
1227 return GetClassNameW( hwnd, buffer, count );
1231 /***********************************************************************
1232 * GetClassInfoA (USER32.@)
1234 BOOL WINAPI GetClassInfoA( HINSTANCE hInstance, LPCSTR name, WNDCLASSA *wc )
1236 WNDCLASSEXA wcex;
1237 UINT ret = GetClassInfoExA( hInstance, name, &wcex );
1239 if (ret)
1241 wc->style = wcex.style;
1242 wc->lpfnWndProc = wcex.lpfnWndProc;
1243 wc->cbClsExtra = wcex.cbClsExtra;
1244 wc->cbWndExtra = wcex.cbWndExtra;
1245 wc->hInstance = wcex.hInstance;
1246 wc->hIcon = wcex.hIcon;
1247 wc->hCursor = wcex.hCursor;
1248 wc->hbrBackground = wcex.hbrBackground;
1249 wc->lpszMenuName = wcex.lpszMenuName;
1250 wc->lpszClassName = wcex.lpszClassName;
1252 return ret;
1256 /***********************************************************************
1257 * GetClassInfoW (USER32.@)
1259 BOOL WINAPI GetClassInfoW( HINSTANCE hInstance, LPCWSTR name, WNDCLASSW *wc )
1261 WNDCLASSEXW wcex;
1262 UINT ret = GetClassInfoExW( hInstance, name, &wcex );
1264 if (ret)
1266 wc->style = wcex.style;
1267 wc->lpfnWndProc = wcex.lpfnWndProc;
1268 wc->cbClsExtra = wcex.cbClsExtra;
1269 wc->cbWndExtra = wcex.cbWndExtra;
1270 wc->hInstance = wcex.hInstance;
1271 wc->hIcon = wcex.hIcon;
1272 wc->hCursor = wcex.hCursor;
1273 wc->hbrBackground = wcex.hbrBackground;
1274 wc->lpszMenuName = wcex.lpszMenuName;
1275 wc->lpszClassName = wcex.lpszClassName;
1277 return ret;
1281 /***********************************************************************
1282 * GetClassInfoExA (USER32.@)
1284 BOOL WINAPI GetClassInfoExA( HINSTANCE hInstance, LPCSTR name, WNDCLASSEXA *wc )
1286 ATOM atom;
1287 CLASS *classPtr;
1289 TRACE("%p %s %p\n", hInstance, debugstr_a(name), wc);
1291 if (!wc)
1293 SetLastError( ERROR_NOACCESS );
1294 return FALSE;
1297 if (!hInstance) hInstance = user32_module;
1299 if (!IS_INTRESOURCE(name))
1301 WCHAR nameW[MAX_ATOM_LEN + 1];
1302 if (!MultiByteToWideChar( CP_ACP, 0, name, -1, nameW, ARRAY_SIZE( nameW )))
1303 return FALSE;
1304 classPtr = CLASS_FindClass( nameW, hInstance );
1306 else classPtr = CLASS_FindClass( (LPCWSTR)name, hInstance );
1308 if (!classPtr)
1310 SetLastError( ERROR_CLASS_DOES_NOT_EXIST );
1311 return FALSE;
1313 wc->style = classPtr->style;
1314 wc->lpfnWndProc = WINPROC_GetProc( classPtr->winproc, FALSE );
1315 wc->cbClsExtra = classPtr->cbClsExtra;
1316 wc->cbWndExtra = classPtr->cbWndExtra;
1317 wc->hInstance = (hInstance == user32_module) ? 0 : hInstance;
1318 wc->hIcon = classPtr->hIcon;
1319 wc->hIconSm = classPtr->hIconSm ? classPtr->hIconSm : classPtr->hIconSmIntern;
1320 wc->hCursor = classPtr->hCursor;
1321 wc->hbrBackground = classPtr->hbrBackground;
1322 wc->lpszMenuName = CLASS_GetMenuNameA( classPtr );
1323 wc->lpszClassName = name;
1324 atom = classPtr->atomName;
1325 release_class_ptr( classPtr );
1327 /* We must return the atom of the class here instead of just TRUE. */
1328 return atom;
1332 /***********************************************************************
1333 * GetClassInfoExW (USER32.@)
1335 BOOL WINAPI GetClassInfoExW( HINSTANCE hInstance, LPCWSTR name, WNDCLASSEXW *wc )
1337 ATOM atom;
1338 CLASS *classPtr;
1340 TRACE("%p %s %p\n", hInstance, debugstr_w(name), wc);
1342 if (!wc)
1344 SetLastError( ERROR_NOACCESS );
1345 return FALSE;
1348 if (!hInstance) hInstance = user32_module;
1350 if (!(classPtr = CLASS_FindClass( name, hInstance )))
1352 SetLastError( ERROR_CLASS_DOES_NOT_EXIST );
1353 return FALSE;
1355 wc->style = classPtr->style;
1356 wc->lpfnWndProc = WINPROC_GetProc( classPtr->winproc, TRUE );
1357 wc->cbClsExtra = classPtr->cbClsExtra;
1358 wc->cbWndExtra = classPtr->cbWndExtra;
1359 wc->hInstance = (hInstance == user32_module) ? 0 : hInstance;
1360 wc->hIcon = classPtr->hIcon;
1361 wc->hIconSm = classPtr->hIconSm ? classPtr->hIconSm : classPtr->hIconSmIntern;
1362 wc->hCursor = classPtr->hCursor;
1363 wc->hbrBackground = classPtr->hbrBackground;
1364 wc->lpszMenuName = CLASS_GetMenuNameW( classPtr );
1365 wc->lpszClassName = name;
1366 atom = classPtr->atomName;
1367 release_class_ptr( classPtr );
1369 /* We must return the atom of the class here instead of just TRUE. */
1370 return atom;
1374 #if 0 /* toolhelp is in kernel, so this cannot work */
1376 /***********************************************************************
1377 * ClassFirst (TOOLHELP.69)
1379 BOOL16 WINAPI ClassFirst16( CLASSENTRY *pClassEntry )
1381 TRACE("%p\n",pClassEntry);
1382 pClassEntry->wNext = 1;
1383 return ClassNext16( pClassEntry );
1387 /***********************************************************************
1388 * ClassNext (TOOLHELP.70)
1390 BOOL16 WINAPI ClassNext16( CLASSENTRY *pClassEntry )
1392 int i;
1393 CLASS *class = firstClass;
1395 TRACE("%p\n",pClassEntry);
1397 if (!pClassEntry->wNext) return FALSE;
1398 for (i = 1; (i < pClassEntry->wNext) && class; i++) class = class->next;
1399 if (!class)
1401 pClassEntry->wNext = 0;
1402 return FALSE;
1404 pClassEntry->hInst = class->hInstance;
1405 pClassEntry->wNext++;
1406 GlobalGetAtomNameA( class->atomName, pClassEntry->szClassName,
1407 sizeof(pClassEntry->szClassName) );
1408 return TRUE;
1410 #endif
1412 /* 64bit versions */
1414 #ifdef GetClassLongPtrA
1415 #undef GetClassLongPtrA
1416 #endif
1418 #ifdef GetClassLongPtrW
1419 #undef GetClassLongPtrW
1420 #endif
1422 #ifdef SetClassLongPtrA
1423 #undef SetClassLongPtrA
1424 #endif
1426 #ifdef SetClassLongPtrW
1427 #undef SetClassLongPtrW
1428 #endif
1430 /***********************************************************************
1431 * GetClassLongPtrA (USER32.@)
1433 ULONG_PTR WINAPI GetClassLongPtrA( HWND hwnd, INT offset )
1435 return CLASS_GetClassLong( hwnd, offset, sizeof(ULONG_PTR), FALSE );
1438 /***********************************************************************
1439 * GetClassLongPtrW (USER32.@)
1441 ULONG_PTR WINAPI GetClassLongPtrW( HWND hwnd, INT offset )
1443 return CLASS_GetClassLong( hwnd, offset, sizeof(ULONG_PTR), TRUE );
1446 /***********************************************************************
1447 * SetClassLongPtrW (USER32.@)
1449 ULONG_PTR WINAPI SetClassLongPtrW( HWND hwnd, INT offset, LONG_PTR newval )
1451 return CLASS_SetClassLong( hwnd, offset, newval, sizeof(LONG_PTR), TRUE );
1454 /***********************************************************************
1455 * SetClassLongPtrA (USER32.@)
1457 ULONG_PTR WINAPI SetClassLongPtrA( HWND hwnd, INT offset, LONG_PTR newval )
1459 return CLASS_SetClassLong( hwnd, offset, newval, sizeof(LONG_PTR), FALSE );