Question

I have a C# project that contains numerous help buttons. When one of these buttons is clicked, it opens a Help file (Help.chm) to a relevant page. Here is the code to do that for one of the pages:

ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = "hh.exe";
startInfo.Arguments = "Help.chm::/html/97198ffa-adb2-4897-b5e4-5bba54252900.htm";//page id
Process.Start(startInfo);

This works fine, but now when the user clicks a different help button (or even the same one) a new Help file opens leaving potentially many redundant chm files open. If my Help file is already open, is there any way to change the page instead? If there is a way to do this through the command line, that would be a good place to start.

Was it helpful?

Solution

Like Helen mentioned before I'd really recommend using the Help.ShowHelp method.

    private void btnHelpTopic1_Click(object sender, EventArgs e)
    {
        // sHTMLHelpFileName_ShowWithNavigationPane = "CHM-example_ShowWithNavigationPane.chm"
        // This is a HelpViewer Window with navigation pane for show case only 
        // created with Microsoft HTMLHelp Workshop
        helpProvider1.HelpNamespace = Application.StartupPath + @"\" + sHTMLHelpFileName_ShowWithNavigationPane;
        Help.ShowHelp(this, helpProvider1.HelpNamespace, @"/Garden/tree.htm");
    }

    private void btnHelpTopic2_Click(object sender, EventArgs e)
    {
        helpProvider1.HelpNamespace = Application.StartupPath + @"\" + sHTMLHelpFileName_ShowWithNavigationPane;
        Help.ShowHelp(this, helpProvider1.HelpNamespace, @"/Garden/flowers.htm");
    }

Please have a look at the code and the small GUI (snap attached). The topics are refreshed after the users button click (e.g. Help Topic1). Note the help file created with Microsoft HTMLHelp Workshop may need a auto sync parameter.

C# code, GUI and opened help file.

For download I provide a C# VS2008 Project including the code above and the help files with different help viewer windows (different CHM files for show case only).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top