azrael_11 0 Posted April 25, 2021 Based to this Implementing Object Persistence using Streams i think i manage to save all the runtime created components of my form in a dat file. with this code when the form closes procedure TForm.FormClose(Sender: TObject; var Action: TCloseAction); var strm: TFileStream; vi: integer; begin strm := TFileStream.Create('MyComponentList.txt', fmCreate); for vi := 0 to ComponentCount - 1 do strm.WriteComponent(Components[vi]); strm.Free; end; Now how can i load all the components in FormCreate or In FormShow event. In tutorial can read-load a component by its name. So how can i get the name of all components in the dat file so i can read-load? Share this post Link to post
Pat Foley 51 Posted April 25, 2021 Try streaming Tpanel with child objects in it object Panel1: TPanel Left = 536 Top = 24 Width = 251 Height = 106 Caption = 'Panel1' ParentBackground = False TabOrder = 0 object Button2: TButton Left = 24 Top = 16 Width = 75 Height = 25 Caption = 'Button1' TabOrder = 0 OnClick = Button1Click end object Edit1: TEdit Left = 112 Top = 72 Width = 121 Height = 21 TabOrder = 1 Text = 'Edit1' end end Simply copy paste these into a form in design window. then follow delphi - How to save and restore a form? - Stack Overflow 1 Share this post Link to post
Remy Lebeau 1394 Posted April 26, 2021 On 4/25/2021 at 2:17 AM, azrael_11 said: Based to this Implementing Object Persistence using Streams i think i manage to save all the runtime created components of my form in a dat file. That article is written for saving a single component to a file, not for saving multiple components. I would suggest saving the TForm itself rather than each of its child components individually. 1 Share this post Link to post
azrael_11 0 Posted April 27, 2021 20 hours ago, Remy Lebeau said: I would suggest saving the TForm itself rather than each of its child components individually. I think this is the best way. Thanks Share this post Link to post