为了正常的体验网站,请在浏览器设置里面开启Javascript功能!

WinForm 类QQ消息提示窗

2018-01-14 4页 doc 17KB 23阅读

用户头像

is_314871

暂无简介

举报
WinForm 类QQ消息提示窗WinForm 类QQ消息提示窗 做一个简单的类似QQ的消息提示窗体,提示消息之后在指定的时间内自动关闭,或通过点击关闭按钮关闭。 在VS2005建立一个WINDOWS应用程序,添加一个窗体,名字就用barForm,FormBorderStyle设为None; BackgroundImage就用一个带关闭图标的背景,关闭图标大小为10*10; 窗体中放两个Label,Label1用于显示传递的信息,Label2用来显示实时时间; 设置两个定时器,timer1用来触发关闭消息提示窗体,其Interval设置为1000;...
WinForm 类QQ消息提示窗
WinForm 类QQ消息提示窗 做一个简单的类似QQ的消息提示窗体,提示消息之后在指定的时间内自动关闭,或通过点击关闭按钮关闭。 在VS2005建立一个WINDOWS应用程序,添加一个窗体,名字就用barForm,FormBorderStyle设为None; BackgroundImage就用一个带关闭图标的背景,关闭图标大小为10*10; 窗体中放两个Label,Label1用于显示传递的信息,Label2用来显示实时时间; 设置两个定时器,timer1用来触发关闭消息提示窗体,其Interval设置为1000; timer2用来刷时间,其Interval设置为1000~ 代码部分如下: 引用: using System.Runtime.InteropServices; using System.Windows.Forms; public partial class barForm : Form { public const Int32 AW_HOR_POSITIVE = 0x00000001;//从左到右打开窗口 public const Int32 AW_HOR_NEGATIVE = 0x00000002;//从右到左打开窗口 public const Int32 AW_VER_POSITIVE = 0x00000004;//从上到下打开窗口 public const Int32 AW_VER_NEGATIVE = 0x00000008;//从下到上打开窗口 public const Int32 AW_CENTER = 0x00000010; public const Int32 AW_HIDE = 0x00010000; public const Int32 AW_ACTIVATE = 0x00020000;//在窗体打开后不失去焦点 public const Int32 AW_SLIDE = 0x00040000; public const Int32 AW_BLEND = 0x00080000;//淡入淡出效果 [DllImport("user32.dll", CharSet = CharSet.Auto)] public static extern bool AnimateWindow(IntPtr hwnd, int dwTime, int dwFlags); private string information=null;//要在窗体中显示的信息 public barForm(string info) { InitializeComponent(); information = info; this.timer2.Enabled = true;//启动时间 } private void TaskbarForm_Load(object sender, EventArgs e) { try { int x = Screen.PrimaryScreen.WorkingArea.Size.Width - this.Width; int y = Screen.PrimaryScreen.WorkingArea.Size.Height - this.Height; this.SetDesktopLocation(x, y); this.Label1.Text = information; AnimateWindow(this.Handle, 1000, AW_VER_NEGATIVE | AW_ACTIVATE);// 从下到上且不占其它程序焦点 this.timer1.Enabled = true; } catch (Exception ex) { log.Error(ex.Message); } } int count = 0;//计数器 private void timer1_Tick(object sender, EventArgs e) { count++; if (count == 50)//5s关闭提示窗体 { count = 0; AnimateWindow(this.Handle, 1000, AW_BLEND | AW_HIDE); this.Close(); } } private void timer2_Tick(object sender, EventArgs e) { this.Label2.Text = DateTime.Now.ToString("F"); } private void barForm_MouseClick(object sender, MouseEventArgs e) { if (e.Button = MouseButtons.Left)//左键点击 { if (Screen.PrimaryScreen.WorkingArea.Size.Width - e.X < 10 && Screen.PrimaryScreen.WorkingArea.Size.Height - e.Y < 10)//有效范 围判断 { AnimateWindow(this.Handle, 1000, AW_BLEND | AW_HIDE); this.Close(); } } } 在其他代码中的调用示例: string info="hello world!"; barForm form = new barForm(info); form.Show();
/
本文档为【WinForm 类QQ消息提示窗】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。 本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。 网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。

历史搜索

    清空历史搜索