建个WinForm项目,其它操作略过。
拉个NotifyIcon控件,将属性Visable设置成False
没有Icon图标 还要加 Icon图
用Form的SizeChanged事件,代码如下:
窗口最小 托盘
if(this.WindowState == FormWindowState.Minimized) //判断是否最小化
{
this.ShowInTaskbar = false; //不显示在系统任务栏
notifyIcon.Visible = true; //托盘图标可见
}
用NotifyIcon控件的DoubleClick事件,代码如下:
双击托盘 恢复窗口
if(this.WindowState == FormWindowState.Minimized)
{
this.ShowInTaskbar = true; //显示在系统任务栏
this.WindowState = FormWindowState.Normal; //还原窗体
notifyIcon.Visible = false; //托盘图标隐藏
}

相关文章:

  • 2021-07-29
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-23
  • 2022-01-05
  • 2021-11-05
猜你喜欢
  • 2021-09-28
  • 2021-06-22
  • 2022-01-19
  • 2022-12-23
  • 2022-12-23
  • 2021-10-30
  • 2022-12-23
相关资源
相似解决方案