DELPHI component production method:
As a RAD tool, Delphi is widely popular for its fast compilation and friendly visual interface. Delphi provides many ready-made components, and as the version is updated,
New components are added continuously. In addition, you can buy special components developed by third parties, or download free components from the Internet. These components are sufficient to support general application system development. But it's still necessary for application developers to make their own widgets.
The component form can be used to seal objects tightly and add an intuitive shell, which is conducive to software debugging and code reuse. The development team divides labor and collaborates with components as functional units.
It is easier to implement engineering management, which can reduce unexpected errors from software planning and design to testing and modification, and greatly improve work efficiency. Mature components can also be sold as commercial software, bringing additional benefits and conducive to social division of labor and collaboration in software development. Delphi's component use and component production use the same working environment and similar programming methods. As long as you understand the basic principles, you don't need to learn many new things to make components.
Basic concepts
The basic process of making components can be summarized as:
1. Write building blocks (units). It contains component declaration and component implementation code.
2. Compile and debug component units in the same way as ordinary Delphi units.
3. Create a component registration unit. The uses statement is used to connect the component units, and the Register process is used to complete the registration of the component.
4. Write component online help information and compile it into a standard Windows help file.
After all the work is completed, the component unit binary file (. DCU), component registration source file (. PAS), help information file (. HLP) and additional keyword files are generated.
(. KWF). After users get these files, they can install and use them. Call the menu command in the Delphi environment to start the installation process (the registration file name needs to be specified during the installation process). You can register the component into Delphi's VCL library and generate a new button on the component toolbar. With the help of the HelpInst installation tool, the keyword file can be incorporated into the Dephi help index system, and online help can be achieved using the F1 key.
Made this way. DCU files are not fundamentally different from general Delphi units and can be called directly by other units even if they are not installed into the VCL library. The biggest difference is
Yu: Some properties and events in the component unit are declared as published, so they are visible to the user during the programming period. The user can use the object editing window to
(ObjectInspector) to access these properties and events. This is the key to visual programming.
Object inheritance and modification
The first thing to do when making a component is to select the appropriate Delphi object type as the parent object to derive new objects. A child object can inherit all non-private parts of the parent object.
parts, but don't get rid of unnecessary parts. Therefore, the selected parent object should contain as many properties, events, and methods as possible that the child object needs, but should not contain things that the child object does not need.
TComponent is the base point of all Delphi components, but if you derive new components directly from TComponent, you will need to start a lot of things from scratch. Generally only non-visual components