Commit 5c8ceb49 authored by Zach Gorman's avatar Zach Gorman Committed by Alexandre Julliard

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.
parent 85b06836
......@@ -761,10 +761,10 @@ 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),
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);
......
......@@ -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 (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))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment