windows: msgboxes should specify a parent HWND if possible (thanks, Ismael!).
authorRyan C. Gordon <icculus@icculus.org>
Sat, 27 May 2017 00:30:06 -0400
changeset 11036c5346d5c3c79
parent 11035 10552ae634ca
child 11037 5fde5f7e2912
windows: msgboxes should specify a parent HWND if possible (thanks, Ismael!).

This lets them be properly modal.

Fixes Bugzilla #3650.
src/video/windows/SDL_windowsmessagebox.c
     1.1 --- a/src/video/windows/SDL_windowsmessagebox.c	Fri May 26 22:45:52 2017 +0200
     1.2 +++ b/src/video/windows/SDL_windowsmessagebox.c	Sat May 27 00:30:06 2017 -0400
     1.3 @@ -354,6 +354,7 @@
     1.4      wchar_t* wmessage;
     1.5      TEXTMETRIC TM;
     1.6  
     1.7 +    HWND ParentWindow = NULL;
     1.8  
     1.9      const int ButtonWidth = 88;
    1.10      const int ButtonHeight = 26;
    1.11 @@ -469,8 +470,13 @@
    1.12          x += ButtonWidth + ButtonMargin;
    1.13      }
    1.14  
    1.15 -    /* FIXME: If we have a parent window, get the Instance and HWND for them */
    1.16 -    which = DialogBoxIndirect(NULL, (DLGTEMPLATE*)dialog->lpDialog, NULL, (DLGPROC)MessageBoxDialogProc);
    1.17 +    /* If we have a parent window, get the Instance and HWND for them
    1.18 +     * so that our little dialog gets exclusive focus at all times. */
    1.19 +    if (messageboxdata->window)
    1.20 +        ParentWindow = ((SDL_WindowData*)messageboxdata->window->driverdata)->hwnd;
    1.21 +
    1.22 +
    1.23 +    which = DialogBoxIndirect(NULL, (DLGTEMPLATE*)dialog->lpDialog, ParentWindow, (DLGPROC)MessageBoxDialogProc);
    1.24      *buttonid = buttons[which].buttonid;
    1.25  
    1.26      FreeDialogData(dialog);