Author: jimtabor
Date: Thu Dec 19 03:35:27 2013
New Revision: 61292
URL:
http://svn.reactos.org/svn/reactos?rev=61292&view=rev
Log:
[User32]
- Fixes TC 8 and GetWindowText issues. See CORE-7447 and CORE-7695.
Modified:
trunk/reactos/win32ss/user/user32/windows/message.c
trunk/reactos/win32ss/user/user32/windows/window.c
Modified: trunk/reactos/win32ss/user/user32/windows/message.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/user32/window…
==============================================================================
--- trunk/reactos/win32ss/user/user32/windows/message.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/user32/windows/message.c [iso-8859-1] Thu Dec 19 03:35:27
2013
@@ -565,6 +565,9 @@
return TRUE;
}
+//
+// Ansi to Unicode -> callout
+//
static BOOL FASTCALL
MsgiAnsiToUnicodeMessage(HWND hwnd, LPMSG UnicodeMsg, LPMSG AnsiMsg)
{
@@ -579,7 +582,8 @@
{
LPWSTR Buffer;
if (!AnsiMsg->lParam) break;
- Buffer = RtlAllocateHeap(GetProcessHeap(), 0, AnsiMsg->wParam *
sizeof(WCHAR));
+ Buffer = RtlAllocateHeap(GetProcessHeap(), HEAP_ZERO_MEMORY, AnsiMsg->wParam *
sizeof(WCHAR));
+ //ERR("WM_GETTEXT A2U Size %d\n",AnsiMsg->wParam);
if (!Buffer) return FALSE;
UnicodeMsg->lParam = (LPARAM)Buffer;
break;
@@ -587,32 +591,32 @@
case LB_GETTEXT:
{
- DWORD Size;
+ DWORD Size = 1024 * sizeof(WCHAR);
if (!AnsiMsg->lParam || !listbox_has_strings( AnsiMsg->hwnd )) break;
- Size = SendMessageW( AnsiMsg->hwnd, LB_GETTEXTLEN, AnsiMsg->wParam, 0 );
+ /*Size = SendMessageW( AnsiMsg->hwnd, LB_GETTEXTLEN, AnsiMsg->wParam, 0 );
if (Size == LB_ERR)
{
ERR("LB_GETTEXT LB_ERR\n");
Size = sizeof(ULONG_PTR);
}
- Size = (Size + 1) * sizeof(WCHAR);
- UnicodeMsg->lParam = (LPARAM) RtlAllocateHeap(GetProcessHeap(), 0, Size);
+ Size = (Size + 1) * sizeof(WCHAR);*/
+ UnicodeMsg->lParam = (LPARAM) RtlAllocateHeap(GetProcessHeap(),
HEAP_ZERO_MEMORY, Size);
if (!UnicodeMsg->lParam) return FALSE;
break;
}
case CB_GETLBTEXT:
{
- DWORD Size;
+ DWORD Size = 1024 * sizeof(WCHAR);
if (!AnsiMsg->lParam || !combobox_has_strings( AnsiMsg->hwnd )) break;
- Size = SendMessageW( AnsiMsg->hwnd, CB_GETLBTEXTLEN, AnsiMsg->wParam, 0 );
+ /*Size = SendMessageW( AnsiMsg->hwnd, CB_GETLBTEXTLEN, AnsiMsg->wParam, 0
);
if (Size == LB_ERR)
{
ERR("CB_GETTEXT LB_ERR\n");
Size = sizeof(ULONG_PTR);
}
- Size = (Size + 1) * sizeof(WCHAR);
- UnicodeMsg->lParam = (LPARAM) RtlAllocateHeap(GetProcessHeap(), 0, Size);
+ Size = (Size + 1) * sizeof(WCHAR);*/
+ UnicodeMsg->lParam = (LPARAM) RtlAllocateHeap(GetProcessHeap(),
HEAP_ZERO_MEMORY, Size);
if (!UnicodeMsg->lParam) return FALSE;
break;
}
@@ -747,6 +751,10 @@
case WM_IME_CHAR:
UnicodeMsg->wParam = map_wparam_AtoW( AnsiMsg->message, AnsiMsg->wParam
);
break;
+ case EM_GETLINE:
+ ERR("FIXME EM_GETLINE A2U\n");
+ break;
+
}
return TRUE;
@@ -861,7 +869,7 @@
}
/*
- * Unicode Result to Ansi Result
+ * callout return -> Unicode Result to Ansi Result
*/
static BOOL FASTCALL
MsgiAnsiToUnicodeReply(LPMSG UnicodeMsg, LPMSG AnsiMsg, LRESULT *Result)
@@ -877,9 +885,10 @@
if (UnicodeMsg->wParam)
{
DWORD len = 0;
- if (*Result) RtlUnicodeToMultiByteN( AnsiBuffer, UnicodeMsg->wParam - 1,
&len, Buffer, strlenW(Buffer) * sizeof(WCHAR) );
+ if (*Result) RtlUnicodeToMultiByteN( AnsiBuffer, UnicodeMsg->wParam - 1,
&len, Buffer, strlenW(Buffer) * sizeof(WCHAR));
AnsiBuffer[len] = 0;
*Result = len;
+ //ERR("WM_GETTEXT U2A Result %d Size
%d\n",*Result,AnsiMsg->wParam);
}
break;
}
@@ -912,6 +921,9 @@
return TRUE;
}
+//
+// Unicode to Ansi callout ->
+//
static BOOL FASTCALL
MsgiUnicodeToAnsiMessage(HWND hwnd, LPMSG AnsiMsg, LPMSG UnicodeMsg)
{
@@ -979,40 +991,40 @@
{
if (!UnicodeMsg->lParam) break;
/* Ansi string might contain MBCS chars so we need 2 * the number of chars */
- AnsiMsg->wParam = UnicodeMsg->wParam * 2;
- AnsiMsg->lParam = (LPARAM) RtlAllocateHeap(GetProcessHeap(), 0,
AnsiMsg->wParam);
+ AnsiMsg->lParam = (LPARAM) RtlAllocateHeap(GetProcessHeap(),
HEAP_ZERO_MEMORY, UnicodeMsg->wParam * 2);
+ //ERR("WM_GETTEXT U2A Size %d\n",AnsiMsg->wParam);
if (!AnsiMsg->lParam) return FALSE;
break;
}
case LB_GETTEXT:
{
- DWORD Size;
+ DWORD Size = 1024;
if (!UnicodeMsg->lParam || !listbox_has_strings( UnicodeMsg->hwnd ))
break;
- Size = SendMessageA( UnicodeMsg->hwnd, LB_GETTEXTLEN, UnicodeMsg->wParam, 0
);
+ /*Size = SendMessageA( UnicodeMsg->hwnd, LB_GETTEXTLEN, UnicodeMsg->wParam,
0 );
if (Size == LB_ERR)
{
ERR("LB_GETTEXT LB_ERR\n");
Size = sizeof(ULONG_PTR);
}
- Size = (Size + 1) * sizeof(WCHAR);
- AnsiMsg->lParam = (LPARAM) RtlAllocateHeap(GetProcessHeap(), 0, Size);
+ Size = (Size + 1) * sizeof(WCHAR);*/
+ AnsiMsg->lParam = (LPARAM) RtlAllocateHeap(GetProcessHeap(), HEAP_ZERO_MEMORY,
Size);
if (!AnsiMsg->lParam) return FALSE;
break;
}
case CB_GETLBTEXT:
{
- DWORD Size;
+ DWORD Size = 1024;
if (!UnicodeMsg->lParam || !combobox_has_strings( UnicodeMsg->hwnd ))
break;
- Size = SendMessageA( UnicodeMsg->hwnd, CB_GETLBTEXTLEN, UnicodeMsg->wParam,
0 );
+ /*Size = SendMessageA( UnicodeMsg->hwnd, CB_GETLBTEXTLEN,
UnicodeMsg->wParam, 0 );
if (Size == LB_ERR)
{
ERR("CB_GETTEXT LB_ERR\n");
Size = sizeof(ULONG_PTR);
}
- Size = (Size + 1) * sizeof(WCHAR);
- AnsiMsg->lParam = (LPARAM) RtlAllocateHeap(GetProcessHeap(), 0, Size);
+ Size = (Size + 1) * sizeof(WCHAR);*/
+ AnsiMsg->lParam = (LPARAM) RtlAllocateHeap(GetProcessHeap(), HEAP_ZERO_MEMORY,
Size);
if (!AnsiMsg->lParam) return FALSE;
break;
}
@@ -1168,6 +1180,9 @@
case WM_IME_CHAR:
AnsiMsg->wParam = map_wparam_char_WtoA(UnicodeMsg->wParam,2);
break;
+ case EM_GETLINE:
+ ERR("FIXME EM_GETLINE U2A\n");
+ break;
}
return TRUE;
}
@@ -1273,7 +1288,7 @@
}
/*
- * Ansi Result to Unicode Result
+ * callout return -> Ansi Result to Unicode Result
*/
static BOOL FASTCALL
MsgiUnicodeToAnsiReply(LPMSG AnsiMsg, LPMSG UnicodeMsg, LRESULT *Result)
@@ -1286,13 +1301,14 @@
case WM_GETTEXT:
case WM_ASKCBFORMATNAME:
{
- DWORD len = AnsiMsg->wParam * 2;
+ DWORD len = AnsiMsg->wParam;// * 2;
if (len)
{
if (*Result)
{
RtlMultiByteToUnicodeN( UBuffer, AnsiMsg->wParam*sizeof(WCHAR),
&len, Buffer, strlen(Buffer)+1 );
*Result = len/sizeof(WCHAR) - 1; /* do not count terminating null */
+ //ERR("WM_GETTEXT U2A Result %d Size
%d\n",*Result,AnsiMsg->wParam);
}
UBuffer[*Result] = 0;
}
@@ -2377,7 +2393,8 @@
if ( Window != NULL &&
Window->head.pti == ti &&
- !IsThreadHooked(GetWin32ClientInfo()) && // This is why HOOKs are bad!
They slow the system down!
+ !ISITHOOKED(WH_CALLWNDPROC) &&
+ !ISITHOOKED(WH_CALLWNDPROCRET) &&
!(Window->state & WNDS_SERVERSIDEWINDOWPROC) )
{
/* NOTE: We can directly send messages to the window procedure
@@ -2440,7 +2457,8 @@
if ( Window != NULL &&
Window->head.pti == ti &&
- !IsThreadHooked(GetWin32ClientInfo()) && // This is why HOOKs are bad!
They slow the system down!
+ !ISITHOOKED(WH_CALLWNDPROC) &&
+ !ISITHOOKED(WH_CALLWNDPROCRET) &&
!(Window->state & WNDS_SERVERSIDEWINDOWPROC) )
{
/* NOTE: We can directly send messages to the window procedure
Modified: trunk/reactos/win32ss/user/user32/windows/window.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/user32/window…
==============================================================================
--- trunk/reactos/win32ss/user/user32/windows/window.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/user32/windows/window.c [iso-8859-1] Thu Dec 19 03:35:27
2013
@@ -1171,7 +1171,7 @@
pwi->cxWindowBorders = Size.cx;
pwi->cyWindowBorders = Size.cy;
pwi->dwWindowStatus = 0;
- if (pWnd->state & WNDS_ACTIVEFRAME)
+ if (pWnd->state & WNDS_ACTIVEFRAME || (GetActiveWindow() == hWnd))
pwi->dwWindowStatus = WS_ACTIVECAPTION;
pwi->atomWindowType = (pCls ? pCls->atomClassName : 0 );
@@ -1237,7 +1237,6 @@
return GetModuleFileNameW( Wnd->hModule, lpszFileName, cchFileNameMax );
}
-
/*
* @implemented
*/
@@ -1264,7 +1263,6 @@
return TRUE;
}
-
/*
* @implemented
*/
@@ -1272,68 +1270,34 @@
GetWindowTextA(HWND hWnd, LPSTR lpString, int nMaxCount)
{
PWND Wnd;
- PCWSTR Buffer;
INT Length = 0;
- if (lpString == NULL)
+ if (lpString == NULL || nMaxCount == 0)
return 0;
Wnd = ValidateHwnd(hWnd);
if (!Wnd)
return 0;
- _SEH2_TRY
- {
- if (!TestWindowProcess( Wnd))
- {
- if (nMaxCount > 0)
- {
- /* do not send WM_GETTEXT messages to other processes */
- Length = Wnd->strName.Length / sizeof(WCHAR);
- if (Length != 0)
- {
- Buffer = DesktopPtrToUser(Wnd->strName.Buffer);
- if (Buffer != NULL)
- {
- if (!WideCharToMultiByte(CP_ACP,
- 0,
- Buffer,
- Length + 1,
- lpString,
- nMaxCount,
- NULL,
- NULL))
- {
- lpString[nMaxCount - 1] = '\0';
- }
- }
- else
- {
- Length = 0;
- lpString[0] = '\0';
- }
- }
- else
- lpString[0] = '\0';
- }
-
- Wnd = NULL; /* Don't send a message */
- }
- }
- _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
- {
- lpString[0] = '\0';
- Length = 0;
- Wnd = NULL; /* Don't send a message */
- }
- _SEH2_END;
-
- if (Wnd != NULL)
- Length = SendMessageA(hWnd, WM_GETTEXT, nMaxCount, (LPARAM)lpString);
-
+ lpString[0] = '\0';
+
+ if (!TestWindowProcess( Wnd))
+ {
+ _SEH2_TRY
+ {
+ Length = DefWindowProcA(hWnd, WM_GETTEXT, nMaxCount, (LPARAM)lpString);
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ Length = 0;
+ }
+ _SEH2_END;
+ }
+ else
+ Length = SendMessageA(hWnd, WM_GETTEXT, nMaxCount, (LPARAM)lpString);
+ //ERR("GWTA Len %d : %s\n",Length,lpString);
return Length;
}
-
/*
* @implemented
@@ -1344,7 +1308,6 @@
return(SendMessageA(hWnd, WM_GETTEXTLENGTH, 0, 0));
}
-
/*
* @implemented
*/
@@ -1354,7 +1317,6 @@
return(SendMessageW(hWnd, WM_GETTEXTLENGTH, 0, 0));
}
-
/*
* @implemented
*/
@@ -1362,57 +1324,32 @@
GetWindowTextW(HWND hWnd, LPWSTR lpString, int nMaxCount)
{
PWND Wnd;
- PCWSTR Buffer;
INT Length = 0;
- if (lpString == NULL)
+ if (lpString == NULL || nMaxCount == 0)
return 0;
Wnd = ValidateHwnd(hWnd);
if (!Wnd)
return 0;
- _SEH2_TRY
- {
- if (!TestWindowProcess( Wnd))
- {
- if (nMaxCount > 0)
- {
- /* do not send WM_GETTEXT messages to other processes */
- Length = Wnd->strName.Length / sizeof(WCHAR);
- if (Length != 0)
- {
- Buffer = DesktopPtrToUser(Wnd->strName.Buffer);
- if (Buffer != NULL)
- {
- RtlCopyMemory(lpString,
- Buffer,
- (Length + 1) * sizeof(WCHAR));
- }
- else
- {
- Length = 0;
- lpString[0] = '\0';
- }
- }
- else
- lpString[0] = '\0';
- }
-
- Wnd = NULL; /* Don't send a message */
- }
- }
- _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
- {
- lpString[0] = '\0';
- Length = 0;
- Wnd = NULL; /* Don't send a message */
- }
- _SEH2_END;
-
- if (Wnd != NULL)
- Length = SendMessageW(hWnd, WM_GETTEXT, nMaxCount, (LPARAM)lpString);
-
+ lpString[0] = L'\0';
+
+ if (!TestWindowProcess( Wnd))
+ {
+ _SEH2_TRY
+ {
+ Length = DefWindowProcW(hWnd, WM_GETTEXT, nMaxCount, (LPARAM)lpString);
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ Length = 0;
+ }
+ _SEH2_END;
+ }
+ else
+ Length = SendMessageW(hWnd, WM_GETTEXT, nMaxCount, (LPARAM)lpString);
+ //ERR("GWTW Len %d : %S\n",Length,lpString);
return Length;
}