locked
Displaying a specific page from help file (.chm) from C# Windows form using System.Windows.Forms.Help.ShowHelp() RRS feed

  • Question

  • Hi folks, 

    Would greatly appreciate your help here.

    Calling System.Windows.Forms.Help.ShowHelp() from a form, and passing it the Tag value of the selected tab in the tab control, does not seem to work.  What am I doing wrong here?

    Tried these options:

    System.Windows.Forms.Help.ShowHelp(this, "foo.chm", HelpNavigator.TopicId, this.tabControl1.SelectedTab.Tag.ToString());

    and

    System.Windows.Forms.Help.ShowHelp(this, "foo.chm",  this.tabControl1.SelectedTab.Tag.ToString());

    Appreciate your help.

    Thanks.


    Khaja

    Tuesday, May 13, 2014 7:12 AM

Answers

  • You didn't specify, what your

    this.tabControl1.SelectedTab.Tag.ToString()

    returns. It should return the filename of the compiled html file in your CHM.

    Moreover, the path to the CHM should be full absolute path, not just a CHM file name. You need to resolve the full path at runtime.

    So the correct call should be like this:

    System.Windows.Forms.Help.ShowHelp(this, @"c:\Program Files\MyApp\foo.chm", "my_topic_in_chm.html");


    Peter Macej, VSdocman - Commenter and generator of class documentation for C#, VB .NET and ASP .NET

    Tuesday, May 13, 2014 10:38 AM

All replies

  • You didn't specify, what your

    this.tabControl1.SelectedTab.Tag.ToString()

    returns. It should return the filename of the compiled html file in your CHM.

    Moreover, the path to the CHM should be full absolute path, not just a CHM file name. You need to resolve the full path at runtime.

    So the correct call should be like this:

    System.Windows.Forms.Help.ShowHelp(this, @"c:\Program Files\MyApp\foo.chm", "my_topic_in_chm.html");


    Peter Macej, VSdocman - Commenter and generator of class documentation for C#, VB .NET and ASP .NET

    Tuesday, May 13, 2014 10:38 AM
  • Thanks for your help Peter.

    The call I am making now is this:

    System.Windows.Forms.Help.ShowHelp(this, "tcpip.chm", this.tabControl1.SelectedTab.Tag.ToString());

    In this call this.tabControl1.SelectedTab.Tag.ToString() returns "d20435e1-cd75-4e53-b678-b60501305145.htm"

    That presumably is calling this version of ShowHelp which has four overloads.

    public static void ShowHelp(Control parent, string url, string keyword);

    However, when I run that, I get the help file come up but the pane on the right has an error message.  The pane on the right shows this:

    This page can’t be displayed
    • Make sure the web address //ieframe.dll/dnserrordiagoff.htm# is correct.
    • Look for the page with your search engine.
    • Refresh the page in a few minutes.

    However, if I make the call with some search string where this.tabControl1.SelectedTab.Tag.ToString() returns "IPv4 General Tab" or some other text in the help file, it does show content in the pane on the right that contains the test.  It seems to search the page.  

    What I need is to be able to get to a specific page.... and I thought when "d20435e1-cd75-4e53-b678-b60501305145.htm" is passed, since that is in the zip (.chm) file as one of the htm files, it will pop up.  It won't.  

    What might I be doing wrong?

    Thanks again.


    Khaja

    Tuesday, May 13, 2014 3:28 PM
  • Passing the "d20435e1-cd75-4e53-b678-b60501305145.htm" should work. Are you sure that the "d20435e1-cd75-4e53-b678-b60501305145.htm" exists in your CHM? Is it in the root of the CHM? Isn't it in any subfolder, e.g. "html/d20435e1-cd75-4e53-b678-b60501305145.htm"? If yes, try to include the subfolder in your call.

    Peter Macej, VSdocman - Commenter and generator of class documentation for C#, VB .NET and ASP .NET

    • Proposed as answer by Caillen Wednesday, May 14, 2014 9:23 AM
    Tuesday, May 13, 2014 4:35 PM
  • Hi Khaja.Ahmed,

    Peter is right, you'll get this error message when the path of the htm is not correct. To get the right htm URL, you could right click the content and click "Jump to URL..."

    Here's the example code:

    Help.ShowHelp(this, @"D:\mmc.CHM", @"/html/99bd7ac1-9beb-438d-900e-426da41898b8.htm");


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, May 14, 2014 9:42 AM
  • Thanks a bunch Peter. Yes, having the full path, "html\foo.htm" did the trick.  Appreciate your help.

    A follow on / related question:

    How do I find the TopicID of topics in a .chm  help file?

    Just to keep the forum clean and searchable, I'll ask that as a separate question if it has not already been answered.  I searched some days ago in vain.  


    Khaja

    Thursday, May 15, 2014 4:37 AM