Declare Function HtmlHelp Lib "hhctrl.ocx" Alias "HtmlHelpA" _
(ByVal hwndCaller As Long, ByVal pszFile As String, _
ByVal uCommand As Long, ByVal dwData As Long) As Long
Const HH_DISPLAY_TOPIC = &H0
Const HH_SET_WIN_TYPE = &H4
Const HH_GET_WIN_TYPE = &H5
Const HH_GET_WIN_HANDLE = &H6
Const HH_DISPLAY_TEXT_POPUP = &HE ' Display string resource ID or
' text in a pop-up window.
Const HH_HELP_CONTEXT = &HF ' Display mapped numeric value in
' dwData.
Const HH_TP_HELP_CONTEXTMENU = &H10 ' Text pop-up help, similar to
' WinHelp's HELP_CONTEXTMENU.
Const HH_TP_HELP_WM_HELP = &H11 ' text pop-up help, similar to
' WinHelp's HELP_WM_HELP.Private Sub Command1_Click()
'hWnd is a Long defined elsewhere to be the window handle
'that will be the parent to the help window.
Dim ssapp As String
Dim hwndHelp As Long
ssapp = App.Path & "\help.chm"
'The return value is the window handle of the created help window.
hwndHelp = HtmlHelp(hWnd, ssapp, HH_DISPLAY_TOPIC, 0)End Sub
(ByVal hwndCaller As Long, ByVal pszFile As String, _
ByVal uCommand As Long, ByVal dwData As Long) As Long
Const HH_DISPLAY_TOPIC = &H0
Const HH_SET_WIN_TYPE = &H4
Const HH_GET_WIN_TYPE = &H5
Const HH_GET_WIN_HANDLE = &H6
Const HH_DISPLAY_TEXT_POPUP = &HE ' Display string resource ID or
' text in a pop-up window.
Const HH_HELP_CONTEXT = &HF ' Display mapped numeric value in
' dwData.
Const HH_TP_HELP_CONTEXTMENU = &H10 ' Text pop-up help, similar to
' WinHelp's HELP_CONTEXTMENU.
Const HH_TP_HELP_WM_HELP = &H11 ' text pop-up help, similar to
' WinHelp's HELP_WM_HELP.Private Sub Command1_Click()
'hWnd is a Long defined elsewhere to be the window handle
'that will be the parent to the help window.
Dim ssapp As String
Dim hwndHelp As Long
ssapp = App.Path & "\help.chm"
'The return value is the window handle of the created help window.
hwndHelp = HtmlHelp(hWnd, ssapp, HH_DISPLAY_TOPIC, 0)End Sub
显示一个主题的帮助内容,点击Command2,显示另一个主题的帮助内容?
#define <帮助页主题> <ID编码>
...
每行定义一个,编译帮助文件时使用该头文件。
在VB中调用帮助时指定<ID编码>即可。
shell "hh.exe " & "c:\cch.chm"
Call ShellExecute(hwnd, "open", "帮助文件名", "", App.Path, 1)