It is often desirable for desktop developers to include some sort of local help in order to demystify the use of an application for a user. This is particularly useful when there is no reliable internet connection available. There are a number of commercially available programs which propose to accomplish this, but most are not free. A freestanding, Microsoft HTML Help Workshop, is still available, but no longer is under active development, and works poorly (if at all) on Windows 10 systems. MFC C++ developers, used to be able to click on Context Sensitive Help in the Wizard to implement HTML Help, but as of Visual Studio 2017, this is no longer an option. The current application provides developers with a customizable, freestanding help application patterned after HTML Help Workshop, written entirely in C#, and which works on Windows 10.
For developers who prefer .NET and C# for demonstrating proof of concept desktop applications, whether or not they are intended to ultimately be run via a network, the only user help options are to purchase a subscription to an app, for example, RoboHelp (C) Adobe Systems, or to provide HTML files on a server. While the latter makes it easy to update for all users, not all users have access to internet, or they operate in a network environment that prevents remote server access. It seems apparent that an economically feasible, customizable, locally-based HTML help system should be of considerable value to C# Windows developers.
Using the Code
THtmlHelp window contains only two major components, a Tab Control, and a Web Browser. The Tab Control contains three pages, a Contents page with a TreeView that lists all the help files, an Index page that contains a list of key words, and a Search page that facilitates searching all of the help files for a particular word. The web browser component is a modified and stripped down version of that obtained from the CodeProject article "Web Browser in C# by Claudia Goga, 20 Feb 2010. The source code contains two separate applications,
KeyWordListBuilder which can be compiled and run separately. The
THelpViewer executable is the actual HTML Help Viewer. The downloadable source has only rudimentary pages designed to serve as a template for developers to create their own help pages. In order to do that, a developer must utilize an HTML editor. In this respect, the application is similar to most other HTML help programs. Running THtmlHelp.exe in the correct directory structure will result in the application automatically populating the
TabControl TreeView with all of the HTML help files. The Index Page needs to be handled separately in order to provide a list of key words and their respective links to appropriate help files. THtmlHelp.exe will automatically load the IndexData.xml file that contains the necessary information to populate the Index Page. In order to customize the IndexData.xml file, you can either do it by hand, or better yet, use the accompanying
KeyWordListBuilder application. The builder app contains some simple instructions and will allow you to add key words and associate them with a particular file, then save the entire list as an XML file. Please note that both THtmlHelp.exe and the IndexData.xml file MUST be placed in the root directory of your application, and that directory MUST also contain the subdirectory 'hlp' which in turn contains all of your help htm files and a subdirectory for images if you choose to utilize any. Note further that the title bar of the
THtmlViewer will contain the name of the HTML page as you have named it.
The code below shows how the viewer loads all of the files contained in the target directory, then loads the
TreeView and the
Browser. This assumes that there are files including a contents.htm in the hlp directory.
public ArrayList arList = new ArrayList();
public String Url = string.Empty;
public String sPath = string.Empty;
public String sFolderPath = string.Empty;
sPath = GetFullPathName("hlp/contents.htm");
Url = "file:///" + sPath;
int n = sPath.LastIndexOf('\\');
sFolderPath = Path.GetDirectoryName(sPath);
public void ProcessDirectory(string targetDirectory)
string fileEntries = Directory.GetFiles(targetDirectory);
foreach (string fileName in fileEntries)
The code below shows how the
TreeView is populated.
private void myTreeView()
string directoryName = GetFullPathName(sPath);
int n1 = directoryName.LastIndexOf('/');
int n2 = directoryName.Length;
directoryName = directoryName.Remove(n1, n2 - n1);
string yourParentNode = "Contents";
var txtFiles = Directory.EnumerateFiles(directoryName);
foreach (string currentFile in txtFiles)
string fileName = currentFile.Substring(directoryName.Length + 1);
n1 = fileName.LastIndexOf('.');
n2 = fileName.Length;
fileName = fileName.Remove(n1, n2 - n1);
catch (Exception e)
MessageBox.Show("Warning: " + e.Message);
Populating the Index Page is facilitated by the accompanying
- Use New, Open, and Save to manage Index Page lists (IndexData.xml).
- Tools / Add Keyword to add to a list
- Associate each keyword with a file in the hlp directory
- Tools / REmove a Keyword to delete a highlighted list element.
- Save the list as 'IndexData.xml' in the app root directory (see above).
With the THtmlHelp.exe in your calling application root directory, together with the necessary accompanying IndexData.xml file and hlp folder, your calling application can use the following code to bring up the help application.
private void contentsToolStripMenuItem_Click(object sender, EventArgs e)
Process p = Process.Start("THelpViewer.exe");
protected override bool ProcessCmdKey(Keys keyData)
if (keyData == Keys.F1)
Process p = Process.Start("THelpViewer.exe");
Points of Interest
It strikes me as odd that Visual Studio no longer supports HTML Help Studio (HTMLS) and developers are left on their own to provide such help. There may exist some work-around to get HTMLS to work properly, but I have been unable to find it. That is why I was compelled to develop this application. Having spent a fair amount of time programming in C++, I have been pleasantly surprised to find how straightforward, efficient, and powerful Visual Studio C# is. While this current effort could use some refinement, perhaps the single best one would be to somehow compress all the necessary help files and the application itself into a single chm-like package. I considered simply zipping all the components together, but quickly realized that there are a number of different zip file formats and accessing the zipped application would not be easy. Additionally, there is undoubtedly a way to facilitate context sensitive help, but this would add considerable complexity to the program.
- Version 2.2 March 05, 2018