/// <summary> /// 关闭窗体时处理的事情 /// </summary> private void MainFrom_FormClosing(object sender, FormClosingEventArgs e) { DialogResult result = MessageBox.Show("是否退出?选否,最小化到托盘", "操作提示", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); if (result == DialogResult.Yes) { this.Dispose(); opc.Close(); } else if (result == DialogResult.Cancel) { e.Cancel = true; } else { e.Cancel = true; this.WindowState = FormWindowState.Minimized; this.Visible = false; this.notifyIcon1.Visible = true; this.ShowInTaskbar = false; } }