If a dialog with the DS_CONTROL style is not visible then ignore
authorUlrich Czekalla <ulrich@codeweavers.com>
Tue, 21 Dec 2004 16:01:50 +0000 (16:01 +0000)
committerAlexandre Julliard <julliard@winehq.org>
Tue, 21 Dec 2004 16:01:50 +0000 (16:01 +0000)
default focus assignment.

dlls/user/tests/dialog.c
dlls/user/tests/resource.rc
windows/dialog.c

index 4fd8e60a464672284e45cadf8bf9ee95aaa0a96e..37a72dca13d51383cbcdd044dd2cdbda137eefeb 100644 (file)
@@ -716,6 +716,31 @@ static LRESULT CALLBACK delayFocusDlgWinProc (HWND hDlg, UINT uiMsg, WPARAM wPar
     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 e75fa8d09f37d4287793307e9561f378735f6a58..eed5a6544df572341dadbb6c928f8e1c523b0be5 100644 (file)
@@ -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 be2ed628aac0b9b5e32b641fb2c3b78a51d3971a..519ec288ee6c1820f644d1f9df8e325a119c9d6d 100644 (file)
@@ -664,7 +664,8 @@ static HWND DIALOG_CreateIndirect( HINSTANCE hInst, LPCVOID dlgTemplate,
     {
         /* 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);