var
  hSysMenu: HMENU;hSysMenu := GetSystemMenu( Form.Handle, FALSE );
EnableMenuItem( hSysMenu, SC_CLOSE, MF_BYCOMMAND or MF_GRAYED );

解决方案 »

  1.   

    easy,处理form.onclosequery就可以了
    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
      StdCtrls;type
      TForm1 = class(TForm)
        Button1: TButton;
        procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }  end;var
      Form1: TForm1;implementation{$R *.DFM}procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
    begin
      canclose:=false;
    end;procedure TForm1.Button1Click(Sender: TObject);
    begin
      self.OnCloseQuery:=nil;
      close;
    end;end.
    //给分吧:)
      

  2.   

    对了忘了说了,如果你不是动态释放form,你在form.oncreate里最好设定
    self.onclosequery:=FormCloseQuery;
      

  3.   

    一个很简单的方法:在此窗体中增加一个PopMenu,再随便增加一个菜单项,使其不可见,设置其热键为Alt+F4,事件代码则为什么都不做,即可!
      

  4.   

    在FORM的private中声明一变量
      AClose : Boolean;FormCreate时
      AClose := False;关闭窗口的button Click时
      AClose := True;在Form的OnCloseQuery中检测
    AClose的值procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
    begin
      canclose := False;
      if AClose then
      begin
        canclose := True;
      end;
    end;
    这样做虽然笨一点,但也能达到需要的效果。
      

  5.   

    如果想屏蔽系统所有'alt+f4',而不是仅仅所设计的程序,只有进行键值捕获
      

  6.   

    没那么复杂:在Form的OnClose事件中设置变量Action := caNone即可.
      

  7.   

    很简单,在form的onclosequery中加入canclose:=false;(最好还有个判断)
      

  8.   

    同意 AcherMagic 的意见。
      

  9.   

    如果想屏蔽系统所有'alt+f4',可以通过修改注册表完成。
      

  10.   

    procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    begin
      if (ssAlt in shift) and (Key=VK_F4) then
      begin
        B:=False;
        FormCloseQuery(sender,B);
      end;
    end;procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
    begin
      if B=False then
        CanClose:=False
      else
        CanClose:=True;
    end;procedure TForm1.Button1Click(Sender: TObject);
    begin
      B:=True;
      Close;
    end;