c# 实现在屏幕的右下角的提示窗口
2010-03-08 11:35
417 查看
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; /*调用代码 frmTips ft = new frmTips(1000,txt,"tishi",true); ft.Show(); this.Activate(); */ namespace ClothingSales_0._5 { public partial class frmTips : Form { private int screenWidth;//屏幕宽度 private int screenHeight;//屏幕高度 private bool finished = true;//是否完全显示提示窗口 private int tim; //停留时间 private string txt; //显示文本 private bool flag; //自动关闭 private string frmTxt; //标题栏文本 public frmTips() { InitializeComponent(); } /// <summary> /// 构造方法重构 /// </summary> /// <param name="time">提示窗口显示时间 时间过后自动关闭 </param> /// <param name="lableText">提示窗口显示的文本</param> /// <param name="formText">提示窗口标题栏</param> /// <param name="formExit">提示窗口是否自动隐藏 true:自动关闭 false:不关闭</param> public frmTips(int time, string lableText, string formText, bool formExit) { InitializeComponent(); tim = time; txt = lableText; flag = formExit; frmTxt = formText; } /// <summary> /// 加载窗体 /// </summary> private void frmTips_Load(object sender, EventArgs e) { this.Text = " "+frmTxt; lblText.Text = txt; fromHeight(); screenHeight = Screen.PrimaryScreen.Bounds.Height; screenWidth = Screen.PrimaryScreen.Bounds.Width; Location = new Point(screenWidth - this.Size.Width-5, screenHeight-30); //设置初始窗口位置 timer1.Start(); } /// <summary> /// 移动控制 /// </summary> private void timer1_Tick(object sender, EventArgs e) { if (finished)//提示窗口没有完全显示 { if (Location.Y + Height + 29 >= screenHeight)//如果提示窗口的纵坐标与提示窗口的高度之和大于屏幕高度 { Location = new Point(Location.X, Location.Y - 1); } else { if (flag == false) //提示窗口不自动关闭 { timer1.Stop(); } else //提示窗口自动关闭 { tim = tim - 5; if (tim <= 0) { finished = false; } } } } else//提示窗口完全显示 { if (Location.Y < screenHeight) { Location = new Point(Location.X, Location.Y + 1); } else { this.Close(); } } } /// <summary> /// 显示文本换行 /// </summary> //private void lableText() //{ // string txt2 = ""; // for (int i = 0; i <= txt.Length / 10; i++) // { // if (i == txt.Length / 10) // { // txt2 += txt.Substring(i * 10, txt.Length - (i * 10)); // } // else // { // txt2 += txt.Substring(i * 10, 10) + Environment.NewLine; // } // } // lblText.Text = txt2; //} /// <summary> /// 窗体高度控制 /// </summary> private void fromHeight() { if (lblText.Height > 60) { Height = 109 + (lblText.Height - 60); } } } }
相关文章推荐
- C# winForm实现的气泡提示窗口功能示例
- 【转】利用C#实现标注式消息提示窗口
- 利用C#实现标注式消息提示窗口
- 仿QQ、MSN消息提示窗口的实现(C#)
- 利用C#实现标注式消息提示窗口
- 利用C#实现标注式消息提示窗口
- c# winform实现气泡提示窗口
- c#里用VBSCRIPT 的MSGBOX实现弹出窗口提示(而不是警告)图标
- C#实现窗口从屏幕右下角升起效果
- C# 窗口实现Win7简单屏幕泡泡保护程序 和实现聊天窗口震动
- 利用C#实现标注式消息提示窗口
- c# winform实现气泡提示窗口
- C#实现窗口靠近屏幕边缘自动吸附
- 利用C#实现标注式消息提示窗口
- C#中父窗口和子窗口之间实现控件互操作
- asp.net 2.0 ajax中实现弹出窗口报警提示
- C#实现简单的Login窗口实例
- 实现在屏幕左下角显示窗口
- Asp.net实现弹出窗口提示,又防止刷新被重复提交的方法
- 【开源下载】客户端根据服务器端的指令弹出提示窗口(c#网络通信源码)