How do I go about changing what happens when a user clicks the close (red X) button in a Windows Forms application (in C#)?
protected override bool ProcessCmdKey(ref Message msg, Keys dataKey) { if (dataKey == Keys.Escape) { this.Close(); //this.Visible = false; //Plus clear values from form, if Visible false. } return base.ProcessCmdKey(ref msg, dataKey); }