Search code examples
c#winformssplash-screen

Splash screen and main window


I have a little problem. I made small game(main window - dungeons) and splash screen. At first made main window, next added splash screen. When run my game at first show splash screen, next main window, but if splash screen close, the main window start, but it is minimalized (visible in taskbar only). How to do to after splash screen the main window visible? Below code main window. Thanks you for help.

public Dungeons()
{
    Thread thread = new Thread(new ThreadStart(SplashStart));
    thread.Start();
    Thread.Sleep(5000);

    InitializeComponent();

    this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint |
        ControlStyles.OptimizedDoubleBuffer, true);
    player30.Visible = true;
    CenterToScreen();
    thread.Abort();
}

public void SplashStart()
{
    Application.Run(new SplashScreen());
}

Solution

  • If you want to show splash screen while loading other controls on the Main form, you can use splash screen waiting . You can refer this link

    In my application I use Devexpress control SplashScreen Manager.

          private void FormMain_Load(object sender, EventArgs e)
            {
                sphManager.ShowWaitForm(); 
                //Place your code which you need to execute while Splash screen is active           
                GenerateNavigationView();          
                this.WindowState = FormWindowState.Maximized;
                //Once you finish all your requirement, close the Splash screen
                sphManager.CloseWaitForm();
            }