Principle: run the welcome page before the main form pops up. After the main form is run, close the welcome page and open the main form.
Create a new project, add a Windows form to the original project, and name the form formwelcome as a welcome interface.
◆ Of course, if you welcome the interface, you will have to see the highlights. The basic settings are as follows:
Showintaskbar-> true (the window is not displayed in the taskbar)
Startposition-> centerscreen (display the window in the middle of the screen during running)
Formborderstyle-> none (remove the border and title bar of the form to make it look like a welcome Interface)
Backgroundimage-> (this can be done by yourself to make a good picture or find a pair, preferably the same size as your welcome window)
Alternatively, you can set the background color in the window to write some text, and the size of the window will be yours.
◆CodeThe implementation is as follows:
You do not need to write the welcome interface, because it is only used to display
The main form formmain is in
Public Formmain ()
{
Initializecomponent ();
}
Add code:
Public Formmain ()
{
Formwelcome FW = New Formwelcome ();
FW. Show (); // Show out welcome window
System. Threading. thread. Sleep ( 2000 ); // Welcome window stay 2 S
FW. Close (); // Close the welcome window and start running the Main Window
Initializecomponent ();
}
//
// The preceding is a simple method. The following describes the implementation of transparent to opaque forms.
// I wanted to implement this effect in the previous method, but I don't know why.
// Principle: Start the welcome page, hide it, and then call the main form.
//
The layout of the welcome form is the same as described in the previous method, mainly because the code is different.
>>> Modify application. Run (New formmain () in the program. CS file ());
Change it to application. Run (New formwelcome ());
>>> (Welcome interface code) set the opacity attribute of the welcome interface to 0%, pull the timer control on the welcome interface, and write the code in the tick event as follows:
Private Void Timereffectick ( Object Sender, eventargs E)
{
If ( This . Opacity < 1 )
{
// Transparency increase per unit of time
This . Opacity + = 0.05 ;
}
Else
{
This . Timer1.stop ();
This . Hide ();
Mf. Show ();
}
}
Public Partial Class Formwelcome: Form
{
Formmain FM = New Formmain ();
}
Add this. timer1.start () to the load event on the page ();
>>> Add the code application. Exit () to the formclosing event of the main form to ensure that the application is actually exited when formmain exits.Program
Source Code address: http://download.csdn.net/source/647632
PS: This articleArticleIt was originally written in csdn. Some people said that I did not write very professionally. Indeed, I am not very technical. I just wanted to give it for your reference. After all, new users still needed it.