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 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
, 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 * Set the window procedure and return the old one.
163 static HANDLE32
CLASS_SetWndProc( CLASS
*classPtr
, HANDLE32 proc
,
164 WINDOWPROCTYPE type
)
166 HANDLE32 oldProc
= classPtr
->winproc
;
167 classPtr
->winproc
= WINPROC_AllocWinProc( proc
, type
);
168 if (oldProc
) WINPROC_FreeWinProc( oldProc
);
173 /***********************************************************************
176 * Free a class structure.
178 static BOOL
CLASS_FreeClass( CLASS
*classPtr
)
182 /* Check if we can remove this class */
184 if (classPtr
->cWindows
> 0) return FALSE
;
186 /* Remove the class from the linked list */
188 for (ppClass
= &firstClass
; *ppClass
; ppClass
= &(*ppClass
)->next
)
189 if (*ppClass
== classPtr
) break;
192 fprintf(stderr
, "ERROR: Class list corrupted\n" );
195 *ppClass
= classPtr
->next
;
197 /* Delete the class */
199 if (classPtr
->hdce
) DCE_FreeDCE( classPtr
->hdce
);
200 if (classPtr
->hbrBackground
) DeleteObject( classPtr
->hbrBackground
);
201 GlobalDeleteAtom( classPtr
->atomName
);
202 CLASS_SetMenuNameA( classPtr
, NULL
);
203 CLASS_SetWndProc( classPtr
, (HANDLE32
)0, WIN_PROC_16
);
204 HeapFree( SystemHeap
, 0, classPtr
);
209 /***********************************************************************
210 * CLASS_FreeModuleClasses
212 void CLASS_FreeModuleClasses( HMODULE hModule
)
216 for (ptr
= firstClass
; ptr
; ptr
= next
)
219 if (ptr
->hInstance
== hModule
) CLASS_FreeClass( ptr
);
224 /***********************************************************************
225 * CLASS_FindClassByAtom
227 * Return a pointer to the class.
229 CLASS
*CLASS_FindClassByAtom( ATOM atom
, HINSTANCE16 hinstance
)
233 /* First search task-specific classes */
235 for (class = firstClass
; (class); class = class->next
)
237 if (class->style
& CS_GLOBALCLASS
) continue;
238 if ((class->atomName
== atom
) &&
239 ((hinstance
==(HINSTANCE16
)0xffff) ||
240 (hinstance
== class->hInstance
))) return class;
243 /* Then search global classes */
245 for (class = firstClass
; (class); class = class->next
)
247 if (!(class->style
& CS_GLOBALCLASS
)) continue;
248 if (class->atomName
== atom
) return class;
255 /***********************************************************************
256 * CLASS_FindClassByName
258 * Return a pointer to the class.
260 CLASS
*CLASS_FindClassByName( SEGPTR name
, HINSTANCE hinstance
)
264 if (!(atom
= GlobalFindAtom16( name
))) return 0;
265 return CLASS_FindClassByAtom( atom
, hinstance
);
269 /***********************************************************************
270 * CLASS_RegisterClass
272 * The real RegisterClass() functionality.
274 static CLASS
*CLASS_RegisterClass( ATOM atom
, HINSTANCE32 hInstance
,
275 DWORD style
, INT32 classExtra
,
276 INT32 winExtra
, HANDLE32 wndProc
,
277 WINDOWPROCTYPE wndProcType
)
281 /* Check if a class with this name already exists */
283 classPtr
= CLASS_FindClassByAtom( atom
, hInstance
);
286 /* Class can be created only if it is local and */
287 /* if the class with the same name is global. */
289 if (style
& CS_GLOBALCLASS
) return NULL
;
290 if (!(classPtr
->style
& CS_GLOBALCLASS
)) return NULL
;
293 /* Fix the extra bytes value */
295 if (classExtra
< 0) classExtra
= 0;
296 else if (classExtra
> 40) /* Extra bytes are limited to 40 in Win32 */
297 fprintf(stderr
, "Warning: class extra bytes %d is > 40\n", classExtra
);
298 if (winExtra
< 0) winExtra
= 0;
299 else if (winExtra
> 40) /* Extra bytes are limited to 40 in Win32 */
300 fprintf( stderr
, "Warning: win extra bytes %d is > 40\n", winExtra
);
302 /* Create the class */
304 classPtr
= (CLASS
*)HeapAlloc( SystemHeap
, 0, sizeof(CLASS
) +
305 classExtra
- sizeof(classPtr
->wExtra
) );
306 if (!classPtr
) return NULL
;
307 classPtr
->next
= firstClass
;
308 classPtr
->magic
= CLASS_MAGIC
;
309 classPtr
->cWindows
= 0;
310 classPtr
->style
= style
;
311 classPtr
->winproc
= 0;
312 classPtr
->cbWndExtra
= winExtra
;
313 classPtr
->cbClsExtra
= classExtra
;
314 classPtr
->hInstance
= hInstance
;
315 classPtr
->atomName
= atom
;
316 classPtr
->menuNameA
= 0;
317 classPtr
->menuNameW
= 0;
318 classPtr
->hdce
= (style
&CS_CLASSDC
) ? DCE_AllocDCE(0, DCE_CLASS_DC
): 0;
319 CLASS_SetWndProc( classPtr
, wndProc
, wndProcType
);
320 /* Other values must be set by caller */
322 if (classExtra
) memset( classPtr
->wExtra
, 0, classExtra
);
323 firstClass
= classPtr
;
328 /***********************************************************************
329 * RegisterClass16 (USER.57)
331 ATOM
RegisterClass16( const WNDCLASS16
*wc
)
336 HINSTANCE32 hInstance
= (HINSTANCE32
)GetExePtr( wc
->hInstance
);
338 if (!(atom
= GlobalAddAtom16( wc
->lpszClassName
))) return 0;
339 if (!(classPtr
= CLASS_RegisterClass( atom
, hInstance
, wc
->style
,
340 wc
->cbClsExtra
, wc
->cbWndExtra
,
341 (HANDLE32
)wc
->lpfnWndProc
,
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 (HANDLE32
)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 (HANDLE32
)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 (HANDLE32
)wc
->lpfnWndProc
,
450 GlobalDeleteAtom( atom
);
454 dprintf_class( stddeb
, "RegisterClassEx16: atom=%04x wndproc=%08lx hinst=%04x bg=%04x style=%08x clsExt=%d winExt=%d class=%p\n",
455 atom
, (DWORD
)wc
->lpfnWndProc
, hInstance
,
456 wc
->hbrBackground
, wc
->style
, wc
->cbClsExtra
,
457 wc
->cbWndExtra
, classPtr
);
459 classPtr
->hIcon
= wc
->hIcon
;
460 classPtr
->hIconSm
= wc
->hIconSm
;
461 classPtr
->hCursor
= wc
->hCursor
;
462 classPtr
->hbrBackground
= wc
->hbrBackground
;
464 CLASS_SetMenuNameA( classPtr
, HIWORD(wc
->lpszMenuName
) ?
465 PTR_SEG_TO_LIN(wc
->lpszMenuName
) : (LPCSTR
)wc
->lpszMenuName
);
470 /***********************************************************************
471 * RegisterClassEx32A (USER32.427)
473 ATOM
RegisterClassEx32A( const WNDCLASSEX32A
* wc
)
478 /* FIXME: this should not be necessary for Win32 */
479 HINSTANCE32 hInstance
= (HINSTANCE32
)GetExePtr( wc
->hInstance
);
481 if (!(atom
= GlobalAddAtom32A( wc
->lpszClassName
))) return 0;
482 if (!(classPtr
= CLASS_RegisterClass( atom
, hInstance
, wc
->style
,
483 wc
->cbClsExtra
, wc
->cbWndExtra
,
484 (HANDLE32
)wc
->lpfnWndProc
,
487 GlobalDeleteAtom( atom
);
491 dprintf_class( stddeb
, "RegisterClassEx32A: atom=%04x wndproc=%08lx hinst=%04x bg=%04x style=%08x clsExt=%d winExt=%d class=%p\n",
492 atom
, (DWORD
)wc
->lpfnWndProc
, hInstance
,
493 wc
->hbrBackground
, wc
->style
, wc
->cbClsExtra
,
494 wc
->cbWndExtra
, classPtr
);
496 classPtr
->hIcon
= (HICON16
)wc
->hIcon
;
497 classPtr
->hIconSm
= (HICON16
)wc
->hIconSm
;
498 classPtr
->hCursor
= (HCURSOR16
)wc
->hCursor
;
499 classPtr
->hbrBackground
= (HBRUSH16
)wc
->hbrBackground
;
500 CLASS_SetMenuNameA( classPtr
, wc
->lpszMenuName
);
505 /***********************************************************************
506 * RegisterClassEx32W (USER32.428)
508 ATOM
RegisterClassEx32W( const WNDCLASSEX32W
* wc
)
513 /* FIXME: this should not be necessary for Win32 */
514 HINSTANCE32 hInstance
= (HINSTANCE32
)GetExePtr( wc
->hInstance
);
516 if (!(atom
= GlobalAddAtom32W( wc
->lpszClassName
))) return 0;
517 if (!(classPtr
= CLASS_RegisterClass( atom
, hInstance
, wc
->style
,
518 wc
->cbClsExtra
, wc
->cbWndExtra
,
519 (HANDLE32
)wc
->lpfnWndProc
,
522 GlobalDeleteAtom( atom
);
526 dprintf_class( stddeb
, "RegisterClassEx32W: atom=%04x wndproc=%08lx hinst=%04x bg=%04x style=%08x clsExt=%d winExt=%d class=%p\n",
527 atom
, (DWORD
)wc
->lpfnWndProc
, hInstance
,
528 wc
->hbrBackground
, wc
->style
, wc
->cbClsExtra
,
529 wc
->cbWndExtra
, classPtr
);
531 classPtr
->hIcon
= (HICON16
)wc
->hIcon
;
532 classPtr
->hIconSm
= (HICON16
)wc
->hIconSm
;
533 classPtr
->hCursor
= (HCURSOR16
)wc
->hCursor
;
534 classPtr
->hbrBackground
= (HBRUSH16
)wc
->hbrBackground
;
535 CLASS_SetMenuNameW( classPtr
, wc
->lpszMenuName
);
540 /***********************************************************************
541 * UnregisterClass16 (USER.403)
543 BOOL16
UnregisterClass16( SEGPTR className
, HINSTANCE16 hInstance
)
548 hInstance
= GetExePtr( hInstance
);
549 if (!(atom
= GlobalFindAtom16( className
))) return FALSE
;
550 if (!(classPtr
= CLASS_FindClassByAtom( atom
, hInstance
)) ||
551 (classPtr
->hInstance
!= hInstance
)) return FALSE
;
552 return CLASS_FreeClass( classPtr
);
556 /***********************************************************************
557 * UnregisterClass32A (USER32.562)
559 BOOL32
UnregisterClass32A( LPCSTR className
, HINSTANCE32 hInstance
)
564 hInstance
= GetExePtr( hInstance
); /* FIXME: not needed in Win32 */
565 if (!(atom
= GlobalFindAtom32A( className
))) return FALSE
;
566 if (!(classPtr
= CLASS_FindClassByAtom( atom
, hInstance
)) ||
567 (classPtr
->hInstance
!= hInstance
)) return FALSE
;
568 return CLASS_FreeClass( classPtr
);
572 /***********************************************************************
573 * UnregisterClass32W (USER32.563)
575 BOOL32
UnregisterClass32W( LPCWSTR className
, HINSTANCE32 hInstance
)
580 hInstance
= GetExePtr( hInstance
); /* FIXME: not needed in Win32 */
581 if (!(atom
= GlobalFindAtom32W( className
))) return FALSE
;
582 if (!(classPtr
= CLASS_FindClassByAtom( atom
, hInstance
)) ||
583 (classPtr
->hInstance
!= hInstance
)) return FALSE
;
584 return CLASS_FreeClass( classPtr
);
588 /***********************************************************************
589 * GetClassWord (USER.129) (USER32.218)
591 WORD
GetClassWord( HWND32 hwnd
, INT32 offset
)
595 if (!(wndPtr
= WIN_FindWndPtr( hwnd
))) return 0;
598 if (offset
<= wndPtr
->class->cbClsExtra
- sizeof(WORD
))
599 return GET_WORD(((char *)wndPtr
->class->wExtra
) + offset
);
603 case GCW_HBRBACKGROUND
: return wndPtr
->class->hbrBackground
;
604 case GCW_HCURSOR
: return wndPtr
->class->hCursor
;
605 case GCW_HICON
: return wndPtr
->class->hIcon
;
606 case GCW_HICONSM
: return wndPtr
->class->hIconSm
;
607 case GCW_ATOM
: return wndPtr
->class->atomName
;
612 return (WORD
)GetClassLong32A( hwnd
, offset
);
614 fprintf(stderr
, "Warning: invalid offset %d for GetClassWord()\n", offset
);
619 /***********************************************************************
620 * GetClassLong16 (USER.131)
622 LONG
GetClassLong16( HWND16 hwnd
, INT16 offset
)
629 ret
= GetClassLong32A( hwnd
, offset
);
630 return (LONG
)SEGPTR_GET( (void *)ret
);
632 ret
= GetClassLong32A( hwnd
, offset
);
633 return (LONG
)WINPROC_GetFunc16( (HANDLE32
)ret
);
635 return GetClassLong32A( hwnd
, offset
);
641 /***********************************************************************
642 * GetClassLong32A (USER32.214)
644 LONG
GetClassLong32A( HWND32 hwnd
, INT32 offset
)
648 if (!(wndPtr
= WIN_FindWndPtr( hwnd
))) return 0;
651 if (offset
<= wndPtr
->class->cbClsExtra
- sizeof(LONG
))
652 return GET_DWORD(((char *)wndPtr
->class->wExtra
) + offset
);
656 case GCL_STYLE
: return (LONG
)wndPtr
->class->style
;
657 case GCL_CBWNDEXTRA
: return (LONG
)wndPtr
->class->cbWndExtra
;
658 case GCL_CBCLSEXTRA
: return (LONG
)wndPtr
->class->cbClsExtra
;
659 case GCL_HMODULE
: return (LONG
)wndPtr
->class->hInstance
;
661 return (LONG
)WINPROC_GetFunc32( wndPtr
->class->winproc
);
663 return (LONG
)CLASS_GetMenuNameA( wndPtr
->class );
664 case GCL_HBRBACKGROUND
:
668 return GetClassWord( hwnd
, offset
);
670 fprintf(stderr
, "Warning: invalid offset %d for GetClassLong()\n", offset
);
675 /***********************************************************************
676 * GetClassLong32W (USER32.215)
678 LONG
GetClassLong32W( HWND32 hwnd
, INT32 offset
)
682 if (offset
!= GCL_MENUNAME
) return GetClassLong32A( hwnd
, offset
);
683 if (!(wndPtr
= WIN_FindWndPtr( hwnd
))) return 0;
684 return (LONG
)CLASS_GetMenuNameW( wndPtr
->class );
688 /***********************************************************************
689 * SetClassWord (USER.130) (USER32.468)
691 WORD
SetClassWord( HWND32 hwnd
, INT32 offset
, WORD newval
)
697 if (!(wndPtr
= WIN_FindWndPtr( hwnd
))) return 0;
700 if (offset
<= wndPtr
->class->cbClsExtra
- sizeof(WORD
))
701 ptr
= ((char *)wndPtr
->class->wExtra
) + offset
;
703 fprintf( stderr
, "Warning: invalid offset %d for SetClassWord()\n",
714 return (WORD
)SetClassLong32A( hwnd
, offset
, (LONG
)newval
);
715 case GCW_HBRBACKGROUND
: ptr
= &wndPtr
->class->hbrBackground
; break;
716 case GCW_HCURSOR
: ptr
= &wndPtr
->class->hCursor
; break;
717 case GCW_HICON
: ptr
= &wndPtr
->class->hIcon
; break;
718 case GCW_HICONSM
: ptr
= &wndPtr
->class->hIconSm
; break;
719 case GCW_ATOM
: ptr
= &wndPtr
->class->atomName
; break;
721 fprintf( stderr
, "Warning: invalid offset %d for SetClassWord()\n",
725 retval
= GET_WORD(ptr
);
726 PUT_WORD( ptr
, newval
);
731 /***********************************************************************
732 * SetClassLong16 (USER.132)
734 LONG
SetClassLong16( HWND16 hwnd
, INT16 offset
, LONG newval
)
741 if (!(wndPtr
= WIN_FindWndPtr(hwnd
))) return 0;
742 return (LONG
)CLASS_SetWndProc( wndPtr
->class, (HANDLE32
)newval
,
745 return SetClassLong32A( hwnd
, offset
, (LONG
)PTR_SEG_TO_LIN(newval
) );
747 return SetClassLong32A( hwnd
, offset
, newval
);
752 /***********************************************************************
753 * SetClassLong32A (USER32.466)
755 LONG
SetClassLong32A( HWND32 hwnd
, INT32 offset
, LONG newval
)
761 if (!(wndPtr
= WIN_FindWndPtr( hwnd
))) return 0;
764 if (offset
<= wndPtr
->class->cbClsExtra
- sizeof(LONG
))
765 ptr
= ((char *)wndPtr
->class->wExtra
) + offset
;
768 fprintf( stderr
, "Warning: invalid offset %d for SetClassLong()\n",
776 CLASS_SetMenuNameA( wndPtr
->class, (LPCSTR
)newval
);
777 return 0; /* Old value is now meaningless anyway */
779 return (LONG
)CLASS_SetWndProc( wndPtr
->class, (HANDLE32
)newval
,
781 case GCL_HBRBACKGROUND
:
785 return SetClassWord( hwnd
, offset
, (WORD
)newval
);
786 case GCL_STYLE
: ptr
= &wndPtr
->class->style
; break;
787 case GCL_CBWNDEXTRA
: ptr
= &wndPtr
->class->cbWndExtra
; break;
788 case GCL_CBCLSEXTRA
: ptr
= &wndPtr
->class->cbClsExtra
; break;
789 case GCL_HMODULE
: ptr
= &wndPtr
->class->hInstance
; break;
791 fprintf( stderr
, "Warning: invalid offset %d for SetClassLong()\n",
795 retval
= GET_DWORD(ptr
);
796 PUT_DWORD( ptr
, newval
);
801 /***********************************************************************
802 * SetClassLong32W (USER32.467)
804 LONG
SetClassLong32W( HWND32 hwnd
, INT32 offset
, LONG newval
)
807 if (!(wndPtr
= WIN_FindWndPtr(hwnd
))) return 0;
812 return (LONG
)CLASS_SetWndProc( wndPtr
->class, (HANDLE32
)newval
,
815 CLASS_SetMenuNameW( wndPtr
->class, (LPCWSTR
)newval
);
816 return 0; /* Old value is now meaningless anyway */
818 return SetClassLong32A( hwnd
, offset
, newval
);
823 /***********************************************************************
824 * GetClassName16 (USER.58)
826 INT16
GetClassName16( HWND16 hwnd
, LPSTR buffer
, INT16 count
)
829 if (!(wndPtr
= WIN_FindWndPtr(hwnd
))) return 0;
830 return GlobalGetAtomName16( wndPtr
->class->atomName
, buffer
, count
);
834 /***********************************************************************
835 * GetClassName32A (USER32.216)
837 INT32
GetClassName32A( HWND32 hwnd
, LPSTR buffer
, INT32 count
)
840 if (!(wndPtr
= WIN_FindWndPtr(hwnd
))) return 0;
841 return GlobalGetAtomName32A( wndPtr
->class->atomName
, buffer
, count
);
845 /***********************************************************************
846 * GetClassName32W (USER32.217)
848 INT32
GetClassName32W( HWND32 hwnd
, LPWSTR buffer
, INT32 count
)
851 if (!(wndPtr
= WIN_FindWndPtr(hwnd
))) return 0;
852 return GlobalGetAtomName32W( wndPtr
->class->atomName
, buffer
, count
);
856 /***********************************************************************
857 * GetClassInfo16 (USER.404)
859 BOOL16
GetClassInfo16( HINSTANCE16 hInstance
, SEGPTR name
, WNDCLASS16
*wc
)
864 hInstance
= GetExePtr( hInstance
);
865 if (!(atom
= GlobalFindAtom16( name
)) ||
866 !(classPtr
= CLASS_FindClassByAtom( atom
, hInstance
)) ||
867 (hInstance
!= classPtr
->hInstance
)) return FALSE
;
868 wc
->style
= (UINT16
)classPtr
->style
;
869 wc
->lpfnWndProc
= WINPROC_GetFunc16( classPtr
->winproc
);
870 wc
->cbClsExtra
= (INT16
)classPtr
->cbClsExtra
;
871 wc
->cbWndExtra
= (INT16
)classPtr
->cbWndExtra
;
872 wc
->hInstance
= (HINSTANCE16
)classPtr
->hInstance
;
873 wc
->hIcon
= classPtr
->hIcon
;
874 wc
->hCursor
= classPtr
->hCursor
;
875 wc
->hbrBackground
= classPtr
->hbrBackground
;
876 wc
->lpszClassName
= (SEGPTR
)0;
877 wc
->lpszMenuName
= (SEGPTR
)CLASS_GetMenuNameA( classPtr
);
878 if (HIWORD(wc
->lpszMenuName
)) /* Make it a SEGPTR */
879 wc
->lpszMenuName
= SEGPTR_GET( (LPSTR
)wc
->lpszMenuName
);
884 /***********************************************************************
885 * GetClassInfo32A (USER32.210)
887 BOOL32
GetClassInfo32A( HINSTANCE32 hInstance
, LPCSTR name
, WNDCLASS32A
*wc
)
892 hInstance
= GetExePtr( hInstance
); /* FIXME: not needed in Win32 */
893 if (!(atom
= GlobalFindAtom32A( name
)) ||
894 !(classPtr
= CLASS_FindClassByAtom( atom
, hInstance
)) ||
895 (hInstance
!= classPtr
->hInstance
)) return FALSE
;
896 wc
->style
= classPtr
->style
;
897 wc
->lpfnWndProc
= WINPROC_GetFunc32( classPtr
->winproc
);
898 wc
->cbClsExtra
= classPtr
->cbClsExtra
;
899 wc
->cbWndExtra
= classPtr
->cbWndExtra
;
900 wc
->hInstance
= classPtr
->hInstance
;
901 wc
->hIcon
= (HICON32
)classPtr
->hIcon
;
902 wc
->hCursor
= (HCURSOR32
)classPtr
->hCursor
;
903 wc
->hbrBackground
= (HBRUSH32
)classPtr
->hbrBackground
;
904 wc
->lpszMenuName
= CLASS_GetMenuNameA( classPtr
);
905 wc
->lpszClassName
= NULL
;
910 /***********************************************************************
911 * GetClassInfo32W (USER32.213)
913 BOOL32
GetClassInfo32W( HINSTANCE32 hInstance
, LPCWSTR name
, WNDCLASS32W
*wc
)
918 hInstance
= GetExePtr( hInstance
); /* FIXME: not needed in Win32 */
919 if (!(atom
= GlobalFindAtom32W( name
)) ||
920 !(classPtr
= CLASS_FindClassByAtom( atom
, hInstance
)) ||
921 (hInstance
!= classPtr
->hInstance
)) return FALSE
;
922 wc
->style
= classPtr
->style
;
923 wc
->lpfnWndProc
= WINPROC_GetFunc32( classPtr
->winproc
);
924 wc
->cbClsExtra
= classPtr
->cbClsExtra
;
925 wc
->cbWndExtra
= classPtr
->cbWndExtra
;
926 wc
->hInstance
= classPtr
->hInstance
;
927 wc
->hIcon
= (HICON32
)classPtr
->hIcon
;
928 wc
->hCursor
= (HCURSOR32
)classPtr
->hCursor
;
929 wc
->hbrBackground
= (HBRUSH32
)classPtr
->hbrBackground
;
930 wc
->lpszMenuName
= CLASS_GetMenuNameW( classPtr
);
931 wc
->lpszClassName
= NULL
;
936 /***********************************************************************
937 * GetClassInfoEx16 (USER.398)
939 * FIXME: this is just a guess, I have no idea if GetClassInfoEx() is the
940 * same in Win16 as in Win32. --AJ
942 BOOL16
GetClassInfoEx16( HINSTANCE16 hInstance
, SEGPTR name
, WNDCLASSEX16
*wc
)
947 hInstance
= GetExePtr( hInstance
);
948 if (!(atom
= GlobalFindAtom16( name
)) ||
949 !(classPtr
= CLASS_FindClassByAtom( atom
, hInstance
)) ||
950 (hInstance
!= classPtr
->hInstance
)) return FALSE
;
951 wc
->style
= classPtr
->style
;
952 wc
->lpfnWndProc
= WINPROC_GetFunc16( classPtr
->winproc
);
953 wc
->cbClsExtra
= (INT16
)classPtr
->cbClsExtra
;
954 wc
->cbWndExtra
= (INT16
)classPtr
->cbWndExtra
;
955 wc
->hInstance
= (HINSTANCE16
)classPtr
->hInstance
;
956 wc
->hIcon
= classPtr
->hIcon
;
957 wc
->hIconSm
= classPtr
->hIconSm
;
958 wc
->hCursor
= classPtr
->hCursor
;
959 wc
->hbrBackground
= classPtr
->hbrBackground
;
960 wc
->lpszClassName
= (SEGPTR
)0;
961 wc
->lpszMenuName
= (SEGPTR
)CLASS_GetMenuNameA( classPtr
);
962 if (HIWORD(wc
->lpszMenuName
)) /* Make it a SEGPTR */
963 wc
->lpszMenuName
= SEGPTR_GET( (LPSTR
)wc
->lpszMenuName
);
968 /***********************************************************************
969 * GetClassInfoEx32A (USER32.211)
971 BOOL32
GetClassInfoEx32A( HINSTANCE32 hInstance
, LPCSTR name
,
977 hInstance
= GetExePtr( hInstance
); /* FIXME: not needed in Win32 */
978 if (!(atom
= GlobalFindAtom32A( name
)) ||
979 !(classPtr
= CLASS_FindClassByAtom( atom
, hInstance
)) ||
980 (hInstance
!= classPtr
->hInstance
)) return FALSE
;
981 wc
->style
= classPtr
->style
;
982 wc
->lpfnWndProc
= WINPROC_GetFunc32( classPtr
->winproc
);
983 wc
->cbClsExtra
= classPtr
->cbClsExtra
;
984 wc
->cbWndExtra
= classPtr
->cbWndExtra
;
985 wc
->hInstance
= classPtr
->hInstance
;
986 wc
->hIcon
= (HICON32
)classPtr
->hIcon
;
987 wc
->hIconSm
= (HICON32
)classPtr
->hIconSm
;
988 wc
->hCursor
= (HCURSOR32
)classPtr
->hCursor
;
989 wc
->hbrBackground
= (HBRUSH32
)classPtr
->hbrBackground
;
990 wc
->lpszMenuName
= CLASS_GetMenuNameA( classPtr
);
991 wc
->lpszClassName
= NULL
;
996 /***********************************************************************
997 * GetClassInfoEx32W (USER32.212)
999 BOOL32
GetClassInfoEx32W( HINSTANCE32 hInstance
, LPCWSTR name
,
1005 hInstance
= GetExePtr( hInstance
); /* FIXME: not needed in Win32 */
1006 if (!(atom
= GlobalFindAtom32W( name
)) ||
1007 !(classPtr
= CLASS_FindClassByAtom( atom
, hInstance
)) ||
1008 (hInstance
!= classPtr
->hInstance
)) return FALSE
;
1009 wc
->style
= classPtr
->style
;
1010 wc
->lpfnWndProc
= WINPROC_GetFunc32( classPtr
->winproc
);
1011 wc
->cbClsExtra
= classPtr
->cbClsExtra
;
1012 wc
->cbWndExtra
= classPtr
->cbWndExtra
;
1013 wc
->hInstance
= classPtr
->hInstance
;
1014 wc
->hIcon
= (HICON32
)classPtr
->hIcon
;
1015 wc
->hIconSm
= (HICON32
)classPtr
->hIconSm
;
1016 wc
->hCursor
= (HCURSOR32
)classPtr
->hCursor
;
1017 wc
->hbrBackground
= (HBRUSH32
)classPtr
->hbrBackground
;
1018 wc
->lpszMenuName
= CLASS_GetMenuNameW( classPtr
);
1019 wc
->lpszClassName
= NULL
;
1024 /***********************************************************************
1025 * ClassFirst (TOOLHELP.69)
1027 BOOL
ClassFirst( CLASSENTRY
*pClassEntry
)
1029 pClassEntry
->wNext
= 1;
1030 return ClassNext( pClassEntry
);
1034 /***********************************************************************
1035 * ClassNext (TOOLHELP.70)
1037 BOOL
ClassNext( CLASSENTRY
*pClassEntry
)
1040 CLASS
*class = firstClass
;
1042 if (!pClassEntry
->wNext
) return FALSE
;
1043 for (i
= 1; (i
< pClassEntry
->wNext
) && class; i
++) class = class->next
;
1046 pClassEntry
->wNext
= 0;
1049 pClassEntry
->hInst
= class->hInstance
;
1050 pClassEntry
->wNext
++;
1051 GlobalGetAtomName32A( class->atomName
, pClassEntry
->szClassName
,
1052 sizeof(pClassEntry
->szClassName
) );