namespace NotifyIcon
...{
public partial class Form1 : Form
...{
public Form1()
...{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
...{
this.components = new Container();
System.Windows.Forms.NotifyIcon notifyicon = new System.Windows.Forms.NotifyIcon(this .components );
notifyicon.Text = "演示创建托盘";
notifyicon.Visible = true;
ResourceManager resourceManager = new ResourceManager("NotifyIcon.Properties.Resources", GetType().Module.Assembly);//从资源文件中添加图标
notifyicon.Icon = resourceManager.GetObject("icon1") as Icon;
MenuItem menuitem = new MenuItem("退出程序");
notifyicon.ContextMenu = new ContextMenu(new MenuItem[] ...{ menuitem });
menuitem.Click += new EventHandler(menuitem_Click);
notifyicon.MouseClick += new MouseEventHandler(notifyicon_MouseClick);
}
void notifyicon_MouseClick(object sender, MouseEventArgs e)
...{
//throw new Exception("The method or operation is not implemented.");
if (this.WindowState == FormWindowState.Minimized)
this.WindowState = FormWindowState.Normal;
}
void menuitem_Click(object sender, EventArgs e)
...{
//throw new Exception("The method or operation is not implemented.");
Application.Exit();
}
}
}
使用NotifyIcon控件创建任务栏托盘
来源:博客
作者:不详
时间:2008-04-24 点击:404 次
相关文章:
文章搜索
推荐文章
推荐产品
|
VARCHART XGantt
全球知名的甘特图控件,能够实现如 Microsoft Project 般强大的项目管理功能。
|
|
TurboDemo 中文版
TurboDemo - 抓取屏幕截图并通过动态演示示例及手册解释软件、个人电脑应用程序、网站与产品。
|
|
BCGControlBar Library .NET Edition
该组件包含大量可自定义程度高、可设计性好的组件,使用户可创建精致美观的图形用户界面。
|
|
WebUI Studio.NET
WebUI Studio.NET 是一套用于开发专业 ASP.NET web 应用程序必不可少的控件。
|





