C#窗口关闭到最小化

希望能够帮助一些人

 

private DialogResult result = DialogResult.No;

//Yes关闭窗口,No最小化窗口
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
if (result == DialogResult.Yes)
{
e.Cancel = false;
Application.Exit();
}
else
{
e.Cancel = true;
this.Hide();
this.Visible = false;
}
}

//关闭按钮,给result赋值
private void btnExit_Click(object sender, EventArgs e)
{
result=MessageBox.Show("确认退出窗口吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
Application.Exit();
}

你可能感兴趣的:(C++,c,C#)