- Table of Contents
- Copyright
- About the Authors
- About the Contributors
- Acknowledgments
- Tell Us What You Think!
- Introduction
- How to Use This Book
- What You Need to Use This Book
- What's New in Visual C++ 6.0
- Contacting the Main Author
- Part I: Introduction
- Chapter 1. The Visual C++ 6.0 Environment
- Part II: MFC Programming
- Chapter 2. MFC Class Library Overview
- Chapter 3. MFC Message Handling Mechanism
- Chapter 4. The Document View Architecture
- Chapter 5. Creating and Using Dialog Boxes
- Chapter 6. Working with Device Contexts and GDI Objects
- Chapter 7. Creating and Using Property Sheets
- Chapter 8. Working with the File System
- Chapter 9. Using Serialization with File and Archive Objects
- Part III: Internet Programming with MFC
- Chapter 10. MFC and the Internet Server API (ISAPI)
- Chapter 11. The WinInet API
- Chapter 12. MFC HTML Support
- Part IV: Advanced Programming Topics
- Chapter 13. Using the Standard C++ Library
- Chapter 14. Error Detection and Exception Handling Techniques
- Chapter 15. Debugging and Profiling Strategies
- Chapter 16. Multithreading
- Chapter 17. Using Scripting and Other Tools to Automate the Visual C++ IDE
- Part V: Database Programming
- Chapter 18. Creating Custom AppWizards
- Chapter 19. Database Overview
- Chapter 20. ODBC Programming
- Chapter 21. MFC Database Classes
- Chapter 22. Using OLE DB
- Chapter 23. Programming with ADO
- Part VI: MFC Support for COM and ActiveX
- Chapter 24. Overview of COM and Active Technologies
- Chapter 25. Active Documents
- Chapter 26. Active Containers
- Chapter 27. Active Servers
- Chapter 28. ActiveX Controls
- Part VII: Using the Active Template Library
- Chapter 29. ATL Architecture
- Chapter 30. Creating COM Objects Using ATL
- Chapter 31. Creating ActiveX Controls Using ATL
- Chapter 32. Using ATL to Create MTS and COM+ Components
- Part VIII: Finishing Touches
- Chapter 33. Adding Windows Help
- Part IX: Appendix
Managing Help Projects
As mentioned previously, Microsoft doesn't provide any integrated tools for developing your own RTF files that go into a help project. However, Visual C++ 6.0 does include a tool that is very useful for managing all the other tasks involved in developing help projects. This tool is the Help Workshop.
You won't find the Help Workshop in any of the menus in Developer Studio, although you can add it to your Tools menu as you saw in Chapter 1. The executable for Help Workshop is found in ...\vc\bin\hcw.exe under whichever directory you have installed Developer Studio.
Help Workshop allows you to do many different things associated with help project development, including the following:
- Create and edit help project (.hpj) files
- Edit contents (.cnt) files
- Compile your help project
- Test your help project
The next few sections cover each of these items.
Help Project Files
The help project (.hpj) file controls how the various pieces of your help project are assembled to create the .hlp file that is actually used by your applications. This file contains several sections, similar to those that you might have seen in .ini files. You may edit the .hpj file for your project with any text editor or you can edit it from within the Help Workshop, as shown in Figure 33.11.
Figure 33.11 Help Project Files in Help Workshop.
Help project files contain the following sections:
- [OPTIONS]: This section contains several different option settings that affect how the help project is built, including the title of the project, the context name for the contents page, and the directories that are searched for component files.
- [FILES]: This section lists all the .rtf files that are to be used in creating the help file.
- [ALIAS]: This section maps numeric constants to context names, which are used for context-sensitive help.
- [MAP]: This section contains the mappings that assign numeric values to the context constants, in much the same way that #define is used in C/C++ files. In most cases, this section simply #includ e's one or more .hm files that contain the actual mappings.
You may edit the help project file directly, using a text editor, although it is generally easier to use Help Workshop, which provides a nice graphical interface for filling in all the relevant settings, including additional help on what each of the settings means. For example, a portion of the dialog for setting project options is shown in Figure 33.12.
Figure 33.12 Help Workshop Options settings.
Contents Files
The contents (.cnt) file specifies the help page that will be displayed to the user when he or she chooses the Contents tab of WinHelp. Once again, you can edit the .cnt file directly with a text editor, although it is easier to use the graphical interface provided by Help Workshop. To do this, simply open your .cnt file in Help Workshop, which will present a dialog like the one shown in Figure 33.13.
Figure 33.13 Editing Contents files.
This dialog allows you to use the buttons on the left to edit or remove existing entries, as well as add new entries to your table of contents.
Compiling Help Projects
Before your applications can make use of your help projects, all the components previously discussed must be compiled to create a single Windows help file, which is given an .hlp extension. You may compile your help project from within Help Workshop by selecting the Compile command from the File menu. This is useful for when you are developing your help project.
However, if you created your application with AppWizard, you will notice that a batch file named MakeHelp.bat has been added to your project directory. This file is called whenever you build your Visual C++ project and is responsible for creating the help file for your project. An example of MakeHelp.bat is shown here:
@echo off REM -- First make map file from Microsoft Visual C++ generated resource.h echo // MAKEHELP.BAT generated Help Map file. Used by HELPSDI.HPJ. >"hlp\HelpSdi.hm" echo. >>"hlp\HelpSdi.hm" echo // Commands (ID_* and IDM_*) >>"hlp\HelpSdi.hm" makehm ID_,HID_,0x10000 IDM_,HIDM_,0x10000 resource.h >>"hlp\HelpSdi.hm" echo. >>"hlp\HelpSdi.hm" echo // Prompts (IDP_*) >>"hlp\HelpSdi.hm" makehm IDP_,HIDP_,0x30000 resource.h >>"hlp\HelpSdi.hm" echo. >>"hlp\HelpSdi.hm" echo // Resources (IDR_*) >>"hlp\HelpSdi.hm" makehm IDR_,HIDR_,0x20000 resource.h >>"hlp\HelpSdi.hm" echo. >>"hlp\HelpSdi.hm" echo // Dialogs (IDD_*) >>"hlp\HelpSdi.hm" makehm IDD_,HIDD_,0x20000 resource.h >>"hlp\HelpSdi.hm" echo. >>"hlp\HelpSdi.hm" echo // Frame Controls (IDW_*) >>"hlp\HelpSdi.hm" makehm IDW_,HIDW_,0x50000 resource.h >>"hlp\HelpSdi.hm" REM -- Make help for Project HELPSDI echo Building Win32 Help files start /wait hcw /C /E /M "hlp\HelpSdi.hpj" if errorlevel 1 goto :Error if not exist "hlp\HelpSdi.hlp" goto :Error if not exist "hlp\HelpSdi.cnt" goto :Error echo. if exist Debug\nul copy "hlp\HelpSdi.hlp" Debug if exist Debug\nul copy "hlp\HelpSdi.cnt" Debug if exist Release\nul copy "hlp\HelpSdi.hlp" Release if exist Release\nul copy "hlp\HelpSdi.cnt" Release echo. goto :done :Error echo hlp\HelpSdi.hpj(1) : error: Problem encountered creating help file :done echo.
The first half of MakeHelp.bat is devoted to generating the help mapping (.hm) file that is used to associate help contexts with the resource identifiers used within your C++ project. You will look at help mapping files and the makehm utility in more detail later.
The most important part of MakeHelp.bat is the line that actually compiles your help project. This is done by calling hcw.exe, as in the following line:
start /wait hcw /C /E /M "hlp\HelpSdi.hpj"
The /C switch tells hcw to compile the help project file that is specified, and the /E switch tells hcw to exit when it finishes. The /M option is used to minimize the window for hcw so that it is out of the way while it is compiling.
If your help project compiles successfully, you will be the proud owner of a bouncing baby help file with a .hlp extension. The remainder of MakeHelp.bat simply copies this file (and your contents file) to the appropriate target directories. Be sure that you distribute these files with your application.
Testing Help Projects
The next section shows how to call on the Windows help system from your applications. However, it is often useful to be sure that your help file is behaving as expected before you integrate it with your application.
Help Workshop can be a great help when you test your help file, and you don't need to change the source code in your application and rebuild each time.
From the Test menu of the Help Workshop, you can test the contents file for your help project, send a macro to WinHelp, or use a graphical interface to make calls to the WinHelp API directly. In addition, you can close all of the help windows that are left hanging around with a single menu command.
Calling WinHelp from Your Applications | Next Section

Account Sign In
View your cart