After the creation of a dialog if the focus is set on a PushButton this
one must have also the BS_DEFPUSHBUTTON style like in windows.
Attached the patch with a regression test.
--
Katia Maculan
Developer
ISIS Papyrus Italy Srl
Tel: (+39) 0125 6455400 Fax: (+39) 0125 6455400
E-mail: katia.maculan@isis-papyrus.com
Info: info@isis-papyrus.com
Hotline: +43-2236-27551-111
Visit our Website:
http://www.isis-papyrus.com
diff -urN oldwinedir/dlls/user/tests/dialog.c newwinedir/dlls/user/tests/dialog.c
--- oldwinedir/dlls/user/tests/dialog.c 2005-03-07 12:12:40.000000000 +0100
+++ newwinedir/dlls/user/tests/dialog.c 2005-03-14 16:33:03.000000000 +0100
@@ -849,6 +849,40 @@
}
}
+static LRESULT CALLBACK DlgFocusProc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ HWND hwndFocusCtrl = NULL;
+ HWND hwndDefPushButton = NULL;
+ LRESULT DlgCode;
+ LRESULT CtrlState;
+ switch (message)
+ {
+ case WM_INITDIALOG:
+ PostMessage(hDlg, WM_USER, 0, 0);
+ return TRUE;
+
+ case WM_USER:
+ // Check if the focus is on IDOK button
+ CtrlState = SendMessage (GetDlgItem(hDlg, IDOK), BM_GETSTATE, 0, 0);
+ if (CtrlState == BST_FOCUS)
+ hwndFocusCtrl = GetDlgItem(hDlg, IDOK);
+ // Check if IDOK is the default push button
+ DlgCode = SendMessage (GetDlgItem(hDlg, IDOK), WM_GETDLGCODE, 0, 0);
+ if (DlgCode & DLGC_DEFPUSHBUTTON)
+ hwndDefPushButton = GetDlgItem(hDlg, IDOK);
+ ok (hwndFocusCtrl && hwndDefPushButton, "The focus and the DLGC_DEFPUSHBUTTON style are not in the same button\n");
+ EndDialog(hDlg, LOWORD(wParam));
+ return TRUE;
+ }
+ return FALSE;
+
+}
+
+static void InitialFocusTest1 (void)
+{
+ DialogBox(g_hinst, "DEFPUSHBUTTON_TEST_DIALOG", NULL, (DLGPROC)DlgFocusProc);
+
+}
START_TEST(dialog)
{
@@ -860,4 +894,5 @@
IsDialogMessageWTest();
WM_NEXTDLGCTLTest();
InitialFocusTest();
+ InitialFocusTest1();
}
diff -urN oldwinedir/windows/dialog.c newwinedir/windows/dialog.c
--- oldwinedir/windows/dialog.c 2005-03-07 12:12:54.000000000 +0100
+++ newwinedir/windows/dialog.c 2005-03-14 16:30:19.000000000 +0100
@@ -669,8 +669,23 @@
{
/* By returning TRUE, app has requested a default focus assignment */
dlgInfo->hwndFocus = GetNextDlgTabItem( hwnd, 0, FALSE);
- if( dlgInfo->hwndFocus )
- SetFocus( dlgInfo->hwndFocus );
+ if (dlgInfo->hwndFocus)
+ {
+ SetFocus( dlgInfo->hwndFocus );
+ HWND hWndOldDefPushButton = NULL;
+ if (SendMessageW(dlgInfo->hwndFocus, WM_GETDLGCODE, 0, 0)
+ & (DLGC_UNDEFPUSHBUTTON | DLGC_BUTTON))
+ {
+ SendMessageA (dlgInfo->hwndFocus, BM_SETSTYLE, BS_DEFPUSHBUTTON, TRUE);
+ /*Check for a previous defpushbutton*/
+ if (dlgInfo->idResult)
+ {
+ hWndOldDefPushButton = GetDlgItem (hwnd,dlgInfo->idResult);
+ if (hWndOldDefPushButton && (hWndOldDefPushButton != dlgInfo->hwndFocus))
+ SendMessageA (hWndOldDefPushButton, BM_SETSTYLE, BS_PUSHBUTTON, TRUE);
+ }
+ }
+ }
}
if (template.style & WS_VISIBLE && !(GetWindowLongW( hwnd, GWL_STYLE ) & WS_VISIBLE))