Hola Lepe.
Es correcta tu observación. Usar el método
Synchronize le da mas estabilidad al código, así que por más que haya sido solo un ensayo, se lo agregamos al amigo pokexperto1.
Código Delphi
[-]
type
TSpell = class(TThread)
private
FText : string;
FCount : Integer;
FTime : DWORD;
FInterval: Cardinal;
Memo : TMemo;
public
constructor Create; reintroduce; overload;
procedure Execute; override;
procedure WriteChar;
property Interval: Cardinal read FInterval write FInterval;
property Text: string read FText write FText;
end;
constructor TSpell.Create;
begin
inherited Create(True);
FTime := GetTickCount;
FCount := 0;
end;
procedure TSpell.WriteChar;
begin
Memo.Text := Memo.Text + FText[FCount];
end;
procedure TSpell.Execute;
begin
inherited;
while FCount <= Length(FText) do
begin
if GetTickCount - FTime > Interval then
begin
Inc(FCount);
Synchronize(WriteChar);
Application.ProcessMessages;
FTime := GetTickCount;
end;
end;
end;
procedure SpellText(const Texto: string; Memo: TMemo; const Interv: Integer);
var
spell: TSpell;
begin
spell := TSpell.Create(True);
try
spell.Memo := Memo;
spell.Text := Texto;
spell.Interval := Interv;
spell.Execute;
finally
spell.Free;
end;
end;
Saludos