C # fade-in and fade-out of software forms

Source: Internet
Author: User

Private void Form1_Load (object sender, System. EventArgs e)
For (double d = 0.01; d <1; d + = 0.02)
{
System. Threading. Thread. Sleep (1 );
Application. DoEvents ();
This. Opacity = d;
This. Refresh ();
}
 
2.www.2cto.com
Private void timerjavastick (object sender, System. EventArgs e)
{
This. Opacity = WinShow;
WinShow ++ = 0.1;
If (WinShow> = 1)
{
Timer1.Dispose ();
}
}
3.
Use a loop or timer,
 
FrmForm myForm = new frmForm ()
FrmForm. Opacity = 0;
FrmForm. show ();
For (int I = 0; I <100; I ++)
{
Application. DoEvents ()
FrmForm. Opacity = I/100;
}
 
4.
 
# Region ******** form fade-in effect function ********
Private double WinShow = 0; // variable used for window fade-in effect
Private void FormShow (System. Windows. Forms. Form Curfrm)
{
Curfrm. Opacity = WinShow;
WinShow ++ = 0.01;
If (WinShow = 1)
{
Curfrm. timerShow. Stop ();
}
}
 
# Endregion
# Region ******** example of function calling for form fade-in effect ********
// Implement the fade-in effect of the window
Private void timerShow_Tick (object sender, System. EventArgs e)
{
// TimerShow, which is the name of the timer control. Set timerShow. interval to 100.
FormShow (this );
}
# Endregion
 
5.
 
Using System. Runtime. InteropServices;
 
Public class Win32
{
Public const Int32 AW_HOR_POSITIVE = 0x00000001; // open the window from left to right
Public const Int32 AW_HOR_NEGATIVE = 0x00000002; // open the window from right to left
Public const Int32 AW_VER_POSITIVE = 0x00000004; // open the window from top to bottom
Public const Int32 AW_VER_NEGATIVE = 0x00000008; // open the window from bottom to top
Public const Int32 AW_CENTER = 0x00000010;
Public const Int32 AW_HIDE = 0x00010000; // This constant must be added if you want to use this function when uninstalling the form.
Public const Int32 AW_ACTIVATE = 0x00020000; // After the form is opened through this function, the focus will be lost by default, unless this constant is added
Public const Int32 AW_SLIDE = 0x00040000;
Public const Int32 AW_BLEND = 0x00080000; // fade-in and fade-out effect
[DllImport ("user32.dll", CharSet = CharSet. Auto)]
Public static extern bool AnimateWindow (
IntPtr hwnd, // handle to window
Int dwTime, // duration of animation
Int dwFlags // animation type
);
}
 
 
/* Fade-in form */
 
Private void Form_Load (object sender, EventArgs e)
{
Win32.AnimateWindow (this. Handle, 2000, Win32.AW _ BLEND );
}
 
/* Fade out form */
 
 
Private void Form_FormClosing (object sender, FormClosingEventArgs e)
{
Win32.AnimateWindow (this. Handle, 2000, Win32.AW _ SLIDE | Win32.AW _ HIDE | Win32.AW _ BLEND );
}

From http://www.xssxss.com/fuck/798.xss

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.