解决方法
您可能会使用TTimer.在表单上删除TTimer,TMemo和TButton.然后做
var lines: TStringList; pos: TPoint; const CHAR_INTERVAL = 75; PARAGRAPH_INTERVAL = 1000; procedure TForm6.Button1Click(Sender: TObject); const S_EMPTY_FILE = 'You are trying to display an empty file!'; begin Memo1.ReadOnly := true; Memo1.Clear; Memo1.Lines.Add(''); pos := Point(0,0); if lines.Count = 0 then raise Exception.Create(S_EMPTY_FILE); while (pos.Y < lines.Count) and (length(lines[pos.Y]) = 0) do inc(pos.Y); if pos.Y = lines.Count then raise Exception.Create(S_EMPTY_FILE); NextCharTimer.Enabled := true; end; procedure TForm6.FormCreate(Sender: TObject); begin lines := TStringList.Create; lines.LoadFromFile('C:\Users\Andreas Rejbrand\Desktop\Test.txt'); end; procedure TForm6.NextCharTimerTimer(Sender: TObject); begin NextCharTimer.Interval := CHAR_INTERVAL; Memo1.Lines[Memo1.Lines.Count - 1] := Memo1.Lines[Memo1.Lines.Count - 1] + lines[pos.Y][pos.X + 1]; inc(pos.X); if pos.X = length(lines[pos.Y]) then begin NextCharTimer.Interval := PARAGRAPH_INTERVAL; pos.X := 0; repeat inc(pos.Y); Memo1.Lines.Add(''); until (pos.Y = lines.Count) or (length(lines[pos.Y]) > 0); end; if pos.Y = lines.Count then NextCharTimer.Enabled := false; end;