user32: A fix for edit controls and long selection strings.
Michael Moss
mmoss at google.com
Thu Apr 17 12:41:11 CDT 2008
[originally a Picasa patch by Aric Stewart]
---
dlls/user32/edit.c | 19 ++++++++++++-------
1 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/dlls/user32/edit.c b/dlls/user32/edit.c
index a5265e9..49f0b04 100644
--- a/dlls/user32/edit.c
+++ b/dlls/user32/edit.c
@@ -3475,6 +3475,11 @@ static void EDIT_EM_ScrollCaret(EDITSTATE *es)
INT format_width;
x = (short)LOWORD(EDIT_EM_PosFromChar(es, es->selection_end, FALSE));
+ if (x < 0)
+ {
+ ERR("Overflow short!\n");
+ return;
+ }
format_width = es->format_rect.right - es->format_rect.left;
if (x < es->format_rect.left) {
goal = es->format_rect.left + format_width / HSCROLL_FRACTION;
@@ -3485,14 +3490,14 @@ static void EDIT_EM_ScrollCaret(EDITSTATE *es)
/* FIXME: use ScrollWindow() somehow to improve performance */
EDIT_UpdateText(es, NULL, TRUE);
} else if (x > es->format_rect.right) {
+ /* scroll edit to display the tail end of the string */
INT x_last;
- INT len = get_text_length(es);
- goal = es->format_rect.right - format_width / HSCROLL_FRACTION;
- do {
- es->x_offset++;
- x = (short)LOWORD(EDIT_EM_PosFromChar(es, es->selection_end, FALSE));
- x_last = (short)LOWORD(EDIT_EM_PosFromChar(es, len, FALSE));
- } while ((x > goal) && (x_last > es->format_rect.right));
+
+ es->x_offset=0;
+ x = (short)LOWORD(EDIT_EM_PosFromChar(es, es->selection_end, FALSE));
+ x_last = EDIT_CharFromPos(es, x-es->format_rect.right, 1, NULL);
+ es->x_offset = x_last+1;
+
/* FIXME: use ScrollWindow() somehow to improve performance */
EDIT_UpdateText(es, NULL, TRUE);
}
--
1.5.3.GIT
More information about the wine-patches
mailing list