Visual C++ 6 Unleashed

Visual C++ 6 Unleashed

By MICKEY WILLIAMS and David Bennett

Adding Context-Sensitive Help

You can make your applications much more user-friendly by presenting help for a particular dialog or menu command that the user has selected when he presses F1. This is much easier to use than searching through the whole help file for the information.

Using the MFC help framework, adding context-sensitive help is rather simple. To show how to do this, we will add a new menu command to an application and add context-sensitive help for it.

You will need to add the menu to your application, adding a command handler for it as you normally would. For the sake of this example, assume that the new command is given the ID of ID_MY_COMMAND.

Next, you will need to add a help topic for this command, as shown earlier. For this example, make sure to use the (#) footnote to assign a context name of my_command.

Now, you will need to add an entry to the [ALIAS] section of the project's .hpj file, like the following:

HID_MY_COMMAND = my_command

Now when you build your application, Developer Studio will call on MakeHelp.bat. One of the first things that this batch file will do is call on the makehm utility to map help context IDs for the resource IDs that are used in your application. This mapping is written to a .hm file, which would contain a line like the following:

HID_MYCOMMAND       0x18003

This .hm file is included in the [MAP] section of the help project (.hpj) file. This mapping, when combined with the entry in the [ALIAS] section, will tell WinHelp to bring up the my_command help topic whenever the user highlights the new menu command and presses F1.

Share ThisShare This

Informit Network