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 /* 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==(HINSTANCE16)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_FindClassByName
243 * Return a pointer to the class.
245 CLASS *CLASS_FindClassByName( SEGPTR name, HINSTANCE hinstance )
249 if (!(atom = GlobalFindAtom16( name ))) return 0;
250 return CLASS_FindClassByAtom( atom, hinstance );
254 /***********************************************************************
255 * CLASS_RegisterClass
257 * The real RegisterClass() functionality.
259 static CLASS *CLASS_RegisterClass( ATOM atom, HINSTANCE32 hInstance,
260 DWORD style, INT32 classExtra,
261 INT32 winExtra, WNDPROC16 wndProc,
262 WINDOWPROCTYPE wndProcType )
266 /* Check if a class with this name already exists */
268 classPtr = CLASS_FindClassByAtom( atom, hInstance );
271 /* Class can be created only if it is local and */
272 /* if the class with the same name is global. */
274 if (style & CS_GLOBALCLASS) return NULL;
275 if (!(classPtr->style & CS_GLOBALCLASS)) return NULL;
278 /* Fix the extra bytes value */
280 if (classExtra < 0) classExtra = 0;
281 else if (classExtra > 40) /* Extra bytes are limited to 40 in Win32 */
282 fprintf(stderr, "Warning: class extra bytes %d is > 40\n", classExtra);
283 if (winExtra < 0) winExtra = 0;
284 else if (winExtra > 40) /* Extra bytes are limited to 40 in Win32 */
285 fprintf( stderr, "Warning: win extra bytes %d is > 40\n", winExtra );
287 /* Create the class */
289 classPtr = (CLASS *)HeapAlloc( SystemHeap, 0, sizeof(CLASS) +
290 classExtra - sizeof(classPtr->wExtra) );
291 if (!classPtr) return NULL;
292 classPtr->next = firstClass;
293 classPtr->magic = CLASS_MAGIC;
294 classPtr->cWindows = 0;
295 classPtr->style = style;
296 classPtr->winproc = (HWINDOWPROC)0;
297 classPtr->cbWndExtra = winExtra;
298 classPtr->cbClsExtra = classExtra;
299 classPtr->hInstance = hInstance;
300 classPtr->atomName = atom;
301 classPtr->menuNameA = 0;
302 classPtr->menuNameW = 0;
303 classPtr->hdce = (style&CS_CLASSDC) ? DCE_AllocDCE(0, DCE_CLASS_DC): 0;
304 WINPROC_SetProc( &classPtr->winproc, wndProc, wndProcType );
306 /* Other values must be set by caller */
308 if (classExtra) memset( classPtr->wExtra, 0, classExtra );
309 firstClass = classPtr;
314 /***********************************************************************
315 * RegisterClass16 (USER.57)
317 ATOM RegisterClass16( const WNDCLASS16 *wc )
322 HINSTANCE32 hInstance = (HINSTANCE32)GetExePtr( wc->hInstance );
324 if (!(atom = GlobalAddAtom16( wc->lpszClassName ))) return 0;
325 if (!(classPtr = CLASS_RegisterClass( atom, hInstance, wc->style,
326 wc->cbClsExtra, wc->cbWndExtra,
327 wc->lpfnWndProc, WIN_PROC_16 )))
329 GlobalDeleteAtom( atom );
333 dprintf_class( stddeb, "RegisterClass16: atom=%04x wndproc=%08lx hinst=%04x bg=%04x style=%08x clsExt=%d winExt=%d class=%p\n",
334 atom, (DWORD)wc->lpfnWndProc, hInstance,
335 wc->hbrBackground, wc->style, wc->cbClsExtra,
336 wc->cbWndExtra, classPtr );
338 classPtr->hIcon = wc->hIcon;
339 classPtr->hIconSm = 0;
340 classPtr->hCursor = wc->hCursor;
341 classPtr->hbrBackground = wc->hbrBackground;
343 CLASS_SetMenuNameA( classPtr, HIWORD(wc->lpszMenuName) ?
344 PTR_SEG_TO_LIN(wc->lpszMenuName) : (LPCSTR)wc->lpszMenuName );
349 /***********************************************************************
350 * RegisterClass32A (USER32.426)
352 ATOM RegisterClass32A( const WNDCLASS32A* wc )
357 /* FIXME: this should not be necessary for Win32 */
358 HINSTANCE32 hInstance = (HINSTANCE32)GetExePtr( wc->hInstance );
360 if (!(atom = GlobalAddAtom32A( wc->lpszClassName ))) return 0;
361 if (!(classPtr = CLASS_RegisterClass( atom, hInstance, wc->style,
362 wc->cbClsExtra, wc->cbWndExtra,
363 (WNDPROC16)wc->lpfnWndProc,
366 GlobalDeleteAtom( atom );
370 dprintf_class( stddeb, "RegisterClass32A: atom=%04x wndproc=%08lx hinst=%04x bg=%04x style=%08x clsExt=%d winExt=%d class=%p\n",
371 atom, (DWORD)wc->lpfnWndProc, hInstance,
372 wc->hbrBackground, wc->style, wc->cbClsExtra,
373 wc->cbWndExtra, classPtr );
375 classPtr->hIcon = (HICON16)wc->hIcon;
376 classPtr->hIconSm = 0;
377 classPtr->hCursor = (HCURSOR16)wc->hCursor;
378 classPtr->hbrBackground = (HBRUSH16)wc->hbrBackground;
379 CLASS_SetMenuNameA( classPtr, wc->lpszMenuName );
384 /***********************************************************************
385 * RegisterClass32W (USER32.429)
387 ATOM RegisterClass32W( const WNDCLASS32W* wc )
392 /* FIXME: this should not be necessary for Win32 */
393 HINSTANCE32 hInstance = (HINSTANCE32)GetExePtr( wc->hInstance );
395 if (!(atom = GlobalAddAtom32W( wc->lpszClassName ))) return 0;
396 if (!(classPtr = CLASS_RegisterClass( atom, hInstance, wc->style,
397 wc->cbClsExtra, wc->cbWndExtra,
398 (WNDPROC16)wc->lpfnWndProc,
401 GlobalDeleteAtom( atom );
405 dprintf_class( stddeb, "RegisterClass32W: atom=%04x wndproc=%08lx hinst=%04x bg=%04x style=%08x clsExt=%d winExt=%d class=%p\n",
406 atom, (DWORD)wc->lpfnWndProc, hInstance,
407 wc->hbrBackground, wc->style, wc->cbClsExtra,
408 wc->cbWndExtra, classPtr );
410 classPtr->hIcon = (HICON16)wc->hIcon;
411 classPtr->hIconSm = 0;
412 classPtr->hCursor = (HCURSOR16)wc->hCursor;
413 classPtr->hbrBackground = (HBRUSH16)wc->hbrBackground;
414 CLASS_SetMenuNameW( classPtr, wc->lpszMenuName );
419 /***********************************************************************
420 * RegisterClassEx16 (USER.397)
422 ATOM RegisterClassEx16( const WNDCLASSEX16 *wc )
427 HINSTANCE32 hInstance = (HINSTANCE32)GetExePtr( wc->hInstance );
429 if (!(atom = GlobalAddAtom16( wc->lpszClassName ))) return 0;
430 if (!(classPtr = CLASS_RegisterClass( atom, hInstance, wc->style,
431 wc->cbClsExtra, wc->cbWndExtra,
432 wc->lpfnWndProc, WIN_PROC_16 )))
434 GlobalDeleteAtom( atom );
438 dprintf_class( stddeb, "RegisterClassEx16: atom=%04x wndproc=%08lx hinst=%04x bg=%04x style=%08x clsExt=%d winExt=%d class=%p\n",
439 atom, (DWORD)wc->lpfnWndProc, hInstance,
440 wc->hbrBackground, wc->style, wc->cbClsExtra,
441 wc->cbWndExtra, classPtr );
443 classPtr->hIcon = wc->hIcon;
444 classPtr->hIconSm = wc->hIconSm;
445 classPtr->hCursor = wc->hCursor;
446 classPtr->hbrBackground = wc->hbrBackground;
448 CLASS_SetMenuNameA( classPtr, HIWORD(wc->lpszMenuName) ?
449 PTR_SEG_TO_LIN(wc->lpszMenuName) : (LPCSTR)wc->lpszMenuName );
454 /***********************************************************************
455 * RegisterClassEx32A (USER32.427)
457 ATOM RegisterClassEx32A( const WNDCLASSEX32A* wc )
462 /* FIXME: this should not be necessary for Win32 */
463 HINSTANCE32 hInstance = (HINSTANCE32)GetExePtr( wc->hInstance );
465 if (!(atom = GlobalAddAtom32A( wc->lpszClassName ))) return 0;
466 if (!(classPtr = CLASS_RegisterClass( atom, hInstance, wc->style,
467 wc->cbClsExtra, wc->cbWndExtra,
468 (WNDPROC16)wc->lpfnWndProc,
471 GlobalDeleteAtom( atom );
475 dprintf_class( stddeb, "RegisterClassEx32A: atom=%04x wndproc=%08lx hinst=%04x bg=%04x style=%08x clsExt=%d winExt=%d class=%p\n",
476 atom, (DWORD)wc->lpfnWndProc, hInstance,
477 wc->hbrBackground, wc->style, wc->cbClsExtra,
478 wc->cbWndExtra, classPtr );
480 classPtr->hIcon = (HICON16)wc->hIcon;
481 classPtr->hIconSm = (HICON16)wc->hIconSm;
482 classPtr->hCursor = (HCURSOR16)wc->hCursor;
483 classPtr->hbrBackground = (HBRUSH16)wc->hbrBackground;
484 CLASS_SetMenuNameA( classPtr, wc->lpszMenuName );
489 /***********************************************************************
490 * RegisterClassEx32W (USER32.428)
492 ATOM RegisterClassEx32W( const WNDCLASSEX32W* wc )
497 /* FIXME: this should not be necessary for Win32 */
498 HINSTANCE32 hInstance = (HINSTANCE32)GetExePtr( wc->hInstance );
500 if (!(atom = GlobalAddAtom32W( wc->lpszClassName ))) return 0;
501 if (!(classPtr = CLASS_RegisterClass( atom, hInstance, wc->style,
502 wc->cbClsExtra, wc->cbWndExtra,
503 (WNDPROC16)wc->lpfnWndProc,
506 GlobalDeleteAtom( atom );
510 dprintf_class( stddeb, "RegisterClassEx32W: atom=%04x wndproc=%08lx hinst=%04x bg=%04x style=%08x clsExt=%d winExt=%d class=%p\n",
511 atom, (DWORD)wc->lpfnWndProc, hInstance,
512 wc->hbrBackground, wc->style, wc->cbClsExtra,
513 wc->cbWndExtra, classPtr );
515 classPtr->hIcon = (HICON16)wc->hIcon;
516 classPtr->hIconSm = (HICON16)wc->hIconSm;
517 classPtr->hCursor = (HCURSOR16)wc->hCursor;
518 classPtr->hbrBackground = (HBRUSH16)wc->hbrBackground;
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( HWND32 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( HWND16 hwnd, INT16 offset )
614 if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return 0;
615 return (LONG)WINPROC_GetProc( wndPtr->class->winproc, WIN_PROC_16 );
617 ret = GetClassLong32A( hwnd, offset );
618 return (LONG)SEGPTR_GET( (void *)ret );
620 return GetClassLong32A( hwnd, offset );
625 /***********************************************************************
626 * GetClassLong32A (USER32.214)
628 LONG GetClassLong32A( HWND32 hwnd, INT32 offset )
632 if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return 0;
635 if (offset <= wndPtr->class->cbClsExtra - sizeof(LONG))
636 return GET_DWORD(((char *)wndPtr->class->wExtra) + offset);
640 case GCL_STYLE: return (LONG)wndPtr->class->style;
641 case GCL_CBWNDEXTRA: return (LONG)wndPtr->class->cbWndExtra;
642 case GCL_CBCLSEXTRA: return (LONG)wndPtr->class->cbClsExtra;
643 case GCL_HMODULE: return (LONG)wndPtr->class->hInstance;
645 return (LONG)WINPROC_GetProc(wndPtr->class->winproc, WIN_PROC_32A);
647 return (LONG)CLASS_GetMenuNameA( wndPtr->class );
648 case GCL_HBRBACKGROUND:
652 return GetClassWord( hwnd, offset );
654 fprintf(stderr, "Warning: invalid offset %d for GetClassLong()\n", offset);
659 /***********************************************************************
660 * GetClassLong32W (USER32.215)
662 LONG GetClassLong32W( HWND32 hwnd, INT32 offset )
669 if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return 0;
670 return (LONG)WINPROC_GetProc( wndPtr->class->winproc, WIN_PROC_32W );
672 if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return 0;
673 return (LONG)CLASS_GetMenuNameW( wndPtr->class );
675 return GetClassLong32A( hwnd, offset );
680 /***********************************************************************
681 * SetClassWord (USER.130) (USER32.468)
683 WORD SetClassWord( HWND32 hwnd, INT32 offset, WORD newval )
689 if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return 0;
692 if (offset + sizeof(WORD) <= wndPtr->class->cbClsExtra)
693 ptr = ((char *)wndPtr->class->wExtra) + offset;
696 fprintf( stderr, "Warning: invalid offset %d for SetClassWord()\n",
707 return (WORD)SetClassLong32A( hwnd, offset, (LONG)newval );
708 case GCW_HBRBACKGROUND: ptr = &wndPtr->class->hbrBackground; break;
709 case GCW_HCURSOR: ptr = &wndPtr->class->hCursor; break;
710 case GCW_HICON: ptr = &wndPtr->class->hIcon; break;
711 case GCW_HICONSM: ptr = &wndPtr->class->hIconSm; break;
712 case GCW_ATOM: ptr = &wndPtr->class->atomName; break;
714 fprintf( stderr, "Warning: invalid offset %d for SetClassWord()\n",
718 retval = GET_WORD(ptr);
719 PUT_WORD( ptr, newval );
724 /***********************************************************************
725 * SetClassLong16 (USER.132)
727 LONG SetClassLong16( HWND16 hwnd, INT16 offset, LONG newval )
735 if (!(wndPtr = WIN_FindWndPtr(hwnd))) return 0;
736 retval = (LONG)WINPROC_GetProc( wndPtr->class->winproc, WIN_PROC_16 );
737 WINPROC_SetProc( &wndPtr->class->winproc, (WNDPROC16)newval,
741 return SetClassLong32A( hwnd, offset, (LONG)PTR_SEG_TO_LIN(newval) );
743 return SetClassLong32A( hwnd, offset, newval );
748 /***********************************************************************
749 * SetClassLong32A (USER32.466)
751 LONG SetClassLong32A( HWND32 hwnd, INT32 offset, LONG newval )
757 if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return 0;
760 if (offset + sizeof(LONG) <= wndPtr->class->cbClsExtra)
761 ptr = ((char *)wndPtr->class->wExtra) + offset;
764 fprintf( stderr, "Warning: invalid offset %d for SetClassLong()\n",
772 CLASS_SetMenuNameA( wndPtr->class, (LPCSTR)newval );
773 return 0; /* Old value is now meaningless anyway */
775 retval = (LONG)WINPROC_GetProc( wndPtr->class->winproc,
777 WINPROC_SetProc( &wndPtr->class->winproc, (WNDPROC16)newval,
780 case GCL_HBRBACKGROUND:
784 return SetClassWord( hwnd, offset, (WORD)newval );
785 case GCL_STYLE: ptr = &wndPtr->class->style; break;
786 case GCL_CBWNDEXTRA: ptr = &wndPtr->class->cbWndExtra; break;
787 case GCL_CBCLSEXTRA: ptr = &wndPtr->class->cbClsExtra; break;
788 case GCL_HMODULE: ptr = &wndPtr->class->hInstance; break;
790 fprintf( stderr, "Warning: invalid offset %d for SetClassLong()\n",
794 retval = GET_DWORD(ptr);
795 PUT_DWORD( ptr, newval );
800 /***********************************************************************
801 * SetClassLong32W (USER32.467)
803 LONG SetClassLong32W( HWND32 hwnd, INT32 offset, LONG newval )
811 if (!(wndPtr = WIN_FindWndPtr(hwnd))) return 0;
812 retval = (LONG)WINPROC_GetProc( wndPtr->class->winproc, WIN_PROC_32W );
813 WINPROC_SetProc( &wndPtr->class->winproc, (WNDPROC16)newval,
817 if (!(wndPtr = WIN_FindWndPtr(hwnd))) return 0;
818 CLASS_SetMenuNameW( wndPtr->class, (LPCWSTR)newval );
819 return 0; /* Old value is now meaningless anyway */
821 return SetClassLong32A( hwnd, offset, newval );
826 /***********************************************************************
827 * GetClassName16 (USER.58)
829 INT16 GetClassName16( HWND16 hwnd, LPSTR buffer, INT16 count )
832 if (!(wndPtr = WIN_FindWndPtr(hwnd))) return 0;
833 return GlobalGetAtomName16( wndPtr->class->atomName, buffer, count );
837 /***********************************************************************
838 * GetClassName32A (USER32.216)
840 INT32 GetClassName32A( HWND32 hwnd, LPSTR buffer, INT32 count )
843 if (!(wndPtr = WIN_FindWndPtr(hwnd))) return 0;
844 return GlobalGetAtomName32A( wndPtr->class->atomName, buffer, count );
848 /***********************************************************************
849 * GetClassName32W (USER32.217)
851 INT32 GetClassName32W( HWND32 hwnd, LPWSTR buffer, INT32 count )
854 if (!(wndPtr = WIN_FindWndPtr(hwnd))) return 0;
855 return GlobalGetAtomName32W( wndPtr->class->atomName, buffer, count );
859 /***********************************************************************
860 * GetClassInfo16 (USER.404)
862 BOOL16 GetClassInfo16( HINSTANCE16 hInstance, SEGPTR name, WNDCLASS16 *wc )
867 hInstance = GetExePtr( hInstance );
868 if (!(atom = GlobalFindAtom16( name )) ||
869 !(classPtr = CLASS_FindClassByAtom( atom, hInstance )) ||
870 (hInstance != classPtr->hInstance)) return FALSE;
871 wc->style = (UINT16)classPtr->style;
872 wc->lpfnWndProc = WINPROC_GetProc( classPtr->winproc, WIN_PROC_16 );
873 wc->cbClsExtra = (INT16)classPtr->cbClsExtra;
874 wc->cbWndExtra = (INT16)classPtr->cbWndExtra;
875 wc->hInstance = (HINSTANCE16)classPtr->hInstance;
876 wc->hIcon = classPtr->hIcon;
877 wc->hCursor = classPtr->hCursor;
878 wc->hbrBackground = classPtr->hbrBackground;
879 wc->lpszClassName = (SEGPTR)0;
880 wc->lpszMenuName = (SEGPTR)CLASS_GetMenuNameA( classPtr );
881 if (HIWORD(wc->lpszMenuName)) /* Make it a SEGPTR */
882 wc->lpszMenuName = SEGPTR_GET( (LPSTR)wc->lpszMenuName );
887 /***********************************************************************
888 * GetClassInfo32A (USER32.210)
890 BOOL32 GetClassInfo32A( HINSTANCE32 hInstance, LPCSTR name, WNDCLASS32A *wc )
895 hInstance = GetExePtr( hInstance ); /* FIXME: not needed in Win32 */
896 if (!(atom = GlobalFindAtom32A( name )) ||
897 !(classPtr = CLASS_FindClassByAtom( atom, hInstance )) ||
898 (hInstance != classPtr->hInstance)) return FALSE;
899 wc->style = classPtr->style;
900 wc->lpfnWndProc = (WNDPROC32)WINPROC_GetProc( classPtr->winproc,
902 wc->cbClsExtra = classPtr->cbClsExtra;
903 wc->cbWndExtra = classPtr->cbWndExtra;
904 wc->hInstance = classPtr->hInstance;
905 wc->hIcon = (HICON32)classPtr->hIcon;
906 wc->hCursor = (HCURSOR32)classPtr->hCursor;
907 wc->hbrBackground = (HBRUSH32)classPtr->hbrBackground;
908 wc->lpszMenuName = CLASS_GetMenuNameA( classPtr );
909 wc->lpszClassName = NULL;
914 /***********************************************************************
915 * GetClassInfo32W (USER32.213)
917 BOOL32 GetClassInfo32W( HINSTANCE32 hInstance, LPCWSTR name, WNDCLASS32W *wc )
922 hInstance = GetExePtr( hInstance ); /* FIXME: not needed in Win32 */
923 if (!(atom = GlobalFindAtom32W( name )) ||
924 !(classPtr = CLASS_FindClassByAtom( atom, hInstance )) ||
925 (hInstance != classPtr->hInstance)) return FALSE;
926 wc->style = classPtr->style;
927 wc->lpfnWndProc = (WNDPROC32)WINPROC_GetProc( classPtr->winproc,
929 wc->cbClsExtra = classPtr->cbClsExtra;
930 wc->cbWndExtra = classPtr->cbWndExtra;
931 wc->hInstance = classPtr->hInstance;
932 wc->hIcon = (HICON32)classPtr->hIcon;
933 wc->hCursor = (HCURSOR32)classPtr->hCursor;
934 wc->hbrBackground = (HBRUSH32)classPtr->hbrBackground;
935 wc->lpszMenuName = CLASS_GetMenuNameW( classPtr );
936 wc->lpszClassName = NULL;
941 /***********************************************************************
942 * GetClassInfoEx16 (USER.398)
944 * FIXME: this is just a guess, I have no idea if GetClassInfoEx() is the
945 * same in Win16 as in Win32. --AJ
947 BOOL16 GetClassInfoEx16( HINSTANCE16 hInstance, SEGPTR name, WNDCLASSEX16 *wc )
952 hInstance = GetExePtr( hInstance );
953 if (!(atom = GlobalFindAtom16( name )) ||
954 !(classPtr = CLASS_FindClassByAtom( atom, hInstance )) ||
955 (hInstance != classPtr->hInstance)) return FALSE;
956 wc->style = classPtr->style;
957 wc->lpfnWndProc = WINPROC_GetProc( classPtr->winproc, WIN_PROC_16 );
958 wc->cbClsExtra = (INT16)classPtr->cbClsExtra;
959 wc->cbWndExtra = (INT16)classPtr->cbWndExtra;
960 wc->hInstance = (HINSTANCE16)classPtr->hInstance;
961 wc->hIcon = classPtr->hIcon;
962 wc->hIconSm = classPtr->hIconSm;
963 wc->hCursor = classPtr->hCursor;
964 wc->hbrBackground = classPtr->hbrBackground;
965 wc->lpszClassName = (SEGPTR)0;
966 wc->lpszMenuName = (SEGPTR)CLASS_GetMenuNameA( classPtr );
967 if (HIWORD(wc->lpszMenuName)) /* Make it a SEGPTR */
968 wc->lpszMenuName = SEGPTR_GET( (LPSTR)wc->lpszMenuName );
973 /***********************************************************************
974 * GetClassInfoEx32A (USER32.211)
976 BOOL32 GetClassInfoEx32A( HINSTANCE32 hInstance, LPCSTR name,
982 hInstance = GetExePtr( hInstance ); /* FIXME: not needed in Win32 */
983 if (!(atom = GlobalFindAtom32A( name )) ||
984 !(classPtr = CLASS_FindClassByAtom( atom, hInstance )) ||
985 (hInstance != classPtr->hInstance)) return FALSE;
986 wc->style = classPtr->style;
987 wc->lpfnWndProc = (WNDPROC32)WINPROC_GetProc( classPtr->winproc,
989 wc->cbClsExtra = classPtr->cbClsExtra;
990 wc->cbWndExtra = classPtr->cbWndExtra;
991 wc->hInstance = classPtr->hInstance;
992 wc->hIcon = (HICON32)classPtr->hIcon;
993 wc->hIconSm = (HICON32)classPtr->hIconSm;
994 wc->hCursor = (HCURSOR32)classPtr->hCursor;
995 wc->hbrBackground = (HBRUSH32)classPtr->hbrBackground;
996 wc->lpszMenuName = CLASS_GetMenuNameA( classPtr );
997 wc->lpszClassName = NULL;
1002 /***********************************************************************
1003 * GetClassInfoEx32W (USER32.212)
1005 BOOL32 GetClassInfoEx32W( HINSTANCE32 hInstance, LPCWSTR name,
1011 hInstance = GetExePtr( hInstance ); /* FIXME: not needed in Win32 */
1012 if (!(atom = GlobalFindAtom32W( name )) ||
1013 !(classPtr = CLASS_FindClassByAtom( atom, hInstance )) ||
1014 (hInstance != classPtr->hInstance)) return FALSE;
1015 wc->style = classPtr->style;
1016 wc->lpfnWndProc = (WNDPROC32)WINPROC_GetProc( classPtr->winproc,
1018 wc->cbClsExtra = classPtr->cbClsExtra;
1019 wc->cbWndExtra = classPtr->cbWndExtra;
1020 wc->hInstance = classPtr->hInstance;
1021 wc->hIcon = (HICON32)classPtr->hIcon;
1022 wc->hIconSm = (HICON32)classPtr->hIconSm;
1023 wc->hCursor = (HCURSOR32)classPtr->hCursor;
1024 wc->hbrBackground = (HBRUSH32)classPtr->hbrBackground;
1025 wc->lpszMenuName = CLASS_GetMenuNameW( classPtr );
1026 wc->lpszClassName = NULL;
1031 /***********************************************************************
1032 * ClassFirst (TOOLHELP.69)
1034 BOOL16 ClassFirst( CLASSENTRY *pClassEntry )
1036 pClassEntry->wNext = 1;
1037 return ClassNext( pClassEntry );
1041 /***********************************************************************
1042 * ClassNext (TOOLHELP.70)
1044 BOOL16 ClassNext( CLASSENTRY *pClassEntry )
1047 CLASS *class = firstClass;
1049 if (!pClassEntry->wNext) return FALSE;
1050 for (i = 1; (i < pClassEntry->wNext) && class; i++) class = class->next;
1053 pClassEntry->wNext = 0;
1056 pClassEntry->hInst = class->hInstance;
1057 pClassEntry->wNext++;
1058 GlobalGetAtomName32A( class->atomName, pClassEntry->szClassName,
1059 sizeof(pClassEntry->szClassName) );