موضوع :
سي شارپ
بازديد :
922 
Introduction
Today you will learn create a simple splash screen for your application. In order to follow this tutorial, you will need to have Visual Studio .NET and .NET Framework installed on your computer.
Getting to work
Let's start by creating a new C# Windows Application ( File -> New -> Project -> Visual C# Projects -> Windows Application ). Name the project SplashScreen.
Let's leave the current form the way it is and add to our project another form. To do this, go to Project menu and click Add Windows Form. Name the class Splash.cs and click OK.
Visual Studio .NET has created another form for you. Let's work a little on our new form. Let's set it's FormBorderStyle to None its StartPosition to CenterScreen. In the attached archive, I've created a simple image witch we will set as the BackgoundImage for our current form. Resize the form until it displays the full image. Now set the TransparencyKey property of our form to the background color of our image. As you can see, the color is Black. Also, it would be nice that this form would not be displayed in the taskbar. So set the ShowInTaskbar property to false.
Now go back to Form1 class, created by default by Visual Studio .NET. We must add some code in this class to show the Splash form before initializing Form1.
Let's go to Form1() method. That method is the constructor of the class and it executes before any other method. Let's add here the following code, right bellow the call to InitializeComponent method:
Thread th = new Thread(new ThreadStart(DoSplash));
th.Start();
Thread.Sleep(3000);
th.Abort();
Thread.Sleep(1000); |
تاريخ : شنبه 9 آذر 1387
ساعت : 10:41:46 PM
نويسنده :
مهرداد قاسمي
|
نظرات