自定义控件问题,请大虾帮忙 ( 积分: 50 )

  • 主题发起人 主题发起人 wanshi131
  • 开始时间 开始时间
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.
 
包的名字是不是也叫AniEdit,包的名字和.pas文件的名字重名了,把包换个名字,例如换成MyAniEdit.dpk
 
谢谢,解决了!
 
接受答案了.
 

Similar threads

I
回复
0
查看
648
import
I
S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
743
import
I
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
后退
顶部