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)
25 static CLASS *firstClass = NULL;
28 /***********************************************************************
31 * Dump the content of a class structure to stderr.
33 void CLASS_DumpClass( CLASS *ptr )
38 if (ptr->magic != CLASS_MAGIC)
40 fprintf( stderr, "%p is not a class\n", ptr );
44 GlobalGetAtomName32A( ptr->atomName, className, sizeof(className) );
46 fprintf( stderr, "Class %p:\n", ptr );
48 "next=%p name=%04x '%s' style=%08x wndProc=%08x\n"
49 "inst=%04x dce=%08x icon=%04x cursor=%04x bkgnd=%04x\n"
50 "clsExtra=%d winExtra=%d #windows=%d\n",
51 ptr->next, ptr->atomName, className, ptr->style,
52 (UINT32)ptr->winproc, ptr->hInstance, (UINT32)ptr->dce,
53 ptr->hIcon, ptr->hCursor, ptr->hbrBackground,
54 ptr->cbClsExtra, ptr->cbWndExtra, ptr->cWindows );
57 fprintf( stderr, "extra bytes:" );
58 for (i = 0; i < ptr->cbClsExtra; i++)
59 fprintf( stderr, " %02x", *((BYTE *)ptr->wExtra+i) );
60 fprintf( stderr, "\n" );
62 fprintf( stderr, "\n" );
66 /***********************************************************************
69 * Walk the class list and print each class on stderr.
71 void CLASS_WalkClasses(void)
76 fprintf( stderr, " Class Name Style WndProc\n" );
77 for (ptr = firstClass; ptr; ptr = ptr->next)
79 GlobalGetAtomName32A( ptr->atomName, className, sizeof(className) );
80 fprintf( stderr, "%08x %-20.20s %08x %08x\n", (UINT32)ptr, className,
81 ptr->style, (UINT32)ptr->winproc );
83 fprintf( stderr, "\n" );
87 /***********************************************************************
90 * Get the menu name as a ASCII string.
92 static LPSTR CLASS_GetMenuNameA( CLASS *classPtr )
94 if (!classPtr->menuNameA && classPtr->menuNameW)
96 /* We need to copy the Unicode string */
97 classPtr->menuNameA = SEGPTR_STRDUP_WtoA( classPtr->menuNameW );
99 return classPtr->menuNameA;
103 /***********************************************************************
106 * Get the menu name as a Unicode string.
108 static LPWSTR CLASS_GetMenuNameW( CLASS *classPtr )
110 if (!classPtr->menuNameW && classPtr->menuNameA)
112 if (!HIWORD(classPtr->menuNameA))
113 return (LPWSTR)classPtr->menuNameA;
114 /* Now we need to copy the ASCII string */
115 classPtr->menuNameW = HEAP_strdupAtoW( SystemHeap, 0,
116 classPtr->menuNameA );
118 return classPtr->menuNameW;
122 /***********************************************************************
125 * Set the menu name in a class structure by copying the string.
127 static void CLASS_SetMenuNameA( CLASS *classPtr, LPCSTR name )
129 if (HIWORD(classPtr->menuNameA)) SEGPTR_FREE( classPtr->menuNameA );
130 if (classPtr->menuNameW) HeapFree( SystemHeap, 0, classPtr->menuNameW );
131 classPtr->menuNameA = SEGPTR_STRDUP( name );
132 classPtr->menuNameW = 0;
136 /***********************************************************************
139 * Set the menu name in a class structure by copying the string.
141 static void CLASS_SetMenuNameW( CLASS *classPtr, LPCWSTR name )
145 CLASS_SetMenuNameA( classPtr, (LPCSTR)name );
148 if (HIWORD(classPtr->menuNameA)) SEGPTR_FREE( classPtr->menuNameA );
149 if (classPtr->menuNameW) HeapFree( SystemHeap, 0, classPtr->menuNameW );
150 if ((classPtr->menuNameW = HeapAlloc( SystemHeap, 0,
151 (lstrlen32W(name)+1)*sizeof(WCHAR) )))
152 lstrcpy32W( classPtr->menuNameW, name );
153 classPtr->menuNameA = 0;
157 /***********************************************************************
160 * Free a class structure.
162 static BOOL32 CLASS_FreeClass( CLASS *classPtr )
166 /* Check if we can remove this class */
168 if (classPtr->cWindows > 0) return FALSE;
170 /* Remove the class from the linked list */
172 for (ppClass = &firstClass; *ppClass; ppClass = &(*ppClass)->next)
173 if (*ppClass == classPtr) break;
176 fprintf(stderr, "ERROR: Class list corrupted\n" );
179 *ppClass = classPtr->next;
181 /* Delete the class */
183 if (classPtr->dce) DCE_FreeDCE( classPtr->dce );
184 if (classPtr->hbrBackground) DeleteObject32( classPtr->hbrBackground );
185 GlobalDeleteAtom( classPtr->atomName );
186 CLASS_SetMenuNameA( classPtr, NULL );
187 WINPROC_FreeProc( classPtr->winproc, WIN_PROC_CLASS );
188 HeapFree( SystemHeap, 0, classPtr );
193 /***********************************************************************
194 * CLASS_FreeModuleClasses
196 void CLASS_FreeModuleClasses( HMODULE16 hModule )
200 for (ptr = firstClass; ptr; ptr = next)
203 if (ptr->hInstance == hModule) CLASS_FreeClass( ptr );
208 /***********************************************************************
209 * CLASS_FindClassByAtom
211 * Return a pointer to the class.
212 * hinstance has been normalized by the caller.
214 CLASS *CLASS_FindClassByAtom( ATOM atom, HINSTANCE32 hinstance )
218 /* First search task-specific classes */
220 for (class = firstClass; (class); class = class->next)
222 if (class->style & CS_GLOBALCLASS) continue;
223 if ((class->atomName == atom) &&
224 ((hinstance == 0xffff) ||
225 (hinstance == class->hInstance))) return class;
228 /* Then search global classes */
230 for (class = firstClass; (class); class = class->next)
232 if (!(class->style & CS_GLOBALCLASS)) continue;
233 if (class->atomName == atom) return class;
240 /***********************************************************************
241 * CLASS_RegisterClass
243 * The real RegisterClass() functionality.
245 static CLASS *CLASS_RegisterClass( ATOM atom, HINSTANCE32 hInstance,
246 DWORD style, INT32 classExtra,
247 INT32 winExtra, WNDPROC16 wndProc,
248 WINDOWPROCTYPE wndProcType )
252 /* Check if a class with this name already exists */
254 classPtr = CLASS_FindClassByAtom( atom, hInstance );
257 /* Class can be created only if it is local and */
258 /* if the class with the same name is global. */
260 if (style & CS_GLOBALCLASS) return NULL;
261 if (!(classPtr->style & CS_GLOBALCLASS)) return NULL;
264 /* Fix the extra bytes value */
266 if (classExtra < 0) classExtra = 0;
267 else if (classExtra > 40) /* Extra bytes are limited to 40 in Win32 */
268 fprintf(stderr, "Warning: class extra bytes %d is > 40\n", classExtra);
269 if (winExtra < 0) winExtra = 0;
270 else if (winExtra > 40) /* Extra bytes are limited to 40 in Win32 */
271 fprintf( stderr, "Warning: win extra bytes %d is > 40\n", winExtra );
273 /* Create the class */
275 classPtr = (CLASS *)HeapAlloc( SystemHeap, 0, sizeof(CLASS) +
276 classExtra - sizeof(classPtr->wExtra) );
277 if (!classPtr) return NULL;
278 classPtr->next = firstClass;
279 classPtr->magic = CLASS_MAGIC;
280 classPtr->cWindows = 0;
281 classPtr->style = style;
282 classPtr->winproc = (HWINDOWPROC)0;
283 classPtr->cbWndExtra = winExtra;
284 classPtr->cbClsExtra = classExtra;
285 classPtr->hInstance = hInstance;
286 classPtr->atomName = atom;
287 classPtr->menuNameA = 0;
288 classPtr->menuNameW = 0;
289 classPtr->dce = (style & CS_CLASSDC) ?
290 DCE_AllocDCE( 0, DCE_CLASS_DC ) : NULL;
292 WINPROC_SetProc( &classPtr->winproc, wndProc, wndProcType, WIN_PROC_CLASS);
294 /* Other values must be set by caller */
296 if (classExtra) memset( classPtr->wExtra, 0, classExtra );
297 firstClass = classPtr;
302 /***********************************************************************
303 * RegisterClass16 (USER.57)
305 ATOM WINAPI RegisterClass16( const WNDCLASS16 *wc )
309 HINSTANCE16 hInstance=GetExePtr(wc->hInstance);
311 if (!(atom = GlobalAddAtom16( wc->lpszClassName ))) return 0;
312 if (!(classPtr = CLASS_RegisterClass( atom, hInstance, wc->style,
313 wc->cbClsExtra, wc->cbWndExtra,
314 wc->lpfnWndProc, WIN_PROC_16 )))
316 GlobalDeleteAtom( atom );
320 dprintf_info(class, "RegisterClass16: atom=%04x wndproc=%08lx hinst=%04x
321 bg=%04x style=%08x clsExt=%d winExt=%d class=%p name='%s'\n",
322 atom, (DWORD)wc->lpfnWndProc, hInstance,
323 wc->hbrBackground, wc->style, wc->cbClsExtra,
324 wc->cbWndExtra, classPtr,
325 HIWORD(wc->lpszClassName) ?
326 (char *)PTR_SEG_TO_LIN(wc->lpszClassName) : "" );
328 classPtr->hIcon = wc->hIcon;
329 classPtr->hIconSm = 0;
330 classPtr->hCursor = wc->hCursor;
331 classPtr->hbrBackground = wc->hbrBackground;
333 CLASS_SetMenuNameA( classPtr, HIWORD(wc->lpszMenuName) ?
334 PTR_SEG_TO_LIN(wc->lpszMenuName) : (LPCSTR)wc->lpszMenuName );
339 /***********************************************************************
340 * RegisterClass32A (USER32.426)
342 ATOM WINAPI RegisterClass32A( const WNDCLASS32A* wc )
347 if (!(atom = GlobalAddAtom32A( wc->lpszClassName ))) return 0;
348 if (!(classPtr = CLASS_RegisterClass( atom, wc->hInstance, wc->style,
349 wc->cbClsExtra, wc->cbWndExtra,
350 (WNDPROC16)wc->lpfnWndProc,
353 GlobalDeleteAtom( atom );
357 dprintf_info(class, "RegisterClass32A: atom=%04x wndproc=%08lx
358 hinst=%04x bg=%04x style=%08x clsExt=%d winExt=%d class=%p name='%s'\n",
359 atom, (DWORD)wc->lpfnWndProc, wc->hInstance,
360 wc->hbrBackground, wc->style, wc->cbClsExtra,
361 wc->cbWndExtra, classPtr,
362 HIWORD(wc->lpszClassName) ? wc->lpszClassName : "" );
364 classPtr->hIcon = (HICON16)wc->hIcon;
365 classPtr->hIconSm = 0;
366 classPtr->hCursor = (HCURSOR16)wc->hCursor;
367 classPtr->hbrBackground = (HBRUSH16)wc->hbrBackground;
368 CLASS_SetMenuNameA( classPtr, wc->lpszMenuName );
373 /***********************************************************************
374 * RegisterClass32W (USER32.429)
376 ATOM WINAPI RegisterClass32W( const WNDCLASS32W* wc )
381 if (!(atom = GlobalAddAtom32W( wc->lpszClassName ))) return 0;
382 if (!(classPtr = CLASS_RegisterClass( atom, wc->hInstance, wc->style,
383 wc->cbClsExtra, wc->cbWndExtra,
384 (WNDPROC16)wc->lpfnWndProc,
387 GlobalDeleteAtom( atom );
391 dprintf_info(class, "RegisterClass32W: atom=%04x wndproc=%08lx hinst=%04x bg=%04x style=%08x clsExt=%d winExt=%d class=%p\n",
392 atom, (DWORD)wc->lpfnWndProc, wc->hInstance,
393 wc->hbrBackground, wc->style, wc->cbClsExtra,
394 wc->cbWndExtra, classPtr );
396 classPtr->hIcon = (HICON16)wc->hIcon;
397 classPtr->hIconSm = 0;
398 classPtr->hCursor = (HCURSOR16)wc->hCursor;
399 classPtr->hbrBackground = (HBRUSH16)wc->hbrBackground;
400 CLASS_SetMenuNameW( classPtr, wc->lpszMenuName );
405 /***********************************************************************
406 * RegisterClassEx16 (USER.397)
408 ATOM WINAPI RegisterClassEx16( const WNDCLASSEX16 *wc )
412 HINSTANCE16 hInstance = GetExePtr( wc->hInstance );
414 if (!(atom = GlobalAddAtom16( wc->lpszClassName ))) return 0;
415 if (!(classPtr = CLASS_RegisterClass( atom, hInstance, wc->style,
416 wc->cbClsExtra, wc->cbWndExtra,
417 wc->lpfnWndProc, WIN_PROC_16 )))
419 GlobalDeleteAtom( atom );
423 dprintf_info(class, "RegisterClassEx16: atom=%04x wndproc=%08lx hinst=%04x bg=%04x style=%08x clsExt=%d winExt=%d class=%p\n",
424 atom, (DWORD)wc->lpfnWndProc, hInstance,
425 wc->hbrBackground, wc->style, wc->cbClsExtra,
426 wc->cbWndExtra, classPtr );
428 classPtr->hIcon = wc->hIcon;
429 classPtr->hIconSm = wc->hIconSm;
430 classPtr->hCursor = wc->hCursor;
431 classPtr->hbrBackground = wc->hbrBackground;
433 CLASS_SetMenuNameA( classPtr, HIWORD(wc->lpszMenuName) ?
434 PTR_SEG_TO_LIN(wc->lpszMenuName) : (LPCSTR)wc->lpszMenuName );
439 /***********************************************************************
440 * RegisterClassEx32A (USER32.427)
442 ATOM WINAPI RegisterClassEx32A( const WNDCLASSEX32A* wc )
447 if (!(atom = GlobalAddAtom32A( wc->lpszClassName ))) return 0;
448 if (!(classPtr = CLASS_RegisterClass( atom, wc->hInstance, wc->style,
449 wc->cbClsExtra, wc->cbWndExtra,
450 (WNDPROC16)wc->lpfnWndProc,
453 GlobalDeleteAtom( atom );
457 dprintf_info(class, "RegisterClassEx32A: atom=%04x wndproc=%08lx hinst=%04x bg=%04x style=%08x clsExt=%d winExt=%d class=%p\n",
458 atom, (DWORD)wc->lpfnWndProc, wc->hInstance,
459 wc->hbrBackground, wc->style, wc->cbClsExtra,
460 wc->cbWndExtra, classPtr );
462 classPtr->hIcon = (HICON16)wc->hIcon;
463 classPtr->hIconSm = (HICON16)wc->hIconSm;
464 classPtr->hCursor = (HCURSOR16)wc->hCursor;
465 classPtr->hbrBackground = (HBRUSH16)wc->hbrBackground;
466 CLASS_SetMenuNameA( classPtr, wc->lpszMenuName );
471 /***********************************************************************
472 * RegisterClassEx32W (USER32.428)
474 ATOM WINAPI RegisterClassEx32W( const WNDCLASSEX32W* wc )
479 if (!(atom = GlobalAddAtom32W( wc->lpszClassName ))) return 0;
480 if (!(classPtr = CLASS_RegisterClass( atom, wc->hInstance, wc->style,
481 wc->cbClsExtra, wc->cbWndExtra,
482 (WNDPROC16)wc->lpfnWndProc,
485 GlobalDeleteAtom( atom );
489 dprintf_info(class, "RegisterClassEx32W: atom=%04x wndproc=%08lx hinst=%04x bg=%04x style=%08x clsExt=%d winExt=%d class=%p\n",
490 atom, (DWORD)wc->lpfnWndProc, wc->hInstance,
491 wc->hbrBackground, wc->style, wc->cbClsExtra,
492 wc->cbWndExtra, classPtr );
494 classPtr->hIcon = (HICON16)wc->hIcon;
495 classPtr->hIconSm = (HICON16)wc->hIconSm;
496 classPtr->hCursor = (HCURSOR16)wc->hCursor;
497 classPtr->hbrBackground = (HBRUSH16)wc->hbrBackground;
498 CLASS_SetMenuNameW( classPtr, wc->lpszMenuName );
503 /***********************************************************************
504 * UnregisterClass16 (USER.403)
506 BOOL16 WINAPI UnregisterClass16( SEGPTR className, HINSTANCE16 hInstance )
511 hInstance = GetExePtr( hInstance );
512 if (!(atom = GlobalFindAtom16( className ))) return FALSE;
513 if (!(classPtr = CLASS_FindClassByAtom( atom, hInstance )) ||
514 (classPtr->hInstance != hInstance)) return FALSE;
515 return CLASS_FreeClass( classPtr );
519 /***********************************************************************
520 * UnregisterClass32A (USER32.562)
522 BOOL32 WINAPI UnregisterClass32A( LPCSTR className, HINSTANCE32 hInstance )
527 if (!(atom = GlobalFindAtom32A( className ))) return FALSE;
528 if (!(classPtr = CLASS_FindClassByAtom( atom, hInstance )) ||
529 (classPtr->hInstance != hInstance)) return FALSE;
530 return CLASS_FreeClass( classPtr );
534 /***********************************************************************
535 * UnregisterClass32W (USER32.563)
537 BOOL32 WINAPI UnregisterClass32W( LPCWSTR className, HINSTANCE32 hInstance )
542 if (!(atom = GlobalFindAtom32W( className ))) return FALSE;
543 if (!(classPtr = CLASS_FindClassByAtom( atom, hInstance )) ||
544 (classPtr->hInstance != hInstance)) return FALSE;
545 return CLASS_FreeClass( classPtr );
549 /***********************************************************************
550 * GetClassWord16 (USER.129)
552 WORD WINAPI GetClassWord16( HWND16 hwnd, INT16 offset )
554 return GetClassWord32( hwnd, offset );
558 /***********************************************************************
559 * GetClassWord32 (USER32.218)
561 WORD WINAPI GetClassWord32( HWND32 hwnd, INT32 offset )
565 if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return 0;
568 if (offset <= wndPtr->class->cbClsExtra - sizeof(WORD))
569 return GET_WORD(((char *)wndPtr->class->wExtra) + offset);
573 case GCW_HBRBACKGROUND: return wndPtr->class->hbrBackground;
574 case GCW_HCURSOR: return wndPtr->class->hCursor;
575 case GCW_HICON: return wndPtr->class->hIcon;
576 case GCW_HICONSM: return wndPtr->class->hIconSm;
577 case GCW_ATOM: return wndPtr->class->atomName;
582 return (WORD)GetClassLong32A( hwnd, offset );
584 fprintf(stderr, "Warning: invalid offset %d for GetClassWord()\n", offset);
589 /***********************************************************************
590 * GetClassLong16 (USER.131)
592 LONG WINAPI GetClassLong16( HWND16 hwnd, INT16 offset )
600 if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return 0;
601 return (LONG)WINPROC_GetProc( wndPtr->class->winproc, WIN_PROC_16 );
603 ret = GetClassLong32A( hwnd, offset );
604 return (LONG)SEGPTR_GET( (void *)ret );
606 return GetClassLong32A( hwnd, offset );
611 /***********************************************************************
612 * GetClassLong32A (USER32.214)
614 LONG WINAPI GetClassLong32A( HWND32 hwnd, INT32 offset )
618 if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return 0;
621 if (offset <= wndPtr->class->cbClsExtra - sizeof(LONG))
622 return GET_DWORD(((char *)wndPtr->class->wExtra) + offset);
626 case GCL_STYLE: return (LONG)wndPtr->class->style;
627 case GCL_CBWNDEXTRA: return (LONG)wndPtr->class->cbWndExtra;
628 case GCL_CBCLSEXTRA: return (LONG)wndPtr->class->cbClsExtra;
629 case GCL_HMODULE: return (LONG)wndPtr->class->hInstance;
631 return (LONG)WINPROC_GetProc(wndPtr->class->winproc, WIN_PROC_32A);
633 return (LONG)CLASS_GetMenuNameA( wndPtr->class );
634 case GCL_HBRBACKGROUND:
638 return GetClassWord32( hwnd, offset );
640 fprintf(stderr, "Warning: invalid offset %d for GetClassLong()\n", offset);
645 /***********************************************************************
646 * GetClassLong32W (USER32.215)
648 LONG WINAPI GetClassLong32W( HWND32 hwnd, INT32 offset )
655 if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return 0;
656 return (LONG)WINPROC_GetProc( wndPtr->class->winproc, WIN_PROC_32W );
658 if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return 0;
659 return (LONG)CLASS_GetMenuNameW( wndPtr->class );
661 return GetClassLong32A( hwnd, offset );
666 /***********************************************************************
667 * SetClassWord16 (USER.130)
669 WORD WINAPI SetClassWord16( HWND16 hwnd, INT16 offset, WORD newval )
671 return SetClassWord32( hwnd, offset, newval );
675 /***********************************************************************
676 * SetClassWord32 (USER32.468)
678 WORD WINAPI SetClassWord32( HWND32 hwnd, INT32 offset, WORD newval )
684 if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return 0;
687 if (offset + sizeof(WORD) <= wndPtr->class->cbClsExtra)
688 ptr = ((char *)wndPtr->class->wExtra) + offset;
691 fprintf( stderr, "Warning: invalid offset %d for SetClassWord()\n",
702 return (WORD)SetClassLong32A( hwnd, offset, (LONG)newval );
703 case GCW_HBRBACKGROUND: ptr = &wndPtr->class->hbrBackground; break;
704 case GCW_HCURSOR: ptr = &wndPtr->class->hCursor; break;
705 case GCW_HICON: ptr = &wndPtr->class->hIcon; break;
706 case GCW_HICONSM: ptr = &wndPtr->class->hIconSm; break;
707 case GCW_ATOM: ptr = &wndPtr->class->atomName; break;
709 fprintf( stderr, "Warning: invalid offset %d for SetClassWord()\n",
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.466)
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 fprintf( stderr, "Warning: invalid offset %d for SetClassLong()\n",
767 CLASS_SetMenuNameA( wndPtr->class, (LPCSTR)newval );
768 return 0; /* Old value is now meaningless anyway */
770 retval = (LONG)WINPROC_GetProc( wndPtr->class->winproc,
772 WINPROC_SetProc( &wndPtr->class->winproc, (WNDPROC16)newval,
773 WIN_PROC_32A, WIN_PROC_CLASS );
775 case GCL_HBRBACKGROUND:
779 return SetClassWord32( hwnd, offset, (WORD)newval );
780 case GCL_STYLE: ptr = &wndPtr->class->style; break;
781 case GCL_CBWNDEXTRA: ptr = &wndPtr->class->cbWndExtra; break;
782 case GCL_CBCLSEXTRA: ptr = &wndPtr->class->cbClsExtra; break;
783 case GCL_HMODULE: ptr = &wndPtr->class->hInstance; break;
785 fprintf( stderr, "Warning: invalid offset %d for SetClassLong()\n",
789 retval = GET_DWORD(ptr);
790 PUT_DWORD( ptr, newval );
795 /***********************************************************************
796 * SetClassLong32W (USER32.467)
798 LONG WINAPI SetClassLong32W( HWND32 hwnd, INT32 offset, LONG newval )
806 if (!(wndPtr = WIN_FindWndPtr(hwnd))) return 0;
807 retval = (LONG)WINPROC_GetProc( wndPtr->class->winproc, WIN_PROC_32W );
808 WINPROC_SetProc( &wndPtr->class->winproc, (WNDPROC16)newval,
809 WIN_PROC_32W, WIN_PROC_CLASS );
812 if (!(wndPtr = WIN_FindWndPtr(hwnd))) return 0;
813 CLASS_SetMenuNameW( wndPtr->class, (LPCWSTR)newval );
814 return 0; /* Old value is now meaningless anyway */
816 return SetClassLong32A( hwnd, offset, newval );
821 /***********************************************************************
822 * GetClassName16 (USER.58)
824 INT16 WINAPI GetClassName16( HWND16 hwnd, LPSTR buffer, INT16 count )
827 if (!(wndPtr = WIN_FindWndPtr(hwnd))) return 0;
828 return GlobalGetAtomName16( wndPtr->class->atomName, buffer, count );
832 /***********************************************************************
833 * GetClassName32A (USER32.216)
835 INT32 WINAPI GetClassName32A( HWND32 hwnd, LPSTR buffer, INT32 count )
838 if (!(wndPtr = WIN_FindWndPtr(hwnd))) return 0;
839 return GlobalGetAtomName32A( wndPtr->class->atomName, buffer, count );
843 /***********************************************************************
844 * GetClassName32W (USER32.217)
846 INT32 WINAPI GetClassName32W( HWND32 hwnd, LPWSTR buffer, INT32 count )
849 if (!(wndPtr = WIN_FindWndPtr(hwnd))) return 0;
850 return GlobalGetAtomName32W( wndPtr->class->atomName, buffer, count );
854 /***********************************************************************
855 * GetClassInfo16 (USER.404)
857 BOOL16 WINAPI GetClassInfo16( HINSTANCE16 hInstance, SEGPTR name,
863 hInstance = GetExePtr( hInstance );
864 if (!(atom = GlobalFindAtom16( name )) ||
865 !(classPtr = CLASS_FindClassByAtom( atom, hInstance )))
867 if ((hInstance != classPtr->hInstance) &&
868 !(classPtr->style & CS_GLOBALCLASS)) /*BWCC likes to pass hInstance=0*/
870 wc->style = (UINT16)classPtr->style;
871 wc->lpfnWndProc = WINPROC_GetProc( classPtr->winproc, WIN_PROC_16 );
872 wc->cbClsExtra = (INT16)classPtr->cbClsExtra;
873 wc->cbWndExtra = (INT16)classPtr->cbWndExtra;
874 wc->hInstance = (HINSTANCE16)classPtr->hInstance;
875 wc->hIcon = classPtr->hIcon;
876 wc->hCursor = classPtr->hCursor;
877 wc->hbrBackground = classPtr->hbrBackground;
878 wc->lpszClassName = (SEGPTR)0;
879 wc->lpszMenuName = (SEGPTR)CLASS_GetMenuNameA( classPtr );
880 if (HIWORD(wc->lpszMenuName)) /* Make it a SEGPTR */
881 wc->lpszMenuName = SEGPTR_GET( (LPSTR)wc->lpszMenuName );
886 /***********************************************************************
887 * GetClassInfo32A (USER32.210)
889 BOOL32 WINAPI GetClassInfo32A( HINSTANCE32 hInstance, LPCSTR name,
895 if (!(atom = GlobalFindAtom32A( name )) ||
896 !(classPtr = CLASS_FindClassByAtom( atom, hInstance )) ||
897 (classPtr->hInstance && (hInstance != classPtr->hInstance)))
900 wc->style = classPtr->style;
901 wc->lpfnWndProc = (WNDPROC32)WINPROC_GetProc( classPtr->winproc,
903 wc->cbClsExtra = classPtr->cbClsExtra;
904 wc->cbWndExtra = classPtr->cbWndExtra;
905 wc->hInstance = classPtr->hInstance;
906 wc->hIcon = (HICON32)classPtr->hIcon;
907 wc->hCursor = (HCURSOR32)classPtr->hCursor;
908 wc->hbrBackground = (HBRUSH32)classPtr->hbrBackground;
909 wc->lpszMenuName = CLASS_GetMenuNameA( classPtr );
910 wc->lpszClassName = NULL;
915 /***********************************************************************
916 * GetClassInfo32W (USER32.213)
918 BOOL32 WINAPI GetClassInfo32W( HINSTANCE32 hInstance, LPCWSTR name,
924 if (!(atom = GlobalFindAtom32W( name )) ||
925 !(classPtr = CLASS_FindClassByAtom( atom, hInstance )) ||
926 (classPtr->hInstance && (hInstance != classPtr->hInstance)))
929 wc->style = classPtr->style;
930 wc->lpfnWndProc = (WNDPROC32)WINPROC_GetProc( classPtr->winproc,
932 wc->cbClsExtra = classPtr->cbClsExtra;
933 wc->cbWndExtra = classPtr->cbWndExtra;
934 wc->hInstance = classPtr->hInstance;
935 wc->hIcon = (HICON32)classPtr->hIcon;
936 wc->hCursor = (HCURSOR32)classPtr->hCursor;
937 wc->hbrBackground = (HBRUSH32)classPtr->hbrBackground;
938 wc->lpszMenuName = CLASS_GetMenuNameW( classPtr );
939 wc->lpszClassName = NULL;
944 /***********************************************************************
945 * GetClassInfoEx16 (USER.398)
947 * FIXME: this is just a guess, I have no idea if GetClassInfoEx() is the
948 * same in Win16 as in Win32. --AJ
950 BOOL16 WINAPI GetClassInfoEx16( HINSTANCE16 hInstance, SEGPTR name,
956 hInstance = GetExePtr( hInstance );
957 if (!(atom = GlobalFindAtom16( name )) ||
958 !(classPtr = CLASS_FindClassByAtom( atom, hInstance )) ||
959 (hInstance != classPtr->hInstance)) return FALSE;
960 wc->style = classPtr->style;
961 wc->lpfnWndProc = WINPROC_GetProc( classPtr->winproc, WIN_PROC_16 );
962 wc->cbClsExtra = (INT16)classPtr->cbClsExtra;
963 wc->cbWndExtra = (INT16)classPtr->cbWndExtra;
964 wc->hInstance = (HINSTANCE16)classPtr->hInstance;
965 wc->hIcon = classPtr->hIcon;
966 wc->hIconSm = classPtr->hIconSm;
967 wc->hCursor = classPtr->hCursor;
968 wc->hbrBackground = classPtr->hbrBackground;
969 wc->lpszClassName = (SEGPTR)0;
970 wc->lpszMenuName = (SEGPTR)CLASS_GetMenuNameA( classPtr );
971 if (HIWORD(wc->lpszMenuName)) /* Make it a SEGPTR */
972 wc->lpszMenuName = SEGPTR_GET( (LPSTR)wc->lpszMenuName );
977 /***********************************************************************
978 * GetClassInfoEx32A (USER32.211)
980 BOOL32 WINAPI GetClassInfoEx32A( HINSTANCE32 hInstance, LPCSTR name,
986 if (!(atom = GlobalFindAtom32A( name )) ||
987 !(classPtr = CLASS_FindClassByAtom( atom, hInstance )) ||
988 (hInstance != classPtr->hInstance)) return FALSE;
989 wc->style = classPtr->style;
990 wc->lpfnWndProc = (WNDPROC32)WINPROC_GetProc( classPtr->winproc,
992 wc->cbClsExtra = classPtr->cbClsExtra;
993 wc->cbWndExtra = classPtr->cbWndExtra;
994 wc->hInstance = classPtr->hInstance;
995 wc->hIcon = (HICON32)classPtr->hIcon;
996 wc->hIconSm = (HICON32)classPtr->hIconSm;
997 wc->hCursor = (HCURSOR32)classPtr->hCursor;
998 wc->hbrBackground = (HBRUSH32)classPtr->hbrBackground;
999 wc->lpszMenuName = CLASS_GetMenuNameA( classPtr );
1000 wc->lpszClassName = NULL;
1005 /***********************************************************************
1006 * GetClassInfoEx32W (USER32.212)
1008 BOOL32 WINAPI GetClassInfoEx32W( HINSTANCE32 hInstance, LPCWSTR name,
1014 if (!(atom = GlobalFindAtom32W( name )) ||
1015 !(classPtr = CLASS_FindClassByAtom( atom, hInstance )) ||
1016 (hInstance != classPtr->hInstance)) return FALSE;
1017 wc->style = classPtr->style;
1018 wc->lpfnWndProc = (WNDPROC32)WINPROC_GetProc( classPtr->winproc,
1020 wc->cbClsExtra = classPtr->cbClsExtra;
1021 wc->cbWndExtra = classPtr->cbWndExtra;
1022 wc->hInstance = classPtr->hInstance;
1023 wc->hIcon = (HICON32)classPtr->hIcon;
1024 wc->hIconSm = (HICON32)classPtr->hIconSm;
1025 wc->hCursor = (HCURSOR32)classPtr->hCursor;
1026 wc->hbrBackground = (HBRUSH32)classPtr->hbrBackground;
1027 wc->lpszMenuName = CLASS_GetMenuNameW( classPtr );
1028 wc->lpszClassName = NULL;
1033 /***********************************************************************
1034 * ClassFirst (TOOLHELP.69)
1036 BOOL16 WINAPI ClassFirst( CLASSENTRY *pClassEntry )
1038 pClassEntry->wNext = 1;
1039 return ClassNext( pClassEntry );
1043 /***********************************************************************
1044 * ClassNext (TOOLHELP.70)
1046 BOOL16 WINAPI ClassNext( CLASSENTRY *pClassEntry )
1049 CLASS *class = firstClass;
1051 if (!pClassEntry->wNext) return FALSE;
1052 for (i = 1; (i < pClassEntry->wNext) && class; i++) class = class->next;
1055 pClassEntry->wNext = 0;
1058 pClassEntry->hInst = class->hInstance;
1059 pClassEntry->wNext++;
1060 GlobalGetAtomName32A( class->atomName, pClassEntry->szClassName,
1061 sizeof(pClassEntry->szClassName) );