Einzelnen Beitrag anzeigen

grenzgaenger
(Gast)

n/a Beiträge
 
#14

Re: EDIT Inhalte in Datei abspeichern und wieder laden

  Alt 5. Jan 2008, 14:40
hier 'n serializierungsbeispiel

Delphi-Quellcode:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    bClear: TButton;
    bSave: TButton;
    bLoad: TButton;
    procedure bClearClick(Sender: TObject);
    procedure bSaveClick(Sender: TObject);
    procedure bLoadClick(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.bClearClick(Sender: TObject);
begin
 Edit1.Text := '';
 Edit2.Text := '';
 edit3.text := '';
end;

procedure TForm1.bLoadClick(Sender: TObject);
var
 fs: tFileStream;
begin
  fs := tFileStream.Create(paramstr(0)+'.save', fmOpenReadWrite);
  fs.ReadComponent(edit1);
  fs.ReadComponent(edit2);
  fs.ReadComponent(edit3);
  fs.free;
end;

procedure TForm1.bSaveClick(Sender: TObject);
var
 fs: tFileStream;
begin
 fs := tFileStream.Create(paramstr(0)+'.save', fmCreate or fmOpenReadWrite);
 fs.WriteComponent(edit1);
 fs.WriteComponent(edit2);
 fs.WriteComponent(edit3);
 fs.free;
end;

end.
  Mit Zitat antworten Zitat