Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'Coded by VANS -=VANS-SOFT.RU=-'
- //===================================================================
- USES: iniFiles;
- Глобальная переменная: ini:TIniFile;
- //===================================================================
- procedure TForm1.FormCreate(Sender: TObject);
- begin
- ini:=TIniFile.Create(ExtractFilePath(Application.ExeName)+'set.ini');
- LoadFields(Form1);
- end;
- procedure LoadFields(AParent: TWinControl);
- var i:integer;
- begin
- for i:=0 to AParent.ControlCount-1 do begin
- if AParent.Controls[i] is TsPanel then LoadFields(TsPanel(AParent.Controls[i]));
- if AParent.Controls[i] is TsFilenameEdit then TsFilenameEdit(AParent.Controls[i]).Text:=ini.ReadString('settings', AParent.Controls[i].Name, '');
- if AParent.Controls[i] is TsEdit then TsEdit(AParent.Controls[i]).Text:=ini.ReadString('settings', AParent.Controls[i].Name, '');
- if AParent.Controls[i] is TsSpinEdit then TsSpinEdit(AParent.Controls[i]).Value:=ini.ReadInteger('settings', AParent.Controls[i].Name, 1000);
- if AParent.Controls[i] is TsCheckBox then TsCheckBox(AParent.Controls[i]).Checked:=ini.ReadBool('settings', AParent.Controls[i].Name, false);
- if AParent.Controls[i] is TsRadioButton then TsRadioButton(AParent.Controls[i]).Checked:=ini.ReadBool('settings', AParent.Controls[i].Name, false);
- end;
- end;
- procedure SaveFields(AParent: TWinControl);
- var i:integer;
- begin
- for i:=0 to AParent.ControlCount-1 do begin
- if AParent.Controls[i] is TsPanel then SaveFields(TsPanel(AParent.Controls[i]));
- if AParent.Controls[i] is TsFilenameEdit then ini.WriteString('settings', AParent.Controls[i].Name, TsFilenameEdit(AParent.Controls[i]).Text);
- if AParent.Controls[i] is TsEdit then ini.WriteString('settings', AParent.Controls[i].Name, TsEdit(AParent.Controls[i]).Text);
- if AParent.Controls[i] is TsSpinEdit then ini.WriteInteger('settings', AParent.Controls[i].Name, TsSpinEdit(AParent.Controls[i]).Value);
- if AParent.Controls[i] is TsCheckBox then ini.WriteBool('settings', AParent.Controls[i].Name, TsCheckBox(AParent.Controls[i]).Checked);
- if AParent.Controls[i] is TsRadioButton then ini.WriteBool('settings', AParent.Controls[i].Name, TsRadioButton(AParent.Controls[i]).Checked);
- end;
- end;
- procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
- begin
- SaveFields(Form1);
- ini.Free;
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement