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=%08x\n"
46 "inst=%04x dce=%08x icon=%04x cursor=%04x bkgnd=%04x\n"
47 "clsExtra=%d winExtra=%d #windows=%d\n",
48 ptr
->next
, ptr
->atomName
, className
, ptr
->style
,
49 (UINT32
)ptr
->winproc
, ptr
->hInstance
, (UINT32
)ptr
->dce
,
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
->winproc
);
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 classPtr
->menuNameA
= SEGPTR_STRDUP_WtoA( classPtr
->menuNameW
);
96 return classPtr
->menuNameA
;
100 /***********************************************************************
103 * Get the menu name as a Unicode string.
105 static LPWSTR
CLASS_GetMenuNameW( CLASS
*classPtr
)
107 if (!classPtr
->menuNameW
&& classPtr
->menuNameA
)
109 if (!HIWORD(classPtr
->menuNameA
))
110 return (LPWSTR
)classPtr
->menuNameA
;
111 /* Now we need to copy the ASCII string */
112 classPtr
->menuNameW
= HEAP_strdupAtoW( SystemHeap
, 0,
113 classPtr
->menuNameA
);
115 return classPtr
->menuNameW
;
119 /***********************************************************************
122 * Set the menu name in a class structure by copying the string.
124 static void CLASS_SetMenuNameA( CLASS
*classPtr
, LPCSTR name
)
126 if (HIWORD(classPtr
->menuNameA
)) SEGPTR_FREE( classPtr
->menuNameA
);
127 if (classPtr
->menuNameW
) HeapFree( SystemHeap
, 0, classPtr
->menuNameW
);
128 classPtr
->menuNameA
= SEGPTR_STRDUP( name
);
129 classPtr
->menuNameW
= 0;
133 /***********************************************************************
136 * Set the menu name in a class structure by copying the string.
138 static void CLASS_SetMenuNameW( CLASS
*classPtr
, LPCWSTR name
)
142 CLASS_SetMenuNameA( classPtr
, (LPCSTR
)name
);
145 if (HIWORD(classPtr
->menuNameA
)) SEGPTR_FREE( classPtr
->menuNameA
);
146 if (classPtr
->menuNameW
) HeapFree( SystemHeap
, 0, classPtr
->menuNameW
);
147 if ((classPtr
->menuNameW
= HeapAlloc( SystemHeap
, 0,
148 (lstrlen32W(name
)+1)*sizeof(WCHAR
) )))
149 lstrcpy32W( classPtr
->menuNameW
, name
);
150 classPtr
->menuNameA
= 0;
154 /***********************************************************************
157 * Free a class structure.
159 static BOOL
CLASS_FreeClass( CLASS
*classPtr
)
163 /* Check if we can remove this class */
165 if (classPtr
->cWindows
> 0) return FALSE
;
167 /* Remove the class from the linked list */
169 for (ppClass
= &firstClass
; *ppClass
; ppClass
= &(*ppClass
)->next
)
170 if (*ppClass
== classPtr
) break;
173 fprintf(stderr
, "ERROR: Class list corrupted\n" );
176 *ppClass
= classPtr
->next
;
178 /* Delete the class */
180 if (classPtr
->dce
) DCE_FreeDCE( classPtr
->dce
);
181 if (classPtr
->hbrBackground
) DeleteObject32( classPtr
->hbrBackground
);
182 GlobalDeleteAtom( classPtr
->atomName
);
183 CLASS_SetMenuNameA( classPtr
, NULL
);
184 WINPROC_FreeProc( classPtr
->winproc
);
185 HeapFree( SystemHeap
, 0, classPtr
);
190 /***********************************************************************
191 * CLASS_FreeModuleClasses
193 void CLASS_FreeModuleClasses( HMODULE16 hModule
)
197 for (ptr
= firstClass
; ptr
; ptr
= next
)
200 if (ptr
->hInstance
== hModule
) CLASS_FreeClass( ptr
);
205 /***********************************************************************
206 * CLASS_FindClassByAtom
208 * Return a pointer to the class.
210 CLASS
*CLASS_FindClassByAtom( ATOM atom
, HINSTANCE16 hinstance
)
214 if (hinstance
!= 0xffff) hinstance
= GetExePtr(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
== 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_RegisterClass
241 * The real RegisterClass() functionality.
243 static CLASS
*CLASS_RegisterClass( ATOM atom
, HINSTANCE32 hInstance
,
244 DWORD style
, INT32 classExtra
,
245 INT32 winExtra
, WNDPROC16 wndProc
,
246 WINDOWPROCTYPE wndProcType
)
250 /* Check if a class with this name already exists */
252 classPtr
= CLASS_FindClassByAtom( atom
, hInstance
);
255 /* Class can be created only if it is local and */
256 /* if the class with the same name is global. */
258 if (style
& CS_GLOBALCLASS
) return NULL
;
259 if (!(classPtr
->style
& CS_GLOBALCLASS
)) return NULL
;
262 /* Fix the extra bytes value */
264 if (classExtra
< 0) classExtra
= 0;
265 else if (classExtra
> 40) /* Extra bytes are limited to 40 in Win32 */
266 fprintf(stderr
, "Warning: class extra bytes %d is > 40\n", classExtra
);
267 if (winExtra
< 0) winExtra
= 0;
268 else if (winExtra
> 40) /* Extra bytes are limited to 40 in Win32 */
269 fprintf( stderr
, "Warning: win extra bytes %d is > 40\n", winExtra
);
271 /* Create the class */
273 classPtr
= (CLASS
*)HeapAlloc( SystemHeap
, 0, sizeof(CLASS
) +
274 classExtra
- sizeof(classPtr
->wExtra
) );
275 if (!classPtr
) return NULL
;
276 classPtr
->next
= firstClass
;
277 classPtr
->magic
= CLASS_MAGIC
;
278 classPtr
->cWindows
= 0;
279 classPtr
->style
= style
;
280 classPtr
->winproc
= (HWINDOWPROC
)0;
281 classPtr
->cbWndExtra
= winExtra
;
282 classPtr
->cbClsExtra
= classExtra
;
283 classPtr
->hInstance
= hInstance
;
284 classPtr
->atomName
= atom
;
285 classPtr
->menuNameA
= 0;
286 classPtr
->menuNameW
= 0;
287 classPtr
->dce
= (style
& CS_CLASSDC
) ?
288 DCE_AllocDCE( 0, DCE_CLASS_DC
) : NULL
;
290 WINPROC_SetProc( &classPtr
->winproc
, wndProc
, wndProcType
);
292 /* Other values must be set by caller */
294 if (classExtra
) memset( classPtr
->wExtra
, 0, classExtra
);
295 firstClass
= classPtr
;
300 /***********************************************************************
301 * RegisterClass16 (USER.57)
303 ATOM
RegisterClass16( const WNDCLASS16
*wc
)
308 HINSTANCE32 hInstance
= (HINSTANCE32
)GetExePtr( wc
->hInstance
);
310 if (!(atom
= GlobalAddAtom16( wc
->lpszClassName
))) return 0;
311 if (!(classPtr
= CLASS_RegisterClass( atom
, hInstance
, wc
->style
,
312 wc
->cbClsExtra
, wc
->cbWndExtra
,
313 wc
->lpfnWndProc
, WIN_PROC_16
)))
315 GlobalDeleteAtom( atom
);
319 dprintf_class( stddeb
, "RegisterClass16: atom=%04x wndproc=%08lx hinst=%04x bg=%04x style=%08x clsExt=%d winExt=%d class=%p\n",
320 atom
, (DWORD
)wc
->lpfnWndProc
, hInstance
,
321 wc
->hbrBackground
, wc
->style
, wc
->cbClsExtra
,
322 wc
->cbWndExtra
, classPtr
);
324 classPtr
->hIcon
= wc
->hIcon
;
325 classPtr
->hIconSm
= 0;
326 classPtr
->hCursor
= wc
->hCursor
;
327 classPtr
->hbrBackground
= wc
->hbrBackground
;
329 CLASS_SetMenuNameA( classPtr
, HIWORD(wc
->lpszMenuName
) ?
330 PTR_SEG_TO_LIN(wc
->lpszMenuName
) : (LPCSTR
)wc
->lpszMenuName
);
335 /***********************************************************************
336 * RegisterClass32A (USER32.426)
338 ATOM
RegisterClass32A( const WNDCLASS32A
* wc
)
343 /* FIXME: this should not be necessary for Win32 */
344 HINSTANCE32 hInstance
= (HINSTANCE32
)GetExePtr( wc
->hInstance
);
346 if (!(atom
= GlobalAddAtom32A( wc
->lpszClassName
))) return 0;
347 if (!(classPtr
= CLASS_RegisterClass( atom
, hInstance
, wc
->style
,
348 wc
->cbClsExtra
, wc
->cbWndExtra
,
349 (WNDPROC16
)wc
->lpfnWndProc
,
352 GlobalDeleteAtom( atom
);
356 dprintf_class( stddeb
, "RegisterClass32A: atom=%04x wndproc=%08lx hinst=%04x bg=%04x style=%08x clsExt=%d winExt=%d class=%p\n",
357 atom
, (DWORD
)wc
->lpfnWndProc
, hInstance
,
358 wc
->hbrBackground
, wc
->style
, wc
->cbClsExtra
,
359 wc
->cbWndExtra
, classPtr
);
361 classPtr
->hIcon
= (HICON16
)wc
->hIcon
;
362 classPtr
->hIconSm
= 0;
363 classPtr
->hCursor
= (HCURSOR16
)wc
->hCursor
;
364 classPtr
->hbrBackground
= (HBRUSH16
)wc
->hbrBackground
;
365 CLASS_SetMenuNameA( classPtr
, wc
->lpszMenuName
);
370 /***********************************************************************
371 * RegisterClass32W (USER32.429)
373 ATOM
RegisterClass32W( const WNDCLASS32W
* wc
)
378 /* FIXME: this should not be necessary for Win32 */
379 HINSTANCE32 hInstance
= (HINSTANCE32
)GetExePtr( wc
->hInstance
);
381 if (!(atom
= GlobalAddAtom32W( wc
->lpszClassName
))) return 0;
382 if (!(classPtr
= CLASS_RegisterClass( atom
, hInstance
, wc
->style
,
383 wc
->cbClsExtra
, wc
->cbWndExtra
,
384 (WNDPROC16
)wc
->lpfnWndProc
,
387 GlobalDeleteAtom( atom
);
391 dprintf_class( stddeb
, "RegisterClass32W: atom=%04x wndproc=%08lx hinst=%04x bg=%04x style=%08x clsExt=%d winExt=%d class=%p\n",
392 atom
, (DWORD
)wc
->lpfnWndProc
, hInstance
,
393 wc
->hbrBackground
, wc
->style
, wc
->cbClsExtra
,
394 wc
->cbWndExtra
, classPtr
);
396 classPtr
->hIcon
= (HICON16
)wc
->hIcon
;
397 classPtr
->hIconSm
= 0;
398 classPtr
->hCursor
= (HCURSOR16
)wc
->hCursor
;
399 classPtr
->hbrBackground
= (HBRUSH16
)wc
->hbrBackground
;
400 CLASS_SetMenuNameW( classPtr
, wc
->lpszMenuName
);
405 /***********************************************************************
406 * RegisterClassEx16 (USER.397)
408 ATOM
RegisterClassEx16( const WNDCLASSEX16
*wc
)
413 HINSTANCE32 hInstance
= (HINSTANCE32
)GetExePtr( wc
->hInstance
);
415 if (!(atom
= GlobalAddAtom16( wc
->lpszClassName
))) return 0;
416 if (!(classPtr
= CLASS_RegisterClass( atom
, hInstance
, wc
->style
,
417 wc
->cbClsExtra
, wc
->cbWndExtra
,
418 wc
->lpfnWndProc
, WIN_PROC_16
)))
420 GlobalDeleteAtom( atom
);
424 dprintf_class( stddeb
, "RegisterClassEx16: atom=%04x wndproc=%08lx hinst=%04x bg=%04x style=%08x clsExt=%d winExt=%d class=%p\n",
425 atom
, (DWORD
)wc
->lpfnWndProc
, hInstance
,
426 wc
->hbrBackground
, wc
->style
, wc
->cbClsExtra
,
427 wc
->cbWndExtra
, classPtr
);
429 classPtr
->hIcon
= wc
->hIcon
;
430 classPtr
->hIconSm
= wc
->hIconSm
;
431 classPtr
->hCursor
= wc
->hCursor
;
432 classPtr
->hbrBackground
= wc
->hbrBackground
;
434 CLASS_SetMenuNameA( classPtr
, HIWORD(wc
->lpszMenuName
) ?
435 PTR_SEG_TO_LIN(wc
->lpszMenuName
) : (LPCSTR
)wc
->lpszMenuName
);
440 /***********************************************************************
441 * RegisterClassEx32A (USER32.427)
443 ATOM
RegisterClassEx32A( const WNDCLASSEX32A
* wc
)
448 /* FIXME: this should not be necessary for Win32 */
449 HINSTANCE32 hInstance
= (HINSTANCE32
)GetExePtr( wc
->hInstance
);
451 if (!(atom
= GlobalAddAtom32A( wc
->lpszClassName
))) return 0;
452 if (!(classPtr
= CLASS_RegisterClass( atom
, hInstance
, wc
->style
,
453 wc
->cbClsExtra
, wc
->cbWndExtra
,
454 (WNDPROC16
)wc
->lpfnWndProc
,
457 GlobalDeleteAtom( atom
);
461 dprintf_class( stddeb
, "RegisterClassEx32A: atom=%04x wndproc=%08lx hinst=%04x bg=%04x style=%08x clsExt=%d winExt=%d class=%p\n",
462 atom
, (DWORD
)wc
->lpfnWndProc
, hInstance
,
463 wc
->hbrBackground
, wc
->style
, wc
->cbClsExtra
,
464 wc
->cbWndExtra
, classPtr
);
466 classPtr
->hIcon
= (HICON16
)wc
->hIcon
;
467 classPtr
->hIconSm
= (HICON16
)wc
->hIconSm
;
468 classPtr
->hCursor
= (HCURSOR16
)wc
->hCursor
;
469 classPtr
->hbrBackground
= (HBRUSH16
)wc
->hbrBackground
;
470 CLASS_SetMenuNameA( classPtr
, wc
->lpszMenuName
);
475 /***********************************************************************
476 * RegisterClassEx32W (USER32.428)
478 ATOM
RegisterClassEx32W( const WNDCLASSEX32W
* wc
)
483 /* FIXME: this should not be necessary for Win32 */
484 HINSTANCE32 hInstance
= (HINSTANCE32
)GetExePtr( wc
->hInstance
);
486 if (!(atom
= GlobalAddAtom32W( wc
->lpszClassName
))) return 0;
487 if (!(classPtr
= CLASS_RegisterClass( atom
, hInstance
, wc
->style
,
488 wc
->cbClsExtra
, wc
->cbWndExtra
,
489 (WNDPROC16
)wc
->lpfnWndProc
,
492 GlobalDeleteAtom( atom
);
496 dprintf_class( stddeb
, "RegisterClassEx32W: atom=%04x wndproc=%08lx hinst=%04x bg=%04x style=%08x clsExt=%d winExt=%d class=%p\n",
497 atom
, (DWORD
)wc
->lpfnWndProc
, hInstance
,
498 wc
->hbrBackground
, wc
->style
, wc
->cbClsExtra
,
499 wc
->cbWndExtra
, classPtr
);
501 classPtr
->hIcon
= (HICON16
)wc
->hIcon
;
502 classPtr
->hIconSm
= (HICON16
)wc
->hIconSm
;
503 classPtr
->hCursor
= (HCURSOR16
)wc
->hCursor
;
504 classPtr
->hbrBackground
= (HBRUSH16
)wc
->hbrBackground
;
505 CLASS_SetMenuNameW( classPtr
, wc
->lpszMenuName
);
510 /***********************************************************************
511 * UnregisterClass16 (USER.403)
513 BOOL16
UnregisterClass16( SEGPTR className
, HINSTANCE16 hInstance
)
518 hInstance
= GetExePtr( hInstance
);
519 if (!(atom
= GlobalFindAtom16( className
))) return FALSE
;
520 if (!(classPtr
= CLASS_FindClassByAtom( atom
, hInstance
)) ||
521 (classPtr
->hInstance
!= hInstance
)) return FALSE
;
522 return CLASS_FreeClass( classPtr
);
526 /***********************************************************************
527 * UnregisterClass32A (USER32.562)
529 BOOL32
UnregisterClass32A( LPCSTR className
, HINSTANCE32 hInstance
)
534 hInstance
= GetExePtr( hInstance
); /* FIXME: not needed in Win32 */
535 if (!(atom
= GlobalFindAtom32A( className
))) return FALSE
;
536 if (!(classPtr
= CLASS_FindClassByAtom( atom
, hInstance
)) ||
537 (classPtr
->hInstance
!= hInstance
)) return FALSE
;
538 return CLASS_FreeClass( classPtr
);
542 /***********************************************************************
543 * UnregisterClass32W (USER32.563)
545 BOOL32
UnregisterClass32W( LPCWSTR className
, HINSTANCE32 hInstance
)
550 hInstance
= GetExePtr( hInstance
); /* FIXME: not needed in Win32 */
551 if (!(atom
= GlobalFindAtom32W( className
))) return FALSE
;
552 if (!(classPtr
= CLASS_FindClassByAtom( atom
, hInstance
)) ||
553 (classPtr
->hInstance
!= hInstance
)) return FALSE
;
554 return CLASS_FreeClass( classPtr
);
558 /***********************************************************************
559 * GetClassWord (USER.129) (USER32.218)
561 WORD
GetClassWord( HWND32 hwnd
, INT32 offset
)
565 if (!(wndPtr
= WIN_FindWndPtr( hwnd
))) return 0;
568 if (offset
<= wndPtr
->class->cbClsExtra
- sizeof(WORD
))
569 return GET_WORD(((char *)wndPtr
->class->wExtra
) + offset
);
573 case GCW_HBRBACKGROUND
: return wndPtr
->class->hbrBackground
;
574 case GCW_HCURSOR
: return wndPtr
->class->hCursor
;
575 case GCW_HICON
: return wndPtr
->class->hIcon
;
576 case GCW_HICONSM
: return wndPtr
->class->hIconSm
;
577 case GCW_ATOM
: return wndPtr
->class->atomName
;
582 return (WORD
)GetClassLong32A( hwnd
, offset
);
584 fprintf(stderr
, "Warning: invalid offset %d for GetClassWord()\n", offset
);
589 /***********************************************************************
590 * GetClassLong16 (USER.131)
592 LONG
GetClassLong16( HWND16 hwnd
, INT16 offset
)
600 if (!(wndPtr
= WIN_FindWndPtr( hwnd
))) return 0;
601 return (LONG
)WINPROC_GetProc( wndPtr
->class->winproc
, WIN_PROC_16
);
603 ret
= GetClassLong32A( hwnd
, offset
);
604 return (LONG
)SEGPTR_GET( (void *)ret
);
606 return GetClassLong32A( hwnd
, offset
);
611 /***********************************************************************
612 * GetClassLong32A (USER32.214)
614 LONG
GetClassLong32A( HWND32 hwnd
, INT32 offset
)
618 if (!(wndPtr
= WIN_FindWndPtr( hwnd
))) return 0;
621 if (offset
<= wndPtr
->class->cbClsExtra
- sizeof(LONG
))
622 return GET_DWORD(((char *)wndPtr
->class->wExtra
) + offset
);
626 case GCL_STYLE
: return (LONG
)wndPtr
->class->style
;
627 case GCL_CBWNDEXTRA
: return (LONG
)wndPtr
->class->cbWndExtra
;
628 case GCL_CBCLSEXTRA
: return (LONG
)wndPtr
->class->cbClsExtra
;
629 case GCL_HMODULE
: return (LONG
)wndPtr
->class->hInstance
;
631 return (LONG
)WINPROC_GetProc(wndPtr
->class->winproc
, WIN_PROC_32A
);
633 return (LONG
)CLASS_GetMenuNameA( wndPtr
->class );
634 case GCL_HBRBACKGROUND
:
638 return GetClassWord( hwnd
, offset
);
640 fprintf(stderr
, "Warning: invalid offset %d for GetClassLong()\n", offset
);
645 /***********************************************************************
646 * GetClassLong32W (USER32.215)
648 LONG
GetClassLong32W( HWND32 hwnd
, INT32 offset
)
655 if (!(wndPtr
= WIN_FindWndPtr( hwnd
))) return 0;
656 return (LONG
)WINPROC_GetProc( wndPtr
->class->winproc
, WIN_PROC_32W
);
658 if (!(wndPtr
= WIN_FindWndPtr( hwnd
))) return 0;
659 return (LONG
)CLASS_GetMenuNameW( wndPtr
->class );
661 return GetClassLong32A( hwnd
, offset
);
666 /***********************************************************************
667 * SetClassWord (USER.130) (USER32.468)
669 WORD
SetClassWord( HWND32 hwnd
, INT32 offset
, WORD newval
)
675 if (!(wndPtr
= WIN_FindWndPtr( hwnd
))) return 0;
678 if (offset
+ sizeof(WORD
) <= wndPtr
->class->cbClsExtra
)
679 ptr
= ((char *)wndPtr
->class->wExtra
) + offset
;
682 fprintf( stderr
, "Warning: invalid offset %d for SetClassWord()\n",
693 return (WORD
)SetClassLong32A( hwnd
, offset
, (LONG
)newval
);
694 case GCW_HBRBACKGROUND
: ptr
= &wndPtr
->class->hbrBackground
; break;
695 case GCW_HCURSOR
: ptr
= &wndPtr
->class->hCursor
; break;
696 case GCW_HICON
: ptr
= &wndPtr
->class->hIcon
; break;
697 case GCW_HICONSM
: ptr
= &wndPtr
->class->hIconSm
; break;
698 case GCW_ATOM
: ptr
= &wndPtr
->class->atomName
; break;
700 fprintf( stderr
, "Warning: invalid offset %d for SetClassWord()\n",
704 retval
= GET_WORD(ptr
);
705 PUT_WORD( ptr
, newval
);
710 /***********************************************************************
711 * SetClassLong16 (USER.132)
713 LONG
SetClassLong16( HWND16 hwnd
, INT16 offset
, LONG newval
)
721 if (!(wndPtr
= WIN_FindWndPtr(hwnd
))) return 0;
722 retval
= (LONG
)WINPROC_GetProc( wndPtr
->class->winproc
, WIN_PROC_16
);
723 WINPROC_SetProc( &wndPtr
->class->winproc
, (WNDPROC16
)newval
,
727 return SetClassLong32A( hwnd
, offset
, (LONG
)PTR_SEG_TO_LIN(newval
) );
729 return SetClassLong32A( hwnd
, offset
, newval
);
734 /***********************************************************************
735 * SetClassLong32A (USER32.466)
737 LONG
SetClassLong32A( HWND32 hwnd
, INT32 offset
, LONG newval
)
743 if (!(wndPtr
= WIN_FindWndPtr( hwnd
))) return 0;
746 if (offset
+ sizeof(LONG
) <= wndPtr
->class->cbClsExtra
)
747 ptr
= ((char *)wndPtr
->class->wExtra
) + offset
;
750 fprintf( stderr
, "Warning: invalid offset %d for SetClassLong()\n",
758 CLASS_SetMenuNameA( wndPtr
->class, (LPCSTR
)newval
);
759 return 0; /* Old value is now meaningless anyway */
761 retval
= (LONG
)WINPROC_GetProc( wndPtr
->class->winproc
,
763 WINPROC_SetProc( &wndPtr
->class->winproc
, (WNDPROC16
)newval
,
766 case GCL_HBRBACKGROUND
:
770 return SetClassWord( hwnd
, offset
, (WORD
)newval
);
771 case GCL_STYLE
: ptr
= &wndPtr
->class->style
; break;
772 case GCL_CBWNDEXTRA
: ptr
= &wndPtr
->class->cbWndExtra
; break;
773 case GCL_CBCLSEXTRA
: ptr
= &wndPtr
->class->cbClsExtra
; break;
774 case GCL_HMODULE
: ptr
= &wndPtr
->class->hInstance
; break;
776 fprintf( stderr
, "Warning: invalid offset %d for SetClassLong()\n",
780 retval
= GET_DWORD(ptr
);
781 PUT_DWORD( ptr
, newval
);
786 /***********************************************************************
787 * SetClassLong32W (USER32.467)
789 LONG
SetClassLong32W( HWND32 hwnd
, INT32 offset
, LONG newval
)
797 if (!(wndPtr
= WIN_FindWndPtr(hwnd
))) return 0;
798 retval
= (LONG
)WINPROC_GetProc( wndPtr
->class->winproc
, WIN_PROC_32W
);
799 WINPROC_SetProc( &wndPtr
->class->winproc
, (WNDPROC16
)newval
,
803 if (!(wndPtr
= WIN_FindWndPtr(hwnd
))) return 0;
804 CLASS_SetMenuNameW( wndPtr
->class, (LPCWSTR
)newval
);
805 return 0; /* Old value is now meaningless anyway */
807 return SetClassLong32A( hwnd
, offset
, newval
);
812 /***********************************************************************
813 * GetClassName16 (USER.58)
815 INT16
GetClassName16( HWND16 hwnd
, LPSTR buffer
, INT16 count
)
818 if (!(wndPtr
= WIN_FindWndPtr(hwnd
))) return 0;
819 return GlobalGetAtomName16( wndPtr
->class->atomName
, buffer
, count
);
823 /***********************************************************************
824 * GetClassName32A (USER32.216)
826 INT32
GetClassName32A( HWND32 hwnd
, LPSTR buffer
, INT32 count
)
829 if (!(wndPtr
= WIN_FindWndPtr(hwnd
))) return 0;
830 return GlobalGetAtomName32A( wndPtr
->class->atomName
, buffer
, count
);
834 /***********************************************************************
835 * GetClassName32W (USER32.217)
837 INT32
GetClassName32W( HWND32 hwnd
, LPWSTR buffer
, INT32 count
)
840 if (!(wndPtr
= WIN_FindWndPtr(hwnd
))) return 0;
841 return GlobalGetAtomName32W( wndPtr
->class->atomName
, buffer
, count
);
845 /***********************************************************************
846 * GetClassInfo16 (USER.404)
848 BOOL16
GetClassInfo16( HINSTANCE16 hInstance
, SEGPTR name
, WNDCLASS16
*wc
)
853 hInstance
= GetExePtr( hInstance
);
854 if (!(atom
= GlobalFindAtom16( name
)) ||
855 !(classPtr
= CLASS_FindClassByAtom( atom
, hInstance
)) ||
856 (hInstance
!= classPtr
->hInstance
)) return FALSE
;
857 wc
->style
= (UINT16
)classPtr
->style
;
858 wc
->lpfnWndProc
= WINPROC_GetProc( classPtr
->winproc
, WIN_PROC_16
);
859 wc
->cbClsExtra
= (INT16
)classPtr
->cbClsExtra
;
860 wc
->cbWndExtra
= (INT16
)classPtr
->cbWndExtra
;
861 wc
->hInstance
= (HINSTANCE16
)classPtr
->hInstance
;
862 wc
->hIcon
= classPtr
->hIcon
;
863 wc
->hCursor
= classPtr
->hCursor
;
864 wc
->hbrBackground
= classPtr
->hbrBackground
;
865 wc
->lpszClassName
= (SEGPTR
)0;
866 wc
->lpszMenuName
= (SEGPTR
)CLASS_GetMenuNameA( classPtr
);
867 if (HIWORD(wc
->lpszMenuName
)) /* Make it a SEGPTR */
868 wc
->lpszMenuName
= SEGPTR_GET( (LPSTR
)wc
->lpszMenuName
);
873 /***********************************************************************
874 * GetClassInfo32A (USER32.210)
876 BOOL32
GetClassInfo32A( HINSTANCE32 hInstance
, LPCSTR name
, WNDCLASS32A
*wc
)
881 hInstance
= GetExePtr( hInstance
); /* FIXME: not needed in Win32 */
882 if (!(atom
= GlobalFindAtom32A( name
)) ||
883 !(classPtr
= CLASS_FindClassByAtom( atom
, hInstance
)) ||
884 (hInstance
!= classPtr
->hInstance
)) return FALSE
;
885 wc
->style
= classPtr
->style
;
886 wc
->lpfnWndProc
= (WNDPROC32
)WINPROC_GetProc( classPtr
->winproc
,
888 wc
->cbClsExtra
= classPtr
->cbClsExtra
;
889 wc
->cbWndExtra
= classPtr
->cbWndExtra
;
890 wc
->hInstance
= classPtr
->hInstance
;
891 wc
->hIcon
= (HICON32
)classPtr
->hIcon
;
892 wc
->hCursor
= (HCURSOR32
)classPtr
->hCursor
;
893 wc
->hbrBackground
= (HBRUSH32
)classPtr
->hbrBackground
;
894 wc
->lpszMenuName
= CLASS_GetMenuNameA( classPtr
);
895 wc
->lpszClassName
= NULL
;
900 /***********************************************************************
901 * GetClassInfo32W (USER32.213)
903 BOOL32
GetClassInfo32W( HINSTANCE32 hInstance
, LPCWSTR name
, WNDCLASS32W
*wc
)
908 hInstance
= GetExePtr( hInstance
); /* FIXME: not needed in Win32 */
909 if (!(atom
= GlobalFindAtom32W( name
)) ||
910 !(classPtr
= CLASS_FindClassByAtom( atom
, hInstance
)) ||
911 (hInstance
!= classPtr
->hInstance
)) return FALSE
;
912 wc
->style
= classPtr
->style
;
913 wc
->lpfnWndProc
= (WNDPROC32
)WINPROC_GetProc( classPtr
->winproc
,
915 wc
->cbClsExtra
= classPtr
->cbClsExtra
;
916 wc
->cbWndExtra
= classPtr
->cbWndExtra
;
917 wc
->hInstance
= classPtr
->hInstance
;
918 wc
->hIcon
= (HICON32
)classPtr
->hIcon
;
919 wc
->hCursor
= (HCURSOR32
)classPtr
->hCursor
;
920 wc
->hbrBackground
= (HBRUSH32
)classPtr
->hbrBackground
;
921 wc
->lpszMenuName
= CLASS_GetMenuNameW( classPtr
);
922 wc
->lpszClassName
= NULL
;
927 /***********************************************************************
928 * GetClassInfoEx16 (USER.398)
930 * FIXME: this is just a guess, I have no idea if GetClassInfoEx() is the
931 * same in Win16 as in Win32. --AJ
933 BOOL16
GetClassInfoEx16( HINSTANCE16 hInstance
, SEGPTR name
, WNDCLASSEX16
*wc
)
938 hInstance
= GetExePtr( hInstance
);
939 if (!(atom
= GlobalFindAtom16( name
)) ||
940 !(classPtr
= CLASS_FindClassByAtom( atom
, hInstance
)) ||
941 (hInstance
!= classPtr
->hInstance
)) return FALSE
;
942 wc
->style
= classPtr
->style
;
943 wc
->lpfnWndProc
= WINPROC_GetProc( classPtr
->winproc
, WIN_PROC_16
);
944 wc
->cbClsExtra
= (INT16
)classPtr
->cbClsExtra
;
945 wc
->cbWndExtra
= (INT16
)classPtr
->cbWndExtra
;
946 wc
->hInstance
= (HINSTANCE16
)classPtr
->hInstance
;
947 wc
->hIcon
= classPtr
->hIcon
;
948 wc
->hIconSm
= classPtr
->hIconSm
;
949 wc
->hCursor
= classPtr
->hCursor
;
950 wc
->hbrBackground
= classPtr
->hbrBackground
;
951 wc
->lpszClassName
= (SEGPTR
)0;
952 wc
->lpszMenuName
= (SEGPTR
)CLASS_GetMenuNameA( classPtr
);
953 if (HIWORD(wc
->lpszMenuName
)) /* Make it a SEGPTR */
954 wc
->lpszMenuName
= SEGPTR_GET( (LPSTR
)wc
->lpszMenuName
);
959 /***********************************************************************
960 * GetClassInfoEx32A (USER32.211)
962 BOOL32
GetClassInfoEx32A( HINSTANCE32 hInstance
, LPCSTR name
,
968 hInstance
= GetExePtr( hInstance
); /* FIXME: not needed in Win32 */
969 if (!(atom
= GlobalFindAtom32A( name
)) ||
970 !(classPtr
= CLASS_FindClassByAtom( atom
, hInstance
)) ||
971 (hInstance
!= classPtr
->hInstance
)) return FALSE
;
972 wc
->style
= classPtr
->style
;
973 wc
->lpfnWndProc
= (WNDPROC32
)WINPROC_GetProc( classPtr
->winproc
,
975 wc
->cbClsExtra
= classPtr
->cbClsExtra
;
976 wc
->cbWndExtra
= classPtr
->cbWndExtra
;
977 wc
->hInstance
= classPtr
->hInstance
;
978 wc
->hIcon
= (HICON32
)classPtr
->hIcon
;
979 wc
->hIconSm
= (HICON32
)classPtr
->hIconSm
;
980 wc
->hCursor
= (HCURSOR32
)classPtr
->hCursor
;
981 wc
->hbrBackground
= (HBRUSH32
)classPtr
->hbrBackground
;
982 wc
->lpszMenuName
= CLASS_GetMenuNameA( classPtr
);
983 wc
->lpszClassName
= NULL
;
988 /***********************************************************************
989 * GetClassInfoEx32W (USER32.212)
991 BOOL32
GetClassInfoEx32W( HINSTANCE32 hInstance
, LPCWSTR name
,
997 hInstance
= GetExePtr( hInstance
); /* FIXME: not needed in Win32 */
998 if (!(atom
= GlobalFindAtom32W( name
)) ||
999 !(classPtr
= CLASS_FindClassByAtom( atom
, hInstance
)) ||
1000 (hInstance
!= classPtr
->hInstance
)) return FALSE
;
1001 wc
->style
= classPtr
->style
;
1002 wc
->lpfnWndProc
= (WNDPROC32
)WINPROC_GetProc( classPtr
->winproc
,
1004 wc
->cbClsExtra
= classPtr
->cbClsExtra
;
1005 wc
->cbWndExtra
= classPtr
->cbWndExtra
;
1006 wc
->hInstance
= classPtr
->hInstance
;
1007 wc
->hIcon
= (HICON32
)classPtr
->hIcon
;
1008 wc
->hIconSm
= (HICON32
)classPtr
->hIconSm
;
1009 wc
->hCursor
= (HCURSOR32
)classPtr
->hCursor
;
1010 wc
->hbrBackground
= (HBRUSH32
)classPtr
->hbrBackground
;
1011 wc
->lpszMenuName
= CLASS_GetMenuNameW( classPtr
);
1012 wc
->lpszClassName
= NULL
;
1017 /***********************************************************************
1018 * ClassFirst (TOOLHELP.69)
1020 BOOL16
ClassFirst( CLASSENTRY
*pClassEntry
)
1022 pClassEntry
->wNext
= 1;
1023 return ClassNext( pClassEntry
);
1027 /***********************************************************************
1028 * ClassNext (TOOLHELP.70)
1030 BOOL16
ClassNext( CLASSENTRY
*pClassEntry
)
1033 CLASS
*class = firstClass
;
1035 if (!pClassEntry
->wNext
) return FALSE
;
1036 for (i
= 1; (i
< pClassEntry
->wNext
) && class; i
++) class = class->next
;
1039 pClassEntry
->wNext
= 0;
1042 pClassEntry
->hInst
= class->hInstance
;
1043 pClassEntry
->wNext
++;
1044 GlobalGetAtomName32A( class->atomName
, pClassEntry
->szClassName
,
1045 sizeof(pClassEntry
->szClassName
) );