win32u: Move WM_GETTEXT implementation from user32.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
This commit is contained in:
Jacek Caban 2022-06-21 00:42:05 +02:00 committed by Alexandre Julliard
parent 9260d114b1
commit 4a53c479e8
2 changed files with 34 additions and 71 deletions

View file

@ -30,8 +30,6 @@
#include "win.h"
#include "user_private.h"
#include "controls.h"
#include "wine/server.h"
#include "wine/exception.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(win);
@ -73,28 +71,6 @@ HBRUSH DEFWND_ControlColor( HDC hDC, UINT ctlType )
}
static LPARAM DEFWND_GetTextA( WND *wndPtr, LPSTR dest, WPARAM wParam )
{
LPARAM result = 0;
__TRY
{
if (wndPtr->text)
{
if (!WideCharToMultiByte( CP_ACP, 0, wndPtr->text, -1,
dest, wParam, NULL, NULL )) dest[wParam-1] = 0;
result = strlen( dest );
}
else dest[0] = '\0';
}
__EXCEPT_PAGE_FAULT
{
return 0;
}
__ENDTRY
return result;
}
/***********************************************************************
* DefWindowProcA (USER32.@)
*
@ -145,19 +121,6 @@ LRESULT WINAPI DefWindowProcA( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam
result = NC_HandleSysCommand( hwnd, wParam, lParam );
break;
case WM_GETTEXT:
if (wParam)
{
LPSTR dest = (LPSTR)lParam;
WND *wndPtr = WIN_GetPtr( hwnd );
if (!wndPtr) break;
result = DEFWND_GetTextA( wndPtr, dest, wParam );
WIN_ReleasePtr( wndPtr );
}
break;
case WM_IME_CHAR:
if (HIBYTE(wParam)) PostMessageA( hwnd, WM_CHAR, HIBYTE(wParam), lParam );
PostMessageA( hwnd, WM_CHAR, LOBYTE(wParam), lParam );
@ -236,28 +199,6 @@ LRESULT WINAPI DefWindowProcA( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam
}
static LPARAM DEFWND_GetTextW( WND *wndPtr, LPWSTR dest, WPARAM wParam )
{
LPARAM result = 0;
__TRY
{
if (wndPtr->text)
{
lstrcpynW( dest, wndPtr->text, wParam );
result = lstrlenW( dest );
}
else dest[0] = '\0';
}
__EXCEPT_PAGE_FAULT
{
return 0;
}
__ENDTRY
return result;
}
/***********************************************************************
* DefWindowProcW (USER32.@) Calls default window message handler
*
@ -315,18 +256,6 @@ LRESULT WINAPI DefWindowProcW(
result = NC_HandleSysCommand( hwnd, wParam, lParam );
break;
case WM_GETTEXT:
if (wParam)
{
LPWSTR dest = (LPWSTR)lParam;
WND *wndPtr = WIN_GetPtr( hwnd );
if (!wndPtr) break;
result = DEFWND_GetTextW( wndPtr, dest, wParam );
WIN_ReleasePtr( wndPtr );
}
break;
case WM_IME_CHAR:
PostMessageW( hwnd, WM_CHAR, wParam, lParam );
break;

View file

@ -2519,6 +2519,40 @@ LRESULT default_window_proc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam,
}
break;
case WM_GETTEXT:
if (wparam)
{
WND *win;
if (!(win = get_win_ptr( hwnd ))) break;
__TRY
{
if (ansi)
{
char *dest = (char *)lparam;
if (win->text)
result = win32u_wctomb( &ansi_cp, dest, wparam - 1,
win->text, wcslen( win->text ));
dest[result] = 0;
}
else
{
WCHAR *dest = (WCHAR *)lparam;
if (win->text) result = min( wcslen( win->text ), wparam - 1 );
if (result) memcpy( dest, win->text, result * sizeof(WCHAR) );
dest[result] = 0;
}
}
__EXCEPT
{
}
__ENDTRY
release_win_ptr( win );
}
break;
case WM_SETICON:
result = (LRESULT)set_window_icon( hwnd, wparam, (HICON)lparam );
if ((get_window_long( hwnd, GWL_STYLE ) & WS_CAPTION) == WS_CAPTION)