I created a very basic splash screen for a WinForm application.
The application has to connect to a database on loading, so I created a OnLoad method like this one:
private void MainForm_OnLoad(object sender, EventArgs e)
{
SplashScreen.ShowSplashScreen();
PerformConnection();
SplashScreen.CloseSplashScreen();
}
The splash screen is a simple form. The ShowSplashScreen method creates the form and shows it up, the CloseSplashScreen closes the form.
Everything seems to work, except that when the splash screen closes, the main form loses the focus and is hidden by the previously selected window.
I do not understand why, nor I know how to solve this problem.