20151124001 关闭C#主窗体弹出是否关闭对话框
关闭C#主窗体弹出是否关闭对话框
private void Frm_Main_FormClosing(object sender, FormClosingEventArgs e)
{
DialogResult TS = MessageBox.Show("确定要关闭并退出程序?", "退出提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (TS == DialogResult.Yes)
{
e.Cancel = false;
//
if (m_bConnected == true)
{
int iResult = ADSHal.ADSHalAPI.ADS_DisconnectController(ref m_comAdatpter, ref m_comm); //断开连接连接门禁控制器
ADSHelp.PromptResult(iResult, true);
if (iResult == (int)ADSHal.ADSHalConstant.ADS_ResultCode.ADS_RC_SUCCESS)
{
//this.Text = "门禁Demo";
this.Text = "门禁连接断开";
m_bConnected = false;
}
}
}
else
{
e.Cancel = true;
}
}