Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / December 2005

Tip: Looking for answers? Try searching our database.

Splash Screen

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Steve - 22 Dec 2005 02:13 GMT
Howdy folks,

How would one go about making a splash screen (message appearing while main
program loading) in c#

cheers in advanced

Steve
Steven Nagy - 22 Dec 2005 02:27 GMT
In your main form constructor, hide the main form.
Create your splash screen form instance and show it with Form.Show()
(not ShowDialog)
Continue with your initialisation code.
When your code is complete, close the splash screen with Form.Close()
and probably dispose it as well.
Show the main form again with this.Show()

You could also do it in the main static method. Show slash form,
initialise, show main form.

Thats the theory anyway!

Steven Nagy
gsb58@hotmail.com - 22 Dec 2005 06:47 GMT
Here's an example. The splash form is made transparent with a bee, so
when it loads, only the bee is visible. Then a timer, in frmSplash,
will close the form after 1375 ms. The bee will "fly" away to the upper
left corner and finally disappear.

However, is there a better way to animate the bee than my example?

The code in frmSplash:

private void timer1_Tick(object sender, System.EventArgs e)
        {
            this.Left = 400;
            this.Top = 300;
            this.Left = 375;
            this.Top = 275;
            this.Left = 350;
            this.Top = 225;
            this.Left = 300;
            this.Top = 200;
            this.Left = 250;
            this.Top = 150;
            this.Left = 200;
            this.Top = 100;
            this.Left = 100;
            this.Top = 75;
            this.Left = 50;
            this.Top = 10;
            this.Left = 0;
            this.Top = 0;
            Close();
        }

        private void frmSplash_Load(object sender, System.EventArgs e)
        {
            timer1.Enabled = true;
        }

And in frmMain:

[STAThread]
        static void Main()
        {
            ///start splash-form for application
            Application.Run(new frmSplash());

            ///start main-form   
            Application.Run(new frmMain());
        }

Me.Name
Ignacio Machin ( .NET/ C# MVP ) - 22 Dec 2005 14:31 GMT
Hi,

> [STAThread]
> static void Main()
[quoted text clipped - 5 lines]
> Application.Run(new frmMain());
> }

What happens if frmMain loads before the timeout? , how  does it close the
splash?

Signature

Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

Ignacio Machin ( .NET/ C# MVP ) - 22 Dec 2005 14:29 GMT
Hi,

If you google you will find several examples of a splash screen , this
question is posted here on a regular basis

Signature

Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

> Howdy folks,
>
[quoted text clipped - 4 lines]
>
> Steve

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.