Commit 34b980e6 authored by Fabian Maurer's avatar Fabian Maurer Committed by Alexandre Julliard

comctl32/edit: In EM_POSFROMCHAR return correct position for empty lines.

parent f37d9122
......@@ -1038,12 +1038,8 @@ static LRESULT EDIT_EM_PosFromChar(EDITSTATE *es, INT index, BOOL after_wrap)
lw = line_def->width;
w = es->format_rect.right - es->format_rect.left;
if (line_def->ssa)
{
ScriptStringCPtoX(line_def->ssa, (index - 1) - li, TRUE, &x);
x -= es->x_offset;
}
else
x = es->x_offset;
x -= es->x_offset;
if (es->style & ES_RIGHT)
x = w - (lw - x);
......
......@@ -1189,6 +1189,8 @@ static void test_char_from_pos(void)
{
int lo, hi, mid, ret, i;
HWND hwEdit;
HDC dc;
SIZE size;
hwEdit = create_editcontrol(ES_AUTOHSCROLL | ES_AUTOVSCROLL, 0);
SendMessageA(hwEdit, WM_SETTEXT, 0, (LPARAM)"aa");
......@@ -1321,6 +1323,24 @@ static void test_char_from_pos(void)
ret = SendMessageA(hwEdit, EM_POSFROMCHAR, 2, 0);
ok(-1 == ret, "expected -1 got %d\n", ret);
DestroyWindow(hwEdit);
/* Scrolled to the right with partially visible line, position on next line. */
hwEdit = create_editcontrol(ES_MULTILINE | ES_AUTOHSCROLL | ES_AUTOVSCROLL, 0);
dc = GetDC(hwEdit);
GetTextExtentPoint32A(dc, "w", 1, &size);
ReleaseDC(hwEdit, dc);
SetWindowPos(hwEdit, NULL, 0, 0, size.cx * 15, size.cy * 5, SWP_NOMOVE | SWP_NOZORDER);
SendMessageA(hwEdit, WM_SETTEXT, 0, (LPARAM)"wwwwwwwwwwwwwwwwwwww\r\n\r\n");
SendMessageA(hwEdit, EM_SETSEL, 40, 40);
lo = (short)SendMessageA(hwEdit, EM_POSFROMCHAR, 22, 0);
ret = (short)SendMessageA(hwEdit, EM_POSFROMCHAR, 20, 0);
ret -= 20 * size.cx; /* Calculate expected position, 20 characters back. */
ok(ret == lo, "Unexpected position %d vs %d.\n", lo, ret);
DestroyWindow(hwEdit);
}
/* Test if creating edit control without ES_AUTOHSCROLL and ES_AUTOVSCROLL
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment