The following example demonstrates several help commands. To try the example, place a CommonDialog control and five CommandButton controls on a form. Paste the code into the Declarations section, press F5 and click each button.
Option Explicit
Const HelpCNT = &HB
Private Sub Command1_Click()
With CommonDialog1
' You must set the Help file name.
.HelpFile = "VB5.hlp"
' Display the Table of Contents. Note that the
' HelpCNT contstant is not an intrinsic
' constant. The cdlHelpSetContents ensures that
' only the Table of Contents (not Index or Find)
' shows.
.HelpCommand = HelpCNT Or cdlHelpSetContents
.ShowHelp
End With
End Sub
Private Sub Command2_Click()
With CommonDialog1
.HelpFile = "VB5.hlp"
' Go to the Click Event topic in the Help file.
' The number is determined in the [MAP] section
' of the .HPJ file for the .chm file. You can
' edit this number only if you are using the
' Microsoft Help Workshop to build your
' own Help file.
.HelpContext = 916302
.HelpCommand = cdlHelpContext
.ShowHelp
End With
End Sub
Private Sub Command3_Click()
With CommonDialog1
.HelpFile = "VB5.hlp"
' Display help on Help.
.HelpCommand = cdlHelpHelpOnHelp
.ShowHelp
End With
End Sub
Private Sub Command4_Click()
With CommonDialog1
.HelpFile = "VB5.hlp"
.HelpKey = "data"
' Display the Index with the keyword selected.
.HelpCommand = cdlHelpKey
.ShowHelp
End With
End Sub
Private Sub Command5_Click()
With CommonDialog1
.HelpFile = "VB5.hlp"
.HelpKey = "arrays,"
' Display a list of topics found with
' the HelpKey.
.HelpCommand = cdlHelpPartialKey
.ShowHelp
End With
End Sub
Private Sub Form_Load()
' Label the CommandButton controls.
Command1.Caption = "Contents"
Command2.Caption = "Specified Topic"
Command3.Caption = "Help On Help"
Command4.Caption = "Index of Topics"
Command5.Caption = "Found Topics"
End Sub