Here you go:
First Create your chm file (i persume you know how)
Then Create a new .bas module, i call it modHelpFiles.bas
Here is sample code:
'================================================= =====
'Module Start:
'================================================= =====
Option Explicit
Declare Function HtmlHelp Lib "HHCtrl.ocx" Alias "HtmlHelpA" _
(ByVal hwndCaller As Long, _
ByVal pszFile As String, _
ByVal uCommand As Long, _
dwData As Any) As Long
'Add these they are defaults:
Public Const HH_DISPLAY_TOPIC = &H0
Public Const HH_HELP_CONTEXT = &HF
'This is your own constants for defining each helpfile name
'Note that the helpfile name i.e. "Allocations" is the actual
'name of the html file added to the chm project.
'If you selected that chm must compile the folders then it's
'critical to also add the folder before the name
'i.e. \UserInformation\UserSetupPage or as done in the function
'Showhelp below it makes it "HTML_Files\" & file name & ".html"
Public Const HF_ALLOCATIONS = "Allocations"
Public Const HF_ACCOUNTS = "Accounts"
Public Const HF_LOGIN = "Login"
'/~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~
Public Sub ShowHelpFile(ByVal strFileName As String)
'/~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~
On Error GoTo ShowHelpFile_ERR
Call HtmlHelp(0, App.Path & "\MyAppName.chm", HH_DISPLAY_TOPIC, _
ByVal "HTML_FILES\" & strFileName & ".htm")
Exit Sub
ShowHelpFile_ERR:
MsgBox "[" & Err.Number & "] " & _
Err.Description, vbInformation, "ShowHelpFile - Error"
End Sub
'================================================= ==
'End Of Module
'================================================= ==
in the form at the help_button its very easy
just add this line of code:
Call ShowHelpFile(HF_LOGIN)
Note HF_Login refers the the file i want displayed.
Regards and shout if you need more help
Helga Anagnostopoulos
|