diff --git a/modules/juce_gui_basics/native/juce_NativeMessageBox_windows.cpp b/modules/juce_gui_basics/native/juce_NativeMessageBox_windows.cpp index 813a343bf8..9be087deb1 100644 --- a/modules/juce_gui_basics/native/juce_NativeMessageBox_windows.cpp +++ b/modules/juce_gui_basics/native/juce_NativeMessageBox_windows.cpp @@ -100,12 +100,15 @@ std::unique_ptr ScopedMessageBoxInterface::create (co return [this, parent] { + const auto title = options.getTitle(); + const auto message = options.getMessage(); + TASKDIALOGCONFIG config{}; config.cbSize = sizeof (config); config.hwndParent = parent; - config.pszWindowTitle = options.getTitle().toWideCharPointer(); - config.pszContent = options.getMessage().toWideCharPointer(); + config.pszWindowTitle = title.toWideCharPointer(); + config.pszContent = message.toWideCharPointer(); config.hInstance = (HINSTANCE) Process::getCurrentModuleInstanceHandle(); config.lpCallbackData = reinterpret_cast (this); config.pfCallback = [] (HWND hwnd, UINT msg, WPARAM, LPARAM, LONG_PTR lpRefData) @@ -154,11 +157,12 @@ std::unique_ptr ScopedMessageBoxInterface::create (co }(); } + std::vector buttonStrings; std::vector buttonLabels; for (auto i = 0; i < options.getNumButtons(); ++i) if (const auto buttonText = options.getButtonText (i); buttonText.isNotEmpty()) - buttonLabels.push_back ({ (int) buttonLabels.size(), buttonText.toWideCharPointer() }); + buttonLabels.push_back ({ (int) buttonLabels.size(), buttonStrings.emplace_back (buttonText).toWideCharPointer() }); config.pButtons = buttonLabels.data(); config.cButtons = (UINT) buttonLabels.size();