unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons;
type
TForm1 = class(TForm)
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
BitBtn3: TBitBtn;
OpenDialog1: TOpenDialog;
Edit1: TEdit;
procedure BitBtn1Click(Sender: TObject);
Procedure Click(Sender:TObject);
procedure BitBtn2Click(Sender: TObject);
procedure BitBtn3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
var
butt:tbitbtn;
p:string;
Procedure tform1.Click(Sender:TObject);
begin
winexec(pchar(p),1);
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
if edit1.Text='' then
begin
showmessage('请写一个路径');
exit;
end;
p:=edit1.Text;
butt:=tbitbtn.Create(self);
butt.Width:=70;
butt.Left:=60;
butt.Height:=50;
butt.Top:=70;
butt.Parent:=form1;
butt.onClick:=Click;
end;
procedure TForm1.BitBtn2Click(Sender: TObject);
var
stream:tstream;
begin
stream:=tfilestream.Create('12.bb',fmcreate);
try
stream.WriteComponent(butt);
finally
stream.Free;
end;
end;
procedure TForm1.BitBtn3Click(Sender: TObject);
var
stream:tstream;
begin
stream:=tfilestream.Create('12.bb',fmopenread);
try
butt:=tbitbtn(stream.ReadComponent(nil));
butt.Parent:=form1;
butt.OnClick:=Click; //赋予butt的OnClick事件
p:=edit1.Text;
finally
stream.Free;
end;
end;
begin
registerclass(tbitbtn);
end.
posted on 2009-02-01 23:17
小叶子 阅读(572)
评论(0) 编辑 收藏 引用 所属分类:
delphi流的应用