2 * Window classes functions
4 * Copyright 1993, 1996 Alexandre Julliard
23 static CLASS *firstClass = NULL;
26 /***********************************************************************
29 * Dump the content of a class structure to stderr.
31 void CLASS_DumpClass( CLASS *ptr )
36 if (ptr->magic != CLASS_MAGIC)
38 fprintf( stderr, "%p is not a class\n", ptr );
42 GlobalGetAtomName32A( ptr->atomName, className, sizeof(className) );
44 fprintf( stderr, "Class %p:\n", ptr );
46 "next=%p name=%04x '%s' style=%08x wndProc=%08lx\n"
47 "inst=%04x hdce=%04x icon=%04x cursor=%04x bkgnd=%04x\n"
48 "clsExtra=%d winExtra=%d #windows=%d\n",
49 ptr->next, ptr->atomName, className, ptr->style,
50 (DWORD)ptr->lpfnWndProc, ptr->hInstance, ptr->hdce,
51 ptr->hIcon, ptr->hCursor, ptr->hbrBackground,
52 ptr->cbClsExtra, ptr->cbWndExtra, ptr->cWindows );
55 fprintf( stderr, "extra bytes:" );
56 for (i = 0; i < ptr->cbClsExtra; i++)
57 fprintf( stderr, " %02x", *((BYTE *)ptr->wExtra+i) );
58 fprintf( stderr, "\n" );
60 fprintf( stderr, "\n" );
64 /***********************************************************************
67 * Walk the class list and print each class on stderr.
69 void CLASS_WalkClasses(void)
74 fprintf( stderr, " Class Name Style WndProc\n" );
75 for (ptr = firstClass; ptr; ptr = ptr->next)
77 GlobalGetAtomName32A( ptr->atomName, className, sizeof(className) );
78 fprintf( stderr, "%08x %-20.20s %08x %08x\n", (UINT32)ptr, className,
79 ptr->style, (UINT32)ptr->lpfnWndProc );
81 fprintf( stderr, "\n" );
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 if ((classPtr->menuNameA = SEGPTR_ALLOC(
96 STRING32_lstrlenW(classPtr->menuNameW) + 1 )))
97 STRING32_UniToAnsi( classPtr->menuNameA, 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 if ((classPtr->menuNameW = HeapAlloc( SystemHeap, 0,
116 (strlen(classPtr->menuNameA)+1)*sizeof(WCHAR) )))
117 STRING32_AnsiToUni( classPtr->menuNameW, classPtr->menuNameA );
119 return classPtr->menuNameW;
123 /***********************************************************************
126 * Set the menu name in a class structure by copying the string.
128 static void CLASS_SetMenuNameA( CLASS *classPtr, LPCSTR name )
130 if (HIWORD(classPtr->menuNameA)) SEGPTR_FREE( classPtr->menuNameA );
131 if (classPtr->menuNameW) HeapFree( SystemHeap, 0, classPtr->menuNameW );
132 classPtr->menuNameA = SEGPTR_STRDUP( name );
133 classPtr->menuNameW = 0;
137 /***********************************************************************
140 * Set the menu name in a class structure by copying the string.
142 static void CLASS_SetMenuNameW( CLASS *classPtr, LPCWSTR name )
146 CLASS_SetMenuNameA( classPtr, (LPCSTR)name );
149 if (HIWORD(classPtr->menuNameA)) SEGPTR_FREE( classPtr->menuNameA );
150 if (classPtr->menuNameW) HeapFree( SystemHeap, 0, classPtr->menuNameW );
151 if ((classPtr->menuNameW = HeapAlloc( SystemHeap, 0,
152 (STRING32_lstrlenW(name)+1)*sizeof(WCHAR) )))
153 STRING32_lstrcpyW( classPtr->menuNameW, name );
154 classPtr->menuNameA = 0;
158 /***********************************************************************
161 * Set the window procedure and return the old one.
163 static WNDPROC16 CLASS_SetWndProc( CLASS *classPtr, WNDPROC16 proc,
164 WINDOWPROCTYPE type )
166 WNDPROC16 oldProc = classPtr->lpfnWndProc;
167 if (type == WIN_PROC_16) classPtr->lpfnWndProc = proc;
168 else classPtr->lpfnWndProc = WINPROC_AllocWinProc( (WNDPROC32)proc, type );
169 WINPROC_FreeWinProc( oldProc );
174 /***********************************************************************
177 * Free a class structure.
179 static BOOL CLASS_FreeClass( CLASS *classPtr )
183 /* Check if we can remove this class */
185 if (classPtr->cWindows > 0) return FALSE;
187 /* Remove the class from the linked list */
189 for (ppClass = &firstClass; *ppClass; ppClass = &(*ppClass)->next)
190 if (*ppClass == classPtr) break;
193 fprintf(stderr, "ERROR: Class list corrupted\n" );
196 *ppClass = classPtr->next;
198 /* Delete the class */
200 if (classPtr->hdce) DCE_FreeDCE( classPtr->hdce );
201 if (classPtr->hbrBackground) DeleteObject( classPtr->hbrBackground );
202 GlobalDeleteAtom( classPtr->atomName );
203 CLASS_SetMenuNameA( classPtr, NULL );
204 CLASS_SetWndProc( classPtr, (WNDPROC16)0, WIN_PROC_16 );
205 HeapFree( SystemHeap, 0, classPtr );
210 /***********************************************************************
211 * CLASS_FreeModuleClasses
213 void CLASS_FreeModuleClasses( HMODULE hModule )
217 for (ptr = firstClass; ptr; ptr = next)
220 if (ptr->hInstance == hModule) CLASS_FreeClass( ptr );
225 /***********************************************************************
226 * CLASS_FindClassByAtom
228 * Return a pointer to the class.
230 CLASS *CLASS_FindClassByAtom( ATOM atom, HINSTANCE16 hinstance )
234 /* First search task-specific classes */
236 for (class = firstClass; (class); class = class->next)
238 if (class->style & CS_GLOBALCLASS) continue;
239 if ((class->atomName == atom) &&
240 ((hinstance==(HINSTANCE16)0xffff) ||
241 (hinstance == class->hInstance))) return class;
244 /* Then search global classes */
246 for (class = firstClass; (class); class = class->next)
248 if (!(class->style & CS_GLOBALCLASS)) continue;
249 if (class->atomName == atom) return class;
256 /***********************************************************************
257 * CLASS_FindClassByName
259 * Return a pointer to the class.
261 CLASS *CLASS_FindClassByName( SEGPTR name, HINSTANCE hinstance )
265 if (!(atom = GlobalFindAtom16( name ))) return 0;
266 return CLASS_FindClassByAtom( atom, hinstance );
270 /***********************************************************************
271 * CLASS_RegisterClass
273 * The real RegisterClass() functionality.
275 static CLASS *CLASS_RegisterClass( ATOM atom, HINSTANCE32 hInstance,
276 DWORD style, INT32 classExtra,
277 INT32 winExtra, WNDPROC16 wndProc,
278 WINDOWPROCTYPE wndProcType )
282 /* Check if a class with this name already exists */
284 classPtr = CLASS_FindClassByAtom( atom, hInstance );
287 /* Class can be created only if it is local and */
288 /* if the class with the same name is global. */
290 if (style & CS_GLOBALCLASS) return NULL;
291 if (!(classPtr->style & CS_GLOBALCLASS)) return NULL;
294 /* Fix the extra bytes value */
296 if (classExtra < 0) classExtra = 0;
297 else if (classExtra > 40) /* Extra bytes are limited to 40 in Win32 */
298 fprintf(stderr, "Warning: class extra bytes %d is > 40\n", classExtra);
299 if (winExtra < 0) winExtra = 0;
300 else if (winExtra > 40) /* Extra bytes are limited to 40 in Win32 */
301 fprintf( stderr, "Warning: win extra bytes %d is > 40\n", winExtra );
303 /* Create the class */
305 classPtr = (CLASS *)HeapAlloc( SystemHeap, 0, sizeof(CLASS) +
306 classExtra - sizeof(classPtr->wExtra) );
307 if (!classPtr) return NULL;
308 classPtr->next = firstClass;
309 classPtr->magic = CLASS_MAGIC;
310 classPtr->cWindows = 0;
311 classPtr->style = style;
312 classPtr->lpfnWndProc = 0;
313 classPtr->cbWndExtra = winExtra;
314 classPtr->cbClsExtra = classExtra;
315 classPtr->hInstance = hInstance;
316 classPtr->atomName = atom;
317 classPtr->menuNameA = 0;
318 classPtr->menuNameW = 0;
319 classPtr->hdce = (style&CS_CLASSDC) ? DCE_AllocDCE(DCE_CLASS_DC): 0;
320 CLASS_SetWndProc( classPtr, wndProc, wndProcType );
321 /* Other values must be set by caller */
323 if (classExtra) memset( classPtr->wExtra, 0, classExtra );
324 firstClass = classPtr;
329 /***********************************************************************
330 * RegisterClass16 (USER.57)
332 ATOM RegisterClass16( const WNDCLASS16 *wc )
337 HINSTANCE32 hInstance = (HINSTANCE32)GetExePtr( wc->hInstance );
339 if (!(atom = GlobalAddAtom16( wc->lpszClassName ))) return 0;
340 if (!(classPtr = CLASS_RegisterClass( atom, hInstance, wc->style,
341 wc->cbClsExtra, wc->cbWndExtra,
342 wc->lpfnWndProc, WIN_PROC_16 )))
344 GlobalDeleteAtom( atom );
348 dprintf_class( stddeb, "RegisterClass16: atom=%04x wndproc=%08lx hinst=%04x bg=%04x style=%08x clsExt=%d winExt=%d class=%p\n",
349 atom, (DWORD)wc->lpfnWndProc, hInstance,
350 wc->hbrBackground, wc->style, wc->cbClsExtra,
351 wc->cbWndExtra, classPtr );
353 classPtr->hIcon = wc->hIcon;
354 classPtr->hIconSm = 0;
355 classPtr->hCursor = wc->hCursor;
356 classPtr->hbrBackground = wc->hbrBackground;
358 CLASS_SetMenuNameA( classPtr, HIWORD(wc->lpszMenuName) ?
359 PTR_SEG_TO_LIN(wc->lpszMenuName) : (LPCSTR)wc->lpszMenuName );
364 /***********************************************************************
365 * RegisterClass32A (USER32.426)
367 ATOM RegisterClass32A( const WNDCLASS32A* wc )
372 /* FIXME: this should not be necessary for Win32 */
373 HINSTANCE32 hInstance = (HINSTANCE32)GetExePtr( wc->hInstance );
375 if (!(atom = GlobalAddAtom32A( wc->lpszClassName ))) return 0;
376 if (!(classPtr = CLASS_RegisterClass( atom, hInstance, wc->style,
377 wc->cbClsExtra, wc->cbWndExtra,
378 (WNDPROC16)wc->lpfnWndProc,
381 GlobalDeleteAtom( atom );
385 dprintf_class( stddeb, "RegisterClass32A: atom=%04x wndproc=%08lx hinst=%04x bg=%04x style=%08x clsExt=%d winExt=%d class=%p\n",
386 atom, (DWORD)wc->lpfnWndProc, hInstance,
387 wc->hbrBackground, wc->style, wc->cbClsExtra,
388 wc->cbWndExtra, classPtr );
390 classPtr->hIcon = (HICON16)wc->hIcon;
391 classPtr->hIconSm = 0;
392 classPtr->hCursor = (HCURSOR16)wc->hCursor;
393 classPtr->hbrBackground = (HBRUSH16)wc->hbrBackground;
394 CLASS_SetMenuNameA( classPtr, wc->lpszMenuName );
399 /***********************************************************************
400 * RegisterClass32W (USER32.429)
402 ATOM RegisterClass32W( const WNDCLASS32W* wc )
407 /* FIXME: this should not be necessary for Win32 */
408 HINSTANCE32 hInstance = (HINSTANCE32)GetExePtr( wc->hInstance );
410 if (!(atom = GlobalAddAtom32W( wc->lpszClassName ))) return 0;
411 if (!(classPtr = CLASS_RegisterClass( atom, hInstance, wc->style,
412 wc->cbClsExtra, wc->cbWndExtra,
413 (WNDPROC16)wc->lpfnWndProc,
416 GlobalDeleteAtom( atom );
420 dprintf_class( stddeb, "RegisterClass32W: atom=%04x wndproc=%08lx hinst=%04x bg=%04x style=%08x clsExt=%d winExt=%d class=%p\n",
421 atom, (DWORD)wc->lpfnWndProc, hInstance,
422 wc->hbrBackground, wc->style, wc->cbClsExtra,
423 wc->cbWndExtra, classPtr );
425 classPtr->hIcon = (HICON16)wc->hIcon;
426 classPtr->hIconSm = 0;
427 classPtr->hCursor = (HCURSOR16)wc->hCursor;
428 classPtr->hbrBackground = (HBRUSH16)wc->hbrBackground;
429 CLASS_SetMenuNameW( classPtr, wc->lpszMenuName );
434 /***********************************************************************
435 * RegisterClassEx16 (USER.397)
437 ATOM RegisterClassEx16( const WNDCLASSEX16 *wc )
442 HINSTANCE32 hInstance = (HINSTANCE32)GetExePtr( wc->hInstance );
444 if (!(atom = GlobalAddAtom16( wc->lpszClassName ))) return 0;
445 if (!(classPtr = CLASS_RegisterClass( atom, hInstance, wc->style,
446 wc->cbClsExtra, wc->cbWndExtra,
447 wc->lpfnWndProc, WIN_PROC_16 )))
449 GlobalDeleteAtom( atom );
453 dprintf_class( stddeb, "RegisterClassEx16: atom=%04x wndproc=%08lx hinst=%04x bg=%04x style=%08x clsExt=%d winExt=%d class=%p\n",
454 atom, (DWORD)wc->lpfnWndProc, hInstance,
455 wc->hbrBackground, wc->style, wc->cbClsExtra,
456 wc->cbWndExtra, classPtr );
458 classPtr->hIcon = wc->hIcon;
459 classPtr->hIconSm = wc->hIconSm;
460 classPtr->hCursor = wc->hCursor;
461 classPtr->hbrBackground = wc->hbrBackground;
463 CLASS_SetMenuNameA( classPtr, HIWORD(wc->lpszMenuName) ?
464 PTR_SEG_TO_LIN(wc->lpszMenuName) : (LPCSTR)wc->lpszMenuName );
469 /***********************************************************************
470 * RegisterClassEx32A (USER32.427)
472 ATOM RegisterClassEx32A( const WNDCLASSEX32A* wc )
477 /* FIXME: this should not be necessary for Win32 */
478 HINSTANCE32 hInstance = (HINSTANCE32)GetExePtr( wc->hInstance );
480 if (!(atom = GlobalAddAtom32A( wc->lpszClassName ))) return 0;
481 if (!(classPtr = CLASS_RegisterClass( atom, hInstance, wc->style,
482 wc->cbClsExtra, wc->cbWndExtra,
483 (WNDPROC16)wc->lpfnWndProc,
486 GlobalDeleteAtom( atom );
490 dprintf_class( stddeb, "RegisterClassEx32A: atom=%04x wndproc=%08lx hinst=%04x bg=%04x style=%08x clsExt=%d winExt=%d class=%p\n",
491 atom, (DWORD)wc->lpfnWndProc, hInstance,
492 wc->hbrBackground, wc->style, wc->cbClsExtra,
493 wc->cbWndExtra, classPtr );
495 classPtr->hIcon = (HICON16)wc->hIcon;
496 classPtr->hIconSm = (HICON16)wc->hIconSm;
497 classPtr->hCursor = (HCURSOR16)wc->hCursor;
498 classPtr->hbrBackground = (HBRUSH16)wc->hbrBackground;
499 CLASS_SetMenuNameA( classPtr, wc->lpszMenuName );
504 /***********************************************************************
505 * RegisterClassEx32W (USER32.428)
507 ATOM RegisterClassEx32W( const WNDCLASSEX32W* wc )
512 /* FIXME: this should not be necessary for Win32 */
513 HINSTANCE32 hInstance = (HINSTANCE32)GetExePtr( wc->hInstance );
515 if (!(atom = GlobalAddAtom32W( wc->lpszClassName ))) return 0;
516 if (!(classPtr = CLASS_RegisterClass( atom, hInstance, wc->style,
517 wc->cbClsExtra, wc->cbWndExtra,
518 (WNDPROC16)wc->lpfnWndProc,
521 GlobalDeleteAtom( atom );
525 dprintf_class( stddeb, "RegisterClassEx32W: atom=%04x wndproc=%08lx hinst=%04x bg=%04x style=%08x clsExt=%d winExt=%d class=%p\n",
526 atom, (DWORD)wc->lpfnWndProc, hInstance,
527 wc->hbrBackground, wc->style, wc->cbClsExtra,
528 wc->cbWndExtra, classPtr );
530 classPtr->hIcon = (HICON16)wc->hIcon;
531 classPtr->hIconSm = (HICON16)wc->hIconSm;
532 classPtr->hCursor = (HCURSOR16)wc->hCursor;
533 classPtr->hbrBackground = (HBRUSH16)wc->hbrBackground;
534 CLASS_SetMenuNameW( classPtr, wc->lpszMenuName );
539 /***********************************************************************
540 * UnregisterClass16 (USER.403)
542 BOOL16 UnregisterClass16( SEGPTR className, HINSTANCE16 hInstance )
547 hInstance = GetExePtr( hInstance );
548 if (!(atom = GlobalFindAtom16( className ))) return FALSE;
549 if (!(classPtr = CLASS_FindClassByAtom( atom, hInstance )) ||
550 (classPtr->hInstance != hInstance)) return FALSE;
551 return CLASS_FreeClass( classPtr );
555 /***********************************************************************
556 * UnregisterClass32A (USER32.562)
558 BOOL32 UnregisterClass32A( LPCSTR className, HINSTANCE32 hInstance )
563 hInstance = GetExePtr( hInstance ); /* FIXME: not needed in Win32 */
564 if (!(atom = GlobalFindAtom32A( className ))) return FALSE;
565 if (!(classPtr = CLASS_FindClassByAtom( atom, hInstance )) ||
566 (classPtr->hInstance != hInstance)) return FALSE;
567 return CLASS_FreeClass( classPtr );
571 /***********************************************************************
572 * UnregisterClass32W (USER32.563)
574 BOOL32 UnregisterClass32W( LPCWSTR className, HINSTANCE32 hInstance )
579 hInstance = GetExePtr( hInstance ); /* FIXME: not needed in Win32 */
580 if (!(atom = GlobalFindAtom32W( className ))) return FALSE;
581 if (!(classPtr = CLASS_FindClassByAtom( atom, hInstance )) ||
582 (classPtr->hInstance != hInstance)) return FALSE;
583 return CLASS_FreeClass( classPtr );
587 /***********************************************************************
588 * GetClassWord (USER.129) (USER32.218)
590 WORD GetClassWord( HWND32 hwnd, INT32 offset )
594 if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return 0;
597 if (offset <= wndPtr->class->cbClsExtra - sizeof(WORD))
598 return GET_WORD(((char *)wndPtr->class->wExtra) + offset);
602 case GCW_HBRBACKGROUND: return wndPtr->class->hbrBackground;
603 case GCW_HCURSOR: return wndPtr->class->hCursor;
604 case GCW_HICON: return wndPtr->class->hIcon;
605 case GCW_HICONSM: return wndPtr->class->hIconSm;
606 case GCW_ATOM: return wndPtr->class->atomName;
611 return (WORD)GetClassLong32A( hwnd, offset );
613 fprintf(stderr, "Warning: invalid offset %d for GetClassWord()\n", offset);
618 /***********************************************************************
619 * GetClassLong16 (USER.131)
621 LONG GetClassLong16( HWND hwnd, INT16 offset )
623 DWORD ret = GetClassLong32A( hwnd, offset );
624 if ((offset == GCL_MENUNAME) && HIWORD(ret))
625 return (LONG)SEGPTR_GET((void *)ret); /* Name needs to be a SEGPTR */
630 /***********************************************************************
631 * GetClassLong32A (USER32.214)
633 LONG GetClassLong32A( HWND hwnd, INT32 offset )
637 if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return 0;
640 if (offset <= wndPtr->class->cbClsExtra - sizeof(LONG))
641 return GET_DWORD(((char *)wndPtr->class->wExtra) + offset);
645 case GCL_STYLE: return (LONG)wndPtr->class->style;
646 case GCL_CBWNDEXTRA: return (LONG)wndPtr->class->cbWndExtra;
647 case GCL_CBCLSEXTRA: return (LONG)wndPtr->class->cbClsExtra;
648 case GCL_WNDPROC: return (LONG)wndPtr->class->lpfnWndProc;
649 case GCL_HMODULE: return (LONG)wndPtr->class->hInstance;
651 return (LONG)CLASS_GetMenuNameA( wndPtr->class );
652 case GCL_HBRBACKGROUND:
656 return GetClassWord( hwnd, offset );
658 fprintf(stderr, "Warning: invalid offset %d for GetClassLong()\n", offset);
663 /***********************************************************************
664 * GetClassLong32W (USER32.215)
666 LONG GetClassLong32W( HWND hwnd, INT32 offset )
670 if (offset != GCL_MENUNAME) return GetClassLong32A( hwnd, offset );
671 if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return 0;
672 return (LONG)CLASS_GetMenuNameW( wndPtr->class );
676 /***********************************************************************
677 * SetClassWord (USER.130) (USER32.468)
679 WORD SetClassWord( HWND32 hwnd, INT32 offset, WORD newval )
685 if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return 0;
688 if (offset <= wndPtr->class->cbClsExtra - sizeof(WORD))
689 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 SetClassLong16( HWND hwnd, INT16 offset, LONG newval )
729 if (!(wndPtr = WIN_FindWndPtr(hwnd))) return 0;
730 return (LONG)CLASS_SetWndProc( wndPtr->class, (WNDPROC16)newval,
733 return SetClassLong32A( hwnd, offset, (LONG)PTR_SEG_TO_LIN(newval) );
735 return SetClassLong32A( hwnd, offset, newval );
740 /***********************************************************************
741 * SetClassLong32A (USER32.466)
743 LONG SetClassLong32A( HWND hwnd, INT32 offset, LONG newval )
749 if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return 0;
752 if (offset <= wndPtr->class->cbClsExtra - sizeof(LONG))
753 ptr = ((char *)wndPtr->class->wExtra) + offset;
756 fprintf( stderr, "Warning: invalid offset %d for SetClassLong()\n",
764 CLASS_SetMenuNameA( wndPtr->class, (LPCSTR)newval );
765 return 0; /* Old value is now meaningless anyway */
767 return (LONG)CLASS_SetWndProc( wndPtr->class, (WNDPROC16)newval,
769 case GCL_HBRBACKGROUND:
773 return SetClassWord( hwnd, offset, (WORD)newval );
774 case GCL_STYLE: ptr = &wndPtr->class->style; break;
775 case GCL_CBWNDEXTRA: ptr = &wndPtr->class->cbWndExtra; break;
776 case GCL_CBCLSEXTRA: ptr = &wndPtr->class->cbClsExtra; break;
777 case GCL_HMODULE: ptr = &wndPtr->class->hInstance; break;
779 fprintf( stderr, "Warning: invalid offset %d for SetClassLong()\n",
783 retval = GET_DWORD(ptr);
784 PUT_DWORD( ptr, newval );
789 /***********************************************************************
790 * SetClassLong32W (USER32.467)
792 LONG SetClassLong32W( HWND hwnd, INT32 offset, LONG newval )
795 if (!(wndPtr = WIN_FindWndPtr(hwnd))) return 0;
800 return (LONG)CLASS_SetWndProc( wndPtr->class, (WNDPROC16)newval,
803 CLASS_SetMenuNameW( wndPtr->class, (LPCWSTR)newval );
804 return 0; /* Old value is now meaningless anyway */
806 return SetClassLong32A( hwnd, offset, newval );
811 /***********************************************************************
812 * GetClassName16 (USER.58)
814 INT16 GetClassName16( HWND hwnd, LPSTR buffer, INT16 count )
817 if (!(wndPtr = WIN_FindWndPtr(hwnd))) return 0;
818 return GlobalGetAtomName16( wndPtr->class->atomName, buffer, count );
822 /***********************************************************************
823 * GetClassName32A (USER32.216)
825 INT32 GetClassName32A( HWND hwnd, LPSTR buffer, INT32 count )
828 if (!(wndPtr = WIN_FindWndPtr(hwnd))) return 0;
829 return GlobalGetAtomName32A( wndPtr->class->atomName, buffer, count );
833 /***********************************************************************
834 * GetClassName32W (USER32.217)
836 INT32 GetClassName32W( HWND hwnd, LPWSTR buffer, INT32 count )
839 if (!(wndPtr = WIN_FindWndPtr(hwnd))) return 0;
840 return GlobalGetAtomName32W( wndPtr->class->atomName, buffer, count );
844 /***********************************************************************
845 * GetClassInfo16 (USER.404)
847 BOOL GetClassInfo16( HINSTANCE16 hInstance, SEGPTR name, WNDCLASS16 *wc )
852 hInstance = GetExePtr( hInstance );
853 if (!(atom = GlobalFindAtom16( name )) ||
854 !(classPtr = CLASS_FindClassByAtom( atom, hInstance )) ||
855 (hInstance != classPtr->hInstance)) return FALSE;
856 wc->style = (UINT16)classPtr->style;
857 wc->lpfnWndProc = classPtr->lpfnWndProc;
858 wc->cbClsExtra = (INT16)classPtr->cbClsExtra;
859 wc->cbWndExtra = (INT16)classPtr->cbWndExtra;
860 wc->hInstance = (HINSTANCE16)classPtr->hInstance;
861 wc->hIcon = classPtr->hIcon;
862 wc->hCursor = classPtr->hCursor;
863 wc->hbrBackground = classPtr->hbrBackground;
864 wc->lpszClassName = (SEGPTR)0;
865 wc->lpszMenuName = (SEGPTR)CLASS_GetMenuNameA( classPtr );
866 if (HIWORD(wc->lpszMenuName)) /* Make it a SEGPTR */
867 wc->lpszMenuName = SEGPTR_GET( (LPSTR)wc->lpszMenuName );
872 /***********************************************************************
873 * GetClassInfo32A (USER32.210)
875 BOOL GetClassInfo32A( HINSTANCE32 hInstance, LPCSTR name, WNDCLASS32A *wc )
880 hInstance = GetExePtr( hInstance ); /* FIXME: not needed in Win32 */
881 if (!(atom = GlobalFindAtom32A( name )) ||
882 !(classPtr = CLASS_FindClassByAtom( atom, hInstance )) ||
883 (hInstance != classPtr->hInstance)) return FALSE;
884 wc->style = classPtr->style;
885 wc->lpfnWndProc = (WNDPROC32)classPtr->lpfnWndProc;
886 wc->cbClsExtra = classPtr->cbClsExtra;
887 wc->cbWndExtra = classPtr->cbWndExtra;
888 wc->hInstance = classPtr->hInstance;
889 wc->hIcon = (HICON32)classPtr->hIcon;
890 wc->hCursor = (HCURSOR32)classPtr->hCursor;
891 wc->hbrBackground = (HBRUSH32)classPtr->hbrBackground;
892 wc->lpszMenuName = CLASS_GetMenuNameA( classPtr );
893 wc->lpszClassName = NULL;
898 /***********************************************************************
899 * GetClassInfo32W (USER32.213)
901 BOOL GetClassInfo32W( HINSTANCE32 hInstance, LPCWSTR name, WNDCLASS32W *wc )
906 hInstance = GetExePtr( hInstance ); /* FIXME: not needed in Win32 */
907 if (!(atom = GlobalFindAtom32W( name )) ||
908 !(classPtr = CLASS_FindClassByAtom( atom, hInstance )) ||
909 (hInstance != classPtr->hInstance)) return FALSE;
910 wc->style = classPtr->style;
911 wc->lpfnWndProc = (WNDPROC32)classPtr->lpfnWndProc;
912 wc->cbClsExtra = classPtr->cbClsExtra;
913 wc->cbWndExtra = classPtr->cbWndExtra;
914 wc->hInstance = classPtr->hInstance;
915 wc->hIcon = (HICON32)classPtr->hIcon;
916 wc->hCursor = (HCURSOR32)classPtr->hCursor;
917 wc->hbrBackground = (HBRUSH32)classPtr->hbrBackground;
918 wc->lpszMenuName = CLASS_GetMenuNameW( classPtr );
919 wc->lpszClassName = NULL;
924 /***********************************************************************
925 * GetClassInfoEx16 (USER.398)
927 * FIXME: this is just a guess, I have no idea if GetClassInfoEx() is the
928 * same in Win16 as in Win32. --AJ
930 BOOL GetClassInfoEx16( HINSTANCE16 hInstance, SEGPTR name, WNDCLASSEX16 *wc )
935 hInstance = GetExePtr( hInstance );
936 if (!(atom = GlobalFindAtom16( name )) ||
937 !(classPtr = CLASS_FindClassByAtom( atom, hInstance )) ||
938 (hInstance != classPtr->hInstance)) return FALSE;
939 wc->style = classPtr->style;
940 wc->lpfnWndProc = classPtr->lpfnWndProc;
941 wc->cbClsExtra = (INT16)classPtr->cbClsExtra;
942 wc->cbWndExtra = (INT16)classPtr->cbWndExtra;
943 wc->hInstance = (HINSTANCE16)classPtr->hInstance;
944 wc->hIcon = classPtr->hIcon;
945 wc->hIconSm = classPtr->hIconSm;
946 wc->hCursor = classPtr->hCursor;
947 wc->hbrBackground = classPtr->hbrBackground;
948 wc->lpszClassName = (SEGPTR)0;
949 wc->lpszMenuName = (SEGPTR)CLASS_GetMenuNameA( classPtr );
950 if (HIWORD(wc->lpszMenuName)) /* Make it a SEGPTR */
951 wc->lpszMenuName = SEGPTR_GET( (LPSTR)wc->lpszMenuName );
956 /***********************************************************************
957 * GetClassInfoEx32A (USER32.211)
959 BOOL GetClassInfoEx32A( HINSTANCE32 hInstance, LPCSTR name, WNDCLASSEX32A *wc )
964 hInstance = GetExePtr( hInstance ); /* FIXME: not needed in Win32 */
965 if (!(atom = GlobalFindAtom32A( name )) ||
966 !(classPtr = CLASS_FindClassByAtom( atom, hInstance )) ||
967 (hInstance != classPtr->hInstance)) return FALSE;
968 wc->style = classPtr->style;
969 wc->lpfnWndProc = (WNDPROC32)classPtr->lpfnWndProc;
970 wc->cbClsExtra = classPtr->cbClsExtra;
971 wc->cbWndExtra = classPtr->cbWndExtra;
972 wc->hInstance = classPtr->hInstance;
973 wc->hIcon = (HICON32)classPtr->hIcon;
974 wc->hIconSm = (HICON32)classPtr->hIconSm;
975 wc->hCursor = (HCURSOR32)classPtr->hCursor;
976 wc->hbrBackground = (HBRUSH32)classPtr->hbrBackground;
977 wc->lpszMenuName = CLASS_GetMenuNameA( classPtr );
978 wc->lpszClassName = NULL;
983 /***********************************************************************
984 * GetClassInfoEx32W (USER32.212)
986 BOOL GetClassInfoEx32W( HINSTANCE32 hInstance, LPCWSTR name, WNDCLASSEX32W *wc)
991 hInstance = GetExePtr( hInstance ); /* FIXME: not needed in Win32 */
992 if (!(atom = GlobalFindAtom32W( name )) ||
993 !(classPtr = CLASS_FindClassByAtom( atom, hInstance )) ||
994 (hInstance != classPtr->hInstance)) return FALSE;
995 wc->style = classPtr->style;
996 wc->lpfnWndProc = (WNDPROC32)classPtr->lpfnWndProc;
997 wc->cbClsExtra = classPtr->cbClsExtra;
998 wc->cbWndExtra = classPtr->cbWndExtra;
999 wc->hInstance = classPtr->hInstance;
1000 wc->hIcon = (HICON32)classPtr->hIcon;
1001 wc->hIconSm = (HICON32)classPtr->hIconSm;
1002 wc->hCursor = (HCURSOR32)classPtr->hCursor;
1003 wc->hbrBackground = (HBRUSH32)classPtr->hbrBackground;
1004 wc->lpszMenuName = CLASS_GetMenuNameW( classPtr );
1005 wc->lpszClassName = NULL;
1010 /***********************************************************************
1011 * ClassFirst (TOOLHELP.69)
1013 BOOL ClassFirst( CLASSENTRY *pClassEntry )
1015 pClassEntry->wNext = 1;
1016 return ClassNext( pClassEntry );
1020 /***********************************************************************
1021 * ClassNext (TOOLHELP.70)
1023 BOOL ClassNext( CLASSENTRY *pClassEntry )
1026 CLASS *class = firstClass;
1028 if (!pClassEntry->wNext) return FALSE;
1029 for (i = 1; (i < pClassEntry->wNext) && class; i++) class = class->next;
1032 pClassEntry->wNext = 0;
1035 pClassEntry->hInst = class->hInstance;
1036 pClassEntry->wNext++;
1037 GlobalGetAtomName32A( class->atomName, pClassEntry->szClassName,
1038 sizeof(pClassEntry->szClassName) );