2 * Window classes functions
4 * Copyright 1993, 1996 Alexandre Julliard
6 * FIXME: In win32 all classes are local. They are registered at
7 * program start. Processes CANNOT share classes. (Source: some
8 * win31->NT migration book)
24 static CLASS *firstClass = NULL;
27 /***********************************************************************
30 * Dump the content of a class structure to stderr.
32 void CLASS_DumpClass( CLASS *ptr )
37 if (ptr->magic != CLASS_MAGIC)
39 DUMP("%p is not a class\n", ptr );
43 GlobalGetAtomName32A( ptr->atomName, className, sizeof(className) );
45 DUMP( "Class %p:\n", ptr );
46 DUMP( "next=%p name=%04x '%s' style=%08x wndProc=%08x\n"
47 "inst=%04x dce=%08x icon=%04x cursor=%04x bkgnd=%04x\n"
48 "clsExtra=%d winExtra=%d #windows=%d\n",
49 ptr->next, ptr->atomName, className, ptr->style,
50 (UINT32)ptr->winproc, ptr->hInstance, (UINT32)ptr->dce,
51 ptr->hIcon, ptr->hCursor, ptr->hbrBackground,
52 ptr->cbClsExtra, ptr->cbWndExtra, ptr->cWindows );
55 DUMP( "extra bytes:" );
56 for (i = 0; i < ptr->cbClsExtra; i++)
57 DUMP( " %02x", *((BYTE *)ptr->wExtra+i) );
64 /***********************************************************************
67 * Walk the class list and print each class on stderr.
69 void CLASS_WalkClasses(void)
74 DUMP( " Class Name Style WndProc\n" );
75 for (ptr = firstClass; ptr; ptr = ptr->next)
77 GlobalGetAtomName32A( ptr->atomName, className, sizeof(className) );
78 DUMP( "%08x %-20.20s %08x %08x\n", (UINT32)ptr, className,
79 ptr->style, (UINT32)ptr->winproc );
85 /***********************************************************************
88 * Get the menu name as a ASCII string.
90 static LPSTR CLASS_GetMenuNameA( CLASS *classPtr )
92 if (!classPtr->menuNameA && classPtr->menuNameW)
94 /* We need to copy the Unicode string */
95 classPtr->menuNameA = SEGPTR_STRDUP_WtoA( classPtr->menuNameW );
97 return classPtr->menuNameA;
101 /***********************************************************************
104 * Get the menu name as a Unicode string.
106 static LPWSTR CLASS_GetMenuNameW( CLASS *classPtr )
108 if (!classPtr->menuNameW && classPtr->menuNameA)
110 if (!HIWORD(classPtr->menuNameA))
111 return (LPWSTR)classPtr->menuNameA;
112 /* Now we need to copy the ASCII string */
113 classPtr->menuNameW = HEAP_strdupAtoW( SystemHeap, 0,
114 classPtr->menuNameA );
116 return classPtr->menuNameW;
120 /***********************************************************************
123 * Set the menu name in a class structure by copying the string.
125 static void CLASS_SetMenuNameA( CLASS *classPtr, LPCSTR name )
127 if (HIWORD(classPtr->menuNameA)) SEGPTR_FREE( classPtr->menuNameA );
128 if (classPtr->menuNameW) HeapFree( SystemHeap, 0, classPtr->menuNameW );
129 classPtr->menuNameA = SEGPTR_STRDUP( name );
130 classPtr->menuNameW = 0;
134 /***********************************************************************
137 * Set the menu name in a class structure by copying the string.
139 static void CLASS_SetMenuNameW( CLASS *classPtr, LPCWSTR name )
143 CLASS_SetMenuNameA( classPtr, (LPCSTR)name );
146 if (HIWORD(classPtr->menuNameA)) SEGPTR_FREE( classPtr->menuNameA );
147 if (classPtr->menuNameW) HeapFree( SystemHeap, 0, classPtr->menuNameW );
148 if ((classPtr->menuNameW = HeapAlloc( SystemHeap, 0,
149 (lstrlen32W(name)+1)*sizeof(WCHAR) )))
150 lstrcpy32W( classPtr->menuNameW, name );
151 classPtr->menuNameA = 0;
155 /***********************************************************************
158 * Free a class structure.
160 static BOOL32 CLASS_FreeClass( CLASS *classPtr )
164 /* Check if we can remove this class */
166 if (classPtr->cWindows > 0) return FALSE;
168 /* Remove the class from the linked list */
170 for (ppClass = &firstClass; *ppClass; ppClass = &(*ppClass)->next)
171 if (*ppClass == classPtr) break;
174 ERR( class, "Class list corrupted\n" );
177 *ppClass = classPtr->next;
179 /* Delete the class */
181 if (classPtr->dce) DCE_FreeDCE( classPtr->dce );
182 if (classPtr->hbrBackground) DeleteObject32( classPtr->hbrBackground );
183 GlobalDeleteAtom( classPtr->atomName );
184 CLASS_SetMenuNameA( classPtr, NULL );
185 WINPROC_FreeProc( classPtr->winproc, WIN_PROC_CLASS );
186 HeapFree( SystemHeap, 0, classPtr );
191 /***********************************************************************
192 * CLASS_FreeModuleClasses
194 void CLASS_FreeModuleClasses( HMODULE16 hModule )
198 for (ptr = firstClass; ptr; ptr = next)
201 if (ptr->hInstance == hModule) CLASS_FreeClass( ptr );
206 /***********************************************************************
207 * CLASS_FindClassByAtom
209 * Return a pointer to the class.
210 * hinstance has been normalized by the caller.
212 CLASS *CLASS_FindClassByAtom( ATOM atom, HINSTANCE32 hinstance )
216 /* First search task-specific classes */
218 for (class = firstClass; (class); class = class->next)
220 if (class->style & CS_GLOBALCLASS) continue;
221 if ((class->atomName == atom) &&
222 ((hinstance == 0xffff) ||
223 (hinstance == class->hInstance))) return class;
226 /* Then search global classes */
228 for (class = firstClass; (class); class = class->next)
230 if (!(class->style & CS_GLOBALCLASS)) continue;
231 if (class->atomName == atom) return class;
238 /***********************************************************************
239 * CLASS_RegisterClass
241 * The real RegisterClass() functionality.
243 static CLASS *CLASS_RegisterClass( ATOM atom, HINSTANCE32 hInstance,
244 DWORD style, INT32 classExtra,
245 INT32 winExtra, WNDPROC16 wndProc,
246 WINDOWPROCTYPE wndProcType )
250 /* Check if a class with this name already exists */
252 classPtr = CLASS_FindClassByAtom( atom, hInstance );
255 /* Class can be created only if it is local and */
256 /* if the class with the same name is global. */
258 if (style & CS_GLOBALCLASS) return NULL;
259 if (!(classPtr->style & CS_GLOBALCLASS)) return NULL;
262 /* Fix the extra bytes value */
264 if (classExtra < 0) classExtra = 0;
265 else if (classExtra > 40) /* Extra bytes are limited to 40 in Win32 */
266 WARN(class, "Class extra bytes %d is > 40\n", classExtra);
267 if (winExtra < 0) winExtra = 0;
268 else if (winExtra > 40) /* Extra bytes are limited to 40 in Win32 */
269 WARN(class, "Win extra bytes %d is > 40\n", winExtra );
271 /* Create the class */
273 classPtr = (CLASS *)HeapAlloc( SystemHeap, 0, sizeof(CLASS) +
274 classExtra - sizeof(classPtr->wExtra) );
275 if (!classPtr) return NULL;
276 classPtr->next = firstClass;
277 classPtr->magic = CLASS_MAGIC;
278 classPtr->cWindows = 0;
279 classPtr->style = style;
280 classPtr->winproc = (HWINDOWPROC)0;
281 classPtr->cbWndExtra = winExtra;
282 classPtr->cbClsExtra = classExtra;
283 classPtr->hInstance = hInstance;
284 classPtr->atomName = atom;
285 classPtr->menuNameA = 0;
286 classPtr->menuNameW = 0;
287 classPtr->dce = (style & CS_CLASSDC) ?
288 DCE_AllocDCE( 0, DCE_CLASS_DC ) : NULL;
290 WINPROC_SetProc( &classPtr->winproc, wndProc, wndProcType, WIN_PROC_CLASS);
292 /* Other values must be set by caller */
294 if (classExtra) memset( classPtr->wExtra, 0, classExtra );
295 firstClass = classPtr;
300 /***********************************************************************
301 * RegisterClass16 (USER.57)
303 ATOM WINAPI RegisterClass16( const WNDCLASS16 *wc )
307 HINSTANCE16 hInstance=GetExePtr(wc->hInstance);
309 if (!(atom = GlobalAddAtom16( wc->lpszClassName ))) return 0;
310 if (!(classPtr = CLASS_RegisterClass( atom, hInstance, wc->style,
311 wc->cbClsExtra, wc->cbWndExtra,
312 wc->lpfnWndProc, WIN_PROC_16 )))
314 GlobalDeleteAtom( atom );
318 TRACE(class, "atom=%04x wndproc=%08lx hinst=%04x
319 bg=%04x style=%08x clsExt=%d winExt=%d class=%p name='%s'\n",
320 atom, (DWORD)wc->lpfnWndProc, hInstance,
321 wc->hbrBackground, wc->style, wc->cbClsExtra,
322 wc->cbWndExtra, classPtr,
323 HIWORD(wc->lpszClassName) ?
324 (char *)PTR_SEG_TO_LIN(wc->lpszClassName) : "" );
326 classPtr->hIcon = wc->hIcon;
327 classPtr->hIconSm = 0;
328 classPtr->hCursor = wc->hCursor;
329 classPtr->hbrBackground = wc->hbrBackground;
331 CLASS_SetMenuNameA( classPtr, HIWORD(wc->lpszMenuName) ?
332 PTR_SEG_TO_LIN(wc->lpszMenuName) : (LPCSTR)wc->lpszMenuName );
337 /***********************************************************************
338 * RegisterClass32A (USER32.427)
340 * >0: Unique identifier
343 ATOM WINAPI RegisterClass32A(
344 const WNDCLASS32A* wc /* Address of structure with class data */
349 if (!(atom = GlobalAddAtom32A( wc->lpszClassName ))) return 0;
350 if (!(classPtr = CLASS_RegisterClass( atom, wc->hInstance, wc->style,
351 wc->cbClsExtra, wc->cbWndExtra,
352 (WNDPROC16)wc->lpfnWndProc,
355 GlobalDeleteAtom( atom );
359 TRACE(class, "atom=%04x wndproc=%08lx
360 hinst=%04x bg=%04x style=%08x clsExt=%d winExt=%d class=%p name='%s'\n",
361 atom, (DWORD)wc->lpfnWndProc, wc->hInstance,
362 wc->hbrBackground, wc->style, wc->cbClsExtra,
363 wc->cbWndExtra, classPtr,
364 HIWORD(wc->lpszClassName) ? wc->lpszClassName : "" );
366 classPtr->hIcon = (HICON16)wc->hIcon;
367 classPtr->hIconSm = 0;
368 classPtr->hCursor = (HCURSOR16)wc->hCursor;
369 classPtr->hbrBackground = (HBRUSH16)wc->hbrBackground;
370 CLASS_SetMenuNameA( classPtr, wc->lpszMenuName );
375 /***********************************************************************
376 * RegisterClass32W (USER32.430)
378 ATOM WINAPI RegisterClass32W( const WNDCLASS32W* wc )
383 if (!(atom = GlobalAddAtom32W( wc->lpszClassName ))) return 0;
384 if (!(classPtr = CLASS_RegisterClass( atom, wc->hInstance, wc->style,
385 wc->cbClsExtra, wc->cbWndExtra,
386 (WNDPROC16)wc->lpfnWndProc,
389 GlobalDeleteAtom( atom );
393 TRACE(class, "atom=%04x wndproc=%08lx hinst=%04x bg=%04x style=%08x clsExt=%d winExt=%d class=%p\n",
394 atom, (DWORD)wc->lpfnWndProc, wc->hInstance,
395 wc->hbrBackground, wc->style, wc->cbClsExtra,
396 wc->cbWndExtra, classPtr );
398 classPtr->hIcon = (HICON16)wc->hIcon;
399 classPtr->hIconSm = 0;
400 classPtr->hCursor = (HCURSOR16)wc->hCursor;
401 classPtr->hbrBackground = (HBRUSH16)wc->hbrBackground;
402 CLASS_SetMenuNameW( classPtr, wc->lpszMenuName );
407 /***********************************************************************
408 * RegisterClassEx16 (USER.397)
410 ATOM WINAPI RegisterClassEx16( const WNDCLASSEX16 *wc )
414 HINSTANCE16 hInstance = GetExePtr( wc->hInstance );
416 if (!(atom = GlobalAddAtom16( wc->lpszClassName ))) return 0;
417 if (!(classPtr = CLASS_RegisterClass( atom, hInstance, wc->style,
418 wc->cbClsExtra, wc->cbWndExtra,
419 wc->lpfnWndProc, WIN_PROC_16 )))
421 GlobalDeleteAtom( atom );
425 TRACE(class, "atom=%04x wndproc=%08lx hinst=%04x bg=%04x style=%08x clsExt=%d winExt=%d class=%p\n",
426 atom, (DWORD)wc->lpfnWndProc, hInstance,
427 wc->hbrBackground, wc->style, wc->cbClsExtra,
428 wc->cbWndExtra, classPtr );
430 classPtr->hIcon = wc->hIcon;
431 classPtr->hIconSm = wc->hIconSm;
432 classPtr->hCursor = wc->hCursor;
433 classPtr->hbrBackground = wc->hbrBackground;
435 CLASS_SetMenuNameA( classPtr, HIWORD(wc->lpszMenuName) ?
436 PTR_SEG_TO_LIN(wc->lpszMenuName) : (LPCSTR)wc->lpszMenuName );
441 /***********************************************************************
442 * RegisterClassEx32A (USER32.428)
444 ATOM WINAPI RegisterClassEx32A( const WNDCLASSEX32A* wc )
449 if (!(atom = GlobalAddAtom32A( wc->lpszClassName ))) return 0;
450 if (!(classPtr = CLASS_RegisterClass( atom, wc->hInstance, wc->style,
451 wc->cbClsExtra, wc->cbWndExtra,
452 (WNDPROC16)wc->lpfnWndProc,
455 GlobalDeleteAtom( atom );
459 TRACE(class, "atom=%04x wndproc=%08lx hinst=%04x bg=%04x style=%08x clsExt=%d winExt=%d class=%p\n",
460 atom, (DWORD)wc->lpfnWndProc, wc->hInstance,
461 wc->hbrBackground, wc->style, wc->cbClsExtra,
462 wc->cbWndExtra, classPtr );
464 classPtr->hIcon = (HICON16)wc->hIcon;
465 classPtr->hIconSm = (HICON16)wc->hIconSm;
466 classPtr->hCursor = (HCURSOR16)wc->hCursor;
467 classPtr->hbrBackground = (HBRUSH16)wc->hbrBackground;
468 CLASS_SetMenuNameA( classPtr, wc->lpszMenuName );
473 /***********************************************************************
474 * RegisterClassEx32W (USER32.429)
476 ATOM WINAPI RegisterClassEx32W( const WNDCLASSEX32W* wc )
481 if (!(atom = GlobalAddAtom32W( wc->lpszClassName ))) return 0;
482 if (!(classPtr = CLASS_RegisterClass( atom, wc->hInstance, wc->style,
483 wc->cbClsExtra, wc->cbWndExtra,
484 (WNDPROC16)wc->lpfnWndProc,
487 GlobalDeleteAtom( atom );
491 TRACE(class, "atom=%04x wndproc=%08lx hinst=%04x bg=%04x style=%08x clsExt=%d winExt=%d class=%p\n",
492 atom, (DWORD)wc->lpfnWndProc, wc->hInstance,
493 wc->hbrBackground, wc->style, wc->cbClsExtra,
494 wc->cbWndExtra, classPtr );
496 classPtr->hIcon = (HICON16)wc->hIcon;
497 classPtr->hIconSm = (HICON16)wc->hIconSm;
498 classPtr->hCursor = (HCURSOR16)wc->hCursor;
499 classPtr->hbrBackground = (HBRUSH16)wc->hbrBackground;
500 CLASS_SetMenuNameW( classPtr, wc->lpszMenuName );
505 /***********************************************************************
506 * UnregisterClass16 (USER.403)
508 BOOL16 WINAPI UnregisterClass16( SEGPTR className, HINSTANCE16 hInstance )
513 hInstance = GetExePtr( hInstance );
514 if (!(atom = GlobalFindAtom16( className ))) return FALSE;
515 if (!(classPtr = CLASS_FindClassByAtom( atom, hInstance )) ||
516 (classPtr->hInstance != hInstance)) return FALSE;
517 return CLASS_FreeClass( classPtr );
521 /***********************************************************************
522 * UnregisterClass32A (USER32.563)
524 BOOL32 WINAPI UnregisterClass32A( LPCSTR className, HINSTANCE32 hInstance )
529 if (!(atom = GlobalFindAtom32A( className ))) return FALSE;
530 if (!(classPtr = CLASS_FindClassByAtom( atom, hInstance )) ||
531 (classPtr->hInstance != hInstance)) return FALSE;
532 return CLASS_FreeClass( classPtr );
536 /***********************************************************************
537 * UnregisterClass32W (USER32.564)
539 BOOL32 WINAPI UnregisterClass32W( LPCWSTR className, HINSTANCE32 hInstance )
544 if (!(atom = GlobalFindAtom32W( className ))) return FALSE;
545 if (!(classPtr = CLASS_FindClassByAtom( atom, hInstance )) ||
546 (classPtr->hInstance != hInstance)) return FALSE;
547 return CLASS_FreeClass( classPtr );
551 /***********************************************************************
552 * GetClassWord16 (USER.129)
554 WORD WINAPI GetClassWord16( HWND16 hwnd, INT16 offset )
556 return GetClassWord32( hwnd, offset );
560 /***********************************************************************
561 * GetClassWord32 (USER32.219)
563 WORD WINAPI GetClassWord32( HWND32 hwnd, INT32 offset )
567 if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return 0;
570 if (offset <= wndPtr->class->cbClsExtra - sizeof(WORD))
571 return GET_WORD(((char *)wndPtr->class->wExtra) + offset);
575 case GCW_HBRBACKGROUND: return wndPtr->class->hbrBackground;
576 case GCW_HCURSOR: return wndPtr->class->hCursor;
577 case GCW_HICON: return wndPtr->class->hIcon;
578 case GCW_HICONSM: return wndPtr->class->hIconSm;
579 case GCW_ATOM: return wndPtr->class->atomName;
584 return (WORD)GetClassLong32A( hwnd, offset );
586 WARN(class, "Invalid offset %d\n", offset);
591 /***********************************************************************
592 * GetClassLong16 (USER.131)
594 LONG WINAPI GetClassLong16( HWND16 hwnd, INT16 offset )
602 if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return 0;
603 return (LONG)WINPROC_GetProc( wndPtr->class->winproc, WIN_PROC_16 );
605 ret = GetClassLong32A( hwnd, offset );
606 return (LONG)SEGPTR_GET( (void *)ret );
608 return GetClassLong32A( hwnd, offset );
613 /***********************************************************************
614 * GetClassLong32A (USER32.215)
616 LONG WINAPI GetClassLong32A( HWND32 hwnd, INT32 offset )
620 if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return 0;
623 if (offset <= wndPtr->class->cbClsExtra - sizeof(LONG))
624 return GET_DWORD(((char *)wndPtr->class->wExtra) + offset);
628 case GCL_STYLE: return (LONG)wndPtr->class->style;
629 case GCL_CBWNDEXTRA: return (LONG)wndPtr->class->cbWndExtra;
630 case GCL_CBCLSEXTRA: return (LONG)wndPtr->class->cbClsExtra;
631 case GCL_HMODULE: return (LONG)wndPtr->class->hInstance;
633 return (LONG)WINPROC_GetProc(wndPtr->class->winproc, WIN_PROC_32A);
635 return (LONG)CLASS_GetMenuNameA( wndPtr->class );
636 case GCL_HBRBACKGROUND:
640 return GetClassWord32( hwnd, offset );
642 WARN(class, "Invalid offset %d\n", offset);
647 /***********************************************************************
648 * GetClassLong32W (USER32.216)
650 LONG WINAPI GetClassLong32W( HWND32 hwnd, INT32 offset )
657 if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return 0;
658 return (LONG)WINPROC_GetProc( wndPtr->class->winproc, WIN_PROC_32W );
660 if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return 0;
661 return (LONG)CLASS_GetMenuNameW( wndPtr->class );
663 return GetClassLong32A( hwnd, offset );
668 /***********************************************************************
669 * SetClassWord16 (USER.130)
671 WORD WINAPI SetClassWord16( HWND16 hwnd, INT16 offset, WORD newval )
673 return SetClassWord32( hwnd, offset, newval );
677 /***********************************************************************
678 * SetClassWord32 (USER32.469)
680 WORD WINAPI SetClassWord32( HWND32 hwnd, INT32 offset, WORD newval )
686 if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return 0;
689 if (offset + sizeof(WORD) <= wndPtr->class->cbClsExtra)
690 ptr = ((char *)wndPtr->class->wExtra) + offset;
693 WARN( class, "Invalid offset %d\n", offset );
703 return (WORD)SetClassLong32A( hwnd, offset, (LONG)newval );
704 case GCW_HBRBACKGROUND: ptr = &wndPtr->class->hbrBackground; break;
705 case GCW_HCURSOR: ptr = &wndPtr->class->hCursor; break;
706 case GCW_HICON: ptr = &wndPtr->class->hIcon; break;
707 case GCW_HICONSM: ptr = &wndPtr->class->hIconSm; break;
708 case GCW_ATOM: ptr = &wndPtr->class->atomName; break;
710 WARN( class, "Invalid offset %d\n", offset);
713 retval = GET_WORD(ptr);
714 PUT_WORD( ptr, newval );
719 /***********************************************************************
720 * SetClassLong16 (USER.132)
722 LONG WINAPI SetClassLong16( HWND16 hwnd, INT16 offset, LONG newval )
730 if (!(wndPtr = WIN_FindWndPtr(hwnd))) return 0;
731 retval = (LONG)WINPROC_GetProc( wndPtr->class->winproc, WIN_PROC_16 );
732 WINPROC_SetProc( &wndPtr->class->winproc, (WNDPROC16)newval,
733 WIN_PROC_16, WIN_PROC_CLASS );
736 return SetClassLong32A( hwnd, offset, (LONG)PTR_SEG_TO_LIN(newval) );
738 return SetClassLong32A( hwnd, offset, newval );
743 /***********************************************************************
744 * SetClassLong32A (USER32.467)
746 LONG WINAPI SetClassLong32A( HWND32 hwnd, INT32 offset, LONG newval )
752 if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return 0;
755 if (offset + sizeof(LONG) <= wndPtr->class->cbClsExtra)
756 ptr = ((char *)wndPtr->class->wExtra) + offset;
759 WARN( class, "Invalid offset %d\n", offset );
766 CLASS_SetMenuNameA( wndPtr->class, (LPCSTR)newval );
767 return 0; /* Old value is now meaningless anyway */
769 retval = (LONG)WINPROC_GetProc( wndPtr->class->winproc,
771 WINPROC_SetProc( &wndPtr->class->winproc, (WNDPROC16)newval,
772 WIN_PROC_32A, WIN_PROC_CLASS );
774 case GCL_HBRBACKGROUND:
778 return SetClassWord32( hwnd, offset, (WORD)newval );
779 case GCL_STYLE: ptr = &wndPtr->class->style; break;
780 case GCL_CBWNDEXTRA: ptr = &wndPtr->class->cbWndExtra; break;
781 case GCL_CBCLSEXTRA: ptr = &wndPtr->class->cbClsExtra; break;
782 case GCL_HMODULE: ptr = &wndPtr->class->hInstance; break;
784 WARN( class, "Invalid offset %d\n", offset );
787 retval = GET_DWORD(ptr);
788 PUT_DWORD( ptr, newval );
793 /***********************************************************************
794 * SetClassLong32W (USER32.468)
796 LONG WINAPI SetClassLong32W( HWND32 hwnd, INT32 offset, LONG newval )
804 if (!(wndPtr = WIN_FindWndPtr(hwnd))) return 0;
805 retval = (LONG)WINPROC_GetProc( wndPtr->class->winproc, WIN_PROC_32W );
806 WINPROC_SetProc( &wndPtr->class->winproc, (WNDPROC16)newval,
807 WIN_PROC_32W, WIN_PROC_CLASS );
810 if (!(wndPtr = WIN_FindWndPtr(hwnd))) return 0;
811 CLASS_SetMenuNameW( wndPtr->class, (LPCWSTR)newval );
812 return 0; /* Old value is now meaningless anyway */
814 return SetClassLong32A( hwnd, offset, newval );
819 /***********************************************************************
820 * GetClassName16 (USER.58)
822 INT16 WINAPI GetClassName16( HWND16 hwnd, LPSTR buffer, INT16 count )
825 if (!(wndPtr = WIN_FindWndPtr(hwnd))) return 0;
826 return GlobalGetAtomName16( wndPtr->class->atomName, buffer, count );
830 /***********************************************************************
831 * GetClassName32A (USER32.217)
833 INT32 WINAPI GetClassName32A( HWND32 hwnd, LPSTR buffer, INT32 count )
836 if (!(wndPtr = WIN_FindWndPtr(hwnd))) return 0;
837 return GlobalGetAtomName32A( wndPtr->class->atomName, buffer, count );
841 /***********************************************************************
842 * GetClassName32W (USER32.218)
844 INT32 WINAPI GetClassName32W( HWND32 hwnd, LPWSTR buffer, INT32 count )
847 if (!(wndPtr = WIN_FindWndPtr(hwnd))) return 0;
848 return GlobalGetAtomName32W( wndPtr->class->atomName, buffer, count );
852 /***********************************************************************
853 * GetClassInfo16 (USER.404)
855 BOOL16 WINAPI GetClassInfo16( HINSTANCE16 hInstance, SEGPTR name,
861 hInstance = GetExePtr( hInstance );
862 if (!(atom = GlobalFindAtom16( name )) ||
863 !(classPtr = CLASS_FindClassByAtom( atom, hInstance )))
865 if ((hInstance != classPtr->hInstance) &&
866 !(classPtr->style & CS_GLOBALCLASS)) /*BWCC likes to pass hInstance=0*/
868 wc->style = (UINT16)classPtr->style;
869 wc->lpfnWndProc = WINPROC_GetProc( classPtr->winproc, WIN_PROC_16 );
870 wc->cbClsExtra = (INT16)classPtr->cbClsExtra;
871 wc->cbWndExtra = (INT16)classPtr->cbWndExtra;
872 wc->hInstance = (HINSTANCE16)classPtr->hInstance;
873 wc->hIcon = classPtr->hIcon;
874 wc->hCursor = classPtr->hCursor;
875 wc->hbrBackground = classPtr->hbrBackground;
876 wc->lpszClassName = (SEGPTR)0;
877 wc->lpszMenuName = (SEGPTR)CLASS_GetMenuNameA( classPtr );
878 if (HIWORD(wc->lpszMenuName)) /* Make it a SEGPTR */
879 wc->lpszMenuName = SEGPTR_GET( (LPSTR)wc->lpszMenuName );
884 /***********************************************************************
885 * GetClassInfo32A (USER32.211)
887 BOOL32 WINAPI GetClassInfo32A( HINSTANCE32 hInstance, LPCSTR name,
893 if (!(atom = GlobalFindAtom32A( name )) ||
894 !(classPtr = CLASS_FindClassByAtom( atom, hInstance )) ||
895 (classPtr->hInstance && (hInstance != classPtr->hInstance)))
898 wc->style = classPtr->style;
899 wc->lpfnWndProc = (WNDPROC32)WINPROC_GetProc( classPtr->winproc,
901 wc->cbClsExtra = classPtr->cbClsExtra;
902 wc->cbWndExtra = classPtr->cbWndExtra;
903 wc->hInstance = classPtr->hInstance;
904 wc->hIcon = (HICON32)classPtr->hIcon;
905 wc->hCursor = (HCURSOR32)classPtr->hCursor;
906 wc->hbrBackground = (HBRUSH32)classPtr->hbrBackground;
907 wc->lpszMenuName = CLASS_GetMenuNameA( classPtr );
908 wc->lpszClassName = NULL;
913 /***********************************************************************
914 * GetClassInfo32W (USER32.214)
916 BOOL32 WINAPI GetClassInfo32W( HINSTANCE32 hInstance, LPCWSTR name,
922 if (!(atom = GlobalFindAtom32W( name )) ||
923 !(classPtr = CLASS_FindClassByAtom( atom, hInstance )) ||
924 (classPtr->hInstance && (hInstance != classPtr->hInstance)))
927 wc->style = classPtr->style;
928 wc->lpfnWndProc = (WNDPROC32)WINPROC_GetProc( classPtr->winproc,
930 wc->cbClsExtra = classPtr->cbClsExtra;
931 wc->cbWndExtra = classPtr->cbWndExtra;
932 wc->hInstance = classPtr->hInstance;
933 wc->hIcon = (HICON32)classPtr->hIcon;
934 wc->hCursor = (HCURSOR32)classPtr->hCursor;
935 wc->hbrBackground = (HBRUSH32)classPtr->hbrBackground;
936 wc->lpszMenuName = CLASS_GetMenuNameW( classPtr );
937 wc->lpszClassName = NULL;
942 /***********************************************************************
943 * GetClassInfoEx16 (USER.398)
945 * FIXME: this is just a guess, I have no idea if GetClassInfoEx() is the
946 * same in Win16 as in Win32. --AJ
948 BOOL16 WINAPI GetClassInfoEx16( HINSTANCE16 hInstance, SEGPTR name,
954 hInstance = GetExePtr( hInstance );
955 if (!(atom = GlobalFindAtom16( name )) ||
956 !(classPtr = CLASS_FindClassByAtom( atom, hInstance )) ||
957 (hInstance != classPtr->hInstance)) return FALSE;
958 wc->style = classPtr->style;
959 wc->lpfnWndProc = WINPROC_GetProc( classPtr->winproc, WIN_PROC_16 );
960 wc->cbClsExtra = (INT16)classPtr->cbClsExtra;
961 wc->cbWndExtra = (INT16)classPtr->cbWndExtra;
962 wc->hInstance = (HINSTANCE16)classPtr->hInstance;
963 wc->hIcon = classPtr->hIcon;
964 wc->hIconSm = classPtr->hIconSm;
965 wc->hCursor = classPtr->hCursor;
966 wc->hbrBackground = classPtr->hbrBackground;
967 wc->lpszClassName = (SEGPTR)0;
968 wc->lpszMenuName = (SEGPTR)CLASS_GetMenuNameA( classPtr );
969 if (HIWORD(wc->lpszMenuName)) /* Make it a SEGPTR */
970 wc->lpszMenuName = SEGPTR_GET( (LPSTR)wc->lpszMenuName );
975 /***********************************************************************
976 * GetClassInfoEx32A (USER32.212)
978 BOOL32 WINAPI GetClassInfoEx32A( HINSTANCE32 hInstance, LPCSTR name,
984 if (!(atom = GlobalFindAtom32A( name )) ||
985 !(classPtr = CLASS_FindClassByAtom( atom, hInstance )) ||
986 (hInstance != classPtr->hInstance)) return FALSE;
987 wc->style = classPtr->style;
988 wc->lpfnWndProc = (WNDPROC32)WINPROC_GetProc( classPtr->winproc,
990 wc->cbClsExtra = classPtr->cbClsExtra;
991 wc->cbWndExtra = classPtr->cbWndExtra;
992 wc->hInstance = classPtr->hInstance;
993 wc->hIcon = (HICON32)classPtr->hIcon;
994 wc->hIconSm = (HICON32)classPtr->hIconSm;
995 wc->hCursor = (HCURSOR32)classPtr->hCursor;
996 wc->hbrBackground = (HBRUSH32)classPtr->hbrBackground;
997 wc->lpszMenuName = CLASS_GetMenuNameA( classPtr );
998 wc->lpszClassName = NULL;
1003 /***********************************************************************
1004 * GetClassInfoEx32W (USER32.213)
1006 BOOL32 WINAPI GetClassInfoEx32W( HINSTANCE32 hInstance, LPCWSTR name,
1012 if (!(atom = GlobalFindAtom32W( name )) ||
1013 !(classPtr = CLASS_FindClassByAtom( atom, hInstance )) ||
1014 (hInstance != classPtr->hInstance)) return FALSE;
1015 wc->style = classPtr->style;
1016 wc->lpfnWndProc = (WNDPROC32)WINPROC_GetProc( classPtr->winproc,
1018 wc->cbClsExtra = classPtr->cbClsExtra;
1019 wc->cbWndExtra = classPtr->cbWndExtra;
1020 wc->hInstance = classPtr->hInstance;
1021 wc->hIcon = (HICON32)classPtr->hIcon;
1022 wc->hIconSm = (HICON32)classPtr->hIconSm;
1023 wc->hCursor = (HCURSOR32)classPtr->hCursor;
1024 wc->hbrBackground = (HBRUSH32)classPtr->hbrBackground;
1025 wc->lpszMenuName = CLASS_GetMenuNameW( classPtr );
1026 wc->lpszClassName = NULL;
1031 /***********************************************************************
1032 * ClassFirst (TOOLHELP.69)
1034 BOOL16 WINAPI ClassFirst( CLASSENTRY *pClassEntry )
1036 pClassEntry->wNext = 1;
1037 return ClassNext( pClassEntry );
1041 /***********************************************************************
1042 * ClassNext (TOOLHELP.70)
1044 BOOL16 WINAPI ClassNext( CLASSENTRY *pClassEntry )
1047 CLASS *class = firstClass;
1049 if (!pClassEntry->wNext) return FALSE;
1050 for (i = 1; (i < pClassEntry->wNext) && class; i++) class = class->next;
1053 pClassEntry->wNext = 0;
1056 pClassEntry->hInst = class->hInstance;
1057 pClassEntry->wNext++;
1058 GlobalGetAtomName32A( class->atomName, pClassEntry->szClassName,
1059 sizeof(pClassEntry->szClassName) );