Hola!! Llevo varios días intentándolo y no doy con las opciones... ¿Seria posible hacer un bucle para guardar estos Edit's y Label's en el mismo orden?
Código Delphi
[-]
procedure TFormConfig.FormClose(Sender: TObject; var Action: TCloseAction);
begin
with TStringList.Create do
try
Add(Edit1.Text);
Add(Label1.Caption);
Add(Edit2.Text);
Add(Label2.Caption);
Add(Edit3.Text);
Add(Label3.Caption);
Add(Edit4.Text);
Add(Label4.Caption);
Add(Edit5.Text);
Add(Label5.Caption);
Add(Edit6.Text);
Add(Label6.Caption);
Add(Edit7.Text);
Add(Label7.Caption);
Add(Edit8.Text);
Add(Label8.Caption);
Add(Edit9.Text);
Add(Label9.Caption);
Add(Edit10.Text);
Add(Label10.Caption);
Add(Edit11.Text);
Add(Label11.Caption);
Add(Edit12.Text);
Add(Label12.Caption);
Add(Edit13.Text);
Add(Label13.Caption);
Add(Edit14.Text);
Add(Label14.Caption);
SaveToFile(ExtractFilePath(Application.ExeName)+'config.txt');
finally
Free;
end;
Para abrir el .txt si lo conseguí con este código:
Código Delphi
[-]
procedure TFormConfig.FormCreate(Sender: TObject);
var
List:TStringList;
i,j,c:Integer;
begin
i:=0;
j:=1;
List := TStringList.Create;
try
if FileExists(ExtractFilePath(Application.ExeName)+'config.txt') = True then
begin
List.LoadFromFile(ExtractFilePath(Application.ExeName)+'config.txt');
for c := 0 to FormConfig.ComponentCount-1 do
begin
if FormConfig.Components[c].ClassName = 'TEdit' then
begin
TEdit(FormConfig.Components[c]).Text := List[i];
i := i+2;
end
else if FormConfig.Components[c].ClassName = 'TLabel' then
begin
TLabel(FormConfig.Components[c]).Caption := List[j];
j := j+2;
end;
end;
end;
finally
List.Free;
end;
end;
Gracias!!