示例:注册托盘图标


用途:如题


        /// <summary> 注册托盘 </summary>
        public void RegisterNotify()
        {

            this.notifyIcon = new NotifyIcon();
            this.notifyIcon.BalloonTipText = "光速启动";
            this.notifyIcon.ShowBalloonTip(2000);
            this.notifyIcon.Text = "光速启动";
            this.notifyIcon.Icon = new System.Drawing.Icon(@"../../skin/Feather.ico");
            this.notifyIcon.Visible = true;

            this.notifyIcon.MouseDoubleClick += (object sender, System.Windows.Forms.MouseEventArgs e) =>
            {
                this.ShowWindow();
            };

            ContextMenuStrip m = new ContextMenuStrip();
            ToolStripItem t = new ToolStripMenuItem();
            t.Text = "退出";
            t.Click += (object ss, EventArgs ee) =>
            {
                this.Close();
            };
            this.notifyIcon.ContextMenuStrip = m;
            this.notifyIcon.ContextMenuStrip.Items.Add(t);
        }


猜你喜欢

转载自blog.csdn.net/u010975589/article/details/61199146