On application startUp focus problem for dialogWindow

Hello All,

In main.cpp
for initialize function I wrote following lines to get dialog window before document window

void initialise (const juce::String & commandLine) { String user; welcomeDialog = new WelcomeDialog(user); welcomeDialog->runModalLoop(); welcomeDialog->setFullScreen(false); deleteAndZero(welcomeDialog); if(user.isNotEmpty()) mainWindow = new MainWindow (); }
I wonder why focus is not gained by my dialogWindow that show’s welcomDialog ?
I also tried
welcomeDialog->setAlwaysOnTop(true); welcomeDialog->setFocusContainer(true); welcomeDialog->setWantsKeyboardFocus(true);

But that also didn’t bring focus to this dialog ? What might be causing problem gettting focus over this ?
Please suggest what shall be the solution here ?

Thank you all.

You shouldn’t really use modal loops at all, but especially not before your app has even finished initialising. Just create your dialog non-modally, and then get it to create your main window when it gets closed.

Hey Jules thanx for your reply, But don’t get you exactly …

creating dialog non-modally means? shall I use DialogWindow::showDialog() ? Or not just call runModelLoop for welcomeDialog ?
Actually I already tried using DialogWindow::showDialog(), but that is behaving something different.

I mean don’t call runModal - use enterModalState instead.

Using modal loops that block the current thread is highly frowned-upon in modern programming (and even illegal on some platforms like android). It’s best to get into the habit of avoiding that style of coding.