W
wanshi131
Unregistered / Unconfirmed
GUEST, unregistred user!
我自定义的一个组件,最后安装的时候出现错误,请大家看看。
错误是:[Fatal Error] AniEdit.pas(1): Program or unit 'AniEdit.pas' recursively uses itself
代码如下:
unit AniEdit;
interface
uses
Windows, Messages, ExtCtrls, Graphics, SysUtils, Classes, Controls, StdCtrls;
type
TAniEdit = class(TEdit)
private
{ Private declarations }
FInterval: integer;
FTimer: TTimer;
procedure MoveShow(Sender: TObject);
protected
{ Protected declarations }
public
{ Public declarations }
constructor Create(AOwner: TComponent);
procedure StartAni;
procedure StopAni;
published
{ Published declarations }
property interval: integer read FInterval write FInterval;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Samples', [TAniEdit]);
end;
{ TAniEdit }
constructor TAniEdit.Create(AOwner: TComponent);
begin
inherited create(aowner);
color := clBlack;
font.Color := clWhite;
font.Size := 12;
font.Name := '仿宋_GB2312';
tabstop := false;
update;
FTimer := TTimer.Create(self);
FTimer.Enabled := false;
FTimer.OnTimer := MoveShow;
FInterval := 1000;
end;
procedure TAniEdit.MoveShow(Sender: TObject);
var
edit_length, i: integer;
edit_char: char;
chars: string;
begin
chars := '';
if length(text) = 0 then
text := 'Welcom you to use the software!';
edit_length := length(text);
edit_char := text[1];
//判断首字符是英文字母还是汉字
if Ord(edit_char) > 127 then
begin
//如果是汉字就拷贝两个字符,代表一个汉字
chars := copy(text, 1, 2);
text := copy(text, 3, edit_length - 1) + chars;
end
else
//如果是英文字符的话,就拷贝一个字符
text := copy(text, 2, edit_length - 1) + edit_char;
end;
procedure TAniEdit.StartAni;
begin
FTimer.Interval := FInterval;
FTimer.Enabled := true;
end;
procedure TAniEdit.StopAni;
begin
FTimer.Enabled := false;
end;
end.
错误是:[Fatal Error] AniEdit.pas(1): Program or unit 'AniEdit.pas' recursively uses itself
代码如下:
unit AniEdit;
interface
uses
Windows, Messages, ExtCtrls, Graphics, SysUtils, Classes, Controls, StdCtrls;
type
TAniEdit = class(TEdit)
private
{ Private declarations }
FInterval: integer;
FTimer: TTimer;
procedure MoveShow(Sender: TObject);
protected
{ Protected declarations }
public
{ Public declarations }
constructor Create(AOwner: TComponent);
procedure StartAni;
procedure StopAni;
published
{ Published declarations }
property interval: integer read FInterval write FInterval;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Samples', [TAniEdit]);
end;
{ TAniEdit }
constructor TAniEdit.Create(AOwner: TComponent);
begin
inherited create(aowner);
color := clBlack;
font.Color := clWhite;
font.Size := 12;
font.Name := '仿宋_GB2312';
tabstop := false;
update;
FTimer := TTimer.Create(self);
FTimer.Enabled := false;
FTimer.OnTimer := MoveShow;
FInterval := 1000;
end;
procedure TAniEdit.MoveShow(Sender: TObject);
var
edit_length, i: integer;
edit_char: char;
chars: string;
begin
chars := '';
if length(text) = 0 then
text := 'Welcom you to use the software!';
edit_length := length(text);
edit_char := text[1];
//判断首字符是英文字母还是汉字
if Ord(edit_char) > 127 then
begin
//如果是汉字就拷贝两个字符,代表一个汉字
chars := copy(text, 1, 2);
text := copy(text, 3, edit_length - 1) + chars;
end
else
//如果是英文字符的话,就拷贝一个字符
text := copy(text, 2, edit_length - 1) + edit_char;
end;
procedure TAniEdit.StartAni;
begin
FTimer.Interval := FInterval;
FTimer.Enabled := true;
end;
procedure TAniEdit.StopAni;
begin
FTimer.Enabled := false;
end;
end.