From 5c8ceb497e3226caf3a7c39771df9b52ab36d055 Mon Sep 17 00:00:00 2001 From: Zach Gorman Date: Fri, 10 Sep 2004 21:27:02 +0000 Subject: [PATCH] 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. --- dlls/user/tests/dialog.c | 10 +++++----- windows/dialog.c | 16 +++++++++++----- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/dlls/user/tests/dialog.c b/dlls/user/tests/dialog.c index 80a22f9963d..a8e197e8d1e 100644 --- a/dlls/user/tests/dialog.c +++ b/dlls/user/tests/dialog.c @@ -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: " diff --git a/windows/dialog.c b/windows/dialog.c index f5a3bf8b76e..de6cf4226cf 100644 --- a/windows/dialog.c +++ b/windows/dialog.c @@ -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)) -- 2.11.4.GIT