From ecd7b2f8f34377f8557bbcb4a9f53ba73d3c5211 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9=20van=20Geldorp?= Date: Mon, 19 May 2003 20:11:17 +0000 Subject: [PATCH] Handle SetWindowText() across Unicode/Ansi conversions svn path=/trunk/; revision=4730 --- reactos/lib/user32/windows/defwnd.c | 16 ++++++++-- reactos/lib/user32/windows/message.c | 45 ++++++++++++++++++++++++++-- reactos/lib/user32/windows/window.c | 10 +++---- 3 files changed, 61 insertions(+), 10 deletions(-) diff --git a/reactos/lib/user32/windows/defwnd.c b/reactos/lib/user32/windows/defwnd.c index 145f53d4542..589cb93353c 100644 --- a/reactos/lib/user32/windows/defwnd.c +++ b/reactos/lib/user32/windows/defwnd.c @@ -1,4 +1,4 @@ -/* $Id: defwnd.c,v 1.45 2003/05/19 18:36:43 gvg Exp $ +/* $Id: defwnd.c,v 1.46 2003/05/19 20:11:17 gvg Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS user32.dll @@ -1477,6 +1477,12 @@ DefWindowProcA(HWND hWnd, strlen((PSTR)lParam) * sizeof(CHAR)); strcpy(WindowText, (PSTR)lParam); SetPropA(hWnd, WindowTextAtom, WindowText); + if (0 != (GetWindowLongW(hWnd, GWL_STYLE) & WS_CAPTION)) + { + DefWndPaintNC(hWnd, (HRGN) 1); + } + Result = (LPARAM) TRUE; + break; } case WM_NCDESTROY: @@ -1579,9 +1585,13 @@ DefWindowProcW(HWND hWnd, wcslen((PWSTR)lParam) * sizeof(WCHAR)); wcscpy(WindowText, (PWSTR)lParam); SetPropW(hWnd, WindowTextAtom, WindowText); + if (0 != (GetWindowLongW(hWnd, GWL_STYLE) & WS_CAPTION)) + { + DefWndPaintNC(hWnd, (HRGN) 1); + } + Result = (LPARAM) TRUE; + break; } - //FIXME: return correct code - return TRUE; case WM_NCDESTROY: { diff --git a/reactos/lib/user32/windows/message.c b/reactos/lib/user32/windows/message.c index 736cf7cd8aa..9b9b5c50551 100644 --- a/reactos/lib/user32/windows/message.c +++ b/reactos/lib/user32/windows/message.c @@ -1,4 +1,4 @@ -/* $Id: message.c,v 1.14 2003/05/12 19:30:00 jfilby Exp $ +/* $Id: message.c,v 1.15 2003/05/19 20:11:17 gvg Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS user32.dll @@ -93,6 +93,13 @@ User32FreeAsciiConvertedMessage(UINT Msg, WPARAM wParam, LPARAM lParam) RtlFreeHeap(RtlGetProcessHeap(), 0, TempString); break; } + case WM_SETTEXT: + { + ANSI_STRING AnsiString; + RtlInitAnsiString(&AnsiString, (PSTR) lParam); + RtlFreeAnsiString(&AnsiString); + break; + } case WM_NCCREATE: { CREATESTRUCTA* Cs; @@ -133,6 +140,19 @@ User32ConvertToAsciiMessage(UINT* Msg, WPARAM* wParam, LPARAM* lParam) (*lParam) = (LPARAM)CsA; break; } + case WM_SETTEXT: + { + ANSI_STRING AnsiString; + UNICODE_STRING UnicodeString; + RtlInitUnicodeString(&UnicodeString, (PWSTR) *lParam); + if (NT_SUCCESS(RtlUnicodeStringToAnsiString(&AnsiString, + &UnicodeString, + TRUE))) + { + *lParam = (LPARAM) AnsiString.Buffer; + } + break; + } } return; } @@ -203,8 +223,22 @@ MsgiAnsiToUnicodeMessage(LPMSG UnicodeMsg, LPMSG AnsiMsg) UnicodeMsg->wParam = UnicodeMsg->wParam / 2; break; } + case WM_SETTEXT: + { + ANSI_STRING AnsiString; + UNICODE_STRING UnicodeString; + RtlInitAnsiString(&AnsiString, (PSTR) AnsiMsg->lParam); + if (! NT_SUCCESS(RtlAnsiStringToUnicodeString(&UnicodeString, + &AnsiString, + TRUE))) + { + return FALSE; + } + UnicodeMsg->lParam = (LPARAM) UnicodeString.Buffer; + break; + } } - return(TRUE); + return TRUE; } BOOL @@ -230,6 +264,13 @@ MsgiAnsiToUnicodeReply(LPMSG UnicodeMsg, LPMSG AnsiMsg, LRESULT Result) RtlFreeHeap(RtlGetProcessHeap(), 0, TempString); break; } + case WM_SETTEXT: + { + UNICODE_STRING UnicodeString; + RtlInitUnicodeString(&UnicodeString, (PCWSTR) UnicodeMsg->lParam); + RtlFreeUnicodeString(&UnicodeString); + break; + } } return(TRUE); } diff --git a/reactos/lib/user32/windows/window.c b/reactos/lib/user32/windows/window.c index 97d403883a2..2c1dd328545 100644 --- a/reactos/lib/user32/windows/window.c +++ b/reactos/lib/user32/windows/window.c @@ -1,4 +1,4 @@ -/* $Id: window.c,v 1.32 2003/05/18 07:51:41 gvg Exp $ +/* $Id: window.c,v 1.33 2003/05/19 20:11:17 gvg Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS user32.dll @@ -897,7 +897,9 @@ IsWindow(HWND hWnd) WINBOOL STDCALL IsWindowUnicode(HWND hWnd) { +#ifdef TODO UNIMPLEMENTED; +#endif return FALSE; } @@ -1021,16 +1023,14 @@ WINBOOL STDCALL SetWindowTextA(HWND hWnd, LPCSTR lpString) { - UNIMPLEMENTED; - return FALSE; + return SendMessageA(hWnd, WM_SETTEXT, 0, (LPARAM)lpString); } WINBOOL STDCALL SetWindowTextW(HWND hWnd, LPCWSTR lpString) { - UNIMPLEMENTED; - return FALSE; + return SendMessageW(hWnd, WM_SETTEXT, 0, (LPARAM)lpString); } WINBOOL STDCALL