using System.Windows.Forms;
namespace _7._17daywin01
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
//判断关闭操作是用户点击右上角的操作按钮
if (e.CloseReason == CloseReason.UserClosing)
{
MessageBox.Show("关闭窗口也改变不了你喜欢我的事实");
e.Cancel = true;//阻止窗口关闭
}
}
private void button1_MouseEnter(object sender, EventArgs e)
{
if (this.button1.Text.Equals("不是"))
{
this.button1.Text = "是的";
this.button2.Text = "不是";
}
}
private void button2_MouseEnter(object sender, EventArgs e)
{
if (this.button2.Text.Equals("不是"))
{
this.button2.Text = "是的";
this.button1.Text = "不是";
}
}
private void button2_Click(object sender, EventArgs e)
{
MessageBox.Show("就知道你喜欢我");
Application.Exit();
}
private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show("就知道你喜欢我");
Application.Exit();
}
}
}
当鼠标悬停在不是的时候 会将不是和是的进行对调
点×的时候会触发("关闭窗口也改变不了你喜欢我的事实");
只有点是的才能关闭窗口