[PATCH] When returning position through wParam pointer, EM_POSFROMCHAR must return 0 as LRESULT. Add tests for EM_POSFROMCHAR for 1.0 and 2.0.
Alex Villacís Lasso
alex at karlalex.palosanto.com
Tue Jun 17 23:23:08 CDT 2008
---
dlls/riched20/editor.c | 2 +-
dlls/riched20/tests/editor.c | 68 ++++++++++++++++++++++++++++++++++++++++
dlls/riched20/wrap.c | 3 ++
dlls/riched32/tests/editor.c | 70 ++++++++++++++++++++++++++++++++++++++++++
4 files changed, 142 insertions(+), 1 deletions(-)
diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c
index 9f18d5f..73d5652 100644
--- a/dlls/riched20/editor.c
+++ b/dlls/riched20/editor.c
@@ -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:
editor->bVScrollEnabled = ((GetWindowLongW(hWnd, GWL_STYLE) & WS_VSCROLL) != 0);
diff --git a/dlls/riched20/tests/editor.c b/dlls/riched20/tests/editor.c
index 7d9bf42..bf900ab 100644
--- a/dlls/riched20/tests/editor.c
+++ b/dlls/riched20/tests/editor.c
@@ -397,6 +397,73 @@ static void test_EM_SCROLLCARET(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)"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);
@@ -4347,6 +4414,7 @@ START_TEST( editor )
test_WM_CHAR();
test_EM_FINDTEXT();
test_EM_GETLINE();
+ test_EM_POSFROMCHAR();
test_EM_SCROLLCARET();
test_EM_SCROLL();
test_scrollbar_visibility();
diff --git a/dlls/riched20/wrap.c b/dlls/riched20/wrap.c
index da5fef7..3230ff7 100644
--- a/dlls/riched20/wrap.c
+++ b/dlls/riched20/wrap.c
@@ -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);
diff --git a/dlls/riched32/tests/editor.c b/dlls/riched32/tests/editor.c
index ff82654..56bb100 100644
--- a/dlls/riched32/tests/editor.c
+++ b/dlls/riched32/tests/editor.c
@@ -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.
--
1.5.4.1
--------------060201010507010304030900--
More information about the wine-patches
mailing list