Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Articles
Search: 

Using the HTML Help Workshop
Hilmar Zonneveld, November 1, 2002
A help file can be used either for interactive help, or as an online manual. In this article, I will give an overview over creating help files in the new help format (CHM), for Visual FoxPro 6 and later. This article is introductory and assumes no prior knowledge of the Help Compiler, or of HTML cod...
A help file can be used either for interactive help, or as an online manual. In this article, I will give an overview over creating help files in the new help format (CHM), for Visual FoxPro 6 and later. This article is introductory and assumes no prior knowledge of the Help Compiler, or of HTML coding.

Overview

The new help format, recommended by Microsoft, is based on HTML files. The output is a file with CHM extension. New Microsoft products, for instance newer versions of MS-Office, use this help format.

The main advantage of this new help format, in my opinion, is that it is much easier to create than the old HLP help files. Its main disadvantage is that support for this format has to be installed separately - support for the old HLP format came included with Windows, even before Windows 95.

The program required to convert the HTML files to a CHM file is included on the Visual FoxPro 6 CD. It can also be downloaded for free from Microsoft. The steps required to create the help file include creating HTML files, creating or obtaining images, creating a table of contents, including your individual help files into the help system, compiling, and testing. I did my testing in VFP 6 only.

This article describes technical aspects only. The - undoubtedly important - issues of planning your help system, good writing style, etc., are not treated here.

A quick tutorial

Let's start by building a small help system. First, we must create an empty help project:

  • Install the HTML Help Compiler. You can find it in folder HTMLHELP, on your Visual FoxPro CD.

  • In Windows Explorer, create a folder c:\MyHelpFolder.

  • Start the Help Compiler.

  • Select "File | New". Select "Project".

  • Leave the checkbox "Convert WinHelp project" blank (we want to create a new project for now), and click on "Next".

  • Under "Specify the name of your project file, and where you would like it to be created", specify a folder and a project name: c:\MyHelpFolder\MyHelp. Click on "Next".

  • Under "existing files", leave everything blank; we didn't create the required files yet. Click on "Next".

  • Click on "Finish".
  • In the HTML Help Compiler, select "File | New". Select HTML file. For the title, write "Main Menu", and click "OK". Write some text between <BODY> and </BODY>. Be sure to start each paragraph with <P> - the HTML code for a new paragraph. The text should describe the main menu.

  • Save the file: "File | Save". Call it MainMenu.htm.

  • Repeat the previous steps, and write some short text to describe the "File" menu. Save as FileMenu.htm.

  • Repeat for the "Edit" menu, and save as "EditMenu.htm".

The next step is to create a table of contents, and include the files you just created. The HTML file for the Main Menu will be included as a "heading", the two submenus as "pages" under this heading. (Using the buttons in the Help Compiler, it is very simple to create additional levels of headings.)

  • Click on the "Contents" tab. Confirm that you want to create a new table of contents, and accept the suggested name ("Table of Contents.hhc").
  • Click on the button "Insert a heading" (the second from the top, on the vertical toolbar). Under "title", write "Main Menu" (this is the text the user will see in the table of contents). Click on the "Add" button, followed by the "Browse" button, select the file "MainMenu.htm", and click on the two "OK" buttons.
  • Click on the button "Insert a page" (the third from the top, on the vertical toolbar). You will be asked whether you want the entry at the beginning of the Table of Contents. Answer "No". Under "Entry title", write "File Menu". Click on "Add" and "Browse", select file "FileMenu.htm", and click on "OK" twice.
  • Repeat for the Edit menu.

We are almost finished now. To test your project, you can click on "Compile" (the third button on the top toolbar). If there are no errors, you can now click on "view compiled file" (if it didn't appear automatically), and see the result.

One little problem is that no files appears initially selected. Go back to the Help Compiler, select the "Project" tab, and click on the "Properties" button (the first in the vertical toolbar). Under the "General" tab, click on "Default file", and type "MainMenu.htm". Recompile, and check the result.

Creating the HTML files

Since the entire help system is based on HTML files, one of our major tasks is to create the HTML files - one for each help topic. If you ever used a word processor, you already have most of the required skills.

As you saw in the previous tutorial, the HTML Help Compiler has a built-in text editor. A pleasant feature is that when you create a new HTML file with it, some important HTML keywords are already inserted. Of course, you can edit an HTML file with any other text editor, too, including Microsoft Word (opening and saving as "Text only").

If you feel more comfortable with a WYSIWYG editor, which hides most of the HTML codes from you, you have several options:

  • While Microsoft Word can save in HTML format, it inserts so many unneeded codes, that it becomes very cumbersome to later edit those same files with any other programs. The extra codes can also adversely affect the way the HTML page looks on screen. I found that MS-Word has some additional problems with HTML files, too. Therefore, I definitely do not recommend using it as a WYSIWYG HTML editor. (Using it as a text editor, where you insert all the HTML codes and then save as text-only, is quite a different issue - here, you can benefit from features like spell-checking, multiple undo, and others.)
  • FrontPage Express comes free with some versions of Internet Explorer. However, it is not included in the default installation.
  • Or, you can go to download sites like www.download.com, and search for popular HTML editors.

HTML Codes

In case you want to learn to code HTML yourself, I will include some of the most important HTML concepts. Otherwise, you may want to skip this section. Please note that some of these codes are also very useful when writing messages in the Universal Thread.

An HTML document is a text-only document - any special codes required can be inserted and read with any text editor.

All HTML codes are enclosed within angle brackets. For instance, to start bold, you use the <B> symbol.

Many HTML codes come in pairs. For instance, to indicate the end of the bold text, use </B>. You can understand this as "end bold". However, not all codes have to come in pairs.

An HTML document starts with <HTML> and ends with </HTML>.

The document is divided into two main sections: the header, and the body.

The header starts with <HEAD> and ends with </HEAD>. Within the header, you have a title between <TITLE> and </TITLE>, that will be displayed as a window title in the browser, if the HTML document is opened independently. (It seems that this text is not really relevant for a help system, which supersedes this title with a title you choose, throughout the entire help system.)

The body contains your main text, tables, references to graphics, etc.

Every paragraph starts with <P>. The end-of-paragraph code, </P>, is optional. Note that if you press ENTER in your text, this will not start a new paragraph - the browser will combine the lines. The only way to start a new line is with the <P> symbol, or with some other special HTML codes, for instance, headings.

<PRE> and </PRE> is used for "pre-formatted text" - in normal paragraphs, spaces and line breaks are not respected, in pre-formatted text, they are. Also, a fixed-width font is used, and word-wrap is turned off. All this makes pre-formatted text ideal for showing program code. (You should always use this code when posting program code in a Universal Thread message, to make it more readable.)

A few additional codes will be introduced later, in their corresponding sections.

Images

Being based on HTML, the help system can use both JPG and GIF images. Both are useful for different purposes:

GIF images are compressed images. No quality is lost in the compression, but a GIF image can only have 256 different colors. GIF images are excellent for screenshots.

JPG (or JPEG) images use lossy compression. That means that in most programs, some quality is lost when saving an image to JPG. This helps save space. The loss in quality is usually imperceptible in a photograph. (When saving to JPG, most image-editing programs allow you to adjust the amount of quality lost; this means choosing between more quality vs. a smaller file.) A JPG file can use millions of color simultaneously. All this makes JPG files ideal for photographs.

For obtaining screenshots, you need some screen capture utility. Without additional software, you can press PrtScr (equivalent of "Copy to Clipboard", for the image of the entire screen), or Alt-PrtScr (current window only), and edit the resulting image in Paint - for instance, cut out the rectangular region that you want to include in your help file.

The HTML Help Compiler installation includes an screen capture and graphic conversion utility, which you can use instead.

Whether the final destination be a Website or a CHM file, in HTML, images are stored as separate graphic files. In your HTML text, include a code like <IMG SRC="MyScreenshot.gif">. Or use the "Image" button of your favorite HTML editor, and fill in the options in the dialog.

Hyperlinks

Hyperlinks provide a way to jump to related topics. Use the hyperlink button of your HTML editor, and fill in the options in the dialog, or use HTML code like <A HREF="AnotherHelpFile.htm">User Sees This Text</A>. (Hint: In the Universal Thread, you can use this code to put a hyperlink into your dynamic signature.)

Note that it is also possible to jump to a specific place in a document, using bookmarks. For instance, I use this feature for glossary terms. I usually leave the details to my HTML editor.

Context-sensitive help

The idea of context-sensitive help is that if the user presses the help key (F1), he will see a help topic relevant to the form that is currently on top, or even to the individual object that has the focus.

It is up to the developer to decide what level of detail he wants (form, or individual objects).

I will assume, in the following explanation, that you have one HTML help file for each form only.

For each form, you need to follow these steps:

  • In an include file (I call it context.h), add a line like #DEFINE IDH_MYFORM 1. The constant should start with "IDH_". Both the named constant and the number must be unique for each form.
  • Include this include file (or another include file, which references it) in the form.
  • In the form, include the following statement in the Init() method: This.HelpContextID = IDH_MYFORM.
  • If you didn't do so already, write the HTML file to describe the form, as described previously. For this example, call it MyForm.htm.
  • To activate the header file, in the Help Compiler click on the fourth button on the vertical toolbar (HtmlHelp API information), and in the map section select the header file (context.h). This has to be done only once.
  • Open the project file as a text-file (open it with NotePad), find or create the [ALIAS] section, and include a command like: IDH_MYFORM = MyForm.htm. According to a KnowledgeBase article, you can get into trouble if you try to add an alias through the HTML Help Compiler - therefore, I always open the project in text mode.
  • Open the project file in the Help Compiler, and add the help topic to the Table of Contents (as outlined above).
  • Compile and test.

    To open the correct topic from a Visual FoxPro form, I use a command like HELP ID ThisForm.HelpContextID.

    Installing Help

    The main problem with the new help format (CHM), as explained previously, is that the support for help is not included in the operating system.

    The easiest way to install help support is with the Visual FoxPro Setup Wizard. In Step 2 of the setup wizard, simply mark the checkbox for HTML Help Engine.

    The setup program you create will check whether Internet Explorer is installed. Internet Explorer version 4 or later is required for the help system to work. Internet Explorer doesn't have to be the default browser, but it has to be installed - other browsers can't open the CHM file.

    Summary

    I hope this brief introduction helped you get an overview over creating help files. Help files in the new CHM format are relatively easy to create, and easy to use for the end-user. And a decent documentation is an important part of a complete computer system.

    Hilmar Zonneveld, Independent Consultant
    Hilmar Zonneveld works in programming since 1986, using dBASE, FoxPro and Visual FoxPro. He is available as an independent consultant. He currently works as a programmer at Bata Shoe Organization; also as an instructor at Cisco Networking Academy. You can contact him through the Universal Thread, or, via e-mail, at hilmarz@yahoo.com. Personal Web page (mainly in Spanish): www.geocities.com/hilmarz.
    More articles from this author
    Hilmar Zonneveld, May 1, 2003
    An audit-trail is a record of who did what changes, and when. In Visual FoxPro, this can easily be accomplished through triggers. I hinted at the possibility of doing an audit-trail, in my article on triggers - now, as a reaction to questions in the Universal Thread, I want to present a sample...
    Hilmar Zonneveld, December 6, 2001
    (The latest update contains minor edits only.) Five easy and fun ways to get yourself into trouble with inheritance. A frequent source of problems in OOP is called "breaking inheritance". This document briefly describes what inheritance is, how it applies to properties and methods, and how it ...
    Hilmar Zonneveld, July 1, 2002
    Introduction Buffering is a feature in Visual FoxPro that allows us to give the user "undo" and "save" capabilities. In the old FoxPro 2.x days, programmers either didn't provide this capability, or edited memory variables, and copied information between these variables and the table fiel...
    Hilmar Zonneveld, October 6, 2005
    Due to a recent Windows security fix, users can no longer access a CHM file on a server. The table of contents appears, but the individual pages are replaced by error messages. Access to CHM files in specific folders can be explicitly allowed through special registry settings.
    Hilmar Zonneveld, July 20, 2001
    (The last update contains minor edits only.) The idea is to have several controls on a form controlled with an array. Thus, you can quickly go through all the controls on the form, managing the array. The sample code included will help you get started quickly. You can easily adapt it to manage...
    Hilmar Zonneveld, September 1, 2002
    With Automation, you can control all aspects of Excel, Word, or other programs that provide this feature, from Visual FoxPro. In this article, I will concentrate on Excel. Its purpose is to provide a starting point, especially for people new to automation. Introduction With automation, you bas...
    Hilmar Zonneveld, March 1, 2003
    Introduction One common task in programming is to keep track of what problems are pending. For this purpose, I use a "hierarchical to-do list": a list of items, each of which can have sub-items. All you need is Microsoft Word. Alternatives are available as freeware or shareware, but in t...
    Hilmar Zonneveld, October 7, 2005
    This is a step-by-step tutorial to show inheritance, specifically in Visual FoxPro forms, as a guidance for people who are not familiar with inheritance in general, or who don’t know how to implement it in Visual FoxPro. The basic idea of inheritance is that all your forms, or several of your for...
    Hilmar Zonneveld, May 30, 2004
    The code shows how to quickly obtain the greatest common factor, and the least common multiple. Both functions are used when manipulating fractions, among others. Several methods are possible; the method usually taught in school involves prime numbers, but this code will execute much faster (and it ...
    Hilmar Zonneveld, November 1, 2006
    A standard requirement in a production system, or in systems for cost calculation, is to add up all the raw materials for a number of finished articles, to get the total cost, or simply to purchase the materials. In this article, Hilmar outlines how to do this with multiple levels of intermediate ar...
    Hilmar Zonneveld, August 1, 2002
    Overview The purpose of this article is to give an overview of normalization. Basically, normalization refers to having an efficient table structure. I will not discuss the famous "first to fifth normal forms" - if you want that information, enough texts exist about it in other places (search sit...
    Hilmar Zonneveld, November 8, 2001
    The following function will open any document, with its default association (the same application that will be called when you double-click on the file, in Windows Explorer). Use it to open a text-file, a Word or Excel document, an image, etc., with an external application.
    Hilmar Zonneveld, May 1, 2002
    Introduction This document explains the meaning of primary key, foreign key and candidate index in Visual FoxPro. A discussion of natural and surrogate keys (keys visible, or not visible, to the end-user) is included, including the advantages of each approach, as well as different methods for o...
    Hilmar Zonneveld, January 1, 2003
    Continuing my series of introductory articles, this article presents an introduction of a simple yet powerful programming concept: recursion. Introduction "To understand recursion, you must first understand recursion." "To make yogurt, you need milk and yogurt." If you are not accustomed...
    Hilmar Zonneveld, December 1, 2002
    Introduction This article presents an introduction to coding shortcuts in Visual FoxPro - when to use them, and when not to. Notes on coding in general This article is about coding shortcuts; however, I should first emphasize that making the code as small as possible is usually not the number...
    Hilmar Zonneveld, July 20, 2001
    Rushmore Optimization can help make queries much faster. However, "Full Rushmore Optimization" is not always a desirable goal. "Partial Optimization" is sometimes much faster. It is often believed that to speed things up, you need to have as many indices as possible. This article explains that so...
    Hilmar Zonneveld, June 7, 2002
    If you need to check elapsed time with seconds() or a datetime value, this function allows you to display the elapsed time in a human-readable format, that is, hours:minutes:seconds, instead of the total number of seconds. Just pass a number of seconds as a parameter.
    Hilmar Zonneveld, April 1, 2002
    SQL is a standard language used to manipulate databases. Several of the SQL commands are integrated into the Visual FoxPro language. Select This is a very flexible command, used to select data from a table, or from several tables. This command has options to get totals from several record...
    Hilmar Zonneveld, August 1, 2003
    In this article, I will show several ways to manipulate text-files. Knowledge of these methods is often important to import and export specific formats. Some of the techniques can also be used to work with files of any content; however, this article will concentrate on text-files. When ...
    Hilmar Zonneveld, June 1, 2002
    The purpose of this article is to show how to use some aspects provided by the Visual FoxPro database engine, to control our data. Indices Perhaps most readers already know indices; anyway, I find it convenient to include a brief summary of the topic, since this is a requisite to understan...
    Hilmar Zonneveld, February 1, 2003
    Introduction Any real-world application will sooner or later misbehave. It is important to be able to find those problems. Visual FoxPro's built-in debugger can help a lot to find out why your program doesn't work as you thought it would. Most of the material in this article applies to Visual...
    Hilmar Zonneveld, May 1, 2006
    This article is an introduction to VisioModeler. This is a free CASE tool, that can help you design your database, in the process sharing the information with the client in a visual, easy-to-understand, format.