zoukankan      html  css  js  c++  java
  • 最小化到托盘

    1.在form中添加一个NotifyIcon控件,并给它设一个图标,如lin.ico
    2.给当前FORM添加SizeChanged事件,最小化时显示在托盘
    3.给NotifyIcon控件添加Click事件,点击后恢复原窗体
     
    using System;  
    using System.Collections.Generic;  
    using System.ComponentModel;  
    using System.Data;  
    using System.Drawing;  
    using System.Text;  
    using System.Windows.Forms;  
     
    namespace LinhaiTest 
    {  
        public partial class Form1 : Form  
        {  
            public Form1()  
            {  
                InitializeComponent();  
            }  
     
            private void Form1_Load(object sender, EventArgs e)  
            {  
                this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components);   
                notifyIcon1.Visible = false;  
                notifyIcon1.Click += new System.EventHandler(this.notifyIcon1_Click);  
                this.SizeChanged += new System.EventHandler(this.Form1_SizeChanged);      
            }  
     
            private void Form1_SizeChanged(object sender, EventArgs e)  
            {  
                if (this.WindowState == FormWindowState.Minimized)    
                {  
                    this.ShowInTaskbar = false;  
                    this.notifyIcon1.Visible = true;  
                }   
            }   
      
            private void notifyIcon1_Click(object sender, EventArgs e)  
            {  
                if (this.WindowState == FormWindowState.Minimized)  
                    this.WindowState = FormWindowState.Normal;  
                this.Activate();  
                this.notifyIcon1.Visible = false;  
                this.ShowInTaskbar = true;      
            }   


        }  

  • 相关阅读:
    java实现第九届蓝桥杯最大乘积
    java实现第九届蓝桥杯最大乘积
    Anaconda入门使用指南
    Java安全——密钥那些事
    关于keyGenerator,KeyPairGenerator,SecretKeyFactory的解析
    @Transactional事务几点注意
    三种方式都是通过某种公开的算法将原始信息进行编码 /加密
    信息摘要算法 MessageDigestUtil
    Java使用RSA加密解密签名及校验
    java util
  • 原文地址:https://www.cnblogs.com/gxlinhai/p/1502456.html
Copyright © 2011-2022 走看看