zoukankan      html  css  js  c++  java
  • 沐风心扬C#编程速查系列之C#窗体渐显渐隐效果

    一.渐显效果
    1.构造函数
    public StartForm()
    {
    this.TransparencyKey = Color.Transparent;//
    this.DoubleBuffered = true;//这句必须加上,不然渐显时
    InitializeComponent();
    this.Opacity = 0.01d;
    }
    2.在Form_Shown事件加入如下代码,不能在Load事件中
    EffectFormFade(this, 200, true, false);//函数源码在下方
    //窗体渐显渐隐效果
    public static void EffectFormFade(Form myForm, int numPeriod, bool inOrOut, bool closeAtLast)
    {
    int inFlag = (inOrOut) ? 1 : -1;
    myForm.Invoke(new EventHandler(delegate
    {
    for (int i = 0; i < numPeriod; i++)
    {
    myForm.Opacity += inFlag * 1d / numPeriod;
    Application.DoEvents();
    if (myForm.Opacity == 0d || myForm.Opacity == 100d)
    {
    if (closeAtLast)
    {
    myForm.Close();
    }
    }
    }
    }));
    }
    二.渐隐效果
    EffectFormFade(this, 200, false, true);
  • 相关阅读:
    SQL8-函数与触发器
    SQL7-约束与权限
    SQL6-连接与视图
    SQL5-数据类型
    SQL4-嵌套查询
    SQL3-基本运算
    SQL2-基本语法
    SQL1-结构概括
    SQL历史概论
    PHP Fatal error: Class 'mysqli' not found
  • 原文地址:https://www.cnblogs.com/hust_wsh/p/2393879.html
Copyright © 2011-2022 走看看