Home | Overview | How Do I | Sample | Tutorial
This article describes the two forms of context-sensitive Windows Help supported by MFC.
F1 Help opens help on a topic associated with the currently selected item in your application. MFC supplies F1 help for windows, dialog boxes, message boxes, menus, and toolbar buttons.
SHIFT+F1 Help invokes a special “Help mode” in which the cursor turns into a Help cursor. The user can then select a visible object in the user interface, such as a menu item, toolbar button, or window. This opens help on a topic that describes the selected item.
The framework implements F1 help for windows, dialog boxes, message boxes, menus, and toolbar buttons. If the cursor is over a window, dialog box, or message box when the user presses the F1 key, the framework opens Windows Help for that window. If a menu item is highlighted, the framework opens Windows Help for that menu item. And if a toolbar button has been pressed (but the mouse not released yet), the framework opens Windows Help for that toolbar button when the user presses F1. (With extra work, you can implement F1 help for other things.)
When the user presses the F1 key, the framework processes the keystroke as a help request as follows, using a variation on the normal command routing. Pressing F1 causes a WM_COMMAND message to be sent for the ID_HELP command. If the application supports help, this command is mapped to the OnHelp message handler of class CWinApp and is routed directly there. OnHelp uses the ID of the current frame window or dialog box to determine the appropriate Help topic to display. If no specific Help topic is found, OnHelp displays the default Help topic.
If the user presses SHIFT+F1 or clicks on the Help toolbar button at any time that the application is active, the framework puts the application into Help mode and changes the cursor to a Help cursor (arrow + question mark). The next thing the user clicks determines what help context the framework opens in Windows Help.
When the user presses SHIFT+F1 or clicks on the Help toolbar button, the framework routes the command ID_CONTEXT_HELP through the normal command routing. The command is mapped to the CWinApp member function OnContextHelp, which captures the mouse, changes the cursor to a Help cursor, and puts the application into Help mode. The Help cursor is maintained as long as the application is in Help mode but reverts to a normal arrow cursor if it is not over the application that is in Help mode. Activating a different application cancels Help mode in the original application. While in Help mode, the application determines what object the user clicks and calls the CWinApp member function WinHelp with the appropriate context, determined from the object clicked upon. Once an object has been selected, Help mode ends and the cursor is restored to the normal arrow.
Note For information about how context-sensitive Help is managed in OLE applications, see the article Help: OLE Support for Help.
For more information, see Technical Note 28.
See Also Help: Message-Map Support