0

We're currently using HTML Help to display CHM help files in our software. We'd like to change how we're opening the help however, to open it in our own custom window with an embedded browser.

Achieving this by directly requesting topic pages to be opened with URLs is straightforward enough, however, we'd like to maintain the usage of Topic IDs such that the editorial team can freely re-structure and re-name the help as they see fit, only by manipulating the maps and aliases.

I've been digging around for a bit and couldn't find any (reasonably cheap) way to get a URL to open from a Topic ID, such that I could request a URL to open in the custom window. Am I missing a trick, or are there any libraries out there that might facilitate this?

Wandering Fool
  • 2,170
  • 3
  • 18
  • 48
Zepee
  • 1,640
  • 3
  • 20
  • 40
  • Why is this tagged as C++? – NathanOliver Aug 12 '15 at 15:23
  • Our code base is split between managed/unmanaged C++ and C#, we could use a library in either of the languages – Zepee Aug 12 '15 at 15:32
  • @Zepee - you certainly know that you will lose all functionality of the HTMLHelp Viewer with table of contents, index, and search? – help-info.de Aug 12 '15 at 16:03
  • Yep :) This is more or less to open certain help pages in our own light WPF window, and we don't want the full blown help to show. Currently we have it working through hard coded URLs, but we want to make it work through topic IDs – Zepee Aug 12 '15 at 16:07
  • You might have a look at the Free Pascal "chmls" command, specifically its extractalias command. chmls is a helper tool to examine CHM structures that was used to construct the CHM lib and compiler. Maybe you can port selected code. – Marco van de Voort Aug 14 '15 at 10:06

1 Answers1

2

AFAIK you need a valid URL with the topic filename e.g. "Garden/garden.htm" when using a web browser control. So other solutions are very difficult and I think not possible with a web browser control.

You know you can do a hard coded call with e.g. following code:

    public static string GetChmUrl(string fileName, string page)
{
  StringBuilder url = new StringBuilder();
  url.AppendFormat("mk:@MSITStore:{0}::", fileName);
  if (page.IndexOf('/') != 0) url.Append('/');
  url.Append(page);
  return url.ToString();
}

and

   webBrowser1.Navigate(new Uri(GetChmUrl(Application.StartupPath + sHTMLHelpFileName_ShowWithoutAutoSync, "Garden/garden.htm")));

For showing HTMLHelp topics by TopicId without the full blown help window you may create a special window type for the HTMLHelp Viewer window. OK – this is more a help authoring work preparing a call from your application. It’s possible by compiling the CHM in a special way and reduce it to the content pane normally on the right side of the HTMLHelp Viewer.

You can call the content by TopicId and the result is shown in the snapshot:

    private void btnTopicId_Click(object sender, EventArgs e)
{
    Help.ShowHelp(this.btnOpenHelpShowTopic, helpProvider1.HelpNamespace, HelpNavigator.TopicId, @"10000");
}

enter image description here

Many years ago there was a so called “embedded help” for application as you can see in the snapshot. This was done by HTMLHelp API call. I have old Delphi code but not translated to .net. HTMLHelp is used for nearly 20 years now and today there is more use of web help. So you have to think about and decide.

enter image description here

You need to use marshalling to call the unmanaged HTML Help API from a Visual C# application. Using HTMLHelp API in .net is not easy. To give this a try you may start with a download sample (at the end of the article) from: https://support.microsoft.com/en-us/kb/317406

I attached a snapshot too:

enter image description here

HTH.

help-info.de
  • 6,695
  • 16
  • 39
  • 41
  • Thanks for the reply. These seem to be the conclusions I arrived at during my own investigations. You can either have a windows HTMLHelp window (which can be customized to some degree) where you can open topics by ID, or you have your own HTLM window and open them by URL. As far as I could tell there is no easy way of manually reading the chm mappings and infer the URL form the topic IDs. It seemed possible to decode the ALink mappings, some custom libraries manipulate them, just not a simple solution to implement, and probabyl not worth the cost. – Zepee Aug 17 '15 at 13:17