Author: jimtabor
Date: Tue Mar 29 05:53:34 2011
New Revision: 51187
URL:
http://svn.reactos.org/svn/reactos?rev=51187&view=rev
Log:
[User32|Win32k]
- Properly implement RealGetWindowClass, fixes the ApiTest. Keeping the Ansi support for
now, will use it as a reference.
Modified:
trunk/reactos/dll/win32/user32/windows/class.c
trunk/reactos/include/reactos/win32k/ntuser.h
trunk/reactos/subsystems/win32/win32k/ntuser/class.c
Modified: trunk/reactos/dll/win32/user32/windows/class.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/windows/c…
==============================================================================
--- trunk/reactos/dll/win32/user32/windows/class.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/user32/windows/class.c [iso-8859-1] Tue Mar 29 05:53:34 2011
@@ -696,22 +696,20 @@
LPSTR lpClassName,
int nMaxCount)
{
- ANSI_STRING ClassName;
- int Result;
-
- ClassName.MaximumLength = nMaxCount;
- ClassName.Buffer = lpClassName;
-
- Result = NtUserGetClassName(hWnd,
- (PUNICODE_STRING)&ClassName,
- TRUE);
+ WCHAR tmpbuf[MAX_ATOM_LEN + 1];
+ int len;
+
+ if (nMaxCount <= 0) return 0;
+ if (!GetClassNameW( hWnd, tmpbuf, sizeof(tmpbuf)/sizeof(WCHAR) )) return 0;
+ RtlUnicodeToMultiByteN( lpClassName, nMaxCount - 1, (PULONG)&len, tmpbuf,
strlenW(tmpbuf) * sizeof(WCHAR) );
+ lpClassName[len] = 0;
TRACE("%p class/atom: %s/%04x %x\n", hWnd,
IS_ATOM(lpClassName) ? NULL : lpClassName,
IS_ATOM(lpClassName) ? lpClassName : 0,
nMaxCount);
- return Result;
+ return len;
}
@@ -732,8 +730,8 @@
ClassName.Buffer = lpClassName;
Result = NtUserGetClassName(hWnd,
- &ClassName,
- FALSE);
+ FALSE,
+ &ClassName);
TRACE("%p class/atom: %S/%04x %x\n", hWnd,
IS_ATOM(lpClassName) ? NULL : lpClassName,
@@ -914,8 +912,11 @@
LPWSTR pszType,
UINT cchType)
{
- /* FIXME: Implement correct functionality of RealGetWindowClass */
- return GetClassNameW(hwnd,pszType,cchType);
+ UNICODE_STRING ClassName;
+ ClassName.MaximumLength = cchType * sizeof(WCHAR);
+ ClassName.Buffer = (PWSTR)pszType;
+
+ return NtUserGetClassName(hwnd,TRUE,&ClassName);
}
@@ -929,8 +930,14 @@
LPSTR pszType,
UINT cchType)
{
- /* FIXME: Implement correct functionality of RealGetWindowClass */
- return GetClassNameA(hwnd,pszType,cchType);
+ WCHAR tmpbuf[MAX_ATOM_LEN + 1];
+ UINT len;
+
+ if (cchType <= 0) return 0;
+ if (!RealGetWindowClassW( hwnd, tmpbuf, sizeof(tmpbuf)/sizeof(WCHAR) )) return 0;
+ RtlUnicodeToMultiByteN( pszType, cchType - 1, (PULONG)&len, tmpbuf,
strlenW(tmpbuf) * sizeof(WCHAR) );
+ pszType[len] = 0;
+ return len;
}
/*
Modified: trunk/reactos/include/reactos/win32k/ntuser.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/win32k/ntu…
==============================================================================
--- trunk/reactos/include/reactos/win32k/ntuser.h [iso-8859-1] (original)
+++ trunk/reactos/include/reactos/win32k/ntuser.h [iso-8859-1] Tue Mar 29 05:53:34 2011
@@ -1764,15 +1764,8 @@
INT
NTAPI
NtUserGetClassName(HWND hWnd,
- PUNICODE_STRING ClassName,
- BOOL Ansi);
-#if 0 // Real NtUserGetClassName
-INT
-NTAPI
-NtUserGetClassName(HWND hWnd,
BOOL Real, // 0 GetClassNameW, 1 RealGetWindowClassA/W
PUNICODE_STRING ClassName);
-#endif
HANDLE
NTAPI
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/class.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/class.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/class.c [iso-8859-1] Tue Mar 29 05:53:34
2011
@@ -1398,6 +1398,7 @@
INT
UserGetClassName(IN PCLS Class,
IN OUT PUNICODE_STRING ClassName,
+ IN RTL_ATOM Atom,
IN BOOL Ansi)
{
NTSTATUS Status = STATUS_SUCCESS;
@@ -1451,7 +1452,7 @@
/* query the class name */
Status = RtlQueryAtomInAtomTable(gAtomTable,
- Class->atomClassName,
+ Atom ? Atom : Class->atomClassName,
NULL,
NULL,
szTemp,
@@ -1485,7 +1486,7 @@
/* query the atom name */
Status = RtlQueryAtomInAtomTable(gAtomTable,
- Class->atomClassName,
+ Atom ? Atom : Class->atomClassName,
NULL,
NULL,
ClassName->Buffer,
@@ -2376,18 +2377,27 @@
INT APIENTRY
NtUserGetClassName (IN HWND hWnd,
- OUT PUNICODE_STRING ClassName,
- IN BOOL Ansi)
+ IN BOOL Real,
+ OUT PUNICODE_STRING ClassName)
{
PWND Window;
UNICODE_STRING CapturedClassName;
- INT Ret = 0;
+ INT iCls, Ret = 0;
+ RTL_ATOM Atom = 0;
UserEnterShared();
Window = UserGetWindowObject(hWnd);
if (Window != NULL)
{
+ if (Real && Window->fnid && !(Window->fnid &
FNID_DESTROY))
+ {
+ if (LookupFnIdToiCls(Window->fnid, &iCls))
+ {
+ Atom = gpsi->atomSysClass[iCls];
+ }
+ }
+
_SEH2_TRY
{
ProbeForWriteUnicodeString(ClassName);
@@ -2396,7 +2406,8 @@
/* get the class name */
Ret = UserGetClassName(Window->pcls,
&CapturedClassName,
- Ansi);
+ Atom,
+ FALSE);
if (Ret != 0)
{