添加HtmlHelp到工程Create a new project, Form1 is created by default. Add a few controls to the
form.
Add a module to the project, and add the following constants to the declarat
ion section of the module:
Public Const HH_HELP_CONTEXT = &HF
Public Const MYHELP_FILE = "myfile.chm"
NOTE: "myfile.chm" is the path and name of the HTML Help file (.ch
m) you created earlier.
Add the following HTML Help API declaration to the module:
Public Declare Function HtmlHelpLongArg Lib "hhctrl.ocx" _
Alias "HtmlHelpA" (ByVal hwndCaller As Long, _
ByVal pszFile As String, ByVal uCommand As Long, _
ByVal dwData As Long) As Long
Intercept the form's KeyUp method to capture the F1 key using the following
sample code in the Form KeyUp event procedure:
Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
dim iRetCode As Long
If KeyCode = vbKeyF1 Then
iRetCode = HtmlHelpLongArg(Me.ActiveControl.hWnd,_
MYHELP_FILE,HH_HELP_CONTEXT,Me.ActiveControl.HelpContextID)
End If
End Sub
Set the form's KeyPreview, WhatsThisHelp, and WhatsThisButton properties to
TRUE.
Set the HelpContextID property of each control on the form to a value from t
he help project file's MAP section.
方法二:Public Declare Function WinHelp Lib "user32" Alias "WinHelpA" (ByVal hwnd As Long, ByVal lpHelpFile As String, ByVal wCommand As Long, ByVal dwData As Long) As Long
Public Const HELP_FINDER = &HB&Private Sub Form_Load() '主窗体载入
App.HelpFile = App.Path & "\help\*.HLP" '帮助文件
end subPrivate Sub MeuHelpFile_Click() '帮助主题-菜单
Dim Hlp As Long
Hlp = WinHelp(MainForm.hwnd, App.HelpFile, HELP_FINDER, CLng(0))
End Sub
以上代码来自: SourceCode Explorer(源代码数据库)
复制时间: 2002-06-12 18:03:47
当前版本: 1.0.705
作者: Shawls
个人主页: Http://Shawls.Yeah.Net
E-Mail: [email protected]
QQ: 9181729
form.
Add a module to the project, and add the following constants to the declarat
ion section of the module:
Public Const HH_HELP_CONTEXT = &HF
Public Const MYHELP_FILE = "myfile.chm"
NOTE: "myfile.chm" is the path and name of the HTML Help file (.ch
m) you created earlier.
Add the following HTML Help API declaration to the module:
Public Declare Function HtmlHelpLongArg Lib "hhctrl.ocx" _
Alias "HtmlHelpA" (ByVal hwndCaller As Long, _
ByVal pszFile As String, ByVal uCommand As Long, _
ByVal dwData As Long) As Long
Intercept the form's KeyUp method to capture the F1 key using the following
sample code in the Form KeyUp event procedure:
Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
dim iRetCode As Long
If KeyCode = vbKeyF1 Then
iRetCode = HtmlHelpLongArg(Me.ActiveControl.hWnd,_
MYHELP_FILE,HH_HELP_CONTEXT,Me.ActiveControl.HelpContextID)
End If
End Sub
Set the form's KeyPreview, WhatsThisHelp, and WhatsThisButton properties to
TRUE.
Set the HelpContextID property of each control on the form to a value from t
he help project file's MAP section.
方法二:Public Declare Function WinHelp Lib "user32" Alias "WinHelpA" (ByVal hwnd As Long, ByVal lpHelpFile As String, ByVal wCommand As Long, ByVal dwData As Long) As Long
Public Const HELP_FINDER = &HB&Private Sub Form_Load() '主窗体载入
App.HelpFile = App.Path & "\help\*.HLP" '帮助文件
end subPrivate Sub MeuHelpFile_Click() '帮助主题-菜单
Dim Hlp As Long
Hlp = WinHelp(MainForm.hwnd, App.HelpFile, HELP_FINDER, CLng(0))
End Sub
以上代码来自: SourceCode Explorer(源代码数据库)
复制时间: 2002-06-12 18:03:47
当前版本: 1.0.705
作者: Shawls
个人主页: Http://Shawls.Yeah.Net
E-Mail: [email protected]
QQ: 9181729
HtmlHelp函数VB声明如下(API浏览器中没有,我自己照VC的声明改的): 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的参数。 这个函数位于system\hhctrl.ocx中,你安装了IE4以上版本浏览器就应该有 调用举例: HtmlHelpA Form1.hWnd, "C:\WINDOWS\HELP\CALC.CHM", 0, 0 这个是
最简单的例子,uCommand和dwData的组合能产生许多非常复杂的功能具体情况可
查找MSDN:HTMLHelp API Reference主题 函数的C语言原型和所用到的结构和常量定义参见HTML Help Workshop\include\
htmlhelp.h 当然你必须先安装了Html Help Workshop hhctrl.ocx文件虽然后缀是OCX却不是控件,而是一个标准的DLL 林夕: 我有点不明白,VB中好象可以直接调用*.chm嘛,如下例,有什么不妥吗?请各位
大虾指正。 Private Sub Form_Load()
App.HelpFile = "c:\a\a.chm" 注释:如不指明路径,默认为Windows目录下的Help
Me.HelpContextID = 10001
End Sub Private Sub Command1_Click()
SendKeys "{F1}" 注释:按F1键,系统自动调用帮助
End Sub hmg: 我用一个小程序试验了一下 form_load()
app.helpfile="c:\1.chm" 注释:文件名是1.chm
end sub ......._click()
cd1.helpfile="c:\1.hlp" 注释:cd1是公用对话框,我故意写成1.hlp
cd1.helpcommand=&h3
cd1.showhelp
end
以上程序居然能成功,莫名其妙可是在我的大程序里,就不那末顺利,奇怪? 一个偶然的机会我发现 windows目录下的hh.exe可以调用chm的帮助,因此我想到可以用shell语句, .........
shell "hh.exe 1.chm,.......
.......... hh.exe可以拷到任一目录下执行.
HtmlHelp函数VB声明如下(API浏览器中没有,我自己照VC的声明改的): 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的参数。 这个函数位于system\hhctrl.ocx中,你安装了IE4以上版本浏览器就应该有 调用举例: HtmlHelpA Form1.hWnd, "C:\WINDOWS\HELP\CALC.CHM", 0, 0 这个是
最简单的例子,uCommand和dwData的组合能产生许多非常复杂的功能具体情况可
查找MSDN:HTMLHelp API Reference主题 函数的C语言原型和所用到的结构和常量定义参见HTML Help Workshop\include\
htmlhelp.h 当然你必须先安装了Html Help Workshop hhctrl.ocx文件虽然后缀是OCX却不是控件,而是一个标准的DLL 林夕: 我有点不明白,VB中好象可以直接调用*.chm嘛,如下例,有什么不妥吗?请各位
大虾指正。 Private Sub Form_Load()
App.HelpFile = "c:\a\a.chm" 注释:如不指明路径,默认为Windows目录下的Help
Me.HelpContextID = 10001
End Sub Private Sub Command1_Click()
SendKeys "{F1}" 注释:按F1键,系统自动调用帮助
End Sub hmg: 我用一个小程序试验了一下 form_load()
app.helpfile="c:\1.chm" 注释:文件名是1.chm
end sub ......._click()
cd1.helpfile="c:\1.hlp" 注释:cd1是公用对话框,我故意写成1.hlp
cd1.helpcommand=&h3
cd1.showhelp
end
以上程序居然能成功,莫名其妙可是在我的大程序里,就不那末顺利,奇怪? 一个偶然的机会我发现 windows目录下的hh.exe可以调用chm的帮助,因此我想到可
以用shell语句, .........
shell "hh.exe 1.chm,.......
.......... hh.exe可以拷到任一目录下执行.
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 首先当然是要在工程中加入上面的声明,然后编辑工程的菜单,在“帮助”菜单的CLICK方法中加入以下的代码: htmlhelp HWND,“MY.CHM”,0,0 运行工程后,选择“帮助”菜单就可以显示HTML帮助文件了。
用 Shell 不行吗?
要是不行的话,确实很累!
用Shell//Open就可以了呀
Public Sub ShellEx(ByVal sLocation As String)
Dim lR As Long
lR = ShellExecute(Main.hwnd, "open", sLocation, "", "", 1)
If (lR < 0) Or (lR > 32) Then
Else
MsgBox "Sorry, I could not go to " & sLocation & ".", vbInformation
End If
End Sub
ShellEx "C:\xxx.chm"
'------- or ---------
ShellEx "C:\xxx.hlp"
如何在chm中设置上下文帮助ID?
如何在chm中设置上下文帮助ID?