![]() |
Languages »
C# »
Windows Forms
Intermediate
Cute Splash Windows and About Boxes using .NETBy Sriram ChitturiBuilding good looking Splash Windows on application startup and About boxes with special effects |
C#.NET 1.0, .NET 1.1, Win2K, WinXPVS.NET2003, Dev
|
|
Advanced Search Add to IE Search |
|
|
|
||||||||||||||||
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.
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.


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();
}
Graphics.DrawString() method. Calculating the location and drawing one character at a time is a good idea (it brings life to the window).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.| You must Sign In to use this message board. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||
General
News
Question
Answer
Joke
Rant
Admin
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 11 Dec 2003 Editor: Nishant Sivakumar |
Copyright 2003 by Sriram Chitturi Everything else Copyright © CodeProject, 1999-2009 Web16 | Advertise on the Code Project |