RAD Studio
ContentsIndex
PreviousUpNext
Understanding the component library
Name 
Description 
The component library is made up of objects that you can use in your projects. The VCL/RTL contains low-level classes and routines available for all VCL applications. VCL/RTL includes the runtime library (RTL) up to and including the Classes unit.
Use the VCL when you want to use native Windows controls, Windows-specific features, or extend an existing VCL application.
All classes in the VCL descend from TObject. TObject introduces methods that implement fundamental behavior like construction, destruction, and message handling.
Components are a subset of the component library that descend from the class TComponent. You can place components... more 
The VCL hierarchy of classes is tied to the IDE, where you can develop applications quickly. The classes in the VCL are based on properties, methods, and events. Each class includes data members (properties), functions that operate on the data (methods), and a way to interact with users of the class (events). The VCL component library is written in the Delphi language, and it is based on the Windows API. 
The kinds of events that can occur can be divided into two main categories:
  • User events
  • System events
  • Internal events
 
The following diagram is a greatly simplified view of the inheritance hierarchy that illustrates the relationship between objects, components, and controls.
Simplified object hierarchy
Every object (class) inherits from TObject. Objects that can appear in the Form Designer inherit from TPersistent or TComponent. Controls, which appear to the user at runtime, inherit from TControl. There are two types of controls, graphic controls, which inherit from TGraphicControl, and windowed controls, which inherit from TWinControl or TWidgetControl. A control like TCheckBox inherits all the functionality of TObject, TPersistent, TComponent, TControl, and TWinControl or... more 
The TObject branch includes all VCL classes that descend from TObject but not from TPersistent. Much of the powerful capability of the component library is established by the methods that TObject introduces. TObject encapsulates the fundamental behavior common to all classes in the component library by introducing methods that provide:
  • The ability to respond when object instances are created or destroyed.
  • Class type and instance information on an object, and runtime type information (RTTI) about its published properties.
  • Support for handling messages (VCL applications) .
TObject is the immediate ancestor of many simple classes. Classes in the TObject branch... more 
The TPersistent branch includes all VCL classes that descend from TPersistent but not from TComponent. Persistence determines what gets saved with a form file or data module and what gets loaded into the form or data module when it is retrieved from memory.
Because of their persistence, objects from this branch can appear at design time. However, they can't exist independently. Rather, they implement properties for components. Properties are only loaded and saved with a form if they have an owner. The owner must be some component. TPersistent introduces the GetOwner method, which lets the Form Designer determine the... more 
The TComponent branch contains classes that descend from TComponent but not TControl. Objects in this branch are components that you can manipulate on forms at design time but which do not appear to the user at runtime. They are persistent objects that can do the following:
  • Appear on the Tool palette and be changed on the form.
  • Own and manage other components.
  • Load and save themselves.
Several methods introduced by TComponent dictate how components act during design time and what information gets saved with the component. Streaming (the saving and loading of form files, which store information about the... more 
The TControl branch consists of components that descend from TControl but not TWinControl applications). Classes in this branch are controls: visual objects that the user can see and manipulate at runtime. All controls have properties, methods, and events in common that relate to how the control looks, such as its position, the cursor associated with the control's window, methods to paint or move the control, and events to respond to mouse actions. Controls in this branch, however, can never receive keyboard input.
Whereas TComponent defines behavior for all components, TControl defines behavior for all visual controls. This includes... more 
Most controls fall into the TWinControl/ TWidgetControl branch. Unlike graphic controls, controls in this branch have their own associated window or widget. Because of this, they are sometimes called windowed controls controls. Windowed controls all descend from TWinControl, which descends from the windows-only version of TControl.
Controls in the TWinControl/TWidgetControl branch:
  • Can receive focus while an application is running, which means they can receive keyboard input from the application user. In comparison, graphic controls can only display data and respond to the mouse.
  • Can be the parent of one or more child controls.
  • Have a handle,... more 
Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!