Z
Z
Zulkund2016-07-19 07:29:49
Delphi
Zulkund, 2016-07-19 07:29:49

Delphi 7, How to create an infinite scrolling line?

Good afternoon! Tell me, how in Delphi 7 to create an endlessly running top-down line (Titles)? Several lines.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Anton Fedoryan, 2016-07-19
@Zulkund

var
  Form1: TForm1;
  list: TStringList;

procedure TForm1.FormCreate(Sender: TObject);
begin
  label1.Caption := '';
  label1.AutoSize := True;
  label1.Color := clInactiveBorder;

  list := TStringList.Create;

  list.Add('Титры');
  list.Add('Какой-то текст');
  list.Add('');
  list.Add('1');
  list.Add('2');
  list.Add('3');
  list.Add('');
  list.Add('4');
  list.Add('5');
end;

procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: boolean);
begin
  list.Free;
end;

procedure MoveTitle();
var
  item: string;
begin
  while (True) do
    begin
      if (Form1.Button1.Tag = 0) then
        exit;
      Form1.Label1.Caption := '';
      for item in list do
        begin
          Form1.label1.Caption := Form1.label1.Caption + #13 + item;
        end;

      list.Insert(0, list[list.Count - 1]);
      list.Delete(list.Count - 1);

      Application.ProcessMessages;
      Sleep(500);
    end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  if (button1.Tag = 0) then
    begin
      button1.Tag := 1;
      MoveTitle;
    end
  else
    button1.Tag := 0;
end;

K
kalapanga, 2016-07-19
@kalapanga

Formally, this elementary solution comes into question:
On the TMemo form Num lines high (exactly or there are more lines of text than lines on the screen). We fill in all Num lines, including empty ones. And then we turn them on the timer:
s := Memo1.Lines[Num-1];
Memo1.Lines.Delete(Num-1);
Memo1.Lines.Insert(0, s);
But, of course, you won’t get beautiful (smooth) titles that way.

A
Alex, 2016-07-19
@streetflush

1. We take the original string.
2. We take its last character.
3. Write to display.
4. We take the last 2 characters.
5. We write to the display
6 ..... x-1 And so on until the line ends.
X. Further goto to the 1st point.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question