Hola ZaneMs.
Creo que te sería mas simple usar
TStringsList para manipular el archivo de texto, por ejemplo:
Código Delphi
[-]
procedure TForm1.CrearBotones(aFileName: TFileName);
var
c,b: Integer;
begin
with TStringList.Create do
try
LoadFromFile(aFileName);
c:= 0;
b:= 1;
while (c < Count) do
begin
if Strings[c] = 'ButtonCtrl' then
with TButton.Create(Self) do
begin
Parent:= Self;
Name:= 'MiBoton'+IntToStr(b);
Left:= StrToIntDef(Strings[c+1],0);
Top := StrToIntDef(Strings[c+2],0);
Inc(c);
Inc(b);
end;
Inc(c);
end;
finally
Free;
end;
end;
Pero de todos modos no te recomiendo trabajarlo de ese modo.
Delphi dispone de las clases
TIniFile y
TRegistry que hacen esa tarea mas simple y segura. Un ejemplo usando IniFiles:
Código Delphi
[-]
...
uses IniFiles;
const
INIFIL = 'C:\CARPETA\ARCHIVO.INI';
procedure CrearIniFile;
var
Ini: TIniFile;
i: Integer;
s: string;
begin
with TIniFile.Create(INIFIL) do
try
for i:= 1 to 5 do
begin
s:= 'MiBoton'+IntToStr(i);
WriteString(s, 'Name', s);
WriteInteger(s,'Left',100);
WriteInteger(s,'Top', 50*i+25);
WriteInteger(s,'Height',25);
WriteInteger(s,'Width',90);
WriteString(s,'Caption', s);
end;
finally
Free;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
var
i: Integer;
s: string;
begin
if not FileExists(INIFIL) then CrearIniFile; with TIniFile.Create(INIFIL) do
try
for i:= 1 to 5 do
begin
with TButton.Create(Self) do
begin
Parent:= Self;
s:= 'MiBoton'+IntToStr(i);
Name:= ReadString(s,'Name','');
Left:= ReadInteger(s,'Left',0);
Top:= ReadInteger(s,'Top',0);
Height:= ReadInteger(s,'Height',25);
Width:= ReadInteger(s,'Width',70);
Caption:= ReadString(s,'Caption','Botón');
end;
end;
finally
Free;
end;
end;
...
Como te mencioné mas arriba lo mismo podes hacer usando
TRegistry, en este enlace:
referencia de tedit en TComponentList tenes un ejemplo con ambos modos.
Saludos
![Smilie](http://www.clubdelphi.com/foros/images/smilies/smile.gif)