I am trying to find a method for saving user created forms to files so
that they can be read back later. I know I saw a thread that included
information on doing this.
Thanks
--------------74874957F6FA3CD510929984
Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Derek Williams
Content-Disposition: attachment; filename="vcard.vcf"
begin: vcard
fn: Derek Williams
n: Williams;Derek
org: ENCORP, Inc.
adr: P.O. Box 269;;or: 621 Innovation Circle # D;Windsor;CO;80550;USA
email;internet: will...@encorp.com
title: Sr. Software Engineer
tel;work: 970 686 2017 x 205
tel;fax: 970 686 9416
tel;home: 970 416 8996
x-mozilla-cpt: ;0
x-mozilla-html: FALSE
version: 2.1
end: vcard
--------------74874957F6FA3CD510929984--
Something similar to the code in the following unit should get you started.
Note that the extension used in the saved (WriteComponentResFile) file is
unimportant. I use it because it is _not_ DFM and stands a reasonable chance
(on my system) of being unique.
unit InternU;
interface
uses
SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
Forms, Dialogs, StdCtrls, Buttons, TabNotBk, ExtCtrls, Tabs;
type
TFrmIntern = class(TForm)
Label1: TLabel;
ListBox1: TListBox;
BitBtn2: TBitBtn;
ListBox: TListBox;
Notebook: TNotebook;
TabSet: TTabSet;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Edit2: TEdit;
Edit3: TEdit;
procedure FormCreate(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
procedure TabSetChange(Sender: TObject; NewTab: Integer;
var AllowChange: Boolean);
procedure FormDestroy(Sender: TObject);
private { Private-Deklarationen }
constructor Create(AOwner: TComponent); override;
public { Public-Deklarationen }
end;
var
FrmIntern: TFrmIntern;
implementation
{$R *.DFM}
constructor TFrmIntern.Create(AOwner: TComponent);
begin
if FileExists('InternU.xGS') then begin
inherited CreateNew(AOwner) ;
ReadComponentResFile('InternU.xGS', FrmIntern) ;
FrmIntern.Visible := false;
FormCreate(self);
end
else
inherited Create(AOwner);
end;
procedure TFrmIntern.FormCreate(Sender: TObject);
var
i: integer;
begin
Randomize;
//Listbox2.Clear;
for i := 0 to Application.ComponentCount - 1 do begin
ListBox.Items.Add(Application.Components[i].ClassName);
end;
end;
procedure TFrmIntern.BitBtn2Click(Sender: TObject);
begin
Label1.Caption := Format('%.04d', [Random(43)]);
end;
procedure TFrmIntern.TabSetChange(Sender: TObject; NewTab: Integer;
var AllowChange: Boolean);
begin
Notebook.PageIndex := NewTab;
end;
procedure TFrmIntern.FormDestroy(Sender: TObject);
begin
WriteComponentResFile('InternU.xGS', self) ;
end;
end.
Regards
Ralph (TeamB)
Herrsching, Germany, Tue, 18 Nov 1997 08:39 +0100 CET