Use Id instead of Context

691 views Asked by At

I use HelpNDoc for providing a chm-file for the context sensitive help in my application.

In this software you define a help-ID and a corresponding help-context. The help-ID for example maybe "SystemSetup" and the help-context is 57.

Now my question:

I can call the help this way:

System.Windows.Forms.Help.ShowHelp(null, @"myhelp.chm", HelpNavigator.TopicId, "57");

and all works well, but can I some how call ShowHelp with the help-ID ("SystemSetup") instead?

I ask this cause the help-context can change, but the help-ID stays always the same.

2

There are 2 answers

2
Patrick Hofman On BEST ANSWER

There is no easy way to do that. The Topic ID is the best thing you have to directly point to a topic. The software we use to generate the CHM files allows names to be given to topics, which can be retrieved using your code.

If that doesn't work for you, and the only thing you have is the name, you might get it done by using the Topic enum value and the name of the HTML file (if it is distinct enough).

Something like this could be what you need (you can retrieve the html file name through an CHM viewer):

System.Windows.Forms.Help.ShowHelp(null, @"myhelp.chm", HelpNavigator.Topic, "SystemSetup.html");

I don't know which option is better. That is up to you and your specific scenario.

0
jonjbar On

HelpNDoc uses the following pattern to name topic files: "HELP_ID.htm" where HELP_ID is the chosen unique Help Id for that topic. So you can reliably open a specific topic using the following command:

System.Windows.Forms.Help.ShowHelp(null, @"help.chm", HelpNavigator.Topic, "HELP_ID.htm");

Also, as you found out, HelpNDoc is able to generate a source file with constants. And you can automate its generation and include it in your build process by creating a new "Code" build. See the step by step guide: How to create a new documentation output to be published