c#软件窗体的淡入淡出

来源:互联网 发布:麻雀网络更新时间 编辑:程序博客网 时间:2024/05/17 08:33
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 timer1_Tick(object sender, System.EventArgs e)
{
this.Opacity = WinShow ;
WinShow += 0.1 ;
if(WinShow >=1 )
{
timer1.Dispose ();
}
}
3.
用循环或计时器,
 
frmForm myForm=new frmForm()
frmForm.Opacity=0;
frmForm.show();
for(int i=0;i<100;i++)
{
Application.DoEvents()
frmForm.Opacity=i/100;
}
 
4.
 
#region ******** 窗体淡入效果函数********
private double WinShow = 0;//用于窗口淡入效果的变量
private void FormShow(System.Windows.Forms.Form Curfrm)
{
Curfrm.Opacity = WinShow ;
WinShow += 0.01;
if(WinShow == 1)
{
Curfrm.timerShow.Stop ();
}
}
 
#endregion
#region ******** 窗体淡入效果函数调用示例********
//实现窗口的淡入效果
private void timerShow_Tick(object sender, System.EventArgs e)
{
//timerShow,这是一个timer控件名称;把timerShow.interval=100就可以了。
FormShow(this);
}
#endregion
 
5.
 
using System.Runtime.InteropServices;
 
public class Win32
{
public const Int32 AW_HOR_POSITIVE = 0x00000001; // 从左到右打开窗口
public const Int32 AW_HOR_NEGATIVE = 0x00000002; // 从右到左打开窗口
public const Int32 AW_VER_POSITIVE = 0x00000004; // 从上到下打开窗口
public const Int32 AW_VER_NEGATIVE = 0x00000008; // 从下到上打开窗口
public const Int32 AW_CENTER = 0x00000010;
public const Int32 AW_HIDE = 0x00010000; // 在窗体卸载时若想使用本函数就得加上此常量
public const Int32 AW_ACTIVATE = 0x00020000; //在窗体通过本函数打开后,默认情况下会失去焦点,除非加上本常量
public const Int32 AW_SLIDE = 0x00040000;
public const Int32 AW_BLEND = 0x00080000; // 淡入淡出效果
[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
);
}
 
 
/*淡入窗体*/
 
private void Form_Load(object sender, EventArgs e)
{
Win32.AnimateWindow(this.Handle, 2000, Win32.AW_BLEND);
}
 
/*淡出窗体*/
 
 
private void Form_FormClosing(object sender, FormClosingEventArgs e)
{
Win32.AnimateWindow(this.Handle, 2000, Win32.AW_SLIDE | Win32.AW_HIDE | Win32.AW_BLEND);
}

原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 做的衣柜没有门怎么办 蒸馒头熟了会瘪怎么办 3dmax贴图太大了怎么办 嘴皮边缘颜色深怎么办 嘴巴周围肤色暗沉怎么办 中奖彩票被洗了怎么办 牙龈下面长米粒肉疙瘩怎么办 书画印章盖反了怎么办 金龙鱼一个月不吃东西怎么办 罗汉鱼头撞扁了怎么办 房顶开槽埋线白色不一样怎么办 顶上灯挪位置线怎么办 马蜂窝弄掉又来怎么办 蜂窝弄掉又有怎么办 2018年小龙虾底板脏怎么办 一本分数线擦边过怎么办 玩具塑料球扁了怎么办 胶皮与海绵开了怎么办 安卓不支持flash了怎么办 看视频要加载flash怎么办 下水道管子铁皮破了怎么办 炸金花牌一样大怎么办 玩棋牌游戏输了怎么办 苹果7插耳机外放怎么办 出国种菠菜抓了怎么办 在菲做菠菜抓到怎么办 3串1中两个怎么办 微博账号封停怎么办 阴阳师账号被永久封停怎么办 寒刃2账号被禁用怎么办 输了好多钱我该怎么办 亲朋打鱼别处在玩怎么办 做糯米蛋的蛋清怎么办 水田地没耙地平怎么办 宝宝拉鸡蛋花样大便怎么办 电子琴伴奏区无旋律音怎么办 手机触摸屏摔坏了怎么办 手机充着电玩游戏卡怎么办? 4个月宝宝拉肚子怎么办 6个月宝宝上火怎么办 1月婴儿大便干燥怎么办