Make your MS-HTML-help-contents perfect
Download first tool
Download second tool
HTML help content is a chm file compiled by Microsoft "HTML help workshop" from a set of html files.
This article shows you how to improve your C/C++ code and html files easily to ensure that chm files compiled work perfectly.
Following is available for C/C++ programs, I guess it is OK for VB and other languages also - but I never use MS help contents for them, please make decision by yourself.
What does "perfect" mean?
We often meet 2 problems when use chm file inside our program:
- Missed links from program
For example, when user clicks a help button on dialog, menu or other places to display help for the issue, but a missed page shows "The page can not be displayed ..."
- Missed links inside chm file, which mainly are:
- Navigation errors
Click a link on a page to navigate to another page but hyperlink is broken.
- Image errors
Images can not be displayed, because of <img> link errors.
- All other link errors
Such as wrong references to css and js files.
"Perfect" means that you will not worry again about missed links from today if you read the article carefully and do the same thing as I do - it is very easy!
Simple to get the best
- Avoid missed links from C/C++ programs
Let's have a look for MS help function to display a page:
What do we need to do?
Next time, we call the function in another way: a single path string inside a brace, for example:
We can also use sub-directory, for example:
To make sure the call successfully, we just need to use #define directive to define YOUR_DISP (see bellow).
Calls inside C/C++ a program should be in the same format depended on structures of html files.
Following is example of my #define:
#define DISP_HELP(a) HelpHtm::DisplayPage(m_hWnd,a)
HelpHtm::DisplayPage() is a static class function, which looks like:
void HelpHtm::DisplayPage(HWND hWnd,CString csHtm)
//get absolute path to your chm file - maybe with some directory, such as
Calling the #define directive in MFC code as:
(Note: m_hWnd is MFC Windows handle).
Anyway, I am sure you can manage #define directive call successfully.
Why use it in this way?
Here is first tool, you can download it now.
The tool goes through your C/C++ code and finds all path strings inside the #define directive's braces then checks if they are valid in html files - that is all story.
I developed the tool in 3 hours and get big benefits in my whole programming life.
Please note, the tool is for private use, interface is ugly, no help content for it, but it works excellent.
Following is its interface:
- [Program directory] is your C/C++ project directory
- [Help file directory] contains your help html files.
- [Function word] is #define directive used in C/C++ code, mine is DISP_HELP
- Left list box displays all links found inside #define directive's braces of C/C++ program.
If a link starts with 0, it means it is a missed link, you have to find the link from C/C++ code to correct it except you don't care.
If a link starts with 1, it means OK.
- Right list box displays all html files.
Prefix 1 means the file is used by C/C++ code, 0 means not.
My html files are:
Do not use forward slash in C/C++ call, such as YOUR_DISP("path\\path0\\file0.htm"), the tool ignores this kind calls.
Please only use backward slash, such as YOUR_DISP("path/path0/file0.htm").
As I said before, the tool is for private use and very easy to be developed, important thing is its idea.
If you do not like its #define directive or interface, you can code yourself - please submit it here so we can share our works.
- Avoid Missed links inside chm file
The best way to avoid this kind errors is to check missed links directly in html files before compiled them as a chm file, so we can modify errors from html pages.
To check missed links of this kind, you need to download second tool.
The tool has help content to show you how to use it in details, I do not repeat again here.
From first day I had the two tools, all of my MS help contents work perfect without any missed link.
I hope you get same benefits and release all headaches about html help contents for forever.