Visual Basic Integration
Previous Topic  Next Topic 

WinHelp Integration

Integrating a WinHelp file into Visual Basic is very straightforward. Please download the following simple example written in VB6:-

HtmlHelp Integration

If your needs are relatively simple, i.e. you want your users to press F1 and display help for whatever form or control currently has focus then the following simple tutorial is all you need.

Simple Tutorial for integrated HtmlHelp into your VB6 Application

If you are using Visual Basic 6, you need to specify the help file that you want to use by setting the App.HelpFile property. E.g.: App.HelpFile = App.Path & "\helpfile.chm"

To make a help window appear when the user presses F1, set the form's WhatsThisHelp property to False. Then set the HelpContextID property of the form to the HelpID for the Topic that you want to link to in Fast-Help. The HelpID can be found by clicking on the "Properties" tab, below the editor in Fast-Help. When the user presses F1 while the form is active, that topic will be displayed.

You can also assign HelpIDs to HelpContextID properties of controls on the form. If the user presses F1, and the control that has keyboard focus has a non-zero HelpContextID, then that topic will be displayed instead of the form's topic.

If you want help text to appear in small popup windows rather than in a top-level help window, set the form's WhatsThisHelp property to True. Set the WhatsThisHelpID property of each control of the form to the appropriate HelpID from Fast-Help.

To show a help topic from within your Visual Basic code, you need to use the HtmlHelp API call. To display the topic that has HelpID 1234 in Fast-Help, simply call: HtmlHelp(frmMain.hWnd, App.HelpFile, HH_HELP_CONTEXT, ByVal CLng(1234))

You can declare this function with the code Public Declare Function HTMLHelp Lib "hhctrl.ocx" Alias "HtmlHelpA" (ByVal hwnd As Long, ByVal lpHelpFile As String, ByVal wCommand As Long, dwData As Any) As Long or by adding HTMLHelp.bas to your VB application.

More complex VB Integration needs

If your needs are complex then we recommend VB Guru, David Liske's example. Using this you can copy and paste his code into your own application:

Do you need a Header file?

In both the "HtmlHelp Compiler Options" and "WinHelp Compiler Options" there is an Application Support tab where you can check the option to create a VB Header file. When you next compile you will find this file in your project folder and you can integrate it into your application.