How can I ignore Alt+F4 in WPF Application?
Add this to the UIElement/FramworkElement
from where you do not wish the Alt+F4 to work.
wnd.KeyDown += new KeyEventHandler(wnd_KeyDown);
void wnd_KeyDown(object sender, KeyEventArgs e)
{
if ( e.Key == Key.System && e.SystemKey == Key.F4)
{
e.Handled = true;
}
}
You can impement OnClosing
event on TForm
and set cea.Cancel = true;
when cea is CancelEventArgs
from OnClosing
argument.
http://msdn.microsoft.com/en-us/library/system.windows.forms.form.onclosing.aspx
private void Form1_Closing(Object sender, CancelEventArgs e) {
e.Cancel = true;
}
void Form1_Cancel( Object^ /*sender*/, CancelEventArgs^ e )
{
e->Cancel = true;
}
Private Sub Form1_Closing(sender As Object, e As _
System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
e.Cancel = True
End Sub 'Form1_Closing
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With