1 /* $Id: class.c,v 1.28 2003/08/09 07:09:57 jimtabor Exp $
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS user32.dll
5 * FILE: lib/user32/windows/class.c
6 * PURPOSE: Window classes
7 * PROGRAMMER: Casper S. Hornstrup (chorns@users.sourceforge.net)
9 * 09-05-2001 CSH Created
34 Status
= HEAP_strdupAtoW (&str
, lpszClass
, NULL
);
35 if ( !NT_SUCCESS (Status
) )
37 SetLastError (RtlNtStatusToDosError(Status
));
40 retval
= (BOOL
)NtUserGetClassInfo(hinst
,str
,&w
,TRUE
,0);
45 RtlCopyMemory (&w
,lpwcx
,sizeof(WNDCLASSEXW
));
46 if (!IS_INTRESOURCE(w
.lpszMenuName
))
48 str
= (LPWSTR
)w
.lpszMenuName
;
49 str2
= (PUNICODE_STRING
)str
;
50 lpwcx
->lpszMenuName
= heap_string_poolA (str2
->Buffer
, str2
->Length
);
70 str
= HEAP_strdupW (lpszClass
, wcslen(lpszClass
) );
71 retval
= (BOOL
)NtUserGetClassInfo(hinst
,lpszClass
,&w
,FALSE
,0);
76 RtlCopyMemory (&w
,lpwcx
,sizeof(WNDCLASSEXW
));
77 if (!IS_INTRESOURCE(w
.lpszMenuName
) )
79 str
= (LPWSTR
)w
.lpszMenuName
;
80 str2
= (PUNICODE_STRING
)str
;
81 lpwcx
->lpszMenuName
= heap_string_poolW (str2
->Buffer
, str2
->Length
);
95 LPWNDCLASSA lpWndClass
)
99 retval
= GetClassInfoExA(hInstance
,lpClassName
,&w
);
100 RtlCopyMemory (lpWndClass
,&w
.style
,sizeof(WNDCLASSA
));
112 LPWNDCLASSW lpWndClass
)
116 retval
= GetClassInfoExW(hInstance
,lpClassName
,&w
);
117 RtlCopyMemory (lpWndClass
,&w
.style
,sizeof(WNDCLASSW
));
126 GetClassLongA ( HWND hWnd
, int nIndex
)
130 if ( nIndex
!= GCL_MENUNAME
)
132 return NtUserGetClassLong ( hWnd
, nIndex
, TRUE
);
135 str
= (PUNICODE_STRING
)NtUserGetClassLong ( hWnd
, nIndex
, TRUE
);
136 if ( IS_INTRESOURCE(str
) )
142 return (DWORD
)heap_string_poolA ( str
->Buffer
, str
->Length
);
150 GetClassLongW ( HWND hWnd
, int nIndex
)
154 if ( nIndex
!= GCL_MENUNAME
)
156 return NtUserGetClassLong ( hWnd
, nIndex
, FALSE
);
159 str
= (PUNICODE_STRING
)NtUserGetClassLong(hWnd
, nIndex
, TRUE
);
160 if ( IS_INTRESOURCE(str
) )
166 return (DWORD
)heap_string_poolW ( str
->Buffer
, str
->Length
);
184 ClassNameW
= HEAP_alloc ( (nMaxCount
+1)*sizeof(WCHAR
) );
186 result
= NtUserGetClassName ( hWnd
, ClassNameW
, nMaxCount
);
188 Status
= HEAP_strcpyWtoA ( lpClassName
, ClassNameW
, result
);
190 HEAP_free ( ClassNameW
);
192 if ( !NT_SUCCESS(Status
) )
212 ClassNameW
= HEAP_alloc ( (nMaxCount
+1) * sizeof(WCHAR
) );
214 result
= NtUserGetClassName ( hWnd
, ClassNameW
, nMaxCount
);
216 RtlCopyMemory ( lpClassName
, ClassNameW
, result
);
218 HEAP_free ( ClassNameW
);
233 * NOTE: Obsoleted in 32-bit windows
245 GetWindowLongA(HWND hWnd
, int nIndex
)
247 return NtUserGetWindowLong(hWnd
, nIndex
, TRUE
);
255 GetWindowLongW(HWND hWnd
, int nIndex
)
257 return NtUserGetWindowLong(hWnd
, nIndex
, FALSE
);
264 GetWindowWord(HWND hWnd
, int nIndex
)
266 return (WORD
)NtUserGetWindowLong(hWnd
, nIndex
, TRUE
);
279 /* FIXME: Implement correct functionality of RealGetWindowClass */
280 return GetClassNameW(hwnd
,pszType
,cchType
);
294 /* FIXME: Implement correct functionality of RealGetWindowClass */
295 return GetClassNameA(hwnd
,pszType
,cchType
);
302 RegisterClassA(CONST WNDCLASSA
*lpWndClass
)
309 RtlCopyMemory ( &Class
.style
, lpWndClass
, sizeof(WNDCLASSA
) );
311 Class
.cbSize
= sizeof(WNDCLASSEXA
);
312 Class
.hIconSm
= INVALID_HANDLE_VALUE
;
314 return RegisterClassExA ( &Class
);
321 RegisterClassExA(CONST WNDCLASSEXA
*lpwcx
)
324 WNDCLASSEXW wndclass
;
326 LPWSTR ClassName
= NULL
;
327 LPWSTR MenuName
= NULL
;
329 if ( !lpwcx
|| (lpwcx
->cbSize
!= sizeof(WNDCLASSEXA
)) )
332 if ( !lpwcx
->lpszClassName
)
335 RtlCopyMemory ( &wndclass
, lpwcx
, sizeof(WNDCLASSEXW
) );
337 if ( !IS_ATOM(lpwcx
->lpszClassName
) )
339 Status
= HEAP_strdupAtoW ( &ClassName
, (LPCSTR
)lpwcx
->lpszClassName
, NULL
);
340 if ( !NT_SUCCESS (Status
) )
342 SetLastError (RtlNtStatusToDosError(Status
));
345 wndclass
.lpszClassName
= ClassName
;
348 if ( !IS_INTRESOURCE(lpwcx
->lpszMenuName
) )
350 Status
= HEAP_strdupAtoW ( &MenuName
, (LPCSTR
)lpwcx
->lpszMenuName
, NULL
);
351 if ( !NT_SUCCESS (Status
) )
354 HEAP_free ( ClassName
);
355 SetLastError (RtlNtStatusToDosError(Status
));
358 wndclass
.lpszMenuName
= MenuName
;
361 Atom
= NtUserRegisterClassExWOW ( &wndclass
, FALSE
, 0, 0, 0 );
363 /* free strings if neccessary */
364 if ( MenuName
) HEAP_free ( MenuName
);
365 if ( ClassName
) HEAP_free ( ClassName
);
376 RegisterClassExW(CONST WNDCLASSEXW
*lpwcx
)
380 WNDCLASSEXW wndclass
;
381 LPWSTR ClassName
= NULL
;
382 LPWSTR MenuName
= NULL
;
384 if ( !lpwcx
|| (lpwcx
->cbSize
!= sizeof(WNDCLASSEXA
)) )
387 if ( !lpwcx
->lpszClassName
)
390 hHeap
= RtlGetProcessHeap();
391 RtlCopyMemory ( &wndclass
, lpwcx
, sizeof(WNDCLASSEXW
) );
393 /* copy strings if needed */
395 if ( !IS_ATOM(lpwcx
->lpszClassName
) )
397 ClassName
= HEAP_strdupW ( lpwcx
->lpszClassName
, lstrlenW(lpwcx
->lpszClassName
) );
400 SetLastError(RtlNtStatusToDosError(STATUS_NO_MEMORY
));
403 wndclass
.lpszClassName
= ClassName
;
406 if ( !IS_INTRESOURCE(lpwcx
->lpszMenuName
) )
408 MenuName
= HEAP_strdupW ( lpwcx
->lpszMenuName
, lstrlenW(lpwcx
->lpszMenuName
) );
412 HEAP_free ( MenuName
);
413 SetLastError(RtlNtStatusToDosError(STATUS_NO_MEMORY
));
416 wndclass
.lpszMenuName
= MenuName
;
419 Atom
= NtUserRegisterClassExWOW ( &wndclass
, TRUE
, 0, 0, 0 );
421 /* free strings if neccessary */
422 if ( MenuName
) HEAP_free ( MenuName
);
423 if ( ClassName
) HEAP_free ( ClassName
);
432 RegisterClassW(CONST WNDCLASSW
*lpWndClass
)
439 RtlCopyMemory ( &Class
.style
, lpWndClass
, sizeof(WNDCLASSW
) );
441 Class
.cbSize
= sizeof(WNDCLASSEXW
);
442 Class
.hIconSm
= INVALID_HANDLE_VALUE
;
444 return RegisterClassExW ( &Class
);
458 PUNICODE_STRING str2
;
460 if ( nIndex
!= GCL_MENUNAME
)
462 return NtUserSetClassLong ( hWnd
, nIndex
, dwNewLong
, TRUE
);
464 if ( IS_INTRESOURCE(dwNewLong
) )
466 str2
= (PUNICODE_STRING
)dwNewLong
;
470 RtlCreateUnicodeString ( str2
, (LPWSTR
)dwNewLong
);
473 str
= (PUNICODE_STRING
)NtUserSetClassLong(hWnd
, nIndex
, (DWORD
)str2
, TRUE
);
475 if ( !IS_INTRESOURCE(dwNewLong
) )
477 RtlFreeUnicodeString ( str2
);
479 if ( IS_INTRESOURCE(str
) )
485 return (DWORD
)heap_string_poolA ( str
->Buffer
, str
->Length
);
501 PUNICODE_STRING str2
;
503 if (nIndex
!= GCL_MENUNAME
)
505 return NtUserSetClassLong ( hWnd
, nIndex
, dwNewLong
, FALSE
);
507 if ( IS_INTRESOURCE(dwNewLong
) )
509 str2
= (PUNICODE_STRING
)dwNewLong
;
513 RtlCreateUnicodeStringFromAsciiz ( str2
,(LPSTR
)dwNewLong
);
516 str
= (PUNICODE_STRING
)NtUserSetClassLong(hWnd
, nIndex
, (DWORD
)str2
, TRUE
);
518 if ( !IS_INTRESOURCE(dwNewLong
) )
520 RtlFreeUnicodeString(str2
);
522 if ( IS_INTRESOURCE(str
) )
528 return (DWORD
)heap_string_poolW ( str
->Buffer
, str
->Length
);
543 * NOTE: Obsoleted in 32-bit windows
561 return NtUserSetWindowLong(hWnd
, nIndex
, dwNewLong
, TRUE
);
575 return NtUserSetWindowLong(hWnd
, nIndex
, dwNewLong
, FALSE
);