delphi: how to to store TCustomFrames and records in one list -


i using tobjectlist<tcustomframe> store tcustomframes. want store more information regarding tcustomframe in same list. record nice.

which delphi class prefer store tcustomframes , records in same list?

the tcustomframes , records added @ runtime.

create single record hold information:

type    tframeinfo = record     frame: tcustomframe;     foo: string;     bar: integer;   end; 

hold in tlist<tframeinfo>.

i note using tobjectlist<t> rather tlist<t>. reason doing if setting ownsobjects true. seems unlikely since doubt list in charge of lifetime of gui objects. note future, if find using tobjectlist<t> ownsobjects set false may switch tlist<t>.

now, in case need list control lifetime you'd best using class rather record tframeinfo.

type    tframeinfo = class   private     fframe: tcustomframe;     ffoo: string;     fbar: integer;   public     constructor create(aframe: tcustomframe; afoo: string; abar: integer);     destructor destroy; override;     property frame: tcustomframe read fframe;     // etc.   end;    constructor tframeinfo.create(aframe: tcustomframe; afoo: string; abar: integer);   begin     inherited create;     fframe := aframe;     // etc.   end;    destructor tframeinfo.destroy;    begin     fframe.free;     inherited;   end; 

and hold in tobjectlist<tframeinfo> ownsobjects set true.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -