The effect of window fading is mainly to enhance the user experience of the software. Currently, winformProgramThis function is automatically available on Vista/win7, so it is only available in earlier versions such as XP.
Let's talk about the specific implementation :-)
1. Use the timer control to control the transparency of the form (opacity ).
/// <Summary>
/// Display form
/// </Summary>
Private Void Showwin ()
{
This . Tsmishowhide. Text = " Hide " ;
This . Setwindowstate ();
This . Opacity = 0 ;
// Window fade-in effect
Timer tstart = New Timer ();
Tstart. Interval = 100 ;
Tstart. tick + = New Eventhandler (tstart_tick );
Tstart. Start ();
}
/// <Summary>
/// Hide form
/// </Summary>
Private Void Hidewin ()
{
This . Tsmishowhide. Text = " Display " ;
// Close the window fade-out effect
Timer tclose = New Timer ();
Tclose. Interval = 100 ;
Tclose. tick + = New Eventhandler (tclose_tick );
Tclose. Start ();
}
/// <Summary>
/// Disable form fade-in
/// </Summary>
/// <Param name = "sender"> </param>
/// <Param name = "E"> </param>
Void Tclose_tick ( Object Sender, eventargs E)
{
// Transparency reduced by 10% per execution
This . Opacity -= 0.1 ;
If ( This . Opacity <= 0 )
{
(Timer) sender). Stop ();
}
}
/// <Summary>
/// Enable the form fade-in effect
/// </Summary>
/// <Param name = "sender"> </param>
/// <Param name = "E"> </param>
Void Tstart_tick ( Object Sender, eventargs E)
{
// The transparency of each execution increases by 10%
This . Opacity + = 0.1 ;
If ( This . Opacity = 1 )
{
(Timer) sender). Stop ();
This . Focus ();
}
}
The fading effect is also called a test tool on eyesbaby.
Summary
Now, the implementation of the eyesbaby function is written here. I wrote a part above, but the technical content is not much. As evidenced by my technical skills, most of my writing can only be a self-recorded method, and it cannot be used as an example! There are many places to learn, and some bloggers have made a lot of good suggestions. For example, the automatic update part. Thank you!
In the future, I hope to develop more personal software that will help us in our work and life (I believe in "technology changes our lives"). I also hope you can provide more suggestions and technical help!
Source code: Http://eyesbaby.codeplex.com/
Installation: http://files.cnblogs.com/yizhuqing/EyesBabySetup10.zip
My first utility-eye protection program (eyesbaby)
Eyesbaby1.0 help documentation
Implementation of the eyesbaby function: Window dragging and Scaling
Add characters to the image control using the eyesbaby Function
Eyesbaby function implementation-Windows foreground color Regulator
Software Update for eyesbaby function implementation
Implementation of the eyesbaby function: Window fading effect
Welcome to the eyesbaby Development Team
Eyesbaby demand feedback team