RAD Studio VCL Reference
TControl.Destroy Destructor

Destroys an instance of TControl.

destructor Destroy; override;
virtual __fastcall ~TControl();

Do not call Destroy directly in an application. Instead, call Free. Free verifies that the control is not nil, and only then calls Destroy. 

Applications should only free controls explicitly when the constructor was called without assigning an owner to the control. 

As the control is destroyed, it: 

Frees the TFont object in its Font property. 

Calls its inherited destructor. 

Override Destroy to free any memory or resources allocated in the Create method. When declaring a Destroy method in a descendant control type, always add the override directive to the declaration and call the inherited Destroy as the last statement in the redeclared method. 

When a control is created, Delphi automatically provides exception handling around the constructor call. The destructor is called if an exception escapes from the constructor. This means that the destructor code must be prepared to clean up a partially constructed instance. Check all data fields for zero before disposing of their contents. 


Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!