weifenluo与notifyIcon小细节

 private void frmMain_Resize(object sender, EventArgs e)
        {
            if (this.WindowState == FormWindowState.Minimized)
            {

                notifyIcon1.ShowBalloonTip(3000, "程序最小化提示",
                    "图标已经缩小到托盘,打开窗口请双击图标即可。",
                    ToolTipIcon.Info);
                this.Hide();
            }
        }
        void notifyIcon1_DoubleClick(object sender, EventArgs e)
        {
            if (this.WindowState == FormWindowState.Minimized)
            {
                this.WindowState = FormWindowState.Maximized;
                this.StartPosition = FormStartPosition.CenterScreen;
                this.Show();
                this.BringToFront();
                this.Activate();
                this.Focus();
            }
            else
            {
                this.WindowState = FormWindowState.Minimized;
                this.Hide();
            }
        }
 private void frmMain_Load(object sender, EventArgs e)
        {
            this.dockPanel1.DocumentStyle = DocumentStyle.DockingMdi;
            //最小化到托盘
            this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components);
            notifyIcon1.Icon = new Icon("Main.ico");
            notifyIcon1.Visible = false;
            notifyIcon1.ContextMenuStrip = this.contextMenuStrip1;
            notifyIcon1.DoubleClick += new EventHandler(notifyIcon1_DoubleClick);
            this.SizeChanged += new System.EventHandler(this.frmMain_Resize);
            notifyIcon1.Visible = true;
            //this.ShowInTaskbar = false;
            user = HelpClass.UserManagerLogin;
            //this.tabShow.DoubleClick+=new EventHandler(tabShow_DoubleClick);
        }


不建议使用   this.ShowInTaskbar = false;属性 可能会出现点小问题

原文地址:https://www.cnblogs.com/Iyce/p/2920139.html