modal dialog: Wait until message queue runs dry before calling ShowWindow()
Zach Gorman
zach at archetypeauction.com
Thu Sep 9 11:58:14 CDT 2004
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.
My tests show that Windows behaves this way.
Index: dialog.c
===================================================================
RCS file: /home/wine/wine/windows/dialog.c,v
retrieving revision 1.132
diff -u -r1.132 dialog.c
--- dialog.c 24 Aug 2004 02:26:40 -0000 1.132
+++ dialog.c 5 Sep 2004 02:00:38 -0000
@@ -765,24 +765,30 @@
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))
More information about the wine-patches
mailing list