• 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;
                }
            }

  • 相关阅读:
    Orchard:如何生成模块和生成一个Content Part
    马云2011年邮件
    asp.net页面编码问题
    创建一个三D立体感的主页
    25个网页设计实例
    设计一个简洁的个人网站
    新浪微博产品交互改进[转]
    设计一个暗色调简洁漂亮的主页
    用HTML5 画LOGO
    成功企业站设计思路
  • 原文地址:https://www.cnblogs.com/candyzhmm/p/5692926.html
Copyright © 2020-2023  润新知