Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

stop window from being closed with Alt+F4

Status
Not open for further replies.

WebStar

Programmer
May 1, 2002
69
DE
Hi,
does anyone knows how can I stop my aplication from being closed with Alt+F4 key combination?
Thank you!
 
public bool F4 = false;

private void Form1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
{
if (e.KeyCode == Keys.F4 && e.Alt == true)
{
F4 = true;
}
}


private void Form1_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e)
{
F4 = false;
}
private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
if (F4) e.Cancel = true;
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top