AniEdit.pas
上传用户:psxgmh
上传日期:2013-04-08
资源大小:15112k
文件大小:2k
- unit AniEdit;
- interface
- uses
- Windows, Messages, SysUtils, Classes, Controls, Forms, StdCtrls, ExtCtrls, Graphics;
- type
- TAniEdit = class(TEdit)
- private
- FInterval: Integer;
- FTimer: TTimer;
- procedure MoveShow(Sender: TObject);
- public
- constructor Create(AOwner: TComponent);
- procedure StartAni;
- procedure StopAni;
- published
- property Interval: Integer read FInterval write FInterval;
- end;
- procedure Register;
- implementation
- 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.StartAni;
- begin
- FTimer.Interval := FInterval;
- FTimer.Enabled := True;
- end;
- procedure TAniEdit.StopAni;
- begin
- FTimer.Enabled := False;
- 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 Register;
- begin
- RegisterComponents('Samples', [TAniEdit]);
- end;
- end.