Adding a CNT to a WinHelp3 file

Context-IDs Single .CNT Multi-file Bypass

Do you want to run your WinHelp3 products with the greatest possible functionality under Win95, but without recompiling? What you might need is a .CNT file.

What is a .CNT file?
A .CNT file adds a graphical Table of Contents (TOC) tab to the Search/Find tabs under Win95.

It is a simple text-file which lists the context-ID of each topic, the title which should appear in the TOC tab, and the hierarchical level of each topic. Its name is based on the helpfile it supports eg. FRED.CNT would belong to FRED.HLP.

A large or complex WinHelp3 file will often have an overview index topic, containing jumps to further sub-contents topics.
This can make it tedious to drill down to the topic you want, particularly if the author didn't use keywords effectively.

With a .CNT, the whole structure of topic titles can be seen at a glance, and the user can quickly move to the one they really need. If a topic is not significant, it can be omitted from the .CNT, and it won't show in the TOC tab.

A .CNT can also be used to provide an integrated view of two or more helpfiles. In this case, the Win95 Find tab can be customised to do a full-text search across all included helpfiles. (I won't go into this, as it's fairly intuitive when you try it.)

And, even if you don't build WinHelp3 files yourself, you might want to add .CNT functionality to the helpfile for a legacy Win3 application you run on Win95.

Top Context-IDs Single .CNT Multi-file Bypass

Getting the context-IDs
If you built the helpfile yourself, you can probably get its context-IDs and topic titles from your topic files. However, there is a much easier way to get this information from any helpfile, even ones you didn't write.
Just find a copy of Manfred Winterhoff's freeware decompiler HELPDECO.EXE Version 2.1. When run from DOS with the /c switch:
HELPDECO helpfile[.hlp] /c
it will generate a skeleton .CNT, complete with topic titles. (Don't worry if the context-IDs look a little strange - they are the hashed equivalents, which are what WinHelp really uses.) HELPDECO V2.1 can be found at various sites including http://www.wextech.com/ as HELPDC21.ZIP.

You could just use the .CNT produced by HELPDECO, but now I'll show you how to modify it, so that you understand the principles of building a .CNT from scratch.

In the examples below, I'll describe how to make .CNTs for two real helpfiles that everyone should have already - NOTEPAD.HLP and CALC.HLP.

This is important - we will be testing the results on Win95, and since Win95 has the same-named applications, helpfiles and .CNTs, and since we don't want any "interference" with our new .CNTs, the Win3 helpfiles must have new names. On your Win3 machine, copy NOTEPAD.HLP as NOTEPAD3.HLP, and CALC.HLP as CALC3.HLP, and use these two new files in the examples. (You won't need the .EXEs.)

First, we'll use HELPDECO to generate a skeleton NOTEPAD3.CNT. Then we'll modify that .CNT a little. Then we'll repeat the process for CALC3.HLP. Finally, we'll merge them, to get a single integrated TOC for both helpfiles.

Top Context-IDs Single .CNT Multi-file Bypass

A .CNT for NOTEPAD3.HLP
On your Win3 machine, use HELPDECO to generate a raw NOTEPAD3.CNT, using this DOS command:

HELPDECO NOTEPAD3.HLP /c

NOTEPAD3.CNT should look like this...

:Base NOTEPAD3.HLP>main
:Title Notepad Help
1 Contents for Notepad Help=36DM_ZC
1 File Menu Commands=VDAGBM
1 Edit Menu Commands=KK3LA6
1 Search Menu Commands=46X4KA
1 Finding Text=1N6J089
1 Deleting Text=F0MDHQ
1 Formatting Text=365BRB
1 Adding the Time and Date to Documents=29GAUW
1 Creating Time-Log Documents=E1S6RH

(Make sure there is a carriage return at the end of the last line, or the line will be ignored in the TOC tab. Thanks to Robin Hilliard for this tip.)

Copy NOTEPAD3.HLP and NOTEPAD3.CNT to your Win95 machine, and open NOTEPAD3.HLP by double-clicking in Windows Explorer or File Manager. You should see the Contents/Search/Find dialog, with an unstructured TOC in the Contents tab.

For the next step, open NOTEPAD3.CNT in Win95 NOTEPAD, and modify it to look like this....
(Lines which don't start with a colon (:) or a number other than zero are ignored.)

:Base NOTEPAD3.HLP>main
:Title Notepad Help
1 Contents for Notepad Help=36DM_ZC
The next line has no context-ID, so appears as a "book"
1 Menu Commands
You don't have to use the "real" topic titles
2 File Menu=VDAGBM
2 Edit Menu=KK3LA6
2 Search Menu=46X4KA
1 Text Operations
2 Finding Text=1N6J089
2 Deleting Text=F0MDHQ
2 Formatting Text=365BRB
1 How-to....
2 Adding the Time and Date to Documents=29GAUW
2 Creating Time-Log Documents=E1S6RH

When you run NOTEPAD3.HLP, the TOC tab should now show a hierarchy of topics, with "books" representing the inserted group headers ("Menu Commands", "Text Operations" and "How-to...").


A .CNT for CALC3.HLP
Now repeat the above processes with CALC3.HLP...

This is the raw CNT produced by HELPDECO CALC3.HLP /c

:Base CALC3.HLP>main
:Title Calculator Help
1 Contents for Calculator Help=1GIL4CU
1 Edit Menu Commands=36_U_OF
1 View Menu Commands=0N2_HC
1 Entering Calculations=NN.N0E
1 Using Calculator with the Clipboard=NHGN7H
1 Switching Calculators=FII8A2
1 Using the Scientific Calculator Statistical Functions=1LYQSN
1 Converting Values to Other Number Systems=1NRF_IY
1 Using Standard Calculator Functions=25I1HX5
1 Using Memory Functions=10Y_OJO
1 Using Number-Base Functions=29LG_PG
1 Using Operators=DXER7W
1 Using Advanced Statistical Functions=IC2LR3
1 Using Other Advanced Functions=54P0_J3

This is CALC3.CNT, modified to create a hierarchy of topics, with group headers ("books") inserted.

:Base CALC3.HLP>main
A title line is not necessary for a single helpfile
1 Contents for Calculator Help=1GIL4CU
1 Menu Commands
2 Edit Menu Commands=36_U_OF
2 View Menu Commands=0N2_HC
1 How to....
2 Enter Calculations=NN.N0E
2 Use Calculator with the Clipboard=NHGN7H
2 Switch Calculators=FII8A2
1 Functions & Operators
2 Using the Scientific Calculator Statistical Functions=1LYQSN
2 Converting Values to Other Number Systems=1NRF_IY
2 Using Standard Calculator Functions=25I1HX5
2 Using Memory Functions=10Y_OJO
2 Using Number-Base Functions=29LG_PG
2 Using Operators=DXER7W
2 Using Advanced Statistical Functions=IC2LR3
2 Using Other Advanced Functions=54P0_J3

When you are satisfied that both NOTEPAD3.CNT and CALC3.CNT are working properly with their respective helpfiles, go to the next step.
Top Context-IDs Single .CNT Multi-file Bypass

A multi-file .CNT
A single CNT can be used to reference and index multiple helpfiles. It takes its name from the the startup helpfile, which is usually the Base file, although it could be one of the others...

So, now let's add CALC3.CNT to the end of NOTEPAD3.CNT, and make a few additional modifications....

:Base NOTEPAD3.HLP>main
Without a title line, each helpfile window would retain its own title.
:Title Joint Help on Notepad & Calculator
List the files to be included in a common FTS index.
:Index NOTEPAD3.HLP
:Index CALC3.HLP
1 Notepad
If you don't want the original Contents topic to show, you could either delete the next line or give it an indexing level of 0 (zero).
2 Contents for Notepad Help=36DM_ZC
2 Menu Commands
Topics in the Base file don't need their filename in their context reference.
3 File Menu=VDAGBM
3 Edit Menu=KK3LA6
3 Search Menu=46X4KA
2 Text Operations
3 Finding Text=1N6J089
3 Deleting Text=F0MDHQ
3 Formatting Text=365BRB
2 How-to....
3 Adding the Time and Date to Documents=29GAUW
3 Creating Time-Log Documents=E1S6RH
1 Calculator
This is not the Base file, so its filename is needed in every topic reference.
2 Contents for Calculator Help=1GIL4CU@calc3.hlp
2 Menu Commands
The next two topics are really Level 3, not Level 2, but the "tree" still works.
However, it would be better to number them "properly".
2 Edit Menu Commands=36_U_OF@calc3.hlp
2 View Menu Commands=0N2_HC@calc3.hlp
2 How-to....
3 Entering Calculations=NN.N0E@calc3.hlp
3 Using Calculator with the Clipboard=NHGN7H@calc3.hlp
3 Switching Calculators=FII8A2@calc3.hlp
3 Using the Scientific Calculator Statistical Functions=1LYQSN@calc3.hlp
Because the Level number of the next topic is 2 less than the topics in the preceding book, it shows as a single topic at the same level as that book.
1 (duplicate of third-last topic in next book) Using Operators=DXER7W@calc3.hlp
2 Operators & Functions
3 Converting Values to Other Number Systems=1NRF_IY@calc3.hlp
3 Using Standard Calculator Functions=25I1HX5@calc3.hlp
3 Using Memory Functions=10Y_OJO@calc3.hlp
3 Using Number-Base Functions=29LG_PG@calc3.hlp
3 Using Operators=DXER7W@calc3.hlp
3 Using Advanced Statistical Functions=IC2LR3@calc3.hlp
3 Using Other Advanced Functions=54P0_J3@calc3.hlp

Run NOTEPAD3.HLP. You'll see that the TOC tab now includes both NOTEPAD3.HLP and CALC3.HLP, and allows you to move easily between the two files.

Now rename NOTEPAD3.CNT as CALC3.CNT. Run CALC3.HLP. The TOC will work the same way, even though the "non:Base" HLP is started first.

That's all there is to it!


Bypassing the Contents tab
When a helpfile is run under Win95, it will normally open at the Contents tab. If you want it to open instead at a particular topic, you can specify this on the commandline by referring to the required topic-ID, using the -I switch, as in this example:
WINHLP32.EXE -I 1N6J089 C:\WINDOWS\NOTEPAD.HLP
This will open Windows 3 NOTEPAD.HLP at the topic "Finding Text".

(The commandline can be specified in the Properties tab of the Win95 desktop shortcut to the helpfile.)


If you have difficulty using these instructions, feel free to e-mail me a description of the problem.

My thanks to Paul Arnote and Lee Kimmelman, who first put me straight on .CNT files, thus allowing me to extend the usefulness of WinHelp3 by at least another two years.
Top Context-IDs Single .CNT Multi-file


Created 17 May 1997 : Last updated 18 Aug 1997
Syntax checked using Doctor HTML