随笔 - 2146  文章 - 97 评论 - 11767 trackbacks - 253


方法1: 使用 TForm 的 BorderIcons 属性
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs;

type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
  BorderIcons := BorderIcons - [biMinimize, biMaximize];
end;

end.


方法2: 使用 SetWindowLong 函数
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs;

type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
var
  ws: Integer;
begin
  ws := GetWindowLong(Handle, GWL_STYLE);
  ws := ws xor WS_MINIMIZEBOX xor WS_MAXIMIZEBOX;
  SetWindowLong(Handle, GWL_STYLE, ws);
end;

end.


方法3: 重载 CreateParams 方法
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs;

type
  TForm1 = class(TForm)
    procedure CreateParams(var Params: TCreateParams); override;
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.CreateParams(var Params: TCreateParams);
begin
  inherited; //inherited CreateParams(Params);
  Params.Style := Params.Style xor WS_MINIMIZEBOX xor WS_MAXIMIZEBOX;
end;

end.

posted on 2008-09-02 01:56  万一  阅读(...)  评论(...编辑  收藏