C# winForm实现的气泡提示窗口功能示例
本文实例讲述了C#winForm实现的气泡提示窗口功能。分享给大家供大家参考,具体如下:
usingSystem;
usingSystem.Collections.Generic;
usingSystem.ComponentModel;
usingSystem.Data;
usingSystem.Drawing;
usingSystem.Text;
usingSystem.Windows.Forms;
namespaceWindowsFormsApplication60
{
publicpartialclassForm1:Form
{
privateButtonbtnShow=null;
privateButtonbtnClose=null;
privateNotifyIconnotifyIcon1=null;
publicForm1()
{
InitializeComponent();
this.Load+=newEventHandler(Form1_Load);
}
privatevoidForm1_Load(objectsender,EventArgse)
{
btnShow=newButton();//显示气泡提示窗口
btnShow.Text="show";
btnShow.Click+=newEventHandler(btnShow_Click);
btnShow.Location=newPoint(10,10);
this.Controls.Add(btnShow);
btnClose=newButton();//影藏气泡提示窗口
btnClose.Text="close";
btnClose.Click+=newEventHandler(btnClose_Click);
btnClose.Location=newPoint(10+btnShow.Width+10,10);
this.Controls.Add(btnClose);
notifyIcon1=newNotifyIcon();
notifyIcon1.MouseMove+=newMouseEventHandler(notifyIcon1_MouseMove);
notifyIcon1.Icon=global::WindowsFormsApplication60.Properties.Resources.Lintway;
}
///
///鼠标移过显示时间
///
///
///
voidnotifyIcon1_MouseMove(objectsender,MouseEventArgse)
{
this.notifyIcon1.ShowBalloonTip(1000,"当前时间:",DateTime.Now.ToLocalTime().ToString(),ToolTipIcon.Info);//显示气泡提示
}
///
///影藏时间
///
///
///
voidbtnClose_Click(objectsender,EventArgse)
{
this.notifyIcon1.Visible=false;//设置提示控件不可见
}
///
///显示时间
///
///
///
voidbtnShow_Click(objectsender,EventArgse)
{
this.notifyIcon1.Visible=true;//设置提示控件可见
this.notifyIcon1.ShowBalloonTip(1000,"当前时间:",DateTime.Now.ToLocalTime().ToString(),ToolTipIcon.Info);//显示气泡提示
}
}
}
更多关于C#相关内容感兴趣的读者可查看本站专题:《C#窗体操作技巧汇总》、《WinForm控件用法总结》、《C#数据结构与算法教程》、《C#常见控件用法教程》、《C#面向对象程序设计入门教程》及《C#程序设计之线程使用技巧总结》
希望本文所述对大家C#程序设计有所帮助。