窗体最小化到系统托盘
来源:互联网 发布:播音王软件下载 编辑:程序博客网 时间:2024/05/22 03:34
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;
using System.Collections;
namespace RichTextBoxUse
{
public partial class Form1 : Form
{
NotifyIcon notifyIcon = new NotifyIcon();//创建托盘对象
Icon icon =newIcon("exit.ico");//创建托D盘图标对象
ContextMenu notifyContextMenu = new ContextMenu();//创建托盘菜单对象
public Form1()
{
InitializeComponent();
notifyIcon.Text = "托盘名称";//鼠标放在托盘图标上显示的文字
notifyIcon.DoubleClick += new EventHandler(notifyIcon_DoubleClick);
notifyIcon.MouseClick += new MouseEventHandler(notifyIcon_MouseClick);
MenuItem mi = new MenuItem("Exit");
notifyContextMenu.MenuItems.Add(mi);
notifyIcon.ContextMenu = notifyContextMenu;
mi.Click += new EventHandler(mi_Click);
}
private void Form1_SizeChanged(object sender,EventArgs e)
{
if (WindowState == FormWindowState.Minimized)
{
notifyIcon.Icon = icon;
this.ShowInTaskbar = false;//任务栏上不显示窗体图标
notifyIcon.Visible = true;//托盘中显示托盘图标
}
}
private void notifyIcon_DoubleClick(object sender,EventArgs e)
{
if (WindowState == FormWindowState.Minimized)
{
WindowState = FormWindowState.Normal;//还原窗体
this.Activate();//激活窗体并给予它焦点
this.ShowInTaskbar =true;//在任务栏上显示窗体图标
notifyIcon.Visible = false;//隐藏托盘图标
}
}
private void notifyIcon_MouseClick(object sender,MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
this.notifyIcon.ContextMenu.Show(this,newPoint(e.X, e.Y));
}
}
private void mi_Click(object sender,EventArgs e)
{
notifyIcon.Visible = false;
this.Close();
}
}
}
- 窗体最小化到系统托盘
- C#Winform窗体如何最小化到系统托盘
- WINFORM是实现窗体最小化到系统托盘中
- 最小化或关闭窗体时,隐藏到系统托盘
- 定义热键调用主窗体(最小化到系统托盘)
- .net实例:WINFORM是实现窗体最小化到系统托盘中
- .net实例:WINFORM是实现窗体最小化到系统托盘中
- .net实例:WINFORM是实现窗体最小化到系统托盘中
- 程序最小化到系统托盘
- 程序最小化到系统托盘
- 应用程序最小化到系统托盘
- 最小化到系统托盘代码
- C# 最小化到系统托盘
- MFC最小化到系统托盘
- AIR-最小化到系统托盘
- delphi最小化到系统托盘
- Outlook最小化到系统托盘
- MFC最小化到系统托盘
- JS进制转
- 字符串中单词的翻转(二)
- 十进制与其他进制之间的转换
- openjudge 2757:最长上升子序列
- 蓝牙的规格,蓝牙的配置文件,中英文文档,Bluetooth profiles
- 窗体最小化到系统托盘
- HDU 5363 Key Set(快速幂)
- 快速排序算法在字符排序中的应用
- MySql 纵表转横表
- Ubiquitous Religions
- Android用户界面UI总结
- php反射代码
- 基本的线程机制
- [笔记]java应用程序窗口关闭的六种方式