Huw Davies : riched20: Handle EM_REPLACESEL's unicode conversion in the host.

Alexandre Julliard julliard at winehq.org
Thu Mar 11 15:59:34 CST 2021


Module: wine
Branch: master
Commit: 45d21d00907b804cc6e02b28653d43ab03445a58
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=45d21d00907b804cc6e02b28653d43ab03445a58

Author: Huw Davies <huw at codeweavers.com>
Date:   Thu Mar 11 08:51:03 2021 +0000

riched20: Handle EM_REPLACESEL's unicode conversion in the host.

Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/riched20/editor.c  | 11 ++++-------
 dlls/riched20/txthost.c | 11 +++++++++++
 2 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c
index 3d17d2d974f..217394eaafb 100644
--- a/dlls/riched20/editor.c
+++ b/dlls/riched20/editor.c
@@ -3883,14 +3883,11 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
   }
   case EM_REPLACESEL:
   {
-    int len = 0;
-    LONG codepage = unicode ? CP_UNICODE : CP_ACP;
-    LPWSTR wszText = ME_ToUnicode(codepage, (void *)lParam, &len);
+    WCHAR *text = (WCHAR *)lParam;
+    int len = text ? lstrlenW( text ) : 0;
 
-    TRACE("EM_REPLACESEL - %s\n", debugstr_w(wszText));
-
-    ME_ReplaceSel(editor, !!wParam, wszText, len);
-    ME_EndToUnicode(codepage, wszText);
+    TRACE( "EM_REPLACESEL - %s\n", debugstr_w( text ) );
+    ME_ReplaceSel( editor, !!wParam, text, len );
     return len;
   }
   case EM_SCROLLCARET:
diff --git a/dlls/riched20/txthost.c b/dlls/riched20/txthost.c
index ac561ef4c83..064ce3fb827 100644
--- a/dlls/riched20/txthost.c
+++ b/dlls/riched20/txthost.c
@@ -849,6 +849,17 @@ static LRESULT RichEditWndProc_common( HWND hwnd, UINT msg, WPARAM wparam,
         EndPaint( editor->hWnd, &ps );
         return 0;
     }
+    case EM_REPLACESEL:
+    {
+        int len;
+        LONG codepage = unicode ? CP_UNICODE : CP_ACP;
+        WCHAR *text = ME_ToUnicode( codepage, (void *)lparam, &len );
+
+        hr = ITextServices_TxSendMessage( host->text_srv, msg, wparam, (LPARAM)text, &res );
+        ME_EndToUnicode( codepage, text );
+        res = len;
+        break;
+    }
     case EM_SETOPTIONS:
     {
         DWORD style;




More information about the wine-cvs mailing list