需要捕捉WM_SYSCOMMAND消息,然后作出判断。
procedure WMSysCommand(var Msg: TMessage);
begin
  if Msg.wParam <> SC_CLOSE then
    inherited;
end;

解决方案 »

  1.   

    说一个看起来不怎么专业。可是十分明了实用的方法。
    建立一个:Action,将它的快捷键(ShortCut)定义为 Alt+F4,在其代码处写一个空行。
    这样用户一但去按  Alt+F4,程序就去执行这一段空的代码而不去执行系统定义的关闭窗口。
    从而实现屏蔽的目的。
      

  2.   

    procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    begin
      if key=115 then key:=0
    end;一定可以,试过了。给分噢
      

  3.   

    say()老兄:
    我试了一下你的代码,发现只是新建一个Form(空白的),你的方法可以用,但是一旦在上面添加了一个控件(什么控件都行,我用的是button)后,就不行了,窗体还是被Alt+F4给关了
      

  4.   

    这个简单,在窗体的OnClose事件中写上:  action:=caNone; 就行了。
      

  5.   

    这有一个现成的,你试试看:
    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:TForm1 = class(TForm)
    {...}
    private
      procedure WMSysCommand(var Msg: TWMSysCommand); message WM_SYSCOMMAND;
    {...}
    end;procedure TForm1.WMSysCommand(var Msg: TWMSysCommand);
    begin
      if Msg.CmdType <> SC_CLOSE then  // Prevent ALT+F4
        inherited;
    end;Gook luck!  
      

  6.   

    在过程WMSysCommand()中该使用什么参数?