Y
yjiqqukq
Unregistered / Unconfirmed
GUEST, unregistred user!
这是我的源代码:
unit TextMovedisp;
interface
uses Classes,comctrls,controls,graphics,SysUtils,ExtCtrls,Dialogs,QStdCtrls;
type
TextMove=class(TPanel) //实现字符的移动。
private
FLabel : TLabel;
FEdit:TEdit;
FTimer : TTimer;
FPanel : TPanel;
Finterval : cardinal; //用来设置 FTimer 的 interval
Fcaption : string;
procedure Setcaption(value:string);
procedure Setinterval(value:cardinal);
procedure onTimer(sender:Tobject);
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
published
property CaptionStr :string read Fcaption write Setcaption;
property interval:cardinal read Finterval write Setinterval;
end;
implementation
procedure TextMove.Setcaption(value:string);
begin
Fcaption:=value;
end;
procedure TextMove.Setinterval(value:cardinal);
begin
Ftimer.Interval :=value;
end;
{procedure TextMove.onTimer; //这是我在没有加 FLabel时做的测试,
begin
FPanel.Align :=alNone;
FPanel.Left :=FPanel.Left -8;
FPanel.Caption :=FCaption;
end; }
constructor TextMove.Create(Aowner:TComponent);
begin
inherited Create(Aowner);
FPanel:=TPanel.Create(self);
FPanel.Parent :=self;
FPanel.Left :=100;
FPanel.Top :=100;
FPanel.Width :=50;
FPanel.Height :=50;
FPanel.Enabled :=true;
FPanel.Visible :=true;
FPanel.Align :=alClient;
FPanel.Color :=clBtnFace;//clRed;
FPanel.Font.Color :=clRed;
Fpanel.Caption :='';
FTimer:= TTimer.Create(nil);
FTimer.Enabled :=true;
FTimer.Interval :=1000;
FTimer.OnTimer :=onTimer ;
FLabel :=TLabel.Create(self);
FLabel.Parent:=FPanel;// //[red]运行到这儿就有问题了 [/red]
FLabel.Left :=100;
FLabel.Top :=0;
FLabel.Width :=50;
FLabel.Height :=50;
FLabel.Font.Color :=clRed;
FLabel.Caption :='好好学习,天天向上';
FLabel.Enabled :=true;
FLabel.Visible :=true;
end;
destructor TextMove.Destroy ;
begin
FLabel.Free;
FTimer.Free;
FPanel.Free ;
inherited Destroy;
end;
end.
unit TextMovedisp;
interface
uses Classes,comctrls,controls,graphics,SysUtils,ExtCtrls,Dialogs,QStdCtrls;
type
TextMove=class(TPanel) //实现字符的移动。
private
FLabel : TLabel;
FEdit:TEdit;
FTimer : TTimer;
FPanel : TPanel;
Finterval : cardinal; //用来设置 FTimer 的 interval
Fcaption : string;
procedure Setcaption(value:string);
procedure Setinterval(value:cardinal);
procedure onTimer(sender:Tobject);
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
published
property CaptionStr :string read Fcaption write Setcaption;
property interval:cardinal read Finterval write Setinterval;
end;
implementation
procedure TextMove.Setcaption(value:string);
begin
Fcaption:=value;
end;
procedure TextMove.Setinterval(value:cardinal);
begin
Ftimer.Interval :=value;
end;
{procedure TextMove.onTimer; //这是我在没有加 FLabel时做的测试,
begin
FPanel.Align :=alNone;
FPanel.Left :=FPanel.Left -8;
FPanel.Caption :=FCaption;
end; }
constructor TextMove.Create(Aowner:TComponent);
begin
inherited Create(Aowner);
FPanel:=TPanel.Create(self);
FPanel.Parent :=self;
FPanel.Left :=100;
FPanel.Top :=100;
FPanel.Width :=50;
FPanel.Height :=50;
FPanel.Enabled :=true;
FPanel.Visible :=true;
FPanel.Align :=alClient;
FPanel.Color :=clBtnFace;//clRed;
FPanel.Font.Color :=clRed;
Fpanel.Caption :='';
FTimer:= TTimer.Create(nil);
FTimer.Enabled :=true;
FTimer.Interval :=1000;
FTimer.OnTimer :=onTimer ;
FLabel :=TLabel.Create(self);
FLabel.Parent:=FPanel;// //[red]运行到这儿就有问题了 [/red]
FLabel.Left :=100;
FLabel.Top :=0;
FLabel.Width :=50;
FLabel.Height :=50;
FLabel.Font.Color :=clRed;
FLabel.Caption :='好好学习,天天向上';
FLabel.Enabled :=true;
FLabel.Visible :=true;
end;
destructor TextMove.Destroy ;
begin
FLabel.Free;
FTimer.Free;
FPanel.Free ;
inherited Destroy;
end;
end.