Email this Page Log Support Call Send Feedback Print

Previous Topic

Next Topic

Book Contents

Book Index

Hooking a Visual Basic Application to a WinHelp File

For a compiled Visual Basic (VB) program and a WinHelp help file (.hlp) to have context sensitive help, they must be correctly associated with each other. The VB program program must know the path and filename of the help file and it must know the ContextIDs of the various topics it wishes to jump to. Earlier versions of VB do not support all these features (i.e. WhatsThisHelp)

In these examples replace nnn with the Author-it Object Code. As a general rule the Author-it Object Code is ideal for linking to WinHelp files. If ContextIDs have been already been set within the program, you will need to modify the linking settings for those topics which need ContextIDs different to their Object Codes.

Associate the VB project with a help file.

This is usually done in your Sub Main() or primary Form_Load event, as follows:


    App.HelpFile = App.Path & "\MyHelpFile.hlp"

To set a ContextID for a VB Form or Control:


    frmMain.HelpContextID = nnn
    frmMain.cmdOK.HelpContextID = nnn

Whats This Help?

If you wish to have "Whats this Help" you can turn on the WhatsThisHelp and WhatsThisHelpButton. You may also need to turn off some of the other (minimize/maximize) buttons as you're limited to three buttons along the top of a form.


    frmWizard.WhatsThisHelp = True
    frmWizard.WhatsThisButton = True

Then, for each control on the form set the following property:

    frmWizard.cboFileType.WhatsThisHelpID = nnn

Create a Help menu

  • Create a menu (the example is called mnuHelpContents), associate this menu with the F1 key.
  • Create a CommonDialog control on your main form (the example is called cdlgHelp).
  • Add the following code to the form:

    Private Sub mnuHelpContents_Click()    
        With cdlgHelp
            .HelpFile = App.Path & "\MyHelpFile.hlp"
            .HelpCommand = cdlHelpContents
            .ShowHelp
        End With
    End Sub

Note: The HelpCommand has several different settings which produce different results when displaying the WinHelp file.

As a minimum you should set a HelpContextID for every form and a WhatsThisHelpID for any controls that will likely require explanation.

Top of Page Email this Page Log Support Call Send Feedback Print