It is such a common question and one not really answered in the workshop online help.
Open your project (.hhp) file in notepad or some other text editor.
Add a [MAP] section and define the IDs your require.
Add an [ALIAS] section and define the mapping between each ID and a help topic.
Best to show you by example:
[ALIAS]
IDH_HomePage=default.htm
IDH_TestTopic1=htmlfiles\testtopic1.htm
IDH_TestTopic2=mychm::htmlfiles\testtopic2.htm
[MAP]
#define IDH_HomePage 1000
#define IDH_TestTopic1 1001
#define IDH_TestTopic2 1002
Alternatively you can do this:
[ALIAS]
#include myhelp.ali
[MAP]
#include myhelp.h
where myhelp.ali is a text file containing
IDH_HomePage=default.htm
IDH_TestTopic1=htmlfiles\testtopic1.htm
IDH_TestTopic2=mychm::htmlfiles\testtopic2.htm
and myhelp.h is a text file containing
#define IDH_HomePage 1000
#define IDH_TestTopic1 1001
#define IDH_TestTopic2 1002
That's it. Nothing much to it is there? Recompile your .HHP file. Now your application can call help using context help Ids instead of topic file names.
Typical context call made from the application:
HtmlHelp(0, "c:\app\help\Help.chm", HH_HELP_CONTEXT, 1001);
Typical context call with window type $global_main included:
HtmlHelp(0, "c:\app\help\Help.chm>$global_main", HH_HELP_CONTEXT, 1001);
Notice that the example above contains a link to a topic in slave CHM. This works but on closer examination we find that the indexes don't merge. This seems to be a problem with latter versions of HTML Help (hhctrl.ocx).
EG. IDH_TestTopic2=mychm::htmlfiles\testtopic2.htm
See also: Context Ids in Merged Help (part 2)