http://www.educity.cn/help/zt/vb/
http://www.newxing.com/Code/Book/VB/254.html#download
几种在程序中调用CHM帮助文件的方法。
这种方法最简单,只需如下代码即可:
Private Sub Form_Load()
App.HelpFile = app.path & "\help.chm" '调用与主程序同目录下的help.chm帮助文件,按F1键调用
End Sub
Private Sub Form_Load()
App.HelpFile = app.path & "\help.chm"
End Sub
private Sub CmdHelp_Click()
SendKeys "{F1}" '发送击键到活动窗口
End Sub
private Sub CmdHelp_Click()
Shell "hh.exe help.chm", vbNormalFocus 'help.chm为指定的帮助文件,可包含路径。
End Sub
先声明如下API:
Option Explicit
Private Declare Function HtmlHelpA Lib "hhctrl.ocx"
(ByVal hwndCaller As Long, ByVal pszFile As String,
ByVal uCommand As Long, ByVal dwData As Long) As Long
其中,hwndCaller指定调用者的窗口,pszFile指定要调用的文件,uCommand是发送给HtmlHelp的命令,dwData是uCommand的参数。
然后在过程中调用:
private Sub CmdHelp_Click()
dim i as string
i = app.path & "\help.chm" '用变量i记录与主程序同目录下的help.chm帮助文件
HtmlHelpA Form1.hWnd, i, 0, 0软件开发网www.mscto.com
End Sub
先声明如下API:
Option Explicit
'声明API函数用于异步打开一个文档
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA"
(ByVal hwnd As Long, ByVal lpOperation As String,
ByVal lpFile As String, ByVal lpParameters As String,
ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Const SW_SHOWNORMAL = 1
然后在过程中调用:
private Sub CmdHelp_Click()
dim a as long
Dim b As String
b = App.Path & "\help.chm" '用变量b记录与主程序同目录下的help.chm帮助文件
a = ShellExecute (0, "open", b, "", "", SW_SHOWNORMAL)
End Sub
以上五种方法各有优缺点,从代码的简单上讲,建议使用第二种方法。从功能上讲,建议使用第五种方法,因其不只用于打开CHM帮助文件,还可用同样的格式打开、打印或查找一个文件或文档(参见该API的说明资料)。