最小化到托盘,右键退出
2016-06-12 13:19
204 查看
1.添加notifyIcon1,并添加Icon图标(.ico文件)
2.添加contextMenuStrip1
3.contextMenuStrip1.Items属性添加选项
4.界面上双击选项编写事件
5.选项退出
private void toolStripMenuItem1_Click(object sender, EventArgs e) { Application.Exit(); }
6.主窗预定Resize事件
if (this.WindowState == FormWindowState.Minimized) //最小化到系统托盘 { this.notifyIcon1.Visible = true; //显示托盘图标 this.Hide(); //隐藏窗口 }
7.主窗预定关窗事件
private void MainForm_FormClosing(object sender, FormClosingEventArgs e) { //注意判断关闭事件Reason来源于窗体按钮,否则用菜单退出时无法退出! if (e.CloseReason == CloseReason.UserClosing) { e.Cancel = true; //取消"关闭窗口"事件 this.WindowState = FormWindowState.Minimized; //使关闭时窗口向右下角缩小的效果 this.notifyIcon1.Visible = true; this.Hide(); return; } }
相关文章推荐
- 线程同步: 条件变量pthread_cond_t
- Win10 下 Powerdesigner、Visio 2010及mysql workbench数据库反向工程实践
- xshell与虚拟机无法连接
- Android Studio编译中“png-cruncher_*”异常的解决方案
- sql server附加数据库错误的解决方法
- 对程序集“”签名时加密失败 --“对程序集签名时出错 - 拒绝访问。
- 从一道题谈C++中构造函数调用构造函数
- Matlab如何在图上画包围目标区域的矩形(或圆)
- c语言中static的用法详细示例分析
- PacBio长reads的大基因组组装
- 袁腾飞——元
- java 浮点运算 工具类
- 粗浅看 Tomcat中设计模式分析
- 上传jcenter的“第一次”所遇到的坑
- 知行合一!如何做好项目经理?
- 知行合一!如何做好项目经理?
- 知行合一!如何做好项目经理?
- pouchdb sync
- 使用visio绘制企业动静分离企业架构
- 【Unity3d】如何绘制椭圆