uses IniFiles; // <- important ! var PathAppli: string; IniFile: TIniFile; procedure TForm1.FormCreate(Sender: TObject); begin PathAppli := ExtractFilePath(Application.ExeName); IniFile := TIniFile.Create(PathAppli + 'SaveParams.ini'); try Panel1.Left := IniFile.ReadInteger('Panel1', 'Left', Panel1.Left); Panel1.Top := IniFile.ReadInteger('Panel1', 'Top', Panel1.Top); finally IniFile.Free; end end; procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction); begin IniFile := TIniFile.Create(PathAppli + 'SaveParams.ini'); try IniFile.WriteInteger('Panel1', 'Left', Panel1.Left); IniFile.WriteInteger('Panel1', 'Top', Panel1.Top); finally IniFile.Free; end end;
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionuses IniFiles; var PathAppli: string; IniFile: TIniFile; procedure TForm1.FormCreate(Sender: TObject); var i: Integer; begin PathAppli := ExtractFilePath(Application.ExeName); IniFile := TIniFile.Create(PathAppli + 'SaveParams.ini'); try for i := 1 to 100 do begin with TPanel(FindComponent('Panel' + IntToStr(i))) do begin Left := IniFile.ReadInteger('Panel' + IntToStr(i), 'Left', Left); Top := IniFile.ReadInteger('Panel' + IntToStr(i), 'Top', Top); end; end; finally IniFile.Free; end; end; procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction); var i: Integer; begin IniFile := TIniFile.Create(PathAppli + 'SaveParams.ini'); try for i := 1 to 100 do begin with TPanel(FindComponent('Panel' + IntToStr(i))) do begin IniFile.WriteInteger('Panel' + IntToStr(i), 'Left', Left); IniFile.WriteInteger('Panel' + IntToStr(i), 'Top', Top); end; end; finally IniFile.Free; end; end;