Modal dialogs should not be shown via ShowWindow until the message

queue first runs empty. This allows all initialization to complete
before a default focus is assigned.
This commit is contained in:
Zach Gorman 2004-09-10 21:27:02 +00:00 committed by Alexandre Julliard
parent 85b06836a5
commit 5c8ceb497e
2 changed files with 16 additions and 10 deletions

View File

@ -761,13 +761,13 @@ static void InitialFocusTest (void)
ok (((g_styleInitialFocusT1 & WS_TABSTOP) == 0),
"Error in wrc - Detected WS_TABSTOP as default style for GROUPBOX\n");
todo_wine ok (((g_styleInitialFocusT2 & WS_VISIBLE) == 0),
ok (((g_styleInitialFocusT2 & WS_VISIBLE) == 0),
"Modal dialogs should not be shown until the message queue first goes empty\n");
todo_wine ok ((g_hwndInitialFocusT1 == NULL),
"Error in initial focus when WM_INITDIALOG returned FALSE: "
"Expected NULL focus, got %s (%p).\n",
GetHwndString(g_hwndInitialFocusT1), g_hwndInitialFocusT1);
ok ((g_hwndInitialFocusT1 == NULL),
"Error in initial focus when WM_INITDIALOG returned FALSE: "
"Expected NULL focus, got %s (%p).\n",
GetHwndString(g_hwndInitialFocusT1), g_hwndInitialFocusT1);
todo_wine ok ((g_hwndInitialFocusT2 == g_hwndButton2),
"Error after first SetFocus() when WM_INITDIALOG returned FALSE: "

View File

@ -765,24 +765,30 @@ INT DIALOG_DoDialogBox( HWND hwnd, HWND owner )
MSG msg;
INT retval;
HWND ownerMsg = GetAncestor( owner, GA_ROOT );
BOOL bFirstEmpty;
if (!(dlgInfo = DIALOG_get_info( hwnd, FALSE ))) return -1;
bFirstEmpty = TRUE;
if (!(dlgInfo->flags & DF_END)) /* was EndDialog called in WM_INITDIALOG ? */
{
ShowWindow( hwnd, SW_SHOW );
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 */
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 (!(dlgInfo->flags & DF_END) && !IsDialogMessageW( hwnd, &msg))