Commit 3cc6e236 authored by Alex Villacís Lasso's avatar Alex Villacís Lasso Committed by Alexandre Julliard

richedit: When returning position through wParam pointer, EM_POSFROMCHAR must return 0 as LRESULT.

Add tests for EM_POSFROMCHAR for 1.0 and 2.0.
parent 15a5da97
......@@ -2920,7 +2920,7 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam,
if (wParam >= 0x40000) {
*(POINTL *)wParam = pt;
}
return MAKELONG( pt.x, pt.y );
return (wParam >= 0x40000) ? 0 : MAKELONG( pt.x, pt.y );
}
case WM_CREATE:
if (GetWindowLongW(hWnd, GWL_STYLE) & WS_HSCROLL)
......
......@@ -397,6 +397,72 @@ static void test_EM_SCROLLCARET(void)
DestroyWindow(hwndRichEdit);
}
static void test_EM_POSFROMCHAR(void)
{
HWND hwndRichEdit = new_richedit(NULL);
unsigned int i;
LRESULT result;
unsigned int height = 0;
unsigned int xpos = 0;
/* Fill the control to lines to ensure that most of them are offscreen */
for (i = 0; i < 50; i++)
{
/* Do not modify the string; it is exactly 16 characters long. */
SendMessage(hwndRichEdit, EM_SETSEL, 0, 0);
SendMessage(hwndRichEdit, EM_REPLACESEL, 0, (LPARAM)"0123456789ABCDE\n");
}
/*
Richedit 1.0 receives a POINTL* on wParam and character offset on lParam, returns void.
Richedit 2.0 receives character offset on wParam, ignores lParam, returns MAKELONG(x,y)
Richedit 3.0 accepts either of the above API conventions.
*/
/* Testing Richedit 2.0 API format */
/* Testing start of lines. X-offset should be constant on all cases (native is 1).
Since all lines are identical and drawn with the same font,
they should have the same height... right?
*/
for (i = 0; i < 50; i++)
{
/* All the lines are 16 characters long */
result = SendMessage(hwndRichEdit, EM_POSFROMCHAR, i * 16, 0);
if (i == 0)
{
ok(HIWORD(result) == 0, "EM_POSFROMCHAR reports y=%d, expected 0\n", HIWORD(result));
todo_wine {
ok(LOWORD(result) == 1, "EM_POSFROMCHAR reports x=%d, expected 1\n", LOWORD(result));
}
xpos = LOWORD(result);
}
else if (i == 1)
{
ok(HIWORD(result) > 0, "EM_POSFROMCHAR reports y=%d, expected > 0\n", HIWORD(result));
ok(LOWORD(result) == xpos, "EM_POSFROMCHAR reports x=%d, expected 1\n", LOWORD(result));
height = HIWORD(result);
}
else
{
ok(HIWORD(result) == i * height, "EM_POSFROMCHAR reports y=%d, expected %d\n", HIWORD(result), i * height);
ok(LOWORD(result) == xpos, "EM_POSFROMCHAR reports x=%d, expected 1\n", LOWORD(result));
}
}
/* Testing position at end of text */
result = SendMessage(hwndRichEdit, EM_POSFROMCHAR, 50 * 16, 0);
ok(HIWORD(result) == 50 * height, "EM_POSFROMCHAR reports y=%d, expected %d\n", HIWORD(result), 50 * height);
ok(LOWORD(result) == xpos, "EM_POSFROMCHAR reports x=%d, expected 1\n", LOWORD(result));
/* Testing position way past end of text */
result = SendMessage(hwndRichEdit, EM_POSFROMCHAR, 55 * 16, 0);
ok(HIWORD(result) == 50 * height, "EM_POSFROMCHAR reports y=%d, expected %d\n", HIWORD(result), 50 * height);
ok(LOWORD(result) == xpos, "EM_POSFROMCHAR reports x=%d, expected 1\n", LOWORD(result));
DestroyWindow(hwndRichEdit);
}
static void test_EM_SETCHARFORMAT(void)
{
HWND hwndRichEdit = new_richedit(NULL);
......@@ -4170,6 +4236,7 @@ START_TEST( editor )
test_WM_CHAR();
test_EM_FINDTEXT();
test_EM_GETLINE();
test_EM_POSFROMCHAR();
test_EM_SCROLLCARET();
test_EM_SCROLL();
test_WM_SETTEXT();
......
......@@ -471,6 +471,7 @@ BOOL ME_WrapMarkedParagraphs(ME_TextEditor *editor) {
ME_Context c;
BOOL bModified = FALSE;
int yStart = -1;
int yLastPos = 0;
ME_InitContext(&c, editor, GetDC(editor->hWnd));
editor->nHeight = 0;
......@@ -496,6 +497,7 @@ BOOL ME_WrapMarkedParagraphs(ME_TextEditor *editor) {
bModified = bModified | bRedraw;
yLastPos = c.pt.y;
c.pt.y += item->member.para.nHeight;
item = item->member.para.next_para;
}
......@@ -503,6 +505,7 @@ BOOL ME_WrapMarkedParagraphs(ME_TextEditor *editor) {
editor->sizeWindow.cy = c.rcView.bottom-c.rcView.top;
editor->nTotalLength = c.pt.y;
editor->pBuffer->pLast->member.para.nYPos = yLastPos;
ME_DestroyContext(&c, editor->hWnd);
......
......@@ -696,6 +696,75 @@ static void test_EM_FINDTEXT(void)
DestroyWindow(hwndRichEdit);
}
static void test_EM_POSFROMCHAR(void)
{
HWND hwndRichEdit = new_richedit(NULL);
unsigned int i;
POINTL pl;
LRESULT result;
unsigned int height = 0;
unsigned int xpos = 0;
/* Fill the control to lines to ensure that most of them are offscreen */
for (i = 0; i < 50; i++)
{
/* Do not modify the string; it is exactly 16 characters long. */
SendMessage(hwndRichEdit, EM_SETSEL, 0, 0);
SendMessage(hwndRichEdit, EM_REPLACESEL, 0, (LPARAM)"0123456789ABCD\r\n");
}
/*
Richedit 1.0 receives a POINTL* on wParam and character offset on lParam, returns void.
Richedit 2.0 receives character offset on wParam, ignores lParam, returns MAKELONG(x,y)
Richedit 3.0 accepts either of the above API conventions.
*/
/* Testing Richedit 1.0 API format */
/* Testing start of lines. X-offset should be constant on all cases (native is 1).
Since all lines are identical and drawn with the same font,
they should have the same height... right?
*/
for (i = 0; i < 50; i++)
{
/* All the lines are 16 characters long */
result = SendMessage(hwndRichEdit, EM_POSFROMCHAR, (WPARAM)&pl, i * 16);
ok(result == 0, "EM_POSFROMCHAR returned %ld, expected 0\n", result);
if (i == 0)
{
ok(pl.y == 0, "EM_POSFROMCHAR reports y=%d, expected 0\n", pl.y);
todo_wine {
ok(pl.x == 1, "EM_POSFROMCHAR reports x=%d, expected 1\n", pl.x);
}
xpos = pl.x;
}
else if (i == 1)
{
ok(pl.y > 0, "EM_POSFROMCHAR reports y=%d, expected > 0\n", pl.y);
ok(pl.x == xpos, "EM_POSFROMCHAR reports x=%d, expected 1\n", pl.x);
height = pl.y;
}
else
{
ok(pl.y == i * height, "EM_POSFROMCHAR reports y=%d, expected %d\n", pl.y, i * height);
ok(pl.x == xpos, "EM_POSFROMCHAR reports x=%d, expected 1\n", pl.x);
}
}
/* Testing position at end of text */
result = SendMessage(hwndRichEdit, EM_POSFROMCHAR, (WPARAM)&pl, 50 * 16);
ok(result == 0, "EM_POSFROMCHAR returned %ld, expected 0\n", result);
ok(pl.y == 50 * height, "EM_POSFROMCHAR reports y=%d, expected %d\n", pl.y, 50 * height);
ok(pl.x == xpos, "EM_POSFROMCHAR reports x=%d, expected 1\n", pl.x);
/* Testing position way past end of text */
result = SendMessage(hwndRichEdit, EM_POSFROMCHAR, (WPARAM)&pl, 55 * 16);
ok(result == 0, "EM_POSFROMCHAR returned %ld, expected 0\n", result);
ok(pl.y == 50 * height, "EM_POSFROMCHAR reports y=%d, expected %d\n", pl.y, 50 * height);
ok(pl.x == xpos, "EM_POSFROMCHAR reports x=%d, expected 1\n", pl.x);
DestroyWindow(hwndRichEdit);
}
START_TEST( editor )
......@@ -717,6 +786,7 @@ START_TEST( editor )
test_EM_GETLINE();
test_EM_LINELENGTH();
test_EM_FINDTEXT();
test_EM_POSFROMCHAR();
/* Set the environment variable WINETEST_RICHED32 to keep windows
* responsive and open for 30 seconds. This is useful for debugging.
......
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