日期:2014-05-18 浏览次数:20804 次
public partial class Form1 : Form
{
private bool exit;
//在FormClosing中加如下代码
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
if (e.CloseReason == CloseReason.UserClosing)
{
if (!exit)
{
e.Cancel = true;
}
}
}
//在托盘控件的右键退出菜单中加如下代码
private void quickMenuExit_Click(object sender, EventArgs e)
{
exit = true;
this.Close();
}
}