Writing Help files for Delphi components
Although the Delphi 5 Help tells us under the title Creating a new component that "Creating a help file to instruct users how to use the component is optional." no one who calls himself programmer shall consider a component finished unless it has a help file. Sometimes for really small projects a single readme file may be acceptable, but for anything serious a help file is a must.
If we follow links that originate from the above mention help page we do find some information about the structure of a help file, but this information is by far not enough to create anything similar to the Delphi help pages. While creating the Multi-glyph controls components using information from different sources I managed to create a help source file that is almost identical to the help style of Borland Delphi 5. As in this project there are only two components, this help file can serve as a template for creating new help files.
I wrote this article to help those programmers who wants to make their own help file with less trouble than I had.
Download the example project
The help example is included in the Multi-glyph control Delphi components. These components can be used as a freeware, and downloaded from here. Please register, because although the components and the help are freeware I want to know who uses them. The component help files are in the Component\Help directory. Make a copy of the files in a new directory and rename the GButtons.* files to something else to use them as templates to create your own help file. These are the files you need:
| Filename | Description |
|---|---|
| GButtons.hlp | Compiled help file |
| GButtons.cnt | Compiled help contents file |
| GButtons.hpj | Help project file |
| GButtons.rtf | Help source file |
| green.bmp | Green rectangle (used in property lists) |
| yellow.bmp | Yellow rectangle (used in property lists) |
| blue.bmp | Blue triangle (used in property lists) |
| vline.bmp | Vertical line (used in hierarchy lists) |
| sbullet.bmp | Small bullet (used everywhere) |
Create the Help Source file
The Help Source file contains all the information you want to display in the help. Open the GButton.rtf file with any word processor capable of handling Rich Text format and edit it. The styles and links are explained later in this document in detail.
Create the Help Project file and compile the project.
Open the Microsoft Help Compiler. (It is hiding in Program Files/Borland/Delphi5/Help/Tools/hcw.exe. You may want it installed in Delphi 5 Tools menu.) Open the GButton.hpj file and check its contents.
If you renamed the GButtons.* file, edit the "Help file:" name and the "Files..." section. You probably want to edit the Copyright and Title in the "Options..." section too. Leave all the others unchanged, especially the Windows... section.
Click on the Compile toolbar icon and debug the RTF file. When you have only a small number of errors then install your help file into the Delphi help and check its cross-file links too.
Create the Help Contents file
The help contents file is really simple. Open the GButtons.cnt file and edit the Filename, Title, Heading and Topic items. To avoid crowding the main contents page of Delphi Help use only one top level Heading.
Install the Help
Distributing Help
You only have to distribute the Compiled Help file and the Help Contents file. Do not forget to include installation instructions, as it may not be obvious to everybody how to use the OpenHelp.
At the beginning of the help file there are a few pages that describes the package in general and the usual copyright and licensing terms. These are strictly speaking not part of a Delphi compatible help system. The "Free Software Foundation: General Public License" is also included here, as the widely accepted terms for distributing freeware.
Each component has a help topic which is opened in the main window.
The title is formatted as Heading 1. At 11.44 cm there is a tabstop which is quite handy to place a link to the writer of the component or to the licensing terms and conditions.
The second line is the "Hierarcy Properties Methods Events See also Examples" line and it is formatted as LinkLine. The actual links are hidden text (Do not forget to enable show hidden text!) Hierarchy window is a simple drop down list. Properties, methods and events are opened in the pme window. (The narrow rectangular window slightly left and down of the main window.) See also is long ALink to related topics in Delphi help and in our help file. Examples are opened in the example window. (The big window on the right.)
The third line is the short definition of the component. It is formatted as Definition.
The fourth line is the subtitle "Unit" formatted as Heading 2.
The unit name is in the next line formatted as Definition. The link opens in pme window listing all the components in the unit.
Then comes the subtitle "Description" formatted as Heading 2.
After that most of the lines are formatted as Text, and give detailed description of the component.
The component help topic has $, #, A and K footnotes to allow every kind of linking.
Each property, method and event has a topic which which is also opened in the main window
The title is formatted as Heading 1. You can repeat the link here at the end of the line to the writer of the component or to the licensing terms and conditions.
The second line is the "Component See also Examples" line and it is formatted as LinkLine. See also is long ALink to related topics in Delphi help and in our help file. Examples are opened in the example window.
The third line is the short definition of the property, method or event. It is formatted as Definition.
The fourth line is the formal declaration formatted as Declaration.
Then comes the subtitle "Description" formatted as Heading 2.
After that most of the lines are formatted as Text, and give a detailed description of the property, method or event..
Every component property, method or event has $, #, A and K footnotes to allow every kind of linking. They are also groupped in browse sequence sets using identical + footnotes. The sequence order is the same as the listing order in the file, which should be alphabetical.
Listings of properties, methods and events are displayed in the pme window
The title is formatted as Heading 1.
The second line is the "Component Alphabetically/By object Legend" line and it is formatted as LinkLine.
The list of links are formatted as PText, and the inserted subtitles as Heading 2. Links to the same file are direct links in the format of Component_Property>main, and links to Delphi help topics are indirect links in the format of !ALink('Component_Property',1,,main). You can place in front of the names the yellow or green rectangle or the blue triangle marker by the {bmc yellow.bmp}, {bmc green.bmp} or {bmc blue.bmp} directives. Do not forget that the blue triangle is always at the first tabstop while the rectangles are at the beginning of the line.
These listings has only # footnotes because they are not included in the index and they are not used for linking.
Listings of components/units are displayed in the pme window
The title is formatted as Heading 1.
The second line is the "Other objects and components, by unit/header" line and it is formatted as LinkLine.
It is followed by the list of component names formatted as UnitComponent and component descriptions formatted as UnitText.
The components/unit listings has $, #, A and K footnotes to allow every kind of linking. The > footnote ensures that these listings are always displayed in the pme window.
The Hierarcy listings are very simple
The title is formatted as Heading 2.
Everything else is formatted as PText. In every second line the {bmc vline.bmp} directive at the second tabstop separates the objects by a small vertical line.
The Legend listings are similar to the Hierarchy listings
Legend listings explain the meaning of the yellow and the green rectangle and the blue triangle markers. They are rarely changed.