用VB编了一个应用程序,帮助文件如何调用?

accp258 2003-08-23 02:24:20
做了一个应用程序,同时也做了自己的帮且文件,在主窗体上有一个帮助菜单,如何实现当点击帮助菜单的时候调出.chm这样格式的帮助文件?
...全文
33 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
shawls 2003-08-23
  • 打赏
  • 举报
回复
[名称] 添加HtmlHelp到工程

[语言种类] Visual Basic

[类别一] 窗体

[类别二] 界面

[类别三] 各种技巧

[数据来源] 未知

[保存时间] 2002-11-23

[关键字一] 添加帮助

[关键字二] 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 (.chm) 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)

'------------------
'or this
iRetCode = HtmlHelpLongArg(Me.hWnd,MYHELP_FILE,0,0)
'---------------------

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 the 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 sub

Private Sub MeuHelpFile_Click() '帮助主题-菜单
Dim Hlp As Long
Hlp = WinHelp(MainForm.hwnd, App.HelpFile, HELP_FINDER, CLng(0))
End Sub

方法3:

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

ShellExecute Me.hwnd, "open", "mychm.chm", "", "", vbNormalFocus


方法4:

Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long

Function GetWinPath() As String
Dim S As String * 250, Length As Long
Length = GetWindowsDirectory(S, Len(S))
GetWinPath = Left(S, Length)
End Function

Shell GetWinPath() & "\hh.exe mtchm.chm", vbNormalFocus


rainstormmaster 2003-08-23
  • 打赏
  • 举报
回复
App.HelpFile="yourhelpfile.hlp"
sendkeys "{F1}"
txlicenhe 2003-08-23
  • 打赏
  • 举报
回复
App.HelpFile="yourhelpfile.hlp"
程序中按F1即可调用。
woxihuanbohe 2003-08-23
  • 打赏
  • 举报
回复
App.HelpFile="yourhelpfile.hlp"
射天狼 2003-08-23
  • 打赏
  • 举报
回复
Public 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 Sub mnuHelps_Click()
On Error GoTo Errhandle
ShellExecute Me.hwnd, "open", IIf(Right(App.Path, 1) = "\", App.Path, App.Path & "\") & "REFERHELP.chm", vbNullString, vbNullString, 1

Exit Sub
Errhandle:
MsgBox Err.Description, vbExclamation
End Sub

7,762

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧