Commit f704d5c6 authored by Lei Zhang's avatar Lei Zhang Committed by Alexandre Julliard

user32: Add edit control check to see if its in a dialog on WM_CHAR/VK_RETURN.

parent 731d77f7
......@@ -863,7 +863,7 @@ static LRESULT WINAPI EditWndProc_common( HWND hwnd, UINT msg,
}
else
{
if (charW == VK_TAB || charW == VK_RETURN)
if (charW == VK_TAB)
break;
}
result = EDIT_WM_Char(es, charW);
......@@ -3989,6 +3989,32 @@ static BOOL EDIT_EM_Undo(EDITSTATE *es)
}
/* Helper function for WM_CHAR
*
* According to an MSDN blog article titled "Just because you're a control
* doesn't mean that you're necessarily inside a dialog box," multiline edit
* controls without ES_WANTRETURN would attempt to detect whether it is inside
* a dialog box or not.
*/
static BOOL EDIT_IsInsideDialog(EDITSTATE *es)
{
WND *pParent;
BOOL r = FALSE;
if (es->hwndParent)
{
pParent = WIN_GetPtr(es->hwndParent);
if (pParent && pParent != WND_OTHER_PROCESS && pParent != WND_DESKTOP)
{
if (pParent->flags & WIN_ISDIALOG)
r = TRUE;
WIN_ReleasePtr(pParent);
}
}
return r;
}
/*********************************************************************
*
* WM_CHAR
......@@ -4002,9 +4028,13 @@ static LRESULT EDIT_WM_Char(EDITSTATE *es, WCHAR c)
switch (c) {
case '\r':
/* If the edit doesn't want the return and it's not a multiline edit, do nothing */
if(!(es->style & ES_MULTILINE) && !(es->style & ES_WANTRETURN))
break;
/* If it's not a multiline edit box, it would be ignored below.
* For multiline edit without ES_WANTRETURN, we have to make a
* special case.
*/
if ((es->style & ES_MULTILINE) && !(es->style & ES_WANTRETURN))
if (EDIT_IsInsideDialog(es))
break;
case '\n':
if (es->style & ES_MULTILINE) {
if (es->style & ES_READONLY) {
......
......@@ -1652,15 +1652,13 @@ static void test_enter(void)
ok(TRUE == r, "Expected: %d, got: %d\n", TRUE, r);
r = SendMessage(hwEdit, WM_CHAR, VK_RETURN, 0);
todo_wine ok(1 == r, "Expected: %d, got: %d\n", 1, r);
ok(1 == r, "Expected: %d, got: %d\n", 1, r);
/* get text */
buffer[0] = 0;
r = SendMessage(hwEdit, WM_GETTEXT, 16, (LPARAM) buffer);
todo_wine {
ok(2 == r, "Expected: %d, got len %d\n", 2, r);
ok(0 == strcmp(buffer, "\r\n"), "expected \"\\r\\n\", got \"%s\"\n", buffer);
}
DestroyWindow (hwEdit);
......@@ -1674,7 +1672,7 @@ static void test_enter(void)
ok(TRUE == r, "Expected: %d, got: %d\n", TRUE, r);
r = SendMessage(hwEdit, WM_CHAR, VK_RETURN, 0);
todo_wine ok(1 == r, "Expected: %d, got: %d\n", 1, r);
ok(1 == r, "Expected: %d, got: %d\n", 1, r);
/* get text */
buffer[0] = 0;
......@@ -1694,7 +1692,7 @@ static void test_enter(void)
ok(TRUE == r, "Expected: %d, got: %d\n", TRUE, r);
r = SendMessage(hwEdit, WM_CHAR, VK_RETURN, 0);
todo_wine ok(1 == r, "Expected: %d, got: %d\n", 1, r);
ok(1 == r, "Expected: %d, got: %d\n", 1, r);
/* get text */
buffer[0] = 0;
......@@ -1844,7 +1842,7 @@ static void test_wantreturn_edit_dialog(void)
r = DialogBoxParam(hinst, "EDIT_WANTRETURN_DIALOG", NULL, (DLGPROC)edit_wantreturn_dialog_proc, 3);
ok(444 == r, "Expected %d, got %d\n", 444, r);
r = DialogBoxParam(hinst, "EDIT_WANTRETURN_DIALOG", NULL, (DLGPROC)edit_wantreturn_dialog_proc, 4);
todo_wine ok(444 == r, "Expected %d, got %d\n", 444, r);
ok(444 == r, "Expected %d, got %d\n", 444, r);
r = DialogBoxParam(hinst, "EDIT_WANTRETURN_DIALOG", NULL, (DLGPROC)edit_wantreturn_dialog_proc, 5);
ok(444 == r, "Expected %d, got %d\n", 444, r);
......@@ -1852,7 +1850,7 @@ static void test_wantreturn_edit_dialog(void)
r = DialogBoxParam(hinst, "EDIT_WANTRETURN_DIALOG", NULL, (DLGPROC)edit_wantreturn_dialog_proc, 6);
todo_wine ok(444 == r, "Expected %d, got %d\n", 444, r);
r = DialogBoxParam(hinst, "EDIT_WANTRETURN_DIALOG", NULL, (DLGPROC)edit_wantreturn_dialog_proc, 7);
todo_wine ok(444 == r, "Expected %d, got %d\n", 444, r);
ok(444 == r, "Expected %d, got %d\n", 444, r);
r = DialogBoxParam(hinst, "EDIT_WANTRETURN_DIALOG", NULL, (DLGPROC)edit_wantreturn_dialog_proc, 8);
ok(444 == r, "Expected %d, got %d\n", 444, r);
}
......
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