user32: edit: Use a dialog mode after receiving WM_GETDLGCODE message.

Tests show that the edit control uses a dialog mode after receiving 
WM_GETDLGCODE message and it doesn't depend on whether the edit control 
has a parent window.
This commit is contained in:
Sergey Khodych 2009-08-24 00:10:01 +03:00 committed by Alexandre Julliard
parent 0a1e0a3261
commit 6fa48cdd91
2 changed files with 86 additions and 35 deletions

View File

@ -83,6 +83,8 @@ WINE_DECLARE_DEBUG_CHANNEL(relay);
#define EF_USE_SOFTBRK 0x0100 /* Enable soft breaks in text. */
#define EF_APP_HAS_HANDLE 0x0200 /* Set when an app sends EM_[G|S]ETHANDLE. We are in sole control of
the text buffer if this is clear. */
#define EF_DIALOGMODE 0x0400 /* Indicates that we are inside a dialog window */
typedef enum
{
END_0 = 0, /* line ends with terminating '\0' character */
@ -3163,22 +3165,9 @@ static BOOL EDIT_EM_Undo(EDITSTATE *es)
* controls without ES_WANTRETURN would attempt to detect whether it is inside
* a dialog box or not.
*/
static BOOL EDIT_IsInsideDialog(EDITSTATE *es)
static inline 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;
return (es->flags & EF_DIALOGMODE);
}
@ -5107,27 +5096,32 @@ static LRESULT EditWndProc_common( HWND hwnd, UINT msg,
if (es->style & ES_MULTILINE)
result |= DLGC_WANTALLKEYS;
if (lParam && (((LPMSG)lParam)->message == WM_KEYDOWN))
{
int vk = (int)((LPMSG)lParam)->wParam;
if (lParam)
{
es->flags|=EF_DIALOGMODE;
if (es->hwndListBox)
{
if (vk == VK_RETURN || vk == VK_ESCAPE)
if (SendMessageW(GetParent(hwnd), CB_GETDROPPEDSTATE, 0, 0))
result |= DLGC_WANTMESSAGE;
}
else
{
switch (vk)
{
case VK_ESCAPE:
SendMessageW(GetParent(hwnd), WM_CLOSE, 0, 0);
break;
default:
break;
}
}
if (((LPMSG)lParam)->message == WM_KEYDOWN)
{
int vk = (int)((LPMSG)lParam)->wParam;
if (es->hwndListBox)
{
if (vk == VK_RETURN || vk == VK_ESCAPE)
if (SendMessageW(GetParent(hwnd), CB_GETDROPPEDSTATE, 0, 0))
result |= DLGC_WANTMESSAGE;
}
else
{
switch (vk)
{
case VK_ESCAPE:
SendMessageW(GetParent(hwnd), WM_CLOSE, 0, 0);
break;
default:
break;
}
}
}
}
break;

View File

@ -2081,6 +2081,62 @@ static void test_fontsize(void)
DeleteObject(hfont);
}
static void test_dialogmode(void)
{
HWND hwEdit;
MSG msg= {0};
int len, r;
hwEdit = create_child_editcontrol(ES_MULTILINE, 0);
r = SendMessage(hwEdit, WM_CHAR, VK_RETURN, 0x1c0001);
ok(1 == r, "expected 1, got %d\n", r);
len = SendMessage(hwEdit, WM_GETTEXTLENGTH, 0, 0);
ok(11 == len, "expected 11, got %d\n", len);
r = SendMessage(hwEdit, WM_GETDLGCODE, (WPARAM)NULL, (LPARAM)NULL);
ok(0x8d == r, "expected 0x8d, got 0x%x\n", r);
r = SendMessage(hwEdit, WM_CHAR, VK_RETURN, 0x1c0001);
ok(1 == r, "expected 1, got %d\n", r);
len = SendMessage(hwEdit, WM_GETTEXTLENGTH, 0, 0);
ok(13 == len, "expected 13, got %d\n", len);
r = SendMessage(hwEdit, WM_GETDLGCODE, (WPARAM)NULL, (LPARAM)&msg);
ok(0x8d == r, "expected 0x8d, got 0x%x\n", r);
r = SendMessage(hwEdit, WM_CHAR, VK_RETURN, 0x1c0001);
ok(1 == r, "expected 1, got %d\n", r);
len = SendMessage(hwEdit, WM_GETTEXTLENGTH, 0, 0);
ok(13 == len, "expected 13, got %d\n", len);
r = SendMessage(hwEdit, WM_CHAR, VK_RETURN, 0x1c0001);
ok(1 == r, "expected 1, got %d\n", r);
len = SendMessage(hwEdit, WM_GETTEXTLENGTH, 0, 0);
ok(13 == len, "expected 13, got %d\n", len);
destroy_child_editcontrol(hwEdit);
hwEdit = create_editcontrol(ES_MULTILINE, 0);
r = SendMessage(hwEdit, WM_CHAR, VK_RETURN, 0x1c0001);
ok(1 == r, "expected 1, got %d\n", r);
len = SendMessage(hwEdit, WM_GETTEXTLENGTH, 0, 0);
ok(11 == len, "expected 11, got %d\n", len);
msg.hwnd = hwEdit;
msg.message = WM_KEYDOWN;
msg.wParam = VK_BACK;
msg.lParam = 0xe0001;
r = SendMessage(hwEdit, WM_GETDLGCODE, VK_BACK, (LPARAM)&msg);
ok(0x8d == r, "expected 0x8d, got 0x%x\n", r);
r = SendMessage(hwEdit, WM_CHAR, VK_RETURN, 0x1c0001);
ok(1 == r, "expected 1, got %d\n", r);
len = SendMessage(hwEdit, WM_GETTEXTLENGTH, 0, 0);
ok(11 == len, "expected 11, got %d\n", len);
DestroyWindow(hwEdit);
}
START_TEST(edit)
{
hinst = GetModuleHandleA(NULL);
@ -2105,6 +2161,7 @@ START_TEST(edit)
test_singleline_wantreturn_edit_dialog();
test_child_edit_wmkeydown();
test_fontsize();
test_dialogmode();
UnregisterWindowClasses();
}