imported newer version of DIALOG_DoDialogBox and DEFDLG_RestoreFocus from Wine

svn path=/trunk/; revision=19834
This commit is contained in:
Sebastian Gasiorek 2005-12-02 22:50:23 +00:00
parent f8d5ea2d87
commit e7fc72f796

View file

@ -502,23 +502,30 @@ INT DIALOG_DoDialogBox( HWND hwnd, HWND owner )
MSG msg; MSG msg;
INT retval; INT retval;
HWND ownerMsg = GetAncestor( owner, GA_ROOT ); HWND ownerMsg = GetAncestor( owner, GA_ROOT );
BOOL bFirstEmpty;
if (!(dlgInfo = GETDLGINFO(hwnd))) return -1; if (!(dlgInfo = GETDLGINFO(hwnd))) return -1;
bFirstEmpty = TRUE;
if (!(dlgInfo->flags & DF_END)) /* was EndDialog called in WM_INITDIALOG ? */ if (!(dlgInfo->flags & DF_END)) /* was EndDialog called in WM_INITDIALOG ? */
{ {
ShowWindow( hwnd, SW_SHOW );
for (;;) for (;;)
{ {
if (!(GetWindowLongW( hwnd, GWL_STYLE ) & DS_NOIDLEMSG)) if (!PeekMessageW( &msg, 0, 0, 0, PM_REMOVE ))
{ {
if (!PeekMessageW( &msg, 0, 0, 0, PM_REMOVE )) if (bFirstEmpty)
{ {
/* ShowWindow the first time the queue goes empty */
ShowWindow( hwnd, SW_SHOWNORMAL );
bFirstEmpty = FALSE;
}
if (!(GetWindowLongW( hwnd, GWL_STYLE ) & DS_NOIDLEMSG))
{
/* No message present -> send ENTERIDLE and wait */ /* No message present -> send ENTERIDLE and wait */
SendMessageW( ownerMsg, WM_ENTERIDLE, MSGF_DIALOGBOX, (LPARAM)hwnd ); SendMessageW( ownerMsg, WM_ENTERIDLE, MSGF_DIALOGBOX, (LPARAM)hwnd );
if (!GetMessageW( &msg, 0, 0, 0 )) break;
} }
if (!GetMessageW( &msg, 0, 0, 0 )) break;
} }
else if (!GetMessageW( &msg, 0, 0, 0 )) break;
if (!IsWindow( hwnd )) return -1; if (!IsWindow( hwnd )) return -1;
if (!(dlgInfo->flags & DF_END) && !IsDialogMessageW( hwnd, &msg)) if (!(dlgInfo->flags & DF_END) && !IsDialogMessageW( hwnd, &msg))
@ -889,13 +896,16 @@ static void DEFDLG_RestoreFocus( HWND hwnd )
if (IsIconic( hwnd )) return; if (IsIconic( hwnd )) return;
if (!(infoPtr = GETDLGINFO(hwnd))) return; if (!(infoPtr = GETDLGINFO(hwnd))) return;
if (!IsWindow( infoPtr->hwndFocus )) return;
/* Don't set the focus back to controls if EndDialog is already called.*/ /* Don't set the focus back to controls if EndDialog is already called.*/
if (!(infoPtr->flags & DF_END)) if (infoPtr->flags & DF_END) return;
{ if (!IsWindow(infoPtr->hwndFocus) || infoPtr->hwndFocus == hwnd) {
DEFDLG_SetFocus( hwnd, infoPtr->hwndFocus ); /* If no saved focus control exists, set focus to the first visible,
return; non-disabled, WS_TABSTOP control in the dialog */
infoPtr->hwndFocus = GetNextDlgTabItem( hwnd, 0, FALSE );
if (!IsWindow( infoPtr->hwndFocus )) return;
} }
DEFDLG_SetFocus( hwnd, infoPtr->hwndFocus );
/* This used to set infoPtr->hwndFocus to NULL for no apparent reason, /* This used to set infoPtr->hwndFocus to NULL for no apparent reason,
sometimes losing focus when receiving WM_SETFOCUS messages. */ sometimes losing focus when receiving WM_SETFOCUS messages. */
} }