The base class type that is ancestor to all other classes System unit
  type TObject = class
    constructor Create;
    destructor Destroy; virtual;
The TObject type defines the base class type. It is the oldest grandparent of all classes - every class is ultimately derived from TObject.
Because of this, every object inherits the methods of TObject.
The TObject methods fall into two categories - class and non-class. When prefixed by the keyword Class, a method may be called in both an object of the class, and in the class itself. Such a static method cannot access any class fields because a class has no data itself - only instantiated classes - objects - have data.
Some key Class (static) methods:
function ClassName  Gives the class name as a string
ClassParent  Gives the class parent name
ClassInfo  Gives class Run Time info
InstanceSize  Size of class object in bytes
NewInstance  Creates a new class object

Some key Object methods:
Create  Empty object creator
Free  Calls Destroy for a non-nil object ref
Destroy  Releases object storage
AfterConstruction  Called after construction
BeforeDestruction  Called before destruction
Related commands
Class Starts the declaration of a type of object class
Printer Returns a reference to the global Printer object
 Author links

 Buy Website Traffic at

 Buy Proxies at
 Download this web site as a Windows program.

Example code : Using TObject methods inherited in a TForm subclass
// Full Unit code.
// -----------------------------------------------------------
// You must store this code in a unit called Unit1 with a form
// called Form1 that has an OnCreate event called FormCreate.
unit Unit1;
  // The System unit does not need to be defined
  Forms, Dialogs;
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
Form1: TForm1;
{$R *.dfm} // Include form definitions
procedure TForm1.FormCreate(Sender: TObject);

  // The unit form was derived from TObject.
  // So we can use methods of TObject:
  ShowMessage('Form1 object class name = '+
  ShowMessage('Form1 object class parent name = '+
  ShowMessage('Form1 object instance size = '+

  // And now on TObject itself
  ShowMessage('TObject class name = '+
  ShowMessage('TObject instance size = '+
Hide full unit code
   Form1 object class name = TForm1
   Form1 object parent class name = TForm
   Form1 object instance size = 764
   TObject class name = TObject
   TObject instance size = 4
Delphi Programming Neil Moffatt 2002 - 2017. All rights reserved.  |  Home Page