// ***************************************************************************************
//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 用法
最新推荐文章于 2022-06-22 22:07:23 发布
本文介绍如何在Windows应用程序中实现将窗口最小化到系统托盘的功能,并提供了双击托盘图标还原窗口及通过右键菜单安全退出程序的具体实现方式。
339

被折叠的 条评论
为什么被折叠?



