• C#实现右下角图标(系统托盘)功能


    窗体中拖入 notifyIcon 组件

    notifyIcon 中的 ICON 属性 显示的图标

    下面是系统托盘的基本功能代码(单击最小化窗体隐藏,双击图标显示)及窗体关闭时退出确认代码。

        //单击最小化窗体隐藏

      private void frmMain_SizeChanged(object sender, EventArgs e)
            {
                if (this.WindowState == FormWindowState.Normal)
                {
                    notifyIcon1.Visible = true; //托盘图标隐藏
                }
                if (this.WindowState == FormWindowState.Minimized)//最小化事件
                {
                    this.Hide();//最小化时窗体隐藏
                }
            }

           //双击系统托盘的小图标事件

            private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e)
            {
                if (this.WindowState == FormWindowState.Minimized)
                {
                    this.Show();
                    this.WindowState = FormWindowState.Normal; //还原窗体
                }
            }

            private void frmMain_FormClosing(object sender, FormClosingEventArgs e) //关闭事件
            {
                DialogResult result;
                result = MessageBox.Show("确定退出吗?", "退出", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
                if (result == DialogResult.OK)
                {

                    Application.ExitThread();
                }
                else
                {
                    e.Cancel = true;
                }
            }

  • 相关阅读:
    银行代码
    c#第二章
    c#第一章
    S1304HTML内测测试分析
    HTML第九章
    HTML第八章
    HTML第七章
    Jupyter Notebook与Jupyterhub的安装与配置
    如果你要拍一部微电影
    针对Excel的vbs操作
  • 原文地址:https://www.cnblogs.com/hailexuexi/p/1804869.html
Copyright © 2020-2023  润新知