OK, haltet euch fest, hier kommt es:
Delphi-Quellcode:
...
const
SectionSystem = 'System';
KeyFormLeft = 'FormLeft';
KeyFormTop = 'FormTop';
...
procedure TForm1.FormCreate(Sender: TObject);
begin
Form1.Left := 100;
Form1.Top := 100;
end;
procedure TForm1.FormDestroy(Sender: TObject);
var savestat: TIniFile;
begin
savestat := TIniFile.Create(ExtractFilepath(Application.Exename)+'settings.ini');
try
savestat.WriteInteger(SectionSystem, KeyFormLeft, Form1.Left);
savestat.WriteInteger(SectionSystem, KeyFormTop, Form1.Top);
finally
savestat.Free;
end;
end;
procedure TForm1.FormActivate(Sender: TObject);
var savestat: TIniFile;
begin
savestat := TIniFile.Create(ExtractFilepath(Application.Exename)+'settings.ini');
try
Form1.Left:= savestat.ReadInteger(SectionSystem, KeyFormLeft, 0);
Form1.Top:= savestat.ReadInteger(SectionSystem, KeyFormTop, 0);
finally
savestat.Free;
end;
end;