The simplified diagram below shows the inheritance hierarchy between Delphi's classes for
objects, components, and controls.
TObject: the ultimate ancestor of all classes. It encapsulates fundamental behavior common to all objects,
by introducing methods that:
Note: if the declaration of a class type does not specify an ancestor, the class inherits directly from TObject.
- Create, maintain, and destroy instances of objects by allocating, initializing, and freeing required memory.
- Respond when object instances are created or destroyed.
- Support message handling.
type TMyClass = class
is equivalent to:
type TMyClass = class(TObject)
TPersistent: the ancestor for classes of objects that have streaming capabilities, meaning that they can read
and write their properties to and from a form file (.dfm file).
TComponent: the ancestor for all component classes.
A component is a persistent object that can appear on the IDE
palette and that can be manipulated in a Form Designer.
A component can have the ability to "own" other components. If Form1 owns Panel1, then Form1 is responsible for
destroying Panel1 when the form Form1 is destroyed.
Components that can be visible at run time are sometimes called visual components. Other components, which are never
visible at run time, are sometimes called non-visual components (such as TTimer).
TControl: for components that are visible at run time.
A control is a visual component, meaning that you can see it and possibly interact with it at run time.
All controls have properties, methods, and events that describe aspects of their appearance, such as the position
of the control (Left, Top), its dimensions, methods to paint or move the control, and events that respond to
TWinControl: the ancestor for all classes that are wrappers for MS Windows screen objects ("windows").
A WinControl has a "window handle", such as TEdit, TListBox and TButton.
A WinControl can receive user input focus, either by clicking on it, by using the TAB / SHIFT TAB key, or under
program control with SetFocus (for example: Button1.Setfocus).
Note: button controls typically indicate the focus by drawing a rectangle around their caption.
A WinControl can serve as a container ("parent") for other controls, referred to as child controls. Examples of
container controls: forms, panels, and toolbars. Note: "parent" does NOT mean the same as "ancestor"!
TScrollingWinControl: controls that support scrolling.
A scrolling windowed control has horizontal and vertical scroll bars and scrolls a child control into view when
the child control receives focus.
Example of a scrolling windowed control: TForm
TCustomControl: to create windowed components that provide their own custom painting.
In contrast, the controls which descend from TWinControl like TEdit and TListbox, already have default drawing
capabilities, provided by the encapsulated MS Windows control.
TGraphicControl: for controls which are not windowed controls (they have no window handle).
Also, they cannot be parents to other controls.
Objects which descend from objects higher than TComponent in the hierarchy are non-component classes. Some useful
non-component classes are TStringList, TIniFile and TPrinter.
At the top of some Delphi's Help pages, you can see the inheritance hierarchy of predefined classes, like
for example this one for TEdit:
Examples of classes
The actual hierarchy of objects is more complex than as shown in the simplified diagram at the top of this
page. Here are a few examples of the real hierarchy, as implemented in Delphi XE 10:
||Ancestor of Ancestor