blob: ae75f003d45e724b9eea84d6a030b320d91ce5e3 [file] [log] [blame]
Alexandre Julliard401710d1993-09-04 10:09:32 +00001/*
2 * Window classes functions
3 *
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00004 * Copyright 1993, 1996 Alexandre Julliard
Alexandre Julliardbd34d4f1995-06-20 19:08:12 +00005 */
Alexandre Julliard401710d1993-09-04 10:09:32 +00006
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00007#include <stdlib.h>
8#include <stdio.h>
9#include <string.h>
Alexandre Julliard401710d1993-09-04 10:09:32 +000010#include "class.h"
Alexandre Julliard1285c2f1996-05-06 16:06:24 +000011#include "heap.h"
Alexandre Julliard401710d1993-09-04 10:09:32 +000012#include "win.h"
Alexandre Julliard5f721f81994-01-04 20:14:34 +000013#include "dce.h"
Alexandre Julliarde2991ea1995-07-29 13:09:43 +000014#include "atom.h"
Alexandre Julliard808cb041995-08-17 17:11:36 +000015#include "ldt.h"
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +000016#include "string32.h"
Alexandre Julliarde2abbb11995-03-19 17:39:39 +000017#include "toolhelp.h"
Alexandre Julliard2d93d001996-05-21 15:01:41 +000018#include "winproc.h"
Alexandre Julliardaca05781994-10-17 18:12:41 +000019#include "stddebug.h"
Alexandre Julliardaca05781994-10-17 18:12:41 +000020#include "debug.h"
Alexandre Julliard8d24ae61994-04-05 21:42:43 +000021
Alexandre Julliard401710d1993-09-04 10:09:32 +000022
Alexandre Julliard2ace16a1996-04-28 15:09:19 +000023static CLASS *firstClass = NULL;
Alexandre Julliard401710d1993-09-04 10:09:32 +000024
25
26/***********************************************************************
Alexandre Julliardb817f4f1996-03-14 18:08:34 +000027 * CLASS_DumpClass
28 *
29 * Dump the content of a class structure to stderr.
30 */
Alexandre Julliard2ace16a1996-04-28 15:09:19 +000031void CLASS_DumpClass( CLASS *ptr )
Alexandre Julliardb817f4f1996-03-14 18:08:34 +000032{
Alexandre Julliardb817f4f1996-03-14 18:08:34 +000033 char className[80];
34 int i;
35
Alexandre Julliard1285c2f1996-05-06 16:06:24 +000036 if (ptr->magic != CLASS_MAGIC)
Alexandre Julliardb817f4f1996-03-14 18:08:34 +000037 {
Alexandre Julliard2ace16a1996-04-28 15:09:19 +000038 fprintf( stderr, "%p is not a class\n", ptr );
Alexandre Julliardb817f4f1996-03-14 18:08:34 +000039 return;
40 }
Alexandre Julliard2ace16a1996-04-28 15:09:19 +000041
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +000042 GlobalGetAtomName32A( ptr->atomName, className, sizeof(className) );
Alexandre Julliardb817f4f1996-03-14 18:08:34 +000043
Alexandre Julliard2ace16a1996-04-28 15:09:19 +000044 fprintf( stderr, "Class %p:\n", ptr );
Alexandre Julliardb817f4f1996-03-14 18:08:34 +000045 fprintf( stderr,
Alexandre Julliard1e9ac791996-06-06 18:38:27 +000046 "next=%p name=%04x '%s' style=%08x wndProc=%08x\n"
Alexandre Julliardb817f4f1996-03-14 18:08:34 +000047 "inst=%04x hdce=%04x icon=%04x cursor=%04x bkgnd=%04x\n"
48 "clsExtra=%d winExtra=%d #windows=%d\n",
Alexandre Julliard1285c2f1996-05-06 16:06:24 +000049 ptr->next, ptr->atomName, className, ptr->style,
Alexandre Julliard3051b641996-07-05 17:14:13 +000050 (UINT32)ptr->winproc, ptr->hInstance, ptr->hdce,
Alexandre Julliard1285c2f1996-05-06 16:06:24 +000051 ptr->hIcon, ptr->hCursor, ptr->hbrBackground,
52 ptr->cbClsExtra, ptr->cbWndExtra, ptr->cWindows );
53 if (ptr->cbClsExtra)
Alexandre Julliardb817f4f1996-03-14 18:08:34 +000054 {
55 fprintf( stderr, "extra bytes:" );
Alexandre Julliard1285c2f1996-05-06 16:06:24 +000056 for (i = 0; i < ptr->cbClsExtra; i++)
Alexandre Julliardb817f4f1996-03-14 18:08:34 +000057 fprintf( stderr, " %02x", *((BYTE *)ptr->wExtra+i) );
58 fprintf( stderr, "\n" );
59 }
60 fprintf( stderr, "\n" );
61}
62
63
64/***********************************************************************
65 * CLASS_WalkClasses
66 *
67 * Walk the class list and print each class on stderr.
68 */
69void CLASS_WalkClasses(void)
70{
Alexandre Julliardb817f4f1996-03-14 18:08:34 +000071 CLASS *ptr;
72 char className[80];
73
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +000074 fprintf( stderr, " Class Name Style WndProc\n" );
Alexandre Julliard2ace16a1996-04-28 15:09:19 +000075 for (ptr = firstClass; ptr; ptr = ptr->next)
Alexandre Julliardb817f4f1996-03-14 18:08:34 +000076 {
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +000077 GlobalGetAtomName32A( ptr->atomName, className, sizeof(className) );
78 fprintf( stderr, "%08x %-20.20s %08x %08x\n", (UINT32)ptr, className,
Alexandre Julliard3051b641996-07-05 17:14:13 +000079 ptr->style, (UINT32)ptr->winproc );
Alexandre Julliardb817f4f1996-03-14 18:08:34 +000080 }
81 fprintf( stderr, "\n" );
82}
83
84
85/***********************************************************************
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +000086 * CLASS_GetMenuNameA
87 *
88 * Get the menu name as a ASCII string.
89 */
90static LPSTR CLASS_GetMenuNameA( CLASS *classPtr )
91{
92 if (!classPtr->menuNameA && classPtr->menuNameW)
93 {
94 /* We need to copy the Unicode string */
95 if ((classPtr->menuNameA = SEGPTR_ALLOC(
Alexandre Julliardd90840e1996-06-11 16:02:08 +000096 lstrlen32W(classPtr->menuNameW) + 1 )))
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +000097 STRING32_UniToAnsi( classPtr->menuNameA, classPtr->menuNameW );
98 }
99 return classPtr->menuNameA;
100}
101
102
103/***********************************************************************
104 * CLASS_GetMenuNameW
105 *
106 * Get the menu name as a Unicode string.
107 */
108static LPWSTR CLASS_GetMenuNameW( CLASS *classPtr )
109{
110 if (!classPtr->menuNameW && classPtr->menuNameA)
111 {
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 );
118 }
119 return classPtr->menuNameW;
120}
121
122
123/***********************************************************************
124 * CLASS_SetMenuNameA
125 *
126 * Set the menu name in a class structure by copying the string.
127 */
128static void CLASS_SetMenuNameA( CLASS *classPtr, LPCSTR name )
129{
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;
134}
135
136
137/***********************************************************************
138 * CLASS_SetMenuNameW
139 *
140 * Set the menu name in a class structure by copying the string.
141 */
142static void CLASS_SetMenuNameW( CLASS *classPtr, LPCWSTR name )
143{
144 if (!HIWORD(name))
145 {
146 CLASS_SetMenuNameA( classPtr, (LPCSTR)name );
147 return;
148 }
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,
Alexandre Julliardd90840e1996-06-11 16:02:08 +0000152 (lstrlen32W(name)+1)*sizeof(WCHAR) )))
153 lstrcpy32W( classPtr->menuNameW, name );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000154 classPtr->menuNameA = 0;
155}
156
157
158/***********************************************************************
Alexandre Julliard2ace16a1996-04-28 15:09:19 +0000159 * CLASS_FreeClass
160 *
161 * Free a class structure.
162 */
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000163static BOOL CLASS_FreeClass( CLASS *classPtr )
Alexandre Julliard2ace16a1996-04-28 15:09:19 +0000164{
165 CLASS **ppClass;
166
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000167 /* Check if we can remove this class */
168
169 if (classPtr->cWindows > 0) return FALSE;
170
Alexandre Julliard2ace16a1996-04-28 15:09:19 +0000171 /* Remove the class from the linked list */
172
173 for (ppClass = &firstClass; *ppClass; ppClass = &(*ppClass)->next)
174 if (*ppClass == classPtr) break;
175 if (!*ppClass)
176 {
177 fprintf(stderr, "ERROR: Class list corrupted\n" );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000178 return FALSE;
Alexandre Julliard2ace16a1996-04-28 15:09:19 +0000179 }
180 *ppClass = classPtr->next;
181
182 /* Delete the class */
183
184 if (classPtr->hdce) DCE_FreeDCE( classPtr->hdce );
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000185 if (classPtr->hbrBackground) DeleteObject( classPtr->hbrBackground );
Alexandre Julliard2ace16a1996-04-28 15:09:19 +0000186 GlobalDeleteAtom( classPtr->atomName );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000187 CLASS_SetMenuNameA( classPtr, NULL );
Alexandre Julliard3051b641996-07-05 17:14:13 +0000188 WINPROC_FreeProc( classPtr->winproc );
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000189 HeapFree( SystemHeap, 0, classPtr );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000190 return TRUE;
Alexandre Julliard2ace16a1996-04-28 15:09:19 +0000191}
192
193
194/***********************************************************************
195 * CLASS_FreeModuleClasses
196 */
Alexandre Julliard3051b641996-07-05 17:14:13 +0000197void CLASS_FreeModuleClasses( HMODULE16 hModule )
Alexandre Julliard2ace16a1996-04-28 15:09:19 +0000198{
199 CLASS *ptr, *next;
200
201 for (ptr = firstClass; ptr; ptr = next)
202 {
203 next = ptr->next;
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000204 if (ptr->hInstance == hModule) CLASS_FreeClass( ptr );
Alexandre Julliard2ace16a1996-04-28 15:09:19 +0000205 }
206}
207
208
209/***********************************************************************
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000210 * CLASS_FindClassByAtom
211 *
212 * Return a pointer to the class.
213 */
214CLASS *CLASS_FindClassByAtom( ATOM atom, HINSTANCE16 hinstance )
215{
216 CLASS * class;
217
218 /* First search task-specific classes */
219
220 for (class = firstClass; (class); class = class->next)
221 {
222 if (class->style & CS_GLOBALCLASS) continue;
223 if ((class->atomName == atom) &&
224 ((hinstance==(HINSTANCE16)0xffff) ||
225 (hinstance == class->hInstance))) return class;
226 }
227
228 /* Then search global classes */
229
230 for (class = firstClass; (class); class = class->next)
231 {
232 if (!(class->style & CS_GLOBALCLASS)) continue;
233 if (class->atomName == atom) return class;
234 }
235
236 return 0;
237}
238
239
240/***********************************************************************
Alexandre Julliard401710d1993-09-04 10:09:32 +0000241 * CLASS_FindClassByName
242 *
Alexandre Julliard2ace16a1996-04-28 15:09:19 +0000243 * Return a pointer to the class.
Alexandre Julliard401710d1993-09-04 10:09:32 +0000244 */
Alexandre Julliard2ace16a1996-04-28 15:09:19 +0000245CLASS *CLASS_FindClassByName( SEGPTR name, HINSTANCE hinstance )
Alexandre Julliard401710d1993-09-04 10:09:32 +0000246{
Alexandre Julliard5f721f81994-01-04 20:14:34 +0000247 ATOM atom;
Alexandre Julliard5f721f81994-01-04 20:14:34 +0000248
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000249 if (!(atom = GlobalFindAtom16( name ))) return 0;
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000250 return CLASS_FindClassByAtom( atom, hinstance );
Alexandre Julliard401710d1993-09-04 10:09:32 +0000251}
252
Alexandre Julliard5f721f81994-01-04 20:14:34 +0000253
Alexandre Julliard401710d1993-09-04 10:09:32 +0000254/***********************************************************************
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000255 * CLASS_RegisterClass
256 *
257 * The real RegisterClass() functionality.
258 */
259static CLASS *CLASS_RegisterClass( ATOM atom, HINSTANCE32 hInstance,
260 DWORD style, INT32 classExtra,
Alexandre Julliard3051b641996-07-05 17:14:13 +0000261 INT32 winExtra, WNDPROC16 wndProc,
Alexandre Julliard2d93d001996-05-21 15:01:41 +0000262 WINDOWPROCTYPE wndProcType )
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000263{
264 CLASS *classPtr;
265
266 /* Check if a class with this name already exists */
267
268 classPtr = CLASS_FindClassByAtom( atom, hInstance );
269 if (classPtr)
270 {
271 /* Class can be created only if it is local and */
272 /* if the class with the same name is global. */
273
274 if (style & CS_GLOBALCLASS) return NULL;
275 if (!(classPtr->style & CS_GLOBALCLASS)) return NULL;
276 }
277
278 /* Fix the extra bytes value */
279
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 );
286
287 /* Create the class */
288
289 classPtr = (CLASS *)HeapAlloc( SystemHeap, 0, sizeof(CLASS) +
290 classExtra - sizeof(classPtr->wExtra) );
291 if (!classPtr) return NULL;
Alexandre Julliard2d93d001996-05-21 15:01:41 +0000292 classPtr->next = firstClass;
293 classPtr->magic = CLASS_MAGIC;
294 classPtr->cWindows = 0;
295 classPtr->style = style;
Alexandre Julliard3051b641996-07-05 17:14:13 +0000296 classPtr->winproc = (HWINDOWPROC)0;
Alexandre Julliard2d93d001996-05-21 15:01:41 +0000297 classPtr->cbWndExtra = winExtra;
298 classPtr->cbClsExtra = classExtra;
299 classPtr->hInstance = hInstance;
300 classPtr->atomName = atom;
301 classPtr->menuNameA = 0;
302 classPtr->menuNameW = 0;
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000303 classPtr->hdce = (style&CS_CLASSDC) ? DCE_AllocDCE(0, DCE_CLASS_DC): 0;
Alexandre Julliard3051b641996-07-05 17:14:13 +0000304 WINPROC_SetProc( &classPtr->winproc, wndProc, wndProcType );
305
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000306 /* Other values must be set by caller */
307
308 if (classExtra) memset( classPtr->wExtra, 0, classExtra );
309 firstClass = classPtr;
310 return classPtr;
311}
312
313
314/***********************************************************************
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000315 * RegisterClass16 (USER.57)
Alexandre Julliard401710d1993-09-04 10:09:32 +0000316 */
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000317ATOM RegisterClass16( const WNDCLASS16 *wc )
Alexandre Julliard401710d1993-09-04 10:09:32 +0000318{
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000319 ATOM atom;
320 CLASS *classPtr;
Alexandre Julliard6b81b391994-07-07 16:23:58 +0000321
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000322 HINSTANCE32 hInstance = (HINSTANCE32)GetExePtr( wc->hInstance );
323
324 if (!(atom = GlobalAddAtom16( wc->lpszClassName ))) return 0;
325 if (!(classPtr = CLASS_RegisterClass( atom, hInstance, wc->style,
Alexandre Julliard2d93d001996-05-21 15:01:41 +0000326 wc->cbClsExtra, wc->cbWndExtra,
Alexandre Julliard3051b641996-07-05 17:14:13 +0000327 wc->lpfnWndProc, WIN_PROC_16 )))
Alexandre Julliard5f721f81994-01-04 20:14:34 +0000328 {
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000329 GlobalDeleteAtom( atom );
330 return 0;
Alexandre Julliard5f721f81994-01-04 20:14:34 +0000331 }
332
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000333 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 );
Alexandre Julliard5f721f81994-01-04 20:14:34 +0000337
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000338 classPtr->hIcon = wc->hIcon;
339 classPtr->hIconSm = 0;
340 classPtr->hCursor = wc->hCursor;
341 classPtr->hbrBackground = wc->hbrBackground;
Alexandre Julliardf0b23541993-09-29 12:21:49 +0000342
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000343 CLASS_SetMenuNameA( classPtr, HIWORD(wc->lpszMenuName) ?
344 PTR_SEG_TO_LIN(wc->lpszMenuName) : (LPCSTR)wc->lpszMenuName );
345 return atom;
Alexandre Julliard401710d1993-09-04 10:09:32 +0000346}
347
348
349/***********************************************************************
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000350 * RegisterClass32A (USER32.426)
Alexandre Julliard401710d1993-09-04 10:09:32 +0000351 */
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000352ATOM RegisterClass32A( const WNDCLASS32A* wc )
353{
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000354 ATOM atom;
355 CLASS *classPtr;
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000356
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000357 /* FIXME: this should not be necessary for Win32 */
358 HINSTANCE32 hInstance = (HINSTANCE32)GetExePtr( wc->hInstance );
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000359
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000360 if (!(atom = GlobalAddAtom32A( wc->lpszClassName ))) return 0;
361 if (!(classPtr = CLASS_RegisterClass( atom, hInstance, wc->style,
Alexandre Julliard2d93d001996-05-21 15:01:41 +0000362 wc->cbClsExtra, wc->cbWndExtra,
Alexandre Julliard3051b641996-07-05 17:14:13 +0000363 (WNDPROC16)wc->lpfnWndProc,
Alexandre Julliard2d93d001996-05-21 15:01:41 +0000364 WIN_PROC_32A )))
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000365 {
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000366 GlobalDeleteAtom( atom );
367 return 0;
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000368 }
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000369
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 );
374
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000375 classPtr->hIcon = (HICON16)wc->hIcon;
376 classPtr->hIconSm = 0;
377 classPtr->hCursor = (HCURSOR16)wc->hCursor;
378 classPtr->hbrBackground = (HBRUSH16)wc->hbrBackground;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000379 CLASS_SetMenuNameA( classPtr, wc->lpszMenuName );
380 return atom;
381}
382
383
384/***********************************************************************
385 * RegisterClass32W (USER32.429)
386 */
387ATOM RegisterClass32W( const WNDCLASS32W* wc )
388{
389 ATOM atom;
390 CLASS *classPtr;
391
392 /* FIXME: this should not be necessary for Win32 */
393 HINSTANCE32 hInstance = (HINSTANCE32)GetExePtr( wc->hInstance );
394
395 if (!(atom = GlobalAddAtom32W( wc->lpszClassName ))) return 0;
396 if (!(classPtr = CLASS_RegisterClass( atom, hInstance, wc->style,
Alexandre Julliard2d93d001996-05-21 15:01:41 +0000397 wc->cbClsExtra, wc->cbWndExtra,
Alexandre Julliard3051b641996-07-05 17:14:13 +0000398 (WNDPROC16)wc->lpfnWndProc,
Alexandre Julliard2d93d001996-05-21 15:01:41 +0000399 WIN_PROC_32W )))
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000400 {
401 GlobalDeleteAtom( atom );
402 return 0;
403 }
404
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 );
409
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000410 classPtr->hIcon = (HICON16)wc->hIcon;
411 classPtr->hIconSm = 0;
412 classPtr->hCursor = (HCURSOR16)wc->hCursor;
413 classPtr->hbrBackground = (HBRUSH16)wc->hbrBackground;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000414 CLASS_SetMenuNameW( classPtr, wc->lpszMenuName );
415 return atom;
416}
417
418
419/***********************************************************************
420 * RegisterClassEx16 (USER.397)
421 */
422ATOM RegisterClassEx16( const WNDCLASSEX16 *wc )
423{
424 ATOM atom;
425 CLASS *classPtr;
426
427 HINSTANCE32 hInstance = (HINSTANCE32)GetExePtr( wc->hInstance );
428
429 if (!(atom = GlobalAddAtom16( wc->lpszClassName ))) return 0;
430 if (!(classPtr = CLASS_RegisterClass( atom, hInstance, wc->style,
Alexandre Julliard2d93d001996-05-21 15:01:41 +0000431 wc->cbClsExtra, wc->cbWndExtra,
Alexandre Julliard3051b641996-07-05 17:14:13 +0000432 wc->lpfnWndProc, WIN_PROC_16 )))
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000433 {
434 GlobalDeleteAtom( atom );
435 return 0;
436 }
437
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 );
442
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000443 classPtr->hIcon = wc->hIcon;
444 classPtr->hIconSm = wc->hIconSm;
445 classPtr->hCursor = wc->hCursor;
446 classPtr->hbrBackground = wc->hbrBackground;
447
448 CLASS_SetMenuNameA( classPtr, HIWORD(wc->lpszMenuName) ?
449 PTR_SEG_TO_LIN(wc->lpszMenuName) : (LPCSTR)wc->lpszMenuName );
450 return atom;
451}
452
453
454/***********************************************************************
455 * RegisterClassEx32A (USER32.427)
456 */
457ATOM RegisterClassEx32A( const WNDCLASSEX32A* wc )
458{
459 ATOM atom;
460 CLASS *classPtr;
461
462 /* FIXME: this should not be necessary for Win32 */
463 HINSTANCE32 hInstance = (HINSTANCE32)GetExePtr( wc->hInstance );
464
465 if (!(atom = GlobalAddAtom32A( wc->lpszClassName ))) return 0;
466 if (!(classPtr = CLASS_RegisterClass( atom, hInstance, wc->style,
Alexandre Julliard2d93d001996-05-21 15:01:41 +0000467 wc->cbClsExtra, wc->cbWndExtra,
Alexandre Julliard3051b641996-07-05 17:14:13 +0000468 (WNDPROC16)wc->lpfnWndProc,
Alexandre Julliard2d93d001996-05-21 15:01:41 +0000469 WIN_PROC_32A )))
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000470 {
471 GlobalDeleteAtom( atom );
472 return 0;
473 }
474
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 );
479
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000480 classPtr->hIcon = (HICON16)wc->hIcon;
481 classPtr->hIconSm = (HICON16)wc->hIconSm;
482 classPtr->hCursor = (HCURSOR16)wc->hCursor;
483 classPtr->hbrBackground = (HBRUSH16)wc->hbrBackground;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000484 CLASS_SetMenuNameA( classPtr, wc->lpszMenuName );
485 return atom;
486}
487
488
489/***********************************************************************
490 * RegisterClassEx32W (USER32.428)
491 */
492ATOM RegisterClassEx32W( const WNDCLASSEX32W* wc )
493{
494 ATOM atom;
495 CLASS *classPtr;
496
497 /* FIXME: this should not be necessary for Win32 */
498 HINSTANCE32 hInstance = (HINSTANCE32)GetExePtr( wc->hInstance );
499
500 if (!(atom = GlobalAddAtom32W( wc->lpszClassName ))) return 0;
501 if (!(classPtr = CLASS_RegisterClass( atom, hInstance, wc->style,
Alexandre Julliard2d93d001996-05-21 15:01:41 +0000502 wc->cbClsExtra, wc->cbWndExtra,
Alexandre Julliard3051b641996-07-05 17:14:13 +0000503 (WNDPROC16)wc->lpfnWndProc,
Alexandre Julliard2d93d001996-05-21 15:01:41 +0000504 WIN_PROC_32W )))
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000505 {
506 GlobalDeleteAtom( atom );
507 return 0;
508 }
509
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 );
514
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000515 classPtr->hIcon = (HICON16)wc->hIcon;
516 classPtr->hIconSm = (HICON16)wc->hIconSm;
517 classPtr->hCursor = (HCURSOR16)wc->hCursor;
518 classPtr->hbrBackground = (HBRUSH16)wc->hbrBackground;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000519 CLASS_SetMenuNameW( classPtr, wc->lpszMenuName );
520 return atom;
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000521}
522
523
524/***********************************************************************
525 * UnregisterClass16 (USER.403)
526 */
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000527BOOL16 UnregisterClass16( SEGPTR className, HINSTANCE16 hInstance )
Alexandre Julliard401710d1993-09-04 10:09:32 +0000528{
Alexandre Julliard2ace16a1996-04-28 15:09:19 +0000529 CLASS *classPtr;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000530 ATOM atom;
Alexandre Julliard2ace16a1996-04-28 15:09:19 +0000531
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000532 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 );
Alexandre Julliard401710d1993-09-04 10:09:32 +0000537}
538
539
540/***********************************************************************
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000541 * UnregisterClass32A (USER32.562)
Alexandre Julliard401710d1993-09-04 10:09:32 +0000542 */
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000543BOOL32 UnregisterClass32A( LPCSTR className, HINSTANCE32 hInstance )
544{
545 CLASS *classPtr;
546 ATOM atom;
547
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 );
553}
554
555
556/***********************************************************************
557 * UnregisterClass32W (USER32.563)
558 */
559BOOL32 UnregisterClass32W( LPCWSTR className, HINSTANCE32 hInstance )
560{
561 CLASS *classPtr;
562 ATOM atom;
563
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 );
569}
570
571
572/***********************************************************************
573 * GetClassWord (USER.129) (USER32.218)
574 */
Alexandre Julliard2d93d001996-05-21 15:01:41 +0000575WORD GetClassWord( HWND32 hwnd, INT32 offset )
Alexandre Julliard401710d1993-09-04 10:09:32 +0000576{
Alexandre Julliard2ace16a1996-04-28 15:09:19 +0000577 WND * wndPtr;
578
579 if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return 0;
580 if (offset >= 0)
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000581 {
582 if (offset <= wndPtr->class->cbClsExtra - sizeof(WORD))
583 return GET_WORD(((char *)wndPtr->class->wExtra) + offset);
584 }
585 else switch(offset)
Alexandre Julliard2ace16a1996-04-28 15:09:19 +0000586 {
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000587 case GCW_HBRBACKGROUND: return wndPtr->class->hbrBackground;
588 case GCW_HCURSOR: return wndPtr->class->hCursor;
589 case GCW_HICON: return wndPtr->class->hIcon;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000590 case GCW_HICONSM: return wndPtr->class->hIconSm;
Alexandre Julliard2ace16a1996-04-28 15:09:19 +0000591 case GCW_ATOM: return wndPtr->class->atomName;
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000592 case GCW_STYLE:
593 case GCW_CBWNDEXTRA:
594 case GCW_CBCLSEXTRA:
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000595 case GCW_HMODULE:
596 return (WORD)GetClassLong32A( hwnd, offset );
Alexandre Julliard2ace16a1996-04-28 15:09:19 +0000597 }
598 fprintf(stderr, "Warning: invalid offset %d for GetClassWord()\n", offset);
599 return 0;
Alexandre Julliard401710d1993-09-04 10:09:32 +0000600}
601
602
603/***********************************************************************
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000604 * GetClassLong16 (USER.131)
Alexandre Julliard401710d1993-09-04 10:09:32 +0000605 */
Alexandre Julliardd90840e1996-06-11 16:02:08 +0000606LONG GetClassLong16( HWND16 hwnd, INT16 offset )
Alexandre Julliard401710d1993-09-04 10:09:32 +0000607{
Alexandre Julliard3051b641996-07-05 17:14:13 +0000608 WND *wndPtr;
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000609 LONG ret;
610
611 switch( offset )
612 {
Alexandre Julliard3051b641996-07-05 17:14:13 +0000613 case GCL_WNDPROC:
614 if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return 0;
615 return (LONG)WINPROC_GetProc( wndPtr->class->winproc, WIN_PROC_16 );
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000616 case GCL_MENUNAME:
617 ret = GetClassLong32A( hwnd, offset );
618 return (LONG)SEGPTR_GET( (void *)ret );
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000619 default:
620 return GetClassLong32A( hwnd, offset );
621 }
Alexandre Julliard401710d1993-09-04 10:09:32 +0000622}
623
624
625/***********************************************************************
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000626 * GetClassLong32A (USER32.214)
Alexandre Julliard401710d1993-09-04 10:09:32 +0000627 */
Alexandre Julliardd90840e1996-06-11 16:02:08 +0000628LONG GetClassLong32A( HWND32 hwnd, INT32 offset )
Alexandre Julliard401710d1993-09-04 10:09:32 +0000629{
Alexandre Julliard401710d1993-09-04 10:09:32 +0000630 WND * wndPtr;
Alexandre Julliard401710d1993-09-04 10:09:32 +0000631
632 if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return 0;
Alexandre Julliard2ace16a1996-04-28 15:09:19 +0000633 if (offset >= 0)
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000634 {
635 if (offset <= wndPtr->class->cbClsExtra - sizeof(LONG))
636 return GET_DWORD(((char *)wndPtr->class->wExtra) + offset);
637 }
Alexandre Julliard2ace16a1996-04-28 15:09:19 +0000638 switch(offset)
639 {
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000640 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;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000643 case GCL_HMODULE: return (LONG)wndPtr->class->hInstance;
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000644 case GCL_WNDPROC:
Alexandre Julliard3051b641996-07-05 17:14:13 +0000645 return (LONG)WINPROC_GetProc(wndPtr->class->winproc, WIN_PROC_32A);
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000646 case GCL_MENUNAME:
647 return (LONG)CLASS_GetMenuNameA( wndPtr->class );
648 case GCL_HBRBACKGROUND:
649 case GCL_HCURSOR:
650 case GCL_HICON:
651 case GCL_HICONSM:
652 return GetClassWord( hwnd, offset );
Alexandre Julliard2ace16a1996-04-28 15:09:19 +0000653 }
654 fprintf(stderr, "Warning: invalid offset %d for GetClassLong()\n", offset);
655 return 0;
Alexandre Julliard401710d1993-09-04 10:09:32 +0000656}
657
658
659/***********************************************************************
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000660 * GetClassLong32W (USER32.215)
Alexandre Julliard401710d1993-09-04 10:09:32 +0000661 */
Alexandre Julliardd90840e1996-06-11 16:02:08 +0000662LONG GetClassLong32W( HWND32 hwnd, INT32 offset )
Alexandre Julliard401710d1993-09-04 10:09:32 +0000663{
Alexandre Julliard401710d1993-09-04 10:09:32 +0000664 WND * wndPtr;
Alexandre Julliard3051b641996-07-05 17:14:13 +0000665
666 switch(offset)
667 {
668 case GCL_WNDPROC:
669 if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return 0;
670 return (LONG)WINPROC_GetProc( wndPtr->class->winproc, WIN_PROC_32W );
671 case GCL_MENUNAME:
672 if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return 0;
673 return (LONG)CLASS_GetMenuNameW( wndPtr->class );
674 default:
675 return GetClassLong32A( hwnd, offset );
676 }
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000677}
678
679
680/***********************************************************************
681 * SetClassWord (USER.130) (USER32.468)
682 */
Alexandre Julliard2d93d001996-05-21 15:01:41 +0000683WORD SetClassWord( HWND32 hwnd, INT32 offset, WORD newval )
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000684{
685 WND * wndPtr;
686 WORD retval = 0;
687 void *ptr;
Alexandre Julliard401710d1993-09-04 10:09:32 +0000688
689 if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return 0;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000690 if (offset >= 0)
691 {
Alexandre Julliard3051b641996-07-05 17:14:13 +0000692 if (offset + sizeof(WORD) <= wndPtr->class->cbClsExtra)
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000693 ptr = ((char *)wndPtr->class->wExtra) + offset;
Alexandre Julliard3051b641996-07-05 17:14:13 +0000694 else
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000695 {
696 fprintf( stderr, "Warning: invalid offset %d for SetClassWord()\n",
697 offset );
698 return 0;
699 }
700 }
Alexandre Julliard2ace16a1996-04-28 15:09:19 +0000701 else switch(offset)
702 {
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000703 case GCW_STYLE:
704 case GCW_CBWNDEXTRA:
705 case GCW_CBCLSEXTRA:
706 case GCW_HMODULE:
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;
Alexandre Julliard2ace16a1996-04-28 15:09:19 +0000713 default:
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000714 fprintf( stderr, "Warning: invalid offset %d for SetClassWord()\n",
Alexandre Julliard2ace16a1996-04-28 15:09:19 +0000715 offset);
716 return 0;
717 }
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000718 retval = GET_WORD(ptr);
719 PUT_WORD( ptr, newval );
Alexandre Julliard401710d1993-09-04 10:09:32 +0000720 return retval;
721}
Alexandre Julliard5f721f81994-01-04 20:14:34 +0000722
723
724/***********************************************************************
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000725 * SetClassLong16 (USER.132)
Alexandre Julliard5f721f81994-01-04 20:14:34 +0000726 */
Alexandre Julliardd90840e1996-06-11 16:02:08 +0000727LONG SetClassLong16( HWND16 hwnd, INT16 offset, LONG newval )
Alexandre Julliard5f721f81994-01-04 20:14:34 +0000728{
Alexandre Julliard2d93d001996-05-21 15:01:41 +0000729 WND *wndPtr;
Alexandre Julliard3051b641996-07-05 17:14:13 +0000730 LONG retval;
Alexandre Julliard2d93d001996-05-21 15:01:41 +0000731
732 switch(offset)
733 {
734 case GCL_WNDPROC:
735 if (!(wndPtr = WIN_FindWndPtr(hwnd))) return 0;
Alexandre Julliard3051b641996-07-05 17:14:13 +0000736 retval = (LONG)WINPROC_GetProc( wndPtr->class->winproc, WIN_PROC_16 );
737 WINPROC_SetProc( &wndPtr->class->winproc, (WNDPROC16)newval,
738 WIN_PROC_16 );
739 return retval;
Alexandre Julliard2d93d001996-05-21 15:01:41 +0000740 case GCL_MENUNAME:
741 return SetClassLong32A( hwnd, offset, (LONG)PTR_SEG_TO_LIN(newval) );
742 default:
743 return SetClassLong32A( hwnd, offset, newval );
744 }
Alexandre Julliard5f721f81994-01-04 20:14:34 +0000745}
746
747
748/***********************************************************************
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000749 * SetClassLong32A (USER32.466)
Alexandre Julliard5f721f81994-01-04 20:14:34 +0000750 */
Alexandre Julliardd90840e1996-06-11 16:02:08 +0000751LONG SetClassLong32A( HWND32 hwnd, INT32 offset, LONG newval )
Alexandre Julliard5f721f81994-01-04 20:14:34 +0000752{
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000753 WND * wndPtr;
754 LONG retval = 0;
755 void *ptr;
756
757 if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return 0;
758 if (offset >= 0)
759 {
Alexandre Julliard3051b641996-07-05 17:14:13 +0000760 if (offset + sizeof(LONG) <= wndPtr->class->cbClsExtra)
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000761 ptr = ((char *)wndPtr->class->wExtra) + offset;
762 else
763 {
764 fprintf( stderr, "Warning: invalid offset %d for SetClassLong()\n",
765 offset );
766 return 0;
767 }
768 }
769 else switch(offset)
770 {
771 case GCL_MENUNAME:
772 CLASS_SetMenuNameA( wndPtr->class, (LPCSTR)newval );
773 return 0; /* Old value is now meaningless anyway */
Alexandre Julliard2d93d001996-05-21 15:01:41 +0000774 case GCL_WNDPROC:
Alexandre Julliard3051b641996-07-05 17:14:13 +0000775 retval = (LONG)WINPROC_GetProc( wndPtr->class->winproc,
776 WIN_PROC_32A );
777 WINPROC_SetProc( &wndPtr->class->winproc, (WNDPROC16)newval,
778 WIN_PROC_32A );
779 return retval;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000780 case GCL_HBRBACKGROUND:
781 case GCL_HCURSOR:
782 case GCL_HICON:
783 case GCL_HICONSM:
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;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000788 case GCL_HMODULE: ptr = &wndPtr->class->hInstance; break;
789 default:
790 fprintf( stderr, "Warning: invalid offset %d for SetClassLong()\n",
791 offset);
792 return 0;
793 }
794 retval = GET_DWORD(ptr);
795 PUT_DWORD( ptr, newval );
796 return retval;
797}
798
799
800/***********************************************************************
801 * SetClassLong32W (USER32.467)
802 */
Alexandre Julliardd90840e1996-06-11 16:02:08 +0000803LONG SetClassLong32W( HWND32 hwnd, INT32 offset, LONG newval )
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000804{
805 WND *wndPtr;
Alexandre Julliard3051b641996-07-05 17:14:13 +0000806 LONG retval;
Alexandre Julliard2d93d001996-05-21 15:01:41 +0000807
808 switch(offset)
809 {
810 case GCL_WNDPROC:
Alexandre Julliard3051b641996-07-05 17:14:13 +0000811 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,
814 WIN_PROC_32W );
815 return retval;
Alexandre Julliard2d93d001996-05-21 15:01:41 +0000816 case GCL_MENUNAME:
Alexandre Julliard3051b641996-07-05 17:14:13 +0000817 if (!(wndPtr = WIN_FindWndPtr(hwnd))) return 0;
Alexandre Julliard2d93d001996-05-21 15:01:41 +0000818 CLASS_SetMenuNameW( wndPtr->class, (LPCWSTR)newval );
819 return 0; /* Old value is now meaningless anyway */
820 default:
821 return SetClassLong32A( hwnd, offset, newval );
822 }
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000823}
824
825
826/***********************************************************************
827 * GetClassName16 (USER.58)
828 */
Alexandre Julliardd90840e1996-06-11 16:02:08 +0000829INT16 GetClassName16( HWND16 hwnd, LPSTR buffer, INT16 count )
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000830{
831 WND *wndPtr;
832 if (!(wndPtr = WIN_FindWndPtr(hwnd))) return 0;
833 return GlobalGetAtomName16( wndPtr->class->atomName, buffer, count );
834}
835
836
837/***********************************************************************
838 * GetClassName32A (USER32.216)
839 */
Alexandre Julliardd90840e1996-06-11 16:02:08 +0000840INT32 GetClassName32A( HWND32 hwnd, LPSTR buffer, INT32 count )
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000841{
842 WND *wndPtr;
843 if (!(wndPtr = WIN_FindWndPtr(hwnd))) return 0;
844 return GlobalGetAtomName32A( wndPtr->class->atomName, buffer, count );
845}
846
847
848/***********************************************************************
849 * GetClassName32W (USER32.217)
850 */
Alexandre Julliardd90840e1996-06-11 16:02:08 +0000851INT32 GetClassName32W( HWND32 hwnd, LPWSTR buffer, INT32 count )
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000852{
853 WND *wndPtr;
854 if (!(wndPtr = WIN_FindWndPtr(hwnd))) return 0;
855 return GlobalGetAtomName32W( wndPtr->class->atomName, buffer, count );
856}
857
858
859/***********************************************************************
860 * GetClassInfo16 (USER.404)
861 */
Alexandre Julliardd90840e1996-06-11 16:02:08 +0000862BOOL16 GetClassInfo16( HINSTANCE16 hInstance, SEGPTR name, WNDCLASS16 *wc )
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000863{
864 ATOM atom;
Alexandre Julliard5f721f81994-01-04 20:14:34 +0000865 CLASS *classPtr;
Alexandre Julliard3ed37e01994-11-07 18:20:42 +0000866
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000867 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;
Alexandre Julliard3051b641996-07-05 17:14:13 +0000872 wc->lpfnWndProc = WINPROC_GetProc( classPtr->winproc, WIN_PROC_16 );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000873 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 );
883 return TRUE;
884}
885
886
887/***********************************************************************
888 * GetClassInfo32A (USER32.210)
889 */
Alexandre Julliardd90840e1996-06-11 16:02:08 +0000890BOOL32 GetClassInfo32A( HINSTANCE32 hInstance, LPCSTR name, WNDCLASS32A *wc )
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000891{
892 ATOM atom;
893 CLASS *classPtr;
894
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;
Alexandre Julliard3051b641996-07-05 17:14:13 +0000900 wc->lpfnWndProc = (WNDPROC32)WINPROC_GetProc( classPtr->winproc,
901 WIN_PROC_32A );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000902 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;
910 return TRUE;
911}
912
913
914/***********************************************************************
915 * GetClassInfo32W (USER32.213)
916 */
Alexandre Julliardd90840e1996-06-11 16:02:08 +0000917BOOL32 GetClassInfo32W( HINSTANCE32 hInstance, LPCWSTR name, WNDCLASS32W *wc )
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000918{
919 ATOM atom;
920 CLASS *classPtr;
921
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;
Alexandre Julliard3051b641996-07-05 17:14:13 +0000927 wc->lpfnWndProc = (WNDPROC32)WINPROC_GetProc( classPtr->winproc,
928 WIN_PROC_32W );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000929 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;
937 return TRUE;
938}
939
940
941/***********************************************************************
942 * GetClassInfoEx16 (USER.398)
943 *
944 * FIXME: this is just a guess, I have no idea if GetClassInfoEx() is the
945 * same in Win16 as in Win32. --AJ
946 */
Alexandre Julliardd90840e1996-06-11 16:02:08 +0000947BOOL16 GetClassInfoEx16( HINSTANCE16 hInstance, SEGPTR name, WNDCLASSEX16 *wc )
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000948{
949 ATOM atom;
950 CLASS *classPtr;
Alexandre Julliard808cb041995-08-17 17:11:36 +0000951
952 hInstance = GetExePtr( hInstance );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000953 if (!(atom = GlobalFindAtom16( name )) ||
954 !(classPtr = CLASS_FindClassByAtom( atom, hInstance )) ||
955 (hInstance != classPtr->hInstance)) return FALSE;
956 wc->style = classPtr->style;
Alexandre Julliard3051b641996-07-05 17:14:13 +0000957 wc->lpfnWndProc = WINPROC_GetProc( classPtr->winproc, WIN_PROC_16 );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000958 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 );
969 return TRUE;
970}
Alexandre Julliard5f721f81994-01-04 20:14:34 +0000971
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000972
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000973/***********************************************************************
974 * GetClassInfoEx32A (USER32.211)
975 */
Alexandre Julliardd90840e1996-06-11 16:02:08 +0000976BOOL32 GetClassInfoEx32A( HINSTANCE32 hInstance, LPCSTR name,
977 WNDCLASSEX32A *wc )
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000978{
979 ATOM atom;
980 CLASS *classPtr;
981
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;
Alexandre Julliard3051b641996-07-05 17:14:13 +0000987 wc->lpfnWndProc = (WNDPROC32)WINPROC_GetProc( classPtr->winproc,
988 WIN_PROC_32A );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000989 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;
998 return TRUE;
999}
1000
1001
1002/***********************************************************************
1003 * GetClassInfoEx32W (USER32.212)
1004 */
Alexandre Julliardd90840e1996-06-11 16:02:08 +00001005BOOL32 GetClassInfoEx32W( HINSTANCE32 hInstance, LPCWSTR name,
1006 WNDCLASSEX32W *wc )
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001007{
1008 ATOM atom;
1009 CLASS *classPtr;
1010
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;
Alexandre Julliard3051b641996-07-05 17:14:13 +00001016 wc->lpfnWndProc = (WNDPROC32)WINPROC_GetProc( classPtr->winproc,
1017 WIN_PROC_32W );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001018 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;
Alexandre Julliard5f721f81994-01-04 20:14:34 +00001027 return TRUE;
1028}
Alexandre Julliarde2abbb11995-03-19 17:39:39 +00001029
1030
1031/***********************************************************************
1032 * ClassFirst (TOOLHELP.69)
1033 */
Alexandre Julliard3051b641996-07-05 17:14:13 +00001034BOOL16 ClassFirst( CLASSENTRY *pClassEntry )
Alexandre Julliarde2abbb11995-03-19 17:39:39 +00001035{
Alexandre Julliard2ace16a1996-04-28 15:09:19 +00001036 pClassEntry->wNext = 1;
Alexandre Julliarde2abbb11995-03-19 17:39:39 +00001037 return ClassNext( pClassEntry );
1038}
1039
1040
1041/***********************************************************************
1042 * ClassNext (TOOLHELP.70)
1043 */
Alexandre Julliard3051b641996-07-05 17:14:13 +00001044BOOL16 ClassNext( CLASSENTRY *pClassEntry )
Alexandre Julliarde2abbb11995-03-19 17:39:39 +00001045{
Alexandre Julliard2ace16a1996-04-28 15:09:19 +00001046 int i;
1047 CLASS *class = firstClass;
Alexandre Julliarde2abbb11995-03-19 17:39:39 +00001048
Alexandre Julliard2ace16a1996-04-28 15:09:19 +00001049 if (!pClassEntry->wNext) return FALSE;
1050 for (i = 1; (i < pClassEntry->wNext) && class; i++) class = class->next;
1051 if (!class)
1052 {
1053 pClassEntry->wNext = 0;
1054 return FALSE;
1055 }
Alexandre Julliard1285c2f1996-05-06 16:06:24 +00001056 pClassEntry->hInst = class->hInstance;
Alexandre Julliard2ace16a1996-04-28 15:09:19 +00001057 pClassEntry->wNext++;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001058 GlobalGetAtomName32A( class->atomName, pClassEntry->szClassName,
1059 sizeof(pClassEntry->szClassName) );
Alexandre Julliarde2abbb11995-03-19 17:39:39 +00001060 return TRUE;
1061}