2 * Window classes functions
4 * Copyright 1993, 1996 Alexandre Julliard
22 static CLASS *firstClass = NULL;
25 /***********************************************************************
28 * Dump the content of a class structure to stderr.
30 void CLASS_DumpClass( CLASS *ptr )
35 if (ptr->magic != CLASS_MAGIC)
37 fprintf( stderr, "%p is not a class\n", ptr );
41 GlobalGetAtomName32A( ptr->atomName, className, sizeof(className) );
43 fprintf( stderr, "Class %p:\n", ptr );
45 "next=%p name=%04x '%s' style=%08x wndProc=%08lx\n"
46 "inst=%04x hdce=%04x icon=%04x cursor=%04x bkgnd=%04x\n"
47 "clsExtra=%d winExtra=%d #windows=%d\n",
48 ptr->next, ptr->atomName, className, ptr->style,
49 (DWORD)ptr->lpfnWndProc, ptr->hInstance, ptr->hdce,
50 ptr->hIcon, ptr->hCursor, ptr->hbrBackground,
51 ptr->cbClsExtra, ptr->cbWndExtra, ptr->cWindows );
54 fprintf( stderr, "extra bytes:" );
55 for (i = 0; i < ptr->cbClsExtra; i++)
56 fprintf( stderr, " %02x", *((BYTE *)ptr->wExtra+i) );
57 fprintf( stderr, "\n" );
59 fprintf( stderr, "\n" );
63 /***********************************************************************
66 * Walk the class list and print each class on stderr.
68 void CLASS_WalkClasses(void)
73 fprintf( stderr, " Class Name Style WndProc\n" );
74 for (ptr = firstClass; ptr; ptr = ptr->next)
76 GlobalGetAtomName32A( ptr->atomName, className, sizeof(className) );
77 fprintf( stderr, "%08x %-20.20s %08x %08x\n", (UINT32)ptr, className,
78 ptr->style, (UINT32)ptr->lpfnWndProc );
80 fprintf( stderr, "\n" );
84 /***********************************************************************
87 * Get the menu name as a ASCII string.
89 static LPSTR CLASS_GetMenuNameA( CLASS *classPtr )
91 if (!classPtr->menuNameA && classPtr->menuNameW)
93 /* We need to copy the Unicode string */
94 if ((classPtr->menuNameA = SEGPTR_ALLOC(
95 STRING32_lstrlenW(classPtr->menuNameW) + 1 )))
96 STRING32_UniToAnsi( classPtr->menuNameA, classPtr->menuNameW );
98 return classPtr->menuNameA;
102 /***********************************************************************
105 * Get the menu name as a Unicode string.
107 static LPWSTR CLASS_GetMenuNameW( CLASS *classPtr )
109 if (!classPtr->menuNameW && classPtr->menuNameA)
111 if (!HIWORD(classPtr->menuNameA))
112 return (LPWSTR)classPtr->menuNameA;
113 /* Now we need to copy the ASCII string */
114 if ((classPtr->menuNameW = HeapAlloc( SystemHeap, 0,
115 (strlen(classPtr->menuNameA)+1)*sizeof(WCHAR) )))
116 STRING32_AnsiToUni( classPtr->menuNameW, 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 (STRING32_lstrlenW(name)+1)*sizeof(WCHAR) )))
152 STRING32_lstrcpyW( classPtr->menuNameW, name );
153 classPtr->menuNameA = 0;
157 /***********************************************************************
160 * Free a class structure.
162 static BOOL 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->hdce) DCE_FreeDCE( classPtr->hdce );
184 if (classPtr->hbrBackground) DeleteObject( classPtr->hbrBackground );
185 GlobalDeleteAtom( classPtr->atomName );
186 CLASS_SetMenuNameA( classPtr, NULL );
187 HeapFree( SystemHeap, 0, classPtr );
192 /***********************************************************************
193 * CLASS_FreeModuleClasses
195 void CLASS_FreeModuleClasses( HMODULE hModule )
199 for (ptr = firstClass; ptr; ptr = next)
202 if (ptr->hInstance == hModule) CLASS_FreeClass( ptr );
207 /***********************************************************************
208 * CLASS_FindClassByAtom
210 * Return a pointer to the class.
212 CLASS *CLASS_FindClassByAtom( ATOM atom, HINSTANCE16 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==(HINSTANCE16)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_FindClassByName
241 * Return a pointer to the class.
243 CLASS *CLASS_FindClassByName( SEGPTR name, HINSTANCE hinstance )
247 if (!(atom = GlobalFindAtom16( name ))) return 0;
248 return CLASS_FindClassByAtom( atom, hinstance );
252 /***********************************************************************
253 * CLASS_RegisterClass
255 * The real RegisterClass() functionality.
257 static CLASS *CLASS_RegisterClass( ATOM atom, HINSTANCE32 hInstance,
258 DWORD style, INT32 classExtra,
263 /* Check if a class with this name already exists */
265 classPtr = CLASS_FindClassByAtom( atom, hInstance );
268 /* Class can be created only if it is local and */
269 /* if the class with the same name is global. */
271 if (style & CS_GLOBALCLASS) return NULL;
272 if (!(classPtr->style & CS_GLOBALCLASS)) return NULL;
275 /* Fix the extra bytes value */
277 if (classExtra < 0) classExtra = 0;
278 else if (classExtra > 40) /* Extra bytes are limited to 40 in Win32 */
279 fprintf(stderr, "Warning: class extra bytes %d is > 40\n", classExtra);
280 if (winExtra < 0) winExtra = 0;
281 else if (winExtra > 40) /* Extra bytes are limited to 40 in Win32 */
282 fprintf( stderr, "Warning: win extra bytes %d is > 40\n", winExtra );
284 /* Create the class */
286 classPtr = (CLASS *)HeapAlloc( SystemHeap, 0, sizeof(CLASS) +
287 classExtra - sizeof(classPtr->wExtra) );
288 if (!classPtr) return NULL;
289 classPtr->next = firstClass;
290 classPtr->magic = CLASS_MAGIC;
291 classPtr->cWindows = 0;
292 classPtr->style = style;
293 classPtr->cbWndExtra = winExtra;
294 classPtr->cbClsExtra = classExtra;
295 classPtr->hInstance = hInstance;
296 classPtr->atomName = atom;
297 classPtr->menuNameA = 0;
298 classPtr->menuNameW = 0;
299 classPtr->hdce = (style&CS_CLASSDC) ? DCE_AllocDCE(DCE_CLASS_DC) : 0;
300 /* Other values must be set by caller */
302 if (classExtra) memset( classPtr->wExtra, 0, classExtra );
303 firstClass = classPtr;
308 /***********************************************************************
309 * RegisterClass16 (USER.57)
311 ATOM RegisterClass16( const WNDCLASS16 *wc )
316 HINSTANCE32 hInstance = (HINSTANCE32)GetExePtr( wc->hInstance );
318 if (!(atom = GlobalAddAtom16( wc->lpszClassName ))) return 0;
319 if (!(classPtr = CLASS_RegisterClass( atom, hInstance, wc->style,
320 wc->cbClsExtra, wc->cbWndExtra )))
322 GlobalDeleteAtom( atom );
326 dprintf_class( stddeb, "RegisterClass16: atom=%04x wndproc=%08lx hinst=%04x bg=%04x style=%08x clsExt=%d winExt=%d class=%p\n",
327 atom, (DWORD)wc->lpfnWndProc, hInstance,
328 wc->hbrBackground, wc->style, wc->cbClsExtra,
329 wc->cbWndExtra, classPtr );
332 classPtr->lpfnWndProc = wc->lpfnWndProc;
333 classPtr->hIcon = wc->hIcon;
334 classPtr->hIconSm = 0;
335 classPtr->hCursor = wc->hCursor;
336 classPtr->hbrBackground = wc->hbrBackground;
338 CLASS_SetMenuNameA( classPtr, HIWORD(wc->lpszMenuName) ?
339 PTR_SEG_TO_LIN(wc->lpszMenuName) : (LPCSTR)wc->lpszMenuName );
344 /***********************************************************************
345 * RegisterClass32A (USER32.426)
347 ATOM RegisterClass32A( const WNDCLASS32A* wc )
352 /* FIXME: this should not be necessary for Win32 */
353 HINSTANCE32 hInstance = (HINSTANCE32)GetExePtr( wc->hInstance );
355 if (!(atom = GlobalAddAtom32A( wc->lpszClassName ))) return 0;
356 if (!(classPtr = CLASS_RegisterClass( atom, hInstance, wc->style,
357 wc->cbClsExtra, wc->cbWndExtra )))
359 GlobalDeleteAtom( atom );
363 dprintf_class( stddeb, "RegisterClass32A: atom=%04x wndproc=%08lx hinst=%04x bg=%04x style=%08x clsExt=%d winExt=%d class=%p\n",
364 atom, (DWORD)wc->lpfnWndProc, hInstance,
365 wc->hbrBackground, wc->style, wc->cbClsExtra,
366 wc->cbWndExtra, classPtr );
369 classPtr->lpfnWndProc = (WNDPROC16)wc->lpfnWndProc;
370 classPtr->hIcon = (HICON16)wc->hIcon;
371 classPtr->hIconSm = 0;
372 classPtr->hCursor = (HCURSOR16)wc->hCursor;
373 classPtr->hbrBackground = (HBRUSH16)wc->hbrBackground;
374 ALIAS_RegisterAlias( 0, 0, (DWORD)wc->lpfnWndProc );
375 CLASS_SetMenuNameA( classPtr, wc->lpszMenuName );
380 /***********************************************************************
381 * RegisterClass32W (USER32.429)
383 ATOM RegisterClass32W( const WNDCLASS32W* wc )
388 /* FIXME: this should not be necessary for Win32 */
389 HINSTANCE32 hInstance = (HINSTANCE32)GetExePtr( wc->hInstance );
391 if (!(atom = GlobalAddAtom32W( wc->lpszClassName ))) return 0;
392 if (!(classPtr = CLASS_RegisterClass( atom, hInstance, wc->style,
393 wc->cbClsExtra, wc->cbWndExtra )))
395 GlobalDeleteAtom( atom );
399 dprintf_class( stddeb, "RegisterClass32W: atom=%04x wndproc=%08lx hinst=%04x bg=%04x style=%08x clsExt=%d winExt=%d class=%p\n",
400 atom, (DWORD)wc->lpfnWndProc, hInstance,
401 wc->hbrBackground, wc->style, wc->cbClsExtra,
402 wc->cbWndExtra, classPtr );
404 classPtr->flags = CLASS_FLAG_UNICODE;
405 classPtr->lpfnWndProc = (WNDPROC16)wc->lpfnWndProc;
406 classPtr->hIcon = (HICON16)wc->hIcon;
407 classPtr->hIconSm = 0;
408 classPtr->hCursor = (HCURSOR16)wc->hCursor;
409 classPtr->hbrBackground = (HBRUSH16)wc->hbrBackground;
411 ALIAS_RegisterAlias( 0, 0, (DWORD)wc->lpfnWndProc );
412 CLASS_SetMenuNameW( classPtr, wc->lpszMenuName );
417 /***********************************************************************
418 * RegisterClassEx16 (USER.397)
420 ATOM RegisterClassEx16( const WNDCLASSEX16 *wc )
425 HINSTANCE32 hInstance = (HINSTANCE32)GetExePtr( wc->hInstance );
427 if (!(atom = GlobalAddAtom16( wc->lpszClassName ))) return 0;
428 if (!(classPtr = CLASS_RegisterClass( atom, hInstance, wc->style,
429 wc->cbClsExtra, wc->cbWndExtra )))
431 GlobalDeleteAtom( atom );
435 dprintf_class( stddeb, "RegisterClassEx16: atom=%04x wndproc=%08lx hinst=%04x bg=%04x style=%08x clsExt=%d winExt=%d class=%p\n",
436 atom, (DWORD)wc->lpfnWndProc, hInstance,
437 wc->hbrBackground, wc->style, wc->cbClsExtra,
438 wc->cbWndExtra, classPtr );
440 classPtr->lpfnWndProc = wc->lpfnWndProc;
441 classPtr->hIcon = wc->hIcon;
442 classPtr->hIconSm = wc->hIconSm;
443 classPtr->hCursor = wc->hCursor;
444 classPtr->hbrBackground = wc->hbrBackground;
446 CLASS_SetMenuNameA( classPtr, HIWORD(wc->lpszMenuName) ?
447 PTR_SEG_TO_LIN(wc->lpszMenuName) : (LPCSTR)wc->lpszMenuName );
452 /***********************************************************************
453 * RegisterClassEx32A (USER32.427)
455 ATOM RegisterClassEx32A( const WNDCLASSEX32A* wc )
460 /* FIXME: this should not be necessary for Win32 */
461 HINSTANCE32 hInstance = (HINSTANCE32)GetExePtr( wc->hInstance );
463 if (!(atom = GlobalAddAtom32A( wc->lpszClassName ))) return 0;
464 if (!(classPtr = CLASS_RegisterClass( atom, hInstance, wc->style,
465 wc->cbClsExtra, wc->cbWndExtra )))
467 GlobalDeleteAtom( atom );
471 dprintf_class( stddeb, "RegisterClassEx32A: atom=%04x wndproc=%08lx hinst=%04x bg=%04x style=%08x clsExt=%d winExt=%d class=%p\n",
472 atom, (DWORD)wc->lpfnWndProc, hInstance,
473 wc->hbrBackground, wc->style, wc->cbClsExtra,
474 wc->cbWndExtra, classPtr );
476 classPtr->lpfnWndProc = (WNDPROC16)wc->lpfnWndProc;
477 classPtr->hIcon = (HICON16)wc->hIcon;
478 classPtr->hIconSm = (HICON16)wc->hIconSm;
479 classPtr->hCursor = (HCURSOR16)wc->hCursor;
480 classPtr->hbrBackground = (HBRUSH16)wc->hbrBackground;
482 ALIAS_RegisterAlias( 0, 0, (DWORD)wc->lpfnWndProc );
483 CLASS_SetMenuNameA( classPtr, wc->lpszMenuName );
488 /***********************************************************************
489 * RegisterClassEx32W (USER32.428)
491 ATOM RegisterClassEx32W( const WNDCLASSEX32W* wc )
496 /* FIXME: this should not be necessary for Win32 */
497 HINSTANCE32 hInstance = (HINSTANCE32)GetExePtr( wc->hInstance );
499 if (!(atom = GlobalAddAtom32W( wc->lpszClassName ))) return 0;
500 if (!(classPtr = CLASS_RegisterClass( atom, hInstance, wc->style,
501 wc->cbClsExtra, wc->cbWndExtra )))
503 GlobalDeleteAtom( atom );
507 dprintf_class( stddeb, "RegisterClassEx32W: atom=%04x wndproc=%08lx hinst=%04x bg=%04x style=%08x clsExt=%d winExt=%d class=%p\n",
508 atom, (DWORD)wc->lpfnWndProc, hInstance,
509 wc->hbrBackground, wc->style, wc->cbClsExtra,
510 wc->cbWndExtra, classPtr );
512 classPtr->lpfnWndProc = (WNDPROC16)wc->lpfnWndProc;
513 classPtr->hIcon = (HICON16)wc->hIcon;
514 classPtr->hIconSm = (HICON16)wc->hIconSm;
515 classPtr->hCursor = (HCURSOR16)wc->hCursor;
516 classPtr->hbrBackground = (HBRUSH16)wc->hbrBackground;
518 ALIAS_RegisterAlias( 0, 0, (DWORD)wc->lpfnWndProc );
519 CLASS_SetMenuNameW( classPtr, wc->lpszMenuName );
524 /***********************************************************************
525 * UnregisterClass16 (USER.403)
527 BOOL16 UnregisterClass16( SEGPTR className, HINSTANCE16 hInstance )
532 hInstance = GetExePtr( hInstance );
533 if (!(atom = GlobalFindAtom16( className ))) return FALSE;
534 if (!(classPtr = CLASS_FindClassByAtom( atom, hInstance )) ||
535 (classPtr->hInstance != hInstance)) return FALSE;
536 return CLASS_FreeClass( classPtr );
540 /***********************************************************************
541 * UnregisterClass32A (USER32.562)
543 BOOL32 UnregisterClass32A( LPCSTR className, HINSTANCE32 hInstance )
548 hInstance = GetExePtr( hInstance ); /* FIXME: not needed in Win32 */
549 if (!(atom = GlobalFindAtom32A( className ))) return FALSE;
550 if (!(classPtr = CLASS_FindClassByAtom( atom, hInstance )) ||
551 (classPtr->hInstance != hInstance)) return FALSE;
552 return CLASS_FreeClass( classPtr );
556 /***********************************************************************
557 * UnregisterClass32W (USER32.563)
559 BOOL32 UnregisterClass32W( LPCWSTR className, HINSTANCE32 hInstance )
564 hInstance = GetExePtr( hInstance ); /* FIXME: not needed in Win32 */
565 if (!(atom = GlobalFindAtom32W( className ))) return FALSE;
566 if (!(classPtr = CLASS_FindClassByAtom( atom, hInstance )) ||
567 (classPtr->hInstance != hInstance)) return FALSE;
568 return CLASS_FreeClass( classPtr );
572 /***********************************************************************
573 * GetClassWord (USER.129) (USER32.218)
575 WORD GetClassWord( HWND hwnd, INT32 offset )
579 if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return 0;
582 if (offset <= wndPtr->class->cbClsExtra - sizeof(WORD))
583 return GET_WORD(((char *)wndPtr->class->wExtra) + offset);
587 case GCW_HBRBACKGROUND: return wndPtr->class->hbrBackground;
588 case GCW_HCURSOR: return wndPtr->class->hCursor;
589 case GCW_HICON: return wndPtr->class->hIcon;
590 case GCW_HICONSM: return wndPtr->class->hIconSm;
591 case GCW_ATOM: return wndPtr->class->atomName;
596 return (WORD)GetClassLong32A( hwnd, offset );
598 fprintf(stderr, "Warning: invalid offset %d for GetClassWord()\n", offset);
603 /***********************************************************************
604 * GetClassLong16 (USER.131)
606 LONG GetClassLong16( HWND hwnd, INT16 offset )
608 DWORD ret = GetClassLong32A( hwnd, offset );
609 if ((offset == GCL_MENUNAME) && HIWORD(ret))
610 return (LONG)SEGPTR_GET((void *)ret); /* Name needs to be a SEGPTR */
615 /***********************************************************************
616 * GetClassLong32A (USER32.214)
618 LONG GetClassLong32A( HWND hwnd, INT32 offset )
622 if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return 0;
625 if (offset <= wndPtr->class->cbClsExtra - sizeof(LONG))
626 return GET_DWORD(((char *)wndPtr->class->wExtra) + offset);
630 case GCL_STYLE: return (LONG)wndPtr->class->style;
631 case GCL_CBWNDEXTRA: return (LONG)wndPtr->class->cbWndExtra;
632 case GCL_CBCLSEXTRA: return (LONG)wndPtr->class->cbClsExtra;
633 case GCL_WNDPROC: return (LONG)wndPtr->class->lpfnWndProc;
634 case GCL_HMODULE: return (LONG)wndPtr->class->hInstance;
636 return (LONG)CLASS_GetMenuNameA( wndPtr->class );
637 case GCL_HBRBACKGROUND:
641 return GetClassWord( hwnd, offset );
643 fprintf(stderr, "Warning: invalid offset %d for GetClassLong()\n", offset);
648 /***********************************************************************
649 * GetClassLong32W (USER32.215)
651 LONG GetClassLong32W( HWND hwnd, INT32 offset )
655 if (offset != GCL_MENUNAME) return GetClassLong32A( hwnd, offset );
656 if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return 0;
657 return (LONG)CLASS_GetMenuNameW( wndPtr->class );
661 /***********************************************************************
662 * SetClassWord (USER.130) (USER32.468)
664 WORD SetClassWord( HWND hwnd, INT32 offset, WORD newval )
670 if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return 0;
673 if (offset <= wndPtr->class->cbClsExtra - sizeof(WORD))
674 ptr = ((char *)wndPtr->class->wExtra) + offset;
676 fprintf( stderr, "Warning: invalid offset %d for SetClassWord()\n",
687 return (WORD)SetClassLong32A( hwnd, offset, (LONG)newval );
688 case GCW_HBRBACKGROUND: ptr = &wndPtr->class->hbrBackground; break;
689 case GCW_HCURSOR: ptr = &wndPtr->class->hCursor; break;
690 case GCW_HICON: ptr = &wndPtr->class->hIcon; break;
691 case GCW_HICONSM: ptr = &wndPtr->class->hIconSm; break;
692 case GCW_ATOM: ptr = &wndPtr->class->atomName; break;
694 fprintf( stderr, "Warning: invalid offset %d for SetClassWord()\n",
698 retval = GET_WORD(ptr);
699 PUT_WORD( ptr, newval );
704 /***********************************************************************
705 * SetClassLong16 (USER.132)
707 LONG SetClassLong16( HWND hwnd, INT16 offset, LONG newval )
709 if ((offset == GCL_MENUNAME) && HIWORD(newval))
710 newval = (LONG)PTR_SEG_TO_LIN(newval);
711 return SetClassLong32A( hwnd, offset, newval );
715 /***********************************************************************
716 * SetClassLong32A (USER32.466)
718 LONG SetClassLong32A( HWND hwnd, INT32 offset, LONG newval )
724 if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return 0;
727 if (offset <= wndPtr->class->cbClsExtra - sizeof(LONG))
728 ptr = ((char *)wndPtr->class->wExtra) + offset;
731 fprintf( stderr, "Warning: invalid offset %d for SetClassLong()\n",
739 CLASS_SetMenuNameA( wndPtr->class, (LPCSTR)newval );
740 return 0; /* Old value is now meaningless anyway */
741 case GCL_HBRBACKGROUND:
745 return SetClassWord( hwnd, offset, (WORD)newval );
746 case GCL_STYLE: ptr = &wndPtr->class->style; break;
747 case GCL_CBWNDEXTRA: ptr = &wndPtr->class->cbWndExtra; break;
748 case GCL_CBCLSEXTRA: ptr = &wndPtr->class->cbClsExtra; break;
749 case GCL_WNDPROC: ptr = &wndPtr->class->lpfnWndProc; break;
750 case GCL_HMODULE: ptr = &wndPtr->class->hInstance; break;
752 fprintf( stderr, "Warning: invalid offset %d for SetClassLong()\n",
756 retval = GET_DWORD(ptr);
757 PUT_DWORD( ptr, newval );
762 /***********************************************************************
763 * SetClassLong32W (USER32.467)
765 LONG SetClassLong32W( HWND hwnd, INT32 offset, LONG newval )
768 if (offset != GCL_MENUNAME) return SetClassLong32A( hwnd, offset, newval );
769 if (!(wndPtr = WIN_FindWndPtr(hwnd))) return 0;
770 CLASS_SetMenuNameW( wndPtr->class, (LPCWSTR)newval );
771 return 0; /* Old value is now meaningless anyway */
775 /***********************************************************************
776 * GetClassName16 (USER.58)
778 INT16 GetClassName16( HWND hwnd, LPSTR buffer, INT16 count )
781 if (!(wndPtr = WIN_FindWndPtr(hwnd))) return 0;
782 return GlobalGetAtomName16( wndPtr->class->atomName, buffer, count );
786 /***********************************************************************
787 * GetClassName32A (USER32.216)
789 INT32 GetClassName32A( HWND hwnd, LPSTR buffer, INT32 count )
792 if (!(wndPtr = WIN_FindWndPtr(hwnd))) return 0;
793 return GlobalGetAtomName32A( wndPtr->class->atomName, buffer, count );
797 /***********************************************************************
798 * GetClassName32W (USER32.217)
800 INT32 GetClassName32W( HWND hwnd, LPWSTR buffer, INT32 count )
803 if (!(wndPtr = WIN_FindWndPtr(hwnd))) return 0;
804 return GlobalGetAtomName32W( wndPtr->class->atomName, buffer, count );
808 /***********************************************************************
809 * GetClassInfo16 (USER.404)
811 BOOL GetClassInfo16( HINSTANCE16 hInstance, SEGPTR name, WNDCLASS16 *wc )
816 hInstance = GetExePtr( hInstance );
817 if (!(atom = GlobalFindAtom16( name )) ||
818 !(classPtr = CLASS_FindClassByAtom( atom, hInstance )) ||
819 (hInstance != classPtr->hInstance)) return FALSE;
820 wc->style = (UINT16)classPtr->style;
821 wc->lpfnWndProc = classPtr->lpfnWndProc;
822 wc->cbClsExtra = (INT16)classPtr->cbClsExtra;
823 wc->cbWndExtra = (INT16)classPtr->cbWndExtra;
824 wc->hInstance = (HINSTANCE16)classPtr->hInstance;
825 wc->hIcon = classPtr->hIcon;
826 wc->hCursor = classPtr->hCursor;
827 wc->hbrBackground = classPtr->hbrBackground;
828 wc->lpszClassName = (SEGPTR)0;
829 wc->lpszMenuName = (SEGPTR)CLASS_GetMenuNameA( classPtr );
830 if (HIWORD(wc->lpszMenuName)) /* Make it a SEGPTR */
831 wc->lpszMenuName = SEGPTR_GET( (LPSTR)wc->lpszMenuName );
836 /***********************************************************************
837 * GetClassInfo32A (USER32.210)
839 BOOL GetClassInfo32A( HINSTANCE32 hInstance, LPCSTR name, WNDCLASS32A *wc )
844 hInstance = GetExePtr( hInstance ); /* FIXME: not needed in Win32 */
845 if (!(atom = GlobalFindAtom32A( name )) ||
846 !(classPtr = CLASS_FindClassByAtom( atom, hInstance )) ||
847 (hInstance != classPtr->hInstance)) return FALSE;
848 wc->style = classPtr->style;
849 wc->lpfnWndProc = (WNDPROC32)classPtr->lpfnWndProc;
850 wc->cbClsExtra = classPtr->cbClsExtra;
851 wc->cbWndExtra = classPtr->cbWndExtra;
852 wc->hInstance = classPtr->hInstance;
853 wc->hIcon = (HICON32)classPtr->hIcon;
854 wc->hCursor = (HCURSOR32)classPtr->hCursor;
855 wc->hbrBackground = (HBRUSH32)classPtr->hbrBackground;
856 wc->lpszMenuName = CLASS_GetMenuNameA( classPtr );
857 wc->lpszClassName = NULL;
862 /***********************************************************************
863 * GetClassInfo32W (USER32.213)
865 BOOL GetClassInfo32W( HINSTANCE32 hInstance, LPCWSTR name, WNDCLASS32W *wc )
870 hInstance = GetExePtr( hInstance ); /* FIXME: not needed in Win32 */
871 if (!(atom = GlobalFindAtom32W( name )) ||
872 !(classPtr = CLASS_FindClassByAtom( atom, hInstance )) ||
873 (hInstance != classPtr->hInstance)) return FALSE;
874 wc->style = classPtr->style;
875 wc->lpfnWndProc = (WNDPROC32)classPtr->lpfnWndProc;
876 wc->cbClsExtra = classPtr->cbClsExtra;
877 wc->cbWndExtra = classPtr->cbWndExtra;
878 wc->hInstance = classPtr->hInstance;
879 wc->hIcon = (HICON32)classPtr->hIcon;
880 wc->hCursor = (HCURSOR32)classPtr->hCursor;
881 wc->hbrBackground = (HBRUSH32)classPtr->hbrBackground;
882 wc->lpszMenuName = CLASS_GetMenuNameW( classPtr );
883 wc->lpszClassName = NULL;
888 /***********************************************************************
889 * GetClassInfoEx16 (USER.398)
891 * FIXME: this is just a guess, I have no idea if GetClassInfoEx() is the
892 * same in Win16 as in Win32. --AJ
894 BOOL GetClassInfoEx16( HINSTANCE16 hInstance, SEGPTR name, WNDCLASSEX16 *wc )
899 hInstance = GetExePtr( hInstance );
900 if (!(atom = GlobalFindAtom16( name )) ||
901 !(classPtr = CLASS_FindClassByAtom( atom, hInstance )) ||
902 (hInstance != classPtr->hInstance)) return FALSE;
903 wc->style = classPtr->style;
904 wc->lpfnWndProc = classPtr->lpfnWndProc;
905 wc->cbClsExtra = (INT16)classPtr->cbClsExtra;
906 wc->cbWndExtra = (INT16)classPtr->cbWndExtra;
907 wc->hInstance = (HINSTANCE16)classPtr->hInstance;
908 wc->hIcon = classPtr->hIcon;
909 wc->hIconSm = classPtr->hIconSm;
910 wc->hCursor = classPtr->hCursor;
911 wc->hbrBackground = classPtr->hbrBackground;
912 wc->lpszClassName = (SEGPTR)0;
913 wc->lpszMenuName = (SEGPTR)CLASS_GetMenuNameA( classPtr );
914 if (HIWORD(wc->lpszMenuName)) /* Make it a SEGPTR */
915 wc->lpszMenuName = SEGPTR_GET( (LPSTR)wc->lpszMenuName );
920 /***********************************************************************
921 * GetClassInfoEx32A (USER32.211)
923 BOOL GetClassInfoEx32A( HINSTANCE32 hInstance, LPCSTR name, WNDCLASSEX32A *wc )
928 hInstance = GetExePtr( hInstance ); /* FIXME: not needed in Win32 */
929 if (!(atom = GlobalFindAtom32A( name )) ||
930 !(classPtr = CLASS_FindClassByAtom( atom, hInstance )) ||
931 (hInstance != classPtr->hInstance)) return FALSE;
932 wc->style = classPtr->style;
933 wc->lpfnWndProc = (WNDPROC32)classPtr->lpfnWndProc;
934 wc->cbClsExtra = classPtr->cbClsExtra;
935 wc->cbWndExtra = classPtr->cbWndExtra;
936 wc->hInstance = classPtr->hInstance;
937 wc->hIcon = (HICON32)classPtr->hIcon;
938 wc->hIconSm = (HICON32)classPtr->hIconSm;
939 wc->hCursor = (HCURSOR32)classPtr->hCursor;
940 wc->hbrBackground = (HBRUSH32)classPtr->hbrBackground;
941 wc->lpszMenuName = CLASS_GetMenuNameA( classPtr );
942 wc->lpszClassName = NULL;
947 /***********************************************************************
948 * GetClassInfoEx32W (USER32.212)
950 BOOL GetClassInfoEx32W( HINSTANCE32 hInstance, LPCWSTR name, WNDCLASSEX32W *wc)
955 hInstance = GetExePtr( hInstance ); /* FIXME: not needed in Win32 */
956 if (!(atom = GlobalFindAtom32W( name )) ||
957 !(classPtr = CLASS_FindClassByAtom( atom, hInstance )) ||
958 (hInstance != classPtr->hInstance)) return FALSE;
959 wc->style = classPtr->style;
960 wc->lpfnWndProc = (WNDPROC32)classPtr->lpfnWndProc;
961 wc->cbClsExtra = classPtr->cbClsExtra;
962 wc->cbWndExtra = classPtr->cbWndExtra;
963 wc->hInstance = classPtr->hInstance;
964 wc->hIcon = (HICON32)classPtr->hIcon;
965 wc->hIconSm = (HICON32)classPtr->hIconSm;
966 wc->hCursor = (HCURSOR32)classPtr->hCursor;
967 wc->hbrBackground = (HBRUSH32)classPtr->hbrBackground;
968 wc->lpszMenuName = CLASS_GetMenuNameW( classPtr );
969 wc->lpszClassName = NULL;
974 /***********************************************************************
975 * ClassFirst (TOOLHELP.69)
977 BOOL ClassFirst( CLASSENTRY *pClassEntry )
979 pClassEntry->wNext = 1;
980 return ClassNext( pClassEntry );
984 /***********************************************************************
985 * ClassNext (TOOLHELP.70)
987 BOOL ClassNext( CLASSENTRY *pClassEntry )
990 CLASS *class = firstClass;
992 if (!pClassEntry->wNext) return FALSE;
993 for (i = 1; (i < pClassEntry->wNext) && class; i++) class = class->next;
996 pClassEntry->wNext = 0;
999 pClassEntry->hInst = class->hInstance;
1000 pClassEntry->wNext++;
1001 GlobalGetAtomName32A( class->atomName, pClassEntry->szClassName,
1002 sizeof(pClassEntry->szClassName) );