RAD Studio
ContentsIndex
PreviousUpNext
Inheriting Data and Code from an Object

The TForm1 object in examining a Delphi object seems simple. TForm1 appears to contain one field (Button1), one method (Button1Click), and no properties. Yet you can show, hide, or resize of the form, add or delete standard border icons, and set up the form to become part of a Multiple Document Interface (MDI) application. You can do these things because the form has inherited all the properties and methods of the component TForm. When you add a new form to your project, you start with TForm and customize it by adding components, changing property values, and writing event handlers. To customize any object, you first derive a new object from the existing one; when you add a new form to your project, the IDE automatically derives a new form from the TForm type:

TForm1 = class(TForm)

A derived class inherits all the properties, events, and methods of the class from which it derives. The derived class is called a descendant and the class from which it derives is called an ancestor. If you look up TForm in the online Help, you'll see lists of its properties, events, and methods, including the ones that TForm inherits from its ancestors. A Delphi class can have only one immediate ancestor, but it can have many direct descendants.

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