自动提醒功能

用FORM实现

C# code
实现类似MSN好友上线的提示 设置两个窗体: form2(即好友上线提示的容器) :代码: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace MSN { public partial class Form2 : Form { public Form2() { InitializeComponent(); } private int heightMax, widthMax; public int HeightMax { set { heightMax = value; } get { return heightMax; } } public int WidthMax { set { widthMax = value; } get { return widthMax; } } //Timer1控制窗体滚出的动画,timer2控制窗体停留时间,timer3控制窗体的滚入动画 public void ScrollShow() { this.Width = widthMax; this.Height = 0; this.Show(); this.timer1.Enabled = true; } public int StayTime = 5000; int a = 30; private void ScrollUp() { if (Height < heightMax) { this.Height += 3; this.Location = new Point(this.Location.X, this.Location.Y - 3); } else { this.timer1.Enabled = false; this.timer2.Enabled = true; } //if (a <= heightMax * 8 ) //{ // a += 3; // this.Height = 35 ; // this.Location = new Point(this.Location.X, this.Location.Y - 3); // if(this.Location.X > 500 ) // { // this.Location = new Point(this.Location.X - 3, this.Location.Y); // } //} } private void ScrollDown() { if (Height > 3) { this.Height -= 3; this.Location = new Point(this.Location.X, this.Location.Y + 3); } else { this.timer3.Enabled = false; this.Close(); } } private void timer3_Tick(object sender, EventArgs e) { ScrollDown(); } private void timer1_Tick(object sender, EventArgs e) { ScrollUp(); } private void timer2_Tick(object sender, EventArgs e) { timer2.Enabled = false; timer3.Enabled = true; } private void Form2_Load(object sender, EventArgs e) { Screen[] screens = Screen.AllScreens; Screen screen = screens[0];//获取屏幕变量 this.Location = new Point(screen.WorkingArea.Width - widthMax - 20, screen.WorkingArea.Height - 34); //WorkingArea为Windows桌面的工作区 this.timer2.Interval = StayTime; } } } form1 前台的调用 :代码 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace MSN { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { Screen[] screens = Screen.AllScreens; Screen screen = screens[0];//获取屏幕变量 Form2 form = new Form2(); form.HeightMax = 120;//窗体滚动的高度 form.WidthMax = 148;//窗体滚动的宽度 form.ScrollShow(); } } }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值