19th Chapter-delphi Custom Parts Development (iii) (2)

Source: Internet
Author: User
Tags resource

19.2.2.4 Registered Parts

Writing parts and their properties, methods, and events is only part of the part creation process. While parts are available with these features, the real power of parts is the ability to manipulate them at design time.

The following steps are required to make a part available at design time:

Register Parts with Delphi

Increase Selection Board bitmap

Provides help on properties and events

Storage and Read properties

1. Register Parts with Delphi

In order for Delphi to recognize custom parts and place them on component palette, you must register each part.

Registering a part involves adding a register method to the unit in which the part is located, which includes two things:

Declaring the registration process

Implementing the registration process

Once the registration process is installed, you can install the part on the selection board.

The registration process is to write a procedure in the unit containing the part, which must be named after the register. Register must appear in the interface part of the library unit so that Delphi can locate it. During the register process, you can invoke procedure registercomponents for each part.

The following code shows a rough way to build and register a part:

Unit Mybtns;

Interface

Type

... {Declaring custom parts}

Procedure Register;

Implementation

Procedure Register;

Begin

... {Registering a part}

End

End.

In the register process, you must register every part of the component palette that you want to join, and if the library unit contains several parts, you should register them once.

When registering a part, call the registercomponents procedure for the part. Registercomponents told Delphi two things about the registered parts:

To register the page name of the component palette where the part resides

The name of the part to be installed

The page name of the selection board is a string. If the page you give the name does not exist, Delphi creates a new page with that name.

The following register procedure registers a part named Tmycomponent and places it on the Component palette page named "Miscellaneous".

Procedure Register;

Begin

Registercomponents (' Miscellaneous ', [TFirst, Tsecond]);

End

You can also register multiple parts at once on the same page, or on a different page:

Procedure Register;

Begin

Registercomponents (' Miscellaneous ', [TFirst, Tsecond]);

Registercomponents (' assorted ', [tthird]);

End

2. Increase the bitmap on the component palette

Each part needs a bitmap to represent it on the component palette. If you do not describe your bitmap at installation time, Delphi automatically applies the default bitmap.

Because the palette bitmap is only required at design time, it is not necessary to compile them into the library unit. Instead, they are provided in the same Windows resource file as the library Single-name, with the extension. DCR. Using the Delphi bitmap editor to generate resource files, each bitmap has a length of 24 pixels.

Provide a Select board bitmap file for each library unit that you want to install, and provide a bitmap for each part you want to register in each file. The bitmap image name is the same as the part name, and the file is placed in the same directory as the library unit, so that the bitmap is dephi when the part is installed.

For example, if you create a part named Tmycontrol in the Toolbox unit, you need to create a resource file named TOOLBOX.DCR that contains a bitmap named Tmycontrol.

3. Provide help on properties and events

When you select a part in a form or select an event or property in the object inspector, you can get help for this item by F1. If you create the appropriate Help file, the user of the custom part gets the appropriate documentation about your part.

Because Delph uses a special help engine to support the process of topic searching across multiple assist files, you can provide small help files about custom widgets that users can find without additional steps. Your help became part of the Delphi Help system.

To help the user, understand the following two things:

How Delphi handles Help requests

To insert help into Delphi

⑴delphi How to handle help requests

Delphi Query help request based on keyword. That is, when the user presses the F1 key on the selected part of the Form Design window, DELPDI converts the name of the part to a keyword, and then calls the Windows Help engine to find the topic for that keyword. The keyword is the standard part of the Windows Help system. In fact, WinHelp uses the keywords in Help to produce a list in the Search dialog box. Because the keywords used in context-sensitive searches are not actually for the user to read, enter the alternative word for the keyword.

For example, a user looking for details of a part named Tsomething might open the WinHelp Search dialog box and enter Tsomething. It does not use the alternative form of the context lookup used for the Form design window class-tsomething. Therefore, this special keyword class-tsomething to the user is not visible, so as not to mess up the search list.

⑵ will help insert Delphi

Delphi provides tools for creating and inserting Windows Help files, including the Windows Help compiler HC.EXE. The mechanism for creating a Help file for a custom part is no different from establishing any of the help files, but there are some conventions to be followed to be compatible with the others in the library.

The way to maintain compatibility is as follows:

Create Help file

Add a special footnote

Create a keyword file

Insert Help Index

When you have created help for a custom part, you have the following several files:

The compiled help (. HLP) file

Help keyword (. KWF) file

One or more help source files (. RTF)

Help Engineering file (. HLJ)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.