This is a dumping ground of software development topics that I've run across and found interesting (mainly .NET development). Many topics are covered more thoroughly in other places, and much of the information is gleaned from other places, and I'll try to credit those sources when possible.

Wednesday, February 13, 2008

C# .NET: Ignoring Alt-F4 key combination

Alt-F4 is a shortcut that closes a window. For some reason you may not be fond of this behavior. After doing some digging around, I finally found a good method of ignoring this request - overriding the ProcessDialogKey method. You can go do more research if you'd like, but the basic code is as follows:

protected override bool ProcessDialogKey(Keys keyData)
if (keyData == (Keys.Alt | Keys.F4))
return true;
return base.ProcessDialogKey(keyData);


Anonymous said...

Thank you !!
Helped me a lot!

Dr.Shadow said...

Thank you very much! For some reason I had to create this shortkey to close application. It wouldn't do otherwise.