这有一个现成的,你试试看:
A better way to disable ALT+F4 to prevent form closing
Undertitle: Catch the WM_SYSCOMMAND message
Category: VCL-General
Uploader: Chen Jiangyong
Question: How can I disable the Alt+F4 key combination to keep my form
from closing? (A better way)
Answer: After I read the article about Peter Lieber's Disabling ALT-F4 to prevent form closing, I think I know a better way to resolve it.
In Windows, when you press ALT+F4 in a form, a WM_SYSCOMMAND will occur. (For more about WM_SYSCOMMAND see MSDN or other win32 help.) So if you catch the WM_SYSCOMMAND message it is easy to prevent form closing.
Example: