whats new ¦  programming tips ¦  indy articles ¦  intraweb articles ¦  informations ¦  links ¦  interviews
 misc ¦  tutorials ¦  Add&Win Game

Tips (1541)

Database (90)
Files (137)
Forms (107)
Graphic (114)
IDE (21)
Indy (5)
Internet / LAN (130)
IntraWeb (0)
Math (76)
Misc (126)
Multimedia (45)
Objects/
ActiveX (51)

OpenTools API (3)
Printing (35)
Strings (83)
System (266)
VCL (242)

Top15

Tips sort by
component


Search Tip

Add new Tip

Add&Win Game

Advertising

37 Visitors Online


 
...use special lists instead of an array of TComponent/TClass/TObject?
Autor: Loïs Bégué
Homepage: http://www.arpoon.de
[ Print tip ]  

Tip Rating (6):  
     


{ Just a reminder...
++++++++++++++++++++++++ ENGLISH ++++++++++++++++++++++++++++++++++++++++++++++
Sometime you need to use at run time a list of component/object/class.
You may use a static array, a dynamic array or a TList to do the job.
Consider to use the "Delphi OOP Way" extended list classes as defined in the
unit Contnrs.pas:
 - TObjectList
 - TClassList
 - TComponentList
 - ...

That way, you'll never need to free your components yourself by code
when deleting an element from such a list: just add your elements and
set the Flag/Property "Owned" to "True"... The List will destroy your
component automatically if they are removed from the list.

++++++++++++++++++++++++ GERMAN  ++++++++++++++++++++++++++++++++++++++++++++++
Oft werden Listen von Objekten/Klassen/Komponenten in der laufenden Anwendung
mittels Arrays (dynamisch oder statisch) oder mittels der TList-Klasse verwaltet.
Es gibt einen besseren, "Delphi OOP" konformen Weg:
In der Unit Contnrs.pas sind folgende Klassen definiert:
 - TObjectList
 - TClassList
 - TComponentList
 - ...
Wenn sie beim Einfügen eines Elements in solchen Listen die Eingenschaft
"Owned" auf True setzen, dann brauchen Sie diese Objekte nicht explizit
freizugeben: Die Liste kümmert sicht darum, sobald das Element "deleted" wird.
}


 

Rate this tip:

poor
very good


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners