• C# WinForm窗口最小化到系统托盘


    * C# WinForm窗口最小化到系统托盘
    http://hi.baidu.com/kfxtgtqyapouyze/item/8ccfdcd5a174a7312a35c7c3

    主要功能:
    (1)、程序启动自动隐藏到任务栏右侧通知栏显示。(与系统托盘同义)
    (2)、双击系统托盘图标显示、隐藏窗口;
    (3)、右击系统托盘图标提供三个菜单选项,“退出”、“隐藏”、“显示”;

    以上(1)的实现:

    private void Form1_SizeChanged(object sender, EventArgs e)
    {
        if (this.WindowState == FormWindowState.Minimized)
        {
            this.Hide();
            this.notifyIcon1.Visible = true;
        }
    }

    以上(2)的实现:

    右击notifyIcon1 ,选择属性,双击其中DoubleClick,添加相关代码  

    private void notifyIcon1_DoubleClick(object sender, EventArgs e)
    {
        if (this.WindowState == FormWindowState.Normal)
        {
            this.WindowState = FormWindowState.Minimized;
            this.Hide();
        }
        else if (this.WindowState == FormWindowState.Minimized)
        {
            this.Show();
            this.WindowState = FormWindowState.Normal;
            this.Activate();
        }
    }

    单击显示程序界面:

    private void notifyIcon1_Click(object sender, EventArgs e)
    {
        this.Visible = true;
        this.WindowState = FormWindowState.Normal;
        this.notifyIcon1.Visible = false;
    }
  • 相关阅读:
    D. Beautiful Array
    C. Magic Ship Educational Codeforces Round 60 (Rated for Div. 2)
    CCPC-Wannafly Winter Camp Day3 小清新数论(莫比乌斯反演反演加杜教筛)
    杜教筛
    Algorithms Weekly 3
    Algorithms Weekly 2
    Algorithms Weekly 1
    KNN算法实现数字识别
    2019总结
    2019 Google Kickstart Round H
  • 原文地址:https://www.cnblogs.com/bluestorm/p/3339201.html
Copyright © 2020-2023  润新知