unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
var
ed:tedit;
procedure TForm1.FormCreate(Sender: TObject);
begin
button1.Caption:='创建';
button2.Caption:='保存';
button3.Caption:='载入';
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
//创建一个edit
ed:=tedit.Create(self);
ed.Height:=20;
ed.Width:=150;
ed.Top:=50;
ed.Left:=70;
ed.Parent:=form1;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
stream:tstream;
begin
//保存在一个文件内
stream:=tfilestream.Create('123.bb',fmcreate);
try
stream.WriteComponent(ed);
finally
stream.Free;
end;
end;
procedure TForm1.Button3Click(Sender: TObject);
var
stream:tstream;
begin
//从文件内导入
stream:=tfilestream.Create('123.bb',fmopenread);
try
ed:=tedit(stream.ReadComponent(nil));
ed.Parent:=form1;
finally
stream.Free;
end;
end;
begin
registerclass(tedit);
end.
posted on 2009-02-01 00:57
小叶子 阅读(828)
评论(0) 编辑 收藏 引用 所属分类:
delphi流的应用