Author: Jonas Bilinkevicius I would like to know how to save a forms appearance once it has been changed by a user. Answer: 1 unit Unit1; 2 3 interface 4 5 uses 6 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, 7 StdCtrls, 8 ExtCtrls; 9 10 type 11 TForm1 = class(TForm) 12 Edit1: TEdit; 13 Edit2: TEdit; 14 Edit3: TEdit; 15 Memo1: TMemo; 16 CheckBox1: TCheckBox; 17 CheckBox2: TCheckBox; 18 CheckBox3: TCheckBox; 19 RadioGroup1: TRadioGroup; 20 Button1: TButton; 21 procedure Button1Click(Sender: TObject); 22 procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean); 23 private 24 function FormFilename: string; 25 public 26 constructor Create(aOwner: TComponent); override; 27 end; 28 29 var 30 Form1: TForm1; 31 32 implementation 33 34 {$R *.DFM} 35 36 procedure TForm1.Button1Click(Sender: TObject); 37 begin 38 close 39 end; 40 41 procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean); 42 var 43 fs: TFilestream; 44 begin 45 fs := TFilestream.Create(FormFilename, fmCreate); 46 try 47 fs.WriteComponent(self); 48 finally 49 fs.free; 50 end; 51 end; 52 53 function TForm1.FormFilename: string; 54 begin 55 Result := ExtractFilePath(ParamStr(0)) + Classname + '.DAT'; 56 end; 57 58 constructor TForm1.Create(aOwner: TComponent); 59 var 60 fs: TFileStream; 61 fname: string; 62 begin 63 fname := FormFilename; 64 if FileExists(fname) then 65 begin 66 CreateNew(aOwner); 67 fs := TFileStream.Create(fname, fmOpenread or fmShareDenyWrite); 68 try 69 fs.ReadComponent(self); 70 finally 71 fs.free; 72 end; 73 end 74 else 75 inherited Create(aOwner); 76 end; 77 78 end.