[C#]C# 最小化 托盘
2016-06-22 09:17
567 查看
关键字:C# 最小化 托盘
原文:/article/4598501.html
先添加notifyicon控件notifyIcon1
复制代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace notifyIconShow
{
public partial class ColdJoke : Form
{
#region
//创建NotifyIcon对象
NotifyIcon notifyicon = new NotifyIcon();
//创建托盘图标对象
Icon ico = new Icon(“snow.ico”);
//创建托盘菜单对象
ContextMenu notifyContextMenu = new ContextMenu();
#endregion
}
复制代码
原文:/article/4598501.html
先添加notifyicon控件notifyIcon1
复制代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace notifyIconShow
{
public partial class ColdJoke : Form
{
#region
//创建NotifyIcon对象
NotifyIcon notifyicon = new NotifyIcon();
//创建托盘图标对象
Icon ico = new Icon(“snow.ico”);
//创建托盘菜单对象
ContextMenu notifyContextMenu = new ContextMenu();
#endregion
public ColdJoke() { InitializeComponent(); } #region 托盘提示 private void Form1_Load(object sender, EventArgs e) { //设置鼠标放在托盘图标上面的文字 this.notifyIcon1.Text = "笑话"; } #endregion #region 隐藏任务栏图标、显示托盘图标 private void Form1_SizeChanged(object sender, EventArgs e) { //判断是否选择的是最小化按钮 if (WindowState == FormWindowState.Minimized) { //托盘显示图标等于托盘图标对象 //注意notifyIcon1是控件的名字而不是对象的名字 notifyIcon1.Icon = ico; //隐藏任务栏区图标 this.ShowInTaskbar = false; //图标显示在托盘区 notifyicon.Visible = true; } } #endregion #region 还原窗体 private void notifyIcon1_DoubleClick(object sender, EventArgs e) { //判断是否已经最小化于托盘 if (WindowState == FormWindowState.Minimized) { //还原窗体显示 WindowState = FormWindowState.Normal; //激活窗体并给予它焦点 this.Activate(); //任务栏区显示图标 this.ShowInTaskbar = true; //托盘区图标隐藏 notifyicon.Visible = false; } } #endregion }
}
复制代码
相关文章推荐
- C#正则表达式编程(四):正则表达式
- C#正则表达式编程(二):Regex类用法
- C#正则表达式编程(一):C#中有关正则的类
- c#_HidUsb设备通信
- C# 中正则表达式 Group 分组【转】
- C#向DataTable插入列或行数据
- C# Winform实现炫酷的透明动画界面(转载)
- C#写PDF文件类库PDF File Writer介绍
- C#中获取文件夹地址、获取文件地址、获取文件夹中的某种类型文件集合、获取某文件中某种类型文件数量操作方法!
- c# 编码转换
- C# Get/Post 模拟提交
- c#正则表达式2
- C#实现文件的压缩与解压
- C#中Image.FromFile(string path)函数报内存不足错误解决方法
- C#winform检测电脑安装的.netframework版本和是否安装了某软件
- C#去除byte数组头尾杂质(即不需要的数据)
- C#位移运算符
- C#委托的回调机制
- C#逻辑运算符详解
- C# 杨辉三角形算法