DelphiFAQ Home Search:
General :: Programming :: Delphi :: VCL
About the Delphi VCL (Visual Component Library)

Articles:

This list is sorted by recent document popularity (not total page views).
New documents will first appear at the bottom.

Only the 40 most recently viewed articles are shown.
You can see the full list here.

Featured Article

Calling base class constructors and destructors

If you're writing a derived-class constructor, you'll want to pass the constructor parameters to the base class constructor, as in this example:

constructor TMyButton.Create(AOwner: TComponent);
 begin
   inherited Create(AOwner);
   { do custom things... }
 end; 
 

However, if your derived-class constructor has the same parameters as the base class constructor, you don't have to specify the constructor method name or parameters, and you can simply write:

constructor TMyButton.Create(AOwner: TComponent);
 begin
   inherited;
   { Do custom things... }
 end; 
 

Destructors: you usually should first free your custom allocated members etc. and then call the derived destructor:

destructor TMyButton.Destroy;
 begin
   { imagine, you'd have an TStringList member variable }
   aStringList.Free;
   inherited;
 end;
 


Generated 16:01:12 on May 28, 2020