Alistair Leslie-Hughes : user32: Don' t reset focus if current dialog is a child.
Alexandre Julliard
julliard at winehq.org
Sun Mar 3 13:21:33 CST 2019
Module: wine
Branch: oldstable
Commit: 14509ebdf7cdfe0d3c88e6da877ef3d9fbdc6bab
URL: https://source.winehq.org/git/wine.git/?a=commit;h=14509ebdf7cdfe0d3c88e6da877ef3d9fbdc6bab
Author: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
Date: Fri Dec 14 04:00:43 2018 +0000
user32: Don't reset focus if current dialog is a child.
The standard File Open Dialog creates an empty WS_EX_CONTROLPARENT
child dialog which shouldn't receive focus.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=46215
Signed-off-by: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
(cherry picked from commit d8a27a78dd83f52b26cf8b7711f3ea127c0b34f7)
Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>
---
dlls/user32/dialog.c | 5 +++-
dlls/user32/tests/dialog.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 77 insertions(+), 1 deletion(-)
diff --git a/dlls/user32/dialog.c b/dlls/user32/dialog.c
index f6d4a86..858dad7 100644
--- a/dlls/user32/dialog.c
+++ b/dlls/user32/dialog.c
@@ -692,7 +692,10 @@ static HWND DIALOG_CreateIndirect( HINSTANCE hInst, LPCVOID dlgTemplate,
SetFocus( focus );
}
else
- SetFocus( hwnd );
+ {
+ if (!(template.style & WS_CHILD))
+ SetFocus( hwnd );
+ }
}
}
diff --git a/dlls/user32/tests/dialog.c b/dlls/user32/tests/dialog.c
index f57271c..34d6331 100644
--- a/dlls/user32/tests/dialog.c
+++ b/dlls/user32/tests/dialog.c
@@ -874,6 +874,56 @@ static INT_PTR CALLBACK focusDlgWinProc (HWND hDlg, UINT uiMsg, WPARAM wParam,
return FALSE;
}
+static INT_PTR CALLBACK EmptyProcUserTemplate(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+ switch(uMsg) {
+ case WM_INITDIALOG:
+ return TRUE;
+ }
+ return FALSE;
+}
+
+static INT_PTR CALLBACK focusChildDlgWinProc (HWND hwnd, UINT uiMsg, WPARAM wParam,
+ LPARAM lParam)
+{
+ static HWND hChildDlg;
+
+ switch (uiMsg)
+ {
+ case WM_INITDIALOG:
+ {
+ RECT rectHwnd;
+ struct {
+ DLGTEMPLATE tmplate;
+ WORD menu,class,title;
+ } temp;
+
+ SetFocus( GetDlgItem(hwnd, 200) );
+
+ GetClientRect(hwnd,&rectHwnd);
+ temp.tmplate.style = WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | DS_CONTROL | DS_3DLOOK;
+ temp.tmplate.dwExtendedStyle = 0;
+ temp.tmplate.cdit = 0;
+ temp.tmplate.x = 0;
+ temp.tmplate.y = 0;
+ temp.tmplate.cx = 0;
+ temp.tmplate.cy = 0;
+ temp.menu = temp.class = temp.title = 0;
+
+ hChildDlg = CreateDialogIndirectParamA(g_hinst, &temp.tmplate,
+ hwnd, (DLGPROC)EmptyProcUserTemplate, 0);
+ ok(hChildDlg != 0, "Failed to create test dialog.\n");
+
+ return FALSE;
+ }
+ case WM_CLOSE:
+ DestroyWindow(hChildDlg);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
/* Helper for InitialFocusTest */
static const char * GetHwndString(HWND hw)
{
@@ -1060,6 +1110,29 @@ static void test_focus(void)
DestroyWindow(hDlg);
}
+
+ /* Test 6:
+ * Select textbox's text on creation when WM_INITDIALOG creates a child dialog. */
+ {
+ HWND hDlg;
+ HRSRC hResource;
+ HANDLE hTemplate;
+ DLGTEMPLATE* pTemplate;
+ HWND edit;
+
+ hResource = FindResourceA(g_hinst,"FOCUS_TEST_DIALOG_3", (LPCSTR)RT_DIALOG);
+ hTemplate = LoadResource(g_hinst, hResource);
+ pTemplate = LockResource(hTemplate);
+
+ hDlg = CreateDialogIndirectParamA(g_hinst, pTemplate, NULL, focusChildDlgWinProc, 0);
+ ok(hDlg != 0, "Failed to create test dialog.\n");
+ edit = GetDlgItem(hDlg, 200);
+
+ ok(GetFocus() == edit, "Focus not set to edit, focus=%p, dialog=%p, edit=%p\n",
+ GetFocus(), hDlg, edit);
+
+ DestroyWindow(hDlg);
+ }
}
static void test_GetDlgItemText(void)
More information about the wine-cvs
mailing list