AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren

Copy Text

Ein Thema von danten · begonnen am 28. Feb 2017 · letzter Beitrag vom 1. Mär 2017
Antwort Antwort
danten

Registriert seit: 19. Feb 2012
Ort: Czech Republic, Prag
126 Beiträge
 
Delphi 10.1 Berlin Architect
 
#1

Copy Text

  Alt 28. Feb 2017, 21:09
Hello,
Please, I need a copy Edit1 text character by character into Edit2 after a certain time, for example, 250 milliseconds.

Edit1.Text = 'this';
after 250 milliseconds Edit2.Text = 't' and after 250 milliseconds Edit2.Text = 'h' and after 250 milliseconds Edit2.Text = 'i' ....

Thank you
Daniel
  Mit Zitat antworten Zitat
Der schöne Günther

Registriert seit: 6. Mär 2013
6.093 Beiträge
 
Delphi 10 Seattle Enterprise
 
#2

AW: Copy Text

  Alt 28. Feb 2017, 21:30
This sounds rather trivial. What is your problem? You will need a variable for keeping track of which character (which index) has been copied to the other Edit so you know which one will be next.


What is your plan if text gets added or removed while the "transmission" to Edit 2 is still taking place?
  Mit Zitat antworten Zitat
t.roller
(Gast)

n/a Beiträge
 
#3

AW: Copy Text

  Alt 28. Feb 2017, 22:54
Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
var I , le : Integer;
begin
Edit1.Text:= 'this is a text';
Edit2.Text:= '';
   le:= Length(Edit1.Text);
   for I := 1 to le do
     BEGIN
      Edit2.Text:= Edit2.Text + copy(Edit1.Text,I,1);
      sleep(250); Application.ProcessMessages;
     END;
end;

// Better:
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
var I , le : Integer;
begin
  If Key = #13 then // Return
    begin
      Edit2.Text:= '';
      le:= Length(Edit1.Text);
     for I := 1 to le do
       BEGIN
        Edit2.Text:= Edit2.Text + copy(Edit1.Text,I,1);
        sleep(250); Application.ProcessMessages;
       END;
      Key := #0;
    end;
end;
(If You want) Replace sleep(250) by
Delphi-Quellcode:
procedure Wait250;
var
AlarmTimer : THandle;
Time : Large_Integer;
start, ende : Cardinal;
begin
AlarmTimer := CreateWaitableTimer(nil, False, nil);
CancelWaitableTimer(AlarmTimer);
Time.QuadPart := 25 * (-100000); // 250 msec
SetWaitableTimer(AlarmTimer, Time.Quadpart, 0, nil, nil, False);
while WaitForSingleObject(AlarmTimer, 50) <> Wait_Object_0 do
begin Application.ProcessMessages; end;
CloseHandle(AlarmTimer);
end;

procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
var I , le : Integer;
begin
  If Key = #13 then // Return
    begin
      Edit2.Text:= '';
      le:= Length(Edit1.Text);
     for I := 1 to le do
       BEGIN
        Edit2.Text:= Edit2.Text + copy(Edit1.Text,I,1);
        Wait250; //sleep(250);
        Application.ProcessMessages;
       END;
      Key := #0;
    end;
end;

Geändert von t.roller ( 1. Mär 2017 um 06:38 Uhr)
  Mit Zitat antworten Zitat
hoika

Registriert seit: 5. Jul 2006
Ort: Magdeburg
8.269 Beiträge
 
Delphi 10.4 Sydney
 
#4

AW: Copy Text

  Alt 1. Mär 2017, 06:02
Hello,
certain time -> use a timer
Heiko
  Mit Zitat antworten Zitat
Themen-Optionen Thema durchsuchen
Thema durchsuchen:

Erweiterte Suche
Ansicht

Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 18:56 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz