A
awfigsk
Unregistered / Unconfirmed
GUEST, unregistred user!
unit Unit1
interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Unit2, ExtCtrls
type TForm1 = class(TForm) Button1: TButton
Button2: TButton
Panel1: TPanel
Label1: TLabel
procedure Button1Click(Sender: TObject)
procedure Button2Click(Sender: TObject)
private { Private declarations } public { Public declarations } end
var Form1: TForm1
implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject)
var s:Tmemorystream
rr:Twriter
ff:TFrame2
begin ff:=TFrame2.Create (self)
ff.Parent :=Panel1
s:=Tmemorystream.Create
s.WriteComponent(ff)
s.SaveToFile('a')
s.Free
end
procedure TForm1.Button2Click(Sender: TObject)
var s:Tmemorystream
ff:TFrame2
begin classes.RegisterClass(TFrame2)
s:=Tmemorystream.Create
s.LoadFromFile('a')
ff := TFrame2(TFrame.Create(Self))
ff.Parent :=self
s.ReadComponent(ff)
s.Free
end;
为什么要RegisterClass(TFrame2)?我在interface引用了Unit2呀,上述代码执行后,报错,提示'Class TLabel not found',这是为何?也要RegisterClass(TLabel)吗?为什么呢?在TForm的Publisher部分有TLabel呀
不明白,还请各位大侠指点,谢谢!
interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Unit2, ExtCtrls
type TForm1 = class(TForm) Button1: TButton
Button2: TButton
Panel1: TPanel
Label1: TLabel
procedure Button1Click(Sender: TObject)
procedure Button2Click(Sender: TObject)
private { Private declarations } public { Public declarations } end
var Form1: TForm1
implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject)
var s:Tmemorystream
rr:Twriter
ff:TFrame2
begin ff:=TFrame2.Create (self)
ff.Parent :=Panel1
s:=Tmemorystream.Create
s.WriteComponent(ff)
s.SaveToFile('a')
s.Free
end
procedure TForm1.Button2Click(Sender: TObject)
var s:Tmemorystream
ff:TFrame2
begin classes.RegisterClass(TFrame2)
s:=Tmemorystream.Create
s.LoadFromFile('a')
ff := TFrame2(TFrame.Create(Self))
ff.Parent :=self
s.ReadComponent(ff)
s.Free
end;
为什么要RegisterClass(TFrame2)?我在interface引用了Unit2呀,上述代码执行后,报错,提示'Class TLabel not found',这是为何?也要RegisterClass(TLabel)吗?为什么呢?在TForm的Publisher部分有TLabel呀
不明白,还请各位大侠指点,谢谢!