[PATCH 2/2] user32: Fix case where EM_SCROLL with page down results in trying to scroll up past the beginning.
David Hedberg
david.hedberg at gmail.com
Wed Mar 3 00:33:35 CST 2010
Reworked my patch from 2007, tested with winetestbot (job #922) and
fixes bug #1517.
---
dlls/user32/edit.c | 2 +-
dlls/user32/tests/edit.c | 17 +++++++++++++++++
2 files changed, 18 insertions(+), 1 deletions(-)
diff --git a/dlls/user32/edit.c b/dlls/user32/edit.c
index 35f8285..9898bc4 100644
--- a/dlls/user32/edit.c
+++ b/dlls/user32/edit.c
@@ -1632,7 +1632,7 @@ static LRESULT EDIT_EM_Scroll(EDITSTATE *es, INT action)
INT vlc = get_vertical_line_count(es);
/* check if we are going to move too far */
if(es->y_offset + dy > es->line_count - vlc)
- dy = es->line_count - vlc - es->y_offset;
+ dy = max(es->line_count - vlc, 0) - es->y_offset;
/* Notification is done in EDIT_EM_LineScroll */
if(dy) {
diff --git a/dlls/user32/tests/edit.c b/dlls/user32/tests/edit.c
index 0a3fc95..9c624e1 100644
--- a/dlls/user32/tests/edit.c
+++ b/dlls/user32/tests/edit.c
@@ -1320,6 +1320,7 @@ static void test_edit_control_limittext(void)
static void test_edit_control_scroll(void)
{
static const char *single_line_str = "a";
+ static const char *multiline_str = "Test\r\nText";
HWND hwEdit;
LONG ret;
@@ -1359,6 +1360,22 @@ static void test_edit_control_scroll(void)
ok(!ret, "Returned %x, expected 0\n", ret);
DestroyWindow (hwEdit);
+
+ /* SB_PAGEDOWN while at the beginning of a buffer with few lines
+ should not cause EM_SCROLL to return a negative value of
+ scrolled lines that would put us "before" the beginning. */
+ hwEdit = CreateWindow(
+ "EDIT",
+ multiline_str,
+ WS_VSCROLL | ES_MULTILINE,
+ 0, 0, 100, 100,
+ NULL, NULL, hinst, NULL);
+ assert(hwEdit);
+
+ ret = SendMessage(hwEdit, EM_SCROLL, SB_PAGEDOWN, 0);
+ ok(!ret, "Returned %x, expected 0.\n", ret);
+
+ DestroyWindow (hwEdit);
}
static void test_margins(void)
--
1.7.0
More information about the wine-patches
mailing list