NotifyIcon最小化程序

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/lkjasdgfh/article/details/79458109
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 NotifyIcon托盘
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private void button1_Click(object sender, EventArgs e)//按钮 最小化FORM 以 出发sizechanged事件
        {
            this.WindowState = FormWindowState.Minimized;
        }
        private void Form1_SizeChanged(object sender, EventArgs e)//事件内容为 显示natifyicon,并提示消息
        {
            if (this.WindowState == FormWindowState.Minimized)//如果为最小化
            {
                notifyIcon1.Visible = true;
                notifyIcon1.ShowBalloonTip(5000, "提示信息", "窗体已最小化至托盘,可双击再次显示", ToolTipIcon.Info);   //参数为  显示时间  标题  提示信息  图标         
            }
        }

        private void 菜单1ToolStripMenuItem_Click(object sender, EventArgs e)//右键快捷菜单
        {
            this.WindowState = FormWindowState.Normal;
            notifyIcon1.Visible = false;
        }
        private void Form1_Load(object sender, EventArgs e)//natifyicon初始化不显示
        {
            notifyIcon1.Visible = false;
        }
        private void notifyIcon1_DoubleClick(object sender, EventArgs e)//双击 显示
        {
            this.WindowState = FormWindowState.Normal;
            notifyIcon1.Visible = false;
        }

    }
}
展开阅读全文

没有更多推荐了,返回首页