Alex Villacís Lasso : riched20: Minimal fix for WM_SETTEXT without ES_MULTILINE style.

Alexandre Julliard julliard at winehq.org
Fri Sep 28 06:45:56 CDT 2007


Module: wine
Branch: master
Commit: 63b12f8602f722e425b41f75d9ad3f55656539fc
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=63b12f8602f722e425b41f75d9ad3f55656539fc

Author: Alex Villacís Lasso <a_villacis at palosanto.com>
Date:   Thu Sep 27 18:17:48 2007 -0500

riched20: Minimal fix for WM_SETTEXT without ES_MULTILINE style.

---

 dlls/riched20/editor.c       |   12 +++++++++++-
 dlls/riched20/tests/editor.c |   15 +++++++++++----
 2 files changed, 22 insertions(+), 5 deletions(-)

diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c
index fcfe03a..81fe9b2 100644
--- a/dlls/riched20/editor.c
+++ b/dlls/riched20/editor.c
@@ -1908,8 +1908,18 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam,
         TRACE("WM_SETTEXT - %s\n", debugstr_w(wszText)); /* debugstr_w() */
         if (lstrlenW(wszText) > 0)
         {
+          int len = -1;
+
           /* uses default style! */
-          ME_InsertTextFromCursor(editor, 0, wszText, -1, editor->pBuffer->pDefaultStyle);
+          if (!(GetWindowLongW(hWnd, GWL_STYLE) & ES_MULTILINE))
+          {
+            WCHAR * p;
+
+            p = wszText;
+            while (*p != '\0' && *p != '\r' && *p != '\n') p++;
+            len = p - wszText;
+          }
+          ME_InsertTextFromCursor(editor, 0, wszText, len, editor->pBuffer->pDefaultStyle);
         }
         ME_EndToUnicode(unicode, wszText);
       }
diff --git a/dlls/riched20/tests/editor.c b/dlls/riched20/tests/editor.c
index de36d6e..5375d30 100644
--- a/dlls/riched20/tests/editor.c
+++ b/dlls/riched20/tests/editor.c
@@ -2064,6 +2064,9 @@ static void test_EM_GETTEXTLENGTHEX(void)
     HWND hwnd;
     GETTEXTLENGTHEX gtl;
     int ret;
+    const char * test_string = "a\nb\n\n\r\n";
+    const char * test_string_after = "a";
+    char buffer[64] = {0};
 
     /* single line */
     hwnd = CreateWindowExA(0, "RichEdit20W", NULL, WS_POPUP,
@@ -2080,17 +2083,21 @@ static void test_EM_GETTEXTLENGTHEX(void)
     ret = SendMessageA(hwnd, EM_GETTEXTLENGTHEX, (WPARAM)&gtl, 0);
     ok(ret == 0, "ret %d\n",ret);
 
-    SendMessage(hwnd, WM_SETTEXT, 0, (LPARAM) "a\nb\n\n\r\n");
+    SendMessage(hwnd, WM_SETTEXT, 0, (LPARAM) test_string);
 
     gtl.flags = GTL_NUMCHARS | GTL_PRECISE | GTL_USECRLF;
     gtl.codepage = CP_ACP;
     ret = SendMessageA(hwnd, EM_GETTEXTLENGTHEX, (WPARAM)&gtl, 0);
-    todo_wine ok(ret == 1, "ret %d\n",ret);
+    ok(ret == 1, "ret %d\n",ret);
 
     gtl.flags = GTL_NUMCHARS | GTL_PRECISE;
     gtl.codepage = CP_ACP;
     ret = SendMessageA(hwnd, EM_GETTEXTLENGTHEX, (WPARAM)&gtl, 0);
-    todo_wine ok(ret == 1, "ret %d\n",ret);
+    ok(ret == 1, "ret %d\n",ret);
+
+    SendMessage(hwnd, WM_GETTEXT, sizeof(buffer), (LPARAM)buffer);
+    ret = strcmp(buffer, test_string_after);
+    ok(ret == 0, "WM_GETTEXT recovered incorrect string!\n");
 
     DestroyWindow(hwnd);
 
@@ -2109,7 +2116,7 @@ static void test_EM_GETTEXTLENGTHEX(void)
     ret = SendMessageA(hwnd, EM_GETTEXTLENGTHEX, (WPARAM)&gtl, 0);
     ok(ret == 0, "ret %d\n",ret);
 
-    SendMessage(hwnd, WM_SETTEXT, 0, (LPARAM) "a\nb\n\n\r\n");
+    SendMessage(hwnd, WM_SETTEXT, 0, (LPARAM) test_string);
 
     gtl.flags = GTL_NUMCHARS | GTL_PRECISE | GTL_USECRLF;
     gtl.codepage = CP_ACP;




More information about the wine-cvs mailing list