Einzelnen Beitrag anzeigen

Popov
(Gast)

n/a Beiträge
 
#2

AW: TButtonColor Speichern

  Alt 17. Apr 2015, 12:08
Kannst den Code nach Lust und Laune erweitern:
Delphi-Quellcode:
uses
  Registry;

function RegPath: String;
begin
  Result := ExtractFileName(ChangeFileExt(ParamStr(0), ''));
end;

procedure SaveFormSettings(Form: TForm);
var
  RegIni: TRegIniFile;
begin
  RegIni := TRegIniFile.Create(RegPath);
  try
    RegIni.WriteInteger('Form', 'Color', Form.Color);
  finally
    RegIni.Free;
  end;
end;

procedure LoadFormSettings(Form: TForm);
var
  RegIni: TRegIniFile;
begin
  RegIni := TRegIniFile.Create(RegPath);
  try
    Form.Color := RegIni.ReadInteger('Form', 'Color', Form.Color);
  finally
    RegIni.Free;
  end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  LoadFormSettings(Form1);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  Color := clRed;
  SaveFormSettings(Form1);
end;
  Mit Zitat antworten Zitat