VBGood网站全文搜索 Google

首页 - 经验之谈 - 调用html格式的帮助
发表评论(0)作者:不详, 平台:VB6.0+Win98, 阅读:12471, 日期:2001-04-17
Launching HTML Help

Need to launch a HTML help file direct from your application?

This sneaky code snippet handles it all for you, opening at just the right topic. It will also close the help file when the launching application quits.

To use, call our LaunchHTMLHelp function, passing the path of your help file, an optional window handle (such as Form1.hWnd - when this is closed, the help file also closes), plus an optional help file topic number.

The function returns a True or False success value.

Sample Usage

x = LaunchHTMLHelp("c:\myhelp.chm", Form1.hWnd, 5124)Code

Public Const HH_DISPLAY_TOPIC = &H0
Public Const HH_HELP_CONTEXT = &HF

Public 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

Public Function LaunchHTMLHelp(HelpFile As String, _
    Optional WindowHandle As Long, Optional Topic As Long) As Boolean

    注释:HelpFile - the path to your HTML help file.
    注释:WindowHandle - an optional handle to the window
    注释:               that the help stems from. When
    注释:               that window is closed, help will
    注释:               also close (only when compiled).
    注释:Topic - the help topic number you wish to call from
    注释:        your help file, if any. AKA context number.

    Dim lngReturn As Long

    If Len(Dir(HelpFile)) > 0 Then
        If Topic = 0 Then
            lngReturn = HtmlHelp(WindowHandle, HelpFile, HH_DISPLAY_TOPIC, 0)
            lngReturn = HtmlHelp(WindowHandle, HelpFile, HH_HELP_CONTEXT, Topic)
        End If
        LaunchHTMLHelp = CBool(lngReturn)
    End If

End Function