user32: Only store dialog focus when window is hidden or inactive.

This commit is contained in:
Piotr Caban 2014-12-22 16:36:48 +01:00 committed by Alexandre Julliard
parent 02f9edfd77
commit 91eced0ce5
2 changed files with 19 additions and 3 deletions

View File

@ -105,9 +105,7 @@ static void DEFDLG_RestoreFocus( HWND hwnd, BOOL justActivate )
SetFocus( infoPtr->hwndFocus );
else
DEFDLG_SetFocus( infoPtr->hwndFocus );
/* This used to set infoPtr->hwndFocus to NULL for no apparent reason,
sometimes losing focus when receiving WM_SETFOCUS messages. */
infoPtr->hwndFocus = NULL;
}

View File

@ -1357,6 +1357,24 @@ static void test_SaveRestoreFocus(void)
foundId = GetWindowLongPtrA(GetFocus(), GWLP_ID);
ok (foundId == 1001, "Second edit box should have gained focus after dialog reactivation. Expected: %d, Found: %ld\n", 1001, foundId);
/* set focus to the dialog */
SetFocus(hDlg);
foundId = GetWindowLongPtrA(GetFocus(), GWLP_ID);
ok (foundId == 1000, "First edit box should have gained focus on dialog focus. Expected: %d, Found: %ld\n", 1000, foundId);
/* select second tabbable item */
SetFocus(GetNextDlgTabItem(hDlg, GetNextDlgTabItem(hDlg, NULL, FALSE), FALSE));
foundId = GetWindowLongPtrA(GetFocus(), GWLP_ID);
ok (foundId == 1001, "Second edit box should have gained focus. Expected: %d, Found: %ld\n", 1001, foundId);
/* send WM_ACTIVATE message to already active dialog */
SendMessageA(hDlg, WM_ACTIVATE, MAKEWPARAM(WA_ACTIVE, 0), 0);
foundId = GetWindowLongPtrA(GetFocus(), GWLP_ID);
ok (foundId == 1001, "Second edit box should have gained focus. Expected: %d, Found: %ld\n", 1001, foundId);
/* disable the 2nd box */
EnableWindow(GetFocus(), FALSE);