当前位置: 移动技术网 > IT编程>开发语言>c# > C#透明窗体实现方法

C#透明窗体实现方法

2019年07月18日  | 移动技术网IT编程  | 我要评论

本文实例讲述了c#透明窗体实现方法。分享给大家供大家参考。具体实现方法如下:

namespace windowsapplication1
{
  public partial class form2 : form
  {
    public form2()
    {
      initializecomponent();
      this.opacity = 1;
      this.text = "opacity=1";
      this.topmost = true;
    }
    private void form2_activated(object sender, eventargs e)
    {
      this.timer1.enabled = true;
    }
    private void form2_deactivate(object sender, eventargs e)
    {
      this.timer1.enabled = false;
      this.opacity = 1;
      this.text = "opacity=" + this.opacity.tostring();
    }
    private void form2_load(object sender, eventargs e)
    {
    }
    private void timer1_tick(object sender, eventargs e)
    {
      if (this.opacity > 0)
      {
        this.opacity -= 0.1;
        this.text = "opacity=" + this.opacity.tostring();
      }
      else if (this.opacity == 0)
      {
        this.close();
      }
      else this.timer1.enabled = false;
    }
  }
}

希望本文所述对大家的c#程序设计有所帮助。

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网