Eso es correcto. En realidad quiero hacer especie de traductor, logré que funcione usando Timer. te copio el código fuente:
unit ContraReciprocoFG2007;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls, ComCtrls;
type
TForm1 = class(TForm)
GroupBox1: TGroupBox;
Enviar: TRadioButton;
Recibir: TRadioButton;
PanelEntrada: TPanel;
lbAlpha: TListBox;
lbNuevo: TListBox;
Entrada: TRichEdit;
Label1: TLabel;
TiempoEnvia: TTimer;
lbVertical: TListBox;
PanelSalida: TPanel;
Salida: TRichEdit;
Label2: TLabel;
Traducir: TButton;
Limpiar: TButton;
Salir: TButton;
Contador: TLabel;
TiempoRecibe: TTimer;
procedure TraducirClick(Sender: TObject);
procedure TiempoEnviaTimer(Sender: TObject);
procedure LimpiarClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure SalirClick(Sender: TObject);
procedure EnviarClick(Sender: TObject);
procedure RecibirClick(Sender: TObject);
procedure TiempoRecibeTimer(Sender: TObject);
procedure ParaEnviar;
procedure ParaRecibir;
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
c:integer;
Ruta:string;
hago:string;
implementation
{$R *.dfm}
procedure TForm1.TraducirClick(Sender: TObject);
begin
if hago='Enviar' then ParaEnviar else
if hago='Recibir' then ParaRecibir;
c:=0;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Ruta:=ExtractFilePath(Application.ExeName);
hago:='';
c:=0;
end;
procedure TForm1.SalirClick(Sender: TObject);
begin
Application.Terminate;
end;
procedure TForm1.LimpiarClick(Sender: TObject);
begin
Entrada.Clear;
Salida.Clear;
lbVertical.Clear;
Contador.Caption:='0';
TiempoEnvia.Enabled:=False;
TiempoRecibe.Enabled:=False;
end;
procedure TForm1.ParaEnviar;
var i:integer;s:string;
begin
//******
Contador.Caption:='-1';
lbVertical.Clear;
Salida.Clear;
for i:=1 to Length(Entrada.Text) do
begin
s:=Entrada.Text;
lbVertical.Items.Add(s[i]);end;
TiempoEnvia.Enabled:=True;
end;
procedure TForm1.ParaRecibir;
var i:integer;s:string;
begin
Contador.Caption:='-1'; {................}
lbVertical.Clear;
Entrada.Clear;
for i:=1 to Length(Salida.Text) do
begin
s:=Salida.Text;
lbVertical.Items.Add(s[i]);end;
TiempoRecibe.Enabled:=True;
//*******
end;
procedure TForm1.TiempoEnviaTimer(Sender: TObject);
var itV:string[1];itA:integer;
begin
if (c<lbVertical.Items.Count-1) then begin
Contador.Caption:=IntToStr(StrToInt(Contador.Caption)+1);
c:=StrToInt(Contador.Caption);
itV:=lbVertical.Items[c];
itA:=lbAlpha.Items.IndexOf(itV);
//***Controla error
Salida.Text:=Salida.Text+lbNuevo.Items[itA]; end;
if c=lbVertical.Items.Count-1 then begin
TiempoEnvia.Enabled:=False;
ShowMessage('Todo se ha transcrito'); end;
end;
//*********************************************************
procedure TForm1.TiempoRecibeTimer(Sender: TObject);
var itV:string[1];itN:integer;
begin
if (c<lbVertical.Items.Count-1) then begin
Contador.Caption:=IntToStr(StrToInt(Contador.Caption)+1);
c:=StrToInt(Contador.Caption);
itV:=lbVertical.Items[c];
itN:=lbNuevo.Items.IndexOf(itV);
Entrada.Text:=Entrada.Text+lbAlpha.Items[itN];end;
if c=lbVertical.Items.Count-1 then begin
TiempoRecibe.Enabled:=False;
ShowMessage('Todo se ha transcrito'); end;
end;
procedure TForm1.EnviarClick(Sender: TObject);
begin
hago:='Enviar';
Salida.ReadOnly:=True;
Entrada.ReadOnly:=False;
Contador.Caption:='-1';
end;
procedure TForm1.RecibirClick(Sender: TObject);
begin
hago:='Recibir';
Contador.Caption:='-1';
Entrada.ReadOnly:=True;
Salida.ReadOnly:=False;
end;
end.