Results 1 to 5 of 5

Thread: Opening a help file.

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2001
    Location
    The Dark Side of the Moon
    Posts
    448

    Opening a help file.

    How do I open a help file at a certain topic or content section of it with a command button? Here's my code thus far. It opens the help file, but I want to jump to a certain spot. I'm doing this in Access too, if that makes a difference. (Likely not)


    Code:
    Private 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
    
    Private Const HELP_CONTENTS = &H3&
    Private Const HELP_QUIT = &H2
    
    Option Compare Database
    Option Explicit
    
    Private Function DBPath() As String
        Dim strDBPath As String
        Dim strDBFile As String
        
        strDBPath = CurrentDb.Name
        strDBFile = Dir(strDBPath)
        DBPath = Left(strDBPath, Len(strDBPath) - Len(strDBFile))
    End Function
    Private Function FileExists(ByVal FileName As String) As Boolean
        If Dir(FileName) = "" Then
            FileExists = False
        Else
            FileExists = True
        End If
    End Function
    
    Private Sub Command0_Click()
        Dim strHelpFile As String
        
        strHelpFile = DBPath & "LegalTracking.hlp"
        
        If FileExists(strHelpFile) Then
            WinHelp Me.hwnd, strHelpFile, HELP_CONTENTS, 0
        Else
            MsgBox "Could not locate help file.  Try contacting your database administrator.", vbOKOnly, "Unable to locate help file."
        End If
    End Sub

  2. #2
    jim mcnamara
    Guest
    Here is some MSDN sample code with a lot of comments:

    http://support.microsoft.com/support.../Q121/1/15.ASP


    Here is what www.allapi.net has:

    Code:
    Const HELP_COMMAND = &H102&
    Const HELP_CONTENTS = &H3&
    Const HELP_CONTEXT = &H1
    Const HELP_CONTEXTPOPUP = &H8&
    Const HELP_FORCEFILE = &H9&
    Const HELP_HELPONHELP = &H4
    Const HELP_INDEX = &H3
    Const HELP_KEY = &H101
    Const HELP_MULTIKEY = &H201&
    Const HELP_PARTIALKEY = &H105&
    Const HELP_QUIT = &H2
    Const HELP_SETCONTENTS = &H5&
    Const HELP_SETINDEX = &H5
    Const HELP_SETWINPOS = &H203&
    Private Declare Function WinHelp Lib "user32.dll" Alias "WinHelpA" (ByVal hWndMain As Long, ByVal lpHelpFile As String, ByVal uCommand As Long, dwData As Any) As Long
    Private Sub Form_Load()
        'KPD-Team 2000
        'URL: http://www.allapi.net/
        'E-Mail: [email protected]
        WinHelp Me.hwnd, "C:\Windows\help\common.hlp", HELP_CONTENTS, ByVal 0
    End Sub

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2001
    Location
    The Dark Side of the Moon
    Posts
    448
    Thanks a lot there buddy. I needed to use the

    HELP_CONTEXT constant

    and it's the topic ID. Works great now.

  4. #4
    Megatron
    Guest
    If you don't need to show a specific context ID, you could just shell WinHelp like:
    Code:
    Shell "WinHelp MyHelpFile.hlp", 1

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2001
    Location
    The Dark Side of the Moon
    Posts
    448
    I think you missed the point, but thanks for contributing though.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width