Starting Out with HtmlHelp

Environments: IE programming, HTML

Creating HTML Help Files for Your Applications

Creating cutting-edge applications is simply not enough these days. Users expect much more from an application. Providing a help file for your application has become an inductry standard. In the early days of Windows, back in 1995, Windows help came in only one flavour, simply called WinHelp. Now, with the integration of the Web in so many applications, even the help format has embraced this all-persave document format. Long live HTML!

You will need the following software to create HTML help files:


  • Microsoft HTML Help compiler

  • A text editor; Notepad will do fine

  • Image editing software such as PaintShop Pro

The entire tutorial for creating an HTML Help project is broken down into four steps. I recommend you read each of them in the order presented.

Note: You can download Microsoft’s help compiler for free here.

Step 1: Decide Your Layout—Pages and Content

The very first thing you must do is list out the functionality of your application and note the areas where help is required. For example, if you have created an Address Book application, you will provide the following functionalities:

  • Adding a new contact
  • Editing a contact
  • Deleting a contact

It is easy to see that breaking up the help by the task that is to be performed will provide an easy and efficient help mechanism for the user. Therefore, we could decide to have three HTML pages, each explaining one of the functionalities and providing help for it.

Step 2: Adding the HTML Files to the Project

After creating the HTML pages, start the Microsoft HTML Help compiler. Select ‘New’ from the ‘File’ menu. Select ‘Project’ in the list of project/file types. Do not select any other options. The screen that you eventually will see should be like this:

To add the HTML files to your project, click the Contents tab. Specify a new Content File name, if asked and, save it in the same directory where the HTML files are present.

To add one of the HTML pages to the project, right-click on the empty space under the tabs as shown in the picture below.

Select Insert Topic from the popup-menu. A dialog box will be shown, called Table of Contents Entry.

Click the Add button to open the Path or URL dialog box. Click the Browse button and select the first HTML file. The Table of Contents Entry dialog box will be enabled. Type in a title for the Entry Title textbox and click OK. The newly added Topic (HTML file) should be listed under the tabs. Similarly, add other HTML files as required.

Step 3: Compiling

The final step is to compile the project. After all the HTML files are included as mentioned in Step 2, the project can be compiled.

Before compiling, final setting still need to be made. Click the Project tab. Double-click the [OPTIONS] item in the list to view the Options dialog box. Various project options can be set from here. Enter a suitable title for the help project in the General section.

Click the Files tab and make sure the Automatically Create Contents File… check box is unchecked.

After the options have been finalized, select Compile from the File menu. If all goes well, the compiler will create a .CHM help file.

Step 4: Calling the Help File from a Project

At the end of it all, one would want to call the help file from an application (executable file). The example shown here is for a Visual Basic project.

Add the following declaration to a VB project’s .BAS module:

Public Const HH_DISPLAY_TOPIC = &H0
Public Const HH_HELP_CONTEXT  = &HF
Public Declare Function HtmlHelp Lib "HHCtrl.ocx" _
       Alias "HtmlHelpA" _
       (ByVal hwndCaller As Long, ByVal pszFile As String, _
        ByVal uCommand As Long, dwData As Any) As Long

This declaration is required to use the HTML Help API command from Visual Basic. To call a particular topic of the HTML help (.chm file), use this code:

Call HtmlHelp(0, "MyHelpFile.chm", HH_DISPLAY_TOPIC, _
              ByVal "Step3.htm")

Here, the last parameter specifies the HTML file to diplay in the Help viewer.

I hope you have enjoyed reading this article. If you find this tutotiral to be useful, I would really appreciate any comments or views on it. You can mail me at siddharthbarman@softhome.net.

Downloads

Download demo file – 143 Kb

More by Author

Get the Free Newsletter!

Subscribe to Developer Insider for top news, trends & analysis

Must Read