From baa1bbafdf1055cc46213c5eb4d524231d2167c4 Mon Sep 17 00:00:00 2001 From: ed Date: Thu, 2 Sep 2021 10:27:18 +0100 Subject: [PATCH] Windows: Fall back to old-style modal dialog when showing native message box modally since TaskDialog does not support fully modal dialogs --- .../native/juce_win32_Windowing.cpp | 40 +++++++++---------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/modules/juce_gui_basics/native/juce_win32_Windowing.cpp b/modules/juce_gui_basics/native/juce_win32_Windowing.cpp index f90fd8476f..14b47eefa0 100644 --- a/modules/juce_gui_basics/native/juce_win32_Windowing.cpp +++ b/modules/juce_gui_basics/native/juce_win32_Windowing.cpp @@ -4621,33 +4621,31 @@ private: static std::unique_ptr createMessageBox (const MessageBoxOptions& options, std::unique_ptr callback) { - std::unique_ptr messageBox; + const auto useTaskDialog = + #if JUCE_MODAL_LOOPS_PERMITTED + callback != nullptr && + #endif + SystemStats::getOperatingSystemType() >= SystemStats::WinVista + && WindowsTaskDialog::loadTaskDialog(); - if (SystemStats::getOperatingSystemType() >= SystemStats::WinVista - && WindowsTaskDialog::loadTaskDialog()) + if (useTaskDialog) + return std::make_unique (options, std::move (callback)); + + const auto extraFlags = [&options] { - messageBox.reset (new WindowsTaskDialog (options, std::move (callback))); - } - else - { - const auto extraFlags = [&options] - { - const auto numButtons = options.getNumButtons(); + const auto numButtons = options.getNumButtons(); - if (numButtons == 3) - return MB_YESNOCANCEL; + if (numButtons == 3) + return MB_YESNOCANCEL; - if (numButtons == 2) - return options.getButtonText (0) == "OK" ? MB_OKCANCEL - : MB_YESNO; + if (numButtons == 2) + return options.getButtonText (0) == "OK" ? MB_OKCANCEL + : MB_YESNO; - return MB_OK; - }(); + return MB_OK; + }(); - messageBox.reset (new PreVistaMessageBox (options, (UINT) extraFlags, std::move (callback))); - } - - return messageBox; + return std::make_unique (options, (UINT) extraFlags, std::move (callback)); } static int showDialog (const MessageBoxOptions& options,