5,548,129 members and growing! (17,856 online)
Email Password   helpLost your password?
Languages » C# » Windows Forms     Intermediate

Cute Splash Windows and About Boxes using .NET

By Sriram Chitturi

Building good looking Splash Windows on application startup and About boxes with special effects
C#Windows, .NET, .NET 1.0, .NET 1.1, Win2K, WinXPVS.NET2003, Visual Studio, Dev

Posted: 11 Dec 2003
Updated: 11 Dec 2003
Views: 41,849
Bookmarked: 20 times
Announcements
Want a new Job?



Search    
Advanced Search
Sitemap
16 votes for this Article.
Popularity: 3.25 Rating: 2.70 out of 5
7 votes, 43.8%
1
2 votes, 12.5%
2
3 votes, 18.8%
3
1 vote, 6.3%
4
3 votes, 18.8%
5

Introduction

Every well designed commercial windows application needs a good splash window to display the name of the application, company details, copy right notice and other contact information. The same window can be displayed as an About box.

Details

The images below show the CuteSplash example in action. The main window in the example is only a dummy window with no functionality and is used only to show how the Splash Window works.


Sample screenshot


Sample screenshot

Opacity and TransparencyKey properties of a Form are used to build the SplashWindow class. When building the form it is important that the background of the image or the Form should be set to the color used to set the TransparencyKey to make parts of form invisible ! Also set the FormBorderStyle property to None.

A thread is kicked off on Load event of SplashWindow to make this class independent and reusable. A Close button is added to the form to kill the window. The Click event on the button will just flag the thread to exit. Instead of suspending the thread it is flagged to exit to get the fading effect.

Here is the relevant code.

    void DrawSplashWindow()
    {
        mrEvent = new ManualResetEvent(false);
        mrEvent.WaitOne(4000, true);
        //fader loop

        for (double i=100.0; i>=0.0; i-=5.0) // run opacity index

        {
            Opacity = i/100.0;// decrease opacity

            Thread.Sleep(50);
        }
        Close();
    }

When the Close button is pressed the ManualResetEvent is Set to signal the Event and come out of the block on mrEvent.WaitOne() in the DrawSplashWindow() method.

    private void OnClose(object sender, System.EventArgs e)
    {
        // make the close button invisible

        CloseBtn.Visible = false;
        // flag the DrawSplashWindow thread to exit

        mrEvent.Set();
    }

Limitation

Opacity property is available only on Windows 2000 and Windows XP !

Extending the code

There are many ways the example given in this article can be used to enhance the splash window.
  • The text can be drawn using the Graphics.DrawString() method. Calculating the location and drawing one character at a time is a good idea (it brings life to the window).
  • To add details like registration and contact information at runtime add static and edit box controls rather than drawing them.
  • Since the SplashWindow class is a stand alone reusable class the display string, duration of display and fading effect can all be parameterized to build a generic class.
    I leave the rest to the imagination of the reader :-)

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Sriram Chitturi



Occupation: Web Developer
Location: United States United States

Other popular C# articles:

Article Top
Sign Up to vote for this article
You must Sign In to use this message board.
FAQ FAQ Noise ToleranceSearch Search Messages 
 Layout  Per page   
 Msgs 1 to 8 of 8 (Total in Forum: 8) (Refresh)FirstPrevNext
Subject  Author Date 
GeneralNever Update the UI Directly from a Worker Threadmembertupacs0120:34 24 Sep '04  
GeneralUnusual codememberThePhoenix9:56 14 Dec '03  
GeneralRe: Unusual codememberSriram Chitturi10:53 14 Dec '03  
GeneralQuick improvementmemberdog_spawn14:14 12 Dec '03  
GeneralRe: Quick improvementmemberSriram Chitturi4:30 13 Dec '03  
GeneralYes.memberShog99:23 14 Dec '03  
GeneralRe: Yes.memberSriram Chitturi10:37 14 Dec '03  
GeneralRe: Quick improvementmemberSimon Brown23:08 14 Dec '03  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 11 Dec 2003
Editor: Nishant Sivakumar
Copyright 2003 by Sriram Chitturi
Everything else Copyright © CodeProject, 1999-2008
Web08 | Advertise on the Code Project