3
3h
Unregistered / Unconfirmed
GUEST, unregistred user!
真麻烦。象写控件那样写可能更适合你,参考以下的代码:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
BtnTest: TButton;
BtnClose: TButton;
procedure BtnTestClick(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
procedure BtnCloseClick(Sender: TObject);
private
FComeIn: Boolean;
procedure SetComeIn(const Value: Boolean);
public
Property ComeIn: Boolean Read FComeIn Write SetComeIn;
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
{ TForm1 }
procedure TForm1.SetComeIn(const Value: Boolean);
Const
IconSel : TBorderIcons = [];
begin
If FComeIn <> Value then
begin
FComeIn := Value;
If Value then
begin
If Form1.BorderIcons <> [] then
IconSel := Form1.BorderIcons;
Form1.BorderIcons := [];
end
else
begin
Form1.BorderIcons := IconSel;
end;
end;
end;
procedure TForm1.BtnTestClick(Sender: TObject);
begin
ComeIn := Not ComeIn;
end;
procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
CanClose := Not ComeIn;
end;
procedure TForm1.BtnCloseClick(Sender: TObject);
begin
Close;
end;
end.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
BtnTest: TButton;
BtnClose: TButton;
procedure BtnTestClick(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
procedure BtnCloseClick(Sender: TObject);
private
FComeIn: Boolean;
procedure SetComeIn(const Value: Boolean);
public
Property ComeIn: Boolean Read FComeIn Write SetComeIn;
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
{ TForm1 }
procedure TForm1.SetComeIn(const Value: Boolean);
Const
IconSel : TBorderIcons = [];
begin
If FComeIn <> Value then
begin
FComeIn := Value;
If Value then
begin
If Form1.BorderIcons <> [] then
IconSel := Form1.BorderIcons;
Form1.BorderIcons := [];
end
else
begin
Form1.BorderIcons := IconSel;
end;
end;
end;
procedure TForm1.BtnTestClick(Sender: TObject);
begin
ComeIn := Not ComeIn;
end;
procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
CanClose := Not ComeIn;
end;
procedure TForm1.BtnCloseClick(Sender: TObject);
begin
Close;
end;
end.