riched20: Implement EM_LIMITTEXT and some simple tests.

Matt Finnicum mattfinn at gmail.com
Tue Jan 23 13:41:14 CST 2007


Forgot the patch itself. Sorry.

On 1/23/07, Matt Finnicum <mattfinn at gmail.com> wrote:
> This just implements EM_LIMITTEXT and some simple tests. Since
> EM_EXLIMITTEXT was already implemented, I didn't have to modify any
> other functions to use the text limiting - I just had to have this
> message set the nTextLimit variable properly. Note that MSDN claims
> lots of nonsense about this message setting the limit to -1 for
> multiline controls, but as the tests show - that's just not true.
> Since it's an old message, I'm just assuming that behavior no longer
> exists or matters.
>
> Changelog:
> riched20: Implement EM_LIMITTEXT and some simple tests.
>
> --Matt Finnicum
>
>  dlls/riched20/editor.c       |   11 +++++++++--
>  dlls/riched20/tests/editor.c |   41 +++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 50 insertions(+), 2 deletions(-)
>
-------------- next part --------------
diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c
index a8fadc1..a8e503f 100644
--- a/dlls/riched20/editor.c
+++ b/dlls/riched20/editor.c
@@ -77,7 +77,7 @@
   - EM_GETWORDWRAPMODE 1.0asian
   + EM_GETZOOM 3.0
   + EM_HIDESELECTION
-  - EM_LIMITTEXT
+  + EM_LIMITTEXT (Also called EM_SETLIMITTEXT)
   + EM_LINEFROMCHAR
   + EM_LINEINDEX
   + EM_LINELENGTH
@@ -1440,7 +1440,6 @@ LRESULT WINAPI RichEditANSIWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lP
   UNSUPPORTED_MSG(EM_GETTYPOGRAPHYOPTIONS)
   UNSUPPORTED_MSG(EM_GETUNDONAME)
   UNSUPPORTED_MSG(EM_GETWORDBREAKPROCEX)
-  UNSUPPORTED_MSG(EM_LIMITTEXT) /* also known as EM_SETLIMITTEXT */
   UNSUPPORTED_MSG(EM_PASTESPECIAL)
   UNSUPPORTED_MSG(EM_SELECTIONTYPE)
   UNSUPPORTED_MSG(EM_SETBIDIOPTIONS)
@@ -2204,6 +2203,14 @@ LRESULT WINAPI RichEditANSIWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lP
       editor->nTextLimit = (int) lParam;
     return 0;
   }
+  case EM_LIMITTEXT:
+  {
+    if (wParam == 0)
+      editor->nTextLimit = 65536;
+    else
+      editor->nTextLimit = (int) wParam;
+    return 0;
+  }    
   case EM_GETLIMITTEXT:
   {
     return editor->nTextLimit;
diff --git a/dlls/riched20/tests/editor.c b/dlls/riched20/tests/editor.c
index da6390f..0fffefc 100644
--- a/dlls/riched20/tests/editor.c
+++ b/dlls/riched20/tests/editor.c
@@ -2,6 +2,7 @@
 * Unit test suite for rich edit control
 *
 * Copyright 2006 Google (Thomas Kho)
+* Copyright 2007 Matt Finnicum
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
@@ -974,6 +975,45 @@ static void test_EM_SETTEXTEX(void)
   DestroyWindow(hwndRichEdit);
 }
 
+static void test_EM_LIMITTEXT(void)
+{
+  int ret;
+    
+  HWND hwndRichEdit = new_richedit(NULL);
+  
+  /* The main purpose of this test is to demonstrate that the nonsense in MSDN
+   * about setting the length to -1 for multiline edit controls doesn't happen.
+   */
+
+  /* Don't check default gettextlimit case. That's done in other tests */
+  
+  /* Set textlimit to 100 */
+  SendMessage (hwndRichEdit, EM_LIMITTEXT, 100, 0);
+  ret = SendMessage (hwndRichEdit, EM_GETLIMITTEXT, 0, 0);
+  ok (ret == 100, 
+      "EM_LIMITTEXT: set to 100, returned: %d, expected: 100\n", ret);
+  
+  /* Set textlimit to 0 */
+  SendMessage (hwndRichEdit, EM_LIMITTEXT, 0, 0);
+  ret = SendMessage (hwndRichEdit, EM_GETLIMITTEXT, 0, 0);
+  ok (ret == 65536, 
+      "EM_LIMITTEXT: set to 0, returned: %d, expected: 65536\n", ret);
+
+  /* Set textlimit to -1 */
+  SendMessage (hwndRichEdit, EM_LIMITTEXT, -1, 0);
+  ret = SendMessage (hwndRichEdit, EM_GETLIMITTEXT, 0, 0);
+  ok (ret == -1, 
+      "EM_LIMITTEXT: set to -1, returned: %d, expected: -1\n", ret);
+
+  /* Set textlimit to -2 */
+  SendMessage (hwndRichEdit, EM_LIMITTEXT, -2, 0);
+  ret = SendMessage (hwndRichEdit, EM_GETLIMITTEXT, 0, 0);
+  ok (ret == -2, 
+      "EM_LIMITTEXT: set to -2, returned: %d, expected: -2\n", ret);
+   
+  DestroyWindow (hwndRichEdit);
+}
+  
 
 static void test_EM_EXLIMITTEXT(void)
 {
@@ -1386,6 +1426,7 @@ START_TEST( editor )
   test_EM_SETUNDOLIMIT();
   test_ES_PASSWORD();
   test_EM_SETTEXTEX();
+  test_EM_LIMITTEXT();
   test_EM_EXLIMITTEXT();
   test_EM_GETLIMITTEXT();
   test_WM_SETFONT();
-- 
1.4.4.4


More information about the wine-patches mailing list