Click here to Skip to main content
15,891,749 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Everyone I'm newbie to programming please help me with my little problem.
I make my splash screen show on .ShowDialog method
so my problem is every time I access my first form(login) Splash Screen always shows.
How to make my Splashscreen Show only once

this is my code (login-form)
C#
public Login()
        {
            InitializeComponent();

            new SplashWindow().ShowDialog();
            //this is where Splash shows

        }


i know this is wrong but i try this
C#
public Login()
       {
           InitializeComponent();
           bool first = false;
           if (first == true)
           {

           }
           else
           {
             new SplashWindow().ShowDialog();
             first = true;
           }
       }



this is how i change forms
C#
Proj.MainWindow ma = new Proj.MainWindow();
                   App.Current.MainWindow = ma;
                   this.Hide();
                   ma.Show();
                   this.Close();
Posted

1 solution

Use the debugger; and you will see what's going on. From your description, it looks like your method Login is called more than once. The issue here is: you don't show in your code what do you do per instance and what per class. Say, it's not shown if first is static or not. Certainly, calling the method with the call to InitializeComponent on the same instance more than once is the apparent bug, and calling it on the same class is the bad code design style, in most cases.

By the way, please see my article on related topic: Wish You Were Here… Only Once[^].

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900