user32: DIALOG_CreateIndirect()
Ulrich Czekalla
ulrich.czekalla at utoronto.ca
Wed Dec 15 14:45:27 CST 2004
ChangeLog:
Ulrich Czekalla <ulrich at codeweavers.com>
If a dialog with the DS_CONTROL style is not visible then ignore
default focus assignment
-------------- next part --------------
Index: dlls/user/tests/dialog.c
===================================================================
RCS file: /home/wine/wine/dlls/user/tests/dialog.c,v
retrieving revision 1.9
diff -u -p -r1.9 dialog.c
--- dlls/user/tests/dialog.c 10 Sep 2004 22:29:02 -0000 1.9
+++ dlls/user/tests/dialog.c 15 Dec 2004 21:26:41 -0000
@@ -716,6 +716,31 @@ static LRESULT CALLBACK delayFocusDlgWin
return FALSE;
}
+static LRESULT CALLBACK focusDlgWinProc (HWND hDlg, UINT uiMsg, WPARAM wParam,
+ LPARAM lParam)
+{
+ switch (uiMsg)
+ {
+ case WM_INITDIALOG:
+ return TRUE;
+
+ case WM_COMMAND:
+ if (LOWORD(wParam) == IDCANCEL)
+ {
+ EndDialog(hDlg, LOWORD(wParam));
+ return TRUE;
+ }
+ else if (LOWORD(wParam) == 200)
+ {
+ if (HIWORD(wParam) == EN_SETFOCUS)
+ g_hwndInitialFocusT1 = (HWND)lParam;
+ }
+ return FALSE;
+ }
+
+ return FALSE;
+}
+
/* Helper for InitialFocusTest */
static const char * GetHwndString(HWND hw)
{
@@ -800,6 +825,28 @@ static void InitialFocusTest (void)
"Expected the second button (%p), got %s (%p).\n",
g_hwndButton2, GetHwndString(g_hwndInitialFocusT2),
g_hwndInitialFocusT2);
+
+ /* Test 3:
+ * If the dialog has DS_CONTROL and it's not visible then we shouldn't change focus */
+ {
+ HWND hDlg;
+ HRSRC hResource;
+ HANDLE hTemplate;
+ DLGTEMPLATE* pTemplate;
+
+ hResource = FindResourceA(g_hinst,"FOCUS_TEST_DIALOG", (LPSTR)RT_DIALOG);
+ hTemplate = LoadResource(g_hinst, hResource);
+ pTemplate = (LPDLGTEMPLATEA)LockResource(hTemplate);
+
+ g_hwndInitialFocusT1 = 0;
+ hDlg = CreateDialogIndirectParamW(g_hinst, pTemplate, NULL, (DLGPROC)focusDlgWinProc,0);
+ ok (hDlg != 0, "Failed to create test dialog.\n");
+
+ ok ((g_hwndInitialFocusT1 == 0),
+ "Focus should not be set for an invisible DS_CONTROL dialog %p.\n", g_hwndInitialFocusT1);
+
+ DestroyWindow(hDlg);
+ }
}
Index: dlls/user/tests/resource.rc
===================================================================
RCS file: /home/wine/wine/dlls/user/tests/resource.rc,v
retrieving revision 1.6
diff -u -p -r1.6 resource.rc
--- dlls/user/tests/resource.rc 5 Oct 2004 23:45:35 -0000 1.6
+++ dlls/user/tests/resource.rc 15 Dec 2004 21:26:41 -0000
@@ -67,3 +67,11 @@ CLASS "TestDialog"
FONT 8, "System"
{
}
+
+FOCUS_TEST_DIALOG DIALOG DISCARDABLE 0, 0, 60, 30
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU | DS_CONTROL
+CAPTION "Test dialog"
+FONT 8, "MS Shell Dlg"
+{
+ EDITTEXT 200,4,4,50,14
+}
Index: windows/dialog.c
===================================================================
RCS file: /home/wine/wine/windows/dialog.c,v
retrieving revision 1.139
diff -u -p -r1.139 dialog.c
--- windows/dialog.c 8 Dec 2004 18:06:14 -0000 1.139
+++ windows/dialog.c 15 Dec 2004 21:26:43 -0000
@@ -664,7 +664,8 @@ static HWND DIALOG_CreateIndirect( HINST
{
/* Send initialisation messages and set focus */
- if (SendMessageW( hwnd, WM_INITDIALOG, (WPARAM)dlgInfo->hwndFocus, param ))
+ if (SendMessageW( hwnd, WM_INITDIALOG, (WPARAM)dlgInfo->hwndFocus, param ) &&
+ ((~template.style & DS_CONTROL) || (template.style & WS_VISIBLE)))
{
/* By returning TRUE, app has requested a default focus assignment */
dlgInfo->hwndFocus = GetNextDlgTabItem( hwnd, 0, FALSE);
More information about the wine-patches
mailing list