[PATCH] richedit: empty text should result in a scroll range of 0. Tests for this behavior.

Alex Villacís Lasso alex at karlalex.palosanto.com
Sun May 11 09:54:58 CDT 2008


---
 dlls/riched20/paint.c        |   11 ++++++++---
 dlls/riched20/tests/editor.c |   12 +++++++++++-
 2 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/dlls/riched20/paint.c b/dlls/riched20/paint.c
index 91b71dc..df2eda8 100644
--- a/dlls/riched20/paint.c
+++ b/dlls/riched20/paint.c
@@ -674,9 +674,14 @@ void ME_Scroll(ME_TextEditor *editor, int value, int type)
     si.fMask |= SIF_DISABLENOSCROLL;
   
   si.nMin = 0;  
-  si.nMax = editor->nTotalLength;
-  
-  si.nPage = editor->sizeWindow.cy;
+
+  if (ME_GetTextLength(editor) > 0)
+  {
+    si.nMax = editor->nTotalLength;
+    si.nPage = editor->sizeWindow.cy;
+  } else {
+    si.nMax = si.nPage = 0;
+  }
      
   TRACE("min=%d max=%d page=%d\n", si.nMin, si.nMax, si.nPage);
   SetScrollInfo(hWnd, SB_VERT, &si, TRUE);
diff --git a/dlls/riched20/tests/editor.c b/dlls/riched20/tests/editor.c
index 94e4595..5dabe62 100644
--- a/dlls/riched20/tests/editor.c
+++ b/dlls/riched20/tests/editor.c
@@ -1917,6 +1917,16 @@ static void test_EM_SCROLL(void)
   int expr; /* expected return value */
   HWND hwndRichEdit = new_richedit(NULL);
   int y_before, y_after; /* units of lines of text */
+  SCROLLINFO si;
+
+  /* Empty richedit should have scroll range of 0 */
+  si.cbSize = sizeof(si);
+  si.fMask = SIF_RANGE | SIF_PAGE | SIF_POS;
+  GetScrollInfo(hwndRichEdit, SB_VERT, &si);
+  ok(si.nMin == 0, "si.nMin == %d, expected 0\n", si.nMin);
+  ok(si.nMax == 0, "si.nMax == %d, expected 0\n", si.nMax);
+  ok(si.nPos == 0, "si.nPos == %d, expected 0\n", si.nPos);
+  ok(si.nPage == 0, "si.nPage == %d, expected 0\n", si.nPage);
 
   /* test a richedit box containing a single line of text */
   SendMessage(hwndRichEdit, WM_SETTEXT, 0, (LPARAM) "a");/* one line of text */
@@ -4177,7 +4187,6 @@ START_TEST( editor )
   test_EM_GETMODIFY();
   test_EM_EXSETSEL();
   test_WM_PASTE();
-  test_EM_AUTOURLDETECT();
   test_EM_STREAMIN();
   test_EM_STREAMOUT();
   test_EM_StreamIn_Undo();
@@ -4187,6 +4196,7 @@ START_TEST( editor )
   test_EM_REPLACESEL(1);
   test_EM_REPLACESEL(0);
   test_WM_NOTIFY();
+  test_EM_AUTOURLDETECT();
   test_eventMask();
 
   /* Set the environment variable WINETEST_RICHED20 to keep windows
-- 
1.5.4.1


--------------080505020605030801080103--



More information about the wine-patches mailing list