我想让FORM 的右上角的关闭按钮不能用,只用一个最小化按钮,如何做?

解决方案 »

  1.   

    BorderIcons := [biMinimize];
      

  2.   

    在bordericos 里面设置就可以了
      

  3.   

    form->BorderIcons -> only bMinimizi is True other all are false
      

  4.   

    在OnClose事件 里面写 Abort就可以了。
    当然你真的想要关闭的时候,就要多做一点事情了。
      

  5.   

    以下程序改自网上代码,前提是把Form的BorderIcons的biSystemMenu设为Falseunit Unit1;interfaceuses
     Windows, Buttons, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
      StdCtrls;type
      TForm1 = class(TForm)
        procedure FormResize(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
        CaptionBtn:TRect;
        procedure DrawCaptButton;
        procedure WMNCPaint(var Msg:TWMNCPaint);message WM_NCPaint;
        procedure WMNCActivate(var Msg:TWMNCActivate);message WM_NCActivate;
        procedure WMSetText(var Msg:TWMSetText);message WM_SetText;
        procedure WMNCHitTest(var Msg:TWMNCHitTest);message WM_NCHittest;
        procedure WMNCLButtonDown(var Msg:TWMNCLButtonDown);message WM_NCLButtonDown;
      end;var
      Form1: TForm1;implementationconst
      htCaptionBtn=htSizeLast+1;
    {$R *.dfm}procedure TForm1.DrawCaptButton;
    var
      xFrame,yFrame,xSize,ySize:Integer;
      R:TRect;
    begin
      xFrame:=GetSystemMetrics(SM_CXFRAME);
      yFrame:=GetSystemMetrics(SM_CYFRAME);
      xSize:=GetSystemMetrics(SM_CXSIZE);
      ySize:=GetSystemMetrics(SM_CYSIZE);
    //  caption:=inttostr(ysize);
      //按钮属性调整->>
      CaptionBtn:=Bounds(Width-xFrame-5*xSize+2,yFrame+2,xSize+13,ySize-4);
      Canvas.Handle:=GetWindowDC(Self.Handle);
      Canvas.Font.Name:='宋体';
      //Canvas.Font.Color:=clblack;
      //Canvas.Pen.Color:=clYellow;
      Canvas.Brush.Color:=clBtnFace;
      try
        DrawButtonFace(Canvas,CaptionBtn,1,bsAutoDetect,False,False,False);
        R:=Bounds(Width-xFrame-5*xSize+3,yFrame+3,xSize+10,ySize-7);
        with CaptionBtn do
          Canvas.TextRect(R,R.Left+5,R.Top,'-');
      finally
        ReleaseDC(Self.Handle,Canvas.Handle);
        Canvas.Handle:=0;
      end;
    end;procedure TForm1.WMNCActivate(var Msg: TWMNCActivate);
    begin
    inherited;
      DrawCaptButton;
    end;procedure TForm1.WMNCHitTest(var Msg: TWMNCHitTest);
    begin
    inherited;
      with Msg do
        if PtInRect(CaptionBtn,Point(xPos-Left,yPos-Top)) then
        Result:=htCaptionBtn;
    end;procedure TForm1.WMNCLButtonDown(var Msg: TWMNCLButtonDown);
    begin
    inherited;
      if(Msg.HitTest=htCaptionBtn)then
        Sendmessage(handle,WM_SYSCOMMAND,SC_MINIMIZE ,0);
    end;procedure TForm1.WMNCPaint(var Msg: TWMNCPaint);
    begin
    inherited;
      DrawCaptButton;
    end;procedure TForm1.WMSetText(var Msg: TWMSetText);
    begin
    inherited;
      DrawCaptButton;
    end;procedure TForm1.FormResize(Sender: TObject);
    begin
      Perform(WM_NCACTIVATE,Word(Active),0);
    end;end.
      

  6.   

    你还是菜鸟啊,属性里就可以设啊! beyondtkl(大龙驹<逝追.弗瑞德>) form->BorderIcons -> only bMinimizi is True other all are false,就ok!
      

  7.   

    对我同意  fangerhua 的说法
    即简单又快捷
      

  8.   

    楼上的你自己试过没有,不要乱说人家。
    其实你也是菜鸟,把很多事情都想当然了,你自己试试看吧。agree
      

  9.   

    我的回复  确实是不对的 刚才去试了一下 没有选biSystemMenu 再选 biMinimizi为true也是不对的
    我当时确实是有点想当然了 汗 对不起了 楼主
    向   linzhengqun(风。全面提高回贴质量) 学习.....唉 偶还是太菜了..
      

  10.   

    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;type
      TForm1 = class(TForm)
        Button1: TButton;
        procedure FormClose(Sender: TObject; var Action: TCloseAction);
        procedure FormCreate(Sender: TObject);
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;
      bool: boolean;implementation{$R *.dfm}procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
    begin
      if bool then
        action := canone;
    end;procedure TForm1.FormCreate(Sender: TObject);
    begin
      bool := true;
    end;procedure TForm1.Button1Click(Sender: TObject);
    begin
      bool := false;
      form1.Close;
    end;end.
      

  11.   

    设置窗体属性:
    BorderIcons := [biMinimize];
    这样就行,还有象上面的用API那种方法也可以。反正方法很多,看你喜欢哪个了。
      

  12.   

    CloseQuery 在这个事件中写:canclose := false; 即可
      

  13.   

    向   linzhengqun(风。全面提高回贴质量)   学习
      

  14.   

    BorderIcons := [biMinimize];
      

  15.   

    去查查windows api ,好像是deletemenu或deletesystemmenu之类的东东。
      

  16.   

    但我似乎理解错楼主的意思了,
    楼主是说标题上只有一个最小化按钮。
    还是说其他按钮也有,只是其他按钮不可用呢。
    如果是第一种,就是我的回复中
    如果是第二种,就是 gaodu2002(旖旎) 的回复