From 3ff27f3544b9954a98e2801201f439aca159cec8 Mon Sep 17 00:00:00 2001 From: Andrew Eikum Date: Thu, 10 Oct 2013 12:06:21 -0500 Subject: [PATCH] user32: Don't try to paint during WM_SETFOCUS if the edit control is not visible. --- dlls/user32/edit.c | 2 +- dlls/user32/tests/msg.c | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/dlls/user32/edit.c b/dlls/user32/edit.c index 3634710866e..dbf1dcc45c0 100644 --- a/dlls/user32/edit.c +++ b/dlls/user32/edit.c @@ -3791,7 +3791,7 @@ static void EDIT_WM_SetFocus(EDITSTATE *es) EDIT_InvalidateText(es, es->selection_start, es->selection_end); /* single line edit updates itself */ - if (!(es->style & ES_MULTILINE)) + if (IsWindowVisible(es->hwndSelf) && !(es->style & ES_MULTILINE)) { HDC hdc = GetDC(es->hwndSelf); EDIT_WM_Paint(es, hdc); diff --git a/dlls/user32/tests/msg.c b/dlls/user32/tests/msg.c index aab3d121a88..a23dd7fee2b 100644 --- a/dlls/user32/tests/msg.c +++ b/dlls/user32/tests/msg.c @@ -9453,6 +9453,17 @@ static const struct message sl_edit_setfocus[] = { WM_COMMAND, sent|parent|wparam, MAKEWPARAM(ID_EDIT, EN_SETFOCUS) }, { 0 } }; +static const struct message sl_edit_invisible[] = +{ + { HCBT_SETFOCUS, hook }, + { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, + { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 }, + { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 }, + { WM_KILLFOCUS, sent|parent }, + { WM_SETFOCUS, sent }, + { WM_COMMAND, sent|parent|wparam, MAKEWPARAM(ID_EDIT, EN_SETFOCUS) }, + { 0 } +}; static const struct message ml_edit_setfocus[] = { { HCBT_SETFOCUS, hook }, @@ -9602,6 +9613,10 @@ static void test_edit_messages(void) dlg_code = SendMessageA(hwnd, WM_GETDLGCODE, 0, 0); ok(dlg_code == (DLGC_WANTCHARS|DLGC_HASSETSEL|DLGC_WANTARROWS), "wrong dlg_code %08x\n", dlg_code); + flush_sequence(); + SetFocus(hwnd); + ok_sequence(sl_edit_invisible, "SetFocus(hwnd) on an invisible edit", FALSE); + ShowWindow(hwnd, SW_SHOW); UpdateWindow(hwnd); SetFocus(0);