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=%08x\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 (UINT32)ptr->winproc, 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->winproc );
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 lstrlen32W(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 (lstrlen32W(name)+1)*sizeof(WCHAR) )))
153 lstrcpy32W( classPtr->menuNameW, name );
154 classPtr->menuNameA = 0;
158 /***********************************************************************
161 * Free a class structure.
163 static BOOL CLASS_FreeClass( CLASS *classPtr )
167 /* Check if we can remove this class */
169 if (classPtr->cWindows > 0) return FALSE;
171 /* Remove the class from the linked list */
173 for (ppClass = &firstClass; *ppClass; ppClass = &(*ppClass)->next)
174 if (*ppClass == classPtr) break;
177 fprintf(stderr, "ERROR: Class list corrupted\n" );
180 *ppClass = classPtr->next;
182 /* Delete the class */
184 if (classPtr->hdce) DCE_FreeDCE( classPtr->hdce );
185 if (classPtr->hbrBackground) DeleteObject( classPtr->hbrBackground );
186 GlobalDeleteAtom( classPtr->atomName );
187 CLASS_SetMenuNameA( classPtr, NULL );
188 WINPROC_FreeProc( classPtr->winproc );
189 HeapFree( SystemHeap, 0, classPtr );
194 /***********************************************************************
195 * CLASS_FreeModuleClasses
197 void CLASS_FreeModuleClasses( HMODULE16 hModule )
201 for (ptr = firstClass; ptr; ptr = next)
204 if (ptr->hInstance == hModule) CLASS_FreeClass( ptr );
209 /***********************************************************************
210 * CLASS_FindClassByAtom
212 * Return a pointer to the class.
214 CLASS *CLASS_FindClassByAtom( ATOM atom, HINSTANCE16 hinstance )
218 if (hinstance != 0xffff) hinstance = GetExePtr(hinstance);
220 /* First search task-specific classes */
222 for (class = firstClass; (class); class = class->next)
224 if (class->style & CS_GLOBALCLASS) continue;
225 if ((class->atomName == atom) &&
226 ((hinstance == 0xffff) ||
227 (hinstance == class->hInstance))) return class;
230 /* Then search global classes */
232 for (class = firstClass; (class); class = class->next)
234 if (!(class->style & CS_GLOBALCLASS)) continue;
235 if (class->atomName == atom) return class;
242 /***********************************************************************
243 * CLASS_RegisterClass
245 * The real RegisterClass() functionality.
247 static CLASS *CLASS_RegisterClass( ATOM atom, HINSTANCE32 hInstance,
248 DWORD style, INT32 classExtra,
249 INT32 winExtra, WNDPROC16 wndProc,
250 WINDOWPROCTYPE wndProcType )
254 /* Check if a class with this name already exists */
256 classPtr = CLASS_FindClassByAtom( atom, hInstance );
259 /* Class can be created only if it is local and */
260 /* if the class with the same name is global. */
262 if (style & CS_GLOBALCLASS) return NULL;
263 if (!(classPtr->style & CS_GLOBALCLASS)) return NULL;
266 /* Fix the extra bytes value */
268 if (classExtra < 0) classExtra = 0;
269 else if (classExtra > 40) /* Extra bytes are limited to 40 in Win32 */
270 fprintf(stderr, "Warning: class extra bytes %d is > 40\n", classExtra);
271 if (winExtra < 0) winExtra = 0;
272 else if (winExtra > 40) /* Extra bytes are limited to 40 in Win32 */
273 fprintf( stderr, "Warning: win extra bytes %d is > 40\n", winExtra );
275 /* Create the class */
277 classPtr = (CLASS *)HeapAlloc( SystemHeap, 0, sizeof(CLASS) +
278 classExtra - sizeof(classPtr->wExtra) );
279 if (!classPtr) return NULL;
280 classPtr->next = firstClass;
281 classPtr->magic = CLASS_MAGIC;
282 classPtr->cWindows = 0;
283 classPtr->style = style;
284 classPtr->winproc = (HWINDOWPROC)0;
285 classPtr->cbWndExtra = winExtra;
286 classPtr->cbClsExtra = classExtra;
287 classPtr->hInstance = hInstance;
288 classPtr->atomName = atom;
289 classPtr->menuNameA = 0;
290 classPtr->menuNameW = 0;
291 classPtr->hdce = (style&CS_CLASSDC) ? DCE_AllocDCE(0, DCE_CLASS_DC): 0;
292 WINPROC_SetProc( &classPtr->winproc, wndProc, wndProcType );
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 RegisterClass16( const WNDCLASS16 *wc )
310 HINSTANCE32 hInstance = (HINSTANCE32)GetExePtr( wc->hInstance );
312 if (!(atom = GlobalAddAtom16( wc->lpszClassName ))) return 0;
313 if (!(classPtr = CLASS_RegisterClass( atom, hInstance, wc->style,
314 wc->cbClsExtra, wc->cbWndExtra,
315 wc->lpfnWndProc, WIN_PROC_16 )))
317 GlobalDeleteAtom( atom );
321 dprintf_class( stddeb, "RegisterClass16: atom=%04x wndproc=%08lx hinst=%04x bg=%04x style=%08x clsExt=%d winExt=%d class=%p\n",
322 atom, (DWORD)wc->lpfnWndProc, hInstance,
323 wc->hbrBackground, wc->style, wc->cbClsExtra,
324 wc->cbWndExtra, classPtr );
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.426)
340 ATOM RegisterClass32A( const WNDCLASS32A* wc )
345 /* FIXME: this should not be necessary for Win32 */
346 HINSTANCE32 hInstance = (HINSTANCE32)GetExePtr( wc->hInstance );
348 if (!(atom = GlobalAddAtom32A( wc->lpszClassName ))) return 0;
349 if (!(classPtr = CLASS_RegisterClass( atom, hInstance, wc->style,
350 wc->cbClsExtra, wc->cbWndExtra,
351 (WNDPROC16)wc->lpfnWndProc,
354 GlobalDeleteAtom( atom );
358 dprintf_class( stddeb, "RegisterClass32A: atom=%04x wndproc=%08lx hinst=%04x bg=%04x style=%08x clsExt=%d winExt=%d class=%p\n",
359 atom, (DWORD)wc->lpfnWndProc, hInstance,
360 wc->hbrBackground, wc->style, wc->cbClsExtra,
361 wc->cbWndExtra, classPtr );
363 classPtr->hIcon = (HICON16)wc->hIcon;
364 classPtr->hIconSm = 0;
365 classPtr->hCursor = (HCURSOR16)wc->hCursor;
366 classPtr->hbrBackground = (HBRUSH16)wc->hbrBackground;
367 CLASS_SetMenuNameA( classPtr, wc->lpszMenuName );
372 /***********************************************************************
373 * RegisterClass32W (USER32.429)
375 ATOM RegisterClass32W( const WNDCLASS32W* wc )
380 /* FIXME: this should not be necessary for Win32 */
381 HINSTANCE32 hInstance = (HINSTANCE32)GetExePtr( wc->hInstance );
383 if (!(atom = GlobalAddAtom32W( wc->lpszClassName ))) return 0;
384 if (!(classPtr = CLASS_RegisterClass( atom, hInstance, wc->style,
385 wc->cbClsExtra, wc->cbWndExtra,
386 (WNDPROC16)wc->lpfnWndProc,
389 GlobalDeleteAtom( atom );
393 dprintf_class( stddeb, "RegisterClass32W: atom=%04x wndproc=%08lx hinst=%04x bg=%04x style=%08x clsExt=%d winExt=%d class=%p\n",
394 atom, (DWORD)wc->lpfnWndProc, 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 RegisterClassEx16( const WNDCLASSEX16 *wc )
415 HINSTANCE32 hInstance = (HINSTANCE32)GetExePtr( wc->hInstance );
417 if (!(atom = GlobalAddAtom16( wc->lpszClassName ))) return 0;
418 if (!(classPtr = CLASS_RegisterClass( atom, hInstance, wc->style,
419 wc->cbClsExtra, wc->cbWndExtra,
420 wc->lpfnWndProc, WIN_PROC_16 )))
422 GlobalDeleteAtom( atom );
426 dprintf_class( stddeb, "RegisterClassEx16: atom=%04x wndproc=%08lx hinst=%04x bg=%04x style=%08x clsExt=%d winExt=%d class=%p\n",
427 atom, (DWORD)wc->lpfnWndProc, hInstance,
428 wc->hbrBackground, wc->style, wc->cbClsExtra,
429 wc->cbWndExtra, classPtr );
431 classPtr->hIcon = wc->hIcon;
432 classPtr->hIconSm = wc->hIconSm;
433 classPtr->hCursor = wc->hCursor;
434 classPtr->hbrBackground = wc->hbrBackground;
436 CLASS_SetMenuNameA( classPtr, HIWORD(wc->lpszMenuName) ?
437 PTR_SEG_TO_LIN(wc->lpszMenuName) : (LPCSTR)wc->lpszMenuName );
442 /***********************************************************************
443 * RegisterClassEx32A (USER32.427)
445 ATOM RegisterClassEx32A( const WNDCLASSEX32A* wc )
450 /* FIXME: this should not be necessary for Win32 */
451 HINSTANCE32 hInstance = (HINSTANCE32)GetExePtr( wc->hInstance );
453 if (!(atom = GlobalAddAtom32A( wc->lpszClassName ))) return 0;
454 if (!(classPtr = CLASS_RegisterClass( atom, hInstance, wc->style,
455 wc->cbClsExtra, wc->cbWndExtra,
456 (WNDPROC16)wc->lpfnWndProc,
459 GlobalDeleteAtom( atom );
463 dprintf_class( stddeb, "RegisterClassEx32A: atom=%04x wndproc=%08lx hinst=%04x bg=%04x style=%08x clsExt=%d winExt=%d class=%p\n",
464 atom, (DWORD)wc->lpfnWndProc, hInstance,
465 wc->hbrBackground, wc->style, wc->cbClsExtra,
466 wc->cbWndExtra, classPtr );
468 classPtr->hIcon = (HICON16)wc->hIcon;
469 classPtr->hIconSm = (HICON16)wc->hIconSm;
470 classPtr->hCursor = (HCURSOR16)wc->hCursor;
471 classPtr->hbrBackground = (HBRUSH16)wc->hbrBackground;
472 CLASS_SetMenuNameA( classPtr, wc->lpszMenuName );
477 /***********************************************************************
478 * RegisterClassEx32W (USER32.428)
480 ATOM RegisterClassEx32W( const WNDCLASSEX32W* wc )
485 /* FIXME: this should not be necessary for Win32 */
486 HINSTANCE32 hInstance = (HINSTANCE32)GetExePtr( wc->hInstance );
488 if (!(atom = GlobalAddAtom32W( wc->lpszClassName ))) return 0;
489 if (!(classPtr = CLASS_RegisterClass( atom, hInstance, wc->style,
490 wc->cbClsExtra, wc->cbWndExtra,
491 (WNDPROC16)wc->lpfnWndProc,
494 GlobalDeleteAtom( atom );
498 dprintf_class( stddeb, "RegisterClassEx32W: atom=%04x wndproc=%08lx hinst=%04x bg=%04x style=%08x clsExt=%d winExt=%d class=%p\n",
499 atom, (DWORD)wc->lpfnWndProc, hInstance,
500 wc->hbrBackground, wc->style, wc->cbClsExtra,
501 wc->cbWndExtra, classPtr );
503 classPtr->hIcon = (HICON16)wc->hIcon;
504 classPtr->hIconSm = (HICON16)wc->hIconSm;
505 classPtr->hCursor = (HCURSOR16)wc->hCursor;
506 classPtr->hbrBackground = (HBRUSH16)wc->hbrBackground;
507 CLASS_SetMenuNameW( classPtr, wc->lpszMenuName );
512 /***********************************************************************
513 * UnregisterClass16 (USER.403)
515 BOOL16 UnregisterClass16( SEGPTR className, HINSTANCE16 hInstance )
520 hInstance = GetExePtr( hInstance );
521 if (!(atom = GlobalFindAtom16( className ))) return FALSE;
522 if (!(classPtr = CLASS_FindClassByAtom( atom, hInstance )) ||
523 (classPtr->hInstance != hInstance)) return FALSE;
524 return CLASS_FreeClass( classPtr );
528 /***********************************************************************
529 * UnregisterClass32A (USER32.562)
531 BOOL32 UnregisterClass32A( LPCSTR className, HINSTANCE32 hInstance )
536 hInstance = GetExePtr( hInstance ); /* FIXME: not needed in Win32 */
537 if (!(atom = GlobalFindAtom32A( className ))) return FALSE;
538 if (!(classPtr = CLASS_FindClassByAtom( atom, hInstance )) ||
539 (classPtr->hInstance != hInstance)) return FALSE;
540 return CLASS_FreeClass( classPtr );
544 /***********************************************************************
545 * UnregisterClass32W (USER32.563)
547 BOOL32 UnregisterClass32W( LPCWSTR className, HINSTANCE32 hInstance )
552 hInstance = GetExePtr( hInstance ); /* FIXME: not needed in Win32 */
553 if (!(atom = GlobalFindAtom32W( className ))) return FALSE;
554 if (!(classPtr = CLASS_FindClassByAtom( atom, hInstance )) ||
555 (classPtr->hInstance != hInstance)) return FALSE;
556 return CLASS_FreeClass( classPtr );
560 /***********************************************************************
561 * GetClassWord (USER.129) (USER32.218)
563 WORD GetClassWord( 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 fprintf(stderr, "Warning: invalid offset %d for GetClassWord()\n", offset);
591 /***********************************************************************
592 * GetClassLong16 (USER.131)
594 LONG 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.214)
616 LONG 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 GetClassWord( hwnd, offset );
642 fprintf(stderr, "Warning: invalid offset %d for GetClassLong()\n", offset);
647 /***********************************************************************
648 * GetClassLong32W (USER32.215)
650 LONG 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 * SetClassWord (USER.130) (USER32.468)
671 WORD SetClassWord( HWND32 hwnd, INT32 offset, WORD newval )
677 if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return 0;
680 if (offset + sizeof(WORD) <= wndPtr->class->cbClsExtra)
681 ptr = ((char *)wndPtr->class->wExtra) + offset;
684 fprintf( stderr, "Warning: invalid offset %d for SetClassWord()\n",
695 return (WORD)SetClassLong32A( hwnd, offset, (LONG)newval );
696 case GCW_HBRBACKGROUND: ptr = &wndPtr->class->hbrBackground; break;
697 case GCW_HCURSOR: ptr = &wndPtr->class->hCursor; break;
698 case GCW_HICON: ptr = &wndPtr->class->hIcon; break;
699 case GCW_HICONSM: ptr = &wndPtr->class->hIconSm; break;
700 case GCW_ATOM: ptr = &wndPtr->class->atomName; break;
702 fprintf( stderr, "Warning: invalid offset %d for SetClassWord()\n",
706 retval = GET_WORD(ptr);
707 PUT_WORD( ptr, newval );
712 /***********************************************************************
713 * SetClassLong16 (USER.132)
715 LONG SetClassLong16( HWND16 hwnd, INT16 offset, LONG newval )
723 if (!(wndPtr = WIN_FindWndPtr(hwnd))) return 0;
724 retval = (LONG)WINPROC_GetProc( wndPtr->class->winproc, WIN_PROC_16 );
725 WINPROC_SetProc( &wndPtr->class->winproc, (WNDPROC16)newval,
729 return SetClassLong32A( hwnd, offset, (LONG)PTR_SEG_TO_LIN(newval) );
731 return SetClassLong32A( hwnd, offset, newval );
736 /***********************************************************************
737 * SetClassLong32A (USER32.466)
739 LONG SetClassLong32A( HWND32 hwnd, INT32 offset, LONG newval )
745 if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return 0;
748 if (offset + sizeof(LONG) <= wndPtr->class->cbClsExtra)
749 ptr = ((char *)wndPtr->class->wExtra) + offset;
752 fprintf( stderr, "Warning: invalid offset %d for SetClassLong()\n",
760 CLASS_SetMenuNameA( wndPtr->class, (LPCSTR)newval );
761 return 0; /* Old value is now meaningless anyway */
763 retval = (LONG)WINPROC_GetProc( wndPtr->class->winproc,
765 WINPROC_SetProc( &wndPtr->class->winproc, (WNDPROC16)newval,
768 case GCL_HBRBACKGROUND:
772 return SetClassWord( hwnd, offset, (WORD)newval );
773 case GCL_STYLE: ptr = &wndPtr->class->style; break;
774 case GCL_CBWNDEXTRA: ptr = &wndPtr->class->cbWndExtra; break;
775 case GCL_CBCLSEXTRA: ptr = &wndPtr->class->cbClsExtra; break;
776 case GCL_HMODULE: ptr = &wndPtr->class->hInstance; break;
778 fprintf( stderr, "Warning: invalid offset %d for SetClassLong()\n",
782 retval = GET_DWORD(ptr);
783 PUT_DWORD( ptr, newval );
788 /***********************************************************************
789 * SetClassLong32W (USER32.467)
791 LONG SetClassLong32W( HWND32 hwnd, INT32 offset, LONG newval )
799 if (!(wndPtr = WIN_FindWndPtr(hwnd))) return 0;
800 retval = (LONG)WINPROC_GetProc( wndPtr->class->winproc, WIN_PROC_32W );
801 WINPROC_SetProc( &wndPtr->class->winproc, (WNDPROC16)newval,
805 if (!(wndPtr = WIN_FindWndPtr(hwnd))) return 0;
806 CLASS_SetMenuNameW( wndPtr->class, (LPCWSTR)newval );
807 return 0; /* Old value is now meaningless anyway */
809 return SetClassLong32A( hwnd, offset, newval );
814 /***********************************************************************
815 * GetClassName16 (USER.58)
817 INT16 GetClassName16( HWND16 hwnd, LPSTR buffer, INT16 count )
820 if (!(wndPtr = WIN_FindWndPtr(hwnd))) return 0;
821 return GlobalGetAtomName16( wndPtr->class->atomName, buffer, count );
825 /***********************************************************************
826 * GetClassName32A (USER32.216)
828 INT32 GetClassName32A( HWND32 hwnd, LPSTR buffer, INT32 count )
831 if (!(wndPtr = WIN_FindWndPtr(hwnd))) return 0;
832 return GlobalGetAtomName32A( wndPtr->class->atomName, buffer, count );
836 /***********************************************************************
837 * GetClassName32W (USER32.217)
839 INT32 GetClassName32W( HWND32 hwnd, LPWSTR buffer, INT32 count )
842 if (!(wndPtr = WIN_FindWndPtr(hwnd))) return 0;
843 return GlobalGetAtomName32W( wndPtr->class->atomName, buffer, count );
847 /***********************************************************************
848 * GetClassInfo16 (USER.404)
850 BOOL16 GetClassInfo16( HINSTANCE16 hInstance, SEGPTR name, WNDCLASS16 *wc )
855 hInstance = GetExePtr( hInstance );
856 if (!(atom = GlobalFindAtom16( name )) ||
857 !(classPtr = CLASS_FindClassByAtom( atom, hInstance )) ||
858 (hInstance != classPtr->hInstance)) return FALSE;
859 wc->style = (UINT16)classPtr->style;
860 wc->lpfnWndProc = WINPROC_GetProc( classPtr->winproc, WIN_PROC_16 );
861 wc->cbClsExtra = (INT16)classPtr->cbClsExtra;
862 wc->cbWndExtra = (INT16)classPtr->cbWndExtra;
863 wc->hInstance = (HINSTANCE16)classPtr->hInstance;
864 wc->hIcon = classPtr->hIcon;
865 wc->hCursor = classPtr->hCursor;
866 wc->hbrBackground = classPtr->hbrBackground;
867 wc->lpszClassName = (SEGPTR)0;
868 wc->lpszMenuName = (SEGPTR)CLASS_GetMenuNameA( classPtr );
869 if (HIWORD(wc->lpszMenuName)) /* Make it a SEGPTR */
870 wc->lpszMenuName = SEGPTR_GET( (LPSTR)wc->lpszMenuName );
875 /***********************************************************************
876 * GetClassInfo32A (USER32.210)
878 BOOL32 GetClassInfo32A( HINSTANCE32 hInstance, LPCSTR name, WNDCLASS32A *wc )
883 hInstance = GetExePtr( hInstance ); /* FIXME: not needed in Win32 */
884 if (!(atom = GlobalFindAtom32A( name )) ||
885 !(classPtr = CLASS_FindClassByAtom( atom, hInstance )) ||
886 (hInstance != classPtr->hInstance)) return FALSE;
887 wc->style = classPtr->style;
888 wc->lpfnWndProc = (WNDPROC32)WINPROC_GetProc( classPtr->winproc,
890 wc->cbClsExtra = classPtr->cbClsExtra;
891 wc->cbWndExtra = classPtr->cbWndExtra;
892 wc->hInstance = classPtr->hInstance;
893 wc->hIcon = (HICON32)classPtr->hIcon;
894 wc->hCursor = (HCURSOR32)classPtr->hCursor;
895 wc->hbrBackground = (HBRUSH32)classPtr->hbrBackground;
896 wc->lpszMenuName = CLASS_GetMenuNameA( classPtr );
897 wc->lpszClassName = NULL;
902 /***********************************************************************
903 * GetClassInfo32W (USER32.213)
905 BOOL32 GetClassInfo32W( HINSTANCE32 hInstance, LPCWSTR name, WNDCLASS32W *wc )
910 hInstance = GetExePtr( hInstance ); /* FIXME: not needed in Win32 */
911 if (!(atom = GlobalFindAtom32W( name )) ||
912 !(classPtr = CLASS_FindClassByAtom( atom, hInstance )) ||
913 (hInstance != classPtr->hInstance)) return FALSE;
914 wc->style = classPtr->style;
915 wc->lpfnWndProc = (WNDPROC32)WINPROC_GetProc( classPtr->winproc,
917 wc->cbClsExtra = classPtr->cbClsExtra;
918 wc->cbWndExtra = classPtr->cbWndExtra;
919 wc->hInstance = classPtr->hInstance;
920 wc->hIcon = (HICON32)classPtr->hIcon;
921 wc->hCursor = (HCURSOR32)classPtr->hCursor;
922 wc->hbrBackground = (HBRUSH32)classPtr->hbrBackground;
923 wc->lpszMenuName = CLASS_GetMenuNameW( classPtr );
924 wc->lpszClassName = NULL;
929 /***********************************************************************
930 * GetClassInfoEx16 (USER.398)
932 * FIXME: this is just a guess, I have no idea if GetClassInfoEx() is the
933 * same in Win16 as in Win32. --AJ
935 BOOL16 GetClassInfoEx16( HINSTANCE16 hInstance, SEGPTR name, WNDCLASSEX16 *wc )
940 hInstance = GetExePtr( hInstance );
941 if (!(atom = GlobalFindAtom16( name )) ||
942 !(classPtr = CLASS_FindClassByAtom( atom, hInstance )) ||
943 (hInstance != classPtr->hInstance)) return FALSE;
944 wc->style = classPtr->style;
945 wc->lpfnWndProc = WINPROC_GetProc( classPtr->winproc, WIN_PROC_16 );
946 wc->cbClsExtra = (INT16)classPtr->cbClsExtra;
947 wc->cbWndExtra = (INT16)classPtr->cbWndExtra;
948 wc->hInstance = (HINSTANCE16)classPtr->hInstance;
949 wc->hIcon = classPtr->hIcon;
950 wc->hIconSm = classPtr->hIconSm;
951 wc->hCursor = classPtr->hCursor;
952 wc->hbrBackground = classPtr->hbrBackground;
953 wc->lpszClassName = (SEGPTR)0;
954 wc->lpszMenuName = (SEGPTR)CLASS_GetMenuNameA( classPtr );
955 if (HIWORD(wc->lpszMenuName)) /* Make it a SEGPTR */
956 wc->lpszMenuName = SEGPTR_GET( (LPSTR)wc->lpszMenuName );
961 /***********************************************************************
962 * GetClassInfoEx32A (USER32.211)
964 BOOL32 GetClassInfoEx32A( HINSTANCE32 hInstance, LPCSTR name,
970 hInstance = GetExePtr( hInstance ); /* FIXME: not needed in Win32 */
971 if (!(atom = GlobalFindAtom32A( name )) ||
972 !(classPtr = CLASS_FindClassByAtom( atom, hInstance )) ||
973 (hInstance != classPtr->hInstance)) return FALSE;
974 wc->style = classPtr->style;
975 wc->lpfnWndProc = (WNDPROC32)WINPROC_GetProc( classPtr->winproc,
977 wc->cbClsExtra = classPtr->cbClsExtra;
978 wc->cbWndExtra = classPtr->cbWndExtra;
979 wc->hInstance = classPtr->hInstance;
980 wc->hIcon = (HICON32)classPtr->hIcon;
981 wc->hIconSm = (HICON32)classPtr->hIconSm;
982 wc->hCursor = (HCURSOR32)classPtr->hCursor;
983 wc->hbrBackground = (HBRUSH32)classPtr->hbrBackground;
984 wc->lpszMenuName = CLASS_GetMenuNameA( classPtr );
985 wc->lpszClassName = NULL;
990 /***********************************************************************
991 * GetClassInfoEx32W (USER32.212)
993 BOOL32 GetClassInfoEx32W( HINSTANCE32 hInstance, LPCWSTR name,
999 hInstance = GetExePtr( hInstance ); /* FIXME: not needed in Win32 */
1000 if (!(atom = GlobalFindAtom32W( name )) ||
1001 !(classPtr = CLASS_FindClassByAtom( atom, hInstance )) ||
1002 (hInstance != classPtr->hInstance)) return FALSE;
1003 wc->style = classPtr->style;
1004 wc->lpfnWndProc = (WNDPROC32)WINPROC_GetProc( classPtr->winproc,
1006 wc->cbClsExtra = classPtr->cbClsExtra;
1007 wc->cbWndExtra = classPtr->cbWndExtra;
1008 wc->hInstance = classPtr->hInstance;
1009 wc->hIcon = (HICON32)classPtr->hIcon;
1010 wc->hIconSm = (HICON32)classPtr->hIconSm;
1011 wc->hCursor = (HCURSOR32)classPtr->hCursor;
1012 wc->hbrBackground = (HBRUSH32)classPtr->hbrBackground;
1013 wc->lpszMenuName = CLASS_GetMenuNameW( classPtr );
1014 wc->lpszClassName = NULL;
1019 /***********************************************************************
1020 * ClassFirst (TOOLHELP.69)
1022 BOOL16 ClassFirst( CLASSENTRY *pClassEntry )
1024 pClassEntry->wNext = 1;
1025 return ClassNext( pClassEntry );
1029 /***********************************************************************
1030 * ClassNext (TOOLHELP.70)
1032 BOOL16 ClassNext( CLASSENTRY *pClassEntry )
1035 CLASS *class = firstClass;
1037 if (!pClassEntry->wNext) return FALSE;
1038 for (i = 1; (i < pClassEntry->wNext) && class; i++) class = class->next;
1041 pClassEntry->wNext = 0;
1044 pClassEntry->hInst = class->hInstance;
1045 pClassEntry->wNext++;
1046 GlobalGetAtomName32A( class->atomName, pClassEntry->szClassName,
1047 sizeof(pClassEntry->szClassName) );