预览加载中,请您耐心等待几秒...
1/6
2/6
3/6
4/6
5/6
6/6

在线预览结束,喜欢就下载吧,查找使用更方便

如果您无法下载资料,请参考说明:

1、部分资料下载需要金币,请确保您的账户上有足够的金币

2、已购买过的文档,再次下载不重复扣费

3、资料包下载后请先用软件解压,在使用对应软件打开

HYPERLINK"http://www.cnblogs.com/lark/articles/955808.html"WinForm窗口最小化到系统托盘 C#编写最小化时隐藏为任务栏图标的Windowappllication. 1.设置WinForm窗体属性showinTask=false 2.加notifyicon控件notifyIcon1,为控件notifyIcon1的属性Icon添加一个icon图标。 3.添加窗体最小化事件(首先需要添加事件引用): this.SizeChanged+=newSystem.EventHandler(this.Form1_SizeChanged); //上面一行是主窗体InitializeComponent()方法中需要添加的引用 privatevoidForm1_SizeChanged(objectsender,EventArgse){if(this.WindowState==FormWindowState.Minimized){this.Hide();this.notifyIcon1.Visible=true;} }4.添加点击图标事件(首先需要添加事件引用): privatevoidnotifyIcon1_Click(objectsender,EventArgse){this.Visible=true; this.WindowState=FormWindowState.Normal; this.notifyIcon1.Visible=false;} 5.可以给notifyIcon添加右键菜单: 主窗体中拖入一个ContextMenu控件NicontextMenu,点中控件,在上下文菜单中添加菜单,notifyIcon1的ContextMenu行为中选中NicontextMenu作为上下文菜单。 this.notifyIcon1=newSystem.Windows.Forms.NotifyIcon(this.components);this.NicontextMenu=newSystem.Windows.Forms.ContextMenu();this.menuItem_Hide=newSystem.Windows.Forms.MenuItem();this.menuItem_Show=newSystem.Windows.Forms.MenuItem();this.menuItem_Aubot=newSystem.Windows.Forms.MenuItem();this.menuItem_Exit=newSystem.Windows.Forms.MenuItem(); this.notifyIcon1.ContextMenu=this.NicontextMenu;this.notifyIcon1.Icon=((System.Drawing.Icon)(resources.GetObject("NotifyIcon.Icon")));this.notifyIcon1.Text="";this.notifyIcon1.Visible=true;this.notifyIcon1.DoubleClick+=newSystem.EventHandler(this.notifyIcon1_DoubleClick);this.notifyIcon1.Click+=newSystem.EventHandler(this.notifyIcon1_Click); this.NicontextMenu.MenuItems.AddRange(newSystem.Windows.Forms.MenuItem[]{this.menuItem_Hide,this.menuItem_Show,this.menuItem_Aubot,this.menuItem_Exit});////menuItem_Hide//this.menuItem_Hide.Index=0;this.menuItem_Hide.Text="隐藏";this.menuItem_Hide.Click+=newSystem.EventHandler(this.menuItem_Hide_Click);////menuItem_Show//this.menuItem_Show.Index=1;this.menuItem_Show.Text="显示";this.menuItem_Show.Click+=newSystem.EventHandler(this.menuItem_Show_Click);////menuItem_Aubot//this.menuItem_Aubot.Index=2;this.menuItem_Aubot.Text="关