zoukankan      html  css  js  c++  java
  • Winform 窗体最小化隐藏在桌面右下角:转

    ICO文件要放到 binDebug 下 

    1、给主窗体添加 NotifyIcon 控件

    2、窗体加载事件里

            private void MainF_Load(object sender, EventArgs e)
            {
                this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components);
                notifyIcon1.Icon = new Icon("JC.ico");
                notifyIcon1.Visible = false;
                notifyIcon1.Click += new System.EventHandler(this.notifyIcon1_Click);
                this.SizeChanged += new System.EventHandler(this.MainF_SizeChanged);
            }

     

    3、窗体的SizeChanged事件

     

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

     

    4、窗体加载事件里的notifyIcon1_Click方法

     

            private void notifyIcon1_Click(object sender, EventArgs e)
            {
                if (this.WindowState == FormWindowState.Minimized)
                {
                    this.WindowState = FormWindowState.Maximized;
                    this.Activate();
                    this.notifyIcon1.Visible = false;
                    this.ShowInTaskbar = true;
                }
            }

  • 相关阅读:
    国外程序员整理的 C++ 资源大全(转)
    深入C#中get与set的详解(转)
    C#异常类型与异常处理
    strcat函数的使用需要注意的问题
    QString转换为char* (转)
    Qt之阴影边框(转)
    Qt 手动添加ui文件到工程(转)
    C++ 类 和 对象!
    怎样才能和编程语言对上眼?你需要做些准备以及...
    【编程骚操作】C++ 获取系统时间!
  • 原文地址:https://www.cnblogs.com/candyzhmm/p/5692926.html
Copyright © 2011-2022 走看看