Programming Delphi What Is the VCL or CLX? Understanding Delphi/C++Builder's Class Libraries and Their Properties, Methods, and Events
Notice: Undefined variable: relatedArticlesCount in /home/wwwroot/codeback.net/plugins/content/tags.php on line 149

Before the programming with Delphi or C++Builder, you may have heart the big name VCL and CLX. Yes, this is the key for you to understand in Delphi or C++Builder. Ok, now let us to see what they are.

What is the VCL or CLX? Understanding the class libraries in Delphi and C++Builder.

VCL and CLX are class libraries made up of objects that you use when developing applications. The libraries are similar to each other and contain many of the same objects. Some objects in VCL implement features that are available on Windows only, such as objects that appear on the ADO, BDE, QReport, COM+, and Servers tabs on the Component palette. Virtually all CLX objects are available on both Windows and Linux.
All VCL and CLX objects descend from TObject, an abstract class whose methods encapsulate fundamental behavior like construction, destruction, and message handling. When you write classes of your own, they should descend from TObject in the class library you plan to use.

Components are a subset of VCL or CLX and descend from the abstract class TComponent. You can place components on a form or data module and manipulate them at design time. Most components are either visual or nonvisual, depending on whether they are visible at runtime. Some components appear on the Component palette.
Visual components, such as TForm and TSpeedButton, are called controls and descend from TControl. TControl provides properties that specify the visual attributes of controls, such as their height and width.

Nonvisual components are used for a variety of tasks. For example, if you are writing an application that connects to a database, you can place a TDataSource component on a form to connect a control and a dataset used by the control. This connection is not visible to the user, so TDataSource is nonvisual. At design time, nonvisual components are represented by an icon. This allows you to manipulate their properties and events just as you would a visual control.

Detailed reference material on all of the objects in VCL and CLX is accessible while you are programming. In the Code editor, place the cursor anywhere on the object and press F1 to display the Help topic. Objects, properties, methods, and events that are in the VCL are marked "VCL Reference" and those in CLX are marked "CLX Reference."

Properties, methods, and events of VCL and CLX.

Both the VCL and CLX form hierarchies of objects that are tied to the IDE, where you can develop applications quickly. The objects in both component libraries are based on properties, methods, and events. Each object includes data members (properties), functions that operate on the data (methods), and a way to interact with users of the class (events). The VCL and CLX are written in Object Pascal, though the VCL is based on the Windows API and CLX is based on the Qt widget library.

Properties

Properties are characteristics of an object that influence either the visible behavior or the operations of the object. For example, the Visible property determines whether an object can be seen or not in an application interface. Well-designed properties make your components easier for others to use and easier for you to maintain.
Here are some of the useful features of properties:

Unlike methods, which are only available at runtime, you can see and change properties at design time and get immediate feedback as the components change in the IDE.
 You can access properties in the Object Inspector where you can modify the values of your object visually. Setting properties at design time is easier than writing code and makes your code easier to maintain.
 Because the data is encapsulated, it is protected and private to the actual object.

The actual calls to get and set the values are methods, so special processing can be done that is invisible to the user of the object. For example, data could reside in a table, but could appear as a normal data member to the programmer.
 You can implement logic that triggers events or modifies other data during the access of the property. For example, changing the value of one property may require you to modify another. You can change the methods created for the property.

Properties can be virtual.
 A property is not restricted to a single object. Changing one property on one object could effect several objects. For example, setting the Checked property on a radio button effects all of the radio buttons in the group.

Methods

A method is a function that is a member of a class. Methods define the behavior of an object. Class methods can access all thepublic, protected, and privateproperties and data members of the class and are commonly referred to as member functions.

Events and Types of Events

An event is an action or occurrence detected by a program. Most modern applications are said to be event-driven, because they are designed to respond to events. In a program, the programmer has no way of predicting the exact sequence of actions a user will perform next. For example, they may choose a menu item, click a button, or mark some text. You can write code to handle the events you're interested in, rather than writing code that always executes in the same restricted order.

Regardless of how an event is called, C++Builder looks to see if you have written any code to handle that event. If you have, that code is executed; otherwise, the default event handling behavior.

The kinds of events that can occur can be divided into two main categories:

User events
 System events

User events

User events are actions that are initiated by the user. Examples of user events are OnClick (the user clicked the mouse), OnKeyPress (the user pressed a key on the keyboard), and OnDblClick (the user double-clicked a mouse button).

System events

System events are events that the operating system fires for you. For example, the OnTimer event (the Timer component issues one of these events whenever a predefined interval has elapsed), the OnCreate event (the component is being created), the OnPaint event (a component or window needs to be redrawn), and so on. Usually, system events are not directly initiated by a user action.


Add comment


Security code
Refresh

Programming - Delphi