showModalDialog error

Hello to all.
To set up audio, I use the code:

void AudioPlayer::settingButtonClicked()
{
    std::cout<<"settingButton"<<std::endl;
    bool showMIDIInputOptions = false;
    bool showMIDIOutputOption = false;
    bool showChannelAsSterepPairs = true;
    bool hideAdvancedOptions = false;
    
    AudioDeviceSelectorComponent settings(deviceManager,
                                          0, 0,//AudioInputChannels: min/Max
                                          1, 2,//AudioOutputChannels: min/Max
                                          showMIDIInputOptions,
                                          showMIDIOutputOption,
                                          showChannelAsSterepPairs,
                                          hideAdvancedOptions);
    settings.setSize(500, 400);
    DialogWindow::showModalDialog(String("Audio Settings"),
                                  &settings,
                                  TopLevelWindow::getTopLevelWindow(0),
                                  Colours::blue,
                                  true,
                                  false,
                                  true);
}

In Juce 6.0.8 on Mac OS it works, but Juce 6.1.4 gives an error on Windows 10. Please tell me how you can call a modal window on Windows.
Thanks in advance to everyone who responded.

In JUCE 6.1, modal loops were disabled by default. You should prefer to use DialogWindow::showDialog or DialogWindow::LaunchOptions::launchAsync to display the window.

You can also add JUCE_MODAL_LOOPS_PERMITTED=1 to carry on using showModalDialog to your preprocessor definitions in the Projucer, but I’d strongly recommend against this course of action, as the modal functions are unsafe in plugins.

I tried to use but the window opens blank. Unfortunately, I’m not good at C ++ yet, I’m in the learning stage. What else needs to be done to open the setup?

Your settings component needs to outlive the dialog window, but at the moment the settings component will be destroyed at the end of the settingButtonClicked function. One way of allowing the component to outlive the function would be to make the AudioDeviceSelectorComponent a class member, instead of making it a local variable inside the function.

Many thanks. I’ll try. Is there a way to move it into a separate function and call it with another function with DialogWindow::showDialog?

Thanks again to reuk.
As it turned out, the task was not difficult even for me, despite the fact that for the last 40 years I have been playing the saxophone and have not done anything else. Just in case, if there is a possibility and desire, look at the code. Hope I did everything right?

void AudioPlayer::settingButtonClicked()
{
    bool showMIDIInputOptions = false;
    bool showMIDIOutputOption = false;
    bool showChannelAsSterepPairs = true;
    bool hideAdvancedOptions = false;
    
    DialogWindow::LaunchOptions options;
            options.dialogTitle = "Audio Settings";
            OptionalScopedPointer<Component> settings (std::make_unique<AudioDeviceSelectorComponent>
                                                    (deviceManager,
                                                    0, 0,//AudioInputChannels: min/Max
                                                    1, 2,//AudioOutputChannels: min/Max
                                                    showMIDIInputOptions,
                                                    showMIDIOutputOption,
                                                    showChannelAsSterepPairs,
                                                    hideAdvancedOptions));
            settings->setSize (450, 350);
            options.content = std::move (settings);
            options.componentToCentreAround = this;
            options.dialogBackgroundColour = Colour (0xff0136bf);
            //options.useNativeTitleBar = (false);
            options.resizable = (false);
            options.launchAsync();
}

And also, after compilation, Visual Studio writes: 0 errors, 176 warnings. Xcode is silent. Returns 0 when the player is closed. Should I pay attention to the warnings or can I ignore them?