实现效果:
知识运用:
NotifyIcon控件的Icon属性 //获取或设置当前托盘图标
public Icon Icon{ get;ser }
和ContextMenu属性 //获取或设置托盘图标的快捷菜单
public ContextMenu ContexeMenu { get;set }
实现代码:
private void Form1_Load(object sender, EventArgs e) { NotifyIcon P_icon = new NotifyIcon(); Icon ic = new Icon("m.ico"); P_icon.Icon = ic; P_icon.Visible = true; MenuItem mi = new MenuItem("最大化"); mi.Click += new EventHandler(mi_Click); MenuItem mi2 = new MenuItem("退出"); mi2.Click+=new EventHandler(mi2_Click); P_icon.ContextMenu = new ContextMenu(new MenuItem[]{mi,mi2}); }