[PATCH 4/5] riched20: Handle WM_CHAR's unicode conversion in the host.

Huw Davies huw at codeweavers.com
Wed Mar 10 03:31:19 CST 2021


Signed-off-by: Huw Davies <huw at codeweavers.com>
---
 dlls/riched20/editor.c  | 23 ++++++-----------------
 dlls/riched20/txthost.c |  8 ++++++++
 2 files changed, 14 insertions(+), 17 deletions(-)

diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c
index cacad463963..3d17d2d974f 100644
--- a/dlls/riched20/editor.c
+++ b/dlls/riched20/editor.c
@@ -2744,11 +2744,8 @@ ME_KeyDown(ME_TextEditor *editor, WORD nKey)
   return FALSE;
 }
 
-static LRESULT ME_Char(ME_TextEditor *editor, WPARAM charCode,
-                       LPARAM flags, BOOL unicode)
+static LRESULT handle_wm_char( ME_TextEditor *editor, WCHAR wstr, LPARAM flags )
 {
-  WCHAR wstr;
-
   if (editor->bMouseCaptured)
     return 0;
 
@@ -2758,14 +2755,6 @@ static LRESULT ME_Char(ME_TextEditor *editor, WPARAM charCode,
     return 0; /* FIXME really 0 ? */
   }
 
-  if (unicode)
-      wstr = (WCHAR)charCode;
-  else
-  {
-      CHAR charA = charCode;
-      MultiByteToWideChar(CP_ACP, 0, &charA, 1, &wstr, 1);
-  }
-
   if (editor->bEmulateVersion10 && wstr == '\r')
       handle_enter(editor);
 
@@ -4379,7 +4368,7 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
     if ((editor->nEventMask & ENM_KEYEVENTS) &&
         !ME_FilterEvent(editor, msg, &wParam, &lParam))
       return 0;
-    return ME_Char(editor, wParam, lParam, unicode);
+    return handle_wm_char( editor, wParam, lParam );
   case WM_UNICHAR:
     if (unicode)
     {
@@ -4389,11 +4378,11 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
             if(wParam > 0xffff) /* convert to surrogates */
             {
                 wParam -= 0x10000;
-                ME_Char(editor, (wParam >> 10) + 0xd800, 0, TRUE);
-                ME_Char(editor, (wParam & 0x03ff) + 0xdc00, 0, TRUE);
-            } else {
-              ME_Char(editor, wParam, 0, TRUE);
+                handle_wm_char( editor, (wParam >> 10) + 0xd800, 0 );
+                handle_wm_char( editor, (wParam & 0x03ff) + 0xdc00, 0 );
             }
+            else
+                handle_wm_char( editor, wParam, 0 );
         }
         return 0;
     }
diff --git a/dlls/riched20/txthost.c b/dlls/riched20/txthost.c
index 23c9962bb3a..3cfb6b65ca7 100644
--- a/dlls/riched20/txthost.c
+++ b/dlls/riched20/txthost.c
@@ -778,6 +778,14 @@ static LRESULT RichEditWndProc_common( HWND hwnd, UINT msg, WPARAM wparam,
     editor = host->editor;
     switch (msg)
     {
+    case WM_CHAR:
+    {
+        WCHAR wc = wparam;
+
+        if (!unicode) MultiByteToWideChar( CP_ACP, 0, (char *)&wparam, 1, &wc, 1 );
+        hr = ITextServices_TxSendMessage( host->text_srv, msg, wc, lparam, &res );
+        break;
+    }
     case WM_DESTROY:
         ITextHost_Release( &host->ITextHost_iface );
         return 0;
-- 
2.23.0




More information about the wine-devel mailing list