刚写的一个完整例子,D6调试通过。
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;
type
TForm1 = class(TForm)
Memo1: TMemo;
Button1: TButton;
Timer1: TTimer;
OpenDialog1: TOpenDialog;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
slTEMP:TStrings;
nId,nCount:Integer;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
slTEMP:=TStringList.Create;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
slTEMP.Free;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if OpenDialog1.Execute then
begin
Timer1.Enabled:=False;
slTEMP.LoadFromFile(OpenDialog1.FileName);
nCount:=Length(slTEMP.Text);
nId:=1;
Timer1.Enabled:=True;
end;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
if nId<=nCount then
begin
Memo1.Text:=Memo1.Text+slTEMP.Text[nId];
inc(nId);
end else
Timer1.Enabled:=False;
end;
end.