VB6 beginners tutorial - Learn VB6

Advanced VB6 tutorial - Learn Advanced VB6

Systems Analysis - System analysis and Design tutorial for Software Engineering

You are here: Visual Basic > Advanced VB6 tutorial > Chapter 7

Context-Sensitive Help With the HelpContextID Property

Each standard visible object in Visual Basic, including the menus and forms, has a HelpContextID property. The HelpContextID property is a numeric value corresponding to a Context ID or Topic ID in a Help file. The default value for HelpContextID is 0, meaning no context help is provided. The HelpContextID for an object is usually specified at design time, but can be defined at runtime as well.

The HelpContextID property of an object maps to a Topic ID and its corresponding topic in a Help file. At runtime when that object is active and the F1 key is pressed, Windows will open the Help file for the application with a specific topic displayed. Visual Basic applications have a hierarchy that is followed to determine which topic to display when Help is invoked. When the F1 key is pressed, the application does the following:

  1. It checks the HelpContextID of the active control on the active form. If that ID is non-zero, it opens the application Help file with the corresponding topic displayed.

  2. If the HelpContextID is zero,Visual Basic checks the HelpContextID of the container control for the active object. Usually this is the active form itself. It can also be another container control such as Frame or PictureBox. If the ID of the container is non-zero, Help is opened with the container's corresponding Help topic displayed.If the HelpContextID for the container is also zero, then the application checks the container's container for a HelpContextID.

  3. Visual Basic keeps checking the HelpContextIDs of objects' containers, and then of containers' containers, and so on, until it gets to the form that is the highest-level container. If a nonzero HelpContextID is found along the way, that help topic is displayed.

  4. If all HelpContextIDs through the form level are zero, the Help file for the application is opened to the Contents page for a WinHelp file (refer back to Figure 7.2) or, for an HTML Help file (refer to Figure 7.1), the default topic or the contents page if no default topic exists.

NOTE : Context ID or Topic ID? The HelpContextID and WhatsThisTopicID properties discussed in this chapter must match Context ID numbers or Topic ID numbers in the corresponding Help file. HTML Help documentation uses the term "Topic ID" while WinHelp documentation uses the term "Context ID" to refer to these topic-mapping numbers. We shall use the term Topic ID in this chapter because that's the term used for HTML Help, the Microsoft standard.

The HelpContextIDs of objects must correspond to the Topic IDs of the Help file specified in the Project Properties window (refer back to Figure 7.3) or to a Help file previously identified to the application through the App.HelpFile property. If a non-zero HelpContextID for an object exists but a Help file has not been specified for the application, the user will get no response when the F1 key is pressed.

Help is displayed only if the Help file has been set in the application and a Topic ID has been defined for a control. If a Topic ID corresponding to the HelpContextID does not exist in the Help file, the Windows Help engine will display an error stating that the help topic does not exist.


<< Previous | Contents | Next >>

Home | About Us | Privacy Policy | Contact Us

Copyright © | All Rights Reserved