From 3fbd21ce40fbe399bec2e9b26c8a8d36d9197114 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Sat, 27 May 2017 00:30:06 -0400 Subject: [PATCH] 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 | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/video/windows/SDL_windowsmessagebox.c b/src/video/windows/SDL_windowsmessagebox.c index 547ade4ae..e60b2c27d 100644 --- a/src/video/windows/SDL_windowsmessagebox.c +++ b/src/video/windows/SDL_windowsmessagebox.c @@ -354,6 +354,7 @@ WIN_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) wchar_t* wmessage; TEXTMETRIC TM; + HWND ParentWindow = NULL; const int ButtonWidth = 88; const int ButtonHeight = 26; @@ -469,8 +470,13 @@ WIN_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) x += ButtonWidth + ButtonMargin; } - /* FIXME: If we have a parent window, get the Instance and HWND for them */ - which = DialogBoxIndirect(NULL, (DLGTEMPLATE*)dialog->lpDialog, NULL, (DLGPROC)MessageBoxDialogProc); + /* If we have a parent window, get the Instance and HWND for them + * so that our little dialog gets exclusive focus at all times. */ + if (messageboxdata->window) + ParentWindow = ((SDL_WindowData*)messageboxdata->window->driverdata)->hwnd; + + + which = DialogBoxIndirect(NULL, (DLGTEMPLATE*)dialog->lpDialog, ParentWindow, (DLGPROC)MessageBoxDialogProc); *buttonid = buttons[which].buttonid; FreeDialogData(dialog);