In the excitement of VS 2005, I want Program I used AForm to display the startup screen. After a while, I used this AForm to hide and showdialog the next bform and closeaform method. I wonder if you have any good solutions.
Set the program cluster AForm to start: Static Void Main ()
{
Application. enablevisualstyles ();
Application. setcompatibletextrenderingdefault (False);
Application. Run (NewAForm ());
}
I define the following timer in AForm:
Define their attributes
Startwindowshowtime (display the length of AForm time)
Enabled = true
Interval = 5000 (100 = 1 second)
Hidewindowstart (starts to hide the AForm process)
Enabled = true
Interval = 4500
Hidewindowspeed (hide the gradient interval of AForm)
Enabled = false
Interval = 10
Showwindowstart (display the gradient interval of AForm)
Enabled = true
Interval = 10
OK. The tick of the timer is defined below.
In the Events file, you can enter the timer file directly or in the background. However, I think it is convenient to enter the file here, and the method declaration can be automatically generated. Be lazy.
Startwindowshowtime
TICK: showmainwindow
Hidewindowstart
TICK: hidewindow
Hidewindowspeed
TICK: hidewindowspeedstart
Showwindowstart
TICK: showwindow
Well, here I want to talk about how to implement the transparent effect, gradient effect, and fade-in and fade-out effect for Windows form. This is the opacity in the form attribute. I have verified that only more than 2000 of systems support this attribute.
Set the opacity of AForm to 0.Code
Public Partial Class AForm: Form
{
Public Form ()
{
Initializecomponent ();
}
Private Void Start_load ( Object Sender, eventargs E)
{
Startwindowshowtime. Start ();
Hidewindowstart. Start ();
}
Private Void Showmainwindow ( Object Sender, eventargs E)
{
Bform showmainwindows = New Bform ();
This . Hide ();
Startwindowshowtime. Stop ();
Hidewindowstart. Stop ();
Hidewindowspeed. Stop ();
Showmainwindows. showdialog ();
This . Close ();
}
Private Void Hidewindow ( Object Sender, eventargs E)
{
Hidewindowspeed. Start ();
}
Private Void Hidewindowspeedstart ( Object Sender, eventargs E)
{
This. Opacity= This. Opacity- 0.02;
}
Private Void Showwindow ( Object Sender, eventargs E)
{
If ( This . Opacity = 1 )
{
Showwindowstart. Stop ();
}
Else
{
This. Opacity= This. Opacity+ 0.02;
}
}
}
Okay. Now let's run it.
I originally set the opacity value to 0.1 every time, but I found that the fade-in and fade-out is not very smooth, so the value and interval are reduced. In this way, it looks much better. I feel good about myself.
If your program only needs to be transparent, you only need to Set opacity.
The combination of timer and opacity can be used for gradient and fade-in and fade-out.
Be careful and share with you. I hope to make friends with you.
Remember to contact me!
To be boldArticleSent to the home page! Fear!