Click here to Skip to main content
Licence CPOL
First Posted 13 Mar 2006
Views 62,916
Downloads 1,654
Bookmarked 49 times

Creating and Using HTML Help in MFC Applications

By | 3 Jul 2006 | Article
Managing HTML Help from scratch
HTML_Help_6.GIF

Introduction

Last time I tried to search the Internet to get a complete guide of using HTML in an MFC application, I found that there are many topics concerned with HTML Help but none of them have the same purpose with my desired work, so after working with HTML Help Workshop and researching documents, I finally decided to write a topic about working with HTML help from scratch.

In this presentation, I'll take you through 9 steps in 2 main stages to integrate an HTML help file with an MFC application. The 2 main stages are:

  1. Create HTML Help files
  2. Link HTML file to your own MFC application

Stage 1: Create *.chm (Compiled Help Module) file

First of all, you need to have HTML Help Workshop installed, it can be downloaded from: Microsoft HTML Help Downloads.

Edit your own *.chm file (Compiled Help Module). You can start from the beginning, but I think you'd better modify an existing .chm file that has the same structure with your desired .chm file. Do the following steps:

Step 1. Open HTML Help Workshop

Step 2. Click File->Decompile

Step 3. Choose destination folder where you want to store files after decompiling. You should create a new folder to store files because many files would be generated after decompiling.

Select the existing .chm file.

HTML_Help_1.GIF

In this example, I use PowerDVD.chm file because it has the same help structure with my application.

Step 4. Using an HTML Editor, Microsoft Frontpage for example, to edit the content of the HTML file(s) that has been extracted by HTML Help Workshop to the content that you want to have. This step is like the process of editing a website.

Step 5. Import and Compile your own help

  • Click File->New->Project. One dialog appears, select Next.
  • Assign a name for the project. Click Next.
  • Check all checkboxes you see in the new dialog. Click Next.
  • In the next three dialogs, the New Project Wizards will ask you to locate the table of contents, the Help index and the HTML files. You simply choose the appropriate files that HTML Help Workshop has extracted in the folder in Step 3. Click Next each time you've answered one dialog.
  • Click File->Compile

That is all you need to do to create your own .chm file, now forward to the 2nd stage.

Stage 2: Aggregate Help file to MFC Application

Step 6. Create a registry key:

  • Open command window, type regedit
  • Browse to KEY_LOCAL_MACHINE\Software\Microsoft\Windows\HTMLHelp
  • Create a new string value as follows:
    • Value name is your HTML help file name, for example: SampleHelp.chm
      • Value data is the path where the .chm file locates, for example: C:\TestHelp\MyHelp\ (remember to put one back-slash at the end).

HTML_Help_5.GIF

Step 7. Create an MFC application.

Step 8. Import htmlhelp.lib to your application.

  • Right click on the Resource Files->Add Files to Folder.
  • Select htmlhelp.lib.

HTML_Help_3.GIF

Step 9. Call Help

  • Create a button.
  • Add this line in the TestHelpDlg.cpp.
    #include "htmlhelp.h"
  • Assign an event to call the Help
    void CTestHelpDlg::OnHelp() 
    {
      HtmlHelp(this->m_hWnd, "HelpSample.chm", HH_DISPLAY_TOPIC, NULL);
    }

That's your work done!

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Nguyen Thanh Phuong

Web Developer

Vietnam Vietnam

Member

I am Vietnamese. I am PhD Student in Germany. My study is Information Technology.
My interest is wiki & programming.
Willing to share experience!

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
QuestionLayout RTL PinmemberMinoo Khazeni0:54 30 Oct '11  
GeneralDisplaying picture in HTML .chm Pinmembersharon16:53 26 Jul '09  
GeneralCLR PinmemberNicolas29297:03 3 May '09  
QuestionAre you able to catch "What's This" htmlhelp requests in a CFormView? PinmemberMember 34553988:03 13 Nov '08  
GeneralHi,i can't down demo project Pinmembersomnuc7:10 13 Oct '08  
GeneralModifications Pinmemberasalvat7:49 9 Apr '08  
QuestionDisplaying a perticular topic in .chm file. Pinmemberbankey101023:44 17 Oct '07  
GeneralProblem with HtmlHelp Pinmemberdandany4:33 12 May '07  
GeneralRe: Problem with HtmlHelp PinmemberAlfonsoFuentes8:13 14 Jun '08  
GeneralRegistry entry PinmemberPhil Sobolik9:51 12 Feb '07  
Actually the correct registry entry (at least in XP) is HKLM/SOFTWARE/Microsoft/Windows/HTML Help
GeneralThank you PinmemberBig Mouse17:58 18 Dec '06  
QuestionVisual C++ 2005 Upgrade? PinmemberDrTom29:45 26 Nov '06  
Generalcalling html help Pinmemberh_rw23:06 14 Jun '06  
GeneralRe: calling html help PinmemberNguyen Thanh Phuong16:20 15 Jun '06  
GeneralNice! Pinmemberthompsons10:24 2 Apr '06  
Generaldebug version Pinmemberv2.023:16 13 Mar '06  
GeneralRe: debug version PinmemberNguyen Thanh Phuong16:15 14 Mar '06  
GeneralRe: debug version Pinmemberv2.021:08 14 Mar '06  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web01 | 2.5.120529.1 | Last Updated 3 Jul 2006
Article Copyright 2006 by Nguyen Thanh Phuong
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid