C# 托盘图标. notifyIcon 用法

           // ***************************************************************************************
                //Application.Exit();
                this.Hide();
                notifyIcon1.Visible = true;
                notifyIcon1.Text = "提醒程序";
            // ***************************************************************************************

    
//---------------------对着图标双击事件----------------------------------------------
        private void notifyIcon1_DoubleClick(object sender, EventArgs e)
        {
            this.Show();
            this.WindowState = FormWindowState.Maximized;
        }


    private void F_Main_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (!isExit)
            {
                e.Cancel = true;
                this.Hide();
                this.notifyIcon1.Visible = true;
                this.notifyIcon1.ShowBalloonTip(3000, "提示", "系统仍在运行",ToolTipIcon.Info);
             }

        }
------------------------------右键菜单的制作方法-------------------------------------------------------------------------
notifyIcon1 属性ContextMenuStrip 绑定 contextMenuStrip1

 private void Contex_exitApp_Click(object sender, EventArgs e)
 {
            // ***************************************************************************************
            string message = "你确定退出本程序?";
            string caption = "提示信息";
            MessageBoxIcon msgBoxIcon = MessageBoxIcon.Information;
            MessageBoxButtons msgBtn = MessageBoxButtons.OKCancel;
            DialogResult result = MessageBox.Show(message, caption, msgBtn, msgBoxIcon);
            if (result == System.Windows.Forms.DialogResult.OK)
            {
                isExit = true;
                Application.Exit();
            }
            // ***************************************************************************************

 }


你可能感兴趣的:(C# 托盘图标. notifyIcon 用法)