Protect against wrong return value from WM_INITDIALOG.
diff --git a/windows/dialog.c b/windows/dialog.c
index bcb0255..8a01df3 100644
--- a/windows/dialog.c
+++ b/windows/dialog.c
@@ -771,12 +771,22 @@
if (DIALOG_CreateControls( wndPtr, dlgTemplate, &template,
hInst, win32Template ))
{
- /* Send initialisation messages and set focus */
+ HWND hwndPreInitFocus;
+
+ /* Send initialisation messages and set focus */
dlgInfo->hwndFocus = GetNextDlgTabItem( hwnd, 0, FALSE );
+ hwndPreInitFocus = GetFocus();
if (SendMessageA( hwnd, WM_INITDIALOG, (WPARAM)dlgInfo->hwndFocus, param ))
SetFocus( dlgInfo->hwndFocus );
+ else
+ {
+ /* If the dlgproc has returned FALSE (indicating handling of keyboard focus)
+ but the focus has not changed, set the focus where we expect it. */
+ if ( GetFocus() == hwndPreInitFocus )
+ SetFocus( dlgInfo->hwndFocus );
+ }
if (template.style & WS_VISIBLE && !(wndPtr->dwStyle & WS_VISIBLE))
{