C_WinForm-最小化或关闭时隐藏到系统托盘.docVIP

  • 3
  • 0
  • 约1.07千字
  • 约 2页
  • 2017-06-08 发布于重庆
  • 举报

C_WinForm-最小化或关闭时隐藏到系统托盘.doc

C_WinForm-最小化或关闭时隐藏到系统托盘

C#WinForm - 最小化或关闭时隐藏到系统托盘 STEP1、添加托盘图标控件NotifyIcon(直接从工具箱中拖动添加即可) STEP2、添加(重写)窗口尺寸变动函数Form1_Resize private void Form1_Resize object sender, EventArgs e if this.WindowState FormWindowState.Minimized //最小化到系统托盘 NotifyIcon1.Visible true; //显示托盘图标 this.Hide ; //隐藏窗口 STEP3、添加(重写)关闭窗口事件 private void Form1_FormClosing object sender, FormClosingEventArgs e //注意判断关闭事件Reason来源于窗体按钮,否则用菜单退出时无法退出! if e.CloseReason CloseReason.UserClosing e.Cancel true; //取消关闭窗口事件 this.WindowState FormWindowState.Minimized; //使关闭时窗口向右下角缩小的效果 NotifyIcon1.Visible true; this.Hide ; return; STE

文档评论(0)

1亿VIP精品文档

相关文档