From 15c58c42398e68c7830d5c488bfe0e02e3276222 Mon Sep 17 00:00:00 2001 From: Abey George Date: Sat, 7 Aug 1999 14:10:04 +0000 Subject: [PATCH] Set focus to the dialog in EndDialog. --- windows/defdlg.c | 6 +++++- windows/dialog.c | 10 ++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/windows/defdlg.c b/windows/defdlg.c index 05f234c7898..133dd095d45 100644 --- a/windows/defdlg.c +++ b/windows/defdlg.c @@ -53,7 +53,11 @@ static BOOL DEFDLG_RestoreFocus( HWND hwnd, DIALOGINFO *infoPtr ) { if (!infoPtr->hwndFocus || IsIconic(hwnd)) return FALSE; if (!IsWindow( infoPtr->hwndFocus )) return FALSE; - DEFDLG_SetFocus( hwnd, infoPtr->hwndFocus ); + + /* Don't set the focus back to controls if EndDialog is already called.*/ + if (!(infoPtr->flags & DF_END)) + DEFDLG_SetFocus( hwnd, infoPtr->hwndFocus ); + /* This used to set infoPtr->hwndFocus to NULL for no apparent reason, sometimes losing focus when receiving WM_SETFOCUS messages. */ return TRUE; diff --git a/windows/dialog.c b/windows/dialog.c index c5e4c79518e..a5d422e4644 100644 --- a/windows/dialog.c +++ b/windows/dialog.c @@ -1073,6 +1073,11 @@ BOOL WINAPI EndDialog( HWND hwnd, INT retval ) dlgInfo->flags |= DF_END; } + /* Windows sets the focus to the dialog itself first in EndDialog */ + + if (IsChild(hwnd, GetFocus())) + SetFocus(wndPtr->hwndSelf); + /* Paint Shop Pro 4.14 calls EndDialog for a CreateDialog* dialog, * which isn't "normal". Only DialogBox* dialogs may be EndDialog()ed. * Just hide the window @@ -1163,6 +1168,7 @@ static BOOL DIALOG_IsAccelerator( HWND hwnd, HWND hwndDlg, WPARAM vKey ) SendMessageA( hwndControl, WM_LBUTTONUP, 0, 0); } RetVal = TRUE; + WIN_ReleaseWndPtr(wndPtr); break; } } @@ -1182,6 +1188,10 @@ static BOOL DIALOG_IsAccelerator( HWND hwnd, HWND hwndDlg, WPARAM vKey ) hwndControl = GetParent( hwndControl ); if (hwndControl == hwndDlg) { + if(hwnd==hwndDlg){ /* prevent endless loop */ + hwndNext=hwnd; + break; + } hwndNext = GetWindow( hwndDlg, GW_CHILD ); } else