Implement chm Help in Visual Basic

By | 2019-09-25

Give your app a more polished appearance by using .chm files for your help system.

First place a existing chm File in the project path. You must know what name your htm pages have to work correct.

Module

Option Explicit
Private Declare Function HtmlHelpTopic Lib "hhctrl.ocx" Alias _
    "HtmlHelpA" (ByVal hWnd As Long, ByVal lpHelpFile As String, _
    ByVal wCommand As Long, ByVal dwData As String) As Long

Sub ShowHtmlHelp(ByVal tHelpFile As String, ByVal tHelpPage As String)
    Const HH_DISPLAY_TOPIC =3D &H0
    On Error Resume Next
    ' open the help page in a modeless window
    HtmlHelpTopic 0, tHelpFile, HH_DISPLAY_TOPIC, tHelpPage
End Sub

Usage

Put a command button to your form and name it cmdHelp

Private Sub cmdHelp_Click()
    'This is only a example
    ShowHtmlHelp App.path & "\MyHelp.chm", "Introduction.htm"
End Sub

Author: dwirch

Derek Wirch is a seasoned IT professional with an impressive career dating back to 1986. He brings a wealth of knowledge and hands-on experience that is invaluable to those embarking on their journey in the tech industry.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.