类似qq弹窗,自动消失
2015-07-20 22:57
288 查看
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Runtime.InteropServices; using System.Text; using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; namespace FormCPM { public partial class Form1 : Form { const int countDown = 60;//倒计时 int currCountDown = countDown;//倒计时 bool isCount = true; Thread thread; public Form1() { InitializeComponent(); thread = new Thread(() => { while (true) { if (isCount) { if (currCountDown <= 0) { this.Invoke(new Action(() => { this.Close(); })); break; } else { Thread.Sleep(100); currCountDown--; this.Invoke(new Action(() => { this.Opacity = this.Opacity - this.Opacity / countDown; })); } } else { Thread.Sleep(10); } } }); thread.IsBackground = true; } [DllImport("user32")] private static extern bool AnimateWindow(IntPtr hwnd, int dwTime, int dwFlags); //下面是可用的常量,按照不合的动画结果声明本身须要的 private const int AW_HOR_POSITIVE = 0x0001;//自左向右显示窗口,该标记可以在迁移转变动画和滑动动画中应用。应用AW_CENTER标记时忽视该标记 private const int AW_HOR_NEGATIVE = 0x0002;//自右向左显示窗口,该标记可以在迁移转变动画和滑动动画中应用。应用AW_CENTER标记时忽视该标记 private const int AW_VER_POSITIVE = 0x0004;//自顶向下显示窗口,该标记可以在迁移转变动画和滑动动画中应用。应用AW_CENTER标记时忽视该标记 private const int AW_VER_NEGATIVE = 0x0008;//自下向上显示窗口,该标记可以在迁移转变动画和滑动动画中应用。应用AW_CENTER标记时忽视该标记该标记 private const int AW_CENTER = 0x0010;//若应用了AW_HIDE标记,则使窗口向内重叠;不然向外扩大 private const int AW_HIDE = 0x10000;//隐蔽窗口 private const int AW_ACTIVE = 0x20000;//激活窗口,在应用了AW_HIDE标记后不要应用这个标记 private const int AW_SLIDE = 0x40000;//应用滑动类型动画结果,默认为迁移转变动画类型,当应用AW_CENTER标记时,这个标记就被忽视 private const int AW_BLEND = 0x80000;//应用淡入淡出结果 private void Form1_Load(object sender, EventArgs e) { int x = Screen.PrimaryScreen.WorkingArea.Right - this.Width; int y = Screen.PrimaryScreen.WorkingArea.Bottom - this.Height; this.Location = new Point(x, y);//设置窗体在屏幕右下角显示 AnimateWindow(this.Handle, 1000, AW_SLIDE | AW_ACTIVE | AW_VER_NEGATIVE); thread.Start(); }private void Form1_MouseEnter(object sender, EventArgs e) { isCount = false; currCountDown = countDown; this.Opacity = 1d; } private void Form1_MouseLeave(object sender, EventArgs e) { isCount = true; } } }
相关文章推荐
- Web前端开发基础 第四课(CSS元素模型)
- [BZOJ2761][JLOI2011]不重复数字
- MacBook Pro使用初体验之Mac快捷键汇总(持续更新中)
- !HDU 4149 Magic Potion-yy-(二进制位运算技巧)
- 股票学习(财务分析11)
- mysql 数据库连接(远程和本地原理相同)
- [Leetcode 222, Medium] Count Complete Tree Nodes
- Java操作Oracle数据库以及调用存储过程
- 观察者模式及Java实现例子
- 再议关键字
- 【Python 学习手册笔记】Python 语句简介
- jstack(查看线程)、jmap(查看内存)和jstat(性能分析)命令
- android AsyncTask介绍
- 34. Search for a Range
- 20150720 Two heads are better than one
- ubuntu14-04升级到15-04
- poj1985 树的直径
- stuts2注解
- XMPP系列(二)----用户注册和用户登录功能
- XMPP系列(二)----用户注册和用户登录功能