detecting keystrokes...How?
-
I have created a windows form application... the problem is that when the keyboard keystroke combination ALT-F4 was press my application quits. How can i stop the user from hitting the ALT-F4 key to terminate my application? thanks in advance :)
-
I have created a windows form application... the problem is that when the keyboard keystroke combination ALT-F4 was press my application quits. How can i stop the user from hitting the ALT-F4 key to terminate my application? thanks in advance :)
You need to override the
ProcessDialogKey
method of the form. The follow code will allow you to block ALT-F4 from closing your application.protected override bool ProcessDialogKey(Keys keyData) { Keys altf4 = Keys.Alt | Keys.F4; if (keyData == altf4) { return true; } return base.ProcessDialogKey(keyData); }
- Nick Parker Microsoft MVP - Visual C#
My Blog | My Articles -
You need to override the
ProcessDialogKey
method of the form. The follow code will allow you to block ALT-F4 from closing your application.protected override bool ProcessDialogKey(Keys keyData) { Keys altf4 = Keys.Alt | Keys.F4; if (keyData == altf4) { return true; } return base.ProcessDialogKey(keyData); }
- Nick Parker Microsoft MVP - Visual C#
My Blog | My ArticlesIt works like a charm!:) Excellent Thanks a lot for the help, Nick :)